@tomei/rental 0.17.1 → 0.17.3-dev.1
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/.husky/commit-msg +0 -6
- package/dist/src/components/agreement-signature/hirer-signature.d.ts +27 -0
- package/dist/src/components/agreement-signature/hirer-signature.js +112 -0
- package/dist/src/components/agreement-signature/hirer-signature.js.map +1 -0
- package/dist/src/components/agreement-signature/hirer-signature.repository.d.ts +8 -0
- package/dist/src/components/agreement-signature/hirer-signature.repository.js +67 -0
- package/dist/src/components/agreement-signature/hirer-signature.repository.js.map +1 -0
- package/dist/src/components/hirer-change-request-new-hirer/hirer-change-request-new-hirer.d.ts +32 -0
- package/dist/src/components/hirer-change-request-new-hirer/hirer-change-request-new-hirer.js +121 -0
- package/dist/src/components/hirer-change-request-new-hirer/hirer-change-request-new-hirer.js.map +1 -0
- package/dist/src/components/hirer-change-request-new-hirer/hirer-change-request-new-hirer.repository.d.ts +9 -0
- package/dist/src/components/hirer-change-request-new-hirer/hirer-change-request-new-hirer.repository.js +79 -0
- package/dist/src/components/hirer-change-request-new-hirer/hirer-change-request-new-hirer.repository.js.map +1 -0
- package/dist/src/components/hirer-change-request-remove-hirer/hirer-change-request-remove-hirer.d.ts +22 -0
- package/dist/src/components/hirer-change-request-remove-hirer/hirer-change-request-remove-hirer.js +104 -0
- package/dist/src/components/hirer-change-request-remove-hirer/hirer-change-request-remove-hirer.js.map +1 -0
- package/dist/src/components/hirer-change-request-remove-hirer/hirer-change-request-remove-hirer.repository.d.ts +9 -0
- package/dist/src/components/hirer-change-request-remove-hirer/hirer-change-request-remove-hirer.repository.js +80 -0
- package/dist/src/components/hirer-change-request-remove-hirer/hirer-change-request-remove-hirer.repository.js.map +1 -0
- package/dist/src/components/hirer-change-request-signature/hirer-change-request-signature.d.ts +30 -0
- package/dist/src/components/hirer-change-request-signature/hirer-change-request-signature.js +224 -0
- package/dist/src/components/hirer-change-request-signature/hirer-change-request-signature.js.map +1 -0
- package/dist/src/components/hirer-change-request-signature/hirer-change-request-signature.repository.d.ts +9 -0
- package/dist/src/components/hirer-change-request-signature/hirer-change-request-signature.repository.js +80 -0
- package/dist/src/components/hirer-change-request-signature/hirer-change-request-signature.repository.js.map +1 -0
- package/dist/src/components/hirer-signature/hirer-signature.d.ts +27 -0
- package/dist/src/components/hirer-signature/hirer-signature.js +112 -0
- package/dist/src/components/hirer-signature/hirer-signature.js.map +1 -0
- package/dist/src/components/hirer-signature/hirer-signature.repository.d.ts +8 -0
- package/dist/src/components/hirer-signature/hirer-signature.repository.js +67 -0
- package/dist/src/components/hirer-signature/hirer-signature.repository.js.map +1 -0
- package/dist/src/components/joint-hirer/joint-hirer.d.ts +3 -0
- package/dist/src/components/joint-hirer/joint-hirer.js +46 -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 +28 -0
- package/dist/src/components/rental/rental.js.map +1 -1
- package/dist/src/components/rental-hirer-change-request/rental-hirer-change-request.d.ts +70 -0
- package/dist/src/components/rental-hirer-change-request/rental-hirer-change-request.js +570 -0
- package/dist/src/components/rental-hirer-change-request/rental-hirer-change-request.js.map +1 -0
- package/dist/src/components/rental-hirer-change-request/rental-hirer-change-request.repository.d.ts +9 -0
- package/dist/src/components/rental-hirer-change-request/rental-hirer-change-request.repository.js +79 -0
- package/dist/src/components/rental-hirer-change-request/rental-hirer-change-request.repository.js.map +1 -0
- package/dist/src/database.js +8 -0
- package/dist/src/database.js.map +1 -1
- package/dist/src/enum/hirer-signature-status.enum.d.ts +4 -0
- package/dist/src/enum/hirer-signature-status.enum.js +9 -0
- package/dist/src/enum/hirer-signature-status.enum.js.map +1 -0
- package/dist/src/enum/index.d.ts +4 -1
- package/dist/src/enum/index.js +7 -1
- package/dist/src/enum/index.js.map +1 -1
- package/dist/src/enum/rental-hirer-change-request-hirer-role.d.ts +4 -0
- package/dist/src/enum/rental-hirer-change-request-hirer-role.js +9 -0
- package/dist/src/enum/rental-hirer-change-request-hirer-role.js.map +1 -0
- package/dist/src/enum/rental-hirer-change-request-status.d.ts +7 -0
- package/dist/src/enum/rental-hirer-change-request-status.js +12 -0
- package/dist/src/enum/rental-hirer-change-request-status.js.map +1 -0
- package/dist/src/enum/rental-hirer-change-request-type.d.ts +4 -0
- package/dist/src/enum/rental-hirer-change-request-type.js +9 -0
- package/dist/src/enum/rental-hirer-change-request-type.js.map +1 -0
- package/dist/src/index.d.ts +9 -1
- package/dist/src/index.js +17 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/interfaces/hirer-change-request-new-hirer-attr.interface.d.ts +15 -0
- package/dist/src/interfaces/hirer-change-request-new-hirer-attr.interface.js +3 -0
- package/dist/src/interfaces/hirer-change-request-new-hirer-attr.interface.js.map +1 -0
- package/dist/src/interfaces/hirer-change-request-remove-hirer-attr.interface.d.ts +5 -0
- package/dist/src/interfaces/hirer-change-request-remove-hirer-attr.interface.js +3 -0
- package/dist/src/interfaces/hirer-change-request-remove-hirer-attr.interface.js.map +1 -0
- package/dist/src/interfaces/hirer-change-request-signature-attr.interface.d.ts +14 -0
- package/dist/src/interfaces/hirer-change-request-signature-attr.interface.js +3 -0
- package/dist/src/interfaces/hirer-change-request-signature-attr.interface.js.map +1 -0
- package/dist/src/interfaces/hirer-signature-attr.interface.d.ts +14 -0
- package/dist/src/interfaces/hirer-signature-attr.interface.js +3 -0
- package/dist/src/interfaces/hirer-signature-attr.interface.js.map +1 -0
- package/dist/src/interfaces/index.d.ts +6 -1
- package/dist/src/interfaces/joint-hirer-attr.interface.d.ts +1 -0
- package/dist/src/interfaces/rental-hirer-change-request.attr.interface.d.ts +16 -0
- package/dist/src/interfaces/rental-hirer-change-request.attr.interface.js +3 -0
- package/dist/src/interfaces/rental-hirer-change-request.attr.interface.js.map +1 -0
- package/dist/src/interfaces/rental-hirer-change-request.update.interface.d.ts +4 -0
- package/dist/src/interfaces/rental-hirer-change-request.update.interface.js +3 -0
- package/dist/src/interfaces/rental-hirer-change-request.update.interface.js.map +1 -0
- package/dist/src/models/hirer-change-request-new-hirer.entity.d.ts +19 -0
- package/dist/src/models/hirer-change-request-new-hirer.entity.js +121 -0
- package/dist/src/models/hirer-change-request-new-hirer.entity.js.map +1 -0
- package/dist/src/models/hirer-change-request-remove-hirer.entity.d.ts +11 -0
- package/dist/src/models/hirer-change-request-remove-hirer.entity.js +57 -0
- package/dist/src/models/hirer-change-request-remove-hirer.entity.js.map +1 -0
- package/dist/src/models/hirer-change-request-signature.entity.d.ts +18 -0
- package/dist/src/models/hirer-change-request-signature.entity.js +101 -0
- package/dist/src/models/hirer-change-request-signature.entity.js.map +1 -0
- package/dist/src/models/hirer-signature.entity.d.ts +16 -0
- package/dist/src/models/hirer-signature.entity.js +100 -0
- package/dist/src/models/hirer-signature.entity.js.map +1 -0
- package/dist/src/models/index.d.ts +5 -1
- package/dist/src/models/index.js +9 -1
- package/dist/src/models/index.js.map +1 -1
- package/dist/src/models/joint-hirer.entity.d.ts +1 -0
- package/dist/src/models/joint-hirer.entity.js +12 -0
- package/dist/src/models/joint-hirer.entity.js.map +1 -1
- package/dist/src/models/rental-hirer-change-request.entity.d.ts +22 -0
- package/dist/src/models/rental-hirer-change-request.entity.js +108 -0
- package/dist/src/models/rental-hirer-change-request.entity.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/migrations/20250529092130-add-status-to-joint-hirer.js +19 -0
- package/migrations/hirer-change-request-new-hirer-migration.js +72 -0
- package/migrations/hirer-change-request-remove-hirer-migration.js +39 -0
- package/migrations/hirer-change-request-signature-migration.js +65 -0
- package/migrations/rental-hirer-change-request-migrations.js +64 -0
- package/package.json +3 -3
- package/src/components/hirer-change-request-new-hirer/hirer-change-request-new-hirer.repository.ts +64 -0
- package/src/components/hirer-change-request-new-hirer/hirer-change-request-new-hirer.ts +153 -0
- package/src/components/hirer-change-request-remove-hirer/hirer-change-request-remove-hirer.repository.ts +65 -0
- package/src/components/hirer-change-request-remove-hirer/hirer-change-request-remove-hirer.ts +134 -0
- package/src/components/hirer-change-request-signature/hirer-change-request-signature.repository.ts +65 -0
- package/src/components/hirer-change-request-signature/hirer-change-request-signature.ts +271 -0
- package/src/components/joint-hirer/joint-hirer.ts +52 -0
- package/src/components/rental/rental.ts +32 -0
- package/src/components/rental-hirer-change-request/rental-hirer-change-request.repository.ts +64 -0
- package/src/components/rental-hirer-change-request/rental-hirer-change-request.ts +919 -0
- package/src/database.ts +8 -0
- package/src/enum/index.ts +6 -0
- package/src/enum/rental-hirer-change-request-hirer-role.ts +4 -0
- package/src/enum/rental-hirer-change-request-status.ts +7 -0
- package/src/enum/rental-hirer-change-request-type.ts +4 -0
- package/src/index.ts +16 -0
- package/src/interfaces/hirer-change-request-new-hirer-attr.interface.ts +15 -0
- package/src/interfaces/hirer-change-request-remove-hirer-attr.interface.ts +5 -0
- package/src/interfaces/hirer-change-request-signature-attr.interface.ts +15 -0
- package/src/interfaces/index.ts +10 -0
- package/src/interfaces/joint-hirer-attr.interface.ts +1 -0
- package/src/interfaces/rental-hirer-change-request.attr.interface.ts +17 -0
- package/src/interfaces/rental-hirer-change-request.update.interface.ts +4 -0
- package/src/models/hirer-change-request-new-hirer.entity.ts +102 -0
- package/src/models/hirer-change-request-remove-hirer.entity.ts +47 -0
- package/src/models/hirer-change-request-signature.entity.ts +86 -0
- package/src/models/index.ts +8 -0
- package/src/models/joint-hirer.entity.ts +7 -0
- package/src/models/rental-hirer-change-request.entity.ts +93 -0
package/src/components/hirer-change-request-signature/hirer-change-request-signature.repository.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { RepositoryBase, IRepositoryBase } from '@tomei/general';
|
|
2
|
+
import { HirerChangeRequestSignatureModel } from '../../models/hirer-change-request-signature.entity';
|
|
3
|
+
|
|
4
|
+
export class HirerChangeRequestSignatureRepository
|
|
5
|
+
extends RepositoryBase<HirerChangeRequestSignatureModel>
|
|
6
|
+
implements IRepositoryBase<HirerChangeRequestSignatureModel>
|
|
7
|
+
{
|
|
8
|
+
constructor() {
|
|
9
|
+
super(HirerChangeRequestSignatureModel);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async findByPk(
|
|
13
|
+
id: string,
|
|
14
|
+
transaction?: any,
|
|
15
|
+
): Promise<HirerChangeRequestSignatureModel | null> {
|
|
16
|
+
try {
|
|
17
|
+
const result = await HirerChangeRequestSignatureModel.findByPk(id, {
|
|
18
|
+
transaction: transaction,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return result;
|
|
22
|
+
} catch (error) {
|
|
23
|
+
throw new Error(`An Error occured when fetching : ${error.message}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async delete(signatureId: string, dbTransaction?: any) {
|
|
28
|
+
try {
|
|
29
|
+
const options = {
|
|
30
|
+
where: {
|
|
31
|
+
SignatureId: signatureId,
|
|
32
|
+
},
|
|
33
|
+
transaction: dbTransaction,
|
|
34
|
+
};
|
|
35
|
+
await HirerChangeRequestSignatureModel.destroy(options);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
throw new Error(`An Error occured when delete : ${error.message}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async findAndCountAll(options?: any) {
|
|
42
|
+
try {
|
|
43
|
+
let hcrSignatures: any;
|
|
44
|
+
if (options) {
|
|
45
|
+
hcrSignatures =
|
|
46
|
+
await HirerChangeRequestSignatureModel.findAndCountAll(options);
|
|
47
|
+
} else {
|
|
48
|
+
hcrSignatures =
|
|
49
|
+
await HirerChangeRequestSignatureModel.findAndCountAll();
|
|
50
|
+
}
|
|
51
|
+
return hcrSignatures;
|
|
52
|
+
} catch (error) {
|
|
53
|
+
throw new Error(`An Error occured when retriving : ${error.message}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async findAll(options: any): Promise<HirerChangeRequestSignatureModel[]> {
|
|
58
|
+
try {
|
|
59
|
+
const result = await HirerChangeRequestSignatureModel.findAll(options);
|
|
60
|
+
return result;
|
|
61
|
+
} catch (error) {
|
|
62
|
+
throw new Error(`An Error occured when fetching : ${error.message}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { ClassError, ObjectBase } from '@tomei/general';
|
|
2
|
+
import { HirerChangeRequestSignatureRepository } from './hirer-change-request-signature.repository';
|
|
3
|
+
import { LoginUser } from '@tomei/sso';
|
|
4
|
+
import { ActionEnum, Activity } from '@tomei/activity-history';
|
|
5
|
+
import { HirerChangeRequestHirerRoleEnum } from '../../enum/rental-hirer-change-request-hirer-role';
|
|
6
|
+
import { IHirerChangeRequestSignatureAttr } from '../../interfaces';
|
|
7
|
+
|
|
8
|
+
export class HirerChangeRequestSignature
|
|
9
|
+
extends ObjectBase
|
|
10
|
+
implements IHirerChangeRequestSignatureAttr
|
|
11
|
+
{
|
|
12
|
+
ObjectId: string;
|
|
13
|
+
ObjectName: string;
|
|
14
|
+
ObjectType: string = 'HirerChangeRequestSignature';
|
|
15
|
+
TableName: string = 'hirerChangeRequest_Signature';
|
|
16
|
+
|
|
17
|
+
RequestId: string;
|
|
18
|
+
CustomerId: string;
|
|
19
|
+
JointHirerId: string;
|
|
20
|
+
HirerType: HirerChangeRequestHirerRoleEnum;
|
|
21
|
+
SignedAt: Date;
|
|
22
|
+
Method: string;
|
|
23
|
+
Remarks: string;
|
|
24
|
+
CreatedAt: Date;
|
|
25
|
+
UpdatedAt: Date;
|
|
26
|
+
UpdatedById: string;
|
|
27
|
+
|
|
28
|
+
protected static _Repository = new HirerChangeRequestSignatureRepository();
|
|
29
|
+
|
|
30
|
+
protected constructor(attr?: IHirerChangeRequestSignatureAttr) {
|
|
31
|
+
super();
|
|
32
|
+
if (attr) {
|
|
33
|
+
this.SignatureId = attr.SignatureId;
|
|
34
|
+
this.RequestId = attr.RequestId;
|
|
35
|
+
this.CustomerId = attr.CustomerId;
|
|
36
|
+
this.JointHirerId = attr.JointHirerId;
|
|
37
|
+
this.SignedAt = attr.SignedAt;
|
|
38
|
+
this.Method = attr.Method;
|
|
39
|
+
this.Remarks = attr.Remarks;
|
|
40
|
+
this.CreatedAt = attr.CreatedAt;
|
|
41
|
+
this.UpdatedAt = attr.UpdatedAt;
|
|
42
|
+
this.UpdatedById = attr.UpdatedById;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
get SignatureId(): string {
|
|
47
|
+
return this.ObjectId;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
set SignatureId(value: string) {
|
|
51
|
+
this.ObjectId = value;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public static async init(signatureId?: string, dbTransaction?: any) {
|
|
55
|
+
try {
|
|
56
|
+
if (signatureId) {
|
|
57
|
+
const hirerChangeReqSignature =
|
|
58
|
+
await HirerChangeRequestSignature._Repository.findByPk(
|
|
59
|
+
signatureId,
|
|
60
|
+
dbTransaction,
|
|
61
|
+
);
|
|
62
|
+
if (hirerChangeReqSignature) {
|
|
63
|
+
return new HirerChangeRequestSignature(
|
|
64
|
+
hirerChangeReqSignature.get({ plain: true }),
|
|
65
|
+
);
|
|
66
|
+
} else {
|
|
67
|
+
throw new ClassError(
|
|
68
|
+
'HirerChangeRequestSignature',
|
|
69
|
+
'HirerChangeRequestSignatureErrMsg00',
|
|
70
|
+
'HirerChangeRequestSignature not found',
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return new HirerChangeRequestSignature();
|
|
75
|
+
} catch (error) {
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
toJSON(): IHirerChangeRequestSignatureAttr {
|
|
81
|
+
return {
|
|
82
|
+
SignatureId: this.SignatureId,
|
|
83
|
+
RequestId: this.RequestId,
|
|
84
|
+
CustomerId: this.CustomerId,
|
|
85
|
+
JointHirerId: this.JointHirerId,
|
|
86
|
+
HirerType: this.HirerType,
|
|
87
|
+
SignedAt: this.SignedAt,
|
|
88
|
+
Method: this.Method,
|
|
89
|
+
Remarks: this.Remarks,
|
|
90
|
+
CreatedAt: this.CreatedAt,
|
|
91
|
+
UpdatedAt: this.UpdatedAt,
|
|
92
|
+
UpdatedById: this.UpdatedById,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public async create(loginUser: LoginUser, dbTransaction?: any) {
|
|
97
|
+
//This method will create a new Hirer Change Request Signature.
|
|
98
|
+
try {
|
|
99
|
+
// Part 1: Create Hirer Change Request Signature Records
|
|
100
|
+
// 1.1 Set other attributes
|
|
101
|
+
this.ObjectId = this.createId();
|
|
102
|
+
this.CreatedAt = new Date();
|
|
103
|
+
this.UpdatedById = loginUser.ObjectId;
|
|
104
|
+
this.UpdatedAt = new Date();
|
|
105
|
+
|
|
106
|
+
// 1.2 Set Entity value after
|
|
107
|
+
const entityValueAfter: IHirerChangeRequestSignatureAttr = {
|
|
108
|
+
SignatureId: this.SignatureId,
|
|
109
|
+
RequestId: this.RequestId,
|
|
110
|
+
CustomerId: this.CustomerId,
|
|
111
|
+
JointHirerId: this.JointHirerId,
|
|
112
|
+
HirerType: this.HirerType,
|
|
113
|
+
SignedAt: this.SignedAt,
|
|
114
|
+
Method: this.Method,
|
|
115
|
+
Remarks: this.Remarks,
|
|
116
|
+
CreatedAt: this.CreatedAt,
|
|
117
|
+
UpdatedAt: this.UpdatedAt,
|
|
118
|
+
UpdatedById: this.UpdatedById,
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// 1.3 Call repo class create method by passing the class attributes and db transaction.
|
|
122
|
+
await HirerChangeRequestSignature._Repository.create(entityValueAfter, {
|
|
123
|
+
transaction: dbTransaction,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
//Part 2: Record Create Hirer Change Request Signature Activity
|
|
127
|
+
const activity = new Activity();
|
|
128
|
+
activity.ObjectId = this._createId();
|
|
129
|
+
activity.Action = ActionEnum.CREATE;
|
|
130
|
+
activity.Description = 'Add Hirer Change Request Signature';
|
|
131
|
+
activity.EntityId = this.ObjectId;
|
|
132
|
+
activity.EntityType = this.ObjectType;
|
|
133
|
+
activity.EntityValueBefore = JSON.stringify({});
|
|
134
|
+
activity.EntityValueAfter = JSON.stringify(entityValueAfter);
|
|
135
|
+
|
|
136
|
+
await activity.create(loginUser.ObjectId, dbTransaction);
|
|
137
|
+
|
|
138
|
+
return this;
|
|
139
|
+
} catch (error) {
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
public async update(loginUser: LoginUser, dbTransaction: any) {
|
|
145
|
+
try {
|
|
146
|
+
// Part 1: Update Hirer Change Request Signature Records
|
|
147
|
+
// 1.1 Set entityValueBefore
|
|
148
|
+
const entityValueBefore: IHirerChangeRequestSignatureAttr = {
|
|
149
|
+
SignatureId: this.SignatureId,
|
|
150
|
+
RequestId: this.RequestId,
|
|
151
|
+
CustomerId: this.CustomerId,
|
|
152
|
+
JointHirerId: this.JointHirerId,
|
|
153
|
+
HirerType: this.HirerType,
|
|
154
|
+
SignedAt: this.SignedAt,
|
|
155
|
+
Method: this.Method,
|
|
156
|
+
Remarks: this.Remarks,
|
|
157
|
+
CreatedAt: this.CreatedAt,
|
|
158
|
+
UpdatedAt: this.UpdatedAt,
|
|
159
|
+
UpdatedById: this.UpdatedById,
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
// 1.2 Update SignedAt UpdatedById, and UpdateAt
|
|
163
|
+
this.SignedAt = new Date();
|
|
164
|
+
this.UpdatedById = loginUser.ObjectId;
|
|
165
|
+
this.UpdatedAt = new Date();
|
|
166
|
+
|
|
167
|
+
// 1.3 Set Entity value after
|
|
168
|
+
const entityValueAfter: IHirerChangeRequestSignatureAttr = {
|
|
169
|
+
SignatureId: this.SignatureId,
|
|
170
|
+
RequestId: this.RequestId,
|
|
171
|
+
CustomerId: this.CustomerId,
|
|
172
|
+
JointHirerId: this.JointHirerId,
|
|
173
|
+
HirerType: this.HirerType,
|
|
174
|
+
SignedAt: this.SignedAt,
|
|
175
|
+
Method: this.Method,
|
|
176
|
+
Remarks: this.Remarks,
|
|
177
|
+
CreatedAt: this.CreatedAt,
|
|
178
|
+
UpdatedAt: this.UpdatedAt,
|
|
179
|
+
UpdatedById: this.UpdatedById,
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
// 1.3 Call repo class create method by passing the class attributes and db transaction.
|
|
183
|
+
await HirerChangeRequestSignature._Repository.update(entityValueAfter, {
|
|
184
|
+
where: {
|
|
185
|
+
SignatureId: this.SignatureId,
|
|
186
|
+
},
|
|
187
|
+
transaction: dbTransaction,
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
//Part 2: Record Create Hirer Change Request Activity
|
|
191
|
+
const activity = new Activity();
|
|
192
|
+
activity.ObjectId = this._createId();
|
|
193
|
+
activity.Action = ActionEnum.UPDATE;
|
|
194
|
+
activity.Description = 'Update Hirer Change Request Signature';
|
|
195
|
+
activity.EntityId = this.ObjectId;
|
|
196
|
+
activity.EntityType = this.ObjectType;
|
|
197
|
+
activity.EntityValueBefore = JSON.stringify(entityValueBefore);
|
|
198
|
+
activity.EntityValueAfter = JSON.stringify(entityValueAfter);
|
|
199
|
+
|
|
200
|
+
await activity.create(loginUser.ObjectId, dbTransaction);
|
|
201
|
+
|
|
202
|
+
return this;
|
|
203
|
+
} catch (error) {
|
|
204
|
+
throw error;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
public async markSigned(loginUser: LoginUser, dbTransaction: any) {
|
|
209
|
+
try {
|
|
210
|
+
// Part 1: Update Hirer Change Request Signature Records
|
|
211
|
+
// 1.1 Set entityValueBefore
|
|
212
|
+
const entityValueBefore: IHirerChangeRequestSignatureAttr = {
|
|
213
|
+
SignatureId: this.SignatureId,
|
|
214
|
+
RequestId: this.RequestId,
|
|
215
|
+
CustomerId: this.CustomerId,
|
|
216
|
+
JointHirerId: this.JointHirerId,
|
|
217
|
+
HirerType: this.HirerType,
|
|
218
|
+
SignedAt: this.SignedAt,
|
|
219
|
+
Method: this.Method,
|
|
220
|
+
Remarks: this.Remarks,
|
|
221
|
+
CreatedAt: this.CreatedAt,
|
|
222
|
+
UpdatedAt: this.UpdatedAt,
|
|
223
|
+
UpdatedById: this.UpdatedById,
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
// 1.2 Update SignedAt UpdatedById, and UpdateAt
|
|
227
|
+
this.SignedAt = new Date();
|
|
228
|
+
this.UpdatedById = loginUser.ObjectId;
|
|
229
|
+
this.UpdatedAt = new Date();
|
|
230
|
+
|
|
231
|
+
// 1.3 Set Entity value after
|
|
232
|
+
const entityValueAfter: IHirerChangeRequestSignatureAttr = {
|
|
233
|
+
SignatureId: this.SignatureId,
|
|
234
|
+
RequestId: this.RequestId,
|
|
235
|
+
CustomerId: this.CustomerId,
|
|
236
|
+
JointHirerId: this.JointHirerId,
|
|
237
|
+
HirerType: this.HirerType,
|
|
238
|
+
SignedAt: this.SignedAt,
|
|
239
|
+
Method: this.Method,
|
|
240
|
+
Remarks: this.Remarks,
|
|
241
|
+
CreatedAt: this.CreatedAt,
|
|
242
|
+
UpdatedAt: this.UpdatedAt,
|
|
243
|
+
UpdatedById: this.UpdatedById,
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
// 1.3 Call repo class create method by passing the class attributes and db transaction.
|
|
247
|
+
await HirerChangeRequestSignature._Repository.update(entityValueAfter, {
|
|
248
|
+
where: {
|
|
249
|
+
SignatureId: this.SignatureId,
|
|
250
|
+
},
|
|
251
|
+
transaction: dbTransaction,
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
//Part 2: Record Create Hirer Change Request Activity
|
|
255
|
+
const activity = new Activity();
|
|
256
|
+
activity.ObjectId = this._createId();
|
|
257
|
+
activity.Action = ActionEnum.UPDATE;
|
|
258
|
+
activity.Description = 'Mark Hirer Change Request Signature as Signed';
|
|
259
|
+
activity.EntityId = this.ObjectId;
|
|
260
|
+
activity.EntityType = this.ObjectType;
|
|
261
|
+
activity.EntityValueBefore = JSON.stringify(entityValueBefore);
|
|
262
|
+
activity.EntityValueAfter = JSON.stringify(entityValueAfter);
|
|
263
|
+
|
|
264
|
+
await activity.create(loginUser.ObjectId, dbTransaction);
|
|
265
|
+
|
|
266
|
+
return this;
|
|
267
|
+
} catch (error) {
|
|
268
|
+
throw error;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
@@ -13,6 +13,7 @@ export class JointHirer extends ObjectBase {
|
|
|
13
13
|
RentalId: string;
|
|
14
14
|
CustomerId: string;
|
|
15
15
|
CustomerType: string;
|
|
16
|
+
Status = 'Active'; // Default status
|
|
16
17
|
CreatedById: string;
|
|
17
18
|
CreatedAt: Date;
|
|
18
19
|
UpdatedById: string;
|
|
@@ -35,6 +36,7 @@ export class JointHirer extends ObjectBase {
|
|
|
35
36
|
this.RentalId = jointHirerAttr.RentalId;
|
|
36
37
|
this.CustomerId = jointHirerAttr.CustomerId;
|
|
37
38
|
this.CustomerType = jointHirerAttr.CustomerType;
|
|
39
|
+
this.Status = jointHirerAttr.Status;
|
|
38
40
|
this.CreatedById = jointHirerAttr.CreatedById;
|
|
39
41
|
this.CreatedAt = jointHirerAttr.CreatedAt;
|
|
40
42
|
this.UpdatedById = jointHirerAttr.UpdatedById;
|
|
@@ -42,6 +44,20 @@ export class JointHirer extends ObjectBase {
|
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
|
|
47
|
+
toJSON(): IJointHirerAttr {
|
|
48
|
+
return {
|
|
49
|
+
HirerId: this.HirerId,
|
|
50
|
+
RentalId: this.RentalId,
|
|
51
|
+
CustomerId: this.CustomerId,
|
|
52
|
+
CustomerType: this.CustomerType,
|
|
53
|
+
Status: this.Status,
|
|
54
|
+
CreatedById: this.CreatedById,
|
|
55
|
+
CreatedAt: this.CreatedAt,
|
|
56
|
+
UpdatedById: this.UpdatedById,
|
|
57
|
+
UpdatedAt: this.UpdatedAt,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
45
61
|
public static async init(hirerId?: string, dbTransaction?: any) {
|
|
46
62
|
try {
|
|
47
63
|
if (hirerId) {
|
|
@@ -106,6 +122,7 @@ export class JointHirer extends ObjectBase {
|
|
|
106
122
|
RentalId: this.RentalId,
|
|
107
123
|
CustomerId: this.CustomerId,
|
|
108
124
|
CustomerType: this.CustomerType,
|
|
125
|
+
Status: this.Status,
|
|
109
126
|
CreatedById: this.CreatedById,
|
|
110
127
|
CreatedAt: this.CreatedAt,
|
|
111
128
|
UpdatedById: this.UpdatedById,
|
|
@@ -134,4 +151,39 @@ export class JointHirer extends ObjectBase {
|
|
|
134
151
|
throw error;
|
|
135
152
|
}
|
|
136
153
|
}
|
|
154
|
+
|
|
155
|
+
public async remove(loginUser: LoginUser, dbTransaction?: any) {
|
|
156
|
+
try {
|
|
157
|
+
//Mark Joint Hirer as Inactive
|
|
158
|
+
const entityValueBefore: IJointHirerAttr = this.toJSON();
|
|
159
|
+
this.Status = 'Inactive'; // Set status to 'Inactive' instead of deleting the record
|
|
160
|
+
this.UpdatedById = loginUser.ObjectId;
|
|
161
|
+
this.UpdatedAt = new Date();
|
|
162
|
+
const entityValueAfter: IJointHirerAttr = this.toJSON();
|
|
163
|
+
|
|
164
|
+
// Part 2: Remove Joint Hirer Record
|
|
165
|
+
await JointHirer._Repository.update(entityValueAfter, {
|
|
166
|
+
where: {
|
|
167
|
+
HirerId: this.HirerId,
|
|
168
|
+
},
|
|
169
|
+
transaction: dbTransaction,
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// Part 3: Record Remove JointHirer Activity
|
|
173
|
+
const activity = new Activity();
|
|
174
|
+
activity.ObjectId = this._createId();
|
|
175
|
+
activity.Action = ActionEnum.UPDATE;
|
|
176
|
+
activity.Description = 'Mark Joint Hirer as Inactive';
|
|
177
|
+
activity.EntityId = this.ObjectId;
|
|
178
|
+
activity.EntityType = this.ObjectType;
|
|
179
|
+
activity.EntityValueBefore = JSON.stringify(entityValueBefore);
|
|
180
|
+
activity.EntityValueAfter = JSON.stringify(entityValueAfter);
|
|
181
|
+
|
|
182
|
+
await activity.create(loginUser.ObjectId, dbTransaction);
|
|
183
|
+
|
|
184
|
+
return this;
|
|
185
|
+
} catch (error) {
|
|
186
|
+
throw error;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
137
189
|
}
|
|
@@ -728,6 +728,38 @@ export class Rental extends ObjectBase {
|
|
|
728
728
|
}
|
|
729
729
|
}
|
|
730
730
|
|
|
731
|
+
async getJointHirers(dbTransaction: any) {
|
|
732
|
+
try {
|
|
733
|
+
if (!this.RentalId) {
|
|
734
|
+
throw new ClassError('Rental', 'RentalErrMsg01', 'RentalId is missing');
|
|
735
|
+
}
|
|
736
|
+
if (this.AccountType !== RentalAccountTypeEnum.JOINT) {
|
|
737
|
+
throw new ClassError(
|
|
738
|
+
'Rental',
|
|
739
|
+
'RentalErrMsg07',
|
|
740
|
+
'This rental does not have joint hirers.',
|
|
741
|
+
);
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
const jointHirers = await Rental._JointHirerRepo.findAll({
|
|
745
|
+
where: {
|
|
746
|
+
RentalId: this.RentalId,
|
|
747
|
+
},
|
|
748
|
+
transaction: dbTransaction,
|
|
749
|
+
});
|
|
750
|
+
// Map the jointHirers to JointHirer instances
|
|
751
|
+
const jointHirerInstances = Promise.all(
|
|
752
|
+
jointHirers.map(async (hirer: JointHirerModel) => {
|
|
753
|
+
return await JointHirer.init(hirer.HirerId, dbTransaction);
|
|
754
|
+
}),
|
|
755
|
+
);
|
|
756
|
+
return jointHirerInstances;
|
|
757
|
+
} catch (error) {
|
|
758
|
+
console.error('Error in getJointHirers:', error);
|
|
759
|
+
throw error;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
|
|
731
763
|
async getCustomerIds(loginUser: LoginUser, dbTransaction: any) {
|
|
732
764
|
try {
|
|
733
765
|
// Part 1: Privilege Checking
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { RepositoryBase, IRepositoryBase } from '@tomei/general';
|
|
2
|
+
import { RentalHirerChangeRequestModel } from '../../models/rental-hirer-change-request.entity';
|
|
3
|
+
|
|
4
|
+
export class RentalHirerChangeRequestRepository
|
|
5
|
+
extends RepositoryBase<RentalHirerChangeRequestModel>
|
|
6
|
+
implements IRepositoryBase<RentalHirerChangeRequestModel>
|
|
7
|
+
{
|
|
8
|
+
constructor() {
|
|
9
|
+
super(RentalHirerChangeRequestModel);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async findByPk(
|
|
13
|
+
id: string,
|
|
14
|
+
transaction?: any,
|
|
15
|
+
): Promise<RentalHirerChangeRequestModel | null> {
|
|
16
|
+
try {
|
|
17
|
+
const result = await RentalHirerChangeRequestModel.findByPk(id, {
|
|
18
|
+
transaction: transaction,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return result;
|
|
22
|
+
} catch (error) {
|
|
23
|
+
throw new Error(`An Error occured when fetching : ${error.message}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async delete(requestId: string, dbTransaction?: any) {
|
|
28
|
+
try {
|
|
29
|
+
const options = {
|
|
30
|
+
where: {
|
|
31
|
+
RequestId: requestId,
|
|
32
|
+
},
|
|
33
|
+
transaction: dbTransaction,
|
|
34
|
+
};
|
|
35
|
+
await RentalHirerChangeRequestModel.destroy(options);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
throw new Error(`An Error occured when delete : ${error.message}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async findAndCountAll(options?: any) {
|
|
42
|
+
try {
|
|
43
|
+
let jointHirers: any;
|
|
44
|
+
if (options) {
|
|
45
|
+
jointHirers =
|
|
46
|
+
await RentalHirerChangeRequestModel.findAndCountAll(options);
|
|
47
|
+
} else {
|
|
48
|
+
jointHirers = await RentalHirerChangeRequestModel.findAndCountAll();
|
|
49
|
+
}
|
|
50
|
+
return jointHirers;
|
|
51
|
+
} catch (error) {
|
|
52
|
+
throw new Error(`An Error occured when retriving : ${error.message}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async findAll(options: any): Promise<RentalHirerChangeRequestModel[]> {
|
|
57
|
+
try {
|
|
58
|
+
const result = await RentalHirerChangeRequestModel.findAll(options);
|
|
59
|
+
return result;
|
|
60
|
+
} catch (error) {
|
|
61
|
+
throw new Error(`An Error occured when fetching : ${error.message}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|