diff --git a/apollo.config.js b/apollo.config.js index d5776dc..dea1bb4 100644 --- a/apollo.config.js +++ b/apollo.config.js @@ -3,7 +3,7 @@ module.exports = { service: { name: 'crmgraphql', url: 'http://localhost/crmgraphql/', - localSchemaFile: 'src/core/graphql/schemas/crm.graphql', + // localSchemaFile: 'src/core/graphql/schemas/crm.graphql', }, excludes: ['src/core/graphql/schemas/**/*.*'], }, diff --git a/package.json b/package.json index 2badc9c..0614b40 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,6 @@ "babel-plugin-transform-imports": "^2.0.0", "craco-less": "^2.0.0", "dayjs": "^1.10.4", - "graphql": "^16.2.0", "graphql.macro": "^1.4.2", "lodash": "^4.17.21", "mobx": "^6.1.8", diff --git a/src/client/Containers/Calculation/Sections/sectionsList.ts b/src/client/Containers/Calculation/Sections/sectionsList.ts index d1fdbbd..b64cfcc 100644 --- a/src/client/Containers/Calculation/Sections/sectionsList.ts +++ b/src/client/Containers/Calculation/Sections/sectionsList.ts @@ -468,6 +468,7 @@ const sections: ISection[] = [ // { // elements: [ // // 'cbxInsDecentral', + // 'tbxMinPriceChange', // 'tbxMaxPriceChange', // 'tbxImporterRewardPerc', // 'tbxImporterRewardRub', diff --git a/src/client/Containers/Calculation/lib/elements/components.ts b/src/client/Containers/Calculation/lib/elements/components.ts index 54049f6..8802673 100644 --- a/src/client/Containers/Calculation/lib/elements/components.ts +++ b/src/client/Containers/Calculation/lib/elements/components.ts @@ -175,6 +175,7 @@ const elementsComponents: TElements = { selectSubsidy: Select, selectFuelCard: Select, labelSubsidySum: Label, + tbxMinPriceChange: InputNumber, }; const tablesComponents: StoreTables = { diff --git a/src/client/Containers/Calculation/lib/elements/elementsProps.ts b/src/client/Containers/Calculation/lib/elements/elementsProps.ts index e97e844..8563bf8 100644 --- a/src/client/Containers/Calculation/lib/elements/elementsProps.ts +++ b/src/client/Containers/Calculation/lib/elements/elementsProps.ts @@ -457,6 +457,14 @@ const elementsProps: TElements = { radioInfuranceOPF: { style: 'button', }, + selectHighSeasonStart: { + tooltip: { + Component: buildTooltip({ + title: 'С какого платежа начинается полный высокий сезон', + placement: 'topLeft', + }), + }, + }, }; export const numberElementsProps: TElements = Object.keys( diff --git a/src/client/Containers/Calculation/lib/elements/titles.ts b/src/client/Containers/Calculation/lib/elements/titles.ts index cc837a7..3a6fb4c 100644 --- a/src/client/Containers/Calculation/lib/elements/titles.ts +++ b/src/client/Containers/Calculation/lib/elements/titles.ts @@ -40,7 +40,7 @@ export const elementsTitles: TElements = { radioGraphType: 'Вид графика', tbxParmentsDecreasePercent: 'Процент убывания платежей', selectSeasonType: 'Тип дегрессии/сезонности', - selectHighSeasonStart: 'С какого платежа начинается высокий сезон', + selectHighSeasonStart: 'Смещение сезонности', tbxComissionPerc: 'Комиссия, %', tbxComissionRub: 'Комиссия, руб.', tbxSaleBonus: 'Размер бонуса МПЛ', @@ -140,6 +140,7 @@ export const elementsTitles: TElements = { selectSubsidy: 'Субсидия', labelSubsidySum: 'Сумма субсидии с НДС', selectFuelCard: 'Топливная карта', + tbxMinPriceChange: 'Мин. возможное изменение стоимости ПЛ', }; const resultsTitles: TElements = { diff --git a/src/client/Containers/Calculation/lib/elements/values.ts b/src/client/Containers/Calculation/lib/elements/values.ts index c925560..c8077fc 100644 --- a/src/client/Containers/Calculation/lib/elements/values.ts +++ b/src/client/Containers/Calculation/lib/elements/values.ts @@ -139,6 +139,7 @@ export const elementsValues: TElements = { selectSubsidy: 'subsidy', labelSubsidySum: 'subsidySum', selectFuelCard: 'fuelCard', + tbxMinPriceChange: 'minPriceChange', }; const resultElementsValues: TElements = { diff --git a/src/client/stores/CalculationStore/Data/values.js b/src/client/stores/CalculationStore/Data/values.js index 9cdaa9f..ba26846 100644 --- a/src/client/stores/CalculationStore/Data/values.js +++ b/src/client/stores/CalculationStore/Data/values.js @@ -1,6 +1,6 @@ import { getValueName } from 'client/Containers/Calculation/lib/elements/tools'; import initialFilters, { - noResetValueElements, + noResetValueElements } from 'client/stores/CalculationStore/config/initialFilters'; import initialStatuses from 'client/stores/CalculationStore/config/initialStatuses'; import { isNil, mergeWith, pick } from 'lodash'; @@ -66,11 +66,17 @@ const valuesActions = { ); }); }, - getOptions(elementName, fields) { - if (!this.options[elementName]) { + getOptions(elementName, fields, filtered = false) { + let options = this.options[elementName]; + const filter = this.filters[elementName]; + if (filtered && filter) { + options = filter(options); + } + + if (!options) { return; } - if (!fields) return this.options[elementName]; + if (!fields) return options; return this.options[elementName].filter(option => { return Object.keys(fields).every( fieldName => option[fieldName] === fields[fieldName], diff --git a/src/client/stores/CalculationStore/Effects/reactions/gibddReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/gibddReactions.ts index 5cf9b5a..e633d6a 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/gibddReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/gibddReactions.ts @@ -352,6 +352,7 @@ const gibddReactions: IReactionEffect[] = [ 'regionRegistration', 'typePTS', 'leaseObjectCategory', + 'leaseObjectType', ]), }; }, @@ -361,9 +362,18 @@ const gibddReactions: IReactionEffect[] = [ regionRegistration, typePTS, leaseObjectCategory, + leaseObjectType, }) => { calculationStore.setFilter('selectRegistration', options => options.filter(x => { + if ( + !x.evo_leasingobject_types?.find( + x => x.evo_leasingobject_typeid === leaseObjectType, + ) + ) { + return false; + } + if (!objectRegionRegistration && !regionRegistration) { return false; } diff --git a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts index 119f0b0..ef13aa0 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts @@ -3,7 +3,7 @@ import { resetIns } from 'client/Components/Calculation/ELT/Content/lib/resetIns import { numberElementsProps } from 'client/Containers/Calculation/lib/elements/elementsProps'; import { getTitle, - getValueName, + getValueName } from 'client/Containers/Calculation/lib/elements/tools'; import { elementsValues } from 'client/Containers/Calculation/lib/elements/values'; import { openNotification } from 'client/Elements/Notification'; @@ -12,9 +12,10 @@ import { getMainOptionsForQuote, getQuoteQuery, getSecondaryOptionsForQuote, - getSingleOptionsForQuote, + getSingleOptionsForQuote } from 'core/graphql/query/crm/quote'; import CrmService from 'core/services/CrmService'; +import { TOptionizedEntity } from 'core/services/CrmService/types/common'; import { currentISODate } from 'core/tools/date'; import { NIL } from 'core/tools/uuid'; import { IReactionEffect } from 'core/types/Calculation/Store/effect'; @@ -26,7 +27,7 @@ import { IEvoGraph, IEvoTown, IQuote, - TCRMEntity, + TCRMEntity } from 'core/types/Entities/crmEntities'; import { ElementStatus } from 'core/types/statuses'; import { get, invert, isEqual, isNil } from 'lodash'; @@ -72,13 +73,10 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ opportunity, recalcWithRevision, calcType, - indAgent, INNForCalc, creditRate, rate, infuranceOPF, - calcBroker, - calcFinDepartment, balanceHolder, } = calculationStore.values; @@ -129,25 +127,74 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ evo_gps_brandid: quote.evo_gps_brandid || NIL, evo_regionid: quote.evo_regionid || NIL, evo_legal_regionid: quote.evo_legal_regionid || NIL, + evo_agency_agreementid_param: { has: true }, }, }); - const { selectDealerBroker } = await CrmService.getCRMOptions< - 'selectDealerBroker', - IAccount - >({ - query: getSingleOptionsForQuote, - variables: { - dealer_broker_accountid: quote.evo_dealer_broker_accountid || NIL, - hasDealerBroker: quote.evo_dealer_broker_accountid ? true : false, - }, - }); + // selectDealerBroker query + let selectDealerBroker: TOptionizedEntity[] = []; + const dealer_broker_accountid = + mainOptions?.selectDealerPerson && + mainOptions?.selectDealerPerson?.length > 0 && + mainOptions.selectDealerPerson[0].evo_broker_accountid; + if (dealer_broker_accountid) { + const selectDealerBrokerRes = await CrmService.getCRMOptions< + 'selectDealerBroker', + IAccount + >({ + query: getSingleOptionsForQuote, + variables: { + dealer_broker_accountid, + }, + }); + if (selectDealerBrokerRes?.selectDealerBroker) + selectDealerBroker = selectDealerBrokerRes.selectDealerBroker; + } + // selectDealerBroker query calculationStore.applyOptions({ ...mainOptions, - selectDealerBroker, + selectDealerBroker: selectDealerBroker, }); + // agents + //TODO: refactor + const { indAgent, calcBroker, calcFinDepartment } = + calculationStore.values; + let { + indAgentRewardCondition, + indAgentRewardSumm, + calcBrokerRewardCondition, + calcBrokerRewardSum, + finDepartmentRewardCondtion, + finDepartmentRewardSumm, + } = calculationStore.values; + if (indAgent === quote.evo_agent_accountid) { + indAgentRewardCondition = quote.evo_agent_reward_conditionid; + indAgentRewardSumm = quote.evo_agent_reward_total; + } + + if (calcBroker === quote.evo_broker_accountid) { + calcBrokerRewardCondition = quote.evo_broker_reward_conditionid; + calcBrokerRewardSum = quote.evo_broker_reward_total; + } + + if (calcFinDepartment === quote.evo_fin_department_accountid) { + finDepartmentRewardCondtion = + quote.evo_fin_department_reward_conditionid; + finDepartmentRewardSumm = quote.evo_fin_department_reward_total; + } + + const agentsValues = { + indAgentRewardCondition, + indAgentRewardSumm, + calcBrokerRewardCondition, + calcBrokerRewardSum, + finDepartmentRewardCondtion, + finDepartmentRewardSumm, + }; + // agents + // fill insurance table calculationStore.setTableRows( 'tableInsurance', @@ -519,6 +566,7 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ requirementTelematic, balanceHolder, redemptionPaymentSum, + ...agentsValues, }; // check min max number values diff --git a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts index eb80cc5..faf9640 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts @@ -48,17 +48,17 @@ const mapKPtoValues: Partial> = { dealerBrokerRewardCondition: 'evo_dealer_broker_reward_conditionid', dealerBrokerRewardSumm: 'evo_dealer_broker_reward_total', // indAgent: 'evo_agent_accountid', - indAgentRewardCondition: 'evo_agent_reward_conditionid', - indAgentRewardSumm: 'evo_agent_reward_total', + // indAgentRewardCondition: 'evo_agent_reward_conditionid', + // indAgentRewardSumm: 'evo_agent_reward_total', calcDoubleAgent: 'evo_double_agent_accountid', calcDoubleAgentRewardCondition: 'evo_double_agent_reward_conditionid', calcDoubleAgentRewardSumm: 'evo_double_agent_reward_total', // calcBroker: 'evo_broker_accountid', - calcBrokerRewardCondition: 'evo_broker_reward_conditionid', - calcBrokerRewardSum: 'evo_broker_reward_total', + // calcBrokerRewardCondition: 'evo_broker_reward_conditionid', + // calcBrokerRewardSum: 'evo_broker_reward_total', // calcFinDepartment: 'evo_fin_department_accountid', - finDepartmentRewardCondtion: 'evo_fin_department_reward_conditionid', - finDepartmentRewardSumm: 'evo_fin_department_reward_total', + // finDepartmentRewardCondtion: 'evo_fin_department_reward_conditionid', + // finDepartmentRewardSumm: 'evo_fin_department_reward_total', GPSBrand: 'evo_gps_brandid', GPSModel: 'evo_gps_modelid', infuranceOPF: 'evo_ins_legal_form', @@ -80,6 +80,7 @@ const mapKPtoValues: Partial> = { quoteName: 'evo_contact_name', quoteContactGender: 'evo_gender', quoteRedemptionGraph: 'evo_redemption_graph', + minPriceChange: 'evo_min_change_price', maxPriceChange: 'evo_max_price_change', importerRewardPerc: 'evo_importer_reward_perc', importerRewardRub: 'evo_importer_reward_rub', diff --git a/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts index c09e4cb..a4398d0 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts @@ -169,7 +169,7 @@ const reactionEffects: IReactionEffect[] = [ }, effect: indAgentRewardConditionId => { if (!indAgentRewardConditionId) { - calculationStore.setValue('indAgentRewardSumm', null); + calculationStore.setValue('indAgentRewardSumm', 0); calculationStore.setStatus( 'tbxIndAgentRewardSumm', ElementStatus.Disabled, @@ -657,11 +657,8 @@ const reactionEffects: IReactionEffect[] = [ calculationStore => ({ expression: () => { - const { - lastPaymentRub, - lastPaymentPerc, - insNSIB, - } = calculationStore.values; + const { lastPaymentRub, lastPaymentPerc, insNSIB } = + calculationStore.values; return { lastPaymentRub, lastPaymentPerc, insNSIB }; }, effect: ({ lastPaymentRub, insNSIB }) => { @@ -794,26 +791,14 @@ const reactionEffects: IReactionEffect[] = [ }), calculationStore => ({ - expression: () => { - const { seasonType } = calculationStore.values; - return seasonType; - }, - effect: seasonType => { - if (seasonType) { - switch (seasonType) { - case 100000001: - case 100000002: { - calculationStore.setFilter('selectHighSeasonStart', seasons => { - return seasons.filter( - season => season.value && season.value <= 100000004, - ); - }); - break; - } - default: - calculationStore.setFilter('selectHighSeasonStart', undefined); - break; - } + expression: () => calculationStore.getOption('selectSeasonType'), + effect: ({ forbiddenHighSeasonStart }) => { + if (forbiddenHighSeasonStart) { + calculationStore.setFilter('selectHighSeasonStart', seasonStart => + seasonStart.filter(s => !forbiddenHighSeasonStart.includes(s.name)), + ); + } else { + calculationStore.setFilter('selectHighSeasonStart', undefined); } }, options: { @@ -1495,12 +1480,10 @@ const reactionEffects: IReactionEffect[] = [ const fuelCard = calculationStore.getOption('selectFuelCard'); if (fuelCard) { - const selectFuelCard_filter = calculationStore.getFilter( - 'selectFuelCard', - ); - const selectFueldCard_options = calculationStore.getOptions( - 'selectFuelCard', - ); + const selectFuelCard_filter = + calculationStore.getFilter('selectFuelCard'); + const selectFueldCard_options = + calculationStore.getOptions('selectFuelCard'); if (selectFuelCard_filter && selectFueldCard_options) { const filtered_technicalCards = selectFuelCard_filter( diff --git a/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts index e5c670d..397de9e 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts @@ -1,9 +1,12 @@ +import { getFieldName } from 'client/Containers/Calculation/lib/elements/tools'; import { openNotification } from 'client/Elements/Notification'; import valuesConstants from 'core/constants/values'; +import { pipe } from 'core/tools/func'; import { IReactionEffect } from 'core/types/Calculation/Store/effect'; import { ElementsNames } from 'core/types/Calculation/Store/elements'; import { Process } from 'core/types/Calculation/Store/process'; import { TableNames } from 'core/types/Calculation/Store/tables'; +import { ValuesNames } from 'core/types/Calculation/Store/values'; import { ElementStatus } from 'core/types/statuses'; import { convertPrice } from '../lib/tools'; import { getPrice } from './priceReactions/calculate'; @@ -42,12 +45,17 @@ const reactionEffects: IReactionEffect[] = [ calculationStore, ); - const maxPriceChange = + const maxPriceChangeValue = price - supplierDiscountRub < 800000 ? price - supplierDiscountRub + 50000 : (price - supplierDiscountRub) * 1.05; + calculationStore.setValue('maxPriceChange', maxPriceChangeValue); - calculationStore.setValue('maxPriceChange', maxPriceChange); + const minPriceChangeValue = + price - supplierDiscountRub < 800000 + ? price - supplierDiscountRub - 50000 + : (price - supplierDiscountRub) * 0.95; + calculationStore.setValue('minPriceChange', minPriceChangeValue); }, options: { fireImmediately: true, @@ -119,7 +127,7 @@ const reactionEffects: IReactionEffect[] = [ ); const quote = calculationStore.getOption('selectQuote'); - if (quote && quote.evo_max_price_change) { + if (quote?.evo_max_price_change) { if (price - supplierDiscountRub > quote.evo_max_price_change) { calculationStore.setValidation('tbxLeaseObjectPrice', false); openNotification({ @@ -133,6 +141,21 @@ const reactionEffects: IReactionEffect[] = [ calculationStore.setValidation('tbxLeaseObjectPrice', undefined); } } + + if (quote?.evo_min_change_price) { + if (price - supplierDiscountRub < quote.evo_min_change_price) { + calculationStore.setValidation('tbxLeaseObjectPrice', false); + openNotification({ + type: 'error', + title: 'Ошибка', + description: + 'Указанная стоимость предмета лизинга меньше возмножного изменения стоимости предмета лизинга при пересчете без пересмотра. ' + + 'Увеличьте стоимость предмета лизинга', + })(); + } else { + calculationStore.setValidation('tbxLeaseObjectPrice', undefined); + } + } }, }), @@ -345,7 +368,9 @@ const reactionEffects: IReactionEffect[] = [ return; } if (!recalcWithRevision) { - const allowedReqTelematicValues = [100000000, 100000001]; + const allowedReqTelematicValues = [ + 100000000, 100000001, 100000002, 100000003, + ]; calculationStore.setFilter('radioRequirementTelematic', options => options.filter( x => @@ -429,32 +454,41 @@ const reactionEffects: IReactionEffect[] = [ (calculationStore, calculationProcess) => ({ expression: () => { - return calculationStore.getValue('requirementTelematic'); - }, - effect: requirementTelematic => { - if (calculationProcess.hasProcess(Process.LoadKp)) { - return; - } - const recalcWithRevision = calculationStore.getValue( + return calculationStore.getValues([ + 'requirementTelematic', 'recalcWithRevision', - ); - if (!recalcWithRevision) { - calculationStore.setValue('telematic', null); + ]); + }, + effect: ({ requirementTelematic, recalcWithRevision }) => { + (['tracker', 'telematic'] as ValuesNames[]).forEach(valueName => { + const elementName = getFieldName(valueName); - const addProducts = calculationStore.getStaticData( - 'evo_addproduct_type', - ); - let tracker = addProducts.find(x => - x.evo_controls_program?.includes(requirementTelematic), + calculationStore.setFilter(elementName, options => + options.filter( + pipe( + x => { + if (x.evo_controls_program?.includes(requirementTelematic)) + return x; + }, + x => { + if (recalcWithRevision) return x; + if (x?.evo_visible_calc === true) return x; + }, + ), + ), ); - calculationStore.setValue('tracker', tracker?.evo_addproduct_typeid); - } else { - calculationStore.setStatus( - 'radioRequirementTelematic', - ElementStatus.Disabled, - ); - } + if (!calculationProcess.hasProcess(Process.LoadKp)) { + const elementOptions = calculationStore.getOptions( + elementName, + undefined, + true, + ); + //TODO: удалить после рефактора CalculationStore + if (elementOptions?.length === 1) + calculationStore.setValue(valueName, elementOptions[0].value); + } + }); }, options: { fireImmediately: true, diff --git a/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts index 8add992..7cbcae5 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts @@ -306,18 +306,21 @@ export default [ $statecode: Int $currentDate: DateTime $evo_agent_accountid: Uuid + $evo_agency_agreementid_param: GuidParamInput ) { evo_reward_conditions( evo_agent_accountid: $evo_agent_accountid evo_datefrom_param: { lte: $currentDate } evo_dateto_param: { gte: $currentDate } statecode: $statecode + evo_agency_agreementid_param: $evo_agency_agreementid_param ) { evo_reward_conditionid evo_name evo_double_agent_accountid evo_reward_summ evo_reduce_reward + evo_agency_agreementid } } `, @@ -325,6 +328,7 @@ export default [ evo_agent_accountid: indAgentId, currentDate: currentISODate, statecode: 0, + evo_agency_agreementid_param: { has: true }, }, }).then(({ evo_reward_conditions }) => { if (evo_reward_conditions) @@ -369,17 +373,20 @@ export default [ $statecode: Int $currentDate: DateTime $evo_agent_accountid: Uuid + $evo_agency_agreementid_param: GuidParamInput ) { evo_reward_conditions( evo_agent_accountid: $evo_agent_accountid evo_datefrom_param: { lte: $currentDate } evo_dateto_param: { gte: $currentDate } statecode: $statecode + evo_agency_agreementid_param: $evo_agency_agreementid_param ) { evo_reward_conditionid evo_name evo_reward_summ evo_reduce_reward + evo_agency_agreementid } } `, @@ -387,6 +394,7 @@ export default [ evo_agent_accountid: doubleAgentId, currentDate: currentISODate, statecode: 0, + evo_agency_agreementid_param: { has: true }, }, }).then(({ evo_reward_conditions }) => { if (evo_reward_conditions) @@ -433,17 +441,20 @@ export default [ $statecode: Int $currentDate: DateTime $evo_agent_accountid: Uuid + $evo_agency_agreementid_param: GuidParamInput ) { evo_reward_conditions( evo_agent_accountid: $evo_agent_accountid evo_datefrom_param: { lte: $currentDate } evo_dateto_param: { gte: $currentDate } statecode: $statecode + evo_agency_agreementid_param: $evo_agency_agreementid_param ) { evo_reward_conditionid evo_name evo_reward_summ evo_reduce_reward + evo_agency_agreementid } } `, @@ -451,6 +462,7 @@ export default [ evo_agent_accountid: calcFinDepartmentId, currentDate: currentISODate, statecode: 0, + evo_agency_agreementid_param: { has: true }, }, }).then(({ evo_reward_conditions }) => { if (evo_reward_conditions) @@ -495,17 +507,20 @@ export default [ $statecode: Int $currentDate: DateTime $evo_agent_accountid: Uuid + $evo_agency_agreementid_param: GuidParamInput ) { evo_reward_conditions( evo_agent_accountid: $evo_agent_accountid evo_datefrom_param: { lte: $currentDate } evo_dateto_param: { gte: $currentDate } statecode: $statecode + evo_agency_agreementid_param: $evo_agency_agreementid_param ) { evo_reward_conditionid evo_name evo_reward_summ evo_reduce_reward + evo_agency_agreementid } } `, @@ -513,6 +528,7 @@ export default [ evo_agent_accountid: calcBrokerId, currentDate: currentISODate, statecode: 0, + evo_agency_agreementid_param: { has: true }, }, }).then(({ evo_reward_conditions }) => { if (evo_reward_conditions) @@ -669,17 +685,20 @@ export default [ $statecode: Int $currentDate: DateTime $evo_agent_accountid: Uuid + $evo_agency_agreementid_param: GuidParamInput ) { evo_reward_conditions( evo_agent_accountid: $evo_agent_accountid evo_datefrom_param: { lte: $currentDate } evo_dateto_param: { gte: $currentDate } statecode: $statecode + evo_agency_agreementid_param: $evo_agency_agreementid_param ) { evo_reward_conditionid evo_name evo_reward_summ evo_reduce_reward + evo_agency_agreementid } } `, @@ -687,6 +706,7 @@ export default [ evo_agent_accountid: dealerBrokerId, currentDate: currentISODate, statecode: 0, + evo_agency_agreementid_param: { has: true }, }, }).then(({ evo_reward_conditions }) => { if (evo_reward_conditions) @@ -730,17 +750,20 @@ export default [ $statecode: Int $currentDate: DateTime $evo_agent_accountid: Uuid + $evo_agency_agreementid_param: GuidParamInput ) { evo_reward_conditions( evo_agent_accountid: $evo_agent_accountid evo_datefrom_param: { lte: $currentDate } evo_dateto_param: { gte: $currentDate } statecode: $statecode + evo_agency_agreementid_param: $evo_agency_agreementid_param ) { evo_reward_conditionid evo_name evo_reward_summ evo_reduce_reward + evo_agency_agreementid } } `, @@ -748,6 +771,7 @@ export default [ evo_agent_accountid: dealerPersonId, currentDate: currentISODate, statecode: 0, + evo_agency_agreementid_param: { has: true }, }, }).then(({ evo_reward_conditions }) => { if (evo_reward_conditions) diff --git a/src/client/stores/CalculationStore/Effects/reactions/tablesReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/tablesReactions.ts index 2311674..ef56594 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/tablesReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/tablesReactions.ts @@ -1,6 +1,7 @@ /* eslint-disable @typescript-eslint/ban-ts-comment */ import { openNotification } from 'client/Elements/Notification'; import { + insuranceKaskoDefaultFilter, insuranceOsagoDefaultFilter, singleValueFilter, } from 'core/constants/stores/Calculation/filters'; @@ -808,4 +809,44 @@ export default [ } }, }), + (calculationStore, calculationProcess) => ({ + expression: () => calculationStore.getOption('selectBrand'), + effect: brand => { + if (calculationProcess.hasProcess(Process.LoadKp)) { + return; + } + if (brand?.evo_id === 'BRAND49') { + const { tableInsurance } = calculationStore.tables; + // ПАО "ГРУППА РЕНЕССАНС СТРАХОВАНИЕ" + const targetInsuranceCompany = + tableInsurance.options?.insuranceCompany?.find( + x => x.evo_inn === '7725497022', + ); + if (targetInsuranceCompany) { + const targetInsuranceFilter = singleValueFilter( + targetInsuranceCompany.value, + ); + calculationStore.setTableRow('tableInsurance', rows => + rows.findIndex(x => x.policyType?.value === 'КАСКО'), + )({ + insuranceCompany: { + filter: targetInsuranceFilter, + value: targetInsuranceCompany.value, + status: ElementStatus.Disabled, + }, + }); + } + } else { + calculationStore.setTableRow('tableInsurance', rows => + rows.findIndex(x => x.policyType?.value === 'КАСКО'), + )({ + insuranceCompany: { + filter: insuranceKaskoDefaultFilter, + status: ElementStatus.Default, + value: null, + }, + }); + } + }, + }), ] as IReactionEffect[]; diff --git a/src/client/stores/CalculationStore/config/initialOptions.ts b/src/client/stores/CalculationStore/config/initialOptions.ts index 5f464d2..08eb924 100644 --- a/src/client/stores/CalculationStore/config/initialOptions.ts +++ b/src/client/stores/CalculationStore/config/initialOptions.ts @@ -89,6 +89,7 @@ const initialOptions: TElements = { startPositions: [0, 6], paymentsInStep: [6, 6], stepsValues: [100, 50], + forbiddenHighSeasonStart: ['9', '10'], }, { name: '8/4', @@ -96,6 +97,7 @@ const initialOptions: TElements = { startPositions: [0, 8], paymentsInStep: [8, 4], stepsValues: [100, 50], + forbiddenHighSeasonStart: ['7', '8', '9'], }, { name: '4/4/4', @@ -103,6 +105,7 @@ const initialOptions: TElements = { startPositions: [0, 4, 8], paymentsInStep: [4, 4, 4], stepsValues: [100, 75, 50], + forbiddenHighSeasonStart: ['11'], }, { name: '100.50.25', @@ -126,36 +129,10 @@ const initialOptions: TElements = { }, ], - selectHighSeasonStart: [ - { - name: '2', - value: 100000000, - }, - { - name: '3', - value: 100000001, - }, - { - name: '4', - value: 100000002, - }, - { - name: '5', - value: 100000003, - }, - { - name: '6', - value: 100000004, - }, - { - name: '7', - value: 100000005, - }, - { - name: '8', - value: 100000006, - }, - ], + selectHighSeasonStart: Array.from({ length: 12 }, (_, i) => ({ + name: `${i + 2}`, + value: 100000000 + i, + })), radioDeliveryTime: [ { @@ -269,8 +246,7 @@ const initialOptions: TElements = { value: 100000012, }, { - name: - 'Для экскурсионных перевозок в т.ч. на торжества; трансфер в аэропорт и пр.', + name: 'Для экскурсионных перевозок в т.ч. на торжества; трансфер в аэропорт и пр.', value: 100000013, }, { diff --git a/src/client/stores/CalculationStore/config/initialStatuses.ts b/src/client/stores/CalculationStore/config/initialStatuses.ts index e65409a..9784cab 100644 --- a/src/client/stores/CalculationStore/config/initialStatuses.ts +++ b/src/client/stores/CalculationStore/config/initialStatuses.ts @@ -9,7 +9,7 @@ const initialStatuses: TElements = { selectCalcDoubleAgent: ElementStatus.Disabled, tbxInsKaskoPriceLeasePeriod: ElementStatus.Disabled, selectClientType: ElementStatus.Disabled, - selectTelematic: ElementStatus.Disabled, + // selectTelematic: ElementStatus.Disabled, tbxImporterRewardRub: ElementStatus.Disabled, tbxImporterRewardPerc: ElementStatus.Disabled, tbxMaxPriceChange: ElementStatus.Disabled, @@ -34,7 +34,7 @@ const initialStatuses: TElements = { tbxCommentLead: ElementStatus.Disabled, btnCreateLead: ElementStatus.Disabled, - selectTracker: ElementStatus.Disabled, + // selectTracker: ElementStatus.Disabled, tbxVehicleTaxInLeasingPeriod: ElementStatus.Disabled, selectObjectTypeTax: ElementStatus.Disabled, diff --git a/src/client/stores/CalculationStore/init/index.ts b/src/client/stores/CalculationStore/init/index.ts index 5177dcd..ce46f67 100644 --- a/src/client/stores/CalculationStore/init/index.ts +++ b/src/client/stores/CalculationStore/init/index.ts @@ -1,5 +1,6 @@ import { ICalculationStore } from 'core/types/Calculation/Store'; import { Process } from 'core/types/Calculation/Store/process'; +import { isEmpty } from 'lodash'; import initialOptions from '../config/initialOptions'; import initialValues from '../config/initialValues'; import { composeRequests } from './requests'; @@ -16,13 +17,23 @@ export default async function (this: ICalculationStore) { insuranceRequest, } = composeRequests(); - const ownerOptions = await ownerOptionsRequest; - const mainOptions = await mainOptionsRequest; - this.applyOptions(Object.assign(initialOptions, ownerOptions, mainOptions)); - - const systemuser = await systemUserRequest; + const { systemuser } = await systemUserRequest; const staticEntities = await staticDataRequest; - this.applyStaticData(Object.assign({ systemuser }, staticEntities)); + this.applyStaticData( + Object.assign({ systemuser: [systemuser] }, staticEntities), + ); + + const ownerOptions = await ownerOptionsRequest; + + const mainOptions = await mainOptionsRequest; + let selectProduct = mainOptions?.selectProduct?.filter( + x => + isEmpty(x.systemusers) || + x?.systemusers?.some(u => u?.systemuserid === systemuser?.systemuserid), + ); + this.applyOptions( + Object.assign(initialOptions, ownerOptions, mainOptions, { selectProduct }), + ); const insuranceData = await insuranceRequest; this.setTableColumns('tableInsurance')({ @@ -36,13 +47,14 @@ export default async function (this: ICalculationStore) { ); this.setValue('supplierCurrency', supplierCurrency?.transactioncurrencyid); - const evo_sot_coefficient_type = staticEntities?.evo_sot_coefficient_type?.find( - x => x.evo_id === 'BONUS_LEASING', - ); + const evo_sot_coefficient_type = + staticEntities?.evo_sot_coefficient_type?.find( + x => x.evo_id === 'BONUS_LEASING', + ); const evo_coefficient_bonus = staticEntities?.evo_coefficient?.find( x => - x.evo_job_titleid === systemuser[0]?.evo_job_titleid && + x.evo_job_titleid === systemuser?.evo_job_titleid && x.evo_sot_coefficient_typeid === evo_sot_coefficient_type?.evo_sot_coefficient_typeid, ); diff --git a/src/client/stores/CalculationStore/init/requests.ts b/src/client/stores/CalculationStore/init/requests.ts index e96d592..1bb9f75 100644 --- a/src/client/stores/CalculationStore/init/requests.ts +++ b/src/client/stores/CalculationStore/init/requests.ts @@ -45,7 +45,7 @@ export function composeRequests() { const domainname = UserStore.getDomainName(); const systemUserRequest = CrmService.getCRMEntities< - CRMEntityNames, + 'systemuser', ISystemUser >({ query: getSystemUserQuery, diff --git a/src/core/graphql/query/crm/options/getInsuranceOptions.graphql b/src/core/graphql/query/crm/options/getInsuranceOptions.graphql index 9589745..a671cff 100644 --- a/src/core/graphql/query/crm/options/getInsuranceOptions.graphql +++ b/src/core/graphql/query/crm/options/getInsuranceOptions.graphql @@ -10,5 +10,6 @@ query GetInsuranceOptions($evo_account_type: [Int!], $statecode: Int) { evo_id_elt_smr evo_id_elt_osago evo_legal_region_calc + evo_inn } } diff --git a/src/core/graphql/query/crm/options/getMainOptions.graphql b/src/core/graphql/query/crm/options/getMainOptions.graphql index afae54a..4fcdab8 100644 --- a/src/core/graphql/query/crm/options/getMainOptions.graphql +++ b/src/core/graphql/query/crm/options/getMainOptions.graphql @@ -92,6 +92,9 @@ query GetMainOptions( evo_name evo_brandid } + systemusers { + systemuserid + } } selectRegistration: evo_addproduct_types( statecode: $statecode @@ -105,6 +108,9 @@ query GetMainOptions( evo_description evo_gibdd_region evo_whom_register + evo_leasingobject_types { + evo_leasingobject_typeid + } } selectInsNSIB: evo_addproduct_types( statecode: $statecode @@ -121,6 +127,7 @@ query GetMainOptions( evo_dateto_param: { gte: $currentDate } ) { ...evo_addproduct_types_fields + evo_visible_calc evo_planpayments { evo_name evo_cost_equipment_withoutnds @@ -135,6 +142,7 @@ query GetMainOptions( evo_dateto_param: { gte: $currentDate } ) { ...evo_addproduct_types_fields + evo_visible_calc evo_planpayments { evo_name evo_cost_equipment_withoutnds diff --git a/src/core/graphql/query/crm/quote/fragments/quoteFields.graphql b/src/core/graphql/query/crm/quote/fragments/quoteFields.graphql index c0bfb78..699b606 100644 --- a/src/core/graphql/query/crm/quote/fragments/quoteFields.graphql +++ b/src/core/graphql/query/crm/quote/fragments/quoteFields.graphql @@ -90,6 +90,8 @@ fragment quoteFields on quote { evo_modelid evo_equipmentid evo_engine_type + evo_category + evo_power evo_engine_volume evo_use_for diff --git a/src/core/graphql/query/crm/quote/fragments/quoteFieldsLite.graphql b/src/core/graphql/query/crm/quote/fragments/quoteFieldsLite.graphql index 5ce2a45..282a3ce 100644 --- a/src/core/graphql/query/crm/quote/fragments/quoteFieldsLite.graphql +++ b/src/core/graphql/query/crm/quote/fragments/quoteFieldsLite.graphql @@ -9,6 +9,7 @@ fragment quoteFieldsLite on quote { evo_statuscode: evo_statuscodeidData { evo_id } + evo_min_change_price evo_max_price_change evo_max_mass evo_seats diff --git a/src/core/graphql/query/crm/quote/options/getMainOptions.graphql b/src/core/graphql/query/crm/quote/options/getMainOptions.graphql index 84b576c..6909525 100644 --- a/src/core/graphql/query/crm/quote/options/getMainOptions.graphql +++ b/src/core/graphql/query/crm/quote/options/getMainOptions.graphql @@ -11,6 +11,7 @@ query GetMainOptionsForKP( # $broker_accountid: Uuid! # $findepartment_accountid: Uuid! $evo_gps_brandid: Uuid! + $evo_agency_agreementid_param: GuidParamInput ) { selectModel: evo_models(statecode: $statecode, evo_brandid: $evo_brandid) { evo_id @@ -52,6 +53,7 @@ query GetMainOptionsForKP( evo_datefrom_param: { lte: $currentDate } evo_dateto_param: { gte: $currentDate } statecode: $statecode + evo_agency_agreementid_param: $evo_agency_agreementid_param ) { evo_reward_conditionid evo_name @@ -63,6 +65,7 @@ query GetMainOptionsForKP( evo_datefrom_param: { lte: $currentDate } evo_dateto_param: { gte: $currentDate } statecode: $statecode + evo_agency_agreementid_param: $evo_agency_agreementid_param ) { evo_reward_conditionid evo_name @@ -74,6 +77,7 @@ query GetMainOptionsForKP( # evo_datefrom_param: { lte: $currentDate } # evo_dateto_param: { gte: $currentDate } # statecode: $statecode + # evo_agency_agreementid_param: $evo_agency_agreementid_param # ) { # evo_reward_conditionid # evo_name @@ -86,6 +90,7 @@ query GetMainOptionsForKP( evo_datefrom_param: { lte: $currentDate } evo_dateto_param: { gte: $currentDate } statecode: $statecode + evo_agency_agreementid_param: $evo_agency_agreementid_param ) { evo_reward_conditionid evo_name @@ -97,6 +102,7 @@ query GetMainOptionsForKP( # evo_datefrom_param: { lte: $currentDate } # evo_dateto_param: { gte: $currentDate } # statecode: $statecode + # evo_agency_agreementid_param: $evo_agency_agreementid_param # ) { # evo_reward_conditionid # evo_name @@ -108,6 +114,7 @@ query GetMainOptionsForKP( # evo_datefrom_param: { lte: $currentDate } # evo_dateto_param: { gte: $currentDate } # statecode: $statecode + # evo_agency_agreementid_param: $evo_agency_agreementid_param # ) { # evo_reward_conditionid # evo_name diff --git a/src/core/graphql/query/crm/quote/options/getSingleOptions.graphql b/src/core/graphql/query/crm/quote/options/getSingleOptions.graphql index 63360df..b82fc2d 100644 --- a/src/core/graphql/query/crm/quote/options/getSingleOptions.graphql +++ b/src/core/graphql/query/crm/quote/options/getSingleOptions.graphql @@ -1,9 +1,5 @@ -query GetSingleOptionsForKP( - $dealer_broker_accountid: Uuid! - $hasDealerBroker: Boolean! -) { - selectDealerBroker: account(accountid: $dealer_broker_accountid) - @include(if: $hasDealerBroker) { +query GetSingleOptionsForKP($dealer_broker_accountid: Uuid!) { + selectDealerBroker: account(accountid: $dealer_broker_accountid) { accountid name } diff --git a/src/core/graphql/query/crm/staticData/getSystemUser.graphql b/src/core/graphql/query/crm/staticData/getSystemUser.graphql index 22abe24..a7cf481 100644 --- a/src/core/graphql/query/crm/staticData/getSystemUser.graphql +++ b/src/core/graphql/query/crm/staticData/getSystemUser.graphql @@ -5,5 +5,6 @@ query GetSystemUser($domainname: String) { firstname lastname fullname + systemuserid } } diff --git a/src/core/graphql/schemas/crm.graphql b/src/core/graphql/schemas/crm.graphql index 231eca8..4aba9cd 100644 --- a/src/core/graphql/schemas/crm.graphql +++ b/src/core/graphql/schemas/crm.graphql @@ -105,7 +105,7 @@ type Query { 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 - evo_reward_conditions(evo_agent_accountid: Uuid, evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, statecode: Int): [evo_reward_condition] + 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_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] @@ -258,6 +258,11 @@ input ConditionInput { logicoperation: LogicOperation! } +input GuidParamInput { + eq: Uuid + has: Boolean +} + """The built-in `Decimal` scalar type.""" scalar Decimal @@ -334,6 +339,7 @@ type evo_addproduct_type { evo_towtruck: Boolean evo_visible_calc: Boolean evo_whom_register: Int + evo_who_register: Int modifiedon: DateTime statecode: Int toObjectString: String @@ -1350,6 +1356,8 @@ type evo_contract { evo_ns_bonus_summ: Decimal evo_number_dkp: String evo_paymentorders(evo_name: String, statecode: Int): [evo_paymentorder] + evo_payment_redemption_sum: Decimal + evo_payment_redemption_sum_without_nds: Decimal evo_period: Int evo_price_without_discount: Decimal evo_price_without_discount_supplier_currency: Decimal @@ -1445,6 +1453,7 @@ type evo_paymentorder { evo_dds_1c: String evo_inn_text: String evo_insurance_periodid: Uuid + evo_money_transfer_paymentorderid: Uuid evo_name: String evo_paydate: DateTime evo_paydate_fact: DateTime @@ -1904,6 +1913,7 @@ type evo_addcontract { evo_insurer_kasko_accountid_new: Uuid evo_insurer_osago_accountid: Uuid evo_insurer_osago_accountid_new: Uuid + evo_ins_period_kasko_date: DateTime evo_ins_period_kasko_number: Int evo_ins_period_osago_date: DateTime evo_ins_period_osago_number: Int @@ -2002,6 +2012,7 @@ type evo_addcontract { evo_registration_new: Int evo_registration_regionid: Uuid evo_registration_regionid_new: Uuid + evo_remove_restrictions: Boolean evo_seats: Int evo_seats_new: Int evo_signatory_evo_systemuserid: Uuid diff --git a/src/core/types/Calculation/Store/elements.ts b/src/core/types/Calculation/Store/elements.ts index 7fa3fd1..b33d84c 100644 --- a/src/core/types/Calculation/Store/elements.ts +++ b/src/core/types/Calculation/Store/elements.ts @@ -149,7 +149,8 @@ export type ElementsNames = | 'selectLegalClientTown' | 'selectSubsidy' | 'labelSubsidySum' - | 'selectFuelCard'; + | 'selectFuelCard' + | 'tbxMinPriceChange'; export type LinkElementsNames = 'linkDownloadKp'; diff --git a/src/core/types/Calculation/Store/index.ts b/src/core/types/Calculation/Store/index.ts index a0c06b2..f329c75 100644 --- a/src/core/types/Calculation/Store/index.ts +++ b/src/core/types/Calculation/Store/index.ts @@ -41,6 +41,7 @@ interface ICalculationValues { getOptions: ( elementName: ElementsNames, fields?: { [field in keyof (IBaseOption & TCRMEntity)]?: any }, + filtered?: boolean, ) => (IBaseOption & TCRMEntity)[] | undefined; setOptions: ( elementName: ElementsNames, diff --git a/src/core/types/Calculation/Store/process.ts b/src/core/types/Calculation/Store/process.ts index 6003fb0..aa6fb9a 100644 --- a/src/core/types/Calculation/Store/process.ts +++ b/src/core/types/Calculation/Store/process.ts @@ -1,6 +1,5 @@ export enum Process { Init, LoadKp, - RecalcWithoutRevision, ELT, } diff --git a/src/core/types/Calculation/Store/values.ts b/src/core/types/Calculation/Store/values.ts index d2bbb2d..f04a0cc 100644 --- a/src/core/types/Calculation/Store/values.ts +++ b/src/core/types/Calculation/Store/values.ts @@ -135,7 +135,8 @@ export type ValuesNames = | 'legalClientTown' | 'subsidy' | 'subsidySum' - | 'fuelCard'; + | 'fuelCard' + | 'minPriceChange'; export type ComputedValuesNames = | 'leaseObjectRiskName' diff --git a/src/core/types/Entities/crmEntities.ts b/src/core/types/Entities/crmEntities.ts index 991d57f..3a95a0e 100644 --- a/src/core/types/Entities/crmEntities.ts +++ b/src/core/types/Entities/crmEntities.ts @@ -106,6 +106,7 @@ export interface IQuote extends BaseEntity { evo_period?: number; evo_first_payment_perc?: number; evo_last_payment_perc?: number; + evo_min_change_price?: number; evo_max_price_change?: number; evo_max_mass?: number; evo_seats?: number; @@ -125,6 +126,15 @@ export interface IQuote extends BaseEntity { evo_req_telematic_accept?: number; evo_one_year_insurance?: boolean; evo_payment_redemption_sum?: number; + evo_agent_accountid?: string; + evo_agent_reward_conditionid?: string; + evo_agent_reward_total?: number; + evo_broker_accountid?: string; + evo_fin_department_reward_total?: number; + evo_fin_department_reward_conditionid?: string; + evo_fin_department_accountid?: string; + evo_broker_reward_total?: number; + evo_broker_reward_conditionid?: string; } export interface IEvoGraph extends BaseEntity { @@ -153,6 +163,7 @@ export interface IEvoBaseproduct extends BaseEntity { evo_dateto_param?: Date; evo_leasingobject_types?: IEvoLeasingObjectType[]; evo_brands?: IEvoBrand[]; + systemusers?: ISystemUser[]; } export interface IEvoLeasingObjectType extends BaseEntity { @@ -212,6 +223,7 @@ export interface IEvoRewardCondition extends BaseEntity { evo_double_agent_accountid?: string; evo_reward_summ?: number; evo_reduce_reward?: boolean; + evo_agency_agreementid?: string; } export interface IEvoGPSBrand extends BaseEntity { @@ -318,6 +330,7 @@ export interface IEvoAddproductType extends BaseEntity { evo_cost_price_telematics?: number; evo_cost_equipment?: number; evo_controls_program?: number[]; + evo_visible_calc?: boolean; evo_helpcard_type?: number; evo_towtruck?: boolean; evo_pts_type?: number[];