node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

invoice-bill

invoice-bill NPM version Build Status Coverage Status

Invoice bill manager.
Create your checkout invoice-bill, add item(s) details,
and export them in HTML and/or PDF format(s). also the rendering is based a JADE template file so you can use/edit your template and make your bill with your template.

Installation

$ npm install --save invoice-bill

Docs

Docs available here

Usage

const InvoiceBill = require('invoice-bill');
const sample = new InvoiceBill({
  billIDGenerator: {preFlightValue: 1, mode: 'padding'},
  currency: 'MYR',
  from: {issuer: 'Amin Aghabeiki'},
  to: 'Some body',
  logo: logo, // Any base64 encoded image.
});
sample.newRecords({itemName: 'test1', itemBasePrice: 10});
sample.newRecords({itemName: 'test2', itemBasePrice: 5, itemCount: 2, discount: 5});
const test = sample.renderToHTML();
require('fs').writeFileSync('test.html', test);
sample.renderPDF(__dirname, {format: 'Letter', orientation: 'landscape'})
  .then((filePath) => {
    console.log(`PDF file generated @ ${filePath}`);// eslint-disable-line no-console
  })
  .catch((err) => {
    console.log(err);
  });
 

And also working example is available in

options

InvoiceBill constractor options: docs

  • billIDGenerator BillIDGeneratorConfig
  • from Company
  • to string
  • currency string
  • templatePath string The JADE template path used for rendering the Bill ,
  • logo string should be in base64 image format
  • title title

renderPDF options: docs

  • outputPathDIR string Output path for storing PDF files.
  • options object The Rendering options.
  • fileName string The filename, if not pass a name with title and a time stamp will be created.

Note:

For PDf rendering the module html-pdf used,
and the rendering options is available here.

Running the tests

`npm test`

Authors

  • Amin Aghabeiki - Initial work

License

This project is licensed under the MIT License - see the LICENSE.md file for details