feat:add sum to delay
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from uuid import UUID
|
||||
|
||||
from app.config import TaskEnv
|
||||
from app.models.bill_delay import BillDelayModel
|
||||
from core.repositories.base import BaseRepository
|
||||
@@ -6,3 +8,49 @@ from core.repositories.base import BaseRepository
|
||||
class BillDelayRepository(BaseRepository):
|
||||
def __init__(self):
|
||||
super().__init__(collection=TaskEnv.CLN_BILL_DELAY, model=BillDelayModel)
|
||||
|
||||
def create_sum(self, coding: BillDelayModel) -> BillDelayModel:
|
||||
if coding.financial:
|
||||
total = 0
|
||||
if coding.financial.status:
|
||||
total += coding.financial.status
|
||||
if coding.financial.prepayment:
|
||||
total += coding.financial.prepayment
|
||||
if coding.financial.modification:
|
||||
total += coding.financial.modification
|
||||
if coding.financial.good_job:
|
||||
total += coding.financial.good_job
|
||||
coding.financial.total = total
|
||||
if coding.force_major:
|
||||
total = 0
|
||||
if coding.force_major.force_event:
|
||||
total += coding.force_major.force_event
|
||||
if coding.force_major.material:
|
||||
total += coding.force_major.material
|
||||
if coding.force_major.rules:
|
||||
total += coding.force_major.rules
|
||||
if coding.force_major.define_indicators:
|
||||
total += coding.force_major.define_indicators
|
||||
coding.force_major.total = total
|
||||
|
||||
if coding.technical:
|
||||
total = 0
|
||||
if coding.technical.map_technical:
|
||||
total += coding.technical.map_technical
|
||||
if coding.technical.permit:
|
||||
total += coding.technical.permit
|
||||
if coding.technical.purchase:
|
||||
total += coding.technical.purchase
|
||||
if coding.technical.suspense:
|
||||
total += coding.technical.suspense
|
||||
coding.technical.total = total
|
||||
return coding
|
||||
async def create(self, coding: BillDelayModel):
|
||||
coding = self.create_sum(coding)
|
||||
return await super().create(coding)
|
||||
async def update(self, _id: UUID, update: BillDelayModel):
|
||||
update = self.create_sum(update)
|
||||
return await super().update(_id, update)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user