@tomei/finance 0.4.8 → 0.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/document/document.js +18 -16
- package/dist/document/document.js.map +1 -1
- package/dist/finance-company/finance-company.js +9 -8
- package/dist/finance-company/finance-company.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/invoice-template/index.html +1 -1
- package/package.json +1 -1
- package/src/document/document.ts +37 -20
- package/src/finance-company/finance-company.ts +22 -14
package/package.json
CHANGED
package/src/document/document.ts
CHANGED
|
@@ -281,7 +281,7 @@ export default class Document extends AccountSystemEntity {
|
|
|
281
281
|
size: htmlBuffer.length,
|
|
282
282
|
encoding: '8bit',
|
|
283
283
|
filename: 'sample-invoice.html',
|
|
284
|
-
destination:
|
|
284
|
+
destination: path.dirname(templateLocation),
|
|
285
285
|
path: '',
|
|
286
286
|
stream: null,
|
|
287
287
|
};
|
|
@@ -334,7 +334,7 @@ export default class Document extends AccountSystemEntity {
|
|
|
334
334
|
}, imgTag);
|
|
335
335
|
|
|
336
336
|
// Get the current date and invoice number from customer
|
|
337
|
-
const currentDate = new Date().toLocaleDateString();
|
|
337
|
+
const currentDate = new Date().toLocaleDateString('en-GB');
|
|
338
338
|
const invoiceNo = 'EZC-2202-2020';
|
|
339
339
|
|
|
340
340
|
// Update the invoice number and date in the HTML content
|
|
@@ -342,7 +342,7 @@ export default class Document extends AccountSystemEntity {
|
|
|
342
342
|
<div class="tm_invoice_seperator tm_gray_bg"></div>
|
|
343
343
|
<div class="tm_invoice_info_list">
|
|
344
344
|
<p class="tm_invoice_number tm_m0">
|
|
345
|
-
Invoice No: <b class="tm_primary_color"
|
|
345
|
+
Invoice No: <b class="tm_primary_color">${invoiceNo}</b>
|
|
346
346
|
</p>
|
|
347
347
|
<p class="tm_invoice_date tm_m0">
|
|
348
348
|
Date: <b class="tm_primary_color">${currentDate}</b>
|
|
@@ -354,6 +354,23 @@ export default class Document extends AccountSystemEntity {
|
|
|
354
354
|
invoice.innerHTML = invoiceContent;
|
|
355
355
|
}, invoiceContent);
|
|
356
356
|
|
|
357
|
+
// Update the invoice customer detail in the HTML content
|
|
358
|
+
const invoiceCustomerContent = `
|
|
359
|
+
<p class="tm_mb2">
|
|
360
|
+
<b class="tm_primary_color">Invoice To:</b>
|
|
361
|
+
</p>
|
|
362
|
+
<p>
|
|
363
|
+
${customer.FullName} <br />
|
|
364
|
+
${customer.DefaultAddress.Address}, ${customer.DefaultAddress.City} <br />
|
|
365
|
+
${customer.DefaultAddress.Country} <br />
|
|
366
|
+
${customer.Email}
|
|
367
|
+
</p>
|
|
368
|
+
`;
|
|
369
|
+
const invoiceCustomerHandle = await page.$('.tm_customer_detail');
|
|
370
|
+
await invoiceCustomerHandle.evaluate((invoice, invoiceCustomerContent) => {
|
|
371
|
+
invoice.innerHTML = invoiceCustomerContent;
|
|
372
|
+
}, invoiceCustomerContent);
|
|
373
|
+
|
|
357
374
|
const pdfBuffer = await page.pdf({
|
|
358
375
|
format: 'a4',
|
|
359
376
|
printBackground: true,
|
|
@@ -500,23 +517,23 @@ export default class Document extends AccountSystemEntity {
|
|
|
500
517
|
userId ?? 'System',
|
|
501
518
|
);
|
|
502
519
|
|
|
503
|
-
try {
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
} catch (err) {
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
}
|
|
520
|
+
// try {
|
|
521
|
+
// const document = await this.RepositoryBase.findOne({
|
|
522
|
+
// where: {
|
|
523
|
+
// DocNo: this.DocNo,
|
|
524
|
+
// },
|
|
525
|
+
// transaction: this._DbTransaction,
|
|
526
|
+
// });
|
|
527
|
+
|
|
528
|
+
// /* storing HTML & PDF MediaId to finance_Document */
|
|
529
|
+
// document.DocHTMLFileMediaId = HTMLInvoiceMedia.MediaId;
|
|
530
|
+
// document.DocPDFFileMediaId = PDFInvoiceMedia.MediaId;
|
|
531
|
+
|
|
532
|
+
// await document.save({ transaction: this._DbTransaction });
|
|
533
|
+
// } catch (err) {
|
|
534
|
+
// // tslint:disable-next-line:no-console
|
|
535
|
+
// console.log(err);
|
|
536
|
+
// }
|
|
520
537
|
|
|
521
538
|
return {
|
|
522
539
|
HTMLMedia: HTMLInvoiceMedia,
|
|
@@ -31,6 +31,7 @@ import { PaymentMethodTypeRepository } from '../payment-method-type/payment-meth
|
|
|
31
31
|
import PaymentMethod from '../payment-method/payment-method';
|
|
32
32
|
import { AccountRepository } from '../account/account.repository';
|
|
33
33
|
import { PaymentPaidWithRepository } from '../payment-paid-with/payment-paid-with.repository';
|
|
34
|
+
import { Medias, MediasModel } from '@tomei/media';
|
|
34
35
|
|
|
35
36
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
36
37
|
const getConfig = require('../config');
|
|
@@ -539,7 +540,25 @@ export default class FinanceCompany extends ObjectBase {
|
|
|
539
540
|
|
|
540
541
|
/*Set up the document type*/
|
|
541
542
|
invoice.DocType = DocType.INVOICE;
|
|
542
|
-
|
|
543
|
+
|
|
544
|
+
/*Generating the invoice*/
|
|
545
|
+
let invoiceMedia: {
|
|
546
|
+
HTMLMedia: MediasModel;
|
|
547
|
+
PDFMedia: MediasModel;
|
|
548
|
+
};
|
|
549
|
+
|
|
550
|
+
if (invoice.UseAccSystemDocYN === 'Y') {
|
|
551
|
+
/*todo: Posting to accounting system to generate invoice*/
|
|
552
|
+
await this.AccountingSystem.createInvoice(invoice);
|
|
553
|
+
} else {
|
|
554
|
+
/*todo: check config file to see which invoice template is to be used for specific project*/
|
|
555
|
+
|
|
556
|
+
/*Generating invoice based on template*/
|
|
557
|
+
invoiceMedia = await invoice.generateInvoice(
|
|
558
|
+
invoice.IssuedById,
|
|
559
|
+
customer,
|
|
560
|
+
);
|
|
561
|
+
}
|
|
543
562
|
|
|
544
563
|
/*Saving the document and document items to the database*/
|
|
545
564
|
await FinanceCompany._DocumentRepository.create(
|
|
@@ -561,8 +580,8 @@ export default class FinanceCompany extends ObjectBase {
|
|
|
561
580
|
CreatedAt: new Date(),
|
|
562
581
|
UpdatedById: invoice.UpdatedById,
|
|
563
582
|
UpdatedAt: new Date(),
|
|
564
|
-
DocPDFFileMediaId:
|
|
565
|
-
DocHTMLFileMediaId:
|
|
583
|
+
DocPDFFileMediaId: invoiceMedia.PDFMedia,
|
|
584
|
+
DocHTMLFileMediaId: invoiceMedia.HTMLMedia,
|
|
566
585
|
AccSystemRefId: invoice.AccSystemRefId,
|
|
567
586
|
PostedToAccSystemYN: invoice.PostedToAccSystemYN,
|
|
568
587
|
PostedById: invoice.PostedById,
|
|
@@ -608,17 +627,6 @@ export default class FinanceCompany extends ObjectBase {
|
|
|
608
627
|
);
|
|
609
628
|
}
|
|
610
629
|
|
|
611
|
-
/*Generating the invoice*/
|
|
612
|
-
if (invoice.UseAccSystemDocYN === 'Y') {
|
|
613
|
-
/*todo: Posting to accounting system to generate invoice*/
|
|
614
|
-
await this.AccountingSystem.createInvoice(invoice);
|
|
615
|
-
} else {
|
|
616
|
-
/*todo: check config file to see which invoice template is to be used for specific project*/
|
|
617
|
-
|
|
618
|
-
/*Generating invoice based on template*/
|
|
619
|
-
invoice.generateInvoice(invoice.IssuedById, customer);
|
|
620
|
-
}
|
|
621
|
-
|
|
622
630
|
const transactionDate = new Date();
|
|
623
631
|
const htCreditAccountAmount = new HashTable();
|
|
624
632
|
const htCreditAccountCurrency = new HashTable();
|