Class: Spree::TaxRate
- Includes:
- AdjustmentSource, CalculatedAdjustments
- Defined in:
- app/models/spree/tax_rate.rb
Class Method Summary collapse
-
.adjust(order_tax_zone, items) ⇒ Object
deprecated
Deprecated.
Please use Spree::Tax::OrderAdjuster or Spree::Tax::ItemAdjuster instead.
Instance Method Summary collapse
-
#adjust(order_tax_zone, item) ⇒ Object
Creates necessary tax adjustments for the order.
-
#compute_amount(item) ⇒ Object
This method is used by Adjustment#update to recalculate the cost.
Methods included from AdjustmentSource
#deals_with_adjustments_for_deleted_source
Methods included from CalculatedAdjustments
#calculator_type, #calculator_type=
Methods inherited from Base
display_includes, #initialize_preference_defaults, page, preference
Methods included from Preferences::Preferable
#default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference
Class Method Details
.adjust(order_tax_zone, items) ⇒ Object
Deprecated.
Please use Spree::Tax::OrderAdjuster or Spree::Tax::ItemAdjuster instead.
Create tax adjustments for some items that have the same tax zone.
74 75 76 77 78 79 |
# File 'app/models/spree/tax_rate.rb', line 74 def self.adjust(order_tax_zone, items) Spree::Deprecation.warn("Please use Spree::Tax::OrderAdjuster or Spree::Tax::ItemAdjuster instead", caller) items.map do |item| Spree::Tax::ItemAdjuster.new(item, rates_for_order_zone: for_zone(order_tax_zone)).adjust! end end |
Instance Method Details
#adjust(order_tax_zone, item) ⇒ Object
Creates necessary tax adjustments for the order.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'app/models/spree/tax_rate.rb', line 82 def adjust(order_tax_zone, item) amount = compute_amount(item) return if amount == 0 included = included_in_price && amount > 0 item.adjustments.create!( source: self, amount: amount, order_id: item.order_id, label: adjustment_label(amount), included: included ) end |
#compute_amount(item) ⇒ Object
This method is used by Adjustment#update to recalculate the cost.
98 99 100 |
# File 'app/models/spree/tax_rate.rb', line 98 def compute_amount(item) calculator.compute(item) end |