@tomei/finance 0.6.76 → 0.6.78
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/.commitlintrc.json +22 -22
- package/.eslintrc.js +72 -72
- package/.gitlab-ci.yml +16 -16
- package/.husky/commit-msg +4 -4
- package/.husky/pre-commit +4 -4
- package/.prettierrc +4 -4
- package/CONTRIBUTING.md +30 -30
- package/LICENSE +21 -21
- package/README.md +13 -13
- package/configs/config.js +348 -348
- package/dist/finance-company/finance-company.js +2 -3
- package/dist/finance-company/finance-company.js.map +1 -1
- package/dist/payment-item/payment-item.js +6 -6
- package/dist/payment-item/payment-item.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/invoice-template/assets/css/style.css.map +12 -12
- package/invoice-template/assets/css/style.min.css +1 -1
- package/invoice-template/assets/img/arrow_bg.svg +11 -11
- package/invoice-template/assets/img/coffy_shop_img.svg +18 -18
- package/invoice-template/assets/img/logo_accent.svg +3 -3
- package/invoice-template/assets/img/logo_white.svg +4 -4
- package/invoice-template/assets/img/sign.svg +12 -12
- package/invoice-template/assets/img/tomei-logo.svg +9 -9
- package/invoice-template/assets/js/html2canvas.min.js +10379 -10379
- package/invoice-template/assets/js/jquery.min.js +1 -1
- package/invoice-template/assets/sass/common/_color_variable.scss +12 -12
- package/invoice-template/assets/sass/common/_typography.scss +178 -178
- package/invoice-template/assets/sass/style.scss +12 -12
- package/migrations/finance-account-migration.js +97 -97
- package/migrations/finance-company-migration.js +29 -29
- package/migrations/finance-customer-migration.js +51 -51
- package/migrations/finance-document-item-migration.js +111 -111
- package/migrations/finance-document-migration.js +122 -122
- package/migrations/finance-journal-entry-migration.js +59 -59
- package/migrations/finance-ledger-transaction-migration.js +89 -89
- package/migrations/finance-payment-item-migration.js +52 -52
- package/migrations/finance-payment-method-migration.js +31 -31
- package/migrations/finance-payment-method-type-migration.js +55 -55
- package/migrations/finance-payment-migration.js +96 -96
- package/migrations/finance-post-history-migration.js +45 -45
- package/migrations/finance-tax-migration.js +52 -52
- package/migrations/refactor-finance-document-migration.js +71 -71
- package/nest-cli.json +19 -19
- package/package.json +82 -82
- package/sonar-project.properties +12 -12
- package/src/account/account.repository.ts +11 -11
- package/src/account/account.ts +276 -276
- package/src/account/interfaces/account-attr.interface.ts +31 -31
- package/src/account-system-entity/account-system-entity.ts +66 -66
- package/src/account-system-entity/post-history.repository.ts +11 -11
- package/src/config.ts +382 -382
- package/src/customer/customer.ts +299 -299
- package/src/customer/finance-customer.repository.ts +13 -13
- package/src/customer/interfaces/customer.repository.interface.ts +3 -3
- package/src/customer/interfaces/finance-customer-attr.interface.ts +10 -10
- package/src/customer/interfaces/finance-customer.repository.interface.ts +4 -4
- package/src/database.ts +48 -48
- package/src/document/document-item.repository.ts +11 -11
- package/src/document/document.repository.ts +11 -11
- package/src/document/interfaces/document-attr.interface.ts +28 -28
- package/src/document/interfaces/document-item-attr.interface.ts +22 -22
- package/src/document/interfaces/document-item.repository.interface.ts +4 -4
- package/src/enum/collect-payment-type.ts +3 -3
- package/src/enum/doc-type.enum.ts +8 -8
- package/src/enum/index.ts +19 -19
- package/src/enum/payment-method.enum.ts +3 -3
- package/src/enum/payment-type.enum.ts +4 -4
- package/src/enum/quick-book-client-scopes.enum.ts +14 -14
- package/src/finance-company/finance-company.repository.ts +11 -11
- package/src/finance-company/finance-company.ts +2229 -2227
- package/src/helpers/login-user.ts +38 -38
- package/src/helpers/typeof.ts +35 -35
- package/src/index.ts +32 -32
- package/src/interfaces/account-system.interface.ts +20 -20
- package/src/interfaces/index.ts +3 -3
- package/src/models/account.entity.ts +206 -206
- package/src/models/customer.entity.ts +93 -93
- package/src/models/document-item.entity.ts +143 -143
- package/src/models/document.entity.ts +211 -211
- package/src/models/finance-company.entity.ts +29 -29
- package/src/models/journal-entry.entity.ts +110 -110
- package/src/models/ledger-transaction.entity.ts +148 -148
- package/src/models/payment-item.entity.ts +60 -60
- package/src/models/payment-method-type.entity.ts +70 -70
- package/src/models/payment-method.entity.ts +51 -51
- package/src/models/payment.entity.ts +165 -165
- package/src/models/post-history.entity.ts +41 -41
- package/src/models/tax.entity.ts +75 -75
- package/src/payment/interfaces/payment-attr.interface.ts +23 -23
- package/src/payment/interfaces/payment-params.interface.ts +8 -8
- package/src/payment/payment.repository.ts +11 -11
- package/src/payment/payment.ts +236 -236
- package/src/payment-item/interfaces/payment-item-attr.interface.ts +10 -10
- package/src/payment-item/payment-item.repository.ts +11 -11
- package/src/payment-item/payment-item.ts +134 -134
- package/src/payment-method/payment-method.repository.ts +11 -11
- package/src/payment-method-type/payment-method-type.repository.ts +11 -11
- package/src/tax/interfaces/tax-attr.interface.ts +10 -10
- package/src/tax/tax.repository.ts +11 -11
- package/src/tax/tax.ts +69 -69
- package/src/test-document.ts +25 -25
- package/src/test.ts +3 -3
- package/tsconfig.build.json +4 -4
- package/tsconfig.json +22 -22
- package/tslint.json +18 -18
package/src/payment/payment.ts
CHANGED
|
@@ -1,236 +1,236 @@
|
|
|
1
|
-
import { ObjectBase } from '@tomei/general';
|
|
2
|
-
import { RecordNotFoundError } from '@tomei/general/dist/class/exceptions/record-not-found.error';
|
|
3
|
-
import { PaymentType } from '../enum';
|
|
4
|
-
import { IPaymentParams } from './interfaces/payment-params.interface';
|
|
5
|
-
import { AccountSystemEntity } from '../account-system-entity/account-system-entity';
|
|
6
|
-
import { PaymentStatus } from '../enum/payment-status.enum';
|
|
7
|
-
import { PaymentRepository } from './payment.repository';
|
|
8
|
-
import { PaymentItemRepository } from '../payment-item/payment-item.repository';
|
|
9
|
-
// import PaymentItemModel from '../models/payment-item.entity';
|
|
10
|
-
import PaymentItem from '../payment-item/payment-item';
|
|
11
|
-
import PaymentPaidWith from '../payment-paid-with/payment-paid-with';
|
|
12
|
-
import { PaymentPaidWithRepository } from '../payment-paid-with/payment-paid-with.repository';
|
|
13
|
-
|
|
14
|
-
export default class Payment extends AccountSystemEntity {
|
|
15
|
-
private _PaymentId = 'New';
|
|
16
|
-
PaymentType: PaymentType;
|
|
17
|
-
PaymentDate: Date;
|
|
18
|
-
MethodTypeId: string;
|
|
19
|
-
Description = '';
|
|
20
|
-
Currency = 'MYR';
|
|
21
|
-
Amount = 0;
|
|
22
|
-
Status: PaymentStatus;
|
|
23
|
-
TransactionId: string;
|
|
24
|
-
TransactionApprovalCode: string;
|
|
25
|
-
TransactionAccountName: string;
|
|
26
|
-
TransactionAccountNo: string;
|
|
27
|
-
ReceivedBy = '';
|
|
28
|
-
IssuedBy = '';
|
|
29
|
-
UpdatedBy = '';
|
|
30
|
-
UpdatedAt: Date;
|
|
31
|
-
Remarks = '';
|
|
32
|
-
RelatedObjectId = '';
|
|
33
|
-
RelatedObjectType = '';
|
|
34
|
-
ReceiptDocNo = '';
|
|
35
|
-
protected _ObjectType: 'Payment';
|
|
36
|
-
|
|
37
|
-
private static _RepositoryBase = new PaymentRepository();
|
|
38
|
-
private static _PaymentItemRepository = new PaymentItemRepository();
|
|
39
|
-
private static _PaymentPaidWithRepository = new PaymentPaidWithRepository();
|
|
40
|
-
|
|
41
|
-
private _DbTransaction: any;
|
|
42
|
-
private _PaymentItems = [];
|
|
43
|
-
private _PaymentPaidWith = [];
|
|
44
|
-
|
|
45
|
-
paymentItemRepository: PaymentItemRepository;
|
|
46
|
-
|
|
47
|
-
public get PaymentId() {
|
|
48
|
-
return this._PaymentId;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
get ObjectType() {
|
|
52
|
-
return this._ObjectType;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
public set PaymentId(id: string) {
|
|
56
|
-
this._PaymentId = id;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/* AccountSystemEntity Implementation */
|
|
60
|
-
get RepositoryBase() {
|
|
61
|
-
return Payment._RepositoryBase;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/* ObjectBase Implementation */
|
|
65
|
-
get ObjectId() {
|
|
66
|
-
return this.PaymentId;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
get ObjectName() {
|
|
70
|
-
return this.PaymentId;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
get TableName() {
|
|
74
|
-
return 'finance_Payment';
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
constructor(dbTransaction?: any, paymentId?: string) {
|
|
78
|
-
super();
|
|
79
|
-
if (dbTransaction) {
|
|
80
|
-
this._DbTransaction = dbTransaction;
|
|
81
|
-
}
|
|
82
|
-
if (paymentId) {
|
|
83
|
-
this.PaymentId = paymentId;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
static async initPayment(
|
|
88
|
-
dbTransaction: any,
|
|
89
|
-
paymentId: string,
|
|
90
|
-
): Promise<Payment> {
|
|
91
|
-
try {
|
|
92
|
-
const paymentData = await this._RepositoryBase.findOne({
|
|
93
|
-
where: {
|
|
94
|
-
PaymentId: paymentId,
|
|
95
|
-
},
|
|
96
|
-
transaction: dbTransaction,
|
|
97
|
-
});
|
|
98
|
-
if (paymentData) {
|
|
99
|
-
const payment = new Payment(dbTransaction, paymentId);
|
|
100
|
-
payment.PaymentType = paymentData.PaymentType;
|
|
101
|
-
payment.PaymentDate = paymentData.PaymentDate;
|
|
102
|
-
payment.Description = paymentData.Description;
|
|
103
|
-
payment.Currency = paymentData.Currency;
|
|
104
|
-
payment.Amount = paymentData.Amount;
|
|
105
|
-
payment.Status = paymentData.Status;
|
|
106
|
-
payment.ReceivedBy = paymentData.ReceivedBy;
|
|
107
|
-
payment.IssuedBy = paymentData.IssuedBy;
|
|
108
|
-
payment.UpdatedAt = paymentData.UpdatedAt;
|
|
109
|
-
payment.UpdatedBy = paymentData.UpdatedBy;
|
|
110
|
-
payment.Remarks = paymentData.Remarks;
|
|
111
|
-
payment.RelatedObjectId = paymentData.RelatedObjectId;
|
|
112
|
-
payment.RelatedObjectType = paymentData.RelatedObjectType;
|
|
113
|
-
payment.ReceiptDocNo = paymentData.ReceiptDocNo;
|
|
114
|
-
payment.AccSystemRefId = paymentData.AccSystemRefId;
|
|
115
|
-
payment.PostedToAccSystemYN = paymentData.PostedToAccSystemYN;
|
|
116
|
-
payment.PostedById = paymentData.PostedById;
|
|
117
|
-
payment.PostedDateTime = paymentData.PostedDateTime;
|
|
118
|
-
return payment;
|
|
119
|
-
} else {
|
|
120
|
-
const notFoundError = new RecordNotFoundError(
|
|
121
|
-
'PaymentErrMsg',
|
|
122
|
-
'No Record Found.',
|
|
123
|
-
);
|
|
124
|
-
throw notFoundError;
|
|
125
|
-
}
|
|
126
|
-
} catch (error) {
|
|
127
|
-
console.log('Payment Class constructor err: ', error);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
async getPaymentItems(dbTransaction?: any): Promise<PaymentItem[]> {
|
|
132
|
-
try {
|
|
133
|
-
if (this.PaymentId !== 'New') {
|
|
134
|
-
const paymentItems = await Payment._PaymentItemRepository.findAll({
|
|
135
|
-
where: {
|
|
136
|
-
PaymentId: this.PaymentId,
|
|
137
|
-
},
|
|
138
|
-
transaction: dbTransaction || this._DbTransaction,
|
|
139
|
-
});
|
|
140
|
-
const paymentItemObjects = paymentItems.map((paymentItem) => {
|
|
141
|
-
const pi = new PaymentItem(
|
|
142
|
-
new Payment(this._DbTransaction, paymentItem.PaymentId),
|
|
143
|
-
{
|
|
144
|
-
ObjectId: this.ObjectId,
|
|
145
|
-
ObjectName: this.ObjectName,
|
|
146
|
-
TableName: this.TableName,
|
|
147
|
-
ObjectType: this.ObjectType,
|
|
148
|
-
} as ObjectBase,
|
|
149
|
-
);
|
|
150
|
-
pi.PayForObjectType = paymentItem.PayForObjectType;
|
|
151
|
-
pi.PayForObjectId = paymentItem.PayForObjectId;
|
|
152
|
-
pi.Currency = paymentItem.Currency;
|
|
153
|
-
pi.Amount = paymentItem.Amount;
|
|
154
|
-
pi.Name = paymentItem.Name;
|
|
155
|
-
pi.Description = paymentItem.Description;
|
|
156
|
-
|
|
157
|
-
return pi;
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
this._PaymentItems = paymentItemObjects;
|
|
161
|
-
return this._PaymentItems;
|
|
162
|
-
} else {
|
|
163
|
-
return this._PaymentItems;
|
|
164
|
-
}
|
|
165
|
-
} catch (error) {
|
|
166
|
-
throw error;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
async getPaymentPaidWith(dbTransaction?: any): Promise<PaymentPaidWith[]> {
|
|
171
|
-
try {
|
|
172
|
-
if (this.PaymentId !== 'New') {
|
|
173
|
-
const paymentPaidWithItems =
|
|
174
|
-
await Payment._PaymentPaidWithRepository.findAll({
|
|
175
|
-
where: {
|
|
176
|
-
PaymentId: this.PaymentId,
|
|
177
|
-
},
|
|
178
|
-
transaction: dbTransaction || this._DbTransaction,
|
|
179
|
-
});
|
|
180
|
-
const paymentPaidWithObjects = paymentPaidWithItems.map(
|
|
181
|
-
(paymentPaidWithItem) => {
|
|
182
|
-
const ppw = new PaymentPaidWith(
|
|
183
|
-
new Payment(this._DbTransaction, paymentPaidWithItem.PaymentId),
|
|
184
|
-
paymentPaidWithItem.MethodTypeId,
|
|
185
|
-
);
|
|
186
|
-
|
|
187
|
-
ppw.Currency = paymentPaidWithItem.Currency;
|
|
188
|
-
ppw.Amount = paymentPaidWithItem.Amount;
|
|
189
|
-
ppw.Status = paymentPaidWithItem.Status;
|
|
190
|
-
ppw.TransactionId = paymentPaidWithItem.TransactionId;
|
|
191
|
-
ppw.RefBank = paymentPaidWithItem.RefBank;
|
|
192
|
-
ppw.RefName = paymentPaidWithItem.RefName;
|
|
193
|
-
ppw.RefNo = paymentPaidWithItem.RefNo;
|
|
194
|
-
ppw.RefOther1 = paymentPaidWithItem.RefOther1;
|
|
195
|
-
ppw.RefOther2 = paymentPaidWithItem.RefOther2;
|
|
196
|
-
ppw.RefOther3 = paymentPaidWithItem.RefOther3;
|
|
197
|
-
ppw.RefOther4 = paymentPaidWithItem.RefOther4;
|
|
198
|
-
ppw.RefOther5 = paymentPaidWithItem.RefOther5;
|
|
199
|
-
ppw.Remarks = paymentPaidWithItem.Remarks;
|
|
200
|
-
ppw.PaymentMediaId = paymentPaidWithItem.PaymentMediaId;
|
|
201
|
-
|
|
202
|
-
return ppw;
|
|
203
|
-
},
|
|
204
|
-
);
|
|
205
|
-
|
|
206
|
-
this._PaymentPaidWith = paymentPaidWithObjects;
|
|
207
|
-
return this._PaymentPaidWith;
|
|
208
|
-
} else {
|
|
209
|
-
return this._PaymentPaidWith;
|
|
210
|
-
}
|
|
211
|
-
} catch (error) {
|
|
212
|
-
throw error;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
newPaymentItem(objectBeingPaidFor: ObjectBase): PaymentItem {
|
|
217
|
-
const paymentItem = new PaymentItem(this, objectBeingPaidFor);
|
|
218
|
-
this._PaymentItems.push(paymentItem);
|
|
219
|
-
return paymentItem;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
newPaymentPaidWith(paymentMethodTypeId: string) {
|
|
223
|
-
const paymentPaidWith = new PaymentPaidWith(
|
|
224
|
-
this,
|
|
225
|
-
paymentMethodTypeId,
|
|
226
|
-
this._DbTransaction,
|
|
227
|
-
);
|
|
228
|
-
this._PaymentPaidWith.push(paymentPaidWith);
|
|
229
|
-
return paymentPaidWith;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
init(Params: IPaymentParams): void {
|
|
233
|
-
if (Params.Currency) this.Currency = Params.Currency;
|
|
234
|
-
if (Params.PaymentType) this.PaymentType = Params.PaymentType;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
1
|
+
import { ObjectBase } from '@tomei/general';
|
|
2
|
+
import { RecordNotFoundError } from '@tomei/general/dist/class/exceptions/record-not-found.error';
|
|
3
|
+
import { PaymentType } from '../enum';
|
|
4
|
+
import { IPaymentParams } from './interfaces/payment-params.interface';
|
|
5
|
+
import { AccountSystemEntity } from '../account-system-entity/account-system-entity';
|
|
6
|
+
import { PaymentStatus } from '../enum/payment-status.enum';
|
|
7
|
+
import { PaymentRepository } from './payment.repository';
|
|
8
|
+
import { PaymentItemRepository } from '../payment-item/payment-item.repository';
|
|
9
|
+
// import PaymentItemModel from '../models/payment-item.entity';
|
|
10
|
+
import PaymentItem from '../payment-item/payment-item';
|
|
11
|
+
import PaymentPaidWith from '../payment-paid-with/payment-paid-with';
|
|
12
|
+
import { PaymentPaidWithRepository } from '../payment-paid-with/payment-paid-with.repository';
|
|
13
|
+
|
|
14
|
+
export default class Payment extends AccountSystemEntity {
|
|
15
|
+
private _PaymentId = 'New';
|
|
16
|
+
PaymentType: PaymentType;
|
|
17
|
+
PaymentDate: Date;
|
|
18
|
+
MethodTypeId: string;
|
|
19
|
+
Description = '';
|
|
20
|
+
Currency = 'MYR';
|
|
21
|
+
Amount = 0;
|
|
22
|
+
Status: PaymentStatus;
|
|
23
|
+
TransactionId: string;
|
|
24
|
+
TransactionApprovalCode: string;
|
|
25
|
+
TransactionAccountName: string;
|
|
26
|
+
TransactionAccountNo: string;
|
|
27
|
+
ReceivedBy = '';
|
|
28
|
+
IssuedBy = '';
|
|
29
|
+
UpdatedBy = '';
|
|
30
|
+
UpdatedAt: Date;
|
|
31
|
+
Remarks = '';
|
|
32
|
+
RelatedObjectId = '';
|
|
33
|
+
RelatedObjectType = '';
|
|
34
|
+
ReceiptDocNo = '';
|
|
35
|
+
protected _ObjectType: 'Payment';
|
|
36
|
+
|
|
37
|
+
private static _RepositoryBase = new PaymentRepository();
|
|
38
|
+
private static _PaymentItemRepository = new PaymentItemRepository();
|
|
39
|
+
private static _PaymentPaidWithRepository = new PaymentPaidWithRepository();
|
|
40
|
+
|
|
41
|
+
private _DbTransaction: any;
|
|
42
|
+
private _PaymentItems = [];
|
|
43
|
+
private _PaymentPaidWith = [];
|
|
44
|
+
|
|
45
|
+
paymentItemRepository: PaymentItemRepository;
|
|
46
|
+
|
|
47
|
+
public get PaymentId() {
|
|
48
|
+
return this._PaymentId;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
get ObjectType() {
|
|
52
|
+
return this._ObjectType;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public set PaymentId(id: string) {
|
|
56
|
+
this._PaymentId = id;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* AccountSystemEntity Implementation */
|
|
60
|
+
get RepositoryBase() {
|
|
61
|
+
return Payment._RepositoryBase;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* ObjectBase Implementation */
|
|
65
|
+
get ObjectId() {
|
|
66
|
+
return this.PaymentId;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
get ObjectName() {
|
|
70
|
+
return this.PaymentId;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
get TableName() {
|
|
74
|
+
return 'finance_Payment';
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
constructor(dbTransaction?: any, paymentId?: string) {
|
|
78
|
+
super();
|
|
79
|
+
if (dbTransaction) {
|
|
80
|
+
this._DbTransaction = dbTransaction;
|
|
81
|
+
}
|
|
82
|
+
if (paymentId) {
|
|
83
|
+
this.PaymentId = paymentId;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static async initPayment(
|
|
88
|
+
dbTransaction: any,
|
|
89
|
+
paymentId: string,
|
|
90
|
+
): Promise<Payment> {
|
|
91
|
+
try {
|
|
92
|
+
const paymentData = await this._RepositoryBase.findOne({
|
|
93
|
+
where: {
|
|
94
|
+
PaymentId: paymentId,
|
|
95
|
+
},
|
|
96
|
+
transaction: dbTransaction,
|
|
97
|
+
});
|
|
98
|
+
if (paymentData) {
|
|
99
|
+
const payment = new Payment(dbTransaction, paymentId);
|
|
100
|
+
payment.PaymentType = paymentData.PaymentType;
|
|
101
|
+
payment.PaymentDate = paymentData.PaymentDate;
|
|
102
|
+
payment.Description = paymentData.Description;
|
|
103
|
+
payment.Currency = paymentData.Currency;
|
|
104
|
+
payment.Amount = paymentData.Amount;
|
|
105
|
+
payment.Status = paymentData.Status;
|
|
106
|
+
payment.ReceivedBy = paymentData.ReceivedBy;
|
|
107
|
+
payment.IssuedBy = paymentData.IssuedBy;
|
|
108
|
+
payment.UpdatedAt = paymentData.UpdatedAt;
|
|
109
|
+
payment.UpdatedBy = paymentData.UpdatedBy;
|
|
110
|
+
payment.Remarks = paymentData.Remarks;
|
|
111
|
+
payment.RelatedObjectId = paymentData.RelatedObjectId;
|
|
112
|
+
payment.RelatedObjectType = paymentData.RelatedObjectType;
|
|
113
|
+
payment.ReceiptDocNo = paymentData.ReceiptDocNo;
|
|
114
|
+
payment.AccSystemRefId = paymentData.AccSystemRefId;
|
|
115
|
+
payment.PostedToAccSystemYN = paymentData.PostedToAccSystemYN;
|
|
116
|
+
payment.PostedById = paymentData.PostedById;
|
|
117
|
+
payment.PostedDateTime = paymentData.PostedDateTime;
|
|
118
|
+
return payment;
|
|
119
|
+
} else {
|
|
120
|
+
const notFoundError = new RecordNotFoundError(
|
|
121
|
+
'PaymentErrMsg',
|
|
122
|
+
'No Record Found.',
|
|
123
|
+
);
|
|
124
|
+
throw notFoundError;
|
|
125
|
+
}
|
|
126
|
+
} catch (error) {
|
|
127
|
+
console.log('Payment Class constructor err: ', error);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async getPaymentItems(dbTransaction?: any): Promise<PaymentItem[]> {
|
|
132
|
+
try {
|
|
133
|
+
if (this.PaymentId !== 'New') {
|
|
134
|
+
const paymentItems = await Payment._PaymentItemRepository.findAll({
|
|
135
|
+
where: {
|
|
136
|
+
PaymentId: this.PaymentId,
|
|
137
|
+
},
|
|
138
|
+
transaction: dbTransaction || this._DbTransaction,
|
|
139
|
+
});
|
|
140
|
+
const paymentItemObjects = paymentItems.map((paymentItem) => {
|
|
141
|
+
const pi = new PaymentItem(
|
|
142
|
+
new Payment(this._DbTransaction, paymentItem.PaymentId),
|
|
143
|
+
{
|
|
144
|
+
ObjectId: this.ObjectId,
|
|
145
|
+
ObjectName: this.ObjectName,
|
|
146
|
+
TableName: this.TableName,
|
|
147
|
+
ObjectType: this.ObjectType,
|
|
148
|
+
} as ObjectBase,
|
|
149
|
+
);
|
|
150
|
+
pi.PayForObjectType = paymentItem.PayForObjectType;
|
|
151
|
+
pi.PayForObjectId = paymentItem.PayForObjectId;
|
|
152
|
+
pi.Currency = paymentItem.Currency;
|
|
153
|
+
pi.Amount = paymentItem.Amount;
|
|
154
|
+
pi.Name = paymentItem.Name;
|
|
155
|
+
pi.Description = paymentItem.Description;
|
|
156
|
+
|
|
157
|
+
return pi;
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
this._PaymentItems = paymentItemObjects;
|
|
161
|
+
return this._PaymentItems;
|
|
162
|
+
} else {
|
|
163
|
+
return this._PaymentItems;
|
|
164
|
+
}
|
|
165
|
+
} catch (error) {
|
|
166
|
+
throw error;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async getPaymentPaidWith(dbTransaction?: any): Promise<PaymentPaidWith[]> {
|
|
171
|
+
try {
|
|
172
|
+
if (this.PaymentId !== 'New') {
|
|
173
|
+
const paymentPaidWithItems =
|
|
174
|
+
await Payment._PaymentPaidWithRepository.findAll({
|
|
175
|
+
where: {
|
|
176
|
+
PaymentId: this.PaymentId,
|
|
177
|
+
},
|
|
178
|
+
transaction: dbTransaction || this._DbTransaction,
|
|
179
|
+
});
|
|
180
|
+
const paymentPaidWithObjects = paymentPaidWithItems.map(
|
|
181
|
+
(paymentPaidWithItem) => {
|
|
182
|
+
const ppw = new PaymentPaidWith(
|
|
183
|
+
new Payment(this._DbTransaction, paymentPaidWithItem.PaymentId),
|
|
184
|
+
paymentPaidWithItem.MethodTypeId,
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
ppw.Currency = paymentPaidWithItem.Currency;
|
|
188
|
+
ppw.Amount = paymentPaidWithItem.Amount;
|
|
189
|
+
ppw.Status = paymentPaidWithItem.Status;
|
|
190
|
+
ppw.TransactionId = paymentPaidWithItem.TransactionId;
|
|
191
|
+
ppw.RefBank = paymentPaidWithItem.RefBank;
|
|
192
|
+
ppw.RefName = paymentPaidWithItem.RefName;
|
|
193
|
+
ppw.RefNo = paymentPaidWithItem.RefNo;
|
|
194
|
+
ppw.RefOther1 = paymentPaidWithItem.RefOther1;
|
|
195
|
+
ppw.RefOther2 = paymentPaidWithItem.RefOther2;
|
|
196
|
+
ppw.RefOther3 = paymentPaidWithItem.RefOther3;
|
|
197
|
+
ppw.RefOther4 = paymentPaidWithItem.RefOther4;
|
|
198
|
+
ppw.RefOther5 = paymentPaidWithItem.RefOther5;
|
|
199
|
+
ppw.Remarks = paymentPaidWithItem.Remarks;
|
|
200
|
+
ppw.PaymentMediaId = paymentPaidWithItem.PaymentMediaId;
|
|
201
|
+
|
|
202
|
+
return ppw;
|
|
203
|
+
},
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
this._PaymentPaidWith = paymentPaidWithObjects;
|
|
207
|
+
return this._PaymentPaidWith;
|
|
208
|
+
} else {
|
|
209
|
+
return this._PaymentPaidWith;
|
|
210
|
+
}
|
|
211
|
+
} catch (error) {
|
|
212
|
+
throw error;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
newPaymentItem(objectBeingPaidFor: ObjectBase): PaymentItem {
|
|
217
|
+
const paymentItem = new PaymentItem(this, objectBeingPaidFor);
|
|
218
|
+
this._PaymentItems.push(paymentItem);
|
|
219
|
+
return paymentItem;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
newPaymentPaidWith(paymentMethodTypeId: string) {
|
|
223
|
+
const paymentPaidWith = new PaymentPaidWith(
|
|
224
|
+
this,
|
|
225
|
+
paymentMethodTypeId,
|
|
226
|
+
this._DbTransaction,
|
|
227
|
+
);
|
|
228
|
+
this._PaymentPaidWith.push(paymentPaidWith);
|
|
229
|
+
return paymentPaidWith;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
init(Params: IPaymentParams): void {
|
|
233
|
+
if (Params.Currency) this.Currency = Params.Currency;
|
|
234
|
+
if (Params.PaymentType) this.PaymentType = Params.PaymentType;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export class IPaymentItemAttr {
|
|
2
|
-
PaymentId: string;
|
|
3
|
-
PayForObjectId: string;
|
|
4
|
-
PayForObjectType: string;
|
|
5
|
-
Currency: string;
|
|
6
|
-
Amount: number;
|
|
7
|
-
Name?: string;
|
|
8
|
-
Description: string;
|
|
9
|
-
Remarks?: string;
|
|
10
|
-
}
|
|
1
|
+
export class IPaymentItemAttr {
|
|
2
|
+
PaymentId: string;
|
|
3
|
+
PayForObjectId: string;
|
|
4
|
+
PayForObjectType: string;
|
|
5
|
+
Currency: string;
|
|
6
|
+
Amount: number;
|
|
7
|
+
Name?: string;
|
|
8
|
+
Description: string;
|
|
9
|
+
Remarks?: string;
|
|
10
|
+
}
|
|
@@ -1,11 +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
|
-
}
|
|
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
|
+
}
|