示例#1
0
class SalesItem(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    product = db.Column(db.Integer, db.ForeignKey('product.id'), nullable=False)
    quantity = db.Column(db.Integer, nullable=False)
    rate = db.Column(db.Integer, nullable=False)
    undersales = db.Column(db.Integer, db.ForeignKey('sales.id', ondelete="CASCADE"), nullable=False)

    def __repr__(self):
        return f"Sales Item('{self.product}', '{self.quantity}', '{self.rate}')"
示例#2
0
class Ledger(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(40), nullable=False)
    affectinventory = db.Column(db.Boolean)
    undername = db.Column(db.String(40))
    under = db.Column(db.Integer, db.ForeignKey('group.id', ondelete="CASCADE"), nullable=False)
    company_id = db.Column(db.Integer, db.ForeignKey('company.id', ondelete="CASCADE"), nullable=False)
    
    def __repr__(self):
        return f"Ledger('{self.name}','{self.under}')"
示例#3
0
class Sales(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    customer = db.Column(db.Integer,db.ForeignKey('customer.id'), nullable=False)
    date = db.Column(db.DateTime, nullable=False)
    invoiceno = db.Column(db.Integer, nullable=False)
    totalamount = db.Column(db.Integer)
    description = db.Column(db.String(250))
    salesitems = db.relationship('SalesItem', lazy=True, cascade="all, delete-orphan")
    company_id = db.Column(db.Integer, db.ForeignKey('company.id', ondelete="CASCADE"), nullable=False)

    def __repr__(self):
        return f"Sales('{self.id}','{self.invoiceno}', '{self.date}', '{self.totalamount}','{self.customer}')"
示例#4
0
class Product(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(40), nullable=False)
    category = db.Column(db.Integer, db.ForeignKey('productcategory.id', ondelete="CASCADE"), nullable=False)
    unit = db.Column(db.Integer, db.ForeignKey('unit.id'), nullable=False)
    quantity = db.Column(db.Integer, default=0)
    rate = db.Column(db.Integer)
    salesprice = db.Column(db.Integer)
    salesproduct = db.relationship('SalesItem',backref="productdetail", lazy=True)
    company_id = db.Column(db.Integer, db.ForeignKey('company.id', ondelete="CASCADE"), nullable=False)

    def __repr__(self):
        return f"Product('{self.name}', '{self.quantity}')"
示例#5
0
class Company(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    companyname = db.Column(db.String(80), unique=True, nullable=False)
    mailingname = db.Column(db.String(80), nullable = False)
    address = db.Column(db.String(100), nullable=False)
    country = db.Column(db.String(40), nullable=False)
    state = db.Column(db.String(40), nullable=False)
    pin = db.Column(db.Integer)
    email = db.Column(db.String(60))
    phoneno = db.Column(db.Integer)
    website = db.Column(db.String(60))
    datecreated = db.Column(db.DateTime, default = datetime.utcnow, nullable=False)
    financialyear = db.Column(db.DateTime, nullable=False)
    booksbegin = db.Column(db.DateTime, nullable=False)
    invoiceno = db.Column(db.Integer, default=0)
    gstno = db.Column(db.String(15))
    description = db.Column(db.Text)
    customers = db.relationship('Customer', backref='undercompany', lazy=True, cascade="all, delete-orphan")
    suppliers = db.relationship('Supplier', backref='undercompany', lazy=True, cascade="all, delete-orphan")
    groups = db.relationship('Group', backref='undercompany', lazy=True, cascade="all, delete-orphan")
    ledgers = db.relationship('Ledger', backref='undercompany', lazy=True, cascade="all, delete-orphan")
    productcategories = db.relationship('Productcategory', backref='undercompany', lazy=True, cascade="all, delete-orphan")
    products = db.relationship('Product', backref='undercompany', lazy=True, cascade="all, delete-orphan")
    units = db.relationship('Unit', backref='undercompany', lazy=True, cascade="all, delete-orphan")
    sale = db.relationship('Sales', backref='undercompany', lazy=True, cascade="all, delete-orphan")
    taxes = db.relationship('Tax', backref='undercompany', lazy=True, cascade="all, delete-orphan")
    user_id = db.Column(db.Integer, db.ForeignKey('user.id', ondelete="CASCADE"), nullable=False)

    def __repr__(self):
        return f"Company('{self.companyname}', '{self.owner.first}')"
示例#6
0
class Productcategory(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(40), nullable=False)
    products = db.relationship('Product', backref='undercategory', lazy=True, cascade="all, delete-orphan")
    company_id = db.Column(db.Integer, db.ForeignKey('company.id', ondelete="CASCADE"), nullable=False)

    def __repr__(self):
        return f"Product Category('{self.name}')"
示例#7
0
class Group(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(40), nullable=False)
    under = db.Column(db.String(20), nullable=False)
    ledgers = db.relationship('Ledger', backref='undergroup', lazy=True, cascade="all, delete-orphan")
    company_id = db.Column(db.Integer, db.ForeignKey('company.id', ondelete="CASCADE"), nullable=False)

    def __repr__(self):
        return f"Group('{self.name}','{self.under}')"
示例#8
0
class Supplier(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(40), nullable=False)
    first = db.Column(db.String(40))
    last = db.Column(db.String(40))
    mailingname = db.Column(db.String(40))
    address = db.Column(db.String(100))
    country = db.Column(db.String(30))
    state = db.Column(db.String(30))
    pin = db.Column(db.Integer)
    email = db.Column(db.String(50))
    phoneno = db.Column(db.Integer)
    gstno = db.Column(db.String(15))
    openingbalance = db.Column(db.Integer, default=0, nullable=False)
    currentbalance = db.Column(db.Integer, default=0, nullable=False)
    description = db.Column(db.Text)
    company_id = db.Column(db.Integer, db.ForeignKey('company.id', ondelete="CASCADE"), nullable=False)

    def __repr__(self):
        return f"Supplier('{self.name}', '{self.company_id}')"
示例#9
0
class Customer(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(40), nullable=False)
    first = db.Column(db.String(40))
    last = db.Column(db.String(40))
    mailingname = db.Column(db.String(40))
    address = db.Column(db.String(100))
    country = db.Column(db.String(30))
    state = db.Column(db.String(30))
    pin = db.Column(db.Integer)
    email = db.Column(db.String(50))
    phoneno = db.Column(db.Integer)
    gstno = db.Column(db.String(15))
    openingbalance = db.Column(db.Integer, default=0, nullable=False)
    currentbalance = db.Column(db.Integer, default=0, nullable=False)
    description = db.Column(db.Text)
    sale = db.relationship('Sales', lazy=True, backref="customerdetail", cascade="all, delete-orphan")
    company_id = db.Column(db.Integer, db.ForeignKey('company.id', ondelete="CASCADE"), nullable=False)

    def __repr__(self):
        return f"Customer('{self.name}', '{self.company_id}')"
示例#10
0
class Tax(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50), nullable=False)
    percentage = db.Column(db.Integer, nullable = False)
    company_id = db.Column(db.Integer, db.ForeignKey('company.id', ondelete="CASCADE"), nullable=False)