Sha256: b54c9f66554153c329718467688d420a7d8f1b38cb583eca9af3205d215b65d5
Contents?: true
Size: 848 Bytes
Versions: 2
Compression:
Stored size: 848 Bytes
Contents
module Workarea decorate PriceAdjustmentSet, with: :global_e do def group_discounts_by_id reduce({}) do |memo, adjustment| if adjustment.discount? memo[adjustment.data["discount_id"]] ||= PriceAdjustment.new( quantity: adjustment.quantity, data: adjustment.data.merge("discount_value" => 0.0), price: adjustment.price, description: adjustment.description, calculator: adjustment.calculator, amount: 0.to_m(adjustment.amount.currency) ) memo[adjustment.data["discount_id"]].amount += adjustment.amount memo[adjustment.data["discount_id"]].data["discount_value"] += adjustment.data["discount_value"] else memo[adjustment.id] = adjustment end memo end.values end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
workarea-global_e-1.3.0 | app/models/workarea/price_adjustment_set.decorator |
workarea-global_e-1.2.1 | app/models/workarea/price_adjustment_set.decorator |