add elt osago request

This commit is contained in:
vchikalkin 2023-05-07 14:16:41 +03:00
parent e533b486a3
commit 79924d41c0
8 changed files with 380 additions and 18 deletions

View File

@ -1,17 +1,67 @@
import { PolicyTable, ReloadButton, Validation } from './Components';
import { columns } from './lib/config';
import { makeEltOsagoRequest } from './lib/make-request';
import type { StoreSelector } from './types';
import { getEltOsago } from '@/api/elt/query';
import { STALE_TIME } from '@/constants/request';
import { useStore } from '@/stores/hooks';
import { useApolloClient } from '@apollo/client';
import type { QueryFunctionContext } from '@tanstack/react-query';
import { useQueries } from '@tanstack/react-query';
import { clone } from 'tools';
import { Flex } from 'ui/grid';
const storeSelector: StoreSelector = ({ osago }) => osago;
function handleOnClick() {}
export function Osago() {
const store = useStore();
const { $tables } = store;
const rows = $tables.elt.osago.getRows;
const apolloClient = useApolloClient();
const queries = useQueries({
queries: rows.map(({ key, id }) => ({
enabled: false,
queryFn: async (context: QueryFunctionContext) => {
const payload = await makeEltOsagoRequest({ apolloClient, store }, id);
const res = await getEltOsago(payload, context);
const companyRes = res[id];
return { ...companyRes, id, key };
},
queryKey: ['elt', 'osago', id],
refetchOnWindowFocus: false,
staleTime: STALE_TIME,
})),
});
async function handleOnClick() {
const fetchingRows = rows.map((x) => ({ ...x, isFetching: true }));
$tables.elt.osago.setRows(fetchingRows);
queries.forEach(({ refetch }) => {
refetch().then((res) => {
if (res.data) {
const { key, numCalc, premiumSum, message, skCalcId, error } = res.data;
$tables.elt.osago.setRow({
isFetching: false,
key,
message: message || error,
numCalc,
skCalcId,
sum: premiumSum,
});
}
});
});
}
const osagoColumns = clone(columns);
osagoColumns[0].title = 'Страховая компания ОСАГО';
osagoColumns[3].title = <ReloadButton storeSelector={storeSelector} onClick={handleOnClick} />;
osagoColumns[3].title = (
<ReloadButton storeSelector={storeSelector} onClick={() => handleOnClick()} />
);
return (
<Flex flexDirection="column">

View File

@ -0,0 +1,281 @@
/* eslint-disable sonarjs/cognitive-complexity */
/* eslint-disable complexity */
import type { RequestEltOsago } from '@/api/elt/types';
import * as CRMTypes from '@/graphql/crm.types';
import type { ProcessContext } from '@/process/types';
import dayjs from 'dayjs';
const getSpecified = (value: unknown) => value !== null && value !== undefined;
export async function makeEltOsagoRequest(
{ store, apolloClient }: Pick<ProcessContext, 'apolloClient' | 'store'>,
companyId: string
): Promise<RequestEltOsago> {
const { $calculation, $tables } = store;
const currentDate = dayjs().toDate();
let kladr = '7700000000000';
if ($calculation.element('radioObjectRegistration').getValue() === 100_000_001) {
const townRegistrationId = $calculation.element('selectTownRegistration').getValue();
if (townRegistrationId) {
const {
data: { evo_town },
} = await apolloClient.query({
query: CRMTypes.GetTownDocument,
variables: { townId: townRegistrationId },
});
kladr = evo_town?.evo_kladr_id || kladr;
}
} else {
const {
data: { account: insuranceCompany },
} = await apolloClient.query({
query: CRMTypes.GetInsuranceCompanyDocument,
variables: { accountId: companyId },
});
if (insuranceCompany?.evo_legal_region_calc === true) {
const regionId = $calculation.element('selectLegalClientRegion').getValue();
let evo_region: CRMTypes.GetRegionQuery['evo_region'] = null;
if (regionId) {
const { data } = await apolloClient.query({
query: CRMTypes.GetRegionDocument,
variables: { regionId },
});
({ evo_region } = data);
}
const townId = $calculation.element('selectLegalClientRegion').getValue();
let evo_town: CRMTypes.GetTownQuery['evo_town'] = null;
if (townId) {
const { data } = await apolloClient.query({
query: CRMTypes.GetTownDocument,
variables: { townId },
});
({ evo_town } = data);
}
kladr = evo_town?.evo_kladr_id || evo_region?.evo_kladr_id || kladr;
}
}
let brandId = '';
const brand = $calculation.element('selectBrand').getValue();
if (brand) {
const {
data: { evo_brand },
} = await apolloClient.query({
query: CRMTypes.GetBrandDocument,
variables: { brandId: brand },
});
if (evo_brand?.evo_id) {
brandId = evo_brand.evo_id;
}
}
let modelId = '';
const model = $calculation.element('selectModel').getValue();
if (model) {
const {
data: { evo_model },
} = await apolloClient.query({
query: CRMTypes.GetModelDocument,
variables: { modelId: model },
});
if (evo_model?.evo_id) {
modelId = evo_model.evo_id;
}
}
let gpsMark = '';
const gpsBrandId = $calculation.element('selectGPSBrand').getValue();
if (gpsBrandId) {
const {
data: { evo_gps_brands },
} = await apolloClient.query({
query: CRMTypes.GetGpsBrandsDocument,
});
gpsMark = evo_gps_brands?.find((x) => x?.value === gpsBrandId)?.evo_id || gpsMark;
}
let gpsModel = '';
const gpsModelId = $calculation.element('selectGPSModel').getValue();
if (gpsModelId) {
const {
data: { evo_gps_models },
} = await apolloClient.query({
query: CRMTypes.GetGpsModelsDocument,
});
gpsModel = evo_gps_models?.find((x) => x?.value === gpsModelId)?.evo_id || gpsModel;
}
const vehicleYear = $calculation.element('tbxLeaseObjectYear').getValue().toString();
const leaseObjectCategory = $calculation.element('selectLeaseObjectCategory').getValue();
const vehiclePower = $calculation.element('tbxLeaseObjectMotorPower').getValue() || 0;
const mapCategory: Record<number, string> = {
100_000_000: 'A',
100_000_001: 'B',
100_000_002: 'C',
100_000_003: 'D',
100_000_004: 'ПРОЧИЕ ТС',
};
const category = (leaseObjectCategory && mapCategory[leaseObjectCategory]) || '0';
const leaseObjectUseFor = $calculation.element('selectLeaseObjectUseFor').getValue();
const maxMass = $calculation.element('tbxMaxMass').getValue();
const countSeats = $calculation.element('tbxCountSeats').getValue();
let subCategory = '0';
switch (leaseObjectCategory) {
case 100_000_001: {
if (leaseObjectUseFor === 100_000_001) {
subCategory = '11';
}
subCategory = '10';
break;
}
case 100_000_002: {
if (maxMass <= 16_000) {
subCategory = '20';
}
subCategory = '21';
break;
}
case 100_000_003: {
if (leaseObjectUseFor === 100_000_001) {
subCategory = '32';
}
if (countSeats <= 20) {
subCategory = '30';
}
subCategory = '31';
break;
}
case 100_000_004: {
subCategory = '22';
break;
}
case 100_000_000:
default: {
subCategory = '0';
break;
}
}
let seatingCapacity = 0;
if (leaseObjectCategory === 100_000_003) {
seatingCapacity = countSeats;
}
const seatingCapacitySpecified = getSpecified(seatingCapacity);
let maxAllowedMass = 0;
if (leaseObjectCategory === 100_000_002) {
maxAllowedMass = maxMass;
}
const maxAllowedMassSpecified = getSpecified(maxAllowedMass);
const useWithTrailer = $calculation.element('cbxWithTrailer').getValue();
const useWithTrailerSpecified = true;
const address = {
// district: '0',
city: 'Москва',
cityKladr: '7700000000000',
country: 'Россия',
flat: '337',
house: '8',
region: 'Москва',
resident: 1,
street: 'ул. Котляковская',
};
const owner = {
JuridicalName: 'ООО "ЛК "ЭВОЛЮЦИЯ"',
email: 'client@evoleasing.ru',
factAddress: address,
inn: '9724016636',
kpp: '772401001',
ogrn: '1207700245037',
opf: 1,
opfSpecified: true,
phone: '8 (800) 333-75-75',
registrationAddress: address,
subjectType: 1,
subjectTypeSpecified: true,
};
let inn = '9724016636';
const insured = $tables.insurance.row('osago').getValue('insured');
const leadid = $calculation.element('selectLead').getValue();
if (insured === 100_000_000 && leadid) {
const {
data: { lead },
} = await apolloClient.query({
query: CRMTypes.GetLeadDocument,
variables: { leadid },
});
inn = lead?.evo_inn || inn;
}
return {
ELTParams: {
FullDriversInfo: [
{
kbm: '3',
},
],
carInfo: {
mark: gpsMark,
model: gpsModel,
tsType: { category, subCategory },
useWithTrailer,
useWithTrailerSpecified,
vehicle: {
maxAllowedMass,
maxAllowedMassSpecified,
seatingCapacity,
seatingCapacitySpecified,
},
vehiclePower,
vehicleYear,
},
contractBeginDate: currentDate,
contractOptionId: 1,
contractStatusId: 13,
driversCount: 0,
duration: 12,
insurer: {
INN: inn,
SubjectType: 1,
SubjectTypeSpecified: true,
},
insurerType: 1,
lessee: {
SubjectType: 1,
SubjectTypeSpecified: true,
inn,
},
owner,
ownerType: 1,
tsToRegistrationPlace: 0,
},
companyIds: [companyId],
preparams: {
brandId,
kladr,
modelId,
},
};
}

View File

@ -5,10 +5,14 @@ import axios from 'axios';
const { URL_ELT_KASKO, URL_ELT_OSAGO } = getUrls();
export async function getEltOsago(payload: ELT.RequestEltOsago, { signal }: QueryFunctionContext) {
const { data } = await axios.post<ELT.ResponseEltOsago>(URL_ELT_OSAGO, payload, { signal });
return data;
export async function getEltOsago(
payload: ELT.RequestEltOsago,
{ signal }: QueryFunctionContext
): Promise<ELT.ResponseEltOsago> {
return await axios
.post<ELT.ResponseEltOsago>(URL_ELT_OSAGO, payload, { signal })
.then((response) => response.data)
.catch((error) => error.response.data);
}
export async function getEltKasko(payload: ELT.RequestEltKasko, { signal }: QueryFunctionContext) {

View File

@ -170,6 +170,8 @@ export const RequestEltOsagoSchema = z.object({
ELTParams: z.object({
FullDriversInfo: z.array(z.object({ kbm: z.string() })),
carInfo: z.object({
mark: z.string(),
model: z.string(),
tsType: z.object({ category: z.string(), subCategory: z.string() }),
useWithTrailer: z.boolean(),
useWithTrailerSpecified: z.boolean(),
@ -182,7 +184,7 @@ export const RequestEltOsagoSchema = z.object({
vehiclePower: z.number(),
vehicleYear: z.string(),
}),
contractBeginDate: z.string(),
contractBeginDate: z.date(),
contractOptionId: z.number(),
contractStatusId: z.number(),
driversCount: z.number(),
@ -264,6 +266,7 @@ export const ResultEltOsagoSchema = z.record(
);
export const RowSchema = z.object({
id: z.string(),
isFetching: z.boolean(),
key: z.string(),
message: z.string().nullable(),

View File

@ -276,6 +276,7 @@ query GetRegion($regionId: Uuid!) {
accounts {
accountid
}
evo_kladr_id
}
}
@ -288,10 +289,17 @@ query GetTowns($regionId: Uuid!) {
}
}
query GetTown($townId: Uuid!) {
evo_town(evo_townid: $townId) {
evo_kladr_id
}
}
query GetGPSBrands {
evo_gps_brands(statecode: 0) {
label: evo_name
value: evo_gps_brandid
evo_id
}
}
@ -299,6 +307,7 @@ query GetGPSModels($gpsBrandId: Uuid!) {
evo_gps_models(evo_gps_brandid: $gpsBrandId) {
label: evo_name
value: evo_gps_modelid
evo_id
}
}
@ -358,6 +367,7 @@ query GetModel($modelId: Uuid!) {
}
evo_importer_reward_perc
evo_importer_reward_rub
evo_id
}
}

View File

@ -250,7 +250,7 @@ export type GetRegionQueryVariables = Exact<{
}>;
export type GetRegionQuery = { __typename?: 'Query', evo_region: { __typename?: 'evo_region', evo_oktmo: string | null, accounts: Array<{ __typename?: 'account', accountid: string | null } | null> | null } | null };
export type GetRegionQuery = { __typename?: 'Query', evo_region: { __typename?: 'evo_region', evo_oktmo: string | null, evo_kladr_id: string | null, accounts: Array<{ __typename?: 'account', accountid: string | null } | null> | null } | null };
export type GetTownsQueryVariables = Exact<{
regionId: Scalars['Uuid'];
@ -259,17 +259,24 @@ export type GetTownsQueryVariables = Exact<{
export type GetTownsQuery = { __typename?: 'Query', evo_towns: Array<{ __typename?: 'evo_town', evo_fias_id: string | null, evo_businessunit_evolution: boolean | null, label: string | null, value: string | null } | null> | null };
export type GetTownQueryVariables = Exact<{
townId: Scalars['Uuid'];
}>;
export type GetTownQuery = { __typename?: 'Query', evo_town: { __typename?: 'evo_town', evo_kladr_id: string | null } | null };
export type GetGpsBrandsQueryVariables = Exact<{ [key: string]: never; }>;
export type GetGpsBrandsQuery = { __typename?: 'Query', evo_gps_brands: Array<{ __typename?: 'evo_gps_brand', label: string | null, value: string | null } | null> | null };
export type GetGpsBrandsQuery = { __typename?: 'Query', evo_gps_brands: Array<{ __typename?: 'evo_gps_brand', evo_id: string | null, label: string | null, value: string | null } | null> | null };
export type GetGpsModelsQueryVariables = Exact<{
gpsBrandId: Scalars['Uuid'];
}>;
export type GetGpsModelsQuery = { __typename?: 'Query', evo_gps_models: Array<{ __typename?: 'evo_gps_model', label: string | null, value: string | null } | null> | null };
export type GetGpsModelsQuery = { __typename?: 'Query', evo_gps_models: Array<{ __typename?: 'evo_gps_model', evo_id: string | null, label: string | null, value: string | null } | null> | null };
export type GetLeaseObjectTypesQueryVariables = Exact<{ [key: string]: never; }>;
@ -307,7 +314,7 @@ export type GetModelQueryVariables = Exact<{
}>;
export type GetModelQuery = { __typename?: 'Query', evo_model: { __typename?: 'evo_model', evo_importer_reward_perc: number | null, evo_importer_reward_rub: number | null, evo_impairment_groupidData: { __typename?: 'evo_impairment_group', evo_name: string | null } | null } | null };
export type GetModelQuery = { __typename?: 'Query', evo_model: { __typename?: 'evo_model', evo_importer_reward_perc: number | null, evo_importer_reward_rub: number | null, evo_id: string | null, evo_impairment_groupidData: { __typename?: 'evo_impairment_group', evo_name: string | null } | null } | null };
export type GetConfigurationsQueryVariables = Exact<{
modelId: Scalars['Uuid'];
@ -615,16 +622,17 @@ export const GetSubsidiesDocument = {"kind":"Document","definitions":[{"kind":"O
export const GetSubsidyDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetSubsidy"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"subsidyId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_subsidy"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_subsidyid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"subsidyId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"accounts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accountid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_brands"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_brandid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_models"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_modelid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_subsidy_summ"}},{"kind":"Field","name":{"kind":"Name","value":"evo_percent_subsidy"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_subsidy_summ"}},{"kind":"Field","name":{"kind":"Name","value":"evo_get_subsidy_payment"}},{"kind":"Field","name":{"kind":"Name","value":"evo_delivery_time"}}]}}]}}]} as unknown as DocumentNode<GetSubsidyQuery, GetSubsidyQueryVariables>;
export const GetImportProgramDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetImportProgram"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"importProgramId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"importProgram"},"name":{"kind":"Name","value":"evo_subsidy"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_subsidyid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"importProgramId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"accounts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accountid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_brands"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_brandid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_models"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_modelid"}}]}}]}}]}}]} as unknown as DocumentNode<GetImportProgramQuery, GetImportProgramQueryVariables>;
export const GetRegionsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRegions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_regions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_regionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fias_id"}},{"kind":"Field","name":{"kind":"Name","value":"evo_businessunit_evolution"}}]}}]}}]} as unknown as DocumentNode<GetRegionsQuery, GetRegionsQueryVariables>;
export const GetRegionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRegion"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"regionId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_region"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_regionid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"regionId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_oktmo"}},{"kind":"Field","name":{"kind":"Name","value":"accounts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accountid"}}]}}]}}]}}]} as unknown as DocumentNode<GetRegionQuery, GetRegionQueryVariables>;
export const GetRegionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRegion"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"regionId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_region"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_regionid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"regionId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_oktmo"}},{"kind":"Field","name":{"kind":"Name","value":"accounts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accountid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_kladr_id"}}]}}]}}]} as unknown as DocumentNode<GetRegionQuery, GetRegionQueryVariables>;
export const GetTownsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetTowns"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"regionId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_towns"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_regionid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"regionId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_fias_id"}},{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_townid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_businessunit_evolution"}}]}}]}}]} as unknown as DocumentNode<GetTownsQuery, GetTownsQueryVariables>;
export const GetGpsBrandsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetGPSBrands"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_gps_brands"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_gps_brandid"}}]}}]}}]} as unknown as DocumentNode<GetGpsBrandsQuery, GetGpsBrandsQueryVariables>;
export const GetGpsModelsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetGPSModels"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"gpsBrandId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_gps_models"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_gps_brandid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"gpsBrandId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_gps_modelid"}}]}}]}}]} as unknown as DocumentNode<GetGpsModelsQuery, GetGpsModelsQueryVariables>;
export const GetTownDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetTown"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"townId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_town"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_townid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"townId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_kladr_id"}}]}}]}}]} as unknown as DocumentNode<GetTownQuery, GetTownQueryVariables>;
export const GetGpsBrandsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetGPSBrands"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_gps_brands"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_gps_brandid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id"}}]}}]}}]} as unknown as DocumentNode<GetGpsBrandsQuery, GetGpsBrandsQueryVariables>;
export const GetGpsModelsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetGPSModels"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"gpsBrandId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_gps_models"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_gps_brandid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"gpsBrandId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_gps_modelid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id"}}]}}]}}]} as unknown as DocumentNode<GetGpsModelsQuery, GetGpsModelsQueryVariables>;
export const GetLeaseObjectTypesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLeaseObjectTypes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_leasingobject_typeid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}}]}}]} as unknown as DocumentNode<GetLeaseObjectTypesQuery, GetLeaseObjectTypesQueryVariables>;
export const GetLeaseObjectTypeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLeaseObjectType"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"leaseObjectTypeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_type"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_leasingobject_typeid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"leaseObjectTypeId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id"}},{"kind":"Field","name":{"kind":"Name","value":"evo_category"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type_tax"}},{"kind":"Field","name":{"kind":"Name","value":"evo_category_tr"}},{"kind":"Field","name":{"kind":"Name","value":"evo_expluatation_period1"}},{"kind":"Field","name":{"kind":"Name","value":"evo_expluatation_period2"}},{"kind":"Field","name":{"kind":"Name","value":"evo_depreciation_rate1"}},{"kind":"Field","name":{"kind":"Name","value":"evo_depreciation_rate2"}}]}}]}}]} as unknown as DocumentNode<GetLeaseObjectTypeQuery, GetLeaseObjectTypeQueryVariables>;
export const GetBrandsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetBrands"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_brands"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_brandid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_brandid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type"}}]}}]}}]} as unknown as DocumentNode<GetBrandsQuery, GetBrandsQueryVariables>;
export const GetBrandDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetBrand"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"brandId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_brand"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_brandid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"brandId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_id"}},{"kind":"Field","name":{"kind":"Name","value":"evo_importer_reward_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_importer_reward_rub"}},{"kind":"Field","name":{"kind":"Name","value":"evo_maximum_percentage_av"}}]}}]}}]} as unknown as DocumentNode<GetBrandQuery, GetBrandQueryVariables>;
export const GetModelsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetModels"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"brandId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_models"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_brandid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"brandId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_modelid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_modelid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type"}}]}}]}}]} as unknown as DocumentNode<GetModelsQuery, GetModelsQueryVariables>;
export const GetModelDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetModel"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"modelId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_model"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_modelid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"modelId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_impairment_groupidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_importer_reward_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_importer_reward_rub"}}]}}]}}]} as unknown as DocumentNode<GetModelQuery, GetModelQueryVariables>;
export const GetModelDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetModel"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"modelId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_model"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_modelid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"modelId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_impairment_groupidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_importer_reward_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_importer_reward_rub"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id"}}]}}]}}]} as unknown as DocumentNode<GetModelQuery, GetModelQueryVariables>;
export const GetConfigurationsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetConfigurations"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"modelId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_equipments"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_modelid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"modelId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_equipmentid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_start_production_year"}}]}}]}}]} as unknown as DocumentNode<GetConfigurationsQuery, GetConfigurationsQueryVariables>;
export const GetConfigurationDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetConfiguration"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"configurationId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_equipment"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_equipmentid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"configurationId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_impairment_groupidData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_name"}}]}}]}}]}}]} as unknown as DocumentNode<GetConfigurationQuery, GetConfigurationQueryVariables>;
export const GetDealersDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetDealers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"dealers"},"name":{"kind":"Name","value":"accounts"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_account_type"},"value":{"kind":"ListValue","values":[{"kind":"IntValue","value":"100000001"}]}},{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_legal_form"},"value":{"kind":"IntValue","value":"100000001"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"accountid"}},{"kind":"Field","name":{"kind":"Name","value":"accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_supplier_financing_accept"}}]}}]}}]} as unknown as DocumentNode<GetDealersQuery, GetDealersQueryVariables>;

View File

@ -36,6 +36,11 @@ export default function helper({ apolloClient, store }: ProcessContext) {
: Boolean(x?.evo_id_elt)
)
.map((x) => ({
id:
evo_leasingobject_type?.evo_id &&
['6', '9', '10'].includes(evo_leasingobject_type?.evo_id)
? x?.evo_id_elt_smr
: x?.evo_id_elt,
isFetching: false,
key: x?.value,
message: null,
@ -49,6 +54,7 @@ export default function helper({ apolloClient, store }: ProcessContext) {
osago: (accounts
?.filter((x) => x?.evo_type_ins_policy?.includes(100_000_001) && x?.evo_id_elt_osago)
.map((x) => ({
id: x?.evo_id_elt_osago,
isFetching: false,
key: x?.value,
message: null,

View File

@ -49,9 +49,9 @@ export default class PolicyStore {
this.rows.replace(rows);
};
public setRow = (row: ELT.Row) => {
public setRow = (row: Partial<ELT.Row> & Pick<ELT.Row, 'key'>) => {
const index = this.rows.findIndex((x) => x.key === row.key);
if (index > 0) this.rows[index] = row;
if (index >= 0) this.rows[index] = { ...this.rows[index], ...row };
};
public get getRows() {