From c0dcaaf8fd2dc9d21d6afb8d71585523c3a75c35 Mon Sep 17 00:00:00 2001 From: Chika Date: Wed, 9 Feb 2022 12:09:39 +0300 Subject: [PATCH] merge release/dyn-829_last-payment-calculation --- .../Calculation/Elements/props/common.ts | 8 ++--- .../Containers/Calculation/Elements/titles.ts | 2 +- .../Effects/actions/calculate/prepareData.ts | 1 + .../Effects/actions/calculate/results.ts | 5 +++ .../Effects/reactions/otherReactions.ts | 36 ++++++++++--------- .../Effects/reactions/priceReactions/index.ts | 4 +-- .../reactions/recalcWoRevisionReactions.ts | 6 +++- .../CalculationStore/config/initialOptions.ts | 8 +++-- .../CalculationService/types/prepared.ts | 1 + 9 files changed, 44 insertions(+), 27 deletions(-) diff --git a/src/client/Containers/Calculation/Elements/props/common.ts b/src/client/Containers/Calculation/Elements/props/common.ts index ad4e565..1d9b4a9 100644 --- a/src/client/Containers/Calculation/Elements/props/common.ts +++ b/src/client/Containers/Calculation/Elements/props/common.ts @@ -209,12 +209,12 @@ const elementsProps: Partial> = { formatter: formatNumber, }, tbxInsAgeDrivers: { - min: '18', - max: '99', + // min: '18', + // max: '99', }, tbxInsExpDrivers: { - min: '0', - max: '99', + // min: '0', + // max: '99', }, selectRegionRegistration: { showSearch: true, 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..58709b9 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, + ); } } }, @@ -474,9 +487,7 @@ const reactionEffects: IReactionEffect[] = [ calculationStore => ({ expression: () => { - const { lastPaymentRub, lastPaymentPerc, insNSIB } = - calculationStore.values; - return { lastPaymentRub, lastPaymentPerc, insNSIB }; + return calculationStore.getValues(['lastPaymentRub', 'insNSIB']); }, effect: ({ lastPaymentRub, insNSIB }) => { if (insNSIB && lastPaymentRub && lastPaymentRub < 3500) { @@ -487,18 +498,9 @@ const reactionEffects: IReactionEffect[] = [ description: 'Последний платеж меньше 3500 руб. не может быть при наличии НСИБ, укажите большее значение', })(); - return; - } else if (lastPaymentRub && lastPaymentRub < 1000) { - calculationStore.setValidation('tbxLastPaymentRub', false); - openNotification({ - type: 'error', - title: 'Ошибка', - description: - 'Последний платеж меньше 1000 руб. не может быть, укажите большее значение', - })(); - return; + } else { + calculationStore.setValidation('tbxLastPaymentRub', true); } - calculationStore.setValidation('tbxLastPaymentRub', true); }, }), 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/Effects/reactions/recalcWoRevisionReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts index 8a74da8..76f2b8d 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts @@ -540,7 +540,11 @@ const reactionEffects: IReactionEffect[] = [ calculationStore => ({ expression: () => - calculationStore.getValues(['lastPaymentPerc', 'balanceHolder']), + calculationStore.getValues([ + 'lastPaymentPerc', + 'balanceHolder', + 'lastPaymentRule', + ]), effect: ({ lastPaymentPerc, balanceHolder }) => { if (balanceHolder && balanceHolder === 100000001) { if (!lastPaymentPerc || parseFloat(lastPaymentPerc) < 1) { 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;