From 7ebbf4627626f219620258dc09f8a75696026142 Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Sat, 2 Jan 2021 10:50:13 -0600 Subject: Fix date month formatting and add category undefined check --- src/server/summary.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/server/summary.js') 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 +} -- cgit v1.2.3