@tomei/rental 0.12.0 → 0.12.3
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/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 +1 -1
- package/src/components/joint-hirer/joint-hirer.ts +137 -137
- package/src/components/rental/rental.ts +7 -10
- package/.eslintignore +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -18
- package/dist/index.js.map +0 -1
- package/dist/src/components/agreement/agreement.d.ts +0 -17
- package/dist/src/components/agreement/agreement.js +0 -50
- package/dist/src/components/agreement/agreement.js.map +0 -1
- package/dist/src/components/agreement/agreement.repository.d.ts +0 -8
- package/dist/src/components/agreement/agreement.repository.js +0 -67
- package/dist/src/components/agreement/agreement.repository.js.map +0 -1
- package/dist/src/components/booking/booking.d.ts +0 -46
- package/dist/src/components/booking/booking.js +0 -314
- package/dist/src/components/booking/booking.js.map +0 -1
- package/dist/src/components/booking/booking.repository.d.ts +0 -8
- package/dist/src/components/booking/booking.repository.js +0 -67
- package/dist/src/components/booking/booking.repository.js.map +0 -1
- package/dist/src/components/joint-hirer/joint-hirer.d.ts +0 -23
- package/dist/src/components/joint-hirer/joint-hirer.js +0 -106
- package/dist/src/components/joint-hirer/joint-hirer.js.map +0 -1
- package/dist/src/components/joint-hirer/joint-hirer.repository.d.ts +0 -8
- package/dist/src/components/joint-hirer/joint-hirer.repository.js +0 -67
- package/dist/src/components/joint-hirer/joint-hirer.repository.js.map +0 -1
- package/dist/src/components/rental/rental.d.ts +0 -59
- package/dist/src/components/rental/rental.js +0 -619
- package/dist/src/components/rental/rental.js.map +0 -1
- package/dist/src/components/rental/rental.repository.d.ts +0 -8
- package/dist/src/components/rental/rental.repository.js +0 -67
- package/dist/src/components/rental/rental.repository.js.map +0 -1
- package/dist/src/components/rental-price/rental-price.d.ts +0 -18
- package/dist/src/components/rental-price/rental-price.js +0 -79
- package/dist/src/components/rental-price/rental-price.js.map +0 -1
- package/dist/src/components/rental-price/rental-price.repository.d.ts +0 -8
- package/dist/src/components/rental-price/rental-price.repository.js +0 -67
- package/dist/src/components/rental-price/rental-price.repository.js.map +0 -1
- package/dist/src/database.d.ts +0 -4
- package/dist/src/database.js +0 -26
- package/dist/src/database.js.map +0 -1
- package/dist/src/enum/account-type.enum.d.ts +0 -4
- package/dist/src/enum/account-type.enum.js +0 -9
- package/dist/src/enum/account-type.enum.js.map +0 -1
- package/dist/src/enum/aggrement-status.enum.d.ts +0 -5
- package/dist/src/enum/aggrement-status.enum.js +0 -10
- package/dist/src/enum/aggrement-status.enum.js.map +0 -1
- package/dist/src/enum/booking.enum.d.ts +0 -5
- package/dist/src/enum/booking.enum.js +0 -10
- package/dist/src/enum/booking.enum.js.map +0 -1
- package/dist/src/enum/index.d.ts +0 -5
- package/dist/src/enum/index.js +0 -12
- package/dist/src/enum/index.js.map +0 -1
- package/dist/src/enum/rental-status.enum.d.ts +0 -9
- package/dist/src/enum/rental-status.enum.js +0 -14
- package/dist/src/enum/rental-status.enum.js.map +0 -1
- package/dist/src/index.d.ts +0 -15
- package/dist/src/index.js +0 -43
- package/dist/src/index.js.map +0 -1
- package/dist/src/interfaces/agreement-attr.interface.d.ts +0 -7
- package/dist/src/interfaces/agreement-attr.interface.js +0 -3
- package/dist/src/interfaces/agreement-attr.interface.js.map +0 -1
- package/dist/src/interfaces/booking-attr.interface.d.ts +0 -18
- package/dist/src/interfaces/booking-attr.interface.js +0 -3
- package/dist/src/interfaces/booking-attr.interface.js.map +0 -1
- package/dist/src/interfaces/booking-find-all-search-attr.interface.d.ts +0 -12
- package/dist/src/interfaces/booking-find-all-search-attr.interface.js +0 -3
- package/dist/src/interfaces/booking-find-all-search-attr.interface.js.map +0 -1
- package/dist/src/interfaces/index.d.ts +0 -7
- package/dist/src/interfaces/index.js +0 -3
- package/dist/src/interfaces/index.js.map +0 -1
- package/dist/src/interfaces/joint-hirer-attr.interface.d.ts +0 -10
- package/dist/src/interfaces/joint-hirer-attr.interface.js +0 -3
- package/dist/src/interfaces/joint-hirer-attr.interface.js.map +0 -1
- package/dist/src/interfaces/rental-attr.interface.d.ts +0 -24
- package/dist/src/interfaces/rental-attr.interface.js +0 -3
- package/dist/src/interfaces/rental-attr.interface.js.map +0 -1
- package/dist/src/interfaces/rental-find-all-search-attr.interface.d.ts +0 -10
- package/dist/src/interfaces/rental-find-all-search-attr.interface.js +0 -3
- package/dist/src/interfaces/rental-find-all-search-attr.interface.js.map +0 -1
- package/dist/src/interfaces/rental-price-attr.interface.d.ts +0 -7
- package/dist/src/interfaces/rental-price-attr.interface.js +0 -3
- package/dist/src/interfaces/rental-price-attr.interface.js.map +0 -1
- package/dist/src/models/agreement.entity.d.ts +0 -10
- package/dist/src/models/agreement.entity.js +0 -60
- package/dist/src/models/agreement.entity.js.map +0 -1
- package/dist/src/models/booking.entity.d.ts +0 -21
- package/dist/src/models/booking.entity.js +0 -128
- package/dist/src/models/booking.entity.js.map +0 -1
- package/dist/src/models/index.d.ts +0 -6
- package/dist/src/models/index.js +0 -14
- package/dist/src/models/index.js.map +0 -1
- package/dist/src/models/joint-hirer.entity.d.ts +0 -13
- package/dist/src/models/joint-hirer.entity.js +0 -79
- package/dist/src/models/joint-hirer.entity.js.map +0 -1
- package/dist/src/models/rental-price.entity.d.ts +0 -8
- package/dist/src/models/rental-price.entity.js +0 -59
- package/dist/src/models/rental-price.entity.js.map +0 -1
- package/dist/src/models/rental.entity.d.ts +0 -29
- package/dist/src/models/rental.entity.js +0 -160
- package/dist/src/models/rental.entity.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +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.12.
|
|
3
|
+
"version": "0.12.3",
|
|
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.22",
|
|
61
|
+
"@tomei/config": "^0.3.20",
|
|
62
|
+
"@tomei/general": "^0.21.2",
|
|
63
|
+
"@tomei/sso": "^0.51.5",
|
|
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;
|
|
@@ -1,137 +1,137 @@
|
|
|
1
|
-
import { ClassError, ObjectBase } from '@tomei/general';
|
|
2
|
-
import { JointHirerRepository } from './joint-hirer.repository';
|
|
3
|
-
import { IJointHirerAttr } from '../../interfaces/joint-hirer-attr.interface';
|
|
4
|
-
import { ApplicationConfig } from '@tomei/config';
|
|
5
|
-
import { LoginUser } from '@tomei/sso';
|
|
6
|
-
import { ActionEnum, Activity } from '@tomei/activity-history';
|
|
7
|
-
|
|
8
|
-
export class JointHirer extends ObjectBase {
|
|
9
|
-
ObjectId: string;
|
|
10
|
-
ObjectName: string;
|
|
11
|
-
ObjectType: string = 'JointHirer';
|
|
12
|
-
TableName: string = 'rental_JointHirer';
|
|
13
|
-
RentalId: string;
|
|
14
|
-
CustomerId: string;
|
|
15
|
-
CustomerType: string;
|
|
16
|
-
CreatedById: string;
|
|
17
|
-
CreatedAt: Date;
|
|
18
|
-
UpdatedById: string;
|
|
19
|
-
UpdatedAt: Date;
|
|
20
|
-
|
|
21
|
-
get HirerId(): string {
|
|
22
|
-
return this.ObjectId;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
set HirerId(value: string) {
|
|
26
|
-
this.ObjectId = value;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
protected static _Repository = new JointHirerRepository();
|
|
30
|
-
|
|
31
|
-
protected constructor(jointHirerAttr?: IJointHirerAttr) {
|
|
32
|
-
super();
|
|
33
|
-
if (jointHirerAttr) {
|
|
34
|
-
this.HirerId = jointHirerAttr.HirerId;
|
|
35
|
-
this.RentalId = jointHirerAttr.RentalId;
|
|
36
|
-
this.CustomerId = jointHirerAttr.CustomerId;
|
|
37
|
-
this.CustomerType = jointHirerAttr.CustomerType;
|
|
38
|
-
this.CreatedById = jointHirerAttr.CreatedById;
|
|
39
|
-
this.CreatedAt = jointHirerAttr.CreatedAt;
|
|
40
|
-
this.UpdatedById = jointHirerAttr.UpdatedById;
|
|
41
|
-
this.UpdatedAt = jointHirerAttr.UpdatedAt;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
public static async init(hirerId?: string, dbTransaction?: any) {
|
|
46
|
-
try {
|
|
47
|
-
if (hirerId) {
|
|
48
|
-
const jr = await JointHirer._Repository.findByPk(
|
|
49
|
-
hirerId,
|
|
50
|
-
dbTransaction,
|
|
51
|
-
);
|
|
52
|
-
if (jr) {
|
|
53
|
-
return new JointHirer(jr.get({ plain: true }));
|
|
54
|
-
} else {
|
|
55
|
-
throw new ClassError(
|
|
56
|
-
'JointHirer',
|
|
57
|
-
'JointHirerErrMsg01',
|
|
58
|
-
'JointHirer not found',
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return new JointHirer();
|
|
63
|
-
} catch (error) {
|
|
64
|
-
throw error;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
public async create(loginUser: LoginUser, dbTransaction?: any) {
|
|
69
|
-
//This method will create a new joint hirer record.
|
|
70
|
-
try {
|
|
71
|
-
//Part 1: Check Privilege
|
|
72
|
-
const systemCode =
|
|
73
|
-
ApplicationConfig.getComponentConfigValue('system-code');
|
|
74
|
-
const isPrivileged = await loginUser.checkPrivileges(
|
|
75
|
-
systemCode,
|
|
76
|
-
'JointHirer - Create',
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
if (!isPrivileged) {
|
|
80
|
-
throw new ClassError(
|
|
81
|
-
'JointHirer',
|
|
82
|
-
'JointHirerErrMsg00',
|
|
83
|
-
"You do not have 'JointHirer - Create' privilege.",
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
//Part 2: Insert Joint Hirer Record
|
|
88
|
-
//Check if this.RentalId, this.CustomerId, this.CustomerType have value otherwise throw new ClassError with below params
|
|
89
|
-
if (!this.RentalId || !this.CustomerId || !this.CustomerType) {
|
|
90
|
-
throw new ClassError(
|
|
91
|
-
'JointHirer',
|
|
92
|
-
'JointHirerErrMsg03',
|
|
93
|
-
'RentalId, CustomerId and CustomerType are required.',
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
//Set other attributes
|
|
98
|
-
this.ObjectId = this.createId();
|
|
99
|
-
this.CreatedById = loginUser.ObjectId;
|
|
100
|
-
this.CreatedAt = new Date();
|
|
101
|
-
this.UpdatedById = loginUser.ObjectId;
|
|
102
|
-
this.UpdatedAt = new Date();
|
|
103
|
-
|
|
104
|
-
const entityValueAfter: IJointHirerAttr = {
|
|
105
|
-
HirerId: this.HirerId,
|
|
106
|
-
RentalId: this.RentalId,
|
|
107
|
-
CustomerId: this.CustomerId,
|
|
108
|
-
CustomerType: this.CustomerType,
|
|
109
|
-
CreatedById: this.CreatedById,
|
|
110
|
-
CreatedAt: this.CreatedAt,
|
|
111
|
-
UpdatedById: this.UpdatedById,
|
|
112
|
-
UpdatedAt: this.UpdatedAt,
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
//Call repo class create method by passing the class attributes and db transaction.
|
|
116
|
-
await JointHirer._Repository.create(entityValueAfter, {
|
|
117
|
-
transaction: dbTransaction,
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
//Part 4: Record Create JointHirer Activity
|
|
121
|
-
const activity = new Activity();
|
|
122
|
-
activity.ObjectId = this._createId();
|
|
123
|
-
activity.Action = ActionEnum.
|
|
124
|
-
activity.Description = 'Add Joint Hirer';
|
|
125
|
-
activity.EntityId = this.ObjectId;
|
|
126
|
-
activity.EntityType = this.ObjectType;
|
|
127
|
-
activity.EntityValueBefore = JSON.stringify({});
|
|
128
|
-
activity.EntityValueAfter = JSON.stringify(entityValueAfter);
|
|
129
|
-
|
|
130
|
-
await activity.create(loginUser.ObjectId, dbTransaction);
|
|
131
|
-
|
|
132
|
-
return this;
|
|
133
|
-
} catch (error) {
|
|
134
|
-
throw error;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
1
|
+
import { ClassError, ObjectBase } from '@tomei/general';
|
|
2
|
+
import { JointHirerRepository } from './joint-hirer.repository';
|
|
3
|
+
import { IJointHirerAttr } from '../../interfaces/joint-hirer-attr.interface';
|
|
4
|
+
import { ApplicationConfig } from '@tomei/config';
|
|
5
|
+
import { LoginUser } from '@tomei/sso';
|
|
6
|
+
import { ActionEnum, Activity } from '@tomei/activity-history';
|
|
7
|
+
|
|
8
|
+
export class JointHirer extends ObjectBase {
|
|
9
|
+
ObjectId: string;
|
|
10
|
+
ObjectName: string;
|
|
11
|
+
ObjectType: string = 'JointHirer';
|
|
12
|
+
TableName: string = 'rental_JointHirer';
|
|
13
|
+
RentalId: string;
|
|
14
|
+
CustomerId: string;
|
|
15
|
+
CustomerType: string;
|
|
16
|
+
CreatedById: string;
|
|
17
|
+
CreatedAt: Date;
|
|
18
|
+
UpdatedById: string;
|
|
19
|
+
UpdatedAt: Date;
|
|
20
|
+
|
|
21
|
+
get HirerId(): string {
|
|
22
|
+
return this.ObjectId;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
set HirerId(value: string) {
|
|
26
|
+
this.ObjectId = value;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
protected static _Repository = new JointHirerRepository();
|
|
30
|
+
|
|
31
|
+
protected constructor(jointHirerAttr?: IJointHirerAttr) {
|
|
32
|
+
super();
|
|
33
|
+
if (jointHirerAttr) {
|
|
34
|
+
this.HirerId = jointHirerAttr.HirerId;
|
|
35
|
+
this.RentalId = jointHirerAttr.RentalId;
|
|
36
|
+
this.CustomerId = jointHirerAttr.CustomerId;
|
|
37
|
+
this.CustomerType = jointHirerAttr.CustomerType;
|
|
38
|
+
this.CreatedById = jointHirerAttr.CreatedById;
|
|
39
|
+
this.CreatedAt = jointHirerAttr.CreatedAt;
|
|
40
|
+
this.UpdatedById = jointHirerAttr.UpdatedById;
|
|
41
|
+
this.UpdatedAt = jointHirerAttr.UpdatedAt;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public static async init(hirerId?: string, dbTransaction?: any) {
|
|
46
|
+
try {
|
|
47
|
+
if (hirerId) {
|
|
48
|
+
const jr = await JointHirer._Repository.findByPk(
|
|
49
|
+
hirerId,
|
|
50
|
+
dbTransaction,
|
|
51
|
+
);
|
|
52
|
+
if (jr) {
|
|
53
|
+
return new JointHirer(jr.get({ plain: true }));
|
|
54
|
+
} else {
|
|
55
|
+
throw new ClassError(
|
|
56
|
+
'JointHirer',
|
|
57
|
+
'JointHirerErrMsg01',
|
|
58
|
+
'JointHirer not found',
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return new JointHirer();
|
|
63
|
+
} catch (error) {
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public async create(loginUser: LoginUser, dbTransaction?: any) {
|
|
69
|
+
//This method will create a new joint hirer record.
|
|
70
|
+
try {
|
|
71
|
+
//Part 1: Check Privilege
|
|
72
|
+
const systemCode =
|
|
73
|
+
ApplicationConfig.getComponentConfigValue('system-code');
|
|
74
|
+
const isPrivileged = await loginUser.checkPrivileges(
|
|
75
|
+
systemCode,
|
|
76
|
+
'JointHirer - Create',
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
if (!isPrivileged) {
|
|
80
|
+
throw new ClassError(
|
|
81
|
+
'JointHirer',
|
|
82
|
+
'JointHirerErrMsg00',
|
|
83
|
+
"You do not have 'JointHirer - Create' privilege.",
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
//Part 2: Insert Joint Hirer Record
|
|
88
|
+
//Check if this.RentalId, this.CustomerId, this.CustomerType have value otherwise throw new ClassError with below params
|
|
89
|
+
if (!this.RentalId || !this.CustomerId || !this.CustomerType) {
|
|
90
|
+
throw new ClassError(
|
|
91
|
+
'JointHirer',
|
|
92
|
+
'JointHirerErrMsg03',
|
|
93
|
+
'RentalId, CustomerId and CustomerType are required.',
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
//Set other attributes
|
|
98
|
+
this.ObjectId = this.createId();
|
|
99
|
+
this.CreatedById = loginUser.ObjectId;
|
|
100
|
+
this.CreatedAt = new Date();
|
|
101
|
+
this.UpdatedById = loginUser.ObjectId;
|
|
102
|
+
this.UpdatedAt = new Date();
|
|
103
|
+
|
|
104
|
+
const entityValueAfter: IJointHirerAttr = {
|
|
105
|
+
HirerId: this.HirerId,
|
|
106
|
+
RentalId: this.RentalId,
|
|
107
|
+
CustomerId: this.CustomerId,
|
|
108
|
+
CustomerType: this.CustomerType,
|
|
109
|
+
CreatedById: this.CreatedById,
|
|
110
|
+
CreatedAt: this.CreatedAt,
|
|
111
|
+
UpdatedById: this.UpdatedById,
|
|
112
|
+
UpdatedAt: this.UpdatedAt,
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
//Call repo class create method by passing the class attributes and db transaction.
|
|
116
|
+
await JointHirer._Repository.create(entityValueAfter, {
|
|
117
|
+
transaction: dbTransaction,
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
//Part 4: Record Create JointHirer Activity
|
|
121
|
+
const activity = new Activity();
|
|
122
|
+
activity.ObjectId = this._createId();
|
|
123
|
+
activity.Action = ActionEnum.CREATE;
|
|
124
|
+
activity.Description = 'Add Joint Hirer';
|
|
125
|
+
activity.EntityId = this.ObjectId;
|
|
126
|
+
activity.EntityType = this.ObjectType;
|
|
127
|
+
activity.EntityValueBefore = JSON.stringify({});
|
|
128
|
+
activity.EntityValueAfter = JSON.stringify(entityValueAfter);
|
|
129
|
+
|
|
130
|
+
await activity.create(loginUser.ObjectId, dbTransaction);
|
|
131
|
+
|
|
132
|
+
return this;
|
|
133
|
+
} catch (error) {
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -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
|
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './src';
|
package/dist/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./src"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAqB"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ObjectBase } from '@tomei/general';
|
|
2
|
-
import { IAgreementAttr } from '../../interfaces/agreement-attr.interface';
|
|
3
|
-
import { AggrementStatusEnum } from '../../enum/aggrement-status.enum';
|
|
4
|
-
export declare class Agreement extends ObjectBase {
|
|
5
|
-
ObjectId: string;
|
|
6
|
-
ObjectName: string;
|
|
7
|
-
ObjectType: string;
|
|
8
|
-
TableName: string;
|
|
9
|
-
Status: AggrementStatusEnum;
|
|
10
|
-
DateSigned: Date;
|
|
11
|
-
MediaId: string;
|
|
12
|
-
private static _Repo;
|
|
13
|
-
get AgreementNo(): string;
|
|
14
|
-
set AgreementNo(value: string);
|
|
15
|
-
protected constructor(agreementAttr?: IAgreementAttr);
|
|
16
|
-
static init(agreementNo?: string, dbTransaction?: any): Promise<Agreement>;
|
|
17
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Agreement = void 0;
|
|
13
|
-
const general_1 = require("@tomei/general");
|
|
14
|
-
const agreement_repository_1 = require("./agreement.repository");
|
|
15
|
-
class Agreement extends general_1.ObjectBase {
|
|
16
|
-
get AgreementNo() {
|
|
17
|
-
return this.ObjectId;
|
|
18
|
-
}
|
|
19
|
-
set AgreementNo(value) {
|
|
20
|
-
this.ObjectId = value;
|
|
21
|
-
}
|
|
22
|
-
constructor(agreementAttr) {
|
|
23
|
-
super();
|
|
24
|
-
this.ObjectType = 'Agreement';
|
|
25
|
-
this.TableName = 'rental_Agreement';
|
|
26
|
-
if (agreementAttr) {
|
|
27
|
-
this.ObjectId = agreementAttr.AgreementNo;
|
|
28
|
-
this.Status = agreementAttr.Status;
|
|
29
|
-
this.DateSigned = agreementAttr.DateSigned;
|
|
30
|
-
this.MediaId = agreementAttr.MediaId;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
static init(agreementNo, dbTransaction) {
|
|
34
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
try {
|
|
36
|
-
if (agreementNo) {
|
|
37
|
-
const agreement = yield this._Repo.findByPk(agreementNo, dbTransaction);
|
|
38
|
-
return new Agreement(agreement === null || agreement === void 0 ? void 0 : agreement.get({ plain: true }));
|
|
39
|
-
}
|
|
40
|
-
return new Agreement();
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
exports.Agreement = Agreement;
|
|
49
|
-
Agreement._Repo = new agreement_repository_1.AgreementRepository();
|
|
50
|
-
//# sourceMappingURL=agreement.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agreement.js","sourceRoot":"","sources":["../../../../src/components/agreement/agreement.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA4C;AAE5C,iEAA6D;AAG7D,MAAa,SAAU,SAAQ,oBAAU;IAWvC,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAI,WAAW,CAAC,KAAa;QAC3B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;IACxB,CAAC;IAED,YAAsB,aAA8B;QAClD,KAAK,EAAE,CAAC;QAjBV,eAAU,GAAW,WAAW,CAAC;QACjC,cAAS,GAAG,kBAAkB,CAAC;QAiB7B,IAAI,aAAa,EAAE;YACjB,IAAI,CAAC,QAAQ,GAAG,aAAa,CAAC,WAAW,CAAC;YAC1C,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;YACnC,IAAI,CAAC,UAAU,GAAG,aAAa,CAAC,UAAU,CAAC;YAC3C,IAAI,CAAC,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC;SACtC;IACH,CAAC;IAEM,MAAM,CAAO,IAAI,CACtB,WAAoB,EACpB,aAAmB;;YAEnB,IAAI;gBACF,IAAI,WAAW,EAAE;oBACf,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;oBACxE,OAAO,IAAI,SAAS,CAAC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;iBACvD;gBACD,OAAO,IAAI,SAAS,EAAE,CAAC;aACxB;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,KAAK,CAAC;aACb;QACH,CAAC;KAAA;;AA1CH,8BA2CC;AAlCgB,eAAK,GAAG,IAAI,0CAAmB,EAAE,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { RepositoryBase, IRepositoryBase } from '@tomei/general';
|
|
2
|
-
import { AgreementModel } from '../../models/agreement.entity';
|
|
3
|
-
export declare class AgreementRepository extends RepositoryBase<AgreementModel> implements IRepositoryBase<AgreementModel> {
|
|
4
|
-
constructor();
|
|
5
|
-
findByPk(id: string, transaction?: any): Promise<AgreementModel | null>;
|
|
6
|
-
delete(AgreementNo: string, dbTransaction?: any): Promise<void>;
|
|
7
|
-
findAndCountAll(options?: any): Promise<any>;
|
|
8
|
-
}
|