quote x recalcwithoutrevision reactions

This commit is contained in:
Chika 2021-01-22 17:27:23 +03:00
parent bbdf1becbe
commit 28616bb8e4
4 changed files with 66 additions and 36 deletions

View File

@ -49,7 +49,7 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
if (!quoteId) {
return;
}
const { lead, opportunity } = calculationStore.values;
const { lead, opportunity, recalcWithRevision } = calculationStore.values;
calculationStore.setStatus('selectQuote', ElementStatus.Disabled);
calculationStore.setStatus('btnCalculate', ElementStatus.Disabled);
@ -228,6 +228,7 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
lead,
opportunity,
quote: quoteId,
recalcWithRevision,
});
message.success({

View File

@ -1290,12 +1290,23 @@ const reactionEffects: IReactionEffect[] = [
supplierDiscountRub,
leaseObjectPrice,
supplierCurrency,
recalcWithRevision,
} = calculationStore.values;
return [supplierDiscountRub, leaseObjectPrice, supplierCurrency];
return [
supplierDiscountRub,
leaseObjectPrice,
supplierCurrency,
recalcWithRevision,
];
},
effect: ([supplierDiscountRub, leaseObjectPrice, supplierCurrencyId]) => {
const { recalcWithRevision, maxPriceChange } = calculationStore.values;
if (recalcWithRevision === false) {
effect: ([
supplierDiscountRub,
leaseObjectPrice,
supplierCurrencyId,
recalcWithRevision,
]) => {
if (!recalcWithRevision) {
calculationStore.setValidation('tbxLeaseObjectPrice', undefined);
return;
}
@ -1313,17 +1324,24 @@ const reactionEffects: IReactionEffect[] = [
evo_currencychangeValue,
);
if (price - supplierDiscountRub > maxPriceChange) {
calculationStore.setValidation('tbxLeaseObjectPrice', false);
openNotification({
type: 'error',
title: 'Ошибка',
description:
'Указанная стоимость предмета лизинга больше возмножного изменения стоимости предмета лизинга при пересчете без пересмотра.' +
'Уменьшите стоимость предмета лизинга',
})();
} else {
calculationStore.setValidation('tbxLeaseObjectPrice', true);
const { quote: quoteId } = calculationStore.values;
const quote = calculationStore.options.selectQuote?.find(
x => x.value === quoteId,
);
if (quote && quote.evo_max_price_change) {
if (price - supplierDiscountRub > quote.evo_max_price_change) {
calculationStore.setValidation('tbxLeaseObjectPrice', false);
openNotification({
type: 'error',
title: 'Ошибка',
description:
'Указанная стоимость предмета лизинга больше возмножного изменения стоимости предмета лизинга при пересчете без пересмотра. ' +
'Уменьшите стоимость предмета лизинга',
})();
} else {
calculationStore.setValidation('tbxLeaseObjectPrice', undefined);
}
}
},
}),
@ -1369,29 +1387,32 @@ const reactionEffects: IReactionEffect[] = [
calculationStore => ({
expression: () => {
const { firstPaymentPerc } = calculationStore.values;
return firstPaymentPerc;
const { firstPaymentPerc, recalcWithRevision } = calculationStore.values;
return { firstPaymentPerc, recalcWithRevision };
},
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;
}
effect: ({ firstPaymentPerc, recalcWithRevision }) => {
if (!recalcWithRevision) {
calculationStore.setValidation('tbxFirstPaymentPerc', undefined);
return;
}
const { quote: quoteId } = calculationStore.values;
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:
'Указанный первый платеж меньше одобренного. При пересчете без пересмотра изменение первого платежа возможно только в большую сторону от одобренного значения',
})();
} else {
calculationStore.setValidation('tbxFirstPaymentPerc', undefined);
}
}
calculationStore.setValidation('tbxFirstPaymentPerc', undefined);
},
}),

View File

@ -61,6 +61,10 @@ export default [
evo_statuscode: evo_statuscodeidData {
evo_id
}
evo_max_price_change
evo_max_mass
evo_seats
evo_year
}
}
`,

View File

@ -72,6 +72,10 @@ export interface IQuote {
evo_period?: number;
evo_first_payment_perc?: number;
evo_last_payment_perc?: number;
evo_max_price_change?: number;
evo_max_mass?: number;
evo_seats?: number;
evo_year?: number;
}
interface IEvoGraph {