-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
spree 4.7 #161
base: master
Are you sure you want to change the base?
spree 4.7 #161
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module SpreePrintInvoice | ||
module Admin | ||
module MainMenu | ||
class PrintInvoiceBuilder | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/Documentation: Missing top-level class documentation comment. |
||
include ::Spree::Core::Engine.routes.url_helpers | ||
|
||
def build | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/AbcSize: Assignment Branch Condition size for build is too high. [21.02/15] |
||
items = [ | ||
::Spree::Admin::MainMenu::ItemBuilder.new('invoices', ::Spree::Core::Engine.routes.url_helpers.admin_bookkeeping_documents_path(q: { template_eq: 'invoice' })). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/LineLength: Line is too long. [172/80] |
||
with_label_translation_key('admin.invoices'). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/DotPosition: Place the . on the next line, together with the method name. |
||
with_manage_ability_check(::Spree::BookkeepingDocument). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/DotPosition: Place the . on the next line, together with the method name. |
||
with_match_path('/bookkeeping_documents?q%5Btemplate_eq%5D=invoice'). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/LineLength: Line is too long. [83/80] |
||
build, | ||
::Spree::Admin::MainMenu::ItemBuilder.new('packaging_slips', ::Spree::Core::Engine.routes.url_helpers.admin_bookkeeping_documents_path(q: { template_eq: 'packaging_slip' })). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/LineLength: Line is too long. [186/80] |
||
with_label_translation_key('admin.packaging_slips'). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/DotPosition: Place the . on the next line, together with the method name. |
||
with_manage_ability_check(::Spree::BookkeepingDocument). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/DotPosition: Place the . on the next line, together with the method name. |
||
with_match_path('/bookkeeping_documents?q%5Btemplate_eq%5D=packaging_slip'). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/LineLength: Line is too long. [90/80] |
||
build | ||
] | ||
|
||
::Spree::Admin::MainMenu::SectionBuilder.new('documents', 'file.svg'). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/DotPosition: Place the . on the next line, together with the method name. |
||
with_manage_ability_check(::Spree::BookkeepingDocument). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/MultilineMethodCallIndentation: Use 2 (not 4) spaces for indenting an expression spanning multiple lines. |
||
with_label_translation_key('admin.documents'). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/MultilineMethodCallIndentation: Use 2 (not 4) spaces for indenting an expression spanning multiple lines. |
||
with_items(items). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/MultilineMethodCallIndentation: Use 2 (not 4) spaces for indenting an expression spanning multiple lines. |
||
build | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/MultilineMethodCallIndentation: Use 2 (not 4) spaces for indenting an expression spanning multiple lines. |
||
end | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
module SpreePrintInvoice | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true. |
||
module Spree | ||
module OrderDecorator | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/Documentation: Missing top-level module documentation comment. |
||
def self.prepended(base) | ||
base.has_many :bookkeeping_documents, as: :printable, dependent: :destroy | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/LineLength: Line is too long. [81/80] |
||
base.has_one :invoice, -> { where(template: 'invoice') }, | ||
class_name: 'Spree::BookkeepingDocument', | ||
as: :printable | ||
base.has_one :packaging_slip, -> { where(template: 'packaging_slip') }, | ||
class_name: 'Spree::BookkeepingDocument', | ||
as: :printable | ||
|
||
base.delegate :number, :date, to: :invoice, prefix: true | ||
|
||
# Create a new invoice before transitioning to complete | ||
# | ||
base.state_machine.before_transition to: :complete, do: :invoice_for_order | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/LineLength: Line is too long. [82/80] |
||
end | ||
|
||
# Backwards compatibility stuff. Please don't use these methods, rather use the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/LineLength: Line is too long. [85/80] |
||
# ones on Spree::BookkeepingDocument | ||
# | ||
def pdf_file | ||
ActiveSupport::Deprecation.warn('This API has changed: Please use order.invoice.pdf instead') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/LineLength: Line is too long. [101/80] |
||
invoice.pdf | ||
end | ||
|
||
def pdf_filename | ||
ActiveSupport::Deprecation.warn('This API has changed: Please use order.invoice.file_name instead') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/LineLength: Line is too long. [107/80] |
||
invoice.file_name | ||
end | ||
|
||
def pdf_file_path | ||
ActiveSupport::Deprecation.warn('This API has changed: Please use order.invoice.pdf_file_path instead') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/LineLength: Line is too long. [111/80] |
||
invoice.pdf_file_path | ||
end | ||
|
||
def pdf_storage_path(template) | ||
ActiveSupport::Deprecation.warn('This API has changed: Please use order.{packaging_slip, invoice}.pdf_file_path instead') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/LineLength: Line is too long. [129/80] |
||
bookkeeping_documents.find_by!(template: template).file_path | ||
end | ||
|
||
def invoice_for_order | ||
bookkeeping_documents.create(template: 'invoice') | ||
bookkeeping_documents.create(template: 'packaging_slip') | ||
end | ||
end | ||
end | ||
end | ||
|
||
::Spree::Order.prepend ::SpreePrintInvoice::Spree::OrderDecorator |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Rails.application.config.after_initialize do | ||
if Spree::Core::Engine.backend_available? | ||
Rails.application.config.spree_backend.main_menu.insert_after('dashboard', ::SpreePrintInvoice::Admin::MainMenu::PrintInvoiceBuilder.new.build) | ||
|
||
Rails.application.config.spree_backend.tabs[:order].add( | ||
::Spree::Admin::Tabs::TabBuilder.new(::Spree.t(:documents, scope: [:print_invoice]), ->(resource) { ::Spree::Core::Engine.routes.url_helpers.admin_order_bookkeeping_documents_path(resource) }). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/LineLength: Line is too long. [199/80] |
||
with_icon_key('file.svg'). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/DotPosition: Place the . on the next line, together with the method name. |
||
with_active_check. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/DotPosition: Place the . on the next line, together with the method name. |
||
build | ||
) | ||
|
||
Rails.application.config.spree_backend.main_menu.add_to_section('settings', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/IndentationConsistency: Inconsistent indentation detected. |
||
::Spree::Admin::MainMenu::ItemBuilder.new('print_invoice.settings', ::Spree::Core::Engine.routes.url_helpers.edit_admin_print_invoice_settings_path). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/AlignParameters: Align the parameters of a method call if they span more than one line. |
||
with_manage_ability_check(::Spree::BookkeepingDocument). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/DotPosition: Place the . on the next line, together with the method name. |
||
build | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/ClosingParenthesisIndentation: Align ) with (. |
||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.