law-common 10.68.5-beta.5 → 10.71.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.
package/README.md CHANGED
@@ -1 +1 @@
1
- # law-common
1
+ # law-common
@@ -1,7 +1,16 @@
1
- import { FlowConfig, ILeaveEntity, LeaveActionEnum, LeaveStatusEnum } from "../../entities";
1
+ import { 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 = FlowConfig<LeaveStatusEnum, LeaveActionEnum, never>;
7
+ export type ILeaveFlowConfig = {
8
+ [key in LeaveStatusEnum]?: {
9
+ actions: {
10
+ [key in LeaveActionEnum]?: {
11
+ permissions: string[];
12
+ next: () => LeaveStatusEnum;
13
+ };
14
+ };
15
+ };
16
+ };
@@ -22,19 +22,10 @@
22
22
  // }
23
23
  // export type IVendorBankDetailCreateExclude = never;
24
24
  // export interface IVendorBankDetailCreateDto extends Omit<IEntityCreateDto<IVendorBankDetailEntity>, IVendorBankDetailCreateExclude> {}
25
- // export type IVendorCreateExclude =
26
- // | "contactDetail"
27
- // | "bankDetail"
28
- // | "organizationTypeId"
29
- // | "status"
30
- // | "remark"
31
- // | "panDocument"
32
- // | "gstDocument"
33
- // | "contractDocument"
34
- // | "attachmentDocuments";
25
+ // export type IVendorCreateExclude = "contactDetail" | "bankDetail" | "panDocument" | "gstDocument" | "contractDocument" | "attachmentDocuments";
35
26
  // export interface IVendorCreateDto extends Omit<IEntityCreateDto<IVendorEntity>, IVendorCreateExclude> {
36
- // contactDetail?: IVendorContactDetailCreateDto[];
37
- // bankDetail?: IVendorBankDetailCreateDto[];
27
+ // contactDetail?: IVendorContactDetailEntity;
28
+ // bankDetail?: IVendorBankDetailEntity;
38
29
  // panDocument?: Nullable<MulterFileWithUrl>;
39
30
  // gstDocument?: Nullable<MulterFileWithUrl>;
40
31
  // contractDocument?: Nullable<MulterFileWithUrl>;
@@ -1,6 +1,12 @@
1
1
  import { VendorActionEnum } from "../../entities/enums/vendor-action.enum";
2
2
  import { VendorStatusEnum } from "../../entities/enums/vendor-status.enum";
3
- import { FlowConfig } from "../../entities/flow-configs/flow-config.type";
4
- export interface IVendorFlowConfigContextData {
5
- }
6
- export type IVendorFlowConfig = FlowConfig<VendorStatusEnum, VendorActionEnum, IVendorFlowConfigContextData>;
3
+ export type IVendorFlowConfig = {
4
+ [key in VendorStatusEnum]?: {
5
+ actions: {
6
+ [key in VendorActionEnum]?: {
7
+ permissions: string[];
8
+ next: () => VendorStatusEnum;
9
+ };
10
+ };
11
+ };
12
+ };
@@ -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 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.
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.
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<STATUS_ENUM_TYPE extends string, ACTION_ENUM_TYPE extends string, CONTEXT_DATA_TYPE = never> = {
31
- [key in STATUS_ENUM_TYPE]?: {
30
+ export type FlowConfig<S extends string, A extends string, T extends Record<any, any> = never> = {
31
+ [key in S]?: {
32
32
  actions: {
33
- [key in ACTION_ENUM_TYPE]?: IFlowConfigActionConfig<STATUS_ENUM_TYPE, CONTEXT_DATA_TYPE>;
33
+ [key in A]?: IFlowConfigActionConfig<S, T>;
34
34
  };
35
35
  description?: string;
36
36
  };
@@ -39,8 +39,8 @@ export type FlowConfig<STATUS_ENUM_TYPE extends string, ACTION_ENUM_TYPE extends
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 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.
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.
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<STATUS_ENUM_TYPE extends string, ACTION_ENUM_TYPE extends
58
58
  * next: (data) => areAllRowsApproved(data) ? ReimbursementStatusEnum.APPROVED : ReimbursementStatusEnum.APPROVAL_PENDING,
59
59
  * };
60
60
  */
61
- export interface IFlowConfigActionConfig<STATUS_ENUM_TYPE extends string, CONTEXT_DATA_TYPE> {
61
+ export interface IFlowConfigActionConfig<S extends string, T> {
62
62
  permissions: string[];
63
- next: (data: CONTEXT_DATA_TYPE) => STATUS_ENUM_TYPE;
63
+ next: (data?: T) => S;
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, never>;
4
+ export declare const leaveFlowConfig: FlowConfig<LeaveStatusEnum, LeaveActionEnum>;
@@ -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: (vendorFlowConfigContextData) => vendor_status_enum_1.VendorStatusEnum.APPROVED,
11
+ next: () => vendor_status_enum_1.VendorStatusEnum.APPROVED,
12
12
  },
13
13
  [vendor_action_enum_1.VendorActionEnum.EDIT]: {
14
14
  permissions: ["VENDOR_UPDATE"],
15
- next: (vendorFlowConfigContextData) => vendor_status_enum_1.VendorStatusEnum.CREATE_APPROVAL,
15
+ next: () => 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: (vendorFlowConfigContextData) => vendor_status_enum_1.VendorStatusEnum.REJECTED,
19
+ next: () => vendor_status_enum_1.VendorStatusEnum.REJECTED,
20
20
  },
21
21
  [vendor_action_enum_1.VendorActionEnum.DELETE]: {
22
22
  permissions: ["VENDOR_UPDATE"],
23
- next: (vendorFlowConfigContextData) => vendor_status_enum_1.VendorStatusEnum.DELETED,
23
+ next: () => 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: (vendorFlowConfigContextData) => vendor_status_enum_1.VendorStatusEnum.APPROVED,
31
+ next: () => vendor_status_enum_1.VendorStatusEnum.APPROVED,
32
32
  },
33
33
  [vendor_action_enum_1.VendorActionEnum.EDIT]: {
34
34
  permissions: ["VENDOR_UPDATE"],
35
- next: (vendorFlowConfigContextData) => vendor_status_enum_1.VendorStatusEnum.EDIT_APPROVAL,
35
+ next: () => 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: (vendorFlowConfigContextData) => vendor_status_enum_1.VendorStatusEnum.RESOLVED_REJECTED,
39
+ next: () => vendor_status_enum_1.VendorStatusEnum.RESOLVED_REJECTED,
40
40
  },
41
41
  // [VendorActionEnum.RECALL]: {
42
42
  // permissions: ["VENDOR_UPDATE"],
43
- // next: (vendorFlowConfigContextData: IVendorFlowConfigContextData) => VendorStatusEnum.DELETED,
43
+ // next: () => 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: (vendorFlowConfigContextData) => vendor_status_enum_1.VendorStatusEnum.DELETED,
51
+ next: () => vendor_status_enum_1.VendorStatusEnum.DELETED,
52
52
  },
53
53
  [vendor_action_enum_1.VendorActionEnum.REJECT]: {
54
54
  permissions: ["VENDOR_APPROVE_ORG"],
55
- next: (vendorFlowConfigContextData) => vendor_status_enum_1.VendorStatusEnum.RESOLVED_REJECTED,
55
+ next: () => vendor_status_enum_1.VendorStatusEnum.RESOLVED_REJECTED,
56
56
  },
57
57
  // [VendorActionEnum.RECALL]: {
58
58
  // permissions: ["VENDOR_UPDATE"],
59
- // next: (vendorFlowConfigContextData: IVendorFlowConfigContextData) => VendorStatusEnum.DELETED,
59
+ // next: () => 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: (vendorFlowConfigContextData) => vendor_status_enum_1.VendorStatusEnum.EDIT_APPROVAL,
67
+ next: () => vendor_status_enum_1.VendorStatusEnum.EDIT_APPROVAL,
68
68
  },
69
69
  [vendor_action_enum_1.VendorActionEnum.DELETE]: {
70
70
  permissions: ["VENDOR_UPDATE"],
71
- next: (vendorFlowConfigContextData) => vendor_status_enum_1.VendorStatusEnum.DELETE_APPROVAL,
71
+ next: () => 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: (vendorFlowConfigContextData) => vendor_status_enum_1.VendorStatusEnum.EDIT_APPROVAL,
79
+ next: () => vendor_status_enum_1.VendorStatusEnum.EDIT_APPROVAL,
80
80
  },
81
81
  [vendor_action_enum_1.VendorActionEnum.DELETE]: {
82
82
  permissions: ["VENDOR_UPDATE"],
83
- next: (vendorFlowConfigContextData) => vendor_status_enum_1.VendorStatusEnum.DELETE_APPROVAL,
83
+ next: () => vendor_status_enum_1.VendorStatusEnum.DELETE_APPROVAL,
84
84
  },
85
85
  },
86
86
  },
