From 830d1d0459683d429b402cb4f68ffe98bcdd689e Mon Sep 17 00:00:00 2001 From: Mohamed ABDELLANI Date: Mon, 13 Nov 2023 10:18:10 +0100 Subject: [PATCH] render the shipping category in the invoice. --- app/models/invoice/data_presenter/shipping_method.rb | 4 ++++ app/views/spree/admin/orders/_invoice_table4.html.haml | 4 ++-- config/locales/en.yml | 3 ++- spec/system/admin/invoice_print_spec.rb | 6 ++---- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/models/invoice/data_presenter/shipping_method.rb b/app/models/invoice/data_presenter/shipping_method.rb index 2d9ba860155c..ed80c9ffa023 100644 --- a/app/models/invoice/data_presenter/shipping_method.rb +++ b/app/models/invoice/data_presenter/shipping_method.rb @@ -5,6 +5,10 @@ class DataPresenter class ShippingMethod < Invoice::DataPresenter::Base attributes :id, :name, :require_ship_address invoice_generation_attributes :id + + def category + I18n.t "invoice_shipping_category_#{require_ship_address ? 'delivery' : 'pickup'}" + end end end end diff --git a/app/views/spree/admin/orders/_invoice_table4.html.haml b/app/views/spree/admin/orders/_invoice_table4.html.haml index ffd413a4c942..6ec2fc01704f 100644 --- a/app/views/spree/admin/orders/_invoice_table4.html.haml +++ b/app/views/spree/admin/orders/_invoice_table4.html.haml @@ -37,8 +37,8 @@ = item.display_amount_with_adjustments_and_with_taxes %tr %td - %strong= "#{t(:shipping)} " - = "( #{t(:invoice_shipping_type)} #{raw(@order.shipping_method.name)} )" + %strong= "#{@order.shipping_method.category} : " + = "(#{raw(@order.shipping_method.name)})" %td{:align => "right"} %td{:align => "right"} %td{:align => "right"} diff --git a/config/locales/en.yml b/config/locales/en.yml index f512b2b9b36a..08dfacb481d0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1894,7 +1894,8 @@ en: invoice_tax_total: "GST Total:" tax_invoice: "TAX INVOICE" tax_total: "Total tax (%{rate}):" - invoice_shipping_type: "Type:" + invoice_shipping_category_delivery: "Delivery" + invoice_shipping_category_pickup: "Pickup" total_excl_tax: "Total (Excl. tax):" total_incl_tax: "Total (Incl. tax):" total_all_tax: "Total tax:" diff --git a/spec/system/admin/invoice_print_spec.rb b/spec/system/admin/invoice_print_spec.rb index 24649c98ce34..f6e4f67661bd 100644 --- a/spec/system/admin/invoice_print_spec.rb +++ b/spec/system/admin/invoice_print_spec.rb @@ -546,8 +546,7 @@ expect(page).to have_content "#{enterprise_fee.name} fee by $104.35 15.0% $120.00" expect(page).to have_content "coordinator #{user1.enterprises.first.name}" # Shipping - expect(page).to have_content "Shipping ( Type: $91.41 10.0% $100.55" - expect(page).to have_content "#{shipping_method_name} )" + expect(page).to have_content "Delivery :(#{shipping_method_name}) $91.41 10.0% $100.55" # Tax totals expect(page).to have_content "Total tax (10.0%): $9.14 " \ "Total tax (15.0%): $15.65 Total tax (20.0%): $250.08" @@ -650,8 +649,7 @@ expect(page).to have_content "#{enterprise_fee.name} fee by $120.00 15.0% $138.00" expect(page).to have_content "coordinator #{user1.enterprises.first.name}" # Shipping - expect(page).to have_content "Shipping ( Type: $100.55 10.0% $110.61" - expect(page).to have_content "#{shipping_method_name} )" + expect(page).to have_content "Delivery :(#{shipping_method_name}) $100.55 10.0% $110.61" # Tax totals expect(page).to have_content "Total tax (10.0%): $10.06 " \ "Total tax (15.0%): $18.00 Total tax (20.0%): $300.09"