law-common 12.8.0 → 12.8.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/README.md +1 -1
  2. package/dist/src/api/index.d.ts +2 -2
  3. package/dist/src/api/index.js +2 -2
  4. package/dist/src/api/interface/office_location.create.dto.interface.d.ts +5 -0
  5. package/dist/src/api/interface/office_location.update.dto.interface.d.ts +17 -0
  6. package/dist/src/api/interface/office_location.update.dto.interface.js +18 -0
  7. package/dist/src/entities/enums/office_location_status_enum.d.ts +5 -0
  8. package/dist/src/entities/enums/office_location_status_enum.js +9 -0
  9. package/dist/src/entities/flow-configs/office_location_flow.config.d.ts +6 -0
  10. package/dist/src/entities/flow-configs/office_location_flow.config.js +70 -0
  11. package/dist/src/entities/index.d.ts +3 -1
  12. package/dist/src/entities/index.js +3 -1
  13. package/dist/src/entities/interface/entity.utils.interface.d.ts +1 -1
  14. package/dist/src/entities/interface/field-constraint/office_location_field_constraints.interface.d.ts +13 -0
  15. package/dist/src/entities/interface/field-constraint/office_location_field_constraints.interface.js +21 -0
  16. package/dist/src/entities/interface/{office.location.entity.d.ts → office_location.entity.interface.d.ts} +2 -0
  17. package/dist/src/entities/model/office_location.entity.model.d.ts +74 -4
  18. package/dist/src/entities/model/office_location.entity.model.js +428 -3
  19. package/package.json +1 -1
  20. package/dist/src/api/interface/office.Location.update.dto.interface.d.ts +0 -3
  21. package/dist/src/api/interface/office.location.create.dto.interface.d.ts +0 -3
  22. package/dist/src/entities/interface/office.location.entity.js +0 -2
  23. /package/dist/src/api/interface/{office.Location.update.dto.interface.js → office_location.create.dto.interface.js} +0 -0
  24. /package/dist/src/{api/interface/office.location.create.dto.interface.js → entities/interface/office_location.entity.interface.js} +0 -0
package/README.md CHANGED
@@ -1 +1 @@
1
- # law-common
1
+ # law-common
@@ -17,9 +17,9 @@ export * from "./interface/expense_type.update.dto";
17
17
  export * from "./interface/expense_type.entity.response";
18
18
  export * from "./interface/billing.create.dto.interface";
19
19
  export * from "./interface/billing.entity.response";
20
- export * from "./interface/office.location.create.dto.interface";
20
+ export * from "./interface/office_location.create.dto.interface";
21
21
  export * from "./interface/office.location.entity.response";
22
- export * from "./interface/office.Location.update.dto.interface";
22
+ export * from "./interface/office_location.update.dto.interface";
23
23
  export * from "./interface/billing.update.dto.interface";
24
24
  export * from "./interface/moving_timesheet.create.dto.interface";
25
25
  export * from "./interface/moving_timesheet.entity.response";
@@ -33,9 +33,9 @@ __exportStar(require("./interface/expense_type.update.dto"), exports);
33
33
  __exportStar(require("./interface/expense_type.entity.response"), exports);
34
34
  __exportStar(require("./interface/billing.create.dto.interface"), exports);
35
35
  __exportStar(require("./interface/billing.entity.response"), exports);
36
- __exportStar(require("./interface/office.location.create.dto.interface"), exports);
36
+ __exportStar(require("./interface/office_location.create.dto.interface"), exports);
37
37
  __exportStar(require("./interface/office.location.entity.response"), exports);
38
- __exportStar(require("./interface/office.Location.update.dto.interface"), exports);
38
+ __exportStar(require("./interface/office_location.update.dto.interface"), exports);
39
39
  __exportStar(require("./interface/billing.update.dto.interface"), exports);
40
40
  __exportStar(require("./interface/moving_timesheet.create.dto.interface"), exports);
41
41
  __exportStar(require("./interface/moving_timesheet.entity.response"), exports);
