From a768cb2510ba9f6c34cfe8f27ad6f57c86c517a8 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 28 Feb 2021 14:29:04 +0000 Subject: [PATCH 01/16] Set adjustment "target" (adjustable) to be the line item when adding enterprise fees on line items --- lib/open_food_network/enterprise_fee_applicator.rb | 14 ++------------ .../enterprise_fee_applicator_spec.rb | 2 +- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/lib/open_food_network/enterprise_fee_applicator.rb b/lib/open_food_network/enterprise_fee_applicator.rb index ab1c96eab1..76f6e78a53 100644 --- a/lib/open_food_network/enterprise_fee_applicator.rb +++ b/lib/open_food_network/enterprise_fee_applicator.rb @@ -1,7 +1,7 @@ module OpenFoodNetwork class EnterpriseFeeApplicator < Struct.new(:enterprise_fee, :variant, :role) def create_line_item_adjustment(line_item) - create_adjustment(line_item_adjustment_label, line_item.order, line_item) + create_adjustment(line_item_adjustment_label, line_item, line_item) end def create_order_adjustment(order) @@ -11,23 +11,13 @@ module OpenFoodNetwork private def create_adjustment(label, target, calculable) - adjustment = create_enterprise_fee_adjustment(label, target, calculable) + adjustment = enterprise_fee.create_adjustment(label, target, calculable, true) AdjustmentMetadata.create! adjustment: adjustment, enterprise: enterprise_fee.enterprise, fee_name: enterprise_fee.name, fee_type: enterprise_fee.fee_type, enterprise_role: role adjustment.set_absolute_included_tax! adjustment_tax(adjustment) end - def create_enterprise_fee_adjustment(label, target, calculable) - adjustment = enterprise_fee.create_adjustment(label, target, calculable, true) - - # This is necessary when source is a line_item - # probably because the association order.adjustments contains "inverse_of :source" - # which overrides the value (the line item) set in calculated_adjustment.create_adjustment - adjustment.source = calculable - adjustment - end - def line_item_adjustment_label "#{variant.product.name} - #{base_adjustment_label}" end diff --git a/spec/lib/open_food_network/enterprise_fee_applicator_spec.rb b/spec/lib/open_food_network/enterprise_fee_applicator_spec.rb index 6ea5597ddc..8fee7bdad2 100644 --- a/spec/lib/open_food_network/enterprise_fee_applicator_spec.rb +++ b/spec/lib/open_food_network/enterprise_fee_applicator_spec.rb @@ -16,7 +16,7 @@ module OpenFoodNetwork adjustment = Spree::Adjustment.last expect(adjustment.label).to eq('label') - expect(adjustment.adjustable).to eq(line_item.order) + expect(adjustment.adjustable).to eq(line_item) expect(adjustment.source).to eq(line_item) expect(adjustment.originator).to eq(enterprise_fee) expect(adjustment).to be_mandatory From 8d4733b3d559b780c3fd13752e2e41e90cd3daa3 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 28 Feb 2021 14:32:35 +0000 Subject: [PATCH 02/16] Update EnterpriseFee#clear_all_adjustments --- app/models/enterprise_fee.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/enterprise_fee.rb b/app/models/enterprise_fee.rb index b7a3eeb6e2..6406ad6868 100644 --- a/app/models/enterprise_fee.rb +++ b/app/models/enterprise_fee.rb @@ -41,7 +41,7 @@ class EnterpriseFee < ActiveRecord::Base } def self.clear_all_adjustments(order) - order.adjustments.enterprise_fee.destroy_all + order.all_adjustments.enterprise_fee.destroy_all end private From f67a8e4af318ea1ad8159e1651f0f3895224a8f1 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 28 Feb 2021 16:38:34 +0000 Subject: [PATCH 03/16] Update and simplify LineItem#price_with_adjustments --- app/models/spree/line_item.rb | 4 ++-- spec/models/spree/line_item_spec.rb | 8 ++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/app/models/spree/line_item.rb b/app/models/spree/line_item.rb index d224b154a8..df88535a2a 100644 --- a/app/models/spree/line_item.rb +++ b/app/models/spree/line_item.rb @@ -190,9 +190,9 @@ module Spree # so line_item.adjustments returns an empty array return 0 if quantity.zero? - line_item_adjustments = OrderAdjustmentsFetcher.new(order).line_item_adjustments(self) + fees = adjustments.enterprise_fee.sum(:amount) - (price + line_item_adjustments.to_a.sum(&:amount) / quantity).round(2) + (price + fees / quantity).round(2) end def single_display_amount_with_adjustments diff --git a/spec/models/spree/line_item_spec.rb b/spec/models/spree/line_item_spec.rb index 0c0277f00a..e8db788b9f 100644 --- a/spec/models/spree/line_item_spec.rb +++ b/spec/models/spree/line_item_spec.rb @@ -418,9 +418,7 @@ module Spree li = LineItem.new allow(li).to receive(:price) { 55.55 } - allow(li).to receive_message_chain(:order, :adjustments, :loaded?) - allow(li).to receive_message_chain(:order, :adjustments, :select) - allow(li).to receive_message_chain(:order, :adjustments, :where, :to_a, :sum) { 11.11 } + allow(li).to receive_message_chain(:adjustments, :enterprise_fee, :sum) { 11.11 } allow(li).to receive(:quantity) { 2 } expect(li.price_with_adjustments).to eq(61.11) end @@ -431,9 +429,7 @@ module Spree li = LineItem.new allow(li).to receive(:price) { 55.55 } - allow(li).to receive_message_chain(:order, :adjustments, :loaded?) - allow(li).to receive_message_chain(:order, :adjustments, :select) - allow(li).to receive_message_chain(:order, :adjustments, :where, :to_a, :sum) { 11.11 } + allow(li).to receive_message_chain(:adjustments, :enterprise_fee, :sum) { 11.11 } allow(li).to receive(:quantity) { 2 } expect(li.amount_with_adjustments).to eq(122.22) end From a0a787b6ecb093d162f340106f05b2f3dfebcf25 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 28 Feb 2021 16:39:28 +0000 Subject: [PATCH 04/16] Delete dead code OrderAdjustmentsFetcher#line_item_adjustments :tada: --- app/services/order_adjustments_fetcher.rb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/services/order_adjustments_fetcher.rb b/app/services/order_adjustments_fetcher.rb index 9292fe8e91..ea553766c8 100644 --- a/app/services/order_adjustments_fetcher.rb +++ b/app/services/order_adjustments_fetcher.rb @@ -29,14 +29,6 @@ class OrderAdjustmentsFetcher sum_adjustments "shipping" end - def line_item_adjustments(line_item) - if adjustments_eager_loaded? - adjustments.select{ |adjustment| adjustment.source_id == line_item.id } - else - adjustments.where(source_id: line_item.id) - end - end - private attr_reader :order From f2627dff0bc84a004c36b2bf3b43fc61b6491b1b Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 28 Feb 2021 16:40:48 +0000 Subject: [PATCH 05/16] Loosen scope in adjustment spec to include enterprise fees on line items --- spec/models/spree/adjustment_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/spree/adjustment_spec.rb b/spec/models/spree/adjustment_spec.rb index b46a431041..b38666751a 100644 --- a/spec/models/spree/adjustment_spec.rb +++ b/spec/models/spree/adjustment_spec.rb @@ -274,7 +274,7 @@ module Spree let(:order_cycle) { create(:simple_order_cycle, coordinator: coordinator, coordinator_fees: [enterprise_fee], distributors: [coordinator], variants: [variant]) } let(:line_item) { create(:line_item, variant: variant) } let(:order) { create(:order, line_items: [line_item], order_cycle: order_cycle, distributor: coordinator) } - let(:adjustment) { order.adjustments.reload.enterprise_fee.first } + let(:adjustment) { order.all_adjustments.reload.enterprise_fee.first } context "when enterprise fees have a fixed tax_category" do before do From 4ee02717567162f2624b11977af62ab6b1646c0e Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 28 Feb 2021 17:51:03 +0000 Subject: [PATCH 06/16] Loosen scope in order enterprise fees tax total method --- app/models/spree/order.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/spree/order.rb b/app/models/spree/order.rb index b1731b42d4..3e460753c5 100644 --- a/app/models/spree/order.rb +++ b/app/models/spree/order.rb @@ -658,7 +658,7 @@ module Spree end def enterprise_fee_tax - adjustments.reload.enterprise_fee.sum(:included_tax) + all_adjustments.reload.enterprise_fee.sum(:included_tax) end def total_tax From 3253ab46164ee565dd177528b88122489cd98a85 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 28 Feb 2021 17:51:31 +0000 Subject: [PATCH 07/16] Fix test setup in CheckoutHelper spec --- spec/helpers/checkout_helper_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/helpers/checkout_helper_spec.rb b/spec/helpers/checkout_helper_spec.rb index 966569459a..0283fabc23 100644 --- a/spec/helpers/checkout_helper_spec.rb +++ b/spec/helpers/checkout_helper_spec.rb @@ -36,7 +36,8 @@ describe CheckoutHelper, type: :helper do let(:order) { create(:order_with_totals_and_distribution) } let(:enterprise_fee) { create(:enterprise_fee, amount: 123) } let!(:fee_adjustment) { - create(:adjustment, originator: enterprise_fee, adjustable: order, source: order) + create(:adjustment, originator: enterprise_fee, adjustable: order, source: order, + order: order) } before do From 526794b32ee5b4b556244a6f29918199c24c702b Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 28 Feb 2021 17:52:05 +0000 Subject: [PATCH 08/16] Refactor CheckoutHelper --- app/helpers/checkout_helper.rb | 14 ++++++-------- app/views/spree/orders/_adjustments.html.haml | 2 +- app/views/spree/orders/_form.html.haml | 4 ++-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/app/helpers/checkout_helper.rb b/app/helpers/checkout_helper.rb index 47d2522afe..18ab79969a 100644 --- a/app/helpers/checkout_helper.rb +++ b/app/helpers/checkout_helper.rb @@ -4,10 +4,9 @@ module CheckoutHelper end def checkout_adjustments_for(order, opts = {}) - adjustments = order.adjustments.eligible exclude = opts[:exclude] || {} - adjustments = adjustments.to_a + order.shipment_adjustments.to_a + adjustments = order.all_adjustments.eligible.to_a # Remove empty tax adjustments and (optionally) shipping fees adjustments.reject! { |a| a.originator_type == 'Spree::TaxRate' && a.amount == 0 } @@ -26,17 +25,16 @@ module CheckoutHelper adjustments end - def display_checkout_admin_and_handling_adjustments_total_for(order) - adjustments = order.adjustments.eligible.where('originator_type = ? AND source_type != ? ', 'EnterpriseFee', 'Spree::LineItem') - Spree::Money.new adjustments.sum(:amount), currency: order.currency + def display_line_item_fees_total_for(order) + Spree::Money.new order.adjustments.enterprise_fee.sum(:amount), currency: order.currency end - def checkout_line_item_adjustments(order) - order.adjustments.eligible.where(source_type: "Spree::LineItem") + def checkout_line_item_fees(order) + order.line_item_adjustments.enterprise_fee end def checkout_subtotal(order) - order.item_total + checkout_line_item_adjustments(order).sum(:amount) + order.item_total + checkout_line_item_fees(order).sum(:amount) end def display_checkout_subtotal(order) diff --git a/app/views/spree/orders/_adjustments.html.haml b/app/views/spree/orders/_adjustments.html.haml index 14fba90f72..915e1a3c39 100644 --- a/app/views/spree/orders/_adjustments.html.haml +++ b/app/views/spree/orders/_adjustments.html.haml @@ -3,7 +3,7 @@ %a{ href: "#" } = t :orders_fees -- checkout_line_item_adjustments(@order).each do |adjustment| +- checkout_line_item_fees(@order).each do |adjustment| %tr.cart_adjustment %td{colspan: "3"}= adjustment.label %td.text-right= adjustment.display_amount.to_html diff --git a/app/views/spree/orders/_form.html.haml b/app/views/spree/orders/_form.html.haml index b38327dd56..e7c83d1217 100644 --- a/app/views/spree/orders/_form.html.haml +++ b/app/views/spree/orders/_form.html.haml @@ -31,12 +31,12 @@ %td.text-right %span.order-total.item-total= display_checkout_subtotal(@order) %td - -if display_checkout_admin_and_handling_adjustments_total_for(@order) != Spree::Money.new(0 , currency: @order.currency) + -if display_line_item_fees_total_for(@order) != Spree::Money.new(0 , currency: @order.currency) %tr %td.text-right{colspan:"3"} = t :orders_form_admin %td.text-right - %span.order-total.distribution-total= display_checkout_admin_and_handling_adjustments_total_for(@order) + %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| From 62a495a42e36140d7870cba31429f6e37871d000 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 28 Feb 2021 18:14:57 +0000 Subject: [PATCH 09/16] Allow line item enterprise fees to be found in EnterpriseFeeSummary report --- .../order_management/reports/enterprise_fee_summary/scope.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/order_management/app/services/order_management/reports/enterprise_fee_summary/scope.rb b/engines/order_management/app/services/order_management/reports/enterprise_fee_summary/scope.rb index eafbdbbad6..d23668edf1 100644 --- a/engines/order_management/app/services/order_management/reports/enterprise_fee_summary/scope.rb +++ b/engines/order_management/app/services/order_management/reports/enterprise_fee_summary/scope.rb @@ -52,7 +52,7 @@ module OrderManagement def for_orders chain_to_scope do - where(adjustable_type: ["Spree::Order", "Spree::Shipment"]) + where(adjustable_type: ["Spree::Order", "Spree::Shipment", "Spree::LineItem"]) end end From cafe1b5f1c216e360178ceba9c4d98826de9d66d Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 28 Feb 2021 18:22:43 +0000 Subject: [PATCH 10/16] Update order totals after creating fees This was being triggered by a callback in Spree::Adjustments before, but now that the adjustable is not the order, it does not get triggered by fees being added to line items... --- app/services/order_fees_handler.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/services/order_fees_handler.rb b/app/services/order_fees_handler.rb index 55c2416136..17247dcca6 100644 --- a/app/services/order_fees_handler.rb +++ b/app/services/order_fees_handler.rb @@ -19,6 +19,9 @@ class OrderFeesHandler create_line_item_fees! create_order_fees! + + order.updater.update_totals + order.updater.persist_totals end order.update! From 9f23bb2203b20f0c5f56e29e59eb23e8970c0a96 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 28 Feb 2021 18:35:53 +0000 Subject: [PATCH 11/16] Update SubscriptionPlacementJob fee deleting --- app/jobs/subscription_placement_job.rb | 2 +- spec/jobs/subscription_placement_job_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/jobs/subscription_placement_job.rb b/app/jobs/subscription_placement_job.rb index ee4369c1d9..7003767625 100644 --- a/app/jobs/subscription_placement_job.rb +++ b/app/jobs/subscription_placement_job.rb @@ -67,7 +67,7 @@ class SubscriptionPlacementJob < ActiveJob::Base end def handle_empty_order(order, changes) - order.reload.adjustments.destroy_all + order.reload.all_adjustments.destroy_all order.update! send_empty_email(order, changes) end diff --git a/spec/jobs/subscription_placement_job_spec.rb b/spec/jobs/subscription_placement_job_spec.rb index 32a621c436..a67dd6d9bd 100644 --- a/spec/jobs/subscription_placement_job_spec.rb +++ b/spec/jobs/subscription_placement_job_spec.rb @@ -170,9 +170,9 @@ describe SubscriptionPlacementJob do allow(job).to receive(:unavailable_stock_lines_for) { order.line_items } end - it "does not place the order, clears, all adjustments, and sends an empty_order email" do + it "does not place the order, clears all adjustments, and sends an empty_order email" do expect{ job.send(:place_order, order) }.to_not change{ order.reload.completed_at }.from(nil) - expect(order.adjustments).to be_empty + expect(order.all_adjustments).to be_empty expect(order.total).to eq 0 expect(order.adjustment_total).to eq 0 expect(job).to_not have_received(:send_placement_email) From 2c7d6453ce501ba613ccb1032168ae2926681fb0 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 28 Feb 2021 18:41:09 +0000 Subject: [PATCH 12/16] Fix adjustment test setup in Order spec Missing order associations... --- spec/models/spree/order_spec.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/spec/models/spree/order_spec.rb b/spec/models/spree/order_spec.rb index 6dbd4764c4..52160de542 100644 --- a/spec/models/spree/order_spec.rb +++ b/spec/models/spree/order_spec.rb @@ -661,8 +661,14 @@ describe Spree::Order do let!(:order) { create(:order) } let(:enterprise_fee1) { create(:enterprise_fee) } let(:enterprise_fee2) { create(:enterprise_fee) } - let!(:adjustment1) { create(:adjustment, adjustable: order, originator: enterprise_fee1, label: "EF 1", amount: 123, included_tax: 10.00) } - let!(:adjustment2) { create(:adjustment, adjustable: order, originator: enterprise_fee2, label: "EF 2", amount: 123, included_tax: 2.00) } + let!(:adjustment1) { + create(:adjustment, adjustable: order, originator: enterprise_fee1, label: "EF 1", + amount: 123, included_tax: 10.00, order: order) + } + let!(:adjustment2) { + create(:adjustment, adjustable: order, originator: enterprise_fee2, label: "EF 2", + amount: 123, included_tax: 2.00, order: order) + } it "returns a sum of the tax included in all enterprise fees" do expect(order.reload.enterprise_fee_tax).to eq(12) From bd81289240254ebc083bde23f8e06e8df3b433e1 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 28 Feb 2021 20:04:41 +0000 Subject: [PATCH 13/16] Use persisted order is order spec --- spec/models/spree/order_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/models/spree/order_spec.rb b/spec/models/spree/order_spec.rb index 52160de542..dab6296271 100644 --- a/spec/models/spree/order_spec.rb +++ b/spec/models/spree/order_spec.rb @@ -490,6 +490,7 @@ describe Spree::Order do end describe "applying enterprise fees" do + let(:subject) { create(:order) } let(:fee_handler) { ::OrderFeesHandler.new(subject) } before do From 6b4de4b3dd9b1886b687afe1285ab757ff361317 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 28 Feb 2021 22:48:33 +0000 Subject: [PATCH 14/16] Migrate enterprise fees on line items --- .../20210228223114_migrate_line_item_fees.rb | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 db/migrate/20210228223114_migrate_line_item_fees.rb diff --git a/db/migrate/20210228223114_migrate_line_item_fees.rb b/db/migrate/20210228223114_migrate_line_item_fees.rb new file mode 100644 index 0000000000..f923a7b7b5 --- /dev/null +++ b/db/migrate/20210228223114_migrate_line_item_fees.rb @@ -0,0 +1,22 @@ +class MigrateLineItemFees < ActiveRecord::Migration + class Spree::Adjustment < ActiveRecord::Base + belongs_to :originator, polymorphic: true + belongs_to :source, polymorphic: true + end + + def up + Spree::Adjustment. + where(originator_type: 'EnterpriseFee', source_type: 'Spree::LineItem'). + update_all( + "adjustable_id = source_id, adjustable_type = 'Spree::LineItem'" + ) + end + + def down + Spree::Adjustment. + where(originator_type: 'EnterpriseFee', source_type: 'Spree::LineItem'). + update_all( + "adjustable_id = order_id, adjustable_type = 'Spree::Order'" + ) + end +end From 2f262f70e1c8456b03360924d70a03dff6d127bc Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Tue, 16 Mar 2021 12:22:24 +0000 Subject: [PATCH 15/16] Update #subject syntax --- spec/models/spree/order_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/spree/order_spec.rb b/spec/models/spree/order_spec.rb index dab6296271..8937d4c81d 100644 --- a/spec/models/spree/order_spec.rb +++ b/spec/models/spree/order_spec.rb @@ -490,7 +490,7 @@ describe Spree::Order do end describe "applying enterprise fees" do - let(:subject) { create(:order) } + subject { create(:order) } let(:fee_handler) { ::OrderFeesHandler.new(subject) } before do From 49f1e44999924b7afddf99479e6b27d0add63fa6 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Thu, 18 Mar 2021 14:05:29 +0000 Subject: [PATCH 16/16] Simplify Order#total_tax to cover all taxes from all sources --- app/models/spree/order.rb | 4 +--- spec/models/spree/order_spec.rb | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/models/spree/order.rb b/app/models/spree/order.rb index 3e460753c5..0e76b64ddf 100644 --- a/app/models/spree/order.rb +++ b/app/models/spree/order.rb @@ -662,9 +662,7 @@ module Spree end def total_tax - adjustments.sum(:included_tax) + - shipment_adjustments.sum(:included_tax) + - line_item_adjustments.tax.sum(:amount) + additional_tax_total + included_tax_total end def has_taxes_included diff --git a/spec/models/spree/order_spec.rb b/spec/models/spree/order_spec.rb index 8937d4c81d..a2c9ad50a7 100644 --- a/spec/models/spree/order_spec.rb +++ b/spec/models/spree/order_spec.rb @@ -699,7 +699,7 @@ describe Spree::Order do amount: 123, included_tax: 2 ) - order.reload + order.update! end it "returns a sum of all tax on the order" do