From ae4adf3246df4a0a028548cf5f34d84d4c637efa Mon Sep 17 00:00:00 2001 From: Dimitri DO BAIRRO Date: Fri, 3 May 2019 17:59:54 +0200 Subject: [PATCH 1/2] doc(README.md) overriding examples created --- README.md | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 100 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 30cdd70..b1710dc 100644 --- a/README.md +++ b/README.md @@ -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** @@ -223,6 +223,105 @@ invoice.getInvoice().toPDF().toFile('./invoice.pdf') }); ``` +### Customization + +All below globals attributes are totally customizable for the `.configure()` method or from `setters`: + +**From .configure()** + +The configure method override all default attributes presente [in this file](https://github.com/rimiti/invoice-it/blob/master/src/index.js). + +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: 'will.jameson@test.com' +}; + +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: 'contact@dimsolution.com', + 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: 'will.jameson@test.com' +}; + +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: 'contact@dimsolution.com', + 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: From 0a26ca117c4faa9fa378e934a41bdf5514a4f332 Mon Sep 17 00:00:00 2001 From: Dimitri DO BAIRRO Date: Sat, 4 May 2019 11:48:38 +0200 Subject: [PATCH 2/2] doc(README.md) spelling mistakes fixed --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b1710dc..6fd0ca0 100644 --- a/README.md +++ b/README.md @@ -225,13 +225,13 @@ invoice.getInvoice().toPDF().toFile('./invoice.pdf') ### Customization -All below globals attributes are totally customizable for the `.configure()` method or from `setters`: +All below globals attributes are totally customizable from the `.configure()` method or from `setters`: **From .configure()** -The configure method override all default attributes presente [in this file](https://github.com/rimiti/invoice-it/blob/master/src/index.js). +The configure method can override all default attributes presents [in this file](https://github.com/rimiti/invoice-it/blob/master/src/index.js). -Example: +Customization example: To generate and export in PDF an invoice with: - Logo url: http://example.com/logo.png