class InvoiceArticle(db.Model): article_id = db.Column(db.Integer, nullable=False, primary_key=True) article_code = db.Column(db.String(255), nullable=False) article = db.Column(db.String(255), nullable=False) description = db.Column(db.String(255), nullable=False) unit = db.Column(db.String(255), nullable=False) budgetitem_id = db.Column(db.String(4), nullable=False) productgroup = db.Column(db.String(255), nullable=False) mwst = db.Column(db.Numeric(precision=5, scale=2), nullable=False, default=0.00) unitprice = db.Column(db.Numeric(precision=8, scale=2), nullable=False, default=0.00)
class Transaction(db.Model): id = db.Column(db.Integer, nullable=False, primary_key=True) financial_year = db.Column(INTEGER(4), nullable = False) date = db.Column(db.DateTime, default = datetime.datetime.now, nullable= False) type_id = db.Column(db.Integer, ForeignKey('transaction_type.type_id'), nullable = False) description = db.Column(db.String(255), nullable=False) category_id = db.Column(db.Integer, ForeignKey('transaction_category.category'), nullable = True) budgetitem_id = db.Column(db.Integer, ForeignKey('budget_item.budgetitem_id'), nullable= True) account_id = db.Column(db.Integer, ForeignKey('transaction_account.account'), nullable= True) is_valid = db.Column(db.Boolean, nullable= False) amount = db.Column(db.Numeric(precision=10,scale=2), nullable = False, default=0.00) currency_id = db.Column(db.Integer, ForeignKey('transaction_currency.currency_id'), nullable= False) amount_in_chf = db.Column(db.Numeric(precision=10,scale=2), nullable = True) user_id = db.Column(db.Integer, ForeignKey('user.user_id'), nullable= False) comment = db.Column(db.String(255), nullable = True)
class InvoiceItem(db.Model): transaction_id = db.Column(db.Integer, ForeignKey('transaction.id'), nullable=False, primary_key=True) article_id = db.Column(db.Integer, ForeignKey('invoice_article.article_id'), nullable=False) description = db.Column(db.Text, nullable=False) unit = db.Column(db.String(7), nullable=False) amount = db.Column(db.Integer, nullable=False) taxrate = db.Column(db.Numeric(precision=2, scale=2), nullable=False) unitprice = db.Column(db.Numeric(precision=10, scale=2), nullable=False) invoice_id = db.Column(db.Integer, db.ForeignKey('invoice.invoice_id'), nullable=False)
class BudgetItem(db.Model): budgetitem_id = db.Column(db.Integer, nullable=False, primary_key=True) budgetitem_code = db.Column(db.String(4), nullable=False) budgetgroup_id = db.Column(db.Integer, ForeignKey('budget_group.budgetgroup_id'), nullable=False) budgetitem_name = db.Column(db.String(255), nullable=False) financial_year = db.Column(INTEGER(4), nullable=False) expenditure_budgeted = db.Column(db.Numeric(precision=10, scale=2), nullable=False, default=0.00) revenue_budgeted = db.Column(db.Numeric(precision=10, scale=2), nullable=False, default=0.00) expenditure_confirmed = db.Column(db.Numeric(precision=10, scale=2), nullable=False, default=0.00) revenue_confirmed = db.Column(db.Numeric(precision=10, scale=2), nullable=False, default=0.00)
class MerchArticle(db.Model): article_id = db.Column(db.Integer, nullable=False, primary_key=True) article = db.Column(db.String(255), nullable=False) unitprice = db.Column(db.Numeric(precision=6, scale=2), nullable=False, default=0.00)
class DetailMerchandise(db.Model): transaction_id = db.Column(db.Integer, ForeignKey('transaction.id') ,nullable=False, primary_key = True) price = db.Column(db.Numeric(precision=6,scale=2), nullable = False, default=0.00) quantity = db.Column(INTEGER(6), nullable= False) article_id = db.Column(db.Integer, ForeignKey('merch_article.article_id'), nullable= False)