@tomei/finance 0.3.0 → 0.3.2
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/account/account.d.ts +22 -27
- package/dist/account/account.js +89 -77
- package/dist/account/account.js.map +1 -1
- package/dist/account/account.repository.d.ts +3 -14
- package/dist/account/account.repository.js +4 -39
- package/dist/account/account.repository.js.map +1 -1
- package/dist/account/interfaces/account-attr.interface.d.ts +15 -7
- package/dist/account-system-entity/account-system-entity.d.ts +2 -2
- package/dist/account-system-entity/account-system-entity.js +1 -1
- package/dist/account-system-entity/post-history.repository.d.ts +2 -2
- package/dist/account-system-entity/post-history.repository.js +1 -1
- package/dist/customer/customer.d.ts +3 -3
- package/dist/customer/customer.js +1 -2
- package/dist/customer/customer.js.map +1 -1
- package/dist/customer/finance-customer.repository.d.ts +2 -2
- package/dist/customer/finance-customer.repository.js +1 -1
- package/dist/customer/interfaces/finance-customer.repository.interface.d.ts +2 -2
- package/dist/document/document-item.d.ts +2 -1
- package/dist/document/document-item.js +2 -2
- package/dist/document/document-item.js.map +1 -1
- package/dist/document/document-item.repository.d.ts +3 -15
- package/dist/document/document-item.repository.js +4 -43
- package/dist/document/document-item.repository.js.map +1 -1
- package/dist/document/document.d.ts +20 -23
- package/dist/document/document.js +85 -54
- package/dist/document/document.js.map +1 -1
- package/dist/document/document.repository.d.ts +3 -14
- package/dist/document/document.repository.js +4 -39
- package/dist/document/document.repository.js.map +1 -1
- package/dist/document/interfaces/document-item.repository.interface.d.ts +2 -2
- package/dist/enum/index.d.ts +2 -1
- package/dist/enum/index.js +3 -1
- package/dist/enum/index.js.map +1 -1
- package/dist/enum/payment-status.enum.d.ts +4 -0
- package/dist/enum/payment-status.enum.js +9 -0
- package/dist/enum/payment-status.enum.js.map +1 -0
- package/dist/enum/transaction-type.enum.d.ts +2 -2
- package/dist/enum/transaction-type.enum.js +2 -2
- package/dist/enum/transaction-type.enum.js.map +1 -1
- package/dist/finance-company/finance-company.d.ts +15 -10
- package/dist/finance-company/finance-company.js +473 -30
- package/dist/finance-company/finance-company.js.map +1 -1
- package/dist/finance-company/finance-company.repository.d.ts +2 -2
- package/dist/finance-company/finance-company.repository.js +1 -1
- package/dist/index.d.ts +11 -8
- package/dist/index.js +14 -8
- package/dist/index.js.map +1 -1
- package/dist/interfaces/account-system.interface.d.ts +2 -2
- package/dist/journal-entry/journal-entry.d.ts +13 -17
- package/dist/journal-entry/journal-entry.js +83 -35
- package/dist/journal-entry/journal-entry.js.map +1 -1
- package/dist/journal-entry/journal-entry.repository.d.ts +3 -13
- package/dist/journal-entry/journal-entry.repository.js +5 -38
- package/dist/journal-entry/journal-entry.repository.js.map +1 -1
- package/dist/ledger-transaction/interfaces/ledger-transaction-attr.interface.d.ts +0 -4
- package/dist/ledger-transaction/ledger-transaction.d.ts +6 -5
- package/dist/ledger-transaction/ledger-transaction.js +6 -9
- package/dist/ledger-transaction/ledger-transaction.js.map +1 -1
- package/dist/ledger-transaction/ledger-transaction.repository.d.ts +3 -8
- package/dist/ledger-transaction/ledger-transaction.repository.js +5 -32
- package/dist/ledger-transaction/ledger-transaction.repository.js.map +1 -1
- package/dist/models/account.entity.d.ts +7 -3
- package/dist/models/account.entity.js +69 -34
- package/dist/models/account.entity.js.map +1 -1
- package/dist/models/finance-company.entity.d.ts +0 -4
- package/dist/models/finance-company.entity.js +0 -20
- package/dist/models/finance-company.entity.js.map +1 -1
- package/dist/models/payment-item.entity.d.ts +1 -0
- package/dist/models/payment-item.entity.js +7 -0
- package/dist/models/payment-item.entity.js.map +1 -1
- package/dist/models/payment-method-type.entity.d.ts +13 -0
- package/dist/models/payment-method-type.entity.js +86 -0
- package/dist/models/payment-method-type.entity.js.map +1 -0
- package/dist/models/payment-method.entity.d.ts +7 -0
- package/dist/models/payment-method.entity.js +46 -0
- package/dist/models/payment-method.entity.js.map +1 -0
- package/dist/models/payment.entity.d.ts +15 -10
- package/dist/models/payment.entity.js +92 -34
- package/dist/models/payment.entity.js.map +1 -1
- package/dist/payment/interfaces/payment-attr.interface.d.ts +11 -8
- package/dist/payment/interfaces/payment-attr.interface.js.map +1 -1
- package/dist/payment/interfaces/payment-item-attr.interface.d.ts +1 -0
- package/dist/payment/interfaces/payment-item-attr.interface.js.map +1 -1
- package/dist/payment/payment-item.repository.d.ts +3 -15
- package/dist/payment/payment-item.repository.js +4 -43
- package/dist/payment/payment-item.repository.js.map +1 -1
- package/dist/payment/payment.d.ts +44 -48
- package/dist/payment/payment.js +122 -133
- package/dist/payment/payment.js.map +1 -1
- package/dist/payment/payment.repository.d.ts +3 -14
- package/dist/payment/payment.repository.js +4 -39
- package/dist/payment/payment.repository.js.map +1 -1
- package/dist/payment-item/interfaces/payment-item-attr.interface.d.ts +8 -0
- package/dist/payment-item/interfaces/payment-item-attr.interface.js +7 -0
- package/dist/payment-item/interfaces/payment-item-attr.interface.js.map +1 -0
- package/{src/payment/interfaces/payment-item.repository.interface.ts → dist/payment-item/interfaces/payment-item.repository.interface.d.ts} +0 -1
- package/dist/payment-item/interfaces/payment-item.repository.interface.js +3 -0
- package/dist/payment-item/interfaces/payment-item.repository.interface.js.map +1 -0
- package/dist/payment-item/payment-item.d.ts +19 -0
- package/dist/payment-item/payment-item.js +42 -0
- package/dist/payment-item/payment-item.js.map +1 -0
- package/dist/payment-item/payment-item.repository.d.ts +5 -0
- package/dist/payment-item/payment-item.repository.js +12 -0
- package/dist/payment-item/payment-item.repository.js.map +1 -0
- package/dist/payment-method/interfaces/payment-method-attr.interface.d.ts +4 -0
- package/dist/payment-method/interfaces/payment-method-attr.interface.js +3 -0
- package/dist/payment-method/interfaces/payment-method-attr.interface.js.map +1 -0
- package/dist/payment-method/payment-method.d.ts +17 -0
- package/dist/payment-method/payment-method.js +83 -0
- package/dist/payment-method/payment-method.js.map +1 -0
- package/dist/payment-method/payment-method.repository.d.ts +5 -0
- package/dist/payment-method/payment-method.repository.js +12 -0
- package/dist/payment-method/payment-method.repository.js.map +1 -0
- package/dist/payment-method-type/interfaces/payment-method-type-attr.interface.d.ts +8 -0
- package/dist/payment-method-type/interfaces/payment-method-type-attr.interface.js +3 -0
- package/dist/payment-method-type/interfaces/payment-method-type-attr.interface.js.map +1 -0
- package/dist/payment-method-type/payment-method-type.d.ts +15 -0
- package/dist/payment-method-type/payment-method-type.js +55 -0
- package/dist/payment-method-type/payment-method-type.js.map +1 -0
- package/dist/payment-method-type/payment-method-type.repository.d.ts +5 -0
- package/dist/payment-method-type/payment-method-type.repository.js +12 -0
- package/dist/payment-method-type/payment-method-type.repository.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/migrations/finance-account-migration.js +30 -16
- package/migrations/finance-company-migration.js +0 -14
- package/migrations/finance-payment-item-migration.js +4 -0
- package/migrations/finance-payment-method-migration.js +21 -0
- package/migrations/finance-payment-method-type-migration.js +55 -0
- package/migrations/finance-payment-migration.js +42 -25
- package/package.json +4 -4
- package/src/account/account.repository.ts +5 -38
- package/src/account/account.ts +115 -98
- package/src/account/interfaces/account-attr.interface.ts +15 -7
- package/src/account-system-entity/account-system-entity.ts +4 -4
- package/src/account-system-entity/post-history.repository.ts +3 -3
- package/src/customer/customer.ts +3 -3
- package/src/customer/finance-customer.repository.ts +2 -2
- package/src/customer/interfaces/finance-customer.repository.interface.ts +2 -2
- package/src/document/document-item.repository.ts +5 -43
- package/src/document/document-item.ts +5 -1
- package/src/document/document.repository.ts +5 -35
- package/src/document/document.ts +127 -74
- package/src/document/interfaces/document-item.repository.interface.ts +2 -2
- package/src/enum/index.ts +2 -0
- package/src/enum/payment-status.enum.ts +4 -0
- package/src/enum/transaction-type.enum.ts +2 -2
- package/src/finance-company/finance-company.repository.ts +3 -3
- package/src/finance-company/finance-company.ts +685 -48
- package/src/index.ts +13 -7
- package/src/interfaces/account-system.interface.ts +2 -2
- package/src/journal-entry/journal-entry.repository.ts +5 -34
- package/src/journal-entry/journal-entry.ts +163 -63
- package/src/ledger-transaction/interfaces/ledger-transaction-attr.interface.ts +0 -5
- package/src/ledger-transaction/ledger-transaction.repository.ts +5 -24
- package/src/ledger-transaction/ledger-transaction.ts +8 -12
- package/src/models/account.entity.ts +67 -32
- package/src/models/finance-company.entity.ts +0 -16
- package/src/models/payment-item.entity.ts +6 -0
- package/src/models/payment-method-type.entity.ts +70 -0
- package/src/models/payment-method.entity.ts +28 -0
- package/src/models/payment.entity.ts +86 -31
- package/src/payment/interfaces/payment-attr.interface.ts +11 -8
- package/src/payment/payment.repository.ts +5 -35
- package/src/payment/payment.ts +183 -181
- package/src/{payment → payment-item}/interfaces/payment-item-attr.interface.ts +1 -0
- package/src/payment-item/payment-item.repository.ts +11 -0
- package/src/payment-item/payment-item.ts +54 -0
- package/src/payment-method/interfaces/payment-method-attr.interface.ts +4 -0
- package/src/payment-method/payment-method.repository.ts +11 -0
- package/src/payment-method/payment-method.ts +95 -0
- package/src/payment-method-type/interfaces/payment-method-type-attr.interface.ts +8 -0
- package/src/payment-method-type/payment-method-type.repository.ts +11 -0
- package/src/payment-method-type/payment-method-type.ts +58 -0
- package/src/account/interfaces/account.repository.interface.ts +0 -4
- package/src/document/interfaces/document.repository.interface.ts +0 -4
- package/src/journal-entry/interfaces/journal-entry.repository.interface.ts +0 -11
- package/src/payment/interfaces/payment.repository.interface.ts +0 -4
- package/src/payment/payment-item.repository.ts +0 -49
|
@@ -10,10 +10,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const axios_1 = require("axios");
|
|
13
|
-
const general_1 = require("@tomei/general");
|
|
14
|
-
const common_1 = require("@nestjs/common");
|
|
15
13
|
const cuid = require("cuid");
|
|
14
|
+
const general_1 = require("@tomei/general");
|
|
15
|
+
const journal_entry_1 = require("../journal-entry/journal-entry");
|
|
16
16
|
const finance_company_repository_1 = require("./finance-company.repository");
|
|
17
|
+
const enum_1 = require("../enum");
|
|
18
|
+
const payment_method_type_1 = require("../payment-method-type/payment-method-type");
|
|
19
|
+
const payment_repository_1 = require("../payment/payment.repository");
|
|
20
|
+
const payment_item_repository_1 = require("../payment-item/payment-item.repository");
|
|
21
|
+
const document_repository_1 = require("../document/document.repository");
|
|
22
|
+
const document_item_repository_1 = require("../document/document-item.repository");
|
|
23
|
+
const { getConfig } = require('../config');
|
|
24
|
+
const config = getConfig();
|
|
17
25
|
class FinanceCompany extends general_1.ObjectBase {
|
|
18
26
|
get CompSystemCode() {
|
|
19
27
|
return this._CompSystemCode;
|
|
@@ -33,9 +41,6 @@ class FinanceCompany extends general_1.ObjectBase {
|
|
|
33
41
|
set AccSystemCode(code) {
|
|
34
42
|
this._AccSystemCode = code;
|
|
35
43
|
}
|
|
36
|
-
get AccSystemRefId() {
|
|
37
|
-
return this._AccSystemRefId;
|
|
38
|
-
}
|
|
39
44
|
get CompanyId() {
|
|
40
45
|
return this._CompanyId;
|
|
41
46
|
}
|
|
@@ -57,7 +62,6 @@ class FinanceCompany extends general_1.ObjectBase {
|
|
|
57
62
|
this._CompSystemCode = '';
|
|
58
63
|
this._CompSystemRefId = '';
|
|
59
64
|
this._AccSystemCode = '';
|
|
60
|
-
this._AccSystemRefId = '';
|
|
61
65
|
this.CompSystemCode = compSystemCode;
|
|
62
66
|
this.CompSystemRefId = compSystemRefId;
|
|
63
67
|
this.AccSystemCode = accSystemCode;
|
|
@@ -68,7 +72,7 @@ class FinanceCompany extends general_1.ObjectBase {
|
|
|
68
72
|
const sKey = `${compSystemCode}-${compSystemRefId}-${accSystemCode}`;
|
|
69
73
|
if (!FinanceCompany._htFinanceCompanyIds.get(sKey)) {
|
|
70
74
|
const financeCompany = new FinanceCompany(compSystemCode, compSystemRefId, accSystemCode);
|
|
71
|
-
const company = yield FinanceCompany.
|
|
75
|
+
const company = yield FinanceCompany._financeCompanyRepository.findOne({
|
|
72
76
|
where: {
|
|
73
77
|
CompSystemCode: compSystemCode,
|
|
74
78
|
CompSystemRefId: compSystemRefId,
|
|
@@ -89,7 +93,7 @@ class FinanceCompany extends general_1.ObjectBase {
|
|
|
89
93
|
static getFinanceCompany(companyId) {
|
|
90
94
|
return __awaiter(this, void 0, void 0, function* () {
|
|
91
95
|
if (!FinanceCompany._htFinanceCompanies.get(companyId)) {
|
|
92
|
-
const company = yield FinanceCompany.
|
|
96
|
+
const company = yield FinanceCompany._financeCompanyRepository.findOne({
|
|
93
97
|
where: { CompanyId: companyId },
|
|
94
98
|
});
|
|
95
99
|
if (!company) {
|
|
@@ -111,7 +115,7 @@ class FinanceCompany extends general_1.ObjectBase {
|
|
|
111
115
|
static createFinanceCompany(dbTransaction, loginUser, compSystemCode, compSystemRefId, accSystemCode) {
|
|
112
116
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
117
|
const financeCompany = new FinanceCompany(compSystemCode, compSystemRefId, accSystemCode);
|
|
114
|
-
const company = yield FinanceCompany.
|
|
118
|
+
const company = yield FinanceCompany._financeCompanyRepository.findOne({
|
|
115
119
|
where: {
|
|
116
120
|
CompSystemCode: compSystemCode,
|
|
117
121
|
CompSystemRefId: compSystemRefId,
|
|
@@ -122,12 +126,11 @@ class FinanceCompany extends general_1.ObjectBase {
|
|
|
122
126
|
throw Error('There is already another Finance Company with the compSystemCode, CompSystemRefId and accSystemCode specified.');
|
|
123
127
|
}
|
|
124
128
|
financeCompany.ObjectId = cuid();
|
|
125
|
-
yield FinanceCompany.
|
|
129
|
+
yield FinanceCompany._financeCompanyRepository.create({
|
|
126
130
|
CompanyId: financeCompany.CompanyId,
|
|
127
131
|
CompSystemCode: financeCompany.CompSystemCode,
|
|
128
132
|
CompSystemRefId: financeCompany.CompSystemRefId,
|
|
129
133
|
AccSystemCode: financeCompany.AccSystemCode,
|
|
130
|
-
AccSystemRefId: financeCompany.AccSystemRefId,
|
|
131
134
|
}, {
|
|
132
135
|
transaction: dbTransaction,
|
|
133
136
|
});
|
|
@@ -140,7 +143,7 @@ class FinanceCompany extends general_1.ObjectBase {
|
|
|
140
143
|
return __awaiter(this, void 0, void 0, function* () {
|
|
141
144
|
try {
|
|
142
145
|
if (customer.CustSystemCode || customer.CustSystemRefId) {
|
|
143
|
-
throw new
|
|
146
|
+
throw new Error('CustSystemCode and CustomerRefId are required fields.');
|
|
144
147
|
}
|
|
145
148
|
const financeCustomerData = yield this.financeCustomerRepository.findOne({
|
|
146
149
|
where: {
|
|
@@ -150,7 +153,7 @@ class FinanceCompany extends general_1.ObjectBase {
|
|
|
150
153
|
},
|
|
151
154
|
});
|
|
152
155
|
if (financeCustomerData) {
|
|
153
|
-
throw new
|
|
156
|
+
throw new Error('Customer already created previously.');
|
|
154
157
|
}
|
|
155
158
|
const customerId = yield this.AccountingSystem.createCustomer({
|
|
156
159
|
customer,
|
|
@@ -167,7 +170,7 @@ class FinanceCompany extends general_1.ObjectBase {
|
|
|
167
170
|
PerformedAt: new Date(),
|
|
168
171
|
EntityId: newCustomer.CustomerId,
|
|
169
172
|
};
|
|
170
|
-
yield axios_1.default.post(`${
|
|
173
|
+
yield axios_1.default.post(`${config.commonApiUrl}/activity-histories`, payload);
|
|
171
174
|
return customer;
|
|
172
175
|
}
|
|
173
176
|
catch (error) {
|
|
@@ -176,20 +179,20 @@ class FinanceCompany extends general_1.ObjectBase {
|
|
|
176
179
|
});
|
|
177
180
|
}
|
|
178
181
|
postJournal(dbTransaction, journalEntry) {
|
|
179
|
-
var _a, _b;
|
|
180
182
|
return __awaiter(this, void 0, void 0, function* () {
|
|
183
|
+
const debitTransactions = yield journalEntry.DebitTransactions;
|
|
184
|
+
const creditTransactions = yield journalEntry.CreditTransactions;
|
|
181
185
|
try {
|
|
182
|
-
if (
|
|
183
|
-
(
|
|
184
|
-
throw new common_1.BadRequestException('There should be at least 1 debit ledger transaction and 1 credit ledger transaction in the journal entry');
|
|
186
|
+
if (creditTransactions.length < 1 || (debitTransactions === null || debitTransactions === void 0 ? void 0 : debitTransactions.length) < 1) {
|
|
187
|
+
throw new Error('There should be at least 1 debit ledger transaction and 1 credit ledger transaction in the journal entry');
|
|
185
188
|
}
|
|
186
|
-
const totalCreditAmount =
|
|
187
|
-
const totalDebitAmount =
|
|
189
|
+
const totalCreditAmount = creditTransactions.reduce((accumulator, currentValue) => accumulator + currentValue.CreditAmount, 0);
|
|
190
|
+
const totalDebitAmount = debitTransactions.reduce((accumulator, currentValue) => accumulator + currentValue.DebitAmount, 0);
|
|
188
191
|
if (totalCreditAmount !== totalDebitAmount) {
|
|
189
|
-
throw new
|
|
192
|
+
throw new Error('Credit ledger transaction and debit ledger transaction should the same amount');
|
|
190
193
|
}
|
|
191
194
|
const newJournalEntry = yield journalEntry.save('test', dbTransaction);
|
|
192
|
-
const allLedgerTransactions = yield this.ledgerTransactionRepository.findAll();
|
|
195
|
+
const allLedgerTransactions = yield this.ledgerTransactionRepository.findAll({});
|
|
193
196
|
for (const ledgerTransaction of allLedgerTransactions) {
|
|
194
197
|
ledgerTransaction.JournalEntryId = newJournalEntry.JournalEntryId;
|
|
195
198
|
ledgerTransaction.save();
|
|
@@ -206,7 +209,7 @@ class FinanceCompany extends general_1.ObjectBase {
|
|
|
206
209
|
PerformedAt: new Date(),
|
|
207
210
|
EntityId: newJournalEntry.JournalEntryId,
|
|
208
211
|
};
|
|
209
|
-
yield axios_1.default.post(`${
|
|
212
|
+
yield axios_1.default.post(`${config.commonApiUrl}/activity-histories`, payload);
|
|
210
213
|
}
|
|
211
214
|
catch (error) {
|
|
212
215
|
throw error;
|
|
@@ -218,13 +221,13 @@ class FinanceCompany extends general_1.ObjectBase {
|
|
|
218
221
|
try {
|
|
219
222
|
account.validateAccountValue();
|
|
220
223
|
let createAccountPayload = {
|
|
221
|
-
Name: account.
|
|
224
|
+
Name: account.Name,
|
|
222
225
|
AcctNum: account.AccountNo,
|
|
223
|
-
AccountType: account.
|
|
224
|
-
AccountSubType: account.
|
|
226
|
+
AccountType: account.AccountType,
|
|
227
|
+
AccountSubType: account.AccountSubtype,
|
|
225
228
|
};
|
|
226
|
-
if (account.
|
|
227
|
-
createAccountPayload = Object.assign(Object.assign({}, createAccountPayload), { CurrencyRef: 'MYR', ParentRef: account.
|
|
229
|
+
if (account.isParentAccountExists()) {
|
|
230
|
+
createAccountPayload = Object.assign(Object.assign({}, createAccountPayload), { CurrencyRef: 'MYR', ParentRef: account.ParentAccountNo, SubAccount: true });
|
|
228
231
|
}
|
|
229
232
|
const accSystemAccountId = yield this.AccountingSystem.createAccount(createAccountPayload);
|
|
230
233
|
const newAccount = yield account.save(accSystemAccountId, 'test', dbTransaction);
|
|
@@ -239,7 +242,7 @@ class FinanceCompany extends general_1.ObjectBase {
|
|
|
239
242
|
PerformedAt: new Date(),
|
|
240
243
|
EntityId: newAccount.AccountNo,
|
|
241
244
|
};
|
|
242
|
-
yield axios_1.default.post(`${
|
|
245
|
+
yield axios_1.default.post(`${config.commonApiUrl}/activity-histories`, payload);
|
|
243
246
|
return account;
|
|
244
247
|
}
|
|
245
248
|
catch (error) {
|
|
@@ -247,9 +250,449 @@ class FinanceCompany extends general_1.ObjectBase {
|
|
|
247
250
|
}
|
|
248
251
|
});
|
|
249
252
|
}
|
|
253
|
+
issueInvoice(dbTransaction, loginUser, invoice, customer, dtAccountNo) {
|
|
254
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
255
|
+
try {
|
|
256
|
+
const duplicateInvoice = yield FinanceCompany._DocumentRepository.findOne({
|
|
257
|
+
where: {
|
|
258
|
+
DocNo: invoice.DocNo,
|
|
259
|
+
},
|
|
260
|
+
transaction: dbTransaction,
|
|
261
|
+
});
|
|
262
|
+
if (duplicateInvoice) {
|
|
263
|
+
throw new Error('Invoice number already exists');
|
|
264
|
+
}
|
|
265
|
+
const documentItems = yield invoice.DocumentItems;
|
|
266
|
+
if (!documentItems.length) {
|
|
267
|
+
throw new Error('Document must have at least 1 document item');
|
|
268
|
+
}
|
|
269
|
+
for (const invoiceItem of documentItems) {
|
|
270
|
+
if (!invoiceItem.CtAccountNo) {
|
|
271
|
+
throw new Error('Each document item should have CtAccountNo provided');
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
invoice.DocType = enum_1.DocType.INVOICE;
|
|
275
|
+
yield FinanceCompany._DocumentRepository.create({
|
|
276
|
+
DocNo: invoice.DocNo,
|
|
277
|
+
DocType: invoice.DocType,
|
|
278
|
+
DocDate: invoice.DocDate,
|
|
279
|
+
CompanyId: invoice.CompanyId,
|
|
280
|
+
Currency: invoice.Currency,
|
|
281
|
+
Amount: invoice.Amount,
|
|
282
|
+
Description: invoice.Description,
|
|
283
|
+
Status: invoice.Status,
|
|
284
|
+
IssuedById: loginUser.ObjectId,
|
|
285
|
+
IssuedToId: customer.ObjectId,
|
|
286
|
+
IssuedToType: invoice.IssuedToType,
|
|
287
|
+
CreatedById: loginUser.ObjectId,
|
|
288
|
+
CreatedAt: new Date(),
|
|
289
|
+
UpdatedById: loginUser.ObjectId,
|
|
290
|
+
UpdatedAt: new Date(),
|
|
291
|
+
DocPDFFileMediaId: invoice.DocPDFFileMediaId,
|
|
292
|
+
DocHTMLFileMediaId: invoice.DocHTMLFileMediaId,
|
|
293
|
+
AccSystemRefId: invoice.AccSystemRefId,
|
|
294
|
+
PostedToAccSystemYN: invoice.PostedToAccSystemYN,
|
|
295
|
+
PostedById: invoice.PostedById,
|
|
296
|
+
PostedDateTime: new Date(),
|
|
297
|
+
UseAccSystemDocYN: invoice.UseAccSystemDocYN,
|
|
298
|
+
}, {
|
|
299
|
+
transaction: dbTransaction,
|
|
300
|
+
});
|
|
301
|
+
documentItems.forEach((documentItem) => __awaiter(this, void 0, void 0, function* () {
|
|
302
|
+
yield FinanceCompany._DocumentItemRepository.create({
|
|
303
|
+
DocumentItemId: documentItem.DocumentItemId,
|
|
304
|
+
DocNo: documentItem.DocNo,
|
|
305
|
+
Name: documentItem.Name,
|
|
306
|
+
NameBM: documentItem.NameBM,
|
|
307
|
+
Description: documentItem.Description,
|
|
308
|
+
ItemId: documentItem.ItemId,
|
|
309
|
+
ItemType: documentItem.ItemType,
|
|
310
|
+
ItemSKU: documentItem.ItemSKU,
|
|
311
|
+
ItemSerialNo: documentItem.ItemSerialNo,
|
|
312
|
+
Currency: documentItem.Currency,
|
|
313
|
+
UnitPrice: documentItem.UnitPrice,
|
|
314
|
+
Quantity: documentItem.Quantity,
|
|
315
|
+
QuantityUOM: documentItem.QuantityUOM,
|
|
316
|
+
Amount: documentItem.Amount,
|
|
317
|
+
TaxCode: documentItem.TaxCode,
|
|
318
|
+
TaxAmount: documentItem.TaxAmount,
|
|
319
|
+
TaxRate: documentItem.TaxRate,
|
|
320
|
+
TaxInclusiveYN: documentItem.TaxInclusiveYN,
|
|
321
|
+
DtAccountNo: documentItem.DtAccountNo,
|
|
322
|
+
CtAccountNo: documentItem.CtAccountNo,
|
|
323
|
+
}, {
|
|
324
|
+
transaction: dbTransaction,
|
|
325
|
+
});
|
|
326
|
+
}));
|
|
327
|
+
if (invoice.UseAccSystemDocYN) {
|
|
328
|
+
yield this.AccountingSystem.createInvoice(invoice);
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
invoice.generateInvoice(loginUser.IDNo, customer);
|
|
332
|
+
}
|
|
333
|
+
const journalEntry = new journal_entry_1.default(dbTransaction);
|
|
334
|
+
const transactionDate = new Date();
|
|
335
|
+
const ledgerTransaction = yield journalEntry.newLedgerTransaction(enum_1.TransactionTypeOptions.DEBIT);
|
|
336
|
+
if (dtAccountNo) {
|
|
337
|
+
ledgerTransaction.AccountNo = dtAccountNo;
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
ledgerTransaction.AccountNo = customer.CustSystemCode + '-AR';
|
|
341
|
+
}
|
|
342
|
+
ledgerTransaction.Currency = invoice.Currency;
|
|
343
|
+
ledgerTransaction.DebitAmount = invoice.Amount;
|
|
344
|
+
ledgerTransaction.Date = transactionDate;
|
|
345
|
+
ledgerTransaction.Name = invoice.DocNo;
|
|
346
|
+
for (const invoiceItem of documentItems) {
|
|
347
|
+
const itemLedger = yield journalEntry.newLedgerTransaction(enum_1.TransactionTypeOptions.CREDIT);
|
|
348
|
+
itemLedger.AccountNo = invoiceItem.CtAccountNo;
|
|
349
|
+
itemLedger.Currency = invoiceItem.Currency;
|
|
350
|
+
itemLedger.CreditAmount = invoiceItem.Amount;
|
|
351
|
+
itemLedger.Date = transactionDate;
|
|
352
|
+
itemLedger.Name = invoiceItem.Name;
|
|
353
|
+
}
|
|
354
|
+
this.postJournal(dbTransaction, journalEntry);
|
|
355
|
+
const payload = {
|
|
356
|
+
Action: 'Create',
|
|
357
|
+
Activity: 'Issuing an Invoice',
|
|
358
|
+
Description: `Ledger Transaction (ID: ${ledgerTransaction.TransactionId}) has been created`,
|
|
359
|
+
EntityType: 'LedgerTransaction',
|
|
360
|
+
EntityValueBefore: JSON.stringify({}),
|
|
361
|
+
EntityValueAfter: JSON.stringify(ledgerTransaction),
|
|
362
|
+
PerformedById: 'test',
|
|
363
|
+
PerformedAt: new Date(),
|
|
364
|
+
EntityId: ledgerTransaction.TransactionId,
|
|
365
|
+
};
|
|
366
|
+
yield axios_1.default.post(`${config.commonApiUrl}/activity-histories`, payload);
|
|
367
|
+
return invoice;
|
|
368
|
+
}
|
|
369
|
+
catch (err) {
|
|
370
|
+
console.log('Issue invoice err: ', err);
|
|
371
|
+
throw err;
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
issueDebitNote(dbTransaction, loginUser, invoice, customer, dtAccountNo) {
|
|
376
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
377
|
+
try {
|
|
378
|
+
const duplicateInvoice = yield FinanceCompany._DocumentRepository.findOne({
|
|
379
|
+
where: {
|
|
380
|
+
DocNo: invoice.DocNo,
|
|
381
|
+
},
|
|
382
|
+
transaction: dbTransaction,
|
|
383
|
+
});
|
|
384
|
+
if (duplicateInvoice) {
|
|
385
|
+
throw new Error('Invoice number already exists');
|
|
386
|
+
}
|
|
387
|
+
const documentItems = yield invoice.DocumentItems;
|
|
388
|
+
if (!documentItems.length) {
|
|
389
|
+
throw new Error('Document must have at least 1 document item');
|
|
390
|
+
}
|
|
391
|
+
for (const invoiceItem of documentItems) {
|
|
392
|
+
if (!invoiceItem.CtAccountNo) {
|
|
393
|
+
throw new Error('Each document item should have CtAccountNo provided');
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
invoice.DocType = enum_1.DocType.DEBIT_NOTE;
|
|
397
|
+
yield FinanceCompany._DocumentRepository.create({
|
|
398
|
+
DocNo: invoice.DocNo,
|
|
399
|
+
DocType: invoice.DocType,
|
|
400
|
+
DocDate: invoice.DocDate,
|
|
401
|
+
CompanyId: invoice.CompanyId,
|
|
402
|
+
Currency: invoice.Currency,
|
|
403
|
+
Amount: invoice.Amount,
|
|
404
|
+
Description: invoice.Description,
|
|
405
|
+
Status: invoice.Status,
|
|
406
|
+
IssuedById: loginUser.ObjectId,
|
|
407
|
+
IssuedToId: customer.ObjectId,
|
|
408
|
+
IssuedToType: invoice.IssuedToType,
|
|
409
|
+
CreatedById: loginUser.ObjectId,
|
|
410
|
+
CreatedAt: new Date(),
|
|
411
|
+
UpdatedById: loginUser.ObjectId,
|
|
412
|
+
UpdatedAt: new Date(),
|
|
413
|
+
DocPDFFileMediaId: invoice.DocPDFFileMediaId,
|
|
414
|
+
DocHTMLFileMediaId: invoice.DocHTMLFileMediaId,
|
|
415
|
+
AccSystemRefId: invoice.AccSystemRefId,
|
|
416
|
+
PostedToAccSystemYN: invoice.PostedToAccSystemYN,
|
|
417
|
+
PostedById: invoice.PostedById,
|
|
418
|
+
PostedDateTime: new Date(),
|
|
419
|
+
UseAccSystemDocYN: invoice.UseAccSystemDocYN,
|
|
420
|
+
}, {
|
|
421
|
+
transaction: dbTransaction,
|
|
422
|
+
});
|
|
423
|
+
documentItems.forEach((documentItem) => __awaiter(this, void 0, void 0, function* () {
|
|
424
|
+
yield FinanceCompany._DocumentItemRepository.create({
|
|
425
|
+
DocumentItemId: documentItem.DocumentItemId,
|
|
426
|
+
DocNo: documentItem.DocNo,
|
|
427
|
+
Name: documentItem.Name,
|
|
428
|
+
NameBM: documentItem.NameBM,
|
|
429
|
+
Description: documentItem.Description,
|
|
430
|
+
ItemId: documentItem.ItemId,
|
|
431
|
+
ItemType: documentItem.ItemType,
|
|
432
|
+
ItemSKU: documentItem.ItemSKU,
|
|
433
|
+
ItemSerialNo: documentItem.ItemSerialNo,
|
|
434
|
+
Currency: documentItem.Currency,
|
|
435
|
+
UnitPrice: documentItem.UnitPrice,
|
|
436
|
+
Quantity: documentItem.Quantity,
|
|
437
|
+
QuantityUOM: documentItem.QuantityUOM,
|
|
438
|
+
Amount: documentItem.Amount,
|
|
439
|
+
TaxCode: documentItem.TaxCode,
|
|
440
|
+
TaxAmount: documentItem.TaxAmount,
|
|
441
|
+
TaxRate: documentItem.TaxRate,
|
|
442
|
+
TaxInclusiveYN: documentItem.TaxInclusiveYN,
|
|
443
|
+
DtAccountNo: documentItem.DtAccountNo,
|
|
444
|
+
CtAccountNo: documentItem.CtAccountNo,
|
|
445
|
+
}, {
|
|
446
|
+
transaction: dbTransaction,
|
|
447
|
+
});
|
|
448
|
+
}));
|
|
449
|
+
if (invoice.UseAccSystemDocYN) {
|
|
450
|
+
yield this.AccountingSystem.createInvoice(invoice);
|
|
451
|
+
}
|
|
452
|
+
else {
|
|
453
|
+
invoice.generateInvoice(loginUser.IDNo, customer);
|
|
454
|
+
}
|
|
455
|
+
const journalEntry = new journal_entry_1.default(dbTransaction);
|
|
456
|
+
const transactionDate = new Date();
|
|
457
|
+
const debitTransaction = yield journalEntry.newLedgerTransaction(enum_1.TransactionTypeOptions.DEBIT);
|
|
458
|
+
if (dtAccountNo) {
|
|
459
|
+
debitTransaction.AccountNo = dtAccountNo;
|
|
460
|
+
}
|
|
461
|
+
else {
|
|
462
|
+
debitTransaction.AccountNo = customer.CustSystemCode + '-AR';
|
|
463
|
+
}
|
|
464
|
+
debitTransaction.Currency = invoice.Currency;
|
|
465
|
+
debitTransaction.DebitAmount = invoice.Amount;
|
|
466
|
+
debitTransaction.Date = transactionDate;
|
|
467
|
+
debitTransaction.Name = invoice.DocNo;
|
|
468
|
+
for (const invoiceItem of documentItems) {
|
|
469
|
+
const itemLedger = yield journalEntry.newLedgerTransaction(enum_1.TransactionTypeOptions.CREDIT);
|
|
470
|
+
itemLedger.AccountNo = invoiceItem.CtAccountNo;
|
|
471
|
+
itemLedger.Currency = invoiceItem.Currency;
|
|
472
|
+
itemLedger.CreditAmount = invoiceItem.Amount;
|
|
473
|
+
itemLedger.Date = transactionDate;
|
|
474
|
+
itemLedger.Name = invoiceItem.Name;
|
|
475
|
+
}
|
|
476
|
+
this.postJournal(dbTransaction, journalEntry);
|
|
477
|
+
const payload = {
|
|
478
|
+
Action: 'Create',
|
|
479
|
+
Activity: 'Issuing a Debit Note',
|
|
480
|
+
Description: `Debit Transaction (ID: ${debitTransaction.TransactionId}) has been created`,
|
|
481
|
+
EntityType: 'DebitTransaction',
|
|
482
|
+
EntityValueBefore: JSON.stringify({}),
|
|
483
|
+
EntityValueAfter: JSON.stringify(debitTransaction),
|
|
484
|
+
PerformedById: 'test',
|
|
485
|
+
PerformedAt: new Date(),
|
|
486
|
+
EntityId: debitTransaction.TransactionId,
|
|
487
|
+
};
|
|
488
|
+
yield axios_1.default.post(`${config.commonApiUrl}/activity-histories`, payload);
|
|
489
|
+
return invoice;
|
|
490
|
+
}
|
|
491
|
+
catch (err) {
|
|
492
|
+
console.log('Issue debit note err: ', err);
|
|
493
|
+
throw err;
|
|
494
|
+
}
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
issueCreditNote(dbTransaction, loginUser, creditNote, customer, ctAccountNo) {
|
|
498
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
499
|
+
try {
|
|
500
|
+
const duplicateCreditNote = yield FinanceCompany._DocumentRepository.findOne({
|
|
501
|
+
where: {
|
|
502
|
+
DocNo: creditNote.DocNo,
|
|
503
|
+
},
|
|
504
|
+
transaction: dbTransaction,
|
|
505
|
+
});
|
|
506
|
+
if (duplicateCreditNote) {
|
|
507
|
+
throw new Error('Invoice number already exists');
|
|
508
|
+
}
|
|
509
|
+
const documentItems = yield creditNote.DocumentItems;
|
|
510
|
+
if (!documentItems.length) {
|
|
511
|
+
throw new Error('Document must have at least 1 document item');
|
|
512
|
+
}
|
|
513
|
+
for (const invoiceItem of documentItems) {
|
|
514
|
+
if (!invoiceItem.CtAccountNo) {
|
|
515
|
+
throw new Error('Each document item should have CtAccountNo provided');
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
creditNote.DocType = enum_1.DocType.DEBIT_NOTE;
|
|
519
|
+
yield FinanceCompany._DocumentRepository.create({
|
|
520
|
+
DocNo: creditNote.DocNo,
|
|
521
|
+
DocType: creditNote.DocType,
|
|
522
|
+
DocDate: creditNote.DocDate,
|
|
523
|
+
CompanyId: creditNote.CompanyId,
|
|
524
|
+
Currency: creditNote.Currency,
|
|
525
|
+
Amount: creditNote.Amount,
|
|
526
|
+
Description: creditNote.Description,
|
|
527
|
+
Status: creditNote.Status,
|
|
528
|
+
IssuedById: loginUser.ObjectId,
|
|
529
|
+
IssuedToId: customer.ObjectId,
|
|
530
|
+
IssuedToType: creditNote.IssuedToType,
|
|
531
|
+
CreatedById: loginUser.ObjectId,
|
|
532
|
+
CreatedAt: new Date(),
|
|
533
|
+
UpdatedById: loginUser.ObjectId,
|
|
534
|
+
UpdatedAt: new Date(),
|
|
535
|
+
DocPDFFileMediaId: creditNote.DocPDFFileMediaId,
|
|
536
|
+
DocHTMLFileMediaId: creditNote.DocHTMLFileMediaId,
|
|
537
|
+
AccSystemRefId: creditNote.AccSystemRefId,
|
|
538
|
+
PostedToAccSystemYN: creditNote.PostedToAccSystemYN,
|
|
539
|
+
PostedById: creditNote.PostedById,
|
|
540
|
+
PostedDateTime: new Date(),
|
|
541
|
+
UseAccSystemDocYN: creditNote.UseAccSystemDocYN,
|
|
542
|
+
}, {
|
|
543
|
+
transaction: dbTransaction,
|
|
544
|
+
});
|
|
545
|
+
documentItems.forEach((documentItem) => __awaiter(this, void 0, void 0, function* () {
|
|
546
|
+
yield FinanceCompany._DocumentItemRepository.create({
|
|
547
|
+
DocumentItemId: documentItem.DocumentItemId,
|
|
548
|
+
DocNo: documentItem.DocNo,
|
|
549
|
+
Name: documentItem.Name,
|
|
550
|
+
NameBM: documentItem.NameBM,
|
|
551
|
+
Description: documentItem.Description,
|
|
552
|
+
ItemId: documentItem.ItemId,
|
|
553
|
+
ItemType: documentItem.ItemType,
|
|
554
|
+
ItemSKU: documentItem.ItemSKU,
|
|
555
|
+
ItemSerialNo: documentItem.ItemSerialNo,
|
|
556
|
+
Currency: documentItem.Currency,
|
|
557
|
+
UnitPrice: documentItem.UnitPrice,
|
|
558
|
+
Quantity: documentItem.Quantity,
|
|
559
|
+
QuantityUOM: documentItem.QuantityUOM,
|
|
560
|
+
Amount: documentItem.Amount,
|
|
561
|
+
TaxCode: documentItem.TaxCode,
|
|
562
|
+
TaxAmount: documentItem.TaxAmount,
|
|
563
|
+
TaxRate: documentItem.TaxRate,
|
|
564
|
+
TaxInclusiveYN: documentItem.TaxInclusiveYN,
|
|
565
|
+
DtAccountNo: documentItem.DtAccountNo,
|
|
566
|
+
CtAccountNo: documentItem.CtAccountNo,
|
|
567
|
+
}, {
|
|
568
|
+
transaction: dbTransaction,
|
|
569
|
+
});
|
|
570
|
+
}));
|
|
571
|
+
if (creditNote.UseAccSystemDocYN) {
|
|
572
|
+
yield this.AccountingSystem.createCreditNote(creditNote);
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
creditNote.generateCreditNote(loginUser.IDNo, customer);
|
|
576
|
+
}
|
|
577
|
+
const journalEntry = new journal_entry_1.default(dbTransaction);
|
|
578
|
+
const transactionDate = new Date();
|
|
579
|
+
const creditTransaction = yield journalEntry.newLedgerTransaction(enum_1.TransactionTypeOptions.CREDIT);
|
|
580
|
+
if (ctAccountNo) {
|
|
581
|
+
creditTransaction.AccountNo = ctAccountNo;
|
|
582
|
+
}
|
|
583
|
+
else {
|
|
584
|
+
creditTransaction.AccountNo = customer.CustSystemCode + '-AP';
|
|
585
|
+
}
|
|
586
|
+
creditTransaction.Currency = creditNote.Currency;
|
|
587
|
+
creditTransaction.DebitAmount = creditNote.Amount;
|
|
588
|
+
creditTransaction.Date = transactionDate;
|
|
589
|
+
creditTransaction.Name = creditNote.DocNo;
|
|
590
|
+
for (const invoiceItem of documentItems) {
|
|
591
|
+
const itemLedger = yield journalEntry.newLedgerTransaction(enum_1.TransactionTypeOptions.CREDIT);
|
|
592
|
+
itemLedger.AccountNo = invoiceItem.CtAccountNo;
|
|
593
|
+
itemLedger.Currency = invoiceItem.Currency;
|
|
594
|
+
itemLedger.CreditAmount = invoiceItem.Amount;
|
|
595
|
+
itemLedger.Date = transactionDate;
|
|
596
|
+
itemLedger.Name = invoiceItem.Name;
|
|
597
|
+
}
|
|
598
|
+
this.postJournal(dbTransaction, journalEntry);
|
|
599
|
+
const payload = {
|
|
600
|
+
Action: 'Create',
|
|
601
|
+
Activity: 'Issuing a Credit Note Transaction',
|
|
602
|
+
Description: `Credit Transaction (ID: ${creditTransaction.TransactionId}) has been created`,
|
|
603
|
+
EntityType: 'CreditTransaction',
|
|
604
|
+
EntityValueBefore: JSON.stringify({}),
|
|
605
|
+
EntityValueAfter: JSON.stringify(creditTransaction),
|
|
606
|
+
PerformedById: 'test',
|
|
607
|
+
PerformedAt: transactionDate,
|
|
608
|
+
EntityId: creditTransaction.TransactionId,
|
|
609
|
+
};
|
|
610
|
+
yield axios_1.default.post(`${config.commonApiUrl}/activity-histories`, payload);
|
|
611
|
+
return creditNote;
|
|
612
|
+
}
|
|
613
|
+
catch (err) {
|
|
614
|
+
console.log('Issue credit note err: ', err);
|
|
615
|
+
throw err;
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
collectPayment(dbTransaction, loginUser, payment, customer, ctAccountNo) {
|
|
620
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
621
|
+
let paymentMethodType;
|
|
622
|
+
try {
|
|
623
|
+
paymentMethodType = new payment_method_type_1.default(dbTransaction, payment.MethodTypeId);
|
|
624
|
+
const paymentItems = yield payment.PaymentItems;
|
|
625
|
+
if (paymentItems.length < 1) {
|
|
626
|
+
throw new Error('Atleast one payment item is required to identify what payment is being paid for');
|
|
627
|
+
}
|
|
628
|
+
payment.PaymentId = cuid();
|
|
629
|
+
yield FinanceCompany._PaymentRepository.create({
|
|
630
|
+
PaymentId: payment.PaymentId,
|
|
631
|
+
PaymentType: payment.PaymentType,
|
|
632
|
+
PaymentDate: payment.PaymentDate,
|
|
633
|
+
CompanyId: this.CompanyId,
|
|
634
|
+
MethodTypeId: payment.MethodTypeId,
|
|
635
|
+
Currency: payment.Currency,
|
|
636
|
+
Amount: payment.Amount,
|
|
637
|
+
Status: payment.Status,
|
|
638
|
+
TransactionId: payment.TransactionId,
|
|
639
|
+
TransactionApprovalCode: payment.TransactionApprovalCode,
|
|
640
|
+
TransactionAccountName: payment.TransactionAccountName,
|
|
641
|
+
TransactionAccountNo: payment.TransactionAccountNo,
|
|
642
|
+
ReceivedBy: payment.ReceivedBy,
|
|
643
|
+
UpdatedAt: new Date(),
|
|
644
|
+
UpdatedBy: loginUser.ObjectId,
|
|
645
|
+
CreatedAt: new Date(),
|
|
646
|
+
CreatedBy: loginUser.ObjectId,
|
|
647
|
+
});
|
|
648
|
+
paymentItems.forEach((paymentItem) => __awaiter(this, void 0, void 0, function* () {
|
|
649
|
+
yield FinanceCompany._PaymentItemRepository.create({
|
|
650
|
+
PaymentId: payment.PaymentId,
|
|
651
|
+
PayForObjectId: paymentItem.PayForObjectId,
|
|
652
|
+
PayForObjectType: paymentItem.PayForObjectType,
|
|
653
|
+
Currency: paymentItem.Currency,
|
|
654
|
+
Amount: paymentItem.Amount,
|
|
655
|
+
});
|
|
656
|
+
}));
|
|
657
|
+
const journalEntry = new journal_entry_1.default(dbTransaction);
|
|
658
|
+
const transactionDate = new Date();
|
|
659
|
+
const debitLT = yield journalEntry.newLedgerTransaction(enum_1.TransactionTypeOptions.DEBIT);
|
|
660
|
+
debitLT.AccountNo = paymentMethodType.AccountNo;
|
|
661
|
+
debitLT.Currency = payment.Currency;
|
|
662
|
+
debitLT.CreditAmount = payment.Amount;
|
|
663
|
+
debitLT.Date = transactionDate;
|
|
664
|
+
debitLT.Name = customer.FullName;
|
|
665
|
+
const creditLT = yield journalEntry.newLedgerTransaction(enum_1.TransactionTypeOptions.CREDIT);
|
|
666
|
+
if (ctAccountNo) {
|
|
667
|
+
creditLT.AccountNo = ctAccountNo;
|
|
668
|
+
}
|
|
669
|
+
else {
|
|
670
|
+
creditLT.AccountNo = customer.CustSystemCode + '-AR';
|
|
671
|
+
}
|
|
672
|
+
creditLT.Currency = payment.Currency;
|
|
673
|
+
creditLT.DebitAmount = payment.Amount;
|
|
674
|
+
creditLT.Date = transactionDate;
|
|
675
|
+
creditLT.Name = paymentMethodType.Name;
|
|
676
|
+
yield this.postJournal(dbTransaction, journalEntry);
|
|
677
|
+
return payment;
|
|
678
|
+
}
|
|
679
|
+
catch (error) {
|
|
680
|
+
if (error instanceof general_1.RecordNotFoundError) {
|
|
681
|
+
throw new Error('Invalid PaymentMethodType id');
|
|
682
|
+
}
|
|
683
|
+
else {
|
|
684
|
+
throw error;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
});
|
|
688
|
+
}
|
|
250
689
|
}
|
|
251
690
|
exports.default = FinanceCompany;
|
|
252
691
|
FinanceCompany._htFinanceCompanyIds = new general_1.HashTable();
|
|
253
692
|
FinanceCompany._htFinanceCompanies = new general_1.HashTable();
|
|
254
|
-
FinanceCompany.
|
|
693
|
+
FinanceCompany._financeCompanyRepository = new finance_company_repository_1.FinanceCompanyRepository();
|
|
694
|
+
FinanceCompany._PaymentRepository = new payment_repository_1.PaymentRepository();
|
|
695
|
+
FinanceCompany._PaymentItemRepository = new payment_item_repository_1.PaymentItemRepository();
|
|
696
|
+
FinanceCompany._DocumentRepository = new document_repository_1.DocumentRepository();
|
|
697
|
+
FinanceCompany._DocumentItemRepository = new document_item_repository_1.DocumentItemRepository();
|
|
255
698
|
//# sourceMappingURL=finance-company.js.map
|