View Source BasicECommerce.SpecialOffer (Basic e-commerce v0.1.0)
Defines a special offer.
This module defines a BasicECommerce.SpecialOffer describing a special offer.
fields
Fields
description- a human-friendly description of the special offertrigger_number- the number of matching products needed to trigger this special offerdiscount_type- the type of discount (percentage on the price of the product or a fixed amount)discount_value- the value of the discount, either a percentage as an integer between 0-100, or an amount in centsapply_discount_to_all- if this is set, the discount is applyed to ALL product on which this discount applies, otherwise only maximumnb_discounted_itemsare discountednb_discounted_items- the maximum number of discounted items using this special offer (ignored ifapply_discount_to_allis set)
Link to this section Summary
Types
(This type is managed by TypeCheck,
which allows checking values against the type at runtime.)
(This type is managed by TypeCheck,
which allows checking values against the type at runtime.)
Functions
Compute the price of an BasicECommerce.OrderLine using the given BasicECommerce.SpecialOffer.
Compute the discounted price of a single unit of a product, applying the given BasicECommerce.SpecialOffer
Check if an offer is applicable to an BasicECommerce.OrderLine.
Link to this section Types
@type order_line() :: BasicECommerce.OrderLine.t()
(This type is managed by TypeCheck,
which allows checking values against the type at runtime.)
Full definition:
order_line :: BasicECommerce.OrderLine.t()
@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 t() :: %BasicECommerce.SpecialOffer{ applicable_sku: atom(), apply_discount_to_all: boolean(), description: String.t(), discount_type: :percentage | :fixed_amount, discount_value: integer(), nb_discounted_items: integer() | nil, trigger_number: integer() }
(This type is managed by TypeCheck,
which allows checking values against the type at runtime.)
Full definition:
t :: %BasicECommerce.SpecialOffer{
applicable_sku: atom(),
description: String.t(),
trigger_number: integer(),
discount_type: :percentage | :fixed_amount,
discount_value: integer(),
apply_discount_to_all: boolean(),
nb_discounted_items: integer() | nil
}
Link to this section Functions
@spec compute_total_price(offer :: t(), line :: order_line()) :: integer()
Compute the price of an BasicECommerce.OrderLine using the given BasicECommerce.SpecialOffer.
Compute the discounted price of a single unit of a product, applying the given BasicECommerce.SpecialOffer
@spec is_applicable?(offer :: t(), line :: order_line()) :: boolean()
Check if an offer is applicable to an BasicECommerce.OrderLine.