aboutsummaryrefslogtreecommitdiff
path: root/src/main.js
diff options
context:
space:
mode:
authorMark Powers <markppowers0@gmail.com>2020-10-07 08:45:32 -0500
committerMark Powers <markppowers0@gmail.com>2020-10-07 08:45:32 -0500
commit98da11b940c194f5e4bd423cb57d252df6185715 (patch)
treea6b55f19fe08be5cc68033fee2b72c53ac269170 /src/main.js
parent0712bdcc1e9c67bdde0a89c94ca5d72822ead854 (diff)
Add budget goals
Diffstat (limited to 'src/main.js')
-rw-r--r--src/main.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/main.js b/src/main.js
index b5e6b86..78b918e 100644
--- a/src/main.js
+++ b/src/main.js
@@ -6,6 +6,8 @@ window.onload = function () {
transactions: [],
summary: {username : ""},
selTodoType: "all",
+ total_to_allocate: 0,
+ goals: []
},
methods: {
setTab: function (value) {
@@ -26,6 +28,15 @@ window.onload = function () {
category: "",
subcategory: "",
}
+ this.ng = {
+ name: "",
+ total: "",
+ amount: 0
+ }
+ this.na = {
+ selected: "",
+ amount: ""
+ }
},
requestThenUpdate: function (request) {
fetch(request)
@@ -81,6 +92,8 @@ window.onload = function () {
},
created() {
this.clearData();
+ fetch(new Request(`/goals`)).then(response => response.json())
+ .then(response => this.goals = response);
fetch(new Request(`/transaction`)).then(response => response.json())
.then(response => this.transactions = response);
fetch(new Request(`/summary`)).then(response => response.json())
@@ -160,6 +173,12 @@ window.onload = function () {
// Note we flip these since income is negative
item.negative = el.s > 0
item.positive = el.s < 0
+
+ // -= since its flipped
+ this.total_to_allocate -= item.net
+ })
+ this.goals.forEach(el => {
+ this.total_to_allocate -= el.amount
})
this.summary.week.sort(function(a, b){
@@ -173,6 +192,9 @@ window.onload = function () {
this.summary.year.sort(function(a, b){
return a.y-b.y;
})
+
+ seriesX = this.summary.month.map(el => el.y)
+
this.summary.username = response.username
});