diff --git a/src/api/controller/accounts.py b/src/api/controller/accounts.py index b59d1f4..3ac705d 100644 --- a/src/api/controller/accounts.py +++ b/src/api/controller/accounts.py @@ -19,6 +19,7 @@ def get_accounts(): query = session.query( Account.id.label("id"), Account.name.label("name"), + Account.authorized_overdraft.label("authorized_overdraft"), func.sum(Entry.value).label("future"), func.sum(case([(Entry.operation_date != None, Entry.value,)], else_=cast(0, db.Numeric(15, 2)))).label("pointed"), func.sum(case([(Entry.value_date < func.now(), Entry.value,)], else_=cast(0, db.Numeric(15, 2)))).label("current") @@ -27,6 +28,7 @@ def get_accounts(): return json.dumps([{ "id": i.id, "name": i.name, + "authorized_overdraft": i.authorized_overdraft, "current": str(i.current), "pointed": str(i.pointed), "future": str(i.future) @@ -51,7 +53,7 @@ def add_account(): session = db.create_scoped_session() try: - account = Account(request.json['name']) + account = Account(request.json['name'], request.json['authorized_overdraft']) session.add(account) session.commit() @@ -70,6 +72,7 @@ def update_account(account_id): account = session.query(Account).filter(Account.id == account_id).first() account.name = request.json['name'] + account.authorized_overdraft = request.json['authorized_overdraft'] session.merge(account) session.commit() diff --git a/src/api/model/accounts.py b/src/api/model/accounts.py index f2b12d4..1fd87de 100644 --- a/src/api/model/accounts.py +++ b/src/api/model/accounts.py @@ -4,7 +4,9 @@ from app import db class Account(db.Model): id = db.Column(db.Integer, primary_key = True) name = db.Column(db.String(200), nullable = False) + authorized_overdraft = db.Column(db.Integer, nullable = True, default = 0) - def __init__(self, name): + def __init__(self, name, authorized_overdraft): self.name = name + self.authorized_overdraft = authorized_overdraft diff --git a/src/html/index.html b/src/html/index.html index b4fffda..016a7de 100644 --- a/src/html/index.html +++ b/src/html/index.html @@ -120,6 +120,10 @@
+ +
+ +
@@ -130,13 +134,13 @@