POS & Billing Build

4 Stages · Flask + SQLite + JavaScript

Home › Apps › POS & Billing
🧾 4 stages · ~12–14 hours · In progress

Build a POS & billing app.
Shell → client → server → advanced.

A complete point-of-sale and billing app in four stages. Start with a static POS shell, add a client-side cart with localStorage, move the data to Flask + SQLite with a sales / sale_lines / payments schema and an atomic checkout, then grow the data layer: receipt printing, refunds, a Z-report, and hold/resume. The same four-stage arc as the CRM and Inventory builds — shell, client logic, backend, advanced data layer. Each stage adds exactly one layer and stops.

~12–14 hours Intermediate HTML · CSS · JavaScript · Python · Flask · SQLite 4 stages

What you end up with: a working POS app — a product grid, a live cart, an atomic checkout, a printable 80mm receipt, a sales history with refunds, and a Z-report for the end of the day. A Flask + SQLite backend with three POS tables (sales, sale_lines, payments) that reads products from the Inventory backend's shared database and writes stock_movements rows on every sale. The whole thing runs on your laptop with three commands.

What it is not: multi-register sync, hardware integration (cash drawer, card terminal), offline-first sync, or multi-store. Those are separate concept courses, not Stage 05.

🗺️ The four stages

Each stage adds exactly one layer. Stage 04 is the last one.

🧾
Stage 01
Interface
✅ Done

The static shell. A two-column layout: product grid on the left, cart on the right, totals at the bottom, a big Charge button, and an 80mm thermal receipt modal. No data, no logic, no JavaScript beyond a demo focus ring. Just the layout that Stage 02 brings to life.

2 hours · HTML · CSS
⚡
Stage 02
Interactions
✅ Done

Make it work. Tap a product → it's added to the cart. Adjust quantity → the line total and grand total update live. Remove → the line goes away. Charge → a payment modal with cash tendered and change due. Complete sale → the cart clears and a receipt shows. The cart persists in localStorage across reloads. Focus returns to the barcode input after every action. Tax rounding is documented and consistent.

3–4 hours · JavaScript · DOM · localStorage
🐍
Stage 03
Backend
✅ Done

Give it a server. Flask + SQLite. Three tables — sales, sale_lines, payments — with two foreign keys. POST /api/sales is the atomic checkout: insert the sale, insert the lines, insert the payment, write stock_movements rows, update products.quantity — all in one transaction. Reads products from the Inventory backend's shared database. Line prices are snapshotted at sale time. Sold products cannot be deleted (RESTRICT).

3–4 hours · Python · Flask · SQLite · transactions
📊
Stage 04 · FINAL (Upcoming)
Advanced
Planned

Make it real. Printable 80mm receipts via @media print. Sales history with date/payment filters and pagination. Refunds as reversal sales (the original stays immutable). A Z-report — total sales, tax collected, by payment method — computed with SQL aggregates. Hold/resume a sale via sales.status. Barcode focus management. Archived products (sold products can't be deleted, but can be hidden). This is the final stage.

3–4 hours · SQL · Flask · printing · reports

🗄️ The data model

Three POS tables, two foreign keys, one shared catalog.

products              ← shared with Inventory (read-only from POS)
suppliers             ← shared with Inventory (not used by POS)
stock_movements       ← shared with Inventory (POS writes reason='sold'/'refunded')

sales
├── id
├── cashier_id        ← text in Stage 03; auth later if you take the auth course
├── subtotal          ← cached (derived from lines, stored for speed)
├── tax_total         ← cached
├── discount_total    ← cached
├── grand_total       ← cached
├── status            ← 'open' | 'paid' | 'voided' | 'held'
├── created_at
└── paid_at

sale_lines            ← THE third table
├── id
├── sale_id     FK → sales.id     ON DELETE CASCADE
├── product_id  FK → products.id  ON DELETE RESTRICT
├── qty
├── unit_price        ← snapshot at time of sale
├── line_total        ← qty × unit_price
└── created_at

payments
├── id
├── sale_id     FK → sales.id     ON DELETE CASCADE
├── method      ← 'cash' | 'card' | 'other'
├── amount
└── created_at

Why RESTRICT on sale_lines.product_id

You cannot delete a product that has been sold. That would orphan the sale line and break every historical report. Products can be archived (Stage 04) but not deleted.

Why unit_price is snapshotted

If you raise a product's price tomorrow, today's sales must still report today's prices. The line stores what the customer was actually charged. This is accounting, not UI.

Why the totals are cached

Subtotal, tax, and grand total are derived from lines — but stored on the sale for fast history queries. The transaction guarantees they stay in sync with the lines.

Why POS reads Inventory's products

One catalog, two apps. Inventory owns it; POS consumes it. The POS writes stock_movements rows on every sale, so Inventory's audit log shows POS sales as reason='sold'.

📦 What you build, stage by stage

A concrete picture of the app at each point.

After Stage 01
A POS screen that looks right. Product grid on the left, sample cart on the right, totals showing real numbers, a big Charge button, a receipt modal. Nothing works yet — the numbers are hardcoded HTML.
After Stage 02
A working app. Tap a product → it's in the cart. Adjust qty → totals update. Remove → line gone. Charge → payment modal → complete → cart clears, receipt shows. Cart persists in localStorage. Still single-device, still no server.
After Stage 03
The same app, now talking to Flask. Sales persist in SQLite. The atomic checkout either fully succeeds (sale + lines + payment + stock movements + quantity updates) or fully rolls back. Products come from the shared Inventory database — sold items' stock drops as soon as the sale commits.
After Stage 04 — complete
The full POS. Printable 80mm receipts. Sales history with filters. Refunds as reversal sales (originals immutable). A Z-report for end-of-day reconciliation. Hold/resume. Barcode focus management. Archived products. The build is finished.

📥 Downloads

Available as each stage ships.

Stage demos
Stage 01 — interface demo
Static shell. Open in a browser.
Stage 02 — interactions demo
Coming with Deliverable 13.
Stage 03 — backend frontend + source
Coming with Deliverable 14.
Stage 04 — advanced frontend + source
Coming with Deliverable 15.

🔗 Related tracks — not part of this build

Where to go after Stage 04.

The POS build is four stages and it will be complete. The things that could be a Stage 05 — multi-register sync, hardware integration, offline-first, multi-store — are separate concept courses. They apply to any POS, not just this one.

🧱 Build something new

The four-stage arc is a template. Shell → client logic → backend → advanced data layer works for any app that has a "record of a transaction":

POS / billing
this build
Ticketing system
events, tickets, sales (third table)
Subscription billing
plans, customers, invoices (third table)
Booking system
rooms, bookings, payments (third table)

Same four stages. Same transaction discipline. Same foreign-key structure. The pattern is the reusable thing.

← Back to Apps
POS & Billing Build · 4 Stages · In progress