law-common 10.18.1-beta.3 → 10.18.1-beta.4

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.
Files changed (33) hide show
  1. package/dist/src/entities/index.d.ts +15 -0
  2. package/dist/src/entities/index.js +15 -0
  3. package/dist/src/entities/model/base.entity.model.d.ts +13 -0
  4. package/dist/src/entities/model/base.entity.model.js +73 -0
  5. package/dist/src/entities/model/billing-reimbursement-expense.entity.model.d.ts +25 -0
  6. package/dist/src/entities/model/billing-reimbursement-expense.entity.model.js +35 -0
  7. package/dist/src/entities/model/billing.entity.model.d.ts +78 -0
  8. package/dist/src/entities/model/billing.entity.model.js +227 -0
  9. package/dist/src/entities/model/client.entity.model.d.ts +48 -0
  10. package/dist/src/entities/model/client.entity.model.js +49 -0
  11. package/dist/src/entities/model/configuration.model.d.ts +2 -0
  12. package/dist/src/entities/model/configuration.model.js +5 -0
  13. package/dist/src/entities/model/entity.model.interface.d.ts +25 -0
  14. package/dist/src/entities/model/entity.model.interface.js +69 -0
  15. package/dist/src/entities/model/holiday.entity.model.d.ts +1 -19
  16. package/dist/src/entities/model/holiday.entity.model.js +42 -29
  17. package/dist/src/entities/model/project-user-mapping.entity.model.d.ts +25 -0
  18. package/dist/src/entities/model/project-user-mapping.entity.model.js +48 -0
  19. package/dist/src/entities/model/project.entity.model.d.ts +39 -0
  20. package/dist/src/entities/model/project.entity.model.js +104 -0
  21. package/dist/src/entities/model/reimbursement-expense.entity.model.d.ts +27 -0
  22. package/dist/src/entities/model/reimbursement-expense.entity.model.js +42 -0
  23. package/dist/src/entities/model/reimbursement.entity.model.d.ts +32 -0
  24. package/dist/src/entities/model/reimbursement.entity.model.js +34 -0
  25. package/dist/src/entities/model/task.entity.model.d.ts +14 -0
  26. package/dist/src/entities/model/task.entity.model.js +23 -0
  27. package/dist/src/entities/model/timesheet.entity.model.d.ts +18 -0
  28. package/dist/src/entities/model/timesheet.entity.model.js +25 -0
  29. package/dist/src/entities/model/user.entity.model.d.ts +43 -0
  30. package/dist/src/entities/model/user.entity.model.js +30 -0
  31. package/dist/src/model/entities/timesheet.model.d.ts +2 -0
  32. package/dist/src/model/entities/timesheet.model.js +5 -0
  33. package/package.json +1 -1
@@ -80,3 +80,18 @@ export * from "./enums/billing-reimbursement-expense-change-status.enum";
80
80
  export * from "./interface/billing-reimbursement-expense-history.entity.interface";
81
81
  export * from "./enums/billing-reimburement-expense-impact.enum";
82
82
  export * from "./model/bank.entity.model";
