Пример #1
0
class Estimate(db.Model):
    """Estimate model"""

    __tablename__ = 'estimates'

    id = db.Column(db.Integer, primary_key=True)
    estimate_number = db.Column(db.Integer, nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    client_id = db.Column(db.Integer,
                          db.ForeignKey('clients.id'),
                          nullable=False)
    line_items = db.relationship('LineItem',
                                 backref='estimate',
                                 lazy='dynamic')
    terms = db.Column(db.Text, nullable=True)
    note = db.Column(db.Text, nullable=True)
    date_of_issue = db.Column(db.DateTime,
                              default=datetime.datetime.utcnow,
                              nullable=False)
    tax_rate = db.Column(db.Float, nullable=False)
    sub_total = db.Column(db.Numeric(8, 2), nullable=False)
    tax_total = db.Column(db.Numeric(8, 2), nullable=False)
    total = db.Column(db.Numeric(8, 2), nullable=False)
    client = db.relationship('Client')

    def as_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}
Пример #2
0
class Product(db.Model):
    """Product model"""

    __tablename__ = 'products'

    id = db.Column(db.Integer(), primary_key=True)
    category_id = db.Column(db.Integer, db.ForeignKey('categories.id'))
    category = db.relationship('Category')
    circulation_id = db.Column(db.Integer, db.ForeignKey('circulation.id'))
    circulation = db.relationship('Circulation')
    duration_id = db.Column(db.Integer, db.ForeignKey('duration.id'))
    duration = db.relationship('Duration')
    image_size_id = db.Column(db.Integer, db.ForeignKey('image_size.id'))
    image_size = db.relationship('ImageSize')
    image_location_id = db.Column(db.Integer,
                                  db.ForeignKey('image_location.id'))
    image_location = db.relationship('ImageLocation')
    price = db.Column(db.Numeric(8, 2), nullable=False)
Пример #3
0
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))
Пример #4
0
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)
Пример #5
0
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}
Пример #6
0
# -*- coding: utf-8 -*-
"""User models"""
from flask_security import UserMixin, RoleMixin
from quote.extensions import db

roles_users = db.Table(
    'roles_users', db.Column('user_id', db.Integer(),
                             db.ForeignKey('user.id')),
    db.Column('role_id', db.Integer(), db.ForeignKey('role.id')))


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))


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())