@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.
- package/dist/src/components/agreement/agreement.d.ts +4 -4
- package/dist/src/components/agreement/agreement.js +3 -3
- package/dist/src/components/agreement/agreement.js.map +1 -1
- package/dist/src/components/agreement-signature/agreement-signature.d.ts +27 -0
- package/dist/src/components/agreement-signature/agreement-signature.js +112 -0
- package/dist/src/components/agreement-signature/agreement-signature.js.map +1 -0
- package/dist/src/components/agreement-signature/agreement-signature.repository.d.ts +8 -0
- package/dist/src/components/agreement-signature/agreement-signature.repository.js +68 -0
- package/dist/src/components/agreement-signature/agreement-signature.repository.js.map +1 -0
- package/dist/src/components/agreement-signature/hirer-signature.d.ts +27 -0
- package/dist/src/components/agreement-signature/hirer-signature.js +112 -0
- package/dist/src/components/agreement-signature/hirer-signature.js.map +1 -0
- package/dist/src/components/agreement-signature/hirer-signature.repository.d.ts +8 -0
- package/dist/src/components/agreement-signature/hirer-signature.repository.js +67 -0
- package/dist/src/components/agreement-signature/hirer-signature.repository.js.map +1 -0
- package/dist/src/components/hirer-signature/hirer-signature.d.ts +2 -2
- package/dist/src/components/hirer-signature/hirer-signature.repository.d.ts +1 -1
- package/dist/src/components/hirer-signature/hirer-signature.repository.js +6 -6
- package/dist/src/components/hirer-signature/hirer-signature.repository.js.map +1 -1
- package/dist/src/components/rental/rental.d.ts +3 -3
- package/dist/src/components/rental/rental.js +27 -23
- package/dist/src/components/rental/rental.js.map +1 -1
- package/dist/src/database.js +2 -2
- package/dist/src/database.js.map +1 -1
- package/dist/src/enum/agreement-signature-status.enum.d.ts +4 -0
- package/dist/src/enum/agreement-signature-status.enum.js +9 -0
- package/dist/src/enum/agreement-signature-status.enum.js.map +1 -0
- package/dist/src/enum/index.d.ts +2 -2
- package/dist/src/enum/index.js +3 -3
- package/dist/src/enum/index.js.map +1 -1
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.js +5 -5
- package/dist/src/index.js.map +1 -1
- package/dist/src/interfaces/agreemeent-signature-attr.interface.d.ts +14 -0
- package/dist/src/interfaces/agreemeent-signature-attr.interface.js +3 -0
- package/dist/src/interfaces/agreemeent-signature-attr.interface.js.map +1 -0
- package/dist/src/interfaces/index.d.ts +3 -3
- package/dist/src/interfaces/response-hirer-signature-attr.interface.d.ts +6 -6
- package/dist/src/models/agreement-signature.entity.d.ts +18 -0
- package/dist/src/models/agreement-signature.entity.js +101 -0
- package/dist/src/models/agreement-signature.entity.js.map +1 -0
- package/dist/src/models/agreement.entity.d.ts +2 -2
- package/dist/src/models/agreement.entity.js +3 -3
- package/dist/src/models/agreement.entity.js.map +1 -1
- package/dist/src/models/hirer-signature.entity.d.ts +2 -2
- package/dist/src/models/hirer-signature.entity.js +18 -18
- package/dist/src/models/hirer-signature.entity.js.map +1 -1
- package/dist/src/models/index.d.ts +2 -2
- package/dist/src/models/index.js +3 -3
- package/dist/src/models/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/migrations/{hirer-signature-table-migration.js → agreement-signature-table-migration.js} +7 -7
- package/package.json +1 -1
- package/src/components/agreement/agreement.ts +5 -5
- package/src/components/agreement-signature/agreement-signature.repository.ts +55 -0
- package/src/components/agreement-signature/agreement-signature.ts +143 -0
- package/src/components/rental/rental.ts +31 -25
- package/src/database.ts +2 -2
- package/src/enum/agreement-signature-status.enum.ts +4 -0
- package/src/enum/index.ts +2 -2
- package/src/index.ts +4 -4
- package/src/interfaces/agreemeent-signature-attr.interface.ts +15 -0
- package/src/interfaces/index.ts +4 -4
- package/src/interfaces/response-hirer-signature-attr.interface.ts +6 -6
- package/src/models/{hirer-signature.entity.ts → agreement-signature.entity.ts} +14 -9
- package/src/models/agreement.entity.ts +3 -3
- package/src/models/index.ts +2 -2
- package/src/components/hirer-signature/hirer-signature.repository.ts +0 -54
- package/src/components/hirer-signature/hirer-signature.ts +0 -140
- package/src/enum/hirer-signature-status.enum.ts +0 -4
- package/src/interfaces/hirer-signature-attr.interface.ts +0 -15
package/migrations/{hirer-signature-table-migration.js → agreement-signature-table-migration.js}
RENAMED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
/** @type {import('sequelize-cli').Migration} */
|
|
4
4
|
module.exports = {
|
|
5
5
|
async up(queryInterface, Sequelize) {
|
|
6
|
-
await queryInterface.createTable('
|
|
7
|
-
|
|
6
|
+
await queryInterface.createTable('rental_AgreementSignature', {
|
|
7
|
+
SignatureId: {
|
|
8
8
|
type: Sequelize.STRING(30),
|
|
9
9
|
allowNull: false,
|
|
10
10
|
primaryKey: true,
|
|
@@ -19,15 +19,15 @@ module.exports = {
|
|
|
19
19
|
onUpdate: 'CASCADE',
|
|
20
20
|
onDelete: 'CASCADE',
|
|
21
21
|
},
|
|
22
|
-
|
|
23
|
-
type: Sequelize.STRING(
|
|
22
|
+
Party: {
|
|
23
|
+
type: Sequelize.STRING(30),
|
|
24
24
|
allowNull: false,
|
|
25
25
|
},
|
|
26
|
-
|
|
26
|
+
PartyId: {
|
|
27
27
|
type: Sequelize.STRING(30),
|
|
28
28
|
allowNull: false,
|
|
29
29
|
},
|
|
30
|
-
|
|
30
|
+
PartyType: {
|
|
31
31
|
type: Sequelize.STRING(30),
|
|
32
32
|
allowNull: false,
|
|
33
33
|
},
|
|
@@ -37,7 +37,7 @@ module.exports = {
|
|
|
37
37
|
},
|
|
38
38
|
SignedAt: {
|
|
39
39
|
type: Sequelize.DATE,
|
|
40
|
-
allowNull:
|
|
40
|
+
allowNull: true,
|
|
41
41
|
},
|
|
42
42
|
CreatedById: {
|
|
43
43
|
type: Sequelize.STRING(30),
|
package/package.json
CHANGED
|
@@ -4,10 +4,10 @@ import { IAgreementAttr } from '../../interfaces/agreement-attr.interface';
|
|
|
4
4
|
import { AgreementRepository } from './agreement.repository';
|
|
5
5
|
import { ApplicationConfig } from '@tomei/config';
|
|
6
6
|
import { LoginUser } from '@tomei/sso';
|
|
7
|
-
import {
|
|
7
|
+
import { AgreementSignatureRepository } from '../agreement-signature/agreement-signature.repository';
|
|
8
8
|
import * as rentalDb from '../../database';
|
|
9
9
|
import { QueryTypes, where } from 'sequelize';
|
|
10
|
-
import {
|
|
10
|
+
import { IResponseAgreementSignature } from '../../interfaces/response-hirer-signature-attr.interface';
|
|
11
11
|
import { AgreementHistoryRepository } from '../agreement-history/agreement-history.repository';
|
|
12
12
|
import { IAgreementHistoryAttr } from 'interfaces/agreement-history-attr.interface';
|
|
13
13
|
import { ActionEnum, Activity } from '@tomei/activity-history';
|
|
@@ -22,7 +22,7 @@ export class Agreement extends ObjectBase {
|
|
|
22
22
|
MediaId: string;
|
|
23
23
|
|
|
24
24
|
private static _Repo = new AgreementRepository();
|
|
25
|
-
protected static
|
|
25
|
+
protected static _AgreementSignatureRepo = new AgreementSignatureRepository();
|
|
26
26
|
protected static _AgreementHistoryRepo = new AgreementHistoryRepository();
|
|
27
27
|
|
|
28
28
|
get AgreementNo(): string {
|
|
@@ -98,14 +98,14 @@ export class Agreement extends ObjectBase {
|
|
|
98
98
|
SELECT
|
|
99
99
|
hs.*
|
|
100
100
|
FROM
|
|
101
|
-
|
|
101
|
+
rental_AgreementSignature hs
|
|
102
102
|
WHERE
|
|
103
103
|
hs.AgreementNo = '${agreementNo}'
|
|
104
104
|
`;
|
|
105
105
|
|
|
106
106
|
const db = rentalDb.getConnection();
|
|
107
107
|
|
|
108
|
-
const signatures:
|
|
108
|
+
const signatures: IResponseAgreementSignature[] = await db.query(query, {
|
|
109
109
|
type: QueryTypes.SELECT,
|
|
110
110
|
transaction: dbTransaction,
|
|
111
111
|
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { RepositoryBase, IRepositoryBase } from '@tomei/general';
|
|
2
|
+
import { AgreementSignatureModel } from '../../models/agreement-signature.entity';
|
|
3
|
+
|
|
4
|
+
export class AgreementSignatureRepository
|
|
5
|
+
extends RepositoryBase<AgreementSignatureModel>
|
|
6
|
+
implements IRepositoryBase<AgreementSignatureModel>
|
|
7
|
+
{
|
|
8
|
+
constructor() {
|
|
9
|
+
super(AgreementSignatureModel);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async findByPk(
|
|
13
|
+
id: string,
|
|
14
|
+
transaction?: any,
|
|
15
|
+
): Promise<AgreementSignatureModel | null> {
|
|
16
|
+
try {
|
|
17
|
+
const result = await AgreementSignatureModel.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(partyId: string, dbTransaction?: any) {
|
|
28
|
+
try {
|
|
29
|
+
const options = {
|
|
30
|
+
where: {
|
|
31
|
+
PartyId: partyId,
|
|
32
|
+
},
|
|
33
|
+
transaction: dbTransaction,
|
|
34
|
+
};
|
|
35
|
+
await AgreementSignatureModel.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 AgreementSignature: any;
|
|
44
|
+
if (options) {
|
|
45
|
+
AgreementSignature =
|
|
46
|
+
await AgreementSignatureModel.findAndCountAll(options);
|
|
47
|
+
} else {
|
|
48
|
+
AgreementSignature = await AgreementSignatureModel.findAndCountAll();
|
|
49
|
+
}
|
|
50
|
+
return AgreementSignature;
|
|
51
|
+
} catch (error) {
|
|
52
|
+
throw new Error(`An Error occured when retriving : ${error.message}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { ClassError, ObjectBase } from '@tomei/general';
|
|
2
|
+
import { AgreementSignatureRepository } from './agreement-signature.repository';
|
|
3
|
+
import { IAgreementSignatureAttr } from '../../interfaces/agreemeent-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 { AgreementSignatureStatusEnum } from '../../enum/agreement-signature-status.enum';
|
|
8
|
+
|
|
9
|
+
export class AgreementSignature
|
|
10
|
+
extends ObjectBase
|
|
11
|
+
implements IAgreementSignatureAttr
|
|
12
|
+
{
|
|
13
|
+
ObjectId: string;
|
|
14
|
+
ObjectName: string;
|
|
15
|
+
ObjectType: string = 'AgreementSignature';
|
|
16
|
+
TableName: string = 'rental_AgreementSignature';
|
|
17
|
+
AgreementNo: string;
|
|
18
|
+
Party: string;
|
|
19
|
+
PartyId: string;
|
|
20
|
+
PartyType: string;
|
|
21
|
+
SignatureStatus: AgreementSignatureStatusEnum;
|
|
22
|
+
SignedAt: Date;
|
|
23
|
+
CreatedById: string;
|
|
24
|
+
CreatedAt: Date;
|
|
25
|
+
UpdatedById: string;
|
|
26
|
+
UpdatedAt: Date;
|
|
27
|
+
|
|
28
|
+
get SignatureId(): string {
|
|
29
|
+
return this.ObjectId;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
set SignatureId(value: string) {
|
|
33
|
+
this.ObjectId = value;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
protected static _Repository = new AgreementSignatureRepository();
|
|
37
|
+
|
|
38
|
+
protected constructor(AgreementSignatureAttr?: IAgreementSignatureAttr) {
|
|
39
|
+
super();
|
|
40
|
+
if (AgreementSignatureAttr) {
|
|
41
|
+
this.SignatureId = AgreementSignatureAttr.SignatureId;
|
|
42
|
+
this.AgreementNo = AgreementSignatureAttr.AgreementNo;
|
|
43
|
+
this.Party = AgreementSignatureAttr.Party;
|
|
44
|
+
this.PartyId = AgreementSignatureAttr.PartyId;
|
|
45
|
+
this.PartyType = AgreementSignatureAttr.PartyType;
|
|
46
|
+
this.SignatureStatus = AgreementSignatureAttr.SignatureStatus;
|
|
47
|
+
this.SignedAt = AgreementSignatureAttr.SignedAt;
|
|
48
|
+
this.CreatedById = AgreementSignatureAttr.CreatedById;
|
|
49
|
+
this.CreatedAt = AgreementSignatureAttr.CreatedAt;
|
|
50
|
+
this.UpdatedById = AgreementSignatureAttr.UpdatedById;
|
|
51
|
+
this.UpdatedAt = AgreementSignatureAttr.UpdatedAt;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public static async init(AgreementSignatureId?: string, dbTransaction?: any) {
|
|
56
|
+
try {
|
|
57
|
+
if (AgreementSignatureId) {
|
|
58
|
+
const hs = await AgreementSignature._Repository.findByPk(
|
|
59
|
+
AgreementSignatureId,
|
|
60
|
+
dbTransaction,
|
|
61
|
+
);
|
|
62
|
+
if (hs) {
|
|
63
|
+
return new AgreementSignature(hs.get({ plain: true }));
|
|
64
|
+
} else {
|
|
65
|
+
throw new ClassError(
|
|
66
|
+
'AgreementSignature',
|
|
67
|
+
'AgreementSignatureErrMsg01',
|
|
68
|
+
'AgreementSignature not found',
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return new AgreementSignature();
|
|
73
|
+
} catch (error) {
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public async create(loginUser: LoginUser, dbTransaction?: any) {
|
|
79
|
+
try {
|
|
80
|
+
const systemCode =
|
|
81
|
+
ApplicationConfig.getComponentConfigValue('system-code');
|
|
82
|
+
const isPrivileged = await loginUser.checkPrivileges(
|
|
83
|
+
systemCode,
|
|
84
|
+
'AgreementSignature - Create',
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
if (!isPrivileged) {
|
|
88
|
+
throw new ClassError(
|
|
89
|
+
'AgreementSignature',
|
|
90
|
+
'AgreementSignatureErrMsg00',
|
|
91
|
+
"You do not have 'AgreementSignature - Create' privilege.",
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (!this.AgreementNo || !this.PartyId || !this.PartyType) {
|
|
96
|
+
throw new ClassError(
|
|
97
|
+
'AgreementSignature',
|
|
98
|
+
'AgreementSignatureErrMsg03',
|
|
99
|
+
'AgreementNo, PartyId and PartyType are required.',
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
this.ObjectId = this.createId();
|
|
104
|
+
this.CreatedById = loginUser.ObjectId;
|
|
105
|
+
this.CreatedAt = new Date();
|
|
106
|
+
this.UpdatedById = loginUser.ObjectId;
|
|
107
|
+
this.UpdatedAt = new Date();
|
|
108
|
+
|
|
109
|
+
const entityValueAfter: IAgreementSignatureAttr = {
|
|
110
|
+
SignatureId: this.SignatureId,
|
|
111
|
+
AgreementNo: this.AgreementNo,
|
|
112
|
+
Party: this.Party,
|
|
113
|
+
PartyId: this.PartyId,
|
|
114
|
+
PartyType: this.PartyType,
|
|
115
|
+
SignatureStatus: this.SignatureStatus,
|
|
116
|
+
SignedAt: this.SignedAt,
|
|
117
|
+
CreatedById: this.CreatedById,
|
|
118
|
+
CreatedAt: this.CreatedAt,
|
|
119
|
+
UpdatedById: this.UpdatedById,
|
|
120
|
+
UpdatedAt: this.UpdatedAt,
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
await AgreementSignature._Repository.create(entityValueAfter, {
|
|
124
|
+
transaction: dbTransaction,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const activity = new Activity();
|
|
128
|
+
activity.ObjectId = this.createId();
|
|
129
|
+
activity.Action = ActionEnum.CREATE;
|
|
130
|
+
activity.Description = 'Add Joint Hirer Signature';
|
|
131
|
+
activity.EntityId = this.ObjectId;
|
|
132
|
+
activity.EntityType = this.ObjectType;
|
|
133
|
+
activity.EntityValueBefore = JSON.stringify({});
|
|
134
|
+
activity.EntityValueAfter = JSON.stringify(entityValueAfter);
|
|
135
|
+
|
|
136
|
+
await activity.create(loginUser.ObjectId, dbTransaction);
|
|
137
|
+
|
|
138
|
+
return this;
|
|
139
|
+
} catch (error) {
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -18,8 +18,8 @@ import { JointHirerRepository } from '../joint-hirer/joint-hirer.repository';
|
|
|
18
18
|
import { AgreementModel } from '../../models';
|
|
19
19
|
import { Agreement } from '../agreement/agreement';
|
|
20
20
|
import { AggrementStatusEnum } from '../../enum/aggrement-status.enum';
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
21
|
+
import { AgreementSignatureRepository } from '../agreement-signature/agreement-signature.repository';
|
|
22
|
+
import { AgreementSignatureStatusEnum } from '../../enum/agreement-signature-status.enum';
|
|
23
23
|
import { HirerTypeEnum } from '../../enum/hirer-type.enum';
|
|
24
24
|
import { AgreementHistoryRepository } from '../agreement-history/agreement-history.repository';
|
|
25
25
|
|
|
@@ -49,7 +49,7 @@ export class Rental extends ObjectBase {
|
|
|
49
49
|
protected static _Repo = new RentalRepository();
|
|
50
50
|
protected static _AgreementRepo = new AgreementRepository();
|
|
51
51
|
protected static _JointHirerRepo = new JointHirerRepository();
|
|
52
|
-
protected static
|
|
52
|
+
protected static _AgreementSignatureRepo = new AgreementSignatureRepository();
|
|
53
53
|
protected static _AgreementHistoryRepo = new AgreementHistoryRepository();
|
|
54
54
|
|
|
55
55
|
get RentalId(): string {
|
|
@@ -197,16 +197,16 @@ export class Rental extends ObjectBase {
|
|
|
197
197
|
},
|
|
198
198
|
);
|
|
199
199
|
|
|
200
|
-
//Create a record into
|
|
200
|
+
//Create a record into rental_AgreementSignature table
|
|
201
201
|
//Create the main customer's signature record
|
|
202
|
-
await Rental.
|
|
202
|
+
await Rental._AgreementSignatureRepo.create(
|
|
203
203
|
{
|
|
204
|
-
|
|
204
|
+
SignatureId: this.createId(),
|
|
205
205
|
AgreementNo: this.AgreementNo,
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
SignatureStatus:
|
|
206
|
+
Party: HirerTypeEnum.PRIMARY,
|
|
207
|
+
PartyId: this.CustomerId,
|
|
208
|
+
PartyType: 'Customer',
|
|
209
|
+
SignatureStatus: AgreementSignatureStatusEnum.PENDING,
|
|
210
210
|
SignedAt: new Date(),
|
|
211
211
|
CreatedById: loginUser.ObjectId,
|
|
212
212
|
CreatedAt: new Date(),
|
|
@@ -219,14 +219,14 @@ export class Rental extends ObjectBase {
|
|
|
219
219
|
// Create signatures record for joint hirers if any
|
|
220
220
|
if (jointHirers && jointHirers.length > 0) {
|
|
221
221
|
for (const jointHirer of jointHirers) {
|
|
222
|
-
await Rental.
|
|
222
|
+
await Rental._AgreementSignatureRepo.create(
|
|
223
223
|
{
|
|
224
|
-
|
|
224
|
+
SignatureId: this.createId(),
|
|
225
225
|
AgreementNo: this.AgreementNo,
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
SignatureStatus:
|
|
226
|
+
Party: HirerTypeEnum.JOINT,
|
|
227
|
+
PartyId: jointHirer.CustomerId,
|
|
228
|
+
PartyType: 'Customer',
|
|
229
|
+
SignatureStatus: AgreementSignatureStatusEnum.PENDING,
|
|
230
230
|
SignedAt: new Date(),
|
|
231
231
|
CreatedById: loginUser.ObjectId,
|
|
232
232
|
CreatedAt: new Date(),
|
|
@@ -773,7 +773,9 @@ export class Rental extends ObjectBase {
|
|
|
773
773
|
|
|
774
774
|
async signAgreement(
|
|
775
775
|
loginUser: LoginUser,
|
|
776
|
-
|
|
776
|
+
party: string,
|
|
777
|
+
PartyId: string,
|
|
778
|
+
PartyType: string,
|
|
777
779
|
dbTransaction: any,
|
|
778
780
|
statusAfterSign?: RentalStatusEnum | string,
|
|
779
781
|
) {
|
|
@@ -816,30 +818,34 @@ export class Rental extends ObjectBase {
|
|
|
816
818
|
);
|
|
817
819
|
const customerSignature = signatureList.find(
|
|
818
820
|
(sig) =>
|
|
819
|
-
sig.
|
|
820
|
-
sig.
|
|
821
|
+
sig.PartyId === PartyId &&
|
|
822
|
+
sig.PartyType === PartyType &&
|
|
823
|
+
sig.Party === party &&
|
|
824
|
+
sig.SignatureStatus === AgreementSignatureStatusEnum.PENDING,
|
|
821
825
|
);
|
|
822
826
|
|
|
823
827
|
if (!customerSignature) {
|
|
824
828
|
throw new ClassError(
|
|
825
829
|
'Rental',
|
|
826
830
|
'RentalErrMsg01',
|
|
827
|
-
'
|
|
831
|
+
'Signature is not pending.',
|
|
828
832
|
);
|
|
829
833
|
}
|
|
830
834
|
|
|
831
|
-
//Update
|
|
835
|
+
//Update rental_AgreementSignature
|
|
832
836
|
const signaturePayload = {
|
|
833
|
-
SignatureStatus:
|
|
837
|
+
SignatureStatus: AgreementSignatureStatusEnum.SIGNED,
|
|
834
838
|
SignedAt: new Date(),
|
|
835
839
|
UpdatedById: loginUser.ObjectId,
|
|
836
840
|
UpdatedAt: new Date(),
|
|
837
841
|
};
|
|
838
842
|
|
|
839
|
-
await Rental.
|
|
843
|
+
await Rental._AgreementSignatureRepo.update(signaturePayload, {
|
|
840
844
|
where: {
|
|
841
845
|
AgreementNo: this.AgreementNo,
|
|
842
|
-
|
|
846
|
+
Party: party,
|
|
847
|
+
PartyId: PartyId,
|
|
848
|
+
PartyType: PartyType,
|
|
843
849
|
},
|
|
844
850
|
transaction: dbTransaction,
|
|
845
851
|
});
|
|
@@ -848,7 +854,7 @@ export class Rental extends ObjectBase {
|
|
|
848
854
|
signatureActivity.ActivityId = signatureActivity.createId();
|
|
849
855
|
signatureActivity.Action = ActionEnum.UPDATE;
|
|
850
856
|
signatureActivity.Description = 'Update hirer signature';
|
|
851
|
-
signatureActivity.EntityType = '
|
|
857
|
+
signatureActivity.EntityType = 'AgreementSignature';
|
|
852
858
|
signatureActivity.EntityId = this.AgreementNo;
|
|
853
859
|
signatureActivity.EntityValueBefore = JSON.stringify(customerSignature);
|
|
854
860
|
signatureActivity.EntityValueAfter = JSON.stringify(signaturePayload);
|
package/src/database.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { RentalPriceModel } from './models/rental-price.entity';
|
|
|
4
4
|
import { BookingModel } from './models/booking.entity';
|
|
5
5
|
import { JointHirerModel } from './models/joint-hirer.entity';
|
|
6
6
|
import { AgreementModel } from './models/agreement.entity';
|
|
7
|
-
import {
|
|
7
|
+
import { AgreementSignatureModel } from './models/agreement-signature.entity';
|
|
8
8
|
import { AgreementHistoryModel } from './models/agreement-history.entity';
|
|
9
9
|
|
|
10
10
|
let sequelize: Sequelize;
|
|
@@ -19,7 +19,7 @@ function init(sequelizeOptions: SequelizeOptions) {
|
|
|
19
19
|
BookingModel,
|
|
20
20
|
JointHirerModel,
|
|
21
21
|
AgreementModel,
|
|
22
|
-
|
|
22
|
+
AgreementSignatureModel,
|
|
23
23
|
AgreementHistoryModel,
|
|
24
24
|
]);
|
|
25
25
|
}
|
package/src/enum/index.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { RentalStatusEnum } from './rental-status.enum';
|
|
|
2
2
|
import { BookingStatusEnum } from './booking.enum';
|
|
3
3
|
import { RentalAccountTypeEnum } from './account-type.enum';
|
|
4
4
|
import { AggrementStatusEnum } from './aggrement-status.enum';
|
|
5
|
-
import {
|
|
5
|
+
import { AgreementSignatureStatusEnum } from './agreement-signature-status.enum';
|
|
6
6
|
import { HirerTypeEnum } from './hirer-type.enum';
|
|
7
7
|
|
|
8
8
|
export {
|
|
@@ -10,6 +10,6 @@ export {
|
|
|
10
10
|
BookingStatusEnum,
|
|
11
11
|
RentalAccountTypeEnum,
|
|
12
12
|
AggrementStatusEnum,
|
|
13
|
-
|
|
13
|
+
AgreementSignatureStatusEnum,
|
|
14
14
|
HirerTypeEnum,
|
|
15
15
|
};
|
package/src/index.ts
CHANGED
|
@@ -8,8 +8,8 @@ import { JointHirer } from './components/joint-hirer/joint-hirer';
|
|
|
8
8
|
import { JointHirerRepository } from './components/joint-hirer/joint-hirer.repository';
|
|
9
9
|
import { Agreement } from './components/agreement/agreement';
|
|
10
10
|
import { AgreementRepository } from './components/agreement/agreement.repository';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { AgreementSignature } from './components/agreement-signature/agreement-signature';
|
|
12
|
+
import { AgreementSignatureRepository } from './components/agreement-signature/agreement-signature.repository';
|
|
13
13
|
import { AgreementHistory } from './components/agreement-history/agreement-history';
|
|
14
14
|
import { AgreementHistoryRepository } from './components/agreement-history/agreement-history.repository';
|
|
15
15
|
import * as rentalDb from './database';
|
|
@@ -29,8 +29,8 @@ export {
|
|
|
29
29
|
JointHirerRepository,
|
|
30
30
|
Agreement,
|
|
31
31
|
AgreementRepository,
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
AgreementSignature,
|
|
33
|
+
AgreementSignatureRepository,
|
|
34
34
|
AgreementHistory,
|
|
35
35
|
AgreementHistoryRepository,
|
|
36
36
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AgreementSignatureStatusEnum } from '../enum/agreement-signature-status.enum';
|
|
2
|
+
|
|
3
|
+
export interface IAgreementSignatureAttr {
|
|
4
|
+
SignatureId: string;
|
|
5
|
+
AgreementNo: string;
|
|
6
|
+
Party: string;
|
|
7
|
+
PartyId: string;
|
|
8
|
+
PartyType: string;
|
|
9
|
+
SignatureStatus: AgreementSignatureStatusEnum;
|
|
10
|
+
SignedAt: Date;
|
|
11
|
+
CreatedById: string;
|
|
12
|
+
CreatedAt: Date;
|
|
13
|
+
UpdatedById: string;
|
|
14
|
+
UpdatedAt: Date;
|
|
15
|
+
}
|
package/src/interfaces/index.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { IRentalFindAllSearchAttr } from './rental-find-all-search-attr.interfac
|
|
|
4
4
|
import { IBookingAttr } from './booking-attr.interface';
|
|
5
5
|
import { IAgreementAttr } from './agreement-attr.interface';
|
|
6
6
|
import { IBookingFindAllSearchAttr } from './booking-find-all-search-attr.interface';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { IAgreementSignatureAttr } from './agreemeent-signature-attr.interface';
|
|
8
|
+
import { IResponseAgreementSignature } from './response-hirer-signature-attr.interface';
|
|
9
9
|
|
|
10
10
|
export {
|
|
11
11
|
IRentalAttr,
|
|
@@ -14,6 +14,6 @@ export {
|
|
|
14
14
|
IBookingAttr,
|
|
15
15
|
IAgreementAttr,
|
|
16
16
|
IBookingFindAllSearchAttr,
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
IAgreementSignatureAttr,
|
|
18
|
+
IResponseAgreementSignature,
|
|
19
19
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AgreementSignatureStatusEnum } from '../enum/agreement-signature-status.enum';
|
|
2
2
|
|
|
3
|
-
export interface
|
|
3
|
+
export interface IResponseAgreementSignature {
|
|
4
4
|
HirerSignatureId: string;
|
|
5
5
|
AgreementNo: string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
SignatureStatus:
|
|
6
|
+
Party: string;
|
|
7
|
+
PartyId: string;
|
|
8
|
+
PartyType: string;
|
|
9
|
+
SignatureStatus: AgreementSignatureStatusEnum;
|
|
10
10
|
SignedAt: Date;
|
|
11
11
|
CreatedById: string;
|
|
12
12
|
CreatedAt: Date;
|
|
@@ -9,17 +9,22 @@ import {
|
|
|
9
9
|
UpdatedAt,
|
|
10
10
|
} from 'sequelize-typescript';
|
|
11
11
|
import { AgreementModel } from './agreement.entity';
|
|
12
|
+
import { IAgreementSignatureAttr } from '../interfaces/agreemeent-signature-attr.interface';
|
|
13
|
+
import { AgreementSignatureStatusEnum } from '../enum/agreement-signature-status.enum';
|
|
12
14
|
|
|
13
15
|
@Table({
|
|
14
|
-
tableName: '
|
|
16
|
+
tableName: 'rental_AgreementSignature',
|
|
15
17
|
})
|
|
16
|
-
export class
|
|
18
|
+
export class AgreementSignatureModel
|
|
19
|
+
extends Model
|
|
20
|
+
implements IAgreementSignatureAttr
|
|
21
|
+
{
|
|
17
22
|
@Column({
|
|
18
23
|
primaryKey: true,
|
|
19
24
|
allowNull: false,
|
|
20
25
|
type: DataType.STRING(30),
|
|
21
26
|
})
|
|
22
|
-
|
|
27
|
+
SignatureId: string;
|
|
23
28
|
|
|
24
29
|
@ForeignKey(() => AgreementModel)
|
|
25
30
|
@Column({
|
|
@@ -30,30 +35,30 @@ export class HirerSignatureModel extends Model {
|
|
|
30
35
|
|
|
31
36
|
@Column({
|
|
32
37
|
allowNull: false,
|
|
33
|
-
type: DataType.STRING(
|
|
38
|
+
type: DataType.STRING(30),
|
|
34
39
|
})
|
|
35
|
-
|
|
40
|
+
Party: string;
|
|
36
41
|
|
|
37
42
|
@Column({
|
|
38
43
|
allowNull: false,
|
|
39
44
|
type: DataType.STRING(30),
|
|
40
45
|
})
|
|
41
|
-
|
|
46
|
+
PartyId: string;
|
|
42
47
|
|
|
43
48
|
@Column({
|
|
44
49
|
allowNull: false,
|
|
45
50
|
type: DataType.STRING(30),
|
|
46
51
|
})
|
|
47
|
-
|
|
52
|
+
PartyType: string;
|
|
48
53
|
|
|
49
54
|
@Column({
|
|
50
55
|
allowNull: false,
|
|
51
56
|
type: DataType.STRING(10),
|
|
52
57
|
})
|
|
53
|
-
SignatureStatus:
|
|
58
|
+
SignatureStatus: AgreementSignatureStatusEnum;
|
|
54
59
|
|
|
55
60
|
@Column({
|
|
56
|
-
allowNull:
|
|
61
|
+
allowNull: true,
|
|
57
62
|
type: DataType.DATE,
|
|
58
63
|
})
|
|
59
64
|
SignedAt: Date;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Column, DataType, Table, Model, HasMany } from 'sequelize-typescript';
|
|
2
2
|
import { RentalModel } from './rental.entity';
|
|
3
3
|
import { AggrementStatusEnum } from '../enum/aggrement-status.enum';
|
|
4
|
-
import {
|
|
4
|
+
import { AgreementSignatureModel } from './agreement-signature.entity';
|
|
5
5
|
import { AgreementHistoryModel } from './agreement-history.entity';
|
|
6
6
|
|
|
7
7
|
@Table({
|
|
@@ -39,8 +39,8 @@ export class AgreementModel extends Model {
|
|
|
39
39
|
@HasMany(() => RentalModel)
|
|
40
40
|
Rentals: RentalModel[];
|
|
41
41
|
|
|
42
|
-
@HasMany(() =>
|
|
43
|
-
|
|
42
|
+
@HasMany(() => AgreementSignatureModel)
|
|
43
|
+
AgreementSignatures: AgreementSignatureModel[];
|
|
44
44
|
|
|
45
45
|
@HasMany(() => AgreementHistoryModel)
|
|
46
46
|
History: AgreementHistoryModel[];
|
package/src/models/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { RentalPriceModel } from './rental-price.entity';
|
|
|
3
3
|
import { BookingModel } from './booking.entity';
|
|
4
4
|
import { JointHirerModel } from './joint-hirer.entity';
|
|
5
5
|
import { AgreementModel } from './agreement.entity';
|
|
6
|
-
import {
|
|
6
|
+
import { AgreementSignatureModel } from './agreement-signature.entity';
|
|
7
7
|
import { AgreementHistoryModel } from './agreement-history.entity';
|
|
8
8
|
|
|
9
9
|
export {
|
|
@@ -12,6 +12,6 @@ export {
|
|
|
12
12
|
BookingModel,
|
|
13
13
|
JointHirerModel,
|
|
14
14
|
AgreementModel,
|
|
15
|
-
|
|
15
|
+
AgreementSignatureModel,
|
|
16
16
|
AgreementHistoryModel,
|
|
17
17
|
};
|