class LineItem(db.Model): """Estimate model""" __tablename__ = 'line_items' id = db.Column(db.Integer, primary_key=True) order = db.Column(db.Integer, nullable=False) invoice_estimate_id = db.Column(db.Integer, db.ForeignKey('estimates.id')) description = db.Column(db.String(300), nullable=False) rate = db.Column(db.Numeric(8, 2), nullable=False) qty = db.Column(db.Float, nullable=False)
class Category(db.Model): """Item Category model""" __tablename__ = 'categories' id = db.Column(db.Integer(), primary_key=True) name = db.Column(db.String(255), nullable=False) parent_id = db.Column(db.Integer, db.ForeignKey('categories.id')) description = db.Column(db.Text) children = db.relationship('Category', backref=db.backref('parent', remote_side=id))
class Client(db.Model): """Client name, contact details, and address""" __tablename__ = 'clients' id = db.Column(db.Integer(), primary_key=True) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) fname = db.Column(db.String(75)) lname = db.Column(db.String(75)) email = db.Column(db.String(100)) phone = db.Column(db.String(75)) address1 = db.Column(db.String(100)) address2 = db.Column(db.String(100)) city = db.Column(db.String(100)) state = db.Column(db.String(50)) zip_code = db.Column(db.Integer()) def as_dict(self): return {c.name: getattr(self, c.name) for c in self.__table__.columns}
class User(db.Model, UserMixin): """A user for the app""" id = db.Column(db.Integer, primary_key=True) email = db.Column(db.String(255), unique=True) business_name = db.Column(db.String(255), nullable=True) fname = db.Column(db.String(255), nullable=True) lname = db.Column(db.String(255), nullable=True) phone = db.Column(db.String(30), nullable=True) initial_setup = db.Column(db.Boolean) password = db.Column(db.String(255)) active = db.Column(db.Boolean()) confirmed_at = db.Column(db.DateTime()) roles = db.relationship('Role', secondary=roles_users, backref=db.backref('users', lazy='dynamic'))
class ImageLocation(db.Model): """License image location""" id = db.Column(db.Integer(), primary_key=True) name = db.Column(db.String(255))
class ImageSize(db.Model): """License image size""" id = db.Column(db.Integer(), primary_key=True) name = db.Column(db.String(255))
class Circulation(db.Model): """License circulation model""" id = db.Column(db.Integer(), primary_key=True) name = db.Column(db.String(255))
class Role(db.Model, RoleMixin): """User roles""" id = db.Column(db.Integer(), primary_key=True) name = db.Column(db.String(80), unique=True) description = db.Column(db.String(255))