Skip to content

Commit

Permalink
render the shipping category in the invoice.
Browse files Browse the repository at this point in the history
  • Loading branch information
abdellani committed Dec 11, 2023
1 parent f6ba2dc commit 5224931
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
4 changes: 4 additions & 0 deletions app/models/invoice/data_presenter/shipping_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions app/views/spree/admin/orders/_invoice_table4.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down
3 changes: 2 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1993,7 +1993,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:"
Expand Down
6 changes: 2 additions & 4 deletions spec/system/admin/invoice_print_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 5224931

Please sign in to comment.