@@ -0,0 +1,5 @@
1
+ import { IEntityCreateDto } from "../../entities";
2
+ import { IOfficeLocationEntity } from "../../entities/interface/office_location.entity.interface";
3
+ export type IOfficeLocationCreateExclude = "organizationId" | "status";
4
+ export interface IOfficeLocationCreateDto extends Omit<IEntityCreateDto<IOfficeLocationEntity>, IOfficeLocationCreateExclude> {
5
+ }
@@ -0,0 +1,17 @@
1
+ import { DeepPartialButRequired } from "./api.utils.interface";
2
+ import { IOfficeLocationCreateDto } from "./office_location.create.dto.interface";
3
+ export type IOfficeLocationUpdateDto = DeepPartialButRequired<IOfficeLocationCreateDto, never> & {
4
+ actionData: IOfficeLocationActionDataDto;
5
+ };
6
+ export interface IOfficeLocationActionDataDto {
7
+ action: OfficeLocationActionEnum;
8
+ remark?: string;
9
+ }
10
+ export declare enum OfficeLocationActionEnum {
11
+ CREATE = "create",
12
+ UPDATE = "update",
13
+ DELETE = "delete",
14
+ DEACTIVATE = "deactivate",
15
+ ACTIVATE = "activate",
16
+ RESTORE = "restore"
17
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OfficeLocationActionEnum = void 0;
4
+ var OfficeLocationActionEnum;
5
+ (function (OfficeLocationActionEnum) {
6
+ OfficeLocationActionEnum["CREATE"] = "create";
7
+ OfficeLocationActionEnum["UPDATE"] = "update";
8
+ OfficeLocationActionEnum["DELETE"] = "delete";
9
+ OfficeLocationActionEnum["DEACTIVATE"] = "deactivate";
10
+ OfficeLocationActionEnum["ACTIVATE"] = "activate";
11
+ OfficeLocationActionEnum["RESTORE"] = "restore";
12
+ // The following actions are for entity flow with approval process. Comment out if entity is automatically approved without approval process.
13
+ // REQUEST_CHANGES = "request_changes",
14
+ // REJECT = "reject",
15
+ // RECALL = "recall",
16
+ // APPROVE = "approve",
17
+ // CHANGES_DONE = "changes_done",
18
+ })(OfficeLocationActionEnum || (exports.OfficeLocationActionEnum = OfficeLocationActionEnum = {}));
@@ -0,0 +1,5 @@
1
+ export declare enum OfficeLocationStatusEnum {
2
+ APPROVED = "APPROVED",
3
+ DEACTIVATED = "DEACTIVATED",
4
+ DELETED = "DELETED"
5
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OfficeLocationStatusEnum = void 0;
4
+ var OfficeLocationStatusEnum;
5
+ (function (OfficeLocationStatusEnum) {
6
+ OfficeLocationStatusEnum["APPROVED"] = "APPROVED";
7
+ OfficeLocationStatusEnum["DEACTIVATED"] = "DEACTIVATED";
8
+ OfficeLocationStatusEnum["DELETED"] = "DELETED";
9
+ })(OfficeLocationStatusEnum || (exports.OfficeLocationStatusEnum = OfficeLocationStatusEnum = {}));
@@ -0,0 +1,6 @@
1
+ import { FlowConfig } from "./flow-config.type";
2
+ import { OfficeLocationActionEnum } from "../../api";
3
+ import { OfficeLocationStatusEnum } from "../enums/office_location_status_enum";
4
+ export interface IOfficeLocationFlowConfigContextData {
5
+ }
6
+ export declare const officeLocationFlowConfig: FlowConfig<OfficeLocationStatusEnum, OfficeLocationActionEnum, IOfficeLocationFlowConfigContextData>;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.officeLocationFlowConfig = void 0;
4
+ const base_flow_config_factory_1 = require("./base-flow-config.factory");
5
+ const api_1 = require("../../api");
6
+ const office_location_status_enum_1 = require("../enums/office_location_status_enum");
7
+ const OFFICE_LOCATION_CREATE_PERMISSION = ["OFFICE_LOCATION_CREATE"];
8
+ const OFFICE_LOCATION_UPDATE_PERMISSION = ["OFFICE_LOCATION_UPDATE"];
9
+ const OFFICE_LOCATION_DELETE_PERMISSION = ["OFFICE_LOCATION_DELETE"];
10
+ const OFFICE_LOCATION_DEACTIVATE_PERMISSION = ["OFFICE_LOCATION_DEACTIVATE"];
11
+ const OFFICE_LOCATION_ACTIVATE_PERMISSION = ["OFFICE_LOCATION_ACTIVATE"];
12
+ const OFFICE_LOCATION_RESTORE_PERMISSION = ["OFFICE_LOCATION_RESTORE"];
13
+ const ACTION_MAP = {
14
+ [api_1.OfficeLocationActionEnum.CREATE]: {
15
+ reachableStatues: [office_location_status_enum_1.OfficeLocationStatusEnum.APPROVED],
16
+ permissions: OFFICE_LOCATION_CREATE_PERMISSION,
17
+ },
18
+ [api_1.OfficeLocationActionEnum.UPDATE]: {
19
+ reachableStatues: [office_location_status_enum_1.OfficeLocationStatusEnum.APPROVED],
20
+ permissions: OFFICE_LOCATION_UPDATE_PERMISSION,
21
+ },
22
+ [api_1.OfficeLocationActionEnum.DELETE]: {
23
+ reachableStatues: [office_location_status_enum_1.OfficeLocationStatusEnum.DELETED],
24
+ permissions: OFFICE_LOCATION_DELETE_PERMISSION,
25
+ },
26
+ [api_1.OfficeLocationActionEnum.DEACTIVATE]: {
27
+ reachableStatues: [office_location_status_enum_1.OfficeLocationStatusEnum.DEACTIVATED],
28
+ permissions: OFFICE_LOCATION_DEACTIVATE_PERMISSION,
29
+ },
30
+ [api_1.OfficeLocationActionEnum.ACTIVATE]: {
31
+ reachableStatues: [office_location_status_enum_1.OfficeLocationStatusEnum.APPROVED],
32
+ permissions: OFFICE_LOCATION_ACTIVATE_PERMISSION,
33
+ },
34
+ [api_1.OfficeLocationActionEnum.RESTORE]: {
35
+ reachableStatues: [office_location_status_enum_1.OfficeLocationStatusEnum.APPROVED],
36
+ permissions: OFFICE_LOCATION_RESTORE_PERMISSION,
37
+ },
38
+ };
39
+ const { createActionConfig } = (0, base_flow_config_factory_1.createFlowConfigFactory)()(ACTION_MAP);
40
+ // APPROVED status transitions
41
+ const transitionApprovedStatusUpdateAction = createActionConfig(api_1.OfficeLocationActionEnum.UPDATE, office_location_status_enum_1.OfficeLocationStatusEnum.APPROVED);
42
+ const transitionApprovedStatusDeleteAction = createActionConfig(api_1.OfficeLocationActionEnum.DELETE, office_location_status_enum_1.OfficeLocationStatusEnum.DELETED);
43
+ const transitionApprovedStatusDeactivateAction = createActionConfig(api_1.OfficeLocationActionEnum.DEACTIVATE, office_location_status_enum_1.OfficeLocationStatusEnum.DEACTIVATED);
44
+ // DEACTIVATED status transitions
45
+ const transitionDeactivatedStatusDeleteAction = createActionConfig(api_1.OfficeLocationActionEnum.DELETE, office_location_status_enum_1.OfficeLocationStatusEnum.DELETED);
46
+ const transitionDeactivatedStatusActivateAction = createActionConfig(api_1.OfficeLocationActionEnum.ACTIVATE, office_location_status_enum_1.OfficeLocationStatusEnum.APPROVED);
47
+ // DELETED status transitions
48
+ const transitionDeletedStatusUpdateAction = createActionConfig(api_1.OfficeLocationActionEnum.UPDATE, office_location_status_enum_1.OfficeLocationStatusEnum.APPROVED);
49
+ const transitionDeletedStatusRestoreAction = createActionConfig(api_1.OfficeLocationActionEnum.RESTORE, office_location_status_enum_1.OfficeLocationStatusEnum.APPROVED);
50
+ exports.officeLocationFlowConfig = {
51
+ [office_location_status_enum_1.OfficeLocationStatusEnum.APPROVED]: {
52
+ actions: {
53
+ [api_1.OfficeLocationActionEnum.UPDATE]: transitionApprovedStatusUpdateAction,
54
+ [api_1.OfficeLocationActionEnum.DELETE]: transitionApprovedStatusDeleteAction,
55
+ [api_1.OfficeLocationActionEnum.DEACTIVATE]: transitionApprovedStatusDeactivateAction,
56
+ },
57
+ },
58
+ [office_location_status_enum_1.OfficeLocationStatusEnum.DEACTIVATED]: {
59
+ actions: {
60
+ [api_1.OfficeLocationActionEnum.DELETE]: transitionDeactivatedStatusDeleteAction,
61
+ [api_1.OfficeLocationActionEnum.ACTIVATE]: transitionDeactivatedStatusActivateAction,
62
+ },
63
+ },
64
+ [office_location_status_enum_1.OfficeLocationStatusEnum.DELETED]: {
65
+ actions: {
66
+ [api_1.OfficeLocationActionEnum.UPDATE]: transitionDeletedStatusUpdateAction,
67
+ [api_1.OfficeLocationActionEnum.RESTORE]: transitionDeletedStatusRestoreAction,
68
+ },
69
+ },
70
+ };
@@ -24,7 +24,7 @@ export * from "./enums/payment_status.enum";
24
24
  export * from "./interface/billing.entity.interface";
25
25
  export * from "./enums/billing.status.enum";
26
26
  export * from "./enums/billing.timesheet.change.status.enum";
27
- export * from "./interface/office.location.entity";
27
+ export * from "./interface/office_location.entity.interface";
28
28
  export * from "./interface/bank.entity.interface";
29
29
  export * from "./interface/client_affiliate_entity.interface";
30
30
  export * from "./interface/permission.entity.interface";
@@ -282,3 +282,5 @@ export * from "./interface/field-constraint/task_field_constraints.interface";
282
282
  export * from "./enums/designation_status_enum";
283
283
  export * from "./flow-configs/designation_flow.config";
284
284
  export * from "./interface/field-constraint/designation_field_constraints.interface";
285
+ export * from "./enums/office_location_status_enum";
286
+ export * from "./interface/field-constraint/office_location_field_constraints.interface";
@@ -40,7 +40,7 @@ __exportStar(require("./enums/payment_status.enum"), exports);
40
40
  __exportStar(require("./interface/billing.entity.interface"), exports);
41
41
  __exportStar(require("./enums/billing.status.enum"), exports);
42
42
  __exportStar(require("./enums/billing.timesheet.change.status.enum"), exports);
43
- __exportStar(require("./interface/office.location.entity"), exports);
43
+ __exportStar(require("./interface/office_location.entity.interface"), exports);
44
44
  __exportStar(require("./interface/bank.entity.interface"), exports);
45
45
  __exportStar(require("./interface/client_affiliate_entity.interface"), exports);
46
46
  __exportStar(require("./interface/permission.entity.interface"), exports);
@@ -299,3 +299,5 @@ __exportStar(require("./interface/field-constraint/task_field_constraints.interf
299
299
  __exportStar(require("./enums/designation_status_enum"), exports);
300
300
  __exportStar(require("./flow-configs/designation_flow.config"), exports);
301
301
  __exportStar(require("./interface/field-constraint/designation_field_constraints.interface"), exports);
302
+ __exportStar(require("./enums/office_location_status_enum"), exports);
303
+ __exportStar(require("./interface/field-constraint/office_location_field_constraints.interface"), exports);
@@ -120,7 +120,7 @@ import { ILeaveCountVirtualEntity, ILeaveEntity } from "./leave.entity.interface
120
120
  import { ILeaveApprovalEntity } from "./leave_approval.entity.interface";
121
121
  import { ILeaveHistoryEntity } from "./leave_history.entity.interface";
122
122
  import { IMovingTimesheetEntity } from "./moving_timesheet.entity.interface";
123
- import { IOfficeLocationEntity } from "./office.location.entity";
123
+ import { IOfficeLocationEntity } from "./office_location.entity.interface";
124
124
  import { IOrganizationEntity } from "./organization.entity.interface";
125
125
  import { IOrganizationTypeEntity } from "./organization_type.entity.interface";
126
126
  import { IOrganizationTypeTdsRateMappingEntity } from "./organization_type_tds_rate_mapping.entity.interface";
@@ -0,0 +1,13 @@
1
+ import { IEntityAuditColumn } from "../entity-audit-columns.interface";
2
+ import { IOfficeLocationEntity } from "../office_location.entity.interface";
3
+ import { IFieldMinMaxConstraint } from "./utils";
4
+ export type IOfficeLocationFieldLengthConstraintsExclude = "status" | "id" | keyof IEntityAuditColumn;
5
+ /**
6
+ * since some fields are optional, but we still need their
7
+ * min & max length constraints, we need to make them required in this type
8
+ * hence we are using -? to make all properties required in this type
9
+ */
10
+ export type IOfficeLocationFieldMinMaxConstraints = {
11
+ [K in keyof Omit<IOfficeLocationEntity, IOfficeLocationFieldLengthConstraintsExclude>]-?: IFieldMinMaxConstraint;
12
+ };
13
+ export declare const officeLocationFieldMinMaxConstraints: IOfficeLocationFieldMinMaxConstraints;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.officeLocationFieldMinMaxConstraints = void 0;
4
+ exports.officeLocationFieldMinMaxConstraints = {
5
+ name: {
6
+ min: 3,
7
+ max: 64,
8
+ },
9
+ country: {
10
+ max: 64,
11
+ },
12
+ address: {
13
+ max: 1024,
14
+ },
15
+ zipCode: {
16
+ max: 99999999,
17
+ },
18
+ organizationId: {
19
+ max: 99999999,
20
+ },
21
+ };
@@ -1,3 +1,4 @@
1
+ import { OfficeLocationStatusEnum } from "../enums/office_location_status_enum";
1
2
  import { IEntityAuditColumn } from "./entity-audit-columns.interface";
2
3
  import { IEntityFilterData } from "./entity.utils.interface";
3
4
  export interface IOfficeLocationEntity extends IEntityAuditColumn {
@@ -7,5 +8,6 @@ export interface IOfficeLocationEntity extends IEntityAuditColumn {
7
8
  zipCode: number;
8
9
  country: string;
9
10
  organizationId: number;
11
+ status: OfficeLocationStatusEnum;
10
12
  }
11
13
  export type IOfficeLocationEntityFilterData = IEntityFilterData<IOfficeLocationEntity>;
@@ -1,20 +1,90 @@
1
1
  import { EntityEnum } from "../interface/entity.utils.interface";
2
- import { BaseEntityModel } from "./base.entity.model";
3
2
  import { RelationConfigs } from "../interface/relation-config.interface";
4
- import { IOfficeLocationEntity } from "../interface/office.location.entity";
3
+ import { IUserEntity } from "../interface/user.entity.interface";
4
+ import { BaseEntityModel } from "./base.entity.model";
5
+ import { IRowActions } from "./interface/row-actions.interface";
6
+ import { UserEntityModel } from "./user.entity.model";
7
+ import { OfficeLocationActionEnum } from "../../api";
8
+ import { OfficeLocationStatusEnum } from "../enums/office_location_status_enum";
9
+ import { IOfficeLocationFlowConfigContextData } from "../flow-configs/office_location_flow.config";
10
+ import { IOfficeLocationEntity } from "../interface/office_location.entity.interface";
11
+ import { BankEntityModel } from "./bank.entity.model";
12
+ import { ClientEntityModel } from "./client.entity.model";
13
+ import { ClientAffiliateEntityModel } from "./client-affiliate.entity.model";
14
+ import { ClientDebitNoteEntityModel } from "./client_debit_note.entity.model";
15
+ import { ClientDebitNoteParticularsEntityModel } from "./client_debit_note_particulars.entity.model";
16
+ import { CountryEntityModel } from "./country.entity.model";
17
+ import { ExpenseHeadEntityModel } from "./expense_head.entity.model";
18
+ import { GstRateEntityModel } from "./gst_rate.entity.model";
19
+ import { LeaveEntityModel } from "./leave.entity.model";
20
+ import { LeaveApprovalEntityModel } from "./leave_approval.entity.model";
21
+ import { OrganizationEntityModel } from "./organization.entity.model";
22
+ import { OrganizationTypeEntityModel } from "./organization_type.entity.model";
23
+ import { ProjectEntityModel } from "./project.entity.model";
24
+ import { StateEntityModel } from "./state.entity.model";
25
+ import { TdsRateEntityModel } from "./tds_rate.entity.model";
26
+ import { ToDoListEntityModel } from "./to_do_list.entity.model";
27
+ import { VendorEntityModel } from "./vendor.entity.model";
28
+ import { VendorAdvanceEntityModel } from "./vendor_advance.entity.model";
29
+ import { VendorInvoiceEntityModel } from "./vendor_invoice.entity.model";
30
+ import { VendorInvoiceAdvanceEntityModel } from "./vendor_invoice_advance.entity.model";
31
+ import { VendorInvoiceItemEntityModel } from "./vendor_invoice_item.entity.model";
32
+ import { VendorInvoicePaymentEntityModel } from "./vendor_invoice_payment.entity.model";
33
+ import { VendorTdsChallanEntityModel } from "./vendor_tds_challan.entity.model";
34
+ import { VendorTdsLiabilityEntityModel } from "./vendor_tds_liability.entity.model";
35
+ import { VoucherTypeEntityModel } from "./voucher_type.entity.model";
36
+ import { WorkFromHomeEntityModel } from "./work-from-home.entity.model";
5
37
  export declare class OfficeLocationEntityModel extends BaseEntityModel<EntityEnum.OFFICE_LOCATION> implements IOfficeLocationEntity {
6
38
  id: number;
7
39
  name: string;
8
40
  country: string;
9
- state: string;
10
41
  address: string;
11
42
  zipCode: number;
12
43
  organizationId: number;
44
+ status: OfficeLocationStatusEnum;
13
45
  createdOn: number;
14
46
  updatedOn: number;
15
47
  createdBy: number;
16
48
  updatedBy: number;
17
- static relationConfigs: RelationConfigs<[], EntityEnum.OFFICE_LOCATION>;
49
+ organization?: OrganizationEntityModel;
50
+ vendorInvoices?: VendorInvoiceEntityModel[];
51
+ static relationConfigs: RelationConfigs<[EntityEnum.ORGANIZATION, EntityEnum.VENDOR_INVOICE], EntityEnum.OFFICE_LOCATION>;
18
52
  static fromEntity(entity: IOfficeLocationEntity): OfficeLocationEntityModel;
19
53
  getRelationConfigs(): any[];
54
+ get vendors(): VendorEntityModel[] | undefined;
55
+ get states(): StateEntityModel[] | undefined;
56
+ get countrys(): CountryEntityModel[] | undefined;
57
+ get organizationTypes(): OrganizationTypeEntityModel[] | undefined;
58
+ get tdsRates(): TdsRateEntityModel[] | undefined;
59
+ get voucherTypes(): VoucherTypeEntityModel[] | undefined;
60
+ get expenseHeads(): ExpenseHeadEntityModel[] | undefined;
61
+ get vendorInvoiceItems(): VendorInvoiceItemEntityModel[] | undefined;
62
+ get gstRates(): GstRateEntityModel[] | undefined;
63
+ get vendorAdvances(): VendorAdvanceEntityModel[] | undefined;
64
+ get vendorInvoiceAdvances(): VendorInvoiceAdvanceEntityModel[] | undefined;
65
+ get vendorTdsLiabilitys(): VendorTdsLiabilityEntityModel[] | undefined;
66
+ get vendorTdsChallans(): VendorTdsChallanEntityModel[] | undefined;
67
+ get banks(): BankEntityModel[] | undefined;
68
+ get clientDebitNotes(): ClientDebitNoteEntityModel[] | undefined;
69
+ get clients(): ClientEntityModel[] | undefined;
70
+ get users(): UserEntityModel[] | undefined;
71
+ get leaveApprovals(): LeaveApprovalEntityModel[] | undefined;
72
+ get leaves(): LeaveEntityModel[] | undefined;
73
+ get workFromHomes(): WorkFromHomeEntityModel[] | undefined;
74
+ get toDoLists(): ToDoListEntityModel[] | undefined;
75
+ get projects(): ProjectEntityModel[] | undefined;
76
+ get clientAffiliates(): ClientAffiliateEntityModel[] | undefined;
77
+ get clientDebitNoteParticularss(): ClientDebitNoteParticularsEntityModel[] | undefined;
78
+ get vendorInvoicePayments(): VendorInvoicePaymentEntityModel[] | undefined;
79
+ getNextStatus(currentUser: IUserEntity, action: OfficeLocationActionEnum, officeLocationFlowConfigContextData: IOfficeLocationFlowConfigContextData): OfficeLocationStatusEnum;
80
+ getAvailableActions(currentUser: UserEntityModel, config?: {
81
+ combinedActions?: Record<string, {
82
+ combineActions: OfficeLocationActionEnum[];
83
+ label: string;
84
+ }>;
85
+ customLabels?: Partial<Record<OfficeLocationActionEnum, string>>;
86
+ }): IRowActions<EntityEnum.OFFICE_LOCATION>[];
87
+ getUpdateActionVisibility(currentUser: UserEntityModel): {
88
+ [key: string]: () => boolean;
89
+ };
20
90
  }
@@ -1,19 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OfficeLocationEntityModel = void 0;
4
+ const error_key_enum_1 = require("../../enums/error.key.enum");
5
+ const exceptions_1 = require("../../exceptions");
6
+ const utils_1 = require("../../utils");
7
+ const relation_type_enum_1 = require("../enums/relation-type.enum");
4
8
  const entity_utils_interface_1 = require("../interface/entity.utils.interface");
5
9
  const base_entity_model_1 = require("./base.entity.model");
6
- // import { IOfficeLocationEntity } from "../interface/office_location.entity.interface";
10
+ const office_location_status_enum_1 = require("../enums/office_location_status_enum");
11
+ const office_location_flow_config_1 = require("../flow-configs/office_location_flow.config");
7
12
  class OfficeLocationEntityModel extends base_entity_model_1.BaseEntityModel {
8
13
  constructor() {
9
14
  super(...arguments);
10
15
  this.id = 0;
11
16
  this.name = "";
12
17
  this.country = "";
13
- this.state = "";
14
18
  this.address = "";
15
19
  this.zipCode = 0;
16
20
  this.organizationId = 0;
21
+ this.status = office_location_status_enum_1.OfficeLocationStatusEnum.APPROVED;
17
22
  this.createdOn = 0;
18
23
  this.updatedOn = 0;
19
24
  this.createdBy = 0;
@@ -27,6 +32,426 @@ class OfficeLocationEntityModel extends base_entity_model_1.BaseEntityModel {
27
32
  getRelationConfigs() {
28
33
  return this.constructor.prototype.constructor.relationConfigs || [];
29
34
  }
35
+ get vendors() {
36
+ // many_to_many -> many_to_many verified
37
+ // {'office_location->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor': 'many_to_one'}
38
+ // ['office_location', 'vendor_invoice'] -> one_to_many
39
+ // ['vendor_invoice', 'vendor'] -> many_to_one
40
+ var _a;
41
+ return (_a = this.vendorInvoices) === null || _a === void 0 ? void 0 : _a.flatMap((vendorInvoice) => vendorInvoice.vendor).filter((vendor) => !!vendor).reduce((accumulator, current) => {
42
+ if (!accumulator.some((vendor) => vendor.id === current.id)) {
43
+ accumulator.push(current);
44
+ }
45
+ return accumulator;
46
+ }, []);
47
+ }
48
+ get states() {
49
+ // many_to_one -> many_to_many mismatch
50
+ // {'office_location->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor': 'many_to_one', 'vendor->state': 'many_to_one'}
51
+ // ['vendor_invoice', 'vendor'] -> many_to_one
52
+ // ['vendor', 'state'] -> many_to_one
53
+ var _a;
54
+ return (_a = this.vendors) === null || _a === void 0 ? void 0 : _a.flatMap((vendor) => vendor.stateModel).filter((state) => !!state).reduce((accumulator, current) => {
55
+ if (!accumulator.some((state) => state.id === current.id)) {
56
+ accumulator.push(current);
57
+ }
58
+ return accumulator;
59
+ }, []);
60
+ }
61
+ get countrys() {
62
+ // many_to_one -> many_to_many mismatch
63
+ // {'office_location->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor': 'many_to_one', 'vendor->country': 'many_to_one'}
64
+ // ['vendor_invoice', 'vendor'] -> many_to_one
65
+ // ['vendor', 'country'] -> many_to_one
66
+ var _a;
67
+ return (_a = this.vendors) === null || _a === void 0 ? void 0 : _a.flatMap((vendor) => vendor.countryModel).filter((country) => !!country).reduce((accumulator, current) => {
68
+ if (!accumulator.some((country) => country.id === current.id)) {
69
+ accumulator.push(current);
70
+ }
71
+ return accumulator;
72
+ }, []);
73
+ }
74
+ get organizationTypes() {
75
+ // many_to_one -> many_to_many mismatch
76
+ // {'office_location->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor': 'many_to_one', 'vendor->organization_type': 'many_to_one'}
77
+ // ['vendor_invoice', 'vendor'] -> many_to_one
78
+ // ['vendor', 'organization_type'] -> many_to_one
79
+ var _a;
80
+ return (_a = this.vendors) === null || _a === void 0 ? void 0 : _a.flatMap((vendor) => vendor.organizationType).filter((organizationType) => !!organizationType).reduce((accumulator, current) => {
81
+ if (!accumulator.some((organizationType) => organizationType.id === current.id)) {
82
+ accumulator.push(current);
83
+ }
84
+ return accumulator;
85
+ }, []);
86
+ }
87
+ get tdsRates() {
88
+ // many_to_many -> many_to_many verified
89
+ // {'office_location->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor': 'many_to_one', 'vendor->organization_type': 'many_to_one', 'organization_type->tds_rate': 'many_to_many'}
90
+ // ['vendor', 'organization_type'] -> many_to_one
91
+ // ['organization_type', 'tds_rate'] -> many_to_many
92
+ var _a;
93
+ return (_a = this.organizationTypes) === null || _a === void 0 ? void 0 : _a.flatMap((organizationType) => organizationType.tdsRates).filter((tdsRate) => !!tdsRate).reduce((accumulator, current) => {
94
+ if (!accumulator.some((tdsRate) => tdsRate.id === current.id)) {
95
+ accumulator.push(current);
96
+ }
97
+ return accumulator;
98
+ }, []);
99
+ }
100
+ get voucherTypes() {
101
+ // many_to_many -> many_to_many verified
102
+ // {'office_location->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor_invoice_item': 'one_to_many', 'vendor_invoice_item->voucher_type': 'many_to_one'}
103
+ // ['vendor_invoice', 'vendor_invoice_item'] -> one_to_many
104
+ // ['vendor_invoice_item', 'voucher_type'] -> many_to_one
105
+ var _a;
106
+ return (_a = this.vendorInvoiceItems) === null || _a === void 0 ? void 0 : _a.flatMap((vendorInvoiceItem) => vendorInvoiceItem.voucherType).filter((voucherType) => !!voucherType).reduce((accumulator, current) => {
107
+ if (!accumulator.some((voucherType) => voucherType.id === current.id)) {
108
+ accumulator.push(current);
109
+ }
110
+ return accumulator;
111
+ }, []);
112
+ }
113
+ get expenseHeads() {
114
+ // many_to_many -> many_to_many verified
115
+ // {'office_location->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor_invoice_item': 'one_to_many', 'vendor_invoice_item->expense_head': 'many_to_one'}
116
+ // ['vendor_invoice', 'vendor_invoice_item'] -> one_to_many
117
+ // ['vendor_invoice_item', 'expense_head'] -> many_to_one
118
+ var _a;
119
+ return (_a = this.vendorInvoiceItems) === null || _a === void 0 ? void 0 : _a.flatMap((vendorInvoiceItem) => vendorInvoiceItem.expenseHead).filter((expenseHead) => !!expenseHead).reduce((accumulator, current) => {
120
+ if (!accumulator.some((expenseHead) => expenseHead.id === current.id)) {
121
+ accumulator.push(current);
122
+ }
123
+ return accumulator;
124
+ }, []);
125
+ }
126
+ get vendorInvoiceItems() {
127
+ // one_to_many -> one_to_many verified
128
+ // {'office_location->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor_invoice_item': 'one_to_many'}
129
+ // ['office_location', 'vendor_invoice'] -> one_to_many
130
+ // ['vendor_invoice', 'vendor_invoice_item'] -> one_to_many
131
+ var _a;
132
+ return (_a = this.vendorInvoices) === null || _a === void 0 ? void 0 : _a.flatMap((vendorInvoice) => vendorInvoice.vendorInvoiceItems).filter((vendorInvoiceItem) => !!vendorInvoiceItem).reduce((accumulator, current) => {
133
+ if (!accumulator.some((vendorInvoiceItem) => vendorInvoiceItem.id === current.id)) {
134
+ accumulator.push(current);
135
+ }
136
+ return accumulator;
137
+ }, []);
138
+ }
139
+ get gstRates() {
140
+ // many_to_many -> many_to_many verified
141
+ // {'office_location->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor_invoice_item': 'one_to_many', 'vendor_invoice_item->gst_rate': 'many_to_one'}
142
+ // ['vendor_invoice', 'vendor_invoice_item'] -> one_to_many
143
+ // ['vendor_invoice_item', 'gst_rate'] -> many_to_one
144
+ var _a;
145
+ return (_a = this.vendorInvoiceItems) === null || _a === void 0 ? void 0 : _a.flatMap((vendorInvoiceItem) => vendorInvoiceItem.gstRate).filter((gstRate) => !!gstRate).reduce((accumulator, current) => {
146
+ if (!accumulator.some((gstRate) => gstRate.id === current.id)) {
147
+ accumulator.push(current);
148
+ }
149
+ return accumulator;
150
+ }, []);
151
+ }
152
+ get vendorAdvances() {
153
+ // many_to_many -> many_to_many verified
154
+ // {'office_location->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor': 'many_to_one', 'vendor->vendor_advance': 'one_to_many'}
155
+ // ['vendor_invoice', 'vendor'] -> many_to_one
156
+ // ['vendor', 'vendor_advance'] -> one_to_many
157
+ var _a;
158
+ return (_a = this.vendors) === null || _a === void 0 ? void 0 : _a.flatMap((vendor) => vendor.vendorAdvances).filter((vendorAdvance) => !!vendorAdvance).reduce((accumulator, current) => {
159
+ if (!accumulator.some((vendorAdvance) => vendorAdvance.id === current.id)) {
160
+ accumulator.push(current);
161
+ }
162
+ return accumulator;
163
+ }, []);
164
+ }
165
+ get vendorInvoiceAdvances() {
166
+ // many_to_many -> many_to_many verified
167
+ // {'office_location->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor': 'many_to_one', 'vendor->vendor_invoice_advance': 'one_to_many'}
168
+ // ['vendor_invoice', 'vendor'] -> many_to_one
169
+ // ['vendor', 'vendor_invoice_advance'] -> one_to_many
170
+ var _a;
171
+ return (_a = this.vendors) === null || _a === void 0 ? void 0 : _a.flatMap((vendor) => vendor.vendorInvoiceAdvances).filter((vendorInvoiceAdvance) => !!vendorInvoiceAdvance).reduce((accumulator, current) => {
172
+ if (!accumulator.some((vendorInvoiceAdvance) => vendorInvoiceAdvance.id === current.id)) {
173
+ accumulator.push(current);
174
+ }
175
+ return accumulator;
176
+ }, []);
177
+ }
178
+ get vendorTdsLiabilitys() {
179
+ // many_to_many -> many_to_many verified
180
+ // {'office_location->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor': 'many_to_one', 'vendor->organization_type': 'many_to_one', 'organization_type->tds_rate': 'many_to_many', 'tds_rate->vendor_tds_liability': 'one_to_many'}
181
+ // ['organization_type', 'tds_rate'] -> many_to_many
182
+ // ['tds_rate', 'vendor_tds_liability'] -> one_to_many
183
+ var _a;
184
+ return (_a = this.tdsRates) === null || _a === void 0 ? void 0 : _a.flatMap((tdsRate) => tdsRate.vendorTdsLiabilitys).filter((vendorTdsLiability) => !!vendorTdsLiability).reduce((accumulator, current) => {
185
+ if (!accumulator.some((vendorTdsLiability) => vendorTdsLiability.id === current.id)) {
186
+ accumulator.push(current);
187
+ }
188
+ return accumulator;
189
+ }, []);
190
+ }
191
+ get vendorTdsChallans() {
192
+ // many_to_many -> many_to_many verified
193
+ // {'office_location->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor': 'many_to_one', 'vendor->organization_type': 'many_to_one', 'organization_type->tds_rate': 'many_to_many', 'tds_rate->vendor_tds_challan': 'one_to_many'}
194
+ // ['organization_type', 'tds_rate'] -> many_to_many
195
+ // ['tds_rate', 'vendor_tds_challan'] -> one_to_many
196
+ var _a;
197
+ return (_a = this.tdsRates) === null || _a === void 0 ? void 0 : _a.flatMap((tdsRate) => tdsRate.vendorTdsChallans).filter((vendorTdsChallan) => !!vendorTdsChallan).reduce((accumulator, current) => {
198
+ if (!accumulator.some((vendorTdsChallan) => vendorTdsChallan.id === current.id)) {
199
+ accumulator.push(current);
200
+ }
201
+ return accumulator;
202
+ }, []);
203
+ }
204
+ get banks() {
205
+ // many_to_many -> many_to_many verified
206
+ // {'office_location->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor': 'many_to_one', 'vendor->organization_type': 'many_to_one', 'organization_type->tds_rate': 'many_to_many', 'tds_rate->vendor_tds_challan': 'one_to_many', 'vendor_tds_challan->bank': 'many_to_one'}
207
+ // ['tds_rate', 'vendor_tds_challan'] -> one_to_many
208
+ // ['vendor_tds_challan', 'bank'] -> many_to_one
209
+ var _a;
210
+ return (_a = this.vendorTdsChallans) === null || _a === void 0 ? void 0 : _a.flatMap((vendorTdsChallan) => vendorTdsChallan.bank).filter((bank) => !!bank).reduce((accumulator, current) => {
211
+ if (!accumulator.some((bank) => bank.id === current.id)) {
212
+ accumulator.push(current);
213
+ }
214
+ return accumulator;
215
+ }, []);
216
+ }
217
+ get clientDebitNotes() {
218
+ // many_to_many -> many_to_many verified
219
+ // {'office_location->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor': 'many_to_one', 'vendor->organization_type': 'many_to_one', 'organization_type->tds_rate': 'many_to_many', 'tds_rate->vendor_tds_challan': 'one_to_many', 'vendor_tds_challan->bank': 'many_to_one', 'bank->client_debit_note': 'one_to_many'}
220
+ // ['vendor_tds_challan', 'bank'] -> many_to_one
221
+ // ['bank', 'client_debit_note'] -> one_to_many
222
+ // return this.banks
223
+ // ?.flatMap((bank) => bank.clientDebitNotes)
224
+ // .filter((clientDebitNote): clientDebitNote is ClientDebitNoteEntityModel => !!clientDebitNote)
225
+ // .reduce((accumulator: ClientDebitNoteEntityModel[], current) => {
226
+ // if (!accumulator.some((clientDebitNote) => clientDebitNote.id === current.id)) {
227
+ // accumulator.push(current);
228
+ // }
229
+ // return accumulator;
230
+ // }, []);
231
+ return undefined;
232
+ }
233
+ get clients() {
234
+ // many_to_many -> many_to_many verified
235
+ // {'office_location->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor': 'many_to_one', 'vendor->organization_type': 'many_to_one', 'organization_type->tds_rate': 'many_to_many', 'tds_rate->vendor_tds_challan': 'one_to_many', 'vendor_tds_challan->bank': 'many_to_one', 'bank->client_debit_note': 'one_to_many', 'client_debit_note->client': 'many_to_one'}
236
+ // ['bank', 'client_debit_note'] -> one_to_many
237
+ // ['client_debit_note', 'client'] -> many_to_one
238
+ var _a;
239
+ return (_a = this.clientDebitNotes) === null || _a === void 0 ? void 0 : _a.flatMap((clientDebitNote) => clientDebitNote.client).filter((client) => !!client).reduce((accumulator, current) => {
240
+ if (!accumulator.some((client) => client.id === current.id)) {
241
+ accumulator.push(current);
242
+ }
243
+ return accumulator;
244
+ }, []);
245
+ }
246
+ get users() {
247
+ // many_to_many -> many_to_many verified
248
+ // {'office_location->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor': 'many_to_one', 'vendor->organization_type': 'many_to_one', 'organization_type->tds_rate': 'many_to_many', 'tds_rate->vendor_tds_challan': 'one_to_many', 'vendor_tds_challan->bank': 'many_to_one', 'bank->client_debit_note': 'one_to_many', 'client_debit_note->client': 'many_to_one', 'client->user': 'many_to_many'}
249
+ // ['client_debit_note', 'client'] -> many_to_one
250
+ // ['client', 'user'] -> many_to_many
251
+ // return this.clients
252
+ // ?.flatMap((client) => client.users)
253
+ // .filter((user): user is UserEntityModel => !!user)
254
+ // .reduce((accumulator: UserEntityModel[], current) => {
255
+ // if (!accumulator.some((user) => user.id === current.id)) {
256
+ // accumulator.push(current);
257
+ // }
258
+ // return accumulator;
259
+ // }, []);
260
+ return undefined;
261
+ }
262
+ get leaveApprovals() {
263
+ // many_to_many -> many_to_many verified
264
+ // {'office_location->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor': 'many_to_one', 'vendor->organization_type': 'many_to_one', 'organization_type->tds_rate': 'many_to_many', 'tds_rate->vendor_tds_challan': 'one_to_many', 'vendor_tds_challan->bank': 'many_to_one', 'bank->client_debit_note': 'one_to_many', 'client_debit_note->client': 'many_to_one', 'client->user': 'many_to_many', 'user->leave_approval': 'one_to_many'}
265
+ // ['client', 'user'] -> many_to_many
266
+ // ['user', 'leave_approval'] -> one_to_many
267
+ // return this.users
268
+ // ?.flatMap((user) => user.leaveApprovals)
269
+ // .filter((leaveApproval): leaveApproval is LeaveApprovalEntityModel => !!leaveApproval)
270
+ // .reduce((accumulator: LeaveApprovalEntityModel[], current) => {
271
+ // if (!accumulator.some((leaveApproval) => leaveApproval.id === current.id)) {
272
+ // accumulator.push(current);
273
+ // }
274
+ // return accumulator;
275
+ // }, []);
276
+ return undefined;
277
+ }
278
+ get leaves() {
279
+ // many_to_many -> many_to_many verified
280
+ // {'office_location->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor': 'many_to_one', 'vendor->organization_type': 'many_to_one', 'organization_type->tds_rate': 'many_to_many', 'tds_rate->vendor_tds_challan': 'one_to_many', 'vendor_tds_challan->bank': 'many_to_one', 'bank->client_debit_note': 'one_to_many', 'client_debit_note->client': 'many_to_one', 'client->user': 'many_to_many', 'user->leave_approval': 'one_to_many', 'leave_approval->leave': 'many_to_one'}
281
+ // ['user', 'leave_approval'] -> one_to_many
282
+ // ['leave_approval', 'leave'] -> many_to_one
283
+ var _a;
284
+ return (_a = this.leaveApprovals) === null || _a === void 0 ? void 0 : _a.flatMap((leaveApproval) => leaveApproval.leave).filter((leave) => !!leave).reduce((accumulator, current) => {
285
+ if (!accumulator.some((leave) => leave.id === current.id)) {
286
+ accumulator.push(current);
287
+ }
288
+ return accumulator;
289
+ }, []);
290
+ }
291
+ get workFromHomes() {
292
+ // many_to_many -> many_to_many verified
293
+ // {'office_location->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor': 'many_to_one', 'vendor->organization_type': 'many_to_one', 'organization_type->tds_rate': 'many_to_many', 'tds_rate->vendor_tds_challan': 'one_to_many', 'vendor_tds_challan->bank': 'many_to_one', 'bank->client_debit_note': 'one_to_many', 'client_debit_note->client': 'many_to_one', 'client->user': 'many_to_many', 'user->work_from_home': 'one_to_many'}
294
+ // ['client', 'user'] -> many_to_many
295
+ // ['user', 'work_from_home'] -> one_to_many
296
+ // return this.users
297
+ // ?.flatMap((user) => user.workFromHomes)
298
+ // .filter((workFromHome): workFromHome is WorkFromHomeEntityModel => !!workFromHome)
299
+ // .reduce((accumulator: WorkFromHomeEntityModel[], current) => {
300
+ // if (!accumulator.some((workFromHome) => workFromHome.id === current.id)) {
301
+ // accumulator.push(current);
302
+ // }
303
+ // return accumulator;
304
+ // }, []);
305
+ return undefined;
306
+ }
307
+ get toDoLists() {
308
+ // many_to_many -> many_to_many verified
309
+ // {'office_location->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor': 'many_to_one', 'vendor->organization_type': 'many_to_one', 'organization_type->tds_rate': 'many_to_many', 'tds_rate->vendor_tds_challan': 'one_to_many', 'vendor_tds_challan->bank': 'many_to_one', 'bank->client_debit_note': 'one_to_many', 'client_debit_note->client': 'many_to_one', 'client->user': 'many_to_many', 'user->to_do_list': 'one_to_many'}
310
+ // ['client', 'user'] -> many_to_many
311
+ // ['user', 'to_do_list'] -> one_to_many
312
+ // return this.users
313
+ // ?.flatMap((user) => user.toDoLists)
314
+ // .filter((toDoList): toDoList is ToDoListEntityModel => !!toDoList)
315
+ // .reduce((accumulator: ToDoListEntityModel[], current) => {
316
+ // if (!accumulator.some((toDoList) => toDoList.id === current.id)) {
317
+ // accumulator.push(current);
318
+ // }
319
+ // return accumulator;
320
+ // }, []);
321
+ return undefined;
322
+ }
323
+ get projects() {
324
+ // many_to_many -> many_to_many verified
325
+ // {'office_location->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor': 'many_to_one', 'vendor->organization_type': 'many_to_one', 'organization_type->tds_rate': 'many_to_many', 'tds_rate->vendor_tds_challan': 'one_to_many', 'vendor_tds_challan->bank': 'many_to_one', 'bank->client_debit_note': 'one_to_many', 'client_debit_note->client': 'many_to_one', 'client->user': 'many_to_many', 'user->to_do_list': 'one_to_many', 'to_do_list->project': 'many_to_one'}
326
+ // ['user', 'to_do_list'] -> one_to_many
327
+ // ['to_do_list', 'project'] -> many_to_one
328
+ var _a;
329
+ return (_a = this.toDoLists) === null || _a === void 0 ? void 0 : _a.flatMap((toDoList) => toDoList.project).filter((project) => !!project).reduce((accumulator, current) => {
330
+ if (!accumulator.some((project) => project.id === current.id)) {
331
+ accumulator.push(current);
332
+ }
333
+ return accumulator;
334
+ }, []);
335
+ }
336
+ get clientAffiliates() {
337
+ // many_to_many -> many_to_many verified
338
+ // {'office_location->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor': 'many_to_one', 'vendor->organization_type': 'many_to_one', 'organization_type->tds_rate': 'many_to_many', 'tds_rate->vendor_tds_challan': 'one_to_many', 'vendor_tds_challan->bank': 'many_to_one', 'bank->client_debit_note': 'one_to_many', 'client_debit_note->client_affiliate': 'many_to_one'}
339
+ // ['bank', 'client_debit_note'] -> one_to_many
340
+ // ['client_debit_note', 'client_affiliate'] -> many_to_one
341
+ var _a;
342
+ return (_a = this.clientDebitNotes) === null || _a === void 0 ? void 0 : _a.flatMap((clientDebitNote) => clientDebitNote.clientAffiliate).filter((clientAffiliate) => !!clientAffiliate).reduce((accumulator, current) => {
343
+ if (!accumulator.some((clientAffiliate) => clientAffiliate.id === current.id)) {
344
+ accumulator.push(current);
345
+ }
346
+ return accumulator;
347
+ }, []);
348
+ }
349
+ get clientDebitNoteParticularss() {
350
+ // one_to_many -> many_to_many mismatch
351
+ // {'office_location->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor': 'many_to_one', 'vendor->organization_type': 'many_to_one', 'organization_type->tds_rate': 'many_to_many', 'tds_rate->vendor_tds_challan': 'one_to_many', 'vendor_tds_challan->bank': 'many_to_one', 'bank->client_debit_note': 'one_to_many', 'client_debit_note->client_debit_note_particulars': 'one_to_many'}
352
+ // ['bank', 'client_debit_note'] -> one_to_many
353
+ // ['client_debit_note', 'client_debit_note_particulars'] -> one_to_many
354
+ // return this.clientDebitNotes
355
+ // ?.flatMap((clientDebitNote) => clientDebitNote.clientDebitNoteParticulars)
356
+ // .filter((clientDebitNoteParticulars): clientDebitNoteParticulars is ClientDebitNoteParticularsEntityModel => !!clientDebitNoteParticulars)
357
+ // .reduce((accumulator: ClientDebitNoteParticularsEntityModel[], current) => {
358
+ // if (!accumulator.some((clientDebitNoteParticulars) => clientDebitNoteParticulars.id === current.id)) {
359
+ // accumulator.push(current);
360
+ // }
361
+ // return accumulator;
362
+ // }, []);
363
+ return undefined;
364
+ }
365
+ get vendorInvoicePayments() {
366
+ // one_to_many -> one_to_many verified
367
+ // {'office_location->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor_invoice_payment': 'one_to_many'}
368
+ // ['office_location', 'vendor_invoice'] -> one_to_many
369
+ // ['vendor_invoice', 'vendor_invoice_payment'] -> one_to_many
370
+ var _a;
371
+ return (_a = this.vendorInvoices) === null || _a === void 0 ? void 0 : _a.flatMap((vendorInvoice) => vendorInvoice.vendorInvoicePayments).filter((vendorInvoicePayment) => !!vendorInvoicePayment).reduce((accumulator, current) => {
372
+ if (!accumulator.some((vendorInvoicePayment) => vendorInvoicePayment.id === current.id)) {
373
+ accumulator.push(current);
374
+ }
375
+ return accumulator;
376
+ }, []);
377
+ }
378
+ getNextStatus(currentUser, action, officeLocationFlowConfigContextData) {
379
+ if (!this.status) {
380
+ throw new exceptions_1.AppBadRequestException({
381
+ key: error_key_enum_1.ErrorKeyEnum.STATUS,
382
+ message: [`Status not found: ${this.status}`],
383
+ });
384
+ }
385
+ const flowForStatus = office_location_flow_config_1.officeLocationFlowConfig[this.status];
386
+ if (!flowForStatus) {
387
+ throw new exceptions_1.AppBadRequestException({
388
+ key: error_key_enum_1.ErrorKeyEnum.STATUS,
389
+ message: [`No flow configuration found for status: ${this.status}`],
390
+ });
391
+ }
392
+ if (!action) {
393
+ throw new exceptions_1.AppBadRequestException({
394
+ key: error_key_enum_1.ErrorKeyEnum.ACTION_DATA,
395
+ message: ["actionData is required"],
396
+ });
397
+ }
398
+ const matchingPermissionConfig = flowForStatus.actions[action];
399
+ if (!matchingPermissionConfig) {
400
+ throw new exceptions_1.AppBadRequestException({
401
+ key: error_key_enum_1.ErrorKeyEnum.ACTION,
402
+ message: [`Action '${action}' is not valid for the current status.`],
403
+ });
404
+ }
405
+ if (!currentUser.permissions || currentUser.permissions.length === 0) {
406
+ throw new exceptions_1.AppBadRequestException({
407
+ key: error_key_enum_1.ErrorKeyEnum.PERMISSIONS,
408
+ message: ["Permission not available for currentUser"],
409
+ });
410
+ }
411
+ const hasPermission = matchingPermissionConfig.permissions.some((permission) => currentUser.permissions.includes(permission));
412
+ if (!hasPermission) {
413
+ throw new exceptions_1.AppBadRequestException({
414
+ key: error_key_enum_1.ErrorKeyEnum.PERMISSION,
415
+ message: [`Current user does not have permission to ${action} officeLocation`],
416
+ });
417
+ }
418
+ const nextStatus = matchingPermissionConfig.next(officeLocationFlowConfigContextData);
419
+ return nextStatus;
420
+ }
421
+ getAvailableActions(currentUser, config) {
422
+ var _a;
423
+ const params = {
424
+ flowConfig: office_location_flow_config_1.officeLocationFlowConfig,
425
+ currentStatus: this.status,
426
+ userPermissions: (_a = currentUser.permissions) !== null && _a !== void 0 ? _a : [],
427
+ visibilityData: this.getUpdateActionVisibility.bind(this, currentUser),
428
+ combinedActions: config === null || config === void 0 ? void 0 : config.combinedActions,
429
+ customLabels: config === null || config === void 0 ? void 0 : config.customLabels,
430
+ };
431
+ return utils_1.EntityActionFlowResolverV2.getAvailableActionsData(params);
432
+ }
433
+ getUpdateActionVisibility(currentUser) {
434
+ return {};
435
+ }
30
436
  }
31
437
  exports.OfficeLocationEntityModel = OfficeLocationEntityModel;
32
- OfficeLocationEntityModel.relationConfigs = [];
438
+ OfficeLocationEntityModel.relationConfigs = [
439
+ {
440
+ name: entity_utils_interface_1.EntityEnum.ORGANIZATION,
441
+ relation: relation_type_enum_1.RelationType.ONE,
442
+ key: "organization",
443
+ mapKeyConfig: {
444
+ relationKey: "id",
445
+ key: "organizationId",
446
+ },
447
+ },
448
+ {
449
+ name: entity_utils_interface_1.EntityEnum.VENDOR_INVOICE,
450
+ relation: relation_type_enum_1.RelationType.MANY,
451
+ key: "vendorInvoices",
452
+ mapKeyConfig: {
453
+ relationKey: "serviceLocationId",
454
+ key: "id",
455
+ },
456
+ },
457
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "law-common",
3
- "version": "12.8.0",
3
+ "version": "12.8.1-beta.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -1,3 +0,0 @@
1
- import { IEntityUpdateDto, IOfficeLocationEntity } from "../../entities";
2
- export interface IOfficeLocationUpdateDto extends IEntityUpdateDto<IOfficeLocationEntity> {
3
- }
@@ -1,3 +0,0 @@
1
- import { IEntityCreateDto, IOfficeLocationEntity } from "../../entities";
2
- export interface IOfficeLocationCreateDto extends IEntityCreateDto<IOfficeLocationEntity> {
3
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });