From 0be3a575f761be9bfbe03099a9b9122ec45ecb8e Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Thu, 4 Jul 2024 13:44:16 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20=D0=B2=D0=B0=D0=BB=D0=B8=D0=B4=D0=B0=D1=86=D0=B8=D1=8E?= =?UTF-8?q?:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit в lease-object, выделяем tbxMaxSpeed Если Тип предмета лизинга selectLeaseObjectType = Спецтехника (ID=9) или Погрузчик (ID=6) или Трактор (ID=10) И значение в поле tbxMaxSpeed= 0, то выводить сообщение "Необходимо указать Макс. констр. скорость (при ПСМ)" в insurance выделяем selectLeaseObjectType Если Тип предмета лизинга selectLeaseObjectType = Спецтехника (ID=9) и значение в поле tbxMaxSpeed< 20 и insuredOSAGO = Лизингодатель (100000001), то выводить сообщение "Нельзя включать в график ОСАГО по Спецтехнике, т.к. полис не требуется" --- apps/web/process/insurance/validation.ts | 15 +++++++++++++++ apps/web/process/leasing-object/validation.ts | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/apps/web/process/insurance/validation.ts b/apps/web/process/insurance/validation.ts index 7ca2a9b..19b36ad 100644 --- a/apps/web/process/insurance/validation.ts +++ b/apps/web/process/insurance/validation.ts @@ -16,6 +16,7 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { leaseObjectType: true, leasingPeriod: true, leasingWithoutKasko: true, + maxSpeed: true, partialVAT: true, plPriceRub: true, product: true, @@ -42,6 +43,7 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { leaseObjectType: leaseObjectTypeId, firstPaymentPerc, plPriceRub, + maxSpeed, }, ctx ) => { @@ -251,6 +253,19 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { path: ['tbxLeaseObjectPrice'], }); } + + if ( + evo_leasingobject_type?.evo_id && + ['9'].includes(evo_leasingobject_type?.evo_id) && + maxSpeed < 20 && + insurance.values.osago.insured === 100_000_001 + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Нельзя включать в график ОСАГО по Спецтехнике, т.к. полис не требуется', + path: ['insurance'], + }); + } } ); } diff --git a/apps/web/process/leasing-object/validation.ts b/apps/web/process/leasing-object/validation.ts index de74677..8ea0dc1 100644 --- a/apps/web/process/leasing-object/validation.ts +++ b/apps/web/process/leasing-object/validation.ts @@ -17,6 +17,7 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { leaseObjectType: true, leaseObjectUseFor: true, maxMass: true, + maxSpeed: true, model: true, }).superRefine( async ( @@ -32,6 +33,7 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { model: modelId, leaseObjectUseFor, configuration, + maxSpeed, }, ctx ) => { @@ -174,6 +176,18 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { path: ['selectLeaseObjectCategory'], }); } + + if ( + evo_leasingobject_type?.evo_id && + ['6', '9', '10'].includes(evo_leasingobject_type?.evo_id) && + !maxSpeed + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Не заполнено поле', + path: ['tbxMaxSpeed'], + }); + } } } );