Schema for catalogue items — individual products/materials with SKU and pricing.
Summary
Functions
Returns the markup percentage that actually applies to an item — the
item's own markup_percentage if set, otherwise catalogue_markup.
Calculates the sale price for an item.
Types
@type t() :: %PhoenixKitCatalogue.Schemas.Item{ __meta__: term(), base_price: term(), catalogue: term(), catalogue_uuid: term(), category: term(), category_uuid: term(), data: term(), description: term(), inserted_at: term(), manufacturer: term(), manufacturer_uuid: term(), markup_percentage: term(), name: term(), sku: term(), status: term(), unit: term(), updated_at: term(), uuid: term() }
Functions
Returns the markup percentage that actually applies to an item — the
item's own markup_percentage if set, otherwise catalogue_markup.
nil on both sides means "no markup at all" and the item should be
sold at its base price. Callers that only need to display which
markup is active (without computing a price) can use this directly.
Calculates the sale price for an item.
catalogue_markup is the fallback markup used when the item has no
override of its own. The item's markup_percentage takes precedence
if set (including an explicit 0, which means "sell at base price
even if the catalogue has a markup"). A nil catalogue_markup with a
nil item override returns the base price unchanged.
Returns nil if the item has no base price. Both percentage values
should be Decimals (e.g., Decimal.new("15.0") for 15%).
Examples
# Item has no override — inherits catalogue's 20%
Item.sale_price(%Item{base_price: Decimal.new("100"), markup_percentage: nil}, Decimal.new("20"))
#=> Decimal.new("120.00")
# Item explicitly overrides to 50% — catalogue markup is ignored
Item.sale_price(%Item{base_price: Decimal.new("100"), markup_percentage: Decimal.new("50")}, Decimal.new("20"))
#=> Decimal.new("150.00")
# Item override of 0 means "sell at base price" even if catalogue marks up
Item.sale_price(%Item{base_price: Decimal.new("100"), markup_percentage: Decimal.new("0")}, Decimal.new("20"))
#=> Decimal.new("100.00")