merge refactor/january-2022 pt.1

This commit is contained in:
Chika 2022-01-12 15:35:19 +03:00
parent f9ecf47390
commit 096cc8c1e6
70 changed files with 3944 additions and 1942 deletions

3
.graphqlrc.yml Normal file
View File

@ -0,0 +1,3 @@
schema:
- ./src/core/graphql/schemas/crm.graphql
documents: ./src/**/*.(graphql|gql)

35
.vscode/launch.json vendored
View File

@ -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}"
}
]
}
// 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}"
}
]
}

10
apollo.config.js Normal file
View File

@ -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/**/*.*'],
},
};

View File

@ -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'],
],
},

View File

@ -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": [

View File

@ -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({

View File

@ -1 +0,0 @@
@import '~antd/dist/antd.less';

View File

@ -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 = () => (
<Grid>
<Sections width={['100vw', '100vw', '100%']} />
<Info width={['100vw', '100vw', '100%']} />
<Results minHeight="500px" width={['100vw', '100vw', '100%']} />
</Grid>
);
if (isLoading) {
return (
<CenterContent>
<Spinner />
</CenterContent>
);
}
if (error) {
const ServerError = Result[500];
return (
<ServerError
extra={[<Button text="Попробовать еще раз" action={fetch}></Button>]}
/>
);
}
return (
<Grid>
<Sections width={['100vw', '100vw', '100%']} />
<Info width={['100vw', '100vw', '100%']} />
<Results minHeight="500px" width={['100vw', '100vw', '100%']} />
</Grid>
);
};
export default Calculation;
export default withStores(Calculation, ['userStore', 'calculationStore']);

View File

@ -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;
};

View File

@ -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;
});
});

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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
}
}
`,
};

View File

@ -11,7 +11,7 @@ export const openNotification = ({
}: {
type: TNotification;
title: string;
description: string;
description?: string;
}) =>
debounce(
() =>

View File

@ -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`

View File

@ -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 () => (
<Suspense

View File

@ -0,0 +1,33 @@
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 { useStores } from 'client/hooks/useStores';
import { useAsync } from 'react-async-hook';
export default (Component, storesList) => () => {
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 (
<CenterContent>
<Spinner />
</CenterContent>
);
}
if (res.error) {
const ServerError = Result[500];
const RetryButton = (
<Button text="Попробовать еще раз" action={() => res.execute()}></Button>
);
return <ServerError extra={[RetryButton]} />;
}
return <Component />;
};

View File

@ -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 };
};

View File

@ -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 {

View File

@ -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);
}
}

View File

@ -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
`;

View File

@ -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,

View File

@ -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<any> = Object.assign(
{},
...(Object.values(elementsValues) as ValuesNames[]).map(
valueName => ({
@ -105,12 +108,11 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
),
);
const {
entities: mainOptions,
}: IGetCRMEntitiesResponse & {
entities: TElements<any>;
} = 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<any>;
} = 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({

View File

@ -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<keyof IQuote | string> = {
const mapKPtoValues: Partial<Record<ValuesNames, keyof IQuote | string>> = {
product: 'evo_baseproductid',
clientType: 'evo_client_typeid',
leaseObjectPrice: 'evo_supplier_currency_price',
@ -96,8 +96,8 @@ const mapKPtoValues: TValues<keyof IQuote | string> = {
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;

View File

@ -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
}
}
`;

View File

@ -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
}
}
`;

View File

@ -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);
}
});

View File

@ -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<IBaseOption[]> = {

View File

@ -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,
}),
);

View File

@ -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);
}

View File

@ -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<ElementsNames>({
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<TableValuesNames, IAccount>(
{
query: getInsuranceOptionsQuery,
variables: insuranceVariables,
},
);
return {
mainOptionsRequest,
staticDataRequest,
systemUserRequest,
insuranceRequest,
ownerOptionsRequest,
};
}

View File

@ -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<IAccount> = {
evo_account_type: [100000002],
statecode: 0,
};
export const staticDataVariables: GQLVariables<keyof TCRMEntity> = {
statecode: 0,
currentDate: currentISODate,
};

View File

@ -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}`;
},

View File

@ -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;
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}
}

View File

@ -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
}
}
}

View File

@ -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
}
}

View File

@ -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');

View File

@ -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
}

View File

@ -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
}

View File

@ -0,0 +1,7 @@
#import './fragments/quoteFields.graphql'
query GetQuote($quoteId: Uuid!) {
quote(quoteId: $quoteId) {
...quoteFields
}
}

View File

