diff --git a/apps/web/process/insurance/validation.ts b/apps/web/process/insurance/validation.ts index 9566a62..cbfa5ec 100644 --- a/apps/web/process/insurance/validation.ts +++ b/apps/web/process/insurance/validation.ts @@ -14,6 +14,8 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { insDecentral: true, leasingPeriod: true, leasingWithoutKasko: true, + partialVAT: true, + product: true, quote: true, recalcWithRevision: true, }) @@ -33,6 +35,8 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { insurance, brand: brandId, fingap: fingapRisks, + partialVAT, + product: productId, }, ctx ) => { @@ -210,6 +214,26 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { } } } + + let evo_baseproduct: CRMTypes.GetProductQuery['evo_baseproduct'] = null; + if (productId) { + const { data } = await apolloClient.query({ + query: CRMTypes.GetProductDocument, + variables: { productId }, + }); + ({ evo_baseproduct } = data); + } + + if ( + (partialVAT || evo_baseproduct?.evo_sale_without_nds) && + insurance.values.kasko.insured === 100_000_001 + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'При частичном НДС нельзя включать КАСКО в график', + path: ['cbxPartialVAT'], + }); + } } ); }