# A Simple Invoice Builder Copy and paste the codeblock below into a new note to try it out. ````md # A Simple Invoice Builder This example will produce and open an `HTML` file representing a simple invoice. From your default web browser, it can then be saved as a PDF. ## Choose the invoice to build ```js meld-build const invNumber = '22001'; ``` ```meld-build-toolbar run = Build the Invoice help = ``` ## The Data defined as JavaScript ```js meld-build // Define the customers const customers = [ { id: 100, name: 'Some Co', address: ['123 Some Rd', 'Some City'] }, { id: 101, name: 'Some Other Co', address: ['123 Some Other Rd', 'Some City'] }, ] // Define the invoices and their lines const invoices = [ { id: '22001', customer:100, date: '2022-12-01', status: 'open', work: [ { date: '2022-11-13', start: 7.00, end: 16.50, rate: 25.45, desc: 'I did the thing' }, { date: '2022-11-16', start: 10.75, end: 12.00, rate: 25.45, desc: 'I did the other thing' }, ] }, ] ``` ## The invoice template ```html
Invoice: {{inv.id}}
Date: {{inv.date}}
To: {{customer.name}}
{{.}}
{{/customer.address}}| Description | Quantity | Unit Price | Amount |
|---|---|---|---|
| {{date}} - {{desc}} | {{duration}} hrs | $ {{format_number rate}} | $ {{format_number total}} |
| Total: | $ {{format_number inv.total}} |