diff --git a/src/client/Containers/Calculation/Components/ELT/Kasko/lib/composeRequest.ts b/src/client/Containers/Calculation/Components/ELT/Kasko/lib/composeRequest.ts index 592b665..fcf0966 100644 --- a/src/client/Containers/Calculation/Components/ELT/Kasko/lib/composeRequest.ts +++ b/src/client/Containers/Calculation/Components/ELT/Kasko/lib/composeRequest.ts @@ -186,6 +186,12 @@ export default function (this: ICalculationStore) { mileage = 0; } + let vin; + + if (leaseObjectUsed === true) { + vin = this.getValue('vin'); + } + const mileageSpecified = getSpecified(mileage); let vehicleUsage = 0; @@ -305,6 +311,7 @@ export default function (this: ICalculationStore) { risk, payType: '0', vehicle: { + vin, maxAllowedMass, maxAllowedMassSpecified, mileage, diff --git a/src/client/Containers/Calculation/Components/ELT/Kasko/lib/validation.ts b/src/client/Containers/Calculation/Components/ELT/Kasko/lib/validation.ts index 46f0cf1..576e20d 100644 --- a/src/client/Containers/Calculation/Components/ELT/Kasko/lib/validation.ts +++ b/src/client/Containers/Calculation/Components/ELT/Kasko/lib/validation.ts @@ -118,6 +118,7 @@ export const resetFields: ElementsNames[] = [ 'tbxInsExpDrivers', 'selectLegalClientTown', 'selectLegalClientRegion', + 'tbxVIN', ]; export default { diff --git a/src/client/Containers/Calculation/Components/Sections/sectionsList.ts b/src/client/Containers/Calculation/Components/Sections/sectionsList.ts index 4863b05..36bb55b 100644 --- a/src/client/Containers/Calculation/Components/Sections/sectionsList.ts +++ b/src/client/Containers/Calculation/Components/Sections/sectionsList.ts @@ -200,7 +200,7 @@ const sections: ISection[] = [ ], }, { - elements: ['tbxMaxSpeed', 'tbxCountSeats', 'tbxMileage'], + elements: ['tbxMaxSpeed', 'tbxCountSeats', 'tbxMileage', 'tbxVIN'], }, ], }, diff --git a/src/client/Containers/Calculation/Elements/components.ts b/src/client/Containers/Calculation/Elements/components.ts index 7086211..0281b49 100644 --- a/src/client/Containers/Calculation/Elements/components.ts +++ b/src/client/Containers/Calculation/Elements/components.ts @@ -136,6 +136,7 @@ export default { tbxMinPriceChange: InputNumber, selectImportProgram: Select, tbxAddEquipmentPrice: InputNumber, + tbxVIN: Input, /** Computed Elements */ labelLeaseObjectRisk: Label, diff --git a/src/client/Containers/Calculation/Elements/titles.ts b/src/client/Containers/Calculation/Elements/titles.ts index d7fc8e0..2c76640 100644 --- a/src/client/Containers/Calculation/Elements/titles.ts +++ b/src/client/Containers/Calculation/Elements/titles.ts @@ -129,6 +129,7 @@ export const elementsTitles: Partial> = { selectImportProgram: 'Программа от производителя', labelImportProgramSum: 'Скидка от производителя, руб., с НДС', tbxAddEquipmentPrice: 'Стоимость доп.оборудования', + tbxVIN: 'VIN', /** Result Elements */ labelResultTotalGraphwithNDS: 'Итого по графику, с НДС', diff --git a/src/client/Containers/Calculation/Elements/values.ts b/src/client/Containers/Calculation/Elements/values.ts index e0d32fd..54d2ba6 100644 --- a/src/client/Containers/Calculation/Elements/values.ts +++ b/src/client/Containers/Calculation/Elements/values.ts @@ -135,6 +135,7 @@ const elementsValues: Record = { tbxMinPriceChange: 'minPriceChange', selectImportProgram: 'importProgram', tbxAddEquipmentPrice: 'addEquipmentPrice', + tbxVIN: 'vin', /** Result Elements */ labelResultTotalGraphwithNDS: 'resultTotalGraphwithNDS', diff --git a/src/client/Containers/Calculation/types/elements.ts b/src/client/Containers/Calculation/types/elements.ts index e2ecadb..af99b4c 100644 --- a/src/client/Containers/Calculation/types/elements.ts +++ b/src/client/Containers/Calculation/types/elements.ts @@ -122,6 +122,7 @@ export type ElementsNames = | 'tbxLeaseObjectPriceWthtVAT' | 'tbxVATInLeaseObjectPrice' | 'tbxAddEquipmentPrice' + | 'tbxVIN' /** Result Elements */ | 'labelResultTotalGraphwithNDS' | 'labelResultPlPrice' diff --git a/src/client/process/used-pl/reactions.ts b/src/client/process/used-pl/reactions.ts index f2d1f94..834cc53 100644 --- a/src/client/process/used-pl/reactions.ts +++ b/src/client/process/used-pl/reactions.ts @@ -338,4 +338,46 @@ export default function ($calculation: ICalculationStore) { }); }, ); + + /** VIN */ + + const vinRegex = /^[A-HJ-NPR-Za-hj-npr-z0-9]+$/; + + reaction( + () => { + return { + ...$calculation.getValues([ + 'vin', + 'leaseObjectCategory', + 'leaseObjectUsed', + ]), + }; + }, + ({ vin }) => { + if (vin) { + if ($calculation.getValue('leaseObjectCategory')) { + $calculation.setValidation( + 'tbxVIN', + vin.length === 17 && vinRegex.test(vin), + ); + } else { + $calculation.setValidation('tbxVIN', vinRegex.test(vin)); + } + } + }, + ); + + reaction( + () => { + return $calculation.getValue('leaseObjectUsed'); + }, + leaseObjectUsed => { + if (leaseObjectUsed) { + $calculation.setStatus('tbxVIN', ElementStatus.Default); + } else { + $calculation.setValue('vin', undefined); + $calculation.setStatus('tbxVIN', ElementStatus.Disabled); + } + }, + ); } diff --git a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts index 4ad2969..c24fb8c 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts @@ -98,6 +98,7 @@ const mapKPtoValues: Partial> = { evo_subsidy_summ: 'subsidySum', evo_program_import_subsidyid: 'importProgram', evo_equip_price: 'addEquipmentPrice', + evo_vin: 'vin', }; export function getValuesFromKP(quote: IQuote) { diff --git a/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts index b324018..56eefd7 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts @@ -633,6 +633,7 @@ const elementsToDisable: (InteractionElementsNames | TableNames)[] = [ 'tbxEngineHours', 'selectImportProgram', 'tbxAddEquipmentPrice', + 'tbxVIN', ]; // Для recalc = true и первого платежа = 0 diff --git a/src/core/services/CrmService/graphql/query/quote/fragments/quoteFields.graphql b/src/core/services/CrmService/graphql/query/quote/fragments/quoteFields.graphql index 904592e..4701cdf 100644 --- a/src/core/services/CrmService/graphql/query/quote/fragments/quoteFields.graphql +++ b/src/core/services/CrmService/graphql/query/quote/fragments/quoteFields.graphql @@ -139,4 +139,5 @@ fragment quoteFields on quote { evo_equip_price evo_accept_period evo_db_accept_registration + evo_vin } diff --git a/src/core/services/CrmService/types/entities.ts b/src/core/services/CrmService/types/entities.ts index 741b7b7..efc0f53 100644 --- a/src/core/services/CrmService/types/entities.ts +++ b/src/core/services/CrmService/types/entities.ts @@ -104,6 +104,7 @@ export interface IOpportunity extends BaseEntity { } export interface IQuote extends BaseEntity { + evo_vin: string; evo_seasons_type?: number; evo_engine_hours?: number; evo_client_riskid?: string; diff --git a/src/core/types/Calculation/Store/values.ts b/src/core/types/Calculation/Store/values.ts index 76d77b5..0c5a5c1 100644 --- a/src/core/types/Calculation/Store/values.ts +++ b/src/core/types/Calculation/Store/values.ts @@ -118,6 +118,7 @@ export type ValuesNames = | 'subsidySum' | 'fuelCard' | 'minPriceChange' + | 'vin' | 'resultTotalGraphwithNDS' | 'resultPlPrice' | 'resultPriceUpPr'