effects: brand, model, configuration, risk
This commit is contained in:
parent
99cce9a97d
commit
be06339a7e
@ -673,7 +673,7 @@ const sections: ISections[] = [
|
|||||||
Component: Label,
|
Component: Label,
|
||||||
props: {
|
props: {
|
||||||
name: 'labelLeaseObjectRisk',
|
name: 'labelLeaseObjectRisk',
|
||||||
valueName: 'leaseObjectRisk',
|
computedValue: 'leaseObjectRiskName',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import { useStores } from 'client/hooks/useStores';
|
|||||||
import CalculationService from 'client/services/CalculationService';
|
import CalculationService from 'client/services/CalculationService';
|
||||||
import { Box, Flex } from 'client/UIKit/grid';
|
import { Box, Flex } from 'client/UIKit/grid';
|
||||||
import initialOptionsMap from 'core/Data/initialOptionsMap';
|
import initialOptionsMap from 'core/Data/initialOptionsMap';
|
||||||
|
import staticEntitiesList from 'core/Data/staticEntitiesList';
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import Results from './Results';
|
import Results from './Results';
|
||||||
import Sections from './Sections';
|
import Sections from './Sections';
|
||||||
@ -19,6 +20,9 @@ const Calculation = () => {
|
|||||||
CalculationService.getInitialOptions({
|
CalculationService.getInitialOptions({
|
||||||
elementsList: initialOptionsMap,
|
elementsList: initialOptionsMap,
|
||||||
}),
|
}),
|
||||||
|
CalculationService.getStaticData({
|
||||||
|
staticEntitiesList,
|
||||||
|
}),
|
||||||
CalculationService.getEntityOptions({
|
CalculationService.getEntityOptions({
|
||||||
entityName: 'lead',
|
entityName: 'lead',
|
||||||
fields: undefined,
|
fields: undefined,
|
||||||
@ -28,8 +32,9 @@ const Calculation = () => {
|
|||||||
entityName: 'opportunity',
|
entityName: 'opportunity',
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
.then(([initialOptions, leadOptions, opportunities]) => {
|
.then(([initialOptions, staticEntities, leadOptions, opportunities]) => {
|
||||||
calculationStore.applyOptions({ ...initialOptions });
|
calculationStore.applyOptions({ ...initialOptions });
|
||||||
|
calculationStore.setStaticData(staticEntities);
|
||||||
calculationStore.applyOptions({ selectLead: leadOptions });
|
calculationStore.applyOptions({ selectLead: leadOptions });
|
||||||
calculationStore.applyOptions({ selectOpportunity: opportunities });
|
calculationStore.applyOptions({ selectOpportunity: opportunities });
|
||||||
setReady(true);
|
setReady(true);
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import { IOption } from 'core/types/Calculation/options';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import {
|
import {
|
||||||
IGetEntity,
|
IGetEntity,
|
||||||
@ -41,6 +42,25 @@ class CalculationService {
|
|||||||
reject(err);
|
reject(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
static getStaticData = ({
|
||||||
|
staticEntitiesList,
|
||||||
|
}: {
|
||||||
|
staticEntitiesList: IGetEntity[];
|
||||||
|
}): Promise<IOption[]> =>
|
||||||
|
new Promise((resolve, reject) => {
|
||||||
|
axios
|
||||||
|
.post('/api/calculation/getStaticEntities', {
|
||||||
|
staticEntitiesList,
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
const { staticEntities } = res.data;
|
||||||
|
resolve(staticEntities);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CalculationService;
|
export default CalculationService;
|
||||||
|
|||||||
12
src/client/stores/CalculationStore/Data/staticEntities.js
Normal file
12
src/client/stores/CalculationStore/Data/staticEntities.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
const staticData = {};
|
||||||
|
|
||||||
|
const staticDataAction = {
|
||||||
|
getStaticData(dataName) {
|
||||||
|
return this.staticData[dataName];
|
||||||
|
},
|
||||||
|
setStaticData(data) {
|
||||||
|
this.staticData = { ...this.staticData, ...data };
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export { staticData, staticDataAction };
|
||||||
@ -1,3 +1,9 @@
|
|||||||
|
const LEASE_OBJECT_RISK = {
|
||||||
|
100000000: 'Низкий',
|
||||||
|
100000001: 'Средний',
|
||||||
|
100000002: 'Высокий',
|
||||||
|
};
|
||||||
|
|
||||||
const computedEffects = {
|
const computedEffects = {
|
||||||
leadName() {
|
leadName() {
|
||||||
const leadId = this.values.lead;
|
const leadId = this.values.lead;
|
||||||
@ -22,6 +28,31 @@ const computedEffects = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
leaseObjectRiskName() {
|
||||||
|
const configurationId = this.values.configuration;
|
||||||
|
if (configurationId) {
|
||||||
|
const configuration = this.options.selectConfiguration?.find(
|
||||||
|
x => x.evo_equipmentid === configurationId,
|
||||||
|
);
|
||||||
|
if (configuration) {
|
||||||
|
if (configuration.evo_leasingobject_risk) {
|
||||||
|
const res = LEASE_OBJECT_RISK[configuration.evo_leasingobject_risk];
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const modelId = this.values.model;
|
||||||
|
if (modelId) {
|
||||||
|
const model = this.options.selectModel?.find(
|
||||||
|
x => x.evo_modelid === modelId,
|
||||||
|
);
|
||||||
|
if (model) {
|
||||||
|
const evo_leasingobject_risk = model.evo_leasingobject_risk;
|
||||||
|
return LEASE_OBJECT_RISK[evo_leasingobject_risk];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default computedEffects;
|
export default computedEffects;
|
||||||
|
|||||||
@ -1300,6 +1300,121 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
calculationStore => ({
|
||||||
|
expression: () => {
|
||||||
|
const { brand } = calculationStore.values;
|
||||||
|
return brand;
|
||||||
|
},
|
||||||
|
effect: brandId => {
|
||||||
|
if (brandId) {
|
||||||
|
const brand = calculationStore.options.selectBrand?.find(
|
||||||
|
x => x.evo_brandid === brandId,
|
||||||
|
);
|
||||||
|
if (brand) {
|
||||||
|
CalculationService.getEntityOptions({
|
||||||
|
entityName: 'evo_model',
|
||||||
|
where: {
|
||||||
|
statecode: 0,
|
||||||
|
evo_brandid: brandId,
|
||||||
|
},
|
||||||
|
}).then(models => {
|
||||||
|
if (models && models.length > 0) {
|
||||||
|
calculationStore.setStatus('selectModel', Status.Default);
|
||||||
|
calculationStore.setOptions('selectModel', models);
|
||||||
|
calculationStore.setValue('model', null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
calculationStore.setStatus('selectModel', Status.Disabled);
|
||||||
|
calculationStore.setOptions('selectModel', []);
|
||||||
|
calculationStore.setValue('model', null);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
|
calculationStore => ({
|
||||||
|
expression: () => {
|
||||||
|
const { model } = calculationStore.values;
|
||||||
|
return model;
|
||||||
|
},
|
||||||
|
effect: modelId => {
|
||||||
|
if (modelId) {
|
||||||
|
const model = calculationStore.options.selectModel?.find(
|
||||||
|
x => x.evo_modelid === modelId,
|
||||||
|
);
|
||||||
|
if (model) {
|
||||||
|
CalculationService.getEntityOptions({
|
||||||
|
entityName: 'evo_equipment',
|
||||||
|
where: {
|
||||||
|
statecode: 0,
|
||||||
|
evo_modelid: modelId,
|
||||||
|
},
|
||||||
|
}).then(equipments => {
|
||||||
|
if (equipments && equipments.length > 0) {
|
||||||
|
calculationStore.setStatus('selectConfiguration', Status.Default);
|
||||||
|
calculationStore.setOptions('selectConfiguration', equipments);
|
||||||
|
calculationStore.setValue('configuration', null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
calculationStore.setStatus('selectConfiguration', Status.Disabled);
|
||||||
|
calculationStore.setOptions('selectConfiguration', []);
|
||||||
|
calculationStore.setValue('configuration', null);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
|
calculationStore => ({
|
||||||
|
expression: () => {
|
||||||
|
const { model, configuration } = calculationStore.values;
|
||||||
|
return [model, configuration];
|
||||||
|
},
|
||||||
|
effect: ([modelId, configurationId]) => {
|
||||||
|
if (configurationId) {
|
||||||
|
const configuration = calculationStore.options.selectConfiguration?.find(
|
||||||
|
x => x.evo_equipmentid === configurationId,
|
||||||
|
);
|
||||||
|
if (configuration) {
|
||||||
|
if (configuration.evo_impairment_groupid) {
|
||||||
|
const evo_impairment_groups = calculationStore.getStaticData(
|
||||||
|
'evo_impairment_group',
|
||||||
|
);
|
||||||
|
const evo_impairment_group = evo_impairment_groups.find(
|
||||||
|
x =>
|
||||||
|
x.evo_impairment_groupid ===
|
||||||
|
configuration.evo_impairment_groupid,
|
||||||
|
);
|
||||||
|
calculationStore.setValue(
|
||||||
|
'depreciationGroup',
|
||||||
|
evo_impairment_group ? evo_impairment_group.evo_name : '',
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const model = calculationStore.options.selectModel?.find(
|
||||||
|
x => x.evo_modelid === modelId,
|
||||||
|
);
|
||||||
|
if (model)
|
||||||
|
if (model.evo_impairment_groupid) {
|
||||||
|
const evo_impairment_groups = calculationStore.getStaticData(
|
||||||
|
'evo_impairment_group',
|
||||||
|
);
|
||||||
|
const evo_impairment_group = evo_impairment_groups.find(
|
||||||
|
x => x.evo_impairment_groupid === model.evo_impairment_groupid,
|
||||||
|
);
|
||||||
|
calculationStore.setValue(
|
||||||
|
'depreciationGroup',
|
||||||
|
evo_impairment_group ? evo_impairment_group.evo_name : '',
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
calculationStore.setValue('depreciationGroup', null);
|
||||||
|
},
|
||||||
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
export default reactionEffects;
|
export default reactionEffects;
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import {
|
|||||||
valuesActions,
|
valuesActions,
|
||||||
valuesData,
|
valuesData,
|
||||||
} from './Data/index';
|
} from './Data/index';
|
||||||
|
import { staticData, staticDataAction } from './Data/staticEntities';
|
||||||
import autorunEffects from './Effects/autorun';
|
import autorunEffects from './Effects/autorun';
|
||||||
import computedEffects from './Effects/computed';
|
import computedEffects from './Effects/computed';
|
||||||
import reactionEffects from './Effects/reaction';
|
import reactionEffects from './Effects/reaction';
|
||||||
@ -21,6 +22,8 @@ import whenEffects from './Effects/when';
|
|||||||
const CalculationStore: ICalculationStore = observable(
|
const CalculationStore: ICalculationStore = observable(
|
||||||
assignProperties(
|
assignProperties(
|
||||||
{},
|
{},
|
||||||
|
staticData,
|
||||||
|
staticDataAction,
|
||||||
valuesData,
|
valuesData,
|
||||||
valuesActions,
|
valuesActions,
|
||||||
tablesData,
|
tablesData,
|
||||||
|
|||||||
@ -55,6 +55,12 @@ const initialOptionMap: TInitialElementsOptions = {
|
|||||||
selectAccount: {
|
selectAccount: {
|
||||||
entityName: 'account',
|
entityName: 'account',
|
||||||
},
|
},
|
||||||
|
selectBrand: {
|
||||||
|
entityName: 'evo_brand',
|
||||||
|
where: {
|
||||||
|
statecode: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default initialOptionMap;
|
export default initialOptionMap;
|
||||||
|
|||||||
@ -44,11 +44,11 @@ const propsMap: {
|
|||||||
value: 'evo_leasingobject_typeid',
|
value: 'evo_leasingobject_typeid',
|
||||||
},
|
},
|
||||||
evo_brand: {
|
evo_brand: {
|
||||||
name: 'evo_brand',
|
name: 'evo_name',
|
||||||
value: 'evo_brandid',
|
value: 'evo_brandid',
|
||||||
},
|
},
|
||||||
evo_model: {
|
evo_model: {
|
||||||
name: 'evo_model',
|
name: 'evo_name',
|
||||||
value: 'evo_modelid',
|
value: 'evo_modelid',
|
||||||
},
|
},
|
||||||
evo_equipment: {
|
evo_equipment: {
|
||||||
@ -83,6 +83,10 @@ const propsMap: {
|
|||||||
name: 'evo_name',
|
name: 'evo_name',
|
||||||
value: 'evo_connection_roleid',
|
value: 'evo_connection_roleid',
|
||||||
},
|
},
|
||||||
|
evo_impairment_group: {
|
||||||
|
name: 'evo_name',
|
||||||
|
value: 'evo_impairment_groupid',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default propsMap;
|
export default propsMap;
|
||||||
|
|||||||
9
src/core/Data/staticEntitiesList.ts
Normal file
9
src/core/Data/staticEntitiesList.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { IGetEntity } from '../types/Requests/Calculation';
|
||||||
|
|
||||||
|
const staticEntitiesList: IGetEntity[] = [
|
||||||
|
{
|
||||||
|
entityName: 'evo_impairment_group',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export default staticEntitiesList;
|
||||||
@ -24,6 +24,9 @@ const initialValues: TValues<TValue> = {
|
|||||||
comissionRub: 0,
|
comissionRub: 0,
|
||||||
saleBonus: 1.1,
|
saleBonus: 1.1,
|
||||||
IRR_Perc: 20,
|
IRR_Perc: 20,
|
||||||
|
brand: null,
|
||||||
|
model: null,
|
||||||
|
configuration: null,
|
||||||
deliveryTime: 100000000,
|
deliveryTime: 100000000,
|
||||||
leaseObjectCount: 1,
|
leaseObjectCount: 1,
|
||||||
withTrailer: 100000000,
|
withTrailer: 100000000,
|
||||||
|
|||||||
@ -83,6 +83,13 @@ const CONNECTION_4_ID = faker.random.uuid();
|
|||||||
const CONNECTION_5_ID = faker.random.uuid();
|
const CONNECTION_5_ID = faker.random.uuid();
|
||||||
const CONNECTION_6_ID = faker.random.uuid();
|
const CONNECTION_6_ID = faker.random.uuid();
|
||||||
|
|
||||||
|
const EVO_BRAND_ID = Array.from({ length: 10 }, () => faker.random.uuid());
|
||||||
|
const EVO_MODEL_ID = Array.from({ length: 10 }, () => faker.random.uuid());
|
||||||
|
const EVO_EQUIPMENT_ID = Array.from({ length: 10 }, () => faker.random.uuid());
|
||||||
|
const EVO_IMPAIRMENT_GROUP_ID = Array.from({ length: 10 }, () =>
|
||||||
|
faker.random.uuid(),
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fake Consts
|
* Fake Consts
|
||||||
*/
|
*/
|
||||||
@ -506,6 +513,96 @@ const entityFakeData: {
|
|||||||
evo_connection_roleid: EVO_CONNECTION_ROLE_3_ID,
|
evo_connection_roleid: EVO_CONNECTION_ROLE_3_ID,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
evo_brand: [
|
||||||
|
{
|
||||||
|
evo_brandid: EVO_BRAND_ID[0],
|
||||||
|
evo_name: 'AUDI',
|
||||||
|
statecode: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
evo_brandid: EVO_BRAND_ID[1],
|
||||||
|
evo_name: 'BMW',
|
||||||
|
statecode: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
evo_model: [
|
||||||
|
{
|
||||||
|
evo_modelid: EVO_MODEL_ID[0],
|
||||||
|
evo_name: 'A1',
|
||||||
|
evo_brandid: EVO_BRAND_ID[0],
|
||||||
|
statecode: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
evo_modelid: EVO_MODEL_ID[1],
|
||||||
|
evo_name: 'A5',
|
||||||
|
evo_brandid: EVO_BRAND_ID[0],
|
||||||
|
statecode: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
evo_modelid: EVO_MODEL_ID[2],
|
||||||
|
evo_name: 'Q7',
|
||||||
|
evo_brandid: EVO_BRAND_ID[0],
|
||||||
|
statecode: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
evo_modelid: EVO_MODEL_ID[3],
|
||||||
|
evo_name: '320i',
|
||||||
|
evo_brandid: EVO_BRAND_ID[1],
|
||||||
|
statecode: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
evo_modelid: EVO_MODEL_ID[4],
|
||||||
|
evo_name: 'X1',
|
||||||
|
evo_brandid: EVO_BRAND_ID[1],
|
||||||
|
statecode: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
evo_modelid: EVO_MODEL_ID[5],
|
||||||
|
evo_name: 'X5',
|
||||||
|
evo_brandid: EVO_BRAND_ID[1],
|
||||||
|
statecode: 0,
|
||||||
|
evo_impairment_groupid: EVO_IMPAIRMENT_GROUP_ID[0],
|
||||||
|
evo_leasingobject_risk: 100000000,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
evo_equipment: [
|
||||||
|
{
|
||||||
|
evo_equipmentid: EVO_EQUIPMENT_ID[0],
|
||||||
|
evo_modelid: EVO_MODEL_ID[2],
|
||||||
|
evo_name: 'Exclusive',
|
||||||
|
statecode: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
evo_equipmentid: EVO_EQUIPMENT_ID[1],
|
||||||
|
evo_modelid: EVO_MODEL_ID[2],
|
||||||
|
evo_name: 'Business',
|
||||||
|
statecode: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
evo_equipmentid: EVO_EQUIPMENT_ID[2],
|
||||||
|
evo_modelid: EVO_MODEL_ID[5],
|
||||||
|
evo_name: 'Super',
|
||||||
|
statecode: 0,
|
||||||
|
evo_impairment_groupid: EVO_IMPAIRMENT_GROUP_ID[1],
|
||||||
|
evo_leasingobject_risk: 100000001,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
evo_equipmentid: EVO_EQUIPMENT_ID[3],
|
||||||
|
evo_modelid: EVO_MODEL_ID[5],
|
||||||
|
evo_name: 'Basic',
|
||||||
|
statecode: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
evo_impairment_group: [
|
||||||
|
{
|
||||||
|
evo_name: 'Группа #1',
|
||||||
|
evo_impairment_groupid: EVO_IMPAIRMENT_GROUP_ID[0],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
evo_name: 'Группа #2',
|
||||||
|
evo_impairment_groupid: EVO_IMPAIRMENT_GROUP_ID[1],
|
||||||
|
},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
export default entityFakeData;
|
export default entityFakeData;
|
||||||
|
|||||||
@ -18,4 +18,5 @@ export type EntityNames =
|
|||||||
| 'evo_region'
|
| 'evo_region'
|
||||||
| 'evo_town'
|
| 'evo_town'
|
||||||
| 'connection'
|
| 'connection'
|
||||||
| 'evo_connection_role';
|
| 'evo_connection_role'
|
||||||
|
| 'evo_impairment_group';
|
||||||
|
|||||||
@ -71,7 +71,10 @@ export interface IEvoBrand extends IBaseOption {
|
|||||||
|
|
||||||
export interface IEvoModel extends IBaseOption {
|
export interface IEvoModel extends IBaseOption {
|
||||||
evo_name?: string;
|
evo_name?: string;
|
||||||
|
evo_brandid?: string;
|
||||||
evo_modelid?: string;
|
evo_modelid?: string;
|
||||||
|
evo_impairment_groupid?: string;
|
||||||
|
evo_leasingobject_risk?: number;
|
||||||
statecode?: number;
|
statecode?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,6 +82,8 @@ export interface IEvoEquipment extends IBaseOption {
|
|||||||
evo_equipmentid?: string;
|
evo_equipmentid?: string;
|
||||||
evo_name?: string;
|
evo_name?: string;
|
||||||
evo_modelid?: string;
|
evo_modelid?: string;
|
||||||
|
evo_impairment_groupid?: string;
|
||||||
|
evo_leasingobject_risk?: number;
|
||||||
statecode?: number;
|
statecode?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,6 +140,11 @@ export interface IEvoConnectionRole extends IBaseOption {
|
|||||||
evo_connection_roleid?: string;
|
evo_connection_roleid?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IEvoImpairmentGroup extends IBaseOption {
|
||||||
|
evo_name?: string;
|
||||||
|
evo_impairment_groupid?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export type TEntity = IAccount &
|
export type TEntity = IAccount &
|
||||||
ILead &
|
ILead &
|
||||||
IOpportunity &
|
IOpportunity &
|
||||||
@ -154,4 +164,5 @@ export type TEntity = IAccount &
|
|||||||
IEvoTown &
|
IEvoTown &
|
||||||
IEvoContact &
|
IEvoContact &
|
||||||
IConnection &
|
IConnection &
|
||||||
IEvoConnectionRole;
|
IEvoConnectionRole &
|
||||||
|
IEvoImpairmentGroup;
|
||||||
|
|||||||
9
src/core/types/staticData.ts
Normal file
9
src/core/types/staticData.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { EntityNames } from 'core/types/Entities/entityNames';
|
||||||
|
import { IOption } from './Calculation/options';
|
||||||
|
import { TValue } from './values';
|
||||||
|
|
||||||
|
export type StaticDataNames = 'evo_impairment_group';
|
||||||
|
|
||||||
|
export type TStaticData = {
|
||||||
|
[dataName in StaticDataNames | EntityNames]?: IOption[] | TValue;
|
||||||
|
};
|
||||||
@ -1,11 +1,16 @@
|
|||||||
import { TElementFilter } from 'core/types/Calculation/filters';
|
import { TElementFilter } from 'core/types/Calculation/filters';
|
||||||
import { IBaseOption, IOption } from 'core/types/Calculation/options';
|
import { IBaseOption, IOption } from 'core/types/Calculation/options';
|
||||||
import { ElementsNames, TElements } from './elements';
|
import { ElementsNames, TElements } from './elements';
|
||||||
|
import { StaticDataNames, TStaticData } from './staticData';
|
||||||
import { Status } from './statuses';
|
import { Status } from './statuses';
|
||||||
import { IStoreTable, TableNames, TableValuesNames } from './tables';
|
import { IStoreTable, TableNames, TableValuesNames } from './tables';
|
||||||
import { TValue, TValues, ValuesNames } from './values';
|
import { TValue, TValues, ValuesNames } from './values';
|
||||||
|
|
||||||
export interface ICalculationStore {
|
export interface ICalculationStore {
|
||||||
|
staticData: TStaticData;
|
||||||
|
getStaticData: (dataName: StaticDataNames) => IOption[];
|
||||||
|
setStaticData: (data: TStaticData) => void;
|
||||||
|
|
||||||
options: TElements<IOption[]>;
|
options: TElements<IOption[]>;
|
||||||
getOptions: (elementName: ElementsNames) => IOption[];
|
getOptions: (elementName: ElementsNames) => IOption[];
|
||||||
setOptions: (elementName: ElementsNames, options: IOption[]) => void;
|
setOptions: (elementName: ElementsNames, options: IOption[]) => void;
|
||||||
|
|||||||
@ -147,7 +147,10 @@ export type ValuesNames =
|
|||||||
| 'insuranceTermNS'
|
| 'insuranceTermNS'
|
||||||
| 'insuranceTermAddEquipment';
|
| 'insuranceTermAddEquipment';
|
||||||
|
|
||||||
export type ComputedValuesNames = 'leadName' | 'opportunityName';
|
export type ComputedValuesNames =
|
||||||
|
| 'leadName'
|
||||||
|
| 'opportunityName'
|
||||||
|
| 'leaseObjectRiskName';
|
||||||
|
|
||||||
export type TValues<T> = {
|
export type TValues<T> = {
|
||||||
[valueName in ValuesNames]?: T;
|
[valueName in ValuesNames]?: T;
|
||||||
|
|||||||
@ -65,6 +65,30 @@ class CalculationController {
|
|||||||
entityOptions,
|
entityOptions,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static getStaticEntities = async (
|
||||||
|
req: Request,
|
||||||
|
res: Response,
|
||||||
|
): Promise<any> => {
|
||||||
|
const {
|
||||||
|
staticEntitiesList,
|
||||||
|
}: { staticEntitiesList: IGetEntity[] } = req.body;
|
||||||
|
let staticEntities = {};
|
||||||
|
staticEntitiesList.forEach(entityQuery => {
|
||||||
|
const entityList = _getFakeEntities(
|
||||||
|
entityQuery.entityName,
|
||||||
|
entityQuery.fields,
|
||||||
|
entityQuery.where,
|
||||||
|
entityQuery.whereIn,
|
||||||
|
);
|
||||||
|
if (entityList) {
|
||||||
|
staticEntities[entityQuery.entityName] = entityList;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
res.send({
|
||||||
|
staticEntities,
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CalculationController;
|
export default CalculationController;
|
||||||
|
|||||||
@ -5,5 +5,6 @@ const router = Router();
|
|||||||
|
|
||||||
router.post('/getInitialOptions', CalculationController.getInitialOptions);
|
router.post('/getInitialOptions', CalculationController.getInitialOptions);
|
||||||
router.post('/getEntityOptions', CalculationController.getEntityOptions);
|
router.post('/getEntityOptions', CalculationController.getEntityOptions);
|
||||||
|
router.post('/getStaticEntities', CalculationController.getStaticEntities);
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
Reference in New Issue
Block a user