доделали жуткую реакцию по страховке и добавили костыль

This commit is contained in:
Chika 2022-09-27 16:09:34 +03:00
parent 92eb52d47d
commit 69512951cd
2 changed files with 49 additions and 1 deletions

View File

@ -122,6 +122,49 @@ function validateInsuranceTable(this: ICalculationStore) {
},
});
}
/**
* Самый откровенный костыль в истории калькулятора,
* потому что мне сейчас лень добавлять проверку текущего значения
* в отфильтрованном списке опций в таблице,
* да и это не имеет смысла
* (связано с самой жуткой реакцией по страховке)
*
* TODO: Для нового калькулятора:
* вместо костыля сбрасывать значение КАСКО на дефолтное, если текущего значения нет в списке опций
*
*/
const leasingWithoutKasko = this.getValue('leasingWithoutKasko');
const otherInsuranceCompany =
this.tables.tableInsurance.options?.insuranceCompany?.find(x =>
x.name?.includes('ПРОЧИЕ'),
);
if (
!leasingWithoutKasko &&
kaskoRow.insuranceCompany === otherInsuranceCompany?.value
) {
this.setTableRow('tableInsurance', rows =>
rows.findIndex(x => x?.key === 'kasko'),
)({
insuranceCompany: {
validation: false,
},
});
openNotification({
type: 'error',
message: 'Ошибка',
description: 'Укажите страховую компанию КАСКО из списка',
});
} else {
this.setTableRow('tableInsurance', rows =>
rows.findIndex(x => x?.key === 'kasko'),
)({
insuranceCompany: {
validation: undefined,
},
});
}
}
function validatePaymentsTable(this: ICalculationStore) {

View File

@ -147,6 +147,7 @@ export default [
},
}),
// самая жуткая реакция по страховке
(calculationStore, calculationProcess) => ({
expression: () => {
const { leasingPeriod, leasingWithoutKasko } = calculationStore.values;
@ -230,7 +231,11 @@ export default [
calculationStore.setTableRow('tableInsurance', rows =>
rows.findIndex(x => x?.key === 'kasko'),
)({
insuranceCompany: { filter: insuranceKaskoDefaultFilter },
insuranceCompany: {
filter: insuranceKaskoDefaultFilter,
status: ElementStatus.Default,
},
insCost: { status: ElementStatus.Default },
});
calculationStore.setTableRow('tableInsurance', rows =>