Add basic support for HouseCoupon model
This commit is contained in:
parent
1a0a25661b
commit
57a1af850c
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# pyCOREPOS -- Python Interface to CORE POS
|
||||
# Copyright © 2018 Lance Edgar
|
||||
# Copyright © 2018-2019 Lance Edgar
|
||||
#
|
||||
# This file is part of pyCOREPOS.
|
||||
#
|
||||
|
@ -28,8 +28,8 @@ from __future__ import unicode_literals, absolute_import
|
|||
|
||||
import six
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.ext.associationproxy import association_proxy
|
||||
|
||||
|
||||
|
@ -88,7 +88,7 @@ class Subdepartment(Base):
|
|||
subdept_name = sa.Column(sa.String(length=30), nullable=True)
|
||||
|
||||
dept_ID = sa.Column(sa.SmallInteger(), nullable=True)
|
||||
department = relationship(
|
||||
department = orm.relationship(
|
||||
Department,
|
||||
doc="""
|
||||
Reference to the parent :class:`Department` for this subdepartment.
|
||||
|
@ -113,7 +113,7 @@ class Vendor(Base):
|
|||
|
||||
discountRate = sa.Column(sa.Float(), nullable=True)
|
||||
|
||||
contact = relationship(
|
||||
contact = orm.relationship(
|
||||
'VendorContact',
|
||||
uselist=False, doc="""
|
||||
Reference to the :class:`VendorContact` instance for this vendor.
|
||||
|
@ -254,7 +254,7 @@ class Product(Base):
|
|||
|
||||
current_origin_id = sa.Column(sa.Integer(), nullable=True, default=0)
|
||||
|
||||
department = relationship(
|
||||
department = orm.relationship(
|
||||
Department,
|
||||
primaryjoin=Department.dept_no == dept_no,
|
||||
foreign_keys=[dept_no],
|
||||
|
@ -262,7 +262,7 @@ class Product(Base):
|
|||
Reference to the :class:`Department` to which the product belongs.
|
||||
""")
|
||||
|
||||
vendor = relationship(
|
||||
vendor = orm.relationship(
|
||||
Vendor,
|
||||
primaryjoin=Vendor.vendorID == default_vendor_id,
|
||||
foreign_keys=[default_vendor_id],
|
||||
|
@ -385,7 +385,7 @@ class Customer(Base):
|
|||
|
||||
LastChange = sa.Column(sa.DateTime(), nullable=False)
|
||||
|
||||
member_type = relationship(
|
||||
member_type = orm.relationship(
|
||||
MemberType,
|
||||
primaryjoin=MemberType.memtype == memType,
|
||||
foreign_keys=[memType],
|
||||
|
@ -393,7 +393,7 @@ class Customer(Base):
|
|||
Reference to the :class:`MemberType` to which this member belongs.
|
||||
""")
|
||||
|
||||
member_info = relationship(
|
||||
member_info = orm.relationship(
|
||||
'MemberInfo',
|
||||
primaryjoin='MemberInfo.card_no == Customer.CardNo',
|
||||
foreign_keys=[CardNo],
|
||||
|
@ -436,7 +436,7 @@ class MemberInfo(Base):
|
|||
|
||||
ads_OK = sa.Column(sa.Boolean(), nullable=True, default=True)
|
||||
|
||||
customers = relationship(
|
||||
customers = orm.relationship(
|
||||
Customer,
|
||||
primaryjoin=Customer.CardNo == card_no,
|
||||
foreign_keys=[Customer.CardNo],
|
||||
|
@ -452,3 +452,44 @@ class MemberInfo(Base):
|
|||
|
||||
def __unicode__(self):
|
||||
return self.full_name
|
||||
|
||||
|
||||
@six.python_2_unicode_compatible
|
||||
class HouseCoupon(Base):
|
||||
"""
|
||||
Represents a "house" (store) coupon.
|
||||
"""
|
||||
__tablename__ = 'houseCoupons'
|
||||
__table_args__ = (
|
||||
sa.ForeignKeyConstraint(['department'], ['departments.dept_no']),
|
||||
)
|
||||
|
||||
coupon_id = sa.Column('coupID', sa.Integer(), primary_key=True, nullable=False)
|
||||
|
||||
description = sa.Column(sa.String(length=30), nullable=True)
|
||||
|
||||
start_date = sa.Column('startDate', sa.DateTime(), nullable=True)
|
||||
|
||||
end_date = sa.Column('endDate', sa.DateTime(), nullable=True)
|
||||
|
||||
limit = sa.Column(sa.SmallInteger(), nullable=True)
|
||||
|
||||
member_only = sa.Column('memberOnly', sa.SmallInteger(), nullable=True)
|
||||
|
||||
discount_type = sa.Column('discountType', sa.String(length=2), nullable=True)
|
||||
|
||||
discount_value = sa.Column('discountValue', sa.Numeric(precision=10, scale=2), nullable=True)
|
||||
|
||||
min_type = sa.Column('minType', sa.String(length=2), nullable=True)
|
||||
|
||||
min_value = sa.Column('minValue', sa.Numeric(precision=10, scale=2), nullable=True)
|
||||
|
||||
department_id = sa.Column('department', sa.Integer(), nullable=True)
|
||||
department = orm.relationship(Department)
|
||||
|
||||
auto = sa.Column(sa.Boolean(), nullable=True, default=False)
|
||||
|
||||
virtual_only = sa.Column('virtualOnly', sa.Boolean(), nullable=True, default=False)
|
||||
|
||||
def __str__(self):
|
||||
return self.description or ''
|
||||
|
|
50
corepos/enum.py
Normal file
50
corepos/enum.py
Normal file
|
@ -0,0 +1,50 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
################################################################################
|
||||
#
|
||||
# pyCOREPOS -- Python Interface to CORE POS
|
||||
# Copyright © 2018-2019 Lance Edgar
|
||||
#
|
||||
# This file is part of pyCOREPOS.
|
||||
#
|
||||
# pyCOREPOS 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.
|
||||
#
|
||||
# pyCOREPOS 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
|
||||
# pyCOREPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
"""
|
||||
CORE POS enumeration constants
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals, absolute_import
|
||||
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
except ImportError:
|
||||
from ordereddict import OrderedDict
|
||||
|
||||
|
||||
HOUSE_COUPON_MEMBER_ONLY_NO = 0
|
||||
HOUSE_COUPON_MEMBER_ONLY_YES = 1
|
||||
HOUSE_COUPON_MEMBER_ONLY_PLUS = 2
|
||||
|
||||
HOUSE_COUPON_MEMBER_ONLY = OrderedDict([
|
||||
(HOUSE_COUPON_MEMBER_ONLY_NO, "No"),
|
||||
(HOUSE_COUPON_MEMBER_ONLY_YES, "Yes"),
|
||||
(HOUSE_COUPON_MEMBER_ONLY_PLUS, "Plus"),
|
||||
])
|
||||
|
||||
|
||||
HOUSE_COUPON_DISCOUNT_TYPE_QUANTITY = 'Q'
|
||||
|
||||
HOUSE_COUPON_DISCOUNT_TYPE = OrderedDict([
|
||||
(HOUSE_COUPON_DISCOUNT_TYPE_QUANTITY, "Quantity Discount"),
|
||||
])
|
3
setup.py
3
setup.py
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# pyCOREPOS -- Python Interface to CORE POS
|
||||
# Copyright © 2018 Lance Edgar
|
||||
# Copyright © 2018-2019 Lance Edgar
|
||||
#
|
||||
# This file is part of pyCOREPOS.
|
||||
#
|
||||
|
@ -63,6 +63,7 @@ requires = [
|
|||
# package # low high
|
||||
|
||||
'mysql-connector-python', # 8.0.6
|
||||
'six', # 1.12.0
|
||||
'SQLAlchemy', # 0.9.8
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in a new issue