83
+ export * from "./model/base.entity.model";
84
+ export * from "./model/billing-reimbursement-expense.entity.model";
85
+ export * from "./model/billing.entity.model";
86
+ export * from "./model/entity.model.interface";
87
+ export * from "./model/project-user-mapping.entity.model";
88
+ export * from "./model/project.entity.model";
89
+ export * from "./model/reimbursement-expense.entity.model";
90
+ export * from "./model/reimbursement.entity.model";
91
+ export * from "./model/task.entity.model";
92
+ export * from "./model/user.entity.model";
93
+ export * from "./model/client.entity.model";
94
+ export * from "./model/configuration.model";
95
+ export * from "./model/designation.entity.model";
96
+ export * from "./model/timesheet.entity.model";
97
+ export * from "./model/user.entity.model";
@@ -97,3 +97,18 @@ __exportStar(require("./enums/billing-reimbursement-expense-change-status.enum")
97
97
  __exportStar(require("./interface/billing-reimbursement-expense-history.entity.interface"), exports);
98
98
  __exportStar(require("./enums/billing-reimburement-expense-impact.enum"), exports);
99
99
  __exportStar(require("./model/bank.entity.model"), exports);
100
+ __exportStar(require("./model/base.entity.model"), exports);
101
+ __exportStar(require("./model/billing-reimbursement-expense.entity.model"), exports);
102
+ __exportStar(require("./model/billing.entity.model"), exports);
103
+ __exportStar(require("./model/entity.model.interface"), exports);
104
+ __exportStar(require("./model/project-user-mapping.entity.model"), exports);
105
+ __exportStar(require("./model/project.entity.model"), exports);
106
+ __exportStar(require("./model/reimbursement-expense.entity.model"), exports);
107
+ __exportStar(require("./model/reimbursement.entity.model"), exports);
108
+ __exportStar(require("./model/task.entity.model"), exports);
109
+ __exportStar(require("./model/user.entity.model"), exports);
110
+ __exportStar(require("./model/client.entity.model"), exports);
111
+ __exportStar(require("./model/configuration.model"), exports);
112
+ __exportStar(require("./model/designation.entity.model"), exports);
113
+ __exportStar(require("./model/timesheet.entity.model"), exports);
114
+ __exportStar(require("./model/user.entity.model"), exports);
@@ -0,0 +1,13 @@
1
+ import { EntityEnum } from "../interface/entity.utils.interface";
2
+ import { EntityIndexMap } from "./entity.model.interface";
3
+ export declare enum RelationType {
4
+ ONE = "one",
5
+ MANY = "many"
6
+ }
7
+ export declare abstract class BaseEntityModel<T extends EntityEnum> {
8
+ protected entityName: T;
9
+ constructor(entityName: T);
10
+ abstract getRelationConfigs(): any[];
11
+ populateRelationsByIndex(entityIndexMap: EntityIndexMap): void;
12
+ static populateRelationsForEntities(entityIndexMap: EntityIndexMap, entityType: EntityEnum): void;
13
+ }
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseEntityModel = exports.RelationType = void 0;
4
+ var RelationType;
5
+ (function (RelationType) {
6
+ RelationType["ONE"] = "one";
7
+ RelationType["MANY"] = "many";
8
+ })(RelationType || (exports.RelationType = RelationType = {}));
9
+ class BaseEntityModel {
10
+ constructor(entityName) {
11
+ this.entityName = entityName;
12
+ }
13
+ populateRelationsByIndex(entityIndexMap) {
14
+ for (const relationConfig of this.getRelationConfigs() || []) {
15
+ if (relationConfig.relation === RelationType.ONE) {
16
+ // @ts-ignore
17
+ const relatedEntities = entityIndexMap[relationConfig.name] || {};
18
+ // @ts-ignore
19
+ let foundRelatedEntities = [];
20
+ if (relationConfig.mapKeyConfig.key.includes(".")) {
21
+ const [parentKey, childKey] = relationConfig.mapKeyConfig.key.split(".");
22
+ // @ts-ignore
23
+ if (this[parentKey] && this[parentKey][childKey]) {
24
+ // @ts-ignore
25
+ foundRelatedEntities = [relatedEntities[this[parentKey][childKey]]];
26
+ }
27
+ }
28
+ else {
29
+ foundRelatedEntities = relatedEntities[
30
+ // @ts-ignore
31
+ this[relationConfig.mapKeyConfig.key]]
32
+ ? // @ts-ignore
33
+ [relatedEntities[this[relationConfig.mapKeyConfig.key]]]
34
+ : [];
35
+ }
36
+ if (foundRelatedEntities.length > 1) {
37
+ throw new Error(`Expected one related entity for ${relationConfig.name} but found ${foundRelatedEntities.length}`);
38
+ }
39
+ if (foundRelatedEntities.length === 0) {
40
+ console.warn(`No related entity found for ${relationConfig.name} with ${relationConfig.mapKeyConfig.key
41
+ // @ts-ignore
42
+ }=${this[relationConfig.mapKeyConfig.foreignKey]}`);
43
+ }
44
+ // @ts-ignore
45
+ this[relationConfig.key] = foundRelatedEntities[0];
46
+ }
47
+ else if (relationConfig.relation === RelationType.MANY) {
48
+ // @ts-ignore
49
+ this[relationConfig.key] = [];
50
+ // @ts-ignore
51
+ const relatedEntities = entityIndexMap[relationConfig.name] || {};
52
+ for (const relatedEntity of Object.values(relatedEntities)) {
53
+ if (
54
+ // @ts-ignore
55
+ relatedEntity[relationConfig.mapKeyConfig.relationKey] ===
56
+ // @ts-ignore
57
+ this[relationConfig.mapKeyConfig.key]) {
58
+ // @ts-ignore
59
+ this[relationConfig.key].push(relatedEntity);
60
+ }
61
+ }
62
+ }
63
+ }
64
+ }
65
+ static populateRelationsForEntities(entityIndexMap, entityType) {
66
+ for (const key of Object.keys(entityIndexMap[entityType] || {})) {
67
+ // @ts-ignore
68
+ const entity = entityIndexMap[entityType][key];
69
+ entity.populateRelationsByIndex(entityIndexMap);
70
+ }
71
+ }
72
+ }
73
+ exports.BaseEntityModel = BaseEntityModel;
@@ -0,0 +1,25 @@
1
+ import { IBillingReimbursementExpenseApiEntity } from "../../api";
2
+ import { BillingReimbursementExpenseImpactEnum } from "../enums/billing-reimburement-expense-impact.enum";
3
+ import { BillingReimbursementExpenseChangedStatusEnum } from "../enums/billing-reimbursement-expense-change-status.enum";
4
+ import { EntityEnum } from "../interface/entity.utils.interface";
5
+ import { BaseEntityModel } from "./base.entity.model";
6
+ export declare class BillingReimbursementExpneseEntity extends BaseEntityModel<EntityEnum.BILLING_REIMBURSEMENT_EXPENSE> implements IBillingReimbursementExpenseApiEntity {
7
+ id: number;
8
+ billingId: number;
9
+ userId: number;
10
+ reimbursementExpenseId: number;
11
+ projectId: number;
12
+ expenseType: string;
13
+ totalAmount: number;
14
+ expenseIncurredDate: string;
15
+ changedStatus: BillingReimbursementExpenseChangedStatusEnum;
16
+ amendmentPurpose?: string;
17
+ impact?: BillingReimbursementExpenseImpactEnum;
18
+ updatedBy: number;
19
+ createdBy: number;
20
+ createdOn: string;
21
+ updatedOn: string;
22
+ static relationConfigs: never[];
23
+ getRelationConfigs(): any[];
24
+ static fromApiEntity(apiEntity: IBillingReimbursementExpenseApiEntity): BillingReimbursementExpneseEntity;
25
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BillingReimbursementExpneseEntity = void 0;
4
+ const billing_reimbursement_expense_change_status_enum_1 = require("../enums/billing-reimbursement-expense-change-status.enum");
5
+ const entity_utils_interface_1 = require("../interface/entity.utils.interface");
6
+ const base_entity_model_1 = require("./base.entity.model");
7
+ class BillingReimbursementExpneseEntity extends base_entity_model_1.BaseEntityModel {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.id = 0;
11
+ this.billingId = 0;
12
+ this.userId = 0;
13
+ this.reimbursementExpenseId = 0;
14
+ this.projectId = 0;
15
+ this.expenseType = "";
16
+ this.totalAmount = 0;
17
+ this.expenseIncurredDate = "";
18
+ this.changedStatus = billing_reimbursement_expense_change_status_enum_1.BillingReimbursementExpenseChangedStatusEnum.UNCHANGED;
19
+ this.amendmentPurpose = "";
20
+ this.updatedBy = 0;
21
+ this.createdBy = 0;
22
+ this.createdOn = `${new Date()}`;
23
+ this.updatedOn = `${new Date()}`;
24
+ }
25
+ getRelationConfigs() {
26
+ return this.constructor.prototype.constructor.relationConfigs || [];
27
+ }
28
+ static fromApiEntity(apiEntity) {
29
+ const entity = new BillingReimbursementExpneseEntity(entity_utils_interface_1.EntityEnum.BILLING_REIMBURSEMENT_EXPENSE);
30
+ Object.assign(entity, apiEntity);
31
+ return entity;
32
+ }
33
+ }
34
+ exports.BillingReimbursementExpneseEntity = BillingReimbursementExpneseEntity;
35
+ BillingReimbursementExpneseEntity.relationConfigs = [];
@@ -0,0 +1,78 @@
1
+ import { IBillingApiEntity, IBillingFlowConfig } from "../../api";
2
+ import { CurrencyEnum } from "../../enums";
3
+ import { BillingTypeEnum } from "../enums/billing-type.enum";
4
+ import { BillingActionsEnum } from "../enums/billing.action.enum";
5
+ import { BillingStatusEnum } from "../enums/billing.status.enum";
6
+ import { BillingInvoiceTypeEnum } from "../enums/billing_invoice_type.enum";
7
+ import { PaymentStatusEnum } from "../enums/payment_status.enum";
8
+ import { EntityEnum, EnumEntityType } from "../interface/entity.utils.interface";
9
+ import { BaseEntityModel } from "./base.entity.model";
10
+ import { BillingReimbursementExpneseEntity } from "./billing-reimbursement-expense.entity.model";
11
+ import { ClientEntity, RelationConfigs } from "./client.entity.model";
12
+ import { ProjectEntity } from "./project.entity.model";
13
+ import { ReimbursementExpenseEntity } from "./reimbursement-expense.entity.model";
14
+ import { UserEntity } from "./user.entity.model";
15
+ export interface BillingActions {
16
+ label: string;
17
+ value: BillingActionsEnum;
18
+ }
19
+ export declare enum BillingStatusCategoryEnumForUI {
20
+ INTERNAL_REVIEW_STATUS = "INTERNAL_REVIEW_STATUS",
21
+ CLIENT_REVIEW_STATUS = "CLIENT_REVIEW_STATUS",
22
+ PAYMENT_STATUS = "PAYMENT_STATUS"
23
+ }
24
+ export declare class BillingEntityModel extends BaseEntityModel<EntityEnum.BILLING> implements IBillingApiEntity {
25
+ id: number;
26
+ startDate: string;
27
+ endDate: string;
28
+ projectId: number;
29
+ totalAmount: number;
30
+ totalMinutes: number;
31
+ invoiceNumber: string;
32
+ paymentStatus: PaymentStatusEnum;
33
+ status: BillingStatusEnum;
34
+ writeoffAmount: number;
35
+ totalAmountPaid: number;
36
+ tdsAmount: number;
37
+ creditNoteAmount: number;
38
+ invoiceEntityId: number;
39
+ invoiceEntityType: BillingInvoiceTypeEnum;
40
+ invoicePdfUrl?: string | null;
41
+ invoiceContactName: string;
42
+ bankId: number;
43
+ conversionRate?: number;
44
+ particulars: string;
45
+ currency: CurrencyEnum;
46
+ createdBy: number;
47
+ updatedBy: number;
48
+ createdOn: string;
49
+ updatedOn: string;
50
+ type: BillingTypeEnum;
51
+ project?: ProjectEntity;
52
+ client?: ClientEntity;
53
+ updatedByUser?: UserEntity;
54
+ billOverdue?: boolean;
55
+ billingIdReimbursementExpense?: BillingReimbursementExpneseEntity[];
56
+ reimbursementExpense?: ReimbursementExpenseEntity[];
57
+ static relationConfigs: RelationConfigs<[
58
+ EntityEnum.PROJECT,
59
+ EntityEnum.CLIENT,
60
+ EntityEnum.USER,
61
+ EntityEnum.REIMBURSEMENT_EXPENSE,
62
+ EntityEnum.BILLING_REIMBURSEMENT_EXPENSE
63
+ ], EnumEntityType<EntityEnum.BILLING>>;
64
+ static fromApiEntity(apiEntity: IBillingApiEntity): BillingEntityModel;
65
+ getStatusCategory(): BillingStatusCategoryEnumForUI;
66
+ getStatusLabel(): string;
67
+ getTotalAmountInINR(): number;
68
+ getDateRange(): string;
69
+ getBillDate(): Date;
70
+ mapOverdue(configValue: string | undefined): void;
71
+ mapStatusCategory(status: BillingStatusEnum): BillingStatusCategoryEnumForUI;
72
+ mapStatusLabel(status: BillingStatusEnum): string;
73
+ formatDate(dateStr: string, includeYear?: boolean): string;
74
+ getAvailableAction(currentUserPermissions: string[], billingConfigFlow: IBillingFlowConfig, getUpdateActionVisibility: (bill: BillingEntityModel) => {
75
+ [key: string]: () => boolean;
76
+ }): BillingActionsEnum[];
77
+ getRelationConfigs(): any;
78
+ }
@@ -0,0 +1,227 @@
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 entity_utils_interface_1 = require("../interface/entity.utils.interface");
10
+ const base_entity_model_1 = require("./base.entity.model");
11
+ var BillingStatusCategoryEnumForUI;
12
+ (function (BillingStatusCategoryEnumForUI) {
13
+ BillingStatusCategoryEnumForUI["INTERNAL_REVIEW_STATUS"] = "INTERNAL_REVIEW_STATUS";
14
+ BillingStatusCategoryEnumForUI["CLIENT_REVIEW_STATUS"] = "CLIENT_REVIEW_STATUS";
15
+ BillingStatusCategoryEnumForUI["PAYMENT_STATUS"] = "PAYMENT_STATUS";
16
+ })(BillingStatusCategoryEnumForUI || (exports.BillingStatusCategoryEnumForUI = BillingStatusCategoryEnumForUI = {}));
17
+ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
18
+ constructor() {
19
+ super(...arguments);
20
+ this.id = 0;
21
+ this.startDate = "";
22
+ this.endDate = "";
23
+ this.projectId = 0;
24
+ this.totalAmount = 0;
25
+ this.totalMinutes = 0;
26
+ this.invoiceNumber = "";
27
+ this.paymentStatus = payment_status_enum_1.PaymentStatusEnum.PENDING;
28
+ this.status = billing_status_enum_1.BillingStatusEnum.PENDING_APPROVAL;
29
+ this.writeoffAmount = 0;
30
+ this.totalAmountPaid = 0;
31
+ this.tdsAmount = 0;
32
+ this.creditNoteAmount = 0;
33
+ this.invoiceEntityId = 0;
34
+ this.invoiceEntityType = billing_invoice_type_enum_1.BillingInvoiceTypeEnum.CLIENT;
35
+ this.invoiceContactName = "";
36
+ this.bankId = 0;
37
+ this.particulars = "";
38
+ this.currency = enums_1.CurrencyEnum.INR;
39
+ this.createdBy = 0;
40
+ this.updatedBy = 0;
41
+ this.createdOn = "";
42
+ this.updatedOn = "";
43
+ this.type = billing_type_enum_1.BillingTypeEnum.INVOICE;
44
+ }
45
+ static fromApiEntity(apiEntity) {
46
+ const entity = new BillingEntityModel(entity_utils_interface_1.EntityEnum.BILLING);
47
+ Object.assign(entity, apiEntity);
48
+ return entity;
49
+ }
50
+ getStatusCategory() {
51
+ return this.mapStatusCategory(this.status);
52
+ }
53
+ getStatusLabel() {
54
+ return this.mapStatusLabel(this.status);
55
+ }
56
+ getTotalAmountInINR() {
57
+ return Number(this.conversionRate) > 0
58
+ ? Number(this.totalAmount) * Number(this.conversionRate)
59
+ : Number(this.totalAmount);
60
+ }
61
+ getDateRange() {
62
+ return `${this.formatDate(this.startDate)} - ${this.formatDate(this.endDate, true)}`;
63
+ }
64
+ getBillDate() {
65
+ return new Date(this.createdOn);
66
+ }
67
+ mapOverdue(configValue) {
68
+ var _a, _b, _c, _d;
69
+ let overdue = false;
70
+ if (configValue !== undefined &&
71
+ this.mapStatusCategory(this.status) ===
72
+ BillingStatusCategoryEnumForUI.PAYMENT_STATUS &&
73
+ this.status !== billing_status_enum_1.BillingStatusEnum.SETTLED) {
74
+ 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);
75
+ const dueDate = new Date(this.createdOn);
76
+ dueDate.setDate(dueDate.getDate() + overdueDays);
77
+ overdue = dueDate < new Date();
78
+ }
79
+ this.billOverdue = overdue;
80
+ }
81
+ mapStatusCategory(status) {
82
+ // Define mapping sets
83
+ const categories = {
84
+ [BillingStatusCategoryEnumForUI.INTERNAL_REVIEW_STATUS]: [
85
+ billing_status_enum_1.BillingStatusEnum.PENDING_APPROVAL,
86
+ billing_status_enum_1.BillingStatusEnum.REQUEST_CHANGES,
87
+ billing_status_enum_1.BillingStatusEnum.CANCELLED,
88
+ ],
89
+ [BillingStatusCategoryEnumForUI.CLIENT_REVIEW_STATUS]: [
90
+ billing_status_enum_1.BillingStatusEnum.INTERNAL_APPROVED,
91
+ billing_status_enum_1.BillingStatusEnum.PENDING_CLIENT_REVIEW,
92
+ billing_status_enum_1.BillingStatusEnum.CLIENT_REVISION_APPROVAL,
93
+ billing_status_enum_1.BillingStatusEnum.REJECT_CLIENT_REVISION,
94
+ ],
95
+ [BillingStatusCategoryEnumForUI.PAYMENT_STATUS]: [
96
+ billing_status_enum_1.BillingStatusEnum.INVOICE_SENT,
97
+ billing_status_enum_1.BillingStatusEnum.PENDING_PAYMENT,
98
+ billing_status_enum_1.BillingStatusEnum.SETTLED,
99
+ ],
100
+ };
101
+ // Validation: check if any status exists in more than one category
102
+ const statusMap = new Map();
103
+ for (const [category, statuses] of Object.entries(categories)) {
104
+ for (const s of statuses) {
105
+ const existing = statusMap.get(s) || [];
106
+ existing.push(category);
107
+ statusMap.set(s, existing);
108
+ }
109
+ }
110
+ for (const [s, cats] of statusMap) {
111
+ if (cats.length > 1) {
112
+ console.error(`Duplicate mapping: ${s} exists in categories ${cats.join(", ")}`);
113
+ }
114
+ }
115
+ // Now do actual mapping
116
+ for (const [category, statuses] of Object.entries(categories)) {
117
+ if (statuses.includes(status)) {
118
+ return category;
119
+ }
120
+ }
121
+ throw new Error(`Unhandled Billing Status: ${status}`);
122
+ }
123
+ mapStatusLabel(status) {
124
+ switch (status) {
125
+ case billing_status_enum_1.BillingStatusEnum.PENDING_APPROVAL:
126
+ return "Pending Internal Approval";
127
+ case billing_status_enum_1.BillingStatusEnum.REQUEST_CHANGES:
128
+ return "Requested Changes";
129
+ case billing_status_enum_1.BillingStatusEnum.CANCELLED:
130
+ return "Cancelled";
131
+ case billing_status_enum_1.BillingStatusEnum.INTERNAL_APPROVED:
132
+ return "Approved Internally";
133
+ case billing_status_enum_1.BillingStatusEnum.PENDING_CLIENT_REVIEW:
134
+ return "Pending Client Review";
135
+ case billing_status_enum_1.BillingStatusEnum.CLIENT_REVISION_APPROVAL:
136
+ return "Client Approved Revision";
137
+ case billing_status_enum_1.BillingStatusEnum.REJECT_CLIENT_REVISION:
138
+ return "Client Rejected Revision";
139
+ case billing_status_enum_1.BillingStatusEnum.INVOICE_SENT:
140
+ return "Invoice Sent";
141
+ case billing_status_enum_1.BillingStatusEnum.PENDING_PAYMENT:
142
+ return "Pending Payment";
143
+ case billing_status_enum_1.BillingStatusEnum.SETTLED:
144
+ return "Settled";
145
+ default:
146
+ return status;
147
+ }
148
+ }
149
+ formatDate(dateStr, includeYear = false) {
150
+ const year = dateStr.slice(0, 4);
151
+ const month = parseInt(dateStr.slice(4, 6), 10) - 1;
152
+ const day = dateStr.slice(6, 8);
153
+ return new Date(+year, month, +day).toLocaleDateString("en-IN", Object.assign({ day: "numeric", month: "short" }, (includeYear && { year: "numeric" })));
154
+ }
155
+ getAvailableAction(currentUserPermissions, billingConfigFlow, getUpdateActionVisibility) {
156
+ const currentBillingStatusActionConfig = billingConfigFlow[this.status];
157
+ if (currentBillingStatusActionConfig) {
158
+ const actionVisibilityConfig = getUpdateActionVisibility(this);
159
+ return Object.entries(currentBillingStatusActionConfig.actions)
160
+ .filter(([_, actionConfig]) => {
161
+ const actionPermissions = actionConfig.permissions.filter((item) => item != "BILLING_VIEW_PDF") || [];
162
+ const commonPermissions = actionPermissions.filter((actionPermission) => currentUserPermissions.includes(actionPermission));
163
+ if (commonPermissions.length === 0) {
164
+ return false;
165
+ }
166
+ if (commonPermissions.length > 1) {
167
+ throw new Error("Multiple permissions found for an action");
168
+ }
169
+ if (!actionVisibilityConfig[commonPermissions[0]]) {
170
+ return true;
171
+ }
172
+ return commonPermissions.some((permission) => actionVisibilityConfig[permission] &&
173
+ actionVisibilityConfig[permission]());
174
+ })
175
+ .map(([actionKey, actionConfig]) => actionKey);
176
+ }
177
+ return [];
178
+ }
179
+ getRelationConfigs() {
180
+ return this.constructor.prototype.constructor.relationConfigs || [];
181
+ }
182
+ }
183
+ exports.BillingEntityModel = BillingEntityModel;
184
+ BillingEntityModel.relationConfigs = [
185
+ {
186
+ name: entity_utils_interface_1.EntityEnum.PROJECT,
187
+ relation: base_entity_model_1.RelationType.ONE,
188
+ key: "project",
189
+ mapKeyConfig: {
190
+ relationKey: "id",
191
+ key: "projectId",
192
+ },
193
+ },
194
+ {
195
+ name: entity_utils_interface_1.EntityEnum.CLIENT,
196
+ relation: base_entity_model_1.RelationType.ONE,
197
+ key: "client",
198
+ mapKeyConfig: {
199
+ relationKey: "id",
200
+ key: "project.clientId",
201
+ },
202
+ },
203
+ {
204
+ name: entity_utils_interface_1.EntityEnum.USER,
205
+ relation: base_entity_model_1.RelationType.ONE,
206
+ key: "updatedByUser",
207
+ mapKeyConfig: {
208
+ relationKey: "id",
209
+ key: "updatedBy",
210
+ },
211
+ },
212
+ {
213
+ name: entity_utils_interface_1.EntityEnum.REIMBURSEMENT_EXPENSE,
214
+ relation: base_entity_model_1.RelationType.MANY,
215
+ key: "reimbursementExpense",
216
+ mapKeyConfig: { relationKey: "projectId", key: "projectId" },
217
+ },
218
+ {
219
+ name: entity_utils_interface_1.EntityEnum.BILLING_REIMBURSEMENT_EXPENSE,
220
+ relation: base_entity_model_1.RelationType.MANY,
221
+ key: "billingIdReimbursementExpense",
222
+ mapKeyConfig: {
223
+ relationKey: "billingId",
224
+ key: "id",
225
+ },
226
+ },
227
+ ];
@@ -0,0 +1,48 @@
1
+ import { ProjectEntity } from "./project.entity.model";
2
+ import { EntityEnum, EnumEntityType, VirtualEntityEnum } from "../interface/entity.utils.interface";
3
+ import { BaseEntityModel, RelationType } from "./base.entity.model";
4
+ import { IClientApiEntity } from "../../api";
5
+ type SourcePath<TSource> = (keyof TSource & string) | `${string}.${string}`;
6
+ export type IRelationConfig<TSource extends EntityEnum | VirtualEntityEnum, K extends EnumEntityType<EntityEnum | VirtualEntityEnum>> = {
7
+ name: TSource;
8
+ relation: RelationType;
9
+ key: string;
10
+ mapKeyConfig: {
11
+ relationKey: SourcePath<EnumEntityType<TSource>>;
12
+ key: keyof K;
13
+ };
14
+ };
15
+ export type RelationConfigs<T extends readonly (EntityEnum | VirtualEntityEnum)[], E extends EnumEntityType<EntityEnum>> = {
16
+ [K in keyof T]: T[K] extends EntityEnum | VirtualEntityEnum ? IRelationConfig<T[K], E> : never;
17
+ };
18
+ export declare class ClientEntity extends BaseEntityModel<EntityEnum.CLIENT> implements IClientApiEntity {
19
+ createdOn: string;
20
+ updatedOn: string;
21
+ id: number;
22
+ name: string;
23
+ description?: string;
24
+ primaryContactName: string;
25
+ primaryContact: string;
26
+ primaryEmail: string;
27
+ secondaryContactName?: string;
28
+ secondaryEmail?: string;
29
+ address?: string;
30
+ secondaryContact?: string;
31
+ country?: string;
32
+ industry?: string;
33
+ zipCode?: string;
34
+ organizationId: number;
35
+ reference?: string;
36
+ createdBy: number;
37
+ updatedBy: number;
38
+ projectIds?: number[];
39
+ billingOverdueDays: number;
40
+ projects: ProjectEntity[];
41
+ getRelationConfigs(): any;
42
+ static relationConfigs: RelationConfigs<[
43
+ EntityEnum.PROJECT
44
+ ], EnumEntityType<EntityEnum.CLIENT>>;
45
+ static fromApiEntity(apiEntity: IClientApiEntity): ClientEntity;
46
+ populateProjectIds(projects: ProjectEntity[]): ClientEntity;
47
+ }
48
+ export {};
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClientEntity = 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 ClientEntity extends base_entity_model_1.BaseEntityModel {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.createdOn = `${new Date()}`;
10
+ this.updatedOn = `${new Date()}`;
11
+ this.id = 0;
12
+ this.name = "";
13
+ this.primaryContactName = "";
14
+ this.primaryContact = "";
15
+ this.primaryEmail = "";
16
+ this.organizationId = 0;
17
+ this.createdBy = 0;
18
+ this.updatedBy = 0;
19
+ this.billingOverdueDays = 0;
20
+ this.projects = [];
21
+ }
22
+ getRelationConfigs() {
23
+ // return this.constructor.prototype.relationConfigs || [];
24
+ return this.constructor.prototype.constructor.relationConfigs;
25
+ }
26
+ static fromApiEntity(apiEntity) {
27
+ const entity = new ClientEntity(entity_utils_interface_1.EntityEnum.CLIENT);
28
+ Object.assign(entity, apiEntity);
29
+ return entity;
30
+ }
31
+ populateProjectIds(projects) {
32
+ this.projectIds = projects
33
+ .filter((project) => project.clientId === this.id)
34
+ .map((project) => project.id);
35
+ return this;
36
+ }
37
+ }
38
+ exports.ClientEntity = ClientEntity;
39
+ ClientEntity.relationConfigs = [
40
+ {
41
+ name: entity_utils_interface_1.EntityEnum.PROJECT,
42
+ relation: base_entity_model_1.RelationType.MANY,
43
+ key: "projects",
44
+ mapKeyConfig: {
45
+ relationKey: "clientId",
46
+ key: "id",
47
+ },
48
+ },
49
+ ];
@@ -1,4 +1,5 @@
1
1
  import { ConfigurationKeyEnum, ConfigurationTypeEnum, IConfigurationEntity } from "..";
