Skip to content

Commit

Permalink
Make sure generated transactions are within date boundaries
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Ferreira committed Oct 29, 2017
1 parent 89a46d0 commit fbb57b7
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions application/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,17 +349,19 @@ def generate_recurring(account_id, label, amount, start_date, end_date, recurrin
inc=True)

for occurence in times:
transaction_id = str(uuid4())
transaction = Transaction(
transaction_id=transaction_id,
account_id=account_id,
label=label,
amount=amount,
recurring_group_id=recurring_group_id,
date=occurence,
tick=0
)
db.session.add(transaction)
# extra safety check
if start_date.strftime('%F%H%M%S') <= occurence.strftime('%F%H%M%S') <= end_date.strftime('%F%H%M%S'):
transaction_id = str(uuid4())
transaction = Transaction(
transaction_id=transaction_id,
account_id=account_id,
label=label,
amount=amount,
recurring_group_id=recurring_group_id,
date=occurence,
tick=0
)
db.session.add(transaction)


@app.route("/api/recurring/create", methods=["POST"])
Expand Down

0 comments on commit fbb57b7

Please sign in to comment.