From db21b16c6f82e38b6151bdff53411a1566694f3f Mon Sep 17 00:00:00 2001 From: Chika Date: Thu, 3 Feb 2022 16:30:00 +0300 Subject: [PATCH] =?UTF-8?q?DYN-829:=20=D0=A0=D0=B0=D1=81=D1=87=D0=B5=D1=82?= =?UTF-8?q?=20=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=D0=B4=D0=BD=D0=B5=D0=B3=D0=BE?= =?UTF-8?q?=20=D0=BB=D0=B8=D0=B7=D0=B8=D0=BD=D0=B3=D0=BE=D0=B2=D0=BE=D0=B3?= =?UTF-8?q?=D0=BE=20=D0=BF=D0=BB=D0=B0=D1=82=D0=B5=D0=B6=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Containers/Calculation/Elements/titles.ts | 2 +- .../Effects/actions/calculate/prepareData.ts | 1 + .../Effects/actions/calculate/results.ts | 5 +++++ .../Effects/reactions/otherReactions.ts | 19 ++++++++++++++++--- .../Effects/reactions/priceReactions/index.ts | 4 ++-- .../CalculationStore/config/initialOptions.ts | 8 ++++++-- .../CalculationService/types/prepared.ts | 1 + 7 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/client/Containers/Calculation/Elements/titles.ts b/src/client/Containers/Calculation/Elements/titles.ts index 3b559b7..9cec879 100644 --- a/src/client/Containers/Calculation/Elements/titles.ts +++ b/src/client/Containers/Calculation/Elements/titles.ts @@ -17,7 +17,7 @@ export const elementsTitles: Partial> = { tbxFirstPaymentRub: 'Первый платеж, руб.', tbxLastPaymentPerc: 'Последний платеж, %', tbxLastPaymentRub: 'Последний платеж, руб.', - radioLastPaymentRule: 'Последний платеж считается от ', + radioLastPaymentRule: 'Последний платеж', tbxRedemptionPaymentSum: 'Сумма выкупного платежа, руб', radioBalanceHolder: 'Балансодержатель', radioGraphType: 'Вид графика', diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts index 816de37..2b26685 100644 --- a/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts +++ b/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts @@ -109,6 +109,7 @@ export default function (this: ICalculationStore): PreparedData { preparedValues.firstPaymentAbs = undefined; preparedValues.firstPaymentNdsAbs = undefined; preparedValues.firstPaymentWithNdsAbs = undefined; + preparedValues.lastPaymentFix = values.lastPaymentRule !== 100_000_002; preparedValues.lastPayment = (values.lastPaymentPerc as number) / 100; preparedValues.lastPaymentSum = (values.lastPaymentRub as number) / (1 + valuesConstants.VAT); diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/results.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/results.ts index 99a48f4..2cd5880 100644 --- a/src/client/stores/CalculationStore/Effects/actions/calculate/results.ts +++ b/src/client/stores/CalculationStore/Effects/actions/calculate/results.ts @@ -157,5 +157,10 @@ export default { (res?.columns?.sumWithVatColumn?.values[0] || 0) - (this.getValue('subsidySum') || 0), ); + if (this.getValue('lastPaymentRule') === 100_000_002) + this.setValue( + 'lastPaymentRub', + res?.columns?.sumWithVatColumn?.values.pop(), + ); }, }; diff --git a/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts index 84ec078..1261951 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts @@ -445,8 +445,8 @@ const reactionEffects: IReactionEffect[] = [ return lastPaymentRule; }, effect: lastPaymentRule => { - if (lastPaymentRule) { - if (lastPaymentRule === 100000000) { + switch (lastPaymentRule) { + case 100_000_000: { calculationStore.setStatus( 'tbxLastPaymentPerc', ElementStatus.Disabled, @@ -455,7 +455,9 @@ const reactionEffects: IReactionEffect[] = [ 'tbxLastPaymentRub', ElementStatus.Default, ); - } else { + break; + } + case 100_000_001: { calculationStore.setStatus( 'tbxLastPaymentPerc', ElementStatus.Default, @@ -464,6 +466,17 @@ const reactionEffects: IReactionEffect[] = [ 'tbxLastPaymentRub', ElementStatus.Disabled, ); + break; + } + default: { + calculationStore.setStatus( + 'tbxLastPaymentPerc', + ElementStatus.Disabled, + ); + calculationStore.setStatus( + 'tbxLastPaymentRub', + ElementStatus.Disabled, + ); } } }, diff --git a/src/client/stores/CalculationStore/Effects/reactions/priceReactions/index.ts b/src/client/stores/CalculationStore/Effects/reactions/priceReactions/index.ts index 6841291..89c71af 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/priceReactions/index.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/priceReactions/index.ts @@ -173,7 +173,7 @@ export default [ lastPaymentRule, ]) => { if ( - lastPaymentRule !== 100000001 || + lastPaymentRule === 100000000 || calculationProcess.hasProcess(Process.LoadKp) ) { return; @@ -212,7 +212,7 @@ export default [ lastPaymentRule, ]) => { if ( - lastPaymentRule !== 100000000 || + lastPaymentRule === 100000001 || calculationProcess.hasProcess(Process.LoadKp) ) { return; diff --git a/src/client/stores/CalculationStore/config/initialOptions.ts b/src/client/stores/CalculationStore/config/initialOptions.ts index 0f5cb8a..e1189ef 100644 --- a/src/client/stores/CalculationStore/config/initialOptions.ts +++ b/src/client/stores/CalculationStore/config/initialOptions.ts @@ -5,11 +5,15 @@ import { orderBy } from 'lodash'; const initialOptions: Partial> = { radioLastPaymentRule: [ { - name: 'рублей', + name: 'равен платежу', + value: 100000002, + }, + { + name: 'в рублях', value: 100000000, }, { - name: '%', + name: 'в %', value: 100000001, }, ], diff --git a/src/core/services/CalculationService/types/prepared.ts b/src/core/services/CalculationService/types/prepared.ts index 029a0c6..a6ea2bb 100644 --- a/src/core/services/CalculationService/types/prepared.ts +++ b/src/core/services/CalculationService/types/prepared.ts @@ -17,6 +17,7 @@ export interface PreparedValues { firstPaymentAbs?: number; firstPaymentNdsAbs?: number; firstPaymentWithNdsAbs?: number; + lastPaymentFix?: boolean; lastPayment?: number; lastPaymentSum?: number; scheduleOfPayments?: number;