diff --git a/src/client/Containers/Calculation/Results/index.jsx b/src/client/Containers/Calculation/Results/index.jsx
index 4eabb3e..78af76a 100644
--- a/src/client/Containers/Calculation/Results/index.jsx
+++ b/src/client/Containers/Calculation/Results/index.jsx
@@ -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 => (
- {renderGroups({ groups: resultsList })}
+ {renderGroups({ groups: resultInfo })}
-
-
+
+
+
+
+ {renderGroups({ groups: calculationResults })}
);
diff --git a/src/client/Containers/Calculation/Results/resultsList.ts b/src/client/Containers/Calculation/Results/resultsList.ts
index 2b87687..c4acacb 100644
--- a/src/client/Containers/Calculation/Results/resultsList.ts
+++ b/src/client/Containers/Calculation/Results/resultsList.ts
@@ -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,
+ },
+ ],
+ },
+ },
+ ],
+ },
+ ],
+ },
+];
diff --git a/src/client/services/CalculationService.ts b/src/client/services/CalculationService.ts
index 2c1a904..8d55a2a 100644
--- a/src/client/services/CalculationService.ts
+++ b/src/client/services/CalculationService.ts
@@ -69,7 +69,7 @@ class CalculationService {
resolve(res.data);
})
.catch(err => {
- throw err;
+ reject(err);
});
});
diff --git a/src/client/stores/CalculationStore/Effects/action.ts b/src/client/stores/CalculationStore/Effects/action.ts
index 63629a9..83c4b03 100644
--- a/src/client/stores/CalculationStore/Effects/action.ts
+++ b/src/client/stores/CalculationStore/Effects/action.ts
@@ -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[] = [];
+
+ 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();
},
};
diff --git a/src/core/config/initialTables/index.ts b/src/core/config/initialTables/index.ts
index 25fe5b0..1634580 100644
--- a/src/core/config/initialTables/index.ts
+++ b/src/core/config/initialTables/index.ts
@@ -1,7 +1,9 @@
import tableInsurance from './tableInsurance';
import tablePayments from './tablePayments';
+import tableResults from './tableResults';
export default {
tableInsurance,
tablePayments,
+ tableResults,
};
diff --git a/src/core/config/initialTables/tableResults.ts b/src/core/config/initialTables/tableResults.ts
new file mode 100644
index 0000000..976a084
--- /dev/null
+++ b/src/core/config/initialTables/tableResults.ts
@@ -0,0 +1,7 @@
+import { ITable } from 'core/types/Calculation/Store/tables';
+
+const tableResults: ITable = {
+ rows: [],
+};
+
+export default tableResults;
diff --git a/src/core/types/Calculation/Core.ts b/src/core/types/Calculation/Core.ts
new file mode 100644
index 0000000..8e181fe
--- /dev/null
+++ b/src/core/types/Calculation/Core.ts
@@ -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;
+}
diff --git a/src/core/types/Calculation/Responses.ts b/src/core/types/Calculation/Responses.ts
index ba15ac3..7f774c0 100644
--- a/src/core/types/Calculation/Responses.ts
+++ b/src/core/types/Calculation/Responses.ts
@@ -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;
}
export interface IGetCalculationResponse {
- columns: any;
- postValues: any;
+ columns: { [column in ColumnsNames]?: IColumn };
+ postValues: PostValues;
}
export interface IGetUserResponse {
diff --git a/src/core/types/Calculation/Store/tables.ts b/src/core/types/Calculation/Store/tables.ts
index b6a18df..8576c74 100644
--- a/src/core/types/Calculation/Store/tables.ts
+++ b/src/core/types/Calculation/Store/tables.ts
@@ -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,