validate insurance table onCalculate

This commit is contained in:
vchikalkin 2020-11-27 14:27:55 +03:00
parent 54869d28f3
commit af56bb2566

View File

@ -49,6 +49,40 @@ const validateElements = () => {
});
};
const validateTables = () => {
const tableInsurance = CalculationStore.tables.tableInsurance;
const kaskoRowIndex = tableInsurance.rows.findIndex(
x => x.policyType?.value === 'КАСКО',
);
const osagoRowIndex = tableInsurance.rows.findIndex(
x => x.policyType?.value === 'ОСАГО',
);
const condition =
!CalculationStore.tables.tableInsurance.rows[kaskoRowIndex].insuranceCompany
?.value ||
!CalculationStore.tables.tableInsurance.rows[osagoRowIndex].insuranceCompany
?.value;
CalculationStore.setTableRows(
'tableInsurance',
0,
)([
{
insuranceCompany: {
validation: !condition,
},
},
{
insuranceCompany: {
validation: !condition,
},
},
]);
};
export default () => {
validateElements();
validateTables();
};