merge release/dyn-200_telematics
This commit is contained in:
parent
19e593dbd8
commit
6e8c9aeb47
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -294,7 +294,7 @@ const elementsProps: TElements<ElementProps> = {
|
||||
showSearch: true,
|
||||
},
|
||||
radioRequirementTelematic: {
|
||||
style: 'button',
|
||||
// style: 'button',
|
||||
},
|
||||
radioQuoteContactGender: {
|
||||
style: 'button',
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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<ValidationCondition> = {
|
||||
}
|
||||
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<any> = {
|
||||
@ -152,4 +183,5 @@ export default function (this: ICalculationStore) {
|
||||
const isValid = validationResult[elementName]?.isValid;
|
||||
if (isValid !== undefined) this.setValidation(elementName, isValid);
|
||||
});
|
||||
showValidationMessages(validationResult, 'Ошибка во время расчета графика');
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -18,4 +18,6 @@ evo_regionid
|
||||
evo_legal_regionid
|
||||
evo_legal_townid
|
||||
link
|
||||
evo_req_telematic
|
||||
evo_req_telematic_accept
|
||||
`;
|
||||
|
||||
@ -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 || ''} загружено!`,
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@ -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',
|
||||
|
||||
@ -312,6 +312,10 @@ const initialOptions: TElements<IBaseOption[]> = {
|
||||
],
|
||||
|
||||
radioRequirementTelematic: [
|
||||
{
|
||||
name: 'Не требуется',
|
||||
value: 100000004,
|
||||
},
|
||||
{
|
||||
name: 'START',
|
||||
value: 100000000,
|
||||
@ -320,14 +324,26 @@ const initialOptions: TElements<IBaseOption[]> = {
|
||||
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: [
|
||||
{
|
||||
|
||||
@ -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 };
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ interface ICalculationValues {
|
||||
sourceValueName: ValuesNames | ResultValuesNames,
|
||||
newValue: TValue,
|
||||
) => void;
|
||||
setValues: (values: TValues<any>) => void;
|
||||
setValues: (values: TValues<any>, override?: boolean) => void;
|
||||
|
||||
statuses: TElements<ElementStatus>;
|
||||
getStatus: (elementName: ElementsNames) => ElementStatus;
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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<ValidationResult>,
|
||||
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 };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user