@tomei/rental 0.11.4 → 0.12.2
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 -0
- package/.husky/pre-commit +0 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17 -17
- package/dist/src/components/agreement/agreement.d.ts +17 -17
- package/dist/src/components/agreement/agreement.js +49 -49
- package/dist/src/components/agreement/agreement.js.map +1 -1
- package/dist/src/components/agreement/agreement.repository.d.ts +8 -8
- package/dist/src/components/agreement/agreement.repository.js +66 -66
- package/dist/src/components/agreement/agreement.repository.js.map +1 -1
- package/dist/src/components/booking/booking.d.ts +46 -45
- package/dist/src/components/booking/booking.js +313 -271
- package/dist/src/components/booking/booking.js.map +1 -1
- package/dist/src/components/booking/booking.repository.d.ts +8 -8
- package/dist/src/components/booking/booking.repository.js +66 -66
- package/dist/src/components/booking/booking.repository.js.map +1 -1
- package/dist/src/components/joint-hirer/joint-hirer.d.ts +23 -23
- package/dist/src/components/joint-hirer/joint-hirer.js +105 -105
- package/dist/src/components/joint-hirer/joint-hirer.js.map +1 -1
- package/dist/src/components/joint-hirer/joint-hirer.repository.d.ts +8 -8
- package/dist/src/components/joint-hirer/joint-hirer.repository.js +66 -66
- package/dist/src/components/joint-hirer/joint-hirer.repository.js.map +1 -1
- package/dist/src/components/rental/rental.d.ts +59 -59
- package/dist/src/components/rental/rental.js +603 -603
- package/dist/src/components/rental/rental.js.map +1 -1
- package/dist/src/components/rental/rental.repository.d.ts +8 -8
- package/dist/src/components/rental/rental.repository.js +66 -66
- package/dist/src/components/rental/rental.repository.js.map +1 -1
- package/dist/src/components/rental-price/rental-price.d.ts +18 -18
- package/dist/src/components/rental-price/rental-price.js +78 -78
- package/dist/src/components/rental-price/rental-price.js.map +1 -1
- package/dist/src/components/rental-price/rental-price.repository.d.ts +8 -8
- package/dist/src/components/rental-price/rental-price.repository.js +66 -66
- package/dist/src/components/rental-price/rental-price.repository.js.map +1 -1
- package/dist/src/database.d.ts +4 -4
- package/dist/src/database.js +24 -25
- package/dist/src/database.js.map +1 -1
- package/dist/src/enum/account-type.enum.d.ts +4 -4
- package/dist/src/enum/account-type.enum.js +8 -8
- package/dist/src/enum/account-type.enum.js.map +1 -1
- package/dist/src/enum/aggrement-status.enum.d.ts +5 -5
- package/dist/src/enum/aggrement-status.enum.js +9 -9
- package/dist/src/enum/aggrement-status.enum.js.map +1 -1
- package/dist/src/enum/booking.enum.d.ts +5 -5
- package/dist/src/enum/booking.enum.js +9 -9
- package/dist/src/enum/booking.enum.js.map +1 -1
- package/dist/src/enum/index.d.ts +5 -5
- package/dist/src/enum/index.js +11 -11
- package/dist/src/enum/rental-status.enum.d.ts +9 -9
- package/dist/src/enum/rental-status.enum.js +13 -13
- package/dist/src/enum/rental-status.enum.js.map +1 -1
- package/dist/src/index.d.ts +15 -15
- package/dist/src/index.js +42 -42
- package/dist/src/interfaces/agreement-attr.interface.d.ts +7 -7
- package/dist/src/interfaces/agreement-attr.interface.js +2 -2
- package/dist/src/interfaces/booking-attr.interface.d.ts +18 -18
- package/dist/src/interfaces/booking-attr.interface.js +2 -2
- package/dist/src/interfaces/booking-find-all-search-attr.interface.d.ts +12 -12
- package/dist/src/interfaces/booking-find-all-search-attr.interface.js +2 -2
- package/dist/src/interfaces/index.d.ts +7 -7
- package/dist/src/interfaces/index.js +2 -2
- package/dist/src/interfaces/joint-hirer-attr.interface.d.ts +10 -10
- package/dist/src/interfaces/joint-hirer-attr.interface.js +2 -2
- package/dist/src/interfaces/rental-attr.interface.d.ts +24 -24
- package/dist/src/interfaces/rental-attr.interface.js +2 -2
- package/dist/src/interfaces/rental-find-all-search-attr.interface.d.ts +10 -10
- package/dist/src/interfaces/rental-find-all-search-attr.interface.js +2 -2
- package/dist/src/interfaces/rental-price-attr.interface.d.ts +7 -7
- package/dist/src/interfaces/rental-price-attr.interface.js +2 -2
- package/dist/src/models/agreement.entity.d.ts +10 -10
- package/dist/src/models/agreement.entity.js +59 -59
- package/dist/src/models/agreement.entity.js.map +1 -1
- package/dist/src/models/booking.entity.d.ts +21 -21
- package/dist/src/models/booking.entity.js +127 -127
- package/dist/src/models/booking.entity.js.map +1 -1
- package/dist/src/models/index.d.ts +6 -6
- package/dist/src/models/index.js +13 -13
- package/dist/src/models/joint-hirer.entity.d.ts +13 -13
- package/dist/src/models/joint-hirer.entity.js +78 -78
- package/dist/src/models/joint-hirer.entity.js.map +1 -1
- package/dist/src/models/rental-price.entity.d.ts +8 -8
- package/dist/src/models/rental-price.entity.js +58 -58
- package/dist/src/models/rental-price.entity.js.map +1 -1
- package/dist/src/models/rental.entity.d.ts +29 -29
- package/dist/src/models/rental.entity.js +159 -159
- package/dist/src/models/rental.entity.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/eslint.config.mjs +37 -0
- package/migrations/booking-table-migration.js +1 -1
- 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 +33 -30
- package/src/components/booking/booking.ts +94 -1
- package/src/components/joint-hirer/joint-hirer.ts +1 -1
- package/src/components/rental/rental.ts +7 -10
- package/.eslintignore +0 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import eslintPlugin from "@typescript-eslint/eslint-plugin";
|
|
2
|
+
import parser from "@typescript-eslint/parser";
|
|
3
|
+
|
|
4
|
+
export default [
|
|
5
|
+
{
|
|
6
|
+
languageOptions: {
|
|
7
|
+
parser: parser,
|
|
8
|
+
ecmaVersion: "latest", // Allows modern ECMAScript features
|
|
9
|
+
sourceType: "module", // Allows for the use of imports
|
|
10
|
+
},
|
|
11
|
+
plugins: {
|
|
12
|
+
"@typescript-eslint": eslintPlugin,
|
|
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
|
+
ignores: ["node_modules", "dist"],
|
|
36
|
+
},
|
|
37
|
+
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomei/rental",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.2",
|
|
4
4
|
"description": "Tomei Rental Package",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -26,42 +26,45 @@
|
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://gitlab.com/tomei-package/rental#readme",
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@commitlint/cli": "^
|
|
30
|
-
"@commitlint/config-conventional": "^
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
29
|
+
"@commitlint/cli": "^19.6.0",
|
|
30
|
+
"@commitlint/config-conventional": "^19.6.0",
|
|
31
|
+
"@eslint/js": "^9.15.0",
|
|
32
|
+
"@tsconfig/node18": "^18.2.4",
|
|
33
|
+
"@types/jest": "^29.5.14",
|
|
33
34
|
"@types/luxon": "^3.4.2",
|
|
34
|
-
"@types/node": "^
|
|
35
|
-
"@types/validator": "^13.
|
|
36
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
37
|
-
"dotenv": "^16.
|
|
38
|
-
"eslint": "^
|
|
39
|
-
"eslint-config-prettier": "^
|
|
40
|
-
"eslint-plugin-prettier": "^
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"jest
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"ts-
|
|
48
|
-
"
|
|
49
|
-
"
|
|
35
|
+
"@types/node": "^22.10.0",
|
|
36
|
+
"@types/validator": "^13.12.2",
|
|
37
|
+
"@typescript-eslint/eslint-plugin": "^8.16.0",
|
|
38
|
+
"dotenv": "^16.4.5",
|
|
39
|
+
"eslint": "^9.15.0",
|
|
40
|
+
"eslint-config-prettier": "^9.1.0",
|
|
41
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
42
|
+
"globals": "^15.12.0",
|
|
43
|
+
"husky": "^9.1.7",
|
|
44
|
+
"jest": "^29.7.0",
|
|
45
|
+
"jest-mock-extended": "^3.0.7",
|
|
46
|
+
"lint-staged": "^15.2.10",
|
|
47
|
+
"prettier": "^3.4.1",
|
|
48
|
+
"ts-jest": "^29.2.5",
|
|
49
|
+
"ts-node": "^10.9.2",
|
|
50
|
+
"tsc-watch": "^6.2.1",
|
|
51
|
+
"tsconfig-paths": "^4.2.0",
|
|
50
52
|
"tslint": "^6.1.3",
|
|
51
|
-
"typescript": "^
|
|
53
|
+
"typescript": "^5.7.2",
|
|
54
|
+
"typescript-eslint": "^8.16.0"
|
|
52
55
|
},
|
|
53
56
|
"publishConfig": {
|
|
54
57
|
"access": "public"
|
|
55
58
|
},
|
|
56
59
|
"peerDependencies": {
|
|
57
|
-
"@tomei/activity-history": "^0.2.
|
|
58
|
-
"@tomei/config": "^0.3.
|
|
59
|
-
"@tomei/general": "^0.
|
|
60
|
-
"@tomei/sso": "^0.
|
|
60
|
+
"@tomei/activity-history": "^0.2.21",
|
|
61
|
+
"@tomei/config": "^0.3.19",
|
|
62
|
+
"@tomei/general": "^0.21.0",
|
|
63
|
+
"@tomei/sso": "^0.51.3",
|
|
61
64
|
"cuid": "^3.0.0",
|
|
62
|
-
"reflect-metadata": "^0.
|
|
63
|
-
"sequelize": "^6.
|
|
64
|
-
"sequelize-typescript": "^2.1.
|
|
65
|
+
"reflect-metadata": "^0.2.2",
|
|
66
|
+
"sequelize": "^6.37.5",
|
|
67
|
+
"sequelize-typescript": "^2.1.6"
|
|
65
68
|
},
|
|
66
69
|
"lint-staged": {
|
|
67
70
|
"*/**/*.{js,ts,tsx}": [
|
|
@@ -70,6 +73,6 @@
|
|
|
70
73
|
]
|
|
71
74
|
},
|
|
72
75
|
"dependencies": {
|
|
73
|
-
"luxon": "^3.
|
|
76
|
+
"luxon": "^3.5.0"
|
|
74
77
|
}
|
|
75
78
|
}
|
|
@@ -238,7 +238,7 @@ export class Booking extends ObjectBase {
|
|
|
238
238
|
//Part 4: Record Create Booking Activity
|
|
239
239
|
const activity = new Activity();
|
|
240
240
|
activity.ActivityId = activity.createId();
|
|
241
|
-
activity.Action = ActionEnum.
|
|
241
|
+
activity.Action = ActionEnum.CREATE;
|
|
242
242
|
activity.Description = 'Add Booking';
|
|
243
243
|
activity.EntityId = this.BookingNo;
|
|
244
244
|
activity.EntityType = this.ObjectType;
|
|
@@ -396,4 +396,97 @@ export class Booking extends ObjectBase {
|
|
|
396
396
|
throw error;
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
|
+
|
|
400
|
+
public static async updateLeadToCustomer(
|
|
401
|
+
loginUser: LoginUser, //The user performing the operation. Used for tracking who initiated the update.
|
|
402
|
+
dbTransaction: any, //The database transaction object to ensure atomicity of the operation.
|
|
403
|
+
LeadId: string, //The identifier for the lead whose bookings will be updated.
|
|
404
|
+
CustomerId: string, //The identifier of the customer to replace the lead in the booking records.
|
|
405
|
+
) {
|
|
406
|
+
// This method updates all booking records where LeadId matches the provided LeadId by replacing the LeadId with the CustomerId and updating the CustomerType from 'Lead' to 'Customer'.
|
|
407
|
+
try {
|
|
408
|
+
// Part 1: Privilege Checking
|
|
409
|
+
// Call loginUser.checkPrivileges() with parameters:
|
|
410
|
+
// SystemCode: Retrieve from app config.
|
|
411
|
+
// PrivilegeCode: 'BOOKING_UPDATE'.
|
|
412
|
+
const systemCode =
|
|
413
|
+
ApplicationConfig.getComponentConfigValue('system-code');
|
|
414
|
+
const isPrivileged = await loginUser.checkPrivileges(
|
|
415
|
+
systemCode,
|
|
416
|
+
'BOOKING_UPDATE',
|
|
417
|
+
);
|
|
418
|
+
if (!isPrivileged) {
|
|
419
|
+
throw new ClassError(
|
|
420
|
+
'Booking',
|
|
421
|
+
'BookingErrMsg02',
|
|
422
|
+
"You do not have 'BOOKING_UPDATE' privilege",
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
// Part 2: Validation
|
|
426
|
+
// Validate the LeadId and CustomerId to ensure they are not null or invalid.
|
|
427
|
+
if (!LeadId || !CustomerId) {
|
|
428
|
+
throw new ClassError(
|
|
429
|
+
'Booking',
|
|
430
|
+
'BookingErrMsg02',
|
|
431
|
+
'LeadId and CustomerId cannot be null or invalid',
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
// Part 3: Retrieve Records
|
|
435
|
+
// Retrieve all booking records:
|
|
436
|
+
// where
|
|
437
|
+
// [Op.AND]:
|
|
438
|
+
// CustomerId: Params.LeadId
|
|
439
|
+
// CustomerType: "Lead"
|
|
440
|
+
// dbTransaction
|
|
441
|
+
const bookings = await Booking._Repo.findAll({
|
|
442
|
+
where: {
|
|
443
|
+
[Op.and]: [{ CustomerId: LeadId }, { CustomerType: 'Lead' }],
|
|
444
|
+
},
|
|
445
|
+
transaction: dbTransaction,
|
|
446
|
+
});
|
|
447
|
+
// Part 5: Update Records and Record Activity
|
|
448
|
+
// For each matching booking record:
|
|
449
|
+
for (const booking of bookings) {
|
|
450
|
+
// Update the CustomerId from LeadId to CustomerId.
|
|
451
|
+
// Update the CustomerType from 'Lead' to 'Customer'.
|
|
452
|
+
// Ensure the UpdatedById and UpdatedAt fields in the SDB booking record are updated to reflect the loginUser and the current timestamp.
|
|
453
|
+
const EntityValueBefore = {
|
|
454
|
+
...booking.get({ plain: true }),
|
|
455
|
+
};
|
|
456
|
+
booking.CustomerId = CustomerId;
|
|
457
|
+
booking.CustomerType = 'Customer';
|
|
458
|
+
booking.UpdatedById = loginUser.ObjectId;
|
|
459
|
+
booking.UpdatedAt = DateTime.now().toJSDate();
|
|
460
|
+
await booking.save({
|
|
461
|
+
transaction: dbTransaction,
|
|
462
|
+
});
|
|
463
|
+
// Record Update Activity:
|
|
464
|
+
// Initialise EntityValueAfter variable and set it to the updated SDB booking record.
|
|
465
|
+
// Instantiate a new activity from the Activity class, and set:
|
|
466
|
+
// ActivityId: activity.createId()
|
|
467
|
+
// Action: ActionEnum.Update
|
|
468
|
+
// Description: "Update Lead to Customer"
|
|
469
|
+
// EntityType: "Booking"
|
|
470
|
+
// EntityId: <UpdatedBookingRecord>.BookingId
|
|
471
|
+
// EntityValueBefore: Stringified representation of the original SDB booking record.
|
|
472
|
+
// EntityValueAfter: EntityValueAfter (stringified representation of the updated booking record).
|
|
473
|
+
const activity = new Activity();
|
|
474
|
+
activity.ActivityId = activity.createId();
|
|
475
|
+
activity.Action = ActionEnum.UPDATE;
|
|
476
|
+
activity.Description = 'Update Lead to Customer';
|
|
477
|
+
activity.EntityType = 'Booking';
|
|
478
|
+
activity.EntityId = booking.BookingNo;
|
|
479
|
+
activity.EntityValueBefore = JSON.stringify(EntityValueBefore);
|
|
480
|
+
activity.EntityValueAfter = JSON.stringify(
|
|
481
|
+
booking.get({ plain: true }),
|
|
482
|
+
);
|
|
483
|
+
// Call the activity create() method by passing:
|
|
484
|
+
// dbTransaction
|
|
485
|
+
// userId: loginUser.UserId
|
|
486
|
+
await activity.create(loginUser.ObjectId, dbTransaction);
|
|
487
|
+
}
|
|
488
|
+
} catch (error) {
|
|
489
|
+
throw error;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
399
492
|
}
|
|
@@ -120,7 +120,7 @@ export class JointHirer extends ObjectBase {
|
|
|
120
120
|
//Part 4: Record Create JointHirer Activity
|
|
121
121
|
const activity = new Activity();
|
|
122
122
|
activity.ObjectId = this._createId();
|
|
123
|
-
activity.Action = ActionEnum.
|
|
123
|
+
activity.Action = ActionEnum.CREATE;
|
|
124
124
|
activity.Description = 'Add Joint Hirer';
|
|
125
125
|
activity.EntityId = this.ObjectId;
|
|
126
126
|
activity.EntityType = this.ObjectType;
|
|
@@ -247,7 +247,7 @@ export class Rental extends ObjectBase {
|
|
|
247
247
|
/*Part 5: Record Create Rental Activity*/
|
|
248
248
|
const activity = new Activity();
|
|
249
249
|
activity.ActivityId = activity.createId();
|
|
250
|
-
activity.Action = ActionEnum.
|
|
250
|
+
activity.Action = ActionEnum.CREATE;
|
|
251
251
|
activity.Description = 'Add Rental';
|
|
252
252
|
activity.EntityType = 'Rental';
|
|
253
253
|
activity.EntityId = this.RentalId;
|
|
@@ -302,9 +302,8 @@ export class Rental extends ObjectBase {
|
|
|
302
302
|
search?: IRentalFindAllSearchAttr,
|
|
303
303
|
) {
|
|
304
304
|
try {
|
|
305
|
-
const systemCode =
|
|
306
|
-
'system-code'
|
|
307
|
-
);
|
|
305
|
+
const systemCode =
|
|
306
|
+
await ApplicationConfig.getComponentConfigValue('system-code');
|
|
308
307
|
|
|
309
308
|
const isPrivileged = await loginUser.checkPrivileges(
|
|
310
309
|
systemCode,
|
|
@@ -399,9 +398,8 @@ export class Rental extends ObjectBase {
|
|
|
399
398
|
dbTransaction?: any,
|
|
400
399
|
) {
|
|
401
400
|
try {
|
|
402
|
-
const systemCode =
|
|
403
|
-
'system-code'
|
|
404
|
-
);
|
|
401
|
+
const systemCode =
|
|
402
|
+
await ApplicationConfig.getComponentConfigValue('system-code');
|
|
405
403
|
|
|
406
404
|
const isPrivileged = await loginUser.checkPrivileges(
|
|
407
405
|
systemCode,
|
|
@@ -484,9 +482,8 @@ export class Rental extends ObjectBase {
|
|
|
484
482
|
) {
|
|
485
483
|
try {
|
|
486
484
|
// Privilege Checking
|
|
487
|
-
const systemCode =
|
|
488
|
-
'system-code'
|
|
489
|
-
);
|
|
485
|
+
const systemCode =
|
|
486
|
+
await ApplicationConfig.getComponentConfigValue('system-code');
|
|
490
487
|
|
|
491
488
|
const isPrivileged = await loginUser.checkPrivileges(
|
|
492
489
|
systemCode,
|
package/.eslintignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
dist
|