Fix: subtotal on dashboard

This commit is contained in:
dx-tan 2024-02-06 11:08:46 +07:00
parent 2e0a369f84
commit ae3bd2b13a

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