law-common 10.51.0 → 10.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +1 -1
  2. package/dist/jest.config.d.ts +1 -1
  3. package/dist/src/@api.d.ts +1 -1
  4. package/dist/src/api/interface/leave.api.d.ts +10 -0
  5. package/dist/src/constants/entity_constants.js +1 -4
  6. package/dist/src/constants/util.constants.js +1 -12
  7. package/dist/src/entities/flow-configs/leave.flow.config.d.ts +4 -2
  8. package/dist/src/entities/flow-configs/work_from_home.flow.config.d.ts +2 -0
  9. package/dist/src/entities/flow-configs/work_from_home.flow.config.js +91 -0
  10. package/dist/src/entities/index.d.ts +5 -2
  11. package/dist/src/entities/index.js +5 -2
  12. package/dist/src/entities/interface/entity.utils.interface.d.ts +3 -5
  13. package/dist/src/entities/interface/leave.entity.interface.js +2 -22
  14. package/dist/src/entities/model/address_book.model.js +1 -1
  15. package/dist/src/entities/model/base.entity.model.js +1 -3
  16. package/dist/src/entities/model/billing-transaction.model.d.ts +1 -6
  17. package/dist/src/entities/model/billing-transaction.model.js +1 -3
  18. package/dist/src/entities/model/billing.entity.model.js +13 -35
  19. package/dist/src/entities/model/client.entity.model.d.ts +1 -3
  20. package/dist/src/entities/model/client.entity.model.js +1 -3
  21. package/dist/src/entities/model/entity.model.interface.js +9 -13
  22. package/dist/src/entities/model/interface/row-actions.interface.d.ts +6 -0
  23. package/dist/src/entities/model/interface/row-actions.interface.js +2 -0
  24. package/dist/src/entities/model/leave.entity.model.d.ts +2 -5
  25. package/dist/src/entities/model/leave.entity.model.js +18 -56
  26. package/dist/src/entities/model/organization_type_tds_rate_mapping.entity.model.d.ts +1 -4
  27. package/dist/src/entities/model/permissions.entity.model.d.ts +1 -3
  28. package/dist/src/entities/model/permissions.entity.model.js +1 -3
  29. package/dist/src/entities/model/project-user-mapping.entity.model.d.ts +1 -4
  30. package/dist/src/entities/model/project.entity.model.d.ts +1 -4
  31. package/dist/src/entities/model/reimbursement-expense.entity.model.d.ts +1 -3
  32. package/dist/src/entities/model/role-permission.entity.model.d.ts +1 -4
  33. package/dist/src/entities/model/tds_rate.entity.model.d.ts +1 -3
  34. package/dist/src/entities/model/tds_rate.entity.model.js +1 -1
  35. package/dist/src/entities/model/voucher_type.entity.model.d.ts +1 -3
  36. package/dist/src/entities/model/work-from-home.entity.model.d.ts +38 -0
  37. package/dist/src/entities/model/work-from-home.entity.model.js +109 -0
  38. package/dist/src/enums/currency.enum.js +2 -6
  39. package/dist/src/enums/time.unit.enum.js +1 -3
  40. package/dist/src/utils/array.util.js +2 -4
  41. package/dist/src/utils/entity.flow.util.d.ts +52 -3
  42. package/dist/src/utils/entity.flow.util.js +102 -8
  43. package/dist/src/utils/helper.fn.util.d.ts +11 -0
  44. package/dist/src/utils/helper.fn.util.js +22 -21
  45. package/dist/src/utils/models/date-code.model.util.js +2 -5
  46. package/dist/src/utils/models/json.generator.js +1 -2
  47. package/dist/src/utils/string.util.js +1 -3
  48. package/dist/tests/json.generator.spec.js +1 -6
  49. package/package.json +5 -2
package/README.md CHANGED
@@ -1 +1 @@
1
- # law-common
1
+ # law-common
@@ -1,3 +1,3 @@
1
- import type { Config } from '@jest/types';
1
+ import type { Config } from "@jest/types";
2
2
  declare const config: Config.InitialOptions;
3
3
  export default config;
@@ -1 +1 @@
1
- export * from './api';
1
+ export * from "./api";
@@ -14,3 +14,13 @@ export type ILeaveFlowConfig = {
14
14
  };
15
15
  };
16
16
  };
17
+ export type FlowConfig<S extends string, A extends string> = {
18
+ [key in S]?: {
19
+ actions: {
20
+ [key in A]?: {
21
+ permissions: string[];
22
+ next: () => S;
23
+ };
24
+ };
25
+ };
26
+ };
@@ -14,9 +14,6 @@ exports.usersToExcludeFromSearchResponse = ["DB migration"];
14
14
  exports.systemUsers = ["DB migration"];
15
15
  exports.reimbursementExpenseProjectUserInactiveBuffer = 24 * 60;
16
16
  exports.annualPaidLeaves = 24;
17
- exports.allowedProjectUpdateBillingStatuses = [
18
- entities_1.BillingStatusEnum.SETTLED,
19
- entities_1.BillingStatusEnum.CANCELLED,
20
- ];
17
+ exports.allowedProjectUpdateBillingStatuses = [entities_1.BillingStatusEnum.SETTLED, entities_1.BillingStatusEnum.CANCELLED];
21
18
  exports.invalidFileNameCharacter = [","];
22
19
  exports.rupeeIcon = "₹";
@@ -23,15 +23,4 @@ exports.onesValues = [
23
23
  "Eighteen",
24
24
  "Nineteen",
25
25
  ];
