law-common 10.72.1-beta.3 → 10.72.2-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1 +1 @@
1
- # law-common
1
+ # law-common
@@ -1,16 +1,7 @@
1
- import { ILeaveEntity, LeaveActionEnum, LeaveStatusEnum } from "../../entities";
1
+ import { FlowConfig, ILeaveEntity, LeaveActionEnum, LeaveStatusEnum } from "../../entities";
2
2
  import { ILeaveUpdateDto } from "./leave.update.dto.interface";
3
3
  export type ILeaveFlowContextData = {
4
4
  currentTimesheet?: ILeaveEntity;
5
5
  dto?: ILeaveUpdateDto;
6
6
  };
7
- export type ILeaveFlowConfig = {
8
- [key in LeaveStatusEnum]?: {
9
- actions: {
10
- [key in LeaveActionEnum]?: {
11
- permissions: string[];
12
- next: () => LeaveStatusEnum;
13
- };
14
- };
15
- };
16
- };
7
+ export type ILeaveFlowConfig = FlowConfig<LeaveStatusEnum, LeaveActionEnum, never>;
@@ -22,10 +22,19 @@
22
22
  // }
23
23
  // export type IVendorBankDetailCreateExclude = never;
24
24
  // export interface IVendorBankDetailCreateDto extends Omit<IEntityCreateDto<IVendorBankDetailEntity>, IVendorBankDetailCreateExclude> {}
25
- // export type IVendorCreateExclude = "contactDetail" | "bankDetail" | "panDocument" | "gstDocument" | "contractDocument" | "attachmentDocuments";
25
+ // export type IVendorCreateExclude =
26
+ // | "contactDetail"
27
+ // | "bankDetail"
28
+ // | "organizationTypeId"
29
+ // | "status"
30
+ // | "remark"
31
+ // | "panDocument"
32
+ // | "gstDocument"
33
+ // | "contractDocument"
34
+ // | "attachmentDocuments";
26
35
  // export interface IVendorCreateDto extends Omit<IEntityCreateDto<IVendorEntity>, IVendorCreateExclude> {
27
- // contactDetail?: IVendorContactDetailEntity;
28
- // bankDetail?: IVendorBankDetailEntity;
36
+ // contactDetail?: IVendorContactDetailCreateDto[];
37
+ // bankDetail?: IVendorBankDetailCreateDto[];
29
38
  // panDocument?: Nullable<MulterFileWithUrl>;
30
39
  // gstDocument?: Nullable<MulterFileWithUrl>;
31
40
  // contractDocument?: Nullable<MulterFileWithUrl>;
@@ -1,12 +1,6 @@
1
1
  import { VendorActionEnum } from "../../entities/enums/vendor-action.enum";
2
2
  import { VendorStatusEnum } from "../../entities/enums/vendor-status.enum";
3
- export type IVendorFlowConfig = {
4
- [key in VendorStatusEnum]?: {
5
- actions: {
6
- [key in VendorActionEnum]?: {
7
- permissions: string[];
8
- next: () => VendorStatusEnum;
9
- };
10
- };
11
- };
12
- };
3
+ import { FlowConfig } from "../../entities/flow-configs/flow-config.type";
4
+ export interface IVendorFlowConfigContextData {
5
+ }
6
+ export type IVendorFlowConfig = FlowConfig<VendorStatusEnum, VendorActionEnum, IVendorFlowConfigContextData>;
@@ -5,9 +5,9 @@
5
5
  * Used as the single source of truth for what actions are valid
6
6
  * at each status, and what permissions are required to execute them.
7
7
  *
8
- * @template S - String enum of all possible statuses
9
- * @template A - String enum of all possible actions
10
- * @template T - Optional context data shape passed to the `next()` resolver.
8
+ * @template STATUS_ENUM_TYPE - String enum of all possible statuses
9
+ * @template ACTION_ENUM_TYPE - String enum of all possible actions
10
+ * @template CONTEXT_DATA_TYPE - Optional context data shape passed to the `next()` resolver.
11
11
  * Defaults to `never` for flows where `next()` needs no runtime data.
12
12
  *
13
13
  * @example
@@ -27,10 +27,10 @@
27
27
  * // Flow with context data (reimbursement parent)
28
28
  * const config: FlowConfig<ReimbursementStatusEnum, ReimbursementActionEnum, IReimbursementFlowContextData> = { ... }
29
29
  */
