feat(report):add_cost

This commit is contained in:
shahzeydyfah
2025-01-21 00:22:44 +03:30
parent ced12fb014
commit 3e9f5450e6
2 changed files with 32 additions and 0 deletions
+26
View File
@@ -1,6 +1,7 @@
import uuid
from app.config import TaskEnv
from app.models.project import ProjectPriceReport
from app.models.report import StatusReport, ReportCountry, DonutList, DelayDonutDetail
from core.service.mongo_db import use_collection
@@ -298,3 +299,28 @@ class ReportRepository():
else:
result['upper_than_200'].append(i["_id"])
return result
#درصد میانگین افزایش هزینه پروژه های خاتمه یافته
async def add_cost(self):
result = {}
result['less_than_20'] = []
result['bet_20_50'] = []
result['bet_50_100'] = []
result['bet_100_200'] = []
result['upper_than_200'] = []
report = await use_collection(TaskEnv.CLN_PROJECT_PRICE_REPORT).find({}).to_list(None)
if report:
for i in report:
_model = ProjectPriceReport(**i)
cal = (_model.first_amount-_model.amount_status +_model.amount_adjust)/_model.first_amount
if cal < 20:
result['less_than_20'].append(_model.project_id)
elif cal < 50:
result['bet_20_50'].append(_model.project_id)
elif cal < 100:
result['bet_50_100'].append(_model.project_id)
elif cal < 200:
result['bet_100_200'].append(_model.project_id)
else:
result['upper_than_200'].append(_model.project_id)
return result
+6
View File
@@ -84,6 +84,12 @@ def list_donut(_inp: DonutList = Body(...)):
def delay_donut(project_id:uuid.UUID):
pass
#درصد میانگین افزایش هزینه پروژه های خاتمه یافته
@router.get('/add_cost', tags=_tag_base)
@shrink(repo.add_cost)
def add_cost():
pass
app.include_router(router)