From eba2589077bde713aff15472ee5da455d528c93e Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Wed, 17 Jan 2024 13:38:20 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B5=D1=81=D0=BB=D0=B8=20=D0=A2=D0=B8=D0=BF?= =?UTF-8?q?=20=D0=BF=D1=80=D0=B5=D0=B4=D0=BC=D0=B5=D1=82=D0=B0=20=D0=BB?= =?UTF-8?q?=D0=B8=D0=B7=D0=B8=D0=BD=D0=B3=D0=B0=20leaseObjectType=3D=20?= =?UTF-8?q?=D0=9B=D0=B5=D0=B3=D0=BA=D0=BE=D0=B2=D0=BE=D0=B9=20=D0=B0=D0=B2?= =?UTF-8?q?=D1=82=D0=BE=D0=BC=D0=BE=D0=B1=D0=B8=D0=BB=D1=8C=20(ID=3D1)=20?= =?UTF-8?q?=D0=98=20"=D0=9F=D0=B5=D1=80=D0=B2=D1=8B=D0=B9=20=D0=BF=D0=BB?= =?UTF-8?q?=D0=B0=D1=82=D0=B5=D0=B6"=20firstPaymentPerc=20<=2025=20=D0=98?= =?UTF-8?q?=20"PlPrice"=20=D0=B1=D0=BE=D0=BB=D1=8C=D1=88=D0=B5=2020=20000?= =?UTF-8?q?=20000=20=D0=B8=20"=D0=9F=D0=BB=D0=B0=D1=82=D0=B5=D0=BB=D1=8C?= =?UTF-8?q?=D1=89=D0=B8=D0=BA=20=D0=9A=D0=90=D0=A1=D0=9A=D0=9E"=20insuredK?= =?UTF-8?q?ASKO=20=20=3D=20=D0=9B=D0=94=20100=20000=20001,=20=D1=82=D0=BE?= =?UTF-8?q?=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B0=20"=D0=9F=D1=80=D0=B8?= =?UTF-8?q?=20=D0=B4=D0=BE=D1=80=D0=BE=D0=B3=D0=BE=D0=BC=20=D0=B0=D0=B2?= =?UTF-8?q?=D1=82=D0=BE=20=D0=B8=20=D0=B0=D0=B2=D0=B0=D0=BD=D1=81=D0=B5=20?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=8C=D1=88=D0=B5=2025%=20=D0=BD=D0=B5=D0=BB?= =?UTF-8?q?=D1=8C=D0=B7=D1=8F=20=D0=B2=D0=BA=D0=BB=D1=8E=D1=87=D0=B0=D1=82?= =?UTF-8?q?=D1=8C=20=D0=9A=D0=90=D0=A1=D0=9A=D0=9E=20=D0=B2=20=D0=B3=D1=80?= =?UTF-8?q?=D0=B0=D1=84=D0=B8=D0=BA"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/process/insurance/validation.ts | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/apps/web/process/insurance/validation.ts b/apps/web/process/insurance/validation.ts index cbfa5ec..49c3a74 100644 --- a/apps/web/process/insurance/validation.ts +++ b/apps/web/process/insurance/validation.ts @@ -11,10 +11,13 @@ import { z } from 'zod'; export function createValidationSchema({ apolloClient }: ValidationContext) { return ValuesSchema.pick({ brand: true, + firstPaymentPerc: true, insDecentral: true, + leaseObjectType: true, leasingPeriod: true, leasingWithoutKasko: true, partialVAT: true, + plPriceRub: true, product: true, quote: true, recalcWithRevision: true, @@ -37,6 +40,9 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { fingap: fingapRisks, partialVAT, product: productId, + leaseObjectType: leaseObjectTypeId, + firstPaymentPerc, + plPriceRub, }, ctx ) => { @@ -234,6 +240,30 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { path: ['cbxPartialVAT'], }); } + + let evo_leasingobject_type: CRMTypes.GetLeaseObjectTypeQuery['evo_leasingobject_type'] = + null; + + if (leaseObjectTypeId) { + const { data } = await apolloClient.query({ + query: CRMTypes.GetLeaseObjectTypeDocument, + variables: { leaseObjectTypeId }, + }); + ({ evo_leasingobject_type } = data); + } + + if ( + evo_leasingobject_type?.evo_id === '1' && + firstPaymentPerc < 25 && + plPriceRub > 20_000_000 && + insurance.values.kasko.insured === 100_000_001 + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'При дорогом авто и авансе меньше 25% нельзя включать КАСКО в график', + path: ['tbxLeaseObjectPrice'], + }); + } } ); }