@tomei/rental 0.16.1 → 0.16.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.
Files changed (65) hide show
  1. package/.commitlintrc.json +22 -22
  2. package/.gitlab-ci.yml +16 -16
  3. package/.husky/commit-msg +15 -15
  4. package/.husky/pre-commit +7 -7
  5. package/.prettierrc +4 -4
  6. package/Jenkinsfile +51 -51
  7. package/README.md +8 -8
  8. package/dist/src/components/agreement/agreement.js +8 -8
  9. package/dist/src/components/agreement/agreement.js.map +1 -1
  10. package/dist/src/components/rental/rental.js +15 -15
  11. package/dist/tsconfig.tsbuildinfo +1 -1
  12. package/eslint.config.mjs +58 -58
  13. package/jest.config.js +10 -10
  14. package/migrations/booking-table-migration.js +79 -79
  15. package/migrations/hirer-signature-table-migration.js +64 -64
  16. package/migrations/joint-hirer-table-migration.js +52 -52
  17. package/migrations/rental-aggreement-history-migration.js +41 -41
  18. package/migrations/rental-aggrement-table-migration.js +30 -30
  19. package/migrations/rental-price-table-migration.js +32 -32
  20. package/migrations/rental-table-migrations.js +96 -96
  21. package/package.json +75 -75
  22. package/sonar-project.properties +12 -12
  23. package/src/components/agreement/agreement.repository.ts +54 -54
  24. package/src/components/agreement/agreement.ts +180 -180
  25. package/src/components/agreement-history/agreement-history.repository.ts +54 -54
  26. package/src/components/agreement-history/agreement-history.ts +57 -57
  27. package/src/components/booking/booking.repository.ts +51 -51
  28. package/src/components/booking/booking.ts +492 -492
  29. package/src/components/hirer-signature/hirer-signature.repository.ts +54 -54
  30. package/src/components/hirer-signature/hirer-signature.ts +140 -140
  31. package/src/components/joint-hirer/joint-hirer.repository.ts +54 -54
  32. package/src/components/joint-hirer/joint-hirer.ts +137 -137
  33. package/src/components/rental/rental.repository.ts +51 -51
  34. package/src/components/rental/rental.ts +1116 -1116
  35. package/src/components/rental-price/rental-price.repository.ts +54 -54
  36. package/src/components/rental-price/rental-price.ts +100 -100
  37. package/src/database.ts +31 -31
  38. package/src/enum/account-type.enum.ts +4 -4
  39. package/src/enum/booking.enum.ts +5 -5
  40. package/src/enum/hirer-signature-status.enum.ts +4 -4
  41. package/src/enum/hirer-type.enum.ts +4 -4
  42. package/src/enum/index.ts +15 -15
  43. package/src/enum/rental-status.enum.ts +39 -39
  44. package/src/index.ts +36 -36
  45. package/src/interfaces/agreement-attr.interface.ts +7 -7
  46. package/src/interfaces/agreement-history-attr.interface.ts +7 -7
  47. package/src/interfaces/booking-attr.interface.ts +19 -19
  48. package/src/interfaces/booking-find-all-search-attr.interface.ts +12 -12
  49. package/src/interfaces/hirer-signature-attr.interface.ts +15 -15
  50. package/src/interfaces/index.ts +19 -19
  51. package/src/interfaces/joint-hirer-attr.interface.ts +10 -10
  52. package/src/interfaces/rental-attr.interface.ts +25 -25
  53. package/src/interfaces/rental-find-all-search-attr.interface.ts +11 -11
  54. package/src/interfaces/rental-price-attr.interface.ts +7 -7
  55. package/src/interfaces/response-hirer-signature-attr.interface.ts +15 -15
  56. package/src/models/agreement-history.entity.ts +51 -51
  57. package/src/models/agreement.entity.ts +47 -47
  58. package/src/models/booking.entity.ts +105 -105
  59. package/src/models/hirer-signature.entity.ts +81 -81
  60. package/src/models/index.ts +17 -17
  61. package/src/models/joint-hirer.entity.ts +63 -63
  62. package/src/models/rental-price.entity.ts +38 -38
  63. package/src/models/rental.entity.ts +133 -133
  64. package/tsconfig.build.json +5 -5
  65. package/tsconfig.json +24 -24