26
- exports.tensValues = [
27
- "",
28
- "",
29
- "Twenty",
30
- "Thirty",
31
- "Forty",
32
- "Fifty",
33
- "Sixty",
34
- "Seventy",
35
- "Eighty",
36
- "Ninety",
37
- ];
26
+ exports.tensValues = ["", "", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"];
@@ -1,2 +1,4 @@
1
- import { ILeaveFlowConfig } from "../../api";
2
- export declare const leaveFlowConfig: ILeaveFlowConfig;
1
+ import { FlowConfig } from "../../api";
2
+ import { LeaveActionEnum } from "../enums/leave.action.enum";
3
+ import { LeaveStatusEnum } from "../enums/leave.status.enum";
4
+ export declare const leaveFlowConfig: FlowConfig<LeaveStatusEnum, LeaveActionEnum>;
@@ -0,0 +1,2 @@
1
+ import { IWorkFromHomeFlowConfig } from "../../api";
2
+ export declare const workFromHomeFlowConfig: IWorkFromHomeFlowConfig;
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.workFromHomeFlowConfig = void 0;
4
+ const work_from_home_action_enum_1 = require("../enums/work.from.home.action.enum");
5
+ const work_from_home_status_enum_1 = require("../enums/work.from.home.status.enum");
6
+ exports.workFromHomeFlowConfig = {
7
+ [work_from_home_status_enum_1.WorkFromHomeStatusEnum.PENDING_APPROVAL]: {
8
+ actions: {
9
+ [work_from_home_action_enum_1.WorkFromHomeActionEnum.EDIT]: {
10
+ permissions: ["WORK_FROM_HOME_UPDATE_SELF", "WORK_FROM_HOME_UPDATE_ORG"],
11
+ next: () => work_from_home_status_enum_1.WorkFromHomeStatusEnum.PENDING_APPROVAL,
12
+ },
13
+ [work_from_home_action_enum_1.WorkFromHomeActionEnum.APPROVE]: {
14
+ permissions: ["WORK_FROM_HOME_APPROVER_ORG"],
15
+ next: () => work_from_home_status_enum_1.WorkFromHomeStatusEnum.APPROVED,
16
+ },
17
+ [work_from_home_action_enum_1.WorkFromHomeActionEnum.REJECT]: {
18
+ permissions: ["WORK_FROM_HOME_APPROVER_ORG"],
19
+ next: () => work_from_home_status_enum_1.WorkFromHomeStatusEnum.REJECTED,
20
+ },
21
+ [work_from_home_action_enum_1.WorkFromHomeActionEnum.DELETE]: {
22
+ permissions: ["WORK_FROM_HOME_DELETE_SELF"],
23
+ next: () => work_from_home_status_enum_1.WorkFromHomeStatusEnum.DELETED,
24
+ },
25
+ },
26
+ },
27
+ [work_from_home_status_enum_1.WorkFromHomeStatusEnum.EDIT_APPROVAL]: {
28
+ actions: {
29
+ [work_from_home_action_enum_1.WorkFromHomeActionEnum.EDIT]: {
30
+ permissions: ["WORK_FROM_HOME_UPDATE_SELF", "WORK_FROM_HOME_UPDATE_ORG"],
31
+ next: () => work_from_home_status_enum_1.WorkFromHomeStatusEnum.EDIT_APPROVAL,
32
+ },
33
+ [work_from_home_action_enum_1.WorkFromHomeActionEnum.RECALL]: {
34
+ permissions: ["WORK_FROM_HOME_UPDATE_SELF", "WORK_FROM_HOME_UPDATE_ORG"],
35
+ next: () => work_from_home_status_enum_1.WorkFromHomeStatusEnum.DELETE_APPROVAL,
36
+ },
37
+ [work_from_home_action_enum_1.WorkFromHomeActionEnum.REJECT]: {
38
+ permissions: ["WORK_FROM_HOME_APPROVER_ORG"],
39
+ next: () => work_from_home_status_enum_1.WorkFromHomeStatusEnum.RESOLVE_REJECTED,
40
+ },
41
+ [work_from_home_action_enum_1.WorkFromHomeActionEnum.APPROVE]: {
42
+ permissions: ["WORK_FROM_HOME_APPROVER_ORG"],
43
+ next: () => work_from_home_status_enum_1.WorkFromHomeStatusEnum.APPROVED,
44
+ },
45
+ },
46
+ },
47
+ [work_from_home_status_enum_1.WorkFromHomeStatusEnum.DELETE_APPROVAL]: {
48
+ actions: {
49
+ [work_from_home_action_enum_1.WorkFromHomeActionEnum.EDIT]: {
50
+ permissions: ["WORK_FROM_HOME_UPDATE_SELF", "WORK_FROM_HOME_UPDATE_ORG"],
51
+ next: () => work_from_home_status_enum_1.WorkFromHomeStatusEnum.DELETE_APPROVAL,
52
+ },
53
+ [work_from_home_action_enum_1.WorkFromHomeActionEnum.RECALL]: {
54
+ permissions: ["WORK_FROM_HOME_UPDATE_SELF", "WORK_FROM_HOME_UPDATE_ORG"],
55
+ next: () => work_from_home_status_enum_1.WorkFromHomeStatusEnum.DELETED,
56
+ },
57
+ [work_from_home_action_enum_1.WorkFromHomeActionEnum.REJECT]: {
58
+ permissions: ["WORK_FROM_HOME_APPROVER_ORG"],
59
+ next: () => work_from_home_status_enum_1.WorkFromHomeStatusEnum.RESOLVE_REJECTED,
60
+ },
61
+ [work_from_home_action_enum_1.WorkFromHomeActionEnum.APPROVE]: {
62
+ permissions: ["WORK_FROM_HOME_APPROVER_ORG"],
63
+ next: () => work_from_home_status_enum_1.WorkFromHomeStatusEnum.DELETED,
64
+ },
65
+ },
66
+ },
67
+ [work_from_home_status_enum_1.WorkFromHomeStatusEnum.APPROVED]: {
68
+ actions: {
69
+ [work_from_home_action_enum_1.WorkFromHomeActionEnum.EDIT]: {
70
+ permissions: ["WORK_FROM_HOME_UPDATE_SELF", "WORK_FROM_HOME_UPDATE_ORG"],
71
+ next: () => work_from_home_status_enum_1.WorkFromHomeStatusEnum.EDIT_APPROVAL,
72
+ },
73
+ [work_from_home_action_enum_1.WorkFromHomeActionEnum.DELETE]: {
74
+ permissions: ["WORK_FROM_HOME_DELETE_SELF"],
75
+ next: () => work_from_home_status_enum_1.WorkFromHomeStatusEnum.DELETE_APPROVAL,
76
+ },
77
+ },
78
+ },
79
+ [work_from_home_status_enum_1.WorkFromHomeStatusEnum.RESOLVE_REJECTED]: {
80
+ actions: {
81
+ [work_from_home_action_enum_1.WorkFromHomeActionEnum.EDIT]: {
82
+ permissions: ["WORK_FROM_HOME_UPDATE_SELF", "WORK_FROM_HOME_UPDATE_ORG"],
83
+ next: () => work_from_home_status_enum_1.WorkFromHomeStatusEnum.EDIT_APPROVAL,
84
+ },
85
+ [work_from_home_action_enum_1.WorkFromHomeActionEnum.DELETE]: {
86
+ permissions: ["WORK_FROM_HOME_DELETE_SELF"],
87
+ next: () => work_from_home_status_enum_1.WorkFromHomeStatusEnum.DELETE_APPROVAL,
88
+ },
89
+ },
90
+ },
91
+ };
@@ -118,13 +118,16 @@ export * from "./model/organization_type_tds_rate_mapping.entity.model";
118
118
  export * from "./enums/tds_rate_status_enum";
119
119
  export * from "./interface/tds_rate.entity.interface";
120
120
  export * from "./model/tds_rate.entity.model";
121
- export * from "./interface/tds_rate_voucher_type_mapping.entity.interface";
122
- export * from "./model/tds_rate_voucher_type_mapping.entity.model";
123
121
  export * from "./enums/voucher_type_status_enum";
122
+ export * from "./interface/tds_rate_voucher_type_mapping.entity.interface";
124
123
  export * from "./interface/voucher_type.entity.interface";
124
+ export * from "./model/tds_rate_voucher_type_mapping.entity.model";
125
125
  export * from "./model/voucher_type.entity.model";
126
126
  export * from "./model/interface/billing.model.interface";
127
127
  export * from "./flow-configs/leave.flow.config";
128
+ export * from "./flow-configs/work_from_home.flow.config";
129
+ export * from "./model/interface/row-actions.interface";
130
+ export * from "./model/work-from-home.entity.model";
128
131
  export * from "./flow-configs/billing.flow.config";
129
132
  export * from "./model/permissions.entity.model";
130
133
  export * from "./model/role-permission.entity.model";
@@ -134,13 +134,16 @@ __exportStar(require("./model/organization_type_tds_rate_mapping.entity.model"),
134
134
  __exportStar(require("./enums/tds_rate_status_enum"), exports);
135
135
  __exportStar(require("./interface/tds_rate.entity.interface"), exports);
136
136
  __exportStar(require("./model/tds_rate.entity.model"), exports);
137
- __exportStar(require("./interface/tds_rate_voucher_type_mapping.entity.interface"), exports);
138
- __exportStar(require("./model/tds_rate_voucher_type_mapping.entity.model"), exports);
139
137
  __exportStar(require("./enums/voucher_type_status_enum"), exports);
138
+ __exportStar(require("./interface/tds_rate_voucher_type_mapping.entity.interface"), exports);
140
139
  __exportStar(require("./interface/voucher_type.entity.interface"), exports);
140
+ __exportStar(require("./model/tds_rate_voucher_type_mapping.entity.model"), exports);
141
141
  __exportStar(require("./model/voucher_type.entity.model"), exports);
142
142
  __exportStar(require("./model/interface/billing.model.interface"), exports);
143
143
  __exportStar(require("./flow-configs/leave.flow.config"), exports);
144
+ __exportStar(require("./flow-configs/work_from_home.flow.config"), exports);
145
+ __exportStar(require("./model/interface/row-actions.interface"), exports);
146
+ __exportStar(require("./model/work-from-home.entity.model"), exports);
144
147
  __exportStar(require("./flow-configs/billing.flow.config"), exports);
145
148
  __exportStar(require("./model/permissions.entity.model"), exports);
146
149
  __exportStar(require("./model/role-permission.entity.model"), exports);
@@ -33,6 +33,7 @@ import { TdsRateVoucherTypeMappingEntityModel } from "../model/tds_rate_voucher_
33
33
  import { TimesheetEntityModel } from "../model/timesheet.entity.model";
34
34
  import { UserEntityModel } from "../model/user.entity.model";
35
35
  import { VoucherTypeEntityModel } from "../model/voucher_type.entity.model";
36
+ import { WorkFromHomeEntityModel } from "../model/work-from-home.entity.model";
36
37
  import { IAddressBookEntity } from "./address-book.entity.interface";
37
38
  import { IBankEntity } from "./bank.entity.interface";
38
39
  import { IBankHistoryEntity } from "./bank_history.entity.interface";
@@ -246,10 +247,7 @@ export type ISearchIncludeEntity<T extends EntityEnum | VirtualEntityEnum> = {
246
247
  [key in keyof EnumEntityType<EntityRelations[T]>]?: EnumEntityType<EntityRelations[T]>[key][];
247
248
  };
248
249
  range?: {
249
- [key in keyof EnumEntityType<T>]?: [
250
- EnumEntityType<T>[key],
251
- EnumEntityType<T>[key]
252
- ];
250
+ [key in keyof EnumEntityType<T>]?: [EnumEntityType<T>[key], EnumEntityType<T>[key]];
253
251
  };
254
252
  ge?: {
255
253
  [key in keyof EnumEntityType<EntityRelations[T]>]?: EnumEntityType<EntityRelations[T]>[key];
@@ -311,7 +309,7 @@ export declare enum VirtualEntityEnum {
311
309
  }
312
310
  export type IHistoryConstraintSearchResponse<T> = IBaseResponse<IHistoryEntitySearchByConstraintResponse<T>[]>;
313
311
  export type IHistoryConstraintSearchServiceResponse<T> = IHistoryEntitySearchByConstraintResponse<T>[];
314
- export type EnumToModel<T extends EntityEnum | VirtualEntityEnum> = T extends EntityEnum.BILLING ? BillingEntityModel : T extends EntityEnum.CLIENT ? ClientEntityModel : T extends EntityEnum.PROJECT ? ProjectEntityModel : T extends EntityEnum.PROJECT_USER_MAPPING ? ProjectUserMappingEntityModel : T extends EntityEnum.REIMBURSEMENT ? ReimbursementEntityModel : T extends EntityEnum.REIMBURSEMENT_EXPENSE ? ReimbursementExpenseEntityModel : T extends EntityEnum.BILLING_REIMBURSEMENT_EXPENSE ? BillingReimbursementExpneseEntityModel : T extends EntityEnum.LEAVE ? LeaveEntityModel : T extends EntityEnum.HOLIDAY ? HolidayEntityModel : T extends VirtualEntityEnum.LEAVE_COUNT ? LeaveCountVirtualEntityModel : T extends EntityEnum.CLIENT_AFFILIATE ? ClientAffiliateEntityModel : T extends EntityEnum.BANK ? BankEntityModel : T extends EntityEnum.CONFIGURATION ? ConfigurationEntityModel : T extends EntityEnum.TASK ? TaskEntityModel : T extends EntityEnum.BILLING_TIMESHEET ? BillingTimesheetEntityModel : T extends EntityEnum.TIMESHEET ? TimesheetEntityModel : T extends EntityEnum.COUNTRY ? CountryEntityModel : T extends EntityEnum.BILLING_TRANSACTION ? BillingTransactionEntityModel : T extends EntityEnum.ADDRESS_BOOK ? AddressBookEntityModel : T extends EntityEnum.STATE ? StateEntityModel : T extends EntityEnum.GST_RATE ? GstRateEntityModel : T extends EntityEnum.ORGANIZATION_TYPE ? OrganizationTypeEntityModel : T extends EntityEnum.ORGANIZATION_TYPE_TDS_RATE_MAPPING ? OrganizationTypeTdsRateMappingEntityModel : T extends EntityEnum.TDS_RATE ? TdsRateEntityModel : T extends EntityEnum.ROLE ? RoleEntityModel : T extends EntityEnum.ROLE_PERMISSION_MAPPING ? RolePermissionMappingEntityModel : T extends EntityEnum.PERMISSION ? PermissionEntityModel : T extends EntityEnum.VOUCHER_TYPE ? VoucherTypeEntityModel : T extends EntityEnum.TDS_RATE_VOUCHER_TYPE_MAPPING ? TdsRateVoucherTypeMappingEntityModel : UserEntityModel;
312
+ export type EnumToModel<T extends EntityEnum | VirtualEntityEnum> = T extends EntityEnum.BILLING ? BillingEntityModel : T extends EntityEnum.CLIENT ? ClientEntityModel : T extends EntityEnum.PROJECT ? ProjectEntityModel : T extends EntityEnum.PROJECT_USER_MAPPING ? ProjectUserMappingEntityModel : T extends EntityEnum.REIMBURSEMENT ? ReimbursementEntityModel : T extends EntityEnum.REIMBURSEMENT_EXPENSE ? ReimbursementExpenseEntityModel : T extends EntityEnum.BILLING_REIMBURSEMENT_EXPENSE ? BillingReimbursementExpneseEntityModel : T extends EntityEnum.LEAVE ? LeaveEntityModel : T extends EntityEnum.WORK_FROM_HOME ? WorkFromHomeEntityModel : T extends EntityEnum.HOLIDAY ? HolidayEntityModel : T extends VirtualEntityEnum.LEAVE_COUNT ? LeaveCountVirtualEntityModel : T extends EntityEnum.CLIENT_AFFILIATE ? ClientAffiliateEntityModel : T extends EntityEnum.BANK ? BankEntityModel : T extends EntityEnum.CONFIGURATION ? ConfigurationEntityModel : T extends EntityEnum.TASK ? TaskEntityModel : T extends EntityEnum.BILLING_TIMESHEET ? BillingTimesheetEntityModel : T extends EntityEnum.TIMESHEET ? TimesheetEntityModel : T extends EntityEnum.COUNTRY ? CountryEntityModel : T extends EntityEnum.BILLING_TRANSACTION ? BillingTransactionEntityModel : T extends EntityEnum.ADDRESS_BOOK ? AddressBookEntityModel : T extends EntityEnum.STATE ? StateEntityModel : T extends EntityEnum.GST_RATE ? GstRateEntityModel : T extends EntityEnum.ORGANIZATION_TYPE ? OrganizationTypeEntityModel : T extends EntityEnum.TDS_RATE ? TdsRateEntityModel : T extends EntityEnum.ORGANIZATION_TYPE_TDS_RATE_MAPPING ? OrganizationTypeTdsRateMappingEntityModel : T extends EntityEnum.VOUCHER_TYPE ? VoucherTypeEntityModel : T extends EntityEnum.TDS_RATE_VOUCHER_TYPE_MAPPING ? TdsRateVoucherTypeMappingEntityModel : T extends EntityEnum.ROLE ? RoleEntityModel : T extends EntityEnum.ROLE_PERMISSION_MAPPING ? RolePermissionMappingEntityModel : T extends EntityEnum.PERMISSION ? PermissionEntityModel : UserEntityModel;
315
313
  export type EntityMap = {
316
314
  [key in EntityEnum | VirtualEntityEnum]: EnumToModel<key>[];
317
315
  };
@@ -3,26 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.virtualEntityToKeysMap = void 0;
4
4
  const entity_utils_interface_1 = require("./entity.utils.interface");
5
5
  exports.virtualEntityToKeysMap = {
6
- [entity_utils_interface_1.VirtualEntityEnum.LEAVE_COUNT]: [
7
- "createdBy",
8
- "createdOn",
9
- "leaveId",
10
- "period",
11
- "updatedBy",
12
- "updatedOn",
13
- "count",
14
- "id",
15
- ],
16
- [entity_utils_interface_1.VirtualEntityEnum.USER_LEAVE]: [
17
- "createdBy",
18
- "createdOn",
19
- "id",
20
- "leavesPending",
21
- "leavesTaken",
22
- "period",
23
- "type",
24
- "updatedBy",
25
- "updatedOn",
26
- "userId",
27
- ],
6
+ [entity_utils_interface_1.VirtualEntityEnum.LEAVE_COUNT]: ["createdBy", "createdOn", "leaveId", "period", "updatedBy", "updatedOn", "count", "id"],
7
+ [entity_utils_interface_1.VirtualEntityEnum.USER_LEAVE]: ["createdBy", "createdOn", "id", "leavesPending", "leavesTaken", "period", "type", "updatedBy", "updatedOn", "userId"],
28
8
  };
@@ -41,5 +41,5 @@ AddressBookEntityModel.relationConfigs = [
41
41
  relationKey: "id",
42
42
  key: "introducedBy",
43
43
  },
44
- }
44
+ },
45
45
  ];
