From 10062ef490e905df15d0d9239d42eb3c3cb4c806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D1=81=D0=BB=D0=B0=D0=B2=20?= =?UTF-8?q?=D0=A7=D0=B8=D0=BA=D0=B0=D0=BB=D0=BA=D0=B8=D0=BD?= Date: Thu, 24 Sep 2020 17:06:41 +0300 Subject: [PATCH] effect: calcBroker => reward condition --- .../CalculationStore/Effects/reaction.ts | 84 +++++++++++++++++++ src/core/fakeData/entityFakes.ts | 34 +++++++- 2 files changed, 117 insertions(+), 1 deletion(-) diff --git a/src/client/stores/CalculationStore/Effects/reaction.ts b/src/client/stores/CalculationStore/Effects/reaction.ts index 0e481ee..14824ce 100644 --- a/src/client/stores/CalculationStore/Effects/reaction.ts +++ b/src/client/stores/CalculationStore/Effects/reaction.ts @@ -330,6 +330,90 @@ const reactionEffects: IReactionEffect[] = [ }, }), + calculationStore => ({ + expression: () => { + const { calcFinDepartment } = calculationStore.values; + return calcFinDepartment; + }, + effect: calcFinDepartmentId => { + if (!calcFinDepartmentId) { + calculationStore.setValue('finDepartmentRewardCondtion', null); + calculationStore.setStatus( + 'selectFinDepartmentRewardCondtion', + Status.Disabled, + ); + } else { + calculationStore.setValue('finDepartmentRewardCondtion', null); + calculationStore.setStatus( + 'selectFinDepartmentRewardCondtion', + Status.Default, + ); + CalculationService.getEntityOptions({ + entityName: 'evo_reward_condition', + where: { + statecode: 0, + // TODO < > текущей даты + // evo_datefrom: new Date(), + // evo_dateto: new Date(), + evo_agent_accountid: calcFinDepartmentId, + }, + }) + .then(reward_conditions => { + console.log('reward_conditions', reward_conditions); + calculationStore.setOptions( + 'selectFinDepartmentRewardCondtion', + reward_conditions, + ); + }) + .catch(err => { + throw err; + }); + } + }, + }), + + calculationStore => ({ + expression: () => { + const { calcBroker } = calculationStore.values; + return calcBroker; + }, + effect: calcBrokerId => { + if (!calcBrokerId) { + calculationStore.setValue('calcBrokerRewardCondition', null); + calculationStore.setStatus( + 'selectCalcBrokerRewardCondition', + Status.Disabled, + ); + } else { + calculationStore.setValue('calcBrokerRewardCondition', null); + calculationStore.setStatus( + 'selectCalcBrokerRewardCondition', + Status.Default, + ); + CalculationService.getEntityOptions({ + entityName: 'evo_reward_condition', + where: { + statecode: 0, + // TODO < > текущей даты + // evo_datefrom: new Date(), + // evo_dateto: new Date(), + evo_agent_accountid: calcBrokerId, + }, + }) + .then(reward_conditions => { + console.log('reward_conditions', reward_conditions); + calculationStore.setOptions( + 'selectCalcBrokerRewardCondition', + reward_conditions, + ); + }) + .catch(err => { + throw err; + }); + } + }, + }), + calculationStore => ({ expression: () => { const { channel } = calculationStore.values; diff --git a/src/core/fakeData/entityFakes.ts b/src/core/fakeData/entityFakes.ts index 238c09d..9d5f622 100644 --- a/src/core/fakeData/entityFakes.ts +++ b/src/core/fakeData/entityFakes.ts @@ -62,6 +62,10 @@ const REWARD_CONDITION_1_ID = faker.random.uuid(); const REWARD_CONDITION_2_ID = faker.random.uuid(); const REWARD_CONDITION_3_ID = faker.random.uuid(); const REWARD_CONDITION_4_ID = faker.random.uuid(); +const REWARD_CONDITION_5_ID = faker.random.uuid(); +const REWARD_CONDITION_6_ID = faker.random.uuid(); +const REWARD_CONDITION_7_ID = faker.random.uuid(); +const REWARD_CONDITION_8_ID = faker.random.uuid(); /** * Fake Consts @@ -96,7 +100,7 @@ const entityFakeData: { }, { accountid: ACCOUNT_4_ID, - name: 'Финотдел1', + name: 'Брокер', evo_account_type: 100000005, evo_supplier_type: 100000000, statecode: 0, @@ -363,6 +367,34 @@ const entityFakeData: { evo_name: 'Не более 10%', evo_reward_summ: 10, }, + { + statecode: 0, + evo_agent_accountid: ACCOUNT_5_ID, + evo_reward_conditionid: REWARD_CONDITION_5_ID, + evo_name: 'Не более 15%', + evo_reward_summ: 15, + }, + { + statecode: 0, + evo_agent_accountid: ACCOUNT_5_ID, + evo_reward_conditionid: REWARD_CONDITION_6_ID, + evo_name: 'Не более 20%', + evo_reward_summ: 20, + }, + { + statecode: 0, + evo_agent_accountid: ACCOUNT_4_ID, + evo_reward_conditionid: REWARD_CONDITION_7_ID, + evo_name: 'Не более 15%', + evo_reward_summ: 15, + }, + { + statecode: 0, + evo_agent_accountid: ACCOUNT_4_ID, + evo_reward_conditionid: REWARD_CONDITION_8_ID, + evo_name: 'Не более 20%', + evo_reward_summ: 20, + }, ], };