@@ -1,180 +1,180 @@
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, where } from 'sequelize';
10
- import { IResponseHirerSignature } from '../../interfaces/response-hirer-signature-attr.interface';
11
- import { AgreementHistoryRepository } from '../agreement-history/agreement-history.repository';
12
- import { IAgreementHistoryAttr } from 'interfaces/agreement-history-attr.interface';
13
- import { ActionEnum, Activity } from '@tomei/activity-history';
14
-
15
- export class Agreement extends ObjectBase {
16
- ObjectId: string;
17
- ObjectName: string;
18
- ObjectType: string = 'Agreement';
19
- TableName = 'rental_Agreement';
20
- Status: AggrementStatusEnum;
21
- DateSigned: Date;
22
- MediaId: string;
23
-
24
- private static _Repo = new AgreementRepository();
25
- protected static _HirerSignatureRepo = new HirerSignatureRepository();
26
- protected static _AgreementHistoryRepo = new AgreementHistoryRepository();
27
-
28
- get AgreementNo(): string {
29
- return this.ObjectId;
30
- }
31
-
32
- set AgreementNo(value: string) {
33
- this.ObjectId = value;
34
- }
35
-
36
- protected constructor(agreementAttr?: IAgreementAttr) {
37
- super();
38
- if (agreementAttr) {
39
- this.ObjectId = agreementAttr.AgreementNo;
40
- this.Status = agreementAttr.Status;
41
- this.DateSigned = agreementAttr.DateSigned;
42
- this.MediaId = agreementAttr.MediaId;
43
- }
44
- }
45
-
46
- public static async init(
47
- agreementNo?: string,
48
- dbTransaction?: any,
49
- ): Promise<Agreement> {
50
- try {
51
- if (agreementNo) {
52
- const agreement = await this._Repo.findByPk(agreementNo, dbTransaction);
53
- return new Agreement(agreement?.get({ plain: true }));
54
- }
55
- return new Agreement();
56
- } catch (error) {
57
- throw error;
58
- }
59
- }
60
-
61
- public static async getSignatureList(
62
- loginUser: LoginUser,
63
- agreementNo: string,
64
- dbTransaction: any,
65
- ) {
66
- try {
67
- // Part 1: Privilege Checking
68
- // Call loginUser.checkPrivileges() by passing:
69
- // SystemCode: "<get_from_app_config>"
70
- // PrivilegeCode: "AGREEMENT_SIGNATURE_LIST"
71
- const systemCode =
72
- ApplicationConfig.getComponentConfigValue('system-code');
73
- const isPrivileged = loginUser.checkPrivileges(
74
- systemCode,
75
- 'AGREEMENT_SIGNATURE_LIST',
76
- );
77
-
78
- if (!isPrivileged) {
79
- throw new ClassError(
80
- 'Agreement',
81
- 'AgreementErrMsg01',
82
- "You do not have 'AGREEMENT_SIGNATURE_LIST' privilege.",
83
- );
84
- }
85
-
86
- // Part 2: Validation
87
- // Make sure agreementNo exists, if not throw new ClassError by passing:
88
- if (!agreementNo) {
89
- throw new ClassError(
90
- 'AgreementNo',
91
- 'AgreementNoErrMsg01',
92
- 'AgreementNo is missing',
93
- );
94
- }
95
-
96
- // Part 3: Retrieve Listing
97
- const query = `
98
- SELECT
99
- hs.*,
100
- FROM
101
- rental_HirerSignature hs
102
- WHERE
103
- hs.AgreementNo = '${agreementNo}'
104
- `;
105
-
106
- const db = rentalDb.getConnection();
107
-
108
- const signatures: IResponseHirerSignature[] = await db.query(query, {
109
- type: QueryTypes.SELECT,
110
- transaction: dbTransaction,
111
- });
112
-
113
- return signatures;
114
- } catch (error) {
115
- throw error;
116
- }
117
- }
118
-
119
- async getAllActivities(
120
- loginUser: LoginUser,
121
- dbTransaction?: any,
122
- ): Promise<IAgreementHistoryAttr[]> {
123
- try {
124
- const systemCode =
125
- ApplicationConfig.getComponentConfigValue('system-code');
126
- const isPrivileged = loginUser.checkPrivileges(
127
- systemCode,
128
- 'RENTAL_AGREEMENT_VIEW',
129
- );
130
-
131
- if (!isPrivileged) {
132
- throw new ClassError(
133
- 'Agreement',
134
- 'AgreementErrMsg02',
135
- "You do not have 'RENTAL_AGREEMENT_VIEW' privilege.",
136
- );
137
- }
138
-
139
- const activities = await Agreement._AgreementHistoryRepo.findAll({
140
- where: { AgreementNo: this.ObjectId },
141
- order: [['Date', 'DESC']],
142
- transaction: dbTransaction,
143
- });
144
- return activities;
145
- } catch (error) {
146
- throw error;
147
- }
148
- }
149
-
150
- async createActivity(
151
- activityCompleted: string,
152
- MediaId: string,
153
- dbTransaction: any,
154
- loginUser: LoginUser,
155
- ): Promise<IAgreementHistoryAttr> {
156
- try {
157
- const activity = await Agreement._AgreementHistoryRepo.create({
158
- AgreementNo: this.ObjectId,
159
- MediaId: MediaId,
160
- ActivityCompleted: activityCompleted,
161
- CreatedAt: new Date(),
162
- });
163
-
164
- const entityValueAfter = activity.get({ plain: true });
165
- const activityHistory = new Activity();
166
- activityHistory.ActivityId = entityValueAfter.HistoryId;
167
- activityHistory.Action = ActionEnum.CREATE;
168
- activityHistory.Description = activityCompleted;
169
- activityHistory.EntityId = activity.HistoryId.toString();
170
- activityHistory.EntityType = 'RentalAgreementHistory';
171
- activityHistory.EntityValueBefore = JSON.stringify({});
172
- activityHistory.EntityValueAfter = JSON.stringify(entityValueAfter);
173
- await activityHistory.create(loginUser.ObjectId, dbTransaction);
174
-
175
- return activity;
176
- } catch (error) {
177
- throw error;
178
- }
179
- }
180
- }
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, where } from 'sequelize';
10
+ import { IResponseHirerSignature } from '../../interfaces/response-hirer-signature-attr.interface';
11
+ import { AgreementHistoryRepository } from '../agreement-history/agreement-history.repository';
12
+ import { IAgreementHistoryAttr } from 'interfaces/agreement-history-attr.interface';
13
+ import { ActionEnum, Activity } from '@tomei/activity-history';
14
+
15
+ export class Agreement extends ObjectBase {
16
+ ObjectId: string;
17
+ ObjectName: string;
18
+ ObjectType: string = 'Agreement';
19
+ TableName = 'rental_Agreement';
20
+ Status: AggrementStatusEnum;
21
+ DateSigned: Date;
22
+ MediaId: string;
23
+
24
+ private static _Repo = new AgreementRepository();
25
+ protected static _HirerSignatureRepo = new HirerSignatureRepository();
26
+ protected static _AgreementHistoryRepo = new AgreementHistoryRepository();
27
+
28
+ get AgreementNo(): string {
29
+ return this.ObjectId;
30
+ }
31
+
32
+ set AgreementNo(value: string) {
33
+ this.ObjectId = value;
34
+ }
35
+
36
+ protected constructor(agreementAttr?: IAgreementAttr) {
37
+ super();
38
+ if (agreementAttr) {
39
+ this.ObjectId = agreementAttr.AgreementNo;
40
+ this.Status = agreementAttr.Status;
41
+ this.DateSigned = agreementAttr.DateSigned;
42
+ this.MediaId = agreementAttr.MediaId;
43
+ }
44
+ }
45
+
46
+ public static async init(
47
+ agreementNo?: string,
48
+ dbTransaction?: any,
49
+ ): Promise<Agreement> {
50
+ try {
51
+ if (agreementNo) {
52
+ const agreement = await this._Repo.findByPk(agreementNo, dbTransaction);
53
+ return new Agreement(agreement?.get({ plain: true }));
54
+ }
55
+ return new Agreement();
56
+ } catch (error) {
57
+ throw error;
58
+ }
59
+ }
60
+
61
+ public static async getSignatureList(
62
+ loginUser: LoginUser,
63
+ agreementNo: string,
64
+ dbTransaction: any,
65
+ ) {
66
+ try {
67
+ // Part 1: Privilege Checking
68
+ // Call loginUser.checkPrivileges() by passing:
69
+ // SystemCode: "<get_from_app_config>"
70
+ // PrivilegeCode: "AGREEMENT_SIGNATURE_LIST"
71
+ const systemCode =
72
+ ApplicationConfig.getComponentConfigValue('system-code');
73
+ const isPrivileged = loginUser.checkPrivileges(
74
+ systemCode,
75
+ 'AGREEMENT_SIGNATURE_LIST',
76
+ );
77
+
78
+ if (!isPrivileged) {
79
+ throw new ClassError(
80
+ 'Agreement',
81
+ 'AgreementErrMsg01',
82
+ "You do not have 'AGREEMENT_SIGNATURE_LIST' privilege.",
83
+ );
84
+ }
85
+
86
+ // Part 2: Validation
87
+ // Make sure agreementNo exists, if not throw new ClassError by passing:
88
+ if (!agreementNo) {
89
+ throw new ClassError(
90
+ 'AgreementNo',
91
+ 'AgreementNoErrMsg01',
92
+ 'AgreementNo is missing',
93
+ );
94
+ }
95
+
96
+ // Part 3: Retrieve Listing
97
+ const query = `
98
+ SELECT
99
+ hs.*
100
+ FROM
101
+ rental_HirerSignature hs
102
+ WHERE
103
+ hs.AgreementNo = '${agreementNo}'
104
+ `;
105
+
106
+ const db = rentalDb.getConnection();
107
+
108
+ const signatures: IResponseHirerSignature[] = await db.query(query, {
109
+ type: QueryTypes.SELECT,
110
+ transaction: dbTransaction,
111
+ });
112
+
113
+ return signatures;
114
+ } catch (error) {
115
+ throw error;
116
+ }
117
+ }
118
+
119
+ async getAllActivities(
120
+ loginUser: LoginUser,
121
+ dbTransaction?: any,
122
+ ): Promise<IAgreementHistoryAttr[]> {
123
+ try {
124
+ const systemCode =
125
+ ApplicationConfig.getComponentConfigValue('system-code');
126
+ const isPrivileged = loginUser.checkPrivileges(
127
+ systemCode,
128
+ 'RENTAL_AGREEMENT_VIEW',
129
+ );
130
+
131
+ if (!isPrivileged) {
132
+ throw new ClassError(
133
+ 'Agreement',
134
+ 'AgreementErrMsg02',
135
+ "You do not have 'RENTAL_AGREEMENT_VIEW' privilege.",
136
+ );
137
+ }
138
+
139
+ const activities = await Agreement._AgreementHistoryRepo.findAll({
140
+ where: { AgreementNo: this.ObjectId },
141
+ order: [['CreatedAt', 'DESC']],
142
+ transaction: dbTransaction,
143
+ });
144
+ return activities;
145
+ } catch (error) {
146
+ throw error;
147
+ }
148
+ }
149
+
150
+ async createActivity(
151
+ activityCompleted: string,
152
+ MediaId: string,
153
+ dbTransaction: any,
154
+ loginUser: LoginUser,
155
+ ): Promise<IAgreementHistoryAttr> {
156
+ try {
157
+ const activity = await Agreement._AgreementHistoryRepo.create({
158
+ AgreementNo: this.ObjectId,
159
+ MediaId: MediaId,
160
+ ActivityCompleted: activityCompleted,
161
+ CreatedAt: new Date(),
162
+ });
163
+
164
+ const entityValueAfter = activity.get({ plain: true });
165
+ const activityHistory = new Activity();
166
+ activityHistory.ActivityId = entityValueAfter.HistoryId;
167
+ activityHistory.Action = ActionEnum.CREATE;
168
+ activityHistory.Description = activityCompleted;
169
+ activityHistory.EntityId = activity.HistoryId.toString();
170
+ activityHistory.EntityType = 'RentalAgreementHistory';
171
+ activityHistory.EntityValueBefore = JSON.stringify({});
172
+ activityHistory.EntityValueAfter = JSON.stringify(entityValueAfter);
173
+ await activityHistory.create(loginUser.ObjectId, dbTransaction);
174
+
175
+ return activity;
176
+ } catch (error) {
177
+ throw error;
178
+ }
179
+ }
180
+ }
@@ -1,54 +1,54 @@
1
- import { RepositoryBase, IRepositoryBase } from '@tomei/general';
2
- import { AgreementHistoryModel } from '../../models/agreement-history.entity';
3
-
4
- export class AgreementHistoryRepository
5
- extends RepositoryBase<AgreementHistoryModel>
6
- implements IRepositoryBase<AgreementHistoryModel>
7
- {
8
- constructor() {
9
- super(AgreementHistoryModel);
10
- }
11
-
12
- async findByPk(
13
- id: string,
14
- transaction?: any,
15
- ): Promise<AgreementHistoryModel | null> {
16
- try {
17
- const result = await AgreementHistoryModel.findByPk(parseInt(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(AgreementNo: string, dbTransaction?: any) {
28
- try {
29
- const options = {
30
- where: {
31
- AgreementNo,
32
- },
33
- transaction: dbTransaction,
34
- };
35
- await AgreementHistoryModel.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 Agreements: any;
44
- if (options) {
45
- Agreements = await AgreementHistoryModel.findAndCountAll(options);
46
- } else {
47
- Agreements = await AgreementHistoryModel.findAndCountAll();
48
- }
49
- return Agreements;
50
- } catch (error) {
51
- throw new Error(`An Error occured when retriving : ${error.message}`);
52
- }
53
- }
54
- }
1
+ import { RepositoryBase, IRepositoryBase } from '@tomei/general';
2
+ import { AgreementHistoryModel } from '../../models/agreement-history.entity';
3
+
4
+ export class AgreementHistoryRepository
5
+ extends RepositoryBase<AgreementHistoryModel>
6
+ implements IRepositoryBase<AgreementHistoryModel>
7
+ {
8
+ constructor() {
9
+ super(AgreementHistoryModel);
10
+ }
11
+
12
+ async findByPk(
13
+ id: string,
14
+ transaction?: any,
15
+ ): Promise<AgreementHistoryModel | null> {
16
+ try {
17
+ const result = await AgreementHistoryModel.findByPk(parseInt(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(AgreementNo: string, dbTransaction?: any) {
28
+ try {
29
+ const options = {
30
+ where: {
31
+ AgreementNo,
32
+ },
33
+ transaction: dbTransaction,
34
+ };
35
+ await AgreementHistoryModel.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 Agreements: any;
44
+ if (options) {
45
+ Agreements = await AgreementHistoryModel.findAndCountAll(options);
46
+ } else {
47
+ Agreements = await AgreementHistoryModel.findAndCountAll();
48
+ }
49
+ return Agreements;
50
+ } catch (error) {
51
+ throw new Error(`An Error occured when retriving : ${error.message}`);
52
+ }
53
+ }
54
+ }
@@ -1,57 +1,57 @@
1
- import { ObjectBase } from '@tomei/general';
2
- import { AgreementHistoryRepository } from './agreement-history.repository';
3
- import { AggrementStatusEnum } from '../../enum/aggrement-status.enum';
4
- import { IAgreementHistoryAttr } from '../../interfaces/agreement-history-attr.interface';
5
-
6
- export class AgreementHistory
7
- extends ObjectBase
8
- implements IAgreementHistoryAttr
9
- {
10
- ObjectId: string;
11
- ObjectName: string;
12
- ObjectType: string = 'AgreementHistory';
13
- TableName = 'rental_AgreementHistory';
14
- AgreementNo: string;
15
- ActivityCompleted: string;
16
- MediaId: string;
17
- CreatedAt: Date;
18
-
19
- private static _Repo = new AgreementHistoryRepository();
20
-
21
- get HistoryId(): number {
22
- return parseInt(this.ObjectId);
23
- }
24
-
25
- set HistoryId(value: number) {
26
- this.ObjectId = value.toString();
27
- }
28
-
29
- protected constructor(agreementAttr?: IAgreementHistoryAttr) {
30
- super();
31
- if (agreementAttr) {
32
- this.HistoryId = agreementAttr.HistoryId;
33
- this.AgreementNo = agreementAttr.AgreementNo;
34
- this.ActivityCompleted = agreementAttr.ActivityCompleted;
35
- this.MediaId = agreementAttr.MediaId;
36
- this.CreatedAt = agreementAttr.CreatedAt;
37
- }
38
- }
39
-
40
- public static async init(
41
- historyId: number,
42
- dbTransaction?: any,
43
- ): Promise<AgreementHistory> {
44
- try {
45
- if (historyId) {
46
- const ah = await this._Repo.findByPk(
47
- historyId.toString(),
48
- dbTransaction,
49
- );
50
- return new AgreementHistory(ah?.get({ plain: true }));
51
- }
52
- return new AgreementHistory();
53
- } catch (error) {
54
- throw error;
55
- }
56
- }
57
- }
1
+ import { ObjectBase } from '@tomei/general';
2
+ import { AgreementHistoryRepository } from './agreement-history.repository';
3
+ import { AggrementStatusEnum } from '../../enum/aggrement-status.enum';
4
+ import { IAgreementHistoryAttr } from '../../interfaces/agreement-history-attr.interface';
5
+
6
+ export class AgreementHistory
7
+ extends ObjectBase
8
+ implements IAgreementHistoryAttr
9
+ {
10
+ ObjectId: string;
11
+ ObjectName: string;
12
+ ObjectType: string = 'AgreementHistory';
13
+ TableName = 'rental_AgreementHistory';
14
+ AgreementNo: string;
15
+ ActivityCompleted: string;
16
+ MediaId: string;
17
+ CreatedAt: Date;
18
+
19
+ private static _Repo = new AgreementHistoryRepository();
20
+
21
+ get HistoryId(): number {
22
+ return parseInt(this.ObjectId);
23
+ }
24
+
25
+ set HistoryId(value: number) {
26
+ this.ObjectId = value.toString();
27
+ }
28
+
29
+ protected constructor(agreementAttr?: IAgreementHistoryAttr) {
30
+ super();
31
+ if (agreementAttr) {
32
+ this.HistoryId = agreementAttr.HistoryId;
33
+ this.AgreementNo = agreementAttr.AgreementNo;
34
+ this.ActivityCompleted = agreementAttr.ActivityCompleted;
35
+ this.MediaId = agreementAttr.MediaId;
36
+ this.CreatedAt = agreementAttr.CreatedAt;
37
+ }
38
+ }
39
+
40
+ public static async init(
41
+ historyId: number,
42
+ dbTransaction?: any,
43
+ ): Promise<AgreementHistory> {
44
+ try {
45
+ if (historyId) {
46
+ const ah = await this._Repo.findByPk(
47
+ historyId.toString(),
48
+ dbTransaction,
49
+ );
50
+ return new AgreementHistory(ah?.get({ plain: true }));
51
+ }
52
+ return new AgreementHistory();
53
+ } catch (error) {
54
+ throw error;
55
+ }
56
+ }
57
+ }