Why (Not) Build Yet Another Finance App — Part 4: Credit Cards and Bills
A credit card bill looks like a list: this month's purchases, a total and a due date.
In our heads, it was a sum with a date filter.
This is Part 4 of the diary we started in Part 0. We have covered Open Finance, charging for the app and categorizing spending. At the end of Part 3, we promised to explain why a credit card bill is not just a list of purchases. Here it is.
Quick context: through Open Finance (Brazil's open banking), the bank sends card purchases as they happen. The bill itself (total, due date, payments) only arrives after it closes. In Brazil, buying in interest-free installments ("3x", "10x") is everyday behavior, so a large share of card entries are installments.
What we thought it was
- Add up the month's purchases
- Show the total with the due date
- Mark it paid when the money leaves the account
What it really was
The September purchase that is due in November
"This month's purchases" does not exist. There are the purchases of the cycle, from one closing date to the next. And the due date does not always fall in the same month as the closing date.
An example, on a card that closes on the 25th and is due on the 5th:
- 1Purchase on Sep 28. September's bill already closed on the 25th.
- 2It goes into the bill that closes on Oct 25.
- 3It is due on Nov 5. The 5th comes before the 25th, so the due date moves to the month after the closing.
Now add February, which has no 30th, and weekends and holidays, which push the real closing date around. Until July 2026, Snabber did not even let you set up a card that closes or is due on the 31st.
Through Open Finance, each purchase also comes with the bank's forecast of the month its bill will close. It is usually more accurate than our own calculation, so it wins. But not always:
- One issuer sometimes sent the forecast one cycle late. The math produced a due date before the purchase itself. Now there is a guardrail: no bill is ever due before the purchase.
- Another sent "0001-01" when it did not know. The sync accepted it as a valid month, and five transactions ended up on a bill due in 1901.
The bill only exists after it closes
While a bill is open, nobody says which bill each purchase belongs to. The bank only tags that after the closing date. Until then, Snabber estimates it from the due date calculated above.
The catch is that the sync only updates the transactions that come back in that fetch. If the bill closed after the purchase left the sync window, the purchase never learned which bill it belonged to. It stayed stuck on the estimate forever.
The fix was a sweep that revisits the last 60 days of card activity and links each purchase to its real bill. It has one rule that cannot break: it only updates, it never inserts. When you reconnect a bank, it may resend the same purchases under new IDs. A sweep that inserted rows would duplicate months of history. (Back in August, reconnecting already left bills empty. We did not want the opposite problem.)
An installment from a purchase made eight months ago
In October, a user asked Snabber's AI about their installment purchases. Six questions in a row. All six times, it searched the descriptions for the text "1/10", found nothing and concluded there were no installments at all. In one answer, it suggested the user add them to the app manually.
The data was there: 14 installment entries, each with the "3 of 10" the bank sends. But each installment was a loose row. Nothing grouped the installments of the same purchase or projected the ones still to come.
Grouping sounds easy: same card, same purchase date, same number of installments. In practice:
- 8% of the groups had identical purchases on the same day. Two 3-installment purchases on the same day, on the same card, merged into one. The amount had to become part of the key.
- The purchase total almost never arrives. Only on 48 of 2,704 rows, all from a single institution. The projection starts from a single installment: if installment 3 landed in October, installment 7 lands in February.
- Sometimes two installments land on the same bill. 1/2 and 2/2 together. You cannot assume "one per month" for what has already posted.
- Some issuers send future installments as transactions. If Snabber also projected those, it would count each one twice.
And a purchase that stops showing up (paid off early, refunded, card disconnected) leaves the projection instead of inventing more installments. Since November 3, the estimated bill is the purchases plus the projected installments.
A bill is not a list of purchases. It is a promise to pay, with a date attached.
The refund that looked like a double charge
On November 3, a user wrote in thinking Snabber had charged their subscription twice. It had not. It was the refund.
On a card, money flows the opposite way from a checking account: a purchase increases what you owe, a refund decreases it. Through Open Finance, card credits (refunds, bill payments, returned tax, discounts) arrived with a negative amount. The sync only adjusted the sign of purchases. The refund showed up as one more expense.
The code fix shipped the same day. So did the history fix: 3,384 entries from 192 users, in 56 seconds, with a run ID to undo it row by row if anything went wrong. Before running it, a dry run showed 15 "CASHBACK PAYMENT" entries that would have been treated as bill payments. We fixed the rule first.
The next day, the exception showed up. Our Open Finance provider's test bank sends purchases as negative credits. The fix turned test purchases into income. The real banks we checked do not do this, but the sync now asks whether a connection is a test one before deciding the sign.
A paid bill comes out of somewhere
In Part 3, we explained why paying the bill cannot count as spending: the purchases were already counted, one by one, on the card. But it has to count somewhere else. To answer "how much will I have in my account on the 10th?", Snabber needs to know that the R$ 2,300 bill comes out of the checking account on the 5th.
Since November, each card can have a paying account, and the bill shows up in that account's balance forecast. When we turned this on, only 4 of 600 cards had it filled in.
Our own card, owing R$ 355,000
Many people use a card without connecting it to the bank, entering purchases by hand or from a spreadsheet. On October 22, the balance of these manual cards changed from "the last balance you typed" to "a starting point minus the purchases since then". It was the right change. The problem was the starting point.
The change went to production without the transition step, which would have saved the old balance as the starting point. Cards with years of imported purchases started adding up everything. One of our own manual cards woke up owing R$ 355,000.
A tool in the admin panel saved the old balance as the starting point, card by card. The lesson stuck: a "before deploy" step that does not block the deploy is not a step. It is a suggestion.
Same card, two people
The primary cardholder and the additional cardholder pay the same bill. But the couple wants to know who spent what. The bank sends the card's last four digits on almost every purchase (around 98%), so it looked like a simple group-by.
Except 264 of 314 connected cards have more than one set of last digits, and not all of them are additional cards. Some banks issue a virtual card per store. Since November 4, you give each set of digits a name, and digits with the same name become the same person. (Sharing finances with someone is the topic of the next part.)
Some of the 57 commits with "fatura" (Portuguese for "bill") in the message, April to November 2026. Our commits are in Portuguese; the highlighted one reads "card: credit from Pluggy (refund, bill payment) comes in positive".
What we did
- ✓A due date for every purchase, calculated from the cycle, with the bank's forecast first and a guardrail: no bill is due before the purchase.
- ✓A sweep that links older purchases to the real bill, without ever inserting a new row.
- ✓Installments grouped by purchase, with the remaining ones projected on the bill and answered by the AI.
- ✓Refunds and payments coming in as credits, with a history fix that can be undone.
- ✓A paying account for each card, so the bill comes out of the right balance in the forecast.
- ✓Spending by card digits, to separate the primary cardholder from the additional one.
What we still haven't solved
The same card can arrive through two connections. One customer has to connect both the card issuer and the bank, because each brings accounts the other does not. The card shows up twice, and today there is no way to stop syncing just one account from an active connection. In production, we found four more similar pairs.
A refund now reduces the bill, but in the category report it still shows up as "income" for that category instead of lowering its spending.
And when the bank has not sent the bill yet, the forecast is the purchases plus the installments. Someone who knows December's bill will be bigger has no way to tell Snabber. Yet.
If you are going to show credit card bills
Store the due date of every purchase, not just the purchase date. That is what decides which bill, and which month, the money leaves in.
And handle each entry's sign by type and by institution, never with a single rule. When you need to fix history, have the undo ready before you run it.
Want to see how it turned out? Create your Snabber account and try the free plan.
In the next part: a couple, a household account, two cards and the question "whose is this?".
