add results table
This commit is contained in:
parent
19e592de67
commit
84c1b6ed54
@ -4,14 +4,17 @@ import Background from 'client/Elements/Background';
|
||||
import Title from 'client/Elements/Title';
|
||||
import { Flex } from 'client/UIKit/grid';
|
||||
import React from 'react';
|
||||
import resultsList from './resultsList';
|
||||
import { resultInfo, calculationResults } from './resultsList';
|
||||
|
||||
const Results = props => (
|
||||
<Background {...props}>
|
||||
{renderGroups({ groups: resultsList })}
|
||||
{renderGroups({ groups: resultInfo })}
|
||||
<Divider style={styles.divider} />
|
||||
<Flex justifyContent="center">
|
||||
<Title text="Результаты" />
|
||||
<Flex flexDirection="column">
|
||||
<Flex justifyContent="center">
|
||||
<Title text="Результаты" />
|
||||
</Flex>
|
||||
{renderGroups({ groups: calculationResults })}
|
||||
</Flex>
|
||||
</Background>
|
||||
);
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import InputNumber from 'client/Elements/InputNumber';
|
||||
import Table from 'client/Elements/Table';
|
||||
import Button from 'client/Elements/Button';
|
||||
import Label from 'client/Elements/Label';
|
||||
import Select from 'client/Elements/Select';
|
||||
import Switch from 'client/Elements/Switch';
|
||||
import { IGroup } from 'core/types/Calculation/components';
|
||||
import { ElementType } from 'core/types/Calculation/Store/elements';
|
||||
|
||||
const resultsList: IGroup[] = [
|
||||
export const resultInfo: IGroup[] = [
|
||||
{
|
||||
blocks: [
|
||||
{
|
||||
@ -40,50 +40,45 @@ const resultsList: IGroup[] = [
|
||||
},
|
||||
],
|
||||
},
|
||||
// {
|
||||
// title: 'Поиск интереса в CRM',
|
||||
// blocks: [
|
||||
// {
|
||||
// elements: [
|
||||
// {
|
||||
// title: 'Выбор Интереса',
|
||||
// Component: Select,
|
||||
// props: {
|
||||
// name: 'selectLead',
|
||||
// valueName: 'lead',
|
||||
// showSearch: true,
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// title: 'Лизинговая сделка',
|
||||
// Component: Select,
|
||||
// props: {
|
||||
// name: 'selectOpportunity',
|
||||
// valueName: 'opportunity',
|
||||
// showSearch: true,
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// title: 'Выбор Предложения',
|
||||
// Component: Select,
|
||||
// props: {
|
||||
// name: 'selectQuote',
|
||||
// valueName: 'quote',
|
||||
// showSearch: true,
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// title: 'Пересчет без пересмотра',
|
||||
// Component: Switch,
|
||||
// props: {
|
||||
// name: 'cbxRecalcWithRevision',
|
||||
// valueName: 'recalcWithRevision',
|
||||
// },
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
];
|
||||
|
||||
export default resultsList;
|
||||
export const calculationResults: IGroup[] = [
|
||||
{
|
||||
blocks: [
|
||||
{
|
||||
elements: [
|
||||
{
|
||||
type: ElementType.Table,
|
||||
title: 'График платежей',
|
||||
Component: Table,
|
||||
props: {
|
||||
name: 'tableResults',
|
||||
features: {
|
||||
numerize: {
|
||||
columnTitle: 'Номер',
|
||||
},
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
name: 'paymentSum',
|
||||
title: 'Сумма платежа',
|
||||
Component: InputNumber,
|
||||
},
|
||||
{
|
||||
name: 'ndsCompensation',
|
||||
title: 'НДС к возмещению',
|
||||
Component: InputNumber,
|
||||
},
|
||||
{
|
||||
name: 'redemptionAmount',
|
||||
title: 'Сумма досрочного выкупа',
|
||||
Component: InputNumber,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
@ -69,7 +69,7 @@ class CalculationService {
|
||||
resolve(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
throw err;
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
import { TableProps } from './../../../../core/types/Calculation/Store/tables';
|
||||
import { ITableCell } from 'core/types/Calculation/Store/tables';
|
||||
import { message } from 'antd';
|
||||
import { openNotification } from 'client/Elements/Notification';
|
||||
import CalculationService from 'client/services/CalculationService';
|
||||
import { prepareCalculationData } from 'client/services/prepareData';
|
||||
import CalculationStore from 'client/stores/CalculationStore';
|
||||
import { TAction } from 'core/types/Calculation/Store/effect';
|
||||
import { prepareCalculationData } from 'client/services/prepareData';
|
||||
import CalculationService from 'client/services/CalculationService';
|
||||
|
||||
const actions: TAction = {
|
||||
createLead: () => {
|
||||
@ -148,7 +151,7 @@ const actions: TAction = {
|
||||
}
|
||||
}
|
||||
},
|
||||
calculate: () => {
|
||||
calculate: async () => {
|
||||
// TODO: block button for time
|
||||
// TODO: collect errors
|
||||
|
||||
@ -215,10 +218,41 @@ const actions: TAction = {
|
||||
console.log(preparedData);
|
||||
console.log(CalculationStore.values);
|
||||
|
||||
CalculationService.calculate(preparedData).then(res => {
|
||||
console.log(res.columns);
|
||||
console.log(res.postValues);
|
||||
});
|
||||
CalculationStore.cleanTable('tableResults');
|
||||
|
||||
CalculationService.calculate(preparedData)
|
||||
.then(res => {
|
||||
console.log(res.columns);
|
||||
console.log(res.postValues);
|
||||
|
||||
message.success({
|
||||
content: 'Расчет завершен успешно!',
|
||||
duration: 5,
|
||||
});
|
||||
|
||||
const { sumWithVatColumn, vatColumn, sumRepaymentColumn } = res.columns;
|
||||
|
||||
let results: TableProps<ITableCell>[] = [];
|
||||
|
||||
for (let i = 0; i < preparedData.preparedValues.nmper; i++) {
|
||||
results.push({
|
||||
paymentSum: { value: sumWithVatColumn?.values[i + 1] },
|
||||
ndsCompensation: { value: vatColumn?.values[i + 1] },
|
||||
redemptionAmount: {
|
||||
value: sumRepaymentColumn?.values[i + 1],
|
||||
},
|
||||
});
|
||||
}
|
||||
//TODO: speed up table render
|
||||
CalculationStore.setTableRows('tableResults', 0)(results);
|
||||
})
|
||||
.catch(() => {
|
||||
message.error({
|
||||
content: 'Произошла ошибка во время расчета!',
|
||||
duration: 5,
|
||||
});
|
||||
});
|
||||
message.destroy();
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import tableInsurance from './tableInsurance';
|
||||
import tablePayments from './tablePayments';
|
||||
import tableResults from './tableResults';
|
||||
|
||||
export default {
|
||||
tableInsurance,
|
||||
tablePayments,
|
||||
tableResults,
|
||||
};
|
||||
|
||||
7
src/core/config/initialTables/tableResults.ts
Normal file
7
src/core/config/initialTables/tableResults.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { ITable } from 'core/types/Calculation/Store/tables';
|
||||
|
||||
const tableResults: ITable = {
|
||||
rows: [],
|
||||
};
|
||||
|
||||
export default tableResults;
|
||||
80
src/core/types/Calculation/Core.ts
Normal file
80
src/core/types/Calculation/Core.ts
Normal file
@ -0,0 +1,80 @@
|
||||
export type IColumn = {
|
||||
irr: number;
|
||||
xnpv: number;
|
||||
nominal: number;
|
||||
values: any[];
|
||||
};
|
||||
|
||||
type TPostValue = {
|
||||
value: any;
|
||||
};
|
||||
|
||||
export type TPostValues = {};
|
||||
|
||||
export type ColumnsNames =
|
||||
| 'dateColumn'
|
||||
| 'dateTempColumn'
|
||||
| 'percentPaymentColumn'
|
||||
| 'kaskoNmperGrColumn'
|
||||
| 'tlmGrColumn'
|
||||
| 'gpsGrColumn'
|
||||
| 'sumColumn'
|
||||
| 'vatColumn'
|
||||
| 'sumWithVatColumn'
|
||||
| 'acceptSumColumn'
|
||||
| 'acceptKaskoColumn'
|
||||
| 'acceptOsagoColumn'
|
||||
| 'acceptInsuranceColumn'
|
||||
| 'deprecationLpColumn'
|
||||
| 'deprecationLdColumn'
|
||||
| 'deprecationColumn'
|
||||
| 'npvBonusExpensesColumn'
|
||||
| 'kaskoBonusGrSumColumn'
|
||||
| 'agentComissionExpensesColumn'
|
||||
| 'ratExpensesColumn'
|
||||
| 'transExprensesColumn'
|
||||
| 'nsibExpensesColumn'
|
||||
| 'tlmExpensesColumn'
|
||||
| 'gpsExpensesColumn'
|
||||
| 'registrExpensesColumn'
|
||||
| 'insuranceBonusExpensesColumn'
|
||||
| 'comissionBonusExpensesColumn'
|
||||
| 'expensesColumn'
|
||||
| 'negativeCashflowColumn'
|
||||
| 'nsibBruttoGrColumn'
|
||||
| 'taxColumn'
|
||||
| 'cashflowColumn'
|
||||
| 'cashflowLeasingColumn'
|
||||
| 'cashflowMsfoColumn'
|
||||
| 'cashflowNpvColumn'
|
||||
| 'npvWeightColumn'
|
||||
| 'npvColumn'
|
||||
| 'irrGrColumn'
|
||||
| 'niColumn'
|
||||
| 'interestColumn'
|
||||
| 'cashflowNsibColumn'
|
||||
| 'revenueColumn'
|
||||
| 'sumCurrentColumn'
|
||||
| 'sumCurrentNegativeColumn'
|
||||
| 'sumCurrentInterestColumn'
|
||||
| 'sumCurrentTlmColumn'
|
||||
| 'sumRepaymentColumn'
|
||||
| 'extraBonusSumColumn'
|
||||
| 'cashflowMsfoFinalColumn'
|
||||
| 'cashflowNpvFinalColumn'
|
||||
| 'npvFinalColumn'
|
||||
| 'directorBonusSumColumn'
|
||||
| 'cashflowMsfoFinal2Column'
|
||||
| 'cashflowNpvFinal2Column'
|
||||
| 'npvFinal2Column';
|
||||
|
||||
export interface PostValues {
|
||||
baseCost: TPostValue;
|
||||
bonusBase: TPostValue;
|
||||
priceUP: TPostValue;
|
||||
priceUP_PR: TPostValue;
|
||||
priceUP_Year: TPostValue;
|
||||
priceUP_Year_PR: TPostValue;
|
||||
npvni: TPostValue;
|
||||
bonusResult: TPostValue;
|
||||
}
|
||||
@ -1,14 +1,15 @@
|
||||
import { User } from 'core/types/user';
|
||||
import { TCRMEntity } from '../Entities/crmEntities';
|
||||
import { TEntities } from '../Entities/crmEntityNames';
|
||||
import { User } from 'core/types/user';
|
||||
import { IColumn, PostValues, ColumnsNames } from './Core';
|
||||
|
||||
export interface IGetEntitiesResponse {
|
||||
entities: TEntities<TCRMEntity | TCRMEntity[]>;
|
||||
}
|
||||
|
||||
export interface IGetCalculationResponse {
|
||||
columns: any;
|
||||
postValues: any;
|
||||
columns: { [column in ColumnsNames]?: IColumn };
|
||||
postValues: PostValues;
|
||||
}
|
||||
|
||||
export interface IGetUserResponse {
|
||||
|
||||
@ -4,7 +4,7 @@ import { ICalculationStore } from './';
|
||||
import { TElementFilter } from './filters';
|
||||
import { IBaseOption } from './options';
|
||||
|
||||
export type TableNames = 'tableInsurance' | 'tablePayments';
|
||||
export type TableNames = 'tableInsurance' | 'tablePayments' | 'tableResults';
|
||||
export type TableValuesNames =
|
||||
| 'policyType'
|
||||
| 'insuranceCompany'
|
||||
@ -12,7 +12,10 @@ export type TableValuesNames =
|
||||
| 'insCost'
|
||||
| 'insTerm'
|
||||
| 'paymentNumber'
|
||||
| 'paymentRelation';
|
||||
| 'paymentRelation'
|
||||
| 'paymentSum'
|
||||
| 'ndsCompensation'
|
||||
| 'redemptionAmount';
|
||||
|
||||
export type TCellCallback = (
|
||||
calculationStore: ICalculationStore,
|
||||
|
||||
Reference in New Issue
Block a user