diff --git a/apps/web/constants/values.js b/apps/web/constants/values.js index e36cba8..f2b8a2f 100644 --- a/apps/web/constants/values.js +++ b/apps/web/constants/values.js @@ -12,3 +12,5 @@ export const VEHICLE_SEATS = 20; export const ESN = 1.3; export const NSIB_MAX = 5_000_000; export const NDFL = 0.13; + +export const IRR_THRESHOLD = 0.001; diff --git a/apps/web/process/calculate/reactions/common.ts b/apps/web/process/calculate/reactions/common.ts index 64f67f7..85c0ea8 100644 --- a/apps/web/process/calculate/reactions/common.ts +++ b/apps/web/process/calculate/reactions/common.ts @@ -1,4 +1,5 @@ import helper from '../lib/helper'; +import { IRR_THRESHOLD } from '@/constants/values'; import type { ProcessContext } from '@/process/types'; import { disposableReaction } from '@/utils/mobx'; import { comparer, reaction } from 'mobx'; @@ -31,7 +32,8 @@ export default function reactions({ store, apolloClient }: ProcessContext) { const { getIrr } = helper({ apolloClient }); - reaction( + disposableReaction( + () => $process.has('LoadKP'), () => $calculation.$values.getValues(['product', 'tarif', 'bonusCoefficient']), async (values) => { const { min, max } = await getIrr(values); @@ -40,6 +42,19 @@ export default function reactions({ store, apolloClient }: ProcessContext) { } ); + // костыль + disposableReaction( + () => + $process.has('LoadKP') || + $calculation.element('radioLastPaymentRule').getValue() === 100_000_002, + () => $calculation.element('labelIrrInfo').getValue(), + ({ min }) => { + if ($calculation.element('radioLastPaymentRule').getValue() === 100_000_002) return; + + $calculation.element('tbxIRR_Perc').setValue(min + IRR_THRESHOLD); + } + ); + disposableReaction( () => $process.has('Calculate') || $process.has('CreateKP'), () => {