reports shows real budget information for total spend
This commit is contained in:
dandds
2018-09-19 10:29:22 -04:00
committed by GitHub
5 changed files with 56 additions and 13 deletions

View File

@@ -154,18 +154,15 @@ CUMULATIVE_BUDGET_BELUGA = {
class Reports:
@classmethod
def workspace_totals(cls, alternate):
data = MONTHLY_SPEND_BELUGA if alternate else MONTHLY_SPEND_AARDVARK
spent = sum(
[
spend
for project in data.values()
for env in project.values()
for spend in env.values()
]
)
budget = 70_000 if alternate else 500_000
return {"budget": budget, "spent": spent}
def workspace_totals(cls, workspace):
if workspace.request and workspace.request.task_order:
ws_to = workspace.request.task_order
budget = ws_to.budget
else:
budget = 0
# spent will be derived from CSP data
return {"budget": budget, "spent": 0}
@classmethod
def monthly_totals(cls, alternate):

View File

@@ -47,3 +47,19 @@ class TaskOrder(Base):
for c in self.__table__.columns
if c.name not in ["id", "attachment_id"]
}
@property
def budget(self):
return sum(
filter(
None,
[
self.clin_0001,
self.clin_0003,
self.clin_1001,
self.clin_1003,
self.clin_2001,
self.clin_2003,
],
)
)

View File

@@ -109,7 +109,7 @@ def workspace_reports(workspace_id):
return render_template(
"workspaces/reports/index.html",
cumulative_budget=Reports.cumulative_budget(alternate_reports),
workspace_totals=Reports.workspace_totals(alternate_reports),
workspace_totals=Reports.workspace_totals(workspace),
monthly_totals=Reports.monthly_totals(alternate_reports),
current_month=current_month,
prev_month=prev_month,