@ -0,0 +1,7 @@
#import './fragments/quoteFieldsLite.graphql'
query GetQuotesByLead($leadid: Uuid) {
quotes(evo_leadid: $leadid) {
...quoteFieldsLite
}
}

View File

@ -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',
);

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -0,0 +1,10 @@
query GetSingleOptionsForKP(
$dealer_broker_accountid: Uuid!
$hasDealerBroker: Boolean!
) {
selectDealerBroker: account(accountid: $dealer_broker_accountid)
@include(if: $hasDealerBroker) {
accountid
name
}
}

View File

@ -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
}
}

View File

@ -0,0 +1,9 @@
query GetSystemUser($domainname: String) {
systemuser(domainname: $domainname) {
evo_job_titleid
businessunitid
firstname
lastname
fullname
}
}

View File

@ -0,0 +1,4 @@
import { loader } from 'graphql.macro';
export const getStaticDataQuery = loader('./getStaticData.graphql');
export const getSystemUserQuery = loader('./getSystemUser.graphql');

File diff suppressed because it is too large Load Diff

View File

@ -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<CRMEntityNames, ExcludeFromPropsMap>,
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',
},

View File

@ -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<K extends string, R, V = TCRMEntity>(
options: QueryOptions<GQLVariables<V>, Record<K, R>>,
): Promise<Partial<Record<K, R>>> {
return new Promise(resolve => {
GQLClient.query<Record<K, R>, GQLVariables<V>>(options).then(res =>
resolve(res.data),
);
});
}
public static getCRMOptions<
K extends string = ElementsNames,
R = TCRMEntity,
>({
variables,
}: IQueryToCRMGQL): Promise<IGetCRMEntitiesResponse> =>
new Promise((resolve, reject) => {
client
.query({
query,
variables,
})
.then(res => {
if (!res.data || res.errors) {
reject(res.error || res.errors);
}
const resEntities: TEntities<TCRMEntity | TCRMEntity[]> = cloneDeep(
res.data,
);
...options
}: QueryOptions<GQLVariables<R>, Record<K, R>>): Promise<
Partial<Record<K, TOptionizedEntity<R>[]>>
> {
return new Promise(resolve =>
this.getCRMEntities<K, R | R[], keyof typeof variables>({
variables,
...options,
}).then(entities => resolve(optionizeEntities<K, R>(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<IGetCRMEntitiesResponse> =>
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<IQuote> =>
new Promise((resolve, reject) => {
console.log('createKp data: ', data);
axios
.post<IQuote>(
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<IQuote>(
String.prototype.concat(CRM_PROXY_URL, '/offer', '/leasingcalculator'),
data,
);
}
}

View File

@ -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<R extends any>(
targetName: string,
entity: TCRMEntity,
entityName?: CRMEntityNames,
): (TCRMEntity & IBaseOption) | undefined {
if (!entityName) {
throw new Error('entityName is missing');
entity: R,
): TOptionizedEntity<R> {
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<K extends string, R>(
entities: Partial<Record<K, R | R[]>>,
): Partial<Record<K, TOptionizedEntity<R>[]>> {
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<Record<K, TOptionizedEntity<R>[]>>);
}

View File

@ -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 = BaseEntity & IBaseOption> = T & IBaseOption;

View File

@ -0,0 +1,4 @@
import { OperationVariables } from '@apollo/client';
export type GQLVariables<R> = Partial<Record<keyof R, any>> &
OperationVariables;

1
src/core/tools/uuid.js Normal file
View File

@ -0,0 +1 @@
export const NIL = '00000000-0000-0000-0000-000000000000';

View File

@ -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<any>[];
preparedValues: PreparedValues;
preparedPayments: PreparedPayments;
postValues: PostValues;
calculationValues: TValues<any>;
columns: { [column in ColumnsNames]?: IColumn };
};
elt: {
[insType: string]: any;
};
}
export interface IGetTransTaxRequest {
calcDate: Date;
OKTMO: string;

View File

@ -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<TCRMEntity | TCRMEntity[]>;
}
export interface IGetCalculationResponse {
columns: { [column in ColumnsNames]?: IColumn };
postValues: PostValues;

View File

@ -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)[];

View File

@ -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<IBaseOption & TCRMEntity[]>;
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<TOptionizedEntity[]>) => void;
filters: TElements<TElementFilter>;
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<TOptionizedEntity[]> }) => void;
}
interface ICalculationStores {

View File

@ -1,8 +0,0 @@
export type IBaseOption = {
/**
* TODO: Remove optional mark when remove fakes
*/
name?: string;
value?: string | number | boolean;
[prop: string]: any | any[];
};

View File

@ -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<TCRMEntity[]>;

View File

@ -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 =

View File

@ -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 &