From 72df2867d4e06c57d99e7aab3d83aae721443468 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Fri, 22 Jul 2022 17:08:07 +0200 Subject: [PATCH] Remove admin_and_handling merging + update specs as well --- app/helpers/checkout_helper.rb | 12 ------------ app/views/spree/orders/_form.html.haml | 2 +- spec/helpers/checkout_helper_spec.rb | 2 +- spec/system/admin/invoice_print_spec.rb | 18 ++++++++++++------ 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/app/helpers/checkout_helper.rb b/app/helpers/checkout_helper.rb index c4754e667e..aa5c069045 100644 --- a/app/helpers/checkout_helper.rb +++ b/app/helpers/checkout_helper.rb @@ -32,18 +32,6 @@ module CheckoutHelper } end - enterprise_fee_adjustments = adjustments.select { |a| - a.originator_type == 'EnterpriseFee' && a.adjustable_type != 'Spree::LineItem' - } - adjustments.reject! { |a| - a.originator_type == 'EnterpriseFee' && a.adjustable_type != 'Spree::LineItem' - } - unless exclude.include? :admin_and_handling - adjustments << Spree::Adjustment.new( - label: I18n.t(:orders_form_admin), amount: enterprise_fee_adjustments.sum(&:amount) - ) - end - adjustments end diff --git a/app/views/spree/orders/_form.html.haml b/app/views/spree/orders/_form.html.haml index 14b483e980..7199594fec 100644 --- a/app/views/spree/orders/_form.html.haml +++ b/app/views/spree/orders/_form.html.haml @@ -38,7 +38,7 @@ %span.order-total.distribution-total= display_line_item_fees_total_for(@order) %td - - checkout_adjustments_for(@order, exclude: [:line_item, :admin_and_handling]).reject{ |a| a.amount == 0 }.reverse_each do |adjustment| + - checkout_adjustments_for(@order, exclude: [:line_item]).reject{ |a| a.amount == 0 }.reverse_each do |adjustment| %tr.order-adjustment %td.text-right{:colspan => "3"} = adjustment.label diff --git a/spec/helpers/checkout_helper_spec.rb b/spec/helpers/checkout_helper_spec.rb index ef64fec69a..a06973240b 100644 --- a/spec/helpers/checkout_helper_spec.rb +++ b/spec/helpers/checkout_helper_spec.rb @@ -148,7 +148,7 @@ describe CheckoutHelper, type: :helper do expect(adjustments).to include shipping_adjustment admin_fee_summary = adjustments.last - expect(admin_fee_summary.label).to eq I18n.t(:orders_form_admin) + expect(admin_fee_summary.label).to eq "Shipping" expect(admin_fee_summary.amount).to eq 123 end diff --git a/spec/system/admin/invoice_print_spec.rb b/spec/system/admin/invoice_print_spec.rb index e7b2bddad1..01ac5d40e4 100644 --- a/spec/system/admin/invoice_print_spec.rb +++ b/spec/system/admin/invoice_print_spec.rb @@ -215,7 +215,8 @@ describe ' it "displays GST for enterprise fees" do pending "ii) for legend see picture on PR #9495" # enterprise fee of $20.00 - expect(page).to have_content "Admin & Handling 1 $20.00 $120.00" + expect(page).to have_content "Whole order - #{enterprise_fee.name} fee by coordinator " \ + "#{user1.enterprises.first.name} 1 $20.00 (included) $120.00" end it "displays the taxes correctly" do @@ -225,7 +226,8 @@ describe ' expect(page).to have_content "#{Spree::Product.second.name} 3 $250.08 $1,500.45" expect(page).to have_content "(1g)" # display as # Enterprise fee - expect(page).to have_content "Admin & Handling 1 $120.00" + expect(page).to have_content "Whole order - #{enterprise_fee.name} fee by coordinator " \ + "#{user1.enterprises.first.name} 1 $15.65 (included) $120.00" # Shipping expect(page).to have_content "Shipping 1 $9.14 (included) $100.55" # Order Totals @@ -257,7 +259,8 @@ describe ' expect(page).to have_content "(1g)" # display as expect(page).to have_content "3 $500.15 $1,500.45 20.0%" # Enterprise fee - expect(page).to have_content "Admin & Handling $120.00" + expect(page).to have_content "#{enterprise_fee.name} fee by coordinator " \ + "#{user1.enterprises.first.name} $120.00" # Shipping expect(page).to have_content "Shipping $100.55 10.0%" # Tax totals @@ -357,14 +360,16 @@ describe ' it "displays GST for enterprise fees" do pending "v) for legend see picture on PR #9495" # enterprise fee of $24.00 - expect(page).to have_content "Admin & Handling 1 $20.00 $120.00" + expect(page).to have_content "Whole order - #{enterprise_fee.name} fee by coordinator " \ + "#{user1.enterprises.first.name} 1 $20.00 $120.00" end it "displays the taxes correctly" do # header expect(page).to have_content "Item Qty GST Price" # Enterprise fee - expect(page).to have_content "Admin & Handling 1 $120.00" + expect(page).to have_content "Whole order - #{enterprise_fee.name} fee by coordinator " \ + "#{user1.enterprises.first.name} 1 $18.00 $120.00" # Shipping expect(page).to have_content "Shipping 1 $10.06 $100.55" # Order Totals @@ -395,7 +400,8 @@ describe ' expect(page).to have_content "(1g)" # display as expect(page).to have_content "3 $500.15 $1,500.45 20.0%" # Enterprise fee - expect(page).to have_content "Admin & Handling $120.00" + expect(page).to have_content "#{enterprise_fee.name} fee by coordinator " \ + "#{user1.enterprises.first.name} $120.00" # Shipping expect(page).to have_content "Shipping $100.55 10.0%" # Tax totals