PhoenixKitCatalogue.Schemas.Item (PhoenixKitCatalogue v0.1.8)

Copy Markdown View Source

Schema for catalogue items — individual products/materials with SKU and pricing.

Summary

Functions

Calculates the sale price for an item given a markup percentage.

Types

t()

@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(),
  name: term(),
  sku: term(),
  status: term(),
  unit: term(),
  updated_at: term(),
  uuid: term()
}

Functions

allowed_units()

changeset(item, attrs)

sale_price(item, markup_percentage)

Calculates the sale price for an item given a markup percentage.

Returns nil if the item has no base price. The markup_percentage should be a Decimal (e.g., Decimal.new("15.0") for 15%).

Examples

Item.sale_price(item, Decimal.new("20.0"))  # base_price * 1.20
Item.sale_price(item, nil)                   # returns base_price unchanged