Update OrderTaxAdjustmentsFetcher

This commit is contained in:
Matt-Yorkley
2021-02-10 20:13:57 +00:00
parent 02fb2c6a55
commit 80aefa8e73
2 changed files with 7 additions and 2 deletions

View File

@@ -22,7 +22,7 @@ class OrderTaxAdjustmentsFetcher
def all
Spree::Adjustment
.with_tax
.where(order_adjustments.or(line_item_adjustments))
.where(order_adjustments.or(line_item_adjustments).or(shipment_adjustments))
.order('created_at ASC')
end
@@ -36,6 +36,11 @@ class OrderTaxAdjustmentsFetcher
.and(table[:adjustable_type].eq('Spree::LineItem'))
end
def shipment_adjustments
table[:order_id].eq(order.id)
.and(table[:adjustable_type].eq('Spree::Shipment'))
end
def table
@table ||= Spree::Adjustment.arel_table
end

View File

@@ -86,7 +86,7 @@ describe OrderTaxAdjustmentsFetcher do
subject { OrderTaxAdjustmentsFetcher.new(order).totals }
it "returns a hash with all 3 taxes" do
it "returns a hash with all 4 taxes" do
expect(subject.size).to eq(4)
end