add validation
This commit is contained in:
parent
4d1bad3a53
commit
c20a8b6cc7
@ -46,6 +46,7 @@ query GetLead($leadid: Uuid!) {
|
||||
evo_region_fias_id
|
||||
evo_city_fias_id
|
||||
}
|
||||
evo_okved
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -58,6 +59,7 @@ query GetOpportunity($opportunityid: Uuid!) {
|
||||
evo_region_fias_id
|
||||
evo_city_fias_id
|
||||
}
|
||||
evo_okved
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,14 +147,14 @@ export type GetLeadQueryVariables = Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type GetLeadQuery = { __typename?: 'Query', lead: { __typename?: 'lead', evo_agent_accountid: string | null, evo_double_agent_accountid: string | null, evo_broker_accountid: string | null, evo_fin_department_accountid: string | null, evo_inn: string | null, evo_opportunityidData: { __typename?: 'opportunity', label: string | null, value: string | null } | null, accountidData: { __typename?: 'account', evo_address_legalidData: { __typename?: 'evo_address', evo_region_fias_id: string | null, evo_city_fias_id: string | null } | null } | null } | null };
|
||||
export type GetLeadQuery = { __typename?: 'Query', lead: { __typename?: 'lead', evo_agent_accountid: string | null, evo_double_agent_accountid: string | null, evo_broker_accountid: string | null, evo_fin_department_accountid: string | null, evo_inn: string | null, evo_opportunityidData: { __typename?: 'opportunity', label: string | null, value: string | null } | null, accountidData: { __typename?: 'account', evo_okved: string | null, evo_address_legalidData: { __typename?: 'evo_address', evo_region_fias_id: string | null, evo_city_fias_id: string | null } | null } | null } | null };
|
||||
|
||||
export type GetOpportunityQueryVariables = Exact<{
|
||||
opportunityid: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetOpportunityQuery = { __typename?: 'Query', opportunity: { __typename?: 'opportunity', evo_leadid: string | null, accountidData: { __typename?: 'account', evo_address_legalidData: { __typename?: 'evo_address', evo_region_fias_id: string | null, evo_city_fias_id: string | null } | null } | null } | null };
|
||||
export type GetOpportunityQuery = { __typename?: 'Query', opportunity: { __typename?: 'opportunity', evo_leadid: string | null, accountidData: { __typename?: 'account', evo_okved: string | null, evo_address_legalidData: { __typename?: 'evo_address', evo_region_fias_id: string | null, evo_city_fias_id: string | null } | null } | null } | null };
|
||||
|
||||
export type GetOpportunitiesQueryVariables = Exact<{
|
||||
domainname: InputMaybe<Scalars['String']>;
|
||||
@ -600,8 +600,8 @@ export const GetTransactionCurrenciesDocument = {"kind":"Document","definitions"
|
||||
export const GetTransactionCurrencyDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetTransactionCurrency"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currencyid"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"transactioncurrency"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"transactioncurrencyid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currencyid"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currencysymbol"}},{"kind":"Field","name":{"kind":"Name","value":"isocurrencycode"}},{"kind":"Field","name":{"kind":"Name","value":"transactioncurrencyid"}}]}}]}}]} as unknown as DocumentNode<GetTransactionCurrencyQuery, GetTransactionCurrencyQueryVariables>;
|
||||
export const GetCurrencyChangesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetCurrencyChanges"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_currencychanges"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_coursedate_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"eq"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_currencychange"}},{"kind":"Field","name":{"kind":"Name","value":"evo_ref_transactioncurrency"}}]}}]}}]} as unknown as DocumentNode<GetCurrencyChangesQuery, GetCurrencyChangesQueryVariables>;
|
||||
export const GetLeadsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLeads"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"domainname"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"leads"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"owner_domainname"},"value":{"kind":"Variable","name":{"kind":"Name","value":"domainname"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"fullname"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"leadid"}}]}}]}}]} as unknown as DocumentNode<GetLeadsQuery, GetLeadsQueryVariables>;
|
||||
export const GetLeadDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLead"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"leadid"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"lead"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"leadid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"leadid"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_agent_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_double_agent_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_broker_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fin_department_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_opportunityidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"opportunityid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_inn"}},{"kind":"Field","name":{"kind":"Name","value":"accountidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_address_legalidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_region_fias_id"}},{"kind":"Field","name":{"kind":"Name","value":"evo_city_fias_id"}}]}}]}}]}}]}}]} as unknown as DocumentNode<GetLeadQuery, GetLeadQueryVariables>;
|
||||
export const GetOpportunityDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetOpportunity"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"opportunityid"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"opportunity"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"opportunityid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"opportunityid"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leadid"}},{"kind":"Field","name":{"kind":"Name","value":"accountidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_address_legalidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_region_fias_id"}},{"kind":"Field","name":{"kind":"Name","value":"evo_city_fias_id"}}]}}]}}]}}]}}]} as unknown as DocumentNode<GetOpportunityQuery, GetOpportunityQueryVariables>;
|
||||
export const GetLeadDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLead"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"leadid"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"lead"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"leadid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"leadid"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_agent_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_double_agent_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_broker_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fin_department_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_opportunityidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"opportunityid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_inn"}},{"kind":"Field","name":{"kind":"Name","value":"accountidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_address_legalidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_region_fias_id"}},{"kind":"Field","name":{"kind":"Name","value":"evo_city_fias_id"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_okved"}}]}}]}}]}}]} as unknown as DocumentNode<GetLeadQuery, GetLeadQueryVariables>;
|
||||
export const GetOpportunityDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetOpportunity"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"opportunityid"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"opportunity"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"opportunityid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"opportunityid"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leadid"}},{"kind":"Field","name":{"kind":"Name","value":"accountidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_address_legalidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_region_fias_id"}},{"kind":"Field","name":{"kind":"Name","value":"evo_city_fias_id"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_okved"}}]}}]}}]}}]} as unknown as DocumentNode<GetOpportunityQuery, GetOpportunityQueryVariables>;
|
||||
export const GetOpportunitiesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetOpportunities"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"domainname"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"opportunities"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"owner_domainname"},"value":{"kind":"Variable","name":{"kind":"Name","value":"domainname"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"opportunityid"}}]}}]}}]} as unknown as DocumentNode<GetOpportunitiesQuery, GetOpportunitiesQueryVariables>;
|
||||
export const GetQuotesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuotes"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"leadid"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quotes"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_leadid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"leadid"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_quotename"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"quoteid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_recalc_limit"}},{"kind":"Field","name":{"kind":"Name","value":"evo_statuscodeidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_id"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_purchases_participation"}}]}}]}}]} as unknown as DocumentNode<GetQuotesQuery, GetQuotesQueryVariables>;
|
||||
export const GetQuoteDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuote"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_baseproductid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_one_year_insurance"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_change_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_price_change"}},{"kind":"Field","name":{"kind":"Name","value":"evo_discount_supplier_currency"}},{"kind":"Field","name":{"kind":"Name","value":"evo_equip_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_program_import_subsidy_sum"}},{"kind":"Field","name":{"kind":"Name","value":"evo_nds_in_price_supplier_currency"}},{"kind":"Field","name":{"kind":"Name","value":"evo_supplier_currency_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_approved_first_payment"}},{"kind":"Field","name":{"kind":"Name","value":"evo_recalc_limit"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_mass"}},{"kind":"Field","name":{"kind":"Name","value":"evo_seats"}},{"kind":"Field","name":{"kind":"Name","value":"evo_year"}},{"kind":"Field","name":{"kind":"Name","value":"evo_last_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_maximum_percentage_av"}}]}}]}}]} as unknown as DocumentNode<GetQuoteQuery, GetQuoteQueryVariables>;
|
||||
|
||||
@ -1 +1,2 @@
|
||||
export { default as common } from './common';
|
||||
export * from './validation';
|
||||
|
||||
4
apps/web/process/elt/reactions/validation.ts
Normal file
4
apps/web/process/elt/reactions/validation.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import { createValidationSchema } from '../validation';
|
||||
import { createValidationReaction } from '@/process/tools';
|
||||
|
||||
export const validation = createValidationReaction(createValidationSchema);
|
||||
182
apps/web/process/elt/validation.ts
Normal file
182
apps/web/process/elt/validation.ts
Normal file
@ -0,0 +1,182 @@
|
||||
/* eslint-disable sonarjs/cognitive-complexity */
|
||||
/* eslint-disable complexity */
|
||||
import type { ValidationContext } from '../types';
|
||||
import ValuesSchema from '@/config/schema/values';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import { z } from 'zod';
|
||||
|
||||
export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
return ValuesSchema.pick({
|
||||
insDecentral: true,
|
||||
lead: true,
|
||||
leaseObjectCategory: true,
|
||||
leaseObjectType: true,
|
||||
leaseObjectUseFor: true,
|
||||
leasingWithoutKasko: true,
|
||||
legalClientRegion: true,
|
||||
objectRegistration: true,
|
||||
opportunity: true,
|
||||
townRegistration: true,
|
||||
}).superRefine(
|
||||
async (
|
||||
{
|
||||
insDecentral,
|
||||
leaseObjectCategory,
|
||||
leaseObjectType: leaseObjectTypeId,
|
||||
leaseObjectUseFor,
|
||||
leasingWithoutKasko,
|
||||
legalClientRegion,
|
||||
townRegistration,
|
||||
lead: leadid,
|
||||
opportunity: opportunityid,
|
||||
objectRegistration,
|
||||
},
|
||||
ctx
|
||||
) => {
|
||||
if (leaseObjectTypeId) {
|
||||
const {
|
||||
data: { evo_leasingobject_type },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetLeaseObjectTypeDocument,
|
||||
variables: {
|
||||
leaseObjectTypeId,
|
||||
},
|
||||
});
|
||||
|
||||
// Проверяем на мотоцикл
|
||||
if (evo_leasingobject_type?.evo_id && ['11'].includes(evo_leasingobject_type?.evo_id)) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message:
|
||||
'По данному Типу предмета лизинга возможен только индивидуальный запрос тарифов КАСКО и ОСАГО. Просьба обратиться на адрес strakhovka@evoleasing.ru',
|
||||
path: ['eltKasko', 'eltOsago'],
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
evo_leasingobject_type?.evo_id &&
|
||||
!['1', '2', '3', '6', '7', '8', '9', '10'].includes(evo_leasingobject_type?.evo_id)
|
||||
) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'Для выбранной категории ТС расчет в ЭЛТ недоступен',
|
||||
path: ['eltKasko', 'eltOsago'],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
leaseObjectUseFor &&
|
||||
[100_000_001, 100_000_002, 100_000_003, 100_000_004, 100_000_006].includes(
|
||||
leaseObjectUseFor
|
||||
)
|
||||
) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message:
|
||||
'По данной цели использования возможен только индивидуальный запрос тарифов КАСКО и ОСАГО. Просьба обратиться на адрес strakhovka@evoleasing.ru',
|
||||
path: ['eltKasko'],
|
||||
});
|
||||
}
|
||||
|
||||
if (objectRegistration === 100_000_000 && !legalClientRegion) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'Не указан Регион по юр.адресу клиента',
|
||||
path: ['eltKasko'],
|
||||
});
|
||||
}
|
||||
|
||||
if (objectRegistration === 100_000_001 && !townRegistration) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'Не указан Город регистрации',
|
||||
path: ['eltOsago'],
|
||||
});
|
||||
}
|
||||
|
||||
if (!leaseObjectCategory && leaseObjectTypeId) {
|
||||
const {
|
||||
data: { evo_leasingobject_type },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetLeaseObjectTypeDocument,
|
||||
variables: {
|
||||
leaseObjectTypeId,
|
||||
},
|
||||
});
|
||||
if (
|
||||
evo_leasingobject_type?.evo_id &&
|
||||
!['6', '9', '10'].includes(evo_leasingobject_type?.evo_id)
|
||||
) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'Не указана категория ТС',
|
||||
path: ['eltKasko'],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (insDecentral) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'Децентрализованное страхование не может быть расчитано в ЭЛТ',
|
||||
path: ['eltKasko'],
|
||||
});
|
||||
}
|
||||
|
||||
if (leasingWithoutKasko) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message:
|
||||
'Вы осуществляете расчет с Лизинг без КАСКО, расчет ЭЛТ в данном случае не требуется',
|
||||
path: ['eltKasko'],
|
||||
});
|
||||
}
|
||||
|
||||
let okved: string | null | undefined;
|
||||
if (leadid) {
|
||||
const {
|
||||
data: { lead },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetLeadDocument,
|
||||
variables: { leadid },
|
||||
});
|
||||
|
||||
okved = lead?.accountidData?.evo_okved;
|
||||
}
|
||||
|
||||
if (!okved && opportunityid) {
|
||||
const {
|
||||
data: { opportunity },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetOpportunityDocument,
|
||||
variables: { opportunityid },
|
||||
});
|
||||
|
||||
okved = opportunity?.accountidData?.evo_okved;
|
||||
}
|
||||
|
||||
if (
|
||||
okved &&
|
||||
[
|
||||
'77.3',
|
||||
'49.32',
|
||||
'49.39',
|
||||
'49.3',
|
||||
'49.31',
|
||||
'49.31.2',
|
||||
'53.20.3',
|
||||
'53.20.32',
|
||||
'77.11',
|
||||
].includes(okved)
|
||||
) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message:
|
||||
'По данному ОКВЭД Контрагента возможен только индивидуальный запрос тарифов КАСКО/ОСАГО. Просьба обратиться на адрес strakhovka@evoleasing.ru',
|
||||
path: ['eltKasko'],
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -52,13 +52,21 @@ export function createValidationReaction<T extends ZodTypeAny>(
|
||||
|
||||
if (validationResult.success === false) {
|
||||
validationResult.error.errors.forEach(({ path, message }) => {
|
||||
(path as Array<Elements & ('insurance' | 'payments')>).forEach((elementName) => {
|
||||
(
|
||||
path as Array<Elements & ('eltKasko' | 'eltOsago' | 'insurance' | 'payments')>
|
||||
).forEach((elementName) => {
|
||||
if (elementName === 'insurance') {
|
||||
const removeError = $tables.insurance.setError({ key, message });
|
||||
if (removeError) helper.add(removeError);
|
||||
} else if (elementName === 'payments') {
|
||||
const removeError = $tables.payments.setError({ key, message });
|
||||
if (removeError) helper.add(removeError);
|
||||
} else if (elementName === 'eltOsago') {
|
||||
const removeError = $tables.elt.osago.validation.setError({ key, message });
|
||||
if (removeError) helper.add(removeError);
|
||||
} else if (elementName === 'eltKasko') {
|
||||
const removeError = $tables.elt.kasko.validation.setError({ key, message });
|
||||
if (removeError) helper.add(removeError);
|
||||
} else {
|
||||
const removeError = $calculation.element(elementName).setError({ key, message });
|
||||
if (removeError) helper.add(removeError);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user