Exemplo n.º 1
0
class Budget(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(60))
    budget = db.Column(db.Float)
    closed = db.Column(db.Boolean, default=False)
    term_id = db.Column(db.Integer, db.ForeignKey('term.id'))
    expenditures = db.relationship('Expenditure', backref='budget', lazy=True)
Exemplo n.º 2
0
class StockPrice(db.Model):
    __tablename__ = 'stock_prices'

    id = db.Column(db.Integer, primary_key=True)
    date = db.Column(db.Date)
    stock_id = db.Column(db.Integer, db.ForeignKey('stocks.id'))
    opn = db.Column(db.Float)
    high = db.Column(db.Float)
    low = db.Column(db.Float)
    close = db.Column(db.Float)
    volume = db.Column(db.Float)
    adjclose = db.Column(db.Float)

    stock = db.relationship("Stock")

    def __init__(self, date, stock, opn, high, low, close, volume, adjclose):
        self.date = date
        self.stock = stock
        self.opn = opn
        self.high = high
        self.low = low
        self.close = close
        self.volume = volume
        self.adjclose = adjclose

    def __repr__(self):
       return "<StockPrice('%s, %s, %s, %f')>" % (self.id or '', self.date,
               self.stock, self.close)
Exemplo n.º 3
0
class MortgageSchedule(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    date = db.Column(db.Date)
    principal = db.Column(db.Float)

    def __init__(self, date, principal):
        self.date = date
        self.principal = principal

    def __repr__(self):
       return "<MortgageSchedule('%s, %s')>" % (self.date, self.principal)
Exemplo n.º 4
0
class TransFile(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String)
    account = db.Column(db.String)

    def __init__(self, name, account):
        self.name = name
        self.account = account

    def __repr__(self):
        return "<TransFile('%s', '%s')>" % (self.name, self.account)
Exemplo n.º 5
0
class Stock(db.Model):
    __tablename__ = 'stocks'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String)
    long_name = db.Column(db.String)

    prices = db.relationship("StockPrice") 

    def __init__(self, name, long_name=None):
        self.name = name
        self.long_name = long_name or name

    def __repr__(self):
       return "<Stock('%s, %s, %s')>" % (self.id or '', self.name, self.long_name)
Exemplo n.º 6
0
class CategoryRE(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String)
    category_id = db.Column(db.Integer, db.ForeignKey('category.id'))
    pattern = db.Column(db.String)
    yearly = db.Column(db.Boolean, default=False)

    category = db.relationship("Category")

    def __init__(self, name, category, pattern, yearly=False):
        self.name = name
        self.category = category
        self.pattern = pattern
        self.yearly = yearly

    def __repr__(self):
        return "<CategoryRE('%s, %s, %s')>" % (self.name, self.category.name,
                                               self.pattern)
Exemplo n.º 7
0
class Category(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    parent_id = db.Column(db.Integer, db.ForeignKey('category.id'))
    name = db.Column(db.String)
    depth = db.Column(db.Integer, default=0)

    children = db.relationship("Category",
                               backref=db.backref('parent', remote_side=[id]))

    def __init__(self, name, parent=None, depth=0):
        self.name = name
        if parent:
            self.parent = parent
            self.depth = parent.depth + 1
        else:
            self.depth = depth

    def __repr__(self):
        return "<Category('%s')>" % (self.name)
Exemplo n.º 8
0
class Account(db.Model):
    account_id = db.Column(db.Integer, primary_key=True)
    holder_name = db.Column(db.String(30), nullable=False)
    account_type = db.Column(db.String(20), nullable=False, default='Resident')
    block_no = db.Column(db.String(1), nullable=True)
    phone_no = db.Column(db.String(10), nullable=False)
    flat_no = db.Column(db.Integer, nullable=True, unique=True)
    balance = db.Column(db.Float, default=0.0, nullable=False)
    transactions = db.relationship('Transactions',
                                   backref='ref_acc',
                                   lazy=True)
    init_date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)

    def __repr__(self):
        return "Account('{}', '{}', '{}')".format(self.account_id,
                                                  self.account_type,
                                                  self.holder_name)
