@tomei/finance 0.3.33 → 0.3.35
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.d.ts +1 -1
- package/dist/document/document.js +9 -6
- package/dist/document/document.js.map +1 -1
- package/dist/finance-company/finance-company.d.ts +1 -0
- package/dist/finance-company/finance-company.js +176 -102
- package/dist/finance-company/finance-company.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/ledger-transaction/interfaces/ledger-transaction-attr.interface.d.ts +2 -1
- package/dist/ledger-transaction/ledger-transaction.d.ts +4 -2
- package/dist/ledger-transaction/ledger-transaction.js +6 -5
- package/dist/ledger-transaction/ledger-transaction.js.map +1 -1
- package/dist/models/ledger-transaction.entity.d.ts +6 -1
- package/dist/models/ledger-transaction.entity.js +31 -14
- package/dist/models/ledger-transaction.entity.js.map +1 -1
- package/dist/models/payment-item.entity.d.ts +2 -1
- package/dist/models/payment-item.entity.js +9 -2
- package/dist/models/payment-item.entity.js.map +1 -1
- package/dist/models/payment-paid-with.entity.d.ts +18 -0
- package/dist/models/payment-paid-with.entity.js +117 -0
- package/dist/models/payment-paid-with.entity.js.map +1 -0
- package/dist/models/payment.entity.d.ts +1 -6
- package/dist/models/payment.entity.js +2 -29
- package/dist/models/payment.entity.js.map +1 -1
- package/dist/payment/interfaces/payment-attr.interface.d.ts +1 -6
- package/dist/payment/interfaces/payment-attr.interface.js.map +1 -1
- package/dist/payment/payment.d.ts +10 -17
- package/dist/payment/payment.js +43 -30
- package/dist/payment/payment.js.map +1 -1
- package/dist/payment-item/interfaces/payment-item-attr.interface.d.ts +3 -1
- package/dist/payment-item/interfaces/payment-item-attr.interface.js.map +1 -1
- package/dist/payment-item/payment-item.d.ts +3 -0
- package/dist/payment-item/payment-item.js +6 -0
- package/dist/payment-item/payment-item.js.map +1 -1
- package/dist/payment-paid-with/interfaces/payment-paid-with.interface.d.ts +13 -0
- package/dist/payment-paid-with/interfaces/payment-paid-with.interface.js +7 -0
- package/dist/payment-paid-with/interfaces/payment-paid-with.interface.js.map +1 -0
- package/dist/payment-paid-with/payment-paid-with.d.ts +24 -0
- package/dist/payment-paid-with/payment-paid-with.js +44 -0
- package/dist/payment-paid-with/payment-paid-with.js.map +1 -0
- package/dist/payment-paid-with/payment-paid-with.repository.d.ts +5 -0
- package/dist/payment-paid-with/payment-paid-with.repository.js +12 -0
- package/dist/payment-paid-with/payment-paid-with.repository.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/migrations/finance-ledger-transaction-migration.js +23 -7
- package/migrations/finance-payment-item-migration.js +10 -2
- package/migrations/finance-payment-migration.js +2 -34
- package/migrations/finance-paymentpaidwith-migration.js +66 -0
- package/package.json +1 -1
- package/src/document/document.ts +20 -10
- package/src/finance-company/finance-company.ts +233 -175
- package/src/index.ts +2 -0
- package/src/ledger-transaction/interfaces/ledger-transaction-attr.interface.ts +2 -1
- package/src/ledger-transaction/ledger-transaction.ts +6 -4
- package/src/models/ledger-transaction.entity.ts +27 -13
- package/src/models/payment-item.entity.ts +8 -2
- package/src/models/payment-paid-with.entity.ts +97 -0
- package/src/models/payment.entity.ts +2 -28
- package/src/payment/interfaces/payment-attr.interface.ts +1 -6
- package/src/payment/payment.ts +55 -50
- package/src/payment-item/interfaces/payment-item-attr.interface.ts +3 -1
- package/src/payment-item/payment-item.ts +6 -3
- package/src/payment-paid-with/interfaces/payment-paid-with.interface.ts +14 -0
- package/src/payment-paid-with/payment-paid-with.repository.ts +11 -0
- package/src/payment-paid-with/payment-paid-with.ts +54 -0
|
@@ -62,6 +62,6 @@ export default class Document extends AccountSystemEntity {
|
|
|
62
62
|
PDFMedia: MediasModel;
|
|
63
63
|
}>;
|
|
64
64
|
generateCreditNote(userId?: string, customer?: FinanceCustomerBase): Promise<void>;
|
|
65
|
-
newDocumentItem(documentItem
|
|
65
|
+
newDocumentItem(dbTransaction?: any, documentItem?: any): Promise<DocumentItem>;
|
|
66
66
|
getPreviousDocument(docType: DocType): Promise<DocumentModel>;
|
|
67
67
|
}
|
|
@@ -9,7 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const cuid = require("cuid");
|
|
13
12
|
const util = require("util");
|
|
14
13
|
const fs = require("fs");
|
|
15
14
|
const puppeteer = require("puppeteer");
|
|
@@ -95,7 +94,6 @@ class Document extends account_system_entity_1.AccountSystemEntity {
|
|
|
95
94
|
this._DocPDFFileMediaId = '';
|
|
96
95
|
this._IsNewRecord = true;
|
|
97
96
|
this._DocumentItems = null;
|
|
98
|
-
console.log(config, '<<< test config from finance');
|
|
99
97
|
if (dbTransaction) {
|
|
100
98
|
this._DbTransaction = dbTransaction;
|
|
101
99
|
}
|
|
@@ -130,6 +128,7 @@ class Document extends account_system_entity_1.AccountSystemEntity {
|
|
|
130
128
|
this.PostedById = documentData.PostedById;
|
|
131
129
|
this.PostedDateTime = documentData.PostedDateTime;
|
|
132
130
|
this.UseAccSystemDocYN = documentData.UseAccSystemDocYN;
|
|
131
|
+
this.IsNewRecord = false;
|
|
133
132
|
}
|
|
134
133
|
else {
|
|
135
134
|
const notFoundError = new general_1.RecordNotFoundError('No Record Found.');
|
|
@@ -165,7 +164,9 @@ class Document extends account_system_entity_1.AccountSystemEntity {
|
|
|
165
164
|
reject(err);
|
|
166
165
|
});
|
|
167
166
|
}
|
|
168
|
-
|
|
167
|
+
else {
|
|
168
|
+
resolve(this._DocumentItems);
|
|
169
|
+
}
|
|
169
170
|
});
|
|
170
171
|
}
|
|
171
172
|
static DEFAULT_INVOICE_TEMPLATE_HTML() {
|
|
@@ -317,10 +318,12 @@ class Document extends account_system_entity_1.AccountSystemEntity {
|
|
|
317
318
|
generateCreditNote(userId, customer) {
|
|
318
319
|
return __awaiter(this, void 0, void 0, function* () { });
|
|
319
320
|
}
|
|
320
|
-
newDocumentItem(documentItem) {
|
|
321
|
+
newDocumentItem(dbTransaction, documentItem) {
|
|
321
322
|
return __awaiter(this, void 0, void 0, function* () {
|
|
322
|
-
|
|
323
|
-
|
|
323
|
+
const di = new document_item_1.default();
|
|
324
|
+
di.DocNo = this.DocNo;
|
|
325
|
+
this._DocumentItems.push(documentItem);
|
|
326
|
+
return documentItem;
|
|
324
327
|
});
|
|
325
328
|
}
|
|
326
329
|
getPreviousDocument(docType) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../src/document/document.ts"],"names":[],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../src/document/document.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,6BAA6B;AAC7B,yBAAyB;AACzB,uCAAuC;AACvC,4CAAqD;AACrD,wCAOsB;AACtB,kCAAkD;AAElD,yEAAoE;AACpE,mDAA2C;AAC3C,0FAAqF;AACrF,+DAA2D;AAO3D,MAAM,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAEvC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;AAE3B,MAAqB,QAAS,SAAQ,2CAAmB;IA8BvD,IAAY,WAAW;QACrB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,IAAY,WAAW,CAAC,MAAe;QACrC,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;IAC7B,CAAC;IAED,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,IAAW,KAAK,CAAC,EAAU;QACzB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACnB,CAAC;IAED,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAW,OAAO,CAAC,OAAgB;QACjC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAA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AAC;YACtB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACvC,OAAO,YAAY,CAAC;QACtB,CAAC;KAAA;IAWK,mBAAmB,CAAC,OAAgB;;YACxC,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;gBACvC,KAAK,EAAE;oBACL,OAAO,EAAE,OAAO;iBACjB;gBACD,KAAK,EAAE,CAAC,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;aAC/B,CAAC,CAAC;QACL,CAAC;KAAA;;AA5dH,2BA6dC;AAzcgB,wBAAe,GAAG,IAAI,wCAAkB,EAAE,CAAC;AAC3C,gCAAuB,GAAG,IAAI,iDAAsB,EAAE,CAAC"}
|
|
@@ -15,6 +15,7 @@ export default class FinanceCompany extends ObjectBase {
|
|
|
15
15
|
private static _financeCompanyRepository;
|
|
16
16
|
private static _PaymentRepository;
|
|
17
17
|
private static _PaymentItemRepository;
|
|
18
|
+
private static _PaymentPaidWithRepository;
|
|
18
19
|
private static _PaymentMethodRepository;
|
|
19
20
|
private static _PaymentMethodTypeRepository;
|
|
20
21
|
private static _DocumentRepository;
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
const axios_1 = require("axios");
|
|
13
13
|
const cuid = require("cuid");
|
|
14
14
|
const general_1 = require("@tomei/general");
|
|
15
|
+
const account_1 = require("../account/account");
|
|
15
16
|
const journal_entry_1 = require("../journal-entry/journal-entry");
|
|
16
17
|
const finance_company_repository_1 = require("./finance-company.repository");
|
|
17
18
|
const finance_customer_repository_1 = require("../customer/finance-customer.repository");
|
|
@@ -25,6 +26,7 @@ const document_item_repository_1 = require("../document/document-item.repository
|
|
|
25
26
|
const payment_method_repository_1 = require("../payment-method/payment-method.repository");
|
|
26
27
|
const payment_method_type_repository_1 = require("../payment-method-type/payment-method-type.repository");
|
|
27
28
|
const payment_method_1 = require("../payment-method/payment-method");
|
|
29
|
+
const payment_paid_with_repository_1 = require("src/payment-paid-with/payment-paid-with.repository");
|
|
28
30
|
const getConfig = require('../config');
|
|
29
31
|
const config = getConfig();
|
|
30
32
|
class FinanceCompany extends general_1.ObjectBase {
|
|
@@ -285,6 +287,7 @@ class FinanceCompany extends general_1.ObjectBase {
|
|
|
285
287
|
}
|
|
286
288
|
}
|
|
287
289
|
invoice.DocType = enum_1.DocType.INVOICE;
|
|
290
|
+
invoice.DocNo = cuid();
|
|
288
291
|
yield FinanceCompany._DocumentRepository.create({
|
|
289
292
|
DocNo: invoice.DocNo,
|
|
290
293
|
DocType: invoice.DocType,
|
|
@@ -311,34 +314,78 @@ class FinanceCompany extends general_1.ObjectBase {
|
|
|
311
314
|
}, {
|
|
312
315
|
transaction: dbTransaction,
|
|
313
316
|
});
|
|
317
|
+
documentItems.forEach((documentItem) => __awaiter(this, void 0, void 0, function* () {
|
|
318
|
+
yield FinanceCompany._DocumentItemRepository.create({
|
|
319
|
+
DocumentItemId: cuid(),
|
|
320
|
+
DocNo: documentItem.DocNo,
|
|
321
|
+
Name: documentItem.Name,
|
|
322
|
+
NameBM: documentItem.NameBM,
|
|
323
|
+
Description: documentItem.Description,
|
|
324
|
+
ItemId: documentItem.ItemId,
|
|
325
|
+
ItemType: documentItem.ItemType,
|
|
326
|
+
ItemSKU: documentItem.ItemSKU,
|
|
327
|
+
ItemSerialNo: documentItem.ItemSerialNo,
|
|
328
|
+
Currency: documentItem.Currency,
|
|
329
|
+
UnitPrice: documentItem.UnitPrice,
|
|
330
|
+
Quantity: documentItem.Quantity,
|
|
331
|
+
QuantityUOM: documentItem.QuantityUOM,
|
|
332
|
+
Amount: documentItem.Amount,
|
|
333
|
+
TaxCode: documentItem.TaxCode,
|
|
334
|
+
TaxAmount: documentItem.TaxAmount,
|
|
335
|
+
TaxRate: documentItem.TaxRate,
|
|
336
|
+
TaxInclusiveYN: documentItem.TaxInclusiveYN,
|
|
337
|
+
DtAccountNo: documentItem.DtAccountNo,
|
|
338
|
+
CtAccountNo: documentItem.CtAccountNo,
|
|
339
|
+
}, {
|
|
340
|
+
transaction: dbTransaction,
|
|
341
|
+
});
|
|
342
|
+
}));
|
|
314
343
|
if (invoice.UseAccSystemDocYN === 'Y') {
|
|
315
344
|
yield this.AccountingSystem.createInvoice(invoice);
|
|
316
345
|
}
|
|
317
346
|
else {
|
|
318
347
|
invoice.generateInvoice(invoice.IssuedById);
|
|
319
348
|
}
|
|
320
|
-
const journalEntry = new journal_entry_1.default(dbTransaction);
|
|
321
349
|
const transactionDate = new Date();
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
350
|
+
const htCreditAccountAmount = new general_1.HashTable();
|
|
351
|
+
const htCreditAccountCurrency = new general_1.HashTable();
|
|
352
|
+
documentItems.forEach((invoiceItem) => {
|
|
353
|
+
if (!htCreditAccountAmount.exists(invoiceItem.CtAccountNo)) {
|
|
354
|
+
htCreditAccountAmount.add(invoiceItem.CtAccountNo, invoiceItem.Amount);
|
|
355
|
+
htCreditAccountCurrency.add(invoiceItem.CtAccountNo, invoiceItem.Currency);
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
const d = htCreditAccountAmount.get(invoiceItem.CtAccountNo);
|
|
359
|
+
htCreditAccountAmount.add(invoiceItem.CtAccountNo, d + invoiceItem.Amount);
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
const savedItems = htCreditAccountAmount.list();
|
|
363
|
+
for (let i = 0; i < savedItems.length; i++) {
|
|
364
|
+
const journalEntry = new journal_entry_1.default(dbTransaction);
|
|
365
|
+
const account = new account_1.default(dbTransaction, savedItems[i].key);
|
|
366
|
+
const creditAmount = savedItems[i].value;
|
|
367
|
+
const currency = htCreditAccountCurrency.get(savedItems[i].key);
|
|
368
|
+
const dt = yield journalEntry.newLedgerTransaction(enum_1.TransactionTypeOptions.DEBIT);
|
|
369
|
+
if (dtAccountNo) {
|
|
370
|
+
dt.AccountNo = dtAccountNo;
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
dt.AccountNo = (yield customer.AccountReceivable).AccountNo;
|
|
374
|
+
}
|
|
375
|
+
dt.Currency = currency ? currency : 'MYR';
|
|
376
|
+
dt.DebitAmount = creditAmount ? creditAmount : 0.0;
|
|
377
|
+
dt.Date = transactionDate;
|
|
378
|
+
dt.Description = account.Name;
|
|
379
|
+
dt.RelatedDocNo = invoice.DocNo;
|
|
380
|
+
const ct = yield journalEntry.newLedgerTransaction(enum_1.TransactionTypeOptions.CREDIT);
|
|
381
|
+
ct.AccountNo = savedItems[i].key;
|
|
382
|
+
ct.Currency = currency ? currency : 'MYR';
|
|
383
|
+
ct.CreditAmount = creditAmount ? creditAmount : 0.0;
|
|
384
|
+
ct.Date = transactionDate;
|
|
385
|
+
ct.Description = account.Name;
|
|
386
|
+
ct.RelatedDocNo = invoice.DocNo;
|
|
387
|
+
yield this.postJournal(dbTransaction, journalEntry);
|
|
340
388
|
}
|
|
341
|
-
this.postJournal(dbTransaction, journalEntry);
|
|
342
389
|
return invoice;
|
|
343
390
|
}
|
|
344
391
|
catch (err) {
|
|
@@ -369,6 +416,7 @@ class FinanceCompany extends general_1.ObjectBase {
|
|
|
369
416
|
}
|
|
370
417
|
}
|
|
371
418
|
invoice.DocType = enum_1.DocType.DEBIT_NOTE;
|
|
419
|
+
invoice.DocNo = cuid();
|
|
372
420
|
yield FinanceCompany._DocumentRepository.create({
|
|
373
421
|
DocNo: invoice.DocNo,
|
|
374
422
|
DocType: invoice.DocType,
|
|
@@ -427,40 +475,46 @@ class FinanceCompany extends general_1.ObjectBase {
|
|
|
427
475
|
else {
|
|
428
476
|
invoice.generateInvoice(loginUser.IDNo, customer);
|
|
429
477
|
}
|
|
430
|
-
const journalEntry = new journal_entry_1.default(dbTransaction);
|
|
431
478
|
const transactionDate = new Date();
|
|
432
|
-
const
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
479
|
+
const htCreditAccountAmount = new general_1.HashTable();
|
|
480
|
+
const htCreditAccountCurrency = new general_1.HashTable();
|
|
481
|
+
documentItems.forEach((invoiceItem) => {
|
|
482
|
+
if (!htCreditAccountAmount.exists(invoiceItem.CtAccountNo)) {
|
|
483
|
+
htCreditAccountAmount.add(invoiceItem.CtAccountNo, invoiceItem.Amount);
|
|
484
|
+
htCreditAccountCurrency.add(invoiceItem.CtAccountNo, invoiceItem.Currency);
|
|
485
|
+
}
|
|
486
|
+
else {
|
|
487
|
+
const d = htCreditAccountAmount.get(invoiceItem.CtAccountNo);
|
|
488
|
+
htCreditAccountAmount.add(invoiceItem.CtAccountNo, d + invoiceItem.Amount);
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
const savedItems = htCreditAccountAmount.list();
|
|
492
|
+
for (let i = 0; i < savedItems.length; i++) {
|
|
493
|
+
const journalEntry = new journal_entry_1.default(dbTransaction);
|
|
494
|
+
const account = new account_1.default(dbTransaction, savedItems[i].key);
|
|
495
|
+
const creditAmount = savedItems[i].value;
|
|
496
|
+
const currency = htCreditAccountCurrency.get(savedItems[i].key);
|
|
497
|
+
const dt = yield journalEntry.newLedgerTransaction(enum_1.TransactionTypeOptions.DEBIT);
|
|
498
|
+
if (dtAccountNo) {
|
|
499
|
+
dt.AccountNo = dtAccountNo;
|
|
500
|
+
}
|
|
501
|
+
else {
|
|
502
|
+
dt.AccountNo = (yield customer.AccountReceivable).AccountNo;
|
|
503
|
+
}
|
|
504
|
+
dt.Currency = currency ? currency : 'MYR';
|
|
505
|
+
dt.DebitAmount = creditAmount ? creditAmount : 0.0;
|
|
506
|
+
dt.Date = transactionDate;
|
|
507
|
+
dt.Description = account.Name;
|
|
508
|
+
dt.RelatedDocNo = invoice.DocNo;
|
|
509
|
+
const ct = yield journalEntry.newLedgerTransaction(enum_1.TransactionTypeOptions.CREDIT);
|
|
510
|
+
ct.AccountNo = savedItems[i].key;
|
|
511
|
+
ct.Currency = currency ? currency : 'MYR';
|
|
512
|
+
ct.CreditAmount = creditAmount ? creditAmount : 0.0;
|
|
513
|
+
ct.Date = transactionDate;
|
|
514
|
+
ct.Description = account.Name;
|
|
515
|
+
ct.RelatedDocNo = invoice.DocNo;
|
|
516
|
+
yield this.postJournal(dbTransaction, journalEntry);
|
|
450
517
|
}
|
|
451
|
-
this.postJournal(dbTransaction, journalEntry);
|
|
452
|
-
const payload = {
|
|
453
|
-
Action: 'Create',
|
|
454
|
-
Activity: 'Issuing a Debit Note',
|
|
455
|
-
Description: `Debit Transaction (ID: ${debitTransaction.TransactionId}) has been created`,
|
|
456
|
-
EntityType: 'DebitTransaction',
|
|
457
|
-
EntityValueBefore: JSON.stringify({}),
|
|
458
|
-
EntityValueAfter: JSON.stringify(debitTransaction),
|
|
459
|
-
PerformedById: 'test',
|
|
460
|
-
PerformedAt: new Date(),
|
|
461
|
-
EntityId: debitTransaction.TransactionId,
|
|
462
|
-
};
|
|
463
|
-
yield axios_1.default.post(`${process.env.COMMON_API_URL}/activity-histories`, payload);
|
|
464
518
|
return invoice;
|
|
465
519
|
}
|
|
466
520
|
catch (err) {
|
|
@@ -561,14 +615,14 @@ class FinanceCompany extends general_1.ObjectBase {
|
|
|
561
615
|
creditTransaction.Currency = creditNote.Currency;
|
|
562
616
|
creditTransaction.CreditAmount = creditNote.Amount;
|
|
563
617
|
creditTransaction.Date = transactionDate;
|
|
564
|
-
creditTransaction.
|
|
618
|
+
creditTransaction.Description = creditNote.DocNo;
|
|
565
619
|
for (const invoiceItem of documentItems) {
|
|
566
620
|
const itemLedger = yield journalEntry.newLedgerTransaction(enum_1.TransactionTypeOptions.DEBIT);
|
|
567
621
|
itemLedger.AccountNo = invoiceItem.CtAccountNo;
|
|
568
622
|
itemLedger.Currency = invoiceItem.Currency;
|
|
569
623
|
itemLedger.DebitAmount = invoiceItem.Amount;
|
|
570
624
|
itemLedger.Date = transactionDate;
|
|
571
|
-
itemLedger.
|
|
625
|
+
itemLedger.Description = invoiceItem.Description;
|
|
572
626
|
}
|
|
573
627
|
this.postJournal(dbTransaction, journalEntry);
|
|
574
628
|
const payload = {
|
|
@@ -593,29 +647,26 @@ class FinanceCompany extends general_1.ObjectBase {
|
|
|
593
647
|
}
|
|
594
648
|
collectPayment(dbTransaction, loginUser, payment, customer, ctAccountNo) {
|
|
595
649
|
return __awaiter(this, void 0, void 0, function* () {
|
|
596
|
-
let paymentMethodType;
|
|
597
650
|
try {
|
|
598
|
-
paymentMethodType = new payment_method_type_1.default(dbTransaction, payment.MethodTypeId);
|
|
599
651
|
const paymentItems = yield payment.PaymentItems;
|
|
600
652
|
if (paymentItems.length < 1) {
|
|
601
|
-
throw new Error('Atleast one payment item is required to identify what payment is being paid for');
|
|
653
|
+
throw new Error('Atleast one payment item is required to identify what payment is being paid for.');
|
|
654
|
+
}
|
|
655
|
+
const paymentPaidWithItems = yield payment.PaymentPaidWith;
|
|
656
|
+
if (paymentPaidWithItems.length < 1) {
|
|
657
|
+
throw new Error('Atleast one payment paid with item is required to identify how the payment was made.');
|
|
602
658
|
}
|
|
603
659
|
payment.PaymentId = cuid();
|
|
604
660
|
payment.PaymentType = enum_1.PaymentType.PAYMENT_RECEIVED;
|
|
661
|
+
payment.ReceivedBy = loginUser.ObjectId;
|
|
605
662
|
yield FinanceCompany._PaymentRepository.create({
|
|
606
663
|
PaymentId: payment.PaymentId,
|
|
607
664
|
PaymentType: payment.PaymentType,
|
|
608
665
|
PaymentDate: payment.PaymentDate,
|
|
609
|
-
|
|
610
|
-
MethodTypeId: payment.MethodTypeId,
|
|
666
|
+
Description: payment.Description,
|
|
611
667
|
Currency: payment.Currency,
|
|
612
668
|
Amount: payment.Amount,
|
|
613
669
|
Status: enum_1.PaymentStatus.SUCCESSFUL,
|
|
614
|
-
TransactionId: payment.TransactionId,
|
|
615
|
-
TransactionApprovalCode: payment.TransactionApprovalCode,
|
|
616
|
-
TransactionAccountName: payment.TransactionAccountName,
|
|
617
|
-
TransactionAccountNo: payment.TransactionAccountNo,
|
|
618
|
-
ReceivedBy: payment.ReceivedBy,
|
|
619
670
|
PostedToAccSystemYN: 'N',
|
|
620
671
|
UpdatedAt: new Date(),
|
|
621
672
|
UpdatedBy: loginUser.ObjectId,
|
|
@@ -629,41 +680,66 @@ class FinanceCompany extends general_1.ObjectBase {
|
|
|
629
680
|
PayForObjectType: paymentItem.PayForObjectType,
|
|
630
681
|
Currency: paymentItem.Currency,
|
|
631
682
|
Amount: paymentItem.Amount,
|
|
683
|
+
Name: paymentItem.Name,
|
|
684
|
+
Description: paymentItem.Description,
|
|
685
|
+
}, { transaction: dbTransaction });
|
|
686
|
+
}));
|
|
687
|
+
paymentPaidWithItems.forEach((paymentPaidWithItem) => __awaiter(this, void 0, void 0, function* () {
|
|
688
|
+
yield FinanceCompany._PaymentPaidWithRepository.create({
|
|
689
|
+
PaymentId: payment.PaymentId,
|
|
690
|
+
MethodTypeId: paymentPaidWithItem.MethodTypeId,
|
|
691
|
+
Currency: paymentPaidWithItem.Currency,
|
|
692
|
+
Amount: paymentPaidWithItem.Amount,
|
|
693
|
+
Status: paymentPaidWithItem.Status,
|
|
694
|
+
TransactionId: paymentPaidWithItem.TransactionId,
|
|
695
|
+
TransactionApprovalCode: paymentPaidWithItem.TransactionApprovalCode,
|
|
696
|
+
TransactionApprovalName: paymentPaidWithItem.TransactionApprovalName,
|
|
697
|
+
TransactionAccountNo: paymentPaidWithItem.TransactionAccountNo,
|
|
698
|
+
Remarks: paymentPaidWithItem.Remarks,
|
|
632
699
|
}, { transaction: dbTransaction });
|
|
633
700
|
}));
|
|
634
|
-
const journalEntry = new journal_entry_1.default(dbTransaction);
|
|
635
|
-
journalEntry.init({
|
|
636
|
-
CompanyId: this.CompanyId,
|
|
637
|
-
Name: 'Collect-payments for ' + payment.PaymentId,
|
|
638
|
-
});
|
|
639
701
|
const transactionDate = new Date();
|
|
640
|
-
const
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
702
|
+
for (const paymentPaidWith of paymentPaidWithItems) {
|
|
703
|
+
let paymentMethodType;
|
|
704
|
+
try {
|
|
705
|
+
paymentMethodType = new payment_method_type_1.default(dbTransaction, paymentPaidWith.MethodTypeId);
|
|
706
|
+
}
|
|
707
|
+
catch (error) {
|
|
708
|
+
if (error instanceof general_1.RecordNotFoundError) {
|
|
709
|
+
throw new Error('Invalid Payment Method Type Id');
|
|
710
|
+
}
|
|
711
|
+
else {
|
|
712
|
+
throw error;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
const journalEntry = new journal_entry_1.default(dbTransaction);
|
|
716
|
+
journalEntry.init({
|
|
717
|
+
CompanyId: this.CompanyId,
|
|
718
|
+
Name: 'Collect-payments for ' + payment.PaymentId,
|
|
719
|
+
});
|
|
720
|
+
const debitLT = yield journalEntry.newLedgerTransaction(enum_1.TransactionTypeOptions.DEBIT);
|
|
721
|
+
debitLT.AccountNo = paymentMethodType.AccountNo;
|
|
722
|
+
debitLT.Currency = payment.Currency;
|
|
723
|
+
debitLT.DebitAmount = payment.Amount;
|
|
724
|
+
debitLT.Date = transactionDate;
|
|
725
|
+
debitLT.Description = customer.FullName;
|
|
726
|
+
const creditLT = yield journalEntry.newLedgerTransaction(enum_1.TransactionTypeOptions.CREDIT);
|
|
727
|
+
if (ctAccountNo) {
|
|
728
|
+
creditLT.AccountNo = ctAccountNo;
|
|
729
|
+
}
|
|
730
|
+
else {
|
|
731
|
+
creditLT.AccountNo = (yield customer.AccountReceivable).AccountNo;
|
|
732
|
+
}
|
|
733
|
+
creditLT.Currency = payment.Currency;
|
|
734
|
+
creditLT.CreditAmount = payment.Amount;
|
|
735
|
+
creditLT.Date = transactionDate;
|
|
736
|
+
creditLT.Description = paymentMethodType.Name;
|
|
737
|
+
yield this.postJournal(dbTransaction, journalEntry);
|
|
652
738
|
}
|
|
653
|
-
creditLT.Currency = payment.Currency;
|
|
654
|
-
creditLT.CreditAmount = payment.Amount;
|
|
655
|
-
creditLT.Date = transactionDate;
|
|
656
|
-
creditLT.Name = paymentMethodType.Name;
|
|
657
|
-
yield this.postJournal(dbTransaction, journalEntry);
|
|
658
739
|
return payment;
|
|
659
740
|
}
|
|
660
741
|
catch (error) {
|
|
661
|
-
|
|
662
|
-
throw new Error('Invalid PaymentMethodType id');
|
|
663
|
-
}
|
|
664
|
-
else {
|
|
665
|
-
throw error;
|
|
666
|
-
}
|
|
742
|
+
throw error;
|
|
667
743
|
}
|
|
668
744
|
});
|
|
669
745
|
}
|
|
@@ -671,27 +747,22 @@ class FinanceCompany extends general_1.ObjectBase {
|
|
|
671
747
|
return __awaiter(this, void 0, void 0, function* () {
|
|
672
748
|
let paymentMethodType;
|
|
673
749
|
try {
|
|
674
|
-
paymentMethodType = new payment_method_type_1.default(dbTransaction
|
|
750
|
+
paymentMethodType = new payment_method_type_1.default(dbTransaction);
|
|
675
751
|
const paymentItems = yield payment.PaymentItems;
|
|
676
752
|
if (paymentItems.length < 1) {
|
|
677
753
|
throw new Error('Atleast one payment item is required to identify what payment is being paid for');
|
|
678
754
|
}
|
|
679
755
|
payment.PaymentId = cuid();
|
|
680
756
|
payment.PaymentType = enum_1.PaymentType.PAYOUT;
|
|
757
|
+
payment.ReceivedBy = loginUser.ObjectId;
|
|
681
758
|
yield FinanceCompany._PaymentRepository.create({
|
|
682
759
|
PaymentId: payment.PaymentId,
|
|
683
760
|
PaymentType: payment.PaymentType,
|
|
684
761
|
PaymentDate: payment.PaymentDate,
|
|
685
|
-
|
|
686
|
-
MethodTypeId: payment.MethodTypeId,
|
|
762
|
+
Description: payment.Description,
|
|
687
763
|
Currency: payment.Currency,
|
|
688
764
|
Amount: payment.Amount,
|
|
689
765
|
Status: enum_1.PaymentStatus.SUCCESSFUL,
|
|
690
|
-
TransactionId: payment.TransactionId,
|
|
691
|
-
TransactionApprovalCode: payment.TransactionApprovalCode,
|
|
692
|
-
TransactionAccountName: payment.TransactionAccountName,
|
|
693
|
-
TransactionAccountNo: payment.TransactionAccountNo,
|
|
694
|
-
ReceivedBy: payment.ReceivedBy,
|
|
695
766
|
PostedToAccSystemYN: 'N',
|
|
696
767
|
UpdatedAt: new Date(),
|
|
697
768
|
UpdatedBy: loginUser.ObjectId,
|
|
@@ -705,6 +776,8 @@ class FinanceCompany extends general_1.ObjectBase {
|
|
|
705
776
|
PayForObjectType: paymentItem.PayForObjectType,
|
|
706
777
|
Currency: paymentItem.Currency,
|
|
707
778
|
Amount: paymentItem.Amount,
|
|
779
|
+
Name: paymentItem.Name,
|
|
780
|
+
Description: paymentItem.Description,
|
|
708
781
|
}, { transaction: dbTransaction });
|
|
709
782
|
}));
|
|
710
783
|
const journalEntry = new journal_entry_1.default(dbTransaction);
|
|
@@ -718,7 +791,7 @@ class FinanceCompany extends general_1.ObjectBase {
|
|
|
718
791
|
creditLT.Currency = payment.Currency;
|
|
719
792
|
creditLT.CreditAmount = payment.Amount;
|
|
720
793
|
creditLT.Date = transactionDate;
|
|
721
|
-
creditLT.
|
|
794
|
+
creditLT.Description = customer.FullName;
|
|
722
795
|
const debitLT = yield journalEntry.newLedgerTransaction(enum_1.TransactionTypeOptions.DEBIT);
|
|
723
796
|
if (dtAccountNo) {
|
|
724
797
|
debitLT.AccountNo = dtAccountNo;
|
|
@@ -729,7 +802,7 @@ class FinanceCompany extends general_1.ObjectBase {
|
|
|
729
802
|
debitLT.Currency = payment.Currency;
|
|
730
803
|
debitLT.DebitAmount = payment.Amount;
|
|
731
804
|
debitLT.Date = transactionDate;
|
|
732
|
-
debitLT.
|
|
805
|
+
debitLT.Description = paymentMethodType.Name;
|
|
733
806
|
yield this.postJournal(dbTransaction, journalEntry);
|
|
734
807
|
return payment;
|
|
735
808
|
}
|
|
@@ -801,6 +874,7 @@ FinanceCompany._htFinanceCompanies = new general_1.HashTable();
|
|
|
801
874
|
FinanceCompany._financeCompanyRepository = new finance_company_repository_1.FinanceCompanyRepository();
|
|
802
875
|
FinanceCompany._PaymentRepository = new payment_repository_1.PaymentRepository();
|
|
803
876
|
FinanceCompany._PaymentItemRepository = new payment_item_repository_1.PaymentItemRepository();
|
|
877
|
+
FinanceCompany._PaymentPaidWithRepository = new payment_paid_with_repository_1.PaymentPaidWithRepository();
|
|
804
878
|
FinanceCompany._PaymentMethodRepository = new payment_method_repository_1.PaymentMethodRepository();
|
|
805
879
|
FinanceCompany._PaymentMethodTypeRepository = new payment_method_type_repository_1.PaymentMethodTypeRepository();
|
|
806
880
|
FinanceCompany._DocumentRepository = new document_repository_1.DocumentRepository();
|