diff --git a/src/client/Components/Calculation/ELT/Content/lib/validation.ts b/src/client/Components/Calculation/ELT/Content/lib/validation.ts index fcebf32..5a68ffe 100644 --- a/src/client/Components/Calculation/ELT/Content/lib/validation.ts +++ b/src/client/Components/Calculation/ELT/Content/lib/validation.ts @@ -10,6 +10,7 @@ import CONDITIONS from 'core/validation/conditions'; import { convertToValidationResult, getValue, + showValidationMessages, validate, ValidationCondition, } from 'core/validation/validate'; @@ -59,27 +60,14 @@ export default function (this: ICalculationStore, validation: ELTValidation) { if (customConditions) { const customConditionsResult = validate(this, customConditions); - let messages: string[] = []; - (Object.keys(customConditionsResult) as ElementsNames[]).forEach( - elementName => { - const validationResult = customConditionsResult[elementName]; - if (validationResult?.isValid === false && validationResult.message) { - messages.push(validationResult.message); - } - }, + const { hasMessages } = showValidationMessages( + customConditionsResult, + 'Ошибка во время расчета ЭЛТ', ); - if (messages && messages.length > 0) { - messages.forEach(message => { - if (message) - openNotification({ - type: 'error', - title: 'Ошибка во время расчета ЭЛТ', - description: message, - })(); - }); + if (hasMessages) { return false; } - } - return true; + return true; + } } diff --git a/src/client/Containers/Calculation/lib/elements/elementsProps.ts b/src/client/Containers/Calculation/lib/elements/elementsProps.ts index 0d28076..4632372 100644 --- a/src/client/Containers/Calculation/lib/elements/elementsProps.ts +++ b/src/client/Containers/Calculation/lib/elements/elementsProps.ts @@ -294,7 +294,7 @@ const elementsProps: TElements = { showSearch: true, }, radioRequirementTelematic: { - style: 'button', + // style: 'button', }, radioQuoteContactGender: { style: 'button', diff --git a/src/client/Containers/Calculation/lib/fetchData/queries/staticDataQuery.ts b/src/client/Containers/Calculation/lib/fetchData/queries/staticDataQuery.ts index 19b5dfb..cb3a6c4 100644 --- a/src/client/Containers/Calculation/lib/fetchData/queries/staticDataQuery.ts +++ b/src/client/Containers/Calculation/lib/fetchData/queries/staticDataQuery.ts @@ -56,6 +56,15 @@ const query = gql` evo_name evo_job_titleid } + evo_addproduct_type: evo_addproduct_types( + statecode: $statecode + evo_datefrom_param: { lte: $currentDate } + evo_dateto_param: { gte: $currentDate } + ) { + evo_product_type + evo_addproduct_typeid + evo_controls_program + } } `; diff --git a/src/client/stores/CalculationStore/Data/values.js b/src/client/stores/CalculationStore/Data/values.js index 5e4843d..e890699 100644 --- a/src/client/stores/CalculationStore/Data/values.js +++ b/src/client/stores/CalculationStore/Data/values.js @@ -21,8 +21,9 @@ const valuesActions = { setValue(sourceValueName, newValue) { this.values[sourceValueName] = newValue; }, - setValues(values) { - this.values = values; + setValues(values, override) { + if (override) this.values = values; + this.values = Object.assign(this.values, values); }, getStatus(elementName) { diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts index 773ed68..a97087b 100644 --- a/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts +++ b/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts @@ -9,6 +9,7 @@ import CONDITIONS from 'core/validation/conditions'; import { convertToValidationResult, getValue, + showValidationMessages, validate, ValidationCondition, } from 'core/validation/validate'; @@ -80,6 +81,36 @@ const customConditions: TElements = { } return { isValid: true }; }, + selectTracker: calculationStore => { + const { tracker, requirementTelematic } = calculationStore.getValues([ + 'tracker', + 'requirementTelematic', + ]); + if (requirementTelematic !== 100000004 && !tracker) { + return { + isValid: false, + message: 'Не указан Тип средства контроля - Маяк', + }; + } + return { + isValid: true, + }; + }, + selectTelematic: calculationStore => { + const { telematic, requirementTelematic } = calculationStore.getValues([ + 'telematic', + 'requirementTelematic', + ]); + if (requirementTelematic !== 100000004 && !telematic) { + return { + isValid: false, + message: 'Не указан Тип средства контроля - Телематика', + }; + } + return { + isValid: true, + }; + }, }; const elementsValidations: TElements = { @@ -152,4 +183,5 @@ export default function (this: ICalculationStore) { const isValid = validationResult[elementName]?.isValid; if (isValid !== undefined) this.setValidation(elementName, isValid); }); + showValidationMessages(validationResult, 'Ошибка во время расчета графика'); } diff --git a/src/client/stores/CalculationStore/Effects/autorun.ts b/src/client/stores/CalculationStore/Effects/autorun.ts index 2a244f7..7240949 100644 --- a/src/client/stores/CalculationStore/Effects/autorun.ts +++ b/src/client/stores/CalculationStore/Effects/autorun.ts @@ -106,34 +106,7 @@ const autorunEffects: IAutorunEffect[] = [ // } else { // calculationStore.setValidation('tbxCountSeats', true); // } - // }, - calculationStore => () => { - const { requirementTelematic } = calculationStore.values; - if (requirementTelematic) { - const tracker = calculationStore.options.selectTracker?.find(x => - x.evo_controls_program?.includes(requirementTelematic), - ); - if (tracker) - calculationStore.setValue('tracker', tracker.evo_addproduct_typeid); - else { - calculationStore.setValue('tracker', null); - } - } - }, - - calculationStore => () => { - const { requirementTelematic } = calculationStore.values; - if (requirementTelematic) { - const telematic = calculationStore.options.selectTelematic?.find(x => - x.evo_controls_program?.includes(requirementTelematic), - ); - if (telematic) - calculationStore.setValue('telematic', telematic.evo_addproduct_typeid); - else { - calculationStore.setValue('telematic', null); - } - } - }, + // // }, calculationStore => () => { const { leaseObjectType: leaseObjectTypeId } = calculationStore.values; diff --git a/src/client/stores/CalculationStore/Effects/lib/queries.js b/src/client/stores/CalculationStore/Effects/lib/queries.js index bb16eb2..f89f6e2 100644 --- a/src/client/stores/CalculationStore/Effects/lib/queries.js +++ b/src/client/stores/CalculationStore/Effects/lib/queries.js @@ -18,4 +18,6 @@ evo_regionid evo_legal_regionid evo_legal_townid link +evo_req_telematic +evo_req_telematic_accept `; diff --git a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts index 38f850c..a9d463f 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts @@ -13,7 +13,7 @@ import { Process } from 'core/types/Calculation/Store/process'; import { ValuesNames } from 'core/types/Calculation/Store/values'; import { IEvoGraph } from 'core/types/Entities/crmEntities'; import { ElementStatus } from 'core/types/statuses'; -import { get, isEqual, isNil } from 'lodash'; +import { get, invert, isEqual, isNil } from 'lodash'; import NIL from 'uuid/dist/nil'; import { getKpPropName } from './mapKpToValues'; import { mainOptionsQuery, secondaryOptionsQuery } from './optionsQuery'; @@ -24,7 +24,7 @@ const map_add_product_types_to_values = { registration: 100000001, insNSIB: 100000002, tracker: 100000003, - telematics: 100000004, + telematic: 100000004, }; const tablePaymentsStatuses = (graphType, leasingPeriod) => { @@ -57,7 +57,6 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ lead, opportunity, recalcWithRevision, - leaseObjectCount, calcType, indAgent, INNForCalc, @@ -111,11 +110,11 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ dealer_person_accountid: quote.evo_dealer_person_accountid || NIL, dealer_broker_accountid: quote.evo_dealer_broker_accountid || NIL, hasDealerBroker: quote.evo_dealer_broker_accountid ? true : false, - ind_agent_accountid: quote.evo_agent_accountid || NIL, + // ind_agent_accountid: quote.evo_agent_accountid || NIL, double_agent_accountid: quote.evo_double_agent_accountid || NIL, - broker_accountid: quote.evo_broker_accountid || NIL, - findepartment_accountid: - quote.evo_fin_department_accountid || NIL, + // broker_accountid: quote.evo_broker_accountid || NIL, + // findepartment_accountid: + // quote.evo_fin_department_accountid || NIL, evo_gps_brandid: quote.evo_gps_brandid || NIL, evo_regionid: quote.evo_regionid || NIL, evo_legal_regionid: quote.evo_legal_regionid || NIL, @@ -230,19 +229,17 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ // get product evo_id // get addproducts - const addProducts = Object.assign( + let addProducts = Object.assign( {}, - ...Object.keys(map_add_product_types_to_values).map(elementName => { + ...Object.keys(map_add_product_types_to_values).map(valueName => { const target_add_product_type = quote?.evo_addproduct_types?.find( x => x.evo_product_type === - map_add_product_types_to_values[elementName], + map_add_product_types_to_values[valueName], ); return { - [elementName]: - target_add_product_type && - target_add_product_type.evo_addproduct_typeid, + [valueName]: target_add_product_type?.evo_addproduct_typeid, }; }), ); @@ -285,13 +282,35 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ // get clientRisk // recalc fields - let requirementTelematic = quote['evo_req_telematic']; let vehicleTaxInYear = quote['evo_vehicle_tax_year']; + let leaseObjectCount = quote.evo_object_count; + let requirementTelematic = quote.evo_req_telematic; if (recalcWithRevision) { + requirementTelematic = quote.evo_req_telematic_accept; if (quote['evo_vehicle_tax_approved']) { vehicleTaxInYear = quote['evo_vehicle_tax_approved']; } - requirementTelematic = quote['evo_req_telematic_accept']; + if (quote.evo_recalc_limit) { + leaseObjectCount = quote.evo_recalc_limit; + } + // telematic/tracker + addProducts.telematic = undefined; + addProducts.tracker = undefined; + const add_product_types = calculationStore.getStaticData( + 'evo_addproduct_type', + ); + const targetAddproduct = add_product_types.find( + x => + x.evo_addproduct_typeid === + quote.evo_accept_control_addproduct_typeid, + ); + if (targetAddproduct?.evo_product_type) { + const targetAddProductValueName = invert( + map_add_product_types_to_values, + )[targetAddproduct?.evo_product_type]; + addProducts[targetAddProductValueName] = + targetAddproduct.evo_addproduct_typeid; + } } // recalc fields @@ -462,33 +481,36 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ //townRegistration } - calculationStore.setValues({ - ...initialValues, - ...newValues, - product, - ...addProducts, - rate, - lead, - opportunity, - quote: quoteId, - recalcWithRevision, - leaseObjectCount, - clientRisk, - calcType, - totalPayments: evo_graph.evo_sumpay_withnds, - indAgent, - requirementTelematic, - vehicleTaxInYear, - INNForCalc, - creditRate, - infuranceOPF, - legalClientRegion, - regionRegistration, - legalClientTown, - townRegistration, - calcBroker, - calcFinDepartment, - }); + calculationStore.setValues( + { + ...initialValues, + ...newValues, + product, + ...addProducts, + rate, + lead, + opportunity, + quote: quoteId, + recalcWithRevision, + leaseObjectCount, + clientRisk, + calcType, + totalPayments: evo_graph.evo_sumpay_withnds, + indAgent, + vehicleTaxInYear, + INNForCalc, + creditRate, + infuranceOPF, + legalClientRegion, + regionRegistration, + legalClientTown, + townRegistration, + calcBroker, + calcFinDepartment, + requirementTelematic, + }, + true, + ); message.success({ content: `КП ${quote?.evo_quotename || ''} загружено!`, diff --git a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/optionsQuery.js b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/optionsQuery.js index 98f6b14..66e5904 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/optionsQuery.js +++ b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/optionsQuery.js @@ -10,10 +10,10 @@ export const mainOptionsQuery = gql` $dealer_person_accountid: Uuid! $dealer_broker_accountid: Uuid! $hasDealerBroker: Boolean! - $ind_agent_accountid: Uuid! + # $ind_agent_accountid: Uuid! $double_agent_accountid: Uuid! - $broker_accountid: Uuid! - $findepartment_accountid: Uuid! + # $broker_accountid: Uuid! + # $findepartment_accountid: Uuid! $evo_gps_brandid: Uuid! ) { selectModel: evo_models(statecode: $statecode, evo_brandid: $evo_brandid) { @@ -74,18 +74,18 @@ export const mainOptionsQuery = gql` evo_reward_summ evo_reduce_reward } - selectIndAgentRewardCondition: evo_reward_conditions( - evo_agent_accountid: $ind_agent_accountid - evo_datefrom_param: { lte: $currentDate } - evo_dateto_param: { gte: $currentDate } - statecode: $statecode - ) { - evo_reward_conditionid - evo_name - evo_double_agent_accountid - evo_reward_summ - evo_reduce_reward - } + # selectIndAgentRewardCondition: evo_reward_conditions( + # evo_agent_accountid: $ind_agent_accountid + # evo_datefrom_param: { lte: $currentDate } + # evo_dateto_param: { gte: $currentDate } + # statecode: $statecode + # ) { + # evo_reward_conditionid + # evo_name + # evo_double_agent_accountid + # evo_reward_summ + # evo_reduce_reward + # } calcDoubleAgentRewardCondition: evo_reward_conditions( evo_agent_accountid: $double_agent_accountid evo_datefrom_param: { lte: $currentDate } @@ -97,28 +97,28 @@ export const mainOptionsQuery = gql` evo_reward_summ evo_reduce_reward } - calcBrokerRewardCondition: evo_reward_conditions( - evo_agent_accountid: $broker_accountid - evo_datefrom_param: { lte: $currentDate } - evo_dateto_param: { gte: $currentDate } - statecode: $statecode - ) { - evo_reward_conditionid - evo_name - evo_reward_summ - evo_reduce_reward - } - selectFinDepartmentRewardCondtion: evo_reward_conditions( - evo_agent_accountid: $findepartment_accountid - evo_datefrom_param: { lte: $currentDate } - evo_dateto_param: { gte: $currentDate } - statecode: $statecode - ) { - evo_reward_conditionid - evo_name - evo_reward_summ - evo_reduce_reward - } + # calcBrokerRewardCondition: evo_reward_conditions( + # evo_agent_accountid: $broker_accountid + # evo_datefrom_param: { lte: $currentDate } + # evo_dateto_param: { gte: $currentDate } + # statecode: $statecode + # ) { + # evo_reward_conditionid + # evo_name + # evo_reward_summ + # evo_reduce_reward + # } + # selectFinDepartmentRewardCondtion: evo_reward_conditions( + # evo_agent_accountid: $findepartment_accountid + # evo_datefrom_param: { lte: $currentDate } + # evo_dateto_param: { gte: $currentDate } + # statecode: $statecode + # ) { + # evo_reward_conditionid + # evo_name + # evo_reward_summ + # evo_reduce_reward + # } selectGPSModel: evo_gps_models( statecode: $statecode evo_gps_brandid: $evo_gps_brandid diff --git a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/quoteQuery.js b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/quoteQuery.js index 678a437..9f74281 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/quoteQuery.js +++ b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/quoteQuery.js @@ -8,7 +8,7 @@ export default gql` evo_addproduct_types { evo_product_type evo_addproduct_typeid - } + } evo_osago_accountid evo_kasko_accountid evo_osago_payer @@ -37,8 +37,6 @@ export default gql` evo_vehicle_tax_year evo_category_tr evo_vehicle_type_tax - evo_req_telematic_accept - evo_req_telematic evo_agent_accountid evo_dealer_person_accountid evo_dealer_broker_accountid @@ -55,6 +53,11 @@ export default gql` evo_osago_price evo_legal_regionid evo_legal_townid + evo_object_count + evo_recalc_limit + evo_req_telematic + evo_req_telematic_accept + evo_accept_control_addproduct_typeid } } `; diff --git a/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts index acebff8..c0595dd 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts @@ -2,6 +2,7 @@ import { openNotification } from 'client/Elements/Notification'; import valuesConstants from 'core/constants/values'; import { IReactionEffect } from 'core/types/Calculation/Store/effect'; import { ElementsNames } from 'core/types/Calculation/Store/elements'; +import { Process } from 'core/types/Calculation/Store/process'; import { TableNames } from 'core/types/Calculation/Store/tables'; import { ElementStatus } from 'core/types/statuses'; import { convertPrice } from '../lib/tools'; @@ -193,17 +194,17 @@ const reactionEffects: IReactionEffect[] = [ calculationStore => ({ expression: () => { - const { quote, recalcWithRevision } = calculationStore.values; - return [quote, recalcWithRevision]; + const { recalcWithRevision } = calculationStore.values; + return recalcWithRevision; }, - effect: ([quoteid, recalcWithRevision]) => { - const quote = calculationStore.getOption('selectQuote', { quoteid }); + effect: recalcWithRevision => { + const quote = calculationStore.getOption('selectQuote'); if (recalcWithRevision) { - if (quote && quote.evo_recalc_limit) { + if (quote?.evo_recalc_limit) { calculationStore.setValue('leaseObjectCount', quote.evo_recalc_limit); } } else { - if (quote && quote.evo_object_count) { + if (quote?.evo_object_count) { calculationStore.setValue('leaseObjectCount', quote.evo_object_count); } } @@ -332,34 +333,127 @@ const reactionEffects: IReactionEffect[] = [ }, }), - calculationStore => ({ + (calculationStore, calculationProcess) => ({ expression: () => { - const recalcWithRevision = calculationStore.getValue( - 'recalcWithRevision', - ); - const leaseObjectType = calculationStore.getOption( - 'selectLeaseObjectType', - ); - return [recalcWithRevision, leaseObjectType]; + return { + recalcWithRevision: calculationStore.getValue('recalcWithRevision'), + leaseObjectType: calculationStore.getOption('selectLeaseObjectType'), + }; }, - effect: ([recalcWithRevision, leaseObjectType]) => { - calculationStore.setStatus( - 'radioRequirementTelematic', - ElementStatus.Default, - ); + effect: ({ recalcWithRevision, leaseObjectType }) => { + if (calculationProcess.hasProcess(Process.LoadKp)) { + return; + } if (!recalcWithRevision) { + const allowedReqTelematicValues = [100000000, 100000001]; calculationStore.setFilter('radioRequirementTelematic', options => - options.filter(x => x.value !== 100000003), + options.filter( + x => + x.value && + typeof x.value === 'number' && + allowedReqTelematicValues.includes(x?.value), + ), ); - if (leaseObjectType.evo_id === '11') { + if (leaseObjectType?.evo_id === '11') { calculationStore.setValue('requirementTelematic', 100000000); calculationStore.setStatus( 'radioRequirementTelematic', ElementStatus.Disabled, ); + } else { + calculationStore.setStatus( + 'radioRequirementTelematic', + ElementStatus.Default, + ); } } else { calculationStore.setFilter('radioRequirementTelematic', undefined); + calculationStore.setStatus( + 'radioRequirementTelematic', + ElementStatus.Disabled, + ); + } + }, + options: { + fireImmediately: true, + }, + }), + + calculationStore => ({ + expression: () => { + return calculationStore.getValue('recalcWithRevision'); + }, + effect: recalcWithRevision => { + if (!recalcWithRevision) { + const quote = calculationStore.getOption('selectQuote'); + if (quote) { + calculationStore.setValue( + 'requirementTelematic', + quote.evo_req_telematic, + ); + let addProducts = Object.assign( + {}, + ...Object.keys(map_add_product_types_to_values).map(valueName => { + const target_add_product_type = quote?.evo_addproduct_types?.find( + x => + x.evo_product_type === + map_add_product_types_to_values[valueName], + ); + + return { + [valueName]: target_add_product_type?.evo_addproduct_typeid, + }; + }), + ); + calculationStore.setValues(addProducts); + } else { + calculationStore.setValue('requirementTelematic', 100000000); + calculationStore.setValue('telematic', null); + + const addProducts = calculationStore.getStaticData( + 'evo_addproduct_type', + ); + const tracker = addProducts.find(x => + x.evo_controls_program?.includes(100000000), + ); + calculationStore.setValue('tracker', tracker?.evo_addproduct_typeid); + } + } else { + calculationStore.setStatus( + 'radioRequirementTelematic', + ElementStatus.Disabled, + ); + } + }, + }), + + (calculationStore, calculationProcess) => ({ + expression: () => { + return calculationStore.getValue('requirementTelematic'); + }, + effect: requirementTelematic => { + if (calculationProcess.hasProcess(Process.LoadKp)) { + return; + } + const recalcWithRevision = calculationStore.getValue( + 'recalcWithRevision', + ); + if (!recalcWithRevision) { + calculationStore.setValue('telematic', null); + + const addProducts = calculationStore.getStaticData( + 'evo_addproduct_type', + ); + let tracker = addProducts.find(x => + x.evo_controls_program?.includes(requirementTelematic), + ); + + calculationStore.setValue('tracker', tracker?.evo_addproduct_typeid); + } else { + calculationStore.setStatus( + 'radioRequirementTelematic', + ElementStatus.Disabled, + ); } }, options: { @@ -368,6 +462,11 @@ const reactionEffects: IReactionEffect[] = [ }), ]; +const map_add_product_types_to_values = { + tracker: 100000003, + telematics: 100000004, +}; + const elementsToDisable: (ElementsNames | TableNames)[] = [ 'tablePayments', 'selectLead', diff --git a/src/client/stores/CalculationStore/config/initialOptions.ts b/src/client/stores/CalculationStore/config/initialOptions.ts index 89a7300..8af8da2 100644 --- a/src/client/stores/CalculationStore/config/initialOptions.ts +++ b/src/client/stores/CalculationStore/config/initialOptions.ts @@ -312,6 +312,10 @@ const initialOptions: TElements = { ], radioRequirementTelematic: [ + { + name: 'Не требуется', + value: 100000004, + }, { name: 'START', value: 100000000, @@ -320,14 +324,26 @@ const initialOptions: TElements = { name: 'START+', value: 100000001, }, - // { - // name: 'COMFORT', - // value: 100000002, - // }, + { + name: 'COMFORT', + value: 100000002, + }, { name: 'COMFORT+', value: 100000003, }, + { + name: 'Omnicomm_1', + value: 100000005, + }, + { + name: 'Omnicomm_2', + value: 100000006, + }, + { + name: 'Omnicomm_3', + value: 100000007, + }, ], radioCalcType: [ { diff --git a/src/core/types/Calculation/Requests.ts b/src/core/types/Calculation/Requests.ts index 1cb884a..7de7477 100644 --- a/src/core/types/Calculation/Requests.ts +++ b/src/core/types/Calculation/Requests.ts @@ -12,7 +12,7 @@ import { CRMEntityNames } from 'core/types/Entities/crmEntityNames'; export interface IQueryToCRMGQL { query: any; toOptions?: CRMEntityNames[] | ElementsNames[]; - variables: { + variables?: { [prop in keyof TCRMEntity]: any; } & { [prop: string]: any }; } diff --git a/src/core/types/Calculation/Store/index.ts b/src/core/types/Calculation/Store/index.ts index a6d7b8e..b8c3614 100644 --- a/src/core/types/Calculation/Store/index.ts +++ b/src/core/types/Calculation/Store/index.ts @@ -60,7 +60,7 @@ interface ICalculationValues { sourceValueName: ValuesNames | ResultValuesNames, newValue: TValue, ) => void; - setValues: (values: TValues) => void; + setValues: (values: TValues, override?: boolean) => void; statuses: TElements; getStatus: (elementName: ElementsNames) => ElementStatus; diff --git a/src/core/types/Entities/crmEntities.ts b/src/core/types/Entities/crmEntities.ts index 3266595..ba4103f 100644 --- a/src/core/types/Entities/crmEntities.ts +++ b/src/core/types/Entities/crmEntities.ts @@ -98,6 +98,9 @@ export interface IQuote { evo_id_elt_osago?: string; evo_object_registration?: number; link?: string; + evo_accept_control_addproduct_typeid?: string; + evo_req_telematic?: number; + evo_req_telematic_accept?: number; } export interface IEvoGraph { diff --git a/src/core/validation/validate.ts b/src/core/validation/validate.ts index 549c120..a59ed31 100644 --- a/src/core/validation/validate.ts +++ b/src/core/validation/validate.ts @@ -1,4 +1,5 @@ import { getValueName } from 'client/Containers/Calculation/lib/elements/tools'; +import { openNotification } from 'client/Elements/Notification'; import { ElementsNames, TElements, @@ -39,3 +40,32 @@ export const getValue = ( }; export const convertToValidationResult = result => ({ isValid: !result }); + +export function showValidationMessages( + validationsResult: TElements, + title: string, +): { hasMessages: boolean } { + let messages: string[] = []; + (Object.keys(validationsResult) as ElementsNames[]).forEach(elementName => { + const elementValidationResult = validationsResult[elementName]; + if (elementValidationResult) { + const { isValid, message } = elementValidationResult; + if (isValid === false && message !== undefined) { + messages.push(message); + } + } + }); + + const hasMessages = messages?.length > 0; + if (hasMessages) { + messages.forEach(message => { + if (message) + openNotification({ + type: 'error', + title, + description: message, + })(); + }); + } + return { hasMessages }; +}