From ca424c4df3549d7d5e855dc713a34a3bf0d61125 Mon Sep 17 00:00:00 2001 From: Mohamed ABDELLANI Date: Tue, 24 Oct 2023 09:10:44 +0100 Subject: [PATCH] update the invoice v3 template --- .../spree/admin/orders/invoice4.html.haml | 2 ++ config/locales/en.yml | 1 + spec/system/admin/invoice_print_spec.rb | 34 +++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/app/views/spree/admin/orders/invoice4.html.haml b/app/views/spree/admin/orders/invoice4.html.haml index 69c8ec9e8f9d..bf7eee3679e7 100644 --- a/app/views/spree/admin/orders/invoice4.html.haml +++ b/app/views/spree/admin/orders/invoice4.html.haml @@ -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 diff --git a/config/locales/en.yml b/config/locales/en.yml index f512b2b9b36a..6911805807c9 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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:" diff --git a/spec/system/admin/invoice_print_spec.rb b/spec/system/admin/invoice_print_spec.rb index 24649c98ce34..f98c6e4390c3 100644 --- a/spec/system/admin/invoice_print_spec.rb +++ b/spec/system/admin/invoice_print_spec.rb @@ -661,6 +661,40 @@ expect(page).to have_content "Total (Excl. tax): $1,733.54" 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