law-common 10.45.3-beta.1 → 10.45.3-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -31,7 +31,9 @@ class BaseEntityModel {
|
|
|
31
31
|
console.warn(`[populateRelationsByIndex] Missing child key "${childKey}" in parent "${parentKey}" on entity "${this.entityName}". Parent value:`, this[parentKey]);
|
|
32
32
|
continue;
|
|
33
33
|
}
|
|
34
|
-
foundRelatedEntities = [
|
|
34
|
+
foundRelatedEntities = [
|
|
35
|
+
relatedEntitiesIndex[this[parentKey][childKey]],
|
|
36
|
+
];
|
|
35
37
|
}
|
|
36
38
|
else {
|
|
37
39
|
// foundRelatedEntities = relatedEntities[this[thisKey]] ? [relatedEntities[this[thisKey]]] : [];
|
|
@@ -10,30 +10,30 @@ exports.entityMapToEntityIndexMap = entityMapToEntityIndexMap;
|
|
|
10
10
|
exports.parseEntitiesWithoutModels = parseEntitiesWithoutModels;
|
|
11
11
|
exports.removeEntityById = removeEntityById;
|
|
12
12
|
const entity_utils_interface_1 = require("../interface/entity.utils.interface");
|
|
13
|
+
const address_book_model_1 = require("./address_book.model");
|
|
13
14
|
const bank_entity_model_1 = require("./bank.entity.model");
|
|
14
15
|
const base_entity_model_1 = require("./base.entity.model");
|
|
15
16
|
const billing_reimbursement_expense_entity_model_1 = require("./billing-reimbursement-expense.entity.model");
|
|
16
17
|
const billing_timesheet_entity_model_1 = require("./billing-timesheet.entity.model");
|
|
18
|
+
const billing_transaction_model_1 = require("./billing-transaction.model");
|
|
17
19
|
const billing_entity_model_1 = require("./billing.entity.model");
|
|
18
20
|
const client_affiliate_entity_model_1 = require("./client-affiliate.entity.model");
|
|
19
21
|
const client_entity_model_1 = require("./client.entity.model");
|
|
22
|
+
const configuration_model_1 = require("./configuration.model");
|
|
23
|
+
const country_entity_model_1 = require("./country.entity.model");
|
|
24
|
+
const gst_rate_entity_model_1 = require("./gst_rate.entity.model");
|
|
20
25
|
const holiday_entity_model_1 = require("./holiday.entity.model");
|
|
21
26
|
const leave_entity_model_1 = require("./leave.entity.model");
|
|
22
27
|
const leave_count_entity_model_1 = require("./leave_count.entity.model");
|
|
23
|
-
const
|
|
28
|
+
const organization_type_entity_model_1 = require("./organization_type.entity.model");
|
|
24
29
|
const project_user_mapping_entity_model_1 = require("./project-user-mapping.entity.model");
|
|
25
30
|
const project_entity_model_1 = require("./project.entity.model");
|
|
26
31
|
const reimbursement_expense_entity_model_1 = require("./reimbursement-expense.entity.model");
|
|
27
32
|
const reimbursement_entity_model_1 = require("./reimbursement.entity.model");
|
|
33
|
+
const state_entity_model_1 = require("./state.entity.model");
|
|
28
34
|
const task_entity_model_1 = require("./task.entity.model");
|
|
29
35
|
const timesheet_entity_model_1 = require("./timesheet.entity.model");
|
|
30
36
|
const user_entity_model_1 = require("./user.entity.model");
|
|
31
|
-
const country_entity_model_1 = require("./country.entity.model");
|
|
32
|
-
const address_book_model_1 = require("./address_book.model");
|
|
33
|
-
const billing_transaction_model_1 = require("./billing-transaction.model");
|
|
34
|
-
const state_entity_model_1 = require("./state.entity.model");
|
|
35
|
-
const gst_rate_entity_model_1 = require("./gst_rate.entity.model");
|
|
36
|
-
const organization_type_entity_model_1 = require("./organization_type.entity.model");
|
|
37
37
|
function mapToIndex(entityMap) {
|
|
38
38
|
return Object.keys(entityMap).reduce((acc, key) => {
|
|
39
39
|
// @ts-ignore
|
|
@@ -92,19 +92,23 @@ function entityMapToModels(entityMap) {
|
|
|
92
92
|
if (!(entityName in exports.entityEnumToEntityModel)) {
|
|
93
93
|
throw new Error(`Unknown entity: ${entityName}`);
|
|
94
94
|
}
|
|
95
|
-
entityMap[entityName] = entityMap[entityName].map((entity) =>
|
|
95
|
+
entityMap[entityName] = entityMap[entityName].map((entity) => exports.entityEnumToEntityModel[entityName](
|
|
96
96
|
// @ts-ignore
|
|
97
|
-
|
|
97
|
+
entity));
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
function parseEntities(json, baseEntity, entityMap) {
|
|
101
|
-
var _a;
|
|
102
101
|
if (!(baseEntity in exports.entityEnumToEntityModel)) {
|
|
103
102
|
throw new Error(`Unknown entity: ${baseEntity}`);
|
|
104
103
|
}
|
|
105
|
-
entityMap
|
|
104
|
+
console.log("entityMap 1", entityMap);
|
|
105
|
+
console.log("ssssssssssssssssssssssssss");
|
|
106
|
+
entityMap[baseEntity] = (entityMap[baseEntity] && entityMap[baseEntity].length > 0
|
|
107
|
+
? [...entityMap[baseEntity], ...json["baseEntities"]]
|
|
108
|
+
: json["baseEntities"]).map(
|
|
106
109
|
// @ts-ignore
|
|
107
110
|
(e) => exports.entityEnumToEntityModel[baseEntity](e));
|
|
111
|
+
console.log("entityMap 2", entityMap);
|
|
108
112
|
if (json["relatedEntities"]) {
|
|
109
113
|
const relatedEntities = json["relatedEntities"];
|
|
110
114
|
for (const entityName in relatedEntities) {
|
|
@@ -162,9 +166,10 @@ class EntityModelRelationHelper {
|
|
|
162
166
|
if (!(entityName in exports.entityEnumToEntityModel)) {
|
|
163
167
|
throw new Error(`Unknown entity: ${entityName}`);
|
|
164
168
|
}
|
|
165
|
-
this.entityModelMap[entityName] =
|
|
166
|
-
|
|
167
|
-
|
|
169
|
+
this.entityModelMap[entityName] =
|
|
170
|
+
this.entityMap[entityName].map((entity) => exports.entityEnumToEntityModel[entityName
|
|
171
|
+
// @ts-ignore
|
|
172
|
+
](entity));
|
|
168
173
|
}
|
|
169
174
|
return this;
|
|
170
175
|
}
|
|
@@ -193,7 +198,8 @@ class EntityModelRelationHelper {
|
|
|
193
198
|
}
|
|
194
199
|
populateRelationsByEntityEnum(entityEnum) {
|
|
195
200
|
for (const key of Object.keys(this.entityModelIndexMap[entityEnum] || {})) {
|
|
196
|
-
const entityModel = this
|
|
201
|
+
const entityModel = this
|
|
202
|
+
.entityModelIndexMap[entityEnum][key];
|
|
197
203
|
entityModel.populateRelationsByIndex(this.entityModelIndexMap);
|
|
198
204
|
}
|
|
199
205
|
}
|
|
@@ -202,9 +208,12 @@ class EntityModelRelationHelper {
|
|
|
202
208
|
}
|
|
203
209
|
addEntityModel(entityModel, config = { populateRelations: false }) {
|
|
204
210
|
const entityEnum = entityModel.entityName;
|
|
205
|
-
this.entityModelIndexMap[entityEnum] =
|
|
211
|
+
this.entityModelIndexMap[entityEnum] =
|
|
212
|
+
this.entityModelIndexMap[entityEnum] || {};
|
|
206
213
|
// @ts-ignore
|
|
207
|
-
this.entityModelIndexMap[entityEnum][entityModel.id] =
|
|
214
|
+
this.entityModelIndexMap[entityEnum][entityModel.id] =
|
|
215
|
+
// @ts-ignore
|
|
216
|
+
entityModel;
|
|
208
217
|
if (config.populateRelations) {
|
|
209
218
|
this.populateRelationsByEntityModel(entityModel);
|
|
210
219
|
}
|
|
@@ -219,9 +228,12 @@ class EntityModelRelationHelper {
|
|
|
219
228
|
}
|
|
220
229
|
updateEntityModel(entityModel, config = { populateRelations: false }) {
|
|
221
230
|
const entityEnum = entityModel.entityName;
|
|
222
|
-
this.entityModelIndexMap[entityEnum] =
|
|
231
|
+
this.entityModelIndexMap[entityEnum] =
|
|
232
|
+
this.entityModelIndexMap[entityEnum] || {};
|
|
223
233
|
// @ts-ignore
|
|
224
|
-
this.entityModelIndexMap[entityEnum][entityModel.id] =
|
|
234
|
+
this.entityModelIndexMap[entityEnum][entityModel.id] =
|
|
235
|
+
// @ts-ignore
|
|
236
|
+
entityModel;
|
|
225
237
|
if (config.populateRelations) {
|
|
226
238
|
this.populateRelationsByEntityModel(entityModel);
|
|
227
239
|
}
|