Skip to content

Commit

Permalink
Fix for category summary chart not showing split record data.
Browse files Browse the repository at this point in the history
  • Loading branch information
dustincjensen committed Dec 7, 2021
1 parent 8a81871 commit 3df67a7
Showing 1 changed file with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,20 @@ const categorySummarySelector = (query: DateCurriedQuery, dateSelector) =>
}
}

// TODO bug where split records are not in balance for this chart.
// const splits = record.splitRecords;
// if (splits?.some(s => s.categoryId)) {
// Add to category balances
// }

/*
Fun Jul 2018
745.7
212.49 -> actual 272.49 // FIX
52.49
77.44
2581.41
964.66
Car Jun 2019
479.37 -> actual 671.27 // FIX
*/
// If the record has category or auto category it probably shouldn't have split records too.
const splits = record.splitRecords;
if (splits?.some(s => s.categoryId)) {
for (const split of splits.filter(s => s.categoryId)) {
const categoryId = split.categoryId;
const balance = (split.credit || 0) - (split.debit || 0);

if (categoryBalances[categoryId]) {
categoryBalances[categoryId] += balance;
} else {
categoryBalances[categoryId] = balance;
}
}
}
}
}
categoryBalancesByDate.push({ date, categoryBalances: categoryBalances });
Expand Down

0 comments on commit 3df67a7

Please sign in to comment.