fix: add base class for all transaction tables, views
also rename some classes; add `dlogBig` for archive view
This commit is contained in:
parent
464f107a88
commit
47c23a65ae
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# pyCOREPOS -- Python Interface to CORE POS
|
||||
# Copyright © 2018-2023 Lance Edgar
|
||||
# Copyright © 2018-2024 Lance Edgar
|
||||
#
|
||||
# This file is part of pyCOREPOS.
|
||||
#
|
||||
|
@ -26,14 +26,25 @@ CORE Office "arch" data model
|
|||
|
||||
from sqlalchemy import orm
|
||||
|
||||
from corepos.db.office_trans.model import TransactionDetailBase
|
||||
from corepos.db.office_trans.model import DTransactionBase, DLogBase
|
||||
|
||||
|
||||
Base = orm.declarative_base()
|
||||
|
||||
|
||||
class TransactionDetail(TransactionDetailBase, Base):
|
||||
class BigArchive(DTransactionBase, Base):
|
||||
"""
|
||||
Represents a POS transaction detail record.
|
||||
Represents a record from ``bigArchive`` table.
|
||||
"""
|
||||
__tablename__ = 'bigArchive'
|
||||
|
||||
|
||||
# TODO: deprecate / remove this
|
||||
TransactionDetail = BigArchive
|
||||
|
||||
|
||||
class DLogBig(DLogBase, Base):
|
||||
"""
|
||||
Represents a record from ``dlogBig`` view.
|
||||
"""
|
||||
__tablename__ = 'dlogBig'
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# pyCOREPOS -- Python Interface to CORE POS
|
||||
# Copyright © 2018-2023 Lance Edgar
|
||||
# Copyright © 2018-2024 Lance Edgar
|
||||
#
|
||||
# This file is part of pyCOREPOS.
|
||||
#
|
||||
|
@ -68,7 +68,7 @@ class EquityLiveBalance(Base):
|
|||
start_date = sa.Column('startdate', sa.DateTime(), nullable=True)
|
||||
|
||||
|
||||
class TransactionDetailBase(object):
|
||||
class TransactionDetailBase:
|
||||
"""
|
||||
Represents a POS transaction detail record.
|
||||
"""
|
||||
|
@ -86,10 +86,12 @@ class TransactionDetailBase(object):
|
|||
transaction_number = sa.Column('trans_no', sa.Integer(), nullable=True)
|
||||
transaction_type = sa.Column('trans_type', sa.String(length=1), nullable=True)
|
||||
transaction_subtype = sa.Column('trans_subtype', sa.String(length=2), nullable=True)
|
||||
transaction_status = sa.Column('trans_status', sa.String(length=1), nullable=True)
|
||||
|
||||
# timestamps
|
||||
date_time = sa.Column('datetime', sa.DateTime(), nullable=True)
|
||||
trans_status = sa.Column(sa.String(length=1), nullable=True)
|
||||
|
||||
@declared_attr
|
||||
def transaction_status(self):
|
||||
return orm.synonym('trans_status')
|
||||
|
||||
# cashier
|
||||
employee_number = sa.Column('emp_no', sa.Integer(), nullable=True)
|
||||
|
@ -115,7 +117,11 @@ class TransactionDetailBase(object):
|
|||
|
||||
cost = sa.Column(sa.Numeric(precision=10, scale=2), nullable=True)
|
||||
|
||||
unit_price = sa.Column('unitPrice', sa.Numeric(precision=10, scale=2), nullable=True)
|
||||
unitPrice = sa.Column('unitPrice', sa.Numeric(precision=10, scale=2), nullable=True)
|
||||
|
||||
@declared_attr
|
||||
def unit_price(self):
|
||||
return orm.synonym('unitPrice')
|
||||
|
||||
total = sa.Column(sa.Numeric(precision=10, scale=2), nullable=True)
|
||||
|
||||
|
@ -161,8 +167,22 @@ class TransactionDetailBase(object):
|
|||
return self.description or ''
|
||||
|
||||
|
||||
class TransactionDetail(TransactionDetailBase, Base):
|
||||
class DTransactionBase(TransactionDetailBase):
|
||||
|
||||
date_time = sa.Column('datetime', sa.DateTime(), nullable=True)
|
||||
|
||||
|
||||
class DLogBase(TransactionDetailBase):
|
||||
|
||||
date_time = sa.Column('tdate', sa.DateTime(), nullable=True)
|
||||
|
||||
|
||||
class DTransaction(DTransactionBase, Base):
|
||||
"""
|
||||
Represents a POS transaction detail record.
|
||||
Represents a record from ``dtransactions`` table.
|
||||
"""
|
||||
__tablename__ = 'dtransactions'
|
||||
|
||||
|
||||
# TODO: deprecate / remove this
|
||||
TransactionDetail = DTransaction
|
||||
|
|
Loading…
Reference in a new issue