diff --git a/src/client/Containers/Calculation/index.jsx b/src/client/Containers/Calculation/index.jsx index 9f53fe0..0c8d06c 100644 --- a/src/client/Containers/Calculation/index.jsx +++ b/src/client/Containers/Calculation/index.jsx @@ -24,10 +24,14 @@ const Calculation = () => { fields: undefined, where: undefined, }), + CalculationService.getEntityOptions({ + entityName: 'opportunity', + }), ]) - .then(([initialOptions, leadOptions]) => { + .then(([initialOptions, leadOptions, opportunities]) => { calculationStore.applyOptions({ ...initialOptions }); calculationStore.applyOptions({ selectLead: leadOptions }); + calculationStore.applyOptions({ selectOpportunity: opportunities }); setReady(true); }) .catch(err => { diff --git a/src/client/stores/CalculationStore/Effects/reaction.ts b/src/client/stores/CalculationStore/Effects/reaction.ts index 7cd25cb..52cea24 100644 --- a/src/client/stores/CalculationStore/Effects/reaction.ts +++ b/src/client/stores/CalculationStore/Effects/reaction.ts @@ -133,6 +133,22 @@ const reactionEffects: IReactionEffect[] = [ }, }), + calculationStore => ({ + expression: () => { + const { opportunity } = calculationStore.values; + return opportunity; + }, + effect: opportunityId => { + const opportunity = calculationStore.options.selectOpportunity?.find( + x => x.opportunityid === opportunityId, + ); + + if (opportunity) { + calculationStore.setValue('lead', opportunity.evo_leadid); + } + }, + }), + calculationStore => ({ expression: () => { const { channel } = calculationStore.values; diff --git a/src/core/fakeData/entityFakes.ts b/src/core/fakeData/entityFakes.ts index 43a0a7f..9bcbdfd 100644 --- a/src/core/fakeData/entityFakes.ts +++ b/src/core/fakeData/entityFakes.ts @@ -15,6 +15,7 @@ const ACCOUNT_6_ID = faker.random.uuid(); const ACCOUNT_7_ID = faker.random.uuid(); const ACCOUNT_8_ID = faker.random.uuid(); const ACCOUNT_9_ID = faker.random.uuid(); +const ACCOUNT_10_ID = faker.random.uuid(); const LEAD_1_ID = faker.random.uuid(); const LEAD_2_ID = faker.random.uuid(); @@ -22,6 +23,7 @@ const LEAD_3_ID = faker.random.uuid(); const OPPORTUNITY_1_ID = faker.random.uuid(); const OPPORTUNITY_2_ID = faker.random.uuid(); +const OPPORTUNITY_3_ID = faker.random.uuid(); const QUOTE_1_ID = faker.random.uuid(); const QUOTE_2_ID = faker.random.uuid(); @@ -129,6 +131,13 @@ const entityFakeData: { evo_legal_form: 100000004, statecode: 0, }, + { + accountid: ACCOUNT_10_ID, + name: 'Клиент 1', + evo_account_type: 100000000, + evo_client_riskid: EVO_CLIENT_RISK_2_ID, + statecode: 0, + }, ], transactioncurrency: [ { @@ -177,24 +186,35 @@ const entityFakeData: { { fullname: '150_ООО "с брокером', leadid: LEAD_2_ID, - // evo_opportunityid: OPPORTUNITY_2_ID, + evo_opportunityid: OPPORTUNITY_2_ID, evo_broker_accountid: ACCOUNT_4_ID, }, { fullname: '176_ООО "С финотделом', leadid: LEAD_3_ID, - // evo_opportunityid: OPPORTUNITY_2_ID, + evo_opportunityid: OPPORTUNITY_3_ID, evo_fin_department_accountid: ACCOUNT_5_ID, }, ], opportunity: [ { - name: '112345_ООО "с агентами ФЛ', + name: '112345_ООО "с агентами ФЛ с риском', opportunityid: OPPORTUNITY_1_ID, + evo_client_riskid: EVO_CLIENT_RISK_1_ID, + evo_leadid: LEAD_1_ID, }, { - name: '145678_ООО "с брокером', + name: '145678_ООО "с брокером и риском в клиенте', opportunityid: OPPORTUNITY_2_ID, + evo_accountid: ACCOUNT_10_ID, + // evo_client_riskid: EVO_CLIENT_RISK_2_ID, + evo_leadid: LEAD_2_ID, + }, + { + name: '346343_ООО "с брокером и риском в интересе', + opportunityid: OPPORTUNITY_3_ID, + evo_accountid: ACCOUNT_9_ID, + evo_leadid: LEAD_3_ID, }, ], quote: [ diff --git a/src/core/types/Entities/index.ts b/src/core/types/Entities/index.ts index 3135cb6..7be4316 100644 --- a/src/core/types/Entities/index.ts +++ b/src/core/types/Entities/index.ts @@ -20,6 +20,8 @@ export interface ILead extends IBaseOption { export interface IOpportunity extends IBaseOption { opportunityid?: string; + evo_accountid?: string; + evo_leadid?: string; } export interface IQuote extends IBaseOption {