diff options
author | Mark Powers <mark@marks.kitchen> | 2022-02-19 21:19:24 -0600 |
---|---|---|
committer | Mark Powers <mark@marks.kitchen> | 2022-02-19 21:19:24 -0600 |
commit | fdafefeabefb8f277bda209a1fd0374b14ce97e2 (patch) | |
tree | 6c87dcead8c2ddbff830da44d59a38220a758b26 /src | |
parent | 8ea923ef2c18fb2d7313800c95b4c3ce19e27a50 (diff) | |
parent | 7ebbf4627626f219620258dc09f8a75696026142 (diff) |
Merge branch 'master' of marks.kitchen:/srv/git/budget
Diffstat (limited to 'src')
-rw-r--r-- | src/server/index.js | 2 | ||||
-rw-r--r-- | src/server/summary.js | 14 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/server/index.js b/src/server/index.js index c34e9d6..582d482 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -42,7 +42,7 @@ function consumeMessage(res){ } } function dateToString(d){ - return `${d.getFullYear().toString()}/${d.getMonth().toString()}/${d.getDate().toString()}` + return `${d.getFullYear().toString()}/${(d.getMonth()+1).toString()}/${d.getDate().toString()}` } function setUpRoutes(models, jwtFunctions, database, templates) { diff --git a/src/server/summary.js b/src/server/summary.js index 373e8f9..999a48c 100644 --- a/src/server/summary.js +++ b/src/server/summary.js @@ -126,13 +126,19 @@ async function formatSummary(database, username) { summary.categories[el.category] = {category: el.category, all: el.s, d30: 0, d90: 0, d365: 0 } }) categories_30day.forEach(el => { - summary.categories[el.category].d30 = el.s + if(summary.categories[el.category]){ + summary.categories[el.category].d30 = el.s + } }) categories_90day.forEach(el => { - summary.categories[el.category].d90 = el.s + if(summary.categories[el.category]){ + summary.categories[el.category].d90 = el.s + } }) categories_365day.forEach(el => { - summary.categories[el.category].d365 = el.s + if(summary.categories[el.category]){ + summary.categories[el.category].d365 = el.s + } }) let subcategories = await database.query(`select subcategory, sum(amount) as s from transactions where username = '${username}' and subcategory <> '' group by subcategory`, { type: database.QueryTypes.SELECT }); @@ -183,4 +189,4 @@ function getClass(value){ module.exports = { setUpRoutes -}
\ No newline at end of file +} |