law-common 10.72.1-beta.2 → 10.72.1-beta.3
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 +1 -1
- package/dist/src/api/interface/leave.api.d.ts +11 -2
- package/dist/src/api/interface/vendor.create.dto.interface.autocode.js +3 -12
- package/dist/src/api/interface/vendor.entity.response.d.ts +10 -4
- package/dist/src/entities/flow-configs/flow-config.type.d.ts +10 -10
- package/dist/src/entities/flow-configs/leave.flow.config.d.ts +1 -1
- package/dist/src/entities/flow-configs/vendor-flow.config.js +15 -15
- package/dist/src/entities/interface/billing_profile.entity.interface.d.ts +3 -0
- package/dist/src/entities/interface/entity.utils.interface.d.ts +2 -2
- package/dist/src/entities/interface/reimbursement.entity.interface.d.ts +1 -0
- package/dist/src/entities/model/billing.entity.model.d.ts +2 -0
- package/dist/src/entities/model/billing.entity.model.js +6 -0
- package/dist/src/entities/model/entity.model.interface.d.ts +4 -0
- package/dist/src/entities/model/entity.model.interface.js +61 -0
- package/dist/src/entities/model/leave.entity.model.js +1 -1
- package/dist/src/entities/model/project.entity.model.js +1 -0
- package/dist/src/entities/model/reimbursement.entity.model.d.ts +5 -1
- package/dist/src/entities/model/reimbursement.entity.model.js +14 -1
- package/dist/src/entities/model/vendor.entity.model.d.ts +6 -4
- package/dist/src/entities/model/vendor.entity.model.js +7 -16
- package/dist/src/entities/model/vendor_invoice_item.entity.model.autocode.js +0 -40
- package/dist/src/entities/model/vendor_invoice_item.entity.model.d.ts +15 -24
- package/dist/src/entities/model/vendor_invoice_item.entity.model.js +5 -44
- package/dist/src/utils/entity.flow.util.d.ts +40 -40
- package/dist/src/utils/helper.fn.util.d.ts +5 -0
- package/dist/src/utils/helper.fn.util.js +8 -0
- package/dist/src/utils/models/date-code.model.util.d.ts +8 -0
- package/dist/src/utils/models/date-code.model.util.js +24 -0
- package/package.json +41 -41
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
# law-common
|
|
1
|
+
# law-common
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import {
|
|
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 =
|
|
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?:
|
|
37
|
-
// bankDetail?:
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
|
9
|
-
* @template
|
|
10
|
-
* @template
|
|
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<
|
|
31
|
-
[key in
|
|
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
|
|
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
|
|
43
|
-
* @template
|
|
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<
|
|
61
|
+
export interface IFlowConfigActionConfig<S extends string, T> {
|
|
62
62
|
permissions: string[];
|
|
63
|
-
next: (data
|
|
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
|
|
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: (
|
|
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: (
|
|
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: (
|
|
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: (
|
|
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: (
|
|
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: (
|
|
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: (
|
|
39
|
+
next: () => vendor_status_enum_1.VendorStatusEnum.RESOLVED_REJECTED,
|
|
40
40
|
},
|
|
41
41
|
// [VendorActionEnum.RECALL]: {
|
|
42
42
|
// permissions: ["VENDOR_UPDATE"],
|
|
43
|
-
// next: (
|
|
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: (
|
|
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: (
|
|
55
|
+
next: () => vendor_status_enum_1.VendorStatusEnum.RESOLVED_REJECTED,
|
|
56
56
|
},
|
|
57
57
|
// [VendorActionEnum.RECALL]: {
|
|
58
58
|
// permissions: ["VENDOR_UPDATE"],
|
|
59
|
-
// next: (
|
|
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: (
|
|
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: (
|
|
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: (
|
|
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: (
|
|
83
|
+
next: () => vendor_status_enum_1.VendorStatusEnum.DELETE_APPROVAL,
|
|
84
84
|
},
|
|
85
85
|
},
|
|
86
86
|
},
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BillingProfileName } from "../enums/billing_profile.enum";
|
|
2
2
|
import { BillingProfileCode } from "../enums/billing_profile_code.enum";
|
|
3
3
|
import { IEntityAuditColumn } from "./entity-audit-columns.interface";
|
|
4
|
+
import { EntityEnum, EnumEntityType, IEntityFilterData } from "./entity.utils.interface";
|
|
4
5
|
export interface IBillingProfileEntity extends IEntityAuditColumn {
|
|
5
6
|
id: number;
|
|
6
7
|
name: BillingProfileName;
|
|
@@ -8,3 +9,5 @@ export interface IBillingProfileEntity extends IEntityAuditColumn {
|
|
|
8
9
|
pan: string;
|
|
9
10
|
code: BillingProfileCode;
|
|
10
11
|
}
|
|
12
|
+
export interface IBillingProfileEntityFilterData extends IEntityFilterData<EnumEntityType<EntityEnum.BILLING_PROFILE>> {
|
|
13
|
+
}
|
|
@@ -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:
|
|
373
|
-
oldValue:
|
|
372
|
+
newValue: string | number;
|
|
373
|
+
oldValue: string | number;
|
|
374
374
|
timeStamp: number;
|
|
375
375
|
};
|
|
376
376
|
export declare enum VirtualEntityEnum {
|
|
@@ -33,6 +33,7 @@ export declare class BillingEntityModel extends BaseEntityModel<EntityEnum.BILLI
|
|
|
33
33
|
projectId: number;
|
|
34
34
|
totalAmount: number;
|
|
35
35
|
totalMinutes: number;
|
|
36
|
+
inrAmount: number;
|
|
36
37
|
draftInvoiceNumber: string;
|
|
37
38
|
invoiceNumber: Nullable<string>;
|
|
38
39
|
paymentStatus: PaymentStatusEnum;
|
|
@@ -109,6 +110,7 @@ export declare class BillingEntityModel extends BaseEntityModel<EntityEnum.BILLI
|
|
|
109
110
|
validateAdvanceBillingId(adjustedBillingTransactions: IBillingTransactionEntity[]): void;
|
|
110
111
|
getApprovedBillingTransactionsTotalAmount(): number;
|
|
111
112
|
getCurrentBillingBillingProfile(billingProfiles: BillingProfileEntityModel[]): BillingProfileEntityModel[];
|
|
113
|
+
static getLatestBillingEntityModel(billingEntityModels: BillingEntityModel[]): BillingEntityModel | void;
|
|
112
114
|
static getNextInvoiceNumber(params: {
|
|
113
115
|
type: BillingInvoiceNumberPrefixEnum;
|
|
114
116
|
invoiceDate: Date;
|
|
@@ -27,6 +27,7 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
27
27
|
this.projectId = 0;
|
|
28
28
|
this.totalAmount = 0;
|
|
29
29
|
this.totalMinutes = 0;
|
|
30
|
+
this.inrAmount = 0;
|
|
30
31
|
this.draftInvoiceNumber = "";
|
|
31
32
|
this.invoiceNumber = null;
|
|
32
33
|
this.paymentStatus = payment_status_enum_1.PaymentStatusEnum.PENDING;
|
|
@@ -284,6 +285,11 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
284
285
|
const billingParticularsOfCurrentBilling = JSON.parse(this.particulars);
|
|
285
286
|
return billingProfiles.filter((profile) => profile.name === billingParticularsOfCurrentBilling.name);
|
|
286
287
|
}
|
|
288
|
+
static getLatestBillingEntityModel(billingEntityModels) {
|
|
289
|
+
if (billingEntityModels.length === 0)
|
|
290
|
+
return;
|
|
291
|
+
return billingEntityModels.sort((a, b) => b.invoiceDate - a.invoiceDate)[0];
|
|
292
|
+
}
|
|
287
293
|
static getNextInvoiceNumber(params) {
|
|
288
294
|
// Draft numbers never use FY-based logic
|
|
289
295
|
if (params.type === invoice_number_prefix_enum_1.BillingInvoiceNumberPrefixEnum.DRAFT) {
|
|
@@ -51,4 +51,8 @@ export declare class EntityModelRelationHelper {
|
|
|
51
51
|
key: keyof EnumToModel<T>;
|
|
52
52
|
value: any;
|
|
53
53
|
}): EnumToModel<T>[];
|
|
54
|
+
private mergeMapFrom;
|
|
55
|
+
mergeHelperFrom(other: EntityModelRelationHelper, config?: {
|
|
56
|
+
populateRelations?: boolean;
|
|
57
|
+
}): EntityModelRelationHelper;
|
|
54
58
|
}
|
|
@@ -376,5 +376,66 @@ class EntityModelRelationHelper {
|
|
|
376
376
|
const entityModels = Object.values(this.entityModelIndexMap[entityEnum] || {});
|
|
377
377
|
return entityModels.filter((model) => model[filter.key] === filter.value).map((model) => model);
|
|
378
378
|
}
|
|
379
|
+
mergeMapFrom(thisCollection, otherCollection) {
|
|
380
|
+
// Normalize both to index map regardless of whether input is array or object
|
|
381
|
+
const thisIndex = Array.isArray(thisCollection)
|
|
382
|
+
? thisCollection.reduce((acc, entity) => {
|
|
383
|
+
acc[entity.id] = entity;
|
|
384
|
+
return acc;
|
|
385
|
+
}, {})
|
|
386
|
+
: Object.assign({}, thisCollection);
|
|
387
|
+
const otherIndex = Array.isArray(otherCollection)
|
|
388
|
+
? otherCollection.reduce((acc, entity) => {
|
|
389
|
+
acc[entity.id] = entity;
|
|
390
|
+
return acc;
|
|
391
|
+
}, {})
|
|
392
|
+
: Object.assign({}, otherCollection);
|
|
393
|
+
for (const id in otherIndex) {
|
|
394
|
+
const numericId = Number(id);
|
|
395
|
+
if (numericId in thisIndex) {
|
|
396
|
+
// ID exists in both — Object.assign mutates existing instance in place
|
|
397
|
+
// preserves prototype chain & fields not present in other (partial DB calls)
|
|
398
|
+
Object.assign(thisIndex[numericId], otherIndex[numericId]);
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
thisIndex[numericId] = otherIndex[numericId];
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
// Return in same shape as input — array if input was array, index map if input was object
|
|
405
|
+
return Array.isArray(thisCollection) ? Object.values(thisIndex) : thisIndex;
|
|
406
|
+
}
|
|
407
|
+
mergeHelperFrom(other, config = { populateRelations: false }) {
|
|
408
|
+
for (const entityEnum in other.entityModelIndexMap) {
|
|
409
|
+
// @ts-ignore
|
|
410
|
+
this.entityMap[entityEnum] = this.mergeMapFrom(
|
|
411
|
+
// @ts-ignore
|
|
412
|
+
this.entityMap[entityEnum] || [], other.entityMap[entityEnum] || []);
|
|
413
|
+
// @ts-ignore
|
|
414
|
+
this.entityModelMap[entityEnum] = this.mergeMapFrom(
|
|
415
|
+
// @ts-ignore
|
|
416
|
+
this.entityModelMap[entityEnum] || [], other.entityModelMap[entityEnum] || []);
|
|
417
|
+
// @ts-ignore
|
|
418
|
+
this.entityModelIndexMap[entityEnum] = this.mergeMapFrom(
|
|
419
|
+
// @ts-ignore
|
|
420
|
+
this.entityModelIndexMap[entityEnum] || {}, other.entityModelIndexMap[entityEnum] || {});
|
|
421
|
+
}
|
|
422
|
+
if (config.populateRelations) {
|
|
423
|
+
// Re-populate other's entity types — their relations are stale since
|
|
424
|
+
// they were wired against other's index map, not the merged one
|
|
425
|
+
for (const entityEnum in other.entityModelIndexMap) {
|
|
426
|
+
this.populateRelationsByEntityEnum(entityEnum);
|
|
427
|
+
}
|
|
428
|
+
// Re-populate this's entity types as well — because other may have introduced
|
|
429
|
+
// new entities (e.g. a user, a project) that this's models were referencing
|
|
430
|
+
// but couldn't resolve before the merge
|
|
431
|
+
for (const entityEnum in this.entityModelIndexMap) {
|
|
432
|
+
// Skip entity types already re-populated from other's pass above
|
|
433
|
+
if (entityEnum in other.entityModelIndexMap)
|
|
434
|
+
continue;
|
|
435
|
+
this.populateRelationsByEntityEnum(entityEnum);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
return EntityModelRelationHelper.getClone(this);
|
|
439
|
+
}
|
|
379
440
|
}
|
|
380
441
|
exports.EntityModelRelationHelper = EntityModelRelationHelper;
|
|
@@ -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) {
|
|
@@ -48,6 +48,7 @@ class ProjectEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
48
48
|
result.updatedOn = entity.updatedOn;
|
|
49
49
|
result.billingOverdueDays = entity.billingOverdueDays;
|
|
50
50
|
result.billToClientAffiliateId = entity.billingOverdueDays;
|
|
51
|
+
result.revenueSplit = entity.revenueSplit;
|
|
51
52
|
return result;
|
|
52
53
|
}
|
|
53
54
|
populateUsers(users, projectUserMapping) {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ReimbursementBillingPresentEnum, ReimbursementBillingTypeEnum, ReimbursementIncurredByEnum, ReimbursementPaymentStatusEnum, ReimbursementStatusEnum } from "../enums/reimbursement.entity.enum";
|
|
2
2
|
import { EntityEnum } from "../interface/entity.utils.interface";
|
|
3
3
|
import { IReimbursementEntity } from "../interface/reimbursement.entity.interface";
|
|
4
|
+
import { RelationConfigs } from "../interface/relation-config.interface";
|
|
4
5
|
import { BaseEntityModel } from "./base.entity.model";
|
|
6
|
+
import { ReimbursementExpenseEntityModel } from "./reimbursement-expense.entity.model";
|
|
5
7
|
export declare class ReimbursementEntityModel extends BaseEntityModel<EntityEnum.REIMBURSEMENT> implements IReimbursementEntity {
|
|
6
8
|
id: number;
|
|
7
9
|
billingType: ReimbursementBillingTypeEnum;
|
|
@@ -22,11 +24,13 @@ export declare class ReimbursementEntityModel extends BaseEntityModel<EntityEnum
|
|
|
22
24
|
disbursementDate?: string;
|
|
23
25
|
referenceNo?: string;
|
|
24
26
|
bankId?: number;
|
|
27
|
+
incurredByUserId: number;
|
|
25
28
|
createdBy: number;
|
|
26
29
|
updatedBy: number;
|
|
27
30
|
createdOn: number;
|
|
28
31
|
updatedOn: number;
|
|
29
|
-
|
|
32
|
+
reimbursementExpenses?: ReimbursementExpenseEntityModel[];
|
|
33
|
+
static relationConfigs: RelationConfigs<[EntityEnum.REIMBURSEMENT_EXPENSE], EntityEnum.REIMBURSEMENT>;
|
|
30
34
|
getRelationConfigs(): any[];
|
|
31
35
|
static fromEntity(entity: IReimbursementEntity): ReimbursementEntityModel;
|
|
32
36
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ReimbursementEntityModel = void 0;
|
|
4
4
|
const reimbursement_entity_enum_1 = require("../enums/reimbursement.entity.enum");
|
|
5
|
+
const relation_type_enum_1 = require("../enums/relation-type.enum");
|
|
5
6
|
const entity_utils_interface_1 = require("../interface/entity.utils.interface");
|
|
6
7
|
const base_entity_model_1 = require("./base.entity.model");
|
|
7
8
|
class ReimbursementEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
@@ -16,10 +17,12 @@ class ReimbursementEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
16
17
|
this.description = "";
|
|
17
18
|
this.status = reimbursement_entity_enum_1.ReimbursementStatusEnum.APPROVAL_PENDING;
|
|
18
19
|
this.paymentStatus = reimbursement_entity_enum_1.ReimbursementPaymentStatusEnum.UNPAID;
|
|
20
|
+
this.incurredByUserId = 0;
|
|
19
21
|
this.createdBy = 0;
|
|
20
22
|
this.updatedBy = 0;
|
|
21
23
|
this.createdOn = 0;
|
|
22
24
|
this.updatedOn = 0;
|
|
25
|
+
this.reimbursementExpenses = [];
|
|
23
26
|
}
|
|
24
27
|
getRelationConfigs() {
|
|
25
28
|
return this.constructor.prototype.constructor.relationConfigs || [];
|
|
@@ -31,4 +34,14 @@ class ReimbursementEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
31
34
|
}
|
|
32
35
|
}
|
|
33
36
|
exports.ReimbursementEntityModel = ReimbursementEntityModel;
|
|
34
|
-
ReimbursementEntityModel.relationConfigs = [
|
|
37
|
+
ReimbursementEntityModel.relationConfigs = [
|
|
38
|
+
{
|
|
39
|
+
name: entity_utils_interface_1.EntityEnum.REIMBURSEMENT_EXPENSE,
|
|
40
|
+
relation: relation_type_enum_1.RelationType.MANY,
|
|
41
|
+
key: "reimbursementExpenses",
|
|
42
|
+
mapKeyConfig: {
|
|
43
|
+
relationKey: "reimbursementId",
|
|
44
|
+
key: "id",
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
];
|
|
@@ -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 {
|
|
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
|
|
65
|
+
static relationConfigs: RelationConfigs<[EntityEnum.STATE], EntityEnum.VENDOR>;
|
|
66
66
|
static fromEntity(entity: IVendorEntity): VendorEntityModel;
|
|
67
67
|
getRelationConfigs(): any[];
|
|
68
|
-
getNextStatus(currentUser: IUserEntity,
|
|
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,
|
|
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 (!
|
|
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(
|
|
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 {
|
|
6
|
-
import {
|
|
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 {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
[
|
|
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,
|
|
76
|
+
export declare class EntityActionFlowResolver<E extends EntityEnum, S extends string, A extends string> {
|
|
77
77
|
getPermittedActions(entityFlowConfig: {
|
|
78
|
-
[key in
|
|
78
|
+
[key in S]?: {
|
|
79
79
|
actions: {
|
|
80
|
-
[key in
|
|
80
|
+
[key in A]?: {
|
|
81
81
|
permissions: string[];
|
|
82
|
-
next: (
|
|
82
|
+
next: () => S;
|
|
83
83
|
};
|
|
84
84
|
};
|
|
85
85
|
};
|
|
86
|
-
}, currentStatus:
|
|
86
|
+
}, currentStatus: S | null, userPermissions: string[], data?: (a: E) => {
|
|
87
87
|
[key: string]: () => boolean;
|
|
88
|
-
}):
|
|
88
|
+
}): A[];
|
|
89
89
|
_getPermittedActions(actionConfig: {
|
|
90
|
-
[key in
|
|
90
|
+
[key in A]?: {
|
|
91
91
|
permissions: string[];
|
|
92
|
-
next: (
|
|
92
|
+
next: () => S;
|
|
93
93
|
};
|
|
94
94
|
}, userPermissions: string[], data: (a: E) => {
|
|
95
95
|
[key: string]: () => boolean;
|
|
96
|
-
}): (
|
|
97
|
-
combinePermittedActions(permittedActions: readonly
|
|
98
|
-
combineActions: readonly
|
|
96
|
+
}): (A | string)[];
|
|
97
|
+
combinePermittedActions(permittedActions: readonly A[], combinedActions?: Record<string, {
|
|
98
|
+
combineActions: readonly A[];
|
|
99
99
|
label: string;
|
|
100
|
-
}>): Map<
|
|
101
|
-
applyActionLabels(result: Map<
|
|
102
|
-
getAvailableActionsLabelValue(availableActionsFromModel: Map<
|
|
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<
|
|
108
|
-
currentStatus:
|
|
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
|
|
114
|
+
combineActions: readonly A[];
|
|
115
115
|
label: string;
|
|
116
116
|
}>;
|
|
117
|
-
customLabels?: Partial<Record<
|
|
117
|
+
customLabels?: Partial<Record<A, string>>;
|
|
118
118
|
}): IRowActions<E>[];
|
|
119
119
|
}
|
|
120
120
|
export declare class EntityActionFlowResolverV2 {
|
|
121
|
-
static getPermittedActions<E extends EntityEnum,
|
|
122
|
-
[key in
|
|
121
|
+
static getPermittedActions<E extends EntityEnum, S extends string, A extends string>(entityFlowConfig: {
|
|
122
|
+
[key in S]?: {
|
|
123
123
|
actions: {
|
|
124
|
-
[key in
|
|
124
|
+
[key in A]?: {
|
|
125
125
|
permissions: string[];
|
|
126
|
-
next: (
|
|
126
|
+
next: () => S;
|
|
127
127
|
};
|
|
128
128
|
};
|
|
129
129
|
};
|
|
130
|
-
}, currentStatus:
|
|
130
|
+
}, currentStatus: S | null, userPermissions: string[], data?: (a: E) => {
|
|
131
131
|
[key: string]: () => boolean;
|
|
132
|
-
}):
|
|
133
|
-
static _getPermittedActions<E extends EntityEnum,
|
|
134
|
-
[key in
|
|
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: (
|
|
136
|
+
next: () => S;
|
|
137
137
|
};
|
|
138
138
|
}, userPermissions: string[], data: (a: E) => {
|
|
139
|
-
[
|
|
140
|
-
}): (
|
|
141
|
-
static combinePermittedActions<
|
|
142
|
-
combineActions: readonly
|
|
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<
|
|
145
|
-
static applyActionLabels<
|
|
146
|
-
static getAvailableActionsLabelValue<
|
|
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,
|
|
151
|
-
flowConfig: FlowConfig<
|
|
152
|
-
currentStatus:
|
|
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
|
|
158
|
+
combineActions: readonly A[];
|
|
159
159
|
label: string;
|
|
160
160
|
}>;
|
|
161
|
-
customLabels?: Partial<Record<
|
|
161
|
+
customLabels?: Partial<Record<A, string>>;
|
|
162
162
|
}): IRowActions<E>[];
|
|
163
163
|
}
|
|
@@ -437,3 +437,8 @@ export declare function sumNormalised<T>(input: T[], key: keyof T): number;
|
|
|
437
437
|
*/
|
|
438
438
|
export declare function isDefined<T>(value: T | null | undefined): value is T;
|
|
439
439
|
export declare function removeDuplicatesByKey<T, K extends keyof T>(items: T[], key: K): T[];
|
|
440
|
+
/**
|
|
441
|
+
* Extracts unique values from an array of objects by key.
|
|
442
|
+
* Preserves the exact type of the key (string[] or number[]).
|
|
443
|
+
*/
|
|
444
|
+
export declare function getUniqueValuesByKey<T, K extends keyof T>(items: T[], key: K): T[K][];
|
|
@@ -47,6 +47,7 @@ exports.getNormalisedFromKey = getNormalisedFromKey;
|
|
|
47
47
|
exports.sumNormalised = sumNormalised;
|
|
48
48
|
exports.isDefined = isDefined;
|
|
49
49
|
exports.removeDuplicatesByKey = removeDuplicatesByKey;
|
|
50
|
+
exports.getUniqueValuesByKey = getUniqueValuesByKey;
|
|
50
51
|
const date_fns_1 = require("date-fns");
|
|
51
52
|
const lodash_1 = require("lodash");
|
|
52
53
|
const util_constants_1 = require("../constants/util.constants");
|
|
@@ -802,3 +803,10 @@ function removeDuplicatesByKey(items, key) {
|
|
|
802
803
|
}
|
|
803
804
|
return Array.from(map.values());
|
|
804
805
|
}
|
|
806
|
+
/**
|
|
807
|
+
* Extracts unique values from an array of objects by key.
|
|
808
|
+
* Preserves the exact type of the key (string[] or number[]).
|
|
809
|
+
*/
|
|
810
|
+
function getUniqueValuesByKey(items, key) {
|
|
811
|
+
return [...new Set(items.map((item) => item[key]))];
|
|
812
|
+
}
|
|
@@ -75,4 +75,12 @@ export declare class DateCodeModel {
|
|
|
75
75
|
* // equivalent to: new DateCodeModel(DateCodeModel.fromDate(new Date('2025-01-01')))
|
|
76
76
|
*/
|
|
77
77
|
static fromDateObject(date: Date): DateCodeModel;
|
|
78
|
+
/**
|
|
79
|
+
* Returns the earliest (min) and latest (max) dateCodes (YYYYMMDD) from a list.
|
|
80
|
+
* Accepts string | undefined | DateCodeModel and normalizes internally.
|
|
81
|
+
*/
|
|
82
|
+
static getMinMax(dateCodes: (string | undefined | DateCodeModel)[]): {
|
|
83
|
+
min: string | null;
|
|
84
|
+
max: string | null;
|
|
85
|
+
};
|
|
78
86
|
}
|
|
@@ -330,5 +330,29 @@ class DateCodeModel {
|
|
|
330
330
|
static fromDateObject(date) {
|
|
331
331
|
return new DateCodeModel(DateCodeModel.fromDate(date));
|
|
332
332
|
}
|
|
333
|
+
/**
|
|
334
|
+
* Returns the earliest (min) and latest (max) dateCodes (YYYYMMDD) from a list.
|
|
335
|
+
* Accepts string | undefined | DateCodeModel and normalizes internally.
|
|
336
|
+
*/
|
|
337
|
+
static getMinMax(dateCodes) {
|
|
338
|
+
if (!dateCodes || dateCodes.length === 0) {
|
|
339
|
+
return { min: null, max: null };
|
|
340
|
+
}
|
|
341
|
+
const models = dateCodes.filter((d) => d != null).map((d) => (d instanceof DateCodeModel ? d : new DateCodeModel(d)));
|
|
342
|
+
if (models.length === 0) {
|
|
343
|
+
return { min: null, max: null };
|
|
344
|
+
}
|
|
345
|
+
let min = models[0];
|
|
346
|
+
let max = models[0];
|
|
347
|
+
for (const current of models) {
|
|
348
|
+
if (current.dateCode < min.dateCode) {
|
|
349
|
+
min = current;
|
|
350
|
+
}
|
|
351
|
+
if (current.dateCode > max.dateCode) {
|
|
352
|
+
max = current;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return { min: min.dateCode, max: max.dateCode };
|
|
356
|
+
}
|
|
333
357
|
}
|
|
334
358
|
exports.DateCodeModel = DateCodeModel;
|
package/package.json
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "law-common",
|
|
3
|
-
"version": "10.72.1-beta.
|
|
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.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
|
+
}
|