diff --git a/apps/web/config/schema/values.ts b/apps/web/config/schema/values.ts index 5ec7c04..d924ccd 100644 --- a/apps/web/config/schema/values.ts +++ b/apps/web/config/schema/values.ts @@ -3,7 +3,7 @@ import { z } from 'zod'; const ValuesSchema = z.object({ addEquipmentPrice: z.number(), - balanceHolder: z.number().nullable(), + balanceHolder: z.number(), bonusCoefficient: z.number(), brand: z.string().nullable(), calcBroker: z.string().nullable(), @@ -13,7 +13,7 @@ const ValuesSchema = z.object({ calcDoubleAgentRewardCondition: z.string().nullable(), calcDoubleAgentRewardSumm: z.number(), calcFinDepartment: z.string().nullable(), - calcType: z.number().nullable(), + calcType: z.number(), clientRisk: z.string().nullable(), clientType: z.string().nullable(), comissionPerc: z.number(), @@ -29,7 +29,7 @@ const ValuesSchema = z.object({ dealerPerson: z.string().nullable(), dealerRewardCondition: z.string().nullable(), dealerRewardSumm: z.number(), - deliveryTime: z.number().nullable(), + deliveryTime: z.number(), disableChecks: z.boolean(), engineHours: z.number(), engineType: z.number().nullable(), @@ -42,7 +42,7 @@ const ValuesSchema = z.object({ fullPriceWithDiscount: z.boolean(), GPSBrand: z.string().nullable(), GPSModel: z.string().nullable(), - graphType: z.number().nullable(), + graphType: z.number(), highSeasonStart: z.number().nullable(), importerRewardPerc: z.number(), importerRewardRub: z.number(), diff --git a/apps/web/constants/values.js b/apps/web/constants/values.js index 55ec457..046bcb9 100644 --- a/apps/web/constants/values.js +++ b/apps/web/constants/values.js @@ -9,3 +9,5 @@ export const MIN_PAYMENT = 3; export const VAT = 0.2; export const MAX_MASS = 3500; export const MAX_VEHICLE_SEATS = 20; +export const ESN = 1.3; +export const NSIB_MAX = 5_000_000; diff --git a/apps/web/graphql/crm.query.graphql b/apps/web/graphql/crm.query.graphql index 5ace66c..d335344 100644 --- a/apps/web/graphql/crm.query.graphql +++ b/apps/web/graphql/crm.query.graphql @@ -12,6 +12,7 @@ query GetTransactionCurrency($currencyid: Uuid!) { transactioncurrency(transactioncurrencyid: $currencyid) { currencysymbol isocurrencycode + transactioncurrencyid } } @@ -134,6 +135,8 @@ query GetTarif($tarifId: Uuid!) { evo_datefrom evo_rateid } + evo_irr_plan + evo_margin_min } } @@ -155,6 +158,7 @@ query GetRates($currentDate: DateTime) { query GetRate($rateId: Uuid!) { evo_rate(evo_rateid: $rateId) { evo_base_rate + evo_credit_period } } @@ -187,6 +191,7 @@ query GetProduct($productId: Uuid!) { evo_cut_proportion_bonus_director evo_cut_irr_with_bonus evo_sale_without_nds + evo_id } } @@ -219,6 +224,7 @@ query GetSubsidy($subsidyId: Uuid!) { evo_subsidy_summ evo_percent_subsidy evo_max_subsidy_summ + evo_get_subsidy_payment } } @@ -295,6 +301,10 @@ query GetLeaseObjectType($leaseObjectTypeId: Uuid!) { evo_category evo_vehicle_type_tax evo_category_tr + evo_expluatation_period1 + evo_expluatation_period2 + evo_depreciation_rate1 + evo_depreciation_rate2 } } @@ -410,7 +420,9 @@ query GetRewardCondition($conditionId: Uuid!) { evo_agency_agreementidData { evo_required_reward evo_reward_without_other_agent + evo_leasingobject_price } + evo_calc_reward_rules } } @@ -430,14 +442,29 @@ query GetCoefficients($currentDate: DateTime, $jobTitleId: Uuid!) { evo_sot_coefficient_typeid evo_baseproducts { evo_baseproductid + evo_id } evo_sot_coefficient + evo_corfficient_type + evo_sot_coefficient_typeidData { + evo_id + } + evo_correction_coefficient + evo_min_period + evo_max_period + evo_season_type + evo_graph_type + evo_businessunits { + evo_sale_businessunitid + } + evo_risk_delta } } query GetSystemUser($domainname: String) { systemuser(domainname: $domainname) { evo_job_titleid + businessunitid } } @@ -462,6 +489,19 @@ query GetAddProductType($addproductTypeId: Uuid!) { evo_addproduct_type(evo_addproduct_typeid: $addproductTypeId) { evo_description evo_helpcard_type + evo_planpayments { + evo_name + evo_cost_price_telematics_withoutnds + evo_cost_equipment_withoutnds + evo_cost_telematics_withoutnds + } + evo_graph_price_withoutnds + evo_cost_service_provider_withoutnds + evo_retro_bonus_withoutnds + evo_evokasko_calc_type + evo_loss_kv + evo_price_service_provider_withoutnds + evo_graph_price } } diff --git a/apps/web/graphql/crm.types.ts b/apps/web/graphql/crm.types.ts index 9d759bc..4e271c7 100644 --- a/apps/web/graphql/crm.types.ts +++ b/apps/web/graphql/crm.types.ts @@ -126,7 +126,7 @@ export type GetTransactionCurrencyQueryVariables = Exact<{ }>; -export type GetTransactionCurrencyQuery = { __typename?: 'Query', transactioncurrency: { __typename?: 'transactioncurrency', currencysymbol: string | null, isocurrencycode: string | null } | null }; +export type GetTransactionCurrencyQuery = { __typename?: 'Query', transactioncurrency: { __typename?: 'transactioncurrency', currencysymbol: string | null, isocurrencycode: string | null, transactioncurrencyid: string | null } | null }; export type GetCurrencyChangesQueryVariables = Exact<{ currentDate: InputMaybe; @@ -189,7 +189,7 @@ export type GetTarifQueryVariables = Exact<{ }>; -export type GetTarifQuery = { __typename?: 'Query', evo_tarif: { __typename?: 'evo_tarif', evo_irr: number | null, evo_graphtype_exception: Array | null, evo_seasons_type_exception: Array | null, evo_min_decreasing_perc: number | null, evo_min_irr: number | null, evo_cut_irr_with_bonus_coefficient: number | null, evo_max_irr: number | null, evo_rates: Array<{ __typename?: 'evo_rate', evo_datefrom: string | null, evo_rateid: string | null } | null> | null } | null }; +export type GetTarifQuery = { __typename?: 'Query', evo_tarif: { __typename?: 'evo_tarif', evo_irr: number | null, evo_graphtype_exception: Array | null, evo_seasons_type_exception: Array | null, evo_min_decreasing_perc: number | null, evo_min_irr: number | null, evo_cut_irr_with_bonus_coefficient: number | null, evo_max_irr: number | null, evo_irr_plan: number | null, evo_margin_min: number | null, evo_rates: Array<{ __typename?: 'evo_rate', evo_datefrom: string | null, evo_rateid: string | null } | null> | null } | null }; export type GetRatesQueryVariables = Exact<{ currentDate: InputMaybe; @@ -203,7 +203,7 @@ export type GetRateQueryVariables = Exact<{ }>; -export type GetRateQuery = { __typename?: 'Query', evo_rate: { __typename?: 'evo_rate', evo_base_rate: number | null } | null }; +export type GetRateQuery = { __typename?: 'Query', evo_rate: { __typename?: 'evo_rate', evo_base_rate: number | null, evo_credit_period: number | null } | null }; export type GetProductsQueryVariables = Exact<{ currentDate: InputMaybe; @@ -217,7 +217,7 @@ export type GetProductQueryVariables = Exact<{ }>; -export type GetProductQuery = { __typename?: 'Query', evo_baseproduct: { __typename?: 'evo_baseproduct', evo_calculation_method: Array | null, evo_sale_without_nds: boolean | null, evo_cut_proportion_bonus_director: boolean | null, evo_cut_irr_with_bonus: boolean | null, evo_leasingobject_types: Array<{ __typename?: 'evo_leasingobject_type', evo_leasingobject_typeid: string | null } | null> | null, evo_baseproducts: Array<{ __typename?: 'evo_baseproduct', evo_baseproductid: string | null } | null> | null, evo_brands: Array<{ __typename?: 'evo_brand', evo_brandid: string | null } | null> | null } | null }; +export type GetProductQuery = { __typename?: 'Query', evo_baseproduct: { __typename?: 'evo_baseproduct', evo_calculation_method: Array | null, evo_sale_without_nds: boolean | null, evo_cut_proportion_bonus_director: boolean | null, evo_cut_irr_with_bonus: boolean | null, evo_id: string | null, evo_leasingobject_types: Array<{ __typename?: 'evo_leasingobject_type', evo_leasingobject_typeid: string | null } | null> | null, evo_baseproducts: Array<{ __typename?: 'evo_baseproduct', evo_baseproductid: string | null } | null> | null, evo_brands: Array<{ __typename?: 'evo_brand', evo_brandid: string | null } | null> | null } | null }; export type GetSubsidiesQueryVariables = Exact<{ currentDate: InputMaybe; @@ -231,7 +231,7 @@ export type GetSubsidyQueryVariables = Exact<{ }>; -export type GetSubsidyQuery = { __typename?: 'Query', evo_subsidy: { __typename?: 'evo_subsidy', evo_subsidy_summ: number | null, evo_percent_subsidy: number | null, evo_max_subsidy_summ: number | null, evo_leasingobject_types: Array<{ __typename?: 'evo_leasingobject_type', evo_leasingobject_typeid: string | null } | null> | null, accounts: Array<{ __typename?: 'account', accountid: string | null } | null> | null, evo_brands: Array<{ __typename?: 'evo_brand', evo_brandid: string | null } | null> | null, evo_models: Array<{ __typename?: 'evo_model', evo_modelid: string | null } | null> | null } | null }; +export type GetSubsidyQuery = { __typename?: 'Query', evo_subsidy: { __typename?: 'evo_subsidy', evo_subsidy_summ: number | null, evo_percent_subsidy: number | null, evo_max_subsidy_summ: number | null, evo_get_subsidy_payment: number | null, evo_leasingobject_types: Array<{ __typename?: 'evo_leasingobject_type', evo_leasingobject_typeid: string | null } | null> | null, accounts: Array<{ __typename?: 'account', accountid: string | null } | null> | null, evo_brands: Array<{ __typename?: 'evo_brand', evo_brandid: string | null } | null> | null, evo_models: Array<{ __typename?: 'evo_model', evo_modelid: string | null } | null> | null } | null }; export type GetImportProgramQueryVariables = Exact<{ importProgramId: Scalars['Uuid']; @@ -281,7 +281,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 } | 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 } | null }; export type GetBrandsQueryVariables = Exact<{ [key: string]: never; }>; @@ -369,7 +369,7 @@ export type GetRewardConditionQueryVariables = Exact<{ }>; -export type GetRewardConditionQuery = { __typename?: 'Query', evo_reward_condition: { __typename?: 'evo_reward_condition', evo_reward_summ: number | null, evo_reduce_reward: boolean | null, evo_min_reward_summ: number | null, evo_agency_agreementidData: { __typename?: 'evo_agency_agreement', evo_required_reward: boolean | null, evo_reward_without_other_agent: boolean | null } | null } | null }; +export type GetRewardConditionQuery = { __typename?: 'Query', evo_reward_condition: { __typename?: 'evo_reward_condition', evo_reward_summ: number | null, evo_reduce_reward: boolean | null, evo_min_reward_summ: number | null, evo_calc_reward_rules: number | null, evo_agency_agreementidData: { __typename?: 'evo_agency_agreement', evo_required_reward: boolean | null, evo_reward_without_other_agent: boolean | null, evo_leasingobject_price: number | null } | null } | null }; export type GetSotCoefficientTypeQueryVariables = Exact<{ evo_id: InputMaybe; @@ -384,14 +384,14 @@ export type GetCoefficientsQueryVariables = Exact<{ }>; -export type GetCoefficientsQuery = { __typename?: 'Query', evo_coefficients: Array<{ __typename?: 'evo_coefficient', evo_job_titleid: string | null, evo_sot_coefficient_typeid: string | null, evo_sot_coefficient: number | null, evo_baseproducts: Array<{ __typename?: 'evo_baseproduct', evo_baseproductid: string | null } | null> | null } | null> | null }; +export type GetCoefficientsQuery = { __typename?: 'Query', evo_coefficients: Array<{ __typename?: 'evo_coefficient', evo_job_titleid: string | null, evo_sot_coefficient_typeid: string | null, evo_sot_coefficient: number | null, evo_corfficient_type: number | null, evo_correction_coefficient: number | null, evo_min_period: number | null, evo_max_period: number | null, evo_season_type: number | null, evo_graph_type: number | null, evo_risk_delta: number | null, evo_baseproducts: Array<{ __typename?: 'evo_baseproduct', evo_baseproductid: string | null, evo_id: string | null } | null> | null, evo_sot_coefficient_typeidData: { __typename?: 'evo_sot_coefficient_type', evo_id: string | null } | null, evo_businessunits: Array<{ __typename?: 'evo_businessunit', evo_sale_businessunitid: string | null } | null> | null } | null> | null }; export type GetSystemUserQueryVariables = Exact<{ domainname: InputMaybe; }>; -export type GetSystemUserQuery = { __typename?: 'Query', systemuser: { __typename?: 'systemuser', evo_job_titleid: string | null } | null }; +export type GetSystemUserQuery = { __typename?: 'Query', systemuser: { __typename?: 'systemuser', evo_job_titleid: string | null, businessunitid: string | null } | null }; export type CoreAddProductTypesFieldsFragment = { __typename?: 'evo_addproduct_type', evo_graph_price: number | null, label: string | null, value: string | null }; @@ -407,7 +407,7 @@ export type GetAddProductTypeQueryVariables = Exact<{ }>; -export type GetAddProductTypeQuery = { __typename?: 'Query', evo_addproduct_type: { __typename?: 'evo_addproduct_type', evo_description: string | null, evo_helpcard_type: number | null } | null }; +export type GetAddProductTypeQuery = { __typename?: 'Query', evo_addproduct_type: { __typename?: 'evo_addproduct_type', evo_description: string | null, evo_helpcard_type: number | null, evo_graph_price_withoutnds: number | null, evo_cost_service_provider_withoutnds: number | null, evo_retro_bonus_withoutnds: number | null, evo_evokasko_calc_type: number | null, evo_loss_kv: number | null, evo_price_service_provider_withoutnds: number | null, evo_graph_price: number | null, evo_planpayments: Array<{ __typename?: 'evo_planpayment', evo_name: string | null, evo_cost_price_telematics_withoutnds: number | null, evo_cost_equipment_withoutnds: number | null, evo_cost_telematics_withoutnds: number | null } | null> | null } | null }; export type GetRegistrationTypesQueryVariables = Exact<{ currentDate: InputMaybe; @@ -591,7 +591,7 @@ export type GetQuoteAgentsDataQuery = { __typename?: 'Query', quote: { __typenam export const CoreAddProductTypesFieldsFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"CoreAddProductTypesFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"evo_addproduct_type"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_graph_price"}},{"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_addproduct_typeid"}}]}}]} as unknown as DocumentNode; export const GetTransactionCurrenciesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetTransactionCurrencies"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"transactioncurrencies"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"currencyname"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"transactioncurrencyid"}},{"kind":"Field","name":{"kind":"Name","value":"transactioncurrencyid"}},{"kind":"Field","name":{"kind":"Name","value":"isocurrencycode"}},{"kind":"Field","name":{"kind":"Name","value":"currencysymbol"}}]}}]}}]} as unknown as DocumentNode; -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"}}]}}]}}]} as unknown as DocumentNode; +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; 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; 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; 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; @@ -600,13 +600,13 @@ export const GetOpportunitiesDocument = {"kind":"Document","definitions":[{"kind 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; 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"}}]}}]}}]} as unknown as DocumentNode; export const GetTarifsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetTarifs"},"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_tarifs"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}}],"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_tarifid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_tarifid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_baseproductid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_delivery_time"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_first_payment"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_first_payment"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_last_payment"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_last_payment"}},{"kind":"Field","name":{"kind":"Name","value":"evo_used"}}]}}]}}]} as unknown as DocumentNode; -export const GetTarifDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetTarif"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"tarifId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_tarif"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_tarifid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"tarifId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_irr"}},{"kind":"Field","name":{"kind":"Name","value":"evo_graphtype_exception"}},{"kind":"Field","name":{"kind":"Name","value":"evo_seasons_type_exception"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_decreasing_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_irr"}},{"kind":"Field","name":{"kind":"Name","value":"evo_cut_irr_with_bonus_coefficient"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_irr"}},{"kind":"Field","name":{"kind":"Name","value":"evo_rates"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_datefrom"}},{"kind":"Field","name":{"kind":"Name","value":"evo_rateid"}}]}}]}}]}}]} as unknown as DocumentNode; +export const GetTarifDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetTarif"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"tarifId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_tarif"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_tarifid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"tarifId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_irr"}},{"kind":"Field","name":{"kind":"Name","value":"evo_graphtype_exception"}},{"kind":"Field","name":{"kind":"Name","value":"evo_seasons_type_exception"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_decreasing_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_irr"}},{"kind":"Field","name":{"kind":"Name","value":"evo_cut_irr_with_bonus_coefficient"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_irr"}},{"kind":"Field","name":{"kind":"Name","value":"evo_rates"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_datefrom"}},{"kind":"Field","name":{"kind":"Name","value":"evo_rateid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_irr_plan"}},{"kind":"Field","name":{"kind":"Name","value":"evo_margin_min"}}]}}]}}]} as unknown as DocumentNode; export const GetRatesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRates"},"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_rates"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}}],"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_rateid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id"}},{"kind":"Field","name":{"kind":"Name","value":"evo_tarifs"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_tarifid"}}]}}]}}]}}]} as unknown as DocumentNode; -export const GetRateDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRate"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"rateId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_rate"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_rateid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"rateId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_base_rate"}}]}}]}}]} as unknown as DocumentNode; +export const GetRateDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRate"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"rateId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_rate"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_rateid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"rateId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_base_rate"}},{"kind":"Field","name":{"kind":"Name","value":"evo_credit_period"}}]}}]}}]} as unknown as DocumentNode; export const GetProductsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetProducts"},"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_baseproducts"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_relation"},"value":{"kind":"ListValue","values":[{"kind":"IntValue","value":"100000000"}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}}],"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_baseproductid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_baseproductid"}}]}}]}}]} as unknown as DocumentNode; -export const GetProductDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetProduct"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"productId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_baseproduct"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_baseproductid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"productId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_calculation_method"}},{"kind":"Field","name":{"kind":"Name","value":"evo_baseproducts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_baseproductid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_brands"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_brandid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_sale_without_nds"}},{"kind":"Field","name":{"kind":"Name","value":"evo_cut_proportion_bonus_director"}},{"kind":"Field","name":{"kind":"Name","value":"evo_cut_irr_with_bonus"}},{"kind":"Field","name":{"kind":"Name","value":"evo_sale_without_nds"}}]}}]}}]} as unknown as DocumentNode; +export const GetProductDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetProduct"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"productId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_baseproduct"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_baseproductid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"productId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_calculation_method"}},{"kind":"Field","name":{"kind":"Name","value":"evo_baseproducts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_baseproductid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_brands"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_brandid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_sale_without_nds"}},{"kind":"Field","name":{"kind":"Name","value":"evo_cut_proportion_bonus_director"}},{"kind":"Field","name":{"kind":"Name","value":"evo_cut_irr_with_bonus"}},{"kind":"Field","name":{"kind":"Name","value":"evo_sale_without_nds"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id"}}]}}]}}]} as unknown as DocumentNode; export const GetSubsidiesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetSubsidies"},"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_subsidies"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}}],"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_subsidyid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_subsidy_type"}}]}}]}}]} as unknown as DocumentNode; -export const GetSubsidyDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetSubsidy"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"subsidyId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_subsidy"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_subsidyid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"subsidyId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"accounts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accountid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_brands"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_brandid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_models"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_modelid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_subsidy_summ"}},{"kind":"Field","name":{"kind":"Name","value":"evo_percent_subsidy"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_subsidy_summ"}}]}}]}}]} as unknown as DocumentNode; +export const GetSubsidyDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetSubsidy"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"subsidyId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_subsidy"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_subsidyid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"subsidyId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"accounts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accountid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_brands"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_brandid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_models"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_modelid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_subsidy_summ"}},{"kind":"Field","name":{"kind":"Name","value":"evo_percent_subsidy"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_subsidy_summ"}},{"kind":"Field","name":{"kind":"Name","value":"evo_get_subsidy_payment"}}]}}]}}]} as unknown as DocumentNode; export const GetImportProgramDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetImportProgram"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"importProgramId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"importProgram"},"name":{"kind":"Name","value":"evo_subsidy"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_subsidyid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"importProgramId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"accounts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accountid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_brands"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_brandid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_models"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_modelid"}}]}}]}}]}}]} as unknown as DocumentNode; export const GetRegionsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRegions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_regions"},"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_regionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fias_id"}},{"kind":"Field","name":{"kind":"Name","value":"evo_businessunit_evolution"}}]}}]}}]} as unknown as DocumentNode; export const GetRegionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRegion"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"regionId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_region"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_regionid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"regionId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_oktmo"}},{"kind":"Field","name":{"kind":"Name","value":"accounts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accountid"}}]}}]}}]}}]} as unknown as DocumentNode; @@ -614,7 +614,7 @@ export const GetTownsDocument = {"kind":"Document","definitions":[{"kind":"Opera 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"}}]}}]}}]} 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"}}]}}]}}]} 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"}}]}}]}}]} 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 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; @@ -627,12 +627,12 @@ export const GetDealerPersonsDocument = {"kind":"Document","definitions":[{"kind export const GetDealerPersonDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetDealerPerson"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"dealerPersonId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"account"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"accountid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"dealerPersonId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_supplier_type"}}]}}]}}]} as unknown as DocumentNode; export const GetAgentDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetAgent"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"agentid"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"agent"},"name":{"kind":"Name","value":"account"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"accountid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"agentid"}}}],"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"}}]}}]}}]} as unknown as DocumentNode; export const GetRewardConditionsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRewardConditions"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"agentid"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}},{"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_reward_conditions"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_agent_accountid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"agentid"}}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_agency_agreementid_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"has"},"value":{"kind":"BooleanValue","value":true}}]}}],"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_reward_conditionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_reward_summ"}}]}}]}}]} as unknown as DocumentNode; -export const GetRewardConditionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRewardCondition"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"conditionId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_reward_condition"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_reward_conditionid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"conditionId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_reward_summ"}},{"kind":"Field","name":{"kind":"Name","value":"evo_reduce_reward"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_reward_summ"}},{"kind":"Field","name":{"kind":"Name","value":"evo_agency_agreementidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_required_reward"}},{"kind":"Field","name":{"kind":"Name","value":"evo_reward_without_other_agent"}}]}}]}}]}}]} as unknown as DocumentNode; +export const GetRewardConditionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRewardCondition"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"conditionId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_reward_condition"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_reward_conditionid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"conditionId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_reward_summ"}},{"kind":"Field","name":{"kind":"Name","value":"evo_reduce_reward"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_reward_summ"}},{"kind":"Field","name":{"kind":"Name","value":"evo_agency_agreementidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_required_reward"}},{"kind":"Field","name":{"kind":"Name","value":"evo_reward_without_other_agent"}},{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_price"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_calc_reward_rules"}}]}}]}}]} as unknown as DocumentNode; export const GetSotCoefficientTypeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetSotCoefficientType"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"evo_id"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_sot_coefficient_type"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"evo_id"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_sot_coefficient_typeid"}}]}}]}}]} as unknown as DocumentNode; -export const GetCoefficientsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetCoefficients"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"jobTitleId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_coefficients"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_job_titleid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"jobTitleId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_job_titleid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_sot_coefficient_typeid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_baseproducts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_baseproductid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_sot_coefficient"}}]}}]}}]} as unknown as DocumentNode; -export const GetSystemUserDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetSystemUser"},"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":"systemuser"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"domainname"},"value":{"kind":"Variable","name":{"kind":"Name","value":"domainname"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_job_titleid"}}]}}]}}]} as unknown as DocumentNode; +export const GetCoefficientsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetCoefficients"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"jobTitleId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_coefficients"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_job_titleid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"jobTitleId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_job_titleid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_sot_coefficient_typeid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_baseproducts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_baseproductid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_sot_coefficient"}},{"kind":"Field","name":{"kind":"Name","value":"evo_corfficient_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_sot_coefficient_typeidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_id"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_correction_coefficient"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_season_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_graph_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_businessunits"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_sale_businessunitid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_risk_delta"}}]}}]}}]} as unknown as DocumentNode; +export const GetSystemUserDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetSystemUser"},"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":"systemuser"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"domainname"},"value":{"kind":"Variable","name":{"kind":"Name","value":"domainname"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_job_titleid"}},{"kind":"Field","name":{"kind":"Name","value":"businessunitid"}}]}}]}}]} as unknown as DocumentNode; export const GetAddproductTypesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetAddproductTypes"},"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_addproduct_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"CoreAddProductTypesFields"}},{"kind":"Field","name":{"kind":"Name","value":"evo_product_type"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"CoreAddProductTypesFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"evo_addproduct_type"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_graph_price"}},{"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_addproduct_typeid"}}]}}]} as unknown as DocumentNode; -export const GetAddProductTypeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetAddProductType"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"addproductTypeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_type"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_addproduct_typeid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"addproductTypeId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_description"}},{"kind":"Field","name":{"kind":"Name","value":"evo_helpcard_type"}}]}}]}}]} as unknown as DocumentNode; +export const GetAddProductTypeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetAddProductType"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"addproductTypeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_type"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_addproduct_typeid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"addproductTypeId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_description"}},{"kind":"Field","name":{"kind":"Name","value":"evo_helpcard_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_planpayments"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","name":{"kind":"Name","value":"evo_cost_price_telematics_withoutnds"}},{"kind":"Field","name":{"kind":"Name","value":"evo_cost_equipment_withoutnds"}},{"kind":"Field","name":{"kind":"Name","value":"evo_cost_telematics_withoutnds"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_graph_price_withoutnds"}},{"kind":"Field","name":{"kind":"Name","value":"evo_cost_service_provider_withoutnds"}},{"kind":"Field","name":{"kind":"Name","value":"evo_retro_bonus_withoutnds"}},{"kind":"Field","name":{"kind":"Name","value":"evo_evokasko_calc_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_loss_kv"}},{"kind":"Field","name":{"kind":"Name","value":"evo_price_service_provider_withoutnds"}},{"kind":"Field","name":{"kind":"Name","value":"evo_graph_price"}}]}}]}}]} as unknown as DocumentNode; export const GetRegistrationTypesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRegistrationTypes"},"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_addproduct_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_product_type"},"value":{"kind":"IntValue","value":"100000001"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"CoreAddProductTypesFields"}},{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_whom_register"}},{"kind":"Field","name":{"kind":"Name","value":"evo_gibdd_region"}},{"kind":"Field","name":{"kind":"Name","value":"evo_pts_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_towtruck"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"CoreAddProductTypesFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"evo_addproduct_type"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_graph_price"}},{"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_addproduct_typeid"}}]}}]} as unknown as DocumentNode; export const GetTechnicalCardsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetTechnicalCards"},"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_addproduct_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_product_type"},"value":{"kind":"IntValue","value":"100000000"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"CoreAddProductTypesFields"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_helpcard_type"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"CoreAddProductTypesFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"evo_addproduct_type"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_graph_price"}},{"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_addproduct_typeid"}}]}}]} as unknown as DocumentNode; export const GetFuelCardsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetFuelCards"},"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_addproduct_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_product_type"},"value":{"kind":"IntValue","value":"100000005"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"CoreAddProductTypesFields"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"CoreAddProductTypesFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"evo_addproduct_type"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_graph_price"}},{"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_addproduct_typeid"}}]}}]} as unknown as DocumentNode; diff --git a/apps/web/process/bonuses/lib/helper.ts b/apps/web/process/bonuses/lib/helper.ts index 0077d02..0bef5cf 100644 --- a/apps/web/process/bonuses/lib/helper.ts +++ b/apps/web/process/bonuses/lib/helper.ts @@ -43,19 +43,9 @@ export default function helper({ apolloClient, queryClient }: ValidationContext) }, }); - const { - data: { evo_sot_coefficient_type }, - } = await apolloClient.query({ - query: CRMTypes.GetSotCoefficientTypeDocument, - variables: { - evo_id: 'BONUS_LEASING', - }, - }); - return evo_coefficients?.find( (evo_coefficient) => - evo_coefficient?.evo_sot_coefficient_typeid === - evo_sot_coefficient_type?.evo_sot_coefficient_typeid && + evo_coefficient?.evo_sot_coefficient_typeidData?.evo_id === 'BONUS_LEASING' && evo_coefficient?.evo_baseproducts?.some((x) => x?.evo_baseproductid === productId) ); }, diff --git a/apps/web/process/create-kp/reactions.ts b/apps/web/process/create-kp/reactions.ts index c3370ea..174a8b1 100644 --- a/apps/web/process/create-kp/reactions.ts +++ b/apps/web/process/create-kp/reactions.ts @@ -7,12 +7,10 @@ export function common({ store }: ProcessContext) { reaction( () => $calculation.element('radioBalanceHolder').getValue(), (balanceHolder) => { - if (balanceHolder) { - if (balanceHolder === 100_000_001) { - $calculation.element('cbxLastPaymentRedemption').setValue(true).block(); - } else { - $calculation.element('cbxLastPaymentRedemption').unblock(); - } + if (balanceHolder === 100_000_001) { + $calculation.element('cbxLastPaymentRedemption').setValue(true).block(); + } else { + $calculation.element('cbxLastPaymentRedemption').unblock(); } } ); diff --git a/apps/web/process/price/reactions/computed.ts b/apps/web/process/price/reactions/computed.ts index 8ec3b9b..1e0a476 100644 --- a/apps/web/process/price/reactions/computed.ts +++ b/apps/web/process/price/reactions/computed.ts @@ -1,23 +1,24 @@ import * as CRMTypes from '@/graphql/crm.types'; import type { ProcessContext } from '@/process/types'; -import dayjs from 'dayjs'; -import utc from 'dayjs/plugin/utc'; -import { autorun } from 'mobx'; - -dayjs.extend(utc); +import { createCurrencyUtility } from '@/utils/currency'; +import { reaction } from 'mobx'; export default function reactions({ store, apolloClient }: ProcessContext) { const { $calculation } = store; - autorun( - async () => { - const supplierCurrencyId = $calculation.element('selectSupplierCurrency').getValue(); - const leaseObjectPrice = $calculation.element('tbxLeaseObjectPrice').getValue(); - const supplierDiscountRub = $calculation.element('tbxSupplierDiscountRub').getValue(); + const { RUB } = createCurrencyUtility({ apolloClient }); + reaction( + () => + $calculation.$values.getValues([ + 'supplierCurrency', + 'leaseObjectPrice', + 'supplierDiscountRub', + ]), + async ({ supplierCurrency: supplierCurrencyId, supplierDiscountRub, leaseObjectPrice }) => { if (!supplierCurrencyId) { - $calculation.$values.setValue('plPriceRub', leaseObjectPrice); - $calculation.$values.setValue('discountRub', supplierDiscountRub); + $calculation.$values.resetValue('plPriceRub'); + $calculation.$values.resetValue('discountRub'); return; } @@ -38,27 +39,20 @@ export default function reactions({ store, apolloClient }: ProcessContext) { return; } - const { - data: { evo_currencychanges }, - } = await apolloClient.query({ - query: CRMTypes.GetCurrencyChangesDocument, - variables: { - currentDate: dayjs().utc(false).format('YYYY-MM-DD'), - }, - }); - - const evo_currencychange = evo_currencychanges?.find( - (x) => x?.evo_ref_transactioncurrency === supplierCurrencyId - ); - $calculation.$values.setValue( 'plPriceRub', - leaseObjectPrice * (evo_currencychange?.evo_currencychange || 0) + await RUB({ + currencyid: supplierCurrencyId, + value: leaseObjectPrice, + }) ); $calculation.$values.setValue( 'discountRub', - supplierDiscountRub * (evo_currencychange?.evo_currencychange || 0) + await RUB({ + currencyid: supplierCurrencyId, + value: supplierDiscountRub, + }) ); }, { diff --git a/apps/web/trpc/middleware.ts b/apps/web/trpc/middleware.ts index 7bdb542..d7230d2 100644 --- a/apps/web/trpc/middleware.ts +++ b/apps/web/trpc/middleware.ts @@ -6,7 +6,10 @@ import { TRPCError } from '@trpc/server'; const { COOKIE_TOKEN_NAME } = getServerConfig(); export const user = t.middleware(async ({ ctx, next }) => { - if (ctx.token === undefined || ctx.token === null || typeof ctx.token !== 'string') { + if ( + process.env.NODE_ENV !== 'development' && + (ctx.token === undefined || ctx.token === null || typeof ctx.token !== 'string') + ) { throw new TRPCError({ code: 'UNAUTHORIZED', }); diff --git a/apps/web/trpc/routers/calculate/index.ts b/apps/web/trpc/routers/calculate/index.ts index 940004a..981155b 100644 --- a/apps/web/trpc/routers/calculate/index.ts +++ b/apps/web/trpc/routers/calculate/index.ts @@ -1,5 +1,6 @@ import { user } from '../../middleware'; import { t } from '../../server'; +import { prepareData } from './prepare-data'; import { CalculateInputSchema, CalculateOutputSchema } from './types'; import { validate } from './validation'; import initializeApollo from '@/apollo/client'; @@ -10,7 +11,7 @@ const calculateRouter = t.router({ .use(user) .input(CalculateInputSchema) .output(CalculateOutputSchema) - .query(async ({ input }) => { + .query(async ({ input, ctx }) => { const apolloClient = initializeApollo(); const queryClient = new QueryClient(); @@ -29,6 +30,15 @@ const calculateRouter = t.router({ }; } + const preparedData = await prepareData({ + context: { + apolloClient, + queryClient, + }, + input, + user: ctx.user, + }); + return { error: undefined, success, diff --git a/apps/web/trpc/routers/calculate/prepare-data.ts b/apps/web/trpc/routers/calculate/prepare-data.ts new file mode 100644 index 0000000..8d14dad --- /dev/null +++ b/apps/web/trpc/routers/calculate/prepare-data.ts @@ -0,0 +1,36 @@ +import { getPreparedValues } from './prepared-values'; +import type { CalculateInput, Context, PreparedData } from './types'; +import type { User } from '@/api/user/types'; +import dayjs from 'dayjs'; +import utc from 'dayjs/plugin/utc'; + +dayjs.extend(utc); + +type Input = { + context: Context; + input: CalculateInput; + user: User; +}; + +export async function prepareData({ context, input, user }: Input): Promise { + const { payments } = input; + + const preparedPayments: PreparedData['preparedPayments'] = { + rows: payments.values.map((payment, index) => ({ + gpsBasePayment: 0, + gpsCostPayment: 0, + numberPayment: index + 1, + percentPayment: index === 0 ? 0 : payment, + sumPayment: 0, + tlmBasePayment: 0, + tlmCostPayment: 0, + })), + }; + + const preparedValues = await getPreparedValues({ context, input, preparedPayments, user }); + + return { + preparedPayments, + preparedValues, + }; +} diff --git a/apps/web/trpc/routers/calculate/prepared-values.ts b/apps/web/trpc/routers/calculate/prepared-values.ts new file mode 100644 index 0000000..2cc1975 --- /dev/null +++ b/apps/web/trpc/routers/calculate/prepared-values.ts @@ -0,0 +1,1174 @@ +/* eslint-disable sonarjs/cognitive-complexity */ +import type { CalculateInput, Context, PreparedPayments, PreparedValues } from './types'; +import type { User } from '@/api/user/types'; +import { ESN, NSIB_MAX, VAT } from '@/constants/values'; +import * as CRMTypes from '@/graphql/crm.types'; +import { createCurrencyUtility } from '@/utils/currency'; +import dayjs from 'dayjs'; +import utc from 'dayjs/plugin/utc'; +import { max, sum } from 'radash'; + +dayjs.extend(utc); + +type Input = { + context: Context; + input: CalculateInput; + preparedPayments: PreparedPayments; + user: User; +}; + +type Getters = { + [Key in keyof PreparedValues]: () => Promise; +}; + +export async function getPreparedValues({ + input, + context, + user, + preparedPayments, +}: Input): Promise { + const { apolloClient } = context; + const { values, insurance } = input; + + const { RUB } = createCurrencyUtility({ apolloClient }); + + const currentUTCDate = dayjs().utc(false); + + const transactioncurrency = values.supplierCurrency + ? ( + await apolloClient.query({ + query: CRMTypes.GetTransactionCurrencyDocument, + variables: { currencyid: values.supplierCurrency }, + }) + ).data.transactioncurrency + : null; + + const { + data: { systemuser }, + } = await apolloClient.query({ + query: CRMTypes.GetSystemUserDocument, + variables: { + domainname: user.domainName, + }, + }); + + async function getDeprecation() { + if (values.leaseObjectType) { + const { + data: { evo_leasingobject_type }, + } = await apolloClient.query({ + query: CRMTypes.GetLeaseObjectTypeDocument, + variables: { leaseObjectTypeId: values.leaseObjectType }, + }); + + if ( + (evo_leasingobject_type?.evo_id === '1' && + (values.engineType === 100_000_000 || values.engineType === 100_000_004) && + values.engineVolume <= 3.5) || + (evo_leasingobject_type?.evo_id === '2' && + (values.engineType === 100_000_000 || + values.engineType === 100_000_004 || + values.engineType === 100_000_001) && + values.maxMass <= 3500) || + (evo_leasingobject_type?.evo_id !== '1' && evo_leasingobject_type?.evo_id !== '2') + ) { + return { + deprecationRate: evo_leasingobject_type?.evo_depreciation_rate1, + nmperDeprecation: evo_leasingobject_type?.evo_expluatation_period1, + }; + } else + return { + deprecationRate: evo_leasingobject_type?.evo_depreciation_rate2, + nmperDeprecation: evo_leasingobject_type.evo_expluatation_period2, + }; + } + + return null; + } + + const evo_coefficients = systemuser?.evo_job_titleid + ? ( + await apolloClient.query({ + query: CRMTypes.GetCoefficientsDocument, + variables: { + currentDate: currentUTCDate.format('YYYY-MM-DD'), + jobTitleId: systemuser?.evo_job_titleid, + }, + }) + ).data.evo_coefficients + : null; + + const getters: Getters = { + async acceptSum() { + const plPrice = await this.plPrice(); + const discount = await this.discount(); + + return plPrice - discount; + }, + + async agentsSum() { + if (values.indAgentRewardCondition) { + const { + data: { evo_reward_condition }, + } = await apolloClient.query({ + query: CRMTypes.GetRewardConditionDocument, + variables: { conditionId: values.indAgentRewardCondition }, + }); + + if (evo_reward_condition?.evo_calc_reward_rules === 100_000_001) { + return values.indAgentRewardSumm * ESN; + } else if ( + evo_reward_condition?.evo_agency_agreementidData?.evo_leasingobject_price === 100_000_001 + ) { + const plPriceWithVAT = await this.plPriceWithVAT(); + const discount = await this.discount(); + + return (values.indAgentRewardSumm / 100) * (plPriceWithVAT - discount * (1 + VAT)) * ESN; + } + } + + const acceptSum = await this.acceptSum(); + + return (values.indAgentRewardSumm / 100) * acceptSum * ESN; + }, + + async balanceHolder() { + return values.balanceHolder; + }, + + async baseRatCost() { + if (values.technicalCard) { + const { + data: { evo_addproduct_type }, + } = await apolloClient.query({ + query: CRMTypes.GetAddProductTypeDocument, + variables: { addproductTypeId: values.technicalCard }, + }); + + return evo_addproduct_type?.evo_cost_service_provider_withoutnds ?? 0; + } + + return 0; + }, + + async baseRegistration() { + if (values.registration) { + const { + data: { evo_addproduct_type }, + } = await apolloClient.query({ + query: CRMTypes.GetAddProductTypeDocument, + variables: { addproductTypeId: values.registration }, + }); + + return evo_addproduct_type?.evo_cost_service_provider_withoutnds ?? 0; + } + + return 0; + }, + + async bonus() { + return values.saleBonus / 100; + }, + + async bonusCoefficient() { + return values.bonusCoefficient; + }, + + async bonusFinGAP() { + const evo_coefficient = evo_coefficients?.find( + (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'BONUS_FINGAP_PR' + ); + + return (evo_coefficient?.evo_sot_coefficient || 0) + insurance.values.fingap.insCost; + }, + + async bonusFix() { + const evo_coefficient = evo_coefficients?.find( + (x) => + x?.evo_sot_coefficient_typeidData?.evo_id === 'BONUS_FIX' && + Boolean(values.product) && + x.evo_baseproducts?.some((evo_baseproduct) => evo_baseproduct?.evo_id === values.product) + ); + + return evo_coefficient?.evo_sot_coefficient || 0; + }, + + async bonusNsPr() { + return 0; + }, + + async bonusNsibPr() { + return 0; + }, + + async bonusRatPr() { + return 0; + }, + + async brandId() { + return values.brand; + }, + + async brokerOfDeliverySum() { + if (values.dealerBrokerRewardCondition) { + const { + data: { evo_reward_condition }, + } = await apolloClient.query({ + query: CRMTypes.GetRewardConditionDocument, + variables: { conditionId: values.dealerBrokerRewardCondition }, + }); + + if (evo_reward_condition?.evo_calc_reward_rules === 100_000_001) { + return values.dealerBrokerRewardSumm / (1 + VAT); + } else if ( + evo_reward_condition?.evo_agency_agreementidData?.evo_leasingobject_price === 100_000_001 + ) { + const plPriceWithVAT = await this.plPriceWithVAT(); + const discount = await this.discount(); + + return (values.dealerBrokerRewardSumm / 100) * (plPriceWithVAT - discount * (1 + VAT)); + } else { + const acceptSum = await this.acceptSum(); + + return (values.dealerBrokerRewardSumm / 100) * acceptSum; + } + } + + return 0; + }, + + async brokerSum() { + if (values.calcBrokerRewardCondition) { + const { + data: { evo_reward_condition }, + } = await apolloClient.query({ + query: CRMTypes.GetRewardConditionDocument, + variables: { conditionId: values.calcBrokerRewardCondition }, + }); + + if (evo_reward_condition?.evo_calc_reward_rules === 100_000_001) { + return values.calcBrokerRewardSum / (1 + VAT); + } else if ( + evo_reward_condition?.evo_agency_agreementidData?.evo_leasingobject_price === 100_000_001 + ) { + const discount = await this.discount(); + const plPriceWithVAT = await this.plPriceWithVAT(); + + return (values.calcBrokerRewardSum / 100) * (plPriceWithVAT - discount * (1 + VAT)); + } else { + const acceptSum = await this.acceptSum(); + + return (values.calcBrokerRewardSum / 100) * acceptSum; + } + } + + return 0; + }, + + async calcDate() { + return currentUTCDate.toDate(); + }, + + async calcType() { + return values.calcType; + }, + + async carCapacity() { + return values.leaseObjectMotorPower; + }, + + async carCarrying() { + return values.maxMass; + }, + + async carSeats() { + return 0; + }, + + async cityc() { + return values.townRegistration || values.regionRegistration || ''; + }, + + async comissionRub() { + return values.comissionRub / (1 + VAT); + }, + + async configurationId() { + return values.configuration; + }, + + async deliverySum() { + if (values.calcDoubleAgentRewardCondition) { + const { + data: { evo_reward_condition }, + } = await apolloClient.query({ + query: CRMTypes.GetRewardConditionDocument, + variables: { conditionId: values.calcDoubleAgentRewardCondition }, + }); + + if (evo_reward_condition?.evo_calc_reward_rules === 100_000_001) { + return values.dealerRewardSumm / (1 + VAT); + } else if ( + evo_reward_condition?.evo_agency_agreementidData?.evo_leasingobject_price === 100_000_001 + ) { + const discount = await this.discount(); + const plPriceWithVAT = await this.plPriceWithVAT(); + + return (values.dealerRewardSumm / 100) * (plPriceWithVAT - discount * (1 + VAT)); + } else { + const acceptSum = await this.acceptSum(); + + return (values.dealerRewardSumm / 100) * acceptSum; + } + } + + return 0; + }, + + async deliveryTime() { + return values.deliveryTime; + }, + + async deprecationTime() { + const deprecation = await getDeprecation(); + + if (deprecation?.nmperDeprecation && [85, 61].includes(deprecation?.nmperDeprecation)) { + return (deprecation.deprecationRate || 0) * 3; + } + + return deprecation?.deprecationRate || 0; + }, + + async directorBonus() { + const evo_coefficient = evo_coefficients?.find( + (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'DIRECTOR_BONUS' + ); + + return (evo_coefficient?.evo_sot_coefficient || 0) + insurance.values.fingap.insCost; + }, + + async directorBonusFinGAP() { + const evo_coefficient = evo_coefficients?.find( + (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'DIRECTOR_BONUS_FINGAP' + ); + + return (evo_coefficient?.evo_sot_coefficient || 0) + insurance.values.fingap.insCost; + }, + + async directorBonusFix() { + const evo_coefficient = evo_coefficients?.find( + (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'DIRECTOR_BONUS_FIX' + ); + + return (evo_coefficient?.evo_sot_coefficient || 0) + insurance.values.fingap.insCost; + }, + + async directorBonusNsib() { + const evo_coefficient = evo_coefficients?.find( + (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'DIRECTOR_BONUS_NSIB' + ); + + return (evo_coefficient?.evo_sot_coefficient || 0) + insurance.values.fingap.insCost; + }, + + async directorExtraBonus() { + const evo_coefficient = evo_coefficients?.find( + (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'DIRECTOR_EXTRA_BONUS' + ); + + return (evo_coefficient?.evo_sot_coefficient || 0) + insurance.values.fingap.insCost; + }, + + async discount() { + if (values.supplierCurrency && transactioncurrency?.isocurrencycode !== 'RUB') { + return ( + ((await RUB({ + currencyid: values.supplierCurrency, + value: values.supplierDiscountRub, + })) + + values.importProgramSum) / + (1 + VAT) + ); + } + + return (values.supplierDiscountRub + values.importProgramSum) / (1 + VAT); + }, + + async districtRate() { + const evo_coefficient = evo_coefficients?.find( + (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'DISTRICT_RATE' + ); + + return (evo_coefficient?.evo_sot_coefficient || 0) + insurance.values.fingap.insCost; + }, + + async doubleAgentsSum() { + if (values.calcDoubleAgentRewardCondition) { + const { + data: { evo_reward_condition }, + } = await apolloClient.query({ + query: CRMTypes.GetRewardConditionDocument, + variables: { conditionId: values.calcDoubleAgentRewardCondition }, + }); + + if (evo_reward_condition?.evo_calc_reward_rules === 100_000_001) { + return values.calcDoubleAgentRewardSumm * ESN; + } else if ( + evo_reward_condition?.evo_agency_agreementidData?.evo_leasingobject_price === 100_000_001 + ) { + const plPriceWithVAT = await this.plPriceWithVAT(); + const discount = await this.discount(); + + return ( + (values.calcDoubleAgentRewardSumm / 100) * (plPriceWithVAT - discount * (1 + VAT)) * ESN + ); + } else { + const acceptSum = await this.acceptSum(); + + return (values.calcDoubleAgentRewardSumm / 100) * acceptSum * ESN; + } + } + + return 0; + }, + + async extraBonus() { + const evo_coefficient = evo_coefficients?.find( + (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'EXTRA_BONUS' + ); + + return (evo_coefficient?.evo_sot_coefficient || 0) + insurance.values.fingap.insCost; + }, + + async financialDeptOfDeliverySum() { + if (values.finDepartmentRewardCondtion) { + const { + data: { evo_reward_condition }, + } = await apolloClient.query({ + query: CRMTypes.GetRewardConditionDocument, + variables: { conditionId: values.finDepartmentRewardCondtion }, + }); + + if (evo_reward_condition?.evo_calc_reward_rules === 100_000_001) { + return values.dealerRewardSumm / (1 + VAT); + } else if ( + evo_reward_condition?.evo_agency_agreementidData?.evo_leasingobject_price === 100_000_001 + ) { + const discount = await this.discount(); + const plPriceWithVAT = await this.plPriceWithVAT(); + + return (values.dealerRewardSumm / 100) * (plPriceWithVAT - discount * (1 + VAT)); + } else { + const acceptSum = await this.acceptSum(); + + return (values.dealerRewardSumm / 100) * acceptSum; + } + } + + return 0; + }, + + async firstPayment() { + const plPrice = await this.plPrice(); + const importProgramSum = await this.importProgramSum(); + const firstPaymentPercWthtVAT = + values.firstPaymentRub / (1 + VAT) / (plPrice - importProgramSum); + + if (firstPaymentPercWthtVAT * 100 < 30) { + if (values.graphType === 100_000_003 && values.highSeasonStart !== 100_000_000) { + const evo_coefficient = evo_coefficients?.find( + (x) => + x?.evo_corfficient_type === 100_000_000 && + x.evo_min_period && + x.evo_min_period <= values.leasingPeriod && + x.evo_max_period && + x.evo_max_period >= values.leasingPeriod && + x.evo_season_type === values.seasonType && + x.evo_graph_type === values.graphType + ); + + return ( + (firstPaymentPercWthtVAT * 100 + (evo_coefficient?.evo_correction_coefficient || 0)) / + 100 + ); + } + + if (values.graphType === 100_000_004) { + const evo_coefficient = evo_coefficients?.find( + (x) => + x?.evo_corfficient_type === 100_000_000 && + x.evo_min_period && + x.evo_min_period <= values.leasingPeriod && + x.evo_max_period && + x.evo_max_period >= values.leasingPeriod && + x.evo_graph_type === values.graphType + ); + + return ( + (firstPaymentPercWthtVAT * 100 + (evo_coefficient?.evo_correction_coefficient || 0)) / + 100 + ); + } + } + + return firstPaymentPercWthtVAT; + }, + + async firstPaymentAbs() { + return 0; + }, + + async firstPaymentNdsAbs() { + return 0; + }, + async firstPaymentSum() { + const firstPayment = await this.firstPayment(); + const plPrice = await this.plPrice(); + const importProgramSum = await this.importProgramSum(); + + return firstPayment * (plPrice - importProgramSum); + }, + + async firstPaymentWithNdsAbs() { + return 0; + }, + + async fuelCardSum() { + if (values.fuelCard) { + const { + data: { evo_addproduct_type }, + } = await apolloClient.query({ + query: CRMTypes.GetAddProductTypeDocument, + variables: { addproductTypeId: values.fuelCard }, + }); + + return evo_addproduct_type?.evo_graph_price_withoutnds || 0; + } + + return 0; + }, + + async gpsCostPaymentSum() { + return sum(preparedPayments.rows, (p) => p.gpsCostPayment); + }, + + async iRR_MSFO_Plan() { + if (values.tarif) { + const { + data: { evo_tarif }, + } = await apolloClient.query({ + query: CRMTypes.GetTarifDocument, + variables: { tarifId: values.tarif }, + }); + + return (evo_tarif?.evo_irr_plan || 0) / 100; + } + + return 0; + }, + + async importProgramSum() { + return values.importProgramSum / (1 + VAT); + }, + + async importerSum() { + const acceptSum = await this.acceptSum(); + + return values.importerRewardRub || (values.importerRewardPerc / 100) * acceptSum; + }, + + async insuranceBonus() { + return 0; + }, + + async insuranceBonusLoss() { + if (values.leasingWithoutKasko) { + const { + data: { evo_addproduct_type }, + } = await apolloClient.query({ + query: CRMTypes.GetAddProductTypeDocument, + variables: { addproductTypeId: values.leasingWithoutKasko }, + }); + + if (evo_addproduct_type?.evo_evokasko_calc_type === 100_000_001) { + return ( + ((evo_addproduct_type?.evo_loss_kv || 0) * + (values.plPriceRub - + values.discountRub - + values.importProgramSum + + values.addEquipmentPrice - + values.firstPaymentRub)) / + 100 + ); + } else { + return ( + ((evo_addproduct_type?.evo_loss_kv || 0) * + (values.plPriceRub - + values.discountRub - + values.importProgramSum + + values.addEquipmentPrice)) / + 100 + ); + } + } + + return 0; + }, + + async insuranceContract() { + const insuranceKaskoNmper = await this.insuranceKaskoNmper(); + const insuranceOsago = await this.insuranceOsago(); + + return insuranceKaskoNmper + insuranceOsago; + }, + + async insuranceEvoKasko() { + if (values.leasingWithoutKasko) { + const { + data: { evo_addproduct_type }, + } = await apolloClient.query({ + query: CRMTypes.GetAddProductTypeDocument, + variables: { addproductTypeId: values.leasingWithoutKasko }, + }); + + if (evo_addproduct_type?.evo_evokasko_calc_type === 100_000_001) { + return ( + (evo_addproduct_type?.evo_cost_service_provider_withoutnds || 0) * + (values.plPriceRub - + values.discountRub - + values.importProgramSum + + values.addEquipmentPrice - + values.firstPaymentRub) + + (evo_addproduct_type?.evo_price_service_provider_withoutnds || 0) + ); + } else { + return ( + (evo_addproduct_type?.evo_cost_service_provider_withoutnds || 0) * + (values.plPriceRub - + values.discountRub - + values.importProgramSum + + values.addEquipmentPrice) + + (evo_addproduct_type?.evo_price_service_provider_withoutnds || 0) + ); + } + } + + return 0; + }, + + async insuranceFinGAP() { + const { insured, insCost } = insurance.values.fingap; + + return insured === 100_000_001 ? insCost : 0; + }, + + async insuranceKasko() { + const { insured, insCost } = insurance.values.kasko; + + return insured === 100_000_001 ? insCost : 0; + }, + + async insuranceKaskoNmper() { + const nmperInsurance = await this.nmperInsurance(); + const insuranceKasko = await this.insuranceKasko(); + + return nmperInsurance >= 16 ? (insuranceKasko * nmperInsurance) / 12 : insuranceKasko; + }, + + async insuranceOsago() { + const { insured, insCost } = insurance.values.osago; + + return insured === 100_000_001 ? insCost : 0; + }, + + async irrExpected() { + return values.IRR_Perc / 100; + }, + + async lastPayment() { + return values.lastPaymentPerc / 100; + }, + + async lastPaymentFix() { + return values.lastPaymentRule === 100_000_002; + }, + + async lastPaymentSum() { + return values.lastPaymentRub / (1 + VAT); + }, + + async leasing0K() { + if (values.product) { + const nmper = await this.nmper(); + const { + data: { evo_baseproduct }, + } = await apolloClient.query({ + query: CRMTypes.GetProductDocument, + variables: { productId: values.product }, + }); + + return evo_baseproduct?.evo_id === 'LEASING0' + ? (nmper - 2) * (0.0234 / (1 - 1 / 1.0234) ** (nmper - 2)) + : 1; + } + + return 1; + }, + + async loanRate() { + return values.creditRate; + }, + + async loanRatePeriod() { + if (values.rate) { + const { + data: { evo_rate }, + } = await apolloClient.query({ + query: CRMTypes.GetRateDocument, + variables: { rateId: values.rate }, + }); + + return evo_rate?.evo_credit_period || 0; + } + + return 0; + }, + + async marketRate() { + const evo_coefficient = evo_coefficients?.find( + (x) => + x?.evo_sot_coefficient_typeidData?.evo_id === 'MARKET_RATE' && + systemuser?.businessunitid && + x.evo_businessunits?.find( + (evo_businessunit) => + evo_businessunit?.evo_sale_businessunitid === systemuser?.businessunitid + ) + ); + + return evo_coefficient?.evo_sot_coefficient || 0; + }, + + async modelId() { + return values.model; + }, + + async motorVolume() { + return values.engineVolume; + }, + + async nmper() { + return values.leasingPeriod; + }, + + async nmperDeprecation() { + return (await getDeprecation())?.nmperDeprecation || 0; + }, + + async nmperFinGAP() { + const { insTerm } = insurance.values.fingap; + + return insTerm === 100_000_001 ? values.leasingPeriod : 12; + }, + + async nmperInsurance() { + const { insured } = insurance.values.kasko; + + return insured === 100_000_001 ? values.leasingPeriod : 12; + }, + + async npvniDelta() { + const evo_coefficient = evo_coefficients?.find( + (x) => + x?.evo_corfficient_type === 100_000_001 && + x.evo_min_period && + x.evo_min_period <= values.leasingPeriod && + x.evo_max_period && + x.evo_max_period >= values.leasingPeriod + ); + + return evo_coefficient?.evo_risk_delta || 0; + }, + + async npvniExpected() { + return 0; + }, + + async nsBonus() { + const evo_coefficient = evo_coefficients?.find( + (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'BONUS_NS_PR' + ); + + return evo_coefficient?.evo_sot_coefficient || 0; + }, + + async nsibBase() { + const discount = await this.discount(); + const plPrice = await this.plPrice(); + const importProgramSum = await this.importProgramSum(); + const insuranceContract = await this.insuranceContract(); + const rats = await this.rats(); + const registration = await this.registration(); + const trackerCost = await this.trackerCost(); + const tLMCost = await this.tLMCost(); + const transportTaxGr = await this.transportTaxGr(); + const tlmCostPaymentSum = await this.tlmCostPaymentSum(); + const gpsCostPaymentSum = await this.gpsCostPaymentSum(); + const leasing0K = await this.leasing0K(); + const firstPaymentSum = await this.firstPaymentSum(); + + const value = + (plPrice - + importProgramSum + + (insuranceContract + + rats + + registration + + trackerCost + + tLMCost + + transportTaxGr + + tlmCostPaymentSum + + gpsCostPaymentSum) * + leasing0K - + firstPaymentSum - + (values.product === 'LEASING0' ? 0 : discount)) * + (1 + VAT); + + return max([NSIB_MAX, value], (v) => v) ?? NSIB_MAX; + }, + + async nsibBonus() { + const evo_coefficient = evo_coefficients?.find( + (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'BONUS_NSIB_PR' + ); + const nsibBrutto = await this.nsibBrutto(); + + return (evo_coefficient?.evo_sot_coefficient || 0) * nsibBrutto; + }, + + async nsibBrutto() { + if (values.insNSIB) { + const { + data: { evo_addproduct_type }, + } = await apolloClient.query({ + query: CRMTypes.GetAddProductTypeDocument, + variables: { addproductTypeId: values.insNSIB }, + }); + + const nsibBase = await this.nsibBase(); + const nmper = await this.nmper(); + + return ((((evo_addproduct_type?.evo_graph_price || 0) / 100) * nsibBase) / 12) * nmper; + } + + return 0; + }, + + async nsibBruttoPr() { + return 0; + }, + + async nsibNetto() { + if (values.insNSIB) { + const { + data: { evo_addproduct_type }, + } = await apolloClient.query({ + query: CRMTypes.GetAddProductTypeDocument, + variables: { addproductTypeId: values.insNSIB }, + }); + + const nsibBase = await this.nsibBase(); + const nmper = await this.nmper(); + + return ( + ((((evo_addproduct_type?.evo_cost_service_provider_withoutnds || 0) / 100) * nsibBase) / + 12) * + nmper + ); + } + + return 0; + }, + + async nsibNettoPr() { + return 0; + }, + + async paymentDateNew() { + return null; + }, + + async plEngineType() { + return values.engineType; + }, + + async plPrice() { + if (values.supplierCurrency && transactioncurrency?.isocurrencycode !== 'RUB') { + return ( + (await RUB({ + currencyid: values.supplierCurrency, + value: values.leaseObjectPriceWthtVAT, + })) + + values.addEquipmentPrice / (1 + VAT) + ); + } + + return values.leaseObjectPriceWthtVAT + values.addEquipmentPrice / (1 + VAT); + }, + + async plPriceVAT() { + if (values.supplierCurrency && transactioncurrency?.isocurrencycode !== 'RUB') { + return ( + (await RUB({ + currencyid: values.supplierCurrency, + value: values.VATInLeaseObjectPrice, + })) + + (values.addEquipmentPrice - values.addEquipmentPrice / (1 + VAT)) + ); + } + + return ( + values.VATInLeaseObjectPrice + + (values.addEquipmentPrice - values.addEquipmentPrice / (1 + VAT)) + ); + }, + + async plPriceWithVAT() { + if (values.supplierCurrency && transactioncurrency?.isocurrencycode !== 'RUB') { + return ( + (await RUB({ + currencyid: values.supplierCurrency, + value: values.leaseObjectPrice, + })) + values.addEquipmentPrice + ); + } + + return values.leaseObjectPrice + values.addEquipmentPrice; + }, + + async plTypeId() { + return values.leaseObjectType; + }, + + async plYear() { + return values.leaseObjectYear; + }, + + async profitExpected() { + if (values.tarif) { + const { + data: { evo_tarif }, + } = await apolloClient.query({ + query: CRMTypes.GetTarifDocument, + variables: { tarifId: values.tarif }, + }); + + return evo_tarif?.evo_margin_min || 0; + } + + return 0; + }, + + async ratBonus() { + const evo_coefficient = evo_coefficients?.find( + (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'BONUS_RAT_PR' + ); + const rats = await this.rats(); + + return (evo_coefficient?.evo_sot_coefficient || 0) * rats; + }, + + async rats() { + if (values.technicalCard) { + const { + data: { evo_addproduct_type }, + } = await apolloClient.query({ + query: CRMTypes.GetAddProductTypeDocument, + variables: { addproductTypeId: values.technicalCard }, + }); + + return evo_addproduct_type?.evo_graph_price_withoutnds ?? 0; + } + + return 0; + }, + + async regionalDirectorBonus() { + const evo_coefficient = evo_coefficients?.find( + (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'REGIONAL_DIRECTOR_BONUS' + ); + + return evo_coefficient?.evo_sot_coefficient || 0; + }, + + async regionalDirectorBonusFinGAP() { + const evo_coefficient = evo_coefficients?.find( + (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'REGIONAL_DIRECTOR_BONUS_FINGAP' + ); + const { insCost } = insurance.values.fingap; + + return (evo_coefficient?.evo_sot_coefficient || 0) * insCost; + }, + + async regionalDirectorBonusFix() { + const evo_coefficient = evo_coefficients?.find( + (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'REGIONAL_DIRECTOR_BONUS_FIX' + ); + + return evo_coefficient?.evo_sot_coefficient || 0; + }, + + async regionalDirectorBonusNsib() { + const evo_coefficient = evo_coefficients?.find( + (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'REGIONAL_DIRECTOR_BONUS_NSIB' + ); + const nsibBrutto = await this.nsibBrutto(); + + return (evo_coefficient?.evo_sot_coefficient || 0) * nsibBrutto; + }, + + async regionalDirectorExtraBonus() { + const evo_coefficient = evo_coefficients?.find( + (x) => + x?.evo_sot_coefficient_typeidData?.evo_id === 'REGIONAL_DIRECTOR_EXTRA_BONUS' && + Boolean(values.product) && + x.evo_baseproducts?.some((evo_baseproduct) => evo_baseproduct?.evo_id === values.product) + ); + + return evo_coefficient?.evo_sot_coefficient || 0; + }, + + async registration() { + if (values.registration) { + const { + data: { evo_addproduct_type }, + } = await apolloClient.query({ + query: CRMTypes.GetAddProductTypeDocument, + variables: { addproductTypeId: values.registration }, + }); + + return evo_addproduct_type?.evo_graph_price_withoutnds ?? 0; + } + + return 0; + }, + + async repayment() { + return 0.25; + }, + + async retroBonus() { + if (values.technicalCard) { + const { + data: { evo_addproduct_type }, + } = await apolloClient.query({ + query: CRMTypes.GetAddProductTypeDocument, + variables: { addproductTypeId: values.technicalCard }, + }); + + return evo_addproduct_type?.evo_retro_bonus_withoutnds ?? 0; + } + + return 0; + }, + + async salaryRate() { + const evo_coefficient = evo_coefficients?.find( + (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'SALARY_RATE' + ); + + return (evo_coefficient?.evo_sot_coefficient || 0) + insurance.values.fingap.insCost; + }, + + async scheduleOfPayments() { + return values.graphType; + }, + + async subsidyPaymentNumber() { + if (values.subsidy) { + const { + data: { evo_subsidy }, + } = await apolloClient.query({ + query: CRMTypes.GetSubsidyDocument, + variables: { subsidyId: values.subsidy }, + }); + + return evo_subsidy?.evo_get_subsidy_payment || 0; + } + + return 0; + }, + + async subsidySum() { + return values.subsidySum / (1 + VAT); + }, + + async supplierFinancing() { + return false; + }, + + async tLMCost() { + if (values.telematic) { + const { + data: { evo_addproduct_type }, + } = await apolloClient.query({ + query: CRMTypes.GetAddProductTypeDocument, + variables: { addproductTypeId: values.telematic }, + }); + + return evo_addproduct_type?.evo_graph_price_withoutnds ?? 0; + } + + return 0; + }, + + async tlmCostPaymentSum() { + return sum(preparedPayments.rows, (p) => p.tlmCostPayment); + }, + + async totalExpected() { + return values.totalPayments + values.subsidySum; + }, + + async trackerCost() { + if (values.tracker) { + const { + data: { evo_addproduct_type }, + } = await apolloClient.query({ + query: CRMTypes.GetAddProductTypeDocument, + variables: { addproductTypeId: values.tracker }, + }); + + return evo_addproduct_type?.evo_graph_price_withoutnds ?? 0; + } + + return 0; + }, + + async transIncludeGr() { + return values.vehicleTaxInYear > 0; + }, + + async transTax() { + return values.vehicleTaxInYear; + }, + + async transportTaxGr() { + return values.vehicleTaxInLeasingPeriod; + }, + + async transportTaxGrYear() { + return values.vehicleTaxInYear; + }, + }; + + const res = await Promise.all( + (Object.keys(getters) as Array).map( + async (key: T) => { + const value = await getters[key](); + + return { [key]: value }; + } + ) + ); + + return Object.assign({}, ...res); +} diff --git a/apps/web/trpc/routers/calculate/types.ts b/apps/web/trpc/routers/calculate/types.ts index 47becc2..73f7c18 100644 --- a/apps/web/trpc/routers/calculate/types.ts +++ b/apps/web/trpc/routers/calculate/types.ts @@ -1,8 +1,11 @@ import { InsuranceSchema } from '@/config/schema/insurance'; import PaymentsSchema from '@/config/schema/payments'; import ValuesSchema from '@/config/schema/values'; +import type { ProcessContext } from '@/process/types'; import { z } from 'zod'; +export type Context = Pick; + export const CalculateInputSchema = z .object({ insurance: InsuranceSchema, @@ -11,7 +14,147 @@ export const CalculateInputSchema = z }) .strict(); +export type CalculateInput = z.infer; + export const CalculateOutputSchema = z.object({ error: z.string().optional(), success: z.boolean(), }); + +export type CalculateOutput = z.infer; + +export const PreparedValuesSchema = z.object({ + acceptSum: z.number(), + agentsSum: z.number(), + balanceHolder: z.number(), + baseRatCost: z.number(), + baseRegistration: z.number(), + bonus: z.number(), + bonusCoefficient: z.number(), + bonusFinGAP: z.number(), + bonusFix: z.number(), + bonusNsPr: z.number(), + bonusNsibPr: z.number(), + bonusRatPr: z.number(), + brandId: z.string().nullable(), + brokerOfDeliverySum: z.number(), + brokerSum: z.number(), + calcDate: z.date(), + calcType: z.number(), + carCapacity: z.number(), + carCarrying: z.number(), + carSeats: z.number(), + cityc: z.string(), + comissionRub: z.number(), + configurationId: z.string().nullable(), + deliverySum: z.number(), + deliveryTime: z.number(), + deprecationTime: z.number(), + directorBonus: z.number(), + directorBonusFinGAP: z.number(), + directorBonusFix: z.number(), + directorBonusNsib: z.number(), + directorExtraBonus: z.number(), + discount: z.number(), + districtRate: z.number(), + doubleAgentsSum: z.number(), + extraBonus: z.number(), + financialDeptOfDeliverySum: z.number(), + firstPayment: z.number(), + firstPaymentAbs: z.number(), + firstPaymentNdsAbs: z.number(), + firstPaymentSum: z.number(), + firstPaymentWithNdsAbs: z.number(), + fuelCardSum: z.number(), + gpsCostPaymentSum: z.number(), + iRR_MSFO_Plan: z.number(), + importProgramSum: z.number(), + importerSum: z.number(), + insuranceBonus: z.number(), + insuranceBonusLoss: z.number(), + insuranceContract: z.number(), + insuranceEvoKasko: z.number(), + insuranceFinGAP: z.number(), + insuranceKasko: z.number(), + insuranceKaskoNmper: z.number(), + insuranceOsago: z.number(), + irrExpected: z.number(), + lastPayment: z.number(), + lastPaymentFix: z.boolean(), + lastPaymentSum: z.number(), + leasing0K: z.number(), + loanRate: z.number(), + loanRatePeriod: z.number(), + marketRate: z.number(), + modelId: z.string().nullable(), + motorVolume: z.number(), + nmper: z.number(), + nmperDeprecation: z.number(), + nmperFinGAP: z.number(), + nmperInsurance: z.number(), + npvniDelta: z.number(), + npvniExpected: z.number(), + nsBonus: z.number(), + nsibBase: z.number(), + nsibBonus: z.number(), + nsibBrutto: z.number(), + nsibBruttoPr: z.number(), + nsibNetto: z.number(), + nsibNettoPr: z.number(), + paymentDateNew: z.date().nullable(), + plEngineType: z.number().nullable(), + plPrice: z.number(), + plPriceVAT: z.number(), + plPriceWithVAT: z.number(), + plTypeId: z.string().nullable(), + plYear: z.number(), + profitExpected: z.number(), + ratBonus: z.number(), + rats: z.number(), + regionalDirectorBonus: z.number(), + regionalDirectorBonusFinGAP: z.number(), + regionalDirectorBonusFix: z.number(), + regionalDirectorBonusNsib: z.number(), + regionalDirectorExtraBonus: z.number(), + registration: z.number(), + repayment: z.number(), + retroBonus: z.number(), + salaryRate: z.number(), + scheduleOfPayments: z.number(), + subsidyPaymentNumber: z.number(), + subsidySum: z.number(), + supplierFinancing: z.boolean(), + tLMCost: z.number(), + tlmCostPaymentSum: z.number(), + totalExpected: z.number(), + trackerCost: z.number(), + transIncludeGr: z.boolean(), + transTax: z.number(), + transportTaxGr: z.number(), + transportTaxGrYear: z.number(), +}); + +export type PreparedValues = z.infer; + +const PaymentRowSchema = z.object({ + gpsBasePayment: z.number(), + gpsCostPayment: z.number(), + numberPayment: z.number(), + percentPayment: z.number(), + sumPayment: z.number(), + tlmBasePayment: z.number(), + tlmCostPayment: z.number(), +}); + +const PreparedPaymentSchema = z.object({ + rows: PaymentRowSchema.array(), +}); + +export type PreparedPayments = z.infer; + +export const PreparedDataSchema = z.object({ + preparedPayments: PreparedPaymentSchema, + preparedValues: PreparedValuesSchema, +}); + +export type PreparedData = z.infer; diff --git a/apps/web/trpc/routers/calculate/validation.ts b/apps/web/trpc/routers/calculate/validation.ts index 2fb2933..6632519 100644 --- a/apps/web/trpc/routers/calculate/validation.ts +++ b/apps/web/trpc/routers/calculate/validation.ts @@ -1,4 +1,4 @@ -import type { CalculateInputSchema } from './types'; +import type { CalculateInput, Context } from './types'; import { CalculateOutputSchema } from './types'; import elementsTitles from '@/Components/Calculation/config/elements-titles'; import type { Elements } from '@/Components/Calculation/config/map/values'; @@ -10,7 +10,6 @@ import * as leasingObject from '@/process/leasing-object'; import * as paymentsProcess from '@/process/payments'; import * as price from '@/process/price'; import * as supplierAgent from '@/process/supplier-agent'; -import type { ValidationContext } from '@/process/types'; import type { z, ZodIssue } from 'zod'; const processes = [ @@ -43,14 +42,13 @@ const ValidationOutputSchema = CalculateOutputSchema.pick({ }); type ValidationOutput = z.infer; -type ValidationInput = z.infer; export async function validate({ input, context, }: { - context: ValidationContext; - input: ValidationInput; + context: Context; + input: CalculateInput; }): Promise { for (const { createValidationSchema } of processes) { const validationSchema = createValidationSchema(context); diff --git a/apps/web/utils/currency.ts b/apps/web/utils/currency.ts new file mode 100644 index 0000000..222de25 --- /dev/null +++ b/apps/web/utils/currency.ts @@ -0,0 +1,37 @@ +import * as CRMTypes from '@/graphql/crm.types'; +import type { ApolloClient } from '@apollo/client'; +import dayjs from 'dayjs'; +import utc from 'dayjs/plugin/utc'; + +dayjs.extend(utc); + +type Context = { + apolloClient: ApolloClient; +}; + +type Input = { + currencyid: string; + value: number; +}; + +export function createCurrencyUtility({ apolloClient }: Context) { + return { + async RUB({ currencyid, value }: Input) { + const { + data: { evo_currencychanges }, + } = await apolloClient.query({ + fetchPolicy: 'network-only', + query: CRMTypes.GetCurrencyChangesDocument, + variables: { + currentDate: dayjs().utc(false).format('YYYY-MM-DD'), + }, + }); + + const evo_currencychange = evo_currencychanges?.find( + (x) => x?.evo_ref_transactioncurrency === currencyid + ); + + return value * (evo_currencychange?.evo_currencychange || 0); + }, + }; +}