feat:add sum to delay
This commit is contained in:
@@ -7,23 +7,30 @@ from pydantic import Field
|
||||
|
||||
from core.models.base import BaseModel
|
||||
|
||||
|
||||
class Financial(pydantic.BaseModel):
|
||||
status: Optional[int] = Field(description="صورت وضعیت")
|
||||
prepayment: Optional[int] = Field(description=" پیش پرداخت")
|
||||
modification: Optional[int] = Field(description="تعدیل")
|
||||
good_job: Optional[int] = Field(description="حسن انجام کار")
|
||||
total: Optional[int] = Field(default=0, description='مجموع')
|
||||
|
||||
|
||||
class ForceMajor(pydantic.BaseModel):
|
||||
force_event: Optional[int] = Field(description="حوادث قهری")
|
||||
material: Optional[int] = Field(description="محدودیت ورود مصالح")
|
||||
rules: Optional[int] = Field(description="وضع قوانین جدید")
|
||||
define_indicators: Optional[int] = Field(description="تاخیرات در اعالم شاخص های قطعی")
|
||||
total: Optional[int] = Field(default=0, description='مجموع')
|
||||
|
||||
|
||||
class Technical(pydantic.BaseModel):
|
||||
map_technical: Optional[int] = Field(description="تغییر نقشه و مشخصات فنی")
|
||||
permit: Optional[int] = Field(description="تاخیرات در تحویل کارگاه معارض زمین یا اخذ پروانه")
|
||||
purchase: Optional[int] = Field(description="تاخیر در خرید کارفرمایی")
|
||||
suspense: Optional[int] = Field(description="تعلیق پیمان ماده 49")
|
||||
total: Optional[int] = Field(default=0, description='مجموع')
|
||||
|
||||
|
||||
class BillDelayModel(BaseModel):
|
||||
id: Optional[uuid.UUID] = Field(alias='_id')
|
||||
@@ -39,4 +46,3 @@ class BillDelayModel(BaseModel):
|
||||
date_submission_bill: Optional[datetime] = Field(description='تاریخ ابلاغ لایحه')
|
||||
description: Optional[str] = Field(description='توضیحات')
|
||||
end_at: Optional[datetime] = Field(description='تاریخ خاتمه پیمان')
|
||||
|
||||
|
||||
@@ -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