Skip to content

Commit

Permalink
Deprecate Spree::TaxRate#adjust method
Browse files Browse the repository at this point in the history
We are not using this method in the codebase and now we have
Spree::Tax::OrderAdjuster class which takes care of applying
taxes to an order. That's the new default way and we should
start printing a notice into apps/extensions that are still
using the old way.
  • Loading branch information
kennyadsl committed Sep 26, 2019
1 parent b76c1dd commit efe804d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/app/models/spree/tax_rate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ class TaxRate < Spree::Base
scope :included_in_price, -> { where(included_in_price: true) }

# Creates necessary tax adjustments for the order.
#
# @deprecated Please use `Spree::Tax::OrderAdjuster#adjust!` instead
def adjust(_order_tax_zone, item)
Spree::Deprecation.warn("`Spree::TaxRate#adjust` is deprecated. Please use `Spree::Tax::OrderAdjuster#adjust!` instead.", caller)

amount = compute_amount(item)

item.adjustments.create!(
Expand Down
1 change: 1 addition & 0 deletions core/spec/models/spree/tax_rate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@

describe 'adjustments' do
before do
expect(Spree::Deprecation).to receive(:warn)
tax_rate.adjust(nil, item)
end

Expand Down

0 comments on commit efe804d

Please sign in to comment.