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 bbb883f..de60b9e 100644 --- a/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts +++ b/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts @@ -87,10 +87,10 @@ const customConditions: TElements = { tracker, requirementTelematic, } = calculationStore.getValues([ - 'telematic', - 'tracker', - 'requirementTelematic', - ]); + 'telematic', + 'tracker', + 'requirementTelematic', + ]); if (requirementTelematic !== 100000004 && !telematic && !tracker) { return { @@ -128,6 +128,17 @@ const customConditions: TElements = { 'Первый платеж с учетом субсидии получается отрицательный, увеличьте первый платеж', }; }, + + tbxLeasingPeriod: calculationStore => { + const leasingPeriod = calculationStore.getValue('leasingPeriod'); + const tablePaymentsLength = + calculationStore.tables.tablePayments.rows.length; + return { + isValid: leasingPeriod === tablePaymentsLength, + message: + 'Срок лизинга не соответствует таблице платежей. Необходимо изменить срок лизинга', + }; + }, }; const elementsValidations: TElements = { @@ -156,32 +167,32 @@ const elementsConditions = (Object.keys( elementsValidations, ) as ElementsNames[]).reduce( (ac: TElements, elementName) => { - ac[elementName] = pipe( - getValue, - elementsValidations[elementName], - convertToValidationResult, - ); - return ac; + ac[elementName] = pipe( + getValue, + elementsValidations[elementName], + convertToValidationResult, + ); + return ac; }, {}, ); const entityElementsConditions = ([ - 'selectIndAgentRewardCondition', - 'selectCalcBrokerRewardCondition', - 'selectFinDepartmentRewardCondtion', + 'selectIndAgentRewardCondition', + 'selectCalcBrokerRewardCondition', + 'selectFinDepartmentRewardCondtion', ] as ElementsNames[]).reduce( (ac: TElements, elementName) => { - const valueName = getValueName(elementName); - ac[elementName] = (calculationStore, elementName) => { - if (isNil(calculationStore.getValue(valueName))) { - return { isValid: true }; - } - return { - isValid: calculationStore.getOption(elementName) !== undefined, - }; + const valueName = getValueName(elementName); + ac[elementName] = (calculationStore, elementName) => { + if (isNil(calculationStore.getValue(valueName))) { + return { isValid: true }; + } + return { + isValid: calculationStore.getOption(elementName) !== undefined, }; - return ac; + }; + return ac; }, {}, );