@@ -28,9 +28,7 @@ class BaseEntityModel {
28
28
  console.warn(`[populateRelationsByIndex] Missing child key "${childKey}" in parent "${parentKey}" on entity "${this.entityName}". Parent value:`, this[parentKey]);
29
29
  continue;
30
30
  }
31
- foundRelatedEntities = [
32
- relatedEntitiesIndex[this[parentKey][childKey]],
33
- ];
31
+ foundRelatedEntities = [relatedEntitiesIndex[this[parentKey][childKey]]];
34
32
  }
35
33
  else {
36
34
  // foundRelatedEntities = relatedEntities[this[thisKey]] ? [relatedEntities[this[thisKey]]] : [];
@@ -29,12 +29,7 @@ export declare class BillingTransactionEntityModel extends BaseEntityModel<Entit
29
29
  bank?: BankEntityModel;
30
30
  billing?: BillingEntityModel;
31
31
  getRelationConfigs(): any;
32
- static relationConfigs: RelationConfigs<[
33
- EntityEnum.USER,
34
- EntityEnum.USER,
35
- EntityEnum.BANK,
36
- EntityEnum.BILLING
37
- ], EntityEnum.BILLING_TRANSACTION>;
32
+ static relationConfigs: RelationConfigs<[EntityEnum.USER, EntityEnum.USER, EntityEnum.BANK, EntityEnum.BILLING], EntityEnum.BILLING_TRANSACTION>;
38
33
  static fromEntity(entity: IBillingTransactionEntity): BillingTransactionEntityModel;
39
34
  static sumAmounts(transactions: BillingTransactionEntityModel[]): number;
40
35
  }
