From 9d9b3b31bc23a39c1594b850ecbf44e229be44ae Mon Sep 17 00:00:00 2001 From: Chika Date: Mon, 12 Sep 2022 13:43:55 +0300 Subject: [PATCH 1/2] merge release/dyn-1310_agents [!] --- .../Calculation/Elements/props/common.ts | 12 +- src/client/process/agents/fill-elements.ts | 114 +++ src/client/process/agents/reactions.ts | 672 ++++++++++++++++++ .../Effects/actions/calculate/prepareData.ts | 191 ++++- .../actions/calculate/validate/elements.ts | 173 +++++ .../Effects/reactions/loadKpReaction/index.ts | 95 ++- .../reactions/loadKpReaction/mapKpToValues.ts | 6 +- .../Effects/reactions/otherReactions.ts | 243 ------- .../Effects/reactions/requestReactions.ts | 182 ++--- src/client/stores/CalculationStore/index.ts | 2 + .../query/quote/fragments/quoteFields.graphql | 6 + .../query/quote/options/main_options.graphql | 21 + .../CrmService/graphql/schema.graphql | 219 ++++-- .../services/CrmService/types/entities.ts | 10 +- 14 files changed, 1478 insertions(+), 468 deletions(-) create mode 100644 src/client/process/agents/fill-elements.ts create mode 100644 src/client/process/agents/reactions.ts diff --git a/src/client/Containers/Calculation/Elements/props/common.ts b/src/client/Containers/Calculation/Elements/props/common.ts index 34f7b57..c19a24b 100644 --- a/src/client/Containers/Calculation/Elements/props/common.ts +++ b/src/client/Containers/Calculation/Elements/props/common.ts @@ -178,42 +178,42 @@ const elementsProps: Partial> = { }, tbxDealerRewardSumm: { min: '0.00', - max: '20.00', + max: '999999.00', step: '0.10', precision: 2, formatter: formatNumber, }, tbxDealerBrokerRewardSumm: { min: '0.00', - max: '20.00', + max: '999999.00', step: '0.10', precision: 2, formatter: formatNumber, }, tbxIndAgentRewardSumm: { min: '0.00', - max: '20.00', + max: '999999.00', step: '0.10', precision: 2, formatter: formatNumber, }, tbxCalcDoubleAgentRewardSumm: { min: '0.00', - max: '20.00', + max: '999999.00', step: '0.10', precision: 2, formatter: formatNumber, }, tbxCalcBrokerRewardSum: { min: '0.00', - max: '20.00', + max: '999999.00', step: '0.10', precision: 2, formatter: formatNumber, }, tbxFinDepartmentRewardSumm: { min: '0.00', - max: '20.00', + max: '999999.00', step: '0.10', precision: 2, formatter: formatNumber, diff --git a/src/client/process/agents/fill-elements.ts b/src/client/process/agents/fill-elements.ts new file mode 100644 index 0000000..18f4038 --- /dev/null +++ b/src/client/process/agents/fill-elements.ts @@ -0,0 +1,114 @@ +import CrmService from 'core/services/CrmService'; +import { IAccount, ILead } from 'core/services/CrmService/types/entities'; +import { ICalculationStore } from 'core/types/Calculation/Store'; +import { gql } from 'graphql.macro'; + +export function fillIndAgent(this: ICalculationStore, lead?: ILead) { + if (lead?.evo_agent_accountid) { + CrmService.getCRMOptions<'accountOptions', IAccount>({ + query: gql` + query selectIndAgent($evo_agent_accountid: Uuid!) { + accountOptions: account(accountid: $evo_agent_accountid) { + accountid + name + } + } + `, + variables: { + evo_agent_accountid: lead.evo_agent_accountid, + }, + }).then(({ accountOptions }) => { + if (accountOptions && accountOptions.length > 0) { + this.setOptions('selectIndAgent', accountOptions); + this.setValue('indAgent', accountOptions[0].accountid); + } else { + this.setValue('indAgent', null); + this.setOptions('selectIndAgent', []); + } + }); + } else { + this.setValue('indAgent', null); + this.setOptions('selectIndAgent', []); + } +} + +export function fillCalcDoubleAgent(this: ICalculationStore, lead?: ILead) { + if (lead?.evo_double_agent_accountid) { + CrmService.getCRMOptions<'accountOptions', IAccount>({ + query: gql` + query selectCalcDoubleAgent($evo_double_agent_accountid: Uuid!) { + accountOptions: account(accountid: $evo_double_agent_accountid) { + accountid + name + } + } + `, + variables: { + evo_double_agent_accountid: lead.evo_double_agent_accountid, + }, + }).then(({ accountOptions }) => { + if (accountOptions && accountOptions.length > 0) { + this.setOptions('selectCalcDoubleAgent', accountOptions); + this.setValue('calcDoubleAgent', accountOptions[0].accountid); + } else { + this.setValue('calcDoubleAgent', null); + this.setOptions('selectCalcDoubleAgent', []); + } + }); + } else { + this.setValue('calcDoubleAgent', null); + this.setOptions('selectCalcDoubleAgent', []); + } +} + +export function fillCalcBroker(this: ICalculationStore, lead?: ILead) { + if (lead?.evo_broker_accountid) { + CrmService.getCRMOptions<'accountOptions', IAccount>({ + query: gql` + query selectCalcBroker($evo_broker_accountid: Uuid!) { + accountOptions: account(accountid: $evo_broker_accountid) { + accountid + name + } + } + `, + variables: { + evo_broker_accountid: lead.evo_broker_accountid, + }, + }).then(({ accountOptions }) => { + if (accountOptions && accountOptions.length > 0) { + this.setOptions('selectCalcBroker', accountOptions); + this.setValue('calcBroker', accountOptions[0].accountid); + } + }); + } else { + this.setValue('calcBroker', null); + this.setOptions('selectCalcBroker', []); + } +} + +export function fillFinDepartment(this: ICalculationStore, lead?: ILead) { + if (lead?.evo_fin_department_accountid) { + CrmService.getCRMOptions<'accountOptions', IAccount>({ + query: gql` + query selectCalcFinDepartment($evo_fin_department_accountid: Uuid!) { + accountOptions: account(accountid: $evo_fin_department_accountid) { + accountid + name + } + } + `, + variables: { + evo_fin_department_accountid: lead.evo_fin_department_accountid, + }, + }).then(({ accountOptions }) => { + if (accountOptions && accountOptions.length > 0) { + this.setOptions('selectCalcFinDepartment', accountOptions); + this.setValue('calcFinDepartment', accountOptions[0].accountid); + } + }); + } else { + this.setValue('calcFinDepartment', null); + this.setOptions('selectCalcFinDepartment', []); + } +} diff --git a/src/client/process/agents/reactions.ts b/src/client/process/agents/reactions.ts new file mode 100644 index 0000000..52648b8 --- /dev/null +++ b/src/client/process/agents/reactions.ts @@ -0,0 +1,672 @@ +import { openNotification } from 'client/Elements/Notification'; +import { ICalculationStore } from 'core/types/Calculation/Store'; +import { reaction } from 'mobx'; +import { ElementStatus } from 'types/elements'; +import { + fillCalcBroker, + fillCalcDoubleAgent, + fillFinDepartment, + fillIndAgent, +} from './fill-elements'; + +export default function agentsReactions($calculation: ICalculationStore) { + /** + * @description + * Добавить реакцию на изменение списка в поле selectDealerRewardCondition : + Если в списке selectDealerRewardCondition есть запись, + у которой evo_reward_condition.evo_agency_agreementid. Выплата без других агентов (evo_reward_without_other_agent) = True, + то сбрасывают значение и закрываются для выбора поля: + + selectDealerBroker + selectIndAgent + selectCalcDoubleAgent + selectCalcBroker + selectFinDepartment + */ + + reaction( + () => { + return $calculation.getOptions( + 'selectDealerRewardCondition', + undefined, + true, + ); + }, + dealerRewardConditionOptions => { + // TODO: отдельный запрос evo_agency_agreement по id + if ( + dealerRewardConditionOptions?.some( + x => + x.evo_agency_agreementidData?.evo_reward_without_other_agent === + true, + ) + ) { + $calculation.setValue('dealerBroker', null); + $calculation.setValue('indAgent', null); + $calculation.setValue('calcDoubleAgent', null); + $calculation.setValue('calcBroker', null); + $calculation.setValue('calcFinDepartment', null); + + $calculation.setStatus('selectDealerBroker', ElementStatus.Disabled); + $calculation.setStatus('selectIndAgent', ElementStatus.Disabled); + $calculation.setStatus('selectCalcDoubleAgent', ElementStatus.Disabled); + $calculation.setStatus('selectCalcBroker', ElementStatus.Disabled); + $calculation.setStatus( + 'selectCalcFinDepartment', + ElementStatus.Disabled, + ); + } else { + $calculation.setStatus('selectDealerBroker', ElementStatus.Default); + + const lead = $calculation.getOption('selectLead'); + fillIndAgent.call($calculation, lead); + fillCalcDoubleAgent.call($calculation, lead); + fillCalcBroker.call($calculation, lead); + fillFinDepartment.call($calculation, lead); + } + }, + ); + + /** + * @description + * Добавить реакцию на изменение списка в поле selectDealerBrokerRewardCondition : + + Если в списке selectDealerBrokerRewardCondition есть запись, у которой evo_reward_condition.evo_agency_agreementid. Выплата без других агентов (evo_reward_without_other_agent) = True, то сбрасывают значение и закрываются для выбора поля: + + selectDealerPerson (не обнуляем) + selectIndAgent + selectCalcDoubleAgent + selectCalcBroker + selectFinDepartment + иначе + + selectDealerPerson открываем для редактирования + selectIndAgent заполняется значением из Интереса + selectCalcDoubleAgent заполняется значением из Интереса + selectCalcBrokerRewardCondition заполняется значением из Интереса + selectFinDepartmentRewardCondtion заполняется значением из Интереса + */ + reaction( + () => { + return $calculation.getOptions( + 'selectDealerBrokerRewardCondition', + undefined, + true, + ); + }, + dealerBrokerRewardConditionOptions => { + // TODO: отдельный запрос evo_agency_agreement по id + if ( + dealerBrokerRewardConditionOptions?.some( + x => + x.evo_agency_agreementidData?.evo_reward_without_other_agent === + true, + ) + ) { + $calculation.setValue('indAgent', null); + $calculation.setValue('calcDoubleAgent', null); + $calculation.setValue('calcBroker', null); + $calculation.setValue('calcFinDepartment', null); + + $calculation.setStatus('selectDealerPerson', ElementStatus.Disabled); + $calculation.setStatus('selectIndAgent', ElementStatus.Disabled); + $calculation.setStatus('selectCalcDoubleAgent', ElementStatus.Disabled); + $calculation.setStatus('selectCalcBroker', ElementStatus.Disabled); + $calculation.setStatus( + 'selectCalcFinDepartment', + ElementStatus.Disabled, + ); + } else { + $calculation.setStatus('selectDealerPerson', ElementStatus.Default); + + //TODO: сделать отдельный запрос на lead (и возможно на опции) + const lead = $calculation.getOption('selectLead'); + fillIndAgent.call($calculation, lead); + fillCalcDoubleAgent.call($calculation, lead); + fillCalcBroker.call($calculation, lead); + fillFinDepartment.call($calculation, lead); + } + }, + ); + + /** + * @description + * Добавить реакцию на изменение списка в поле selectIndAgentRewardCondition : + + Если в списке selectIndAgentRewardCondition есть запись, у которой evo_reward_condition.evo_agency_agreementid. Выплата без других агентов (evo_reward_without_other_agent) = True, то сбрасывают значение и закрываются для выбора поля: + + selectDealerPerson (не обнуляем) + selectDealerBroker + selectCalcDoubleAgent + selectCalcBroker + selectFinDepartment + иначе + + selectDealerPerson открываем для редактирования + selectDealerBroker открываем для редактирования + selectCalcDoubleAgent заполняется значением из Интереса + selectCalcBroker заполняется значением из Интереса + selectCalcFinDepartment заполняется значением из Интереса + */ + reaction( + () => { + return $calculation.getOptions( + 'selectIndAgentRewardCondition', + undefined, + true, + ); + }, + indAgentRewardConditionOptions => { + // TODO: отдельный запрос evo_agency_agreement по id + if ( + indAgentRewardConditionOptions?.some( + x => + x.evo_agency_agreementidData?.evo_reward_without_other_agent === + true, + ) + ) { + $calculation.setValue('dealerBroker', null); + $calculation.setValue('calcDoubleAgent', null); + $calculation.setValue('calcBroker', null); + $calculation.setValue('calcFinDepartment', null); + + $calculation.setStatus('selectDealerPerson', ElementStatus.Disabled); + $calculation.setStatus('selectDealerBroker', ElementStatus.Disabled); + $calculation.setStatus('selectCalcDoubleAgent', ElementStatus.Disabled); + $calculation.setStatus('selectCalcBroker', ElementStatus.Disabled); + $calculation.setStatus( + 'selectCalcFinDepartment', + ElementStatus.Disabled, + ); + } else { + $calculation.setStatus('selectDealerPerson', ElementStatus.Default); + $calculation.setStatus('selectDealerBroker', ElementStatus.Default); + + //TODO: сделать отдельный запрос на lead (и возможно на опции) + const lead = $calculation.getOption('selectLead'); + fillCalcDoubleAgent.call($calculation, lead); + fillCalcBroker.call($calculation, lead); + fillFinDepartment.call($calculation, lead); + } + }, + ); + + /** + * @description + * Добавить реакцию на изменение списка в поле selectCalcDoubleAgentRewardCondition : + + Если в списке selectCalcDoubleAgentRewardCondition есть запись, у которой evo_reward_condition.evo_agency_agreementid. Выплата без других агентов (evo_reward_without_other_agent) = True, то сбрасывают значение и закрываются для выбора поля: + + selectDealerPerson (не обнуляем) + selectDealerBroker + selectIndAgent + selectCalcBroker + selectCalcFinDepartment + иначе + + selectDealerPerson открываем для редактирования + selectDealerBroker открываем для редактирования + selectIndAgent заполняется значением из Интереса + selectCalcBroker заполняется значением из Интереса + selectCalcFinDepartment заполняется значением из Интереса + */ + reaction( + () => { + return $calculation.getOptions( + 'selectCalcDoubleAgentRewardCondition', + undefined, + true, + ); + }, + calcDoubleAgentRewardConditionOptions => { + // TODO: отдельный запрос evo_agency_agreement по id + if ( + calcDoubleAgentRewardConditionOptions?.some( + x => + x.evo_agency_agreementidData?.evo_reward_without_other_agent === + true, + ) + ) { + $calculation.setValue('dealerBroker', null); + $calculation.setValue('indAgent', null); + $calculation.setValue('calcBroker', null); + $calculation.setValue('calcFinDepartment', null); + + $calculation.setStatus('selectDealerPerson', ElementStatus.Disabled); + $calculation.setStatus('selectDealerBroker', ElementStatus.Disabled); + $calculation.setStatus('selectIndAgent', ElementStatus.Disabled); + $calculation.setStatus('selectCalcBroker', ElementStatus.Disabled); + $calculation.setStatus( + 'selectCalcFinDepartment', + ElementStatus.Disabled, + ); + } else { + $calculation.setStatus('selectDealerPerson', ElementStatus.Default); + $calculation.setStatus('selectDealerBroker', ElementStatus.Default); + + //TODO: сделать отдельный запрос на lead (и возможно на опции) + const lead = $calculation.getOption('selectLead'); + fillIndAgent.call($calculation, lead); + fillCalcBroker.call($calculation, lead); + fillFinDepartment.call($calculation, lead); + } + }, + ); + + /** + * @description + * Добавить реакцию на изменение списка в поле selectCalcBrokerRewardCondition: + + Если в списке selectCalcBrokerRewardCondition есть запись, у которой evo_reward_condition.evo_agency_agreementid. Выплата без других агентов (evo_reward_without_other_agent) = True, то сбрасывают значение и закрываются для выбора поля: + + selectDealerPerson (не обнуляем) + selectDealerBroker + selectIndAgent + selectCalcDoubleAgent + selectCalcFinDepartment + иначе + + selectDealerPerson открываем для редактирования + selectDealerBroker открываем для редактирования + selectIndAgent заполняется значением из Интереса + selectCalcDoubleAgent заполняется значением из Интереса + selectCalcFinDepartment заполняется значением из Интереса + */ + reaction( + () => { + return $calculation.getOptions( + 'selectCalcBrokerRewardCondition', + undefined, + true, + ); + }, + calcBrokerRewardConditionOptions => { + // TODO: отдельный запрос evo_agency_agreement по id + if ( + calcBrokerRewardConditionOptions?.some( + x => + x.evo_agency_agreementidData?.evo_reward_without_other_agent === + true, + ) + ) { + $calculation.setValue('dealerBroker', null); + $calculation.setValue('indAgent', null); + $calculation.setValue('calcDoubleAgent', null); + $calculation.setValue('calcFinDepartment', null); + + $calculation.setStatus('selectDealerPerson', ElementStatus.Disabled); + $calculation.setStatus('selectDealerBroker', ElementStatus.Disabled); + $calculation.setStatus('selectIndAgent', ElementStatus.Disabled); + $calculation.setStatus('selectCalcDoubleAgent', ElementStatus.Disabled); + $calculation.setStatus( + 'selectCalcFinDepartment', + ElementStatus.Disabled, + ); + } else { + $calculation.setStatus('selectDealerPerson', ElementStatus.Default); + $calculation.setStatus('selectDealerBroker', ElementStatus.Default); + + //TODO: сделать отдельный запрос на lead (и возможно на опции) + const lead = $calculation.getOption('selectLead'); + fillIndAgent.call($calculation, lead); + fillCalcDoubleAgent.call($calculation, lead); + fillFinDepartment.call($calculation, lead); + } + }, + ); + + /** + * @description + * Добавить реакцию на изменение списка в поле selectFinDepartmentRewardCondtion: + + Если в списке selectFinDepartmentRewardCondtion есть запись, у которой evo_reward_condition.evo_agency_agreementid. Выплата без других агентов (evo_reward_without_other_agent) = True, то сбрасывают значение и закрываются для выбора поля: + + selectDealerPerson (не обнуляем) + selectDealerBroker + selectIndAgent + selectCalcDoubleAgent + selectCalcBroker + иначе + + selectDealerPerson открываем для редактирования + selectDealerBroker открываем для редактирования + selectIndAgent заполняется значением из Интереса + selectCalcDoubleAgent заполняется значением из Интереса + selectCalcBroker заполняется значением из Интереса + */ + reaction( + () => { + return $calculation.getOptions( + 'selectFinDepartmentRewardCondtion', + undefined, + true, + ); + }, + finDepartmentRewardCondtionOptions => { + // TODO: отдельный запрос evo_agency_agreement по id + if ( + finDepartmentRewardCondtionOptions?.some( + x => + x.evo_agency_agreementidData?.evo_reward_without_other_agent === + true, + ) + ) { + $calculation.setValue('dealerBroker', null); + $calculation.setValue('indAgent', null); + $calculation.setValue('calcDoubleAgent', null); + $calculation.setValue('calcBroker', null); + + $calculation.setStatus('selectDealerPerson', ElementStatus.Disabled); + $calculation.setStatus('selectDealerBroker', ElementStatus.Disabled); + $calculation.setStatus('selectIndAgent', ElementStatus.Disabled); + $calculation.setStatus('selectCalcDoubleAgent', ElementStatus.Disabled); + $calculation.setStatus('selectCalcBroker', ElementStatus.Disabled); + } else { + $calculation.setStatus('selectDealerPerson', ElementStatus.Default); + $calculation.setStatus('selectDealerBroker', ElementStatus.Default); + + //TODO: сделать отдельный запрос на lead (и возможно на опции) + const lead = $calculation.getOption('selectLead'); + fillIndAgent.call($calculation, lead); + fillCalcDoubleAgent.call($calculation, lead); + fillCalcBroker.call($calculation, lead); + } + }, + ); + + reaction( + () => { + return $calculation.getValue('dealerRewardSumm'); + }, + dealerRewardSumm => { + const dealerRewardCondition = $calculation.getOption( + 'selectDealerRewardCondition', + ); + if ( + dealerRewardCondition?.evo_reward_summ && + dealerRewardSumm > dealerRewardCondition.evo_reward_summ + ) { + $calculation.setValidation('tbxDealerRewardSumm', false); + openNotification({ + type: 'error', + message: 'Ошибка', + description: + 'Вознаграждение ЮЛ поставщика указано больше условия по агентскому договору!', + }); + } else if ( + !dealerRewardCondition?.evo_reduce_reward && + dealerRewardCondition?.evo_reward_summ && + dealerRewardSumm < dealerRewardCondition.evo_reward_summ + ) { + $calculation.setValidation('tbxDealerRewardSumm', false); + openNotification({ + type: 'error', + message: 'Ошибка', + description: + 'Вознаграждение ЮЛ поставщика указано меньше условия по агентскому договору!', + }); + } else if ( + dealerRewardCondition?.evo_min_reward_summ && + dealerRewardSumm < dealerRewardCondition?.evo_min_reward_summ + ) { + $calculation.setValidation('tbxDealerRewardSumm', false); + openNotification({ + type: 'error', + message: 'Ошибка', + description: + 'Вознаграждение ЮЛ поставщика указано меньше условия по агентскому договору!', + }); + } else { + $calculation.setValidation('tbxDealerRewardSumm', true); + } + }, + ); + + reaction( + () => { + return $calculation.getValue('dealerBrokerRewardSumm'); + }, + dealerBrokerRewardSumm => { + const dealerBrokerRewardCondition = $calculation.getOption( + 'selectDealerBrokerRewardCondition', + ); + if ( + dealerBrokerRewardCondition?.evo_reward_summ && + dealerBrokerRewardSumm > dealerBrokerRewardCondition.evo_reward_summ + ) { + $calculation.setValidation('tbxDealerBrokerRewardSumm', false); + openNotification({ + type: 'error', + message: 'Ошибка', + description: + 'Вознаграждение брокера поставщика указано больше условия по агентскому договору!', + }); + } else if ( + !dealerBrokerRewardCondition?.evo_reduce_reward && + dealerBrokerRewardCondition?.evo_reward_summ && + dealerBrokerRewardSumm < dealerBrokerRewardCondition.evo_reward_summ + ) { + $calculation.setValidation('tbxDealerBrokerRewardSumm', false); + openNotification({ + type: 'error', + message: 'Ошибка', + description: + 'Вознаграждение брокера поставщика указано меньше условия по агентскому договору!', + }); + } else if ( + dealerBrokerRewardCondition?.evo_min_reward_summ && + dealerBrokerRewardSumm < dealerBrokerRewardCondition.evo_min_reward_summ + ) { + $calculation.setValidation('tbxDealerBrokerRewardSumm', false); + openNotification({ + type: 'error', + message: 'Ошибка', + description: + 'Вознаграждение Брокера поставщика указано меньше условия по агентскому договору!', + }); + } else { + $calculation.setValidation('tbxDealerBrokerRewardSumm', true); + } + }, + ); + + reaction( + () => { + return $calculation.getValue('indAgentRewardSumm'); + }, + indAgentRewardSumm => { + const indAgentRewardCondition = $calculation.getOption( + 'selectIndAgentRewardCondition', + ); + if ( + indAgentRewardCondition?.evo_reward_summ && + indAgentRewardSumm > indAgentRewardCondition.evo_reward_summ + ) { + $calculation.setValidation('tbxIndAgentRewardSumm', false); + openNotification({ + type: 'error', + message: 'Ошибка', + description: + 'Вознаграждение агента ФЛ указано больше условия по агентскому договору!', + }); + } else if ( + !indAgentRewardCondition?.evo_reduce_reward && + indAgentRewardCondition?.evo_reward_summ && + indAgentRewardSumm < indAgentRewardCondition.evo_reward_summ + ) { + $calculation.setValidation('tbxIndAgentRewardSumm', false); + openNotification({ + type: 'error', + message: 'Ошибка', + description: + 'Вознаграждение агента ФЛ указано меньше условия по агентскому договору!', + }); + } else if ( + indAgentRewardCondition?.evo_min_reward_summ && + indAgentRewardSumm > indAgentRewardCondition.evo_min_reward_summ + ) { + $calculation.setValidation('tbxIndAgentRewardSumm', false); + openNotification({ + type: 'error', + message: 'Ошибка', + description: + 'Вознаграждение агента ФЛ указано меньше условия по агентскому договору!', + }); + } else { + $calculation.setValidation('tbxIndAgentRewardSumm', true); + } + }, + ); + + reaction( + () => { + return $calculation.getValue('calcDoubleAgentRewardSumm'); + }, + calcDoubleAgentRewardSumm => { + const selectCalcDoubleAgentRewardCondition = $calculation.getOption( + 'selectCalcDoubleAgentRewardCondition', + ); + if ( + selectCalcDoubleAgentRewardCondition?.evo_reward_summ && + calcDoubleAgentRewardSumm > + selectCalcDoubleAgentRewardCondition.evo_reward_summ + ) { + $calculation.setValidation('tbxCalcDoubleAgentRewardSumm', false); + openNotification({ + type: 'error', + message: 'Ошибка', + description: + 'Вознаграждение двойного агента указано больше условия по агентскому договору!', + }); + } else if ( + !selectCalcDoubleAgentRewardCondition?.evo_reduce_reward && + selectCalcDoubleAgentRewardCondition?.evo_reward_summ && + calcDoubleAgentRewardSumm < + selectCalcDoubleAgentRewardCondition.evo_reward_summ + ) { + $calculation.setValidation('tbxCalcDoubleAgentRewardSumm', false); + openNotification({ + type: 'error', + message: 'Ошибка', + description: + 'Вознаграждение двойного агента указано меньше условия по агентскому договору!', + }); + } else if ( + selectCalcDoubleAgentRewardCondition?.evo_min_reward_summ && + calcDoubleAgentRewardSumm > + selectCalcDoubleAgentRewardCondition.evo_min_reward_summ + ) { + $calculation.setValidation('tbxCalcDoubleAgentRewardSumm', false); + openNotification({ + type: 'error', + message: 'Ошибка', + description: + 'Вознаграждение двойного агента указано меньше условия по агентскому договору!', + }); + } else { + $calculation.setValidation('tbxCalcDoubleAgentRewardSumm', true); + } + }, + ); + + reaction( + () => { + return $calculation.getValue('calcBrokerRewardSum'); + }, + calcBrokerRewardSum => { + const selectCalcBrokerRewardCondition = $calculation.getOption( + 'selectCalcBrokerRewardCondition', + ); + if ( + selectCalcBrokerRewardCondition?.evo_reward_summ && + calcBrokerRewardSum > selectCalcBrokerRewardCondition.evo_reward_summ + ) { + $calculation.setValidation('tbxCalcBrokerRewardSum', false); + openNotification({ + type: 'error', + message: 'Ошибка', + description: + 'Вознаграждение брокера указано больше условия по агентскому договору!', + }); + } else if ( + !selectCalcBrokerRewardCondition?.evo_reduce_reward && + selectCalcBrokerRewardCondition?.evo_reward_summ && + calcBrokerRewardSum < selectCalcBrokerRewardCondition.evo_reward_summ + ) { + $calculation.setValidation('tbxCalcBrokerRewardSum', false); + openNotification({ + type: 'error', + message: 'Ошибка', + description: + 'Вознаграждение брокера указано меньше условия по агентскому договору!', + }); + } else if ( + selectCalcBrokerRewardCondition?.evo_min_reward_summ && + calcBrokerRewardSum < + selectCalcBrokerRewardCondition?.evo_min_reward_summ + ) { + $calculation.setValidation('tbxCalcBrokerRewardSum', false); + openNotification({ + type: 'error', + message: 'Ошибка', + description: + 'Вознаграждение брокера указано меньше условия по агентскому договору!', + }); + } else { + $calculation.setValidation('tbxCalcBrokerRewardSum', true); + } + }, + ); + + reaction( + () => { + return $calculation.getValue('finDepartmentRewardSumm'); + }, + finDepartmentRewardSumm => { + const selectFinDepartmentRewardCondtion = $calculation.getOption( + 'selectFinDepartmentRewardCondtion', + ); + + if ( + selectFinDepartmentRewardCondtion?.evo_reward_summ && + finDepartmentRewardSumm > + selectFinDepartmentRewardCondtion?.evo_reward_summ + ) { + $calculation.setValidation('tbxFinDepartmentRewardSumm', false); + openNotification({ + type: 'error', + message: 'Ошибка', + description: + 'Вознаграждение финотдела указано больше условия по агентскому договору!', + }); + } else if ( + selectFinDepartmentRewardCondtion?.evo_reward_summ && + !selectFinDepartmentRewardCondtion.evo_reduce_reward && + finDepartmentRewardSumm < + selectFinDepartmentRewardCondtion.evo_reward_summ + ) { + $calculation.setValidation('tbxFinDepartmentRewardSumm', false); + openNotification({ + type: 'error', + message: 'Ошибка', + description: + 'Вознаграждение финотдела указано меньше условия по агентскому договору!', + }); + } else if ( + selectFinDepartmentRewardCondtion?.evo_min_reward_summ && + finDepartmentRewardSumm < + selectFinDepartmentRewardCondtion?.evo_min_reward_summ + ) { + $calculation.setValidation('tbxFinDepartmentRewardSumm', false); + openNotification({ + type: 'error', + message: 'Ошибка', + description: + 'Вознаграждение финотдела указано меньше условия по агентскому договору!', + }); + } else { + $calculation.setValidation('tbxFinDepartmentRewardSumm', true); + } + }, + ); +} diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts index d2fa480..845b5d6 100644 --- a/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts +++ b/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts @@ -306,27 +306,186 @@ export default function (this: ICalculationStore): PreparedData { (preparedValues.firstPayment || 0) * ((preparedValues.plPrice || 0) - (preparedValues.importProgramSum || 0)); - preparedValues.agentsSum = - (values.indAgentRewardSumm / 100) * - preparedValues.acceptSum * - valuesConstants.ESN; + /** + * @description + * если в selectIndAgentRewardCondition значение evo_reward_condition.Расчет вознаграждения от (evo_calc_reward_rules) = 100 000 001 (от суммы), + то AgentsSum = Размер АВ агента ФЛ (tbxIndAgentRewardSumm) * ЕСН [ESN] + иначе + если в selectIndAgentRewardCondition указана запись, у которой evo_reward_condition.evo_agency_agreementid. Стоимость ПЛ (evo_leasingobject_price) = 100 000 001 (с НДС), + то AgentsSum = (Размер АВ агента ФЛ (tbxIndAgentRewardSumm) /100 * (PreparedValues.PlPriceWithVAT - Discount*(1+VAT)) * ЕСН [ESN], + иначе AgentsSum = (значение поля Размер АВ агента ФЛ (tbxIndAgentRewardSumm) /100 * Стоимость ПЛ с учетом скидки [AcceptSum] ) * ЕСН [ESN] + */ + const selectIndAgentRewardConditionOption = this.getOption( + 'selectIndAgentRewardCondition', + ); + if ( + selectIndAgentRewardConditionOption?.evo_calc_reward_rules === 100_000_001 + ) { + preparedValues.agentsSum = values.indAgentRewardSumm * valuesConstants.ESN; + } else if ( + selectIndAgentRewardConditionOption?.evo_agency_agreementidData + ?.evo_leasingobject_price === 100_000_001 + ) { + preparedValues.agentsSum = + (values.indAgentRewardSumm / 100) * + ((preparedValues.plPriceWithVAT || 0) - + (preparedValues.discount || 0) * (1 + valuesConstants.VAT)) * + valuesConstants.ESN; + } else { + preparedValues.agentsSum = + (values.indAgentRewardSumm / 100) * + preparedValues.acceptSum * + valuesConstants.ESN; + } - preparedValues.doubleAgentsSum = - (values.calcDoubleAgentRewardSumm / 100) * - preparedValues.acceptSum * - valuesConstants.ESN; + /** + * @description + * если в selectCalcDoubleAgentRewardCondition значение evo_reward_condition.Расчет вознаграждения от (evo_calc_reward_rules) = 100 000 001 (от суммы), + то DoubleAgentsSum= Размер АВ двойного агента (tbxCalcDoubleAgentRewardSumm) * ЕСН [ESN] + иначе + если в selectCalcDoubleAgentRewardCondition указана запись, у которой evo_reward_condition.evo_agency_agreementid. Стоимость ПЛ (evo_leasingobject_price) = 100 000 001 (с НДС), + то DoubleAgentsSum= (Размер АВ двойного агента (tbxCalcDoubleAgentRewardSumm) /100 * (PreparedValues.PlPriceWithVAT - Discount*(1+VAT)) * ЕСН [ESN], + иначе DoubleAgentsSum= (значение поля Размер АВ двойного агента (tbxCalcDoubleAgentRewardSumm) /100 * Стоимость ПЛ с учетом скидки [AcceptSum] ) * ЕСН [ESN] + */ + const selectCalcDoubleAgentRewardCondition = this.getOption( + 'selectCalcDoubleAgentRewardCondition', + ); + if ( + selectCalcDoubleAgentRewardCondition?.evo_calc_reward_rules === 100_000_001 + ) { + preparedValues.doubleAgentsSum = + values.calcDoubleAgentRewardSumm * valuesConstants.ESN; + } else if ( + selectCalcDoubleAgentRewardCondition?.evo_agency_agreementidData + ?.evo_leasingobject_price === 100_000_001 + ) { + preparedValues.doubleAgentsSum = + (values.calcDoubleAgentRewardSumm / 100) * + ((preparedValues.plPriceWithVAT || 0) - + (preparedValues.discount || 0) * (1 + valuesConstants.VAT)) * + valuesConstants.ESN; + } else { + preparedValues.doubleAgentsSum = + (values.calcDoubleAgentRewardSumm / 100) * + preparedValues.acceptSum * + valuesConstants.ESN; + } - preparedValues.deliverySum = - (values.dealerRewardSumm / 100) * preparedValues.acceptSum; + /** + * @description + * если в selectDealerRewardCondition значение evo_reward_condition.Расчет вознаграждения от (evo_calc_reward_rules) = 100 000 001 (от суммы), + то DeliverySum= Размер АВ ЮЛ поставщика (tbxDealerRewardSumm) / (1+VAT) + иначе + если в selectDealerRewardCondition указана запись, у которой evo_reward_condition.evo_agency_agreementid. Стоимость ПЛ (evo_leasingobject_price) = 100 000 001 (с НДС), + то DeliverySum= Размер АВ ЮЛ поставщика (tbxDealerRewardSumm) /100 * (PreparedValues.PlPriceWithVAT - Discount*(1+VAT)), + иначе DeliverySum=значение поля Размер АВ ЮЛ поставщика (tbxDealerRewardSumm) /100 * Стоимость ПЛ с учетом скидки [AcceptSum] + */ + const selectDealerRewardCondition = this.getOption( + 'selectDealerRewardCondition', + ); + if (selectDealerRewardCondition?.evo_calc_reward_rules === 100_000_001) { + preparedValues.deliverySum = + values.dealerRewardSumm / (1 + valuesConstants.VAT); + } else if ( + selectDealerRewardCondition?.evo_agency_agreementidData + ?.evo_leasingobject_price === 100_000_001 + ) { + preparedValues.deliverySum = + (values.dealerRewardSumm / 100) * + ((preparedValues.plPriceWithVAT || 0) - + (preparedValues.discount || 0) * (1 + valuesConstants.VAT)); + } else { + preparedValues.deliverySum = + (values.dealerRewardSumm / 100) * preparedValues.acceptSum; + } - preparedValues.brokerSum = - (values.calcBrokerRewardSum / 100) * preparedValues.acceptSum; + /** + * @description + * если в selectCalcBrokerRewardCondition значение evo_reward_condition.Расчет вознаграждения от (evo_calc_reward_rules) = 100 000 001 (от суммы), + то BrokerSum= Размер АВ брокера (tbxCalcBrokerRewardSum) / (1+VAT) + иначе + если в selectCalcBrokerRewardCondition указана запись, у которой evo_reward_condition.evo_agency_agreementid. Стоимость ПЛ (evo_leasingobject_price) = 100 000 001 (с НДС), + то BrokerSum= Размер АВ брокера (tbxCalcBrokerRewardSum) /100 * (PreparedValues.PlPriceWithVAT - Discount*(1+VAT)) , + иначе BrokerSum= значение поля Размер АВ брокера (tbxCalcBrokerRewardSum)/100 * Стоимость ПЛ с учетом скидки [AcceptSum] + */ + const selectCalcBrokerRewardCondition = this.getOption( + 'selectCalcBrokerRewardCondition', + ); + if (selectCalcBrokerRewardCondition?.evo_calc_reward_rules === 100_000_001) { + preparedValues.brokerSum = + values.calcBrokerRewardSum / (1 + valuesConstants.VAT); + } else if ( + selectCalcBrokerRewardCondition?.evo_agency_agreementidData + ?.evo_leasingobject_price === 100_000_001 + ) { + preparedValues.brokerSum = + (values.calcBrokerRewardSum / 100) * + ((preparedValues.plPriceWithVAT || 0) - + (preparedValues.discount || 0) * (1 + valuesConstants.VAT)); + } else { + preparedValues.brokerSum = + (values.calcBrokerRewardSum / 100) * preparedValues.acceptSum; + } - preparedValues.brokerOfDeliverySum = - (values.dealerBrokerRewardSumm / 100) * preparedValues.acceptSum; + /** + * @description + * если в selectDealerBrokerRewardCondition значение evo_reward_condition.Расчет вознаграждения от (evo_calc_reward_rules) = 100 000 001 (от суммы), + то BrokerOfDeliverySum= Размер АВ брокера поставщика (tbxDealerBrokerRewardSumm) / (1+VAT) + иначе + если в selectDealerBrokerRewardCondition указана запись, у которой evo_reward_condition.evo_agency_agreementid. Стоимость ПЛ (evo_leasingobject_price) = 100 000 001 (с НДС), + то BrokerOfDeliverySum= Размер АВ брокера поставщика (tbxDealerBrokerRewardSumm) /100 * (PreparedValues.PlPriceWithVAT - Discount*(1+VAT)), + иначе BrokerOfDeliverySum= значение поля Размер АВ брокера поставщика (tbxDealerBrokerRewardSumm)/100 * Стоимость ПЛ с учетом скидки [AcceptSum] + */ + const selectDealerBrokerRewardCondition = this.getOption( + 'selectDealerBrokerRewardCondition', + ); + if ( + selectDealerBrokerRewardCondition?.evo_calc_reward_rules === 100_000_001 + ) { + preparedValues.brokerOfDeliverySum = + values.dealerBrokerRewardSumm / (1 + valuesConstants.VAT); + } else if ( + selectDealerBrokerRewardCondition?.evo_agency_agreementidData + ?.evo_leasingobject_price === 100_000_001 + ) { + preparedValues.brokerOfDeliverySum = + (values.dealerBrokerRewardSumm / 100) * + ((preparedValues.plPriceWithVAT || 0) - + (preparedValues.discount || 0) * (1 + valuesConstants.VAT)); + } else { + preparedValues.brokerOfDeliverySum = + (values.dealerBrokerRewardSumm / 100) * preparedValues.acceptSum; + } - preparedValues.financialDeptOfDeliverySum = - (values.finDepartmentRewardSumm / 100) * preparedValues.acceptSum; + /** + * @description + * если в selectFinDepartmentRewardCondtion значение evo_reward_condition.Расчет вознаграждения от (evo_calc_reward_rules) = 100 000 001 (от суммы), + то FinancialDeptOfDeliverySum= Размер АВ финотдела (tbxFinDepartmentRewardSumm) / (1+VAT) + иначе + если в selectFinDepartmentRewardCondtion указана запись, у которой evo_reward_condition.evo_agency_agreementid. Стоимость ПЛ (evo_leasingobject_price) = 100 000 001 (с НДС), + то FinancialDeptOfDeliverySum= Размер АВ финотдела (tbxFinDepartmentRewardSumm) /100 * (PreparedValues.PlPriceWithVAT - Discount*(1+VAT)), + иначе FinancialDeptOfDeliverySum= значение поля Размер АВ финотдела (tbxFinDepartmentRewardSumm)/100 * Стоимость ПЛ с учетом скидки [PreparedValue.AcceptSum] + */ + const selectFinDepartmentRewardCondtion = this.getOption( + 'selectFinDepartmentRewardCondtion', + ); + if ( + selectFinDepartmentRewardCondtion?.evo_calc_reward_rules === 100_000_001 + ) { + preparedValues.financialDeptOfDeliverySum = + values.finDepartmentRewardSumm / (1 + valuesConstants.VAT); + } else if ( + selectFinDepartmentRewardCondtion?.evo_agency_agreementidData + ?.evo_leasingobject_price === 100_000_001 + ) { + preparedValues.financialDeptOfDeliverySum = + (values.finDepartmentRewardSumm / 100) * + ((preparedValues.plPriceWithVAT || 0) - + (preparedValues.discount || 0) * (1 + valuesConstants.VAT)); + } else { + preparedValues.financialDeptOfDeliverySum = + (values.finDepartmentRewardSumm / 100) * preparedValues.acceptSum; + } if (values.importerRewardRub > 0) { preparedValues.importerSum = values.importerRewardRub; diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts index 70ab469..3ad52e4 100644 --- a/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts +++ b/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts @@ -132,6 +132,179 @@ const customConditions: Partial> = { 'Срок лизинга не соответствует таблице платежей. Необходимо изменить срок лизинга', }; }, + + //TODO: перенести в process/agents/validation + + /** + * @description + * Валидация: + * Если tbxDealerRewardSumm= 0 И в списке selectDealerRewardCondition есть запись, + * у которой evo_reward_condition.evo_agency_agreementid. Обязательная выплата АВ (evo_required_reward) = True, + * то поле tbxDealerRewardSumm обводить красной рамкой + * и выводить ошибку "Согласно Агентскому договору с данным ЮЛ поставщика обязательна выплата АВ. Заложите АВ в расчет" + */ + tbxDealerRewardSumm: calculationStore => { + const dealerRewardConditionOptions = calculationStore.getOptions( + 'selectDealerRewardCondition', + ); + const dealerRewardSumm = calculationStore.getValue('dealerRewardSumm'); + + const isValid = !( + dealerRewardSumm === 0 && + dealerRewardConditionOptions?.some( + x => x.evo_agency_agreementidData?.evo_required_reward, + ) + ); + + return { + isValid, + message: + 'Согласно Агентскому договору с данным ЮЛ поставщика обязательна выплата АВ. Заложите АВ в расчет', + }; + }, + /** + * @description + * Валидация + * Если tbxDealerBrokerRewardSumm= 0 И в списке selectDealerBrokerRewardCondition есть запись, + * у которой evo_reward_condition.evo_agency_agreementid. Обязательная выплата АВ (evo_required_reward) = True, + * то поле tbxDealerBrokerRewardSumm обводить красной рамкой + * и выводить ошибку "Согласно Агентскому договору с данным Брокером поставщика обязательна выплата АВ. Заложите АВ в расчет" + */ + tbxDealerBrokerRewardSumm: calculationStore => { + const dealerBrokerRewardConditionOptions = calculationStore.getOptions( + 'selectDealerBrokerRewardCondition', + ); + const dealerBrokerRewardSumm = calculationStore.getValue( + 'dealerBrokerRewardSumm', + ); + + const isValid = !( + dealerBrokerRewardSumm === 0 && + dealerBrokerRewardConditionOptions?.some( + x => x.evo_agency_agreementidData?.evo_required_reward, + ) + ); + + return { + isValid, + message: + 'Согласно Агентскому договору с данным Брокером поставщика обязательна выплата АВ. Заложите АВ в расчет', + }; + }, + + /** + * @description + * Если tbxIndAgentRewardSumm= 0 И в списке selectIndAgentRewardCondition есть запись, + * у которой evo_reward_condition.evo_agency_agreementid. Обязательная выплата АВ (evo_required_reward) = True, + * то поле tbxIndAgentRewardSumm обводить красной рамкой + * и выводить ошибку "Согласно Агентскому договору с данным Агентом ФЛ обязательна выплата АВ. Заложите АВ в расчет" + */ + tbxIndAgentRewardSumm: calculationStore => { + const indAgentRewardConditionOptions = calculationStore.getOptions( + 'selectIndAgentRewardCondition', + ); + const indAgentRewardSumm = calculationStore.getValue('indAgentRewardSumm'); + + const isValid = !( + indAgentRewardSumm === 0 && + indAgentRewardConditionOptions?.some( + x => x.evo_agency_agreementidData?.evo_required_reward, + ) + ); + + return { + isValid, + message: + 'Согласно Агентскому договору с данным Агентом ФЛ обязательна выплата АВ. Заложите АВ в расчет', + }; + }, + + /** + * @description + * Если tbxCalcDoubleAgentRewardSumm = 0 И в списке selectCalcDoubleAgentRewardCondition есть запись, + * у которой evo_reward_condition.evo_agency_agreementid. Обязательная выплата АВ (evo_required_reward) = True, + * то поле tbxCalcDoubleAgentRewardSumm обводить красной рамкой + * и выводить ошибку "Согласно Агентскому договору с данным Двойным агентом обязательна выплата АВ. Заложите АВ в расчет" + */ + tbxCalcDoubleAgentRewardSumm: calculationStore => { + const calcDoubleAgentRewardConditionOptions = calculationStore.getOptions( + 'selectCalcDoubleAgentRewardCondition', + ); + const calcDoubleAgentRewardSumm = calculationStore.getValue( + 'calcDoubleAgentRewardSumm', + ); + + const isValid = !( + calcDoubleAgentRewardSumm === 0 && + calcDoubleAgentRewardConditionOptions?.some( + x => x.evo_agency_agreementidData?.evo_required_reward, + ) + ); + + return { + isValid, + message: + 'Согласно Агентскому договору с данным Двойным агентом обязательна выплата АВ. Заложите АВ в расчет', + }; + }, + + /** + * @description + * Если tbxCalcBrokerRewardSum = 0 И в списке selectCalcBrokerRewardCondition есть запись, + * у которой evo_reward_condition.evo_agency_agreementid. Обязательная выплата АВ (evo_required_reward) = True, + * то поле tbxCalcBrokerRewardSum обводить красной рамкой + * и выводить ошибку "Согласно Агентскому договору с данным Брокером обязательна выплата АВ. Заложите АВ в расчет" + */ + tbxCalcBrokerRewardSum: calculationStore => { + const calcBrokerRewardConditionOptions = calculationStore.getOptions( + 'selectCalcBrokerRewardCondition', + ); + const calcBrokerRewardSum = calculationStore.getValue( + 'calcBrokerRewardSum', + ); + + const isValid = !( + calcBrokerRewardSum === 0 && + calcBrokerRewardConditionOptions?.some( + x => x.evo_agency_agreementidData?.evo_required_reward, + ) + ); + + return { + isValid, + message: + 'Согласно Агентскому договору с данным Брокером обязательна выплата АВ. Заложите АВ в расчет', + }; + }, + + /** + * @description + * Если tbxFinDepartmentRewardSumm = 0 И в списке selectFinDepartmentRewardCondtion есть запись, + * у которой evo_reward_condition.evo_agency_agreementid. Обязательная выплата АВ (evo_required_reward) = True, + * то поле tbxFinDepartmentRewardSumm обводить красной рамкой + * и выводить ошибку "Согласно Агентскому договору с данным Финотделом обязательна выплата АВ. Заложите АВ в расчет" + */ + tbxFinDepartmentRewardSumm: calculationStore => { + const finDepartmentRewardCondtionOptions = calculationStore.getOptions( + 'selectFinDepartmentRewardCondtion', + ); + const finDepartmentRewardSumm = calculationStore.getValue( + 'finDepartmentRewardSumm', + ); + + const isValid = !( + finDepartmentRewardSumm === 0 && + finDepartmentRewardCondtionOptions?.some( + x => x.evo_agency_agreementidData?.evo_required_reward, + ) + ); + + return { + isValid, + message: + 'Согласно Агентскому договору с данным Финотделом обязательна выплата АВ. Заложите АВ в расчет', + }; + }, }; const elementsValidations: Partial< diff --git a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts index 3bbad4b..c1953ff 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts @@ -21,6 +21,7 @@ import { CRMEntity, IAccount, IEvoGraph, + IEvoRewardCondition, IEvoTown, IQuote, } from 'core/services/CrmService/types/entities'; @@ -72,6 +73,39 @@ function getObjectRegistration(recalcWithRevision: boolean, quote: IQuote) { : quote.evo_object_registration; } +async function getRewardSumm( + reward_conditionid: string, + quote: IQuote, + quoteRewardSummName: string, + quoteRewardTotalName: string, +) { + if (reward_conditionid) { + const { evo_reward_condition } = await CrmService.getCRMEntities< + 'evo_reward_condition', + IEvoRewardCondition + >({ + query: gql` + query ($id: Uuid!) { + evo_reward_condition(evo_reward_conditionid: $id) { + evo_calc_reward_rules + } + } + `, + variables: { + id: reward_conditionid, + }, + }); + + if (evo_reward_condition?.evo_calc_reward_rules === 100_000_001) { + return quote[quoteRewardSummName]; + } else { + return quote[quoteRewardTotalName]; + } + } else { + return quote[quoteRewardTotalName]; + } +} + const loadKpReaction: IReactionEffect = calculationStore => ({ expression: () => { const { quote } = calculationStore.values; @@ -164,8 +198,6 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ // agents //TODO: refactor - const { indAgent, calcBroker, calcFinDepartment } = - calculationStore.values; let { indAgentRewardCondition, @@ -175,22 +207,72 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ finDepartmentRewardCondtion, finDepartmentRewardSumm, } = calculationStore.values; + + const indAgent = calculationStore.getValue('indAgent'); if (indAgent === quote.evo_agent_accountid) { indAgentRewardCondition = quote.evo_agent_reward_conditionid; - indAgentRewardSumm = quote.evo_agent_reward_total; + + indAgentRewardSumm = await getRewardSumm( + //@ts-ignore + quote.evo_agent_reward_conditionid, + quote, + 'evo_agent_reward_summ', + 'evo_agent_reward_total', + ); } + const calcBroker = calculationStore.getValue('calcBroker'); if (calcBroker === quote.evo_broker_accountid) { calcBrokerRewardCondition = quote.evo_broker_reward_conditionid; - calcBrokerRewardSum = quote.evo_broker_reward_total; + + calcBrokerRewardSum = await getRewardSumm( + //@ts-ignore + quote.evo_broker_reward_conditionid, + quote, + 'evo_broker_reward_summ', + 'evo_broker_reward_total', + ); } + const calcFinDepartment = + calculationStore.getValue('calcFinDepartment'); if (calcFinDepartment === quote.evo_fin_department_accountid) { finDepartmentRewardCondtion = quote.evo_fin_department_reward_conditionid; - finDepartmentRewardSumm = quote.evo_fin_department_reward_total; + + finDepartmentRewardSumm = await getRewardSumm( + //@ts-ignore + quote.evo_fin_department_reward_conditionid, + quote, + 'evo_fin_department_reward_summ', + 'evo_fin_department_reward_total', + ); } + const dealerRewardSumm = await getRewardSumm( + //@ts-ignore + quote.evo_dealer_reward_conditionid, + quote, + 'evo_dealer_reward_summ', + 'evo_dealer_reward_total', + ); + + const dealerBrokerRewardSumm = await getRewardSumm( + //@ts-ignore + quote.evo_dealer_broker_reward_conditionid, + quote, + 'evo_dealer_broker_reward_summ', + 'evo_dealer_broker_reward_total', + ); + + const calcDoubleRewardSumm = await getRewardSumm( + //@ts-ignore + quote.evo_double_agent_reward_conditionid, + quote, + 'evo_double_agent_reward_summ', + 'evo_double_agent_reward_total', + ); + const agentsValues = { indAgentRewardCondition, indAgentRewardSumm, @@ -198,6 +280,9 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ calcBrokerRewardSum, finDepartmentRewardCondtion, finDepartmentRewardSumm, + dealerRewardSumm, + dealerBrokerRewardSumm, + calcDoubleRewardSumm, }; // agents diff --git a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts index c24fb8c..cd40e60 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts @@ -46,16 +46,16 @@ const mapKPtoValues: Partial> = { evo_supplier_accountid: 'dealer', // evo_dealer_person_accountid: 'dealerPerson', evo_dealer_reward_conditionid: 'dealerRewardCondition', - evo_dealer_reward_total: 'dealerRewardSumm', + // evo_dealer_reward_total: 'dealerRewardSumm', evo_dealer_broker_accountid: 'dealerBroker', evo_dealer_broker_reward_conditionid: 'dealerBrokerRewardCondition', - evo_dealer_broker_reward_total: 'dealerBrokerRewardSumm', + // evo_dealer_broker_reward_total: 'dealerBrokerRewardSumm', // evo_agent_accountid: indAgent, // evo_agent_reward_conditionid: 'indAgentRewardCondition', // evo_agent_reward_total: indAgentRewardSumm, evo_double_agent_accountid: 'calcDoubleAgent', evo_double_agent_reward_conditionid: 'calcDoubleAgentRewardCondition', - evo_double_agent_reward_total: 'calcDoubleAgentRewardSumm', + // evo_double_agent_reward_total: 'calcDoubleAgentRewardSumm', // evo_broker_accountid: 'calcBroker', // evo_broker_reward_conditionid: 'calcBrokerRewardCondition', // evo_broker_reward_total: 'calcBrokerRewardSum', diff --git a/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts index 5e1d7d9..4360187 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts @@ -220,201 +220,6 @@ const reactionEffects: IReactionEffect[] = [ }, }), - calculationStore => ({ - expression: () => { - const { indAgentRewardSumm } = calculationStore.values; - return indAgentRewardSumm; - }, - effect: indAgentRewardSumm => { - const indAgentRewardCondition = calculationStore.getOption( - 'selectIndAgentRewardCondition', - ); - if (indAgentRewardCondition) { - if (indAgentRewardCondition.evo_reward_summ) { - if ( - parseFloat(indAgentRewardSumm) > - indAgentRewardCondition.evo_reward_summ - ) { - calculationStore.setValidation('tbxIndAgentRewardSumm', false); - openNotification({ - type: 'error', - message: 'Ошибка', - description: - 'Вознаграждение агента ФЛ указано больше условия по агентскому договору! \nЗначение установлено по условию договора.', - }); - return; - } else if ( - !indAgentRewardCondition.evo_reduce_reward && - indAgentRewardCondition.evo_reward_summ - ) { - if ( - parseFloat(indAgentRewardSumm) < - indAgentRewardCondition.evo_reward_summ - ) { - calculationStore.setValidation('tbxIndAgentRewardSumm', false); - openNotification({ - type: 'error', - message: 'Ошибка', - description: - 'Вознаграждение агента ФЛ указано меньше условия по агентскому договору! \nЗначение установлено по условию договора.', - }); - return; - } - } - calculationStore.setValidation('tbxIndAgentRewardSumm', true); - } - } - }, - }), - - calculationStore => ({ - expression: () => { - const { calcDoubleAgentRewardSumm } = calculationStore.values; - return calcDoubleAgentRewardSumm; - }, - effect: calcDoubleAgentRewardSumm => { - const selectCalcDoubleAgentRewardCondition = calculationStore.getOption( - 'selectCalcDoubleAgentRewardCondition', - ); - if (selectCalcDoubleAgentRewardCondition) { - if (selectCalcDoubleAgentRewardCondition.evo_reward_summ) { - if ( - parseFloat(calcDoubleAgentRewardSumm) > - selectCalcDoubleAgentRewardCondition.evo_reward_summ - ) { - calculationStore.setValidation( - 'tbxCalcDoubleAgentRewardSumm', - false, - ); - openNotification({ - type: 'error', - message: 'Ошибка', - description: - 'Вознаграждение двойного агента указано больше условия по агентскому договору! \nЗначение установлено по условию договора.', - }); - return; - } else if ( - !selectCalcDoubleAgentRewardCondition.evo_reduce_reward && - selectCalcDoubleAgentRewardCondition.evo_reward_summ - ) { - if ( - parseFloat(calcDoubleAgentRewardSumm) < - selectCalcDoubleAgentRewardCondition.evo_reward_summ - ) { - calculationStore.setValidation( - 'tbxCalcDoubleAgentRewardSumm', - false, - ); - openNotification({ - type: 'error', - message: 'Ошибка', - description: - 'Вознаграждение двойного агента указано меньше условия по агентскому договору! \nЗначение установлено по условию договора.', - }); - return; - } - } - calculationStore.setValidation('tbxCalcDoubleAgentRewardSumm', true); - } - } - }, - }), - - calculationStore => ({ - expression: () => { - const { calcBrokerRewardSum } = calculationStore.values; - return calcBrokerRewardSum; - }, - effect: calcBrokerRewardSum => { - const selectCalcBrokerRewardCondition = calculationStore.getOption( - 'selectCalcBrokerRewardCondition', - ); - if (selectCalcBrokerRewardCondition) { - if (selectCalcBrokerRewardCondition.evo_reward_summ) { - if ( - parseFloat(calcBrokerRewardSum) > - selectCalcBrokerRewardCondition.evo_reward_summ - ) { - calculationStore.setValidation('tbxCalcBrokerRewardSum', false); - openNotification({ - type: 'error', - message: 'Ошибка', - description: - 'Вознаграждение брокера указано больше условия по агентскому договору! \nЗначение установлено по условию договора.', - }); - return; - } else if ( - !selectCalcBrokerRewardCondition.evo_reduce_reward && - selectCalcBrokerRewardCondition.evo_reward_summ - ) { - if ( - parseFloat(calcBrokerRewardSum) < - selectCalcBrokerRewardCondition.evo_reward_summ - ) { - calculationStore.setValidation('tbxCalcBrokerRewardSum', false); - openNotification({ - type: 'error', - message: 'Ошибка', - description: - 'Вознаграждение брокера указано меньше условия по агентскому договору! \nЗначение установлено по условию договора.', - }); - return; - } - } - calculationStore.setValidation('tbxCalcBrokerRewardSum', true); - } - } - }, - }), - - calculationStore => ({ - expression: () => { - const { finDepartmentRewardSumm } = calculationStore.values; - return finDepartmentRewardSumm; - }, - effect: finDepartmentRewardSumm => { - const selectFinDepartmentRewardCondtion = calculationStore.getOption( - 'selectFinDepartmentRewardCondtion', - ); - if ( - selectFinDepartmentRewardCondtion && - selectFinDepartmentRewardCondtion.evo_reward_summ - ) { - if ( - parseFloat(finDepartmentRewardSumm) > - selectFinDepartmentRewardCondtion.evo_reward_summ - ) { - calculationStore.setValidation('tbxFinDepartmentRewardSumm', false); - openNotification({ - type: 'error', - message: 'Ошибка', - description: - 'Вознаграждение финотдела указано больше условия по агентскому договору! \nЗначение установлено по условию договора.', - }); - return; - } else if ( - !selectFinDepartmentRewardCondtion.evo_reduce_reward && - selectFinDepartmentRewardCondtion.evo_reward_summ - ) { - if ( - parseFloat(finDepartmentRewardSumm) < - selectFinDepartmentRewardCondtion.evo_reward_summ - ) { - calculationStore.setValidation('tbxFinDepartmentRewardSumm', false); - openNotification({ - type: 'error', - message: 'Ошибка', - description: - 'Вознаграждение финотдела указано меньше условия по агентскому договору! \nЗначение установлено по условию договора.', - }); - return; - } - } - calculationStore.setValidation('tbxFinDepartmentRewardSumm', true); - } - }, - }), - calculationStore => ({ expression: () => { const { leaseObjectUsed } = calculationStore.values; @@ -807,54 +612,6 @@ const reactionEffects: IReactionEffect[] = [ }, }), - calculationStore => ({ - expression: () => { - const { dealerBrokerRewardSumm } = calculationStore.values; - return dealerBrokerRewardSumm; - }, - effect: dealerBrokerRewardSumm => { - const dealerBrokerRewardCondition = calculationStore.getOption( - 'selectDealerBrokerRewardCondition', - ); - if (dealerBrokerRewardCondition) { - if (dealerBrokerRewardCondition.evo_reward_summ) { - if ( - parseFloat(dealerBrokerRewardSumm) > - dealerBrokerRewardCondition.evo_reward_summ - ) { - calculationStore.setValidation('tbxDealerBrokerRewardSumm', false); - openNotification({ - type: 'error', - message: 'Ошибка', - description: - 'Вознаграждение брокера поставщика указано больше условия по агентскому договору! \nЗначение установлено по условию договора.', - }); - return; - } - } - if ( - !dealerBrokerRewardCondition.evo_reduce_reward && - dealerBrokerRewardCondition.evo_reward_summ - ) { - if ( - parseFloat(dealerBrokerRewardSumm) < - dealerBrokerRewardCondition.evo_reward_summ - ) { - calculationStore.setValidation('tbxDealerBrokerRewardSumm', false); - openNotification({ - type: 'error', - message: 'Ошибка', - description: - 'Вознаграждение брокера поставщика указано меньше условия по агентскому договору! \nЗначение установлено по условию договора.', - }); - return; - } - } - calculationStore.setValidation('tbxDealerBrokerRewardSumm', true); - } - }, - }), - calculationStore => ({ expression: () => { const { configuration } = calculationStore.values; diff --git a/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts index 1bab417..224c37d 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts @@ -1,4 +1,10 @@ import { gql } from '@apollo/client'; +import { + fillCalcBroker, + fillCalcDoubleAgent, + fillFinDepartment, + fillIndAgent, +} from 'client/process/agents/fill-elements'; import CrmService from 'core/services/CrmService'; import { quotesByLeadQuery } from 'core/services/CrmService/graphql/query/quote'; import { @@ -28,14 +34,6 @@ export default [ calculationStore.setFilter('selectOpportunity', undefined); calculationStore.setValue('quote', null); calculationStore.setOptions('selectQuote', []); - calculationStore.setOptions('selectIndAgent', []); - calculationStore.setValue('indAgent', null); - calculationStore.setOptions('selectCalcDoubleAgent', []); - calculationStore.setValue('calcDoubleAgent', null); - calculationStore.setOptions('selectCalcBroker', []); - calculationStore.setValue('calcBroker', null); - calculationStore.setOptions('selectCalcFinDepartment', []); - calculationStore.setValue('calcFinDepartment', null); return; } @@ -69,126 +67,10 @@ export default [ calculationStore.setValue('quote', null); } - if (lead?.evo_agent_accountid) { - CrmService.getCRMOptions<'accountOptions', IAccount>({ - query: gql` - query selectIndAgent($evo_agent_accountid: Uuid!) { - accountOptions: account(accountid: $evo_agent_accountid) { - accountid - name - } - } - `, - variables: { - evo_agent_accountid: lead.evo_agent_accountid, - }, - }).then(({ accountOptions }) => { - if (accountOptions && accountOptions.length > 0) { - calculationStore.setOptions('selectIndAgent', accountOptions); - calculationStore.setValue('indAgent', accountOptions[0].accountid); - } else { - calculationStore.setValue('indAgent', null); - calculationStore.setOptions('selectIndAgent', []); - } - }); - } else { - calculationStore.setValue('indAgent', null); - calculationStore.setOptions('selectIndAgent', []); - } - - if (lead?.evo_double_agent_accountid) { - CrmService.getCRMOptions<'accountOptions', IAccount>({ - query: gql` - query selectCalcDoubleAgent($evo_double_agent_accountid: Uuid!) { - accountOptions: account(accountid: $evo_double_agent_accountid) { - accountid - name - } - } - `, - variables: { - evo_double_agent_accountid: lead.evo_double_agent_accountid, - }, - }).then(({ accountOptions }) => { - if (accountOptions && accountOptions.length > 0) { - calculationStore.setOptions( - 'selectCalcDoubleAgent', - accountOptions, - ); - calculationStore.setValue( - 'calcDoubleAgent', - accountOptions[0].accountid, - ); - } else { - calculationStore.setValue('calcDoubleAgent', null); - calculationStore.setOptions('selectCalcDoubleAgent', []); - } - }); - } else { - calculationStore.setValue('calcDoubleAgent', null); - calculationStore.setOptions('selectCalcDoubleAgent', []); - } - - if (lead?.evo_broker_accountid) { - CrmService.getCRMOptions<'accountOptions', IAccount>({ - query: gql` - query selectCalcBroker($evo_broker_accountid: Uuid!) { - accountOptions: account(accountid: $evo_broker_accountid) { - accountid - name - } - } - `, - variables: { - evo_broker_accountid: lead.evo_broker_accountid, - }, - }).then(({ accountOptions }) => { - if (accountOptions && accountOptions.length > 0) { - calculationStore.setOptions('selectCalcBroker', accountOptions); - calculationStore.setValue( - 'calcBroker', - accountOptions[0].accountid, - ); - } - }); - } else { - calculationStore.setValue('calcBroker', null); - calculationStore.setOptions('selectCalcBroker', []); - } - - if (lead?.evo_fin_department_accountid) { - CrmService.getCRMOptions<'accountOptions', IAccount>({ - query: gql` - query selectCalcFinDepartment( - $evo_fin_department_accountid: Uuid! - ) { - accountOptions: account( - accountid: $evo_fin_department_accountid - ) { - accountid - name - } - } - `, - variables: { - evo_fin_department_accountid: lead.evo_fin_department_accountid, - }, - }).then(({ accountOptions }) => { - if (accountOptions && accountOptions.length > 0) { - calculationStore.setOptions( - 'selectCalcFinDepartment', - accountOptions, - ); - calculationStore.setValue( - 'calcFinDepartment', - accountOptions[0].accountid, - ); - } - }); - } else { - calculationStore.setValue('calcFinDepartment', null); - calculationStore.setOptions('selectCalcFinDepartment', []); - } + fillIndAgent.call(calculationStore, lead); + fillCalcDoubleAgent.call(calculationStore, lead); + fillCalcBroker.call(calculationStore, lead); + fillFinDepartment.call(calculationStore, lead); }, }), @@ -303,6 +185,13 @@ export default [ evo_reward_summ evo_reduce_reward evo_agency_agreementid + evo_agency_agreementidData { + evo_reward_without_other_agent + evo_required_reward + evo_leasingobject_price + } + evo_min_reward_summ + evo_calc_reward_rules } } `, @@ -369,6 +258,13 @@ export default [ evo_reward_summ evo_reduce_reward evo_agency_agreementid + evo_agency_agreementidData { + evo_reward_without_other_agent + evo_required_reward + evo_leasingobject_price + } + evo_min_reward_summ + evo_calc_reward_rules } } `, @@ -437,6 +333,13 @@ export default [ evo_reward_summ evo_reduce_reward evo_agency_agreementid + evo_agency_agreementidData { + evo_reward_without_other_agent + evo_required_reward + evo_leasingobject_price + } + evo_min_reward_summ + evo_calc_reward_rules } } `, @@ -503,6 +406,13 @@ export default [ evo_reward_summ evo_reduce_reward evo_agency_agreementid + evo_agency_agreementidData { + evo_reward_without_other_agent + evo_required_reward + evo_leasingobject_price + } + evo_min_reward_summ + evo_calc_reward_rules } } `, @@ -681,6 +591,13 @@ export default [ evo_reward_summ evo_reduce_reward evo_agency_agreementid + evo_agency_agreementidData { + evo_reward_without_other_agent + evo_required_reward + evo_leasingobject_price + } + evo_min_reward_summ + evo_calc_reward_rules } } `, @@ -704,6 +621,7 @@ export default [ 'selectDealerBrokerRewardCondition', ElementStatus.Disabled, ); + calculationStore.setOptions('selectDealerBrokerRewardCondition', []); } }, options: { @@ -746,6 +664,13 @@ export default [ evo_reward_summ evo_reduce_reward evo_agency_agreementid + evo_agency_agreementidData { + evo_reward_without_other_agent + evo_required_reward + evo_leasingobject_price + } + evo_min_reward_summ + evo_calc_reward_rules } } `, @@ -770,6 +695,7 @@ export default [ 'selectDealerRewardCondition', ElementStatus.Disabled, ); + calculationStore.setOptions('selectDealerRewardCondition', []); } }, options: { diff --git a/src/client/stores/CalculationStore/index.ts b/src/client/stores/CalculationStore/index.ts index 36aafcc..dd100a2 100644 --- a/src/client/stores/CalculationStore/index.ts +++ b/src/client/stores/CalculationStore/index.ts @@ -1,4 +1,5 @@ import leasebackReactions from 'client/process/agents/leaseback'; +import agentsReactions from 'client/process/agents/reactions'; import injectBonusesReaction from 'client/process/bonuses/reactions'; import { injectConfiguratorReactions } from 'client/process/configurator/reactions'; import { injectFinGapReactions } from 'client/process/fingap/reactions'; @@ -44,6 +45,7 @@ injectUsedWhthVATReactions(CalculationStore); injectConfiguratorReactions(CalculationStore); injectSubsidyReactions(CalculationStore); injectBonusesReaction(CalculationStore); +agentsReactions(CalculationStore); leasebackReactions(CalculationStore); whenEffects.map(whenEffectBuilder => { diff --git a/src/core/services/CrmService/graphql/query/quote/fragments/quoteFields.graphql b/src/core/services/CrmService/graphql/query/quote/fragments/quoteFields.graphql index 4701cdf..0d3b50e 100644 --- a/src/core/services/CrmService/graphql/query/quote/fragments/quoteFields.graphql +++ b/src/core/services/CrmService/graphql/query/quote/fragments/quoteFields.graphql @@ -43,16 +43,22 @@ fragment quoteFields on quote { evo_double_agent_accountid evo_dealer_reward_conditionid evo_dealer_reward_total + evo_dealer_reward_summ evo_dealer_broker_reward_conditionid evo_dealer_broker_reward_total + evo_dealer_broker_reward_summ evo_agent_reward_conditionid evo_agent_reward_total + evo_agent_reward_summ evo_double_agent_reward_conditionid evo_double_agent_reward_total + evo_double_agent_reward_summ evo_broker_reward_conditionid evo_broker_reward_total + evo_broker_reward_summ evo_fin_department_reward_conditionid evo_fin_department_reward_total + evo_fin_department_reward_summ evo_broker_accountid evo_fin_department_accountid diff --git a/src/core/services/CrmService/graphql/query/quote/options/main_options.graphql b/src/core/services/CrmService/graphql/query/quote/options/main_options.graphql index 6909525..628a68a 100644 --- a/src/core/services/CrmService/graphql/query/quote/options/main_options.graphql +++ b/src/core/services/CrmService/graphql/query/quote/options/main_options.graphql @@ -59,6 +59,13 @@ query GetMainOptionsForKP( evo_name evo_reward_summ evo_reduce_reward + evo_agency_agreementidData { + evo_reward_without_other_agent + evo_required_reward + evo_leasingobject_price + } + evo_min_reward_summ + evo_calc_reward_rules } selectDealerBrokerRewardCondition: evo_reward_conditions( evo_agent_accountid: $dealer_broker_accountid @@ -71,6 +78,13 @@ query GetMainOptionsForKP( evo_name evo_reward_summ evo_reduce_reward + evo_agency_agreementidData { + evo_reward_without_other_agent + evo_required_reward + evo_leasingobject_price + } + evo_min_reward_summ + evo_calc_reward_rules } # selectIndAgentRewardCondition: evo_reward_conditions( # evo_agent_accountid: $ind_agent_accountid @@ -96,6 +110,13 @@ query GetMainOptionsForKP( evo_name evo_reward_summ evo_reduce_reward + evo_agency_agreementidData { + evo_reward_without_other_agent + evo_required_reward + evo_leasingobject_price + } + evo_min_reward_summ + evo_calc_reward_rules } # calcBrokerRewardCondition: evo_reward_conditions( # evo_agent_accountid: $broker_accountid diff --git a/src/core/services/CrmService/graphql/schema.graphql b/src/core/services/CrmService/graphql/schema.graphql index 2f81c39..c310c4b 100644 --- a/src/core/services/CrmService/graphql/schema.graphql +++ b/src/core/services/CrmService/graphql/schema.graphql @@ -74,7 +74,7 @@ type Query { evo_client_types(statecode: Int): [evo_client_type] 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, statecode: Int): [evo_contract] + evo_contracts(evo_accountid: Uuid, evo_name: String, orderby: OrderByInput, statecode: Int): [evo_contract] evo_countries(evo_code_numeric: String): [evo_countryGraphQL] evo_country(evo_countryid: Uuid!): evo_countryGraphQL evo_currencychanges(evo_coursedate_param: DateParamInput, evo_ref_transactioncurrency: Uuid, statecode: Int): [evo_currencychange] @@ -108,6 +108,7 @@ type Query { """Регион. statecode по умолчанию 0""" evo_regions(evo_businessunit_evolution: Boolean, evo_creditregistry_id: Int, statecode: Int): [evo_region] + evo_request_client(evo_request_clientid: Uuid!): evo_request_client evo_request_payment(evo_request_paymentid: Uuid!): evo_request_payment evo_request_payments(evo_id: String, evo_name: String, statecode: Int): [evo_request_payment] evo_reward_condition(evo_reward_conditionid: Uuid!): evo_reward_condition @@ -168,15 +169,24 @@ type Mutation { by(systemuserid: Uuid): MutationBy } -type evo_subject_incident { +type evo_request_client { createdon: DateTime - evo_group: Int - evo_groupname: String - evo_name: String - evo_subjectid: Uuid - evo_subject_incidentid: Uuid - evo_type_incident: Int - evo_type_incidentname: String + evo_accountid: Uuid + evo_accountidData: account + evo_caseorigincode: Int + evo_caseorigincodename: String + evo_client_request_text: String + evo_comment: String + evo_documents: [evo_document] + evo_number: String + evo_owner_systemuserid: Uuid + evo_owner_systemuseridData: systemuser + evo_phonecallid: Uuid + evo_request_clientid: Uuid + evo_statuscodeid: Uuid + evo_statuscodeidData: evo_statuscode + evo_storage: String + incidents: [incidentGraphQL] link: String modifiedon: DateTime toObjectString: String @@ -224,12 +234,30 @@ input GuidParamInput { """The built-in `Decimal` scalar type.""" scalar Decimal +type evo_subject_incident { + createdon: DateTime + evo_group: Int + evo_groupname: String + evo_name: String + evo_subjectid: Uuid + evo_subject_incidentid: Uuid + evo_type_incident: Int + evo_type_incidentname: String + link: String + modifiedon: DateTime + toObjectString: String +} + type incidentGraphQL { + caseorigincode: Int createdon: DateTime customerid: Uuid customerid_account: Uuid customerid_contact: Uuid description: String + evo_accountid_new: Uuid + evo_cession_opportunityid: Uuid + evo_contracts: [evo_contract] evo_fast_advice: Boolean evo_plan_execut_date: DateTime evo_statuscodeid: Uuid @@ -244,7 +272,10 @@ type incidentGraphQL { modifiedon: DateTime ownerid: Uuid owneridData: systemuser + ownerid_systemuser: Uuid + ownerid_team: Uuid subjectid: Uuid + subjectidData: subjectGraphQL ticketnumber: String title: String toObjectString: String @@ -404,9 +435,11 @@ type account { evo_orglegalformid: Uuid evo_orglegalformidData: evo_orglegalform evo_osago_with_kasko: Boolean + evo_request_clients: [evo_request_client] evo_return_leasing_dealer: Boolean evo_smb_category: Int evo_smb_issue_date: DateTime + evo_special_accounting: Int evo_state_actuality_date: DateTime evo_state_liquidation_date: DateTime evo_state_registration_date: DateTime @@ -417,6 +450,7 @@ type account { evo_tax_system: Int evo_type_ins_policy: [Int!] evo_unscrupulous_supplier: Boolean + incidents: [incidentGraphQL] link: String modifiedon: DateTime name: String @@ -508,6 +542,7 @@ type evo_addproduct_type { evo_datefrom: DateTime evo_dateto: DateTime evo_description: String + evo_equipment_1_name: String evo_equip_cost: Decimal evo_gibdd_region: Boolean evo_graph_price: Decimal @@ -591,6 +626,7 @@ type evo_insurance_period { evo_age_drivers: Int evo_base_reward_factor: Decimal evo_base_reward_rub: Decimal + evo_calc_dateend: DateTime evo_change_insurer_accountid: Uuid evo_close: Boolean evo_comment: String @@ -666,17 +702,30 @@ type evo_addproduct { evo_addproductnumberidData: evo_addproductnumber evo_addproduct_typeid: Uuid evo_addproduct_typeidData: evo_addproduct_type + evo_contractid: Uuid + evo_cs_actualdate: DateTime + evo_date_instal: DateTime + evo_date_instal_cancel: DateTime evo_deactivation_date: DateTime evo_fuel_card_currency_limit_check: Boolean evo_fuel_card_limit_check: Boolean evo_fuel_card_limit_used: Decimal + evo_id_request_instal: String + evo_issue_date_plan: DateTime + evo_issue_owner_salon: String + evo_issue_tel_salon: String evo_leasingobjectid: Uuid evo_name: String evo_provider_accountid: Uuid evo_provider_accountidData: account + evo_provider_contact_info: String + evo_provider_phone_number: String evo_request_instal_message: String + evo_request_instal_path: String evo_service_contactid: Uuid + evo_setting_date: DateTime evo_telematics_number: String + evo_telematics_pin: String evo_validity_from: DateTime modifiedon: DateTime toObjectString: String @@ -862,6 +911,7 @@ type lead { evo_new_client: String evo_opportunityid: Uuid evo_opportunityidData: opportunity + evo_scheduled_callid: Uuid evo_statuscodeid: Uuid evo_supplier_accountid: Uuid evo_utm_campaign: String @@ -870,6 +920,7 @@ type lead { evo_utm_source: String evo_utm_term: String fullname: String + jobtitle: String leadid: Uuid leadsourcecode: Int link: String @@ -896,6 +947,7 @@ type opportunity { evo_all_credit_evoprofi: Decimal evo_all_credit_evosmart: Decimal evo_approvallogs: [evo_approvallog] + evo_assignor_accountid: Uuid evo_businessunitid: Uuid evo_businessunitidData: businessunit evo_check_type: [Int!] @@ -1416,10 +1468,13 @@ type evo_scheduled_call { createdon: DateTime evo_accountid: Uuid evo_channel: String + evo_comment: String evo_company_name: String + evo_contact_jobtitle: String evo_contact_lastname: String evo_contact_name: String evo_inn: String + evo_leadid: Uuid evo_name: String evo_note: String evo_scheduled_callid: Uuid @@ -1576,6 +1631,7 @@ type evo_contract { evo_contract_status_1cname: String evo_contract_status_change_date_in_crm: DateTime evo_contract_status_date_1c: DateTime + evo_cre_uuid: String evo_dateend: DateTime evo_date_of_pledge_claim: DateTime evo_date_of_pledge_leasobject: DateTime @@ -1608,6 +1664,7 @@ type evo_contract { evo_discount_supplier_currency: Decimal evo_docdate: DateTime evo_docdate_dkp: DateTime + evo_documents: [evo_document] evo_dogovortype: Int evo_dog_credit: Decimal evo_double_agent_accountid: Uuid @@ -1642,6 +1699,7 @@ type evo_contract { evo_first_payment_rub: Decimal evo_first_payment_rub_without_subsidy: Decimal evo_forwarder_contactid: Uuid + evo_for_export_cre: Boolean evo_fuel_card_addproductid: Uuid evo_fuel_card_addproduct_typeid: Uuid evo_graphs(statecode: Int): [evo_graph] @@ -1659,6 +1717,9 @@ type evo_contract { evo_issue_date_buh: DateTime evo_issue_place_addressid: Uuid evo_issue_without_pay: Boolean + evo_issue_without_pay_comm: String + evo_last_formation_cre_date: DateTime + evo_last_formation_cre_status: Int evo_last_payment_redemption: Boolean evo_leasingobjectid: Uuid evo_leasingobjectidData: evo_leasingobject @@ -1994,6 +2055,7 @@ type evo_address { evo_federal_district: String evo_fias: Boolean evo_fias_code: String + evo_fias_id: String evo_fias_level: Int evo_flat: String evo_flat_type: String @@ -2004,6 +2066,8 @@ type evo_address { evo_house_fias_id: String evo_house_type: String evo_house_type_full: String + evo_okato: String + evo_oktmo: String evo_postal_box: String evo_postal_code: String evo_region: String @@ -2031,9 +2095,12 @@ type systemuser { businessunitid: Uuid businessunitidData: businessunit createdon: DateTime + defaultmailbox: Uuid domainname: String + evo_available_assignment_director: Boolean evo_baseproducts(statecode: Int): [evo_baseproduct] evo_callrecords_access: Boolean + evo_can_export_cre: Boolean evo_can_import_sheduled_calls: Boolean evo_datebirth: DateTime evo_employee_id: String @@ -2122,6 +2189,7 @@ type evo_agency_agreement { evo_agent_accountid: Uuid evo_agent_accountidData: account evo_agent_type: Int + evo_agreement_date: DateTime evo_bank_detailsid: Uuid evo_boss_comment: String evo_boss_decision: Int @@ -2139,12 +2207,14 @@ type evo_agency_agreement { evo_name: String evo_new_version: Boolean evo_number: Int + evo_pay_period: Int evo_region_director_comment: String evo_region_director_decision: Int evo_required_reward: Boolean evo_reward_without_other_agent: Boolean evo_select_lp: Boolean evo_select_vin: Boolean + evo_service_period: Int evo_signer_systemuserid: Uuid evo_statuscodeid: Uuid evo_storage: String @@ -2178,6 +2248,7 @@ type evo_addcontract { evo_add_bonus_summ: Decimal evo_add_director_bonus: Decimal evo_add_region_director_bonus: Decimal + evo_agent_reward: Decimal evo_agent_reward_summ: Decimal evo_age_drivers: Int evo_age_drivers_new: Int @@ -2192,6 +2263,7 @@ type evo_addcontract { evo_base_bonus: Decimal evo_base_calc_pay: Decimal evo_base_new: String + evo_broker_reward: Decimal evo_broker_reward_summ: Decimal evo_businessunitid: Uuid evo_calculation_method: Int @@ -2221,6 +2293,7 @@ type evo_addcontract { evo_date_addcontract: DateTime evo_date_calculation_done: DateTime evo_date_offset_change: Boolean + evo_date_offset_type: Int evo_deadline_date: DateTime evo_dealer_broker_accountid: Uuid evo_dealer_broker_accountid_new: Uuid @@ -2240,6 +2313,7 @@ type evo_addcontract { evo_dealer_person_reward_summ_new: Decimal evo_deviation_investments_withoutnds: Decimal evo_deviation_irr: Decimal + evo_deviation_irr_change: Boolean evo_dgo_price: Decimal evo_dgo_price_new: Decimal evo_director_bonus: Decimal @@ -2249,6 +2323,7 @@ type evo_addcontract { evo_discount_supplier_currency_new: Decimal evo_dog_credit: Decimal evo_dog_credit_new: Decimal + evo_double_agent_reward: Decimal evo_double_agent_reward_summ: Decimal evo_driving_axle: String evo_driving_axle_new: String @@ -2276,8 +2351,10 @@ type evo_addcontract { evo_equip_price_new: Decimal evo_exp_drivers: Int evo_exp_drivers_new: Int + evo_fin_department_reward: Decimal evo_fin_department_reward_conditionid: Uuid evo_fin_department_reward_conditionid_new: Uuid + evo_fin_department_reward_new: Decimal evo_fin_department_reward_summ: Decimal evo_fin_department_reward_summ_new: Decimal evo_fix_last_payment: Boolean @@ -2288,6 +2365,7 @@ type evo_addcontract { evo_graph_irr: Decimal evo_importer_reward_rub: Decimal evo_insurance_change: Boolean + evo_insurance_checking: Boolean evo_insurance_period: Int evo_insurance_period_new: Int evo_insurance_price_result: Decimal @@ -2536,6 +2614,7 @@ type evo_typedocpackage { evo_name: String evo_opportunity: Boolean evo_programsolution: [Int!] + evo_request_client: Boolean evo_request_payment: Boolean evo_typedocpackageid: Uuid modifiedon: DateTime @@ -2551,45 +2630,6 @@ type MutationBy { updateEntity(data: EntityDataInput): Boolean! } -"""The `DateTime` scalar represents an ISO-8601 compliant date time type.""" -scalar DateTime - -enum SortingType { - DESC - ASC -} - -input FilterInput { - fieldname: String - guidvalues: [Uuid] - intvalues: [Int!] - operation: FilterOperation! - stringvalues: [String] -} - -enum LogicOperation { - AND - OR -} - -type picklist { - name: String - values: [picklist_value] -} - -type businessunit { - businessunitid: Uuid - createdon: DateTime - evo_addressid: Uuid - evo_boss_systemuserid: Uuid - evo_director_systemuserid: Uuid - evo_region_director_systgemuserid: Uuid - evo_region_director_systgemuseridname: String - modifiedon: DateTime - name: String - toObjectString: String -} - type evo_document { createdon: DateTime evo_accountid: Uuid @@ -2617,6 +2657,53 @@ type evo_document { toObjectString: String } +"""The `DateTime` scalar represents an ISO-8601 compliant date time type.""" +scalar DateTime + +enum SortingType { + DESC + ASC +} + +input FilterInput { + fieldname: String + guidvalues: [Uuid] + intvalues: [Int!] + operation: FilterOperation! + stringvalues: [String] +} + +enum LogicOperation { + AND + OR +} + +type subjectGraphQL { + createdon: DateTime + modifiedon: DateTime + subjectid: Uuid + title: String + toObjectString: String +} + +type picklist { + name: String + values: [picklist_value] +} + +type businessunit { + businessunitid: Uuid + createdon: DateTime + evo_addressid: Uuid + evo_boss_systemuserid: Uuid + evo_director_systemuserid: Uuid + evo_region_director_systgemuserid: Uuid + evo_region_director_systgemuseridname: String + modifiedon: DateTime + name: String + toObjectString: String +} + type team { createdon: DateTime evo_baseproducts(statecode: Int): [evo_baseproduct] @@ -2731,24 +2818,6 @@ type Entity { logical_name: String } -enum FilterOperation { - ISNULL - EQUAL - CONTAINS - NOTCONTAINS - MORETHEN - MOREOREQUALTHEN - LESSTHEN - LESSOREQUALTHEN -} - -type picklist_value { - color: String - label: String - order: Int! - value: Int! -} - type evo_documenttype { createdon: DateTime evo_comment: String @@ -2767,6 +2836,24 @@ type evo_documenttype { toObjectString: String } +enum FilterOperation { + ISNULL + EQUAL + CONTAINS + NOTCONTAINS + MORETHEN + MOREOREQUALTHEN + LESSTHEN + LESSOREQUALTHEN +} + +type picklist_value { + color: String + label: String + order: Int! + value: Int! +} + input EntityFieldInput { activitypartiesvalue: [activitypartyInput] boolvalue: Boolean diff --git a/src/core/services/CrmService/types/entities.ts b/src/core/services/CrmService/types/entities.ts index efc0f53..89a8b15 100644 --- a/src/core/services/CrmService/types/entities.ts +++ b/src/core/services/CrmService/types/entities.ts @@ -104,7 +104,7 @@ export interface IOpportunity extends BaseEntity { } export interface IQuote extends BaseEntity { - evo_vin: string; + evo_vin?: string; evo_seasons_type?: number; evo_engine_hours?: number; evo_client_riskid?: string; @@ -166,6 +166,7 @@ export interface IQuote extends BaseEntity { evo_agent_accountid?: string; evo_agent_reward_conditionid?: string; evo_agent_reward_total?: number; + evo_agent_reward_summ?: number; evo_broker_accountid?: string; evo_fin_department_reward_total?: number; evo_fin_department_reward_conditionid?: string; @@ -278,6 +279,13 @@ export interface IEvoRewardCondition extends BaseEntity { evo_reward_summ?: number; evo_reduce_reward?: boolean; evo_agency_agreementid?: string; + evo_agency_agreementidData?: { + evo_reward_without_other_agent?: boolean; + evo_required_reward?: boolean; + evo_leasingobject_price?: number; + }; + evo_min_reward_summ?: number; + evo_calc_reward_rules?: number; } export interface IEvoGPSBrand extends BaseEntity { From 8f7bb3948d3bbc89c564d5353b9fbe68a56331e0 Mon Sep 17 00:00:00 2001 From: Chika Date: Mon, 12 Sep 2022 14:45:59 +0300 Subject: [PATCH 2/2] constants: MAX_INSURANCE = 3000000 --- src/core/constants/stores/Calculation/limits.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/constants/stores/Calculation/limits.js b/src/core/constants/stores/Calculation/limits.js index 0c65e8f..1c6a33a 100644 --- a/src/core/constants/stores/Calculation/limits.js +++ b/src/core/constants/stores/Calculation/limits.js @@ -1,3 +1,3 @@ export const MAX_FRANCHISE = 75000; -export const MAX_INSURANCE = 2500000; +export const MAX_INSURANCE = 3000000; export const MIN_INSURANCE = 3000;