last fixes for db21b16
This commit is contained in:
parent
9c87172a58
commit
86fe6ffd2c
@ -1,4 +1,3 @@
|
||||
import { numberElementsProps } from 'client/Containers/Calculation/Elements/props/common';
|
||||
import { getValueName } from 'client/Containers/Calculation/Elements/tools';
|
||||
import { ElementsNames } from 'client/Containers/Calculation/types/elements';
|
||||
import { pipe } from 'core/tools/func';
|
||||
@ -193,30 +192,11 @@ const entityElementsConditions = (
|
||||
{},
|
||||
);
|
||||
|
||||
/** Проверяем по настройкам полей min max */
|
||||
const numberElementsConditions = Object.keys(numberElementsProps).reduce(
|
||||
(acc, elem) => {
|
||||
acc[elem] = (calculationStore, elementName) => {
|
||||
const valueName = getValueName(elementName);
|
||||
const value = calculationStore.getValue(valueName);
|
||||
const { min, max } = numberElementsProps[elem];
|
||||
return {
|
||||
isValid:
|
||||
(min === undefined || value >= min) &&
|
||||
(max === undefined || value <= max),
|
||||
};
|
||||
};
|
||||
return acc;
|
||||
},
|
||||
{} as Partial<Record<ElementsNames, ValidationCondition>>,
|
||||
);
|
||||
|
||||
const conditions = Object.assign(
|
||||
{},
|
||||
customConditions,
|
||||
elementsConditions,
|
||||
entityElementsConditions,
|
||||
numberElementsConditions,
|
||||
);
|
||||
|
||||
export default function (this: ICalculationStore) {
|
||||
|
||||
@ -487,9 +487,7 @@ const reactionEffects: IReactionEffect[] = [
|
||||
|
||||
calculationStore => ({
|
||||
expression: () => {
|
||||
const { lastPaymentRub, lastPaymentPerc, insNSIB } =
|
||||
calculationStore.values;
|
||||
return { lastPaymentRub, lastPaymentPerc, insNSIB };
|
||||
return calculationStore.getValues(['lastPaymentRub', 'insNSIB']);
|
||||
},
|
||||
effect: ({ lastPaymentRub, insNSIB }) => {
|
||||
if (insNSIB && lastPaymentRub && lastPaymentRub < 3500) {
|
||||
@ -500,18 +498,9 @@ const reactionEffects: IReactionEffect[] = [
|
||||
description:
|
||||
'Последний платеж меньше 3500 руб. не может быть при наличии НСИБ, укажите большее значение',
|
||||
})();
|
||||
return;
|
||||
} else if (lastPaymentRub && lastPaymentRub < 1000) {
|
||||
calculationStore.setValidation('tbxLastPaymentRub', false);
|
||||
openNotification({
|
||||
type: 'error',
|
||||
title: 'Ошибка',
|
||||
description:
|
||||
'Последний платеж меньше 1000 руб. не может быть, укажите большее значение',
|
||||
})();
|
||||
return;
|
||||
} else {
|
||||
calculationStore.setValidation('tbxLastPaymentRub', true);
|
||||
}
|
||||
calculationStore.setValidation('tbxLastPaymentRub', true);
|
||||
},
|
||||
}),
|
||||
|
||||
|
||||
@ -540,7 +540,11 @@ const reactionEffects: IReactionEffect[] = [
|
||||
|
||||
calculationStore => ({
|
||||
expression: () =>
|
||||
calculationStore.getValues(['lastPaymentPerc', 'balanceHolder']),
|
||||
calculationStore.getValues([
|
||||
'lastPaymentPerc',
|
||||
'balanceHolder',
|
||||
'lastPaymentRule',
|
||||
]),
|
||||
effect: ({ lastPaymentPerc, balanceHolder }) => {
|
||||
if (balanceHolder && balanceHolder === 100000001) {
|
||||
if (!lastPaymentPerc || parseFloat(lastPaymentPerc) < 1) {
|
||||
|
||||
Reference in New Issue
Block a user