Merge pull request #20 from SDSRV-IDP/enhancment/accuracy_calculation

Fix: subtotal on dashboard
This commit is contained in:
Nguyen Viet Anh 2024-02-06 13:46:46 +07:00 committed by GitHub Enterprise
commit 406685119f

View File

@ -178,6 +178,7 @@ class ReportAccumulateByRequest:
this_day = request.created_at.strftime("%Y%m%d")
if not self.data.get(this_month, None):
self.data[this_month] = [copy.deepcopy(self.total_format), {}]
self.data[this_month][0]["extraction_date"] = "Subtotal (" + request.created_at.strftime("%Y-%m") + ")"
if not self.data[this_month][1].get(this_day, None):
self.data[this_month][1][this_day] = copy.deepcopy(self.day_format)[0]
self.data[this_month][1][this_day]['extraction_date'] = request.created_at.strftime("%Y-%m-%d")
@ -207,7 +208,9 @@ class ReportAccumulateByRequest:
# extract data
for month in report_data.keys():
fine_data.append(report_data[month][0])
for day in report_data[month][1].keys():
day_keys = list(report_data[month][1].keys())
day_keys.sort(reverse = True)
for day in day_keys:
fine_data.append(report_data[month][1][day])
# save daily reports
report_id = root_report_id + "_" + day