Add CustomerShopper.corepos_customer_id
and refactor importers
removes phone/email support for now..also change how we handle default/empty values for member start/end date..
This commit is contained in:
parent
86a8e2d241
commit
660637522d
7 changed files with 150 additions and 37 deletions
|
@ -0,0 +1,51 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
"""add CustomerShopper.corepos_customer_id
|
||||
|
||||
Revision ID: b025df7cf41b
|
||||
Revises: ae74c537ea51
|
||||
Create Date: 2023-06-10 13:24:40.735959
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'b025df7cf41b'
|
||||
down_revision = 'ae74c537ea51'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import rattail.db.types
|
||||
|
||||
|
||||
|
||||
def upgrade():
|
||||
|
||||
# corepos_customer_shopper
|
||||
op.create_table('corepos_customer_shopper',
|
||||
sa.Column('uuid', sa.String(length=32), nullable=False),
|
||||
sa.Column('corepos_customer_id', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['uuid'], ['customer_shopper.uuid'], name='corepos_customer_shopper_fk_shopper'),
|
||||
sa.PrimaryKeyConstraint('uuid')
|
||||
)
|
||||
op.create_table('corepos_customer_shopper_version',
|
||||
sa.Column('uuid', sa.String(length=32), autoincrement=False, nullable=False),
|
||||
sa.Column('corepos_customer_id', sa.Integer(), autoincrement=False, nullable=True),
|
||||
sa.Column('transaction_id', sa.BigInteger(), autoincrement=False, nullable=False),
|
||||
sa.Column('end_transaction_id', sa.BigInteger(), nullable=True),
|
||||
sa.Column('operation_type', sa.SmallInteger(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('uuid', 'transaction_id')
|
||||
)
|
||||
op.create_index(op.f('ix_corepos_customer_shopper_version_end_transaction_id'), 'corepos_customer_shopper_version', ['end_transaction_id'], unique=False)
|
||||
op.create_index(op.f('ix_corepos_customer_shopper_version_operation_type'), 'corepos_customer_shopper_version', ['operation_type'], unique=False)
|
||||
op.create_index(op.f('ix_corepos_customer_shopper_version_transaction_id'), 'corepos_customer_shopper_version', ['transaction_id'], unique=False)
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
||||
# corepos_customer_shopper
|
||||
op.drop_index(op.f('ix_corepos_customer_shopper_version_transaction_id'), table_name='corepos_customer_shopper_version')
|
||||
op.drop_index(op.f('ix_corepos_customer_shopper_version_operation_type'), table_name='corepos_customer_shopper_version')
|
||||
op.drop_index(op.f('ix_corepos_customer_shopper_version_end_transaction_id'), table_name='corepos_customer_shopper_version')
|
||||
op.drop_table('corepos_customer_shopper_version')
|
||||
op.drop_table('corepos_customer_shopper')
|
|
@ -91,7 +91,8 @@ class CoreCustomer(model.Base):
|
|||
"""))
|
||||
|
||||
corepos_account_id = sa.Column(sa.Integer(), nullable=True, doc="""
|
||||
``Customers.customerAccountID`` value for this customer, within CORE-POS.
|
||||
``CustomerAccounts.customerAccountID`` value for this customer
|
||||
account, within CORE-POS.
|
||||
""")
|
||||
|
||||
corepos_card_number = sa.Column(sa.Integer(), nullable=True, doc="""
|
||||
|
@ -105,6 +106,42 @@ CoreCustomer.make_proxy(model.Customer, '_corepos', 'corepos_account_id')
|
|||
CoreCustomer.make_proxy(model.Customer, '_corepos', 'corepos_card_number')
|
||||
|
||||
|
||||
class CoreCustomerShopper(model.Base):
|
||||
"""
|
||||
CORE-specific extensions to
|
||||
:class:`~rattail:rattail.db.model.CustomerShopper`.
|
||||
"""
|
||||
__tablename__ = 'corepos_customer_shopper'
|
||||
__table_args__ = (
|
||||
sa.ForeignKeyConstraint(['uuid'], ['customer_shopper.uuid'],
|
||||
name='corepos_customer_shopper_fk_shopper'),
|
||||
)
|
||||
__versioned__ = {}
|
||||
|
||||
uuid = model.uuid_column(default=None)
|
||||
shopper = orm.relationship(
|
||||
model.CustomerShopper, doc="""
|
||||
Reference to the actual shopper record, which this one extends.
|
||||
""",
|
||||
cascade_backrefs=False,
|
||||
backref=orm.backref(
|
||||
'_corepos', doc="""
|
||||
Reference to the CORE-POS extension record for this customer.
|
||||
""",
|
||||
uselist=False,
|
||||
cascade='all, delete-orphan',
|
||||
cascade_backrefs=False))
|
||||
|
||||
corepos_customer_id = sa.Column(sa.Integer(), nullable=True, doc="""
|
||||
``Customers.customerID`` value for this shopper, within CORE-POS.
|
||||
""")
|
||||
|
||||
def __str__(self):
|
||||
return str(self.shopper)
|
||||
|
||||
CoreCustomerShopper.make_proxy(model.CustomerShopper, '_corepos', 'corepos_customer_id')
|
||||
|
||||
|
||||
class CoreMember(model.Base):
|
||||
"""
|
||||
CORE-specific extensions to :class:`rattail:rattail.db.model.Member`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue