@tomei/finance 0.4.9 → 0.4.11
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 +1 -15
- 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/package.json +1 -1
- package/src/document/document.ts +19 -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
|
};
|
|
@@ -337,8 +337,6 @@ export default class Document extends AccountSystemEntity {
|
|
|
337
337
|
const currentDate = new Date().toLocaleDateString('en-GB');
|
|
338
338
|
const invoiceNo = 'EZC-2202-2020';
|
|
339
339
|
|
|
340
|
-
console.log(customer, '<<<<');
|
|
341
|
-
|
|
342
340
|
// Update the invoice number and date in the HTML content
|
|
343
341
|
const invoiceContent = `
|
|
344
342
|
<div class="tm_invoice_seperator tm_gray_bg"></div>
|
|
@@ -519,23 +517,24 @@ export default class Document extends AccountSystemEntity {
|
|
|
519
517
|
userId ?? 'System',
|
|
520
518
|
);
|
|
521
519
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
520
|
+
/*Below is commented because the current implentation flow does not add up*/
|
|
521
|
+
// try {
|
|
522
|
+
// const document = await this.RepositoryBase.findOne({
|
|
523
|
+
// where: {
|
|
524
|
+
// DocNo: this.DocNo,
|
|
525
|
+
// },
|
|
526
|
+
// transaction: this._DbTransaction,
|
|
527
|
+
// });
|
|
528
|
+
|
|
529
|
+
// /* storing HTML & PDF MediaId to finance_Document */
|
|
530
|
+
// document.DocHTMLFileMediaId = HTMLInvoiceMedia.MediaId;
|
|
531
|
+
// document.DocPDFFileMediaId = PDFInvoiceMedia.MediaId;
|
|
532
|
+
|
|
533
|
+
// await document.save({ transaction: this._DbTransaction });
|
|
534
|
+
// } catch (err) {
|
|
535
|
+
// // tslint:disable-next-line:no-console
|
|
536
|
+
// console.log(err);
|
|
537
|
+
// }
|
|
539
538
|
|
|
540
539
|
return {
|
|
541
540
|
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.MediaId,
|
|
584
|
+
DocHTMLFileMediaId: invoiceMedia.HTMLMedia.MediaId,
|
|
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();
|