From 5a290d5be957ebabf69ae0b3a03a0a5dc21d1f8e Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Thu, 1 Feb 2024 08:58:19 +0300 Subject: [PATCH] merge branch release/dyn-3855_kasko-validation --- .../Calculation/config/elements-components.ts | 1 + .../Calculation/config/elements-titles.ts | 1 + .../Calculation/config/elements-types.ts | 1 + .../Calculation/config/map/values.ts | 1 + apps/web/config/default-options.ts | 1 + apps/web/config/default-statuses.ts | 1 + apps/web/config/default-values.ts | 1 + apps/web/config/schema/values.ts | 1 + apps/web/graphql/crm.query.graphql | 1 + apps/web/graphql/crm.schema.graphql | 31 +++++++++++ apps/web/graphql/crm.types.ts | 7 ++- apps/web/process/insurance/validation.ts | 54 +++++++++++++++++++ apps/web/process/price/get-kp-data.ts | 11 +++- apps/web/process/used-pl/reactions.ts | 27 ++++++++++ .../server/routers/calculate/lib/transform.ts | 1 + 15 files changed, 136 insertions(+), 4 deletions(-) diff --git a/apps/web/Components/Calculation/config/elements-components.ts b/apps/web/Components/Calculation/config/elements-components.ts index 3f6c49d..d7dde05 100644 --- a/apps/web/Components/Calculation/config/elements-components.ts +++ b/apps/web/Components/Calculation/config/elements-components.ts @@ -133,6 +133,7 @@ const components = wrapComponentsMap({ selectUser: e.Select, cbxSupplierFinancing: e.Switch, tbxPi: e.InputNumber, + cbxPartialVAT: e.Switch, /** Readonly Elements */ labelLeaseObjectRisk: e.Text, diff --git a/apps/web/Components/Calculation/config/elements-titles.ts b/apps/web/Components/Calculation/config/elements-titles.ts index 505163c..bf555a0 100644 --- a/apps/web/Components/Calculation/config/elements-titles.ts +++ b/apps/web/Components/Calculation/config/elements-titles.ts @@ -127,6 +127,7 @@ const titles: Record = { selectUser: 'Пользователь', cbxSupplierFinancing: 'Финансирование поставщика', tbxPi: 'PI', + cbxPartialVAT: 'Частичный НДС', /** Link Elements */ linkDownloadKp: '', diff --git a/apps/web/Components/Calculation/config/elements-types.ts b/apps/web/Components/Calculation/config/elements-types.ts index 24ea19a..4b7c8cc 100644 --- a/apps/web/Components/Calculation/config/elements-types.ts +++ b/apps/web/Components/Calculation/config/elements-types.ts @@ -192,6 +192,7 @@ const types = wrapElementsTypes({ selectUser: t.Options, cbxSupplierFinancing: t.Switch, tbxPi: t.Number, + cbxPartialVAT: t.Switch, labelLeaseObjectRisk: t.Readonly, tbxInsKaskoPriceLeasePeriod: t.Readonly, diff --git a/apps/web/Components/Calculation/config/map/values.ts b/apps/web/Components/Calculation/config/map/values.ts index 77cb28a..5bdf7e2 100644 --- a/apps/web/Components/Calculation/config/map/values.ts +++ b/apps/web/Components/Calculation/config/map/values.ts @@ -130,6 +130,7 @@ const elementsToValues = wrapElementsMap({ selectUser: 'user', cbxSupplierFinancing: 'supplierFinancing', tbxPi: 'pi', + cbxPartialVAT: 'partialVAT', /** Readonly Elements */ labelLeaseObjectRisk: 'leaseObjectRiskName', diff --git a/apps/web/config/default-options.ts b/apps/web/config/default-options.ts index eca1773..0080899 100644 --- a/apps/web/config/default-options.ts +++ b/apps/web/config/default-options.ts @@ -504,6 +504,7 @@ const defaultOptions: CalculationOptions = { selectUser: [], cbxSupplierFinancing: [], tbxPi: [], + cbxPartialVAT: [], }; export default defaultOptions; diff --git a/apps/web/config/default-statuses.ts b/apps/web/config/default-statuses.ts index 48cd1bd..5d2a630 100644 --- a/apps/web/config/default-statuses.ts +++ b/apps/web/config/default-statuses.ts @@ -13,6 +13,7 @@ const defaultStatuses: CalculationStatuses = { cbxLastPaymentRedemption: 'Default', cbxLeaseObjectUsed: 'Default', cbxNSIB: 'Default', + cbxPartialVAT: 'Default', cbxPriceWithDiscount: 'Default', cbxQuoteRedemptionGraph: 'Default', cbxRecalcWithRevision: 'Default', diff --git a/apps/web/config/default-values.ts b/apps/web/config/default-values.ts index 446d400..cc70187 100644 --- a/apps/web/config/default-values.ts +++ b/apps/web/config/default-values.ts @@ -141,6 +141,7 @@ const defaultValues: CalculationValues = { vehicleTaxInYear: 0, vin: null, withTrailer: false, + partialVAT: false, }; export default defaultValues; diff --git a/apps/web/config/schema/values.ts b/apps/web/config/schema/values.ts index 7919d83..3a5ce52 100644 --- a/apps/web/config/schema/values.ts +++ b/apps/web/config/schema/values.ts @@ -126,6 +126,7 @@ const ValuesSchema = z.object({ vehicleTaxInYear: z.number(), vin: z.string().nullable(), withTrailer: z.boolean(), + partialVAT: z.boolean(), /** * Link Values diff --git a/apps/web/graphql/crm.query.graphql b/apps/web/graphql/crm.query.graphql index 240c1ca..e127420 100644 --- a/apps/web/graphql/crm.query.graphql +++ b/apps/web/graphql/crm.query.graphql @@ -214,6 +214,7 @@ query GetProduct($productId: Uuid!) { accounts { accountid } + evo_product_properties } } diff --git a/apps/web/graphql/crm.schema.graphql b/apps/web/graphql/crm.schema.graphql index f2fcfd6..45dfb58 100644 --- a/apps/web/graphql/crm.schema.graphql +++ b/apps/web/graphql/crm.schema.graphql @@ -170,6 +170,7 @@ type account { evo_address_postalidData: evo_address evo_agency_agreementid: Uuid evo_bank_detailses(statecode: Int): [evo_bank_details] + evo_block_pay_supplier: Boolean evo_branch_count: String evo_branch_type: Int evo_broker_accountid: Uuid @@ -462,6 +463,7 @@ type evo_baseproduct { evo_leasingobject_types(statecode: Int): [evo_leasingobject_type] evo_name: String evo_object_count_max: Int + evo_product_properties: [Int!] evo_relation: [Int!] evo_sale_without_nds: Boolean evo_scoring_available: Boolean @@ -964,6 +966,7 @@ type quote { evo_add_director_bonus: Decimal evo_add_equipment: Boolean evo_add_region_director_bonus: Decimal + evo_advance_regulations: Decimal evo_agent_accountid: Uuid evo_agent_reward_conditionid: Uuid evo_agent_reward_summ: Decimal @@ -1070,6 +1073,7 @@ type quote { evo_first_payment_perc_without_subsidy: Decimal evo_first_payment_rub: Decimal evo_first_payment_rub_without_subsidy: Decimal + evo_floating_rate: Boolean evo_franchise: Decimal evo_fssp_legal_entity: Decimal evo_fuel: Boolean @@ -1197,6 +1201,7 @@ type quote { evo_program_import_subsidyid: Uuid evo_program_import_subsidy_sum: Decimal evo_promotion: [Int!] + evo_promotion_credit: Boolean evo_pts_type: Int evo_purchases_participation: Boolean evo_question_credit_committees: [evo_question_credit_committee] @@ -1638,11 +1643,16 @@ type evo_contract { evo_agent_reward_summ: Decimal evo_agent_reward_tech: Decimal evo_agent_service_list: [Int!] + evo_all_payment_summ: Decimal + evo_all_payment_summ_leasing: Decimal + evo_all_payment_summ_penalty_fee: Decimal evo_approvallogs: [evo_approvallog] evo_balance_holder: Int evo_bank_detailsid: Uuid evo_bank_detailsidData: evo_bank_details evo_base_calc_pay: Decimal + evo_bch_account_state: Int + evo_bch_account_state_date: DateTime evo_bonus_pay_systemuserid: Uuid evo_broker_accountid: Uuid evo_broker_request_paymentid: Uuid @@ -1749,6 +1759,11 @@ type evo_contract { evo_fin_department_reward_summ: Decimal evo_fin_department_reward_tech: Decimal evo_fin_department_service_list: [Int!] + evo_first_cre_export_date: DateTime + evo_first_cre_export_date_guarantor1: DateTime + evo_first_cre_export_date_guarantor2: DateTime + evo_first_cre_export_date_guarantor3: DateTime + evo_first_cre_export_date_guarantor4: DateTime evo_first_payment_fact: Decimal evo_first_payment_fact_date: DateTime evo_first_payment_perc: Decimal @@ -1792,6 +1807,11 @@ type evo_contract { evo_last_data_transfer_to_bch_date: DateTime evo_last_formation_cre_date: DateTime evo_last_formation_cre_status: Int + evo_last_missed_payment_leasing_date: DateTime + evo_last_payment_amount: Decimal + evo_last_payment_date: DateTime + evo_last_payment_debt_leasing: Decimal + evo_last_payment_debt_penalty_fee: Decimal evo_last_payment_redemption: Boolean evo_leasingobjectid: Uuid evo_leasingobjectidData: evo_leasingobject @@ -1825,6 +1845,8 @@ type evo_contract { evo_number_dkp: String evo_ownership_date: DateTime evo_paymentorders(evo_name: String, statecode: Int): [evo_paymentorder] + evo_payment_compliance_code: Int + evo_payment_due_date_code: Int evo_payment_redemption: Int evo_payment_redemption_sum: Decimal evo_payment_redemption_sum_without_nds: Decimal @@ -2076,6 +2098,7 @@ type evo_tarif { evo_datefrom: DateTime evo_dateto: DateTime evo_delivery_time: [Int!] + evo_floating_rate: Boolean evo_graphtype_exception: [Int!] evo_id: String evo_ins_type: [Int!] @@ -2099,9 +2122,11 @@ type evo_tarif { evo_models(statecode: Int): [evo_model] evo_model_exceptions(statecode: Int): [evo_model] evo_name: String + evo_nds_rules: Int evo_pay_supplier_without_addcontract: Boolean evo_pl_use_type: [Int!] evo_rates(statecode: Int): [evo_rate] + evo_scoring_accept: Boolean evo_seasons_type_exception: [Int!] evo_tarifid: Uuid evo_transactioncurrencyid: Uuid @@ -2235,6 +2260,7 @@ type systemuser { evo_can_import_sheduled_calls: Boolean evo_datebirth: DateTime evo_editing_question_cc: Boolean + evo_edit_parking: Boolean evo_edo: Boolean evo_edo_department: [Int!] evo_edo_departmentData: [picklist_value] @@ -2645,6 +2671,7 @@ type evo_addcontract { evo_pts_change: Boolean evo_pts_type: Int evo_pts_type_new: Int + evo_publish_site: Boolean evo_quoteid: Uuid evo_reasons_calc: [Int!] evo_reason_validation_doc: [Int!] @@ -3112,6 +3139,7 @@ type evo_systemparameters { evo_card_number_count_request: Int evo_clientfinance_queueid: Uuid evo_client_queueid: Uuid + evo_cre_xml_folder: String evo_custom_reports_directory: String evo_dadata_account_update_maxday: Int evo_dadata_key: String @@ -3600,6 +3628,7 @@ input quoteInput { evo_add_director_bonus: Decimal evo_add_equipment: Boolean evo_add_region_director_bonus: Decimal + evo_advance_regulations: Decimal evo_agent_accountid: Uuid evo_agent_reward_conditionid: Uuid evo_agent_reward_summ: Decimal @@ -3704,6 +3733,7 @@ input quoteInput { evo_first_payment_perc_without_subsidy: Decimal evo_first_payment_rub: Decimal evo_first_payment_rub_without_subsidy: Decimal + evo_floating_rate: Boolean evo_franchise: Decimal evo_fssp_legal_entity: Decimal evo_fuel: Boolean @@ -3824,6 +3854,7 @@ input quoteInput { evo_program_import_subsidyid: Uuid evo_program_import_subsidy_sum: Decimal evo_promotion: [Int!] + evo_promotion_credit: Boolean evo_pts_type: Int evo_purchases_participation: Boolean evo_quotename: String diff --git a/apps/web/graphql/crm.types.ts b/apps/web/graphql/crm.types.ts index c0ab1d5..48fdd01 100644 --- a/apps/web/graphql/crm.types.ts +++ b/apps/web/graphql/crm.types.ts @@ -402,6 +402,7 @@ export type QuoteInput = { evo_add_director_bonus?: InputMaybe; evo_add_equipment?: InputMaybe; evo_add_region_director_bonus?: InputMaybe; + evo_advance_regulations?: InputMaybe; evo_age_drivers?: InputMaybe; evo_agent_accountid?: InputMaybe; evo_agent_reward_conditionid?: InputMaybe; @@ -506,6 +507,7 @@ export type QuoteInput = { evo_first_payment_perc_without_subsidy?: InputMaybe; evo_first_payment_rub?: InputMaybe; evo_first_payment_rub_without_subsidy?: InputMaybe; + evo_floating_rate?: InputMaybe; evo_franchise?: InputMaybe; evo_fssp_legal_entity?: InputMaybe; evo_fuel?: InputMaybe; @@ -626,6 +628,7 @@ export type QuoteInput = { evo_program_import_subsidyid?: InputMaybe; evo_programsolution?: InputMaybe; evo_promotion?: InputMaybe>; + evo_promotion_credit?: InputMaybe; evo_pts_type?: InputMaybe; evo_purchases_participation?: InputMaybe; evo_quotename?: InputMaybe; @@ -802,7 +805,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_id: string | null, evo_supplier_financing_accept: 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, accounts: Array<{ __typename?: 'account', accountid: 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_supplier_financing_accept: boolean | null, evo_product_properties: Array | 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, accounts: Array<{ __typename?: 'account', accountid: string | null } | null> | null } | null }; export type GetSubsidiesQueryVariables = Exact<{ currentDate: InputMaybe; @@ -1209,7 +1212,7 @@ export const GetTarifDocument = {"kind":"Document","definitions":[{"kind":"Opera 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"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_rateid"}}]}}]}}]} 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"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id"}},{"kind":"Field","name":{"kind":"Name","value":"evo_finance_rate"}}]}}]}}]} 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"}},{"kind":"Field","name":{"kind":"Name","value":"systemusers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"systemuserid"}}]}}]}}]}}]} 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"}},{"kind":"Field","name":{"kind":"Name","value":"evo_supplier_financing_accept"}},{"kind":"Field","name":{"kind":"Name","value":"accounts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accountid"}}]}}]}}]}}]} 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"}},{"kind":"Field","name":{"kind":"Name","value":"evo_supplier_financing_accept"}},{"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_product_properties"}}]}}]}}]} 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"}},{"kind":"Field","name":{"kind":"Name","value":"evo_get_subsidy_payment"}},{"kind":"Field","name":{"kind":"Name","value":"evo_delivery_time"}}]}}]}}]} 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; diff --git a/apps/web/process/insurance/validation.ts b/apps/web/process/insurance/validation.ts index 9566a62..49c3a74 100644 --- a/apps/web/process/insurance/validation.ts +++ b/apps/web/process/insurance/validation.ts @@ -11,9 +11,14 @@ import { z } from 'zod'; export function createValidationSchema({ apolloClient }: ValidationContext) { return ValuesSchema.pick({ brand: true, + firstPaymentPerc: true, insDecentral: true, + leaseObjectType: true, leasingPeriod: true, leasingWithoutKasko: true, + partialVAT: true, + plPriceRub: true, + product: true, quote: true, recalcWithRevision: true, }) @@ -33,6 +38,11 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { insurance, brand: brandId, fingap: fingapRisks, + partialVAT, + product: productId, + leaseObjectType: leaseObjectTypeId, + firstPaymentPerc, + plPriceRub, }, ctx ) => { @@ -210,6 +220,50 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { } } } + + let evo_baseproduct: CRMTypes.GetProductQuery['evo_baseproduct'] = null; + if (productId) { + const { data } = await apolloClient.query({ + query: CRMTypes.GetProductDocument, + variables: { productId }, + }); + ({ evo_baseproduct } = data); + } + + if ( + (partialVAT || evo_baseproduct?.evo_sale_without_nds) && + insurance.values.kasko.insured === 100_000_001 + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'При частичном НДС нельзя включать КАСКО в график', + path: ['cbxPartialVAT'], + }); + } + + let evo_leasingobject_type: CRMTypes.GetLeaseObjectTypeQuery['evo_leasingobject_type'] = + null; + + if (leaseObjectTypeId) { + const { data } = await apolloClient.query({ + query: CRMTypes.GetLeaseObjectTypeDocument, + variables: { leaseObjectTypeId }, + }); + ({ evo_leasingobject_type } = data); + } + + if ( + evo_leasingobject_type?.evo_id === '1' && + firstPaymentPerc < 25 && + plPriceRub > 20_000_000 && + insurance.values.kasko.insured === 100_000_001 + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'При дорогом авто и авансе меньше 25% нельзя включать КАСКО в график', + path: ['tbxLeaseObjectPrice'], + }); + } } ); } diff --git a/apps/web/process/price/get-kp-data.ts b/apps/web/process/price/get-kp-data.ts index be2a8a8..36350f9 100644 --- a/apps/web/process/price/get-kp-data.ts +++ b/apps/web/process/price/get-kp-data.ts @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/cognitive-complexity */ import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types'; import initializeApollo from '@/apollo/client'; import defaultValues from '@/config/default-values'; @@ -27,7 +28,7 @@ const QUERY_GET_QUOTE_PRICE_DATA = gql` `; export async function getKPData({ - values: { quote: quoteId }, + values: { quote: quoteId, recalcWithRevision }, }: GetQuoteInputData): Promise { const apolloClient = initializeApollo(); @@ -40,6 +41,12 @@ export async function getKPData({ }, }); + let lastPaymentRule = quote?.evo_last_payment_calc ?? defaultValues.lastPaymentRule; + + if (recalcWithRevision && quote?.evo_last_payment_calc === 100_000_002) { + lastPaymentRule = 100_000_001; + } + return { values: { VATInLeaseObjectPrice: @@ -51,7 +58,7 @@ export async function getKPData({ firstPaymentRub: quote?.evo_first_payment_rub ?? defaultValues.firstPaymentRub, lastPaymentPerc: quote?.evo_last_payment_perc ?? defaultValues.lastPaymentPerc, lastPaymentRub: quote?.evo_last_payment_rub ?? defaultValues.lastPaymentRub, - lastPaymentRule: quote?.evo_last_payment_calc, + lastPaymentRule, leaseObjectPrice: quote?.evo_supplier_currency_price ?? defaultValues.leaseObjectPrice, leaseObjectPriceWthtVAT: quote?.evo_price_without_nds_supplier_currency ?? defaultValues.leaseObjectPriceWthtVAT, diff --git a/apps/web/process/used-pl/reactions.ts b/apps/web/process/used-pl/reactions.ts index f64427e..bb262e0 100644 --- a/apps/web/process/used-pl/reactions.ts +++ b/apps/web/process/used-pl/reactions.ts @@ -313,6 +313,33 @@ export function common({ store, apolloClient }: ProcessContext) { } } ); + + /** + * Если Продукт selectProduct в "ID" содержит "IZT" + * то поле "ПЛ БУ" leaseObjectUsed = true Да и закрыто для редактирования, + * иначе открыто для редактирования + */ + reaction( + () => $calculation.element('selectProduct').getValue(), + async (productId) => { + let izt = false; + + if (productId) { + const { + data: { evo_baseproduct }, + } = await apolloClient.query({ + query: CRMTypes.GetProductDocument, + variables: { productId }, + }); + + if (evo_baseproduct?.evo_product_properties) + izt = evo_baseproduct?.evo_product_properties?.includes(100_000_000); + } + + if (izt) $calculation.element('cbxLeaseObjectUsed').setValue(true).block(); + else $calculation.element('cbxLeaseObjectUsed').unblock(); + } + ); } export const validation = createValidationReaction(createValidationSchema); diff --git a/apps/web/server/routers/calculate/lib/transform.ts b/apps/web/server/routers/calculate/lib/transform.ts index 8e8d507..b86a397 100644 --- a/apps/web/server/routers/calculate/lib/transform.ts +++ b/apps/web/server/routers/calculate/lib/transform.ts @@ -89,6 +89,7 @@ export function transformCalculateResults({ columns?.extraBonusSumColumn.values[0] + preparedValues.importerSum + preparedValues.agentsSum + + preparedValues.doubleAgentsSum + preparedValues.deliverySum + preparedValues.brokerSum + preparedValues.brokerOfDeliverySum +