@@ -36,9 +36,7 @@ class BillingTransactionEntityModel extends base_entity_model_1.BaseEntityModel
36
36
  return (0, utils_1.sumArray)(transactions.map((t) => {
37
37
  var _a;
38
38
  return ({
39
- amount: typeof t.amount === "string"
40
- ? (0, utils_1.getDecimalNumberFromString)(t.amount)
41
- : ((_a = t.amount) !== null && _a !== void 0 ? _a : 0),
39
+ amount: typeof t.amount === "string" ? (0, utils_1.getDecimalNumberFromString)(t.amount) : ((_a = t.amount) !== null && _a !== void 0 ? _a : 0),
42
40
  });
43
41
  }), "amount");
44
42
  }
@@ -75,8 +75,7 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
75
75
  var _a, _b, _c, _d;
76
76
  let overdue = false;
77
77
  if (configValue !== undefined &&
78
- this.mapStatusCategory(this.status) ===
79
- BillingStatusCategoryEnumForUI.PAYMENT_STATUS &&
78
+ this.mapStatusCategory(this.status) === BillingStatusCategoryEnumForUI.PAYMENT_STATUS &&
80
79
  this.status !== billing_status_enum_1.BillingStatusEnum.SETTLED) {
81
80
  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);
82
81
  const dueDate = new Date(this.createdOn);
