From 15261931c273f57ff856d21987789fab0e2ea957 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Thu, 13 Apr 2023 19:54:58 +0300 Subject: [PATCH] release/dyn-2505_check_av_by_brand --- apps/web/graphql/crm.query.graphql | 1 + apps/web/graphql/crm.schema.graphql | 59 +++++++++++++++++++ apps/web/graphql/crm.types.ts | 4 +- apps/web/process/supplier-agent/validation.ts | 38 +++++++++++- 4 files changed, 98 insertions(+), 4 deletions(-) diff --git a/apps/web/graphql/crm.query.graphql b/apps/web/graphql/crm.query.graphql index 4112f31..051d83c 100644 --- a/apps/web/graphql/crm.query.graphql +++ b/apps/web/graphql/crm.query.graphql @@ -326,6 +326,7 @@ query GetBrand($brandId: Uuid!) { evo_id evo_importer_reward_perc evo_importer_reward_rub + evo_maximum_percentage_av } } diff --git a/apps/web/graphql/crm.schema.graphql b/apps/web/graphql/crm.schema.graphql index 77f91f3..bf457ac 100644 --- a/apps/web/graphql/crm.schema.graphql +++ b/apps/web/graphql/crm.schema.graphql @@ -196,6 +196,10 @@ type evo_addcontract { evo_change_payment_date: Boolean evo_chassis: String evo_chassis_new: String + evo_check_success: Boolean + evo_claim_bill_date: DateTime + evo_claim_bill_number: String + evo_claim_sum_plan: Decimal evo_color: String evo_color_new: String evo_contractid: Uuid @@ -316,6 +320,7 @@ type evo_addcontract { evo_leasingobject_specification: String evo_leasingobject_specification_new: String evo_leasing_bonus_summ: Decimal + evo_leasing_profit: Decimal evo_log_activdate_1c: String evo_loss_kv: Decimal evo_maker: String @@ -398,6 +403,7 @@ type evo_addcontract { evo_pts_type_new: Int evo_quoteid: Uuid evo_reasons_calc: [Int!] + evo_reason_validation_doc: [Int!] evo_recalculate_demand: Boolean evo_refuse_reason: Int evo_regionid: Uuid @@ -518,6 +524,7 @@ type email { modifiedon: DateTime regardingobjectid_account: Uuid regardingobjectid_evo_contract: Uuid + regardingobjectid_evo_debtwork_contract: Uuid regardingobjectid_evo_insurance_period: Uuid regardingobjectid_evo_insurance_policy: Uuid regardingobjectid_evo_insurance_policyData: evo_insurance_policy @@ -722,6 +729,7 @@ type evo_request_client { evo_site_text: String evo_statuscodeid: Uuid evo_statuscodeidData: evo_statuscode + evo_statuscode_reason: String evo_storage: String incidents: [incidentGraphQL] link: String @@ -876,24 +884,35 @@ type account { evo_fingap_number_rules: Int evo_fin_department_accountid: Uuid evo_fin_department_accountidData: account + evo_foreign_countries_financing: Boolean evo_fuel_card_code: String evo_fuel_card_login: String evo_fuel_card_pass: String evo_fullname: String evo_group_sales_network: Uuid + evo_gt_sc: String evo_id_elt: String evo_id_elt_osago: String evo_id_elt_smr: String evo_ifns_code: String evo_ifns_code_branch: String evo_ifns_name: String + evo_individual_executive_docdate: DateTime + evo_individual_executive_docnum: String + evo_individual_executive_inn: String + evo_individual_executive_kpp: String + evo_individual_executive_oop: String evo_inn: String + evo_insurance_periods: [evo_insurance_period] evo_invoice_number_fix: String evo_invoice_number_rules: Int + evo_is_individual_executive: Boolean evo_kpp: String + evo_la: String evo_legal_form: Int evo_legal_region_calc: Boolean evo_licenses_list: String + evo_lkt: String evo_lk_regdate: DateTime evo_log_activdate_1c: String evo_management_disqualified: Boolean @@ -910,6 +929,10 @@ type account { evo_osago_with_kasko: Boolean evo_request_clients: [evo_request_client] evo_return_leasing_dealer: Boolean + evo_revenue_source_1: Boolean + evo_revenue_source_2: Boolean + evo_revenue_source_3: Boolean + evo_revenue_source_other: String evo_smb_category: Int evo_smb_issue_date: DateTime evo_special_accounting: Int @@ -941,6 +964,7 @@ type account { telephone2: String telephone3: String toObjectString: String + websiteurl: String } type contact { @@ -951,6 +975,7 @@ type contact { emailaddress2: String emailaddress3: String evo_consent_date: DateTime + evo_delegation_agreement: Boolean evo_docdate: DateTime evo_docnumber: String evo_fact_addressid: Uuid @@ -1060,6 +1085,7 @@ type evo_addproduct_type { } type evo_baseproduct { + accounts(statecode: Int): [account] createdon: DateTime evo_baseproductid: Uuid evo_baseproducts(statecode: Int): [evo_baseproduct] @@ -1118,6 +1144,7 @@ type evo_insurance_period { evo_close: Boolean evo_comment: String evo_contractid: Uuid + evo_contractidData: evo_contract evo_datefrom: DateTime evo_dateto: DateTime evo_dgo_price: Decimal @@ -1165,6 +1192,8 @@ type evo_insurance_period { evo_pay_summ_fact: Decimal evo_period_number: Int evo_prolong_listid: Uuid + evo_request_clientid: Uuid + evo_request_clientidData: evo_request_client evo_request_id_elt: String evo_request_status: Int evo_result_reward_factor: Decimal @@ -1175,6 +1204,7 @@ type evo_insurance_period { evo_territory_price: Decimal evo_under_payment_compensation: Decimal evo_unlimit_drivers: Boolean + link: String modifiedon: DateTime ownerid_systemuser: Uuid ownerid_team: Uuid @@ -1233,6 +1263,7 @@ type evo_external_supplier_code { evo_external_supplier_codeid: Uuid evo_id: String evo_manager_systemuserid: Uuid + evo_supplier_type: Int modifiedon: DateTime toObjectString: String } @@ -1286,6 +1317,7 @@ type evo_leasingobject { evo_engine_power_kvt: Decimal evo_engine_type: Int evo_engine_volume: Decimal + evo_epts_status: Int evo_equipmentid: Uuid evo_gosnumber: String evo_gos_akt: String @@ -1298,6 +1330,7 @@ type evo_leasingobject { evo_legal_regionid: Uuid evo_legal_townid: Uuid evo_maker: String + evo_maximum_percentage_av: Decimal evo_max_mass: Decimal evo_max_speed: Decimal evo_mileage: Decimal @@ -1397,6 +1430,7 @@ type lead { evo_comment: String evo_double_agent_accountid: Uuid evo_external_supplierid: Uuid + evo_failure: Boolean evo_fin_department_accountid: Uuid evo_firstname: String evo_inn: String @@ -1442,6 +1476,7 @@ type opportunity { evo_all_credit_evosmart: Decimal evo_approvallogs: [evo_approvallog] evo_assignor_accountid: Uuid + evo_board_of_directors: String evo_businessunitid: Uuid evo_businessunitidData: businessunit evo_cession_incidentid: Uuid @@ -1449,6 +1484,7 @@ type opportunity { evo_check_type_fact: [Int!] evo_client_riskid: Uuid evo_client_riskidData: evo_client_risk + evo_collective_executive: String evo_comment_description: String evo_contracts: [evo_contract] evo_credit_analyst_systemuserid: Uuid @@ -1456,6 +1492,7 @@ type opportunity { evo_declaration_revenue: Decimal evo_docpay_ka_received: Int evo_docpay_ka_require: Boolean + evo_financial_loan: Decimal evo_founder1_beneficial_owner: Boolean evo_founder1_contactid: Uuid evo_founder1_part: Decimal @@ -1479,10 +1516,13 @@ type opportunity { evo_guarantor2_contactid: Uuid evo_guarantor3_contactid: Uuid evo_guarantor4_contactid: Uuid + evo_high_level: String + evo_individual_executive: String evo_leadid: Uuid evo_leadidData: lead evo_mps_systemuserid: Uuid evo_oppnumber: String + evo_other_control: String evo_process_type: Int evo_programsolution: Int evo_report_year: Int @@ -1521,6 +1561,7 @@ type quote { customerid_contact: Uuid evo_accept_control_addproduct_typeid: Uuid evo_accept_control_addproduct_typeidData: evo_addproduct_type + evo_accept_param: [Int!] evo_accept_period: Int evo_accept_quoteid: Uuid evo_acquisition_costs: Decimal @@ -1833,6 +1874,7 @@ type evo_brand { evo_id: String evo_importer_reward_perc: Decimal evo_importer_reward_rub: Decimal + evo_maximum_percentage_av: Decimal evo_name: String evo_subsidies(statecode: Int): [evo_subsidy] evo_vehicle_type: [Int!] @@ -2124,6 +2166,7 @@ type evo_request_payment { type evo_documenttype { createdon: DateTime evo_check_edo: Boolean + evo_clientsign_field: String evo_code_wm: String evo_comment: String evo_documenttypeid: Uuid @@ -2203,6 +2246,7 @@ type evo_contract { evo_date_of_pledge_claim: DateTime evo_date_of_pledge_leasobject: DateTime evo_date_of_sending_dkp: DateTime + evo_date_of_sending_dl: DateTime evo_date_sor: DateTime evo_date_termination: DateTime evo_dealer_broker_accountid: Uuid @@ -2300,6 +2344,8 @@ type evo_contract { evo_leasing_bonus_pay_date: DateTime evo_leasing_bonus_summ: Decimal evo_leasing_pledge_agreementid: Uuid + evo_leasing_profit: Decimal + evo_leasing_profit_actual: Decimal evo_lessor_bank_detailsid: Uuid evo_log_activdate_1c: String evo_msfo_irr: Decimal @@ -2324,6 +2370,7 @@ type evo_contract { evo_payment_redemption: Int evo_payment_redemption_sum: Decimal evo_payment_redemption_sum_without_nds: Decimal + evo_paysum_before_act_date_plan: Decimal evo_period: Int evo_previous_accountid: Uuid evo_price_without_discount: Decimal @@ -2365,6 +2412,7 @@ type evo_contract { evo_subsidy_validity_date: DateTime evo_sumhold_date_sor: Decimal evo_sumhold_month: Decimal + evo_sum_pay_future: Decimal evo_supplier_accountid: Uuid evo_supplier_bank_detailsid: Uuid evo_supplier_bank_detailsidData: evo_bank_details @@ -2411,10 +2459,12 @@ type evo_external_system_request { evo_accountidData: account evo_addcontractid: Uuid evo_addproductid: Uuid + evo_addressid: Uuid evo_agency_agreementid: Uuid evo_contactid: Uuid evo_contractid: Uuid evo_credreg_report_code: String + evo_debtwork_contractid: Uuid evo_emailid: Uuid evo_emailidData: email evo_external_system_requestid: Uuid @@ -2441,6 +2491,7 @@ type evo_external_system_request { type evo_paymentorder { createdon: DateTime evo_account_name_text: String + evo_addcontractid: Uuid evo_comment: String evo_contractid: Uuid evo_correction_date_1c: DateTime @@ -2569,6 +2620,7 @@ type evo_tarif { evo_model_exceptions(statecode: Int): [evo_model] evo_name: String evo_pay_supplier_without_addcontract: Boolean + evo_pl_use_type: [Int!] evo_rates(statecode: Int): [evo_rate] evo_seasons_type_exception: [Int!] evo_tarifid: Uuid @@ -2651,6 +2703,7 @@ type evo_address { evo_flat: String evo_flat_type: String evo_flat_type_full: String + evo_geocoding_level: Int evo_geo_lat: String evo_geo_lon: String evo_house: String @@ -2690,6 +2743,7 @@ type systemuser { domainname: String evo_access_download_ni: Boolean evo_access_exception_addcontract: Boolean + evo_alt_lead: Boolean evo_available_assignment_director: Boolean evo_baseproducts(statecode: Int): [evo_baseproduct] evo_callrecords_access: Boolean @@ -2729,11 +2783,13 @@ type evo_identity_document { createdon: DateTime evo_citizenship_countryid: Uuid evo_code: String + evo_contactid: Uuid evo_docnumber: String evo_doctype: Int evo_employee_systemuserid: Uuid evo_identity_documentid: Uuid evo_issueby: String + evo_issueby_search_dadata: String evo_issuedate: DateTime evo_placebirth: String evo_registration_addressid: Uuid @@ -2905,6 +2961,7 @@ type evo_insurance_policy { evo_insurance_policyid: Uuid evo_insurer_accountid: Uuid evo_ins_change_comment: String + evo_name: String evo_nsib_ins_summ: Decimal evo_one_year_insurance: Boolean evo_owner_comment: String @@ -2914,6 +2971,7 @@ type evo_insurance_policy { evo_pre_polis_number: String evo_quoteid: Uuid evo_statuscodeid: Uuid + link: String modifiedon: DateTime ownerid: Uuid statecode: Int @@ -2982,6 +3040,7 @@ type evo_edo { evo_box_edoidData: evo_edo evo_box_id: String evo_box_name: String + evo_client_signer_contactid: Uuid evo_contractid: Uuid evo_contractidData: evo_contract evo_documentid: Uuid diff --git a/apps/web/graphql/crm.types.ts b/apps/web/graphql/crm.types.ts index e9c6f97..ef8b8dc 100644 --- a/apps/web/graphql/crm.types.ts +++ b/apps/web/graphql/crm.types.ts @@ -293,7 +293,7 @@ export type GetBrandQueryVariables = Exact<{ }>; -export type GetBrandQuery = { __typename?: 'Query', evo_brand: { __typename?: 'evo_brand', evo_id: string | null, evo_importer_reward_perc: number | null, evo_importer_reward_rub: number | null } | null }; +export type GetBrandQuery = { __typename?: 'Query', evo_brand: { __typename?: 'evo_brand', evo_id: string | null, evo_importer_reward_perc: number | null, evo_importer_reward_rub: number | null, evo_maximum_percentage_av: number | null } | null }; export type GetModelsQueryVariables = Exact<{ brandId: Scalars['Uuid']; @@ -630,7 +630,7 @@ export const GetGpsModelsDocument = {"kind":"Document","definitions":[{"kind":"O 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 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"}}]}}]}}]} 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"}}]}}]}}]} 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"}}]}}]}}]} 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; diff --git a/apps/web/process/supplier-agent/validation.ts b/apps/web/process/supplier-agent/validation.ts index c74919f..f27389e 100644 --- a/apps/web/process/supplier-agent/validation.ts +++ b/apps/web/process/supplier-agent/validation.ts @@ -176,8 +176,7 @@ const SumsSchema = ValuesSchema.pick({ export function createValidationSchema(context: ValidationContext) { const { apolloClient } = context; - return z - .object({}) + return ValuesSchema.pick({ brand: true }) .merge(AgentsSchema) .merge(ConditionsSchema) .merge(SumsSchema) @@ -202,6 +201,7 @@ export function createValidationSchema(context: ValidationContext) { indAgent, indAgentRewardCondition, indAgentRewardSumm, + brand: brandId, } = values; /** @@ -463,5 +463,39 @@ export function createValidationSchema(context: ValidationContext) { fieldName: 'selectIndAgentRewardCondition', }); } + + if (brandId) { + const { + data: { evo_brand }, + } = await apolloClient.query({ + query: CRMTypes.GetBrandDocument, + variables: { brandId }, + }); + + if ( + evo_brand?.evo_maximum_percentage_av && + indAgentRewardSumm + + calcDoubleAgentRewardSumm + + dealerRewardSumm + + calcBrokerRewardSum + + dealerBrokerRewardSumm + + finDepartmentRewardSumm > + evo_brand?.evo_maximum_percentage_av + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: + 'В данном расчете АВ закладывается выше установленного максимума. Уменьшите размер АВ', + path: [ + 'tbxDealerRewardSumm', + 'tbxDealerBrokerRewardSumm', + 'tbxIndAgentRewardSumm', + 'tbxCalcDoubleAgentRewardSumm', + 'tbxCalcBrokerRewardSum', + 'tbxFinDepartmentRewardSumm', + ], + }); + } + } }); }