Esempio n. 1
0
File: models.py Progetto: araikc/sbb
class Account(db.Model):
    __tablename__ = 'accounts'

    id = db.Column(db.Integer, primary_key=True)
    balance = db.Column(db.Float, nullable=False, default=0)
    bitcoin = db.Column(db.Float, nullable=True)

    referralProgramId = db.Column(db.Integer,
                                  db.ForeignKey('referral_programs.id'),
                                  nullable=False)
    userId = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)

    wallets = db.relationship('AccountWallets',
                              backref='account',
                              lazy='dynamic')
    inherits = db.relationship('Referral',
                               backref='referralAccount',
                               lazy='dynamic')
    investments = db.relationship('AccountInvestments',
                                  backref='account',
                                  lazy='dynamic')
    transactions = db.relationship('Transaction',
                                   backref='account',
                                   lazy='dynamic')
    referralBonuses = db.relationship('ReferralBonuses',
                                      backref='earnedAccount',
                                      lazy='dynamic')
    withdraws = db.relationship('Withdraws', backref='account', lazy='dynamic')

    def __init__(self, balance, bc):
        self.balance = balance
        self.bitcoin = bc

    def __unicode__(self):
        return str(self.id) or ''
Esempio n. 2
0
File: models.py Progetto: araikc/sbb
class Transaction(db.Model):
    __tablename__ = "transactions"

    id = db.Column(db.Integer, primary_key=True)
    accountId = db.Column(db.Integer,
                          db.ForeignKey('accounts.id'),
                          nullable=True)

    execDatetime = db.Column(db.DateTime, nullable=False)

    transactionTypeId = db.Column(db.Integer,
                                  db.ForeignKey('transaction_types.id'),
                                  nullable=False)
    investmentPlanId = db.Column(db.Integer,
                                 db.ForeignKey('investment_plans.id'),
                                 nullable=True)
    paymentSystemId = db.Column(db.Integer,
                                db.ForeignKey('payment_systems.id'),
                                nullable=True)

    amount = db.Column(db.Float, nullable=True)
    unit = db.Column(db.String(5), nullable=True)
    status = db.Column(db.Boolean, nullable=False, default=False)

    def __init__(self, date, amount, status):
        self.execDatetime = date
        self.amount = amount
        self.status = status
Esempio n. 3
0
File: models.py Progetto: araikc/sbb
class AccountWallets(db.Model):
    __tablename__ = "account_wallets"

    accountId = db.Column(db.Integer,
                          db.ForeignKey('accounts.id'),
                          nullable=False,
                          primary_key=True)
    walletId = db.Column(db.Integer,
                         db.ForeignKey('wallet.id'),
                         nullable=False,
                         primary_key=True)
    #wallet = db.relationship(Wallet, backref='wallet')
    walletValue = db.Column(db.String(100), nullable=True)

    def __init__(self, value):
        self.walletValue = value
Esempio n. 4
0
File: models.py Progetto: araikc/sbb
class Withdraws(db.Model):
    __tablename__ = "withdraws"

    id = db.Column(db.Integer, primary_key=True)

    dateTime = db.Column(db.DateTime, nullable=True, default=datetime.utcnow)
    accountId = db.Column(db.Integer,
                          db.ForeignKey('accounts.id'),
                          nullable=False,
                          index=True)
    amount = db.Column(db.Float, nullable=False)
    walletId = db.Column(db.Integer,
                         db.ForeignKey('wallet.id'),
                         nullable=False,
                         index=True)
    batch_num = db.Column(db.Integer, nullable=True)
    status = db.Column(db.Boolean, nullable=False, default=False)

    def __init__(self, dateTime, amount, walletId):
        self.dateTime = dateTime
        self.amount = amount
        self.walletId = walletId
Esempio n. 5
0
File: models.py Progetto: araikc/sbb
class AccountInvestments(db.Model):
    __tablename__ = "account_investments"

    id = db.Column(db.Integer, primary_key=True)
    accountId = db.Column(db.Integer,
                          db.ForeignKey('accounts.id'),
                          nullable=False)

    investmentPlanId = db.Column(db.Integer,
                                 db.ForeignKey('investment_plans.id'),
                                 nullable=False)
    #investmentPlan = db.relationship(InvestmentPlan, backref='investment_plans')

    startDatetime = db.Column(db.DateTime, nullable=True)
    endDatetime = db.Column(db.DateTime, nullable=True)
    currentBalance = db.Column(db.Float, nullable=False)
    initialInvestment = db.Column(db.Float, nullable=False)
    lastInvestment = db.Column(db.Float, nullable=False, default=0)
    isActive = db.Column(db.Boolean, nullable=True, default=False)
    paymentSystemId = db.Column(db.Integer,
                                db.ForeignKey('payment_systems.id'),
                                nullable=False)
    pm_batch_num = db.Column(db.Integer, nullable=True)
    payment_unit = db.Column(db.String(10), nullable=True)

    #paymentSystem = db.relationship(PaymentSystems, backref='payment_systems')

    def __init__(self,
                 currentBalance,
                 initialInvestment,
                 isActive,
                 startDatetime=None,
                 endDatetime=None):
        self.startDatetime = startDatetime
        self.endDatetime = endDatetime
        self.currentBalance = currentBalance
        self.initialInvestment = initialInvestment
        self.isActive = isActive
Esempio n. 6
0
File: models.py Progetto: araikc/sbb
class Referral(db.Model):
    __tablename__ = "referrals"

    #id = db.Column(db.Integer, primary_key=True)
    accountId = db.Column(db.Integer, nullable=False, primary_key=True)
    refAccId = db.Column(db.Integer,
                         db.ForeignKey('accounts.id'),
                         nullable=False,
                         primary_key=True)

    #level = db.Column(db.Integer, nullable=False)

    def __init__(self, accountId):
        self.accountId = accountId
Esempio n. 7
0
File: models.py Progetto: araikc/sbb
class ReferralBonuses(db.Model):
    __tablename__ = "referral_bonuses"

    id = db.Column(db.Integer, primary_key=True)

    invester_account_id = db.Column(db.Integer, nullable=False)
    earned_account_id = db.Column(db.Integer,
                                  db.ForeignKey('accounts.id'),
                                  nullable=False,
                                  index=True)
    invested_amount = db.Column(db.Float, nullable=False)
    earned_amount = db.Column(db.Float, nullable=False)
    level = db.Column(db.Integer, nullable=False)
    payed = db.Column(db.Boolean, nullable=True, default=False)
    dateTime = db.Column(db.DateTime, nullable=True, default=datetime.utcnow)

    def __init__(self, invAccId, amount, earned, level):
        self.invester_account_id = invAccId
        self.invested_amount = amount
        self.earned_amount = earned
        self.level = level
Esempio n. 8
0
File: models.py Progetto: araikc/sbb
class Wallet(db.Model):
    __tablename__ = "wallet"

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(30), nullable=True)
    url = db.Column(db.String(70), nullable=True, default='')
    paymentSystemId = db.Column(db.Integer,
                                db.ForeignKey('payment_systems.id'),
                                nullable=False)
    unit = db.Column(db.String(5), nullable=False, default='USD')

    accounts = db.relationship('AccountWallets',
                               backref='wallet',
                               lazy='dynamic')
    withdraws = db.relationship('Withdraws', backref='wallet', lazy='dynamic')

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

    def __unicode__(self):
        return self.name or ''