feat(backend): order channel prices: a product's price per sales point, per product / category / channel

channel_prices rules (migration 0040, services/channel_prices.py): for one or more sales points,
set the price (one product), add an amount or a percentage (with rounding), for listed products,
the products of listed categories, or everything sold there. The most precise rule wins (product
> category > channel, newest on a tie); resolve_price starts from it, so tills, phones, menus and
the cloud's per-sales-point prices all follow. /api/pricing/channel-prices (CRUD) and
/product/{id} (the product editor's quick edit of its own rules, with the fallback shown).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 15:11:35 +02:00
co-authored by Claude Opus 5.5
parent f3fc3340d2
commit 94c10944ed
9 changed files with 400 additions and 1 deletions
+9 -1
View File
@@ -305,9 +305,17 @@ def resolve_price(
order_id must be set on the PriceEvents before writing them; the caller does this.
"""
from models.pricing import PriceModifier
from services import channel_prices
base = product.base_price + options_extra
events: list[PriceEvent] = []
# the price at this sales point (order channel prices, 2026-11-20): the base for the rest
own, rule = channel_prices.price_at(db, product, ctx.channel) if ctx.channel else (product.base_price, None)
base = own + options_extra
if rule is not None:
events.append(PriceEvent(order_id=0, order_item_id=None, event_type="channel_price",
price_before=product.base_price + options_extra, price_after=base,
delta_amount=round(base - product.base_price - options_extra, 4),
conditions_snapshot={"channel_price_id": rule.id, "sales_point": ctx.channel}))
# --- Load modifiers ---
# Item-scoped modifiers for this product