Files
xenia-pos-local/local_backend/migrations/versions/0040_channel_prices.py
T
bonaminandClaude Opus 5.5 94c10944ed 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>
2026-11-20 15:11:35 +02:00

41 lines
1.5 KiB
Python

"""Order channel prices (UI review 2026-11-20): a product's price at a sales point, set per
product, per category or for the whole channel (services/channel_prices.py).
Revision ID: 0040_channel_prices
Revises: 0039_expense_lines_documents
Create Date: 2026-11-20 17:00:00
"""
from alembic import op
import sqlalchemy as sa
from core.timeutil import UTCDateTime
revision = '0040_channel_prices'
down_revision = '0039_expense_lines_documents'
branch_labels = None
depends_on = None
def upgrade() -> None:
op.create_table(
'channel_prices',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(), nullable=True),
sa.Column('sales_points', sa.Text(), nullable=False),
sa.Column('product_ids', sa.Text(), nullable=False),
sa.Column('category_ids', sa.Text(), nullable=False),
sa.Column('action_type', sa.String(), nullable=False),
sa.Column('value', sa.Float(), nullable=False),
sa.Column('round_to', sa.String(), nullable=True),
sa.Column('is_active', sa.Boolean(), nullable=False),
sa.Column('created_at', UTCDateTime(), nullable=True),
sa.Column('updated_at', UTCDateTime(), nullable=True),
sa.Column('updated_by', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['updated_by'], ['users.id']),
sa.PrimaryKeyConstraint('id'),
)
op.create_index('ix_channel_prices_id', 'channel_prices', ['id'])
def downgrade() -> None:
op.drop_table('channel_prices')