Catalogue 0.1.10: Smart catalogues and discounts
Catalogue 0.1.10 adds smart catalogues, for items such as delivery whose cost depends on other catalogues, and a discount that applies after the markup.
Smart catalogues
The catalogue form gets a Kind choice between standard catalogues, whose items are priced directly, and smart ones, whose items reference other catalogues. A smart item has a Catalogue Rules section: tick the catalogues it applies to and give each a value in Percent (%) or Flat, with a Default Value and Default Unit for blank rows. The module stores the rules; turning them into an order price is left to the app. A catalogue that smart items refer to cannot be deleted for good.
Discounts and fixes
A catalogue has a Discount Percentage (0 to 100), applied after the markup, and an item can override it with Discount Override (%). Buttons show Saving… or Deleting… while they work, and a malformed delete request no longer crashes the page.
Upgrading
Needs PhoenixKit 1.7.102 or later for the V102 migration: run mix phoenix_kit.update first. Existing catalogues become standard ones with no discount.
Full release notes: Catalogue 0.1.10
0.1.10 · 20 April 2026
Added
- Smart catalogues (
kind: "smart") — catalogues whose items are priced as a rule-driven function of other catalogues. NewCatalogueRuleschema (phoenix_kit_cat_item_catalogue_rules) andput_catalogue_rules/3replace-all API with duplicate detection, per-legvalue/unitinheritance viaCatalogueRule.effective/2, andsmart_rules.syncedactivity logging (added/updated/removed counts). Requires phoenix_kit 1.7.102+ for the V102 migration. - Per-item discount override — nullable
Item.discount_percentage(nilinherits the catalogue’s discount, any value including0overrides). Pricing chain is nowbase → markup → discount, exposed viaItem.final_price/3,Item.effective_discount/2,Item.discount_amount/3, and the expandedCatalogue.item_pricing/1. - Smart-item defaults —
Item.default_value/Item.default_unitas fallbacks when aCatalogueRulerow hasnilvalue/unit (lets a user set “5% across everything” once and override specific catalogues). list_items_referencing_catalogue/1+catalogue_reference_count/1for warn-before-delete flows;permanently_delete_catalogue/2now refuses with{:error, {:referenced_by_smart_items, count}}when smart items still reference the catalogue, unlessforce: trueis passed.list_catalogues(kind: :smart)filter;Catalogue.move_item_to_catalogue/3for moving smart items across catalogues (categories don’t apply to smart items).- Scoped search:
search_items/2accepts:catalogue_uuids/:category_uuidsfilters composed viawhere dynamic; newscope_selectorcomponent pairs with it. category_counts_by_catalogue/0grouped-query helper.
Changed
- Context split — extracted the monolithic
catalogue.exinto 10 focused submodules (Rules,Search,Manufacturers,Suppliers,Links,Counts,PubSub,Translations,Helpers,ActivityLog). Public surface is unchanged — every caller still goes throughCatalogue.*viadefdelegate. - All form LiveViews (catalogue / category / item / manufacturer / supplier) migrated to Phoenix 1.7 component-style
<.input>/<.select>/<.textarea>/<.checkbox>bindings. The multilang wrapper now scopes only translatable fields (name / description) — pricing, classification, and actions render as siblings so a language switch doesn’t re-mount them.
Fixed
- Replace raising
confirm_delete!/1with a safecase-match +unexpected_confirm_event/2fallback across all 5 delete handlers (item / category / catalogue / manufacturer / supplier). Malformed push events flash + log instead of crashing the LV. Catalogue.ActivityLog.log/1now rescues — activity-logging failures no longer crash the primary mutation, matching the AGENTS.md contract.- New
log_operation_error/3helper in both admin LVs — structured logs carryingactor_uuid,entity_type,entity_uuid, andEcto.Changeset.traverse_errors-expanded field/message pairs so production incidents can be debugged from the log alone. - Search task-exit logs now include query, offset, and
catalogue_uuid. phx-disable-withon 9 destructive-action buttons (trash / restore on catalogue + category + item tables and cards) to prevent double-mutation on slow networks.
Catalogue 0.1.10. Install or update: {:phoenix_kit_catalogue, "~> 0.1"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.