Skip to content

Fix filteredViewTotals and chartAggregations to use per-transaction tags#13

Merged
terryaney merged 2 commits into
issue/88-merchant-category-displayfrom
copilot/fix-filtered-view-totals
Apr 29, 2026
Merged

Fix filteredViewTotals and chartAggregations to use per-transaction tags#13
terryaney merged 2 commits into
issue/88-merchant-category-displayfrom
copilot/fix-filtered-view-totals

Conversation

Copilot AI commented Apr 29, 2026

Copy link
Copy Markdown

Both filteredViewTotals and chartAggregations were hoisting merchant.tags (the union of all tags across every transaction in that merchant entry) outside the transaction loop, causing categorizeAmount() to misclassify transactions that individually carry only a subset of those tags. This produces a mismatch between the Filtered View KPI card and the Cash Flow KPI card (which Python precomputes per-transaction).

Changes

  • filteredViewTotals — removed outer const tags = merchant.tags || []; replaced categorizeAmount(txn.amount, tags) with categorizeAmount(txn.amount, txn.tags || [])
  • chartAggregations — same fix: dropped merchant-level tags variable, pass txn.tags || [] directly
// Before — all txns in a merchant share the aggregate tag union
const tags = merchant.tags || [];
for (const txn of txns) {
    const c = categorizeAmount(txn.amount || 0, tags);

// After — each txn is classified by its own tags
for (const txn of txns) {
    const c = categorizeAmount(txn.amount || 0, txn.tags || []);

Each transaction already carries its own tags array in the report JSON, so no data-shape changes are required.

Copilot AI changed the title [WIP] Fix filteredViewTotals to use per-transaction tags Fix filteredViewTotals and chartAggregations to use per-transaction tags Apr 29, 2026
Copilot AI requested a review from terryaney April 29, 2026 18:37
@terryaney terryaney marked this pull request as ready for review April 29, 2026 19:09
@terryaney terryaney merged commit 996655d into issue/88-merchant-category-display Apr 29, 2026
@terryaney terryaney deleted the copilot/fix-filtered-view-totals branch April 29, 2026 19:12
terryaney pushed a commit that referenced this pull request Jul 9, 2026
…ags (#13)

filteredViewTotals and chartAggregations to use per-transaction tags

Fixes the Python-side bug — changing by_merchant to use a composite (merchant, category, subcategory) key so same-named merchants with different categories appear as separate rows. This significantly reduces the practical impact of the JavaScript-side bug described here.

However, even after the PR fix, merchant.tags in the report data is still the union of all transaction tags within that merchant entry. When that union includes tags that not every transaction individually carries, filteredViewTotals misclassifies those transactions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

filteredViewTotals and chartAggregations use merchant-level aggregate tags instead of per-transaction tags

2 participants