Skip to content

Commit

Permalink
Review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
KJanikCC committed Jun 10, 2019
1 parent a8dd8c9 commit 175b466
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ typings/
.env

.idea/
.DS_store
dist/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,11 @@ invoice.getInvoice().toPDF().toFile('./invoice.pdf')

Add custom fields to invoice
```js
let paymentId = {
const paymentId = {
key: 'invoice_header_paymentId_value',
value: paymentRef
};
let phrases = ['invoice_header_payment_reference', paymentId];
const phrases = ['invoice_header_payment_reference', paymentId];
invoice.getInvoice(phrases).toPDF()
```

Expand Down
3 changes: 2 additions & 1 deletion __tests__/invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ jest.setTimeout(90000);
describe('Invoice', () => {
const htmlPathfile = './invoice.html';
const pdfPathfile = './invoice.pdf';
const pdfPathfileAdd = './invoiceAdd.pdf';

const recipient = {
company_name: 'Receiver company',
Expand Down Expand Up @@ -141,7 +142,7 @@ describe('Invoice', () => {
invoice.getInvoice(['invoice_header_payment_reference', {
key: 'invoice_header_paymentId_value',
value: 'paymentRef',
}]).toPDF().toFile(pdfPathfile).then(() => done());
}]).toPDF().toFile(pdfPathfileAdd).then(() => done());
});

it('Export to PDF file', (done) => {
Expand Down
3 changes: 2 additions & 1 deletion __tests__/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ jest.setTimeout(90000);
describe('Order', () => {
const htmlPathfile = './order.html';
const pdfPathfile = './order.pdf';
const pdfPathfileAdd = './orderAdd.pdf';

const recipient = {
company_name: 'Receiver company',
Expand Down Expand Up @@ -140,7 +141,7 @@ describe('Order', () => {
order.getOrder(['invoice_header_payment_reference', {
key: 'invoice_header_paymentId_value',
value: 'paymentRef',
}]).toPDF().toFile(pdfPathfile).then(() => done());
}]).toPDF().toFile(pdfPathfileAdd).then(() => done());
});

it('Export to PDF file', (done) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"clean": "rm -rf coverage dist tmp invoice.pdf invoice.html order.pdf order.html",
"clean": "rm -rf coverage dist tmp invoice.pdf invoice.html order.pdf orderAdd.pdf order.html invoiceAdd.pdf",
"pretest": "npm run lint",
"test": "jest --coverage",
"test:watch": "jest --watch",
Expand Down
14 changes: 12 additions & 2 deletions src/classes/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,17 +318,22 @@ export default class Generator extends Common {
return compiled(keys);
}

/**
* @description Prepare phrases from translations
* @param type
*/
getPhrases(type) {
return {
header_title: i18n.__({phrase: `${type}_header_title`, locale: this.lang}),
header_subject: i18n.__({phrase: `${type}_header_subject`, locale: this.lang}),
header_reference: i18n.__({phrase: `${type}_header_reference`, locale: this.lang}),
invoice_header_date: i18n.__({phrase: `${type}_header_date`, locale: this.lang}),
header_date: i18n.__({phrase: `${type}_header_date`, locale: this.lang}),
};
}

/**
* @description Return invoice translation keys object
* @param params
* @returns {*}
*/
getInvoice(params = []) {
Expand Down Expand Up @@ -358,6 +363,7 @@ export default class Generator extends Common {

/**
* @description Return order translation keys object
* @param params
* @returns {*}
*/
getOrder(params = []) {
Expand All @@ -366,7 +372,7 @@ export default class Generator extends Common {
order_header_subject: this.getPhrases('order').header_subject,
order_header_reference: this.getPhrases('order').header_reference,
order_header_reference_value: this.getReferenceFromPattern('order'),
order_header_date: this.getPhrases('order').invoice_header_date,
order_header_date: this.getPhrases('order').header_date,
table_note_content: this.order_note,
note: (note) => ((note) ? this.order_note = note : this.order_note),
filename: 'order',
Expand Down Expand Up @@ -435,6 +441,8 @@ export default class Generator extends Common {

/**
* @description Export object with html content and exportation functions
* @param keys
* @param params
* @returns {{html: *, toFile: (function(*): *)}}
* @private
*/
Expand All @@ -448,6 +456,8 @@ export default class Generator extends Common {

/**
* @description Save content to pdf file
* @param keys
* @param params
* @returns {*}
* @private
*/
Expand Down

0 comments on commit 175b466

Please sign in to comment.