merge feature/elt-release
This commit is contained in:
parent
b7b0681734
commit
6b52faa502
@ -0,0 +1,33 @@
|
||||
import { message } from 'antd';
|
||||
import Button from 'client/Elements/Button';
|
||||
import { useStores } from 'client/hooks/useStores';
|
||||
import { Process } from 'core/types/Calculation/Store/process';
|
||||
import { ElementStatus } from 'core/types/statuses';
|
||||
|
||||
const BottomControls = ({ insType, onSelectRow, selectedKey }) => {
|
||||
const { calculationStore } = useStores();
|
||||
const { ELTStore } = calculationStore.stores;
|
||||
const handleSelectRow = () => {
|
||||
const { calculationProcess } = calculationStore.stores;
|
||||
calculationProcess.addProcess(Process.ELT);
|
||||
ELTStore[insType].setKey(selectedKey);
|
||||
onSelectRow.call(calculationStore, insType, selectedKey);
|
||||
calculationProcess.deleteProcess(Process.ELT);
|
||||
|
||||
message.success({ content: 'Выбранный расчет ЭЛТ применен' });
|
||||
};
|
||||
|
||||
return (
|
||||
<Button
|
||||
text="Применить"
|
||||
action={handleSelectRow}
|
||||
status={
|
||||
selectedKey === undefined
|
||||
? ElementStatus.Disabled
|
||||
: ElementStatus.Default
|
||||
}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default BottomControls;
|
||||
@ -0,0 +1,62 @@
|
||||
import ReloadOutlined from '@ant-design/icons/lib/icons/ReloadOutlined';
|
||||
import { getTitle } from 'client/Containers/Calculation/lib/elements/tools';
|
||||
import Button from 'client/Elements/Button';
|
||||
import { openNotification } from 'client/Elements/Notification';
|
||||
import { PrimaryText } from 'client/Elements/Text';
|
||||
import { useStores } from 'client/hooks/useStores';
|
||||
import { Flex } from 'client/UIKit/grid';
|
||||
import { ElementStatus } from 'core/types/statuses';
|
||||
import { useState } from 'react';
|
||||
import { resetIns } from '../../lib/resetIns';
|
||||
import { validate } from '../../lib/validation';
|
||||
|
||||
const TopControls = ({ title, insType, fetchData, requiredFields }) => {
|
||||
const [isPending, setIsPending] = useState(false);
|
||||
const { calculationStore } = useStores();
|
||||
|
||||
function getMissingFields() {
|
||||
const missingFields = validate.call(calculationStore, requiredFields);
|
||||
if (missingFields && missingFields.length > 0) {
|
||||
const elementsNames = missingFields.map(fieldName => getTitle(fieldName));
|
||||
return elementsNames;
|
||||
}
|
||||
}
|
||||
|
||||
const handleGetData = () => {
|
||||
const missingFieldsTitles = getMissingFields();
|
||||
if (missingFieldsTitles && missingFieldsTitles.length > 0) {
|
||||
const message = String.prototype.concat(
|
||||
'Не заполнены поля: ',
|
||||
missingFieldsTitles.join(', '),
|
||||
);
|
||||
openNotification({
|
||||
type: 'error',
|
||||
title: 'Ошибка во время расчета ЭЛТ',
|
||||
description: message,
|
||||
})();
|
||||
return;
|
||||
}
|
||||
|
||||
resetIns.call(calculationStore, insType);
|
||||
setIsPending(true);
|
||||
fetchData.call(calculationStore).finally(
|
||||
setTimeout(() => {
|
||||
setIsPending(false);
|
||||
}, 1500),
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<Flex alignItems="center" justifyContent="space-between" mb="5px">
|
||||
<PrimaryText>{title}</PrimaryText>
|
||||
<Button
|
||||
shape="circle"
|
||||
status={isPending ? ElementStatus.Loading : ElementStatus.Default}
|
||||
action={handleGetData}
|
||||
icon={<ReloadOutlined />}
|
||||
/>
|
||||
</Flex>
|
||||
);
|
||||
};
|
||||
|
||||
export default TopControls;
|
||||
@ -0,0 +1,4 @@
|
||||
import BottomControls from './BottomControls';
|
||||
import TopControls from './TopControls';
|
||||
|
||||
export { BottomControls, TopControls };
|
||||
@ -1,74 +0,0 @@
|
||||
import Alert from 'client/Elements/Alert';
|
||||
import { useStores } from 'client/hooks/useStores';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { getFieldsNames, validate } from '../lib/validation';
|
||||
import InsTable from './InsTable';
|
||||
import Controls from './TableControls';
|
||||
|
||||
export default ({
|
||||
title,
|
||||
insType,
|
||||
getData,
|
||||
onSelectRow,
|
||||
requiredFields,
|
||||
...tableProps
|
||||
}) => props => {
|
||||
const { calculationStore } = useStores();
|
||||
const { ELTStore } = calculationStore.stores;
|
||||
const [selectedKey, selectKey] = useState('');
|
||||
const [alert, setAlert] = useState({
|
||||
message: undefined,
|
||||
type: undefined,
|
||||
});
|
||||
const [isPending, setIsPending] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
selectKey(ELTStore[insType].selectedKey);
|
||||
}, []);
|
||||
|
||||
const handleGetData = () => {
|
||||
const missingFields = validate.call(calculationStore, requiredFields);
|
||||
if (missingFields && missingFields.length > 0) {
|
||||
const fieldsNames = getFieldsNames(missingFields);
|
||||
const msgText = String.prototype.concat(
|
||||
'Не заполнены поля: ',
|
||||
fieldsNames.join(', '),
|
||||
);
|
||||
setAlert({ message: msgText, type: 'error' });
|
||||
return;
|
||||
} else {
|
||||
setAlert({ message: undefined, type: undefined });
|
||||
}
|
||||
|
||||
setIsPending(true);
|
||||
const resetPending = () => setIsPending(false);
|
||||
getData.call(calculationStore, resetPending);
|
||||
};
|
||||
|
||||
const handleSelectRow = () => {
|
||||
ELTStore[insType].setKey(selectedKey);
|
||||
onSelectRow.call(calculationStore, insType, selectedKey);
|
||||
setAlert({ message: 'Выбранные параметры сохранены', type: 'success' });
|
||||
setTimeout(() => {
|
||||
setAlert({ message: undefined, type: undefined });
|
||||
}, 2500);
|
||||
};
|
||||
|
||||
return (
|
||||
<Controls
|
||||
title={title}
|
||||
getData={handleGetData}
|
||||
selectRow={handleSelectRow}
|
||||
isLoading={isPending}
|
||||
>
|
||||
{alert.message && <Alert {...alert} />}
|
||||
<InsTable
|
||||
insType={insType}
|
||||
selectKey={selectKey}
|
||||
selectedKey={selectedKey}
|
||||
{...tableProps}
|
||||
dataSource={ELTStore[insType].list}
|
||||
/>
|
||||
</Controls>
|
||||
);
|
||||
};
|
||||
@ -1,39 +1,51 @@
|
||||
//@ts-nocheck
|
||||
import { Table as AntTable, TableProps } from 'antd';
|
||||
import { useStores } from 'client/hooks/useStores';
|
||||
import { Box } from 'client/UIKit/grid';
|
||||
import mq from 'client/UIKit/mq';
|
||||
import { toJS } from 'mobx';
|
||||
import { observer } from 'mobx-react-lite';
|
||||
import React from 'react';
|
||||
import React, { useEffect } from 'react';
|
||||
import styled from 'styled-components';
|
||||
|
||||
const TableWrapper = styled(Box)`
|
||||
.ant-table-row-level-1 .ant-table-selection-column {
|
||||
visibility: hidden;
|
||||
}
|
||||
height: 100%;
|
||||
overflow-x: scroll;
|
||||
${mq.laptop`
|
||||
overflow-x: hidden;
|
||||
`}
|
||||
margin-bottom: 5px;
|
||||
`;
|
||||
|
||||
interface ITableProps {
|
||||
insType: string;
|
||||
selectKey: (key: string) => void;
|
||||
selectedKey: string;
|
||||
tableConfig: TableProps<any>;
|
||||
dataSource: any[];
|
||||
}
|
||||
|
||||
export default observer(
|
||||
({ selectKey, selectedKey, tableConfig, dataSource, ...props }) => {
|
||||
return (
|
||||
<TableWrapper my="5px">
|
||||
<AntTable
|
||||
{...tableConfig}
|
||||
rowSelection={Object.assign(tableConfig.rowSelection, {
|
||||
selectedRowKeys: selectedKey ? [selectedKey] : [],
|
||||
onSelect: record => {
|
||||
selectKey(record.key);
|
||||
},
|
||||
})}
|
||||
dataSource={toJS(dataSource)}
|
||||
{...props}
|
||||
></AntTable>
|
||||
</TableWrapper>
|
||||
);
|
||||
},
|
||||
) as React.FC<ITableProps>;
|
||||
export default observer(({ insType, selectKey, selectedKey, tableConfig }) => {
|
||||
const { calculationStore } = useStores();
|
||||
const { ELTStore } = calculationStore.stores;
|
||||
|
||||
// update parent selectedKey from store (when reset)
|
||||
const storeSelectedKey = ELTStore[insType].selectedKey;
|
||||
useEffect(() => {
|
||||
selectKey(storeSelectedKey);
|
||||
}, [storeSelectedKey]);
|
||||
|
||||
return (
|
||||
<TableWrapper my="5px">
|
||||
<AntTable
|
||||
{...tableConfig}
|
||||
rowSelection={Object.assign(tableConfig.rowSelection, {
|
||||
selectedRowKeys: selectedKey ? [selectedKey] : [],
|
||||
onSelect: record => {
|
||||
selectKey(record.key);
|
||||
},
|
||||
})}
|
||||
dataSource={toJS(ELTStore[insType].list)}
|
||||
></AntTable>
|
||||
</TableWrapper>
|
||||
);
|
||||
}) as React.FC<ITableProps>;
|
||||
|
||||
@ -1,34 +0,0 @@
|
||||
import ReloadOutlined from '@ant-design/icons/lib/icons/ReloadOutlined';
|
||||
import Button from 'client/Elements/Button';
|
||||
import { PrimaryText } from 'client/Elements/Text';
|
||||
import { Flex } from 'client/UIKit/grid';
|
||||
import { ElementStatus } from 'core/types/statuses';
|
||||
import styled from 'styled-components';
|
||||
|
||||
const TopControls = ({ title, getData, isLoading }) => (
|
||||
<Flex alignItems="center" justifyContent="space-between" mb="5px">
|
||||
<PrimaryText>{title}</PrimaryText>
|
||||
<Button
|
||||
shape="circle"
|
||||
status={isLoading ? ElementStatus.Loading : ElementStatus.Default}
|
||||
action={getData}
|
||||
icon={<ReloadOutlined />}
|
||||
/>
|
||||
</Flex>
|
||||
);
|
||||
|
||||
const BottomControls = ({ selectRow }) => (
|
||||
<Button text="Применить" action={selectRow}></Button>
|
||||
);
|
||||
|
||||
const ContentWrapper = styled(Flex)`
|
||||
width: 550px !important;
|
||||
`;
|
||||
|
||||
export default ({ children, ...props }) => (
|
||||
<ContentWrapper flexDirection="column">
|
||||
<TopControls {...props} />
|
||||
{children}
|
||||
<BottomControls {...props} />
|
||||
</ContentWrapper>
|
||||
);
|
||||
@ -1,5 +1,5 @@
|
||||
import InsTable from '../InsTable';
|
||||
import tableConfig from '../lib/config';
|
||||
import tableConfig from '../lib/config/table';
|
||||
|
||||
export default {
|
||||
title: 'Components/Calculation/ELT/Kasko',
|
||||
|
||||
@ -1,17 +1,17 @@
|
||||
import InsContent from '../Components/InsContent';
|
||||
import tableConfig from '../lib/config';
|
||||
import getData from '../lib/getData';
|
||||
import buildELTContent from '../build';
|
||||
import { fetchData } from '../lib/requests';
|
||||
import composeRequest from './lib/composeRequest';
|
||||
import tableConfig from './lib/config';
|
||||
import convertEltResult from './lib/convertEltResult';
|
||||
import onSelectRow from './lib/onSelectRow';
|
||||
import { requiredFields } from './lib/validation';
|
||||
|
||||
const insType = 'kasko';
|
||||
|
||||
export default InsContent({
|
||||
export default buildELTContent({
|
||||
title: 'КАСКО',
|
||||
insType,
|
||||
getData: getData(insType, composeRequest, convertEltResult),
|
||||
fetchData: fetchData(insType, composeRequest, convertEltResult),
|
||||
onSelectRow,
|
||||
tableConfig,
|
||||
requiredFields,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { currentDate } from 'core/tools/date';
|
||||
import { ICalculationStore } from 'core/types/Calculation/Store/index';
|
||||
import { isNull } from 'lodash';
|
||||
import { get, isNull } from 'lodash';
|
||||
|
||||
const mapEngineType = {
|
||||
100000000: '0',
|
||||
@ -37,8 +37,9 @@ const mapCategory = {
|
||||
const getSpecified = value => !isNull(value);
|
||||
|
||||
export default function (this: ICalculationStore) {
|
||||
const regionName = this.getOption('selectRegionRegistration')?.evo_name;
|
||||
const cityName = this.getOption('selectTownRegistration')?.evo_name;
|
||||
const region = this.getOption('selectRegionRegistration');
|
||||
const city = this.getOption('selectTownRegistration');
|
||||
const kladr = get(city, 'evo_kladr_id') || get(region, 'evo_kladr_id');
|
||||
const brandId = this.getOption('selectBrand')?.evo_id;
|
||||
const modelId = this.getOption('selectModel')?.evo_id;
|
||||
|
||||
@ -57,7 +58,7 @@ export default function (this: ICalculationStore) {
|
||||
const cost =
|
||||
this.getValue('leaseObjectPrice') - this.getValue('supplierDiscountRub');
|
||||
|
||||
const franchise = this.getValue('insFranchise');
|
||||
const franchise = parseInt(this.getValue('insFranchise') || 0);
|
||||
const franchiseSpecified = getSpecified(franchise);
|
||||
const puuMark = this.getOption('selectGPSBrand')?.evo_id;
|
||||
const puuModel = this.getOption('selectGPSModel')?.evo_id;
|
||||
@ -108,19 +109,11 @@ export default function (this: ICalculationStore) {
|
||||
? '11635'
|
||||
: '0';
|
||||
|
||||
const globalLimitSum = this.getTableRowValues('tableInsurance', 2, 'value')
|
||||
.insCost
|
||||
? 1000000
|
||||
: 0;
|
||||
const globalLimitSumSpecified = getSpecified(globalLimitSum);
|
||||
const limitSumId = globalLimitSum + '';
|
||||
|
||||
const INN = this.getValue('INNForCalc') || '' + '';
|
||||
const INN = `${this.getValue('INNForCalc')}`;
|
||||
|
||||
return {
|
||||
preparams: {
|
||||
regionName,
|
||||
cityName,
|
||||
kladr,
|
||||
brandId,
|
||||
modelId,
|
||||
},
|
||||
@ -170,8 +163,6 @@ export default function (this: ICalculationStore) {
|
||||
classification,
|
||||
},
|
||||
drivers: [{ age, experience, sex, sexSpecified }],
|
||||
GO: { limitSumId, globalLimitSum, globalLimitSumSpecified },
|
||||
NS: { LimitSum: '1000000' },
|
||||
Insurer: {
|
||||
SubjectType: 1,
|
||||
SubjectTypeSpecified: true,
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
import { formatMoney } from 'core/tools/format';
|
||||
|
||||
const columns: { title: string; dataIndex: string; [key: string]: any }[] = [
|
||||
{
|
||||
title: 'Страховая компания',
|
||||
dataIndex: 'name',
|
||||
},
|
||||
{
|
||||
title: 'Сумма',
|
||||
dataIndex: 'kaskoSum',
|
||||
//@ts-ignore
|
||||
sorter: (a, b) => a.kaskoSum || 0 - b.kaskoSum || 0,
|
||||
sortDirections: ['descend', 'ascend'],
|
||||
render: value => formatMoney(value, 'RUB'),
|
||||
},
|
||||
{
|
||||
title: 'Франшиза',
|
||||
dataIndex: 'totalFranchise',
|
||||
render: value => formatMoney(value, 'RUB'),
|
||||
},
|
||||
];
|
||||
|
||||
export default columns;
|
||||
@ -0,0 +1,4 @@
|
||||
import tableConfig from '../../../lib/config/table';
|
||||
import columns from './columns';
|
||||
|
||||
export default { columns, ...tableConfig };
|
||||
@ -1,21 +1,6 @@
|
||||
import { get, pick } from 'lodash';
|
||||
|
||||
const mapKaskoSums = [
|
||||
{
|
||||
sumTitle: 'КАСКО',
|
||||
sumPath: 'paymentPeriods[0].kaskoSum',
|
||||
},
|
||||
{
|
||||
sumTitle: 'ДГО',
|
||||
sumPath: 'paymentPeriods[0].goSum',
|
||||
},
|
||||
{
|
||||
sumTitle: 'НС',
|
||||
sumPath: 'paymentPeriods[0].nsSum',
|
||||
},
|
||||
];
|
||||
|
||||
export default function (resultCompany, key) {
|
||||
export default function (resultCompany, key, { leasingPeriod }) {
|
||||
if (!resultCompany || Object.keys(resultCompany).length === 0) {
|
||||
return;
|
||||
}
|
||||
@ -25,23 +10,17 @@ export default function (resultCompany, key) {
|
||||
['message', 'requestId', 'skCalcId'],
|
||||
'',
|
||||
);
|
||||
const sumsFromResult = Object.fromEntries(
|
||||
['kaskoSum', 'goSum', 'nsSum', 'premiumSum'].map(x => [
|
||||
x,
|
||||
get(resultCompany, 'paymentPeriods[0].' + x, 0),
|
||||
]),
|
||||
);
|
||||
|
||||
const sumsFromResult = pick(resultCompany, ['totalFranchise'], 0);
|
||||
|
||||
const kaskoSumSource =
|
||||
leasingPeriod < 16 ? 'kaskoSum' : 'paymentPeriods[0].kaskoSum';
|
||||
const kaskoSum = get(resultCompany, kaskoSumSource, 0);
|
||||
|
||||
return {
|
||||
key,
|
||||
sumType: 'premiumSum',
|
||||
sumTitle: 'Премия по договору',
|
||||
...dataFromResult,
|
||||
...sumsFromResult,
|
||||
children: mapKaskoSums.map(({ sumPath, ...x }) => ({
|
||||
key,
|
||||
...x,
|
||||
premiumSum: get(resultCompany, sumPath, 0),
|
||||
})),
|
||||
kaskoSum,
|
||||
};
|
||||
}
|
||||
|
||||
@ -8,7 +8,10 @@ export default function (
|
||||
const selectedRow = this.stores.ELTStore[insType].list.find(
|
||||
x => x.key === selectedKey,
|
||||
);
|
||||
const { accountid, kaskoSum, goSum, nsSum } = selectedRow;
|
||||
const { accountid, kaskoSum, totalFranchise } = selectedRow;
|
||||
|
||||
this.setValue('insFranchise', totalFranchise);
|
||||
|
||||
this.setTableRows(
|
||||
'tableInsurance',
|
||||
1,
|
||||
@ -19,17 +22,17 @@ export default function (
|
||||
},
|
||||
insCost: { value: kaskoSum },
|
||||
},
|
||||
{
|
||||
insuranceCompany: {
|
||||
value: accountid,
|
||||
},
|
||||
insCost: { value: goSum },
|
||||
},
|
||||
{
|
||||
insuranceCompany: {
|
||||
value: accountid,
|
||||
},
|
||||
insCost: { value: nsSum },
|
||||
},
|
||||
// {
|
||||
// insuranceCompany: {
|
||||
// value: accountid,
|
||||
// },
|
||||
// insCost: { value: goSum },
|
||||
// },
|
||||
// {
|
||||
// insuranceCompany: {
|
||||
// value: accountid,
|
||||
// },
|
||||
// insCost: { value: nsSum },
|
||||
// },
|
||||
]);
|
||||
}
|
||||
|
||||
@ -5,9 +5,15 @@ export const requiredFields: ElementsNames[] = [
|
||||
'selectTownRegistration',
|
||||
'selectBrand',
|
||||
'selectModel',
|
||||
'cbxLeaseObjectUsed',
|
||||
'tbxLeaseObjectYear',
|
||||
'tbxLeaseObjectMotorPower',
|
||||
'selectEngineType',
|
||||
'tbxLeasingPeriod',
|
||||
'tbxLeaseObjectPrice',
|
||||
'tbxSupplierDiscountRub',
|
||||
'tbxInsFranchise',
|
||||
'selectLeaseObjectCategory',
|
||||
'selectLeaseObjectUseFor',
|
||||
'tbxINNForCalc',
|
||||
];
|
||||
|
||||
@ -1,17 +1,17 @@
|
||||
import InsContent from '../Components/InsContent';
|
||||
import tableConfig from '../lib/config';
|
||||
import getData from '../lib/getData';
|
||||
import buildELTContent from '../build';
|
||||
import { fetchData } from '../lib/requests';
|
||||
import composeRequest from './lib/composeRequest';
|
||||
import tableConfig from './lib/config';
|
||||
import convertEltResult from './lib/convertEltResult';
|
||||
import onSelectRow from './lib/onSelectRow';
|
||||
import { requiredFields } from './lib/validation';
|
||||
|
||||
const insType = 'osago';
|
||||
|
||||
export default InsContent({
|
||||
export default buildELTContent({
|
||||
title: 'ОСАГО',
|
||||
insType,
|
||||
getData: getData(insType, composeRequest, convertEltResult),
|
||||
fetchData: fetchData(insType, composeRequest, convertEltResult),
|
||||
onSelectRow,
|
||||
tableConfig,
|
||||
requiredFields,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { currentDate } from 'core/tools/date';
|
||||
import { ICalculationStore } from 'core/types/Calculation/Store';
|
||||
import { isNull } from 'lodash';
|
||||
import { get, isNull } from 'lodash';
|
||||
|
||||
const mapCategory = {
|
||||
100000000: 'A',
|
||||
@ -11,7 +11,7 @@ const mapCategory = {
|
||||
};
|
||||
|
||||
const mapSubCategoryBuilder = (leaseObjectUseFor, maxMass, countSeats) => ({
|
||||
100000000: () => '0',
|
||||
100000000: '0',
|
||||
100000001: () => {
|
||||
if (leaseObjectUseFor === 100000001) {
|
||||
return '11';
|
||||
@ -39,8 +39,9 @@ const mapSubCategoryBuilder = (leaseObjectUseFor, maxMass, countSeats) => ({
|
||||
const getSpecified = value => !isNull(value);
|
||||
|
||||
export default function (this: ICalculationStore) {
|
||||
const regionName = this.getOption('selectRegionRegistration')?.evo_name;
|
||||
const cityName = this.getOption('selectTownRegistration')?.evo_name;
|
||||
const region = this.getOption('selectRegionRegistration');
|
||||
const city = this.getOption('selectTownRegistration');
|
||||
const kladr = get(city, 'evo_kladr_id') || get(region, 'evo_kladr_id');
|
||||
const brandId = this.getOption('selectBrand')?.evo_id;
|
||||
const modelId = this.getOption('selectModel')?.evo_id;
|
||||
|
||||
@ -54,19 +55,20 @@ export default function (this: ICalculationStore) {
|
||||
: '0';
|
||||
|
||||
let category = '0';
|
||||
if (Object.keys(mapCategory).includes(leaseObjectCategory)) {
|
||||
category = mapCategory[leaseObjectCategory];
|
||||
if (Object.keys(mapCategory).includes(`${leaseObjectCategory}`)) {
|
||||
category = mapCategory[`${leaseObjectCategory}`];
|
||||
}
|
||||
|
||||
const leaseObjectUseFor = this.getValue('leaseObjectUseFor');
|
||||
const maxMass = this.getValue('maxMass');
|
||||
const countSeats = this.getValue('countSeats');
|
||||
|
||||
const mapSubCategory = mapSubCategoryBuilder(
|
||||
leaseObjectUseFor,
|
||||
maxMass,
|
||||
countSeats,
|
||||
);
|
||||
const subCategory = mapSubCategory[leaseObjectCategory];
|
||||
const subCategory = mapSubCategory[leaseObjectCategory]();
|
||||
|
||||
let seatingCapacity = 0;
|
||||
if (leaseObjectCategory === 100000003) {
|
||||
@ -87,13 +89,11 @@ export default function (this: ICalculationStore) {
|
||||
resident: 1,
|
||||
country: 'Российская Федерация',
|
||||
region: 'Москва',
|
||||
district: '0',
|
||||
// district: '0',
|
||||
city: 'Москва',
|
||||
cityKladr: '7700000000000',
|
||||
street: 'ул. Котляковская',
|
||||
streetKladr: '0',
|
||||
house: '8',
|
||||
korpus: '0',
|
||||
flat: '337',
|
||||
};
|
||||
|
||||
@ -106,19 +106,27 @@ export default function (this: ICalculationStore) {
|
||||
factAddress: address,
|
||||
phone: '8 (800) 333-75-75',
|
||||
email: 'client@evoleasing.ru',
|
||||
subjectType: 1,
|
||||
subjectTypeSpecified: true,
|
||||
opf: 1,
|
||||
opfSpecified: true,
|
||||
};
|
||||
|
||||
return {
|
||||
preparams: {
|
||||
regionName,
|
||||
cityName,
|
||||
kladr,
|
||||
brandId,
|
||||
modelId,
|
||||
},
|
||||
ELTParams: {
|
||||
driversCount: 0,
|
||||
tsToRegistrationPlace: 0,
|
||||
contractBeginDate: currentDate,
|
||||
duration: 12,
|
||||
insurerType: 1,
|
||||
ownerType: 1,
|
||||
contractOptionId: 1,
|
||||
contractStatusId: 13,
|
||||
carInfo: {
|
||||
mark,
|
||||
model,
|
||||
@ -126,10 +134,6 @@ export default function (this: ICalculationStore) {
|
||||
vehiclePower,
|
||||
tsType: { category, subCategory },
|
||||
vehicle: {
|
||||
regNumber: '0',
|
||||
bodyNumber: '0',
|
||||
chassisNumber: '0',
|
||||
VIN: '0',
|
||||
seatingCapacity,
|
||||
seatingCapacitySpecified,
|
||||
maxAllowedMass,
|
||||
|
||||
@ -1,20 +1,17 @@
|
||||
export type KaskoDataNames = 'name' | 'sumTitle' | 'premiumSum';
|
||||
import { formatMoney } from 'core/tools/format';
|
||||
|
||||
const columns: { title: string; dataIndex: KaskoDataNames }[] = [
|
||||
const columns: { title: string; dataIndex: string; [key: string]: any }[] = [
|
||||
{
|
||||
title: 'Страховая компания',
|
||||
dataIndex: 'name',
|
||||
},
|
||||
{
|
||||
title: '',
|
||||
dataIndex: 'sumTitle',
|
||||
},
|
||||
{
|
||||
title: 'Сумма',
|
||||
dataIndex: 'premiumSum',
|
||||
//@ts-ignore
|
||||
sorter: (a, b) => a.premiumSum - b.premiumSum,
|
||||
sorter: (a, b) => a.premiumSum || 0 - b.premiumSum || 0,
|
||||
sortDirections: ['descend', 'ascend'],
|
||||
render: value => formatMoney(value),
|
||||
},
|
||||
];
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
import tableConfig from '../../../lib/config/table';
|
||||
import columns from './columns';
|
||||
|
||||
export default { columns, ...tableConfig };
|
||||
@ -9,5 +9,10 @@ export const requiredFields: ElementsNames[] = [
|
||||
'tbxLeaseObjectMotorPower',
|
||||
'tbxLeasingPeriod',
|
||||
'tbxLeaseObjectPrice',
|
||||
'selectLeaseObjectUseFor',
|
||||
'tbxMaxMass',
|
||||
'tbxCountSeats',
|
||||
'cbxWithTrailer',
|
||||
'selectLeaseObjectCategory',
|
||||
'tbxINNForCalc',
|
||||
];
|
||||
|
||||
28
src/client/Components/Calculation/ELT/Content/build.jsx
Normal file
28
src/client/Components/Calculation/ELT/Content/build.jsx
Normal file
@ -0,0 +1,28 @@
|
||||
import { Flex } from 'client/UIKit/grid';
|
||||
import { useState } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { BottomControls, TopControls } from './Components/Controls';
|
||||
import InsTable from './Components/InsTable';
|
||||
|
||||
const ContentWrapper = styled(Flex)`
|
||||
flex-direction: column;
|
||||
width: 100%; !important
|
||||
`;
|
||||
|
||||
const buildELTContent = ({ tableConfig, ...params }) => props => {
|
||||
const [selectedKey, selectKey] = useState();
|
||||
return (
|
||||
<ContentWrapper>
|
||||
<TopControls {...params} />
|
||||
<InsTable
|
||||
{...params}
|
||||
tableConfig={tableConfig}
|
||||
selectedKey={selectedKey}
|
||||
selectKey={selectKey}
|
||||
/>
|
||||
<BottomControls {...params} selectedKey={selectedKey} />
|
||||
</ContentWrapper>
|
||||
);
|
||||
};
|
||||
|
||||
export default buildELTContent;
|
||||
@ -1,18 +1,14 @@
|
||||
import { Flex } from 'client/UIKit/grid';
|
||||
import mq from 'client/UIKit/mq';
|
||||
import styled from 'styled-components';
|
||||
import Kasko from './Kasko';
|
||||
import Osago from './Osago';
|
||||
|
||||
const ContentDivider = styled.div`
|
||||
margin: 16px 0;
|
||||
${mq.laptopHD`
|
||||
margin: 0 16px;
|
||||
`}
|
||||
`;
|
||||
|
||||
export default () => (
|
||||
<Flex flexDirection={['column', 'column', 'column', 'row']}>
|
||||
<Flex flexDirection="column">
|
||||
<Osago />
|
||||
<ContentDivider />
|
||||
<Kasko />
|
||||
|
||||
@ -1,15 +1,13 @@
|
||||
import { TableProps } from 'antd';
|
||||
import columns from './columns';
|
||||
|
||||
export default {
|
||||
columns,
|
||||
rowSelection: {
|
||||
hideSelectAll: true,
|
||||
type: 'radio',
|
||||
},
|
||||
expandable: {
|
||||
// rowExpandable: record => record.message || record.children,
|
||||
// expandedRowRender: record => record.message,
|
||||
rowExpandable: record => record.message || record.children,
|
||||
expandedRowRender: record => record.message,
|
||||
// expandRowByClick: true,
|
||||
// expandIconColumnIndex: -1,
|
||||
},
|
||||
@ -1,9 +1,20 @@
|
||||
import axios from 'axios';
|
||||
import ELTService from 'core/services/ELTService';
|
||||
import { ICalculationStore } from 'core/types/Calculation/Store';
|
||||
import { IAccount } from 'core/types/Entities/crmEntities';
|
||||
import { toJS } from 'mobx';
|
||||
|
||||
const CancelToken = axios.CancelToken;
|
||||
export let sources = {};
|
||||
|
||||
export function cancelRequests(insType: string) {
|
||||
if (sources[insType]) sources[insType].cancel();
|
||||
}
|
||||
|
||||
export const fetchData = (insType: string, composeRequest, convertEltResult) =>
|
||||
function (this: ICalculationStore) {
|
||||
sources[insType] = CancelToken.source();
|
||||
|
||||
export default (insType: string, composeRequest, convertEltResult) =>
|
||||
function (this: ICalculationStore, callback: () => any) {
|
||||
const { ELTStore } = this.stores;
|
||||
const request = composeRequest.call(this);
|
||||
|
||||
@ -11,10 +22,13 @@ export default (insType: string, composeRequest, convertEltResult) =>
|
||||
(company: IAccount, i: number) =>
|
||||
new Promise<void>((resolve, reject) => {
|
||||
ELTService[insType]
|
||||
.getCalculation({
|
||||
companyIds: [company.evo_id_elt],
|
||||
...request,
|
||||
})
|
||||
.getCalculation(
|
||||
{
|
||||
companyIds: [company.evo_id_elt],
|
||||
...request,
|
||||
},
|
||||
sources[insType].token,
|
||||
)
|
||||
.then(res => {
|
||||
if (!company.evo_id_elt || !res[company.evo_id_elt]) {
|
||||
return;
|
||||
@ -22,6 +36,7 @@ export default (insType: string, composeRequest, convertEltResult) =>
|
||||
const converted = convertEltResult(
|
||||
res[company.evo_id_elt],
|
||||
company.accountid,
|
||||
toJS(this.getValues(['leasingPeriod'])),
|
||||
);
|
||||
ELTStore.setCompanyRes(
|
||||
insType,
|
||||
@ -36,5 +51,5 @@ export default (insType: string, composeRequest, convertEltResult) =>
|
||||
}),
|
||||
);
|
||||
|
||||
Promise.allSettled(requests).then(() => callback());
|
||||
return Promise.race(requests);
|
||||
};
|
||||
@ -0,0 +1,48 @@
|
||||
import { ICalculationStore } from 'core/types/Calculation/Store';
|
||||
import { TCRMEntity } from 'core/types/Entities/crmEntities';
|
||||
import { pick } from 'lodash';
|
||||
import { sources } from './requests';
|
||||
|
||||
const mapInsType = {
|
||||
kasko: 100000000,
|
||||
osago: 100000001,
|
||||
};
|
||||
|
||||
export const initFields = ['evo_id_elt', 'name', 'accountid'];
|
||||
|
||||
export function initIns(this: ICalculationStore, insType) {
|
||||
const insuranceCompanies = this.getTableOptions(
|
||||
'tableInsurance',
|
||||
'insuranceCompany',
|
||||
);
|
||||
if (insuranceCompanies === undefined) {
|
||||
return;
|
||||
}
|
||||
const { ELTStore } = this.stores;
|
||||
const list: TCRMEntity[] = [];
|
||||
insuranceCompanies.forEach(company => {
|
||||
if (
|
||||
company &&
|
||||
company.evo_id_elt &&
|
||||
company.evo_type_ins_policy &&
|
||||
company.evo_type_ins_policy.includes(mapInsType[insType])
|
||||
) {
|
||||
const companyData = pick(company, initFields, '');
|
||||
list.push(companyData);
|
||||
}
|
||||
});
|
||||
ELTStore[insType].list.replace(list);
|
||||
}
|
||||
|
||||
export function resetIns(this: ICalculationStore, insType) {
|
||||
sources[insType] && sources[insType].cancel();
|
||||
|
||||
const { ELTStore } = this.stores;
|
||||
|
||||
const list: TCRMEntity[] = [];
|
||||
ELTStore[insType].list.forEach(x => {
|
||||
const picked = pick(x, initFields, '');
|
||||
list.push(picked);
|
||||
});
|
||||
ELTStore[insType].reset(list);
|
||||
}
|
||||
@ -1,19 +1,16 @@
|
||||
import { elementsTitles } from 'client/Containers/Calculation/lib/elements/titles';
|
||||
import { elementsValues } from 'client/Containers/Calculation/lib/elements/values';
|
||||
import { getValueName } from 'client/Containers/Calculation/lib/elements/tools';
|
||||
import { ICalculationStore } from 'core/types/Calculation/Store';
|
||||
import { ElementsNames } from 'core/types/Calculation/Store/elements';
|
||||
import { isNil } from 'lodash';
|
||||
|
||||
export function validate(this: ICalculationStore, requiredValues) {
|
||||
const missingValues = requiredValues.filter(x => {
|
||||
const valueName = elementsValues[x] || '';
|
||||
|
||||
return (
|
||||
this.values[valueName] === undefined || this.values[valueName] === null
|
||||
);
|
||||
export function validate(
|
||||
this: ICalculationStore,
|
||||
requiredFields: ElementsNames[],
|
||||
) {
|
||||
const missingValues = requiredFields.filter(fieldName => {
|
||||
const valueName = getValueName(fieldName);
|
||||
const value = this.getValue(valueName);
|
||||
return isNil(value);
|
||||
});
|
||||
return missingValues;
|
||||
}
|
||||
|
||||
export function getFieldsNames(elementsNames: ElementsNames[]): string[] {
|
||||
return elementsNames.map(x => elementsTitles[x] || '');
|
||||
}
|
||||
|
||||
@ -1,51 +1,7 @@
|
||||
import { Modal } from 'antd';
|
||||
import { Outlined as SpinnerOutlined } from 'client/Components/Spinner';
|
||||
import Button from 'client/Elements/Button';
|
||||
import { CenterContent } from 'client/Elements/Wrapper';
|
||||
import { Box } from 'client/UIKit/grid';
|
||||
import { lazy, Suspense, useState } from 'react';
|
||||
import { lazy } from 'react';
|
||||
|
||||
const Content = lazy(() => import('./Content'));
|
||||
|
||||
const ELT = ({ title }) => {
|
||||
const [isOpenModal, setIsOpenModal] = useState(false);
|
||||
function closeModal() {
|
||||
setIsOpenModal(false);
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<Box mb="24px">
|
||||
<Button
|
||||
style={{ width: '100%' }}
|
||||
text={title}
|
||||
action={() => {
|
||||
setIsOpenModal(!isOpenModal);
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
{isOpenModal && (
|
||||
<Modal
|
||||
title={title}
|
||||
visible={isOpenModal}
|
||||
onOk={closeModal}
|
||||
onCancel={closeModal}
|
||||
footer={null}
|
||||
width="max-content"
|
||||
centered
|
||||
>
|
||||
<Suspense
|
||||
fallback={
|
||||
<CenterContent>
|
||||
<SpinnerOutlined />
|
||||
</CenterContent>
|
||||
}
|
||||
>
|
||||
<Content />
|
||||
</Suspense>
|
||||
</Modal>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
const ELT = () => <Content />;
|
||||
|
||||
export default ELT;
|
||||
|
||||
25
src/client/Components/Calculation/InsuranceTag.jsx
Normal file
25
src/client/Components/Calculation/InsuranceTag.jsx
Normal file
@ -0,0 +1,25 @@
|
||||
import Tag from 'client/Elements/Tag';
|
||||
import { useStores } from 'client/hooks/useStores';
|
||||
import { observer } from 'mobx-react-lite';
|
||||
import { Flex } from 'rebass';
|
||||
|
||||
const InsuranceTag = observer(() => {
|
||||
const {
|
||||
calculationStore: {
|
||||
stores: { ELTStore },
|
||||
},
|
||||
} = useStores();
|
||||
|
||||
return (
|
||||
<Flex flexDirection="inherit" marginBottom="5px">
|
||||
{ELTStore.osago.selectedKey && (
|
||||
<Tag color="gold">Применен расчет ЭЛТ для ОСАГО</Tag>
|
||||
)}
|
||||
{ELTStore.kasko.selectedKey && (
|
||||
<Tag color="cyan">Применен расчет ЭЛТ для КАСКО</Tag>
|
||||
)}
|
||||
</Flex>
|
||||
);
|
||||
});
|
||||
|
||||
export default InsuranceTag;
|
||||
@ -276,7 +276,6 @@ const sections: ISection[] = [
|
||||
'radioInsKaskoType',
|
||||
'tbxInsFranchise',
|
||||
'tbxMileage',
|
||||
// 'btnInsCalculation',
|
||||
// 'selectInsPeriod',
|
||||
// 'btnFranschise',
|
||||
],
|
||||
@ -287,7 +286,7 @@ const sections: ISection[] = [
|
||||
'tbxInsAgeDrivers',
|
||||
'tbxInsExpDrivers',
|
||||
'cbxWithTrailer',
|
||||
// 'tbxINNForCalc',
|
||||
'tbxINNForCalc',
|
||||
// 'btnDriversApplication',
|
||||
],
|
||||
},
|
||||
@ -307,7 +306,21 @@ const sections: ISection[] = [
|
||||
style: { columnsNumber: 1 },
|
||||
blocks: [
|
||||
{
|
||||
elements: ['componentElt', 'tableInsurance'],
|
||||
elements: ['tableInsurance'],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: 'ЭЛТ',
|
||||
groups: [
|
||||
{
|
||||
title: 'Расчет страховки ЭЛТ',
|
||||
style: { columnsNumber: 1 },
|
||||
blocks: [
|
||||
{
|
||||
elements: ['componentElt'],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@ -11,9 +11,9 @@ import elementsActions from './elements/actions';
|
||||
import elementsComponents from './elements/components';
|
||||
import elementsComputedValues from './elements/computedValues';
|
||||
import tables from './elements/tables';
|
||||
import { getValueName } from './elements/tools';
|
||||
import elementsTypes from './elements/types';
|
||||
import elementsUrls from './elements/urls';
|
||||
import elementsValues from './elements/values';
|
||||
|
||||
export function buildElement(elementName, elementProps = {}) {
|
||||
const elementType = elementsTypes[elementName];
|
||||
@ -53,7 +53,7 @@ export function buildElement(elementName, elementProps = {}) {
|
||||
default: {
|
||||
return withValue(Component)({
|
||||
name: elementName,
|
||||
valueName: elementsValues[elementName],
|
||||
valueName: getValueName(elementName),
|
||||
...elementProps,
|
||||
});
|
||||
}
|
||||
|
||||
@ -94,7 +94,6 @@ const elementsComponents: TElements<Component> = {
|
||||
cbxInsDecentral: Switch,
|
||||
radioInsKaskoType: Radio,
|
||||
tbxInsFranchise: InputNumber,
|
||||
btnInsCalculation: Button,
|
||||
selectInsPeriod: Select,
|
||||
btnFranschise: Button,
|
||||
cbxInsUnlimitDrivers: Switch,
|
||||
|
||||
@ -1,5 +1,9 @@
|
||||
import DownloadOutlined from '@ant-design/icons/lib/icons/DownloadOutlined';
|
||||
import InsuranceTag from 'client/Components/Calculation/InsuranceTag';
|
||||
import { currentYear } from 'core/tools/date';
|
||||
import { formatMoney, formatNumber } from 'core/tools/format';
|
||||
import { compose } from 'core/tools/func';
|
||||
import { round } from 'core/tools/num';
|
||||
import {
|
||||
validateEmail,
|
||||
validateInn,
|
||||
@ -8,7 +12,6 @@ import {
|
||||
} from 'core/tools/validate';
|
||||
import { ElementProps } from 'core/types/Calculation/components';
|
||||
import { TElements } from 'core/types/Calculation/Store/elements';
|
||||
import { round } from 'lodash';
|
||||
|
||||
const elementsProps: TElements<ElementProps> = {
|
||||
selectChannel: {
|
||||
@ -71,23 +74,24 @@ const elementsProps: TElements<ElementProps> = {
|
||||
text: 'Создать интерес',
|
||||
},
|
||||
tbxLeaseObjectPrice: {
|
||||
min: '1000',
|
||||
max: '1000000000',
|
||||
min: '1000.00',
|
||||
max: '1000000000.00',
|
||||
step: '10000.00',
|
||||
precision: 2,
|
||||
formatter: formatNumber,
|
||||
},
|
||||
tbxSupplierDiscountRub: {
|
||||
// TODO formatter + rub, parser
|
||||
min: '0',
|
||||
max: '1000000000',
|
||||
step: '10000.00',
|
||||
precision: 2,
|
||||
formatter: formatNumber,
|
||||
},
|
||||
tbxSupplierDiscountPerc: {
|
||||
// TODO formatter + %, parser
|
||||
min: '0',
|
||||
max: '100',
|
||||
precision: 2,
|
||||
formatter: formatNumber,
|
||||
},
|
||||
radioBalanceHolder: {
|
||||
style: 'button',
|
||||
@ -97,17 +101,20 @@ const elementsProps: TElements<ElementProps> = {
|
||||
// max: '1.30',
|
||||
step: '0.1',
|
||||
precision: 2,
|
||||
formatter: formatNumber,
|
||||
},
|
||||
tbxFirstPaymentPerc: {
|
||||
min: '0',
|
||||
max: '50',
|
||||
precision: 2,
|
||||
formatter: formatNumber,
|
||||
},
|
||||
tbxFirstPaymentRub: {
|
||||
min: '0',
|
||||
max: '1000000000',
|
||||
step: '10000.00',
|
||||
precision: 2,
|
||||
formatter: formatNumber,
|
||||
},
|
||||
radioLastPaymentRule: {
|
||||
style: 'button',
|
||||
@ -116,18 +123,21 @@ const elementsProps: TElements<ElementProps> = {
|
||||
min: '0',
|
||||
max: '15',
|
||||
step: '1.000000',
|
||||
precision: 6,
|
||||
formatter: formatNumber,
|
||||
},
|
||||
tbxLastPaymentRub: {
|
||||
min: '0',
|
||||
max: '1000000000',
|
||||
step: '10000.00',
|
||||
precision: 2,
|
||||
formatter: formatNumber,
|
||||
},
|
||||
tbxLeasingPeriod: {
|
||||
min: '7',
|
||||
max: '60',
|
||||
},
|
||||
tbxParmentsDecreasePercent: {
|
||||
// TODO: formatter, parser: %
|
||||
min: '50',
|
||||
max: '99',
|
||||
},
|
||||
@ -178,16 +188,21 @@ const elementsProps: TElements<ElementProps> = {
|
||||
min: '0.00',
|
||||
max: '20000.00',
|
||||
step: '10.00',
|
||||
precision: 2,
|
||||
formatter: formatNumber,
|
||||
},
|
||||
tbxEngineVolume: {
|
||||
min: '0.00',
|
||||
max: '99.99',
|
||||
step: '0.50',
|
||||
precision: 2,
|
||||
formatter: formatNumber,
|
||||
},
|
||||
tbxMaxMass: {
|
||||
min: '0',
|
||||
max: '999999',
|
||||
step: '100',
|
||||
formatter: formatNumber,
|
||||
},
|
||||
tbxCountSeats: {
|
||||
min: '0',
|
||||
@ -204,31 +219,43 @@ const elementsProps: TElements<ElementProps> = {
|
||||
min: '0.0',
|
||||
max: '20.0',
|
||||
step: '0.1',
|
||||
precision: 1,
|
||||
formatter: formatNumber,
|
||||
},
|
||||
tbxDealerBrokerRewardSumm: {
|
||||
min: '0.0',
|
||||
max: '20.0',
|
||||
step: '0.1',
|
||||
precision: 1,
|
||||
formatter: formatNumber,
|
||||
},
|
||||
tbxIndAgentRewardSumm: {
|
||||
min: '0.0',
|
||||
max: '20.0',
|
||||
step: '0.1',
|
||||
precision: 1,
|
||||
formatter: formatNumber,
|
||||
},
|
||||
tbxCalcDoubleAgentRewardSumm: {
|
||||
min: '0.0',
|
||||
max: '20.0',
|
||||
step: '0.1',
|
||||
precision: 1,
|
||||
formatter: formatNumber,
|
||||
},
|
||||
tbxCalcBrokerRewardSum: {
|
||||
min: '0.0',
|
||||
max: '20.0',
|
||||
step: '0.1',
|
||||
precision: 1,
|
||||
formatter: formatNumber,
|
||||
},
|
||||
tbxFinDepartmentRewardSumm: {
|
||||
min: '0.0',
|
||||
max: '20.0',
|
||||
step: '0.1',
|
||||
precision: 1,
|
||||
formatter: formatNumber,
|
||||
},
|
||||
radioInsKaskoType: {
|
||||
style: 'button',
|
||||
@ -237,10 +264,8 @@ const elementsProps: TElements<ElementProps> = {
|
||||
min: '0',
|
||||
max: '75000',
|
||||
step: '10000.00',
|
||||
},
|
||||
btnInsCalculation: {
|
||||
type: 'primary',
|
||||
text: 'Запрос расчета страховки',
|
||||
precision: 2,
|
||||
formatter: formatNumber,
|
||||
},
|
||||
btnFranschise: {
|
||||
type: 'ghost',
|
||||
@ -319,8 +344,9 @@ const elementsProps: TElements<ElementProps> = {
|
||||
},
|
||||
tbxMileage: {
|
||||
min: 0,
|
||||
step: 100,
|
||||
step: 100.0,
|
||||
precision: 2,
|
||||
formatter: formatNumber,
|
||||
},
|
||||
cbxRecalcWithRevision: {
|
||||
text: 'Пересчет без пересмотра',
|
||||
@ -364,31 +390,57 @@ const elementsProps: TElements<ElementProps> = {
|
||||
selectObjectRegionRegistration: {
|
||||
showSearch: true,
|
||||
},
|
||||
tbxINNForCalc: {
|
||||
validation: {
|
||||
errorMessage: 'Некорректный ИНН',
|
||||
validator: validateInn,
|
||||
},
|
||||
},
|
||||
tableInsurance: {
|
||||
tag: {
|
||||
Component: InsuranceTag,
|
||||
},
|
||||
},
|
||||
tbxInsKaskoPriceLeasePeriod: {
|
||||
min: 0,
|
||||
precision: 2,
|
||||
formatter: formatNumber,
|
||||
},
|
||||
};
|
||||
|
||||
const resultElementsProps: TElements<ElementProps> = [
|
||||
'labelResultTotalGraphwithNDS',
|
||||
'labelResultPlPrice',
|
||||
'labelResultPriceUpPr',
|
||||
'labelResultIRRGraphPerc',
|
||||
'labelResultIRRNominalPerc',
|
||||
'labelResultInsKasko',
|
||||
'labelResultInsOsago',
|
||||
'labelResultDopProdSum',
|
||||
'labelResultFirstPayment',
|
||||
'labelResultLastPayment',
|
||||
'labelResultTerm',
|
||||
'labelResultAB_FL',
|
||||
'labelResultAB_UL',
|
||||
'labelResultBonusMPL',
|
||||
'labelResultDopMPLLeasing',
|
||||
'labelResultBonusDopProd',
|
||||
].reduce(
|
||||
(ac, a) => ({
|
||||
...ac,
|
||||
[a]: { middleware: value => value && round(value, 2).toFixed(2) },
|
||||
}),
|
||||
const resultElementsProps: TElements<ElementProps> = Object.assign(
|
||||
{},
|
||||
[
|
||||
'labelResultTotalGraphwithNDS',
|
||||
'labelResultPlPrice',
|
||||
'labelResultInsKasko',
|
||||
'labelResultInsOsago',
|
||||
'labelResultDopProdSum',
|
||||
'labelResultFirstPayment',
|
||||
'labelResultLastPayment',
|
||||
'labelResultAB_FL',
|
||||
'labelResultAB_UL',
|
||||
'labelResultBonusMPL',
|
||||
'labelResultDopMPLLeasing',
|
||||
'labelResultBonusDopProd',
|
||||
].reduce(
|
||||
(ac, a) => ({
|
||||
...ac,
|
||||
[a]: { middleware: value => compose(round, formatMoney)(value || 0) },
|
||||
}),
|
||||
{},
|
||||
),
|
||||
[
|
||||
'labelResultPriceUpPr',
|
||||
'labelResultIRRGraphPerc',
|
||||
'labelResultIRRNominalPerc',
|
||||
'labelResultTerm',
|
||||
].reduce(
|
||||
(ac, a) => ({
|
||||
...ac,
|
||||
[a]: { middleware: value => round(value || 0) },
|
||||
}),
|
||||
{},
|
||||
),
|
||||
);
|
||||
|
||||
export default Object.assign(elementsProps, resultElementsProps);
|
||||
|
||||
@ -6,6 +6,7 @@ import {
|
||||
insuranceKaskoDefaultFilter,
|
||||
insuranceOsagoDefaultFilter,
|
||||
} from 'core/constants/stores/Calculation/filters';
|
||||
import { formatNumber } from 'core/tools/format';
|
||||
import {
|
||||
ITable,
|
||||
TableColumn,
|
||||
@ -48,6 +49,8 @@ const columns: TableColumn[] = [
|
||||
min: '0.00',
|
||||
max: '1500000.00',
|
||||
step: '1000.00',
|
||||
precision: 2,
|
||||
formatter: formatNumber,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
import Label from 'client/Elements/Label';
|
||||
import { formatMoney } from 'core/tools/format';
|
||||
import { compose } from 'core/tools/func';
|
||||
import { round } from 'core/tools/num';
|
||||
import {
|
||||
ITable,
|
||||
TableColumn,
|
||||
TableColumnFeatures,
|
||||
} from 'core/types/Calculation/Store/tables';
|
||||
import { round } from 'lodash';
|
||||
|
||||
const columns: TableColumn[] = [
|
||||
{
|
||||
@ -12,7 +14,7 @@ const columns: TableColumn[] = [
|
||||
title: 'Сумма платежа',
|
||||
Component: Label,
|
||||
props: {
|
||||
middleware: value => value && round(value, 2).toFixed(2),
|
||||
middleware: value => compose(round, formatMoney)(value || 0),
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -20,7 +22,7 @@ const columns: TableColumn[] = [
|
||||
title: 'НДС к возмещению',
|
||||
Component: Label,
|
||||
props: {
|
||||
middleware: value => value && round(value, 2).toFixed(2),
|
||||
middleware: value => compose(round, formatMoney)(value || 0),
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -28,7 +30,7 @@ const columns: TableColumn[] = [
|
||||
title: 'Сумма досрочного выкупа',
|
||||
Component: Label,
|
||||
props: {
|
||||
middleware: value => value && round(value, 2).toFixed(2),
|
||||
middleware: value => compose(round, formatMoney)(value || 0),
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@ -133,22 +133,23 @@ export const elementsTitles: TElements<string> = {
|
||||
selectObjectTypeTax: 'Тип ТС для ТН',
|
||||
radioTypePTS: 'Тип ПТС',
|
||||
labelRegistrationDescription: 'Описание регистрации',
|
||||
tbxINNForCalc: 'ИНН контрагента',
|
||||
};
|
||||
|
||||
const resultsTitles: TElements<string> = {
|
||||
labelResultTotalGraphwithNDS: 'Итого по графику, с НДС',
|
||||
labelResultPlPrice: 'Стоимость ПЛ, руб. с НДС',
|
||||
labelResultPlPrice: 'Стоимость ПЛ с НДС',
|
||||
labelResultPriceUpPr: 'Удорожание, год',
|
||||
labelResultIRRGraphPerc: 'IRR по графику клиента, %',
|
||||
labelResultIRRNominalPerc: 'IRR (номинал), %',
|
||||
labelResultInsKasko: 'КАСКО, НС, ДГО в графике',
|
||||
labelResultInsOsago: 'ОСАГО в графике',
|
||||
labelResultDopProdSum: 'Общая сумма доп.продуктов',
|
||||
labelResultFirstPayment: 'Первый платеж, руб.',
|
||||
labelResultLastPayment: 'Последний платеж, руб.',
|
||||
labelResultFirstPayment: 'Первый платеж.',
|
||||
labelResultLastPayment: 'Последний платеж.',
|
||||
labelResultTerm: 'Срок, мес.',
|
||||
labelResultAB_FL: 'АВ ФЛ, без НДФЛ, руб.',
|
||||
labelResultAB_UL: 'АВ ЮЛ, с НДС, руб.',
|
||||
labelResultAB_FL: 'АВ ФЛ, без НДФЛ.',
|
||||
labelResultAB_UL: 'АВ ЮЛ, с НДС.',
|
||||
labelResultBonusMPL: 'Бонус МПЛ за лизинг, без НДФЛ',
|
||||
labelResultDopMPLLeasing: 'Доп.бонус МПЛ за лизинг, без НДФЛ',
|
||||
labelResultBonusDopProd: 'Бонус МПЛ за доп.продукты, без НДФЛ',
|
||||
|
||||
19
src/client/Containers/Calculation/lib/elements/tools.ts
Normal file
19
src/client/Containers/Calculation/lib/elements/tools.ts
Normal file
@ -0,0 +1,19 @@
|
||||
//@ts-nocheck
|
||||
import { ElementsNames } from 'core/types/Calculation/Store/elements';
|
||||
import { ValuesNames } from 'core/types/Calculation/Store/values';
|
||||
import { elementsTitles } from './titles';
|
||||
import { elementsValues } from './values';
|
||||
|
||||
export function getValueName(fieldName: ElementsNames): ValuesNames {
|
||||
return elementsValues[fieldName];
|
||||
}
|
||||
|
||||
export function getFieldName(valueName: ValuesNames): ElementsNames {
|
||||
return Object.keys(elementsValues).find(
|
||||
key => elementsValues[key] === valueName,
|
||||
);
|
||||
}
|
||||
|
||||
export function getTitle(fieldName: ElementsNames): string {
|
||||
return elementsTitles[fieldName];
|
||||
}
|
||||
@ -3,7 +3,6 @@ import { StoreTables } from 'core/types/Calculation/Store/tables';
|
||||
|
||||
const elementsTypes: TElements<ElementType> = {
|
||||
labelLeaseObjectRisk: ElementType.Computed,
|
||||
btnInsCalculation: ElementType.Action,
|
||||
btnFranschise: ElementType.Action,
|
||||
btnDriversApplication: ElementType.Action,
|
||||
tbxInsKaskoPriceLeasePeriod: ElementType.Computed,
|
||||
|
||||
@ -58,6 +58,7 @@ const query = gql`
|
||||
evo_fias_id
|
||||
evo_businessunit_evolution
|
||||
evo_oktmo
|
||||
evo_kladr_id
|
||||
}
|
||||
selectAccount: accounts(
|
||||
evo_account_type: $account_account_type
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { IQueryToCRMGQL } from 'core/types/Calculation/Requests';
|
||||
import { gql } from '@apollo/client';
|
||||
import { IQueryToCRMGQL } from 'core/types/Calculation/Requests';
|
||||
|
||||
const query = gql`
|
||||
query($statecode: Int, $domainname: String) {
|
||||
@ -18,6 +18,7 @@ const query = gql`
|
||||
evo_city_fias_id
|
||||
}
|
||||
}
|
||||
evo_inn
|
||||
}
|
||||
selectOpportunity: opportunities(
|
||||
statecode: $statecode
|
||||
|
||||
@ -25,13 +25,25 @@ const ElementTitle = styled.h5`
|
||||
const renderElements = ({ elements }) => {
|
||||
return elements.map((elementName, ie) => {
|
||||
const elementTitle = elementsTitles[elementName];
|
||||
const { tooltip, ...elementProps } = elementsProps[elementName] || {};
|
||||
const { tooltip, tag, ...elementProps } = elementsProps[elementName] || {};
|
||||
|
||||
let TagComponent = () => null;
|
||||
if (tag && tag.Component) {
|
||||
TagComponent = tag.Component;
|
||||
}
|
||||
|
||||
const Component = buildElement(elementName, elementProps);
|
||||
return (
|
||||
<Tooltip {...tooltip}>
|
||||
<Flex flexDirection="column" key={ie}>
|
||||
<ElementTitle>{elementTitle}</ElementTitle>
|
||||
<Flex
|
||||
flexDirection={['column', 'row']}
|
||||
justifyContent={[undefined, 'space-between']}
|
||||
alignItems={[undefined, 'center']}
|
||||
>
|
||||
<ElementTitle>{elementTitle}</ElementTitle>
|
||||
<TagComponent />
|
||||
</Flex>
|
||||
<Component />
|
||||
</Flex>
|
||||
</Tooltip>
|
||||
|
||||
@ -24,6 +24,7 @@ const InputNumber = ({
|
||||
status,
|
||||
validateStatus,
|
||||
message,
|
||||
formatter,
|
||||
...props
|
||||
}) => {
|
||||
return (
|
||||
@ -34,10 +35,14 @@ const InputNumber = ({
|
||||
>
|
||||
<AntInputNumber
|
||||
{...props}
|
||||
parser={value => {
|
||||
value = value.replace(/[^0-9.,]+/, '');
|
||||
if (value === '') {
|
||||
return '0';
|
||||
// parser={value => value.replace(/\$\s?|(,*)/g, '')}
|
||||
decimalSeparator=","
|
||||
formatter={value => {
|
||||
if (formatter) {
|
||||
return formatter(value, {
|
||||
minimumFractionDigits: props.precision,
|
||||
maximumFractionDigits: props.precision,
|
||||
});
|
||||
}
|
||||
return value;
|
||||
}}
|
||||
@ -45,6 +50,7 @@ const InputNumber = ({
|
||||
style={styles}
|
||||
onChange={value => setCurrentValue(value)}
|
||||
value={value}
|
||||
stringMode
|
||||
/>
|
||||
{status === ElementStatus.Loading && <Outlined />}
|
||||
</FormWrapper>
|
||||
|
||||
3
src/client/Elements/Tag.jsx
Normal file
3
src/client/Elements/Tag.jsx
Normal file
@ -0,0 +1,3 @@
|
||||
import { Tag as AntTag } from 'antd';
|
||||
|
||||
export default AntTag;
|
||||
@ -1,5 +1,4 @@
|
||||
import { DEFAULT_DEBOUNCE_DELAY } from 'core/constants/debounce';
|
||||
import { Process } from 'core/types/Calculation/Store/process';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useDebouncedCallback } from 'use-debounce';
|
||||
import { useStores } from '../useStores';
|
||||
@ -92,7 +91,7 @@ export const useTableValue = ({
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (columnCallback && calculationProcess.process === Process.Default)
|
||||
if (columnCallback && calculationProcess.noProcesses())
|
||||
debouncedCellCallback(
|
||||
columnCallback,
|
||||
calculationStore,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { elementsValues } from 'client/Containers/Calculation/lib/elements/values';
|
||||
import { getValueName } from 'client/Containers/Calculation/lib/elements/tools';
|
||||
import initialFilters from 'client/stores/CalculationStore/config/initialFilters';
|
||||
import initialOptions from 'client/stores/CalculationStore/config/initialOptions';
|
||||
import initialStatuses from 'client/stores/CalculationStore/config/initialStatuses';
|
||||
@ -72,7 +72,7 @@ const valuesActions = {
|
||||
});
|
||||
},
|
||||
getCurrentOption(elementName) {
|
||||
const valueName = elementsValues[elementName];
|
||||
const valueName = getValueName(elementName);
|
||||
const currentValue = this.values[valueName];
|
||||
if (!currentValue) {
|
||||
return;
|
||||
@ -98,7 +98,7 @@ const valuesActions = {
|
||||
return this.filters[elementName];
|
||||
},
|
||||
setFilter(elementName, filter) {
|
||||
const valueName = elementsValues[elementName];
|
||||
const valueName = getValueName(elementName);
|
||||
const value = this.getValue(valueName);
|
||||
if (
|
||||
filter &&
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
import { elementsValues } from 'client/Containers/Calculation/lib/elements/values';
|
||||
import { getValueName } from 'client/Containers/Calculation/lib/elements/tools';
|
||||
import { ICalculationStore } from 'core/types/Calculation/Store';
|
||||
import { TElements } from 'core/types/Calculation/Store/elements';
|
||||
import {
|
||||
ElementsNames,
|
||||
TElements,
|
||||
} from 'core/types/Calculation/Store/elements';
|
||||
|
||||
const CONDITIONS = {
|
||||
IS_NULL: value => value === undefined || value === null,
|
||||
@ -90,8 +93,8 @@ const elementsValidations: TElements<any> = {
|
||||
};
|
||||
|
||||
export default function (this: ICalculationStore) {
|
||||
Object.keys(elementsValidations).forEach(elementName => {
|
||||
const valueName = elementsValues[elementName];
|
||||
(Object.keys(elementsValidations) as ElementsNames[]).forEach(elementName => {
|
||||
const valueName = getValueName(elementName);
|
||||
const value = this.getValue(valueName);
|
||||
const condition = elementsValidations[elementName];
|
||||
let conditionRes;
|
||||
|
||||
@ -0,0 +1,99 @@
|
||||
import { message } from 'antd';
|
||||
import { requiredFields as kaskoRequiredFields } from 'client/Components/Calculation/ELT/Content/Kasko/lib/validation';
|
||||
import { cancelRequests } from 'client/Components/Calculation/ELT/Content/lib/requests';
|
||||
import { resetIns } from 'client/Components/Calculation/ELT/Content/lib/resetIns';
|
||||
import { requiredFields as osagoRequiredFields } from 'client/Components/Calculation/ELT/Content/Osago/lib/validation';
|
||||
import { getValueName } from 'client/Containers/Calculation/lib/elements/tools';
|
||||
import { TCalculationProcess } from 'client/stores/CalculationStore/subStores/calculationProcess';
|
||||
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
||||
import { ElementsNames } from 'core/types/Calculation/Store/elements';
|
||||
import { ICalculationStore } from 'core/types/Calculation/Store/index';
|
||||
import { Process } from 'core/types/Calculation/Store/process';
|
||||
|
||||
const resetConf = [
|
||||
{
|
||||
insType: 'osago',
|
||||
requiredFields: osagoRequiredFields,
|
||||
tableRowNumber: 0,
|
||||
},
|
||||
{
|
||||
insType: 'kasko',
|
||||
requiredFields: [
|
||||
...kaskoRequiredFields,
|
||||
'tbxInsAgeDrivers',
|
||||
'tbxInsExpDrivers',
|
||||
],
|
||||
tableRowNumber: 1,
|
||||
},
|
||||
];
|
||||
|
||||
const RESET_MESSAGES = {
|
||||
kasko: 'Расчеты ЭЛТ по КАСКО сброшены',
|
||||
osago: 'Расчеты ЭЛТ по ОСАГО сброшены',
|
||||
};
|
||||
|
||||
const eltReactions: IReactionEffect[] = [
|
||||
...resetConf.map(
|
||||
({ insType, requiredFields }) => (
|
||||
calculationStore: ICalculationStore,
|
||||
calculationProcess: TCalculationProcess,
|
||||
) => ({
|
||||
expression: () => {
|
||||
return calculationStore.getValues(
|
||||
//@ts-ignore
|
||||
(requiredFields as ElementsNames[]).map(getValueName),
|
||||
);
|
||||
},
|
||||
effect: () => {
|
||||
cancelRequests(insType);
|
||||
if (
|
||||
calculationProcess.hasProcess(Process.ELT) ||
|
||||
calculationProcess.hasProcess(Process.LoadKp)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const { ELTStore } = calculationStore.stores;
|
||||
if (ELTStore[insType].isReseted() === true) {
|
||||
return;
|
||||
}
|
||||
message.warn({ content: RESET_MESSAGES[insType] });
|
||||
resetIns.call(calculationStore, insType);
|
||||
},
|
||||
}),
|
||||
),
|
||||
|
||||
...resetConf.map(
|
||||
({ insType, tableRowNumber }) => (
|
||||
calculationStore: ICalculationStore,
|
||||
calculationProcess: TCalculationProcess,
|
||||
) => ({
|
||||
expression: () => {
|
||||
return [
|
||||
...['insuranceCompany', 'insCost'].map(
|
||||
fieldName =>
|
||||
calculationStore.tables.tableInsurance.rows[tableRowNumber][
|
||||
fieldName
|
||||
].value,
|
||||
),
|
||||
];
|
||||
},
|
||||
effect: () => {
|
||||
cancelRequests(insType);
|
||||
if (
|
||||
calculationProcess.hasProcess(Process.ELT) ||
|
||||
calculationProcess.hasProcess(Process.LoadKp)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const { ELTStore } = calculationStore.stores;
|
||||
if (ELTStore[insType].isReseted() === true) {
|
||||
return;
|
||||
}
|
||||
message.warn({ content: RESET_MESSAGES[insType] });
|
||||
resetIns.call(calculationStore, insType);
|
||||
},
|
||||
}),
|
||||
),
|
||||
];
|
||||
|
||||
export default eltReactions;
|
||||
@ -1,21 +1,24 @@
|
||||
import { elementsValues } from 'client/Containers/Calculation/lib/elements/values';
|
||||
import { getValueName } from 'client/Containers/Calculation/lib/elements/tools';
|
||||
import { openNotification } from 'client/Elements/Notification';
|
||||
import _1CService from 'core/services/1CService';
|
||||
import { currentDate } from 'core/tools/date';
|
||||
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
||||
import { TElements } from 'core/types/Calculation/Store/elements';
|
||||
import {
|
||||
ElementsNames,
|
||||
TElements,
|
||||
} from 'core/types/Calculation/Store/elements';
|
||||
import { Process } from 'core/types/Calculation/Store/process';
|
||||
import { ElementStatus } from 'core/types/statuses';
|
||||
import { get } from 'lodash';
|
||||
|
||||
const v = {
|
||||
const v: TElements<any> = {
|
||||
tbxVehicleTaxInYear: { value: 0, validator: value => value === 0 },
|
||||
radioTypePTS: { value: null, validator: value => value === null },
|
||||
selectObjectRegionRegistration: {
|
||||
value: null,
|
||||
validator: value => value === null,
|
||||
},
|
||||
} as TElements<any>;
|
||||
};
|
||||
|
||||
const gibddReactions: IReactionEffect[] = [
|
||||
calculationStore => ({
|
||||
@ -41,8 +44,8 @@ const gibddReactions: IReactionEffect[] = [
|
||||
},
|
||||
}),
|
||||
|
||||
...Object.keys(v).map(elementName => {
|
||||
const valueName = elementsValues[elementName];
|
||||
...(Object.keys(v) as ElementsNames[]).map(elementName => {
|
||||
const valueName = getValueName(elementName);
|
||||
const value = v[elementName].value;
|
||||
const validator = v[elementName].validator;
|
||||
|
||||
@ -97,7 +100,7 @@ const gibddReactions: IReactionEffect[] = [
|
||||
]);
|
||||
},
|
||||
effect: ({ objectRegistration, objectCategoryTax }) => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
if (objectRegistration === 100000001) {
|
||||
@ -287,7 +290,7 @@ const gibddReactions: IReactionEffect[] = [
|
||||
leaseObjectYear,
|
||||
leaseObjectMotorPower,
|
||||
}) => {
|
||||
if (calculationProcess.process !== Process.Default) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import eltReactions from './eltReactions';
|
||||
import gibddReactions from './gibddReactions';
|
||||
import loadKpReaction from './loadKpReaction';
|
||||
import otherReactions from './otherReactions';
|
||||
@ -15,5 +16,6 @@ export default [
|
||||
...statusReactions,
|
||||
...recalcWoRevisionReactions,
|
||||
...gibddReactions,
|
||||
...eltReactions,
|
||||
loadKpReaction,
|
||||
];
|
||||
|
||||
@ -9,10 +9,11 @@ import { IGetCRMEntitiesResponse } from 'core/types/Calculation/Responses';
|
||||
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
||||
import { TElements } 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 { ElementStatus } from 'core/types/statuses';
|
||||
import NIL from 'uuid/dist/nil';
|
||||
import mapKPtoValues from './mapKpToValues';
|
||||
import { getKpPropName } from './mapKpToValues';
|
||||
import optionsQuery from './optionsQuery';
|
||||
import quoteQuery from './quoteQuery';
|
||||
|
||||
@ -57,6 +58,7 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
|
||||
leaseObjectCount,
|
||||
calcType,
|
||||
indAgent,
|
||||
INNForCalc,
|
||||
} = calculationStore.values;
|
||||
|
||||
calculationStore.setStatus('selectQuote', ElementStatus.Disabled);
|
||||
@ -75,14 +77,16 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
|
||||
if (!quote) {
|
||||
throw new Error('No quote!');
|
||||
}
|
||||
calculationProcess.setProcess(Process.LoadKp);
|
||||
calculationProcess.addProcess(Process.LoadKp);
|
||||
if (!Array.isArray(quote)) {
|
||||
const newValues = Object.assign(
|
||||
{},
|
||||
...Object.values(elementsValues).map(valueName => ({
|
||||
//@ts-ignore
|
||||
[valueName]: quote[mapKPtoValues[valueName]],
|
||||
})),
|
||||
...(Object.values(elementsValues) as ValuesNames[]).map(
|
||||
valueName => ({
|
||||
//@ts-ignore
|
||||
[valueName]: quote[getKpPropName(valueName)],
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
let regionRegistration = quote.evo_regionid,
|
||||
@ -297,6 +301,7 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
|
||||
indAgent,
|
||||
requirementTelematic,
|
||||
vehicleTaxInYear,
|
||||
INNForCalc,
|
||||
});
|
||||
|
||||
message.success({
|
||||
@ -316,7 +321,7 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
|
||||
calculationStore.setStatus('selectQuote', ElementStatus.Default);
|
||||
calculationStore.setStatus('btnCalculate', ElementStatus.Default);
|
||||
calculationStore.setStatus('btnCreateKP', ElementStatus.Default);
|
||||
calculationProcess.setProcess(Process.Default);
|
||||
calculationProcess.deleteProcess(Process.LoadKp);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { TValues } from 'core/types/Calculation/Store/values';
|
||||
import { TValues, ValuesNames } from 'core/types/Calculation/Store/values';
|
||||
// import { TCRMEntity } from 'core/types/Entities/crmEntities';
|
||||
|
||||
const mapKPtoValues: TValues<string> = {
|
||||
@ -94,4 +94,8 @@ const mapKPtoValues: TValues<string> = {
|
||||
typePTS: 'evo_pts_type',
|
||||
};
|
||||
|
||||
export function getKpPropName(valueName: ValuesNames) {
|
||||
return mapKPtoValues[valueName];
|
||||
}
|
||||
|
||||
export default mapKPtoValues;
|
||||
|
||||
@ -2,7 +2,7 @@ import { openNotification } from 'client/Elements/Notification';
|
||||
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
||||
import { Process } from 'core/types/Calculation/Store/process';
|
||||
import { ElementStatus } from 'core/types/statuses';
|
||||
import { intersection, round } from 'lodash';
|
||||
import { get, intersection, round } from 'lodash';
|
||||
|
||||
const reactionEffects: IReactionEffect[] = [
|
||||
// calculationStore => ({
|
||||
@ -189,7 +189,7 @@ const reactionEffects: IReactionEffect[] = [
|
||||
},
|
||||
);
|
||||
if (indAgentRewardCondition) {
|
||||
if (calculationProcess.process !== Process.LoadKp) {
|
||||
if (!calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
calculationStore.setValue(
|
||||
'indAgentRewardSumm',
|
||||
indAgentRewardCondition.evo_reward_summ || 0,
|
||||
@ -258,7 +258,7 @@ const reactionEffects: IReactionEffect[] = [
|
||||
calcDoubleAgentRewardCondition &&
|
||||
calcDoubleAgentRewardCondition.evo_reward_summ
|
||||
) {
|
||||
if (calculationProcess.process !== Process.LoadKp) {
|
||||
if (!calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
calculationStore.setValue(
|
||||
'calcDoubleAgentRewardSumm',
|
||||
calcDoubleAgentRewardCondition.evo_reward_summ,
|
||||
@ -300,7 +300,7 @@ const reactionEffects: IReactionEffect[] = [
|
||||
calcBrokerRewardCondition &&
|
||||
calcBrokerRewardCondition.evo_reward_summ
|
||||
) {
|
||||
if (calculationProcess.process !== Process.LoadKp) {
|
||||
if (!calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
calculationStore.setValue(
|
||||
'calcBrokerRewardSum',
|
||||
calcBrokerRewardCondition.evo_reward_summ,
|
||||
@ -339,7 +339,7 @@ const reactionEffects: IReactionEffect[] = [
|
||||
finDepartmentRewardCondtion &&
|
||||
finDepartmentRewardCondtion.evo_reward_summ
|
||||
) {
|
||||
if (calculationProcess.process !== Process.LoadKp) {
|
||||
if (!calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
calculationStore.setValue(
|
||||
'finDepartmentRewardSumm',
|
||||
finDepartmentRewardCondtion.evo_reward_summ,
|
||||
@ -729,7 +729,7 @@ const reactionEffects: IReactionEffect[] = [
|
||||
},
|
||||
effect: graphType => {
|
||||
if (graphType) {
|
||||
if (calculationProcess.process === Process.Default) {
|
||||
if (!calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
calculationStore.setValue('seasonType', null);
|
||||
calculationStore.setValue('highSeasonStart', null);
|
||||
calculationStore.setValue('parmentsDecreasePercent', 96);
|
||||
@ -946,7 +946,7 @@ const reactionEffects: IReactionEffect[] = [
|
||||
);
|
||||
if (dealerRewardContition) {
|
||||
if (dealerRewardContition.evo_reward_summ) {
|
||||
if (calculationProcess.process !== Process.LoadKp) {
|
||||
if (!calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
calculationStore.setValue(
|
||||
'dealerRewardSumm',
|
||||
dealerRewardContition.evo_reward_summ,
|
||||
@ -1004,7 +1004,7 @@ const reactionEffects: IReactionEffect[] = [
|
||||
dealerBrokerRewardContition &&
|
||||
dealerBrokerRewardContition.evo_reward_summ
|
||||
) {
|
||||
if (calculationProcess.process !== Process.LoadKp) {
|
||||
if (!calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
calculationStore.setValue(
|
||||
'dealerBrokerRewardSumm',
|
||||
dealerBrokerRewardContition.evo_reward_summ,
|
||||
@ -1394,7 +1394,7 @@ const reactionEffects: IReactionEffect[] = [
|
||||
return tarif;
|
||||
},
|
||||
effect: tarif_evo_id => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1439,7 +1439,7 @@ const reactionEffects: IReactionEffect[] = [
|
||||
return { leaseObjectType };
|
||||
},
|
||||
effect: () => {
|
||||
if (calculationProcess.process !== Process.Default) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
calculationStore.setValue('technicalCard', null);
|
||||
@ -1452,7 +1452,7 @@ const reactionEffects: IReactionEffect[] = [
|
||||
return leasingPeriod;
|
||||
},
|
||||
effect: () => {
|
||||
if (calculationProcess.process !== Process.Default) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1718,6 +1718,19 @@ const reactionEffects: IReactionEffect[] = [
|
||||
);
|
||||
},
|
||||
}),
|
||||
|
||||
calculationStore => ({
|
||||
expression: () => {
|
||||
return {
|
||||
lead: calculationStore.getOption('selectLead'),
|
||||
opportnity: calculationStore.getOption('selectOpportunity'),
|
||||
};
|
||||
},
|
||||
effect: ({ lead, opportunity }) => {
|
||||
const inn = get(lead, 'evo_inn', '');
|
||||
calculationStore.setValue('INNForCalc', inn);
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
export default reactionEffects;
|
||||
|
||||
@ -11,7 +11,7 @@ export default [
|
||||
return [leaseObjectPrice, supplierDiscountRub];
|
||||
},
|
||||
effect: ([leaseObjectPrice, supplierDiscountRub = 0]) => {
|
||||
if (calculationProcess.process !== Process.Default) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
calculationStore.setValue(
|
||||
@ -33,7 +33,7 @@ export default [
|
||||
return [leaseObjectPrice, supplierDiscountPerc];
|
||||
},
|
||||
effect: ([leaseObjectPrice = 0, supplierDiscountPerc = 0]) => {
|
||||
if (calculationProcess.process !== Process.Default) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
calculationStore.setValue(
|
||||
@ -52,7 +52,7 @@ export default [
|
||||
return firstPaymentRub;
|
||||
},
|
||||
effect: (firstPaymentRub = 0) => {
|
||||
if (calculationProcess.process !== Process.Default) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
const { supplierCurrency, leaseObjectPrice } = calculationStore.values;
|
||||
@ -110,7 +110,7 @@ export default [
|
||||
return [supplierCurrency, leaseObjectPrice, comissionPerc];
|
||||
},
|
||||
effect: ([supplierCurrencyId, leaseObjectPrice = 0, comissionPerc = 0]) => {
|
||||
if (calculationProcess.process !== Process.Default) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
const rub = calculateRub(calculationStore)(
|
||||
@ -131,7 +131,7 @@ export default [
|
||||
return comissionRub;
|
||||
},
|
||||
effect: comissionRub => {
|
||||
if (calculationProcess.process !== Process.Default) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
const { supplierCurrency, leaseObjectPrice } = calculationStore.values;
|
||||
@ -174,7 +174,7 @@ export default [
|
||||
]) => {
|
||||
if (
|
||||
lastPaymentRule !== 100000001 ||
|
||||
calculationProcess.process !== Process.Default
|
||||
calculationProcess.hasProcess(Process.LoadKp)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
@ -213,7 +213,7 @@ export default [
|
||||
]) => {
|
||||
if (
|
||||
lastPaymentRule !== 100000000 ||
|
||||
calculationProcess.process !== Process.Default
|
||||
calculationProcess.hasProcess(Process.LoadKp)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ export default [
|
||||
return values.lead;
|
||||
},
|
||||
effect: async leadid => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
if (!leadid) {
|
||||
@ -220,7 +220,7 @@ export default [
|
||||
return { leadid: lead, opportunityid: opportunity };
|
||||
},
|
||||
effect: ({ leadid, opportunityid }) => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
if (opportunityid) {
|
||||
@ -295,7 +295,7 @@ export default [
|
||||
return account;
|
||||
},
|
||||
effect: account => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
if (account && account.length > 0) {
|
||||
@ -326,7 +326,7 @@ export default [
|
||||
ElementStatus.Default,
|
||||
);
|
||||
|
||||
if (indAgentId && calculationProcess.process === Process.Default)
|
||||
if (indAgentId && !calculationProcess.hasProcess(Process.LoadKp))
|
||||
CrmService.crmgqlquery({
|
||||
query: gql`
|
||||
query(
|
||||
@ -387,7 +387,7 @@ export default [
|
||||
ElementStatus.Default,
|
||||
);
|
||||
|
||||
if (doubleAgentId && calculationProcess.process === Process.Default)
|
||||
if (doubleAgentId && !calculationProcess.hasProcess(Process.LoadKp))
|
||||
CrmService.crmgqlquery({
|
||||
query: gql`
|
||||
query(
|
||||
@ -434,7 +434,7 @@ export default [
|
||||
return calcFinDepartment;
|
||||
},
|
||||
effect: calcFinDepartmentId => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
if (!calcFinDepartmentId) {
|
||||
@ -509,7 +509,7 @@ export default [
|
||||
ElementStatus.Default,
|
||||
);
|
||||
|
||||
if (calcBrokerId && calculationProcess.process === Process.Default)
|
||||
if (calcBrokerId && !calculationProcess.hasProcess(Process.LoadKp))
|
||||
CrmService.crmgqlquery({
|
||||
query: gql`
|
||||
query(
|
||||
@ -556,7 +556,7 @@ export default [
|
||||
return dealer;
|
||||
},
|
||||
effect: dealerId => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
if (dealerId) {
|
||||
@ -622,7 +622,7 @@ export default [
|
||||
return dealerPerson;
|
||||
},
|
||||
effect: dealerPersonId => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
calculationStore.setOptions('selectDealerBroker', []);
|
||||
@ -685,7 +685,7 @@ export default [
|
||||
ElementStatus.Default,
|
||||
);
|
||||
|
||||
if (calculationProcess.process === Process.Default)
|
||||
if (!calculationProcess.hasProcess(Process.LoadKp))
|
||||
CrmService.crmgqlquery({
|
||||
query: gql`
|
||||
query(
|
||||
@ -744,7 +744,7 @@ export default [
|
||||
'selectDealerRewardCondition',
|
||||
ElementStatus.Default,
|
||||
);
|
||||
if (calculationProcess.process === Process.Default)
|
||||
if (!calculationProcess.hasProcess(Process.LoadKp))
|
||||
CrmService.crmgqlquery({
|
||||
query: gql`
|
||||
query(
|
||||
@ -797,7 +797,7 @@ export default [
|
||||
return brand;
|
||||
},
|
||||
effect: brandId => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -850,7 +850,7 @@ export default [
|
||||
return model;
|
||||
},
|
||||
effect: modelId => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
calculationStore.setStatus('selectConfiguration', ElementStatus.Disabled);
|
||||
@ -912,7 +912,7 @@ export default [
|
||||
return supplier;
|
||||
},
|
||||
effect: supplierId => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
calculationStore.setOptions('selectFinDepartment', []);
|
||||
@ -952,7 +952,7 @@ export default [
|
||||
},
|
||||
//TODO: add $ownerid: Uuid
|
||||
effect: ({ supplierId, channelId }) => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
calculationStore.setOptions('selectAgent', []);
|
||||
@ -1021,7 +1021,7 @@ export default [
|
||||
return GPSBrand;
|
||||
},
|
||||
effect: GPSBrandId => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
calculationStore.setStatus('selectGPSModel', ElementStatus.Disabled);
|
||||
@ -1080,7 +1080,7 @@ export default [
|
||||
return regionRegistration;
|
||||
},
|
||||
effect: regionRegistrationId => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
calculationStore.setStatus(
|
||||
@ -1108,6 +1108,7 @@ export default [
|
||||
evo_name
|
||||
evo_townid
|
||||
evo_fias_id
|
||||
evo_kladr_id
|
||||
}
|
||||
}
|
||||
`,
|
||||
|
||||
@ -32,7 +32,7 @@ export default [
|
||||
};
|
||||
},
|
||||
effect: ({ insuranceCompany, insTerm, insured }) => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
if (insTerm) {
|
||||
@ -87,7 +87,7 @@ export default [
|
||||
};
|
||||
},
|
||||
effect: ({ insTerm, leasingPeriod }) => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
@ -245,7 +245,7 @@ export default [
|
||||
};
|
||||
},
|
||||
effect: ({ kaskoRow, dgoRow, nsRow }) => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
@ -301,7 +301,7 @@ export default [
|
||||
};
|
||||
},
|
||||
effect: ({ kaskoRow }) => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
@ -356,7 +356,7 @@ export default [
|
||||
};
|
||||
},
|
||||
effect: ({ osagoRow }) => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
@ -434,7 +434,7 @@ export default [
|
||||
};
|
||||
},
|
||||
effect: async (nextParams, prevParams) => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -754,7 +754,7 @@ export default [
|
||||
return leaseObjectCategory;
|
||||
},
|
||||
effect: (nextLeaseObjectCategory, prevLeaseObjectCategory) => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
const nextIsTrailer = nextLeaseObjectCategory === 100000004;
|
||||
|
||||
@ -1,10 +1,5 @@
|
||||
import { IWhenEffect } from 'core/types/Calculation/Store/effect'; // @ts-nocheck
|
||||
import { pick } from 'lodash';
|
||||
|
||||
const mapInsType = {
|
||||
kasko: 100000000,
|
||||
osago: 100000001,
|
||||
};
|
||||
import { initIns } from 'client/Components/Calculation/ELT/Content/lib/resetIns';
|
||||
import { IWhenEffect } from 'core/types/Calculation/Store/effect';
|
||||
|
||||
const whenEffects: IWhenEffect[] = [
|
||||
calculationStore => ({
|
||||
@ -16,31 +11,8 @@ const whenEffects: IWhenEffect[] = [
|
||||
return insuranceCompanies !== undefined && insuranceCompanies.length > 0;
|
||||
},
|
||||
effect: () => {
|
||||
const insuranceCompanies = calculationStore.getTableOptions(
|
||||
'tableInsurance',
|
||||
'insuranceCompany',
|
||||
);
|
||||
if (insuranceCompanies === undefined) {
|
||||
return;
|
||||
}
|
||||
const { ELTStore } = calculationStore.stores;
|
||||
insuranceCompanies.forEach(company => {
|
||||
if (company.evo_id_elt) {
|
||||
const companyData = pick(
|
||||
company,
|
||||
['evo_id_elt', 'name', 'accountid'],
|
||||
'',
|
||||
);
|
||||
Object.keys(mapInsType).forEach(insType => {
|
||||
if (
|
||||
company &&
|
||||
company.evo_type_ins_policy &&
|
||||
company.evo_type_ins_policy.includes(mapInsType[insType])
|
||||
) {
|
||||
ELTStore[insType].list.push(companyData);
|
||||
}
|
||||
});
|
||||
}
|
||||
['osago', 'kasko'].forEach(insType => {
|
||||
initIns.call(calculationStore, insType);
|
||||
});
|
||||
},
|
||||
}),
|
||||
|
||||
@ -39,6 +39,7 @@ const initialStatuses: TElements<ElementStatus> = {
|
||||
tbxVehicleTaxInLeasingPeriod: ElementStatus.Disabled,
|
||||
selectObjectTypeTax: ElementStatus.Disabled,
|
||||
selectLeaseObjectCategory: ElementStatus.Disabled,
|
||||
tbxINNForCalc: ElementStatus.Disabled,
|
||||
};
|
||||
|
||||
export default initialStatuses;
|
||||
|
||||
@ -43,7 +43,6 @@ const initialValues: TValues<TValue> = {
|
||||
leaseObjectCategory: 100000001,
|
||||
leaseObjectMotorPower: 0,
|
||||
engineVolume: 0,
|
||||
leaseObjectUseFor: 100000000,
|
||||
dealerRewardSumm: 0,
|
||||
dealerBrokerRewardSumm: 0,
|
||||
indAgent: null,
|
||||
|
||||
@ -1,14 +1,22 @@
|
||||
import { ElementParam } from 'core/types/Calculation/Store';
|
||||
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 { ElementStatus } from 'core/types/statuses';
|
||||
import { makeAutoObservable } from 'mobx';
|
||||
|
||||
const calculationProcess = makeAutoObservable({
|
||||
process: Process.Default,
|
||||
setProcess(process) {
|
||||
this.process = process;
|
||||
processes: new Set(),
|
||||
addProcess(process) {
|
||||
this.processes.add(process);
|
||||
},
|
||||
deleteProcess(process) {
|
||||
this.processes.delete(process);
|
||||
},
|
||||
hasProcess(process) {
|
||||
return this.processes.has(process);
|
||||
},
|
||||
noProcesses() {
|
||||
return this.processes.size === 0;
|
||||
},
|
||||
|
||||
bypass: {
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
// @ts-nocheck
|
||||
import { initFields } from 'client/Components/Calculation/ELT/Content/lib/resetIns';
|
||||
import { makeAutoObservable } from 'mobx';
|
||||
|
||||
const ELTStore = makeAutoObservable(
|
||||
@ -6,8 +7,17 @@ const ELTStore = makeAutoObservable(
|
||||
{},
|
||||
...['osago', 'kasko'].map(x => ({
|
||||
[x]: {
|
||||
isReseted() {
|
||||
return this.list.every(
|
||||
x => Object.keys(x).length === initFields.length,
|
||||
);
|
||||
},
|
||||
reset(list) {
|
||||
this.selectedKey = undefined;
|
||||
this.list.replace(list);
|
||||
},
|
||||
list: [],
|
||||
selectedKey: '',
|
||||
selectedKey: undefined,
|
||||
setKey(key) {
|
||||
this.selectedKey = key;
|
||||
},
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import axios from 'axios';
|
||||
import { _1C_PROXY_URL } from 'core/constants/urls';
|
||||
import { wrapRequest } from 'core/tools/request';
|
||||
import { IGetTransTaxRequest } from 'core/types/Calculation/Requests';
|
||||
import { IGetTransTaxResponse } from 'core/types/Calculation/Responses';
|
||||
|
||||
@ -7,17 +8,10 @@ export default class {
|
||||
static getTransTax = (
|
||||
payload: IGetTransTaxRequest,
|
||||
): Promise<IGetTransTaxResponse> =>
|
||||
new Promise((resolve, reject) => {
|
||||
axios
|
||||
.post(
|
||||
String.prototype.concat(_1C_PROXY_URL, '/leasingTrial', '/transTax'),
|
||||
payload,
|
||||
)
|
||||
.then(res => {
|
||||
resolve(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
wrapRequest(
|
||||
axios.post(
|
||||
String.prototype.concat(_1C_PROXY_URL, '/leasingTrial', '/transTax'),
|
||||
payload,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,23 +1,16 @@
|
||||
import axios from 'axios';
|
||||
import { ELT_PROXY_URL } from 'core/constants/urls';
|
||||
import { wrapRequest } from 'core/tools/request';
|
||||
|
||||
export default class {
|
||||
static getCalculation = payload =>
|
||||
new Promise((resolve, reject) => {
|
||||
axios
|
||||
.post(
|
||||
String.prototype.concat(
|
||||
ELT_PROXY_URL,
|
||||
'/insurance',
|
||||
'/calculateKasko',
|
||||
),
|
||||
payload,
|
||||
)
|
||||
.then(res => {
|
||||
resolve(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
export default {
|
||||
getCalculation: (payload, cancelToken) =>
|
||||
wrapRequest(
|
||||
axios.post(
|
||||
String.prototype.concat(ELT_PROXY_URL, '/insurance', '/calculateKasko'),
|
||||
payload,
|
||||
{
|
||||
cancelToken,
|
||||
},
|
||||
),
|
||||
),
|
||||
};
|
||||
|
||||
@ -1,24 +1,14 @@
|
||||
import axios from 'axios';
|
||||
import { ELT_PROXY_URL } from 'core/constants/urls';
|
||||
import { wrapRequest } from 'core/tools/request';
|
||||
|
||||
export default class {
|
||||
static getCalculation = payload =>
|
||||
new Promise((resolve, reject) => {
|
||||
axios
|
||||
.post(
|
||||
String.prototype.concat(
|
||||
ELT_PROXY_URL,
|
||||
'/insurance',
|
||||
'/calculateOsago',
|
||||
),
|
||||
payload,
|
||||
)
|
||||
.then(res => {
|
||||
resolve(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
reject(err);
|
||||
throw err.response.data;
|
||||
});
|
||||
});
|
||||
}
|
||||
export default {
|
||||
getCalculation: (payload, cancelToken) =>
|
||||
wrapRequest(
|
||||
axios.post(
|
||||
String.prototype.concat(ELT_PROXY_URL, '/insurance', '/calculateOsago'),
|
||||
payload,
|
||||
{ cancelToken },
|
||||
),
|
||||
),
|
||||
};
|
||||
|
||||
@ -1,16 +1,8 @@
|
||||
import axios from 'axios';
|
||||
import { AUTH_PROXY_URL } from 'core/constants/urls';
|
||||
import { wrapRequest } from 'core/tools/request';
|
||||
|
||||
export default class {
|
||||
static fetchUser = () =>
|
||||
new Promise((resolve, reject) => {
|
||||
axios
|
||||
.get(String.prototype.concat(AUTH_PROXY_URL, '/user'))
|
||||
.then(res => {
|
||||
resolve(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
wrapRequest(axios.get(String.prototype.concat(AUTH_PROXY_URL, '/user')));
|
||||
}
|
||||
|
||||
9
src/core/tools/format.ts
Normal file
9
src/core/tools/format.ts
Normal file
@ -0,0 +1,9 @@
|
||||
export const formatMoney = (n = 0, currency = 'RUB') =>
|
||||
Intl.NumberFormat('ru', {
|
||||
style: 'currency',
|
||||
currency,
|
||||
}).format(n);
|
||||
|
||||
export const formatNumber = (n = 0.0, options: Intl.NumberFormatOptions) => {
|
||||
return Intl.NumberFormat('ru', options).format(n);
|
||||
};
|
||||
2
src/core/tools/func.js
Normal file
2
src/core/tools/func.js
Normal file
@ -0,0 +1,2 @@
|
||||
export const compose = (...functions) => args =>
|
||||
functions.reduce((arg, fn) => fn(arg), args);
|
||||
3
src/core/tools/num.js
Normal file
3
src/core/tools/num.js
Normal file
@ -0,0 +1,3 @@
|
||||
import { round as _round } from 'lodash';
|
||||
|
||||
export const round = (value, n) => _round(value, n || 2).toFixed(n || 2);
|
||||
10
src/core/tools/request.js
Normal file
10
src/core/tools/request.js
Normal file
@ -0,0 +1,10 @@
|
||||
export const wrapRequest = request =>
|
||||
new Promise((resolve, reject) => {
|
||||
request
|
||||
.then(res => {
|
||||
resolve(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
@ -1,3 +1,5 @@
|
||||
import { TableNames } from 'core/types/Calculation/Store/tables';
|
||||
|
||||
export type ElementsNames =
|
||||
| 'selectLead'
|
||||
| 'selectOpportunity'
|
||||
@ -89,7 +91,6 @@ export type ElementsNames =
|
||||
| 'radioInsKaskoType'
|
||||
| 'tbxInsKaskoPriceLeasePeriod'
|
||||
| 'cbxInsDecentral'
|
||||
| 'btnInsCalculation'
|
||||
| 'selectInsPeriod'
|
||||
| 'tbxInsFranchise'
|
||||
| 'cbxInsUnlimitDrivers'
|
||||
@ -171,7 +172,8 @@ export type AllElements =
|
||||
| ElementsNames
|
||||
| ResultElementsNames
|
||||
| LinkElementsNames
|
||||
| CustomComponents;
|
||||
| CustomComponents
|
||||
| TableNames;
|
||||
|
||||
export enum ElementType {
|
||||
Default,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
export enum Process {
|
||||
Default,
|
||||
LoadKp,
|
||||
RecalcWithoutRevision,
|
||||
ELT,
|
||||
}
|
||||
|
||||
@ -37,6 +37,7 @@ export interface ILead {
|
||||
evo_agent_accountid?: string;
|
||||
accountidData?: IAccount;
|
||||
owner_domainname?: string;
|
||||
evo_inn?: string;
|
||||
}
|
||||
|
||||
export interface IOpportunity {
|
||||
@ -208,12 +209,14 @@ export interface IEvoRegion {
|
||||
evo_businessunit_evolution?: boolean;
|
||||
evo_oktmo?: string;
|
||||
accounts?: IAccount[];
|
||||
evo_kladr_id?: string;
|
||||
}
|
||||
export interface IEvoTown {
|
||||
evo_name?: string;
|
||||
evo_townid?: string;
|
||||
statecode?: number;
|
||||
evo_fias_id?: string;
|
||||
evo_kladr_id?: string;
|
||||
}
|
||||
export interface IEvoContact {
|
||||
parentcustomerid?: string;
|
||||
|
||||
Reference in New Issue
Block a user