@tomei/rental 0.12.3 → 0.13.0
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/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/src/components/agreement/agreement.d.ts +22 -0
- package/dist/src/components/agreement/agreement.js +89 -0
- package/dist/src/components/agreement/agreement.js.map +1 -0
- package/dist/src/components/agreement/agreement.repository.d.ts +8 -0
- package/dist/src/components/agreement/agreement.repository.js +67 -0
- package/dist/src/components/agreement/agreement.repository.js.map +1 -0
- package/dist/src/components/booking/booking.d.ts +46 -0
- package/dist/src/components/booking/booking.js +314 -0
- package/dist/src/components/booking/booking.js.map +1 -0
- package/dist/src/components/booking/booking.repository.d.ts +8 -0
- package/dist/src/components/booking/booking.repository.js +67 -0
- package/dist/src/components/booking/booking.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 +23 -0
- package/dist/src/components/joint-hirer/joint-hirer.js +106 -0
- package/dist/src/components/joint-hirer/joint-hirer.js.map +1 -0
- package/dist/src/components/joint-hirer/joint-hirer.repository.d.ts +8 -0
- package/dist/src/components/joint-hirer/joint-hirer.repository.js +67 -0
- package/dist/src/components/joint-hirer/joint-hirer.repository.js.map +1 -0
- package/dist/src/components/rental/rental.d.ts +61 -0
- package/dist/src/components/rental/rental.js +687 -0
- package/dist/src/components/rental/rental.js.map +1 -0
- package/dist/src/components/rental/rental.repository.d.ts +8 -0
- package/dist/src/components/rental/rental.repository.js +67 -0
- package/dist/src/components/rental/rental.repository.js.map +1 -0
- package/dist/src/components/rental-price/rental-price.d.ts +18 -0
- package/dist/src/components/rental-price/rental-price.js +79 -0
- package/dist/src/components/rental-price/rental-price.js.map +1 -0
- package/dist/src/components/rental-price/rental-price.repository.d.ts +8 -0
- package/dist/src/components/rental-price/rental-price.repository.js +67 -0
- package/dist/src/components/rental-price/rental-price.repository.js.map +1 -0
- package/dist/src/database.d.ts +4 -0
- package/dist/src/database.js +27 -0
- package/dist/src/database.js.map +1 -0
- package/dist/src/enum/account-type.enum.d.ts +4 -0
- package/dist/src/enum/account-type.enum.js +9 -0
- package/dist/src/enum/account-type.enum.js.map +1 -0
- package/dist/src/enum/aggrement-status.enum.d.ts +5 -0
- package/dist/src/enum/aggrement-status.enum.js +10 -0
- package/dist/src/enum/aggrement-status.enum.js.map +1 -0
- package/dist/src/enum/booking.enum.d.ts +5 -0
- package/dist/src/enum/booking.enum.js +10 -0
- package/dist/src/enum/booking.enum.js.map +1 -0
- 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/hirer-type.enum.d.ts +4 -0
- package/dist/src/enum/hirer-type.enum.js +9 -0
- package/dist/src/enum/hirer-type.enum.js.map +1 -0
- package/dist/src/enum/index.d.ts +7 -0
- package/dist/src/enum/index.js +16 -0
- package/dist/src/enum/index.js.map +1 -0
- package/dist/src/enum/rental-status.enum.d.ts +9 -0
- package/dist/src/enum/rental-status.enum.js +14 -0
- package/dist/src/enum/rental-status.enum.js.map +1 -0
- package/dist/src/index.d.ts +17 -0
- package/dist/src/index.js +47 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/interfaces/agreement-attr.interface.d.ts +7 -0
- package/dist/src/interfaces/agreement-attr.interface.js +3 -0
- package/dist/src/interfaces/agreement-attr.interface.js.map +1 -0
- package/dist/src/interfaces/booking-attr.interface.d.ts +18 -0
- package/dist/src/interfaces/booking-attr.interface.js +3 -0
- package/dist/src/interfaces/booking-attr.interface.js.map +1 -0
- package/dist/src/interfaces/booking-find-all-search-attr.interface.d.ts +12 -0
- package/dist/src/interfaces/booking-find-all-search-attr.interface.js +3 -0
- package/dist/src/interfaces/booking-find-all-search-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 +9 -0
- package/dist/src/interfaces/index.js +3 -0
- package/dist/src/interfaces/index.js.map +1 -0
- package/dist/src/interfaces/joint-hirer-attr.interface.d.ts +10 -0
- package/dist/src/interfaces/joint-hirer-attr.interface.js +3 -0
- package/dist/src/interfaces/joint-hirer-attr.interface.js.map +1 -0
- package/dist/src/interfaces/rental-attr.interface.d.ts +24 -0
- package/dist/src/interfaces/rental-attr.interface.js +3 -0
- package/dist/src/interfaces/rental-attr.interface.js.map +1 -0
- package/dist/src/interfaces/rental-find-all-search-attr.interface.d.ts +10 -0
- package/dist/src/interfaces/rental-find-all-search-attr.interface.js +3 -0
- package/dist/src/interfaces/rental-find-all-search-attr.interface.js.map +1 -0
- package/dist/src/interfaces/rental-price-attr.interface.d.ts +7 -0
- package/dist/src/interfaces/rental-price-attr.interface.js +3 -0
- package/dist/src/interfaces/rental-price-attr.interface.js.map +1 -0
- package/dist/src/interfaces/response-hirer-signature-attr.interface.d.ts +15 -0
- package/dist/src/interfaces/response-hirer-signature-attr.interface.js +3 -0
- package/dist/src/interfaces/response-hirer-signature-attr.interface.js.map +1 -0
- package/dist/src/models/agreement.entity.d.ts +12 -0
- package/dist/src/models/agreement.entity.js +65 -0
- package/dist/src/models/agreement.entity.js.map +1 -0
- package/dist/src/models/booking.entity.d.ts +21 -0
- package/dist/src/models/booking.entity.js +128 -0
- package/dist/src/models/booking.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 +7 -0
- package/dist/src/models/index.js +16 -0
- package/dist/src/models/index.js.map +1 -0
- package/dist/src/models/joint-hirer.entity.d.ts +13 -0
- package/dist/src/models/joint-hirer.entity.js +79 -0
- package/dist/src/models/joint-hirer.entity.js.map +1 -0
- package/dist/src/models/rental-price.entity.d.ts +8 -0
- package/dist/src/models/rental-price.entity.js +59 -0
- package/dist/src/models/rental-price.entity.js.map +1 -0
- package/dist/src/models/rental.entity.d.ts +29 -0
- package/dist/src/models/rental.entity.js +160 -0
- package/dist/src/models/rental.entity.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/eslint.config.mjs +22 -1
- package/migrations/booking-table-migration.js +1 -1
- package/migrations/hirer-signature-table-migration.js +64 -0
- package/migrations/joint-hirer-table-migration.js +1 -1
- package/migrations/rental-aggrement-table-migration.js +1 -1
- package/migrations/rental-price-table-migration.js +1 -1
- package/migrations/rental-table-migrations.js +1 -1
- package/package.json +7 -10
- package/src/components/agreement/agreement.ts +70 -2
- package/src/components/hirer-signature/hirer-signature.repository.ts +54 -0
- package/src/components/hirer-signature/hirer-signature.ts +140 -0
- package/src/components/rental/rental.ts +111 -1
- package/src/database.ts +2 -0
- package/src/enum/hirer-signature-status.enum.ts +4 -0
- package/src/enum/hirer-type.enum.ts +4 -0
- package/src/enum/index.ts +4 -0
- package/src/index.ts +4 -0
- package/src/interfaces/hirer-signature-attr.interface.ts +15 -0
- package/src/interfaces/index.ts +4 -0
- package/src/interfaces/response-hirer-signature-attr.interface.ts +16 -0
- package/src/models/agreement.entity.ts +4 -0
- package/src/models/hirer-signature.entity.ts +81 -0
- package/src/models/index.ts +2 -0
- package/tsconfig.json +1 -0
- package/.eslintrc +0 -16
- package/.eslintrc.js +0 -35
- package/tomei-rental-0.9.4.tgz +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { RepositoryBase, IRepositoryBase } from '@tomei/general';
|
|
2
|
+
import { HirerSignatureModel } from '../../models/hirer-signature.entity';
|
|
3
|
+
|
|
4
|
+
export class HirerSignatureRepository
|
|
5
|
+
extends RepositoryBase<HirerSignatureModel>
|
|
6
|
+
implements IRepositoryBase<HirerSignatureModel>
|
|
7
|
+
{
|
|
8
|
+
constructor() {
|
|
9
|
+
super(HirerSignatureModel);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async findByPk(
|
|
13
|
+
id: string,
|
|
14
|
+
transaction?: any,
|
|
15
|
+
): Promise<HirerSignatureModel | null> {
|
|
16
|
+
try {
|
|
17
|
+
const result = await HirerSignatureModel.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(hirerId: string, dbTransaction?: any) {
|
|
28
|
+
try {
|
|
29
|
+
const options = {
|
|
30
|
+
where: {
|
|
31
|
+
HirerId: hirerId,
|
|
32
|
+
},
|
|
33
|
+
transaction: dbTransaction,
|
|
34
|
+
};
|
|
35
|
+
await HirerSignatureModel.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 = await HirerSignatureModel.findAndCountAll(options);
|
|
46
|
+
} else {
|
|
47
|
+
jointHirers = await HirerSignatureModel.findAndCountAll();
|
|
48
|
+
}
|
|
49
|
+
return jointHirers;
|
|
50
|
+
} catch (error) {
|
|
51
|
+
throw new Error(`An Error occured when retriving : ${error.message}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { ClassError, ObjectBase } from '@tomei/general';
|
|
2
|
+
import { HirerSignatureRepository } from './hirer-signature.repository';
|
|
3
|
+
import { IHirerSignatureAttr } from '../../interfaces/hirer-signature-attr.interface';
|
|
4
|
+
import { ApplicationConfig } from '@tomei/config';
|
|
5
|
+
import { LoginUser } from '@tomei/sso';
|
|
6
|
+
import { ActionEnum, Activity } from '@tomei/activity-history';
|
|
7
|
+
import { HirerSignatureStatusEnum } from '../../enum/hirer-signature-status.enum';
|
|
8
|
+
|
|
9
|
+
export class HirerSignature extends ObjectBase {
|
|
10
|
+
ObjectId: string;
|
|
11
|
+
ObjectName: string;
|
|
12
|
+
ObjectType: string = 'HirerSignature';
|
|
13
|
+
TableName: string = 'rental_HirerSignature';
|
|
14
|
+
AgreementNo: string;
|
|
15
|
+
HirerType: string;
|
|
16
|
+
CustomerId: string;
|
|
17
|
+
CustomerType: string;
|
|
18
|
+
SignatureStatus: HirerSignatureStatusEnum;
|
|
19
|
+
SignedAt: Date;
|
|
20
|
+
CreatedById: string;
|
|
21
|
+
CreatedAt: Date;
|
|
22
|
+
UpdatedById: string;
|
|
23
|
+
UpdatedAt: Date;
|
|
24
|
+
|
|
25
|
+
get HirerSignatureId(): string {
|
|
26
|
+
return this.ObjectId;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
set HirerSignatureId(value: string) {
|
|
30
|
+
this.ObjectId = value;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
protected static _Repository = new HirerSignatureRepository();
|
|
34
|
+
|
|
35
|
+
protected constructor(hirerSignatureAttr?: IHirerSignatureAttr) {
|
|
36
|
+
super();
|
|
37
|
+
if (hirerSignatureAttr) {
|
|
38
|
+
this.HirerSignatureId = hirerSignatureAttr.HirerSignatureId;
|
|
39
|
+
this.AgreementNo = hirerSignatureAttr.AgreementNo;
|
|
40
|
+
this.HirerType = hirerSignatureAttr.HirerType;
|
|
41
|
+
this.CustomerId = hirerSignatureAttr.CustomerId;
|
|
42
|
+
this.CustomerType = hirerSignatureAttr.CustomerType;
|
|
43
|
+
this.SignatureStatus = hirerSignatureAttr.SignatureStatus;
|
|
44
|
+
this.SignedAt = hirerSignatureAttr.SignedAt;
|
|
45
|
+
this.CreatedById = hirerSignatureAttr.CreatedById;
|
|
46
|
+
this.CreatedAt = hirerSignatureAttr.CreatedAt;
|
|
47
|
+
this.UpdatedById = hirerSignatureAttr.UpdatedById;
|
|
48
|
+
this.UpdatedAt = hirerSignatureAttr.UpdatedAt;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public static async init(HirerSignatureId?: string, dbTransaction?: any) {
|
|
53
|
+
try {
|
|
54
|
+
if (HirerSignatureId) {
|
|
55
|
+
const hs = await HirerSignature._Repository.findByPk(
|
|
56
|
+
HirerSignatureId,
|
|
57
|
+
dbTransaction,
|
|
58
|
+
);
|
|
59
|
+
if (hs) {
|
|
60
|
+
return new HirerSignature(hs.get({ plain: true }));
|
|
61
|
+
} else {
|
|
62
|
+
throw new ClassError(
|
|
63
|
+
'HirerSignature',
|
|
64
|
+
'HirerSignatureErrMsg01',
|
|
65
|
+
'HirerSignature not found',
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return new HirerSignature();
|
|
70
|
+
} catch (error) {
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public async create(loginUser: LoginUser, dbTransaction?: any) {
|
|
76
|
+
try {
|
|
77
|
+
const systemCode =
|
|
78
|
+
ApplicationConfig.getComponentConfigValue('system-code');
|
|
79
|
+
const isPrivileged = await loginUser.checkPrivileges(
|
|
80
|
+
systemCode,
|
|
81
|
+
'HirerSignature - Create',
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
if (!isPrivileged) {
|
|
85
|
+
throw new ClassError(
|
|
86
|
+
'HirerSignature',
|
|
87
|
+
'HirerSignatureErrMsg00',
|
|
88
|
+
"You do not have 'HirerSignature - Create' privilege.",
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (!this.AgreementNo || !this.CustomerId || !this.CustomerType) {
|
|
93
|
+
throw new ClassError(
|
|
94
|
+
'HirerSignature',
|
|
95
|
+
'HirerSignatureErrMsg03',
|
|
96
|
+
'AgreementNo, CustomerId and CustomerType are required.',
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
this.ObjectId = this.createId();
|
|
101
|
+
this.CreatedById = loginUser.ObjectId;
|
|
102
|
+
this.CreatedAt = new Date();
|
|
103
|
+
this.UpdatedById = loginUser.ObjectId;
|
|
104
|
+
this.UpdatedAt = new Date();
|
|
105
|
+
|
|
106
|
+
const entityValueAfter: IHirerSignatureAttr = {
|
|
107
|
+
HirerSignatureId: this.HirerSignatureId,
|
|
108
|
+
AgreementNo: this.AgreementNo,
|
|
109
|
+
HirerType: this.HirerType,
|
|
110
|
+
CustomerId: this.CustomerId,
|
|
111
|
+
CustomerType: this.CustomerType,
|
|
112
|
+
SignatureStatus: this.SignatureStatus,
|
|
113
|
+
SignedAt: this.SignedAt,
|
|
114
|
+
CreatedById: this.CreatedById,
|
|
115
|
+
CreatedAt: this.CreatedAt,
|
|
116
|
+
UpdatedById: this.UpdatedById,
|
|
117
|
+
UpdatedAt: this.UpdatedAt,
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
await HirerSignature._Repository.create(entityValueAfter, {
|
|
121
|
+
transaction: dbTransaction,
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const activity = new Activity();
|
|
125
|
+
activity.ObjectId = this.createId();
|
|
126
|
+
activity.Action = ActionEnum.CREATE;
|
|
127
|
+
activity.Description = 'Add Joint Hirer Signature';
|
|
128
|
+
activity.EntityId = this.ObjectId;
|
|
129
|
+
activity.EntityType = this.ObjectType;
|
|
130
|
+
activity.EntityValueBefore = JSON.stringify({});
|
|
131
|
+
activity.EntityValueAfter = JSON.stringify(entityValueAfter);
|
|
132
|
+
|
|
133
|
+
await activity.create(loginUser.ObjectId, dbTransaction);
|
|
134
|
+
|
|
135
|
+
return this;
|
|
136
|
+
} catch (error) {
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -18,6 +18,9 @@ import { JointHirerRepository } from '../joint-hirer/joint-hirer.repository';
|
|
|
18
18
|
import { AgreementModel } from '../../models';
|
|
19
19
|
import { Agreement } from '../agreement/agreement';
|
|
20
20
|
import { AggrementStatusEnum } from '../../enum/aggrement-status.enum';
|
|
21
|
+
import { HirerSignatureRepository } from '../hirer-signature/hirer-signature.repository';
|
|
22
|
+
import { HirerSignatureStatusEnum } from '../../enum/hirer-signature-status.enum';
|
|
23
|
+
import { HirerTypeEnum } from '../../enum/hirer-type.enum';
|
|
21
24
|
|
|
22
25
|
export class Rental extends ObjectBase {
|
|
23
26
|
ObjectId: string;
|
|
@@ -45,6 +48,7 @@ export class Rental extends ObjectBase {
|
|
|
45
48
|
protected static _Repo = new RentalRepository();
|
|
46
49
|
protected static _AgreementRepo = new AgreementRepository();
|
|
47
50
|
protected static _JointHirerRepo = new JointHirerRepository();
|
|
51
|
+
protected static _HirerSignatureRepo = new HirerSignatureRepository();
|
|
48
52
|
|
|
49
53
|
get RentalId(): string {
|
|
50
54
|
return this.ObjectId;
|
|
@@ -191,6 +195,47 @@ export class Rental extends ObjectBase {
|
|
|
191
195
|
},
|
|
192
196
|
);
|
|
193
197
|
|
|
198
|
+
//Create a record into rental_HirerSignature table
|
|
199
|
+
//Create the main customer's signature record
|
|
200
|
+
await Rental._HirerSignatureRepo.create(
|
|
201
|
+
{
|
|
202
|
+
HirerSignatureId: this.createId(),
|
|
203
|
+
AgreementNo: this.AgreementNo,
|
|
204
|
+
HirerType: HirerTypeEnum.PRIMARY,
|
|
205
|
+
CustomerId: this.CustomerId,
|
|
206
|
+
CustomerType: 'Customer',
|
|
207
|
+
SignatureStatus: HirerSignatureStatusEnum.PENDING,
|
|
208
|
+
SignedAt: new Date(),
|
|
209
|
+
CreatedById: loginUser.ObjectId,
|
|
210
|
+
CreatedAt: new Date(),
|
|
211
|
+
UpdatedById: loginUser.ObjectId,
|
|
212
|
+
UpdatedAt: new Date(),
|
|
213
|
+
},
|
|
214
|
+
{ transaction: dbTransaction },
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
// Create signatures record for joint hirers if any
|
|
218
|
+
if (jointHirers && jointHirers.length > 0) {
|
|
219
|
+
for (const jointHirer of jointHirers) {
|
|
220
|
+
await Rental._HirerSignatureRepo.create(
|
|
221
|
+
{
|
|
222
|
+
HirerSignatureId: this.createId(),
|
|
223
|
+
AgreementNo: this.AgreementNo,
|
|
224
|
+
HirerType: HirerTypeEnum.JOINT,
|
|
225
|
+
CustomerId: jointHirer.CustomerId,
|
|
226
|
+
CustomerType: 'SDBCustomer',
|
|
227
|
+
SignatureStatus: HirerSignatureStatusEnum.PENDING,
|
|
228
|
+
SignedAt: new Date(),
|
|
229
|
+
CreatedById: loginUser.ObjectId,
|
|
230
|
+
CreatedAt: new Date(),
|
|
231
|
+
UpdatedById: loginUser.ObjectId,
|
|
232
|
+
UpdatedAt: new Date(),
|
|
233
|
+
},
|
|
234
|
+
{ transaction: dbTransaction },
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
194
239
|
/*Part 4: Insert Rental & The Agreed Rental Price*/
|
|
195
240
|
if (!rentalPrice.PriceId) {
|
|
196
241
|
const rentalPriceData = await rentalPrice.create(
|
|
@@ -724,7 +769,11 @@ export class Rental extends ObjectBase {
|
|
|
724
769
|
}
|
|
725
770
|
}
|
|
726
771
|
|
|
727
|
-
async signAgreement(
|
|
772
|
+
async signAgreement(
|
|
773
|
+
loginUser: LoginUser,
|
|
774
|
+
CustomerId: string,
|
|
775
|
+
dbTransaction: any,
|
|
776
|
+
) {
|
|
728
777
|
try {
|
|
729
778
|
// Part 1: Privilege Checking
|
|
730
779
|
// Call loginUser.checkPrivileges() by passing:
|
|
@@ -756,6 +805,65 @@ export class Rental extends ObjectBase {
|
|
|
756
805
|
);
|
|
757
806
|
}
|
|
758
807
|
|
|
808
|
+
//Make sure CustomerId inside the listing and SignatureStatus is "Pending"
|
|
809
|
+
const signatureList = await Agreement.getSignatureList(
|
|
810
|
+
loginUser,
|
|
811
|
+
this.AgreementNo,
|
|
812
|
+
dbTransaction,
|
|
813
|
+
);
|
|
814
|
+
const customerSignature = signatureList.find(
|
|
815
|
+
(sig) =>
|
|
816
|
+
sig.CustomerId === CustomerId &&
|
|
817
|
+
sig.SignatureStatus === HirerSignatureStatusEnum.PENDING,
|
|
818
|
+
);
|
|
819
|
+
|
|
820
|
+
if (!customerSignature) {
|
|
821
|
+
throw new ClassError(
|
|
822
|
+
'Rental',
|
|
823
|
+
'RentalErrMsg01',
|
|
824
|
+
'Customer signature is not pending.',
|
|
825
|
+
);
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
//Update rental_HirerSignature
|
|
829
|
+
const signaturePayload = {
|
|
830
|
+
SignatureStatus: HirerSignatureStatusEnum.SIGNED,
|
|
831
|
+
SignedAt: new Date(),
|
|
832
|
+
UpdatedById: loginUser.ObjectId,
|
|
833
|
+
UpdatedAt: new Date(),
|
|
834
|
+
};
|
|
835
|
+
|
|
836
|
+
await Rental._HirerSignatureRepo.update(signaturePayload, {
|
|
837
|
+
where: {
|
|
838
|
+
AgreementNo: this.AgreementNo,
|
|
839
|
+
CustomerId: CustomerId,
|
|
840
|
+
},
|
|
841
|
+
transaction: dbTransaction,
|
|
842
|
+
});
|
|
843
|
+
|
|
844
|
+
const signatureActivity = new Activity();
|
|
845
|
+
signatureActivity.ActivityId = signatureActivity.createId();
|
|
846
|
+
signatureActivity.Action = ActionEnum.UPDATE;
|
|
847
|
+
signatureActivity.Description = 'Update hirer signature';
|
|
848
|
+
signatureActivity.EntityType = 'HirerSignature';
|
|
849
|
+
signatureActivity.EntityId = this.AgreementNo;
|
|
850
|
+
signatureActivity.EntityValueBefore = JSON.stringify(customerSignature);
|
|
851
|
+
signatureActivity.EntityValueAfter = JSON.stringify(signaturePayload);
|
|
852
|
+
await signatureActivity.create(loginUser.ObjectId, dbTransaction);
|
|
853
|
+
|
|
854
|
+
const updatedSignatureList = await Agreement.getSignatureList(
|
|
855
|
+
loginUser,
|
|
856
|
+
this.AgreementNo,
|
|
857
|
+
dbTransaction,
|
|
858
|
+
);
|
|
859
|
+
|
|
860
|
+
const pendingSignatures = updatedSignatureList.filter(
|
|
861
|
+
(sig) => sig.SignatureStatus === 'Pending',
|
|
862
|
+
);
|
|
863
|
+
if (pendingSignatures.length > 0) {
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
|
|
759
867
|
//Part 3: Update Agreement Status
|
|
760
868
|
// 3.1 Set EntityValueBefore to current agreement instance.
|
|
761
869
|
const entityValueAgreementBefore = {
|
|
@@ -844,6 +952,8 @@ export class Rental extends ObjectBase {
|
|
|
844
952
|
...payloadRental,
|
|
845
953
|
};
|
|
846
954
|
|
|
955
|
+
this._Status = RentalStatusEnum.PENDING_KEY_COLLECTION;
|
|
956
|
+
|
|
847
957
|
// Part 6: Record Update Agreement Activity
|
|
848
958
|
const rentalActivity = new Activity();
|
|
849
959
|
rentalActivity.ActivityId = activity.createId();
|
package/src/database.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { RentalPriceModel } from './models/rental-price.entity';
|
|
|
4
4
|
import { BookingModel } from './models/booking.entity';
|
|
5
5
|
import { JointHirerModel } from './models/joint-hirer.entity';
|
|
6
6
|
import { AgreementModel } from './models/agreement.entity';
|
|
7
|
+
import { HirerSignatureModel } from './models/hirer-signature.entity';
|
|
7
8
|
|
|
8
9
|
let sequelize: Sequelize;
|
|
9
10
|
|
|
@@ -17,6 +18,7 @@ function init(sequelizeOptions: SequelizeOptions) {
|
|
|
17
18
|
BookingModel,
|
|
18
19
|
JointHirerModel,
|
|
19
20
|
AgreementModel,
|
|
21
|
+
HirerSignatureModel,
|
|
20
22
|
]);
|
|
21
23
|
}
|
|
22
24
|
|
package/src/enum/index.ts
CHANGED
|
@@ -2,10 +2,14 @@ import { RentalStatusEnum } from './rental-status.enum';
|
|
|
2
2
|
import { BookingStatusEnum } from './booking.enum';
|
|
3
3
|
import { RentalAccountTypeEnum } from './account-type.enum';
|
|
4
4
|
import { AggrementStatusEnum } from './aggrement-status.enum';
|
|
5
|
+
import { HirerSignatureStatusEnum } from './hirer-signature-status.enum';
|
|
6
|
+
import { HirerTypeEnum } from './hirer-type.enum';
|
|
5
7
|
|
|
6
8
|
export {
|
|
7
9
|
RentalStatusEnum,
|
|
8
10
|
BookingStatusEnum,
|
|
9
11
|
RentalAccountTypeEnum,
|
|
10
12
|
AggrementStatusEnum,
|
|
13
|
+
HirerSignatureStatusEnum,
|
|
14
|
+
HirerTypeEnum,
|
|
11
15
|
};
|
package/src/index.ts
CHANGED
|
@@ -8,6 +8,8 @@ import { JointHirer } from './components/joint-hirer/joint-hirer';
|
|
|
8
8
|
import { JointHirerRepository } from './components/joint-hirer/joint-hirer.repository';
|
|
9
9
|
import { Agreement } from './components/agreement/agreement';
|
|
10
10
|
import { AgreementRepository } from './components/agreement/agreement.repository';
|
|
11
|
+
import { HirerSignature } from './components/hirer-signature/hirer-signature';
|
|
12
|
+
import { HirerSignatureRepository } from './components/hirer-signature/hirer-signature.repository';
|
|
11
13
|
import * as rentalDb from './database';
|
|
12
14
|
export * from './interfaces';
|
|
13
15
|
export * from './models';
|
|
@@ -25,4 +27,6 @@ export {
|
|
|
25
27
|
JointHirerRepository,
|
|
26
28
|
Agreement,
|
|
27
29
|
AgreementRepository,
|
|
30
|
+
HirerSignature,
|
|
31
|
+
HirerSignatureRepository,
|
|
28
32
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { HirerSignatureStatusEnum } from '../enum/hirer-signature-status.enum';
|
|
2
|
+
|
|
3
|
+
export interface IHirerSignatureAttr {
|
|
4
|
+
HirerSignatureId: string;
|
|
5
|
+
AgreementNo: string;
|
|
6
|
+
HirerType: string;
|
|
7
|
+
CustomerId: string;
|
|
8
|
+
CustomerType: string;
|
|
9
|
+
SignatureStatus: HirerSignatureStatusEnum;
|
|
10
|
+
SignedAt: Date;
|
|
11
|
+
CreatedById: string;
|
|
12
|
+
CreatedAt: Date;
|
|
13
|
+
UpdatedById: string;
|
|
14
|
+
UpdatedAt: Date;
|
|
15
|
+
}
|
package/src/interfaces/index.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { IRentalFindAllSearchAttr } from './rental-find-all-search-attr.interfac
|
|
|
4
4
|
import { IBookingAttr } from './booking-attr.interface';
|
|
5
5
|
import { IAgreementAttr } from './agreement-attr.interface';
|
|
6
6
|
import { IBookingFindAllSearchAttr } from './booking-find-all-search-attr.interface';
|
|
7
|
+
import { IHirerSignatureAttr } from './hirer-signature-attr.interface';
|
|
8
|
+
import { IResponseHirerSignature } from './response-hirer-signature-attr.interface';
|
|
7
9
|
|
|
8
10
|
export {
|
|
9
11
|
IRentalAttr,
|
|
@@ -12,4 +14,6 @@ export {
|
|
|
12
14
|
IBookingAttr,
|
|
13
15
|
IAgreementAttr,
|
|
14
16
|
IBookingFindAllSearchAttr,
|
|
17
|
+
IHirerSignatureAttr,
|
|
18
|
+
IResponseHirerSignature,
|
|
15
19
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { HirerSignatureStatusEnum } from '../enum/hirer-signature-status.enum';
|
|
2
|
+
|
|
3
|
+
export interface IResponseHirerSignature {
|
|
4
|
+
HirerSignatureId: string;
|
|
5
|
+
AgreementNo: string;
|
|
6
|
+
HirerType: string;
|
|
7
|
+
CustomerId: string;
|
|
8
|
+
CustomerName: string;
|
|
9
|
+
CustomerType: string;
|
|
10
|
+
SignatureStatus: HirerSignatureStatusEnum;
|
|
11
|
+
SignedAt: Date;
|
|
12
|
+
CreatedById: string;
|
|
13
|
+
CreatedAt: Date;
|
|
14
|
+
UpdatedById: string;
|
|
15
|
+
UpdatedAt: Date;
|
|
16
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Column, DataType, Table, Model, HasMany } from 'sequelize-typescript';
|
|
2
2
|
import { RentalModel } from './rental.entity';
|
|
3
3
|
import { AggrementStatusEnum } from '../enum/aggrement-status.enum';
|
|
4
|
+
import { HirerSignatureModel } from './hirer-signature.entity';
|
|
4
5
|
|
|
5
6
|
@Table({
|
|
6
7
|
tableName: 'rental_Agreement',
|
|
@@ -36,4 +37,7 @@ export class AgreementModel extends Model {
|
|
|
36
37
|
|
|
37
38
|
@HasMany(() => RentalModel)
|
|
38
39
|
Rentals: RentalModel[];
|
|
40
|
+
|
|
41
|
+
@HasMany(() => HirerSignatureModel)
|
|
42
|
+
HirerSignatures: HirerSignatureModel[];
|
|
39
43
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Column,
|
|
3
|
+
DataType,
|
|
4
|
+
Table,
|
|
5
|
+
Model,
|
|
6
|
+
ForeignKey,
|
|
7
|
+
BelongsTo,
|
|
8
|
+
CreatedAt,
|
|
9
|
+
UpdatedAt,
|
|
10
|
+
} from 'sequelize-typescript';
|
|
11
|
+
import { AgreementModel } from './agreement.entity';
|
|
12
|
+
|
|
13
|
+
@Table({
|
|
14
|
+
tableName: 'rental_HirerSignature',
|
|
15
|
+
})
|
|
16
|
+
export class HirerSignatureModel extends Model {
|
|
17
|
+
@Column({
|
|
18
|
+
primaryKey: true,
|
|
19
|
+
allowNull: false,
|
|
20
|
+
type: DataType.STRING(30),
|
|
21
|
+
})
|
|
22
|
+
HirerSignatureId: string;
|
|
23
|
+
|
|
24
|
+
@ForeignKey(() => AgreementModel)
|
|
25
|
+
@Column({
|
|
26
|
+
allowNull: false,
|
|
27
|
+
type: DataType.STRING(30),
|
|
28
|
+
})
|
|
29
|
+
AgreementNo: string;
|
|
30
|
+
|
|
31
|
+
@Column({
|
|
32
|
+
allowNull: false,
|
|
33
|
+
type: DataType.STRING(10),
|
|
34
|
+
})
|
|
35
|
+
HirerType: string;
|
|
36
|
+
|
|
37
|
+
@Column({
|
|
38
|
+
allowNull: false,
|
|
39
|
+
type: DataType.STRING(30),
|
|
40
|
+
})
|
|
41
|
+
CustomerId: string;
|
|
42
|
+
|
|
43
|
+
@Column({
|
|
44
|
+
allowNull: false,
|
|
45
|
+
type: DataType.STRING(30),
|
|
46
|
+
})
|
|
47
|
+
CustomerType: string;
|
|
48
|
+
|
|
49
|
+
@Column({
|
|
50
|
+
allowNull: false,
|
|
51
|
+
type: DataType.STRING(10),
|
|
52
|
+
})
|
|
53
|
+
SignatureStatus: string;
|
|
54
|
+
|
|
55
|
+
@Column({
|
|
56
|
+
allowNull: false,
|
|
57
|
+
type: DataType.DATE,
|
|
58
|
+
})
|
|
59
|
+
SignedAt: Date;
|
|
60
|
+
|
|
61
|
+
@Column({
|
|
62
|
+
allowNull: false,
|
|
63
|
+
type: DataType.STRING(30),
|
|
64
|
+
})
|
|
65
|
+
CreatedById: string;
|
|
66
|
+
|
|
67
|
+
@CreatedAt
|
|
68
|
+
CreatedAt: Date;
|
|
69
|
+
|
|
70
|
+
@Column({
|
|
71
|
+
allowNull: false,
|
|
72
|
+
type: DataType.STRING(30),
|
|
73
|
+
})
|
|
74
|
+
UpdatedById: string;
|
|
75
|
+
|
|
76
|
+
@UpdatedAt
|
|
77
|
+
UpdatedAt: Date;
|
|
78
|
+
|
|
79
|
+
@BelongsTo(() => AgreementModel)
|
|
80
|
+
Agreement: AgreementModel;
|
|
81
|
+
}
|
package/src/models/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { RentalPriceModel } from './rental-price.entity';
|
|
|
3
3
|
import { BookingModel } from './booking.entity';
|
|
4
4
|
import { JointHirerModel } from './joint-hirer.entity';
|
|
5
5
|
import { AgreementModel } from './agreement.entity';
|
|
6
|
+
import { HirerSignatureModel } from './hirer-signature.entity';
|
|
6
7
|
|
|
7
8
|
export {
|
|
8
9
|
RentalModel,
|
|
@@ -10,4 +11,5 @@ export {
|
|
|
10
11
|
BookingModel,
|
|
11
12
|
JointHirerModel,
|
|
12
13
|
AgreementModel,
|
|
14
|
+
HirerSignatureModel,
|
|
13
15
|
};
|
package/tsconfig.json
CHANGED
package/.eslintrc
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"parser": "@typescript-eslint/parser",
|
|
3
|
-
"parserOptions": {
|
|
4
|
-
"ecmaVersion": "latest",
|
|
5
|
-
"sourceType": "module" // Allows for the use of imports
|
|
6
|
-
},
|
|
7
|
-
"extends": ["plugin:@typescript-eslint/recommended"],
|
|
8
|
-
"env": {
|
|
9
|
-
"node": true // Enable Node.js global variables
|
|
10
|
-
},
|
|
11
|
-
"rules": {
|
|
12
|
-
"no-console": "off",
|
|
13
|
-
"import/prefer-default-export": "off",
|
|
14
|
-
"@typescript-eslint/no-unused-vars": "warn"
|
|
15
|
-
}
|
|
16
|
-
}
|
package/.eslintrc.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
parser: "@typescript-eslint/parser",
|
|
3
|
-
plugins: ["@typescript-eslint"],
|
|
4
|
-
|
|
5
|
-
parserOptions: {
|
|
6
|
-
ecmaVersion: "latest", // Allows the use of modern ECMAScript features
|
|
7
|
-
sourceType: "module", // Allows for the use of imports
|
|
8
|
-
},
|
|
9
|
-
|
|
10
|
-
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
|
|
11
|
-
env: {
|
|
12
|
-
node: true, // Enable Node.js global variables
|
|
13
|
-
},
|
|
14
|
-
rules: {
|
|
15
|
-
"no-console": "off",
|
|
16
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
17
|
-
"@typescript-eslint/no-var-requires": "off",
|
|
18
|
-
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
19
|
-
"import/prefer-default-export": "off",
|
|
20
|
-
"@typescript-eslint/no-unused-vars": "warn",
|
|
21
|
-
"no-useless-catch": "off",
|
|
22
|
-
"@typescript-eslint/no-non-null-assertion": "off",
|
|
23
|
-
"@typescript-eslint/no-empty-function": "off",
|
|
24
|
-
"@typescript-eslint/no-empty-interface": "off",
|
|
25
|
-
"@typescript-eslint/no-inferrable-types": "off",
|
|
26
|
-
"@typescript-eslint/no-namespace": "off",
|
|
27
|
-
"@typescript-eslint/no-use-before-define": "off",
|
|
28
|
-
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
29
|
-
"@typescript-eslint/no-unsafe-call": "off",
|
|
30
|
-
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
31
|
-
"@typescript-eslint/no-unsafe-return": "off",
|
|
32
|
-
"@typescript-eslint/restrict-template-expressions": "off",
|
|
33
|
-
"no-useless-escape": "off",
|
|
34
|
-
},
|
|
35
|
-
};
|
package/tomei-rental-0.9.4.tgz
DELETED
|
Binary file
|