regular exp updated on model

This commit is contained in:
2026-03-17 18:02:28 +05:30
parent 96a3a79731
commit 5ddfb1f440
11 changed files with 25 additions and 135 deletions

View File

@@ -1,6 +1,7 @@
from app import db
from datetime import datetime
from sqlalchemy import event
from app.utils.regex_utils import RegularExpression
class ManholeExcavation(db.Model):
__tablename__ = "manhole_excavation"
@@ -67,13 +68,11 @@ class ManholeExcavation(db.Model):
def serialize(self):
return {c.name: getattr(self, c.name) for c in self.__table__.columns}
# ==========================================
# AUTO CALCULATE GRAND TOTAL
# ==========================================
# AUTO TOTAL USING REGEX
def calculate_Manhole_total(mapper, connection, target):
total = 0
for column in target.__table__.columns:
if column.name.endswith("_total"):
if RegularExpression.STR_TOTAL_PATTERN.match(column.name):
total += getattr(target, column.name) or 0
target.Total = total