Merge branch 'development'

This commit is contained in:
Chika 2022-01-21 15:20:40 +03:00
commit a8addd87ad
88 changed files with 5031 additions and 2209 deletions

View File

@ -4,4 +4,6 @@ yarn.lock
yarn-error.log
*.log
.git
build
build
.yarn
.yarnrc.yml

13
.gitignore vendored
View File

@ -2,11 +2,6 @@
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
@ -20,4 +15,12 @@ yarn-error.log*
yarn.lock
*.log
package-lock.json
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.eslintcache

3
.graphqlrc.yml Normal file
View File

@ -0,0 +1,3 @@
schema:
- ./src/core/graphql/schemas/crm.graphql
documents: src/**/*.{graphql,js,ts,jsx,tsx}

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

768
.yarn/releases/yarn-3.1.1.cjs vendored Normal file

File diff suppressed because one or more lines are too long

3
.yarnrc.yml Normal file
View File

@ -0,0 +1,3 @@
nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-3.1.1.cjs

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"
"mini-css-extract-plugin": "2.4.5"
},
"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": [
@ -111,5 +114,6 @@
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
},
"packageManager": "yarn@3.1.1"
}

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

@ -468,6 +468,7 @@ const sections: ISection[] = [
// {
// elements: [
// // 'cbxInsDecentral',
// 'tbxMinPriceChange',
// 'tbxMaxPriceChange',
// 'tbxImporterRewardPerc',
// 'tbxImporterRewardRub',

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

@ -175,6 +175,7 @@ const elementsComponents: TElements<Component> = {
selectSubsidy: Select,
selectFuelCard: Select,
labelSubsidySum: Label,
tbxMinPriceChange: InputNumber,
};
const tablesComponents: StoreTables<Component> = {

View File

@ -457,6 +457,14 @@ const elementsProps: TElements<ElementProps> = {
radioInfuranceOPF: {
style: 'button',
},
selectHighSeasonStart: {
tooltip: {
Component: buildTooltip({
title: 'С какого платежа начинается полный высокий сезон',
placement: 'topLeft',
}),
},
},
};
export const numberElementsProps: TElements<ElementProps> = Object.keys(

View File

@ -40,7 +40,7 @@ export const elementsTitles: TElements<string> = {
radioGraphType: 'Вид графика',
tbxParmentsDecreasePercent: 'Процент убывания платежей',
selectSeasonType: 'Тип дегрессии/сезонности',
selectHighSeasonStart: 'С какого платежа начинается высокий сезон',
selectHighSeasonStart: 'Смещение сезонности',
tbxComissionPerc: 'Комиссия, %',
tbxComissionRub: 'Комиссия, руб.',
tbxSaleBonus: 'Размер бонуса МПЛ',
@ -140,6 +140,7 @@ export const elementsTitles: TElements<string> = {
selectSubsidy: 'Субсидия',
labelSubsidySum: 'Сумма субсидии с НДС',
selectFuelCard: 'Топливная карта',
tbxMinPriceChange: 'Мин. возможное изменение стоимости ПЛ',
};
const resultsTitles: TElements<string> = {

View File

@ -139,6 +139,7 @@ export const elementsValues: TElements<ValuesNames> = {
selectSubsidy: 'subsidy',
labelSubsidySum: 'subsidySum',
selectFuelCard: 'fuelCard',
tbxMinPriceChange: 'minPriceChange',
};
const resultElementsValues: TElements<ResultValuesNames> = {

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

@ -43,11 +43,7 @@ const TableStyles = styled(Box)`
th,
td {
// ${mq.laptop`
// width: 25% !important;
// `}
position: relative;
// overflow-wrap: break-word;
text-overflow: ellipsis;
overflow: hidden;
border-bottom: 1px solid ${colors.WHITE[50]};
@ -55,7 +51,7 @@ const TableStyles = styled(Box)`
td {
padding: 10px 16px;
& :first-child {
> * {
margin: 0;
}
}

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,6 +1,6 @@
import { getValueName } from 'client/Containers/Calculation/lib/elements/tools';
import initialFilters, {
noResetValueElements,
noResetValueElements
} from 'client/stores/CalculationStore/config/initialFilters';
import initialStatuses from 'client/stores/CalculationStore/config/initialStatuses';
import { isNil, mergeWith, pick } from 'lodash';
@ -66,11 +66,17 @@ const valuesActions = {
);
});
},
getOptions(elementName, fields) {
if (!this.options[elementName]) {
getOptions(elementName, fields, filtered = false) {
let options = this.options[elementName];
const filter = this.filters[elementName];
if (filtered && filter) {
options = filter(options);
}
if (!options) {
return;
}
if (!fields) return this.options[elementName];
if (!fields) return options;
return this.options[elementName].filter(option => {
return Object.keys(fields).every(
fieldName => option[fieldName] === fields[fieldName],

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,91 @@
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;
const { data: newKP } = await CrmService.createKP(payload);
message.success({
content: 'КП создано! ' + newKP?.evo_quotename,
});
if (newKP?.offerprintformapi)
this.stores.calculationUrls.setUrl({
name: 'kpUrl',
url: String.prototype.concat(CRM_PROXY_URL, newKP?.offerprintformapi),
});
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,139 +0,0 @@
import { openNotification } from 'client/Elements/Notification';
import { ICalculationStore } from 'core/types/Calculation/Store';
export default function (this: ICalculationStore) {
const {
contactClient,
contact,
newClient,
account,
commentLead,
phoneNumber,
} = this.values;
if (!contactClient && !contact) {
this.setValidation('selectContactClient', false);
this.setValidation('tbxContact', false);
openNotification({
type: 'error',
title: 'Ошибка во время создания интереса',
description: 'Не указан контакт клиента',
})();
}
if (!newClient && !account) {
this.setValidation('tbxNewClient', false);
this.setValidation('selectAccount', false);
openNotification({
type: 'error',
title: 'Ошибка во время создания интереса',
description: 'Не указан клиент',
})();
}
if (!commentLead) {
this.setValidation('tbxCommentLead', false);
openNotification({
type: 'error',
title: 'Ошибка во время создания интереса',
description: 'Не указан комментарий к интересу',
})();
}
if (contact && !phoneNumber) {
this.setValidation('tbxPhoneNumber', false);
openNotification({
type: 'error',
title: 'Ошибка во время создания интереса',
description: 'Не указан телефон контактного лица',
})();
}
const { channel } = this.values;
if (!channel) {
this.setValidation('selectChannel', false);
openNotification({
type: 'error',
title: 'Ошибка во время создания интереса',
description: 'Не указан канал привлечения',
})();
} else {
const { supplier, agent, finDepartment, broker } = this.values;
switch (channel) {
case 100000000: {
this.setValidation('selectFinDepartment', true);
this.setValidation('selectBroker', true);
if (!supplier) {
this.setValidation('selectSupplier', false);
openNotification({
type: 'error',
title: 'Ошибка во время создания интереса',
description: 'Не указан поставщик',
})();
}
if (!agent) {
this.setValidation('selectAgent', false);
openNotification({
type: 'error',
title: 'Ошибка во время создания интереса',
description: 'Не указан агент',
})();
}
break;
}
case 100000001: {
this.setValidation('selectAgent', true);
this.setValidation('selectBroker', true);
if (!supplier) {
this.setValidation('selectSupplier', false);
openNotification({
type: 'error',
title: 'Ошибка во время создания интереса',
description: 'Не указан поставщик',
})();
}
if (!finDepartment) {
this.setValidation('selectFinDepartment', false);
openNotification({
type: 'error',
title: 'Ошибка во время создания интереса',
description: 'Не указан финотдел',
})();
}
break;
}
case 100000002: {
this.setValidation('selectFinDepartment', true);
this.setValidation('selectSupplier', true);
this.setValidation('selectBroker', true);
if (!agent) {
this.setValidation('selectAgent', false);
openNotification({
type: 'error',
title: 'Ошибка во время создания интереса',
description: 'Не указан агент',
})();
}
break;
}
case 100000003: {
this.setValidation('selectFinDepartment', true);
this.setValidation('selectSupplier', true);
this.setValidation('selectAgent', true);
if (!broker) {
this.setValidation('selectBroker', false);
openNotification({
type: 'error',
title: 'Ошибка во время создания интереса',
description: 'Не указан брокер',
})();
}
break;
}
case 100000004:
default: {
this.setValidation('selectFinDepartment', true);
this.setValidation('selectSupplier', true);
this.setValidation('selectAgent', true);
this.setValidation('selectBroker', true);
break;
}
}
}
}

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';
@ -351,6 +352,7 @@ const gibddReactions: IReactionEffect[] = [
'regionRegistration',
'typePTS',
'leaseObjectCategory',
'leaseObjectType',
]),
};
},
@ -360,9 +362,18 @@ const gibddReactions: IReactionEffect[] = [
regionRegistration,
typePTS,
leaseObjectCategory,
leaseObjectType,
}) => {
calculationStore.setFilter('selectRegistration', options =>
options.filter(x => {
if (
!x.evo_leasingobject_types?.find(
x => x.evo_leasingobject_typeid === leaseObjectType,
)
) {
return false;
}
if (!objectRegionRegistration && !regionRegistration) {
return false;
}
@ -462,9 +473,9 @@ const gibddReactions: IReactionEffect[] = [
);
if (evo_city_fias_id) {
CrmService.crmgqlquery({
CrmService.getCRMEntities<'evo_town', IEvoTown>({
query: gql`
query($evo_fias_id: String) {
query legalClientTown($evo_fias_id: String) {
evo_town(evo_fias_id: $evo_fias_id) {
evo_fias_id
evo_townid
@ -474,12 +485,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,9 +576,9 @@ const gibddReactions: IReactionEffect[] = [
);
if (evo_city_fias_id && objectRegistration === 100000000) {
CrmService.crmgqlquery({
CrmService.getCRMEntities<'evo_town', IEvoTown>({
query: gql`
query($evo_fias_id: String) {
query townRegistration($evo_fias_id: String) {
evo_town(evo_fias_id: $evo_fias_id) {
evo_fias_id
evo_townid
@ -580,12 +588,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,
@ -610,9 +615,8 @@ const gibddReactions: IReactionEffect[] = [
]);
},
effect: () => {
const objectRegistration = calculationStore.getValue(
'objectRegistration',
);
const objectRegistration =
calculationStore.getValue('objectRegistration');
if (objectRegistration === 100000001) {
calculationStore.setFilter('selectTownRegistration', towns =>
towns.filter(x => x.evo_businessunit_evolution === true),

View File

@ -1,4 +1,3 @@
/* 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';
@ -9,23 +8,30 @@ import {
import { elementsValues } from 'client/Containers/Calculation/lib/elements/values';
import { openNotification } from 'client/Elements/Notification';
import initialValues from 'client/stores/CalculationStore/config/initialValues';
import CrmService from 'core/services/CrmService';
import { currentISODate } from 'core/tools/date';
import { IGetCRMEntitiesResponse } from 'core/types/Calculation/Responses';
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
import {
ElementsNames,
TElements
} from 'core/types/Calculation/Store/elements';
getMainOptionsForQuote,
getQuoteQuery,
getSecondaryOptionsForQuote,
getSingleOptionsForQuote
} from 'core/graphql/query/crm/quote';
import CrmService from 'core/services/CrmService';
import { TOptionizedEntity } from 'core/services/CrmService/types/common';
import { currentISODate } from 'core/tools/date';
import { NIL } from 'core/tools/uuid';
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
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,
@ -67,13 +73,10 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
opportunity,
recalcWithRevision,
calcType,
indAgent,
INNForCalc,
creditRate,
rate,
infuranceOPF,
calcBroker,
calcFinDepartment,
balanceHolder,
} = calculationStore.values;
@ -83,19 +86,17 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
const { calculationProcess } = calculationStore.stores;
CrmService.crmgqlquery({
query: quoteQuery,
CrmService.getCRMEntities<'quote', 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 +106,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 +119,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,
@ -128,29 +127,74 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
evo_gps_brandid: quote.evo_gps_brandid || NIL,
evo_regionid: quote.evo_regionid || NIL,
evo_legal_regionid: quote.evo_legal_regionid || NIL,
evo_agency_agreementid_param: { has: true },
},
toOptions: [
'selectModel',
'selectConfiguration',
'selectDealerPerson',
'selectDealerRewardCondition',
'selectDealerBroker',
'selectDealerBrokerRewardCondition',
'selectIndAgentRewardCondition',
'selectCalcDoubleAgentRewardCondition',
'selectCalcBrokerRewardCondition',
'selectFinDepartmentRewardCondtion',
'selectGPSModel',
'selectTownRegistration',
'selectLegalClientTown',
],
});
// selectDealerBroker query
let selectDealerBroker: TOptionizedEntity<IAccount>[] = [];
const dealer_broker_accountid =
mainOptions?.selectDealerPerson &&
mainOptions?.selectDealerPerson?.length > 0 &&
mainOptions.selectDealerPerson[0].evo_broker_accountid;
if (dealer_broker_accountid) {
const selectDealerBrokerRes = await CrmService.getCRMOptions<
'selectDealerBroker',
IAccount
>({
query: getSingleOptionsForQuote,
variables: {
dealer_broker_accountid,
},
});
if (selectDealerBrokerRes?.selectDealerBroker)
selectDealerBroker = selectDealerBrokerRes.selectDealerBroker;
}
// selectDealerBroker query
calculationStore.applyOptions({
...mainOptions,
selectDealerBroker: [mainOptions.selectDealerBroker],
selectDealerBroker: selectDealerBroker,
});
// agents
//TODO: refactor
const { indAgent, calcBroker, calcFinDepartment } =
calculationStore.values;
let {
indAgentRewardCondition,
indAgentRewardSumm,
calcBrokerRewardCondition,
calcBrokerRewardSum,
finDepartmentRewardCondtion,
finDepartmentRewardSumm,
} = calculationStore.values;
if (indAgent === quote.evo_agent_accountid) {
indAgentRewardCondition = quote.evo_agent_reward_conditionid;
indAgentRewardSumm = quote.evo_agent_reward_total;
}
if (calcBroker === quote.evo_broker_accountid) {
calcBrokerRewardCondition = quote.evo_broker_reward_conditionid;
calcBrokerRewardSum = quote.evo_broker_reward_total;
}
if (calcFinDepartment === quote.evo_fin_department_accountid) {
finDepartmentRewardCondtion =
quote.evo_fin_department_reward_conditionid;
finDepartmentRewardSumm = quote.evo_fin_department_reward_total;
}
const agentsValues = {
indAgentRewardCondition,
indAgentRewardSumm,
calcBrokerRewardCondition,
calcBrokerRewardSum,
finDepartmentRewardCondtion,
finDepartmentRewardSumm,
};
// agents
// fill insurance table
calculationStore.setTableRows(
'tableInsurance',
@ -394,18 +438,16 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
}
// regionRegistration
const {
entities: secondaryOptions,
}: IGetCRMEntitiesResponse & {
entities: TElements<any>;
} = await CrmService.crmgqlquery({
query: secondaryOptionsQuery,
const secondaryOptions = await CrmService.getCRMOptions<
ElementsNames,
IEvoTown
>({
query: getSecondaryOptionsForQuote,
variables: {
statecode: 0,
evo_regionid: regionRegistration || NIL,
evo_legal_regionid: legalClientRegion || NIL,
},
toOptions: ['selectTownRegistration', 'selectLegalClientTown'],
});
calculationStore.applyOptions(secondaryOptions);
@ -428,9 +470,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 +487,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 +517,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;
}
@ -523,6 +566,7 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
requirementTelematic,
balanceHolder,
redemptionPaymentSum,
...agentsValues,
};
// check min max number values
@ -558,7 +602,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',
@ -48,17 +48,17 @@ const mapKPtoValues: TValues<keyof IQuote | string> = {
dealerBrokerRewardCondition: 'evo_dealer_broker_reward_conditionid',
dealerBrokerRewardSumm: 'evo_dealer_broker_reward_total',
// indAgent: 'evo_agent_accountid',
indAgentRewardCondition: 'evo_agent_reward_conditionid',
indAgentRewardSumm: 'evo_agent_reward_total',
// indAgentRewardCondition: 'evo_agent_reward_conditionid',
// indAgentRewardSumm: 'evo_agent_reward_total',
calcDoubleAgent: 'evo_double_agent_accountid',
calcDoubleAgentRewardCondition: 'evo_double_agent_reward_conditionid',
calcDoubleAgentRewardSumm: 'evo_double_agent_reward_total',
// calcBroker: 'evo_broker_accountid',
calcBrokerRewardCondition: 'evo_broker_reward_conditionid',
calcBrokerRewardSum: 'evo_broker_reward_total',
// calcBrokerRewardCondition: 'evo_broker_reward_conditionid',
// calcBrokerRewardSum: 'evo_broker_reward_total',
// calcFinDepartment: 'evo_fin_department_accountid',
finDepartmentRewardCondtion: 'evo_fin_department_reward_conditionid',
finDepartmentRewardSumm: 'evo_fin_department_reward_total',
// finDepartmentRewardCondtion: 'evo_fin_department_reward_conditionid',
// finDepartmentRewardSumm: 'evo_fin_department_reward_total',
GPSBrand: 'evo_gps_brandid',
GPSModel: 'evo_gps_modelid',
infuranceOPF: 'evo_ins_legal_form',
@ -80,6 +80,7 @@ const mapKPtoValues: TValues<keyof IQuote | string> = {
quoteName: 'evo_contact_name',
quoteContactGender: 'evo_gender',
quoteRedemptionGraph: 'evo_redemption_graph',
minPriceChange: 'evo_min_change_price',
maxPriceChange: 'evo_max_price_change',
importerRewardPerc: 'evo_importer_reward_perc',
importerRewardRub: 'evo_importer_reward_rub',
@ -96,8 +97,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

@ -169,7 +169,7 @@ const reactionEffects: IReactionEffect[] = [
},
effect: indAgentRewardConditionId => {
if (!indAgentRewardConditionId) {
calculationStore.setValue('indAgentRewardSumm', null);
calculationStore.setValue('indAgentRewardSumm', 0);
calculationStore.setStatus(
'tbxIndAgentRewardSumm',
ElementStatus.Disabled,
@ -657,11 +657,8 @@ const reactionEffects: IReactionEffect[] = [
calculationStore => ({
expression: () => {
const {
lastPaymentRub,
lastPaymentPerc,
insNSIB,
} = calculationStore.values;
const { lastPaymentRub, lastPaymentPerc, insNSIB } =
calculationStore.values;
return { lastPaymentRub, lastPaymentPerc, insNSIB };
},
effect: ({ lastPaymentRub, insNSIB }) => {
@ -794,26 +791,14 @@ const reactionEffects: IReactionEffect[] = [
}),
calculationStore => ({
expression: () => {
const { seasonType } = calculationStore.values;
return seasonType;
},
effect: seasonType => {
if (seasonType) {
switch (seasonType) {
case 100000001:
case 100000002: {
calculationStore.setFilter('selectHighSeasonStart', seasons => {
return seasons.filter(
season => season.value && season.value <= 100000004,
);
});
break;
}
default:
calculationStore.setFilter('selectHighSeasonStart', undefined);
break;
}
expression: () => calculationStore.getOption('selectSeasonType'),
effect: ({ forbiddenHighSeasonStart }) => {
if (forbiddenHighSeasonStart) {
calculationStore.setFilter('selectHighSeasonStart', seasonStart =>
seasonStart.filter(s => !forbiddenHighSeasonStart.includes(s.name)),
);
} else {
calculationStore.setFilter('selectHighSeasonStart', undefined);
}
},
options: {
@ -1495,12 +1480,10 @@ const reactionEffects: IReactionEffect[] = [
const fuelCard = calculationStore.getOption('selectFuelCard');
if (fuelCard) {
const selectFuelCard_filter = calculationStore.getFilter(
'selectFuelCard',
);
const selectFueldCard_options = calculationStore.getOptions(
'selectFuelCard',
);
const selectFuelCard_filter =
calculationStore.getFilter('selectFuelCard');
const selectFueldCard_options =
calculationStore.getOptions('selectFuelCard');
if (selectFuelCard_filter && selectFueldCard_options) {
const filtered_technicalCards = selectFuelCard_filter(

View File

@ -1,9 +1,12 @@
import { getFieldName } from 'client/Containers/Calculation/lib/elements/tools';
import { openNotification } from 'client/Elements/Notification';
import valuesConstants from 'core/constants/values';
import { pipe } from 'core/tools/func';
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
import { ElementsNames } from 'core/types/Calculation/Store/elements';
import { Process } from 'core/types/Calculation/Store/process';
import { TableNames } from 'core/types/Calculation/Store/tables';
import { ValuesNames } from 'core/types/Calculation/Store/values';
import { ElementStatus } from 'core/types/statuses';
import { convertPrice } from '../lib/tools';
import { getPrice } from './priceReactions/calculate';
@ -42,12 +45,17 @@ const reactionEffects: IReactionEffect[] = [
calculationStore,
);
const maxPriceChange =
const maxPriceChangeValue =
price - supplierDiscountRub < 800000
? price - supplierDiscountRub + 50000
: (price - supplierDiscountRub) * 1.05;
calculationStore.setValue('maxPriceChange', maxPriceChangeValue);
calculationStore.setValue('maxPriceChange', maxPriceChange);
const minPriceChangeValue =
price - supplierDiscountRub < 800000
? price - supplierDiscountRub - 50000
: (price - supplierDiscountRub) * 0.95;
calculationStore.setValue('minPriceChange', minPriceChangeValue);
},
options: {
fireImmediately: true,
@ -119,7 +127,7 @@ const reactionEffects: IReactionEffect[] = [
);
const quote = calculationStore.getOption('selectQuote');
if (quote && quote.evo_max_price_change) {
if (quote?.evo_max_price_change) {
if (price - supplierDiscountRub > quote.evo_max_price_change) {
calculationStore.setValidation('tbxLeaseObjectPrice', false);
openNotification({
@ -133,6 +141,21 @@ const reactionEffects: IReactionEffect[] = [
calculationStore.setValidation('tbxLeaseObjectPrice', undefined);
}
}
if (quote?.evo_min_change_price) {
if (price - supplierDiscountRub < quote.evo_min_change_price) {
calculationStore.setValidation('tbxLeaseObjectPrice', false);
openNotification({
type: 'error',
title: 'Ошибка',
description:
'Указанная стоимость предмета лизинга меньше возмножного изменения стоимости предмета лизинга при пересчете без пересмотра. ' +
'Увеличьте стоимость предмета лизинга',
})();
} else {
calculationStore.setValidation('tbxLeaseObjectPrice', undefined);
}
}
},
}),
@ -345,7 +368,9 @@ const reactionEffects: IReactionEffect[] = [
return;
}
if (!recalcWithRevision) {
const allowedReqTelematicValues = [100000000, 100000001];
const allowedReqTelematicValues = [
100000000, 100000001, 100000002, 100000003,
];
calculationStore.setFilter('radioRequirementTelematic', options =>
options.filter(
x =>
@ -429,32 +454,41 @@ const reactionEffects: IReactionEffect[] = [
(calculationStore, calculationProcess) => ({
expression: () => {
return calculationStore.getValue('requirementTelematic');
},
effect: requirementTelematic => {
if (calculationProcess.hasProcess(Process.LoadKp)) {
return;
}
const recalcWithRevision = calculationStore.getValue(
return calculationStore.getValues([
'requirementTelematic',
'recalcWithRevision',
);
if (!recalcWithRevision) {
calculationStore.setValue('telematic', null);
]);
},
effect: ({ requirementTelematic, recalcWithRevision }) => {
(['tracker', 'telematic'] as ValuesNames[]).forEach(valueName => {
const elementName = getFieldName(valueName);
const addProducts = calculationStore.getStaticData(
'evo_addproduct_type',
);
let tracker = addProducts.find(x =>
x.evo_controls_program?.includes(requirementTelematic),
calculationStore.setFilter(elementName, options =>
options.filter(
pipe(
x => {
if (x.evo_controls_program?.includes(requirementTelematic))
return x;
},
x => {
if (recalcWithRevision) return x;
if (x?.evo_visible_calc === true) return x;
},
),
),
);
calculationStore.setValue('tracker', tracker?.evo_addproduct_typeid);
} else {
calculationStore.setStatus(
'radioRequirementTelematic',
ElementStatus.Disabled,
);
}
if (!calculationProcess.hasProcess(Process.LoadKp)) {
const elementOptions = calculationStore.getOptions(
elementName,
undefined,
true,
);
//TODO: удалить после рефактора CalculationStore
if (elementOptions?.length === 1)
calculationStore.setValue(valueName, elementOptions[0].value);
}
});
},
options: {
fireImmediately: true,

View File

@ -1,6 +1,7 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { openNotification } from 'client/Elements/Notification';
import {
insuranceKaskoDefaultFilter,
insuranceOsagoDefaultFilter,
singleValueFilter,
} from 'core/constants/stores/Calculation/filters';
@ -808,4 +809,44 @@ export default [
}
},
}),
(calculationStore, calculationProcess) => ({
expression: () => calculationStore.getOption('selectBrand'),
effect: brand => {
if (calculationProcess.hasProcess(Process.LoadKp)) {
return;
}
if (brand?.evo_id === 'BRAND49') {
const { tableInsurance } = calculationStore.tables;
// ПАО "ГРУППА РЕНЕССАНС СТРАХОВАНИЕ"
const targetInsuranceCompany =
tableInsurance.options?.insuranceCompany?.find(
x => x.evo_inn === '7725497022',
);
if (targetInsuranceCompany) {
const targetInsuranceFilter = singleValueFilter(
targetInsuranceCompany.value,
);
calculationStore.setTableRow('tableInsurance', rows =>
rows.findIndex(x => x.policyType?.value === 'КАСКО'),
)({
insuranceCompany: {
filter: targetInsuranceFilter,
value: targetInsuranceCompany.value,
status: ElementStatus.Disabled,
},
});
}
} else {
calculationStore.setTableRow('tableInsurance', rows =>
rows.findIndex(x => x.policyType?.value === 'КАСКО'),
)({
insuranceCompany: {
filter: insuranceKaskoDefaultFilter,
status: ElementStatus.Default,
value: null,
},
});
}
},
}),
] as IReactionEffect[];

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[]> = {
@ -89,6 +89,7 @@ const initialOptions: TElements<IBaseOption[]> = {
startPositions: [0, 6],
paymentsInStep: [6, 6],
stepsValues: [100, 50],
forbiddenHighSeasonStart: ['9', '10'],
},
{
name: '8/4',
@ -96,6 +97,7 @@ const initialOptions: TElements<IBaseOption[]> = {
startPositions: [0, 8],
paymentsInStep: [8, 4],
stepsValues: [100, 50],
forbiddenHighSeasonStart: ['7', '8', '9'],
},
{
name: '4/4/4',
@ -103,6 +105,7 @@ const initialOptions: TElements<IBaseOption[]> = {
startPositions: [0, 4, 8],
paymentsInStep: [4, 4, 4],
stepsValues: [100, 75, 50],
forbiddenHighSeasonStart: ['11'],
},
{
name: '100.50.25',
@ -126,36 +129,10 @@ const initialOptions: TElements<IBaseOption[]> = {
},
],
selectHighSeasonStart: [
{
name: '2',
value: 100000000,
},
{
name: '3',
value: 100000001,
},
{
name: '4',
value: 100000002,
},
{
name: '5',
value: 100000003,
},
{
name: '6',
value: 100000004,
},
{
name: '7',
value: 100000005,
},
{
name: '8',
value: 100000006,
},
],
selectHighSeasonStart: Array.from({ length: 12 }, (_, i) => ({
name: `${i + 2}`,
value: 100000000 + i,
})),
radioDeliveryTime: [
{
@ -269,8 +246,7 @@ const initialOptions: TElements<IBaseOption[]> = {
value: 100000012,
},
{
name:
'Для экскурсионных перевозок в т.ч. на торжества; трансфер в аэропорт и пр.',
name: 'Для экскурсионных перевозок в т.ч. на торжества; трансфер в аэропорт и пр.',
value: 100000013,
},
{

View File

@ -9,7 +9,7 @@ const initialStatuses: TElements<ElementStatus> = {
selectCalcDoubleAgent: ElementStatus.Disabled,
tbxInsKaskoPriceLeasePeriod: ElementStatus.Disabled,
selectClientType: ElementStatus.Disabled,
selectTelematic: ElementStatus.Disabled,
// selectTelematic: ElementStatus.Disabled,
tbxImporterRewardRub: ElementStatus.Disabled,
tbxImporterRewardPerc: ElementStatus.Disabled,
tbxMaxPriceChange: ElementStatus.Disabled,
@ -34,7 +34,7 @@ const initialStatuses: TElements<ElementStatus> = {
tbxCommentLead: ElementStatus.Disabled,
btnCreateLead: ElementStatus.Disabled,
selectTracker: ElementStatus.Disabled,
// selectTracker: ElementStatus.Disabled,
tbxVehicleTaxInLeasingPeriod: ElementStatus.Disabled,
selectObjectTypeTax: ElementStatus.Disabled,

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,66 @@
import { ICalculationStore } from 'core/types/Calculation/Store';
import { Process } from 'core/types/Calculation/Store/process';
import { isEmpty } from 'lodash';
import initialOptions from '../config/initialOptions';
import initialValues from '../config/initialValues';
import { composeRequests } from './requests';
export default async function (this: ICalculationStore) {
const { calculationProcess } = this.stores;
calculationProcess.addProcess(Process.Init);
const {
ownerOptionsRequest,
mainOptionsRequest,
staticDataRequest,
systemUserRequest,
insuranceRequest,
} = composeRequests();
const { systemuser } = await systemUserRequest;
const staticEntities = await staticDataRequest;
this.applyStaticData(
Object.assign({ systemuser: [systemuser] }, staticEntities),
);
const ownerOptions = await ownerOptionsRequest;
const mainOptions = await mainOptionsRequest;
let selectProduct = mainOptions?.selectProduct?.filter(
x =>
isEmpty(x.systemusers) ||
x?.systemusers?.some(u => u?.systemuserid === systemuser?.systemuserid),
);
this.applyOptions(
Object.assign(initialOptions, ownerOptions, mainOptions, { selectProduct }),
);
const insuranceData = await insuranceRequest;
this.setTableColumns('tableInsurance')({
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?.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,80 @@
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,
TCRMEntity
>({
query: getMainOptionsQuery,
variables: mainOptionsVariables,
});
const staticDataRequest = CrmService.getCRMEntities<
CRMEntityNames,
TCRMEntity[]
>({
query: getStaticDataQuery,
variables: staticDataVariables,
});
const domainname = UserStore.getDomainName();
const systemUserRequest = CrmService.getCRMEntities<
'systemuser',
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 { currentISODate } from 'core/tools/date';
import { IAccount, TCRMEntity } from 'core/types/Entities/crmEntities';
export const mainOptionsVariables:
| Partial<Record<keyof TCRMEntity, any>>
| Record<string, any> = {
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: Partial<Record<keyof IAccount, any>> = {
evo_account_type: [100000002],
statecode: 0,
};
export const staticDataVariables: Record<string, any> = {
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,15 @@
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
evo_inn
}
}

View File

@ -0,0 +1,273 @@
#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
}
systemusers {
systemuserid
}
}
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
evo_leasingobject_types {
evo_leasingobject_typeid
}
}
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_visible_calc
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_visible_calc
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,128 @@
#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_category
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,26 @@
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_min_change_price
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,131 @@
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!
$evo_agency_agreementid_param: GuidParamInput
) {
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_agency_agreementid_param: $evo_agency_agreementid_param
) {
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_agency_agreementid_param: $evo_agency_agreementid_param
) {
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_agency_agreementid_param: $evo_agency_agreementid_param
# ) {
# 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_agency_agreementid_param: $evo_agency_agreementid_param
) {
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_agency_agreementid_param: $evo_agency_agreementid_param
# ) {
# 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_agency_agreementid_param: $evo_agency_agreementid_param
# ) {
# 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,6 @@
query GetSingleOptionsForKP($dealer_broker_accountid: Uuid!) {
selectDealerBroker: account(accountid: $dealer_broker_accountid) {
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,10 @@
query GetSystemUser($domainname: String) {
systemuser(domainname: $domainname) {
evo_job_titleid
businessunitid
firstname
lastname
fullname
systemuserid
}
}

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,38 @@
/* 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 { 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 GQLClient from 'core/graphql/client';
import { IQuote } from 'core/types/Entities/crmEntities';
import { optionizeEntities } from './tools/entity';
export default class {
static crmgqlquery = ({
query,
toOptions,
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,
);
public static getCRMEntities<K extends string, R>(
queryOptions: QueryOptions<
Partial<Record<keyof R, any>> | Record<string, any>,
Record<K, R>
>,
) {
return GQLClient.query<
Record<K, R>,
Partial<Record<keyof R, any> | Record<string, any>>
>(queryOptions).then(res => res.data);
}
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);
}
}
public static getCRMOptions<K extends string, R>(
queryOptions: QueryOptions<
Partial<Record<keyof R, any>> | Record<string, any>,
Record<K, R>
>,
) {
return this.getCRMEntities<K, R | R[]>(queryOptions).then(entities =>
optionizeEntities<K, R>(entities),
);
}
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;

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

@ -149,7 +149,8 @@ export type ElementsNames =
| 'selectLegalClientTown'
| 'selectSubsidy'
| 'labelSubsidySum'
| 'selectFuelCard';
| 'selectFuelCard'
| 'tbxMinPriceChange';
export type LinkElementsNames = 'linkDownloadKp';

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,21 @@ 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 },
filtered?: boolean,
) => (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 +120,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,5 @@
export enum Process {
Init,
LoadKp,
RecalcWithoutRevision,
ELT,
}

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

@ -135,7 +135,8 @@ export type ValuesNames =
| 'legalClientTown'
| 'subsidy'
| 'subsidySum'
| 'fuelCard';
| 'fuelCard'
| 'minPriceChange';
export type ComputedValuesNames =
| 'leaseObjectRiskName'

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;
@ -84,6 +106,7 @@ export interface IQuote {
evo_period?: number;
evo_first_payment_perc?: number;
evo_last_payment_perc?: number;
evo_min_change_price?: number;
evo_max_price_change?: number;
evo_max_mass?: number;
evo_seats?: number;
@ -103,47 +126,47 @@ export interface IQuote {
evo_req_telematic_accept?: number;
evo_one_year_insurance?: boolean;
evo_payment_redemption_sum?: number;
evo_agent_accountid?: string;
evo_agent_reward_conditionid?: string;
evo_agent_reward_total?: number;
evo_broker_accountid?: string;
evo_fin_department_reward_total?: number;
evo_fin_department_reward_conditionid?: string;
evo_fin_department_accountid?: string;
evo_broker_reward_total?: number;
evo_broker_reward_conditionid?: string;
}
export interface IEvoGraph {
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;
evo_dateto_param?: Date;
evo_leasingobject_types?: IEvoLeasingObjectType[];
evo_brands?: IEvoBrand[];
systemusers?: ISystemUser[];
}
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 +179,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 +203,93 @@ 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;
evo_agency_agreementid?: string;
}
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 +307,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;
@ -337,6 +330,7 @@ export interface IEvoAddproductType {
evo_cost_price_telematics?: number;
evo_cost_equipment?: number;
evo_controls_program?: number[];
evo_visible_calc?: boolean;
evo_helpcard_type?: number;
evo_towtruck?: boolean;
evo_pts_type?: number[];
@ -345,9 +339,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 +359,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 +368,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 +378,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 +392,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 +421,7 @@ export interface IEvoSubsidy {
accounts?: IAccount[];
}
type BaseEntity = {
__typename?: CRMEntityNames;
};
export type TCRMEntity = BaseEntity &
IAccount &
export type TCRMEntity = IAccount &
ILead &
IOpportunity &
IQuote &