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 🙏

© 2024 – Pkg Stats / Ryan Hefner

pdf-invoice-generator

v1.0.7

Published

Order and invoice generator

Downloads

553

Readme

invoice-generator

Generate invoices and export them easily. If you want some examples, check tests.

Install

$ npm install invoice-generator --save

Features

  • Generate invoice
  • Export to HTML / PDF / Stream
  • Easy to use it

Usage

Importation

From import

import invoiceGenerator from 'invoice-generator';

From require

const invoiceGenerator = require('invoice-generator');

If you want to export your invoice in PDF, you must install the html-pdf (v2.2.0) peer dependence

$ npm i -S [email protected]

Invoice

To generate an invoice:

const invoiceGenerator = require('invoice-generator');

invoiceGenerator.configure({
  global: {
    logo:"https://vehiclesolutions.com.au/wp-content/uploads/2017/03/Vehicle-Solutions-logo.png",
    invoice_template: `${__dirname}/static/invoice.pug`,
    date: new Date(),
    date_format: "YY/MM/DD",
    lang: "en"
  }
});

const invoice = invoiceGenerator.create();

invoice.recipient = {
  title: "Ms",
  first_name: "Anne",
  last_name: "Haworth",
  street1: "3/288 Glen Osmond Road",
  street2: "FULLARTON SA 5063"
};
invoice.statement_conclusion = {
  Employee: "1409",
  "Payroll Id": "001409",
  Phone: "8338 4427",
  Email: "[email protected]"
};
invoice.statement_heading = {
  subject: "Activity Statement",
  subtitle: "Salary Packaging Statement for the period FBT year to date"
};
invoice.article_headers = [
  "Name",
  "Date",
  "Ref",
  "Inst#",
  "Description",
  "Debit",
  "Credit",
  "Balance"
];
invoice.articles = [
  [
    "Payroll Deduction",
    "24/08/2017",
    "144102894",
    "1",
    "Deduction",
    "525.20",
    "",
    "526.21 Cr"
  ]
];

Return invoice object

invoice.getInvoice();

Return html invoice

invoice.getInvoice().toHTML();

Save html invoice into file (default filepath: 'invoice.html')

invoice.getInvoice().toHTML().toFile('./invoice.html')
  .then(() => {
      console.log('HTML file created.');
  });

Save html invoice into file (default filepath: 'invoice.pdf')

const options = {
  timeout: "90000",
  border: {
    top: "10px",
    right: "10px",
    bottom: "10px",
    left: "10px"
  },
  header: {
    height: "10mm",
    contents:
      '<div style="padding:5px 10px 5px 10px;"><div style="float:left;">Activity Statement</div><div style="float:right;"><span style="color:#444;font-size: 50%;">Print No.: ' +
      require("uuid/v4")() +
      "</span></div></div>"
  },
  footer: {
    height: "10mm",
    contents: {
      default:
        '<div style="padding:5px 10px 5px 10px;"><div style="float:left;"><span>Page {{page}}</span> of <span>{{pages}}</span>  <span style="color:#444;font-size: 50%;">Generated ' +
        new Date() +
        "</span></div></div>"
    }
  }
};

invoice.getInvoice().toPDF(options).toFile('./invoice.pdf')
  .then(() => {
      console.log('PDF file created.');
  });

i18n

To add more language:

const invoiceGenerator = require('invoice-generator');

invoiceIt.configure({
  language: {
    locales: ['en', 'pl'],
    directory: `${__dirname}/path/to/locales`,
    defaultLocale: 'en'
  }
});

Scripts

Run using npm run command.

clean - remove coverage data, Jest cache and transpiled files,
test - run tests with coverage,
test:watch - interactive watch mode to automatically re-run tests,
build - compile source files,
build:watch - interactive watch mode, compile sources on change.