Sha256: b772e176ce90caa09b4fb96d1048594bb73c4c63e36ff10ce76cd843fc940fc1

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

module Workarea
  decorate Order::Item, with: :global_e do
    decorated do
      field :international_total_value, type: Money
      field :international_total_price, type: Money
      field :discounted_price_for_customs, type: Money
      field :generic_hs_code, type: String

      embeds_many :international_price_adjustments,
        class_name: 'Workarea::PriceAdjustment',
        extend: PriceAdjustmentExtension
    end

    def international_discounted_price
      international_total_value
    end

    # The original item calculator price adjustment amount before GlobalE 
    # adjusting
    #
    # @return [nil, Money]
    #
    def nonadjusted_amount
      return if price_adjustments.first.data["nonadjusted_amount"].nil?

      Money.demongoize(price_adjustments.first.data["nonadjusted_amount"])
    end

    # The original item calculator price adjustment price before GlobalE 
    # adjusting
    #
    # @return [nil, Float]
    #
    def nonadjusted_price
      price_adjustments.first.data["nonadjusted_price"]
    end

    # Adds an international price adjustment to the item. Does not persist.
    #
    # @return [self]
    #
    def adjust_international_pricing(options = {})
      international_price_adjustments.build(options)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
workarea-global_e-1.3.0 app/models/workarea/order/item.decorator
workarea-global_e-1.2.1 app/models/workarea/order/item.decorator