diff --git a/apps/web/Components/Calculation/Form/Leasing/config.ts b/apps/web/Components/Calculation/Form/Leasing/config.ts index 4c8704e..1c77106 100644 --- a/apps/web/Components/Calculation/Form/Leasing/config.ts +++ b/apps/web/Components/Calculation/Form/Leasing/config.ts @@ -7,7 +7,7 @@ export const rows: FormTabRows = [ [['selectProduct'], { gridTemplateColumns: '1fr' }], [['tbxLeaseObjectPrice', 'tbxVATInLeaseObjectPrice', 'tbxLeaseObjectPriceWthtVAT']], [['selectSupplierCurrency', 'tbxSupplierDiscountRub', 'tbxSupplierDiscountPerc']], - [['tbxFirstPaymentPerc', 'tbxFirstPaymentRub', 'cbxSupplierFinancing']], + [['tbxFirstPaymentPerc', 'tbxFirstPaymentRub']], [['tbxLeasingPeriod', 'tbxSaleBonus']], [['selectSubsidy', 'tbxSubsidySum'], { gridTemplateColumns: '2fr 1fr' }], [['selectImportProgram', 'tbxImportProgramSum', 'tbxAddEquipmentPrice']], diff --git a/apps/web/Components/Calculation/Form/Unlimited/config.ts b/apps/web/Components/Calculation/Form/Unlimited/config.ts index 2c5cc34..0ce3042 100644 --- a/apps/web/Components/Calculation/Form/Unlimited/config.ts +++ b/apps/web/Components/Calculation/Form/Unlimited/config.ts @@ -9,4 +9,5 @@ export const rows: FormTabRows = [ [['tbxMinPriceChange', 'tbxMaxPriceChange']], [['tbxImporterRewardPerc', 'tbxImporterRewardRub']], [['tbxBonusCoefficient', 'tbxComissionRub', 'tbxComissionPerc']], + [['cbxSupplierFinancing']], ]; diff --git a/apps/web/api/crm/types.ts b/apps/web/api/crm/types.ts index 4a8a47b..bc86dd9 100644 --- a/apps/web/api/crm/types.ts +++ b/apps/web/api/crm/types.ts @@ -21,7 +21,7 @@ export const RequestCreateKPSchema = z.object({ ), domainName: z.string(), finGAP: RiskSchema.array(), - insurance: RowSchema.array(), + insurance: RowSchema.extend({ key: z.string() }).array(), }); export type RequestCreateKP = z.infer; diff --git a/apps/web/config/default-options.ts b/apps/web/config/default-options.ts index 1f383dc..15f6026 100644 --- a/apps/web/config/default-options.ts +++ b/apps/web/config/default-options.ts @@ -193,6 +193,10 @@ export const radioCalcType = [ label: 'Суммы', value: 100_000_001, }, + { + label: 'PI', + value: 100_000_099, + }, ]; export const selectRequirementTelematic = [ diff --git a/apps/web/config/default-values.ts b/apps/web/config/default-values.ts index d83ae9d..d398ec7 100644 --- a/apps/web/config/default-values.ts +++ b/apps/web/config/default-values.ts @@ -111,7 +111,7 @@ const defaultValues: CalculationValues = { quoteUrl: null, rate: null, recalcWithRevision: false, - redemptionPaymentSum: 0, + redemptionPaymentSum: null, regionRegistration: null, registration: null, registrationDescription: '-', diff --git a/apps/web/config/schema/values.ts b/apps/web/config/schema/values.ts index e764341..1c6fc82 100644 --- a/apps/web/config/schema/values.ts +++ b/apps/web/config/schema/values.ts @@ -98,7 +98,7 @@ const ValuesSchema = z.object({ quoteRedemptionGraph: z.boolean(), rate: z.string().nullable(), recalcWithRevision: z.boolean(), - redemptionPaymentSum: z.number(), + redemptionPaymentSum: z.number().nullable(), regionRegistration: z.string().nullable(), registration: z.string().nullable(), registrationQuote: z.boolean(), diff --git a/apps/web/graphql/crm.query.graphql b/apps/web/graphql/crm.query.graphql index 29884a6..aad6b15 100644 --- a/apps/web/graphql/crm.query.graphql +++ b/apps/web/graphql/crm.query.graphql @@ -178,6 +178,9 @@ query GetProducts($currentDate: DateTime) { label: evo_name value: evo_baseproductid evo_baseproductid + systemusers { + systemuserid + } } } @@ -385,6 +388,7 @@ query GetDealer($dealerId: Uuid!) { dealer: account(accountid: $dealerId) { evo_return_leasing_dealer evo_broker_accountid + evo_supplier_financing_accept } } @@ -446,12 +450,12 @@ query GetSotCoefficientType($evo_id: String) { evo_sot_coefficient_typeid } } -query GetCoefficients($currentDate: DateTime, $jobTitleId: Uuid!) { + +query GetCoefficients($currentDate: DateTime) { evo_coefficients( statecode: 0 evo_datefrom_param: { lte: $currentDate } evo_dateto_param: { gte: $currentDate } - evo_job_titleid: $jobTitleId ) { evo_job_titleid evo_sot_coefficient_typeid @@ -483,6 +487,7 @@ query GetSystemUser($domainname: String) { roles { name } + systemuserid } } diff --git a/apps/web/graphql/crm.types.ts b/apps/web/graphql/crm.types.ts index 3ba305f..833e838 100644 --- a/apps/web/graphql/crm.types.ts +++ b/apps/web/graphql/crm.types.ts @@ -210,7 +210,7 @@ export type GetProductsQueryVariables = Exact<{ }>; -export type GetProductsQuery = { __typename?: 'Query', evo_baseproducts: Array<{ __typename?: 'evo_baseproduct', evo_baseproductid: string | null, label: string | null, value: string | null } | null> | null }; +export type GetProductsQuery = { __typename?: 'Query', evo_baseproducts: Array<{ __typename?: 'evo_baseproduct', evo_baseproductid: string | null, label: string | null, value: string | null, systemusers: Array<{ __typename?: 'systemuser', systemuserid: string | null } | null> | null } | null> | null }; export type GetProductQueryVariables = Exact<{ productId: Scalars['Uuid']; @@ -333,7 +333,7 @@ export type GetDealerQueryVariables = Exact<{ }>; -export type GetDealerQuery = { __typename?: 'Query', dealer: { __typename?: 'account', evo_return_leasing_dealer: boolean | null, evo_broker_accountid: string | null } | null }; +export type GetDealerQuery = { __typename?: 'Query', dealer: { __typename?: 'account', evo_return_leasing_dealer: boolean | null, evo_broker_accountid: string | null, evo_supplier_financing_accept: boolean | null } | null }; export type GetDealerPersonsQueryVariables = Exact<{ dealerId: Scalars['Uuid']; @@ -380,7 +380,6 @@ export type GetSotCoefficientTypeQuery = { __typename?: 'Query', evo_sot_coeffic export type GetCoefficientsQueryVariables = Exact<{ currentDate: InputMaybe; - jobTitleId: Scalars['Uuid']; }>; @@ -391,7 +390,7 @@ export type GetSystemUserQueryVariables = Exact<{ }>; -export type GetSystemUserQuery = { __typename?: 'Query', systemuser: { __typename?: 'systemuser', evo_job_titleid: string | null, businessunitid: string | null, roles: Array<{ __typename?: 'role', name: string | null } | null> | null } | null }; +export type GetSystemUserQuery = { __typename?: 'Query', systemuser: { __typename?: 'systemuser', evo_job_titleid: string | null, businessunitid: string | null, systemuserid: string | null, roles: Array<{ __typename?: 'role', name: string | null } | null> | null } | null }; export type CoreAddProductTypesFieldsFragment = { __typename?: 'evo_addproduct_type', evo_graph_price: number | null, label: string | null, value: string | null }; @@ -526,13 +525,6 @@ export type GetQuoteGibddDataQueryVariables = Exact<{ export type GetQuoteGibddDataQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_db_accept_registration: number | null, evo_object_registration: number | null, evo_pts_type: number | null, evo_vehicle_tax_year: number | null, evo_vehicle_tax_approved: number | null, evo_category_tr: number | null, evo_vehicle_type_tax: number | null, evo_regionid: string | null, evo_townid: string | null, evo_legal_regionid: string | null, evo_legal_townid: string | null, evo_registration_regionid: string | null, evo_req_telematic: number | null, evo_req_telematic_accept: number | null } | null }; -export type GetQuoteRegionTownQueryVariables = Exact<{ - quoteId: Scalars['Uuid']; -}>; - - -export type GetQuoteRegionTownQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_regionid: string | null, evo_townid: string | null, evo_legal_regionid: string | null, evo_legal_townid: string | null } | null }; - export type GetQuoteInsuranceDataQueryVariables = Exact<{ quoteId: Scalars['Uuid']; }>; @@ -617,7 +609,7 @@ export const GetTarifsDocument = {"kind":"Document","definitions":[{"kind":"Oper 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"}},{"kind":"Field","name":{"kind":"Name","value":"evo_credit_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id"}}]}}]}}]} 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 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 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; @@ -636,15 +628,15 @@ export const GetModelDocument = {"kind":"Document","definitions":[{"kind":"Opera export const GetConfigurationsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetConfigurations"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"modelId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_equipments"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_modelid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"modelId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_equipmentid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_start_production_year"}}]}}]}}]} as unknown as DocumentNode; export const GetConfigurationDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetConfiguration"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"configurationId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_equipment"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_equipmentid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"configurationId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_impairment_groupidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_name"}}]}}]}}]}}]} as unknown as DocumentNode; export const GetDealersDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetDealers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"dealers"},"name":{"kind":"Name","value":"accounts"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_account_type"},"value":{"kind":"ListValue","values":[{"kind":"IntValue","value":"100000001"}]}},{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_legal_form"},"value":{"kind":"IntValue","value":"100000001"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"accountid"}},{"kind":"Field","name":{"kind":"Name","value":"accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_supplier_financing_accept"}}]}}]}}]} as unknown as DocumentNode; -export const GetDealerDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetDealer"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"dealerId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"dealer"},"name":{"kind":"Name","value":"account"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"accountid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"dealerId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_return_leasing_dealer"}},{"kind":"Field","name":{"kind":"Name","value":"evo_broker_accountid"}}]}}]}}]} as unknown as DocumentNode; +export const GetDealerDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetDealer"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"dealerId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"dealer"},"name":{"kind":"Name","value":"account"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"accountid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"dealerId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_return_leasing_dealer"}},{"kind":"Field","name":{"kind":"Name","value":"evo_broker_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_supplier_financing_accept"}}]}}]}}]} as unknown as DocumentNode; export const GetDealerPersonsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetDealerPersons"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"dealerId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"dealerPersons"},"name":{"kind":"Name","value":"salon_providers"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"salonaccountid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"dealerId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"accountid"}},{"kind":"Field","name":{"kind":"Name","value":"accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_inn"}},{"kind":"Field","name":{"kind":"Name","value":"evo_kpp"}},{"kind":"Field","name":{"kind":"Name","value":"evo_supplier_financing_accept"}}]}}]}}]} as unknown as DocumentNode; 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"}},{"kind":"Field","name":{"kind":"Name","value":"evo_supplier_financing_accept"}}]}}]}}]} 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"}},{"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_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"}},{"kind":"Field","name":{"kind":"Name","value":"roles"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}}]} 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"}}}],"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"}}}]}}],"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"}},{"kind":"Field","name":{"kind":"Name","value":"roles"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"systemuserid"}}]}}]}}]} 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"}},{"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; @@ -664,7 +656,6 @@ export const GetQuoteCreateKpDataDocument = {"kind":"Document","definitions":[{" export const GetQuoteFingapDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteFingapData"},"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_product_risks"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_typeid"}}]}}]}}]}}]} as unknown as DocumentNode; export const GetFinGapAddProductTypesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetFinGAPAddProductTypes"},"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":"100000006"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_typeid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","name":{"kind":"Name","value":"evo_type_calc_cerebellum"}},{"kind":"Field","name":{"kind":"Name","value":"evo_cost_service_provider_withoutnds"}},{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_typeid"}}]}}]}}]}}]} as unknown as DocumentNode; export const GetQuoteGibddDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteGibddData"},"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_db_accept_registration"}},{"kind":"Field","name":{"kind":"Name","value":"evo_object_registration"}},{"kind":"Field","name":{"kind":"Name","value":"evo_pts_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_tax_year"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_tax_approved"}},{"kind":"Field","name":{"kind":"Name","value":"evo_category_tr"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type_tax"}},{"kind":"Field","name":{"kind":"Name","value":"evo_regionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_townid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_legal_regionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_legal_townid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_registration_regionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_req_telematic"}},{"kind":"Field","name":{"kind":"Name","value":"evo_req_telematic_accept"}}]}}]}}]} as unknown as DocumentNode; -export const GetQuoteRegionTownDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteRegionTown"},"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_regionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_townid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_legal_regionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_legal_townid"}}]}}]}}]} as unknown as DocumentNode; export const GetQuoteInsuranceDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteInsuranceData"},"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_osago_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_osago_payer"}},{"kind":"Field","name":{"kind":"Name","value":"evo_osago_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_kasko_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_kasko_payer"}},{"kind":"Field","name":{"kind":"Name","value":"evo_kasko_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_insurance_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fingap_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fingap_payer"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fingap_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_gps_brandid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_gps_modelid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_insurance_decentral"}},{"kind":"Field","name":{"kind":"Name","value":"evo_franchise"}},{"kind":"Field","name":{"kind":"Name","value":"evo_unlimit_drivers"}},{"kind":"Field","name":{"kind":"Name","value":"evo_age_drivers"}},{"kind":"Field","name":{"kind":"Name","value":"evo_exp_drivers"}}]}}]}}]} as unknown as DocumentNode; export const GetLeadUrlDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLeadUrl"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"entity"},"name":{"kind":"Name","value":"lead"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"leadid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"link"}}]}}]}}]} as unknown as DocumentNode; export const GetOpportunityUrlDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetOpportunityUrl"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"entity"},"name":{"kind":"Name","value":"opportunity"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"opportunityid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"link"}}]}}]}}]} as unknown as DocumentNode; diff --git a/apps/web/process/add-product/reactions.ts b/apps/web/process/add-product/reactions.ts index 36a0d25..0356458 100644 --- a/apps/web/process/add-product/reactions.ts +++ b/apps/web/process/add-product/reactions.ts @@ -22,7 +22,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) { return; } - const currentDate = dayjs().utc(false).format('YYYY-MM-DD'); + const currentDate = dayjs().utc(false).toISOString(); const { data: { evo_addproduct_types }, @@ -79,7 +79,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) { reaction( () => $calculation.$values.getValues(['leasingPeriod', 'leaseObjectType']), async ({ leasingPeriod, leaseObjectType }) => { - const currentDate = dayjs().utc(false).format('YYYY-MM-DD'); + const currentDate = dayjs().utc(false).toISOString(); const { data: { evo_addproduct_types }, @@ -163,7 +163,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) { leasingPeriod, plPriceRub, }) => { - const currentDate = dayjs().utc(false).format('YYYY-MM-DD'); + const currentDate = dayjs().utc(false).toISOString(); const { data: { evo_addproduct_types }, @@ -175,14 +175,14 @@ export default function reactions({ store, apolloClient }: ProcessContext) { const options = evo_addproduct_types?.filter( (x) => x && - Boolean(x?.evo_max_period && x.evo_max_period >= leasingPeriod) && - Boolean(x?.evo_min_period && x.evo_min_period <= leasingPeriod) && + Boolean(x?.evo_max_period !== null && x.evo_max_period >= leasingPeriod) && + Boolean(x?.evo_min_period !== null && x.evo_min_period <= leasingPeriod) && Boolean( - x?.evo_max_price && + x?.evo_max_price !== null && x.evo_max_price >= plPriceRub - discountRub - importProgramSum + addEquipmentPrice ) && Boolean( - x?.evo_min_price && + x?.evo_min_price !== null && x.evo_min_price <= plPriceRub - discountRub - importProgramSum + addEquipmentPrice ) && x.evo_leasingobject_types?.find( @@ -191,9 +191,13 @@ export default function reactions({ store, apolloClient }: ProcessContext) { ) && x.evo_visible_calc && Boolean( - x.evo_min_first_payment_perc && x.evo_min_first_payment_perc <= firstPaymentPerc + x.evo_min_first_payment_perc !== null && + x.evo_min_first_payment_perc <= firstPaymentPerc ) && - Boolean(x.evo_max_first_payment_perc && x.evo_max_first_payment_perc >= firstPaymentPerc) + Boolean( + x.evo_max_first_payment_perc !== null && + x.evo_max_first_payment_perc >= firstPaymentPerc + ) ); $calculation.element('selectInsNSIB').setOptions(normalizeOptions(options)); @@ -242,7 +246,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) { reaction( () => $calculation.$values.getValues(['requirementTelematic', 'recalcWithRevision']), async ({ requirementTelematic, recalcWithRevision }) => { - const currentDate = dayjs().utc(false).format('YYYY-MM-DD'); + const currentDate = dayjs().utc(false).toISOString(); const { data: { evo_addproduct_types: trackerTypes }, } = await apolloClient.query({ diff --git a/apps/web/process/bonuses/lib/helper.ts b/apps/web/process/bonuses/lib/helper.ts index 4745e61..902cc99 100644 --- a/apps/web/process/bonuses/lib/helper.ts +++ b/apps/web/process/bonuses/lib/helper.ts @@ -25,7 +25,7 @@ export default function helper({ apolloClient, user }: ValidationContext) { return null; } - const currentDate = dayjs().utc(false).format('YYYY-MM-DD'); + const currentDate = dayjs().utc(false).toISOString(); const { data: { evo_coefficients }, @@ -39,6 +39,7 @@ export default function helper({ apolloClient, user }: ValidationContext) { return evo_coefficients?.find( (evo_coefficient) => + evo_coefficient?.evo_job_titleid === systemuser.evo_job_titleid && 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/bonuses/reactions/common.ts b/apps/web/process/bonuses/reactions/common.ts index ba9aacd..dae1f5e 100644 --- a/apps/web/process/bonuses/reactions/common.ts +++ b/apps/web/process/bonuses/reactions/common.ts @@ -26,7 +26,7 @@ export default function reactions(context: ProcessContext) { () => $calculation.element('selectProduct').getValue(), async (productId) => { if (!productId) { - $calculation.element('tbxSaleBonus').resetValue().block(); + $calculation.element('tbxSaleBonus').resetValue(); return; } @@ -34,19 +34,38 @@ export default function reactions(context: ProcessContext) { const coefficient = await getCoefficient(productId); if (!coefficient?.evo_sot_coefficient) { - $calculation.element('tbxSaleBonus').resetValue().block(); + $calculation.element('tbxSaleBonus').resetValue(); return; } const maxBonus = (coefficient?.evo_sot_coefficient || 0) * 100; - $calculation.element('tbxSaleBonus').setValue(maxBonus).unblock(); + $calculation.element('tbxSaleBonus').setValue(maxBonus); }, { fireImmediately: true, } ); + reaction( + () => $calculation.element('selectProduct').getValue(), + async (productId) => { + if (!productId) { + $calculation.element('tbxSaleBonus').block(); + + return; + } + + const coefficient = await getCoefficient(productId); + + if (coefficient?.evo_sot_coefficient) { + $calculation.element('tbxSaleBonus').unblock(); + } else { + $calculation.element('tbxSaleBonus').block(); + } + } + ); + /** * если в Продукте evo_cut_proportion_bonus_director " = Да, * то tbxBonusCoefficient = tbxSaleBonus/evo_sot_coefficient, diff --git a/apps/web/process/configurator/reactions/filters.ts b/apps/web/process/configurator/reactions/filters.ts index 3be7740..5b708d9 100644 --- a/apps/web/process/configurator/reactions/filters.ts +++ b/apps/web/process/configurator/reactions/filters.ts @@ -10,7 +10,7 @@ import { diff } from 'radash'; dayjs.extend(utc); -export default function reactions({ store, apolloClient }: ProcessContext) { +export default function reactions({ store, apolloClient, user }: ProcessContext) { const { $calculation } = store; reaction( @@ -302,8 +302,10 @@ export default function reactions({ store, apolloClient }: ProcessContext) { reaction( () => $calculation.element('selectProduct').getValue(), async (productId) => { + const IRRCalcTypeOptions = radioCalcType.filter((x) => x.value === 100_000_000); + if (!productId) { - $calculation.element('radioCalcType').resetOptions(); + $calculation.element('radioCalcType').setOptions(IRRCalcTypeOptions); return; } @@ -323,8 +325,11 @@ export default function reactions({ store, apolloClient }: ProcessContext) { ); $calculation.element('radioCalcType').setOptions(filteredCalcTypeOptions); } else { - $calculation.element('radioCalcType').resetOptions(); + $calculation.element('radioCalcType').setOptions(IRRCalcTypeOptions); } + }, + { + fireImmediately: true, } ); @@ -337,9 +342,9 @@ export default function reactions({ store, apolloClient }: ProcessContext) { reaction( () => $calculation.element('selectQuote').getValue(), async (quoteId) => { - const currentDate = dayjs().utc(false).format('YYYY-MM-DD'); + const currentDate = dayjs().utc(false).toISOString(); - const { + let { data: { evo_baseproducts }, } = await apolloClient.query({ fetchPolicy: 'network-only', @@ -349,6 +354,28 @@ export default function reactions({ store, apolloClient }: ProcessContext) { }, }); + if (user && evo_baseproducts) { + const { + data: { systemuser }, + } = await apolloClient.query({ + fetchPolicy: 'network-only', + query: CRMTypes.GetSystemUserDocument, + variables: { + domainname: user?.domainName, + }, + }); + + evo_baseproducts = evo_baseproducts?.filter( + (x) => + !x?.systemusers?.length || + x?.systemusers?.some( + (evo_baseproduct_systemuser) => + systemuser?.systemuserid && + evo_baseproduct_systemuser?.systemuserid === systemuser?.systemuserid + ) + ); + } + if (!$calculation.element('cbxRecalcWithRevision').getValue()) { $calculation.element('selectProduct').setOptions(normalizeOptions(evo_baseproducts)); @@ -392,6 +419,9 @@ export default function reactions({ store, apolloClient }: ProcessContext) { } else { $calculation.element('selectProduct').setOptions(normalizeOptions(evo_baseproducts)); } + }, + { + fireImmediately: true, } ); } diff --git a/apps/web/process/configurator/reactions/values.ts b/apps/web/process/configurator/reactions/values.ts index 171891d..a4a7888 100644 --- a/apps/web/process/configurator/reactions/values.ts +++ b/apps/web/process/configurator/reactions/values.ts @@ -33,7 +33,7 @@ export default function valuesReactions({ store, apolloClient }: ProcessContext) lastPaymentPerc, leaseObjectType: leaseObjectTypeId, }) => { - const currentDate = dayjs().utc(false).format('YYYY-MM-DD'); + const currentDate = dayjs().utc(false).toISOString(); let { data: { evo_tarifs = [] }, @@ -137,7 +137,7 @@ export default function valuesReactions({ store, apolloClient }: ProcessContext) return; } - const currentDate = dayjs().utc(false).format('YYYY-MM-DD'); + const currentDate = dayjs().utc(false).toISOString(); const { data: { evo_rates }, diff --git a/apps/web/process/create-kp/reactions.ts b/apps/web/process/create-kp/reactions.ts index 174a8b1..42e8390 100644 --- a/apps/web/process/create-kp/reactions.ts +++ b/apps/web/process/create-kp/reactions.ts @@ -14,4 +14,22 @@ export function common({ store }: ProcessContext) { } } ); + + reaction( + () => $calculation.element('cbxPriceWithDiscount').getValue(), + (priceWithDiscount) => { + if (priceWithDiscount === true) { + $calculation.element('cbxFullPriceWithDiscount').setValue(false); + } + } + ); + + reaction( + () => $calculation.element('cbxFullPriceWithDiscount').getValue(), + (fullPriceWithDiscount) => { + if (fullPriceWithDiscount === true) { + $calculation.element('cbxPriceWithDiscount').setValue(false); + } + } + ); } diff --git a/apps/web/process/fingap/reactions/common.ts b/apps/web/process/fingap/reactions/common.ts index 1b18a00..adf1d65 100644 --- a/apps/web/process/fingap/reactions/common.ts +++ b/apps/web/process/fingap/reactions/common.ts @@ -148,7 +148,7 @@ export default function reactions({ store, apolloClient, queryClient }: ProcessC >({ query: QUERY_GET_FINGAP_ADDPRODUCT_TYPES, variables: { - currentDate: dayjs().utc(false).format('YYYY-MM-DD'), + currentDate: dayjs().utc(false).toISOString(), }, }); diff --git a/apps/web/process/gibdd/get-kp-data.ts b/apps/web/process/gibdd/get-kp-data.ts index cef7390..5a5a59a 100644 --- a/apps/web/process/gibdd/get-kp-data.ts +++ b/apps/web/process/gibdd/get-kp-data.ts @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/cognitive-complexity */ import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types'; import helper from './lib/helper'; import initializeApollo from '@/apollo/client'; @@ -5,6 +6,7 @@ import defaultValues from '@/config/default-values'; import * as CRMTypes from '@/graphql/crm.types'; import { gql } from '@apollo/client'; +// eslint-disable-next-line @typescript-eslint/no-unused-vars const QUERY_GET_QUOTE_GIBDD_DATA = gql` query GetQuoteGibddData($quoteId: Uuid!) { quote(quoteId: $quoteId) { @@ -40,52 +42,57 @@ export async function getKPData({ values }: GetQuoteInputData): Promise) { + async function getRegionByFias(evo_region_fias_id: string) { + const { + data: { evo_regions }, + } = await apolloClient.query({ + query: CRMTypes.GetRegionsDocument, + }); + + return evo_regions?.find((x) => x?.evo_fias_id === evo_region_fias_id); + } + + async function getTownByFias(regionId: string, evo_town_fias_id: string) { + const { + data: { evo_towns }, + } = await apolloClient.query({ + query: CRMTypes.GetTownsDocument, + variables: { + regionId, + }, + }); + + return evo_towns?.find((x) => x?.evo_fias_id === evo_town_fias_id); + } + return { - async getLegalRegion({ + async getData({ lead: leadid, opportunity: opportunityid, - quote: quoteId, - }: Pick) { - let regionId: string | null | undefined; - - const { - data: { evo_regions }, - } = await apolloClient.query({ - query: CRMTypes.GetRegionsDocument, - }); + }: Pick) { + let lead: CRMTypes.GetLeadQuery['lead'] = null; + let opportunity: CRMTypes.GetOpportunityQuery['opportunity'] = null; if (leadid) { - const { - data: { lead }, - } = await apolloClient.query({ + const { data } = await apolloClient.query({ query: CRMTypes.GetLeadDocument, variables: { leadid }, }); - if (lead?.accountidData?.evo_address_legalidData?.evo_region_fias_id) { - const region = evo_regions?.find( - (x) => - x?.evo_fias_id === lead?.accountidData?.evo_address_legalidData?.evo_region_fias_id - ); - regionId = region?.value; - } + ({ lead } = data); } if (opportunityid) { - const { - data: { opportunity }, - } = await apolloClient.query({ + const { data } = await apolloClient.query({ query: CRMTypes.GetOpportunityDocument, variables: { opportunityid }, }); - if (!regionId && opportunity?.accountidData?.evo_address_legalidData?.evo_region_fias_id) { - const region = evo_regions?.find( - (x) => - x?.evo_fias_id === - opportunity?.accountidData?.evo_address_legalidData?.evo_region_fias_id - ); - regionId = region?.value; - } + ({ opportunity } = data); } - if (!regionId && quoteId) { - const { - data: { quote }, - } = await apolloClient.query< - CRMTypes.GetQuoteRegionTownQuery, - CRMTypes.GetQuoteRegionTownQueryVariables - >({ - query: QUERY_GET_QUOTE_REGION_TOWN, - variables: { quoteId }, - }); - regionId = quote?.evo_legal_regionid; + // region + let region: Awaited> = null; + const evo_region_fias_id = + lead?.accountidData?.evo_address_legalidData?.evo_region_fias_id || + opportunity?.accountidData?.evo_address_legalidData?.evo_region_fias_id; + + if (evo_region_fias_id) { + region = await getRegionByFias(evo_region_fias_id); } - return regionId; - }, + // town + let town: Awaited> = null; + const evo_city_fias_id = + lead?.accountidData?.evo_address_legalidData?.evo_city_fias_id || + opportunity?.accountidData?.evo_address_legalidData?.evo_city_fias_id; - async getLegalTown({ - lead: leadid, - opportunity: opportunityid, - quote: quoteId, - regionId, - }: Pick & { - regionId: string | null | undefined; - }) { - if (!regionId) { - return null; + if (region?.value && evo_city_fias_id) { + town = await getTownByFias(region?.value, evo_city_fias_id); } - let townId: string | null | undefined; - - const { - data: { evo_towns }, - } = await apolloClient.query({ - query: CRMTypes.GetTownsDocument, - variables: { regionId }, - }); - - if (leadid) { - const { - data: { lead }, - } = await apolloClient.query({ - query: CRMTypes.GetLeadDocument, - variables: { leadid }, - }); - if (lead?.accountidData?.evo_address_legalidData?.evo_city_fias_id) { - const town = evo_towns?.find( - (x) => x?.evo_fias_id === lead?.accountidData?.evo_address_legalidData?.evo_city_fias_id - ); - townId = town?.value; - } - } - - if (opportunityid) { - const { - data: { opportunity }, - } = await apolloClient.query({ - query: CRMTypes.GetOpportunityDocument, - variables: { opportunityid }, - }); - - if (!townId && opportunity?.accountidData?.evo_address_legalidData?.evo_city_fias_id) { - const town = evo_towns?.find( - (x) => - x?.evo_fias_id === - opportunity?.accountidData?.evo_address_legalidData?.evo_city_fias_id - ); - townId = town?.value; - } - } - - if (!townId && quoteId) { - const { - data: { quote }, - } = await apolloClient.query< - CRMTypes.GetQuoteRegionTownQuery, - CRMTypes.GetQuoteRegionTownQueryVariables - >({ - query: QUERY_GET_QUOTE_REGION_TOWN, - variables: { quoteId }, - }); - townId = quote?.evo_legal_townid; - } - - return townId; - }, - - async getRegion({ - lead: leadid, - opportunity: opportunityid, - quote: quoteId, - }: Pick) { - let regionId: string | null | undefined; - - const { - data: { evo_regions }, - } = await apolloClient.query({ - query: CRMTypes.GetRegionsDocument, - }); - - if (leadid) { - const { - data: { lead }, - } = await apolloClient.query({ - query: CRMTypes.GetLeadDocument, - variables: { leadid }, - }); - if (lead?.accountidData?.evo_address_legalidData?.evo_region_fias_id) { - const region = evo_regions?.find( - (x) => - x?.evo_fias_id === lead?.accountidData?.evo_address_legalidData?.evo_region_fias_id - ); - regionId = region?.value; - } - } - - if (opportunityid) { - const { - data: { opportunity }, - } = await apolloClient.query({ - query: CRMTypes.GetOpportunityDocument, - variables: { opportunityid }, - }); - - if (!regionId && opportunity?.accountidData?.evo_address_legalidData?.evo_region_fias_id) { - const region = evo_regions?.find( - (x) => - x?.evo_fias_id === - opportunity?.accountidData?.evo_address_legalidData?.evo_region_fias_id - ); - regionId = region?.value; - } - } - - if (!regionId && quoteId) { - const { - data: { quote }, - } = await apolloClient.query< - CRMTypes.GetQuoteRegionTownQuery, - CRMTypes.GetQuoteRegionTownQueryVariables - >({ - query: QUERY_GET_QUOTE_REGION_TOWN, - variables: { quoteId }, - }); - regionId = quote?.evo_regionid; - } - - return regionId; - }, - - async getTown({ - lead: leadid, - opportunity: opportunityid, - quote: quoteId, - regionId, - }: Pick & { - regionId: string | null | undefined; - }) { - if (!regionId) { - return null; - } - - let townId: string | null | undefined; - - const { - data: { evo_towns }, - } = await apolloClient.query({ - query: CRMTypes.GetTownsDocument, - variables: { regionId }, - }); - - if (leadid) { - const { - data: { lead }, - } = await apolloClient.query({ - query: CRMTypes.GetLeadDocument, - variables: { leadid }, - }); - if (lead?.accountidData?.evo_address_legalidData?.evo_city_fias_id) { - const town = evo_towns?.find( - (x) => x?.evo_fias_id === lead?.accountidData?.evo_address_legalidData?.evo_city_fias_id - ); - townId = town?.value; - } - } - - if (opportunityid) { - const { - data: { opportunity }, - } = await apolloClient.query({ - query: CRMTypes.GetOpportunityDocument, - variables: { opportunityid }, - }); - - if (!townId && opportunity?.accountidData?.evo_address_legalidData?.evo_city_fias_id) { - const town = evo_towns?.find( - (x) => - x?.evo_fias_id === - opportunity?.accountidData?.evo_address_legalidData?.evo_city_fias_id - ); - townId = town?.value; - } - } - - if (quoteId) { - const { - data: { quote }, - } = await apolloClient.query< - CRMTypes.GetQuoteRegionTownQuery, - CRMTypes.GetQuoteRegionTownQueryVariables - >({ - query: QUERY_GET_QUOTE_REGION_TOWN, - variables: { quoteId }, - }); - if (!townId && quote?.evo_townid) { - townId = quote?.evo_townid; - } - } - - return townId; + return { + account: { + evo_legal_regionid: region?.value, + evo_legal_townid: town?.value, + evo_regionid: region?.value, + evo_townid: town?.value, + }, + }; }, }; } diff --git a/apps/web/process/gibdd/reactions.ts b/apps/web/process/gibdd/reactions.ts index c65bdf6..8d574d2 100644 --- a/apps/web/process/gibdd/reactions.ts +++ b/apps/web/process/gibdd/reactions.ts @@ -202,7 +202,7 @@ export function common({ store, apolloClient, queryClient }: ProcessContext) { }, context ); - const { tax, error } = await queryClient.fetchQuery( + const { tax } = await queryClient.fetchQuery( ['1c', 'trans-tax', carCategory, leaseObjectMotorPower, leaseObjectYear], request, { @@ -210,7 +210,7 @@ export function common({ store, apolloClient, queryClient }: ProcessContext) { } ); - if (!error && tax) { + if (tax) { $calculation.element('tbxVehicleTaxInYear').setValue(tax); } else { $calculation.element('tbxVehicleTaxInYear').resetValue(); @@ -241,7 +241,7 @@ export function common({ store, apolloClient, queryClient }: ProcessContext) { leaseObjectType, // eslint-disable-next-line sonarjs/cognitive-complexity }) => { - const currentDate = dayjs().utc(false).format('YYYY-MM-DD'); + const currentDate = dayjs().utc(false).toISOString(); let evo_region: CRMTypes.GetRegionQuery['evo_region']; if (objectRegionRegistrationId) { @@ -377,117 +377,52 @@ export function common({ store, apolloClient, queryClient }: ProcessContext) { } ); - const { getLegalRegion, getLegalTown, getRegion, getTown } = helper({ apolloClient }); + const { getData } = helper({ apolloClient }); reaction( () => $calculation.$values.getValues(['lead', 'opportunity']), async ({ lead, opportunity }) => { - if (!lead && !opportunity) { - $calculation.element('selectLegalClientRegion').resetValue().unblock(); - $calculation.element('selectRegionRegistration').resetValue().unblock(); + const { account } = await getData({ lead, opportunity }); - return; - } - - const quote = $calculation.element('selectQuote').getValue(); - - const legalRegionId = await getLegalRegion({ - lead, - opportunity, - quote, - }); - if (legalRegionId) { - $calculation.element('selectLegalClientRegion').setValue(legalRegionId).block(); + if (account.evo_legal_regionid) { + $calculation + .element('selectLegalClientRegion') + .setValue(account.evo_legal_regionid) + .block(); } else { $calculation.element('selectLegalClientRegion').resetValue().unblock(); } - const regionId = await getRegion({ - lead, - opportunity, - quote, - }); - if (regionId) { - $calculation.element('selectRegionRegistration').setValue(regionId).block(); + if (account.evo_legal_townid) { + $calculation.element('selectLegalClientTown').setValue(account.evo_legal_townid).block(); } else { - $calculation.element('selectRegionRegistration').resetValue().unblock(); + $calculation.element('selectLegalClientTown').resetValue().unblock(); } }, { - delay: 10, + delay: 50, } ); reaction( - () => $calculation.element('selectLegalClientRegion').getValue(), - async (regionId) => { - if (!regionId) { - $calculation.element('selectLegalClientTown').resetValue().unblock(); + () => $calculation.$values.getValues(['lead', 'opportunity', 'objectRegistration']), + async ({ lead, objectRegistration, opportunity }) => { + const { account } = await getData({ lead, opportunity }); - return; - } - - const lead = $calculation.element('selectLead').getValue(); - const opportunity = $calculation.element('selectOpportunity').getValue(); - const quote = $calculation.element('selectQuote').getValue(); - - const townId = await getLegalTown({ - lead, - opportunity, - quote, - regionId, - }); - if (townId) { - $calculation.element('selectLegalClientTown').setValue(townId).block(); + if (objectRegistration === 100_000_000 && account.evo_regionid) { + $calculation.element('selectRegionRegistration').setValue(account.evo_regionid).block(); } else { - $calculation.element('selectLegalClientTown').resetValue().unblock(); - } - } - ); - - reaction( - () => $calculation.$values.getValues(['regionRegistration', 'objectRegistration']), - async ({ regionRegistration: regionId, objectRegistration }) => { - if (!regionId) { - $calculation.element('selectTownRegistration').resetValue().unblock(); - - return; + $calculation.element('selectRegionRegistration').unblock(); } - const lead = $calculation.element('selectLead').getValue(); - const opportunity = $calculation.element('selectOpportunity').getValue(); - const quote = $calculation.element('selectQuote').getValue(); - - const townId = await getTown({ - lead, - opportunity, - quote, - regionId, - }); - - if (townId && objectRegistration === 100_000_000) { - $calculation.element('selectTownRegistration').setValue(townId).block(); + if (objectRegistration === 100_000_000 && account.evo_townid) { + $calculation.element('selectTownRegistration').setValue(account.evo_townid).block(); } else { - $calculation.element('selectTownRegistration').resetValue().unblock(); - } - } - ); - - reaction( - () => $calculation.element('radioObjectRegistration').getValue(), - async (objectRegistration) => { - const { - data: { evo_regions }, - } = await apolloClient.query({ - query: CRMTypes.GetRegionsDocument, - }); - - if (objectRegistration === 100_000_001) { - const regions = evo_regions?.filter((x) => x?.evo_businessunit_evolution === true); - $calculation.element('selectRegionRegistration').setOptions(normalizeOptions(regions)); - } else { - $calculation.element('selectRegionRegistration').setOptions(normalizeOptions(evo_regions)); + $calculation.element('selectTownRegistration').unblock(); } + }, + { + delay: 50, } ); diff --git a/apps/web/process/gibdd/validation.ts b/apps/web/process/gibdd/validation.ts index d7681df..1f167be 100644 --- a/apps/web/process/gibdd/validation.ts +++ b/apps/web/process/gibdd/validation.ts @@ -117,7 +117,7 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { } } - if (objectRegistration === 100_000_000 && !townRegistration) + if (!townRegistration) ctx.addIssue({ code: z.ZodIssueCode.custom, message: 'Не заполнено поле', diff --git a/apps/web/process/hooks/init/get-main-data.js b/apps/web/process/hooks/init/get-main-data.js index 376ae7d..126a289 100644 --- a/apps/web/process/hooks/init/get-main-data.js +++ b/apps/web/process/hooks/init/get-main-data.js @@ -9,7 +9,7 @@ import { useEffect } from 'react'; dayjs.extend(utc); -const currentDate = dayjs().utc(false).format('YYYY-MM-DD'); +const currentDate = dayjs().utc(false).toISOString(); /** * @@ -19,9 +19,6 @@ const currentDate = dayjs().utc(false).format('YYYY-MM-DD'); function getMainData({ query }, onCompleted) { query({ query: CRMTypes.GetLeaseObjectTypesDocument, - variables: { - currentDate, - }, }).then(({ data }) => { onCompleted({ selectLeaseObjectType: data?.evo_leasingobject_types, diff --git a/apps/web/process/insurance/reactions.ts b/apps/web/process/insurance/reactions.ts index d1afbde..1d4a2ea 100644 --- a/apps/web/process/insurance/reactions.ts +++ b/apps/web/process/insurance/reactions.ts @@ -5,11 +5,11 @@ import { createValidationSchema } from './validation'; import { selectLeaseObjectUseFor } from '@/config/default-options'; import * as CRMTypes from '@/graphql/crm.types'; import { normalizeOptions } from '@/utils/entity'; -import { debouncedReaction } from '@/utils/mobx'; +import { debouncedReaction, disposableReaction } from '@/utils/mobx'; import { reaction } from 'mobx'; export function common({ store, apolloClient }: ProcessContext) { - const { $calculation, $tables } = store; + const { $calculation, $tables, $process } = store; reaction( () => $calculation.element('selectGPSBrand').getValue(), @@ -146,6 +146,7 @@ export function common({ store, apolloClient }: ProcessContext) { $tables.insurance .row('kasko') .setOptions('insuranceCompany', normalizeOptions(defaultKaskoOptions)) + .unblock('insuranceCompany') .unblock('insCost'); if (leasingPeriod < 12) { @@ -229,7 +230,8 @@ export function common({ store, apolloClient }: ProcessContext) { } ); - reaction( + disposableReaction( + () => $process.has('LoadKP'), () => $calculation.element('selectBrand').getValue(), async (brandId) => { if (!brandId) { diff --git a/apps/web/process/insurance/validation.ts b/apps/web/process/insurance/validation.ts index a2fabb4..32442f2 100644 --- a/apps/web/process/insurance/validation.ts +++ b/apps/web/process/insurance/validation.ts @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/cognitive-complexity */ /* eslint-disable zod/require-strict */ import type { ValidationContext } from '../types'; import type * as Insurance from '@/Components/Calculation/Form/Insurance/InsuranceTable/types'; @@ -8,6 +9,7 @@ import { z } from 'zod'; export function createValidationSchema({ apolloClient }: ValidationContext) { return ValuesSchema.pick({ + brand: true, insDecentral: true, leasingPeriod: true, leasingWithoutKasko: true, @@ -27,6 +29,7 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { leasingWithoutKasko, insDecentral, insurance, + brand: brandId, }, ctx ) => { @@ -63,7 +66,7 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { }); } - if (insCost > 0 && !insuranceCompany) { + if (!insuranceCompany) { ctx.addIssue({ code: z.ZodIssueCode.custom, message: `Укажите страховую компанию ${policyType}`, @@ -71,7 +74,7 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { }); } - if (insCost > 0 && !insTerm) { + if (!insTerm) { ctx.addIssue({ code: z.ZodIssueCode.custom, message: `Укажите срок страхования ${policyType}`, @@ -79,7 +82,7 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { }); } - if (insCost > 0 && !insured) { + if (!insured) { ctx.addIssue({ code: z.ZodIssueCode.custom, message: `Укажите плательщика ${policyType}`, @@ -110,6 +113,41 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { }); } } + + if (brandId) { + const { + data: { evo_brand }, + } = await apolloClient.query({ + query: CRMTypes.GetBrandDocument, + variables: { brandId }, + }); + + const { + data: { accounts }, + } = await apolloClient.query({ + query: CRMTypes.GetInsuranceCompaniesDocument, + }); + + const defaultKaskoOptions = accounts?.filter((x) => + x?.evo_type_ins_policy?.includes(100_000_000) + ); + + if (evo_brand?.evo_id === 'BRAND49') { + const renessansCompany = defaultKaskoOptions?.find((x) => x?.evo_inn === '7725497022'); + + if ( + renessansCompany && + insurance.values.kasko.insuranceCompany !== renessansCompany.value + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: + 'Для Harley-Davidson СК для КАСКО может быть только ' + renessansCompany.label, + path: ['insurance'], + }); + } + } + } } ); } diff --git a/apps/web/process/leasing-object/validation.ts b/apps/web/process/leasing-object/validation.ts index 28430c4..c6abbb3 100644 --- a/apps/web/process/leasing-object/validation.ts +++ b/apps/web/process/leasing-object/validation.ts @@ -1,3 +1,5 @@ +/* eslint-disable sonarjs/cognitive-complexity */ +/* eslint-disable complexity */ import type { ValidationContext } from '../types'; import ValuesSchema from '@/config/schema/values'; import * as CRMTypes from '@/graphql/crm.types'; @@ -5,13 +7,16 @@ import { z } from 'zod'; export function createValidationSchema({ apolloClient }: ValidationContext) { return ValuesSchema.pick({ + brand: true, countSeats: true, engineType: true, engineVolume: true, leaseObjectCategory: true, leaseObjectMotorPower: true, leaseObjectType: true, + leaseObjectUseFor: true, maxMass: true, + model: true, }).superRefine( async ( { @@ -22,9 +27,44 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { countSeats, maxMass, leaseObjectCategory, + brand, + model, + leaseObjectUseFor, }, ctx ) => { + if (!leaseObjectTypeId) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Не заполнено поле', + path: ['selectLeaseObjectType'], + }); + } + + if (!brand) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Не заполнено поле', + path: ['selectBrand'], + }); + } + + if (!model) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Не заполнено поле', + path: ['selectModel'], + }); + } + + if (!leaseObjectUseFor) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Не заполнено поле', + path: ['selectLeaseObjectUseFor'], + }); + } + if (leaseObjectTypeId) { const { data: { evo_leasingobject_type }, diff --git a/apps/web/process/leasing-without-kasko/reactions.ts b/apps/web/process/leasing-without-kasko/reactions.ts index d4039dc..240d773 100644 --- a/apps/web/process/leasing-without-kasko/reactions.ts +++ b/apps/web/process/leasing-without-kasko/reactions.ts @@ -66,7 +66,7 @@ export function common({ store, apolloClient }: ProcessContext) { firstPaymentPerc, model: modelId, }) => { - const currentDate = dayjs().utc(false).format('YYYY-MM-DD'); + const currentDate = dayjs().utc(false).toISOString(); const { data: { evo_addproduct_types }, diff --git a/apps/web/process/load-kp/reactions.ts b/apps/web/process/load-kp/reactions.ts index ae02c0f..77cae89 100644 --- a/apps/web/process/load-kp/reactions.ts +++ b/apps/web/process/load-kp/reactions.ts @@ -72,7 +72,9 @@ export function common({ store, trpcClient }: ProcessContext) { $calculation.element('selectQuote').resetValue(); }) .finally(() => { - $process.delete('LoadKP'); + setTimeout(() => { + $process.delete('LoadKP'); + }, 100); }); } ); diff --git a/apps/web/process/price/validation.ts b/apps/web/process/price/validation.ts index a924ba2..ef49ba5 100644 --- a/apps/web/process/price/validation.ts +++ b/apps/web/process/price/validation.ts @@ -8,7 +8,9 @@ import { z } from 'zod'; export function createValidationSchema({ apolloClient }: ValidationContext) { return ValuesSchema.pick({ VATInLeaseObjectPrice: true, + balanceHolder: true, firstPaymentRub: true, + lastPaymentPerc: true, leaseObjectPriceWthtVAT: true, plPriceRub: true, product: true, @@ -24,6 +26,8 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { plPriceRub, firstPaymentRub, subsidySum, + balanceHolder, + lastPaymentPerc, }, ctx ) => { @@ -74,6 +78,23 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { path: ['tbxFirstPaymentRub'], }); } + + if (balanceHolder === 100_000_001) { + if (lastPaymentPerc < 1) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: + 'При балансе лизингодатель последний платеж не может быть меньше 1%! Увеличьте значение.', + path: ['tbxLastPaymentPerc'], + }); + } + } else if (lastPaymentPerc === 0) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Последний платеж не может быть равен 0. Увеличьте значение', + path: ['tbxLastPaymentPerc'], + }); + } } ); } diff --git a/apps/web/process/recalc/validation.ts b/apps/web/process/recalc/validation.ts index b9148ac..112bc24 100644 --- a/apps/web/process/recalc/validation.ts +++ b/apps/web/process/recalc/validation.ts @@ -9,7 +9,6 @@ import { z } from 'zod'; export function createValidationSchema({ apolloClient }: ValidationContext) { return ValuesSchema.pick({ addEquipmentPrice: true, - balanceHolder: true, countSeats: true, dealerPerson: true, discountRub: true, @@ -45,7 +44,6 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { countSeats, leaseObjectYear, lastPaymentPerc, - balanceHolder, leaseObjectCategory, }, ctx @@ -87,54 +85,39 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { const maxCondition1 = leaseObjectUsed === false && dealerPerson?.evo_supplier_type !== 100_000_001 && + quote?.evo_max_price_change && !evo_baseproduct?.evo_sale_without_nds && - Boolean( - quote?.evo_max_price_change && - plPriceRub - discountRub + addEquipmentPrice - importProgramSum > - quote.evo_max_price_change - ); + plPriceRub - discountRub + addEquipmentPrice - importProgramSum > + quote.evo_max_price_change; const maxCondition2 = leaseObjectUsed === false && dealerPerson?.evo_supplier_type !== 100_000_001 && - Boolean(evo_baseproduct?.evo_sale_without_nds) && - Boolean( - quote?.evo_nds_in_price_supplier_currency && - quote?.evo_max_price_change && - leaseObjectPriceWthtVAT > - quote.evo_max_price_change - quote.evo_nds_in_price_supplier_currency - ); + quote?.evo_max_price_change && + evo_baseproduct?.evo_sale_without_nds && + leaseObjectPriceWthtVAT > + quote.evo_max_price_change - (quote.evo_nds_in_price_supplier_currency || 0); const maxCondition3 = (leaseObjectUsed === true || dealerPerson?.evo_supplier_type === 100_000_001) && - Boolean( - quote?.evo_supplier_currency_price && - quote.evo_discount_supplier_currency && - quote.evo_equip_price && - quote.evo_program_import_subsidy_sum && - plPriceRub - discountRub + addEquipmentPrice - importProgramSum > - quote?.evo_supplier_currency_price - - quote.evo_discount_supplier_currency + - quote.evo_equip_price - - quote.evo_program_import_subsidy_sum - ); + quote?.evo_supplier_currency_price && + plPriceRub - discountRub + addEquipmentPrice - importProgramSum > + quote.evo_supplier_currency_price - + (quote.evo_discount_supplier_currency || 0) + + (quote.evo_equip_price || 0) - + (quote.evo_program_import_subsidy_sum || 0); const minCondition1 = !evo_baseproduct?.evo_sale_without_nds && - Boolean( - quote?.evo_min_change_price && - plPriceRub - discountRub + addEquipmentPrice - importProgramSum < - quote.evo_min_change_price - ); + quote?.evo_min_change_price && + plPriceRub - discountRub + addEquipmentPrice - importProgramSum < + quote.evo_min_change_price; const minCondition2 = - Boolean(evo_baseproduct?.evo_sale_without_nds) && - Boolean( - quote?.evo_nds_in_price_supplier_currency && - quote?.evo_min_change_price && - leaseObjectPriceWthtVAT < - quote.evo_min_change_price - quote.evo_nds_in_price_supplier_currency - ); + evo_baseproduct?.evo_sale_without_nds && + quote?.evo_min_change_price && + leaseObjectPriceWthtVAT < + quote.evo_min_change_price - (quote.evo_nds_in_price_supplier_currency || 0); if (maxCondition1 || maxCondition2) { ctx.addIssue({ @@ -236,23 +219,6 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { path: ['tbxLastPaymentPerc'], }); } - - if (balanceHolder === 100_000_001) { - if (lastPaymentPerc < 1) { - ctx.addIssue({ - code: z.ZodIssueCode.custom, - message: - 'При балансе лизингодатель последний платеж не может быть меньше 1%! Увеличьте значение.', - path: ['tbxLastPaymentPerc'], - }); - } - } else if (lastPaymentPerc === 0) { - ctx.addIssue({ - code: z.ZodIssueCode.custom, - message: 'Последний платеж не может быть равен 0. Увеличьте значение', - path: ['tbxLastPaymentPerc'], - }); - } } } ); diff --git a/apps/web/process/supplier-agent/lib/create-reactions.ts b/apps/web/process/supplier-agent/lib/create-reactions.ts index 26eccd5..e5dc8fe 100644 --- a/apps/web/process/supplier-agent/lib/create-reactions.ts +++ b/apps/web/process/supplier-agent/lib/create-reactions.ts @@ -35,7 +35,7 @@ export function fillAgentRewardReaction( query: CRMTypes.GetRewardConditionsDocument, variables: { agentid, - currentDate: dayjs().utc(false).format('YYYY-MM-DD'), + currentDate: dayjs().utc(false).toISOString(), }, }); diff --git a/apps/web/process/supplier-agent/reactions/supplier.ts b/apps/web/process/supplier-agent/reactions/supplier.ts index b639cfe..862924a 100644 --- a/apps/web/process/supplier-agent/reactions/supplier.ts +++ b/apps/web/process/supplier-agent/reactions/supplier.ts @@ -61,9 +61,8 @@ export function common({ store, apolloClient }: ProcessContext) { ); const value = dealerPersons.at(0)?.value; - if (!$process.has('LoadKP') && value) { + if (!$process.has('LoadKP') && value && !dealer?.evo_supplier_financing_accept) $calculation.element('selectDealerPerson').setValue(value); - } } else { $calculation.element('selectDealerPerson').reset(); } @@ -158,10 +157,9 @@ export function common({ store, apolloClient }: ProcessContext) { ); reaction( - () => $calculation.$values.getValues(['product', 'dealerPerson']), - async ({ product: productId, dealerPerson: dealerPersonId }) => { + () => $calculation.$values.getValues(['product']), + async ({ product: productId }) => { let evo_baseproduct: CRMTypes.GetProductQuery['evo_baseproduct'] = null; - let dealerPerson: CRMTypes.GetDealerPersonQuery['account'] = null; if (productId) { const { data } = await apolloClient.query({ @@ -172,23 +170,9 @@ export function common({ store, apolloClient }: ProcessContext) { ({ evo_baseproduct } = data); } - if (dealerPersonId) { - const { data } = await apolloClient.query({ - query: CRMTypes.GetDealerPersonDocument, - variables: { dealerPersonId }, - }); - - ({ account: dealerPerson } = data); - } - - if ( - evo_baseproduct?.evo_supplier_financing_accept && - dealerPerson?.evo_supplier_financing_accept - ) { - $calculation.element('cbxSupplierFinancing').unblock(); - } else { - $calculation.element('cbxSupplierFinancing').setValue(false).block(); - } + $calculation + .element('cbxSupplierFinancing') + .setValue(Boolean(evo_baseproduct?.evo_supplier_financing_accept)); } ); } diff --git a/apps/web/process/supplier-agent/validation.ts b/apps/web/process/supplier-agent/validation.ts index f27389e..08c6123 100644 --- a/apps/web/process/supplier-agent/validation.ts +++ b/apps/web/process/supplier-agent/validation.ts @@ -32,7 +32,7 @@ function helper({ apolloClient, ctx }: ValidationContext & { ctx: RefinementCtx query: CRMTypes.GetRewardConditionsDocument, variables: { agentid, - currentDate: dayjs().utc(false).format('YYYY-MM-DD'), + currentDate: dayjs().utc(false).toISOString(), }, }); @@ -369,6 +369,12 @@ export function createValidationSchema(context: ValidationContext) { message: 'Не заполнено поле', path: ['selectDealerPerson'], }); + } else { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Не заполнено поле', + path: ['selectDealer'], + }); } const { validateRewardSum, validateRewardWithoutOtherAgent } = helper({ ...context, ctx }); diff --git a/apps/web/process/tools.ts b/apps/web/process/tools.ts index 208efb7..b4678fc 100644 --- a/apps/web/process/tools.ts +++ b/apps/web/process/tools.ts @@ -52,7 +52,7 @@ export function createValidationReaction( if (validationResult.success === false) { validationResult.error.errors.forEach(({ path, message }) => { - (path as Array).forEach((elementName) => { + (path as Array).forEach((elementName) => { if (elementName === 'insurance') { const removeError = $tables.insurance.setError({ key, message }); if (removeError) helper.add(removeError); diff --git a/apps/web/process/used-pl/reactions.ts b/apps/web/process/used-pl/reactions.ts index d1067fa..4224db4 100644 --- a/apps/web/process/used-pl/reactions.ts +++ b/apps/web/process/used-pl/reactions.ts @@ -156,6 +156,9 @@ export function common({ store, apolloClient }: ProcessContext) { } else { $calculation.element('tbxMileage').resetValue().block(); } + }, + { + fireImmediately: true, } ); @@ -247,13 +250,13 @@ export function common({ store, apolloClient }: ProcessContext) { reaction( () => $calculation.$values.getValues(['subsidy', 'supplierFinancing']), ({ subsidy: subsidyId, supplierFinancing }) => { - if (subsidyId || supplierFinancing) { + if (subsidyId) { $calculation.element('tbxLeaseObjectCount').setValue(1).block(); } else { $calculation.element('tbxLeaseObjectCount').unblock(); } - if (subsidyId) { + if (subsidyId || supplierFinancing) { $calculation.element('cbxLeaseObjectUsed').setValue(false).block(); } else { $calculation.element('cbxLeaseObjectUsed').unblock(); diff --git a/apps/web/server/routers/calculate/index.ts b/apps/web/server/routers/calculate/index.ts index 67230f7..2f206f5 100644 --- a/apps/web/server/routers/calculate/index.ts +++ b/apps/web/server/routers/calculate/index.ts @@ -65,6 +65,11 @@ export const calculateRouter = router({ responseCalculate: calculateResult, }); + // TEMP + if (ctx.unlimited) { + result.__calculateResult = calculateResult; + } + return { data: result, success: true, diff --git a/apps/web/server/routers/calculate/lib/request.ts b/apps/web/server/routers/calculate/lib/request.ts index 014ef38..15c7afb 100644 --- a/apps/web/server/routers/calculate/lib/request.ts +++ b/apps/web/server/routers/calculate/lib/request.ts @@ -45,7 +45,7 @@ export async function createRequestData({ })), }; - const currentUTCDate = dayjs().utc(false); + const currentDate = dayjs().utc(false); let systemuser: CRMTypes.GetSystemUserQuery['systemuser'] = null; @@ -98,8 +98,7 @@ export async function createRequestData({ await apolloClient.query({ query: CRMTypes.GetCoefficientsDocument, variables: { - currentDate: currentUTCDate.format('YYYY-MM-DD'), - jobTitleId: systemuser?.evo_job_titleid, + currentDate: currentDate.toISOString(), }, }) ).data.evo_coefficients @@ -183,18 +182,23 @@ export async function createRequestData({ async bonusFinGAP() { const evo_coefficient = evo_coefficients?.find( - (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'BONUS_FINGAP_PR' + (x) => + x?.evo_job_titleid === systemuser?.evo_job_titleid && + x?.evo_sot_coefficient_typeidData?.evo_id === 'BONUS_FINGAP_PR' ); - return (evo_coefficient?.evo_sot_coefficient || 0) + insurance.values.fingap.insCost; + return (evo_coefficient?.evo_sot_coefficient || 0) * insurance.values.fingap.insCost; }, async bonusFix() { const evo_coefficient = evo_coefficients?.find( (x) => + x?.evo_job_titleid === systemuser?.evo_job_titleid && x?.evo_sot_coefficient_typeidData?.evo_id === 'BONUS_FIX' && - Boolean(values.product) && - x.evo_baseproducts?.some((evo_baseproduct) => evo_baseproduct?.evo_id === values.product) + values.product && + x.evo_baseproducts?.some( + (evo_baseproduct) => evo_baseproduct?.evo_baseproductid === values.product + ) ); return evo_coefficient?.evo_sot_coefficient || 0; @@ -273,7 +277,7 @@ export async function createRequestData({ }, async calcDate() { - return currentUTCDate.toDate(); + return currentDate.toDate(); }, async calcType() { @@ -305,12 +309,12 @@ export async function createRequestData({ }, async deliverySum() { - if (values.calcDoubleAgentRewardCondition) { + if (values.dealerRewardCondition) { const { data: { evo_reward_condition }, } = await apolloClient.query({ query: CRMTypes.GetRewardConditionDocument, - variables: { conditionId: values.calcDoubleAgentRewardCondition }, + variables: { conditionId: values.dealerRewardCondition }, }); if (evo_reward_condition?.evo_calc_reward_rules === 100_000_001) { @@ -348,10 +352,15 @@ export async function createRequestData({ async directorBonus() { const evo_coefficient = evo_coefficients?.find( - (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'DIRECTOR_BONUS' + (x) => + x?.evo_sot_coefficient_typeidData?.evo_id === 'DIRECTOR_BONUS' && + values.product && + x.evo_baseproducts?.some( + (evo_baseproduct) => evo_baseproduct?.evo_baseproductid === values.product + ) ); - return (evo_coefficient?.evo_sot_coefficient || 0) + insurance.values.fingap.insCost; + return evo_coefficient?.evo_sot_coefficient || 0; }, async directorBonusFinGAP() { @@ -359,15 +368,20 @@ export async function createRequestData({ (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'DIRECTOR_BONUS_FINGAP' ); - return (evo_coefficient?.evo_sot_coefficient || 0) + insurance.values.fingap.insCost; + 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' + (x) => + x?.evo_sot_coefficient_typeidData?.evo_id === 'DIRECTOR_BONUS_FIX' && + values.product && + x.evo_baseproducts?.some( + (evo_baseproduct) => evo_baseproduct?.evo_baseproductid === values.product + ) ); - return (evo_coefficient?.evo_sot_coefficient || 0) + insurance.values.fingap.insCost; + return evo_coefficient?.evo_sot_coefficient || 0; }, async directorBonusNsib() { @@ -375,15 +389,20 @@ export async function createRequestData({ (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'DIRECTOR_BONUS_NSIB' ); - return (evo_coefficient?.evo_sot_coefficient || 0) + insurance.values.fingap.insCost; + return evo_coefficient?.evo_sot_coefficient || 0; }, async directorExtraBonus() { const evo_coefficient = evo_coefficients?.find( - (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'DIRECTOR_EXTRA_BONUS' + (x) => + x?.evo_sot_coefficient_typeidData?.evo_id === 'DIRECTOR_EXTRA_BONUS' && + values.product && + x.evo_baseproducts?.some( + (evo_baseproduct) => evo_baseproduct?.evo_baseproductid === values.product + ) ); - return (evo_coefficient?.evo_sot_coefficient || 0) + insurance.values.fingap.insCost; + return evo_coefficient?.evo_sot_coefficient || 0; }, async discount() { @@ -406,11 +425,11 @@ export async function createRequestData({ (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'DISTRICT_RATE' ); - return (evo_coefficient?.evo_sot_coefficient || 0) + insurance.values.fingap.insCost; + return evo_coefficient?.evo_sot_coefficient || 0; }, async dogDate() { - return currentUTCDate.toDate(); + return currentDate.toDate(); }, async doubleAgentsSum() { @@ -445,10 +464,16 @@ export async function createRequestData({ async extraBonus() { const evo_coefficient = evo_coefficients?.find( - (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'EXTRA_BONUS' + (x) => + x?.evo_job_titleid === systemuser?.evo_job_titleid && + x?.evo_sot_coefficient_typeidData?.evo_id === 'EXTRA_BONUS' && + values.product && + x.evo_baseproducts?.some( + (evo_baseproduct) => evo_baseproduct?.evo_baseproductid === values.product + ) ); - return (evo_coefficient?.evo_sot_coefficient || 0) + insurance.values.fingap.insCost; + return evo_coefficient?.evo_sot_coefficient || 0; }, async financialDeptOfDeliverySum() { @@ -461,18 +486,18 @@ export async function createRequestData({ }); if (evo_reward_condition?.evo_calc_reward_rules === 100_000_001) { - return values.dealerRewardSumm / (1 + VAT); + return values.finDepartmentRewardSumm / (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)); + return (values.finDepartmentRewardSumm / 100) * (plPriceWithVAT - discount * (1 + VAT)); } else { const acceptSum = await this.acceptSum(); - return (values.dealerRewardSumm / 100) * acceptSum; + return (values.finDepartmentRewardSumm / 100) * acceptSum; } } @@ -583,9 +608,11 @@ export async function createRequestData({ }, async importerSum() { + if (values.importerRewardRub > 0) return values.importerRewardRub; + const acceptSum = await this.acceptSum(); - return values.importerRewardRub || (values.importerRewardPerc / 100) * acceptSum; + return (values.importerRewardPerc / 100) * acceptSum; }, async insuranceBonus() { @@ -806,7 +833,9 @@ export async function createRequestData({ async nsBonus() { const evo_coefficient = evo_coefficients?.find( - (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'BONUS_NS_PR' + (x) => + x?.evo_job_titleid === systemuser?.evo_job_titleid && + x?.evo_sot_coefficient_typeidData?.evo_id === 'BONUS_NS_PR' ); return evo_coefficient?.evo_sot_coefficient || 0; @@ -848,7 +877,9 @@ export async function createRequestData({ async nsibBonus() { const evo_coefficient = evo_coefficients?.find( - (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'BONUS_NSIB_PR' + (x) => + x?.evo_job_titleid === systemuser?.evo_job_titleid && + x?.evo_sot_coefficient_typeidData?.evo_id === 'BONUS_NSIB_PR' ); const nsibBrutto = await this.nsibBrutto(); @@ -980,7 +1011,9 @@ export async function createRequestData({ async ratBonus() { const evo_coefficient = evo_coefficients?.find( - (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'BONUS_RAT_PR' + (x) => + x?.evo_job_titleid === systemuser?.evo_job_titleid && + x?.evo_sot_coefficient_typeidData?.evo_id === 'BONUS_RAT_PR' ); const rats = await this.rats(); @@ -1004,7 +1037,12 @@ export async function createRequestData({ async regionalDirectorBonus() { const evo_coefficient = evo_coefficients?.find( - (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'REGIONAL_DIRECTOR_BONUS' + (x) => + x?.evo_sot_coefficient_typeidData?.evo_id === 'REGIONAL_DIRECTOR_BONUS' && + values.product && + x.evo_baseproducts?.some( + (evo_baseproduct) => evo_baseproduct?.evo_baseproductid === values.product + ) ); return evo_coefficient?.evo_sot_coefficient || 0; @@ -1014,14 +1052,18 @@ export async function createRequestData({ 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; + return (evo_coefficient?.evo_sot_coefficient || 0) * insurance.values.fingap.insCost; }, async regionalDirectorBonusFix() { const evo_coefficient = evo_coefficients?.find( - (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'REGIONAL_DIRECTOR_BONUS_FIX' + (x) => + x?.evo_sot_coefficient_typeidData?.evo_id === 'REGIONAL_DIRECTOR_BONUS_FIX' && + values.product && + x.evo_baseproducts?.some( + (evo_baseproduct) => evo_baseproduct?.evo_baseproductid === values.product + ) ); return evo_coefficient?.evo_sot_coefficient || 0; @@ -1040,8 +1082,10 @@ export async function createRequestData({ 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) + values.product && + x.evo_baseproducts?.some( + (evo_baseproduct) => evo_baseproduct?.evo_baseproductid === values.product + ) ); return evo_coefficient?.evo_sot_coefficient || 0; @@ -1086,7 +1130,7 @@ export async function createRequestData({ (x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'SALARY_RATE' ); - return (evo_coefficient?.evo_sot_coefficient || 0) + insurance.values.fingap.insCost; + return evo_coefficient?.evo_sot_coefficient || 0; }, async scheduleOfPayments() { diff --git a/apps/web/server/routers/calculate/types.ts b/apps/web/server/routers/calculate/types.ts index 27eced0..f3ba96e 100644 --- a/apps/web/server/routers/calculate/types.ts +++ b/apps/web/server/routers/calculate/types.ts @@ -18,6 +18,7 @@ export const CalculateInputSchema = z export type CalculateInput = z.infer; export const OutputDataSchema = z.object({ + __calculateResult: z.any().optional(), resultPayments: ResultPaymentsSchema, resultValues: ResultValuesSchema, values: ValuesSchema.pick({ diff --git a/apps/web/server/routers/quote/index.ts b/apps/web/server/routers/quote/index.ts index 999260f..a6a6946 100644 --- a/apps/web/server/routers/quote/index.ts +++ b/apps/web/server/routers/quote/index.ts @@ -13,6 +13,7 @@ import { } from './types'; import { calculate } from '@/api/core/query'; import { createKP } from '@/api/crm/query'; +import type { RequestCreateKP } from '@/api/crm/types'; import type { User } from '@/api/user/types'; import initializeApollo from '@/apollo/client'; import defaultValues from '@/config/default-values'; @@ -133,7 +134,7 @@ export const quoteRouter = router({ }; } - const createKPResult = await createKP({ + const requestCreateKP = compatRequestCreateKP({ domainName: user.domainName, finGAP: input.fingap, insurance: Object.values(input.insurance.values), @@ -145,6 +146,8 @@ export const quoteRouter = router({ }, }); + const createKPResult = await createKP(requestCreateKP); + if (createKPResult.success === false) { return { success: false, @@ -171,6 +174,15 @@ export const quoteRouter = router({ }), }); +function compatRequestCreateKP(request: RequestCreateKP) { + const fingapIndex = request.insurance.findIndex((x) => x.key === 'fingap'); + if (fingapIndex >= 0) { + request.insurance[fingapIndex].key = 'finGAP'; + } + + return request; +} + async function compatValues( values: CalculationValues, { apolloClient }: Pick diff --git a/apps/web/stores/validation/index.ts b/apps/web/stores/validation/index.ts index afb8e27..e58c028 100644 --- a/apps/web/stores/validation/index.ts +++ b/apps/web/stores/validation/index.ts @@ -1,6 +1,7 @@ import type RootStore from '../root'; import type { RemoveError, ValidationConfig, ValidationError, ValidationParams } from './types'; import { makeAutoObservable } from 'mobx'; +import { isServer } from 'tools'; import { notification } from 'ui/elements'; export default class Validation { @@ -35,14 +36,13 @@ export default class Validation { this.errors.add({ key, message }); - if (!silent) { + if (!silent && !isServer()) notification.open({ description: message, key: this.params.err_key, message: this.params.err_title, type: this.root.$process.has('Unlimited') ? 'warning' : 'error', }); - } return (() => this.removeError({ key })) as RemoveError; }; diff --git a/apps/web/utils/currency.ts b/apps/web/utils/currency.ts index c4bf647..9f5a887 100644 --- a/apps/web/utils/currency.ts +++ b/apps/web/utils/currency.ts @@ -36,7 +36,7 @@ export function createCurrencyUtility({ apolloClient }: Context) { fetchPolicy: 'network-only', query: CRMTypes.GetCurrencyChangesDocument, variables: { - currentDate: dayjs().utc(false).format('YYYY-MM-DD'), + currentDate: dayjs().utc(false).toISOString(), }, });