Add new Customer and CustomerAccount models
This commit is contained in:
		
							parent
							
								
									92f522cf65
								
							
						
					
					
						commit
						9e850496e7
					
				
					 1 changed files with 115 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -390,9 +390,124 @@ class MemberType(Base):
 | 
			
		|||
        return self.description or ""
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CustomerAccount(Base):
 | 
			
		||||
    """
 | 
			
		||||
    This represents the customer account itself, and not a "person" per se.
 | 
			
		||||
 | 
			
		||||
    https://github.com/CORE-POS/IS4C/blob/master/fannie/classlib2.0/data/models/op/CustomerAccountsModel.php
 | 
			
		||||
    """
 | 
			
		||||
    __tablename__ = 'CustomerAccounts'
 | 
			
		||||
 | 
			
		||||
    id = sa.Column('customerAccountID', sa.Integer(), primary_key=True, autoincrement=True, nullable=False)
 | 
			
		||||
 | 
			
		||||
    card_number = sa.Column('cardNo', sa.Integer(), nullable=True,
 | 
			
		||||
                            unique=True, index=True)
 | 
			
		||||
 | 
			
		||||
    member_status = sa.Column('memberStatus', sa.String(length=10), nullable=True,
 | 
			
		||||
                              default='PC')
 | 
			
		||||
 | 
			
		||||
    active_status = sa.Column('activeStatus', sa.String(length=10), nullable=True,
 | 
			
		||||
                              default='')
 | 
			
		||||
 | 
			
		||||
    customer_type_id = sa.Column('customerTypeID', sa.Integer(), nullable=True,
 | 
			
		||||
                                 default=1)
 | 
			
		||||
 | 
			
		||||
    charge_balance = sa.Column('chargeBalance', sa.Numeric(precision=10, scale=2), nullable=True,
 | 
			
		||||
                               default=0)
 | 
			
		||||
 | 
			
		||||
    charge_limit = sa.Column('chargeLimit', sa.Numeric(precision=10, scale=2), nullable=True,
 | 
			
		||||
                             default=0)
 | 
			
		||||
 | 
			
		||||
    id_card_upc = sa.Column('idCardUPC', sa.String(length=13), nullable=True)
 | 
			
		||||
 | 
			
		||||
    start_date = sa.Column('startDate', sa.DateTime(), nullable=True)
 | 
			
		||||
 | 
			
		||||
    end_date = sa.Column('endDate', sa.DateTime(), nullable=True)
 | 
			
		||||
 | 
			
		||||
    address_first_line = sa.Column('addressFirstLine', sa.String(length=100), nullable=True)
 | 
			
		||||
 | 
			
		||||
    address_second_line = sa.Column('addressSecondLine', sa.String(length=100), nullable=True)
 | 
			
		||||
 | 
			
		||||
    city = sa.Column(sa.String(length=50), nullable=True)
 | 
			
		||||
 | 
			
		||||
    state = sa.Column(sa.String(length=10), nullable=True)
 | 
			
		||||
 | 
			
		||||
    zip = sa.Column(sa.String(length=10), nullable=True)
 | 
			
		||||
 | 
			
		||||
    contact_allowed = sa.Column('contactAllowed', sa.Boolean(), nullable=True,
 | 
			
		||||
                                default=True)
 | 
			
		||||
 | 
			
		||||
    contact_method = sa.Column('contactMethod', sa.String(length=10), nullable=True,
 | 
			
		||||
                               default='mail')
 | 
			
		||||
 | 
			
		||||
    modified = sa.Column(sa.DateTime(), nullable=True)
 | 
			
		||||
 | 
			
		||||
    def __str__(self):
 | 
			
		||||
        return "Account ID-{}".format(self.id)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Customer(Base):
 | 
			
		||||
    """
 | 
			
		||||
    This really represents a "person" attached to a proper "customer account".
 | 
			
		||||
 | 
			
		||||
    https://github.com/CORE-POS/IS4C/blob/master/fannie/classlib2.0/data/models/op/CustomersModel.php
 | 
			
		||||
    """
 | 
			
		||||
    __tablename__ = 'Customers'
 | 
			
		||||
 | 
			
		||||
    id = sa.Column('customerID', sa.Integer(), primary_key=True, autoincrement=True, nullable=False)
 | 
			
		||||
 | 
			
		||||
    account_id = sa.Column('customerAccountID', sa.Integer(),
 | 
			
		||||
                           sa.ForeignKey('CustomerAccounts.customerAccountID'),
 | 
			
		||||
                           nullable=True)
 | 
			
		||||
    account = orm.relationship(CustomerAccount)
 | 
			
		||||
 | 
			
		||||
    card_number = sa.Column('cardNo', sa.Integer(), nullable=True)
 | 
			
		||||
 | 
			
		||||
    first_name = sa.Column('firstName', sa.String(length=50), nullable=True)
 | 
			
		||||
 | 
			
		||||
    last_name = sa.Column('lastName', sa.String(length=50), nullable=True)
 | 
			
		||||
 | 
			
		||||
    charge_allowed = sa.Column('chargeAllowed', sa.Boolean(), nullable=True,
 | 
			
		||||
                               default=True)
 | 
			
		||||
 | 
			
		||||
    checks_allowed = sa.Column('checksAllowed', sa.Boolean(), nullable=True,
 | 
			
		||||
                               default=True)
 | 
			
		||||
 | 
			
		||||
    discount = sa.Column(sa.Boolean(), nullable=True,
 | 
			
		||||
                         default=False)
 | 
			
		||||
 | 
			
		||||
    account_holder = sa.Column('accountHolder', sa.Boolean(), nullable=True,
 | 
			
		||||
                               default=False)
 | 
			
		||||
 | 
			
		||||
    staff = sa.Column(sa.Boolean(), nullable=True,
 | 
			
		||||
                      default=False)
 | 
			
		||||
 | 
			
		||||
    phone = sa.Column(sa.String(length=20), nullable=True)
 | 
			
		||||
 | 
			
		||||
    alternate_phone = sa.Column('altPhone', sa.String(length=20), nullable=True)
 | 
			
		||||
 | 
			
		||||
    email = sa.Column(sa.String(length=100), nullable=True)
 | 
			
		||||
 | 
			
		||||
    member_pricing_allowed = sa.Column('memberPricingAllowed', sa.Boolean(), nullable=True,
 | 
			
		||||
                                       default=False)
 | 
			
		||||
 | 
			
		||||
    member_coupons_allowed = sa.Column('memberCouponsAllowed', sa.Boolean(), nullable=True,
 | 
			
		||||
                                       default=False)
 | 
			
		||||
 | 
			
		||||
    low_income_benefits = sa.Column('lowIncomeBenefits', sa.Boolean(), nullable=True,
 | 
			
		||||
                                    default=False)
 | 
			
		||||
 | 
			
		||||
    modified = sa.Column(sa.DateTime(), nullable=True)
 | 
			
		||||
 | 
			
		||||
    def __str__(self):
 | 
			
		||||
        return "{} {}".format(self.first_name or '', self.last_name or '').strip()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CustData(Base):
 | 
			
		||||
    """
 | 
			
		||||
    Represents a customer of the organization.
 | 
			
		||||
 | 
			
		||||
    https://github.com/CORE-POS/IS4C/blob/master/fannie/classlib2.0/data/models/op/CustdataModel.php
 | 
			
		||||
    """
 | 
			
		||||
    __tablename__ = 'custdata'
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -463,10 +578,6 @@ class CustData(Base):
 | 
			
		|||
        return "{} {}".format(self.first_name or '', self.last_name or '').strip()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# TODO: deprecate / remove this (so we can repurpose, for 'Customers' table)
 | 
			
		||||
Customer = CustData
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class MemberInfo(Base):
 | 
			
		||||
    """
 | 
			
		||||
    Contact info regarding a member of the organization.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue