law-common 10.72.2-beta.1 → 10.72.2-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.
@@ -1,11 +1,19 @@
1
- import { OrganizationTypeStatusEnum } from "../enums/organization_type_status_enum";
2
1
  import { EntityEnum } from "../interface/entity.utils.interface";
3
- import { IOrganizationTypeEntity } from "../interface/organization_type.entity.interface";
4
- import { RelationConfigs } from "../interface/relation-config.interface";
5
2
  import { BaseEntityModel } from "./base.entity.model";
3
+ import { RelationConfigs } from "../interface/relation-config.interface";
4
+ import { IOrganizationTypeEntity } from "../interface/organization_type.entity.interface";
5
+ import { OrganizationTypeStatusEnum } from "../enums/organization_type_status_enum";
6
6
  import { OrganizationTypeTdsRateMappingEntityModel } from "./organization_type_tds_rate_mapping.entity.model";
7
7
  import { TdsRateEntityModel } from "./tds_rate.entity.model";
8
+ import { VendorEntityModel } from "./vendor.entity.model";
8
9
  import { VoucherTypeEntityModel } from "./voucher_type.entity.model";
10
+ import { ExpenseHeadEntityModel } from "./expense_head.entity.model";
11
+ import { VendorInvoiceItemEntityModel } from "./vendor_invoice_item.entity.model";
12
+ import { VendorInvoiceEntityModel } from "./vendor_invoice.entity.model";
13
+ import { StateEntityModel } from "./state.entity.model";
14
+ import { CountryEntityModel } from "./country.entity.model";
15
+ import { OfficeLocationEntityModel } from "./office_location.entity.model";
16
+ import { GstRateEntityModel } from "./gst_rate.entity.model";
9
17
  export declare class OrganizationTypeEntityModel extends BaseEntityModel<EntityEnum.ORGANIZATION_TYPE> implements IOrganizationTypeEntity {
10
18
  id: number;
11
19
  code: string;
@@ -16,9 +24,17 @@ export declare class OrganizationTypeEntityModel extends BaseEntityModel<EntityE
16
24
  createdBy: number;
17
25
  updatedBy: number;
18
26
  organizationTypeTdsRateMappings?: OrganizationTypeTdsRateMappingEntityModel[];
19
- static relationConfigs: RelationConfigs<[EntityEnum.ORGANIZATION_TYPE_TDS_RATE_MAPPING], EntityEnum.ORGANIZATION_TYPE>;
27
+ vendors?: VendorEntityModel[];
28
+ static relationConfigs: RelationConfigs<[EntityEnum.ORGANIZATION_TYPE_TDS_RATE_MAPPING, EntityEnum.VENDOR], EntityEnum.ORGANIZATION_TYPE>;
20
29
  static fromEntity(entity: IOrganizationTypeEntity): OrganizationTypeEntityModel;
21
30
  getRelationConfigs(): any[];
22
31
  get tdsRates(): TdsRateEntityModel[];
23
- get voucherTypes(): VoucherTypeEntityModel[];
32
+ get voucherTypes(): VoucherTypeEntityModel[] | undefined;
33
+ get expenseHeads(): ExpenseHeadEntityModel[] | undefined;
34
+ get vendorInvoiceItems(): VendorInvoiceItemEntityModel[] | undefined;
35
+ get vendorInvoices(): VendorInvoiceEntityModel[] | undefined;
36
+ get states(): StateEntityModel[] | undefined;
37
+ get countrys(): CountryEntityModel[] | undefined;
38
+ get officeLocations(): OfficeLocationEntityModel[] | undefined;
39
+ get gstRates(): GstRateEntityModel[] | undefined;
24
40
  }
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OrganizationTypeEntityModel = void 0;
4
- const organization_type_status_enum_1 = require("../enums/organization_type_status_enum");
5
- const relation_type_enum_1 = require("../enums/relation-type.enum");
6
4
  const entity_utils_interface_1 = require("../interface/entity.utils.interface");
7
5
  const base_entity_model_1 = require("./base.entity.model");
6
+ const relation_type_enum_1 = require("../enums/relation-type.enum");
7
+ const organization_type_status_enum_1 = require("../enums/organization_type_status_enum");
8
8
  class OrganizationTypeEntityModel extends base_entity_model_1.BaseEntityModel {
9
9
  constructor() {
10
10
  super(...arguments);
@@ -32,18 +32,108 @@ class OrganizationTypeEntityModel extends base_entity_model_1.BaseEntityModel {
32
32
  return [];
33
33
  }
34
34
  get voucherTypes() {
35
- const tdsRateVoucherTypeMappings = this.tdsRates.map((tdsRate) => tdsRate.tdsRateVoucherTypeMappings || []).flat();
36
- const voucherTypes = tdsRateVoucherTypeMappings.filter((mapping) => mapping.voucherType).map((mapping) => mapping.voucherType);
37
- // remove duplicate voucher types based on id
38
- const uniqueVoucherTypesMap = {};
39
- // Use Reduce to create a map of unique voucher types
40
- voucherTypes.reduce((acc, voucherType) => {
41
- if (!acc[voucherType.id]) {
42
- acc[voucherType.id] = voucherType;
43
- }
44
- return acc;
45
- }, uniqueVoucherTypesMap);
46
- return Object.values(uniqueVoucherTypesMap);
35
+ // many_to_many -> many_to_many verified
36
+ // {'organization_type->tds_rate': 'many_to_many', 'tds_rate->voucher_type': 'many_to_many'}
37
+ // ['organization_type', 'tds_rate'] -> many_to_many
38
+ // ['tds_rate', 'voucher_type'] -> many_to_many
39
+ var _a;
40
+ return (_a = this.tdsRates) === null || _a === void 0 ? void 0 : _a.flatMap((tdsRate) => tdsRate.voucherTypes).filter((voucherType) => !!voucherType).reduce((accumulator, current) => {
41
+ if (!accumulator.some((voucherType) => voucherType.id === current.id)) {
42
+ accumulator.push(current);
43
+ }
44
+ return accumulator;
45
+ }, []);
46
+ }
47
+ get expenseHeads() {
48
+ // many_to_many -> many_to_many verified
49
+ // {'organization_type->tds_rate': 'many_to_many', 'tds_rate->voucher_type': 'many_to_many', 'voucher_type->expense_head': 'one_to_many'}
50
+ // ['tds_rate', 'voucher_type'] -> many_to_many
51
+ // ['voucher_type', 'expense_head'] -> one_to_many
52
+ var _a;
53
+ return (_a = this.voucherTypes) === null || _a === void 0 ? void 0 : _a.flatMap((voucherType) => voucherType.expenseHeads).filter((expenseHead) => !!expenseHead).reduce((accumulator, current) => {
54
+ if (!accumulator.some((expenseHead) => expenseHead.id === current.id)) {
55
+ accumulator.push(current);
56
+ }
57
+ return accumulator;
58
+ }, []);
59
+ }
60
+ get vendorInvoiceItems() {
61
+ // one_to_many -> one_to_many verified
62
+ // {'organization_type->vendor': 'one_to_many', 'vendor->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor_invoice_item': 'one_to_many'}
63
+ // ['vendor', 'vendor_invoice'] -> one_to_many
64
+ // ['vendor_invoice', 'vendor_invoice_item'] -> one_to_many
65
+ var _a;
66
+ return (_a = this.vendorInvoices) === null || _a === void 0 ? void 0 : _a.flatMap((vendorInvoice) => vendorInvoice.vendorInvoiceItems).filter((vendorInvoiceItem) => !!vendorInvoiceItem).reduce((accumulator, current) => {
67
+ if (!accumulator.some((vendorInvoiceItem) => vendorInvoiceItem.id === current.id)) {
68
+ accumulator.push(current);
69
+ }
70
+ return accumulator;
71
+ }, []);
72
+ }
73
+ get vendorInvoices() {
74
+ // one_to_many -> one_to_many verified
75
+ // {'organization_type->vendor': 'one_to_many', 'vendor->vendor_invoice': 'one_to_many'}
76
+ // ['organization_type', 'vendor'] -> one_to_many
77
+ // ['vendor', 'vendor_invoice'] -> one_to_many
78
+ var _a;
79
+ return (_a = this.vendors) === null || _a === void 0 ? void 0 : _a.flatMap((vendor) => vendor.vendorInvoices).filter((vendorInvoice) => !!vendorInvoice).reduce((accumulator, current) => {
80
+ if (!accumulator.some((vendorInvoice) => vendorInvoice.id === current.id)) {
81
+ accumulator.push(current);
82
+ }
83
+ return accumulator;
84
+ }, []);
85
+ }
86
+ get states() {
87
+ // many_to_many -> many_to_many verified
88
+ // {'organization_type->vendor': 'one_to_many', 'vendor->state': 'many_to_one'}
89
+ // ['organization_type', 'vendor'] -> one_to_many
90
+ // ['vendor', 'state'] -> many_to_one
91
+ var _a;
92
+ return (_a = this.vendors) === null || _a === void 0 ? void 0 : _a.flatMap((vendor) => vendor.stateModel).filter((state) => !!state).reduce((accumulator, current) => {
93
+ if (!accumulator.some((state) => state.id === current.id)) {
94
+ accumulator.push(current);
95
+ }
96
+ return accumulator;
97
+ }, []);
98
+ }
99
+ get countrys() {
100
+ // many_to_many -> many_to_many verified
101
+ // {'organization_type->vendor': 'one_to_many', 'vendor->country': 'many_to_one'}
102
+ // ['organization_type', 'vendor'] -> one_to_many
103
+ // ['vendor', 'country'] -> many_to_one
104
+ var _a;
105
+ return (_a = this.vendors) === null || _a === void 0 ? void 0 : _a.flatMap((vendor) => vendor.countryModel).filter((country) => !!country).reduce((accumulator, current) => {
106
+ if (!accumulator.some((country) => country.id === current.id)) {
107
+ accumulator.push(current);
108
+ }
109
+ return accumulator;
110
+ }, []);
111
+ }
112
+ get officeLocations() {
113
+ // many_to_many -> many_to_many verified
114
+ // {'organization_type->vendor': 'one_to_many', 'vendor->vendor_invoice': 'one_to_many', 'vendor_invoice->office_location': 'many_to_one'}
115
+ // ['vendor', 'vendor_invoice'] -> one_to_many
116
+ // ['vendor_invoice', 'office_location'] -> many_to_one
117
+ var _a;
118
+ return (_a = this.vendorInvoices) === null || _a === void 0 ? void 0 : _a.flatMap((vendorInvoice) => vendorInvoice.officeLocation).filter((officeLocation) => !!officeLocation).reduce((accumulator, current) => {
119
+ if (!accumulator.some((officeLocation) => officeLocation.id === current.id)) {
120
+ accumulator.push(current);
121
+ }
122
+ return accumulator;
123
+ }, []);
124
+ }
125
+ get gstRates() {
126
+ // many_to_many -> many_to_many verified
127
+ // {'organization_type->vendor': 'one_to_many', 'vendor->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor_invoice_item': 'one_to_many', 'vendor_invoice_item->gst_rate': 'many_to_one'}
128
+ // ['vendor_invoice', 'vendor_invoice_item'] -> one_to_many
129
+ // ['vendor_invoice_item', 'gst_rate'] -> many_to_one
130
+ var _a;
131
+ return (_a = this.vendorInvoiceItems) === null || _a === void 0 ? void 0 : _a.flatMap((vendorInvoiceItem) => vendorInvoiceItem.gstRate).filter((gstRate) => !!gstRate).reduce((accumulator, current) => {
132
+ if (!accumulator.some((gstRate) => gstRate.id === current.id)) {
133
+ accumulator.push(current);
134
+ }
135
+ return accumulator;
136
+ }, []);
47
137
  }
48
138
  }
49
139
  exports.OrganizationTypeEntityModel = OrganizationTypeEntityModel;
@@ -57,4 +147,13 @@ OrganizationTypeEntityModel.relationConfigs = [
57
147
  key: "id",
58
148
  },
59
149
  },
150
+ {
151
+ name: entity_utils_interface_1.EntityEnum.VENDOR,
152
+ relation: relation_type_enum_1.RelationType.MANY,
153
+ key: "vendors",
154
+ mapKeyConfig: {
155
+ relationKey: "organizationTypeId",
156
+ key: "id",
157
+ },
158
+ },
60
159
  ];
@@ -1,10 +1,20 @@
1
- import { TdsRateStatusEnum } from "../enums/tds_rate_status_enum";
2
1
  import { EntityEnum } from "../interface/entity.utils.interface";
2
+ import { BaseEntityModel } from "./base.entity.model";
3
3
  import { RelationConfigs } from "../interface/relation-config.interface";
4
4
  import { ITdsRateEntity } from "../interface/tds_rate.entity.interface";
5
- import { BaseEntityModel } from "./base.entity.model";
5
+ import { TdsRateStatusEnum } from "../enums/tds_rate_status_enum";
6
6
  import { OrganizationTypeTdsRateMappingEntityModel } from "./organization_type_tds_rate_mapping.entity.model";
7
7
  import { TdsRateVoucherTypeMappingEntityModel } from "./tds_rate_voucher_type_mapping.entity.model";
8
+ import { OrganizationTypeEntityModel } from "./organization_type.entity.model";
9
+ import { VoucherTypeEntityModel } from "./voucher_type.entity.model";
10
+ import { VendorInvoiceItemEntityModel } from "./vendor_invoice_item.entity.model";
11
+ import { VendorEntityModel } from "./vendor.entity.model";
12
+ import { StateEntityModel } from "./state.entity.model";
13
+ import { CountryEntityModel } from "./country.entity.model";
14
+ import { VendorInvoiceEntityModel } from "./vendor_invoice.entity.model";
15
+ import { OfficeLocationEntityModel } from "./office_location.entity.model";
16
+ import { ExpenseHeadEntityModel } from "./expense_head.entity.model";
17
+ import { GstRateEntityModel } from "./gst_rate.entity.model";
8
18
  export declare class TdsRateEntityModel extends BaseEntityModel<EntityEnum.TDS_RATE> implements ITdsRateEntity {
9
19
  id: number;
10
20
  section: string;
@@ -20,9 +30,23 @@ export declare class TdsRateEntityModel extends BaseEntityModel<EntityEnum.TDS_R
20
30
  updatedBy: number;
21
31
  organizationTypeTdsRateMappings?: OrganizationTypeTdsRateMappingEntityModel[];
22
32
  tdsRateVoucherTypeMappings?: TdsRateVoucherTypeMappingEntityModel[];
23
- static relationConfigs: RelationConfigs<[EntityEnum.ORGANIZATION_TYPE_TDS_RATE_MAPPING, EntityEnum.TDS_RATE_VOUCHER_TYPE_MAPPING], EntityEnum.TDS_RATE>;
33
+ vendorInvoiceItems?: VendorInvoiceItemEntityModel[];
34
+ static relationConfigs: RelationConfigs<[
35
+ EntityEnum.ORGANIZATION_TYPE_TDS_RATE_MAPPING,
36
+ EntityEnum.TDS_RATE_VOUCHER_TYPE_MAPPING,
37
+ EntityEnum.VENDOR_INVOICE_ITEM
38
+ ], EntityEnum.TDS_RATE>;
24
39
  static fromEntity(entity: ITdsRateEntity): TdsRateEntityModel;
25
40
  getRelationConfigs(): any[];
41
+ get organizationTypes(): OrganizationTypeEntityModel[];
42
+ get voucherTypes(): VoucherTypeEntityModel[];
43
+ get vendors(): VendorEntityModel[] | undefined;
44
+ get states(): StateEntityModel[] | undefined;
45
+ get countrys(): CountryEntityModel[] | undefined;
46
+ get vendorInvoices(): VendorInvoiceEntityModel[] | undefined;
47
+ get officeLocations(): OfficeLocationEntityModel[] | undefined;
48
+ get expenseHeads(): ExpenseHeadEntityModel[] | undefined;
49
+ get gstRates(): GstRateEntityModel[] | undefined;
26
50
  get organizationTypeIds(): number[];
27
51
  static getTdsNotApplicableRate(tdsRateEntityModels: TdsRateEntityModel[]): TdsRateEntityModel | undefined;
28
52
  isTdsNotApplicable(): boolean;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TdsRateEntityModel = void 0;
4
- const relation_type_enum_1 = require("../enums/relation-type.enum");
5
- const tds_rate_status_enum_1 = require("../enums/tds_rate_status_enum");
6
4
  const entity_utils_interface_1 = require("../interface/entity.utils.interface");
7
5
  const base_entity_model_1 = require("./base.entity.model");
6
+ const relation_type_enum_1 = require("../enums/relation-type.enum");
7
+ const tds_rate_status_enum_1 = require("../enums/tds_rate_status_enum");
8
8
  class TdsRateEntityModel extends base_entity_model_1.BaseEntityModel {
9
9
  constructor() {
10
10
  super(...arguments);
@@ -28,6 +28,109 @@ class TdsRateEntityModel extends base_entity_model_1.BaseEntityModel {
28
28
  getRelationConfigs() {
29
29
  return this.constructor.prototype.constructor.relationConfigs || [];
30
30
  }
31
+ get organizationTypes() {
32
+ if (this.organizationTypeTdsRateMappings) {
33
+ return this.organizationTypeTdsRateMappings.filter((mapping) => mapping.organizationType).map((mapping) => mapping.organizationType);
34
+ }
35
+ return [];
36
+ }
37
+ get voucherTypes() {
38
+ if (this.tdsRateVoucherTypeMappings) {
39
+ return this.tdsRateVoucherTypeMappings.filter((mapping) => mapping.voucherType).map((mapping) => mapping.voucherType);
40
+ }
41
+ return [];
42
+ }
43
+ get vendors() {
44
+ // many_to_many -> many_to_many verified
45
+ // {'tds_rate->organization_type': 'many_to_many', 'organization_type->vendor': 'one_to_many'}
46
+ // ['tds_rate', 'organization_type'] -> many_to_many
47
+ // ['organization_type', 'vendor'] -> one_to_many
48
+ var _a;
49
+ return (_a = this.organizationTypes) === null || _a === void 0 ? void 0 : _a.flatMap((organizationType) => organizationType.vendors).filter((vendor) => !!vendor).reduce((accumulator, current) => {
50
+ if (!accumulator.some((vendor) => vendor.id === current.id)) {
51
+ accumulator.push(current);
52
+ }
53
+ return accumulator;
54
+ }, []);
55
+ }
56
+ get states() {
57
+ // many_to_many -> many_to_many verified
58
+ // {'tds_rate->organization_type': 'many_to_many', 'organization_type->vendor': 'one_to_many', 'vendor->state': 'many_to_one'}
59
+ // ['organization_type', 'vendor'] -> one_to_many
60
+ // ['vendor', 'state'] -> many_to_one
61
+ var _a;
62
+ return (_a = this.vendors) === null || _a === void 0 ? void 0 : _a.flatMap((vendor) => vendor.stateModel).filter((state) => !!state).reduce((accumulator, current) => {
63
+ if (!accumulator.some((state) => state.id === current.id)) {
64
+ accumulator.push(current);
65
+ }
66
+ return accumulator;
67
+ }, []);
68
+ }
69
+ get countrys() {
70
+ // many_to_many -> many_to_many verified
71
+ // {'tds_rate->organization_type': 'many_to_many', 'organization_type->vendor': 'one_to_many', 'vendor->country': 'many_to_one'}
72
+ // ['organization_type', 'vendor'] -> one_to_many
73
+ // ['vendor', 'country'] -> many_to_one
74
+ var _a;
75
+ return (_a = this.vendors) === null || _a === void 0 ? void 0 : _a.flatMap((vendor) => vendor.countryModel).filter((country) => !!country).reduce((accumulator, current) => {
76
+ if (!accumulator.some((country) => country.id === current.id)) {
77
+ accumulator.push(current);
78
+ }
79
+ return accumulator;
80
+ }, []);
81
+ }
82
+ get vendorInvoices() {
83
+ // one_to_many -> many_to_many mismatch
84
+ // {'tds_rate->organization_type': 'many_to_many', 'organization_type->vendor': 'one_to_many', 'vendor->vendor_invoice': 'one_to_many'}
85
+ // ['organization_type', 'vendor'] -> one_to_many
86
+ // ['vendor', 'vendor_invoice'] -> one_to_many
87
+ var _a;
88
+ return (_a = this.vendors) === null || _a === void 0 ? void 0 : _a.flatMap((vendor) => vendor.vendorInvoices).filter((vendorInvoice) => !!vendorInvoice).reduce((accumulator, current) => {
89
+ if (!accumulator.some((vendorInvoice) => vendorInvoice.id === current.id)) {
90
+ accumulator.push(current);
91
+ }
92
+ return accumulator;
93
+ }, []);
94
+ }
95
+ get officeLocations() {
96
+ // many_to_many -> many_to_many verified
97
+ // {'tds_rate->organization_type': 'many_to_many', 'organization_type->vendor': 'one_to_many', 'vendor->vendor_invoice': 'one_to_many', 'vendor_invoice->office_location': 'many_to_one'}
98
+ // ['vendor', 'vendor_invoice'] -> one_to_many
99
+ // ['vendor_invoice', 'office_location'] -> many_to_one
100
+ var _a;
101
+ return (_a = this.vendorInvoices) === null || _a === void 0 ? void 0 : _a.flatMap((vendorInvoice) => vendorInvoice.officeLocation).filter((officeLocation) => !!officeLocation).reduce((accumulator, current) => {
102
+ if (!accumulator.some((officeLocation) => officeLocation.id === current.id)) {
103
+ accumulator.push(current);
104
+ }
105
+ return accumulator;
106
+ }, []);
107
+ }
108
+ get expenseHeads() {
109
+ // many_to_many -> many_to_many verified
110
+ // {'tds_rate->voucher_type': 'many_to_many', 'voucher_type->expense_head': 'one_to_many'}
111
+ // ['tds_rate', 'voucher_type'] -> many_to_many
112
+ // ['voucher_type', 'expense_head'] -> one_to_many
113
+ var _a;
114
+ return (_a = this.voucherTypes) === null || _a === void 0 ? void 0 : _a.flatMap((voucherType) => voucherType.expenseHeads).filter((expenseHead) => !!expenseHead).reduce((accumulator, current) => {
115
+ if (!accumulator.some((expenseHead) => expenseHead.id === current.id)) {
116
+ accumulator.push(current);
117
+ }
118
+ return accumulator;
119
+ }, []);
120
+ }
121
+ get gstRates() {
122
+ // many_to_many -> many_to_many verified
123
+ // {'tds_rate->vendor_invoice_item': 'one_to_many', 'vendor_invoice_item->gst_rate': 'many_to_one'}
124
+ // ['tds_rate', 'vendor_invoice_item'] -> one_to_many
125
+ // ['vendor_invoice_item', 'gst_rate'] -> many_to_one
126
+ var _a;
127
+ return (_a = this.vendorInvoiceItems) === null || _a === void 0 ? void 0 : _a.flatMap((vendorInvoiceItem) => vendorInvoiceItem.gstRate).filter((gstRate) => !!gstRate).reduce((accumulator, current) => {
128
+ if (!accumulator.some((gstRate) => gstRate.id === current.id)) {
129
+ accumulator.push(current);
130
+ }
131
+ return accumulator;
132
+ }, []);
133
+ }
31
134
  get organizationTypeIds() {
32
135
  var _a;
33
136
  return ((_a = this.organizationTypeTdsRateMappings) === null || _a === void 0 ? void 0 : _a.map((mapping) => mapping.organizationTypeId)) || [];
@@ -59,4 +162,13 @@ TdsRateEntityModel.relationConfigs = [
59
162
  key: "id",
60
163
  },
61
164
  },
165
+ {
166
+ name: entity_utils_interface_1.EntityEnum.VENDOR_INVOICE_ITEM,
167
+ relation: relation_type_enum_1.RelationType.MANY,
168
+ key: "vendorInvoiceItems",
169
+ mapKeyConfig: {
170
+ relationKey: "tdsRateId",
171
+ key: "id",
172
+ },
173
+ },
62
174
  ];
@@ -1,19 +1,27 @@
1
1
  import { EntityEnum, Nullable } from "../interface/entity.utils.interface";
2
- import { RelationConfigs } from "../interface/relation-config.interface";
3
2
  import { BaseEntityModel } from "./base.entity.model";
4
- import { IVendorFlowConfigContextData } from "../../api";
5
- import { VendorActionEnum } from "../enums/vendor-action.enum";
6
- import { VendorStatusEnum } from "../enums/vendor-status.enum";
7
- import { VendorContractApplicabilityEnum } from "../enums/vendor_contract_applicability_enum";
8
- import { VendorGstTypeEnum } from "../enums/vendor_gst_type_enum";
3
+ import { RelationConfigs } from "../interface/relation-config.interface";
4
+ import { IVendorEntity } from "../interface/vendor.entity.interface";
9
5
  import { VendorLocationTypeEnum } from "../enums/vendor_location_type_enum";
6
+ import { VendorGstTypeEnum } from "../enums/vendor_gst_type_enum";
10
7
  import { VendorPanTypeEnum } from "../enums/vendor_pan_type_enum";
8
+ import { VendorContractApplicabilityEnum } from "../enums/vendor_contract_applicability_enum";
9
+ import { VendorStatusEnum } from "../enums/vendor-status.enum";
10
+ import { StateEntityModel } from "./state.entity.model";
11
+ import { CountryEntityModel } from "./country.entity.model";
12
+ import { VendorInvoiceEntityModel } from "./vendor_invoice.entity.model";
13
+ import { OrganizationTypeEntityModel } from "./organization_type.entity.model";
14
+ import { OfficeLocationEntityModel } from "./office_location.entity.model";
15
+ import { VendorInvoiceItemEntityModel } from "./vendor_invoice_item.entity.model";
16
+ import { VoucherTypeEntityModel } from "./voucher_type.entity.model";
17
+ import { TdsRateEntityModel } from "./tds_rate.entity.model";
18
+ import { ExpenseHeadEntityModel } from "./expense_head.entity.model";
19
+ import { GstRateEntityModel } from "./gst_rate.entity.model";
11
20
  import { IUserEntity } from "../interface/user.entity.interface";
12
- import { IVendorEntity } from "../interface/vendor.entity.interface";
21
+ import { VendorActionEnum } from "../enums/vendor-action.enum";
13
22
  import { IRowActions } from "./interface/row-actions.interface";
14
- import { OrganizationTypeEntityModel } from "./organization_type.entity.model";
15
- import { StateEntityModel } from "./state.entity.model";
16
23
  import { UserEntityModel } from "./user.entity.model";
24
+ import { IVendorFlowConfigContextData } from "../../api";
17
25
  export declare class VendorEntityModel extends BaseEntityModel<EntityEnum.VENDOR> implements IVendorEntity {
18
26
  id: number;
19
27
  name: string;
@@ -36,14 +44,37 @@ export declare class VendorEntityModel extends BaseEntityModel<EntityEnum.VENDOR
36
44
  attachmentDocuments?: string;
37
45
  contactDetail?: string;
38
46
  bankDetail?: string;
47
+ organizationTypeId?: number;
48
+ status: VendorStatusEnum;
49
+ remark: Nullable<string>;
39
50
  createdOn: number;
40
51
  updatedOn: number;
41
52
  createdBy: number;
42
53
  updatedBy: number;
43
- status: VendorStatusEnum;
44
- remark: Nullable<string>;
45
- organizationTypeId?: Nullable<number>;
54
+ stateModel?: StateEntityModel;
55
+ countryModel?: CountryEntityModel;
46
56
  organizationType?: OrganizationTypeEntityModel;
57
+ vendorInvoices?: VendorInvoiceEntityModel[];
58
+ static relationConfigs: RelationConfigs<[EntityEnum.STATE, EntityEnum.COUNTRY, EntityEnum.ORGANIZATION_TYPE, EntityEnum.VENDOR_INVOICE], EntityEnum.VENDOR>;
59
+ static fromEntity(entity: IVendorEntity): VendorEntityModel;
60
+ getRelationConfigs(): any[];
61
+ get officeLocations(): OfficeLocationEntityModel[] | undefined;
62
+ get vendorInvoiceItems(): VendorInvoiceItemEntityModel[] | undefined;
63
+ get voucherTypes(): VoucherTypeEntityModel[] | undefined;
64
+ get tdsRates(): TdsRateEntityModel[] | undefined;
65
+ get expenseHeads(): ExpenseHeadEntityModel[] | undefined;
66
+ get gstRates(): GstRateEntityModel[] | undefined;
67
+ getNextStatus(currentUser: IUserEntity, action: VendorActionEnum, vendorFlowConfigContextData: IVendorFlowConfigContextData): VendorStatusEnum;
68
+ getAvailableActions(currentUser: UserEntityModel, config?: {
69
+ combinedActions?: Record<string, {
70
+ combineActions: VendorActionEnum[];
71
+ label: string;
72
+ }>;
73
+ customLabels?: Partial<Record<VendorActionEnum, string>>;
74
+ }): IRowActions<EntityEnum.VENDOR>[];
75
+ getUpdateActionVisibility(currentUser: UserEntityModel): {
76
+ [key: string]: () => boolean;
77
+ };
47
78
  static readonly VENDOR_ENTITY_DOCUMENT_TYPES: readonly ["pan", "gst"];
48
79
  /**
49
80
  * Default number of days added to the Invoice Date to calculate the Due Date,
@@ -59,21 +90,4 @@ export declare class VendorEntityModel extends BaseEntityModel<EntityEnum.VENDOR
59
90
  * @see VendorEntityModel.paymentDueDays
60
91
  */
61
92
  static readonly DEFAULT_DUE_DAYS = 7;
62
- stateModel?: StateEntityModel;
63
- populateOrganizationTypeModel(organizationTypeEntityModels: OrganizationTypeEntityModel[]): null;
64
- getPanNoFourthCharacter(): string;
65
- static relationConfigs: RelationConfigs<[EntityEnum.STATE, EntityEnum.ORGANIZATION_TYPE], EntityEnum.VENDOR>;
66
- static fromEntity(entity: IVendorEntity): VendorEntityModel;
67
- getRelationConfigs(): any[];
68
- getNextStatus(currentUser: IUserEntity, action: VendorActionEnum, vendorFlowConfigContextData: IVendorFlowConfigContextData): VendorStatusEnum;
69
- getAvailableActions(currentUser: UserEntityModel, config?: {
70
- combinedActions?: Record<string, {
71
- combineActions: VendorActionEnum[];
72
- label: string;
73
- }>;
74
- customLabels?: Partial<Record<VendorActionEnum, string>>;
75
- }): IRowActions<EntityEnum.VENDOR>[];
76
- getUpdateActionVisibility(currentUser: UserEntityModel): {
77
- [key: string]: () => boolean;
78
- };
79
93
  }
@@ -3,16 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VendorEntityModel = void 0;
4
4
  const entity_utils_interface_1 = require("../interface/entity.utils.interface");
5
5
  const base_entity_model_1 = require("./base.entity.model");
6
- const error_key_enum_1 = require("../../enums/error.key.enum");
7
- const exceptions_1 = require("../../exceptions");
8
- const utils_1 = require("../../utils");
9
- const vendor_status_enum_1 = require("../enums/vendor-status.enum");
10
6
  const relation_type_enum_1 = require("../enums/relation-type.enum");
11
- const vendor_contract_applicability_enum_1 = require("../enums/vendor_contract_applicability_enum");
12
- const vendor_gst_type_enum_1 = require("../enums/vendor_gst_type_enum");
13
7
  const vendor_location_type_enum_1 = require("../enums/vendor_location_type_enum");
8
+ const vendor_gst_type_enum_1 = require("../enums/vendor_gst_type_enum");
14
9
  const vendor_pan_type_enum_1 = require("../enums/vendor_pan_type_enum");
10
+ const vendor_contract_applicability_enum_1 = require("../enums/vendor_contract_applicability_enum");
11
+ const vendor_status_enum_1 = require("../enums/vendor-status.enum");
12
+ const exceptions_1 = require("../../exceptions");
13
+ const error_key_enum_1 = require("../../enums/error.key.enum");
15
14
  const vendor_flow_config_1 = require("../flow-configs/vendor-flow.config");
15
+ const utils_1 = require("../../utils");
16
16
  class VendorEntityModel extends base_entity_model_1.BaseEntityModel {
17
17
  constructor() {
18
18
  super(...arguments);
@@ -24,30 +24,12 @@ class VendorEntityModel extends base_entity_model_1.BaseEntityModel {
24
24
  this.gstType = vendor_gst_type_enum_1.VendorGstTypeEnum.REGISTERED;
25
25
  this.panType = vendor_pan_type_enum_1.VendorPanTypeEnum.AVAILABLE;
26
26
  this.contractApplicability = vendor_contract_applicability_enum_1.VendorContractApplicabilityEnum.YES;
27
+ this.status = vendor_status_enum_1.VendorStatusEnum.CREATE_APPROVAL;
28
+ this.remark = null;
27
29
  this.createdOn = 0;
28
30
  this.updatedOn = 0;
29
31
  this.createdBy = 0;
30
32
  this.updatedBy = 0;
31
- this.status = vendor_status_enum_1.VendorStatusEnum.CREATE_APPROVAL;
32
- this.remark = null;
33
- }
34
- populateOrganizationTypeModel(organizationTypeEntityModels) {
35
- const panType = this.getPanNoFourthCharacter();
36
- if (!panType) {
37
- return null;
38
- }
39
- if (panType) {
40
- this.organizationType = organizationTypeEntityModels.find((model) => model.code === panType);
41
- }
42
- return null;
43
- }
44
- getPanNoFourthCharacter() {
45
- var _a;
46
- if (this.panType === vendor_pan_type_enum_1.VendorPanTypeEnum.AVAILABLE && this.panNo) {
47
- const panNo = ((_a = this.panNo.split("/").pop()) === null || _a === void 0 ? void 0 : _a.split(".").shift()) || "";
48
- return panNo.charAt(3) || "";
49
- }
50
- return "";
51
33
  }
52
34
  static fromEntity(entity) {
53
35
  const result = new VendorEntityModel(entity_utils_interface_1.EntityEnum.VENDOR);
@@ -57,6 +39,84 @@ class VendorEntityModel extends base_entity_model_1.BaseEntityModel {
57
39
  getRelationConfigs() {
58
40
  return this.constructor.prototype.constructor.relationConfigs || [];
59
41
  }
42
+ get officeLocations() {
43
+ // many_to_many -> many_to_many verified
44
+ // {'vendor->vendor_invoice': 'one_to_many', 'vendor_invoice->office_location': 'many_to_one'}
45
+ // ['vendor', 'vendor_invoice'] -> one_to_many
46
+ // ['vendor_invoice', 'office_location'] -> many_to_one
47
+ var _a;
48
+ return (_a = this.vendorInvoices) === null || _a === void 0 ? void 0 : _a.flatMap((vendorInvoice) => vendorInvoice.officeLocation).filter((officeLocation) => !!officeLocation).reduce((accumulator, current) => {
49
+ if (!accumulator.some((officeLocation) => officeLocation.id === current.id)) {
50
+ accumulator.push(current);
51
+ }
52
+ return accumulator;
53
+ }, []);
54
+ }
55
+ get vendorInvoiceItems() {
56
+ // one_to_many -> one_to_many verified
57
+ // {'vendor->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor_invoice_item': 'one_to_many'}
58
+ // ['vendor', 'vendor_invoice'] -> one_to_many
59
+ // ['vendor_invoice', 'vendor_invoice_item'] -> one_to_many
60
+ var _a;
61
+ return (_a = this.vendorInvoices) === null || _a === void 0 ? void 0 : _a.flatMap((vendorInvoice) => vendorInvoice.vendorInvoiceItems).filter((vendorInvoiceItem) => !!vendorInvoiceItem).reduce((accumulator, current) => {
62
+ if (!accumulator.some((vendorInvoiceItem) => vendorInvoiceItem.id === current.id)) {
63
+ accumulator.push(current);
64
+ }
65
+ return accumulator;
66
+ }, []);
67
+ }
68
+ get voucherTypes() {
69
+ // many_to_many -> many_to_many verified
70
+ // {'vendor->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor_invoice_item': 'one_to_many', 'vendor_invoice_item->voucher_type': 'many_to_one'}
71
+ // ['vendor_invoice', 'vendor_invoice_item'] -> one_to_many
72
+ // ['vendor_invoice_item', 'voucher_type'] -> many_to_one
73
+ var _a;
74
+ return (_a = this.vendorInvoiceItems) === null || _a === void 0 ? void 0 : _a.flatMap((vendorInvoiceItem) => vendorInvoiceItem.voucherType).filter((voucherType) => !!voucherType).reduce((accumulator, current) => {
75
+ if (!accumulator.some((voucherType) => voucherType.id === current.id)) {
76
+ accumulator.push(current);
77
+ }
78
+ return accumulator;
79
+ }, []);
80
+ }
81
+ get tdsRates() {
82
+ // many_to_many -> many_to_many verified
83
+ // {'vendor->organization_type': 'many_to_one', 'organization_type->tds_rate': 'many_to_many'}
84
+ // ['vendor', 'organization_type'] -> many_to_one
85
+ // ['organization_type', 'tds_rate'] -> many_to_many
86
+ var _a;
87
+ return (_a = this.organizationType) === null || _a === void 0 ? void 0 : _a.tdsRates.filter((tdsRate) => !!tdsRate).reduce((accumulator, current) => {
88
+ if (!accumulator.some((tdsRate) => tdsRate.id === current.id)) {
89
+ accumulator.push(current);
90
+ }
91
+ return accumulator;
92
+ }, []);
93
+ }
94
+ get expenseHeads() {
95
+ // many_to_many -> many_to_many verified
96
+ // {'vendor->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor_invoice_item': 'one_to_many', 'vendor_invoice_item->expense_head': 'many_to_one'}
97
+ // ['vendor_invoice', 'vendor_invoice_item'] -> one_to_many
98
+ // ['vendor_invoice_item', 'expense_head'] -> many_to_one
99
+ var _a;
100
+ return (_a = this.vendorInvoiceItems) === null || _a === void 0 ? void 0 : _a.flatMap((vendorInvoiceItem) => vendorInvoiceItem.expenseHead).filter((expenseHead) => !!expenseHead).reduce((accumulator, current) => {
101
+ if (!accumulator.some((expenseHead) => expenseHead.id === current.id)) {
102
+ accumulator.push(current);
103
+ }
104
+ return accumulator;
105
+ }, []);
106
+ }
107
+ get gstRates() {
108
+ // many_to_many -> many_to_many verified
109
+ // {'vendor->vendor_invoice': 'one_to_many', 'vendor_invoice->vendor_invoice_item': 'one_to_many', 'vendor_invoice_item->gst_rate': 'many_to_one'}
110
+ // ['vendor_invoice', 'vendor_invoice_item'] -> one_to_many
111
+ // ['vendor_invoice_item', 'gst_rate'] -> many_to_one
112
+ var _a;
113
+ return (_a = this.vendorInvoiceItems) === null || _a === void 0 ? void 0 : _a.flatMap((vendorInvoiceItem) => vendorInvoiceItem.gstRate).filter((gstRate) => !!gstRate).reduce((accumulator, current) => {
114
+ if (!accumulator.some((gstRate) => gstRate.id === current.id)) {
115
+ accumulator.push(current);
116
+ }
117
+ return accumulator;
118
+ }, []);
119
+ }
60
120
  getNextStatus(currentUser, action, vendorFlowConfigContextData) {
61
121
  if (!this.status) {
62
122
  throw new exceptions_1.AppBadRequestException({
@@ -117,21 +177,6 @@ class VendorEntityModel extends base_entity_model_1.BaseEntityModel {
117
177
  }
118
178
  }
119
179
  exports.VendorEntityModel = VendorEntityModel;
120
- VendorEntityModel.VENDOR_ENTITY_DOCUMENT_TYPES = ["pan", "gst"];
121
- /**
122
- * Default number of days added to the Invoice Date to calculate the Due Date,
123
- * used as a fallback when the Vendor does not have a `paymentDueDays` value configured.
124
- *
125
- * @formula
126
- * DueDate = InvoiceDate + (vendor.paymentDueDays ?? VendorEntityModel.DEFAULT_DUE_DAYS)
127
- *
128
- * @example
129
- * vendor.paymentDueDays = 30 → DueDate = InvoiceDate + 30
130
- * vendor.paymentDueDays = null → DueDate = InvoiceDate + 7 (this constant)
131
- *
132
- * @see VendorEntityModel.paymentDueDays
133
- */
134
- VendorEntityModel.DEFAULT_DUE_DAYS = 7;
135
180
  VendorEntityModel.relationConfigs = [
136
181
  {
137
182
  name: entity_utils_interface_1.EntityEnum.STATE,
@@ -142,15 +187,15 @@ VendorEntityModel.relationConfigs = [
142
187
  key: "state",
143
188
  },
144
189
  },
145
- // {
146
- // name: EntityEnum.OFFICE_LOCATION,
147
- // relation: RelationType.MANY,
148
- // key: "officeLocations",
149
- // mapKeyConfig: {
150
- // relationKey: "id",
151
- // key: "officeLocationId",
152
- // },
153
- // },
190
+ {
191
+ name: entity_utils_interface_1.EntityEnum.COUNTRY,
192
+ relation: relation_type_enum_1.RelationType.ONE,
193
+ key: "countryModel",
194
+ mapKeyConfig: {
195
+ relationKey: "name",
196
+ key: "country",
197
+ },
198
+ },
154
199
  {
155
200
  name: entity_utils_interface_1.EntityEnum.ORGANIZATION_TYPE,
156
201
  relation: relation_type_enum_1.RelationType.ONE,
@@ -160,4 +205,29 @@ VendorEntityModel.relationConfigs = [
160
205
  key: "organizationTypeId",
161
206
  },
162
207
  },
208
+ {
209
+ name: entity_utils_interface_1.EntityEnum.VENDOR_INVOICE,
210
+ relation: relation_type_enum_1.RelationType.MANY,
211
+ key: "vendorInvoices",
212
+ mapKeyConfig: {
213
+ relationKey: "vendorId",
214
+ key: "id",
215
+ },
216
+ },
163
217
  ];
218
+ //
219
+ VendorEntityModel.VENDOR_ENTITY_DOCUMENT_TYPES = ["pan", "gst"];
220
+ /**
221
+ * Default number of days added to the Invoice Date to calculate the Due Date,
222
+ * used as a fallback when the Vendor does not have a `paymentDueDays` value configured.
223
+ *
224
+ * @formula
225
+ * DueDate = InvoiceDate + (vendor.paymentDueDays ?? VendorEntityModel.DEFAULT_DUE_DAYS)
226
+ *
227
+ * @example
228
+ * vendor.paymentDueDays = 30 → DueDate = InvoiceDate + 30
229
+ * vendor.paymentDueDays = null → DueDate = InvoiceDate + 7 (this constant)
230
+ *
231
+ * @see VendorEntityModel.paymentDueDays
232
+ */
233
+ VendorEntityModel.DEFAULT_DUE_DAYS = 7;
@@ -1,11 +1,19 @@
1
- import { VoucherTypeStatusEnum } from "../enums/voucher_type_status_enum";
2
1
  import { EntityEnum } from "../interface/entity.utils.interface";
2
+ import { BaseEntityModel } from "./base.entity.model";
3
3
  import { RelationConfigs } from "../interface/relation-config.interface";
4
4
  import { IVoucherTypeEntity } from "../interface/voucher_type.entity.interface";
5
- import { BaseEntityModel } from "./base.entity.model";
6
- import { ExpenseHeadEntityModel } from "./expense_head.entity.model";
7
- import { TdsRateEntityModel } from "./tds_rate.entity.model";
5
+ import { VoucherTypeStatusEnum } from "../enums/voucher_type_status_enum";
8
6
  import { TdsRateVoucherTypeMappingEntityModel } from "./tds_rate_voucher_type_mapping.entity.model";
7
+ import { TdsRateEntityModel } from "./tds_rate.entity.model";
8
+ import { ExpenseHeadEntityModel } from "./expense_head.entity.model";
9
+ import { VendorInvoiceItemEntityModel } from "./vendor_invoice_item.entity.model";
10
+ import { OrganizationTypeEntityModel } from "./organization_type.entity.model";
11
+ import { VendorEntityModel } from "./vendor.entity.model";
12
+ import { StateEntityModel } from "./state.entity.model";
13
+ import { CountryEntityModel } from "./country.entity.model";
14
+ import { VendorInvoiceEntityModel } from "./vendor_invoice.entity.model";
15
+ import { OfficeLocationEntityModel } from "./office_location.entity.model";
16
+ import { GstRateEntityModel } from "./gst_rate.entity.model";
9
17
  export declare class VoucherTypeEntityModel extends BaseEntityModel<EntityEnum.VOUCHER_TYPE> implements IVoucherTypeEntity {
10
18
  id: number;
11
19
  name: string;
@@ -16,8 +24,20 @@ export declare class VoucherTypeEntityModel extends BaseEntityModel<EntityEnum.V
16
24
  updatedBy: number;
17
25
  tdsRateVoucherTypeMappings?: TdsRateVoucherTypeMappingEntityModel[];
18
26
  expenseHeads?: ExpenseHeadEntityModel[];
19
- static relationConfigs: RelationConfigs<[EntityEnum.TDS_RATE_VOUCHER_TYPE_MAPPING, EntityEnum.EXPENSE_HEAD], EntityEnum.VOUCHER_TYPE>;
27
+ vendorInvoiceItems?: VendorInvoiceItemEntityModel[];
28
+ static relationConfigs: RelationConfigs<[
29
+ EntityEnum.TDS_RATE_VOUCHER_TYPE_MAPPING,
30
+ EntityEnum.EXPENSE_HEAD,
31
+ EntityEnum.VENDOR_INVOICE_ITEM
32
+ ], EntityEnum.VOUCHER_TYPE>;
20
33
  static fromEntity(entity: IVoucherTypeEntity): VoucherTypeEntityModel;
21
34
  getRelationConfigs(): any[];
22
35
  get tdsRates(): TdsRateEntityModel[];
36
+ get organizationTypes(): OrganizationTypeEntityModel[] | undefined;
37
+ get vendors(): VendorEntityModel[] | undefined;
38
+ get states(): StateEntityModel[] | undefined;
39
+ get countrys(): CountryEntityModel[] | undefined;
40
+ get vendorInvoices(): VendorInvoiceEntityModel[] | undefined;
41
+ get officeLocations(): OfficeLocationEntityModel[] | undefined;
42
+ get gstRates(): GstRateEntityModel[] | undefined;
23
43
  }
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VoucherTypeEntityModel = void 0;
4
- const relation_type_enum_1 = require("../enums/relation-type.enum");
5
- const voucher_type_status_enum_1 = require("../enums/voucher_type_status_enum");
6
4
  const entity_utils_interface_1 = require("../interface/entity.utils.interface");
7
5
  const base_entity_model_1 = require("./base.entity.model");
6
+ const relation_type_enum_1 = require("../enums/relation-type.enum");
7
+ const voucher_type_status_enum_1 = require("../enums/voucher_type_status_enum");
8
8
  class VoucherTypeEntityModel extends base_entity_model_1.BaseEntityModel {
9
9
  constructor() {
10
10
  super(...arguments);
@@ -30,6 +30,97 @@ class VoucherTypeEntityModel extends base_entity_model_1.BaseEntityModel {
30
30
  }
31
31
  return [];
32
32
  }
33
+ get organizationTypes() {
34
+ // many_to_many -> many_to_many verified
35
+ // {'voucher_type->tds_rate': 'many_to_many', 'tds_rate->organization_type': 'many_to_many'}
36
+ // ['voucher_type', 'tds_rate'] -> many_to_many
37
+ // ['tds_rate', 'organization_type'] -> many_to_many
38
+ var _a;
39
+ return (_a = this.tdsRates) === null || _a === void 0 ? void 0 : _a.flatMap((tdsRate) => tdsRate.organizationTypes).filter((organizationType) => !!organizationType).reduce((accumulator, current) => {
40
+ if (!accumulator.some((organizationType) => organizationType.id === current.id)) {
41
+ accumulator.push(current);
42
+ }
43
+ return accumulator;
44
+ }, []);
45
+ }
46
+ get vendors() {
47
+ // many_to_many -> many_to_many verified
48
+ // {'voucher_type->tds_rate': 'many_to_many', 'tds_rate->organization_type': 'many_to_many', 'organization_type->vendor': 'one_to_many'}
49
+ // ['tds_rate', 'organization_type'] -> many_to_many
50
+ // ['organization_type', 'vendor'] -> one_to_many
51
+ var _a;
52
+ return (_a = this.organizationTypes) === null || _a === void 0 ? void 0 : _a.flatMap((organizationType) => organizationType.vendors).filter((vendor) => !!vendor).reduce((accumulator, current) => {
53
+ if (!accumulator.some((vendor) => vendor.id === current.id)) {
54
+ accumulator.push(current);
55
+ }
56
+ return accumulator;
57
+ }, []);
58
+ }
59
+ get states() {
60
+ // many_to_many -> many_to_many verified
61
+ // {'voucher_type->tds_rate': 'many_to_many', 'tds_rate->organization_type': 'many_to_many', 'organization_type->vendor': 'one_to_many', 'vendor->state': 'many_to_one'}
62
+ // ['organization_type', 'vendor'] -> one_to_many
63
+ // ['vendor', 'state'] -> many_to_one
64
+ var _a;
65
+ return (_a = this.vendors) === null || _a === void 0 ? void 0 : _a.flatMap((vendor) => vendor.stateModel).filter((state) => !!state).reduce((accumulator, current) => {
66
+ if (!accumulator.some((state) => state.id === current.id)) {
67
+ accumulator.push(current);
68
+ }
69
+ return accumulator;
70
+ }, []);
71
+ }
72
+ get countrys() {
73
+ // many_to_many -> many_to_many verified
74
+ // {'voucher_type->tds_rate': 'many_to_many', 'tds_rate->organization_type': 'many_to_many', 'organization_type->vendor': 'one_to_many', 'vendor->country': 'many_to_one'}
75
+ // ['organization_type', 'vendor'] -> one_to_many
76
+ // ['vendor', 'country'] -> many_to_one
77
+ var _a;
78
+ return (_a = this.vendors) === null || _a === void 0 ? void 0 : _a.flatMap((vendor) => vendor.countryModel).filter((country) => !!country).reduce((accumulator, current) => {
79
+ if (!accumulator.some((country) => country.id === current.id)) {
80
+ accumulator.push(current);
81
+ }
82
+ return accumulator;
83
+ }, []);
84
+ }
85
+ get vendorInvoices() {
86
+ // one_to_many -> many_to_many mismatch
87
+ // {'voucher_type->tds_rate': 'many_to_many', 'tds_rate->organization_type': 'many_to_many', 'organization_type->vendor': 'one_to_many', 'vendor->vendor_invoice': 'one_to_many'}
88
+ // ['organization_type', 'vendor'] -> one_to_many
89
+ // ['vendor', 'vendor_invoice'] -> one_to_many
90
+ var _a;
91
+ return (_a = this.vendors) === null || _a === void 0 ? void 0 : _a.flatMap((vendor) => vendor.vendorInvoices).filter((vendorInvoice) => !!vendorInvoice).reduce((accumulator, current) => {
92
+ if (!accumulator.some((vendorInvoice) => vendorInvoice.id === current.id)) {
93
+ accumulator.push(current);
94
+ }
95
+ return accumulator;
96
+ }, []);
97
+ }
98
+ get officeLocations() {
99
+ // many_to_many -> many_to_many verified
100
+ // {'voucher_type->tds_rate': 'many_to_many', 'tds_rate->organization_type': 'many_to_many', 'organization_type->vendor': 'one_to_many', 'vendor->vendor_invoice': 'one_to_many', 'vendor_invoice->office_location': 'many_to_one'}
101
+ // ['vendor', 'vendor_invoice'] -> one_to_many
102
+ // ['vendor_invoice', 'office_location'] -> many_to_one
103
+ var _a;
104
+ return (_a = this.vendorInvoices) === null || _a === void 0 ? void 0 : _a.flatMap((vendorInvoice) => vendorInvoice.officeLocation).filter((officeLocation) => !!officeLocation).reduce((accumulator, current) => {
105
+ if (!accumulator.some((officeLocation) => officeLocation.id === current.id)) {
106
+ accumulator.push(current);
107
+ }
108
+ return accumulator;
109
+ }, []);
110
+ }
111
+ get gstRates() {
112
+ // many_to_many -> many_to_many verified
113
+ // {'voucher_type->vendor_invoice_item': 'one_to_many', 'vendor_invoice_item->gst_rate': 'many_to_one'}
114
+ // ['voucher_type', 'vendor_invoice_item'] -> one_to_many
115
+ // ['vendor_invoice_item', 'gst_rate'] -> many_to_one
116
+ var _a;
117
+ return (_a = this.vendorInvoiceItems) === null || _a === void 0 ? void 0 : _a.flatMap((vendorInvoiceItem) => vendorInvoiceItem.gstRate).filter((gstRate) => !!gstRate).reduce((accumulator, current) => {
118
+ if (!accumulator.some((gstRate) => gstRate.id === current.id)) {
119
+ accumulator.push(current);
120
+ }
121
+ return accumulator;
122
+ }, []);
123
+ }
33
124
  }
34
125
  exports.VoucherTypeEntityModel = VoucherTypeEntityModel;
35
126
  VoucherTypeEntityModel.relationConfigs = [
@@ -51,4 +142,13 @@ VoucherTypeEntityModel.relationConfigs = [
51
142
  key: "id",
52
143
  },
53
144
  },
145
+ {
146
+ name: entity_utils_interface_1.EntityEnum.VENDOR_INVOICE_ITEM,
147
+ relation: relation_type_enum_1.RelationType.MANY,
148
+ key: "vendorInvoiceItems",
149
+ mapKeyConfig: {
150
+ relationKey: "voucherTypeId",
151
+ key: "id",
152
+ },
153
+ },
54
154
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "law-common",
3
- "version": "10.72.2-beta.1",
3
+ "version": "10.72.2-beta.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [