apps/web: elt kasko fix outsideRoads
This commit is contained in:
parent
ef8059b3b1
commit
8f53187a3c
762
apps/web/process/elt/lib/request.ts
Normal file
762
apps/web/process/elt/lib/request.ts
Normal file
@ -0,0 +1,762 @@
|
||||
/* eslint-disable sonarjs/cognitive-complexity */
|
||||
/* eslint-disable complexity */
|
||||
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 type { ProcessContext } from '@/process/types';
|
||||
import { getCurrentDateString } from '@/utils/date';
|
||||
import dayjs from 'dayjs';
|
||||
import { first, sort } from 'radash';
|
||||
|
||||
export async function ownOsagoRequest(
|
||||
{ store, apolloClient }: Pick<ProcessContext, 'apolloClient' | 'store'>,
|
||||
row: Row
|
||||
): Promise<NonNullable<CRMTypes.GetOsagoAddproductTypesQuery['evo_addproduct_types']>[number]> {
|
||||
const currentDate = getCurrentDateString();
|
||||
|
||||
const {
|
||||
data: { evo_addproduct_types },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetOsagoAddproductTypesDocument,
|
||||
variables: { currentDate },
|
||||
});
|
||||
|
||||
if (!evo_addproduct_types) return null;
|
||||
|
||||
const { leaseObjectCategory, leaseObjectMotorPower, countSeats, maxMass } =
|
||||
store.$calculation.$values.getValues([
|
||||
'leaseObjectCategory',
|
||||
'leaseObjectMotorPower',
|
||||
'countSeats',
|
||||
'maxMass',
|
||||
]);
|
||||
|
||||
const filteredTypes = evo_addproduct_types.filter(
|
||||
(type) =>
|
||||
type?.evo_accountid === row.key &&
|
||||
type.evo_visible_calc &&
|
||||
type.evo_category === leaseObjectCategory &&
|
||||
type.evo_min_power !== null &&
|
||||
type.evo_max_power !== null &&
|
||||
type.evo_min_power <= leaseObjectMotorPower &&
|
||||
type.evo_max_power >= leaseObjectMotorPower &&
|
||||
type.evo_min_seats_count !== null &&
|
||||
type.evo_max_seats_count !== null &&
|
||||
type.evo_min_seats_count <= countSeats &&
|
||||
type.evo_max_seats_count >= countSeats &&
|
||||
type.evo_min_mass !== null &&
|
||||
type.evo_max_mass !== null &&
|
||||
type.evo_min_mass <= maxMass &&
|
||||
type.evo_max_mass >= maxMass
|
||||
);
|
||||
|
||||
const sortedTypes = sort(filteredTypes, (type) => dayjs(type?.createdon).date());
|
||||
|
||||
return first(sortedTypes) || null;
|
||||
}
|
||||
|
||||
const getSpecified = (value: unknown) => value !== null && value !== undefined;
|
||||
|
||||
export async function makeEltOsagoRequest(
|
||||
{ store, apolloClient }: Pick<ProcessContext, 'apolloClient' | 'store'>,
|
||||
row: Row
|
||||
): 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: row.key },
|
||||
});
|
||||
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('selectLegalClientTown').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: 'Россия',
|
||||
|
||||
house: '52',
|
||||
korpus: '5',
|
||||
region: 'Москва',
|
||||
resident: 1,
|
||||
street: 'Космодамианская наб',
|
||||
};
|
||||
|
||||
const owner = {
|
||||
JuridicalName: 'ООО "ЛК "ЭВОЛЮЦИЯ"',
|
||||
email: 'client@evoleasing.ru',
|
||||
factAddress: address,
|
||||
inn: '9724016636',
|
||||
kpp: '770501001',
|
||||
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 {
|
||||
companyId: row.id,
|
||||
params: {
|
||||
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,
|
||||
},
|
||||
preparams: {
|
||||
brandId,
|
||||
kladr,
|
||||
modelId,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export async function makeEltKaskoRequest(
|
||||
{ store, apolloClient }: Pick<ProcessContext, 'apolloClient' | 'store'>,
|
||||
row: Row
|
||||
): Promise<RequestEltKasko> {
|
||||
const { $calculation } = store;
|
||||
|
||||
const currentDate = dayjs().toDate();
|
||||
|
||||
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('selectLegalClientTown').getValue();
|
||||
let evo_town: CRMTypes.GetTownQuery['evo_town'] = null;
|
||||
if (townId) {
|
||||
const { data } = await apolloClient.query({
|
||||
query: CRMTypes.GetTownDocument,
|
||||
variables: { townId },
|
||||
});
|
||||
({ evo_town } = data);
|
||||
}
|
||||
|
||||
const kladr = evo_town?.evo_kladr_id || evo_region?.evo_kladr_id || '';
|
||||
|
||||
const leaseObjectTypeId = $calculation.element('selectLeaseObjectType').getValue();
|
||||
let evo_leasingobject_type: CRMTypes.GetLeaseObjectTypeQuery['evo_leasingobject_type'] = null;
|
||||
if (leaseObjectTypeId) {
|
||||
const { data } = await apolloClient.query({
|
||||
query: CRMTypes.GetLeaseObjectTypeDocument,
|
||||
variables: { leaseObjectTypeId },
|
||||
});
|
||||
({ evo_leasingobject_type } = data);
|
||||
}
|
||||
|
||||
const leaseObjectCategory = $calculation.element('selectLeaseObjectCategory').getValue();
|
||||
|
||||
const brand = $calculation.element('selectBrand').getValue();
|
||||
let evo_brand: CRMTypes.GetBrandQuery['evo_brand'] = null;
|
||||
if (brand) {
|
||||
const { data } = await apolloClient.query({
|
||||
query: CRMTypes.GetBrandDocument,
|
||||
variables: { brandId: brand },
|
||||
});
|
||||
({ evo_brand } = data);
|
||||
}
|
||||
const brandId = evo_brand?.evo_id || '';
|
||||
|
||||
const model = $calculation.element('selectModel').getValue();
|
||||
let evo_model: CRMTypes.GetModelQuery['evo_model'] = null;
|
||||
if (model) {
|
||||
const { data } = await apolloClient.query({
|
||||
query: CRMTypes.GetModelDocument,
|
||||
variables: { modelId: model },
|
||||
});
|
||||
({ evo_model } = data);
|
||||
}
|
||||
const modelId = evo_model?.evo_id || '';
|
||||
|
||||
const leaseObjectUsed = $calculation.element('cbxLeaseObjectUsed').getValue();
|
||||
|
||||
const productId = $calculation.element('selectProduct').getValue();
|
||||
const partialVAT = $calculation.element('cbxPartialVAT').getValue();
|
||||
|
||||
const leaseObjectYear = $calculation.element('tbxLeaseObjectYear').getValue();
|
||||
let isNew = true;
|
||||
if (
|
||||
leaseObjectUsed === true ||
|
||||
(leaseObjectUsed === false &&
|
||||
productId &&
|
||||
partialVAT &&
|
||||
leaseObjectYear < currentDate.getFullYear() - 1)
|
||||
) {
|
||||
isNew = false;
|
||||
}
|
||||
|
||||
const vehicleYear = leaseObjectYear;
|
||||
let vehicleDate;
|
||||
if (
|
||||
leaseObjectUsed === true ||
|
||||
(leaseObjectUsed === false &&
|
||||
productId &&
|
||||
partialVAT &&
|
||||
leaseObjectYear < currentDate.getFullYear() - 1)
|
||||
) {
|
||||
vehicleDate = new Date(`${vehicleYear}-01-01`);
|
||||
}
|
||||
const vehicleDateSpecified = getSpecified(vehicleDate);
|
||||
|
||||
const power = $calculation.element('tbxLeaseObjectMotorPower').getValue();
|
||||
const powerSpecified = getSpecified(power);
|
||||
|
||||
let country = 0;
|
||||
let countrySpecified = false;
|
||||
if (
|
||||
(leaseObjectCategory === 100_000_002 ||
|
||||
(evo_leasingobject_type?.evo_id &&
|
||||
['6', '9', '10', '8'].includes(evo_leasingobject_type?.evo_id))) &&
|
||||
evo_brand?.evo_brand_owner === 100_000_001
|
||||
) {
|
||||
country = 1;
|
||||
countrySpecified = true;
|
||||
}
|
||||
|
||||
const mapEngineType: Record<number, string> = {
|
||||
100_000_000: '0',
|
||||
100_000_001: '1',
|
||||
100_000_003: '2',
|
||||
100_000_004: '3',
|
||||
};
|
||||
|
||||
let engineType = '5';
|
||||
const engineTypeValue = $calculation.element('selectEngineType').getValue();
|
||||
if (engineTypeValue) {
|
||||
engineType = mapEngineType[engineTypeValue] || '5';
|
||||
}
|
||||
|
||||
const leasingPeriod = $calculation.element('tbxLeasingPeriod').getValue();
|
||||
const duration = leasingPeriod < 12 ? 12 : leasingPeriod;
|
||||
|
||||
const cost =
|
||||
$calculation.$values.getValue('plPriceRub') -
|
||||
$calculation.$values.getValue('discountRub') -
|
||||
$calculation.$values.getValue('importProgramSum') +
|
||||
$calculation.$values.getValue('addEquipmentPrice');
|
||||
|
||||
let notConfirmedDamages = 0;
|
||||
let notConfirmedDamagesSpecified = false;
|
||||
let notConfirmedGlassesDamages = 0;
|
||||
let notConfirmedGlassesDamagesSpecified = false;
|
||||
let outsideRoads = false;
|
||||
let outsideRoadsSpecified = false;
|
||||
let selfIgnition = false;
|
||||
let selfIgnitionSpecified = false;
|
||||
if (
|
||||
leaseObjectCategory === 100_000_002 ||
|
||||
(evo_leasingobject_type?.evo_id &&
|
||||
['6', '8', '9', '10'].includes(evo_leasingobject_type?.evo_id))
|
||||
) {
|
||||
notConfirmedGlassesDamages = 3;
|
||||
notConfirmedGlassesDamagesSpecified = true;
|
||||
notConfirmedDamages = 2;
|
||||
notConfirmedDamagesSpecified = true;
|
||||
selfIgnition = true;
|
||||
selfIgnitionSpecified = getSpecified(selfIgnition);
|
||||
outsideRoads = true;
|
||||
outsideRoadsSpecified = true;
|
||||
}
|
||||
|
||||
const franchise = $calculation.element('tbxInsFranchise').getValue();
|
||||
const franchiseSpecified = getSpecified(franchise);
|
||||
|
||||
let puuMark = '';
|
||||
const gpsBrandId = $calculation.element('selectGPSBrand').getValue();
|
||||
if (gpsBrandId) {
|
||||
const {
|
||||
data: { evo_gps_brands },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetGpsBrandsDocument,
|
||||
});
|
||||
puuMark = evo_gps_brands?.find((x) => x?.value === gpsBrandId)?.evo_id || puuMark;
|
||||
}
|
||||
|
||||
let puuModel = '';
|
||||
const gpsModelId = $calculation.element('selectGPSModel').getValue();
|
||||
if (gpsModelId) {
|
||||
const {
|
||||
data: { evo_gps_models },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetGpsModelsDocument,
|
||||
});
|
||||
puuModel = evo_gps_models?.find((x) => x?.value === gpsModelId)?.evo_id || puuModel;
|
||||
}
|
||||
|
||||
const puuModelSpecified = getSpecified(puuModel);
|
||||
|
||||
let age = $calculation.element('tbxInsAgeDrivers').getValue();
|
||||
let experience = $calculation.element('tbxInsExpDrivers').getValue();
|
||||
const sex = '0';
|
||||
let driversCount = 1;
|
||||
|
||||
const risk =
|
||||
evo_leasingobject_type?.evo_id && ['6', '9', '10'].includes(evo_leasingobject_type?.evo_id)
|
||||
? 3
|
||||
: 0;
|
||||
|
||||
if ($calculation.element('cbxInsUnlimitDrivers').getValue()) {
|
||||
age = 18;
|
||||
experience = 0;
|
||||
driversCount = 0;
|
||||
}
|
||||
const sexSpecified = getSpecified(sex);
|
||||
|
||||
let maxAllowedMass = 0;
|
||||
if (leaseObjectCategory === 100_000_002) {
|
||||
maxAllowedMass = $calculation.element('tbxMaxMass').getValue();
|
||||
}
|
||||
const maxAllowedMassSpecified = getSpecified(maxAllowedMass);
|
||||
|
||||
let mileage = 0;
|
||||
if (leaseObjectUsed === true) {
|
||||
mileage = $calculation.element('tbxMileage').getValue();
|
||||
}
|
||||
|
||||
if (
|
||||
leaseObjectUsed === false &&
|
||||
productId &&
|
||||
partialVAT &&
|
||||
leaseObjectYear < currentDate.getFullYear() - 1
|
||||
) {
|
||||
mileage = 0;
|
||||
}
|
||||
|
||||
let vin = '';
|
||||
|
||||
if (leaseObjectUsed === true) {
|
||||
vin = $calculation.element('tbxVIN').getValue() || vin;
|
||||
}
|
||||
|
||||
const mileageSpecified = getSpecified(mileage);
|
||||
|
||||
let vehicleUsage = 0;
|
||||
|
||||
const mapVehicleUsage: Record<number, number> = {
|
||||
100_000_000: 0,
|
||||
100_000_001: 1,
|
||||
100_000_002: 5,
|
||||
100_000_003: 5,
|
||||
100_000_004: 2,
|
||||
100_000_005: 6,
|
||||
100_000_006: 5,
|
||||
100_000_007: 4,
|
||||
100_000_008: 4,
|
||||
100_000_009: 0,
|
||||
100_000_010: 0,
|
||||
100_000_011: 3,
|
||||
100_000_012: 3,
|
||||
100_000_013: 9,
|
||||
100_000_020: 10,
|
||||
};
|
||||
|
||||
const leaseObjectUseFor = $calculation.element('selectLeaseObjectUseFor').getValue();
|
||||
if (leaseObjectUseFor) {
|
||||
vehicleUsage = mapVehicleUsage[leaseObjectUseFor] || 0;
|
||||
}
|
||||
const vehicleUsageSpecified = getSpecified(vehicleUsage);
|
||||
|
||||
let seatingCapacity = 0;
|
||||
if (leaseObjectCategory === 100_000_003) {
|
||||
seatingCapacity = $calculation.element('tbxCountSeats').getValue();
|
||||
}
|
||||
const seatingCapacitySpecified = getSpecified(seatingCapacity);
|
||||
|
||||
const mapCategory: Record<number, string> = {
|
||||
100_000_000: 'A',
|
||||
100_000_001: 'B',
|
||||
// 100000002: 'C2',
|
||||
100_000_003: 'D',
|
||||
100_000_004: 'E1',
|
||||
};
|
||||
|
||||
let category = '';
|
||||
|
||||
if (leaseObjectCategory) {
|
||||
category = mapCategory[leaseObjectCategory];
|
||||
}
|
||||
|
||||
if (leaseObjectCategory === 100_000_002)
|
||||
switch (evo_leasingobject_type?.evo_id) {
|
||||
case '7': {
|
||||
category = 'C1';
|
||||
break;
|
||||
}
|
||||
case '3': {
|
||||
category = 'C3';
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
category = 'C2';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const classification =
|
||||
leaseObjectCategory && [100_000_002, 100_000_003, 100_000_004].includes(leaseObjectCategory)
|
||||
? '11635'
|
||||
: '0';
|
||||
|
||||
let INN = '';
|
||||
const leadid = $calculation.element('selectLead').getValue();
|
||||
if (leadid) {
|
||||
const {
|
||||
data: { lead },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetLeadDocument,
|
||||
variables: { leadid },
|
||||
});
|
||||
INN = lead?.evo_inn || INN;
|
||||
}
|
||||
|
||||
const lesseSubjectType = (INN.length === 10 && 1) || (INN.length === 12 && 2) || 0;
|
||||
|
||||
const mapLeaseObjectUseForToIndustry: Record<number, number> = {
|
||||
100_000_014: 30,
|
||||
100_000_015: 15,
|
||||
100_000_016: 3,
|
||||
100_000_017: 26,
|
||||
100_000_018: 2,
|
||||
100_000_019: 6,
|
||||
};
|
||||
|
||||
let specialMachineryIndustry = 0;
|
||||
let specialMachineryMover = 0;
|
||||
let specialMachineryType = 0;
|
||||
if (evo_leasingobject_type?.evo_id && ['6', '9', '10'].includes(evo_leasingobject_type?.evo_id)) {
|
||||
specialMachineryType = Number(evo_model?.evo_vehicle_body_typeidData?.evo_id_elt || 0);
|
||||
specialMachineryIndustry = leaseObjectUseFor
|
||||
? mapLeaseObjectUseForToIndustry[leaseObjectUseFor]
|
||||
: specialMachineryIndustry;
|
||||
specialMachineryMover = evo_model?.evo_running_gear === 100_000_001 ? 2 : 1;
|
||||
}
|
||||
|
||||
return {
|
||||
companyId: row.id,
|
||||
params: {
|
||||
Insurer: {
|
||||
SubjectType: 1,
|
||||
SubjectTypeSpecified: true,
|
||||
},
|
||||
Lessee: {
|
||||
INN,
|
||||
SubjectType: lesseSubjectType,
|
||||
SubjectTypeSpecified: true,
|
||||
},
|
||||
OfficialDealer: true,
|
||||
OfficialDealerSpecified: true,
|
||||
Owner: {
|
||||
SubjectType: 1,
|
||||
SubjectTypeSpecified: true,
|
||||
},
|
||||
PUUs: puuMark
|
||||
? [
|
||||
{
|
||||
mark: puuMark,
|
||||
model: puuModel,
|
||||
modelSpecified: puuModelSpecified,
|
||||
},
|
||||
]
|
||||
: [],
|
||||
STOA: '0',
|
||||
approvedDriving: 2,
|
||||
approvedDrivingSpecified: true,
|
||||
bankId: '245',
|
||||
cost,
|
||||
currency: 'RUR',
|
||||
drivers: [{ age, experience, sex, sexSpecified }],
|
||||
driversCount,
|
||||
duration,
|
||||
franchise,
|
||||
franchiseSpecified,
|
||||
isNew,
|
||||
modification: {
|
||||
KPPTypeId: 1,
|
||||
country,
|
||||
countrySpecified,
|
||||
engineType,
|
||||
engineVolume: 0,
|
||||
engineVolumeSpecified: true,
|
||||
power,
|
||||
powerSpecified,
|
||||
},
|
||||
notConfirmedDamages,
|
||||
notConfirmedDamagesSpecified,
|
||||
notConfirmedGlassesDamages,
|
||||
notConfirmedGlassesDamagesSpecified,
|
||||
outsideRoads,
|
||||
outsideRoadsSpecified,
|
||||
payType: '0',
|
||||
risk,
|
||||
selfIgnition,
|
||||
selfIgnitionSpecified,
|
||||
ssType: '1',
|
||||
usageStart: currentDate,
|
||||
vehicle: {
|
||||
category,
|
||||
classification,
|
||||
maxAllowedMass,
|
||||
maxAllowedMassSpecified,
|
||||
mileage,
|
||||
mileageSpecified,
|
||||
seatingCapacity,
|
||||
seatingCapacitySpecified,
|
||||
vehicleUsage,
|
||||
vehicleUsageSpecified,
|
||||
vin,
|
||||
},
|
||||
vehicleDate,
|
||||
vehicleDateSpecified,
|
||||
vehicleYear,
|
||||
// FullDriversInfo: [
|
||||
// {
|
||||
// surname,
|
||||
// name,
|
||||
// patronymic,
|
||||
// sex,
|
||||
// sexSpecified,
|
||||
// expertienceStart,
|
||||
// },
|
||||
// ],
|
||||
},
|
||||
preparams: {
|
||||
brandId,
|
||||
kladr,
|
||||
modelId,
|
||||
specialMachinery: {
|
||||
industry: specialMachineryIndustry,
|
||||
industrySpecified: getSpecified(specialMachineryIndustry),
|
||||
mover: specialMachineryMover,
|
||||
moverSpecified: getSpecified(specialMachineryMover),
|
||||
type: specialMachineryType,
|
||||
typeSpecified: getSpecified(specialMachineryType),
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user