Portfolio

Engineering notes

Teaching my expense app to read Malaysian receipts, mostly without AI

How ManaDuit finds the total, merchant and date on a Malaysian receipt with a scoring parser instead of a language model, and why it would rather ask than guess.

By Vincent Teo · Updated

Where my money went

When I started my part-time job I finally had money coming in, and almost immediately I had no idea where it was going. Some of it was cash. Some went through TnG eWallet, some through the bank app, some through other wallets. Every one of them has a transaction history, but nobody opens five apps to add up a month.

There are plenty of expense trackers out there. I built my own anyway, partly to see if I could, and partly because I wanted my own dashboard, my own categories and my own rules. That became ManaDuit, which was called VinExpenses at first.

The feature I spent the longest on is receipt scanning: take a photo or drop in a PDF, and the app fills in the merchant, the total and the date.

Why a receipt is harder than it looks

Pick up any receipt near you and count the numbers on it. Subtotal. Service charge. SST. Rounding. Total. Cash. Change. Maybe points earned. The total is one of seven or eight amounts, and it is usually not the biggest one, because the RM50 note you paid with is printed there too.

Malaysian receipts add their own flavour. One shop prints "Total", the next prints "Jumlah", an e-wallet receipt says "Anda bayar", and a Chinese restaurant prints "总计". Dates come as Mac, Ogos and Disember. Some online receipts show a USD price beside the ringgit one.

Scoring instead of guessing

The obvious move today is to send the photo to an AI model and ask for the total. I did not want that as the default. It costs money on every scan, it is slower, and when it is wrong you cannot ask it why.

So the parser does something more boring. After OCR turns the photo into text, every amount on the receipt gets a score based on the words beside it, or on the line above it, because e-mailed receipts love to put "TOTAL" on one line and the amount on the next. "Grand total", "Jumlah besar" or "总计" scores highest. A plain "Total" or "Jumlah" scores a bit lower. "Subtotal" and "Jumlah kecil" get a negative score, and so do tax lines and discounts. A price in another currency takes a penalty.

Then come two checks I am quite happy with. If the same amount appears under more than one total-like label, it gets a bonus. And if subtotal plus tax and fees minus discounts adds up to a candidate, that candidate gets another bonus, because a receipt is basically a small maths problem that has already been solved for you.

The merchant works the same way: lines near the top, in capital letters, ending in "Sdn Bhd", or matching the web address printed on the receipt score higher.

When it is not sure, it asks

Every result is marked high, medium or low confidence, based on how strong the winning score is and how far ahead it is of the runner-up. On low confidence the app fills in nothing. It shows the top few amounts as buttons and you tap the right one.

That was a deliberate choice. In a money app, a wrong number that looks right is worse than a question. You will not notice RM12.50 saved as RM125.00 until your month looks strange.

The first version had an optional AI backup for the receipts the rules could not settle. When I rebuilt the app I left it out, so today the rules do all the work and the app asks you when they are unsure. PDFs that already contain text never leave your phone at all.

Does it actually work?

I keep 8 real receipts, with the personal details removed, as tests. For each one the parser has to return the exact amount, merchant and date with high confidence, and all 8 pass. The whole project has about 950 automated tests, and a failing one blocks the deploy.

I should be straight about what that proves. Eight receipts tell me the parser keeps working on formats it has already seen. They do not tell me how often it is right on a receipt from a shop it has never met. I do not have that number yet, and I am not going to make one up.

And a small confession: I mostly still type my own expenses in by hand. Old habit. It was my siblings and friends who started using the scanner properly, and they are the ones who told me it is useful and usually right. I am taking that as a sign I should use my own feature more.

What I would do next

Collect 30 to 50 labelled receipts and publish a real hit rate for amount, merchant and date. Add a demo account, because nobody wants to sign up just to look around. And the app only handles ringgit for now.

The idea and the backend are my own work, and I drafted the screens myself. I used an AI assistant to tighten things up: proper fallbacks, hunting down bugs, checking the endpoints, and making my rough UI look better.

You can try the scanner yourself at manaduit.com.

Analytics cookies

I'd like to use Google Analytics to see which pages are useful. It sets cookies and is off unless you accept. Privacy policy