fix(bill delay):update project
This commit is contained in:
@@ -3,6 +3,7 @@ from uuid import UUID
|
||||
from app.config import TaskEnv
|
||||
from app.models.bill_delay import BillDelayModel
|
||||
from core.repositories.base import BaseRepository
|
||||
from core.service.mongo_db import use_collection
|
||||
|
||||
|
||||
class BillDelayRepository(BaseRepository):
|
||||
@@ -59,9 +60,17 @@ class BillDelayRepository(BaseRepository):
|
||||
return coding
|
||||
async def create(self, coding: BillDelayModel):
|
||||
coding = self.create_sum(coding)
|
||||
return await super().create(coding)
|
||||
delay = await super().create(coding)
|
||||
await use_collection(TaskEnv.CLN_PROJECT).update_one({"_id": coding.project_id}, {"$inc": {"all_delay_day":coding.total_day}})
|
||||
return delay
|
||||
async def update(self, _id: UUID, update: BillDelayModel):
|
||||
old = await self.get(_id)
|
||||
old_model = BillDelayModel(**old)
|
||||
update = self.create_sum(update)
|
||||
if old_model.total_day:
|
||||
diff = update.total_day - old_model.total_day
|
||||
await use_collection(TaskEnv.CLN_PROJECT).update_one({"_id": update.project_id},
|
||||
{"$inc": {"all_delay_day": diff}})
|
||||
return await super().update(_id, update)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user