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

invoice-it

2.0.0 • Public • Published

This package has been deprecated

Author message:

WARNING: This project has been renamed to @rimiti/invoice-it. Install using new-package-name instead.

invoice-it

Dependencies Dependencies Code Climate score Code Climate coverage Code Climate coverage Node.js version NPM version Build Status MIT License PRs Welcome

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

Install

$ npm install invoice-it --save

Features

  • Generate order / invoice
  • Export to HTML / PDF / Stream
  • Easy to use it
  • Robust implementation with good unit test coverage.

Demonstration

Usage

Importation

From import

import invoiceIt from 'invoice-it';

From require

const invoiceIt = require('invoice-it');

Order

To generate an order:

import invoiceIt from 'invoice-it';
 
  const recipient = {
    company_name: 'Receiver company',
    first_name: 'Will',
    last_name: 'Jameson',
    street_number: '20',
    street_name: 'Rue Victor Hugo',
    zip_code: '77340',
    city: 'Pontault-Combault',
    country: 'France',
    phone: '06 00 00 00 00',
    mail: 'will.jameson@test.com'
  };
 
  const emitter = {
    name: 'Dim Solution',
    street_number: '15',
    street_name: 'Rue Jean Jaures',
    zip_code: '75012',
    city: 'Paris',
    country: 'France',
    phone: '01 00 00 00 00',
    mail: 'contact@dimsolution.com',
    website: 'www.dimsolution.com'
  };
 
  const order = invoiceIt.create(recipient, emitter);

You can also use getter / setters like that

const order = invoiceIt.create();
 
order.recipient.company_name = 'Receiver company';
order.recipient.first_name = 'Will';
order.recipient.last_name = 'Jameson';
order.recipient.street_number = '20';
order.recipient.street_name = 'Rue Victor Hugo';
order.recipient.zip_code = '77340';
order.recipient.city = 'Pontault-Combault';
order.recipient.country = 'France';
order.recipient.phone = '06 00 00 00 00';
order.recipient.mail = 'will.jameson@test.com';
 
order.emitter.name = 'Dim Solution';
order.emitter.street_number = '15';
order.emitter.street_name = 'Rue Jean Jaures';
order.emitter.zip_code = '75012';
order.emitter.city = 'Paris';
order.emitter.country = 'France';
order.emitter.phone = '01 00 00 00 00';
order.emitter.mail = 'contact@dimsolution.com';
order.emitter.website = 'www.dimsolution.com';

Return order object

order.getOrder();

Return html order

order.getOrder().toHTML();

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

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

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

order.getOrder().toPDF().toFile('./order.pdf')
  .then(() => {
     console.log('PDF file created.');
  });

Invoice

To generate an invoice:

import invoiceIt from 'invoice-it';
 
  const recipient = {
    company_name: 'Receiver company',
    first_name: 'Will',
    last_name: 'Jameson',
    street_number: '20',
    street_name: 'Rue Victor Hugo',
    zip_code: '77340',
    city: 'Pontault-Combault',
    country: 'France',
    phone: '06 00 00 00 00',
    mail: 'will.jameson@test.com'
  };
 
  const emitter = {
    name: 'Dim Solution',
    street_number: '15',
    street_name: 'Rue Jean Jaures',
    zip_code: '75012',
    city: 'Paris',
    country: 'France',
    phone: '01 00 00 00 00',
    mail: 'contact@dimsolution.com',
    website: 'www.dimsolution.com'
  };
 
  const invoice = invoiceIt.create(recipient, emitter);

You can also use getter / setters like that

const invoice = invoiceIt.create();
 
invoice.recipient.company_name = 'Receiver company';
invoice.recipient.first_name = 'Will';
invoice.recipient.last_name = 'Jameson';
invoice.recipient.street_number = '20';
invoice.recipient.street_name = 'Rue Victor Hugo';
invoice.recipient.zip_code = '77340';
invoice.recipient.city = 'Pontault-Combault';
invoice.recipient.country = 'France';
invoice.recipient.phone = '06 00 00 00 00';
invoice.recipient.mail = 'will.jameson@test.com';
 
invoice.emitter.name = 'Dim Solution';
invoice.emitter.street_number = '15';
invoice.emitter.street_name = 'Rue Jean Jaures';
invoice.emitter.zip_code = '75012';
invoice.emitter.city = 'Paris';
invoice.emitter.country = 'France';
invoice.emitter.phone = '01 00 00 00 00';
invoice.emitter.mail = 'contact@dimsolution.com';
invoice.emitter.website = 'www.dimsolution.com';

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')

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

i18n

To add more language:

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

Scripts

Run using npm run

install

npm i invoice-it

Downloadsweekly downloads

21

version

2.0.0

license

MIT

repository

githubgithub

last publish

collaborators

  • avatar