From cabb0950286ad65048016504a48036aff23540c2 Mon Sep 17 00:00:00 2001 From: Kumi Date: Fri, 4 Oct 2024 07:33:25 +0200 Subject: [PATCH] fix(data): standardize month formatting to two digits Updated the month keys in the `finances.json` file to use a two-digit format. Adjusted the `get_transparency_data` function to accommodate this change by zero-padding single-digit months. This ensures consistency in data representation and prevents potential errors in handling financial data. --- data/finances.json | 22 +++++++++++++++------- helpers/finances.py | 4 ++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/data/finances.json b/data/finances.json index 52a891a..b600fbd 100644 --- a/data/finances.json +++ b/data/finances.json @@ -1,6 +1,6 @@ { "2024": { - "4": { + "04": { "Membership Fees": { "EUR": 365 }, @@ -12,7 +12,7 @@ "Notes": "Administrative fee for the formation of the association" } }, - "5": { + "05": { "Membership Fees": { "EUR": 390 }, @@ -25,7 +25,7 @@ "Notes": "Includes setup costs and two monthly payments for new server" } }, - "6": { + "06": { "Membership Fees": { "EUR": 382.42 }, @@ -36,7 +36,7 @@ "EUR": -49.05 } }, - "7": { + "07": { "Membership Fees": { "EUR": 422.42 }, @@ -47,7 +47,7 @@ "EUR": -264.99 } }, - "8": { + "08": { "Membership Fees": { "EUR": 402.42 }, @@ -55,12 +55,20 @@ "EUR": -416.47 } }, - "9": { + "09": { "Membership Fees": { - "EUR": 448.11 + "EUR": 468.11 }, "Server Costs": { "EUR": -243.46 + }, + "Bank Fees": { + "EUR": -53.32 + } + }, + "10": { + "Membership Fees": { + "EUR": 30.23 } } } diff --git a/helpers/finances.py b/helpers/finances.py index 325acfb..aeb5acb 100644 --- a/helpers/finances.py +++ b/helpers/finances.py @@ -30,12 +30,12 @@ def get_transparency_data(data, year=None, month=None, allow_current=False): month = max(data[year].keys()) year = str(year) - month = str(month) + month = str(month).zfill(2) if ( not allow_current and year == str(datetime.now().year) - and month == str(datetime.now().month) + and month == str(datetime.now().month).zfill(2) ): try: month = max([m for m in data[year].keys() if m != str(datetime.now().month)])