Exemplo n.º 9
0
class Transactions(db.Model):
    trans_id = db.Column(db.Integer, primary_key=True)
    trans_user = db.Column(db.Integer,
                           db.ForeignKey('account.account_id'),
                           nullable=False)
    trans_amount = db.Column(db.Float, nullable=False)
    trans_date = db.Column(db.DateTime,
                           nullable=False,
                           default=datetime.utcnow)
    trans_mode = db.Column(db.String(10), nullable=False)
    trans_type = db.Column(db.String(10), nullable=False)
    trans_descr = db.Column(db.Text)

    def __repr__(self):
        return "Transcation('{}', '{}', '{}')".format(self.trans_id,
                                                      self.trans_user,
                                                      self.trans_mode)
Exemplo n.º 10
0
class Transaction(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    tdate = db.Column(db.Date)
    category_id = db.Column(db.Integer, db.ForeignKey('category.id'))
    file_id = db.Column(db.Integer, db.ForeignKey('trans_file.id'))
    name = db.Column(db.String)
    amount = db.Column(db.Float)
    bdate = db.Column(db.Date)
    yearly = db.Column(db.Boolean, default=False)

    category = db.relationship("Category")
    trans_file = db.relationship("TransFile")

    def __init__(self,
                 tdate,
                 name,
                 category,
                 amount,
                 trans_file,
                 bdate=None,
                 yearly=False):
        self.tdate = tdate
        self.name = name
        self.amount = amount
        self.bdate = bdate or self.tdate
        self.yearly = yearly

        if isinstance(category, int):
            self.category_id = category
        else:
            self.category = category

        if isinstance(trans_file, int):
            self.file_id = trans_file
        else:
            self.trans_file = trans_file

    def __repr__(self):
        return "<Tran('%d, %s, %s, %s, %s, %s, %s')>" % (
            (self.id or 0), self.tdate, self.name, self.category, self.amount,
            self.trans_file, self.bdate)
Exemplo n.º 11
0
class InvTransaction(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    account = db.Column(db.String)
    date = db.Column(db.Date)
    fund = db.Column(db.String)
    shares = db.Column(db.Float)
    action = db.Column(db.String)
    cost = db.Column(db.Float)
    price = db.Column(db.Float)

    def __init__(self, date, account, fund, shares, cost, price, action):
        self.date = date
        self.account = account
        self.fund = fund
        self.action = action
        self.cost = cost
        self.shares = shares
        self.price = price

    def __repr__(self):
        return "<InvTransaction(%s, %s, '%s' %f, %f, %f)>" % (
            self.date, self.fund, self.action, self.cost, self.shares,
            self.price)
Exemplo n.º 12
0
class Budgettemplate(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(60))
    budget = db.Column(db.Float)
Exemplo n.º 13
0
class Term(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(60))
    income = db.Column(db.Float)
    budgets = db.relationship('Budget', backref='term', lazy=True)
Exemplo n.º 14
0
class Expenditure(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(60))
    price = db.Column(db.Float)
    payed = db.Column(db.Boolean)
    budget_id = db.Column(db.Integer, db.ForeignKey('budget.id'))
Exemplo n.º 15
0
class Fixedcosttemplate(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(60))
    price = db.Column(db.Float)
    default = db.Column(db.Boolean)
Exemplo n.º 16
0
class Fixedcost(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(60))
    price = db.Column(db.Float)
    payed = db.Column(db.Boolean)
    fixedcosttemplate_id = db.Column(db.Integer, db.ForeignKey('fixedcosttemplate.id'))
Exemplo n.º 17
0
class Termlink(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    linkedterm = db.Column(db.Integer)