-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalues.py
More file actions
33 lines (25 loc) · 763 Bytes
/
Copy pathvalues.py
File metadata and controls
33 lines (25 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from connect import db
from models import Transactions
from flask_login import current_user
from datetime import datetime
from sqlalchemy import func
import numpy as np
today = datetime.today()
def totalBal():
amount = 0
uid = current_user.id
for obj in Transactions.query.filter_by(userId = uid).all():
if obj.cashFlow == 2:
amount -= obj.amount
if obj.cashFlow == 1:
amount += obj.amount
return amount
def leftBal():
amount = 0
budget = current_user.budget
uid = current_user.id
for obj in Transactions.query.filter_by(userId = uid).all():
if obj.date.month == today.month:
if obj.cashFlow == 2:
amount += obj.amount
return (budget - amount)