Class: Spree::Calculator::FlowIo
- Inherits:
-
Calculator::DefaultTax
- Object
- Calculator::DefaultTax
- Spree::Calculator::FlowIo
- Defined in:
- app/models/spree/calculator/flow_io.rb
Class Method Summary collapse
Instance Method Summary collapse
- #compute_shipment_or_line_item(item) ⇒ Object (also: #compute_shipment, #compute_line_item)
- #get_order_tax_amount(_taxable) ⇒ Object
- #get_tax_rate(taxable) ⇒ Object
Class Method Details
.description ⇒ Object
6 7 8 |
# File 'app/models/spree/calculator/flow_io.rb', line 6 def self.description 'FlowIO Calculator' end |
Instance Method Details
#compute_shipment_or_line_item(item) ⇒ Object Also known as: compute_shipment, compute_line_item
10 11 12 13 14 15 16 17 18 19 |
# File 'app/models/spree/calculator/flow_io.rb', line 10 def compute_shipment_or_line_item(item) order = item.order if can_calculate_tax?(order) get_flow_tax_data(order) tax_for_item(item) else prev_tax_amount(item) end end |
#get_order_tax_amount(_taxable) ⇒ Object
30 |
# File 'app/models/spree/calculator/flow_io.rb', line 30 def get_order_tax_amount(_taxable); end |
#get_tax_rate(taxable) ⇒ Object
23 24 25 26 27 28 |
# File 'app/models/spree/calculator/flow_io.rb', line 23 def get_tax_rate(taxable) order = taxable.class.to_s == 'Spree::Order' ? taxable : taxable.order get_flow_tax_data(order) if order.flow_allocations.empty? response = order.flow_tax_for_item(taxable.adjustable, 'vat_item_price', rate.included_in_price) response.nil? ? 0 : response['rate']&.to_f end |