Sha256: 909f68fa962dbb0f1be75dbeb9b7760ed84ca4788b6311f6441c467c640f5d09

Contents?: true

Size: 429 Bytes

Versions: 3

Compression:

Stored size: 429 Bytes

Contents

module ShoppingCart
  module OrderSummary
    extend ActiveSupport::Concern

    def subtotal
      order_items.sum(&:total_price)
    end

    def discount
      coupon.try(:discount) || 0.00
    end

    def delivery_price
      delivery.try(:price) || 0.00
    end

    def order_total
      subtotal - discount + delivery_price
    end

    def items_count
      order_items.collect(&:quantity).compact.sum
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
loker-shopping-cart-0.1.3 app/models/concerns/shopping_cart/order_summary.rb
loker-shopping-cart-0.1.2 app/models/concerns/shopping_cart/order_summary.rb
loker-shopping-cart-0.1.1 app/models/concerns/shopping_cart/order_summary.rb