Sha256: f1240037e17300f60e582c74f285e019b22c0d9120afff6817163be08cb8efa9
Contents?: true
Size: 1.43 KB
Versions: 1
Compression:
Stored size: 1.43 KB
Contents
module Workarea decorate Pricing::OrderTotals, with: :flow_io do def total super return unless @order.experience.present? set_flow_item_totals set_flow_subtotal set_flow_shipping_totals set_flow_tax_totals set_flow_total set_flow_total_value end private def flow_price_adjustments @flow_price_adjustments ||= @order.flow_price_adjustments + @shippings.map(&:flow_price_adjustments).reduce(:+) end def set_flow_item_totals @order.items.each do |item| item.flow_total_value = item.flow_price_adjustments.reject do |adjustment| adjustment.price.in?(%w(tax shipping)) end.sum(&:amount) item.flow_total_price = item.flow_price_adjustments.adjusting('item').sum end end def set_flow_subtotal @order.flow_subtotal_price = flow_price_adjustments.adjusting('item').sum end def set_flow_shipping_totals @order.flow_shipping_total = flow_price_adjustments.adjusting('shipping').sum end def set_flow_tax_totals @order.flow_tax_total = flow_price_adjustments.adjusting('tax').sum end def set_flow_total @order.flow_total_price = flow_price_adjustments.sum end def set_flow_total_value @order.flow_total_value = @order.flow_total_price - @order.flow_shipping_total - @order.flow_tax_total end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
workarea-flow_io-1.2.1 | app/models/workarea/pricing/order_totals.decorator |