@tomei/rental 0.13.1 → 0.14.0
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 +2 -1
- package/dist/src/components/agreement/agreement.js +3 -22
- package/dist/src/components/agreement/agreement.js.map +1 -1
- package/dist/src/components/agreement-history/agreement-history.d.ts +17 -0
- package/dist/src/components/agreement-history/agreement-history.js +51 -0
- package/dist/src/components/agreement-history/agreement-history.js.map +1 -0
- package/dist/src/components/agreement-history/agreement-history.repository.d.ts +8 -0
- package/dist/src/components/agreement-history/agreement-history.repository.js +67 -0
- package/dist/src/components/agreement-history/agreement-history.repository.js.map +1 -0
- package/dist/src/database.js +2 -0
- package/dist/src/database.js.map +1 -1
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.js +5 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/interfaces/agreement-history-attr.interface.d.ts +7 -0
- package/dist/src/interfaces/agreement-history-attr.interface.js +3 -0
- package/dist/src/interfaces/agreement-history-attr.interface.js.map +1 -0
- package/dist/src/interfaces/response-hirer-signature-attr.interface.d.ts +1 -0
- package/dist/src/models/agreement-history.entity.d.ts +10 -0
- package/dist/src/models/agreement-history.entity.js +65 -0
- package/dist/src/models/agreement-history.entity.js.map +1 -0
- package/dist/src/models/agreement.entity.d.ts +2 -0
- package/dist/src/models/agreement.entity.js +5 -0
- package/dist/src/models/agreement.entity.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/migrations/rental-aggreement-history.js +41 -0
- package/package.json +1 -1
- package/src/components/agreement/agreement.ts +4 -34
- package/src/components/agreement-history/agreement-history.repository.ts +54 -0
- package/src/components/agreement-history/agreement-history.ts +57 -0
- package/src/database.ts +2 -0
- package/src/index.ts +4 -0
- package/src/interfaces/agreement-history-attr.interface.ts +7 -0
- package/src/interfaces/response-hirer-signature-attr.interface.ts +1 -0
- package/src/models/agreement-history.entity.ts +51 -0
- package/src/models/agreement.entity.ts +4 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/** @type {import('sequelize-cli').Migration} */
|
|
4
|
+
module.exports = {
|
|
5
|
+
async up(queryInterface, Sequelize) {
|
|
6
|
+
await queryInterface.createTable('rental_AgreementHistory', {
|
|
7
|
+
BookingNo: {
|
|
8
|
+
type: Sequelize.INTEGER,
|
|
9
|
+
allowNull: false,
|
|
10
|
+
primaryKey: true,
|
|
11
|
+
autoIncrement: true,
|
|
12
|
+
},
|
|
13
|
+
MediaId: {
|
|
14
|
+
type: Sequelize.STRING(30),
|
|
15
|
+
allowNull: false,
|
|
16
|
+
},
|
|
17
|
+
ActivityCompleted: {
|
|
18
|
+
type: Sequelize.STRING(200),
|
|
19
|
+
allowNull: false,
|
|
20
|
+
},
|
|
21
|
+
AgreementNo: {
|
|
22
|
+
type: Sequelize.STRING(30),
|
|
23
|
+
allowNull: false,
|
|
24
|
+
references: {
|
|
25
|
+
model: 'rental_Agreement',
|
|
26
|
+
key: 'AgreementNo',
|
|
27
|
+
},
|
|
28
|
+
onUpdate: 'CASCADE',
|
|
29
|
+
onDelete: 'CASCADE',
|
|
30
|
+
},
|
|
31
|
+
CreatedAt: {
|
|
32
|
+
type: Sequelize.DATE,
|
|
33
|
+
allowNull: false,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
async down(queryInterface, Sequelize) {
|
|
39
|
+
await queryInterface.dropTable('rental_AgreementHistory');
|
|
40
|
+
},
|
|
41
|
+
};
|
package/package.json
CHANGED
|
@@ -94,53 +94,23 @@ export class Agreement extends ObjectBase {
|
|
|
94
94
|
SELECT
|
|
95
95
|
hs.*,
|
|
96
96
|
c.FullName,
|
|
97
|
-
|
|
98
|
-
cf.RightIndexFinger,
|
|
99
|
-
cf.LeftThumb,
|
|
100
|
-
cf.LeftIndexFinger
|
|
97
|
+
c.CRMRefNo
|
|
101
98
|
FROM
|
|
102
99
|
rental_HirerSignature hs
|
|
103
100
|
LEFT JOIN
|
|
104
|
-
sdb_Customer c ON hs.CustomerId = c.CustomerId
|
|
105
|
-
LEFT JOIN
|
|
106
|
-
${process.env.CENTRAL_DB_NAME}.customer_fingerprint cf ON c.CRMRefNo = cf.CustomerId
|
|
101
|
+
sdb_Customer c ON hs.CustomerId = c.CustomerId
|
|
107
102
|
WHERE
|
|
108
103
|
hs.AgreementNo = '${agreementNo}'
|
|
109
104
|
`;
|
|
110
105
|
|
|
111
106
|
const db = rentalDb.getConnection();
|
|
112
107
|
|
|
113
|
-
const signatures = await db.query(query, {
|
|
108
|
+
const signatures: IResponseHirerSignature[] = await db.query(query, {
|
|
114
109
|
type: QueryTypes.SELECT,
|
|
115
110
|
transaction: dbTransaction,
|
|
116
111
|
});
|
|
117
112
|
|
|
118
|
-
|
|
119
|
-
const processedSignatures = signatures.map((signature: any) => {
|
|
120
|
-
const convertToBase64 = (data: Buffer | null) =>
|
|
121
|
-
data ? atob(Buffer.from(data).toString('base64')) : null;
|
|
122
|
-
|
|
123
|
-
const processedSignature = {
|
|
124
|
-
...signature,
|
|
125
|
-
FingerPrint: {
|
|
126
|
-
RightThumb: convertToBase64(signature.RightThumb),
|
|
127
|
-
RightIndexFinger: convertToBase64(signature.RightIndexFinger),
|
|
128
|
-
LeftThumb: convertToBase64(signature.LeftThumb),
|
|
129
|
-
LeftIndexFinger: convertToBase64(signature.LeftIndexFinger),
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
// Delete individual fingerprint fields
|
|
134
|
-
delete processedSignature.RightThumb;
|
|
135
|
-
delete processedSignature.RightIndexFinger;
|
|
136
|
-
delete processedSignature.LeftThumb;
|
|
137
|
-
delete processedSignature.LeftIndexFinger;
|
|
138
|
-
|
|
139
|
-
return processedSignature;
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
// Return the processed records
|
|
143
|
-
return processedSignatures;
|
|
113
|
+
return signatures;
|
|
144
114
|
} catch (error) {
|
|
145
115
|
throw error;
|
|
146
116
|
}
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +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
|
+
}
|
package/src/database.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { BookingModel } from './models/booking.entity';
|
|
|
5
5
|
import { JointHirerModel } from './models/joint-hirer.entity';
|
|
6
6
|
import { AgreementModel } from './models/agreement.entity';
|
|
7
7
|
import { HirerSignatureModel } from './models/hirer-signature.entity';
|
|
8
|
+
import { AgreementHistoryModel } from './models/agreement-history.entity';
|
|
8
9
|
|
|
9
10
|
let sequelize: Sequelize;
|
|
10
11
|
|
|
@@ -19,6 +20,7 @@ function init(sequelizeOptions: SequelizeOptions) {
|
|
|
19
20
|
JointHirerModel,
|
|
20
21
|
AgreementModel,
|
|
21
22
|
HirerSignatureModel,
|
|
23
|
+
AgreementHistoryModel,
|
|
22
24
|
]);
|
|
23
25
|
}
|
|
24
26
|
|
package/src/index.ts
CHANGED
|
@@ -10,6 +10,8 @@ import { Agreement } from './components/agreement/agreement';
|
|
|
10
10
|
import { AgreementRepository } from './components/agreement/agreement.repository';
|
|
11
11
|
import { HirerSignature } from './components/hirer-signature/hirer-signature';
|
|
12
12
|
import { HirerSignatureRepository } from './components/hirer-signature/hirer-signature.repository';
|
|
13
|
+
import { AgreementHistory } from './components/agreement-history/agreement-history';
|
|
14
|
+
import { AgreementHistoryRepository } from './components/agreement-history/agreement-history.repository';
|
|
13
15
|
import * as rentalDb from './database';
|
|
14
16
|
export * from './interfaces';
|
|
15
17
|
export * from './models';
|
|
@@ -29,4 +31,6 @@ export {
|
|
|
29
31
|
AgreementRepository,
|
|
30
32
|
HirerSignature,
|
|
31
33
|
HirerSignatureRepository,
|
|
34
|
+
AgreementHistory,
|
|
35
|
+
AgreementHistoryRepository,
|
|
32
36
|
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Column,
|
|
3
|
+
DataType,
|
|
4
|
+
Table,
|
|
5
|
+
Model,
|
|
6
|
+
ForeignKey,
|
|
7
|
+
BelongsTo,
|
|
8
|
+
CreatedAt,
|
|
9
|
+
} from 'sequelize-typescript';
|
|
10
|
+
import { AgreementModel } from './agreement.entity';
|
|
11
|
+
|
|
12
|
+
@Table({
|
|
13
|
+
tableName: 'rental_Agreement',
|
|
14
|
+
createdAt: 'CreatedAt',
|
|
15
|
+
updatedAt: false,
|
|
16
|
+
timestamps: true,
|
|
17
|
+
})
|
|
18
|
+
export class AgreementHistoryModel extends Model {
|
|
19
|
+
@Column({
|
|
20
|
+
primaryKey: true,
|
|
21
|
+
allowNull: false,
|
|
22
|
+
autoIncrement: true,
|
|
23
|
+
type: DataType.INTEGER,
|
|
24
|
+
})
|
|
25
|
+
HistoryId: number;
|
|
26
|
+
|
|
27
|
+
@ForeignKey(() => AgreementModel)
|
|
28
|
+
@Column({
|
|
29
|
+
allowNull: false,
|
|
30
|
+
type: DataType.STRING(30),
|
|
31
|
+
})
|
|
32
|
+
AgreementNo: string;
|
|
33
|
+
|
|
34
|
+
@Column({
|
|
35
|
+
allowNull: false,
|
|
36
|
+
type: DataType.STRING(30),
|
|
37
|
+
})
|
|
38
|
+
MediaId: string;
|
|
39
|
+
|
|
40
|
+
@Column({
|
|
41
|
+
allowNull: false,
|
|
42
|
+
type: DataType.STRING(200),
|
|
43
|
+
})
|
|
44
|
+
ActivityCompleted: string;
|
|
45
|
+
|
|
46
|
+
@CreatedAt
|
|
47
|
+
CreatedAt?: Date;
|
|
48
|
+
|
|
49
|
+
@BelongsTo(() => AgreementModel)
|
|
50
|
+
Agreement: AgreementModel;
|
|
51
|
+
}
|
|
@@ -2,6 +2,7 @@ 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
4
|
import { HirerSignatureModel } from './hirer-signature.entity';
|
|
5
|
+
import { AgreementHistoryModel } from './agreement-history.entity';
|
|
5
6
|
|
|
6
7
|
@Table({
|
|
7
8
|
tableName: 'rental_Agreement',
|
|
@@ -40,4 +41,7 @@ export class AgreementModel extends Model {
|
|
|
40
41
|
|
|
41
42
|
@HasMany(() => HirerSignatureModel)
|
|
42
43
|
HirerSignatures: HirerSignatureModel[];
|
|
44
|
+
|
|
45
|
+
@HasMany(() => AgreementHistoryModel)
|
|
46
|
+
History: AgreementHistoryModel[];
|
|
43
47
|
}
|