diff --git a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts index 8edc38f..7f1f146 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts @@ -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({ diff --git a/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts index 9cbdefd..c0a39ab 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts @@ -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); }, }), diff --git a/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts index d8be280..001b9e0 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts @@ -61,6 +61,10 @@ export default [ evo_statuscode: evo_statuscodeidData { evo_id } + evo_max_price_change + evo_max_mass + evo_seats + evo_year } } `, diff --git a/src/core/types/Entities/crmEntities.ts b/src/core/types/Entities/crmEntities.ts index addf0e1..bf52cc3 100644 --- a/src/core/types/Entities/crmEntities.ts +++ b/src/core/types/Entities/crmEntities.ts @@ -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 {