From 66fc8ee70ea224b950ebeeb9ab00d2f10cc6bbc1 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Thu, 11 Apr 2024 15:00:34 +0300 Subject: [PATCH] merge branch release/dyn-4114_filter-models --- apps/web/graphql/crm.query.graphql | 9 +++ apps/web/graphql/crm.schema.graphql | 3 + apps/web/graphql/crm.types.ts | 12 ++-- .../leasing-object/reactions/common.ts | 31 +++++++-- apps/web/process/leasing-object/validation.ts | 65 +++++++++++-------- 5 files changed, 84 insertions(+), 36 deletions(-) diff --git a/apps/web/graphql/crm.query.graphql b/apps/web/graphql/crm.query.graphql index 1c36e39..7187b52 100644 --- a/apps/web/graphql/crm.query.graphql +++ b/apps/web/graphql/crm.query.graphql @@ -499,6 +499,11 @@ query GetLeaseObjectType($leaseObjectTypeId: Uuid!) { evo_expluatation_period2 evo_depreciation_rate1 evo_depreciation_rate2 + evo_trailer + evo_vehicle_body_type_option + evo_vehicle_body_types { + evo_vehicle_body_typeid + } } } @@ -527,6 +532,8 @@ query GetModels($brandId: Uuid!) { value: evo_modelid evo_modelid evo_vehicle_type + evo_trailer_sign + evo_vehicle_body_typeid } } @@ -542,6 +549,8 @@ query GetModel($modelId: Uuid!) { evo_id_elt } evo_running_gear + evo_trailer_sign + evo_vehicle_body_typeid } } diff --git a/apps/web/graphql/crm.schema.graphql b/apps/web/graphql/crm.schema.graphql index eaeb878..4ad3646 100644 --- a/apps/web/graphql/crm.schema.graphql +++ b/apps/web/graphql/crm.schema.graphql @@ -1803,7 +1803,10 @@ type evo_leasingobject_type { evo_name: String evo_reward_summ_accept: Decimal evo_subsidies(statecode: Int): [evo_subsidy] + evo_trailer: Boolean evo_type_code: String + evo_vehicle_body_types: [evo_vehicle_body_type] + evo_vehicle_body_type_option: Int evo_vehicle_type: [Int!] evo_vehicle_type_tax: Int importsequencenumber: Int diff --git a/apps/web/graphql/crm.types.ts b/apps/web/graphql/crm.types.ts index 75bdad7..f195bd3 100644 --- a/apps/web/graphql/crm.types.ts +++ b/apps/web/graphql/crm.types.ts @@ -267,7 +267,7 @@ export type GetLeaseObjectTypeQueryVariables = Exact<{ }>; -export type GetLeaseObjectTypeQuery = { __typename?: 'Query', evo_leasingobject_type: { __typename?: 'evo_leasingobject_type', evo_vehicle_type: Array | null, evo_id: string | null, evo_category: number | null, evo_vehicle_type_tax: number | null, evo_category_tr: Array | null, evo_expluatation_period1: number | null, evo_expluatation_period2: number | null, evo_depreciation_rate1: number | null, evo_depreciation_rate2: number | null } | null }; +export type GetLeaseObjectTypeQuery = { __typename?: 'Query', evo_leasingobject_type: { __typename?: 'evo_leasingobject_type', evo_vehicle_type: Array | null, evo_id: string | null, evo_category: number | null, evo_vehicle_type_tax: number | null, evo_category_tr: Array | null, evo_expluatation_period1: number | null, evo_expluatation_period2: number | null, evo_depreciation_rate1: number | null, evo_depreciation_rate2: number | null, evo_trailer: boolean | null, evo_vehicle_body_type_option: number | null, evo_vehicle_body_types: Array<{ __typename?: 'evo_vehicle_body_type', evo_vehicle_body_typeid: string | null } | null> | null } | null }; export type GetBrandsQueryVariables = Exact<{ [key: string]: never; }>; @@ -286,14 +286,14 @@ export type GetModelsQueryVariables = Exact<{ }>; -export type GetModelsQuery = { __typename?: 'Query', evo_models: Array<{ __typename?: 'evo_model', evo_modelid: string | null, evo_vehicle_type: number | null, label: string | null, value: string | null } | null> | null }; +export type GetModelsQuery = { __typename?: 'Query', evo_models: Array<{ __typename?: 'evo_model', evo_modelid: string | null, evo_vehicle_type: number | null, evo_trailer_sign: boolean | null, evo_vehicle_body_typeid: string | null, label: string | null, value: string | null } | null> | null }; export type GetModelQueryVariables = Exact<{ modelId: Scalars['Uuid']['input']; }>; -export type GetModelQuery = { __typename?: 'Query', evo_model: { __typename?: 'evo_model', evo_importer_reward_perc: number | null, evo_importer_reward_rub: number | null, evo_id: string | null, evo_running_gear: number | null, evo_impairment_groupidData: { __typename?: 'evo_impairment_group', evo_name: string | null } | null, evo_vehicle_body_typeidData: { __typename?: 'evo_vehicle_body_type', evo_id_elt: string | null } | null } | null }; +export type GetModelQuery = { __typename?: 'Query', evo_model: { __typename?: 'evo_model', evo_importer_reward_perc: number | null, evo_importer_reward_rub: number | null, evo_id: string | null, evo_running_gear: number | null, evo_trailer_sign: boolean | null, evo_vehicle_body_typeid: string | null, evo_impairment_groupidData: { __typename?: 'evo_impairment_group', evo_name: string | null } | null, evo_vehicle_body_typeidData: { __typename?: 'evo_vehicle_body_type', evo_id_elt: string | null } | null } | null }; export type GetConfigurationsQueryVariables = Exact<{ modelId: Scalars['Uuid']['input']; @@ -496,11 +496,11 @@ export const GetTownDocument = {"kind":"Document","definitions":[{"kind":"Operat export const GetGpsBrandsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetGPSBrands"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_gps_brands"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_gps_brandid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id"}}]}}]}}]} as unknown as DocumentNode; export const GetGpsModelsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetGPSModels"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"gpsBrandId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_gps_models"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_gps_brandid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"gpsBrandId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_gps_modelid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id"}}]}}]}}]} as unknown as DocumentNode; export const GetLeaseObjectTypesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLeaseObjectTypes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_leasingobject_typeid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}}]}}]} as unknown as DocumentNode; -export const GetLeaseObjectTypeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLeaseObjectType"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"leaseObjectTypeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_type"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_leasingobject_typeid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"leaseObjectTypeId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id"}},{"kind":"Field","name":{"kind":"Name","value":"evo_category"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type_tax"}},{"kind":"Field","name":{"kind":"Name","value":"evo_category_tr"}},{"kind":"Field","name":{"kind":"Name","value":"evo_expluatation_period1"}},{"kind":"Field","name":{"kind":"Name","value":"evo_expluatation_period2"}},{"kind":"Field","name":{"kind":"Name","value":"evo_depreciation_rate1"}},{"kind":"Field","name":{"kind":"Name","value":"evo_depreciation_rate2"}}]}}]}}]} as unknown as DocumentNode; +export const GetLeaseObjectTypeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLeaseObjectType"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"leaseObjectTypeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_type"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_leasingobject_typeid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"leaseObjectTypeId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id"}},{"kind":"Field","name":{"kind":"Name","value":"evo_category"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type_tax"}},{"kind":"Field","name":{"kind":"Name","value":"evo_category_tr"}},{"kind":"Field","name":{"kind":"Name","value":"evo_expluatation_period1"}},{"kind":"Field","name":{"kind":"Name","value":"evo_expluatation_period2"}},{"kind":"Field","name":{"kind":"Name","value":"evo_depreciation_rate1"}},{"kind":"Field","name":{"kind":"Name","value":"evo_depreciation_rate2"}},{"kind":"Field","name":{"kind":"Name","value":"evo_trailer"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_body_type_option"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_body_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_body_typeid"}}]}}]}}]}}]} as unknown as DocumentNode; export const GetBrandsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetBrands"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_brands"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_brandid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_brandid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type"}}]}}]}}]} as unknown as DocumentNode; export const GetBrandDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetBrand"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"brandId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_brand"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_brandid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"brandId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_id"}},{"kind":"Field","name":{"kind":"Name","value":"evo_importer_reward_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_importer_reward_rub"}},{"kind":"Field","name":{"kind":"Name","value":"evo_maximum_percentage_av"}},{"kind":"Field","name":{"kind":"Name","value":"evo_brand_owner"}}]}}]}}]} as unknown as DocumentNode; -export const GetModelsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetModels"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"brandId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_models"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_brandid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"brandId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_modelid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_modelid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type"}}]}}]}}]} as unknown as DocumentNode; -export const GetModelDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetModel"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"modelId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_model"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_modelid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"modelId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_impairment_groupidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_importer_reward_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_importer_reward_rub"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_body_typeidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_id_elt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_running_gear"}}]}}]}}]} as unknown as DocumentNode; +export const GetModelsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetModels"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"brandId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_models"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_brandid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"brandId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_modelid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_modelid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_trailer_sign"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_body_typeid"}}]}}]}}]} as unknown as DocumentNode; +export const GetModelDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetModel"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"modelId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_model"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_modelid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"modelId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_impairment_groupidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_importer_reward_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_importer_reward_rub"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_body_typeidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_id_elt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_running_gear"}},{"kind":"Field","name":{"kind":"Name","value":"evo_trailer_sign"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_body_typeid"}}]}}]}}]} as unknown as DocumentNode; export const GetConfigurationsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetConfigurations"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"modelId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_equipments"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_modelid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"modelId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_equipmentid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_start_production_year"}}]}}]}}]} as unknown as DocumentNode; export const GetConfigurationDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetConfiguration"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"configurationId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_equipment"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_equipmentid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"configurationId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_impairment_groupidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_name"}}]}}]}}]}}]} as unknown as DocumentNode; export const GetDealersDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetDealers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"dealers"},"name":{"kind":"Name","value":"accounts"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_account_type"},"value":{"kind":"ListValue","values":[{"kind":"IntValue","value":"100000001"}]}},{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_legal_form"},"value":{"kind":"IntValue","value":"100000001"}}],"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":"accountid"}},{"kind":"Field","name":{"kind":"Name","value":"accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_supplier_financing_accept"}}]}}]}}]} as unknown as DocumentNode; diff --git a/apps/web/process/leasing-object/reactions/common.ts b/apps/web/process/leasing-object/reactions/common.ts index 1a0a9ad..344ddea 100644 --- a/apps/web/process/leasing-object/reactions/common.ts +++ b/apps/web/process/leasing-object/reactions/common.ts @@ -51,7 +51,20 @@ export default function reactions({ store, apolloClient }: ProcessContext) { models = models?.filter((model) => { if ( model?.evo_vehicle_type && - evo_leasingobject_type?.evo_vehicle_type?.includes(model.evo_vehicle_type) + evo_leasingobject_type?.evo_vehicle_type?.includes(model.evo_vehicle_type) && + (evo_leasingobject_type?.evo_trailer === model?.evo_trailer_sign || + (!evo_leasingobject_type.evo_trailer && !model?.evo_trailer_sign)) && + ((evo_leasingobject_type.evo_vehicle_body_type_option === 100_000_000 && + evo_leasingobject_type.evo_vehicle_body_types?.some( + (evo_vehicle_body_type) => + evo_vehicle_body_type?.evo_vehicle_body_typeid === model.evo_vehicle_body_typeid + )) || + (evo_leasingobject_type.evo_vehicle_body_type_option === 100_000_001 && + !evo_leasingobject_type.evo_vehicle_body_types?.some( + (evo_vehicle_body_type) => + evo_vehicle_body_type?.evo_vehicle_body_typeid === model.evo_vehicle_body_typeid + )) || + evo_leasingobject_type.evo_vehicle_body_type_option === 100_000_002) ) { return model; } @@ -352,9 +365,10 @@ export default function reactions({ store, apolloClient }: ProcessContext) { 'engineVolume', 'engineType', 'leaseObjectMotorPower', + 'model', ]), - async ({ leaseObjectType: leaseObjectTypeId }) => { - if (!leaseObjectTypeId) { + async ({ leaseObjectType: leaseObjectTypeId, model: modelId }) => { + if (!leaseObjectTypeId || !modelId) { $calculation.element('selectEngineType').unblock(); $calculation.element('tbxEngineVolume').unblock(); $calculation.element('tbxLeaseObjectMotorPower').unblock(); @@ -371,7 +385,16 @@ export default function reactions({ store, apolloClient }: ProcessContext) { }, }); - if (evo_leasingobject_type?.evo_id === '8') { + const { + data: { evo_model }, + } = await apolloClient.query({ + query: CRMTypes.GetModelDocument, + variables: { + modelId, + }, + }); + + if (evo_leasingobject_type?.evo_id === '8' || evo_model?.evo_trailer_sign === true) { $calculation.element('selectEngineType').setValue(null).block(); $calculation.element('tbxEngineVolume').resetValue().block(); $calculation.element('tbxLeaseObjectMotorPower').resetValue().block(); diff --git a/apps/web/process/leasing-object/validation.ts b/apps/web/process/leasing-object/validation.ts index beec27d..de74677 100644 --- a/apps/web/process/leasing-object/validation.ts +++ b/apps/web/process/leasing-object/validation.ts @@ -29,7 +29,7 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { maxMass, leaseObjectCategory, brand, - model, + model: modelId, leaseObjectUseFor, configuration, }, @@ -51,7 +51,7 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { }); } - if (!model) { + if (!modelId) { ctx.addIssue({ code: z.ZodIssueCode.custom, message: 'Не заполнено поле', @@ -59,12 +59,12 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { }); } - if (model && !configuration) { + if (modelId && !configuration) { const { data: { evo_equipments }, } = await apolloClient.query({ query: CRMTypes.GetConfigurationsDocument, - variables: { modelId: model }, + variables: { modelId }, }); if (evo_equipments?.length) { @@ -94,31 +94,44 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { }, }); - const isNotTrailer = - evo_leasingobject_type?.evo_id !== null && evo_leasingobject_type?.evo_id !== '8'; - - if (isNotTrailer && engineVolume <= 0) { - ctx.addIssue({ - code: z.ZodIssueCode.custom, - message: 'Не заполнено поле', - path: ['tbxEngineVolume'], + if (modelId) { + const { + data: { evo_model }, + } = await apolloClient.query({ + query: CRMTypes.GetModelDocument, + variables: { + modelId, + }, }); - } - if (isNotTrailer && !engineType) { - ctx.addIssue({ - code: z.ZodIssueCode.custom, - message: 'Не заполнено поле', - path: ['selectEngineType'], - }); - } + const isNotTrailer = + evo_leasingobject_type?.evo_id !== null && + evo_leasingobject_type?.evo_id !== '8' && + evo_model?.evo_trailer_sign !== true; - if (isNotTrailer && leaseObjectMotorPower <= 0) { - ctx.addIssue({ - code: z.ZodIssueCode.custom, - message: 'Не заполнено поле', - path: ['tbxLeaseObjectMotorPower'], - }); + if (isNotTrailer && engineType !== 100_000_003 && engineVolume <= 0) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Не заполнено поле', + path: ['tbxEngineVolume'], + }); + } + + if (isNotTrailer && !engineType) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Не заполнено поле', + path: ['selectEngineType'], + }); + } + + if (isNotTrailer && leaseObjectMotorPower <= 0) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Не заполнено поле', + path: ['tbxLeaseObjectMotorPower'], + }); + } } if (evo_leasingobject_type?.evo_id === '1' && countSeats >= 9) {