law-common 10.19.1-beta.9 → 10.20.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 (45) hide show
  1. package/dist/src/api/index.d.ts +0 -1
  2. package/dist/src/api/index.js +0 -1
  3. package/dist/src/api/interface/billing.create.dto.interface.d.ts +2 -2
  4. package/dist/src/api/interface/billing.transaction.create.dto.interface.d.ts +2 -7
  5. package/dist/src/api/interface/billing.transaction.entity.response.d.ts +1 -11
  6. package/dist/src/api/interface/billing.transaction.update.dto.interface.d.ts +2 -12
  7. package/dist/src/entities/func/convert-to-common-entity.func.js +2 -8
  8. package/dist/src/entities/index.d.ts +0 -5
  9. package/dist/src/entities/index.js +0 -5
  10. package/dist/src/entities/interface/billing.entity.interface.d.ts +0 -1
  11. package/dist/src/entities/interface/billing_timesheet.entity.interface.d.ts +2 -2
  12. package/dist/src/entities/interface/billing_transaction.entity.interface.d.ts +0 -7
  13. package/dist/src/entities/interface/entity.utils.interface.d.ts +4 -13
  14. package/dist/src/entities/interface/entity.utils.interface.js +0 -1
  15. package/dist/src/entities/model/base.entity.model.d.ts +2 -8
  16. package/dist/src/entities/model/base.entity.model.js +35 -43
  17. package/dist/src/entities/model/billing.entity.model.d.ts +1 -4
  18. package/dist/src/entities/model/billing.entity.model.js +0 -9
  19. package/dist/src/entities/model/entity.model.interface.d.ts +2 -12
  20. package/dist/src/entities/model/entity.model.interface.js +18 -61
  21. package/dist/src/entities/model/holiday.entity.model.d.ts +1 -14
  22. package/dist/src/entities/model/holiday.entity.model.js +42 -25
  23. package/dist/src/entities/model/leave.entity.model.d.ts +3 -50
  24. package/dist/src/entities/model/leave.entity.model.js +21 -154
  25. package/dist/src/utils/helper.fn.util.d.ts +1 -37
  26. package/dist/src/utils/helper.fn.util.js +0 -53
  27. package/dist/src/utils/index.d.ts +0 -2
  28. package/dist/src/utils/index.js +0 -2
  29. package/dist/src/utils/string.util.d.ts +0 -1
  30. package/dist/src/utils/string.util.js +0 -14
  31. package/package.json +35 -35
  32. package/dist/src/api/interface/billing-transaction-history.api.d.ts +0 -3
  33. package/dist/src/api/interface/billing-transaction-history.api.js +0 -2
  34. package/dist/src/entities/enums/billing-transaction-action.enum.d.ts +0 -11
  35. package/dist/src/entities/enums/billing-transaction-action.enum.js +0 -15
  36. package/dist/src/entities/enums/billing-transaction-status.enum.d.ts +0 -6
  37. package/dist/src/entities/enums/billing-transaction-status.enum.js +0 -10
  38. package/dist/src/entities/interface/billing-transaction-history.entity.d.ts +0 -7
  39. package/dist/src/entities/interface/billing-transaction-history.entity.js +0 -2
  40. package/dist/src/entities/model/billing-transaction.model.d.ts +0 -24
  41. package/dist/src/entities/model/billing-transaction.model.js +0 -56
  42. package/dist/src/entities/model/leave_count.entity.model.d.ts +0 -19
  43. package/dist/src/entities/model/leave_count.entity.model.js +0 -60
  44. package/dist/src/utils/entity.flow.util.d.ts +0 -32
  45. package/dist/src/utils/entity.flow.util.js +0 -83
@@ -83,4 +83,3 @@ export * from "./interface/to-do.entity.api";
83
83
  export * from "./interface/billing-reimbursement-expense.api";
84
84
  export * from "./interface/billing-reimbursement-expense-history.api";
85
85
  export * from "./interface/project-user-mapping.entity.api";
86
- export * from "./interface/billing-transaction-history.api";
@@ -99,4 +99,3 @@ __exportStar(require("./interface/to-do.entity.api"), exports);
99
99
  __exportStar(require("./interface/billing-reimbursement-expense.api"), exports);
100
100
  __exportStar(require("./interface/billing-reimbursement-expense-history.api"), exports);
101
101
  __exportStar(require("./interface/project-user-mapping.entity.api"), exports);
102
- __exportStar(require("./interface/billing-transaction-history.api"), exports);
@@ -16,7 +16,7 @@ export interface IBillingCreateDtoExtra {
16
16
  }
17
17
  export interface IBillingTimesheetUnchangedDto {
18
18
  id: number;
19
- amount?: number;
19
+ amount: number;
20
20
  }
