From 096cc8c1e6a05883142c7304f60dcce125319ec0 Mon Sep 17 00:00:00 2001 From: Chika Date: Wed, 12 Jan 2022 15:35:19 +0300 Subject: [PATCH] merge refactor/january-2022 pt.1 --- .graphqlrc.yml | 3 + .vscode/launch.json | 35 +- apollo.config.js | 10 + craco.config.js | 34 +- package.json | 35 +- src/client/App.jsx | 1 - src/client/App.less | 1 - src/client/Containers/Calculation/index.jsx | 44 +- .../Calculation/lib/fetchData/getUser.js | 26 - .../Calculation/lib/fetchData/index.js | 101 - .../lib/fetchData/queries/insuranceQuery.ts | 28 - .../lib/fetchData/queries/optionsQuery.ts | 396 --- .../lib/fetchData/queries/ownerQuery.ts | 51 - .../lib/fetchData/queries/staticDataQuery.ts | 79 - .../lib/fetchData/queries/systemUserQuery.ts | 15 - src/client/Elements/Notification.ts | 2 +- src/client/Layout/index.jsx | 2 +- .../{Layout/routes.jsx => Routes/index.jsx} | 2 +- src/{core/common => client/Routes}/paths.js | 0 src/client/hocs/withStores.jsx | 33 + src/client/hooks/Calculation/useFetch.js | 28 - .../Effects/actions/calculate/prepareData.ts | 2 +- .../Effects/actions/createKP.ts | 185 +- .../CalculationStore/Effects/lib/queries.js | 25 - .../Effects/reactions/gibddReactions.ts | 23 +- .../Effects/reactions/loadKpReaction/index.ts | 114 +- .../reactions/loadKpReaction/mapKpToValues.ts | 10 +- .../reactions/loadKpReaction/optionsQuery.js | 159 -- .../reactions/loadKpReaction/quoteQuery.js | 64 - .../Effects/reactions/requestReactions.ts | 654 +++-- .../CalculationStore/config/initialOptions.ts | 2 +- src/client/stores/CalculationStore/index.ts | 3 +- .../stores/CalculationStore/init/index.ts | 54 + .../stores/CalculationStore/init/requests.ts | 77 + .../stores/CalculationStore/init/variables.ts | 31 + src/client/stores/UserStore/index.js | 12 + src/client/stores/UserStore/lib/user.js | 12 + .../CrmService => graphql}/client.ts | 0 .../evo_addproduct_types_fields.graphql | 15 + .../crm/fragments/evo_regions_fields.graphql | 8 + .../crm/options/getInsuranceOptions.graphql | 14 + .../query/crm/options/getMainOptions.graphql | 265 ++ .../query/crm/options/getOwnerOptions.graphql | 39 + src/core/graphql/query/crm/options/index.js | 5 + .../crm/quote/fragments/quoteFields.graphql | 126 + .../quote/fragments/quoteFieldsLite.graphql | 25 + .../graphql/query/crm/quote/getQuote.graphql | 7 + .../query/crm/quote/getQuotesByLead.graphql | 7 + src/core/graphql/query/crm/quote/index.js | 14 + .../crm/quote/options/getMainOptions.graphql | 124 + .../quote/options/getSecondaryOptions.graphql | 26 + .../quote/options/getSingleOptions.graphql | 10 + .../crm/staticData/getStaticData.graphql | 63 + .../crm/staticData/getSystemUser.graphql | 9 + .../graphql/query/crm/staticData/index.js | 4 + src/core/graphql/schemas/crm.graphql | 2263 +++++++++++++++++ .../{propsMap.ts => common/entitiesProps.ts} | 37 +- src/core/services/CrmService/index.ts | 151 +- src/core/services/CrmService/tools/entity.ts | 67 +- src/core/services/CrmService/types/common.ts | 8 + src/core/services/CrmService/types/request.ts | 4 + src/core/tools/uuid.js | 1 + src/core/types/Calculation/Requests.ts | 34 - src/core/types/Calculation/Responses.ts | 6 - src/core/types/Calculation/Store/filters.ts | 2 +- src/core/types/Calculation/Store/index.ts | 21 +- src/core/types/Calculation/Store/options.ts | 8 - .../types/Calculation/Store/staticData.ts | 6 +- src/core/types/Calculation/Store/tables.ts | 2 +- src/core/types/Entities/crmEntities.ts | 162 +- 70 files changed, 3944 insertions(+), 1942 deletions(-) create mode 100644 .graphqlrc.yml create mode 100644 apollo.config.js delete mode 100644 src/client/App.less delete mode 100644 src/client/Containers/Calculation/lib/fetchData/getUser.js delete mode 100644 src/client/Containers/Calculation/lib/fetchData/index.js delete mode 100644 src/client/Containers/Calculation/lib/fetchData/queries/insuranceQuery.ts delete mode 100644 src/client/Containers/Calculation/lib/fetchData/queries/optionsQuery.ts delete mode 100644 src/client/Containers/Calculation/lib/fetchData/queries/ownerQuery.ts delete mode 100644 src/client/Containers/Calculation/lib/fetchData/queries/staticDataQuery.ts delete mode 100644 src/client/Containers/Calculation/lib/fetchData/queries/systemUserQuery.ts rename src/client/{Layout/routes.jsx => Routes/index.jsx} (94%) rename src/{core/common => client/Routes}/paths.js (100%) create mode 100644 src/client/hocs/withStores.jsx delete mode 100644 src/client/hooks/Calculation/useFetch.js delete mode 100644 src/client/stores/CalculationStore/Effects/lib/queries.js delete mode 100644 src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/optionsQuery.js delete mode 100644 src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/quoteQuery.js create mode 100644 src/client/stores/CalculationStore/init/index.ts create mode 100644 src/client/stores/CalculationStore/init/requests.ts create mode 100644 src/client/stores/CalculationStore/init/variables.ts create mode 100644 src/client/stores/UserStore/lib/user.js rename src/core/{services/CrmService => graphql}/client.ts (100%) create mode 100644 src/core/graphql/query/crm/fragments/evo_addproduct_types_fields.graphql create mode 100644 src/core/graphql/query/crm/fragments/evo_regions_fields.graphql create mode 100644 src/core/graphql/query/crm/options/getInsuranceOptions.graphql create mode 100644 src/core/graphql/query/crm/options/getMainOptions.graphql create mode 100644 src/core/graphql/query/crm/options/getOwnerOptions.graphql create mode 100644 src/core/graphql/query/crm/options/index.js create mode 100644 src/core/graphql/query/crm/quote/fragments/quoteFields.graphql create mode 100644 src/core/graphql/query/crm/quote/fragments/quoteFieldsLite.graphql create mode 100644 src/core/graphql/query/crm/quote/getQuote.graphql create mode 100644 src/core/graphql/query/crm/quote/getQuotesByLead.graphql create mode 100644 src/core/graphql/query/crm/quote/index.js create mode 100644 src/core/graphql/query/crm/quote/options/getMainOptions.graphql create mode 100644 src/core/graphql/query/crm/quote/options/getSecondaryOptions.graphql create mode 100644 src/core/graphql/query/crm/quote/options/getSingleOptions.graphql create mode 100644 src/core/graphql/query/crm/staticData/getStaticData.graphql create mode 100644 src/core/graphql/query/crm/staticData/getSystemUser.graphql create mode 100644 src/core/graphql/query/crm/staticData/index.js create mode 100644 src/core/graphql/schemas/crm.graphql rename src/core/services/CrmService/{propsMap.ts => common/entitiesProps.ts} (77%) create mode 100644 src/core/services/CrmService/types/common.ts create mode 100644 src/core/services/CrmService/types/request.ts create mode 100644 src/core/tools/uuid.js delete mode 100644 src/core/types/Calculation/Store/options.ts diff --git a/.graphqlrc.yml b/.graphqlrc.yml new file mode 100644 index 0000000..eb57a15 --- /dev/null +++ b/.graphqlrc.yml @@ -0,0 +1,3 @@ +schema: + - ./src/core/graphql/schemas/crm.graphql +documents: ./src/**/*.(graphql|gql) diff --git a/.vscode/launch.json b/.vscode/launch.json index 2feae02..2bf7912 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,15 +1,22 @@ { - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "pwa-chrome", - "request": "launch", - "name": "Launch Chrome against localhost", - "url": "http://localhost:80", - "webRoot": "${workspaceFolder}" - } - ] -} \ No newline at end of file + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "pwa-chrome", + "request": "launch", + "name": "Launch Chrome on 80", + "url": "http://localhost:80", + "webRoot": "${workspaceFolder}" + }, + { + "type": "pwa-chrome", + "request": "launch", + "name": "Launch Chrome on 3000", + "url": "http://localhost:3000", + "webRoot": "${workspaceFolder}" + } + ] +} diff --git a/apollo.config.js b/apollo.config.js new file mode 100644 index 0000000..d5776dc --- /dev/null +++ b/apollo.config.js @@ -0,0 +1,10 @@ +module.exports = { + client: { + service: { + name: 'crmgraphql', + url: 'http://localhost/crmgraphql/', + localSchemaFile: 'src/core/graphql/schemas/crm.graphql', + }, + excludes: ['src/core/graphql/schemas/**/*.*'], + }, +}; diff --git a/craco.config.js b/craco.config.js index 49d3f98..71611c8 100644 --- a/craco.config.js +++ b/craco.config.js @@ -1,30 +1,19 @@ -const CracoAntDesignPlugin = require('craco-antd'); const colors = require('./src/client/UIKit/colors'); - -const { ProvidePlugin } = require('webpack'); -const CracoEsbuildPlugin = require('craco-esbuild'); +const CracoLessPlugin = require('craco-less'); module.exports = { - webpack: { - plugins: [ - new ProvidePlugin({ - React: 'react', - }), - ], - }, plugins: [ { - plugin: CracoAntDesignPlugin, + plugin: CracoLessPlugin, options: { - customizeTheme: { - '@primary-color': colors.primary, - }, - babelPluginImportOptions: { - libraryDirectory: 'es', + lessLoaderOptions: { + lessOptions: { + modifyVars: { '@primary-color': colors.primary }, + javascriptEnabled: true, + }, }, }, }, - { plugin: CracoEsbuildPlugin }, ], babel: { plugins: [ @@ -37,6 +26,15 @@ module.exports = { }, }, ], + [ + 'import', + { + libraryName: 'antd', + libraryDirectory: 'lib', + style: true, + }, + 'antd', + ], ['babel-plugin-styled-components'], ], }, diff --git a/package.json b/package.json index de3ac79..e211094 100644 --- a/package.json +++ b/package.json @@ -3,35 +3,31 @@ "private": true, "dependencies": { "@ant-design/icons": "^4.6.2", - "@apollo/client": "^3.3.13", - "@craco/craco": "^6.1.1", - "@testing-library/jest-dom": "^5.11.4", - "@testing-library/react": "^11.1.0", - "@testing-library/user-event": "^12.1.10", + "@apollo/client": "^3.5.6", + "@craco/craco": "^6.4.3", "antd": "^4.15.5", "axios": "^0.21.1", + "babel-plugin-import": "^1.13.3", "babel-plugin-styled-components": "^1.13.2", "babel-plugin-transform-imports": "^2.0.0", - "craco-antd": "^1.19.0", - "craco-esbuild": "^0.3.4", + "craco-less": "^2.0.0", "dayjs": "^1.10.4", - "graphql": "^15.5.0", + "graphql": "^16.2.0", + "graphql.macro": "^1.4.2", "lodash": "^4.17.21", "mobx": "^6.1.8", "mobx-react-lite": "^3.2.0", - "pluralize": "^8.0.0", "react": "^17.0.2", + "react-async-hook": "^4.0.0", "react-dom": "^17.0.2", "react-router": "^5.2.0", "react-router-dom": "^5.2.0", - "react-scripts": "^4.0.3", + "react-scripts": "^5.0.0", "rebass": "^4.0.7", "styled-components": "^5.2.3", - "typescript": "^4.2.4", + "typescript": "^4.5.4", "use-debounce": "^6.0.1", - "uuid": "^8.3.2", - "validator": "^13.5.2", - "webpack": "4.44.2" + "validator": "^13.5.2" }, "devDependencies": { "@storybook/addon-actions": "^6.2.9", @@ -41,25 +37,31 @@ "@storybook/preset-ant-design": "^0.0.2", "@storybook/preset-create-react-app": "^3.1.7", "@storybook/react": "^6.2.9", + "@testing-library/jest-dom": "^5.11.4", + "@testing-library/react": "^11.1.0", + "@testing-library/user-event": "^12.1.10", "@types/jest": "^26.0.15", "@types/lodash": "^4.14.168", "@types/node": "^12.0.0", - "@types/pluralize": "^0.0.29", "@types/react": "^17.0.0", "@types/react-dom": "^17.0.0", "@types/react-router-dom": "^5.1.7", "@types/rebass": "^4.0.8", "@types/styled-components": "^5.1.9", "@types/uuid": "^8.3.0", + "apollo": "^2.33.9", "commitizen": "^4.2.3", "cz-conventional-changelog": "^3.3.0", "dotenv-cli": "^4.1.1", + "rimraf": "^3.0.2", "source-map-explorer": "^2.5.2" }, "resolutions": { "babel-loader": "8.1.0" }, "scripts": { + "graphql:codegen": "apollo client:codegen --target typescript", + "graphql:update-schema": "apollo client:download-schema src/core/graphql/schemas/crm.graphql", "test": "react-scripts test", "eject": "react-scripts eject", "start": "dotenv -e .env craco start", @@ -69,7 +71,8 @@ "commit": "git-cz", "analyze": "source-map-explorer 'build/static/js/*.js'", "storybook": "start-storybook -p 6006 -s public", - "build-storybook": "build-storybook -s public" + "build-storybook": "build-storybook -s public", + "babel:clear": "rimraf -rf ./node_modules/.cache/babel-loader/*" }, "eslintConfig": { "extends": [ diff --git a/src/client/App.jsx b/src/client/App.jsx index ffd15b9..bb4cad6 100644 --- a/src/client/App.jsx +++ b/src/client/App.jsx @@ -4,7 +4,6 @@ import { StoreProvider } from 'client/contexts/storeContext'; import theme from 'client/UIKit/theme'; import { BrowserRouter } from 'react-router-dom'; import { ThemeProvider } from 'styled-components'; -import './App.less'; import Layout from './Layout'; message.config({ diff --git a/src/client/App.less b/src/client/App.less deleted file mode 100644 index ce63c10..0000000 --- a/src/client/App.less +++ /dev/null @@ -1 +0,0 @@ -@import '~antd/dist/antd.less'; diff --git a/src/client/Containers/Calculation/index.jsx b/src/client/Containers/Calculation/index.jsx index dc19e64..3fc9875 100644 --- a/src/client/Containers/Calculation/index.jsx +++ b/src/client/Containers/Calculation/index.jsx @@ -1,13 +1,8 @@ -import Result from 'client/Components/Result'; -import Spinner from 'client/Components/Spinner'; -import Button from 'client/Elements/Button'; -import { CenterContent } from 'client/Elements/Wrapper'; -import { useFetch } from 'client/hooks/Calculation/useFetch'; +import withStores from 'client/hocs/withStores'; import { Box } from 'client/UIKit/grid'; import mq from 'client/UIKit/mq'; import styled from 'styled-components'; import Info from './Info'; -import fetchData from './lib/fetchData'; import Results from './Results'; import Sections from './Sections'; @@ -25,33 +20,12 @@ const Grid = styled(Box)` `} `; -const Calculation = () => { - const { isLoading, error, fetch } = useFetch({ fetchData }); +const Calculation = () => ( + + + + + +); - if (isLoading) { - return ( - - - - ); - } - - if (error) { - const ServerError = Result[500]; - return ( - ]} - /> - ); - } - - return ( - - - - - - ); -}; - -export default Calculation; +export default withStores(Calculation, ['userStore', 'calculationStore']); diff --git a/src/client/Containers/Calculation/lib/fetchData/getUser.js b/src/client/Containers/Calculation/lib/fetchData/getUser.js deleted file mode 100644 index 8c681e4..0000000 --- a/src/client/Containers/Calculation/lib/fetchData/getUser.js +++ /dev/null @@ -1,26 +0,0 @@ -import UserStore from 'client/stores/UserStore'; -import UserService from 'core/services/UserService'; - -function getUserFromLocalStorage() { - const user = ['username', 'domain'].reduce((acc, propName) => { - let prop = localStorage.getItem(propName); - if (!prop) { - prop = prompt('Enter ' + propName); - localStorage.setItem(propName, prop); - } - acc[propName] = prop; - return acc; - }, {}); - return user; -} - -export default async () => { - let user; - if (process.env.NODE_ENV === 'development') { - user = getUserFromLocalStorage(); - } else { - user = await UserService.fetchUser(); - } - UserStore.setUser(user); - return user; -}; diff --git a/src/client/Containers/Calculation/lib/fetchData/index.js b/src/client/Containers/Calculation/lib/fetchData/index.js deleted file mode 100644 index 048a940..0000000 --- a/src/client/Containers/Calculation/lib/fetchData/index.js +++ /dev/null @@ -1,101 +0,0 @@ -import CalculationStore from 'client/stores/CalculationStore'; -import initialOptions from 'client/stores/CalculationStore/config/initialOptions'; -import initialValues from 'client/stores/CalculationStore/config/initialValues'; -import UserStore from 'client/stores/UserStore'; -import CrmService from 'core/services/CrmService'; -import { Process } from 'core/types/Calculation/Store/process'; -import getUser from './getUser'; -import insuranceQuery from './queries/insuranceQuery'; -import optionsQuery from './queries/optionsQuery'; -import initialOwnerQuery from './queries/ownerQuery'; -import staticDataQuery from './queries/staticDataQuery'; -import systemUserQuery from './queries/systemUserQuery'; - -export default () => - new Promise(async (resolve, reject) => { - await getUser(); - const domainname = UserStore.getDomainName(); - const { calculationProcess } = CalculationStore.stores; - calculationProcess.addProcess(Process.Init); - Promise.all([ - CrmService.crmgqlquery({ - ...initialOwnerQuery, - variables: { - statecode: 0, - domainname, - }, - }), - CrmService.crmgqlquery(optionsQuery), - CrmService.crmgqlquery(staticDataQuery), - CrmService.crmgqlquery({ - ...systemUserQuery, - variables: { domainname }, - }), - CrmService.crmgqlquery(insuranceQuery), - ]) - .then( - ([ - { entities: ownerOptions }, - { entities: options }, - { entities: staticEntities }, - { - entities: { systemuser }, - }, - { - entities: { insuranceCompany }, - }, - ]) => { - CalculationStore.applyOptions({ - ...initialOptions, - ...ownerOptions, - ...options, - }); - CalculationStore.applyStaticData({ - ...staticEntities, - systemuser: [systemuser], - }); - CalculationStore.setValues(initialValues, true); - CalculationStore.setTableColumns('tableInsurance')({ - options: { insuranceCompany }, - }); - - const supplierCurrency = CalculationStore.options.selectSupplierCurrency?.find( - x => x.isocurrencycode === 'RUB', - ); - if (supplierCurrency) - CalculationStore.setValue( - 'supplierCurrency', - supplierCurrency.transactioncurrencyid, - ); - - const evo_sot_coefficient_type = staticEntities.evo_sot_coefficient_type.find( - x => x.evo_id === 'BONUS_LEASING', - ); - - const evo_coefficient_bonus = staticEntities.evo_coefficient.find( - x => - x.evo_job_titleid === systemuser.evo_job_titleid && - x.evo_sot_coefficient_typeid === - evo_sot_coefficient_type?.evo_sot_coefficient_typeid, - ); - - if ( - evo_coefficient_bonus && - evo_coefficient_bonus.evo_sot_coefficient - ) { - CalculationStore.setValue( - 'saleBonus', - evo_coefficient_bonus.evo_sot_coefficient * 100, - ); - } - - calculationProcess.deleteProcess(Process.Init); - - resolve(); - }, - ) - .catch(err => { - reject(err); - throw err; - }); - }); diff --git a/src/client/Containers/Calculation/lib/fetchData/queries/insuranceQuery.ts b/src/client/Containers/Calculation/lib/fetchData/queries/insuranceQuery.ts deleted file mode 100644 index 7617e32..0000000 --- a/src/client/Containers/Calculation/lib/fetchData/queries/insuranceQuery.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { gql } from '@apollo/client'; -import { IQueryToCRMGQL } from 'core/types/Calculation/Requests'; - -const query = gql` - query($evo_account_type: [Int!], $statecode: Int) { - insuranceCompanies: accounts( - evo_account_type: $evo_account_type - statecode: $statecode - ) { - accountid - name - evo_type_ins_policy - evo_id_elt - evo_id_elt_smr - evo_id_elt_osago - evo_legal_region_calc - } - } -`; - -const variables = { evo_account_type: [100000002], statecode: 0 }; -const toOptions = ['insuranceCompanies']; - -export default { - query, - variables, - toOptions, -} as IQueryToCRMGQL; diff --git a/src/client/Containers/Calculation/lib/fetchData/queries/optionsQuery.ts b/src/client/Containers/Calculation/lib/fetchData/queries/optionsQuery.ts deleted file mode 100644 index 5e67126..0000000 --- a/src/client/Containers/Calculation/lib/fetchData/queries/optionsQuery.ts +++ /dev/null @@ -1,396 +0,0 @@ -import { gql } from '@apollo/client'; -import { currentISODate } from 'core/tools/date'; -import { IQueryToCRMGQL } from 'core/types/Calculation/Requests'; - -const query = gql` - query( - $statecode: Int - $currentDate: DateTime - $supplier_account_type: [Int!] - $supplier_legal_form: Int - $dealer_account_type: [Int!] - $dealer_legal_form: Int - $account_account_type: [Int!] - $product_relation: [Int!] - $registration_product_type: Int - $nsib_product_type: Int - $tracker_product_type: Int - $telematic_product_type: Int - $fuelcard_product_type: Int - $techcard_product_type: Int - ) { - selectSupplier: accounts( - evo_account_type: $supplier_account_type - statecode: $statecode - evo_legal_form: $supplier_legal_form - ) { - name - accountid - evo_fin_department_accountid - } - selectSupplierCurrency: transactioncurrencies(statecode: $statecode) { - transactioncurrencyid - isocurrencycode - } - selectClientRisk: evo_client_risks(statecode: $statecode) { - evo_name - evo_client_riskid - evo_id - } - selectClientType: evo_client_types(statecode: $statecode) { - evo_name - evo_client_typeid - } - selectDealer: accounts( - evo_account_type: $dealer_account_type - statecode: $statecode - evo_legal_form: $dealer_legal_form - ) { - name - accountid - } - selectGPSBrand: evo_gps_brands(statecode: $statecode) { - evo_name - evo_gps_brandid - } - selectRegionRegistration: evo_regions(statecode: $statecode) { - evo_name - evo_regionid - evo_fias_id - evo_businessunit_evolution - evo_oktmo - evo_kladr_id - } - selectLegalClientRegion: evo_regions(statecode: $statecode) { - evo_name - evo_regionid - evo_fias_id - evo_businessunit_evolution - evo_oktmo - evo_kladr_id - } - selectAccount: accounts( - evo_account_type: $account_account_type - statecode: $statecode - ) { - name - accountid - evo_client_riskid - } - selectBrand: evo_brands(statecode: $statecode) { - evo_id - evo_name - evo_brandid - evo_brand_owner - evo_importer_reward_perc - evo_importer_reward_rub - evo_vehicle_type - } - selectProduct: evo_baseproducts( - statecode: $statecode - evo_relation: $product_relation - evo_datefrom_param: { lte: $currentDate } - evo_dateto_param: { gte: $currentDate } - ) { - evo_name - evo_baseproductid - evo_id - evo_leasingobject_types { - evo_name - evo_leasingobject_typeid - evo_id - } - evo_brands { - evo_name - evo_brandid - } - } - selectRegistration: evo_addproduct_types( - statecode: $statecode - evo_product_type: $registration_product_type - evo_datefrom_param: { lte: $currentDate } - evo_dateto_param: { gte: $currentDate } - ) { - evo_id - evo_name - evo_addproduct_typeid - evo_accountid - evo_graph_price_withoutnds - evo_cost_service_provider_withoutnds - evo_retro_bonus_withoutnds - evo_prime_cost - evo_graph_price - evo_max_period - evo_min_period - evo_controls_program - evo_towtruck - evo_pts_type - evo_description - evo_gibdd_region - evo_whom_register - } - selectInsNSIB: evo_addproduct_types( - statecode: $statecode - evo_product_type: $nsib_product_type - evo_datefrom_param: { lte: $currentDate } - evo_dateto_param: { gte: $currentDate } - ) { - evo_id - evo_name - evo_addproduct_typeid - evo_accountid - evo_graph_price_withoutnds - evo_cost_service_provider_withoutnds - evo_retro_bonus_withoutnds - evo_prime_cost - evo_graph_price - evo_max_period - evo_min_period - evo_controls_program - } - selectTracker: evo_addproduct_types( - statecode: $statecode - evo_product_type: $tracker_product_type - evo_datefrom_param: { lte: $currentDate } - evo_dateto_param: { gte: $currentDate } - ) { - evo_id - evo_name - evo_addproduct_typeid - evo_accountid - evo_graph_price_withoutnds - evo_cost_service_provider_withoutnds - evo_retro_bonus_withoutnds - evo_prime_cost - evo_graph_price - evo_max_period - evo_min_period - evo_controls_program - evo_planpayments { - evo_name - evo_cost_equipment_withoutnds - evo_cost_price_telematics_withoutnds - evo_cost_telematics_withoutnds - } - } - selectTelematic: evo_addproduct_types( - statecode: $statecode - evo_product_type: $telematic_product_type - evo_datefrom_param: { lte: $currentDate } - evo_dateto_param: { gte: $currentDate } - ) { - evo_id - evo_name - evo_addproduct_typeid - evo_accountid - evo_graph_price_withoutnds - evo_cost_service_provider_withoutnds - evo_retro_bonus_withoutnds - evo_prime_cost - evo_graph_price - evo_max_period - evo_min_period - evo_controls_program - evo_planpayments { - evo_name - evo_cost_equipment_withoutnds - evo_cost_price_telematics_withoutnds - evo_cost_telematics_withoutnds - } - } - selectTechnicalCard: evo_addproduct_types( - statecode: $statecode - evo_product_type: $techcard_product_type - evo_datefrom_param: { lte: $currentDate } - evo_dateto_param: { gte: $currentDate } - ) { - evo_id - evo_name - evo_addproduct_typeid - evo_accountid - evo_graph_price_withoutnds - evo_cost_service_provider_withoutnds - evo_retro_bonus_withoutnds - evo_prime_cost - evo_graph_price - evo_max_period - evo_min_period - evo_controls_program - evo_helpcard_type - evo_leasingobject_types { - evo_leasingobject_typeid - } - } - selectTarif: evo_tarifs( - statecode: $statecode - evo_datefrom_param: { lte: $currentDate } - evo_dateto_param: { gte: $currentDate } - ) { - evo_name - evo_tarifid - evo_baseproductid - evo_irr - evo_max_irr - evo_min_profit - evo_min_irr - evo_irr_plan - evo_ins_type - evo_min_period - evo_max_period - evo_client_risks { - evo_name - evo_client_riskid - } - evo_client_types { - evo_name - evo_client_typeid - } - evo_leasingobject_types { - evo_name - evo_id - evo_leasingobject_typeid - } - evo_delivery_time - } - selectRate: evo_rates( - statecode: $statecode - evo_datefrom_param: { lte: $currentDate } - evo_dateto_param: { gte: $currentDate } - ) { - createdon - evo_id - evo_rateid - evo_name - evo_base_rate - evo_coeff_12_23 - evo_coeff_24_35 - evo_coeff_36_47 - evo_coeff_7_11 - evo_coeff_48_60 - evo_tarifs { - evo_tarifid - evo_name - } - evo_credit_period - } - selectLeaseObjectType: evo_leasingobject_types(statecode: $statecode) { - evo_name - evo_id - evo_leasingobject_typeid - evo_depreciation_rate1 - evo_depreciation_rate2 - evo_expluatation_period1 - evo_expluatation_period2 - evo_type_code - evo_category - evo_category_tr - evo_vehicle_type_tax - evo_vehicle_type - } - selectObjectRegionRegistration: evo_regions(statecode: $statecode) { - evo_name - evo_regionid - evo_fias_id - evo_businessunit_evolution - evo_oktmo - accounts { - accountid - } - } - selectSubsidy: evo_subsidies( - statecode: $statecode - evo_datefrom_param: { lte: $currentDate } - evo_dateto_param: { gte: $currentDate } - ) { - evo_name - evo_subsidyid - evo_percent_subsidy - evo_subsidy_summ - evo_max_subsidy_summ - evo_get_subsidy_payment - evo_brands { - evo_brandid - } - evo_models { - evo_modelid - } - evo_leasingobject_types { - evo_leasingobject_typeid - } - accounts { - accountid - } - } - selectFuelCard: evo_addproduct_types( - statecode: $statecode - evo_product_type: $fuelcard_product_type - evo_datefrom_param: { lte: $currentDate } - evo_dateto_param: { gte: $currentDate } - ) { - evo_id - evo_name - evo_addproduct_typeid - evo_accountid - evo_graph_price_withoutnds - evo_cost_service_provider_withoutnds - evo_retro_bonus_withoutnds - evo_prime_cost - evo_graph_price - evo_max_period - evo_min_period - evo_controls_program - evo_helpcard_type - evo_leasingobject_types { - evo_leasingobject_typeid - } - } - } -`; - -const variables = { - currentDate: currentISODate, - statecode: 0, - supplier_account_type: [100000001], - supplier_legal_form: 100000001, - dealer_account_type: [100000001], - dealer_legal_form: 100000001, - account_account_type: [100000000], - product_relation: [100000000], - registration_product_type: 100000001, - nsib_product_type: 100000002, - tracker_product_type: 100000003, - telematic_product_type: 100000004, - techcard_product_type: 100000000, - fuelcard_product_type: 100000005, -}; - -const toOptions = [ - 'selectSupplier', - 'selectSupplierCurrency', - 'selectClientRisk', - 'selectClientType', - 'selectDealer', - 'selectGPSBrand', - 'selectRegionRegistration', - 'selectAccount', - 'selectBrand', - 'selectProduct', - 'selectRegistration', - 'selectInsNSIB', - 'selectTracker', - 'selectTelematic', - 'selectTechnicalCard', - 'selectTarif', - 'selectRate', - 'selectLeaseObjectType', - 'selectObjectRegionRegistration', - 'selectLegalClientRegion', - 'selectSubsidy', - 'selectFuelCard', -]; - -export default { - query, - variables, - toOptions, -} as IQueryToCRMGQL; diff --git a/src/client/Containers/Calculation/lib/fetchData/queries/ownerQuery.ts b/src/client/Containers/Calculation/lib/fetchData/queries/ownerQuery.ts deleted file mode 100644 index 6dc981a..0000000 --- a/src/client/Containers/Calculation/lib/fetchData/queries/ownerQuery.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { gql } from '@apollo/client'; -import { IQueryToCRMGQL } from 'core/types/Calculation/Requests'; - -const query = gql` - query($statecode: Int, $domainname: String) { - selectLead: leads(statecode: $statecode, owner_domainname: $domainname) { - customerid - leadid - fullname - evo_opportunityid - evo_agent_accountid - evo_double_agent_accountid - evo_broker_accountid - evo_fin_department_accountid - accountidData { - evo_address_legalidData { - evo_region_fias_id - evo_city_fias_id - } - } - evo_inn - link - } - selectOpportunity: opportunities( - statecode: $statecode - owner_domainname: $domainname - ) { - opportunityid - name - accountid - evo_leadid - evo_client_riskid - parentaccountid - evo_programsolution - accountidData { - evo_address_legalidData { - evo_region_fias_id - evo_city_fias_id - } - } - link - } - } -`; - -const toOptions = ['selectLead', 'selectOpportunity']; - -export default { - query, - toOptions, -} as IQueryToCRMGQL; diff --git a/src/client/Containers/Calculation/lib/fetchData/queries/staticDataQuery.ts b/src/client/Containers/Calculation/lib/fetchData/queries/staticDataQuery.ts deleted file mode 100644 index cb3a6c4..0000000 --- a/src/client/Containers/Calculation/lib/fetchData/queries/staticDataQuery.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { gql } from '@apollo/client'; -import { currentISODate } from 'core/tools/date'; -import { IQueryToCRMGQL } from 'core/types/Calculation/Requests'; - -const query = gql` - query($statecode: Int, $currentDate: DateTime) { - evo_impairment_group: evo_impairment_groups(statecode: $statecode) { - evo_impairment_groupid - evo_name - } - evo_currencychange: evo_currencychanges( - statecode: $statecode - evo_coursedate_param: { eq: $currentDate } - ) { - evo_currencychange - evo_ref_transactioncurrency - } - evo_coefficient: evo_coefficients( - statecode: $statecode - evo_datefrom_param: { lte: $currentDate } - evo_dateto_param: { gte: $currentDate } - ) { - evo_correction_coefficient - evo_graph_type - evo_season_type - evo_job_titleid - evo_sot_coefficient_typeid - evo_sot_coefficient - evo_corfficient_type - evo_min_period - evo_max_period - evo_graph_type - evo_season_type - evo_correction_coefficient - evo_client_riskid - evo_client_typeid - evo_risk_delta - evo_leasingobject_types { - evo_name - evo_id - evo_leasingobject_typeid - } - evo_businessunits { - evo_name - evo_businessunitid - evo_sale_businessunitid - } - } - evo_sot_coefficient_type: evo_sot_coefficient_types(statecode: $statecode) { - evo_id - evo_name - evo_sot_coefficient_typeid - } - evo_job_title: evo_job_titles(statecode: $statecode) { - evo_id - evo_name - evo_job_titleid - } - evo_addproduct_type: evo_addproduct_types( - statecode: $statecode - evo_datefrom_param: { lte: $currentDate } - evo_dateto_param: { gte: $currentDate } - ) { - evo_product_type - evo_addproduct_typeid - evo_controls_program - } - } -`; - -const variables = { - statecode: 0, - currentDate: currentISODate, -}; - -export default { - query, - variables, -} as IQueryToCRMGQL; diff --git a/src/client/Containers/Calculation/lib/fetchData/queries/systemUserQuery.ts b/src/client/Containers/Calculation/lib/fetchData/queries/systemUserQuery.ts deleted file mode 100644 index e896106..0000000 --- a/src/client/Containers/Calculation/lib/fetchData/queries/systemUserQuery.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { gql } from '@apollo/client'; - -export default { - query: gql` - query($domainname: String) { - systemuser(domainname: $domainname) { - evo_job_titleid - businessunitid - firstname - lastname - fullname - } - } - `, -}; diff --git a/src/client/Elements/Notification.ts b/src/client/Elements/Notification.ts index 7397fc3..137a0e3 100644 --- a/src/client/Elements/Notification.ts +++ b/src/client/Elements/Notification.ts @@ -11,7 +11,7 @@ export const openNotification = ({ }: { type: TNotification; title: string; - description: string; + description?: string; }) => debounce( () => diff --git a/src/client/Layout/index.jsx b/src/client/Layout/index.jsx index 4d45bf3..59f3946 100644 --- a/src/client/Layout/index.jsx +++ b/src/client/Layout/index.jsx @@ -1,8 +1,8 @@ import { Box, Flex } from 'client/UIKit/grid'; import mq from 'client/UIKit/mq'; import styled from 'styled-components'; +import Routes from '../Routes'; import Header from './Header'; -import Routes from './routes'; const Main = styled(Box)` ${mq.laptop` diff --git a/src/client/Layout/routes.jsx b/src/client/Routes/index.jsx similarity index 94% rename from src/client/Layout/routes.jsx rename to src/client/Routes/index.jsx index e827b50..b927c42 100644 --- a/src/client/Layout/routes.jsx +++ b/src/client/Routes/index.jsx @@ -1,9 +1,9 @@ import Spinner from 'client/Components/Spinner'; import { CenterContent } from 'client/Elements/Wrapper'; -import paths from 'core/common/paths'; import { container as resolveContainer } from 'core/tools/resolve'; import { Suspense } from 'react'; import { Route, Switch } from 'react-router-dom'; +import paths from './paths'; export default () => ( () => { + const stores = useStores(); + const initStores = async function () { + for (const storeName of storesList) await stores[storeName].init(); + }; + + const res = useAsync(initStores, [storesList]); + + if (res.loading) { + return ( + + + + ); + } + + if (res.error) { + const ServerError = Result[500]; + const RetryButton = ( + + ); + return ; + } + + return ; +}; diff --git a/src/client/hooks/Calculation/useFetch.js b/src/client/hooks/Calculation/useFetch.js deleted file mode 100644 index 23d86dc..0000000 --- a/src/client/hooks/Calculation/useFetch.js +++ /dev/null @@ -1,28 +0,0 @@ -import { useEffect, useState } from 'react'; - -export const useFetch = ({ fetchData }) => { - const [response, setResponse] = useState(); - const [error, setError] = useState(); - const [isLoading, setIsLoading] = useState(false); - - function fetch() { - setError(false); - setResponse(undefined); - setIsLoading(true); - fetchData() - .then(res => { - setResponse(res); - }) - .catch(err => { - setError(err); - }) - .finally(() => { - setIsLoading(false); - }); - } - - useEffect(() => { - fetch(); - }, []); - return { response, isLoading, error, fetch }; -}; diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts index 75d593a..c0e37c8 100644 --- a/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts +++ b/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts @@ -1,9 +1,9 @@ import valuesConstants from 'core/constants/values'; import { currentDate } from 'core/tools/date'; +import { NIL } from 'core/tools/uuid'; import { PaymentRow, PreparedValues } from 'core/types/Calculation/Prepare'; import { IPreparedData } from 'core/types/Calculation/Requests'; import { ICalculationStore } from 'core/types/Calculation/Store'; -import NIL from 'uuid/dist/nil'; import { convertPrice } from '../../lib/tools'; export default function (this: ICalculationStore): IPreparedData { diff --git a/src/client/stores/CalculationStore/Effects/actions/createKP.ts b/src/client/stores/CalculationStore/Effects/actions/createKP.ts index ffd9b48..5d8777f 100644 --- a/src/client/stores/CalculationStore/Effects/actions/createKP.ts +++ b/src/client/stores/CalculationStore/Effects/actions/createKP.ts @@ -1,139 +1,88 @@ -import { gql } from '@apollo/client'; import { message } from 'antd'; +import { AxiosError } from 'axios'; import { openNotification } from 'client/Elements/Notification'; import UserStore from 'client/stores/UserStore'; -import { CRM_PROXY_URL } from 'core/constants/urls'; +import { getQuotesByLeadQuery } from 'core/graphql/query/crm/quote'; import CrmService from 'core/services/CrmService'; import { ICalculationStore } from 'core/types/Calculation/Store'; +import { IQuote } from 'core/types/Entities/crmEntities'; import { toJS } from 'mobx'; import customValues from '../lib/customValues'; -import { quoteFields } from '../lib/queries'; import calculate from './calculate'; -export default async function (this: ICalculationStore) { - const { values, tables } = this; - const { calculationUrls, ELTStore } = this.stores; +async function composeRequest(this: ICalculationStore) { const calculationRes = await calculate.call(this); - if (!calculationRes) { - return; - } + if (!calculationRes) return; - calculationUrls.setUrl({ name: 'kpUrl', url: undefined }); - - const insurances = tables.tableInsurance.rows.map(insuranceRow => { - const resObj = {}; - Object.keys(insuranceRow).forEach(prop => { - resObj[prop] = insuranceRow[prop].value; - }); - return resObj; - }); - - const { - columns, - postValues, - preparedValues, - preparedPayments, - } = calculationRes; - - const domainname = UserStore.getDomainName(); + const insurances = this.tables.tableInsurance.rows.map( + insuranceRow => + Object.keys(insuranceRow).reduce((acc, v) => { + acc[v] = toJS(insuranceRow[v].value); + return acc; + }, {}), + {}, + ); const elt = Object.assign( {}, ...['osago', 'kasko'].map(insType => ({ - [insType]: toJS(ELTStore[insType].getCompany()), + [insType]: toJS(this.stores.ELTStore[insType].getCompany()), })), ); - CrmService.createKp( - toJS({ - domainName: domainname, - calculation: { - insurances, - preparedValues, - preparedPayments, - columns, - postValues, - calculationValues: { - ...values, - insKaskoPriceLeasePeriod: customValues.insKaskoPriceLeasePeriod.call( - this, - ), - }, - }, - elt, - }), - ) - .then(({ quoteid }) => { - CrmService.crmgqlquery({ - query: gql` - query($quoteid: Uuid!) { - quote(quoteId: $quoteid) { - ${quoteFields} - } - } - `, - variables: { - quoteid, - }, - toOptions: ['quote'], - }).then(async ({ entities: { quote: new_quote } }) => { - console.log('quote', new_quote); - if (!Array.isArray(new_quote)) { - message.success({ - content: `КП ${new_quote?.evo_quotename || ''} создано!`, - }); + const insKaskoPriceLeasePeriod = + customValues.insKaskoPriceLeasePeriod.call(this); + const calculationValues = Object.assign({}, toJS(this.values), { + insKaskoPriceLeasePeriod, + }); - if (new_quote?.offerprintformapi) { - calculationUrls.setUrl({ - name: 'kpUrl', - url: String.prototype.concat( - CRM_PROXY_URL, - new_quote.offerprintformapi, - ), - }); - } - this.setValue('recalcWithRevision', false); - let quotes = toJS(this.getOptions('selectQuote')) || []; - //@ts-ignore - quotes = [new_quote].concat(quotes); - - const { quote: selected_quoteid } = this.values; - const { - entities: { quote: updated_quote }, - } = await CrmService.crmgqlquery({ - query: gql` - query($quoteid: Uuid!) { - quote(quoteId: $quoteid) { - ${quoteFields} - } - } - `, - variables: { - quoteid: selected_quoteid, - }, - toOptions: ['quote'], - }); - - if (updated_quote && !Array.isArray(updated_quote)) { - const qIndex = quotes.findIndex( - quote => quote.quoteid === updated_quote.quoteid, - ); - if (qIndex) quotes.splice(qIndex, 1, updated_quote); - } - - this.setOptions('selectQuote', quotes); - } - }); - }) - .catch(err => { - openNotification({ - type: 'error', - title: 'Ошибка во время создания КП!', - description: - err.response.data && JSON.stringify(err.response.data.errors), - })(); - - throw err.response.data; - }); + const domainname = UserStore.getDomainName(); + const payload = { + domainName: domainname, + calculation: { + insurances, + calculationValues, + ...calculationRes, + }, + elt, + }; + return payload; +} + +export default async function (this: ICalculationStore) { + try { + this.stores.calculationUrls.setUrl({ name: 'kpUrl', url: undefined }); + const payload = await composeRequest.call(this); + if (!payload) return; + + await CrmService.createKP(payload); + message.success({ + content: 'КП создано!', + }); + const leadid = this.getValue('lead'); + + CrmService.getCRMOptions<'quotes', IQuote>({ + query: getQuotesByLeadQuery, + variables: { + leadid, + }, + fetchPolicy: 'network-only', + }).then(({ quotes }) => { + if (!quotes || quotes?.length === 0) { + throw new Error(); + } + + this.setOptions('selectQuote', quotes); + }); + } catch (err) { + openNotification({ + type: 'error', + title: 'Ошибка во время создания КП!', + })(); + + const { response } = err as AxiosError; + const error = response?.data || err; + throw JSON.stringify(error); + } } diff --git a/src/client/stores/CalculationStore/Effects/lib/queries.js b/src/client/stores/CalculationStore/Effects/lib/queries.js deleted file mode 100644 index 9b34d81..0000000 --- a/src/client/stores/CalculationStore/Effects/lib/queries.js +++ /dev/null @@ -1,25 +0,0 @@ -export const quoteFields = ` -quoteid -name -evo_quotename -quotenumber -evo_recalc_limit -evo_object_count -evo_approved_first_payment -evo_statuscode: evo_statuscodeidData { - evo_id -} -evo_max_price_change -evo_max_mass -evo_seats -evo_year -offerprintformapi -evo_regionid -evo_legal_regionid -evo_legal_townid -link -evo_req_telematic -evo_req_telematic_accept -evo_one_year_insurance -evo_last_payment_perc -`; diff --git a/src/client/stores/CalculationStore/Effects/reactions/gibddReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/gibddReactions.ts index a2438f6..88cf4d0 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/gibddReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/gibddReactions.ts @@ -10,6 +10,7 @@ import { TElements, } from 'core/types/Calculation/Store/elements'; import { Process } from 'core/types/Calculation/Store/process'; +import { IEvoTown } from 'core/types/Entities/crmEntities'; import { ElementStatus } from 'core/types/statuses'; import { get } from 'lodash'; @@ -462,7 +463,7 @@ const gibddReactions: IReactionEffect[] = [ ); if (evo_city_fias_id) { - CrmService.crmgqlquery({ + CrmService.getCRMEntities<'evo_town', IEvoTown, IEvoTown>({ query: gql` query($evo_fias_id: String) { evo_town(evo_fias_id: $evo_fias_id) { @@ -474,12 +475,9 @@ const gibddReactions: IReactionEffect[] = [ variables: { evo_fias_id: evo_city_fias_id, }, - }).then(({ entities }) => { - if (entities.evo_town && !Array.isArray(entities.evo_town)) { - calculationStore.setValue( - 'legalClientTown', - entities.evo_town.evo_townid, - ); + }).then(({ evo_town }) => { + if (evo_town) { + calculationStore.setValue('legalClientTown', evo_town.evo_townid); calculationStore.setStatus( 'selectLegalClientTown', ElementStatus.Disabled, @@ -568,7 +566,7 @@ const gibddReactions: IReactionEffect[] = [ ); if (evo_city_fias_id && objectRegistration === 100000000) { - CrmService.crmgqlquery({ + CrmService.getCRMEntities<'evo_town', IEvoTown, IEvoTown>({ query: gql` query($evo_fias_id: String) { evo_town(evo_fias_id: $evo_fias_id) { @@ -580,12 +578,9 @@ const gibddReactions: IReactionEffect[] = [ variables: { evo_fias_id: evo_city_fias_id, }, - }).then(({ entities }) => { - if (entities.evo_town && !Array.isArray(entities.evo_town)) { - calculationStore.setValue( - 'townRegistration', - entities.evo_town.evo_townid, - ); + }).then(({ evo_town }) => { + if (evo_town && !Array.isArray(evo_town)) { + calculationStore.setValue('townRegistration', evo_town.evo_townid); calculationStore.setStatus( 'selectTownRegistration', ElementStatus.Disabled, diff --git a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts index 375a2b0..edb654e 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts @@ -1,31 +1,36 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment */ import { message } from 'antd'; import { resetIns } from 'client/Components/Calculation/ELT/Content/lib/resetIns'; import { numberElementsProps } from 'client/Containers/Calculation/lib/elements/elementsProps'; import { getTitle, - getValueName + getValueName, } from 'client/Containers/Calculation/lib/elements/tools'; import { elementsValues } from 'client/Containers/Calculation/lib/elements/values'; import { openNotification } from 'client/Elements/Notification'; import initialValues from 'client/stores/CalculationStore/config/initialValues'; +import { + getMainOptionsForQuote, + getQuoteQuery, + getSecondaryOptionsForQuote, + getSingleOptionsForQuote, +} from 'core/graphql/query/crm/quote'; import CrmService from 'core/services/CrmService'; import { currentISODate } from 'core/tools/date'; -import { IGetCRMEntitiesResponse } from 'core/types/Calculation/Responses'; +import { NIL } from 'core/tools/uuid'; import { IReactionEffect } from 'core/types/Calculation/Store/effect'; -import { - ElementsNames, - TElements -} from 'core/types/Calculation/Store/elements'; +import { ElementsNames } from 'core/types/Calculation/Store/elements'; import { Process } from 'core/types/Calculation/Store/process'; -import { ValuesNames } from 'core/types/Calculation/Store/values'; -import { IEvoGraph } from 'core/types/Entities/crmEntities'; +import { TValues, ValuesNames } from 'core/types/Calculation/Store/values'; +import { + IAccount, + IEvoGraph, + IEvoTown, + IQuote, + TCRMEntity, +} from 'core/types/Entities/crmEntities'; import { ElementStatus } from 'core/types/statuses'; import { get, invert, isEqual, isNil } from 'lodash'; -import NIL from 'uuid/dist/nil'; import { getKpPropName } from './mapKpToValues'; -import { mainOptionsQuery, secondaryOptionsQuery } from './optionsQuery'; -import quoteQuery from './quoteQuery'; const map_add_product_types_to_values = { technicalCard: 100000000, @@ -83,19 +88,17 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ const { calculationProcess } = calculationStore.stores; - CrmService.crmgqlquery({ - query: quoteQuery, + CrmService.getCRMEntities<'quote', IQuote, keyof IQuote>({ + query: getQuoteQuery, variables: { quoteId, }, }) - .then(async ({ entities: { quote } }) => { - if (!quote) { - throw new Error('No quote!'); - } + .then(async ({ quote }) => { + if (!quote) throw new Error('no quote'); calculationProcess.addProcess(Process.LoadKp); if (!Array.isArray(quote)) { - const newValues = Object.assign( + const newValues: TValues = Object.assign( {}, ...(Object.values(elementsValues) as ValuesNames[]).map( valueName => ({ @@ -105,12 +108,11 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ ), ); - const { - entities: mainOptions, - }: IGetCRMEntitiesResponse & { - entities: TElements; - } = await CrmService.crmgqlquery({ - query: mainOptionsQuery, + const mainOptions = await CrmService.getCRMOptions< + ElementsNames, + TCRMEntity + >({ + query: getMainOptionsForQuote, variables: { statecode: 0, evo_brandid: quote.evo_brandid || NIL, @@ -119,7 +121,6 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ currentDate: currentISODate, dealer_person_accountid: quote.evo_dealer_person_accountid || NIL, dealer_broker_accountid: quote.evo_dealer_broker_accountid || NIL, - hasDealerBroker: quote.evo_dealer_broker_accountid ? true : false, // ind_agent_accountid: quote.evo_agent_accountid || NIL, double_agent_accountid: quote.evo_double_agent_accountid || NIL, // broker_accountid: quote.evo_broker_accountid || NIL, @@ -129,26 +130,22 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ evo_regionid: quote.evo_regionid || NIL, evo_legal_regionid: quote.evo_legal_regionid || NIL, }, - toOptions: [ - 'selectModel', - 'selectConfiguration', - 'selectDealerPerson', - 'selectDealerRewardCondition', - 'selectDealerBroker', - 'selectDealerBrokerRewardCondition', - 'selectIndAgentRewardCondition', - 'selectCalcDoubleAgentRewardCondition', - 'selectCalcBrokerRewardCondition', - 'selectFinDepartmentRewardCondtion', - 'selectGPSModel', - 'selectTownRegistration', - 'selectLegalClientTown', - ], + }); + + const { selectDealerBroker } = await CrmService.getCRMOptions< + 'selectDealerBroker', + IAccount + >({ + query: getSingleOptionsForQuote, + variables: { + dealer_broker_accountid: quote.evo_dealer_broker_accountid || NIL, + hasDealerBroker: quote.evo_dealer_broker_accountid ? true : false, + }, }); calculationStore.applyOptions({ ...mainOptions, - selectDealerBroker: [mainOptions.selectDealerBroker], + selectDealerBroker, }); // fill insurance table @@ -394,18 +391,16 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ } // regionRegistration - const { - entities: secondaryOptions, - }: IGetCRMEntitiesResponse & { - entities: TElements; - } = await CrmService.crmgqlquery({ - query: secondaryOptionsQuery, + const secondaryOptions = await CrmService.getCRMOptions< + ElementsNames, + keyof IEvoTown + >({ + query: getSecondaryOptionsForQuote, variables: { statecode: 0, evo_regionid: regionRegistration || NIL, evo_legal_regionid: legalClientRegion || NIL, }, - toOptions: ['selectTownRegistration', 'selectLegalClientTown'], }); calculationStore.applyOptions(secondaryOptions); @@ -428,9 +423,10 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ ); } else { if ( - secondaryOptions.selectLegalClientTown.findIndex( - x => x.evo_legal_townid === quote.evo_legal_townid, - ) > -1 + ( + secondaryOptions?.selectLegalClientTown as IEvoTown[] + )?.findIndex(x => x.evo_townid === 'quote?.evo_legal_townid') > + -1 ) { legalClientTown = quote.evo_legal_townid; } @@ -444,9 +440,9 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ //townRegistration if (quote.evo_object_registration === 100000001) { if ( - secondaryOptions.selectTownRegistration.findIndex( - x => x.evo_townid === quote.evo_townid, - ) > -1 + ( + secondaryOptions?.selectTownRegistration as IEvoTown[] + )?.findIndex(x => x.evo_townid === quote.evo_townid) > -1 ) { townRegistration = quote.evo_townid; } @@ -474,9 +470,9 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ ); } else { if ( - secondaryOptions.selectTownRegistration.findIndex( - x => x.evo_townid === quote.evo_townid, - ) > -1 + ( + secondaryOptions?.selectTownRegistration as IEvoTown[] + )?.findIndex(x => x.evo_townid === quote.evo_townid) > -1 ) { townRegistration = quote.evo_townid; } @@ -558,7 +554,7 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ })(); } // check min max number values - + calculationStore.setValues(finalValues, true); message.success({ diff --git a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts index 7d955bb..eb80cc5 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts @@ -1,7 +1,7 @@ -import { TValues, ValuesNames } from 'core/types/Calculation/Store/values'; +import { ValuesNames } from 'core/types/Calculation/Store/values'; import { IQuote } from 'core/types/Entities/crmEntities'; -const mapKPtoValues: TValues = { +const mapKPtoValues: Partial> = { product: 'evo_baseproductid', clientType: 'evo_client_typeid', leaseObjectPrice: 'evo_supplier_currency_price', @@ -96,8 +96,8 @@ const mapKPtoValues: TValues = { subsidySum: 'evo_subsidy_summ', }; -export function getKpPropName(valueName: ValuesNames) { - return mapKPtoValues[valueName]; -} +export const getKpPropName = ( + valueName: ValuesNames, +): keyof IQuote | string | undefined => mapKPtoValues[valueName]; export default mapKPtoValues; diff --git a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/optionsQuery.js b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/optionsQuery.js deleted file mode 100644 index 82f40bc..0000000 --- a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/optionsQuery.js +++ /dev/null @@ -1,159 +0,0 @@ -import { gql } from '@apollo/client'; - -export const mainOptionsQuery = gql` - query( - $statecode: Int - $evo_brandid: Uuid - $evo_modelid: Uuid - $salonaccountid: Uuid! - $currentDate: DateTime - $dealer_person_accountid: Uuid! - $dealer_broker_accountid: Uuid! - $hasDealerBroker: Boolean! - # $ind_agent_accountid: Uuid! - $double_agent_accountid: Uuid! - # $broker_accountid: Uuid! - # $findepartment_accountid: Uuid! - $evo_gps_brandid: Uuid! - ) { - selectModel: evo_models(statecode: $statecode, evo_brandid: $evo_brandid) { - evo_id - evo_name - evo_modelid - evo_leasingobject_risk - evo_importer_reward_perc - evo_importer_reward_rub - evo_impairment_groupid - evo_vehicle_type - evo_gps - evo_vehicle_body_typeidData { - evo_id_elt - } - evo_running_gear - } - selectConfiguration: evo_equipments( - statecode: $statecode - evo_modelid: $evo_modelid - ) { - evo_equipmentid - evo_name - evo_impairment_groupid - evo_leasingobject_risk - evo_start_production_year - } - selectDealerPerson: salon_providers( - statecode: $statecode - salonaccountid: $salonaccountid - ) { - accountid - name - evo_broker_accountid - evo_kpp - evo_inn - } - selectDealerRewardCondition: evo_reward_conditions( - evo_agent_accountid: $dealer_person_accountid - evo_datefrom_param: { lte: $currentDate } - evo_dateto_param: { gte: $currentDate } - statecode: $statecode - ) { - evo_reward_conditionid - evo_name - evo_reward_summ - evo_reduce_reward - } - selectDealerBroker: account(accountid: $dealer_broker_accountid) - @include(if: $hasDealerBroker) { - accountid - name - } - selectDealerBrokerRewardCondition: evo_reward_conditions( - evo_agent_accountid: $dealer_broker_accountid - evo_datefrom_param: { lte: $currentDate } - evo_dateto_param: { gte: $currentDate } - statecode: $statecode - ) { - evo_reward_conditionid - evo_name - evo_reward_summ - evo_reduce_reward - } - # selectIndAgentRewardCondition: evo_reward_conditions( - # evo_agent_accountid: $ind_agent_accountid - # evo_datefrom_param: { lte: $currentDate } - # evo_dateto_param: { gte: $currentDate } - # statecode: $statecode - # ) { - # evo_reward_conditionid - # evo_name - # evo_double_agent_accountid - # evo_reward_summ - # evo_reduce_reward - # } - calcDoubleAgentRewardCondition: evo_reward_conditions( - evo_agent_accountid: $double_agent_accountid - evo_datefrom_param: { lte: $currentDate } - evo_dateto_param: { gte: $currentDate } - statecode: $statecode - ) { - evo_reward_conditionid - evo_name - evo_reward_summ - evo_reduce_reward - } - # calcBrokerRewardCondition: evo_reward_conditions( - # evo_agent_accountid: $broker_accountid - # evo_datefrom_param: { lte: $currentDate } - # evo_dateto_param: { gte: $currentDate } - # statecode: $statecode - # ) { - # evo_reward_conditionid - # evo_name - # evo_reward_summ - # evo_reduce_reward - # } - # selectFinDepartmentRewardCondtion: evo_reward_conditions( - # evo_agent_accountid: $findepartment_accountid - # evo_datefrom_param: { lte: $currentDate } - # evo_dateto_param: { gte: $currentDate } - # statecode: $statecode - # ) { - # evo_reward_conditionid - # evo_name - # evo_reward_summ - # evo_reduce_reward - # } - selectGPSModel: evo_gps_models( - statecode: $statecode - evo_gps_brandid: $evo_gps_brandid - ) { - evo_name - evo_gps_modelid - } - } -`; - -export const secondaryOptionsQuery = gql` - query($statecode: Int, $evo_regionid: Uuid!, $evo_legal_regionid: Uuid!) { - selectTownRegistration: evo_towns( - statecode: $statecode - evo_regionid: $evo_regionid - ) { - evo_name - evo_townid - evo_fias_id - evo_kladr_id - evo_businessunit_evolution - } - selectLegalClientTown: evo_towns( - statecode: $statecode - evo_regionid: $evo_legal_regionid - ) { - evo_name - evo_townid - evo_fias_id - evo_kladr_id - evo_businessunit_evolution - } - } -`; diff --git a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/quoteQuery.js b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/quoteQuery.js deleted file mode 100644 index b006aee..0000000 --- a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/quoteQuery.js +++ /dev/null @@ -1,64 +0,0 @@ -import { gql } from '@apollo/client'; -import mapKPtoValues from './mapKpToValues'; - -export default gql` - query($quoteId: Uuid!) { - quote(quoteId: $quoteId) { - ${Object.values(mapKPtoValues).join(' ')} - evo_addproduct_types { - evo_product_type - evo_addproduct_typeid - } - evo_osago_accountid - evo_kasko_accountid - evo_osago_payer - evo_kasko_payer - evo_osago_price - evo_kasko_price - evo_dgo_price - evo_ns_price - evo_insurance_period - evo_graphs { - createdon - evo_sumpay_withnds - evo_planpayments { - evo_payment_ratio - } - } - evo_first_payment_perc - evo_last_payment_perc - evo_quotename - evo_rateid - evo_client_riskid - evo_regionid - evo_townid - evo_registration_regionid - evo_vehicle_tax_approved - evo_vehicle_tax_year - evo_category_tr - evo_vehicle_type_tax - evo_agent_accountid - evo_dealer_person_accountid - evo_dealer_broker_accountid - evo_double_agent_accountid - evo_broker_accountid - evo_fin_department_accountid - - evo_kasko_accountid - evo_kasko_price - evo_id_elt_kasko - evo_id_kasko_calc - evo_franchise - evo_id_elt_osago - evo_osago_price - evo_legal_regionid - evo_legal_townid - evo_object_count - evo_recalc_limit - evo_req_telematic - evo_req_telematic_accept - evo_accept_control_addproduct_typeid - evo_payment_redemption_sum - } - } -`; diff --git a/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts index 1247d80..f327cb1 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts @@ -1,22 +1,29 @@ import { gql } from '@apollo/client'; +import { getQuotesByLeadQuery } from 'core/graphql/query/crm/quote'; import CrmService from 'core/services/CrmService'; import { currentISODate } from 'core/tools/date'; import { IReactionEffect } from 'core/types/Calculation/Store/effect'; import { Process } from 'core/types/Calculation/Store/process'; +import { + IAccount, + IEvoEquipment, + IEvoGPSModel, + IEvoModel, + IEvoRewardCondition, + IEvoTown, + IQuote, + ISalonProvider, +} from 'core/types/Entities/crmEntities'; import { ElementStatus } from 'core/types/statuses'; -import { quoteFields } from '../lib/queries'; export default [ (calculationStore, calculationProcess) => ({ - expression: () => { - const { values } = calculationStore; - return values.lead; - }, - effect: async leadid => { + expression: () => calculationStore.getOption('selectLead'), + effect: async lead => { if (calculationProcess.hasProcess(Process.LoadKp)) { return; } - if (!leadid) { + if (!lead) { calculationStore.setValue('opportunity', null); calculationStore.setFilter('selectOpportunity', undefined); calculationStore.setValue('quote', null); @@ -32,184 +39,155 @@ export default [ return; } - const lead = calculationStore.getOption('selectLead', { leadid }); - if (lead) { - if (lead.evo_opportunityid) { - calculationStore.setValue('opportunity', lead.evo_opportunityid); - calculationStore.setFilter('selectOpportunity', opportunities => - opportunities.filter( - x => x.opportunityid === lead.evo_opportunityid, - ), - ); - } else { - calculationStore.setFilter('selectOpportunity', () => []); - calculationStore.setValue('opportunity', null); - } + if (lead?.evo_opportunityid) { + calculationStore.setValue('opportunity', lead.evo_opportunityid); + calculationStore.setFilter('selectOpportunity', opportunities => + opportunities.filter(x => x.opportunityid === lead.evo_opportunityid), + ); + } else { + calculationStore.setFilter('selectOpportunity', () => []); + calculationStore.setValue('opportunity', null); + } - if (lead.leadid) { - CrmService.crmgqlquery({ - query: gql` - query($leadid: Uuid) { - quote: quotes(evo_leadid: $leadid) { - ${quoteFields} - } + if (lead?.leadid) { + CrmService.getCRMOptions<'quotes', IQuote>({ + query: getQuotesByLeadQuery, + variables: { + leadid: lead?.leadid, + }, + }).then(({ quotes }) => { + if (quotes && quotes.length > 0) { + calculationStore.setOptions('selectQuote', quotes); + calculationStore.setValue('quote', null); + } else { + calculationStore.setOptions('selectQuote', []); + calculationStore.setValue('quote', null); + } + }); + } else { + calculationStore.setOptions('selectQuote', []); + calculationStore.setValue('quote', null); + } + + if (lead?.evo_agent_accountid) { + CrmService.getCRMOptions<'accountOptions', IAccount>({ + query: gql` + query selectIndAgent($evo_agent_accountid: Uuid!) { + accountOptions: account(accountid: $evo_agent_accountid) { + accountid + name } - `, - variables: { - leadid: leadid, - }, - toOptions: ['quote'], - }).then(({ entities }) => { - if ( - entities.quote && - Array.isArray(entities.quote) && - entities.quote.length > 0 + } + `, + variables: { + evo_agent_accountid: lead.evo_agent_accountid, + }, + }).then(({ accountOptions }) => { + if (accountOptions && accountOptions.length > 0) { + calculationStore.setOptions('selectIndAgent', accountOptions); + calculationStore.setValue('indAgent', accountOptions[0].accountid); + } else { + calculationStore.setValue('indAgent', null); + calculationStore.setOptions('selectIndAgent', []); + } + }); + } else { + calculationStore.setValue('indAgent', null); + calculationStore.setOptions('selectIndAgent', []); + } + + if (lead?.evo_double_agent_accountid) { + CrmService.getCRMOptions<'accountOptions', IAccount>({ + query: gql` + query selectCalcDoubleAgent($evo_double_agent_accountid: Uuid!) { + accountOptions: account(accountid: $evo_double_agent_accountid) { + accountid + name + } + } + `, + variables: { + evo_double_agent_accountid: lead.evo_double_agent_accountid, + }, + }).then(({ accountOptions }) => { + if (accountOptions && accountOptions.length > 0) { + calculationStore.setOptions( + 'selectCalcDoubleAgent', + accountOptions, + ); + calculationStore.setValue( + 'calcDoubleAgent', + accountOptions[0].accountid, + ); + } else { + calculationStore.setValue('calcDoubleAgent', null); + calculationStore.setOptions('selectCalcDoubleAgent', []); + } + }); + } else { + calculationStore.setValue('calcDoubleAgent', null); + calculationStore.setOptions('selectCalcDoubleAgent', []); + } + + if (lead?.evo_broker_accountid) { + CrmService.getCRMOptions<'accountOptions', IAccount>({ + query: gql` + query selectCalcBroker($evo_broker_accountid: Uuid!) { + accountOptions: account(accountid: $evo_broker_accountid) { + accountid + name + } + } + `, + variables: { + evo_broker_accountid: lead.evo_broker_accountid, + }, + }).then(({ accountOptions }) => { + if (accountOptions && accountOptions.length > 0) { + calculationStore.setOptions('selectCalcBroker', accountOptions); + calculationStore.setValue( + 'calcBroker', + accountOptions[0].accountid, + ); + } + }); + } else { + calculationStore.setValue('calcBroker', null); + calculationStore.setOptions('selectCalcBroker', []); + } + + if (lead?.evo_fin_department_accountid) { + CrmService.getCRMOptions<'accountOptions', IAccount>({ + query: gql` + query selectCalcFinDepartment( + $evo_fin_department_accountid: Uuid! ) { - calculationStore.setOptions('selectQuote', entities.quote); - calculationStore.setValue('quote', null); - } else { - calculationStore.setOptions('selectQuote', []); - calculationStore.setValue('quote', null); - } - }); - } else { - calculationStore.setOptions('selectQuote', []); - calculationStore.setValue('quote', null); - } - - if (lead.evo_agent_accountid) { - CrmService.crmgqlquery({ - query: gql` - query($evo_agent_accountid: Uuid!) { - account(accountid: $evo_agent_accountid) { - accountid - name - } - } - `, - variables: { - evo_agent_accountid: lead.evo_agent_accountid, - }, - toOptions: ['account'], - }).then(({ entities }) => { - if (entities.account) { - if (!Array.isArray(entities.account)) { - calculationStore.setOptions('selectIndAgent', [ - entities.account, - ]); - calculationStore.setValue( - 'indAgent', - entities.account.accountid, - ); - } - } else { - calculationStore.setValue('indAgent', null); - calculationStore.setOptions('selectIndAgent', []); - } - }); - } else { - calculationStore.setValue('indAgent', null); - calculationStore.setOptions('selectIndAgent', []); - } - - if (lead.evo_double_agent_accountid) { - CrmService.crmgqlquery({ - query: gql` - query($evo_double_agent_accountid: Uuid!) { - account(accountid: $evo_double_agent_accountid) { - accountid - name - } - } - `, - variables: { - evo_double_agent_accountid: lead.evo_double_agent_accountid, - }, - toOptions: ['account'], - }).then(({ entities }) => { - if (entities.account) { - if (!Array.isArray(entities.account)) { - calculationStore.setOptions('selectCalcDoubleAgent', [ - entities.account, - ]); - calculationStore.setValue( - 'calcDoubleAgent', - entities.account.accountid, - ); - } - } else { - calculationStore.setValue('calcDoubleAgent', null); - calculationStore.setOptions('selectCalcDoubleAgent', []); - } - }); - } else { - calculationStore.setValue('calcDoubleAgent', null); - calculationStore.setOptions('selectCalcDoubleAgent', []); - } - - if (lead.evo_broker_accountid) { - CrmService.crmgqlquery({ - query: gql` - query($evo_broker_accountid: Uuid!) { - account(accountid: $evo_broker_accountid) { - accountid - name - } - } - `, - variables: { - evo_broker_accountid: lead.evo_broker_accountid, - }, - toOptions: ['account'], - }).then(({ entities }) => { - if (entities.account) { - if (!Array.isArray(entities.account)) { - calculationStore.setOptions('selectCalcBroker', [ - entities.account, - ]); - calculationStore.setValue( - 'calcBroker', - entities.account.accountid, - ); + accountOptions: account( + accountid: $evo_fin_department_accountid + ) { + accountid + name } } - }); - } else { - calculationStore.setValue('calcBroker', null); - calculationStore.setOptions('selectCalcBroker', []); - } - - if (lead.evo_fin_department_accountid) { - CrmService.crmgqlquery({ - query: gql` - query($evo_fin_department_accountid: Uuid!) { - account(accountid: $evo_fin_department_accountid) { - accountid - name - } - } - `, - variables: { - evo_fin_department_accountid: lead.evo_fin_department_accountid, - }, - toOptions: ['account'], - }).then(({ entities }) => { - if (entities.account) { - if (!Array.isArray(entities.account)) { - calculationStore.setOptions('selectCalcFinDepartment', [ - entities.account, - ]); - calculationStore.setValue( - 'calcFinDepartment', - entities.account.accountid, - ); - } - } - }); - } else { - calculationStore.setValue('calcFinDepartment', null); - calculationStore.setOptions('selectCalcFinDepartment', []); - } + `, + variables: { + evo_fin_department_accountid: lead.evo_fin_department_accountid, + }, + }).then(({ accountOptions }) => { + if (accountOptions && accountOptions.length > 0) { + calculationStore.setOptions( + 'selectCalcFinDepartment', + accountOptions, + ); + calculationStore.setValue( + 'calcFinDepartment', + accountOptions[0].accountid, + ); + } + }); + } else { + calculationStore.setValue('calcFinDepartment', null); + calculationStore.setOptions('selectCalcFinDepartment', []); } }, }), @@ -235,24 +213,20 @@ export default [ ); } else { if (opportunity.parentaccountid) - CrmService.crmgqlquery({ + CrmService.getCRMEntities<'account', IAccount, IAccount>({ query: gql` - query($accountid: Uuid!) { + query clientRisk_1($accountid: Uuid!) { account(accountid: $accountid) { evo_client_riskid } } `, variables: { accountid: opportunity.parentaccountid }, - }).then(({ entities }) => { - if ( - entities.account && - !Array.isArray(entities.account) && - entities.account.evo_client_riskid - ) + }).then(({ account }) => { + if (account?.evo_client_riskid) calculationStore.setValue( 'clientRisk', - entities.account.evo_client_riskid, + account.evo_client_riskid, ); }); } @@ -262,24 +236,20 @@ export default [ leadid, }); if (lead && lead.customerid) { - CrmService.crmgqlquery({ + CrmService.getCRMEntities<'account', IAccount, IAccount>({ query: gql` - query($customerid: Uuid!) { + query clientRisk_2($customerid: Uuid!) { account(accountid: $customerid) { evo_client_riskid } } `, variables: { customerid: lead.customerid }, - }).then(({ entities }) => { - if ( - entities.account && - !Array.isArray(entities.account) && - entities.account.evo_client_riskid - ) + }).then(({ account }) => { + if (account?.evo_client_riskid) calculationStore.setValue( 'clientRisk', - entities.account.evo_client_riskid, + account.evo_client_riskid, ); }); } @@ -327,14 +297,14 @@ export default [ ); if (indAgentId && !calculationProcess.hasProcess(Process.LoadKp)) - CrmService.crmgqlquery({ + CrmService.getCRMOptions<'evo_reward_conditions'>({ query: gql` - query( + query selectIndAgentRewardCondition( $statecode: Int $currentDate: DateTime $evo_agent_accountid: Uuid ) { - evo_reward_condition: evo_reward_conditions( + evo_reward_conditions( evo_agent_accountid: $evo_agent_accountid evo_datefrom_param: { lte: $currentDate } evo_dateto_param: { gte: $currentDate } @@ -353,12 +323,11 @@ export default [ currentDate: currentISODate, statecode: 0, }, - toOptions: ['evo_reward_condition'], - }).then(({ entities: { evo_reward_condition } }) => { - if (evo_reward_condition && Array.isArray(evo_reward_condition)) + }).then(({ evo_reward_conditions }) => { + if (evo_reward_conditions) calculationStore.setOptions( 'selectIndAgentRewardCondition', - evo_reward_condition, + evo_reward_conditions, ); }); } @@ -388,14 +357,17 @@ export default [ ); if (doubleAgentId && !calculationProcess.hasProcess(Process.LoadKp)) - CrmService.crmgqlquery({ + CrmService.getCRMOptions< + 'evo_reward_conditions', + IEvoRewardCondition + >({ query: gql` - query( + query selectCalcDoubleAgentRewardCondition( $statecode: Int $currentDate: DateTime $evo_agent_accountid: Uuid ) { - evo_reward_condition: evo_reward_conditions( + evo_reward_conditions( evo_agent_accountid: $evo_agent_accountid evo_datefrom_param: { lte: $currentDate } evo_dateto_param: { gte: $currentDate } @@ -413,12 +385,11 @@ export default [ currentDate: currentISODate, statecode: 0, }, - toOptions: ['evo_reward_condition'], - }).then(({ entities: { evo_reward_condition } }) => { - if (evo_reward_condition && Array.isArray(evo_reward_condition)) + }).then(({ evo_reward_conditions }) => { + if (evo_reward_conditions) calculationStore.setOptions( 'selectCalcDoubleAgentRewardCondition', - evo_reward_condition, + evo_reward_conditions, ); }); } @@ -450,14 +421,17 @@ export default [ ElementStatus.Default, ); if (calcFinDepartmentId) - CrmService.crmgqlquery({ + CrmService.getCRMOptions< + 'evo_reward_conditions', + IEvoRewardCondition + >({ query: gql` - query( + query selectFinDepartmentRewardCondtion( $statecode: Int $currentDate: DateTime $evo_agent_accountid: Uuid ) { - evo_reward_condition: evo_reward_conditions( + evo_reward_conditions( evo_agent_accountid: $evo_agent_accountid evo_datefrom_param: { lte: $currentDate } evo_dateto_param: { gte: $currentDate } @@ -475,12 +449,11 @@ export default [ currentDate: currentISODate, statecode: 0, }, - toOptions: ['evo_reward_condition'], - }).then(({ entities: { evo_reward_condition } }) => { - if (evo_reward_condition && Array.isArray(evo_reward_condition)) + }).then(({ evo_reward_conditions }) => { + if (evo_reward_conditions) calculationStore.setOptions( 'selectFinDepartmentRewardCondtion', - evo_reward_condition, + evo_reward_conditions, ); }); } @@ -510,14 +483,17 @@ export default [ ); if (calcBrokerId && !calculationProcess.hasProcess(Process.LoadKp)) - CrmService.crmgqlquery({ + CrmService.getCRMOptions< + 'evo_reward_conditions', + IEvoRewardCondition + >({ query: gql` - query( + query selectCalcBrokerRewardCondition( $statecode: Int $currentDate: DateTime $evo_agent_accountid: Uuid ) { - evo_reward_condition: evo_reward_conditions( + evo_reward_conditions( evo_agent_accountid: $evo_agent_accountid evo_datefrom_param: { lte: $currentDate } evo_dateto_param: { gte: $currentDate } @@ -535,12 +511,11 @@ export default [ currentDate: currentISODate, statecode: 0, }, - toOptions: ['evo_reward_condition'], - }).then(({ entities: { evo_reward_condition } }) => { - if (evo_reward_condition && Array.isArray(evo_reward_condition)) + }).then(({ evo_reward_conditions }) => { + if (evo_reward_conditions) calculationStore.setOptions( 'selectCalcBrokerRewardCondition', - evo_reward_condition, + evo_reward_conditions, ); }); } @@ -564,10 +539,13 @@ export default [ accountid: dealerId, }); if (dealer) { - CrmService.crmgqlquery({ + CrmService.getCRMOptions<'salon_providers', ISalonProvider>({ query: gql` - query($statecode: Int, $salonaccountid: Uuid!) { - selectDealerPerson: salon_providers( + query selectDealerPerson( + $statecode: Int + $salonaccountid: Uuid! + ) { + salon_providers( statecode: $statecode salonaccountid: $salonaccountid ) { @@ -579,23 +557,19 @@ export default [ } } `, - toOptions: ['selectDealerPerson'], variables: { salonaccountid: dealerId, statecode: 0, }, - }).then(({ entities }) => { - // @ts-ignore - const dealerPersons = entities.selectDealerPerson; - if ( - dealerPersons && - Array.isArray(dealerPersons) && - dealerPersons.length > 0 - ) { - calculationStore.setOptions('selectDealerPerson', dealerPersons); + }).then(({ salon_providers }) => { + if (salon_providers && salon_providers.length > 0) { + calculationStore.setOptions( + 'selectDealerPerson', + salon_providers, + ); calculationStore.setValue( 'dealerPerson', - dealerPersons[0].accountid, + salon_providers[0].accountid, ); calculationStore.setStatus( 'selectDealerPerson', @@ -633,27 +607,24 @@ export default [ accountid: dealerPersonId, }); if (dealerPerson && dealerPerson.evo_broker_accountid) { - CrmService.crmgqlquery({ + CrmService.getCRMOptions<'accountOptions', IAccount>({ query: gql` - query($accountid: Uuid!) { - account(accountid: $accountid) { + query selectDealerBroker($accountid: Uuid!) { + accountOptions: account(accountid: $accountid) { accountid name } } `, - toOptions: ['account'], variables: { accountid: dealerPerson.evo_broker_accountid, }, - }).then(({ entities }) => { - if (entities.account && !Array.isArray(entities.account)) { - calculationStore.setOptions('selectDealerBroker', [ - entities.account, - ]); + }).then(({ accountOptions }) => { + if (accountOptions && accountOptions.length > 0) { + calculationStore.setOptions('selectDealerBroker', accountOptions); calculationStore.setValue( 'dealerBroker', - entities.account.accountid, + accountOptions[0].accountid, ); calculationStore.setStatus( 'selectDealerBroker', @@ -686,14 +657,17 @@ export default [ ); if (!calculationProcess.hasProcess(Process.LoadKp)) - CrmService.crmgqlquery({ + CrmService.getCRMOptions< + 'evo_reward_conditions', + IEvoRewardCondition + >({ query: gql` - query( + query selectDealerBrokerRewardCondition( $statecode: Int $currentDate: DateTime $evo_agent_accountid: Uuid ) { - evo_reward_condition: evo_reward_conditions( + evo_reward_conditions( evo_agent_accountid: $evo_agent_accountid evo_datefrom_param: { lte: $currentDate } evo_dateto_param: { gte: $currentDate } @@ -711,12 +685,11 @@ export default [ currentDate: currentISODate, statecode: 0, }, - toOptions: ['evo_reward_condition'], - }).then(({ entities: { evo_reward_condition } }) => { - if (evo_reward_condition && Array.isArray(evo_reward_condition)) + }).then(({ evo_reward_conditions }) => { + if (evo_reward_conditions) calculationStore.setOptions( 'selectDealerBrokerRewardCondition', - evo_reward_condition, + evo_reward_conditions, ); }); } @@ -745,14 +718,17 @@ export default [ ElementStatus.Default, ); if (!calculationProcess.hasProcess(Process.LoadKp)) - CrmService.crmgqlquery({ + CrmService.getCRMOptions< + 'evo_reward_conditions', + IEvoRewardCondition + >({ query: gql` - query( + query selectDealerRewardCondition( $statecode: Int $currentDate: DateTime $evo_agent_accountid: Uuid ) { - evo_reward_condition: evo_reward_conditions( + evo_reward_conditions( evo_agent_accountid: $evo_agent_accountid evo_datefrom_param: { lte: $currentDate } evo_dateto_param: { gte: $currentDate } @@ -770,12 +746,11 @@ export default [ currentDate: currentISODate, statecode: 0, }, - toOptions: ['evo_reward_condition'], - }).then(({ entities: { evo_reward_condition } }) => { - if (evo_reward_condition && Array.isArray(evo_reward_condition)) + }).then(({ evo_reward_conditions }) => { + if (evo_reward_conditions) calculationStore.setOptions( 'selectDealerRewardCondition', - evo_reward_condition, + evo_reward_conditions, ); }); } else { @@ -805,13 +780,10 @@ export default [ calculationStore.setValue('model', null); if (brandId) { - CrmService.crmgqlquery({ + CrmService.getCRMOptions<'evo_models', IEvoModel>({ query: gql` - query($statecode: Int, $evo_brandid: Uuid) { - evo_model: evo_models( - statecode: $statecode - evo_brandid: $evo_brandid - ) { + query selectModel($statecode: Int, $evo_brandid: Uuid) { + evo_models(statecode: $statecode, evo_brandid: $evo_brandid) { evo_id evo_name evo_modelid @@ -832,14 +804,9 @@ export default [ statecode: 0, evo_brandid: brandId, }, - toOptions: ['evo_model'], - }).then(({ entities }) => { - if ( - entities.evo_model && - Array.isArray(entities.evo_model) && - entities.evo_model.length > 0 - ) { - calculationStore.setOptions('selectModel', entities.evo_model); + }).then(({ evo_models }) => { + if (evo_models) { + calculationStore.setOptions('selectModel', evo_models); calculationStore.setValue('model', null); } }); @@ -866,10 +833,10 @@ export default [ evo_modelid: modelId, }); if (model) { - CrmService.crmgqlquery({ + CrmService.getCRMOptions<'evo_equipments', IEvoEquipment>({ query: gql` - query($statecode: Int, $evo_modelid: Uuid) { - evo_equipment: evo_equipments( + query selectConfiguration($statecode: Int, $evo_modelid: Uuid) { + evo_equipments( statecode: $statecode evo_modelid: $evo_modelid ) { @@ -881,24 +848,19 @@ export default [ } } `, - toOptions: ['evo_equipment'], variables: { statecode: 0, evo_modelid: modelId, }, - }).then(({ entities }) => { - if ( - entities.evo_equipment && - Array.isArray(entities.evo_equipment) && - entities.evo_equipment.length > 0 - ) { + }).then(({ evo_equipments }) => { + if (evo_equipments) { calculationStore.setStatus( 'selectConfiguration', ElementStatus.Default, ); calculationStore.setOptions( 'selectConfiguration', - entities.evo_equipment, + evo_equipments, ); } }); @@ -926,24 +888,24 @@ export default [ accountid: supplierId, }); if (supplier && supplier.evo_fin_department_accountid) - CrmService.crmgqlquery({ + CrmService.getCRMOptions<'accountOptions', IAccount>({ query: gql` - query($accountid: Uuid!) { - account(accountid: $accountid) { + query selectFinDepartment($accountid: Uuid!) { + accountOptions: account(accountid: $accountid) { accountid name } } `, - toOptions: ['account'], variables: { accountid: supplier.evo_fin_department_accountid, }, - }).then(({ entities }) => { - if (entities.account && !Array.isArray(entities.account)) { - calculationStore.setOptions('selectFinDepartment', [ - entities.account, - ]); + }).then(({ accountOptions }) => { + if (accountOptions) { + calculationStore.setOptions( + 'selectFinDepartment', + accountOptions, + ); } }); } @@ -962,14 +924,14 @@ export default [ calculationStore.setOptions('selectAgent', []); calculationStore.setValue('agent', null); if (channelId === 100000002) { - CrmService.crmgqlquery({ + CrmService.getCRMOptions<'accountOptions', IAccount>({ query: gql` - query( + query selectAgent_1( $statecode: Int $evo_account_type: [Int!] $evo_legal_form: Int ) { - account: accounts( + accountOptions: accounts( statecode: $statecode evo_account_type: $evo_account_type evo_legal_form: $evo_legal_form @@ -979,22 +941,21 @@ export default [ } } `, - toOptions: ['account'], variables: { statecode: 0, evo_account_type: [100000005], evo_legal_form: 100000004, }, - }).then(({ entities }) => { - if (entities.account && Array.isArray(entities.account)) { - calculationStore.setOptions('selectAgent', entities.account); + }).then(({ accountOptions }) => { + if (accountOptions) { + calculationStore.setOptions('selectAgent', accountOptions); } }); } else { if (supplierId) { - CrmService.crmgqlquery({ + CrmService.getCRMOptions<'accountOptions', IAccount>({ query: gql` - query($statecode: Int, $salonaccountid: Uuid!) { + query selectAgent_2($statecode: Int, $salonaccountid: Uuid!) { account: salon_agents( statecode: $statecode salonaccountid: $salonaccountid @@ -1004,14 +965,13 @@ export default [ } } `, - toOptions: ['account'], variables: { statecode: 0, salonaccountid: supplierId, }, - }).then(({ entities }) => { - if (entities.account && Array.isArray(entities.account)) { - calculationStore.setOptions('selectAgent', entities.account); + }).then(({ accountOptions }) => { + if (accountOptions) { + calculationStore.setOptions('selectAgent', accountOptions); } }); } @@ -1037,10 +997,10 @@ export default [ evo_gps_brandid: GPSBrandId, }); if (gpsBrand) { - CrmService.crmgqlquery({ + CrmService.getCRMOptions<'evo_gps_models', IEvoGPSModel>({ query: gql` - query($statecode: Int, $evo_gps_brandid: Uuid) { - evo_gps_model: evo_gps_models( + query selectGPSModel($statecode: Int, $evo_gps_brandid: Uuid) { + evo_gps_models( statecode: $statecode evo_gps_brandid: $evo_gps_brandid ) { @@ -1054,21 +1014,13 @@ export default [ statecode: 0, evo_gps_brandid: GPSBrandId, }, - toOptions: ['evo_gps_model'], - }).then(({ entities }) => { - if ( - entities.evo_gps_model && - Array.isArray(entities.evo_gps_model) && - entities.evo_gps_model.length > 0 - ) { + }).then(({ evo_gps_models }) => { + if (evo_gps_models) { calculationStore.setStatus( 'selectGPSModel', ElementStatus.Default, ); - calculationStore.setOptions( - 'selectGPSModel', - entities.evo_gps_model, - ); + calculationStore.setOptions('selectGPSModel', evo_gps_models); calculationStore.setValue('GPSModel', null); } }); @@ -1101,13 +1053,13 @@ export default [ }, ); if (regionRegistration) { - CrmService.crmgqlquery({ + CrmService.getCRMOptions<'evo_towns', IEvoTown>({ query: gql` - query($statecode: Int, $evo_regionid: Uuid) { - evo_town: evo_towns( - statecode: $statecode - evo_regionid: $evo_regionid - ) { + query selectTownRegistration( + $statecode: Int + $evo_regionid: Uuid + ) { + evo_towns(statecode: $statecode, evo_regionid: $evo_regionid) { evo_name evo_townid evo_fias_id @@ -1120,21 +1072,13 @@ export default [ statecode: 0, evo_regionid: regionRegistrationId, }, - toOptions: ['evo_town'], - }).then(({ entities }) => { - if ( - entities.evo_town && - Array.isArray(entities.evo_town) && - entities.evo_town.length > 0 - ) { + }).then(({ evo_towns }) => { + if (evo_towns) { // calculationStore.setStatus( // 'selectTownRegistration', // ElementStatus.Default, // ); - calculationStore.setOptions( - 'selectTownRegistration', - entities.evo_town, - ); + calculationStore.setOptions('selectTownRegistration', evo_towns); // calculationStore.setValue('townRegistration', null); } }); @@ -1167,13 +1111,13 @@ export default [ }, ); if (regionRegistration) { - CrmService.crmgqlquery({ + CrmService.getCRMOptions<'evo_towns', IEvoTown>({ query: gql` - query($statecode: Int, $evo_regionid: Uuid) { - evo_town: evo_towns( - statecode: $statecode - evo_regionid: $evo_regionid - ) { + query selectLegalClientTown( + $statecode: Int + $evo_regionid: Uuid + ) { + evo_towns(statecode: $statecode, evo_regionid: $evo_regionid) { evo_name evo_townid evo_fias_id @@ -1185,21 +1129,13 @@ export default [ statecode: 0, evo_regionid: legalClientRegionId, }, - toOptions: ['evo_town'], - }).then(({ entities }) => { - if ( - entities.evo_town && - Array.isArray(entities.evo_town) && - entities.evo_town.length > 0 - ) { + }).then(({ evo_towns }) => { + if (evo_towns) { // calculationStore.setStatus( // 'selectLegalClientTown', // ElementStatus.Default, // ); - calculationStore.setOptions( - 'selectLegalClientTown', - entities.evo_town, - ); + calculationStore.setOptions('selectLegalClientTown', evo_towns); // calculationStore.setValue('legalClientTown', null); } }); diff --git a/src/client/stores/CalculationStore/config/initialOptions.ts b/src/client/stores/CalculationStore/config/initialOptions.ts index b4326f9..5f464d2 100644 --- a/src/client/stores/CalculationStore/config/initialOptions.ts +++ b/src/client/stores/CalculationStore/config/initialOptions.ts @@ -1,5 +1,5 @@ +import { IBaseOption } from 'core/services/CrmService/types/common'; import { TElements } from 'core/types/Calculation/Store/elements'; -import { IBaseOption } from 'core/types/Calculation/Store/options'; import { orderBy } from 'lodash'; const initialOptions: TElements = { diff --git a/src/client/stores/CalculationStore/index.ts b/src/client/stores/CalculationStore/index.ts index ab6ca73..d0d0017 100644 --- a/src/client/stores/CalculationStore/index.ts +++ b/src/client/stores/CalculationStore/index.ts @@ -8,12 +8,13 @@ import autorunEffects from './Effects/autorun'; import computedEffects from './Effects/computed'; import reactionEffects from './Effects/reactions'; import whenEffects from './Effects/when'; +import init from './init'; import subStores from './subStores'; const { calculationProcess } = subStores; const CalculationStore: ICalculationStore = makeAutoObservable( - Object.assign({}, staticData, values, tables, computedEffects, { + Object.assign({ init }, staticData, values, tables, computedEffects, { stores: subStores, }), ); diff --git a/src/client/stores/CalculationStore/init/index.ts b/src/client/stores/CalculationStore/init/index.ts new file mode 100644 index 0000000..5177dcd --- /dev/null +++ b/src/client/stores/CalculationStore/init/index.ts @@ -0,0 +1,54 @@ +import { ICalculationStore } from 'core/types/Calculation/Store'; +import { Process } from 'core/types/Calculation/Store/process'; +import initialOptions from '../config/initialOptions'; +import initialValues from '../config/initialValues'; +import { composeRequests } from './requests'; + +export default async function (this: ICalculationStore) { + const { calculationProcess } = this.stores; + calculationProcess.addProcess(Process.Init); + + const { + ownerOptionsRequest, + mainOptionsRequest, + staticDataRequest, + systemUserRequest, + insuranceRequest, + } = composeRequests(); + + const ownerOptions = await ownerOptionsRequest; + const mainOptions = await mainOptionsRequest; + this.applyOptions(Object.assign(initialOptions, ownerOptions, mainOptions)); + + const systemuser = await systemUserRequest; + const staticEntities = await staticDataRequest; + this.applyStaticData(Object.assign({ systemuser }, staticEntities)); + + const insuranceData = await insuranceRequest; + this.setTableColumns('tableInsurance')({ + options: insuranceData, + }); + + this.setValues(initialValues, true); + + const supplierCurrency = this.options.selectSupplierCurrency?.find( + x => x.isocurrencycode === 'RUB', + ); + this.setValue('supplierCurrency', supplierCurrency?.transactioncurrencyid); + + const evo_sot_coefficient_type = staticEntities?.evo_sot_coefficient_type?.find( + x => x.evo_id === 'BONUS_LEASING', + ); + + const evo_coefficient_bonus = staticEntities?.evo_coefficient?.find( + x => + x.evo_job_titleid === systemuser[0]?.evo_job_titleid && + x.evo_sot_coefficient_typeid === + evo_sot_coefficient_type?.evo_sot_coefficient_typeid, + ); + + if (evo_coefficient_bonus?.evo_sot_coefficient) + this.setValue('saleBonus', evo_coefficient_bonus.evo_sot_coefficient * 100); + + calculationProcess.deleteProcess(Process.Init); +} diff --git a/src/client/stores/CalculationStore/init/requests.ts b/src/client/stores/CalculationStore/init/requests.ts new file mode 100644 index 0000000..cabb2a9 --- /dev/null +++ b/src/client/stores/CalculationStore/init/requests.ts @@ -0,0 +1,77 @@ +import UserStore from 'client/stores/UserStore'; +import { + getInsuranceOptionsQuery, + getMainOptionsQuery, + getOwnerOptionsQuery, +} from 'core/graphql/query/crm/options'; +import { + getStaticDataQuery, + getSystemUserQuery, +} from 'core/graphql/query/crm/staticData'; +import CrmService from 'core/services/CrmService'; +import { ElementsNames } from 'core/types/Calculation/Store/elements'; +import { TableValuesNames } from 'core/types/Calculation/Store/tables'; +import { + IAccount, + ILead, + IOpportunity, + ISystemUser, + TCRMEntity, +} from 'core/types/Entities/crmEntities'; +import { CRMEntityNames } from 'core/types/Entities/crmEntityNames'; +import { + insuranceVariables, + mainOptionsVariables, + staticDataVariables, +} from './variables'; + +export function composeRequests() { + const mainOptionsRequest = CrmService.getCRMOptions({ + query: getMainOptionsQuery, + variables: mainOptionsVariables, + }); + + const staticDataRequest = CrmService.getCRMEntities< + CRMEntityNames, + TCRMEntity[] + >({ + query: getStaticDataQuery, + variables: staticDataVariables, + }); + + const domainname = UserStore.getDomainName(); + + const systemUserRequest = CrmService.getCRMEntities< + CRMEntityNames, + ISystemUser + >({ + query: getSystemUserQuery, + variables: { domainname }, + }); + + const ownerOptionsRequest = CrmService.getCRMOptions< + ElementsNames, + ILead & IOpportunity + >({ + query: getOwnerOptionsQuery, + variables: { + statecode: 0, + domainname, + }, + }); + + const insuranceRequest = CrmService.getCRMOptions( + { + query: getInsuranceOptionsQuery, + variables: insuranceVariables, + }, + ); + + return { + mainOptionsRequest, + staticDataRequest, + systemUserRequest, + insuranceRequest, + ownerOptionsRequest, + }; +} diff --git a/src/client/stores/CalculationStore/init/variables.ts b/src/client/stores/CalculationStore/init/variables.ts new file mode 100644 index 0000000..f356ce7 --- /dev/null +++ b/src/client/stores/CalculationStore/init/variables.ts @@ -0,0 +1,31 @@ +import { OperationVariables } from '@apollo/client'; +import { GQLVariables } from 'core/services/CrmService/types/request'; +import { currentISODate } from 'core/tools/date'; +import { IAccount, TCRMEntity } from 'core/types/Entities/crmEntities'; + +export const mainOptionsVariables: OperationVariables = { + currentDate: currentISODate, + statecode: 0, + supplier_account_type: [100000001], + supplier_legal_form: 100000001, + dealer_account_type: [100000001], + dealer_legal_form: 100000001, + account_account_type: [100000000], + product_relation: [100000000], + registration_product_type: 100000001, + nsib_product_type: 100000002, + tracker_product_type: 100000003, + telematic_product_type: 100000004, + techcard_product_type: 100000000, + fuelcard_product_type: 100000005, +}; + +export const insuranceVariables: GQLVariables = { + evo_account_type: [100000002], + statecode: 0, +}; + +export const staticDataVariables: GQLVariables = { + statecode: 0, + currentDate: currentISODate, +}; diff --git a/src/client/stores/UserStore/index.js b/src/client/stores/UserStore/index.js index 901f912..f7044f0 100644 --- a/src/client/stores/UserStore/index.js +++ b/src/client/stores/UserStore/index.js @@ -1,11 +1,23 @@ +import UserService from 'core/services/UserService'; import { makeAutoObservable } from 'mobx'; +import { __getUserFromLocalStorage } from './lib/user'; const UserStore = makeAutoObservable({ + async init() { + let user; + if (process.env.NODE_ENV === 'development') { + user = __getUserFromLocalStorage(); + } else { + user = await UserService.fetchUser(); + } + this.setUser(user); + }, user: undefined, setUser(user) { this.user = user; }, getDomainName() { + if (!this.user) return ''; const { username, domain } = this.user; return `${domain}\\${username}`; }, diff --git a/src/client/stores/UserStore/lib/user.js b/src/client/stores/UserStore/lib/user.js new file mode 100644 index 0000000..a7b764a --- /dev/null +++ b/src/client/stores/UserStore/lib/user.js @@ -0,0 +1,12 @@ +export function __getUserFromLocalStorage() { + const user = ['username', 'domain'].reduce((acc, propName) => { + let prop = localStorage.getItem(propName); + if (!prop) { + prop = prompt('Enter ' + propName); + localStorage.setItem(propName, prop); + } + acc[propName] = prop; + return acc; + }, {}); + return user; +} diff --git a/src/core/services/CrmService/client.ts b/src/core/graphql/client.ts similarity index 100% rename from src/core/services/CrmService/client.ts rename to src/core/graphql/client.ts diff --git a/src/core/graphql/query/crm/fragments/evo_addproduct_types_fields.graphql b/src/core/graphql/query/crm/fragments/evo_addproduct_types_fields.graphql new file mode 100644 index 0000000..f74bfec --- /dev/null +++ b/src/core/graphql/query/crm/fragments/evo_addproduct_types_fields.graphql @@ -0,0 +1,15 @@ +fragment evo_addproduct_types_fields on evo_addproduct_type { + evo_id + evo_name + evo_addproduct_typeid + evo_product_type + evo_accountid + evo_graph_price_withoutnds + evo_cost_service_provider_withoutnds + evo_retro_bonus_withoutnds + evo_prime_cost + evo_graph_price + evo_max_period + evo_min_period + evo_controls_program +} diff --git a/src/core/graphql/query/crm/fragments/evo_regions_fields.graphql b/src/core/graphql/query/crm/fragments/evo_regions_fields.graphql new file mode 100644 index 0000000..6a02570 --- /dev/null +++ b/src/core/graphql/query/crm/fragments/evo_regions_fields.graphql @@ -0,0 +1,8 @@ +fragment evo_region_fields on evo_region { + evo_name + evo_regionid + evo_fias_id + evo_businessunit_evolution + evo_oktmo + evo_kladr_id +} diff --git a/src/core/graphql/query/crm/options/getInsuranceOptions.graphql b/src/core/graphql/query/crm/options/getInsuranceOptions.graphql new file mode 100644 index 0000000..9589745 --- /dev/null +++ b/src/core/graphql/query/crm/options/getInsuranceOptions.graphql @@ -0,0 +1,14 @@ +query GetInsuranceOptions($evo_account_type: [Int!], $statecode: Int) { + insuranceCompany: accounts( + evo_account_type: $evo_account_type + statecode: $statecode + ) { + accountid + name + evo_type_ins_policy + evo_id_elt + evo_id_elt_smr + evo_id_elt_osago + evo_legal_region_calc + } +} diff --git a/src/core/graphql/query/crm/options/getMainOptions.graphql b/src/core/graphql/query/crm/options/getMainOptions.graphql new file mode 100644 index 0000000..afae54a --- /dev/null +++ b/src/core/graphql/query/crm/options/getMainOptions.graphql @@ -0,0 +1,265 @@ +#import '../fragments/evo_regions_fields.graphql' +#import '../fragments/evo_addproduct_types_fields.graphql' + +query GetMainOptions( + $statecode: Int + $currentDate: DateTime + $supplier_account_type: [Int!] + $supplier_legal_form: Int + $dealer_account_type: [Int!] + $dealer_legal_form: Int + $account_account_type: [Int!] + $product_relation: [Int!] + $registration_product_type: Int + $nsib_product_type: Int + $tracker_product_type: Int + $telematic_product_type: Int + $fuelcard_product_type: Int + $techcard_product_type: Int +) { + selectSupplier: accounts( + evo_account_type: $supplier_account_type + statecode: $statecode + evo_legal_form: $supplier_legal_form + ) { + name + accountid + evo_fin_department_accountid + } + selectSupplierCurrency: transactioncurrencies(statecode: $statecode) { + transactioncurrencyid + isocurrencycode + } + selectClientRisk: evo_client_risks(statecode: $statecode) { + evo_name + evo_client_riskid + evo_id + } + selectClientType: evo_client_types(statecode: $statecode) { + evo_name + evo_client_typeid + } + selectDealer: accounts( + evo_account_type: $dealer_account_type + statecode: $statecode + evo_legal_form: $dealer_legal_form + ) { + name + accountid + } + selectGPSBrand: evo_gps_brands(statecode: $statecode) { + evo_name + evo_gps_brandid + } + selectRegionRegistration: evo_regions(statecode: $statecode) { + ...evo_region_fields + } + selectLegalClientRegion: evo_regions(statecode: $statecode) { + ...evo_region_fields + } + selectAccount: accounts( + evo_account_type: $account_account_type + statecode: $statecode + ) { + name + accountid + evo_client_riskid + } + selectBrand: evo_brands(statecode: $statecode) { + evo_id + evo_name + evo_brandid + evo_brand_owner + evo_importer_reward_perc + evo_importer_reward_rub + evo_vehicle_type + } + selectProduct: evo_baseproducts( + statecode: $statecode + evo_relation: $product_relation + evo_datefrom_param: { lte: $currentDate } + evo_dateto_param: { gte: $currentDate } + ) { + evo_name + evo_baseproductid + evo_id + evo_leasingobject_types { + evo_name + evo_leasingobject_typeid + evo_id + } + evo_brands { + evo_name + evo_brandid + } + } + selectRegistration: evo_addproduct_types( + statecode: $statecode + evo_product_type: $registration_product_type + evo_datefrom_param: { lte: $currentDate } + evo_dateto_param: { gte: $currentDate } + ) { + ...evo_addproduct_types_fields + evo_towtruck + evo_pts_type + evo_description + evo_gibdd_region + evo_whom_register + } + selectInsNSIB: evo_addproduct_types( + statecode: $statecode + evo_product_type: $nsib_product_type + evo_datefrom_param: { lte: $currentDate } + evo_dateto_param: { gte: $currentDate } + ) { + ...evo_addproduct_types_fields + } + selectTracker: evo_addproduct_types( + statecode: $statecode + evo_product_type: $tracker_product_type + evo_datefrom_param: { lte: $currentDate } + evo_dateto_param: { gte: $currentDate } + ) { + ...evo_addproduct_types_fields + evo_planpayments { + evo_name + evo_cost_equipment_withoutnds + evo_cost_price_telematics_withoutnds + evo_cost_telematics_withoutnds + } + } + selectTelematic: evo_addproduct_types( + statecode: $statecode + evo_product_type: $telematic_product_type + evo_datefrom_param: { lte: $currentDate } + evo_dateto_param: { gte: $currentDate } + ) { + ...evo_addproduct_types_fields + evo_planpayments { + evo_name + evo_cost_equipment_withoutnds + evo_cost_price_telematics_withoutnds + evo_cost_telematics_withoutnds + } + } + selectTechnicalCard: evo_addproduct_types( + statecode: $statecode + evo_product_type: $techcard_product_type + evo_datefrom_param: { lte: $currentDate } + evo_dateto_param: { gte: $currentDate } + ) { + ...evo_addproduct_types_fields + evo_helpcard_type + evo_leasingobject_types { + evo_leasingobject_typeid + } + } + selectTarif: evo_tarifs( + statecode: $statecode + evo_datefrom_param: { lte: $currentDate } + evo_dateto_param: { gte: $currentDate } + ) { + evo_name + evo_tarifid + evo_baseproductid + evo_irr + evo_max_irr + evo_min_profit + evo_min_irr + evo_irr_plan + evo_ins_type + evo_min_period + evo_max_period + evo_client_risks { + evo_name + evo_client_riskid + } + evo_client_types { + evo_name + evo_client_typeid + } + evo_leasingobject_types { + evo_name + evo_id + evo_leasingobject_typeid + } + evo_delivery_time + } + selectRate: evo_rates( + statecode: $statecode + evo_datefrom_param: { lte: $currentDate } + evo_dateto_param: { gte: $currentDate } + ) { + createdon + evo_id + evo_rateid + evo_name + evo_base_rate + evo_coeff_12_23 + evo_coeff_24_35 + evo_coeff_36_47 + evo_coeff_7_11 + evo_coeff_48_60 + evo_tarifs { + evo_tarifid + evo_name + } + evo_credit_period + } + selectLeaseObjectType: evo_leasingobject_types(statecode: $statecode) { + evo_name + evo_id + evo_leasingobject_typeid + evo_depreciation_rate1 + evo_depreciation_rate2 + evo_expluatation_period1 + evo_expluatation_period2 + evo_type_code + evo_category + evo_category_tr + evo_vehicle_type_tax + evo_vehicle_type + } + selectObjectRegionRegistration: evo_regions(statecode: $statecode) { + ...evo_region_fields + accounts { + accountid + } + } + selectSubsidy: evo_subsidies( + statecode: $statecode + evo_datefrom_param: { lte: $currentDate } + evo_dateto_param: { gte: $currentDate } + ) { + evo_name + evo_subsidyid + evo_percent_subsidy + evo_subsidy_summ + evo_max_subsidy_summ + evo_get_subsidy_payment + evo_brands { + evo_brandid + } + evo_models { + evo_modelid + } + evo_leasingobject_types { + evo_leasingobject_typeid + } + accounts { + accountid + } + } + selectFuelCard: evo_addproduct_types( + statecode: $statecode + evo_product_type: $fuelcard_product_type + evo_datefrom_param: { lte: $currentDate } + evo_dateto_param: { gte: $currentDate } + ) { + ...evo_addproduct_types_fields + evo_helpcard_type + evo_leasingobject_types { + evo_leasingobject_typeid + } + } +} diff --git a/src/core/graphql/query/crm/options/getOwnerOptions.graphql b/src/core/graphql/query/crm/options/getOwnerOptions.graphql new file mode 100644 index 0000000..e86a206 --- /dev/null +++ b/src/core/graphql/query/crm/options/getOwnerOptions.graphql @@ -0,0 +1,39 @@ +query GetOwnerOptions($statecode: Int, $domainname: String) { + selectLead: leads(statecode: $statecode, owner_domainname: $domainname) { + customerid + leadid + fullname + evo_opportunityid + evo_agent_accountid + evo_double_agent_accountid + evo_broker_accountid + evo_fin_department_accountid + accountidData { + evo_address_legalidData { + evo_region_fias_id + evo_city_fias_id + } + } + evo_inn + link + } + selectOpportunity: opportunities( + statecode: $statecode + owner_domainname: $domainname + ) { + opportunityid + name + accountid + evo_leadid + evo_client_riskid + parentaccountid + evo_programsolution + accountidData { + evo_address_legalidData { + evo_region_fias_id + evo_city_fias_id + } + } + link + } +} diff --git a/src/core/graphql/query/crm/options/index.js b/src/core/graphql/query/crm/options/index.js new file mode 100644 index 0000000..f78403c --- /dev/null +++ b/src/core/graphql/query/crm/options/index.js @@ -0,0 +1,5 @@ +import { loader } from 'graphql.macro'; + +export const getMainOptionsQuery = loader('./getMainOptions.graphql'); +export const getOwnerOptionsQuery = loader('./getOwnerOptions.graphql'); +export const getInsuranceOptionsQuery = loader('./getInsuranceOptions.graphql'); diff --git a/src/core/graphql/query/crm/quote/fragments/quoteFields.graphql b/src/core/graphql/query/crm/quote/fragments/quoteFields.graphql new file mode 100644 index 0000000..c0bfb78 --- /dev/null +++ b/src/core/graphql/query/crm/quote/fragments/quoteFields.graphql @@ -0,0 +1,126 @@ +#import './quoteFieldsLite.graphql' + +fragment quoteFields on quote { + ...quoteFieldsLite + + evo_addproduct_types { + evo_product_type + evo_addproduct_typeid + } + + evo_insurance_type + evo_kasko_price_leasperiod + evo_insurance_decentral + evo_insurance_period + evo_osago_accountid + evo_kasko_accountid + evo_osago_payer + evo_kasko_payer + evo_osago_price + evo_kasko_price + evo_dgo_price + evo_ns_price + evo_graphs { + createdon + evo_sumpay_withnds + evo_planpayments { + evo_payment_ratio + } + } + evo_first_payment_perc + evo_rateid + evo_client_riskid + evo_townid + evo_registration_regionid + evo_vehicle_tax_approved + evo_vehicle_tax_year + evo_category_tr + evo_vehicle_type_tax + + evo_agent_accountid + evo_dealer_person_accountid + evo_dealer_broker_accountid + evo_double_agent_accountid + evo_dealer_reward_conditionid + evo_dealer_reward_total + evo_dealer_broker_reward_conditionid + evo_dealer_broker_reward_total + evo_agent_reward_conditionid + evo_agent_reward_total + evo_double_agent_reward_conditionid + evo_double_agent_reward_total + evo_broker_reward_conditionid + evo_broker_reward_total + evo_fin_department_reward_conditionid + evo_fin_department_reward_total + evo_broker_accountid + evo_fin_department_accountid + + evo_kasko_accountid + evo_kasko_price + evo_id_elt_kasko + evo_id_kasko_calc + evo_id_elt_osago + evo_osago_price + evo_accept_control_addproduct_typeid + evo_payment_redemption_sum + + evo_baseproductid + evo_client_typeid + evo_supplier_currency_price + evo_transactioncurrencyid + evo_discount_supplier_currency + evo_discount_perc + evo_last_payment_calc + evo_last_payment_rub + evo_balance_holder + evo_graph_type + evo_payments_decrease_perc + evo_seasons_type + evo_high_season + evo_comission_perc + evo_comission_rub + evo_sale_bonus + evo_period + evo_tarifid + evo_msfo_irr + evo_leasingobject_typeid + evo_delivery_time + evo_brandid + evo_modelid + evo_equipmentid + evo_engine_type + evo_power + evo_engine_volume + evo_use_for + evo_trailer + evo_leasingobject_used + evo_max_speed + evo_supplier_accountid + + evo_gps_brandid + evo_gps_modelid + evo_ins_legal_form + evo_franchise + evo_unlimit_drivers + evo_age_drivers + evo_exp_drivers + evo_last_payment_redemption + evo_price_with_discount + evo_cost_increace + evo_insurance + evo_registration_quote + evo_card_quote + evo_nsib_quote + evo_contact_name + evo_gender + evo_redemption_graph + evo_importer_reward_perc + evo_importer_reward_rub + evo_mileage + evo_price_without_discount_quote + evo_object_registration + evo_pts_type + evo_subsidyid + evo_subsidy_summ +} diff --git a/src/core/graphql/query/crm/quote/fragments/quoteFieldsLite.graphql b/src/core/graphql/query/crm/quote/fragments/quoteFieldsLite.graphql new file mode 100644 index 0000000..5ce2a45 --- /dev/null +++ b/src/core/graphql/query/crm/quote/fragments/quoteFieldsLite.graphql @@ -0,0 +1,25 @@ +fragment quoteFieldsLite on quote { + quoteid + name + evo_quotename + quotenumber + evo_recalc_limit + evo_object_count + evo_approved_first_payment + evo_statuscode: evo_statuscodeidData { + evo_id + } + evo_max_price_change + evo_max_mass + evo_seats + evo_year + offerprintformapi + evo_regionid + evo_legal_regionid + evo_legal_townid + link + evo_req_telematic + evo_req_telematic_accept + evo_one_year_insurance + evo_last_payment_perc +} diff --git a/src/core/graphql/query/crm/quote/getQuote.graphql b/src/core/graphql/query/crm/quote/getQuote.graphql new file mode 100644 index 0000000..4cf6f80 --- /dev/null +++ b/src/core/graphql/query/crm/quote/getQuote.graphql @@ -0,0 +1,7 @@ +#import './fragments/quoteFields.graphql' + +query GetQuote($quoteId: Uuid!) { + quote(quoteId: $quoteId) { + ...quoteFields + } +} diff --git a/src/core/graphql/query/crm/quote/getQuotesByLead.graphql b/src/core/graphql/query/crm/quote/getQuotesByLead.graphql new file mode 100644 index 0000000..5951dd0 --- /dev/null +++ b/src/core/graphql/query/crm/quote/getQuotesByLead.graphql @@ -0,0 +1,7 @@ +#import './fragments/quoteFieldsLite.graphql' + +query GetQuotesByLead($leadid: Uuid) { + quotes(evo_leadid: $leadid) { + ...quoteFieldsLite + } +} diff --git a/src/core/graphql/query/crm/quote/index.js b/src/core/graphql/query/crm/quote/index.js new file mode 100644 index 0000000..4ff1245 --- /dev/null +++ b/src/core/graphql/query/crm/quote/index.js @@ -0,0 +1,14 @@ +import { loader } from 'graphql.macro'; + +export const getQuotesByLeadQuery = loader('./getQuotesByLead.graphql'); +export const getQuoteQuery = loader('./getQuote.graphql'); + +export const getMainOptionsForQuote = loader( + './options/getMainOptions.graphql', +); +export const getSecondaryOptionsForQuote = loader( + './options/getSecondaryOptions.graphql', +); +export const getSingleOptionsForQuote = loader( + './options/getSingleOptions.graphql', +); diff --git a/src/core/graphql/query/crm/quote/options/getMainOptions.graphql b/src/core/graphql/query/crm/quote/options/getMainOptions.graphql new file mode 100644 index 0000000..84b576c --- /dev/null +++ b/src/core/graphql/query/crm/quote/options/getMainOptions.graphql @@ -0,0 +1,124 @@ +query GetMainOptionsForKP( + $statecode: Int + $evo_brandid: Uuid + $evo_modelid: Uuid + $salonaccountid: Uuid! + $currentDate: DateTime + $dealer_person_accountid: Uuid! + $dealer_broker_accountid: Uuid! + # $ind_agent_accountid: Uuid! + $double_agent_accountid: Uuid! + # $broker_accountid: Uuid! + # $findepartment_accountid: Uuid! + $evo_gps_brandid: Uuid! +) { + selectModel: evo_models(statecode: $statecode, evo_brandid: $evo_brandid) { + evo_id + evo_name + evo_modelid + evo_leasingobject_risk + evo_importer_reward_perc + evo_importer_reward_rub + evo_impairment_groupid + evo_vehicle_type + evo_gps + evo_vehicle_body_typeidData { + evo_id_elt + } + evo_running_gear + } + selectConfiguration: evo_equipments( + statecode: $statecode + evo_modelid: $evo_modelid + ) { + evo_equipmentid + evo_name + evo_impairment_groupid + evo_leasingobject_risk + evo_start_production_year + } + selectDealerPerson: salon_providers( + statecode: $statecode + salonaccountid: $salonaccountid + ) { + accountid + name + evo_broker_accountid + evo_kpp + evo_inn + } + selectDealerRewardCondition: evo_reward_conditions( + evo_agent_accountid: $dealer_person_accountid + evo_datefrom_param: { lte: $currentDate } + evo_dateto_param: { gte: $currentDate } + statecode: $statecode + ) { + evo_reward_conditionid + evo_name + evo_reward_summ + evo_reduce_reward + } + selectDealerBrokerRewardCondition: evo_reward_conditions( + evo_agent_accountid: $dealer_broker_accountid + evo_datefrom_param: { lte: $currentDate } + evo_dateto_param: { gte: $currentDate } + statecode: $statecode + ) { + evo_reward_conditionid + evo_name + evo_reward_summ + evo_reduce_reward + } + # selectIndAgentRewardCondition: evo_reward_conditions( + # evo_agent_accountid: $ind_agent_accountid + # evo_datefrom_param: { lte: $currentDate } + # evo_dateto_param: { gte: $currentDate } + # statecode: $statecode + # ) { + # evo_reward_conditionid + # evo_name + # evo_double_agent_accountid + # evo_reward_summ + # evo_reduce_reward + # } + calcDoubleAgentRewardCondition: evo_reward_conditions( + evo_agent_accountid: $double_agent_accountid + evo_datefrom_param: { lte: $currentDate } + evo_dateto_param: { gte: $currentDate } + statecode: $statecode + ) { + evo_reward_conditionid + evo_name + evo_reward_summ + evo_reduce_reward + } + # calcBrokerRewardCondition: evo_reward_conditions( + # evo_agent_accountid: $broker_accountid + # evo_datefrom_param: { lte: $currentDate } + # evo_dateto_param: { gte: $currentDate } + # statecode: $statecode + # ) { + # evo_reward_conditionid + # evo_name + # evo_reward_summ + # evo_reduce_reward + # } + # selectFinDepartmentRewardCondtion: evo_reward_conditions( + # evo_agent_accountid: $findepartment_accountid + # evo_datefrom_param: { lte: $currentDate } + # evo_dateto_param: { gte: $currentDate } + # statecode: $statecode + # ) { + # evo_reward_conditionid + # evo_name + # evo_reward_summ + # evo_reduce_reward + # } + selectGPSModel: evo_gps_models( + statecode: $statecode + evo_gps_brandid: $evo_gps_brandid + ) { + evo_name + evo_gps_modelid + } +} diff --git a/src/core/graphql/query/crm/quote/options/getSecondaryOptions.graphql b/src/core/graphql/query/crm/quote/options/getSecondaryOptions.graphql new file mode 100644 index 0000000..94ec8cd --- /dev/null +++ b/src/core/graphql/query/crm/quote/options/getSecondaryOptions.graphql @@ -0,0 +1,26 @@ +query GetSecondaryOptionsForKP( + $statecode: Int + $evo_regionid: Uuid! + $evo_legal_regionid: Uuid! +) { + selectTownRegistration: evo_towns( + statecode: $statecode + evo_regionid: $evo_regionid + ) { + evo_name + evo_townid + evo_fias_id + evo_kladr_id + evo_businessunit_evolution + } + selectLegalClientTown: evo_towns( + statecode: $statecode + evo_regionid: $evo_legal_regionid + ) { + evo_name + evo_townid + evo_fias_id + evo_kladr_id + evo_businessunit_evolution + } +} diff --git a/src/core/graphql/query/crm/quote/options/getSingleOptions.graphql b/src/core/graphql/query/crm/quote/options/getSingleOptions.graphql new file mode 100644 index 0000000..63360df --- /dev/null +++ b/src/core/graphql/query/crm/quote/options/getSingleOptions.graphql @@ -0,0 +1,10 @@ +query GetSingleOptionsForKP( + $dealer_broker_accountid: Uuid! + $hasDealerBroker: Boolean! +) { + selectDealerBroker: account(accountid: $dealer_broker_accountid) + @include(if: $hasDealerBroker) { + accountid + name + } +} diff --git a/src/core/graphql/query/crm/staticData/getStaticData.graphql b/src/core/graphql/query/crm/staticData/getStaticData.graphql new file mode 100644 index 0000000..6a88575 --- /dev/null +++ b/src/core/graphql/query/crm/staticData/getStaticData.graphql @@ -0,0 +1,63 @@ +#import '../fragments/evo_addproduct_types_fields.graphql' + +query GetStaticData($statecode: Int, $currentDate: DateTime) { + evo_impairment_group: evo_impairment_groups(statecode: $statecode) { + evo_impairment_groupid + evo_name + } + evo_currencychange: evo_currencychanges( + statecode: $statecode + evo_coursedate_param: { eq: $currentDate } + ) { + evo_currencychange + evo_ref_transactioncurrency + } + evo_coefficient: evo_coefficients( + statecode: $statecode + evo_datefrom_param: { lte: $currentDate } + evo_dateto_param: { gte: $currentDate } + ) { + evo_correction_coefficient + evo_graph_type + evo_season_type + evo_job_titleid + evo_sot_coefficient_typeid + evo_sot_coefficient + evo_corfficient_type + evo_min_period + evo_max_period + evo_graph_type + evo_season_type + evo_correction_coefficient + evo_client_riskid + evo_client_typeid + evo_risk_delta + evo_leasingobject_types { + evo_name + evo_id + evo_leasingobject_typeid + } + evo_businessunits { + evo_name + evo_businessunitid + evo_sale_businessunitid + } + } + evo_sot_coefficient_type: evo_sot_coefficient_types(statecode: $statecode) { + evo_id + evo_name + evo_sot_coefficient_typeid + } + evo_job_title: evo_job_titles(statecode: $statecode) { + evo_id + evo_name + evo_job_titleid + } + evo_addproduct_type: evo_addproduct_types( + statecode: $statecode + evo_datefrom_param: { lte: $currentDate } + evo_dateto_param: { gte: $currentDate } + ) { + ...evo_addproduct_types_fields + } +} diff --git a/src/core/graphql/query/crm/staticData/getSystemUser.graphql b/src/core/graphql/query/crm/staticData/getSystemUser.graphql new file mode 100644 index 0000000..22abe24 --- /dev/null +++ b/src/core/graphql/query/crm/staticData/getSystemUser.graphql @@ -0,0 +1,9 @@ +query GetSystemUser($domainname: String) { + systemuser(domainname: $domainname) { + evo_job_titleid + businessunitid + firstname + lastname + fullname + } +} diff --git a/src/core/graphql/query/crm/staticData/index.js b/src/core/graphql/query/crm/staticData/index.js new file mode 100644 index 0000000..96c42e3 --- /dev/null +++ b/src/core/graphql/query/crm/staticData/index.js @@ -0,0 +1,4 @@ +import { loader } from 'graphql.macro'; + +export const getStaticDataQuery = loader('./getStaticData.graphql'); +export const getSystemUserQuery = loader('./getSystemUser.graphql'); diff --git a/src/core/graphql/schemas/crm.graphql b/src/core/graphql/schemas/crm.graphql new file mode 100644 index 0000000..231eca8 --- /dev/null +++ b/src/core/graphql/schemas/crm.graphql @@ -0,0 +1,2263 @@ +"""The cost directives is used to express the complexity of a field.""" +directive @cost( + """Defines the complexity of the field.""" + complexity: Int! = 1 + + """Defines field arguments that act as complexity multipliers.""" + multipliers: [MultiplierPath!] +) on FIELD_DEFINITION + +""" +Direct the client to resolve this field locally, either from the cache or local resolvers. +""" +directive @client( + """ + When true, the client will never use the cache for this value. See + https://www.apollographql.com/docs/react/essentials/local-state/#forcing-resolvers-with-clientalways-true + """ + always: Boolean +) on FIELD | FRAGMENT_DEFINITION | INLINE_FRAGMENT + +""" +Export this locally resolved field as a variable to be used in the remainder of this query. See +https://www.apollographql.com/docs/react/essentials/local-state/#using-client-fields-as-variables +""" +directive @export( + """The variable name to export this field as.""" + as: String! +) on FIELD + +""" +Specify a custom store key for this result. See +https://www.apollographql.com/docs/react/advanced/caching/#the-connection-directive +""" +directive @connection( + """Specify the store key.""" + key: String! + + """ + An array of query argument names to include in the generated custom store key. + """ + filter: [String!] +) on FIELD + +""" +The multiplier path scalar represents a valid GraphQL multiplier path string. +""" +scalar MultiplierPath + +type Query { + account(accountid: Uuid!): account + + """Контрагенты. statecode по умолчанию 0""" + accounts(evo_accnumber: String, evo_account_type: [Int!], evo_broker_accountid: Uuid, evo_fin_department_accountid: Uuid, evo_id_elt: String, evo_inn: String, evo_kpp: String, evo_legal_form: Int, evo_type_ins_policy: [Int!], ownerid: Uuid, owner_domainname: String, statecode: Int): [account] + + """Брокер. statecode по умолчанию 0""" + broker_agents(ownnerid: Uuid!, statecode: Int): [account] + contacts(parentcustomerid: Uuid, statecode: Int): [contact] + email(activityid: Uuid!): email + evo_addcontract(evo_addcontractid: Uuid!): evo_addcontract + evo_addproduct(evo_addproductid: Uuid!): evo_addproduct + evo_addproduct_type(evo_addproduct_typeid: Uuid!): evo_addproduct_type + evo_addproduct_types(evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, evo_max_period_param: DecimalParamInput, evo_min_period_param: DecimalParamInput, evo_product_type: Int, statecode: Int): [evo_addproduct_type] + evo_address(evo_addressid: Uuid!): evo_address + evo_addresses(evo_address_name: String, evo_fias: Boolean, statecode: Int): [evo_address] + evo_agency_agreement(evo_agency_agreementid: Uuid!): evo_agency_agreement + evo_bank_detailses(evo_accountid: Uuid, orderby: OrderByInput, statecode: Int = 0): [evo_bank_details] + evo_baseproduct(evo_baseproductid: Uuid!): evo_baseproduct + evo_baseproducts(evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, evo_relation: [Int!], statecode: Int): [evo_baseproduct] + evo_brands(evo_vehicle_type: [Int!], statecode: Int): [evo_brand] + evo_businessunits(statecode: Int): [evo_businessunit] + evo_client_risks(statecode: Int): [evo_client_risk] + evo_client_types(statecode: Int): [evo_client_type] + evo_coefficients(evo_client_riskid: Uuid, evo_client_typeid: Uuid, evo_corfficient_type: Int, evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, evo_job_titleid: Uuid, evo_max_period_param: DecimalParamInput, evo_min_period_param: DecimalParamInput, statecode: Int): [evo_coefficient] + evo_contract(evo_contractid: Uuid!): evo_contract + evo_contracts(evo_name: String, statecode: Int): [evo_contract] + evo_countries(evo_code_numeric: String): [evo_countryGraphQL] + evo_country(evo_countryid: Uuid!): evo_countryGraphQL + evo_currencychanges(evo_coursedate_param: DateParamInput, evo_ref_transactioncurrency: Uuid, statecode: Int): [evo_currencychange] + evo_equipments(evo_modelid: Uuid, statecode: Int): [evo_equipment] + evo_external_supplier_codes(evo_id: String, statecode: Int): [evo_external_supplier_code] + evo_external_system_request(evo_external_system_requestid: Uuid!): evo_external_system_request + evo_external_system_requests(evo_integration_status: Int, evo_name: String, evo_system: Int, statecode: Int): [evo_external_system_request] + evo_finegibdd(evo_finegibddid: Uuid!): evo_finegibdd + evo_gps_brands(statecode: Int): [evo_gps_brand] + evo_gps_models(evo_gps_brandid: Uuid, statecode: Int): [evo_gps_model] + evo_graphs(evo_contractid: Uuid, statecode: Int): [evo_graph] + evo_identity_documents(evo_employee_systemuserid: Uuid!): [evo_identity_document] + evo_impairment_groups(statecode: Int): [evo_impairment_group] + evo_insurance_periods(evo_contractid: Uuid, statecode: Int): [evo_insurance_period] + evo_job_titles(statecode: Int): [evo_job_title] + evo_leasingobject(evo_leasingobjectid: Uuid!): evo_leasingobject + evo_leasingobject_type(evo_leasingobject_typeid: Uuid!): evo_leasingobject_type + evo_leasingobject_types(statecode: Int): [evo_leasingobject_type] + evo_model(evo_modelid: Uuid!): evo_model + evo_models(evo_brandid: Uuid, evo_vehicle_type: Int, statecode: Int): [evo_model] + evo_orglegalform(evo_orglegalformid: Uuid!): evo_orglegalform + evo_orglegalforms(statecode: Int = 0): [evo_orglegalform] + evo_paymentorders(evo_dds_1c: String, evo_name: String, evo_paydate_param: DateParamInput, evo_payment_number_1c: String, evo_paysum: Decimal, statecode: Int, statuscode: Int): [evo_paymentorder] + evo_planpayments(evo_addproduct_typeid: Uuid, statecode: Int): [evo_planpayment] + evo_rate(evo_rateid: Uuid!): evo_rate + evo_rates(evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, statecode: Int): [evo_rate] + + """Регион. statecode по умолчанию 0""" + evo_regions(evo_businessunit_evolution: Boolean, evo_creditregistry_id: Int, statecode: Int): [evo_region] + evo_request_payment(evo_request_paymentid: Uuid!): evo_request_payment + evo_request_payments(evo_id: String, evo_name: String, statecode: Int): [evo_request_payment] + evo_reward_condition(evo_reward_conditionid: Uuid!): evo_reward_condition + evo_reward_conditions(evo_agent_accountid: Uuid, evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, statecode: Int): [evo_reward_condition] + evo_sot_coefficient_types(statecode: Int): [evo_sot_coefficient_type] + evo_statuscode(evo_id: String, evo_statuscodeid: Uuid): evo_statuscode + evo_statuscodes(statecode: Int): [evo_statuscode] + evo_subsidies(evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, statecode: Int): [evo_subsidy] + evo_tarif(evo_tarifid: Uuid!): evo_tarif + evo_tarifs(evo_balance_holder: [Int!], evo_baseproductid: Uuid, evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, evo_graphtype_exception: [Int!], evo_ins_type: [Int!], evo_max_first_payment_param: DecimalParamInput, evo_max_last_payment_param: DecimalParamInput, evo_max_period_param: DecimalParamInput, evo_min_first_payment_param: DecimalParamInput, evo_min_last_payment_param: DecimalParamInput, evo_min_period_param: DecimalParamInput, evo_used: Boolean, statecode: Int): [evo_tarif] + evo_town(evo_fias_id: String, evo_townid: Uuid): evo_town + + """Города. statecode по умолчанию 0""" + evo_towns(evo_regionid: Uuid, statecode: Int): [evo_town] + evo_vehicle_body_type(evo_vehicle_body_typeid: Uuid!): evo_vehicle_body_typeGraphQL + + """ + Лизинговые сделки. statecode по умолчанию 0, можно отфильтровать по ownerid и/или domainName + """ + lead(leadid: Uuid!): lead + + """ + Интересы. statecode по умолчанию 0, можно отфильтровать по ownerid и/или domainName + """ + leads(evo_opportunityid: Uuid, ownerid: Uuid, owner_domainname: String, statecode: Int): [lead] + opportunities(evo_leadid: Uuid, ownerid: Uuid, owner_domainname: String, statecode: Int): [opportunity] + opportunity(opportunityid: Uuid!): opportunity + queue(emailaddress: String): queue + quote(quoteId: Uuid!): quote + + """ + Предложения. statecode по умолчанию 0, можно отфильтровать по ownerid и/или domainName + """ + quotes(condition: ConditionInput, evo_leadid: Uuid, ownerid: Uuid, owner_domainname: String, statecode: Int): [quote] + + """Агенты салона. statecode по умолчанию 0""" + salon_agents(salonaccountid: Uuid!, statecode: Int): [account] + + """Поставщики ЮЛ салона. statecode по умолчанию 0""" + salon_providers(salonaccountid: Uuid!, statecode: Int): [account] + systemuser(domainname: String, systemuserid: Uuid): systemuser + systemusers(evo_employee_id: String, isdisabled: Boolean = false): [systemuser] + templates(description: String): [template] + + """Валюта. statecode по умолчанию 0""" + transactioncurrencies(statecode: Int): [transactioncurrency] + transactioncurrency(transactioncurrencyid: Uuid!): transactioncurrency +} + +type Mutation { + by(domainName: String): MutationBy +} + +type account { + accountid: Uuid + childcontacts(statecode: Int): [contact] + createdon: DateTime + emailaddress1: String + evo_accnumber: String + evo_account_type: [Int!] + evo_address_factid: Uuid + evo_address_factidData: evo_address + evo_address_legalid: Uuid + evo_address_legalidData: evo_address + evo_address_legal_string: String + evo_address_postalid: Uuid + evo_address_postalidData: evo_address + evo_bank_detailses(statecode: Int): [evo_bank_details] + evo_branch_count: String + evo_branch_type: Int + evo_broker_accountid: Uuid + evo_broker_accountidData: account + evo_citizenship_countryid: Uuid + evo_client_riskid: Uuid + evo_consent_date: DateTime + evo_dadata_dateupdate: DateTime + evo_dadatdalog: String + evo_dealer_responsible_systemuserid: Uuid + evo_div_12month: Boolean + evo_economic_security_systemuserid: Uuid + evo_employee_count: Int + evo_fin_department_accountid: Uuid + evo_fin_department_accountidData: account + evo_fullname: String + evo_group_sales_network: Uuid + evo_id_elt: String + evo_id_elt_osago: String + evo_id_elt_smr: String + evo_ifns_code: String + evo_ifns_code_branch: String + evo_ifns_name: String + evo_inn: String + evo_invoice_number_fix: String + evo_invoice_number_rules: Int + evo_kpp: String + evo_legal_form: Int + evo_legal_region_calc: Boolean + evo_licenses_list: String + evo_lk_regdate: DateTime + evo_management_disqualified: Boolean + evo_ogrn: String + evo_ogrn_date: DateTime + evo_okato: String + evo_okfs: String + evo_okogu: String + evo_okpo: String + evo_oktmo: String + evo_okved: String + evo_orglegalformid: Uuid + evo_orglegalformidData: evo_orglegalform + evo_smb_category: Int + evo_smb_issue_date: DateTime + evo_state_actuality_date: DateTime + evo_state_liquidation_date: DateTime + evo_state_registration_date: DateTime + evo_state_status: Int + evo_storage: String + evo_subsidies(statecode: Int): [evo_subsidy] + evo_tax_system: Int + evo_type_ins_policy: [Int!] + modifiedon: DateTime + name: String + ownerid: Uuid + owneridsystemuserData: systemuser + owneridtype: Int + ownerid_systemuser: Uuid + ownerid_team: Uuid + statecode: Int + telephone1: String + toObjectString: String +} + +scalar Uuid + +input DateParamInput { + eq: DateTime + gt: DateTime + gte: DateTime + lt: DateTime + lte: DateTime +} + +input DecimalParamInput { + eq: Decimal + gt: Decimal + gte: Decimal + lt: Decimal + lte: Decimal +} + +input ConditionInput { + conditions: [ConditionInput] + filters: [FilterInput] + logicoperation: LogicOperation! +} + +"""The built-in `Decimal` scalar type.""" +scalar Decimal + +input OrderByInput { + fieldName: String + sortingType: SortingType! +} + +type contact { + birthdate: DateTime + contactid: Uuid + createdon: DateTime + emailaddress1: String + emailaddress2: String + emailaddress3: String + evo_consent_date: DateTime + evo_fact_addressid: Uuid + evo_fullname: String + evo_functiontype: [Int!] + evo_inn: String + evo_name_dative: String + evo_name_genitive: String + evo_no_middle_name: Boolean + evo_reg_addressid: Uuid + evo_share_capital: Decimal + evo_signer_rule_basis: Int + firstname: String + fullname: String + gendercode: Int + lastname: String + middlename: String + mobilephone: String + modifiedon: DateTime + ownerid: Uuid + owneridtype: Int + ownerid_systemuser: Uuid + ownerid_team: Uuid + parentcustomeridtype: Int + parentcustomerid_account: Uuid + parentcustomerid_contact: Uuid + statecode: Int + toObjectString: String +} + +type evo_addproduct_type { + createdon: DateTime + evo_accountid: Uuid + evo_addproduct_typeid: Uuid + evo_controls_program: [Int!] + evo_cost_service_provider: Decimal + evo_cost_service_provider_withoutnds: Decimal + evo_datefrom: DateTime + evo_dateto: DateTime + evo_description: String + evo_equip_cost: Decimal + evo_gibdd_region: Boolean + evo_graph_price: Decimal + evo_graph_price_withoutnds: Decimal + evo_helpcard_type: Int + evo_id: String + evo_leasingobject_types(statecode: Int): [evo_leasingobject_type] + evo_max_age: Int + evo_max_period: Decimal + evo_min_age: Int + evo_min_period: Decimal + evo_name: String + evo_nsib_limit: Decimal + evo_planpayments(statecode: Int): [evo_planpayment] + evo_prime_cost: Decimal + evo_product_type: Int + evo_pts_type: [Int!] + evo_retro_bonus: Decimal + evo_retro_bonus_withoutnds: Decimal + evo_towtruck: Boolean + evo_visible_calc: Boolean + evo_whom_register: Int + modifiedon: DateTime + statecode: Int + toObjectString: String +} + +type evo_baseproduct { + createdon: DateTime + evo_baseproductid: Uuid + evo_brands(statecode: Int): [evo_brand] + evo_datefrom: DateTime + evo_dateto: DateTime + evo_id: String + evo_leasingobject_types(statecode: Int): [evo_leasingobject_type] + evo_name: String + evo_relation: [Int!] + modifiedon: DateTime + statecode: Int + systemusers(statecode: Int): [systemuser] + toObjectString: String +} + +type evo_graph { + createdon: DateTime + evo_addcontractid: Uuid + evo_contractid: Uuid + evo_cost_equipment_sum: Decimal + evo_cost_equipment_withoutnds_sum: Decimal + evo_cost_price_telematics_sum: Decimal + evo_cost_price_telematics_withoutnds_sum: Decimal + evo_cost_telematics_sum: Decimal + evo_cost_telematics_withoutnds_sum: Decimal + evo_graphid: Uuid + evo_name: String + evo_nds: Decimal + evo_planpayments: [evo_planpayment] + evo_quoteid: Uuid + evo_sumpay_withnds: Decimal + evo_sumpay_withoutnds: Decimal + modifiedon: DateTime + ownerid: Uuid + toObjectString: String +} + +type evo_insurance_period { + createdon: DateTime + evo_accept_pay_listid: Uuid + evo_accountid: Uuid + evo_age_drivers: Int + evo_base_reward_factor: Decimal + evo_base_reward_rub: Decimal + evo_comment: String + evo_contractid: Uuid + evo_datefrom: DateTime + evo_dateto: DateTime + evo_dgo_price: Decimal + evo_elt_id: String + evo_exp_drivers: Int + evo_franchise: Decimal + evo_id: String + evo_id_elt_calc: String + evo_insurance_decentral: Boolean + evo_insurance_decentral_factor: Decimal + evo_insurance_decentral_rub: Decimal + evo_insurance_periodid: Uuid + evo_insurance_policyid: Uuid + evo_insurance_policyidData: evo_insurance_policy + evo_insurance_price_result: Decimal + evo_insurance_supplier: Boolean + evo_insurance_supplier_factor: Decimal + evo_insurance_supplier_rub: Decimal + evo_insurance_type: Int + evo_insurer_accountid: Uuid + evo_insurer_accountidData: account + evo_ins_risk: [Int!] + evo_kasko_price: Decimal + evo_leasingobjectid: Uuid + evo_mobile_discount: Boolean + evo_mobile_discount_factor: Decimal + evo_mobile_discount_rub: Decimal + evo_name: String + evo_nsib_connection_listid: Uuid + evo_nsib_pay_summ: Decimal + evo_ns_price: Decimal + evo_opponent_discount: Boolean + evo_opponent_discount_factor: Decimal + evo_opponent_discount_rub: Decimal + evo_osago_price: Decimal + evo_other_discount: Boolean + evo_other_discount_factor: Decimal + evo_other_discount_rub: Decimal + evo_paid: Boolean + evo_payer: Int + evo_pay_summ_fact: Decimal + evo_period_number: Int + evo_prolong_listid: Uuid + evo_request_id_elt: String + evo_request_status: Int + evo_result_reward_factor: Decimal + evo_result_reward_rub: Decimal + evo_settlement_type: Int + evo_storage: String + evo_supplier_accountid: Uuid + evo_territory_price: Decimal + evo_unlimit_drivers: Boolean + modifiedon: DateTime + ownerid_systemuser: Uuid + ownerid_team: Uuid + statecode: Int + statuscode: Int + toObjectString: String +} + +type evo_addproduct { + createdon: DateTime + evo_accountid: Uuid + evo_activation_date: DateTime + evo_addproductid: Uuid + evo_addproductnumberid: Uuid + evo_addproductnumberidData: evo_addproductnumber + evo_addproduct_typeid: Uuid + evo_addproduct_typeidData: evo_addproduct_type + evo_deactivation_date: DateTime + evo_leasingobjectid: Uuid + evo_name: String + evo_provider_accountid: Uuid + evo_provider_accountidData: account + evo_request_instal_message: String + evo_service_contactid: Uuid + evo_telematics_number: String + modifiedon: DateTime + toObjectString: String +} + +type evo_external_supplier_code { + accounts(statecode: Int): [account] + createdon: DateTime + evo_accountid: Uuid + evo_accountidData: account + evo_external_supplier_codeid: Uuid + evo_id: String + evo_manager_systemuserid: Uuid + modifiedon: DateTime + toObjectString: String +} + +type evo_orglegalform { + createdon: DateTime + evo_code: String + evo_elt_id: String + evo_legal_form: Int + evo_name: String + evo_nko: Boolean + evo_not_financing: Boolean + evo_orglegalformid: Uuid + modifiedon: DateTime + toObjectString: String +} + +type evo_statuscode { + createdon: DateTime + evo_id: String + evo_name: String + evo_statuscodeid: Uuid + modifiedon: DateTime + toObjectString: String +} + +type evo_leasingobject { + createdon: DateTime + evo_addequipment_list: String + evo_base: String + evo_brandid: Uuid + evo_brandidData: evo_brand + evo_category: Int + evo_category_tr: Int + evo_certificate: String + evo_certificate_date: DateTime + evo_certificate_issued: String + evo_chassis: String + evo_color: String + evo_contractid: Uuid + evo_delivery_time: Int + evo_driving_axle: String + evo_ecological_class: Int + evo_engine_model: String + evo_engine_power: Decimal + evo_engine_power_kvt: Decimal + evo_engine_type: Int + evo_engine_volume: Decimal + evo_equipmentid: Uuid + evo_gosnumber: String + evo_gos_akt: String + evo_guarantee: String + evo_insured_contactid: Uuid + evo_leasingobjectid: Uuid + evo_leasingobject_specification: String + evo_leasingobject_typeid: Uuid + evo_leasingobject_typeidData: evo_leasingobject_type + evo_legal_regionid: Uuid + evo_legal_townid: Uuid + evo_maker: String + evo_max_mass: Decimal + evo_max_speed: Decimal + evo_mileage: Decimal + evo_modelid: Uuid + evo_motor_power_1: String + evo_name: String + evo_object_number: String + evo_passport_address: String + evo_passport_brand_model: String + evo_passport_company: String + evo_passport_date: DateTime + evo_passport_engine_type: String + evo_passport_name: String + evo_passport_number: String + evo_passport_seria: String + evo_passport_type: Int + evo_prop_type: String + evo_pts_type: Int + evo_quoteid: Uuid + evo_regionid: Uuid + evo_registration: Int + evo_registration_regionid: Uuid + evo_seats: Int + evo_sts_number: String + evo_townid: Uuid + evo_trailer: Boolean + evo_transmission_number: String + evo_used: Boolean + evo_use_for: Int + evo_vehicle_type_tax: Int + evo_vin: String + evo_year: Int + modifiedon: DateTime + statecode: Int + toObjectString: String +} + +type evo_reward_condition { + createdon: DateTime + evo_add_agency_agreement: Uuid + evo_agency_agreementid: Uuid + evo_agency_agreementidData: evo_agency_agreement + evo_agent_accountid: Uuid + evo_brandid: Uuid + evo_client_type: Int + evo_condition_type: Int + evo_datefrom: DateTime + evo_dateto: DateTime + evo_deactivated: Boolean + evo_double_agent_accountid: Uuid + evo_name: String + evo_reduce_reward: Boolean + evo_reward_conditionid: Uuid + evo_reward_summ: Decimal + modifiedon: DateTime + ownerid_systemuser: Uuid + ownerid_team: Uuid + statecode: Int + toObjectString: String +} + +type evo_leasingobject_type { + createdon: DateTime + evo_category: Int + evo_category_tr: [Int!] + evo_depreciation_rate1: Decimal + evo_depreciation_rate2: Decimal + evo_expluatation_period1: Decimal + evo_expluatation_period2: Decimal + evo_id: String + evo_leasingobject_typeid: Uuid + evo_name: String + evo_subsidies(statecode: Int): [evo_subsidy] + evo_type_code: String + evo_vehicle_type: [Int!] + evo_vehicle_type_tax: Int + modifiedon: DateTime + statecode: Int + toObjectString: String +} + +type lead { + accountidData: account + createdon: DateTime + customerid: Uuid + customeridtype: Int + customerid_account: Uuid + customerid_contact: Uuid + emailaddress1: String + evo_agent_accountid: Uuid + evo_broker_accountid: Uuid + evo_client_type: Int + evo_comment: String + evo_double_agent_accountid: Uuid + evo_external_supplierid: Uuid + evo_fin_department_accountid: Uuid + evo_firstname: String + evo_inn: String + evo_kpp: String + evo_new_client: String + evo_opportunityid: Uuid + evo_opportunityidData: opportunity + evo_statuscodeid: Uuid + evo_supplier_accountid: Uuid + evo_utm_campaign: String + evo_utm_content: String + evo_utm_medium: String + evo_utm_source: String + evo_utm_term: String + fullname: String + leadid: Uuid + leadsourcecode: Int + link: String + modifiedon: DateTime + ownerid: Uuid + owneridsystemuserData: systemuser + owneridtype: Int + ownerid_systemuser: Uuid + ownerid_team: Uuid + statecode: Int + telephone1: String + toObjectString: String +} + +type opportunity { + accountid: Uuid + accountidData: account + createdon: DateTime + evo_acc_director_contactid: Uuid + evo_acc_singdoc_contactid: Uuid + evo_all_credit: Decimal + evo_all_credit_actual_date: DateTime + evo_all_credit_evolight: Decimal + evo_all_credit_evoprofi: Decimal + evo_all_credit_evosmart: Decimal + evo_approvallogs: [evo_approvallog] + evo_businessunitid: Uuid + evo_businessunitidData: businessunit + evo_client_riskid: Uuid + evo_client_riskidData: evo_client_risk + evo_comment_description: String + evo_contracts: [evo_contract] + evo_credit_analyst_systemuserid: Uuid + evo_date_change_statuscode: DateTime + evo_declaration_revenue: Decimal + evo_docpay_ka_received: Int + evo_docpay_ka_require: Boolean + evo_founder1_beneficial_owner: Boolean + evo_founder1_contactid: Uuid + evo_founder1_part: Decimal + evo_founder2_beneficial_owner: Boolean + evo_founder2_contactid: Uuid + evo_founder2_part: Decimal + evo_founder3_beneficial_owner: Boolean + evo_founder3_contactid: Uuid + evo_founder3_part: Decimal + evo_founder4_beneficial_owner: Boolean + evo_founder4_contactid: Uuid + evo_founder4_part: Decimal + evo_gt_client_riskid: Uuid + evo_guarantor1_accountid: Uuid + evo_guarantor1_contactid: Uuid + evo_guarantor1_report_year: Int + evo_guarantor1_year_equity_capital: Decimal + evo_guarantor1_year_profit: Decimal + evo_guarantor1_year_revenue: Decimal + evo_guarantor2_accountid: Uuid + evo_guarantor2_contactid: Uuid + evo_guarantor3_contactid: Uuid + evo_guarantor4_contactid: Uuid + evo_leadid: Uuid + evo_leadidData: lead + evo_mps_systemuserid: Uuid + evo_oppnumber: String + evo_process_type: Int + evo_programsolution: Int + evo_report_year: Int + evo_sfm_comment: [Int!] + evo_statuscodeid: Uuid + evo_statuscodeidData: evo_statuscode + evo_statuscode_reason: String + evo_storage: String + evo_year_equity_capital: Decimal + evo_year_profit: Decimal + evo_year_revenue: Decimal + link: String + modifiedon: DateTime + name: String + opportunityid: Uuid + ownerid: Uuid + owneridsystemuserData: systemuser + owneridtype: Int + ownerid_systemuser: Uuid + ownerid_team: Uuid + parentaccountid: Uuid + quotes: [quote] + statecode: Int + toObjectString: String +} + +type quote { + createdon: DateTime + customerid: Uuid + customerid_account: Uuid + customerid_contact: Uuid + evo_accept_control_addproduct_typeid: Uuid + evo_accept_quoteid: Uuid + evo_acquisition_costs: Decimal + evo_addproduct_types: [evo_addproduct_type] + evo_add_bonus_summ: Decimal + evo_add_equipment: Boolean + evo_agent_accountid: Uuid + evo_agent_reward_conditionid: Uuid + evo_agent_reward_summ: Decimal + evo_agent_reward_total: Decimal + evo_age_drivers: Int + evo_another_payments: Decimal + evo_approvallogs: [evo_approvallog] + evo_approved_first_payment: Decimal + evo_balance_holder: Int + evo_baseproductid: Uuid + evo_base_bonus: Decimal + evo_base_calc_pay: Decimal + evo_brandid: Uuid + evo_broker_accountid: Uuid + evo_broker_reward_conditionid: Uuid + evo_broker_reward_summ: Decimal + evo_broker_reward_total: Decimal + evo_calc_irr: Decimal + evo_calc_profit: Decimal + evo_card: Boolean + evo_card_bonus_summ: Decimal + evo_card_quote: Boolean + evo_category: Int + evo_category_tr: Int + evo_check_ins_result: Int + evo_client_riskid: Uuid + evo_client_typeid: Uuid + evo_comission_perc: Decimal + evo_comission_rub: Decimal + evo_contact_name: String + evo_cost_increace: Boolean + evo_cost_increase_perc: Decimal + evo_dealer_broker_accountid: Uuid + evo_dealer_broker_reward_conditionid: Uuid + evo_dealer_broker_reward_summ: Decimal + evo_dealer_broker_reward_total: Decimal + evo_dealer_person_accountid: Uuid + evo_dealer_reward_conditionid: Uuid + evo_dealer_reward_summ: Decimal + evo_dealer_reward_total: Decimal + evo_declaration_knd: String + evo_declaration_period: Int + evo_declaration_profit: Decimal + evo_declaration_revenue: Decimal + evo_declaration_year: Int + evo_delivery_time: Int + evo_dgo_price: Decimal + evo_director_bonus: Decimal + evo_director_nsib_bonus: Decimal + evo_discount_perc: Decimal + evo_discount_rub: Decimal + evo_discount_supplier_currency: Decimal + evo_dog_credit: Decimal + evo_double_agent_accountid: Uuid + evo_double_agent_reward_conditionid: Uuid + evo_double_agent_reward_summ: Decimal + evo_double_agent_reward_total: Decimal + evo_economic: Decimal + evo_engine_type: Int + evo_engine_volume: Decimal + evo_equipmentid: Uuid + evo_equity_capital: Decimal + evo_exp_drivers: Int + evo_fin_department_accountid: Uuid + evo_fin_department_reward_conditionid: Uuid + evo_fin_department_reward_summ: Decimal + evo_fin_department_reward_total: Decimal + evo_first_dgo_price: Decimal + evo_first_kasko_accountid: Uuid + evo_first_kasko_price: Decimal + evo_first_ns_price: Decimal + evo_first_osago_accountid: Uuid + evo_first_osago_price: Decimal + evo_first_payment_perc: Decimal + evo_first_payment_perc_without_subsidy: Decimal + evo_first_payment_rub: Decimal + evo_first_payment_rub_without_subsidy: Decimal + evo_franchise: Decimal + evo_fuel: Boolean + evo_gender: Int + evo_gps_brandid: Uuid + evo_gps_modelid: Uuid + evo_graphs: [evo_graph] + evo_graph_irr: Decimal + evo_graph_type: Int + evo_guarantor1_another_peyments: Decimal + evo_guarantor1_declaration_year: Int + evo_guarantor1_equity_capital: Decimal + evo_guarantor1_profit_period: Decimal + evo_guarantor1_report_period: Int + evo_guarantor1_report_year: Int + evo_guarantor1_revenue_period: Decimal + evo_guarantor1_riskid: Uuid + evo_guarantor1_year_equity_capital: Decimal + evo_guarantor1_year_profit: Decimal + evo_guarantor1_year_revenue: Decimal + evo_high_season: Int + evo_id_elt_kasko: String + evo_id_elt_osago: String + evo_id_kasko_calc: String + evo_id_osago_calc: String + evo_importer_reward_perc: Decimal + evo_importer_reward_rub: Decimal + evo_importer_reward_summ: Decimal + evo_individual_insurance: Boolean + evo_insurance: Boolean + evo_insurance_decentral: Boolean + evo_insurance_period: Int + evo_insurance_type: Int + evo_insurer_comment: String + evo_ins_accept_quoteid: Uuid + evo_ins_comment: String + evo_ins_legal_form: Int + evo_irr: Decimal + evo_irr_final: Decimal + evo_irr_msfo_final: Decimal + evo_irr_msfo_final2: Decimal + evo_kasko_accountid: Uuid + evo_kasko_payer: Int + evo_kasko_price: Decimal + evo_kasko_price_leasperiod: Decimal + evo_kilometrage_limit: Int + evo_kilometrage_limit_period: Int + evo_last_payment_calc: Int + evo_last_payment_perc: Decimal + evo_last_payment_redemption: Boolean + evo_last_payment_rub: Decimal + evo_leadid: Uuid + evo_leadidData: lead + evo_leasingobject_specification: String + evo_leasingobject_typeid: Uuid + evo_leasingobject_used: Boolean + evo_leasing_bonus_summ: Decimal + evo_legal_regionid: Uuid + evo_legal_townid: Uuid + evo_loan_appraisalid: Uuid + evo_logid: Uuid + evo_max_mass: Decimal + evo_max_price_change: Decimal + evo_max_speed: Decimal + evo_mileage: Decimal + evo_min_change_price: Decimal + evo_modelid: Uuid + evo_msfo_irr: Decimal + evo_net_irr: Decimal + evo_niatinception_msfo: Decimal + evo_ni_at_inception: Decimal + evo_npvni_msfo: Decimal + evo_npvni_msfo_final: Decimal + evo_nsib: Boolean + evo_nsib_bonus_summ: Decimal + evo_nsib_ins_summ: Decimal + evo_nsib_pay_summ: Decimal + evo_nsib_price: Decimal + evo_nsib_quote: Boolean + evo_ns_bonus_summ: Decimal + evo_ns_price: Decimal + evo_object_count: Int + evo_object_registration: Int + evo_one_year_insurance: Boolean + evo_osago_accountid: Uuid + evo_osago_payer: Int + evo_osago_price: Decimal + evo_passport_type: Int + evo_payments_decrease_perc: Decimal + evo_payment_redemption: Int + evo_payment_redemption_sum: Decimal + evo_payment_redemption_sum_without_nds: Decimal + evo_percent_subsidy: Decimal + evo_period: Int + evo_power: Decimal + evo_price_without_discount: Decimal + evo_price_without_discount_quote: Boolean + evo_price_without_discount_supplier_currency: Decimal + evo_price_without_nds_supplier_currency: Decimal + evo_price_with_discount: Boolean + evo_price_wthout_discount_nds_sup_currency: Decimal + evo_programsolution: Int + evo_pts_type: Int + evo_quotename: String + evo_quotenumber: String + evo_rate: Decimal + evo_rateid: Uuid + evo_recalc_limit: Int + evo_recalc_quoteid: Uuid + evo_redemption_graph: Boolean + evo_regionid: Uuid + evo_region_director_nsib_bonus: Decimal + evo_registration: Boolean + evo_registration_quote: Boolean + evo_registration_regionid: Uuid + evo_report_year: Int + evo_req_telematic: Int + evo_req_telematic_accept: Int + evo_risk: Int + evo_risk_coefficientid: Uuid + evo_risk_profit_coefficientid: Uuid + evo_risk_programsolution: Uuid + evo_rub_price: Decimal + evo_sale_bonus: Decimal + evo_seasons_type: Int + evo_seats: Int + evo_statuscodeid: Uuid + evo_statuscodeidData: evo_statuscode + evo_statuscode_reason: String + evo_subsidyid: Uuid + evo_subsidy_summ: Decimal + evo_supplier_accountid: Uuid + evo_supplier_currency_price: Decimal + evo_tarifid: Uuid + evo_tax_period: Decimal + evo_telematic: Boolean + evo_townid: Uuid + evo_tracker: Boolean + evo_trailer: Boolean + evo_transactioncurrencyid: Uuid + evo_unlimit_drivers: Boolean + evo_use_for: Int + evo_vehicle_tax_approved: Decimal + evo_vehicle_tax_period: Decimal + evo_vehicle_tax_year: Decimal + evo_vehicle_type_tax: Int + evo_vin: String + evo_year: Int + evo_year_equity_capital: Decimal + evo_year_profit: Decimal + evo_year_revenue: Decimal + link: String + modifiedon: DateTime + name: String + offerprintform: String + offerprintformapi: String + opportunityid: Uuid + ownerid: Uuid + owneridsystemuserData: systemuser + owneridtype: Int + quoteid: Uuid + quotenumber: String + statecode: Int + toObjectString: String + transactioncurrencyid: Uuid +} + +type evo_brand { + createdon: DateTime + evo_baseproducts(evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, evo_relation: [Int!], statecode: Int): [evo_baseproduct] + evo_brandid: Uuid + evo_brand_owner: Int + evo_id: String + evo_importer_reward_perc: Decimal + evo_importer_reward_rub: Decimal + evo_name: String + evo_subsidies(statecode: Int): [evo_subsidy] + evo_vehicle_type: [Int!] + modifiedon: DateTime + statecode: Int + toObjectString: String +} + +type evo_model { + createdon: DateTime + evo_baseproducts(evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, evo_relation: [Int!], statecode: Int): [evo_baseproduct] + evo_brandid: Uuid + evo_gps: Boolean + evo_high_risk_vehicle: Boolean + evo_id: String + evo_impairment_groupid: Uuid + evo_impairment_groupidData: evo_impairment_group + evo_importer_reward_perc: Decimal + evo_importer_reward_rub: Decimal + evo_leasingobject_risk: Int + evo_modelid: Uuid + evo_name: String + evo_not_match_evolight_scoring: Boolean + evo_running_gear: Int + evo_subsidies(statecode: Int): [evo_subsidy] + evo_taxi_sign: Boolean + evo_vehicle_body_typeid: Uuid + evo_vehicle_body_typeidData: evo_vehicle_body_typeGraphQL + evo_vehicle_type: Int + modifiedon: DateTime + statecode: Int + toObjectString: String +} + +type evo_equipment { + createdon: DateTime + evo_baseproducts(evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, evo_relation: [Int!], statecode: Int): [evo_baseproduct] + evo_equipmentid: Uuid + evo_id: String + evo_impairment_groupid: Uuid + evo_impairment_groupidData: evo_impairment_group + evo_leasingobject_risk: Int + evo_modelid: Uuid + evo_name: String + evo_start_production_year: Int + modifiedon: DateTime + statecode: Int + toObjectString: String +} + +type evo_subsidy { + accounts: [account] + createdon: DateTime + evo_brands: [evo_brand] + evo_datefrom: DateTime + evo_dateto: DateTime + evo_get_subsidy_payment: Int + evo_leasingobject_types: [evo_leasingobject_type] + evo_max_subsidy_summ: Decimal + evo_models: [evo_model] + evo_name: String + evo_percent_subsidy: Decimal + evo_subsidyid: Uuid + evo_subsidy_summ: Decimal + evo_subsidy_type: Int + modifiedon: DateTime + statecode: Int + statuscode: Int + toObjectString: String +} + +type evo_client_risk { + createdon: DateTime + evo_client_riskid: Uuid + evo_id: Int + evo_name: String + modifiedon: DateTime + statecode: Int + toObjectString: String +} + +type evo_client_type { + createdon: DateTime + evo_client_typeid: Uuid + evo_name: String + modifiedon: DateTime + statecode: Int + toObjectString: String +} + +type evo_currencychange { + createdon: DateTime + evo_coursedate: DateTime + evo_currencychange: Decimal + evo_ref_transactioncurrency: Uuid + evo_ref_transactioncurrencyData: transactioncurrency + modifiedon: DateTime + toObjectString: String +} + +type evo_town { + createdon: DateTime + evo_businessunit_evolution: Boolean + evo_fias_id: String + evo_kladr_id: String + evo_name: String + evo_townid: Uuid + modifiedon: DateTime + statecode: Int + toObjectString: String +} + +type evo_region { + accounts(statecode: Int): [account] + createdon: DateTime + evo_businessunit_evolution: Boolean + evo_creditregistry_id: Int + evo_fias_id: String + evo_kladr_id: String + evo_name: String + evo_okato: String + evo_oktmo: String + evo_postal_code: String + evo_regionid: Uuid + evo_region_name: String + evo_region_type: String + evo_timezone: String + modifiedon: DateTime + statecode: Int + toObjectString: String +} + +type evo_gps_brand { + createdon: DateTime + evo_gps_brandid: Uuid + evo_id: String + evo_name: String + modifiedon: DateTime + statecode: Int + toObjectString: String +} + +type evo_gps_model { + createdon: DateTime + evo_gps_brandid: Uuid + evo_gps_modelid: Uuid + evo_id: String + evo_moto: Boolean + evo_name: String + modifiedon: DateTime + statecode: Int + toObjectString: String +} + +type evo_impairment_group { + createdon: DateTime + evo_impairment_groupid: Uuid + evo_name: String + modifiedon: DateTime + statecode: Int + toObjectString: String +} + +type transactioncurrency { + createdon: DateTime + currencyname: String + isocurrencycode: String + modifiedon: DateTime + statecode: Int + toObjectString: String + transactioncurrencyid: Uuid +} + +type evo_businessunit { + createdon: DateTime + evo_businessunitid: Uuid + evo_name: String + evo_sale_businessunitid: Uuid + modifiedon: DateTime + toObjectString: String +} + +type evo_request_payment { + createdon: DateTime + evo_accountid: Uuid + evo_act_accept: Boolean + evo_agency_agreementid: Uuid + evo_agency_agreementidData: evo_agency_agreement + evo_agent_report_date: DateTime + evo_agent_report_summ: Decimal + evo_bank_code: String + evo_bank_detailsid: Uuid + evo_bank_detailsidData: evo_bank_details + evo_businessunitid: Uuid + evo_contractid: Uuid + evo_contractidData: evo_contract + evo_contract_paysum: Decimal + evo_contract_paysum_currency: Decimal + evo_contract_paysum_fact: Decimal + evo_director_decision: Int + evo_director_systemuserid: Uuid + evo_final_accept: Int + evo_finegibddid: Uuid + evo_finegibddidData: evo_finegibdd + evo_id: String + evo_insurance_policyid: Uuid + evo_insurance_policyidData: evo_insurance_policy + evo_leasingobjectid: Uuid + evo_name: String + evo_number_dkp: String + evo_oktmo_mreo: String + evo_opportunityid: Uuid + evo_paymentorders(evo_name: String, statecode: Int): [evo_paymentorder] + evo_payment_account: String + evo_payment_branch: Boolean + evo_payment_branch_accountid: Uuid + evo_payment_branch_accountidData: account + evo_payment_date: DateTime + evo_payment_recipient: Uuid + evo_payment_recipientData: account + evo_payorder_date: DateTime + evo_purpose_pay: String + evo_region_director_systemuserid: Uuid + evo_request_paymentid: Uuid + evo_request_payment_type: Int + evo_statuscodeid: Uuid + evo_storage: String + evo_supplier_payment_type: Int + evo_transactioncurrencyid: Uuid + evo_vat: Decimal + modifiedon: DateTime + toObjectString: String +} + +type evo_contract { + createdon: DateTime + emailaddress: String + evo_1c_date_state: Int + evo_1c_date_update: DateTime + evo_accountid: Uuid + evo_accountidData: account + evo_acc_singdoc_contactid: Uuid + evo_acquisition_costs: Decimal + evo_act_date: DateTime + evo_add_bonus_summ: Decimal + evo_agent_accountid: Uuid + evo_agent_reward: Decimal + evo_agent_reward_summ: Decimal + evo_approvallogs: [evo_approvallog] + evo_balance_holder: Int + evo_bank_detailsid: Uuid + evo_bank_detailsidData: evo_bank_details + evo_base_calc_pay: Decimal + evo_broker_accountid: Uuid + evo_broker_reward: Decimal + evo_broker_reward_conditionid: Uuid + evo_broker_reward_summ: Decimal + evo_businessunitid: Uuid + evo_calc_irr: Decimal + evo_calc_profit: Decimal + evo_cancel_contract: Boolean + evo_card_bonus_summ: Decimal + evo_check_scan_comment: String + evo_check_scan_result: Int + evo_claim_pledge_agreementid: Uuid + evo_client_type: Int + evo_contractid: Uuid + evo_contract_status_1c: Int + evo_contract_status_change_date_in_crm: DateTime + evo_contract_status_date_1c: DateTime + evo_dateend: DateTime + evo_date_of_pledge_claim: DateTime + evo_date_of_pledge_leasobject: DateTime + evo_date_termination: DateTime + evo_dealer_broker_accountid: Uuid + evo_dealer_broker_reward: Decimal + evo_dealer_broker_reward_conditionid: Uuid + evo_dealer_broker_reward_summ: Decimal + evo_dealer_person_accountid: Uuid + evo_dealer_person_accountidData: account + evo_dealer_person_reward: Decimal + evo_dealer_person_reward_conditionid: Uuid + evo_dealer_person_reward_summ: Decimal + evo_debtwork_contractid: Uuid + evo_debt_leasing: Decimal + evo_debt_penalty_fee: Decimal + evo_debt_total: Decimal + evo_delay_days_count: Int + evo_director_bonus: Decimal + evo_director_nsib_bonus: Decimal + evo_discount_perc: Decimal + evo_discount_supplier_currency: Decimal + evo_docdate: DateTime + evo_docdate_dkp: DateTime + evo_dogovortype: Int + evo_dog_credit: Decimal + evo_double_agent_accountid: Uuid + evo_double_agent_reward: Decimal + evo_double_agent_reward_conditionid: Uuid + evo_double_agent_reward_summ: Decimal + evo_economic: Decimal + evo_end_date_of_pledge_claim: DateTime + evo_end_date_of_pledge_leasobject: DateTime + evo_expinput_actual_date: DateTime + evo_fedres_xml_date: DateTime + evo_finegibdds: [evo_finegibdd] + evo_fin_department_accountid: Uuid + evo_fin_department_reward: Decimal + evo_fin_department_reward_conditionid: Uuid + evo_fin_department_reward_summ: Decimal + evo_first_payment_fact: Decimal + evo_first_payment_fact_date: DateTime + evo_first_payment_perc: Decimal + evo_first_payment_perc_without_subsidy: Decimal + evo_first_payment_rub: Decimal + evo_first_payment_rub_without_subsidy: Decimal + evo_forwarder_contactid: Uuid + evo_fuel_card_addproduct_typeid: Uuid + evo_graphs(statecode: Int): [evo_graph] + evo_graph_irr: Decimal + evo_graph_irr_actual: Decimal + evo_help_card_addproductid: Uuid + evo_help_card_addproductidData: evo_addproduct + evo_help_card_addproduct_typeid: Uuid + evo_importer_reward_rub: Decimal + evo_info_redemption_date: DateTime + evo_insurance_period: Int + evo_irr_msfo_final: Decimal + evo_irr_msfo_final2_actual: Decimal + evo_irr_msfo_final_actual: Decimal + evo_issue_date_buh: DateTime + evo_issue_place_addressid: Uuid + evo_last_payment_redemption: Boolean + evo_leasingobjectid: Uuid + evo_leasingobjectidData: evo_leasingobject + evo_leasing_bonus_summ: Decimal + evo_leasing_pledge_agreementid: Uuid + evo_log_activdate_1c: String + evo_msfo_irr: Decimal + evo_msfo_irr_actual: Decimal + evo_name: String + evo_net_irr: Decimal + evo_niatinception_msfo: Decimal + evo_niatinception_msfo_actual: Decimal + evo_ni_at_inception: Decimal + evo_ni_at_inception_actual: Decimal + evo_non_payment_count: Decimal + evo_npvni_msfo: Decimal + evo_npvni_msfo_final: Decimal + evo_nsib_bonus_summ: Decimal + evo_ns_bonus_summ: Decimal + evo_number_dkp: String + evo_paymentorders(evo_name: String, statecode: Int): [evo_paymentorder] + evo_period: Int + evo_price_without_discount: Decimal + evo_price_without_discount_supplier_currency: Decimal + evo_price_wthout_discount_nds_sup_currency: Decimal + evo_quoteid: Uuid + evo_rate: Decimal + evo_rateid: Uuid + evo_reason_change_account: Int + evo_ref_opportunityid: Uuid + evo_region_director_nsib_bonus: Decimal + evo_registration_addproductid: Uuid + evo_registration_addproductidData: evo_addproduct + evo_registration_addproduct_typeid: Uuid + evo_signer_different_contactid: Uuid + evo_signer_different_dkpid: Uuid + evo_signer_different_systemuserid: Uuid + evo_singdoc_systemuserid: Uuid + evo_statuscodeid: Uuid + evo_statuscodeidData: evo_statuscode + evo_storage: String + evo_subsidyid: Uuid + evo_subsidy_solution: Int + evo_subsidy_summ: Decimal + evo_subsidy_validity_date: DateTime + evo_supplier_accountid: Uuid + evo_supplier_bank_detailsid: Uuid + evo_supplier_bank_detailsidData: evo_bank_details + evo_supplier_currency_price: Decimal + evo_supplier_pay1_sum: Decimal + evo_supplier_payfull_date: DateTime + evo_supplier_pay_actual: Decimal + evo_supplier_pay_actual_currency: Decimal + evo_supplier_signer_contactid: Uuid + evo_telematics_addproduct_typeid: Uuid + evo_telematics_addproduct_typeid_new: Uuid + evo_telematics_equipment_addproductid: Uuid + evo_telematics_equipment_addproductidData: evo_addproduct + evo_telematics_service_addproductid: Uuid + evo_termreason: Int + evo_tracking_addproductid: Uuid + evo_tracking_addproductidData: evo_addproduct + evo_tracking_addproduct_typeid: Uuid + evo_tracking_addproduct_typeid_new: Uuid + evo_trade_in_accountid: Uuid + evo_trade_in_cost_pre: Decimal + evo_transactioncurrencyid: Uuid + evo_transactioncurrencyidData: transactioncurrency + evo_vehicle_tax_period: Decimal + evo_vehicle_tax_year: Decimal + modifiedon: DateTime + ownerid: Uuid + toObjectString: String +} + +type evo_external_system_request { + createdon: DateTime + evo_accountid: Uuid + evo_accountidData: account + evo_addcontractid: Uuid + evo_addproductid: Uuid + evo_agency_agreementid: Uuid + evo_contactid: Uuid + evo_contractid: Uuid + evo_credreg_report_code: String + evo_emailid: Uuid + evo_emailidData: email + evo_external_system_requestid: Uuid + evo_finegibddid: Uuid + evo_insurance_periodid: Uuid + evo_insurance_policyid: Uuid + evo_integration_status: Int + evo_log: String + evo_name: String + evo_number_repetitions_fact: Int + evo_number_repetitions_plan: Int + evo_opportunityid: Uuid + evo_path_report: String + evo_prima_requestid: String + evo_request_paymentid: Uuid + evo_request_paymentidData: evo_request_payment + evo_system: Int + modifiedon: DateTime + toObjectString: String +} + +type evo_paymentorder { + createdon: DateTime + evo_account_name_text: String + evo_comment: String + evo_contractid: Uuid + evo_correction_date_1c: DateTime + evo_correction_number_1c: String + evo_dds_1c: String + evo_inn_text: String + evo_insurance_periodid: Uuid + evo_name: String + evo_paydate: DateTime + evo_paydate_fact: DateTime + evo_paymentorderid: Uuid + evo_payment_number_1c: String + evo_payment_type: Int + evo_paystatus: Int + evo_paysum: Decimal + evo_received_not_from_client: Boolean + evo_request_paymentid: Uuid + modifiedon: DateTime + statecode: Int + statuscode: Int + toObjectString: String +} + +type evo_vehicle_body_typeGraphQL { + createdon: DateTime + evo_id: Int + evo_id_elt: String + evo_name: String + evo_vehicle_body_typeid: Uuid + modifiedon: DateTime + toObjectString: String +} + +type evo_coefficient { + createdon: DateTime + evo_businessunitid: Uuid + evo_businessunits(statecode: Int): [evo_businessunit] + evo_client_riskid: Uuid + evo_client_typeid: Uuid + evo_coefficientid: Uuid + evo_corfficient_type: Int + evo_correction_coefficient: Decimal + evo_datefrom: DateTime + evo_dateto: DateTime + evo_graph_type: Int + evo_job_titleid: Uuid + evo_leasingobject_types(statecode: Int): [evo_leasingobject_type] + evo_max_period: Int + evo_min_period: Int + evo_name: String + evo_risk_delta: Decimal + evo_season_type: Int + evo_sot_coefficient: Decimal + evo_sot_coefficient_typeid: Uuid + modifiedon: DateTime + statecode: Int + toObjectString: String +} + +type evo_planpayment { + createdon: DateTime + evo_addproduct_typeid: Uuid + evo_cashflow_nsib: Decimal + evo_cost_equipment: Decimal + evo_cost_equipment_withoutnds: Decimal + evo_cost_price_telematics: Decimal + evo_cost_price_telematics_withoutnds: Decimal + evo_cost_telematics: Decimal + evo_cost_telematics_withoutnds: Decimal + evo_early_repayment_sum: Decimal + evo_fix_calc_sum: Decimal + evo_graphid: Uuid + evo_name: String + evo_nds: Decimal + evo_nsib_brutto: Decimal + evo_nsib_expenses: Decimal + evo_nsib_revenue: Decimal + evo_payment_ratio: Decimal + evo_plandate: DateTime + evo_planpaymentid: Uuid + evo_pl_sum: Decimal + evo_remaining_payments: Decimal + evo_subsidy_summ: Decimal + evo_sum: Decimal + evo_sum_withoutnds: Decimal + modifiedon: DateTime + ownerid: Uuid + statecode: Int + toObjectString: String +} + +type evo_tarif { + createdon: DateTime + evo_balance_holder: [Int!] + evo_baseproductid: Uuid + evo_client_risks(statecode: Int): [evo_client_risk] + evo_client_types(statecode: Int): [evo_client_type] + evo_datefrom: DateTime + evo_dateto: DateTime + evo_delivery_time: [Int!] + evo_graphtype_exception: [Int!] + evo_id: String + evo_ins_type: [Int!] + evo_irr: Decimal + evo_irr_plan: Decimal + evo_leasingobject_types(statecode: Int): [evo_leasingobject_type] + evo_max_first_payment: Decimal + evo_max_irr: Decimal + evo_max_last_payment: Decimal + evo_max_period: Decimal + evo_min_first_payment: Decimal + evo_min_irr: Decimal + evo_min_last_payment: Decimal + evo_min_period: Decimal + evo_min_profit: Decimal + evo_models(statecode: Int): [evo_model] + evo_model_exceptions(statecode: Int): [evo_model] + evo_name: String + evo_rates(statecode: Int): [evo_rate] + evo_tarifid: Uuid + evo_transactioncurrencyid: Uuid + evo_used: Boolean + modifiedon: DateTime + statecode: Int + toObjectString: String +} + +type evo_rate { + createdon: DateTime + evo_base_rate: Decimal + evo_brands(statecode: Int): [evo_brand] + evo_coeff_12_23: Decimal + evo_coeff_24_35: Decimal + evo_coeff_36_47: Decimal + evo_coeff_48_60: Decimal + evo_coeff_7_11: Decimal + evo_credit_period: Int + evo_datefrom: DateTime + evo_dateto: DateTime + evo_id: String + evo_name: String + evo_rateid: Uuid + evo_tarifs(statecode: Int): [evo_tarif] + modifiedon: DateTime + toObjectString: String +} + +type evo_sot_coefficient_type { + createdon: DateTime + evo_id: String + evo_name: String + evo_sot_coefficient_typeid: Uuid + modifiedon: DateTime + statecode: Int + toObjectString: String +} + +type evo_job_title { + createdon: DateTime + evo_id: String + evo_job_titleid: Uuid + evo_name: String + modifiedon: DateTime + toObjectString: String +} + +type evo_address { + createdon: DateTime + evo_addressid: Uuid + evo_address_name: String + evo_area: String + evo_area_fias_id: String + evo_area_type: String + evo_area_type_full: String + evo_area_with_type: String + evo_block: String + evo_block_type: String + evo_block_type_full: String + evo_city: String + evo_city_district: String + evo_city_district_fias_id: String + evo_city_district_type: String + evo_city_district_type_full: String + evo_city_district_with_type: String + evo_city_fias_id: String + evo_city_type: String + evo_city_type_full: String + evo_city_with_type: String + evo_country: String + evo_country_iso_code: String + evo_federal_district: String + evo_fias: Boolean + evo_fias_code: String + evo_fias_level: Int + evo_flat: String + evo_flat_type: String + evo_flat_type_full: String + evo_geo_lat: String + evo_geo_lon: String + evo_house: String + evo_house_fias_id: String + evo_house_type: String + evo_house_type_full: String + evo_postal_box: String + evo_postal_code: String + evo_region: String + evo_regionid: Uuid + evo_region_fias_id: String + evo_region_iso_code: String + evo_region_type: String + evo_region_type_full: String + evo_region_with_type: String + evo_settlement: String + evo_settlement_fias_id: String + evo_settlement_type: String + evo_settlement_type_full: String + evo_settlement_with_type: String + evo_street: String + evo_street_fias_id: String + evo_street_type: String + evo_street_type_full: String + evo_street_with_type: String + modifiedon: DateTime + toObjectString: String +} + +type systemuser { + businessunitid: Uuid + createdon: DateTime + domainname: String + evo_baseproducts(statecode: Int): [evo_baseproduct] + evo_callrecords_access: Boolean + evo_datebirth: DateTime + evo_employee_id: String + evo_fedresurs_rules: Boolean + evo_identity_documents: [evo_identity_document] + evo_job_titleid: Uuid + evo_loader: String + evo_role_treasury: Boolean + evo_sfm: Boolean + evo_wordmergerui_access: Boolean + firstname: String + fullname: String + jobtitle: String + lastname: String + middlename: String + mobilephone: String + modifiedon: DateTime + systemuserid: Uuid + toObjectString: String +} + +type evo_identity_document { + createdon: DateTime + evo_citizenship_countryid: Uuid + evo_code: String + evo_docnumber: String + evo_doctype: Int + evo_employee_systemuserid: Uuid + evo_identity_documentid: Uuid + evo_issueby: String + evo_issuedate: DateTime + evo_placebirth: String + evo_registration_addressid: Uuid + evo_seria: String + modifiedon: DateTime + toObjectString: String +} + +type evo_countryGraphQL { + createdon: DateTime + evo_alpha2_code: String + evo_code_numeric: String + evo_countryid: Uuid + modifiedon: DateTime + toObjectString: String +} + +type evo_finegibdd { + createdon: DateTime + evo_accountid: Uuid + evo_contractid: Uuid + evo_contractidData: evo_contract + evo_date_send_accrued: DateTime + evo_date_send_email: DateTime + evo_decree_date: DateTime + evo_decree_judicial_date: DateTime + evo_decree_judicial_number: String + evo_decree_number: String + evo_finegibddid: Uuid + evo_fine_creat: Int + evo_gibdd_accountid: Uuid + evo_kbk: String + evo_leasingobjectid: Uuid + evo_name: String + evo_oktmo: String + evo_payorder_date: DateTime + evo_payorder_sum: Decimal + evo_pay_before: DateTime + evo_storage: String + evo_sum: Decimal + evo_sum_discount: Decimal + modifiedon: DateTime + toObjectString: String +} + +type evo_agency_agreement { + createdon: DateTime + evo_add_agency_agreementid: Uuid + evo_agency_agreementid: Uuid + evo_agency_agreement_number: String + evo_agency_agreement_type: Int + evo_agent_accountid: Uuid + evo_bank_detailsid: Uuid + evo_boss_comment: String + evo_boss_decision: Int + evo_businessunitid: Uuid + evo_contactid: Uuid + evo_datefrom: DateTime + evo_dateto: DateTime + evo_date_change_statuscode: DateTime + evo_director_comment: String + evo_director_decision: Int + evo_name: String + evo_number: Int + evo_region_director_comment: String + evo_region_director_decision: Int + evo_signer_systemuserid: Uuid + evo_statuscodeid: Uuid + evo_storage: String + evo_termination_doc_date: DateTime + evo_termination_type: Int + evo_term_boss_systemuserid: Uuid + evo_term_director_systemuserid: Uuid + evo_term_region_director_systemuserid: Uuid + evo_term_topboss_systemuserid: Uuid + evo_topboss_comment: String + evo_topboss_decision: Int + evo_top_termination: Int + modifiedon: DateTime + ownerid_systemuser: Uuid + ownerid_team: Uuid + toObjectString: String +} + +type evo_addcontract { + createdon: DateTime + evo_accountid: Uuid + evo_accountid_new: Uuid + evo_account_change: Boolean + evo_acquisition_costs: Decimal + evo_activdate_1c: DateTime + evo_activdate_crm: DateTime + evo_addcontractid: Uuid + evo_add_bonus_summ: Decimal + evo_agent_reward_summ: Decimal + evo_age_drivers: Int + evo_age_drivers_new: Int + evo_balance: Int + evo_balance_change: Boolean + evo_balance_new: Int + evo_bank_detailsid: Uuid + evo_bank_detailsid_new: Uuid + evo_base: String + evo_base_bonus: Decimal + evo_base_calc_pay: Decimal + evo_base_new: String + evo_broker_reward_summ: Decimal + evo_businessunitid: Uuid + evo_calculation_method: Int + evo_calculator_type: Int + evo_calc_profit: Decimal + evo_category: Int + evo_category_new: Int + evo_category_tr: Int + evo_category_tr_new: Int + evo_certificate: String + evo_certificate_date: DateTime + evo_certificate_date_new: DateTime + evo_certificate_issued: String + evo_certificate_issued_new: String + evo_certificate_new: String + evo_change_payment_date: Boolean + evo_chassis: String + evo_chassis_new: String + evo_color: String + evo_color_new: String + evo_contractid: Uuid + evo_contract_term_change: Boolean + evo_cost_change: Boolean + evo_cost_currency_change: Boolean + evo_dateend: DateTime + evo_date_addcontract: DateTime + evo_date_calculation_done: DateTime + evo_date_offset_change: Boolean + evo_deadline_date: DateTime + evo_dealer_broker_accountid: Uuid + evo_dealer_broker_accountid_new: Uuid + evo_dealer_broker_reward: Decimal + evo_dealer_broker_reward_conditionid: Uuid + evo_dealer_broker_reward_conditionid_new: Uuid + evo_dealer_broker_reward_new: Decimal + evo_dealer_broker_reward_summ: Decimal + evo_dealer_broker_reward_summ_new: Decimal + evo_dealer_person_accountid: Uuid + evo_dealer_person_accountid_new: Uuid + evo_dealer_person_reward: Decimal + evo_dealer_person_reward_conditionid: Uuid + evo_dealer_person_reward_conditionid_new: Uuid + evo_dealer_person_reward_new: Decimal + evo_dealer_person_reward_summ: Decimal + evo_dealer_person_reward_summ_new: Decimal + evo_deviation_investments_withoutnds: Decimal + evo_deviation_irr: Decimal + evo_dgo_price: Decimal + evo_dgo_price_new: Decimal + evo_director_bonus: Decimal + evo_discount_perc: Decimal + evo_discount_perc_new: Decimal + evo_discount_supplier_currency: Decimal + evo_discount_supplier_currency_new: Decimal + evo_dog_credit: Decimal + evo_dog_credit_new: Decimal + evo_double_agent_reward_summ: Decimal + evo_driving_axle: String + evo_driving_axle_new: String + evo_early_change_discount: Boolean + evo_early_discount_perc: Decimal + evo_early_redemption_change: Boolean + evo_ecological_class: Int + evo_ecological_class_new: Int + evo_economic: Decimal + evo_emailaddress: String + evo_emailaddress_new: String + evo_engine_model: String + evo_engine_model_new: String + evo_engine_power: Decimal + evo_engine_power_kvt: Decimal + evo_engine_power_kvt_new: Decimal + evo_engine_power_new: Decimal + evo_engine_type: Int + evo_engine_type_new: Int + evo_engine_volume: Decimal + evo_engine_volume_new: Decimal + evo_exp_drivers: Int + evo_exp_drivers_new: Int + evo_fin_department_reward_conditionid: Uuid + evo_fin_department_reward_conditionid_new: Uuid + evo_fin_department_reward_summ: Decimal + evo_fin_department_reward_summ_new: Decimal + evo_fix_last_payment: Boolean + evo_franchise: Decimal + evo_franchise_new: Decimal + evo_gos_akt: String + evo_gos_akt_new: String + evo_graph_irr: Decimal + evo_importer_reward_rub: Decimal + evo_insurance_change: Boolean + evo_insurance_period: Int + evo_insurance_period_new: Int + evo_insurance_price_result: Decimal + evo_insurance_price_result_new: Decimal + evo_insurer_kasko_accountid: Uuid + evo_insurer_kasko_accountid_new: Uuid + evo_insurer_osago_accountid: Uuid + evo_insurer_osago_accountid_new: Uuid + evo_ins_period_kasko_number: Int + evo_ins_period_osago_date: DateTime + evo_ins_period_osago_number: Int + evo_irr_msfo_final: Decimal + evo_irr_msfo_final2: Decimal + evo_kasko_elt_id: String + evo_kasko_elt_id_new: String + evo_kasko_id_elt_calc: String + evo_kasko_id_elt_calc_new: String + evo_kasko_price: Decimal + evo_kasko_price_new: Decimal + evo_last_day_month: Boolean + evo_last_payment_change: Boolean + evo_last_payment_redemption: Boolean + evo_last_payment_redemption_new: Boolean + evo_leasingobjectid: Uuid + evo_leasingobject_specification: String + evo_leasingobject_specification_new: String + evo_leasing_bonus_summ: Decimal + evo_log_activdate_1c: String + evo_maker: String + evo_maker_new: String + evo_max_mass: Decimal + evo_max_mass_new: Decimal + evo_max_speed: Decimal + evo_max_speed_new: Decimal + evo_motor_power_1: String + evo_motor_power_1_new: String + evo_msfo_irr: Decimal + evo_name: String + evo_net_irr: Decimal + evo_niatinception_msfo: Decimal + evo_ni_at_inception: Decimal + evo_npvni_msfo: Decimal + evo_npvni_msfo_final: Decimal + evo_ns_bonus_summ: Decimal + evo_ns_price: Decimal + evo_ns_price_new: Decimal + evo_number_paydate: DateTime + evo_number_planpaymentid: Uuid + evo_object_number: String + evo_object_number_new: String + evo_osago_elt_id: String + evo_osago_elt_id_new: String + evo_osago_id_elt_calc: String + evo_osago_id_elt_calc_new: String + evo_osago_price: Decimal + evo_osago_price_new: Decimal + evo_passport_address: String + evo_passport_address_new: String + evo_passport_brand_model: String + evo_passport_brand_model_new: String + evo_passport_company: String + evo_passport_company_new: String + evo_passport_date: DateTime + evo_passport_date_new: DateTime + evo_passport_engine_type: String + evo_passport_engine_type_new: String + evo_passport_name: String + evo_passport_name_new: String + evo_passport_number: String + evo_passport_number_new: String + evo_passport_seria: String + evo_passport_seria_new: String + evo_passport_type: Int + evo_passport_type_new: Int + evo_payer_kasko: Int + evo_payer_kasko_new: Int + evo_payer_osago: Int + evo_payer_osago_new: Int + evo_payment_redemption: Int + evo_period: Int + evo_period_new: Int + evo_price_without_discount: Decimal + evo_price_without_discount_new: Decimal + evo_price_without_discount_supplier_rub: Decimal + evo_price_without_discount_supplier_rub_new: Decimal + evo_price_without_disc_supplier_currency: Decimal + evo_price_without_disc_supplier_currency_new: Decimal + evo_price_wthout_disc_nds_sup_currency: Decimal + evo_price_wthout_disc_nds_sup_currency_new: Decimal + evo_prop_type: String + evo_prop_type_new: String + evo_pts_change: Boolean + evo_pts_type: Int + evo_pts_type_new: Int + evo_quoteid: Uuid + evo_recalculate_demand: Boolean + evo_refuse_reason: Int + evo_regionid: Uuid + evo_regionid_new: Uuid + evo_registration: Int + evo_registration_addproduct_typeid: Uuid + evo_registration_addproduct_typeid_new: Uuid + evo_registration_change: Boolean + evo_registration_new: Int + evo_registration_regionid: Uuid + evo_registration_regionid_new: Uuid + evo_seats: Int + evo_seats_new: Int + evo_signatory_evo_systemuserid: Uuid + evo_signatory_lp_contactid: Uuid + evo_signatory_lp_contactid_new: Uuid + evo_source: Int + evo_specification_change: Boolean + evo_statuscodeid: Uuid + evo_statuscodeidData: evo_statuscode + evo_statuscode_reason: String + evo_storage: String + evo_sum_pay_change: Boolean + evo_supplier_accountid: Uuid + evo_supplier_accountid_new: Uuid + evo_supplier_bank_detailsid: Uuid + evo_supplier_bank_detailsid_new: Uuid + evo_supplier_change: Boolean + evo_supplier_currency_price: Decimal + evo_supplier_currency_price_new: Decimal + evo_supplier_pay_actual: Decimal + evo_supplier_pay_actual_currency: Decimal + evo_supplier_signer_contactid_new: Uuid + evo_telematics_addproduct_typeid: Uuid + evo_telematics_addproduct_typeid_new: Uuid + evo_townid: Uuid + evo_townid_new: Uuid + evo_tracking_addproduct_typeid: Uuid + evo_tracking_addproduct_typeid_new: Uuid + evo_tracking_control_change: Boolean + evo_transmission_number: String + evo_transmission_number_new: String + evo_type_agreement: Int + evo_type_change_registration: Int + evo_type_change_telematics: Int + evo_type_change_tracking: Int + evo_unlimit_drivers: Boolean + evo_unlimit_drivers_new: Boolean + evo_vacation_number_months: Int + evo_vehicle_tax_approved: Decimal + evo_vehicle_tax_approved_new: Decimal + evo_vehicle_tax_period: Decimal + evo_vehicle_tax_period_new: Decimal + evo_vehicle_tax_year: Decimal + evo_vehicle_tax_year_new: Decimal + evo_vehicle_type_tax: Int + evo_vehicle_type_tax_new: Int + evo_vin: String + evo_vin_new: String + evo_year: Int + evo_year_new: Int + modifiedon: DateTime + ownerid: Uuid + toObjectString: String +} + +type email { + activityid: Uuid + createdon: DateTime + description: String + email_activity_parties: [activityparty] + evo_accountid: Uuid + modifiedon: DateTime + regardingobjectid_account: Uuid + regardingobjectid_evo_contract: Uuid + regardingobjectid_evo_insurance_period: Uuid + regardingobjectid_evo_insurance_policy: Uuid + regardingobjectid_evo_insurance_policyData: evo_insurance_policy + regardingobjectid_evo_list: Uuid + regardingobjectid_opportunity: Uuid + statuscode: Int + subject: String + templateid: Uuid + toObjectString: String +} + +type evo_bank_details { + createdon: DateTime + evo_accountid: Uuid + evo_bankid: Uuid + evo_bankidData: account + evo_bank_code: String + evo_bank_detailsid: Uuid + evo_contactid: Uuid + evo_corresponding_account: String + evo_kbk: String + evo_name: String + evo_payment_account: String + modifiedon: DateTime + toObjectString: String +} + +type queue { + createdon: DateTime + emailaddress: String + evo_id: String + modifiedon: DateTime + name: String + queueid: Uuid + toObjectString: String +} + +type template { + body: String + createdon: DateTime + description: String + modifiedon: DateTime + subject: String + templateid: Uuid + toObjectString: String +} + +type MutationBy { + createEntity(data: EntityDataInput): Uuid! + updateEntity(data: EntityDataInput): Boolean! +} + +"""The `DateTime` scalar represents an ISO-8601 compliant date time type.""" +scalar DateTime + +input FilterInput { + fieldname: String + guidvalues: [Uuid] + intvalues: [Int!] + operation: FilterOperation! + stringvalues: [String] +} + +enum LogicOperation { + AND + OR +} + +enum SortingType { + DESC + ASC +} + +type evo_insurance_policy { + createdon: DateTime + evo_accountid: Uuid + evo_contractid: Uuid + evo_create_contract_elt: Boolean + evo_create_period_status: Int + evo_id: String + evo_insurance_periods(statecode: Int): [evo_insurance_period] + evo_insurance_policyid: Uuid + evo_insurer_accountid: Uuid + evo_ins_change_comment: String + evo_nsib_ins_summ: Decimal + evo_one_year_insurance: Boolean + evo_owner_comment: String + evo_pay_period: Int + evo_polis_number: String + evo_polis_type: Int + evo_pre_polis_number: String + evo_statuscodeid: Uuid + modifiedon: DateTime + statecode: Int + statuscode: Int + toObjectString: String +} + +type evo_addproductnumber { + createdon: DateTime + evo_addproductnumberid: Uuid + evo_insurance_type: Int + evo_name: String + evo_number_status: Int + modifiedon: DateTime + toObjectString: String +} + +type businessunit { + businessunitid: Uuid + createdon: DateTime + evo_addressid: Uuid + evo_boss_systemuserid: Uuid + evo_director_systemuserid: Uuid + evo_region_director_systgemuserid: Uuid + evo_region_director_systgemuseridname: String + modifiedon: DateTime + name: String + toObjectString: String +} + +type evo_approvallog { + createdon: DateTime + evo_addcontractid: Uuid + evo_agency_agreementid: Uuid + evo_approvallogid: Uuid + evo_contractid: Uuid + evo_incidentid: Uuid + evo_insurance_policyid: Uuid + evo_leadid: Uuid + evo_opportunityid: Uuid + evo_predate_change_statuscode: DateTime + evo_prestatuscodeid: Uuid + evo_quoteid: Uuid + evo_reason: String + evo_request_paymentid: Uuid + evo_statuscodeid: Uuid + evo_statuscodeidData: evo_statuscode + modifiedon: DateTime + toObjectString: String +} + +type activityparty { + addressused: String + createdon: DateTime + modifiedon: DateTime + participationtypemask: Int + partyid_account: Uuid + partyid_contact: Uuid + partyid_evo_contract: Uuid + partyid_queue: Uuid + partyid_systemuser: Uuid + toObjectString: String +} + +input EntityDataInput { + fields: [EntityFieldInput] + id: Uuid + logicalName: String +} + +enum FilterOperation { + ISNULL + EQUAL + CONTAINS + NOTCONTAINS + MORETHEN + MOREOREQUALTHEN + LESSTHEN + LESSOREQUALTHEN +} + +input EntityFieldInput { + activitypartiesvalue: [activitypartyInput] + boolvalue: Boolean + datetimevalue: DateTime + decimalvalue: Decimal + guidvalue: Uuid + intarrayvalue: [Int!] + intvalue: Int + key: String + stringvalue: String +} + +input activitypartyInput { + addressused: String + createdon: DateTime + modifiedon: DateTime + participationtypemask: Int + partyid_account: Uuid + partyid_contact: Uuid + partyid_evo_contract: Uuid + partyid_queue: Uuid + partyid_systemuser: Uuid +} diff --git a/src/core/services/CrmService/propsMap.ts b/src/core/services/CrmService/common/entitiesProps.ts similarity index 77% rename from src/core/services/CrmService/propsMap.ts rename to src/core/services/CrmService/common/entitiesProps.ts index 1567b29..c4c16d5 100644 --- a/src/core/services/CrmService/propsMap.ts +++ b/src/core/services/CrmService/common/entitiesProps.ts @@ -1,13 +1,30 @@ -import { TCRMEntity } from 'core/types/Entities/crmEntities'; -import { TEntities } from 'core/types/Entities/crmEntityNames'; +import { + IAccount, + IEvoAddproductType, + IEvoEquipment, + TCRMEntity, +} from 'core/types/Entities/crmEntities'; +import { CRMEntityNames } from 'core/types/Entities/crmEntityNames'; -const propsMap: TEntities<{ +type TGetName = (entity: any, targetName: string) => string; + +export type TEntityProps = Record<'value', keyof TCRMEntity> & { name?: keyof TCRMEntity; - value: keyof TCRMEntity; - getName?: (entity: TCRMEntity, targetName: string) => string | undefined; -}> = { + getName?: TGetName; +}; + +type ExcludeFromPropsMap = + | 'evo_currencychange' + | 'evo_sot_coefficient_type' + | 'evo_statuscode' + | 'systemuser'; + +const propsMap: Record< + Exclude, + TEntityProps +> = { account: { - getName: (account, targetName) => { + getName: (account: IAccount, targetName) => { if (['selectDealerPerson'].includes(targetName)) { return ` ${account.name} @@ -62,7 +79,7 @@ const propsMap: TEntities<{ value: 'evo_modelid', }, evo_equipment: { - getName: equipment => + getName: (equipment: IEvoEquipment) => `${equipment.evo_name} (${equipment.evo_start_production_year})`, value: 'evo_equipmentid', }, @@ -103,7 +120,7 @@ const propsMap: TEntities<{ value: 'evo_coefficientid', }, evo_addproduct_type: { - getName: (productType, targetName) => { + getName: (productType: IEvoAddproductType, targetName) => { if ( [ 'selectRegistration', @@ -115,7 +132,7 @@ const propsMap: TEntities<{ ) { return `${productType.evo_name} (${productType.evo_graph_price} руб.)`; } - return productType.evo_name; + return `${productType.evo_name}`; }, value: 'evo_addproduct_typeid', }, diff --git a/src/core/services/CrmService/index.ts b/src/core/services/CrmService/index.ts index 787e9b5..0fdb2fa 100644 --- a/src/core/services/CrmService/index.ts +++ b/src/core/services/CrmService/index.ts @@ -1,122 +1,45 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment */ +import { QueryOptions } from '@apollo/client'; import axios from 'axios'; import { CRM_PROXY_URL } from 'core/constants/urls'; -import { - ICreateKpRequest, - IMutateToCRMGQL, - IQueryToCRMGQL, -} from 'core/types/Calculation/Requests'; -import { IGetCRMEntitiesResponse } from 'core/types/Calculation/Responses'; -import { IBaseOption } from 'core/types/Calculation/Store/options'; +import GQLClient from 'core/graphql/client'; +import { ElementsNames } from 'core/types/Calculation/Store/elements'; import { IQuote, TCRMEntity } from 'core/types/Entities/crmEntities'; -import { TEntities } from 'core/types/Entities/crmEntityNames'; -import { cloneDeep } from 'lodash'; -import { isPlural, singular } from 'pluralize'; -import client from './client'; -import { convertEntityToOption } from './tools/entity'; +import { optionizeEntities } from './tools/entity'; +import { TOptionizedEntity } from './types/common'; +import { GQLVariables } from './types/request'; export default class { - static crmgqlquery = ({ - query, - toOptions, + public static getCRMEntities( + options: QueryOptions, Record>, + ): Promise>> { + return new Promise(resolve => { + GQLClient.query, GQLVariables>(options).then(res => + resolve(res.data), + ); + }); + } + + public static getCRMOptions< + K extends string = ElementsNames, + R = TCRMEntity, + >({ variables, - }: IQueryToCRMGQL): Promise => - new Promise((resolve, reject) => { - client - .query({ - query, - variables, - }) - .then(res => { - if (!res.data || res.errors) { - reject(res.error || res.errors); - } - const resEntities: TEntities = cloneDeep( - res.data, - ); + ...options + }: QueryOptions, Record>): Promise< + Partial[]>> + > { + return new Promise(resolve => + this.getCRMEntities({ + variables, + ...options, + }).then(entities => resolve(optionizeEntities(entities))), + ); + } - if (toOptions) - Object.keys(resEntities).forEach(targetName => { - const targetEnt: TCRMEntity | TCRMEntity[] = - resEntities[targetName]; - //@ts-ignore - if (toOptions.includes(targetName)) { - if (Array.isArray(targetEnt)) { - const optionatedEntities: (TCRMEntity & IBaseOption)[] = []; - for (const entity of targetEnt) { - const entityOption = convertEntityToOption( - targetName, - entity, - entity.__typename, - ); - if (entityOption) { - optionatedEntities.push(entityOption); - } - } - - resEntities[ - isPlural(targetName) ? singular(targetName) : targetName - ] = optionatedEntities; - } else { - const entityOption = convertEntityToOption( - targetName, - targetEnt, - targetEnt.__typename, - ); - - resEntities[ - isPlural(targetName) ? singular(targetName) : targetName - ] = entityOption; - } - } - }); - - resolve({ entities: resEntities }); - }) - .catch(err => { - reject(err); - }); - }); - - static crmgqlmutaion = ({ - mutation, - variables, - }: IMutateToCRMGQL): Promise => - new Promise((resolve, reject) => { - client - .mutate({ - mutation, - variables, - }) - .then(res => { - if (!res.data || res.errors) { - reject(res.errors); - } - - resolve({ entities: res.data?.entities }); - }) - .catch(err => { - reject(err); - }); - }); - - static createKp = (data: ICreateKpRequest): Promise => - new Promise((resolve, reject) => { - console.log('createKp data: ', data); - axios - .post( - String.prototype.concat( - CRM_PROXY_URL, - '/offer', - '/leasingcalculator', - ), - data, - ) - .then(res => { - resolve(res.data); - }) - .catch(err => { - reject(err); - }); - }); + public static createKP(data) { + return axios.post( + String.prototype.concat(CRM_PROXY_URL, '/offer', '/leasingcalculator'), + data, + ); + } } diff --git a/src/core/services/CrmService/tools/entity.ts b/src/core/services/CrmService/tools/entity.ts index 5c148eb..babfd7c 100644 --- a/src/core/services/CrmService/tools/entity.ts +++ b/src/core/services/CrmService/tools/entity.ts @@ -1,42 +1,39 @@ -import { IBaseOption } from 'core/types/Calculation/Store/options'; -import { TCRMEntity } from 'core/types/Entities/crmEntities'; -import { CRMEntityNames } from 'core/types/Entities/crmEntityNames'; -import propsMap from '../propsMap'; +import { CoreEntity } from 'core/types/Entities/crmEntities'; +import entitiesProps, { TEntityProps } from '../common/entitiesProps'; +import { TOptionizedEntity } from '../types/common'; -export function convertEntityToOption( +function convertEntityToOption( targetName: string, - entity: TCRMEntity, - entityName?: CRMEntityNames, -): (TCRMEntity & IBaseOption) | undefined { - if (!entityName) { - throw new Error('entityName is missing'); + entity: R, +): TOptionizedEntity { + const entityName = (entity as CoreEntity).__typename; + const entityProps: TEntityProps = entitiesProps[entityName]; + if (!entityProps) { + throw new Error(`${entityName} was not found in propsMap!`); } - if (!entity || !propsMap || !propsMap[entityName]) { - throw new Error(`${entityName} not found in propsMap!`); - } + const { name: nameProp, getName, value: valueProp } = entitiesProps[ + entityName + ]; - const entityPropsMap = propsMap[entityName]; - if (entityPropsMap) { - const { name: propName, getName, value: propValue } = entityPropsMap; + let name: string = entity[nameProp]; + if (getName) name = getName(entity, targetName); + const value = entity[valueProp]; - let name; - const value = entity[propValue]; - if (propName) { - name = entity[propName]; - } - if (getName) { - name = getName(entity, targetName); - } - - if (targetName) { - } - - const optionatedObject = { - ...entity, - name, - value, - }; - return optionatedObject; - } + return Object.assign({}, entity, { name, value }); +} + +export function optionizeEntities( + entities: Partial>, +): Partial[]>> { + return Object.keys(entities).reduce((acc, targetName) => { + let target: R[] = entities[targetName]; + if (!Array.isArray(entities[targetName])) target = [entities[targetName]]; + + const optionizedEntities = target.map(entity => + convertEntityToOption(targetName, entity), + ); + acc[targetName] = optionizedEntities; + return acc; + }, {} as Partial[]>>); } diff --git a/src/core/services/CrmService/types/common.ts b/src/core/services/CrmService/types/common.ts new file mode 100644 index 0000000..5655b6c --- /dev/null +++ b/src/core/services/CrmService/types/common.ts @@ -0,0 +1,8 @@ +import { BaseEntity } from 'core/types/Entities/crmEntities'; +export type IBaseOption = { + name: string; + value: any; + [prop: string]: any; +}; + +export type TOptionizedEntity = T & IBaseOption; diff --git a/src/core/services/CrmService/types/request.ts b/src/core/services/CrmService/types/request.ts new file mode 100644 index 0000000..1245f40 --- /dev/null +++ b/src/core/services/CrmService/types/request.ts @@ -0,0 +1,4 @@ +import { OperationVariables } from '@apollo/client'; + +export type GQLVariables = Partial> & + OperationVariables; diff --git a/src/core/tools/uuid.js b/src/core/tools/uuid.js new file mode 100644 index 0000000..94e18a0 --- /dev/null +++ b/src/core/tools/uuid.js @@ -0,0 +1 @@ +export const NIL = '00000000-0000-0000-0000-000000000000'; diff --git a/src/core/types/Calculation/Requests.ts b/src/core/types/Calculation/Requests.ts index 7de7477..0a3f2d2 100644 --- a/src/core/types/Calculation/Requests.ts +++ b/src/core/types/Calculation/Requests.ts @@ -1,47 +1,13 @@ -import { ColumnsNames, IColumn, PostValues } from 'core/types/Calculation/Core'; import { PreparedPayments, PreparedValues, } from 'core/types/Calculation/Prepare'; -import { ElementsNames } from 'core/types/Calculation/Store/elements'; -import { TableProps } from 'core/types/Calculation/Store/tables'; -import { TValues } from 'core/types/Calculation/Store/values'; -import { TCRMEntity } from 'core/types/Entities/crmEntities'; -import { CRMEntityNames } from 'core/types/Entities/crmEntityNames'; - -export interface IQueryToCRMGQL { - query: any; - toOptions?: CRMEntityNames[] | ElementsNames[]; - variables?: { - [prop in keyof TCRMEntity]: any; - } & { [prop: string]: any }; -} - -export interface IMutateToCRMGQL { - mutation: any; - variables?: { [prop: string]: any }; -} export interface IPreparedData { preparedPayments: PreparedPayments; preparedValues: PreparedValues; } -export interface ICreateKpRequest { - domainName: string; - calculation: { - insurances: TableProps[]; - preparedValues: PreparedValues; - preparedPayments: PreparedPayments; - postValues: PostValues; - calculationValues: TValues; - columns: { [column in ColumnsNames]?: IColumn }; - }; - elt: { - [insType: string]: any; - }; -} - export interface IGetTransTaxRequest { calcDate: Date; OKTMO: string; diff --git a/src/core/types/Calculation/Responses.ts b/src/core/types/Calculation/Responses.ts index b69b4a3..7beb35b 100644 --- a/src/core/types/Calculation/Responses.ts +++ b/src/core/types/Calculation/Responses.ts @@ -1,12 +1,6 @@ -import { TCRMEntity } from '../Entities/crmEntities'; -import { TEntities } from '../Entities/crmEntityNames'; import { ColumnsNames, IColumn, PostValues } from './Core'; import { PreparedValues } from './Prepare'; -export interface IGetCRMEntitiesResponse { - entities: TEntities; -} - export interface IGetCalculationResponse { columns: { [column in ColumnsNames]?: IColumn }; postValues: PostValues; diff --git a/src/core/types/Calculation/Store/filters.ts b/src/core/types/Calculation/Store/filters.ts index 7218f9b..5e4ad79 100644 --- a/src/core/types/Calculation/Store/filters.ts +++ b/src/core/types/Calculation/Store/filters.ts @@ -1,5 +1,5 @@ +import { IBaseOption } from 'core/services/CrmService/types/common'; import { TCRMEntity } from 'core/types/Entities/crmEntities'; -import { IBaseOption } from 'core/types/Calculation/Store/options'; export type TElementFilter = ( options: (TCRMEntity & IBaseOption)[], ) => (TCRMEntity & IBaseOption)[]; diff --git a/src/core/types/Calculation/Store/index.ts b/src/core/types/Calculation/Store/index.ts index 9bd8b42..a0c06b2 100644 --- a/src/core/types/Calculation/Store/index.ts +++ b/src/core/types/Calculation/Store/index.ts @@ -1,12 +1,15 @@ import { TCalculationProcess } from 'client/stores/CalculationStore/subStores/calculationProcess'; import { TCalculationUrls } from 'client/stores/CalculationStore/subStores/calculationUrls'; import { TELTStore } from 'client/stores/CalculationStore/subStores/eltStore'; +import { + IBaseOption, + TOptionizedEntity, +} from 'core/services/CrmService/types/common'; import { TCRMEntity } from '../../Entities/crmEntities'; import { CRMEntityNames } from '../../Entities/crmEntityNames'; import { ElementStatus } from '../../statuses'; import { ElementsNames, TElements } from './elements'; import { TElementFilter } from './filters'; -import { IBaseOption } from './options'; import { TStaticData } from './staticData'; import { ITable, @@ -30,20 +33,20 @@ interface ICalculationValues { getStaticData: (dataName: CRMEntityNames) => TCRMEntity[]; applyStaticData: (data: TStaticData) => void; - options: TElements<(IBaseOption & TCRMEntity)[]>; + options: TElements; getOption: ( elementName: ElementsNames, - fields?: { [field in keyof (IBaseOption & TCRMEntity)]: any }, + fields?: { [field in keyof (IBaseOption & TCRMEntity)]?: any }, ) => (IBaseOption & TCRMEntity) | undefined; getOptions: ( elementName: ElementsNames, - fields?: { [field in keyof (IBaseOption & TCRMEntity)]: any }, + fields?: { [field in keyof (IBaseOption & TCRMEntity)]?: any }, ) => (IBaseOption & TCRMEntity)[] | undefined; setOptions: ( elementName: ElementsNames, - options: (IBaseOption & TCRMEntity)[], + options: TOptionizedEntity[], ) => void; - applyOptions: (options: TElements<(IBaseOption & TCRMEntity)[]>) => void; + applyOptions: (options: TElements) => void; filters: TElements; getFilter: (elementName: ElementsNames) => TElementFilter | undefined; @@ -116,11 +119,7 @@ interface ICalculationTables { setTableColumns: ( tableName: TableNames, override?: boolean, - ) => ({ - options, - }: { - options?: TableProps<(IBaseOption & TCRMEntity)[]>; - }) => void; + ) => ({ options }: { options?: TableProps }) => void; } interface ICalculationStores { diff --git a/src/core/types/Calculation/Store/options.ts b/src/core/types/Calculation/Store/options.ts deleted file mode 100644 index 299b78b..0000000 --- a/src/core/types/Calculation/Store/options.ts +++ /dev/null @@ -1,8 +0,0 @@ -export type IBaseOption = { - /** - * TODO: Remove optional mark when remove fakes - */ - name?: string; - value?: string | number | boolean; - [prop: string]: any | any[]; -}; diff --git a/src/core/types/Calculation/Store/staticData.ts b/src/core/types/Calculation/Store/staticData.ts index 13aed0a..42e47db 100644 --- a/src/core/types/Calculation/Store/staticData.ts +++ b/src/core/types/Calculation/Store/staticData.ts @@ -1,6 +1,4 @@ -import { CRMEntityNames } from '../../Entities/crmEntityNames'; import { TCRMEntity } from './../../Entities/crmEntities'; +import { TEntities } from './../../Entities/crmEntityNames'; -export type TStaticData = { - [dataName in CRMEntityNames]?: TCRMEntity[]; -}; +export type TStaticData = TEntities; diff --git a/src/core/types/Calculation/Store/tables.ts b/src/core/types/Calculation/Store/tables.ts index e713cc8..1fe51d6 100644 --- a/src/core/types/Calculation/Store/tables.ts +++ b/src/core/types/Calculation/Store/tables.ts @@ -1,11 +1,11 @@ import { TCalculationProcess } from 'client/stores/CalculationStore/subStores/calculationProcess'; +import { IBaseOption } from 'core/services/CrmService/types/common'; import { Component } from 'core/types/Calculation/components'; import { ElementStatus } from '../../statuses'; import { ElementProps } from '../components'; import { ICalculationStore } from './'; import { TCRMEntity } from './../../Entities/crmEntities'; import { TElementFilter } from './filters'; -import { IBaseOption } from './options'; export type TableNames = 'tableInsurance' | 'tablePayments' | 'tableResults'; export type TableValuesNames = diff --git a/src/core/types/Entities/crmEntities.ts b/src/core/types/Entities/crmEntities.ts index 648f62f..991d57f 100644 --- a/src/core/types/Entities/crmEntities.ts +++ b/src/core/types/Entities/crmEntities.ts @@ -1,12 +1,22 @@ import { CRMEntityNames } from './crmEntityNames'; -export interface IAccount { +export interface CoreEntity { + __typename: CRMEntityNames; +} + +export interface BaseEntity { + statecode?: number; + createdon?: Date; + evo_id?: string; + evo_name?: string; +} + +export interface IAccount extends BaseEntity { name?: string; accountid?: string; evo_inn?: string; evo_account_type?: number; evo_supplier_type?: number; - statecode?: number; evo_fin_department_accountid?: string; evo_legal_form?: number; ownerid?: string; @@ -21,18 +31,22 @@ export interface IAccount { evo_legal_region_calc?: boolean; } -export interface IEvoAddress { +export interface ISalonProvider extends IAccount { + salonaccountid?: string; +} +export interface ISalonAgent extends ISalonProvider {} + +export interface IEvoAddress extends BaseEntity { evo_region_fias_id?: string; evo_city_fias_id?: string; } -export interface ILead { +export interface ILead extends BaseEntity { leadid?: string; fullname?: string; evo_opportunityid?: string; account?: string; ownerid?: string; - statecode?: number; evo_fin_department_accountid?: string; evo_broker_accountid?: string; evo_double_agent_accountid?: string; @@ -41,29 +55,37 @@ export interface ILead { owner_domainname?: string; evo_inn?: string; link?: string; + evo_programsolution?: number; } -export interface IOpportunity { +export interface IOpportunity extends BaseEntity { opportunityid?: string; accountid?: string; evo_leadid?: string; evo_client_riskid?: string; ownerid?: string; - statecode?: number; accountidData?: IAccount; parentaccountid?: string; evo_addproduct_types?: IEvoAddproductType[]; link?: string; } -export interface IQuote { +export interface IQuote extends BaseEntity { + evo_client_riskid?: string; + evo_addproduct_types?: IEvoAddproductType[]; + evo_gps_brandid?: string; + evo_double_agent_accountid?: string; + evo_dealer_broker_accountid?: string; + evo_dealer_person_accountid?: string; + evo_supplier_accountid?: string; + evo_modelid?: string; + evo_brandid?: string; quoteid?: string; quotenumber?: string; evo_leadid?: string; evo_recalc_limit?: number; evo_approved_first_payment?: number; ownerid?: string; - statecode?: number; evo_statuscodeid?: string; evo_statuscode?: IEvoStatusCode; evo_quotename?: string; @@ -105,34 +127,26 @@ export interface IQuote { evo_payment_redemption_sum?: number; } -export interface IEvoGraph { - createdon?: Date; +export interface IEvoGraph extends BaseEntity { evo_sumpay_withnds?: number; evo_planpayments?: IEvoPlanPayment[]; } -export interface ITransactionCurrency { +export interface ITransactionCurrency extends BaseEntity { transactioncurrencyid?: string; - statecode?: number; isocurrencycode?: string; } -export interface IEvoClientType { - evo_name?: string; +export interface IEvoClientType extends BaseEntity { evo_client_typeid?: string; - statecode?: number; } -export interface IEvoClientRisk { - evo_name?: string; +export interface IEvoClientRisk extends BaseEntity { evo_client_riskid?: string; - statecode?: number; } -export interface IEvoBaseproduct { - evo_name?: string; +export interface IEvoBaseproduct extends BaseEntity { evo_baseproductid?: string; - evo_id?: string; evo_relation?: number; evo_datefrom?: Date; evo_datefrom_param?: Date; @@ -141,9 +155,7 @@ export interface IEvoBaseproduct { evo_brands?: IEvoBrand[]; } -export interface IEvoLeasingObjectType { - evo_id?: string; - evo_name?: string; +export interface IEvoLeasingObjectType extends BaseEntity { evo_leasingobject_typeid?: string; evo_depreciation_rate1?: number; evo_depreciation_rate2?: number; @@ -156,25 +168,21 @@ export interface IEvoLeasingObjectType { evo_vehicle_type_tax?: number; evo_vehicle_type?: number[]; } -export interface IEvoBrand { - evo_name?: string; +export interface IEvoBrand extends BaseEntity { evo_brandid?: string; evo_brand_owner?: number; evo_importer_reward_perc?: number; evo_importer_reward_rub?: number; - statecode?: number; evo_vehicle_type?: number[]; } -export interface IEvoModel { - evo_name?: string; +export interface IEvoModel extends BaseEntity { evo_brandid?: string; evo_modelid?: string; evo_impairment_groupid?: string; evo_leasingobject_risk?: number; evo_importer_reward_perc?: number; evo_importer_reward_rub?: number; - statecode?: number; evo_baseproduct?: any; evo_vehicle_type?: number; evo_gps?: boolean; @@ -184,118 +192,92 @@ export interface IEvoModel { evo_running_gear?: number; } -export interface IEvoEquipment { +export interface IEvoEquipment extends BaseEntity { evo_equipmentid?: string; - evo_name?: string; evo_modelid?: string; evo_impairment_groupid?: string; evo_leasingobject_risk?: number; evo_start_production_year?: number; - statecode?: number; evo_supplier_accountid?: string; evo_dealer_person_accountid?: string; evo_dealer_broker_accountid?: string; evo_vehicle_type?: number; } -export interface IEvoRewardCondition { +export interface IEvoRewardCondition extends BaseEntity { evo_reward_conditionid?: string; - evo_name?: string; evo_datefrom?: Date; evo_dateto?: Date; evo_agent_accountid?: string; evo_double_agent_accountid?: string; evo_reward_summ?: number; - statecode?: number; evo_reduce_reward?: boolean; } -export interface IEvoGPSBrand { +export interface IEvoGPSBrand extends BaseEntity { evo_gps_brandid?: string; - evo_name?: string; - statecode?: number; } -export interface IEvoGPSModel { +export interface IEvoGPSModel extends BaseEntity { evo_gps_modelid?: string; - evo_name?: string; evo_gps_brandid?: string; - statecode?: number; evo_moto?: boolean; } -export interface IEvoRegion { - evo_name?: string; +export interface IEvoRegion extends BaseEntity { evo_regionid?: string; evo_fias_id?: string; - statecode?: number; evo_businessunit_evolution?: boolean; evo_oktmo?: string; accounts?: IAccount[]; evo_kladr_id?: string; } -export interface IEvoTown { - evo_name?: string; +export interface IEvoTown extends BaseEntity { evo_townid?: string; - statecode?: number; evo_fias_id?: string; evo_kladr_id?: string; evo_businessunit_evolution?: boolean; } -export interface IEvoContact { +export interface IEvoContact extends BaseEntity { parentcustomerid?: string; contactid?: string; fullname?: string; - statecode?: number; } -export interface IConnection { - evo_name?: string; +export interface IConnection extends BaseEntity { connectionid?: string; record1id?: string; record2id?: string; record2roleid?: string; - statecode?: number; } -export interface IEvoConnectionRole { - evo_name?: string; +export interface IEvoConnectionRole extends BaseEntity { evo_connection_roleid?: string; - statecode?: number; } -export interface IEvoImpairmentGroup { - evo_name?: string; +export interface IEvoImpairmentGroup extends BaseEntity { evo_impairment_groupid?: string; - statecode?: number; } -export interface IEvoCurrencyChange { +export interface IEvoCurrencyChange extends BaseEntity { evo_currencychangeid?: string; - evo_name?: string; evo_ref_transactioncurrency?: string; evo_currencychange?: number; evo_coursedate?: Date; - statecode?: number; evo_coursedate_param?: any; } -export interface IEvoStatusCode { +export interface IEvoStatusCode extends BaseEntity { evo_statuscodeid?: string; - evo_id?: string; - evo_name?: string; importsequencenumber?: number; - statecode?: number; } -export interface IEvoBusinessunit { - evo_name?: string; +export interface IEvoBusinessunit extends BaseEntity { evo_businessunitid?: string; evo_sale_businessunitid?: string; } -export interface IEvoCoefficient { +export interface IEvoCoefficient extends BaseEntity { evo_coefficientid?: string; evo_corfficient_type?: number; - statecode?: number; evo_datefrom?: Date; evo_dateto?: Date; evo_min_period?: number; @@ -313,13 +295,12 @@ export interface IEvoCoefficient { evo_businessunits?: IEvoBusinessunit[]; } -export interface IEvoAddproductType { +export interface IEvoAddproductType extends BaseEntity { evo_addproduct_typeid?: string; evo_graph_price?: number; evo_prime_cost?: number; evo_cost_service_provider?: number; evo_retro_bonus?: number; - statecode?: number; evo_product_type?: number; evo_datefrom?: Date; evo_dateto?: Date; @@ -345,9 +326,7 @@ export interface IEvoAddproductType { evo_gibdd_region?: boolean; } -export interface IEvoTarif { - evo_id?: string; - evo_name?: string; +export interface IEvoTarif extends BaseEntity { evo_tarifid?: string; evo_baseproductid?: string; evo_irr?: number; @@ -367,7 +346,6 @@ export interface IEvoTarif { evo_dateto?: Date; evo_irr_plan?: number; evo_used?: boolean; - statecode?: number; evo_ins_type?: number; evo_client_risks?: IEvoClientRisk[]; evo_leasingobject_types?: IEvoLeasingObjectType[]; @@ -377,10 +355,7 @@ export interface IEvoTarif { evo_delivery_time?: number[]; } -export interface IEvoRate { - createdon?: Date; - evo_id?: string; - evo_name?: string; +export interface IEvoRate extends BaseEntity { evo_rateid?: string; evo_base_rate?: number; evo_coeff_12_23?: number; @@ -390,15 +365,13 @@ export interface IEvoRate { evo_coeff_7_11?: number; evo_datefrom?: Date; evo_dateto?: Date; - statecode?: number; evo_brands?: IEvoBrand[]; evo_credit_period?: number; evo_tarifs?: IEvoTarif[]; } -export interface IEvoPlanPayment { +export interface IEvoPlanPayment extends BaseEntity { evo_planpaymentid?: string; - evo_name?: string; evo_cost_telematics_withoutnds?: number; evo_cost_price_telematics_withoutnds?: number; evo_cost_equipment_withoutnds?: number; @@ -406,31 +379,25 @@ export interface IEvoPlanPayment { evo_payment_ratio?: number; } -export interface ISystemUser { +export interface ISystemUser extends BaseEntity { domainname?: string; systemuserid?: string; evo_job_titleid?: string; - statecode?: number; firstname?: string; lastname?: string; fullname?: string; businessunitid?: string; } -export interface IEvoSotCoefficientType { - evo_id?: string; - statecode?: number; +export interface IEvoSotCoefficientType extends BaseEntity { evo_sot_coefficient_typeid?: string; - evo_name?: string; } -export interface IEvoJobTitle { - evo_id?: string; - evo_name?: string; +export interface IEvoJobTitle extends BaseEntity { evo_job_titleid?: string; } -export interface IEvoSubsidy { +export interface IEvoSubsidy extends BaseEntity { evo_subsidy_summ?: number; evo_percent_subsidy?: number; evo_max_subsidy_summ?: number; @@ -441,12 +408,7 @@ export interface IEvoSubsidy { accounts?: IAccount[]; } -type BaseEntity = { - __typename?: CRMEntityNames; -}; - -export type TCRMEntity = BaseEntity & - IAccount & +export type TCRMEntity = IAccount & ILead & IOpportunity & IQuote &