Skip to content

Project · JavaScript Programming (language in depth)

Project: Hisaab, a UPI statement analyser

Projectintermediate· about 7 hours· 7 steps

The brief

Build Hisaab, which turns a UPI statement export into answers: a Txn class with validation, a parser that reports bad lines instead of crashing, regular expressions for UPI IDs and reference numbers in bank SMS, spend per payee with Map, monthly totals in Indian time with Intl, saving with JSON, and downloading every page from an API with an async generator.

Why it matters

India makes over ten billion UPI payments a month, and budgeting apps, accounting tools and lending companies all analyse statements like this one. The real-world mess (broken lines, odd SMS formats, midnight payments that belong to the next month in India) is exactly what this level of the course prepares you for.

Skills you practise

  • classes, getters and static methods
  • throwing and catching errors
  • regular expressions
  • Map, Set and sorting entries
  • Intl.DateTimeFormat and NumberFormat with time zones
  • JSON round trips
  • async generators and for await

What you will have at the end

statement.js: Hisaab, a tested UPI statement analyser (parsing, validation, spend per payee, monthly totals, JSON storage and paged downloads).

How it is marked (rubric, 100 points)
Correct resultsEvery check passes, including broken lines, Windows line endings and the midnight bill.40
Robust designInvalid Txn objects cannot exist; errors are reported, not hidden; time zones handled explicitly.25
Right toolsClass with getter and static factory, Map for totals, regex with anchors, Intl formatters, async generator.20
ReadableClear names, money in paise until it is shown, formatters built once.15

0/7 steps done

Step 1 of 7

A transaction class

Txn has a constructor that checks its fields (a valid Date, type DEBIT or CREDIT, a whole number of paise above 0), a getter isDebit, a method signedPaise() (negative for debits) and a static Txn.fromCsvLine(line) that parses "date,type,amount,payee,upiId,utr".

A class keeps the data and the rules about it together. The constructor refuses bad data by throwing (TypeError for the wrong kind of value, RangeError for a value out of range), so an invalid Txn can never exist anywhere in the program. A getter reads like a property (txn.isDebit) but is computed.

A static method belongs to the class itself, not to one object: Txn.fromCsvLine(line) is a "factory" that builds a Txn from text. Convert rupees to paise with Math.round(Number(amount) * 100), because 450.10 × 100 is 45010.00000000001.

Run shows what your code prints. Check runs the step's tests. Ctrl+Enter checks too.