effects: final reaction
This commit is contained in:
parent
87662e10d7
commit
cd31f70def
@ -1913,6 +1913,116 @@ const reactionEffects: IReactionEffect[] = [
|
||||
calculationStore.setStatus('cbxRecalcWithRevision', Status.Disabled);
|
||||
},
|
||||
}),
|
||||
|
||||
calculationStore => ({
|
||||
expression: () => {
|
||||
const { firstPaymentPerc } = calculationStore.values;
|
||||
return firstPaymentPerc;
|
||||
},
|
||||
effect: firstPaymentPerc => {
|
||||
const { recalcWithRevision, quote: quoteId } = calculationStore.values;
|
||||
if (recalcWithRevision) {
|
||||
const quote = calculationStore.options.selectQuote?.find(
|
||||
x => x.quoteid === quoteId,
|
||||
);
|
||||
if (quote && quote.evo_approved_first_payment) {
|
||||
if (firstPaymentPerc < quote.evo_approved_first_payment) {
|
||||
calculationStore.setValidation('tbxFirstPaymentPerc', false);
|
||||
openNotification({
|
||||
type: 'error',
|
||||
title: 'Ошибка',
|
||||
description:
|
||||
'Указанный первый платеж меньше одобренного. При пересчете без пересмотра изменение первого платежа возможно только в большую сторону от одобренного значения',
|
||||
})();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
calculationStore.setValidation('tbxFirstPaymentPerc', undefined);
|
||||
},
|
||||
}),
|
||||
|
||||
calculationStore => ({
|
||||
expression: () => {
|
||||
const { brand, model, leaseObjectUsed } = calculationStore.values;
|
||||
return [brand, model, leaseObjectUsed];
|
||||
},
|
||||
effect: ([brandId, modelId, leaseObjectUsed]) => {
|
||||
if (leaseObjectUsed === false) {
|
||||
const model = calculationStore.options.selectModel?.find(
|
||||
x => x.evo_modelid === modelId,
|
||||
);
|
||||
const brand = calculationStore.options.selectBrand?.find(
|
||||
x => x.evo_brandid === brandId,
|
||||
);
|
||||
|
||||
if (
|
||||
model &&
|
||||
model.evo_importer_reward_perc &&
|
||||
model.evo_importer_reward_perc > 0
|
||||
) {
|
||||
calculationStore.setValue(
|
||||
'importerRewardPerc',
|
||||
model.evo_importer_reward_perc,
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (
|
||||
brand &&
|
||||
brand.evo_importer_reward_perc &&
|
||||
brand.evo_importer_reward_perc > 0
|
||||
) {
|
||||
calculationStore.setValue(
|
||||
'importerRewardPerc',
|
||||
brand.evo_importer_reward_perc,
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
calculationStore.setValue('importerRewardPerc', 0);
|
||||
},
|
||||
}),
|
||||
|
||||
calculationStore => ({
|
||||
expression: () => {
|
||||
const { brand, model, leaseObjectUsed } = calculationStore.values;
|
||||
return [brand, model, leaseObjectUsed];
|
||||
},
|
||||
effect: ([brandId, modelId, leaseObjectUsed]) => {
|
||||
if (leaseObjectUsed === false) {
|
||||
const model = calculationStore.options.selectModel?.find(
|
||||
x => x.evo_modelid === modelId,
|
||||
);
|
||||
const brand = calculationStore.options.selectBrand?.find(
|
||||
x => x.evo_brandid === brandId,
|
||||
);
|
||||
|
||||
if (
|
||||
model &&
|
||||
model.evo_importer_reward_rub &&
|
||||
model.evo_importer_reward_rub > 0
|
||||
) {
|
||||
calculationStore.setValue(
|
||||
'importerRewardRub',
|
||||
model.evo_importer_reward_rub,
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (
|
||||
brand &&
|
||||
brand.evo_importer_reward_rub &&
|
||||
brand.evo_importer_reward_rub > 0
|
||||
) {
|
||||
calculationStore.setValue(
|
||||
'importerRewardRub',
|
||||
brand.evo_importer_reward_rub,
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
calculationStore.setValue('importerRewardRub', 0);
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
export default reactionEffects;
|
||||
|
||||
@ -290,6 +290,7 @@ const entityFakeData: {
|
||||
evo_leadid: LEAD_1_ID,
|
||||
evo_recalc_limit: 2,
|
||||
evo_statuscodeid: EVO_STATUSCODE_ID[0],
|
||||
evo_approved_first_payment: 25,
|
||||
},
|
||||
{
|
||||
name: '6789_ООО "с брокером"',
|
||||
@ -533,6 +534,8 @@ const entityFakeData: {
|
||||
{
|
||||
evo_brandid: EVO_BRAND_ID[0],
|
||||
evo_name: 'AUDI',
|
||||
evo_importer_reward_perc: 2,
|
||||
evo_importer_reward_rub: 5000,
|
||||
statecode: 0,
|
||||
},
|
||||
{
|
||||
@ -557,6 +560,8 @@ const entityFakeData: {
|
||||
{
|
||||
evo_modelid: EVO_MODEL_ID[2],
|
||||
evo_name: 'Q7',
|
||||
evo_importer_reward_perc: 5,
|
||||
evo_importer_reward_rub: 10000,
|
||||
evo_brandid: EVO_BRAND_ID[0],
|
||||
statecode: 0,
|
||||
},
|
||||
|
||||
@ -31,6 +31,7 @@ export interface IQuote extends IBaseOption {
|
||||
quotenumber?: string;
|
||||
evo_leadid?: string;
|
||||
evo_recalc_limit?: number;
|
||||
evo_approved_first_payment?: number;
|
||||
}
|
||||
|
||||
export interface ITransactionCurrency extends IBaseOption {
|
||||
@ -67,6 +68,8 @@ export interface IEvoLeasingObjectType extends IBaseOption {
|
||||
export interface IEvoBrand extends IBaseOption {
|
||||
evo_name?: string;
|
||||
evo_brandid?: string;
|
||||
evo_importer_reward_perc?: number;
|
||||
evo_importer_reward_rub?: number;
|
||||
statecode?: number;
|
||||
}
|
||||
|
||||
@ -76,6 +79,8 @@ export interface IEvoModel extends IBaseOption {
|
||||
evo_modelid?: string;
|
||||
evo_impairment_groupid?: string;
|
||||
evo_leasingobject_risk?: number;
|
||||
evo_importer_reward_perc?: number;
|
||||
evo_importer_reward_rub?: number;
|
||||
statecode?: number;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user