class Mappings(db.Model): __table_args__ = (db.UniqueConstraint('source', 'keyword', name='mappings_unique_constraint'), { 'schema': 'admin' }) __tablename__ = 'mappings' id = db.Column(db.Integer, primary_key=True) source = db.Column(db.String) keyword = db.Column(db.String) positive_debit_subaccount_id = db.Column( db.String, db.ForeignKey('bookkeeping.subaccounts.name')) positive_debit_subaccount = db.relationship( 'Subaccounts', foreign_keys=[positive_debit_subaccount_id]) positive_credit_subaccount_id = db.Column( db.String, db.ForeignKey('bookkeeping.subaccounts.name')) positive_credit_subaccount = db.relationship( 'Subaccounts', foreign_keys=[positive_credit_subaccount_id]) negative_debit_subaccount_id = db.Column( db.String, db.ForeignKey('bookkeeping.subaccounts.name')) negative_debit_subaccount = db.relationship( 'Subaccounts', foreign_keys=[negative_debit_subaccount_id]) negative_credit_subaccount_id = db.Column( db.String, db.ForeignKey('bookkeeping.subaccounts.name')) negative_credit_subaccount = db.relationship( 'Subaccounts', foreign_keys=[negative_credit_subaccount_id]) def __repr__(self): return '{0} - {1}'.format(self.source, self.keyword)
class JournalEntries(db.Model): __tablename__ = 'journal_entries' id = db.Column(db.Integer, primary_key=True) transaction_id = db.Column(db.String) transaction_source = db.Column(db.String) mapping_id = db.Column(db.Integer, db.ForeignKey('admin.mappings.id')) mapping = db.relationship('Mappings', backref='journal_entries') timestamp = db.Column(db.DateTime(timezone=True), nullable=False) debit_subaccount = db.Column(db.String, db.ForeignKey('bookkeeping.subaccounts.name'), nullable=False) credit_subaccount = db.Column( db.String, db.ForeignKey('bookkeeping.subaccounts.name'), nullable=False) functional_amount = db.Column(db.Numeric, nullable=False) functional_currency = db.Column(db.String, nullable=False) source_amount = db.Column(db.Numeric, nullable=False) source_currency = db.Column(db.String, nullable=False) __table_args__ = (db.UniqueConstraint( 'transaction_id', 'transaction_source', name='journal_entries_unique_constraint'), db.CheckConstraint( functional_amount >= 0, name='check_functional_amount_positive'), db.CheckConstraint(source_amount >= 0, name='check_source_amount_positive'), { 'schema': 'bookkeeping' })
class ConnectionResponses(db.Model): __table_args__ = {'schema': 'admin'} __tablename__ = 'connection_responses' id = db.Column(db.Integer, primary_key=True) connection_id = db.Column(db.Integer, db.ForeignKey('admin.connections.id')) connection = db.relationship('Connections') connected_at = db.Column(db.DateTime(timezone=True)) response = db.Column(db.String)
class Elements(db.Model): __table_args__ = {'schema': 'bookkeeping'} __tablename__ = 'elements' name = db.Column(db.String, primary_key=True) classifications = db.relationship('Classifications', backref='element', lazy='select', cascade="save-update, merge, delete") def __repr__(self): return self.name
class AmazonCategories(db.Model): __table_args__ = {'schema': 'amazon'} __tablename__ = 'categories' name = db.Column(db.String, primary_key=True) items = db.relationship('AmazonItems', backref='category', lazy="select", cascade="save-update, merge, delete") def __repr__(self): return self.name
class Classifications(db.Model): __table_args__ = {'schema': 'bookkeeping'} __tablename__ = 'classifications' name = db.Column(db.String, primary_key=True) parent = db.Column(db.String, db.ForeignKey('bookkeeping.elements.name')) accounts = db.relationship('Accounts', backref='classification', lazy='select', cascade="save-update, merge, delete") def __repr__(self): return self.name
class AmazonOrders(db.Model): __table_args__ = {'schema': 'amazon'} __tablename__ = 'orders' id = db.Column(db.String, primary_key=True) order_date = db.Column(db.Date) items = db.relationship('AmazonItems', backref='order', lazy="select", cascade="save-update, merge, delete") def __repr__(self): return self.id
class Subaccounts(db.Model): __table_args__ = {'schema': 'bookkeeping'} __tablename__ = 'subaccounts' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String) description = db.Column(db.String) parent = db.Column(db.String, db.ForeignKey('bookkeeping.accounts.name')) tax_tags = db.relationship('TaxTags', backref='subaccounts', secondary='tax.subaccounts_tax_tags') def __repr__(self): return '{0} - {1}'.format(self.parent, self.name)
class Users(db.Model, UserMixin): __table_args__ = {'schema': 'admin'} id = db.Column(db.Integer, primary_key=True) email = db.Column(db.String(), unique=True) password = db.Column(db.String()) active = db.Column(db.Boolean()) confirmed_at = db.Column(db.DateTime) last_login_at = db.Column(db.DateTime) current_login_at = db.Column(db.DateTime) last_login_ip = db.Column(db.String()) current_login_ip = db.Column(db.String()) login_count = db.Column(db.Integer) roles = db.relationship('Roles', secondary=roles_users, backref=db.backref('users'))
class Paystubs(db.Model): __table_args__ = (db.UniqueConstraint('employer_name', 'period_beginning', 'period_ending', name='paystubs_unique_constraint'), { 'schema': 'payroll' }) __tablename__ = 'paystubs' id = db.Column(db.Integer, primary_key=True) employer_name = db.Column(db.String) period_beginning = db.Column(db.Date) period_ending = db.Column(db.Date) pay_date = db.Column(db.Date) items = db.relationship('PaystubItems', backref='paystub', lazy="select", cascade="save-update, merge, delete") def __repr__(self): return '{0}: {1} to {2}'.format(self.employer_name, self.period_beginning, self.period_ending)