# import SQLAlchemy from flask_sqlalchemy import SQLAlchemy from datetime import datetime db = SQLAlchemy() class Module(db.Model): name = db.Column( "Name", db.String(20), unique=True, nullable=False, primary_key=True ) description = db.Column("Description", db.String(50), nullable=False) def __repr__(self): return f"" class Customer(db.Model): primary_key = db.Column("CustomerId", db.Integer, nullable=False, primary_key=True) name = db.Column("Name", db.String(20), nullable=False) name_alternative = db.Column("NameAlternative", db.String(20)) date_time_created = db.Column("DateTimeCreated", db.String(20), nullable=False) date_time_updated = db.Column("DateTimeUpdated", db.String(20), nullable=False) code_customer = db.Column("CodeCustomer", db.String(20), unique=True) code_accounting = db.Column("CodeAccounting", db.String(20), unique=True) address = db.Column("Address", db.String(20)) postal_code = db.Column("PostalCode", db.Integer) city = db.Column("City", db.String(20)) country = db.Column("Country", db.String(20)) phone = db.Column("Phone", db.String(20)) website = db.Column("Website", db.String(20)) email = db.Column("Email", db.String(20)) professional_id_1 = db.Column("ProfessionalId1", db.String(20), unique=True) professional_id_2 = db.Column("ProfessionalId2", db.String(20), unique=True) tax_id = db.Column("TaxId", db.String(20), unique=True) payment_terms = db.Column("PaymentTerms", db.String(20), unique=True) def __repr__(self): return f"" class Product(db.Model): primary_key = db.Column("ProductId", db.Integer, primary_key=True) name = db.Column("Name", db.String(20), nullable=False, unique=True) code_accounting = db.Column("CodeAccounting", db.String(20)) unit_weight = db.Column("UnitWeight", db.Float) price_net = db.Column("PriceNet", db.Float) price_gross = db.Column("PriceGross", db.Float) tax_rate = db.Column("TaxRate", db.Float) date_time_created = db.Column( "DateTimeCreated", db.String, default=datetime.now().strftime("%Y-%m-%d %H:%M:%S"), ) date_time_updated = db.Column( "DateTimeUpdated", db.String, default=datetime.now().strftime("%Y-%m-%d %H:%M:%S"), ) def __init__( self, name, code_accounting, unit_weight, price_net, price_gross, tax_rate, ): self.name = name self.code_accounting = code_accounting self.unit_weight = unit_weight self.price_net = price_net self.price_gross = price_gross self.tax_rate = tax_rate def __repr__(self): return f"" class Log(db.Model): primary_key = db.Column("LogId", db.Integer, primary_key=True) target = db.Column("Target", db.String, default="False") nno3 = db.Column("NNO3", db.Float, default=0) p = db.Column("P", db.Float, default=0) k = db.Column("K", db.Float, default=0) ca = db.Column("Ca", db.Float, default=0) mg = db.Column("Mg", db.Float, default=0) s = db.Column("S", db.Float, default=0) na = db.Column("Na", db.Float, default=0) cl = db.Column("Cl", db.Float, default=0) fe = db.Column("Fe", db.Float, default=0) zn = db.Column("Zn", db.Float, default=0) b = db.Column("B", db.Float, default=0) mn = db.Column("Mn", db.Float, default=0) cu = db.Column("Cu", db.Float, default=0) mo = db.Column("Mo", db.Float, default=0) si = db.Column("Si", db.Float, default=0) nnh4 = db.Column("NNH4", db.Float, default=0) date_time_created = db.Column( "DateTimeCreated", db.String, default=datetime.now().strftime("%Y-%m-%d %H:%M:%S"), ) date_time_updated = db.Column( "DateTimeUpdated", db.String, default=datetime.now().strftime("%Y-%m-%d %H:%M:%S"), ) def __init__( self, target, nno3, p, k, ca, mg, s, na, cl, fe, zn, b, mn, cu, mo, si, nnh4 ): self.target = target self.nno3 = nno3 self.p = p self.k = k self.ca = ca self.mg = mg self.s = s self.na = na self.cl = cl self.fe = fe self.zn = zn self.b = b self.mn = mn self.cu = cu self.mo = mo self.si = si self.nnh4 = nnh4 self.date_time_created = datetime.now().strftime("%Y-%m-%d %H:%M:%S") def __repr__(self): return f"" # Everything after here is garbage class User(db.Model): id = db.Column(db.Integer, primary_key=True) name_first = db.Column(db.String(20), nullable=False) name_last = db.Column(db.String(20), nullable=False) email = db.Column(db.String(20), nullable=False) phone_mobile = db.Column(db.Integer, nullable=False) phone_alternative = db.Column(db.Integer) updated = db.Column(db.String) def __repr__(self): return f"" class Order(db.Model): # TODO id = db.Column(db.Integer, primary_key=True) date = db.Column(db.String(20), nullable=False) customer = db.Column(db.String(20), nullable=False) content = db.Column(db.String(10), nullable=False) updated = db.Column(db.String) def __repr__(self): return f""