Module: SpreeAvataxOfficial::Spree::ShipmentDecorator

Defined in:
app/models/spree_avatax_official/spree/shipment_decorator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



6
7
8
# File 'app/models/spree_avatax_official/spree/shipment_decorator.rb', line 6

def self.prepended(base)
  base.include ::SpreeAvataxOfficial::HasUuid
end

Instance Method Details

#avatax_tax_codeObject



18
19
20
# File 'app/models/spree_avatax_official/spree/shipment_decorator.rb', line 18

def avatax_tax_code
  tax_category.try(:tax_code).presence || ::Spree::TaxCategory::DEFAULT_TAX_CODES['Shipment']
end

#included_in_priceObject



10
11
12
# File 'app/models/spree_avatax_official/spree/shipment_decorator.rb', line 10

def included_in_price
  order.market&.tax_inclusive || false
end

#selected_shipping_rate_id=(id) ⇒ Object



22
23
24
25
26
27
# File 'app/models/spree_avatax_official/spree/shipment_decorator.rb', line 22

def selected_shipping_rate_id=(id)
  super
  return if order.nil? || order.completed?

  order.recalculate_avatax_taxes
end

#tax_categoryObject



14
15
16
# File 'app/models/spree_avatax_official/spree/shipment_decorator.rb', line 14

def tax_category
  selected_shipping_rate.try(:tax_rate).try(:tax_category) || shipping_method.try(:tax_category)
end