@@ -99,11 +98,7 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
99
98
  billing_status_enum_1.BillingStatusEnum.CLIENT_REVISION_APPROVAL,
100
99
  billing_status_enum_1.BillingStatusEnum.REJECT_CLIENT_REVISION,
101
100
  ],
102
- [BillingStatusCategoryEnumForUI.PAYMENT_STATUS]: [
103
- billing_status_enum_1.BillingStatusEnum.INVOICE_SENT,
104
- billing_status_enum_1.BillingStatusEnum.PENDING_PAYMENT,
105
- billing_status_enum_1.BillingStatusEnum.SETTLED,
106
- ],
101
+ [BillingStatusCategoryEnumForUI.PAYMENT_STATUS]: [billing_status_enum_1.BillingStatusEnum.INVOICE_SENT, billing_status_enum_1.BillingStatusEnum.PENDING_PAYMENT, billing_status_enum_1.BillingStatusEnum.SETTLED],
107
102
  };
108
103
  // Validation: check if any status exists in more than one category
109
104
  const statusMap = new Map();
@@ -176,8 +171,7 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
176
171
  if (!actionVisibilityConfig[commonPermissions[0]]) {
177
172
  return true;
178
173
  }
179
- return commonPermissions.some((permission) => actionVisibilityConfig[permission] &&
180
- actionVisibilityConfig[permission]());
174
+ return commonPermissions.some((permission) => actionVisibilityConfig[permission] && actionVisibilityConfig[permission]());
181
175
  })
