recalc: закрываем поля при первом платеже = 0
This commit is contained in:
parent
a9b0eee6bf
commit
40594d377b
@ -356,6 +356,24 @@ const reactionEffects: IReactionEffect[] = [
|
||||
},
|
||||
}),
|
||||
|
||||
(calculationStore, calculationProcess) => ({
|
||||
expression: () =>
|
||||
calculationStore.getValues(['firstPaymentPerc', 'recalcWithRevision']),
|
||||
effect: ({ firstPaymentPerc, recalcWithRevision }) => {
|
||||
if (firstPaymentPerc === 0 && recalcWithRevision === true) {
|
||||
calculationProcess.addToBypass({
|
||||
param: 'status',
|
||||
target: agentsElementsToDisable,
|
||||
});
|
||||
} else {
|
||||
calculationProcess.removeFromByPass({
|
||||
param: 'status',
|
||||
target: agentsElementsToDisable,
|
||||
});
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
(calculationStore, calculationProcess) => ({
|
||||
expression: () => {
|
||||
return {
|
||||
@ -601,4 +619,21 @@ const elementsToDisable: (ElementsNames | TableNames)[] = [
|
||||
'selectSubsidy',
|
||||
];
|
||||
|
||||
// Для recalc = true и первого платежа = 0
|
||||
const agentsElementsToDisable: ElementsNames[] = [
|
||||
'selectDealerRewardCondition',
|
||||
'tbxDealerRewardSumm',
|
||||
'selectDealerBroker',
|
||||
'selectDealerBrokerRewardCondition',
|
||||
'tbxDealerBrokerRewardSumm',
|
||||
'selectIndAgentRewardCondition',
|
||||
'tbxIndAgentRewardSumm',
|
||||
'selectCalcDoubleAgentRewardCondition',
|
||||
'tbxCalcDoubleAgentRewardSumm',
|
||||
'selectCalcBrokerRewardCondition',
|
||||
'tbxCalcBrokerRewardSum',
|
||||
'selectFinDepartmentRewardCondtion',
|
||||
'tbxFinDepartmentRewardSumm',
|
||||
];
|
||||
|
||||
export default reactionEffects;
|
||||
|
||||
@ -4,6 +4,12 @@ import { TableNames } from 'core/types/Calculation/Store/tables';
|
||||
import { ElementStatus } from 'core/types/statuses';
|
||||
import { makeAutoObservable } from 'mobx';
|
||||
|
||||
type BypassParams = {
|
||||
param: ElementParam;
|
||||
target: (ElementsNames | TableNames)[];
|
||||
value: ElementStatus;
|
||||
};
|
||||
|
||||
const calculationProcess = makeAutoObservable({
|
||||
processes: new Set(),
|
||||
addProcess(process) {
|
||||
@ -19,23 +25,26 @@ const calculationProcess = makeAutoObservable({
|
||||
return this.processes.size === 0;
|
||||
},
|
||||
|
||||
//TODO: move to substore
|
||||
bypass: {
|
||||
status: undefined,
|
||||
},
|
||||
setBypass({
|
||||
param,
|
||||
target,
|
||||
value,
|
||||
}: {
|
||||
param: ElementParam;
|
||||
target: (ElementsNames | TableNames)[];
|
||||
value: ElementStatus;
|
||||
}) {
|
||||
setBypass({ param, target, value }: BypassParams) {
|
||||
this.bypass[param] = { target, value };
|
||||
},
|
||||
clearBypass(param: ElementParam) {
|
||||
this.bypass[param] = undefined;
|
||||
},
|
||||
addToBypass({ param, target }: Omit<BypassParams, 'value'>) {
|
||||
const newTarget = this.bypass[param].target.concat(target);
|
||||
this.bypass[param].target.replace(newTarget);
|
||||
},
|
||||
removeFromByPass({ param, target }: Omit<BypassParams, 'value'>) {
|
||||
const newTarget = this.bypass[param].target.filter(
|
||||
x => target.indexOf(x) < 0,
|
||||
);
|
||||
this.bypass[param].target.replace(newTarget);
|
||||
},
|
||||
});
|
||||
|
||||
export default calculationProcess;
|
||||
|
||||
Reference in New Issue
Block a user