easy effects
This commit is contained in:
parent
3f6099dc1c
commit
e26f709f5c
@ -465,6 +465,7 @@ const sections: ISections[] = [
|
||||
props: {
|
||||
min: '0',
|
||||
max: '100',
|
||||
step: '1.000000',
|
||||
name: 'tbxLastPaymentPerc',
|
||||
valueName: 'lastPaymentPerc',
|
||||
},
|
||||
@ -1196,7 +1197,7 @@ const sections: ISections[] = [
|
||||
title: 'Франшиза',
|
||||
Component: InputNumber,
|
||||
props: {
|
||||
min: '10000',
|
||||
min: '0',
|
||||
max: '300000',
|
||||
step: '10000.00',
|
||||
name: 'tbxInsFranchise',
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import CalculationService from 'client/services/CalculationService';
|
||||
import { IReactionEffect } from 'core/types/effect';
|
||||
import { Status } from 'core/types/statuses';
|
||||
import { parse } from 'path';
|
||||
|
||||
const reactionEffects: IReactionEffect[] = [
|
||||
calculationStore => ({
|
||||
@ -799,6 +800,207 @@ const reactionEffects: IReactionEffect[] = [
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
calculationStore => ({
|
||||
expression: () => {
|
||||
const { leaseObjectUsed } = calculationStore.values;
|
||||
return leaseObjectUsed;
|
||||
},
|
||||
effect: leaseObjectUsed => {
|
||||
if (leaseObjectUsed) {
|
||||
calculationStore.setValue('leaseObjectCount', 1);
|
||||
calculationStore.setStatus('tbxLeaseObjectCount', Status.Disabled);
|
||||
} else {
|
||||
calculationStore.setStatus('tbxLeaseObjectCount', Status.Default);
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
calculationStore => ({
|
||||
expression: () => {
|
||||
const { insUnlimitDrivers } = calculationStore.values;
|
||||
return insUnlimitDrivers;
|
||||
},
|
||||
effect: insUnlimitDrivers => {
|
||||
if (insUnlimitDrivers) {
|
||||
calculationStore.setStatus('btnDriversApplication', Status.Disabled);
|
||||
} else {
|
||||
calculationStore.setStatus('btnDriversApplication', Status.Default);
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
calculationStore => ({
|
||||
expression: () => {
|
||||
const { insFranchise } = calculationStore.values;
|
||||
return insFranchise;
|
||||
},
|
||||
effect: insFranchise => {
|
||||
if (!insFranchise || parseInt(insFranchise) === 0) {
|
||||
calculationStore.setStatus('btnFranschise', Status.Disabled);
|
||||
} else {
|
||||
calculationStore.setStatus('btnFranschise', Status.Default);
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
calculationStore => ({
|
||||
expression: () => {
|
||||
const { lastPaymentRule } = calculationStore.values;
|
||||
return lastPaymentRule;
|
||||
},
|
||||
effect: lastPaymentRule => {
|
||||
if (lastPaymentRule) {
|
||||
if (lastPaymentRule === 100000000) {
|
||||
calculationStore.setStatus('tbxLastPaymentPerc', Status.Disabled);
|
||||
calculationStore.setStatus('tbxLastPaymentRub', Status.Default);
|
||||
} else {
|
||||
calculationStore.setStatus('tbxLastPaymentPerc', Status.Default);
|
||||
calculationStore.setStatus('tbxLastPaymentRub', Status.Disabled);
|
||||
}
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
calculationStore => ({
|
||||
expression: () => {
|
||||
const { lastPaymentPerc, balanceHolder } = calculationStore.values;
|
||||
return {
|
||||
lastPaymentPerc,
|
||||
balanceHolder,
|
||||
};
|
||||
},
|
||||
effect: ({ lastPaymentPerc, balanceHolder }) => {
|
||||
if (
|
||||
balanceHolder &&
|
||||
balanceHolder === 100000001 &&
|
||||
lastPaymentPerc &&
|
||||
parseInt(lastPaymentPerc) < 1
|
||||
) {
|
||||
/**
|
||||
* TODO: modal=>notification
|
||||
* validation
|
||||
* move to autorun
|
||||
*/
|
||||
calculationStore.showModal(
|
||||
'При балансе лизингодатель последний платеж не может быть меньше 1%! Увеличьте значение.',
|
||||
);
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
calculationStore => ({
|
||||
expression: () => {
|
||||
const { graphType } = calculationStore.values;
|
||||
return graphType;
|
||||
},
|
||||
effect: graphType => {
|
||||
if (graphType) {
|
||||
switch (graphType) {
|
||||
case 100000002: {
|
||||
calculationStore.setStatus('radioSeasonType', Status.Disabled);
|
||||
calculationStore.setStatus(
|
||||
'tbxParmentsDecreasePercent',
|
||||
Status.Default,
|
||||
);
|
||||
calculationStore.setStatus(
|
||||
'selectHighSeasonStart',
|
||||
Status.Disabled,
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
case 100000003: {
|
||||
calculationStore.setStatus('radioSeasonType', Status.Default);
|
||||
calculationStore.setStatus(
|
||||
'tbxParmentsDecreasePercent',
|
||||
Status.Disabled,
|
||||
);
|
||||
calculationStore.setStatus('selectHighSeasonStart', Status.Default);
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
calculationStore.setStatus('radioSeasonType', Status.Disabled);
|
||||
calculationStore.setStatus(
|
||||
'tbxParmentsDecreasePercent',
|
||||
Status.Disabled,
|
||||
);
|
||||
calculationStore.setStatus(
|
||||
'selectHighSeasonStart',
|
||||
Status.Disabled,
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
calculationStore => ({
|
||||
expression: () => {
|
||||
const { seasonType } = calculationStore.values;
|
||||
return seasonType;
|
||||
},
|
||||
effect: seasonType => {
|
||||
if (seasonType) {
|
||||
switch (seasonType) {
|
||||
case 100000001:
|
||||
case 100000002: {
|
||||
calculationStore.setFilter('selectHighSeasonStart', seasons => {
|
||||
return seasons.filter(
|
||||
season => season.value && season.value <= 100000004,
|
||||
);
|
||||
});
|
||||
break;
|
||||
}
|
||||
default:
|
||||
calculationStore.setFilter('selectHighSeasonStart', undefined);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
calculationStore => ({
|
||||
expression: () => {
|
||||
const { leasingPeriod } = calculationStore.values;
|
||||
return leasingPeriod;
|
||||
},
|
||||
effect: leasingPeriod => {
|
||||
if (leasingPeriod) {
|
||||
if (parseInt(leasingPeriod) < 12) {
|
||||
calculationStore.setStatus('radioBalanceHolder', Status.Disabled);
|
||||
calculationStore.setValue('balanceHolder', 100000000);
|
||||
} else {
|
||||
calculationStore.setStatus('radioBalanceHolder', Status.Default);
|
||||
}
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
calculationStore => ({
|
||||
expression: () => {
|
||||
const { balanceHolder } = calculationStore.values;
|
||||
return balanceHolder;
|
||||
},
|
||||
effect: balanceHolder => {
|
||||
if (balanceHolder) {
|
||||
if (balanceHolder === 100000001) {
|
||||
calculationStore.setStatus(
|
||||
'cbxLastPaymentRedemption',
|
||||
Status.Disabled,
|
||||
);
|
||||
calculationStore.setValue('lastPaymentRedemption', true);
|
||||
} else {
|
||||
calculationStore.setStatus(
|
||||
'cbxLastPaymentRedemption',
|
||||
Status.Default,
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
export default reactionEffects;
|
||||
|
||||
@ -66,5 +66,6 @@ const initialValues: TValues<TValue> = {
|
||||
importerRewardPerc: 0,
|
||||
importerRewardRub: 0,
|
||||
disableChecks: false,
|
||||
insFranchise: 0,
|
||||
};
|
||||
export default initialValues;
|
||||
|
||||
@ -13,7 +13,10 @@ export interface ICalculationStore {
|
||||
|
||||
filters: TElements<TElementFilter>;
|
||||
getFilter: (elementName: ElementsNames) => TElementFilter;
|
||||
setFilter: (elementName: ElementsNames, filter: TElementFilter) => void;
|
||||
setFilter: (
|
||||
elementName: ElementsNames,
|
||||
filter: TElementFilter | undefined,
|
||||
) => void;
|
||||
// applyFilters: (filters: TElementFilter[]) => void;
|
||||
|
||||
values: TValues<TValue>;
|
||||
|
||||
Reference in New Issue
Block a user