Add current (e.g. sale) price for POS batch row

also `txn_price_adusted` flag
This commit is contained in:
Lance Edgar 2023-10-18 21:22:27 -05:00
parent 102bc463c3
commit eef7208b18
3 changed files with 68 additions and 3 deletions

View file

@ -197,9 +197,14 @@ class POSBatchHandler(BatchHandler):
if regprice:
row.reg_price = regprice.price
txnprice = product.current_price or product.regular_price
if txnprice:
row.txn_price = txnprice.price
curprice = product.current_price
if curprice:
row.cur_price = curprice.price
row.cur_price_type = curprice.type
row.cur_price_start = curprice.starts
row.cur_price_end = curprice.ends
row.txn_price = row.cur_price or row.reg_price
if row.txn_price:
row.sales_total = row.txn_price * row.quantity
@ -388,6 +393,7 @@ class POSBatchHandler(BatchHandler):
orig_txn_price = orig_row.txn_price
orig_sales_total = orig_row.sales_total
orig_row.txn_price = txn_price
orig_row.txn_price_adjusted = True
orig_row.sales_total = orig_row.quantity * orig_row.txn_price
# adjust totals

View file

@ -0,0 +1,39 @@
# -*- coding: utf-8; -*-
"""add batch_pos_row.cur_price
Revision ID: e112f75359b3
Revises: 7f025fc530cc
Create Date: 2023-10-18 18:42:24.745734
"""
# revision identifiers, used by Alembic.
revision = 'e112f75359b3'
down_revision = '7f025fc530cc'
branch_labels = None
depends_on = None
from alembic import op
import sqlalchemy as sa
import rattail.db.types
def upgrade():
# batch_pos_row
op.add_column('batch_pos_row', sa.Column('cur_price', sa.Numeric(precision=8, scale=3), nullable=True))
op.add_column('batch_pos_row', sa.Column('cur_price_type', sa.Integer(), nullable=True))
op.add_column('batch_pos_row', sa.Column('cur_price_start', sa.DateTime(), nullable=True))
op.add_column('batch_pos_row', sa.Column('cur_price_end', sa.DateTime(), nullable=True))
op.add_column('batch_pos_row', sa.Column('txn_price_adjusted', sa.Boolean(), nullable=True))
def downgrade():
# batch_pos_row
op.drop_column('batch_pos_row', 'txn_price_adjusted')
op.drop_column('batch_pos_row', 'cur_price_end')
op.drop_column('batch_pos_row', 'cur_price_start')
op.drop_column('batch_pos_row', 'cur_price_type')
op.drop_column('batch_pos_row', 'cur_price')

View file

@ -330,10 +330,30 @@ class POSBatchRow(BatchRowMixin, Base):
Regular price for the item.
""")
cur_price = sa.Column(sa.Numeric(precision=8, scale=3), nullable=True, doc="""
Current price for the item.
""")
cur_price_type = sa.Column(sa.Integer(), nullable=True, doc="""
Type code for the current price, if applicable.
""")
cur_price_start = sa.Column(sa.DateTime(), nullable=True, doc="""
Start date for current price, if applicable.
""")
cur_price_end = sa.Column(sa.DateTime(), nullable=True, doc="""
End date for current price, if applicable.
""")
txn_price = sa.Column(sa.Numeric(precision=8, scale=3), nullable=True, doc="""
Actual price paid for the item.
""")
txn_price_adjusted = sa.Column(sa.Boolean(), nullable=True, doc="""
Flag indicating the actual price was manually adjusted.
""")
sales_total = sa.Column(sa.Numeric(precision=9, scale=2), nullable=True, doc="""
Sales total for the item.
""")