Skip to content

Commit

Permalink
update the invoice v3 template
Browse files Browse the repository at this point in the history
  • Loading branch information
abdellani committed Nov 28, 2023
1 parent 2316a84 commit ff2fd99
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/views/spree/admin/orders/invoice4.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
%br
= "#{t :invoice_number}:"
= @order.display_number
- if @order.previous_invoice.present?
= "#{t :invoice_cancel_and_replace_invoice} #{ @order.previous_invoice.display_number}"
%br
= t :invoice_issued_on
= l @order.invoice_date
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1892,6 +1892,7 @@ en:
invoice_column_price_per_unit_without_taxes: "Price Per unit (Excl. tax)"
invoice_column_tax_rate: "Tax rate"
invoice_tax_total: "GST Total:"
invoice_cancel_and_replace_invoice: "cancels and replaces invoice"
tax_invoice: "TAX INVOICE"
tax_total: "Total tax (%{rate}):"
invoice_shipping_type: "Type:"
Expand Down
33 changes: 33 additions & 0 deletions spec/system/admin/invoice_print_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,39 @@
end
end
end
describe "Rendering previous invoice number" do
context "Order doesn't have previous invoices" do
it "should display the invoice number" do
login_as_admin
visit spree.print_admin_order_path(order, params: {})

convert_pdf_to_page
expect(page).to have_content "#{order.distributor_id}-#{order.invoices.first.number}"
end
end

context "Order has previous invoices" do
before do
OrderInvoiceGenerator.new(order).generate_or_update_latest_invoice
first_line_item = order.line_items.first
order.line_items.first.update(quantity: first_line_item.quantity + 1)
end

it "should display the invoice number along with the latest invoice number" do
login_as_admin
visit spree.print_admin_order_path(order, params: {})

expect(order.invoices.count).to eq(2)

new_invoice_number = "#{order.distributor_id}-#{order.invoices.first.number}"
canceled_invoice_number = "#{order.distributor_id}-#{order.invoices.last.number}"

convert_pdf_to_page
expect(page).to have_content "#{new_invoice_number} cancels and replaces invoice #{
canceled_invoice_number}"
end
end
end
end
end

Expand Down

0 comments on commit ff2fd99

Please sign in to comment.