aboutsummaryrefslogtreecommitdiff
path: root/src/main.js
diff options
context:
space:
mode:
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
});