@tomei/rental 0.17.1 → 0.19.0-staging.1
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/rental/rental.d.ts +7 -0
- package/dist/src/components/rental/rental.js +135 -0
- package/dist/src/components/rental/rental.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -6
- package/src/ClassMappings/ItemClassMap.ts +7 -0
- package/src/ClassMappings/index.ts +3 -0
- package/src/components/rental/rental.ts +226 -0
- package/src/index.ts +2 -0
- 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 -27
- package/dist/src/components/agreement/agreement.js +0 -137
- 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/agreement-history/agreement-history.d.ts +0 -17
- package/dist/src/components/agreement-history/agreement-history.js +0 -51
- package/dist/src/components/agreement-history/agreement-history.js.map +0 -1
- package/dist/src/components/agreement-history/agreement-history.repository.d.ts +0 -8
- package/dist/src/components/agreement-history/agreement-history.repository.js +0 -67
- package/dist/src/components/agreement-history/agreement-history.repository.js.map +0 -1
- package/dist/src/components/agreement-signature/agreement-signature.d.ts +0 -27
- package/dist/src/components/agreement-signature/agreement-signature.js +0 -112
- package/dist/src/components/agreement-signature/agreement-signature.js.map +0 -1
- package/dist/src/components/agreement-signature/agreement-signature.repository.d.ts +0 -8
- package/dist/src/components/agreement-signature/agreement-signature.repository.js +0 -68
- package/dist/src/components/agreement-signature/agreement-signature.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.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 -29
- 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/agreement-signature-status.enum.d.ts +0 -4
- package/dist/src/enum/agreement-signature-status.enum.js +0 -9
- package/dist/src/enum/agreement-signature-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/hirer-type.enum.d.ts +0 -4
- package/dist/src/enum/hirer-type.enum.js +0 -9
- package/dist/src/enum/hirer-type.enum.js.map +0 -1
- package/dist/src/enum/index.d.ts +0 -7
- package/dist/src/enum/index.js +0 -16
- 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 -19
- package/dist/src/index.js +0 -51
- package/dist/src/index.js.map +0 -1
- package/dist/src/interfaces/agreemeent-signature-attr.interface.d.ts +0 -14
- package/dist/src/interfaces/agreemeent-signature-attr.interface.js +0 -3
- package/dist/src/interfaces/agreemeent-signature-attr.interface.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/agreement-history-attr.interface.d.ts +0 -7
- package/dist/src/interfaces/agreement-history-attr.interface.js +0 -3
- package/dist/src/interfaces/agreement-history-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 -9
- 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/interfaces/response-hirer-signature-attr.interface.d.ts +0 -14
- package/dist/src/interfaces/response-hirer-signature-attr.interface.js +0 -3
- package/dist/src/interfaces/response-hirer-signature-attr.interface.js.map +0 -1
- package/dist/src/models/agreement-history.entity.d.ts +0 -10
- package/dist/src/models/agreement-history.entity.js +0 -65
- package/dist/src/models/agreement-history.entity.js.map +0 -1
- package/dist/src/models/agreement-signature.entity.d.ts +0 -18
- package/dist/src/models/agreement-signature.entity.js +0 -101
- package/dist/src/models/agreement-signature.entity.js.map +0 -1
- package/dist/src/models/agreement.entity.d.ts +0 -14
- package/dist/src/models/agreement.entity.js +0 -70
- 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 -8
- package/dist/src/models/index.js +0 -18
- 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomei/rental",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0-staging.1",
|
|
4
4
|
"description": "Tomei Rental Package",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -57,13 +57,15 @@
|
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@tomei/activity-history": "^0.
|
|
60
|
+
"@tomei/activity-history": "^0.4.1",
|
|
61
61
|
"@tomei/config": "^0.3.21",
|
|
62
|
-
"@tomei/
|
|
63
|
-
"@tomei/
|
|
64
|
-
"
|
|
62
|
+
"@tomei/finance": "^0.11.7-staging.4",
|
|
63
|
+
"@tomei/general": "^0.21.7",
|
|
64
|
+
"@tomei/sso": "^0.60.4",
|
|
65
|
+
"@tomei/stock": "^0.18.1",
|
|
66
|
+
"luxon": "^3.6.1",
|
|
65
67
|
"reflect-metadata": "^0.2.2",
|
|
66
|
-
"sequelize": "^6.37.
|
|
68
|
+
"sequelize": "^6.37.7",
|
|
67
69
|
"sequelize-typescript": "^2.1.6"
|
|
68
70
|
},
|
|
69
71
|
"lint-staged": {
|
|
@@ -71,5 +73,8 @@
|
|
|
71
73
|
"prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
72
74
|
"eslint \"{src,apps,libs,test}/**/*.ts\" --fix"
|
|
73
75
|
]
|
|
76
|
+
},
|
|
77
|
+
"overrides": {
|
|
78
|
+
"glob": "^9.0.0"
|
|
74
79
|
}
|
|
75
80
|
}
|
|
@@ -22,6 +22,8 @@ import { AgreementSignatureRepository } from '../agreement-signature/agreement-s
|
|
|
22
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
|
+
import { DocType, Document, IAccountSystem } from '@tomei/finance';
|
|
26
|
+
import { ItemClassMap } from '../../ClassMappings/ItemClassMap';
|
|
25
27
|
|
|
26
28
|
export class Rental extends ObjectBase {
|
|
27
29
|
ObjectId: string;
|
|
@@ -40,6 +42,8 @@ export class Rental extends ObjectBase {
|
|
|
40
42
|
AgreementNo: string;
|
|
41
43
|
AccountType: RentalAccountTypeEnum;
|
|
42
44
|
JointHirers: JointHirer[] = [];
|
|
45
|
+
Invoices: Document[] = [];
|
|
46
|
+
Item: any;
|
|
43
47
|
protected _Status: RentalStatusEnum | string;
|
|
44
48
|
protected _EscheatmentYN: string = 'N';
|
|
45
49
|
protected _CreatedById: string;
|
|
@@ -1132,4 +1136,226 @@ export class Rental extends ObjectBase {
|
|
|
1132
1136
|
throw error;
|
|
1133
1137
|
}
|
|
1134
1138
|
}
|
|
1139
|
+
|
|
1140
|
+
public toJSON(): IRentalAttr {
|
|
1141
|
+
return {
|
|
1142
|
+
RentalId: this.RentalId,
|
|
1143
|
+
CustomerId: this.CustomerId,
|
|
1144
|
+
CustomerType: this.CustomerType,
|
|
1145
|
+
ItemId: this.ItemId,
|
|
1146
|
+
ItemType: this.ItemType,
|
|
1147
|
+
PriceId: this.PriceId,
|
|
1148
|
+
StartDateTime: this.StartDateTime,
|
|
1149
|
+
EndDateTime: this.EndDateTime,
|
|
1150
|
+
Status: this.Status,
|
|
1151
|
+
CancelRemarks: this.CancelRemarks,
|
|
1152
|
+
TerminateRemarks: this.TerminateRemarks,
|
|
1153
|
+
EscheatmentYN: this.EscheatmentYN,
|
|
1154
|
+
AgreementNo: this.AgreementNo,
|
|
1155
|
+
AccountType: this.AccountType,
|
|
1156
|
+
CreatedById: this.CreatedById,
|
|
1157
|
+
CreatedAt: this.CreatedAt,
|
|
1158
|
+
UpdatedById: this.UpdatedById,
|
|
1159
|
+
UpdatedAt: this.UpdatedAt,
|
|
1160
|
+
};
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
public async getInvoices(
|
|
1164
|
+
loginUser: LoginUser,
|
|
1165
|
+
dbTransaction: any,
|
|
1166
|
+
accountingSystem?: IAccountSystem,
|
|
1167
|
+
) {
|
|
1168
|
+
try {
|
|
1169
|
+
// Part 1: Privilege Checking
|
|
1170
|
+
// Call loginUser.checkPrivileges() by passing:
|
|
1171
|
+
// SystemCode: <get_from_app_config>
|
|
1172
|
+
// PrivilegeCode: "RENTAL_VIEW_INVOICE"
|
|
1173
|
+
const systemCode =
|
|
1174
|
+
ApplicationConfig.getComponentConfigValue('system-code');
|
|
1175
|
+
const isPrivileged = loginUser.checkPrivileges(
|
|
1176
|
+
systemCode,
|
|
1177
|
+
'RENTAL_VIEW_INVOICE',
|
|
1178
|
+
);
|
|
1179
|
+
|
|
1180
|
+
if (!isPrivileged) {
|
|
1181
|
+
throw new ClassError(
|
|
1182
|
+
'Rental',
|
|
1183
|
+
'RentalErrMsg01',
|
|
1184
|
+
"You do not have 'RENTAL_VIEW_INVOICE' privilege.",
|
|
1185
|
+
);
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
// Part 2: Validation
|
|
1189
|
+
// Make sure this._ObjectId exists, if not throw new ClassError by passing
|
|
1190
|
+
if (!this.ObjectId) {
|
|
1191
|
+
throw new ClassError(
|
|
1192
|
+
'Rental',
|
|
1193
|
+
'RentalErrMsg01',
|
|
1194
|
+
'ObjectId is missing.',
|
|
1195
|
+
);
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
// Part 3: Check Existing Invoices
|
|
1199
|
+
if (this.Invoices.length > 0) {
|
|
1200
|
+
return this.Invoices;
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
// Part 4: Retrieve Invoices and Returns
|
|
1204
|
+
const search = {
|
|
1205
|
+
DocType: DocType.INVOICE,
|
|
1206
|
+
RelatedObjectId: this.ObjectId,
|
|
1207
|
+
RelatedObjectType: this.ObjectType,
|
|
1208
|
+
};
|
|
1209
|
+
|
|
1210
|
+
const documents = await Document.findAll(
|
|
1211
|
+
loginUser,
|
|
1212
|
+
dbTransaction,
|
|
1213
|
+
undefined,
|
|
1214
|
+
undefined,
|
|
1215
|
+
search,
|
|
1216
|
+
undefined,
|
|
1217
|
+
accountingSystem,
|
|
1218
|
+
);
|
|
1219
|
+
|
|
1220
|
+
this.Invoices = documents.rows.map((doc) => {
|
|
1221
|
+
const document = new Document(dbTransaction, doc);
|
|
1222
|
+
return document;
|
|
1223
|
+
});
|
|
1224
|
+
|
|
1225
|
+
return this.Invoices;
|
|
1226
|
+
} catch (error) {
|
|
1227
|
+
throw error;
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
public async getItem(dbTransaction: any): Promise<any> {
|
|
1232
|
+
if (this.Item) {
|
|
1233
|
+
return this.Item;
|
|
1234
|
+
} else {
|
|
1235
|
+
const ItemClass = ItemClassMap[this.ItemType];
|
|
1236
|
+
|
|
1237
|
+
if (!ItemClass || typeof ItemClass.init !== 'function') {
|
|
1238
|
+
throw new Error(`Invalid or unregistered ItemType: ${this.ItemType}`);
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
ItemClass._Repo = ItemClass._Repo || ItemClass.getRepo();
|
|
1242
|
+
|
|
1243
|
+
if (!ItemClass._Repo) {
|
|
1244
|
+
throw new Error(
|
|
1245
|
+
`ItemType ${this.ItemType} does not have a repository.`,
|
|
1246
|
+
);
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
const itemInstance = await ItemClass.init(this.ItemId, dbTransaction);
|
|
1250
|
+
|
|
1251
|
+
if (!itemInstance) {
|
|
1252
|
+
throw new Error(`${this.ItemType} not found with ID ${this.ItemId}`);
|
|
1253
|
+
}
|
|
1254
|
+
this.Item = itemInstance;
|
|
1255
|
+
|
|
1256
|
+
// Make sure item has setAvailable method
|
|
1257
|
+
if (typeof this.Item.setAvailable !== 'function') {
|
|
1258
|
+
throw new Error(`${this.ItemType} does not implement setAvailable()`);
|
|
1259
|
+
}
|
|
1260
|
+
return this.Item;
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
public async cancel(
|
|
1265
|
+
loginUser: LoginUser,
|
|
1266
|
+
dbTransaction: any,
|
|
1267
|
+
remarks: string,
|
|
1268
|
+
): Promise<Rental> {
|
|
1269
|
+
try {
|
|
1270
|
+
// Part 1: Privilege Checking
|
|
1271
|
+
const systemCode =
|
|
1272
|
+
ApplicationConfig.getComponentConfigValue('system-code');
|
|
1273
|
+
const isPrivileged = await loginUser.checkPrivileges(
|
|
1274
|
+
systemCode,
|
|
1275
|
+
'RENTAL_CANCEL',
|
|
1276
|
+
);
|
|
1277
|
+
|
|
1278
|
+
if (!isPrivileged) {
|
|
1279
|
+
throw new ClassError(
|
|
1280
|
+
'Rental',
|
|
1281
|
+
'RentalErrMsg01',
|
|
1282
|
+
"You do not have 'RENTAL_CANCEL' privilege.",
|
|
1283
|
+
);
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
// Part 2: Validation
|
|
1287
|
+
if (!this.ObjectId) {
|
|
1288
|
+
throw new ClassError(
|
|
1289
|
+
'Rental',
|
|
1290
|
+
'RentalErrMsg01',
|
|
1291
|
+
'Rental not found. Rental Id is empty.',
|
|
1292
|
+
);
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
if (
|
|
1296
|
+
this.Status === RentalStatusEnum.ACTIVE ||
|
|
1297
|
+
this.Status === RentalStatusEnum.SUSPENDED
|
|
1298
|
+
) {
|
|
1299
|
+
throw new ClassError(
|
|
1300
|
+
'Rental',
|
|
1301
|
+
'RentalErrMsg01',
|
|
1302
|
+
`Rental already ${this.Status}, please do termination process.`,
|
|
1303
|
+
);
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
if (!remarks) {
|
|
1307
|
+
throw new ClassError(
|
|
1308
|
+
'Rental',
|
|
1309
|
+
'RentalErrMsg01',
|
|
1310
|
+
'Cancellation remarks is required.',
|
|
1311
|
+
);
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
// Part 3: Capture Record Info Before Changes
|
|
1315
|
+
const entityValueBefore = this.toJSON();
|
|
1316
|
+
|
|
1317
|
+
// Part 4: Update Rental Status and Remarks
|
|
1318
|
+
this._Status = RentalStatusEnum.CANCELLED;
|
|
1319
|
+
this.CancelRemarks = remarks;
|
|
1320
|
+
this._UpdatedById = loginUser.ObjectId;
|
|
1321
|
+
this._UpdatedAt = new Date();
|
|
1322
|
+
|
|
1323
|
+
// Part 5: Update Rental Record
|
|
1324
|
+
await Rental._Repo.update(
|
|
1325
|
+
{
|
|
1326
|
+
Status: this.Status,
|
|
1327
|
+
CancelRemarks: this.CancelRemarks,
|
|
1328
|
+
UpdatedById: this.UpdatedById,
|
|
1329
|
+
UpdatedAt: this.UpdatedAt,
|
|
1330
|
+
},
|
|
1331
|
+
{
|
|
1332
|
+
where: {
|
|
1333
|
+
RentalId: this.RentalId,
|
|
1334
|
+
},
|
|
1335
|
+
transaction: dbTransaction,
|
|
1336
|
+
},
|
|
1337
|
+
);
|
|
1338
|
+
|
|
1339
|
+
// Part 6: Mark Item as Available
|
|
1340
|
+
const item = await this.getItem(dbTransaction);
|
|
1341
|
+
|
|
1342
|
+
await item.setAvailable(loginUser, dbTransaction);
|
|
1343
|
+
|
|
1344
|
+
// Part 7: Capture Record Info After Changes
|
|
1345
|
+
const entityValueAfter = this.toJSON();
|
|
1346
|
+
// Part 8: Record Activity
|
|
1347
|
+
const activity = new Activity();
|
|
1348
|
+
activity.ActivityId = activity.createId();
|
|
1349
|
+
activity.Action = ActionEnum.UPDATE;
|
|
1350
|
+
activity.Description = 'Rental Cancellation';
|
|
1351
|
+
activity.EntityType = this.ObjectType;
|
|
1352
|
+
activity.EntityId = this.ObjectId;
|
|
1353
|
+
activity.EntityValueBefore = JSON.stringify(entityValueBefore);
|
|
1354
|
+
activity.EntityValueAfter = JSON.stringify(entityValueAfter);
|
|
1355
|
+
await activity.create(loginUser.ObjectId, dbTransaction);
|
|
1356
|
+
return this;
|
|
1357
|
+
} catch (error) {
|
|
1358
|
+
throw error;
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1135
1361
|
}
|
package/src/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { AgreementSignature } from './components/agreement-signature/agreement-s
|
|
|
12
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
|
+
import { ItemClassMap } from './ClassMappings/ItemClassMap';
|
|
15
16
|
import * as rentalDb from './database';
|
|
16
17
|
export * from './interfaces';
|
|
17
18
|
export * from './models';
|
|
@@ -33,4 +34,5 @@ export {
|
|
|
33
34
|
AgreementSignatureRepository,
|
|
34
35
|
AgreementHistory,
|
|
35
36
|
AgreementHistoryRepository,
|
|
37
|
+
ItemClassMap,
|
|
36
38
|
};
|
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,27 +0,0 @@
|
|
|
1
|
-
import { ObjectBase } from '@tomei/general';
|
|
2
|
-
import { AggrementStatusEnum } from '../../enum/aggrement-status.enum';
|
|
3
|
-
import { IAgreementAttr } from '../../interfaces/agreement-attr.interface';
|
|
4
|
-
import { LoginUser } from '@tomei/sso';
|
|
5
|
-
import { AgreementSignatureRepository } from '../agreement-signature/agreement-signature.repository';
|
|
6
|
-
import { IResponseAgreementSignature } from '../../interfaces/response-hirer-signature-attr.interface';
|
|
7
|
-
import { AgreementHistoryRepository } from '../agreement-history/agreement-history.repository';
|
|
8
|
-
import { IAgreementHistoryAttr } from 'interfaces/agreement-history-attr.interface';
|
|
9
|
-
export declare class Agreement extends ObjectBase {
|
|
10
|
-
ObjectId: string;
|
|
11
|
-
ObjectName: string;
|
|
12
|
-
ObjectType: string;
|
|
13
|
-
TableName: string;
|
|
14
|
-
Status: AggrementStatusEnum;
|
|
15
|
-
DateSigned: Date;
|
|
16
|
-
MediaId: string;
|
|
17
|
-
private static _Repo;
|
|
18
|
-
protected static _AgreementSignatureRepo: AgreementSignatureRepository;
|
|
19
|
-
protected static _AgreementHistoryRepo: AgreementHistoryRepository;
|
|
20
|
-
get AgreementNo(): string;
|
|
21
|
-
set AgreementNo(value: string);
|
|
22
|
-
protected constructor(agreementAttr?: IAgreementAttr);
|
|
23
|
-
static init(agreementNo?: string, dbTransaction?: any): Promise<Agreement>;
|
|
24
|
-
static getSignatureList(loginUser: LoginUser, agreementNo: string, dbTransaction: any): Promise<IResponseAgreementSignature[]>;
|
|
25
|
-
getAllActivities(loginUser: LoginUser, dbTransaction?: any): Promise<IAgreementHistoryAttr[]>;
|
|
26
|
-
createActivity(activityCompleted: string, MediaId: string, dbTransaction: any, loginUser: LoginUser): Promise<IAgreementHistoryAttr>;
|
|
27
|
-
}
|
|
@@ -1,137 +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
|
-
const config_1 = require("@tomei/config");
|
|
16
|
-
const agreement_signature_repository_1 = require("../agreement-signature/agreement-signature.repository");
|
|
17
|
-
const rentalDb = require("../../database");
|
|
18
|
-
const sequelize_1 = require("sequelize");
|
|
19
|
-
const agreement_history_repository_1 = require("../agreement-history/agreement-history.repository");
|
|
20
|
-
const activity_history_1 = require("@tomei/activity-history");
|
|
21
|
-
class Agreement extends general_1.ObjectBase {
|
|
22
|
-
get AgreementNo() {
|
|
23
|
-
return this.ObjectId;
|
|
24
|
-
}
|
|
25
|
-
set AgreementNo(value) {
|
|
26
|
-
this.ObjectId = value;
|
|
27
|
-
}
|
|
28
|
-
constructor(agreementAttr) {
|
|
29
|
-
super();
|
|
30
|
-
this.ObjectType = 'Agreement';
|
|
31
|
-
this.TableName = 'rental_Agreement';
|
|
32
|
-
if (agreementAttr) {
|
|
33
|
-
this.ObjectId = agreementAttr.AgreementNo;
|
|
34
|
-
this.Status = agreementAttr.Status;
|
|
35
|
-
this.DateSigned = agreementAttr.DateSigned;
|
|
36
|
-
this.MediaId = agreementAttr.MediaId;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
static init(agreementNo, dbTransaction) {
|
|
40
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
try {
|
|
42
|
-
if (agreementNo) {
|
|
43
|
-
const agreement = yield this._Repo.findByPk(agreementNo, dbTransaction);
|
|
44
|
-
return new Agreement(agreement === null || agreement === void 0 ? void 0 : agreement.get({ plain: true }));
|
|
45
|
-
}
|
|
46
|
-
return new Agreement();
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
throw error;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
static getSignatureList(loginUser, agreementNo, dbTransaction) {
|
|
54
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
try {
|
|
56
|
-
const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
|
|
57
|
-
const isPrivileged = loginUser.checkPrivileges(systemCode, 'AGREEMENT_SIGNATURE_LIST');
|
|
58
|
-
if (!isPrivileged) {
|
|
59
|
-
throw new general_1.ClassError('Agreement', 'AgreementErrMsg01', "You do not have 'AGREEMENT_SIGNATURE_LIST' privilege.");
|
|
60
|
-
}
|
|
61
|
-
if (!agreementNo) {
|
|
62
|
-
throw new general_1.ClassError('AgreementNo', 'AgreementNoErrMsg01', 'AgreementNo is missing');
|
|
63
|
-
}
|
|
64
|
-
const query = `
|
|
65
|
-
SELECT
|
|
66
|
-
hs.*
|
|
67
|
-
FROM
|
|
68
|
-
rental_AgreementSignature hs
|
|
69
|
-
WHERE
|
|
70
|
-
hs.AgreementNo = '${agreementNo}'
|
|
71
|
-
`;
|
|
72
|
-
const db = rentalDb.getConnection();
|
|
73
|
-
const signatures = yield db.query(query, {
|
|
74
|
-
type: sequelize_1.QueryTypes.SELECT,
|
|
75
|
-
transaction: dbTransaction,
|
|
76
|
-
});
|
|
77
|
-
return signatures;
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
throw error;
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
getAllActivities(loginUser, dbTransaction) {
|
|
85
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
try {
|
|
87
|
-
const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
|
|
88
|
-
const isPrivileged = loginUser.checkPrivileges(systemCode, 'RENTAL_AGREEMENT_VIEW');
|
|
89
|
-
if (!isPrivileged) {
|
|
90
|
-
throw new general_1.ClassError('Agreement', 'AgreementErrMsg02', "You do not have 'RENTAL_AGREEMENT_VIEW' privilege.");
|
|
91
|
-
}
|
|
92
|
-
const activities = yield Agreement._AgreementHistoryRepo.findAll({
|
|
93
|
-
where: { AgreementNo: this.ObjectId },
|
|
94
|
-
order: [['CreatedAt', 'DESC']],
|
|
95
|
-
transaction: dbTransaction,
|
|
96
|
-
});
|
|
97
|
-
return activities;
|
|
98
|
-
}
|
|
99
|
-
catch (error) {
|
|
100
|
-
throw error;
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
createActivity(activityCompleted, MediaId, dbTransaction, loginUser) {
|
|
105
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
-
try {
|
|
107
|
-
const activity = yield Agreement._AgreementHistoryRepo.create({
|
|
108
|
-
AgreementNo: this.ObjectId,
|
|
109
|
-
MediaId: MediaId,
|
|
110
|
-
ActivityCompleted: activityCompleted,
|
|
111
|
-
CreatedAt: new Date(),
|
|
112
|
-
}, {
|
|
113
|
-
transaction: dbTransaction,
|
|
114
|
-
});
|
|
115
|
-
const entityValueAfter = activity.get({ plain: true });
|
|
116
|
-
const activityHistory = new activity_history_1.Activity();
|
|
117
|
-
activityHistory.ActivityId = entityValueAfter.HistoryId;
|
|
118
|
-
activityHistory.Action = activity_history_1.ActionEnum.CREATE;
|
|
119
|
-
activityHistory.Description = activityCompleted;
|
|
120
|
-
activityHistory.EntityId = activity.HistoryId.toString();
|
|
121
|
-
activityHistory.EntityType = 'RentalAgreementHistory';
|
|
122
|
-
activityHistory.EntityValueBefore = JSON.stringify({});
|
|
123
|
-
activityHistory.EntityValueAfter = JSON.stringify(entityValueAfter);
|
|
124
|
-
yield activityHistory.create(loginUser.ObjectId, dbTransaction);
|
|
125
|
-
return activity;
|
|
126
|
-
}
|
|
127
|
-
catch (error) {
|
|
128
|
-
throw error;
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
exports.Agreement = Agreement;
|
|
134
|
-
Agreement._Repo = new agreement_repository_1.AgreementRepository();
|
|
135
|
-
Agreement._AgreementSignatureRepo = new agreement_signature_repository_1.AgreementSignatureRepository();
|
|
136
|
-
Agreement._AgreementHistoryRepo = new agreement_history_repository_1.AgreementHistoryRepository();
|
|
137
|
-
//# sourceMappingURL=agreement.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agreement.js","sourceRoot":"","sources":["../../../../src/components/agreement/agreement.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAAwD;AAGxD,iEAA6D;AAC7D,0CAAkD;AAElD,0GAAqG;AACrG,2CAA2C;AAC3C,yCAA8C;AAE9C,oGAA+F;AAE/F,8DAA+D;AAE/D,MAAa,SAAU,SAAQ,oBAAU;IAavC,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;QAnBV,eAAU,GAAW,WAAW,CAAC;QACjC,cAAS,GAAG,kBAAkB,CAAC;QAmB7B,IAAI,aAAa,EAAE,CAAC;YAClB,IAAI,CAAC,QAAQ,GAAG,aAAa,CAAC,WAAW,CAAC;YAC1C,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;Y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AAI,EAAE;iBACtB,EACD;oBACE,WAAW,EAAE,aAAa;iBAC3B,CACF,CAAC;gBAEF,MAAM,gBAAgB,GAAG,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;gBACvD,MAAM,eAAe,GAAG,IAAI,2BAAQ,EAAE,CAAC;gBACvC,eAAe,CAAC,UAAU,GAAG,gBAAgB,CAAC,SAAS,CAAC;gBACxD,eAAe,CAAC,MAAM,GAAG,6BAAU,CAAC,MAAM,CAAC;gBAC3C,eAAe,CAAC,WAAW,GAAG,iBAAiB,CAAC;gBAChD,eAAe,CAAC,QAAQ,GAAG,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;gBACzD,eAAe,CAAC,UAAU,GAAG,wBAAwB,CAAC;gBACtD,eAAe,CAAC,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;gBACvD,eAAe,CAAC,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;gBACpE,MAAM,eAAe,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;gBAEhE,OAAO,QAAQ,CAAC;YAClB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;KAAA;;AAzKH,8BA0KC;AAjKgB,eAAK,GAAG,IAAI,0CAAmB,EAAE,AAA5B,CAA6B;AAChC,iCAAuB,GAAG,IAAI,6DAA4B,EAAE,AAArC,CAAsC;AAC7D,+BAAqB,GAAG,IAAI,yDAA0B,EAAE,AAAnC,CAAoC"}
|
|
@@ -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
|
-
}
|
|
@@ -1,67 +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.AgreementRepository = void 0;
|
|
13
|
-
const general_1 = require("@tomei/general");
|
|
14
|
-
const agreement_entity_1 = require("../../models/agreement.entity");
|
|
15
|
-
class AgreementRepository extends general_1.RepositoryBase {
|
|
16
|
-
constructor() {
|
|
17
|
-
super(agreement_entity_1.AgreementModel);
|
|
18
|
-
}
|
|
19
|
-
findByPk(id, transaction) {
|
|
20
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
try {
|
|
22
|
-
const result = yield agreement_entity_1.AgreementModel.findByPk(id, {
|
|
23
|
-
transaction: transaction,
|
|
24
|
-
});
|
|
25
|
-
return result;
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
throw new Error(`An Error occured when fetching : ${error.message}`);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
delete(AgreementNo, dbTransaction) {
|
|
33
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
try {
|
|
35
|
-
const options = {
|
|
36
|
-
where: {
|
|
37
|
-
AgreementNo,
|
|
38
|
-
},
|
|
39
|
-
transaction: dbTransaction,
|
|
40
|
-
};
|
|
41
|
-
yield agreement_entity_1.AgreementModel.destroy(options);
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
throw new Error(`An Error occured when delete : ${error.message}`);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
findAndCountAll(options) {
|
|
49
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
try {
|
|
51
|
-
let Agreements;
|
|
52
|
-
if (options) {
|
|
53
|
-
Agreements = yield agreement_entity_1.AgreementModel.findAndCountAll(options);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
Agreements = yield agreement_entity_1.AgreementModel.findAndCountAll();
|
|
57
|
-
}
|
|
58
|
-
return Agreements;
|
|
59
|
-
}
|
|
60
|
-
catch (error) {
|
|
61
|
-
throw new Error(`An Error occured when retriving : ${error.message}`);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
exports.AgreementRepository = AgreementRepository;
|
|
67
|
-
//# sourceMappingURL=agreement.repository.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agreement.repository.js","sourceRoot":"","sources":["../../../../src/components/agreement/agreement.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAAiE;AACjE,oEAA+D;AAE/D,MAAa,mBACX,SAAQ,wBAA8B;IAGtC;QACE,KAAK,CAAC,iCAAc,CAAC,CAAC;IACxB,CAAC;IAEK,QAAQ,CACZ,EAAU,EACV,WAAiB;;YAEjB,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,iCAAc,CAAC,QAAQ,CAAC,EAAE,EAAE;oBAC/C,WAAW,EAAE,WAAW;iBACzB,CAAC,CAAC;gBAEH,OAAO,MAAM,CAAC;YAChB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,KAAK,CAAC,oCAAoC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACvE,CAAC;QACH,CAAC;KAAA;IAEK,MAAM,CAAC,WAAmB,EAAE,aAAmB;;YACnD,IAAI,CAAC;gBACH,MAAM,OAAO,GAAG;oBACd,KAAK,EAAE;wBACL,WAAW;qBACZ;oBACD,WAAW,EAAE,aAAa;iBAC3B,CAAC;gBACF,MAAM,iCAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACxC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,KAAK,CAAC,kCAAkC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACrE,CAAC;QACH,CAAC;KAAA;IAEK,eAAe,CAAC,OAAa;;YACjC,IAAI,CAAC;gBACH,IAAI,UAAe,CAAC;gBACpB,IAAI,OAAO,EAAE,CAAC;oBACZ,UAAU,GAAG,MAAM,iCAAc,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;gBAC7D,CAAC;qBAAM,CAAC;oBACN,UAAU,GAAG,MAAM,iCAAc,CAAC,eAAe,EAAE,CAAC;gBACtD,CAAC;gBACD,OAAO,UAAU,CAAC;YACpB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,KAAK,CAAC,qCAAqC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACxE,CAAC;QACH,CAAC;KAAA;CACF;AAlDD,kDAkDC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ObjectBase } from '@tomei/general';
|
|
2
|
-
import { IAgreementHistoryAttr } from '../../interfaces/agreement-history-attr.interface';
|
|
3
|
-
export declare class AgreementHistory extends ObjectBase implements IAgreementHistoryAttr {
|
|
4
|
-
ObjectId: string;
|
|
5
|
-
ObjectName: string;
|
|
6
|
-
ObjectType: string;
|
|
7
|
-
TableName: string;
|
|
8
|
-
AgreementNo: string;
|
|
9
|
-
ActivityCompleted: string;
|
|
10
|
-
MediaId: string;
|
|
11
|
-
CreatedAt: Date;
|
|
12
|
-
private static _Repo;
|
|
13
|
-
get HistoryId(): number;
|
|
14
|
-
set HistoryId(value: number);
|
|
15
|
-
protected constructor(agreementAttr?: IAgreementHistoryAttr);
|
|
16
|
-
static init(historyId: number, dbTransaction?: any): Promise<AgreementHistory>;
|
|
17
|
-
}
|
|
@@ -1,51 +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.AgreementHistory = void 0;
|
|
13
|
-
const general_1 = require("@tomei/general");
|
|
14
|
-
const agreement_history_repository_1 = require("./agreement-history.repository");
|
|
15
|
-
class AgreementHistory extends general_1.ObjectBase {
|
|
16
|
-
get HistoryId() {
|
|
17
|
-
return parseInt(this.ObjectId);
|
|
18
|
-
}
|
|
19
|
-
set HistoryId(value) {
|
|
20
|
-
this.ObjectId = value.toString();
|
|
21
|
-
}
|
|
22
|
-
constructor(agreementAttr) {
|
|
23
|
-
super();
|
|
24
|
-
this.ObjectType = 'AgreementHistory';
|
|
25
|
-
this.TableName = 'rental_AgreementHistory';
|
|
26
|
-
if (agreementAttr) {
|
|
27
|
-
this.HistoryId = agreementAttr.HistoryId;
|
|
28
|
-
this.AgreementNo = agreementAttr.AgreementNo;
|
|
29
|
-
this.ActivityCompleted = agreementAttr.ActivityCompleted;
|
|
30
|
-
this.MediaId = agreementAttr.MediaId;
|
|
31
|
-
this.CreatedAt = agreementAttr.CreatedAt;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
static init(historyId, dbTransaction) {
|
|
35
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
try {
|
|
37
|
-
if (historyId) {
|
|
38
|
-
const ah = yield this._Repo.findByPk(historyId.toString(), dbTransaction);
|
|
39
|
-
return new AgreementHistory(ah === null || ah === void 0 ? void 0 : ah.get({ plain: true }));
|
|
40
|
-
}
|
|
41
|
-
return new AgreementHistory();
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
throw error;
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.AgreementHistory = AgreementHistory;
|
|
50
|
-
AgreementHistory._Repo = new agreement_history_repository_1.AgreementHistoryRepository();
|
|
51
|
-
//# sourceMappingURL=agreement-history.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agreement-history.js","sourceRoot":"","sources":["../../../../src/components/agreement-history/agreement-history.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA4C;AAC5C,iFAA4E;AAI5E,MAAa,gBACX,SAAQ,oBAAU;IAclB,IAAI,SAAS;QACX,OAAO,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;IAED,IAAI,SAAS,CAAC,KAAa;QACzB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;IACnC,CAAC;IAED,YAAsB,aAAqC;QACzD,KAAK,EAAE,CAAC;QAlBV,eAAU,GAAW,kBAAkB,CAAC;QACxC,cAAS,GAAG,yBAAyB,CAAC;QAkBpC,IAAI,aAAa,EAAE,CAAC;YAClB,IAAI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