@tomei/rental 0.12.4 → 0.13.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/.commitlintrc.json +22 -22
- package/.gitlab-ci.yml +16 -16
- package/.husky/commit-msg +15 -15
- package/.husky/pre-commit +7 -7
- package/.prettierrc +4 -4
- package/Jenkinsfile +51 -51
- package/README.md +8 -8
- package/dist/src/components/agreement/agreement.d.ts +5 -1
- package/dist/src/components/agreement/agreement.js +59 -0
- package/dist/src/components/agreement/agreement.js.map +1 -1
- 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/rental/rental.d.ts +3 -1
- package/dist/src/components/rental/rental.js +84 -16
- package/dist/src/components/rental/rental.js.map +1 -1
- package/dist/src/database.js +2 -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/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 +3 -1
- package/dist/src/enum/index.js +5 -1
- package/dist/src/enum/index.js.map +1 -1
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.js +5 -1
- package/dist/src/index.js.map +1 -1
- 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 +3 -1
- 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 +2 -0
- package/dist/src/models/agreement.entity.js +5 -0
- package/dist/src/models/agreement.entity.js.map +1 -1
- 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 +2 -1
- package/dist/src/models/index.js +3 -1
- package/dist/src/models/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/eslint.config.mjs +58 -58
- package/jest.config.js +10 -10
- package/migrations/booking-table-migration.js +79 -79
- package/migrations/hirer-signature-table-migration.js +64 -0
- package/migrations/joint-hirer-table-migration.js +52 -52
- package/migrations/rental-aggrement-table-migration.js +30 -30
- package/migrations/rental-price-table-migration.js +32 -32
- package/migrations/rental-table-migrations.js +96 -96
- package/package.json +75 -75
- package/sonar-project.properties +12 -12
- package/src/components/agreement/agreement.repository.ts +54 -54
- package/src/components/agreement/agreement.ts +148 -49
- package/src/components/booking/booking.repository.ts +51 -51
- package/src/components/booking/booking.ts +492 -492
- package/src/components/hirer-signature/hirer-signature.repository.ts +54 -0
- package/src/components/hirer-signature/hirer-signature.ts +140 -0
- package/src/components/joint-hirer/joint-hirer.repository.ts +54 -54
- package/src/components/joint-hirer/joint-hirer.ts +137 -137
- package/src/components/rental/rental.repository.ts +51 -51
- package/src/components/rental/rental.ts +1073 -963
- package/src/components/rental-price/rental-price.repository.ts +54 -54
- package/src/components/rental-price/rental-price.ts +100 -100
- package/src/database.ts +29 -27
- package/src/enum/account-type.enum.ts +4 -4
- package/src/enum/booking.enum.ts +5 -5
- package/src/enum/hirer-signature-status.enum.ts +4 -0
- package/src/enum/hirer-type.enum.ts +4 -0
- package/src/enum/index.ts +15 -11
- package/src/enum/rental-status.enum.ts +39 -39
- package/src/index.ts +32 -28
- package/src/interfaces/agreement-attr.interface.ts +7 -7
- package/src/interfaces/booking-attr.interface.ts +19 -19
- package/src/interfaces/booking-find-all-search-attr.interface.ts +12 -12
- package/src/interfaces/hirer-signature-attr.interface.ts +15 -0
- package/src/interfaces/index.ts +19 -15
- package/src/interfaces/joint-hirer-attr.interface.ts +10 -10
- package/src/interfaces/rental-attr.interface.ts +25 -25
- package/src/interfaces/rental-find-all-search-attr.interface.ts +11 -11
- package/src/interfaces/rental-price-attr.interface.ts +7 -7
- package/src/interfaces/response-hirer-signature-attr.interface.ts +16 -0
- package/src/models/agreement.entity.ts +43 -39
- package/src/models/booking.entity.ts +105 -105
- package/src/models/hirer-signature.entity.ts +81 -0
- package/src/models/index.ts +15 -13
- package/src/models/joint-hirer.entity.ts +63 -63
- package/src/models/rental-price.entity.ts +38 -38
- package/src/models/rental.entity.ts +133 -133
- package/tsconfig.build.json +5 -5
- package/tsconfig.json +24 -24
|
@@ -1,49 +1,148 @@
|
|
|
1
|
-
import { ObjectBase } from '@tomei/general';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
1
|
+
import { ClassError, ObjectBase } from '@tomei/general';
|
|
2
|
+
import { AggrementStatusEnum } from '../../enum/aggrement-status.enum';
|
|
3
|
+
import { IAgreementAttr } from '../../interfaces/agreement-attr.interface';
|
|
4
|
+
import { AgreementRepository } from './agreement.repository';
|
|
5
|
+
import { ApplicationConfig } from '@tomei/config';
|
|
6
|
+
import { LoginUser } from '@tomei/sso';
|
|
7
|
+
import { HirerSignatureRepository } from '../hirer-signature/hirer-signature.repository';
|
|
8
|
+
import * as rentalDb from '../../database';
|
|
9
|
+
import { QueryTypes } from 'sequelize';
|
|
10
|
+
import { IResponseHirerSignature } from '../../interfaces/response-hirer-signature-attr.interface';
|
|
11
|
+
|
|
12
|
+
export class Agreement extends ObjectBase {
|
|
13
|
+
ObjectId: string;
|
|
14
|
+
ObjectName: string;
|
|
15
|
+
ObjectType: string = 'Agreement';
|
|
16
|
+
TableName = 'rental_Agreement';
|
|
17
|
+
Status: AggrementStatusEnum;
|
|
18
|
+
DateSigned: Date;
|
|
19
|
+
MediaId: string;
|
|
20
|
+
|
|
21
|
+
private static _Repo = new AgreementRepository();
|
|
22
|
+
protected static _HirerSignatureRepo = new HirerSignatureRepository();
|
|
23
|
+
|
|
24
|
+
get AgreementNo(): string {
|
|
25
|
+
return this.ObjectId;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
set AgreementNo(value: string) {
|
|
29
|
+
this.ObjectId = value;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
protected constructor(agreementAttr?: IAgreementAttr) {
|
|
33
|
+
super();
|
|
34
|
+
if (agreementAttr) {
|
|
35
|
+
this.ObjectId = agreementAttr.AgreementNo;
|
|
36
|
+
this.Status = agreementAttr.Status;
|
|
37
|
+
this.DateSigned = agreementAttr.DateSigned;
|
|
38
|
+
this.MediaId = agreementAttr.MediaId;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public static async init(
|
|
43
|
+
agreementNo?: string,
|
|
44
|
+
dbTransaction?: any,
|
|
45
|
+
): Promise<Agreement> {
|
|
46
|
+
try {
|
|
47
|
+
if (agreementNo) {
|
|
48
|
+
const agreement = await this._Repo.findByPk(agreementNo, dbTransaction);
|
|
49
|
+
return new Agreement(agreement?.get({ plain: true }));
|
|
50
|
+
}
|
|
51
|
+
return new Agreement();
|
|
52
|
+
} catch (error) {
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public static async getSignatureList(
|
|
58
|
+
loginUser: LoginUser,
|
|
59
|
+
agreementNo: string,
|
|
60
|
+
dbTransaction: any,
|
|
61
|
+
) {
|
|
62
|
+
try {
|
|
63
|
+
// Part 1: Privilege Checking
|
|
64
|
+
// Call loginUser.checkPrivileges() by passing:
|
|
65
|
+
// SystemCode: "<get_from_app_config>"
|
|
66
|
+
// PrivilegeCode: "AGREEMENT_SIGNATURE_LIST"
|
|
67
|
+
const systemCode =
|
|
68
|
+
ApplicationConfig.getComponentConfigValue('system-code');
|
|
69
|
+
const isPrivileged = loginUser.checkPrivileges(
|
|
70
|
+
systemCode,
|
|
71
|
+
'AGREEMENT_SIGNATURE_LIST',
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
if (!isPrivileged) {
|
|
75
|
+
throw new ClassError(
|
|
76
|
+
'Agreement',
|
|
77
|
+
'AgreementErrMsg01',
|
|
78
|
+
"You do not have 'AGREEMENT_SIGNATURE_LIST' privilege.",
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Part 2: Validation
|
|
83
|
+
// Make sure agreementNo exists, if not throw new ClassError by passing:
|
|
84
|
+
if (!agreementNo) {
|
|
85
|
+
throw new ClassError(
|
|
86
|
+
'AgreementNo',
|
|
87
|
+
'AgreementNoErrMsg01',
|
|
88
|
+
'AgreementNo is missing',
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Part 3: Retrieve Listing
|
|
93
|
+
const query = `
|
|
94
|
+
SELECT
|
|
95
|
+
hs.*,
|
|
96
|
+
c.FullName,
|
|
97
|
+
cf.RightThumb,
|
|
98
|
+
cf.RightIndexFinger,
|
|
99
|
+
cf.LeftThumb,
|
|
100
|
+
cf.LeftIndexFinger
|
|
101
|
+
FROM
|
|
102
|
+
rental_HirerSignature hs
|
|
103
|
+
LEFT JOIN
|
|
104
|
+
sdb_Customer c ON hs.CustomerId = c.CustomerId
|
|
105
|
+
LEFT JOIN
|
|
106
|
+
${process.env.CENTRAL_DB_NAME}.customer_fingerprint cf ON c.CRMRefNo = cf.CustomerId
|
|
107
|
+
WHERE
|
|
108
|
+
hs.AgreementNo = '${agreementNo}'
|
|
109
|
+
`;
|
|
110
|
+
|
|
111
|
+
const db = rentalDb.getConnection();
|
|
112
|
+
|
|
113
|
+
const signatures = await db.query(query, {
|
|
114
|
+
type: QueryTypes.SELECT,
|
|
115
|
+
transaction: dbTransaction,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// Process the result to convert fingerprint fields to base64 strings
|
|
119
|
+
const processedSignatures = signatures.map((signature: any) => {
|
|
120
|
+
const convertToBase64 = (data: Buffer | null) =>
|
|
121
|
+
data ? atob(Buffer.from(data).toString('base64')) : null;
|
|
122
|
+
|
|
123
|
+
const processedSignature = {
|
|
124
|
+
...signature,
|
|
125
|
+
FingerPrint: {
|
|
126
|
+
RightThumb: convertToBase64(signature.RightThumb),
|
|
127
|
+
RightIndexFinger: convertToBase64(signature.RightIndexFinger),
|
|
128
|
+
LeftThumb: convertToBase64(signature.LeftThumb),
|
|
129
|
+
LeftIndexFinger: convertToBase64(signature.LeftIndexFinger),
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// Delete individual fingerprint fields
|
|
134
|
+
delete processedSignature.RightThumb;
|
|
135
|
+
delete processedSignature.RightIndexFinger;
|
|
136
|
+
delete processedSignature.LeftThumb;
|
|
137
|
+
delete processedSignature.LeftIndexFinger;
|
|
138
|
+
|
|
139
|
+
return processedSignature;
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// Return the processed records
|
|
143
|
+
return processedSignatures;
|
|
144
|
+
} catch (error) {
|
|
145
|
+
throw error;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import { RepositoryBase, IRepositoryBase } from '@tomei/general';
|
|
2
|
-
import { BookingModel } from '../../models/booking.entity';
|
|
3
|
-
|
|
4
|
-
export class BookingRepository
|
|
5
|
-
extends RepositoryBase<BookingModel>
|
|
6
|
-
implements IRepositoryBase<BookingModel>
|
|
7
|
-
{
|
|
8
|
-
constructor() {
|
|
9
|
-
super(BookingModel);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
async findByPk(id: string, transaction?: any): Promise<BookingModel | null> {
|
|
13
|
-
try {
|
|
14
|
-
const result = await BookingModel.findByPk(id, {
|
|
15
|
-
transaction: transaction,
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
return result;
|
|
19
|
-
} catch (error) {
|
|
20
|
-
throw new Error(`An Error occured when fetching : ${error.message}`);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async delete(BookingNo: string, dbTransaction?: any) {
|
|
25
|
-
try {
|
|
26
|
-
const options = {
|
|
27
|
-
where: {
|
|
28
|
-
BookingNo: BookingNo,
|
|
29
|
-
},
|
|
30
|
-
transaction: dbTransaction,
|
|
31
|
-
};
|
|
32
|
-
await BookingModel.destroy(options);
|
|
33
|
-
} catch (error) {
|
|
34
|
-
throw new Error(`An Error occured when delete : ${error.message}`);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async findAndCountAll(options?: any) {
|
|
39
|
-
try {
|
|
40
|
-
let Bookings: any;
|
|
41
|
-
if (options) {
|
|
42
|
-
Bookings = await BookingModel.findAndCountAll(options);
|
|
43
|
-
} else {
|
|
44
|
-
Bookings = await BookingModel.findAndCountAll();
|
|
45
|
-
}
|
|
46
|
-
return Bookings;
|
|
47
|
-
} catch (error) {
|
|
48
|
-
throw new Error(`An Error occured when retriving : ${error.message}`);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
1
|
+
import { RepositoryBase, IRepositoryBase } from '@tomei/general';
|
|
2
|
+
import { BookingModel } from '../../models/booking.entity';
|
|
3
|
+
|
|
4
|
+
export class BookingRepository
|
|
5
|
+
extends RepositoryBase<BookingModel>
|
|
6
|
+
implements IRepositoryBase<BookingModel>
|
|
7
|
+
{
|
|
8
|
+
constructor() {
|
|
9
|
+
super(BookingModel);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async findByPk(id: string, transaction?: any): Promise<BookingModel | null> {
|
|
13
|
+
try {
|
|
14
|
+
const result = await BookingModel.findByPk(id, {
|
|
15
|
+
transaction: transaction,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return result;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
throw new Error(`An Error occured when fetching : ${error.message}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async delete(BookingNo: string, dbTransaction?: any) {
|
|
25
|
+
try {
|
|
26
|
+
const options = {
|
|
27
|
+
where: {
|
|
28
|
+
BookingNo: BookingNo,
|
|
29
|
+
},
|
|
30
|
+
transaction: dbTransaction,
|
|
31
|
+
};
|
|
32
|
+
await BookingModel.destroy(options);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
throw new Error(`An Error occured when delete : ${error.message}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async findAndCountAll(options?: any) {
|
|
39
|
+
try {
|
|
40
|
+
let Bookings: any;
|
|
41
|
+
if (options) {
|
|
42
|
+
Bookings = await BookingModel.findAndCountAll(options);
|
|
43
|
+
} else {
|
|
44
|
+
Bookings = await BookingModel.findAndCountAll();
|
|
45
|
+
}
|
|
46
|
+
return Bookings;
|
|
47
|
+
} catch (error) {
|
|
48
|
+
throw new Error(`An Error occured when retriving : ${error.message}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|