V102: Catalogue discount + smart catalogues.
Two related catalogue features shipped together:
Discount
Mirrors the markup columns added in V89 (catalogue) and V97 (item override):
phoenix_kit_cat_catalogues.discount_percentage DECIMAL(7, 2) NOT NULL DEFAULT 0— the catalogue-wide default discount applied on top of the post-markup sale price.phoenix_kit_cat_items.discount_percentage DECIMAL(7, 2)— nullable per-item override.NULL= inherit the catalogue's discount; any set value (including0) overrides the catalogue's discount for that item.
The pricing chain becomes base → markup → discount:
sale_price = base_price * (1 + effective_markup / 100)
final_price = sale_price * (1 - effective_discount / 100)Smart catalogues
A smart catalogue's items reference other catalogues with a value + unit (e.g. a "Delivery" item says "5% of Kitchen, 3% of Plumbing, plus $20 flat of Hardware"). Consumers do the math; this module stores the user's intent.
phoenix_kit_cat_catalogues.kind VARCHAR(20) NOT NULL DEFAULT 'standard'— one of'standard'(existing behavior) or'smart'(items reference other catalogues).phoenix_kit_cat_items.default_value DECIMAL(12, 4)anddefault_unit VARCHAR(20)(both nullable) — per-item fallback that applies when a rule row has NULLvalue/unit.- New table
phoenix_kit_cat_item_catalogue_rulesstoring one row per (item, referenced_catalogue) pair, with nullablevalue+unit(inherit from item defaults) and aposition INTfor UI ordering. Unit vocabulary is open-ended VARCHAR; v1 uses'percent'and'flat'. Self- and smart-to-smart references are intentionally allowed — consumers handle cycles at math time.
All operations are idempotent.
Summary
Functions
Rolls V102 back: drops the rules table and both sets of added columns (discount + smart-catalogue).