class Panier::Domain::Receipt
A receipt is a value object describing a payment that has been made by a shopper to a merchant in relation to an order.
Attributes
line_items[R]
Public Class Methods
new(line_items)
click to toggle source
Initializes the receipt with the given line items.
@param line_items
[Array] The line items to be represented on the
receipt.
# File lib/panier/domain/receipt.rb, line 17 def initialize(line_items) @line_items = line_items end
Public Instance Methods
total_amount()
click to toggle source
Calculates the total value of the receipt by adding together the total values of all line items.
@return [Money] The total value of the receipt.
# File lib/panier/domain/receipt.rb, line 26 def total_amount line_items.reduce(Money.zero) { |a, e| a + e.total_amount_inc_tax } end
total_tax()
click to toggle source
Calculates the total tax present on the receipt by adding together the total tax of all line items.
@return [Money] The total tax present on the receipt.
# File lib/panier/domain/receipt.rb, line 35 def total_tax line_items.reduce(Money.zero) { |a, e| a + e.total_tax } end