law-common 10.19.1-beta.0 → 10.19.1-beta.10

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 (43) hide show
  1. package/dist/src/api/index.d.ts +1 -0
  2. package/dist/src/api/index.js +1 -0
  3. package/dist/src/api/interface/billing-transaction-history.api.d.ts +3 -0
  4. package/dist/src/api/interface/billing-transaction-history.api.js +2 -0
  5. package/dist/src/api/interface/billing.transaction.create.dto.interface.d.ts +7 -2
  6. package/dist/src/api/interface/billing.transaction.entity.response.d.ts +11 -1
  7. package/dist/src/api/interface/billing.transaction.update.dto.interface.d.ts +12 -2
  8. package/dist/src/entities/enums/billing-transaction-action.enum.d.ts +11 -0
  9. package/dist/src/entities/enums/billing-transaction-action.enum.js +15 -0
  10. package/dist/src/entities/enums/billing-transaction-status.enum.d.ts +6 -0
  11. package/dist/src/entities/enums/billing-transaction-status.enum.js +10 -0
  12. package/dist/src/entities/func/convert-to-common-entity.func.js +8 -2
  13. package/dist/src/entities/index.d.ts +5 -0
  14. package/dist/src/entities/index.js +5 -0
  15. package/dist/src/entities/interface/billing-transaction-history.entity.d.ts +7 -0
  16. package/dist/src/entities/interface/billing-transaction-history.entity.js +2 -0
  17. package/dist/src/entities/interface/billing.entity.interface.d.ts +1 -0
  18. package/dist/src/entities/interface/billing_transaction.entity.interface.d.ts +7 -0
  19. package/dist/src/entities/interface/entity.utils.interface.d.ts +13 -4
  20. package/dist/src/entities/interface/entity.utils.interface.js +1 -0
  21. package/dist/src/entities/model/base.entity.model.d.ts +8 -2
  22. package/dist/src/entities/model/base.entity.model.js +43 -35
  23. package/dist/src/entities/model/billing-transaction.model.d.ts +35 -0
  24. package/dist/src/entities/model/billing-transaction.model.js +62 -0
  25. package/dist/src/entities/model/billing.entity.model.d.ts +4 -1
  26. package/dist/src/entities/model/billing.entity.model.js +9 -0
  27. package/dist/src/entities/model/entity.model.interface.d.ts +12 -2
  28. package/dist/src/entities/model/entity.model.interface.js +61 -18
  29. package/dist/src/entities/model/holiday.entity.model.d.ts +14 -1
  30. package/dist/src/entities/model/holiday.entity.model.js +25 -42
  31. package/dist/src/entities/model/leave.entity.model.d.ts +50 -3
  32. package/dist/src/entities/model/leave.entity.model.js +154 -21
  33. package/dist/src/entities/model/leave_count.entity.model.d.ts +19 -0
  34. package/dist/src/entities/model/leave_count.entity.model.js +60 -0
  35. package/dist/src/utils/entity.flow.util.d.ts +32 -0
  36. package/dist/src/utils/entity.flow.util.js +83 -0
  37. package/dist/src/utils/helper.fn.util.d.ts +37 -1
  38. package/dist/src/utils/helper.fn.util.js +53 -0
  39. package/dist/src/utils/index.d.ts +2 -0
  40. package/dist/src/utils/index.js +2 -0
  41. package/dist/src/utils/string.util.d.ts +1 -0
  42. package/dist/src/utils/string.util.js +14 -0
  43. package/package.json +1 -1
@@ -83,3 +83,4 @@ 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,3 +99,4 @@ __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);
@@ -0,0 +1,3 @@
1
+ import { IApiEntity, IBillingTransactionHistoryEntity } from "../../entities";
2
+ export type IBillingTransactionHistoryApiEntity = IApiEntity<IBillingTransactionHistoryEntity>;
3
+ export type IBillingTransactionHistoryApiEntityArray = IBillingTransactionHistoryApiEntity[];
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,8 @@
1
- import { IBillingTransactionEntity, IEntityCreateDto } from "../../entities";
2
- export interface IBillingTransactionCreateDto extends IEntityCreateDto<IBillingTransactionEntity> {
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;
3
8
  }
