@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
package/dist/payment/payment.js
CHANGED
|
@@ -1,154 +1,143 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
|
|
13
|
-
const payment_entity_1 = require("../models/payment.entity");
|
|
14
|
-
const axios_1 = require("axios");
|
|
3
|
+
const general_1 = require("@tomei/general");
|
|
15
4
|
const account_system_entity_1 = require("../account-system-entity/account-system-entity");
|
|
5
|
+
const payment_repository_1 = require("./payment.repository");
|
|
6
|
+
const payment_item_repository_1 = require("../payment-item/payment-item.repository");
|
|
7
|
+
const payment_item_1 = require("../payment-item/payment-item");
|
|
16
8
|
class Payment extends account_system_entity_1.AccountSystemEntity {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
this.AccountingSystem = AccountingSystem;
|
|
20
|
-
this.PaymentRepository = PaymentRepository;
|
|
21
|
-
this.PaymentItemRepository = PaymentItemRepository;
|
|
22
|
-
this.Customer = Customer;
|
|
23
|
-
this.ReceivableAccount = ReceivableAccount;
|
|
24
|
-
this.DepositAccount = DepositAccount;
|
|
25
|
-
this.PaymentItems = PaymentItems;
|
|
26
|
-
if (Params) {
|
|
27
|
-
this.init(Params);
|
|
28
|
-
}
|
|
29
|
-
if (sequelize) {
|
|
30
|
-
this.sequelize = sequelize;
|
|
31
|
-
}
|
|
9
|
+
get PaymentId() {
|
|
10
|
+
return this._PaymentId;
|
|
32
11
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
this.Currency = Params.Currency;
|
|
36
|
-
if (Params.Method)
|
|
37
|
-
this.Method = Params.Method;
|
|
38
|
-
if (Params.MethodParty)
|
|
39
|
-
this.MethodParty = Params.MethodParty;
|
|
40
|
-
if (Params.PaymentType)
|
|
41
|
-
this.PaymentType = Params.PaymentType;
|
|
12
|
+
set PaymentId(id) {
|
|
13
|
+
this._PaymentId = id;
|
|
42
14
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (this.PaymentItems.length === 0) {
|
|
46
|
-
throw new Error('Payment must have at least one payment item');
|
|
47
|
-
}
|
|
48
|
-
this.PaymentItems.forEach((paymentItem) => {
|
|
49
|
-
this.Amount += paymentItem.Amount;
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
return this.Amount;
|
|
15
|
+
get Status() {
|
|
16
|
+
return this._Status;
|
|
53
17
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
throw new Error('Currency is missing.');
|
|
57
|
-
}
|
|
58
|
-
return this.Currency;
|
|
18
|
+
set Status(status) {
|
|
19
|
+
this._Status = status;
|
|
59
20
|
}
|
|
60
|
-
|
|
61
|
-
this.
|
|
21
|
+
get ReceivedBy() {
|
|
22
|
+
return this._ReceivedBy;
|
|
62
23
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (!this.DepositAccountNo) {
|
|
66
|
-
this.DepositAccountNo = yield this.DepositAccount.getAccountNo();
|
|
67
|
-
}
|
|
68
|
-
return this.DepositAccountNo;
|
|
69
|
-
});
|
|
24
|
+
set ReceivedBy(id) {
|
|
25
|
+
this._ReceivedBy = id;
|
|
70
26
|
}
|
|
71
|
-
|
|
72
|
-
return
|
|
73
|
-
if (!this.ReceivableAccountNo) {
|
|
74
|
-
this.ReceivableAccountNo = yield this.ReceivableAccount.getAccountNo();
|
|
75
|
-
}
|
|
76
|
-
return this.ReceivableAccountNo;
|
|
77
|
-
});
|
|
27
|
+
get UpdatedBy() {
|
|
28
|
+
return this._UpdatedBy;
|
|
78
29
|
}
|
|
79
|
-
|
|
80
|
-
|
|
30
|
+
set UpdatedBy(id) {
|
|
31
|
+
this._UpdatedBy = id;
|
|
81
32
|
}
|
|
82
|
-
|
|
83
|
-
return
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
33
|
+
get UpdatedAt() {
|
|
34
|
+
return this._UpdatedAt;
|
|
35
|
+
}
|
|
36
|
+
set UpdatedAt(date) {
|
|
37
|
+
this._UpdatedAt = date;
|
|
38
|
+
}
|
|
39
|
+
get RepositoryBase() {
|
|
40
|
+
return Payment._RepositoryBase;
|
|
41
|
+
}
|
|
42
|
+
get ObjectId() {
|
|
43
|
+
return this.PaymentId;
|
|
44
|
+
}
|
|
45
|
+
get ObjectName() {
|
|
46
|
+
return this.PaymentId;
|
|
47
|
+
}
|
|
48
|
+
get TableName() {
|
|
49
|
+
return 'finance_Payment';
|
|
50
|
+
}
|
|
51
|
+
constructor(dbTransaction, paymentId) {
|
|
52
|
+
super();
|
|
53
|
+
this._PaymentId = 'New';
|
|
54
|
+
this._PaymentItems = null;
|
|
55
|
+
if (dbTransaction) {
|
|
56
|
+
this._DbTransaction = dbTransaction;
|
|
57
|
+
}
|
|
58
|
+
if (paymentId) {
|
|
59
|
+
this.RepositoryBase.findOne({
|
|
60
|
+
where: {
|
|
61
|
+
PaymentId: paymentId,
|
|
62
|
+
},
|
|
63
|
+
transaction: dbTransaction,
|
|
64
|
+
})
|
|
65
|
+
.then((paymentData) => {
|
|
66
|
+
if (paymentData) {
|
|
67
|
+
this.PaymentType = paymentData.PaymentType;
|
|
68
|
+
this.PaymentDate = paymentData.PaymentDate;
|
|
69
|
+
this.CompanyId = paymentData.CompanyId;
|
|
70
|
+
this.MethodTypeId = paymentData.MethodTypeId;
|
|
71
|
+
this.Currency = paymentData.Currency;
|
|
72
|
+
this.Amount = paymentData.Amount;
|
|
73
|
+
this.Status = paymentData.Status;
|
|
74
|
+
this.TransactionId = paymentData.TransactionId;
|
|
75
|
+
this.TransactionApprovalCode = paymentData.TransactionApprovalCode;
|
|
76
|
+
this.TransactionAccountName = paymentData.TransactionAccountName;
|
|
77
|
+
this.TransactionAccountNo = paymentData.TransactionAccountNo;
|
|
78
|
+
this.ReceivedBy = paymentData.ReceivedBy;
|
|
79
|
+
this.UpdatedAt = paymentData.UpdatedAt;
|
|
80
|
+
this.UpdatedBy = paymentData.UpdatedBy;
|
|
81
|
+
this.Remarks = paymentData.Remarks;
|
|
82
|
+
this.AccSystemRefId = paymentData.AccSystemRefId;
|
|
83
|
+
this.PostedToAccSystemYN = paymentData.PostedToAccSystemYN;
|
|
84
|
+
this.PostedById = paymentData.PostedById;
|
|
85
|
+
this.PostedDateTime = paymentData.PostedDateTime;
|
|
94
86
|
}
|
|
95
|
-
|
|
96
|
-
|
|
87
|
+
else {
|
|
88
|
+
const notFoundError = new general_1.RecordNotFoundError('No Record Found.');
|
|
89
|
+
throw notFoundError;
|
|
97
90
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
paymentItemsData.push({
|
|
122
|
-
PaymentId: this.ObjectId,
|
|
123
|
-
PayForObjectId: paymentItem.ObjectId,
|
|
124
|
-
PayForObjectType: paymentItem.Type,
|
|
125
|
-
Amount: paymentItem.Amount,
|
|
126
|
-
Currency: paymentItem.Currency,
|
|
91
|
+
})
|
|
92
|
+
.catch((err) => {
|
|
93
|
+
console.log('Payment Class constructor err: ', err);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
get PaymentItems() {
|
|
98
|
+
return new Promise((resolve, reject) => {
|
|
99
|
+
if (this.PaymentId !== 'New') {
|
|
100
|
+
Payment._PaymentItemRepository
|
|
101
|
+
.findAll({
|
|
102
|
+
where: {
|
|
103
|
+
PaymentId: this.PaymentId,
|
|
104
|
+
},
|
|
105
|
+
transaction: this._DbTransaction,
|
|
106
|
+
})
|
|
107
|
+
.then((paymentItems) => {
|
|
108
|
+
const paymentItemObjects = paymentItems.map((paymentItem) => {
|
|
109
|
+
new payment_item_1.default(new Payment(this._DbTransaction, paymentItem.PaymentId), {
|
|
110
|
+
ObjectId: this.ObjectId,
|
|
111
|
+
ObjectName: this.ObjectName,
|
|
112
|
+
TableName: this.TableName,
|
|
113
|
+
});
|
|
127
114
|
});
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
115
|
+
return Promise.all(paymentItemObjects);
|
|
116
|
+
})
|
|
117
|
+
.then((paymentItemObjects) => {
|
|
118
|
+
this._PaymentItems = paymentItemObjects;
|
|
119
|
+
resolve(this._PaymentItems);
|
|
120
|
+
})
|
|
121
|
+
.catch((err) => {
|
|
122
|
+
reject(err);
|
|
131
123
|
});
|
|
132
|
-
const payload = {
|
|
133
|
-
Action: 'Create',
|
|
134
|
-
Activity: 'Payment Created',
|
|
135
|
-
Description: `Account (ID: ${this.ObjectId}) has been created`,
|
|
136
|
-
EntityType: typeof payment_entity_1.default,
|
|
137
|
-
EntityValueBefore: JSON.stringify({}),
|
|
138
|
-
EntityValueAfter: JSON.stringify(payment),
|
|
139
|
-
PerformedById: payment.UpdatedBy,
|
|
140
|
-
PerformedAt: payment.UpdatedAt,
|
|
141
|
-
EntityId: this.ObjectId,
|
|
142
|
-
};
|
|
143
|
-
yield axios_1.default.post(`${process.env.COMMON_API_URL}/activity-histories`, payload);
|
|
144
|
-
yield transaction.commit();
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
yield transaction.rollback();
|
|
148
|
-
throw error;
|
|
149
124
|
}
|
|
125
|
+
resolve(this._PaymentItems);
|
|
150
126
|
});
|
|
151
127
|
}
|
|
128
|
+
newPaymentItem(objectBeingPaidFor) {
|
|
129
|
+
const paymentItem = new payment_item_1.default(new Payment(null, this.PaymentId), objectBeingPaidFor);
|
|
130
|
+
this._PaymentItems.push(paymentItem);
|
|
131
|
+
return paymentItem;
|
|
132
|
+
}
|
|
133
|
+
init(Params) {
|
|
134
|
+
if (Params.Currency)
|
|
135
|
+
this.Currency = Params.Currency;
|
|
136
|
+
if (Params.PaymentType)
|
|
137
|
+
this.PaymentType = Params.PaymentType;
|
|
138
|
+
}
|
|
152
139
|
}
|
|
153
|
-
exports.
|
|
140
|
+
exports.default = Payment;
|
|
141
|
+
Payment._RepositoryBase = new payment_repository_1.PaymentRepository();
|
|
142
|
+
Payment._PaymentItemRepository = new payment_item_repository_1.PaymentItemRepository();
|
|
154
143
|
//# sourceMappingURL=payment.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payment.js","sourceRoot":"","sources":["../../src/payment/payment.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"payment.js","sourceRoot":"","sources":["../../src/payment/payment.ts"],"names":[],"mappings":";;AAAA,4CAAiE;AAGjE,0FAAqF;AAErF,6DAAyD;AACzD,qFAAgF;AAEhF,+DAAuD;AAEvD,MAAqB,OAAQ,SAAQ,2CAAmB;IAyBtD,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,IAAW,SAAS,CAAC,EAAU;QAC7B,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IACvB,CAAC;IAED,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,IAAY,MAAM,CAAC,MAAqB;QACtC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,IAAY,UAAU,CAAC,EAAU;QAC/B,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACxB,CAAC;IAED,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,IAAY,SAAS,CAAC,EAAU;QAC9B,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IACvB,CAAC;IAED,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,IAAY,SAAS,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,CAAC;AAC1C,8BAAsB,GAAG,IAAI,+CAAqB,EAAE,CAAC"}
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RepositoryBase, IRepositoryBase } from '@tomei/general';
|
|
2
2
|
import PaymentModel from '../models/payment.entity';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export declare class PaymentRepository extends BaseRepository<PaymentModel> implements IPaymentRepository {
|
|
6
|
-
private readonly paymentModel;
|
|
7
|
-
constructor(paymentModel: typeof PaymentModel);
|
|
8
|
-
create(data: IPaymentAttr, options?: any): Promise<PaymentModel> | any;
|
|
9
|
-
findAll(options: any): Promise<PaymentModel[]>;
|
|
10
|
-
findAllWithPagination(options: any): Promise<{
|
|
11
|
-
count: number;
|
|
12
|
-
rows: PaymentModel[];
|
|
13
|
-
}>;
|
|
14
|
-
findOne(options: any): Promise<PaymentModel>;
|
|
15
|
-
update(data: IPaymentAttr, options?: any): any;
|
|
3
|
+
export declare class PaymentRepository extends RepositoryBase<PaymentModel> implements IRepositoryBase<PaymentModel> {
|
|
4
|
+
constructor();
|
|
16
5
|
}
|
|
@@ -1,47 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
exports.PaymentRepository = void 0;
|
|
16
|
-
const common_1 = require("@nestjs/common");
|
|
17
|
-
const sequelize_1 = require("@nestjs/sequelize");
|
|
18
4
|
const general_1 = require("@tomei/general");
|
|
19
5
|
const payment_entity_1 = require("../models/payment.entity");
|
|
20
|
-
|
|
21
|
-
constructor(
|
|
22
|
-
super(
|
|
23
|
-
this.paymentModel = paymentModel;
|
|
6
|
+
class PaymentRepository extends general_1.RepositoryBase {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(payment_entity_1.default);
|
|
24
9
|
}
|
|
25
|
-
|
|
26
|
-
return this.paymentModel.create(Object.assign({}, data), options);
|
|
27
|
-
}
|
|
28
|
-
findAll(options) {
|
|
29
|
-
return this.paymentModel.findAll(options);
|
|
30
|
-
}
|
|
31
|
-
findAllWithPagination(options) {
|
|
32
|
-
return this.paymentModel.findAndCountAll(options);
|
|
33
|
-
}
|
|
34
|
-
findOne(options) {
|
|
35
|
-
return this.paymentModel.findOne(options);
|
|
36
|
-
}
|
|
37
|
-
update(data, options) {
|
|
38
|
-
return this.paymentModel.update(Object.assign({}, data), options);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
PaymentRepository = __decorate([
|
|
42
|
-
(0, common_1.Injectable)(),
|
|
43
|
-
__param(0, (0, sequelize_1.InjectModel)(payment_entity_1.default)),
|
|
44
|
-
__metadata("design:paramtypes", [Object])
|
|
45
|
-
], PaymentRepository);
|
|
10
|
+
}
|
|
46
11
|
exports.PaymentRepository = PaymentRepository;
|
|
47
12
|
//# sourceMappingURL=payment.repository.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payment.repository.js","sourceRoot":"","sources":["../../src/payment/payment.repository.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"payment.repository.js","sourceRoot":"","sources":["../../src/payment/payment.repository.ts"],"names":[],"mappings":";;;AAAA,4CAAiE;AACjE,6DAAoD;AAEpD,MAAa,iBACX,SAAQ,wBAA4B;IAGpC;QACE,KAAK,CAAC,wBAAY,CAAC,CAAC;IACtB,CAAC;CACF;AAPD,8CAOC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-item-attr.interface.js","sourceRoot":"","sources":["../../../src/payment-item/interfaces/payment-item-attr.interface.ts"],"names":[],"mappings":";;;AAAA,MAAa,gBAAgB;CAO5B;AAPD,4CAOC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-item.repository.interface.js","sourceRoot":"","sources":["../../../src/payment-item/interfaces/payment-item.repository.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ObjectBase } from '@tomei/general';
|
|
2
|
+
import Payment from '../payment/payment';
|
|
3
|
+
export default class PaymentItem extends ObjectBase {
|
|
4
|
+
private _PaymentId;
|
|
5
|
+
private _PayForObjectId;
|
|
6
|
+
private _PayForObjectType;
|
|
7
|
+
Currency: string;
|
|
8
|
+
Amount: number;
|
|
9
|
+
get PaymentId(): string;
|
|
10
|
+
private set PaymentId(value);
|
|
11
|
+
get PayForObjectId(): string;
|
|
12
|
+
private set PayForObjectId(value);
|
|
13
|
+
get PayForObjectType(): string;
|
|
14
|
+
private set PayForObjectType(value);
|
|
15
|
+
get ObjectId(): string;
|
|
16
|
+
get ObjectName(): string;
|
|
17
|
+
get TableName(): string;
|
|
18
|
+
constructor(payment: Payment, objectBeingPaidFor: ObjectBase);
|
|
19
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const general_1 = require("@tomei/general");
|
|
4
|
+
class PaymentItem extends general_1.ObjectBase {
|
|
5
|
+
get PaymentId() {
|
|
6
|
+
return this._PaymentId;
|
|
7
|
+
}
|
|
8
|
+
set PaymentId(id) {
|
|
9
|
+
this._PaymentId = id;
|
|
10
|
+
}
|
|
11
|
+
get PayForObjectId() {
|
|
12
|
+
return this._PayForObjectId;
|
|
13
|
+
}
|
|
14
|
+
set PayForObjectId(id) {
|
|
15
|
+
this._PayForObjectId = id;
|
|
16
|
+
}
|
|
17
|
+
get PayForObjectType() {
|
|
18
|
+
return this._PayForObjectType;
|
|
19
|
+
}
|
|
20
|
+
set PayForObjectType(type) {
|
|
21
|
+
this._PayForObjectType = type;
|
|
22
|
+
}
|
|
23
|
+
get ObjectId() {
|
|
24
|
+
return '';
|
|
25
|
+
}
|
|
26
|
+
get ObjectName() {
|
|
27
|
+
return '';
|
|
28
|
+
}
|
|
29
|
+
get TableName() {
|
|
30
|
+
return 'finance_PaymentItem';
|
|
31
|
+
}
|
|
32
|
+
constructor(payment, objectBeingPaidFor) {
|
|
33
|
+
super();
|
|
34
|
+
this.Currency = 'MYR';
|
|
35
|
+
this.Amount = 0;
|
|
36
|
+
this.PaymentId = payment.PaymentId;
|
|
37
|
+
this.PayForObjectId = objectBeingPaidFor.ObjectId;
|
|
38
|
+
this.PayForObjectType = objectBeingPaidFor.constructor.name;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.default = PaymentItem;
|
|
42
|
+
//# sourceMappingURL=payment-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-item.js","sourceRoot":"","sources":["../../src/payment-item/payment-item.ts"],"names":[],"mappings":";;AAAA,4CAA4C;AAG5C,MAAqB,WAAY,SAAQ,oBAAU;IAOjD,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,IAAY,SAAS,CAAC,EAAU;QAC9B,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IACvB,CAAC;IAED,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED,IAAY,cAAc,CAAC,EAAU;QACnC,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;IAC5B,CAAC;IAED,IAAI,gBAAgB;QAClB,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAChC,CAAC;IAED,IAAY,gBAAgB,CAAC,IAAY;QACvC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAChC,CAAC;IAGD,IAAI,QAAQ;QACV,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,SAAS;QACX,OAAO,qBAAqB,CAAC;IAC/B,CAAC;IAED,YAAY,OAAgB,EAAE,kBAA8B;QAC1D,KAAK,EAAE,CAAC;QAzCV,aAAQ,GAAG,KAAK,CAAC;QACjB,WAAM,GAAG,CAAC,CAAC;QAyCT,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,cAAc,GAAG,kBAAkB,CAAC,QAAQ,CAAC;QAClD,IAAI,CAAC,gBAAgB,GAAG,kBAAkB,CAAC,WAAW,CAAC,IAAI,CAAC;IAC9D,CAAC;CACF;AAlDD,8BAkDC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RepositoryBase, IRepositoryBase } from '@tomei/general';
|
|
2
|
+
import PaymentItemModel from '../models/payment-item.entity';
|
|
3
|
+
export declare class PaymentItemRepository extends RepositoryBase<PaymentItemModel> implements IRepositoryBase<PaymentItemModel> {
|
|
4
|
+
constructor();
|
|
5
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PaymentItemRepository = void 0;
|
|
4
|
+
const general_1 = require("@tomei/general");
|
|
5
|
+
const payment_item_entity_1 = require("../models/payment-item.entity");
|
|
6
|
+
class PaymentItemRepository extends general_1.RepositoryBase {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(payment_item_entity_1.default);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.PaymentItemRepository = PaymentItemRepository;
|
|
12
|
+
//# sourceMappingURL=payment-item.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-item.repository.js","sourceRoot":"","sources":["../../src/payment-item/payment-item.repository.ts"],"names":[],"mappings":";;;AAAA,4CAAiE;AACjE,uEAA6D;AAE7D,MAAa,qBACX,SAAQ,wBAAgC;IAGxC;QACE,KAAK,CAAC,6BAAgB,CAAC,CAAC;IAC1B,CAAC;CACF;AAPD,sDAOC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-method-attr.interface.js","sourceRoot":"","sources":["../../../src/payment-method/interfaces/payment-method-attr.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ObjectBase } from '@tomei/general';
|
|
2
|
+
import PaymentMethodType from '../payment-method-type/payment-method-type';
|
|
3
|
+
export default class PaymentMethod extends ObjectBase {
|
|
4
|
+
MethodId: string;
|
|
5
|
+
CompanyId: string;
|
|
6
|
+
Name: string;
|
|
7
|
+
private static _RepositoryBase;
|
|
8
|
+
private static _PaymentMethodTypeRepository;
|
|
9
|
+
private _DbTransaction;
|
|
10
|
+
private _PaymentMethodTypes;
|
|
11
|
+
constructor(dbTransaction?: any, methodId?: string);
|
|
12
|
+
get ObjectId(): string;
|
|
13
|
+
get ObjectName(): string;
|
|
14
|
+
get TableName(): string;
|
|
15
|
+
get PaymentMethodTypes(): Promise<PaymentMethodType[]>;
|
|
16
|
+
get NewPaymentMethodType(): PaymentMethodType;
|
|
17
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const general_1 = require("@tomei/general");
|
|
4
|
+
const payment_method_repository_1 = require("./payment-method.repository");
|
|
5
|
+
const payment_method_type_1 = require("../payment-method-type/payment-method-type");
|
|
6
|
+
const payment_method_type_repository_1 = require("../payment-method-type/payment-method-type.repository");
|
|
7
|
+
class PaymentMethod extends general_1.ObjectBase {
|
|
8
|
+
constructor(dbTransaction, methodId) {
|
|
9
|
+
super();
|
|
10
|
+
this.MethodId = 'New';
|
|
11
|
+
this.CompanyId = '';
|
|
12
|
+
this.Name = '';
|
|
13
|
+
this._PaymentMethodTypes = [];
|
|
14
|
+
if (dbTransaction) {
|
|
15
|
+
this._DbTransaction = dbTransaction;
|
|
16
|
+
}
|
|
17
|
+
if (methodId) {
|
|
18
|
+
this.MethodId = methodId;
|
|
19
|
+
PaymentMethod._RepositoryBase
|
|
20
|
+
.findOne({
|
|
21
|
+
where: {
|
|
22
|
+
MethodId: methodId,
|
|
23
|
+
},
|
|
24
|
+
transaction: dbTransaction,
|
|
25
|
+
})
|
|
26
|
+
.then((methodData) => {
|
|
27
|
+
if (methodData) {
|
|
28
|
+
this.Name = methodData.Name;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
throw new general_1.RecordNotFoundError('No record found.');
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
.catch((err) => {
|
|
35
|
+
console.log('Payment method constructor err: ', err);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
get ObjectId() {
|
|
40
|
+
return this.MethodId;
|
|
41
|
+
}
|
|
42
|
+
get ObjectName() {
|
|
43
|
+
return this.Name;
|
|
44
|
+
}
|
|
45
|
+
get TableName() {
|
|
46
|
+
return 'finance_PaymentMethod';
|
|
47
|
+
}
|
|
48
|
+
get PaymentMethodTypes() {
|
|
49
|
+
return new Promise((resolve, reject) => {
|
|
50
|
+
if (this.MethodId !== 'New') {
|
|
51
|
+
PaymentMethod._PaymentMethodTypeRepository
|
|
52
|
+
.findAll({
|
|
53
|
+
where: {
|
|
54
|
+
MethodId: this.MethodId,
|
|
55
|
+
},
|
|
56
|
+
transaction: this._DbTransaction,
|
|
57
|
+
})
|
|
58
|
+
.then((paymentMethodTypes) => {
|
|
59
|
+
const paymentMethodTypeObjects = paymentMethodTypes.map((paymentMethodTypeData) => new payment_method_type_1.default(this._DbTransaction, paymentMethodTypeData.MethodTypeId));
|
|
60
|
+
return Promise.all(paymentMethodTypeObjects);
|
|
61
|
+
})
|
|
62
|
+
.then((paymentMethodTypeObjects) => {
|
|
63
|
+
this._PaymentMethodTypes = paymentMethodTypeObjects;
|
|
64
|
+
resolve(this._PaymentMethodTypes);
|
|
65
|
+
})
|
|
66
|
+
.catch((err) => {
|
|
67
|
+
reject(err);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
resolve(this._PaymentMethodTypes);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
get NewPaymentMethodType() {
|
|
74
|
+
const newPaymentMethodType = new payment_method_type_1.default();
|
|
75
|
+
newPaymentMethodType.MethodId = this.MethodId;
|
|
76
|
+
this._PaymentMethodTypes.push(newPaymentMethodType);
|
|
77
|
+
return newPaymentMethodType;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.default = PaymentMethod;
|
|
81
|
+
PaymentMethod._RepositoryBase = new payment_method_repository_1.PaymentMethodRepository();
|
|
82
|
+
PaymentMethod._PaymentMethodTypeRepository = new payment_method_type_repository_1.PaymentMethodTypeRepository();
|
|
83
|
+
//# sourceMappingURL=payment-method.js.map
|