182
176
  .map(([actionKey, actionConfig]) => actionKey);
183
177
  }
@@ -203,8 +197,7 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
203
197
  return {};
204
198
  }
205
199
  getUseableTDSAmount(adjustedBillingTransactions) {
206
- return ((0, utils_1.getDecimalNumberFromString)(this.tdsAmount) -
207
- this.getUsedTDSAmount(adjustedBillingTransactions));
200
+ return (0, utils_1.getDecimalNumberFromString)(this.tdsAmount) - this.getUsedTDSAmount(adjustedBillingTransactions);
208
201
  }
209
202
  getUsedTDSAmount(adjustedBillingTransactions) {
210
203
  return (0, utils_1.sumNormalised)(adjustedBillingTransactions.filter((transaction) => transaction.type === billing_transaction_enum_1.BillingTransactionType.TDS), "amount");
@@ -213,61 +206,46 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
213
206
  return this.refundAmount;
214
207
  }
215
208
  getTotalTDSAmount(adjustedBillingTransactions) {
216
- return (this.getUseableTDSAmount(adjustedBillingTransactions) +
217
- this.getUsedTDSAmount(adjustedBillingTransactions));
209
+ return this.getUseableTDSAmount(adjustedBillingTransactions) + this.getUsedTDSAmount(adjustedBillingTransactions);
218
210
  }
219
211
  getTotalRecieptAmount(adjustedBillingTransactions) {
220
- return (this.getUseableRecieptAmount(adjustedBillingTransactions) +
221
- this.getUsedRecieptAmount(adjustedBillingTransactions));
212
+ return this.getUseableRecieptAmount(adjustedBillingTransactions) + this.getUsedRecieptAmount(adjustedBillingTransactions);
222
213
  }
223
214
  getUseableRecieptAmount(adjustedBillingTransactions) {
224
- return ((0, utils_1.getDecimalNumberFromString)(this.totalAmountPaid) -
225
- this.getUsedRecieptAmount(adjustedBillingTransactions));
215
+ return (0, utils_1.getDecimalNumberFromString)(this.totalAmountPaid) - this.getUsedRecieptAmount(adjustedBillingTransactions);
226
216
  }
227
217
  getUsedRecieptAmount(adjustedBillingTransactions) {
228
218
  return (0, utils_1.sumNormalised)(adjustedBillingTransactions.filter((transaction) => transaction.type === billing_transaction_enum_1.BillingTransactionType.RECEIPT), "amount");
229
219
  }
230
220
  getUseableAmount(adjustedBillingTransactions) {
231
- return (this.getUseableRecieptAmount(adjustedBillingTransactions) +
232
- this.getUseableTDSAmount(adjustedBillingTransactions) -
233
- this.getRefundedAmount());
221
+ return this.getUseableRecieptAmount(adjustedBillingTransactions) + this.getUseableTDSAmount(adjustedBillingTransactions) - this.getRefundedAmount();
234
222
  }
235
223
  getUsedAmount(adjustedBillingTransactions) {
236
- return (this.getUsedRecieptAmount(adjustedBillingTransactions) +
237
- this.getUsedTDSAmount(adjustedBillingTransactions));
224
+ return this.getUsedRecieptAmount(adjustedBillingTransactions) + this.getUsedTDSAmount(adjustedBillingTransactions);
238
225
  }
239
226
  getTotalAmountRecieved() {
240
227
  var _a, _b, _c, _d;
241
- const amountRecieved = (0, utils_1.sumNormalised)((_b = (_a = this.billingTransactions) === null || _a === void 0 ? void 0 : _a.filter((transaction) => [billing_transaction_enum_1.BillingTransactionType.TDS, billing_transaction_enum_1.BillingTransactionType.RECEIPT].includes(transaction.type))) !== null && _b !== void 0 ? _b : [], "amount") -
242
- (0, utils_1.sumNormalised)((_d = (_c = this.billingTransactions) === null || _c === void 0 ? void 0 : _c.filter((transaction) => transaction.type === billing_transaction_enum_1.BillingTransactionType.REFUND)) !== null && _d !== void 0 ? _d : [], "amount");
228
+ const amountRecieved = (0, utils_1.sumNormalised)((_b = (_a = this.billingTransactions) === null || _a === void 0 ? void 0 : _a.filter((transaction) => [billing_transaction_enum_1.BillingTransactionType.TDS, billing_transaction_enum_1.BillingTransactionType.RECEIPT].includes(transaction.type))) !== null && _b !== void 0 ? _b : [], "amount") - (0, utils_1.sumNormalised)((_d = (_c = this.billingTransactions) === null || _c === void 0 ? void 0 : _c.filter((transaction) => transaction.type === billing_transaction_enum_1.BillingTransactionType.REFUND)) !== null && _d !== void 0 ? _d : [], "amount");
243
229
  return amountRecieved;
244
230
  }