30
- export type FlowConfig<S extends string, A extends string, T extends Record<any, any> = never> = {
31
- [key in S]?: {
30
+ export type FlowConfig<STATUS_ENUM_TYPE extends string, ACTION_ENUM_TYPE extends string, CONTEXT_DATA_TYPE = never> = {
31
+ [key in STATUS_ENUM_TYPE]?: {
32
32
  actions: {
33
- [key in A]?: IFlowConfigActionConfig<S, T>;
33
+ [key in ACTION_ENUM_TYPE]?: IFlowConfigActionConfig<STATUS_ENUM_TYPE, CONTEXT_DATA_TYPE>;
34
34
  };
35
35
  description?: string;
36
36
  };
@@ -39,8 +39,8 @@ export type FlowConfig<S extends string, A extends string, T extends Record<any,
39
39
  * Configuration for a single action within a {@link FlowConfig}.
40
40
  * Defines who can execute the action and what status it transitions to.
41
41
  *
42
- * @template S - String enum of statuses, used as the return type of `next()`
43
- * @template T - Optional context data passed to `next()` for dynamic status resolution.
42
+ * @template STATUS_ENUM_TYPE - String enum of statuses, used as the return type of `next()`
43
+ * @template CONTEXT_DATA_TYPE - Optional context data passed to `next()` for dynamic status resolution.
44
44
  * Pass `never` for actions where the next status is always static.
45
45
  *
46
46
  * @example
@@ -58,9 +58,9 @@ export type FlowConfig<S extends string, A extends string, T extends Record<any,
58
58
  * next: (data) => areAllRowsApproved(data) ? ReimbursementStatusEnum.APPROVED : ReimbursementStatusEnum.APPROVAL_PENDING,
59
59
  * };
60
60
  */
61
- export interface IFlowConfigActionConfig<S extends string, T> {
61
+ export interface IFlowConfigActionConfig<STATUS_ENUM_TYPE extends string, CONTEXT_DATA_TYPE> {
62
62
  permissions: string[];
63
- next: (data?: T) => S;
63
+ next: (data: CONTEXT_DATA_TYPE) => STATUS_ENUM_TYPE;
64
64
  description?: string;
65
65
  }
66
66
  export type ParentChildFlowConfig<S extends string, A extends string, CS extends string = never, CA extends string = never, T extends Record<any, any> = never> = {
@@ -1,4 +1,4 @@
1
1
  import { LeaveActionEnum } from "../enums/leave.action.enum";
2
2
  import { LeaveStatusEnum } from "../enums/leave.status.enum";
3
3
  import { FlowConfig } from "./flow-config.type";
4
- export declare const leaveFlowConfig: FlowConfig<LeaveStatusEnum, LeaveActionEnum>;
4
+ export declare const leaveFlowConfig: FlowConfig<LeaveStatusEnum, LeaveActionEnum, never>;
@@ -8,19 +8,19 @@ exports.vendorFlowConfig = {
8
8
  actions: {
9
9
  [vendor_action_enum_1.VendorActionEnum.APPROVE]: {
10
10
  permissions: ["VENDOR_APPROVE_ORG"],
11
- next: () => vendor_status_enum_1.VendorStatusEnum.APPROVED,
11
+ next: (vendorFlowConfigContextData) => vendor_status_enum_1.VendorStatusEnum.APPROVED,
12
12
  },
13
13
  [vendor_action_enum_1.VendorActionEnum.EDIT]: {
14
14
  permissions: ["VENDOR_UPDATE"],
15
- next: () => vendor_status_enum_1.VendorStatusEnum.CREATE_APPROVAL,
15
+ next: (vendorFlowConfigContextData) => vendor_status_enum_1.VendorStatusEnum.CREATE_APPROVAL,
16
16
  },
17
17
  [vendor_action_enum_1.VendorActionEnum.REJECT]: {
18
18
  permissions: ["VENDOR_APPROVE_ORG"],
19
- next: () => vendor_status_enum_1.VendorStatusEnum.REJECTED,
19
+ next: (vendorFlowConfigContextData) => vendor_status_enum_1.VendorStatusEnum.REJECTED,
20
20
  },
21
21
  [vendor_action_enum_1.VendorActionEnum.DELETE]: {
22
22
  permissions: ["VENDOR_UPDATE"],
23
- next: () => vendor_status_enum_1.VendorStatusEnum.DELETED,
23
+ next: (vendorFlowConfigContextData) => vendor_status_enum_1.VendorStatusEnum.DELETED,
24
24
  },
25
25
  },
26
26
  },
@@ -28,19 +28,19 @@ exports.vendorFlowConfig = {
28
28
  actions: {
29
29
  [vendor_action_enum_1.VendorActionEnum.APPROVE]: {
30
30
  permissions: ["VENDOR_APPROVE_ORG"],
31
- next: () => vendor_status_enum_1.VendorStatusEnum.APPROVED,
31
+ next: (vendorFlowConfigContextData) => vendor_status_enum_1.VendorStatusEnum.APPROVED,
32
32
  },
33
33
  [vendor_action_enum_1.VendorActionEnum.EDIT]: {
34
34
  permissions: ["VENDOR_UPDATE"],
35
- next: () => vendor_status_enum_1.VendorStatusEnum.EDIT_APPROVAL,
35
+ next: (vendorFlowConfigContextData) => vendor_status_enum_1.VendorStatusEnum.EDIT_APPROVAL,
36
36
  },
37
37
  [vendor_action_enum_1.VendorActionEnum.REJECT]: {
38
38
  permissions: ["VENDOR_APPROVE_ORG"],
39
- next: () => vendor_status_enum_1.VendorStatusEnum.RESOLVED_REJECTED,
39
+ next: (vendorFlowConfigContextData) => vendor_status_enum_1.VendorStatusEnum.RESOLVED_REJECTED,
40
40
  },
41
41
  // [VendorActionEnum.RECALL]: {
42
42
  // permissions: ["VENDOR_UPDATE"],
43
- // next: () => VendorStatusEnum.DELETED,
43
+ // next: (vendorFlowConfigContextData: IVendorFlowConfigContextData) => VendorStatusEnum.DELETED,
44
44
  // },
45
45
  },
46
46
  },
@@ -48,15 +48,15 @@ exports.vendorFlowConfig = {
48
48
  actions: {
49
49
  [vendor_action_enum_1.VendorActionEnum.APPROVE]: {
50
50
  permissions: ["VENDOR_APPROVE_ORG"],
51
- next: () => vendor_status_enum_1.VendorStatusEnum.DELETED,
51
+ next: (vendorFlowConfigContextData) => vendor_status_enum_1.VendorStatusEnum.DELETED,
52
52
  },
53
53
  [vendor_action_enum_1.VendorActionEnum.REJECT]: {
54
54
  permissions: ["VENDOR_APPROVE_ORG"],
55
- next: () => vendor_status_enum_1.VendorStatusEnum.RESOLVED_REJECTED,
55
+ next: (vendorFlowConfigContextData) => vendor_status_enum_1.VendorStatusEnum.RESOLVED_REJECTED,
56
56
  },
57
57
  // [VendorActionEnum.RECALL]: {
58
58
  // permissions: ["VENDOR_UPDATE"],
59
- // next: () => VendorStatusEnum.DELETED,
59
+ // next: (vendorFlowConfigContextData: IVendorFlowConfigContextData) => VendorStatusEnum.DELETED,
60
60
  // },
61
61
  },
62
62
  },
@@ -64,11 +64,11 @@ exports.vendorFlowConfig = {
64
64
  actions: {
65
65
  [vendor_action_enum_1.VendorActionEnum.EDIT]: {
66
66
  permissions: ["VENDOR_UPDATE"],
67
- next: () => vendor_status_enum_1.VendorStatusEnum.EDIT_APPROVAL,
67
+ next: (vendorFlowConfigContextData) => vendor_status_enum_1.VendorStatusEnum.EDIT_APPROVAL,
68
68
  },
69
69
  [vendor_action_enum_1.VendorActionEnum.DELETE]: {
70
70
  permissions: ["VENDOR_UPDATE"],
71
- next: () => vendor_status_enum_1.VendorStatusEnum.DELETE_APPROVAL,
71
+ next: (vendorFlowConfigContextData) => vendor_status_enum_1.VendorStatusEnum.DELETE_APPROVAL,
72
72
  },
73
73
  },
74
74
  },
@@ -76,11 +76,11 @@ exports.vendorFlowConfig = {
76
76
  actions: {
77
77
  [vendor_action_enum_1.VendorActionEnum.EDIT]: {
78
78
  permissions: ["VENDOR_UPDATE"],
79
- next: () => vendor_status_enum_1.VendorStatusEnum.EDIT_APPROVAL,
79
+ next: (vendorFlowConfigContextData) => vendor_status_enum_1.VendorStatusEnum.EDIT_APPROVAL,
80
80
  },
81
81
  [vendor_action_enum_1.VendorActionEnum.DELETE]: {
82
82
  permissions: ["VENDOR_UPDATE"],
83
- next: () => vendor_status_enum_1.VendorStatusEnum.DELETE_APPROVAL,
83
+ next: (vendorFlowConfigContextData) => vendor_status_enum_1.VendorStatusEnum.DELETE_APPROVAL,
84
84
  },
85
85
  },
86
86
  },
@@ -369,8 +369,8 @@ export type IHistoryEntitySearchByConstraintResponse<T> = {
369
369
  export type IHistoryEntityChangedLogs<T> = {
370
370
  key: keyof T;
371
371
  label: string;
372
- newValue: string | number;
373
- oldValue: string | number;
372
+ newValue: T[keyof T];
373
+ oldValue: T[keyof T] | null;
374
374
  timeStamp: number;
375
375
  };
376
376
  export declare enum VirtualEntityEnum {
@@ -22,7 +22,6 @@ export interface IReimbursementEntity extends IEntityAuditColumn {
22
22
  disbursementDate?: string;
23
23
  referenceNo?: string;
24
24
  bankId?: number;
25
- incurredByUserId: number;
26
25
  }
27
26
  export interface IReimbursementExpenseAllocation {
28
27
  id: number;
@@ -233,7 +233,7 @@ class LeaveEntityModel extends base_entity_model_1.BaseEntityModel {
233
233
  message: [`Current user does not have permission to ${dto.actionData.action} leave`],
234
234
  });
235
235
  }
236
- const nextStatus = matchingPermissionConfig.next();
236
+ const nextStatus = matchingPermissionConfig.next({});
237
237
  return nextStatus;
238
238
  }
239
239
  mapStatusLabel(status) {
@@ -24,7 +24,6 @@ export declare class ReimbursementEntityModel extends BaseEntityModel<EntityEnum
24
24
  disbursementDate?: string;
25
25
  referenceNo?: string;
26
26
  bankId?: number;
27
- incurredByUserId: number;
28
27
  createdBy: number;
29
28
  updatedBy: number;
30
29
  createdOn: number;
@@ -17,7 +17,6 @@ class ReimbursementEntityModel extends base_entity_model_1.BaseEntityModel {
17
17
  this.description = "";
18
18
  this.status = reimbursement_entity_enum_1.ReimbursementStatusEnum.APPROVAL_PENDING;
19
19
  this.paymentStatus = reimbursement_entity_enum_1.ReimbursementPaymentStatusEnum.UNPAID;
20
- this.incurredByUserId = 0;
21
20
  this.createdBy = 0;
22
21
  this.updatedBy = 0;
23
22
  this.createdOn = 0;
@@ -1,7 +1,7 @@
1
- import { EntityEnum, IEntityUpdateDto, Nullable } from "../interface/entity.utils.interface";
1
+ import { EntityEnum, Nullable } from "../interface/entity.utils.interface";
2
2
  import { RelationConfigs } from "../interface/relation-config.interface";
3
3
  import { BaseEntityModel } from "./base.entity.model";
4
- import { IVendorActionDataDto } from "../../api";
4
+ import { IVendorFlowConfigContextData } from "../../api";
5
5
  import { VendorActionEnum } from "../enums/vendor-action.enum";
6
6
  import { VendorStatusEnum } from "../enums/vendor-status.enum";
7
7
  import { VendorContractApplicabilityEnum } from "../enums/vendor_contract_applicability_enum";
@@ -62,12 +62,10 @@ export declare class VendorEntityModel extends BaseEntityModel<EntityEnum.VENDOR
62
62
  stateModel?: StateEntityModel;
63
63
  populateOrganizationTypeModel(organizationTypeEntityModels: OrganizationTypeEntityModel[]): null;
64
64
  getPanNoFourthCharacter(): string;
65
- static relationConfigs: RelationConfigs<[EntityEnum.STATE], EntityEnum.VENDOR>;
65
+ static relationConfigs: RelationConfigs<[EntityEnum.STATE, EntityEnum.ORGANIZATION_TYPE], EntityEnum.VENDOR>;
66
66
  static fromEntity(entity: IVendorEntity): VendorEntityModel;
67
67
  getRelationConfigs(): any[];
68
- getNextStatus(currentUser: IUserEntity, dto: IEntityUpdateDto<IVendorEntity> & {
69
- actionData: IVendorActionDataDto;
70
- }): VendorStatusEnum;
68
+ getNextStatus(currentUser: IUserEntity, action: VendorActionEnum, vendorFlowConfigContextData: IVendorFlowConfigContextData): VendorStatusEnum;
71
69
  getAvailableActions(currentUser: UserEntityModel, config?: {
72
70
  combinedActions?: Record<string, {
73
71
  combineActions: VendorActionEnum[];
@@ -57,7 +57,7 @@ class VendorEntityModel extends base_entity_model_1.BaseEntityModel {
57
57
  getRelationConfigs() {
58
58
  return this.constructor.prototype.constructor.relationConfigs || [];
59
59
  }
60
- getNextStatus(currentUser, dto) {
60
+ getNextStatus(currentUser, action, vendorFlowConfigContextData) {
61
61
  if (!this.status) {
62
62
  throw new exceptions_1.AppBadRequestException({
63
63
  key: error_key_enum_1.ErrorKeyEnum.STATUS,
@@ -71,17 +71,17 @@ class VendorEntityModel extends base_entity_model_1.BaseEntityModel {
71
71
  message: [`No flow configuration found for status: ${this.status}`],
72
72
  });
73
73
  }
74
- if (!(dto === null || dto === void 0 ? void 0 : dto.actionData)) {
74
+ if (!action) {
75
75
  throw new exceptions_1.AppBadRequestException({
76
76
  key: error_key_enum_1.ErrorKeyEnum.ACTION_DATA,
77
- message: ["dto.actionData is required"],
77
+ message: ["actionData is required"],
78
78
  });
79
79
  }
80
- const matchingPermissionConfig = flowForStatus.actions[dto.actionData.action];
80
+ const matchingPermissionConfig = flowForStatus.actions[action];
81
81
  if (!matchingPermissionConfig) {
82
82
  throw new exceptions_1.AppBadRequestException({
83
83
  key: error_key_enum_1.ErrorKeyEnum.ACTION,
84
- message: [`Action '${dto.actionData.action}' is not valid for the current status.`],
84
+ message: [`Action '${action}' is not valid for the current status.`],
85
85
  });
86
86
  }
87
87
  if (!currentUser.permissions || currentUser.permissions.length === 0) {
@@ -94,10 +94,10 @@ class VendorEntityModel extends base_entity_model_1.BaseEntityModel {
94
94
  if (!hasPermission) {
95
95
  throw new exceptions_1.AppBadRequestException({
96
96
  key: error_key_enum_1.ErrorKeyEnum.PERMISSION,
97
- message: [`Current user does not have permission to ${dto.actionData.action} vendor`],
97
+ message: [`Current user does not have permission to ${action} vendor`],
98
98
  });
99
99
  }
100
- const nextStatus = matchingPermissionConfig.next();
100
+ const nextStatus = matchingPermissionConfig.next(vendorFlowConfigContextData);
101
101
  return nextStatus;
102
102
  }
103
103
  getAvailableActions(currentUser, config) {
@@ -151,4 +151,13 @@ VendorEntityModel.relationConfigs = [
151
151
  // key: "officeLocationId",
152
152
  // },
153
153
  // },
154
+ {
155
+ name: entity_utils_interface_1.EntityEnum.ORGANIZATION_TYPE,
156
+ relation: relation_type_enum_1.RelationType.ONE,
157
+ key: "organizationType",
158
+ mapKeyConfig: {
159
+ relationKey: "id",
160
+ key: "organizationTypeId",
161
+ },
162
+ },
154
163
  ];
@@ -9,6 +9,11 @@
9
9
  // import { ExpenseHeadEntityModel } from "./expense_head.entity.model";
10
10
  // import { GstRateEntityModel } from "./gst_rate.entity.model";
11
11
  // import { TdsRateEntityModel } from "./tds_rate.entity.model";
12
+ // import { VendorEntityModel } from "./vendor.entity.model";
13
+ // import { StateEntityModel } from "./state.entity.model";
14
+ // import { CountryEntityModel } from "./country.entity.model";
15
+ // import { OrganizationTypeEntityModel } from "./organization_type.entity.model";
16
+ // import { OfficeLocationEntityModel } from "./office_location.entity.model";
12
17
  // export class VendorInvoiceItemEntityModel extends BaseEntityModel<EntityEnum.VENDOR_INVOICE_ITEM> implements IVendorInvoiceItemEntity {
13
18
  // id: number = 0;
14
19
  // vendorInvoiceId: number = 0;
@@ -89,4 +94,39 @@
89
94
  // getRelationConfigs(): any[] {
90
95
  // return this.constructor.prototype.constructor.relationConfigs || [];
91
96
  // }
97
+ // get vendor(): VendorEntityModel | undefined {
98
+ // // many_to_one -> many_to_one verified
99
+ // // {'vendor_invoice_item->vendor_invoice': 'many_to_one', 'vendor_invoice->vendor': 'many_to_one'}
100
+ // // ['vendor_invoice_item', 'vendor_invoice'] -> many_to_one
101
+ // // ['vendor_invoice', 'vendor'] -> many_to_one
102
+ // return this.vendorInvoice?.vendor;
103
+ // }
104
+ // get state(): StateEntityModel | undefined {
105
+ // // many_to_one -> many_to_one verified
106
+ // // {'vendor_invoice_item->vendor_invoice': 'many_to_one', 'vendor_invoice->vendor': 'many_to_one', 'vendor->state': 'many_to_one'}
107
+ // // ['vendor_invoice', 'vendor'] -> many_to_one
108
+ // // ['vendor', 'state'] -> many_to_one
109
+ // return this.vendor?.state;
110
+ // }
111
+ // get country(): CountryEntityModel | undefined {
112
+ // // many_to_one -> many_to_one verified
113
+ // // {'vendor_invoice_item->vendor_invoice': 'many_to_one', 'vendor_invoice->vendor': 'many_to_one', 'vendor->country': 'many_to_one'}
114
+ // // ['vendor_invoice', 'vendor'] -> many_to_one
115
+ // // ['vendor', 'country'] -> many_to_one
116
+ // return this.vendor?.country;
117
+ // }
118
+ // get organizationType(): OrganizationTypeEntityModel | undefined {
119
+ // // many_to_one -> many_to_one verified
120
+ // // {'vendor_invoice_item->vendor_invoice': 'many_to_one', 'vendor_invoice->vendor': 'many_to_one', 'vendor->organization_type': 'many_to_one'}
121
+ // // ['vendor_invoice', 'vendor'] -> many_to_one
122
+ // // ['vendor', 'organization_type'] -> many_to_one
123
+ // return this.vendor?.organizationType;
124
+ // }
125
+ // get officeLocation(): OfficeLocationEntityModel | undefined {
126
+ // // many_to_one -> many_to_one verified
127
+ // // {'vendor_invoice_item->vendor_invoice': 'many_to_one', 'vendor_invoice->office_location': 'many_to_one'}
128
+ // // ['vendor_invoice_item', 'vendor_invoice'] -> many_to_one
129
+ // // ['vendor_invoice', 'office_location'] -> many_to_one
130
+ // return this.vendorInvoice?.officeLocation;
131
+ // }
92
132
  // }
@@ -1,22 +1,20 @@
1
1
  import { EntityEnum, Nullable } from "../interface/entity.utils.interface";
2
- import { RelationConfigs } from "../interface/relation-config.interface";
3
2
  import { BaseEntityModel } from "./base.entity.model";
3
+ import { RelationConfigs } from "../interface/relation-config.interface";
4
4
  import { IVendorInvoiceItemEntity } from "../interface/vendor_invoice_item.entity.interface";
5
- import { IGstRateEntity } from "../interface/gst_rate.entity.interface";
6
- import { ITdsRateEntity } from "../interface/tds_rate.entity.interface";
7
- import { IVendorEntity } from "../interface/vendor.entity.interface";
5
+ import { VendorInvoiceEntityModel } from "./vendor_invoice.entity.model";
6
+ import { VoucherTypeEntityModel } from "./voucher_type.entity.model";
8
7
  import { ExpenseHeadEntityModel } from "./expense_head.entity.model";
9
8
  import { GstRateEntityModel } from "./gst_rate.entity.model";
10
9
  import { TdsRateEntityModel } from "./tds_rate.entity.model";
11
10
  import { VendorEntityModel } from "./vendor.entity.model";
12
- import { VendorInvoiceEntityModel } from "./vendor_invoice.entity.model";
13
- import { VoucherTypeEntityModel } from "./voucher_type.entity.model";
14
- export interface IVendorInvoiceItemEntityAmounts {
15
- gstAmount: number;
16
- tdsAmount: number;
17
- invoiceAmount: number;
18
- netAmount: number;
19
- }
11
+ import { StateEntityModel } from "./state.entity.model";
12
+ import { CountryEntityModel } from "./country.entity.model";
13
+ import { OrganizationTypeEntityModel } from "./organization_type.entity.model";
14
+ import { OfficeLocationEntityModel } from "./office_location.entity.model";
15
+ import { IGstRateEntity } from "../interface/gst_rate.entity.interface";
16
+ import { ITdsRateEntity } from "../interface/tds_rate.entity.interface";
17
+ import { IVendorEntity } from "../interface/vendor.entity.interface";
20
18
  export declare class VendorInvoiceItemEntityModel extends BaseEntityModel<EntityEnum.VENDOR_INVOICE_ITEM> implements IVendorInvoiceItemEntity {
21
19
  id: number;
22
20
  vendorInvoiceId: number;
@@ -30,13 +28,13 @@ export declare class VendorInvoiceItemEntityModel extends BaseEntityModel<Entity
30
28
  netAmount: number;
31
29
  quantity: number;
32
30
  rate: number;
33
- remark: Nullable<string>;
34
- gstAmount: number;
35
- tdsAmount: number;
36
31
  createdOn: number;
37
32
  updatedOn: number;
38
33
  createdBy: number;
39
34
  updatedBy: number;
35
+ remark: Nullable<string>;
36
+ gstAmount: number;
37
+ tdsAmount: number;
40
38
  vendorInvoice?: VendorInvoiceEntityModel;
41
39
  voucherType?: VoucherTypeEntityModel;
42
40
  expenseHead?: ExpenseHeadEntityModel;
@@ -51,6 +49,11 @@ export declare class VendorInvoiceItemEntityModel extends BaseEntityModel<Entity
51
49
  ], EntityEnum.VENDOR_INVOICE_ITEM>;
52
50
  static fromEntity(entity: IVendorInvoiceItemEntity): VendorInvoiceItemEntityModel;
53
51
  getRelationConfigs(): any[];
52
+ get vendor(): VendorEntityModel | undefined;
53
+ get state(): StateEntityModel | undefined;
54
+ get country(): CountryEntityModel | undefined;
55
+ get organizationType(): OrganizationTypeEntityModel | undefined;
56
+ get officeLocation(): OfficeLocationEntityModel | undefined;
54
57
  static calculateAmounts(params: {
55
58
  basicAmount: number;
56
59
  gstRateEntity: IGstRateEntity;
@@ -60,3 +63,9 @@ export declare class VendorInvoiceItemEntityModel extends BaseEntityModel<Entity
60
63
  static tdsRate(vendorEntity: IVendorEntity, tdsRateEntity: ITdsRateEntity): number;
61
64
  static AMOUNT_KEYS: (keyof IVendorInvoiceItemEntityAmounts)[];
62
65
  }
66
+ export interface IVendorInvoiceItemEntityAmounts {
67
+ gstAmount: number;
68
+ tdsAmount: number;
69
+ invoiceAmount: number;
70
+ netAmount: number;
71
+ }
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VendorInvoiceItemEntityModel = void 0;
4
- const relation_type_enum_1 = require("../enums/relation-type.enum");
5
4
  const entity_utils_interface_1 = require("../interface/entity.utils.interface");
6
5
  const base_entity_model_1 = require("./base.entity.model");
6
+ const relation_type_enum_1 = require("../enums/relation-type.enum");
7
7
  const vendor_pan_type_enum_1 = require("../enums/vendor_pan_type_enum");
8
8
  class VendorInvoiceItemEntityModel extends base_entity_model_1.BaseEntityModel {
9
9
  constructor() {
@@ -20,14 +20,13 @@ class VendorInvoiceItemEntityModel extends base_entity_model_1.BaseEntityModel {
20
20
  this.netAmount = 0;
21
21
  this.quantity = 0;
22
22
  this.rate = 0;
23
- // status: VendorInvoiceItemStatus = VendorInvoiceItemStatus.PENDING;
24
- this.remark = null;
25
- this.gstAmount = 0;
26
- this.tdsAmount = 0;
27
23
  this.createdOn = 0;
28
24
  this.updatedOn = 0;
29
25
  this.createdBy = 0;
30
26
  this.updatedBy = 0;
27
+ this.remark = null;
28
+ this.gstAmount = 0;
29
+ this.tdsAmount = 0;
31
30
  // getAvailableActions(
32
31
  // currentUser: UserEntityModel,
33
32
  // config?: {
@@ -65,6 +64,46 @@ class VendorInvoiceItemEntityModel extends base_entity_model_1.BaseEntityModel {
65
64
  getRelationConfigs() {
66
65
  return this.constructor.prototype.constructor.relationConfigs || [];
67
66
  }
67
+ get vendor() {
68
+ // many_to_one -> many_to_one verified
69
+ // {'vendor_invoice_item->vendor_invoice': 'many_to_one', 'vendor_invoice->vendor': 'many_to_one'}
70
+ // ['vendor_invoice_item', 'vendor_invoice'] -> many_to_one
71
+ // ['vendor_invoice', 'vendor'] -> many_to_one
72
+ var _a;
73
+ return (_a = this.vendorInvoice) === null || _a === void 0 ? void 0 : _a.vendor;
74
+ }
75
+ get state() {
76
+ // many_to_one -> many_to_one verified
77
+ // {'vendor_invoice_item->vendor_invoice': 'many_to_one', 'vendor_invoice->vendor': 'many_to_one', 'vendor->state': 'many_to_one'}
78
+ // ['vendor_invoice', 'vendor'] -> many_to_one
79
+ // ['vendor', 'state'] -> many_to_one
80
+ var _a;
81
+ return (_a = this.vendor) === null || _a === void 0 ? void 0 : _a.stateModel;
82
+ }
83
+ get country() {
84
+ // many_to_one -> many_to_one verified
85
+ // {'vendor_invoice_item->vendor_invoice': 'many_to_one', 'vendor_invoice->vendor': 'many_to_one', 'vendor->country': 'many_to_one'}
86
+ // ['vendor_invoice', 'vendor'] -> many_to_one
87
+ // ['vendor', 'country'] -> many_to_one
88
+ throw new Error("Relation 'country' is not defined in VendorEntityModel. Please define the relation to access country from VendorInvoiceItemEntityModel.");
89
+ // return this.vendor?.country;
90
+ }
91
+ get organizationType() {
92
+ // many_to_one -> many_to_one verified
93
+ // {'vendor_invoice_item->vendor_invoice': 'many_to_one', 'vendor_invoice->vendor': 'many_to_one', 'vendor->organization_type': 'many_to_one'}
94
+ // ['vendor_invoice', 'vendor'] -> many_to_one
95
+ // ['vendor', 'organization_type'] -> many_to_one
96
+ var _a;
97
+ return (_a = this.vendor) === null || _a === void 0 ? void 0 : _a.organizationType;
98
+ }
99
+ get officeLocation() {
100
+ // many_to_one -> many_to_one verified
101
+ // {'vendor_invoice_item->vendor_invoice': 'many_to_one', 'vendor_invoice->office_location': 'many_to_one'}
102
+ // ['vendor_invoice_item', 'vendor_invoice'] -> many_to_one
103
+ // ['vendor_invoice', 'office_location'] -> many_to_one
104
+ var _a;
105
+ return (_a = this.vendorInvoice) === null || _a === void 0 ? void 0 : _a.officeLocation;
106
+ }
68
107
  // getNextStatus(dto: IVendorInvoiceItemUpdateDto, currentUser: IUserEntity): VendorInvoiceItemStatus {
69
108
  // // const flow = vendorInvoiceConfigFlow as FlowConfig<
70
109
  // // VendorInvoiceActionStatusEnum,
@@ -30,7 +30,7 @@ export declare function getPermittedActionsOld<T extends LeaveStatusActionPair,
30
30
  }, currentStatus: T["status"] | null, userPermissions: string[], combineActions?: T["action"][], actionLabels?: {
31
31
  [key in T["action"]]?: string;
32
32
  }, data?: (a: E) => {
33
- [key: string]: () => boolean;
33
+ [permissionName: string]: () => boolean;
34
34
  }): {
35
35
  label: string;
36
36
  value: T["action"] | string;
@@ -73,91 +73,91 @@ export declare function getPermittedActions<T extends LeaveStatusActionPair, E>(
73
73
  }, currentStatus: T["status"] | null, userPermissions: string[], data?: (a: E) => {
74
74
  [key: string]: () => boolean;
75
75
  }): T["action"][];
76
- export declare class EntityActionFlowResolver<E extends EntityEnum, S extends string, A extends string> {
76
+ export declare class EntityActionFlowResolver<E extends EntityEnum, STATUS_ENUM_TYPE extends string, ACTION_ENUM_TYPE extends string, CONTEXT_DATA_TYPE = never> {
77
77
  getPermittedActions(entityFlowConfig: {
78
- [key in S]?: {
78
+ [key in STATUS_ENUM_TYPE]?: {
79
79
  actions: {
80
- [key in A]?: {
80
+ [key in ACTION_ENUM_TYPE]?: {
81
81
  permissions: string[];
82
- next: () => S;
82
+ next: (data: CONTEXT_DATA_TYPE) => STATUS_ENUM_TYPE;
83
83
  };
84
84
  };
85
85
  };
86
- }, currentStatus: S | null, userPermissions: string[], data?: (a: E) => {
86
+ }, currentStatus: STATUS_ENUM_TYPE | null, userPermissions: string[], data?: (a: E) => {
87
87
  [key: string]: () => boolean;
88
- }): A[];
88
+ }): ACTION_ENUM_TYPE[];
89
89
  _getPermittedActions(actionConfig: {
90
- [key in A]?: {
90
+ [key in ACTION_ENUM_TYPE]?: {
91
91
  permissions: string[];
92
- next: () => S;
92
+ next: (data: CONTEXT_DATA_TYPE) => STATUS_ENUM_TYPE;
93
93
  };
94
94
  }, userPermissions: string[], data: (a: E) => {
95
95
  [key: string]: () => boolean;
96
- }): (A | string)[];
97
- combinePermittedActions(permittedActions: readonly A[], combinedActions?: Record<string, {
98
- combineActions: readonly A[];
96
+ }): (ACTION_ENUM_TYPE | string)[];
97
+ combinePermittedActions(permittedActions: readonly ACTION_ENUM_TYPE[], combinedActions?: Record<string, {
98
+ combineActions: readonly ACTION_ENUM_TYPE[];
99
99
  label: string;
100
- }>): Map<A | string, string>;
101
- applyActionLabels(result: Map<A | string, string>, customLabels?: Partial<Record<A, string>>): Map<A | string, string>;
102
- getAvailableActionsLabelValue(availableActionsFromModel: Map<A | string, string>): {
100
+ }>): Map<ACTION_ENUM_TYPE | string, string>;
101
+ applyActionLabels(result: Map<ACTION_ENUM_TYPE | string, string>, customLabels?: Partial<Record<ACTION_ENUM_TYPE, string>>): Map<ACTION_ENUM_TYPE | string, string>;
102
+ getAvailableActionsLabelValue(availableActionsFromModel: Map<ACTION_ENUM_TYPE | string, string>): {
103
103
  label: string;
104
104
  value: string;
105
105
  }[];
106
106
  getAvailableActionsData(params: {
107
- flowConfig: FlowConfig<S, A>;
108
- currentStatus: S | null;
107
+ flowConfig: FlowConfig<STATUS_ENUM_TYPE, ACTION_ENUM_TYPE, CONTEXT_DATA_TYPE>;
108
+ currentStatus: STATUS_ENUM_TYPE | null;
109
109
  userPermissions: string[];
110
110
  visibilityData?: (e: E) => {
111
111
  [key: string]: () => boolean;
112
112
  };
113
113
  combinedActions?: Record<string, {
114
- combineActions: readonly A[];
114
+ combineActions: readonly ACTION_ENUM_TYPE[];
115
115
  label: string;
116
116
  }>;
117
- customLabels?: Partial<Record<A, string>>;
117
+ customLabels?: Partial<Record<ACTION_ENUM_TYPE, string>>;
118
118
  }): IRowActions<E>[];
119
119
  }
120
120
  export declare class EntityActionFlowResolverV2 {
121
- static getPermittedActions<E extends EntityEnum, S extends string, A extends string>(entityFlowConfig: {
122
- [key in S]?: {
121
+ static getPermittedActions<E extends EntityEnum, STATUS_ENUM_TYPE extends string, ACTION_ENUM_TYPE extends string, CONTEXT_DATA_TYPE = never>(entityFlowConfig: {
122
+ [key in STATUS_ENUM_TYPE]?: {
123
123
  actions: {
124
- [key in A]?: {
124
+ [key in ACTION_ENUM_TYPE]?: {
125
125
  permissions: string[];
126
- next: () => S;
126
+ next: (data: CONTEXT_DATA_TYPE) => STATUS_ENUM_TYPE;
127
127
  };
128
128
  };
129
129
  };
130
- }, currentStatus: S | null, userPermissions: string[], data?: (a: E) => {
130
+ }, currentStatus: STATUS_ENUM_TYPE | null, userPermissions: string[], data?: (a: E) => {
131
131
  [key: string]: () => boolean;
132
- }): A[];
133
- static _getPermittedActions<E extends EntityEnum, S extends string, A extends string>(actionConfig: {
134
- [key in A]?: {
132
+ }): ACTION_ENUM_TYPE[];
133
+ static _getPermittedActions<E extends EntityEnum, STATUS_ENUM_TYPE extends string, ACTION_ENUM_TYPE extends string, CONTEXT_DATA_TYPE = never>(actionConfig: {
134
+ [key in ACTION_ENUM_TYPE]?: {
135
135
  permissions: string[];
136
- next: () => S;
136
+ next: (data: CONTEXT_DATA_TYPE) => STATUS_ENUM_TYPE;
137
137
  };
138
138
  }, userPermissions: string[], data: (a: E) => {
139
- [key: string]: () => boolean;
140
- }): (A | string)[];
141
- static combinePermittedActions<A extends string>(permittedActions: readonly A[], combinedActions?: Record<string, {
142
- combineActions: readonly A[];
139
+ [permissionName: string]: () => boolean;
140
+ }): (ACTION_ENUM_TYPE | string)[];
141
+ static combinePermittedActions<ACTION_ENUM_TYPE extends string>(permittedActions: readonly ACTION_ENUM_TYPE[], combinedActions?: Record<string, {
142
+ combineActions: readonly ACTION_ENUM_TYPE[];
143
143
  label: string;
144
- }>): Map<A | string, string>;
145
- static applyActionLabels<A extends string>(result: Map<A | string, string>, customLabels?: Partial<Record<A, string>>): Map<A | string, string>;
146
- static getAvailableActionsLabelValue<A extends string>(availableActionsFromModel: Map<A | string, string>): {
144
+ }>): Map<ACTION_ENUM_TYPE | string, string>;
145
+ static applyActionLabels<ACTION_ENUM_TYPE extends string>(result: Map<ACTION_ENUM_TYPE | string, string>, customLabels?: Partial<Record<ACTION_ENUM_TYPE, string>>): Map<ACTION_ENUM_TYPE | string, string>;
146
+ static getAvailableActionsLabelValue<ACTION_ENUM_TYPE extends string>(availableActionsFromModel: Map<ACTION_ENUM_TYPE | string, string>): {
147
147
  label: string;
148
148
  value: string;
149
149
  }[];
150
- static getAvailableActionsData<E extends EntityEnum, S extends string, A extends string>(params: {
151
- flowConfig: FlowConfig<S, A>;
152
- currentStatus: S | null;
150
+ static getAvailableActionsData<E extends EntityEnum, STATUS_ENUM_TYPE extends string, ACTION_ENUM_TYPE extends string, FLOW_CONTEXT_DATA_TYPE = never>(params: {
151
+ flowConfig: FlowConfig<STATUS_ENUM_TYPE, ACTION_ENUM_TYPE, FLOW_CONTEXT_DATA_TYPE>;
152
+ currentStatus: STATUS_ENUM_TYPE | null;
153
153
  userPermissions: string[];
154
154
  visibilityData?: (e: E) => {
155
155
  [key: string]: () => boolean;
156
156
  };
157
157
  combinedActions?: Record<string, {
158
- combineActions: readonly A[];
158
+ combineActions: readonly ACTION_ENUM_TYPE[];
159
159
  label: string;
160
160
  }>;
161
- customLabels?: Partial<Record<A, string>>;
161
+ customLabels?: Partial<Record<ACTION_ENUM_TYPE, string>>;
162
162
  }): IRowActions<E>[];
163
163
  }
package/package.json CHANGED
@@ -1,41 +1,41 @@
1
- {
2
- "name": "law-common",
3
- "version": "10.72.1-beta.3",
4
- "description": "",
5
- "main": "dist/index.js",
6
- "files": [
7
- "dist/**/*"
8
- ],
9
- "scripts": {
10
- "clean": "rm -rf dist",
11
- "build": "npm run clean && tsc",
12
- "publish:beta": "npm version prerelease --preid beta && git push && npm run build && npm publish --tag beta && npm run link",
13
- "publish:patch": "npm version patch && git push && npm run build && npm publish",
14
- "publish:minor": "npm version minor && git push && npm run build && npm publish",
15
- "publish:major": "npm version major && git push && npm run build && npm publish",
16
- "link": "npm run build && npm link",
17
- "test": "jest",
18
- "format": "prettier --write .",
19
- "check-format": "prettier --check .",
20
- "pull:link": "git pull && npm run link"
21
- },
22
- "keywords": [],
23
- "author": "",
24
- "license": "ISC",
25
- "devDependencies": {
26
- "@types/jest": "^29.5.13",
27
- "@types/lodash": "^4.17.21",
28
- "@types/node": "^22.6.1",
29
- "jest": "^29.7.0",
30
- "prettier": "3.8.1",
31
- "ts-jest": "^29.2.5",
32
- "ts-node": "^10.9.2",
33
- "typescript": "^5.6.2"
34
- },
35
- "dependencies": {
36
- "@types/express": "^5.0.0",
37
- "@types/multer": "^1.4.12",
38
- "date-fns": "^4.1.0",
39
- "lodash": "4.17.21"
40
- }
41
- }
1
+ {
2
+ "name": "law-common",
3
+ "version": "10.72.2-beta.1",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "files": [
7
+ "dist/**/*"
8
+ ],
9
+ "scripts": {
10
+ "clean": "rm -rf dist",
11
+ "build": "npm run clean && tsc",
12
+ "publish:beta": "npm version prerelease --preid beta && git push && npm run build && npm publish --tag beta && npm run link",
13
+ "publish:patch": "npm version patch && git push && npm run build && npm publish",
14
+ "publish:minor": "npm version minor && git push && npm run build && npm publish",
15
+ "publish:major": "npm version major && git push && npm run build && npm publish",
16
+ "link": "npm run build && npm link",
17
+ "test": "jest",
18
+ "format": "prettier --write .",
19
+ "check-format": "prettier --check .",
20
+ "pull:link": "git pull && npm run link"
21
+ },
22
+ "keywords": [],
23
+ "author": "",
24
+ "license": "ISC",
25
+ "devDependencies": {
26
+ "@types/jest": "^29.5.13",
27
+ "@types/lodash": "^4.17.21",
28
+ "@types/node": "^22.6.1",
29
+ "jest": "^29.7.0",
30
+ "prettier": "3.8.1",
31
+ "ts-jest": "^29.2.5",
32
+ "ts-node": "^10.9.2",
33
+ "typescript": "^5.6.2"
34
+ },
35
+ "dependencies": {
36
+ "@types/express": "^5.0.0",
37
+ "@types/multer": "^1.4.12",
38
+ "date-fns": "^4.1.0",
39
+ "lodash": "4.17.21"
40
+ }
41
+ }