Fix spending-by-category counting transfers as uncategorized spending
Inter-account transfers have no category and a non-null transfer_id. The spending-by-category command was only filtering out positive amounts (income) but not transfers, causing the negative side of each transfer to appear as "Uncategorized" spending.
This commit is contained in:
@@ -208,6 +208,7 @@ async function main() {
|
||||
const txns = await api.getTransactions(acct.id, startDate, endDate);
|
||||
for (const t of txns) {
|
||||
if (t.amount >= 0) continue; // skip income
|
||||
if (t.transfer_id) continue; // skip inter-account transfers
|
||||
const catName = categoryMap[t.category] || 'Uncategorized';
|
||||
spending[catName] = (spending[catName] || 0) + t.amount;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user