Skip to content

Commit

Permalink
Fix for end of the month dates for quarterly transactions and update …
Browse files Browse the repository at this point in the history
…to Flask 3.0.2.
  • Loading branch information
William Hahn committed Feb 9, 2024
1 parent f30af1b commit 63b9450
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions app/cashflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 63b9450

Please sign in to comment.