@@ -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) {
@@ -1,7 +1,7 @@
1
- import { EntityEnum, Nullable } from "../interface/entity.utils.interface";
1
+ import { EntityEnum, IEntityUpdateDto, 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 { IVendorFlowConfigContextData } from "../../api";
4
+ import { IVendorActionDataDto } 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,10 +62,12 @@ 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.ORGANIZATION_TYPE], EntityEnum.VENDOR>;
65
+ static relationConfigs: RelationConfigs<[EntityEnum.STATE], EntityEnum.VENDOR>;
66
66
  static fromEntity(entity: IVendorEntity): VendorEntityModel;
67
67
  getRelationConfigs(): any[];
68
- getNextStatus(currentUser: IUserEntity, action: VendorActionEnum, vendorFlowConfigContextData: IVendorFlowConfigContextData): VendorStatusEnum;
68
+ getNextStatus(currentUser: IUserEntity, dto: IEntityUpdateDto<IVendorEntity> & {
69
+ actionData: IVendorActionDataDto;
70
+ }): VendorStatusEnum;
69
71
  getAvailableActions(currentUser: UserEntityModel, config?: {
70
72
  combinedActions?: Record<string, {
71
73
  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, action, vendorFlowConfigContextData) {
60
+ getNextStatus(currentUser, dto) {
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 (!action) {
74
+ if (!(dto === null || dto === void 0 ? void 0 : dto.actionData)) {
75
75
  throw new exceptions_1.AppBadRequestException({
76
76
  key: error_key_enum_1.ErrorKeyEnum.ACTION_DATA,
77
- message: ["actionData is required"],
77
+ message: ["dto.actionData is required"],
78
78
  });
79
79
  }
80
- const matchingPermissionConfig = flowForStatus.actions[action];
80
+ const matchingPermissionConfig = flowForStatus.actions[dto.actionData.action];
81
81
  if (!matchingPermissionConfig) {
82
82
  throw new exceptions_1.AppBadRequestException({
83
83
  key: error_key_enum_1.ErrorKeyEnum.ACTION,
84
- message: [`Action '${action}' is not valid for the current status.`],
84
+ message: [`Action '${dto.actionData.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 ${action} vendor`],
97
+ message: [`Current user does not have permission to ${dto.actionData.action} vendor`],
98
98
  });
99
99
  }
100
- const nextStatus = matchingPermissionConfig.next(vendorFlowConfigContextData);
100
+ const nextStatus = matchingPermissionConfig.next();
101
101
  return nextStatus;
102
102
  }
103
103
  getAvailableActions(currentUser, config) {
@@ -151,13 +151,4 @@ 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
- },
163
154
  ];
@@ -9,11 +9,6 @@
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";
17
12
  // export class VendorInvoiceItemEntityModel extends BaseEntityModel<EntityEnum.VENDOR_INVOICE_ITEM> implements IVendorInvoiceItemEntity {
18
13
  // id: number = 0;
19
14
  // vendorInvoiceId: number = 0;
@@ -94,39 +89,4 @@
94
89
  // getRelationConfigs(): any[] {
95
90
  // return this.constructor.prototype.constructor.relationConfigs || [];
96
91
  // }
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
- // }
132
92
  // }
@@ -1,20 +1,22 @@
1
1
  import { EntityEnum, Nullable } from "../interface/entity.utils.interface";
2
- import { BaseEntityModel } from "./base.entity.model";
3
2
  import { RelationConfigs } from "../interface/relation-config.interface";
3
+ import { BaseEntityModel } from "./base.entity.model";
4
4
  import { IVendorInvoiceItemEntity } from "../interface/vendor_invoice_item.entity.interface";
5
- import { VendorInvoiceEntityModel } from "./vendor_invoice.entity.model";
6
- import { VoucherTypeEntityModel } from "./voucher_type.entity.model";
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";
7
8
  import { ExpenseHeadEntityModel } from "./expense_head.entity.model";
8
9
  import { GstRateEntityModel } from "./gst_rate.entity.model";
9
10
  import { TdsRateEntityModel } from "./tds_rate.entity.model";
10
11
  import { VendorEntityModel } from "./vendor.entity.model";
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";
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
+ }
18
20
  export declare class VendorInvoiceItemEntityModel extends BaseEntityModel<EntityEnum.VENDOR_INVOICE_ITEM> implements IVendorInvoiceItemEntity {
19
21
  id: number;
20
22
  vendorInvoiceId: number;
@@ -28,13 +30,13 @@ export declare class VendorInvoiceItemEntityModel extends BaseEntityModel<Entity
28
30
  netAmount: number;
29
31
  quantity: number;
30
32
  rate: number;
33
+ remark: Nullable<string>;
34
+ gstAmount: number;
35
+ tdsAmount: number;
31
36
  createdOn: number;
32
37
  updatedOn: number;
33
38
  createdBy: number;
34
39
  updatedBy: number;
35
- remark: Nullable<string>;
36
- gstAmount: number;
37
- tdsAmount: number;
38
40
  vendorInvoice?: VendorInvoiceEntityModel;
39
41
  voucherType?: VoucherTypeEntityModel;
40
42
  expenseHead?: ExpenseHeadEntityModel;
@@ -49,11 +51,6 @@ export declare class VendorInvoiceItemEntityModel extends BaseEntityModel<Entity
49
51
  ], EntityEnum.VENDOR_INVOICE_ITEM>;
50
52
  static fromEntity(entity: IVendorInvoiceItemEntity): VendorInvoiceItemEntityModel;
51
53
  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;
57
54
  static calculateAmounts(params: {
58
55
  basicAmount: number;
59
56
  gstRateEntity: IGstRateEntity;
@@ -63,9 +60,3 @@ export declare class VendorInvoiceItemEntityModel extends BaseEntityModel<Entity
63
60
  static tdsRate(vendorEntity: IVendorEntity, tdsRateEntity: ITdsRateEntity): number;
64
61
  static AMOUNT_KEYS: (keyof IVendorInvoiceItemEntityAmounts)[];
65
62
  }
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");
4
5
  const entity_utils_interface_1 = require("../interface/entity.utils.interface");
5
6
  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,13 +20,14 @@ 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;
23
27
  this.createdOn = 0;
24
28
  this.updatedOn = 0;
25
29
  this.createdBy = 0;
26
30
  this.updatedBy = 0;
27
- this.remark = null;
28
- this.gstAmount = 0;
29
- this.tdsAmount = 0;
30
31
  // getAvailableActions(
31
32
  // currentUser: UserEntityModel,
32
33
  // config?: {
@@ -64,46 +65,6 @@ class VendorInvoiceItemEntityModel extends base_entity_model_1.BaseEntityModel {
64
65
  getRelationConfigs() {
65
66
  return this.constructor.prototype.constructor.relationConfigs || [];
66
67
  }
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
- }
107
68
  // getNextStatus(dto: IVendorInvoiceItemUpdateDto, currentUser: IUserEntity): VendorInvoiceItemStatus {
108
69
  // // const flow = vendorInvoiceConfigFlow as FlowConfig<
109
70
  // // 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
- [permissionName: string]: () => boolean;
33
+ [key: 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, STATUS_ENUM_TYPE extends string, ACTION_ENUM_TYPE extends string, CONTEXT_DATA_TYPE = never> {
76
+ export declare class EntityActionFlowResolver<E extends EntityEnum, S extends string, A extends string> {
77
77
  getPermittedActions(entityFlowConfig: {
78
- [key in STATUS_ENUM_TYPE]?: {
78
+ [key in S]?: {
79
79
  actions: {
80
- [key in ACTION_ENUM_TYPE]?: {
80
+ [key in A]?: {
81
81
  permissions: string[];
82
- next: (data: CONTEXT_DATA_TYPE) => STATUS_ENUM_TYPE;
82
+ next: () => S;
83
83
  };
84
84
  };
85
85
  };
86
- }, currentStatus: STATUS_ENUM_TYPE | null, userPermissions: string[], data?: (a: E) => {
86
+ }, currentStatus: S | null, userPermissions: string[], data?: (a: E) => {
87
87
  [key: string]: () => boolean;
88
- }): ACTION_ENUM_TYPE[];
88
+ }): A[];
89
89
  _getPermittedActions(actionConfig: {
90
- [key in ACTION_ENUM_TYPE]?: {
90
+ [key in A]?: {
91
91
  permissions: string[];
92
- next: (data: CONTEXT_DATA_TYPE) => STATUS_ENUM_TYPE;
92
+ next: () => S;
93
93
  };
94
94
  }, userPermissions: string[], data: (a: E) => {
95
95
  [key: string]: () => boolean;
96
- }): (ACTION_ENUM_TYPE | string)[];
97
- combinePermittedActions(permittedActions: readonly ACTION_ENUM_TYPE[], combinedActions?: Record<string, {
98
- combineActions: readonly ACTION_ENUM_TYPE[];
96
+ }): (A | string)[];
97
+ combinePermittedActions(permittedActions: readonly A[], combinedActions?: Record<string, {
98
+ combineActions: readonly A[];
99
99
  label: 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>): {
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>): {
103
103
  label: string;
104
104
  value: string;
105
105
  }[];
106
106
  getAvailableActionsData(params: {
107
- flowConfig: FlowConfig<STATUS_ENUM_TYPE, ACTION_ENUM_TYPE, CONTEXT_DATA_TYPE>;
108
- currentStatus: STATUS_ENUM_TYPE | null;
107
+ flowConfig: FlowConfig<S, A>;
108
+ currentStatus: S | 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 ACTION_ENUM_TYPE[];
114
+ combineActions: readonly A[];
115
115
  label: string;
116
116
  }>;
117
- customLabels?: Partial<Record<ACTION_ENUM_TYPE, string>>;
117
+ customLabels?: Partial<Record<A, string>>;
118
118
  }): IRowActions<E>[];
119
119
  }
120
120
  export declare class EntityActionFlowResolverV2 {
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]?: {
121
+ static getPermittedActions<E extends EntityEnum, S extends string, A extends string>(entityFlowConfig: {
122
+ [key in S]?: {
123
123
  actions: {
124
- [key in ACTION_ENUM_TYPE]?: {
124
+ [key in A]?: {
125
125
  permissions: string[];
126
- next: (data: CONTEXT_DATA_TYPE) => STATUS_ENUM_TYPE;
126
+ next: () => S;
127
127
  };
128
128
  };
129
129
  };
130
- }, currentStatus: STATUS_ENUM_TYPE | null, userPermissions: string[], data?: (a: E) => {
130
+ }, currentStatus: S | null, userPermissions: string[], data?: (a: E) => {
131
131
  [key: string]: () => boolean;
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]?: {
132
+ }): A[];
133
+ static _getPermittedActions<E extends EntityEnum, S extends string, A extends string>(actionConfig: {
134
+ [key in A]?: {
135
135
  permissions: string[];
136
- next: (data: CONTEXT_DATA_TYPE) => STATUS_ENUM_TYPE;
136
+ next: () => S;
137
137
  };
138
138
  }, userPermissions: string[], data: (a: E) => {
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[];
139
+ [key: string]: () => boolean;
140
+ }): (A | string)[];
141
+ static combinePermittedActions<A extends string>(permittedActions: readonly A[], combinedActions?: Record<string, {
142
+ combineActions: readonly A[];
143
143
  label: 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>): {
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>): {
147
147
  label: string;
148
148
  value: string;
149
149
  }[];
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;
150
+ static getAvailableActionsData<E extends EntityEnum, S extends string, A extends string>(params: {
151
+ flowConfig: FlowConfig<S, A>;
152
+ currentStatus: S | 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 ACTION_ENUM_TYPE[];
158
+ combineActions: readonly A[];
159
159
  label: string;
160
160
  }>;
161
- customLabels?: Partial<Record<ACTION_ENUM_TYPE, string>>;
161
+ customLabels?: Partial<Record<A, string>>;
162
162
  }): IRowActions<E>[];
163
163
  }
package/package.json CHANGED
@@ -1,41 +1,41 @@
1
- {
2
- "name": "law-common",
3
- "version": "10.68.5-beta.5",
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.71.0",
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
+ }