Skip to content

Commit

Permalink
update the invoice number rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
abdellani authored and sigmundpetersen committed Dec 8, 2023
1 parent 41d5ca7 commit fea910f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions app/models/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ def serialize_order
def cancel_previous_invoices
order.invoices.where.not(id:).update_all(cancelled: true)
end

def display_number
"#{order.distributor.id}-#{number}"
end
end
4 changes: 2 additions & 2 deletions app/models/invoice/data_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ class DataPresenter
include ::ActionView::Helpers::NumberHelper
attr_reader :invoice

delegate :data, to: :invoice
delegate :number, :date, to: :invoice, prefix: true
delegate :display_number, :data, to: :invoice
delegate :date, to: :invoice, prefix: true

FINALIZED_NON_SUCCESSFUL_STATES = %w(canceled returned).freeze

Expand Down
2 changes: 1 addition & 1 deletion app/views/spree/admin/invoices/_invoices_table.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
%td.align-center.created_at
= invoice.presenter.display_date
%td.align-center.label
= invoice.number
= invoice.display_number
%td.align-center.label
= invoice.presenter.total
%td.align-center.label
Expand Down
2 changes: 1 addition & 1 deletion app/views/spree/admin/orders/invoice4.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
%td{ :align => "left" }
%br
= "#{t :invoice_number}:"
= @order.invoice_number
= @order.display_number
%br
= t :invoice_issued_on
= l @order.invoice_date
Expand Down

0 comments on commit fea910f

Please sign in to comment.