если ("Частичный НДС" cbxPartialVAT = Да или в Продукте Частичный НДС evo_sale_without_nds = Да) и "Плательщик КАСКО" insuredKASKO = ЛД 100 000 001, то ошибка "При частичном НДС нельзя включать КАСКО в график"

This commit is contained in:
vchikalkin 2024-01-17 13:29:27 +03:00
parent 08635d2caa
commit c3854c8194

View File

@ -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'],
});
}
}
);
}