Sha256: 33a658e329769031e6804cbd695229426aba9b663fb3ff3eeb110e07811f3d81
Contents?: true
Size: 478 Bytes
Versions: 3
Compression:
Stored size: 478 Bytes
Contents
# frozen_string_literal: true module ShoppyCartus class OrderDecorator < ApplicationDecorator delegate_all decorates_association :order_item def sale coupon ? coupon.sale : 0.0 end def subtotal order_items.map(&:decorate).map(&:subtotal).reduce(&:+) end def total total_price = subtotal - sale total_price.positive? ? total_price : 0.0 end def total_with_delivery total + delivery.price end end end
Version data entries
3 entries across 3 versions & 1 rubygems