21
21
  export interface IBillingTimesheetUpdateDeleteDetailDto {
22
22
  id: number;
@@ -24,7 +24,7 @@ export interface IBillingTimesheetUpdateDeleteDetailDto {
24
24
  description: string;
25
25
  date: string;
26
26
  duration: number;
27
- amount?: number;
27
+ amount: number;
28
28
  impact: BillingImpactEnum;
29
29
  amendmentPurpose: string;
30
30
  }
@@ -1,8 +1,3 @@
1
- import { BillingTransactionStatusEnum, IBillingEntity, IBillingTransactionEntity, IEntityCreateDto } from "../../entities";
2
- export type IBillingTransactionExclude = "status";
3
- export interface IBillingTransactionCreateDto extends Omit<IEntityCreateDto<IBillingTransactionEntity>, IBillingTransactionExclude> {
4
- status?: BillingTransactionStatusEnum;
5
- }
6
- export interface IBillingTransactionCreateDtoValidationData {
7
- billingEntity: IBillingEntity;
1
+ import { IBillingTransactionEntity, IEntityCreateDto } from "../../entities";
2
+ export interface IBillingTransactionCreateDto extends IEntityCreateDto<IBillingTransactionEntity> {
8
3
  }
@@ -1,4 +1,4 @@
1
- import { BillingTransactionActionEnum, BillingTransactionStatusEnum, IApiEntity, IBillingTransactionEntity } from "../../entities";
1
+ import { IApiEntity, IBillingTransactionEntity } from "../../entities";
2
2
  import { IBillingApiEntity } from "./billing.entity.api";
3
3
  export type IBillingTransactionApiEntity = IApiEntity<IBillingTransactionEntity>;
4
4
  export type IBillingTransactionApiEntityArray = IBillingTransactionApiEntity[];
@@ -6,13 +6,3 @@ export type IBillingTransactionEntityGet = {
6
6
  billingTransaction: IBillingTransactionApiEntity;
7
7
  billing: IBillingApiEntity;
8
8
  };
9
- export type IBillingTransactionFlowConfig = {
10
- [key in BillingTransactionStatusEnum]?: {
11
- actions: {
12
- [key in BillingTransactionActionEnum]?: {
13
- permissions: string[];
14
- next: () => BillingTransactionStatusEnum;
15
- };
16
- };
17
- };
18
- };
@@ -1,13 +1,3 @@
1
- import { BillingTransactionActionEnum, IBillingTransactionEntity, IEntityUpdateDto } from "../../entities";
2
- export interface IBillingTransactionSupportingDocsDetails {
3
- supportingDocsDetails?: string[];
4
- }
5
- export interface IBillingTransactionActionDataDto {
6
- action: BillingTransactionActionEnum;
7
- }
8
- export interface IBillingTransactionUpdateDto extends IEntityUpdateDto<IBillingTransactionEntity>, IBillingTransactionSupportingDocsDetails {
9
- actionData?: IBillingTransactionActionDataDto;
10
- }
11
- export interface IBillingTransactionUpdateDtoValidationResult {
12
- billingTransactionEntity: IBillingTransactionEntity;
1
+ import { IBillingTransactionEntity, IEntityUpdateDto } from "../../entities";
2
+ export interface IBillingTransactionUpdateDto extends IEntityUpdateDto<IBillingTransactionEntity> {
13
3
  }
@@ -14,15 +14,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.ConvertToCommonEntity = ConvertToCommonEntity;
15
15
  exports.ConvertApiToEntity = ConvertApiToEntity;
16
16
  function ConvertToCommonEntity(obj) {
17
+ var _a, _b;
17
18
  const { createdOn: _, updatedOn: __ } = obj, objectToAssign = __rest(obj, ["createdOn", "updatedOn"]);
18
- const dateTransformerObj = {};
19
- if (obj.createdOn) {
20
- dateTransformerObj["createdOn"] = obj.createdOn.toISOString();
21
- }
22
- if (obj.updatedOn) {
23
- dateTransformerObj["updatedOn"] = obj.updatedOn.toISOString();
24
- }
25
- return Object.assign(Object.assign({}, dateTransformerObj), objectToAssign);
19
+ return Object.assign({ createdOn: (_a = obj.createdOn) === null || _a === void 0 ? void 0 : _a.toISOString(), updatedOn: (_b = obj.updatedOn) === null || _b === void 0 ? void 0 : _b.toISOString() }, objectToAssign);
26
20
  }
27
21
  function ConvertApiToEntity(obj) {
28
22
  const { createdOn: _, updatedOn: __ } = obj, objectToAssign = __rest(obj, ["createdOn", "updatedOn"]);
@@ -66,7 +66,6 @@ export * from "./interface/intermediary_bank.entity.interface";
66
66
  export * from "./interface/holiday-list.entity.interface";
67
67
  export * from "./interface/holiday.entity.interface";
68
68
  export * from "./model/leave.entity.model";
69
- export * from "./model/leave_count.entity.model";
70
69
  export * from "./model/holiday.entity.model";
71
70
  export * from "./enums/cron-jobs-name.enum";
72
71
  export * from "./enums/cron-jobs-status.enum";
@@ -98,7 +97,3 @@ export * from "./model/timesheet.entity.model";
98
97
  export * from "./model/user.entity.model";
99
98
  export * from "./model/client-affiliate.entity.model";
100
99
  export * from "./model/billing-timesheet.entity.model";
101
- export * from "./enums/billing-transaction-action.enum";
102
- export * from "./enums/billing-transaction-status.enum";
103
- export * from "./interface/billing-transaction-history.entity";
104
- export * from "./model/billing-transaction.model";
@@ -83,7 +83,6 @@ __exportStar(require("./interface/intermediary_bank.entity.interface"), exports)
83
83
  __exportStar(require("./interface/holiday-list.entity.interface"), exports);
84
84
  __exportStar(require("./interface/holiday.entity.interface"), exports);
85
85
  __exportStar(require("./model/leave.entity.model"), exports);
86
- __exportStar(require("./model/leave_count.entity.model"), exports);
87
86
  __exportStar(require("./model/holiday.entity.model"), exports);
88
87
  __exportStar(require("./enums/cron-jobs-name.enum"), exports);
89
88
  __exportStar(require("./enums/cron-jobs-status.enum"), exports);
@@ -115,7 +114,3 @@ __exportStar(require("./model/timesheet.entity.model"), exports);
115
114
  __exportStar(require("./model/user.entity.model"), exports);
116
115
  __exportStar(require("./model/client-affiliate.entity.model"), exports);
117
116
  __exportStar(require("./model/billing-timesheet.entity.model"), exports);
118
- __exportStar(require("./enums/billing-transaction-action.enum"), exports);
119
- __exportStar(require("./enums/billing-transaction-status.enum"), exports);
120
- __exportStar(require("./interface/billing-transaction-history.entity"), exports);
121
- __exportStar(require("./model/billing-transaction.model"), exports);
@@ -11,7 +11,6 @@ export interface IBillingEntity extends IAuditColumnEntity {
11
11
  endDate: string;
12
12
  projectId: number;
13
13
  totalAmount: number;
14
- inrAmount?: number;
15
14
  totalMinutes: number;
16
15
  invoiceNumber: string;
17
16
  paymentStatus: PaymentStatusEnum;
@@ -13,7 +13,7 @@ export interface IBillingTimesheetEntity extends IAuditColumnEntity {
13
13
  task: string;
14
14
  description?: string;
15
15
  totalDuration: number;
16
- totalAmount?: number;
16
+ totalAmount: number;
17
17
  impact: BillingImpactEnum;
18
18
  amendmentPurpose?: string;
19
19
  changedStatus: BillingTimesheetStatusEnum;
@@ -23,7 +23,7 @@ export interface IBillingTimesheetEntityCreateDto extends IEntityCreateDto<IBill
23
23
  export interface IBillingTimesheetDetail extends IAuditColumnEntity {
24
24
  timesheetId: number;
25
25
  billingId: number;
26
- totalAmount?: number;
26
+ totalAmount: number;
27
27
  changedStatus: BillingTimesheetStatusEnum;
28
28
  impact: BillingImpactEnum;
29
29
  amendmentPurpose?: string;
@@ -1,4 +1,3 @@
1
- import { BillingTransactionStatusEnum } from "../enums/billing-transaction-status.enum";
2
1
  import { BillingTransactionType } from "../enums/billing.transaction.enum";
3
2
  import { IAuditColumnEntity } from "./audit-column.entity.interface";
4
3
  import { IEntityFilterData } from "./entity.utils.interface";
@@ -8,11 +7,5 @@ export interface IBillingTransactionEntity extends IAuditColumnEntity {
8
7
  type: BillingTransactionType;
9
8
  amount: number;
10
9
  details: string;
11
- bankCharges?: number;
12
- bankId?: number;
13
- paymentDate?: string;
14
- referenceNo?: string;
15
- supportingDocsUrls?: string;
16
- status: BillingTransactionStatusEnum;
17
10
  }
18
11
  export type IBillingTransactionEntityFilterData = IEntityFilterData<IBillingTransactionEntity>;
@@ -6,14 +6,10 @@ import { HistoryOperationEnum } from "../enums/history_operation.enum";
6
6
  import { BankEntityModel } from "../model/bank.entity.model";
7
7
  import { BillingReimbursementExpneseEntityModel } from "../model/billing-reimbursement-expense.entity.model";
8
8
  import { BillingTimesheetEntityModel } from "../model/billing-timesheet.entity.model";
9
- import { BillingTransactionEntityModel } from "../model/billing-transaction.model";
10
9
  import { BillingEntityModel } from "../model/billing.entity.model";
11
10
  import { ClientAffiliateEntityModel } from "../model/client-affiliate.entity.model";
12
11
  import { ClientEntityModel } from "../model/client.entity.model";
13
12
  import { ConfigurationEntityModel } from "../model/configuration.model";
14
- import { HolidayEntityModel } from "../model/holiday.entity.model";
15
- import { LeaveEntityModel } from "../model/leave.entity.model";
16
- import { LeaveCountVirtualEntityModel } from "../model/leave_count.entity.model";
17
13
  import { ProjectUserMappingEntityModel } from "../model/project-user-mapping.entity.model";
18
14
  import { ProjectEntityModel } from "../model/project.entity.model";
19
15
  import { ReimbursementExpenseEntityModel } from "../model/reimbursement-expense.entity.model";
@@ -25,7 +21,6 @@ import { IAuditColumnEntity } from "./audit-column.entity.interface";
25
21
  import { IBankEntity } from "./bank.entity.interface";
26
22
  import { IBankHistoryEntity } from "./bank_history.entity.interface";
27
23
  import { IBillingReimbursementExpenseEntity } from "./billing-reimbursement-expense.entity.interface";
28
- import { IBillingTransactionHistoryEntity } from "./billing-transaction-history.entity";
29
24
  import { IBillingEntity } from "./billing.entity.interface";
30
25
  import { IBillingPaymentEntity } from "./billing_payment.entity.interface";
31
26
  import { IBillingTimesheetEntity } from "./billing_timesheet.entity.interface";
@@ -126,7 +121,6 @@ export declare enum EntityEnum {
126
121
  BANK_HISTORY = "bank_history",
127
122
  BILLING_PAYMENT = "billing_payment",
128
123
  BILLING_TRANSACTION = "billing_transaction",
129
- BILLING_TRANSACTION_HISTORY = "billing_transaction_history",
130
124
  CONFIGURATION = "configuration",
131
125
  COUNTRY = "country",
132
126
  EXPENSE_TYPE = "expense_type",
@@ -164,7 +158,7 @@ export type IBaseEntityApiResponse<T extends {
164
158
  [K in EntityEnum | VirtualEntityEnum]?: IBaseEntityApiResponse<EnumEntityType<K>>;
165
159
  };
166
160
  };
167
- export type EnumEntityType<T extends EntityEnum | VirtualEntityEnum> = (T extends EntityEnum.BILLING ? IBillingEntity : T extends EntityEnum.BILLING_TIMESHEET ? IBillingTimesheetEntity : T extends EntityEnum.BILLING_REIMBURSEMENT_EXPENSE ? IBillingReimbursementExpenseEntity : T extends EntityEnum.TIMESHEET ? ITimesheetEntity : T extends EntityEnum.USER ? IUserEntity : T extends EntityEnum.PROJECT ? IProjectEntity : T extends EntityEnum.CLIENT ? IClientEntity : T extends EntityEnum.LEAVE ? ILeaveEntity : T extends EntityEnum.BANK ? IBankEntity : T extends EntityEnum.BILLING_PAYMENT ? IBillingPaymentEntity : T extends EntityEnum.BILLING_TRANSACTION ? IBillingTransactionEntity : T extends EntityEnum.BILLING_TRANSACTION_HISTORY ? IBillingTransactionHistoryEntity : T extends EntityEnum.CLIENT_AFFILIATE ? IClientAffiliateEntity : T extends EntityEnum.CONFIGURATION ? IConfigurationEntity : T extends EntityEnum.HOLIDAY ? IHolidayEntity : T extends EntityEnum.HOLIDAY_LIST ? IHolidayListEntity : T extends EntityEnum.COUNTRY ? ICountryEntity : T extends EntityEnum.EXPENSE_TYPE ? IExpenseTypeEntity : T extends EntityEnum.INDUSTRY ? IIndustryEntity : T extends EntityEnum.INTERMEDIARY_BANK ? IIntermediaryBankEntity : T extends EntityEnum.OFFICE_LOCATION ? IOfficeLocationEntity : T extends EntityEnum.PERMISSION ? IPermissionEntity : T extends EntityEnum.ROLE ? IRoleEntity : T extends EntityEnum.TASK ? ITaskEntity : T extends EntityEnum.DESIGNATION ? IDesignationEntity : T extends EntityEnum.RATE ? IRateEntity : T extends EntityEnum.REIMBURSEMENT ? IReimbursementEntity : T extends EntityEnum.REIMBURSEMENT_EXPENSE ? IReimbursementExpenseEntity : T extends EntityEnum.WORK_FROM_HOME ? IWorkFromHomeEntity : T extends EntityEnum.ORGANIZATION ? IOrganizationEntity : T extends EntityEnum.PROJECT_USER_MAPPING ? IProjectUserMappingEntity : T extends EntityEnum.CLIENT_USER_MAPPING ? IClientUserMappingEntity : T extends EntityEnum.TO_DO_LIST ? IToDoListEntity : T extends EntityEnum.CRON_JOBS ? ICronJobsEntity : T extends EntityEnum.ROLE_PERMISSION_MAPPING ? IRolePermissionMappingEntity : T extends VirtualEntityEnum.USER_LEAVE ? IUserLeaveVirtualEntity : T extends VirtualEntityEnum.LEAVE_COUNT ? ILeaveCountVirtualEntity : T extends EntityEnum.BANK_HISTORY ? IBankHistoryEntity : T extends EntityEnum.LEAVE_HISTORY ? ILeaveHistoryEntity : T extends EntityEnum.WORK_FROM_HOME_HISTORY ? IWorkFromHomeHistoryEntity : T extends EntityEnum.TIMESHEET_HISTORY ? ITimesheetHistoryEntity : never) & {
161
+ export type EnumEntityType<T extends EntityEnum | VirtualEntityEnum> = (T extends EntityEnum.BILLING ? IBillingEntity : T extends EntityEnum.BILLING_TIMESHEET ? IBillingTimesheetEntity : T extends EntityEnum.BILLING_REIMBURSEMENT_EXPENSE ? IBillingReimbursementExpenseEntity : T extends EntityEnum.TIMESHEET ? ITimesheetEntity : T extends EntityEnum.USER ? IUserEntity : T extends EntityEnum.PROJECT ? IProjectEntity : T extends EntityEnum.CLIENT ? IClientEntity : T extends EntityEnum.LEAVE ? ILeaveEntity : T extends EntityEnum.BANK ? IBankEntity : T extends EntityEnum.BILLING_PAYMENT ? IBillingPaymentEntity : T extends EntityEnum.BILLING_TRANSACTION ? IBillingTransactionEntity : T extends EntityEnum.CLIENT_AFFILIATE ? IClientAffiliateEntity : T extends EntityEnum.CONFIGURATION ? IConfigurationEntity : T extends EntityEnum.HOLIDAY ? IHolidayEntity : T extends EntityEnum.HOLIDAY_LIST ? IHolidayListEntity : T extends EntityEnum.COUNTRY ? ICountryEntity : T extends EntityEnum.EXPENSE_TYPE ? IExpenseTypeEntity : T extends EntityEnum.INDUSTRY ? IIndustryEntity : T extends EntityEnum.INTERMEDIARY_BANK ? IIntermediaryBankEntity : T extends EntityEnum.OFFICE_LOCATION ? IOfficeLocationEntity : T extends EntityEnum.PERMISSION ? IPermissionEntity : T extends EntityEnum.ROLE ? IRoleEntity : T extends EntityEnum.TASK ? ITaskEntity : T extends EntityEnum.DESIGNATION ? IDesignationEntity : T extends EntityEnum.RATE ? IRateEntity : T extends EntityEnum.REIMBURSEMENT ? IReimbursementEntity : T extends EntityEnum.REIMBURSEMENT_EXPENSE ? IReimbursementExpenseEntity : T extends EntityEnum.WORK_FROM_HOME ? IWorkFromHomeEntity : T extends EntityEnum.ORGANIZATION ? IOrganizationEntity : T extends EntityEnum.PROJECT_USER_MAPPING ? IProjectUserMappingEntity : T extends EntityEnum.CLIENT_USER_MAPPING ? IClientUserMappingEntity : T extends EntityEnum.TO_DO_LIST ? IToDoListEntity : T extends EntityEnum.CRON_JOBS ? ICronJobsEntity : T extends EntityEnum.ROLE_PERMISSION_MAPPING ? IRolePermissionMappingEntity : T extends VirtualEntityEnum.USER_LEAVE ? IUserLeaveVirtualEntity : T extends VirtualEntityEnum.LEAVE_COUNT ? ILeaveCountVirtualEntity : T extends EntityEnum.BANK_HISTORY ? IBankHistoryEntity : T extends EntityEnum.LEAVE_HISTORY ? ILeaveHistoryEntity : T extends EntityEnum.WORK_FROM_HOME_HISTORY ? IWorkFromHomeHistoryEntity : T extends EntityEnum.TIMESHEET_HISTORY ? ITimesheetHistoryEntity : never) & {
168
162
  id: number;
169
163
  };
170
164
  export type EntityRelationConfig<T extends EntityEnum | VirtualEntityEnum> = {
@@ -287,15 +281,12 @@ export declare enum VirtualEntityEnum {
287
281
  }
288
282
  export type IHistoryConstraintSearchResponse<T> = IBaseResponse<IHistoryEntitySearchByConstraintResponse<T>[]>;
289
283
  export type IHistoryConstraintSearchServiceResponse<T> = IHistoryEntitySearchByConstraintResponse<T>[];
290
- 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.BILLING_TRANSACTION ? BillingTransactionEntityModel : UserEntityModel;
284
+ 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.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 : UserEntityModel;
291
285
  export type EntityMap = {
292
- [key in EntityEnum | VirtualEntityEnum]: EnumToModel<key>[];
286
+ [key in EntityEnum]: EnumToModel<key>[];
293
287
  };
294
288
  export type EntityIndexMap = {
295
- [key in EntityEnum | VirtualEntityEnum]: {
289
+ [key in EntityEnum]: {
296
290
  [id: number]: EnumToModel<key>;
297
291
  };
298
292
  };
299
- export type IPremissionFilterConfig<T extends EntityEnum | VirtualEntityEnum> = {
300
- [key: string]: () => Promise<IEntityFilterData<EnumEntityType<T>>>;
301
- };
@@ -60,7 +60,6 @@ var EntityEnum;
60
60
  EntityEnum["BANK_HISTORY"] = "bank_history";
61
61
  EntityEnum["BILLING_PAYMENT"] = "billing_payment";
62
62
  EntityEnum["BILLING_TRANSACTION"] = "billing_transaction";
63
- EntityEnum["BILLING_TRANSACTION_HISTORY"] = "billing_transaction_history";
64
63
  EntityEnum["CONFIGURATION"] = "configuration";
65
64
  EntityEnum["COUNTRY"] = "country";
66
65
  EntityEnum["EXPENSE_TYPE"] = "expense_type";
@@ -1,14 +1,8 @@
1
- import { EntityEnum, EntityIndexMap, VirtualEntityEnum } from "../interface/entity.utils.interface";
2
- export declare enum RelationType {
3
- ONE = "one",
4
- MANY = "many"
5
- }
6
- export declare abstract class BaseEntityModel<T extends EntityEnum | VirtualEntityEnum> {
1
+ import { EntityEnum, EntityIndexMap } from "../interface/entity.utils.interface";
2
+ export declare abstract class BaseEntityModel<T extends EntityEnum> {
7
3
  protected entityName: T;
8
4
  constructor(entityName: T);
9
5
  abstract getRelationConfigs(): any[];
10
6
  populateRelationsByIndex(entityIndexMap: EntityIndexMap): void;
11
7
  static populateRelationsForEntities(entityIndexMap: EntityIndexMap, entityType: EntityEnum): void;
12
- populateRelations(entityIndexMap: EntityIndexMap): void;
13
- overwrite(entityIndexMap: EntityIndexMap, indexKey?: string): this;
14
8
  }
@@ -1,56 +1,58 @@
1
1
  "use strict";
2
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 = {}));
3
+ exports.BaseEntityModel = void 0;
4
+ const relation_type_enum_1 = require("../enums/relation-type.enum");
9
5
  class BaseEntityModel {
10
6
  constructor(entityName) {
11
7
  this.entityName = entityName;
12
8
  }
13
9
  populateRelationsByIndex(entityIndexMap) {
14
10
  for (const relationConfig of this.getRelationConfigs() || []) {
15
- const thisMappingKey = relationConfig.mapKeyConfig.key;
16
- const relatedMappingKey = relationConfig.mapKeyConfig.relationKey;
17
- const thisKey = relationConfig.key;
18
- // console.log('Populating relation for', relationConfig.name, 'on', this.entityName, relationConfig);
19
- // debugger;
20
- if (relationConfig.relation === RelationType.ONE) {
11
+ if (relationConfig.relation === relation_type_enum_1.RelationType.ONE) {
12
+ // @ts-ignore
21
13
  const relatedEntities = entityIndexMap[relationConfig.name] || {};
14
+ // @ts-ignore
22
15
  let foundRelatedEntities = [];
23
- if (thisMappingKey.includes(".")) {
24
- const [parentKey, childKey] = thisMappingKey.split(".");
25
- foundRelatedEntities = [relatedEntities[this[parentKey][childKey]]];
16
+ if (relationConfig.mapKeyConfig.key.includes(".")) {
17
+ const [parentKey, childKey] = relationConfig.mapKeyConfig.key.split(".");
18
+ // @ts-ignore
19
+ if (this[parentKey] && this[parentKey][childKey]) {
20
+ // @ts-ignore
21
+ foundRelatedEntities = [relatedEntities[this[parentKey][childKey]]];
22
+ }
26
23
  }
27
24
  else {
28
- // foundRelatedEntities = relatedEntities[this[thisKey]] ? [relatedEntities[this[thisKey]]] : [];
29
- const relatedEntity = relatedEntities[this[thisMappingKey]];
30
- if (relatedEntity) {
31
- foundRelatedEntities = [relatedEntity];
32
- }
33
- else if (relatedMappingKey !== "id") {
34
- foundRelatedEntities = Object.values(relatedEntities).filter((entity) => entity[relatedMappingKey] === this[thisMappingKey]);
35
- }
36
- else {
37
- foundRelatedEntities = [];
38
- }
25
+ foundRelatedEntities = relatedEntities[
26
+ // @ts-ignore
27
+ this[relationConfig.mapKeyConfig.key]]
28
+ ? // @ts-ignore
29
+ [relatedEntities[this[relationConfig.mapKeyConfig.key]]]
30
+ : [];
39
31
  }
40
32
  if (foundRelatedEntities.length > 1) {
41
33
  throw new Error(`Expected one related entity for ${relationConfig.name} but found ${foundRelatedEntities.length}`);
42
34
  }
43
35
  if (foundRelatedEntities.length === 0) {
44
- console.warn(`No related entity found for ${relationConfig.name} with ${thisMappingKey}=${this[relationConfig.mapKeyConfig.foreignKey]}`);
36
+ console.warn(`No related entity found for ${relationConfig.name} with ${relationConfig.mapKeyConfig.key
37
+ // @ts-ignore
38
+ }=${this[relationConfig.mapKeyConfig.foreignKey]}`);
45
39
  }
46
- this[thisKey] = foundRelatedEntities[0];
40
+ // @ts-ignore
41
+ this[relationConfig.key] = foundRelatedEntities[0];
47
42
  }
48
- else if (relationConfig.relation === RelationType.MANY) {
49
- this[thisKey] = [];
43
+ else if (relationConfig.relation === relation_type_enum_1.RelationType.MANY) {
44
+ // @ts-ignore
45
+ this[relationConfig.key] = [];
46
+ // @ts-ignore
50
47
  const relatedEntities = entityIndexMap[relationConfig.name] || {};
51
48
  for (const relatedEntity of Object.values(relatedEntities)) {
52
- if (relatedEntity[relatedMappingKey] === this[thisMappingKey]) {
53
- this[thisKey].push(relatedEntity);
49
+ if (
50
+ // @ts-ignore
51
+ relatedEntity[relationConfig.mapKeyConfig.relationKey] ===
52
+ // @ts-ignore
53
+ this[relationConfig.mapKeyConfig.key]) {
54
+ // @ts-ignore
55
+ this[relationConfig.key].push(relatedEntity);
54
56
  }
55
57
  }
56
58
  }
@@ -58,20 +60,10 @@ class BaseEntityModel {
58
60
  }
59
61
  static populateRelationsForEntities(entityIndexMap, entityType) {
60
62
  for (const key of Object.keys(entityIndexMap[entityType] || {})) {
63
+ // @ts-ignore
61
64
  const entity = entityIndexMap[entityType][key];
62
65
  entity.populateRelationsByIndex(entityIndexMap);
63
66
  }
64
67
  }
65
- populateRelations(entityIndexMap) {
66
- this.populateRelationsByIndex(entityIndexMap);
67
- }
68
- overwrite(entityIndexMap, indexKey = "id") {
69
- if (this[indexKey] === undefined) {
70
- console.warn(`Entity of type ${this.entityName} does not have ${indexKey}, cannot merge`);
71
- return this;
72
- }
73
- entityIndexMap[this.entityName][this[indexKey]] = this;
74
- return this;
75
- }
76
68
  }
77
69
  exports.BaseEntityModel = BaseEntityModel;
@@ -11,7 +11,6 @@ import { BankEntityModel } from "./bank.entity.model";
11
11
  import { BaseEntityModel } from "./base.entity.model";
12
12
  import { BillingReimbursementExpneseEntityModel } from "./billing-reimbursement-expense.entity.model";
13
13
  import { BillingTimesheetEntityModel } from "./billing-timesheet.entity.model";
14
- import { BillingTransactionEntityModel } from "./billing-transaction.model";
15
14
  import { ClientEntityModel } from "./client.entity.model";
16
15
  import { ProjectEntityModel } from "./project.entity.model";
17
16
  import { ReimbursementExpenseEntityModel } from "./reimbursement-expense.entity.model";
@@ -60,7 +59,6 @@ export declare class BillingEntityModel extends BaseEntityModel<EntityEnum.BILLI
60
59
  reimbursementExpense?: ReimbursementExpenseEntityModel[];
61
60
  bank?: BankEntityModel[];
62
61
  billingTimesheets?: BillingTimesheetEntityModel[];
63
- billingTransactions?: BillingTransactionEntityModel[];
64
62
  static relationConfigs: RelationConfigs<[
65
63
  EntityEnum.PROJECT,
66
64
  EntityEnum.CLIENT,
@@ -68,8 +66,7 @@ export declare class BillingEntityModel extends BaseEntityModel<EntityEnum.BILLI
68
66
  EntityEnum.REIMBURSEMENT_EXPENSE,
69
67
  EntityEnum.BILLING_REIMBURSEMENT_EXPENSE,
70
68
  EntityEnum.BILLING_TIMESHEET,
71
- EntityEnum.BANK,
72
- EntityEnum.BILLING_TRANSACTION
69
+ EntityEnum.BANK
73
70
  ], EnumEntityType<EntityEnum.BILLING>>;
74
71
  static fromApiEntity(apiEntity: IBillingApiEntity): BillingEntityModel;
75
72
  getStatusCategory(): BillingStatusCategoryEnumForUI;
@@ -243,13 +243,4 @@ BillingEntityModel.relationConfigs = [
243
243
  key: "bankId",
244
244
  },
245
245
  },
246
- {
247
- name: entity_utils_interface_1.EntityEnum.BILLING_TRANSACTION,
248
- relation: relation_type_enum_1.RelationType.MANY,
249
- key: "billingTransactions",
250
- mapKeyConfig: {
251
- relationKey: "billingId",
252
- key: "id",
253
- },
254
- },
255
246
  ];
@@ -1,18 +1,8 @@
1
- import { EntityEnum, EntityIndexMap, EntityMap, EnumEntityType, EnumToModel, IApiEntity, IBaseEntityApiResponse, VirtualEntityEnum } from "../interface/entity.utils.interface";
1
+ import { EntityEnum, EntityIndexMap, EntityMap, EnumEntityType, IBaseEntityApiResponse } from "../interface/entity.utils.interface";
2
2
  export declare function mapToIndex(entityMap: EntityMap): EntityIndexMap;
3
3
  export declare function getEntityIndexMap<T extends EntityEnum>(data: IBaseEntityApiResponse<EnumEntityType<T>>, baseEntity: T, reusedConfig?: {
4
4
  existingEntityIndexMap: EntityIndexMap;
5
5
  enumEntities: EntityEnum[];
6
6
  }): EntityIndexMap;
7
7
  export declare function populateRelationsFor(entityIndexMap: EntityIndexMap, enumEntities: EntityEnum[]): void;
8
- export declare const entityEnumToEntityModel: {
9
- [E in EntityEnum | VirtualEntityEnum]?: (json: IApiEntity<EnumEntityType<E>>) => EnumToModel<E>;
10
- };
11
- export declare function entityMapToModels(entityMap: EntityMap): void;
12
- export declare function parseEntities<T extends EnumEntityType<EntityEnum | VirtualEntityEnum>>(json: IBaseEntityApiResponse<T>, baseEntity: EntityEnum | VirtualEntityEnum, entityMap: EntityMap): EntityMap;
13
- export declare function entityMapToEntityIndexMap(entityMap: EntityMap, entityRelationsFor: EntityEnum[]): EntityIndexMap;
14
- export declare function parseEntitiesWithoutModels<T extends EnumEntityType<EntityEnum | VirtualEntityEnum>>(json: IBaseEntityApiResponse<T>, baseEntity: EntityEnum | VirtualEntityEnum, entityMap?: {
15
- [E in EntityEnum | VirtualEntityEnum]?: IApiEntity<EnumEntityType<E>>[];
16
- }): {
17
- [E in EntityEnum | VirtualEntityEnum]?: IApiEntity<EnumEntityType<E>>[];
18
- };
8
+ export declare function parseEntities<T extends EnumEntityType<EntityEnum>>(json: IBaseEntityApiResponse<T>, baseEntity: EntityEnum, entityMap: EntityMap): EntityMap;
@@ -1,25 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.entityEnumToEntityModel = void 0;
4
3
  exports.mapToIndex = mapToIndex;
5
4
  exports.getEntityIndexMap = getEntityIndexMap;
6
5
  exports.populateRelationsFor = populateRelationsFor;
7
- exports.entityMapToModels = entityMapToModels;
8
6
  exports.parseEntities = parseEntities;
9
- exports.entityMapToEntityIndexMap = entityMapToEntityIndexMap;
10
- exports.parseEntitiesWithoutModels = parseEntitiesWithoutModels;
11
7
  const entity_utils_interface_1 = require("../interface/entity.utils.interface");
12
8
  const bank_entity_model_1 = require("./bank.entity.model");
13
9
  const base_entity_model_1 = require("./base.entity.model");
14
10
  const billing_reimbursement_expense_entity_model_1 = require("./billing-reimbursement-expense.entity.model");
15
11
  const billing_timesheet_entity_model_1 = require("./billing-timesheet.entity.model");
16
- const billing_transaction_model_1 = require("./billing-transaction.model");
17
12
  const billing_entity_model_1 = require("./billing.entity.model");
18
13
  const client_affiliate_entity_model_1 = require("./client-affiliate.entity.model");
19
14
  const client_entity_model_1 = require("./client.entity.model");
20
- const holiday_entity_model_1 = require("./holiday.entity.model");
21
- const leave_entity_model_1 = require("./leave.entity.model");
22
- const leave_count_entity_model_1 = require("./leave_count.entity.model");
23
15
  const configuration_model_1 = require("./configuration.model");
24
16
  const project_user_mapping_entity_model_1 = require("./project-user-mapping.entity.model");
25
17
  const project_entity_model_1 = require("./project.entity.model");
@@ -55,41 +47,28 @@ function populateRelationsFor(entityIndexMap, enumEntities) {
55
47
  base_entity_model_1.BaseEntityModel.populateRelationsForEntities(entityIndexMap, entity);
56
48
  });
57
49
  }
58
- exports.entityEnumToEntityModel = {
59
- [entity_utils_interface_1.EntityEnum.PROJECT]: project_entity_model_1.ProjectEntityModel.fromApiEntity,
60
- [entity_utils_interface_1.EntityEnum.CLIENT]: client_entity_model_1.ClientEntityModel.fromApiEntity,
61
- [entity_utils_interface_1.EntityEnum.BILLING]: billing_entity_model_1.BillingEntityModel.fromApiEntity,
62
- [entity_utils_interface_1.EntityEnum.USER]: user_entity_model_1.UserEntityModel.fromApiEntity,
63
- [entity_utils_interface_1.EntityEnum.PROJECT_USER_MAPPING]: project_user_mapping_entity_model_1.ProjectUserMappingEntityModel.fromApiEntity,
64
- [entity_utils_interface_1.EntityEnum.REIMBURSEMENT]: reimbursement_entity_model_1.ReimbursementEntityModel.fromApiEntity,
65
- [entity_utils_interface_1.EntityEnum.REIMBURSEMENT_EXPENSE]: reimbursement_expense_entity_model_1.ReimbursementExpenseEntityModel.fromApiEntity,
66
- [entity_utils_interface_1.EntityEnum.BILLING_REIMBURSEMENT_EXPENSE]: billing_reimbursement_expense_entity_model_1.BillingReimbursementExpneseEntityModel.fromApiEntity,
67
- [entity_utils_interface_1.EntityEnum.HOLIDAY]: holiday_entity_model_1.HolidayEntityModel.fromApiEntity,
68
- [entity_utils_interface_1.EntityEnum.LEAVE]: leave_entity_model_1.LeaveEntityModel.fromApiEntity,
69
- [entity_utils_interface_1.VirtualEntityEnum.LEAVE_COUNT]: leave_count_entity_model_1.LeaveCountVirtualEntityModel.fromApiEntity,
70
- // Add other entities here as needed
71
- [entity_utils_interface_1.EntityEnum.CLIENT_AFFILIATE]: client_affiliate_entity_model_1.ClientAffiliateEntityModel.fromApiEntity,
72
- [entity_utils_interface_1.EntityEnum.BANK]: bank_entity_model_1.BankEntityModel.fromApiEntity,
73
- [entity_utils_interface_1.EntityEnum.CONFIGURATION]: configuration_model_1.ConfigurationEntityModel.fromApiEntity,
74
- [entity_utils_interface_1.EntityEnum.TASK]: task_entity_model_1.TaskEntityModel.fromApiEntity,
75
- [entity_utils_interface_1.EntityEnum.BILLING_TIMESHEET]: billing_timesheet_entity_model_1.BillingTimesheetEntityModel.fromApiEntity,
76
- [entity_utils_interface_1.EntityEnum.TIMESHEET]: timesheet_entity_model_1.TimesheetEntityModel.fromApiEntity,
77
- [entity_utils_interface_1.EntityEnum.BILLING_TRANSACTION]: billing_transaction_model_1.BillingTransactionEntityModel.fromApiEntity,
78
- };
79
- function entityMapToModels(entityMap) {
80
- for (const entityName in entityMap) {
81
- if (!(entityName in exports.entityEnumToEntityModel)) {
82
- throw new Error(`Unknown entity: ${entityName}`);
83
- }
84
- entityMap[entityName] = entityMap[entityName].map((entity) => exports.entityEnumToEntityModel[entityName](entity));
85
- }
86
- }
87
50
  function parseEntities(json, baseEntity, entityMap) {
88
51
  var _a;
89
- if (!(baseEntity in exports.entityEnumToEntityModel)) {
52
+ const entityFromJsonMappings = {
53
+ [entity_utils_interface_1.EntityEnum.PROJECT]: project_entity_model_1.ProjectEntityModel.fromApiEntity,
54
+ [entity_utils_interface_1.EntityEnum.CLIENT]: client_entity_model_1.ClientEntityModel.fromApiEntity,
55
+ [entity_utils_interface_1.EntityEnum.BILLING]: billing_entity_model_1.BillingEntityModel.fromApiEntity,
56
+ [entity_utils_interface_1.EntityEnum.USER]: user_entity_model_1.UserEntityModel.fromApiEntity,
57
+ [entity_utils_interface_1.EntityEnum.PROJECT_USER_MAPPING]: project_user_mapping_entity_model_1.ProjectUserMappingEntityModel.fromApiEntity,
58
+ [entity_utils_interface_1.EntityEnum.REIMBURSEMENT]: reimbursement_entity_model_1.ReimbursementEntityModel.fromApiEntity,
59
+ [entity_utils_interface_1.EntityEnum.REIMBURSEMENT_EXPENSE]: reimbursement_expense_entity_model_1.ReimbursementExpenseEntityModel.fromApiEntity,
60
+ [entity_utils_interface_1.EntityEnum.BILLING_REIMBURSEMENT_EXPENSE]: billing_reimbursement_expense_entity_model_1.BillingReimbursementExpneseEntityModel.fromApiEntity,
61
+ [entity_utils_interface_1.EntityEnum.CLIENT_AFFILIATE]: client_affiliate_entity_model_1.ClientAffiliateEntityModel.fromApiEntity,
62
+ [entity_utils_interface_1.EntityEnum.BANK]: bank_entity_model_1.BankEntityModel.fromApiEntity,
63
+ [entity_utils_interface_1.EntityEnum.CONFIGURATION]: configuration_model_1.ConfigurationEntityModel.fromApiEntity,
64
+ [entity_utils_interface_1.EntityEnum.TASK]: task_entity_model_1.TaskEntityModel.fromApiEntity,
65
+ [entity_utils_interface_1.EntityEnum.BILLING_TIMESHEET]: billing_timesheet_entity_model_1.BillingTimesheetEntityModel.fromApiEntity,
66
+ [entity_utils_interface_1.EntityEnum.TIMESHEET]: timesheet_entity_model_1.TimesheetEntityModel.fromApiEntity,
67
+ };
68
+ if (!(baseEntity in entityFromJsonMappings)) {
90
69
  throw new Error(`Unknown entity: ${baseEntity}`);
91
70
  }
92
- entityMap[baseEntity] = ((_a = json["baseEntities"]) !== null && _a !== void 0 ? _a : []).map((e) => exports.entityEnumToEntityModel[baseEntity](e));
71
+ entityMap[baseEntity] = ((_a = json["baseEntities"]) !== null && _a !== void 0 ? _a : []).map((e) => entityFromJsonMappings[baseEntity](e));
93
72
  if (json["relatedEntities"]) {
94
73
  const relatedEntities = json["relatedEntities"];
95
74
  for (const entityName in relatedEntities) {
@@ -100,25 +79,3 @@ function parseEntities(json, baseEntity, entityMap) {
100
79
  }
101
80
  return entityMap;
102
81
  }
103
- function entityMapToEntityIndexMap(entityMap, entityRelationsFor) {
104
- entityMapToModels(entityMap);
105
- const entityIndexMap = mapToIndex(entityMap);
106
- populateRelationsFor(entityIndexMap, entityRelationsFor);
107
- return entityIndexMap;
108
- }
109
- function parseEntitiesWithoutModels(json, baseEntity, entityMap = {}) {
110
- var _a;
111
- if (!(baseEntity in exports.entityEnumToEntityModel)) {
112
- throw new Error(`Unknown entity: ${baseEntity}`);
113
- }
114
- entityMap[baseEntity] = ((_a = json["baseEntities"]) !== null && _a !== void 0 ? _a : []);
115
- if (json["relatedEntities"]) {
116
- const relatedEntities = json["relatedEntities"];
117
- for (const entityName in relatedEntities) {
118
- parseEntitiesWithoutModels(
119
- // @ts-ignore
120
- relatedEntities[entityName], entityName, entityMap);
121
- }
122
- }
123
- return entityMap;
124
- }
@@ -1,14 +1 @@
1
- import { IHolidayApiEntity } from "../../api";
2
- import { EntityEnum } from "../interface/entity.utils.interface";
3
- import { BaseEntityModel } from "./base.entity.model";
4
- export declare class HolidayEntityModel extends BaseEntityModel<EntityEnum.HOLIDAY> implements IHolidayApiEntity {
5
- id: number;
6
- holidayListId: number;
7
- dateCode: string;
8
- createdBy: number;
9
- updatedBy: number;
10
- createdOn: string;
11
- updatedOn: string;
12
- getRelationConfigs(): never[];
13
- static fromApiEntity(apiEntity: IHolidayApiEntity): HolidayEntityModel;
14
- }
1
+ export declare const toBeDeleted = "holiday";