Takes Wave API data and outputs custom HTML and PDF.
First, install in your project:
npm install --save wave-custom-invoice
Next, you need to create an application in Wave, and generate a token.
You will also need a Mustache template. An example is provided in template.mustache
.
In your project, require wave-custom-invoice
and pass it a config object.
const wave = require('wave-custom-invoice');
const waveConfig = {
token: 'your_wave_application_token',
template: 'template.mustache',
htmlDirectory: "./output/html",
pdfDirectory: "./output/pdf",
generateHTML: true,
generatePDF: true,
pdfConfig: {
base: 'http://localhost:5000', // You need to serve the HTML using a web server; I suggest PHP's built-in web server
format: "Letter",
},
locale: 'fr-ca',
currencyFormat: '0,0.00 $', // Uses Numeral.js
dateFormat: 'YYYY.MM.DD', // Uses Moment.js
};
wave(waveConfig);