mirror of
https://github.com/andwati/ledga.git
synced 2026-10-19 03:42:54 +00:00
Two parser bugs around Fuliza auto-pay that produced wrong balance and
phantom-outstanding alerts:
1. BALANCE_REGEX required the literal "Ksh" before the amount, but the
full-clear auto-pay SMS ends "Your M-PESA balance is 8581.08." with
no Ksh prefix. Balance was lost → stored as 0 → Home's
getLatestTransactionWithBalance filter (balance > 0) fell back to a
stale older transaction. Made the Ksh optional.
2. parseFulizaAutoPay was stuffing the *available Fuliza limit* into
fulizaOutstanding. Those are opposites (available = ceiling - owed).
After a full clear that meant FulizaRule saw the full 14k limit and
raised "You owe Ksh 14,000" — incorrect. Now:
- full clear -> fulizaOutstanding = 0 (rule correctly bails)
- partial -> fulizaOutstanding = null (rule defers to the
previous Fuliza tx;
avoids reporting the
available-limit value)
Reparse all transactions
- New "Re-parse ALL transactions" entry in You → Data. Walks every
stored row through MpesaSmsParser and updates parser-derived fields
in place, preserving user fields (categoryId, accountId, note, id).
- Needed because the broken regex above silently corrupted historical
rows on import; this is the no-data-loss path back to correctness.