Remove duplicative line item for taxes

This commit is contained in:
Andy Brett
2021-07-07 08:26:47 -07:00
parent 46cd05c54a
commit 7d399b4c6d
3 changed files with 33 additions and 5 deletions

View File

@@ -10,8 +10,8 @@ module CheckoutHelper
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 }
# Remove tax adjustments and (optionally) shipping fees
adjustments.reject! { |a| a.originator_type == 'Spree::TaxRate' }
if exclude.include? :shipping
adjustments.reject! { |a|
a.originator_type == 'Spree::ShippingMethod'

View File

@@ -19,7 +19,7 @@
'#{j(@order.distributor.address.address_part1)}' + '\x0A', // text and line break
'#{j(@order.distributor.address.address_part2)}' + '\x0A',
'#{j(@order.distributor.contact.email)}' + '\x0A',
'\x0A', // line break
'\x0A', // line break
'\x1B' + '\x61' + '\x32', // right align
'#{j(l(Time.zone.now.to_date))}' + '\x0A',
'#{j(@order.number)}' + '\x0A',
@@ -73,5 +73,3 @@
= javascript_include_tag "qz/ticket-popup.js"
%body
%div#printer-list

View File

@@ -60,6 +60,36 @@ describe CheckoutHelper, type: :helper do
expect(admin_fee_summary.amount).to eq 123
end
context "tax rate adjustments" do
let!(:tax_rate) { create(:tax_rate, amount: 0.1, calculator: ::Calculator::DefaultTax.new) }
let!(:line_item_fee_adjustment) {
create(:adjustment, originator: enterprise_fee, adjustable: order.line_items.first,
order: order)
}
let!(:order_tax_adjustment) {
create(:adjustment,
originator: tax_rate,
adjustable: fee_adjustment,
order: order
)
}
let!(:line_item_fee_adjustment_tax_adjustment) {
create(:adjustment,
originator: tax_rate,
adjustable: line_item_fee_adjustment,
order: order
)
}
it "removes tax rate adjustments" do
expect(order.all_adjustments.tax.count).to eq(2)
adjustments = helper.checkout_adjustments_for(order)
tax_adjustments = adjustments.select { |a| a.originator_type == "Spree::TaxRate" }
expect(tax_adjustments.count).to eq(0)
end
end
context "with return authorization adjustments" do
let!(:return_adjustment) {
create(:adjustment, originator_type: 'Spree::ReturnAuthorization', adjustable: order,