npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pk-invoice

v1.0.0

Published

Make professional invoices in Node.js or the browser: line discounts, sales tax by rate, shipping, advance payments, lakh/crore formatting, amount in words (English + Urdu), and a print-ready A4 HTML template for PDF. Plus a CLI.

Readme

🧾 pk-invoice

Make professional invoices in seconds, in Node.js, the browser, or from the command line. Line discounts, sales tax by rate, shipping, advance payments, lakh/crore formatting, amount in words in English and Urdu, and a clean A4 template that prints straight to PDF.

Tests npm License

🧮 Free online invoice maker: no sign-up, nothing to install · 📖 Full guide


Features

  • Correct maths: per-item discount, invoice discount spread across items before tax, sales tax at different rates (18%, 16%, 0%...), shipping, amount already paid and balance due. Every amount is rounded properly to 2 decimals.
  • Pakistani formatting: Rs 4,72,680.29, and the total in words: Four Lakh Seventy Two Thousand Six Hundred Eighty Rupees and Twenty Nine Paisa Only, plus چار لاکھ بہتر ہزار چھ سو اسی روپے اور انتیس پیسے صرف
  • Sales tax invoice fields: seller and buyer NTN and STRN, tax rate and tax amount per line, value before and after tax. It becomes a "Sales Tax Invoice" automatically when tax is charged and the seller has an NTN/STRN.
  • Print-ready template: A4, your logo and colour, payment details (bank, IBAN), notes, terms and signature line. Open it in a browser and save as PDF.
  • Safe: every field is escaped, so text from a form can't inject code into the invoice.
  • Other currencies too (USD, EUR, GBP, AED, SAR...), with English words.

Quick start (command line)

npx pk-invoice --example > invoice.json     # a sample invoice to edit
npx pk-invoice invoice.json -o invoice.html # make the invoice

Open invoice.html in your browser and choose Print → Save as PDF.

npx pk-invoice invoice.json --totals        # just the numbers, as JSON
npx pk-invoice --next INV-2026-0042         # → INV-2026-0043

Library

npm install pk-invoice
import { calculateInvoice, renderInvoiceHTML } from 'pk-invoice';

const invoice = {
  number: 'INV-2026-0042',
  date: '2026-11-24',
  dueDate: '2026-12-08',
  taxRate: 18,                                  // default sales tax for items
  seller: { name: 'Crescent Garments', address: 'Faisalabad', ntn: '1234567-8', strn: '32-77-8761-234-56' },
  buyer:  { name: 'Ahmed Textiles', address: 'Karachi' },
  items: [
    { description: 'Cotton T-shirt', quantity: 200, unit: 'pcs', unitPrice: 850 },
    { description: 'Denim jeans', quantity: 120, unit: 'pcs', unitPrice: 1950, discount: 5 },
    { description: 'Printing charges', unitPrice: 15000, taxRate: 0 },
  ],
  discount: { type: 'amount', value: 10000 },   // or { type: 'percent', value: 5 }
  shipping: 6500,
  amountPaid: 150000,
  payment: { bank: 'Meezan Bank', accountTitle: 'Crescent Garments', iban: 'PK36 SCBL 0000 0011 2345 6702' },
  notes: 'Thank you for your order.',
};

const totals = calculateInvoice(invoice);
// totals.total      → 472680.29
// totals.balanceDue → 322680.29
// totals.taxes      → [{ rate: 18, taxable: 382668.28, tax: 68880.29 }]
// totals.words      → { english: 'Four Lakh Seventy Two Thousand ...', urdu: 'چار لاکھ بہتر ہزار ...' }

const html = renderInvoiceHTML(invoice);        // a complete HTML page

In the browser, put the HTML in an iframe or a new window and call print() to save a PDF. On a server, any HTML-to-PDF tool (Puppeteer, Playwright, wkhtmltopdf) turns it into a PDF file.

How the totals are calculated

  1. Line amount = quantity × rate − line discount %
  2. The invoice discount is shared between lines in proportion to their amounts, so tax is charged on the discounted value
  3. Tax = line amount after discount × the line's tax rate, grouped by rate
  4. Total = amount after discounts + tax + delivery charges
  5. Balance due = total − amount paid

Invoice fields

| Field | Description | |---|---| | number, date, dueDate, reference | Dates as YYYY-MM-DD | | currency | PKR (default), USD, EUR, GBP, AED, SAR... | | taxRate, taxLabel | Default tax % for items, and its name (default "Sales Tax") | | seller, buyer | name, address, phone, email, ntn, strn; seller.logo (data URL or https) | | items[] | description, quantity, unit, unitPrice, discount (%), taxRate (%) | | discount | { type: 'percent' \| 'amount', value } on the whole invoice | | shipping, amountPaid | Delivery charges (not taxed), advance received | | payment | bank, accountTitle, accountNumber, iban, other | | notes, terms, footer, title, accentColor | Text and look |

Note on tax

pk-invoice calculates and prints the fields a sales tax invoice usually needs, but it does not connect to FBR's digital invoicing system, and it is not tax advice. Check the current rules for your business with FBR or your tax adviser.

License

MIT. Made by ZexCart. More free tools: zexcart.site/dev-tools. Built on pakistan-toolkit and urdu-toolkit.

If it helps your business, please ⭐ star the repo.