Add DB models for TaxRate, TaxRateComponent

This commit is contained in:
Lance Edgar 2020-03-27 20:50:00 -05:00
parent 573595497e
commit 9466b16b64

View file

@ -200,6 +200,41 @@ class VendorContact(Base):
notes = sa.Column(sa.Text(), nullable=True)
class TaxRate(Base):
"""
Represents a tax rate. Note that this may be a "combo" of various local
tax rates / levels.
"""
__tablename__ = 'taxrates'
id = sa.Column(sa.Integer(), primary_key=True, autoincrement=False, nullable=False)
rate = sa.Column(sa.Float(), nullable=True)
description = sa.Column(sa.String(length=50), nullable=True)
sales_code = sa.Column('salesCode', sa.Integer(), nullable=True)
class TaxRateComponent(Base):
"""
Represents a "component" of a tax rate.
"""
__tablename__ = 'TaxRateComponents'
__table_args__ = (
sa.ForeignKeyConstraint(['taxRateID'], ['taxrates.id']),
)
id = sa.Column(sa.Integer(), primary_key=True, autoincrement=True, nullable=False)
tax_rate_id = sa.Column('taxRateID', sa.Integer())
tax_rate = orm.relationship(TaxRate, backref='components')
rate = sa.Column(sa.Float(), nullable=True)
description = sa.Column(sa.String(length=50), nullable=True)
class Product(Base):
"""
Represents a product, purchased and/or sold by the organization.
@ -207,6 +242,7 @@ class Product(Base):
__tablename__ = 'products'
__table_args__ = (
sa.ForeignKeyConstraint(['department'], ['departments.dept_no']),
sa.ForeignKeyConstraint(['tax'], ['taxrates.id']),
)
id = sa.Column(sa.Integer(), primary_key=True, autoincrement=True, nullable=False)
@ -243,7 +279,8 @@ class Product(Base):
size = sa.Column(sa.String(length=9), nullable=True)
tax = sa.Column(sa.SmallInteger(), nullable=True)
tax_rate_id = sa.Column('tax', sa.SmallInteger(), nullable=True)
tax_rate = orm.relationship(TaxRate)
foodstamp = sa.Column(sa.Boolean(), nullable=True)