Skip to content

Latest commit

 

History

65 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TS INDUSTRIES — Invoice Generator (v2)

A static invoice/bill generator with cloud bill history and configurable saved items, built on the original PDF template. Zero server, zero monthly cost (Firebase Spark plan).

  • New Invoice — same form as the original app. Produces a byte-identical PDF (same template, same jsPDF 1.5.3, verified draw-for-draw).
  • Bill History — every printed invoice's metadata is saved to the cloud: dated, searchable, re-downloadable (identical PDF), duplicable as a new draft, deletable.
  • Items — a preset manager that replaces the old fixed list of 6 products. Add unlimited products with default GSM / HSN / Size / Rate; picking one on an invoice auto-fills those defaults.

Only PDFs are regenerated on demand — never stored — because generation is deterministic. The cloud only holds lightweight metadata + your item presets.


Files

File Purpose
index.html UI: 3 tabs + login gate. Loads all scripts in order.
template.js The base64 invoice background image (imgData).
invoice.js Data-driven PDF generation — line-for-line port of the original.
db.js Firebase init, owner login, CRUD for bills + itemPresets.
app.js All UI wiring (form, tabs, presets, history).
firebase-config.js Public Firebase project config (safe to commit).
.verify/parity.js Dev-only: proves byte-identical output vs the original.

Security model (important)

  • firebase-config.js is not a secret — it only identifies the project.
  • Data is protected by two things working together:
    1. Authentication — only the single owner account can sign in (arnav.kr.grv@gmail.com), by typing the password.
    2. Firestore security rules — locked so only that owner's UID may read or write. Anyone with the public config still gets denied.
  • The password unlocks history + saved items. Anyone can still "Skip & just print" to generate PDFs offline (print-only mode) — no data is exposed.

Firestore rules currently published

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if request.auth != null
        && request.auth.uid == "X83o8gVkVkdV3FVXocgLzCg8pz42";
    }
  }
}

To change the password later: Firebase Console → Authentication → Users → the owner → reset password. To add a second operator, create another user and add their UID to the rule with ||.


Firebase setup (already done, for reference)

Project ts-invoices (Spark / no-cost, region asia-south1 / Mumbai):

  1. Created the project (no billing, no credit card).
  2. Registered a Web App → copied config into firebase-config.js.
  3. Authentication → enabled Email/Password; created the owner user.
  4. Firestore Database → created in production mode → published the rules above. Collections (bills, itemPresets) are created automatically on first write.

Run locally

Because the scripts are loaded as files, use any static server (opening the file with file:// also works for jsPDF, but Firebase auth prefers http):

cd invoicegen-v2
python3 -m http.server 8000
# then open http://localhost:8000

Deploy to GitHub Pages (keeps your current URL style)

  1. Create/replace the repo contents with this folder.
  2. Commit & push to main.
  3. Repo → Settings → Pages → Source: main / root → Save.
  4. Site goes live at https://<user>.github.io/<repo>/.

No build step — it's plain static files.

Verify PDF parity (optional, dev only)

Requires bun (or Node). Confirms the refactor draws exactly what the original did:

bun .verify/parity.js
# -> ✅ IDENTICAL DRAW SEQUENCE — output is byte-for-byte the same.

Data model

bills (one per printed invoice)

{ invoiceNumber, invoiceDate, transport, vehicle, consignee,
  items: [{ name, gsm, hsn, size, quantity, bundles, rate }],
  carriageOutward, otherCharges, igst, sgst, cgst, lessAdvance,
  totals: { itemCost, totalQuantity, carriageOutward, otherCharges,
            igst, cgst, sgst, tax, extraCost, roundedTotal,
            lessAdvance, gross },
  createdAt }

itemPresets (the configurable product list)

{ name, defaultGsm, defaultHsn, defaultSize, defaultRate, active, createdAt }

About

A custom PDF invoice/BILL generator

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages