law-common 10.61.2-beta.2 → 10.61.2-beta.4
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/dist/src/api/interface/vendor_invoice.update.dto.interface.d.ts +1 -1
- package/dist/src/entities/enums/vendor-action.enum.d.ts +1 -2
- package/dist/src/entities/enums/vendor-action.enum.js +1 -1
- package/dist/src/entities/flow-configs/vendor-flow.config.js +8 -8
- package/dist/src/entities/model/vendor.entity.model.d.ts +13 -0
- package/dist/src/entities/model/vendor.entity.model.js +16 -0
- package/dist/src/utils/helper.fn.util.d.ts +29 -0
- package/dist/src/utils/helper.fn.util.js +32 -2
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import { DeepPartialButRequired } from "./api.utils.interface";
|
|
|
4
4
|
import { IVendorInvoiceCreateDto } from "./vendor_invoice.create.dto.interface";
|
|
5
5
|
export type IVendorInvoiceUpdateDto = DeepPartialButRequired<IVendorInvoiceCreateDto, never> & {
|
|
6
6
|
deleteDocumentDetails?: IDeleteDocumentDetails<EnumEntityType<EntityEnum.VENDOR_INVOICE>>;
|
|
7
|
-
actionData
|
|
7
|
+
actionData: IVendorInvoiceActionDataDto;
|
|
8
8
|
};
|
|
9
9
|
export interface IVendorInvoiceActionDataDto {
|
|
10
10
|
action: VendorInvoiceActionEnum;
|
|
@@ -9,5 +9,5 @@ var VendorActionEnum;
|
|
|
9
9
|
VendorActionEnum["CREATE"] = "create";
|
|
10
10
|
VendorActionEnum["APPROVE"] = "approve";
|
|
11
11
|
VendorActionEnum["REJECT"] = "reject";
|
|
12
|
-
|
|
12
|
+
// RECALL = "recall",
|
|
13
13
|
})(VendorActionEnum || (exports.VendorActionEnum = VendorActionEnum = {}));
|
|
@@ -38,10 +38,10 @@ exports.vendorFlowConfig = {
|
|
|
38
38
|
permissions: ["VENDOR_APPROVE_ORG"],
|
|
39
39
|
next: () => vendor_status_enum_1.VendorStatusEnum.RESOLVED_REJECTED,
|
|
40
40
|
},
|
|
41
|
-
[
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
},
|
|
41
|
+
// [VendorActionEnum.RECALL]: {
|
|
42
|
+
// permissions: ["VENDOR_UPDATE"],
|
|
43
|
+
// next: () => VendorStatusEnum.DELETED,
|
|
44
|
+
// },
|
|
45
45
|
},
|
|
46
46
|
},
|
|
47
47
|
[vendor_status_enum_1.VendorStatusEnum.DELETE_APPROVAL]: {
|
|
@@ -54,10 +54,10 @@ exports.vendorFlowConfig = {
|
|
|
54
54
|
permissions: ["VENDOR_APPROVE_ORG"],
|
|
55
55
|
next: () => vendor_status_enum_1.VendorStatusEnum.RESOLVED_REJECTED,
|
|
56
56
|
},
|
|
57
|
-
[
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
},
|
|
57
|
+
// [VendorActionEnum.RECALL]: {
|
|
58
|
+
// permissions: ["VENDOR_UPDATE"],
|
|
59
|
+
// next: () => VendorStatusEnum.DELETED,
|
|
60
|
+
// },
|
|
61
61
|
},
|
|
62
62
|
},
|
|
63
63
|
[vendor_status_enum_1.VendorStatusEnum.APPROVED]: {
|
|
@@ -10,6 +10,9 @@ import { VendorPanTypeEnum } from "../enums/vendor_pan_type_enum";
|
|
|
10
10
|
import { IUserEntity } from "../interface/user.entity.interface";
|
|
11
11
|
import { IVendorEntity } from "../interface/vendor.entity.interface";
|
|
12
12
|
import { OrganizationTypeEntityModel } from "./organization_type.entity.model";
|
|
13
|
+
import { IRowActions } from "./interface/row-actions.interface";
|
|
14
|
+
import { UserEntityModel } from "./user.entity.model";
|
|
15
|
+
import { VendorActionEnum } from "../enums/vendor-action.enum";
|
|
13
16
|
export declare class VendorEntityModel extends BaseEntityModel<EntityEnum.VENDOR> implements IVendorEntity {
|
|
14
17
|
id: number;
|
|
15
18
|
name: string;
|
|
@@ -47,4 +50,14 @@ export declare class VendorEntityModel extends BaseEntityModel<EntityEnum.VENDOR
|
|
|
47
50
|
getNextStatus(currentUser: IUserEntity, dto: IEntityUpdateDto<IVendorEntity> & {
|
|
48
51
|
actionData: IVendorActionDataDto;
|
|
49
52
|
}): VendorStatusEnum;
|
|
53
|
+
getAvailableActions(currentUser: UserEntityModel, config?: {
|
|
54
|
+
combinedActions?: Record<string, {
|
|
55
|
+
combineActions: VendorActionEnum[];
|
|
56
|
+
label: string;
|
|
57
|
+
}>;
|
|
58
|
+
customLabels?: Partial<Record<VendorActionEnum, string>>;
|
|
59
|
+
}): IRowActions<EntityEnum.VENDOR>[];
|
|
60
|
+
getUpdateActionVisibility(currentUser: UserEntityModel): {
|
|
61
|
+
[key: string]: () => boolean;
|
|
62
|
+
};
|
|
50
63
|
}
|
|
@@ -11,6 +11,7 @@ const vendor_gst_type_enum_1 = require("../enums/vendor_gst_type_enum");
|
|
|
11
11
|
const vendor_location_type_enum_1 = require("../enums/vendor_location_type_enum");
|
|
12
12
|
const vendor_pan_type_enum_1 = require("../enums/vendor_pan_type_enum");
|
|
13
13
|
const vendor_flow_config_1 = require("../flow-configs/vendor-flow.config");
|
|
14
|
+
const utils_1 = require("../../utils");
|
|
14
15
|
class VendorEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
15
16
|
constructor() {
|
|
16
17
|
super(...arguments);
|
|
@@ -98,6 +99,21 @@ class VendorEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
98
99
|
const nextStatus = matchingPermissionConfig.next();
|
|
99
100
|
return nextStatus;
|
|
100
101
|
}
|
|
102
|
+
getAvailableActions(currentUser, config) {
|
|
103
|
+
var _a;
|
|
104
|
+
const params = {
|
|
105
|
+
flowConfig: vendor_flow_config_1.vendorFlowConfig,
|
|
106
|
+
currentStatus: this.status,
|
|
107
|
+
userPermissions: (_a = currentUser.permissions) !== null && _a !== void 0 ? _a : [],
|
|
108
|
+
visibilityData: this.getUpdateActionVisibility.bind(this, currentUser),
|
|
109
|
+
combinedActions: config === null || config === void 0 ? void 0 : config.combinedActions,
|
|
110
|
+
customLabels: config === null || config === void 0 ? void 0 : config.customLabels,
|
|
111
|
+
};
|
|
112
|
+
return utils_1.EntityActionFlowResolverV2.getAvailableActionsData(params);
|
|
113
|
+
}
|
|
114
|
+
getUpdateActionVisibility(currentUser) {
|
|
115
|
+
return {};
|
|
116
|
+
}
|
|
101
117
|
}
|
|
102
118
|
exports.VendorEntityModel = VendorEntityModel;
|
|
103
119
|
VendorEntityModel.relationConfigs = [];
|
|
@@ -19,6 +19,35 @@ export type DiffObject<T extends Record<string, unknown>, U extends Record<strin
|
|
|
19
19
|
export declare function getDifferingKeysWithValues<T extends Record<string, unknown>, U extends Record<string, unknown>>(obj1: T, obj2: U, keysToCompare?: (keyof T | keyof U)[]): DiffObject<T, U>;
|
|
20
20
|
export declare function removeSamePropertyValues(source: any, target: any): void;
|
|
21
21
|
export declare function getChangedProperties<T>(source: T, target: T): Partial<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Performs a deep equality comparison between two objects of the same type.
|
|
24
|
+
* Recursively compares nested objects and handles null/undefined values.
|
|
25
|
+
*
|
|
26
|
+
* @template T - An object type extending `Record<string, any>`
|
|
27
|
+
* @param {T} obj1 - The first object to compare
|
|
28
|
+
* @param {T} obj2 - The second object to compare
|
|
29
|
+
* @returns {boolean} `true` if both objects are deeply equal, `false` otherwise
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* // Primitive values
|
|
33
|
+
* compareObjects({ a: 1, b: "hello" }, { a: 1, b: "hello" }); // true
|
|
34
|
+
* compareObjects({ a: 1 }, { a: 2 }); // false
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* // Nested objects
|
|
38
|
+
* compareObjects(
|
|
39
|
+
* { user: { name: "Alice", age: 30 } },
|
|
40
|
+
* { user: { name: "Alice", age: 30 } }
|
|
41
|
+
* ); // true
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* // Mismatched keys
|
|
45
|
+
* compareObjects({ a: 1, b: 2 }, { a: 1 }); // false
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* // null and undefined are treated as equal
|
|
49
|
+
* compareObjects({ a: null }, { a: undefined }); // true
|
|
50
|
+
*/
|
|
22
51
|
export declare function compareObjects<T extends Record<string, any>>(obj1: T, obj2: T): boolean;
|
|
23
52
|
/**
|
|
24
53
|
* Removes elements from the target array that are present in the source array.
|
|
@@ -142,13 +142,43 @@ function getChangedProperties(source, target) {
|
|
|
142
142
|
}
|
|
143
143
|
return result;
|
|
144
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Performs a deep equality comparison between two objects of the same type.
|
|
147
|
+
* Recursively compares nested objects and handles null/undefined values.
|
|
148
|
+
*
|
|
149
|
+
* @template T - An object type extending `Record<string, any>`
|
|
150
|
+
* @param {T} obj1 - The first object to compare
|
|
151
|
+
* @param {T} obj2 - The second object to compare
|
|
152
|
+
* @returns {boolean} `true` if both objects are deeply equal, `false` otherwise
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* // Primitive values
|
|
156
|
+
* compareObjects({ a: 1, b: "hello" }, { a: 1, b: "hello" }); // true
|
|
157
|
+
* compareObjects({ a: 1 }, { a: 2 }); // false
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* // Nested objects
|
|
161
|
+
* compareObjects(
|
|
162
|
+
* { user: { name: "Alice", age: 30 } },
|
|
163
|
+
* { user: { name: "Alice", age: 30 } }
|
|
164
|
+
* ); // true
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* // Mismatched keys
|
|
168
|
+
* compareObjects({ a: 1, b: 2 }, { a: 1 }); // false
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* // null and undefined are treated as equal
|
|
172
|
+
* compareObjects({ a: null }, { a: undefined }); // true
|
|
173
|
+
*/
|
|
145
174
|
function compareObjects(obj1, obj2) {
|
|
175
|
+
const excludeKeys = ["createdOn", "updatedOn", "createdBy", "updatedBy"];
|
|
146
176
|
if (obj1 === obj2)
|
|
147
177
|
return true;
|
|
148
178
|
if (!obj1 || !obj2)
|
|
149
179
|
return false;
|
|
150
|
-
const keys1 = Object.keys(obj1);
|
|
151
|
-
const keys2 = Object.keys(obj2);
|
|
180
|
+
const keys1 = Object.keys(obj1).filter((key) => !excludeKeys.includes(key));
|
|
181
|
+
const keys2 = Object.keys(obj2).filter((key) => !excludeKeys.includes(key));
|
|
152
182
|
if (keys1.length !== keys2.length)
|
|
153
183
|
return false;
|
|
154
184
|
return keys1.every((key) => {
|