class User(db.Model, UserMixin): __tablename__ = 'users' id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(120), unique=True, nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) designation = db.Column(db.String(120), nullable=False) image_file = db.Column(db.String(120), nullable=False, default='default.jpg') password = db.Column(db.String(60), nullable=False) is_admin = db.Column(db.Boolean, default=True) invoice = db.relationship('Invoice', backref='author', lazy=True) receipt = db.relationship('Receipt', backref='receiptAuthor', lazy=True) def check_password(self, password): """Check hashed password.""" return check_password_hash(self.password, password) def get_reset_token(self, expires_sec=1800): s = Serializer(current_app.config['SECRET_KEY'], expires_sec) return s.dumps({'user_id': self.id}).decode('utf-8') @staticmethod def verify_reset_token(token): s = Serializer(current_app.config['SECRET_KEY']) try: user_id = s.loads(token)['user_id'] except: return None return User.query.get(user_id) def __repr__(self): return f" User('{self.username}','{self.email}','{self.designation}','{self.image_file}')"
class InvoiceLineItem(db.Model): __tablename__ = 'line_items' id = db.Column(db.Integer, primary_key=True) notes = db.Column(db.String(255), nullable=False) disbursements = db.Column(db.String, nullable=True) professional_fees = db.Column(db.String, nullable=True) amount = db.Column(db.Float, nullable=False) invoice_id = db.Column(db.Integer, db.ForeignKey('invoice.id'), nullable=False) # Relationship invoice = db.relationship('Invoice', backref=db.backref('laps', lazy='dynamic', collection_class=list))
class User(db.Model, UserMixin): __tablename__ = 'users' id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(120), unique=True, nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) designation = db.Column(db.String(120), nullable=False) image_file = db.Column(db.String(120), nullable=False, default='default.jpg') password = db.Column(db.String(60), nullable=False) is_admin = db.Column(db.Boolean, default=True) invoice = db.relationship('Invoice', backref='author', lazy=True) def __repr__(self): return f" User('{self.username}','{self.email}','{self.designation}','{self.image_file}')"
class disbursements(db.Model): __tablename__ = 'disbursementsfees' id = db.Column(db.Integer, primary_key=True) disbursement_amount = db.Column(db.Float, default='0.0') disb_heading = db.Column(db.String, nullable=True) disb_sub1 = db.Column(db.String(500), nullable=True) disb_sub2 = db.Column(db.String(500), nullable=True) disb_sub3 = db.Column(db.String(500), nullable=True) invoice_id = db.Column(db.Integer, db.ForeignKey('invoice.id', ondelete='SET NULL'), nullable=False) # Relationship invoice = db.relationship('Invoice', backref=db.backref('laps2', lazy='dynamic', passive_deletes=True, collection_class=list))
class InvoiceLineItem(db.Model): __tablename__ = 'line_items' id = db.Column(db.Integer, primary_key=True) prof_heading = db.Column(db.String(500), nullable=True) prof_sub1 = db.Column(db.String(500), nullable=True) prof_sub2 = db.Column(db.String(500), nullable=True) prof_sub3 = db.Column(db.String(500), nullable=True) prof_sub4 = db.Column(db.String(500), nullable=True) prof_sub5 = db.Column(db.String(500), nullable=True) invoice_id = db.Column(db.Integer, db.ForeignKey('invoice.id', ondelete='SET NULL'), nullable=False) # Relationship invoice = db.relationship('Invoice', backref=db.backref('laps', lazy='dynamic', passive_deletes=True, collection_class=list))