From 25ad87b7b2582dd351d857e1b1d52757bd8e88fe Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Wed, 24 Jul 2024 13:53:16 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=20=D0=BC=D0=BE=D0=BC=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D1=80=D0=B5=D0=B7=D1=83=D0=BB=D1=8C=D1=82=D0=B0=D1=82=D0=B0=20?= =?UTF-8?q?=D1=80=D0=B0=D1=81=D1=87=D0=B5=D1=82=D0=B0=20=D0=B8=D0=B7=20ELT?= =?UTF-8?q?=20(=D0=B4=D0=BE=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=D0=B0=20?= =?UTF-8?q?=D1=80=D0=B5=D0=B7=D1=83=D0=BB=D1=8C=D1=82=D0=B0=D1=82=D0=B0)?= =?UTF-8?q?=20=D0=BF=D0=BE=20=D0=BA=D0=B0=D0=B6=D0=B4=D0=BE=D0=B9=20=D0=A1?= =?UTF-8?q?=D1=82=D1=80=D0=B0=D1=85=D0=BE=D0=B2=D0=BE=D0=B9=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BC=D0=BF=D0=B0=D0=BD=D0=B8=D0=B8=20=D0=BE=D1=81=D1=83=D1=89?= =?UTF-8?q?=D0=B5=D1=81=D1=82=D0=B2=D0=BB=D1=8F=D1=82=D1=8C:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit по КАСКО: осуществлять проверку если в карточке Страховая компания "Фактическая доля" evo_kasko_fact_part > "Плановой доли" evo_kasko_plan_part, то в полученных результатах от ELT заменить значения: "requestId": обнулять, "skCalcId": обнулять "sum": обнулять "totalFranchise": обнулять --- apps/web/graphql/crm.query.graphql | 2 + apps/web/graphql/crm.schema.graphql | 139 +++++++++++++++++++++------ apps/web/graphql/crm.types.ts | 4 +- apps/web/process/elt/lib/response.ts | 48 +++++++-- apps/web/server/routers/elt/kasko.ts | 6 +- 5 files changed, 157 insertions(+), 42 deletions(-) diff --git a/apps/web/graphql/crm.query.graphql b/apps/web/graphql/crm.query.graphql index 47ec3d4..dc12bdb 100644 --- a/apps/web/graphql/crm.query.graphql +++ b/apps/web/graphql/crm.query.graphql @@ -1059,6 +1059,8 @@ query GetInsuranceCompany($accountId: UUID!) { evo_osago_with_kasko evo_legal_region_calc accountid + evo_kasko_fact_part + evo_kasko_plan_part } } diff --git a/apps/web/graphql/crm.schema.graphql b/apps/web/graphql/crm.schema.graphql index e5c8f7d..1e68673 100644 --- a/apps/web/graphql/crm.schema.graphql +++ b/apps/web/graphql/crm.schema.graphql @@ -105,6 +105,8 @@ type Query { evo_insurance_periods(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_insurance_period] evo_insurance_policy(evo_insurance_policyid: UUID!): evo_insurance_policy evo_insurance_policies(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_insurance_policy] + evo_insurance_rules(evo_insurance_rulesid: UUID!): evo_insurance_rules + evo_insurance_ruleses(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_insurance_rules] evo_job_title(evo_job_titleid: UUID!): evo_job_title evo_job_titles(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_job_title] evo_leasingobject(evo_leasingobjectid: UUID!): evo_leasingobject @@ -2174,8 +2176,8 @@ type systemuser { roles: [role] evo_edo_departmentData: [picklist_value] businessunitidData: businessunit - leads(orderby: OrderByInput): [lead] - opportunities(orderby: OrderByInput): [opportunity] + leads(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [lead] + opportunities(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [opportunity] link: String picklistName(value: Int, key: String): String twoParamsName(value: Boolean, key: String): String @@ -2270,7 +2272,7 @@ type role { evo_documenttypes: [evo_documenttype] evo_documenttypes_letter: [evo_documenttype] evo_connection_roleData: [evo_connection_role] - systemusers: [systemuser] + systemusers(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [systemuser] picklistName(value: Int, key: String): String twoParamsName(value: Boolean, key: String): String } @@ -2807,9 +2809,9 @@ type quote { evo_statuscodeidData: evo_statuscode evo_evokasko_insurer_accountidData: account evo_supplier_accountidData: account - evo_addproduct_types: [evo_addproduct_type] - evo_product_risks: [evo_product_risk] - evo_graphs: [evo_graph] + evo_addproduct_types(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_addproduct_type] + evo_product_risks(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_product_risk] + evo_graphs(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_graph] evo_approvallogs: [evo_approvallog] evo_lessor_bank_detailsidData: evo_bank_details evo_accept_control_addproduct_typeidData: evo_addproduct_type @@ -4082,10 +4084,10 @@ type evo_tarif { organizationid: UUID evo_client_risks: [evo_client_risk] evo_client_types: [evo_client_type] - evo_leasingobject_types: [evo_leasingobject_type] + evo_leasingobject_types(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_leasingobject_type] evo_models: [evo_model] evo_model_exceptions: [evo_model] - evo_rates: [evo_rate] + evo_rates(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_rate] link: String picklistName(value: Int, key: String): String twoParamsName(value: Boolean, key: String): String @@ -4265,10 +4267,10 @@ type evo_subsidy { modifiedby: UUID createdby: UUID organizationid: UUID - evo_brands: [evo_brand] - evo_models: [evo_model] - accounts: [account] - evo_leasingobject_types: [evo_leasingobject_type] + evo_brands(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_brand] + evo_models(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_model] + accounts(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [account] + evo_leasingobject_types(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_leasingobject_type] link: String picklistName(value: Int, key: String): String twoParamsName(value: Boolean, key: String): String @@ -4879,7 +4881,7 @@ type evo_region { modifiedby: UUID createdby: UUID organizationid: UUID - accounts: [account] + accounts(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [account] link: String picklistName(value: Int, key: String): String twoParamsName(value: Boolean, key: String): String @@ -4937,7 +4939,7 @@ type evo_rate { createdby: UUID organizationid: UUID evo_brands: [evo_brand] - evo_tarifs: [evo_tarif] + evo_tarifs(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_tarif] link: String picklistName(value: Int, key: String): String twoParamsName(value: Boolean, key: String): String @@ -5798,8 +5800,8 @@ type evo_leasingobject_type { modifiedby: UUID createdby: UUID organizationid: UUID - evo_subsidies: [evo_subsidy] - evo_vehicle_body_types: [evo_vehicle_body_type] + evo_subsidies(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_subsidy] + evo_vehicle_body_types(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_vehicle_body_type] link: String picklistName(value: Int, key: String): String twoParamsName(value: Boolean, key: String): String @@ -6024,6 +6026,83 @@ type evo_job_title { twoParamsName(value: Boolean, key: String): String } +type evo_insurance_rules { + toOdata(keys: [String]): [KeyValuePairOfStringAndObject!] + toOdataCreate: [KeyValuePairOfStringAndObject!] + toOdataUpdate: [KeyValuePairOfStringAndObject!] + emptyGuids: [String] + entitySetName: String + primaryId: UUID! + relativePathForUpdate: String + containerFields: [KeyValuePairOfStringAndObject!] + evo_insurance_rulesid: UUID + createdon: DateTime + modifiedon: DateTime + overriddencreatedon: DateTime + evo_dateto: DateTime + evo_datefrom: DateTime + evo_risk: Int + evo_max_year: Int + evo_object_type: Int + evo_dealer: Int + statecode: Int + timezoneruleversionnumber: Int + evo_rules_type: Int + utcconversiontimezonecode: Int + importsequencenumber: Int + evo_brand: Int + evo_max_period: Int + evo_model: Int + evo_min_year: Int + evo_region: Int + statuscode: Int + evo_min_period: Int + evo_min_price: Decimal + evo_min_mileage: Decimal + evo_min_power: Decimal + evo_max_power: Decimal + evo_max_price: Decimal + evo_max_mileage: Decimal + evo_discount: Decimal + modifiedbyname: String + evo_insurer_accountidname: String + evo_message: String + evo_id: String + createdonbehalfbyname: String + createdbyyominame: String + evo_name: String + createdbyname: String + modifiedonbehalfbyname: String + createdonbehalfbyyominame: String + modifiedbyyominame: String + evo_insurer_accountidyominame: String + modifiedonbehalfbyyominame: String + organizationidname: String + evo_opf: [Int!] + evo_use_for: [Int!] + evo_enginie_type: [Int!] + evo_category: [Int!] + createdonbehalfby: UUID + modifiedonbehalfby: UUID + evo_insurer_accountid: UUID + createdby: UUID + modifiedby: UUID + organizationid: UUID + evo_models: [evo_model] + evo_brands: [evo_brand] + evo_regions: [evo_region] + accounts: [account] + evo_riskname: String + evo_rules_typename: String + ownerid_systemuser: UUID + ownerid_team: UUID + ownerid_systemuserData: systemuser + ownerid_teamData: team + link: String + picklistName(value: Int, key: String): String + twoParamsName(value: Boolean, key: String): String +} + type evo_insurance_policy { toOdata(keys: [String]): [KeyValuePairOfStringAndObject!] toOdataCreate: [KeyValuePairOfStringAndObject!] @@ -6593,7 +6672,7 @@ type evo_graph { modifiedonbehalfby: UUID ownerid_systemuser: UUID ownerid_team: UUID - evo_planpayments: [evo_planpayment] + evo_planpayments(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_planpayment] ownerid_systemuserData: systemuser ownerid_teamData: team link: String @@ -8344,9 +8423,9 @@ type evo_coefficient { evo_businessunitid: UUID organizationid: UUID evo_job_titleid: UUID - evo_leasingobject_types: [evo_leasingobject_type] - evo_businessunits: [evo_businessunit] - evo_baseproducts: [evo_baseproduct] + evo_leasingobject_types(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_leasingobject_type] + evo_businessunits(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_businessunit] + evo_baseproducts(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_baseproduct] evo_sot_coefficient_typeidData: evo_sot_coefficient_type link: String picklistName(value: Int, key: String): String @@ -8633,12 +8712,12 @@ type evo_baseproduct { modifiedby: UUID createdby: UUID organizationid: UUID - evo_leasingobject_types: [evo_leasingobject_type] - evo_brands: [evo_brand] - systemusers: [systemuser] - accounts: [account] + evo_leasingobject_types(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_leasingobject_type] + evo_brands(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_brand] + systemusers(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [systemuser] + accounts(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [account] evo_coefficients: [evo_coefficient] - evo_baseproducts: [evo_baseproduct] + evo_baseproducts(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_baseproduct] link: String picklistName(value: Int, key: String): String twoParamsName(value: Boolean, key: String): String @@ -9226,11 +9305,11 @@ type evo_addproduct_type { modifiedonbehalfby: UUID organizationid: UUID evo_accountid: UUID - evo_leasingobject_types: [evo_leasingobject_type] - evo_planpayments: [evo_planpayment] - evo_addproduct_types: [evo_addproduct_type] - evo_models: [evo_model] - evo_brands: [evo_brand] + evo_leasingobject_types(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_leasingobject_type] + evo_planpayments(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_planpayment] + evo_addproduct_types(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_addproduct_type] + evo_models(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_model] + evo_brands(filterConditionGroup: FilterConditionGroupInput, orderby: OrderByInput): [evo_brand] link: String picklistName(value: Int, key: String): String twoParamsName(value: Boolean, key: String): String diff --git a/apps/web/graphql/crm.types.ts b/apps/web/graphql/crm.types.ts index 97f9f07..bf88e37 100644 --- a/apps/web/graphql/crm.types.ts +++ b/apps/web/graphql/crm.types.ts @@ -2223,7 +2223,7 @@ export type GetInsuranceCompanyQueryVariables = Exact<{ }>; -export type GetInsuranceCompanyQuery = { __typename?: 'Query', account: { __typename?: 'account', evo_osago_with_kasko: boolean | null, evo_legal_region_calc: boolean | null, accountid: string | null } | null }; +export type GetInsuranceCompanyQuery = { __typename?: 'Query', account: { __typename?: 'account', evo_osago_with_kasko: boolean | null, evo_legal_region_calc: boolean | null, accountid: string | null, evo_kasko_fact_part: number | null, evo_kasko_plan_part: number | null } | null }; export type GetInsuranceCompaniesQueryVariables = Exact<{ [key: string]: never; }>; @@ -2291,6 +2291,6 @@ export const GetTrackerTypesDocument = {"kind":"Document","definitions":[{"kind" export const GetInsNsibTypesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetInsNSIBTypes"},"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":"filterConditionGroup"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"andFilterConditions"},"value":{"kind":"ListValue","values":[{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"filterConditionInt"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"fieldName"},"value":{"kind":"StringValue","value":"statecode","block":false}},{"kind":"ObjectField","name":{"kind":"Name","value":"eq"},"value":{"kind":"IntValue","value":"0"}}]}}]},{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"filterConditionDateTime"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"fieldName"},"value":{"kind":"StringValue","value":"evo_datefrom","block":false}},{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}}]},{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"filterConditionDateTime"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"fieldName"},"value":{"kind":"StringValue","value":"evo_dateto","block":false}},{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}}]},{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"filterConditionInt"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"fieldName"},"value":{"kind":"StringValue","value":"evo_product_type","block":false}},{"kind":"ObjectField","name":{"kind":"Name","value":"eq"},"value":{"kind":"IntValue","value":"100000002"}}]}}]}]}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"CoreAddProductTypesFields"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_price"}},{"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_visible_calc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_first_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_first_payment_perc"}}]}}]}},{"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 GetLeasingWithoutKaskoTypesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLeasingWithoutKaskoTypes"},"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":"filterConditionGroup"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"andFilterConditions"},"value":{"kind":"ListValue","values":[{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"filterConditionInt"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"fieldName"},"value":{"kind":"StringValue","value":"statecode","block":false}},{"kind":"ObjectField","name":{"kind":"Name","value":"eq"},"value":{"kind":"IntValue","value":"0"}}]}}]},{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"filterConditionDateTime"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"fieldName"},"value":{"kind":"StringValue","value":"evo_datefrom","block":false}},{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}}]},{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"filterConditionDateTime"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"fieldName"},"value":{"kind":"StringValue","value":"evo_dateto","block":false}},{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}}]},{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"filterConditionInt"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"fieldName"},"value":{"kind":"StringValue","value":"evo_product_type","block":false}},{"kind":"ObjectField","name":{"kind":"Name","value":"eq"},"value":{"kind":"IntValue","value":"100000007"}}]}}]}]}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"CoreAddProductTypesFields"}},{"kind":"Field","name":{"kind":"Name","value":"evo_product_type"}},{"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_min_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_price"}},{"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_visible_calc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_first_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_first_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_models"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_modelid"}}]}}]}}]}},{"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 GetOsagoAddproductTypesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetOsagoAddproductTypes"},"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":"filterConditionGroup"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"andFilterConditions"},"value":{"kind":"ListValue","values":[{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"filterConditionInt"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"fieldName"},"value":{"kind":"StringValue","value":"statecode","block":false}},{"kind":"ObjectField","name":{"kind":"Name","value":"eq"},"value":{"kind":"IntValue","value":"0"}}]}}]},{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"filterConditionDateTime"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"fieldName"},"value":{"kind":"StringValue","value":"evo_datefrom","block":false}},{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}}]},{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"filterConditionDateTime"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"fieldName"},"value":{"kind":"StringValue","value":"evo_dateto","block":false}},{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}}]},{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"filterConditionInt"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"fieldName"},"value":{"kind":"StringValue","value":"evo_product_type","block":false}},{"kind":"ObjectField","name":{"kind":"Name","value":"eq"},"value":{"kind":"IntValue","value":"100000008"}}]}}]}]}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_product_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_visible_calc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"createdon"}},{"kind":"Field","name":{"kind":"Name","value":"evo_category"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_power"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_power"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_seats_count"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_seats_count"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_mass"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_mass"}},{"kind":"Field","name":{"kind":"Name","value":"evo_graph_price_withoutnds"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id"}}]}}]}}]} as unknown as DocumentNode; -export const GetInsuranceCompanyDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetInsuranceCompany"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"accountId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"account"},"name":{"kind":"Name","value":"insurance"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"accountid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"accountId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_osago_with_kasko"}},{"kind":"Field","name":{"kind":"Name","value":"evo_legal_region_calc"}},{"kind":"Field","name":{"kind":"Name","value":"accountid"}}]}}]}}]} as unknown as DocumentNode; +export const GetInsuranceCompanyDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetInsuranceCompany"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"accountId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"account"},"name":{"kind":"Name","value":"insurance"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"accountid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"accountId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_osago_with_kasko"}},{"kind":"Field","name":{"kind":"Name","value":"evo_legal_region_calc"}},{"kind":"Field","name":{"kind":"Name","value":"accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_kasko_fact_part"}},{"kind":"Field","name":{"kind":"Name","value":"evo_kasko_plan_part"}}]}}]}}]} as unknown as DocumentNode; export const GetInsuranceCompaniesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetInsuranceCompanies"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"accounts"},"name":{"kind":"Name","value":"insurances"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_type_ins_policy"}},{"kind":"Field","name":{"kind":"Name","value":"evo_evokasko_access"}},{"kind":"Field","name":{"kind":"Name","value":"evo_inn"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"accountid"}},{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id_elt_osago"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id_elt"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id_elt_smr"}},{"kind":"Field","name":{"kind":"Name","value":"evo_osago_id"}},{"kind":"Field","name":{"kind":"Name","value":"evo_kasko_category"}},{"kind":"Field","name":{"kind":"Name","value":"evo_osago_category"}}]}}]}}]} as unknown as DocumentNode; export const GetRolesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRoles"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"roleName"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"roles"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"filterConditionGroup"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"andFilterConditions"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"filterConditionString"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"fieldName"},"value":{"kind":"StringValue","value":"name","block":false}},{"kind":"ObjectField","name":{"kind":"Name","value":"eq"},"value":{"kind":"Variable","name":{"kind":"Name","value":"roleName"}}}]}}]}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"systemusers"},"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":"domainname"}}]}}]}}]}}]} as unknown as DocumentNode; \ No newline at end of file diff --git a/apps/web/process/elt/lib/response.ts b/apps/web/process/elt/lib/response.ts index cd20a1b..03cc528 100644 --- a/apps/web/process/elt/lib/response.ts +++ b/apps/web/process/elt/lib/response.ts @@ -2,7 +2,9 @@ import type { ownOsagoRequest } from './request'; import type * as ELT from '@/api/elt/types'; import type { Row } from '@/Components/Calculation/Form/ELT/types'; import { MAX_FRANCHISE, MAX_INSURANCE, MIN_INSURANCE } from '@/constants/values'; -import type { CalculationValues } from '@/stores/calculation/values/types'; +import * as CRMTypes from '@/graphql/crm.types'; +import type { ProcessContext } from '@/process/types'; +import { defaultRow } from '@/stores/tables/elt/default-values'; export function convertEltOsagoResponse(response: ELT.ResponseEltOsago, row: Row): Row { const { message, numCalc, premiumSum = 0, skCalcId } = response; @@ -72,15 +74,22 @@ export function convertOwnOsagoResult(result: ResponseOwnOsago | undefined, row: }; } -export function convertEltKaskoResponse( - res: ELT.ResponseEltKasko, - row: Row, - values: CalculationValues -): Row { - const { kaskoSum = 0, message, paymentPeriods, requestId, skCalcId, totalFranchise = 0 } = res; - let { error } = res; +type ConvertEltKaskoResponseInput = { + context: Pick; + response: ELT.ResponseEltKasko; + row: Row; +}; - const sum = values.leasingPeriod <= 16 ? kaskoSum : paymentPeriods?.[0]?.kaskoSum || 0; +export async function convertEltKaskoResponse(input: ConvertEltKaskoResponseInput): Promise { + const { context, response, row } = input; + const { apolloClient, store } = context; + + const { kaskoSum = 0, message, paymentPeriods } = response; + let { requestId, skCalcId, totalFranchise = 0, error } = response; + + const { $calculation } = store; + const leasingPeriod = $calculation.element('tbxLeasingPeriod').getValue(); + let sum = leasingPeriod <= 16 ? kaskoSum : paymentPeriods?.[0]?.kaskoSum || 0; if (totalFranchise > MAX_FRANCHISE) { error ||= `Франшиза по страховке превышает максимально допустимое значение: ${Intl.NumberFormat( @@ -112,6 +121,27 @@ export function convertEltKaskoResponse( ).format(MIN_INSURANCE)}`; } + const { + data: { account: insuranceCompany }, + } = await apolloClient.query({ + query: CRMTypes.GetInsuranceCompanyDocument, + variables: { accountId: row.key }, + }); + + if ( + insuranceCompany?.evo_kasko_fact_part !== null && + insuranceCompany?.evo_kasko_plan_part !== undefined && + insuranceCompany?.evo_kasko_plan_part !== null && + insuranceCompany?.evo_kasko_plan_part !== undefined && + insuranceCompany?.evo_kasko_fact_part > insuranceCompany?.evo_kasko_plan_part + ) { + requestId = defaultRow.requestId; + skCalcId = defaultRow.skCalcId; + sum = defaultRow.sum; + totalFranchise = defaultRow.totalFranchise; + error = 'Расчет возможен только через отдел страхования ЛК'; + } + return { ...row, message: error || message, diff --git a/apps/web/server/routers/elt/kasko.ts b/apps/web/server/routers/elt/kasko.ts index 15ce450..25ace4a 100644 --- a/apps/web/server/routers/elt/kasko.ts +++ b/apps/web/server/routers/elt/kasko.ts @@ -25,7 +25,11 @@ export const eltKaskoRouter = router({ const requests = initRows.map((row) => makeEltKaskoRequest({ apolloClient, store }, row).then((request) => getEltKasko(request) - .then((response) => convertEltKaskoResponse(response, row, input.calculation.values)) + .then((response) => + convertEltKaskoResponse({ context: { apolloClient, store }, response, row }).then( + (convertedRow) => convertedRow + ) + ) .catch((error) => ({ ...row, message: error.message, status: 'error' })) ) );