diff --git a/src/client/Components/Calculation/ELT/Content/Kasko/lib/composeRequest.ts b/src/client/Components/Calculation/ELT/Content/Kasko/lib/composeRequest.ts index 2e555fb..b7a920a 100644 --- a/src/client/Components/Calculation/ELT/Content/Kasko/lib/composeRequest.ts +++ b/src/client/Components/Calculation/ELT/Content/Kasko/lib/composeRequest.ts @@ -39,15 +39,28 @@ const mapInfuranceToLesseSubjectType = { 100000001: 2, }; +const mapLeaseObjectUseForToIndustry = { + 100000014: 30, + 100000015: 15, + 100000016: 3, + 100000017: 26, + 100000018: 2, + 100000019: 6, +}; + const getSpecified = value => !isNull(value); export default function (this: ICalculationStore) { const region = this.getOption('selectLegalClientRegion'); const city = this.getOption('selectLegalClientTown'); const kladr = get(city, 'evo_kladr_id') || get(region, 'evo_kladr_id'); + const leaseObjectType = this.getOption('selectLeaseObjectType'); + const leaseObjectCategory = this.getValue('leaseObjectCategory'); + const brand = this.getOption('selectBrand'); - const brandId = brand?.evo_id; - const modelId = this.getOption('selectModel')?.evo_id; + let brandId = brand?.evo_id; + const model = this.getOption('selectModel'); + let modelId = model?.evo_id; const isNew = !this.getValue('leaseObjectUsed'); const vehicleYear = this.getValue('leaseObjectYear'); @@ -56,10 +69,11 @@ export default function (this: ICalculationStore) { let country = 0, countrySpecified = false; - if (brand?.evo_brand_owner === 100000001) { - country = 1; - countrySpecified = true; - } + if (leaseObjectCategory === 100000002 || leaseObjectType?.evo_id === '9') + if (brand?.evo_brand_owner === 100000001) { + country = 1; + countrySpecified = true; + } let engineType = '5'; const engineTypeValue = this.getValue('engineType'); @@ -74,8 +88,6 @@ export default function (this: ICalculationStore) { const cost = this.getValue('leaseObjectPrice') - this.getValue('supplierDiscountRub'); - const leaseObjectCategory = this.getValue('leaseObjectCategory'); - let notConfirmedGlassesDamages, notConfirmedGlassesDamagesSpecified = false, notConfirmedDamages, @@ -84,7 +96,7 @@ export default function (this: ICalculationStore) { selfIgnitionSpecified = false, outsideRoads, outsideRoadsSpecified = false; - if (leaseObjectCategory === 100000002) { + if (leaseObjectCategory === 100000002 || leaseObjectType?.evo_id === '9') { notConfirmedGlassesDamages = 3; notConfirmedGlassesDamagesSpecified = true; notConfirmedDamages = 2; @@ -106,6 +118,8 @@ export default function (this: ICalculationStore) { sex = '0', driversCount = 1; + const risk = leaseObjectType?.evo_id === '9' ? 3 : 0; + if (this.getValue('insUnlimitDrivers')) { age = 18; experience = 0; @@ -139,7 +153,6 @@ export default function (this: ICalculationStore) { const seatingCapacitySpecified = getSpecified(seatingCapacity); let category = mapCategory[leaseObjectCategory]; - const leaseObjectType = this.getOption('selectLeaseObjectType'); if (leaseObjectCategory === 100000002) switch (leaseObjectType?.evo_id) { case '7': { @@ -167,11 +180,34 @@ export default function (this: ICalculationStore) { const infuranceOPF = this.getValue('infuranceOPF'); const lesseSubjectType = get(mapInfuranceToLesseSubjectType, infuranceOPF, 0); + let specialMachineryType = 0, + specialMachineryIndustry = 0, + specialMachineryMover = 0; + if (leaseObjectType?.evo_id === '9') { + specialMachineryType = parseInt( + model?.evo_vehicle_body_typeidData?.evo_id_elt || '0', + ); + specialMachineryIndustry = + mapLeaseObjectUseForToIndustry[leaseObjectUseForValue]; + specialMachineryMover = + leaseObjectType.evo_id === '9' && model?.evo_running_gear === 100000001 + ? 2 + : 1; + } + return { preparams: { kladr, brandId, modelId, + specialMachinery: { + type: specialMachineryType, + typeSpecified: getSpecified(specialMachineryType), + industry: specialMachineryIndustry, + industrySpecified: getSpecified(specialMachineryIndustry), + mover: specialMachineryMover, + moverSpecified: getSpecified(specialMachineryMover), + }, }, ELTParams: { currency: 'RUR', @@ -185,7 +221,6 @@ export default function (this: ICalculationStore) { engineVolume: 0, engineVolumeSpecified: true, KPPTypeId: 1, - BodyType: 9, country, countrySpecified, }, @@ -214,7 +249,9 @@ export default function (this: ICalculationStore) { }, ], driversCount, - risk: 0, + approvedDriving: 2, + approvedDrivingSpecified: true, + risk, payType: '0', vehicle: { maxAllowedMass, diff --git a/src/client/Components/Calculation/ELT/Content/Kasko/lib/validation.ts b/src/client/Components/Calculation/ELT/Content/Kasko/lib/validation.ts index eca46eb..8b1c844 100644 --- a/src/client/Components/Calculation/ELT/Content/Kasko/lib/validation.ts +++ b/src/client/Components/Calculation/ELT/Content/Kasko/lib/validation.ts @@ -22,10 +22,7 @@ export const requiredFields: ElementsNames[] = [ export const conditions: TElements = { selectLeaseObjectType: calculationStore => { const leaseObjectType = calculationStore.getOption('selectLeaseObjectType'); - if ( - leaseObjectType?.evo_id && - ['9', '11'].includes(leaseObjectType?.evo_id) - ) { + if (leaseObjectType?.evo_id && ['11'].includes(leaseObjectType?.evo_id)) { return { isValid: false, message: `По данному Типу предмета лизинга возможен только индивидуальный запрос тарифов КАСКО и ОСАГО. Просьба обратиться на адрес strakhovka@evoleasing.ru`, @@ -34,7 +31,7 @@ export const conditions: TElements = { if ( leaseObjectType?.evo_id && - !['1', '2', '3', '7'].includes(leaseObjectType?.evo_id) + !['1', '2', '3', '7', '9'].includes(leaseObjectType?.evo_id) ) { return { isValid: false, @@ -81,7 +78,7 @@ export const conditions: TElements = { const leaseObjectType = calculationStore.getOption('selectLeaseObjectType'); if (!leaseObjectCategory) { - if (['6', '10'].includes(leaseObjectType?.evo_id || '')) { + if (['6', '9', '10'].includes(leaseObjectType?.evo_id || '')) { return { isValid: true, }; diff --git a/src/client/Components/Calculation/ELT/Content/lib/requests.ts b/src/client/Components/Calculation/ELT/Content/lib/requests.ts index cb6d2a0..1ad6c04 100644 --- a/src/client/Components/Calculation/ELT/Content/lib/requests.ts +++ b/src/client/Components/Calculation/ELT/Content/lib/requests.ts @@ -18,11 +18,10 @@ export const fetchData = (insType: string, composeRequest, convertEltResult) => const { ELTStore } = this.stores; - const evo_id_elt_fieldName = map_evo_id_elt_FieldName[insType]; + const evo_id_elt_fieldName = map_evo_id_elt_FieldName[insType](this); const requests = ELTStore[insType].list.map( - (company: IAccount, i: number) => { - //@ts-ignore + (company: IAccount & { isFetching: boolean }, i: number) => { company.isFetching = true; return new Promise((resolve, reject) => { const request = composeRequest.call(this, company); @@ -56,7 +55,6 @@ export const fetchData = (insType: string, composeRequest, convertEltResult) => reject(err); }) .finally(() => { - //@ts-ignore company.isFetching = false; resolve(); }); diff --git a/src/client/Components/Calculation/ELT/Content/lib/resetIns.ts b/src/client/Components/Calculation/ELT/Content/lib/resetIns.ts index c9bef51..b2a1dbb 100644 --- a/src/client/Components/Calculation/ELT/Content/lib/resetIns.ts +++ b/src/client/Components/Calculation/ELT/Content/lib/resetIns.ts @@ -9,12 +9,16 @@ const mapInsType = { }; export const map_evo_id_elt_FieldName = { - kasko: 'evo_id_elt', - osago: 'evo_id_elt_osago', + kasko: (calculationStore: ICalculationStore) => + calculationStore.getOption('selectLeaseObjectType')?.evo_id !== '9' + ? 'evo_id_elt' + : 'evo_id_elt_smr', + osago: (_: ICalculationStore) => 'evo_id_elt_osago', }; export const initFields = [ 'evo_id_elt_osago', + 'evo_id_elt_smr', 'evo_id_elt', 'name', 'accountid', @@ -31,13 +35,12 @@ export function initIns(this: ICalculationStore, insType) { } const { ELTStore } = this.stores; const list: TCRMEntity[] = []; - const evo_id_elt_fieldName = map_evo_id_elt_FieldName[insType]; + const evo_id_elt_fieldName = map_evo_id_elt_FieldName[insType](this); insuranceCompanies.forEach(company => { if ( company && company[evo_id_elt_fieldName] && - company.evo_type_ins_policy && - company.evo_type_ins_policy.includes(mapInsType[insType]) + company?.evo_type_ins_policy?.includes(mapInsType[insType]) ) { const companyData = pick(company, initFields, ''); list.push(companyData); diff --git a/src/client/Containers/Calculation/lib/fetchData/queries/insuranceQuery.ts b/src/client/Containers/Calculation/lib/fetchData/queries/insuranceQuery.ts index 0259d43..7617e32 100644 --- a/src/client/Containers/Calculation/lib/fetchData/queries/insuranceQuery.ts +++ b/src/client/Containers/Calculation/lib/fetchData/queries/insuranceQuery.ts @@ -11,6 +11,7 @@ const query = gql` name evo_type_ins_policy evo_id_elt + evo_id_elt_smr evo_id_elt_osago evo_legal_region_calc } diff --git a/src/client/stores/CalculationStore/Effects/reactions/eltReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/eltReactions.ts index 1251e67..0c987e8 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/eltReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/eltReactions.ts @@ -1,7 +1,10 @@ import { message } from 'antd'; import { resetFields as kaskoResetFields } from 'client/Components/Calculation/ELT/Content/Kasko/lib/validation'; import { cancelRequests } from 'client/Components/Calculation/ELT/Content/lib/requests'; -import { resetIns } from 'client/Components/Calculation/ELT/Content/lib/resetIns'; +import { + initIns, + resetIns, +} from 'client/Components/Calculation/ELT/Content/lib/resetIns'; import { resetFields as osagoResetFields } from 'client/Components/Calculation/ELT/Content/Osago/lib/validation'; import { getValueName } from 'client/Containers/Calculation/lib/elements/tools'; import { TCalculationProcess } from 'client/stores/CalculationStore/subStores/calculationProcess'; @@ -29,6 +32,18 @@ const RESET_MESSAGES = { }; const eltReactions: IReactionEffect[] = [ + calculationStore => ({ + expression: () => { + return calculationStore.getOption('selectLeaseObjectType'); + }, + effect: (prevLeaseObjectType, nextLeaseObjectType) => { + if ( + prevLeaseObjectType?.evo_id === '9' || + nextLeaseObjectType?.evo_id === '9' + ) + initIns.call(calculationStore, 'kasko'); + }, + }), ...resetConf.map( ({ insType, resetFields }) => ( calculationStore: ICalculationStore, diff --git a/src/client/stores/CalculationStore/Effects/reactions/insuranceReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/insuranceReactions.ts index aa77463..3f8de66 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/insuranceReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/insuranceReactions.ts @@ -32,6 +32,8 @@ const mapObjectCategoryToUseFor = { 100000013, ], 100000004: [100000002, 100000009], + null: [100000014, 100000015, 100000016, 100000017, 100000018, 100000019], + undefined: [100000014, 100000015, 100000016, 100000017, 100000018, 100000019], }; const insuranceReactions: IReactionEffect[] = [ @@ -40,21 +42,16 @@ const insuranceReactions: IReactionEffect[] = [ return calculationStore.getValue('leaseObjectCategory'); }, effect: leaseObjectCategory => { - if (leaseObjectCategory) { - const allowedObjectUseFor: number[] = - mapObjectCategoryToUseFor[leaseObjectCategory]; - calculationStore.setFilter('selectLeaseObjectUseFor', options => - options.filter( - option => - option.value && - typeof option.value === 'number' && - allowedObjectUseFor && - allowedObjectUseFor.includes(option.value), - ), - ); - } else { - calculationStore.setFilter('selectLeaseObjectUseFor', undefined); - } + const allowedObjectUseFor: number[] = + mapObjectCategoryToUseFor[leaseObjectCategory]; + calculationStore.setFilter('selectLeaseObjectUseFor', options => + options.filter( + option => + option.value && + typeof option.value === 'number' && + allowedObjectUseFor?.includes(option.value), + ), + ); }, }), diff --git a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/optionsQuery.js b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/optionsQuery.js index 66e5904..82f40bc 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/optionsQuery.js +++ b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/optionsQuery.js @@ -26,6 +26,10 @@ export const mainOptionsQuery = gql` evo_impairment_groupid evo_vehicle_type evo_gps + evo_vehicle_body_typeidData { + evo_id_elt + } + evo_running_gear } selectConfiguration: evo_equipments( statecode: $statecode diff --git a/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts index aa2ed31..1247d80 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts @@ -821,6 +821,10 @@ export default [ evo_impairment_groupid evo_vehicle_type evo_gps + evo_vehicle_body_typeidData { + evo_id_elt + } + evo_running_gear } } `, diff --git a/src/client/stores/CalculationStore/config/initialOptions.ts b/src/client/stores/CalculationStore/config/initialOptions.ts index 8af8da2..8949ebd 100644 --- a/src/client/stores/CalculationStore/config/initialOptions.ts +++ b/src/client/stores/CalculationStore/config/initialOptions.ts @@ -273,6 +273,30 @@ const initialOptions: TElements = { 'Для экскурсионных перевозок в т.ч. на торжества; трансфер в аэропорт и пр.', value: 100000013, }, + { + name: 'Дорожно-строительная техника', + value: 100000014, + }, + { + name: 'Жилищно-коммунальное хозяйство', + value: 100000015, + }, + { + name: 'Лесное хозяйство', + value: 100000016, + }, + { + name: 'Подъёмно-транспортная отрасль', + value: 100000017, + }, + { + name: 'Сельское хозяйство', + value: 100000018, + }, + { + name: 'Строительство', + value: 100000019, + }, ], objectUseFor => objectUseFor.name.toLowerCase(), ['asc'], diff --git a/src/core/types/Entities/crmEntities.ts b/src/core/types/Entities/crmEntities.ts index 0372f86..f030571 100644 --- a/src/core/types/Entities/crmEntities.ts +++ b/src/core/types/Entities/crmEntities.ts @@ -154,7 +154,6 @@ export interface IEvoLeasingObjectType { evo_vehicle_type_tax?: number; evo_vehicle_type?: number[]; } - export interface IEvoBrand { evo_name?: string; evo_brandid?: string; @@ -177,6 +176,10 @@ export interface IEvoModel { evo_baseproduct?: any; evo_vehicle_type?: number; evo_gps?: boolean; + evo_vehicle_body_typeidData?: { + evo_id_elt: string; + }; + evo_running_gear?: number; } export interface IEvoEquipment {