set result values
This commit is contained in:
parent
f5c6bd7539
commit
08550a47a9
@ -27,8 +27,8 @@ export const calculationResults: IGroup[] = [
|
||||
title: 'Удорожание, год',
|
||||
Component: Label,
|
||||
props: {
|
||||
name: 'labelResultPriceUp',
|
||||
valueName: 'resultPriceUp',
|
||||
name: 'labelResultPriceUpPr',
|
||||
valueName: 'resultPriceUpPr',
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@ -9,7 +9,15 @@ import { getUser } from 'client/tools/user';
|
||||
import { TAction } from 'core/types/Calculation/Store/effect';
|
||||
import { ITableCell } from 'core/types/Calculation/Store/tables';
|
||||
import { Status } from 'core/types/statuses';
|
||||
import { TableProps } from './../../../../core/types/Calculation/Store/tables';
|
||||
import { TableProps } from 'core/types/Calculation/Store/tables';
|
||||
import { resultsValues } from 'core/types/Calculation/Store/values';
|
||||
import valuesConstants from 'core/constants/values';
|
||||
|
||||
const cleanResults = () => {
|
||||
for (let resultValue of resultsValues) {
|
||||
CalculationStore.setValue(resultValue, '');
|
||||
}
|
||||
};
|
||||
|
||||
const actions: TAction = {
|
||||
createLead: () => {
|
||||
@ -302,6 +310,7 @@ const actions: TAction = {
|
||||
CalculationStore.cleanTable('tableResults');
|
||||
|
||||
console.log('preparedData', preparedData);
|
||||
cleanResults();
|
||||
|
||||
return CalculationService.calculate(preparedData)
|
||||
.then(res => {
|
||||
@ -332,6 +341,74 @@ const actions: TAction = {
|
||||
|
||||
console.log('calculation res', res);
|
||||
|
||||
//set values
|
||||
CalculationStore.setValue(
|
||||
'resultTotalGraphwithNDS',
|
||||
sumWithVatColumn?.values.shift().reduce((a, b) => a + b),
|
||||
);
|
||||
CalculationStore.setValue(
|
||||
'resultPlPrice',
|
||||
preparedData.preparedValues.acceptSum * (1 + valuesConstants.VAT),
|
||||
);
|
||||
CalculationStore.setValue(
|
||||
'resultPriceUpPr',
|
||||
res?.postValues?.priceUP_PR || '',
|
||||
);
|
||||
CalculationStore.setValue(
|
||||
'resultIRRGraphPerc',
|
||||
res?.columns?.cashflowColumn?.irr || '',
|
||||
);
|
||||
CalculationStore.setValue(
|
||||
'resultIRRNominalPerc',
|
||||
res?.columns?.cashflowMsfoColumn?.nominal || '',
|
||||
);
|
||||
CalculationStore.setValue(
|
||||
'resultInsKasko',
|
||||
preparedData?.preparedValues?.insuranceKasko || '',
|
||||
);
|
||||
CalculationStore.setValue(
|
||||
'resultInsOsago',
|
||||
preparedData?.preparedValues?.insuranceOsago || '',
|
||||
);
|
||||
CalculationStore.setValue(
|
||||
'resultInsOsago',
|
||||
preparedData?.preparedValues?.insuranceOsago || '',
|
||||
);
|
||||
CalculationStore.setValue(
|
||||
'resultDopProdSum',
|
||||
(preparedData?.preparedValues?.rats || 0) +
|
||||
(preparedData?.preparedValues?.registration || 0) +
|
||||
(preparedData?.preparedValues?.trackerCost || 0) +
|
||||
(preparedData?.preparedValues?.tLMCost || 0) +
|
||||
(preparedData?.preparedValues?.nsibBrutto || 0),
|
||||
);
|
||||
CalculationStore.setValue(
|
||||
'resultFirstPayment',
|
||||
preparedData?.preparedValues?.firstPaymentSum ||
|
||||
0 * (1 + valuesConstants.VAT),
|
||||
);
|
||||
CalculationStore.setValue(
|
||||
'resultLastPayment',
|
||||
preparedData?.preparedValues?.lastPaymentSum ||
|
||||
0 * (1 + valuesConstants.VAT),
|
||||
);
|
||||
|
||||
CalculationStore.setValue(
|
||||
'resultTerm',
|
||||
preparedData?.preparedValues?.nmper || '',
|
||||
);
|
||||
CalculationStore.setValue(
|
||||
'resultAB',
|
||||
(preparedData?.preparedValues?.agentsSum || 0) +
|
||||
(preparedData?.preparedValues?.doubleAgentsSum || 0) +
|
||||
(preparedData?.preparedValues?.deliverySum || 0) +
|
||||
(preparedData?.preparedValues?.brokerSum || 0) +
|
||||
(preparedData?.preparedValues?.brokerOfDeliverySum || 0) +
|
||||
(preparedData?.preparedValues?.financialDeptOfDeliverySum || 0),
|
||||
);
|
||||
|
||||
//set values
|
||||
|
||||
return { ...res, ...preparedData };
|
||||
})
|
||||
.catch(err => {
|
||||
|
||||
@ -137,7 +137,7 @@ export type ElementsNames =
|
||||
export type ResultElementsNames =
|
||||
| 'labelResultTotalGraphwithNDS'
|
||||
| 'labelResultPlPrice'
|
||||
| 'labelResultPriceUp'
|
||||
| 'labelResultPriceUpPr'
|
||||
| 'labelResultIRRGraphPerc'
|
||||
| 'labelResultIRRNominalPerc'
|
||||
| 'labelResultInsKasko'
|
||||
@ -156,5 +156,5 @@ export enum ElementType {
|
||||
}
|
||||
|
||||
export type TElements<T> = {
|
||||
[elementName in ElementsNames & ResultElementsNames]?: T;
|
||||
[elementName in ElementsNames | ResultElementsNames]?: T;
|
||||
};
|
||||
|
||||
@ -12,7 +12,7 @@ import {
|
||||
TableProps,
|
||||
TCellCallback,
|
||||
} from './tables';
|
||||
import { TValue, TValues, ValuesNames } from './values';
|
||||
import { TValue, TValues, ValuesNames, ResultValuesNames } from './values';
|
||||
|
||||
interface ICalculationValues {
|
||||
staticData: TStaticData;
|
||||
@ -37,7 +37,10 @@ interface ICalculationValues {
|
||||
|
||||
values: TValues<any>;
|
||||
getValue: (sourceValueName: ValuesNames) => TValue;
|
||||
setValue: (sourceValueName: ValuesNames, newValue: TValue) => void;
|
||||
setValue: (
|
||||
sourceValueName: ValuesNames | ResultValuesNames,
|
||||
newValue: TValue,
|
||||
) => void;
|
||||
|
||||
statuses: TElements<Status>;
|
||||
getStatus: (elementName: ElementsNames) => Status;
|
||||
|
||||
@ -126,20 +126,23 @@ export type ComputedValuesNames =
|
||||
| 'leaseObjectRiskName'
|
||||
| 'insKaskoPriceLeasePeriod';
|
||||
|
||||
export type ResultValuesNames =
|
||||
| 'resultTotalGraphwithNDS'
|
||||
| 'resultPlPrice'
|
||||
| 'resultPriceUp'
|
||||
| 'resultIRRGraphPerc'
|
||||
| 'resultIRRNominalPerc'
|
||||
| 'resultInsKasko'
|
||||
| 'resultInsOsago'
|
||||
| 'resultDopProdSum'
|
||||
| 'resultFirstPayment'
|
||||
| 'resultLastPayment'
|
||||
| 'resultTerm'
|
||||
| 'resultAB'
|
||||
| 'resultBonusMPL';
|
||||
export const resultsValues = [
|
||||
'resultTotalGraphwithNDS',
|
||||
'resultPlPrice',
|
||||
'resultPriceUpPr',
|
||||
'resultIRRGraphPerc',
|
||||
'resultIRRNominalPerc',
|
||||
'resultInsKasko',
|
||||
'resultInsOsago',
|
||||
'resultDopProdSum',
|
||||
'resultFirstPayment',
|
||||
'resultLastPayment',
|
||||
'resultTerm',
|
||||
'resultAB',
|
||||
'resultBonusMPL',
|
||||
] as const; // TS 3.4
|
||||
type SuitTuple = typeof resultsValues; // readonly ['hearts', 'diamonds', 'spades', 'clubs']
|
||||
export type ResultValuesNames = SuitTuple[number]; // union type
|
||||
|
||||
export type TValues<T> = {
|
||||
[valueName in ValuesNames | ResultValuesNames]?: T;
|
||||
|
||||
Reference in New Issue
Block a user