effects: quote

This commit is contained in:
Chika 2020-09-30 14:34:15 +03:00
parent 420f9bdb57
commit 87662e10d7
4 changed files with 77 additions and 2 deletions

View File

@ -1870,6 +1870,49 @@ const reactionEffects: IReactionEffect[] = [
}
},
}),
calculationStore => ({
expression: () => {
const { quote } = calculationStore.values;
return quote;
},
effect: quoteId => {
if (quoteId) {
const quote = calculationStore.options.selectQuote?.find(
x => x.quoteid === quoteId,
);
if (quote) {
if (quote.evo_recalc_limit && quote.evo_recalc_limit > 0) {
if (quote.evo_statuscodeid) {
CalculationService.getEntityOptions({
entityName: 'evo_statuscode',
where: {
evo_statuscodeid: quote.evo_statuscodeid,
statecode: 0,
},
})
.then(evo_statuscodes => {
if (evo_statuscodes && evo_statuscodes.length > 0) {
const evo_statuscode = evo_statuscodes[0];
if (evo_statuscode.evo_id === '2.3') {
calculationStore.setStatus(
'cbxRecalcWithRevision',
Status.Default,
);
return;
}
}
})
.catch(err => {
throw err;
});
}
}
}
}
calculationStore.setStatus('cbxRecalcWithRevision', Status.Disabled);
},
}),
];
export default reactionEffects;

View File

@ -93,6 +93,7 @@ const EVO_IMPAIRMENT_GROUP_ID = Array.from({ length: 10 }, () =>
const EVO_CURRENCY_CHANGE_ID = Array.from({ length: 5 }, () =>
faker.random.uuid(),
);
const EVO_STATUSCODE_ID = Array.from({ length: 5 }, () => faker.random.uuid());
/**
* Fake Consts
@ -287,6 +288,8 @@ const entityFakeData: {
name: '2345_ООО "с агентами ФЛ"',
quoteid: QUOTE_1_ID,
evo_leadid: LEAD_1_ID,
evo_recalc_limit: 2,
evo_statuscodeid: EVO_STATUSCODE_ID[0],
},
{
name: '6789_ООО "с брокером"',
@ -297,12 +300,16 @@ const entityFakeData: {
name: '4567_ООО "с агентами ФЛ"',
quoteid: QUOTE_3_ID,
evo_leadid: LEAD_1_ID,
evo_recalc_limit: 1,
evo_statuscodeid: EVO_STATUSCODE_ID[1],
},
{
name: '5678_ООО "с агентами ФЛ"',
quoteid: QUOTE_4_ID,
evo_leadid: LEAD_1_ID,
evo_broker_accountid: ACCOUNT_5_ID,
evo_recalc_limit: 0,
evo_statuscodeid: EVO_STATUSCODE_ID[0],
},
],
evo_gps_brand: [
@ -632,6 +639,20 @@ const entityFakeData: {
statecode: 0,
},
],
evo_statuscode: [
{
evo_statuscodeid: EVO_STATUSCODE_ID[0],
evo_id: '2.3',
evo_name: 'Положительное решение',
statecode: 0,
},
{
evo_statuscodeid: EVO_STATUSCODE_ID[1],
evo_id: '2.2',
evo_name: 'Одобрено клиентом',
statecode: 0,
},
],
};
export default entityFakeData;

View File

@ -20,4 +20,5 @@ export type EntityNames =
| 'connection'
| 'evo_connection_role'
| 'evo_impairment_group'
| 'evo_currencychange';
| 'evo_currencychange'
| 'evo_statuscode';

View File

@ -30,6 +30,7 @@ export interface IQuote extends IBaseOption {
quoteid?: string;
quotenumber?: string;
evo_leadid?: string;
evo_recalc_limit?: number;
}
export interface ITransactionCurrency extends IBaseOption {
@ -154,6 +155,14 @@ export interface IEvoCurrencyChange extends IBaseOption {
statecode?: number;
}
export interface IEvoStatusCode extends IBaseOption {
evo_statuscodeid?: string;
evo_id?: string;
evo_name?: string;
importsequencenumber?: number;
statecode?: number;
}
export type TEntity = IAccount &
ILead &
IOpportunity &
@ -175,4 +184,5 @@ export type TEntity = IAccount &
IConnection &
IEvoConnectionRole &
IEvoImpairmentGroup &
IEvoCurrencyChange;
IEvoCurrencyChange &
IEvoStatusCode;