From 590c2d180ed8161a6b115f5860edf2608530c5e7 Mon Sep 17 00:00:00 2001 From: Chika Date: Thu, 17 Jun 2021 12:54:35 +0300 Subject: [PATCH 1/5] fix tbxCountSeats validation --- .../reactions/recalcWoRevisionReactions.ts | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts index ccf5362..acebff8 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts @@ -253,27 +253,29 @@ const reactionEffects: IReactionEffect[] = [ }; }, effect: ({ countSeats, leaseObjectCategory, recalcWithRevision }) => { - if (recalcWithRevision && leaseObjectCategory === 100000003) { - const quote = calculationStore.getOption('selectQuote'); - if (quote && quote?.evo_seats) - if ( - (countSeats < valuesConstants.MAX_VEHICLE_SEATS && - quote.evo_seats < valuesConstants.MAX_VEHICLE_SEATS) || - (countSeats >= valuesConstants.MAX_VEHICLE_SEATS && - quote.evo_seats >= valuesConstants.MAX_VEHICLE_SEATS) - ) { - calculationStore.setValidation('tbxCountSeats', undefined); - } else { - openNotification({ - type: 'error', - title: 'Ошибка', - description: - 'Указанная разрешенная макс. масса выходит из утвержденного диапазона. Для изменения параметра требуется пересмотр сделки', - })(); - calculationStore.setValidation('tbxCountSeats', false); - } - } else { - calculationStore.setValidation('tbxCountSeats', undefined); + if (recalcWithRevision) { + if (leaseObjectCategory === 100000003) { + const quote = calculationStore.getOption('selectQuote'); + if (quote && quote?.evo_seats) + if ( + (countSeats < valuesConstants.MAX_VEHICLE_SEATS && + quote.evo_seats < valuesConstants.MAX_VEHICLE_SEATS) || + (countSeats >= valuesConstants.MAX_VEHICLE_SEATS && + quote.evo_seats >= valuesConstants.MAX_VEHICLE_SEATS) + ) { + calculationStore.setValidation('tbxCountSeats', undefined); + } else { + openNotification({ + type: 'error', + title: 'Ошибка', + description: + 'Указанное кол-во мест выходит из утвержденного диапазона. Для изменения параметра требуется пересмотр сделки', + })(); + calculationStore.setValidation('tbxCountSeats', false); + } + } else { + calculationStore.setValidation('tbxCountSeats', undefined); + } } }, }), From 5bdfd17f171415fe8919cdf059418ae2b7bb67b1 Mon Sep 17 00:00:00 2001 From: Chika Date: Mon, 17 Jan 2022 12:42:03 +0300 Subject: [PATCH 2/5] ELT(Kasko): selfIgnition updates --- .../Calculation/ELT/Content/Kasko/lib/composeRequest.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/client/Components/Calculation/ELT/Content/Kasko/lib/composeRequest.ts b/src/client/Components/Calculation/ELT/Content/Kasko/lib/composeRequest.ts index 6675a3a..aeb39c3 100644 --- a/src/client/Components/Calculation/ELT/Content/Kasko/lib/composeRequest.ts +++ b/src/client/Components/Calculation/ELT/Content/Kasko/lib/composeRequest.ts @@ -96,8 +96,8 @@ export default function (this: ICalculationStore) { notConfirmedGlassesDamagesSpecified = false, notConfirmedDamages, notConfirmedDamagesSpecified = false, - selfIgnition = false, - selfIgnitionSpecified = false, + selfIgnition, + selfIgnitionSpecified, outsideRoads, outsideRoadsSpecified = false; if ( @@ -109,8 +109,8 @@ export default function (this: ICalculationStore) { notConfirmedGlassesDamagesSpecified = true; notConfirmedDamages = 2; notConfirmedDamagesSpecified = true; - // selfIgnition = true; - selfIgnitionSpecified = true; + selfIgnition = true; + selfIgnitionSpecified = getSpecified(selfIgnition); outsideRoads = true; outsideRoadsSpecified = true; } From db21b16c6f82e38b6151bdff53411a1566694f3f Mon Sep 17 00:00:00 2001 From: Chika Date: Thu, 3 Feb 2022 16:30:00 +0300 Subject: [PATCH 3/5] =?UTF-8?q?DYN-829:=20=D0=A0=D0=B0=D1=81=D1=87=D0=B5?= =?UTF-8?q?=D1=82=20=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=D0=B4=D0=BD=D0=B5=D0=B3?= =?UTF-8?q?=D0=BE=20=D0=BB=D0=B8=D0=B7=D0=B8=D0=BD=D0=B3=D0=BE=D0=B2=D0=BE?= =?UTF-8?q?=D0=B3=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; From 9c87172a58de00ef6f839b3cdd057e82aadc854d Mon Sep 17 00:00:00 2001 From: Chika Date: Thu, 3 Feb 2022 17:00:06 +0300 Subject: [PATCH 4/5] =?UTF-8?q?for=20db21b16:=20=D0=B2=D0=B0=D0=BB=D0=B8?= =?UTF-8?q?=D0=B4=D0=B0=D1=86=D0=B8=D1=8F=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4?= =?UTF-8?q?=20=D1=80=D0=B0=D1=81=D1=87=D0=B5=D1=82=D0=BE=D0=BC=20=D0=BF?= =?UTF-8?q?=D0=BE=20=D0=BF=D1=80=D0=BE=D0=BF=D1=81=D0=B0=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Calculation/Elements/props/common.ts | 10 ++++++---- .../actions/calculate/validate/elements.ts | 20 +++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/client/Containers/Calculation/Elements/props/common.ts b/src/client/Containers/Calculation/Elements/props/common.ts index ad4e565..13aba13 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, @@ -348,6 +348,8 @@ export const numberElementsProps: Partial> = return acc; }, {}); + console.table(numberElementsProps) + const moneyResultElementsProps = ( [ 'labelResultTotalGraphwithNDS', diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts index 4bfff21..546e875 100644 --- a/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts +++ b/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts @@ -1,3 +1,4 @@ +import { numberElementsProps } from 'client/Containers/Calculation/Elements/props/common'; import { getValueName } from 'client/Containers/Calculation/Elements/tools'; import { ElementsNames } from 'client/Containers/Calculation/types/elements'; import { pipe } from 'core/tools/func'; @@ -192,11 +193,30 @@ const entityElementsConditions = ( {}, ); +/** Проверяем по настройкам полей min max */ +const numberElementsConditions = Object.keys(numberElementsProps).reduce( + (acc, elem) => { + acc[elem] = (calculationStore, elementName) => { + const valueName = getValueName(elementName); + const value = calculationStore.getValue(valueName); + const { min, max } = numberElementsProps[elem]; + return { + isValid: + (min === undefined || value >= min) && + (max === undefined || value <= max), + }; + }; + return acc; + }, + {} as Partial>, +); + const conditions = Object.assign( {}, customConditions, elementsConditions, entityElementsConditions, + numberElementsConditions, ); export default function (this: ICalculationStore) { From 86fe6ffd2c3bf5e818b8dcd125715fe8ae9e55ac Mon Sep 17 00:00:00 2001 From: Chika Date: Tue, 8 Feb 2022 13:34:56 +0300 Subject: [PATCH 5/5] last fixes for db21b16 --- .../actions/calculate/validate/elements.ts | 20 ------------------- .../Effects/reactions/otherReactions.ts | 17 +++------------- .../reactions/recalcWoRevisionReactions.ts | 6 +++++- 3 files changed, 8 insertions(+), 35 deletions(-) diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts index 546e875..4bfff21 100644 --- a/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts +++ b/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts @@ -1,4 +1,3 @@ -import { numberElementsProps } from 'client/Containers/Calculation/Elements/props/common'; import { getValueName } from 'client/Containers/Calculation/Elements/tools'; import { ElementsNames } from 'client/Containers/Calculation/types/elements'; import { pipe } from 'core/tools/func'; @@ -193,30 +192,11 @@ const entityElementsConditions = ( {}, ); -/** Проверяем по настройкам полей min max */ -const numberElementsConditions = Object.keys(numberElementsProps).reduce( - (acc, elem) => { - acc[elem] = (calculationStore, elementName) => { - const valueName = getValueName(elementName); - const value = calculationStore.getValue(valueName); - const { min, max } = numberElementsProps[elem]; - return { - isValid: - (min === undefined || value >= min) && - (max === undefined || value <= max), - }; - }; - return acc; - }, - {} as Partial>, -); - const conditions = Object.assign( {}, customConditions, elementsConditions, entityElementsConditions, - numberElementsConditions, ); export default function (this: ICalculationStore) { diff --git a/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts index 1261951..58709b9 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts @@ -487,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) { @@ -500,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/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) {