доделали жуткую реакцию по страховке и добавили костыль
This commit is contained in:
parent
92eb52d47d
commit
69512951cd
@ -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) {
|
||||
|
||||
@ -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 =>
|
||||
|
||||
Reference in New Issue
Block a user