regular exp updated on model
This commit is contained in:
@@ -1,15 +1,12 @@
|
||||
from app import db
|
||||
from datetime import datetime
|
||||
from sqlalchemy import event
|
||||
from app.utils.regex_utils import RegularExpression
|
||||
|
||||
class ManholeExcavationClient(db.Model):
|
||||
__tablename__ = "mh_ex_client"
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
# Foreign Key to Subcontractor table
|
||||
# subcontractor_id = db.Column(db.Integer, db.ForeignKey("subcontractors.id"), nullable=False)
|
||||
# Relationship for easy access (subcontractor.subcontractor_name)
|
||||
# subcontractor = db.relationship("Subcontractor", backref="mh_ex_records")
|
||||
|
||||
# Basic Fields
|
||||
RA_Bill_No=db.Column(db.String(500))
|
||||
@@ -84,13 +81,11 @@ class ManholeExcavationClient(db.Model):
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user