From d1898e7f38f3e3e40794a7ff5040c72f450360d9 Mon Sep 17 00:00:00 2001 From: Tilman Date: Sun, 10 Nov 2019 00:33:56 +0100 Subject: [PATCH] Show budget, pt. 1 --- src/main/resources/data-h2.sql | 2 +- src/main/resources/static/app/controllers.js | 19 +++++++++++++++++++ .../static/app/transaction-list.html | 4 ++++ src/main/resources/static/css/app.css | 11 +++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/main/resources/data-h2.sql b/src/main/resources/data-h2.sql index 528f387..974cc3b 100644 --- a/src/main/resources/data-h2.sql +++ b/src/main/resources/data-h2.sql @@ -73,6 +73,6 @@ INSERT INTO Transaction (id, amount, account_id, category_id, date, description, INSERT INTO Transaction (id, amount, account_id, category_id, date, description, creditor_id) VALUES (NULL, -1.50, 1, 3, '2019-10-01', 'Transaction28', null); Commit; INSERT INTO Transaction (id, amount, account_id, category_id, date, description, creditor_id) VALUES (NULL, -1.50, 1, 1, '2019-10-01', 'Transaction29', null); Commit; INSERT INTO Transaction (id, amount, account_id, category_id, date, description, creditor_id) VALUES (NULL, -1.50, 1, 3, '2019-10-01', 'Transaction30', null); Commit; -INSERT INTO Transaction (id, amount, account_id, category_id, date, description, creditor_id) VALUES (NULL, 1.90, 2, 5, CURRENT_TIMESTAMP()+1, 'LAST Transaction', null); Commit; +INSERT INTO Transaction (id, amount, account_id, category_id, date, description, creditor_id) VALUES (NULL, -14.95, 1, 5, CURRENT_TIMESTAMP()+1, 'LAST Transaction', null); Commit; --SCRIPT TO 'h2export.sql'; \ No newline at end of file diff --git a/src/main/resources/static/app/controllers.js b/src/main/resources/static/app/controllers.js index ab2a078..0de12af 100644 --- a/src/main/resources/static/app/controllers.js +++ b/src/main/resources/static/app/controllers.js @@ -104,6 +104,25 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$routePara $scope.checkCategory = function() { + // get current expense level for category + $scope.transaction.category.percentage = 0; + + // https://stackoverflow.com/a/30119263 + var budgetInfo = $resource('/api/categories/search/expenseLevelYear', { accountId: $scope.account.id, categoryId: $scope.transaction.category.id }, {'getText': { + transformResponse: function(data, headersGetter, status) { + return {value: data}; + }}}).getText(); + budgetInfo.$promise.then(function(data) { + $scope.transaction.category.percentage = parseFloat(budgetInfo.value) + 5; +// console.log(budgetInfo.value); + }); + + + + + + + // if this is selected to be a withdrawal, preselect the current user and disable "no creditor" radio button if ($scope.transaction.category.name === 'Private Entnahme') { $scope.transaction.creditor = $scope.userinfo._links.self.href; diff --git a/src/main/resources/static/app/transaction-list.html b/src/main/resources/static/app/transaction-list.html index 79641a6..4bf1a0a 100644 --- a/src/main/resources/static/app/transaction-list.html +++ b/src/main/resources/static/app/transaction-list.html @@ -84,6 +84,10 @@ +
+ Budget: +
+
diff --git a/src/main/resources/static/css/app.css b/src/main/resources/static/css/app.css index 9a69bb0..aa640d0 100644 --- a/src/main/resources/static/css/app.css +++ b/src/main/resources/static/css/app.css @@ -15,6 +15,17 @@ label { color: white; } +.budgetArea { + font-family: "Yanone Kaffeesatz", sans-serif; + color: #eee; + margin-top: .5em; +} + +.budgetCalculation { + font-family: "Open Sans", sans-serif; + color: white; +} + .modal-body label { color: #aaa; }