@@ -1,4 +1,4 @@
1
- import { IApiEntity, IBillingTransactionEntity } from "../../entities";
1
+ import { BillingTransactionActionEnum, BillingTransactionStatusEnum, 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,3 +6,13 @@ 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,3 +1,13 @@
1
- import { IBillingTransactionEntity, IEntityUpdateDto } from "../../entities";
2
- export interface IBillingTransactionUpdateDto extends IEntityUpdateDto<IBillingTransactionEntity> {
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;
3
13
  }
@@ -0,0 +1,11 @@
1
+ export declare enum BillingTransactionActionEnum {
2
+ UPDATE_PAYMENT = "updatePayment",
3
+ WRITE_OFF = "writeOff",
4
+ CREDIT_NOTE = "creditNote",
5
+ TDS = "tds",
6
+ WRITE_OFF_APPROVAL = "writeOffApproval",
7
+ CREDIT_NOTE_APPROVAL = "creditNoteApproval",
8
+ APPROVE = "approve",
9
+ REJECT = "reject",
10
+ EDIT = "edit"
11
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BillingTransactionActionEnum = void 0;
4
+ var BillingTransactionActionEnum;
5
+ (function (BillingTransactionActionEnum) {
6
+ BillingTransactionActionEnum["UPDATE_PAYMENT"] = "updatePayment";
7
+ BillingTransactionActionEnum["WRITE_OFF"] = "writeOff";
8
+ BillingTransactionActionEnum["CREDIT_NOTE"] = "creditNote";
9
+ BillingTransactionActionEnum["TDS"] = "tds";
10
+ BillingTransactionActionEnum["WRITE_OFF_APPROVAL"] = "writeOffApproval";
11
+ BillingTransactionActionEnum["CREDIT_NOTE_APPROVAL"] = "creditNoteApproval";
12
+ BillingTransactionActionEnum["APPROVE"] = "approve";
13
+ BillingTransactionActionEnum["REJECT"] = "reject";
14
+ BillingTransactionActionEnum["EDIT"] = "edit";
15
+ })(BillingTransactionActionEnum || (exports.BillingTransactionActionEnum = BillingTransactionActionEnum = {}));
@@ -0,0 +1,6 @@
1
+ export declare enum BillingTransactionStatusEnum {
2
+ APPROVED = "approved",
3
+ REJECTED = "rejected",
4
+ WRITEOFF_APPROVAL_PENDING = "writeoff_approval_pending",
5
+ CREDITNOTE_APPROVAL_PENDING = "creditnote_approval_pending"
6
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BillingTransactionStatusEnum = void 0;
4
+ var BillingTransactionStatusEnum;
5
+ (function (BillingTransactionStatusEnum) {
6
+ BillingTransactionStatusEnum["APPROVED"] = "approved";
7
+ BillingTransactionStatusEnum["REJECTED"] = "rejected";
8
+ BillingTransactionStatusEnum["WRITEOFF_APPROVAL_PENDING"] = "writeoff_approval_pending";
9
+ BillingTransactionStatusEnum["CREDITNOTE_APPROVAL_PENDING"] = "creditnote_approval_pending";
10
+ })(BillingTransactionStatusEnum || (exports.BillingTransactionStatusEnum = BillingTransactionStatusEnum = {}));
@@ -14,9 +14,15 @@ 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;
18
17
  const { createdOn: _, updatedOn: __ } = obj, objectToAssign = __rest(obj, ["createdOn", "updatedOn"]);
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);
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);
20
26
  }
21
27
  function ConvertApiToEntity(obj) {
22
28
  const { createdOn: _, updatedOn: __ } = obj, objectToAssign = __rest(obj, ["createdOn", "updatedOn"]);
@@ -66,6 +66,7 @@ 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";
69
70
  export * from "./model/holiday.entity.model";
70
71
  export * from "./enums/cron-jobs-name.enum";
71
72
  export * from "./enums/cron-jobs-status.enum";
@@ -97,3 +98,7 @@ export * from "./model/timesheet.entity.model";
97
98
  export * from "./model/user.entity.model";
98
99
  export * from "./model/client-affiliate.entity.model";
99
100
  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,6 +83,7 @@ __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);
86
87
  __exportStar(require("./model/holiday.entity.model"), exports);
