Guide · 26

Quotes and invoices

Generates a quote or invoice (Markdown or HTML) from JSON: lines, discounts, VAT, currency-rounded total, due date.

In one line

node scripts/26-quote-invoice.mjs mon-devis.json --format html --out devis.html

What it's for

A quote or invoice gets rebuilt every time in a word processor, with the risk of a calculation error or a forgotten VAT. This script produces the document from a small JSON file: lines, discounts, VAT, total, validity or due date. You keep the data (the JSON) and generate the layout whenever you like.

Before you start

  • A JSON file describing the document (see samples/devis.json).
  • The currency (XOF, EUR…): amounts are rounded to its decimals (0 for the CFA franc, 2 for the euro).

Step by step

  1. Copy the example and adapt seller, client and lines:
    cp samples/devis.json my-quote.json
    
  2. Generate a Markdown document, or an HTML page you can print to PDF from the browser:
    node scripts/26-quote-invoice.mjs my-quote.json --format html --out quote.html
    
  3. For an invoice, set "type": "facture": the heading becomes "FACTURE" and the validity date becomes a due date.

Reading the output

Each line = quantity × price, minus the discount in %. The subtotal is the sum of lines; VAT applies to the subtotal; the amount due is their sum. The deadline is date + dueDays.

Automating it

Connect it to your entry tool: one line per service in a spreadsheet → JSON → document. Numbering (number) stays your responsibility: keep an unbroken sequence.

Pitfalls

  • Mandatory legal mentions (tax ID, payment terms) depend on your country: add them in notes and seller.
  • The script calculates, it does not store anything: archive the documents you issue.
  • The document text itself is in French.

This guide goes with a free script (MIT license). Try it on a copy of your data first.