@tomei/rental 0.16.4 → 0.16.6

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 (71) hide show
  1. package/dist/src/components/agreement/agreement.d.ts +4 -4
  2. package/dist/src/components/agreement/agreement.js +3 -3
  3. package/dist/src/components/agreement/agreement.js.map +1 -1
  4. package/dist/src/components/agreement-signature/agreement-signature.d.ts +27 -0
  5. package/dist/src/components/agreement-signature/agreement-signature.js +112 -0
  6. package/dist/src/components/agreement-signature/agreement-signature.js.map +1 -0
  7. package/dist/src/components/agreement-signature/agreement-signature.repository.d.ts +8 -0
  8. package/dist/src/components/agreement-signature/agreement-signature.repository.js +68 -0
  9. package/dist/src/components/agreement-signature/agreement-signature.repository.js.map +1 -0
  10. package/dist/src/components/agreement-signature/hirer-signature.d.ts +27 -0
  11. package/dist/src/components/agreement-signature/hirer-signature.js +112 -0
  12. package/dist/src/components/agreement-signature/hirer-signature.js.map +1 -0
  13. package/dist/src/components/agreement-signature/hirer-signature.repository.d.ts +8 -0
  14. package/dist/src/components/agreement-signature/hirer-signature.repository.js +67 -0
  15. package/dist/src/components/agreement-signature/hirer-signature.repository.js.map +1 -0
  16. package/dist/src/components/hirer-signature/hirer-signature.d.ts +2 -2
  17. package/dist/src/components/hirer-signature/hirer-signature.repository.d.ts +1 -1
  18. package/dist/src/components/hirer-signature/hirer-signature.repository.js +6 -6
  19. package/dist/src/components/hirer-signature/hirer-signature.repository.js.map +1 -1
  20. package/dist/src/components/rental/rental.d.ts +3 -3
  21. package/dist/src/components/rental/rental.js +27 -23
  22. package/dist/src/components/rental/rental.js.map +1 -1
  23. package/dist/src/database.js +2 -2
  24. package/dist/src/database.js.map +1 -1
  25. package/dist/src/enum/agreement-signature-status.enum.d.ts +4 -0
  26. package/dist/src/enum/agreement-signature-status.enum.js +9 -0
  27. package/dist/src/enum/agreement-signature-status.enum.js.map +1 -0
  28. package/dist/src/enum/index.d.ts +2 -2
  29. package/dist/src/enum/index.js +3 -3
  30. package/dist/src/enum/index.js.map +1 -1
  31. package/dist/src/index.d.ts +3 -3
  32. package/dist/src/index.js +5 -5
  33. package/dist/src/index.js.map +1 -1
  34. package/dist/src/interfaces/agreemeent-signature-attr.interface.d.ts +14 -0
  35. package/dist/src/interfaces/agreemeent-signature-attr.interface.js +3 -0
  36. package/dist/src/interfaces/agreemeent-signature-attr.interface.js.map +1 -0
  37. package/dist/src/interfaces/index.d.ts +3 -3
  38. package/dist/src/interfaces/response-hirer-signature-attr.interface.d.ts +6 -6
  39. package/dist/src/models/agreement-signature.entity.d.ts +18 -0
  40. package/dist/src/models/agreement-signature.entity.js +101 -0
  41. package/dist/src/models/agreement-signature.entity.js.map +1 -0
  42. package/dist/src/models/agreement.entity.d.ts +2 -2
  43. package/dist/src/models/agreement.entity.js +3 -3
  44. package/dist/src/models/agreement.entity.js.map +1 -1
  45. package/dist/src/models/hirer-signature.entity.d.ts +2 -2
  46. package/dist/src/models/hirer-signature.entity.js +18 -18
  47. package/dist/src/models/hirer-signature.entity.js.map +1 -1
  48. package/dist/src/models/index.d.ts +2 -2
  49. package/dist/src/models/index.js +3 -3
  50. package/dist/src/models/index.js.map +1 -1
  51. package/dist/tsconfig.tsbuildinfo +1 -1
  52. package/migrations/{hirer-signature-table-migration.js → agreement-signature-table-migration.js} +7 -7
  53. package/package.json +1 -1
  54. package/src/components/agreement/agreement.ts +5 -5
  55. package/src/components/agreement-signature/agreement-signature.repository.ts +55 -0
  56. package/src/components/agreement-signature/agreement-signature.ts +143 -0
  57. package/src/components/rental/rental.ts +31 -25
  58. package/src/database.ts +2 -2
  59. package/src/enum/agreement-signature-status.enum.ts +4 -0
  60. package/src/enum/index.ts +2 -2
  61. package/src/index.ts +4 -4
  62. package/src/interfaces/agreemeent-signature-attr.interface.ts +15 -0
  63. package/src/interfaces/index.ts +4 -4
  64. package/src/interfaces/response-hirer-signature-attr.interface.ts +6 -6
  65. package/src/models/{hirer-signature.entity.ts → agreement-signature.entity.ts} +14 -9
  66. package/src/models/agreement.entity.ts +3 -3
  67. package/src/models/index.ts +2 -2
  68. package/src/components/hirer-signature/hirer-signature.repository.ts +0 -54
  69. package/src/components/hirer-signature/hirer-signature.ts +0 -140
  70. package/src/enum/hirer-signature-status.enum.ts +0 -4
  71. package/src/interfaces/hirer-signature-attr.interface.ts +0 -15
@@ -1,54 +0,0 @@
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
- }
@@ -1,140 +0,0 @@
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
- }
@@ -1,4 +0,0 @@
1
- export enum HirerSignatureStatusEnum {
2
- PENDING = 'Pending',
3
- SIGNED = 'Signed',
4
- }
@@ -1,15 +0,0 @@
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
- }