first calculation!!!
This commit is contained in:
parent
52021141af
commit
a34bfebcde
@ -1603,7 +1603,7 @@ const sections: ISections[] = [
|
||||
Component: Select,
|
||||
props: {
|
||||
name: 'selectTarif',
|
||||
valueName: 'Tarif',
|
||||
valueName: 'tarif',
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@ -26,7 +26,7 @@ const Calculation = () => {
|
||||
}),
|
||||
CalculationService.crmgqlquery({
|
||||
query: gql`
|
||||
query($statecode: Int, $currentDate: DateTime, $username: String) {
|
||||
query($statecode: Int, $currentDate: DateTime) {
|
||||
evo_impairment_group: evo_impairment_groups(
|
||||
statecode: $statecode
|
||||
) {
|
||||
@ -73,13 +73,6 @@ const Calculation = () => {
|
||||
evo_name
|
||||
evo_sot_coefficient_typeid
|
||||
}
|
||||
systemuser(domainname: $username) {
|
||||
evo_job_titleid
|
||||
businessunitid
|
||||
firstname
|
||||
lastname
|
||||
fullname
|
||||
}
|
||||
evo_job_title: evo_job_titles(statecode: $statecode) {
|
||||
evo_id
|
||||
evo_name
|
||||
@ -90,9 +83,22 @@ const Calculation = () => {
|
||||
variables: {
|
||||
statecode: 0,
|
||||
currentDate,
|
||||
username: `${DomainName}\\${UserName}`,
|
||||
},
|
||||
}),
|
||||
CalculationService.crmgqlquery({
|
||||
query: gql`
|
||||
query($username: String) {
|
||||
systemuser(domainname: $username) {
|
||||
evo_job_titleid
|
||||
businessunitid
|
||||
firstname
|
||||
lastname
|
||||
fullname
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: { username: `${DomainName}\\${UserName}` },
|
||||
}),
|
||||
CalculationService.getEntities({
|
||||
queries: [
|
||||
{
|
||||
@ -109,10 +115,15 @@ const Calculation = () => {
|
||||
([
|
||||
{ entities: initialOptions },
|
||||
{ entities: staticEntities },
|
||||
{
|
||||
entities: { systemuser },
|
||||
},
|
||||
{ entities: insuranceCompanies },
|
||||
]) => {
|
||||
console.log('Calculation -> staticEntities', staticEntities);
|
||||
calculationStore.applyOptions(initialOptions);
|
||||
calculationStore.applyStaticData(staticEntities);
|
||||
calculationStore.applyStaticData({ systemuser: [systemuser] });
|
||||
calculationStore.setTableColumns('tableInsurance')({
|
||||
options: { ...insuranceCompanies },
|
||||
});
|
||||
|
||||
@ -1,14 +1,20 @@
|
||||
import { ApolloClient, gql, HttpLink, InMemoryCache } from '@apollo/client';
|
||||
import axios from 'axios';
|
||||
import { API_HOSTNAME } from 'client/common/constants';
|
||||
import { CRM_GRAPHQL_PROXY_URL, CRM_GRAPHQL_URL } from 'core/constants/urls';
|
||||
import {
|
||||
CORE_PROXY_URL,
|
||||
CRM_GRAPHQL_PROXY_URL,
|
||||
CRM_GRAPHQL_URL,
|
||||
} from 'core/constants/urls';
|
||||
import { convertEntityToOption } from 'core/tools/entities';
|
||||
import { convertJSONToGQLQuery } from 'core/tools/query';
|
||||
import {
|
||||
IGetEntitiesRequest,
|
||||
IRequestToCRMGQL,
|
||||
IGetCalculationRequest,
|
||||
} from 'core/types/Calculation/Requests';
|
||||
import {
|
||||
IGetCalculationResponse,
|
||||
IGetEntitiesResponse,
|
||||
IGetUserResponse,
|
||||
} from 'core/types/Calculation/Responses';
|
||||
@ -49,6 +55,39 @@ class CalculationService {
|
||||
});
|
||||
});
|
||||
|
||||
static calculate = (
|
||||
preparedData: IGetCalculationRequest,
|
||||
): Promise<IGetCalculationResponse> =>
|
||||
new Promise((resolve, reject) => {
|
||||
axios
|
||||
.post<IGetCalculationResponse>(
|
||||
String.prototype.concat(
|
||||
(process.env.NODE_ENV !== 'development' &&
|
||||
`http://${API_HOSTNAME}:3001`) ||
|
||||
'',
|
||||
'/proxy',
|
||||
CORE_PROXY_URL,
|
||||
'/api',
|
||||
'/v1',
|
||||
'/calculation',
|
||||
'/calculate',
|
||||
),
|
||||
{
|
||||
preparedValues: preparedData.preparedValues,
|
||||
preparedPayments: {
|
||||
Rows: preparedData.preparedPayments,
|
||||
},
|
||||
},
|
||||
)
|
||||
.then(res => {
|
||||
console.log(res);
|
||||
resolve(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
throw err;
|
||||
});
|
||||
});
|
||||
|
||||
static crmgqlquery = ({
|
||||
query,
|
||||
toOptions,
|
||||
|
||||
@ -20,7 +20,15 @@ export const prepareCalculationData = ({
|
||||
//@ts-ignore
|
||||
let preparedPayments: PreparedPayments = Array.from(
|
||||
{ length: values.leasingPeriod },
|
||||
() => ({}),
|
||||
() => ({
|
||||
numberPayment: 0,
|
||||
percentPayment: 0,
|
||||
sumPayment: 0,
|
||||
gpsBasePayment: 0,
|
||||
gpsCostPayment: 0,
|
||||
tlmBasePayment: 0,
|
||||
tlmCostPayment: 0,
|
||||
}),
|
||||
);
|
||||
|
||||
const tracker = options.selectTracker?.find(x => x.evo_id === values.tracker);
|
||||
@ -67,7 +75,16 @@ export const prepareCalculationData = ({
|
||||
}
|
||||
}
|
||||
|
||||
let preparedValues: PreparedValues = {};
|
||||
let preparedValues: PreparedValues = {
|
||||
brandId: '00000000-0000-0000-0000-000000000000',
|
||||
configurationId: '00000000-0000-0000-0000-000000000000',
|
||||
firstPaymentAbs: 0,
|
||||
firstPaymentNdsAbs: 0,
|
||||
firstPaymentWithNdsAbs: 0,
|
||||
modelId: '00000000-0000-0000-0000-000000000000',
|
||||
paymentDateNew: new Date(),
|
||||
plTypeId: '00000000-0000-0000-0000-000000000000',
|
||||
};
|
||||
|
||||
preparedValues.calcDate = currentDate;
|
||||
preparedValues.calcType = 100000000;
|
||||
@ -564,7 +581,7 @@ export const prepareCalculationData = ({
|
||||
|
||||
preparedValues.cityc = values.townRegistration || values.regionRegistration;
|
||||
|
||||
const tarif = options.selectTarif?.find(x => x.evo_id === values.tarif);
|
||||
const tarif = options.selectTarif?.find(x => x.evo_tarifid === values.tarif);
|
||||
if (tarif) {
|
||||
preparedValues.iRR_MSFO_Plan = (tarif.evo_irr_plan || 0) / 100;
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ import { openNotification } from 'client/Elements/Notification';
|
||||
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: () => {
|
||||
@ -210,7 +211,14 @@ const actions: TAction = {
|
||||
var preparedData = prepareCalculationData({
|
||||
calculationStore: CalculationStore,
|
||||
});
|
||||
console.log('preparedData', preparedData);
|
||||
|
||||
console.log(preparedData);
|
||||
console.log(CalculationStore.values);
|
||||
|
||||
CalculationService.calculate(preparedData).then(res => {
|
||||
console.log(res.columns);
|
||||
console.log(res.postValues);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
export const API_PORT = 3001;
|
||||
export const CRM_GRAPHQL_URL = 'http://crmgraphql-dev.evoleasing.ru';
|
||||
export const CRM_GRAPHQL_PROXY_URL = '/crmgraphql';
|
||||
export const CORE_URL = 'http://localhost:5000';
|
||||
export const CORE_PROXY_URL = '/core';
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { CRMEntityNames } from '../Entities/crmEntityNames';
|
||||
export interface PreparedValues {
|
||||
calcDate?: Date;
|
||||
calcType?: number;
|
||||
@ -103,7 +102,3 @@ export interface PaymentRow {
|
||||
}
|
||||
|
||||
export type PreparedPayments = PaymentRow[];
|
||||
|
||||
export type TPrepareEntities<T> = {
|
||||
[entityAlias in CRMEntityNames]?: T;
|
||||
};
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
import { ICalculationStore } from 'core/types/Calculation/Store';
|
||||
import { CRMEntityNames } from 'core/types/Entities/crmEntityNames';
|
||||
import { TEntityQuery } from '../Entities/query';
|
||||
import {
|
||||
PreparedPayments,
|
||||
PreparedValues,
|
||||
} from 'core/types/Calculation/Prepare';
|
||||
|
||||
export interface IGetEntitiesRequest {
|
||||
queries: TEntityQuery[];
|
||||
@ -13,5 +17,6 @@ export interface IRequestToCRMGQL {
|
||||
}
|
||||
|
||||
export interface IGetCalculationRequest {
|
||||
calculationStore: ICalculationStore;
|
||||
preparedPayments: PreparedPayments;
|
||||
preparedValues: PreparedValues;
|
||||
}
|
||||
|
||||
@ -1,18 +1,3 @@
|
||||
import { Response } from 'express';
|
||||
import { IGetCalculationResponse } from '../../core/types/Calculation/Responses';
|
||||
import { IGetCalculationRequest } from '../../core/types/Calculation/Requests';
|
||||
|
||||
class CalculationController {
|
||||
static calculate = async (
|
||||
req: { body: IGetCalculationRequest },
|
||||
res: Response<IGetCalculationResponse>,
|
||||
): Promise<void> => {
|
||||
/**
|
||||
* prepare Data
|
||||
* send to core
|
||||
* send to client
|
||||
*/
|
||||
};
|
||||
}
|
||||
class CalculationController {}
|
||||
|
||||
export default CalculationController;
|
||||
|
||||
@ -3,6 +3,4 @@ import CalculationController from '../controllers/CalculationController';
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.post('/calculate', CalculationController.calculate);
|
||||
|
||||
export default router;
|
||||
|
||||
@ -3,10 +3,13 @@ import proxy from 'express-http-proxy';
|
||||
import {
|
||||
CRM_GRAPHQL_PROXY_URL,
|
||||
CRM_GRAPHQL_URL,
|
||||
CORE_URL,
|
||||
CORE_PROXY_URL,
|
||||
} from '../../core/constants/urls';
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.use(CRM_GRAPHQL_PROXY_URL, proxy(CRM_GRAPHQL_URL));
|
||||
router.use(CORE_PROXY_URL, proxy(CORE_URL));
|
||||
|
||||
export default router;
|
||||
|
||||
Reference in New Issue
Block a user