Compare commits
15 Commits
dev
...
release/dy
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e9a4612262 | ||
|
|
d4b0ae503f | ||
|
|
1dd23ea03d | ||
|
|
746166a59d | ||
|
|
c57fc73fdc | ||
|
|
c82144dc7e | ||
|
|
870d7b373b | ||
|
|
7797325f8c | ||
|
|
009c9fb5dd | ||
|
|
464e3cba8d | ||
|
|
d9c3c7e2a5 | ||
|
|
63462becc5 | ||
|
|
ba22659578 | ||
|
|
af5c9cb061 | ||
|
|
47807b7bda |
@ -2,14 +2,14 @@
|
|||||||
# Make sure you update both files!
|
# Make sure you update both files!
|
||||||
|
|
||||||
FROM node:alpine AS builder
|
FROM node:alpine AS builder
|
||||||
RUN corepack enable && corepack prepare pnpm@8.9.0 --activate
|
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||||
ENV PNPM_HOME=/usr/local/bin
|
ENV PNPM_HOME=/usr/local/bin
|
||||||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
||||||
RUN apk add --no-cache libc6-compat
|
RUN apk add --no-cache libc6-compat
|
||||||
RUN apk update
|
RUN apk update
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN pnpm add -g turbo@1.12.4 dotenv-cli
|
RUN pnpm add -g turbo dotenv-cli
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN turbo prune --scope=api --docker
|
RUN turbo prune --scope=api --docker
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,6 @@ export const queryTTL: Record<string, number | false> = {
|
|||||||
GetDealerPerson: seconds().fromHours(1),
|
GetDealerPerson: seconds().fromHours(1),
|
||||||
GetDealerPersons: seconds().fromHours(1),
|
GetDealerPersons: seconds().fromHours(1),
|
||||||
GetDealers: seconds().fromMinutes(15),
|
GetDealers: seconds().fromMinutes(15),
|
||||||
GetEltInsuranceRules: seconds().fromHours(12),
|
|
||||||
GetFuelCards: seconds().fromHours(12),
|
GetFuelCards: seconds().fromHours(12),
|
||||||
GetGPSBrands: seconds().fromHours(24),
|
GetGPSBrands: seconds().fromHours(24),
|
||||||
GetGPSModels: seconds().fromHours(24),
|
GetGPSModels: seconds().fromHours(24),
|
||||||
@ -33,7 +32,6 @@ export const queryTTL: Record<string, number | false> = {
|
|||||||
GetOpportunities: false,
|
GetOpportunities: false,
|
||||||
GetOpportunity: false,
|
GetOpportunity: false,
|
||||||
GetOpportunityUrl: seconds().fromHours(12),
|
GetOpportunityUrl: seconds().fromHours(12),
|
||||||
GetOsagoAddproductTypes: seconds().fromHours(12),
|
|
||||||
GetProduct: seconds().fromHours(12),
|
GetProduct: seconds().fromHours(12),
|
||||||
GetProducts: seconds().fromHours(12),
|
GetProducts: seconds().fromHours(12),
|
||||||
GetQuote: false,
|
GetQuote: false,
|
||||||
|
|||||||
@ -16,7 +16,7 @@ generates:
|
|||||||
object: true
|
object: true
|
||||||
defaultValue: true
|
defaultValue: true
|
||||||
scalars:
|
scalars:
|
||||||
UUID: string
|
Uuid: string
|
||||||
Decimal: number
|
Decimal: number
|
||||||
DateTime: string
|
DateTime: string
|
||||||
# exclude: './graphql/crm.schema.graphql'
|
# exclude: './graphql/crm.schema.graphql'
|
||||||
|
|||||||
@ -1,19 +0,0 @@
|
|||||||
import elementsToValues from '@/Components/Calculation/config/map/values';
|
|
||||||
|
|
||||||
export const ERR_ELT_KASKO = 'ERR_ELT_KASKO';
|
|
||||||
export const ERR_ELT_OSAGO = 'ERR_ELT_OSAGO';
|
|
||||||
export const ERR_FINGAP_TABLE = 'ERR_FINGAP_TABLE';
|
|
||||||
export const ERR_INSURANCE_TABLE = 'ERR_INSURANCE_TABLE';
|
|
||||||
export const ERR_PAYMENTS_TABLE = 'ERR_PAYMENTS_TABLE';
|
|
||||||
|
|
||||||
export const ERROR_TABLE_KEYS = [
|
|
||||||
ERR_ELT_KASKO,
|
|
||||||
ERR_ELT_OSAGO,
|
|
||||||
ERR_FINGAP_TABLE,
|
|
||||||
ERR_INSURANCE_TABLE,
|
|
||||||
ERR_PAYMENTS_TABLE,
|
|
||||||
];
|
|
||||||
|
|
||||||
export const ERROR_ELEMENTS_KEYS = Object.keys(elementsToValues);
|
|
||||||
|
|
||||||
export const ERROR_KEYS = [...ERROR_ELEMENTS_KEYS, ...ERROR_TABLE_KEYS];
|
|
||||||
@ -1,10 +1,9 @@
|
|||||||
import Background from '../../Layout/Background';
|
import Background from '../../Layout/Background';
|
||||||
import { useFilteredQueries } from './lib/hooks';
|
import { useFilteredQueries } from './lib/hooks';
|
||||||
import { QueryList } from './QueryList';
|
import { QueryList } from './QueryList';
|
||||||
import { reset } from '@/api/cache/query';
|
|
||||||
import { min } from '@/styles/mq';
|
import { min } from '@/styles/mq';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { Button, Collapse, Divider, Input } from 'ui/elements';
|
import { Collapse, Divider, Input } from 'ui/elements';
|
||||||
|
|
||||||
const Wrapper = styled(Background)`
|
const Wrapper = styled(Background)`
|
||||||
padding: 4px 6px;
|
padding: 4px 6px;
|
||||||
@ -22,21 +21,13 @@ const Wrapper = styled(Background)`
|
|||||||
|
|
||||||
const Flex = styled.div`
|
const Flex = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
margin-bottom: 16px;
|
||||||
|
justify-content: space-between;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const ButtonWrapper = styled.div`
|
|
||||||
display: flex;
|
|
||||||
justify-content: flex-end;
|
|
||||||
`;
|
|
||||||
|
|
||||||
export function Cache() {
|
export function Cache() {
|
||||||
const { filteredQueries, refetch, setFilterString } = useFilteredQueries();
|
const { filteredQueries, setFilterString } = useFilteredQueries();
|
||||||
|
|
||||||
function handleDeleteQuery() {
|
|
||||||
return reset().then(() => refetch());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!filteredQueries) {
|
if (!filteredQueries) {
|
||||||
return <div>Загрузка...</div>;
|
return <div>Загрузка...</div>;
|
||||||
@ -51,20 +42,15 @@ export function Cache() {
|
|||||||
allowClear
|
allowClear
|
||||||
onChange={(e) => setFilterString(e.target.value)}
|
onChange={(e) => setFilterString(e.target.value)}
|
||||||
/>
|
/>
|
||||||
<Collapse
|
|
||||||
accordion
|
|
||||||
items={Object.keys(filteredQueries).map((queryGroupName) => ({
|
|
||||||
children: <QueryList {...filteredQueries[queryGroupName]} />,
|
|
||||||
key: queryGroupName,
|
|
||||||
label: queryGroupName,
|
|
||||||
}))}
|
|
||||||
/>
|
|
||||||
<ButtonWrapper>
|
|
||||||
<Button type="primary" danger disabled={false} onClick={() => handleDeleteQuery()}>
|
|
||||||
Очистить кэш
|
|
||||||
</Button>
|
|
||||||
</ButtonWrapper>
|
|
||||||
</Flex>
|
</Flex>
|
||||||
|
<Collapse
|
||||||
|
accordion
|
||||||
|
items={Object.keys(filteredQueries).map((queryGroupName) => ({
|
||||||
|
children: <QueryList {...filteredQueries[queryGroupName]} />,
|
||||||
|
key: queryGroupName,
|
||||||
|
label: queryGroupName,
|
||||||
|
}))}
|
||||||
|
/>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@ export const rows: FormTabRows = [
|
|||||||
{
|
{
|
||||||
title: 'Регистрация',
|
title: 'Регистрация',
|
||||||
},
|
},
|
||||||
[['radioObjectRegistration', 'radioTypePTS'], { gridTemplateColumns: ['1fr', '1fr 1fr'] }],
|
[['radioObjectRegistration', 'radioTypePTS'], { gridTemplateColumns: ['1fr 1fr'] }],
|
||||||
[['selectRegionRegistration', 'selectTownRegistration', 'selectObjectRegionRegistration']],
|
[['selectRegionRegistration', 'selectTownRegistration', 'selectObjectRegionRegistration']],
|
||||||
[['selectObjectCategoryTax', 'selectObjectTypeTax', 'tbxVehicleTaxInYear']],
|
[['selectObjectCategoryTax', 'selectObjectTypeTax', 'tbxVehicleTaxInYear']],
|
||||||
[['tbxLeaseObjectYear', 'tbxLeaseObjectMotorPower', 'tbxVehicleTaxInLeasingPeriod']],
|
[['tbxLeaseObjectYear', 'tbxLeaseObjectMotorPower', 'tbxVehicleTaxInLeasingPeriod']],
|
||||||
|
|||||||
@ -12,6 +12,5 @@ export const rows: FormTabRows = [
|
|||||||
[['cbxInsurance', 'cbxRegistrationQuote'], { gridTemplateColumns: ['1fr', '1fr 1fr'] }],
|
[['cbxInsurance', 'cbxRegistrationQuote'], { gridTemplateColumns: ['1fr', '1fr 1fr'] }],
|
||||||
[['cbxTechnicalCardQuote', 'cbxNSIB'], { gridTemplateColumns: ['1fr', '1fr 1fr'] }],
|
[['cbxTechnicalCardQuote', 'cbxNSIB'], { gridTemplateColumns: ['1fr', '1fr 1fr'] }],
|
||||||
[['cbxQuoteRedemptionGraph', 'cbxShowFinGAP'], { gridTemplateColumns: ['1fr', '1fr 1fr'] }],
|
[['cbxQuoteRedemptionGraph', 'cbxShowFinGAP'], { gridTemplateColumns: ['1fr', '1fr 1fr'] }],
|
||||||
[['cbxQuoteShowAcceptLimit'], { gridTemplateColumns: ['1fr', '1fr 1fr'] }],
|
|
||||||
[['tbxQuoteName', 'radioQuoteContactGender'], { gridTemplateColumns: ['1fr', '2fr 1fr'] }],
|
[['tbxQuoteName', 'radioQuoteContactGender'], { gridTemplateColumns: ['1fr', '2fr 1fr'] }],
|
||||||
];
|
];
|
||||||
|
|||||||
@ -1,41 +1,129 @@
|
|||||||
/* eslint-disable sonarjs/cognitive-complexity */
|
/* eslint-disable sonarjs/cognitive-complexity */
|
||||||
import { PolicyTable, ReloadButton, Validation } from './Components';
|
import { PolicyTable, ReloadButton, Validation } from './Components';
|
||||||
import { columns } from './lib/config';
|
import { columns } from './lib/config';
|
||||||
import { resetRow } from './lib/tools';
|
import { makeEltKaskoRequest } from './lib/make-request';
|
||||||
import type { Row, StoreSelector } from './types';
|
import type { Row, StoreSelector } from './types';
|
||||||
|
import { getEltKasko } from '@/api/elt/query';
|
||||||
|
import { MAX_FRANCHISE, MAX_INSURANCE, MIN_INSURANCE } from '@/constants/values';
|
||||||
|
import helper from '@/process/elt/lib/helper';
|
||||||
import { useStore } from '@/stores/hooks';
|
import { useStore } from '@/stores/hooks';
|
||||||
import { trpcClient } from '@/trpc/client';
|
import { defaultRow } from '@/stores/tables/elt/default-values';
|
||||||
|
import { useApolloClient } from '@apollo/client';
|
||||||
import { observer } from 'mobx-react-lite';
|
import { observer } from 'mobx-react-lite';
|
||||||
|
import { omit, sift } from 'radash';
|
||||||
|
import { useCallback } from 'react';
|
||||||
import { Flex } from 'ui/grid';
|
import { Flex } from 'ui/grid';
|
||||||
|
|
||||||
const storeSelector: StoreSelector = ({ kasko }) => kasko;
|
const storeSelector: StoreSelector = ({ kasko }) => kasko;
|
||||||
|
|
||||||
|
const initialData = {
|
||||||
|
...omit(defaultRow, ['name', 'key', 'id']),
|
||||||
|
error: null,
|
||||||
|
kaskoSum: 0,
|
||||||
|
paymentPeriods: [
|
||||||
|
{
|
||||||
|
kaskoSum: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
export const Kasko = observer(() => {
|
export const Kasko = observer(() => {
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const { $calculation, $tables } = store;
|
const { $calculation, $tables } = store;
|
||||||
|
const apolloClient = useApolloClient();
|
||||||
|
const { init } = helper({ apolloClient, store });
|
||||||
|
|
||||||
const calculateKasko = trpcClient.eltKasko.useMutation({
|
const handleOnClick = useCallback(async () => {
|
||||||
onError() {
|
$tables.elt.kasko.abortController?.abort();
|
||||||
$tables.elt.kasko.setRows(
|
$tables.elt.kasko.abortController = new AbortController();
|
||||||
$tables.elt.kasko.getRows.map((row) => ({ ...row, status: 'error' }))
|
|
||||||
);
|
|
||||||
},
|
|
||||||
onMutate: () => {
|
|
||||||
const rows = $tables.elt.kasko.getRows;
|
|
||||||
$tables.elt.kasko.setRows(rows.map((row) => ({ ...resetRow(row), status: 'fetching' })));
|
|
||||||
},
|
|
||||||
onSuccess: ({ rows }) => {
|
|
||||||
$tables.elt.kasko.setRows(rows);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
function handleOnClick() {
|
const { kasko } = await init();
|
||||||
calculateKasko.mutate({
|
$tables.elt.kasko.setRows(kasko);
|
||||||
calculation: {
|
const kaskoCompanyIds = sift(
|
||||||
values: store.$calculation.$values.getValues(),
|
$tables.insurance
|
||||||
},
|
.row('kasko')
|
||||||
|
.getOptions('insuranceCompany')
|
||||||
|
.map((x) => x.value)
|
||||||
|
);
|
||||||
|
const values = $calculation.$values.getValues();
|
||||||
|
|
||||||
|
kaskoCompanyIds.forEach((key) => {
|
||||||
|
const row = $tables.elt.kasko.getRow(key);
|
||||||
|
if (row) {
|
||||||
|
$tables.elt.kasko.setRow({ key, status: 'fetching' });
|
||||||
|
makeEltKaskoRequest({ apolloClient, store }, row)
|
||||||
|
.then((payload) =>
|
||||||
|
getEltKasko(payload, { signal: $tables.elt.kasko.abortController?.signal })
|
||||||
|
)
|
||||||
|
.then((res) => {
|
||||||
|
if (res) {
|
||||||
|
const {
|
||||||
|
kaskoSum = 0,
|
||||||
|
message,
|
||||||
|
paymentPeriods,
|
||||||
|
requestId,
|
||||||
|
skCalcId,
|
||||||
|
totalFranchise = 0,
|
||||||
|
} = res;
|
||||||
|
let { error } = res;
|
||||||
|
|
||||||
|
const sum =
|
||||||
|
values.leasingPeriod <= 16 ? kaskoSum : paymentPeriods?.[0]?.kaskoSum || 0;
|
||||||
|
|
||||||
|
if (totalFranchise > MAX_FRANCHISE) {
|
||||||
|
error ||= `Франшиза по страховке превышает максимально допустимое значение: ${Intl.NumberFormat(
|
||||||
|
'ru',
|
||||||
|
{
|
||||||
|
currency: 'RUB',
|
||||||
|
style: 'currency',
|
||||||
|
}
|
||||||
|
).format(MAX_FRANCHISE)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sum > MAX_INSURANCE) {
|
||||||
|
error ||= `Сумма по страховке превышает максимально допустимое значение по стоимости КАСКО: ${Intl.NumberFormat(
|
||||||
|
'ru',
|
||||||
|
{
|
||||||
|
currency: 'RUB',
|
||||||
|
style: 'currency',
|
||||||
|
}
|
||||||
|
).format(MAX_INSURANCE)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sum < MIN_INSURANCE) {
|
||||||
|
error ||= `Сумма по страховке не должна быть меньше допустимого значения по стоимости КАСКО: ${Intl.NumberFormat(
|
||||||
|
'ru',
|
||||||
|
{
|
||||||
|
currency: 'RUB',
|
||||||
|
style: 'currency',
|
||||||
|
}
|
||||||
|
).format(MIN_INSURANCE)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tables.elt.kasko.setRow({
|
||||||
|
key,
|
||||||
|
message: error || message,
|
||||||
|
numCalc: '0',
|
||||||
|
requestId,
|
||||||
|
skCalcId,
|
||||||
|
status: error ? 'error' : null,
|
||||||
|
sum,
|
||||||
|
totalFranchise,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
const _err = error as Error;
|
||||||
|
$tables.elt.kasko.setRow({
|
||||||
|
...initialData,
|
||||||
|
key,
|
||||||
|
message: _err.message || String(error),
|
||||||
|
status: 'error',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}, [$calculation.$values, $tables.elt.kasko, $tables.insurance, apolloClient, init, store]);
|
||||||
|
|
||||||
function handleOnSelectRow(row: Row) {
|
function handleOnSelectRow(row: Row) {
|
||||||
$tables.insurance.row('kasko').column('insuranceCompany').setValue(row.key);
|
$tables.insurance.row('kasko').column('insuranceCompany').setValue(row.key);
|
||||||
|
|||||||
@ -2,41 +2,125 @@
|
|||||||
/* eslint-disable sonarjs/cognitive-complexity */
|
/* eslint-disable sonarjs/cognitive-complexity */
|
||||||
import { PolicyTable, ReloadButton, Validation } from './Components';
|
import { PolicyTable, ReloadButton, Validation } from './Components';
|
||||||
import { columns } from './lib/config';
|
import { columns } from './lib/config';
|
||||||
import { resetRow } from './lib/tools';
|
import { makeEltOsagoRequest, makeOwnOsagoRequest } from './lib/make-request';
|
||||||
import type { Row, StoreSelector } from './types';
|
import type { Row, StoreSelector } from './types';
|
||||||
|
import { getEltOsago } from '@/api/elt/query';
|
||||||
|
import { MAX_INSURANCE, MIN_INSURANCE } from '@/constants/values';
|
||||||
|
import helper from '@/process/elt/lib/helper';
|
||||||
import { useStore } from '@/stores/hooks';
|
import { useStore } from '@/stores/hooks';
|
||||||
import { trpcClient } from '@/trpc/client';
|
import { defaultRow } from '@/stores/tables/elt/default-values';
|
||||||
|
import { useApolloClient } from '@apollo/client';
|
||||||
import { observer } from 'mobx-react-lite';
|
import { observer } from 'mobx-react-lite';
|
||||||
|
import { omit, sift } from 'radash';
|
||||||
|
import { useCallback } from 'react';
|
||||||
import { Flex } from 'ui/grid';
|
import { Flex } from 'ui/grid';
|
||||||
|
|
||||||
const storeSelector: StoreSelector = ({ osago }) => osago;
|
const storeSelector: StoreSelector = ({ osago }) => osago;
|
||||||
|
|
||||||
|
const initialData = {
|
||||||
|
...omit(defaultRow, ['name', 'key', 'id']),
|
||||||
|
error: null,
|
||||||
|
premiumSum: 0,
|
||||||
|
};
|
||||||
|
|
||||||
export const Osago = observer(() => {
|
export const Osago = observer(() => {
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const { $tables } = store;
|
const { $tables } = store;
|
||||||
|
const apolloClient = useApolloClient();
|
||||||
|
const { init } = helper({ apolloClient, store });
|
||||||
|
|
||||||
const calculateOsago = trpcClient.eltOsago.useMutation({
|
const handleOnClick = useCallback(async () => {
|
||||||
onError() {
|
$tables.elt.osago.abortController?.abort();
|
||||||
$tables.elt.osago.setRows(
|
$tables.elt.osago.abortController = new AbortController();
|
||||||
$tables.elt.osago.getRows.map((row) => ({ ...row, status: 'error' }))
|
|
||||||
);
|
|
||||||
},
|
|
||||||
onMutate: () => {
|
|
||||||
const rows = $tables.elt.osago.getRows;
|
|
||||||
$tables.elt.osago.setRows(rows.map((row) => ({ ...resetRow(row), status: 'fetching' })));
|
|
||||||
},
|
|
||||||
onSuccess: ({ rows }) => {
|
|
||||||
$tables.elt.osago.setRows(rows);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
async function handleOnClick() {
|
const { osago } = await init();
|
||||||
calculateOsago.mutate({
|
$tables.elt.osago.setRows(osago);
|
||||||
calculation: {
|
const osagoCompanyIds = sift(
|
||||||
values: store.$calculation.$values.getValues(),
|
$tables.insurance
|
||||||
},
|
.row('osago')
|
||||||
|
.getOptions('insuranceCompany')
|
||||||
|
.map((x) => x.value)
|
||||||
|
);
|
||||||
|
|
||||||
|
osagoCompanyIds.forEach((key) => {
|
||||||
|
const row = $tables.elt.osago.getRow(key);
|
||||||
|
if (row) {
|
||||||
|
row.status = 'fetching';
|
||||||
|
$tables.elt.osago.setRow(row);
|
||||||
|
|
||||||
|
if (row.metodCalc === 'CRM') {
|
||||||
|
makeOwnOsagoRequest({ apolloClient, store }, row).then((res) => {
|
||||||
|
if (!res) {
|
||||||
|
$tables.elt.osago.setRow({
|
||||||
|
key,
|
||||||
|
message:
|
||||||
|
'Для получения расчета ОСАГО следует использовать калькулятор ЭЛТ или Индивидуальный запрос',
|
||||||
|
numCalc: undefined,
|
||||||
|
skCalcId: undefined,
|
||||||
|
status: 'error',
|
||||||
|
sum: 0,
|
||||||
|
totalFranchise: 0,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$tables.elt.osago.setRow({
|
||||||
|
key,
|
||||||
|
message: null,
|
||||||
|
numCalc: res.evo_id || undefined,
|
||||||
|
status: null,
|
||||||
|
sum: res.evo_graph_price_withoutnds || undefined,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
makeEltOsagoRequest({ apolloClient, store }, row)
|
||||||
|
.then((payload) =>
|
||||||
|
getEltOsago(payload, { signal: $tables.elt.osago.abortController.signal })
|
||||||
|
)
|
||||||
|
.then((res) => {
|
||||||
|
if (res) {
|
||||||
|
const { message, numCalc, premiumSum = 0, skCalcId } = res;
|
||||||
|
let { error } = res;
|
||||||
|
if (premiumSum > MAX_INSURANCE) {
|
||||||
|
error ||= `Сумма по страховке превышает максимально допустимое значение по стоимости ОСАГО: ${Intl.NumberFormat(
|
||||||
|
'ru',
|
||||||
|
{
|
||||||
|
currency: 'RUB',
|
||||||
|
style: 'currency',
|
||||||
|
}
|
||||||
|
).format(MAX_INSURANCE)}`;
|
||||||
|
}
|
||||||
|
if (premiumSum < MIN_INSURANCE) {
|
||||||
|
error ||= `Сумма по страховке не должна быть меньше допустимого значения по стоимости ОСАГО: ${Intl.NumberFormat(
|
||||||
|
'ru',
|
||||||
|
{
|
||||||
|
currency: 'RUB',
|
||||||
|
style: 'currency',
|
||||||
|
}
|
||||||
|
).format(MIN_INSURANCE)}`;
|
||||||
|
}
|
||||||
|
$tables.elt.osago.setRow({
|
||||||
|
key,
|
||||||
|
message: error || message,
|
||||||
|
numCalc: `${numCalc}`,
|
||||||
|
skCalcId,
|
||||||
|
status: error ? 'error' : null,
|
||||||
|
sum: premiumSum,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
const _err = error as Error;
|
||||||
|
$tables.elt.osago.setRow({
|
||||||
|
...initialData,
|
||||||
|
key,
|
||||||
|
message: _err.message || String(error),
|
||||||
|
status: 'error',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}, [$tables.elt.osago, $tables.insurance, apolloClient, init, store]);
|
||||||
|
|
||||||
function handleOnSelectRow(row: Row) {
|
function handleOnSelectRow(row: Row) {
|
||||||
$tables.insurance.row('osago').column('insuranceCompany').setValue(row.key);
|
$tables.insurance.row('osago').column('insuranceCompany').setValue(row.key);
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
import type { Row } from '../types';
|
import type { RowSchema } from '@/config/schema/elt';
|
||||||
import type { ColumnsType } from 'antd/lib/table';
|
import type { ColumnsType } from 'antd/lib/table';
|
||||||
import { CloseOutlined, LoadingOutlined } from 'ui/elements/icons';
|
import { CloseOutlined, LoadingOutlined } from 'ui/elements/icons';
|
||||||
import { Flex } from 'ui/grid';
|
import { Flex } from 'ui/grid';
|
||||||
|
import type { z } from 'zod';
|
||||||
|
|
||||||
|
type Row = z.infer<typeof RowSchema>;
|
||||||
|
|
||||||
const formatter = Intl.NumberFormat('ru', {
|
const formatter = Intl.NumberFormat('ru', {
|
||||||
currency: 'RUB',
|
currency: 'RUB',
|
||||||
|
|||||||
@ -1,18 +1,18 @@
|
|||||||
/* eslint-disable sonarjs/cognitive-complexity */
|
/* eslint-disable sonarjs/cognitive-complexity */
|
||||||
/* eslint-disable complexity */
|
/* eslint-disable complexity */
|
||||||
|
import type { Row } from '../types';
|
||||||
import type { RequestEltKasko, RequestEltOsago } from '@/api/elt/types';
|
import type { RequestEltKasko, RequestEltOsago } from '@/api/elt/types';
|
||||||
import type { Row } from '@/Components/Calculation/Form/ELT/types';
|
|
||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import type { ProcessContext } from '@/process/types';
|
import type { ProcessContext } from '@/process/types';
|
||||||
import { getCurrentDateString } from '@/utils/date';
|
import { getCurrentISODate } from '@/utils/date';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { first, sort } from 'radash';
|
import { first, sort } from 'radash';
|
||||||
|
|
||||||
export async function ownOsagoRequest(
|
export async function makeOwnOsagoRequest(
|
||||||
{ store, apolloClient }: Pick<ProcessContext, 'apolloClient' | 'store'>,
|
{ store, apolloClient }: Pick<ProcessContext, 'apolloClient' | 'store'>,
|
||||||
row: Row
|
row: Row
|
||||||
): Promise<NonNullable<CRMTypes.GetOsagoAddproductTypesQuery['evo_addproduct_types']>[number]> {
|
): Promise<NonNullable<CRMTypes.GetOsagoAddproductTypesQuery['evo_addproduct_types']>[number]> {
|
||||||
const currentDate = getCurrentDateString();
|
const currentDate = getCurrentISODate();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: { evo_addproduct_types },
|
data: { evo_addproduct_types },
|
||||||
@ -471,8 +471,7 @@ export async function makeEltKaskoRequest(
|
|||||||
let selfIgnitionSpecified = false;
|
let selfIgnitionSpecified = false;
|
||||||
if (
|
if (
|
||||||
leaseObjectCategory === 100_000_002 ||
|
leaseObjectCategory === 100_000_002 ||
|
||||||
(evo_leasingobject_type?.evo_id &&
|
(evo_leasingobject_type?.evo_id && ['6', '9', '10'].includes(evo_leasingobject_type?.evo_id))
|
||||||
['6', '8', '9', '10'].includes(evo_leasingobject_type?.evo_id))
|
|
||||||
) {
|
) {
|
||||||
notConfirmedGlassesDamages = 3;
|
notConfirmedGlassesDamages = 3;
|
||||||
notConfirmedGlassesDamagesSpecified = true;
|
notConfirmedGlassesDamagesSpecified = true;
|
||||||
@ -618,26 +617,10 @@ export async function makeEltKaskoRequest(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let classification = '11606';
|
const classification =
|
||||||
|
leaseObjectCategory && [100_000_002, 100_000_003, 100_000_004].includes(leaseObjectCategory)
|
||||||
switch (evo_leasingobject_type?.evo_id) {
|
? '11635'
|
||||||
case '7': {
|
: '0';
|
||||||
classification = '11611';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case '3': {
|
|
||||||
classification = '11607';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case '8': {
|
|
||||||
classification = '11650';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
classification = '11606';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let INN = '';
|
let INN = '';
|
||||||
const leadid = $calculation.element('selectLead').getValue();
|
const leadid = $calculation.element('selectLead').getValue();
|
||||||
@ -1,12 +0,0 @@
|
|||||||
import type { Row } from '@/Components/Calculation/Form/ELT/types';
|
|
||||||
import { defaultRow } from '@/stores/tables/elt/default-values';
|
|
||||||
|
|
||||||
export function resetRow(row: Row): Row {
|
|
||||||
return {
|
|
||||||
...defaultRow,
|
|
||||||
id: row.id,
|
|
||||||
key: row.key,
|
|
||||||
metodCalc: row.metodCalc,
|
|
||||||
name: row.name,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@ -1,14 +1,13 @@
|
|||||||
import type { FormTabRows } from '../../lib/render-rows';
|
import type { FormTabRows } from '../../lib/render-rows';
|
||||||
import { transformRowsForMobile } from '../lib/utils';
|
|
||||||
|
|
||||||
export const id = 'insurance';
|
export const id = 'insurance';
|
||||||
export const title = 'Страхование';
|
export const title = 'Страхование';
|
||||||
|
|
||||||
export const rows: FormTabRows = [
|
export const rows: FormTabRows = [
|
||||||
[['tbxLeaseObjectYear', 'selectLeaseObjectUseFor', 'selectLegalClientRegion']],
|
[['tbxLeaseObjectYear', 'selectLeaseObjectUseFor', 'selectLegalClientRegion']],
|
||||||
[['tbxMileage', 'tbxInsFranchise', 'selectLegalClientTown']],
|
[['selectEngineType', 'tbxInsFranchise', 'selectLegalClientTown']],
|
||||||
[['selectGPSBrand', 'cbxWithTrailer', 'selectInsNSIB']],
|
[['selectLeaseObjectCategory', 'tbxMileage']],
|
||||||
[['selectGPSModel', 'cbxInsDecentral', 'selectLeasingWithoutKasko']],
|
[['tbxLeaseObjectMotorPower', 'cbxWithTrailer', 'selectGPSBrand']],
|
||||||
|
[['tbxEngineVolume', 'cbxInsDecentral', 'selectGPSModel']],
|
||||||
|
[['selectLeasingWithoutKasko', 'selectInsNSIB']],
|
||||||
];
|
];
|
||||||
|
|
||||||
export const mobileRows = transformRowsForMobile(rows);
|
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
import renderFormRows from '../../lib/render-rows';
|
import renderFormRows from '../../lib/render-rows';
|
||||||
import { id, mobileRows, rows, title } from './config';
|
import { id, rows, title } from './config';
|
||||||
import FinGAPTable from './FinGAPTable';
|
import FinGAPTable from './FinGAPTable';
|
||||||
import InsuranceTable from './InsuranceTable';
|
import InsuranceTable from './InsuranceTable';
|
||||||
import { Media } from '@/styles/media';
|
|
||||||
import { Flex } from 'ui/grid';
|
import { Flex } from 'ui/grid';
|
||||||
|
|
||||||
function Insurance() {
|
function Insurance() {
|
||||||
|
const renderedRows = renderFormRows(rows);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex flexDirection="column">
|
<Flex flexDirection="column">
|
||||||
<Media lessThan="laptop">{renderFormRows(mobileRows)}</Media>
|
{renderedRows}
|
||||||
<Media greaterThanOrEqual="laptop">{renderFormRows(rows)}</Media>
|
|
||||||
<InsuranceTable />
|
<InsuranceTable />
|
||||||
<FinGAPTable />
|
<FinGAPTable />
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import type { FormTabRows } from '../../lib/render-rows';
|
import type { FormTabRows } from '../../lib/render-rows';
|
||||||
import { transformRowsForMobile } from '../lib/utils';
|
|
||||||
|
|
||||||
export const id = 'leasing-object';
|
export const id = 'leasing-object';
|
||||||
export const title = 'ПЛ';
|
export const title = 'ПЛ';
|
||||||
@ -17,5 +16,3 @@ export const rows: FormTabRows = [
|
|||||||
[['selectLeaseObjectCategory', 'tbxEngineVolume', 'tbxMileage']],
|
[['selectLeaseObjectCategory', 'tbxEngineVolume', 'tbxMileage']],
|
||||||
[['tbxMaxMass', 'tbxEngineHours', 'tbxVIN']],
|
[['tbxMaxMass', 'tbxEngineHours', 'tbxVIN']],
|
||||||
];
|
];
|
||||||
|
|
||||||
export const mobileRows = transformRowsForMobile(rows);
|
|
||||||
|
|||||||
@ -1,14 +1,8 @@
|
|||||||
import renderFormRows from '../../lib/render-rows';
|
import renderFormRows from '../../lib/render-rows';
|
||||||
import { id, mobileRows, rows, title } from './config';
|
import { id, rows, title } from './config';
|
||||||
import { Media } from '@/styles/media';
|
|
||||||
|
|
||||||
function LeasingObject() {
|
function LeasingObject() {
|
||||||
return (
|
return renderFormRows(rows);
|
||||||
<>
|
|
||||||
<Media lessThan="laptop">{renderFormRows(mobileRows)}</Media>
|
|
||||||
<Media greaterThanOrEqual="laptop">{renderFormRows(rows)}</Media>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import type { FormTabRows } from '../../lib/render-rows';
|
import type { FormTabRows } from '../../lib/render-rows';
|
||||||
import { transformRowsForMobile } from '../lib/utils';
|
|
||||||
|
|
||||||
export const id = 'supplier-agent';
|
export const id = 'supplier-agent';
|
||||||
export const title = 'Поставщик/агент';
|
export const title = 'Поставщик/агент';
|
||||||
@ -21,5 +20,3 @@ export const rows: FormTabRows = [
|
|||||||
[['selectCalcBrokerRewardCondition', 'selectFinDepartmentRewardCondtion'], defaultRowStyle],
|
[['selectCalcBrokerRewardCondition', 'selectFinDepartmentRewardCondtion'], defaultRowStyle],
|
||||||
[['tbxCalcBrokerRewardSum', 'tbxFinDepartmentRewardSumm'], defaultRowStyle],
|
[['tbxCalcBrokerRewardSum', 'tbxFinDepartmentRewardSumm'], defaultRowStyle],
|
||||||
];
|
];
|
||||||
|
|
||||||
export const mobileRows = transformRowsForMobile(rows);
|
|
||||||
|
|||||||
@ -1,14 +1,8 @@
|
|||||||
import renderFormRows from '../../lib/render-rows';
|
import renderFormRows from '../../lib/render-rows';
|
||||||
import { id, mobileRows, rows, title } from './config';
|
import { id, rows, title } from './config';
|
||||||
import { Media } from '@/styles/media';
|
|
||||||
|
|
||||||
function Leasing() {
|
function Leasing() {
|
||||||
return (
|
return renderFormRows(rows);
|
||||||
<>
|
|
||||||
<Media lessThan="laptop">{renderFormRows(mobileRows)}</Media>
|
|
||||||
<Media greaterThanOrEqual="laptop">{renderFormRows(rows)}</Media>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
@ -8,9 +8,7 @@ import Payments from './Payments';
|
|||||||
import SupplierAgent from './SupplierAgent';
|
import SupplierAgent from './SupplierAgent';
|
||||||
import Unlimited from './Unlimited';
|
import Unlimited from './Unlimited';
|
||||||
import Background from '@/Components/Layout/Background';
|
import Background from '@/Components/Layout/Background';
|
||||||
import { useStore } from '@/stores/hooks';
|
|
||||||
import { min } from '@/styles/mq';
|
import { min } from '@/styles/mq';
|
||||||
import { memo } from 'react';
|
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { Tabs } from 'ui/elements';
|
import { Tabs } from 'ui/elements';
|
||||||
|
|
||||||
@ -46,23 +44,20 @@ const ComponentWrapper = styled.div`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const Form = memo(() => {
|
export function Form({ prune }) {
|
||||||
const { $process } = useStore();
|
|
||||||
|
|
||||||
const filteredTabs =
|
|
||||||
$process.has('Unlimited') === false ? formTabs.filter((x) => x.id !== 'unlimited') : formTabs;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<Tabs type="card" tabBarGutter="5px">
|
<Tabs type="card" tabBarGutter="5px">
|
||||||
{filteredTabs.map(({ Component, id, title }) => (
|
{formTabs
|
||||||
<Tabs.TabPane tab={title} key={id}>
|
.filter((tab) => !prune?.includes(tab.id))
|
||||||
<ComponentWrapper>
|
.map(({ Component, id, title }) => (
|
||||||
<Component />
|
<Tabs.TabPane tab={title} key={id}>
|
||||||
</ComponentWrapper>
|
<ComponentWrapper>
|
||||||
</Tabs.TabPane>
|
<Component />
|
||||||
))}
|
</ComponentWrapper>
|
||||||
|
</Tabs.TabPane>
|
||||||
|
))}
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
);
|
);
|
||||||
});
|
}
|
||||||
|
|||||||
@ -1,32 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* @param {import('../../lib/render-rows').FormTabRows} rows
|
|
||||||
* @returns {import('../../lib/render-rows').FormTabRows}
|
|
||||||
*/
|
|
||||||
export function transformRowsForMobile(rows) {
|
|
||||||
const mobileRows = [];
|
|
||||||
let columnGroups = {};
|
|
||||||
|
|
||||||
rows.forEach((row) => {
|
|
||||||
if (Array.isArray(row)) {
|
|
||||||
row[0].forEach((item, index) => {
|
|
||||||
if (!columnGroups[index]) {
|
|
||||||
columnGroups[index] = [];
|
|
||||||
}
|
|
||||||
columnGroups[index].push(item);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
Object.values(columnGroups).forEach((group) => {
|
|
||||||
mobileRows.push([group, { gridTemplateColumns: '1fr' }]);
|
|
||||||
});
|
|
||||||
columnGroups = {};
|
|
||||||
mobileRows.push(row);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Object.values(columnGroups).forEach((group) => {
|
|
||||||
mobileRows.push([group, { gridTemplateColumns: '1fr' }]);
|
|
||||||
});
|
|
||||||
|
|
||||||
return mobileRows;
|
|
||||||
}
|
|
||||||
@ -42,7 +42,7 @@ const Wrapper = styled(Background)`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const Output = observer(({ tabs }) => {
|
export const Output = observer(() => {
|
||||||
const { $results } = useStore();
|
const { $results } = useStore();
|
||||||
const [activeKey, setActiveKey] = useState(undefined);
|
const [activeKey, setActiveKey] = useState(undefined);
|
||||||
const { hasErrors } = useErrors();
|
const { hasErrors } = useErrors();
|
||||||
@ -52,15 +52,15 @@ export const Output = observer(({ tabs }) => {
|
|||||||
setActiveKey('payments-table');
|
setActiveKey('payments-table');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tabs && hasErrors) {
|
if (hasErrors) {
|
||||||
setActiveKey('validation');
|
setActiveKey('validation');
|
||||||
}
|
}
|
||||||
}, [$results.payments.length, hasErrors, tabs]);
|
}, [$results.payments.length, hasErrors]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<Tabs
|
<Tabs
|
||||||
items={tabs ? items.filter((x) => x.key !== 'validation') : items}
|
items={items}
|
||||||
activeKey={activeKey}
|
activeKey={activeKey}
|
||||||
onChange={(key) => {
|
onChange={(key) => {
|
||||||
setActiveKey(key);
|
setActiveKey(key);
|
||||||
|
|||||||
@ -18,8 +18,8 @@ export const mainRows: FormTabRows = [
|
|||||||
[
|
[
|
||||||
['btnCreateKP', 'linkDownloadKp'],
|
['btnCreateKP', 'linkDownloadKp'],
|
||||||
{
|
{
|
||||||
gap: ['10px'],
|
gap: [0, '10px'],
|
||||||
gridTemplateColumns: ['1fr 1fr'],
|
gridTemplateColumns: ['1fr', '1fr 1fr'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@ -41,8 +41,8 @@ export const unlimitedMainRows: FormTabRows = [
|
|||||||
[
|
[
|
||||||
['btnCreateKP', 'linkDownloadKp'],
|
['btnCreateKP', 'linkDownloadKp'],
|
||||||
{
|
{
|
||||||
gap: ['10px'],
|
gap: [0, '10px'],
|
||||||
gridTemplateColumns: ['1fr 1fr'],
|
gridTemplateColumns: ['1fr', '1fr 1fr'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import * as config from './config';
|
|||||||
import Background from '@/Components/Layout/Background';
|
import Background from '@/Components/Layout/Background';
|
||||||
import { useStore } from '@/stores/hooks';
|
import { useStore } from '@/stores/hooks';
|
||||||
import { min } from '@/styles/mq';
|
import { min } from '@/styles/mq';
|
||||||
import { memo } from 'react';
|
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
const Wrapper = styled(Background)`
|
const Wrapper = styled(Background)`
|
||||||
@ -18,7 +17,7 @@ const Wrapper = styled(Background)`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const Settings = memo(() => {
|
export function Settings() {
|
||||||
const { $process } = useStore();
|
const { $process } = useStore();
|
||||||
|
|
||||||
const mainRows = $process.has('Unlimited')
|
const mainRows = $process.has('Unlimited')
|
||||||
@ -34,4 +33,4 @@ export const Settings = memo(() => {
|
|||||||
{paramsRows}
|
{paramsRows}
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
);
|
);
|
||||||
});
|
}
|
||||||
|
|||||||
@ -1,19 +0,0 @@
|
|||||||
import Validation from '../Output/Validation';
|
|
||||||
import Background from '@/Components/Layout/Background';
|
|
||||||
import { min } from '@/styles/mq';
|
|
||||||
import { memo } from 'react';
|
|
||||||
import styled from 'styled-components';
|
|
||||||
|
|
||||||
const Wrapper = styled(Background)`
|
|
||||||
padding: 4px 10px;
|
|
||||||
|
|
||||||
${min('laptop')} {
|
|
||||||
padding: 4px 18px;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const Component = memo(() => (
|
|
||||||
<Wrapper>
|
|
||||||
<Validation.Component />
|
|
||||||
</Wrapper>
|
|
||||||
));
|
|
||||||
@ -136,7 +136,6 @@ const components = wrapComponentsMap({
|
|||||||
cbxPartialVAT: e.Switch,
|
cbxPartialVAT: e.Switch,
|
||||||
cbxFloatingRate: e.Switch,
|
cbxFloatingRate: e.Switch,
|
||||||
cbxQuotePriceWithFullVAT: e.Switch,
|
cbxQuotePriceWithFullVAT: e.Switch,
|
||||||
cbxQuoteShowAcceptLimit: e.Switch,
|
|
||||||
|
|
||||||
/** Readonly Elements */
|
/** Readonly Elements */
|
||||||
labelLeaseObjectRisk: e.Text,
|
labelLeaseObjectRisk: e.Text,
|
||||||
|
|||||||
@ -130,7 +130,6 @@ const titles: Record<ActionElements | ValuesElements, string> = {
|
|||||||
cbxPartialVAT: 'Частичный НДС',
|
cbxPartialVAT: 'Частичный НДС',
|
||||||
cbxFloatingRate: 'Плавающая ставка',
|
cbxFloatingRate: 'Плавающая ставка',
|
||||||
cbxQuotePriceWithFullVAT: 'Отображать Стоимость ПЛ с полным НДС',
|
cbxQuotePriceWithFullVAT: 'Отображать Стоимость ПЛ с полным НДС',
|
||||||
cbxQuoteShowAcceptLimit: 'Отображать одобренный лимит',
|
|
||||||
|
|
||||||
/** Link Elements */
|
/** Link Elements */
|
||||||
linkDownloadKp: '',
|
linkDownloadKp: '',
|
||||||
|
|||||||
@ -195,7 +195,6 @@ const types = wrapElementsTypes({
|
|||||||
cbxPartialVAT: t.Switch,
|
cbxPartialVAT: t.Switch,
|
||||||
cbxFloatingRate: t.Switch,
|
cbxFloatingRate: t.Switch,
|
||||||
cbxQuotePriceWithFullVAT: t.Switch,
|
cbxQuotePriceWithFullVAT: t.Switch,
|
||||||
cbxQuoteShowAcceptLimit: t.Switch,
|
|
||||||
|
|
||||||
labelLeaseObjectRisk: t.Readonly,
|
labelLeaseObjectRisk: t.Readonly,
|
||||||
tbxInsKaskoPriceLeasePeriod: t.Readonly,
|
tbxInsKaskoPriceLeasePeriod: t.Readonly,
|
||||||
|
|||||||
@ -133,7 +133,6 @@ const elementsToValues = wrapElementsMap({
|
|||||||
cbxPartialVAT: 'partialVAT',
|
cbxPartialVAT: 'partialVAT',
|
||||||
cbxFloatingRate: 'floatingRate',
|
cbxFloatingRate: 'floatingRate',
|
||||||
cbxQuotePriceWithFullVAT: 'quotePriceWithFullVAT',
|
cbxQuotePriceWithFullVAT: 'quotePriceWithFullVAT',
|
||||||
cbxQuoteShowAcceptLimit: 'quoteShowAcceptLimit',
|
|
||||||
|
|
||||||
/** Readonly Elements */
|
/** Readonly Elements */
|
||||||
labelLeaseObjectRisk: 'leaseObjectRiskName',
|
labelLeaseObjectRisk: 'leaseObjectRiskName',
|
||||||
|
|||||||
4
apps/web/Components/Calculation/index.ts
Normal file
4
apps/web/Components/Calculation/index.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export * from './Form';
|
||||||
|
export * from './Layout';
|
||||||
|
export * from './Output';
|
||||||
|
export * from './Settings';
|
||||||
@ -1,101 +0,0 @@
|
|||||||
import { Form } from './Form';
|
|
||||||
import { Layout } from './Layout';
|
|
||||||
import { Output } from './Output';
|
|
||||||
import { Settings } from './Settings';
|
|
||||||
import { Component as Validation } from './Validation';
|
|
||||||
import { Notification } from '@/Components/Common';
|
|
||||||
import { NavigationBar, Tabs } from '@/Components/Layout/Navigation';
|
|
||||||
import { NavigationProvider } from '@/context/navigation';
|
|
||||||
import { useErrors, useResults } from '@/stores/hooks';
|
|
||||||
import { Media } from '@/styles/media';
|
|
||||||
import { getPageTitle } from '@/utils/page';
|
|
||||||
import { observer } from 'mobx-react-lite';
|
|
||||||
import Head from 'next/head';
|
|
||||||
import styled from 'styled-components';
|
|
||||||
import { Badge } from 'ui/elements';
|
|
||||||
import {
|
|
||||||
BarChartOutlined,
|
|
||||||
CalculatorOutlined,
|
|
||||||
ProfileOutlined,
|
|
||||||
WarningOutlined,
|
|
||||||
} from 'ui/elements/icons';
|
|
||||||
|
|
||||||
const defaultIconStyle = { fontSize: '1.2rem' };
|
|
||||||
|
|
||||||
const StyledBadge = styled(Badge)`
|
|
||||||
color: unset !important;
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const tabs = [
|
|
||||||
{
|
|
||||||
Component: Settings,
|
|
||||||
Icon: () => <ProfileOutlined style={defaultIconStyle} />,
|
|
||||||
key: 'settings',
|
|
||||||
title: 'Интерес/Расчет',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Component: Form,
|
|
||||||
Icon: () => <CalculatorOutlined style={defaultIconStyle} />,
|
|
||||||
key: 'form',
|
|
||||||
title: 'Параметры',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Component: Output,
|
|
||||||
Icon: observer(() => {
|
|
||||||
const { hasResults } = useResults();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<StyledBadge status="success" dot={hasResults}>
|
|
||||||
<BarChartOutlined style={defaultIconStyle} />
|
|
||||||
</StyledBadge>
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
key: 'output',
|
|
||||||
title: 'Результаты',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Component: Validation,
|
|
||||||
Icon: observer(() => {
|
|
||||||
const { hasErrors } = useErrors();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<StyledBadge status="error" dot={hasErrors}>
|
|
||||||
<WarningOutlined style={defaultIconStyle} />
|
|
||||||
</StyledBadge>
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
key: 'errors',
|
|
||||||
title: 'Ошибки',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
type ContentProps = {
|
|
||||||
readonly initHooks: () => void;
|
|
||||||
readonly title: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function Content({ initHooks, title }: ContentProps) {
|
|
||||||
initHooks();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Head>
|
|
||||||
<title>{getPageTitle(title)}</title>
|
|
||||||
</Head>
|
|
||||||
<Notification />
|
|
||||||
<Media lessThan="laptop">
|
|
||||||
<NavigationProvider>
|
|
||||||
<Tabs tabs={tabs} />
|
|
||||||
<NavigationBar />
|
|
||||||
</NavigationProvider>
|
|
||||||
</Media>
|
|
||||||
<Media greaterThanOrEqual="laptop">
|
|
||||||
<Layout>
|
|
||||||
<Form />
|
|
||||||
<Settings />
|
|
||||||
<Output />
|
|
||||||
</Layout>
|
|
||||||
</Media>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@ -1,7 +1,4 @@
|
|||||||
/* eslint-disable import/no-mutable-exports */
|
/* eslint-disable import/no-mutable-exports */
|
||||||
import { ERROR_KEYS } from '@/@types/errors';
|
|
||||||
import { Media } from '@/styles/media';
|
|
||||||
import { getDevice } from '@/utils/device';
|
|
||||||
import type { MessageInstance } from 'antd/es/message/interface';
|
import type { MessageInstance } from 'antd/es/message/interface';
|
||||||
import type { NotificationInstance } from 'antd/es/notification/interface';
|
import type { NotificationInstance } from 'antd/es/notification/interface';
|
||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
@ -10,44 +7,9 @@ import { message as antdMessage, notification as antdNotification } from 'ui/ele
|
|||||||
export let message: Readonly<MessageInstance>;
|
export let message: Readonly<MessageInstance>;
|
||||||
export let notification: Readonly<NotificationInstance>;
|
export let notification: Readonly<NotificationInstance>;
|
||||||
|
|
||||||
function createWrapper<T extends NotificationInstance, M extends MessageInstance>(
|
export function Notification({ children }: { readonly children: ReactNode }) {
|
||||||
notificationObj: T,
|
|
||||||
messageObj: M
|
|
||||||
): T {
|
|
||||||
const handler: ProxyHandler<T> = {
|
|
||||||
get(target, prop, receiver) {
|
|
||||||
const notificationMethod = target[prop as keyof T];
|
|
||||||
const messageMethod = messageObj[prop as keyof M];
|
|
||||||
|
|
||||||
if (typeof notificationMethod === 'function' && typeof messageMethod === 'function') {
|
|
||||||
return function (...args: any[]) {
|
|
||||||
const device = getDevice();
|
|
||||||
|
|
||||||
if (device?.isMobile) {
|
|
||||||
if (typeof args[0] === 'object') {
|
|
||||||
if (ERROR_KEYS.includes(args[0].key)) return;
|
|
||||||
args[0].content = args[0].description || args[0].message;
|
|
||||||
}
|
|
||||||
|
|
||||||
messageMethod.apply(messageObj, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
notificationMethod.apply(target, args);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return Reflect.get(target, prop, receiver);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
return new Proxy(notificationObj, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function Notification({ children }: { readonly children?: ReactNode }) {
|
|
||||||
const device = getDevice();
|
|
||||||
|
|
||||||
const [messageApi, messageContextHolder] = antdMessage.useMessage({
|
const [messageApi, messageContextHolder] = antdMessage.useMessage({
|
||||||
duration: device?.isMobile ? 1.5 : 1.2,
|
duration: 1.2,
|
||||||
maxCount: 3,
|
maxCount: 3,
|
||||||
top: 70,
|
top: 70,
|
||||||
});
|
});
|
||||||
@ -59,12 +21,12 @@ export function Notification({ children }: { readonly children?: ReactNode }) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
message = messageApi;
|
message = messageApi;
|
||||||
notification = createWrapper(notificationApi, messageApi);
|
notification = notificationApi;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{messageContextHolder}
|
{messageContextHolder}
|
||||||
<Media greaterThanOrEqual="laptop">{notificationContextHolder}</Media>
|
{notificationContextHolder}
|
||||||
{children}
|
{children}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -10,7 +10,7 @@ const UserText = styled.span`
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-size: 0.55rem;
|
font-size: 0.5rem;
|
||||||
font-family: 'Montserrat';
|
font-family: 'Montserrat';
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
|
|||||||
@ -1,64 +0,0 @@
|
|||||||
import { NavigationContext } from '@/context/navigation';
|
|
||||||
import { useContext, useEffect } from 'react';
|
|
||||||
import styled from 'styled-components';
|
|
||||||
import { Flex } from 'ui/grid';
|
|
||||||
|
|
||||||
const Container = styled.div`
|
|
||||||
background-color: white;
|
|
||||||
bottom: 0;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
gap: 10px;
|
|
||||||
height: 46px;
|
|
||||||
justify-content: space-around;
|
|
||||||
position: fixed;
|
|
||||||
width: 100%;
|
|
||||||
border-top: 1px solid rgba(5, 5, 5, 0.06);
|
|
||||||
z-index: 999999;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const TabButton = styled.button`
|
|
||||||
background: ${({ active }) => (active ? 'var(--color-primary)' : 'white')};
|
|
||||||
color: ${({ active }) => (active ? 'white' : 'black')};
|
|
||||||
border-radius: 2px 2px 0 0;
|
|
||||||
border: none;
|
|
||||||
cursor: pointer;
|
|
||||||
height: 100%;
|
|
||||||
width: 100%;
|
|
||||||
font-size: 0.75rem;
|
|
||||||
`;
|
|
||||||
|
|
||||||
export function NavigationBar() {
|
|
||||||
const { currentTab, setCurrentTab, tabsList } = useContext(NavigationContext);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Container>
|
|
||||||
{tabsList.map(({ Icon, key, title }) => (
|
|
||||||
<TabButton key={key} active={key === currentTab} onClick={() => setCurrentTab(key)}>
|
|
||||||
<Flex flexDirection="column" alignItems="center">
|
|
||||||
<Icon />
|
|
||||||
{title}
|
|
||||||
</Flex>
|
|
||||||
</TabButton>
|
|
||||||
))}
|
|
||||||
</Container>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const Display = styled.div`
|
|
||||||
display: ${(props) => (props.visible ? 'block' : 'none')};
|
|
||||||
`;
|
|
||||||
|
|
||||||
export function Tabs({ tabs }) {
|
|
||||||
const { currentTab, setTabsList } = useContext(NavigationContext);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setTabsList(tabs);
|
|
||||||
}, [setTabsList, tabs]);
|
|
||||||
|
|
||||||
return tabs.map(({ Component, key }) => (
|
|
||||||
<Display key={key} visible={key === currentTab}>
|
|
||||||
<Component key={key} tabs />
|
|
||||||
</Display>
|
|
||||||
));
|
|
||||||
}
|
|
||||||
@ -49,7 +49,7 @@ const items: MenuProps['items'] = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export function AppMenu() {
|
export function AppNavigation() {
|
||||||
const { pathname } = useRouter();
|
const { pathname } = useRouter();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -1,15 +1,11 @@
|
|||||||
import Header from './Header';
|
import Header from './Header';
|
||||||
import { AppMenu } from './Menu';
|
import { AppNavigation } from './Navigation';
|
||||||
import { max, min } from '@/styles/mq';
|
import { min } from '@/styles/mq';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
const Main = styled.main`
|
const Main = styled.main`
|
||||||
margin: 8px 0;
|
margin: 8px 0;
|
||||||
|
|
||||||
${max('laptop')} {
|
|
||||||
margin-bottom: calc(46px + 8px); // height of the navigation bar
|
|
||||||
}
|
|
||||||
|
|
||||||
${min('desktop-xl')} {
|
${min('desktop-xl')} {
|
||||||
margin: 8px 10%;
|
margin: 8px 10%;
|
||||||
}
|
}
|
||||||
@ -19,7 +15,7 @@ export default function Layout({ children, user }) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Header />
|
<Header />
|
||||||
{user?.admin ? <AppMenu /> : false}
|
{user?.admin ? <AppNavigation /> : false}
|
||||||
<Main>{children}</Main>
|
<Main>{children}</Main>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -2,14 +2,14 @@
|
|||||||
# Make sure you update both files!
|
# Make sure you update both files!
|
||||||
|
|
||||||
FROM node:alpine AS builder
|
FROM node:alpine AS builder
|
||||||
RUN corepack enable && corepack prepare pnpm@8.9.0 --activate
|
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||||
ENV PNPM_HOME=/usr/local/bin
|
ENV PNPM_HOME=/usr/local/bin
|
||||||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
||||||
RUN apk add --no-cache libc6-compat
|
RUN apk add --no-cache libc6-compat
|
||||||
RUN apk update
|
RUN apk update
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN pnpm add -g turbo@1.12.4 dotenv-cli
|
RUN pnpm add -g turbo dotenv-cli
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN turbo prune --scope=web --docker
|
RUN turbo prune --scope=web --docker
|
||||||
|
|
||||||
@ -47,8 +47,6 @@ ARG URL_CORE_CALCULATE_DIRECT
|
|||||||
ARG URL_1C_TRANSTAX_DIRECT
|
ARG URL_1C_TRANSTAX_DIRECT
|
||||||
ARG URL_ELT_OSAGO_DIRECT
|
ARG URL_ELT_OSAGO_DIRECT
|
||||||
ARG URL_ELT_KASKO_DIRECT
|
ARG URL_ELT_KASKO_DIRECT
|
||||||
ARG USERNAME_1C_TRANSTAX
|
|
||||||
ARG PASSWORD_1C_TRANSTAX
|
|
||||||
RUN pnpm dotenv -v NODE_ENV=production -e .env turbo run prebuild --filter=web...
|
RUN pnpm dotenv -v NODE_ENV=production -e .env turbo run prebuild --filter=web...
|
||||||
RUN pnpm dotenv -e .env turbo run build --filter=web...
|
RUN pnpm dotenv -e .env turbo run build --filter=web...
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,11 @@
|
|||||||
export type RequestTransTax = {
|
export type RequestTransTax = {
|
||||||
CalcDate: string;
|
|
||||||
CarCategory: string;
|
|
||||||
OKTMO: string;
|
OKTMO: string;
|
||||||
Power: number;
|
calcDate: Date;
|
||||||
Year: number;
|
carCategory: string;
|
||||||
|
power: number;
|
||||||
|
year: number;
|
||||||
};
|
};
|
||||||
export type ResponseTransTax = {
|
export type ResponseTransTax = {
|
||||||
Error: string;
|
error: string;
|
||||||
Tax: number;
|
tax: number;
|
||||||
TaxRate: number;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import ValuesSchema from '@/config/schema/values';
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
export const RequestCreateKPSchema = z.object({
|
export const RequestCreateKPSchema = z.object({
|
||||||
__info: z.record(z.any()).optional(),
|
|
||||||
calculation: z
|
calculation: z
|
||||||
.object({
|
.object({
|
||||||
calculationValues: ValuesSchema,
|
calculationValues: ValuesSchema,
|
||||||
|
|||||||
@ -6,18 +6,24 @@ import axios from 'axios';
|
|||||||
|
|
||||||
const { URL_ELT_KASKO, URL_ELT_OSAGO } = getUrls();
|
const { URL_ELT_KASKO, URL_ELT_OSAGO } = getUrls();
|
||||||
|
|
||||||
export async function getEltOsago(payload: ELT.RequestEltOsago) {
|
export async function getEltOsago(
|
||||||
|
payload: ELT.RequestEltOsago,
|
||||||
|
{ signal }: { signal: AbortSignal }
|
||||||
|
) {
|
||||||
return withHandleError(
|
return withHandleError(
|
||||||
axios
|
axios
|
||||||
.post<ELT.ResponseEltOsago>(URL_ELT_OSAGO, payload, { timeout: TIMEOUT })
|
.post<ELT.ResponseEltOsago>(URL_ELT_OSAGO, payload, { signal, timeout: TIMEOUT })
|
||||||
.then(({ data }) => data)
|
.then(({ data }) => data)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getEltKasko(payload: ELT.RequestEltKasko) {
|
export async function getEltKasko(
|
||||||
|
payload: ELT.RequestEltKasko,
|
||||||
|
{ signal }: { signal: AbortSignal }
|
||||||
|
) {
|
||||||
return withHandleError(
|
return withHandleError(
|
||||||
axios
|
axios
|
||||||
.post<ELT.ResponseEltKasko>(URL_ELT_KASKO, payload, { timeout: TIMEOUT })
|
.post<ELT.ResponseEltKasko>(URL_ELT_KASKO, payload, { signal, timeout: TIMEOUT })
|
||||||
.then(({ data }) => data)
|
.then(({ data }) => data)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,24 +1,20 @@
|
|||||||
import { createLink } from './link';
|
import { link } from './link';
|
||||||
import { ApolloClient, InMemoryCache } from '@apollo/client';
|
import { ApolloClient, InMemoryCache } from '@apollo/client';
|
||||||
import { isServer } from 'tools/common';
|
import { isServer } from 'tools/common';
|
||||||
|
|
||||||
/** @type {import('@apollo/client').ApolloClient<import('@apollo/client').NormalizedCacheObject>} */
|
/** @type {import('@apollo/client').ApolloClient<import('@apollo/client').NormalizedCacheObject>} */
|
||||||
let apolloClient;
|
let apolloClient;
|
||||||
|
|
||||||
function createApolloClient(headers) {
|
function createApolloClient() {
|
||||||
return new ApolloClient({
|
return new ApolloClient({
|
||||||
cache: new InMemoryCache(),
|
cache: new InMemoryCache(),
|
||||||
link: createLink(headers),
|
link,
|
||||||
ssrMode: isServer(),
|
ssrMode: isServer(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function initializeApollo(initialState, headers) {
|
export default function initializeApollo(initialState = null) {
|
||||||
if (isServer() && !headers) {
|
const _apolloClient = apolloClient ?? createApolloClient();
|
||||||
throw new Error('initializeApollo: headers must be provided in server side');
|
|
||||||
}
|
|
||||||
|
|
||||||
const _apolloClient = apolloClient ?? createApolloClient(headers);
|
|
||||||
|
|
||||||
// If your page has Next.js data fetching methods that use Apollo Client, the initial state
|
// If your page has Next.js data fetching methods that use Apollo Client, the initial state
|
||||||
// gets hydrated here
|
// gets hydrated here
|
||||||
|
|||||||
@ -1,133 +1,86 @@
|
|||||||
/* eslint-disable sonarjs/cognitive-complexity */
|
/* eslint-disable sonarjs/cognitive-complexity */
|
||||||
import { message } from '@/Components/Common/Notification';
|
import { message } from '@/Components/Common/Notification';
|
||||||
import { publicRuntimeConfigSchema } from '@/config/schema/runtime-config';
|
|
||||||
import getUrls from '@/config/urls';
|
import getUrls from '@/config/urls';
|
||||||
import { ApolloLink, from, HttpLink } from '@apollo/client';
|
import { ApolloLink, from, HttpLink } from '@apollo/client';
|
||||||
import { setContext } from '@apollo/client/link/context';
|
|
||||||
import { onError } from '@apollo/client/link/error';
|
import { onError } from '@apollo/client/link/error';
|
||||||
import { getCurrentScope } from '@sentry/nextjs';
|
import { getCurrentScope } from '@sentry/nextjs';
|
||||||
import getConfig from 'next/config';
|
|
||||||
import { isServer } from 'tools';
|
import { isServer } from 'tools';
|
||||||
|
|
||||||
function isSovkom(account) {
|
const { URL_CRM_GRAPHQL } = getUrls();
|
||||||
return account.label.toLowerCase().includes('совком');
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createLink(headers) {
|
const modifyDataLink = new ApolloLink((operation, forward) => {
|
||||||
const { URL_CRM_GRAPHQL } = getUrls();
|
const context = operation?.getContext();
|
||||||
|
|
||||||
const modifyDataLink = new ApolloLink((operation, forward) => {
|
return forward(operation).map((response) => {
|
||||||
const context = operation?.getContext();
|
if (!context?.disableModify) {
|
||||||
|
if (Object.keys(response?.data).includes('evo_addproduct_types')) {
|
||||||
return forward(operation).map((response) => {
|
response.data.evo_addproduct_types = response.data.evo_addproduct_types.map(
|
||||||
if (!context?.disableModify) {
|
(evo_addproduct_type) => {
|
||||||
if (Object.keys(response?.data).includes('evo_addproduct_types')) {
|
if (evo_addproduct_type.evo_graph_price)
|
||||||
response.data.evo_addproduct_types = response.data.evo_addproduct_types.map(
|
|
||||||
(evo_addproduct_type) => {
|
|
||||||
if (evo_addproduct_type.evo_graph_price)
|
|
||||||
return {
|
|
||||||
...evo_addproduct_type,
|
|
||||||
label: `${evo_addproduct_type.label} (${evo_addproduct_type.evo_graph_price} руб.)`,
|
|
||||||
};
|
|
||||||
|
|
||||||
return evo_addproduct_type;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Object.keys(response?.data).includes('evo_equipments')) {
|
|
||||||
response.data.evo_equipments = response.data.evo_equipments.map((evo_equipment) => {
|
|
||||||
if (evo_equipment.evo_start_production_year)
|
|
||||||
return {
|
return {
|
||||||
...evo_equipment,
|
...evo_addproduct_type,
|
||||||
label: `${evo_equipment.label} (${evo_equipment.evo_start_production_year})`,
|
label: `${evo_addproduct_type.label} (${evo_addproduct_type.evo_graph_price} руб.)`,
|
||||||
};
|
};
|
||||||
|
|
||||||
return evo_equipment;
|
return evo_addproduct_type;
|
||||||
});
|
}
|
||||||
}
|
);
|
||||||
|
|
||||||
if (operation.operationName === 'GetInsuranceCompanies') {
|
|
||||||
response.data.accounts = response.data.accounts
|
|
||||||
.sort((a, b) => {
|
|
||||||
if (isSovkom(a)) return -1;
|
|
||||||
|
|
||||||
if (isSovkom(b)) return 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
})
|
|
||||||
.map((account) => {
|
|
||||||
const substring = account.label.match(/"(.+)"/u);
|
|
||||||
if (substring)
|
|
||||||
return {
|
|
||||||
...account,
|
|
||||||
label: substring ? substring[1].replaceAll('"', '').trim() : account.label,
|
|
||||||
};
|
|
||||||
|
|
||||||
return account;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
if (Object.keys(response?.data).includes('evo_equipments')) {
|
||||||
|
response.data.evo_equipments = response.data.evo_equipments.map((evo_equipment) => {
|
||||||
|
if (evo_equipment.evo_start_production_year)
|
||||||
|
return {
|
||||||
|
...evo_equipment,
|
||||||
|
label: `${evo_equipment.label} (${evo_equipment.evo_start_production_year})`,
|
||||||
|
};
|
||||||
|
|
||||||
|
return evo_equipment;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operation.operationName === 'GetInsuranceCompanies') {
|
||||||
|
response.data.accounts = response.data.accounts.map((account) => {
|
||||||
|
const substring = account.label.match(/"(.+)"/u);
|
||||||
|
if (substring)
|
||||||
|
return {
|
||||||
|
...account,
|
||||||
|
label: substring ? substring[1].replaceAll('"', '').trim() : account.label,
|
||||||
|
};
|
||||||
|
|
||||||
|
return account;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const httpLink = new HttpLink({
|
||||||
|
uri: URL_CRM_GRAPHQL,
|
||||||
|
});
|
||||||
|
|
||||||
|
const key = 'APOLLO_GRAPHQL';
|
||||||
|
|
||||||
|
const errorLink = onError(({ graphQLErrors, networkError, operation, response }) => {
|
||||||
|
const scope = getCurrentScope();
|
||||||
|
scope.setTag('operationName', operation.operationName);
|
||||||
|
|
||||||
|
if (!isServer()) {
|
||||||
|
message.error({
|
||||||
|
content: `Ошибка во время загрузки данных из CRM`,
|
||||||
|
key,
|
||||||
|
onClick: () => message.destroy(key),
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
scope.setExtras({
|
||||||
|
graphQLErrors,
|
||||||
|
networkError,
|
||||||
|
operation,
|
||||||
|
response,
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
const httpLink = new HttpLink({
|
export const link = from([errorLink, modifyDataLink, httpLink]);
|
||||||
uri: URL_CRM_GRAPHQL,
|
|
||||||
});
|
|
||||||
|
|
||||||
const authLink = setContext((_, { headers: existingHeaders }) => {
|
|
||||||
if (process.env.NODE_ENV === 'development') {
|
|
||||||
const { publicRuntimeConfig } = getConfig();
|
|
||||||
const { DEV_AUTH_TOKEN } = publicRuntimeConfigSchema.parse(publicRuntimeConfig);
|
|
||||||
|
|
||||||
if (DEV_AUTH_TOKEN)
|
|
||||||
return {
|
|
||||||
headers: {
|
|
||||||
...existingHeaders,
|
|
||||||
authorization: `Bearer ${DEV_AUTH_TOKEN}`,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isServer()) {
|
|
||||||
return {
|
|
||||||
headers: {
|
|
||||||
...existingHeaders,
|
|
||||||
authorization: headers?.authorization,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
headers: {
|
|
||||||
...existingHeaders,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const key = 'APOLLO_GRAPHQL';
|
|
||||||
|
|
||||||
const errorLink = onError(({ graphQLErrors, networkError, operation, response }) => {
|
|
||||||
const scope = getCurrentScope();
|
|
||||||
scope.setTag('operationName', operation.operationName);
|
|
||||||
|
|
||||||
if (!isServer()) {
|
|
||||||
message.error({
|
|
||||||
content: `Ошибка во время загрузки данных из CRM`,
|
|
||||||
key,
|
|
||||||
onClick: () => message.destroy(key),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
scope.setExtras({
|
|
||||||
graphQLErrors,
|
|
||||||
networkError,
|
|
||||||
operation,
|
|
||||||
response,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return from([authLink, errorLink, modifyDataLink, httpLink]);
|
|
||||||
}
|
|
||||||
|
|||||||
@ -104,7 +104,7 @@ export const selectObjectCategoryTax = [
|
|||||||
export const selectLeaseObjectUseFor = alphabetical(
|
export const selectLeaseObjectUseFor = alphabetical(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
label: 'Для представительских целей / перевозки сотрудников ЛП',
|
label: 'Для представительских целей',
|
||||||
value: 100_000_000,
|
value: 100_000_000,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -151,10 +151,10 @@ export const selectLeaseObjectUseFor = alphabetical(
|
|||||||
label: 'Для перевозки сотрудников других организаций (водитель ЛП)',
|
label: 'Для перевозки сотрудников других организаций (водитель ЛП)',
|
||||||
value: 100_000_011,
|
value: 100_000_011,
|
||||||
},
|
},
|
||||||
// {
|
{
|
||||||
// label: 'Для перевозки сотрудников ЛП',
|
label: 'Для перевозки сотрудников ЛП',
|
||||||
// value: 100_000_012,
|
value: 100_000_012,
|
||||||
// },
|
},
|
||||||
{
|
{
|
||||||
label: 'Для экскурсионных перевозок в т.ч. на торжества; трансфер в аэропорт и пр.',
|
label: 'Для экскурсионных перевозок в т.ч. на торжества; трансфер в аэропорт и пр.',
|
||||||
value: 100_000_013,
|
value: 100_000_013,
|
||||||
@ -511,7 +511,6 @@ const defaultOptions: CalculationOptions = {
|
|||||||
cbxPartialVAT: [],
|
cbxPartialVAT: [],
|
||||||
cbxFloatingRate: [],
|
cbxFloatingRate: [],
|
||||||
cbxQuotePriceWithFullVAT: [],
|
cbxQuotePriceWithFullVAT: [],
|
||||||
cbxQuoteShowAcceptLimit: [],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defaultOptions;
|
export default defaultOptions;
|
||||||
|
|||||||
@ -18,7 +18,6 @@ const defaultStatuses: CalculationStatuses = {
|
|||||||
cbxPriceWithDiscount: 'Default',
|
cbxPriceWithDiscount: 'Default',
|
||||||
cbxQuotePriceWithFullVAT: 'Default',
|
cbxQuotePriceWithFullVAT: 'Default',
|
||||||
cbxQuoteRedemptionGraph: 'Default',
|
cbxQuoteRedemptionGraph: 'Default',
|
||||||
cbxQuoteShowAcceptLimit: 'Default',
|
|
||||||
cbxRecalcWithRevision: 'Default',
|
cbxRecalcWithRevision: 'Default',
|
||||||
cbxRegistrationQuote: 'Default',
|
cbxRegistrationQuote: 'Default',
|
||||||
cbxShowFinGAP: 'Default',
|
cbxShowFinGAP: 'Default',
|
||||||
|
|||||||
@ -22,7 +22,7 @@ const defaultValues: CalculationValues = {
|
|||||||
comissionRub: 0,
|
comissionRub: 0,
|
||||||
configuration: null,
|
configuration: null,
|
||||||
costIncrease: true,
|
costIncrease: true,
|
||||||
countSeats: 4,
|
countSeats: 0,
|
||||||
creditRate: RATE,
|
creditRate: RATE,
|
||||||
dealer: null,
|
dealer: null,
|
||||||
dealerBroker: null,
|
dealerBroker: null,
|
||||||
@ -144,7 +144,6 @@ const defaultValues: CalculationValues = {
|
|||||||
partialVAT: false,
|
partialVAT: false,
|
||||||
floatingRate: false,
|
floatingRate: false,
|
||||||
quotePriceWithFullVAT: false,
|
quotePriceWithFullVAT: false,
|
||||||
quoteShowAcceptLimit: true,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defaultValues;
|
export default defaultValues;
|
||||||
|
|||||||
@ -2,7 +2,6 @@ import { withBasePath } from '@/config/urls';
|
|||||||
|
|
||||||
export const metaFavicon = (
|
export const metaFavicon = (
|
||||||
<>
|
<>
|
||||||
<link rel="icon" type="image/x-icon" href={withBasePath('/favicon.ico')} sizes="32x32" />
|
|
||||||
<link rel="apple-touch-icon" sizes="180x180" href={withBasePath('/apple-touch-icon.png')} />
|
<link rel="apple-touch-icon" sizes="180x180" href={withBasePath('/apple-touch-icon.png')} />
|
||||||
<link rel="icon" type="image/png" sizes="32x32" href={withBasePath('/favicon-32x32.png')} />
|
<link rel="icon" type="image/png" sizes="32x32" href={withBasePath('/favicon-32x32.png')} />
|
||||||
<link rel="icon" type="image/png" sizes="16x16" href={withBasePath('/favicon-16x16.png')} />
|
<link rel="icon" type="image/png" sizes="16x16" href={withBasePath('/favicon-16x16.png')} />
|
||||||
|
|||||||
@ -270,7 +270,6 @@ export const ResultEltOsagoSchema = z.object({
|
|||||||
|
|
||||||
export const RowSchema = z.object({
|
export const RowSchema = z.object({
|
||||||
id: z.string(),
|
id: z.string(),
|
||||||
insuranceCondition: z.string().nullable(),
|
|
||||||
key: z.string(),
|
key: z.string(),
|
||||||
message: z.string().nullable(),
|
message: z.string().nullable(),
|
||||||
metodCalc: z.union([z.literal('CRM'), z.literal('ELT')]),
|
metodCalc: z.union([z.literal('CRM'), z.literal('ELT')]),
|
||||||
|
|||||||
@ -2,8 +2,6 @@ const { z } = require('zod');
|
|||||||
|
|
||||||
const envSchema = z.object({
|
const envSchema = z.object({
|
||||||
BASE_PATH: z.string().optional().default(''),
|
BASE_PATH: z.string().optional().default(''),
|
||||||
DEV_AUTH_TOKEN: z.string().optional(),
|
|
||||||
PASSWORD_1C_TRANSTAX: z.string(),
|
|
||||||
PORT: z.string().optional(),
|
PORT: z.string().optional(),
|
||||||
SENTRY_AUTH_TOKEN: z.string(),
|
SENTRY_AUTH_TOKEN: z.string(),
|
||||||
SENTRY_DSN: z.string(),
|
SENTRY_DSN: z.string(),
|
||||||
@ -23,7 +21,6 @@ const envSchema = z.object({
|
|||||||
URL_ELT_OSAGO_DIRECT: z.string(),
|
URL_ELT_OSAGO_DIRECT: z.string(),
|
||||||
URL_GET_USER_DIRECT: z.string(),
|
URL_GET_USER_DIRECT: z.string(),
|
||||||
USE_DEV_COLORS: z.unknown().optional().transform(Boolean),
|
USE_DEV_COLORS: z.unknown().optional().transform(Boolean),
|
||||||
USERNAME_1C_TRANSTAX: z.string(),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = envSchema;
|
module.exports = envSchema;
|
||||||
|
|||||||
@ -2,7 +2,6 @@ const envSchema = require('./env');
|
|||||||
|
|
||||||
const publicRuntimeConfigSchema = envSchema.pick({
|
const publicRuntimeConfigSchema = envSchema.pick({
|
||||||
BASE_PATH: true,
|
BASE_PATH: true,
|
||||||
DEV_AUTH_TOKEN: true,
|
|
||||||
SENTRY_DSN: true,
|
SENTRY_DSN: true,
|
||||||
SENTRY_ENVIRONMENT: true,
|
SENTRY_ENVIRONMENT: true,
|
||||||
USE_DEV_COLORS: true,
|
USE_DEV_COLORS: true,
|
||||||
@ -10,8 +9,6 @@ const publicRuntimeConfigSchema = envSchema.pick({
|
|||||||
|
|
||||||
const serverRuntimeConfigSchema = envSchema.pick({
|
const serverRuntimeConfigSchema = envSchema.pick({
|
||||||
BASE_PATH: true,
|
BASE_PATH: true,
|
||||||
DEV_AUTH_TOKEN: true,
|
|
||||||
PASSWORD_1C_TRANSTAX: true,
|
|
||||||
PORT: true,
|
PORT: true,
|
||||||
SENTRY_DSN: true,
|
SENTRY_DSN: true,
|
||||||
SENTRY_ENVIRONMENT: true,
|
SENTRY_ENVIRONMENT: true,
|
||||||
@ -28,7 +25,6 @@ const serverRuntimeConfigSchema = envSchema.pick({
|
|||||||
URL_ELT_KASKO_DIRECT: true,
|
URL_ELT_KASKO_DIRECT: true,
|
||||||
URL_ELT_OSAGO_DIRECT: true,
|
URL_ELT_OSAGO_DIRECT: true,
|
||||||
URL_GET_USER_DIRECT: true,
|
URL_GET_USER_DIRECT: true,
|
||||||
USERNAME_1C_TRANSTAX: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@ -129,7 +129,6 @@ const ValuesSchema = z.object({
|
|||||||
withTrailer: z.boolean(),
|
withTrailer: z.boolean(),
|
||||||
partialVAT: z.boolean(),
|
partialVAT: z.boolean(),
|
||||||
floatingRate: z.boolean(),
|
floatingRate: z.boolean(),
|
||||||
quoteShowAcceptLimit: z.boolean(),
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Link Values
|
* Link Values
|
||||||
|
|||||||
@ -12,5 +12,3 @@ export const VEHICLE_SEATS = 20;
|
|||||||
export const ESN = 1.3;
|
export const ESN = 1.3;
|
||||||
export const NSIB_MAX = 5_000_000;
|
export const NSIB_MAX = 5_000_000;
|
||||||
export const NDFL = 0.13;
|
export const NDFL = 0.13;
|
||||||
|
|
||||||
export const IRR_THRESHOLD = 0.001;
|
|
||||||
|
|||||||
@ -1,34 +0,0 @@
|
|||||||
import { createContext, useEffect, useMemo, useState } from 'react';
|
|
||||||
|
|
||||||
type Tab = {
|
|
||||||
icon: JSX.Element;
|
|
||||||
key: string;
|
|
||||||
title: string;
|
|
||||||
useShowBadge?: () => boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
type NavigationContextType = {
|
|
||||||
currentTab: string;
|
|
||||||
setCurrentTab: (tab: string) => void;
|
|
||||||
setTabsList: (list: Tab[]) => void;
|
|
||||||
tabsList: Tab[];
|
|
||||||
};
|
|
||||||
|
|
||||||
export const NavigationContext = createContext<NavigationContextType>({} as NavigationContextType);
|
|
||||||
|
|
||||||
export function NavigationProvider({ children }: { readonly children: React.ReactNode }) {
|
|
||||||
const [currentTab, setCurrentTab] = useState('');
|
|
||||||
const [tabsList, setTabsList] = useState<Tab[]>([]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const defaultTab = tabsList.at(0);
|
|
||||||
if (defaultTab) setCurrentTab(defaultTab.key);
|
|
||||||
}, [tabsList]);
|
|
||||||
|
|
||||||
const value = useMemo(
|
|
||||||
() => ({ currentTab, setCurrentTab, setTabsList, tabsList }),
|
|
||||||
[currentTab, setCurrentTab, setTabsList, tabsList]
|
|
||||||
);
|
|
||||||
|
|
||||||
return <NavigationContext.Provider value={value}>{children}</NavigationContext.Provider>;
|
|
||||||
}
|
|
||||||
@ -8,7 +8,7 @@ query GetTransactionCurrencies {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetTransactionCurrency($currencyid: UUID!) {
|
query GetTransactionCurrency($currencyid: Uuid!) {
|
||||||
transactioncurrency(transactioncurrencyid: $currencyid) {
|
transactioncurrency(transactioncurrencyid: $currencyid) {
|
||||||
currencysymbol
|
currencysymbol
|
||||||
isocurrencycode
|
isocurrencycode
|
||||||
@ -17,33 +17,20 @@ query GetTransactionCurrency($currencyid: UUID!) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
query GetCurrencyChanges($currentDate: DateTime) {
|
query GetCurrencyChanges($currentDate: DateTime) {
|
||||||
evo_currencychanges(
|
evo_currencychanges(statecode: 0, evo_coursedate_param: { eq: $currentDate }) {
|
||||||
filterConditionGroup: {
|
|
||||||
andFilterConditions: [
|
|
||||||
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
|
||||||
{ filterConditionDateTime: { fieldName: "evo_coursedate", eq: $currentDate } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
evo_currencychange
|
evo_currencychange
|
||||||
evo_ref_transactioncurrency
|
evo_ref_transactioncurrency
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetLeads($domainname: String) {
|
query GetLeads($domainname: String) {
|
||||||
systemusers(
|
leads(owner_domainname: $domainname) {
|
||||||
filterConditionGroup: {
|
label: fullname
|
||||||
andFilterConditions: { filterConditionString: { fieldName: "domainname", eq: $domainname } }
|
value: leadid
|
||||||
}
|
|
||||||
) {
|
|
||||||
leads(orderby: { fieldName: "createdon", sortingType: DESC }) {
|
|
||||||
label: fullname
|
|
||||||
value: leadid
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetLead($leadid: UUID!) {
|
query GetLead($leadid: Uuid!) {
|
||||||
lead(leadid: $leadid) {
|
lead(leadid: $leadid) {
|
||||||
evo_agent_accountid
|
evo_agent_accountid
|
||||||
evo_double_agent_accountid
|
evo_double_agent_accountid
|
||||||
@ -65,7 +52,7 @@ query GetLead($leadid: UUID!) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetOpportunity($opportunityid: UUID!) {
|
query GetOpportunity($opportunityid: Uuid!) {
|
||||||
opportunity(opportunityid: $opportunityid) {
|
opportunity(opportunityid: $opportunityid) {
|
||||||
evo_leadid
|
evo_leadid
|
||||||
accountidData {
|
accountidData {
|
||||||
@ -80,28 +67,14 @@ query GetOpportunity($opportunityid: UUID!) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
query GetOpportunities($domainname: String) {
|
query GetOpportunities($domainname: String) {
|
||||||
systemusers(
|
opportunities(owner_domainname: $domainname) {
|
||||||
filterConditionGroup: {
|
label: name
|
||||||
andFilterConditions: { filterConditionString: { fieldName: "domainname", eq: $domainname } }
|
value: opportunityid
|
||||||
}
|
|
||||||
) {
|
|
||||||
opportunities(orderby: { fieldName: "createdon", sortingType: DESC }) {
|
|
||||||
label: name
|
|
||||||
value: opportunityid
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetQuotes($leadid: UUID!) {
|
query GetQuotes($leadid: Uuid!) {
|
||||||
quotes(
|
quotes(evo_leadid: $leadid) {
|
||||||
filterConditionGroup: {
|
|
||||||
andFilterConditions: [
|
|
||||||
{ filterConditionGuid: { fieldName: "evo_leadid", eq: $leadid } }
|
|
||||||
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
orderby: { fieldName: "createdon", sortingType: DESC }
|
|
||||||
) {
|
|
||||||
label: evo_quotename
|
label: evo_quotename
|
||||||
value: quoteid
|
value: quoteid
|
||||||
evo_recalc_limit
|
evo_recalc_limit
|
||||||
@ -112,8 +85,8 @@ query GetQuotes($leadid: UUID!) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetQuote($quoteId: UUID!) {
|
query GetQuote($quoteId: Uuid!) {
|
||||||
quote(quoteid: $quoteId) {
|
quote(quoteId: $quoteId) {
|
||||||
evo_baseproductid
|
evo_baseproductid
|
||||||
evo_one_year_insurance
|
evo_one_year_insurance
|
||||||
evo_min_change_price
|
evo_min_change_price
|
||||||
@ -159,8 +132,8 @@ query GetQuote($quoteId: UUID!) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetQuoteData($quoteId: UUID!) {
|
query GetQuoteData($quoteId: Uuid!) {
|
||||||
quote(quoteid: $quoteId) {
|
quote(quoteId: $quoteId) {
|
||||||
evo_addproduct_types {
|
evo_addproduct_types {
|
||||||
evo_product_type
|
evo_product_type
|
||||||
evo_addproduct_typeid
|
evo_addproduct_typeid
|
||||||
@ -255,7 +228,7 @@ query GetQuoteData($quoteId: UUID!) {
|
|||||||
evo_graphs {
|
evo_graphs {
|
||||||
createdon
|
createdon
|
||||||
evo_sumpay_withnds
|
evo_sumpay_withnds
|
||||||
evo_planpayments(orderby: { fieldName: "evo_plandate", sortingType: ASC }) {
|
evo_planpayments {
|
||||||
evo_payment_ratio
|
evo_payment_ratio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -309,25 +282,14 @@ query GetQuoteData($quoteId: UUID!) {
|
|||||||
evo_transactioncurrencyid
|
evo_transactioncurrencyid
|
||||||
evo_equip_price
|
evo_equip_price
|
||||||
evo_coefficien_bonus_reducttion
|
evo_coefficien_bonus_reducttion
|
||||||
evo_accept_limit_quote
|
|
||||||
evo_kasko_insurance_rulesidData {
|
|
||||||
evo_id
|
|
||||||
}
|
|
||||||
evo_osago_insurance_rulesiddData {
|
|
||||||
evo_id
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetTarifs($currentDate: DateTime) {
|
query GetTarifs($currentDate: DateTime) {
|
||||||
evo_tarifs(
|
evo_tarifs(
|
||||||
filterConditionGroup: {
|
statecode: 0
|
||||||
andFilterConditions: [
|
evo_datefrom_param: { lte: $currentDate }
|
||||||
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
evo_dateto_param: { gte: $currentDate }
|
||||||
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
|
||||||
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_tarifid
|
value: evo_tarifid
|
||||||
@ -350,7 +312,7 @@ query GetTarifs($currentDate: DateTime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetTarif($tarifId: UUID!) {
|
query GetTarif($tarifId: Uuid!) {
|
||||||
evo_tarif(evo_tarifid: $tarifId) {
|
evo_tarif(evo_tarifid: $tarifId) {
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_tarifid
|
value: evo_tarifid
|
||||||
@ -365,7 +327,6 @@ query GetTarif($tarifId: UUID!) {
|
|||||||
evo_datefrom
|
evo_datefrom
|
||||||
evo_rateid
|
evo_rateid
|
||||||
evo_type
|
evo_type
|
||||||
statecode
|
|
||||||
}
|
}
|
||||||
evo_irr_plan
|
evo_irr_plan
|
||||||
evo_margin_min
|
evo_margin_min
|
||||||
@ -374,13 +335,9 @@ query GetTarif($tarifId: UUID!) {
|
|||||||
|
|
||||||
query GetRates($currentDate: DateTime) {
|
query GetRates($currentDate: DateTime) {
|
||||||
evo_rates(
|
evo_rates(
|
||||||
filterConditionGroup: {
|
statecode: 0
|
||||||
andFilterConditions: [
|
evo_datefrom_param: { lte: $currentDate }
|
||||||
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
evo_dateto_param: { gte: $currentDate }
|
||||||
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
|
||||||
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_rateid
|
value: evo_rateid
|
||||||
@ -392,7 +349,7 @@ query GetRates($currentDate: DateTime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetRate($rateId: UUID!) {
|
query GetRate($rateId: Uuid!) {
|
||||||
evo_rate(evo_rateid: $rateId) {
|
evo_rate(evo_rateid: $rateId) {
|
||||||
evo_base_rate
|
evo_base_rate
|
||||||
evo_credit_period
|
evo_credit_period
|
||||||
@ -403,14 +360,10 @@ query GetRate($rateId: UUID!) {
|
|||||||
|
|
||||||
query GetProducts($currentDate: DateTime) {
|
query GetProducts($currentDate: DateTime) {
|
||||||
evo_baseproducts(
|
evo_baseproducts(
|
||||||
filterConditionGroup: {
|
statecode: 0
|
||||||
andFilterConditions: [
|
evo_relation: [100000000]
|
||||||
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
evo_datefrom_param: { lte: $currentDate }
|
||||||
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
evo_dateto_param: { gte: $currentDate }
|
||||||
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
|
||||||
{ filterConditionMultyPicklist: { fieldName: "evo_relation", oneof: [100000000] } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_baseproductid
|
value: evo_baseproductid
|
||||||
@ -421,7 +374,7 @@ query GetProducts($currentDate: DateTime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetProduct($productId: UUID!) {
|
query GetProduct($productId: Uuid!) {
|
||||||
evo_baseproduct(evo_baseproductid: $productId) {
|
evo_baseproduct(evo_baseproductid: $productId) {
|
||||||
evo_leasingobject_types {
|
evo_leasingobject_types {
|
||||||
evo_leasingobject_typeid
|
evo_leasingobject_typeid
|
||||||
@ -447,13 +400,9 @@ query GetProduct($productId: UUID!) {
|
|||||||
|
|
||||||
query GetSubsidies($currentDate: DateTime) {
|
query GetSubsidies($currentDate: DateTime) {
|
||||||
evo_subsidies(
|
evo_subsidies(
|
||||||
filterConditionGroup: {
|
statecode: 0
|
||||||
andFilterConditions: [
|
evo_datefrom_param: { lte: $currentDate }
|
||||||
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
evo_dateto_param: { gte: $currentDate }
|
||||||
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
|
||||||
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_subsidyid
|
value: evo_subsidyid
|
||||||
@ -461,7 +410,7 @@ query GetSubsidies($currentDate: DateTime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetSubsidy($subsidyId: UUID!) {
|
query GetSubsidy($subsidyId: Uuid!) {
|
||||||
evo_subsidy(evo_subsidyid: $subsidyId) {
|
evo_subsidy(evo_subsidyid: $subsidyId) {
|
||||||
evo_leasingobject_types {
|
evo_leasingobject_types {
|
||||||
evo_leasingobject_typeid
|
evo_leasingobject_typeid
|
||||||
@ -483,7 +432,7 @@ query GetSubsidy($subsidyId: UUID!) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetImportProgram($importProgramId: UUID!) {
|
query GetImportProgram($importProgramId: Uuid!) {
|
||||||
importProgram: evo_subsidy(evo_subsidyid: $importProgramId) {
|
importProgram: evo_subsidy(evo_subsidyid: $importProgramId) {
|
||||||
evo_leasingobject_types {
|
evo_leasingobject_types {
|
||||||
evo_leasingobject_typeid
|
evo_leasingobject_typeid
|
||||||
@ -501,7 +450,7 @@ query GetImportProgram($importProgramId: UUID!) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
query GetRegions {
|
query GetRegions {
|
||||||
evo_regions(orderby: { fieldName: "evo_name", sortingType: ASC }) {
|
evo_regions {
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_regionid
|
value: evo_regionid
|
||||||
evo_fias_id
|
evo_fias_id
|
||||||
@ -509,7 +458,7 @@ query GetRegions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetRegion($regionId: UUID!) {
|
query GetRegion($regionId: Uuid!) {
|
||||||
evo_region(evo_regionid: $regionId) {
|
evo_region(evo_regionid: $regionId) {
|
||||||
evo_oktmo
|
evo_oktmo
|
||||||
accounts {
|
accounts {
|
||||||
@ -519,16 +468,8 @@ query GetRegion($regionId: UUID!) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetTowns($regionId: UUID!) {
|
query GetTowns($regionId: Uuid!) {
|
||||||
evo_towns(
|
evo_towns(evo_regionid: $regionId) {
|
||||||
filterConditionGroup: {
|
|
||||||
andFilterConditions: [
|
|
||||||
{ filterConditionGuid: { fieldName: "evo_regionid", eq: $regionId } }
|
|
||||||
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
orderby: { fieldName: "evo_name", sortingType: ASC }
|
|
||||||
) {
|
|
||||||
evo_fias_id
|
evo_fias_id
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_townid
|
value: evo_townid
|
||||||
@ -536,33 +477,22 @@ query GetTowns($regionId: UUID!) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetTown($townId: UUID!) {
|
query GetTown($townId: Uuid!) {
|
||||||
evo_town(evo_townid: $townId) {
|
evo_town(evo_townid: $townId) {
|
||||||
evo_kladr_id
|
evo_kladr_id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetGPSBrands {
|
query GetGPSBrands {
|
||||||
evo_gps_brands(
|
evo_gps_brands(statecode: 0) {
|
||||||
filterConditionGroup: {
|
|
||||||
andFilterConditions: { filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_gps_brandid
|
value: evo_gps_brandid
|
||||||
evo_id
|
evo_id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetGPSModels($gpsBrandId: UUID!) {
|
query GetGPSModels($gpsBrandId: Uuid!) {
|
||||||
evo_gps_models(
|
evo_gps_models(evo_gps_brandid: $gpsBrandId) {
|
||||||
filterConditionGroup: {
|
|
||||||
andFilterConditions: [
|
|
||||||
{ filterConditionGuid: { fieldName: "evo_gps_brandid", eq: $gpsBrandId } }
|
|
||||||
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_gps_modelid
|
value: evo_gps_modelid
|
||||||
evo_id
|
evo_id
|
||||||
@ -570,18 +500,14 @@ query GetGPSModels($gpsBrandId: UUID!) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
query GetLeaseObjectTypes {
|
query GetLeaseObjectTypes {
|
||||||
evo_leasingobject_types(
|
evo_leasingobject_types(statecode: 0) {
|
||||||
filterConditionGroup: {
|
|
||||||
andFilterConditions: { filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_leasingobject_typeid
|
value: evo_leasingobject_typeid
|
||||||
evo_leasingobject_typeid
|
evo_leasingobject_typeid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetLeaseObjectType($leaseObjectTypeId: UUID!) {
|
query GetLeaseObjectType($leaseObjectTypeId: Uuid!) {
|
||||||
evo_leasingobject_type(evo_leasingobject_typeid: $leaseObjectTypeId) {
|
evo_leasingobject_type(evo_leasingobject_typeid: $leaseObjectTypeId) {
|
||||||
evo_vehicle_type
|
evo_vehicle_type
|
||||||
evo_id
|
evo_id
|
||||||
@ -601,12 +527,7 @@ query GetLeaseObjectType($leaseObjectTypeId: UUID!) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
query GetBrands {
|
query GetBrands {
|
||||||
evo_brands(
|
evo_brands(statecode: 0) {
|
||||||
filterConditionGroup: {
|
|
||||||
andFilterConditions: { filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
|
||||||
}
|
|
||||||
orderby: { fieldName: "evo_name", sortingType: ASC }
|
|
||||||
) {
|
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_brandid
|
value: evo_brandid
|
||||||
evo_brandid
|
evo_brandid
|
||||||
@ -614,7 +535,7 @@ query GetBrands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetBrand($brandId: UUID!) {
|
query GetBrand($brandId: Uuid!) {
|
||||||
evo_brand(evo_brandid: $brandId) {
|
evo_brand(evo_brandid: $brandId) {
|
||||||
evo_id
|
evo_id
|
||||||
evo_importer_reward_perc
|
evo_importer_reward_perc
|
||||||
@ -624,16 +545,8 @@ query GetBrand($brandId: UUID!) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetModels($brandId: UUID!) {
|
query GetModels($brandId: Uuid!) {
|
||||||
evo_models(
|
evo_models(statecode: 0, evo_brandid: $brandId) {
|
||||||
filterConditionGroup: {
|
|
||||||
andFilterConditions: [
|
|
||||||
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
|
||||||
{ filterConditionGuid: { fieldName: "evo_brandid", eq: $brandId } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
orderby: { fieldName: "evo_name", sortingType: ASC }
|
|
||||||
) {
|
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_modelid
|
value: evo_modelid
|
||||||
evo_modelid
|
evo_modelid
|
||||||
@ -643,7 +556,7 @@ query GetModels($brandId: UUID!) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetModel($modelId: UUID!) {
|
query GetModel($modelId: Uuid!) {
|
||||||
evo_model(evo_modelid: $modelId) {
|
evo_model(evo_modelid: $modelId) {
|
||||||
evo_impairment_groupidData {
|
evo_impairment_groupidData {
|
||||||
evo_name
|
evo_name
|
||||||
@ -660,22 +573,15 @@ query GetModel($modelId: UUID!) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetConfigurations($modelId: UUID!) {
|
query GetConfigurations($modelId: Uuid!) {
|
||||||
evo_equipments(
|
evo_equipments(statecode: 0, evo_modelid: $modelId) {
|
||||||
filterConditionGroup: {
|
|
||||||
andFilterConditions: [
|
|
||||||
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
|
||||||
{ filterConditionGuid: { fieldName: "evo_modelid", eq: $modelId } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_equipmentid
|
value: evo_equipmentid
|
||||||
evo_start_production_year
|
evo_start_production_year
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetConfiguration($configurationId: UUID!) {
|
query GetConfiguration($configurationId: Uuid!) {
|
||||||
evo_equipment(evo_equipmentid: $configurationId) {
|
evo_equipment(evo_equipmentid: $configurationId) {
|
||||||
evo_impairment_groupidData {
|
evo_impairment_groupidData {
|
||||||
evo_name
|
evo_name
|
||||||
@ -684,7 +590,7 @@ query GetConfiguration($configurationId: UUID!) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
query GetDealers {
|
query GetDealers {
|
||||||
dealers {
|
dealers: accounts(evo_account_type: [100000001], statecode: 0, evo_legal_form: 100000001) {
|
||||||
label: name
|
label: name
|
||||||
value: accountid
|
value: accountid
|
||||||
accountid
|
accountid
|
||||||
@ -692,16 +598,16 @@ query GetDealers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetDealer($dealerId: UUID!) {
|
query GetDealer($dealerId: Uuid!) {
|
||||||
dealer(accountid: $dealerId) {
|
dealer: account(accountid: $dealerId) {
|
||||||
evo_return_leasing_dealer
|
evo_return_leasing_dealer
|
||||||
evo_broker_accountid
|
evo_broker_accountid
|
||||||
evo_supplier_financing_accept
|
evo_supplier_financing_accept
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetDealerPersons($dealerId: UUID!) {
|
query GetDealerPersons($dealerId: Uuid!) {
|
||||||
dealerPersons: dealer_persons(salonaccountid: $dealerId) {
|
dealerPersons: salon_providers(statecode: 0, salonaccountid: $dealerId) {
|
||||||
label: name
|
label: name
|
||||||
value: accountid
|
value: accountid
|
||||||
accountid
|
accountid
|
||||||
@ -711,46 +617,27 @@ query GetDealerPersons($dealerId: UUID!) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetDealerPerson($dealerPersonId: UUID!) {
|
query GetDealerPerson($dealerPersonId: Uuid!) {
|
||||||
dealer_person(accountid: $dealerPersonId) {
|
account(accountid: $dealerPersonId) {
|
||||||
evo_supplier_type
|
evo_supplier_type
|
||||||
evo_supplier_financing_accept
|
evo_supplier_financing_accept
|
||||||
evo_return_leasing_dealer
|
|
||||||
evo_broker_accountid
|
|
||||||
evo_supplier_financing_accept
|
|
||||||
evo_legal_form
|
|
||||||
evo_inn
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetAgent($agentid: UUID!) {
|
query GetAgent($agentid: Uuid!) {
|
||||||
agent(accountid: $agentid) {
|
agent: account(accountid: $agentid) {
|
||||||
label: name
|
label: name
|
||||||
value: accountid
|
value: accountid
|
||||||
evo_inn
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetRewardConditions($agentid: UUID!, $currentDate: DateTime) {
|
query GetRewardConditions($agentid: Uuid!, $currentDate: DateTime) {
|
||||||
evo_reward_conditions(
|
evo_reward_conditions(
|
||||||
filterConditionGroup: {
|
evo_agent_accountid: $agentid
|
||||||
andFilterConditionGroup: [
|
evo_datefrom_param: { lte: $currentDate }
|
||||||
{
|
evo_dateto_param: { gte: $currentDate }
|
||||||
orFilterConditions: [
|
statecode: 0
|
||||||
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
evo_agency_agreementid_param: { has: true }
|
||||||
{ filterConditionDateTime: { fieldName: "evo_dateto", eq: null } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
{
|
|
||||||
andFilterConditions: [
|
|
||||||
{ filterConditionGuid: { fieldName: "evo_agent_accountid", eq: $agentid } }
|
|
||||||
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
|
||||||
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
|
||||||
{ filterConditionGuid: { fieldName: "evo_agency_agreementid", neq: null } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_reward_conditionid
|
value: evo_reward_conditionid
|
||||||
@ -759,7 +646,7 @@ query GetRewardConditions($agentid: UUID!, $currentDate: DateTime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetRewardCondition($conditionId: UUID!) {
|
query GetRewardCondition($conditionId: Uuid!) {
|
||||||
evo_reward_condition(evo_reward_conditionid: $conditionId) {
|
evo_reward_condition(evo_reward_conditionid: $conditionId) {
|
||||||
evo_reward_summ
|
evo_reward_summ
|
||||||
evo_reduce_reward
|
evo_reduce_reward
|
||||||
@ -774,27 +661,16 @@ query GetRewardCondition($conditionId: UUID!) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
query GetSotCoefficientType($evo_id: String) {
|
query GetSotCoefficientType($evo_id: String) {
|
||||||
evo_sot_coefficient_types(
|
evo_sot_coefficient_type(evo_id: $evo_id) {
|
||||||
filterConditionGroup: {
|
|
||||||
andFilterConditions: [
|
|
||||||
{ filterConditionString: { fieldName: "evo_id", eq: $evo_id } }
|
|
||||||
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
evo_sot_coefficient_typeid
|
evo_sot_coefficient_typeid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetCoefficients($currentDate: DateTime) {
|
query GetCoefficients($currentDate: DateTime) {
|
||||||
evo_coefficients(
|
evo_coefficients(
|
||||||
filterConditionGroup: {
|
statecode: 0
|
||||||
andFilterConditions: [
|
evo_datefrom_param: { lte: $currentDate }
|
||||||
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
evo_dateto_param: { gte: $currentDate }
|
||||||
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
|
||||||
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
evo_job_titleid
|
evo_job_titleid
|
||||||
evo_sot_coefficient_typeid
|
evo_sot_coefficient_typeid
|
||||||
@ -820,11 +696,7 @@ query GetCoefficients($currentDate: DateTime) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
query GetSystemUser($domainname: String) {
|
query GetSystemUser($domainname: String) {
|
||||||
systemusers(
|
systemuser(domainname: $domainname) {
|
||||||
filterConditionGroup: {
|
|
||||||
filterCondition: { filterConditionString: { fieldName: "domainname", eq: $domainname } }
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
evo_job_titleid
|
evo_job_titleid
|
||||||
businessunitid
|
businessunitid
|
||||||
roles {
|
roles {
|
||||||
@ -842,13 +714,9 @@ fragment CoreAddProductTypesFields on evo_addproduct_type {
|
|||||||
|
|
||||||
query GetAddproductTypes($currentDate: DateTime) {
|
query GetAddproductTypes($currentDate: DateTime) {
|
||||||
evo_addproduct_types(
|
evo_addproduct_types(
|
||||||
filterConditionGroup: {
|
statecode: 0
|
||||||
andFilterConditions: [
|
evo_datefrom_param: { lte: $currentDate }
|
||||||
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
evo_dateto_param: { gte: $currentDate }
|
||||||
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
|
||||||
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
...CoreAddProductTypesFields
|
...CoreAddProductTypesFields
|
||||||
evo_product_type
|
evo_product_type
|
||||||
@ -862,7 +730,7 @@ query GetAddproductTypes($currentDate: DateTime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetAddProductType($addproductTypeId: UUID!) {
|
query GetAddProductType($addproductTypeId: Uuid!) {
|
||||||
evo_addproduct_type(evo_addproduct_typeid: $addproductTypeId) {
|
evo_addproduct_type(evo_addproduct_typeid: $addproductTypeId) {
|
||||||
evo_description
|
evo_description
|
||||||
evo_helpcard_type
|
evo_helpcard_type
|
||||||
@ -886,14 +754,10 @@ query GetAddProductType($addproductTypeId: UUID!) {
|
|||||||
|
|
||||||
query GetRegistrationTypes($currentDate: DateTime) {
|
query GetRegistrationTypes($currentDate: DateTime) {
|
||||||
evo_addproduct_types(
|
evo_addproduct_types(
|
||||||
filterConditionGroup: {
|
statecode: 0
|
||||||
andFilterConditions: [
|
evo_datefrom_param: { lte: $currentDate }
|
||||||
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
evo_dateto_param: { gte: $currentDate }
|
||||||
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
evo_product_type: 100000001
|
||||||
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
|
||||||
{ filterConditionInt: { fieldName: "evo_product_type", eq: 100000001 } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
...CoreAddProductTypesFields
|
...CoreAddProductTypesFields
|
||||||
evo_leasingobject_types {
|
evo_leasingobject_types {
|
||||||
@ -909,14 +773,10 @@ query GetRegistrationTypes($currentDate: DateTime) {
|
|||||||
|
|
||||||
query GetTechnicalCards($currentDate: DateTime) {
|
query GetTechnicalCards($currentDate: DateTime) {
|
||||||
evo_addproduct_types(
|
evo_addproduct_types(
|
||||||
filterConditionGroup: {
|
statecode: 0
|
||||||
andFilterConditions: [
|
evo_datefrom_param: { lte: $currentDate }
|
||||||
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
evo_dateto_param: { gte: $currentDate }
|
||||||
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
evo_product_type: 100000000
|
||||||
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
|
||||||
{ filterConditionInt: { fieldName: "evo_product_type", eq: 100000000 } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
...CoreAddProductTypesFields
|
...CoreAddProductTypesFields
|
||||||
evo_min_period
|
evo_min_period
|
||||||
@ -930,14 +790,10 @@ query GetTechnicalCards($currentDate: DateTime) {
|
|||||||
|
|
||||||
query GetFuelCards($currentDate: DateTime) {
|
query GetFuelCards($currentDate: DateTime) {
|
||||||
evo_addproduct_types(
|
evo_addproduct_types(
|
||||||
filterConditionGroup: {
|
statecode: 0
|
||||||
andFilterConditions: [
|
evo_datefrom_param: { lte: $currentDate }
|
||||||
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
evo_dateto_param: { gte: $currentDate }
|
||||||
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
evo_product_type: 100000005
|
||||||
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
|
||||||
{ filterConditionInt: { fieldName: "evo_product_type", eq: 100000005 } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
...CoreAddProductTypesFields
|
...CoreAddProductTypesFields
|
||||||
evo_min_period
|
evo_min_period
|
||||||
@ -950,14 +806,10 @@ query GetFuelCards($currentDate: DateTime) {
|
|||||||
|
|
||||||
query GetTelematicTypes($currentDate: DateTime) {
|
query GetTelematicTypes($currentDate: DateTime) {
|
||||||
evo_addproduct_types(
|
evo_addproduct_types(
|
||||||
filterConditionGroup: {
|
statecode: 0
|
||||||
andFilterConditions: [
|
evo_datefrom_param: { lte: $currentDate }
|
||||||
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
evo_dateto_param: { gte: $currentDate }
|
||||||
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
evo_product_type: 100000004
|
||||||
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
|
||||||
{ filterConditionInt: { fieldName: "evo_product_type", eq: 100000004 } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
...CoreAddProductTypesFields
|
...CoreAddProductTypesFields
|
||||||
evo_controls_program
|
evo_controls_program
|
||||||
@ -967,14 +819,10 @@ query GetTelematicTypes($currentDate: DateTime) {
|
|||||||
|
|
||||||
query GetTrackerTypes($currentDate: DateTime) {
|
query GetTrackerTypes($currentDate: DateTime) {
|
||||||
evo_addproduct_types(
|
evo_addproduct_types(
|
||||||
filterConditionGroup: {
|
statecode: 0
|
||||||
andFilterConditions: [
|
evo_datefrom_param: { lte: $currentDate }
|
||||||
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
evo_dateto_param: { gte: $currentDate }
|
||||||
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
evo_product_type: 100000003
|
||||||
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
|
||||||
{ filterConditionInt: { fieldName: "evo_product_type", eq: 100000003 } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
...CoreAddProductTypesFields
|
...CoreAddProductTypesFields
|
||||||
evo_controls_program
|
evo_controls_program
|
||||||
@ -984,14 +832,10 @@ query GetTrackerTypes($currentDate: DateTime) {
|
|||||||
|
|
||||||
query GetInsNSIBTypes($currentDate: DateTime) {
|
query GetInsNSIBTypes($currentDate: DateTime) {
|
||||||
evo_addproduct_types(
|
evo_addproduct_types(
|
||||||
filterConditionGroup: {
|
statecode: 0
|
||||||
andFilterConditions: [
|
evo_datefrom_param: { lte: $currentDate }
|
||||||
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
evo_dateto_param: { gte: $currentDate }
|
||||||
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
evo_product_type: 100000002
|
||||||
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
|
||||||
{ filterConditionInt: { fieldName: "evo_product_type", eq: 100000002 } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
...CoreAddProductTypesFields
|
...CoreAddProductTypesFields
|
||||||
evo_max_period
|
evo_max_period
|
||||||
@ -1009,14 +853,10 @@ query GetInsNSIBTypes($currentDate: DateTime) {
|
|||||||
|
|
||||||
query GetLeasingWithoutKaskoTypes($currentDate: DateTime) {
|
query GetLeasingWithoutKaskoTypes($currentDate: DateTime) {
|
||||||
evo_addproduct_types(
|
evo_addproduct_types(
|
||||||
filterConditionGroup: {
|
statecode: 0
|
||||||
andFilterConditions: [
|
evo_product_type: 100000007
|
||||||
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
evo_datefrom_param: { lte: $currentDate }
|
||||||
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
evo_dateto_param: { gte: $currentDate }
|
||||||
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
|
||||||
{ filterConditionInt: { fieldName: "evo_product_type", eq: 100000007 } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
...CoreAddProductTypesFields
|
...CoreAddProductTypesFields
|
||||||
evo_product_type
|
evo_product_type
|
||||||
@ -1038,14 +878,10 @@ query GetLeasingWithoutKaskoTypes($currentDate: DateTime) {
|
|||||||
|
|
||||||
query GetOsagoAddproductTypes($currentDate: DateTime) {
|
query GetOsagoAddproductTypes($currentDate: DateTime) {
|
||||||
evo_addproduct_types(
|
evo_addproduct_types(
|
||||||
filterConditionGroup: {
|
statecode: 0
|
||||||
andFilterConditions: [
|
evo_product_type: 100000008
|
||||||
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
evo_datefrom_param: { lte: $currentDate }
|
||||||
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
evo_dateto_param: { gte: $currentDate }
|
||||||
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
|
||||||
{ filterConditionInt: { fieldName: "evo_product_type", eq: 100000008 } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
evo_product_type
|
evo_product_type
|
||||||
evo_visible_calc
|
evo_visible_calc
|
||||||
@ -1063,18 +899,16 @@ query GetOsagoAddproductTypes($currentDate: DateTime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetInsuranceCompany($accountId: UUID!) {
|
query GetInsuranceCompany($accountId: Uuid!) {
|
||||||
account: insurance(accountid: $accountId) {
|
account(accountid: $accountId) {
|
||||||
evo_osago_with_kasko
|
evo_osago_with_kasko
|
||||||
evo_legal_region_calc
|
evo_legal_region_calc
|
||||||
accountid
|
accountid
|
||||||
evo_kasko_fact_part
|
|
||||||
evo_kasko_plan_part
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetInsuranceCompanies {
|
query GetInsuranceCompanies {
|
||||||
accounts: insurances {
|
accounts(evo_account_type: [100000002], statecode: 0) {
|
||||||
evo_type_ins_policy
|
evo_type_ins_policy
|
||||||
evo_evokasko_access
|
evo_evokasko_access
|
||||||
evo_inn
|
evo_inn
|
||||||
@ -1084,73 +918,11 @@ query GetInsuranceCompanies {
|
|||||||
evo_id_elt
|
evo_id_elt
|
||||||
evo_id_elt_smr
|
evo_id_elt_smr
|
||||||
evo_osago_id
|
evo_osago_id
|
||||||
evo_kasko_category
|
|
||||||
evo_osago_category
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
query GetEltInsuranceRules($currentDate: DateTime) {
|
|
||||||
evo_insurance_ruleses(
|
|
||||||
filterConditionGroup: {
|
|
||||||
andFilterConditions: [
|
|
||||||
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
|
||||||
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
|
||||||
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
evo_id
|
|
||||||
evo_datefrom
|
|
||||||
evo_dateto
|
|
||||||
evo_risk
|
|
||||||
evo_category
|
|
||||||
evo_min_period
|
|
||||||
evo_max_period
|
|
||||||
evo_object_type
|
|
||||||
evo_use_for
|
|
||||||
evo_min_price
|
|
||||||
evo_max_price
|
|
||||||
evo_min_year
|
|
||||||
evo_max_year
|
|
||||||
evo_min_power
|
|
||||||
evo_max_power
|
|
||||||
evo_enginie_type
|
|
||||||
evo_opf
|
|
||||||
evo_min_mileage
|
|
||||||
evo_max_mileage
|
|
||||||
evo_brand
|
|
||||||
evo_model
|
|
||||||
evo_region
|
|
||||||
evo_dealer
|
|
||||||
evo_rules_type
|
|
||||||
evo_message
|
|
||||||
evo_discount
|
|
||||||
evo_insurer_accountid
|
|
||||||
evo_brand
|
|
||||||
evo_model
|
|
||||||
evo_region
|
|
||||||
evo_dealer
|
|
||||||
evo_brands {
|
|
||||||
evo_brandid
|
|
||||||
}
|
|
||||||
evo_models {
|
|
||||||
evo_modelid
|
|
||||||
}
|
|
||||||
accounts {
|
|
||||||
accountid
|
|
||||||
}
|
|
||||||
evo_regions {
|
|
||||||
evo_regionid
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetRoles($roleName: String) {
|
query GetRoles($roleName: String) {
|
||||||
roles(
|
roles(name: $roleName) {
|
||||||
filterConditionGroup: {
|
|
||||||
andFilterConditions: { filterConditionString: { fieldName: "name", eq: $roleName } }
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
systemusers {
|
systemusers {
|
||||||
label: fullname
|
label: fullname
|
||||||
value: domainname
|
value: domainname
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,14 +1,12 @@
|
|||||||
import type * as CRMTypes from '@/graphql/crm.types';
|
import type * as CRMTypes from '@/graphql/crm.types';
|
||||||
|
|
||||||
type SystemUser = NonNullable<CRMTypes.GetSystemUserQuery['systemusers']>[number];
|
function evo_baseproducts(evo_baseproducts: CRMTypes.GetProductsQuery['evo_baseproducts']) {
|
||||||
|
|
||||||
function evo_baseproducts(baseproducts: CRMTypes.GetProductsQuery['evo_baseproducts']) {
|
|
||||||
return {
|
return {
|
||||||
filterBy: {
|
filterBy: {
|
||||||
systemuser(systemuser: SystemUser) {
|
systemuser(systemuser: CRMTypes.GetSystemUserQuery['systemuser']) {
|
||||||
if (!baseproducts?.length || !systemuser) return [];
|
if (!evo_baseproducts?.length || !systemuser) return [];
|
||||||
|
|
||||||
return baseproducts?.filter(
|
return evo_baseproducts?.filter(
|
||||||
(evo_baseproduct) =>
|
(evo_baseproduct) =>
|
||||||
!evo_baseproduct?.systemusers?.length ||
|
!evo_baseproduct?.systemusers?.length ||
|
||||||
evo_baseproduct?.systemusers?.some(
|
evo_baseproduct?.systemusers?.some(
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -1,17 +0,0 @@
|
|||||||
/* eslint-disable no-console */
|
|
||||||
import { useEffect } from 'react';
|
|
||||||
|
|
||||||
export function useServiceWorker() {
|
|
||||||
useEffect(() => {
|
|
||||||
if ('serviceWorker' in navigator) {
|
|
||||||
navigator.serviceWorker
|
|
||||||
.register('/sw.js')
|
|
||||||
.then((registration) => {
|
|
||||||
console.log('Service Worker registered with scope:', registration.scope);
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.log('Service Worker registration failed:', error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
}
|
|
||||||
@ -39,23 +39,20 @@ export const handlers = [
|
|||||||
rest.post(URL_1C_TRANSTAX, (req, res, ctx) =>
|
rest.post(URL_1C_TRANSTAX, (req, res, ctx) =>
|
||||||
res(
|
res(
|
||||||
ctx.json({
|
ctx.json({
|
||||||
Error: null,
|
error: null,
|
||||||
Tax: _.random(100000, 200000),
|
tax: _.random(100000, 200000),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
rest.post(URL_ELT_OSAGO, async (req, res, ctx) =>
|
rest.post(URL_ELT_OSAGO, async (req, res, ctx) => res(
|
||||||
res(
|
|
||||||
ctx.json({
|
ctx.json({
|
||||||
numCalc: _.random(1000000, 3000000),
|
numCalc: _.random(1000000, 3000000),
|
||||||
skCalcId: _.random(50000000, 60000000).toString(),
|
skCalcId: _.random(50000000, 60000000).toString(),
|
||||||
premiumSum: _.random(10000, 20000),
|
premiumSum: _.random(10000, 20000),
|
||||||
message: 'OSAGO Message',
|
message: 'OSAGO Message',
|
||||||
})
|
})
|
||||||
)
|
)),
|
||||||
),
|
rest.post(URL_ELT_KASKO, async (req, res, ctx) => res(
|
||||||
rest.post(URL_ELT_KASKO, async (req, res, ctx) =>
|
|
||||||
res(
|
|
||||||
ctx.json({
|
ctx.json({
|
||||||
requestId: _.random(3000000, 4000000).toString(),
|
requestId: _.random(3000000, 4000000).toString(),
|
||||||
skCalcId: _.random(50000000, 60000000).toString(),
|
skCalcId: _.random(50000000, 60000000).toString(),
|
||||||
@ -70,8 +67,7 @@ export const handlers = [
|
|||||||
],
|
],
|
||||||
totalFranchise: _.random(20000, 40000),
|
totalFranchise: _.random(20000, 40000),
|
||||||
})
|
})
|
||||||
)
|
)),
|
||||||
),
|
|
||||||
|
|
||||||
// rest.post(URL_CRM_GRAPHQL, (req, res, ctx) => {
|
// rest.post(URL_CRM_GRAPHQL, (req, res, ctx) => {
|
||||||
// return res(ctx.status(503));
|
// return res(ctx.status(503));
|
||||||
|
|||||||
@ -29,7 +29,6 @@ module.exports = withSentryConfig(
|
|||||||
},
|
},
|
||||||
experimental: {
|
experimental: {
|
||||||
outputFileTracingRoot: path.join(__dirname, '../../'),
|
outputFileTracingRoot: path.join(__dirname, '../../'),
|
||||||
proxyTimeout: 1000 * 90,
|
|
||||||
},
|
},
|
||||||
images: {
|
images: {
|
||||||
deviceSizes: devices,
|
deviceSizes: devices,
|
||||||
@ -66,10 +65,10 @@ module.exports = withSentryConfig(
|
|||||||
destination: env.URL_CORE_FINGAP_DIRECT,
|
destination: env.URL_CORE_FINGAP_DIRECT,
|
||||||
source: urls.URL_CORE_FINGAP_PROXY,
|
source: urls.URL_CORE_FINGAP_PROXY,
|
||||||
},
|
},
|
||||||
// {
|
{
|
||||||
// destination: env.URL_1C_TRANSTAX_DIRECT,
|
destination: env.URL_1C_TRANSTAX_DIRECT,
|
||||||
// source: urls.URL_1C_TRANSTAX_PROXY,
|
source: urls.URL_1C_TRANSTAX_PROXY,
|
||||||
// },
|
},
|
||||||
{
|
{
|
||||||
destination: env.URL_ELT_KASKO_DIRECT,
|
destination: env.URL_ELT_KASKO_DIRECT,
|
||||||
source: urls.URL_ELT_KASKO_PROXY,
|
source: urls.URL_ELT_KASKO_PROXY,
|
||||||
|
|||||||
@ -16,7 +16,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@apollo/client": "^3.9.5",
|
"@apollo/client": "^3.9.5",
|
||||||
"@artsy/fresnel": "^7.1.4",
|
|
||||||
"@fontsource/montserrat": "^4.5.14",
|
"@fontsource/montserrat": "^4.5.14",
|
||||||
"@sentry/nextjs": "^7.102.0",
|
"@sentry/nextjs": "^7.102.0",
|
||||||
"@sentry/node": "^7.102.0",
|
"@sentry/node": "^7.102.0",
|
||||||
@ -30,14 +29,13 @@
|
|||||||
"mobx": "^6.12.0",
|
"mobx": "^6.12.0",
|
||||||
"mobx-react-lite": "^4.0.5",
|
"mobx-react-lite": "^4.0.5",
|
||||||
"modern-normalize": "^2.0.0",
|
"modern-normalize": "^2.0.0",
|
||||||
"next": "^14.2.5",
|
"next": "^14.1.0",
|
||||||
"radash": "^11.0.0",
|
"radash": "^11.0.0",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"styled-components": "^5.3.11",
|
"styled-components": "^5.3.11",
|
||||||
"superjson": "^2.2.1",
|
"superjson": "^2.2.1",
|
||||||
"tools": "workspace:*",
|
"tools": "workspace:*",
|
||||||
"ua-parser-js": "^1.0.38",
|
|
||||||
"ui": "workspace:*",
|
"ui": "workspace:*",
|
||||||
"use-debounce": "^9.0.4",
|
"use-debounce": "^9.0.4",
|
||||||
"zod": "^3.22.4"
|
"zod": "^3.22.4"
|
||||||
@ -55,11 +53,10 @@
|
|||||||
"@types/react": "^18.2.14",
|
"@types/react": "^18.2.14",
|
||||||
"@types/react-dom": "^18.2.6",
|
"@types/react-dom": "^18.2.6",
|
||||||
"@types/styled-components": "^5.1.26",
|
"@types/styled-components": "^5.1.26",
|
||||||
"@types/ua-parser-js": "^0.7.39",
|
|
||||||
"@vchikalkin/eslint-config-awesome": "^1.1.6",
|
"@vchikalkin/eslint-config-awesome": "^1.1.6",
|
||||||
"antd": "^5.14.2",
|
"antd": "^5.14.2",
|
||||||
"eslint": "^8.52.0",
|
"eslint": "^8.52.0",
|
||||||
"gql-sdl": "^1.1.0",
|
"gql-sdl": "^1.0.0",
|
||||||
"jest": "^29.4.3",
|
"jest": "^29.4.3",
|
||||||
"jest-environment-jsdom": "^29.3.1",
|
"jest-environment-jsdom": "^29.3.1",
|
||||||
"msw": "^1.1.0",
|
"msw": "^1.1.0",
|
||||||
|
|||||||
@ -4,15 +4,13 @@ import '../styles/antd-fix.css';
|
|||||||
import '../styles/antd.min.css';
|
import '../styles/antd.min.css';
|
||||||
import initializeQueryClient from '@/api/client';
|
import initializeQueryClient from '@/api/client';
|
||||||
import initializeApollo from '@/apollo/client';
|
import initializeApollo from '@/apollo/client';
|
||||||
import { Loading } from '@/Components/Common';
|
import { Loading, Notification } from '@/Components/Common';
|
||||||
import Layout from '@/Components/Layout';
|
import Layout from '@/Components/Layout';
|
||||||
import { theme } from '@/config/ui';
|
import { theme } from '@/config/ui';
|
||||||
import { usePageLoading } from '@/hooks';
|
import { usePageLoading } from '@/hooks';
|
||||||
import { useServiceWorker } from '@/hooks/worker';
|
|
||||||
import StoreProvider from '@/stores/Provider';
|
import StoreProvider from '@/stores/Provider';
|
||||||
import getColors from '@/styles/colors';
|
import getColors from '@/styles/colors';
|
||||||
import { GlobalStyle } from '@/styles/global-style';
|
import { GlobalStyle } from '@/styles/global-style';
|
||||||
import { MediaContextProvider } from '@/styles/media';
|
|
||||||
import { trpcClient } from '@/trpc/client';
|
import { trpcClient } from '@/trpc/client';
|
||||||
import { ApolloProvider } from '@apollo/client';
|
import { ApolloProvider } from '@apollo/client';
|
||||||
import { QueryClientProvider } from '@tanstack/react-query';
|
import { QueryClientProvider } from '@tanstack/react-query';
|
||||||
@ -29,14 +27,10 @@ const colorPrimary = getColors().COLOR_PRIMARY;
|
|||||||
|
|
||||||
function App({ Component, pageProps }) {
|
function App({ Component, pageProps }) {
|
||||||
const { initialApolloState, initialQueryState } = pageProps;
|
const { initialApolloState, initialQueryState } = pageProps;
|
||||||
const apolloClient = useMemo(
|
const apolloClient = useMemo(() => initializeApollo(initialApolloState), [initialApolloState]);
|
||||||
() => initializeApollo(initialApolloState, {}),
|
|
||||||
[initialApolloState]
|
|
||||||
);
|
|
||||||
const queryClient = useMemo(() => initializeQueryClient(initialQueryState), [initialQueryState]);
|
const queryClient = useMemo(() => initializeQueryClient(initialQueryState), [initialQueryState]);
|
||||||
|
|
||||||
const { loading } = usePageLoading();
|
const { loading } = usePageLoading();
|
||||||
useServiceWorker();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ThemeProvider theme={theme}>
|
<ThemeProvider theme={theme}>
|
||||||
@ -60,11 +54,11 @@ function App({ Component, pageProps }) {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<MediaContextProvider>
|
<Notification>
|
||||||
<Layout {...pageProps}>
|
<Layout {...pageProps}>
|
||||||
{loading ? <Loading /> : <Component {...pageProps} />}
|
{loading ? <Loading /> : <Component {...pageProps} />}
|
||||||
</Layout>
|
</Layout>
|
||||||
</MediaContextProvider>
|
</Notification>
|
||||||
</AntdConfig>
|
</AntdConfig>
|
||||||
</QueryClientProvider>
|
</QueryClientProvider>
|
||||||
</ApolloProvider>
|
</ApolloProvider>
|
||||||
|
|||||||
@ -29,7 +29,7 @@ export async function getServerSideProps({ req }) {
|
|||||||
const { cookie = '' } = req.headers;
|
const { cookie = '' } = req.headers;
|
||||||
|
|
||||||
const queryClient = new QueryClient();
|
const queryClient = new QueryClient();
|
||||||
const apolloClient = initializeApollo(null, req.headers);
|
const apolloClient = initializeApollo();
|
||||||
const getUserType = makeGetUserType({ apolloClient, queryClient });
|
const getUserType = makeGetUserType({ apolloClient, queryClient });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -1,38 +0,0 @@
|
|||||||
import type { ResponseTransTax } from '@/api/1c/types';
|
|
||||||
import { serverRuntimeConfigSchema } from '@/config/schema/runtime-config';
|
|
||||||
import { withHandleError } from '@/utils/axios';
|
|
||||||
import type { HttpError } from '@/utils/error';
|
|
||||||
import axios from 'axios';
|
|
||||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
|
||||||
import getConfig from 'next/config';
|
|
||||||
|
|
||||||
const { serverRuntimeConfig } = getConfig();
|
|
||||||
const { USERNAME_1C_TRANSTAX, PASSWORD_1C_TRANSTAX, URL_1C_TRANSTAX_DIRECT } =
|
|
||||||
serverRuntimeConfigSchema.parse(serverRuntimeConfig);
|
|
||||||
|
|
||||||
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
||||||
const abortController = new AbortController();
|
|
||||||
|
|
||||||
req.on('close', () => {
|
|
||||||
abortController.abort();
|
|
||||||
});
|
|
||||||
|
|
||||||
const params = req.body as ResponseTransTax;
|
|
||||||
|
|
||||||
withHandleError(
|
|
||||||
axios.get<ResponseTransTax>(URL_1C_TRANSTAX_DIRECT, {
|
|
||||||
auth: {
|
|
||||||
password: PASSWORD_1C_TRANSTAX,
|
|
||||||
username: USERNAME_1C_TRANSTAX,
|
|
||||||
},
|
|
||||||
params,
|
|
||||||
signal: abortController.signal,
|
|
||||||
})
|
|
||||||
)
|
|
||||||
.then(({ data }) => res.json(data))
|
|
||||||
.catch((error) => {
|
|
||||||
const _err = error as HttpError;
|
|
||||||
|
|
||||||
return res.json({ message: _err.message });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@ -1,23 +1,34 @@
|
|||||||
import initializeApollo from '@/apollo/client';
|
import initializeApollo from '@/apollo/client';
|
||||||
import { Content } from '@/Components/Calculation';
|
import * as Calculation from '@/Components/Calculation';
|
||||||
import { Error } from '@/Components/Common/Error';
|
import { Error } from '@/Components/Common/Error';
|
||||||
import * as hooks from '@/process/hooks';
|
import * as hooks from '@/process/hooks';
|
||||||
|
import { getPageTitle } from '@/utils/page';
|
||||||
import { makeGetUserType } from '@/utils/user';
|
import { makeGetUserType } from '@/utils/user';
|
||||||
import { dehydrate, QueryClient } from '@tanstack/react-query';
|
import { dehydrate, QueryClient } from '@tanstack/react-query';
|
||||||
|
import Head from 'next/head';
|
||||||
|
|
||||||
|
function Content() {
|
||||||
|
hooks.useSentryScope();
|
||||||
|
hooks.useMainData();
|
||||||
|
hooks.useInsuranceData();
|
||||||
|
hooks.useReactions();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Calculation.Layout>
|
||||||
|
<Head>
|
||||||
|
<title>{getPageTitle()}</title>
|
||||||
|
</Head>
|
||||||
|
<Calculation.Form prune={['unlimited']} />
|
||||||
|
<Calculation.Settings />
|
||||||
|
<Calculation.Output />
|
||||||
|
</Calculation.Layout>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export default function Page(props) {
|
export default function Page(props) {
|
||||||
if (props.statusCode !== 200) return <Error {...props} />;
|
if (props.statusCode !== 200) return <Error {...props} />;
|
||||||
|
|
||||||
return (
|
return <Content />;
|
||||||
<Content
|
|
||||||
initHooks={() => {
|
|
||||||
hooks.useSentryScope();
|
|
||||||
hooks.useMainData();
|
|
||||||
hooks.useInsuranceData();
|
|
||||||
hooks.useReactions();
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {import('next').GetServerSideProps} */
|
/** @type {import('next').GetServerSideProps} */
|
||||||
@ -25,7 +36,7 @@ export async function getServerSideProps({ req }) {
|
|||||||
const { cookie = '' } = req.headers;
|
const { cookie = '' } = req.headers;
|
||||||
|
|
||||||
const queryClient = new QueryClient();
|
const queryClient = new QueryClient();
|
||||||
const apolloClient = initializeApollo(null, req.headers);
|
const apolloClient = initializeApollo();
|
||||||
const getUserType = makeGetUserType({ apolloClient, queryClient });
|
const getUserType = makeGetUserType({ apolloClient, queryClient });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -1,25 +1,35 @@
|
|||||||
import initializeApollo from '@/apollo/client';
|
import initializeApollo from '@/apollo/client';
|
||||||
import { Content } from '@/Components/Calculation';
|
import * as Calculation from '@/Components/Calculation';
|
||||||
import { Error } from '@/Components/Common/Error';
|
import { Error } from '@/Components/Common/Error';
|
||||||
import * as hooks from '@/process/hooks';
|
import * as hooks from '@/process/hooks';
|
||||||
|
import { getPageTitle } from '@/utils/page';
|
||||||
import { makeGetUserType } from '@/utils/user';
|
import { makeGetUserType } from '@/utils/user';
|
||||||
import { dehydrate, QueryClient } from '@tanstack/react-query';
|
import { dehydrate, QueryClient } from '@tanstack/react-query';
|
||||||
|
import Head from 'next/head';
|
||||||
|
|
||||||
|
function Content() {
|
||||||
|
hooks.useSentryScope();
|
||||||
|
hooks.useMainData();
|
||||||
|
hooks.useGetUsers();
|
||||||
|
hooks.useInsuranceData();
|
||||||
|
hooks.useReactions();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Calculation.Layout>
|
||||||
|
<Head>
|
||||||
|
<title>{getPageTitle('Без ограничений')}</title>
|
||||||
|
</Head>
|
||||||
|
<Calculation.Form />
|
||||||
|
<Calculation.Settings />
|
||||||
|
<Calculation.Output />
|
||||||
|
</Calculation.Layout>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export default function Page(props) {
|
export default function Page(props) {
|
||||||
if (props.statusCode !== 200) return <Error {...props} />;
|
if (props.statusCode !== 200) return <Error {...props} />;
|
||||||
|
|
||||||
return (
|
return <Content />;
|
||||||
<Content
|
|
||||||
title="Без ограничений"
|
|
||||||
initHooks={() => {
|
|
||||||
hooks.useSentryScope();
|
|
||||||
hooks.useMainData();
|
|
||||||
hooks.useGetUsers();
|
|
||||||
hooks.useInsuranceData();
|
|
||||||
hooks.useReactions();
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {import('next').GetServerSideProps} */
|
/** @type {import('next').GetServerSideProps} */
|
||||||
@ -27,7 +37,7 @@ export async function getServerSideProps({ req }) {
|
|||||||
const { cookie = '' } = req.headers;
|
const { cookie = '' } = req.headers;
|
||||||
|
|
||||||
const queryClient = new QueryClient();
|
const queryClient = new QueryClient();
|
||||||
const apolloClient = initializeApollo(null, req.headers);
|
const apolloClient = initializeApollo();
|
||||||
const getUserType = makeGetUserType({ apolloClient, queryClient });
|
const getUserType = makeGetUserType({ apolloClient, queryClient });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -1,12 +1,14 @@
|
|||||||
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
|
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
|
||||||
|
import initializeApollo from '@/apollo/client';
|
||||||
import defaultValues from '@/config/default-values';
|
import defaultValues from '@/config/default-values';
|
||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
|
|
||||||
export async function getKPData({
|
export async function getKPData({
|
||||||
values: { recalcWithRevision },
|
values: { recalcWithRevision },
|
||||||
quote,
|
quote,
|
||||||
ctx: { apolloClient },
|
|
||||||
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
|
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
|
||||||
|
const apolloClient = initializeApollo();
|
||||||
|
|
||||||
const registration =
|
const registration =
|
||||||
quote?.evo_addproduct_types?.find((x) => x?.evo_product_type === 100_000_001)
|
quote?.evo_addproduct_types?.find((x) => x?.evo_product_type === 100_000_001)
|
||||||
?.evo_addproduct_typeid ?? defaultValues.registration;
|
?.evo_addproduct_typeid ?? defaultValues.registration;
|
||||||
|
|||||||
@ -4,14 +4,14 @@ import type { ProcessContext } from '../types';
|
|||||||
import { createValidationSchema } from './validation';
|
import { createValidationSchema } from './validation';
|
||||||
import { selectRequirementTelematic } from '@/config/default-options';
|
import { selectRequirementTelematic } from '@/config/default-options';
|
||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import { getCurrentDateString } from '@/utils/date';
|
import { getCurrentISODate } from '@/utils/date';
|
||||||
import { normalizeOptions } from '@/utils/entity';
|
import { normalizeOptions } from '@/utils/entity';
|
||||||
import { debouncedReaction } from '@/utils/mobx';
|
import { debouncedReaction } from '@/utils/mobx';
|
||||||
import { reaction } from 'mobx';
|
import { reaction, toJS } from 'mobx';
|
||||||
import { max } from 'radash';
|
import { max } from 'radash';
|
||||||
|
|
||||||
export default function reactions({ store, apolloClient }: ProcessContext) {
|
export default function reactions({ store, apolloClient }: ProcessContext) {
|
||||||
const { $calculation, $process } = store;
|
const { $calculation, $tables, $process } = store;
|
||||||
|
|
||||||
reaction(
|
reaction(
|
||||||
() => $calculation.$values.getValues(['leasingPeriod', 'leaseObjectType', 'maxMass']),
|
() => $calculation.$values.getValues(['leasingPeriod', 'leaseObjectType', 'maxMass']),
|
||||||
@ -21,7 +21,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const currentDate = getCurrentDateString();
|
const currentDate = getCurrentISODate();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: { evo_addproduct_types },
|
data: { evo_addproduct_types },
|
||||||
@ -126,7 +126,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
|||||||
reaction(
|
reaction(
|
||||||
() => $calculation.$values.getValues(['leasingPeriod', 'leaseObjectType']),
|
() => $calculation.$values.getValues(['leasingPeriod', 'leaseObjectType']),
|
||||||
async ({ leasingPeriod, leaseObjectType }) => {
|
async ({ leasingPeriod, leaseObjectType }) => {
|
||||||
const currentDate = getCurrentDateString();
|
const currentDate = getCurrentISODate();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: { evo_addproduct_types },
|
data: { evo_addproduct_types },
|
||||||
@ -160,35 +160,35 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// reaction(
|
reaction(
|
||||||
// () => {
|
() => {
|
||||||
// const values = $calculation.$values.getValues(['leasingPeriod', 'leasingWithoutKasko']);
|
const values = $calculation.$values.getValues(['leasingPeriod', 'leasingWithoutKasko']);
|
||||||
// const kaskoInsured = toJS($tables.insurance.row('kasko').getValue('insured'));
|
const kaskoInsured = toJS($tables.insurance.row('kasko').getValue('insured'));
|
||||||
// const fingapInsured = toJS($tables.insurance.row('fingap').getValue('insured'));
|
const fingapInsured = toJS($tables.insurance.row('fingap').getValue('insured'));
|
||||||
|
|
||||||
// return {
|
return {
|
||||||
// ...values,
|
...values,
|
||||||
// fingapInsured,
|
fingapInsured,
|
||||||
// kaskoInsured,
|
kaskoInsured,
|
||||||
// };
|
};
|
||||||
// },
|
},
|
||||||
// ({ leasingPeriod, fingapInsured, kaskoInsured, leasingWithoutKasko }) => {
|
({ leasingPeriod, fingapInsured, kaskoInsured, leasingWithoutKasko }) => {
|
||||||
// if (
|
if (
|
||||||
// leasingPeriod < 12 ||
|
leasingPeriod < 12 ||
|
||||||
// leasingWithoutKasko ||
|
leasingWithoutKasko ||
|
||||||
// kaskoInsured === 100_000_001 ||
|
kaskoInsured === 100_000_001 ||
|
||||||
// (fingapInsured === 100_000_001 && leasingPeriod < 36)
|
(fingapInsured === 100_000_001 && leasingPeriod < 36)
|
||||||
// ) {
|
) {
|
||||||
// $calculation.element('selectInsNSIB').resetValue().block();
|
$calculation.element('selectInsNSIB').resetValue().block();
|
||||||
// } else {
|
} else {
|
||||||
// $calculation.element('selectInsNSIB').unblock();
|
$calculation.element('selectInsNSIB').unblock();
|
||||||
// }
|
}
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// delay: 10,
|
delay: 10,
|
||||||
// fireImmediately: true,
|
fireImmediately: true,
|
||||||
// }
|
}
|
||||||
// );
|
);
|
||||||
|
|
||||||
debouncedReaction(
|
debouncedReaction(
|
||||||
() =>
|
() =>
|
||||||
@ -210,7 +210,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
|||||||
leasingPeriod,
|
leasingPeriod,
|
||||||
plPriceRub,
|
plPriceRub,
|
||||||
}) => {
|
}) => {
|
||||||
const currentDate = getCurrentDateString();
|
const currentDate = getCurrentISODate();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: { evo_addproduct_types },
|
data: { evo_addproduct_types },
|
||||||
@ -323,7 +323,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
|||||||
leaseObjectType: leaseObjectTypeId,
|
leaseObjectType: leaseObjectTypeId,
|
||||||
engineType,
|
engineType,
|
||||||
}) => {
|
}) => {
|
||||||
const currentDate = getCurrentDateString();
|
const currentDate = getCurrentISODate();
|
||||||
const {
|
const {
|
||||||
data: { evo_addproduct_types: trackerTypes },
|
data: { evo_addproduct_types: trackerTypes },
|
||||||
} = await apolloClient.query({
|
} = await apolloClient.query({
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import type { ValidationContext } from '../../types';
|
import type { ValidationContext } from '../../types';
|
||||||
import type { ElementsTypes } from '@/Components/Calculation/config/map/values';
|
import type { ElementsTypes } from '@/Components/Calculation/config/map/values';
|
||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import { getCurrentDateString } from '@/utils/date';
|
import { getCurrentISODate } from '@/utils/date';
|
||||||
|
|
||||||
export type ProductId = ElementsTypes['selectProduct'];
|
export type ProductId = ElementsTypes['selectProduct'];
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ export default function helper({ apolloClient, user }: ValidationContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: { systemusers },
|
data: { systemuser },
|
||||||
} = await apolloClient.query({
|
} = await apolloClient.query({
|
||||||
query: CRMTypes.GetSystemUserDocument,
|
query: CRMTypes.GetSystemUserDocument,
|
||||||
variables: {
|
variables: {
|
||||||
@ -21,13 +21,11 @@ export default function helper({ apolloClient, user }: ValidationContext) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const systemuser = systemusers?.[0];
|
|
||||||
|
|
||||||
if (!systemuser?.evo_job_titleid) {
|
if (!systemuser?.evo_job_titleid) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentDate = getCurrentDateString();
|
const currentDate = getCurrentISODate();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: { evo_coefficients },
|
data: { evo_coefficients },
|
||||||
|
|||||||
@ -10,17 +10,8 @@ export function createValidationSchema(context: ValidationContext) {
|
|||||||
return ValuesSchema.pick({ product: true, saleBonus: true }).superRefine(
|
return ValuesSchema.pick({ product: true, saleBonus: true }).superRefine(
|
||||||
async ({ product, saleBonus }, ctx) => {
|
async ({ product, saleBonus }, ctx) => {
|
||||||
const coefficient = await getCoefficient(product);
|
const coefficient = await getCoefficient(product);
|
||||||
const minBonus = (coefficient?.evo_correction_coefficient || 0) * 100;
|
|
||||||
const maxBonus = (coefficient?.evo_sot_coefficient || 0) * 100;
|
const maxBonus = (coefficient?.evo_sot_coefficient || 0) * 100;
|
||||||
|
|
||||||
if (round(saleBonus, 2) < round(minBonus, 2)) {
|
|
||||||
ctx.addIssue({
|
|
||||||
code: z.ZodIssueCode.custom,
|
|
||||||
message: 'Бонус не может быть ниже установленного по СОТ',
|
|
||||||
path: ['tbxSaleBonus'],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (round(saleBonus, 2) > round(maxBonus, 2)) {
|
if (round(saleBonus, 2) > round(maxBonus, 2)) {
|
||||||
ctx.addIssue({
|
ctx.addIssue({
|
||||||
code: z.ZodIssueCode.custom,
|
code: z.ZodIssueCode.custom,
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import helper from '../lib/helper';
|
import helper from '../lib/helper';
|
||||||
import { IRR_THRESHOLD } from '@/constants/values';
|
|
||||||
import type { ProcessContext } from '@/process/types';
|
import type { ProcessContext } from '@/process/types';
|
||||||
import { disposableReaction } from '@/utils/mobx';
|
import { disposableReaction } from '@/utils/mobx';
|
||||||
import { comparer, reaction } from 'mobx';
|
import { comparer, reaction } from 'mobx';
|
||||||
@ -32,8 +31,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
|||||||
|
|
||||||
const { getIrr } = helper({ apolloClient });
|
const { getIrr } = helper({ apolloClient });
|
||||||
|
|
||||||
disposableReaction(
|
reaction(
|
||||||
() => $process.has('LoadKP'),
|
|
||||||
() => $calculation.$values.getValues(['product', 'tarif', 'bonusCoefficient']),
|
() => $calculation.$values.getValues(['product', 'tarif', 'bonusCoefficient']),
|
||||||
async (values) => {
|
async (values) => {
|
||||||
const { min, max } = await getIrr(values);
|
const { min, max } = await getIrr(values);
|
||||||
@ -42,19 +40,6 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// костыль
|
|
||||||
disposableReaction(
|
|
||||||
() =>
|
|
||||||
$process.has('LoadKP') ||
|
|
||||||
$calculation.element('radioLastPaymentRule').getValue() === 100_000_002,
|
|
||||||
() => $calculation.element('labelIrrInfo').getValue(),
|
|
||||||
({ min }) => {
|
|
||||||
if ($calculation.element('radioLastPaymentRule').getValue() === 100_000_002) return;
|
|
||||||
|
|
||||||
$calculation.element('tbxIRR_Perc').setValue(min + IRR_THRESHOLD);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
disposableReaction(
|
disposableReaction(
|
||||||
() => $process.has('Calculate') || $process.has('CreateKP'),
|
() => $process.has('Calculate') || $process.has('CreateKP'),
|
||||||
() => {
|
() => {
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
/* eslint-disable complexity */
|
/* eslint-disable complexity */
|
||||||
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
|
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
|
||||||
import helper from './lib/helper';
|
import helper from './lib/helper';
|
||||||
|
import initializeApollo from '@/apollo/client';
|
||||||
import defaultValues from '@/config/default-values';
|
import defaultValues from '@/config/default-values';
|
||||||
import calculateHelper from '@/process/calculate/lib/helper';
|
import calculateHelper from '@/process/calculate/lib/helper';
|
||||||
import { getKPData as getKPDataPrice } from '@/process/price/get-kp-data';
|
import { getKPData as getKPDataPrice } from '@/process/price/get-kp-data';
|
||||||
@ -12,10 +13,9 @@ import { normalizeOptions } from '@/utils/entity';
|
|||||||
export async function getKPData({
|
export async function getKPData({
|
||||||
values,
|
values,
|
||||||
quote,
|
quote,
|
||||||
ctx,
|
|
||||||
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
|
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
|
||||||
const { apolloClient } = ctx;
|
|
||||||
const { recalcWithRevision } = values;
|
const { recalcWithRevision } = values;
|
||||||
|
const apolloClient = initializeApollo();
|
||||||
|
|
||||||
const leasingPeriod = recalcWithRevision
|
const leasingPeriod = recalcWithRevision
|
||||||
? Math.min(quote?.evo_period ?? 0, quote?.evo_accept_period ?? 0)
|
? Math.min(quote?.evo_period ?? 0, quote?.evo_accept_period ?? 0)
|
||||||
@ -61,8 +61,8 @@ export async function getKPData({
|
|||||||
let minPriceChange = quote?.evo_min_change_price ?? defaultValues.minPriceChange;
|
let minPriceChange = quote?.evo_min_change_price ?? defaultValues.minPriceChange;
|
||||||
|
|
||||||
if (!recalcWithRevision) {
|
if (!recalcWithRevision) {
|
||||||
const kpDataPrice = await getKPDataPrice({ ctx, quote, values });
|
const kpDataPrice = await getKPDataPrice({ quote, values });
|
||||||
const kpDataSubsidy = await getKPDataSubsidy({ ctx, quote, values });
|
const kpDataSubsidy = await getKPDataSubsidy({ quote, values });
|
||||||
|
|
||||||
const supplierCurrency = kpDataPrice.values?.supplierCurrency ?? defaultValues.supplierCurrency;
|
const supplierCurrency = kpDataPrice.values?.supplierCurrency ?? defaultValues.supplierCurrency;
|
||||||
const leaseObjectPrice = kpDataPrice.values?.leaseObjectPrice ?? defaultValues.leaseObjectPrice;
|
const leaseObjectPrice = kpDataPrice.values?.leaseObjectPrice ?? defaultValues.leaseObjectPrice;
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { RATE } from '@/constants/values';
|
|||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import type { ProcessContext } from '@/process/types';
|
import type { ProcessContext } from '@/process/types';
|
||||||
import type { CalculationValues } from '@/stores/calculation/values/types';
|
import type { CalculationValues } from '@/stores/calculation/values/types';
|
||||||
import { getCurrentDateString } from '@/utils/date';
|
import { getCurrentISODate } from '@/utils/date';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { first, sort } from 'radash';
|
import { first, sort } from 'radash';
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ export default function helper({ apolloClient }: Pick<ProcessContext, 'apolloCli
|
|||||||
},
|
},
|
||||||
|
|
||||||
async getRates({ tarif: tarifId }: GetRatesInputValues) {
|
async getRates({ tarif: tarifId }: GetRatesInputValues) {
|
||||||
const currentDate = getCurrentDateString();
|
const currentDate = getCurrentISODate();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: { evo_rates },
|
data: { evo_rates },
|
||||||
@ -125,7 +125,7 @@ export default function helper({ apolloClient }: Pick<ProcessContext, 'apolloCli
|
|||||||
});
|
});
|
||||||
|
|
||||||
const filtered_evo_tarif_evo_rates =
|
const filtered_evo_tarif_evo_rates =
|
||||||
evo_tarif?.evo_rates?.filter((x) => x?.evo_type === 100_000_000 && x.statecode === 0) || [];
|
evo_tarif?.evo_rates?.filter((x) => x?.evo_type === 100_000_000) || [];
|
||||||
|
|
||||||
const evo_tarif_evo_rate =
|
const evo_tarif_evo_rate =
|
||||||
evo_tarif?.evo_rates &&
|
evo_tarif?.evo_rates &&
|
||||||
@ -157,7 +157,7 @@ export default function helper({ apolloClient }: Pick<ProcessContext, 'apolloCli
|
|||||||
floatingRate,
|
floatingRate,
|
||||||
partialVAT,
|
partialVAT,
|
||||||
}: GetTarifInputValues) {
|
}: GetTarifInputValues) {
|
||||||
const currentDate = getCurrentDateString();
|
const currentDate = getCurrentISODate();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: { evo_tarifs = [] },
|
data: { evo_tarifs = [] },
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { crmTools } from '@/graphql/crm.tools';
|
|||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import { SEASON_TYPES } from '@/process/payments/lib/seasons-constants';
|
import { SEASON_TYPES } from '@/process/payments/lib/seasons-constants';
|
||||||
import type { ProcessContext } from '@/process/types';
|
import type { ProcessContext } from '@/process/types';
|
||||||
import { getCurrentDateString } from '@/utils/date';
|
import { getCurrentISODate } from '@/utils/date';
|
||||||
import { normalizeOptions } from '@/utils/entity';
|
import { normalizeOptions } from '@/utils/entity';
|
||||||
import { disposableReaction } from '@/utils/mobx';
|
import { disposableReaction } from '@/utils/mobx';
|
||||||
import { reaction } from 'mobx';
|
import { reaction } from 'mobx';
|
||||||
@ -355,7 +355,7 @@ export default function reactions({ store, apolloClient, user }: ProcessContext)
|
|||||||
reaction(
|
reaction(
|
||||||
() => $calculation.element('selectQuote').getValue(),
|
() => $calculation.element('selectQuote').getValue(),
|
||||||
async (quoteId) => {
|
async (quoteId) => {
|
||||||
const currentDate = getCurrentDateString();
|
const currentDate = getCurrentISODate();
|
||||||
|
|
||||||
let {
|
let {
|
||||||
data: { evo_baseproducts },
|
data: { evo_baseproducts },
|
||||||
@ -369,7 +369,7 @@ export default function reactions({ store, apolloClient, user }: ProcessContext)
|
|||||||
|
|
||||||
if (user && evo_baseproducts) {
|
if (user && evo_baseproducts) {
|
||||||
const {
|
const {
|
||||||
data: { systemusers },
|
data: { systemuser },
|
||||||
} = await apolloClient.query({
|
} = await apolloClient.query({
|
||||||
fetchPolicy: 'network-only',
|
fetchPolicy: 'network-only',
|
||||||
query: CRMTypes.GetSystemUserDocument,
|
query: CRMTypes.GetSystemUserDocument,
|
||||||
@ -378,13 +378,9 @@ export default function reactions({ store, apolloClient, user }: ProcessContext)
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const systemuser = systemusers?.[0];
|
evo_baseproducts = crmTools
|
||||||
|
.evo_baseproducts(evo_baseproducts)
|
||||||
if (systemuser) {
|
.filterBy.systemuser(systemuser);
|
||||||
evo_baseproducts = crmTools
|
|
||||||
.evo_baseproducts(evo_baseproducts)
|
|
||||||
.filterBy.systemuser(systemuser);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$calculation.element('cbxRecalcWithRevision').getValue()) {
|
if (!$calculation.element('cbxRecalcWithRevision').getValue()) {
|
||||||
|
|||||||
@ -16,35 +16,23 @@ export default function unlimitedReactions({ store, apolloClient }: ProcessConte
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const {
|
||||||
|
data: { leads },
|
||||||
|
} = await apolloClient.query({
|
||||||
|
query: CRMTypes.GetLeadsDocument,
|
||||||
|
variables: { domainname },
|
||||||
|
});
|
||||||
|
|
||||||
{
|
$calculation.element('selectLead').setOptions(normalizeOptions(leads));
|
||||||
const { data } = await apolloClient.query({
|
|
||||||
query: CRMTypes.GetLeadsDocument,
|
|
||||||
variables: { domainname },
|
|
||||||
});
|
|
||||||
|
|
||||||
const systemuser = data?.systemusers?.[0];
|
const {
|
||||||
|
data: { opportunities },
|
||||||
|
} = await apolloClient.query({
|
||||||
|
query: CRMTypes.GetOpportunitiesDocument,
|
||||||
|
variables: { domainname },
|
||||||
|
});
|
||||||
|
|
||||||
if (systemuser) {
|
$calculation.element('selectOpportunity').setOptions(normalizeOptions(opportunities));
|
||||||
const { leads } = systemuser;
|
|
||||||
|
|
||||||
$calculation.element('selectLead').setOptions(normalizeOptions(leads));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
const { data } = await apolloClient.query({
|
|
||||||
query: CRMTypes.GetOpportunitiesDocument,
|
|
||||||
variables: { domainname },
|
|
||||||
});
|
|
||||||
|
|
||||||
const systemuser = data?.systemusers?.[0];
|
|
||||||
|
|
||||||
if (systemuser) {
|
|
||||||
const { opportunities } = systemuser;
|
|
||||||
$calculation.element('selectOpportunity').setOptions(normalizeOptions(opportunities));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,6 @@ export async function getKPData({ quote }: GetQuoteInputData): Promise<GetQuoteP
|
|||||||
quoteName: quote?.evo_contact_name ?? defaultValues.quoteName,
|
quoteName: quote?.evo_contact_name ?? defaultValues.quoteName,
|
||||||
quotePriceWithFullVAT: quote?.evo_full_nds_price ?? defaultValues.quotePriceWithFullVAT,
|
quotePriceWithFullVAT: quote?.evo_full_nds_price ?? defaultValues.quotePriceWithFullVAT,
|
||||||
quoteRedemptionGraph: quote?.evo_redemption_graph ?? defaultValues.quoteRedemptionGraph,
|
quoteRedemptionGraph: quote?.evo_redemption_graph ?? defaultValues.quoteRedemptionGraph,
|
||||||
quoteShowAcceptLimit: quote?.evo_accept_limit_quote ?? defaultValues.quoteShowAcceptLimit,
|
|
||||||
registrationQuote: quote?.evo_registration_quote ?? defaultValues.registrationQuote,
|
registrationQuote: quote?.evo_registration_quote ?? defaultValues.registrationQuote,
|
||||||
showFinGAP: quote?.evo_fingap_quote ?? defaultValues.showFinGAP,
|
showFinGAP: quote?.evo_fingap_quote ?? defaultValues.showFinGAP,
|
||||||
technicalCardQuote: quote?.evo_card_quote ?? defaultValues.technicalCardQuote,
|
technicalCardQuote: quote?.evo_card_quote ?? defaultValues.technicalCardQuote,
|
||||||
|
|||||||
@ -1,37 +1,28 @@
|
|||||||
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
|
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
|
||||||
import { defaultRow } from '@/stores/tables/elt/default-values';
|
|
||||||
|
|
||||||
export async function getKPData({ quote }: GetQuoteInputData): Promise<GetQuoteProcessData> {
|
export async function getKPData({ quote }: GetQuoteInputData): Promise<GetQuoteProcessData> {
|
||||||
const elt: NonNullable<GetQuoteProcessData['elt']> = { kasko: undefined, osago: undefined };
|
const elt: NonNullable<GetQuoteProcessData['elt']> = { kasko: undefined, osago: undefined };
|
||||||
|
|
||||||
if (
|
if (
|
||||||
quote?.evo_kasko_accountid &&
|
quote?.evo_kasko_accountid &&
|
||||||
((quote?.evo_id_elt_kasko && quote?.evo_id_kasko_calc) ||
|
quote?.evo_id_elt_kasko &&
|
||||||
quote.evo_kasko_insurance_rulesidData?.evo_id) &&
|
quote?.evo_id_kasko_calc &&
|
||||||
quote?.evo_kasko_price &&
|
quote?.evo_kasko_price &&
|
||||||
quote?.evo_franchise !== null
|
quote?.evo_franchise !== null
|
||||||
) {
|
) {
|
||||||
elt.kasko = {
|
elt.kasko = {
|
||||||
insuranceCondition:
|
|
||||||
quote.evo_kasko_insurance_rulesidData?.evo_id ?? defaultRow.insuranceCondition,
|
|
||||||
key: quote?.evo_kasko_accountid,
|
key: quote?.evo_kasko_accountid,
|
||||||
requestId: quote?.evo_id_elt_kasko ?? defaultRow.requestId,
|
requestId: quote?.evo_id_elt_kasko,
|
||||||
skCalcId: quote?.evo_id_kasko_calc ?? defaultRow.skCalcId,
|
skCalcId: quote?.evo_id_kasko_calc,
|
||||||
sum: quote?.evo_kasko_price,
|
sum: quote?.evo_kasko_price,
|
||||||
totalFranchise: quote?.evo_franchise,
|
totalFranchise: quote?.evo_franchise,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (quote?.evo_osago_accountid && quote?.evo_id_elt_osago && quote?.evo_osago_price) {
|
||||||
quote?.evo_osago_accountid &&
|
|
||||||
(quote?.evo_id_elt_osago || quote.evo_osago_insurance_rulesiddData?.evo_id) &&
|
|
||||||
quote?.evo_osago_price
|
|
||||||
) {
|
|
||||||
elt.osago = {
|
elt.osago = {
|
||||||
insuranceCondition:
|
|
||||||
quote.evo_osago_insurance_rulesiddData?.evo_id ?? defaultRow.insuranceCondition,
|
|
||||||
key: quote?.evo_osago_accountid,
|
key: quote?.evo_osago_accountid,
|
||||||
numCalc: quote?.evo_id_elt_osago ?? defaultRow.numCalc,
|
numCalc: quote?.evo_id_elt_osago,
|
||||||
sum: quote?.evo_osago_price,
|
sum: quote?.evo_osago_price,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,19 +30,14 @@ export default function helper({
|
|||||||
({ evo_leasingobject_type } = data);
|
({ evo_leasingobject_type } = data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// const leaseObjectCategory = $calculation.element('selectLeaseObjectCategory').getValue();
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
kasko: (accounts
|
kasko: (accounts
|
||||||
?.filter(
|
?.filter((x) =>
|
||||||
(x) =>
|
x?.evo_type_ins_policy?.includes(100_000_000) &&
|
||||||
x?.evo_type_ins_policy?.includes(100_000_000) &&
|
evo_leasingobject_type?.evo_id &&
|
||||||
// leaseObjectCategory &&
|
['6', '9', '10'].includes(evo_leasingobject_type?.evo_id)
|
||||||
// x.evo_kasko_category?.includes(leaseObjectCategory) &&
|
? Boolean(x.evo_id_elt_smr)
|
||||||
(evo_leasingobject_type?.evo_id &&
|
: Boolean(x?.evo_id_elt)
|
||||||
['6', '9', '10'].includes(evo_leasingobject_type.evo_id)
|
|
||||||
? x?.evo_id_elt_smr
|
|
||||||
: x?.evo_id_elt)
|
|
||||||
)
|
)
|
||||||
.map((x) => ({
|
.map((x) => ({
|
||||||
...defaultRow,
|
...defaultRow,
|
||||||
@ -58,8 +53,6 @@ export default function helper({
|
|||||||
?.filter(
|
?.filter(
|
||||||
(x) =>
|
(x) =>
|
||||||
x?.evo_type_ins_policy?.includes(100_000_001) &&
|
x?.evo_type_ins_policy?.includes(100_000_001) &&
|
||||||
// leaseObjectCategory &&
|
|
||||||
// x.evo_osago_category?.includes(leaseObjectCategory) &&
|
|
||||||
(x?.evo_id_elt_osago || x.evo_osago_id)
|
(x?.evo_id_elt_osago || x.evo_osago_id)
|
||||||
)
|
)
|
||||||
.map((x) => ({
|
.map((x) => ({
|
||||||
|
|||||||
@ -1,284 +0,0 @@
|
|||||||
/* eslint-disable sonarjs/cognitive-complexity */
|
|
||||||
/* eslint-disable complexity */
|
|
||||||
import type { ownOsagoRequest } from './request';
|
|
||||||
import { getInsuranceRule } from './tools';
|
|
||||||
import type { BaseConvertResponseInput } from './types';
|
|
||||||
import type * as ELT from '@/api/elt/types';
|
|
||||||
import type { Row } from '@/Components/Calculation/Form/ELT/types';
|
|
||||||
import { MAX_FRANCHISE, MAX_INSURANCE, MIN_INSURANCE } from '@/constants/values';
|
|
||||||
import * as CRMTypes from '@/graphql/crm.types';
|
|
||||||
import { defaultRow } from '@/stores/tables/elt/default-values';
|
|
||||||
import { round } from 'tools';
|
|
||||||
|
|
||||||
type ConvertEltOsagoResponseInput = BaseConvertResponseInput & {
|
|
||||||
response: ELT.ResponseEltOsago;
|
|
||||||
};
|
|
||||||
|
|
||||||
export async function convertEltOsagoResponse(input: ConvertEltOsagoResponseInput): Promise<Row> {
|
|
||||||
const { context, response, row } = input;
|
|
||||||
const { store } = context;
|
|
||||||
|
|
||||||
const { premiumSum = 0 } = response;
|
|
||||||
let { message, numCalc, skCalcId, error } = response;
|
|
||||||
let sum = premiumSum;
|
|
||||||
|
|
||||||
const { $calculation } = store;
|
|
||||||
|
|
||||||
const cost =
|
|
||||||
$calculation.$values.getValue('plPriceRub') -
|
|
||||||
$calculation.$values.getValue('discountRub') -
|
|
||||||
$calculation.$values.getValue('importProgramSum') +
|
|
||||||
$calculation.$values.getValue('addEquipmentPrice');
|
|
||||||
|
|
||||||
const selectedRule = await getInsuranceRule(input, { cost, riskType: 'osago' });
|
|
||||||
|
|
||||||
const insuranceCondition = selectedRule?.evo_id ?? null;
|
|
||||||
|
|
||||||
if (selectedRule) {
|
|
||||||
const rule_evo_discount = selectedRule.evo_discount ?? 0;
|
|
||||||
|
|
||||||
switch (selectedRule.evo_rules_type) {
|
|
||||||
// "не выводить результат расчета"
|
|
||||||
case 100_000_000: {
|
|
||||||
sum = 0;
|
|
||||||
numCalc = Number.parseInt(defaultRow.numCalc, 2);
|
|
||||||
skCalcId = defaultRow.skCalcId;
|
|
||||||
if (selectedRule.evo_message) message = selectedRule.evo_message;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// "проверка на мин.тариф"
|
|
||||||
case 100_000_001: {
|
|
||||||
const newSum = round((sum / cost) * 100, 2);
|
|
||||||
if (newSum < rule_evo_discount) {
|
|
||||||
sum = 0;
|
|
||||||
numCalc = Number.parseInt(defaultRow.numCalc, 2);
|
|
||||||
skCalcId = defaultRow.skCalcId;
|
|
||||||
if (selectedRule.evo_message) message = selectedRule.evo_message;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// "скидка за счет КВ"
|
|
||||||
case 100_000_002: {
|
|
||||||
sum = (sum * (100 - rule_evo_discount)) / 100;
|
|
||||||
numCalc = Number.parseInt(defaultRow.numCalc, 2);
|
|
||||||
skCalcId = defaultRow.skCalcId;
|
|
||||||
if (selectedRule.evo_message) message = selectedRule.evo_message;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// "акционный тариф"
|
|
||||||
case 100_000_003: {
|
|
||||||
sum = (rule_evo_discount / 100) * cost;
|
|
||||||
numCalc = Number.parseInt(defaultRow.numCalc, 2);
|
|
||||||
skCalcId = defaultRow.skCalcId;
|
|
||||||
if (selectedRule.evo_message) message = selectedRule.evo_message;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sum > MAX_INSURANCE) {
|
|
||||||
error ||= `Сумма по страховке превышает максимально допустимое значение по стоимости ОСАГО: ${Intl.NumberFormat(
|
|
||||||
'ru',
|
|
||||||
{
|
|
||||||
currency: 'RUB',
|
|
||||||
style: 'currency',
|
|
||||||
}
|
|
||||||
).format(MAX_INSURANCE)}`;
|
|
||||||
}
|
|
||||||
if (sum < MIN_INSURANCE) {
|
|
||||||
error ||= `Сумма по страховке не должна быть меньше допустимого значения по стоимости ОСАГО: ${Intl.NumberFormat(
|
|
||||||
'ru',
|
|
||||||
{
|
|
||||||
currency: 'RUB',
|
|
||||||
style: 'currency',
|
|
||||||
}
|
|
||||||
).format(MIN_INSURANCE)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
...row,
|
|
||||||
insuranceCondition,
|
|
||||||
message: error || message,
|
|
||||||
numCalc: `${numCalc}`,
|
|
||||||
skCalcId,
|
|
||||||
status: error ? 'error' : null,
|
|
||||||
sum,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
type ResponseOwnOsago = Awaited<ReturnType<typeof ownOsagoRequest>>;
|
|
||||||
|
|
||||||
export function convertOwnOsagoResult(result: ResponseOwnOsago | undefined, row: Row): Row {
|
|
||||||
if (!result) {
|
|
||||||
return {
|
|
||||||
...row,
|
|
||||||
message:
|
|
||||||
'Для получения расчета ОСАГО следует использовать калькулятор ЭЛТ или Индивидуальный запрос',
|
|
||||||
numCalc: '',
|
|
||||||
skCalcId: '',
|
|
||||||
status: 'error',
|
|
||||||
sum: 0,
|
|
||||||
totalFranchise: 0,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!result.evo_id) {
|
|
||||||
return {
|
|
||||||
...row,
|
|
||||||
message: 'Сервер не вернул идентификатор страховки evo_id',
|
|
||||||
numCalc: '',
|
|
||||||
skCalcId: '',
|
|
||||||
status: 'error',
|
|
||||||
sum: result.evo_graph_price_withoutnds || 0,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
...row,
|
|
||||||
message: null,
|
|
||||||
numCalc: result.evo_id,
|
|
||||||
status: null,
|
|
||||||
sum: result.evo_graph_price_withoutnds || 0,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
type ConvertEltKaskoResponseInput = BaseConvertResponseInput & {
|
|
||||||
response: ELT.ResponseEltKasko;
|
|
||||||
};
|
|
||||||
|
|
||||||
export async function convertEltKaskoResponse(input: ConvertEltKaskoResponseInput): Promise<Row> {
|
|
||||||
const { context, response, row } = input;
|
|
||||||
const { apolloClient, store } = context;
|
|
||||||
|
|
||||||
const { kaskoSum = 0, paymentPeriods } = response;
|
|
||||||
let { message, requestId, skCalcId, totalFranchise = 0, error } = response;
|
|
||||||
|
|
||||||
const { $calculation } = store;
|
|
||||||
const leasingPeriod = $calculation.element('tbxLeasingPeriod').getValue();
|
|
||||||
let sum = leasingPeriod <= 16 ? kaskoSum : paymentPeriods?.[0]?.kaskoSum || 0;
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: { account: insuranceCompany },
|
|
||||||
} = await apolloClient.query({
|
|
||||||
query: CRMTypes.GetInsuranceCompanyDocument,
|
|
||||||
variables: { accountId: row.key },
|
|
||||||
});
|
|
||||||
|
|
||||||
if (
|
|
||||||
insuranceCompany?.evo_kasko_fact_part !== null &&
|
|
||||||
insuranceCompany?.evo_kasko_plan_part !== undefined &&
|
|
||||||
insuranceCompany?.evo_kasko_plan_part !== null &&
|
|
||||||
insuranceCompany?.evo_kasko_plan_part !== undefined &&
|
|
||||||
insuranceCompany?.evo_kasko_fact_part > insuranceCompany?.evo_kasko_plan_part
|
|
||||||
) {
|
|
||||||
requestId = defaultRow.requestId;
|
|
||||||
skCalcId = defaultRow.skCalcId;
|
|
||||||
sum = defaultRow.sum;
|
|
||||||
totalFranchise = defaultRow.totalFranchise;
|
|
||||||
error = 'Расчет закрыт';
|
|
||||||
}
|
|
||||||
|
|
||||||
const cost =
|
|
||||||
$calculation.$values.getValue('plPriceRub') -
|
|
||||||
$calculation.$values.getValue('discountRub') -
|
|
||||||
$calculation.$values.getValue('importProgramSum') +
|
|
||||||
$calculation.$values.getValue('addEquipmentPrice');
|
|
||||||
|
|
||||||
const selectedRule = await getInsuranceRule(input, { cost, riskType: 'kasko' });
|
|
||||||
|
|
||||||
const insuranceCondition = selectedRule?.evo_id ?? null;
|
|
||||||
|
|
||||||
if (selectedRule) {
|
|
||||||
const rule_evo_discount = selectedRule.evo_discount ?? 0;
|
|
||||||
|
|
||||||
switch (selectedRule.evo_rules_type) {
|
|
||||||
// "не выводить результат расчета"
|
|
||||||
case 100_000_000: {
|
|
||||||
sum = 0;
|
|
||||||
requestId = defaultRow.requestId;
|
|
||||||
skCalcId = defaultRow.skCalcId;
|
|
||||||
if (selectedRule.evo_message) message = selectedRule.evo_message;
|
|
||||||
totalFranchise = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// "проверка на мин.тариф"
|
|
||||||
case 100_000_001: {
|
|
||||||
const newSum = round((sum / cost) * 100, 2);
|
|
||||||
if (newSum < rule_evo_discount) {
|
|
||||||
sum = 0;
|
|
||||||
requestId = defaultRow.requestId;
|
|
||||||
skCalcId = defaultRow.skCalcId;
|
|
||||||
if (selectedRule.evo_message) message = selectedRule.evo_message;
|
|
||||||
totalFranchise = 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// "скидка за счет КВ"
|
|
||||||
case 100_000_002: {
|
|
||||||
sum = (sum * (100 - rule_evo_discount)) / 100;
|
|
||||||
requestId = defaultRow.requestId;
|
|
||||||
skCalcId = defaultRow.skCalcId;
|
|
||||||
if (selectedRule.evo_message) message = selectedRule.evo_message;
|
|
||||||
totalFranchise = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// "акционный тариф"
|
|
||||||
case 100_000_003: {
|
|
||||||
sum = (rule_evo_discount / 100) * cost;
|
|
||||||
requestId = defaultRow.requestId;
|
|
||||||
skCalcId = defaultRow.skCalcId;
|
|
||||||
if (selectedRule.evo_message) message = selectedRule.evo_message;
|
|
||||||
totalFranchise = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (totalFranchise > MAX_FRANCHISE) {
|
|
||||||
error ||= `Франшиза по страховке превышает максимально допустимое значение: ${Intl.NumberFormat(
|
|
||||||
'ru',
|
|
||||||
{
|
|
||||||
currency: 'RUB',
|
|
||||||
style: 'currency',
|
|
||||||
}
|
|
||||||
).format(MAX_FRANCHISE)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sum > MAX_INSURANCE) {
|
|
||||||
error ||= `Сумма по страховке превышает максимально допустимое значение по стоимости КАСКО: ${Intl.NumberFormat(
|
|
||||||
'ru',
|
|
||||||
{
|
|
||||||
currency: 'RUB',
|
|
||||||
style: 'currency',
|
|
||||||
}
|
|
||||||
).format(MAX_INSURANCE)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sum < MIN_INSURANCE) {
|
|
||||||
error ||= `Сумма по страховке не должна быть меньше допустимого значения по стоимости КАСКО: ${Intl.NumberFormat(
|
|
||||||
'ru',
|
|
||||||
{
|
|
||||||
currency: 'RUB',
|
|
||||||
style: 'currency',
|
|
||||||
}
|
|
||||||
).format(MIN_INSURANCE)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
...row,
|
|
||||||
insuranceCondition,
|
|
||||||
message: error || message,
|
|
||||||
numCalc: '0',
|
|
||||||
requestId,
|
|
||||||
skCalcId,
|
|
||||||
status: error ? 'error' : null,
|
|
||||||
sum,
|
|
||||||
totalFranchise,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@ -1,142 +0,0 @@
|
|||||||
/* eslint-disable sonarjs/cognitive-complexity */
|
|
||||||
/* eslint-disable complexity */
|
|
||||||
import type { BaseConvertResponseInput } from './types';
|
|
||||||
import * as CRMTypes from '@/graphql/crm.types';
|
|
||||||
import { getCurrentDateString } from '@/utils/date';
|
|
||||||
import dayjs from 'dayjs';
|
|
||||||
import { sort } from 'radash';
|
|
||||||
|
|
||||||
type GetInsuranceConditionParams = {
|
|
||||||
cost: number;
|
|
||||||
riskType: 'osago' | 'kasko';
|
|
||||||
};
|
|
||||||
|
|
||||||
type Rule =
|
|
||||||
| NonNullable<CRMTypes.GetEltInsuranceRulesQuery['evo_insurance_ruleses']>[number]
|
|
||||||
| undefined;
|
|
||||||
|
|
||||||
export async function getInsuranceRule(
|
|
||||||
input: BaseConvertResponseInput,
|
|
||||||
{ cost, riskType }: GetInsuranceConditionParams
|
|
||||||
) {
|
|
||||||
const { context, row } = input;
|
|
||||||
const { apolloClient, store } = context;
|
|
||||||
|
|
||||||
const { $calculation } = store;
|
|
||||||
const leasingPeriod = $calculation.element('tbxLeasingPeriod').getValue();
|
|
||||||
|
|
||||||
const currentDate = getCurrentDateString();
|
|
||||||
|
|
||||||
const leaseObjectCategory = $calculation.element('selectLeaseObjectCategory').getValue();
|
|
||||||
const leaseObjectYear = $calculation.element('tbxLeaseObjectYear').getValue();
|
|
||||||
const leaseObjectMotorPower = $calculation.element('tbxLeaseObjectMotorPower').getValue();
|
|
||||||
const engineType = $calculation.element('selectEngineType').getValue();
|
|
||||||
const tbxMileage = $calculation.element('tbxMileage').getValue();
|
|
||||||
const brand = $calculation.element('selectBrand').getValue();
|
|
||||||
const model = $calculation.element('selectModel').getValue();
|
|
||||||
const selectLeaseObjectUseFor = $calculation.element('selectLeaseObjectUseFor').getValue();
|
|
||||||
const legalClientRegion = $calculation.element('selectLegalClientRegion').getValue();
|
|
||||||
const dealerPerson = $calculation.element('selectDealerPerson').getValue();
|
|
||||||
const cbxLeaseObjectUsed = $calculation.element('cbxLeaseObjectUsed').getValue();
|
|
||||||
|
|
||||||
let lead: CRMTypes.GetLeadQuery['lead'] = null;
|
|
||||||
const leadid = $calculation.element('selectLead').getValue();
|
|
||||||
if (leadid) {
|
|
||||||
const { data } = await apolloClient.query({
|
|
||||||
query: CRMTypes.GetLeadDocument,
|
|
||||||
variables: { leadid },
|
|
||||||
});
|
|
||||||
({ lead } = data);
|
|
||||||
}
|
|
||||||
const insuranceOPF = lead?.evo_inn?.length === 12 ? 100_000_001 : 100_000_000;
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: { evo_insurance_ruleses },
|
|
||||||
} = await apolloClient.query({
|
|
||||||
query: CRMTypes.GetEltInsuranceRulesDocument,
|
|
||||||
variables: {
|
|
||||||
currentDate,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: { account: insuranceCompany },
|
|
||||||
} = await apolloClient.query({
|
|
||||||
query: CRMTypes.GetInsuranceCompanyDocument,
|
|
||||||
variables: { accountId: row.key },
|
|
||||||
});
|
|
||||||
|
|
||||||
const filteredRules = evo_insurance_ruleses?.filter(
|
|
||||||
(rule) =>
|
|
||||||
rule &&
|
|
||||||
rule.evo_insurer_accountid === insuranceCompany?.accountid &&
|
|
||||||
(riskType === 'kasko' ? rule.evo_risk === 100_000_000 : rule.evo_risk === 100_000_003) &&
|
|
||||||
leaseObjectCategory &&
|
|
||||||
rule.evo_category?.includes(leaseObjectCategory) &&
|
|
||||||
rule.evo_min_period !== null &&
|
|
||||||
rule.evo_max_period !== null &&
|
|
||||||
leasingPeriod !== null &&
|
|
||||||
rule.evo_min_period <= leasingPeriod &&
|
|
||||||
rule.evo_max_period >= leasingPeriod &&
|
|
||||||
(rule.evo_object_type === 100_000_000 ||
|
|
||||||
(rule.evo_object_type === 100_000_001 && cbxLeaseObjectUsed === false) ||
|
|
||||||
(rule.evo_object_type === 100_000_002 && cbxLeaseObjectUsed === true)) &&
|
|
||||||
selectLeaseObjectUseFor &&
|
|
||||||
rule.evo_use_for?.includes(selectLeaseObjectUseFor) &&
|
|
||||||
rule.evo_min_price !== null &&
|
|
||||||
rule.evo_max_price !== null &&
|
|
||||||
cost !== null &&
|
|
||||||
rule.evo_min_price <= cost &&
|
|
||||||
rule.evo_max_price >= cost &&
|
|
||||||
rule.evo_min_year !== null &&
|
|
||||||
rule.evo_max_year !== null &&
|
|
||||||
leaseObjectYear !== null &&
|
|
||||||
rule.evo_min_year <= leaseObjectYear &&
|
|
||||||
rule.evo_max_year >= leaseObjectYear &&
|
|
||||||
rule.evo_min_power !== null &&
|
|
||||||
rule.evo_max_power !== null &&
|
|
||||||
leaseObjectMotorPower !== null &&
|
|
||||||
rule.evo_min_power <= leaseObjectMotorPower &&
|
|
||||||
rule.evo_max_power >= leaseObjectMotorPower &&
|
|
||||||
engineType &&
|
|
||||||
rule.evo_enginie_type?.includes(engineType) &&
|
|
||||||
rule.evo_opf === insuranceOPF &&
|
|
||||||
rule.evo_min_mileage !== null &&
|
|
||||||
rule.evo_max_mileage !== null &&
|
|
||||||
tbxMileage !== null &&
|
|
||||||
rule.evo_min_mileage <= tbxMileage &&
|
|
||||||
rule.evo_max_mileage >= tbxMileage &&
|
|
||||||
(rule.evo_brand === 100_000_000 ||
|
|
||||||
(rule.evo_brand === 100_000_001 &&
|
|
||||||
rule.evo_brands?.some((x) => x?.evo_brandid === brand)) ||
|
|
||||||
(rule.evo_brand === 100_000_002 &&
|
|
||||||
!rule.evo_brands?.some((x) => x?.evo_brandid === brand))) &&
|
|
||||||
(rule.evo_model === 100_000_000 ||
|
|
||||||
(rule.evo_model === 100_000_001 &&
|
|
||||||
rule.evo_models?.some((x) => x?.evo_modelid === model)) ||
|
|
||||||
(rule.evo_model === 100_000_002 &&
|
|
||||||
!rule.evo_models?.some((x) => x?.evo_modelid === model))) &&
|
|
||||||
(rule.evo_region === 100_000_000 ||
|
|
||||||
(rule.evo_region === 100_000_001 &&
|
|
||||||
rule.evo_regions?.some((x) => x?.evo_regionid === legalClientRegion)) ||
|
|
||||||
(rule.evo_region === 100_000_002 &&
|
|
||||||
!rule.evo_regions?.some((x) => x?.evo_regionid === legalClientRegion))) &&
|
|
||||||
(rule.evo_dealer === 100_000_000 ||
|
|
||||||
(rule.evo_dealer === 100_000_001 &&
|
|
||||||
rule.accounts?.some((x) => x?.accountid === dealerPerson)) ||
|
|
||||||
(rule.evo_dealer === 100_000_002 &&
|
|
||||||
!rule.accounts?.some((x) => x?.accountid === dealerPerson)))
|
|
||||||
);
|
|
||||||
|
|
||||||
// Обработка найденных записей по приоритету
|
|
||||||
const sortedRules = filteredRules
|
|
||||||
? sort(filteredRules, (x) => dayjs(x?.evo_datefrom).date(), true)
|
|
||||||
: [];
|
|
||||||
|
|
||||||
const priorities = [100_000_000, 100_000_003, 100_000_001, 100_000_002];
|
|
||||||
|
|
||||||
return priorities.reduce(
|
|
||||||
(found, priority) => found || sortedRules.find((rule) => rule?.evo_rules_type === priority),
|
|
||||||
null as Rule
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
import type { Row } from '@/Components/Calculation/Form/ELT/types';
|
|
||||||
import type { ProcessContext } from '@/process/types';
|
|
||||||
|
|
||||||
export type BaseConvertResponseInput = {
|
|
||||||
context: Pick<ProcessContext, 'apolloClient' | 'store'>;
|
|
||||||
row: Row;
|
|
||||||
};
|
|
||||||
@ -259,8 +259,6 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let okved: string | null | undefined;
|
let okved: string | null | undefined;
|
||||||
let evo_inn: string | null | undefined;
|
|
||||||
|
|
||||||
if (leadid) {
|
if (leadid) {
|
||||||
const {
|
const {
|
||||||
data: { lead },
|
data: { lead },
|
||||||
@ -270,7 +268,6 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
okved = lead?.accountidData?.evo_okved;
|
okved = lead?.accountidData?.evo_okved;
|
||||||
evo_inn = lead?.evo_inn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!okved && opportunityid) {
|
if (!okved && opportunityid) {
|
||||||
@ -305,14 +302,6 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
|||||||
path: ['eltKasko', 'eltOsago'],
|
path: ['eltKasko', 'eltOsago'],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!evo_inn) {
|
|
||||||
ctx.addIssue({
|
|
||||||
code: z.ZodIssueCode.custom,
|
|
||||||
message: 'ИНН в интересе не заполнен',
|
|
||||||
path: ['eltKasko', 'eltOsago'],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,17 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||||
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
|
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
|
||||||
import helper from './lib/helper';
|
import helper from './lib/helper';
|
||||||
|
import initializeApollo from '@/apollo/client';
|
||||||
import defaultValues from '@/config/default-values';
|
import defaultValues from '@/config/default-values';
|
||||||
import { getKPData as getKPDataPayments } from '@/process/payments/get-kp-data';
|
import { getKPData as getKPDataPayments } from '@/process/payments/get-kp-data';
|
||||||
import { getKPData as getKPDataPrice } from '@/process/price/get-kp-data';
|
import { getKPData as getKPDataPrice } from '@/process/price/get-kp-data';
|
||||||
import { createCurrencyUtility } from '@/utils/currency';
|
import { createCurrencyUtility } from '@/utils/currency';
|
||||||
|
import { QueryClient } from '@tanstack/react-query';
|
||||||
|
|
||||||
export async function getKPData({
|
export async function getKPData({
|
||||||
quote,
|
quote,
|
||||||
values,
|
values,
|
||||||
ctx,
|
|
||||||
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
|
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
|
||||||
const { apolloClient, queryClient } = ctx;
|
|
||||||
|
|
||||||
if (!quote?.evo_fingap_accountid) {
|
if (!quote?.evo_fingap_accountid) {
|
||||||
return {
|
return {
|
||||||
fingap: {
|
fingap: {
|
||||||
@ -22,10 +21,13 @@ export async function getKPData({
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const apolloClient = initializeApollo();
|
||||||
|
const queryClient = new QueryClient();
|
||||||
|
|
||||||
const { getFingapRisks } = helper({ apolloClient, queryClient });
|
const { getFingapRisks } = helper({ apolloClient, queryClient });
|
||||||
|
|
||||||
const kpDataPrice = await getKPDataPrice({ ctx, quote, values });
|
const kpDataPrice = await getKPDataPrice({ quote, values });
|
||||||
const kpDataPayments = await getKPDataPayments({ ctx, quote, values });
|
const kpDataPayments = await getKPDataPayments({ quote, values });
|
||||||
|
|
||||||
const leaseObjectPrice = kpDataPrice.values?.leaseObjectPrice ?? defaultValues.leaseObjectPrice;
|
const leaseObjectPrice = kpDataPrice.values?.leaseObjectPrice ?? defaultValues.leaseObjectPrice;
|
||||||
const firstPaymentRub = kpDataPrice.values?.firstPaymentRub ?? defaultValues.firstPaymentRub;
|
const firstPaymentRub = kpDataPrice.values?.firstPaymentRub ?? defaultValues.firstPaymentRub;
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { STALE_TIME } from '@/constants/request';
|
|||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import type { ProcessContext } from '@/process/types';
|
import type { ProcessContext } from '@/process/types';
|
||||||
import type { CalculationValues } from '@/stores/calculation/values/types';
|
import type { CalculationValues } from '@/stores/calculation/values/types';
|
||||||
import { getCurrentDateString } from '@/utils/date';
|
import { getCurrentISODate } from '@/utils/date';
|
||||||
import type { QueryFunctionContext } from '@tanstack/react-query';
|
import type { QueryFunctionContext } from '@tanstack/react-query';
|
||||||
import { flatten } from 'tools/object';
|
import { flatten } from 'tools/object';
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ export default function helper({
|
|||||||
} = await apolloClient.query({
|
} = await apolloClient.query({
|
||||||
query: CRMTypes.GetAddproductTypesDocument,
|
query: CRMTypes.GetAddproductTypesDocument,
|
||||||
variables: {
|
variables: {
|
||||||
currentDate: getCurrentDateString(),
|
currentDate: getCurrentISODate(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,15 +1,17 @@
|
|||||||
/* eslint-disable sonarjs/cognitive-complexity */
|
/* eslint-disable sonarjs/cognitive-complexity */
|
||||||
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
|
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
|
||||||
import helper from './lib/helper';
|
import helper from './lib/helper';
|
||||||
|
import initializeApollo from '@/apollo/client';
|
||||||
import defaultValues from '@/config/default-values';
|
import defaultValues from '@/config/default-values';
|
||||||
|
|
||||||
export async function getKPData({
|
export async function getKPData({
|
||||||
values,
|
values,
|
||||||
quote,
|
quote,
|
||||||
ctx: { apolloClient },
|
|
||||||
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
|
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
|
||||||
const { recalcWithRevision, lead: leadId, opportunity: opportunityId } = values;
|
const { recalcWithRevision, lead: leadId, opportunity: opportunityId } = values;
|
||||||
|
|
||||||
|
const apolloClient = initializeApollo();
|
||||||
|
|
||||||
const { getData } = helper({
|
const { getData } = helper({
|
||||||
apolloClient,
|
apolloClient,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -6,9 +6,10 @@ import { getTransTax } from '@/api/1c/query';
|
|||||||
import { selectObjectCategoryTax } from '@/config/default-options';
|
import { selectObjectCategoryTax } from '@/config/default-options';
|
||||||
import { STALE_TIME } from '@/constants/request';
|
import { STALE_TIME } from '@/constants/request';
|
||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import { getCurrentDateString } from '@/utils/date';
|
import { getCurrentISODate } from '@/utils/date';
|
||||||
import { normalizeOptions } from '@/utils/entity';
|
import { normalizeOptions } from '@/utils/entity';
|
||||||
import { disposableReaction } from '@/utils/mobx';
|
import { disposableReaction } from '@/utils/mobx';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
import { reaction } from 'mobx';
|
import { reaction } from 'mobx';
|
||||||
|
|
||||||
export function common({ store, apolloClient, queryClient }: ProcessContext) {
|
export function common({ store, apolloClient, queryClient }: ProcessContext) {
|
||||||
@ -185,16 +186,18 @@ export function common({ store, apolloClient, queryClient }: ProcessContext) {
|
|||||||
const carCategory = getCarCategory(objectTypeTax);
|
const carCategory = getCarCategory(objectTypeTax);
|
||||||
|
|
||||||
if (OKTMO) {
|
if (OKTMO) {
|
||||||
|
const currentDate = dayjs().utc(false).toDate();
|
||||||
|
|
||||||
const response = await queryClient.fetchQuery(
|
const response = await queryClient.fetchQuery(
|
||||||
['1c', 'trans-tax', carCategory, leaseObjectMotorPower, leaseObjectYear, OKTMO],
|
['1c', 'trans-tax', carCategory, leaseObjectMotorPower, leaseObjectYear],
|
||||||
(context) =>
|
(context) =>
|
||||||
getTransTax(
|
getTransTax(
|
||||||
{
|
{
|
||||||
CalcDate: getCurrentDateString(),
|
|
||||||
CarCategory: carCategory,
|
|
||||||
OKTMO,
|
OKTMO,
|
||||||
Power: leaseObjectMotorPower,
|
calcDate: currentDate,
|
||||||
Year: leaseObjectYear,
|
carCategory,
|
||||||
|
power: leaseObjectMotorPower,
|
||||||
|
year: leaseObjectYear,
|
||||||
},
|
},
|
||||||
context
|
context
|
||||||
),
|
),
|
||||||
@ -203,8 +206,8 @@ export function common({ store, apolloClient, queryClient }: ProcessContext) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response?.Tax) {
|
if (response?.tax) {
|
||||||
$calculation.element('tbxVehicleTaxInYear').setValue(response.Tax);
|
$calculation.element('tbxVehicleTaxInYear').setValue(response.tax);
|
||||||
} else {
|
} else {
|
||||||
$calculation.element('tbxVehicleTaxInYear').resetValue();
|
$calculation.element('tbxVehicleTaxInYear').resetValue();
|
||||||
}
|
}
|
||||||
@ -247,7 +250,7 @@ export function common({ store, apolloClient, queryClient }: ProcessContext) {
|
|||||||
data: { evo_addproduct_types },
|
data: { evo_addproduct_types },
|
||||||
} = await apolloClient.query({
|
} = await apolloClient.query({
|
||||||
query: CRMTypes.GetRegistrationTypesDocument,
|
query: CRMTypes.GetRegistrationTypesDocument,
|
||||||
variables: { currentDate: getCurrentDateString() },
|
variables: { currentDate: getCurrentISODate() },
|
||||||
});
|
});
|
||||||
|
|
||||||
const options = evo_addproduct_types?.filter((x) => {
|
const options = evo_addproduct_types?.filter((x) => {
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { STALE_TIME } from '@/constants/request';
|
|||||||
import { crmTools } from '@/graphql/crm.tools';
|
import { crmTools } from '@/graphql/crm.tools';
|
||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import { useStore } from '@/stores/hooks';
|
import { useStore } from '@/stores/hooks';
|
||||||
import { getCurrentDateString } from '@/utils/date';
|
import { getCurrentISODate } from '@/utils/date';
|
||||||
import { normalizeOptions } from '@/utils/entity';
|
import { normalizeOptions } from '@/utils/entity';
|
||||||
import { useApolloClient } from '@apollo/client';
|
import { useApolloClient } from '@apollo/client';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
@ -16,34 +16,24 @@ import { useEffect } from 'react';
|
|||||||
* @param {*} onCompleted
|
* @param {*} onCompleted
|
||||||
*/
|
*/
|
||||||
function getMainData({ query }, onCompleted, user) {
|
function getMainData({ query }, onCompleted, user) {
|
||||||
const currentDate = getCurrentDateString();
|
const currentDate = getCurrentISODate();
|
||||||
|
|
||||||
query({
|
query({
|
||||||
query: CRMTypes.GetLeadsDocument,
|
query: CRMTypes.GetLeadsDocument,
|
||||||
variables: { domainname: user.domainName },
|
variables: { domainname: user.domainName },
|
||||||
}).then(({ data }) => {
|
}).then(({ data }) => {
|
||||||
const systemuser = data?.systemusers?.[0];
|
onCompleted({
|
||||||
|
selectLead: data?.leads,
|
||||||
if (systemuser) {
|
});
|
||||||
const { leads } = systemuser;
|
|
||||||
onCompleted({
|
|
||||||
selectLead: leads,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
query({
|
query({
|
||||||
query: CRMTypes.GetOpportunitiesDocument,
|
query: CRMTypes.GetOpportunitiesDocument,
|
||||||
variables: { domainname: user.domainName },
|
variables: { domainname: user.domainName },
|
||||||
}).then(({ data }) => {
|
}).then(({ data }) => {
|
||||||
const systemuser = data?.systemusers?.[0];
|
onCompleted({
|
||||||
|
selectOpportunity: data?.opportunities,
|
||||||
if (systemuser) {
|
});
|
||||||
const { opportunities } = systemuser;
|
|
||||||
onCompleted({
|
|
||||||
selectOpportunity: opportunities,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
query({ query: CRMTypes.GetTransactionCurrenciesDocument }).then(({ data }) => {
|
query({ query: CRMTypes.GetTransactionCurrenciesDocument }).then(({ data }) => {
|
||||||
@ -56,22 +46,16 @@ function getMainData({ query }, onCompleted, user) {
|
|||||||
fetchPolicy: 'network-only',
|
fetchPolicy: 'network-only',
|
||||||
query: CRMTypes.GetSystemUserDocument,
|
query: CRMTypes.GetSystemUserDocument,
|
||||||
variables: { domainname: user?.domainName },
|
variables: { domainname: user?.domainName },
|
||||||
}).then(({ data: { systemusers } }) => {
|
}).then(({ data: { systemuser } }) => {
|
||||||
const systemuser = systemusers?.[0];
|
query({
|
||||||
|
fetchPolicy: 'network-only',
|
||||||
if (systemuser) {
|
query: CRMTypes.GetProductsDocument,
|
||||||
query({
|
variables: { currentDate },
|
||||||
fetchPolicy: 'network-only',
|
}).then(({ data: { evo_baseproducts } }) => {
|
||||||
query: CRMTypes.GetProductsDocument,
|
onCompleted({
|
||||||
variables: { currentDate },
|
selectProduct: crmTools.evo_baseproducts(evo_baseproducts).filterBy.systemuser(systemuser),
|
||||||
}).then(({ data: { evo_baseproducts } }) => {
|
|
||||||
onCompleted({
|
|
||||||
selectProduct: crmTools
|
|
||||||
.evo_baseproducts(evo_baseproducts)
|
|
||||||
.filterBy.systemuser(systemuser),
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// query({
|
// query({
|
||||||
|
|||||||
@ -11,9 +11,8 @@ import { sum } from 'radash';
|
|||||||
export async function getKPData({
|
export async function getKPData({
|
||||||
values,
|
values,
|
||||||
quote,
|
quote,
|
||||||
ctx,
|
|
||||||
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
|
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
|
||||||
const kpDataFingap = await getKPDataFingap({ ctx, quote, values });
|
const kpDataFingap = await getKPDataFingap({ quote, values });
|
||||||
|
|
||||||
const risks = kpDataFingap.fingap?.risks;
|
const risks = kpDataFingap.fingap?.risks;
|
||||||
|
|
||||||
|
|||||||
@ -207,7 +207,6 @@ export function common({ store, apolloClient }: ProcessContext) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// объединить со строчкой 308
|
|
||||||
debouncedReaction(
|
debouncedReaction(
|
||||||
() => $calculation.$values.getValues(['leaseObjectCategory', 'leasingWithoutKasko']),
|
() => $calculation.$values.getValues(['leaseObjectCategory', 'leasingWithoutKasko']),
|
||||||
async ({ leaseObjectCategory, leasingWithoutKasko }) => {
|
async ({ leaseObjectCategory, leasingWithoutKasko }) => {
|
||||||
@ -304,70 +303,6 @@ export function common({ store, apolloClient }: ProcessContext) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// объединить со строчкой 210
|
|
||||||
reaction(
|
|
||||||
() => $calculation.$values.getValues(['leaseObjectType', 'maxSpeed']),
|
|
||||||
async ({ leaseObjectType: leaseObjectTypeId, maxSpeed }) => {
|
|
||||||
if (!leaseObjectTypeId) {
|
|
||||||
$tables.insurance.row('osago').column('insuranceCompany').unblock();
|
|
||||||
$tables.insurance.row('osago').column('insured').unblock();
|
|
||||||
$tables.insurance.row('osago').column('insCost').unblock();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: { evo_leasingobject_type },
|
|
||||||
} = await apolloClient.query({
|
|
||||||
query: CRMTypes.GetLeaseObjectTypeDocument,
|
|
||||||
variables: {
|
|
||||||
leaseObjectTypeId,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: { accounts },
|
|
||||||
} = await apolloClient.query({
|
|
||||||
query: CRMTypes.GetInsuranceCompaniesDocument,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (
|
|
||||||
evo_leasingobject_type?.evo_id &&
|
|
||||||
['9', '6', '10'].includes(evo_leasingobject_type.evo_id) &&
|
|
||||||
maxSpeed < 20
|
|
||||||
) {
|
|
||||||
const otherInsuranceCompany = accounts?.find(
|
|
||||||
(x) => x?.evo_type_ins_policy === null && x.label?.includes('ПРОЧИЕ')
|
|
||||||
);
|
|
||||||
|
|
||||||
if (otherInsuranceCompany) {
|
|
||||||
$tables.insurance
|
|
||||||
.row('osago')
|
|
||||||
.column('insuranceCompany')
|
|
||||||
.setOptions(normalizeOptions([otherInsuranceCompany]))
|
|
||||||
.setValue(otherInsuranceCompany.value)
|
|
||||||
.block();
|
|
||||||
}
|
|
||||||
|
|
||||||
$tables.insurance.row('osago').column('insured').setValue(100_000_000).block();
|
|
||||||
$tables.insurance.row('osago').column('insCost').setValue(0).block();
|
|
||||||
} else {
|
|
||||||
const defaultOsagoOptions = accounts?.filter((x) =>
|
|
||||||
x?.evo_type_ins_policy?.includes(100_000_001)
|
|
||||||
);
|
|
||||||
|
|
||||||
$tables.insurance
|
|
||||||
.row('osago')
|
|
||||||
.column('insuranceCompany')
|
|
||||||
.setOptions(normalizeOptions(defaultOsagoOptions))
|
|
||||||
.unblock();
|
|
||||||
|
|
||||||
$tables.insurance.row('osago').column('insured').unblock();
|
|
||||||
$tables.insurance.row('osago').column('insCost').unblock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const validation = createValidationReaction(createValidationSchema);
|
export const validation = createValidationReaction(createValidationSchema);
|
||||||
|
|||||||
@ -16,7 +16,6 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
|||||||
leaseObjectType: true,
|
leaseObjectType: true,
|
||||||
leasingPeriod: true,
|
leasingPeriod: true,
|
||||||
leasingWithoutKasko: true,
|
leasingWithoutKasko: true,
|
||||||
maxSpeed: true,
|
|
||||||
partialVAT: true,
|
partialVAT: true,
|
||||||
plPriceRub: true,
|
plPriceRub: true,
|
||||||
product: true,
|
product: true,
|
||||||
@ -43,7 +42,6 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
|||||||
leaseObjectType: leaseObjectTypeId,
|
leaseObjectType: leaseObjectTypeId,
|
||||||
firstPaymentPerc,
|
firstPaymentPerc,
|
||||||
plPriceRub,
|
plPriceRub,
|
||||||
maxSpeed,
|
|
||||||
},
|
},
|
||||||
ctx
|
ctx
|
||||||
) => {
|
) => {
|
||||||
@ -253,19 +251,6 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
|||||||
path: ['tbxLeaseObjectPrice'],
|
path: ['tbxLeaseObjectPrice'],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
|
||||||
evo_leasingobject_type?.evo_id &&
|
|
||||||
['9', '6', '10'].includes(evo_leasingobject_type?.evo_id) &&
|
|
||||||
maxSpeed < 20 &&
|
|
||||||
insurance.values.osago.insured === 100_000_001
|
|
||||||
) {
|
|
||||||
ctx.addIssue({
|
|
||||||
code: z.ZodIssueCode.custom,
|
|
||||||
message: 'Нельзя включать в график ОСАГО по Спецтехнике, т.к. полис не требуется',
|
|
||||||
path: ['insurance'],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,14 @@
|
|||||||
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
|
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
|
||||||
import helper from './lib/helper';
|
import helper from './lib/helper';
|
||||||
|
import initializeApollo from '@/apollo/client';
|
||||||
import defaultValues from '@/config/default-values';
|
import defaultValues from '@/config/default-values';
|
||||||
|
|
||||||
export async function getKPData({
|
export async function getKPData({
|
||||||
values: { recalcWithRevision },
|
values: { recalcWithRevision },
|
||||||
quote,
|
quote,
|
||||||
ctx: { apolloClient },
|
|
||||||
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
|
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
|
||||||
|
const apolloClient = initializeApollo();
|
||||||
|
|
||||||
const brand = quote?.evo_brandid ?? defaultValues.brand;
|
const brand = quote?.evo_brandid ?? defaultValues.brand;
|
||||||
const model = quote?.evo_modelid ?? defaultValues.model;
|
const model = quote?.evo_modelid ?? defaultValues.model;
|
||||||
const leaseObjectUsed = quote?.evo_leasingobject_used ?? defaultValues.leaseObjectUsed;
|
const leaseObjectUsed = quote?.evo_leasingobject_used ?? defaultValues.leaseObjectUsed;
|
||||||
|
|||||||
@ -17,7 +17,6 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
|||||||
leaseObjectType: true,
|
leaseObjectType: true,
|
||||||
leaseObjectUseFor: true,
|
leaseObjectUseFor: true,
|
||||||
maxMass: true,
|
maxMass: true,
|
||||||
maxSpeed: true,
|
|
||||||
model: true,
|
model: true,
|
||||||
}).superRefine(
|
}).superRefine(
|
||||||
async (
|
async (
|
||||||
@ -33,7 +32,6 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
|||||||
model: modelId,
|
model: modelId,
|
||||||
leaseObjectUseFor,
|
leaseObjectUseFor,
|
||||||
configuration,
|
configuration,
|
||||||
maxSpeed,
|
|
||||||
},
|
},
|
||||||
ctx
|
ctx
|
||||||
) => {
|
) => {
|
||||||
@ -136,21 +134,21 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evo_leasingobject_type?.evo_id === '1' && (countSeats <= 0 || countSeats > 9)) {
|
if (evo_leasingobject_type?.evo_id === '1' && countSeats >= 9) {
|
||||||
ctx.addIssue({
|
ctx.addIssue({
|
||||||
code: z.ZodIssueCode.custom,
|
code: z.ZodIssueCode.custom,
|
||||||
message: 'Количество мест должно быть от 0 до 9',
|
message: 'Количество мест должно быть меньше 9',
|
||||||
path: ['tbxCountSeats'],
|
path: ['tbxCountSeats'],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(evo_leasingobject_type?.evo_id === '4' || evo_leasingobject_type?.evo_id === '5') &&
|
(evo_leasingobject_type?.evo_id === '4' || evo_leasingobject_type?.evo_id === '5') &&
|
||||||
countSeats <= 9
|
countSeats <= 8
|
||||||
) {
|
) {
|
||||||
ctx.addIssue({
|
ctx.addIssue({
|
||||||
code: z.ZodIssueCode.custom,
|
code: z.ZodIssueCode.custom,
|
||||||
message: 'Количество мест должно быть не меньше 9',
|
message: 'Количество мест должно быть больше 8',
|
||||||
path: ['tbxCountSeats'],
|
path: ['tbxCountSeats'],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -176,18 +174,6 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
|||||||
path: ['selectLeaseObjectCategory'],
|
path: ['selectLeaseObjectCategory'],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
|
||||||
evo_leasingobject_type?.evo_id &&
|
|
||||||
['6', '9', '10'].includes(evo_leasingobject_type?.evo_id) &&
|
|
||||||
!maxSpeed
|
|
||||||
) {
|
|
||||||
ctx.addIssue({
|
|
||||||
code: z.ZodIssueCode.custom,
|
|
||||||
message: 'Не заполнено поле',
|
|
||||||
path: ['tbxMaxSpeed'],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
import { notification } from '@/Components/Common/Notification';
|
import { notification } from '@/Components/Common/Notification';
|
||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import type { ProcessContext } from '@/process/types';
|
import type { ProcessContext } from '@/process/types';
|
||||||
import { getCurrentDateString } from '@/utils/date';
|
import { getCurrentISODate } from '@/utils/date';
|
||||||
import { normalizeOptions } from '@/utils/entity';
|
import { normalizeOptions } from '@/utils/entity';
|
||||||
import { reaction } from 'mobx';
|
import { reaction } from 'mobx';
|
||||||
import { uid } from 'radash';
|
import { uid } from 'radash';
|
||||||
@ -64,7 +64,7 @@ export function common({ store, apolloClient }: ProcessContext) {
|
|||||||
firstPaymentPerc,
|
firstPaymentPerc,
|
||||||
model: modelId,
|
model: modelId,
|
||||||
}) => {
|
}) => {
|
||||||
const currentDate = getCurrentDateString();
|
const currentDate = getCurrentISODate();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: { evo_addproduct_types },
|
data: { evo_addproduct_types },
|
||||||
|
|||||||
@ -15,7 +15,7 @@ export function common({ store, trpcClient, apolloClient }: ProcessContext) {
|
|||||||
|
|
||||||
reaction(
|
reaction(
|
||||||
() => $calculation.$values.getValue('quote'),
|
() => $calculation.$values.getValue('quote'),
|
||||||
() => {
|
async () => {
|
||||||
const quote = $calculation.element('selectQuote').getOption();
|
const quote = $calculation.element('selectQuote').getOption();
|
||||||
|
|
||||||
if (!quote || $process.has('LoadKP') || $process.has('Calculate') || $process.has('CreateKP'))
|
if (!quote || $process.has('LoadKP') || $process.has('Calculate') || $process.has('CreateKP'))
|
||||||
@ -29,6 +29,8 @@ export function common({ store, trpcClient, apolloClient }: ProcessContext) {
|
|||||||
onClick: () => message.destroy(key),
|
onClick: () => message.destroy(key),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const eltInitialValues = await initElt();
|
||||||
|
|
||||||
trpcClient.getQuote
|
trpcClient.getQuote
|
||||||
.query({
|
.query({
|
||||||
values: {
|
values: {
|
||||||
@ -36,7 +38,7 @@ export function common({ store, trpcClient, apolloClient }: ProcessContext) {
|
|||||||
...$calculation.$values.getValues(['lead', 'opportunity', 'recalcWithRevision']),
|
...$calculation.$values.getValues(['lead', 'opportunity', 'recalcWithRevision']),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then(async ({ values, payments, insurance, fingap, elt, options }) => {
|
.then(({ values, payments, insurance, fingap, elt, options }) => {
|
||||||
if (options?.selectTarif) {
|
if (options?.selectTarif) {
|
||||||
$calculation.element('selectTarif').setOptions(normalizeOptions(options.selectTarif));
|
$calculation.element('selectTarif').setOptions(normalizeOptions(options.selectTarif));
|
||||||
} else {
|
} else {
|
||||||
@ -74,7 +76,6 @@ export function common({ store, trpcClient, apolloClient }: ProcessContext) {
|
|||||||
$tables.fingap.setRisks(fingap.risks);
|
$tables.fingap.setRisks(fingap.risks);
|
||||||
$tables.fingap.setSelectedKeys(fingap.keys);
|
$tables.fingap.setSelectedKeys(fingap.keys);
|
||||||
}
|
}
|
||||||
const eltInitialValues = await initElt();
|
|
||||||
|
|
||||||
if (eltInitialValues) {
|
if (eltInitialValues) {
|
||||||
$tables.elt.kasko.setRows(eltInitialValues.kasko);
|
$tables.elt.kasko.setRows(eltInitialValues.kasko);
|
||||||
|
|||||||
@ -86,7 +86,7 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
|||||||
|
|
||||||
if (dealerPersonId && quoteId && productId) {
|
if (dealerPersonId && quoteId && productId) {
|
||||||
const {
|
const {
|
||||||
data: { dealer_person },
|
data: { account: dealerPerson },
|
||||||
} = await apolloClient.query({
|
} = await apolloClient.query({
|
||||||
query: CRMTypes.GetDealerPersonDocument,
|
query: CRMTypes.GetDealerPersonDocument,
|
||||||
variables: { dealerPersonId },
|
variables: { dealerPersonId },
|
||||||
@ -101,7 +101,7 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
|||||||
|
|
||||||
const maxCondition1 =
|
const maxCondition1 =
|
||||||
leaseObjectUsed === false &&
|
leaseObjectUsed === false &&
|
||||||
dealer_person?.evo_supplier_type !== 100_000_001 &&
|
dealerPerson?.evo_supplier_type !== 100_000_001 &&
|
||||||
quote?.evo_max_price_change &&
|
quote?.evo_max_price_change &&
|
||||||
!partialVAT &&
|
!partialVAT &&
|
||||||
plPriceRub - discountRub + addEquipmentPrice - importProgramSum >
|
plPriceRub - discountRub + addEquipmentPrice - importProgramSum >
|
||||||
@ -109,14 +109,14 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
|||||||
|
|
||||||
const maxCondition2 =
|
const maxCondition2 =
|
||||||
leaseObjectUsed === false &&
|
leaseObjectUsed === false &&
|
||||||
dealer_person?.evo_supplier_type !== 100_000_001 &&
|
dealerPerson?.evo_supplier_type !== 100_000_001 &&
|
||||||
quote?.evo_max_price_change &&
|
quote?.evo_max_price_change &&
|
||||||
partialVAT &&
|
partialVAT &&
|
||||||
leaseObjectPriceWthtVAT >
|
leaseObjectPriceWthtVAT >
|
||||||
quote.evo_max_price_change - (quote.evo_nds_in_price_supplier_currency || 0);
|
quote.evo_max_price_change - (quote.evo_nds_in_price_supplier_currency || 0);
|
||||||
|
|
||||||
const maxCondition3 =
|
const maxCondition3 =
|
||||||
(leaseObjectUsed === true || dealer_person?.evo_supplier_type === 100_000_001) &&
|
(leaseObjectUsed === true || dealerPerson?.evo_supplier_type === 100_000_001) &&
|
||||||
quote?.evo_supplier_currency_price &&
|
quote?.evo_supplier_currency_price &&
|
||||||
plPriceRub - discountRub + addEquipmentPrice - importProgramSum >
|
plPriceRub - discountRub + addEquipmentPrice - importProgramSum >
|
||||||
quote.evo_supplier_currency_price -
|
quote.evo_supplier_currency_price -
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
|
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
|
||||||
import helper from './lib/helper';
|
import helper from './lib/helper';
|
||||||
|
import initializeApollo from '@/apollo/client';
|
||||||
import defaultValues from '@/config/default-values';
|
import defaultValues from '@/config/default-values';
|
||||||
import { getKPData as getKPDataPrice } from '@/process/price/get-kp-data';
|
import { getKPData as getKPDataPrice } from '@/process/price/get-kp-data';
|
||||||
import { createCurrencyUtility } from '@/utils/currency';
|
import { createCurrencyUtility } from '@/utils/currency';
|
||||||
@ -7,11 +8,10 @@ import { createCurrencyUtility } from '@/utils/currency';
|
|||||||
export async function getKPData({
|
export async function getKPData({
|
||||||
values,
|
values,
|
||||||
quote,
|
quote,
|
||||||
ctx,
|
|
||||||
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
|
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
|
||||||
const { apolloClient } = ctx;
|
const apolloClient = initializeApollo();
|
||||||
|
|
||||||
const kpDataPrice = await getKPDataPrice({ ctx, quote, values });
|
const kpDataPrice = await getKPDataPrice({ quote, values });
|
||||||
const { RUB } = createCurrencyUtility({ apolloClient });
|
const { RUB } = createCurrencyUtility({ apolloClient });
|
||||||
|
|
||||||
const supplierCurrency = kpDataPrice.values?.supplierCurrency ?? defaultValues.supplierCurrency;
|
const supplierCurrency = kpDataPrice.values?.supplierCurrency ?? defaultValues.supplierCurrency;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
|
import initializeApollo from '@/apollo/client';
|
||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import type { GetQuoteContext } from '@/server/routers/quote/types';
|
|
||||||
|
|
||||||
type Quote = NonNullable<CRMTypes.GetQuoteDataQuery['quote']>;
|
type Quote = NonNullable<CRMTypes.GetQuoteDataQuery['quote']>;
|
||||||
|
|
||||||
@ -19,42 +19,39 @@ type QuoteTotalFields =
|
|||||||
| 'evo_double_agent_reward_total'
|
| 'evo_double_agent_reward_total'
|
||||||
| 'evo_fin_department_reward_total';
|
| 'evo_fin_department_reward_total';
|
||||||
|
|
||||||
function makeGetRewardSum({ apolloClient }: GetQuoteContext) {
|
async function getRewardSum(
|
||||||
return async function (
|
conditionId: string | null | undefined,
|
||||||
conditionId: string | null | undefined,
|
quote: Quote,
|
||||||
quote: Quote,
|
quoteRewardSummField: keyof Pick<Quote, QuoteSumFields>,
|
||||||
quoteRewardSummField: keyof Pick<Quote, QuoteSumFields>,
|
quoteRewardTotalField: keyof Pick<Quote, QuoteTotalFields>
|
||||||
quoteRewardTotalField: keyof Pick<Quote, QuoteTotalFields>
|
) {
|
||||||
) {
|
if (!conditionId) return 0;
|
||||||
if (!conditionId) return 0;
|
|
||||||
|
|
||||||
const {
|
const apolloClient = initializeApollo();
|
||||||
data: { evo_reward_condition },
|
const {
|
||||||
} = await apolloClient.query<
|
data: { evo_reward_condition },
|
||||||
CRMTypes.GetRewardConditionQuery,
|
} = await apolloClient.query<
|
||||||
CRMTypes.GetRewardConditionQueryVariables
|
CRMTypes.GetRewardConditionQuery,
|
||||||
>({
|
CRMTypes.GetRewardConditionQueryVariables
|
||||||
query: CRMTypes.GetRewardConditionDocument,
|
>({
|
||||||
variables: {
|
query: CRMTypes.GetRewardConditionDocument,
|
||||||
conditionId,
|
variables: {
|
||||||
},
|
conditionId,
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
|
||||||
if (evo_reward_condition?.evo_calc_reward_rules === 100_000_001) {
|
if (evo_reward_condition?.evo_calc_reward_rules === 100_000_001) {
|
||||||
return quote[quoteRewardSummField];
|
return quote[quoteRewardSummField];
|
||||||
}
|
}
|
||||||
|
|
||||||
return quote[quoteRewardTotalField];
|
return quote[quoteRewardTotalField];
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function getSums(quote: Quote | null, ctx: GetQuoteContext) {
|
export default async function getSums(quote: Quote | null) {
|
||||||
if (!quote) {
|
if (!quote) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const getRewardSum = makeGetRewardSum(ctx);
|
|
||||||
|
|
||||||
const [
|
const [
|
||||||
dealerRewardSumm,
|
dealerRewardSumm,
|
||||||
dealerBrokerRewardSumm,
|
dealerBrokerRewardSumm,
|
||||||
|
|||||||
@ -3,8 +3,8 @@ import type { GetQuoteInputData, GetQuoteProcessData } from '../../load-kp/types
|
|||||||
import getSums from './get-sums';
|
import getSums from './get-sums';
|
||||||
import defaultValues from '@/config/default-values';
|
import defaultValues from '@/config/default-values';
|
||||||
|
|
||||||
export async function getKPData({ quote, ctx }: GetQuoteInputData): Promise<GetQuoteProcessData> {
|
export async function getKPData({ quote }: GetQuoteInputData): Promise<GetQuoteProcessData> {
|
||||||
const sums = await getSums(quote, ctx);
|
const sums = await getSums(quote);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
values: {
|
values: {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import type { AgentsFields, AgentsRewardConditionsFields, AgentsSumFields } from './types';
|
import type { AgentsFields, AgentsRewardConditionsFields, AgentsSumFields } from './types';
|
||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import type RootStore from '@/stores/root';
|
import type RootStore from '@/stores/root';
|
||||||
import { getCurrentDateString } from '@/utils/date';
|
import { getCurrentISODate } from '@/utils/date';
|
||||||
import { normalizeOptions } from '@/utils/entity';
|
import { normalizeOptions } from '@/utils/entity';
|
||||||
import { disposableReaction } from '@/utils/mobx';
|
import { disposableReaction } from '@/utils/mobx';
|
||||||
import type { ApolloClient } from '@apollo/client';
|
import type { ApolloClient } from '@apollo/client';
|
||||||
@ -41,7 +41,7 @@ export function fillAgentRewardReaction(
|
|||||||
query: CRMTypes.GetRewardConditionsDocument,
|
query: CRMTypes.GetRewardConditionsDocument,
|
||||||
variables: {
|
variables: {
|
||||||
agentid,
|
agentid,
|
||||||
currentDate: getCurrentDateString(),
|
currentDate: getCurrentISODate(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -75,21 +75,21 @@ export function common({ store, apolloClient }: ProcessContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: { dealer_person },
|
data: { dealer },
|
||||||
} = await apolloClient.query({
|
} = await apolloClient.query({
|
||||||
query: CRMTypes.GetDealerPersonDocument,
|
query: CRMTypes.GetDealerDocument,
|
||||||
variables: {
|
variables: {
|
||||||
dealerPersonId,
|
dealerId: dealerPersonId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (dealer_person?.evo_broker_accountid) {
|
if (dealer?.evo_broker_accountid) {
|
||||||
const {
|
const {
|
||||||
data: { agent: dealerBroker },
|
data: { agent: dealerBroker },
|
||||||
} = await apolloClient.query<CRMTypes.GetAgentQuery, CRMTypes.GetAgentQueryVariables>({
|
} = await apolloClient.query<CRMTypes.GetAgentQuery, CRMTypes.GetAgentQueryVariables>({
|
||||||
query: CRMTypes.GetAgentDocument,
|
query: CRMTypes.GetAgentDocument,
|
||||||
variables: {
|
variables: {
|
||||||
agentid: dealer_person?.evo_broker_accountid,
|
agentid: dealer?.evo_broker_accountid,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -167,53 +167,4 @@ export function common({ store, apolloClient }: ProcessContext) {
|
|||||||
.setValue(Boolean(evo_baseproduct?.evo_supplier_financing_accept));
|
.setValue(Boolean(evo_baseproduct?.evo_supplier_financing_accept));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
{
|
|
||||||
// eslint-disable-next-line no-inner-declarations
|
|
||||||
function unblock() {
|
|
||||||
const cbxPartialVAT = $calculation.element('cbxPartialVAT');
|
|
||||||
cbxPartialVAT.unblock();
|
|
||||||
if (cbxPartialVAT.getValue()) $calculation.element('tbxVATInLeaseObjectPrice').unblock();
|
|
||||||
|
|
||||||
$calculation.element('cbxInsDecentral').unblock();
|
|
||||||
$calculation.element('selectDealerPerson').unblock();
|
|
||||||
$calculation.element('selectDealerRewardCondition').unblock();
|
|
||||||
$calculation.element('selectDealerBroker').unblock();
|
|
||||||
$calculation.element('selectDealerBrokerRewardCondition').unblock();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see 'apps/web/process/used-pl/reactions.ts:common (40)'
|
|
||||||
*/
|
|
||||||
reaction(
|
|
||||||
() => $calculation.$values.getValues(['dealerPerson', 'partialVAT']),
|
|
||||||
async ({ dealerPerson: dealerPersonId }) => {
|
|
||||||
if (!dealerPersonId) {
|
|
||||||
unblock();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { data } = await apolloClient.query({
|
|
||||||
query: CRMTypes.GetDealerPersonDocument,
|
|
||||||
variables: {
|
|
||||||
dealerPersonId,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (data?.dealer_person?.evo_legal_form === 100_000_004) {
|
|
||||||
$calculation.element('cbxPartialVAT').setValue(true).block();
|
|
||||||
$calculation.element('tbxVATInLeaseObjectPrice').resetValue().block();
|
|
||||||
$calculation.element('cbxInsDecentral').setValue(false).block();
|
|
||||||
$calculation.element('selectDealerRewardCondition').block();
|
|
||||||
$calculation.element('tbxDealerRewardSumm').resetValue().block();
|
|
||||||
$calculation.element('selectDealerBroker').resetValue().block();
|
|
||||||
$calculation.element('selectDealerBrokerRewardCondition').resetValue().block();
|
|
||||||
$calculation.element('tbxDealerBrokerRewardSumm').resetValue().block();
|
|
||||||
} else {
|
|
||||||
unblock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import type { ValidationContext } from '../types';
|
|||||||
import type { Elements } from '@/Components/Calculation/config/map/values';
|
import type { Elements } from '@/Components/Calculation/config/map/values';
|
||||||
import ValuesSchema from '@/config/schema/values';
|
import ValuesSchema from '@/config/schema/values';
|
||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import { getCurrentDateString } from '@/utils/date';
|
import { getCurrentISODate } from '@/utils/date';
|
||||||
import { normalizeOptions } from '@/utils/entity';
|
import { normalizeOptions } from '@/utils/entity';
|
||||||
import type { RefinementCtx } from 'zod';
|
import type { RefinementCtx } from 'zod';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
@ -29,7 +29,7 @@ function helper({ apolloClient, ctx }: ValidationContext & { ctx: RefinementCtx
|
|||||||
query: CRMTypes.GetRewardConditionsDocument,
|
query: CRMTypes.GetRewardConditionsDocument,
|
||||||
variables: {
|
variables: {
|
||||||
agentid,
|
agentid,
|
||||||
currentDate: getCurrentDateString(),
|
currentDate: getCurrentISODate(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ export function createValidationSchema(context: ValidationContext) {
|
|||||||
dealerBroker,
|
dealerBroker,
|
||||||
dealerBrokerRewardCondition,
|
dealerBrokerRewardCondition,
|
||||||
dealerBrokerRewardSumm,
|
dealerBrokerRewardSumm,
|
||||||
dealerPerson: dealerPersonId,
|
dealerPerson,
|
||||||
dealerRewardCondition,
|
dealerRewardCondition,
|
||||||
dealerRewardSumm,
|
dealerRewardSumm,
|
||||||
finDepartmentRewardCondtion,
|
finDepartmentRewardCondtion,
|
||||||
@ -248,12 +248,12 @@ export function createValidationSchema(context: ValidationContext) {
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
dealerRewardSumm > 0 &&
|
dealerRewardSumm > 0 &&
|
||||||
Boolean(dealerPersonId) &&
|
Boolean(dealerPerson) &&
|
||||||
((dealerPersonId === dealerBroker && dealerBrokerRewardSumm > 0) ||
|
((dealerPerson === dealerBroker && dealerBrokerRewardSumm > 0) ||
|
||||||
(dealerPersonId === indAgent && indAgentRewardSumm > 0) ||
|
(dealerPerson === indAgent && indAgentRewardSumm > 0) ||
|
||||||
(dealerPersonId === calcDoubleAgent && calcDoubleAgentRewardSumm > 0) ||
|
(dealerPerson === calcDoubleAgent && calcDoubleAgentRewardSumm > 0) ||
|
||||||
(dealerPersonId === calcBroker && calcBrokerRewardSum > 0) ||
|
(dealerPerson === calcBroker && calcBrokerRewardSum > 0) ||
|
||||||
(dealerPersonId === calcFinDepartment && finDepartmentRewardSumm > 0))
|
(dealerPerson === calcFinDepartment && finDepartmentRewardSumm > 0))
|
||||||
) {
|
) {
|
||||||
ctx.addIssue({
|
ctx.addIssue({
|
||||||
code: z.ZodIssueCode.custom,
|
code: z.ZodIssueCode.custom,
|
||||||
@ -265,7 +265,7 @@ export function createValidationSchema(context: ValidationContext) {
|
|||||||
if (
|
if (
|
||||||
dealerBrokerRewardSumm > 0 &&
|
dealerBrokerRewardSumm > 0 &&
|
||||||
Boolean(dealerBroker) &&
|
Boolean(dealerBroker) &&
|
||||||
((dealerBroker === dealerPersonId && dealerRewardSumm > 0) ||
|
((dealerBroker === dealerPerson && dealerRewardSumm > 0) ||
|
||||||
(dealerBroker === indAgent && indAgentRewardSumm > 0) ||
|
(dealerBroker === indAgent && indAgentRewardSumm > 0) ||
|
||||||
(dealerBroker === calcDoubleAgent && calcDoubleAgentRewardSumm > 0) ||
|
(dealerBroker === calcDoubleAgent && calcDoubleAgentRewardSumm > 0) ||
|
||||||
(dealerBroker === calcBroker && calcBrokerRewardSum > 0) ||
|
(dealerBroker === calcBroker && calcBrokerRewardSum > 0) ||
|
||||||
@ -281,7 +281,7 @@ export function createValidationSchema(context: ValidationContext) {
|
|||||||
if (
|
if (
|
||||||
indAgentRewardSumm > 0 &&
|
indAgentRewardSumm > 0 &&
|
||||||
Boolean(indAgent) &&
|
Boolean(indAgent) &&
|
||||||
((indAgent === dealerPersonId && dealerRewardSumm > 0) ||
|
((indAgent === dealerPerson && dealerRewardSumm > 0) ||
|
||||||
(indAgent === dealerBroker && dealerBrokerRewardSumm > 0) ||
|
(indAgent === dealerBroker && dealerBrokerRewardSumm > 0) ||
|
||||||
(indAgent === calcDoubleAgent && calcDoubleAgentRewardSumm > 0) ||
|
(indAgent === calcDoubleAgent && calcDoubleAgentRewardSumm > 0) ||
|
||||||
(indAgent === calcBroker && calcBrokerRewardSum > 0) ||
|
(indAgent === calcBroker && calcBrokerRewardSum > 0) ||
|
||||||
@ -297,7 +297,7 @@ export function createValidationSchema(context: ValidationContext) {
|
|||||||
if (
|
if (
|
||||||
calcDoubleAgentRewardSumm > 0 &&
|
calcDoubleAgentRewardSumm > 0 &&
|
||||||
Boolean(calcDoubleAgent) &&
|
Boolean(calcDoubleAgent) &&
|
||||||
((calcDoubleAgent === dealerPersonId && dealerRewardSumm > 0) ||
|
((calcDoubleAgent === dealerPerson && dealerRewardSumm > 0) ||
|
||||||
(calcDoubleAgent === dealerBroker && dealerBrokerRewardSumm > 0) ||
|
(calcDoubleAgent === dealerBroker && dealerBrokerRewardSumm > 0) ||
|
||||||
(calcDoubleAgent === indAgent && indAgentRewardSumm > 0) ||
|
(calcDoubleAgent === indAgent && indAgentRewardSumm > 0) ||
|
||||||
(calcDoubleAgent === calcBroker && calcBrokerRewardSum > 0) ||
|
(calcDoubleAgent === calcBroker && calcBrokerRewardSum > 0) ||
|
||||||
@ -313,7 +313,7 @@ export function createValidationSchema(context: ValidationContext) {
|
|||||||
if (
|
if (
|
||||||
calcBrokerRewardSum > 0 &&
|
calcBrokerRewardSum > 0 &&
|
||||||
Boolean(calcBroker) &&
|
Boolean(calcBroker) &&
|
||||||
((calcBroker === dealerPersonId && dealerRewardSumm > 0) ||
|
((calcBroker === dealerPerson && dealerRewardSumm > 0) ||
|
||||||
(calcBroker === dealerBroker && dealerBrokerRewardSumm > 0) ||
|
(calcBroker === dealerBroker && dealerBrokerRewardSumm > 0) ||
|
||||||
(calcBroker === indAgent && indAgentRewardSumm > 0) ||
|
(calcBroker === indAgent && indAgentRewardSumm > 0) ||
|
||||||
(calcBroker === calcDoubleAgent && calcDoubleAgentRewardSumm > 0) ||
|
(calcBroker === calcDoubleAgent && calcDoubleAgentRewardSumm > 0) ||
|
||||||
@ -329,7 +329,7 @@ export function createValidationSchema(context: ValidationContext) {
|
|||||||
if (
|
if (
|
||||||
finDepartmentRewardSumm > 0 &&
|
finDepartmentRewardSumm > 0 &&
|
||||||
Boolean(calcFinDepartment) &&
|
Boolean(calcFinDepartment) &&
|
||||||
((calcFinDepartment === dealerPersonId && dealerRewardSumm > 0) ||
|
((calcFinDepartment === dealerPerson && dealerRewardSumm > 0) ||
|
||||||
(calcFinDepartment === dealerBroker && dealerBrokerRewardSumm > 0) ||
|
(calcFinDepartment === dealerBroker && dealerBrokerRewardSumm > 0) ||
|
||||||
(calcFinDepartment === indAgent && indAgentRewardSumm > 0) ||
|
(calcFinDepartment === indAgent && indAgentRewardSumm > 0) ||
|
||||||
(calcFinDepartment === calcDoubleAgent && calcDoubleAgentRewardSumm > 0) ||
|
(calcFinDepartment === calcDoubleAgent && calcDoubleAgentRewardSumm > 0) ||
|
||||||
@ -360,7 +360,7 @@ export function createValidationSchema(context: ValidationContext) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!dealerPersonId && !dealer?.evo_return_leasing_dealer)
|
if (!dealerPerson && !dealer?.evo_return_leasing_dealer)
|
||||||
ctx.addIssue({
|
ctx.addIssue({
|
||||||
code: z.ZodIssueCode.custom,
|
code: z.ZodIssueCode.custom,
|
||||||
message: 'Не заполнено поле',
|
message: 'Не заполнено поле',
|
||||||
@ -377,29 +377,14 @@ export function createValidationSchema(context: ValidationContext) {
|
|||||||
const { validateRewardSum, validateRewardWithoutOtherAgent } = helper({ ...context, ctx });
|
const { validateRewardSum, validateRewardWithoutOtherAgent } = helper({ ...context, ctx });
|
||||||
|
|
||||||
await validateRewardSum({
|
await validateRewardSum({
|
||||||
agentid: dealerPersonId,
|
agentid: dealerPerson,
|
||||||
conditionId: dealerRewardCondition,
|
conditionId: dealerRewardCondition,
|
||||||
sum: dealerRewardSumm,
|
sum: dealerRewardSumm,
|
||||||
sumFieldName: 'tbxDealerRewardSumm',
|
sumFieldName: 'tbxDealerRewardSumm',
|
||||||
});
|
});
|
||||||
|
|
||||||
let evo_broker_accountid: string | null = null;
|
|
||||||
|
|
||||||
if (dealerPersonId) {
|
|
||||||
const {
|
|
||||||
data: { dealer_person },
|
|
||||||
} = await apolloClient.query({
|
|
||||||
query: CRMTypes.GetDealerPersonDocument,
|
|
||||||
variables: {
|
|
||||||
dealerPersonId,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
evo_broker_accountid = dealer_person?.evo_broker_accountid || null;
|
|
||||||
}
|
|
||||||
|
|
||||||
await validateRewardSum({
|
await validateRewardSum({
|
||||||
agentid: dealerBroker || evo_broker_accountid,
|
agentid: dealerBroker,
|
||||||
conditionId: dealerBrokerRewardCondition,
|
conditionId: dealerBrokerRewardCondition,
|
||||||
sum: dealerBrokerRewardSumm,
|
sum: dealerBrokerRewardSumm,
|
||||||
sumFieldName: 'tbxDealerBrokerRewardSumm',
|
sumFieldName: 'tbxDealerBrokerRewardSumm',
|
||||||
@ -482,46 +467,6 @@ export function createValidationSchema(context: ValidationContext) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dealerPersonId) {
|
|
||||||
const {
|
|
||||||
data: { dealer_person },
|
|
||||||
} = await apolloClient.query({
|
|
||||||
query: CRMTypes.GetDealerPersonDocument,
|
|
||||||
variables: {
|
|
||||||
dealerPersonId,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// eslint-disable-next-line no-inner-declarations
|
|
||||||
async function isAgentEqualsToDealerPerson(agentid: string | null) {
|
|
||||||
if (!agentid) return false;
|
|
||||||
if (agentid === dealerPersonId) return true;
|
|
||||||
|
|
||||||
const { data } = await apolloClient.query({
|
|
||||||
query: CRMTypes.GetAgentDocument,
|
|
||||||
variables: {
|
|
||||||
agentid,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return data?.agent?.evo_inn === dealer_person?.evo_inn;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
dealer_person?.evo_legal_form === 100_000_004 &&
|
|
||||||
((await isAgentEqualsToDealerPerson(indAgent)) ||
|
|
||||||
(await isAgentEqualsToDealerPerson(calcDoubleAgent)) ||
|
|
||||||
(await isAgentEqualsToDealerPerson(calcBroker)) ||
|
|
||||||
(await isAgentEqualsToDealerPerson(calcFinDepartment)))
|
|
||||||
) {
|
|
||||||
ctx.addIssue({
|
|
||||||
code: z.ZodIssueCode.custom,
|
|
||||||
message: 'Нельзя закладывать АВ поставщику-ФЛ',
|
|
||||||
path: ['selectDealerPerson'],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (brandId) {
|
if (brandId) {
|
||||||
const {
|
const {
|
||||||
data: { evo_brand },
|
data: { evo_brand },
|
||||||
|
|||||||
@ -90,13 +90,13 @@ export function common({ store, apolloClient }: ProcessContext) {
|
|||||||
$calculation.element('selectImportProgram').resetValue();
|
$calculation.element('selectImportProgram').resetValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (
|
if (
|
||||||
// productId &&
|
productId &&
|
||||||
// partialVAT &&
|
partialVAT &&
|
||||||
// $calculation.element('cbxRecalcWithRevision').getValue() === false
|
$calculation.element('cbxRecalcWithRevision').getValue() === false
|
||||||
// ) {
|
) {
|
||||||
// $calculation.element('cbxLeaseObjectUsed').setValue(true);
|
$calculation.element('cbxLeaseObjectUsed').setValue(true);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user