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:
@@ -280,3 +280,23 @@ class WaiterDiscountSettings(Base):
|
||||
max_items_per_order = Column(Integer, nullable=True)
|
||||
|
||||
user = relationship("User", foreign_keys=[user_id])
|
||||
|
||||
|
||||
class ChannelPrice(Base):
|
||||
"""A price at one or more sales points (2026-11-20, services/channel_prices.py): for listed
|
||||
products, the products of listed categories, or (neither) everything sold there. The most
|
||||
precise rule wins: product > category > channel."""
|
||||
__tablename__ = "channel_prices"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
name = Column(String, nullable=True)
|
||||
sales_points = Column(Text, nullable=False, default="[]") # JSON ["online_delivery", …]
|
||||
product_ids = Column(Text, nullable=False, default="[]") # JSON [int]
|
||||
category_ids = Column(Text, nullable=False, default="[]") # JSON [int]
|
||||
action_type = Column(String, nullable=False) # 'set' | 'add_amount' | 'add_percent'
|
||||
value = Column(Float, nullable=False)
|
||||
round_to = Column(String, nullable=True) # as PriceModifier.round_to
|
||||
is_active = Column(Boolean, nullable=False, default=True)
|
||||
created_at = Column(UTCDateTime, default=utcnow)
|
||||
updated_at = Column(UTCDateTime, nullable=True)
|
||||
updated_by = Column(Integer, ForeignKey("users.id"), nullable=True)
|
||||
|
||||
Reference in New Issue
Block a user