Skip to content
This repository was archived by the owner on Sep 12, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions app/models/spree/promotion_handler/coupon_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
Spree::PromotionHandler::Coupon.class_eval do
def apply_with_avatax
apply_without_avatax.tap do
if successful?
SpreeAvatax::SalesShared.reset_tax_attributes(order)
module Solidus
module Avatax
module PromotionHandler
def apply
super.tap do
if successful?
SpreeAvatax::SalesShared.reset_tax_attributes(order)
end
end
end
end
end

alias_method_chain :apply, :avatax
end

Spree::PromotionHandler::Coupon.send(:prepend, Solidus::Avatax::PromotionHandler)
8 changes: 4 additions & 4 deletions app/models/spree/tax/order_adjuster_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Spree::Tax::OrderAdjuster.class_eval do
def adjust_with_avatax!
module Solidus::Avatax::OrderAdjuster
def adjust!
# do nothing. we hook in in our own ways.
# TODO: See if we can make OrderAdjuster pluggable and workable for what we
# need to do.
end

alias_method_chain :adjust!, :avatax
end

Spree::Tax::OrderAdjuster.send(:prepend, Solidus::Avatax::OrderAdjuster)
6 changes: 3 additions & 3 deletions spec/models/spree/order_contents_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
describe 'add_with_avatax' do
let(:variant) { create :variant }

subject { order_contents.add_with_avatax(variant) }
subject { order_contents.add(variant) }

it 'clears tax' do
expect(SpreeAvatax::SalesShared).to receive(:reset_tax_attributes).with(order)
Expand All @@ -16,7 +16,7 @@
end

describe 'remove_with_avatax' do
subject { order_contents.remove_with_avatax(order.line_items.first.variant) }
subject { order_contents.remove(order.line_items.first.variant) }

it 'recomputes tax' do
expect(SpreeAvatax::SalesShared).to receive(:reset_tax_attributes).with(order)
Expand All @@ -25,7 +25,7 @@
end

describe 'update_cart_with_avatax' do
subject { order_contents.update_cart_with_avatax({}) }
subject { order_contents.update_cart({}) }

it 'recomputes tax' do
expect(SpreeAvatax::SalesShared).to receive(:reset_tax_attributes).with(order)
Expand Down