Add Suspension and ReasonCodes to model
This commit is contained in:
parent
365d679d76
commit
4c7b208e6e
|
@ -1053,6 +1053,21 @@ class MemberInfo(Base):
|
|||
Reference to the :class:`MemberInfo` record to which the note applies.
|
||||
"""))
|
||||
|
||||
suspension = orm.relationship(
|
||||
'Suspension',
|
||||
primaryjoin='Suspension.card_number == MemberInfo.card_number',
|
||||
foreign_keys='Suspension.card_number',
|
||||
uselist=False,
|
||||
doc="""
|
||||
Suspension record for the member, if applicable.
|
||||
""",
|
||||
backref=orm.backref(
|
||||
'member_info',
|
||||
doc="""
|
||||
Reference to the :class:`MemberInfo` record to which the suspension
|
||||
applies.
|
||||
"""))
|
||||
|
||||
@property
|
||||
def full_name(self):
|
||||
return '{} {}'.format(self.first_name or '', self.last_name or '').strip()
|
||||
|
@ -1145,6 +1160,51 @@ class MemberNote(Base):
|
|||
return self.note or ""
|
||||
|
||||
|
||||
class ReasonCode(Base):
|
||||
"""
|
||||
Reason codes for legacy account suspensions.
|
||||
"""
|
||||
__tablename__ = 'reasoncodes'
|
||||
|
||||
mask = sa.Column(sa.Integer(), nullable=False, primary_key=True, autoincrement=False)
|
||||
|
||||
text_string = sa.Column('textStr', sa.String(length=100), nullable=True)
|
||||
|
||||
def __str__(self):
|
||||
return "#{}: {}".format(self.mask, self.text_string)
|
||||
|
||||
|
||||
class Suspension(Base):
|
||||
"""
|
||||
Suspension status for legacy customer accounts.
|
||||
"""
|
||||
__tablename__ = 'suspensions'
|
||||
__table_args__ = (
|
||||
sa.ForeignKeyConstraint(['reasoncode'], ['reasoncodes.mask']),
|
||||
)
|
||||
|
||||
card_number = sa.Column('cardno', sa.Integer(), nullable=False, primary_key=True, autoincrement=False)
|
||||
|
||||
type = sa.Column(sa.String(length=1), nullable=True)
|
||||
|
||||
memtype1 = sa.Column(sa.Integer(), nullable=True)
|
||||
|
||||
memtype2 = sa.Column(sa.String(length=6), nullable=True)
|
||||
|
||||
suspension_date = sa.Column('suspDate', sa.DateTime(), nullable=True)
|
||||
|
||||
reason = sa.Column(sa.Text(), nullable=True)
|
||||
|
||||
mail_flag = sa.Column('mailflag', sa.Integer(), nullable=True)
|
||||
|
||||
discount = sa.Column(sa.Integer(), nullable=True)
|
||||
|
||||
charge_limit = sa.Column('chargelimit', sa.Numeric(precision=10, scale=2), nullable=True)
|
||||
|
||||
reason_code = sa.Column('reasoncode', sa.Integer(), nullable=True)
|
||||
reason_object = orm.relationship(ReasonCode)
|
||||
|
||||
|
||||
class HouseCoupon(Base):
|
||||
"""
|
||||
Represents a "house" (store) coupon.
|
||||
|
|
Loading…
Reference in a new issue