87
88
  __exportStar(require("./enums/cron-jobs-name.enum"), exports);
88
89
  __exportStar(require("./enums/cron-jobs-status.enum"), exports);
@@ -114,3 +115,7 @@ __exportStar(require("./model/timesheet.entity.model"), exports);
114
115
  __exportStar(require("./model/user.entity.model"), exports);
115
116
  __exportStar(require("./model/client-affiliate.entity.model"), exports);
116
117
  __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);
@@ -0,0 +1,7 @@
1
+ import { IBaseHistoryEntity, IEntityCreateDto, IEntityFilterData } from "./entity.utils.interface";
2
+ export interface IBillingTransactionHistoryEntity extends IBaseHistoryEntity {
3
+ }
4
+ export interface IBillingTransactionHistoryCreateDto extends IEntityCreateDto<IBillingTransactionHistoryEntity> {
5
+ }
6
+ export interface IBillingTransactionHistorySearchDto extends IEntityFilterData<IBillingTransactionHistoryEntity> {
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -11,6 +11,7 @@ export interface IBillingEntity extends IAuditColumnEntity {
11
11
  endDate: string;
12
12
  projectId: number;
13
13
  totalAmount: number;
14
+ inrAmount?: number;
14
15
  totalMinutes: number;
15
16
  invoiceNumber: string;
16
17
  paymentStatus: PaymentStatusEnum;
@@ -1,3 +1,4 @@
1
+ import { BillingTransactionStatusEnum } from "../enums/billing-transaction-status.enum";
1
2
  import { BillingTransactionType } from "../enums/billing.transaction.enum";
2
3
  import { IAuditColumnEntity } from "./audit-column.entity.interface";
3
4
  import { IEntityFilterData } from "./entity.utils.interface";
@@ -7,5 +8,11 @@ export interface IBillingTransactionEntity extends IAuditColumnEntity {
7
8
  type: BillingTransactionType;
8
9
  amount: number;
9
10
  details: string;
11
+ bankCharges?: number;
12
+ bankId?: number;
13
+ paymentDate?: string;
14
+ referenceNo?: string;
15
+ supportingDocsUrls?: string;
16
+ status: BillingTransactionStatusEnum;
10
17
  }
11
18
  export type IBillingTransactionEntityFilterData = IEntityFilterData<IBillingTransactionEntity>;
@@ -6,10 +6,14 @@ 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";
9
10
  import { BillingEntityModel } from "../model/billing.entity.model";
10
11
  import { ClientAffiliateEntityModel } from "../model/client-affiliate.entity.model";
11
12
  import { ClientEntityModel } from "../model/client.entity.model";
12
13
  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";
13
17
  import { ProjectUserMappingEntityModel } from "../model/project-user-mapping.entity.model";
14
18
  import { ProjectEntityModel } from "../model/project.entity.model";
15
19
  import { ReimbursementExpenseEntityModel } from "../model/reimbursement-expense.entity.model";
@@ -21,6 +25,7 @@ import { IAuditColumnEntity } from "./audit-column.entity.interface";
21
25
  import { IBankEntity } from "./bank.entity.interface";
22
26
  import { IBankHistoryEntity } from "./bank_history.entity.interface";
23
27
  import { IBillingReimbursementExpenseEntity } from "./billing-reimbursement-expense.entity.interface";
28
+ import { IBillingTransactionHistoryEntity } from "./billing-transaction-history.entity";
24
29
  import { IBillingEntity } from "./billing.entity.interface";
25
30
  import { IBillingPaymentEntity } from "./billing_payment.entity.interface";
26
31
  import { IBillingTimesheetEntity } from "./billing_timesheet.entity.interface";
@@ -121,6 +126,7 @@ export declare enum EntityEnum {
121
126
  BANK_HISTORY = "bank_history",
122
127
  BILLING_PAYMENT = "billing_payment",
123
128
  BILLING_TRANSACTION = "billing_transaction",
129
+ BILLING_TRANSACTION_HISTORY = "billing_transaction_history",
124
130
  CONFIGURATION = "configuration",
125
131
  COUNTRY = "country",
126
132
  EXPENSE_TYPE = "expense_type",
@@ -158,7 +164,7 @@ export type IBaseEntityApiResponse<T extends {
158
164
  [K in EntityEnum | VirtualEntityEnum]?: IBaseEntityApiResponse<EnumEntityType<K>>;
159
165
  };
160
166
  };
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) & {
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) & {
162
168
  id: number;
163
169
  };
164
170
  export type EntityRelationConfig<T extends EntityEnum | VirtualEntityEnum> = {
@@ -281,12 +287,15 @@ export declare enum VirtualEntityEnum {
281
287
  }
282
288
  export type IHistoryConstraintSearchResponse<T> = IBaseResponse<IHistoryEntitySearchByConstraintResponse<T>[]>;
283
289
  export type IHistoryConstraintSearchServiceResponse<T> = IHistoryEntitySearchByConstraintResponse<T>[];
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;
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;
285
291
  export type EntityMap = {
286
- [key in EntityEnum]: EnumToModel<key>[];
292
+ [key in EntityEnum | VirtualEntityEnum]: EnumToModel<key>[];
287
293
  };
288
294
  export type EntityIndexMap = {
289
- [key in EntityEnum]: {
295
+ [key in EntityEnum | VirtualEntityEnum]: {
290
296
  [id: number]: EnumToModel<key>;
291
297
  };
292
298
  };
299
+ export type IPremissionFilterConfig<T extends EntityEnum | VirtualEntityEnum> = {
300
+ [key: string]: () => Promise<IEntityFilterData<EnumEntityType<T>>>;
301
+ };
@@ -60,6 +60,7 @@ 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";
63
64
  EntityEnum["CONFIGURATION"] = "configuration";
64
65
  EntityEnum["COUNTRY"] = "country";
65
66
  EntityEnum["EXPENSE_TYPE"] = "expense_type";
@@ -1,8 +1,14 @@
1
- import { EntityEnum, EntityIndexMap } from "../interface/entity.utils.interface";
2
- export declare abstract class BaseEntityModel<T extends EntityEnum> {
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> {
3
7
  protected entityName: T;
4
8
  constructor(entityName: T);
5
9
  abstract getRelationConfigs(): any[];
6
10
  populateRelationsByIndex(entityIndexMap: EntityIndexMap): void;
7
11
  static populateRelationsForEntities(entityIndexMap: EntityIndexMap, entityType: EntityEnum): void;
12
+ populateRelations(entityIndexMap: EntityIndexMap): void;
13
+ overwrite(entityIndexMap: EntityIndexMap, indexKey?: string): this;
8
14
  }
@@ -1,58 +1,56 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseEntityModel = void 0;
4
- const relation_type_enum_1 = require("../enums/relation-type.enum");
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 = {}));
5
9
  class BaseEntityModel {
6
10
  constructor(entityName) {
7
11
  this.entityName = entityName;
8
12
  }
9
13
  populateRelationsByIndex(entityIndexMap) {
10
14
  for (const relationConfig of this.getRelationConfigs() || []) {
11
- if (relationConfig.relation === relation_type_enum_1.RelationType.ONE) {
12
- // @ts-ignore
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) {
13
21
  const relatedEntities = entityIndexMap[relationConfig.name] || {};
14
- // @ts-ignore
15
22
  let foundRelatedEntities = [];
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
- }
23
+ if (thisMappingKey.includes(".")) {
24
+ const [parentKey, childKey] = thisMappingKey.split(".");
25
+ foundRelatedEntities = [relatedEntities[this[parentKey][childKey]]];
23
26
  }
24
27
  else {
25
- foundRelatedEntities = relatedEntities[
26
- // @ts-ignore
27
- this[relationConfig.mapKeyConfig.key]]
28
- ? // @ts-ignore
29
- [relatedEntities[this[relationConfig.mapKeyConfig.key]]]
30
- : [];
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
+ }
31
39
  }
32
40
  if (foundRelatedEntities.length > 1) {
33
41
  throw new Error(`Expected one related entity for ${relationConfig.name} but found ${foundRelatedEntities.length}`);
34
42
  }
35
43
  if (foundRelatedEntities.length === 0) {
36
- console.warn(`No related entity found for ${relationConfig.name} with ${relationConfig.mapKeyConfig.key
37
- // @ts-ignore
38
- }=${this[relationConfig.mapKeyConfig.foreignKey]}`);
44
+ console.warn(`No related entity found for ${relationConfig.name} with ${thisMappingKey}=${this[relationConfig.mapKeyConfig.foreignKey]}`);
39
45
  }
40
- // @ts-ignore
41
- this[relationConfig.key] = foundRelatedEntities[0];
46
+ this[thisKey] = foundRelatedEntities[0];
42
47
  }
43
- else if (relationConfig.relation === relation_type_enum_1.RelationType.MANY) {
44
- // @ts-ignore
45
- this[relationConfig.key] = [];
46
- // @ts-ignore
48
+ else if (relationConfig.relation === RelationType.MANY) {
49
+ this[thisKey] = [];
47
50
  const relatedEntities = entityIndexMap[relationConfig.name] || {};
48
51
  for (const relatedEntity of Object.values(relatedEntities)) {
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);
52
+ if (relatedEntity[relatedMappingKey] === this[thisMappingKey]) {
53
+ this[thisKey].push(relatedEntity);
56
54
  }
57
55
  }
58
56
  }
@@ -60,10 +58,20 @@ class BaseEntityModel {
60
58
  }
61
59
  static populateRelationsForEntities(entityIndexMap, entityType) {
62
60
  for (const key of Object.keys(entityIndexMap[entityType] || {})) {
63
- // @ts-ignore
64
61
  const entity = entityIndexMap[entityType][key];
65
62
  entity.populateRelationsByIndex(entityIndexMap);
66
63
  }
67
64
  }
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
+ }
68
76
  }
69
77
  exports.BaseEntityModel = BaseEntityModel;
@@ -0,0 +1,35 @@
1
+ import { IBillingTransactionApiEntity } from "../../api";
2
+ import { BillingTransactionStatusEnum } from "../enums/billing-transaction-status.enum";
3
+ import { BillingTransactionType } from "../enums/billing.transaction.enum";
4
+ import { EntityEnum, EnumEntityType } from "../interface/entity.utils.interface";
5
+ import { RelationConfigs } from "../interface/relation-config.interface";
6
+ import { BankEntityModel } from "./bank.entity.model";
7
+ import { BaseEntityModel } from "./base.entity.model";
8
+ import { UserEntityModel } from "./user.entity.model";
9
+ export declare class BillingTransactionEntityModel extends BaseEntityModel<EntityEnum.BILLING_TRANSACTION> implements IBillingTransactionApiEntity {
10
+ id: number;
11
+ billingId: number;
12
+ type: BillingTransactionType;
13
+ amount: number;
14
+ details: string;
15
+ bankCharges?: number;
16
+ bankId?: number;
17
+ paymentDate?: string;
18
+ referenceNo?: string;
19
+ supportingDocsUrls?: string;
20
+ status: BillingTransactionStatusEnum;
21
+ createdOn: string;
22
+ updatedOn: string;
23
+ createdBy: number;
24
+ updatedBy: number;
25
+ createdByUserName?: UserEntityModel;
26
+ updatedByUserName?: UserEntityModel;
27
+ bank?: BankEntityModel;
28
+ getRelationConfigs(): any;
29
+ static relationConfigs: RelationConfigs<[
30
+ EntityEnum.USER,
31
+ EntityEnum.USER,
32
+ EntityEnum.BANK
33
+ ], EnumEntityType<EntityEnum.BILLING_TRANSACTION>>;
34
+ static fromApiEntity(apiEntity: IBillingTransactionApiEntity): BillingTransactionEntityModel;
35
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BillingTransactionEntityModel = void 0;
4
+ const billing_transaction_status_enum_1 = require("../enums/billing-transaction-status.enum");
5
+ const billing_transaction_enum_1 = require("../enums/billing.transaction.enum");
6
+ const entity_utils_interface_1 = require("../interface/entity.utils.interface");
7
+ const base_entity_model_1 = require("./base.entity.model");
8
+ class BillingTransactionEntityModel extends base_entity_model_1.BaseEntityModel {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.id = 0;
12
+ this.billingId = 0;
13
+ this.type = billing_transaction_enum_1.BillingTransactionType.PAYMENT;
14
+ this.amount = 0;
15
+ this.details = "";
16
+ this.status = billing_transaction_status_enum_1.BillingTransactionStatusEnum.APPROVED;
17
+ this.createdOn = "";
18
+ this.updatedOn = "";
19
+ this.createdBy = 0;
20
+ this.updatedBy = 0;
21
+ }
22
+ // billing?: BillingEntityModel;
23
+ // bank?: BankEntityModel;
24
+ getRelationConfigs() {
25
+ return this.constructor.prototype.constructor.relationConfigs;
26
+ }
27
+ static fromApiEntity(apiEntity) {
28
+ const entity = new BillingTransactionEntityModel(entity_utils_interface_1.EntityEnum.BILLING_TRANSACTION);
29
+ Object.assign(entity, apiEntity);
30
+ return entity;
31
+ }
32
+ }
33
+ exports.BillingTransactionEntityModel = BillingTransactionEntityModel;
34
+ BillingTransactionEntityModel.relationConfigs = [
35
+ {
36
+ name: entity_utils_interface_1.EntityEnum.USER,
37
+ relation: base_entity_model_1.RelationType.ONE,
38
+ key: "createdByUserName",
39
+ mapKeyConfig: {
40
+ relationKey: "id",
41
+ key: "createdBy",
42
+ },
43
+ },
44
+ {
45
+ name: entity_utils_interface_1.EntityEnum.USER,
46
+ relation: base_entity_model_1.RelationType.ONE,
47
+ key: "updatedByUserName",
48
+ mapKeyConfig: {
49
+ relationKey: "id",
50
+ key: "updatedBy",
51
+ },
52
+ },
53
+ {
54
+ name: entity_utils_interface_1.EntityEnum.BANK,
55
+ relation: base_entity_model_1.RelationType.ONE,
56
+ key: "bank",
57
+ mapKeyConfig: {
58
+ relationKey: "id",
59
+ key: "bankId",
60
+ },
61
+ },
62
+ ];
@@ -11,6 +11,7 @@ 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";
14
15
  import { ClientEntityModel } from "./client.entity.model";
15
16
  import { ProjectEntityModel } from "./project.entity.model";
16
17
  import { ReimbursementExpenseEntityModel } from "./reimbursement-expense.entity.model";
@@ -59,6 +60,7 @@ export declare class BillingEntityModel extends BaseEntityModel<EntityEnum.BILLI
59
60
  reimbursementExpense?: ReimbursementExpenseEntityModel[];
60
61
  bank?: BankEntityModel[];
61
62
  billingTimesheets?: BillingTimesheetEntityModel[];
63
+ billingTransactions?: BillingTransactionEntityModel[];
62
64
  static relationConfigs: RelationConfigs<[
63
65
  EntityEnum.PROJECT,
64
66
  EntityEnum.CLIENT,
@@ -66,7 +68,8 @@ export declare class BillingEntityModel extends BaseEntityModel<EntityEnum.BILLI
66
68
  EntityEnum.REIMBURSEMENT_EXPENSE,
67
69
  EntityEnum.BILLING_REIMBURSEMENT_EXPENSE,
68
70
  EntityEnum.BILLING_TIMESHEET,
69
- EntityEnum.BANK
71
+ EntityEnum.BANK,
72
+ EntityEnum.BILLING_TRANSACTION
70
73
  ], EnumEntityType<EntityEnum.BILLING>>;
71
74
  static fromApiEntity(apiEntity: IBillingApiEntity): BillingEntityModel;
72
75
  getStatusCategory(): BillingStatusCategoryEnumForUI;
@@ -243,4 +243,13 @@ 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
+ },
246
255
  ];
@@ -1,8 +1,18 @@
1
- import { EntityEnum, EntityIndexMap, EntityMap, EnumEntityType, IBaseEntityApiResponse } from "../interface/entity.utils.interface";
1
+ import { EntityEnum, EntityIndexMap, EntityMap, EnumEntityType, EnumToModel, IApiEntity, IBaseEntityApiResponse, VirtualEntityEnum } 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 function parseEntities<T extends EnumEntityType<EntityEnum>>(json: IBaseEntityApiResponse<T>, baseEntity: EntityEnum, entityMap: EntityMap): EntityMap;
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
+ };