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..34475c8 100644 --- a/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts +++ b/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts @@ -128,6 +128,58 @@ const customConditions: TElements = { 'Первый платеж с учетом субсидии получается отрицательный, увеличьте первый платеж', }; }, + // TODO: temp (move to tableInsurance validation) + tbxLeasingPeriod: calculationStore => { + const { recalcWithRevision, leasingPeriod } = calculationStore.values; + const quote = calculationStore.getOption('selectQuote'); + const kaskoRowIndex = calculationStore.tables.tableInsurance.rows.findIndex( + x => x.policyType?.value === 'КАСКО', + ); + + const kaskoValues = calculationStore.getTableRowValues( + 'tableInsurance', + kaskoRowIndex, + 'value', + ); + + const kaskoInsTerm = kaskoValues.insTerm; + + if ( + recalcWithRevision && + quote?.evo_one_year_insurance && + leasingPeriod > 16 && + kaskoInsTerm !== 100000000 + ) { + calculationStore.setTableRow( + 'tableInsurance', + kaskoRowIndex, + false, + )({ + insTerm: { + validation: false, + }, + }); + return { + isValid: false, + message: + 'Невозможно включить страховку на весь срок для однолетнего полиса', + }; + } else { + calculationStore.setTableRow( + 'tableInsurance', + kaskoRowIndex, + false, + )({ + insTerm: { + validation: true, + }, + }); + + return { + isValid: true, + }; + } + }, }; const elementsValidations: TElements = { diff --git a/src/client/stores/CalculationStore/Effects/lib/queries.js b/src/client/stores/CalculationStore/Effects/lib/queries.js index f89f6e2..2afc5b0 100644 --- a/src/client/stores/CalculationStore/Effects/lib/queries.js +++ b/src/client/stores/CalculationStore/Effects/lib/queries.js @@ -20,4 +20,5 @@ evo_legal_townid link evo_req_telematic evo_req_telematic_accept +evo_one_year_insurance `; diff --git a/src/core/types/Entities/crmEntities.ts b/src/core/types/Entities/crmEntities.ts index 80b0630..8001258 100644 --- a/src/core/types/Entities/crmEntities.ts +++ b/src/core/types/Entities/crmEntities.ts @@ -101,6 +101,7 @@ export interface IQuote { evo_accept_control_addproduct_typeid?: string; evo_req_telematic?: number; evo_req_telematic_accept?: number; + evo_one_year_insurance?: boolean; } export interface IEvoGraph {