From 9d45a7bff0aeeebefde070c9273bc95e163f7470 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Thu, 16 Mar 2023 15:35:44 +0300 Subject: [PATCH] merge migration/random-3 --- .../Form/Insurance/FinGAPTable/index.jsx | 6 +- .../Form/Insurance/InsuranceTable/index.jsx | 6 +- .../Calculation/Form/Insurance/config.ts | 2 +- .../Form/Payments/PaymentsTable/index.jsx | 6 +- .../Calculation/config/elements-components.ts | 3 - .../Calculation/config/elements-props.tsx | 8 - .../Calculation/config/elements-titles.ts | 3 - .../Calculation/config/elements-types.ts | 3 - .../Calculation/config/map/values.ts | 3 - apps/web/Components/Output/Validation.jsx | 18 +- apps/web/apollo/client.js | 6 +- apps/web/config/apollo.js | 34 ++ apps/web/config/default-options.ts | 289 ++++++------- apps/web/config/default-statuses.ts | 3 - apps/web/config/default-values.ts | 3 - apps/web/config/process/default.ts | 7 +- apps/web/config/schema/values.ts | 3 - apps/web/constants/values.js | 2 + apps/web/graphql/crm.query.graphql | 171 +++++++- apps/web/graphql/crm.types.ts | 168 +++++--- apps/web/process/add-product/get-kp-data.ts | 71 ++++ apps/web/process/add-product/index.ts | 2 + apps/web/process/add-product/reactions.ts | 120 ++++++ .../bonuses/{reactions => }/lib/helper.ts | 7 +- apps/web/process/bonuses/reactions/common.ts | 5 +- .../process/bonuses/reactions/validation.ts | 32 +- apps/web/process/bonuses/validation.ts | 24 ++ .../web/process/calculate/reactions/common.ts | 1 - .../process/calculate/reactions/validation.ts | 41 +- apps/web/process/configurator/get-kp-data.ts | 5 + .../process/configurator/reactions/filters.ts | 14 +- .../configurator/reactions/validation.ts | 57 ++- .../process/configurator/reactions/values.ts | 78 +++- apps/web/process/configurator/validation.ts | 40 ++ apps/web/process/fingap/reactions/common.ts | 1 - .../process/fingap/reactions/validation.ts | 18 +- apps/web/process/gibdd/get-kp-data.ts | 15 +- apps/web/process/gibdd/lib/helper.ts | 1 - apps/web/process/gibdd/reactions.ts | 207 +++------- apps/web/process/gibdd/validation.ts | 94 +++++ apps/web/process/init/get-initial-data.ts | 1 - apps/web/process/init/get-insurance-data.js | 48 +-- apps/web/process/init/get-main-data.js | 66 +-- apps/web/process/insurance/get-kp-data.ts | 17 + apps/web/process/insurance/index.ts | 1 + apps/web/process/insurance/reactions.ts | 318 +++++++++++++++ apps/web/process/insurance/validation.ts | 120 ++++++ .../lead-opportunity/reactions/common.ts | 41 +- .../web/process/leasing-object/get-kp-data.ts | 1 - .../leasing-object/reactions/common.ts | 39 +- .../leasing-object/reactions/validation.ts | 167 ++------ apps/web/process/leasing-object/validation.ts | 108 +++++ .../leasing-without-kasko/reactions.ts | 45 +- apps/web/process/load-kp/reactions.ts | 44 +- apps/web/process/payments/lib/validation.ts | 138 ------- .../process/payments/reactions/validation.ts | 76 ++-- apps/web/process/payments/validation.ts | 215 ++++++++++ apps/web/process/price/get-kp-data.ts | 2 + apps/web/process/price/reactions/common.ts | 1 - apps/web/process/price/reactions/computed.ts | 1 - .../web/process/price/reactions/validation.ts | 82 ++-- apps/web/process/price/validation.ts | 79 ++++ apps/web/process/recalc/index.ts | 1 + apps/web/process/recalc/reactions.ts | 252 ++++++++++++ apps/web/process/recalc/validation.ts | 249 +++++++++++ .../subsidy-import-program/reactions.ts | 2 +- .../supplier-agent/get-kp-data/get-sums.ts | 1 - .../supplier-agent/lib/create-reactions.ts | 111 +---- .../supplier-agent/reactions/agents.ts | 168 +------- .../process/supplier-agent/reactions/index.ts | 7 +- .../supplier-agent/reactions/leaseback.ts | 35 +- .../supplier-agent/reactions/supplier.ts | 12 - .../supplier-agent/reactions/validation.ts | 70 ++++ apps/web/process/supplier-agent/validation.ts | 386 ++++++++++++++++++ apps/web/process/types.ts | 2 + apps/web/process/used-pl/reactions.ts | 118 ++---- apps/web/process/used-pl/validation.ts | 80 ++++ apps/web/stores/calculation/index.ts | 27 +- apps/web/stores/calculation/statuses/index.ts | 11 +- .../stores/calculation/validation/hooks.js | 5 +- apps/web/stores/calculation/values/index.ts | 7 +- apps/web/stores/tables/fingap/index.ts | 15 +- apps/web/stores/tables/insurance/index.ts | 54 ++- apps/web/stores/tables/payments/index.ts | 29 +- apps/web/stores/validation/index.ts | 34 +- apps/web/stores/validation/types.ts | 11 +- apps/web/trpc/routers/quote.ts | 2 + packages/eslint-config-custom/rules.js | 8 + 88 files changed, 3348 insertions(+), 1536 deletions(-) create mode 100644 apps/web/config/apollo.js create mode 100644 apps/web/process/add-product/get-kp-data.ts create mode 100644 apps/web/process/add-product/index.ts create mode 100644 apps/web/process/add-product/reactions.ts rename apps/web/process/bonuses/{reactions => }/lib/helper.ts (86%) create mode 100644 apps/web/process/bonuses/validation.ts create mode 100644 apps/web/process/configurator/validation.ts create mode 100644 apps/web/process/gibdd/validation.ts create mode 100644 apps/web/process/insurance/reactions.ts create mode 100644 apps/web/process/insurance/validation.ts create mode 100644 apps/web/process/leasing-object/validation.ts delete mode 100644 apps/web/process/payments/lib/validation.ts create mode 100644 apps/web/process/payments/validation.ts create mode 100644 apps/web/process/price/validation.ts create mode 100644 apps/web/process/recalc/index.ts create mode 100644 apps/web/process/recalc/reactions.ts create mode 100644 apps/web/process/recalc/validation.ts create mode 100644 apps/web/process/supplier-agent/reactions/validation.ts create mode 100644 apps/web/process/supplier-agent/validation.ts create mode 100644 apps/web/process/used-pl/validation.ts diff --git a/apps/web/Components/Calculation/Form/Insurance/FinGAPTable/index.jsx b/apps/web/Components/Calculation/Form/Insurance/FinGAPTable/index.jsx index 5ce9cb8..3547673 100644 --- a/apps/web/Components/Calculation/Form/Insurance/FinGAPTable/index.jsx +++ b/apps/web/Components/Calculation/Form/Insurance/FinGAPTable/index.jsx @@ -14,10 +14,10 @@ const Grid = styled(Flex)` const Validation = observer(() => { const store = useStore(); - const messages = store.$tables.fingap.validation.getMessages(); + const errors = store.$tables.fingap.validation.getErrors(); - if (messages?.length) { - return ; + if (errors?.length) { + return ; } return null; diff --git a/apps/web/Components/Calculation/Form/Insurance/InsuranceTable/index.jsx b/apps/web/Components/Calculation/Form/Insurance/InsuranceTable/index.jsx index 6cc6fde..24ef8af 100644 --- a/apps/web/Components/Calculation/Form/Insurance/InsuranceTable/index.jsx +++ b/apps/web/Components/Calculation/Form/Insurance/InsuranceTable/index.jsx @@ -19,10 +19,10 @@ const TableWrapper = styled.div` const Validation = observer(() => { const store = useStore(); - const messages = store.$tables.insurance.validation.getMessages(); + const errors = store.$tables.insurance.validation.getErrors(); - if (messages?.length) { - return ; + if (errors?.length) { + return ; } return null; diff --git a/apps/web/Components/Calculation/Form/Insurance/config.ts b/apps/web/Components/Calculation/Form/Insurance/config.ts index d689749..5e69762 100644 --- a/apps/web/Components/Calculation/Form/Insurance/config.ts +++ b/apps/web/Components/Calculation/Form/Insurance/config.ts @@ -6,7 +6,7 @@ export const title = 'Страхование'; export const rows: FormTabRows = [ [['tbxLeaseObjectYear', 'selectLeaseObjectUseFor', 'selectLegalClientRegion']], [['selectEngineType', 'tbxInsFranchise', 'selectLegalClientTown']], - [['selectLeaseObjectCategory', 'tbxMileage', 'tbxINNForCalc']], + [['selectLeaseObjectCategory', 'tbxMileage']], [['tbxLeaseObjectMotorPower', 'cbxWithTrailer', 'selectGPSBrand']], [['tbxEngineVolume', 'cbxInsDecentral', 'selectGPSModel']], [['selectLeasingWithoutKasko', 'selectInsNSIB']], diff --git a/apps/web/Components/Calculation/Form/Payments/PaymentsTable/index.jsx b/apps/web/Components/Calculation/Form/Payments/PaymentsTable/index.jsx index 804ecbd..a8fd83b 100644 --- a/apps/web/Components/Calculation/Form/Payments/PaymentsTable/index.jsx +++ b/apps/web/Components/Calculation/Form/Payments/PaymentsTable/index.jsx @@ -33,10 +33,10 @@ const Validation = observer(() => { const store = useStore(); const { payments } = store.$tables; - const messages = payments.validation.getMessages(); + const errors = payments.validation.getErrors(); - if (messages?.length) { - return ; + if (errors?.length) { + return ; } return null; diff --git a/apps/web/Components/Calculation/config/elements-components.ts b/apps/web/Components/Calculation/config/elements-components.ts index 52f00df..b74ebc2 100644 --- a/apps/web/Components/Calculation/config/elements-components.ts +++ b/apps/web/Components/Calculation/config/elements-components.ts @@ -74,17 +74,14 @@ const components = wrapComponentsMap({ selectFinDepartmentRewardCondtion: e.Select, tbxFinDepartmentRewardSumm: e.InputNumber, cbxInsDecentral: e.Switch, - radioInsKaskoType: e.Radio, tbxInsFranchise: e.InputNumber, cbxInsUnlimitDrivers: e.Switch, tbxInsAgeDrivers: e.InputNumber, tbxInsExpDrivers: e.InputNumber, - tbxINNForCalc: e.InputNumber, selectGPSBrand: e.Select, selectGPSModel: e.Select, selectRegionRegistration: e.Select, selectTownRegistration: e.Select, - radioInfuranceOPF: e.Radio, selectRegistration: e.Select, selectInsNSIB: e.Select, selectRequirementTelematic: e.Select, diff --git a/apps/web/Components/Calculation/config/elements-props.tsx b/apps/web/Components/Calculation/config/elements-props.tsx index e4933e5..9c80f93 100644 --- a/apps/web/Components/Calculation/config/elements-props.tsx +++ b/apps/web/Components/Calculation/config/elements-props.tsx @@ -267,10 +267,6 @@ const props: Partial = { step: 0.1, precision: 2, }, - radioInsKaskoType: { - optionType: 'button', - buttonStyle: 'solid', - }, tbxInsFranchise: { min: 0, max: MAX_FRANCHISE, @@ -425,10 +421,6 @@ const props: Partial = { showSearch: true, optionFilterProp: 'label', }, - radioInfuranceOPF: { - optionType: 'button', - buttonStyle: 'solid', - }, radioGraphType: { spaceProps: { direction: 'vertical', diff --git a/apps/web/Components/Calculation/config/elements-titles.ts b/apps/web/Components/Calculation/config/elements-titles.ts index ef7dd2a..c65b33a 100644 --- a/apps/web/Components/Calculation/config/elements-titles.ts +++ b/apps/web/Components/Calculation/config/elements-titles.ts @@ -74,8 +74,6 @@ const titles: Record = { selectGPSModel: 'Модель GPS', selectRegionRegistration: 'Регион регистрации', selectTownRegistration: 'Город регистрации', - radioInfuranceOPF: 'ОПФ для расчета страховки', - radioInsKaskoType: 'Тип страхования КАСКО', cbxInsDecentral: 'Децентрализованное страхование', tbxInsFranchise: 'Франшиза', cbxInsUnlimitDrivers: 'Неограниченное число водителей', @@ -116,7 +114,6 @@ const titles: Record = { selectObjectCategoryTax: 'Кат. по ТР ТС 018/2011', selectObjectTypeTax: 'Тип ТС для ТН', radioTypePTS: 'Тип ПТС', - tbxINNForCalc: 'ИНН контрагента', selectLegalClientRegion: 'Регион по юр.адресу клиента', selectLegalClientTown: 'Город по юр.адресу клиента', selectSubsidy: 'Субсидия', diff --git a/apps/web/Components/Calculation/config/elements-types.ts b/apps/web/Components/Calculation/config/elements-types.ts index 3fdc4ed..fe954b1 100644 --- a/apps/web/Components/Calculation/config/elements-types.ts +++ b/apps/web/Components/Calculation/config/elements-types.ts @@ -81,7 +81,6 @@ const types = wrapElementsTypes({ cbxInsUnlimitDrivers: t.Value, tbxInsAgeDrivers: t.Value, tbxInsExpDrivers: t.Value, - tbxINNForCalc: t.Value, cbxLastPaymentRedemption: t.Value, cbxPriceWithDiscount: t.Value, cbxFullPriceWithDiscount: t.Value, @@ -155,8 +154,6 @@ const types = wrapElementsTypes({ radioLastPaymentRule: t.Options, radioGraphType: t.Options, radioDeliveryTime: t.Options, - radioInsKaskoType: t.Options, - radioInfuranceOPF: t.Options, selectRequirementTelematic: t.Options, radioQuoteContactGender: t.Options, radioCalcType: t.Options, diff --git a/apps/web/Components/Calculation/config/map/values.ts b/apps/web/Components/Calculation/config/map/values.ts index ed7a9fd..5271277 100644 --- a/apps/web/Components/Calculation/config/map/values.ts +++ b/apps/web/Components/Calculation/config/map/values.ts @@ -80,14 +80,11 @@ const elementsToValues = wrapElementsMap({ selectGPSModel: 'GPSModel', selectRegionRegistration: 'regionRegistration', selectTownRegistration: 'townRegistration', - radioInfuranceOPF: 'infuranceOPF', - radioInsKaskoType: 'insKaskoType', cbxInsDecentral: 'insDecentral', tbxInsFranchise: 'insFranchise', cbxInsUnlimitDrivers: 'insUnlimitDrivers', tbxInsAgeDrivers: 'insAgeDrivers', tbxInsExpDrivers: 'insExpDrivers', - tbxINNForCalc: 'INNForCalc', cbxLastPaymentRedemption: 'lastPaymentRedemption', cbxPriceWithDiscount: 'priceWithDiscount', cbxFullPriceWithDiscount: 'fullPriceWithDiscount', diff --git a/apps/web/Components/Output/Validation.jsx b/apps/web/Components/Output/Validation.jsx index 6435e2b..c66cff2 100644 --- a/apps/web/Components/Output/Validation.jsx +++ b/apps/web/Components/Output/Validation.jsx @@ -25,12 +25,12 @@ const AlertWrapper = styled(Box)` function getElementsErrors($calculation) { return Object.values($calculation.$validation).map((validation) => { - const elementErrors = validation.getMessages(); + const elementErrors = validation.getErrors(); const elementTitle = validation.params.err_title; - return elementErrors.map((error) => ( + return elementErrors.map(({ key, message }) => ( - + )); }); @@ -38,18 +38,22 @@ function getElementsErrors($calculation) { function getPaymentsTableErrors($tables) { const { payments } = $tables; - const messages = payments.validation.getMessages(); + const errors = payments.validation.getErrors(); const title = payments.validation.params.err_title; - return messages.map((text) => ); + return errors.map(({ key, message }) => ( + + )); } function getInsuranceTableErrors($tables) { const { insurance } = $tables; - const messages = insurance.validation.getMessages(); + const errors = insurance.validation.getErrors(); const title = insurance.validation.params.err_title; - return messages.map((text) => ); + return errors.map(({ key, message }) => ( + + )); } const Errors = observer(() => { diff --git a/apps/web/apollo/client.js b/apps/web/apollo/client.js index 012742d..bde795e 100644 --- a/apps/web/apollo/client.js +++ b/apps/web/apollo/client.js @@ -1,17 +1,15 @@ -import getUrls from '@/config/urls'; +import { link } from '@/config/apollo'; import { ApolloClient, InMemoryCache } from '@apollo/client'; import { isServer } from 'tools/common'; /** @type {import('@apollo/client').ApolloClient} */ let apolloClient; -const { URL_CRM_GRAPHQL } = getUrls(); - function createApolloClient() { return new ApolloClient({ cache: new InMemoryCache(), + link, ssrMode: isServer(), - uri: URL_CRM_GRAPHQL, }); } diff --git a/apps/web/config/apollo.js b/apps/web/config/apollo.js new file mode 100644 index 0000000..b98b2a6 --- /dev/null +++ b/apps/web/config/apollo.js @@ -0,0 +1,34 @@ +import getUrls from './urls'; +import { ApolloLink, HttpLink } from '@apollo/client'; + +const { URL_CRM_GRAPHQL } = getUrls(); + +const modifyDataLink = new ApolloLink((operation, forward) => { + const context = operation?.getContext(); + + return forward(operation).map((response) => { + if (!context?.disableModify) { + if (Object.keys(response?.data).includes('evo_addproduct_types')) { + response.data.evo_addproduct_types = response.data.evo_addproduct_types.map((x) => ({ + ...x, + label: `${x.label} (${x.evo_graph_price} руб.)`, + })); + } + + if (Object.keys(response?.data).includes('evo_equipments')) { + response.data.evo_equipments = response.data.evo_equipments.map((x) => ({ + ...x, + label: `${x.label} (${x.evo_start_production_year})`, + })); + } + } + + return response; + }); +}); + +const httpLink = new HttpLink({ + uri: URL_CRM_GRAPHQL, +}); + +export const link = modifyDataLink.concat(httpLink); diff --git a/apps/web/config/default-options.ts b/apps/web/config/default-options.ts index 3951f64..10c5b9b 100644 --- a/apps/web/config/default-options.ts +++ b/apps/web/config/default-options.ts @@ -97,6 +97,139 @@ export const selectObjectCategoryTax = [ value: 100_000_000 + i, })); +export const selectLeaseObjectUseFor = alphabetical( + [ + { + label: 'Для представительских целей', + value: 100_000_000, + }, + { + label: 'Для использования в качестве «такси»', + value: 100_000_001, + }, + { + label: 'Для передачи третьим лицам (прокат; аренда)', + value: 100_000_002, + }, + { + label: 'Каршеринг', + value: 100_000_003, + }, + { + label: 'Тест-драйв', + value: 100_000_004, + }, + { + label: 'Для доставки продуктов конечному потребителю', + value: 100_000_005, + }, + { + label: 'Для обучения вождению', + value: 100_000_006, + }, + { + label: 'Маршрутные такси / Рейсовые автобусы', + value: 100_000_007, + }, + { + label: 'Междугородние перевозки', + value: 100_000_008, + }, + { + label: 'Для перевозки крупногабаритных грузов', + value: 100_000_009, + }, + { + label: 'Для перевозки малогабаритных грузов', + value: 100_000_010, + }, + { + label: 'Для перевозки сотрудников других организаций (водитель ЛП)', + value: 100_000_011, + }, + { + label: 'Для перевозки сотрудников ЛП', + value: 100_000_012, + }, + { + label: 'Для экскурсионных перевозок в т.ч. на торжества; трансфер в аэропорт и пр.', + value: 100_000_013, + }, + { + label: 'Дорожно-строительная техника', + value: 100_000_014, + }, + { + label: 'Жилищно-коммунальное хозяйство', + value: 100_000_015, + }, + { + label: 'Лесное хозяйство', + value: 100_000_016, + }, + { + label: 'Подъёмно-транспортная отрасль', + value: 100_000_017, + }, + { + label: 'Сельское хозяйство', + value: 100_000_018, + }, + { + label: 'Строительство', + value: 100_000_019, + }, + ], + (objectUseFor) => objectUseFor.label.toLowerCase(), + 'asc' +); + +export const radioCalcType = [ + { + label: 'IRR', + value: 100_000_000, + }, + { + label: 'Суммы', + value: 100_000_001, + }, +]; + +export const selectRequirementTelematic = [ + { + label: 'Не требуется', + value: 100_000_004, + }, + { + label: 'START', + value: 100_000_000, + }, + { + label: 'START+', + value: 100_000_001, + }, + { + label: 'COMFORT', + value: 100_000_002, + }, + { + label: 'COMFORT+', + value: 100_000_003, + }, + { + label: 'Omnicomm_1', + value: 100_000_005, + }, + { + label: 'Omnicomm_2', + value: 100_000_006, + }, + { + label: 'Omnicomm_3', + value: 100_000_007, + }, +]; + const defaultOptions: CalculationOptions = { radioLastPaymentRule: [ { @@ -187,114 +320,7 @@ const defaultOptions: CalculationOptions = { }, ], - selectLeaseObjectUseFor: alphabetical( - [ - { - label: 'Для представительских целей', - value: 100_000_000, - }, - { - label: 'Для использования в качестве «такси»', - value: 100_000_001, - }, - { - label: 'Для передачи третьим лицам (прокат; аренда)', - value: 100_000_002, - }, - { - label: 'Каршеринг', - value: 100_000_003, - }, - { - label: 'Тест-драйв', - value: 100_000_004, - }, - { - label: 'Для доставки продуктов конечному потребителю', - value: 100_000_005, - }, - { - label: 'Для обучения вождению', - value: 100_000_006, - }, - { - label: 'Маршрутные такси / Рейсовые автобусы', - value: 100_000_007, - }, - { - label: 'Междугородние перевозки', - value: 100_000_008, - }, - { - label: 'Для перевозки крупногабаритных грузов', - value: 100_000_009, - }, - { - label: 'Для перевозки малогабаритных грузов', - value: 100_000_010, - }, - { - label: 'Для перевозки сотрудников других организаций (водитель ЛП)', - value: 100_000_011, - }, - { - label: 'Для перевозки сотрудников ЛП', - value: 100_000_012, - }, - { - label: 'Для экскурсионных перевозок в т.ч. на торжества; трансфер в аэропорт и пр.', - value: 100_000_013, - }, - { - label: 'Дорожно-строительная техника', - value: 100_000_014, - }, - { - label: 'Жилищно-коммунальное хозяйство', - value: 100_000_015, - }, - { - label: 'Лесное хозяйство', - value: 100_000_016, - }, - { - label: 'Подъёмно-транспортная отрасль', - value: 100_000_017, - }, - { - label: 'Сельское хозяйство', - value: 100_000_018, - }, - { - label: 'Строительство', - value: 100_000_019, - }, - ], - (objectUseFor) => objectUseFor.label.toLowerCase(), - 'asc' - ), - - radioInfuranceOPF: [ - { - label: 'ЮЛ', - value: 100_000_000, - }, - { - label: 'ИП', - value: 100_000_001, - }, - ], - - radioInsKaskoType: [ - { - label: 'Полное', - value: 100_000_000, - }, - { - label: 'Усеченное', - value: 100_000_001, - }, - ], + selectLeaseObjectUseFor, radioQuoteContactGender: [ { @@ -307,50 +333,8 @@ const defaultOptions: CalculationOptions = { }, ], - selectRequirementTelematic: [ - { - label: 'Не требуется', - value: 100_000_004, - }, - { - label: 'START', - value: 100_000_000, - }, - { - label: 'START+', - value: 100_000_001, - }, - { - label: 'COMFORT', - value: 100_000_002, - }, - { - label: 'COMFORT+', - value: 100_000_003, - }, - { - label: 'Omnicomm_1', - value: 100_000_005, - }, - { - label: 'Omnicomm_2', - value: 100_000_006, - }, - { - label: 'Omnicomm_3', - value: 100_000_007, - }, - ], - radioCalcType: [ - { - label: 'IRR', - value: 100_000_000, - }, - { - label: 'Суммы', - value: 100_000_001, - }, - ], + selectRequirementTelematic, + radioCalcType, radioObjectRegistration: [ { label: 'Лизингополучатель', @@ -461,7 +445,6 @@ const defaultOptions: CalculationOptions = { cbxInsUnlimitDrivers: [], tbxInsAgeDrivers: [], tbxInsExpDrivers: [], - tbxINNForCalc: [], cbxLastPaymentRedemption: [], cbxPriceWithDiscount: [], cbxFullPriceWithDiscount: [], diff --git a/apps/web/config/default-statuses.ts b/apps/web/config/default-statuses.ts index b47b4d4..81d0e5f 100644 --- a/apps/web/config/default-statuses.ts +++ b/apps/web/config/default-statuses.ts @@ -31,8 +31,6 @@ const defaultStatuses: CalculationStatuses = { radioCalcType: 'Default', radioDeliveryTime: 'Default', radioGraphType: 'Default', - radioInfuranceOPF: 'Disabled', - radioInsKaskoType: 'Default', radioLastPaymentRule: 'Default', radioObjectRegistration: 'Default', radioQuoteContactGender: 'Default', @@ -102,7 +100,6 @@ const defaultStatuses: CalculationStatuses = { tbxFinDepartmentRewardSumm: 'Disabled', tbxFirstPaymentPerc: 'Default', tbxFirstPaymentRub: 'Default', - tbxINNForCalc: 'Disabled', tbxIRR_Perc: 'Default', tbxImportProgramSum: 'Default', tbxImporterRewardPerc: 'Disabled', diff --git a/apps/web/config/default-values.ts b/apps/web/config/default-values.ts index 7f4dee4..5050599 100644 --- a/apps/web/config/default-values.ts +++ b/apps/web/config/default-values.ts @@ -55,14 +55,11 @@ const defaultValues: CalculationValues = { indAgent: null, indAgentRewardCondition: null, indAgentRewardSumm: 0, - infuranceOPF: null, - INNForCalc: 0, insAgeDrivers: 0, insDecentral: false, insExpDrivers: 0, insFranchise: 0, insKaskoPriceLeasePeriod: 0, - insKaskoType: 100_000_000, insNSIB: null, insUnlimitDrivers: true, insurance: true, diff --git a/apps/web/config/process/default.ts b/apps/web/config/process/default.ts index 66e22e7..b3c88a4 100644 --- a/apps/web/config/process/default.ts +++ b/apps/web/config/process/default.ts @@ -1,3 +1,4 @@ +import * as addProduct from '@/process/add-product'; import * as bonuses from '@/process/bonuses'; import * as calculate from '@/process/calculate'; import * as configurator from '@/process/configurator'; @@ -5,12 +6,14 @@ import * as createKP from '@/process/create-kp'; import * as fingap from '@/process/fingap'; import * as gibdd from '@/process/gibdd'; import { useProcess } from '@/process/hooks'; +import * as insurance from '@/process/insurance'; import * as leadOpportunity from '@/process/lead-opportunity'; import * as leasingObject from '@/process/leasing-object'; import * as leasingWithoutKasko from '@/process/leasing-without-kasko'; import * as loadKP from '@/process/load-kp'; import * as payments from '@/process/payments'; import * as price from '@/process/price'; +import * as recalc from '@/process/recalc'; import * as subsidy from '@/process/subsidy'; import * as subsidyImportProgram from '@/process/subsidy-import-program'; import * as supplierAgent from '@/process/supplier-agent'; @@ -23,7 +26,6 @@ export default function useReactions() { useProcess(supplierAgent); useProcess(price); useProcess(fingap); - useProcess(loadKP); useProcess(leasingWithoutKasko); useProcess(subsidy); useProcess(leasingObject); @@ -34,4 +36,7 @@ export default function useReactions() { useProcess(subsidyImportProgram); useProcess(payments); useProcess(gibdd); + useProcess(addProduct); + useProcess(insurance); + useProcess(recalc); } diff --git a/apps/web/config/schema/values.ts b/apps/web/config/schema/values.ts index f05826c..4c821a1 100644 --- a/apps/web/config/schema/values.ts +++ b/apps/web/config/schema/values.ts @@ -52,13 +52,10 @@ const ValuesSchema = z indAgent: z.string().nullable(), indAgentRewardCondition: z.string().nullable(), indAgentRewardSumm: z.number(), - infuranceOPF: z.number().nullable(), - INNForCalc: z.number(), insAgeDrivers: z.number(), insDecentral: z.boolean(), insExpDrivers: z.number(), insFranchise: z.number(), - insKaskoType: z.number().nullable(), insNSIB: z.string().nullable(), insUnlimitDrivers: z.boolean(), insurance: z.boolean(), diff --git a/apps/web/constants/values.js b/apps/web/constants/values.js index ae2d4ca..55ec457 100644 --- a/apps/web/constants/values.js +++ b/apps/web/constants/values.js @@ -7,3 +7,5 @@ export const MAX_LEASING_PERIOD = 60; export const MIN_LASTPAYMENT_NSIB = 3500; export const MIN_PAYMENT = 3; export const VAT = 0.2; +export const MAX_MASS = 3500; +export const MAX_VEHICLE_SEATS = 20; diff --git a/apps/web/graphql/crm.query.graphql b/apps/web/graphql/crm.query.graphql index a03234a..5ace66c 100644 --- a/apps/web/graphql/crm.query.graphql +++ b/apps/web/graphql/crm.query.graphql @@ -72,12 +72,31 @@ query GetQuotes($leadid: Uuid!) { quotes(evo_leadid: $leadid) { label: evo_quotename value: quoteid + evo_recalc_limit + evo_statuscodeidData { + evo_id + } + evo_purchases_participation } } query GetQuote($quoteId: Uuid!) { quote(quoteId: $quoteId) { evo_baseproductid + evo_one_year_insurance + evo_min_change_price + evo_max_price_change + evo_discount_supplier_currency + evo_equip_price + evo_program_import_subsidy_sum + evo_nds_in_price_supplier_currency + evo_supplier_currency_price + evo_approved_first_payment + evo_recalc_limit + evo_max_mass + evo_seats + evo_year + evo_last_payment_perc } } @@ -111,6 +130,10 @@ query GetTarif($tarifId: Uuid!) { evo_min_irr evo_cut_irr_with_bonus_coefficient evo_max_irr + evo_rates { + evo_datefrom + evo_rateid + } } } @@ -163,6 +186,7 @@ query GetProduct($productId: Uuid!) { evo_sale_without_nds evo_cut_proportion_bonus_director evo_cut_irr_with_bonus + evo_sale_without_nds } } @@ -249,6 +273,13 @@ query GetGPSBrands { } } +query GetGPSModels($gpsBrandId: Uuid!) { + evo_gps_models(evo_gps_brandid: $gpsBrandId) { + label: evo_name + value: evo_gps_modelid + } +} + query GetLeaseObjectTypes { evo_leasingobject_types(statecode: 0) { label: evo_name @@ -278,6 +309,7 @@ query GetBrands { query GetBrand($brandId: Uuid!) { evo_brand(evo_brandid: $brandId) { + evo_id evo_importer_reward_perc evo_importer_reward_rub } @@ -306,6 +338,7 @@ query GetConfigurations($modelId: Uuid!) { evo_equipments(statecode: 0, evo_modelid: $modelId) { label: evo_name value: evo_equipmentid + evo_start_production_year } } @@ -342,6 +375,12 @@ query GetDealerPersons($dealerId: Uuid!) { } } +query GetDealerPerson($dealerPersonId: Uuid!) { + account(accountid: $dealerPersonId) { + evo_supplier_type + } +} + query GetAgent($agentid: Uuid!) { agent: account(accountid: $agentid) { label: name @@ -402,19 +441,30 @@ query GetSystemUser($domainname: String) { } } +fragment CoreAddProductTypesFields on evo_addproduct_type { + evo_graph_price + label: evo_name + value: evo_addproduct_typeid +} + query GetAddproductTypes($currentDate: DateTime) { evo_addproduct_types( statecode: 0 evo_datefrom_param: { lte: $currentDate } evo_dateto_param: { gte: $currentDate } ) { - label: evo_name - value: evo_addproduct_typeid - evo_graph_price + ...CoreAddProductTypesFields evo_product_type } } +query GetAddProductType($addproductTypeId: Uuid!) { + evo_addproduct_type(evo_addproduct_typeid: $addproductTypeId) { + evo_description + evo_helpcard_type + } +} + query GetRegistrationTypes($currentDate: DateTime) { evo_addproduct_types( statecode: 0 @@ -422,9 +472,7 @@ query GetRegistrationTypes($currentDate: DateTime) { evo_dateto_param: { gte: $currentDate } evo_product_type: 100000001 ) { - label: evo_name - value: evo_addproduct_typeid - evo_graph_price + ...CoreAddProductTypesFields evo_leasingobject_types { evo_leasingobject_typeid } @@ -436,8 +484,113 @@ query GetRegistrationTypes($currentDate: DateTime) { } } -query GetAddProductType($addproductTypeId: Uuid!) { - evo_addproduct_type(evo_addproduct_typeid: $addproductTypeId) { - evo_description +query GetTechnicalCards($currentDate: DateTime) { + evo_addproduct_types( + statecode: 0 + evo_datefrom_param: { lte: $currentDate } + evo_dateto_param: { gte: $currentDate } + evo_product_type: 100000000 + ) { + ...CoreAddProductTypesFields + evo_min_period + evo_max_period + evo_leasingobject_types { + evo_leasingobject_typeid + } + evo_helpcard_type + } +} + +query GetFuelCards($currentDate: DateTime) { + evo_addproduct_types( + statecode: 0 + evo_datefrom_param: { lte: $currentDate } + evo_dateto_param: { gte: $currentDate } + evo_product_type: 100000005 + ) { + ...CoreAddProductTypesFields + evo_min_period + evo_max_period + evo_leasingobject_types { + evo_leasingobject_typeid + } + } +} + +query GetTelematicTypes($currentDate: DateTime) { + evo_addproduct_types( + statecode: 0 + evo_datefrom_param: { lte: $currentDate } + evo_dateto_param: { gte: $currentDate } + evo_product_type: 100000004 + ) { + ...CoreAddProductTypesFields + evo_controls_program + evo_visible_calc + } +} + +query GetTrackerTypes($currentDate: DateTime) { + evo_addproduct_types( + statecode: 0 + evo_datefrom_param: { lte: $currentDate } + evo_dateto_param: { gte: $currentDate } + evo_product_type: 100000003 + ) { + ...CoreAddProductTypesFields + evo_controls_program + evo_visible_calc + } +} + +query GetInsNSIBTypes($currentDate: DateTime) { + evo_addproduct_types( + statecode: 0 + evo_datefrom_param: { lte: $currentDate } + evo_dateto_param: { gte: $currentDate } + evo_product_type: 100000002 + ) { + ...CoreAddProductTypesFields + } +} + +query GetLeasingWithoutKaskoTypes($currentDate: DateTime) { + evo_addproduct_types( + statecode: 0 + evo_product_type: 100000007 + evo_datefrom_param: { lte: $currentDate } + evo_dateto_param: { gte: $currentDate } + ) { + ...CoreAddProductTypesFields + evo_product_type + evo_min_period + evo_max_period + evo_min_price + evo_max_price + evo_leasingobject_types { + evo_leasingobject_typeid + } + evo_visible_calc + evo_min_first_payment_perc + evo_max_first_payment_perc + evo_models { + evo_modelid + } + } +} + +query GetInsuranceCompany($accountId: Uuid!) { + account(accountid: $accountId) { + evo_osago_with_kasko + } +} + +query GetInsuranceCompanies { + accounts(evo_account_type: [100000002], statecode: 0) { + evo_type_ins_policy + evo_evokasko_access + evo_inn + value: accountid + label: name } } diff --git a/apps/web/graphql/crm.types.ts b/apps/web/graphql/crm.types.ts index d3aa73f..9d759bc 100644 --- a/apps/web/graphql/crm.types.ts +++ b/apps/web/graphql/crm.types.ts @@ -168,14 +168,14 @@ export type GetQuotesQueryVariables = Exact<{ }>; -export type GetQuotesQuery = { __typename?: 'Query', quotes: Array<{ __typename?: 'quote', label: string | null, value: string | null } | null> | null }; +export type GetQuotesQuery = { __typename?: 'Query', quotes: Array<{ __typename?: 'quote', evo_recalc_limit: number | null, evo_purchases_participation: boolean | null, label: string | null, value: string | null, evo_statuscodeidData: { __typename?: 'evo_statuscode', evo_id: string | null } | null } | null> | null }; export type GetQuoteQueryVariables = Exact<{ quoteId: Scalars['Uuid']; }>; -export type GetQuoteQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_baseproductid: string | null } | null }; +export type GetQuoteQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_baseproductid: string | null, evo_one_year_insurance: boolean | null, evo_min_change_price: number | null, evo_max_price_change: number | null, evo_discount_supplier_currency: number | null, evo_equip_price: number | null, evo_program_import_subsidy_sum: number | null, evo_nds_in_price_supplier_currency: number | null, evo_supplier_currency_price: number | null, evo_approved_first_payment: number | null, evo_recalc_limit: number | null, evo_max_mass: number | null, evo_seats: number | null, evo_year: number | null, evo_last_payment_perc: number | null } | null }; export type GetTarifsQueryVariables = Exact<{ currentDate: InputMaybe; @@ -189,7 +189,7 @@ export type GetTarifQueryVariables = Exact<{ }>; -export type GetTarifQuery = { __typename?: 'Query', evo_tarif: { __typename?: 'evo_tarif', evo_irr: number | null, evo_graphtype_exception: Array | null, evo_seasons_type_exception: Array | null, evo_min_decreasing_perc: number | null, evo_min_irr: number | null, evo_cut_irr_with_bonus_coefficient: number | null, evo_max_irr: number | null } | null }; +export type GetTarifQuery = { __typename?: 'Query', evo_tarif: { __typename?: 'evo_tarif', evo_irr: number | null, evo_graphtype_exception: Array | null, evo_seasons_type_exception: Array | null, evo_min_decreasing_perc: number | null, evo_min_irr: number | null, evo_cut_irr_with_bonus_coefficient: number | null, evo_max_irr: number | null, evo_rates: Array<{ __typename?: 'evo_rate', evo_datefrom: string | null, evo_rateid: string | null } | null> | null } | null }; export type GetRatesQueryVariables = Exact<{ currentDate: InputMaybe; @@ -264,6 +264,13 @@ export type GetGpsBrandsQueryVariables = Exact<{ [key: string]: never; }>; export type GetGpsBrandsQuery = { __typename?: 'Query', evo_gps_brands: Array<{ __typename?: 'evo_gps_brand', label: string | null, value: string | null } | null> | null }; +export type GetGpsModelsQueryVariables = Exact<{ + gpsBrandId: Scalars['Uuid']; +}>; + + +export type GetGpsModelsQuery = { __typename?: 'Query', evo_gps_models: Array<{ __typename?: 'evo_gps_model', label: string | null, value: string | null } | null> | null }; + export type GetLeaseObjectTypesQueryVariables = Exact<{ [key: string]: never; }>; @@ -286,7 +293,7 @@ export type GetBrandQueryVariables = Exact<{ }>; -export type GetBrandQuery = { __typename?: 'Query', evo_brand: { __typename?: 'evo_brand', evo_importer_reward_perc: number | null, evo_importer_reward_rub: number | null } | null }; +export type GetBrandQuery = { __typename?: 'Query', evo_brand: { __typename?: 'evo_brand', evo_id: string | null, evo_importer_reward_perc: number | null, evo_importer_reward_rub: number | null } | null }; export type GetModelsQueryVariables = Exact<{ brandId: Scalars['Uuid']; @@ -307,7 +314,7 @@ export type GetConfigurationsQueryVariables = Exact<{ }>; -export type GetConfigurationsQuery = { __typename?: 'Query', evo_equipments: Array<{ __typename?: 'evo_equipment', label: string | null, value: string | null } | null> | null }; +export type GetConfigurationsQuery = { __typename?: 'Query', evo_equipments: Array<{ __typename?: 'evo_equipment', evo_start_production_year: number | null, label: string | null, value: string | null } | null> | null }; export type GetConfigurationQueryVariables = Exact<{ configurationId: Scalars['Uuid']; @@ -335,6 +342,13 @@ export type GetDealerPersonsQueryVariables = Exact<{ export type GetDealerPersonsQuery = { __typename?: 'Query', dealerPersons: Array<{ __typename?: 'account', accountid: string | null, evo_inn: string | null, evo_kpp: string | null, label: string | null, value: string | null } | null> | null }; +export type GetDealerPersonQueryVariables = Exact<{ + dealerPersonId: Scalars['Uuid']; +}>; + + +export type GetDealerPersonQuery = { __typename?: 'Query', account: { __typename?: 'account', evo_supplier_type: number | null } | null }; + export type GetAgentQueryVariables = Exact<{ agentid: Scalars['Uuid']; }>; @@ -379,26 +393,89 @@ export type GetSystemUserQueryVariables = Exact<{ export type GetSystemUserQuery = { __typename?: 'Query', systemuser: { __typename?: 'systemuser', evo_job_titleid: string | null } | null }; +export type CoreAddProductTypesFieldsFragment = { __typename?: 'evo_addproduct_type', evo_graph_price: number | null, label: string | null, value: string | null }; + export type GetAddproductTypesQueryVariables = Exact<{ currentDate: InputMaybe; }>; -export type GetAddproductTypesQuery = { __typename?: 'Query', evo_addproduct_types: Array<{ __typename?: 'evo_addproduct_type', evo_graph_price: number | null, evo_product_type: number | null, label: string | null, value: string | null } | null> | null }; - -export type GetRegistrationTypesQueryVariables = Exact<{ - currentDate: InputMaybe; -}>; - - -export type GetRegistrationTypesQuery = { __typename?: 'Query', evo_addproduct_types: Array<{ __typename?: 'evo_addproduct_type', evo_graph_price: number | null, evo_whom_register: number | null, evo_gibdd_region: boolean | null, evo_pts_type: Array | null, evo_accountid: string | null, evo_towtruck: boolean | null, label: string | null, value: string | null, evo_leasingobject_types: Array<{ __typename?: 'evo_leasingobject_type', evo_leasingobject_typeid: string | null } | null> | null } | null> | null }; +export type GetAddproductTypesQuery = { __typename?: 'Query', evo_addproduct_types: Array<{ __typename?: 'evo_addproduct_type', evo_product_type: number | null, evo_graph_price: number | null, label: string | null, value: string | null } | null> | null }; export type GetAddProductTypeQueryVariables = Exact<{ addproductTypeId: Scalars['Uuid']; }>; -export type GetAddProductTypeQuery = { __typename?: 'Query', evo_addproduct_type: { __typename?: 'evo_addproduct_type', evo_description: string | null } | null }; +export type GetAddProductTypeQuery = { __typename?: 'Query', evo_addproduct_type: { __typename?: 'evo_addproduct_type', evo_description: string | null, evo_helpcard_type: number | null } | null }; + +export type GetRegistrationTypesQueryVariables = Exact<{ + currentDate: InputMaybe; +}>; + + +export type GetRegistrationTypesQuery = { __typename?: 'Query', evo_addproduct_types: Array<{ __typename?: 'evo_addproduct_type', evo_whom_register: number | null, evo_gibdd_region: boolean | null, evo_pts_type: Array | null, evo_accountid: string | null, evo_towtruck: boolean | null, evo_graph_price: number | null, label: string | null, value: string | null, evo_leasingobject_types: Array<{ __typename?: 'evo_leasingobject_type', evo_leasingobject_typeid: string | null } | null> | null } | null> | null }; + +export type GetTechnicalCardsQueryVariables = Exact<{ + currentDate: InputMaybe; +}>; + + +export type GetTechnicalCardsQuery = { __typename?: 'Query', evo_addproduct_types: Array<{ __typename?: 'evo_addproduct_type', evo_min_period: number | null, evo_max_period: number | null, evo_helpcard_type: number | null, evo_graph_price: number | null, label: string | null, value: string | null, evo_leasingobject_types: Array<{ __typename?: 'evo_leasingobject_type', evo_leasingobject_typeid: string | null } | null> | null } | null> | null }; + +export type GetFuelCardsQueryVariables = Exact<{ + currentDate: InputMaybe; +}>; + + +export type GetFuelCardsQuery = { __typename?: 'Query', evo_addproduct_types: Array<{ __typename?: 'evo_addproduct_type', evo_min_period: number | null, evo_max_period: number | null, evo_graph_price: number | null, label: string | null, value: string | null, evo_leasingobject_types: Array<{ __typename?: 'evo_leasingobject_type', evo_leasingobject_typeid: string | null } | null> | null } | null> | null }; + +export type GetTelematicTypesQueryVariables = Exact<{ + currentDate: InputMaybe; +}>; + + +export type GetTelematicTypesQuery = { __typename?: 'Query', evo_addproduct_types: Array<{ __typename?: 'evo_addproduct_type', evo_controls_program: Array | null, evo_visible_calc: boolean | null, evo_graph_price: number | null, label: string | null, value: string | null } | null> | null }; + +export type GetTrackerTypesQueryVariables = Exact<{ + currentDate: InputMaybe; +}>; + + +export type GetTrackerTypesQuery = { __typename?: 'Query', evo_addproduct_types: Array<{ __typename?: 'evo_addproduct_type', evo_controls_program: Array | null, evo_visible_calc: boolean | null, evo_graph_price: number | null, label: string | null, value: string | null } | null> | null }; + +export type GetInsNsibTypesQueryVariables = Exact<{ + currentDate: InputMaybe; +}>; + + +export type GetInsNsibTypesQuery = { __typename?: 'Query', evo_addproduct_types: Array<{ __typename?: 'evo_addproduct_type', evo_graph_price: number | null, label: string | null, value: string | null } | null> | null }; + +export type GetLeasingWithoutKaskoTypesQueryVariables = Exact<{ + currentDate: InputMaybe; +}>; + + +export type GetLeasingWithoutKaskoTypesQuery = { __typename?: 'Query', evo_addproduct_types: Array<{ __typename?: 'evo_addproduct_type', evo_product_type: number | null, evo_min_period: number | null, evo_max_period: number | null, evo_min_price: number | null, evo_max_price: number | null, evo_visible_calc: boolean | null, evo_min_first_payment_perc: number | null, evo_max_first_payment_perc: number | null, evo_graph_price: number | null, label: string | null, value: string | null, evo_leasingobject_types: Array<{ __typename?: 'evo_leasingobject_type', evo_leasingobject_typeid: string | null } | null> | null, evo_models: Array<{ __typename?: 'evo_model', evo_modelid: string | null } | null> | null } | null> | null }; + +export type GetInsuranceCompanyQueryVariables = Exact<{ + accountId: Scalars['Uuid']; +}>; + + +export type GetInsuranceCompanyQuery = { __typename?: 'Query', account: { __typename?: 'account', evo_osago_with_kasko: boolean | null } | null }; + +export type GetInsuranceCompaniesQueryVariables = Exact<{ [key: string]: never; }>; + + +export type GetInsuranceCompaniesQuery = { __typename?: 'Query', accounts: Array<{ __typename?: 'account', evo_type_ins_policy: Array | null, evo_evokasko_access: boolean | null, evo_inn: string | null, value: string | null, label: string | null } | null> | null }; + +export type GetQuoteAddProductDataQueryVariables = Exact<{ + quoteId: Scalars['Uuid']; +}>; + + +export type GetQuoteAddProductDataQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_addproduct_types: Array<{ __typename?: 'evo_addproduct_type', evo_product_type: number | null, evo_addproduct_typeid: string | null } | null> | null } | null }; export type GetQuoteBonusDataQueryVariables = Exact<{ quoteId: Scalars['Uuid']; @@ -412,7 +489,7 @@ export type GetQuoteConfiguratorDataQueryVariables = Exact<{ }>; -export type GetQuoteConfiguratorDataQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_baseproductid: string | null } | null }; +export type GetQuoteConfiguratorDataQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_baseproductid: string | null, evo_client_typeid: string | null, evo_msfo_irr: number | null } | null }; export type GetQuoteFingapDataQueryVariables = Exact<{ quoteId: Scalars['Uuid']; @@ -433,7 +510,7 @@ export type GetQuoteGibddDataQueryVariables = Exact<{ }>; -export type GetQuoteGibddDataQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_db_accept_registration: number | null, evo_object_registration: number | null, evo_pts_type: number | null, evo_vehicle_tax_year: number | null, evo_vehicle_tax_approved: number | null, evo_category_tr: number | null, evo_vehicle_type_tax: number | null, evo_regionid: string | null, evo_townid: string | null, evo_legal_regionid: string | null, evo_legal_townid: string | null, evo_registration_regionid: string | null, evo_addproduct_types: Array<{ __typename?: 'evo_addproduct_type', evo_product_type: number | null, evo_addproduct_typeid: string | null } | null> | null } | null }; +export type GetQuoteGibddDataQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_db_accept_registration: number | null, evo_object_registration: number | null, evo_pts_type: number | null, evo_vehicle_tax_year: number | null, evo_vehicle_tax_approved: number | null, evo_category_tr: number | null, evo_vehicle_type_tax: number | null, evo_regionid: string | null, evo_townid: string | null, evo_legal_regionid: string | null, evo_legal_townid: string | null, evo_registration_regionid: string | null, evo_req_telematic: number | null, evo_req_telematic_accept: number | null } | null }; export type GetQuoteRegionTownQueryVariables = Exact<{ quoteId: Scalars['Uuid']; @@ -442,19 +519,12 @@ export type GetQuoteRegionTownQueryVariables = Exact<{ export type GetQuoteRegionTownQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_regionid: string | null, evo_townid: string | null, evo_legal_regionid: string | null, evo_legal_townid: string | null } | null }; -export type GetInsuranceDataQueryVariables = Exact<{ - evo_account_type: InputMaybe | Scalars['Int']>; -}>; - - -export type GetInsuranceDataQuery = { __typename?: 'Query', osago: Array<{ __typename?: 'account', value: string | null, label: string | null } | null> | null, kasko: Array<{ __typename?: 'account', value: string | null, label: string | null } | null> | null, fingap: Array<{ __typename?: 'account', value: string | null, label: string | null } | null> | null }; - export type GetQuoteInsuranceDataQueryVariables = Exact<{ quoteId: Scalars['Uuid']; }>; -export type GetQuoteInsuranceDataQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_osago_accountid: string | null, evo_osago_payer: number | null, evo_osago_price: number | null, evo_kasko_accountid: string | null, evo_kasko_payer: number | null, evo_kasko_price: number | null, evo_insurance_period: number | null, evo_fingap_accountid: string | null, evo_fingap_payer: number | null, evo_fingap_period: number | null } | null }; +export type GetQuoteInsuranceDataQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_osago_accountid: string | null, evo_osago_payer: number | null, evo_osago_price: number | null, evo_kasko_accountid: string | null, evo_kasko_payer: number | null, evo_kasko_price: number | null, evo_insurance_period: number | null, evo_fingap_accountid: string | null, evo_fingap_payer: number | null, evo_fingap_period: number | null, evo_gps_brandid: string | null, evo_gps_modelid: string | null, evo_insurance_decentral: boolean | null, evo_franchise: number | null, evo_unlimit_drivers: boolean | null, evo_age_drivers: number | null, evo_exp_drivers: number | null } | null }; export type GetLeadUrlQueryVariables = Exact<{ id: Scalars['Uuid']; @@ -484,13 +554,6 @@ export type GetQuoteLeasingObjectDataQueryVariables = Exact<{ export type GetQuoteLeasingObjectDataQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_brandid: string | null, evo_category: number | null, evo_delivery_time: number | null, evo_engine_hours: number | null, evo_engine_type: number | null, evo_engine_volume: number | null, evo_equipmentid: string | null, evo_leasingobject_typeid: string | null, evo_leasingobject_used: boolean | null, evo_max_mass: number | null, evo_max_speed: number | null, evo_mileage: number | null, evo_modelid: string | null, evo_object_count: number | null, evo_power: number | null, evo_recalc_limit: number | null, evo_seats: number | null, evo_trailer: boolean | null, evo_use_for: number | null, evo_vin: string | null, evo_year: number | null } | null }; -export type GetLeasingWithoutKaskoOptionsQueryVariables = Exact<{ - currentDate: InputMaybe; -}>; - - -export type GetLeasingWithoutKaskoOptionsQuery = { __typename?: 'Query', evo_addproduct_types: Array<{ __typename?: 'evo_addproduct_type', evo_product_type: number | null, evo_min_period: number | null, evo_max_period: number | null, evo_min_price: number | null, evo_max_price: number | null, evo_visible_calc: boolean | null, evo_min_first_payment_perc: number | null, evo_max_first_payment_perc: number | null, label: string | null, value: string | null, evo_leasingobject_types: Array<{ __typename?: 'evo_leasingobject_type', evo_leasingobject_typeid: string | null } | null> | null, evo_models: Array<{ __typename?: 'evo_model', evo_modelid: string | null } | null> | null } | null> | null }; - export type GetQuotePaymentsDataQueryVariables = Exact<{ quoteId: Scalars['Uuid']; }>; @@ -503,7 +566,7 @@ export type GetQuotePriceDataQueryVariables = Exact<{ }>; -export type GetQuotePriceDataQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_comission_rub: number | null, evo_comission_perc: number | null, evo_discount_perc: number | null, evo_discount_supplier_currency: number | null, evo_first_payment_perc: number | null, evo_last_payment_calc: number | null, evo_last_payment_perc: number | null, evo_last_payment_rub: number | null, evo_nds_in_price_supplier_currency: number | null, evo_price_without_nds_supplier_currency: number | null, evo_supplier_currency_price: number | null, evo_transactioncurrencyid: string | null } | null }; +export type GetQuotePriceDataQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_comission_rub: number | null, evo_comission_perc: number | null, evo_discount_perc: number | null, evo_discount_supplier_currency: number | null, evo_first_payment_perc: number | null, evo_last_payment_calc: number | null, evo_last_payment_perc: number | null, evo_last_payment_rub: number | null, evo_nds_in_price_supplier_currency: number | null, evo_price_without_nds_supplier_currency: number | null, evo_supplier_currency_price: number | null, evo_transactioncurrencyid: string | null, evo_equip_price: number | null } | null }; export type GetQuoteSubsidyDataQueryVariables = Exact<{ quoteId: Scalars['Uuid']; @@ -526,7 +589,7 @@ export type GetQuoteAgentsDataQueryVariables = Exact<{ export type GetQuoteAgentsDataQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_supplier_accountid: string | null, evo_dealer_person_accountid: string | null, evo_dealer_reward_conditionid: string | null, evo_dealer_reward_total: number | null, evo_dealer_reward_summ: number | null, evo_dealer_broker_accountid: string | null, evo_dealer_broker_reward_conditionid: string | null, evo_dealer_broker_reward_total: number | null, evo_dealer_broker_reward_summ: number | null, evo_agent_accountid: string | null, evo_agent_reward_conditionid: string | null, evo_agent_reward_total: number | null, evo_agent_reward_summ: number | null, evo_double_agent_accountid: string | null, evo_double_agent_reward_conditionid: string | null, evo_double_agent_reward_total: number | null, evo_double_agent_reward_summ: number | null, evo_broker_accountid: string | null, evo_broker_reward_conditionid: string | null, evo_broker_reward_total: number | null, evo_broker_reward_summ: number | null, evo_fin_department_accountid: string | null, evo_fin_department_reward_conditionid: string | null, evo_fin_department_reward_total: number | null, evo_fin_department_reward_summ: number | null } | null }; - +export const CoreAddProductTypesFieldsFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"CoreAddProductTypesFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"evo_addproduct_type"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_graph_price"}},{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_addproduct_typeid"}}]}}]} as unknown as DocumentNode; export const GetTransactionCurrenciesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetTransactionCurrencies"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"transactioncurrencies"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"currencyname"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"transactioncurrencyid"}},{"kind":"Field","name":{"kind":"Name","value":"transactioncurrencyid"}},{"kind":"Field","name":{"kind":"Name","value":"isocurrencycode"}},{"kind":"Field","name":{"kind":"Name","value":"currencysymbol"}}]}}]}}]} as unknown as DocumentNode; export const GetTransactionCurrencyDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetTransactionCurrency"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currencyid"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"transactioncurrency"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"transactioncurrencyid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currencyid"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currencysymbol"}},{"kind":"Field","name":{"kind":"Name","value":"isocurrencycode"}}]}}]}}]} as unknown as DocumentNode; export const GetCurrencyChangesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetCurrencyChanges"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_currencychanges"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_coursedate_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"eq"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_currencychange"}},{"kind":"Field","name":{"kind":"Name","value":"evo_ref_transactioncurrency"}}]}}]}}]} as unknown as DocumentNode; @@ -534,14 +597,14 @@ export const GetLeadsDocument = {"kind":"Document","definitions":[{"kind":"Opera export const GetLeadDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLead"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"leadid"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"lead"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"leadid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"leadid"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_agent_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_double_agent_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_broker_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fin_department_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_opportunityidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"opportunityid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_inn"}},{"kind":"Field","name":{"kind":"Name","value":"accountidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_address_legalidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_region_fias_id"}},{"kind":"Field","name":{"kind":"Name","value":"evo_city_fias_id"}}]}}]}}]}}]}}]} as unknown as DocumentNode; export const GetOpportunityDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetOpportunity"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"opportunityid"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"opportunity"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"opportunityid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"opportunityid"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leadid"}},{"kind":"Field","name":{"kind":"Name","value":"accountidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_address_legalidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_region_fias_id"}},{"kind":"Field","name":{"kind":"Name","value":"evo_city_fias_id"}}]}}]}}]}}]}}]} as unknown as DocumentNode; export const GetOpportunitiesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetOpportunities"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"domainname"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"opportunities"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"owner_domainname"},"value":{"kind":"Variable","name":{"kind":"Name","value":"domainname"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"opportunityid"}}]}}]}}]} as unknown as DocumentNode; -export const GetQuotesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuotes"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"leadid"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quotes"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_leadid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"leadid"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_quotename"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"quoteid"}}]}}]}}]} as unknown as DocumentNode; -export const GetQuoteDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuote"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_baseproductid"}}]}}]}}]} as unknown as DocumentNode; +export const GetQuotesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuotes"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"leadid"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quotes"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_leadid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"leadid"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_quotename"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"quoteid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_recalc_limit"}},{"kind":"Field","name":{"kind":"Name","value":"evo_statuscodeidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_id"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_purchases_participation"}}]}}]}}]} as unknown as DocumentNode; +export const GetQuoteDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuote"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_baseproductid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_one_year_insurance"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_change_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_price_change"}},{"kind":"Field","name":{"kind":"Name","value":"evo_discount_supplier_currency"}},{"kind":"Field","name":{"kind":"Name","value":"evo_equip_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_program_import_subsidy_sum"}},{"kind":"Field","name":{"kind":"Name","value":"evo_nds_in_price_supplier_currency"}},{"kind":"Field","name":{"kind":"Name","value":"evo_supplier_currency_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_approved_first_payment"}},{"kind":"Field","name":{"kind":"Name","value":"evo_recalc_limit"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_mass"}},{"kind":"Field","name":{"kind":"Name","value":"evo_seats"}},{"kind":"Field","name":{"kind":"Name","value":"evo_year"}},{"kind":"Field","name":{"kind":"Name","value":"evo_last_payment_perc"}}]}}]}}]} as unknown as DocumentNode; export const GetTarifsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetTarifs"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_tarifs"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_tarifid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_tarifid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_baseproductid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_delivery_time"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_first_payment"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_first_payment"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_last_payment"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_last_payment"}},{"kind":"Field","name":{"kind":"Name","value":"evo_used"}}]}}]}}]} as unknown as DocumentNode; -export const GetTarifDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetTarif"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"tarifId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_tarif"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_tarifid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"tarifId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_irr"}},{"kind":"Field","name":{"kind":"Name","value":"evo_graphtype_exception"}},{"kind":"Field","name":{"kind":"Name","value":"evo_seasons_type_exception"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_decreasing_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_irr"}},{"kind":"Field","name":{"kind":"Name","value":"evo_cut_irr_with_bonus_coefficient"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_irr"}}]}}]}}]} as unknown as DocumentNode; +export const GetTarifDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetTarif"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"tarifId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_tarif"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_tarifid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"tarifId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_irr"}},{"kind":"Field","name":{"kind":"Name","value":"evo_graphtype_exception"}},{"kind":"Field","name":{"kind":"Name","value":"evo_seasons_type_exception"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_decreasing_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_irr"}},{"kind":"Field","name":{"kind":"Name","value":"evo_cut_irr_with_bonus_coefficient"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_irr"}},{"kind":"Field","name":{"kind":"Name","value":"evo_rates"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_datefrom"}},{"kind":"Field","name":{"kind":"Name","value":"evo_rateid"}}]}}]}}]}}]} as unknown as DocumentNode; export const GetRatesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRates"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_rates"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_rateid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id"}},{"kind":"Field","name":{"kind":"Name","value":"evo_tarifs"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_tarifid"}}]}}]}}]}}]} as unknown as DocumentNode; export const GetRateDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRate"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"rateId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_rate"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_rateid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"rateId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_base_rate"}}]}}]}}]} as unknown as DocumentNode; export const GetProductsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetProducts"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_baseproducts"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_relation"},"value":{"kind":"ListValue","values":[{"kind":"IntValue","value":"100000000"}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_baseproductid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_baseproductid"}}]}}]}}]} as unknown as DocumentNode; -export const GetProductDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetProduct"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"productId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_baseproduct"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_baseproductid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"productId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_calculation_method"}},{"kind":"Field","name":{"kind":"Name","value":"evo_baseproducts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_baseproductid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_brands"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_brandid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_sale_without_nds"}},{"kind":"Field","name":{"kind":"Name","value":"evo_cut_proportion_bonus_director"}},{"kind":"Field","name":{"kind":"Name","value":"evo_cut_irr_with_bonus"}}]}}]}}]} as unknown as DocumentNode; +export const GetProductDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetProduct"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"productId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_baseproduct"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_baseproductid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"productId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_calculation_method"}},{"kind":"Field","name":{"kind":"Name","value":"evo_baseproducts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_baseproductid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_brands"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_brandid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_sale_without_nds"}},{"kind":"Field","name":{"kind":"Name","value":"evo_cut_proportion_bonus_director"}},{"kind":"Field","name":{"kind":"Name","value":"evo_cut_irr_with_bonus"}},{"kind":"Field","name":{"kind":"Name","value":"evo_sale_without_nds"}}]}}]}}]} as unknown as DocumentNode; export const GetSubsidiesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetSubsidies"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_subsidies"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_subsidyid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_subsidy_type"}}]}}]}}]} as unknown as DocumentNode; export const GetSubsidyDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetSubsidy"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"subsidyId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_subsidy"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_subsidyid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"subsidyId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"accounts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accountid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_brands"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_brandid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_models"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_modelid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_subsidy_summ"}},{"kind":"Field","name":{"kind":"Name","value":"evo_percent_subsidy"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_subsidy_summ"}}]}}]}}]} as unknown as DocumentNode; export const GetImportProgramDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetImportProgram"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"importProgramId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"importProgram"},"name":{"kind":"Name","value":"evo_subsidy"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_subsidyid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"importProgramId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"accounts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accountid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_brands"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_brandid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_models"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_modelid"}}]}}]}}]}}]} as unknown as DocumentNode; @@ -549,41 +612,50 @@ export const GetRegionsDocument = {"kind":"Document","definitions":[{"kind":"Ope export const GetRegionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRegion"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"regionId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_region"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_regionid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"regionId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_oktmo"}},{"kind":"Field","name":{"kind":"Name","value":"accounts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accountid"}}]}}]}}]}}]} as unknown as DocumentNode; export const GetTownsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetTowns"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"regionId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_towns"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_regionid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"regionId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_fias_id"}},{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_townid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_businessunit_evolution"}}]}}]}}]} as unknown as DocumentNode; export const GetGpsBrandsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetGPSBrands"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_gps_brands"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_gps_brandid"}}]}}]}}]} as unknown as DocumentNode; +export const GetGpsModelsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetGPSModels"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"gpsBrandId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_gps_models"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_gps_brandid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"gpsBrandId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_gps_modelid"}}]}}]}}]} as unknown as DocumentNode; export const GetLeaseObjectTypesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLeaseObjectTypes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_leasingobject_typeid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}}]}}]} as unknown as DocumentNode; export const GetLeaseObjectTypeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLeaseObjectType"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"leaseObjectTypeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_type"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_leasingobject_typeid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"leaseObjectTypeId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id"}},{"kind":"Field","name":{"kind":"Name","value":"evo_category"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type_tax"}},{"kind":"Field","name":{"kind":"Name","value":"evo_category_tr"}}]}}]}}]} as unknown as DocumentNode; export const GetBrandsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetBrands"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_brands"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_brandid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_brandid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type"}}]}}]}}]} as unknown as DocumentNode; -export const GetBrandDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetBrand"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"brandId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_brand"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_brandid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"brandId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_importer_reward_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_importer_reward_rub"}}]}}]}}]} as unknown as DocumentNode; +export const GetBrandDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetBrand"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"brandId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_brand"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_brandid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"brandId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_id"}},{"kind":"Field","name":{"kind":"Name","value":"evo_importer_reward_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_importer_reward_rub"}}]}}]}}]} as unknown as DocumentNode; export const GetModelsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetModels"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"brandId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_models"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_brandid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"brandId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_modelid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_modelid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type"}}]}}]}}]} as unknown as DocumentNode; export const GetModelDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetModel"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"modelId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_model"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_modelid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"modelId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_impairment_groupidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_importer_reward_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_importer_reward_rub"}}]}}]}}]} as unknown as DocumentNode; -export const GetConfigurationsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetConfigurations"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"modelId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_equipments"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_modelid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"modelId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_equipmentid"}}]}}]}}]} as unknown as DocumentNode; +export const GetConfigurationsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetConfigurations"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"modelId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_equipments"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_modelid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"modelId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_equipmentid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_start_production_year"}}]}}]}}]} as unknown as DocumentNode; export const GetConfigurationDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetConfiguration"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"configurationId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_equipment"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_equipmentid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"configurationId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_impairment_groupidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_name"}}]}}]}}]}}]} as unknown as DocumentNode; export const GetDealersDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetDealers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"dealers"},"name":{"kind":"Name","value":"accounts"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_account_type"},"value":{"kind":"ListValue","values":[{"kind":"IntValue","value":"100000001"}]}},{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_legal_form"},"value":{"kind":"IntValue","value":"100000001"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"accountid"}},{"kind":"Field","name":{"kind":"Name","value":"accountid"}}]}}]}}]} as unknown as DocumentNode; export const GetDealerDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetDealer"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"dealerId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"dealer"},"name":{"kind":"Name","value":"account"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"accountid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"dealerId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_return_leasing_dealer"}},{"kind":"Field","name":{"kind":"Name","value":"evo_broker_accountid"}}]}}]}}]} as unknown as DocumentNode; export const GetDealerPersonsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetDealerPersons"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"dealerId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"dealerPersons"},"name":{"kind":"Name","value":"salon_providers"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"salonaccountid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"dealerId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"accountid"}},{"kind":"Field","name":{"kind":"Name","value":"accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_inn"}},{"kind":"Field","name":{"kind":"Name","value":"evo_kpp"}}]}}]}}]} as unknown as DocumentNode; +export const GetDealerPersonDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetDealerPerson"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"dealerPersonId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"account"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"accountid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"dealerPersonId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_supplier_type"}}]}}]}}]} as unknown as DocumentNode; export const GetAgentDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetAgent"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"agentid"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"agent"},"name":{"kind":"Name","value":"account"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"accountid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"agentid"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"accountid"}}]}}]}}]} as unknown as DocumentNode; export const GetRewardConditionsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRewardConditions"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"agentid"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_reward_conditions"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_agent_accountid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"agentid"}}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_agency_agreementid_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"has"},"value":{"kind":"BooleanValue","value":true}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_reward_conditionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_reward_summ"}}]}}]}}]} as unknown as DocumentNode; export const GetRewardConditionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRewardCondition"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"conditionId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_reward_condition"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_reward_conditionid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"conditionId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_reward_summ"}},{"kind":"Field","name":{"kind":"Name","value":"evo_reduce_reward"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_reward_summ"}},{"kind":"Field","name":{"kind":"Name","value":"evo_agency_agreementidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_required_reward"}},{"kind":"Field","name":{"kind":"Name","value":"evo_reward_without_other_agent"}}]}}]}}]}}]} as unknown as DocumentNode; export const GetSotCoefficientTypeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetSotCoefficientType"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"evo_id"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_sot_coefficient_type"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"evo_id"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_sot_coefficient_typeid"}}]}}]}}]} as unknown as DocumentNode; export const GetCoefficientsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetCoefficients"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"jobTitleId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_coefficients"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_job_titleid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"jobTitleId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_job_titleid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_sot_coefficient_typeid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_baseproducts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_baseproductid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_sot_coefficient"}}]}}]}}]} as unknown as DocumentNode; export const GetSystemUserDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetSystemUser"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"domainname"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"systemuser"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"domainname"},"value":{"kind":"Variable","name":{"kind":"Name","value":"domainname"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_job_titleid"}}]}}]}}]} as unknown as DocumentNode; -export const GetAddproductTypesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetAddproductTypes"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_addproduct_typeid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_graph_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_product_type"}}]}}]}}]} as unknown as DocumentNode; -export const GetRegistrationTypesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRegistrationTypes"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_product_type"},"value":{"kind":"IntValue","value":"100000001"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_addproduct_typeid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_graph_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_whom_register"}},{"kind":"Field","name":{"kind":"Name","value":"evo_gibdd_region"}},{"kind":"Field","name":{"kind":"Name","value":"evo_pts_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_towtruck"}}]}}]}}]} as unknown as DocumentNode; -export const GetAddProductTypeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetAddProductType"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"addproductTypeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_type"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_addproduct_typeid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"addproductTypeId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_description"}}]}}]}}]} as unknown as DocumentNode; +export const GetAddproductTypesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetAddproductTypes"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"CoreAddProductTypesFields"}},{"kind":"Field","name":{"kind":"Name","value":"evo_product_type"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"CoreAddProductTypesFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"evo_addproduct_type"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_graph_price"}},{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_addproduct_typeid"}}]}}]} as unknown as DocumentNode; +export const GetAddProductTypeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetAddProductType"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"addproductTypeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_type"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_addproduct_typeid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"addproductTypeId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_description"}},{"kind":"Field","name":{"kind":"Name","value":"evo_helpcard_type"}}]}}]}}]} as unknown as DocumentNode; +export const GetRegistrationTypesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRegistrationTypes"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_product_type"},"value":{"kind":"IntValue","value":"100000001"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"CoreAddProductTypesFields"}},{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_whom_register"}},{"kind":"Field","name":{"kind":"Name","value":"evo_gibdd_region"}},{"kind":"Field","name":{"kind":"Name","value":"evo_pts_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_towtruck"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"CoreAddProductTypesFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"evo_addproduct_type"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_graph_price"}},{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_addproduct_typeid"}}]}}]} as unknown as DocumentNode; +export const GetTechnicalCardsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetTechnicalCards"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_product_type"},"value":{"kind":"IntValue","value":"100000000"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"CoreAddProductTypesFields"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_helpcard_type"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"CoreAddProductTypesFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"evo_addproduct_type"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_graph_price"}},{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_addproduct_typeid"}}]}}]} as unknown as DocumentNode; +export const GetFuelCardsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetFuelCards"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_product_type"},"value":{"kind":"IntValue","value":"100000005"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"CoreAddProductTypesFields"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"CoreAddProductTypesFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"evo_addproduct_type"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_graph_price"}},{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_addproduct_typeid"}}]}}]} as unknown as DocumentNode; +export const GetTelematicTypesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetTelematicTypes"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_product_type"},"value":{"kind":"IntValue","value":"100000004"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"CoreAddProductTypesFields"}},{"kind":"Field","name":{"kind":"Name","value":"evo_controls_program"}},{"kind":"Field","name":{"kind":"Name","value":"evo_visible_calc"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"CoreAddProductTypesFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"evo_addproduct_type"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_graph_price"}},{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_addproduct_typeid"}}]}}]} as unknown as DocumentNode; +export const GetTrackerTypesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetTrackerTypes"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_product_type"},"value":{"kind":"IntValue","value":"100000003"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"CoreAddProductTypesFields"}},{"kind":"Field","name":{"kind":"Name","value":"evo_controls_program"}},{"kind":"Field","name":{"kind":"Name","value":"evo_visible_calc"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"CoreAddProductTypesFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"evo_addproduct_type"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_graph_price"}},{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_addproduct_typeid"}}]}}]} as unknown as DocumentNode; +export const GetInsNsibTypesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetInsNSIBTypes"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_product_type"},"value":{"kind":"IntValue","value":"100000002"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"CoreAddProductTypesFields"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"CoreAddProductTypesFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"evo_addproduct_type"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_graph_price"}},{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_addproduct_typeid"}}]}}]} as unknown as DocumentNode; +export const GetLeasingWithoutKaskoTypesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLeasingWithoutKaskoTypes"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_product_type"},"value":{"kind":"IntValue","value":"100000007"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"CoreAddProductTypesFields"}},{"kind":"Field","name":{"kind":"Name","value":"evo_product_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_visible_calc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_first_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_first_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_models"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_modelid"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"CoreAddProductTypesFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"evo_addproduct_type"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_graph_price"}},{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_addproduct_typeid"}}]}}]} as unknown as DocumentNode; +export const GetInsuranceCompanyDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetInsuranceCompany"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"accountId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"account"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"accountid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"accountId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_osago_with_kasko"}}]}}]}}]} as unknown as DocumentNode; +export const GetInsuranceCompaniesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetInsuranceCompanies"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accounts"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_account_type"},"value":{"kind":"ListValue","values":[{"kind":"IntValue","value":"100000002"}]}},{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_type_ins_policy"}},{"kind":"Field","name":{"kind":"Name","value":"evo_evokasko_access"}},{"kind":"Field","name":{"kind":"Name","value":"evo_inn"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"accountid"}},{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"name"}}]}}]}}]} as unknown as DocumentNode; +export const GetQuoteAddProductDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteAddProductData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_product_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_typeid"}}]}}]}}]}}]} as unknown as DocumentNode; export const GetQuoteBonusDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteBonusData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_sale_bonus"}}]}}]}}]} as unknown as DocumentNode; -export const GetQuoteConfiguratorDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteConfiguratorData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_baseproductid"}}]}}]}}]} as unknown as DocumentNode; +export const GetQuoteConfiguratorDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteConfiguratorData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_baseproductid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_client_typeid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_msfo_irr"}}]}}]}}]} as unknown as DocumentNode; export const GetQuoteFingapDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteFingapData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_product_risks"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_typeid"}}]}}]}}]}}]} as unknown as DocumentNode; export const GetFinGapAddProductTypesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetFinGAPAddProductTypes"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_product_type"},"value":{"kind":"IntValue","value":"100000006"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_typeid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","name":{"kind":"Name","value":"evo_type_calc_cerebellum"}},{"kind":"Field","name":{"kind":"Name","value":"evo_cost_service_provider_withoutnds"}},{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_typeid"}}]}}]}}]}}]} as unknown as DocumentNode; -export const GetQuoteGibddDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteGibddData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_db_accept_registration"}},{"kind":"Field","name":{"kind":"Name","value":"evo_object_registration"}},{"kind":"Field","name":{"kind":"Name","value":"evo_pts_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_tax_year"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_tax_approved"}},{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_product_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_typeid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_category_tr"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type_tax"}},{"kind":"Field","name":{"kind":"Name","value":"evo_regionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_townid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_legal_regionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_legal_townid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_registration_regionid"}}]}}]}}]} as unknown as DocumentNode; +export const GetQuoteGibddDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteGibddData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_db_accept_registration"}},{"kind":"Field","name":{"kind":"Name","value":"evo_object_registration"}},{"kind":"Field","name":{"kind":"Name","value":"evo_pts_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_tax_year"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_tax_approved"}},{"kind":"Field","name":{"kind":"Name","value":"evo_category_tr"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type_tax"}},{"kind":"Field","name":{"kind":"Name","value":"evo_regionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_townid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_legal_regionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_legal_townid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_registration_regionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_req_telematic"}},{"kind":"Field","name":{"kind":"Name","value":"evo_req_telematic_accept"}}]}}]}}]} as unknown as DocumentNode; export const GetQuoteRegionTownDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteRegionTown"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_regionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_townid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_legal_regionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_legal_townid"}}]}}]}}]} as unknown as DocumentNode; -export const GetInsuranceDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetInsuranceData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"evo_account_type"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"osago"},"name":{"kind":"Name","value":"accounts"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_account_type"},"value":{"kind":"Variable","name":{"kind":"Name","value":"evo_account_type"}}},{"kind":"Argument","name":{"kind":"Name","value":"evo_type_ins_policy"},"value":{"kind":"ListValue","values":[{"kind":"IntValue","value":"100000001"}]}},{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"accountid"}},{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","alias":{"kind":"Name","value":"kasko"},"name":{"kind":"Name","value":"accounts"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_account_type"},"value":{"kind":"Variable","name":{"kind":"Name","value":"evo_account_type"}}},{"kind":"Argument","name":{"kind":"Name","value":"evo_type_ins_policy"},"value":{"kind":"ListValue","values":[{"kind":"IntValue","value":"100000000"}]}},{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"accountid"}},{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","alias":{"kind":"Name","value":"fingap"},"name":{"kind":"Name","value":"accounts"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_account_type"},"value":{"kind":"Variable","name":{"kind":"Name","value":"evo_account_type"}}},{"kind":"Argument","name":{"kind":"Name","value":"evo_type_ins_policy"},"value":{"kind":"ListValue","values":[{"kind":"IntValue","value":"100000002"}]}},{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"accountid"}},{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"name"}}]}}]}}]} as unknown as DocumentNode; -export const GetQuoteInsuranceDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteInsuranceData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_osago_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_osago_payer"}},{"kind":"Field","name":{"kind":"Name","value":"evo_osago_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_kasko_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_kasko_payer"}},{"kind":"Field","name":{"kind":"Name","value":"evo_kasko_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_insurance_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fingap_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fingap_payer"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fingap_period"}}]}}]}}]} as unknown as DocumentNode; +export const GetQuoteInsuranceDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteInsuranceData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_osago_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_osago_payer"}},{"kind":"Field","name":{"kind":"Name","value":"evo_osago_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_kasko_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_kasko_payer"}},{"kind":"Field","name":{"kind":"Name","value":"evo_kasko_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_insurance_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fingap_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fingap_payer"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fingap_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_gps_brandid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_gps_modelid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_insurance_decentral"}},{"kind":"Field","name":{"kind":"Name","value":"evo_franchise"}},{"kind":"Field","name":{"kind":"Name","value":"evo_unlimit_drivers"}},{"kind":"Field","name":{"kind":"Name","value":"evo_age_drivers"}},{"kind":"Field","name":{"kind":"Name","value":"evo_exp_drivers"}}]}}]}}]} as unknown as DocumentNode; export const GetLeadUrlDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLeadUrl"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"entity"},"name":{"kind":"Name","value":"lead"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"leadid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"link"}}]}}]}}]} as unknown as DocumentNode; export const GetOpportunityUrlDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetOpportunityUrl"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"entity"},"name":{"kind":"Name","value":"opportunity"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"opportunityid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"link"}}]}}]}}]} as unknown as DocumentNode; export const GetQuoteUrlDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteUrl"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"entity"},"name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"link"}}]}}]}}]} as unknown as DocumentNode; export const GetQuoteLeasingObjectDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteLeasingObjectData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_brandid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_category"}},{"kind":"Field","name":{"kind":"Name","value":"evo_delivery_time"}},{"kind":"Field","name":{"kind":"Name","value":"evo_engine_hours"}},{"kind":"Field","name":{"kind":"Name","value":"evo_engine_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_engine_volume"}},{"kind":"Field","name":{"kind":"Name","value":"evo_equipmentid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_used"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_mass"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_speed"}},{"kind":"Field","name":{"kind":"Name","value":"evo_mileage"}},{"kind":"Field","name":{"kind":"Name","value":"evo_modelid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_object_count"}},{"kind":"Field","name":{"kind":"Name","value":"evo_power"}},{"kind":"Field","name":{"kind":"Name","value":"evo_recalc_limit"}},{"kind":"Field","name":{"kind":"Name","value":"evo_seats"}},{"kind":"Field","name":{"kind":"Name","value":"evo_trailer"}},{"kind":"Field","name":{"kind":"Name","value":"evo_use_for"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vin"}},{"kind":"Field","name":{"kind":"Name","value":"evo_year"}}]}}]}}]} as unknown as DocumentNode; -export const GetLeasingWithoutKaskoOptionsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLeasingWithoutKaskoOptions"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_product_type"},"value":{"kind":"IntValue","value":"100000007"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_addproduct_typeid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_product_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_visible_calc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_first_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_first_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_models"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_modelid"}}]}}]}}]}}]} as unknown as DocumentNode; export const GetQuotePaymentsDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuotePaymentsData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_accept_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_first_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_last_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_graph_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_payments_decrease_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_seasons_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_high_season"}},{"kind":"Field","name":{"kind":"Name","value":"evo_graphs"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createdon"}},{"kind":"Field","name":{"kind":"Name","value":"evo_sumpay_withnds"}},{"kind":"Field","name":{"kind":"Name","value":"evo_planpayments"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_payment_ratio"}}]}}]}}]}}]}}]} as unknown as DocumentNode; -export const GetQuotePriceDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuotePriceData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_comission_rub"}},{"kind":"Field","name":{"kind":"Name","value":"evo_comission_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_discount_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_discount_supplier_currency"}},{"kind":"Field","name":{"kind":"Name","value":"evo_first_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_last_payment_calc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_last_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_last_payment_rub"}},{"kind":"Field","name":{"kind":"Name","value":"evo_nds_in_price_supplier_currency"}},{"kind":"Field","name":{"kind":"Name","value":"evo_price_without_nds_supplier_currency"}},{"kind":"Field","name":{"kind":"Name","value":"evo_supplier_currency_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_transactioncurrencyid"}}]}}]}}]} as unknown as DocumentNode; +export const GetQuotePriceDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuotePriceData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_comission_rub"}},{"kind":"Field","name":{"kind":"Name","value":"evo_comission_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_discount_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_discount_supplier_currency"}},{"kind":"Field","name":{"kind":"Name","value":"evo_first_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_last_payment_calc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_last_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_last_payment_rub"}},{"kind":"Field","name":{"kind":"Name","value":"evo_nds_in_price_supplier_currency"}},{"kind":"Field","name":{"kind":"Name","value":"evo_price_without_nds_supplier_currency"}},{"kind":"Field","name":{"kind":"Name","value":"evo_supplier_currency_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_transactioncurrencyid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_equip_price"}}]}}]}}]} as unknown as DocumentNode; export const GetQuoteSubsidyDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteSubsidyData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_subsidyid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_program_import_subsidyid"}}]}}]}}]} as unknown as DocumentNode; export const GetRewardRulesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRewardRules"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"conditionId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_reward_condition"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_reward_conditionid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"conditionId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_calc_reward_rules"}}]}}]}}]} as unknown as DocumentNode; export const GetQuoteAgentsDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteAgentsData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_supplier_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_dealer_person_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_dealer_reward_conditionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_dealer_reward_total"}},{"kind":"Field","name":{"kind":"Name","value":"evo_dealer_reward_summ"}},{"kind":"Field","name":{"kind":"Name","value":"evo_dealer_broker_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_dealer_broker_reward_conditionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_dealer_broker_reward_total"}},{"kind":"Field","name":{"kind":"Name","value":"evo_dealer_broker_reward_summ"}},{"kind":"Field","name":{"kind":"Name","value":"evo_agent_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_agent_reward_conditionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_agent_reward_total"}},{"kind":"Field","name":{"kind":"Name","value":"evo_agent_reward_summ"}},{"kind":"Field","name":{"kind":"Name","value":"evo_double_agent_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_double_agent_reward_conditionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_double_agent_reward_total"}},{"kind":"Field","name":{"kind":"Name","value":"evo_double_agent_reward_summ"}},{"kind":"Field","name":{"kind":"Name","value":"evo_broker_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_broker_reward_conditionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_broker_reward_total"}},{"kind":"Field","name":{"kind":"Name","value":"evo_broker_reward_summ"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fin_department_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fin_department_reward_conditionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fin_department_reward_total"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fin_department_reward_summ"}}]}}]}}]} as unknown as DocumentNode; \ No newline at end of file diff --git a/apps/web/process/add-product/get-kp-data.ts b/apps/web/process/add-product/get-kp-data.ts new file mode 100644 index 0000000..720a59c --- /dev/null +++ b/apps/web/process/add-product/get-kp-data.ts @@ -0,0 +1,71 @@ +import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types'; +import initializeApollo from '@/apollo/client'; +import defaultValues from '@/config/default-values'; +import * as CRMTypes from '@/graphql/crm.types'; +import { gql } from '@apollo/client'; + +const QUERY_GET_QUOTE_ADD_PRODUCT_DATA = gql` + query GetQuoteAddProductData($quoteId: Uuid!) { + quote(quoteId: $quoteId) { + evo_addproduct_types { + evo_product_type + evo_addproduct_typeid + } + } + } +`; + +export async function getKPData({ + values: { quote: quoteId }, +}: GetQuoteInputData): Promise { + const apolloClient = initializeApollo(); + + const { + data: { quote }, + } = await apolloClient.query({ + query: CRMTypes.GetQuoteAddProductDataDocument, + variables: { + quoteId, + }, + }); + + const registration = + quote?.evo_addproduct_types?.find((x) => x?.evo_product_type === 100_000_001) + ?.evo_addproduct_typeid ?? defaultValues.registration; + + const technicalCard = + quote?.evo_addproduct_types?.find((x) => x?.evo_product_type === 100_000_000) + ?.evo_addproduct_typeid ?? defaultValues.technicalCard; + + const insNSIB = + quote?.evo_addproduct_types?.find((x) => x?.evo_product_type === 100_000_002) + ?.evo_addproduct_typeid ?? defaultValues.insNSIB; + + const tracker = + quote?.evo_addproduct_types?.find((x) => x?.evo_product_type === 100_000_003) + ?.evo_addproduct_typeid ?? defaultValues.tracker; + + const telematic = + quote?.evo_addproduct_types?.find((x) => x?.evo_product_type === 100_000_004) + ?.evo_addproduct_typeid ?? defaultValues.telematic; + + const fuelCard = + quote?.evo_addproduct_types?.find((x) => x?.evo_product_type === 100_000_005) + ?.evo_addproduct_typeid ?? defaultValues.fuelCard; + + const leasingWithoutKasko = + quote?.evo_addproduct_types?.find((x) => x?.evo_product_type === 100_000_007) + ?.evo_addproduct_typeid ?? defaultValues.leasingWithoutKasko; + + return { + values: { + fuelCard, + insNSIB, + leasingWithoutKasko, + registration, + technicalCard, + telematic, + tracker, + }, + }; +} diff --git a/apps/web/process/add-product/index.ts b/apps/web/process/add-product/index.ts new file mode 100644 index 0000000..e05ea2d --- /dev/null +++ b/apps/web/process/add-product/index.ts @@ -0,0 +1,2 @@ +export * from './get-kp-data'; +export * as reactions from './reactions'; diff --git a/apps/web/process/add-product/reactions.ts b/apps/web/process/add-product/reactions.ts new file mode 100644 index 0000000..3963bb4 --- /dev/null +++ b/apps/web/process/add-product/reactions.ts @@ -0,0 +1,120 @@ +import type { ProcessContext } from '../types'; +import * as CRMTypes from '@/graphql/crm.types'; +import dayjs from 'dayjs'; +import utc from 'dayjs/plugin/utc'; +import { reaction } from 'mobx'; +import { normalizeOptions } from 'tools'; + +dayjs.extend(utc); + +export default function reactions({ store, apolloClient }: ProcessContext) { + const { $calculation } = store; + + reaction( + () => $calculation.$values.getValues(['leasingPeriod', 'leaseObjectType']), + async ({ leasingPeriod, leaseObjectType }) => { + const currentDate = dayjs().utc(false).format('YYYY-MM-DD'); + + const { + data: { evo_addproduct_types }, + } = await apolloClient.query({ + query: CRMTypes.GetTechnicalCardsDocument, + variables: { currentDate }, + }); + + const options = evo_addproduct_types?.filter( + (evo_addproduct_type) => + Boolean( + evo_addproduct_type?.evo_min_period && + evo_addproduct_type.evo_min_period <= leasingPeriod + ) && + Boolean( + evo_addproduct_type?.evo_max_period && + evo_addproduct_type.evo_max_period >= leasingPeriod + ) && + Boolean( + leaseObjectType && + evo_addproduct_type?.evo_leasingobject_types?.find( + (x) => x?.evo_leasingobject_typeid === leaseObjectType + ) + ) + ); + + $calculation.element('selectTechnicalCard').setOptions(normalizeOptions(options)); + + const currentTechnicalCardId = $calculation.element('selectTechnicalCard').getValue(); + if (currentTechnicalCardId) { + const { + data: { evo_addproduct_type }, + } = await apolloClient.query({ + query: CRMTypes.GetAddProductTypeDocument, + variables: { addproductTypeId: currentTechnicalCardId }, + }); + + const nextTechnicalCard = options?.find( + (x) => x?.evo_helpcard_type === evo_addproduct_type?.evo_helpcard_type + ); + + if (nextTechnicalCard) { + $calculation.element('selectTechnicalCard').setValue(nextTechnicalCard?.value); + } else { + $calculation.element('selectTechnicalCard').resetValue(); + } + } + }, + { + fireImmediately: true, + } + ); + + reaction( + () => $calculation.$values.getValues(['leasingPeriod', 'leaseObjectType']), + async ({ leasingPeriod, leaseObjectType }) => { + const currentDate = dayjs().utc(false).format('YYYY-MM-DD'); + + const { + data: { evo_addproduct_types }, + } = await apolloClient.query({ + query: CRMTypes.GetFuelCardsDocument, + variables: { currentDate }, + }); + + const options = evo_addproduct_types?.filter( + (evo_addproduct_type) => + Boolean( + evo_addproduct_type?.evo_min_period && + evo_addproduct_type.evo_min_period <= leasingPeriod + ) && + Boolean( + evo_addproduct_type?.evo_max_period && + evo_addproduct_type.evo_max_period >= leasingPeriod + ) && + Boolean( + leaseObjectType && + evo_addproduct_type?.evo_leasingobject_types?.find( + (x) => x?.evo_leasingobject_typeid === leaseObjectType + ) + ) + ); + + $calculation.element('selectFuelCard').setOptions(normalizeOptions(options)); + }, + { + fireImmediately: true, + } + ); + + reaction( + () => $calculation.element('tbxLeasingPeriod').getValue(), + (leasingPeriod) => { + if (leasingPeriod < 12) { + $calculation.element('selectInsNSIB').resetValue().block(); + } else { + $calculation.element('selectInsNSIB').unblock(); + } + }, + { + fireImmediately: true, + } + ); +} diff --git a/apps/web/process/bonuses/reactions/lib/helper.ts b/apps/web/process/bonuses/lib/helper.ts similarity index 86% rename from apps/web/process/bonuses/reactions/lib/helper.ts rename to apps/web/process/bonuses/lib/helper.ts index 4536fee..0077d02 100644 --- a/apps/web/process/bonuses/reactions/lib/helper.ts +++ b/apps/web/process/bonuses/lib/helper.ts @@ -1,5 +1,4 @@ -/* eslint-disable @typescript-eslint/naming-convention */ -import type { ProcessContext } from '../../../types'; +import type { ValidationContext } from '../../types'; import { getUser } from '@/api/user/query'; import type { ElementsTypes } from '@/Components/Calculation/config/map/values'; import { STALE_TIME } from '@/constants/request'; @@ -8,7 +7,7 @@ import dayjs from 'dayjs'; export type ProductId = ElementsTypes['selectProduct']; -export default function helper({ apolloClient, queryClient }: ProcessContext) { +export default function helper({ apolloClient, queryClient }: ValidationContext) { return { async getCoefficient(productId: ProductId) { if (!productId) { @@ -32,7 +31,7 @@ export default function helper({ apolloClient, queryClient }: ProcessContext) { return null; } - const currentDate = dayjs().utc(false).toISOString(); + const currentDate = dayjs().utc(false).format('YYYY-MM-DD'); const { data: { evo_coefficients }, diff --git a/apps/web/process/bonuses/reactions/common.ts b/apps/web/process/bonuses/reactions/common.ts index 93a4fdc..b8af8b5 100644 --- a/apps/web/process/bonuses/reactions/common.ts +++ b/apps/web/process/bonuses/reactions/common.ts @@ -1,11 +1,10 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import type { ProcessContext } from '../../types'; -import helper from './lib/helper'; -import { makeDisposable } from '@/../../packages/tools'; +import helper from '../lib/helper'; import * as CRMTypes from '@/graphql/crm.types'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; import { reaction } from 'mobx'; +import { makeDisposable } from 'tools'; dayjs.extend(utc); diff --git a/apps/web/process/bonuses/reactions/validation.ts b/apps/web/process/bonuses/reactions/validation.ts index 961c169..d8ff572 100644 --- a/apps/web/process/bonuses/reactions/validation.ts +++ b/apps/web/process/bonuses/reactions/validation.ts @@ -1,23 +1,35 @@ -import helper from './lib/helper'; +import { createValidationSchema } from '../validation'; +import type { Elements } from '@/Components/Calculation/config/map/values'; import type { ProcessContext } from '@/process/types'; +import ValidationHelper from '@/stores/validation/helper'; import { reaction } from 'mobx'; -import { round } from 'tools'; +import { uid } from 'radash'; + +const key = uid(7); export default function reactions(context: ProcessContext) { const { store } = context; const { $calculation } = store; - const { getCoefficient } = helper(context); + const validationSchema = createValidationSchema(context); + const helper = new ValidationHelper(); reaction( () => $calculation.$values.getValues(['product', 'saleBonus']), - async ({ product: productId, saleBonus }) => { - const coefficient = await getCoefficient(productId); - const maxBonus = (coefficient?.evo_sot_coefficient || 0) * 100; + async (values) => { + helper.removeErrors(); + const validationResult = await validationSchema.safeParseAsync(values); - $calculation.element('tbxSaleBonus').validate({ - invalid: round(saleBonus, 2) > round(maxBonus, 2), - message: 'Размер бонуса МПЛ не может быть выше установленного по СОТ', - }); + if (!validationResult.success) { + validationResult.error.errors.forEach(({ path, message }) => { + (path as Elements[]).forEach((elementName) => { + const removeError = $calculation.element(elementName).setError({ key, message }); + if (removeError) helper.add(removeError); + }); + }); + } + }, + { + delay: 100, } ); } diff --git a/apps/web/process/bonuses/validation.ts b/apps/web/process/bonuses/validation.ts new file mode 100644 index 0000000..6727bda --- /dev/null +++ b/apps/web/process/bonuses/validation.ts @@ -0,0 +1,24 @@ +import type { ValidationContext } from '../types'; +import helper from './lib/helper'; +import ValuesSchema from '@/config/schema/values'; +import { round } from 'tools'; +import { z } from 'zod'; + +export function createValidationSchema(context: ValidationContext) { + const { getCoefficient } = helper(context); + + return ValuesSchema.pick({ product: true, saleBonus: true }).superRefine( + async ({ product, saleBonus }, ctx) => { + const coefficient = await getCoefficient(product); + const maxBonus = (coefficient?.evo_sot_coefficient || 0) * 100; + + if (round(saleBonus, 2) > round(maxBonus, 2)) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Размер бонуса МПЛ не может быть выше установленного по СОТ', + path: ['tbxSaleBonus'], + }); + } + } + ); +} diff --git a/apps/web/process/calculate/reactions/common.ts b/apps/web/process/calculate/reactions/common.ts index aa940f3..dcc81ac 100644 --- a/apps/web/process/calculate/reactions/common.ts +++ b/apps/web/process/calculate/reactions/common.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import * as CRMTypes from '@/graphql/crm.types'; import type { ProcessContext } from '@/process/types'; import { reaction } from 'mobx'; diff --git a/apps/web/process/calculate/reactions/validation.ts b/apps/web/process/calculate/reactions/validation.ts index 1ace7fb..18c95ae 100644 --- a/apps/web/process/calculate/reactions/validation.ts +++ b/apps/web/process/calculate/reactions/validation.ts @@ -2,7 +2,9 @@ import types from '@/Components/Calculation/config/elements-types'; import type * as Values from '@/Components/Calculation/config/map/values'; import type * as Insurance from '@/Components/Calculation/Form/Insurance/InsuranceTable/types'; import type { ProcessContext } from '@/process/types'; +import ValidationHelper from '@/stores/validation/helper'; import { reaction } from 'mobx'; +import { uid } from 'radash'; import type { BaseOption } from 'ui/elements/types'; function hasInvalidValueOrOptions(value: unknown, options: Array>) { @@ -21,6 +23,7 @@ export default function reactions({ store }: ProcessContext) { const hasElementsErrors = Object.values($calculation.$validation).some( (validation) => validation.hasErrors ); + const hasPaymentsErrors = $tables.payments.validation.hasErrors; const hasInsuranceErrors = $tables.insurance.validation.hasErrors; const hasFingapErrors = $tables.fingap.validation.hasErrors; @@ -44,6 +47,10 @@ export default function reactions({ store }: ProcessContext) { /** * Проверяем, что выбранное значение элемента есть в списке */ + + const key = uid(7); + const message = 'Выбранное значение отсутствует в списке'; + function validateOptionsElement(elementName: Values.Elements) { const type = types[elementName]; if (type().typeName !== 'Options') { @@ -52,6 +59,8 @@ export default function reactions({ store }: ProcessContext) { const element = $calculation.element(elementName); + const validationHelper = new ValidationHelper(); + reaction( () => { const options = element.getOptions(); @@ -63,11 +72,16 @@ export default function reactions({ store }: ProcessContext) { }; }, ({ value, options }) => { - element.validate({ - invalid: hasInvalidValueOrOptions(value, options), - message: 'Выбранное значение отсутствует в списке', - silent: true, - }); + if (hasInvalidValueOrOptions(value, options)) { + const removeError = element.setError({ + key, + message, + silent: true, + }); + if (removeError) validationHelper.add(removeError); + } else { + validationHelper.removeErrors(); + } }, { delay: 100, @@ -95,6 +109,8 @@ export default function reactions({ store }: ProcessContext) { function validateInsuranceCompany(rowKey: Insurance.Keys) { const row = $tables.insurance.row(rowKey); + const validationHelper = new ValidationHelper(); + reaction( () => { const options = row.getOptions('insuranceCompany'); @@ -106,11 +122,16 @@ export default function reactions({ store }: ProcessContext) { }; }, ({ value, options }) => { - $tables.insurance.validate({ - invalid: hasInvalidValueOrOptions(value, options), - message: 'Выбранное значение отсутствует в списке', - silent: true, - }); + if (hasInvalidValueOrOptions(value, options)) { + const removeError = $tables.insurance.setError({ + key, + message, + silent: true, + }); + validationHelper.add(removeError); + } else { + validationHelper.removeErrors(); + } }, { delay: 100, diff --git a/apps/web/process/configurator/get-kp-data.ts b/apps/web/process/configurator/get-kp-data.ts index a440c94..cb590fc 100644 --- a/apps/web/process/configurator/get-kp-data.ts +++ b/apps/web/process/configurator/get-kp-data.ts @@ -1,5 +1,6 @@ import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types'; import initializeApollo from '@/apollo/client'; +import defaultValues from '@/config/default-values'; import * as CRMTypes from '@/graphql/crm.types'; import { gql } from '@apollo/client'; @@ -7,6 +8,8 @@ const QUERY_GET_QUOTE_CONFIGURATOR_DATA = gql` query GetQuoteConfiguratorData($quoteId: Uuid!) { quote(quoteId: $quoteId) { evo_baseproductid + evo_client_typeid + evo_msfo_irr } } `; @@ -27,6 +30,8 @@ export async function getKPData({ return { values: { + IRR_Perc: quote?.evo_msfo_irr ?? defaultValues.IRR_Perc, + clientType: quote?.evo_client_typeid, product: quote?.evo_baseproductid, }, }; diff --git a/apps/web/process/configurator/reactions/filters.ts b/apps/web/process/configurator/reactions/filters.ts index 0959194..8434497 100644 --- a/apps/web/process/configurator/reactions/filters.ts +++ b/apps/web/process/configurator/reactions/filters.ts @@ -1,5 +1,4 @@ -/* eslint-disable @typescript-eslint/naming-convention */ -import { radioGraphType, selectSeasonType } from '@/config/default-options'; +import { radioCalcType, radioGraphType, selectSeasonType } from '@/config/default-options'; import * as CRMTypes from '@/graphql/crm.types'; import { SEASON_TYPES } from '@/process/payments/lib/seasons-constants'; import type { ProcessContext } from '@/process/types'; @@ -278,7 +277,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) { const { data: { evo_baseproduct }, - } = await apolloClient.query({ + } = await apolloClient.query({ query: CRMTypes.GetProductDocument, variables: { productId, @@ -286,10 +285,9 @@ export default function reactions({ store, apolloClient }: ProcessContext) { }); if (evo_baseproduct?.evo_calculation_method) { - const filteredCalcTypeOptions = $calculation - .element('radioCalcType') - .getOptions() - .filter((calcType) => evo_baseproduct.evo_calculation_method?.includes(calcType.value)); + const filteredCalcTypeOptions = radioCalcType.filter((calcType) => + evo_baseproduct.evo_calculation_method?.includes(calcType.value) + ); $calculation.element('radioCalcType').setOptions(filteredCalcTypeOptions); } else { $calculation.element('radioCalcType').resetOptions(); @@ -306,7 +304,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) { reaction( () => $calculation.element('selectQuote').getValue(), async (quoteId) => { - const currentDate = dayjs().utc(false).toISOString(); + const currentDate = dayjs().utc(false).format('YYYY-MM-DD'); const { data: { evo_baseproducts }, diff --git a/apps/web/process/configurator/reactions/validation.ts b/apps/web/process/configurator/reactions/validation.ts index 9e24896..86a8dda 100644 --- a/apps/web/process/configurator/reactions/validation.ts +++ b/apps/web/process/configurator/reactions/validation.ts @@ -1,44 +1,35 @@ -/* eslint-disable @typescript-eslint/naming-convention */ -import * as CRMTypes from '@/graphql/crm.types'; +import { createValidationSchema } from '../validation'; +import type { Elements } from '@/Components/Calculation/config/map/values'; import type { ProcessContext } from '@/process/types'; +import ValidationHelper from '@/stores/validation/helper'; import { reaction } from 'mobx'; +import { uid } from 'radash'; -export default function reactions({ store, apolloClient }: ProcessContext) { +const key = uid(7); + +export default function reactions(context: ProcessContext) { + const { store } = context; const { $calculation } = store; - /** - * На изменение поля Процет убывания платежей tbxParmentsDecreasePercent необходимо заложить проверку: - * Если значение поля меньше значения в поле "Минимальный % убывания платежей" evo_min_decreasing_perc из записи, - * указанной в поле ТарифselectTarif , то поле Процет убывания платежей tbxParmentsDecreasePercent должно обводиться красной рамкой - * и выводиться сообщение "Процент убывания не может быть меньше минимального значения по данному тарифу - * - <указывается значение из поля "Минимальный % убывания платежей">, иначе красная рамка снимается. - * При красной рамке в данном поле нельзя осуществить расчет графика. - */ + const validationSchema = createValidationSchema(context); + + const helper = new ValidationHelper(); reaction( - () => ({ - parmentsDecreasePercent: $calculation.element('tbxParmentsDecreasePercent').getValue(), - tarifId: $calculation.element('selectTarif').getValue(), - }), - async ({ parmentsDecreasePercent, tarifId }) => { - let evo_tarif: CRMTypes.GetTarifQuery['evo_tarif'] = null; + () => $calculation.$values.getValues(['parmentsDecreasePercent', 'tarif']), + async (values) => { + helper.removeErrors(); + const validationResult = await validationSchema.safeParseAsync(values); - if (tarifId) { - const { data } = await apolloClient.query({ - query: CRMTypes.GetTarifDocument, - variables: { - tarifId, - }, + if (!validationResult.success) { + validationResult.error.errors.forEach(({ path, message }) => { + (path as Elements[]).forEach((elementName) => { + const removeError = $calculation.element(elementName).setError({ key, message }); + if (removeError) helper.add(removeError); + }); }); - - ({ evo_tarif } = data); } - - $calculation.element('tbxParmentsDecreasePercent').validate({ - invalid: Boolean( - evo_tarif?.evo_min_decreasing_perc && - parmentsDecreasePercent < evo_tarif?.evo_min_decreasing_perc - ), - message: `Процент убывания не может быть меньше минимального значения по данному тарифу - ${evo_tarif?.evo_min_decreasing_perc}`, - }); + }, + { + delay: 100, } ); } diff --git a/apps/web/process/configurator/reactions/values.ts b/apps/web/process/configurator/reactions/values.ts index 26c217c..47dc84b 100644 --- a/apps/web/process/configurator/reactions/values.ts +++ b/apps/web/process/configurator/reactions/values.ts @@ -1,9 +1,10 @@ -/* eslint-disable @typescript-eslint/naming-convention */ +import type { Elements } from '@/Components/Calculation/config/map/values'; import * as CRMTypes from '@/graphql/crm.types'; import type { ProcessContext } from '@/process/types'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; import { reaction } from 'mobx'; +import { first, sort } from 'radash'; import { makeDisposable, normalizeOptions } from 'tools'; dayjs.extend(utc); @@ -29,7 +30,7 @@ export default function valuesReactions({ store, apolloClient }: ProcessContext) firstPaymentPerc, lastPaymentPerc, }) => { - const currentDate = dayjs().utc(false).toISOString(); + const currentDate = dayjs().utc(false).format('YYYY-MM-DD'); let { data: { evo_tarifs = [] }, @@ -41,6 +42,8 @@ export default function valuesReactions({ store, apolloClient }: ProcessContext) }, }); + $calculation.element('selectTarif').setOptions(normalizeOptions(evo_tarifs)); + if (product && leasingPeriod && deliveryTime && evo_tarifs) { evo_tarifs = evo_tarifs?.filter( (tarif) => @@ -60,11 +63,9 @@ export default function valuesReactions({ store, apolloClient }: ProcessContext) tarif.evo_max_last_payment !== null && tarif.evo_max_last_payment >= lastPaymentPerc ); - } else { - $calculation.element('selectTarif').resetValue(); - } - if (leaseObjectUsed === true && evo_tarifs) { + $calculation.element('selectTarif').setValue(evo_tarifs?.at(0)?.evo_tarifid || null); + } else if (leaseObjectUsed === true && evo_tarifs) { evo_tarifs = evo_tarifs?.filter((tarif) => { if (leaseObjectUsed === true) { return tarif?.evo_used; @@ -72,12 +73,10 @@ export default function valuesReactions({ store, apolloClient }: ProcessContext) return true; }); + $calculation.element('selectTarif').setValue(evo_tarifs?.at(0)?.evo_tarifid || null); + } else { + $calculation.element('selectTarif').resetValue(); } - - $calculation - .element('selectTarif') - .setOptions(normalizeOptions(evo_tarifs)) - .setValue(evo_tarifs?.at(0)?.evo_tarifid || null); }, { delay: 10, @@ -98,6 +97,7 @@ export default function valuesReactions({ store, apolloClient }: ProcessContext) const { data: { evo_tarif }, } = await apolloClient.query({ + fetchPolicy: 'network-only', query: CRMTypes.GetTarifDocument, variables: { tarifId, @@ -124,26 +124,37 @@ export default function valuesReactions({ store, apolloClient }: ProcessContext) return; } - const currentDate = dayjs().utc(false).toISOString(); + const currentDate = dayjs().utc(false).format('YYYY-MM-DD'); const { data: { evo_rates }, } = await apolloClient.query({ + fetchPolicy: 'network-only', query: CRMTypes.GetRatesDocument, variables: { currentDate, }, }); - const rates = evo_rates?.filter((rate) => - rate?.evo_tarifs?.filter((tarif) => tarif?.evo_tarifid === tarifId) - ); - const baseRate = rates?.find((x) => x?.evo_id === 'BASE'); + $calculation.element('selectRate').setOptions(normalizeOptions(evo_rates)); - $calculation - .element('selectRate') - .setOptions(normalizeOptions(rates)) - .setValue(baseRate?.value ?? null); + const { + data: { evo_tarif }, + } = await apolloClient.query({ + query: CRMTypes.GetTarifDocument, + variables: { tarifId }, + }); + + const targetRate = + evo_tarif?.evo_rates && + first(sort(evo_tarif?.evo_rates, (x) => dayjs(x?.evo_datefrom).date())); + + if (targetRate) { + $calculation.element('selectRate').setValue(targetRate?.evo_rateid); + } else { + const baseRate = evo_rates?.find((x) => x?.evo_id === 'BASE'); + if (baseRate) $calculation.element('selectRate').setValue(baseRate?.value); + } } ); @@ -159,6 +170,7 @@ export default function valuesReactions({ store, apolloClient }: ProcessContext) const { data: { evo_rate }, } = await apolloClient.query({ + fetchPolicy: 'network-only', query: CRMTypes.GetRateDocument, variables: { rateId, @@ -174,4 +186,30 @@ export default function valuesReactions({ store, apolloClient }: ProcessContext) $calculation.element('tbxCreditRate').setValue(evo_rate?.evo_base_rate); } ); + + ( + [ + 'selectProduct', + 'selectLeaseObjectType', + 'selectBrand', + 'selectModel', + 'selectConfiguration', + 'selectTracker', + 'selectTelematic', + 'selectTechnicalCard', + 'selectFuelCard', + 'selectRegistration', + 'selectTownRegistration', + 'radioCalcType', + ] as Elements[] + ).forEach((elementName) => { + reaction( + () => $calculation.element(elementName).getOptions(), + (options) => { + if (options.length === 1) { + $calculation.element(elementName).setValue(options[0]?.value); + } + } + ); + }); } diff --git a/apps/web/process/configurator/validation.ts b/apps/web/process/configurator/validation.ts new file mode 100644 index 0000000..c24707e --- /dev/null +++ b/apps/web/process/configurator/validation.ts @@ -0,0 +1,40 @@ +import type { ValidationContext } from '../types'; +import ValuesSchema from '@/config/schema/values'; +import * as CRMTypes from '@/graphql/crm.types'; +import { z } from 'zod'; + +export function createValidationSchema({ apolloClient }: ValidationContext) { + return ValuesSchema.pick({ parmentsDecreasePercent: true, tarif: true }).superRefine( + async ({ parmentsDecreasePercent, tarif: tarifId }, ctx) => { + /** + * На изменение поля Процет убывания платежей tbxParmentsDecreasePercent необходимо заложить проверку: + * Если значение поля меньше значения в поле "Минимальный % убывания платежей" evo_min_decreasing_perc из записи, + * указанной в поле ТарифselectTarif , то поле Процет убывания платежей tbxParmentsDecreasePercent должно обводиться красной рамкой + * и выводиться сообщение "Процент убывания не может быть меньше минимального значения по данному тарифу + * - <указывается значение из поля "Минимальный % убывания платежей">, иначе красная рамка снимается. + * При красной рамке в данном поле нельзя осуществить расчет графика. + */ + if (tarifId) { + const { + data: { evo_tarif }, + } = await apolloClient.query({ + query: CRMTypes.GetTarifDocument, + variables: { + tarifId, + }, + }); + + if ( + evo_tarif?.evo_min_decreasing_perc && + parmentsDecreasePercent < evo_tarif?.evo_min_decreasing_perc + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: `Процент убывания не может быть меньше минимального значения по данному тарифу - ${evo_tarif?.evo_min_decreasing_perc}`, + path: ['tbxParmentsDecreasePercent'], + }); + } + } + } + ); +} diff --git a/apps/web/process/fingap/reactions/common.ts b/apps/web/process/fingap/reactions/common.ts index 2d43f07..1b18a00 100644 --- a/apps/web/process/fingap/reactions/common.ts +++ b/apps/web/process/fingap/reactions/common.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import { calculateFinGAP } from '@/api/core/query'; import type { RequestFinGAP } from '@/api/core/types'; import type { Risk } from '@/Components/Calculation/Form/Insurance/FinGAPTable/types'; diff --git a/apps/web/process/fingap/reactions/validation.ts b/apps/web/process/fingap/reactions/validation.ts index 3f8df5f..580208e 100644 --- a/apps/web/process/fingap/reactions/validation.ts +++ b/apps/web/process/fingap/reactions/validation.ts @@ -1,9 +1,14 @@ import type { ProcessContext } from '@/process/types'; +import ValidationHelper from '@/stores/validation/helper'; import { reaction } from 'mobx'; +import { uid } from 'radash'; + +const key = uid(7); export default function reactions({ store }: ProcessContext) { const { $tables } = store; + const helper = new ValidationHelper(); reaction( () => { const hasPaymentsErrors = $tables.payments.validation.hasErrors; @@ -15,10 +20,15 @@ export default function reactions({ store }: ProcessContext) { }; }, ({ hasPaymentsErrors, finGAPInsuranceCompany }) => { - $tables.fingap.validate({ - invalid: finGAPInsuranceCompany !== null && hasPaymentsErrors, - message: 'Неверно заполнены платежи', - }); + if (finGAPInsuranceCompany !== null && hasPaymentsErrors) { + const removeError = $tables.fingap.setError({ + key, + message: 'Неверно заполнены платежи', + }); + helper.add(removeError); + } else { + helper.removeErrors(); + } if (hasPaymentsErrors) { $tables.fingap.clear(); diff --git a/apps/web/process/gibdd/get-kp-data.ts b/apps/web/process/gibdd/get-kp-data.ts index ca6975c..cef7390 100644 --- a/apps/web/process/gibdd/get-kp-data.ts +++ b/apps/web/process/gibdd/get-kp-data.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types'; import helper from './lib/helper'; import initializeApollo from '@/apollo/client'; @@ -14,10 +13,6 @@ const QUERY_GET_QUOTE_GIBDD_DATA = gql` evo_pts_type evo_vehicle_tax_year evo_vehicle_tax_approved - evo_addproduct_types { - evo_product_type - evo_addproduct_typeid - } evo_category_tr evo_vehicle_type_tax evo_regionid @@ -25,6 +20,8 @@ const QUERY_GET_QUOTE_GIBDD_DATA = gql` evo_legal_regionid evo_legal_townid evo_registration_regionid + evo_req_telematic + evo_req_telematic_accept } } `; @@ -73,10 +70,6 @@ export async function getKPData({ values }: GetQuoteInputData): Promise x?.evo_product_type === 100_000_001 - )?.evo_addproduct_typeid; - return { values: { legalClientRegion: legalRegionId, @@ -88,7 +81,9 @@ export async function getKPData({ values }: GetQuoteInputData): Promise $calculation.$values.getValues(['objectRegistration', 'vehicleTaxInYear']), - ({ objectRegistration, vehicleTaxInYear }) => { - if (objectRegistration === 100_000_001) { - $calculation.element('tbxVehicleTaxInYear').unblock(); - } else { - $calculation.element('tbxVehicleTaxInYear').resetValue().block(); - } - $calculation.element('tbxVehicleTaxInYear').validate({ - invalid: objectRegistration === 100_000_001 && !(vehicleTaxInYear > 0), - message: 'Значение должно быть больше 0', - }); - } - ); - - reaction( - () => $calculation.$values.getValues(['objectRegistration', 'typePTS']), - ({ objectRegistration, typePTS }) => { - if (objectRegistration === 100_000_001) { - $calculation.element('radioTypePTS').unblock(); - } else { - $calculation.element('radioTypePTS').resetValue().block(); - } - $calculation.element('radioTypePTS').validate({ - invalid: objectRegistration === 100_000_001 && !typePTS, - message: 'Не заполнено поле', - }); - } - ); - makeDisposable( () => reaction( @@ -233,9 +205,13 @@ export function common({ store, apolloClient, queryClient }: ProcessContext) { }, context ); - const { tax, error } = await queryClient.fetchQuery(['1c', 'trans-tax'], request, { - staleTime: STALE_TIME, - }); + const { tax, error } = await queryClient.fetchQuery( + ['1c', 'trans-tax', carCategory, leaseObjectMotorPower, leaseObjectYear], + request, + { + staleTime: STALE_TIME, + } + ); if (!error && tax) { $calculation.element('tbxVehicleTaxInYear').setValue(tax); @@ -273,7 +249,7 @@ export function common({ store, apolloClient, queryClient }: ProcessContext) { return; } - const currentDate = dayjs().utc(false).toISOString(); + const currentDate = dayjs().utc(false).format('YYYY-MM-DD'); const { data: { evo_region }, @@ -289,32 +265,27 @@ export function common({ store, apolloClient, queryClient }: ProcessContext) { variables: { currentDate }, }); - const options = evo_addproduct_types - ?.filter( - (x) => - x?.evo_leasingobject_types?.find( - (evo_leasingobject_type) => - evo_leasingobject_type?.evo_leasingobject_typeid === leaseObjectType - ) && - x.evo_whom_register === objectRegistration && - Boolean( - leaseObjectCategory === 100_000_001 - ? x.evo_towtruck === true || x.evo_towtruck === false - : x.evo_towtruck === false - ) && - x.evo_gibdd_region === (objectRegionRegistrationId === regionRegistrationId) && - Boolean(typePTS && x.evo_pts_type?.includes(typePTS)) && - Boolean( - x.evo_accountid && - evo_region?.accounts?.some( - (evo_region_account) => evo_region_account?.accountid === x.evo_accountid - ) - ) - ) - .map((x) => ({ - ...x, - label: `${x?.label} (${x?.evo_graph_price} руб.)`, - })); + const options = evo_addproduct_types?.filter( + (x) => + x?.evo_leasingobject_types?.find( + (evo_leasingobject_type) => + evo_leasingobject_type?.evo_leasingobject_typeid === leaseObjectType + ) && + x.evo_whom_register === objectRegistration && + Boolean( + leaseObjectCategory === 100_000_001 + ? x.evo_towtruck === true || x.evo_towtruck === false + : x.evo_towtruck === false + ) && + x.evo_gibdd_region === (objectRegionRegistrationId === regionRegistrationId) && + Boolean(typePTS && x.evo_pts_type?.includes(typePTS)) && + Boolean( + x.evo_accountid && + evo_region?.accounts?.some( + (evo_region_account) => evo_region_account?.accountid === x.evo_accountid + ) + ) + ); $calculation.element('selectRegistration').setOptions(normalizeOptions(options)); } @@ -504,89 +475,41 @@ export function common({ store, apolloClient, queryClient }: ProcessContext) { ); } -export function validation({ store, apolloClient }: ProcessContext) { - const { $calculation } = store; +const key = uid(7); +export function validation(context: ProcessContext) { + const { store } = context; + const { $calculation } = store; + const validationSchema = createValidationSchema(context); + + const validationHelper = new ValidationHelper(); reaction( - () => $calculation.$values.getValues(['leaseObjectCategory', 'maxMass']), - ({ leaseObjectCategory, maxMass }) => { - $calculation.element('tbxMaxMass').validate({ - invalid: leaseObjectCategory === 100_000_001 && maxMass > 3500, - message: 'При категории ТС = В Разрешенная макс.масса не может быть больше 3500 кг', - }); - $calculation.element('tbxMaxMass').validate({ - invalid: leaseObjectCategory === 100_000_002 && maxMass <= 3500, - message: 'При категории ТС = С Разрешенная макс.масса не может быть меньше 3500 кг', - }); + () => + $calculation.$values.getValues([ + 'leaseObjectCategory', + 'maxMass', + 'leaseObjectType', + 'typePTS', + 'objectRegistration', + 'objectCategoryTax', + 'insNSIB', + 'vehicleTaxInYear', + ]), + async (values) => { + validationHelper.removeErrors(); + const validationResult = await validationSchema.safeParseAsync(values); + + if (!validationResult.success) { + validationResult.error.errors.forEach(({ path, message }) => { + (path as Elements[]).forEach((elementName) => { + const removeError = $calculation.element(elementName).setError({ key, message }); + if (removeError) validationHelper.add(removeError); + }); + }); + } + }, + { + delay: 100, } ); - - { - const validationHelper = new ValidationHelper(); - reaction( - () => - $calculation.$values.getValues([ - 'typePTS', - 'objectRegistration', - 'objectCategoryTax', - 'leaseObjectType', - ]), - async ({ - leaseObjectType: leaseObjectTypeId, - typePTS, - objectRegistration, - objectCategoryTax, - }) => { - if (!leaseObjectTypeId) { - validationHelper.removeErrors(); - - return; - } - - const { - data: { evo_leasingobject_type }, - } = await apolloClient.query({ - query: CRMTypes.GetLeaseObjectTypeDocument, - variables: { leaseObjectTypeId }, - }); - - $calculation.element('selectObjectCategoryTax').validate({ - helper: validationHelper, - invalid: - objectRegistration === 100_000_001 && - typePTS === 100_000_001 && - objectCategoryTax === null && - Boolean(evo_leasingobject_type?.evo_category_tr?.length), - message: 'Необходимо из ЭПТС указать Категорию в соответствии с ТР ТС 018/2011', - }); - } - ); - } - - { - const validationHelper = new ValidationHelper(); - reaction( - () => $calculation.$values.getValues(['leaseObjectType', 'insNSIB']), - async ({ insNSIB, leaseObjectType: leaseObjectTypeId }) => { - if (!leaseObjectTypeId) { - validationHelper.removeErrors(); - - return; - } - - const { - data: { evo_leasingobject_type }, - } = await apolloClient.query({ - query: CRMTypes.GetLeaseObjectTypeDocument, - variables: { leaseObjectTypeId }, - }); - - $calculation.element('selectInsNSIB').validate({ - helper: validationHelper, - invalid: evo_leasingobject_type?.evo_id === '11' && !insNSIB, - message: 'Страхование НСИБ обязательно для мотоциклистов', - }); - } - ); - } } diff --git a/apps/web/process/gibdd/validation.ts b/apps/web/process/gibdd/validation.ts new file mode 100644 index 0000000..b1fb526 --- /dev/null +++ b/apps/web/process/gibdd/validation.ts @@ -0,0 +1,94 @@ +import type { ValidationContext } from '../types'; +import ValuesSchema from '@/config/schema/values'; +import { MAX_MASS } from '@/constants/values'; +import * as CRMTypes from '@/graphql/crm.types'; +import { z } from 'zod'; + +export function createValidationSchema({ apolloClient }: ValidationContext) { + return ValuesSchema.pick({ + insNSIB: true, + leaseObjectCategory: true, + leaseObjectType: true, + maxMass: true, + objectCategoryTax: true, + objectRegistration: true, + typePTS: true, + vehicleTaxInYear: true, + }).superRefine( + async ( + { + leaseObjectCategory, + maxMass, + leaseObjectType: leaseObjectTypeId, + typePTS, + objectRegistration, + objectCategoryTax, + insNSIB, + vehicleTaxInYear, + }, + ctx + ) => { + if (leaseObjectCategory === 100_000_001 && maxMass > MAX_MASS) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: `При категории ТС = В Разрешенная макс.масса не может быть больше ${MAX_MASS} кг`, + path: ['tbxMaxMass'], + }); + } + + if (leaseObjectCategory === 100_000_002 && maxMass <= MAX_MASS) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: `При категории ТС = С Разрешенная макс.масса не может быть меньше ${MAX_MASS} кг`, + path: ['tbxMaxMass'], + }); + } + + if (leaseObjectTypeId) { + const { + data: { evo_leasingobject_type }, + } = await apolloClient.query({ + query: CRMTypes.GetLeaseObjectTypeDocument, + variables: { leaseObjectTypeId }, + }); + + if ( + objectRegistration === 100_000_001 && + typePTS === 100_000_001 && + objectCategoryTax === null && + Boolean(evo_leasingobject_type?.evo_category_tr?.length) + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Не заполнено поле', + path: ['selectObjectCategoryTax'], + }); + } + + if (evo_leasingobject_type?.evo_id === '11' && !insNSIB) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Страхование НСИБ обязательно для мотоциклистов', + path: ['selectInsNSIB'], + }); + } + } + + if (objectRegistration === 100_000_001 && !(vehicleTaxInYear > 0)) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Значение должно быть больше 0', + path: ['tbxVehicleTaxInYear'], + }); + } + + if (objectRegistration === 100_000_001 && !typePTS) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Не заполнено поле', + path: ['radioTypePTS'], + }); + } + } + ); +} diff --git a/apps/web/process/init/get-initial-data.ts b/apps/web/process/init/get-initial-data.ts index b585d3d..d97a2bf 100644 --- a/apps/web/process/init/get-initial-data.ts +++ b/apps/web/process/init/get-initial-data.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import type { User } from '@/api/user/types'; import * as CRMTypes from '@/graphql/crm.types'; import type { ApolloClient } from '@apollo/client'; diff --git a/apps/web/process/init/get-insurance-data.js b/apps/web/process/init/get-insurance-data.js index 7320528..9b9c1a5 100644 --- a/apps/web/process/init/get-insurance-data.js +++ b/apps/web/process/init/get-insurance-data.js @@ -1,56 +1,32 @@ /* eslint-disable canonical/sort-keys */ +import * as CRMTypes from '@/graphql/crm.types'; import { useStore } from '@/stores/hooks'; -import { gql, useApolloClient } from '@apollo/client'; +import { useApolloClient } from '@apollo/client'; import { useEffect } from 'react'; -const QUERY_GET_INSURANCE_DATA = gql` - query GetInsuranceData($evo_account_type: [Int!]) { - osago: accounts( - evo_account_type: $evo_account_type - evo_type_ins_policy: [100000001] - statecode: 0 - ) { - value: accountid - label: name - } - - kasko: accounts( - evo_account_type: $evo_account_type - evo_type_ins_policy: [100000000] - statecode: 0 - ) { - value: accountid - label: name - } - - fingap: accounts( - evo_account_type: $evo_account_type - evo_type_ins_policy: [100000002] - statecode: 0 - ) { - value: accountid - label: name - } - } -`; /** - * * @param {import('@apollo/client').ApolloClient} apolloClient * @param {*} onCompleted */ function getInsuranceData({ query }, onCompleted) { query({ - query: QUERY_GET_INSURANCE_DATA, + query: CRMTypes.GetInsuranceCompaniesDocument, }).then(({ data }) => { const insurance = { osago: { - insuranceCompany: data.osago, + insuranceCompany: data.accounts.filter((x) => + x?.evo_type_ins_policy?.includes(100_000_001) + ), }, kasko: { - insuranceCompany: data.kasko, + insuranceCompany: data.accounts.filter((x) => + x?.evo_type_ins_policy?.includes(100_000_000) + ), }, fingap: { - insuranceCompany: data.fingap, + insuranceCompany: data.accounts.filter((x) => + x?.evo_type_ins_policy?.includes(100_000_002) + ), }, }; diff --git a/apps/web/process/init/get-main-data.js b/apps/web/process/init/get-main-data.js index dcfc861..5a5c232 100644 --- a/apps/web/process/init/get-main-data.js +++ b/apps/web/process/init/get-main-data.js @@ -9,7 +9,7 @@ import { normalizeOptions } from 'tools'; dayjs.extend(utc); -const currentDate = dayjs().utc(false).toISOString(); +const currentDate = dayjs().utc(false).format('YYYY-MM-DD'); /** * @@ -98,55 +98,33 @@ function getMainData({ query }, onCompleted) { }); query({ - query: CRMTypes.GetAddproductTypesDocument, + query: CRMTypes.GetTelematicTypesDocument, variables: { currentDate, }, }).then(({ data }) => { - // const selectRegistration = data.evo_addproduct_types - // ?.filter((x) => x?.evo_product_type === 100_000_001) - // .map((x) => ({ - // ...x, - // label: `${x?.label} (${x?.evo_graph_price} руб.)`, - // })); + onCompleted({ selectTelematic: data?.evo_addproduct_types }); + }); - const selectTechnicalCard = data.evo_addproduct_types - ?.filter((x) => x?.evo_product_type === 100_000_000) - .map((x) => ({ - ...x, - label: `${x?.label} (${x?.evo_graph_price} руб.)`, - })); + query({ + query: CRMTypes.GetTrackerTypesDocument, + variables: { + currentDate, + }, + }).then(({ data }) => { + onCompleted({ selectTracker: data?.evo_addproduct_types }); + }); - const selectTelematic = data.evo_addproduct_types - ?.filter((x) => x?.evo_product_type === 100_000_004) - .map((x) => ({ - ...x, - label: `${x?.label} (${x?.evo_graph_price} руб.)`, - })); - - const selectTracker = data.evo_addproduct_types - ?.filter((x) => x?.evo_product_type === 100_000_003) - .map((x) => ({ - ...x, - label: `${x?.label} (${x?.evo_graph_price} руб.)`, - })); - - const selectInsNSIB = data.evo_addproduct_types?.filter( - (x) => x?.evo_product_type === 100_000_002 - ); - - const selectLeasingWithoutKasko = data.evo_addproduct_types?.filter( - (x) => x?.evo_product_type === 100_000_007 - ); - - onCompleted({ - // selectRegistration, - selectTechnicalCard, - selectTelematic, - selectTracker, - selectInsNSIB, - selectLeasingWithoutKasko, - }); + query({ + query: CRMTypes.GetInsNsibTypesDocument, + variables: { + currentDate, + }, + context: { + disableModify: true, + }, + }).then(({ data }) => { + onCompleted({ selectInsNSIB: data?.evo_addproduct_types }); }); query({ diff --git a/apps/web/process/insurance/get-kp-data.ts b/apps/web/process/insurance/get-kp-data.ts index 169468c..f364f0a 100644 --- a/apps/web/process/insurance/get-kp-data.ts +++ b/apps/web/process/insurance/get-kp-data.ts @@ -1,6 +1,7 @@ /* eslint-disable @typescript-eslint/no-non-null-assertion */ import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types'; import initializeApollo from '@/apollo/client'; +import defaultValues from '@/config/default-values'; import * as insuranceTable from '@/config/tables/insurance-table'; import * as CRMTypes from '@/graphql/crm.types'; import { gql } from '@apollo/client'; @@ -20,6 +21,13 @@ const QUERY_GET_QUOTE_INSURANCE_DATA = gql` evo_fingap_accountid evo_fingap_payer evo_fingap_period + evo_gps_brandid + evo_gps_modelid + evo_insurance_decentral + evo_franchise + evo_unlimit_drivers + evo_age_drivers + evo_exp_drivers } } `; @@ -60,5 +68,14 @@ export async function getKPData({ }), }, }, + values: { + GPSBrand: quote?.evo_gps_brandid, + insAgeDrivers: quote?.evo_age_drivers ?? defaultValues.insAgeDrivers, + insDecentral: quote?.evo_insurance_decentral ?? defaultValues.insDecentral, + insExpDrivers: quote?.evo_exp_drivers ?? defaultValues.insExpDrivers, + insFranchise: quote?.evo_franchise ?? defaultValues.insFranchise, + insUnlimitDrivers: quote?.evo_unlimit_drivers ?? defaultValues.insUnlimitDrivers, + model: quote?.evo_gps_modelid, + }, }; } diff --git a/apps/web/process/insurance/index.ts b/apps/web/process/insurance/index.ts index f5291d5..e05ea2d 100644 --- a/apps/web/process/insurance/index.ts +++ b/apps/web/process/insurance/index.ts @@ -1 +1,2 @@ export * from './get-kp-data'; +export * as reactions from './reactions'; diff --git a/apps/web/process/insurance/reactions.ts b/apps/web/process/insurance/reactions.ts new file mode 100644 index 0000000..b895532 --- /dev/null +++ b/apps/web/process/insurance/reactions.ts @@ -0,0 +1,318 @@ +import type { ProcessContext } from '../types'; +import { createValidationSchema } from './validation'; +import type { Elements } from '@/Components/Calculation/config/map/values'; +import { selectLeaseObjectUseFor } from '@/config/default-options'; +import * as CRMTypes from '@/graphql/crm.types'; +import ValidationHelper from '@/stores/validation/helper'; +import { comparer, reaction, toJS } from 'mobx'; +import { uid } from 'radash'; +import { normalizeOptions } from 'tools'; + +export function common({ store, apolloClient }: ProcessContext) { + const { $calculation, $tables } = store; + + reaction( + () => $calculation.element('selectGPSBrand').getValue(), + async (gpsBrandId) => { + if (!gpsBrandId) { + $calculation.element('selectGPSModel').resetValue(); + + return; + } + + const { + data: { evo_gps_models }, + } = await apolloClient.query({ + query: CRMTypes.GetGpsModelsDocument, + variables: { + gpsBrandId, + }, + }); + + if (evo_gps_models) { + $calculation.element('selectGPSModel').setOptions(normalizeOptions(evo_gps_models)); + } + } + ); + + reaction( + () => $calculation.element('selectLeaseObjectCategory').getValue(), + (leaseObjectCategory) => { + switch (leaseObjectCategory) { + case 100_000_000: { + $calculation + .element('selectLeaseObjectUseFor') + .setOptions( + selectLeaseObjectUseFor.filter((x) => [100_000_000, 100_000_002].includes(x.value)) + ); + break; + } + case 100_000_001: { + $calculation + .element('selectLeaseObjectUseFor') + .setOptions( + selectLeaseObjectUseFor.filter((x) => + [ + 100_000_000, 100_000_001, 100_000_002, 100_000_003, 100_000_004, 100_000_005, + 100_000_006, 100_000_007, 100_000_008, 100_000_009, 100_000_010, 100_000_011, + 100_000_012, 100_000_013, + ].includes(x.value) + ) + ); + break; + } + case 100_000_002: { + $calculation + .element('selectLeaseObjectUseFor') + .setOptions( + selectLeaseObjectUseFor.filter((x) => + [ + 100_000_002, 100_000_004, 100_000_005, 100_000_006, 100_000_009, 100_000_010, + ].includes(x.value) + ) + ); + break; + } + case 100_000_003: { + $calculation + .element('selectLeaseObjectUseFor') + .setOptions( + selectLeaseObjectUseFor.filter((x) => + [ + 100_000_002, 100_000_004, 100_000_006, 100_000_007, 100_000_008, 100_000_011, + 100_000_012, 100_000_013, + ].includes(x.value) + ) + ); + break; + } + case 100_000_004: { + $calculation + .element('selectLeaseObjectUseFor') + .setOptions( + selectLeaseObjectUseFor.filter((x) => [100_000_002, 100_000_009].includes(x.value)) + ); + break; + } + default: { + $calculation + .element('selectLeaseObjectUseFor') + .setOptions( + selectLeaseObjectUseFor.filter((x) => + [ + 100_000_014, 100_000_015, 100_000_016, 100_000_017, 100_000_018, 100_000_019, + ].includes(x.value) + ) + ); + break; + } + } + }, + { + fireImmediately: true, + } + ); + + reaction( + () => $calculation.$values.getValues(['leasingPeriod', 'leasingWithoutKasko']), + async ({ leasingPeriod, leasingWithoutKasko }) => { + const { + data: { accounts }, + } = await apolloClient.query({ + query: CRMTypes.GetInsuranceCompaniesDocument, + }); + + if (leasingWithoutKasko) { + const otherInsuranceCompany = accounts?.find( + (x) => x?.evo_type_ins_policy === null && x.label?.includes('ПРОЧИЕ') + ); + + if (otherInsuranceCompany) { + $tables.insurance + .row('kasko') + .column('insuranceCompany') + .setOptions(normalizeOptions([otherInsuranceCompany])) + .setValue(otherInsuranceCompany.value) + .block(); + + $tables.insurance.row('kasko').column('insCost').resetValue().block(); + $tables.insurance.row('kasko').column('insTerm').setValue(100_000_000).block(); + $tables.insurance.row('kasko').column('insured').setValue(100_000_000).block(); + } + } else { + const defaultKaskoOptions = accounts?.filter((x) => + x?.evo_type_ins_policy?.includes(100_000_000) + ); + $tables.insurance + .row('kasko') + .setOptions('insuranceCompany', normalizeOptions(defaultKaskoOptions)) + .unblock('insCost'); + + if (leasingPeriod < 12) { + $tables.insurance.row('osago').column('insured').setValue(100_000_000).block(); + $tables.insurance.row('kasko').column('insured').setValue(100_000_000).block(); + $tables.insurance.row('kasko').column('insTerm').setValue(100_000_000).block(); + } else if (leasingPeriod === 12 || leasingPeriod > 16) { + $tables.insurance.row('osago').column('insured').unblock(); + $tables.insurance.row('kasko').column('insTerm').setValue(100_000_000).block(); + $tables.insurance.row('kasko').column('insured').unblock(); + } else if (leasingPeriod > 12 && leasingPeriod < 16) { + $tables.insurance.row('osago').column('insured').unblock(); + $tables.insurance.row('kasko').column('insTerm').setValue(100_000_001).block(); + $tables.insurance.row('kasko').column('insured').unblock(); + } else { + $tables.insurance.row('osago').column('insured').unblock(); + $tables.insurance.row('kasko').column('insTerm').block(); + $tables.insurance.row('kasko').column('insured').unblock(); + } + } + }, + { + fireImmediately: true, + } + ); + + reaction( + () => $calculation.$values.getValues(['leaseObjectCategory', 'leasingWithoutKasko']), + async ({ leaseObjectCategory, leasingWithoutKasko }) => { + const { + data: { accounts }, + } = await apolloClient.query({ + query: CRMTypes.GetInsuranceCompaniesDocument, + }); + + const isTrailer = leaseObjectCategory === 100_000_004; + if (isTrailer) { + const otherInsuranceCompany = accounts?.find( + (x) => x?.evo_type_ins_policy === null && x.label?.includes('ПРОЧИЕ') + ); + + if (otherInsuranceCompany) { + $tables.insurance + .row('osago') + .column('insuranceCompany') + .setOptions(normalizeOptions([otherInsuranceCompany])) + .setValue(otherInsuranceCompany.value) + .block(); + + $tables.insurance.row('osago').column('insCost').resetValue().block(); + } + } else { + $tables.insurance.row('osago').column('insCost').unblock(); + $tables.insurance.row('osago').column('insuranceCompany').unblock(); + + const defaultOsagoOptions = accounts?.filter((x) => + x?.evo_type_ins_policy?.includes(100_000_001) + ); + + if (leasingWithoutKasko) { + const evoKaskoInsuranceOptions = defaultOsagoOptions?.filter( + (x) => x?.evo_evokasko_access === true + ); + $tables.insurance + .row('osago') + .column('insuranceCompany') + .setOptions(normalizeOptions(evoKaskoInsuranceOptions)); + } else { + $tables.insurance + .row('osago') + .column('insuranceCompany') + .setOptions(normalizeOptions(defaultOsagoOptions)); + } + } + } + ); + + reaction( + () => $calculation.element('selectBrand').getValue(), + async (brandId) => { + if (!brandId) { + $tables.insurance.row('kasko').column('insuranceCompany').resetValue().unblock(); + + return; + } + + const { + data: { accounts }, + } = await apolloClient.query({ + query: CRMTypes.GetInsuranceCompaniesDocument, + }); + + const defaultKaskoOptions = accounts?.filter((x) => + x?.evo_type_ins_policy?.includes(100_000_000) + ); + + const { + data: { evo_brand }, + } = await apolloClient.query({ + query: CRMTypes.GetBrandDocument, + variables: { brandId }, + }); + + if (evo_brand?.evo_id === 'BRAND49') { + const renessansCompany = defaultKaskoOptions?.find((x) => x?.evo_inn === '7725497022'); + + if (renessansCompany) + $tables.insurance + .row('kasko') + .column('insuranceCompany') + .setValue(renessansCompany?.value) + .block(); + } else { + $tables.insurance.row('kasko').column('insuranceCompany').resetValue().unblock(); + } + } + ); +} + +const key = uid(7); + +export function validation(context: ProcessContext) { + const { $calculation, $tables } = context.store; + + const validationSchema = createValidationSchema(context); + const helper = new ValidationHelper(); + + reaction( + () => { + const values = $calculation.$values.getValues([ + 'leasingPeriod', + 'quote', + 'recalcWithRevision', + 'leasingWithoutKasko', + 'insDecentral', + ]); + + return { + insurance: { + fingap: toJS($tables.insurance.row('fingap').getValues()), + kasko: toJS($tables.insurance.row('kasko').getValues()), + osago: toJS($tables.insurance.row('osago').getValues()), + }, + ...values, + }; + }, + async (values) => { + helper.removeErrors(); + const validationResult = await validationSchema.safeParseAsync(values); + + if (!validationResult.success) { + validationResult.error.errors.forEach(({ path, message }) => { + (path as Array).forEach((elementName) => { + if (elementName === 'insurance') { + const removeError = $tables.insurance.setError({ key, message }); + if (removeError) helper.add(removeError); + } else { + const removeError = $calculation.element(elementName).setError({ key, message }); + if (removeError) helper.add(removeError); + } + }); + }); + } + }, + { + delay: 100, + equals: comparer.structural, + } + ); +} diff --git a/apps/web/process/insurance/validation.ts b/apps/web/process/insurance/validation.ts new file mode 100644 index 0000000..fd52ada --- /dev/null +++ b/apps/web/process/insurance/validation.ts @@ -0,0 +1,120 @@ +/* eslint-disable zod/require-strict */ +import type { ValidationContext } from '../types'; +import type * as Insurance from '@/Components/Calculation/Form/Insurance/InsuranceTable/types'; +import { RowSchema } from '@/config/schema/insurance'; +import ValuesSchema from '@/config/schema/values'; +import * as CRMTypes from '@/graphql/crm.types'; +import { z } from 'zod'; + +const InsuranceSchema = z.object({ + insurance: z.object({ + fingap: RowSchema, + kasko: RowSchema, + osago: RowSchema, + }), +}); + +export function createValidationSchema({ apolloClient }: ValidationContext) { + return ValuesSchema.pick({ + insDecentral: true, + leasingPeriod: true, + leasingWithoutKasko: true, + quote: true, + recalcWithRevision: true, + }) + .merge(InsuranceSchema) + .superRefine( + async ( + { + leasingPeriod, + recalcWithRevision, + quote: quoteId, + leasingWithoutKasko, + insDecentral, + insurance, + }, + ctx + ) => { + if (quoteId) { + const { + data: { quote }, + } = await apolloClient.query({ + query: CRMTypes.GetQuoteDocument, + variables: { quoteId }, + }); + if ( + recalcWithRevision && + quote?.evo_one_year_insurance === true && + leasingPeriod > 15 && + insurance.kasko.insTerm === 100_000_001 + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: + 'Срок страхования КАСКО должен быть 12 месяцев, т.к. оформляется Однолетний полис', + path: ['insurance'], + }); + } + } + + (['osago', 'kasko'] as Insurance.Keys[]).forEach((key) => { + const { insCost, insured, policyType, insuranceCompany, insTerm } = insurance[key]; + + if (insured === 100_000_001 && insCost < 1000) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: `Укажите стоимость ${policyType}, включаемую в график (>1000)`, + path: ['insurance'], + }); + } + + if (insCost > 0 && !insuranceCompany) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: `Укажите страховую компанию ${policyType}`, + path: ['insurance'], + }); + } + + if (insCost > 0 && !insTerm) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: `Укажите срок страхования ${policyType}`, + path: ['insurance'], + }); + } + + if (insCost > 0 && !insured) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: `Укажите плательщика ${policyType}`, + path: ['insurance'], + }); + } + }); + + if ( + !leasingWithoutKasko && + !insDecentral && + insurance.osago.insuranceCompany && + insurance.kasko.insuranceCompany !== insurance.osago.insuranceCompany + ) { + const { + data: { account }, + } = await apolloClient.query({ + query: CRMTypes.GetInsuranceCompanyDocument, + variables: { accountId: insurance.osago.insuranceCompany }, + }); + + if (account?.evo_osago_with_kasko) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: + 'Невозможно страхование ОСАГО отдельно от КАСКО - страховая компания должна быть одна!', + path: ['insurance'], + }); + } + } + } + ); +} diff --git a/apps/web/process/lead-opportunity/reactions/common.ts b/apps/web/process/lead-opportunity/reactions/common.ts index 5cff530..2876aac 100644 --- a/apps/web/process/lead-opportunity/reactions/common.ts +++ b/apps/web/process/lead-opportunity/reactions/common.ts @@ -91,8 +91,8 @@ export default function reactions({ store, apolloClient }: ProcessContext) { */ reaction( - () => $calculation.element('selectLead').getValue(), - async (leadid) => { + () => $calculation.$values.getValues(['recalcWithRevision', 'lead']), + async ({ lead: leadid, recalcWithRevision }) => { if (leadid) { const { data: { quotes }, @@ -104,34 +104,21 @@ export default function reactions({ store, apolloClient }: ProcessContext) { }, }); - $calculation.element('selectQuote').setOptions(normalizeOptions(quotes)); + if (recalcWithRevision) { + const filteredQuotes = quotes?.filter( + (quote) => + quote?.evo_recalc_limit && + quote.evo_recalc_limit > 0 && + quote.evo_statuscodeidData?.evo_id === '2.3' && + !quote.evo_purchases_participation + ); + $calculation.element('selectQuote').setOptions(normalizeOptions(filteredQuotes)); + } else { + $calculation.element('selectQuote').setOptions(normalizeOptions(quotes)); + } } else { $calculation.element('selectQuote').reset(); } } ); - - reaction( - () => $calculation.element('selectLead').getValue(), - async (leadid) => { - if (!leadid) { - $calculation.element('tbxINNForCalc').resetValue(); - - return; - } - - const { - data: { lead }, - } = await apolloClient.query({ - query: CRMTypes.GetLeadDocument, - variables: { leadid }, - }); - - if (lead?.evo_inn) { - $calculation.element('tbxINNForCalc').setValue(Number.parseInt(lead?.evo_inn, 10)); - } else { - $calculation.element('tbxINNForCalc').resetValue(); - } - } - ); } diff --git a/apps/web/process/leasing-object/get-kp-data.ts b/apps/web/process/leasing-object/get-kp-data.ts index d6f1db9..74867d0 100644 --- a/apps/web/process/leasing-object/get-kp-data.ts +++ b/apps/web/process/leasing-object/get-kp-data.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types'; import initializeApollo from '@/apollo/client'; import defaultValues from '@/config/default-values'; diff --git a/apps/web/process/leasing-object/reactions/common.ts b/apps/web/process/leasing-object/reactions/common.ts index 7e0ec09..c51518c 100644 --- a/apps/web/process/leasing-object/reactions/common.ts +++ b/apps/web/process/leasing-object/reactions/common.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import * as CRMTypes from '@/graphql/crm.types'; import type { ProcessContext } from '@/process/types'; import { reaction } from 'mobx'; @@ -405,4 +404,42 @@ export default function reactions({ store, apolloClient }: ProcessContext) { } } ); + + reaction( + () => + $calculation.$values.getValues([ + 'leaseObjectType', + 'engineVolume', + 'engineType', + 'leaseObjectMotorPower', + ]), + async ({ leaseObjectType: leaseObjectTypeId }) => { + if (!leaseObjectTypeId) { + $calculation.element('selectEngineType').unblock(); + $calculation.element('tbxEngineVolume').unblock(); + $calculation.element('tbxLeaseObjectMotorPower').unblock(); + + return; + } + + const { + data: { evo_leasingobject_type }, + } = await apolloClient.query({ + query: CRMTypes.GetLeaseObjectTypeDocument, + variables: { + leaseObjectTypeId, + }, + }); + + if (evo_leasingobject_type?.evo_id === '8') { + $calculation.element('selectEngineType').resetValue().block(); + $calculation.element('tbxEngineVolume').resetValue().block(); + $calculation.element('tbxLeaseObjectMotorPower').resetValue().block(); + } else { + $calculation.element('selectEngineType').unblock(); + $calculation.element('tbxEngineVolume').unblock(); + $calculation.element('tbxLeaseObjectMotorPower').unblock(); + } + } + ); } diff --git a/apps/web/process/leasing-object/reactions/validation.ts b/apps/web/process/leasing-object/reactions/validation.ts index a981034..d83b8db 100644 --- a/apps/web/process/leasing-object/reactions/validation.ts +++ b/apps/web/process/leasing-object/reactions/validation.ts @@ -1,11 +1,14 @@ -/* eslint-disable @typescript-eslint/naming-convention */ -import * as CRMTypes from '@/graphql/crm.types'; +import { createValidationSchema } from '../validation'; +import type { Elements } from '@/Components/Calculation/config/map/values'; import type { ProcessContext } from '@/process/types'; import ValidationHelper from '@/stores/validation/helper'; import { autorun, reaction } from 'mobx'; +import { uid } from 'radash'; -export default function reactions({ store, apolloClient }: ProcessContext) { - const { $calculation } = store; +const key = uid(7); + +export default function reactions(context: ProcessContext) { + const { $calculation } = context.store; /** * Если model содержит данные и по связи Модель-Комплектация в CRM у данной модели есть связанные активные записи Комплектаций, @@ -14,16 +17,23 @@ export default function reactions({ store, apolloClient }: ProcessContext) { autorun( () => { const selectConfiguration = $calculation.element('selectConfiguration'); - selectConfiguration.validate({ - invalid: selectConfiguration.getOptions()?.length > 0 && !selectConfiguration.getValue(), - message: 'Не заполнено поле', - }); + if (selectConfiguration.getOptions()?.length > 0 && !selectConfiguration.getValue()) { + selectConfiguration.setError({ + key, + message: 'Не заполнено поле', + }); + } else { + selectConfiguration.removeError({ key }); + } }, { delay: 10, } ); + const validationSchema = createValidationSchema(context); + const helper = new ValidationHelper(); + reaction( () => $calculation.$values.getValues([ @@ -31,134 +41,25 @@ export default function reactions({ store, apolloClient }: ProcessContext) { 'engineVolume', 'engineType', 'leaseObjectMotorPower', + 'countSeats', + 'maxMass', + 'leaseObjectCategory', ]), - async ({ - engineType, - engineVolume, - leaseObjectType: leaseObjectTypeId, - leaseObjectMotorPower, - }) => { - if (!leaseObjectTypeId) { - $calculation.element('selectEngineType').unblock(); - $calculation.element('tbxEngineVolume').unblock(); - $calculation.element('tbxLeaseObjectMotorPower').unblock(); + async (values) => { + helper.removeErrors(); + const validationResult = await validationSchema.safeParseAsync(values); - return; + if (!validationResult.success) { + validationResult.error.errors.forEach(({ path, message }) => { + (path as Elements[]).forEach((elementName) => { + const removeError = $calculation.element(elementName).setError({ key, message }); + if (removeError) helper.add(removeError); + }); + }); } - - const { - data: { evo_leasingobject_type }, - } = await apolloClient.query({ - query: CRMTypes.GetLeaseObjectTypeDocument, - variables: { - leaseObjectTypeId, - }, - }); - - if (evo_leasingobject_type?.evo_id === '8') { - $calculation.element('selectEngineType').resetValue().block(); - $calculation.element('tbxEngineVolume').resetValue().block(); - $calculation.element('tbxLeaseObjectMotorPower').resetValue().block(); - } else { - $calculation.element('selectEngineType').unblock(); - $calculation.element('tbxEngineVolume').unblock(); - $calculation.element('tbxLeaseObjectMotorPower').unblock(); - } - - const isNotTrailer = - evo_leasingobject_type?.evo_id !== null && evo_leasingobject_type?.evo_id !== '8'; - - $calculation.element('tbxEngineVolume').validate({ - invalid: isNotTrailer && engineVolume <= 0, - message: 'Не заполнено поле', - }); - $calculation.element('selectEngineType').validate({ - invalid: isNotTrailer && !engineType, - message: 'Не заполнено поле', - }); - $calculation.element('tbxLeaseObjectMotorPower').validate({ - invalid: isNotTrailer && leaseObjectMotorPower <= 0, - message: 'Не заполнено поле', - }); + }, + { + delay: 100, } ); - - { - const validationHelper = new ValidationHelper(); - - reaction( - () => $calculation.$values.getValues(['leaseObjectType', 'countSeats', 'maxMass']), - async ({ countSeats, leaseObjectType: leaseObjectTypeId, maxMass }) => { - if (!leaseObjectTypeId) { - validationHelper.removeErrors(); - - return; - } - - const { - data: { evo_leasingobject_type }, - } = await apolloClient.query({ - query: CRMTypes.GetLeaseObjectTypeDocument, - variables: { - leaseObjectTypeId, - }, - }); - - $calculation.element('tbxCountSeats').validate({ - helper: validationHelper, - invalid: evo_leasingobject_type?.evo_id === '1' && countSeats >= 9, - message: 'Количество мест должно быть меньше 9', - }); - - $calculation.element('tbxCountSeats').validate({ - helper: validationHelper, - invalid: - (evo_leasingobject_type?.evo_id === '4' || evo_leasingobject_type?.evo_id === '5') && - countSeats <= 8, - message: 'Количество мест должно быть больше 8', - }); - - $calculation.element('tbxMaxMass').validate({ - helper: validationHelper, - invalid: evo_leasingobject_type?.evo_id === '2' && maxMass <= 0, - message: 'Не заполнено поле', - }); - } - ); - } - - { - const validationHelper = new ValidationHelper(); - - reaction( - () => $calculation.$values.getValues(['leaseObjectType', 'leaseObjectCategory']), - async ({ leaseObjectCategory, leaseObjectType: leaseObjectTypeId }) => { - if (!leaseObjectTypeId) { - validationHelper.removeErrors(); - - return; - } - - const { - data: { evo_leasingobject_type }, - } = await apolloClient.query({ - query: CRMTypes.GetLeaseObjectTypeDocument, - variables: { - leaseObjectTypeId, - }, - }); - - $calculation.element('selectLeaseObjectCategory').validate({ - helper: validationHelper, - invalid: - !leaseObjectCategory && - Boolean( - evo_leasingobject_type?.evo_id && - !['6', '9', '10'].includes(evo_leasingobject_type?.evo_id) - ), - message: 'Не заполнено поле', - }); - } - ); - } } diff --git a/apps/web/process/leasing-object/validation.ts b/apps/web/process/leasing-object/validation.ts new file mode 100644 index 0000000..28430c4 --- /dev/null +++ b/apps/web/process/leasing-object/validation.ts @@ -0,0 +1,108 @@ +import type { ValidationContext } from '../types'; +import ValuesSchema from '@/config/schema/values'; +import * as CRMTypes from '@/graphql/crm.types'; +import { z } from 'zod'; + +export function createValidationSchema({ apolloClient }: ValidationContext) { + return ValuesSchema.pick({ + countSeats: true, + engineType: true, + engineVolume: true, + leaseObjectCategory: true, + leaseObjectMotorPower: true, + leaseObjectType: true, + maxMass: true, + }).superRefine( + async ( + { + leaseObjectType: leaseObjectTypeId, + engineVolume, + engineType, + leaseObjectMotorPower, + countSeats, + maxMass, + leaseObjectCategory, + }, + ctx + ) => { + if (leaseObjectTypeId) { + const { + data: { evo_leasingobject_type }, + } = await apolloClient.query({ + query: CRMTypes.GetLeaseObjectTypeDocument, + variables: { + leaseObjectTypeId, + }, + }); + + const isNotTrailer = + evo_leasingobject_type?.evo_id !== null && evo_leasingobject_type?.evo_id !== '8'; + + if (isNotTrailer && engineVolume <= 0) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Не заполнено поле', + path: ['tbxEngineVolume'], + }); + } + + if (isNotTrailer && !engineType) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Не заполнено поле', + path: ['selectEngineType'], + }); + } + + if (isNotTrailer && leaseObjectMotorPower <= 0) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Не заполнено поле', + path: ['tbxLeaseObjectMotorPower'], + }); + } + + if (evo_leasingobject_type?.evo_id === '1' && countSeats >= 9) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Количество мест должно быть меньше 9', + path: ['tbxCountSeats'], + }); + } + + if ( + (evo_leasingobject_type?.evo_id === '4' || evo_leasingobject_type?.evo_id === '5') && + countSeats <= 8 + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Количество мест должно быть больше 8', + path: ['tbxCountSeats'], + }); + } + + if (evo_leasingobject_type?.evo_id === '2' && maxMass <= 0) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Не заполнено поле', + path: ['tbxMaxMass'], + }); + } + + if ( + !leaseObjectCategory && + Boolean( + evo_leasingobject_type?.evo_id && + !['6', '9', '10'].includes(evo_leasingobject_type?.evo_id) + ) + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Не заполнено поле', + path: ['selectLeaseObjectCategory'], + }); + } + } + } + ); +} diff --git a/apps/web/process/leasing-without-kasko/reactions.ts b/apps/web/process/leasing-without-kasko/reactions.ts index a7d6177..fbe7912 100644 --- a/apps/web/process/leasing-without-kasko/reactions.ts +++ b/apps/web/process/leasing-without-kasko/reactions.ts @@ -1,8 +1,7 @@ /* eslint-disable canonical/sort-keys */ -/* eslint-disable @typescript-eslint/naming-convention */ -import type * as CRMTypes from '@/graphql/crm.types'; + +import * as CRMTypes from '@/graphql/crm.types'; import type { ProcessContext } from '@/process/types'; -import { gql } from '@apollo/client'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; import { reaction } from 'mobx'; @@ -14,34 +13,6 @@ dayjs.extend(utc); const NOTIFICATION_KEY = uid(7); -const QUERY_GET_LEASING_WITHOUT_KASKO_OPTIONS = gql` - query GetLeasingWithoutKaskoOptions($currentDate: DateTime) { - evo_addproduct_types( - statecode: 0 - evo_product_type: 100000007 - evo_datefrom_param: { lte: $currentDate } - evo_dateto_param: { gte: $currentDate } - ) { - label: evo_name - value: evo_addproduct_typeid - evo_product_type - evo_min_period - evo_max_period - evo_min_price - evo_max_price - evo_leasingobject_types { - evo_leasingobject_typeid - } - evo_visible_calc - evo_min_first_payment_perc - evo_max_first_payment_perc - evo_models { - evo_modelid - } - } - } -`; - export function common({ store, apolloClient }: ProcessContext) { const { $calculation, $tables } = store; @@ -95,18 +66,18 @@ export function common({ store, apolloClient }: ProcessContext) { firstPaymentPerc, model: modelId, }) => { - const currentDate = dayjs().utc(false).toISOString(); + const currentDate = dayjs().utc(false).format('YYYY-MM-DD'); const { data: { evo_addproduct_types }, - } = await apolloClient.query< - CRMTypes.GetLeasingWithoutKaskoOptionsQuery, - CRMTypes.GetLeasingWithoutKaskoOptionsQueryVariables - >({ - query: QUERY_GET_LEASING_WITHOUT_KASKO_OPTIONS, + } = await apolloClient.query({ + query: CRMTypes.GetLeasingWithoutKaskoTypesDocument, variables: { currentDate, }, + context: { + disableModify: true, + }, }); const price = plPriceRub - discountRub - importProgramSum + addEquipmentPrice; diff --git a/apps/web/process/load-kp/reactions.ts b/apps/web/process/load-kp/reactions.ts index 60b89e9..a495318 100644 --- a/apps/web/process/load-kp/reactions.ts +++ b/apps/web/process/load-kp/reactions.ts @@ -1,5 +1,6 @@ import type { ProcessContext } from '@/process/types'; import { reaction } from 'mobx'; +import { omit } from 'radash'; import message from 'ui/elements/message'; const key = 'KP_LOADING_INFO'; @@ -8,41 +9,36 @@ export function common({ store, trpcClient }: ProcessContext) { const { $calculation, $process, $tables } = store; reaction( - () => $calculation.element('selectQuote').getValue(), - (quoteId) => { - if (!quoteId || $process.has('LoadKP')) return; + () => $calculation.element('selectQuote').getOption(), + (quote) => { + if (!quote || $process.has('LoadKP')) return; $process.add('LoadKP'); - const quoteName = $calculation.element('selectQuote').getOption()?.label; - message.loading({ - content: `Загружаем КП ${quoteName}...`, + content: `Загружаем КП ${quote?.label}...`, key, }); trpcClient.quote.getData .query({ values: { - quote: quoteId, - ...$calculation.$values.getValues(['recalcWithRevision', 'lead', 'opportunity']), + quote: quote.value, + ...$calculation.$values.getValues(['lead', 'opportunity', 'recalcWithRevision']), }, }) .then(({ values, payments, insurance, fingap }) => { - const savedValues = $calculation.$values.getValues([ - 'lead', - 'opportunity', - 'quote', - 'leadUrl', - 'opportunityUrl', - 'quoteUrl', - 'recalcWithRevision', - ]); - - $calculation.$values.setValues({ - ...values, - ...savedValues, - }); + $calculation.$values.setValues( + omit(values, [ + 'lead', + 'opportunity', + 'quote', + 'leadUrl', + 'opportunityUrl', + 'quoteUrl', + 'recalcWithRevision', + ]) + ); $tables.payments.setValues(payments.values); @@ -59,13 +55,13 @@ export function common({ store, trpcClient }: ProcessContext) { if (fingap) $tables.fingap.setSelectedKeys(fingap.keys); message.success({ - content: `КП ${quoteName} загружено`, + content: `КП ${quote.label} загружено`, key, }); }) .catch(() => { message.error({ - content: `Ошибка во время загрузки КП ${quoteName}`, + content: `Ошибка во время загрузки КП ${quote.label}`, key, }); $calculation.element('selectQuote').resetValue(); diff --git a/apps/web/process/payments/lib/validation.ts b/apps/web/process/payments/lib/validation.ts deleted file mode 100644 index ae38795..0000000 --- a/apps/web/process/payments/lib/validation.ts +++ /dev/null @@ -1,138 +0,0 @@ -import { SEASONS_PERIOD_NUMBER, SEASONS_PERIODS } from './seasons-constants'; -import { MIN_PAYMENT } from '@/constants/values'; -import type RootStore from '@/stores/root'; -import { counting, max, min, shift, sort } from 'radash'; -import { areEqual, isSorted } from 'tools/array'; - -// eslint-disable-next-line sonarjs/cognitive-complexity -export default function validatePaymentsTable({ $calculation, $tables }: RootStore) { - /** - * в таблице платежей в столбце Соотношение платежей - * для строк с 2 до "Срок лизинга-1" минимальное значение должно быть равно 3 - */ - { - const leasingPeriod = $calculation.element('tbxLeasingPeriod').getValue(); - const targetPayments = $tables.payments.values.slice(1, leasingPeriod - 1); - - if (!targetPayments.every((payment) => payment >= MIN_PAYMENT)) { - return `Минимальное значение платежа должно быть равно ${MIN_PAYMENT}`; - } - } - - switch ($calculation.element('radioGraphType').getValue()) { - // Дегрессия - case 100_000_001: { - if (!$calculation.element('selectSeasonType').getValue()) { - return 'Не выбран тип дегрессии'; - } - - /** - * при Дегрессии все значения не должны быть равны друг другу - * + что при Легком старте 2,3 и 4 платежи не должны быть равны 100 - */ - { - const leasingPeriod = $calculation.element('tbxLeasingPeriod').getValue(); - const targetPayments = $tables.payments.values.slice(1, leasingPeriod - 1); - - if (new Set(targetPayments).size === 1) { - return 'Платежи не должны быть равны друг другу'; - } - } - - /** - * Проверка на возрастание - */ - { - const leasingPeriod = $calculation.element('tbxLeasingPeriod').getValue(); - const targetPayments = $tables.payments.values.slice(1, leasingPeriod - 1); - - for (let i = 2; i < targetPayments.length - 1; i += 1) { - if (targetPayments[i] > targetPayments[i - 1]) { - return 'Платежи должны убывать'; - } - } - } - /** - * Если вид графика = Дегрессия И значения в "Соотношении платежей" у 2, 3 и 4 платежа отличаются друг от друга не более чем на 10 - * (т.е. берем значения в этих полях, определяем максимальное и минимальное значение и смотрим на их разницу) - * то не осуществлять Расчет графика и выводить ошибку "Нельзя осуществить расчет - указана очень жетская дегрессия. - * На 2-4 платежах Соотношение платежа должен отличаться не более чем на 10%", - * иначе осуществлять расчет - */ - { - const targetPayments = $tables.payments.values.slice(1, 4); - - if ((max(targetPayments) || 0) - (min(targetPayments) || 0) > 10) { - return 'Указана очень жесткая дегрессия. На 2-4 платежах Соотношение платежа должен отличаться не более чем на 10%'; - } - } - - /** - * Если вид графика = Дегрессия И значения в "Соотношении платежей" для строк с 2 До "Срок лизинга-1" как минимум 2 раза по 2 платежа должны между собой быть равны - * (т.е. берем значения "Соотношения платежей" для строк с 2 до "Срок лизинга-1" и делаем сводную таблицу - если кол-во одинаковых значение больше 2 встречаются 2 и более раза), - * то осуществлять расчет, - * иначе не осуществлять Расчет графика и выводить ошибку "Нельзя осуществить расчет - указана очень жетская дегрессия. Не менее чем у 4х платежей "Соотношение платежа" должно не отличаться между самой", - */ - { - const leasingPeriod = $calculation.element('tbxLeasingPeriod').getValue(); - const targetPayments = $tables.payments.values.slice(1, leasingPeriod - 1); - const counts = counting(targetPayments, (v) => v); - if (Object.values(counts).filter((count) => count > 1).length < 2) { - return 'Указана очень жесткая дегрессия. Не менее чем у 4х платежей соотношение должно не отличаться между собой'; - } - } - - break; - } - - case 100_000_003: { - const leasingPeriod = $calculation.element('tbxLeasingPeriod').getValue(); - if (leasingPeriod < 14) { - return 'При сезонном виде графика срок лизинга должен быть больше 14 месяцев'; - } - - const seasonType = $calculation.element('selectSeasonType').getValue(); - if (!seasonType) { - return 'Не выбран тип сезонности'; - } - - const highSeasonStartOption = $calculation.element('selectHighSeasonStart').getOption(); - if (!highSeasonStartOption) { - return 'Не выбрано смещение сезонности'; - } - - { - const seasons = $tables.payments.values.slice(1, SEASONS_PERIOD_NUMBER + 1); - const shiftNumber = Number.parseInt(highSeasonStartOption.label, 10) - 2; - const unshiftedSeasons = shift(seasons, -shiftNumber); - - const positions = SEASONS_PERIODS[seasonType]; - const seasonsValues = positions.map((position) => unshiftedSeasons[position]); - - if (isSorted(seasonsValues)) { - return 'Сезонные платежи должны убывать'; - } - } - - break; - } - - // Легкий старт - case 100_000_004: { - const targetPayments = $tables.payments.values.slice(1, 4); - const sortedPayments = sort(targetPayments, (x) => x); - const areEqualPayments = new Set(targetPayments).size === 1; - - if (!areEqual(targetPayments, sortedPayments) || areEqualPayments) { - return '2, 3, 4 платежи должны возрастать'; - } - - break; - } - default: { - return null; - } - } - - return null; -} diff --git a/apps/web/process/payments/reactions/validation.ts b/apps/web/process/payments/reactions/validation.ts index 7d6eefb..7338325 100644 --- a/apps/web/process/payments/reactions/validation.ts +++ b/apps/web/process/payments/reactions/validation.ts @@ -1,64 +1,56 @@ -import validatePaymentsTable from '../lib/validation'; -import { MIN_LASTPAYMENT_NSIB } from '@/constants/values'; +import { createValidationSchema } from '../validation'; +import type { Elements } from '@/Components/Calculation/config/map/values'; import type { ProcessContext } from '@/process/types'; import ValidationHelper from '@/stores/validation/helper'; import { comparer, reaction, toJS } from 'mobx'; +import { uid } from 'radash'; -export default function reactions({ store }: ProcessContext) { - const { $calculation, $tables } = store; +const key = uid(7); - const validationHelper = new ValidationHelper(); +export default function reactions(context: ProcessContext) { + const { $calculation, $tables } = context.store; + + const validationSchema = createValidationSchema(); + const helper = new ValidationHelper(); reaction( () => { const payments = toJS($tables.payments.values); - const graphType = $calculation.element('radioGraphType').getValue(); - const seasonType = $calculation.element('selectSeasonType').getValue(); - const highSeasonStart = $calculation.element('selectHighSeasonStart').getValue(); - const leasingPeriod = $calculation.element('tbxLeasingPeriod').getValue(); + const values = $calculation.$values.getValues([ + 'graphType', + 'highSeasonStart', + 'leasingPeriod', + 'seasonType', + 'insNSIB', + 'lastPaymentRub', + ]); return { - graphType, - highSeasonStart, - leasingPeriod, - payments, - seasonType, + payments: { values: payments }, + ...values, }; }, - () => { - validationHelper.removeErrors(); + async (values) => { + helper.removeErrors(); + const validationResult = await validationSchema.safeParseAsync(values); - const errorText = validatePaymentsTable(store); - - if (errorText) { - $tables.payments.validate({ - helper: validationHelper, - invalid: errorText !== null, - message: errorText, + if (!validationResult.success) { + validationResult.error.errors.forEach(({ path, message }) => { + (path as Array).forEach((elementName) => { + if (elementName === 'payments') { + const removeError = $tables.payments.setError({ key, message }); + if (removeError) helper.add(removeError); + } else { + const removeError = $calculation.element(elementName).setError({ key, message }); + if (removeError) helper.add(removeError); + } + }); }); } }, { - delay: 50, + delay: 100, equals: comparer.structural, } ); - - reaction( - () => { - const lastPaymentRub = $calculation.element('tbxLastPaymentRub').getValue(); - const insNSIB = $calculation.element('selectInsNSIB').getValue(); - - return { - insNSIB, - lastPaymentRub, - }; - }, - ({ lastPaymentRub, insNSIB }) => { - $calculation.element('tbxLastPaymentRub').validate({ - invalid: Boolean(insNSIB) && lastPaymentRub < MIN_LASTPAYMENT_NSIB, - message: `Последний платеж меньше ${MIN_LASTPAYMENT_NSIB} руб. не может быть при наличии НСИБ, укажите большее значение`, - }); - } - ); } diff --git a/apps/web/process/payments/validation.ts b/apps/web/process/payments/validation.ts new file mode 100644 index 0000000..5a5fc1f --- /dev/null +++ b/apps/web/process/payments/validation.ts @@ -0,0 +1,215 @@ +/* eslint-disable sonarjs/cognitive-complexity */ +/* eslint-disable complexity */ +import { SEASONS_PERIOD_NUMBER, SEASONS_PERIODS } from './lib/seasons-constants'; +import { selectHighSeasonStart } from '@/config/default-options'; +import PaymentsSchema from '@/config/schema/payments'; +import ValuesSchema from '@/config/schema/values'; +import { MIN_LASTPAYMENT_NSIB, MIN_PAYMENT } from '@/constants/values'; +import { counting, max, min, shift, sort } from 'radash'; +import { areEqual, isSorted } from 'tools/array'; +import { z } from 'zod'; + +export function createValidationSchema() { + return ValuesSchema.pick({ + graphType: true, + highSeasonStart: true, + insNSIB: true, + lastPaymentRub: true, + leasingPeriod: true, + seasonType: true, + }) + .extend({ + payments: PaymentsSchema, + }) + .superRefine( + async ( + { + graphType, + highSeasonStart, + leasingPeriod, + payments, + seasonType, + insNSIB, + lastPaymentRub, + }, + ctx + ) => { + if (Boolean(insNSIB) && lastPaymentRub < MIN_LASTPAYMENT_NSIB) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: `Последний платеж не может быть меньше ${MIN_LASTPAYMENT_NSIB} руб. при наличии НСИБ, укажите большее значение`, + path: ['tbxLastPaymentRub'], + }); + } + + { + const targetPayments = payments.values.slice(1, leasingPeriod - 1); + + if (!targetPayments.every((payment) => payment >= MIN_PAYMENT)) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: `Минимальное значение платежа должно быть равно ${MIN_PAYMENT}`, + path: ['payments'], + }); + } + } + + switch (graphType) { + // Дегрессия + case 100_000_001: { + if (!seasonType) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Не выбран тип дегрессии', + path: ['payments', 'selectSeasonType'], + }); + break; + } + + /** + * при Дегрессии все значения не должны быть равны друг другу + * + что при Легком старте 2,3 и 4 платежи не должны быть равны 100 + */ + { + const targetPayments = payments.values.slice(1, leasingPeriod - 1); + if (new Set(targetPayments).size === 1) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Платежи не должны быть равны друг другу', + path: ['payments'], + }); + } + } + + /** + * Проверка на возрастание + */ + { + const targetPayments = payments.values.slice(1, leasingPeriod - 1); + for (let i = 2; i < targetPayments.length - 1; i += 1) { + if (targetPayments[i] > targetPayments[i - 1]) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Платежи должны убывать', + path: ['payments'], + }); + } + } + } + + /** + * Если вид графика = Дегрессия И значения в "Соотношении платежей" у 2, 3 и 4 платежа отличаются друг от друга не более чем на 10 + * (т.е. берем значения в этих полях, определяем максимальное и минимальное значение и смотрим на их разницу) + * то не осуществлять Расчет графика и выводить ошибку "Нельзя осуществить расчет - указана очень жетская дегрессия. + * На 2-4 платежах Соотношение платежа должен отличаться не более чем на 10%", + * иначе осуществлять расчет + */ + { + const targetPayments = payments.values.slice(1, 4); + + if ((max(targetPayments) || 0) - (min(targetPayments) || 0) > 10) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: + 'Указана очень жесткая дегрессия. На 2-4 платежах Соотношение платежа должен отличаться не более чем на 10%', + path: ['payments'], + }); + } + } + + /** + * Если вид графика = Дегрессия И значения в "Соотношении платежей" для строк с 2 До "Срок лизинга-1" как минимум 2 раза по 2 платежа должны между собой быть равны + * (т.е. берем значения "Соотношения платежей" для строк с 2 до "Срок лизинга-1" и делаем сводную таблицу - если кол-во одинаковых значение больше 2 встречаются 2 и более раза), + * то осуществлять расчет, + * иначе не осуществлять Расчет графика и выводить ошибку "Нельзя осуществить расчет - указана очень жетская дегрессия. Не менее чем у 4х платежей "Соотношение платежа" должно не отличаться между самой", + */ + { + const targetPayments = payments.values.slice(1, leasingPeriod - 1); + const counts = counting(targetPayments, (v) => v); + if (Object.values(counts).filter((count) => count > 1).length < 2) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: + 'Указана очень жесткая дегрессия. Не менее чем у 4х платежей соотношение должно не отличаться между собой', + path: ['payments'], + }); + } + } + + break; + } + + case 100_000_003: { + if (leasingPeriod < 14) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'При сезонном виде графика срок лизинга должен быть больше 14 месяцев', + path: ['payments', 'tbxLeasingPeriod'], + }); + } + + if (!seasonType) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Не выбран тип сезонности', + path: ['payments', 'selectSeasonType'], + }); + break; + } + + if (!highSeasonStart) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Не выбрано смещение сезонности', + path: ['payments', 'selectHighSeasonStart'], + }); + break; + } + + const seasons = payments.values.slice(1, SEASONS_PERIOD_NUMBER + 1); + const highSeasonStartOption = selectHighSeasonStart.find( + (x) => x.value === highSeasonStart + ); + + if (highSeasonStartOption) { + const shiftNumber = Number.parseInt(highSeasonStartOption.label, 10) - 2; + const unshiftedSeasons = shift(seasons, -shiftNumber); + + const positions = SEASONS_PERIODS[seasonType]; + const seasonsValues = positions.map((position) => unshiftedSeasons[position]); + + if (isSorted(seasonsValues)) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Сезонные платежи должны убывать', + path: ['payments'], + }); + } + } + + break; + } + + // Легкий старт + case 100_000_004: { + const targetPayments = payments.values.slice(1, 4); + const sortedPayments = sort(targetPayments, (x) => x); + const areEqualPayments = new Set(targetPayments).size === 1; + + if (!areEqual(targetPayments, sortedPayments) || areEqualPayments) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: '2, 3, 4 платежи должны возрастать', + path: ['payments'], + }); + } + + break; + } + default: { + break; + } + } + } + ); +} diff --git a/apps/web/process/price/get-kp-data.ts b/apps/web/process/price/get-kp-data.ts index 14c3f8e..7093e4b 100644 --- a/apps/web/process/price/get-kp-data.ts +++ b/apps/web/process/price/get-kp-data.ts @@ -19,6 +19,7 @@ const QUERY_GET_QUOTE_PRICE_DATA = gql` evo_price_without_nds_supplier_currency evo_supplier_currency_price evo_transactioncurrencyid + evo_equip_price } } `; @@ -41,6 +42,7 @@ export async function getKPData({ values: { VATInLeaseObjectPrice: quote?.evo_nds_in_price_supplier_currency ?? defaultValues.VATInLeaseObjectPrice, + addEquipmentPrice: quote?.evo_equip_price ?? defaultValues.addEquipmentPrice, comissionPerc: quote?.evo_comission_perc ?? defaultValues.comissionPerc, // comissionRub: quote?.evo_comission_rub , firstPaymentPerc: quote?.evo_first_payment_perc ?? defaultValues.firstPaymentPerc, diff --git a/apps/web/process/price/reactions/common.ts b/apps/web/process/price/reactions/common.ts index a227432..d393e3b 100644 --- a/apps/web/process/price/reactions/common.ts +++ b/apps/web/process/price/reactions/common.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import { VAT } from '@/constants/values'; import * as CRMTypes from '@/graphql/crm.types'; import type { ProcessContext } from '@/process/types'; diff --git a/apps/web/process/price/reactions/computed.ts b/apps/web/process/price/reactions/computed.ts index af76d14..8ec3b9b 100644 --- a/apps/web/process/price/reactions/computed.ts +++ b/apps/web/process/price/reactions/computed.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import * as CRMTypes from '@/graphql/crm.types'; import type { ProcessContext } from '@/process/types'; import dayjs from 'dayjs'; diff --git a/apps/web/process/price/reactions/validation.ts b/apps/web/process/price/reactions/validation.ts index 8860c17..236a9c5 100644 --- a/apps/web/process/price/reactions/validation.ts +++ b/apps/web/process/price/reactions/validation.ts @@ -1,74 +1,44 @@ -/* eslint-disable @typescript-eslint/naming-convention */ -import { VAT } from '@/constants/values'; -import * as CRMTypes from '@/graphql/crm.types'; +import { createValidationSchema } from '../validation'; +import type { Elements } from '@/Components/Calculation/config/map/values'; import type { ProcessContext } from '@/process/types'; +import ValidationHelper from '@/stores/validation/helper'; import { reaction } from 'mobx'; -import { round } from 'tools'; +import { uid } from 'radash'; -export default function reactions({ store, apolloClient }: ProcessContext) { +const key = uid(7); + +export default function reactions(context: ProcessContext) { + const { store } = context; const { $calculation } = store; + const validationSchema = createValidationSchema(context); + const helper = new ValidationHelper(); reaction( () => $calculation.$values.getValues([ 'VATInLeaseObjectPrice', 'leaseObjectPriceWthtVAT', 'product', + 'supplierDiscountRub', + 'plPriceRub', + 'firstPaymentRub', + 'subsidySum', ]), - async ({ VATInLeaseObjectPrice, leaseObjectPriceWthtVAT, product: productId }) => { - let evo_sale_without_nds = false; + async (values) => { + helper.removeErrors(); + const validationResult = await validationSchema.safeParseAsync(values); - if (productId) { - const { - data: { evo_baseproduct }, - } = await apolloClient.query({ - query: CRMTypes.GetProductDocument, - variables: { - productId, - }, + if (!validationResult.success) { + validationResult.error.errors.forEach(({ path, message }) => { + (path as Elements[]).forEach((elementName) => { + const removeError = $calculation.element(elementName).setError({ key, message }); + if (removeError) helper.add(removeError); + }); }); - if (evo_baseproduct?.evo_sale_without_nds) { - evo_sale_without_nds = evo_baseproduct.evo_sale_without_nds; - } } - - $calculation.element('tbxVATInLeaseObjectPrice').validate({ - invalid: - evo_sale_without_nds && round(VATInLeaseObjectPrice / leaseObjectPriceWthtVAT, 2) >= VAT, - message: - 'При продаже ПЛ после ФЛ размер НДС в стоимости ПЛ не может составлять 20% и более от стоимости с НДС. Проверьте корректность НДС, либо измените Продукт', - }); - } - ); - - reaction( - () => $calculation.$values.getValues(['supplierDiscountRub', 'plPriceRub']), - ({ supplierDiscountRub, plPriceRub }) => { - $calculation.element('tbxSupplierDiscountRub').validate({ - invalid: supplierDiscountRub >= plPriceRub, - message: 'Скидка от поставщика не может быть больше или равна стоимости ПЛ', - }); - } - ); - - reaction( - () => $calculation.$values.getValues(['firstPaymentRub', 'plPriceRub']), - ({ firstPaymentRub, plPriceRub }) => { - $calculation.element('tbxFirstPaymentRub').validate({ - invalid: firstPaymentRub >= plPriceRub, - message: 'Первый платеж не может быть больше или равен стоимости ПЛ', - }); - } - ); - - reaction( - () => $calculation.$values.getValues(['firstPaymentRub', 'subsidySum']), - ({ firstPaymentRub, subsidySum }) => { - $calculation.element('tbxFirstPaymentRub').validate({ - invalid: firstPaymentRub - subsidySum < 0, - message: - 'Первый платеж с учетом субсидии получается отрицательный, увеличьте первый платеж', - }); + }, + { + delay: 100, } ); } diff --git a/apps/web/process/price/validation.ts b/apps/web/process/price/validation.ts new file mode 100644 index 0000000..a924ba2 --- /dev/null +++ b/apps/web/process/price/validation.ts @@ -0,0 +1,79 @@ +import type { ValidationContext } from '../types'; +import ValuesSchema from '@/config/schema/values'; +import { VAT } from '@/constants/values'; +import * as CRMTypes from '@/graphql/crm.types'; +import { round } from 'tools'; +import { z } from 'zod'; + +export function createValidationSchema({ apolloClient }: ValidationContext) { + return ValuesSchema.pick({ + VATInLeaseObjectPrice: true, + firstPaymentRub: true, + leaseObjectPriceWthtVAT: true, + plPriceRub: true, + product: true, + subsidySum: true, + supplierDiscountRub: true, + }).superRefine( + async ( + { + VATInLeaseObjectPrice, + leaseObjectPriceWthtVAT, + product: productId, + supplierDiscountRub, + plPriceRub, + firstPaymentRub, + subsidySum, + }, + ctx + ) => { + if (productId) { + const { + data: { evo_baseproduct }, + } = await apolloClient.query({ + query: CRMTypes.GetProductDocument, + variables: { + productId, + }, + }); + + if ( + evo_baseproduct?.evo_sale_without_nds && + round(VATInLeaseObjectPrice / leaseObjectPriceWthtVAT, 2) >= VAT + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: + 'При продаже ПЛ после ФЛ размер НДС в стоимости ПЛ не может составлять 20% и более от стоимости с НДС. Проверьте корректность НДС, либо измените Продукт', + path: ['tbxVATInLeaseObjectPrice'], + }); + } + } + + if (supplierDiscountRub >= plPriceRub) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Скидка не может быть больше или равна стоимости ПЛ', + path: ['tbxSupplierDiscountRub'], + }); + } + + if (firstPaymentRub >= plPriceRub) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Первый платеж не может быть больше или равен стоимости ПЛ', + path: ['tbxFirstPaymentRub'], + }); + } + + if (firstPaymentRub - subsidySum < 0) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: + 'Первый платеж с учетом субсидии получается отрицательный, увеличьте первый платеж', + path: ['tbxFirstPaymentRub'], + }); + } + } + ); +} diff --git a/apps/web/process/recalc/index.ts b/apps/web/process/recalc/index.ts new file mode 100644 index 0000000..88c740a --- /dev/null +++ b/apps/web/process/recalc/index.ts @@ -0,0 +1 @@ +export * as reactions from './reactions'; diff --git a/apps/web/process/recalc/reactions.ts b/apps/web/process/recalc/reactions.ts new file mode 100644 index 0000000..d122d51 --- /dev/null +++ b/apps/web/process/recalc/reactions.ts @@ -0,0 +1,252 @@ +import type { ProcessContext } from '../types'; +import { createValidationSchema } from './validation'; +import { makeDisposable, normalizeOptions } from '@/../../packages/tools'; +import type { Elements } from '@/Components/Calculation/config/map/values'; +import { selectRequirementTelematic } from '@/config/default-options'; +import * as CRMTypes from '@/graphql/crm.types'; +import type { Values } from '@/stores/calculation/values/types'; +import ValidationHelper from '@/stores/validation/helper'; +import dayjs from 'dayjs'; +import utc from 'dayjs/plugin/utc'; +import { reaction } from 'mobx'; +import { uid } from 'radash'; + +dayjs.extend(utc); + +export function common({ store, apolloClient }: ProcessContext) { + const { $calculation, $tables } = store; + + reaction( + () => $calculation.element('cbxRecalcWithRevision').getValue(), + () => $calculation.element('selectQuote').resetValue() + ); + + makeDisposable( + () => + reaction( + () => + $calculation.$values.getValues([ + 'supplierDiscountRub', + 'addEquipmentPrice', + 'importProgramSum', + 'plPriceRub', + ]), + ({ supplierDiscountRub, importProgramSum, addEquipmentPrice, plPriceRub }) => { + const price = plPriceRub + addEquipmentPrice - importProgramSum; + const maxPriceChange = + price - supplierDiscountRub < 800_000 + ? price - supplierDiscountRub + 50_000 + : (price - supplierDiscountRub) * 1.05; + + $calculation.element('tbxMaxPriceChange').setValue(maxPriceChange); + + const minPriceChange = + price - supplierDiscountRub < 800_000 + ? price - supplierDiscountRub - 50_000 + : (price - supplierDiscountRub) * 0.95; + + $calculation.element('tbxMinPriceChange').setValue(minPriceChange); + } + ), + () => $calculation.element('cbxRecalcWithRevision').getValue() === true + ); + + reaction( + () => $calculation.$values.getValues(['leaseObjectUsed', 'recalcWithRevision']), + ({ leaseObjectUsed, recalcWithRevision }) => { + if (recalcWithRevision && leaseObjectUsed) { + $calculation.element('tbxLeaseObjectYear').block(); + } else { + $calculation.element('tbxLeaseObjectYear').unblock(); + } + } + ); + + reaction( + () => $calculation.$values.getValues(['recalcWithRevision', 'leaseObjectType']), + async ({ recalcWithRevision, leaseObjectType: leaseObjectTypeId }) => { + if (recalcWithRevision === false) { + $calculation + .element('selectRequirementTelematic') + .setOptions( + selectRequirementTelematic.filter((x) => + [100_000_000, 100_000_001, 100_000_002, 100_000_003].includes(x.value) + ) + ); + + if (leaseObjectTypeId) { + const { + data: { evo_leasingobject_type }, + } = await apolloClient.query({ + query: CRMTypes.GetLeaseObjectTypeDocument, + variables: { leaseObjectTypeId }, + }); + + if (evo_leasingobject_type?.evo_id === '11') { + $calculation.element('selectRequirementTelematic').setValue(100_000_000).block(); + } else { + $calculation.element('selectRequirementTelematic').unblock(); + } + } + } else { + $calculation.element('selectRequirementTelematic').resetOptions(); + } + } + ); + + reaction( + () => $calculation.$values.getValues(['requirementTelematic', 'recalcWithRevision']), + async ({ requirementTelematic, recalcWithRevision }) => { + const currentDate = dayjs().utc(false).format('YYYY-MM-DD'); + const { + data: { evo_addproduct_types: trackerTypes }, + } = await apolloClient.query({ + query: CRMTypes.GetTrackerTypesDocument, + variables: { currentDate }, + }); + + const { + data: { evo_addproduct_types: telematicTypes }, + } = await apolloClient.query({ + query: CRMTypes.GetTelematicTypesDocument, + variables: { currentDate }, + }); + + let filteredTrackerTypes = trackerTypes?.filter( + (x) => requirementTelematic && x?.evo_controls_program?.includes(requirementTelematic) + ); + + let filteredTelematicTypes = telematicTypes?.filter( + (x) => requirementTelematic && x?.evo_controls_program?.includes(requirementTelematic) + ); + + if (!recalcWithRevision) { + filteredTrackerTypes = filteredTrackerTypes?.filter((x) => x?.evo_visible_calc === true); + filteredTelematicTypes = filteredTelematicTypes?.filter( + (x) => x?.evo_visible_calc === true + ); + } + + $calculation.element('selectTracker').setOptions(normalizeOptions(filteredTrackerTypes)); + $calculation.element('selectTelematic').setOptions(normalizeOptions(filteredTelematicTypes)); + } + ); + + { + const elements: Elements[] = [ + 'cbxLeaseObjectUsed', + 'radioGraphType', + 'selectBrand', + 'selectCalcBroker', + 'selectCalcFinDepartment', + 'selectClientRisk', + 'selectClientType', + 'selectConfiguration', + 'selectDealer', + 'selectDealerPerson', + 'selectHighSeasonStart', + 'selectImportProgram', + 'selectIndAgent', + 'selectLead', + 'selectLeaseObjectCategory', + 'selectLeaseObjectType', + 'selectModel', + 'selectOpportunity', + 'selectRate', + 'selectRequirementTelematic', + 'selectSeasonType', + 'selectSubsidy', + 'selectTarif', + 'selectTelematic', + 'selectTracker', + 'tbxAddEquipmentPrice', + 'tbxCreditRate', + 'tbxEngineHours', + 'tbxImporterRewardPerc', + 'tbxImporterRewardRub', + 'tbxLeasingPeriod', + 'tbxMaxPriceChange', + 'tbxMileage', + 'tbxParmentsDecreasePercent', + 'tbxVIN', + ]; + reaction( + () => $calculation.element('cbxRecalcWithRevision').getValue(), + (recalcWithRevision) => { + if (recalcWithRevision) { + elements.forEach((elementName) => + $calculation.$status.overrideStatus(elementName, 'Disabled') + ); + $tables.payments.overrideStatuses('Disabled'); + } else { + elements.forEach((elementName) => $calculation.$status.clearOverridedStatus(elementName)); + $tables.payments.clearOverridedStatuses(); + } + } + ); + + const agents: Elements[] = [ + 'selectCalcBroker', + 'selectCalcBrokerRewardCondition', + 'selectCalcDoubleAgent', + 'selectCalcDoubleAgentRewardCondition', + 'selectCalcFinDepartment', + 'selectDealerBroker', + 'selectDealerBrokerRewardCondition', + 'selectDealerPerson', + 'selectDealerRewardCondition', + 'selectFinDepartmentRewardCondtion', + 'selectIndAgent', + 'selectIndAgentRewardCondition', + 'tbxCalcBrokerRewardSum', + 'tbxCalcDoubleAgentRewardSumm', + 'tbxDealerBrokerRewardSumm', + 'tbxDealerRewardSumm', + 'tbxFinDepartmentRewardSumm', + 'tbxIndAgentRewardSumm', + ]; + + reaction( + () => $calculation.$values.getValues(['firstPaymentPerc', 'recalcWithRevision']), + ({ firstPaymentPerc, recalcWithRevision }) => { + if (firstPaymentPerc === 0 && recalcWithRevision === true) { + agents.forEach((elementName) => + $calculation.$status.overrideStatus(elementName, 'Disabled') + ); + } else { + agents.forEach((elementName) => $calculation.$status.clearOverridedStatus(elementName)); + } + } + ); + } +} + +const key = uid(7); + +export function validation(context: ProcessContext) { + const { store } = context; + const { $calculation } = store; + const validationSchema = createValidationSchema(context); + + const helper = new ValidationHelper(); + reaction( + () => + $calculation.$values.getValues(Object.keys(validationSchema._def.schema.shape) as Values[]), + async (values) => { + helper.removeErrors(); + const validationResult = await validationSchema.safeParseAsync(values); + + if (!validationResult.success) { + validationResult.error.errors.forEach(({ path, message }) => { + (path as Elements[]).forEach((elementName) => { + const removeError = $calculation.element(elementName).setError({ key, message }); + if (removeError) helper.add(removeError); + }); + }); + } + }, + { + delay: 100, + } + ); +} diff --git a/apps/web/process/recalc/validation.ts b/apps/web/process/recalc/validation.ts new file mode 100644 index 0000000..ac9b644 --- /dev/null +++ b/apps/web/process/recalc/validation.ts @@ -0,0 +1,249 @@ +/* eslint-disable complexity */ +import type { ValidationContext } from '../types'; +import ValuesSchema from '@/config/schema/values'; +import { MAX_MASS, MAX_VEHICLE_SEATS } from '@/constants/values'; +import * as CRMTypes from '@/graphql/crm.types'; +import { z } from 'zod'; + +export function createValidationSchema({ apolloClient }: ValidationContext) { + return ValuesSchema.pick({ + addEquipmentPrice: true, + balanceHolder: true, + countSeats: true, + dealerPerson: true, + firstPaymentPerc: true, + importProgramSum: true, + lastPaymentPerc: true, + leaseObjectCount: true, + leaseObjectPriceWthtVAT: true, + leaseObjectUsed: true, + leaseObjectYear: true, + maxMass: true, + plPriceRub: true, + product: true, + quote: true, + recalcWithRevision: true, + supplierDiscountRub: true, + }).superRefine( + async ( + { + addEquipmentPrice, + dealerPerson: dealerPersonId, + importProgramSum, + leaseObjectPriceWthtVAT, + leaseObjectUsed, + product: productId, + quote: quoteId, + recalcWithRevision, + supplierDiscountRub, + plPriceRub, + firstPaymentPerc, + leaseObjectCount, + maxMass, + countSeats, + leaseObjectYear, + lastPaymentPerc, + balanceHolder, + }, + ctx + ) => { + if (!recalcWithRevision) { + return; + } + + if (dealerPersonId && quoteId && productId) { + const { + data: { account: dealerPerson }, + } = await apolloClient.query({ + query: CRMTypes.GetDealerPersonDocument, + variables: { dealerPersonId }, + }); + + const { + data: { quote }, + } = await apolloClient.query({ + query: CRMTypes.GetQuoteDocument, + variables: { quoteId }, + }); + + const { + data: { evo_baseproduct }, + } = await apolloClient.query({ + query: CRMTypes.GetProductDocument, + variables: { productId }, + }); + + const maxCondition1 = + leaseObjectUsed === false && + dealerPerson?.evo_supplier_type !== 100_000_001 && + !evo_baseproduct?.evo_sale_without_nds && + Boolean( + quote?.evo_max_price_change && + plPriceRub - supplierDiscountRub + addEquipmentPrice - importProgramSum > + quote.evo_max_price_change + ); + + const maxCondition2 = + leaseObjectUsed === false && + dealerPerson?.evo_supplier_type !== 100_000_001 && + Boolean(evo_baseproduct?.evo_sale_without_nds) && + Boolean( + quote?.evo_nds_in_price_supplier_currency && + quote?.evo_max_price_change && + leaseObjectPriceWthtVAT > + quote.evo_max_price_change - quote.evo_nds_in_price_supplier_currency + ); + + const maxCondition3 = + (leaseObjectUsed === true || dealerPerson?.evo_supplier_type === 100_000_001) && + Boolean( + quote?.evo_supplier_currency_price && + quote.evo_discount_supplier_currency && + quote.evo_equip_price && + quote.evo_program_import_subsidy_sum && + plPriceRub - supplierDiscountRub + addEquipmentPrice - importProgramSum > + quote?.evo_supplier_currency_price - + quote.evo_discount_supplier_currency + + quote.evo_equip_price - + quote.evo_program_import_subsidy_sum + ); + + const minCondition1 = + !evo_baseproduct?.evo_sale_without_nds && + Boolean( + quote?.evo_min_change_price && + plPriceRub - supplierDiscountRub + addEquipmentPrice - importProgramSum < + quote.evo_min_change_price + ); + + const minCondition2 = + Boolean(evo_baseproduct?.evo_sale_without_nds) && + Boolean( + quote?.evo_nds_in_price_supplier_currency && + quote?.evo_min_change_price && + leaseObjectPriceWthtVAT < + quote.evo_min_change_price - quote.evo_nds_in_price_supplier_currency + ); + + if (maxCondition1 || maxCondition2) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: + 'Указанная стоимость предмета лизинга больше возможного изменения стоимости предмета лизинга при пересчете без пересмотра. ' + + 'Уменьшите стоимость предмета лизинга', + path: ['tbxLeaseObjectPrice'], + }); + } else if (maxCondition3) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: + 'При пересчете без пересмотра КП с ПЛ БУ или с непрофессиональным поставщиком недопустимо увеличение стоимости. Создайте новое КП и отправьте его на рассмотрение андеррайтингу для повторной проверки оценщиком.', + path: ['tbxLeaseObjectPrice'], + }); + } else if (minCondition1 || minCondition2) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: + 'Указанная стоимость предмета лизинга меньше возможного изменения стоимости предмета лизинга при пересчете без пересмотра. ' + + 'Увеличьте стоимость предмета лизинга', + path: ['tbxLeaseObjectPrice'], + }); + } + } + + if (quoteId) { + const { + data: { quote }, + } = await apolloClient.query({ + query: CRMTypes.GetQuoteDocument, + variables: { quoteId }, + }); + + if ( + quote?.evo_approved_first_payment && + firstPaymentPerc < quote.evo_approved_first_payment + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: `Указанный первый платеж меньше одобренного ${quote?.evo_approved_first_payment}. При пересчете без пересмотра изменение первого платежа возможно только в большую сторону от одобренного значения`, + path: ['tbxFirstPaymentPerc'], + }); + } + + if (quote?.evo_recalc_limit && leaseObjectCount > quote.evo_recalc_limit) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Количество ПЛ превышает лимит пересчета без пересмотра', + path: ['tbxLeaseObjectCount'], + }); + } + + if ( + (quote?.evo_max_mass && maxMass < MAX_MASS && quote.evo_max_mass < MAX_MASS) || + (quote?.evo_max_mass && maxMass >= MAX_MASS && quote?.evo_max_mass >= MAX_MASS) + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: + 'Указанная разрешенная макс. масса выходит из утвержденного диапазона. Для изменения параметра требуется пересмотр сделки', + path: ['tbxMaxMass'], + }); + } + + if ( + (quote?.evo_seats && + countSeats < MAX_VEHICLE_SEATS && + quote.evo_seats < MAX_VEHICLE_SEATS) || + (quote?.evo_seats && + countSeats >= MAX_VEHICLE_SEATS && + quote.evo_seats >= MAX_VEHICLE_SEATS) + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: + 'Указанное кол-во мест выходит из утвержденного диапазона. Для изменения параметра требуется пересмотр сделки', + path: ['tbxCountSeats'], + }); + } + + if (quote?.evo_year && leaseObjectYear >= quote.evo_year) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'При пересчете без пересмотра год выпуска нельзя уменьшать', + path: ['tbxLeaseObjectYear'], + }); + } + + if ( + quote?.evo_last_payment_perc && + lastPaymentPerc > 1 && + lastPaymentPerc > quote.evo_last_payment_perc + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: + 'При пересчете без пересмотра последний платеж можно уменьшать или увеличивать до 1%', + path: ['tbxLastPaymentPerc'], + }); + } + + if (balanceHolder === 100_000_001) { + if (lastPaymentPerc < 1) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: + 'При балансе лизингодатель последний платеж не может быть меньше 1%! Увеличьте значение.', + path: ['tbxLastPaymentPerc'], + }); + } + } else if (lastPaymentPerc === 0) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Последний платеж не может быть равен 0. Увеличьте значение', + path: ['tbxLastPaymentPerc'], + }); + } + } + } + ); +} diff --git a/apps/web/process/subsidy-import-program/reactions.ts b/apps/web/process/subsidy-import-program/reactions.ts index 40af966..a834ce9 100644 --- a/apps/web/process/subsidy-import-program/reactions.ts +++ b/apps/web/process/subsidy-import-program/reactions.ts @@ -1,5 +1,5 @@ /* eslint-disable no-negated-condition */ -/* eslint-disable @typescript-eslint/naming-convention */ + import type { ProcessContext } from '../types'; import * as CRMTypes from '@/graphql/crm.types'; import { reaction } from 'mobx'; diff --git a/apps/web/process/supplier-agent/get-kp-data/get-sums.ts b/apps/web/process/supplier-agent/get-kp-data/get-sums.ts index d12138e..299fcb5 100644 --- a/apps/web/process/supplier-agent/get-kp-data/get-sums.ts +++ b/apps/web/process/supplier-agent/get-kp-data/get-sums.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import initializeApollo from '@/apollo/client'; import type * as CRMTypes from '@/graphql/crm.types'; import { gql } from '@apollo/client'; diff --git a/apps/web/process/supplier-agent/lib/create-reactions.ts b/apps/web/process/supplier-agent/lib/create-reactions.ts index dfd54c0..a0a38ed 100644 --- a/apps/web/process/supplier-agent/lib/create-reactions.ts +++ b/apps/web/process/supplier-agent/lib/create-reactions.ts @@ -1,12 +1,10 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import type { AgentsFields, AgentsRewardConditionsFields, AgentsSumFields } from './types'; import * as CRMTypes from '@/graphql/crm.types'; import type RootStore from '@/stores/root'; -import ValidationHelper from '@/stores/validation/helper'; import type { ApolloClient } from '@apollo/client'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; -import { autorun, reaction } from 'mobx'; +import { reaction } from 'mobx'; import { normalizeOptions } from 'tools/entity'; import { makeDisposable } from 'tools/mobx'; @@ -37,7 +35,7 @@ export function fillAgentRewardReaction( query: CRMTypes.GetRewardConditionsDocument, variables: { agentid, - currentDate: dayjs().toISOString(), + currentDate: dayjs().utc(false).format('YYYY-MM-DD'), }, }); @@ -104,108 +102,3 @@ export function fillAgentRewardSummReaction( } ); } - -export function validateAgentRewardSumm( - store: RootStore, - apolloClient: ApolloClient, - agentParams: { - rewardConditionField: AgentsRewardConditionsFields; - rewardSummField: AgentsSumFields; - } -) { - const { $calculation } = store; - const { rewardConditionField, rewardSummField } = agentParams; - - const validationHelper = new ValidationHelper(); - - reaction( - () => $calculation.element(rewardSummField).getValue(), - async (rewardSumm) => { - const conditionId = $calculation.element(rewardConditionField).getValue(); - if (!conditionId) { - validationHelper.removeErrors(); - - return; - } - - const { - data: { evo_reward_condition }, - } = await apolloClient.query< - CRMTypes.GetRewardConditionQuery, - CRMTypes.GetRewardConditionQueryVariables - >({ - query: CRMTypes.GetRewardConditionDocument, - variables: { - conditionId, - }, - }); - - if (!evo_reward_condition) { - validationHelper.removeErrors(); - - return; - } - - if (evo_reward_condition.evo_reward_summ) { - $calculation.element(rewardSummField).validate({ - helper: validationHelper, - invalid: rewardSumm > evo_reward_condition?.evo_reward_summ, - message: 'Вознаграждение указано больше условия по агентскому договору!', - }); - } - - if ( - evo_reward_condition?.evo_reduce_reward !== null && - evo_reward_condition.evo_reward_summ - ) { - $calculation.element(rewardSummField).validate({ - helper: validationHelper, - invalid: - evo_reward_condition.evo_reduce_reward === false && - rewardSumm < evo_reward_condition.evo_reward_summ, - message: 'Вознаграждение указано меньше условия по агентскому договору!', - }); - } - - if (evo_reward_condition?.evo_min_reward_summ !== null) { - $calculation.element(rewardSummField).validate({ - helper: validationHelper, - invalid: rewardSumm < evo_reward_condition?.evo_min_reward_summ, - message: 'Вознаграждение указано меньше условия по агентскому договору!', - }); - } - } - ); - - autorun(() => { - const rewardSumm = $calculation.element(rewardSummField).getValue(); - const rewardConditionOptions = $calculation.$options.getOptions(rewardConditionField); - - const conditionIds = rewardConditionOptions.map((x) => x.value); - const requests = conditionIds.map(async (conditionId) => { - const { - data: { evo_reward_condition }, - } = await apolloClient.query< - CRMTypes.GetRewardConditionQuery, - CRMTypes.GetRewardConditionQueryVariables - >({ - query: CRMTypes.GetRewardConditionDocument, - variables: { - conditionId, - }, - }); - - return evo_reward_condition; - }); - - Promise.all(requests).then((results) => { - const required_reward = results.some( - (x) => x?.evo_agency_agreementidData?.evo_required_reward === true - ); - $calculation.element(rewardSummField).validate({ - invalid: rewardSumm === 0 && required_reward, - message: 'Согласно агентскому договору обязательна выплата АВ. Заложите АВ в расчет', - }); - }); - }); -} diff --git a/apps/web/process/supplier-agent/reactions/agents.ts b/apps/web/process/supplier-agent/reactions/agents.ts index 000750d..866de94 100644 --- a/apps/web/process/supplier-agent/reactions/agents.ts +++ b/apps/web/process/supplier-agent/reactions/agents.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable sonarjs/no-identical-functions */ import * as createReactions from '../lib/create-reactions'; import * as fillAgentsFromLead from '../lib/fill-agents-from-lead'; @@ -6,12 +5,11 @@ import * as CRMTypes from '@/graphql/crm.types'; import type { ProcessContext } from '@/process/types'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; -import { autorun, reaction } from 'mobx'; +import { reaction } from 'mobx'; import { makeDisposable } from 'tools/mobx'; const { fillIndAgent, fillCalcBroker, fillCalcDoubleAgent, fillFinDepartment } = fillAgentsFromLead; -const { fillAgentRewardReaction, fillAgentRewardSummReaction, validateAgentRewardSumm } = - createReactions; +const { fillAgentRewardReaction, fillAgentRewardSummReaction } = createReactions; dayjs.extend(utc); @@ -521,165 +519,3 @@ export function common({ store, apolloClient }: ProcessContext) { ); } } - -export function validation({ store, apolloClient }: ProcessContext) { - const { $calculation } = store; - - validateAgentRewardSumm(store, apolloClient, { - rewardConditionField: 'selectIndAgentRewardCondition', - rewardSummField: 'tbxIndAgentRewardSumm', - }); - - validateAgentRewardSumm(store, apolloClient, { - rewardConditionField: 'selectCalcDoubleAgentRewardCondition', - rewardSummField: 'tbxCalcDoubleAgentRewardSumm', - }); - - validateAgentRewardSumm(store, apolloClient, { - rewardConditionField: 'selectCalcBrokerRewardCondition', - rewardSummField: 'tbxCalcBrokerRewardSum', - }); - - validateAgentRewardSumm(store, apolloClient, { - rewardConditionField: 'selectFinDepartmentRewardCondtion', - rewardSummField: 'tbxFinDepartmentRewardSumm', - }); - - /** - * Добавить валидацию на кнопку Рассчитать: - * если tbxDealerRewardSumm > 0 и - * если selectDealerPerson = selectDealerBroker и tbxDealerBrokerRewardSumm > 0, то ругаться на selectDealerPerson - * если selectDealerPerson = selectIndAgent и tbxIndAgentRewardSumm > 0, то ругаться на selectDealerPerson - * если selectDealerPerson = selectCalcDoubleAgent и tbxCalcDoubleAgentRewardSumm > 0, то ругаться на selectDealerPerson - * если selectDealerPerson = selectCalcBroker tbxCalcBrokerRewardSum > 0, то ругаться на selectDealerPerson - * если selectDealerPerson = selectFinDepartment и tbxFinDepartmentRewardSumm > 0, то ругаться на selectDealerPerson - * 2.если tbxDealerBrokerRewardSumm > 0 и - * - * если selectDealerBroker = selectDealerPerson и tbxDealerRewardSumm > 0, то ругаться на selectDealerBroker - * если selectDealerBroker = selectIndAgent и tbxIndAgentRewardSumm > 0, то ругаться на selectDealerBroker - * если selectDealerBroker = selectCalcDoubleAgent и tbxCalcDoubleAgentRewardSumm > 0, то ругаться на selectDealerBroker - * если selectDealerBroker = selectCalcBroker tbxCalcBrokerRewardSum > 0, то ругаться на selectDealerBroker - * если selectDealerBroker = selectFinDepartment и tbxFinDepartmentRewardSumm > 0, то ругаться на selectDealerBroker - * 3. если tbxIndAgentRewardSumm > 0 и - * - * если selectIndAgent = selectDealerPerson и tbxDealerRewardSumm > 0, то ругаться на selectIndAgent - * если selectIndAgent = selectDealerBroker и tbxDealerBrokerRewardSumm > 0, то ругаться на selectIndAgent - * если selectIndAgent = selectCalcDoubleAgent и tbxCalcDoubleAgentRewardSumm > 0, то ругаться на selectIndAgent - * если selectIndAgent = selectCalcBroker tbxCalcBrokerRewardSum > 0, то ругаться на selectIndAgent - * если selectIndAgent = selectFinDepartment и tbxFinDepartmentRewardSumm > 0, то ругаться на selectIndAgent - * 4. если tbxCalcDoubleAgentRewardSumm > 0 и - * - * если selectCalcDoubleAgent = selectDealerPerson и tbxDealerRewardSumm > 0, то ругаться на selectCalcDoubleAgent - * если selectCalcDoubleAgent = selectDealerBroker и tbxDealerBrokerRewardSumm > 0, то ругаться на selectCalcDoubleAgent - * если selectCalcDoubleAgent = sselectIndAgent и tbxIndAgentRewardSumm > 0, то ругаться на selectCalcDoubleAgent - * если selectCalcDoubleAgent = selectCalcBroker tbxCalcBrokerRewardSum > 0, то ругаться на selectCalcDoubleAgent - * если selectCalcDoubleAgent = selectFinDepartment и tbxFinDepartmentRewardSumm > 0, то ругаться на selectCalcDoubleAgent - * 5. если tbxCalcBrokerRewardSum > 0 и - * - * если selectCalcBroker = selectDealerPerson и tbxDealerRewardSumm > 0, то ругаться на selectCalcBroker - * если selectCalcBroker = selectDealerBroker и tbxDealerBrokerRewardSumm > 0, то ругаться на selectCalcBroker - * если selectCalcBroker = sselectIndAgent и tbxIndAgentRewardSumm > 0, то ругаться на selectCalcBroker - * если selectCalcBroker = selectCalcDoubleAgent и tbxCalcDoubleAgentRewardSumm > 0, то ругаться на selectCalcBroker - * если selectCalcBroker = selectFinDepartment и tbxFinDepartmentRewardSumm > 0, то ругаться на selectCalcBroker - * 6. если tbxFinDepartmentRewardSumm > 0 и - * - * если selectFinDepartment = selectDealerPerson и tbxDealerRewardSumm > 0, то ругаться на selectFinDepartment - * если selectFinDepartment = selectDealerBroker и tbxDealerBrokerRewardSumm > 0, то ругаться на selectFinDepartment - * если selectFinDepartment = sselectIndAgent и tbxIndAgentRewardSumm > 0, то ругаться на selectFinDepartment - * если selectFinDepartment = selectCalcDoubleAgent и tbxCalcDoubleAgentRewardSumm > 0, то ругаться на selectFinDepartment - * если selectFinDepartment = selectCalcBroker tbxCalcBrokerRewardSum > 0, то ругаться на selectFinDepartment - */ - - // eslint-disable-next-line complexity, sonarjs/cognitive-complexity - autorun(() => { - const dealerRewardSumm = $calculation.element('tbxDealerRewardSumm').getValue(); - const dealerBrokerRewardSumm = $calculation.element('tbxDealerBrokerRewardSumm').getValue(); - const indAgentRewardSumm = $calculation.element('tbxIndAgentRewardSumm').getValue(); - const calcDoubleAgentRewardSumm = $calculation - .element('tbxCalcDoubleAgentRewardSumm') - .getValue(); - const calcBrokerRewardSum = $calculation.element('tbxCalcBrokerRewardSum').getValue(); - const finDepartmentRewardSumm = $calculation.element('tbxFinDepartmentRewardSumm').getValue(); - - const dealerPerson = $calculation.element('selectDealerPerson').getValue(); - const dealerBroker = $calculation.element('selectDealerBroker').getValue(); - const indAgent = $calculation.element('selectIndAgent').getValue(); - const calcDoubleAgent = $calculation.element('selectCalcDoubleAgent').getValue(); - const calcBroker = $calculation.element('selectCalcBroker').getValue(); - const calcFinDepartment = $calculation.element('selectCalcFinDepartment').getValue(); - - const message = 'Вы закладываете вознаграждение одному и тому же агенту дважды'; - - $calculation.element('selectDealerPerson').validate({ - invalid: - dealerRewardSumm > 0 && - Boolean(dealerPerson) && - ((dealerPerson === dealerBroker && dealerBrokerRewardSumm > 0) || - (dealerPerson === indAgent && indAgentRewardSumm > 0) || - (dealerPerson === calcDoubleAgent && calcDoubleAgentRewardSumm > 0) || - (dealerPerson === calcBroker && calcBrokerRewardSum > 0) || - (dealerPerson === calcFinDepartment && finDepartmentRewardSumm > 0)), - message, - }); - - $calculation.element('selectDealerBroker').validate({ - invalid: - dealerBrokerRewardSumm > 0 && - Boolean(dealerBroker) && - ((dealerBroker === dealerPerson && dealerRewardSumm > 0) || - (dealerBroker === indAgent && indAgentRewardSumm > 0) || - (dealerBroker === calcDoubleAgent && calcDoubleAgentRewardSumm > 0) || - (dealerBroker === calcBroker && calcBrokerRewardSum > 0) || - (dealerBroker === calcFinDepartment && finDepartmentRewardSumm > 0)), - message, - }); - - $calculation.element('selectIndAgent').validate({ - invalid: - indAgentRewardSumm > 0 && - Boolean(indAgent) && - ((indAgent === dealerPerson && dealerRewardSumm > 0) || - (indAgent === dealerBroker && dealerBrokerRewardSumm > 0) || - (indAgent === calcDoubleAgent && calcDoubleAgentRewardSumm > 0) || - (indAgent === calcBroker && calcBrokerRewardSum > 0) || - (indAgent === calcFinDepartment && finDepartmentRewardSumm > 0)), - message, - }); - - $calculation.element('selectCalcDoubleAgent').validate({ - invalid: - calcDoubleAgentRewardSumm > 0 && - Boolean(calcDoubleAgent) && - ((calcDoubleAgent === dealerPerson && dealerRewardSumm > 0) || - (calcDoubleAgent === dealerBroker && dealerBrokerRewardSumm > 0) || - (calcDoubleAgent === indAgent && indAgentRewardSumm > 0) || - (calcDoubleAgent === calcBroker && calcBrokerRewardSum > 0) || - (calcDoubleAgent === calcFinDepartment && finDepartmentRewardSumm > 0)), - message, - }); - - $calculation.element('selectCalcBroker').validate({ - invalid: - calcBrokerRewardSum > 0 && - Boolean(calcBroker) && - ((calcBroker === dealerPerson && dealerRewardSumm > 0) || - (calcBroker === dealerBroker && dealerBrokerRewardSumm > 0) || - (calcBroker === indAgent && indAgentRewardSumm > 0) || - (calcBroker === calcDoubleAgent && calcDoubleAgentRewardSumm > 0) || - (calcBroker === calcFinDepartment && finDepartmentRewardSumm > 0)), - message, - }); - - $calculation.element('selectCalcFinDepartment').validate({ - invalid: - finDepartmentRewardSumm > 0 && - Boolean(calcFinDepartment) && - ((calcFinDepartment === dealerPerson && dealerRewardSumm > 0) || - (calcFinDepartment === dealerBroker && dealerBrokerRewardSumm > 0) || - (calcFinDepartment === indAgent && indAgentRewardSumm > 0) || - (calcFinDepartment === calcDoubleAgent && calcDoubleAgentRewardSumm > 0) || - (calcFinDepartment === calcBroker && calcBrokerRewardSum > 0)), - message, - }); - }); -} diff --git a/apps/web/process/supplier-agent/reactions/index.ts b/apps/web/process/supplier-agent/reactions/index.ts index 52e9725..9a46f6f 100644 --- a/apps/web/process/supplier-agent/reactions/index.ts +++ b/apps/web/process/supplier-agent/reactions/index.ts @@ -9,9 +9,6 @@ function common(context: ProcessContext) { supplier.common(context); } -function validation(context: ProcessContext) { - agents.validation(context); - supplier.validation(context); -} +export { common }; -export { common, validation }; +export { default as validation } from './validation'; diff --git a/apps/web/process/supplier-agent/reactions/leaseback.ts b/apps/web/process/supplier-agent/reactions/leaseback.ts index ce8ff98..0340a81 100644 --- a/apps/web/process/supplier-agent/reactions/leaseback.ts +++ b/apps/web/process/supplier-agent/reactions/leaseback.ts @@ -1,6 +1,6 @@ import * as CRMTypes from '@/graphql/crm.types'; import type { ProcessContext } from '@/process/types'; -import { autorun, reaction } from 'mobx'; +import { reaction } from 'mobx'; export function common({ store, apolloClient }: ProcessContext) { const { $calculation, $tables } = store; @@ -73,37 +73,4 @@ export function common({ store, apolloClient }: ProcessContext) { } } ); - - /** - * В валидацию на кнопку Рассчитать внести изменение: - * 1) поле selectDealerPerson убрать из списка обязательных для расчета полей - * 2) добавить валидацию на поле selectDealerPerson : - * Если в поле selectDealer указан account, у которого evo_return_leasing_dealer = False (или null) - * и поле selectDealerPerson = null, то выводить ошибку и поле selectDealerPerson обводить красной рамкой, - * иначе все ок - */ - - autorun(async () => { - const dealerId = $calculation.element('selectDealer').getValue(); - const dealerPersonId = $calculation.element('selectDealerPerson').getValue(); - - let returnLeasing: boolean | null | undefined; - - if (dealerId) { - const { - data: { dealer }, - } = await apolloClient.query({ - query: CRMTypes.GetDealerDocument, - variables: { - dealerId, - }, - }); - returnLeasing = dealer?.evo_return_leasing_dealer; - } - - $calculation.element('selectDealerPerson').validate({ - invalid: Boolean(dealerId) && !dealerPersonId && !returnLeasing, - message: 'Не заполнено поле', - }); - }); } diff --git a/apps/web/process/supplier-agent/reactions/supplier.ts b/apps/web/process/supplier-agent/reactions/supplier.ts index bbb50f7..1709be1 100644 --- a/apps/web/process/supplier-agent/reactions/supplier.ts +++ b/apps/web/process/supplier-agent/reactions/supplier.ts @@ -157,15 +157,3 @@ export function common({ store, apolloClient }: ProcessContext) { } ); } - -export function validation({ store, apolloClient }: ProcessContext) { - createReactions.validateAgentRewardSumm(store, apolloClient, { - rewardConditionField: 'selectDealerRewardCondition', - rewardSummField: 'tbxDealerRewardSumm', - }); - - createReactions.validateAgentRewardSumm(store, apolloClient, { - rewardConditionField: 'selectDealerBrokerRewardCondition', - rewardSummField: 'tbxDealerBrokerRewardSumm', - }); -} diff --git a/apps/web/process/supplier-agent/reactions/validation.ts b/apps/web/process/supplier-agent/reactions/validation.ts new file mode 100644 index 0000000..234660c --- /dev/null +++ b/apps/web/process/supplier-agent/reactions/validation.ts @@ -0,0 +1,70 @@ +import { createValidationSchema } from '../validation'; +import type { Elements } from '@/Components/Calculation/config/map/values'; +import type { ProcessContext } from '@/process/types'; +import ValidationHelper from '@/stores/validation/helper'; +import { reaction } from 'mobx'; +import { uid } from 'radash'; + +const key = uid(7); + +export default function reactions(context: ProcessContext) { + const { store } = context; + const { $calculation } = store; + const validationSchema = createValidationSchema(context); + + const helper = new ValidationHelper(); + reaction( + () => { + const values = $calculation.$values.getValues([ + 'calcBrokerRewardCondition', + 'calcBrokerRewardSum', + 'calcDoubleAgentRewardCondition', + 'calcDoubleAgentRewardSumm', + 'dealer', + 'dealerBroker', + 'calcFinDepartment', + 'dealerBrokerRewardCondition', + 'dealerBrokerRewardSumm', + 'dealerPerson', + 'dealerRewardCondition', + 'dealerRewardSumm', + 'finDepartmentRewardCondtion', + 'finDepartmentRewardSumm', + 'indAgent', + 'indAgentRewardCondition', + 'indAgentRewardSumm', + 'calcDoubleAgent', + 'calcBroker', + ]); + + const options = ( + [ + 'selectCalcBrokerRewardCondition', + 'selectCalcDoubleAgentRewardCondition', + 'selectDealerBrokerRewardCondition', + 'selectDealerRewardCondition', + 'selectFinDepartmentRewardCondtion', + 'selectIndAgentRewardCondition', + ] as Elements[] + ).map((elementName) => $calculation.element(elementName).getOptions()); + + return { options, values }; + }, + async ({ values }) => { + helper.removeErrors(); + const validationResult = await validationSchema.safeParseAsync(values); + + if (!validationResult.success) { + validationResult.error.errors.forEach(({ path, message }) => { + (path as Elements[]).forEach((elementName) => { + const removeError = $calculation.element(elementName).setError({ key, message }); + if (removeError) helper.add(removeError); + }); + }); + } + }, + { + delay: 100, + } + ); +} diff --git a/apps/web/process/supplier-agent/validation.ts b/apps/web/process/supplier-agent/validation.ts new file mode 100644 index 0000000..63baed2 --- /dev/null +++ b/apps/web/process/supplier-agent/validation.ts @@ -0,0 +1,386 @@ +/* eslint-disable complexity */ +import type { ValidationContext } from '../types'; +import type { Elements } from '@/Components/Calculation/config/map/values'; +import ValuesSchema from '@/config/schema/values'; +import * as CRMTypes from '@/graphql/crm.types'; +import dayjs from 'dayjs'; +import utc from 'dayjs/plugin/utc'; +import { normalizeOptions } from 'tools'; +import type { RefinementCtx } from 'zod'; +import { z } from 'zod'; + +dayjs.extend(utc); + +function helper({ apolloClient, ctx }: ValidationContext & { ctx: RefinementCtx }) { + return { + async validateRewardSum({ + agentid, + conditionId, + sumFieldName, + sum, + }: { + agentid: string | null; + conditionId: string | null; + sum: number; + sumFieldName: Elements; + }) { + if (agentid) { + const { + data: { evo_reward_conditions }, + } = await apolloClient.query({ + query: CRMTypes.GetRewardConditionsDocument, + variables: { + agentid, + currentDate: dayjs().utc(false).format('YYYY-MM-DD'), + }, + }); + + const requests = normalizeOptions(evo_reward_conditions)?.map(async ({ value }) => { + const { + data: { evo_reward_condition }, + } = await apolloClient.query< + CRMTypes.GetRewardConditionQuery, + CRMTypes.GetRewardConditionQueryVariables + >({ + query: CRMTypes.GetRewardConditionDocument, + variables: { + conditionId: value, + }, + }); + + return evo_reward_condition; + }); + + const requiredReward = (await Promise.all(requests)).some( + (x) => x?.evo_agency_agreementidData?.evo_required_reward === true + ); + + if (sum === 0 && requiredReward) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Согласно агентскому договору обязательна выплата АВ. Заложите АВ в расчет', + path: [sumFieldName], + }); + } + } + + if (conditionId) { + const { + data: { evo_reward_condition }, + } = await apolloClient.query< + CRMTypes.GetRewardConditionQuery, + CRMTypes.GetRewardConditionQueryVariables + >({ + query: CRMTypes.GetRewardConditionDocument, + variables: { + conditionId, + }, + }); + + if (evo_reward_condition?.evo_reward_summ && sum > evo_reward_condition?.evo_reward_summ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Вознаграждение указано больше условия по агентскому договору!', + path: [sumFieldName], + }); + } + + if ( + evo_reward_condition?.evo_reduce_reward === false && + evo_reward_condition?.evo_reward_summ && + sum < evo_reward_condition?.evo_reward_summ + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Вознаграждение указано меньше условия по агентскому договору!', + path: [sumFieldName], + }); + } + + if ( + evo_reward_condition?.evo_min_reward_summ && + sum < evo_reward_condition?.evo_min_reward_summ + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Вознаграждение указано меньше условия по агентскому договору!', + path: [sumFieldName], + }); + } + } + }, + }; +} + +const ERR_DOUBLE_REWARD = 'Вы закладываете вознаграждение одному и тому же агенту дважды'; + +const AgentsSchema = ValuesSchema.pick({ + calcBroker: true, + calcDoubleAgent: true, + calcFinDepartment: true, + dealer: true, + dealerBroker: true, + dealerPerson: true, + indAgent: true, +}); + +const ConditionsSchema = ValuesSchema.pick({ + calcBrokerRewardCondition: true, + calcDoubleAgentRewardCondition: true, + dealerBrokerRewardCondition: true, + dealerRewardCondition: true, + finDepartmentRewardCondtion: true, + indAgentRewardCondition: true, +}); + +const SumsSchema = ValuesSchema.pick({ + calcBrokerRewardSum: true, + calcDoubleAgentRewardSumm: true, + dealerBrokerRewardSumm: true, + dealerRewardSumm: true, + finDepartmentRewardSumm: true, + indAgentRewardSumm: true, +}); + +export function createValidationSchema(context: ValidationContext) { + const { apolloClient } = context; + + return z + .object({}) + .merge(AgentsSchema) + .merge(ConditionsSchema) + .merge(SumsSchema) + .superRefine(async (values, ctx) => { + const { + calcBrokerRewardCondition, + calcBrokerRewardSum, + calcDoubleAgentRewardCondition, + calcDoubleAgentRewardSumm, + dealer: dealerId, + dealerBroker, + calcFinDepartment, + dealerBrokerRewardCondition, + dealerBrokerRewardSumm, + dealerPerson, + dealerRewardCondition, + dealerRewardSumm, + finDepartmentRewardCondtion, + finDepartmentRewardSumm, + indAgent, + indAgentRewardCondition, + indAgentRewardSumm, + calcDoubleAgent, + calcBroker, + } = values; + /** + * Добавить валидацию на кнопку Рассчитать: + * если tbxDealerRewardSumm > 0 и + * если selectDealerPerson = selectDealerBroker и tbxDealerBrokerRewardSumm > 0, то ругаться на selectDealerPerson + * если selectDealerPerson = selectIndAgent и tbxIndAgentRewardSumm > 0, то ругаться на selectDealerPerson + * если selectDealerPerson = selectCalcDoubleAgent и tbxCalcDoubleAgentRewardSumm > 0, то ругаться на selectDealerPerson + * если selectDealerPerson = selectCalcBroker tbxCalcBrokerRewardSum > 0, то ругаться на selectDealerPerson + * если selectDealerPerson = selectFinDepartment и tbxFinDepartmentRewardSumm > 0, то ругаться на selectDealerPerson + * 2.если tbxDealerBrokerRewardSumm > 0 и + * + * если selectDealerBroker = selectDealerPerson и tbxDealerRewardSumm > 0, то ругаться на selectDealerBroker + * если selectDealerBroker = selectIndAgent и tbxIndAgentRewardSumm > 0, то ругаться на selectDealerBroker + * если selectDealerBroker = selectCalcDoubleAgent и tbxCalcDoubleAgentRewardSumm > 0, то ругаться на selectDealerBroker + * если selectDealerBroker = selectCalcBroker tbxCalcBrokerRewardSum > 0, то ругаться на selectDealerBroker + * если selectDealerBroker = selectFinDepartment и tbxFinDepartmentRewardSumm > 0, то ругаться на selectDealerBroker + * 3. если tbxIndAgentRewardSumm > 0 и + * + * если selectIndAgent = selectDealerPerson и tbxDealerRewardSumm > 0, то ругаться на selectIndAgent + * если selectIndAgent = selectDealerBroker и tbxDealerBrokerRewardSumm > 0, то ругаться на selectIndAgent + * если selectIndAgent = selectCalcDoubleAgent и tbxCalcDoubleAgentRewardSumm > 0, то ругаться на selectIndAgent + * если selectIndAgent = selectCalcBroker tbxCalcBrokerRewardSum > 0, то ругаться на selectIndAgent + * если selectIndAgent = selectFinDepartment и tbxFinDepartmentRewardSumm > 0, то ругаться на selectIndAgent + * 4. если tbxCalcDoubleAgentRewardSumm > 0 и + * + * если selectCalcDoubleAgent = selectDealerPerson и tbxDealerRewardSumm > 0, то ругаться на selectCalcDoubleAgent + * если selectCalcDoubleAgent = selectDealerBroker и tbxDealerBrokerRewardSumm > 0, то ругаться на selectCalcDoubleAgent + * если selectCalcDoubleAgent = sselectIndAgent и tbxIndAgentRewardSumm > 0, то ругаться на selectCalcDoubleAgent + * если selectCalcDoubleAgent = selectCalcBroker tbxCalcBrokerRewardSum > 0, то ругаться на selectCalcDoubleAgent + * если selectCalcDoubleAgent = selectFinDepartment и tbxFinDepartmentRewardSumm > 0, то ругаться на selectCalcDoubleAgent + * 5. если tbxCalcBrokerRewardSum > 0 и + * + * если selectCalcBroker = selectDealerPerson и tbxDealerRewardSumm > 0, то ругаться на selectCalcBroker + * если selectCalcBroker = selectDealerBroker и tbxDealerBrokerRewardSumm > 0, то ругаться на selectCalcBroker + * если selectCalcBroker = sselectIndAgent и tbxIndAgentRewardSumm > 0, то ругаться на selectCalcBroker + * если selectCalcBroker = selectCalcDoubleAgent и tbxCalcDoubleAgentRewardSumm > 0, то ругаться на selectCalcBroker + * если selectCalcBroker = selectFinDepartment и tbxFinDepartmentRewardSumm > 0, то ругаться на selectCalcBroker + * 6. если tbxFinDepartmentRewardSumm > 0 и + * + * если selectFinDepartment = selectDealerPerson и tbxDealerRewardSumm > 0, то ругаться на selectFinDepartment + * если selectFinDepartment = selectDealerBroker и tbxDealerBrokerRewardSumm > 0, то ругаться на selectFinDepartment + * если selectFinDepartment = sselectIndAgent и tbxIndAgentRewardSumm > 0, то ругаться на selectFinDepartment + * если selectFinDepartment = selectCalcDoubleAgent и tbxCalcDoubleAgentRewardSumm > 0, то ругаться на selectFinDepartment + * если selectFinDepartment = selectCalcBroker tbxCalcBrokerRewardSum > 0, то ругаться на selectFinDepartment + */ + + if ( + dealerRewardSumm > 0 && + Boolean(dealerPerson) && + ((dealerPerson === dealerBroker && dealerBrokerRewardSumm > 0) || + (dealerPerson === indAgent && indAgentRewardSumm > 0) || + (dealerPerson === calcDoubleAgent && calcDoubleAgentRewardSumm > 0) || + (dealerPerson === calcBroker && calcBrokerRewardSum > 0) || + (dealerPerson === calcFinDepartment && finDepartmentRewardSumm > 0)) + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: ERR_DOUBLE_REWARD, + path: ['selectDealerPerson'], + }); + } + + if ( + dealerBrokerRewardSumm > 0 && + Boolean(dealerBroker) && + ((dealerBroker === dealerPerson && dealerRewardSumm > 0) || + (dealerBroker === indAgent && indAgentRewardSumm > 0) || + (dealerBroker === calcDoubleAgent && calcDoubleAgentRewardSumm > 0) || + (dealerBroker === calcBroker && calcBrokerRewardSum > 0) || + (dealerBroker === calcFinDepartment && finDepartmentRewardSumm > 0)) + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: ERR_DOUBLE_REWARD, + path: ['selectDealerBroker'], + }); + } + + if ( + indAgentRewardSumm > 0 && + Boolean(indAgent) && + ((indAgent === dealerPerson && dealerRewardSumm > 0) || + (indAgent === dealerBroker && dealerBrokerRewardSumm > 0) || + (indAgent === calcDoubleAgent && calcDoubleAgentRewardSumm > 0) || + (indAgent === calcBroker && calcBrokerRewardSum > 0) || + (indAgent === calcFinDepartment && finDepartmentRewardSumm > 0)) + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: ERR_DOUBLE_REWARD, + path: ['selectIndAgent'], + }); + } + + if ( + calcDoubleAgentRewardSumm > 0 && + Boolean(calcDoubleAgent) && + ((calcDoubleAgent === dealerPerson && dealerRewardSumm > 0) || + (calcDoubleAgent === dealerBroker && dealerBrokerRewardSumm > 0) || + (calcDoubleAgent === indAgent && indAgentRewardSumm > 0) || + (calcDoubleAgent === calcBroker && calcBrokerRewardSum > 0) || + (calcDoubleAgent === calcFinDepartment && finDepartmentRewardSumm > 0)) + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: ERR_DOUBLE_REWARD, + path: ['selectCalcDoubleAgent'], + }); + } + + if ( + calcBrokerRewardSum > 0 && + Boolean(calcBroker) && + ((calcBroker === dealerPerson && dealerRewardSumm > 0) || + (calcBroker === dealerBroker && dealerBrokerRewardSumm > 0) || + (calcBroker === indAgent && indAgentRewardSumm > 0) || + (calcBroker === calcDoubleAgent && calcDoubleAgentRewardSumm > 0) || + (calcBroker === calcFinDepartment && finDepartmentRewardSumm > 0)) + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: ERR_DOUBLE_REWARD, + path: ['selectCalcBroker'], + }); + } + + if ( + finDepartmentRewardSumm > 0 && + Boolean(calcFinDepartment) && + ((calcFinDepartment === dealerPerson && dealerRewardSumm > 0) || + (calcFinDepartment === dealerBroker && dealerBrokerRewardSumm > 0) || + (calcFinDepartment === indAgent && indAgentRewardSumm > 0) || + (calcFinDepartment === calcDoubleAgent && calcDoubleAgentRewardSumm > 0) || + (calcFinDepartment === calcBroker && calcBrokerRewardSum > 0)) + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: ERR_DOUBLE_REWARD, + path: ['selectCalcFinDepartment'], + }); + } + + /** + * В валидацию на кнопку Рассчитать внести изменение: + * 1) поле selectDealerPerson убрать из списка обязательных для расчета полей + * 2) добавить валидацию на поле selectDealerPerson : + * Если в поле selectDealer указан account, у которого evo_return_leasing_dealer = False (или null) + * и поле selectDealerPerson = null, то выводить ошибку и поле selectDealerPerson обводить красной рамкой, + * иначе все ок + */ + if (dealerId) { + const { + data: { dealer }, + } = await apolloClient.query({ + query: CRMTypes.GetDealerDocument, + variables: { + dealerId, + }, + }); + + if (!dealerPerson && !dealer?.evo_return_leasing_dealer) + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Не заполнено поле', + path: ['selectDealerPerson'], + }); + } + + const { validateRewardSum } = helper({ ...context, ctx }); + + await validateRewardSum({ + agentid: dealerPerson, + conditionId: dealerRewardCondition, + sum: dealerRewardSumm, + sumFieldName: 'tbxDealerRewardSumm', + }); + + await validateRewardSum({ + agentid: dealerBroker, + conditionId: dealerBrokerRewardCondition, + sum: dealerBrokerRewardSumm, + sumFieldName: 'tbxDealerBrokerRewardSumm', + }); + + await validateRewardSum({ + agentid: indAgent, + conditionId: indAgentRewardCondition, + sum: indAgentRewardSumm, + sumFieldName: 'tbxIndAgentRewardSumm', + }); + + await validateRewardSum({ + agentid: calcDoubleAgent, + conditionId: calcDoubleAgentRewardCondition, + sum: calcDoubleAgentRewardSumm, + sumFieldName: 'tbxCalcDoubleAgentRewardSumm', + }); + + await validateRewardSum({ + agentid: calcBroker, + conditionId: calcBrokerRewardCondition, + sum: calcBrokerRewardSum, + sumFieldName: 'tbxCalcBrokerRewardSum', + }); + + await validateRewardSum({ + agentid: calcFinDepartment, + conditionId: finDepartmentRewardCondtion, + sum: finDepartmentRewardSumm, + sumFieldName: 'tbxFinDepartmentRewardSumm', + }); + }); +} diff --git a/apps/web/process/types.ts b/apps/web/process/types.ts index 6ec8db7..da05177 100644 --- a/apps/web/process/types.ts +++ b/apps/web/process/types.ts @@ -13,3 +13,5 @@ export type ProcessContext = { export type Process = { reactions: Record void>; }; + +export type ValidationContext = Omit; diff --git a/apps/web/process/used-pl/reactions.ts b/apps/web/process/used-pl/reactions.ts index 50c88da..3d38931 100644 --- a/apps/web/process/used-pl/reactions.ts +++ b/apps/web/process/used-pl/reactions.ts @@ -1,8 +1,10 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import type { ProcessContext } from '../types'; +import { createValidationSchema } from './validation'; +import type { Elements } from '@/Components/Calculation/config/map/values'; import * as CRMTypes from '@/graphql/crm.types'; import ValidationHelper from '@/stores/validation/helper'; import { reaction } from 'mobx'; +import { uid } from 'radash'; export function common({ store, apolloClient }: ProcessContext) { const { $calculation } = store; @@ -150,41 +152,6 @@ export function common({ store, apolloClient }: ProcessContext) { } ); - /** - * Добавить реакцию на изменение Типа ПЛ selectLeaseObjectType , ПЛ БУ cbxLeaseObjectUsed и Моточасы tbxEngineHours: - * Если ПЛ БУ cbxLeaseObjectUsed = True и Тип ПЛ selectLeaseObjectType = Спецтехника (id=9) и Моточасы = 0, - * то поле Моточасы tbxEngineHours должно обводиться красной рамкой и выводиться сообщение - * "Укажите Моточасы, иначе красная рамка снимается. - * При красной рамке в данном поле нельзя осуществить расчет графика. - */ - { - const validationHelper = new ValidationHelper(); - - reaction( - () => $calculation.$values.getValues(['leaseObjectUsed', 'engineHours', 'leaseObjectType']), - async ({ leaseObjectType: leaseObjectTypeId, leaseObjectUsed, engineHours }) => { - if (!leaseObjectTypeId) { - validationHelper.removeErrors(); - - return; - } - - const { - data: { evo_leasingobject_type }, - } = await apolloClient.query({ - query: CRMTypes.GetLeaseObjectTypeDocument, - variables: { leaseObjectTypeId }, - }); - - $calculation.element('tbxEngineHours').validate({ - helper: validationHelper, - invalid: leaseObjectUsed && evo_leasingobject_type?.evo_id === '9' && !engineHours, - message: 'Не заполнено поле', - }); - } - ); - } - reaction( () => $calculation.element('cbxLeaseObjectUsed').getValue(), (leaseObjectUsed) => { @@ -196,16 +163,6 @@ export function common({ store, apolloClient }: ProcessContext) { } ); - reaction( - () => $calculation.$values.getValues(['mileage', 'leaseObjectUsed']), - ({ mileage, leaseObjectUsed }) => { - $calculation.element('tbxMileage').validate({ - invalid: leaseObjectUsed && !mileage, - message: 'Не заполнено поле', - }); - } - ); - reaction( () => $calculation.element('cbxLeaseObjectUsed').getValue(), (leaseObjectUsed) => { @@ -273,38 +230,6 @@ export function common({ store, apolloClient }: ProcessContext) { } ); - /** - * Если "Категория" содержит данные, то должны быть доступными для набора только арабские цифры и буквы латинского алфавита за исключением I, O, Q, так как они сходны по начертанию с цифрами 1, 0, 9. Можно использовать регулярное выражение: "^[A-HJ-NPR-Za-hj-npr-z0-9]{17}$". - * Иначе (если Категория = пусто) то требуется аналогичная первому условию маска, но без проверки 17ти символов (допускать и больше и меньше символов, мб так: "^[A-HJ-NPR-Za-hj-npr-z0-9]{99}$". - * Вот так: /^[A-HJ-NPR-Za-hj-npr-z0-9]+$/ - */ - { - const vinRegex = /^[\dA-HJ-NPR-Za-hj-npr-z]+$/u; - const validationHelper = new ValidationHelper(); - - reaction( - () => $calculation.$values.getValues(['vin', 'leaseObjectCategory', 'leaseObjectUsed']), - ({ vin, leaseObjectCategory }) => { - if (!vin) { - validationHelper.removeErrors(); - - return; - } - - let invalid = vinRegex.test(vin) === false; - if (leaseObjectCategory && vin?.length !== 17) { - invalid = true; - } - - $calculation.element('tbxVIN').validate({ - helper: validationHelper, - invalid, - message: 'Неверно заполнено поле', - }); - } - ); - } - reaction( () => $calculation.element('cbxLeaseObjectUsed').getValue(), (leaseObjectUsed) => { @@ -316,3 +241,40 @@ export function common({ store, apolloClient }: ProcessContext) { } ); } + +const key = uid(7); + +export function validation(context: ProcessContext) { + const { store } = context; + const { $calculation } = store; + const validationSchema = createValidationSchema(context); + + const helper = new ValidationHelper(); + reaction( + () => + $calculation.$values.getValues([ + 'engineHours', + 'leaseObjectCategory', + 'leaseObjectType', + 'leaseObjectUsed', + 'mileage', + 'vin', + ]), + async (values) => { + helper.removeErrors(); + const validationResult = await validationSchema.safeParseAsync(values); + + if (!validationResult.success) { + validationResult.error.errors.forEach(({ path, message }) => { + (path as Elements[]).forEach((elementName) => { + const removeError = $calculation.element(elementName).setError({ key, message }); + if (removeError) helper.add(removeError); + }); + }); + } + }, + { + delay: 100, + } + ); +} diff --git a/apps/web/process/used-pl/validation.ts b/apps/web/process/used-pl/validation.ts new file mode 100644 index 0000000..a926499 --- /dev/null +++ b/apps/web/process/used-pl/validation.ts @@ -0,0 +1,80 @@ +import type { ValidationContext } from '../types'; +import ValuesSchema from '@/config/schema/values'; +import * as CRMTypes from '@/graphql/crm.types'; +import { z } from 'zod'; + +const vinRegex = /^[\dA-HJ-NPR-Za-hj-npr-z]+$/u; + +export function createValidationSchema({ apolloClient }: ValidationContext) { + return ValuesSchema.pick({ + engineHours: true, + leaseObjectCategory: true, + leaseObjectType: true, + leaseObjectUsed: true, + mileage: true, + vin: true, + }).superRefine( + async ( + { + engineHours, + leaseObjectCategory, + leaseObjectType: leaseObjectTypeId, + leaseObjectUsed, + mileage, + vin, + }, + ctx + ) => { + /** + * Добавить реакцию на изменение Типа ПЛ selectLeaseObjectType , ПЛ БУ cbxLeaseObjectUsed и Моточасы tbxEngineHours: + * Если ПЛ БУ cbxLeaseObjectUsed = True и Тип ПЛ selectLeaseObjectType = Спецтехника (id=9) и Моточасы = 0, + * то поле Моточасы tbxEngineHours должно обводиться красной рамкой и выводиться сообщение + * "Укажите Моточасы, иначе красная рамка снимается. + * При красной рамке в данном поле нельзя осуществить расчет графика. + */ + if (leaseObjectTypeId) { + const { + data: { evo_leasingobject_type }, + } = await apolloClient.query({ + query: CRMTypes.GetLeaseObjectTypeDocument, + variables: { leaseObjectTypeId }, + }); + if (leaseObjectUsed && evo_leasingobject_type?.evo_id === '9' && !engineHours) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Не заполнено поле', + path: ['tbxEngineHours'], + }); + } + } + + if (leaseObjectUsed && !mileage) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Не заполнено поле', + path: ['tbxMileage'], + }); + } + + /** + * Если "Категория" содержит данные, то должны быть доступными для набора только арабские цифры и буквы латинского алфавита за исключением I, O, Q, так как они сходны по начертанию с цифрами 1, 0, 9. Можно использовать регулярное выражение: "^[A-HJ-NPR-Za-hj-npr-z0-9]{17}$". + * Иначе (если Категория = пусто) то требуется аналогичная первому условию маска, но без проверки 17ти символов (допускать и больше и меньше символов, мб так: "^[A-HJ-NPR-Za-hj-npr-z0-9]{99}$". + * Вот так: /^[A-HJ-NPR-Za-hj-npr-z0-9]+$/ + */ + if (vin) { + let invalid = vinRegex.test(vin) === false; + if (leaseObjectCategory && vin?.length !== 17) { + invalid = true; + } + + if (invalid) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Неверно заполнено поле', + path: ['tbxVIN'], + }); + } + } + } + ); +} diff --git a/apps/web/stores/calculation/index.ts b/apps/web/stores/calculation/index.ts index 42816cb..ab662c5 100644 --- a/apps/web/stores/calculation/index.ts +++ b/apps/web/stores/calculation/index.ts @@ -1,4 +1,4 @@ -import type { RemoveError, ValidationParams } from '../validation/types'; +import type { ValidationParams } from '../validation/types'; import OptionsStore from './options'; import StatusStore from './statuses'; import ValuesStore from './values'; @@ -56,6 +56,10 @@ export default class CalculationStore { return this.$values.getValue(valueName) as Values.ElementsTypes[E]; }, + removeError: (params: Pick) => { + this.$validation[elementName]?.removeError(params); + }, + reset: () => { const valueName = getValueName(elementName); this.$values.resetValue(valueName); @@ -80,6 +84,12 @@ export default class CalculationStore { return this.element(elementName); }, + setError: (params: ValidationParams) => { + if (!this.$validation[elementName]) this.createElementValidation(elementName); + + return this.$validation[elementName]?.setError(params); + }, + setOptions: (options: Array>) => { this.$options.setOptions(elementName, options); @@ -98,20 +108,5 @@ export default class CalculationStore { return this.element(elementName); }, - - validate: ({ invalid, message, silent, helper }: ValidationParams) => { - if (!this.$validation[elementName]) this.createElementValidation(elementName); - - let removeError: RemoveError | undefined; - - if (invalid) { - removeError = this.$validation[elementName]?.addError(message, silent); - if (helper && removeError) helper.add(removeError); - } else { - this.$validation[elementName]?.removeError(message); - } - - return removeError; - }, }); } diff --git a/apps/web/stores/calculation/statuses/index.ts b/apps/web/stores/calculation/statuses/index.ts index a4cd277..faf77f8 100644 --- a/apps/web/stores/calculation/statuses/index.ts +++ b/apps/web/stores/calculation/statuses/index.ts @@ -9,6 +9,7 @@ import type { Status } from 'ui/elements/types'; export default class StatusStore { private root: RootStore; private statuses: CalculationStatuses = defaultStatuses; + private overrided: Partial = {}; constructor(rootStore: RootStore) { makeAutoObservable(this); @@ -20,7 +21,7 @@ export default class StatusStore { }; public getStatus(elementName: ElementsActions | ElementsValues) { - return this.statuses[elementName]; + return this.overrided[elementName] || this.statuses[elementName]; } public setStatus = (elementName: ElementsActions | ElementsValues, status: Status) => { @@ -30,4 +31,12 @@ export default class StatusStore { public resetStatus = (elementName: ElementsActions | ElementsValues) => { this.statuses[elementName] = defaultStatuses[elementName]; }; + + public overrideStatus = (elementName: ElementsActions | ElementsValues, status: Status) => { + this.overrided[elementName] = status; + }; + + public clearOverridedStatus = (elementName: ElementsActions | ElementsValues) => { + this.overrided[elementName] = undefined; + }; } diff --git a/apps/web/stores/calculation/validation/hooks.js b/apps/web/stores/calculation/validation/hooks.js index 9ae1faa..7a8a06e 100644 --- a/apps/web/stores/calculation/validation/hooks.js +++ b/apps/web/stores/calculation/validation/hooks.js @@ -2,9 +2,8 @@ import { useStore } from '@/stores/hooks'; export function useValidation(elementName) { const { $calculation } = useStore(); - const messages = $calculation.$validation[elementName]?.getMessages(); - - if (messages?.length) { + const hasErrors = $calculation.$validation?.[elementName]?.hasErrors; + if (hasErrors) { return { help: 'Некорректные данные', isValid: false, diff --git a/apps/web/stores/calculation/values/index.ts b/apps/web/stores/calculation/values/index.ts index 038427d..0cb1711 100644 --- a/apps/web/stores/calculation/values/index.ts +++ b/apps/web/stores/calculation/values/index.ts @@ -19,8 +19,11 @@ export default class ValuesStore { public getValues = (keys: K[]) => pick(this.values, keys); - public setValues = (values: CalculationValues) => { - this.values = values; + public setValues = (values: Partial) => { + (Object.keys(values) as Array).forEach((valueName) => { + const value = values[valueName]; + if (value) this.setValue(valueName, value); + }); }; public getValue(valueName: V) { diff --git a/apps/web/stores/tables/fingap/index.ts b/apps/web/stores/tables/fingap/index.ts index 9df4da9..82d5f6d 100644 --- a/apps/web/stores/tables/fingap/index.ts +++ b/apps/web/stores/tables/fingap/index.ts @@ -1,5 +1,5 @@ import Validation from '../../validation'; -import type { RemoveError, ValidationParams } from '../../validation/types'; +import type { ValidationParams } from '../../validation/types'; import type * as FinGAP from '@/Components/Calculation/Form/Insurance/FinGAPTable/types'; import type RootStore from '@/stores/root'; import type { IObservableArray } from 'mobx'; @@ -38,17 +38,10 @@ export default class FinGAPTable { .reduce((sum, risk) => sum + risk.premium, 0); } - public validate = ({ invalid, message, helper }: ValidationParams) => { - let removeError: RemoveError | undefined; + public setError = (params: ValidationParams) => this.validation.setError(params); - if (invalid) { - removeError = this.validation?.addError(message); - if (helper && removeError) helper.add(removeError); - } else { - this.validation?.removeError(message); - } - - return removeError; + public removeError = (params: Pick) => { + this.validation.removeError(params); }; public clear = () => { diff --git a/apps/web/stores/tables/insurance/index.ts b/apps/web/stores/tables/insurance/index.ts index b79a33c..8d70370 100644 --- a/apps/web/stores/tables/insurance/index.ts +++ b/apps/web/stores/tables/insurance/index.ts @@ -1,5 +1,5 @@ import Validation from '../../validation'; -import type { RemoveError, ValidationParams } from '../../validation/types'; +import type { ValidationParams } from '../../validation/types'; import type * as Insurance from '@/Components/Calculation/Form/Insurance/InsuranceTable/types'; import * as insuranceTableConfig from '@/config/tables/insurance-table'; import type RootStore from '@/stores/root'; @@ -40,17 +40,10 @@ export default class InsuranceTable { if (initialStatuses) this.statuses = initialStatuses; }; - public validate = ({ invalid, message, helper }: ValidationParams) => { - let removeError: RemoveError | undefined; + public setError = (params: ValidationParams) => this.validation.setError(params); - if (invalid) { - removeError = this.validation?.addError(message); - if (helper && removeError) helper.add(removeError); - } else { - this.validation?.removeError(message); - } - - return removeError; + public removeError = (params: Pick) => { + this.validation.removeError(params); }; public reset = () => { @@ -67,6 +60,39 @@ export default class InsuranceTable { return this.row(key); }, + column: (valueName: V) => ({ + block: () => { + this.row(key).block(valueName); + + return this.row(key).column(valueName); + }, + resetOptions: () => { + this.row(key).resetOptions(valueName); + + return this.row(key).column(valueName); + }, + resetValue: () => { + this.row(key).resetValue(valueName); + + return this.row(key).column(valueName); + }, + setOptions: (options: Insurance.RowOptions[V]) => { + this.row(key).setOptions(valueName, options); + + return this.row(key).column(valueName); + }, + setValue: (value: Insurance.RowValues[V]) => { + this.row(key).setValue(valueName, value); + + return this.row(key).column(valueName); + }, + unblock: () => { + this.row(key).unblock(valueName); + + return this.row(key).column(valueName); + }, + }), + getOptions: (valueName: V) => this.options[key][valueName], getStatus: (valueName: Insurance.Values) => this.statuses[key][valueName], @@ -77,6 +103,12 @@ export default class InsuranceTable { return this.values[rowIndex][valueName]; }, + getValues: () => { + const rowIndex = this.values.findIndex((x) => x.key === key); + + return this.values[rowIndex]; + }, + reset: (valueName: Insurance.Values) => { this.row(key).resetValue(valueName).resetStatus(valueName).resetOptions(valueName); diff --git a/apps/web/stores/tables/payments/index.ts b/apps/web/stores/tables/payments/index.ts index cbe63eb..bddc221 100644 --- a/apps/web/stores/tables/payments/index.ts +++ b/apps/web/stores/tables/payments/index.ts @@ -1,8 +1,8 @@ import Validation from '../../validation'; -import type { RemoveError, ValidationParams } from '../../validation/types'; +import type { ValidationParams } from '../../validation/types'; import type { Row } from './types'; import type RootStore from '@/stores/root'; -import type { IObservableArray } from 'mobx'; +import type { IObservableArray, IObservableValue } from 'mobx'; import { makeAutoObservable, observable, reaction } from 'mobx'; import type { Status } from 'ui/elements/types'; @@ -11,6 +11,7 @@ export default class PaymentsTable { public validation: Validation; public values: IObservableArray; private statuses: IObservableArray; + private overridedStatus: IObservableValue; constructor(rootStore: RootStore) { this.validation = new Validation({ @@ -20,6 +21,7 @@ export default class PaymentsTable { this.values = observable([]); this.statuses = observable([]); + this.overridedStatus = observable.box(undefined); makeAutoObservable(this); this.root = rootStore; @@ -48,13 +50,21 @@ export default class PaymentsTable { }; public getStatus(index: number) { - return this.statuses[index]; + return this.overridedStatus.get() ?? this.statuses[index]; } public setStatus = (index: number, status: Status) => { this.statuses[index] = status; }; + public overrideStatuses = (status: Status) => { + this.overridedStatus.set(status); + }; + + public clearOverridedStatuses = () => { + this.overridedStatus.set(undefined); + }; + public setStatuses = (statuses: Status[]) => { this.statuses.replace(statuses); }; @@ -72,17 +82,10 @@ export default class PaymentsTable { this.setStatuses(statuses); }; - public validate = ({ invalid, message, helper }: ValidationParams) => { - let removeError: RemoveError | undefined; + public setError = (params: ValidationParams) => this.validation.setError(params); - if (invalid) { - removeError = this.validation?.addError(message); - if (helper && removeError) helper.add(removeError); - } else { - this.validation?.removeError(message); - } - - return removeError; + public removeError = (params: Pick) => { + this.validation.removeError(params); }; public reset = () => { diff --git a/apps/web/stores/validation/index.ts b/apps/web/stores/validation/index.ts index e9c86b7..5b9ca5a 100644 --- a/apps/web/stores/validation/index.ts +++ b/apps/web/stores/validation/index.ts @@ -1,32 +1,38 @@ -import type { RemoveError, ValidationConfig } from './types'; +import type { RemoveError, ValidationConfig, ValidationError, ValidationParams } from './types'; import { makeAutoObservable } from 'mobx'; import notification from 'ui/elements/notification'; export default class Validation { private params: ValidationConfig; - private messages: Set; + private errors: Set; constructor(config: ValidationConfig) { this.params = config; - this.messages = new Set(); + this.errors = new Set(); makeAutoObservable(this); } public get hasErrors() { - return this.messages.size > 0; + return this.errors.size > 0; } - public getMessages() { - return [...this.messages]; + public getErrors() { + return [...this.errors]; } - public removeError = (message: string) => { - this.messages.delete(message); - if (this.messages.size === 0) notification.close(this.params.err_key); + public removeError = ({ key }: Pick) => { + const error = [...this.errors].find((x) => x.key === key); + if (error) this.errors.delete(error); + if (this.errors.size === 0) notification.close(this.params.err_key); }; - public addError = (message: string, silent?: boolean) => { - if (!silent && !this.messages.has(message)) { + public setError = ({ key, message, silent }: ValidationParams) => { + const error = [...this.errors].find((x) => x.key === key); + if (error) this.removeError({ key }); + + this.errors.add({ key, message }); + + if (!silent) { notification.error({ description: message, key: this.params.err_key, @@ -34,13 +40,11 @@ export default class Validation { }); } - this.messages.add(message); - - return (() => this.removeError(message)) as RemoveError; + return (() => this.removeError({ key })) as RemoveError; }; public clearErrors = () => { - this.messages.clear(); + this.errors.clear(); notification.close(this.params.err_key); }; } diff --git a/apps/web/stores/validation/types.ts b/apps/web/stores/validation/types.ts index 4c27464..888cd7e 100644 --- a/apps/web/stores/validation/types.ts +++ b/apps/web/stores/validation/types.ts @@ -1,15 +1,10 @@ -import type ValidationHelper from './helper'; - export type ValidationConfig = { err_key: string; err_title: string; }; -export type ValidationParams = { - helper?: ValidationHelper; - invalid: boolean; - message: string; - silent?: boolean; -}; +export type ValidationError = { key: string; message: string }; + +export type ValidationParams = ValidationError & { silent?: boolean }; export type RemoveError = () => void; diff --git a/apps/web/trpc/routers/quote.ts b/apps/web/trpc/routers/quote.ts index 66e093e..69d9c5b 100644 --- a/apps/web/trpc/routers/quote.ts +++ b/apps/web/trpc/routers/quote.ts @@ -3,6 +3,7 @@ import { t } from '../server'; import defaultValues from '@/config/default-values'; import * as insuranceTable from '@/config/tables/insurance-table'; +import * as addProduct from '@/process/add-product'; import * as bonuses from '@/process/bonuses'; import * as configurator from '@/process/configurator'; import * as fingapProcess from '@/process/fingap'; @@ -46,6 +47,7 @@ const quoteRouter = t.router({ gibdd, subsidy, insuranceProcess, + addProduct, ].map(({ getKPData }) => getKPData(input)) ); diff --git a/packages/eslint-config-custom/rules.js b/packages/eslint-config-custom/rules.js index 091a394..ea04884 100644 --- a/packages/eslint-config-custom/rules.js +++ b/packages/eslint-config-custom/rules.js @@ -55,6 +55,7 @@ module.exports = { 'import/no-unassigned-import': 'off', 'import/no-named-as-default-member': 'warn', 'react/jsx-sort-props': 'off', + '@typescript-eslint/naming-convention': 'warn', // Unicorn 'unicorn/no-array-for-each': 'off', @@ -130,6 +131,13 @@ module.exports = { requireReturnForObjectLiteral: false, }, ], + + // Sonar + 'sonarjs/no-duplicate-string': 'warn', + + // Zod + 'zod/require-strict': 'off', + // Turbo 'turbo/no-undeclared-env-vars': 'warn', },