From 6e5d05371f2ed2493baac08981102124554d1f6e Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Wed, 8 Feb 2023 10:10:07 +0300 Subject: [PATCH] payments min value = 3 --- .../Calculation/Form/Payments/PaymentsTable/config.tsx | 9 +-------- apps/web/constants/values.js | 1 + apps/web/process/payments/reactions.ts | 4 +++- apps/web/process/payments/validation.ts | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/apps/web/Components/Calculation/Form/Payments/PaymentsTable/config.tsx b/apps/web/Components/Calculation/Form/Payments/PaymentsTable/config.tsx index 391e807..ba50492 100644 --- a/apps/web/Components/Calculation/Form/Payments/PaymentsTable/config.tsx +++ b/apps/web/Components/Calculation/Form/Payments/PaymentsTable/config.tsx @@ -24,14 +24,7 @@ export const columns: ColumnsType = [ render: (_value, payment) => { const Component = buildValueComponent(payment.num, InputNumber); - return ( - - ); + return ; }, }, ]; diff --git a/apps/web/constants/values.js b/apps/web/constants/values.js index 5af532c..7436947 100644 --- a/apps/web/constants/values.js +++ b/apps/web/constants/values.js @@ -5,3 +5,4 @@ export const MIN_INSURANCE = 3000; export const RATE = 7.75; export const MAX_LEASING_PERIOD = 60; export const MIN_LASTPAYMENT_NSIB = 3500; +export const MIN_PAYMENT = 3; diff --git a/apps/web/process/payments/reactions.ts b/apps/web/process/payments/reactions.ts index 7d736f2..68d749a 100644 --- a/apps/web/process/payments/reactions.ts +++ b/apps/web/process/payments/reactions.ts @@ -2,6 +2,7 @@ import * as seasonsConstants from './lib/seasons-constants'; import * as seasonsTools from './lib/seasons-tools'; import validatePaymentsTable from './validation'; import { selectHighSeasonStart } from '@/config/default-options'; +import { MIN_PAYMENT } from '@/constants/values'; import type { ReactionsContext } from '@/process/types'; import type { Row } from '@/stores/tables/payments/types'; import ValidationHelper from '@/stores/validation/helper'; @@ -114,7 +115,8 @@ export default function paymentsReactions({ store }: ReactionsContext) { length: leasingPeriod - 2, }, (_, k) => { - const payment = 100 * (parmentsDecreasePercent / 100) ** k; + let payment = 100 * (parmentsDecreasePercent / 100) ** k; + if (payment < MIN_PAYMENT) payment = MIN_PAYMENT; return { status: 'Disabled', diff --git a/apps/web/process/payments/validation.ts b/apps/web/process/payments/validation.ts index 85e45b7..8f1f919 100644 --- a/apps/web/process/payments/validation.ts +++ b/apps/web/process/payments/validation.ts @@ -1,4 +1,5 @@ import { SEASONS_PERIOD_NUMBER, SEASONS_PERIODS } from './lib/seasons-constants'; +import { MIN_PAYMENT } from '@/constants/values'; import type RootStore from '@/stores/root'; import { counting, max, min, shift, sort } from 'radash'; import { areEqual, isSorted } from 'tools/array'; @@ -10,7 +11,6 @@ export default function validatePaymentsTable({ $calculation, $tables }: RootSto * для строк с 2 до "Срок лизинга-1" минимальное значение должно быть равно 3 */ { - const MIN_PAYMENT = 3; const leasingPeriod = $calculation.element('tbxLeasingPeriod').getValue(); const targetPayments = $tables.payments.values.slice(1, leasingPeriod - 1);