2
+ import { IConfigurationApiEntity } from "../../api";
2
3
  export interface IConfigurationsModel extends IConfigurationEntity {
3
4
  isCronJobKey(): boolean;
4
5
  }
@@ -17,4 +18,5 @@ export declare class ConfigurationsModel implements IConfigurationsModel {
17
18
  constructor(data: IConfigurationEntity);
18
19
  isCronJobKey(): boolean;
19
20
  static findByKey(configurationEntities: IConfigurationEntity[], key: ConfigurationKeyEnum): IConfigurationEntity | undefined;
21
+ static fromApiEntity(apiEntity: IConfigurationApiEntity): ConfigurationsModel;
20
22
  }
@@ -23,5 +23,10 @@ class ConfigurationsModel {
23
23
  static findByKey(configurationEntities, key) {
24
24
  return configurationEntities.find((configurationEntity) => configurationEntity.key === key);
25
25
  }
26
+ static fromApiEntity(apiEntity) {
27
+ const entity = new ConfigurationsModel((0, __1.ConvertApiToEntity)(apiEntity));
28
+ Object.assign(entity, apiEntity);
29
+ return entity;
30
+ }
26
31
  }
27
32
  exports.ConfigurationsModel = ConfigurationsModel;
@@ -0,0 +1,25 @@
1
+ import { EntityEnum, EnumEntityType, IBaseEntityApiResponse, VirtualEntityEnum } from "../interface/entity.utils.interface";
2
+ import { BillingReimbursementExpneseEntity } from "./billing-reimbursement-expense.entity.model";
3
+ import { BillingEntityModel } from "./billing.entity.model";
4
+ import { ClientEntity } from "./client.entity.model";
5
+ import { ProjectUserMappingEntity } from "./project-user-mapping.entity.model";
6
+ import { ProjectEntity } from "./project.entity.model";
7
+ import { ReimbursementExpenseEntity } from "./reimbursement-expense.entity.model";
8
+ import { ReimbursementEntity } from "./reimbursement.entity.model";
9
+ import { UserEntity } from "./user.entity.model";
10
+ export type EnumToModel<T extends EntityEnum | VirtualEntityEnum> = T extends EntityEnum.BILLING ? BillingEntityModel : T extends EntityEnum.CLIENT ? ClientEntity : T extends EntityEnum.PROJECT ? ProjectEntity : T extends EntityEnum.PROJECT_USER_MAPPING ? ProjectUserMappingEntity : T extends EntityEnum.REIMBURSEMENT ? ReimbursementEntity : T extends EntityEnum.REIMBURSEMENT_EXPENSE ? ReimbursementExpenseEntity : T extends EntityEnum.BILLING_REIMBURSEMENT_EXPENSE ? BillingReimbursementExpneseEntity : UserEntity;
11
+ export type EntityMap = {
12
+ [key in EntityEnum]: EnumToModel<key>[];
13
+ };
14
+ export type EntityIndexMap = {
15
+ [key in EntityEnum]: {
16
+ [id: number]: EnumToModel<key>;
17
+ };
18
+ };
19
+ export declare function mapToIndex(entityMap: EntityMap): EntityIndexMap;
20
+ export declare function getEntityIndexMap<T extends EntityEnum>(data: IBaseEntityApiResponse<EnumEntityType<T>>, baseEntity: T, reusedConfig?: {
21
+ existingEntityIndexMap: EntityIndexMap;
22
+ enumEntities: EntityEnum[];
23
+ }): EntityIndexMap;
24
+ export declare function populateRelationsFor(entityIndexMap: EntityIndexMap, enumEntities: EntityEnum[]): void;
25
+ export declare function parseEntities<T extends EnumEntityType<EntityEnum>>(json: IBaseEntityApiResponse<T>, baseEntity: EntityEnum, entityMap: EntityMap): EntityMap;