@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/src/payment/payment.ts
CHANGED
|
@@ -1,204 +1,206 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { IAccountSystem } from '../interfaces';
|
|
4
|
-
import { IPaymentRepository } from './interfaces/payment.repository.interface';
|
|
5
|
-
import { IPaymentItemRepository } from './interfaces/payment-item.repository.interface';
|
|
6
|
-
import { Sequelize } from 'sequelize-typescript';
|
|
7
|
-
import { IPaymentAttr } from './interfaces/payment-attr.interface';
|
|
8
|
-
import PaymentModel from '../models/payment.entity';
|
|
9
|
-
import axios from 'axios';
|
|
1
|
+
import { ObjectBase, RecordNotFoundError } from '@tomei/general';
|
|
2
|
+
import { PaymentType } from '../enum';
|
|
10
3
|
import { IPaymentParams } from './interfaces/payment-params.interface';
|
|
11
4
|
import { AccountSystemEntity } from '../account-system-entity/account-system-entity';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
private
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
private
|
|
31
|
-
private
|
|
32
|
-
private
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
private
|
|
36
|
-
private
|
|
37
|
-
|
|
38
|
-
private
|
|
39
|
-
private
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
private PaymentItemRepository: IPaymentItemRepository;
|
|
46
|
-
private sequelize: Sequelize;
|
|
47
|
-
AccSystemCode: string;
|
|
48
|
-
|
|
49
|
-
constructor(
|
|
50
|
-
AccountingSystem: IAccountSystem,
|
|
51
|
-
PaymentRepository: IPaymentRepository,
|
|
52
|
-
PaymentItemRepository: IPaymentItemRepository,
|
|
53
|
-
Customer: FinanceCustomerBase,
|
|
54
|
-
ReceivableAccount: Account,
|
|
55
|
-
DepositAccount: Account,
|
|
56
|
-
PaymentItems: PaymentItemBase[],
|
|
57
|
-
Params?: IPaymentParams,
|
|
58
|
-
sequelize?: Sequelize,
|
|
59
|
-
) {
|
|
60
|
-
super();
|
|
61
|
-
this.AccountingSystem = AccountingSystem;
|
|
62
|
-
this.PaymentRepository = PaymentRepository;
|
|
63
|
-
this.PaymentItemRepository = PaymentItemRepository;
|
|
64
|
-
this.Customer = Customer;
|
|
65
|
-
this.ReceivableAccount = ReceivableAccount;
|
|
66
|
-
this.DepositAccount = DepositAccount;
|
|
67
|
-
this.PaymentItems = PaymentItems;
|
|
68
|
-
if (Params) {
|
|
69
|
-
this.init(Params);
|
|
70
|
-
}
|
|
71
|
-
if (sequelize) {
|
|
72
|
-
this.sequelize = sequelize;
|
|
73
|
-
}
|
|
5
|
+
import { PaymentStatus } from '../enum/payment-status.enum';
|
|
6
|
+
import { PaymentRepository } from './payment.repository';
|
|
7
|
+
import { PaymentItemRepository } from '../payment-item/payment-item.repository';
|
|
8
|
+
import PaymentItemModel from '../models/payment-item.entity';
|
|
9
|
+
import PaymentItem from '../payment-item/payment-item';
|
|
10
|
+
|
|
11
|
+
export default class Payment extends AccountSystemEntity {
|
|
12
|
+
private _PaymentId = 'New';
|
|
13
|
+
PaymentType: PaymentType;
|
|
14
|
+
PaymentDate: Date;
|
|
15
|
+
MethodTypeId: string;
|
|
16
|
+
Currency: string;
|
|
17
|
+
Amount: number;
|
|
18
|
+
private _Status: PaymentStatus;
|
|
19
|
+
TransactionId: string;
|
|
20
|
+
TransactionApprovalCode: string;
|
|
21
|
+
TransactionAccountName: string;
|
|
22
|
+
TransactionAccountNo: string;
|
|
23
|
+
private _ReceivedBy: string;
|
|
24
|
+
private _UpdatedBy: string;
|
|
25
|
+
private _UpdatedAt: Date;
|
|
26
|
+
Remarks: string;
|
|
27
|
+
|
|
28
|
+
private static _RepositoryBase = new PaymentRepository();
|
|
29
|
+
private static _PaymentItemRepository = new PaymentItemRepository();
|
|
30
|
+
|
|
31
|
+
private _DbTransaction: any;
|
|
32
|
+
private _PaymentItems = null;
|
|
33
|
+
|
|
34
|
+
paymentItemRepository: PaymentItemRepository;
|
|
35
|
+
|
|
36
|
+
public get PaymentId() {
|
|
37
|
+
return this._PaymentId;
|
|
74
38
|
}
|
|
75
39
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (Params.Method) this.Method = Params.Method;
|
|
79
|
-
if (Params.MethodParty) this.MethodParty = Params.MethodParty;
|
|
80
|
-
if (Params.PaymentType) this.PaymentType = Params.PaymentType;
|
|
40
|
+
public set PaymentId(id: string) {
|
|
41
|
+
this._PaymentId = id;
|
|
81
42
|
}
|
|
82
43
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (this.PaymentItems.length === 0) {
|
|
86
|
-
throw new Error('Payment must have at least one payment item');
|
|
87
|
-
}
|
|
88
|
-
this.PaymentItems.forEach((paymentItem) => {
|
|
89
|
-
this.Amount += paymentItem.Amount;
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
return this.Amount;
|
|
44
|
+
public get Status() {
|
|
45
|
+
return this._Status;
|
|
93
46
|
}
|
|
94
47
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
throw new Error('Currency is missing.');
|
|
98
|
-
}
|
|
99
|
-
return this.Currency;
|
|
48
|
+
private set Status(status: PaymentStatus) {
|
|
49
|
+
this._Status = status;
|
|
100
50
|
}
|
|
101
51
|
|
|
102
|
-
|
|
103
|
-
this.
|
|
52
|
+
public get ReceivedBy() {
|
|
53
|
+
return this._ReceivedBy;
|
|
104
54
|
}
|
|
105
55
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
this.DepositAccountNo = await this.DepositAccount.getAccountNo();
|
|
109
|
-
}
|
|
110
|
-
return this.DepositAccountNo;
|
|
56
|
+
private set ReceivedBy(id: string) {
|
|
57
|
+
this._ReceivedBy = id;
|
|
111
58
|
}
|
|
112
59
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
this.ReceivableAccountNo = await this.ReceivableAccount.getAccountNo();
|
|
116
|
-
}
|
|
117
|
-
return this.ReceivableAccountNo;
|
|
60
|
+
public get UpdatedBy() {
|
|
61
|
+
return this._UpdatedBy;
|
|
118
62
|
}
|
|
119
63
|
|
|
120
|
-
|
|
121
|
-
|
|
64
|
+
private set UpdatedBy(id: string) {
|
|
65
|
+
this._UpdatedBy = id;
|
|
122
66
|
}
|
|
123
67
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
68
|
+
public get UpdatedAt() {
|
|
69
|
+
return this._UpdatedAt;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private set UpdatedAt(date: Date) {
|
|
73
|
+
this._UpdatedAt = date;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/* AccountSystemEntity Implementation */
|
|
77
|
+
get RepositoryBase() {
|
|
78
|
+
return Payment._RepositoryBase;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* ObjectBase Implementation */
|
|
82
|
+
get ObjectId() {
|
|
83
|
+
return this.PaymentId;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
get ObjectName() {
|
|
87
|
+
return this.PaymentId;
|
|
88
|
+
}
|
|
139
89
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
90
|
+
get TableName() {
|
|
91
|
+
return 'finance_Payment';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
constructor(dbTransaction?: any, paymentId?: string) {
|
|
95
|
+
super();
|
|
96
|
+
if (dbTransaction) {
|
|
97
|
+
this._DbTransaction = dbTransaction;
|
|
98
|
+
}
|
|
99
|
+
if (paymentId) {
|
|
100
|
+
this.RepositoryBase.findOne({
|
|
101
|
+
where: {
|
|
102
|
+
PaymentId: paymentId,
|
|
103
|
+
},
|
|
104
|
+
transaction: dbTransaction,
|
|
105
|
+
})
|
|
106
|
+
.then((paymentData) => {
|
|
107
|
+
if (paymentData) {
|
|
108
|
+
this.PaymentType = paymentData.PaymentType;
|
|
109
|
+
this.PaymentDate = paymentData.PaymentDate;
|
|
110
|
+
this.CompanyId = paymentData.CompanyId;
|
|
111
|
+
this.MethodTypeId = paymentData.MethodTypeId;
|
|
112
|
+
this.Currency = paymentData.Currency;
|
|
113
|
+
this.Amount = paymentData.Amount;
|
|
114
|
+
this.Status = paymentData.Status;
|
|
115
|
+
this.TransactionId = paymentData.TransactionId;
|
|
116
|
+
this.TransactionApprovalCode = paymentData.TransactionApprovalCode;
|
|
117
|
+
this.TransactionAccountName = paymentData.TransactionAccountName;
|
|
118
|
+
this.TransactionAccountNo = paymentData.TransactionAccountNo;
|
|
119
|
+
this.ReceivedBy = paymentData.ReceivedBy;
|
|
120
|
+
this.UpdatedAt = paymentData.UpdatedAt;
|
|
121
|
+
this.UpdatedBy = paymentData.UpdatedBy;
|
|
122
|
+
this.Remarks = paymentData.Remarks;
|
|
123
|
+
this.AccSystemRefId = paymentData.AccSystemRefId;
|
|
124
|
+
this.PostedToAccSystemYN = paymentData.PostedToAccSystemYN;
|
|
125
|
+
this.PostedById = paymentData.PostedById;
|
|
126
|
+
this.PostedDateTime = paymentData.PostedDateTime;
|
|
127
|
+
} else {
|
|
128
|
+
const notFoundError = new RecordNotFoundError('No Record Found.');
|
|
129
|
+
throw notFoundError;
|
|
130
|
+
}
|
|
131
|
+
})
|
|
132
|
+
.catch((err) => {
|
|
133
|
+
// tslint:disable-next-line:no-console
|
|
134
|
+
console.log('Payment Class constructor err: ', err);
|
|
174
135
|
});
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
await this.PaymentItemRepository.bulkCreate(paymentItemsData, {
|
|
178
|
-
transaction,
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
const payload = {
|
|
182
|
-
Action: 'Create',
|
|
183
|
-
Activity: 'Payment Created',
|
|
184
|
-
Description: `Account (ID: ${this.ObjectId}) has been created`,
|
|
185
|
-
EntityType: typeof PaymentModel,
|
|
186
|
-
EntityValueBefore: JSON.stringify({}),
|
|
187
|
-
EntityValueAfter: JSON.stringify(payment),
|
|
188
|
-
PerformedById: payment.UpdatedBy,
|
|
189
|
-
PerformedAt: payment.UpdatedAt,
|
|
190
|
-
EntityId: this.ObjectId,
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
await axios.post(
|
|
194
|
-
`${process.env.COMMON_API_URL}/activity-histories`,
|
|
195
|
-
payload,
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
await transaction.commit();
|
|
199
|
-
} catch (error) {
|
|
200
|
-
await transaction.rollback();
|
|
201
|
-
throw error;
|
|
202
136
|
}
|
|
203
137
|
}
|
|
138
|
+
|
|
139
|
+
// public get PaymentItems() {
|
|
140
|
+
// if (this._PaymentItems === null) {
|
|
141
|
+
// this._PaymentItems = new Array<PaymentItemModel>();
|
|
142
|
+
// if (this.PaymentId !== 'New') {
|
|
143
|
+
// this.paymentItemRepository
|
|
144
|
+
// .findAll({
|
|
145
|
+
// where: {
|
|
146
|
+
// PaymentId: this.PaymentId,
|
|
147
|
+
// },
|
|
148
|
+
// })
|
|
149
|
+
// .then((allPaymentItems) => {
|
|
150
|
+
// this._PaymentItems = allPaymentItems;
|
|
151
|
+
// });
|
|
152
|
+
// }
|
|
153
|
+
// }
|
|
154
|
+
|
|
155
|
+
// return this._PaymentItems;
|
|
156
|
+
// }
|
|
157
|
+
|
|
158
|
+
get PaymentItems(): Promise<PaymentItem[]> {
|
|
159
|
+
return new Promise((resolve, reject) => {
|
|
160
|
+
if (this.PaymentId !== 'New') {
|
|
161
|
+
Payment._PaymentItemRepository
|
|
162
|
+
.findAll({
|
|
163
|
+
where: {
|
|
164
|
+
PaymentId: this.PaymentId,
|
|
165
|
+
},
|
|
166
|
+
transaction: this._DbTransaction,
|
|
167
|
+
})
|
|
168
|
+
.then((paymentItems) => {
|
|
169
|
+
const paymentItemObjects = paymentItems.map((paymentItem) => {
|
|
170
|
+
new PaymentItem(
|
|
171
|
+
new Payment(this._DbTransaction, paymentItem.PaymentId),
|
|
172
|
+
{
|
|
173
|
+
ObjectId: this.ObjectId,
|
|
174
|
+
ObjectName: this.ObjectName,
|
|
175
|
+
TableName: this.TableName,
|
|
176
|
+
},
|
|
177
|
+
);
|
|
178
|
+
});
|
|
179
|
+
return Promise.all(paymentItemObjects);
|
|
180
|
+
})
|
|
181
|
+
.then((paymentItemObjects) => {
|
|
182
|
+
this._PaymentItems = paymentItemObjects;
|
|
183
|
+
resolve(this._PaymentItems);
|
|
184
|
+
})
|
|
185
|
+
.catch((err) => {
|
|
186
|
+
reject(err);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
resolve(this._PaymentItems);
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
newPaymentItem(objectBeingPaidFor: ObjectBase): PaymentItem {
|
|
194
|
+
const paymentItem = new PaymentItem(
|
|
195
|
+
new Payment(null, this.PaymentId),
|
|
196
|
+
objectBeingPaidFor,
|
|
197
|
+
);
|
|
198
|
+
this._PaymentItems.push(paymentItem);
|
|
199
|
+
return paymentItem;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
init(Params: IPaymentParams): void {
|
|
203
|
+
if (Params.Currency) this.Currency = Params.Currency;
|
|
204
|
+
if (Params.PaymentType) this.PaymentType = Params.PaymentType;
|
|
205
|
+
}
|
|
204
206
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RepositoryBase, IRepositoryBase } from '@tomei/general';
|
|
2
|
+
import PaymentItemModel from '../models/payment-item.entity';
|
|
3
|
+
|
|
4
|
+
export class PaymentItemRepository
|
|
5
|
+
extends RepositoryBase<PaymentItemModel>
|
|
6
|
+
implements IRepositoryBase<PaymentItemModel>
|
|
7
|
+
{
|
|
8
|
+
constructor() {
|
|
9
|
+
super(PaymentItemModel);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ObjectBase } from '@tomei/general';
|
|
2
|
+
import Payment from '../payment/payment';
|
|
3
|
+
|
|
4
|
+
export default class PaymentItem extends ObjectBase {
|
|
5
|
+
private _PaymentId: string;
|
|
6
|
+
private _PayForObjectId: string;
|
|
7
|
+
private _PayForObjectType: string;
|
|
8
|
+
Currency = 'MYR';
|
|
9
|
+
Amount = 0;
|
|
10
|
+
|
|
11
|
+
get PaymentId() {
|
|
12
|
+
return this._PaymentId;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
private set PaymentId(id: string) {
|
|
16
|
+
this._PaymentId = id;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get PayForObjectId() {
|
|
20
|
+
return this._PayForObjectId;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
private set PayForObjectId(id: string) {
|
|
24
|
+
this._PayForObjectId = id;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
get PayForObjectType(): string {
|
|
28
|
+
return this._PayForObjectType;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private set PayForObjectType(type: string) {
|
|
32
|
+
this._PayForObjectType = type;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* ObjectBase Implementation */
|
|
36
|
+
get ObjectId() {
|
|
37
|
+
return '';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
get ObjectName() {
|
|
41
|
+
return '';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
get TableName() {
|
|
45
|
+
return 'finance_PaymentItem';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
constructor(payment: Payment, objectBeingPaidFor: ObjectBase) {
|
|
49
|
+
super();
|
|
50
|
+
this.PaymentId = payment.PaymentId;
|
|
51
|
+
this.PayForObjectId = objectBeingPaidFor.ObjectId;
|
|
52
|
+
this.PayForObjectType = objectBeingPaidFor.constructor.name;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RepositoryBase, IRepositoryBase } from '@tomei/general';
|
|
2
|
+
import PaymentMethodModel from '../models/payment-method.entity';
|
|
3
|
+
|
|
4
|
+
export class PaymentMethodRepository
|
|
5
|
+
extends RepositoryBase<PaymentMethodModel>
|
|
6
|
+
implements IRepositoryBase<PaymentMethodModel>
|
|
7
|
+
{
|
|
8
|
+
constructor() {
|
|
9
|
+
super(PaymentMethodModel);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { ObjectBase, RecordNotFoundError } from '@tomei/general';
|
|
2
|
+
import { PaymentMethodRepository } from './payment-method.repository';
|
|
3
|
+
import PaymentMethodType from '../payment-method-type/payment-method-type';
|
|
4
|
+
import { PaymentMethodTypeRepository } from '../payment-method-type/payment-method-type.repository';
|
|
5
|
+
|
|
6
|
+
export default class PaymentMethod extends ObjectBase {
|
|
7
|
+
MethodId = 'New';
|
|
8
|
+
CompanyId = '';
|
|
9
|
+
Name = '';
|
|
10
|
+
|
|
11
|
+
private static _RepositoryBase = new PaymentMethodRepository();
|
|
12
|
+
private static _PaymentMethodTypeRepository =
|
|
13
|
+
new PaymentMethodTypeRepository();
|
|
14
|
+
|
|
15
|
+
private _DbTransaction: any;
|
|
16
|
+
private _PaymentMethodTypes: PaymentMethodType[] = [];
|
|
17
|
+
|
|
18
|
+
constructor(dbTransaction?: any, methodId?: string) {
|
|
19
|
+
super();
|
|
20
|
+
if (dbTransaction) {
|
|
21
|
+
this._DbTransaction = dbTransaction;
|
|
22
|
+
}
|
|
23
|
+
if (methodId) {
|
|
24
|
+
this.MethodId = methodId;
|
|
25
|
+
PaymentMethod._RepositoryBase
|
|
26
|
+
.findOne({
|
|
27
|
+
where: {
|
|
28
|
+
MethodId: methodId,
|
|
29
|
+
},
|
|
30
|
+
transaction: dbTransaction,
|
|
31
|
+
})
|
|
32
|
+
.then((methodData) => {
|
|
33
|
+
if (methodData) {
|
|
34
|
+
this.Name = methodData.Name;
|
|
35
|
+
} else {
|
|
36
|
+
throw new RecordNotFoundError('No record found.');
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
.catch((err) => {
|
|
40
|
+
console.log('Payment method constructor err: ', err);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
get ObjectId() {
|
|
46
|
+
return this.MethodId;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
get ObjectName() {
|
|
50
|
+
return this.Name;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
get TableName() {
|
|
54
|
+
return 'finance_PaymentMethod';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
get PaymentMethodTypes(): Promise<PaymentMethodType[]> {
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
if (this.MethodId !== 'New') {
|
|
60
|
+
PaymentMethod._PaymentMethodTypeRepository
|
|
61
|
+
.findAll({
|
|
62
|
+
where: {
|
|
63
|
+
MethodId: this.MethodId,
|
|
64
|
+
},
|
|
65
|
+
transaction: this._DbTransaction,
|
|
66
|
+
})
|
|
67
|
+
.then((paymentMethodTypes) => {
|
|
68
|
+
const paymentMethodTypeObjects = paymentMethodTypes.map(
|
|
69
|
+
(paymentMethodTypeData) =>
|
|
70
|
+
new PaymentMethodType(
|
|
71
|
+
this._DbTransaction,
|
|
72
|
+
paymentMethodTypeData.MethodTypeId,
|
|
73
|
+
),
|
|
74
|
+
);
|
|
75
|
+
return Promise.all(paymentMethodTypeObjects);
|
|
76
|
+
})
|
|
77
|
+
.then((paymentMethodTypeObjects) => {
|
|
78
|
+
this._PaymentMethodTypes = paymentMethodTypeObjects;
|
|
79
|
+
resolve(this._PaymentMethodTypes);
|
|
80
|
+
})
|
|
81
|
+
.catch((err) => {
|
|
82
|
+
reject(err);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
resolve(this._PaymentMethodTypes);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
get NewPaymentMethodType(): PaymentMethodType {
|
|
90
|
+
const newPaymentMethodType = new PaymentMethodType();
|
|
91
|
+
newPaymentMethodType.MethodId = this.MethodId;
|
|
92
|
+
this._PaymentMethodTypes.push(newPaymentMethodType);
|
|
93
|
+
return newPaymentMethodType;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RepositoryBase, IRepositoryBase } from '@tomei/general';
|
|
2
|
+
import PaymentMethodType from '../models/payment-method-type.entity';
|
|
3
|
+
|
|
4
|
+
export class PaymentMethodTypeRepository
|
|
5
|
+
extends RepositoryBase<PaymentMethodType>
|
|
6
|
+
implements IRepositoryBase<PaymentMethodType>
|
|
7
|
+
{
|
|
8
|
+
constructor() {
|
|
9
|
+
super(PaymentMethodType);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ObjectBase, RecordNotFoundError } from '@tomei/general';
|
|
2
|
+
import { PaymentMethodTypeRepository } from './payment-method-type.repository';
|
|
3
|
+
|
|
4
|
+
export default class PaymentMethodType extends ObjectBase {
|
|
5
|
+
MethodTypeId = 'New';
|
|
6
|
+
MethodId = '';
|
|
7
|
+
Name = '';
|
|
8
|
+
AccountNo = '';
|
|
9
|
+
ProcessingFeeRate = 0.0;
|
|
10
|
+
ProcessingFeeAccountNo = '';
|
|
11
|
+
|
|
12
|
+
private _DbTransaction: any;
|
|
13
|
+
|
|
14
|
+
private static _RepositoryBase = new PaymentMethodTypeRepository();
|
|
15
|
+
|
|
16
|
+
constructor(dbTransaction?: any, methodTypeId?: string) {
|
|
17
|
+
super();
|
|
18
|
+
if (dbTransaction) {
|
|
19
|
+
this._DbTransaction = dbTransaction;
|
|
20
|
+
}
|
|
21
|
+
if (methodTypeId) {
|
|
22
|
+
this.MethodTypeId = methodTypeId;
|
|
23
|
+
PaymentMethodType._RepositoryBase
|
|
24
|
+
.findOne({
|
|
25
|
+
where: {
|
|
26
|
+
MethodTypeId: this.MethodTypeId,
|
|
27
|
+
},
|
|
28
|
+
transaction: this._DbTransaction,
|
|
29
|
+
})
|
|
30
|
+
.then((paymentMethodTypeData) => {
|
|
31
|
+
if (paymentMethodTypeData) {
|
|
32
|
+
this.Name = paymentMethodTypeData.Name;
|
|
33
|
+
this.AccountNo = paymentMethodTypeData.AccountNo;
|
|
34
|
+
this.ProcessingFeeRate = paymentMethodTypeData.ProcessingFeeRate;
|
|
35
|
+
this.ProcessingFeeAccountNo =
|
|
36
|
+
paymentMethodTypeData.ProcessingFeeAccountNo;
|
|
37
|
+
} else {
|
|
38
|
+
throw new RecordNotFoundError('No record found.');
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
.catch((err) => {
|
|
42
|
+
console.log('Payment method type constructor err: ', err);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
get ObjectId() {
|
|
48
|
+
return this.MethodTypeId;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
get ObjectName() {
|
|
52
|
+
return this.Name;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
get TableName() {
|
|
56
|
+
return 'finance_PaymentMethodType';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export interface IJournalEntryRepository<T> {
|
|
2
|
-
create?(data: T | any, options?: any): Promise<T> | any;
|
|
3
|
-
|
|
4
|
-
findAll?(options?: any): Promise<T[]>;
|
|
5
|
-
|
|
6
|
-
findAllWithPagination(options: any): Promise<{ count: number; rows: T[] }>;
|
|
7
|
-
|
|
8
|
-
findOne?(options: any): Promise<T>;
|
|
9
|
-
|
|
10
|
-
update?(data: any, options?: any): Promise<any>;
|
|
11
|
-
}
|