From db653fc945e2123845471ba4dd1bca9abdb81d17 Mon Sep 17 00:00:00 2001 From: Mohamed ABDELLANI Date: Mon, 13 Nov 2023 10:18:10 +0100 Subject: [PATCH 1/3] 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 2d9ba86015..ed80c9ffa0 100644 --- a/app/models/invoice/data_presenter/shipping_method.rb +++ b/app/models/invoice/data_presenter/shipping_method.rb @@ -5,6 +5,10 @@ class Invoice 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 ffd413a4c9..6ec2fc0170 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 08cfddd3b9..9926da47b1 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1996,7 +1996,8 @@ en: invoice_cancel_and_replace_invoice: "cancels and replaces invoice" 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 5e51aae36b..cdd126e208 100644 --- a/spec/system/admin/invoice_print_spec.rb +++ b/spec/system/admin/invoice_print_spec.rb @@ -546,8 +546,7 @@ describe ' 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 @@ describe ' 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" From 82d50f58f391a16b3d396c47abc1a7d8fa0afbee Mon Sep 17 00:00:00 2001 From: Mohamed ABDELLANI Date: Mon, 11 Dec 2023 08:32:48 +0100 Subject: [PATCH 2/3] remove raw from shipping method name --- app/views/spree/admin/orders/_invoice_table4.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/spree/admin/orders/_invoice_table4.html.haml b/app/views/spree/admin/orders/_invoice_table4.html.haml index 6ec2fc0170..d8527c8c29 100644 --- a/app/views/spree/admin/orders/_invoice_table4.html.haml +++ b/app/views/spree/admin/orders/_invoice_table4.html.haml @@ -38,7 +38,7 @@ %tr %td %strong= "#{@order.shipping_method.category} : " - = "(#{raw(@order.shipping_method.name)})" + = "(#{@order.shipping_method.name})" %td{:align => "right"} %td{:align => "right"} %td{:align => "right"} From 2b1d7923dac22bd568219a813d5d189cd1ddca8a Mon Sep 17 00:00:00 2001 From: Mohamed ABDELLANI Date: Thu, 14 Dec 2023 16:20:59 +0100 Subject: [PATCH 3/3] remove ':' after the shipping category on the invoice template --- app/views/spree/admin/orders/_invoice_table4.html.haml | 2 +- spec/system/admin/invoice_print_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/spree/admin/orders/_invoice_table4.html.haml b/app/views/spree/admin/orders/_invoice_table4.html.haml index d8527c8c29..82a7c57d28 100644 --- a/app/views/spree/admin/orders/_invoice_table4.html.haml +++ b/app/views/spree/admin/orders/_invoice_table4.html.haml @@ -37,7 +37,7 @@ = item.display_amount_with_adjustments_and_with_taxes %tr %td - %strong= "#{@order.shipping_method.category} : " + %strong= "#{@order.shipping_method.category} " = "(#{@order.shipping_method.name})" %td{:align => "right"} %td{:align => "right"} diff --git a/spec/system/admin/invoice_print_spec.rb b/spec/system/admin/invoice_print_spec.rb index cdd126e208..790db07849 100644 --- a/spec/system/admin/invoice_print_spec.rb +++ b/spec/system/admin/invoice_print_spec.rb @@ -546,7 +546,7 @@ describe ' 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 "Delivery :(#{shipping_method_name}) $91.41 10.0% $100.55" + 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" @@ -649,7 +649,7 @@ describe ' 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 "Delivery :(#{shipping_method_name}) $100.55 10.0% $110.61" + 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"