From faa421e1ce840e120388816041d58b93db4a8c5a Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Tue, 8 Oct 2024 16:20:19 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=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?=20=D0=BD=D0=B0=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20"=D0=AE=D0=9B=20=D0=BF=D0=BE=D1=81=D1=82=D0=B0?= =?UTF-8?q?=D0=B2=D1=89=D0=B8=D0=BA=D0=B0"=20selectDealerPerson=20=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=20"=D0=90=D0=B3=D0=B5=D0=BD=D1=82=20=D0=A4=D0=9B"?= =?UTF-8?q?=20selectindAgent=20=D0=B8=D0=BB=D0=B8=20"=D0=94=D0=B2=D0=BE?= =?UTF-8?q?=D0=B9=D0=BD=D0=BE=D0=B9=20=D0=B0=D0=B3=D0=B5=D0=BD=D1=82"=20se?= =?UTF-8?q?lectcalcDoubleAgent=20=D0=B8=D0=BB=D0=B8=20"=D0=91=D1=80=D0=BE?= =?UTF-8?q?=D0=BA=D0=B5=D1=80"=20selectcalcBroker=20=D0=B8=D0=BB=D0=B8=20"?= =?UTF-8?q?=D0=A4=D0=B8=D0=BD=D0=BE=D1=82=D0=B4=D0=B5=D0=BB"=20selectcalcF?= =?UTF-8?q?inDepartment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit если в поле "ЮЛ поставщика" selectDealerPerson указана запись, у которой Вид контрагента (account.evo_legal_form) = Физическое лицо (100 000 004) И selectDealerPerson = selectindAgent или selectcalcDoubleAgent или selectcalcBroker или selectcalcFinDepartment , то выводить сообщение "Нельзя закладывать АВ поставщику-ФЛ" --- apps/web/process/supplier-agent/validation.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/apps/web/process/supplier-agent/validation.ts b/apps/web/process/supplier-agent/validation.ts index 2d2ff3e..9e215ec 100644 --- a/apps/web/process/supplier-agent/validation.ts +++ b/apps/web/process/supplier-agent/validation.ts @@ -482,6 +482,31 @@ export function createValidationSchema(context: ValidationContext) { }); } + if (dealerPerson) { + const { + data: { dealer_person }, + } = await apolloClient.query({ + query: CRMTypes.GetDealerPersonDocument, + variables: { + dealerPersonId: dealerPerson, + }, + }); + + if ( + dealer_person?.evo_legal_form === 100_000_004 && + ((indAgent && dealerPerson === indAgent) || + (calcDoubleAgent && dealerPerson === calcDoubleAgent) || + (calcBroker && dealerPerson === calcBroker) || + (calcFinDepartment && dealerPerson === calcFinDepartment)) + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Нельзя закладывать АВ поставщику-ФЛ', + path: ['selectDealerPerson'], + }); + } + } + if (brandId) { const { data: { evo_brand },