diff --git a/apps/web/graphql/crm.query.graphql b/apps/web/graphql/crm.query.graphql index 3aaa705..67792ac 100644 --- a/apps/web/graphql/crm.query.graphql +++ b/apps/web/graphql/crm.query.graphql @@ -325,13 +325,11 @@ query GetRewardCondition($conditionId: Uuid!) { } } -query GetSotCoefficientTypes { - evo_sot_coefficient_types(statecode: 0) { - evo_id +query GetSotCoefficientType($evo_id: String) { + evo_sot_coefficient_type(evo_id: $evo_id) { evo_sot_coefficient_typeid } } - query GetCoefficients($currentDate: DateTime, $jobTitleId: Uuid!) { evo_coefficients( statecode: 0 diff --git a/apps/web/graphql/crm.schema.graphql b/apps/web/graphql/crm.schema.graphql index 354ab26..92da466 100644 --- a/apps/web/graphql/crm.schema.graphql +++ b/apps/web/graphql/crm.schema.graphql @@ -38,6 +38,7 @@ type Query { evo_businessunits(statecode: Int): [evo_businessunit] evo_client_risks(statecode: Int): [evo_client_risk] evo_client_types(statecode: Int): [evo_client_type] + evo_coefficient(evo_coefficientid: Uuid!): evo_coefficient evo_coefficients(evo_client_riskid: Uuid, evo_client_typeid: Uuid, evo_corfficient_type: Int, evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, evo_job_titleid: Uuid, evo_max_period_param: DecimalParamInput, evo_min_period_param: DecimalParamInput, statecode: Int): [evo_coefficient] evo_contract(evo_contractid: Uuid!): evo_contract evo_contracts(evo_accountid: Uuid, evo_name: String, orderby: OrderByInput, statecode: Int): [evo_contract] @@ -86,6 +87,7 @@ type Query { evo_reward_conditions(evo_agency_agreementid_param: GuidParamInput, evo_agent_accountid: Uuid, evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, statecode: Int): [evo_reward_condition] evo_scheduled_call(evo_scheduled_callid: Uuid!): evo_scheduled_call evo_scheduled_calls(evo_inn: String, evo_status: [Int!], evo_telephone1: String, evo_telephone2: String, statecode: Int): [evo_scheduled_call] + evo_sot_coefficient_type(evo_id: String, evo_sot_coefficient_typeid: Uuid): evo_sot_coefficient_type evo_sot_coefficient_types(statecode: Int): [evo_sot_coefficient_type] evo_statuscode(evo_id: String, evo_statuscodeid: Uuid): evo_statuscode evo_statuscodes(statecode: Int): [evo_statuscode] @@ -142,13 +144,21 @@ type Mutation { by(systemuserid: Uuid): MutationBy } -type template { - body: String +type evo_bank_details { createdon: DateTime - description: String + evo_accountid: Uuid + evo_bankid: Uuid + evo_bankidData: account + evo_bank_code: String + evo_bank_detailsid: Uuid + evo_contactid: Uuid + evo_corresponding_account: String + evo_datefrom: DateTime + evo_kbk: String + evo_name: String + evo_payment_account: String + link: String modifiedon: DateTime - subject: String - templateid: Uuid toObjectString: String } @@ -194,6 +204,27 @@ input GuidParamInput { """The built-in `Decimal` scalar type.""" scalar Decimal +type queue { + createdon: DateTime + emailaddress: String + evo_id: String + modifiedon: DateTime + name: String + queueid: Uuid + teams: [team] + toObjectString: String +} + +type template { + body: String + createdon: DateTime + description: String + modifiedon: DateTime + subject: String + templateid: Uuid + toObjectString: String +} + type evo_typedocpackage { createdon: DateTime evo_account: Boolean @@ -312,6 +343,7 @@ type evo_debtwork_contract { evo_withdrawal_issue_done_date: DateTime evo_withdrawal_parking_addressid: Uuid evo_withdrawal_plan_date: DateTime + evo_withdrawal_storage_doc_keys: [Int!] evo_withdrawal_systemuserid: Uuid evo_withdrawal_systemuseridData: systemuser link: String @@ -422,6 +454,8 @@ type evo_question_credit_committee { evo_summary_judgment: Int modifiedon: DateTime quotes: [quote] + statecode: Int + statuscode: Int toObjectString: String } @@ -1639,6 +1673,7 @@ type evo_scheduled_call { evo_utm_term: String modifiedon: DateTime ownerid: Uuid + owneridtype: Int ownerid_systemuser: Uuid ownerid_team: Uuid toObjectString: String @@ -1805,6 +1840,7 @@ type evo_contract { evo_businessunitid: Uuid evo_calc_irr: Decimal evo_calc_profit: Decimal + evo_call_systemuserid: Uuid evo_cancel_contract: Boolean evo_card_bonus_summ: Decimal evo_cession_opportunityid: Uuid @@ -2050,6 +2086,7 @@ type evo_external_system_request { evo_opportunityid: Uuid evo_path_report: String evo_prima_requestid: String + evo_question_credit_committeeid: Uuid evo_request_paymentid: Uuid evo_request_paymentidData: evo_request_payment evo_system: Int @@ -2116,6 +2153,7 @@ type evo_coefficient { evo_season_type: Int evo_sot_coefficient: Decimal evo_sot_coefficient_typeid: Uuid + evo_sot_coefficient_typeidData: evo_sot_coefficient_type modifiedon: DateTime statecode: Int toObjectString: String @@ -2219,6 +2257,7 @@ type evo_rate { type evo_sot_coefficient_type { createdon: DateTime + evo_coefficients: [evo_coefficient] evo_id: String evo_name: String evo_sot_coefficient_typeid: Uuid @@ -2794,35 +2833,6 @@ type email { toObjectString: String } -type evo_bank_details { - createdon: DateTime - evo_accountid: Uuid - evo_bankid: Uuid - evo_bankidData: account - evo_bank_code: String - evo_bank_detailsid: Uuid - evo_contactid: Uuid - evo_corresponding_account: String - evo_datefrom: DateTime - evo_kbk: String - evo_name: String - evo_payment_account: String - link: String - modifiedon: DateTime - toObjectString: String -} - -type queue { - createdon: DateTime - emailaddress: String - evo_id: String - modifiedon: DateTime - name: String - queueid: Uuid - teams: [team] - toObjectString: String -} - type MutationBy { associateBankDetailsAndAgencyAgreement_(evo_agency_agreementid: Uuid!, evo_bank_detailsid: Uuid!): Entity createEntity(data: EntityDataInput): Uuid! @@ -2853,6 +2863,16 @@ enum LogicOperation { OR } +type team { + createdon: DateTime + evo_baseproducts(statecode: Int): [evo_baseproduct] + evo_identity_documents: [evo_identity_document] + modifiedon: DateTime + name: String + teamid: Uuid + toObjectString: String +} + type businessunit { businessunitid: Uuid createdon: DateTime @@ -2909,16 +2929,6 @@ type evo_connection_role { toObjectString: String } -type team { - createdon: DateTime - evo_baseproducts(statecode: Int): [evo_baseproduct] - evo_identity_documents: [evo_identity_document] - modifiedon: DateTime - name: String - teamid: Uuid - toObjectString: String -} - type evo_edo { createdon: DateTime evo_accountid: Uuid diff --git a/apps/web/graphql/crm.types.ts b/apps/web/graphql/crm.types.ts index 39a9c9d..af6ce49 100644 --- a/apps/web/graphql/crm.types.ts +++ b/apps/web/graphql/crm.types.ts @@ -329,10 +329,12 @@ export type GetRewardConditionQueryVariables = Exact<{ export type GetRewardConditionQuery = { __typename?: 'Query', evo_reward_condition: { __typename?: 'evo_reward_condition', evo_reward_summ: number | null, evo_reduce_reward: boolean | null, evo_min_reward_summ: number | null, evo_agency_agreementidData: { __typename?: 'evo_agency_agreement', evo_required_reward: boolean | null, evo_reward_without_other_agent: boolean | null } | null } | null }; -export type GetSotCoefficientTypesQueryVariables = Exact<{ [key: string]: never; }>; +export type GetSotCoefficientTypeQueryVariables = Exact<{ + evo_id: InputMaybe; +}>; -export type GetSotCoefficientTypesQuery = { __typename?: 'Query', evo_sot_coefficient_types: Array<{ __typename?: 'evo_sot_coefficient_type', evo_id: string | null, evo_sot_coefficient_typeid: string | null } | null> | null }; +export type GetSotCoefficientTypeQuery = { __typename?: 'Query', evo_sot_coefficient_type: { __typename?: 'evo_sot_coefficient_type', evo_sot_coefficient_typeid: string | null } | null }; export type GetCoefficientsQueryVariables = Exact<{ currentDate: InputMaybe; @@ -494,7 +496,7 @@ export const GetDealerPersonsDocument = {"kind":"Document","definitions":[{"kind export const GetAgentDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetAgent"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"agentid"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"agent"},"name":{"kind":"Name","value":"account"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"accountid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"agentid"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"accountid"}}]}}]}}]} as unknown as DocumentNode; export const GetRewardConditionsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRewardConditions"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"agentid"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_reward_conditions"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_agent_accountid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"agentid"}}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_agency_agreementid_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"has"},"value":{"kind":"BooleanValue","value":true}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_reward_conditionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_reward_summ"}}]}}]}}]} as unknown as DocumentNode; export const GetRewardConditionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRewardCondition"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"conditionId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_reward_condition"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_reward_conditionid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"conditionId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_reward_summ"}},{"kind":"Field","name":{"kind":"Name","value":"evo_reduce_reward"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_reward_summ"}},{"kind":"Field","name":{"kind":"Name","value":"evo_agency_agreementidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_required_reward"}},{"kind":"Field","name":{"kind":"Name","value":"evo_reward_without_other_agent"}}]}}]}}]}}]} as unknown as DocumentNode; -export const GetSotCoefficientTypesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetSotCoefficientTypes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_sot_coefficient_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_id"}},{"kind":"Field","name":{"kind":"Name","value":"evo_sot_coefficient_typeid"}}]}}]}}]} as unknown as DocumentNode; +export const GetSotCoefficientTypeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetSotCoefficientType"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"evo_id"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_sot_coefficient_type"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"evo_id"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_sot_coefficient_typeid"}}]}}]}}]} as unknown as DocumentNode; export const GetCoefficientsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetCoefficients"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"jobTitleId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_coefficients"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_job_titleid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"jobTitleId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_job_titleid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_sot_coefficient_typeid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_baseproducts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_baseproductid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_sot_coefficient"}}]}}]}}]} as unknown as DocumentNode; export const GetSystemUserDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetSystemUser"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"domainname"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"systemuser"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"domainname"},"value":{"kind":"Variable","name":{"kind":"Name","value":"domainname"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_job_titleid"}}]}}]}}]} as unknown as DocumentNode; export const GetBonusDataFromQuoteDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetBonusDataFromQuote"},"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_sale_bonus"}}]}}]}}]} as unknown as DocumentNode; diff --git a/apps/web/process/bonuses/reactions/lib/helper.ts b/apps/web/process/bonuses/reactions/lib/helper.ts index a631e98..d9bd337 100644 --- a/apps/web/process/bonuses/reactions/lib/helper.ts +++ b/apps/web/process/bonuses/reactions/lib/helper.ts @@ -45,19 +45,18 @@ export default function helper({ apolloClient, queryClient }: ReactionsContext) }); const { - data: { evo_sot_coefficient_types }, + data: { evo_sot_coefficient_type }, } = await apolloClient.query({ - query: CRMTypes.GetSotCoefficientTypesDocument, + query: CRMTypes.GetSotCoefficientTypeDocument, + variables: { + evo_id: 'BONUS_LEASING', + }, }); - const evo_sot_coefficient_type_bonus = evo_sot_coefficient_types?.find( - (x) => x?.evo_id === 'BONUS_LEASING' - ); - return evo_coefficients?.find( (evo_coefficient) => evo_coefficient?.evo_sot_coefficient_typeid === - evo_sot_coefficient_type_bonus?.evo_sot_coefficient_typeid && + evo_sot_coefficient_type?.evo_sot_coefficient_typeid && evo_coefficient?.evo_baseproducts?.some((x) => x?.evo_baseproductid === productId) ); },