From 63b94505291ca3293d80305cb85ee4b88937eb0f Mon Sep 17 00:00:00 2001 From: William Hahn Date: Fri, 9 Feb 2024 10:09:28 -0600 Subject: [PATCH] Fix for end of the month dates for quarterly transactions and update to Flask 3.0.2. --- app/cashflow.py | 20 ++++++++++++++++++++ requirements.txt | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/cashflow.py b/app/cashflow.py index 57df60d..951104f 100644 --- a/app/cashflow.py +++ b/app/cashflow.py @@ -144,8 +144,28 @@ def calc_schedule(): elif frequency == 'Quarterly': for k in range(quarters): futuredate = datetime.strptime(startdate, format).date() + relativedelta(months=3 * k) + futuredateday = futuredate.day + firstdateday = datetime.strptime(firstdate, format).date().day + if firstdateday > futuredateday: + try: + for m in range(3): + futuredateday += 1 + if firstdateday >= futuredateday: + futuredate = futuredate.replace(day=futuredateday) + except ValueError: + pass if futuredate <= todaydate: existing.startdate = futuredate + relativedelta(months=3) + daycheckdate = futuredate + relativedelta(months=3) + daycheck = daycheckdate.day + if firstdateday > daycheck: + try: + for m in range(3): + daycheck += 1 + if firstdateday >= daycheck: + existing.startdate = daycheckdate.replace(day=daycheck) + except ValueError: + pass total = Total(type=type, name=name, amount=amount, date=futuredate - pd.tseries.offsets.BDay(0)) db.session.add(total) elif frequency == 'BiWeekly': diff --git a/requirements.txt b/requirements.txt index 7239f2f..c591758 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -Flask>=3.0.0 +Flask>=3.0.2 flask-sqlalchemy>=3.0.2 Flask-Login>=0.6.3 plotly>=5.14.1