law-common 10.18.1-beta.2 → 10.18.1-beta.20
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/api/index.d.ts +1 -0
- package/dist/src/api/index.js +1 -0
- package/dist/src/api/interface/billing.update.dto.interface.d.ts +5 -3
- package/dist/src/api/interface/project-user-mapping.entity.api.d.ts +3 -0
- package/dist/src/api/interface/project-user-mapping.entity.api.js +2 -0
- package/dist/src/entities/enums/relation-type.enum.d.ts +4 -0
- package/dist/src/entities/enums/relation-type.enum.js +8 -0
- package/dist/src/entities/index.d.ts +17 -0
- package/dist/src/entities/index.js +17 -0
- package/dist/src/entities/interface/entity.utils.interface.d.ts +23 -0
- package/dist/src/entities/interface/relation-config.interface.d.ts +16 -0
- package/dist/src/entities/interface/relation-config.interface.js +2 -0
- package/dist/src/entities/model/bank.entity.model.d.ts +4 -1
- package/dist/src/entities/model/bank.entity.model.js +10 -4
- package/dist/src/entities/model/base.entity.model.d.ts +8 -0
- package/dist/src/entities/model/base.entity.model.js +69 -0
- package/dist/src/entities/model/billing-reimbursement-expense.entity.model.d.ts +25 -0
- package/dist/src/entities/model/billing-reimbursement-expense.entity.model.js +35 -0
- package/dist/src/entities/model/billing-timesheet.entity.model.d.ts +26 -0
- package/dist/src/entities/model/billing-timesheet.entity.model.js +36 -0
- package/dist/src/entities/model/billing.entity.model.d.ts +85 -0
- package/dist/src/entities/model/billing.entity.model.js +246 -0
- package/dist/src/entities/model/client-affiliate.entity.model.d.ts +19 -0
- package/dist/src/entities/model/client-affiliate.entity.model.js +30 -0
- package/dist/src/entities/model/client.entity.model.d.ts +35 -0
- package/dist/src/entities/model/client.entity.model.js +50 -0
- package/dist/src/entities/model/configuration.model.d.ts +8 -9
- package/dist/src/entities/model/configuration.model.js +11 -5
- package/dist/src/entities/model/designation.entity.model.d.ts +8 -5
- package/dist/src/entities/model/designation.entity.model.js +28 -9
- package/dist/src/entities/model/entity.model.interface.d.ts +8 -0
- package/dist/src/entities/model/entity.model.interface.js +84 -0
- package/dist/src/entities/model/holiday.entity.model.d.ts +1 -19
- package/dist/src/entities/model/holiday.entity.model.js +42 -29
- package/dist/src/entities/model/leave.entity.model.d.ts +5 -5
- package/dist/src/entities/model/leave.entity.model.js +4 -1
- package/dist/src/entities/model/project-user-mapping.entity.model.d.ts +26 -0
- package/dist/src/entities/model/project-user-mapping.entity.model.js +49 -0
- package/dist/src/entities/model/project.entity.model.d.ts +40 -0
- package/dist/src/entities/model/project.entity.model.js +105 -0
- package/dist/src/entities/model/reimbursement-expense.entity.model.d.ts +27 -0
- package/dist/src/entities/model/reimbursement-expense.entity.model.js +43 -0
- package/dist/src/entities/model/reimbursement.entity.model.d.ts +32 -0
- package/dist/src/entities/model/reimbursement.entity.model.js +34 -0
- package/dist/src/entities/model/task.entity.model.d.ts +17 -0
- package/dist/src/entities/model/task.entity.model.js +29 -0
- package/dist/src/entities/model/timesheet.entity.model.d.ts +21 -0
- package/dist/src/entities/model/timesheet.entity.model.js +31 -0
- package/dist/src/entities/model/user.entity.model.d.ts +46 -0
- package/dist/src/entities/model/user.entity.model.js +36 -0
- package/dist/src/model/entities/timesheet.model.d.ts +2 -0
- package/dist/src/model/entities/timesheet.model.js +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BillingEntityModel = exports.BillingStatusCategoryEnumForUI = void 0;
|
|
4
|
+
const enums_1 = require("../../enums");
|
|
5
|
+
const billing_type_enum_1 = require("../enums/billing-type.enum");
|
|
6
|
+
const billing_status_enum_1 = require("../enums/billing.status.enum");
|
|
7
|
+
const billing_invoice_type_enum_1 = require("../enums/billing_invoice_type.enum");
|
|
8
|
+
const payment_status_enum_1 = require("../enums/payment_status.enum");
|
|
9
|
+
const relation_type_enum_1 = require("../enums/relation-type.enum");
|
|
10
|
+
const entity_utils_interface_1 = require("../interface/entity.utils.interface");
|
|
11
|
+
const base_entity_model_1 = require("./base.entity.model");
|
|
12
|
+
var BillingStatusCategoryEnumForUI;
|
|
13
|
+
(function (BillingStatusCategoryEnumForUI) {
|
|
14
|
+
BillingStatusCategoryEnumForUI["INTERNAL_REVIEW_STATUS"] = "INTERNAL_REVIEW_STATUS";
|
|
15
|
+
BillingStatusCategoryEnumForUI["CLIENT_REVIEW_STATUS"] = "CLIENT_REVIEW_STATUS";
|
|
16
|
+
BillingStatusCategoryEnumForUI["PAYMENT_STATUS"] = "PAYMENT_STATUS";
|
|
17
|
+
})(BillingStatusCategoryEnumForUI || (exports.BillingStatusCategoryEnumForUI = BillingStatusCategoryEnumForUI = {}));
|
|
18
|
+
class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.id = 0;
|
|
22
|
+
this.startDate = "";
|
|
23
|
+
this.endDate = "";
|
|
24
|
+
this.projectId = 0;
|
|
25
|
+
this.totalAmount = 0;
|
|
26
|
+
this.totalMinutes = 0;
|
|
27
|
+
this.invoiceNumber = "";
|
|
28
|
+
this.paymentStatus = payment_status_enum_1.PaymentStatusEnum.PENDING;
|
|
29
|
+
this.status = billing_status_enum_1.BillingStatusEnum.PENDING_APPROVAL;
|
|
30
|
+
this.writeoffAmount = 0;
|
|
31
|
+
this.totalAmountPaid = 0;
|
|
32
|
+
this.tdsAmount = 0;
|
|
33
|
+
this.creditNoteAmount = 0;
|
|
34
|
+
this.invoiceEntityId = 0;
|
|
35
|
+
this.invoiceEntityType = billing_invoice_type_enum_1.BillingInvoiceTypeEnum.CLIENT;
|
|
36
|
+
this.invoiceContactName = "";
|
|
37
|
+
this.bankId = 0;
|
|
38
|
+
this.particulars = "";
|
|
39
|
+
this.currency = enums_1.CurrencyEnum.INR;
|
|
40
|
+
this.createdBy = 0;
|
|
41
|
+
this.updatedBy = 0;
|
|
42
|
+
this.createdOn = "";
|
|
43
|
+
this.updatedOn = "";
|
|
44
|
+
this.type = billing_type_enum_1.BillingTypeEnum.INVOICE;
|
|
45
|
+
}
|
|
46
|
+
static fromApiEntity(apiEntity) {
|
|
47
|
+
const entity = new BillingEntityModel(entity_utils_interface_1.EntityEnum.BILLING);
|
|
48
|
+
Object.assign(entity, apiEntity);
|
|
49
|
+
return entity;
|
|
50
|
+
}
|
|
51
|
+
getStatusCategory() {
|
|
52
|
+
return this.mapStatusCategory(this.status);
|
|
53
|
+
}
|
|
54
|
+
getStatusLabel() {
|
|
55
|
+
return this.mapStatusLabel(this.status);
|
|
56
|
+
}
|
|
57
|
+
getTotalAmountInINR() {
|
|
58
|
+
return Number(this.conversionRate) > 0
|
|
59
|
+
? Number(this.totalAmount) * Number(this.conversionRate)
|
|
60
|
+
: Number(this.totalAmount);
|
|
61
|
+
}
|
|
62
|
+
getDateRange() {
|
|
63
|
+
return `${this.formatDate(this.startDate)} - ${this.formatDate(this.endDate, true)}`;
|
|
64
|
+
}
|
|
65
|
+
getBillDate() {
|
|
66
|
+
return new Date(this.createdOn);
|
|
67
|
+
}
|
|
68
|
+
mapOverdue(configValue) {
|
|
69
|
+
var _a, _b, _c, _d;
|
|
70
|
+
let overdue = false;
|
|
71
|
+
if (configValue !== undefined &&
|
|
72
|
+
this.mapStatusCategory(this.status) ===
|
|
73
|
+
BillingStatusCategoryEnumForUI.PAYMENT_STATUS &&
|
|
74
|
+
this.status !== billing_status_enum_1.BillingStatusEnum.SETTLED) {
|
|
75
|
+
const overdueDays = (_d = (_b = (_a = this.project) === null || _a === void 0 ? void 0 : _a.billingOverdueDays) !== null && _b !== void 0 ? _b : (_c = this.client) === null || _c === void 0 ? void 0 : _c.billingOverdueDays) !== null && _d !== void 0 ? _d : Number(configValue);
|
|
76
|
+
const dueDate = new Date(this.createdOn);
|
|
77
|
+
dueDate.setDate(dueDate.getDate() + overdueDays);
|
|
78
|
+
overdue = dueDate < new Date();
|
|
79
|
+
}
|
|
80
|
+
this.billOverdue = overdue;
|
|
81
|
+
}
|
|
82
|
+
mapStatusCategory(status) {
|
|
83
|
+
// Define mapping sets
|
|
84
|
+
const categories = {
|
|
85
|
+
[BillingStatusCategoryEnumForUI.INTERNAL_REVIEW_STATUS]: [
|
|
86
|
+
billing_status_enum_1.BillingStatusEnum.INTERNAL_APPROVED,
|
|
87
|
+
billing_status_enum_1.BillingStatusEnum.PENDING_APPROVAL,
|
|
88
|
+
billing_status_enum_1.BillingStatusEnum.REQUEST_CHANGES,
|
|
89
|
+
billing_status_enum_1.BillingStatusEnum.CANCELLED,
|
|
90
|
+
],
|
|
91
|
+
[BillingStatusCategoryEnumForUI.CLIENT_REVIEW_STATUS]: [
|
|
92
|
+
billing_status_enum_1.BillingStatusEnum.PENDING_CLIENT_REVIEW,
|
|
93
|
+
billing_status_enum_1.BillingStatusEnum.CLIENT_REVISION_APPROVAL,
|
|
94
|
+
billing_status_enum_1.BillingStatusEnum.REJECT_CLIENT_REVISION,
|
|
95
|
+
],
|
|
96
|
+
[BillingStatusCategoryEnumForUI.PAYMENT_STATUS]: [
|
|
97
|
+
billing_status_enum_1.BillingStatusEnum.INVOICE_SENT,
|
|
98
|
+
billing_status_enum_1.BillingStatusEnum.PENDING_PAYMENT,
|
|
99
|
+
billing_status_enum_1.BillingStatusEnum.SETTLED,
|
|
100
|
+
],
|
|
101
|
+
};
|
|
102
|
+
// Validation: check if any status exists in more than one category
|
|
103
|
+
const statusMap = new Map();
|
|
104
|
+
for (const [category, statuses] of Object.entries(categories)) {
|
|
105
|
+
for (const s of statuses) {
|
|
106
|
+
const existing = statusMap.get(s) || [];
|
|
107
|
+
existing.push(category);
|
|
108
|
+
statusMap.set(s, existing);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
for (const [s, cats] of statusMap) {
|
|
112
|
+
if (cats.length > 1) {
|
|
113
|
+
console.error(`Duplicate mapping: ${s} exists in categories ${cats.join(", ")}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// Now do actual mapping
|
|
117
|
+
for (const [category, statuses] of Object.entries(categories)) {
|
|
118
|
+
if (statuses.includes(status)) {
|
|
119
|
+
return category;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
throw new Error(`Unhandled Billing Status: ${status}`);
|
|
123
|
+
}
|
|
124
|
+
mapStatusLabel(status) {
|
|
125
|
+
switch (status) {
|
|
126
|
+
case billing_status_enum_1.BillingStatusEnum.PENDING_APPROVAL:
|
|
127
|
+
return "Pending Internal Approval";
|
|
128
|
+
case billing_status_enum_1.BillingStatusEnum.REQUEST_CHANGES:
|
|
129
|
+
return "Requested Changes";
|
|
130
|
+
case billing_status_enum_1.BillingStatusEnum.CANCELLED:
|
|
131
|
+
return "Cancelled";
|
|
132
|
+
case billing_status_enum_1.BillingStatusEnum.INTERNAL_APPROVED:
|
|
133
|
+
return "Approved Internally";
|
|
134
|
+
case billing_status_enum_1.BillingStatusEnum.PENDING_CLIENT_REVIEW:
|
|
135
|
+
return "Pending Client Review";
|
|
136
|
+
case billing_status_enum_1.BillingStatusEnum.CLIENT_REVISION_APPROVAL:
|
|
137
|
+
return "Client Approved Revision";
|
|
138
|
+
case billing_status_enum_1.BillingStatusEnum.REJECT_CLIENT_REVISION:
|
|
139
|
+
return "Client Rejected Revision";
|
|
140
|
+
case billing_status_enum_1.BillingStatusEnum.INVOICE_SENT:
|
|
141
|
+
return "Invoice Sent";
|
|
142
|
+
case billing_status_enum_1.BillingStatusEnum.PENDING_PAYMENT:
|
|
143
|
+
return "Pending Payment";
|
|
144
|
+
case billing_status_enum_1.BillingStatusEnum.SETTLED:
|
|
145
|
+
return "Settled";
|
|
146
|
+
default:
|
|
147
|
+
return status;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
formatDate(dateStr, includeYear = false) {
|
|
151
|
+
const year = dateStr.slice(0, 4);
|
|
152
|
+
const month = parseInt(dateStr.slice(4, 6), 10) - 1;
|
|
153
|
+
const day = dateStr.slice(6, 8);
|
|
154
|
+
return new Date(+year, month, +day).toLocaleDateString("en-IN", Object.assign({ day: "numeric", month: "short" }, (includeYear && { year: "numeric" })));
|
|
155
|
+
}
|
|
156
|
+
getAvailableAction(currentUserPermissions, billingConfigFlow, getUpdateActionVisibility) {
|
|
157
|
+
const currentBillingStatusActionConfig = billingConfigFlow[this.status];
|
|
158
|
+
if (currentBillingStatusActionConfig) {
|
|
159
|
+
const actionVisibilityConfig = getUpdateActionVisibility(this);
|
|
160
|
+
return Object.entries(currentBillingStatusActionConfig.actions)
|
|
161
|
+
.filter(([_, actionConfig]) => {
|
|
162
|
+
const actionPermissions = actionConfig.permissions.filter((item) => item != "BILLING_VIEW_PDF") || [];
|
|
163
|
+
const commonPermissions = actionPermissions.filter((actionPermission) => currentUserPermissions.includes(actionPermission));
|
|
164
|
+
if (commonPermissions.length === 0) {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
if (commonPermissions.length > 1) {
|
|
168
|
+
throw new Error("Multiple permissions found for an action");
|
|
169
|
+
}
|
|
170
|
+
if (!actionVisibilityConfig[commonPermissions[0]]) {
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
return commonPermissions.some((permission) => actionVisibilityConfig[permission] &&
|
|
174
|
+
actionVisibilityConfig[permission]());
|
|
175
|
+
})
|
|
176
|
+
.map(([actionKey, actionConfig]) => actionKey);
|
|
177
|
+
}
|
|
178
|
+
return [];
|
|
179
|
+
}
|
|
180
|
+
getRelationConfigs() {
|
|
181
|
+
return this.constructor.prototype.constructor.relationConfigs || [];
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
exports.BillingEntityModel = BillingEntityModel;
|
|
185
|
+
BillingEntityModel.relationConfigs = [
|
|
186
|
+
{
|
|
187
|
+
name: entity_utils_interface_1.EntityEnum.PROJECT,
|
|
188
|
+
relation: relation_type_enum_1.RelationType.ONE,
|
|
189
|
+
key: "project",
|
|
190
|
+
mapKeyConfig: {
|
|
191
|
+
relationKey: "id",
|
|
192
|
+
key: "projectId",
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
name: entity_utils_interface_1.EntityEnum.CLIENT,
|
|
197
|
+
relation: relation_type_enum_1.RelationType.ONE,
|
|
198
|
+
key: "client",
|
|
199
|
+
mapKeyConfig: {
|
|
200
|
+
relationKey: "id",
|
|
201
|
+
key: "project.clientId",
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
name: entity_utils_interface_1.EntityEnum.USER,
|
|
206
|
+
relation: relation_type_enum_1.RelationType.ONE,
|
|
207
|
+
key: "updatedByUser",
|
|
208
|
+
mapKeyConfig: {
|
|
209
|
+
relationKey: "id",
|
|
210
|
+
key: "updatedBy",
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: entity_utils_interface_1.EntityEnum.REIMBURSEMENT_EXPENSE,
|
|
215
|
+
relation: relation_type_enum_1.RelationType.MANY,
|
|
216
|
+
key: "reimbursementExpense",
|
|
217
|
+
mapKeyConfig: { relationKey: "projectId", key: "projectId" },
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
name: entity_utils_interface_1.EntityEnum.BILLING_REIMBURSEMENT_EXPENSE,
|
|
221
|
+
relation: relation_type_enum_1.RelationType.MANY,
|
|
222
|
+
key: "billingIdReimbursementExpense",
|
|
223
|
+
mapKeyConfig: {
|
|
224
|
+
relationKey: "billingId",
|
|
225
|
+
key: "id",
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
name: entity_utils_interface_1.EntityEnum.BILLING_TIMESHEET,
|
|
230
|
+
relation: relation_type_enum_1.RelationType.MANY,
|
|
231
|
+
key: "billingTimesheets",
|
|
232
|
+
mapKeyConfig: {
|
|
233
|
+
relationKey: "billingId",
|
|
234
|
+
key: "id",
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
name: entity_utils_interface_1.EntityEnum.BANK,
|
|
239
|
+
relation: relation_type_enum_1.RelationType.MANY,
|
|
240
|
+
key: "bank",
|
|
241
|
+
mapKeyConfig: {
|
|
242
|
+
relationKey: "id",
|
|
243
|
+
key: "bankId",
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IClientAffiliateApiEntity } from "../../api";
|
|
2
|
+
import { EntityEnum } from "../interface/entity.utils.interface";
|
|
3
|
+
import { BaseEntityModel } from "./base.entity.model";
|
|
4
|
+
export declare class ClientAffiliateEntityModel extends BaseEntityModel<EntityEnum.CLIENT_AFFILIATE> implements IClientAffiliateApiEntity {
|
|
5
|
+
id: number;
|
|
6
|
+
name: string;
|
|
7
|
+
address: string;
|
|
8
|
+
details?: string;
|
|
9
|
+
clientId: number;
|
|
10
|
+
organizationId: number;
|
|
11
|
+
zipCode: string;
|
|
12
|
+
country: string;
|
|
13
|
+
createdOn: string;
|
|
14
|
+
updatedOn: string;
|
|
15
|
+
createdBy: number;
|
|
16
|
+
updatedBy: number;
|
|
17
|
+
getRelationConfigs(): any;
|
|
18
|
+
static fromApiEntity(apiEntity: IClientAffiliateApiEntity): ClientAffiliateEntityModel;
|
|
19
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientAffiliateEntityModel = void 0;
|
|
4
|
+
const entity_utils_interface_1 = require("../interface/entity.utils.interface");
|
|
5
|
+
const base_entity_model_1 = require("./base.entity.model");
|
|
6
|
+
class ClientAffiliateEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.id = 0;
|
|
10
|
+
this.name = "";
|
|
11
|
+
this.address = "";
|
|
12
|
+
this.clientId = 0;
|
|
13
|
+
this.organizationId = 0;
|
|
14
|
+
this.zipCode = "";
|
|
15
|
+
this.country = "";
|
|
16
|
+
this.createdOn = "";
|
|
17
|
+
this.updatedOn = "";
|
|
18
|
+
this.createdBy = 0;
|
|
19
|
+
this.updatedBy = 0;
|
|
20
|
+
}
|
|
21
|
+
getRelationConfigs() {
|
|
22
|
+
return this.constructor.prototype.constructor.relationConfigs;
|
|
23
|
+
}
|
|
24
|
+
static fromApiEntity(apiEntity) {
|
|
25
|
+
const entity = new ClientAffiliateEntityModel(entity_utils_interface_1.EntityEnum.CLIENT_AFFILIATE);
|
|
26
|
+
Object.assign(entity, apiEntity);
|
|
27
|
+
return entity;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.ClientAffiliateEntityModel = ClientAffiliateEntityModel;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { IClientApiEntity } from "../../api";
|
|
2
|
+
import { EntityEnum, EnumEntityType } from "../interface/entity.utils.interface";
|
|
3
|
+
import { RelationConfigs } from "../interface/relation-config.interface";
|
|
4
|
+
import { BaseEntityModel } from "./base.entity.model";
|
|
5
|
+
import { ProjectEntityModel } from "./project.entity.model";
|
|
6
|
+
export declare class ClientEntityModel extends BaseEntityModel<EntityEnum.CLIENT> implements IClientApiEntity {
|
|
7
|
+
createdOn: string;
|
|
8
|
+
updatedOn: string;
|
|
9
|
+
id: number;
|
|
10
|
+
name: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
primaryContactName: string;
|
|
13
|
+
primaryContact: string;
|
|
14
|
+
primaryEmail: string;
|
|
15
|
+
secondaryContactName?: string;
|
|
16
|
+
secondaryEmail?: string;
|
|
17
|
+
address?: string;
|
|
18
|
+
secondaryContact?: string;
|
|
19
|
+
country?: string;
|
|
20
|
+
industry?: string;
|
|
21
|
+
zipCode?: string;
|
|
22
|
+
organizationId: number;
|
|
23
|
+
reference?: string;
|
|
24
|
+
createdBy: number;
|
|
25
|
+
updatedBy: number;
|
|
26
|
+
projectIds?: number[];
|
|
27
|
+
billingOverdueDays: number;
|
|
28
|
+
projects: ProjectEntityModel[];
|
|
29
|
+
getRelationConfigs(): any;
|
|
30
|
+
static relationConfigs: RelationConfigs<[
|
|
31
|
+
EntityEnum.PROJECT
|
|
32
|
+
], EnumEntityType<EntityEnum.CLIENT>>;
|
|
33
|
+
static fromApiEntity(apiEntity: IClientApiEntity): ClientEntityModel;
|
|
34
|
+
populateProjectIds(projects: ProjectEntityModel[]): ClientEntityModel;
|
|
35
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientEntityModel = void 0;
|
|
4
|
+
const relation_type_enum_1 = require("../enums/relation-type.enum");
|
|
5
|
+
const entity_utils_interface_1 = require("../interface/entity.utils.interface");
|
|
6
|
+
const base_entity_model_1 = require("./base.entity.model");
|
|
7
|
+
class ClientEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.createdOn = "";
|
|
11
|
+
this.updatedOn = "";
|
|
12
|
+
this.id = 0;
|
|
13
|
+
this.name = "";
|
|
14
|
+
this.primaryContactName = "";
|
|
15
|
+
this.primaryContact = "";
|
|
16
|
+
this.primaryEmail = "";
|
|
17
|
+
this.organizationId = 0;
|
|
18
|
+
this.createdBy = 0;
|
|
19
|
+
this.updatedBy = 0;
|
|
20
|
+
this.billingOverdueDays = 0;
|
|
21
|
+
this.projects = [];
|
|
22
|
+
}
|
|
23
|
+
getRelationConfigs() {
|
|
24
|
+
// return this.constructor.prototype.relationConfigs || [];
|
|
25
|
+
return this.constructor.prototype.constructor.relationConfigs;
|
|
26
|
+
}
|
|
27
|
+
static fromApiEntity(apiEntity) {
|
|
28
|
+
const entity = new ClientEntityModel(entity_utils_interface_1.EntityEnum.CLIENT);
|
|
29
|
+
Object.assign(entity, apiEntity);
|
|
30
|
+
return entity;
|
|
31
|
+
}
|
|
32
|
+
populateProjectIds(projects) {
|
|
33
|
+
this.projectIds = projects
|
|
34
|
+
.filter((project) => project.clientId === this.id)
|
|
35
|
+
.map((project) => project.id);
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.ClientEntityModel = ClientEntityModel;
|
|
40
|
+
ClientEntityModel.relationConfigs = [
|
|
41
|
+
{
|
|
42
|
+
name: entity_utils_interface_1.EntityEnum.PROJECT,
|
|
43
|
+
relation: relation_type_enum_1.RelationType.MANY,
|
|
44
|
+
key: "projects",
|
|
45
|
+
mapKeyConfig: {
|
|
46
|
+
relationKey: "clientId",
|
|
47
|
+
key: "id",
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
];
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import { ConfigurationKeyEnum, ConfigurationTypeEnum
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
export declare class ConfigurationsModel implements IConfigurationsModel {
|
|
1
|
+
import { ConfigurationKeyEnum, ConfigurationTypeEnum } from "..";
|
|
2
|
+
import { IConfigurationApiEntity } from "../../api";
|
|
3
|
+
export declare class ConfigurationEntityModel implements IConfigurationApiEntity {
|
|
6
4
|
id: number;
|
|
7
5
|
key: ConfigurationKeyEnum;
|
|
8
6
|
value: string;
|
|
9
7
|
description: string;
|
|
10
8
|
label: string;
|
|
11
9
|
type: ConfigurationTypeEnum;
|
|
12
|
-
createdOn:
|
|
13
|
-
updatedOn:
|
|
10
|
+
createdOn: string;
|
|
11
|
+
updatedOn: string;
|
|
14
12
|
createdBy: number;
|
|
15
13
|
updatedBy: number;
|
|
16
14
|
organizationId: number;
|
|
17
|
-
constructor(data:
|
|
15
|
+
constructor(data: IConfigurationApiEntity);
|
|
18
16
|
isCronJobKey(): boolean;
|
|
19
|
-
static findByKey(configurationEntities:
|
|
17
|
+
static findByKey(configurationEntities: IConfigurationApiEntity[], key: ConfigurationKeyEnum): IConfigurationApiEntity | undefined;
|
|
18
|
+
static fromApiEntity(apiEntity: IConfigurationApiEntity): ConfigurationEntityModel;
|
|
20
19
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ConfigurationEntityModel = void 0;
|
|
4
4
|
const __1 = require("..");
|
|
5
|
-
class
|
|
5
|
+
class ConfigurationEntityModel {
|
|
6
6
|
constructor(data) {
|
|
7
7
|
this.id = 0;
|
|
8
8
|
this.key = __1.ConfigurationKeyEnum.PENDING_APPROVAL_TIMESHEET_REMINDER;
|
|
@@ -10,8 +10,8 @@ class ConfigurationsModel {
|
|
|
10
10
|
this.description = "";
|
|
11
11
|
this.label = "";
|
|
12
12
|
this.type = __1.ConfigurationTypeEnum.CRONJOB_EXPRESSION;
|
|
13
|
-
this.createdOn =
|
|
14
|
-
this.updatedOn =
|
|
13
|
+
this.createdOn = "";
|
|
14
|
+
this.updatedOn = "";
|
|
15
15
|
this.createdBy = 0;
|
|
16
16
|
this.updatedBy = 0;
|
|
17
17
|
this.organizationId = 0;
|
|
@@ -23,5 +23,11 @@ class ConfigurationsModel {
|
|
|
23
23
|
static findByKey(configurationEntities, key) {
|
|
24
24
|
return configurationEntities.find((configurationEntity) => configurationEntity.key === key);
|
|
25
25
|
}
|
|
26
|
+
static fromApiEntity(apiEntity) {
|
|
27
|
+
console.log("apiEntity", apiEntity);
|
|
28
|
+
const entity = new ConfigurationEntityModel(apiEntity);
|
|
29
|
+
Object.assign(entity, apiEntity);
|
|
30
|
+
return entity;
|
|
31
|
+
}
|
|
26
32
|
}
|
|
27
|
-
exports.
|
|
33
|
+
exports.ConfigurationEntityModel = ConfigurationEntityModel;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { IDesignationApiEntity } from "../interface/designation.entity.interface";
|
|
2
|
+
import { EntityEnum } from "../interface/entity.utils.interface";
|
|
3
|
+
import { BaseEntityModel } from "./base.entity.model";
|
|
4
|
+
export declare class DesignationEntityModel extends BaseEntityModel<EntityEnum.DESIGNATION> implements IDesignationApiEntity {
|
|
3
5
|
id: number;
|
|
4
6
|
name: string;
|
|
5
7
|
description?: string;
|
|
6
8
|
createdBy: number;
|
|
7
|
-
createdOn:
|
|
9
|
+
createdOn: string;
|
|
8
10
|
updatedBy: number;
|
|
9
|
-
updatedOn:
|
|
10
|
-
|
|
11
|
+
updatedOn: string;
|
|
12
|
+
static fromApiEntity(apiEntity: IDesignationApiEntity): DesignationEntityModel;
|
|
13
|
+
getRelationConfigs(): any[];
|
|
11
14
|
}
|
|
@@ -1,15 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DesignationEntityModel = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
this.
|
|
10
|
-
this.
|
|
11
|
-
this.
|
|
12
|
-
this.
|
|
4
|
+
const entity_utils_interface_1 = require("../interface/entity.utils.interface");
|
|
5
|
+
const base_entity_model_1 = require("./base.entity.model");
|
|
6
|
+
class DesignationEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.id = 0;
|
|
10
|
+
this.name = "";
|
|
11
|
+
this.createdBy = 0;
|
|
12
|
+
this.createdOn = "";
|
|
13
|
+
this.updatedBy = 0;
|
|
14
|
+
this.updatedOn = "";
|
|
15
|
+
}
|
|
16
|
+
// constructor(data: IDesignationApiEntity) {
|
|
17
|
+
// this.id = data.id;
|
|
18
|
+
// this.name = data.name;
|
|
19
|
+
// this.description = data.description;
|
|
20
|
+
// this.createdBy = data.createdBy;
|
|
21
|
+
// this.createdOn = data.createdOn;
|
|
22
|
+
// this.updatedBy = data.updatedBy;
|
|
23
|
+
// this.updatedOn = data.updatedOn;
|
|
24
|
+
// }
|
|
25
|
+
static fromApiEntity(apiEntity) {
|
|
26
|
+
const entity = new DesignationEntityModel(entity_utils_interface_1.EntityEnum.DESIGNATION);
|
|
27
|
+
Object.assign(entity, apiEntity);
|
|
28
|
+
return entity;
|
|
29
|
+
}
|
|
30
|
+
getRelationConfigs() {
|
|
31
|
+
return this.constructor.prototype.constructor.relationConfigs || [];
|
|
13
32
|
}
|
|
14
33
|
}
|
|
15
34
|
exports.DesignationEntityModel = DesignationEntityModel;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EntityEnum, EntityIndexMap, EntityMap, EnumEntityType, IBaseEntityApiResponse } from "../interface/entity.utils.interface";
|
|
2
|
+
export declare function mapToIndex(entityMap: EntityMap): EntityIndexMap;
|
|
3
|
+
export declare function getEntityIndexMap<T extends EntityEnum>(data: IBaseEntityApiResponse<EnumEntityType<T>>, baseEntity: T, reusedConfig?: {
|
|
4
|
+
existingEntityIndexMap: EntityIndexMap;
|
|
5
|
+
enumEntities: EntityEnum[];
|
|
6
|
+
}): EntityIndexMap;
|
|
7
|
+
export declare function populateRelationsFor(entityIndexMap: EntityIndexMap, enumEntities: EntityEnum[]): void;
|
|
8
|
+
export declare function parseEntities<T extends EnumEntityType<EntityEnum>>(json: IBaseEntityApiResponse<T>, baseEntity: EntityEnum, entityMap: EntityMap): EntityMap;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapToIndex = mapToIndex;
|
|
4
|
+
exports.getEntityIndexMap = getEntityIndexMap;
|
|
5
|
+
exports.populateRelationsFor = populateRelationsFor;
|
|
6
|
+
exports.parseEntities = parseEntities;
|
|
7
|
+
const timesheet_model_1 = require("../../model/entities/timesheet.model");
|
|
8
|
+
const entity_utils_interface_1 = require("../interface/entity.utils.interface");
|
|
9
|
+
const bank_entity_model_1 = require("./bank.entity.model");
|
|
10
|
+
const base_entity_model_1 = require("./base.entity.model");
|
|
11
|
+
const billing_reimbursement_expense_entity_model_1 = require("./billing-reimbursement-expense.entity.model");
|
|
12
|
+
const billing_timesheet_entity_model_1 = require("./billing-timesheet.entity.model");
|
|
13
|
+
const billing_entity_model_1 = require("./billing.entity.model");
|
|
14
|
+
const client_affiliate_entity_model_1 = require("./client-affiliate.entity.model");
|
|
15
|
+
const client_entity_model_1 = require("./client.entity.model");
|
|
16
|
+
const configuration_model_1 = require("./configuration.model");
|
|
17
|
+
const project_user_mapping_entity_model_1 = require("./project-user-mapping.entity.model");
|
|
18
|
+
const project_entity_model_1 = require("./project.entity.model");
|
|
19
|
+
const reimbursement_expense_entity_model_1 = require("./reimbursement-expense.entity.model");
|
|
20
|
+
const reimbursement_entity_model_1 = require("./reimbursement.entity.model");
|
|
21
|
+
const task_entity_model_1 = require("./task.entity.model");
|
|
22
|
+
const user_entity_model_1 = require("./user.entity.model");
|
|
23
|
+
function mapToIndex(entityMap) {
|
|
24
|
+
return Object.keys(entityMap).reduce((acc, key) => {
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
acc[key] = entityMap[key].reduce((innerAcc, entity) => {
|
|
27
|
+
innerAcc[entity.id] = entity;
|
|
28
|
+
return innerAcc;
|
|
29
|
+
}, {});
|
|
30
|
+
return acc;
|
|
31
|
+
}, {});
|
|
32
|
+
}
|
|
33
|
+
function getEntityIndexMap(data, baseEntity, reusedConfig) {
|
|
34
|
+
const entityMap = {};
|
|
35
|
+
parseEntities(data, baseEntity, entityMap);
|
|
36
|
+
const entityIndexMap = mapToIndex(entityMap);
|
|
37
|
+
if (reusedConfig) {
|
|
38
|
+
for (const entity of reusedConfig.enumEntities) {
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
entityIndexMap[entity] = reusedConfig.existingEntityIndexMap[entity];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return entityIndexMap;
|
|
44
|
+
}
|
|
45
|
+
function populateRelationsFor(entityIndexMap, enumEntities) {
|
|
46
|
+
enumEntities.forEach((entity) => {
|
|
47
|
+
base_entity_model_1.BaseEntityModel.populateRelationsForEntities(entityIndexMap, entity);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function parseEntities(json, baseEntity, entityMap) {
|
|
51
|
+
var _a;
|
|
52
|
+
console.log("baseEntity", baseEntity);
|
|
53
|
+
const entityFromJsonMappings = {
|
|
54
|
+
[entity_utils_interface_1.EntityEnum.PROJECT]: project_entity_model_1.ProjectEntityModel.fromApiEntity,
|
|
55
|
+
[entity_utils_interface_1.EntityEnum.CLIENT]: client_entity_model_1.ClientEntityModel.fromApiEntity,
|
|
56
|
+
[entity_utils_interface_1.EntityEnum.BILLING]: billing_entity_model_1.BillingEntityModel.fromApiEntity,
|
|
57
|
+
[entity_utils_interface_1.EntityEnum.USER]: user_entity_model_1.UserEntityModel.fromApiEntity,
|
|
58
|
+
[entity_utils_interface_1.EntityEnum.PROJECT_USER_MAPPING]: project_user_mapping_entity_model_1.ProjectUserMappingEntityModel.fromApiEntity,
|
|
59
|
+
[entity_utils_interface_1.EntityEnum.REIMBURSEMENT]: reimbursement_entity_model_1.ReimbursementEntityModel.fromApiEntity,
|
|
60
|
+
[entity_utils_interface_1.EntityEnum.REIMBURSEMENT_EXPENSE]: reimbursement_expense_entity_model_1.ReimbursementExpenseEntityModel.fromApiEntity,
|
|
61
|
+
[entity_utils_interface_1.EntityEnum.BILLING_REIMBURSEMENT_EXPENSE]: billing_reimbursement_expense_entity_model_1.BillingReimbursementExpneseEntityModel.fromApiEntity,
|
|
62
|
+
[entity_utils_interface_1.EntityEnum.CLIENT_AFFILIATE]: client_affiliate_entity_model_1.ClientAffiliateEntityModel.fromApiEntity,
|
|
63
|
+
[entity_utils_interface_1.EntityEnum.BANK]: bank_entity_model_1.BankEntityModel.fromApiEntity,
|
|
64
|
+
[entity_utils_interface_1.EntityEnum.CONFIGURATION]: configuration_model_1.ConfigurationEntityModel.fromApiEntity,
|
|
65
|
+
[entity_utils_interface_1.EntityEnum.TASK]: task_entity_model_1.TaskEntityModel.fromApiEntity,
|
|
66
|
+
[entity_utils_interface_1.EntityEnum.BILLING_TIMESHEET]: billing_timesheet_entity_model_1.BillingTimesheetEntityModel.fromApiEntity,
|
|
67
|
+
[entity_utils_interface_1.EntityEnum.TIMESHEET]: timesheet_model_1.TimesheetEntityModel.fromApiEntity,
|
|
68
|
+
};
|
|
69
|
+
if (!(baseEntity in entityFromJsonMappings)) {
|
|
70
|
+
console.log("entityFromJsonMappings", entityFromJsonMappings);
|
|
71
|
+
throw new Error(`Unknown entity: ${baseEntity}`);
|
|
72
|
+
}
|
|
73
|
+
entityMap[baseEntity] = ((_a = json["baseEntities"]) !== null && _a !== void 0 ? _a : []).map((e) => entityFromJsonMappings[baseEntity](e));
|
|
74
|
+
console.log("entityMap", entityMap[entity_utils_interface_1.EntityEnum.CONFIGURATION]);
|
|
75
|
+
if (json["relatedEntities"]) {
|
|
76
|
+
const relatedEntities = json["relatedEntities"];
|
|
77
|
+
for (const entityName in relatedEntities) {
|
|
78
|
+
parseEntities(
|
|
79
|
+
// @ts-ignore
|
|
80
|
+
relatedEntities[entityName], entityName, entityMap);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return entityMap;
|
|
84
|
+
}
|
|
@@ -1,19 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { IAuditColumnEntity } from "../interface/audit-column.entity.interface";
|
|
3
|
-
import { IHolidayEntity } from "../interface/holiday.entity.interface";
|
|
4
|
-
export declare class BaseEntityModel<T extends IAuditColumnEntity> {
|
|
5
|
-
createdOn: Date;
|
|
6
|
-
updatedOn: Date;
|
|
7
|
-
createdBy: number;
|
|
8
|
-
updatedBy: number;
|
|
9
|
-
constructor(data: T);
|
|
10
|
-
}
|
|
11
|
-
export declare class HolidayEntityModel extends BaseEntityModel<IHolidayEntity> implements IHolidayEntity {
|
|
12
|
-
id: number;
|
|
13
|
-
holidayListId: number;
|
|
14
|
-
dateCode: string;
|
|
15
|
-
private constructor();
|
|
16
|
-
getDateCodeModel(): DateCodeModel;
|
|
17
|
-
static fromEntity(data: IHolidayEntity): HolidayEntityModel;
|
|
18
|
-
static getDateCodeModelFromDate(models: HolidayEntityModel[]): DateCodeModel[];
|
|
19
|
-
}
|
|
1
|
+
export declare const toBeDeleted = "holiday";
|