diff --git a/app/models/spree/order.rb b/app/models/spree/order.rb index a8aa560875..f2e9714e38 100644 --- a/app/models/spree/order.rb +++ b/app/models/spree/order.rb @@ -253,16 +253,6 @@ module Spree Spree::Config[:tax_using_ship_address] ? ship_address : bill_address end - # Array of totals grouped by Adjustment#label. Useful for displaying line item - # adjustments on an invoice. For example, you can display tax breakout for - # cases where tax is included in price. - def line_item_adjustment_totals - Hash[line_item_adjustments.eligible.group_by(&:label).map do |label, adjustments| - total = adjustments.sum(&:amount) - [label, Spree::Money.new(total, currency: currency)] - end] - end - def updater @updater ||= OrderManagement::Order::Updater.new(self) end @@ -708,13 +698,6 @@ module Spree (adjustments.to_a + line_item_adjustments.to_a).sum(&:included_tax) end - def price_adjustment_totals - Hash[tax_adjustment_totals.map do |tax_rate, tax_amount| - [tax_rate.name, - Spree::Money.new(tax_amount, currency: currency)] - end] - end - def has_taxes_included !line_items.with_tax.empty? end diff --git a/spec/models/spree/order/adjustments_spec.rb b/spec/models/spree/order/adjustments_spec.rb index 11c4cd9797..ede6051f38 100644 --- a/spec/models/spree/order/adjustments_spec.rb +++ b/spec/models/spree/order/adjustments_spec.rb @@ -25,54 +25,6 @@ describe Spree::Order do end end - context "line item adjustment totals" do - before { @order = Spree::Order.create! } - - context "when there are no line item adjustments" do - before { allow(@order).to receive_message_chain(:line_item_adjustments, eligible: []) } - - it "should return an empty hash" do - expect(@order.line_item_adjustment_totals).to eq({}) - end - end - - context "when there are two adjustments with different labels" do - let(:adj1) { build(:adjustment, amount: 10, label: "Foo") } - let(:adj2) { build(:adjustment, amount: 20, label: "Bar") } - - before do - allow(@order).to receive_message_chain(:line_item_adjustments, eligible: [adj1, adj2]) - end - - it "should return exactly two totals" do - expect(@order.line_item_adjustment_totals.size).to eq 2 - end - - it "should return the correct totals" do - expect(@order.line_item_adjustment_totals["Foo"]).to eq Spree::Money.new(10) - expect(@order.line_item_adjustment_totals["Bar"]).to eq Spree::Money.new(20) - end - end - - context "when there are two adjustments with one label and a single adjustment with another" do - let(:adj1) { build(:adjustment, amount: 10, label: "Foo") } - let(:adj2) { build(:adjustment, amount: 20, label: "Bar") } - let(:adj3) { build(:adjustment, amount: 40, label: "Bar") } - - before do - allow(@order).to receive_message_chain(:line_item_adjustments, eligible: [adj1, adj2, adj3]) - end - - it "should return exactly two totals" do - expect(@order.line_item_adjustment_totals.size).to eq 2 - end - it "should return the correct totals" do - expect(@order.line_item_adjustment_totals["Foo"]).to eq Spree::Money.new(10) - expect(@order.line_item_adjustment_totals["Bar"]).to eq Spree::Money.new(60) - end - end - end - context "line item adjustments" do before do @order = Spree::Order.create!