@tomei/rental 0.17.3 → 0.17.4-dev.10
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/src/components/joint-hirer/joint-hirer.d.ts +2 -0
- package/dist/src/components/joint-hirer/joint-hirer.js +38 -0
- package/dist/src/components/joint-hirer/joint-hirer.js.map +1 -1
- package/dist/src/components/rental/rental.d.ts +1 -0
- package/dist/src/components/rental/rental.js +41 -1
- package/dist/src/components/rental/rental.js.map +1 -1
- package/dist/src/components/rental-hirer-change-request/rental-hirer-change-request.js +20 -19
- package/dist/src/components/rental-hirer-change-request/rental-hirer-change-request.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/joint-hirer/joint-hirer.ts +63 -0
- package/src/components/rental/rental.ts +69 -1
- package/src/components/rental-hirer-change-request/rental-hirer-change-request.ts +47 -34
- package/dist/src/components/agreement-signature/hirer-signature.d.ts +0 -27
- package/dist/src/components/agreement-signature/hirer-signature.js +0 -112
- package/dist/src/components/agreement-signature/hirer-signature.js.map +0 -1
- package/dist/src/components/agreement-signature/hirer-signature.repository.d.ts +0 -8
- package/dist/src/components/agreement-signature/hirer-signature.repository.js +0 -67
- package/dist/src/components/agreement-signature/hirer-signature.repository.js.map +0 -1
- package/dist/src/components/hirer-signature/hirer-signature.d.ts +0 -27
- package/dist/src/components/hirer-signature/hirer-signature.js +0 -112
- package/dist/src/components/hirer-signature/hirer-signature.js.map +0 -1
- package/dist/src/components/hirer-signature/hirer-signature.repository.d.ts +0 -8
- package/dist/src/components/hirer-signature/hirer-signature.repository.js +0 -67
- package/dist/src/components/hirer-signature/hirer-signature.repository.js.map +0 -1
- package/dist/src/enum/hirer-signature-status.enum.d.ts +0 -4
- package/dist/src/enum/hirer-signature-status.enum.js +0 -9
- package/dist/src/enum/hirer-signature-status.enum.js.map +0 -1
- package/dist/src/interfaces/hirer-signature-attr.interface.d.ts +0 -14
- package/dist/src/interfaces/hirer-signature-attr.interface.js +0 -3
- package/dist/src/interfaces/hirer-signature-attr.interface.js.map +0 -1
- package/dist/src/models/hirer-signature.entity.d.ts +0 -16
- package/dist/src/models/hirer-signature.entity.js +0 -100
- package/dist/src/models/hirer-signature.entity.js.map +0 -1
package/package.json
CHANGED
|
@@ -4,6 +4,8 @@ import { IJointHirerAttr } from '../../interfaces/joint-hirer-attr.interface';
|
|
|
4
4
|
import { ApplicationConfig } from '@tomei/config';
|
|
5
5
|
import { LoginUser } from '@tomei/sso';
|
|
6
6
|
import { ActionEnum, Activity } from '@tomei/activity-history';
|
|
7
|
+
import { Rental } from '../rental/rental';
|
|
8
|
+
import { RentalAccountTypeEnum } from '../../enum/account-type.enum';
|
|
7
9
|
|
|
8
10
|
export class JointHirer extends ObjectBase {
|
|
9
11
|
ObjectId: string;
|
|
@@ -18,6 +20,7 @@ export class JointHirer extends ObjectBase {
|
|
|
18
20
|
CreatedAt: Date;
|
|
19
21
|
UpdatedById: string;
|
|
20
22
|
UpdatedAt: Date;
|
|
23
|
+
private _Rental: Rental;
|
|
21
24
|
|
|
22
25
|
get HirerId(): string {
|
|
23
26
|
return this.ObjectId;
|
|
@@ -146,6 +149,16 @@ export class JointHirer extends ObjectBase {
|
|
|
146
149
|
|
|
147
150
|
await activity.create(loginUser.ObjectId, dbTransaction);
|
|
148
151
|
|
|
152
|
+
//update the AccountType
|
|
153
|
+
const rental = await this.getRental(dbTransaction);
|
|
154
|
+
const totalIds = await rental.getCustomerIds(loginUser, dbTransaction);
|
|
155
|
+
|
|
156
|
+
if (totalIds.length > 1 && rental.AccountType === 'Single') {
|
|
157
|
+
await rental.update(loginUser, dbTransaction, {
|
|
158
|
+
AccountType: RentalAccountTypeEnum.JOINT,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
149
162
|
return this;
|
|
150
163
|
} catch (error) {
|
|
151
164
|
throw error;
|
|
@@ -154,6 +167,20 @@ export class JointHirer extends ObjectBase {
|
|
|
154
167
|
|
|
155
168
|
public async remove(loginUser: LoginUser, dbTransaction?: any) {
|
|
156
169
|
try {
|
|
170
|
+
//Make sure this.HirerId exists
|
|
171
|
+
if (!this.HirerId) {
|
|
172
|
+
throw new ClassError(
|
|
173
|
+
'JointHirer',
|
|
174
|
+
'JointHirerErrMsg02',
|
|
175
|
+
'HirerId is required to remove Joint Hirer.',
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
//Make sure this.Status is not "Inactive"
|
|
180
|
+
if (this.Status === 'Inactive') {
|
|
181
|
+
return this;
|
|
182
|
+
}
|
|
183
|
+
|
|
157
184
|
//Mark Joint Hirer as Inactive
|
|
158
185
|
const entityValueBefore: IJointHirerAttr = this.toJSON();
|
|
159
186
|
this.Status = 'Inactive'; // Set status to 'Inactive' instead of deleting the record
|
|
@@ -181,9 +208,45 @@ export class JointHirer extends ObjectBase {
|
|
|
181
208
|
|
|
182
209
|
await activity.create(loginUser.ObjectId, dbTransaction);
|
|
183
210
|
|
|
211
|
+
//update the AccountType
|
|
212
|
+
const rental = await this.getRental(dbTransaction);
|
|
213
|
+
const totalIds = await rental.getCustomerIds(loginUser, dbTransaction);
|
|
214
|
+
|
|
215
|
+
if (totalIds.length === 1 && rental.AccountType === 'Joint') {
|
|
216
|
+
await rental.update(loginUser, dbTransaction, {
|
|
217
|
+
AccountType: RentalAccountTypeEnum.SINGLE,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
|
|
184
221
|
return this;
|
|
185
222
|
} catch (error) {
|
|
186
223
|
throw error;
|
|
187
224
|
}
|
|
188
225
|
}
|
|
226
|
+
|
|
227
|
+
private async getRental(dbTransaction?: any) {
|
|
228
|
+
if (this._Rental) {
|
|
229
|
+
return this._Rental;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (!this.RentalId) {
|
|
233
|
+
throw new ClassError(
|
|
234
|
+
'JointHirer',
|
|
235
|
+
'JointHirerErrMsg04',
|
|
236
|
+
'RentalId is empty.',
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
console.log('JointHirer getRental', this.RentalId);
|
|
240
|
+
this._Rental = await Rental.init(this.RentalId, dbTransaction);
|
|
241
|
+
|
|
242
|
+
if (!this._Rental) {
|
|
243
|
+
throw new ClassError(
|
|
244
|
+
'JointHirer',
|
|
245
|
+
'JointHirerErrMsg05',
|
|
246
|
+
'Rental not found.',
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return this._Rental;
|
|
251
|
+
}
|
|
189
252
|
}
|
|
@@ -128,10 +128,11 @@ export class Rental extends ObjectBase {
|
|
|
128
128
|
}
|
|
129
129
|
return new Rental();
|
|
130
130
|
} catch (error) {
|
|
131
|
+
console.error('Error initializing Rental:', error);
|
|
131
132
|
throw new ClassError(
|
|
132
133
|
'Rental',
|
|
133
134
|
'RentalErrMsg00',
|
|
134
|
-
'Failed To Initialize
|
|
135
|
+
'Failed To Initialize Rental',
|
|
135
136
|
);
|
|
136
137
|
}
|
|
137
138
|
}
|
|
@@ -796,6 +797,7 @@ export class Rental extends ObjectBase {
|
|
|
796
797
|
const options: any = {
|
|
797
798
|
where: {
|
|
798
799
|
RentalId: this.RentalId,
|
|
800
|
+
Status: 'Active',
|
|
799
801
|
},
|
|
800
802
|
transaction: dbTransaction,
|
|
801
803
|
};
|
|
@@ -1390,4 +1392,70 @@ export class Rental extends ObjectBase {
|
|
|
1390
1392
|
throw error;
|
|
1391
1393
|
}
|
|
1392
1394
|
}
|
|
1395
|
+
|
|
1396
|
+
public async update(
|
|
1397
|
+
loginUser: LoginUser,
|
|
1398
|
+
dbTransaction: any,
|
|
1399
|
+
updates: Partial<IRentalAttr>,
|
|
1400
|
+
): Promise<Rental> {
|
|
1401
|
+
try {
|
|
1402
|
+
// Part 1: Privilege Checking
|
|
1403
|
+
const systemCode =
|
|
1404
|
+
ApplicationConfig.getComponentConfigValue('system-code');
|
|
1405
|
+
const isPrivileged = await loginUser.checkPrivileges(
|
|
1406
|
+
systemCode,
|
|
1407
|
+
'RENTAL_UPDATE',
|
|
1408
|
+
);
|
|
1409
|
+
|
|
1410
|
+
if (!isPrivileged) {
|
|
1411
|
+
throw new ClassError(
|
|
1412
|
+
'Rental',
|
|
1413
|
+
'RentalErrMsg01',
|
|
1414
|
+
"You do not have 'RENTAL_UPDATE' privilege.",
|
|
1415
|
+
);
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
// Part 2: Validation
|
|
1419
|
+
if (!this.ObjectId) {
|
|
1420
|
+
throw new ClassError(
|
|
1421
|
+
'Rental',
|
|
1422
|
+
'RentalErrMsg01',
|
|
1423
|
+
'Rental not found. Rental Id is empty.',
|
|
1424
|
+
);
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
// Part 3: Capture Record Info Before Changes
|
|
1428
|
+
const entityValueBefore = this.toJSON();
|
|
1429
|
+
|
|
1430
|
+
// Part 4: Update Rental Record
|
|
1431
|
+
await Rental._Repo.update(updates, {
|
|
1432
|
+
where: {
|
|
1433
|
+
RentalId: this.RentalId,
|
|
1434
|
+
},
|
|
1435
|
+
transaction: dbTransaction,
|
|
1436
|
+
});
|
|
1437
|
+
|
|
1438
|
+
// Part 5: Update object instance properties and capture after changes
|
|
1439
|
+
Object.assign(this, updates);
|
|
1440
|
+
this._UpdatedById = loginUser.ObjectId;
|
|
1441
|
+
this._UpdatedAt = new Date();
|
|
1442
|
+
|
|
1443
|
+
const entityValueAfter = this.toJSON();
|
|
1444
|
+
|
|
1445
|
+
// Part 6: Record Activity
|
|
1446
|
+
const activity = new Activity();
|
|
1447
|
+
activity.ActivityId = activity.createId();
|
|
1448
|
+
activity.Action = ActionEnum.UPDATE;
|
|
1449
|
+
activity.Description = 'Update Rental';
|
|
1450
|
+
activity.EntityType = this.ObjectType;
|
|
1451
|
+
activity.EntityId = this.ObjectId;
|
|
1452
|
+
activity.EntityValueBefore = JSON.stringify(entityValueBefore);
|
|
1453
|
+
activity.EntityValueAfter = JSON.stringify(entityValueAfter);
|
|
1454
|
+
await activity.create(loginUser.ObjectId, dbTransaction);
|
|
1455
|
+
|
|
1456
|
+
return this;
|
|
1457
|
+
} catch (error) {
|
|
1458
|
+
throw error;
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1393
1461
|
}
|
|
@@ -227,16 +227,8 @@ export class RentalHirerChangeRequest
|
|
|
227
227
|
}
|
|
228
228
|
const rental = await Rental.init(dbTransaction, this.RentalId);
|
|
229
229
|
|
|
230
|
-
// 2.2 Only allow for joint account
|
|
231
|
-
if (rental.AccountType !== RentalAccountTypeEnum.JOINT) {
|
|
232
|
-
throw new ClassError(
|
|
233
|
-
'HirerChangeRequest',
|
|
234
|
-
'HirerChangeRequestErrMsg03',
|
|
235
|
-
'Only Rental with Joint Account Type Allowed.',
|
|
236
|
-
);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
230
|
// 2.3 only allow for rental account where its joint hirer not maximum yet (at this step you've retrieve the number of joint hirer)
|
|
231
|
+
rental.AccountType = RentalAccountTypeEnum.JOINT;
|
|
240
232
|
const jointHirers = await rental.getJointHirers(dbTransaction);
|
|
241
233
|
|
|
242
234
|
if (this.Type === HirerChangeRequestTypeEnum.ADD) {
|
|
@@ -253,18 +245,6 @@ export class RentalHirerChangeRequest
|
|
|
253
245
|
);
|
|
254
246
|
}
|
|
255
247
|
}
|
|
256
|
-
// For Remove type, we don't need to check the max joint hirer length
|
|
257
|
-
// but we need to ensure that there is at least one joint hirer left after removal
|
|
258
|
-
if (
|
|
259
|
-
this.Type == HirerChangeRequestTypeEnum.REMOVE &&
|
|
260
|
-
jointHirers?.length <= 1
|
|
261
|
-
) {
|
|
262
|
-
throw new ClassError(
|
|
263
|
-
'HirerChangeRequest',
|
|
264
|
-
'HirerChangeRequestErrMsg05',
|
|
265
|
-
'Cannot remove the last joint hirer.',
|
|
266
|
-
);
|
|
267
|
-
}
|
|
268
248
|
|
|
269
249
|
// 2.4 avoid duplicate request, call this.checkForDuplicate() private method, this method will ensure no record with same RentalId and same Type and Status is not "Completed" or "Cancelled"
|
|
270
250
|
await this.checkForDuplicate(dbTransaction);
|
|
@@ -465,6 +445,7 @@ export class RentalHirerChangeRequest
|
|
|
465
445
|
}
|
|
466
446
|
|
|
467
447
|
// 2. Prepare all signature data (main + joint) in one go
|
|
448
|
+
this.Rental.AccountType = RentalAccountTypeEnum.JOINT;
|
|
468
449
|
const jointHirers = await this.Rental.getJointHirers(dbTransaction);
|
|
469
450
|
|
|
470
451
|
// Main hirer signature
|
|
@@ -474,23 +455,32 @@ export class RentalHirerChangeRequest
|
|
|
474
455
|
mainSignature.HirerType = HirerChangeRequestHirerRoleEnum.MAIN;
|
|
475
456
|
mainSignature.Method = 'Upload';
|
|
476
457
|
|
|
477
|
-
// Joint hirer signatures
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
458
|
+
// Joint hirer signatures - only if there are joint hirers
|
|
459
|
+
let jointSignatures = [];
|
|
460
|
+
if (jointHirers.length > 0) {
|
|
461
|
+
const jointSignaturePromises = jointHirers.map(async (jointHirer) => {
|
|
462
|
+
const signature = await HirerChangeRequestSignature.init();
|
|
463
|
+
signature.RequestId = this.RequestId;
|
|
464
|
+
signature.JointHirerId = jointHirer.HirerId;
|
|
465
|
+
signature.HirerType = HirerChangeRequestHirerRoleEnum.JOINT;
|
|
466
|
+
signature.Method = 'Upload';
|
|
467
|
+
return signature;
|
|
468
|
+
});
|
|
486
469
|
|
|
487
|
-
|
|
470
|
+
jointSignatures = await Promise.all(jointSignaturePromises);
|
|
471
|
+
}
|
|
488
472
|
|
|
489
473
|
// 3. Create all signatures in parallel
|
|
490
|
-
|
|
474
|
+
const signaturesToCreate = [
|
|
491
475
|
mainSignature.create(loginUser, dbTransaction),
|
|
492
|
-
|
|
493
|
-
|
|
476
|
+
];
|
|
477
|
+
if (jointSignatures.length > 0) {
|
|
478
|
+
signaturesToCreate.push(
|
|
479
|
+
...jointSignatures.map((sig) => sig.create(loginUser, dbTransaction)),
|
|
480
|
+
);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
await Promise.all(signaturesToCreate);
|
|
494
484
|
|
|
495
485
|
this.Signatures = [mainSignature, ...jointSignatures];
|
|
496
486
|
} catch (error) {
|
|
@@ -818,6 +808,12 @@ export class RentalHirerChangeRequest
|
|
|
818
808
|
jointHirer.CustomerId = customerId;
|
|
819
809
|
jointHirer.CustomerType = customerType;
|
|
820
810
|
await jointHirer.create(loginUser, dbTransaction);
|
|
811
|
+
|
|
812
|
+
//d. Set the AccountType to "Joint" for the rental
|
|
813
|
+
// const rental = await Rental.init(dbTransaction, this.RentalId);
|
|
814
|
+
// await rental.update(loginUser, dbTransaction, {
|
|
815
|
+
// AccountType: RentalAccountTypeEnum.JOINT,
|
|
816
|
+
// });
|
|
821
817
|
} else if (this.Type === HirerChangeRequestTypeEnum.REMOVE) {
|
|
822
818
|
// a. Get joint hirer from remove hirer request
|
|
823
819
|
const removeHirer = await this.getRemoveHirer(dbTransaction);
|
|
@@ -828,6 +824,23 @@ export class RentalHirerChangeRequest
|
|
|
828
824
|
|
|
829
825
|
//Call jointHirer.remove() method by passing loginUser and dbTransaction
|
|
830
826
|
await jointHirer.remove(loginUser, dbTransaction);
|
|
827
|
+
|
|
828
|
+
// //find the number of joint hirers after removal
|
|
829
|
+
// const rental = await Rental.init(dbTransaction, this.RentalId);
|
|
830
|
+
// rental.AccountType = RentalAccountTypeEnum.JOINT;
|
|
831
|
+
// const jointHirers = await rental.getJointHirers(dbTransaction);
|
|
832
|
+
|
|
833
|
+
// //filter out the active joint hirers
|
|
834
|
+
// const activeJointHirers = jointHirers.filter(
|
|
835
|
+
// (hirer) => hirer.Status === 'Active',
|
|
836
|
+
// );
|
|
837
|
+
|
|
838
|
+
// //if jointHirers is empty, set rental.AccountType to "Single"
|
|
839
|
+
// if (activeJointHirers.length === 0) {
|
|
840
|
+
// await rental.update(loginUser, dbTransaction, {
|
|
841
|
+
// AccountType: RentalAccountTypeEnum.SINGLE,
|
|
842
|
+
// });
|
|
843
|
+
// }
|
|
831
844
|
}
|
|
832
845
|
|
|
833
846
|
// 3. Call _Repo update method
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ObjectBase } from '@tomei/general';
|
|
2
|
-
import { HirerSignatureRepository } from './hirer-signature.repository';
|
|
3
|
-
import { IHirerSignatureAttr } from '../../interfaces/agreemeent-signature-attr.interface';
|
|
4
|
-
import { LoginUser } from '@tomei/sso';
|
|
5
|
-
import { HirerSignatureStatusEnum } from '../../enum/agreement-signature-status.enum';
|
|
6
|
-
export declare class HirerSignature extends ObjectBase {
|
|
7
|
-
ObjectId: string;
|
|
8
|
-
ObjectName: string;
|
|
9
|
-
ObjectType: string;
|
|
10
|
-
TableName: string;
|
|
11
|
-
AgreementNo: string;
|
|
12
|
-
HirerType: string;
|
|
13
|
-
CustomerId: string;
|
|
14
|
-
CustomerType: string;
|
|
15
|
-
SignatureStatus: HirerSignatureStatusEnum;
|
|
16
|
-
SignedAt: Date;
|
|
17
|
-
CreatedById: string;
|
|
18
|
-
CreatedAt: Date;
|
|
19
|
-
UpdatedById: string;
|
|
20
|
-
UpdatedAt: Date;
|
|
21
|
-
get HirerSignatureId(): string;
|
|
22
|
-
set HirerSignatureId(value: string);
|
|
23
|
-
protected static _Repository: HirerSignatureRepository;
|
|
24
|
-
protected constructor(hirerSignatureAttr?: IHirerSignatureAttr);
|
|
25
|
-
static init(HirerSignatureId?: string, dbTransaction?: any): Promise<HirerSignature>;
|
|
26
|
-
create(loginUser: LoginUser, dbTransaction?: any): Promise<this>;
|
|
27
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.HirerSignature = void 0;
|
|
13
|
-
const general_1 = require("@tomei/general");
|
|
14
|
-
const hirer_signature_repository_1 = require("./hirer-signature.repository");
|
|
15
|
-
const config_1 = require("@tomei/config");
|
|
16
|
-
const activity_history_1 = require("@tomei/activity-history");
|
|
17
|
-
class HirerSignature extends general_1.ObjectBase {
|
|
18
|
-
get HirerSignatureId() {
|
|
19
|
-
return this.ObjectId;
|
|
20
|
-
}
|
|
21
|
-
set HirerSignatureId(value) {
|
|
22
|
-
this.ObjectId = value;
|
|
23
|
-
}
|
|
24
|
-
constructor(hirerSignatureAttr) {
|
|
25
|
-
super();
|
|
26
|
-
this.ObjectType = 'HirerSignature';
|
|
27
|
-
this.TableName = 'rental_HirerSignature';
|
|
28
|
-
if (hirerSignatureAttr) {
|
|
29
|
-
this.HirerSignatureId = hirerSignatureAttr.HirerSignatureId;
|
|
30
|
-
this.AgreementNo = hirerSignatureAttr.AgreementNo;
|
|
31
|
-
this.HirerType = hirerSignatureAttr.HirerType;
|
|
32
|
-
this.CustomerId = hirerSignatureAttr.CustomerId;
|
|
33
|
-
this.CustomerType = hirerSignatureAttr.CustomerType;
|
|
34
|
-
this.SignatureStatus = hirerSignatureAttr.SignatureStatus;
|
|
35
|
-
this.SignedAt = hirerSignatureAttr.SignedAt;
|
|
36
|
-
this.CreatedById = hirerSignatureAttr.CreatedById;
|
|
37
|
-
this.CreatedAt = hirerSignatureAttr.CreatedAt;
|
|
38
|
-
this.UpdatedById = hirerSignatureAttr.UpdatedById;
|
|
39
|
-
this.UpdatedAt = hirerSignatureAttr.UpdatedAt;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
static init(HirerSignatureId, dbTransaction) {
|
|
43
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
try {
|
|
45
|
-
if (HirerSignatureId) {
|
|
46
|
-
const hs = yield HirerSignature._Repository.findByPk(HirerSignatureId, dbTransaction);
|
|
47
|
-
if (hs) {
|
|
48
|
-
return new HirerSignature(hs.get({ plain: true }));
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
throw new general_1.ClassError('HirerSignature', 'HirerSignatureErrMsg01', 'HirerSignature not found');
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return new HirerSignature();
|
|
55
|
-
}
|
|
56
|
-
catch (error) {
|
|
57
|
-
throw error;
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
create(loginUser, dbTransaction) {
|
|
62
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
try {
|
|
64
|
-
const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
|
|
65
|
-
const isPrivileged = yield loginUser.checkPrivileges(systemCode, 'HirerSignature - Create');
|
|
66
|
-
if (!isPrivileged) {
|
|
67
|
-
throw new general_1.ClassError('HirerSignature', 'HirerSignatureErrMsg00', "You do not have 'HirerSignature - Create' privilege.");
|
|
68
|
-
}
|
|
69
|
-
if (!this.AgreementNo || !this.CustomerId || !this.CustomerType) {
|
|
70
|
-
throw new general_1.ClassError('HirerSignature', 'HirerSignatureErrMsg03', 'AgreementNo, CustomerId and CustomerType are required.');
|
|
71
|
-
}
|
|
72
|
-
this.ObjectId = this.createId();
|
|
73
|
-
this.CreatedById = loginUser.ObjectId;
|
|
74
|
-
this.CreatedAt = new Date();
|
|
75
|
-
this.UpdatedById = loginUser.ObjectId;
|
|
76
|
-
this.UpdatedAt = new Date();
|
|
77
|
-
const entityValueAfter = {
|
|
78
|
-
HirerSignatureId: this.HirerSignatureId,
|
|
79
|
-
AgreementNo: this.AgreementNo,
|
|
80
|
-
HirerType: this.HirerType,
|
|
81
|
-
CustomerId: this.CustomerId,
|
|
82
|
-
CustomerType: this.CustomerType,
|
|
83
|
-
SignatureStatus: this.SignatureStatus,
|
|
84
|
-
SignedAt: this.SignedAt,
|
|
85
|
-
CreatedById: this.CreatedById,
|
|
86
|
-
CreatedAt: this.CreatedAt,
|
|
87
|
-
UpdatedById: this.UpdatedById,
|
|
88
|
-
UpdatedAt: this.UpdatedAt,
|
|
89
|
-
};
|
|
90
|
-
yield HirerSignature._Repository.create(entityValueAfter, {
|
|
91
|
-
transaction: dbTransaction,
|
|
92
|
-
});
|
|
93
|
-
const activity = new activity_history_1.Activity();
|
|
94
|
-
activity.ObjectId = this.createId();
|
|
95
|
-
activity.Action = activity_history_1.ActionEnum.CREATE;
|
|
96
|
-
activity.Description = 'Add Joint Hirer Signature';
|
|
97
|
-
activity.EntityId = this.ObjectId;
|
|
98
|
-
activity.EntityType = this.ObjectType;
|
|
99
|
-
activity.EntityValueBefore = JSON.stringify({});
|
|
100
|
-
activity.EntityValueAfter = JSON.stringify(entityValueAfter);
|
|
101
|
-
yield activity.create(loginUser.ObjectId, dbTransaction);
|
|
102
|
-
return this;
|
|
103
|
-
}
|
|
104
|
-
catch (error) {
|
|
105
|
-
throw error;
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
exports.HirerSignature = HirerSignature;
|
|
111
|
-
HirerSignature._Repository = new hirer_signature_repository_1.HirerSignatureRepository();
|
|
112
|
-
//# sourceMappingURL=hirer-signature.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hirer-signature.js","sourceRoot":"","sources":["../../../../src/components/agreement-signature/hirer-signature.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAAwD;AACxD,6EAAwE;AAExE,0CAAkD;AAElD,8DAA+D;AAG/D,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AAC;KAAA;;AAlIH,wCAmIC;AA3GkB,0BAAW,GAAG,IAAI,qDAAwB,EAAE,AAAjC,CAAkC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { RepositoryBase, IRepositoryBase } from '@tomei/general';
|
|
2
|
-
import { HirerSignatureModel } from '../../models/agreement-signature.entity';
|
|
3
|
-
export declare class HirerSignatureRepository extends RepositoryBase<HirerSignatureModel> implements IRepositoryBase<HirerSignatureModel> {
|
|
4
|
-
constructor();
|
|
5
|
-
findByPk(id: string, transaction?: any): Promise<HirerSignatureModel | null>;
|
|
6
|
-
delete(hirerId: string, dbTransaction?: any): Promise<void>;
|
|
7
|
-
findAndCountAll(options?: any): Promise<any>;
|
|
8
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.HirerSignatureRepository = void 0;
|
|
13
|
-
const general_1 = require("@tomei/general");
|
|
14
|
-
const agreement_signature_entity_1 = require("../../models/agreement-signature.entity");
|
|
15
|
-
class HirerSignatureRepository extends general_1.RepositoryBase {
|
|
16
|
-
constructor() {
|
|
17
|
-
super(agreement_signature_entity_1.HirerSignatureModel);
|
|
18
|
-
}
|
|
19
|
-
findByPk(id, transaction) {
|
|
20
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
try {
|
|
22
|
-
const result = yield agreement_signature_entity_1.HirerSignatureModel.findByPk(id, {
|
|
23
|
-
transaction: transaction,
|
|
24
|
-
});
|
|
25
|
-
return result;
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
throw new Error(`An Error occured when fetching : ${error.message}`);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
delete(hirerId, dbTransaction) {
|
|
33
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
try {
|
|
35
|
-
const options = {
|
|
36
|
-
where: {
|
|
37
|
-
HirerId: hirerId,
|
|
38
|
-
},
|
|
39
|
-
transaction: dbTransaction,
|
|
40
|
-
};
|
|
41
|
-
yield agreement_signature_entity_1.HirerSignatureModel.destroy(options);
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
throw new Error(`An Error occured when delete : ${error.message}`);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
findAndCountAll(options) {
|
|
49
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
try {
|
|
51
|
-
let jointHirers;
|
|
52
|
-
if (options) {
|
|
53
|
-
jointHirers = yield agreement_signature_entity_1.HirerSignatureModel.findAndCountAll(options);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
jointHirers = yield agreement_signature_entity_1.HirerSignatureModel.findAndCountAll();
|
|
57
|
-
}
|
|
58
|
-
return jointHirers;
|
|
59
|
-
}
|
|
60
|
-
catch (error) {
|
|
61
|
-
throw new Error(`An Error occured when retriving : ${error.message}`);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
exports.HirerSignatureRepository = HirerSignatureRepository;
|
|
67
|
-
//# sourceMappingURL=hirer-signature.repository.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hirer-signature.repository.js","source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EAAE,CAAC;gBACf,MAAM,IAAI,KAAK,CAAC,qCAAqC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACxE,CAAC;QACH,CAAC;KAAA;CACF;AAlDD,4DAkDC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ObjectBase } from '@tomei/general';
|
|
2
|
-
import { HirerSignatureRepository } from './hirer-signature.repository';
|
|
3
|
-
import { IHirerSignatureAttr } from '../../interfaces/agreemeent-signature-attr.interface';
|
|
4
|
-
import { LoginUser } from '@tomei/sso';
|
|
5
|
-
import { HirerSignatureStatusEnum } from '../../enum/agreement-signature-status.enum';
|
|
6
|
-
export declare class HirerSignature extends ObjectBase {
|
|
7
|
-
ObjectId: string;
|
|
8
|
-
ObjectName: string;
|
|
9
|
-
ObjectType: string;
|
|
10
|
-
TableName: string;
|
|
11
|
-
AgreementNo: string;
|
|
12
|
-
HirerType: string;
|
|
13
|
-
CustomerId: string;
|
|
14
|
-
CustomerType: string;
|
|
15
|
-
SignatureStatus: HirerSignatureStatusEnum;
|
|
16
|
-
SignedAt: Date;
|
|
17
|
-
CreatedById: string;
|
|
18
|
-
CreatedAt: Date;
|
|
19
|
-
UpdatedById: string;
|
|
20
|
-
UpdatedAt: Date;
|
|
21
|
-
get HirerSignatureId(): string;
|
|
22
|
-
set HirerSignatureId(value: string);
|
|
23
|
-
protected static _Repository: HirerSignatureRepository;
|
|
24
|
-
protected constructor(hirerSignatureAttr?: IHirerSignatureAttr);
|
|
25
|
-
static init(HirerSignatureId?: string, dbTransaction?: any): Promise<HirerSignature>;
|
|
26
|
-
create(loginUser: LoginUser, dbTransaction?: any): Promise<this>;
|
|
27
|
-
}
|