diff --git a/src/client/Components/Calculation/ELT/Content/Kasko/lib/validation.ts b/src/client/Components/Calculation/ELT/Content/Kasko/lib/validation.ts index f16bf9b..5b445b0 100644 --- a/src/client/Components/Calculation/ELT/Content/Kasko/lib/validation.ts +++ b/src/client/Components/Calculation/ELT/Content/Kasko/lib/validation.ts @@ -10,14 +10,13 @@ export const requiredFields: ElementsNames[] = [ 'cbxLeaseObjectUsed', 'tbxLeaseObjectYear', 'tbxLeaseObjectMotorPower', - 'selectEngineType', 'tbxLeasingPeriod', 'tbxLeaseObjectPrice', 'tbxSupplierDiscountRub', 'tbxInsFranchise', - 'selectLeaseObjectCategory', 'selectLeaseObjectUseFor', 'tbxINNForCalc', + 'radioInfuranceOPF', ]; export const conditions: TElements = { @@ -62,6 +61,46 @@ export const conditions: TElements = { isValid: true, }; }, + selectLeaseObjectCategory: calculationStore => { + const leaseObjectCategory = calculationStore.getValue( + 'leaseObjectCategory', + ); + const leaseObjectType = calculationStore.getOption('selectLeaseObjectType'); + + if (!leaseObjectCategory) { + if (['6', '10'].includes(leaseObjectType?.evo_id || '')) { + return { + isValid: true, + }; + } else + return { + isValid: false, + message: 'Не указана категория ТС', + }; + } + + return { + isValid: true, + }; + }, + selectEngineType: calculationStore => { + const engineType = calculationStore.getValue('engineType'); + + if (!engineType) { + if (['8'].includes(engineType?.evo_id || '')) + return { + isValid: true, + }; + else + return { + isValid: false, + message: 'Не указан тип двигателя', + }; + } + return { + isValid: true, + }; + }, }; export const resetFields: ElementsNames[] = [ diff --git a/src/client/Components/Calculation/ELT/Content/Osago/lib/composeRequest.ts b/src/client/Components/Calculation/ELT/Content/Osago/lib/composeRequest.ts index 4bb10d7..12ce35c 100644 --- a/src/client/Components/Calculation/ELT/Content/Osago/lib/composeRequest.ts +++ b/src/client/Components/Calculation/ELT/Content/Osago/lib/composeRequest.ts @@ -11,7 +11,7 @@ const mapCategory = { }; const mapSubCategoryBuilder = (leaseObjectUseFor, maxMass, countSeats) => ({ - 100000000: '0', + 100000000: () => '0', 100000001: () => { if (leaseObjectUseFor === 100000001) { return '11'; @@ -70,7 +70,8 @@ export default function (this: ICalculationStore) { maxMass, countSeats, ); - const subCategory = mapSubCategory[leaseObjectCategory](); + + const subCategory = get(mapSubCategory, leaseObjectCategory, () => '0')(); let seatingCapacity = 0; if (leaseObjectCategory === 100000003) { diff --git a/src/client/Components/Calculation/ELT/Content/Osago/lib/validation.ts b/src/client/Components/Calculation/ELT/Content/Osago/lib/validation.ts index d31a3de..5ed8295 100644 --- a/src/client/Components/Calculation/ELT/Content/Osago/lib/validation.ts +++ b/src/client/Components/Calculation/ELT/Content/Osago/lib/validation.ts @@ -3,6 +3,7 @@ import { TElements, } from 'core/types/Calculation/Store/elements'; import { ValidationCondition } from 'core/validation/validate'; +import { omit } from 'lodash'; import { conditions as kaskoConditions } from '../../Kasko/lib/validation'; export const requiredFields: ElementsNames[] = [ @@ -16,9 +17,9 @@ export const requiredFields: ElementsNames[] = [ 'tbxMaxMass', 'tbxCountSeats', 'cbxWithTrailer', - 'selectLeaseObjectCategory', 'tbxINNForCalc', 'radioObjectRegistration', + 'radioInfuranceOPF', ]; const conditions: TElements = { @@ -50,5 +51,8 @@ export const resetFields: ElementsNames[] = [ export default { requiredFields, - conditions: Object.assign(conditions, kaskoConditions), + conditions: Object.assign( + conditions, + omit(kaskoConditions, ['selectEngineType']), + ), };