245
231
  getTotalRecievableAmount() {
246
232
  var _a, _b;
247
233
  return ((0, utils_1.getDecimalNumberFromString)(this.totalAmount) -
248
234
  (this.getTotalAmountRecieved() +
249
- (0, utils_1.sumNormalised)((_b = (_a = this.billingTransactions) === null || _a === void 0 ? void 0 : _a.filter((transaction) => [
250
- billing_transaction_enum_1.BillingTransactionType.CREDIT_NOTE,
251
- billing_transaction_enum_1.BillingTransactionType.WRITE_OFF,
252
- ].includes(transaction.type))) !== null && _b !== void 0 ? _b : [], "amount")));
235
+ (0, utils_1.sumNormalised)((_b = (_a = this.billingTransactions) === null || _a === void 0 ? void 0 : _a.filter((transaction) => [billing_transaction_enum_1.BillingTransactionType.CREDIT_NOTE, billing_transaction_enum_1.BillingTransactionType.WRITE_OFF].includes(transaction.type))) !== null && _b !== void 0 ? _b : [], "amount")));
253
236
  }
254
237
  validateAdvanceBillingId(adjustedBillingTransactions) {
255
238
  const index = adjustedBillingTransactions.findIndex((item) => item.advanceBillingId === null);
256
239
  if (index !== -1) {
257
240
  throw new exceptions_1.AppBadRequestException({
258
241
  key: error_key_enum_1.ErrorKeyEnum.ADVANCE_BILLING_ID,
259
- message: [
260
- `advanceBillingId is missing in transaction at index ${index}`,
261
- ],
242
+ message: [`advanceBillingId is missing in transaction at index ${index}`],
262
243
  });
263
244
  }
264
245
  }
265
246
  getApprovedBillingTransactionsTotalAmount() {
266
247
  var _a, _b;
267
- return (0, utils_1.sumNormalised)((_b = (_a = this.billingTransactions) === null || _a === void 0 ? void 0 : _a.filter((entity) => ![
268
- billing_transaction_status_enum_1.BillingTransactionStatusEnum.CREDITNOTE_APPROVAL_PENDING,
269
- billing_transaction_status_enum_1.BillingTransactionStatusEnum.WRITEOFF_APPROVAL_PENDING,
270
- ].includes(entity.status))) !== null && _b !== void 0 ? _b : [], "amount");
248
+ return (0, utils_1.sumNormalised)((_b = (_a = this.billingTransactions) === null || _a === void 0 ? void 0 : _a.filter((entity) => ![billing_transaction_status_enum_1.BillingTransactionStatusEnum.CREDITNOTE_APPROVAL_PENDING, billing_transaction_status_enum_1.BillingTransactionStatusEnum.WRITEOFF_APPROVAL_PENDING].includes(entity.status))) !== null && _b !== void 0 ? _b : [], "amount");
271
249
  }
272
250
  }
273
251
  exports.BillingEntityModel = BillingEntityModel;
@@ -27,9 +27,7 @@ export declare class ClientEntityModel extends BaseEntityModel<EntityEnum.CLIENT
27
27
  billingOverdueDays: number;
28
28
  projects: ProjectEntityModel[];
29
29
  getRelationConfigs(): any;
30
- static relationConfigs: RelationConfigs<[
31
- EntityEnum.PROJECT
32
- ], EntityEnum.CLIENT>;
30
+ static relationConfigs: RelationConfigs<[EntityEnum.PROJECT], EntityEnum.CLIENT>;
33
31
  static fromEntity(apiEntity: IClientEntity): ClientEntityModel;
34
32
  populateProjectIds(projects: ProjectEntityModel[]): ClientEntityModel;
35
33
  }
@@ -30,9 +30,7 @@ class ClientEntityModel extends base_entity_model_1.BaseEntityModel {
30
30
  return entity;
31
31
  }
32
32
  populateProjectIds(projects) {
33
- this.projectIds = projects
34
- .filter((project) => project.clientId === this.id)
35
- .map((project) => project.id);
33
+ this.projectIds = projects.filter((project) => project.clientId === this.id).map((project) => project.id);
36
34
  return this;
37
35
  }
38
36
  }
