effect: indAgentRewardCondition=>calcDoubleAgent

This commit is contained in:
Владислав Чикалкин 2020-09-24 18:18:34 +03:00
parent 10062ef490
commit 7e5b126de8
2 changed files with 65 additions and 4 deletions

View File

@ -187,10 +187,11 @@ const reactionEffects: IReactionEffect[] = [
entityName: 'account',
where: { accountid: lead.account },
}).then(accounts => {
calculationStore.setValue(
'clientRisk',
accounts[0].evo_client_riskid || null,
);
if (accounts.length > 0)
calculationStore.setValue(
'clientRisk',
accounts[0].evo_client_riskid || null,
);
});
}
}
@ -414,6 +415,65 @@ const reactionEffects: IReactionEffect[] = [
},
}),
calculationStore => ({
expression: () => {
const { indAgentRewardCondition } = calculationStore.values;
return indAgentRewardCondition;
},
effect: indAgentRewardConditionId => {
if (!indAgentRewardConditionId) {
calculationStore.setValue('indAgentRewardSumm', null);
calculationStore.setStatus('tbxIndAgentRewardSumm', Status.Disabled);
const leadId = calculationStore.values.lead;
if (leadId) {
const lead = calculationStore.options.selectLead?.find(
x => x.leadid === leadId,
);
if (lead && !lead.evo_double_agent_accountid) {
calculationStore.setValue('calcDoubleAgent', null);
calculationStore.setStatus(
'selectCalcDoubleAgent',
Status.Disabled,
);
}
}
} else {
const indAgentRewardCondition = calculationStore.options.selectIndAgentRewardCondition?.find(
x => x.evo_reward_conditionid === indAgentRewardConditionId,
);
if (indAgentRewardCondition) {
calculationStore.setValue(
'indAgentRewardSumm',
indAgentRewardCondition.evo_reward_summ,
);
calculationStore.setStatus('tbxIndAgentRewardSumm', Status.Default);
if (indAgentRewardCondition?.evo_double_agent_accountid) {
calculationStore.setStatus('selectCalcDoubleAgent', Status.Default);
const doubleAgent = calculationStore.options.selectDoubleAgent?.find(
x =>
x.evo_agent_accountid ===
indAgentRewardCondition?.evo_double_agent_accountid,
);
if (doubleAgent) {
calculationStore.setOptions('selectDoubleAgent', [doubleAgent]);
calculationStore.setValue(
'calcDoubleAgent',
doubleAgent.evo_double_agent_accountid,
);
}
} else {
calculationStore.setValue('calcDoubleAgent', null);
calculationStore.setStatus(
'selectCalcDoubleAgent',
Status.Disabled,
);
}
}
}
},
}),
calculationStore => ({
expression: () => {
const { channel } = calculationStore.values;

View File

@ -345,6 +345,7 @@ const entityFakeData: {
evo_reward_conditionid: REWARD_CONDITION_1_ID,
evo_name: 'Не более 1.5%',
evo_reward_summ: 1.5,
evo_double_agent_accountid: ACCOUNT_7_ID,
},
{
statecode: 0,