effect for clientrisk

This commit is contained in:
Владислав Чикалкин 2020-09-24 15:56:50 +03:00
parent 55050f6e7d
commit cdf2622969
3 changed files with 57 additions and 2 deletions

View File

@ -10,7 +10,7 @@ const reactionEffects: IReactionEffect[] = [
},
effect: async leadId => {
const lead = calculationStore.options.selectLead?.find(
x => x.value === leadId,
x => x.leadid === leadId,
);
if (lead) {
@ -149,6 +149,57 @@ const reactionEffects: IReactionEffect[] = [
},
}),
calculationStore => ({
expression: () => {
const { lead, opportunity } = calculationStore.values;
return { leadid: lead, opportunityid: opportunity };
},
effect: ({ leadid, opportunityid }) => {
if (opportunityid) {
const opportunity = calculationStore.options.selectOpportunity?.find(
x => x.opportunityid === opportunityid,
);
if (opportunity) {
if (opportunity.evo_client_riskid) {
calculationStore.setValue(
'clientRisk',
opportunity.evo_client_riskid,
);
} else {
CalculationService.getEntityOptions({
entityName: 'account',
where: { accountid: opportunity.evo_accountid },
}).then(accounts => {
calculationStore.setValue(
'clientRisk',
accounts[0].evo_client_riskid || null,
);
});
}
}
} else if (leadid && !opportunityid) {
const lead = calculationStore.options.selectLead?.find(
x => x.leadid === leadid,
);
if (lead) {
if (lead.account) {
CalculationService.getEntityOptions({
entityName: 'account',
where: { accountid: lead.account },
}).then(accounts => {
calculationStore.setValue(
'clientRisk',
accounts[0].evo_client_riskid || null,
);
});
}
}
} else {
calculationStore.setValue('clientRisk', null);
}
},
}),
calculationStore => ({
expression: () => {
const { channel } = calculationStore.values;

View File

@ -102,6 +102,7 @@ const entityFakeData: {
evo_account_type: 100000005,
evo_supplier_type: 100000000,
statecode: 0,
evo_client_riskid: EVO_CLIENT_RISK_1_ID,
},
{
accountid: ACCOUNT_6_ID,
@ -192,8 +193,9 @@ const entityFakeData: {
{
fullname: '176_ООО "С финотделом',
leadid: LEAD_3_ID,
evo_opportunityid: OPPORTUNITY_3_ID,
// evo_opportunityid: OPPORTUNITY_3_ID,
evo_fin_department_accountid: ACCOUNT_5_ID,
account: ACCOUNT_5_ID,
},
],
opportunity: [

View File

@ -16,12 +16,14 @@ export interface ILead extends IBaseOption {
leadid?: string;
fullname?: string;
evo_opportunityid?: string;
account?: string;
}
export interface IOpportunity extends IBaseOption {
opportunityid?: string;
evo_accountid?: string;
evo_leadid?: string;
evo_client_riskid?: string;
}
export interface IQuote extends IBaseOption {