validation: check leasePeriod = payments.length
This commit is contained in:
parent
aa33605d90
commit
1765925e93
@ -87,10 +87,10 @@ const customConditions: TElements<ValidationCondition> = {
|
||||
tracker,
|
||||
requirementTelematic,
|
||||
} = calculationStore.getValues([
|
||||
'telematic',
|
||||
'tracker',
|
||||
'requirementTelematic',
|
||||
]);
|
||||
'telematic',
|
||||
'tracker',
|
||||
'requirementTelematic',
|
||||
]);
|
||||
|
||||
if (requirementTelematic !== 100000004 && !telematic && !tracker) {
|
||||
return {
|
||||
@ -128,6 +128,17 @@ const customConditions: TElements<ValidationCondition> = {
|
||||
'Первый платеж с учетом субсидии получается отрицательный, увеличьте первый платеж',
|
||||
};
|
||||
},
|
||||
|
||||
tbxLeasingPeriod: calculationStore => {
|
||||
const leasingPeriod = calculationStore.getValue('leasingPeriod');
|
||||
const tablePaymentsLength =
|
||||
calculationStore.tables.tablePayments.rows.length;
|
||||
return {
|
||||
isValid: leasingPeriod === tablePaymentsLength,
|
||||
message:
|
||||
'Срок лизинга не соответствует таблице платежей. Необходимо изменить срок лизинга',
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
const elementsValidations: TElements<any> = {
|
||||
@ -156,32 +167,32 @@ const elementsConditions = (Object.keys(
|
||||
elementsValidations,
|
||||
) as ElementsNames[]).reduce(
|
||||
(ac: TElements<ValidationCondition>, elementName) => {
|
||||
ac[elementName] = pipe(
|
||||
getValue,
|
||||
elementsValidations[elementName],
|
||||
convertToValidationResult,
|
||||
);
|
||||
return ac;
|
||||
ac[elementName] = pipe(
|
||||
getValue,
|
||||
elementsValidations[elementName],
|
||||
convertToValidationResult,
|
||||
);
|
||||
return ac;
|
||||
},
|
||||
{},
|
||||
);
|
||||
|
||||
const entityElementsConditions = ([
|
||||
'selectIndAgentRewardCondition',
|
||||
'selectCalcBrokerRewardCondition',
|
||||
'selectFinDepartmentRewardCondtion',
|
||||
'selectIndAgentRewardCondition',
|
||||
'selectCalcBrokerRewardCondition',
|
||||
'selectFinDepartmentRewardCondtion',
|
||||
] as ElementsNames[]).reduce(
|
||||
(ac: TElements<ValidationCondition>, elementName) => {
|
||||
const valueName = getValueName(elementName);
|
||||
ac[elementName] = (calculationStore, elementName) => {
|
||||
if (isNil(calculationStore.getValue(valueName))) {
|
||||
return { isValid: true };
|
||||
}
|
||||
return {
|
||||
isValid: calculationStore.getOption(elementName) !== undefined,
|
||||
};
|
||||
const valueName = getValueName(elementName);
|
||||
ac[elementName] = (calculationStore, elementName) => {
|
||||
if (isNil(calculationStore.getValue(valueName))) {
|
||||
return { isValid: true };
|
||||
}
|
||||
return {
|
||||
isValid: calculationStore.getOption(elementName) !== undefined,
|
||||
};
|
||||
return ac;
|
||||
};
|
||||
return ac;
|
||||
},
|
||||
{},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user