Remove dead code; Spree::Order #line_item_adjustment_totals and #price_adjustment_totals

This commit is contained in:
Matt-Yorkley
2021-02-27 11:56:44 +00:00
parent f1fca874a1
commit 16eff698df
2 changed files with 0 additions and 65 deletions

View File

@@ -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

View File

@@ -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!