update code of dash and report of cont_client and devlp abstract of qty
This commit is contained in:
@@ -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 LayingClient(db.Model):
|
||||
__tablename__ = "laying_client"
|
||||
@@ -9,39 +10,47 @@ class LayingClient(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
|
||||
# Basic 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)
|
||||
CC_length = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
# Bedding Qty.
|
||||
Outer_dia_of_MH_m = db.Column(db.Numeric(10, 4), default=0)
|
||||
Bedding_Length = db.Column(db.Numeric(10, 4), default=0)
|
||||
Width = db.Column(db.Numeric(10, 4), default=0)
|
||||
Depth = db.Column(db.Numeric(10, 4), default=0)
|
||||
Qty = db.Column(db.Numeric(10, 4), default=0)
|
||||
Outer_dia_of_MH_m = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Bedding_Length = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Width = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Depth = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Qty = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
# PIPE LAYING Qty.
|
||||
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)
|
||||
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))
|
||||
np4_pipe_200_mm = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
np4_pipe_250_mm = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
np4_pipe_300_mm = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
np4_pipe_350_mm = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
np4_pipe_400_mm = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
np4_pipe_450_mm = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
np4_pipe_500_mm = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
np4_pipe_600_mm = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
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):
|
||||
@@ -53,11 +62,13 @@ class LayingClient(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(LayingClient, "before_insert", calculate_laying_total)
|
||||
event.listen(LayingClient, "before_update", calculate_laying_total)
|
||||
@@ -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)
|
||||
@@ -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 ManholeDomesticChamber(db.Model):
|
||||
__tablename__ = "manhole_domestic_chamber"
|
||||
@@ -13,38 +14,40 @@ class ManholeDomesticChamber(db.Model):
|
||||
subcontractor = db.relationship("Subcontractor", backref="manhole_domestic_chamber_records")
|
||||
|
||||
# Basic Fields
|
||||
RA_Bill_No=db.Column(db.String(500))
|
||||
Location = db.Column(db.String(500))
|
||||
MH_NO = db.Column(db.String(100))
|
||||
Depth_of_MH = db.Column(db.Numeric(10, 4), default=0)
|
||||
|
||||
# Excavation categories
|
||||
d_0_to_0_75 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_0_76_to_1_05 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_1_06_to_1_65 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_1_66_to_2_15 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_2_16_to_2_65 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_2_66_to_3_15 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_3_16_to_3_65= db.Column(db.Numeric(10, 4), default=0)
|
||||
d_3_66_to_4_15 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_4_16_to_4_65 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_4_66_to_5_15 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_5_16_to_5_65 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_5_66_to_6_15 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_6_16_to_6_65 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_6_66_to_7_15 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_7_16_to_7_65 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_7_66_to_8_15 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_8_16_to_8_65 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_8_66_to_9_15 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_9_16_to_9_65 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Depth_of_MH = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Domestic_Chambers = db.Column(db.Numeric(10, 4), default=0)
|
||||
DWC_Pipe_Length = db.Column(db.Numeric(10, 4), default=0)
|
||||
UPVC_Pipe_Length = db.Column(db.Numeric(10, 4), default=0)
|
||||
RA_Bill_No=db.Column(db.String(500))
|
||||
# Excavation categories
|
||||
d_0_to_0_75 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_0_76_to_1_05 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_1_06_to_1_65 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_1_66_to_2_15 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_2_16_to_2_65 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_2_66_to_3_15 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_3_16_to_3_65= db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_3_66_to_4_15 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_4_16_to_4_65 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_4_66_to_5_15 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_5_16_to_5_65 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_5_66_to_6_15 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_6_16_to_6_65 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_6_66_to_7_15 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_7_16_to_7_65 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_7_66_to_8_15 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_8_16_to_8_65 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_8_66_to_9_15 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_9_16_to_9_65 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Total = db.Column(db.Numeric(12, 4), default=0)
|
||||
created_at = db.Column(db.DateTime, default=datetime.today)
|
||||
Domestic_Chambers = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
DWC_Pipe_Length = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
UPVC_Pipe_Length = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
|
||||
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):
|
||||
return f"<HanholeDomesticChamberConstruction {self.Location}>"
|
||||
@@ -55,11 +58,13 @@ class ManholeDomesticChamber(db.Model):
|
||||
|
||||
# AUTO TOTAL USING REGEX
|
||||
def calculate_mh_dc_total(mapper, connection, target):
|
||||
total = 0
|
||||
total = Decimal("0.00")
|
||||
for column in target.__table__.columns:
|
||||
if RegularExpression.D_RANGE_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(ManholeDomesticChamber, "before_insert", calculate_mh_dc_total)
|
||||
event.listen(ManholeDomesticChamber, "before_update", calculate_mh_dc_total)
|
||||
@@ -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 ManholeExcavation(db.Model):
|
||||
__tablename__ = "manhole_excavation"
|
||||
@@ -13,54 +14,53 @@ class ManholeExcavation(db.Model):
|
||||
subcontractor = db.relationship("Subcontractor", backref="manhole_records")
|
||||
|
||||
# Basic Fields
|
||||
RA_Bill_No=db.Column(db.String(500))
|
||||
Location = db.Column(db.String(500))
|
||||
MH_NO = db.Column(db.String(100))
|
||||
|
||||
Upto_IL_Depth = db.Column(db.Numeric(10, 4), default=0)
|
||||
Cutting_Depth = db.Column(db.Numeric(10, 4), default=0)
|
||||
ID_of_MH_m = db.Column(db.Numeric(10, 4), default=0)
|
||||
Ex_Dia_of_Manhole = db.Column(db.Numeric(10, 4), default=0)
|
||||
Area_of_Manhole = db.Column(db.Numeric(10, 4), default=0)
|
||||
Upto_IL_Depth = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Cutting_Depth = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
ID_of_MH_m = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Ex_Dia_of_Manhole = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Area_of_Manhole = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
# Excavation categories
|
||||
Soft_Murum_0_to_1_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Murum_1_5_to_3_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Murum_3_0_to_4_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Murum_0_to_1_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Murum_1_5_to_3_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Murum_3_0_to_4_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Hard_Murum_0_to_1_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Murum_1_5_to_3_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Murum_0_to_1_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Murum_1_5_to_3_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Soft_Rock_0_to_1_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Rock_1_5_to_3_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Rock_0_to_1_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Rock_1_5_to_3_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Hard_Rock_0_to_1_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_1_5_to_3_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_3_0_to_4_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_4_5_to_6_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_6_0_to_7_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_0_to_1_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_1_5_to_3_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_3_0_to_4_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_4_5_to_6_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_6_0_to_7_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
# Totals
|
||||
Soft_Murum_0_to_1_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Murum_1_5_to_3_0_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Murum_3_0_to_4_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Murum_0_to_1_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Murum_1_5_to_3_0_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Murum_3_0_to_4_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Hard_Murum_0_to_1_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Murum_1_5_and_above_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Murum_0_to_1_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Murum_1_5_and_above_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Soft_Rock_0_to_1_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Rock_1_5_and_above_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Rock_0_to_1_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Rock_1_5_and_above_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Hard_Rock_0_to_1_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_1_5_to_3_0_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_3_0_to_4_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_4_5_to_6_0_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_6_0_to_7_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_0_to_1_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_1_5_to_3_0_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_3_0_to_4_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_4_5_to_6_0_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_6_0_to_7_5_total = 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):
|
||||
return f"<HanholeExcavation {self.Location}>"
|
||||
@@ -70,11 +70,13 @@ class ManholeExcavation(db.Model):
|
||||
|
||||
# AUTO TOTAL USING REGEX
|
||||
def calculate_Manhole_total(mapper, connection, target):
|
||||
total = 0
|
||||
total = Decimal("0.00")
|
||||
for column in target.__table__.columns:
|
||||
if RegularExpression.STR_TOTAL_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(ManholeExcavation, "before_insert", calculate_Manhole_total)
|
||||
|
||||
@@ -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 ManholeDomesticChamberClient(db.Model):
|
||||
__tablename__ = "mh_dc_client"
|
||||
@@ -9,30 +10,31 @@ class ManholeDomesticChamberClient(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
|
||||
# Basic Fields
|
||||
RA_Bill_No=db.Column(db.String(500))
|
||||
RA_Bill_No = db.Column(db.String(500))
|
||||
Location = db.Column(db.String(500))
|
||||
MH_NO = db.Column(db.String(100))
|
||||
MH_TOP_LEVEL = db.Column(db.Numeric(10, 4), default=0)
|
||||
MH_IL_LEVEL = db.Column(db.Numeric(10, 4), default=0)
|
||||
Depth_of_MH = db.Column(db.Numeric(10, 4), default=0)
|
||||
MH_TOP_LEVEL = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
MH_IL_LEVEL = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Depth_of_MH = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
# Excavation categories
|
||||
d_0_to_1_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_1_5_to_2_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_2_0_to_2_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_2_5_to_3_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_3_0_to_3_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_3_5_to_4_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_4_0_to_4_5= db.Column(db.Numeric(10, 4), default=0)
|
||||
d_4_5_to_5_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_5_0_to_5_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_5_5_to_6_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_6_0_to_6_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
d_0_to_1_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_1_5_to_2_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_2_0_to_2_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_2_5_to_3_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_3_0_to_3_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_3_5_to_4_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_4_0_to_4_5= db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_4_5_to_5_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_5_0_to_5_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_5_5_to_6_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
d_6_0_to_6_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Domestic_Chambers = db.Column(db.Numeric(10, 4), default=0)
|
||||
Domestic_Chambers = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Total = db.Column(db.Numeric(12, 4), default=0)
|
||||
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):
|
||||
return f"<HanholeDomesticChamberConstruction {self.Location}>"
|
||||
@@ -44,12 +46,13 @@ class ManholeDomesticChamberClient(db.Model):
|
||||
|
||||
# AUTO TOTAL USING REGEX
|
||||
def calculate_mh_dc_total(mapper, connection, target):
|
||||
total = 0
|
||||
total = Decimal("0.00")
|
||||
for column in target.__table__.columns:
|
||||
if RegularExpression.D_RANGE_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(ManholeDomesticChamberClient, "before_insert", calculate_mh_dc_total)
|
||||
event.listen(ManholeDomesticChamberClient, "before_update", calculate_mh_dc_total)
|
||||
@@ -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 ManholeExcavationClient(db.Model):
|
||||
__tablename__ = "mh_ex_client"
|
||||
@@ -9,70 +10,70 @@ class ManholeExcavationClient(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
|
||||
# Basic Fields
|
||||
RA_Bill_No=db.Column(db.String(500))
|
||||
RA_Bill_No = db.Column(db.String(500))
|
||||
Location = db.Column(db.String(500))
|
||||
MH_NO = db.Column(db.String(100))
|
||||
Ground_Level = db.Column(db.Numeric(10, 4), default=0)
|
||||
MH_Invert_Level = db.Column(db.Numeric(10, 4), default=0)
|
||||
MH_Top_Level = db.Column(db.Numeric(10, 4), default=0)
|
||||
Ex_Level = db.Column(db.Numeric(10, 4), default=0)
|
||||
Cutting_Depth = db.Column(db.Numeric(10, 4), default=0)
|
||||
MH_Depth = db.Column(db.Numeric(10, 4), default=0)
|
||||
ID_of_MH_m = db.Column(db.Numeric(10, 4), default=0)
|
||||
Ground_Level = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
MH_Invert_Level = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
MH_Top_Level = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Ex_Level = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Cutting_Depth = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
MH_Depth = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
ID_of_MH_m = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Dia_of_MH_Cutting = db.Column(db.Numeric(10, 4), default=0)
|
||||
Area_of_Manhole = db.Column(db.Numeric(10, 4), default=0)
|
||||
Dia_of_MH_Cutting = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Area_of_Manhole = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
# Excavation categories
|
||||
Marshi_Muddy_Slushy_0_to_1_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Marshi_Muddy_Slushy_1_5_to_3_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Marshi_Muddy_Slushy_3_0_to_4_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Marshi_Muddy_Slushy_0_to_1_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Marshi_Muddy_Slushy_1_5_to_3_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Marshi_Muddy_Slushy_3_0_to_4_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Soft_Murum_0_to_1_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Murum_1_5_to_3_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Murum_3_0_to_4_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Murum_0_to_1_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Murum_1_5_to_3_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Murum_3_0_to_4_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Hard_Murum_0_to_1_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Murum_1_5_to_3_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Murum_3_0_to_4_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Murum_0_to_1_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Murum_1_5_to_3_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Murum_3_0_to_4_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Soft_Rock_0_to_1_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Rock_1_5_to_3_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Murum_3_0_to_4_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Rock_0_to_1_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Rock_1_5_to_3_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Murum_3_0_to_4_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Hard_Rock_0_to_1_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_1_5_to_3_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_3_0_to_4_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_4_5_to_6_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_6_0_to_7_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_0_to_1_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_1_5_to_3_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_3_0_to_4_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_4_5_to_6_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_6_0_to_7_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
# Totals
|
||||
Marshi_Muddy_Slushy_0_to_1_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Marshi_Muddy_Slushy_1_5_to_3_0_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Marshi_Muddy_Slushy_3_0_to_4_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Marshi_Muddy_Slushy_0_to_1_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Marshi_Muddy_Slushy_1_5_to_3_0_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Marshi_Muddy_Slushy_3_0_to_4_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Soft_Murum_0_to_1_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Murum_1_5_to_3_0_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Murum_3_0_to_4_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Murum_0_to_1_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Murum_1_5_to_3_0_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Murum_3_0_to_4_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Hard_Murum_0_to_1_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Murum_1_5_to_3_0_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Murum_3_0_to_4_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Murum_0_to_1_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Murum_1_5_to_3_0_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Murum_3_0_to_4_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Soft_Rock_0_to_1_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Rock_1_5_to_3_0_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Rock_3_0_to_4_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Rock_0_to_1_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Rock_1_5_to_3_0_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Rock_3_0_to_4_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Hard_Rock_0_to_1_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_1_5_to_3_0_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_3_0_to_4_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_4_5_to_6_0_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_6_0_to_7_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_0_to_1_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_1_5_to_3_0_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_3_0_to_4_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_4_5_to_6_0_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_6_0_to_7_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Remarks = db.Column(db.String(500))
|
||||
Total = db.Column(db.Numeric(12, 4), default=0)
|
||||
|
||||
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):
|
||||
return f"<HanholeExcavation {self.Location}>"
|
||||
@@ -81,14 +82,15 @@ class ManholeExcavationClient(db.Model):
|
||||
return {c.name: getattr(self, c.name) for c in self.__table__.columns}
|
||||
|
||||
|
||||
# AUTO TOTAL USING REGEX
|
||||
# AUTO TOTAL USING REGEX
|
||||
def calculate_Manhole_total(mapper, connection, target):
|
||||
total = 0
|
||||
total = Decimal("0.00")
|
||||
for column in target.__table__.columns:
|
||||
if RegularExpression.STR_TOTAL_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(ManholeExcavationClient, "before_insert", calculate_Manhole_total)
|
||||
event.listen(ManholeExcavationClient, "before_update", calculate_Manhole_total)
|
||||
0
app/models/rate_model.py
Normal file
0
app/models/rate_model.py
Normal file
@@ -2,6 +2,8 @@ from app import db
|
||||
from datetime import datetime
|
||||
from sqlalchemy import event
|
||||
from app.utils.regex_utils import RegularExpression
|
||||
from decimal import Decimal
|
||||
|
||||
|
||||
class TrenchExcavationClient(db.Model):
|
||||
__tablename__ = "tr_ex_client"
|
||||
@@ -12,72 +14,71 @@ class TrenchExcavationClient(db.Model):
|
||||
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)
|
||||
Actual_Trench_Length = db.Column(db.Numeric(10, 4), default=0)
|
||||
Ground_Level = db.Column(db.Numeric(10, 4), default=0)
|
||||
Invert_Level = db.Column(db.Numeric(10, 4), default=0)
|
||||
Excavated_level = db.Column(db.Numeric(10, 4), default=0)
|
||||
Cutting_Depth = db.Column(db.Numeric(10, 4), default=0)
|
||||
Avg_Depth = db.Column(db.Numeric(10, 4), default=0)
|
||||
Pipe_Dia_mm = db.Column(db.Numeric(10, 4), default=0)
|
||||
CC_length = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Actual_Trench_Length = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Ground_Level = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Invert_Level = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Excavated_level = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Cutting_Depth = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Avg_Depth = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Pipe_Dia_mm = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
# width
|
||||
Width_0_to_1_5_m = db.Column(db.Numeric(10, 4), default=0)
|
||||
Width_1_5_to_3_0_m = db.Column(db.Numeric(10, 4), default=0)
|
||||
Width_3_0_to_4_5_m = db.Column(db.Numeric(10, 4), default=0)
|
||||
Width_4_5_to_6_0_m = db.Column(db.Numeric(10, 4), default=0)
|
||||
Width_6_0_to_7_5_m = db.Column(db.Numeric(10, 4), default=0)
|
||||
Width_0_to_1_5_m = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Width_1_5_to_3_0_m = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Width_3_0_to_4_5_m = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Width_4_5_to_6_0_m = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Width_6_0_to_7_5_m = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
# Excavation categories
|
||||
Marshi_Muddy_Slushy_0_to_1_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Marshi_Muddy_Slushy_1_5_to_3_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Marshi_Muddy_Slushy_3_0_to_4_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Marshi_Muddy_Slushy_0_to_1_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Marshi_Muddy_Slushy_1_5_to_3_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Marshi_Muddy_Slushy_3_0_to_4_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Soft_Murum_0_to_1_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Murum_1_5_to_3_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Murum_3_0_to_4_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Murum_0_to_1_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Murum_1_5_to_3_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Murum_3_0_to_4_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Hard_Murum_0_to_1_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Murum_1_5_to_3_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Murum_3_0_to_4_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Murum_0_to_1_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Murum_1_5_to_3_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Murum_3_0_to_4_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Soft_Rock_0_to_1_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Rock_1_5_to_3_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Rock_3_0_to_4_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Rock_0_to_1_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Rock_1_5_to_3_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Rock_3_0_to_4_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Hard_Rock_0_to_1_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_1_5_to_3_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_3_0_to_4_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_4_5_to_6_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_6_0_to_7_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_0_to_1_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_1_5_to_3_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_3_0_to_4_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_4_5_to_6_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_6_0_to_7_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
# Totals
|
||||
Marshi_Muddy_Slushy_0_to_1_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Marshi_Muddy_Slushy_1_5_to_3_0_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Marshi_Muddy_Slushy_3_0_to_4_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Marshi_Muddy_Slushy_0_to_1_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Marshi_Muddy_Slushy_1_5_to_3_0_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Marshi_Muddy_Slushy_3_0_to_4_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Soft_Murum_0_to_1_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Murum_1_5_to_3_0_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Murum_3_0_to_4_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Murum_0_to_1_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Murum_1_5_to_3_0_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Murum_3_0_to_4_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Hard_Murum_0_to_1_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Murum_1_5_to_3_0_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Murum_3_0_to_4_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Murum_0_to_1_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Murum_1_5_to_3_0_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Murum_3_0_to_4_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Soft_Rock_0_to_1_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Rock_1_5_to_3_0_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Rock_3_0_to_4_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Rock_0_to_1_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Rock_1_5_to_3_0_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Rock_3_0_to_4_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Hard_Rock_0_to_1_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_1_5_to_3_0_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_3_0_to_4_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_4_5_to_6_0_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_6_0_to_7_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_0_to_1_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_1_5_to_3_0_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_3_0_to_4_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_4_5_to_6_0_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_6_0_to_7_5_total = 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))
|
||||
|
||||
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):
|
||||
return f"<TrenchExcavation {self.Location}>"
|
||||
@@ -88,11 +89,13 @@ class TrenchExcavationClient(db.Model):
|
||||
|
||||
# AUTO TOTAL USING REGEX
|
||||
def calculate_trench_client_total(mapper, connection, target):
|
||||
total = 0
|
||||
total = Decimal("0.00")
|
||||
for column in target.__table__.columns:
|
||||
if RegularExpression.STR_TOTAL_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(TrenchExcavationClient, "before_insert", calculate_trench_client_total)
|
||||
event.listen(TrenchExcavationClient, "before_update", calculate_trench_client_total)
|
||||
@@ -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 TrenchExcavation(db.Model):
|
||||
__tablename__ = "trench_excavation"
|
||||
@@ -13,65 +14,64 @@ class TrenchExcavation(db.Model):
|
||||
subcontractor = db.relationship("Subcontractor", backref="trench_records")
|
||||
|
||||
# Basic 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)
|
||||
Invert_Level = db.Column(db.Numeric(10, 4), default=0)
|
||||
MH_Top_Level = db.Column(db.Numeric(10, 4), default=0)
|
||||
Ground_Level = db.Column(db.Numeric(10, 4), default=0)
|
||||
ID_of_MH_m = db.Column(db.Numeric(10, 4), default=0)
|
||||
Actual_Trench_Length = db.Column(db.Numeric(10, 4), default=0)
|
||||
Pipe_Dia_mm = db.Column(db.Numeric(10, 4), default=0)
|
||||
CC_length = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Invert_Level = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
MH_Top_Level = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Ground_Level = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
ID_of_MH_m = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Actual_Trench_Length = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Pipe_Dia_mm = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
# width
|
||||
Width_0_to_2_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Width_2_5_to_3_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Width_3_0_to_4_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Width_4_5_to_6_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Width_0_to_2_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Width_2_5_to_3_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Width_3_0_to_4_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Width_4_5_to_6_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Upto_IL_Depth = db.Column(db.Numeric(10, 4), default=0)
|
||||
Cutting_Depth = db.Column(db.Numeric(10, 4), default=0)
|
||||
Avg_Depth = db.Column(db.Numeric(10, 4), default=0)
|
||||
Upto_IL_Depth = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Cutting_Depth = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Avg_Depth = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
# Excavation categories
|
||||
Soft_Murum_0_to_1_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Murum_1_5_to_3_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Murum_3_0_to_4_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Murum_0_to_1_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Murum_1_5_to_3_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Murum_3_0_to_4_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Hard_Murum_0_to_1_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Murum_1_5_to_3_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Murum_0_to_1_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Murum_1_5_to_3_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Soft_Rock_0_to_1_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Rock_1_5_to_3_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Rock_0_to_1_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Rock_1_5_to_3_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Hard_Rock_0_to_1_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_1_5_to_3_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_3_0_to_4_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_4_5_to_6_0 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_6_0_to_7_5 = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_0_to_1_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_1_5_to_3_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_3_0_to_4_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_4_5_to_6_0 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_6_0_to_7_5 = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
# Totals
|
||||
Soft_Murum_0_to_1_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Murum_1_5_to_3_0_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Murum_3_0_to_4_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Murum_0_to_1_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Murum_1_5_to_3_0_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Murum_3_0_to_4_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Hard_Murum_0_to_1_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Murum_1_5_and_above_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Murum_0_to_1_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Murum_1_5_and_above_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Soft_Rock_0_to_1_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Rock_1_5_and_above_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Soft_Rock_0_to_1_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Soft_Rock_1_5_and_above_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
|
||||
Hard_Rock_0_to_1_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_1_5_to_3_0_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_3_0_to_4_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_4_5_to_6_0_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_6_0_to_7_5_total = db.Column(db.Numeric(10, 4), default=0)
|
||||
Hard_Rock_0_to_1_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_1_5_to_3_0_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_3_0_to_4_5_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_4_5_to_6_0_total = db.Column(db.Numeric(10, 2), default=Decimal("0.00"))
|
||||
Hard_Rock_6_0_to_7_5_total = 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):
|
||||
@@ -83,12 +83,13 @@ class TrenchExcavation(db.Model):
|
||||
|
||||
# AUTO TOTAL USING REGEX
|
||||
def calculate_trench_total(mapper, connection, target):
|
||||
total = 0
|
||||
total = Decimal("0.00")
|
||||
for column in target.__table__.columns:
|
||||
if RegularExpression.STR_TOTAL_PATTERN.match(column.name):
|
||||
total += getattr(target, column.name) or 0
|
||||
target.Total = total
|
||||
|
||||
value = getattr(target, column.name)
|
||||
if value is not None:
|
||||
total += Decimal(value)
|
||||
target.Total = total.quantize(Decimal("0.01"))
|
||||
|
||||
event.listen(TrenchExcavation, "before_insert", calculate_trench_total)
|
||||
event.listen(TrenchExcavation, "before_update", calculate_trench_total)
|
||||
21
app/models/width_model.py
Normal file
21
app/models/width_model.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from app import db
|
||||
|
||||
class Width(db.Model):
|
||||
__tablename__ = "width"
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
Dia_mm = db.Column(db.Numeric(10, 2), default=0)
|
||||
|
||||
pipe_150_mm = db.Column(db.Numeric(10, 2), default=0)
|
||||
pipe_200_mm = db.Column(db.Numeric(10, 2), default=0)
|
||||
pipe_250_mm = db.Column(db.Numeric(10, 2), default=0)
|
||||
pipe_300_mm = db.Column(db.Numeric(10, 2), default=0)
|
||||
pipe_350_mm = db.Column(db.Numeric(10, 2), default=0)
|
||||
pipe_400_mm = db.Column(db.Numeric(10, 2), default=0)
|
||||
pipe_450_mm = db.Column(db.Numeric(10, 2), default=0)
|
||||
pipe_500_mm = db.Column(db.Numeric(10, 2), default=0)
|
||||
pipe_600_mm = db.Column(db.Numeric(10, 2), default=0)
|
||||
pipe_700_mm = db.Column(db.Numeric(10, 2), default=0)
|
||||
pipe_900_mm = db.Column(db.Numeric(10, 2), default=0)
|
||||
pipe_1200_mm = db.Column(db.Numeric(10, 2), default=0)
|
||||
|
||||
Reference in New Issue
Block a user