class PageData(db.Model): __tablename__ = "pagedata" name = db.Column(db.String(30), primary_key=True) value = db.Column(db.String(50), nullable=False, default='') def __init__(self, name, value): self.name = name self.value = value
class InvestmentPlan(db.Model): __tablename__ = "investment_plans" id = db.Column(db.Integer, primary_key=True) period = db.Column(db.Integer, nullable=False) # 1 - hour, 2 - day, 3 - week, 4 - month periodUnit = db.Column(db.Integer, nullable=False) percentage = db.Column(db.Float, nullable=False) # 0 - new investment will be added into current one with the same percentage # 1 - new investment will be added separatelly with the new percentage usage = db.Column(db.Integer, default=0) # 0 - not active investmentPlan # 1 - active investmentPlan active = db.Column(db.Boolean, default=False) description = db.Column(db.String(50), nullable=True) acountInvestments = db.relationship('AccountInvestments', backref='investmentPlan', lazy='dynamic') transactions = db.relationship('Transaction', backref='investmentPlan', lazy='dynamic') def __init__(self, per, peru, perc, desc, act=None): self.period = per self.periodUnit = peru self.percentage = perc self.description = desc self.active = act
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
class User(db.Model): __tablename__ = 'users' id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(50), nullable=False, unique=True, index=True) email = db.Column(db.String(120), unique=True, nullable=False, index=True) password = db.Column(db.String(255)) registered_on = db.Column(db.DateTime, nullable=False) confirmed = db.Column(db.Boolean, nullable=False, default=False) confirmed_on = db.Column(db.DateTime, nullable=True) role = db.Column(db.String(20), nullable=False, default='user') pin = db.Column(db.String(4), nullable=False) fb = db.Column(db.String(120), nullable=True) skype = db.Column(db.String(120), nullable=True) #### account = db.relationship('Account', backref='user', uselist=False) def __init__(self, username, password, email, confirmed=None, confirmed_on=None, role='user'): self.username = username self.email = email self.password = User.hash_password(password) self.registered_on = datetime.now() self.confirmed = confirmed self.confirmed_on = confirmed_on self.role = role def check_password(self, password): return check_password_hash(self.password, password) @staticmethod def hash_password(password): return generate_password_hash(password) @property def is_authenticated(self): return True @property def is_active(self): return True @property def is_anonymous(self): return False def get_id(self): return str(self.id) def __unicode__(self): return self.username or ''
class TransactionType(db.Model): __tablename__ = "transaction_types" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(30), default="") transactions = db.relationship('Transaction', backref='transactionType', lazy='dynamic') def __init__(self, name): self.name = name
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 ''
class PaymentSystems(db.Model): __tablename__ = "payment_systems" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(50), nullable=True) logo = db.Column(db.String(50), nullable=True) url = db.Column(db.String(100), nullable=True) unit = db.Column(db.String(10), nullable=True) acountInvestments = db.relationship('AccountInvestments', backref='paymentSystem', lazy='dynamic') transactions = db.relationship('Transaction', backref='paymentSystem', lazy='dynamic') wallets = db.relationship('Wallet', backref='paymentSystem', lazy='dynamic') def __init__(self, name, logo, url): self.name = name self.logo = logo self.url = url
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
class ReferralProgram(db.Model): __tablename__ = "referral_programs" # 1 - 5/2/1, 2 - 7/3/1 id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(30), nullable=False) level1 = db.Column(db.Integer, nullable=True) level2 = db.Column(db.Integer, nullable=True) level3 = db.Column(db.Integer, nullable=True) accounts = db.relationship('Account', backref='referralProgram', lazy='dynamic') def __init__(self, name, l1=None, l2=None, l3=None): self.name = name self.level1 = l1 self.level2 = l2 self.level3 = l3 def __unicode__(self): return self.name or ''
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