Skip to content

Commit

Permalink
Show next schedule date instead of last date.
Browse files Browse the repository at this point in the history
  • Loading branch information
William Hahn committed Nov 17, 2023
1 parent afedcdc commit 278e1d8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions app/cashflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
def calc_schedule():
months = 13
weeks = 53
years = 2
quarters = 5
years = 1
quarters = 4
biweeks = 27

try:
Expand All @@ -41,7 +41,7 @@ def calc_schedule():
futuredate = datetime.strptime(startdate, format).date() + relativedelta(months=k)
if futuredate <= datetime.today().date():
existing = Schedule.query.filter_by(name=name).first()
existing.startdate = futuredate
existing.startdate = futuredate + relativedelta(months=1)
if type == 'Income':
rollbackdate = datetime.combine(futuredate, datetime.min.time())
total = Total(type=type, name=name, amount=amount,
Expand All @@ -54,31 +54,31 @@ def calc_schedule():
futuredate = datetime.strptime(startdate, format).date() + relativedelta(weeks=k)
if futuredate <= datetime.today().date():
existing = Schedule.query.filter_by(name=name).first()
existing.startdate = futuredate
existing.startdate = futuredate + relativedelta(weeks=1)
total = Total(type=type, name=name, amount=amount, date=futuredate - pd.tseries.offsets.BDay(0))
db.session.add(total)
elif frequency == 'Yearly':
for k in range(years):
futuredate = datetime.strptime(startdate, format).date() + relativedelta(years=k)
if futuredate <= datetime.today().date():
existing = Schedule.query.filter_by(name=name).first()
existing.startdate = futuredate
existing.startdate = futuredate + relativedelta(years=1)
total = Total(type=type, name=name, amount=amount, date=futuredate - pd.tseries.offsets.BDay(0))
db.session.add(total)
elif frequency == 'Quarterly':
for k in range(quarters):
futuredate = datetime.strptime(startdate, format).date() + relativedelta(months=3 * k)
if futuredate <= datetime.today().date():
existing = Schedule.query.filter_by(name=name).first()
existing.startdate = futuredate
existing.startdate = futuredate + relativedelta(months=3)
total = Total(type=type, name=name, amount=amount, date=futuredate - pd.tseries.offsets.BDay(0))
db.session.add(total)
elif frequency == 'BiWeekly':
for k in range(biweeks):
futuredate = datetime.strptime(startdate, format).date() + relativedelta(weeks=2 * k)
if futuredate <= datetime.today().date():
existing = Schedule.query.filter_by(name=name).first()
existing.startdate = futuredate
existing.startdate = futuredate + relativedelta(weeks=2)
total = Total(type=type, name=name, amount=amount, date=futuredate - pd.tseries.offsets.BDay(0))
db.session.add(total)
elif frequency == 'Onetime':
Expand Down
2 changes: 1 addition & 1 deletion app/templates/schedule_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h2 style="color:white"><b>Schedules</b> </h2>
<th style="color:white">Amount</th>
<th style="color:white">Type</th>
<th style="color:white">Frequency</th>
<th style="color:white">Date</th>
<th style="color:white">Next Date</th>
<th>
<button type="button" class="btn btn-success float-center"
data-toggle="modal" data-target="#mymodal">Add New</button>
Expand Down

0 comments on commit 278e1d8

Please sign in to comment.