2020-03-04 19:05:55 -06:00
|
|
|
# -*- coding: utf-8; -*-
|
|
|
|
################################################################################
|
|
|
|
#
|
|
|
|
# Rattail -- Retail Software Framework
|
2023-06-05 20:45:45 -05:00
|
|
|
# Copyright © 2010-2023 Lance Edgar
|
2020-03-04 19:05:55 -06:00
|
|
|
#
|
|
|
|
# This file is part of Rattail.
|
|
|
|
#
|
|
|
|
# Rattail is free software: you can redistribute it and/or modify it under the
|
|
|
|
# terms of the GNU General Public License as published by the Free Software
|
|
|
|
# Foundation, either version 3 of the License, or (at your option) any later
|
|
|
|
# version.
|
|
|
|
#
|
|
|
|
# Rattail is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
# details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along with
|
|
|
|
# Rattail. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
"""
|
|
|
|
Database schema extensions for CORE-POS integration
|
|
|
|
"""
|
|
|
|
|
|
|
|
import sqlalchemy as sa
|
|
|
|
from sqlalchemy import orm
|
|
|
|
|
|
|
|
from rattail.db import model
|
|
|
|
|
|
|
|
|
2020-03-16 16:55:48 -05:00
|
|
|
class CorePerson(model.Base):
|
|
|
|
"""
|
|
|
|
CORE-specific extensions to :class:`rattail:rattail.db.model.Person`.
|
|
|
|
"""
|
|
|
|
__tablename__ = 'corepos_person'
|
|
|
|
__table_args__ = (
|
|
|
|
sa.ForeignKeyConstraint(['uuid'], ['person.uuid'],
|
|
|
|
name='corepos_person_fk_person'),
|
|
|
|
)
|
|
|
|
__versioned__ = {}
|
|
|
|
|
|
|
|
uuid = model.uuid_column(default=None)
|
|
|
|
person = orm.relationship(
|
|
|
|
model.Person,
|
|
|
|
doc="""
|
|
|
|
Reference to the actual person record, which this one extends.
|
|
|
|
""",
|
|
|
|
backref=orm.backref(
|
|
|
|
'_corepos',
|
|
|
|
uselist=False,
|
|
|
|
cascade='all, delete-orphan',
|
|
|
|
doc="""
|
|
|
|
Reference to the CORE-POS extension record for this person.
|
|
|
|
"""))
|
|
|
|
|
|
|
|
corepos_customer_id = sa.Column(sa.Integer(), nullable=False, doc="""
|
|
|
|
``Customers.customerID`` value for this person, within CORE-POS.
|
|
|
|
""")
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return str(self.person)
|
|
|
|
|
|
|
|
CorePerson.make_proxy(model.Person, '_corepos', 'corepos_customer_id')
|
2020-03-04 19:05:55 -06:00
|
|
|
|
|
|
|
|
2023-10-01 19:40:46 -05:00
|
|
|
class CoreEmployee(model.Base):
|
|
|
|
"""
|
|
|
|
CORE-specific extensions to :class:`~rattail:rattail.db.model.Employee`
|
|
|
|
"""
|
|
|
|
__tablename__ = 'corepos_employee'
|
|
|
|
__table_args__ = (
|
|
|
|
sa.ForeignKeyConstraint(['uuid'], ['employee.uuid'],
|
|
|
|
name='corepos_employee_fk_employee'),
|
|
|
|
)
|
|
|
|
__versioned__ = {}
|
|
|
|
|
|
|
|
uuid = model.uuid_column(default=None)
|
|
|
|
employee = orm.relationship(
|
|
|
|
model.Employee,
|
|
|
|
doc="""
|
|
|
|
Reference to the actual employee record, which this one extends.
|
|
|
|
""",
|
|
|
|
backref=orm.backref(
|
|
|
|
'_corepos',
|
|
|
|
uselist=False,
|
|
|
|
cascade='all, delete-orphan',
|
|
|
|
doc="""
|
|
|
|
Reference to the CORE-POS extension record for this employee.
|
|
|
|
"""))
|
|
|
|
|
|
|
|
corepos_number = sa.Column(sa.Integer(), nullable=True, doc="""
|
|
|
|
``employees.emp_no`` value for this employee, within CORE-POS.
|
|
|
|
""")
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return str(self.employee)
|
|
|
|
|
|
|
|
CoreEmployee.make_proxy(model.Employee, '_corepos', 'corepos_number')
|
|
|
|
|
|
|
|
|
2020-07-06 21:16:01 -05:00
|
|
|
class CoreCustomer(model.Base):
|
|
|
|
"""
|
|
|
|
CORE-specific extensions to :class:`rattail:rattail.db.model.Customer`.
|
|
|
|
"""
|
|
|
|
__tablename__ = 'corepos_customer'
|
|
|
|
__table_args__ = (
|
|
|
|
sa.ForeignKeyConstraint(['uuid'], ['customer.uuid'],
|
|
|
|
name='corepos_customer_fk_customer'),
|
|
|
|
)
|
|
|
|
__versioned__ = {}
|
|
|
|
|
|
|
|
uuid = model.uuid_column(default=None)
|
|
|
|
customer = orm.relationship(
|
|
|
|
model.Customer,
|
|
|
|
doc="""
|
|
|
|
Reference to the actual customer record, which this one extends.
|
|
|
|
""",
|
|
|
|
backref=orm.backref(
|
|
|
|
'_corepos',
|
|
|
|
uselist=False,
|
|
|
|
cascade='all, delete-orphan',
|
|
|
|
doc="""
|
|
|
|
Reference to the CORE-POS extension record for this customer.
|
|
|
|
"""))
|
|
|
|
|
2023-06-05 20:45:45 -05:00
|
|
|
corepos_account_id = sa.Column(sa.Integer(), nullable=True, doc="""
|
2023-06-10 14:35:08 -05:00
|
|
|
``CustomerAccounts.customerAccountID`` value for this customer
|
|
|
|
account, within CORE-POS.
|
2020-07-06 21:16:01 -05:00
|
|
|
""")
|
|
|
|
|
2023-06-05 20:45:45 -05:00
|
|
|
corepos_card_number = sa.Column(sa.Integer(), nullable=True, doc="""
|
|
|
|
``custdata.CardNo`` value for this customer, within CORE-POS.
|
|
|
|
""")
|
|
|
|
|
2020-07-06 21:16:01 -05:00
|
|
|
def __str__(self):
|
|
|
|
return str(self.customer)
|
|
|
|
|
|
|
|
CoreCustomer.make_proxy(model.Customer, '_corepos', 'corepos_account_id')
|
2023-06-05 20:45:45 -05:00
|
|
|
CoreCustomer.make_proxy(model.Customer, '_corepos', 'corepos_card_number')
|
2020-07-06 21:16:01 -05:00
|
|
|
|
|
|
|
|
2023-06-10 14:35:08 -05:00
|
|
|
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))
|
|
|
|
|
2023-06-11 20:55:46 -05:00
|
|
|
# please note, there is *not* a unique constraint on this field.
|
|
|
|
# that is intentional, for now, to give some breathing room for
|
|
|
|
# testing etc.
|
2023-06-10 14:35:08 -05:00
|
|
|
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')
|
|
|
|
|
|
|
|
|
2020-07-06 21:16:01 -05:00
|
|
|
class CoreMember(model.Base):
|
2020-03-04 19:05:55 -06:00
|
|
|
"""
|
2020-07-06 21:16:01 -05:00
|
|
|
CORE-specific extensions to :class:`rattail:rattail.db.model.Member`.
|
2020-03-04 19:05:55 -06:00
|
|
|
"""
|
2020-07-06 21:16:01 -05:00
|
|
|
__tablename__ = 'corepos_member'
|
2020-03-04 19:05:55 -06:00
|
|
|
__table_args__ = (
|
2020-07-06 21:16:01 -05:00
|
|
|
sa.ForeignKeyConstraint(['uuid'], ['member.uuid'],
|
|
|
|
name='corepos_member_fk_member'),
|
2020-03-04 19:05:55 -06:00
|
|
|
)
|
|
|
|
__versioned__ = {}
|
|
|
|
|
|
|
|
uuid = model.uuid_column(default=None)
|
2020-07-06 21:16:01 -05:00
|
|
|
member = orm.relationship(
|
|
|
|
model.Member,
|
2020-03-04 19:05:55 -06:00
|
|
|
doc="""
|
2020-07-06 21:16:01 -05:00
|
|
|
Reference to the actual member record, which this one extends.
|
2020-03-04 19:05:55 -06:00
|
|
|
""",
|
|
|
|
backref=orm.backref(
|
|
|
|
'_corepos',
|
|
|
|
uselist=False,
|
|
|
|
cascade='all, delete-orphan',
|
|
|
|
doc="""
|
2020-07-06 21:16:01 -05:00
|
|
|
Reference to the CORE-POS extension record for this member.
|
2020-03-04 19:05:55 -06:00
|
|
|
"""))
|
|
|
|
|
2023-10-12 10:34:46 -05:00
|
|
|
corepos_account_id = sa.Column(sa.Integer(), nullable=True, doc="""
|
2020-07-06 21:16:01 -05:00
|
|
|
``Customers.customerAccountID`` value for this member, within CORE-POS.
|
2020-03-04 19:05:55 -06:00
|
|
|
""")
|
|
|
|
|
2023-10-12 10:34:46 -05:00
|
|
|
corepos_card_number = sa.Column(sa.Integer(), nullable=True, doc="""
|
|
|
|
``meminfo.card_no`` / ``CustomerAccounts.cardNo`` value for this
|
|
|
|
member, within CORE-POS.
|
|
|
|
""")
|
|
|
|
|
2020-03-04 19:05:55 -06:00
|
|
|
def __str__(self):
|
2020-07-06 21:16:01 -05:00
|
|
|
return str(self.member)
|
2020-03-04 19:05:55 -06:00
|
|
|
|
2020-07-06 21:16:01 -05:00
|
|
|
CoreMember.make_proxy(model.Member, '_corepos', 'corepos_account_id')
|
2023-10-12 10:34:46 -05:00
|
|
|
CoreMember.make_proxy(model.Member, '_corepos', 'corepos_card_number')
|
2023-09-07 17:49:28 -05:00
|
|
|
|
|
|
|
|
|
|
|
class CoreMemberEquityPayment(model.Base):
|
|
|
|
"""
|
|
|
|
CORE-specific extensions to
|
|
|
|
:class:`~rattail:rattail.db.model.MemberEquityPayment`.
|
|
|
|
"""
|
|
|
|
__tablename__ = 'corepos_member_equity_payment'
|
|
|
|
__table_args__ = (
|
|
|
|
sa.ForeignKeyConstraint(['uuid'], ['member_equity_payment.uuid'],
|
|
|
|
name='corepos_member_equity_payment_fk_payment'),
|
|
|
|
)
|
|
|
|
__versioned__ = {}
|
|
|
|
|
|
|
|
uuid = model.uuid_column(default=None)
|
|
|
|
payment = orm.relationship(
|
|
|
|
model.MemberEquityPayment,
|
|
|
|
doc="""
|
|
|
|
Reference to the actual payment record, which this one extends.
|
|
|
|
""",
|
|
|
|
backref=orm.backref(
|
|
|
|
'_corepos',
|
|
|
|
uselist=False,
|
|
|
|
cascade='all, delete-orphan',
|
|
|
|
doc="""
|
|
|
|
Reference to the CORE-POS extension record for this payment.
|
|
|
|
"""))
|
|
|
|
|
|
|
|
corepos_card_number = sa.Column(sa.Integer(), nullable=False, doc="""
|
|
|
|
``stockpurchases.card_no`` value for this payment, within CORE-POS.
|
|
|
|
""")
|
|
|
|
|
|
|
|
corepos_transaction_number = sa.Column(sa.String(length=50), nullable=True, doc="""
|
|
|
|
``stockpurchases.trans_num`` value for this payment, within CORE-POS.
|
|
|
|
""")
|
|
|
|
|
|
|
|
corepos_transaction_id = sa.Column(sa.Integer(), nullable=True, doc="""
|
|
|
|
``stockpurchases.trans_id`` value for this payment, within CORE-POS.
|
|
|
|
""")
|
|
|
|
|
|
|
|
corepos_department_number = sa.Column(sa.Integer(), nullable=True, doc="""
|
|
|
|
``stockpurchases.dept`` value for this payment, within CORE-POS.
|
|
|
|
""")
|
|
|
|
|
2023-09-13 21:29:16 -05:00
|
|
|
corepos_datetime = sa.Column(sa.DateTime(), nullable=True, doc="""
|
|
|
|
``stockpurchases.datetime`` value for this payment, within CORE-POS.
|
|
|
|
""")
|
|
|
|
|
2023-09-07 17:49:28 -05:00
|
|
|
def __str__(self):
|
|
|
|
return str(self.payment)
|
|
|
|
|
|
|
|
CoreMemberEquityPayment.make_proxy(model.MemberEquityPayment, '_corepos', 'corepos_card_number')
|
|
|
|
CoreMemberEquityPayment.make_proxy(model.MemberEquityPayment, '_corepos', 'corepos_transaction_number')
|
|
|
|
CoreMemberEquityPayment.make_proxy(model.MemberEquityPayment, '_corepos', 'corepos_transaction_id')
|
|
|
|
CoreMemberEquityPayment.make_proxy(model.MemberEquityPayment, '_corepos', 'corepos_department_number')
|
2023-09-13 21:29:16 -05:00
|
|
|
CoreMemberEquityPayment.make_proxy(model.MemberEquityPayment, '_corepos', 'corepos_datetime')
|