View Source BasicECommerce.OrderLine (Basic e-commerce v0.1.0)
Defines a line of an order.
This module defines a BasicECommerce.OrderLine
describing a line of an order.
fields
Fields
sku
- the SKU of the product described on this linequantity
- the number of product in this line
Link to this section Summary
Types
(This type is managed by TypeCheck
,
which allows checking values against the type at runtime.)
Functions
Apply the best applicable offer to a given line.
Returns the total price of the given line without any applicable special offer
Link to this section Types
@type product() :: BasicECommerce.Product.t()
(This type is managed by TypeCheck
,
which allows checking values against the type at runtime.)
Full definition:
product :: BasicECommerce.Product.t()
@type special_offer() :: BasicECommerce.SpecialOffer.t()
(This type is managed by TypeCheck
,
which allows checking values against the type at runtime.)
Full definition:
t :: %BasicECommerce.OrderLine{product: product(), quantity: integer()}
Link to this section Functions
@spec apply_offers(t(), [special_offer()]) :: {nil | special_offer(), integer()}
Apply the best applicable offer to a given line.
Returns a tuple with
- the first element being the applied
BasicECommerce.SpecialOffer
or nil if no offer was applied - the second element being the total price after the special offer was applied
Returns the total price of the given line without any applicable special offer