@@ -41,6 +41,7 @@ const tds_rate_voucher_type_mapping_entity_model_1 = require("./tds_rate_voucher
41
41
  const timesheet_entity_model_1 = require("./timesheet.entity.model");
42
42
  const user_entity_model_1 = require("./user.entity.model");
43
43
  const voucher_type_entity_model_1 = require("./voucher_type.entity.model");
44
+ const work_from_home_entity_model_1 = require("./work-from-home.entity.model");
44
45
  function mapToIndex(entityMap) {
45
46
  return Object.keys(entityMap).reduce((acc, key) => {
46
47
  // @ts-ignore
@@ -79,6 +80,7 @@ exports.entityEnumToEntityModel = {
79
80
  [entity_utils_interface_1.EntityEnum.BILLING_REIMBURSEMENT_EXPENSE]: billing_reimbursement_expense_entity_model_1.BillingReimbursementExpneseEntityModel.fromEntity,
80
81
  [entity_utils_interface_1.EntityEnum.HOLIDAY]: holiday_entity_model_1.HolidayEntityModel.fromEntity,
81
82
  [entity_utils_interface_1.EntityEnum.LEAVE]: leave_entity_model_1.LeaveEntityModel.fromEntity,
83
+ [entity_utils_interface_1.EntityEnum.WORK_FROM_HOME]: work_from_home_entity_model_1.WorkFromHomeEntityModel.fromEntity,
82
84
  [entity_utils_interface_1.VirtualEntityEnum.LEAVE_COUNT]: leave_count_entity_model_1.LeaveCountVirtualEntityModel.fromEntity,
83
85
  // Add other entities here as needed
84
86
  [entity_utils_interface_1.EntityEnum.CLIENT_AFFILIATE]: client_affiliate_entity_model_1.ClientAffiliateEntityModel.fromEntity,
@@ -115,9 +117,7 @@ function parseEntities(json, baseEntity, entityMap) {
115
117
  if (!(baseEntity in exports.entityEnumToEntityModel)) {
116
118
  throw new Error(`Unknown entity: ${baseEntity}`);
117
119
  }
118
- entityMap[baseEntity] = ((entityMap[baseEntity] && entityMap[baseEntity].length > 0
119
- ? [...entityMap[baseEntity], ...json["baseEntities"]]
120
- : json["baseEntities"]) || []).map(
120
+ entityMap[baseEntity] = ((entityMap[baseEntity] && entityMap[baseEntity].length > 0 ? [...entityMap[baseEntity], ...json["baseEntities"]] : json["baseEntities"]) || []).map(
121
121
  // @ts-ignore
122
122
  (e) => exports.entityEnumToEntityModel[baseEntity](e));
123
123
  if (json["relatedEntities"]) {
@@ -177,10 +177,9 @@ class EntityModelRelationHelper {
177
177
  if (!(entityName in exports.entityEnumToEntityModel)) {
178
178
  throw new Error(`Unknown entity: ${entityName}`);
179
179
  }
180
- this.entityModelMap[entityName] =
181
- this.entityMap[entityName].map((entity) => exports.entityEnumToEntityModel[entityName
182
- // @ts-ignore
183
- ](entity));
180
+ this.entityModelMap[entityName] = this.entityMap[entityName].map((entity) => exports.entityEnumToEntityModel[entityName
181
+ // @ts-ignore
182
+ ](entity));
184
183
  }
185
184
  return this;
186
185
  }
@@ -209,8 +208,7 @@ class EntityModelRelationHelper {
209
208
  }
210
209
  populateRelationsByEntityEnum(entityEnum) {
211
210
  for (const key of Object.keys(this.entityModelIndexMap[entityEnum] || {})) {
212
- const entityModel = this
213
- .entityModelIndexMap[entityEnum][key];
211
+ const entityModel = this.entityModelIndexMap[entityEnum][key];
214
212
  entityModel.populateRelationsByIndex(this.entityModelIndexMap);
215
213
  }
216
214
  }
@@ -219,8 +217,7 @@ class EntityModelRelationHelper {
219
217
  }
220
218
  addEntityModel(entityModel, config = { populateRelations: false }) {
221
219
  const entityEnum = entityModel.entityName;
222
- this.entityModelIndexMap[entityEnum] =
223
- this.entityModelIndexMap[entityEnum] || {};
220
+ this.entityModelIndexMap[entityEnum] = this.entityModelIndexMap[entityEnum] || {};
224
221
  // @ts-ignore
225
222
  this.entityModelIndexMap[entityEnum][entityModel.id] =
226
223
  // @ts-ignore
@@ -283,8 +280,7 @@ class EntityModelRelationHelper {
283
280
  }
284
281
  updateEntityModel(entityModel, config = { populateRelations: false }) {
285
282
  const entityEnum = entityModel.entityName;
286
- this.entityModelIndexMap[entityEnum] =
287
- this.entityModelIndexMap[entityEnum] || {};
283
+ this.entityModelIndexMap[entityEnum] = this.entityModelIndexMap[entityEnum] || {};
288
284
  // @ts-ignore
289
285
  this.entityModelIndexMap[entityEnum][entityModel.id] =
290
286
  // @ts-ignore
@@ -0,0 +1,6 @@
1
+ import { EntityEnum, EnumToModel } from "../../interface/entity.utils.interface";
2
+ export interface IRowActions<T extends EntityEnum> {
3
+ label: string;
4
+ value: string;
5
+ actionResolver?: (row: EnumToModel<T>) => void;
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -8,6 +8,7 @@ import { RelationType } from "../enums/relation-type.enum";
8
8
  import { EntityEnum, VirtualEntityEnum } from "../interface/entity.utils.interface";
9
9
  import { ILeaveEntity } from "../interface/leave.entity.interface";
10
10
  import { BaseEntityModel } from "./base.entity.model";
11
+ import { IRowActions } from "./interface/row-actions.interface";
11
12
  import { LeaveCountVirtualEntityModel } from "./leave_count.entity.model";
12
13
  import { UserEntityModel } from "./user.entity.model";
13
14
  export declare class LeaveEntityModel extends BaseEntityModel<EntityEnum.LEAVE> implements ILeaveEntity {
@@ -81,13 +82,9 @@ export declare class LeaveEntityModel extends BaseEntityModel<EntityEnum.LEAVE>
81
82
  label: string;
82
83
  }>;
83
84
  customLabels?: Partial<Record<LeaveActionEnum, string>>;
84
- }): Map<LeaveActionEnum | string, string>;
85
+ }): IRowActions<EntityEnum.LEAVE>[];
85
86
  getUpdateActionVisibility(currentUser: UserEntityModel): {
86
87
  [key: string]: () => boolean;
87
88
  };
88
- getAvailableActionsLabelValue(availableActionsFromModel: Map<LeaveActionEnum | string, string>): {
89
- label: string;
90
- value: string;
91
- }[];
92
89
  getNextStatus(currentUser: UserEntityModel, dto: ILeaveUpdateDto): LeaveStatusEnum;
93
90
  }