merge refactor/february-2022-pt.1
This commit is contained in:
parent
40594d377b
commit
1e1422f723
@ -1,3 +1,3 @@
|
|||||||
schema:
|
schema:
|
||||||
- ./src/core/graphql/schemas/crm.graphql
|
- ./src/core/services/CrmService/graphql/schema.graphql
|
||||||
documents: src/**/*.{graphql,js,ts,jsx,tsx}
|
documents: src/**/*.{graphql,js,ts,jsx,tsx}
|
||||||
|
|||||||
@ -3,8 +3,8 @@ module.exports = {
|
|||||||
service: {
|
service: {
|
||||||
name: 'crmgraphql',
|
name: 'crmgraphql',
|
||||||
url: 'http://localhost/crmgraphql/',
|
url: 'http://localhost/crmgraphql/',
|
||||||
// localSchemaFile: 'src/core/graphql/schemas/crm.graphql',
|
// localSchemaFile: 'src/core/services/CrmService/graphql/schema.graphql',
|
||||||
},
|
},
|
||||||
excludes: ['src/core/graphql/schemas/**/*.*'],
|
excludes: ['src/core/services/CrmService/graphql/schema.graphql'],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@ -26,8 +26,7 @@
|
|||||||
"rebass": "^4.0.7",
|
"rebass": "^4.0.7",
|
||||||
"styled-components": "^5.2.3",
|
"styled-components": "^5.2.3",
|
||||||
"typescript": "^4.5.4",
|
"typescript": "^4.5.4",
|
||||||
"use-debounce": "^6.0.1",
|
"use-debounce": "^6.0.1"
|
||||||
"validator": "^13.5.2"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@storybook/addon-actions": "^6.2.9",
|
"@storybook/addon-actions": "^6.2.9",
|
||||||
@ -61,7 +60,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"graphql:codegen": "apollo client:codegen --target typescript",
|
"graphql:codegen": "apollo client:codegen --target typescript",
|
||||||
"graphql:update-schema": "apollo client:download-schema src/core/graphql/schemas/crm.graphql",
|
"graphql:update-schema": "apollo client:download-schema src/core/services/CrmService/graphql/schema.graphql",
|
||||||
"test": "react-scripts test",
|
"test": "react-scripts test",
|
||||||
"eject": "react-scripts eject",
|
"eject": "react-scripts eject",
|
||||||
"start": "dotenv -e .env craco start",
|
"start": "dotenv -e .env craco start",
|
||||||
|
|||||||
@ -1,7 +0,0 @@
|
|||||||
import { lazy } from 'react';
|
|
||||||
|
|
||||||
const Content = lazy(() => import('./Content'));
|
|
||||||
|
|
||||||
const ELT = () => <Content />;
|
|
||||||
|
|
||||||
export default ELT;
|
|
||||||
@ -3,7 +3,7 @@ import Button from 'client/Elements/Button';
|
|||||||
import { openNotification } from 'client/Elements/Notification';
|
import { openNotification } from 'client/Elements/Notification';
|
||||||
import { useStores } from 'client/hooks/useStores';
|
import { useStores } from 'client/hooks/useStores';
|
||||||
import { Process } from 'core/types/Calculation/Store/process';
|
import { Process } from 'core/types/Calculation/Store/process';
|
||||||
import { ElementStatus } from 'core/types/statuses';
|
import { ElementStatus } from 'types/elements';
|
||||||
|
|
||||||
const BottomControls = ({ insType, onSelectRow, selectedKey }) => {
|
const BottomControls = ({ insType, onSelectRow, selectedKey }) => {
|
||||||
const { calculationStore } = useStores();
|
const { calculationStore } = useStores();
|
||||||
@ -3,8 +3,8 @@ import Button from 'client/Elements/Button';
|
|||||||
import { PrimaryText } from 'client/Elements/Text';
|
import { PrimaryText } from 'client/Elements/Text';
|
||||||
import { useStores } from 'client/hooks/useStores';
|
import { useStores } from 'client/hooks/useStores';
|
||||||
import { Flex } from 'client/UIKit/grid';
|
import { Flex } from 'client/UIKit/grid';
|
||||||
import { ElementStatus } from 'core/types/statuses';
|
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
import { ElementStatus } from 'types/elements';
|
||||||
import { resetIns } from '../../lib/resetIns';
|
import { resetIns } from '../../lib/resetIns';
|
||||||
import validate from '../../lib/validation';
|
import validate from '../../lib/validation';
|
||||||
|
|
||||||
@ -1,5 +1,5 @@
|
|||||||
import InsTable from '../InsTable';
|
|
||||||
import tableConfig from '../lib/config/table';
|
import tableConfig from '../lib/config/table';
|
||||||
|
import InsTable from './index';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'Components/Calculation/ELT/Kasko',
|
title: 'Components/Calculation/ELT/Kasko',
|
||||||
@ -1,6 +1,6 @@
|
|||||||
import { InsTableColumn } from 'client/Components/Calculation/ELT/Content/lib/config/table';
|
|
||||||
import { Outlined } from 'client/Components/Spinner';
|
import { Outlined } from 'client/Components/Spinner';
|
||||||
import { formatMoney } from 'core/tools/format';
|
import { formatMoney } from 'core/tools/format';
|
||||||
|
import { InsTableColumn } from '../../../lib/config/table';
|
||||||
|
|
||||||
const columns: InsTableColumn[] = [
|
const columns: InsTableColumn[] = [
|
||||||
{
|
{
|
||||||
@ -1,7 +1,4 @@
|
|||||||
import {
|
import { ElementsNames } from 'client/Containers/Calculation/types/elements';
|
||||||
ElementsNames,
|
|
||||||
TElements,
|
|
||||||
} from 'core/types/Calculation/Store/elements';
|
|
||||||
import { ValidationCondition } from 'core/validation/validate';
|
import { ValidationCondition } from 'core/validation/validate';
|
||||||
|
|
||||||
export const requiredFields: ElementsNames[] = [
|
export const requiredFields: ElementsNames[] = [
|
||||||
@ -19,7 +16,7 @@ export const requiredFields: ElementsNames[] = [
|
|||||||
'radioInfuranceOPF',
|
'radioInfuranceOPF',
|
||||||
];
|
];
|
||||||
|
|
||||||
export const conditions: TElements<ValidationCondition> = {
|
export const conditions: Partial<Record<ElementsNames, ValidationCondition>> = {
|
||||||
selectLeaseObjectType: calculationStore => {
|
selectLeaseObjectType: calculationStore => {
|
||||||
const leaseObjectType = calculationStore.getOption('selectLeaseObjectType');
|
const leaseObjectType = calculationStore.getOption('selectLeaseObjectType');
|
||||||
if (leaseObjectType?.evo_id && ['11'].includes(leaseObjectType?.evo_id)) {
|
if (leaseObjectType?.evo_id && ['11'].includes(leaseObjectType?.evo_id)) {
|
||||||
@ -1,6 +1,6 @@
|
|||||||
|
import { IAccount } from 'core/services/CrmService/types/entities';
|
||||||
import { currentDate } from 'core/tools/date';
|
import { currentDate } from 'core/tools/date';
|
||||||
import { ICalculationStore } from 'core/types/Calculation/Store';
|
import { ICalculationStore } from 'core/types/Calculation/Store';
|
||||||
import { IAccount } from 'core/types/Entities/crmEntities';
|
|
||||||
import { get, isNull } from 'lodash';
|
import { get, isNull } from 'lodash';
|
||||||
|
|
||||||
const mapCategory = {
|
const mapCategory = {
|
||||||
@ -1,6 +1,6 @@
|
|||||||
import { InsTableColumn } from 'client/Components/Calculation/ELT/Content/lib/config/table';
|
|
||||||
import { Outlined } from 'client/Components/Spinner';
|
import { Outlined } from 'client/Components/Spinner';
|
||||||
import { formatMoney } from 'core/tools/format';
|
import { formatMoney } from 'core/tools/format';
|
||||||
|
import { InsTableColumn } from '../../../lib/config/table';
|
||||||
|
|
||||||
const columns: InsTableColumn[] = [
|
const columns: InsTableColumn[] = [
|
||||||
{
|
{
|
||||||
@ -1,7 +1,4 @@
|
|||||||
import {
|
import { ElementsNames } from 'client/Containers/Calculation/types/elements';
|
||||||
ElementsNames,
|
|
||||||
TElements,
|
|
||||||
} from 'core/types/Calculation/Store/elements';
|
|
||||||
import { ValidationCondition } from 'core/validation/validate';
|
import { ValidationCondition } from 'core/validation/validate';
|
||||||
import { omit } from 'lodash';
|
import { omit } from 'lodash';
|
||||||
import { conditions as kaskoConditions } from '../../Kasko/lib/validation';
|
import { conditions as kaskoConditions } from '../../Kasko/lib/validation';
|
||||||
@ -22,7 +19,7 @@ export const requiredFields: ElementsNames[] = [
|
|||||||
'radioInfuranceOPF',
|
'radioInfuranceOPF',
|
||||||
];
|
];
|
||||||
|
|
||||||
const osagoConditions: TElements<ValidationCondition> = {
|
const osagoConditions: Partial<Record<ElementsNames, ValidationCondition>> = {
|
||||||
selectTownRegistration: calculationStore => {
|
selectTownRegistration: calculationStore => {
|
||||||
const objectRegistration = calculationStore.getValue('objectRegistration');
|
const objectRegistration = calculationStore.getValue('objectRegistration');
|
||||||
if (objectRegistration === 100000001) {
|
if (objectRegistration === 100000001) {
|
||||||
@ -1,7 +1,7 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import { IAccount } from 'core/services/CrmService/types/entities';
|
||||||
import ELTService from 'core/services/ELTService';
|
import ELTService from 'core/services/ELTService';
|
||||||
import { ICalculationStore } from 'core/types/Calculation/Store';
|
import { ICalculationStore } from 'core/types/Calculation/Store';
|
||||||
import { IAccount } from 'core/types/Entities/crmEntities';
|
|
||||||
import { toJS } from 'mobx';
|
import { toJS } from 'mobx';
|
||||||
import { map_evo_id_elt_FieldName } from '../lib/resetIns';
|
import { map_evo_id_elt_FieldName } from '../lib/resetIns';
|
||||||
|
|
||||||
@ -1,5 +1,5 @@
|
|||||||
|
import { CRMEntity } from 'core/services/CrmService/types/entities';
|
||||||
import { ICalculationStore } from 'core/types/Calculation/Store';
|
import { ICalculationStore } from 'core/types/Calculation/Store';
|
||||||
import { TCRMEntity } from 'core/types/Entities/crmEntities';
|
|
||||||
import { pick } from 'lodash';
|
import { pick } from 'lodash';
|
||||||
import { sources } from './requests';
|
import { sources } from './requests';
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ export function initIns(this: ICalculationStore, insType) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { ELTStore } = this.stores;
|
const { ELTStore } = this.stores;
|
||||||
const list: TCRMEntity[] = [];
|
const list: CRMEntity[] = [];
|
||||||
const evo_id_elt_fieldName = map_evo_id_elt_FieldName[insType](this);
|
const evo_id_elt_fieldName = map_evo_id_elt_FieldName[insType](this);
|
||||||
insuranceCompanies.forEach(company => {
|
insuranceCompanies.forEach(company => {
|
||||||
if (
|
if (
|
||||||
@ -60,7 +60,7 @@ export function resetIns(this: ICalculationStore, insType) {
|
|||||||
|
|
||||||
const { ELTStore } = this.stores;
|
const { ELTStore } = this.stores;
|
||||||
|
|
||||||
const list: TCRMEntity[] = [];
|
const list: CRMEntity[] = [];
|
||||||
ELTStore[insType].list.forEach(x => {
|
ELTStore[insType].list.forEach(x => {
|
||||||
const picked = pick(x, initFields, '');
|
const picked = pick(x, initFields, '');
|
||||||
list.push(picked);
|
list.push(picked);
|
||||||
@ -1,30 +1,27 @@
|
|||||||
import { getTitle } from 'client/Containers/Calculation/lib/elements/tools';
|
import { getTitle } from 'client/Containers/Calculation/Elements/tools';
|
||||||
|
import { ElementsNames } from 'client/Containers/Calculation/types/elements';
|
||||||
import { openNotification } from 'client/Elements/Notification';
|
import { openNotification } from 'client/Elements/Notification';
|
||||||
import { pipe } from 'core/tools/func';
|
import { pipe } from 'core/tools/func';
|
||||||
import { ICalculationStore } from 'core/types/Calculation/Store';
|
import { ICalculationStore } from 'core/types/Calculation/Store';
|
||||||
import {
|
|
||||||
ElementsNames,
|
|
||||||
TElements,
|
|
||||||
} from 'core/types/Calculation/Store/elements';
|
|
||||||
import CONDITIONS from 'core/validation/conditions';
|
import CONDITIONS from 'core/validation/conditions';
|
||||||
import {
|
import {
|
||||||
convertToValidationResult,
|
convertToValidationResult,
|
||||||
getValue,
|
getValue,
|
||||||
showValidationMessages,
|
showValidationMessages,
|
||||||
validate,
|
validate,
|
||||||
ValidationCondition,
|
ValidationCondition
|
||||||
} from 'core/validation/validate';
|
} from 'core/validation/validate';
|
||||||
|
|
||||||
type ELTValidation = {
|
type ELTValidation = {
|
||||||
requiredFields: ElementsNames[];
|
requiredFields: ElementsNames[];
|
||||||
conditions?: TElements<ValidationCondition>;
|
conditions?: Partial<Record<ElementsNames, ValidationCondition>>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function (this: ICalculationStore, validation: ELTValidation) {
|
export default function (this: ICalculationStore, validation: ELTValidation) {
|
||||||
const { requiredFields, conditions: customConditions } = validation;
|
const { requiredFields, conditions: customConditions } = validation;
|
||||||
|
|
||||||
const requiredFieldsConditions = requiredFields.reduce(
|
const requiredFieldsConditions = requiredFields.reduce(
|
||||||
(ac: TElements<ValidationCondition>, elementName) => {
|
(ac: Partial<Record<ElementsNames, ValidationCondition>>, elementName) => {
|
||||||
ac[elementName] = pipe(
|
ac[elementName] = pipe(
|
||||||
getValue,
|
getValue,
|
||||||
CONDITIONS.IS_NULL,
|
CONDITIONS.IS_NULL,
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import { IGroup } from 'core/types/Calculation/components';
|
import { IGroup } from '../../types/common';
|
||||||
|
|
||||||
export const controlsList: IGroup[] = [
|
export const controlsList: IGroup[] = [
|
||||||
{
|
{
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import { ISection } from 'core/types/Calculation/components';
|
import { ISection } from '../../types/common';
|
||||||
|
|
||||||
export const calculationResults: ISection[] = [
|
export const calculationResults: ISection[] = [
|
||||||
{
|
{
|
||||||
@ -1,5 +1,5 @@
|
|||||||
import Background from 'client/Elements/Background';
|
import Background from 'client/Elements/Background';
|
||||||
import { renderSections } from '../lib/renderSections';
|
import { renderSections } from '../../lib/renderSections';
|
||||||
import sectionsList from './sectionsList';
|
import sectionsList from './sectionsList';
|
||||||
|
|
||||||
const Sections = props => (
|
const Sections = props => (
|
||||||
@ -1,60 +1,6 @@
|
|||||||
import { ISection } from 'core/types/Calculation/components';
|
import { ISection } from '../../types/common';
|
||||||
|
|
||||||
const sections: ISection[] = [
|
const sections: ISection[] = [
|
||||||
// {
|
|
||||||
// title: 'Интерес/ЛС',
|
|
||||||
// groups: [
|
|
||||||
// {
|
|
||||||
// title: 'Создание нового интереса в CRM',
|
|
||||||
// style: { columnsNumber: 3 },
|
|
||||||
// blocks: [
|
|
||||||
// {
|
|
||||||
// elements: [
|
|
||||||
// 'selectChannel',
|
|
||||||
// 'tbxNewClient',
|
|
||||||
// 'selectAccount',
|
|
||||||
// 'tbxINN',
|
|
||||||
// 'tbxKPP',
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// elements: [
|
|
||||||
// 'selectContactClient',
|
|
||||||
// 'tbxContact',
|
|
||||||
// 'radioContactGender',
|
|
||||||
// 'tbxPhoneNumber',
|
|
||||||
// 'tbxEmailAddress',
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// elements: [
|
|
||||||
// 'selectSupplier',
|
|
||||||
// 'selectFinDepartment',
|
|
||||||
// 'selectBroker',
|
|
||||||
// 'selectAgent',
|
|
||||||
// 'selectDoubleAgent',
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// style: { columnsNumber: 1 },
|
|
||||||
// blocks: [
|
|
||||||
// {
|
|
||||||
// elements: ['tbxCommentLead'],
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// style: { columnsNumber: 1 },
|
|
||||||
// blocks: [
|
|
||||||
// {
|
|
||||||
// elements: ['btnCreateLead'],
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
{
|
{
|
||||||
title: 'Лизинг',
|
title: 'Лизинг',
|
||||||
groups: [
|
groups: [
|
||||||
@ -305,7 +251,6 @@ const sections: ISection[] = [
|
|||||||
'selectGPSModel',
|
'selectGPSModel',
|
||||||
'tbxInsKaskoPriceLeasePeriod',
|
'tbxInsKaskoPriceLeasePeriod',
|
||||||
'cbxWithTrailer',
|
'cbxWithTrailer',
|
||||||
// 'btnDriversApplication',
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -402,11 +347,6 @@ const sections: ISection[] = [
|
|||||||
blocks: [
|
blocks: [
|
||||||
{
|
{
|
||||||
style: { columnsNumber: 2 },
|
style: { columnsNumber: 2 },
|
||||||
elementStyle: {
|
|
||||||
head: {
|
|
||||||
whiteSpace: 'normal',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
elements: [
|
elements: [
|
||||||
// 'cbxLastPaymentRedemption',
|
// 'cbxLastPaymentRedemption',
|
||||||
'cbxPriceWithDiscount',
|
'cbxPriceWithDiscount',
|
||||||
@ -445,15 +385,6 @@ const sections: ISection[] = [
|
|||||||
// {
|
// {
|
||||||
// title: 'Без ограничений',
|
// title: 'Без ограничений',
|
||||||
// groups: [
|
// groups: [
|
||||||
// // {
|
|
||||||
// // blocks: [
|
|
||||||
// // {
|
|
||||||
// // elements: [
|
|
||||||
// // 'selectUserSession'
|
|
||||||
// // ],
|
|
||||||
// // },
|
|
||||||
// // ],
|
|
||||||
// // },
|
|
||||||
// {
|
// {
|
||||||
// blocks: [
|
// blocks: [
|
||||||
// {
|
// {
|
||||||
@ -1,11 +1,11 @@
|
|||||||
import { observer } from 'mobx-react-lite';
|
|
||||||
import { useStatus } from 'client/hooks/Calculation/useStatus';
|
|
||||||
import { useAction } from 'client/hooks/Calculation/useAction';
|
import { useAction } from 'client/hooks/Calculation/useAction';
|
||||||
|
import { useStatus } from 'client/hooks/Calculation/useStatus';
|
||||||
|
import { observer } from 'mobx-react-lite';
|
||||||
|
|
||||||
export default Button => ({ name, actionName, ...props }) =>
|
export default ({ name, valueName: actionName, Component, ...props }) =>
|
||||||
observer(() => {
|
observer(() => {
|
||||||
const { status } = useStatus(name);
|
const { status } = useStatus(name);
|
||||||
const { action } = useAction({ actionName });
|
const { action } = useAction({ actionName });
|
||||||
|
|
||||||
return <Button {...props} status={status} action={action} />;
|
return <Component {...props} status={status} action={action} />;
|
||||||
});
|
});
|
||||||
@ -1,13 +1,8 @@
|
|||||||
import { observer } from 'mobx-react-lite';
|
|
||||||
import { useComputedValue } from 'client/hooks/Calculation/useValue';
|
|
||||||
import { useStatus } from 'client/hooks/Calculation/useStatus';
|
import { useStatus } from 'client/hooks/Calculation/useStatus';
|
||||||
|
import { useComputedValue } from 'client/hooks/Calculation/useValue';
|
||||||
|
import { observer } from 'mobx-react-lite';
|
||||||
|
|
||||||
export default Component => ({
|
export default ({ name, valueName: computedValueName, Component, ...props }) =>
|
||||||
name,
|
|
||||||
computedValueName,
|
|
||||||
validation,
|
|
||||||
...props
|
|
||||||
}) =>
|
|
||||||
observer(() => {
|
observer(() => {
|
||||||
const { value } = useComputedValue({
|
const { value } = useComputedValue({
|
||||||
computedValueName,
|
computedValueName,
|
||||||
@ -2,10 +2,10 @@ import { useStatus } from 'client/hooks/Calculation/useStatus';
|
|||||||
import { useUrl } from 'client/hooks/Calculation/useUrl';
|
import { useUrl } from 'client/hooks/Calculation/useUrl';
|
||||||
import { observer } from 'mobx-react-lite';
|
import { observer } from 'mobx-react-lite';
|
||||||
|
|
||||||
export default Button => ({ name, urlName, ...props }) =>
|
export default ({ name, valueName: urlName, Component, ...props }) =>
|
||||||
observer(() => {
|
observer(() => {
|
||||||
const { status } = useStatus(name);
|
const { status } = useStatus(name);
|
||||||
const { url } = useUrl({ urlName });
|
const { url } = useUrl({ urlName });
|
||||||
|
|
||||||
return <Button status={status} {...props} url={url} />;
|
return <Component status={status} {...props} url={url} />;
|
||||||
});
|
});
|
||||||
@ -0,0 +1,59 @@
|
|||||||
|
import { useTableOptions } from 'client/hooks/Calculation/useOptions';
|
||||||
|
import { useTableStatus } from 'client/hooks/Calculation/useStatus';
|
||||||
|
import { useTableValidation } from 'client/hooks/Calculation/useValidation';
|
||||||
|
import { useTableValue } from 'client/hooks/Calculation/useValue';
|
||||||
|
import { useStores } from 'client/hooks/useStores';
|
||||||
|
import { observer } from 'mobx-react-lite';
|
||||||
|
|
||||||
|
export default ({ Component: Table, ...props }) => {
|
||||||
|
const { name: tableName, callbacks } = props;
|
||||||
|
const ObservedTable = observer(Table);
|
||||||
|
const { calculationStore } = useStores();
|
||||||
|
const tableData = calculationStore.tables[tableName];
|
||||||
|
return () => (
|
||||||
|
<ObservedTable
|
||||||
|
{...props}
|
||||||
|
{...tableData}
|
||||||
|
withTableValue={withTableValue(callbacks)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const withTableValue =
|
||||||
|
callbacks =>
|
||||||
|
Component =>
|
||||||
|
({ tableName, rowIndex, propName, validation, ...props }) =>
|
||||||
|
observer(() => {
|
||||||
|
const { value, setCurrentValue } = useTableValue({
|
||||||
|
tableName,
|
||||||
|
rowIndex,
|
||||||
|
propName,
|
||||||
|
columnCallback: callbacks?.[propName],
|
||||||
|
});
|
||||||
|
const { status } = useTableStatus({ tableName, rowIndex, propName });
|
||||||
|
const { validateStatus, message } = useTableValidation({
|
||||||
|
tableName,
|
||||||
|
rowIndex,
|
||||||
|
propName,
|
||||||
|
validation,
|
||||||
|
});
|
||||||
|
|
||||||
|
const { options, filter } = useTableOptions({
|
||||||
|
tableName,
|
||||||
|
rowIndex,
|
||||||
|
propName,
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Component
|
||||||
|
{...props}
|
||||||
|
value={value}
|
||||||
|
setCurrentValue={setCurrentValue}
|
||||||
|
status={status}
|
||||||
|
validateStatus={validateStatus}
|
||||||
|
message={message}
|
||||||
|
options={options}
|
||||||
|
filter={filter}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
@ -1,10 +1,10 @@
|
|||||||
import { observer } from 'mobx-react-lite';
|
import { useOptions } from 'client/hooks/Calculation/useOptions';
|
||||||
import { useStoreValue } from 'client/hooks/Calculation/useValue';
|
|
||||||
import { useStatus } from 'client/hooks/Calculation/useStatus';
|
import { useStatus } from 'client/hooks/Calculation/useStatus';
|
||||||
import { useValidation } from 'client/hooks/Calculation/useValidation';
|
import { useValidation } from 'client/hooks/Calculation/useValidation';
|
||||||
import { useOptions } from 'client/hooks/Calculation/useOptions';
|
import { useStoreValue } from 'client/hooks/Calculation/useValue';
|
||||||
|
import { observer } from 'mobx-react-lite';
|
||||||
|
|
||||||
export default Component => ({ name, valueName, validation, ...props }) =>
|
export default ({ name, valueName, Component, ...props }) =>
|
||||||
observer(() => {
|
observer(() => {
|
||||||
const { value, setCurrentValue } = useStoreValue({
|
const { value, setCurrentValue } = useStoreValue({
|
||||||
valueName,
|
valueName,
|
||||||
@ -13,7 +13,6 @@ export default Component => ({ name, valueName, validation, ...props }) =>
|
|||||||
const { validateStatus, message } = useValidation({
|
const { validateStatus, message } = useValidation({
|
||||||
elementName: name,
|
elementName: name,
|
||||||
value,
|
value,
|
||||||
validation,
|
|
||||||
});
|
});
|
||||||
const { options } = useOptions(name);
|
const { options } = useOptions(name);
|
||||||
|
|
||||||
40
src/client/Containers/Calculation/Elements/builders/index.ts
Normal file
40
src/client/Containers/Calculation/Elements/builders/index.ts
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import ELT from '../../Components/ELT';
|
||||||
|
import { CustomComponents, NonValueElementsNames } from '../../types/elements';
|
||||||
|
import { TableNames } from '../../types/tables';
|
||||||
|
import components from '../components';
|
||||||
|
import tables from '../tables';
|
||||||
|
import buildAction from './buildAction';
|
||||||
|
import buildComputed from './buildComputed';
|
||||||
|
import buildLink from './buildLink';
|
||||||
|
import buildTable from './buildTable';
|
||||||
|
import buildValue from './buildValue';
|
||||||
|
|
||||||
|
const valueElementsBuilders = Object.keys(components).reduce(
|
||||||
|
(acc, elementName) => {
|
||||||
|
acc[elementName] = buildValue;
|
||||||
|
return acc;
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
);
|
||||||
|
|
||||||
|
const overrideBuilders: Record<
|
||||||
|
NonValueElementsNames | TableNames | CustomComponents,
|
||||||
|
any
|
||||||
|
> = {
|
||||||
|
labelLeaseObjectRisk: buildComputed,
|
||||||
|
tbxInsKaskoPriceLeasePeriod: buildComputed,
|
||||||
|
labelIrrInfo: buildComputed,
|
||||||
|
labelRegistrationDescription: buildComputed,
|
||||||
|
btnCreateKP: buildAction,
|
||||||
|
btnCalculate: buildAction,
|
||||||
|
linkDownloadKp: buildLink,
|
||||||
|
componentElt: () => ELT,
|
||||||
|
tablePayments: ({ name, Component }) =>
|
||||||
|
buildTable({ name, Component, ...tables[name] }),
|
||||||
|
tableInsurance: ({ name, Component }) =>
|
||||||
|
buildTable({ name, Component, ...tables[name] }),
|
||||||
|
tableResults: ({ name, Component }) =>
|
||||||
|
buildTable({ name, Component, ...tables[name] }),
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Object.assign(valueElementsBuilders, overrideBuilders);
|
||||||
@ -1,4 +1,3 @@
|
|||||||
import ELT from 'client/Components/Calculation/ELT';
|
|
||||||
import Button from 'client/Elements/Button';
|
import Button from 'client/Elements/Button';
|
||||||
import Checkbox from 'client/Elements/Checkbox';
|
import Checkbox from 'client/Elements/Checkbox';
|
||||||
import Input from 'client/Elements/Input';
|
import Input from 'client/Elements/Input';
|
||||||
@ -9,29 +8,11 @@ import Radio from 'client/Elements/Radio';
|
|||||||
import Select from 'client/Elements/Select';
|
import Select from 'client/Elements/Select';
|
||||||
import Switch from 'client/Elements/Switch';
|
import Switch from 'client/Elements/Switch';
|
||||||
import Table from 'client/Elements/Table';
|
import Table from 'client/Elements/Table';
|
||||||
import TextArea from 'client/Elements/TextArea';
|
import { FC } from 'react';
|
||||||
import { Component } from 'core/types/Calculation/components';
|
import { AllElementsNames } from '../types/elements';
|
||||||
import { TElements } from 'core/types/Calculation/Store/elements';
|
import { TableNames } from './../types/tables';
|
||||||
import { StoreTables } from 'core/types/Calculation/Store/tables';
|
|
||||||
|
|
||||||
const elementsComponents: TElements<Component> = {
|
export default {
|
||||||
selectChannel: Select,
|
|
||||||
tbxNewClient: Input,
|
|
||||||
selectAccount: Select,
|
|
||||||
tbxINN: Input,
|
|
||||||
tbxKPP: Input,
|
|
||||||
selectContactClient: Select,
|
|
||||||
tbxContact: Input,
|
|
||||||
radioContactGender: Radio,
|
|
||||||
tbxPhoneNumber: Input,
|
|
||||||
tbxEmailAddress: Input,
|
|
||||||
selectSupplier: Select,
|
|
||||||
selectFinDepartment: Select,
|
|
||||||
selectBroker: Select,
|
|
||||||
selectAgent: Select,
|
|
||||||
selectDoubleAgent: Select,
|
|
||||||
tbxCommentLead: TextArea,
|
|
||||||
btnCreateLead: Button,
|
|
||||||
selectProduct: Select,
|
selectProduct: Select,
|
||||||
selectClientRisk: Select,
|
selectClientRisk: Select,
|
||||||
selectClientType: Select,
|
selectClientType: Select,
|
||||||
@ -58,7 +39,6 @@ const elementsComponents: TElements<Component> = {
|
|||||||
selectBrand: Select,
|
selectBrand: Select,
|
||||||
selectModel: Select,
|
selectModel: Select,
|
||||||
selectConfiguration: Select,
|
selectConfiguration: Select,
|
||||||
labelLeaseObjectRisk: Label,
|
|
||||||
labelDepreciationGroup: Label,
|
labelDepreciationGroup: Label,
|
||||||
cbxLeaseObjectUsed: Checkbox,
|
cbxLeaseObjectUsed: Checkbox,
|
||||||
radioDeliveryTime: Radio,
|
radioDeliveryTime: Radio,
|
||||||
@ -95,19 +75,15 @@ const elementsComponents: TElements<Component> = {
|
|||||||
cbxInsDecentral: Switch,
|
cbxInsDecentral: Switch,
|
||||||
radioInsKaskoType: Radio,
|
radioInsKaskoType: Radio,
|
||||||
tbxInsFranchise: InputNumber,
|
tbxInsFranchise: InputNumber,
|
||||||
selectInsPeriod: Select,
|
|
||||||
btnFranschise: Button,
|
|
||||||
cbxInsUnlimitDrivers: Switch,
|
cbxInsUnlimitDrivers: Switch,
|
||||||
tbxInsAgeDrivers: InputNumber,
|
tbxInsAgeDrivers: InputNumber,
|
||||||
tbxInsExpDrivers: InputNumber,
|
tbxInsExpDrivers: InputNumber,
|
||||||
tbxINNForCalc: InputNumber,
|
tbxINNForCalc: InputNumber,
|
||||||
btnDriversApplication: Button,
|
|
||||||
selectGPSBrand: Select,
|
selectGPSBrand: Select,
|
||||||
selectGPSModel: Select,
|
selectGPSModel: Select,
|
||||||
selectRegionRegistration: Select,
|
selectRegionRegistration: Select,
|
||||||
selectTownRegistration: Select,
|
selectTownRegistration: Select,
|
||||||
radioInfuranceOPF: Radio,
|
radioInfuranceOPF: Radio,
|
||||||
tbxInsKaskoPriceLeasePeriod: InputNumber,
|
|
||||||
selectRegistration: Select,
|
selectRegistration: Select,
|
||||||
selectInsNSIB: Select,
|
selectInsNSIB: Select,
|
||||||
radioRequirementTelematic: Radio,
|
radioRequirementTelematic: Radio,
|
||||||
@ -125,8 +101,6 @@ const elementsComponents: TElements<Component> = {
|
|||||||
cbxQuoteRedemptionGraph: Switch,
|
cbxQuoteRedemptionGraph: Switch,
|
||||||
tbxQuoteName: Input,
|
tbxQuoteName: Input,
|
||||||
radioQuoteContactGender: Radio,
|
radioQuoteContactGender: Radio,
|
||||||
btnCreateKP: Button,
|
|
||||||
selectUserSession: Select,
|
|
||||||
cbxDisableChecks: Switch,
|
cbxDisableChecks: Switch,
|
||||||
selectTarif: Select,
|
selectTarif: Select,
|
||||||
tbxCreditRate: InputNumber,
|
tbxCreditRate: InputNumber,
|
||||||
@ -138,9 +112,31 @@ const elementsComponents: TElements<Component> = {
|
|||||||
selectOpportunity: Select,
|
selectOpportunity: Select,
|
||||||
selectQuote: Select,
|
selectQuote: Select,
|
||||||
cbxRecalcWithRevision: Checkbox,
|
cbxRecalcWithRevision: Checkbox,
|
||||||
btnCalculate: Button,
|
|
||||||
tbxIRR_Perc: InputNumber,
|
tbxIRR_Perc: InputNumber,
|
||||||
|
tbxMileage: InputNumber,
|
||||||
|
radioCalcType: Radio,
|
||||||
|
tbxTotalPayments: InputNumber,
|
||||||
|
radioObjectRegistration: Radio,
|
||||||
|
selectObjectRegionRegistration: Select,
|
||||||
|
tbxVehicleTaxInYear: InputNumber,
|
||||||
|
tbxVehicleTaxInLeasingPeriod: InputNumber,
|
||||||
|
selectObjectCategoryTax: Select,
|
||||||
|
selectObjectTypeTax: Select,
|
||||||
|
radioTypePTS: Radio,
|
||||||
|
selectLegalClientRegion: Select,
|
||||||
|
selectLegalClientTown: Select,
|
||||||
|
selectSubsidy: Select,
|
||||||
|
selectFuelCard: Select,
|
||||||
|
labelSubsidySum: Label,
|
||||||
|
tbxMinPriceChange: InputNumber,
|
||||||
|
|
||||||
|
/** Computed Elements */
|
||||||
|
labelLeaseObjectRisk: Label,
|
||||||
|
tbxInsKaskoPriceLeasePeriod: InputNumber,
|
||||||
labelIrrInfo: Label,
|
labelIrrInfo: Label,
|
||||||
|
labelRegistrationDescription: Label,
|
||||||
|
|
||||||
|
/** Result Elements */
|
||||||
labelResultTotalGraphwithNDS: Label,
|
labelResultTotalGraphwithNDS: Label,
|
||||||
labelResultPlPrice: Label,
|
labelResultPlPrice: Label,
|
||||||
labelResultPriceUpPr: Label,
|
labelResultPriceUpPr: Label,
|
||||||
@ -157,31 +153,16 @@ const elementsComponents: TElements<Component> = {
|
|||||||
labelResultBonusMPL: Label,
|
labelResultBonusMPL: Label,
|
||||||
labelResultDopMPLLeasing: Label,
|
labelResultDopMPLLeasing: Label,
|
||||||
labelResultBonusDopProd: Label,
|
labelResultBonusDopProd: Label,
|
||||||
|
|
||||||
|
/** Button Elements */
|
||||||
|
btnCreateKP: Button,
|
||||||
|
btnCalculate: Button,
|
||||||
|
|
||||||
|
/** Link Elements */
|
||||||
linkDownloadKp: Link,
|
linkDownloadKp: Link,
|
||||||
tbxMileage: InputNumber,
|
|
||||||
radioCalcType: Radio,
|
|
||||||
tbxTotalPayments: InputNumber,
|
|
||||||
componentElt: ELT,
|
|
||||||
radioObjectRegistration: Radio,
|
|
||||||
selectObjectRegionRegistration: Select,
|
|
||||||
tbxVehicleTaxInYear: InputNumber,
|
|
||||||
tbxVehicleTaxInLeasingPeriod: InputNumber,
|
|
||||||
selectObjectCategoryTax: Select,
|
|
||||||
selectObjectTypeTax: Select,
|
|
||||||
radioTypePTS: Radio,
|
|
||||||
labelRegistrationDescription: Label,
|
|
||||||
selectLegalClientRegion: Select,
|
|
||||||
selectLegalClientTown: Select,
|
|
||||||
selectSubsidy: Select,
|
|
||||||
selectFuelCard: Select,
|
|
||||||
labelSubsidySum: Label,
|
|
||||||
tbxMinPriceChange: InputNumber,
|
|
||||||
};
|
|
||||||
|
|
||||||
const tablesComponents: StoreTables<Component> = {
|
/** Table Elements */
|
||||||
tableInsurance: Table,
|
|
||||||
tablePayments: Table,
|
tablePayments: Table,
|
||||||
|
tableInsurance: Table,
|
||||||
tableResults: Table,
|
tableResults: Table,
|
||||||
};
|
} as Record<AllElementsNames | TableNames, FC<any>>;
|
||||||
|
|
||||||
export default Object.assign(elementsComponents, tablesComponents);
|
|
||||||
@ -1,82 +1,13 @@
|
|||||||
import DownloadOutlined from '@ant-design/icons/lib/icons/DownloadOutlined';
|
import DownloadOutlined from '@ant-design/icons/lib/icons/DownloadOutlined';
|
||||||
import InsuranceTag from 'client/Components/Calculation/InsuranceTag';
|
|
||||||
import Link from 'client/Elements/Link';
|
|
||||||
import buildTooltip from 'client/Elements/Tooltip';
|
|
||||||
import { withLink } from 'client/hocs/Calculation';
|
|
||||||
import { MAX_FRANCHISE } from 'core/constants/stores/Calculation/limits';
|
import { MAX_FRANCHISE } from 'core/constants/stores/Calculation/limits';
|
||||||
import { currentYear } from 'core/tools/date';
|
import { currentYear } from 'core/tools/date';
|
||||||
import { formatMoney, formatNumber } from 'core/tools/format';
|
import { formatMoney, formatNumber } from 'core/tools/format';
|
||||||
import { pipe } from 'core/tools/func';
|
import { pipe } from 'core/tools/func';
|
||||||
import { round } from 'core/tools/num';
|
import { round } from 'core/tools/num';
|
||||||
import {
|
import { ElementProps } from 'types/elements';
|
||||||
validateEmail,
|
import { AllElementsNames, ElementsNames } from '../../types/elements';
|
||||||
validateInn,
|
|
||||||
validateKpp,
|
|
||||||
validatePhone,
|
|
||||||
} from 'core/tools/validate';
|
|
||||||
import { ElementProps } from 'core/types/Calculation/components';
|
|
||||||
import { TElements } from 'core/types/Calculation/Store/elements';
|
|
||||||
|
|
||||||
const elementsProps: TElements<ElementProps> = {
|
const elementsProps: Partial<Record<AllElementsNames, ElementProps>> = {
|
||||||
selectChannel: {
|
|
||||||
showSearch: true,
|
|
||||||
},
|
|
||||||
selectAccount: {
|
|
||||||
showSearch: true,
|
|
||||||
},
|
|
||||||
tbxINN: {
|
|
||||||
validation: {
|
|
||||||
errorMessage: 'Некорректный ИНН',
|
|
||||||
validator: validateInn,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
tbxKPP: {
|
|
||||||
validation: {
|
|
||||||
errorMessage: 'Некорректный КПП',
|
|
||||||
validator: validateKpp,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
selectContactClient: {
|
|
||||||
showSearch: true,
|
|
||||||
},
|
|
||||||
radioContactGender: {
|
|
||||||
style: 'button',
|
|
||||||
},
|
|
||||||
tbxPhoneNumber: {
|
|
||||||
type: 'tel',
|
|
||||||
validation: {
|
|
||||||
errorMessage: 'Некорректный номер телефона',
|
|
||||||
validator: validatePhone,
|
|
||||||
},
|
|
||||||
//TODO: mask + 7(999) 999 99 99
|
|
||||||
},
|
|
||||||
tbxEmailAddress: {
|
|
||||||
type: 'email',
|
|
||||||
//TODO email mask
|
|
||||||
validation: {
|
|
||||||
errorMessage: 'Некорректный E-mail',
|
|
||||||
validator: validateEmail,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
selectSupplier: {
|
|
||||||
showSearch: true,
|
|
||||||
},
|
|
||||||
selectFinDepartment: {
|
|
||||||
showSearch: false,
|
|
||||||
},
|
|
||||||
selectBroker: {
|
|
||||||
showSearch: false,
|
|
||||||
},
|
|
||||||
selectAgent: {
|
|
||||||
showSearch: true,
|
|
||||||
},
|
|
||||||
selectDoubleAgent: {
|
|
||||||
showSearch: true,
|
|
||||||
},
|
|
||||||
btnCreateLead: {
|
|
||||||
type: 'primary',
|
|
||||||
text: 'Создать интерес',
|
|
||||||
},
|
|
||||||
tbxLeaseObjectPrice: {
|
tbxLeaseObjectPrice: {
|
||||||
min: '1000.00',
|
min: '1000.00',
|
||||||
max: '1000000000.00',
|
max: '1000000000.00',
|
||||||
@ -152,7 +83,6 @@ const elementsProps: TElements<ElementProps> = {
|
|||||||
min: '50',
|
min: '50',
|
||||||
max: '99',
|
max: '99',
|
||||||
},
|
},
|
||||||
selectSeasonType: {},
|
|
||||||
tbxComissionPerc: {
|
tbxComissionPerc: {
|
||||||
min: '0',
|
min: '0',
|
||||||
max: '100',
|
max: '100',
|
||||||
@ -278,10 +208,6 @@ const elementsProps: TElements<ElementProps> = {
|
|||||||
precision: 2,
|
precision: 2,
|
||||||
formatter: formatNumber,
|
formatter: formatNumber,
|
||||||
},
|
},
|
||||||
btnFranschise: {
|
|
||||||
type: 'ghost',
|
|
||||||
text: 'Заявление на франшизу',
|
|
||||||
},
|
|
||||||
tbxInsAgeDrivers: {
|
tbxInsAgeDrivers: {
|
||||||
min: '18',
|
min: '18',
|
||||||
max: '99',
|
max: '99',
|
||||||
@ -290,19 +216,12 @@ const elementsProps: TElements<ElementProps> = {
|
|||||||
min: '0',
|
min: '0',
|
||||||
max: '99',
|
max: '99',
|
||||||
},
|
},
|
||||||
btnDriversApplication: {
|
|
||||||
type: 'ghost',
|
|
||||||
text: 'Заявление на ограничения по водителям',
|
|
||||||
},
|
|
||||||
selectRegionRegistration: {
|
selectRegionRegistration: {
|
||||||
showSearch: true,
|
showSearch: true,
|
||||||
},
|
},
|
||||||
selectTownRegistration: {
|
selectTownRegistration: {
|
||||||
showSearch: true,
|
showSearch: true,
|
||||||
},
|
},
|
||||||
radioRequirementTelematic: {
|
|
||||||
// style: 'button',
|
|
||||||
},
|
|
||||||
radioQuoteContactGender: {
|
radioQuoteContactGender: {
|
||||||
style: 'button',
|
style: 'button',
|
||||||
},
|
},
|
||||||
@ -334,36 +253,12 @@ const elementsProps: TElements<ElementProps> = {
|
|||||||
},
|
},
|
||||||
selectLead: {
|
selectLead: {
|
||||||
showSearch: true,
|
showSearch: true,
|
||||||
sub: {
|
|
||||||
Component: withLink(Link)({
|
|
||||||
name: 'leadUrl',
|
|
||||||
text: 'Открыть в CRM',
|
|
||||||
urlName: 'leadUrl',
|
|
||||||
type: 'link',
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
selectOpportunity: {
|
selectOpportunity: {
|
||||||
showSearch: true,
|
showSearch: true,
|
||||||
sub: {
|
|
||||||
Component: withLink(Link)({
|
|
||||||
name: 'leadUrl',
|
|
||||||
text: 'Открыть в CRM',
|
|
||||||
urlName: 'opportunityUrl',
|
|
||||||
type: 'link',
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
selectQuote: {
|
selectQuote: {
|
||||||
showSearch: true,
|
showSearch: true,
|
||||||
sub: {
|
|
||||||
Component: withLink(Link)({
|
|
||||||
name: 'leadUrl',
|
|
||||||
text: 'Открыть в CRM',
|
|
||||||
urlName: 'quoteUrl',
|
|
||||||
type: 'link',
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
btnCalculate: {
|
btnCalculate: {
|
||||||
text: 'Рассчитать график',
|
text: 'Рассчитать график',
|
||||||
@ -402,9 +297,6 @@ const elementsProps: TElements<ElementProps> = {
|
|||||||
precision: 2,
|
precision: 2,
|
||||||
formatter: formatNumber,
|
formatter: formatNumber,
|
||||||
},
|
},
|
||||||
componentElt: {
|
|
||||||
title: 'Расчет страховки в ЭЛТ',
|
|
||||||
},
|
|
||||||
radioObjectRegistration: {
|
radioObjectRegistration: {
|
||||||
style: 'button',
|
style: 'button',
|
||||||
},
|
},
|
||||||
@ -416,12 +308,6 @@ const elementsProps: TElements<ElementProps> = {
|
|||||||
step: '100',
|
step: '100',
|
||||||
max: '9999999',
|
max: '9999999',
|
||||||
precision: 2,
|
precision: 2,
|
||||||
tooltip: {
|
|
||||||
Component: buildTooltip({
|
|
||||||
title: 'Без учета налога на роскошь',
|
|
||||||
placement: 'topLeft',
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
tbxVehicleTaxInLeasingPeriod: {
|
tbxVehicleTaxInLeasingPeriod: {
|
||||||
min: '0',
|
min: '0',
|
||||||
@ -432,21 +318,12 @@ const elementsProps: TElements<ElementProps> = {
|
|||||||
selectObjectRegionRegistration: {
|
selectObjectRegionRegistration: {
|
||||||
showSearch: true,
|
showSearch: true,
|
||||||
},
|
},
|
||||||
tbxINNForCalc: {
|
|
||||||
// validation: {
|
|
||||||
// errorMessage: 'Некорректный ИНН',
|
|
||||||
// validator: validateInn,
|
|
||||||
// },
|
|
||||||
},
|
|
||||||
tableInsurance: {
|
|
||||||
sub: {
|
|
||||||
Component: InsuranceTag,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
tbxInsKaskoPriceLeasePeriod: {
|
tbxInsKaskoPriceLeasePeriod: {
|
||||||
min: 0,
|
min: 0,
|
||||||
precision: 2,
|
precision: 2,
|
||||||
formatter: formatNumber,
|
formatter: formatNumber,
|
||||||
|
readOnly: true,
|
||||||
|
controls: false,
|
||||||
},
|
},
|
||||||
selectLegalClientRegion: {
|
selectLegalClientRegion: {
|
||||||
showSearch: true,
|
showSearch: true,
|
||||||
@ -457,31 +334,21 @@ const elementsProps: TElements<ElementProps> = {
|
|||||||
radioInfuranceOPF: {
|
radioInfuranceOPF: {
|
||||||
style: 'button',
|
style: 'button',
|
||||||
},
|
},
|
||||||
selectHighSeasonStart: {
|
|
||||||
tooltip: {
|
|
||||||
Component: buildTooltip({
|
|
||||||
title: 'С какого платежа начинается полный высокий сезон',
|
|
||||||
placement: 'topLeft',
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const numberElementsProps: TElements<ElementProps> = Object.keys(
|
export const numberElementsProps: Partial<Record<ElementsNames, ElementProps>> =
|
||||||
elementsProps,
|
Object.keys(elementsProps).reduce((acc, a) => {
|
||||||
).reduce((acc, a) => {
|
const min = elementsProps[a]?.min,
|
||||||
const min = elementsProps[a]?.min,
|
max = elementsProps[a]?.max;
|
||||||
max = elementsProps[a]?.max;
|
if (min || max)
|
||||||
if (min || max)
|
return {
|
||||||
return {
|
...acc,
|
||||||
...acc,
|
[a]: { min, max },
|
||||||
[a]: { min, max },
|
};
|
||||||
};
|
return acc;
|
||||||
return acc;
|
}, {});
|
||||||
}, {});
|
|
||||||
|
|
||||||
const labelElementsProps: TElements<ElementProps> = Object.assign(
|
const moneyResultElementsProps = (
|
||||||
{},
|
|
||||||
[
|
[
|
||||||
'labelResultTotalGraphwithNDS',
|
'labelResultTotalGraphwithNDS',
|
||||||
'labelResultPlPrice',
|
'labelResultPlPrice',
|
||||||
@ -496,25 +363,33 @@ const labelElementsProps: TElements<ElementProps> = Object.assign(
|
|||||||
'labelResultDopMPLLeasing',
|
'labelResultDopMPLLeasing',
|
||||||
'labelResultBonusDopProd',
|
'labelResultBonusDopProd',
|
||||||
'labelSubsidySum',
|
'labelSubsidySum',
|
||||||
].reduce(
|
] as ElementsNames[]
|
||||||
(ac, a) => ({
|
).reduce(
|
||||||
...ac,
|
(ac, a) => ({
|
||||||
//@ts-ignore
|
...ac,
|
||||||
[a]: { middleware: value => pipe(round, formatMoney)(value) },
|
//@ts-ignore
|
||||||
}),
|
[a]: { middleware: value => pipe(round, formatMoney)(value) },
|
||||||
{},
|
}),
|
||||||
),
|
{},
|
||||||
|
);
|
||||||
|
|
||||||
|
const numberResultElementsProps = (
|
||||||
[
|
[
|
||||||
'labelResultPriceUpPr',
|
'labelResultPriceUpPr',
|
||||||
'labelResultIRRGraphPerc',
|
'labelResultIRRGraphPerc',
|
||||||
'labelResultIRRNominalPerc',
|
'labelResultIRRNominalPerc',
|
||||||
'labelResultTerm',
|
'labelResultTerm',
|
||||||
].reduce(
|
] as ElementsNames[]
|
||||||
(ac, a) => ({
|
).reduce(
|
||||||
...ac,
|
(ac, a) => ({
|
||||||
[a]: { middleware: value => round(value) },
|
...ac,
|
||||||
}),
|
[a]: { middleware: value => round(value) },
|
||||||
{},
|
}),
|
||||||
),
|
{},
|
||||||
|
);
|
||||||
|
|
||||||
|
export default Object.assign(
|
||||||
|
elementsProps,
|
||||||
|
moneyResultElementsProps,
|
||||||
|
numberResultElementsProps,
|
||||||
);
|
);
|
||||||
export default Object.assign(elementsProps, labelElementsProps);
|
|
||||||
135
src/client/Containers/Calculation/Elements/props/render.tsx
Normal file
135
src/client/Containers/Calculation/Elements/props/render.tsx
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
|
||||||
|
import Link from 'client/Elements/Link';
|
||||||
|
import buildTooltip from 'client/Elements/Tooltip';
|
||||||
|
import { Flex } from 'client/UIKit/grid';
|
||||||
|
import { ElementProps } from 'types/elements';
|
||||||
|
import InsuranceTag from '../../Components/InsuranceTag';
|
||||||
|
import { AllElementsNames } from '../../types/elements';
|
||||||
|
import { TableNames } from '../../types/tables';
|
||||||
|
import buildLink from '../builders/buildLink';
|
||||||
|
|
||||||
|
const Head = props => (
|
||||||
|
<Flex
|
||||||
|
flexDirection={['column', 'row']}
|
||||||
|
justifyContent={['', 'space-between']}
|
||||||
|
alignItems={['', 'center']}
|
||||||
|
>
|
||||||
|
{props.children}
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
|
|
||||||
|
export default {
|
||||||
|
selectLead: {
|
||||||
|
render: (Title, Element) => {
|
||||||
|
const SubComponent = buildLink({
|
||||||
|
name: 'leadUrl',
|
||||||
|
text: 'Открыть в CRM',
|
||||||
|
valueName: 'leadUrl',
|
||||||
|
type: 'link',
|
||||||
|
Component: Link,
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
<Flex flexDirection="column">
|
||||||
|
<Head>
|
||||||
|
<Title />
|
||||||
|
<SubComponent />
|
||||||
|
</Head>
|
||||||
|
<Element />
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
selectOpportunity: {
|
||||||
|
render: (Title, Element) => {
|
||||||
|
const SubComponent = buildLink({
|
||||||
|
name: 'leadUrl',
|
||||||
|
text: 'Открыть в CRM',
|
||||||
|
valueName: 'opportunityUrl',
|
||||||
|
type: 'link',
|
||||||
|
Component: Link,
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
<Flex flexDirection="column">
|
||||||
|
<Head>
|
||||||
|
<Title />
|
||||||
|
<SubComponent />
|
||||||
|
</Head>
|
||||||
|
<Element />
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
selectQuote: {
|
||||||
|
render: (Title, Element) => {
|
||||||
|
const SubComponent = buildLink({
|
||||||
|
name: 'leadUrl',
|
||||||
|
text: 'Открыть в CRM',
|
||||||
|
valueName: 'quoteUrl',
|
||||||
|
type: 'link',
|
||||||
|
Component: Link,
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
<Flex flexDirection="column">
|
||||||
|
<Head>
|
||||||
|
<Title />
|
||||||
|
<SubComponent />
|
||||||
|
</Head>
|
||||||
|
<Element />
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
tableInsurance: {
|
||||||
|
sub: {
|
||||||
|
Component: InsuranceTag,
|
||||||
|
},
|
||||||
|
render: (Title, Element) => {
|
||||||
|
return (
|
||||||
|
<Flex flexDirection="column">
|
||||||
|
<Head>
|
||||||
|
<Title />
|
||||||
|
<InsuranceTag />
|
||||||
|
</Head>
|
||||||
|
<Element />
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
tbxVehicleTaxInYear: {
|
||||||
|
render: (Title, Component) => {
|
||||||
|
const Tooltip = buildTooltip({
|
||||||
|
title: 'Без учета налога на роскошь',
|
||||||
|
placement: 'topLeft',
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
<Tooltip>
|
||||||
|
<Flex flexDirection="column">
|
||||||
|
<Title />
|
||||||
|
<Component />
|
||||||
|
</Flex>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
selectHighSeasonStart: {
|
||||||
|
render: (Title, Component) => {
|
||||||
|
const Tooltip = buildTooltip({
|
||||||
|
title: 'С какого платежа начинается полный высокий сезон',
|
||||||
|
placement: 'topLeft',
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
<Tooltip>
|
||||||
|
<Flex flexDirection="column">
|
||||||
|
<Title />
|
||||||
|
<Component />
|
||||||
|
</Flex>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
} as Partial<Record<AllElementsNames | TableNames, ElementProps>>;
|
||||||
@ -8,16 +8,10 @@ import {
|
|||||||
} from 'core/constants/stores/Calculation/filters';
|
} from 'core/constants/stores/Calculation/filters';
|
||||||
import { MAX_INSURANCE } from 'core/constants/stores/Calculation/limits';
|
import { MAX_INSURANCE } from 'core/constants/stores/Calculation/limits';
|
||||||
import { formatNumber } from 'core/tools/format';
|
import { formatNumber } from 'core/tools/format';
|
||||||
import {
|
import { ElementStatus } from 'types/elements';
|
||||||
ITable,
|
import { Column, Table } from '../../types/tables';
|
||||||
TableColumn,
|
|
||||||
TableColumnCallbacks,
|
|
||||||
TableColumnOptions,
|
|
||||||
TableRow,
|
|
||||||
} from 'core/types/Calculation/Store/tables';
|
|
||||||
import { ElementStatus } from 'core/types/statuses';
|
|
||||||
|
|
||||||
const columns: TableColumn[] = [
|
const columns: Column[] = [
|
||||||
{
|
{
|
||||||
name: 'policyType',
|
name: 'policyType',
|
||||||
title: 'Тип полиса',
|
title: 'Тип полиса',
|
||||||
@ -61,7 +55,7 @@ const columns: TableColumn[] = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const rows: TableRow[] = [
|
const rows: Table['rows'] = [
|
||||||
{
|
{
|
||||||
policyType: {
|
policyType: {
|
||||||
value: 'ОСАГО',
|
value: 'ОСАГО',
|
||||||
@ -144,7 +138,7 @@ const rows: TableRow[] = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const callbacks: TableColumnCallbacks = {
|
const callbacks: Table['callbacks'] = {
|
||||||
insCost: ({ calculationStore, tableName, rowIndex }) => {
|
insCost: ({ calculationStore, tableName, rowIndex }) => {
|
||||||
if (
|
if (
|
||||||
calculationStore.tables[tableName]?.rows[rowIndex]['insCost']?.value &&
|
calculationStore.tables[tableName]?.rows[rowIndex]['insCost']?.value &&
|
||||||
@ -336,7 +330,7 @@ const callbacks: TableColumnCallbacks = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const options: TableColumnOptions = {
|
const options: Table['options'] = {
|
||||||
insured: [
|
insured: [
|
||||||
{
|
{
|
||||||
name: 'ЛП',
|
name: 'ЛП',
|
||||||
@ -365,4 +359,4 @@ export default {
|
|||||||
options,
|
options,
|
||||||
callbacks,
|
callbacks,
|
||||||
params: {},
|
params: {},
|
||||||
} as ITable;
|
} as Table;
|
||||||
@ -2,16 +2,12 @@ import InputNumber from 'client/Elements/InputNumber';
|
|||||||
import valuesConstants from 'core/constants/values';
|
import valuesConstants from 'core/constants/values';
|
||||||
import { rotateArrays } from 'core/tools/array';
|
import { rotateArrays } from 'core/tools/array';
|
||||||
import { formatNumber } from 'core/tools/format';
|
import { formatNumber } from 'core/tools/format';
|
||||||
import {
|
|
||||||
ITable,
|
|
||||||
TableColumn,
|
|
||||||
TableColumnCallbacks,
|
|
||||||
TableColumnFeatures,
|
|
||||||
} from 'core/types/Calculation/Store/tables';
|
|
||||||
import { inRange } from 'lodash';
|
import { inRange } from 'lodash';
|
||||||
|
import { Table } from '../../types/tables';
|
||||||
|
|
||||||
const { PERIODS_NUMBER } = valuesConstants;
|
const { PERIODS_NUMBER } = valuesConstants;
|
||||||
|
|
||||||
const columns: TableColumn[] = [
|
const columns: Table['columns'] = [
|
||||||
{
|
{
|
||||||
name: 'paymentRelation',
|
name: 'paymentRelation',
|
||||||
title: '% платежа',
|
title: '% платежа',
|
||||||
@ -26,7 +22,7 @@ const columns: TableColumn[] = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const callbacks: TableColumnCallbacks = {
|
const callbacks: Table['callbacks'] = {
|
||||||
paymentRelation: ({ calculationStore, tableName, rowIndex, value }) => {
|
paymentRelation: ({ calculationStore, tableName, rowIndex, value }) => {
|
||||||
const rowLength = calculationStore.tables[tableName].rows.length;
|
const rowLength = calculationStore.tables[tableName].rows.length;
|
||||||
const { graphType, seasonType } = calculationStore.values;
|
const { graphType, seasonType } = calculationStore.values;
|
||||||
@ -65,9 +61,8 @@ const callbacks: TableColumnCallbacks = {
|
|||||||
),
|
),
|
||||||
shiftNumber = highSeasonStartValue - 2;
|
shiftNumber = highSeasonStartValue - 2;
|
||||||
|
|
||||||
const seasonTypeOptions = calculationStore.getOption(
|
const seasonTypeOptions =
|
||||||
'selectSeasonType',
|
calculationStore.getOption('selectSeasonType');
|
||||||
);
|
|
||||||
const startPositions =
|
const startPositions =
|
||||||
seasonTypeOptions && seasonTypeOptions.startPositions,
|
seasonTypeOptions && seasonTypeOptions.startPositions,
|
||||||
endPositions =
|
endPositions =
|
||||||
@ -123,19 +118,19 @@ const callbacks: TableColumnCallbacks = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const features: TableColumnFeatures = {
|
const params: Table['params'] = {
|
||||||
numerize: true,
|
features: {
|
||||||
split: {
|
numerize: true,
|
||||||
rowsNumber: 12,
|
split: {
|
||||||
columnsNumber: 3,
|
rowsNumber: 12,
|
||||||
|
columnsNumber: 3,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const params = { features };
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
columns,
|
columns,
|
||||||
rows: [],
|
rows: [],
|
||||||
params,
|
params,
|
||||||
callbacks,
|
callbacks,
|
||||||
} as ITable;
|
} as Table;
|
||||||
@ -3,13 +3,9 @@ import Label from 'client/Elements/Label';
|
|||||||
import { formatMoney } from 'core/tools/format';
|
import { formatMoney } from 'core/tools/format';
|
||||||
import { pipe } from 'core/tools/func';
|
import { pipe } from 'core/tools/func';
|
||||||
import { round } from 'core/tools/num';
|
import { round } from 'core/tools/num';
|
||||||
import {
|
import { Column, Table } from '../../types/tables';
|
||||||
ITable,
|
|
||||||
TableColumn,
|
|
||||||
TableColumnFeatures,
|
|
||||||
} from 'core/types/Calculation/Store/tables';
|
|
||||||
|
|
||||||
const columns: TableColumn[] = [
|
const columns: Column[] = [
|
||||||
{
|
{
|
||||||
name: 'paymentSum',
|
name: 'paymentSum',
|
||||||
title: 'Сумма платежа',
|
title: 'Сумма платежа',
|
||||||
@ -36,14 +32,14 @@ const columns: TableColumn[] = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const features: TableColumnFeatures = {
|
const params: Table['params'] = {
|
||||||
numerize: true,
|
features: {
|
||||||
|
numerize: true,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const params = { features };
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
columns,
|
columns,
|
||||||
rows: [],
|
rows: [],
|
||||||
params,
|
params,
|
||||||
} as ITable;
|
} as Table;
|
||||||
@ -1,27 +1,10 @@
|
|||||||
import { TElements } from 'core/types/Calculation/Store/elements';
|
import { AllElementsNames } from '../types/elements';
|
||||||
import { StoreTables } from 'core/types/Calculation/Store/tables';
|
import { TableNames } from '../types/tables';
|
||||||
|
|
||||||
export const elementsTitles: TElements<string> = {
|
export const elementsTitles: Partial<Record<AllElementsNames, string>> = {
|
||||||
selectLead: 'Интерес',
|
selectLead: 'Интерес',
|
||||||
selectOpportunity: 'Лизинговая сделка',
|
selectOpportunity: 'Лизинговая сделка',
|
||||||
selectQuote: 'Предложение',
|
selectQuote: 'Предложение',
|
||||||
selectTemplate: 'Выбор шаблона',
|
|
||||||
selectChannel: 'Канал привлечения',
|
|
||||||
tbxNewClient: 'Новый контрагент',
|
|
||||||
selectAccount: 'Существующий контрагент',
|
|
||||||
tbxINN: 'ИНН',
|
|
||||||
tbxKPP: 'КПП',
|
|
||||||
selectContactClient: 'Контактное лицо контрагента',
|
|
||||||
tbxContact: 'Контактное лицо',
|
|
||||||
radioContactGender: 'Пол контактного лица',
|
|
||||||
tbxPhoneNumber: 'Телефон',
|
|
||||||
tbxEmailAddress: 'E-mail',
|
|
||||||
selectSupplier: 'Поставщик',
|
|
||||||
selectFinDepartment: 'Финотдел',
|
|
||||||
selectAgent: 'Агент',
|
|
||||||
selectDoubleAgent: 'Двойной агент',
|
|
||||||
selectBroker: 'Брокер',
|
|
||||||
tbxCommentLead: 'Комментарий к интересу',
|
|
||||||
selectProduct: 'Продукт',
|
selectProduct: 'Продукт',
|
||||||
selectClientRisk: 'Риск клиента',
|
selectClientRisk: 'Риск клиента',
|
||||||
selectClientType: 'Тип клиента',
|
selectClientType: 'Тип клиента',
|
||||||
@ -113,15 +96,12 @@ export const elementsTitles: TElements<string> = {
|
|||||||
tbxImporterRewardPerc: 'АВ импортера, %',
|
tbxImporterRewardPerc: 'АВ импортера, %',
|
||||||
tbxImporterRewardRub: 'АВ импортера, руб.',
|
tbxImporterRewardRub: 'АВ импортера, руб.',
|
||||||
cbxDisableChecks: 'Отключить все проверки',
|
cbxDisableChecks: 'Отключить все проверки',
|
||||||
tbxSystemUser: 'Пользователь',
|
|
||||||
tbxBusinessUnit: 'Подразделение',
|
|
||||||
selectRegistration: 'Регистрация',
|
selectRegistration: 'Регистрация',
|
||||||
selectInsNSIB: 'НСИБ',
|
selectInsNSIB: 'НСИБ',
|
||||||
selectTechnicalCard: 'Карта техпомощи',
|
selectTechnicalCard: 'Карта техпомощи',
|
||||||
radioRequirementTelematic: 'Программа средства контроля',
|
radioRequirementTelematic: 'Программа средства контроля',
|
||||||
selectTelematic: 'Телематика ',
|
selectTelematic: 'Телематика ',
|
||||||
selectTracker: 'Маяк',
|
selectTracker: 'Маяк',
|
||||||
selectUserSession: 'Загрузить сессию пользователя',
|
|
||||||
labelIrrInfo: 'Диапазон IRR (Номинал)',
|
labelIrrInfo: 'Диапазон IRR (Номинал)',
|
||||||
tbxMileage: 'Пробег, км',
|
tbxMileage: 'Пробег, км',
|
||||||
radioCalcType: 'Расчет от',
|
radioCalcType: 'Расчет от',
|
||||||
@ -141,9 +121,8 @@ export const elementsTitles: TElements<string> = {
|
|||||||
labelSubsidySum: 'Сумма субсидии с НДС',
|
labelSubsidySum: 'Сумма субсидии с НДС',
|
||||||
selectFuelCard: 'Топливная карта',
|
selectFuelCard: 'Топливная карта',
|
||||||
tbxMinPriceChange: 'Мин. возможное изменение стоимости ПЛ',
|
tbxMinPriceChange: 'Мин. возможное изменение стоимости ПЛ',
|
||||||
};
|
|
||||||
|
|
||||||
const resultsTitles: TElements<string> = {
|
/** Result Elements */
|
||||||
labelResultTotalGraphwithNDS: 'Итого по графику, с НДС',
|
labelResultTotalGraphwithNDS: 'Итого по графику, с НДС',
|
||||||
labelResultPlPrice: 'Стоимость ПЛ с НДС',
|
labelResultPlPrice: 'Стоимость ПЛ с НДС',
|
||||||
labelResultPriceUpPr: 'Удорожание, год',
|
labelResultPriceUpPr: 'Удорожание, год',
|
||||||
@ -162,10 +141,10 @@ const resultsTitles: TElements<string> = {
|
|||||||
labelResultBonusDopProd: 'Бонус МПЛ за доп.продукты, без НДФЛ',
|
labelResultBonusDopProd: 'Бонус МПЛ за доп.продукты, без НДФЛ',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const tablesTitles: StoreTables<string> = {
|
export const tablesTitles: Record<TableNames, string> = {
|
||||||
tableInsurance: 'Таблица страхования',
|
tableInsurance: 'Таблица страхования',
|
||||||
tablePayments: 'Таблица платежей',
|
tablePayments: 'Таблица платежей',
|
||||||
tableResults: '',
|
tableResults: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Object.assign(elementsTitles, resultsTitles, tablesTitles);
|
export default Object.assign(elementsTitles, tablesTitles);
|
||||||
@ -1,17 +1,15 @@
|
|||||||
//@ts-nocheck
|
//@ts-nocheck
|
||||||
import { ElementsNames } from 'core/types/Calculation/Store/elements';
|
|
||||||
import { ValuesNames } from 'core/types/Calculation/Store/values';
|
import { ValuesNames } from 'core/types/Calculation/Store/values';
|
||||||
|
import { ElementsNames } from '../types/elements';
|
||||||
import { elementsTitles } from './titles';
|
import { elementsTitles } from './titles';
|
||||||
import { elementsValues } from './values';
|
import values from './values';
|
||||||
|
|
||||||
export function getValueName(elementName: ElementsNames): ValuesNames {
|
export function getValueName(elementName: ElementsNames): ValuesNames {
|
||||||
return elementsValues[elementName];
|
return values[elementName];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getFieldName(valueName: ValuesNames): ElementsNames {
|
export function getFieldName(valueName: ValuesNames): ElementsNames {
|
||||||
return Object.keys(elementsValues).find(
|
return Object.keys(values).find(key => values[key] === valueName);
|
||||||
key => elementsValues[key] === valueName,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getTitle(elementName: ElementsNames): string {
|
export function getTitle(elementName: ElementsNames): string {
|
||||||
@ -1,31 +1,21 @@
|
|||||||
import { TElements } from 'core/types/Calculation/Store/elements';
|
import { ActionsNames } from 'core/types/Calculation/Store/effect';
|
||||||
|
import { LinksNames } from 'core/types/Calculation/Store/links';
|
||||||
import {
|
import {
|
||||||
ResultValuesNames,
|
ComputedValuesNames,
|
||||||
ValuesNames,
|
ValuesNames,
|
||||||
} from 'core/types/Calculation/Store/values';
|
} from 'core/types/Calculation/Store/values';
|
||||||
|
import {
|
||||||
|
ButtonElementsNames,
|
||||||
|
ComputedElementsNames,
|
||||||
|
ElementsNames,
|
||||||
|
LinkElementsNames,
|
||||||
|
} from '../types/elements';
|
||||||
|
|
||||||
export const elementsValues: TElements<ValuesNames> = {
|
const elementsValues: Record<ElementsNames, ValuesNames> = {
|
||||||
selectLead: 'lead',
|
selectLead: 'lead',
|
||||||
selectOpportunity: 'opportunity',
|
selectOpportunity: 'opportunity',
|
||||||
selectQuote: 'quote',
|
selectQuote: 'quote',
|
||||||
cbxRecalcWithRevision: 'recalcWithRevision',
|
cbxRecalcWithRevision: 'recalcWithRevision',
|
||||||
selectTemplate: 'template',
|
|
||||||
selectChannel: 'channel',
|
|
||||||
tbxNewClient: 'newClient',
|
|
||||||
selectAccount: 'account',
|
|
||||||
tbxINN: 'INN',
|
|
||||||
tbxKPP: 'KPP',
|
|
||||||
selectContactClient: 'contactClient',
|
|
||||||
tbxContact: 'contact',
|
|
||||||
radioContactGender: 'contactGender',
|
|
||||||
tbxPhoneNumber: 'phoneNumber',
|
|
||||||
tbxEmailAddress: 'emailAddress',
|
|
||||||
selectSupplier: 'supplier',
|
|
||||||
selectFinDepartment: 'finDepartment',
|
|
||||||
selectAgent: 'agent',
|
|
||||||
selectDoubleAgent: 'doubleAgent',
|
|
||||||
selectBroker: 'broker',
|
|
||||||
tbxCommentLead: 'commentLead',
|
|
||||||
selectProduct: 'product',
|
selectProduct: 'product',
|
||||||
selectClientRisk: 'clientRisk',
|
selectClientRisk: 'clientRisk',
|
||||||
selectClientType: 'clientType',
|
selectClientType: 'clientType',
|
||||||
@ -93,7 +83,6 @@ export const elementsValues: TElements<ValuesNames> = {
|
|||||||
radioInfuranceOPF: 'infuranceOPF',
|
radioInfuranceOPF: 'infuranceOPF',
|
||||||
radioInsKaskoType: 'insKaskoType',
|
radioInsKaskoType: 'insKaskoType',
|
||||||
cbxInsDecentral: 'insDecentral',
|
cbxInsDecentral: 'insDecentral',
|
||||||
selectInsPeriod: 'insPeriod',
|
|
||||||
tbxInsFranchise: 'insFranchise',
|
tbxInsFranchise: 'insFranchise',
|
||||||
cbxInsUnlimitDrivers: 'insUnlimitDrivers',
|
cbxInsUnlimitDrivers: 'insUnlimitDrivers',
|
||||||
tbxInsAgeDrivers: 'insAgeDrivers',
|
tbxInsAgeDrivers: 'insAgeDrivers',
|
||||||
@ -113,7 +102,6 @@ export const elementsValues: TElements<ValuesNames> = {
|
|||||||
selectTarif: 'tarif',
|
selectTarif: 'tarif',
|
||||||
tbxCreditRate: 'creditRate',
|
tbxCreditRate: 'creditRate',
|
||||||
selectRate: 'rate',
|
selectRate: 'rate',
|
||||||
selectUserSession: 'userSession',
|
|
||||||
tbxMaxPriceChange: 'maxPriceChange',
|
tbxMaxPriceChange: 'maxPriceChange',
|
||||||
tbxImporterRewardPerc: 'importerRewardPerc',
|
tbxImporterRewardPerc: 'importerRewardPerc',
|
||||||
tbxImporterRewardRub: 'importerRewardRub',
|
tbxImporterRewardRub: 'importerRewardRub',
|
||||||
@ -140,9 +128,8 @@ export const elementsValues: TElements<ValuesNames> = {
|
|||||||
labelSubsidySum: 'subsidySum',
|
labelSubsidySum: 'subsidySum',
|
||||||
selectFuelCard: 'fuelCard',
|
selectFuelCard: 'fuelCard',
|
||||||
tbxMinPriceChange: 'minPriceChange',
|
tbxMinPriceChange: 'minPriceChange',
|
||||||
};
|
|
||||||
|
|
||||||
const resultElementsValues: TElements<ResultValuesNames> = {
|
/** Result Elements */
|
||||||
labelResultTotalGraphwithNDS: 'resultTotalGraphwithNDS',
|
labelResultTotalGraphwithNDS: 'resultTotalGraphwithNDS',
|
||||||
labelResultPlPrice: 'resultPlPrice',
|
labelResultPlPrice: 'resultPlPrice',
|
||||||
labelResultPriceUpPr: 'resultPriceUpPr',
|
labelResultPriceUpPr: 'resultPriceUpPr',
|
||||||
@ -161,4 +148,28 @@ const resultElementsValues: TElements<ResultValuesNames> = {
|
|||||||
labelResultBonusDopProd: 'resultBonusDopProd',
|
labelResultBonusDopProd: 'resultBonusDopProd',
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Object.assign(elementsValues, resultElementsValues);
|
const elementsComputedValues: Record<
|
||||||
|
ComputedElementsNames,
|
||||||
|
ComputedValuesNames
|
||||||
|
> = {
|
||||||
|
labelLeaseObjectRisk: 'leaseObjectRiskName',
|
||||||
|
tbxInsKaskoPriceLeasePeriod: 'insKaskoPriceLeasePeriod',
|
||||||
|
labelIrrInfo: 'irrInfo',
|
||||||
|
labelRegistrationDescription: 'registrationDescription',
|
||||||
|
};
|
||||||
|
|
||||||
|
const elementsActions: Record<ButtonElementsNames, ActionsNames> = {
|
||||||
|
btnCalculate: 'calculate',
|
||||||
|
btnCreateKP: 'createKP',
|
||||||
|
};
|
||||||
|
|
||||||
|
const elementsLinks: Record<LinkElementsNames, LinksNames> = {
|
||||||
|
linkDownloadKp: 'kpUrl',
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Object.assign(
|
||||||
|
elementsValues,
|
||||||
|
elementsComputedValues,
|
||||||
|
elementsActions,
|
||||||
|
elementsLinks,
|
||||||
|
);
|
||||||
@ -2,9 +2,9 @@ import withStores from 'client/hocs/withStores';
|
|||||||
import { Box } from 'client/UIKit/grid';
|
import { Box } from 'client/UIKit/grid';
|
||||||
import mq from 'client/UIKit/mq';
|
import mq from 'client/UIKit/mq';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import Info from './Info';
|
import Info from './Components/Info';
|
||||||
import Results from './Results';
|
import Results from './Components/Results';
|
||||||
import Sections from './Sections';
|
import Sections from './Components/Sections';
|
||||||
|
|
||||||
const Grid = styled(Box)`
|
const Grid = styled(Box)`
|
||||||
grid-gap: 10px;
|
grid-gap: 10px;
|
||||||
|
|||||||
@ -1,61 +1,20 @@
|
|||||||
import {
|
import builders from '../Elements/builders';
|
||||||
withButton,
|
import components from '../Elements/components';
|
||||||
withComputedValue,
|
import props from '../Elements/props/common';
|
||||||
withLink,
|
import { getValueName } from '../Elements/tools';
|
||||||
withTable,
|
|
||||||
withValue,
|
|
||||||
} from 'client/hocs/Calculation';
|
|
||||||
import { ElementType } from 'core/types/Calculation/Store/elements';
|
|
||||||
import { pick } from 'lodash';
|
|
||||||
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';
|
|
||||||
|
|
||||||
export function buildElement(elementName, elementProps = {}) {
|
export function buildElement(name) {
|
||||||
const elementType = elementsTypes[elementName];
|
const valueName = getValueName(name);
|
||||||
const Component = elementsComponents[elementName];
|
const Component = components[name];
|
||||||
|
const elementProps = props[name];
|
||||||
|
|
||||||
switch (elementType) {
|
const builder = builders[name];
|
||||||
case ElementType.Table: {
|
const Element = builder({
|
||||||
return withTable(Component)({
|
name,
|
||||||
name: elementName,
|
valueName,
|
||||||
...pick(tables[elementName], ['options', 'callbacks', 'params']),
|
Component,
|
||||||
});
|
...elementProps,
|
||||||
}
|
});
|
||||||
case ElementType.Action: {
|
|
||||||
return withButton(Component)({
|
return Element;
|
||||||
name: elementName,
|
|
||||||
actionName: elementsActions[elementName],
|
|
||||||
...elementProps,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
case ElementType.Computed: {
|
|
||||||
return withComputedValue(Component)({
|
|
||||||
name: elementName,
|
|
||||||
computedValueName: elementsComputedValues[elementName],
|
|
||||||
...elementProps,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
case ElementType.Link: {
|
|
||||||
return withLink(Component)({
|
|
||||||
name: elementName,
|
|
||||||
urlName: elementsUrls[elementName],
|
|
||||||
...elementProps,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
case ElementType.Custom: {
|
|
||||||
return () => <Component {...elementProps} />;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
return withValue(Component)({
|
|
||||||
name: elementName,
|
|
||||||
valueName: getValueName(elementName),
|
|
||||||
...elementProps,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +0,0 @@
|
|||||||
import { TElements } from 'core/types/Calculation/Store/elements';
|
|
||||||
import { ActionsNames } from 'core/types/Calculation/Store/effect';
|
|
||||||
|
|
||||||
const elementsActions: TElements<ActionsNames> = {
|
|
||||||
btnCalculate: 'calculate',
|
|
||||||
btnCreateLead: 'createLead',
|
|
||||||
btnCreateKP: 'createKP',
|
|
||||||
};
|
|
||||||
|
|
||||||
export default elementsActions;
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
import { TElements } from 'core/types/Calculation/Store/elements';
|
|
||||||
import { ComputedValuesNames } from 'core/types/Calculation/Store/values';
|
|
||||||
|
|
||||||
const elementsComputedValues: TElements<ComputedValuesNames> = {
|
|
||||||
labelLeaseObjectRisk: 'leaseObjectRiskName',
|
|
||||||
tbxInsKaskoPriceLeasePeriod: 'insKaskoPriceLeasePeriod',
|
|
||||||
labelIrrInfo: 'irrInfo',
|
|
||||||
labelRegistrationDescription: 'registrationDescription',
|
|
||||||
};
|
|
||||||
|
|
||||||
export default elementsComputedValues;
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
import { ElementType, TElements } from 'core/types/Calculation/Store/elements';
|
|
||||||
import { StoreTables } from 'core/types/Calculation/Store/tables';
|
|
||||||
|
|
||||||
const elementsTypes: TElements<ElementType> = {
|
|
||||||
labelLeaseObjectRisk: ElementType.Computed,
|
|
||||||
btnFranschise: ElementType.Action,
|
|
||||||
btnDriversApplication: ElementType.Action,
|
|
||||||
tbxInsKaskoPriceLeasePeriod: ElementType.Computed,
|
|
||||||
btnCreateKP: ElementType.Action,
|
|
||||||
btnCalculate: ElementType.Action,
|
|
||||||
labelIrrInfo: ElementType.Computed,
|
|
||||||
linkDownloadKp: ElementType.Link,
|
|
||||||
componentElt: ElementType.Custom,
|
|
||||||
labelRegistrationDescription: ElementType.Computed,
|
|
||||||
};
|
|
||||||
|
|
||||||
const tablesTypes: StoreTables<ElementType> = {
|
|
||||||
tablePayments: ElementType.Table,
|
|
||||||
tableInsurance: ElementType.Table,
|
|
||||||
tableResults: ElementType.Table,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Object.assign(elementsTypes, tablesTypes);
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
import { LinksNames } from 'core/types/Calculation/Store/links';
|
|
||||||
import { TElements } from 'core/types/Calculation/Store/elements';
|
|
||||||
|
|
||||||
const elementsUrls: TElements<LinksNames> = {
|
|
||||||
linkDownloadKp: 'kpUrl',
|
|
||||||
};
|
|
||||||
|
|
||||||
export default elementsUrls;
|
|
||||||
@ -5,9 +5,9 @@ import colors from 'client/UIKit/colors';
|
|||||||
import { Box, Flex } from 'client/UIKit/grid';
|
import { Box, Flex } from 'client/UIKit/grid';
|
||||||
import mq from 'client/UIKit/mq';
|
import mq from 'client/UIKit/mq';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
import elementsRenderProps from '../Elements/props/render';
|
||||||
|
import elementsTitles from '../Elements/titles';
|
||||||
import { buildElement } from '../lib/buildElement';
|
import { buildElement } from '../lib/buildElement';
|
||||||
import elementsProps from './elements/elementsProps';
|
|
||||||
import elementsTitles from './elements/titles';
|
|
||||||
|
|
||||||
const ElementTitle = styled.h5`
|
const ElementTitle = styled.h5`
|
||||||
color: rgba(0, 0, 0, 0.75);
|
color: rgba(0, 0, 0, 0.75);
|
||||||
@ -17,47 +17,26 @@ const ElementTitle = styled.h5`
|
|||||||
margin: 0 8px 3px 0;
|
margin: 0 8px 3px 0;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
white-space: ${props => props.whiteSpace || 'nowrap'};
|
white-space: nowrap;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Head = ({ sub, elementTitle, style }) => {
|
const renderElements = ({ elements }) => {
|
||||||
if (sub?.Component) {
|
return elements.map(elementName => {
|
||||||
return (
|
const elementTitleText = elementsTitles[elementName];
|
||||||
<Flex
|
const Title = () => <ElementTitle>{elementTitleText}</ElementTitle>;
|
||||||
flexDirection={['column', 'row']}
|
const Element = buildElement(elementName);
|
||||||
justifyContent={[undefined, 'space-between']}
|
|
||||||
alignItems={[undefined, 'center']}
|
|
||||||
>
|
|
||||||
<ElementTitle {...style}>{elementTitle}</ElementTitle>
|
|
||||||
<sub.Component />
|
|
||||||
</Flex>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return <ElementTitle {...style}>{elementTitle}</ElementTitle>;
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderElements = ({ elements, elementStyle }) => {
|
if (elementsRenderProps[elementName]) {
|
||||||
return elements.map((elementName, ie) => {
|
const { render } = elementsRenderProps[elementName];
|
||||||
const elementTitle = elementsTitles[elementName];
|
return render(Title, Element);
|
||||||
const { tooltip, sub, ...elementProps } = elementsProps[elementName] || {};
|
|
||||||
|
|
||||||
const Component = buildElement(elementName, elementProps);
|
|
||||||
const Tooltip = tooltip?.Component;
|
|
||||||
|
|
||||||
const element = (
|
|
||||||
<Flex flexDirection="column" key={ie}>
|
|
||||||
<Head
|
|
||||||
sub={sub}
|
|
||||||
elementTitle={elementTitle}
|
|
||||||
style={elementStyle?.head}
|
|
||||||
/>
|
|
||||||
<Component />
|
|
||||||
</Flex>
|
|
||||||
);
|
|
||||||
if (tooltip) {
|
|
||||||
return <Tooltip>{element}</Tooltip>;
|
|
||||||
}
|
}
|
||||||
return element;
|
|
||||||
|
return (
|
||||||
|
<Flex flexDirection="column" key={elementName}>
|
||||||
|
<Title />
|
||||||
|
<Element />
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -73,16 +52,13 @@ const ElementsGrid = styled(Box)`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const renderBlocks = ({ blocks }) => {
|
const renderBlocks = ({ blocks }) => {
|
||||||
if (!blocks || blocks.length === 0) {
|
return blocks?.map((block, ib) => {
|
||||||
return null;
|
const { elements, title, style } = block;
|
||||||
}
|
|
||||||
return blocks.map((block, ib) => {
|
|
||||||
const { elements, title, style, elementStyle } = block;
|
|
||||||
return (
|
return (
|
||||||
<Flex key={ib} flexDirection="column" flexWrap="nowrap">
|
<Flex key={ib} flexDirection="column" flexWrap="nowrap">
|
||||||
{title && <SecondaryColoredText>{title}</SecondaryColoredText>}
|
{title && <SecondaryColoredText>{title}</SecondaryColoredText>}
|
||||||
<ElementsGrid {...style} defaultColumnsNumber={1}>
|
<ElementsGrid {...style} defaultColumnsNumber={1}>
|
||||||
{renderElements({ elements, elementStyle })}
|
{renderElements({ elements })}
|
||||||
</ElementsGrid>
|
</ElementsGrid>
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
@ -96,10 +72,7 @@ const BlocksTitle = styled(Divider)`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
export const renderGroups = ({ groups }) => {
|
export const renderGroups = ({ groups }) => {
|
||||||
if (!groups || groups.length === 0) {
|
return groups?.map((group, ig) => {
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return groups.map((group, ig) => {
|
|
||||||
const { title, blocks, style } = group;
|
const { title, blocks, style } = group;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
19
src/client/Containers/Calculation/types/common.ts
Normal file
19
src/client/Containers/Calculation/types/common.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { AllElementsNames, CustomComponents } from './elements';
|
||||||
|
import { TableNames } from './tables';
|
||||||
|
|
||||||
|
interface IBlock {
|
||||||
|
title?: string;
|
||||||
|
elements: (AllElementsNames | TableNames | CustomComponents)[];
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IGroup {
|
||||||
|
title?: string;
|
||||||
|
blocks?: IBlock[];
|
||||||
|
style?: { [key: string]: any };
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ISection {
|
||||||
|
title?: string;
|
||||||
|
groups?: IGroup[];
|
||||||
|
}
|
||||||
@ -1,28 +1,8 @@
|
|||||||
import { TableNames } from 'core/types/Calculation/Store/tables';
|
|
||||||
|
|
||||||
export type ElementsNames =
|
export type ElementsNames =
|
||||||
| 'selectLead'
|
| 'selectLead'
|
||||||
| 'selectOpportunity'
|
| 'selectOpportunity'
|
||||||
| 'selectQuote'
|
| 'selectQuote'
|
||||||
| 'cbxRecalcWithRevision'
|
| 'cbxRecalcWithRevision'
|
||||||
| 'selectTemplate'
|
|
||||||
| 'selectChannel'
|
|
||||||
| 'tbxNewClient'
|
|
||||||
| 'selectAccount'
|
|
||||||
| 'tbxINN'
|
|
||||||
| 'tbxKPP'
|
|
||||||
| 'selectContactClient'
|
|
||||||
| 'tbxContact'
|
|
||||||
| 'radioContactGender'
|
|
||||||
| 'tbxPhoneNumber'
|
|
||||||
| 'tbxEmailAddress'
|
|
||||||
| 'selectSupplier'
|
|
||||||
| 'selectFinDepartment'
|
|
||||||
| 'selectAgent'
|
|
||||||
| 'selectDoubleAgent'
|
|
||||||
| 'selectBroker'
|
|
||||||
| 'tbxCommentLead'
|
|
||||||
| 'btnCreateLead'
|
|
||||||
| 'selectProduct'
|
| 'selectProduct'
|
||||||
| 'selectClientRisk'
|
| 'selectClientRisk'
|
||||||
| 'selectClientType'
|
| 'selectClientType'
|
||||||
@ -48,7 +28,6 @@ export type ElementsNames =
|
|||||||
| 'tbxIRR_Perc'
|
| 'tbxIRR_Perc'
|
||||||
| 'selectLeaseObjectType'
|
| 'selectLeaseObjectType'
|
||||||
| 'radioDeliveryTime'
|
| 'radioDeliveryTime'
|
||||||
| 'labelLeaseObjectRisk'
|
|
||||||
| 'labelDepreciationGroup'
|
| 'labelDepreciationGroup'
|
||||||
| 'tbxLeaseObjectCount'
|
| 'tbxLeaseObjectCount'
|
||||||
| 'cbxWithTrailer'
|
| 'cbxWithTrailer'
|
||||||
@ -90,9 +69,7 @@ export type ElementsNames =
|
|||||||
| 'selectTownRegistration'
|
| 'selectTownRegistration'
|
||||||
| 'radioInfuranceOPF'
|
| 'radioInfuranceOPF'
|
||||||
| 'radioInsKaskoType'
|
| 'radioInsKaskoType'
|
||||||
| 'tbxInsKaskoPriceLeasePeriod'
|
|
||||||
| 'cbxInsDecentral'
|
| 'cbxInsDecentral'
|
||||||
| 'selectInsPeriod'
|
|
||||||
| 'tbxInsFranchise'
|
| 'tbxInsFranchise'
|
||||||
| 'cbxInsUnlimitDrivers'
|
| 'cbxInsUnlimitDrivers'
|
||||||
| 'tbxInsAgeDrivers'
|
| 'tbxInsAgeDrivers'
|
||||||
@ -108,32 +85,20 @@ export type ElementsNames =
|
|||||||
| 'cbxNSIB'
|
| 'cbxNSIB'
|
||||||
| 'tbxQuoteName'
|
| 'tbxQuoteName'
|
||||||
| 'radioQuoteContactGender'
|
| 'radioQuoteContactGender'
|
||||||
| 'btnCreateKP'
|
|
||||||
| 'cbxQuoteRedemptionGraph'
|
| 'cbxQuoteRedemptionGraph'
|
||||||
| 'selectTarif'
|
| 'selectTarif'
|
||||||
| 'tbxCreditRate'
|
| 'tbxCreditRate'
|
||||||
| 'selectRate'
|
| 'selectRate'
|
||||||
| 'selectUserSession'
|
|
||||||
| 'radioRequirementTelematic'
|
| 'radioRequirementTelematic'
|
||||||
| 'tbxMaxPriceChange'
|
| 'tbxMaxPriceChange'
|
||||||
| 'tbxImporterRewardPerc'
|
| 'tbxImporterRewardPerc'
|
||||||
| 'tbxImporterRewardRub'
|
| 'tbxImporterRewardRub'
|
||||||
| 'cbxDisableChecks'
|
| 'cbxDisableChecks'
|
||||||
| 'btnFranschise'
|
|
||||||
| 'btnDriversApplication'
|
|
||||||
| 'tbxSystemUser'
|
|
||||||
| 'tbxBusinessUnit'
|
|
||||||
| 'tbxLeadNumber'
|
|
||||||
| 'tbxOpportunityNumber'
|
|
||||||
| 'lblLead'
|
|
||||||
| 'lblOpportunity'
|
|
||||||
| 'btnCalculate'
|
|
||||||
| 'selectRegistration'
|
| 'selectRegistration'
|
||||||
| 'selectInsNSIB'
|
| 'selectInsNSIB'
|
||||||
| 'selectTechnicalCard'
|
| 'selectTechnicalCard'
|
||||||
| 'selectTelematic'
|
| 'selectTelematic'
|
||||||
| 'selectTracker'
|
| 'selectTracker'
|
||||||
| 'labelIrrInfo'
|
|
||||||
| 'tbxMileage'
|
| 'tbxMileage'
|
||||||
| 'radioCalcType'
|
| 'radioCalcType'
|
||||||
| 'tbxTotalPayments'
|
| 'tbxTotalPayments'
|
||||||
@ -144,17 +109,13 @@ export type ElementsNames =
|
|||||||
| 'selectObjectCategoryTax'
|
| 'selectObjectCategoryTax'
|
||||||
| 'selectObjectTypeTax'
|
| 'selectObjectTypeTax'
|
||||||
| 'radioTypePTS'
|
| 'radioTypePTS'
|
||||||
| 'labelRegistrationDescription'
|
|
||||||
| 'selectLegalClientRegion'
|
| 'selectLegalClientRegion'
|
||||||
| 'selectLegalClientTown'
|
| 'selectLegalClientTown'
|
||||||
| 'selectSubsidy'
|
| 'selectSubsidy'
|
||||||
| 'labelSubsidySum'
|
| 'labelSubsidySum'
|
||||||
| 'selectFuelCard'
|
| 'selectFuelCard'
|
||||||
| 'tbxMinPriceChange';
|
| 'tbxMinPriceChange'
|
||||||
|
/** Result Elements */
|
||||||
export type LinkElementsNames = 'linkDownloadKp';
|
|
||||||
|
|
||||||
export type ResultElementsNames =
|
|
||||||
| 'labelResultTotalGraphwithNDS'
|
| 'labelResultTotalGraphwithNDS'
|
||||||
| 'labelResultPlPrice'
|
| 'labelResultPlPrice'
|
||||||
| 'labelResultPriceUpPr'
|
| 'labelResultPriceUpPr'
|
||||||
@ -171,25 +132,29 @@ export type ResultElementsNames =
|
|||||||
| 'labelResultBonusMPL'
|
| 'labelResultBonusMPL'
|
||||||
| 'labelResultDopMPLLeasing'
|
| 'labelResultDopMPLLeasing'
|
||||||
| 'labelResultBonusDopProd';
|
| 'labelResultBonusDopProd';
|
||||||
|
export type ButtonElementsNames = 'btnCreateKP' | 'btnCalculate';
|
||||||
|
export type LinkElementsNames = 'linkDownloadKp';
|
||||||
|
export type ComputedElementsNames =
|
||||||
|
| 'labelLeaseObjectRisk'
|
||||||
|
| 'tbxInsKaskoPriceLeasePeriod'
|
||||||
|
| 'labelIrrInfo'
|
||||||
|
| 'labelRegistrationDescription';
|
||||||
|
|
||||||
export type CustomComponents = 'componentElt';
|
export type CustomComponents = 'componentElt';
|
||||||
|
|
||||||
export type AllElements =
|
/** GROUPS */
|
||||||
|
export type InteractionElementsNames =
|
||||||
| ElementsNames
|
| ElementsNames
|
||||||
| ResultElementsNames
|
| ButtonElementsNames
|
||||||
|
| LinkElementsNames;
|
||||||
|
|
||||||
|
export type NonValueElementsNames =
|
||||||
|
| ButtonElementsNames
|
||||||
| LinkElementsNames
|
| LinkElementsNames
|
||||||
| CustomComponents
|
| ComputedElementsNames;
|
||||||
| TableNames;
|
|
||||||
|
|
||||||
export enum ElementType {
|
export type AllElementsNames =
|
||||||
Default,
|
| ElementsNames
|
||||||
Computed,
|
| ComputedElementsNames
|
||||||
Table,
|
| ButtonElementsNames
|
||||||
Action,
|
| LinkElementsNames;
|
||||||
Link,
|
|
||||||
Custom,
|
|
||||||
}
|
|
||||||
|
|
||||||
export type TElements<T> = {
|
|
||||||
[elementName in AllElements]?: T;
|
|
||||||
};
|
|
||||||
49
src/client/Containers/Calculation/types/tables.ts
Normal file
49
src/client/Containers/Calculation/types/tables.ts
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import { TCalculationProcess } from 'client/stores/CalculationStore/subStores/calculationProcess';
|
||||||
|
import { TOptionizedEntity } from 'core/services/CrmService/types/common';
|
||||||
|
import { ICalculationStore } from 'core/types/Calculation/Store';
|
||||||
|
import { TElementFilter } from 'core/types/Calculation/Store/filters';
|
||||||
|
import { FC } from 'react';
|
||||||
|
import { ElementProps, ElementStatus } from 'types/elements';
|
||||||
|
|
||||||
|
export type TableNames = 'tableInsurance' | 'tablePayments' | 'tableResults';
|
||||||
|
export type TableValuesNames =
|
||||||
|
| 'policyType'
|
||||||
|
| 'insuranceCompany'
|
||||||
|
| 'insured'
|
||||||
|
| 'insCost'
|
||||||
|
| 'insTerm'
|
||||||
|
| 'paymentNumber'
|
||||||
|
| 'paymentRelation'
|
||||||
|
| 'paymentSum'
|
||||||
|
| 'ndsCompensation'
|
||||||
|
| 'redemptionAmount';
|
||||||
|
|
||||||
|
type CellCallback = (props: {
|
||||||
|
calculationStore: ICalculationStore;
|
||||||
|
calculationProcess: TCalculationProcess;
|
||||||
|
tableName: TableNames;
|
||||||
|
rowIndex: number;
|
||||||
|
value: any;
|
||||||
|
}) => void;
|
||||||
|
|
||||||
|
export type Cell = {
|
||||||
|
value?: any;
|
||||||
|
status?: ElementStatus;
|
||||||
|
validation?: boolean;
|
||||||
|
filter?: TElementFilter;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Column = {
|
||||||
|
name: TableValuesNames;
|
||||||
|
title: string;
|
||||||
|
Component: FC<any>;
|
||||||
|
props?: ElementProps;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Table = {
|
||||||
|
columns: Column[];
|
||||||
|
rows: Partial<Record<TableValuesNames, Cell>>[];
|
||||||
|
options?: Partial<Record<TableValuesNames, TOptionizedEntity[]>>;
|
||||||
|
params?: { features?: Record<string, any> };
|
||||||
|
callbacks?: Partial<Record<TableValuesNames, CellCallback>>;
|
||||||
|
};
|
||||||
@ -1,7 +1,7 @@
|
|||||||
import { Button as AntButton } from 'antd';
|
import { Button as AntButton } from 'antd';
|
||||||
import { ACTION_DELAY } from 'core/constants/debounce';
|
import { ACTION_DELAY } from 'core/constants/debounce';
|
||||||
import { ElementStatus } from 'core/types/statuses';
|
|
||||||
import { throttle } from 'lodash';
|
import { throttle } from 'lodash';
|
||||||
|
import { ElementStatus } from 'types/elements';
|
||||||
|
|
||||||
const Button = ({ status, action, text, ...props }) => {
|
const Button = ({ status, action, text, ...props }) => {
|
||||||
const throttledAction = action
|
const throttledAction = action
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { Checkbox as AntCheckbox, Form } from 'antd';
|
import { Checkbox as AntCheckbox, Form } from 'antd';
|
||||||
import { ElementStatus } from 'core/types/statuses';
|
import { ElementStatus } from 'types/elements';
|
||||||
|
|
||||||
const Checkbox = ({
|
const Checkbox = ({
|
||||||
value,
|
value,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { Form, Input as AntInput } from 'antd';
|
import { Form, Input as AntInput } from 'antd';
|
||||||
import { ElementStatus } from 'core/types/statuses';
|
import { ElementStatus } from 'types/elements';
|
||||||
|
|
||||||
const Input = ({
|
const Input = ({
|
||||||
value,
|
value,
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { Form, InputNumber as AntInputNumber } from 'antd';
|
import { Form, InputNumber as AntInputNumber } from 'antd';
|
||||||
import { Outlined } from 'client/Components/Spinner';
|
import { Outlined } from 'client/Components/Spinner';
|
||||||
import { ElementStatus } from 'core/types/statuses';
|
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
import { ElementStatus } from 'types/elements';
|
||||||
|
|
||||||
const { Disabled, Loading } = ElementStatus;
|
const { Disabled, Loading } = ElementStatus;
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { Button as AntButton } from 'antd';
|
import { Button as AntButton } from 'antd';
|
||||||
import { ElementStatus } from 'core/types/statuses';
|
import { ElementStatus } from 'types/elements';
|
||||||
|
|
||||||
const Link = ({ status, url, text, icon: Icon, ...props }) => {
|
const Link = ({ status, url, text, icon: Icon, ...props }) => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { Form, Radio as AntRadio } from 'antd';
|
import { Form, Radio as AntRadio } from 'antd';
|
||||||
import { ElementStatus } from 'core/types/statuses';
|
import { ElementStatus } from 'types/elements';
|
||||||
|
|
||||||
const Radio = ({
|
const Radio = ({
|
||||||
value,
|
value,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { Form, Select as AntSelect } from 'antd';
|
import { Form, Select as AntSelect } from 'antd';
|
||||||
import { ElementStatus } from 'core/types/statuses';
|
import { ElementStatus } from 'types/elements';
|
||||||
|
|
||||||
const Select = ({
|
const Select = ({
|
||||||
value = null,
|
value = null,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { Form, Switch as AntSwitch } from 'antd';
|
import { Form, Switch as AntSwitch } from 'antd';
|
||||||
import { ElementStatus } from 'core/types/statuses';
|
import { ElementStatus } from 'types/elements';
|
||||||
|
|
||||||
const Switch = ({
|
const Switch = ({
|
||||||
value,
|
value,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { Form, Input as AntInput } from 'antd';
|
import { Form, Input as AntInput } from 'antd';
|
||||||
import { ElementStatus } from 'core/types/statuses';
|
import { ElementStatus } from 'types/elements';
|
||||||
|
|
||||||
const TextArea = ({
|
const TextArea = ({
|
||||||
value,
|
value,
|
||||||
|
|||||||
@ -1,7 +0,0 @@
|
|||||||
import withButton from './withButton';
|
|
||||||
import withComputedValue from './withComputedValue';
|
|
||||||
import withLink from './withLink';
|
|
||||||
import withTable from './withTable';
|
|
||||||
import withValue from './withValue';
|
|
||||||
|
|
||||||
export { withButton, withLink, withValue, withComputedValue, withTable };
|
|
||||||
@ -1,62 +0,0 @@
|
|||||||
import { useTableOptions } from 'client/hooks/Calculation/useOptions';
|
|
||||||
import { useTableStatus } from 'client/hooks/Calculation/useStatus';
|
|
||||||
import { useTableValidation } from 'client/hooks/Calculation/useValidation';
|
|
||||||
import { useTableValue } from 'client/hooks/Calculation/useValue';
|
|
||||||
import { useStores } from 'client/hooks/useStores';
|
|
||||||
import { observer } from 'mobx-react-lite';
|
|
||||||
|
|
||||||
export default Table => props => {
|
|
||||||
const { name: tableName, callbacks } = props;
|
|
||||||
const ObservedTable = observer(Table);
|
|
||||||
const { calculationStore } = useStores();
|
|
||||||
const tableData = calculationStore.tables[tableName];
|
|
||||||
return () => (
|
|
||||||
<ObservedTable
|
|
||||||
{...props}
|
|
||||||
{...tableData}
|
|
||||||
withTableValue={withTableValue(callbacks)}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const withTableValue = callbacks => Component => ({
|
|
||||||
tableName,
|
|
||||||
rowIndex,
|
|
||||||
propName,
|
|
||||||
validation,
|
|
||||||
...props
|
|
||||||
}) =>
|
|
||||||
observer(() => {
|
|
||||||
const { value, setCurrentValue } = useTableValue({
|
|
||||||
tableName,
|
|
||||||
rowIndex,
|
|
||||||
propName,
|
|
||||||
columnCallback: callbacks?.[propName],
|
|
||||||
});
|
|
||||||
const { status } = useTableStatus({ tableName, rowIndex, propName });
|
|
||||||
const { validateStatus, message } = useTableValidation({
|
|
||||||
tableName,
|
|
||||||
rowIndex,
|
|
||||||
propName,
|
|
||||||
validation,
|
|
||||||
});
|
|
||||||
|
|
||||||
const { options, filter } = useTableOptions({
|
|
||||||
tableName,
|
|
||||||
rowIndex,
|
|
||||||
propName,
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Component
|
|
||||||
{...props}
|
|
||||||
value={value}
|
|
||||||
setCurrentValue={setCurrentValue}
|
|
||||||
status={status}
|
|
||||||
validateStatus={validateStatus}
|
|
||||||
message={message}
|
|
||||||
options={options}
|
|
||||||
filter={filter}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
62
src/client/hooks/Calculation/useValidation.js
Normal file
62
src/client/hooks/Calculation/useValidation.js
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
import { INVALID_INPUT as INVALID_INPUT_MESSAGE } from 'core/constants/errorMessages';
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { useStores } from '../useStores';
|
||||||
|
|
||||||
|
export const useValidation = ({ elementName, value }) => {
|
||||||
|
const [isValid, setValidation] = useState(undefined);
|
||||||
|
const { calculationStore } = useStores();
|
||||||
|
|
||||||
|
// get value from store
|
||||||
|
const validationStatus = calculationStore.validations[elementName];
|
||||||
|
useEffect(() => {
|
||||||
|
setValidation(validationStatus);
|
||||||
|
}, [validationStatus]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (value === undefined || value === '') {
|
||||||
|
calculationStore.setValidation(elementName, undefined);
|
||||||
|
}
|
||||||
|
}, [value]);
|
||||||
|
|
||||||
|
return {
|
||||||
|
validateStatus: isValid === false ? 'error' : undefined,
|
||||||
|
message: isValid === false ? INVALID_INPUT_MESSAGE : undefined,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useTableValidation = ({
|
||||||
|
tableName,
|
||||||
|
rowIndex,
|
||||||
|
propName,
|
||||||
|
value,
|
||||||
|
}) => {
|
||||||
|
const [isValid, setValidation] = useState(undefined);
|
||||||
|
const { calculationStore } = useStores();
|
||||||
|
|
||||||
|
const validationStatus =
|
||||||
|
calculationStore?.tables?.[tableName]?.rows?.[rowIndex]?.[propName]
|
||||||
|
?.validation;
|
||||||
|
useEffect(() => {
|
||||||
|
setValidation(validationStatus);
|
||||||
|
}, [validationStatus]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (value === undefined || value === '') {
|
||||||
|
calculationStore.setTableRows(
|
||||||
|
tableName,
|
||||||
|
rowIndex,
|
||||||
|
)([
|
||||||
|
{
|
||||||
|
[propName]: {
|
||||||
|
validation: undefined,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}, [value]);
|
||||||
|
|
||||||
|
return {
|
||||||
|
validateStatus: isValid === false ? 'error' : undefined,
|
||||||
|
message: isValid === false ? INVALID_INPUT_MESSAGE : undefined,
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,147 +0,0 @@
|
|||||||
import { ValidateStatus } from 'antd/lib/form/FormItem';
|
|
||||||
import { INVALID_INPUT as INVALID_INPUT_MESSAGE } from 'core/constants/errorMessages';
|
|
||||||
import { ElementsNames } from 'core/types/Calculation/Store/elements';
|
|
||||||
import {
|
|
||||||
TableNames,
|
|
||||||
TableValuesNames,
|
|
||||||
} from 'core/types/Calculation/Store/tables';
|
|
||||||
import { useEffect, useState } from 'react';
|
|
||||||
import { useStores } from '../useStores';
|
|
||||||
|
|
||||||
type TValidation = {
|
|
||||||
errorMessage: string;
|
|
||||||
validator: ((_: any) => boolean) | undefined;
|
|
||||||
};
|
|
||||||
interface IUseValidationArgs {
|
|
||||||
elementName: ElementsNames;
|
|
||||||
value: any;
|
|
||||||
validation: TValidation;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IUseTableValidationArgs {
|
|
||||||
tableName: TableNames;
|
|
||||||
rowIndex: number;
|
|
||||||
propName: TableValuesNames;
|
|
||||||
value: any;
|
|
||||||
validation: TValidation;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useValidation = ({
|
|
||||||
elementName,
|
|
||||||
value,
|
|
||||||
validation,
|
|
||||||
}: IUseValidationArgs) => {
|
|
||||||
const { validator, errorMessage } = validation || {
|
|
||||||
validator: undefined,
|
|
||||||
errorMessage: undefined,
|
|
||||||
};
|
|
||||||
const [isValid, setValidation] = useState<boolean | undefined>(undefined);
|
|
||||||
const { calculationStore } = useStores();
|
|
||||||
|
|
||||||
// inject value from store
|
|
||||||
const validationStatus = calculationStore.validations[elementName];
|
|
||||||
useEffect(() => {
|
|
||||||
setValidation(validationStatus);
|
|
||||||
}, [validationStatus]);
|
|
||||||
|
|
||||||
// inner validation && set validation status to store
|
|
||||||
useEffect(() => {
|
|
||||||
if (value === undefined || value === '') {
|
|
||||||
calculationStore.setValidation(elementName, undefined);
|
|
||||||
} else {
|
|
||||||
if (validator) {
|
|
||||||
const validationResult = validator(value);
|
|
||||||
calculationStore.setValidation(elementName, validationResult);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [value]);
|
|
||||||
|
|
||||||
const getValidateStatus = (): ValidateStatus | undefined => {
|
|
||||||
if (isValid === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return isValid === false ? 'error' : 'success';
|
|
||||||
};
|
|
||||||
|
|
||||||
const getMessage = (): string | undefined => {
|
|
||||||
if (isValid === false) {
|
|
||||||
return errorMessage || INVALID_INPUT_MESSAGE;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
|
||||||
isValid,
|
|
||||||
validateStatus: getValidateStatus(),
|
|
||||||
message: getMessage(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export const useTableValidation = ({
|
|
||||||
tableName,
|
|
||||||
rowIndex,
|
|
||||||
propName,
|
|
||||||
value,
|
|
||||||
validation,
|
|
||||||
}: IUseTableValidationArgs) => {
|
|
||||||
const { validator, errorMessage } = validation || {
|
|
||||||
validator: undefined,
|
|
||||||
errorMessage: undefined,
|
|
||||||
};
|
|
||||||
const [isValid, setValidation] = useState<boolean | undefined>(undefined);
|
|
||||||
const { calculationStore } = useStores();
|
|
||||||
|
|
||||||
const validationStatus =
|
|
||||||
calculationStore?.tables?.[tableName]?.rows?.[rowIndex]?.[propName]
|
|
||||||
?.validation;
|
|
||||||
useEffect(() => {
|
|
||||||
setValidation(validationStatus);
|
|
||||||
}, [validationStatus]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (value === undefined || value === '') {
|
|
||||||
calculationStore.setTableRows(
|
|
||||||
tableName,
|
|
||||||
rowIndex,
|
|
||||||
)([
|
|
||||||
{
|
|
||||||
[propName]: {
|
|
||||||
validation: undefined,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
if (validator) {
|
|
||||||
const validationResult = validator(value);
|
|
||||||
calculationStore.setTableRows(
|
|
||||||
tableName,
|
|
||||||
rowIndex,
|
|
||||||
)([
|
|
||||||
{
|
|
||||||
[propName]: {
|
|
||||||
validation: validationResult,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [value]);
|
|
||||||
|
|
||||||
const getValidateStatus = (): ValidateStatus | undefined => {
|
|
||||||
if (isValid === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return isValid === false ? 'error' : 'success';
|
|
||||||
};
|
|
||||||
|
|
||||||
const getMessage = (): string | undefined => {
|
|
||||||
if (isValid === false) {
|
|
||||||
return errorMessage || INVALID_INPUT_MESSAGE;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
|
||||||
isValid,
|
|
||||||
validateStatus: getValidateStatus(),
|
|
||||||
message: getMessage(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import { getValueName } from 'client/Containers/Calculation/lib/elements/tools';
|
import { getValueName } from 'client/Containers/Calculation/Elements/tools';
|
||||||
import initialFilters, {
|
import initialFilters, {
|
||||||
noResetValueElements
|
noResetValueElements
|
||||||
} from 'client/stores/CalculationStore/config/initialFilters';
|
} from 'client/stores/CalculationStore/config/initialFilters';
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
import elementsTitles, {
|
import elementsTitles, {
|
||||||
tablesTitles,
|
tablesTitles
|
||||||
} from 'client/Containers/Calculation/lib/elements/titles';
|
} from 'client/Containers/Calculation/Elements/titles';
|
||||||
|
import { TableNames } from 'client/Containers/Calculation/types/tables';
|
||||||
import { ICalculationStore } from 'core/types/Calculation/Store';
|
import { ICalculationStore } from 'core/types/Calculation/Store';
|
||||||
import { TableNames } from 'core/types/Calculation/Store/tables';
|
|
||||||
import { omit } from 'lodash';
|
import { omit } from 'lodash';
|
||||||
import { toJS } from 'mobx';
|
import { toJS } from 'mobx';
|
||||||
|
|
||||||
|
|||||||
@ -2,8 +2,8 @@ import { message } from 'antd';
|
|||||||
import { openNotification } from 'client/Elements/Notification';
|
import { openNotification } from 'client/Elements/Notification';
|
||||||
import CalculationService from 'core/services/CalculationService';
|
import CalculationService from 'core/services/CalculationService';
|
||||||
import { ICalculationStore } from 'core/types/Calculation/Store';
|
import { ICalculationStore } from 'core/types/Calculation/Store';
|
||||||
import { resultsValues } from 'core/types/Calculation/Store/values';
|
import { ValuesNames } from 'core/types/Calculation/Store/values';
|
||||||
import { ElementStatus } from 'core/types/statuses';
|
import { ElementStatus } from 'types/elements';
|
||||||
import checkValidation from './checkValidation';
|
import checkValidation from './checkValidation';
|
||||||
import prepareCalculationData from './prepareData';
|
import prepareCalculationData from './prepareData';
|
||||||
import results from './results';
|
import results from './results';
|
||||||
@ -11,11 +11,33 @@ import validate from './validate';
|
|||||||
|
|
||||||
const BUTTONS_TIMEOUT = 500;
|
const BUTTONS_TIMEOUT = 500;
|
||||||
|
|
||||||
|
export const RESULT_VALUES: ValuesNames[] = [
|
||||||
|
'resultTotalGraphwithNDS',
|
||||||
|
'resultPlPrice',
|
||||||
|
'resultPriceUpPr',
|
||||||
|
'resultIRRGraphPerc',
|
||||||
|
'resultIRRNominalPerc',
|
||||||
|
'resultInsKasko',
|
||||||
|
'resultInsOsago',
|
||||||
|
'resultDopProdSum',
|
||||||
|
'resultFirstPayment',
|
||||||
|
'resultLastPayment',
|
||||||
|
'resultTerm',
|
||||||
|
'resultAB_FL',
|
||||||
|
'resultAB_UL',
|
||||||
|
'resultBonusMPL',
|
||||||
|
'resultDopMPLLeasing',
|
||||||
|
'resultBonusDopProd',
|
||||||
|
];
|
||||||
|
|
||||||
export default function (this: ICalculationStore) {
|
export default function (this: ICalculationStore) {
|
||||||
const cleanResults = () => {
|
const cleanResults = () => {
|
||||||
for (let resultValue of resultsValues) {
|
this.setValues(
|
||||||
this.setValue(resultValue, '');
|
RESULT_VALUES.reduce((acc, v) => {
|
||||||
}
|
acc[v] = '';
|
||||||
|
return acc;
|
||||||
|
}, {}),
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const blockButtons = () => {
|
const blockButtons = () => {
|
||||||
|
|||||||
@ -1,12 +1,15 @@
|
|||||||
import valuesConstants from 'core/constants/values';
|
import valuesConstants from 'core/constants/values';
|
||||||
|
import {
|
||||||
|
PaymentRow,
|
||||||
|
PreparedValues,
|
||||||
|
} from 'core/services/CalculationService/types/prepared';
|
||||||
|
import { PreparedData } from 'core/services/CalculationService/types/request';
|
||||||
import { currentDate } from 'core/tools/date';
|
import { currentDate } from 'core/tools/date';
|
||||||
import { NIL } from 'core/tools/uuid';
|
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 { ICalculationStore } from 'core/types/Calculation/Store';
|
||||||
import { convertPrice } from '../../lib/tools';
|
import { convertPrice } from '../../lib/tools';
|
||||||
|
|
||||||
export default function (this: ICalculationStore): IPreparedData {
|
export default function (this: ICalculationStore): PreparedData {
|
||||||
const { values, options, tables } = this;
|
const { values, options, tables } = this;
|
||||||
|
|
||||||
const preparedPaymentsRows: PaymentRow[] = Array.from(
|
const preparedPaymentsRows: PaymentRow[] = Array.from(
|
||||||
@ -97,9 +100,8 @@ export default function (this: ICalculationStore): IPreparedData {
|
|||||||
(0.0234 / ((1 - 1 / 1.0234) ^ ((preparedValues.nmper as number) - 2)))
|
(0.0234 / ((1 - 1 / 1.0234) ^ ((preparedValues.nmper as number) - 2)))
|
||||||
: 1;
|
: 1;
|
||||||
preparedValues.loanRate = parseFloat(values.creditRate) / 100;
|
preparedValues.loanRate = parseFloat(values.creditRate) / 100;
|
||||||
preparedValues.loanRatePeriod = this.getOption(
|
preparedValues.loanRatePeriod =
|
||||||
'selectRate',
|
this.getOption('selectRate')?.evo_credit_period;
|
||||||
)?.evo_credit_period;
|
|
||||||
preparedValues.balanceHolder = values.balanceHolder;
|
preparedValues.balanceHolder = values.balanceHolder;
|
||||||
preparedValues.dogDate = preparedValues.calcDate;
|
preparedValues.dogDate = preparedValues.calcDate;
|
||||||
preparedValues.paymentDateNew = undefined;
|
preparedValues.paymentDateNew = undefined;
|
||||||
@ -112,12 +114,10 @@ export default function (this: ICalculationStore): IPreparedData {
|
|||||||
(values.lastPaymentRub as number) / (1 + valuesConstants.VAT);
|
(values.lastPaymentRub as number) / (1 + valuesConstants.VAT);
|
||||||
preparedValues.subsidySum =
|
preparedValues.subsidySum =
|
||||||
parseInt(values.subsidySum) / (1 + valuesConstants.VAT);
|
parseInt(values.subsidySum) / (1 + valuesConstants.VAT);
|
||||||
preparedValues.subsidyPaymentNumber = this.getOption(
|
preparedValues.subsidyPaymentNumber =
|
||||||
'selectSubsidy',
|
this.getOption('selectSubsidy')?.evo_get_subsidy_payment;
|
||||||
)?.evo_get_subsidy_payment;
|
preparedValues.fuelCardSum =
|
||||||
preparedValues.fuelCardSum = this.getOption(
|
this.getOption('selectFuelCard')?.evo_graph_price_withoutnds;
|
||||||
'selectFuelCard',
|
|
||||||
)?.evo_graph_price_withoutnds;
|
|
||||||
preparedValues.scheduleOfPayments = values.graphType;
|
preparedValues.scheduleOfPayments = values.graphType;
|
||||||
preparedValues.comissionRub =
|
preparedValues.comissionRub =
|
||||||
(values.comissionRub as number) / (1 + valuesConstants.VAT);
|
(values.comissionRub as number) / (1 + valuesConstants.VAT);
|
||||||
|
|||||||
@ -1,18 +1,20 @@
|
|||||||
|
import { Table } from 'client/Containers/Calculation/types/tables';
|
||||||
import valuesConstants from 'core/constants/values';
|
import valuesConstants from 'core/constants/values';
|
||||||
import { IPreparedData } from 'core/types/Calculation/Requests';
|
import {
|
||||||
import { IGetCalculationResponse } from 'core/types/Calculation/Responses';
|
GetCalculationResponse,
|
||||||
|
PreparedData,
|
||||||
|
} from 'core/services/CalculationService/types/request';
|
||||||
import { ICalculationStore } from 'core/types/Calculation/Store';
|
import { ICalculationStore } from 'core/types/Calculation/Store';
|
||||||
import { ITableCell, TableProps } from 'core/types/Calculation/Store/tables';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
showResultsTable: function (
|
showResultsTable: function (
|
||||||
this: ICalculationStore,
|
this: ICalculationStore,
|
||||||
preparedData: IPreparedData,
|
preparedData: PreparedData,
|
||||||
res: IGetCalculationResponse,
|
res: GetCalculationResponse,
|
||||||
) {
|
) {
|
||||||
if (preparedData.preparedValues.nmper) {
|
if (preparedData.preparedValues.nmper) {
|
||||||
const { sumWithVatColumn, vatColumn, sumRepaymentColumn } = res.columns;
|
const { sumWithVatColumn, vatColumn, sumRepaymentColumn } = res.columns;
|
||||||
const results: TableProps<ITableCell>[] = [];
|
const results: Table['rows'] = [];
|
||||||
|
|
||||||
for (let i = 0; i < preparedData.preparedValues.nmper; i++) {
|
for (let i = 0; i < preparedData.preparedValues.nmper; i++) {
|
||||||
const balanceHolder = this.getValue('balanceHolder');
|
const balanceHolder = this.getValue('balanceHolder');
|
||||||
@ -44,8 +46,8 @@ export default {
|
|||||||
},
|
},
|
||||||
showResults: function (
|
showResults: function (
|
||||||
this: ICalculationStore,
|
this: ICalculationStore,
|
||||||
preparedData: IPreparedData,
|
preparedData: PreparedData,
|
||||||
res: IGetCalculationResponse,
|
res: GetCalculationResponse,
|
||||||
) {
|
) {
|
||||||
const { sumWithVatColumn } = res.columns;
|
const { sumWithVatColumn } = res.columns;
|
||||||
this.setValue(
|
this.setValue(
|
||||||
@ -144,7 +146,7 @@ export default {
|
|||||||
},
|
},
|
||||||
setResValues: function (
|
setResValues: function (
|
||||||
this: ICalculationStore,
|
this: ICalculationStore,
|
||||||
res: IGetCalculationResponse,
|
res: GetCalculationResponse,
|
||||||
) {
|
) {
|
||||||
this.setValue(
|
this.setValue(
|
||||||
'IRR_Perc',
|
'IRR_Perc',
|
||||||
|
|||||||
@ -1,21 +1,18 @@
|
|||||||
import { getValueName } from 'client/Containers/Calculation/lib/elements/tools';
|
import { getValueName } from 'client/Containers/Calculation/Elements/tools';
|
||||||
|
import { ElementsNames } from 'client/Containers/Calculation/types/elements';
|
||||||
import { pipe } from 'core/tools/func';
|
import { pipe } from 'core/tools/func';
|
||||||
import { ICalculationStore } from 'core/types/Calculation/Store';
|
import { ICalculationStore } from 'core/types/Calculation/Store';
|
||||||
import {
|
|
||||||
ElementsNames,
|
|
||||||
TElements,
|
|
||||||
} from 'core/types/Calculation/Store/elements';
|
|
||||||
import CONDITIONS from 'core/validation/conditions';
|
import CONDITIONS from 'core/validation/conditions';
|
||||||
import {
|
import {
|
||||||
convertToValidationResult,
|
convertToValidationResult,
|
||||||
getValue,
|
getValue,
|
||||||
showValidationMessages,
|
showValidationMessages,
|
||||||
validate,
|
validate,
|
||||||
ValidationCondition,
|
ValidationCondition
|
||||||
} from 'core/validation/validate';
|
} from 'core/validation/validate';
|
||||||
import { isNil } from 'lodash';
|
import { isNil } from 'lodash';
|
||||||
|
|
||||||
const customConditions: TElements<ValidationCondition> = {
|
const customConditions: Partial<Record<ElementsNames, ValidationCondition>> = {
|
||||||
selectLeaseObjectCategory: calculationStore => {
|
selectLeaseObjectCategory: calculationStore => {
|
||||||
const leaseObjectType = calculationStore.getOption('selectLeaseObjectType');
|
const leaseObjectType = calculationStore.getOption('selectLeaseObjectType');
|
||||||
const leaseObjectCategory = calculationStore.getValue(
|
const leaseObjectCategory = calculationStore.getValue(
|
||||||
@ -82,11 +79,8 @@ const customConditions: TElements<ValidationCondition> = {
|
|||||||
return { isValid: true };
|
return { isValid: true };
|
||||||
},
|
},
|
||||||
radioRequirementTelematic: calculationStore => {
|
radioRequirementTelematic: calculationStore => {
|
||||||
const {
|
const { telematic, tracker, requirementTelematic } =
|
||||||
telematic,
|
calculationStore.getValues([
|
||||||
tracker,
|
|
||||||
requirementTelematic,
|
|
||||||
} = calculationStore.getValues([
|
|
||||||
'telematic',
|
'telematic',
|
||||||
'tracker',
|
'tracker',
|
||||||
'requirementTelematic',
|
'requirementTelematic',
|
||||||
@ -107,10 +101,9 @@ const customConditions: TElements<ValidationCondition> = {
|
|||||||
return { isValid: true };
|
return { isValid: true };
|
||||||
},
|
},
|
||||||
selectTownRegistration: calculationStore => {
|
selectTownRegistration: calculationStore => {
|
||||||
const {
|
const { townRegistration, objectRegistration } = calculationStore.getValues(
|
||||||
townRegistration,
|
['townRegistration', 'objectRegistration'],
|
||||||
objectRegistration,
|
);
|
||||||
} = calculationStore.getValues(['townRegistration', 'objectRegistration']);
|
|
||||||
if (objectRegistration === 100000000 && !townRegistration) {
|
if (objectRegistration === 100000000 && !townRegistration) {
|
||||||
return {
|
return {
|
||||||
isValid: false,
|
isValid: false,
|
||||||
@ -141,7 +134,9 @@ const customConditions: TElements<ValidationCondition> = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const elementsValidations: TElements<any> = {
|
const elementsValidations: Partial<
|
||||||
|
Record<ElementsNames, (value?: any) => boolean>
|
||||||
|
> = {
|
||||||
selectLead: CONDITIONS.IS_NULL,
|
selectLead: CONDITIONS.IS_NULL,
|
||||||
selectProduct: CONDITIONS.IS_NULL,
|
selectProduct: CONDITIONS.IS_NULL,
|
||||||
selectSupplierCurrency: CONDITIONS.IS_NULL,
|
selectSupplierCurrency: CONDITIONS.IS_NULL,
|
||||||
@ -163,36 +158,36 @@ const elementsValidations: TElements<any> = {
|
|||||||
tbxLeaseObjectCount: CONDITIONS.LESS_OR_EQUALS_ZERO,
|
tbxLeaseObjectCount: CONDITIONS.LESS_OR_EQUALS_ZERO,
|
||||||
};
|
};
|
||||||
|
|
||||||
const elementsConditions = (Object.keys(
|
const elementsConditions = (
|
||||||
elementsValidations,
|
Object.keys(elementsValidations) as ElementsNames[]
|
||||||
) as ElementsNames[]).reduce(
|
).reduce(
|
||||||
(ac: TElements<ValidationCondition>, elementName) => {
|
(ac: Partial<Record<ElementsNames, ValidationCondition>>, elementName) => {
|
||||||
ac[elementName] = pipe(
|
const validator = elementsValidations[elementName];
|
||||||
getValue,
|
if (validator)
|
||||||
elementsValidations[elementName],
|
ac[elementName] = pipe(getValue, validator, convertToValidationResult);
|
||||||
convertToValidationResult,
|
return ac;
|
||||||
);
|
|
||||||
return ac;
|
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
);
|
);
|
||||||
|
|
||||||
const entityElementsConditions = ([
|
const entityElementsConditions = (
|
||||||
|
[
|
||||||
'selectIndAgentRewardCondition',
|
'selectIndAgentRewardCondition',
|
||||||
'selectCalcBrokerRewardCondition',
|
'selectCalcBrokerRewardCondition',
|
||||||
'selectFinDepartmentRewardCondtion',
|
'selectFinDepartmentRewardCondtion',
|
||||||
] as ElementsNames[]).reduce(
|
] as ElementsNames[]
|
||||||
(ac: TElements<ValidationCondition>, elementName) => {
|
).reduce(
|
||||||
const valueName = getValueName(elementName);
|
(ac: Partial<Record<ElementsNames, ValidationCondition>>, elementName) => {
|
||||||
ac[elementName] = (calculationStore, elementName) => {
|
const valueName = getValueName(elementName);
|
||||||
if (isNil(calculationStore.getValue(valueName))) {
|
ac[elementName] = (calculationStore, elementName) => {
|
||||||
return { isValid: true };
|
if (isNil(calculationStore.getValue(valueName))) {
|
||||||
}
|
return { isValid: true };
|
||||||
return {
|
}
|
||||||
isValid: calculationStore.getOption(elementName) !== undefined,
|
return {
|
||||||
|
isValid: calculationStore.getOption(elementName) !== undefined,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
return ac;
|
||||||
return ac;
|
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
);
|
);
|
||||||
|
|||||||
@ -3,12 +3,12 @@ import { AxiosError } from 'axios';
|
|||||||
import { openNotification } from 'client/Elements/Notification';
|
import { openNotification } from 'client/Elements/Notification';
|
||||||
import UserStore from 'client/stores/UserStore';
|
import UserStore from 'client/stores/UserStore';
|
||||||
import { CRM_PROXY_URL } from 'core/constants/urls';
|
import { CRM_PROXY_URL } from 'core/constants/urls';
|
||||||
import { getQuotesByLeadQuery } from 'core/graphql/query/crm/quote';
|
|
||||||
import CrmService from 'core/services/CrmService';
|
import CrmService from 'core/services/CrmService';
|
||||||
|
import { quotesByLeadQuery } from 'core/services/CrmService/graphql/query/quote';
|
||||||
|
import { IQuote } from 'core/services/CrmService/types/entities';
|
||||||
import { ICalculationStore } from 'core/types/Calculation/Store';
|
import { ICalculationStore } from 'core/types/Calculation/Store';
|
||||||
import { IQuote } from 'core/types/Entities/crmEntities';
|
|
||||||
import { toJS } from 'mobx';
|
import { toJS } from 'mobx';
|
||||||
import customValues from '../lib/customValues';
|
import { insKaskoPriceLeasePeriod } from '../computed';
|
||||||
import calculate from './calculate';
|
import calculate from './calculate';
|
||||||
|
|
||||||
async function composeRequest(this: ICalculationStore) {
|
async function composeRequest(this: ICalculationStore) {
|
||||||
@ -32,10 +32,9 @@ async function composeRequest(this: ICalculationStore) {
|
|||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
|
||||||
const insKaskoPriceLeasePeriod =
|
const insKaskoPriceLeasePeriodValue = insKaskoPriceLeasePeriod.call(this);
|
||||||
customValues.insKaskoPriceLeasePeriod.call(this);
|
|
||||||
const calculationValues = Object.assign({}, toJS(this.values), {
|
const calculationValues = Object.assign({}, toJS(this.values), {
|
||||||
insKaskoPriceLeasePeriod,
|
insKaskoPriceLeasePeriod: insKaskoPriceLeasePeriodValue,
|
||||||
});
|
});
|
||||||
|
|
||||||
const domainname = UserStore.getDomainName();
|
const domainname = UserStore.getDomainName();
|
||||||
@ -71,7 +70,7 @@ export default async function (this: ICalculationStore) {
|
|||||||
|
|
||||||
const leadid = this.getValue('lead');
|
const leadid = this.getValue('lead');
|
||||||
CrmService.getCRMOptions<'quotes', IQuote>({
|
CrmService.getCRMOptions<'quotes', IQuote>({
|
||||||
query: getQuotesByLeadQuery,
|
query: quotesByLeadQuery,
|
||||||
variables: {
|
variables: {
|
||||||
leadid,
|
leadid,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,84 +1,9 @@
|
|||||||
import { openNotification } from 'client/Elements/Notification';
|
import { openNotification } from 'client/Elements/Notification';
|
||||||
import { IAutorunEffect } from 'core/types/Calculation/Store/effect';
|
import { IAutorunEffect } from 'core/types/Calculation/Store/effect';
|
||||||
import { ElementStatus } from 'core/types/statuses';
|
import { ElementStatus } from 'types/elements';
|
||||||
import { convertPrice } from './lib/tools';
|
import { convertPrice } from './lib/tools';
|
||||||
|
|
||||||
const autorunEffects: IAutorunEffect[] = [
|
const autorunEffects: IAutorunEffect[] = [
|
||||||
calculationStore => () => {
|
|
||||||
const { contactClient, contact } = calculationStore.values;
|
|
||||||
if (contactClient || contact) {
|
|
||||||
calculationStore.setValidation('selectContactClient', true);
|
|
||||||
calculationStore.setValidation('tbxContact', true);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
calculationStore => () => {
|
|
||||||
const { newClient, account } = calculationStore.values;
|
|
||||||
if (newClient || account) {
|
|
||||||
calculationStore.setValidation('tbxNewClient', true);
|
|
||||||
calculationStore.setValidation('selectAccount', true);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
calculationStore => () => {
|
|
||||||
const { commentLead } = calculationStore.values;
|
|
||||||
if (commentLead) {
|
|
||||||
calculationStore.setValidation('tbxCommentLead', true);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
calculationStore => () => {
|
|
||||||
const { phoneNumber } = calculationStore.values;
|
|
||||||
if (phoneNumber) {
|
|
||||||
calculationStore.setValidation('tbxPhoneNumber', true);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
calculationStore => () => {
|
|
||||||
const { channel } = calculationStore.values;
|
|
||||||
if (channel) {
|
|
||||||
calculationStore.setValidation('selectChannel', true);
|
|
||||||
|
|
||||||
switch (channel) {
|
|
||||||
case 100000000: {
|
|
||||||
const { supplier, agent } = calculationStore.values;
|
|
||||||
if (supplier) {
|
|
||||||
calculationStore.setValidation('selectSupplier', true);
|
|
||||||
}
|
|
||||||
if (agent) {
|
|
||||||
calculationStore.setValidation('selectAgent', true);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 100000001: {
|
|
||||||
const { supplier, finDepartment } = calculationStore.values;
|
|
||||||
if (supplier) {
|
|
||||||
calculationStore.setValidation('selectSupplier', true);
|
|
||||||
}
|
|
||||||
if (finDepartment) {
|
|
||||||
calculationStore.setValidation('selectFinDepartment', true);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 100000002: {
|
|
||||||
const { agent } = calculationStore.values;
|
|
||||||
if (agent) {
|
|
||||||
calculationStore.setValidation('selectAgent', true);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 100000003: {
|
|
||||||
const { broker } = calculationStore.values;
|
|
||||||
if (broker) {
|
|
||||||
calculationStore.setValidation('selectBroker', true);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 100000004:
|
|
||||||
default: {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// calculationStore => () => {
|
// calculationStore => () => {
|
||||||
// const {
|
// const {
|
||||||
// leaseObjectCategory,
|
// leaseObjectCategory,
|
||||||
@ -131,11 +56,8 @@ const autorunEffects: IAutorunEffect[] = [
|
|||||||
ElementStatus.Default,
|
ElementStatus.Default,
|
||||||
);
|
);
|
||||||
|
|
||||||
const {
|
const { engineVolume, engineType, leaseObjectMotorPower } =
|
||||||
engineVolume,
|
calculationStore.values;
|
||||||
engineType,
|
|
||||||
leaseObjectMotorPower,
|
|
||||||
} = calculationStore.values;
|
|
||||||
|
|
||||||
if (engineVolume <= 0) {
|
if (engineVolume <= 0) {
|
||||||
calculationStore.setValidation('tbxEngineVolume', false);
|
calculationStore.setValidation('tbxEngineVolume', false);
|
||||||
@ -194,16 +116,13 @@ const autorunEffects: IAutorunEffect[] = [
|
|||||||
calculationStore.setValue('subsidySum', subsidy?.evo_subsidy_summ);
|
calculationStore.setValue('subsidySum', subsidy?.evo_subsidy_summ);
|
||||||
} else {
|
} else {
|
||||||
if (subsidy?.evo_max_subsidy_summ) {
|
if (subsidy?.evo_max_subsidy_summ) {
|
||||||
const {
|
const { leaseObjectPrice, supplierDiscountRub } =
|
||||||
leaseObjectPrice,
|
calculationStore.values;
|
||||||
supplierDiscountRub,
|
|
||||||
} = calculationStore.values;
|
|
||||||
const supplierCurrency = calculationStore.getOption(
|
const supplierCurrency = calculationStore.getOption(
|
||||||
'selectSupplierCurrency',
|
'selectSupplierCurrency',
|
||||||
);
|
);
|
||||||
const evo_currencychanges = calculationStore.getStaticData(
|
const evo_currencychanges =
|
||||||
'evo_currencychange',
|
calculationStore.getStaticData('evo_currencychange');
|
||||||
);
|
|
||||||
const evo_currencychange = evo_currencychanges.find(
|
const evo_currencychange = evo_currencychanges.find(
|
||||||
x =>
|
x =>
|
||||||
x.evo_ref_transactioncurrency ===
|
x.evo_ref_transactioncurrency ===
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import { ICalculationStore } from 'core/types/Calculation/Store';
|
import { ICalculationStore } from 'core/types/Calculation/Store';
|
||||||
import { TValues } from 'core/types/Calculation/Store/values';
|
import { ComputedValuesNames } from 'core/types/Calculation/Store/values';
|
||||||
import customValues from './lib/customValues';
|
|
||||||
|
|
||||||
const LEASE_OBJECT_RISK = {
|
const LEASE_OBJECT_RISK = {
|
||||||
100000000: 'Низкий',
|
100000000: 'Низкий',
|
||||||
@ -8,9 +7,32 @@ const LEASE_OBJECT_RISK = {
|
|||||||
100000002: 'Высокий',
|
100000002: 'Высокий',
|
||||||
};
|
};
|
||||||
|
|
||||||
const computedEffects: TValues<
|
type ComputedEffect = (this: ICalculationStore) => string | number | undefined;
|
||||||
(this: ICalculationStore) => string | number | undefined
|
|
||||||
> = {
|
export const insKaskoPriceLeasePeriod: ComputedEffect = function () {
|
||||||
|
const { leasingPeriod } = this.values;
|
||||||
|
const { rows } = this.tables.tableInsurance;
|
||||||
|
const kaskoRow = rows[1];
|
||||||
|
const dgoRow = rows[2];
|
||||||
|
const nsRow = rows[3];
|
||||||
|
|
||||||
|
let res = 0;
|
||||||
|
if (
|
||||||
|
leasingPeriod &&
|
||||||
|
leasingPeriod > 15 &&
|
||||||
|
kaskoRow?.insTerm?.value === 100000001
|
||||||
|
) {
|
||||||
|
res =
|
||||||
|
(leasingPeriod / 12) *
|
||||||
|
(kaskoRow?.insCost?.value +
|
||||||
|
dgoRow?.insCost?.value +
|
||||||
|
nsRow?.insCost?.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
|
const computedEffects: Record<ComputedValuesNames, ComputedEffect> = {
|
||||||
leaseObjectRiskName: function () {
|
leaseObjectRiskName: function () {
|
||||||
const configuration = this.getOption('selectConfiguration');
|
const configuration = this.getOption('selectConfiguration');
|
||||||
if (configuration) {
|
if (configuration) {
|
||||||
@ -25,9 +47,7 @@ const computedEffects: TValues<
|
|||||||
if (evo_leasingobject_risk)
|
if (evo_leasingobject_risk)
|
||||||
return LEASE_OBJECT_RISK[evo_leasingobject_risk];
|
return LEASE_OBJECT_RISK[evo_leasingobject_risk];
|
||||||
},
|
},
|
||||||
insKaskoPriceLeasePeriod: function () {
|
insKaskoPriceLeasePeriod,
|
||||||
return customValues.insKaskoPriceLeasePeriod.call(this).toFixed(2);
|
|
||||||
},
|
|
||||||
irrInfo: function () {
|
irrInfo: function () {
|
||||||
const tarif = this.getOption('selectTarif');
|
const tarif = this.getOption('selectTarif');
|
||||||
if (tarif && tarif.evo_min_irr && tarif.evo_max_irr) {
|
if (tarif && tarif.evo_min_irr && tarif.evo_max_irr) {
|
||||||
|
|||||||
@ -1,22 +0,0 @@
|
|||||||
export default {
|
|
||||||
insKaskoPriceLeasePeriod() {
|
|
||||||
const { leasingPeriod } = this.values;
|
|
||||||
const { rows } = this.tables.tableInsurance;
|
|
||||||
const kaskoRow = rows[1];
|
|
||||||
const dgoRow = rows[2];
|
|
||||||
const nsRow = rows[3];
|
|
||||||
|
|
||||||
let res = 0;
|
|
||||||
if (
|
|
||||||
leasingPeriod &&
|
|
||||||
leasingPeriod > 15 &&
|
|
||||||
kaskoRow.insTerm.value === 100000001
|
|
||||||
) {
|
|
||||||
res =
|
|
||||||
(leasingPeriod / 12) *
|
|
||||||
(kaskoRow.insCost.value + dgoRow.insCost.value + nsRow.insCost.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@ -1,15 +1,15 @@
|
|||||||
import { message } from 'antd';
|
import { message } from 'antd';
|
||||||
import { resetFields as kaskoResetFields } from 'client/Components/Calculation/ELT/Content/Kasko/lib/validation';
|
import { resetFields as kaskoResetFields } from 'client/Containers/Calculation/Components/ELT/Kasko/lib/validation';
|
||||||
import { cancelRequests } from 'client/Components/Calculation/ELT/Content/lib/requests';
|
import { cancelRequests } from 'client/Containers/Calculation/Components/ELT/lib/requests';
|
||||||
import {
|
import {
|
||||||
initIns,
|
initIns,
|
||||||
resetIns,
|
resetIns
|
||||||
} from 'client/Components/Calculation/ELT/Content/lib/resetIns';
|
} from 'client/Containers/Calculation/Components/ELT/lib/resetIns';
|
||||||
import { resetFields as osagoResetFields } from 'client/Components/Calculation/ELT/Content/Osago/lib/validation';
|
import { resetFields as osagoResetFields } from 'client/Containers/Calculation/Components/ELT/Osago/lib/validation';
|
||||||
import { getValueName } from 'client/Containers/Calculation/lib/elements/tools';
|
import { getValueName } from 'client/Containers/Calculation/Elements/tools';
|
||||||
|
import { ElementsNames } from 'client/Containers/Calculation/types/elements';
|
||||||
import { TCalculationProcess } from 'client/stores/CalculationStore/subStores/calculationProcess';
|
import { TCalculationProcess } from 'client/stores/CalculationStore/subStores/calculationProcess';
|
||||||
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
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 { ICalculationStore } from 'core/types/Calculation/Store/index';
|
||||||
import { Process } from 'core/types/Calculation/Store/process';
|
import { Process } from 'core/types/Calculation/Store/process';
|
||||||
|
|
||||||
@ -45,70 +45,72 @@ const eltReactions: IReactionEffect[] = [
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
...resetConf.map(
|
...resetConf.map(
|
||||||
({ insType, resetFields }) => (
|
({ insType, resetFields }) =>
|
||||||
calculationStore: ICalculationStore,
|
(
|
||||||
calculationProcess: TCalculationProcess,
|
calculationStore: ICalculationStore,
|
||||||
) => ({
|
calculationProcess: TCalculationProcess,
|
||||||
expression: () => {
|
) => ({
|
||||||
return calculationStore.getValues(
|
expression: () => {
|
||||||
(resetFields as ElementsNames[]).map(getValueName),
|
return calculationStore.getValues(
|
||||||
);
|
(resetFields as ElementsNames[]).map(getValueName),
|
||||||
},
|
);
|
||||||
effect: () => {
|
},
|
||||||
cancelRequests(insType);
|
effect: () => {
|
||||||
|
cancelRequests(insType);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
calculationProcess.hasProcess(Process.Init) ||
|
calculationProcess.hasProcess(Process.Init) ||
|
||||||
calculationProcess.hasProcess(Process.ELT) ||
|
calculationProcess.hasProcess(Process.ELT) ||
|
||||||
calculationProcess.hasProcess(Process.LoadKp)
|
calculationProcess.hasProcess(Process.LoadKp)
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { ELTStore } = calculationStore.stores;
|
const { ELTStore } = calculationStore.stores;
|
||||||
if (ELTStore[insType]?.isReseted()) {
|
if (ELTStore[insType]?.isReseted()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
message.warn({ content: RESET_MESSAGES[insType] });
|
message.warn({ content: RESET_MESSAGES[insType] });
|
||||||
resetIns.call(calculationStore, insType);
|
resetIns.call(calculationStore, insType);
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
|
||||||
...resetConf.map(
|
...resetConf.map(
|
||||||
({ insType, tableRowNumber }) => (
|
({ insType, tableRowNumber }) =>
|
||||||
calculationStore: ICalculationStore,
|
(
|
||||||
calculationProcess: TCalculationProcess,
|
calculationStore: ICalculationStore,
|
||||||
) => ({
|
calculationProcess: TCalculationProcess,
|
||||||
expression: () => {
|
) => ({
|
||||||
return [
|
expression: () => {
|
||||||
...['insuranceCompany', 'insCost'].map(
|
return [
|
||||||
fieldName =>
|
...['insuranceCompany', 'insCost'].map(
|
||||||
calculationStore.tables.tableInsurance.rows[tableRowNumber][
|
fieldName =>
|
||||||
fieldName
|
calculationStore.tables.tableInsurance.rows[tableRowNumber][
|
||||||
].value,
|
fieldName
|
||||||
),
|
].value,
|
||||||
];
|
),
|
||||||
},
|
];
|
||||||
effect: () => {
|
},
|
||||||
cancelRequests(insType);
|
effect: () => {
|
||||||
|
cancelRequests(insType);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
calculationProcess.hasProcess(Process.Init) ||
|
calculationProcess.hasProcess(Process.Init) ||
|
||||||
calculationProcess.hasProcess(Process.ELT) ||
|
calculationProcess.hasProcess(Process.ELT) ||
|
||||||
calculationProcess.hasProcess(Process.LoadKp)
|
calculationProcess.hasProcess(Process.LoadKp)
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { ELTStore } = calculationStore.stores;
|
const { ELTStore } = calculationStore.stores;
|
||||||
if (ELTStore[insType]?.isReseted()) {
|
if (ELTStore[insType]?.isReseted()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
message.warn({ content: RESET_MESSAGES[insType] });
|
message.warn({ content: RESET_MESSAGES[insType] });
|
||||||
resetIns.call(calculationStore, insType);
|
resetIns.call(calculationStore, insType);
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@ -1,20 +1,18 @@
|
|||||||
import { gql } from '@apollo/client';
|
import { gql } from '@apollo/client';
|
||||||
import { getValueName } from 'client/Containers/Calculation/lib/elements/tools';
|
import { getValueName } from 'client/Containers/Calculation/Elements/tools';
|
||||||
|
import { ElementsNames } from 'client/Containers/Calculation/types/elements';
|
||||||
import { openNotification } from 'client/Elements/Notification';
|
import { openNotification } from 'client/Elements/Notification';
|
||||||
import _1CService from 'core/services/1CService';
|
import _1CService from 'core/services/1CService';
|
||||||
import CrmService from 'core/services/CrmService';
|
import CrmService from 'core/services/CrmService';
|
||||||
|
import { IEvoTown } from 'core/services/CrmService/types/entities';
|
||||||
import { currentDate } from 'core/tools/date';
|
import { currentDate } from 'core/tools/date';
|
||||||
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
||||||
import {
|
|
||||||
ElementsNames,
|
|
||||||
TElements,
|
|
||||||
} from 'core/types/Calculation/Store/elements';
|
|
||||||
import { Process } from 'core/types/Calculation/Store/process';
|
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';
|
import { get } from 'lodash';
|
||||||
|
import { ElementStatus } from 'types/elements';
|
||||||
|
|
||||||
const v: TElements<any> = {
|
//TODO: beautify
|
||||||
|
const v = {
|
||||||
tbxVehicleTaxInYear: { value: 0, validator: value => value === 0 },
|
tbxVehicleTaxInYear: { value: 0, validator: value => value === 0 },
|
||||||
radioTypePTS: { value: null, validator: value => value === null },
|
radioTypePTS: { value: null, validator: value => value === null },
|
||||||
// selectObjectRegionRegistration: {
|
// selectObjectRegionRegistration: {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
|
import { ElementsNames } from 'client/Containers/Calculation/types/elements';
|
||||||
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
||||||
import { ElementsNames } from 'core/types/Calculation/Store/elements';
|
|
||||||
import { LinksNames } from 'core/types/Calculation/Store/links';
|
import { LinksNames } from 'core/types/Calculation/Store/links';
|
||||||
|
|
||||||
export default ([
|
export default ([
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,104 +1,107 @@
|
|||||||
|
import { IQuote } from 'core/services/CrmService/types/entities';
|
||||||
import { ValuesNames } from 'core/types/Calculation/Store/values';
|
import { ValuesNames } from 'core/types/Calculation/Store/values';
|
||||||
import { IQuote } from 'core/types/Entities/crmEntities';
|
|
||||||
|
|
||||||
const mapKPtoValues: Partial<Record<ValuesNames, keyof IQuote | string>> = {
|
const mapKPtoValues: Partial<Record<keyof IQuote | string, ValuesNames>> = {
|
||||||
product: 'evo_baseproductid',
|
evo_baseproductid: 'product',
|
||||||
clientType: 'evo_client_typeid',
|
evo_client_typeid: 'clientType',
|
||||||
leaseObjectPrice: 'evo_supplier_currency_price',
|
evo_supplier_currency_price: 'leaseObjectPrice',
|
||||||
supplierCurrency: 'evo_transactioncurrencyid',
|
evo_transactioncurrencyid: 'supplierCurrency',
|
||||||
supplierDiscountRub: 'evo_discount_supplier_currency',
|
evo_discount_supplier_currency: 'supplierDiscountRub',
|
||||||
supplierDiscountPerc: 'evo_discount_perc',
|
evo_discount_perc: 'supplierDiscountPerc',
|
||||||
firstPaymentPerc: 'evo_first_payment_perc',
|
evo_first_payment_perc: 'firstPaymentPerc',
|
||||||
lastPaymentRule: 'evo_last_payment_calc',
|
evo_last_payment_calc: 'lastPaymentRule',
|
||||||
lastPaymentPerc: 'evo_last_payment_perc',
|
evo_last_payment_perc: 'lastPaymentPerc',
|
||||||
lastPaymentRub: 'evo_last_payment_rub',
|
evo_last_payment_rub: 'lastPaymentRub',
|
||||||
// balanceHolder: 'evo_balance_holder',
|
// evo_balance_holder: 'balanceHolder',
|
||||||
graphType: 'evo_graph_type',
|
evo_graph_type: 'graphType',
|
||||||
parmentsDecreasePercent: 'evo_payments_decrease_perc',
|
evo_payments_decrease_perc: 'parmentsDecreasePercent',
|
||||||
seasonType: 'evo_seasons_type',
|
evo_seasons_type: 'seasonType',
|
||||||
highSeasonStart: 'evo_high_season',
|
evo_high_season: 'highSeasonStart',
|
||||||
comissionPerc: 'evo_comission_perc',
|
evo_comission_perc: 'comissionPerc',
|
||||||
comissionRub: 'evo_comission_rub',
|
evo_comission_rub: 'comissionRub',
|
||||||
saleBonus: 'evo_sale_bonus',
|
evo_sale_bonus: 'saleBonus',
|
||||||
leasingPeriod: 'evo_period',
|
evo_period: 'leasingPeriod',
|
||||||
tarif: 'evo_tarifid',
|
evo_tarifid: 'tarif',
|
||||||
// creditRate: 'evo_rate',
|
// evo_rate: 'creditRate',
|
||||||
IRR_Perc: 'evo_msfo_irr',
|
evo_msfo_irr: 'IRR_Perc',
|
||||||
leaseObjectType: 'evo_leasingobject_typeid',
|
evo_leasingobject_typeid: 'leaseObjectType',
|
||||||
deliveryTime: 'evo_delivery_time',
|
evo_delivery_time: 'deliveryTime',
|
||||||
brand: 'evo_brandid',
|
evo_brandid: 'brand',
|
||||||
model: 'evo_modelid',
|
evo_modelid: 'model',
|
||||||
configuration: 'evo_equipmentid',
|
evo_equipmentid: 'configuration',
|
||||||
leaseObjectYear: 'evo_year',
|
evo_year: 'leaseObjectYear',
|
||||||
engineType: 'evo_engine_type',
|
evo_engine_type: 'engineType',
|
||||||
leaseObjectCategory: 'evo_category',
|
evo_category: 'leaseObjectCategory',
|
||||||
leaseObjectMotorPower: 'evo_power',
|
evo_power: 'leaseObjectMotorPower',
|
||||||
engineVolume: 'evo_engine_volume',
|
evo_engine_volume: 'engineVolume',
|
||||||
leaseObjectUseFor: 'evo_use_for',
|
evo_use_for: 'leaseObjectUseFor',
|
||||||
withTrailer: 'evo_trailer',
|
evo_trailer: 'withTrailer',
|
||||||
leaseObjectUsed: 'evo_leasingobject_used',
|
evo_leasingobject_used: 'leaseObjectUsed',
|
||||||
maxMass: 'evo_max_mass',
|
evo_max_mass: 'maxMass',
|
||||||
countSeats: 'evo_seats',
|
evo_seats: 'countSeats',
|
||||||
maxSpeed: 'evo_max_speed',
|
evo_max_speed: 'maxSpeed',
|
||||||
dealer: 'evo_supplier_accountid',
|
evo_supplier_accountid: 'dealer',
|
||||||
dealerPerson: 'evo_dealer_person_accountid',
|
evo_dealer_person_accountid: 'dealerPerson',
|
||||||
dealerRewardCondition: 'evo_dealer_reward_conditionid',
|
evo_dealer_reward_conditionid: 'dealerRewardCondition',
|
||||||
dealerRewardSumm: 'evo_dealer_reward_total',
|
evo_dealer_reward_total: 'dealerRewardSumm',
|
||||||
dealerBroker: 'evo_dealer_broker_accountid',
|
evo_dealer_broker_accountid: 'dealerBroker',
|
||||||
dealerBrokerRewardCondition: 'evo_dealer_broker_reward_conditionid',
|
evo_dealer_broker_reward_conditionid: 'dealerBrokerRewardCondition',
|
||||||
dealerBrokerRewardSumm: 'evo_dealer_broker_reward_total',
|
evo_dealer_broker_reward_total: 'dealerBrokerRewardSumm',
|
||||||
// indAgent: 'evo_agent_accountid',
|
// evo_agent_accountid: indAgent,
|
||||||
// indAgentRewardCondition: 'evo_agent_reward_conditionid',
|
// evo_agent_reward_conditionid: 'indAgentRewardCondition',
|
||||||
// indAgentRewardSumm: 'evo_agent_reward_total',
|
// evo_agent_reward_total: indAgentRewardSumm,
|
||||||
calcDoubleAgent: 'evo_double_agent_accountid',
|
evo_double_agent_accountid: 'calcDoubleAgent',
|
||||||
calcDoubleAgentRewardCondition: 'evo_double_agent_reward_conditionid',
|
evo_double_agent_reward_conditionid: 'calcDoubleAgentRewardCondition',
|
||||||
calcDoubleAgentRewardSumm: 'evo_double_agent_reward_total',
|
evo_double_agent_reward_total: 'calcDoubleAgentRewardSumm',
|
||||||
// calcBroker: 'evo_broker_accountid',
|
// evo_broker_accountid: 'calcBroker',
|
||||||
// calcBrokerRewardCondition: 'evo_broker_reward_conditionid',
|
// evo_broker_reward_conditionid: 'calcBrokerRewardCondition',
|
||||||
// calcBrokerRewardSum: 'evo_broker_reward_total',
|
// evo_broker_reward_total: 'calcBrokerRewardSum',
|
||||||
// calcFinDepartment: 'evo_fin_department_accountid',
|
// evo_fin_department_accountid: 'calcFinDepartment',
|
||||||
// finDepartmentRewardCondtion: 'evo_fin_department_reward_conditionid',
|
// evo_fin_department_reward_conditionid: 'finDepartmentRewardCondtion',
|
||||||
// finDepartmentRewardSumm: 'evo_fin_department_reward_total',
|
// evo_fin_department_reward_total: 'finDepartmentRewardSumm'
|
||||||
GPSBrand: 'evo_gps_brandid',
|
evo_gps_brandid: 'GPSBrand',
|
||||||
GPSModel: 'evo_gps_modelid',
|
evo_gps_modelid: 'GPSModel',
|
||||||
infuranceOPF: 'evo_ins_legal_form',
|
evo_ins_legal_form: 'infuranceOPF',
|
||||||
insKaskoType: 'evo_insurance_type',
|
evo_insurance_type: 'insKaskoType',
|
||||||
insKaskoPriceLeasePeriod: 'evo_kasko_price_leasperiod',
|
evo_insurance_decentral: 'insDecentral',
|
||||||
insDecentral: 'evo_insurance_decentral',
|
evo_franchise: 'insFranchise',
|
||||||
insPeriod: 'evo_insurance_period',
|
evo_unlimit_drivers: 'insUnlimitDrivers',
|
||||||
insFranchise: 'evo_franchise',
|
evo_age_drivers: 'insAgeDrivers',
|
||||||
insUnlimitDrivers: 'evo_unlimit_drivers',
|
evo_exp_drivers: 'insExpDrivers',
|
||||||
insAgeDrivers: 'evo_age_drivers',
|
evo_last_payment_redemption: 'lastPaymentRedemption',
|
||||||
insExpDrivers: 'evo_exp_drivers',
|
evo_price_with_discount: 'priceWithDiscount',
|
||||||
lastPaymentRedemption: 'evo_last_payment_redemption',
|
evo_cost_increace: 'costIncrease',
|
||||||
priceWithDiscount: 'evo_price_with_discount',
|
evo_insurance: 'insurance',
|
||||||
costIncrease: 'evo_cost_increace',
|
evo_registration_quote: 'registrationQuote',
|
||||||
insurance: 'evo_insurance',
|
evo_card_quote: 'technicalCardQuote',
|
||||||
registrationQuote: 'evo_registration_quote',
|
evo_nsib_quote: 'NSIB',
|
||||||
technicalCardQuote: 'evo_card_quote',
|
evo_contact_name: 'quoteName',
|
||||||
NSIB: 'evo_nsib_quote',
|
evo_gender: 'quoteContactGender',
|
||||||
quoteName: 'evo_contact_name',
|
evo_redemption_graph: 'quoteRedemptionGraph',
|
||||||
quoteContactGender: 'evo_gender',
|
evo_min_change_price: 'minPriceChange',
|
||||||
quoteRedemptionGraph: 'evo_redemption_graph',
|
evo_max_price_change: 'maxPriceChange',
|
||||||
minPriceChange: 'evo_min_change_price',
|
evo_importer_reward_perc: 'importerRewardPerc',
|
||||||
maxPriceChange: 'evo_max_price_change',
|
evo_importer_reward_rub: 'importerRewardRub',
|
||||||
importerRewardPerc: 'evo_importer_reward_perc',
|
// evo_req_telematic_accept: 'requirementTelematic',
|
||||||
importerRewardRub: 'evo_importer_reward_rub',
|
evo_mileage: 'mileage',
|
||||||
// requirementTelematic: 'evo_req_telematic_accept',
|
evo_price_without_discount_quote: 'fullPriceWithDiscount',
|
||||||
mileage: 'evo_mileage',
|
evo_object_registration: 'objectRegistration',
|
||||||
fullPriceWithDiscount: 'evo_price_without_discount_quote',
|
evo_registration_regionid: 'objectRegionRegistration',
|
||||||
objectRegistration: 'evo_object_registration',
|
// evo_vehicle_tax_approved: vehicleTaxInYear,
|
||||||
objectRegionRegistration: 'evo_registration_regionid',
|
evo_category_tr: 'objectCategoryTax',
|
||||||
// vehicleTaxInYear: 'evo_vehicle_tax_approved',
|
evo_vehicle_type_tax: 'objectTypeTax',
|
||||||
objectCategoryTax: 'evo_category_tr',
|
evo_pts_type: 'typePTS',
|
||||||
objectTypeTax: 'evo_vehicle_type_tax',
|
evo_subsidyid: 'subsidy',
|
||||||
typePTS: 'evo_pts_type',
|
evo_subsidy_summ: 'subsidySum',
|
||||||
subsidy: 'evo_subsidyid',
|
|
||||||
subsidySum: 'evo_subsidy_summ',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getKpPropName = (
|
export function getValuesFromKP(quote: IQuote) {
|
||||||
valueName: ValuesNames,
|
return Object.keys(mapKPtoValues).reduce((acc, kpProp) => {
|
||||||
): keyof IQuote | string | undefined => mapKPtoValues[valueName];
|
const valueName = mapKPtoValues[kpProp];
|
||||||
|
if (valueName) {
|
||||||
export default mapKPtoValues;
|
const value = quote[kpProp];
|
||||||
|
acc[valueName] = value;
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, {} as Partial<Record<ValuesNames, any>>);
|
||||||
|
}
|
||||||
|
|||||||
@ -3,24 +3,10 @@ import valuesConstants from 'core/constants/values';
|
|||||||
import { pipe } from 'core/tools/func';
|
import { pipe } from 'core/tools/func';
|
||||||
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
||||||
import { Process } from 'core/types/Calculation/Store/process';
|
import { Process } from 'core/types/Calculation/Store/process';
|
||||||
import { ElementStatus } from 'core/types/statuses';
|
|
||||||
import { get, intersection, round } from 'lodash';
|
import { get, intersection, round } from 'lodash';
|
||||||
|
import { ElementStatus } from 'types/elements';
|
||||||
|
|
||||||
const reactionEffects: IReactionEffect[] = [
|
const reactionEffects: IReactionEffect[] = [
|
||||||
// calculationStore => ({
|
|
||||||
// expression: () => {
|
|
||||||
// const { options } = calculationStore;
|
|
||||||
// return options.selectQuote;
|
|
||||||
// },
|
|
||||||
// effect: quotes => {
|
|
||||||
// if (quotes.length > 0) {
|
|
||||||
// calculationStore.setStatus('tbxQuoteName', Status.Disabled);
|
|
||||||
// } else {
|
|
||||||
// calculationStore.setStatus('tbxQuoteName', Status.Default);
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// }),
|
|
||||||
|
|
||||||
calculationStore => ({
|
calculationStore => ({
|
||||||
expression: () => {
|
expression: () => {
|
||||||
const { opportunity } = calculationStore.values;
|
const { opportunity } = calculationStore.values;
|
||||||
@ -37,131 +23,6 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
calculationStore => ({
|
|
||||||
expression: () => {
|
|
||||||
const { agent } = calculationStore.values;
|
|
||||||
return agent;
|
|
||||||
},
|
|
||||||
effect: agentid => {
|
|
||||||
if (!agentid) {
|
|
||||||
calculationStore.setStatus('selectDoubleAgent', ElementStatus.Disabled);
|
|
||||||
} else {
|
|
||||||
calculationStore.setStatus('selectDoubleAgent', ElementStatus.Default);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
|
|
||||||
calculationStore => ({
|
|
||||||
expression: () => {
|
|
||||||
const { channel } = calculationStore.values;
|
|
||||||
return channel;
|
|
||||||
},
|
|
||||||
effect: channel => {
|
|
||||||
switch (channel) {
|
|
||||||
case 100000000:
|
|
||||||
calculationStore.setStatus('selectSupplier', ElementStatus.Default);
|
|
||||||
calculationStore.setStatus('selectAgent', ElementStatus.Default);
|
|
||||||
|
|
||||||
calculationStore.setStatus(
|
|
||||||
'selectFinDepartment',
|
|
||||||
ElementStatus.Disabled,
|
|
||||||
);
|
|
||||||
calculationStore.setValue('finDepartment', null);
|
|
||||||
|
|
||||||
calculationStore.setStatus('selectBroker', ElementStatus.Disabled);
|
|
||||||
calculationStore.setValue('broker', null);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 100000001:
|
|
||||||
calculationStore.setStatus('selectSupplier', ElementStatus.Default);
|
|
||||||
calculationStore.setStatus('selectAgent', ElementStatus.Default);
|
|
||||||
|
|
||||||
calculationStore.setStatus(
|
|
||||||
'selectFinDepartment',
|
|
||||||
ElementStatus.Default,
|
|
||||||
);
|
|
||||||
|
|
||||||
calculationStore.setStatus('selectBroker', ElementStatus.Disabled);
|
|
||||||
calculationStore.setValue('broker', null);
|
|
||||||
break;
|
|
||||||
case 100000002:
|
|
||||||
calculationStore.setStatus('selectSupplier', ElementStatus.Disabled);
|
|
||||||
calculationStore.setValue('supplier', null);
|
|
||||||
|
|
||||||
calculationStore.setStatus('selectAgent', ElementStatus.Default);
|
|
||||||
|
|
||||||
calculationStore.setStatus(
|
|
||||||
'selectFinDepartment',
|
|
||||||
ElementStatus.Disabled,
|
|
||||||
);
|
|
||||||
calculationStore.setValue('finDepartment', null);
|
|
||||||
|
|
||||||
calculationStore.setStatus('selectBroker', ElementStatus.Disabled);
|
|
||||||
calculationStore.setValue('broker', null);
|
|
||||||
break;
|
|
||||||
case 100000003:
|
|
||||||
calculationStore.setStatus('selectSupplier', ElementStatus.Disabled);
|
|
||||||
calculationStore.setValue('supplier', null);
|
|
||||||
|
|
||||||
calculationStore.setStatus('selectAgent', ElementStatus.Default);
|
|
||||||
calculationStore.setValue('agent', null);
|
|
||||||
|
|
||||||
calculationStore.setStatus(
|
|
||||||
'selectFinDepartment',
|
|
||||||
ElementStatus.Disabled,
|
|
||||||
);
|
|
||||||
calculationStore.setValue('finDepartment', null);
|
|
||||||
|
|
||||||
calculationStore.setStatus('selectBroker', ElementStatus.Default);
|
|
||||||
break;
|
|
||||||
case 100000004:
|
|
||||||
default:
|
|
||||||
calculationStore.setStatus('selectSupplier', ElementStatus.Disabled);
|
|
||||||
calculationStore.setValue('supplier', null);
|
|
||||||
|
|
||||||
calculationStore.setStatus('selectAgent', ElementStatus.Disabled);
|
|
||||||
calculationStore.setValue('agent', null);
|
|
||||||
|
|
||||||
calculationStore.setStatus(
|
|
||||||
'selectFinDepartment',
|
|
||||||
ElementStatus.Disabled,
|
|
||||||
);
|
|
||||||
calculationStore.setValue('finDepartment', null);
|
|
||||||
|
|
||||||
calculationStore.setStatus('selectBroker', ElementStatus.Disabled);
|
|
||||||
calculationStore.setValue('broker', null);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
options: {
|
|
||||||
fireImmediately: true,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
|
|
||||||
calculationStore => ({
|
|
||||||
expression: () => {
|
|
||||||
const { newClient } = calculationStore.values;
|
|
||||||
return newClient;
|
|
||||||
},
|
|
||||||
effect: newClient => {
|
|
||||||
if (newClient && newClient.length > 0) {
|
|
||||||
calculationStore.setValue('account', null);
|
|
||||||
calculationStore.setValue('contactClient', null);
|
|
||||||
calculationStore.setStatus('selectAccount', ElementStatus.Disabled);
|
|
||||||
calculationStore.setStatus(
|
|
||||||
'selectContactClient',
|
|
||||||
ElementStatus.Disabled,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
calculationStore.setStatus('selectAccount', ElementStatus.Default);
|
|
||||||
calculationStore.setStatus(
|
|
||||||
'selectContactClient',
|
|
||||||
ElementStatus.Default,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
|
|
||||||
(calculationStore, calculationProcess) => ({
|
(calculationStore, calculationProcess) => ({
|
||||||
expression: () => {
|
expression: () => {
|
||||||
const { indAgentRewardCondition } = calculationStore.values;
|
const { indAgentRewardCondition } = calculationStore.values;
|
||||||
@ -578,50 +439,6 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
calculationStore => ({
|
|
||||||
expression: () => {
|
|
||||||
const { insUnlimitDrivers } = calculationStore.values;
|
|
||||||
return insUnlimitDrivers;
|
|
||||||
},
|
|
||||||
effect: insUnlimitDrivers => {
|
|
||||||
if (insUnlimitDrivers) {
|
|
||||||
calculationStore.setStatus('tbxInsAgeDrivers', ElementStatus.Disabled);
|
|
||||||
calculationStore.setStatus('tbxInsExpDrivers', ElementStatus.Disabled);
|
|
||||||
calculationStore.setStatus(
|
|
||||||
'btnDriversApplication',
|
|
||||||
ElementStatus.Disabled,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
calculationStore.setStatus('tbxInsAgeDrivers', ElementStatus.Default);
|
|
||||||
calculationStore.setStatus('tbxInsExpDrivers', ElementStatus.Default);
|
|
||||||
calculationStore.setStatus(
|
|
||||||
'btnDriversApplication',
|
|
||||||
ElementStatus.Default,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
options: {
|
|
||||||
fireImmediately: true,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
|
|
||||||
calculationStore => ({
|
|
||||||
expression: () => {
|
|
||||||
const { insFranchise } = calculationStore.values;
|
|
||||||
return insFranchise;
|
|
||||||
},
|
|
||||||
effect: insFranchise => {
|
|
||||||
if (!insFranchise || parseInt(insFranchise) === 0) {
|
|
||||||
calculationStore.setStatus('btnFranschise', ElementStatus.Disabled);
|
|
||||||
} else {
|
|
||||||
calculationStore.setStatus('btnFranschise', ElementStatus.Default);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
options: {
|
|
||||||
fireImmediately: true,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
|
|
||||||
calculationStore => ({
|
calculationStore => ({
|
||||||
expression: () => {
|
expression: () => {
|
||||||
const { lastPaymentRule } = calculationStore.values;
|
const { lastPaymentRule } = calculationStore.values;
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
import { getFieldName } from 'client/Containers/Calculation/lib/elements/tools';
|
import { getFieldName } from 'client/Containers/Calculation/Elements/tools';
|
||||||
|
import { InteractionElementsNames } from 'client/Containers/Calculation/types/elements';
|
||||||
|
import { TableNames } from 'client/Containers/Calculation/types/tables';
|
||||||
import { openNotification } from 'client/Elements/Notification';
|
import { openNotification } from 'client/Elements/Notification';
|
||||||
import valuesConstants from 'core/constants/values';
|
import valuesConstants from 'core/constants/values';
|
||||||
import { pipe } from 'core/tools/func';
|
import { pipe } from 'core/tools/func';
|
||||||
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
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 { Process } from 'core/types/Calculation/Store/process';
|
||||||
import { TableNames } from 'core/types/Calculation/Store/tables';
|
|
||||||
import { ValuesNames } from 'core/types/Calculation/Store/values';
|
import { ValuesNames } from 'core/types/Calculation/Store/values';
|
||||||
import { ElementStatus } from 'core/types/statuses';
|
import { ElementStatus } from 'types/elements';
|
||||||
import { convertPrice } from '../lib/tools';
|
import { convertPrice } from '../lib/tools';
|
||||||
import { getPrice } from './priceReactions/calculate';
|
import { getPrice } from './priceReactions/calculate';
|
||||||
|
|
||||||
@ -265,11 +265,8 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
|
|
||||||
calculationStore => ({
|
calculationStore => ({
|
||||||
expression: () => {
|
expression: () => {
|
||||||
const {
|
const { countSeats, leaseObjectCategory, recalcWithRevision } =
|
||||||
countSeats,
|
calculationStore.values;
|
||||||
leaseObjectCategory,
|
|
||||||
recalcWithRevision,
|
|
||||||
} = calculationStore.values;
|
|
||||||
return {
|
return {
|
||||||
countSeats,
|
countSeats,
|
||||||
leaseObjectCategory,
|
leaseObjectCategory,
|
||||||
@ -579,7 +576,7 @@ const map_add_product_types_to_values = {
|
|||||||
telematics: 100000004,
|
telematics: 100000004,
|
||||||
};
|
};
|
||||||
|
|
||||||
const elementsToDisable: (ElementsNames | TableNames)[] = [
|
const elementsToDisable: (InteractionElementsNames | TableNames)[] = [
|
||||||
'tablePayments',
|
'tablePayments',
|
||||||
'selectLead',
|
'selectLead',
|
||||||
'selectOpportunity',
|
'selectOpportunity',
|
||||||
@ -605,7 +602,6 @@ const elementsToDisable: (ElementsNames | TableNames)[] = [
|
|||||||
'selectIndAgent',
|
'selectIndAgent',
|
||||||
'selectCalcBroker',
|
'selectCalcBroker',
|
||||||
'selectCalcFinDepartment',
|
'selectCalcFinDepartment',
|
||||||
'tbxInsKaskoPriceLeasePeriod',
|
|
||||||
'selectTarif',
|
'selectTarif',
|
||||||
'tbxCreditRate',
|
'tbxCreditRate',
|
||||||
'selectRate',
|
'selectRate',
|
||||||
@ -620,7 +616,7 @@ const elementsToDisable: (ElementsNames | TableNames)[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
// Для recalc = true и первого платежа = 0
|
// Для recalc = true и первого платежа = 0
|
||||||
const agentsElementsToDisable: ElementsNames[] = [
|
const agentsElementsToDisable: InteractionElementsNames[] = [
|
||||||
'selectDealerRewardCondition',
|
'selectDealerRewardCondition',
|
||||||
'tbxDealerRewardSumm',
|
'tbxDealerRewardSumm',
|
||||||
'selectDealerBroker',
|
'selectDealerBroker',
|
||||||
|
|||||||
@ -1,9 +1,6 @@
|
|||||||
import { gql } from '@apollo/client';
|
import { gql } from '@apollo/client';
|
||||||
import { getQuotesByLeadQuery } from 'core/graphql/query/crm/quote';
|
|
||||||
import CrmService from 'core/services/CrmService';
|
import CrmService from 'core/services/CrmService';
|
||||||
import { currentISODate } from 'core/tools/date';
|
import { quotesByLeadQuery } from 'core/services/CrmService/graphql/query/quote';
|
||||||
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
|
||||||
import { Process } from 'core/types/Calculation/Store/process';
|
|
||||||
import {
|
import {
|
||||||
IAccount,
|
IAccount,
|
||||||
IEvoEquipment,
|
IEvoEquipment,
|
||||||
@ -13,8 +10,11 @@ import {
|
|||||||
IEvoTown,
|
IEvoTown,
|
||||||
IQuote,
|
IQuote,
|
||||||
ISalonProvider,
|
ISalonProvider,
|
||||||
} from 'core/types/Entities/crmEntities';
|
} from 'core/services/CrmService/types/entities';
|
||||||
import { ElementStatus } from 'core/types/statuses';
|
import { currentISODate } from 'core/tools/date';
|
||||||
|
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
||||||
|
import { Process } from 'core/types/Calculation/Store/process';
|
||||||
|
import { ElementStatus } from 'types/elements';
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
(calculationStore, calculationProcess) => ({
|
(calculationStore, calculationProcess) => ({
|
||||||
@ -51,7 +51,7 @@ export default [
|
|||||||
|
|
||||||
if (lead?.leadid) {
|
if (lead?.leadid) {
|
||||||
CrmService.getCRMOptions<'quotes', IQuote>({
|
CrmService.getCRMOptions<'quotes', IQuote>({
|
||||||
query: getQuotesByLeadQuery,
|
query: quotesByLeadQuery,
|
||||||
variables: {
|
variables: {
|
||||||
leadid: lead?.leadid,
|
leadid: lead?.leadid,
|
||||||
},
|
},
|
||||||
@ -259,24 +259,6 @@ export default [
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
(calculationStore, calculationProcess) => ({
|
|
||||||
expression: () => {
|
|
||||||
const { account } = calculationStore.values;
|
|
||||||
return account;
|
|
||||||
},
|
|
||||||
effect: account => {
|
|
||||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (account && account.length > 0) {
|
|
||||||
calculationStore.setStatus('tbxNewClient', ElementStatus.Disabled);
|
|
||||||
calculationStore.setValue('newClient', null);
|
|
||||||
} else {
|
|
||||||
calculationStore.setStatus('tbxNewClient', ElementStatus.Default);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
|
|
||||||
(calculationStore, calculationProcess) => ({
|
(calculationStore, calculationProcess) => ({
|
||||||
expression: () => {
|
expression: () => {
|
||||||
const { indAgent } = calculationStore.values;
|
const { indAgent } = calculationStore.values;
|
||||||
@ -899,113 +881,6 @@ export default [
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
(calculationStore, calculationProcess) => ({
|
|
||||||
expression: () => {
|
|
||||||
const { supplier } = calculationStore.values;
|
|
||||||
return supplier;
|
|
||||||
},
|
|
||||||
effect: supplierId => {
|
|
||||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
calculationStore.setOptions('selectFinDepartment', []);
|
|
||||||
calculationStore.setValue('finDepartment', null);
|
|
||||||
if (supplierId) {
|
|
||||||
const supplier = calculationStore.getOption('selectSupplier', {
|
|
||||||
accountid: supplierId,
|
|
||||||
});
|
|
||||||
if (supplier && supplier.evo_fin_department_accountid)
|
|
||||||
CrmService.getCRMOptions<'accountOptions', IAccount>({
|
|
||||||
query: gql`
|
|
||||||
query selectFinDepartment($accountid: Uuid!) {
|
|
||||||
accountOptions: account(accountid: $accountid) {
|
|
||||||
accountid
|
|
||||||
name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
variables: {
|
|
||||||
accountid: supplier.evo_fin_department_accountid,
|
|
||||||
},
|
|
||||||
}).then(({ accountOptions }) => {
|
|
||||||
if (accountOptions) {
|
|
||||||
calculationStore.setOptions(
|
|
||||||
'selectFinDepartment',
|
|
||||||
accountOptions,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
(calculationStore, calculationProcess) => ({
|
|
||||||
expression: () => {
|
|
||||||
const { supplier, channel } = calculationStore.values;
|
|
||||||
return { supplierId: supplier, channelId: channel };
|
|
||||||
},
|
|
||||||
//TODO: add $ownerid: Uuid
|
|
||||||
effect: ({ supplierId, channelId }) => {
|
|
||||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
calculationStore.setOptions('selectAgent', []);
|
|
||||||
calculationStore.setValue('agent', null);
|
|
||||||
if (channelId === 100000002) {
|
|
||||||
CrmService.getCRMOptions<'accountOptions', IAccount>({
|
|
||||||
query: gql`
|
|
||||||
query selectAgent_1(
|
|
||||||
$statecode: Int
|
|
||||||
$evo_account_type: [Int!]
|
|
||||||
$evo_legal_form: Int
|
|
||||||
) {
|
|
||||||
accountOptions: accounts(
|
|
||||||
statecode: $statecode
|
|
||||||
evo_account_type: $evo_account_type
|
|
||||||
evo_legal_form: $evo_legal_form
|
|
||||||
) {
|
|
||||||
accountid
|
|
||||||
name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
variables: {
|
|
||||||
statecode: 0,
|
|
||||||
evo_account_type: [100000005],
|
|
||||||
evo_legal_form: 100000004,
|
|
||||||
},
|
|
||||||
}).then(({ accountOptions }) => {
|
|
||||||
if (accountOptions) {
|
|
||||||
calculationStore.setOptions('selectAgent', accountOptions);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if (supplierId) {
|
|
||||||
CrmService.getCRMOptions<'accountOptions', IAccount>({
|
|
||||||
query: gql`
|
|
||||||
query selectAgent_2($statecode: Int, $salonaccountid: Uuid!) {
|
|
||||||
account: salon_agents(
|
|
||||||
statecode: $statecode
|
|
||||||
salonaccountid: $salonaccountid
|
|
||||||
) {
|
|
||||||
accountid
|
|
||||||
name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
variables: {
|
|
||||||
statecode: 0,
|
|
||||||
salonaccountid: supplierId,
|
|
||||||
},
|
|
||||||
}).then(({ accountOptions }) => {
|
|
||||||
if (accountOptions) {
|
|
||||||
calculationStore.setOptions('selectAgent', accountOptions);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
|
|
||||||
(calculationStore, calculationProcess) => ({
|
(calculationStore, calculationProcess) => ({
|
||||||
expression: () => {
|
expression: () => {
|
||||||
const { GPSBrand } = calculationStore.values;
|
const { GPSBrand } = calculationStore.values;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
|
import { ElementsNames } from 'client/Containers/Calculation/types/elements';
|
||||||
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
||||||
import { ElementsNames } from 'core/types/Calculation/Store/elements';
|
import { ElementStatus } from 'types/elements';
|
||||||
import { ElementStatus } from 'core/types/statuses';
|
|
||||||
|
|
||||||
const elementsNames: ElementsNames[] = [
|
const elementsNames: ElementsNames[] = [
|
||||||
'selectModel',
|
'selectModel',
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
import { Table } from 'client/Containers/Calculation/types/tables';
|
||||||
import { openNotification } from 'client/Elements/Notification';
|
import { openNotification } from 'client/Elements/Notification';
|
||||||
import {
|
import {
|
||||||
insuranceKaskoDefaultFilter,
|
insuranceKaskoDefaultFilter,
|
||||||
@ -9,9 +9,9 @@ import valuesConstants from 'core/constants/values';
|
|||||||
import { shift, shiftRight } from 'core/tools/array';
|
import { shift, shiftRight } from 'core/tools/array';
|
||||||
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
||||||
import { Process } from 'core/types/Calculation/Store/process';
|
import { Process } from 'core/types/Calculation/Store/process';
|
||||||
import { ITableCell, TableProps } from 'core/types/Calculation/Store/tables';
|
|
||||||
import { ElementStatus } from 'core/types/statuses';
|
|
||||||
import { toJS } from 'mobx';
|
import { toJS } from 'mobx';
|
||||||
|
import { ElementStatus } from 'types/elements';
|
||||||
|
|
||||||
const { PERIODS_NUMBER } = valuesConstants;
|
const { PERIODS_NUMBER } = valuesConstants;
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
@ -122,9 +122,8 @@ export default [
|
|||||||
},
|
},
|
||||||
effect: ({ insTerm, leasingPeriod }) => {
|
effect: ({ insTerm, leasingPeriod }) => {
|
||||||
const quote = calculationStore.getOption('selectQuote');
|
const quote = calculationStore.getOption('selectQuote');
|
||||||
const recalcWithRevision = calculationStore.getValue(
|
const recalcWithRevision =
|
||||||
'recalcWithRevision',
|
calculationStore.getValue('recalcWithRevision');
|
||||||
);
|
|
||||||
if (
|
if (
|
||||||
recalcWithRevision &&
|
recalcWithRevision &&
|
||||||
quote?.evo_one_year_insurance &&
|
quote?.evo_one_year_insurance &&
|
||||||
@ -406,12 +405,8 @@ export default [
|
|||||||
|
|
||||||
(calculationStore, calculationProcess) => ({
|
(calculationStore, calculationProcess) => ({
|
||||||
expression: () => {
|
expression: () => {
|
||||||
const {
|
const { leasingPeriod, graphType, parmentsDecreasePercent, seasonType } =
|
||||||
leasingPeriod,
|
calculationStore.values;
|
||||||
graphType,
|
|
||||||
parmentsDecreasePercent,
|
|
||||||
seasonType,
|
|
||||||
} = calculationStore.values;
|
|
||||||
|
|
||||||
const highSeasonStart = calculationStore.getOption(
|
const highSeasonStart = calculationStore.getOption(
|
||||||
'selectHighSeasonStart',
|
'selectHighSeasonStart',
|
||||||
@ -442,7 +437,7 @@ export default [
|
|||||||
const prevValues = toJS(calculationStore.tables.tablePayments.rows).map(
|
const prevValues = toJS(calculationStore.tables.tablePayments.rows).map(
|
||||||
x => x.paymentRelation?.value,
|
x => x.paymentRelation?.value,
|
||||||
);
|
);
|
||||||
let payments: TableProps<ITableCell>[] = [
|
let payments: Table['rows'] = [
|
||||||
{
|
{
|
||||||
paymentRelation: {
|
paymentRelation: {
|
||||||
value: firstPaymentPerc,
|
value: firstPaymentPerc,
|
||||||
@ -753,7 +748,8 @@ export default [
|
|||||||
const prevIsTrailer = prevLeaseObjectCategory === 100000004;
|
const prevIsTrailer = prevLeaseObjectCategory === 100000004;
|
||||||
|
|
||||||
if (nextIsTrailer) {
|
if (nextIsTrailer) {
|
||||||
const otherInsuranceCompany = calculationStore.tables.tableInsurance.options?.insuranceCompany?.find(
|
const otherInsuranceCompany =
|
||||||
|
calculationStore.tables.tableInsurance.options?.insuranceCompany?.find(
|
||||||
x => x.name?.includes('ПРОЧИЕ'),
|
x => x.name?.includes('ПРОЧИЕ'),
|
||||||
);
|
);
|
||||||
if (otherInsuranceCompany) {
|
if (otherInsuranceCompany) {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { initIns } from 'client/Components/Calculation/ELT/Content/lib/resetIns';
|
import { initIns } from 'client/Containers/Calculation/Components/ELT/lib/resetIns';
|
||||||
import { IWhenEffect } from 'core/types/Calculation/Store/effect';
|
import { IWhenEffect } from 'core/types/Calculation/Store/effect';
|
||||||
|
|
||||||
const whenEffects: IWhenEffect[] = [
|
const whenEffects: IWhenEffect[] = [
|
||||||
|
|||||||
@ -1,10 +1,7 @@
|
|||||||
import {
|
import { ElementsNames } from 'client/Containers/Calculation/types/elements';
|
||||||
ElementsNames,
|
|
||||||
TElements,
|
|
||||||
} from 'core/types/Calculation/Store/elements';
|
|
||||||
import { TElementFilter } from 'core/types/Calculation/Store/filters';
|
import { TElementFilter } from 'core/types/Calculation/Store/filters';
|
||||||
|
|
||||||
const initialFilters: TElements<TElementFilter> = {};
|
const initialFilters: Partial<Record<ElementsNames, TElementFilter>> = {};
|
||||||
|
|
||||||
export const noResetValueElements: ElementsNames[] = ['selectTechnicalCard'];
|
export const noResetValueElements: ElementsNames[] = ['selectTechnicalCard'];
|
||||||
|
|
||||||
|
|||||||
@ -1,42 +1,8 @@
|
|||||||
|
import { ElementsNames } from 'client/Containers/Calculation/types/elements';
|
||||||
import { IBaseOption } from 'core/services/CrmService/types/common';
|
import { IBaseOption } from 'core/services/CrmService/types/common';
|
||||||
import { TElements } from 'core/types/Calculation/Store/elements';
|
|
||||||
import { orderBy } from 'lodash';
|
import { orderBy } from 'lodash';
|
||||||
|
|
||||||
const initialOptions: TElements<IBaseOption[]> = {
|
const initialOptions: Partial<Record<ElementsNames, IBaseOption[]>> = {
|
||||||
selectChannel: [
|
|
||||||
{
|
|
||||||
name: 'От агента-ФЛ-сотрудника поставщика',
|
|
||||||
value: 100000000,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Поставщик (финотдел)',
|
|
||||||
value: 100000001,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'От агента-ФЛ (не сотрудник поставщика)',
|
|
||||||
value: 100000002,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Брокер (ЮЛ/ИП не связан с поставщиком)',
|
|
||||||
value: 100000003,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Прочее',
|
|
||||||
value: 100000004,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
radioContactGender: [
|
|
||||||
{
|
|
||||||
name: 'Мужской',
|
|
||||||
value: 100000000,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Женский',
|
|
||||||
value: 100000001,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
radioLastPaymentRule: [
|
radioLastPaymentRule: [
|
||||||
{
|
{
|
||||||
name: 'рублей',
|
name: 'рублей',
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user