update code of dash and report of cont_client and devlp abstract of qty

This commit is contained in:
2026-07-30 14:38:37 +05:30
parent 12b2032430
commit bf1df3a817
42 changed files with 3066 additions and 952 deletions

View File

@@ -2,6 +2,7 @@ from app import db
from datetime import datetime
from sqlalchemy import event
from app.utils.regex_utils import RegularExpression
from decimal import Decimal
class Laying(db.Model):
__tablename__ = "laying"
@@ -13,31 +14,30 @@ class Laying(db.Model):
subcontractor = db.relationship("Subcontractor", backref="laying_records")
# Pipe Laying Fields
RA_Bill_No=db.Column(db.String(500))
Location = db.Column(db.String(500))
MH_NO = db.Column(db.String(100))
CC_length = db.Column(db.Numeric(10, 4), default=0)
Pipe_Dia_mm = db.Column(db.Numeric(10, 4), default=0)
ID_of_MH_m = db.Column(db.Numeric(10, 4), default=0)
Laying_Length = db.Column(db.Numeric(10, 4), default=0)
CC_length = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
Pipe_Dia_mm = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
ID_of_MH_m = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
Laying_Length = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
pipe_150_mm = db.Column(db.Numeric(10, 4), default=0)
pipe_200_mm = db.Column(db.Numeric(10, 4), default=0)
pipe_250_mm = db.Column(db.Numeric(10, 4), default=0)
pipe_300_mm = db.Column(db.Numeric(10, 4), default=0)
pipe_350_mm = db.Column(db.Numeric(10, 4), default=0)
pipe_400_mm = db.Column(db.Numeric(10, 4), default=0)
pipe_450_mm = db.Column(db.Numeric(10, 4), default=0)
pipe_500_mm = db.Column(db.Numeric(10, 4), default=0)
pipe_600_mm = db.Column(db.Numeric(10, 4), default=0)
pipe_700_mm = db.Column(db.Numeric(10, 4), default=0)
pipe_900_mm = db.Column(db.Numeric(10, 4), default=0)
pipe_1200_mm = db.Column(db.Numeric(10, 4), default=0)
pipe_150_mm = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
pipe_200_mm = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
pipe_250_mm = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
pipe_300_mm = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
pipe_350_mm = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
pipe_400_mm = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
pipe_450_mm = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
pipe_500_mm = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
pipe_600_mm = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
pipe_700_mm = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
pipe_900_mm = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
pipe_1200_mm = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
Total = db.Column(db.Numeric(12, 4), default=0)
Remarks = db.Column(db.String(500))
RA_Bill_No=db.Column(db.String(500))
created_at = db.Column(db.DateTime, default=datetime.today)
Total = db.Column(db.Numeric(12, 2), default=Decimal("0.00"))
Remarks = db.Column(db.String(500), default="Import File")
created_at = db.Column(db.DateTime,default=datetime.now,nullable=False)
def __repr__(self):
@@ -49,11 +49,13 @@ class Laying(db.Model):
# AUTO TOTAL USING REGEX
def calculate_laying_total(mapper, connection, target):
total = 0
total = Decimal("0.00")
for column in target.__table__.columns:
if RegularExpression.PIPE_MM_PATTERN.match(column.name):
total += getattr(target, column.name) or 0
target.Total = round(total)
value = getattr(target, column.name)
if value is not None:
total += Decimal(value)
target.Total = total.quantize(Decimal("0.01"))
event.listen(Laying, "before_insert", calculate_laying_total)
event.listen(Laying, "before_update", calculate_laying_total)