opportunity effect

This commit is contained in:
Владислав Чикалкин 2020-09-24 14:12:44 +03:00
parent 5c23af2b05
commit a4c59277d7
4 changed files with 47 additions and 5 deletions

View File

@ -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 => {

View File

@ -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;

View File

@ -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: [

View File

@ -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 {