update the invoice v3 template

This commit is contained in:
Mohamed ABDELLANI
2023-10-24 09:10:44 +01:00
parent 615c001c28
commit 915afd8557
3 changed files with 36 additions and 0 deletions

View File

@@ -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

View File

@@ -1991,6 +1991,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:"

View File

@@ -662,6 +662,39 @@ describe '
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