Skip to content

Capstone · Python Programming

Capstone: GST billing for a kirana shop

Capstoneexpert· about 8 hours· 11 steps

The brief

Build the billing core of a neighbourhood shop: exact money rounding, a product list loaded from CSV, CGST and SGST on every line, a cart that guards the stock, GST-style invoice numbers, checkout, a day-end report, a reorder list and a test that catches tax bugs.

Why it matters

Lakhs of Indian shops bill customers with small GST billing apps, and developers are paid to build, fix and extend them. Getting paise right, splitting GST into CGST and SGST, numbering invoices by financial year and never selling stock you do not have are the exact problems those developers solve. This is a project you can show and explain in an interview.

Skills you practise

  • decimal for money
  • csv and io.StringIO
  • dataclasses
  • custom exceptions
  • classes and generators
  • datetime and financial years
  • collections.Counter and defaultdict
  • sorting with key
  • writing tests that catch bugs

What you will have at the end

billing.py: a tested GST billing core for a small shop (catalogue loading, cart, invoice lines with CGST and SGST, round-off, financial-year invoice numbers, checkout, a day-end report and a reorder list), ready to show in an interview or extend into a real app.

How it is marked (rubric, 100 points)
Correct billsAll eleven checks pass: paise rounded half up, CGST and SGST equal halves, round-off right, stock never oversold.35
Robust codeBad rows, unknown items, bad quantities and empty carts raise BillingError with a clear message, and a failed action changes nothing.20
Good designDataclasses for records, a Cart class for state, generators for lines, small functions that reuse money() and gst_split().20
Tests that catch bugstest_gst_split() covers a normal rate, 0% and a half-paisa case, and fails for both broken versions.15
ExplainedYou can explain why floats are not used for rounding money, how CGST and SGST split, and how the financial year is worked out.10

0/11 steps done

Step 1 of 11

Money in paise

money(amount) returns the amount rounded to 2 decimal places with halves rounded up (money(2.675) is 2.68).

Floats are stored in binary, so 2.675 is really 2.67499999… and round(2.675, 2) gives 2.67. A bill must round a half paisa up, the way people expect. Decimal(str(amount)) keeps the number exactly as written, and quantize(Decimal("0.01"), rounding=ROUND_HALF_UP) rounds it to paise. Turn the result back into a float for the rest of the program.

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