Sha256: f42a1991fe0b3e7802b59ae7c85a1a72e8f166647f90e911a8bd73652c8e9cd1
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
# frozen_string_literal: true module SolidusTaxCloud module Spree module LineItemDecorator def tax_cloud_cache_key if ActiveRecord::Base.try(:cache_versioning) cache_key else key = "Spree::LineItem #{id}: #{quantity}x<#{variant.cache_key}>@#{total_excluding_vat}#{currency}" if order.ship_address key += "shipped_to<#{order.ship_address.try(:cache_key)}>" elsif order.billing_address key += "billed_to<#{order.bill_address.try(:cache_key)}>" end key end end def tax_cloud_cache_version if ActiveRecord::Base.try(:cache_versioning) key = "Spree::LineItem #{id}: #{quantity}x<#{variant.cache_version}>@#{total_excluding_vat}#{currency}" if order.ship_address key += "shipped_to<#{order.ship_address.try(:cache_version)}>" elsif order.billing_address key += "billed_to<#{order.bill_address.try(:cache_version)}>" end key end end def price_with_discounts round_to_two_places(total_excluding_vat / quantity) end def round_to_two_places(amount) BigDecimal(amount.to_s).round(2, BigDecimal::ROUND_HALF_UP) end ::Spree::LineItem.prepend self end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
solidus_tax_cloud-1.0.0 | app/decorators/models/solidus_tax_cloud/spree/line_item_decorator.rb |