Reclassify debt transfers and MACH/Servipag card payments as internal

Debt repayments (TRASPASO A/DE DEUDA, TRASPASO POR CIERRE DE CUENTA) are
payments against an international credit card — the purchases already
happened on that card, only fees/interest are new costs. Reclassify from
expense → card_payment (internal) so they show in Cycles, not Spending.

Same for MACH Comercios→Servipag and PAGO EN SERVIPAG.COM* which are
Rappi card payments routed through Servipag, not utility bills.
This commit is contained in:
Kavi 2026-06-02 04:23:43 -04:00
parent 948736c79a
commit fae5af446f
1 changed files with 13 additions and 0 deletions

View File

@ -130,6 +130,19 @@
if (s.account_last4) ACCT_LAST4.add(s.account_last4); if (s.account_last4) ACCT_LAST4.add(s.account_last4);
} }
} }
// Reclassify transactions that the raw parser tagged as 'expense' but are
// really internal movements — debt repayments to cards (the purchases already
// happened on those cards; only interest/fees are new costs) and known
// card-payment intermediaries (MACH→Servipag for Rappi card, etc.)
const DEBT_RE = /TRASPASO\s+(A\s+DEUDA|POR\s+CIERRE\s+DE\s+CUENTA|DE\s+DEUDA\b|DEUDA\s*(NACIONAL|INTERNACIONAL)?$)/i;
const CPAY_RE = /PAGO\s+EN\s+SERVIPAG\.COM|COMPRA\s+MACH\s+COMERCIOS.*SERVIPAG/i;
TX = TX.map(t => {
if (t.flow_type !== 'expense') return t;
if (DEBT_RE.test(t.description) || CPAY_RE.test(t.description)) {
return { ...t, flow_type: 'card_payment', internal: true };
}
return t;
});
MONTHS = [...new Set(TX.map(t => t.ym))].sort(); MONTHS = [...new Set(TX.map(t => t.ym))].sort();
BANKS = [...new Set(TX.map(t => t.bank))].sort(); BANKS = [...new Set(TX.map(t => t.bank))].sort();
return { months: MONTHS, banks: BANKS, totals: RAW.real_totals }; return { months: MONTHS, banks: BANKS, totals: RAW.real_totals };