Skip to content

Commit

Permalink
Merge pull request #35 from rimiti/update-documentation-examples
Browse files Browse the repository at this point in the history
Overriding examples created
  • Loading branch information
rimiti authored May 4, 2019
2 parents ce0aa58 + 0a26ca1 commit fbfd2cb
Showing 1 changed file with 100 additions and 1 deletion.
101 changes: 100 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import invoiceIt from '@rimiti/invoice-it';

**From require**
```javascript
const invoiceIt = require('@rimiti/invoice-it');
const invoiceIt = require('@rimiti/invoice-it').default;
```

**If you want to export your invoice in PDF, you must install the *html-pdf (v2.2.0)* peer dependence**
Expand Down Expand Up @@ -223,6 +223,105 @@ invoice.getInvoice().toPDF().toFile('./invoice.pdf')
});
```

### Customization

All below globals attributes are totally customizable from the `.configure()` method or from `setters`:

**From .configure()**

The configure method can override all default attributes presents [in this file](https://github.com/rimiti/invoice-it/blob/master/src/index.js).

Customization example:

To generate and export in PDF an invoice with:
- Logo url: http://example.com/logo.png
- Date format: YYYY-MM-DD
- Your invoice pattern: INVOICE-1901_00001
- Invoice note: It's my custom node!

```js
import invoiceIt from '@rimiti/invoice-it';

invoiceIt.configure({
global: {
logo: 'http://example.com/logo.png',
invoice_reference_pattern: '$prefix{INVOICE}$date{YYMM}$separator{_}$id{00000}',
invoice_note: 'It\'s my custom node!',
date_format: 'YYYY-MM-DD',
},
});

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: '[email protected]'
};

const emitter = {
name: 'Dim Solution',
street_number: '73',
street_name: 'Rue Jean Jaures',
zip_code: '75012',
city: 'Paris',
country: 'France',
phone: '01 00 00 00 00',
mail: '[email protected]',
website: 'www.dimsolution.com'
};

const invoice = invoiceIt.create(recipient, emitter);

invoice.id = 1;
order.getInvoice().toPDF().toFile();
```

**From setters**

```js
import invoiceIt from '@rimiti/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: '[email protected]'
};

const emitter = {
name: 'Dim Solution',
street_number: '73',
street_name: 'Rue Jean Jaures',
zip_code: '75012',
city: 'Paris',
country: 'France',
phone: '01 00 00 00 00',
mail: '[email protected]',
website: 'www.dimsolution.com'
};

const invoice = invoiceIt.create(recipient, emitter);

invoice.global.logo = 'http://example.com/logo.png';
invoice.global.invoice_reference_pattern = '$prefix{INVOICE}$date{YYMM}$separator{_}$id{00000}';
invoice.global.invoice_note = 'It\'s my custom node!';
invoice.global.date_format = 'YYYY-MM-DD';
invoice.id = 1;
order.getInvoice().toPDF().toFile();
```

### i18n

To add more language:
Expand Down

0 comments on commit fbfd2cb

Please sign in to comment.