From 6f12b8b448a1dd181c82a2ea39f8ec111a224b4f Mon Sep 17 00:00:00 2001 From: Chika Date: Mon, 5 Sep 2022 13:53:18 +0300 Subject: [PATCH 1/4] merge release/dyn-1488_vin --- .../ELT/Kasko/lib/composeRequest.ts | 7 ++++ .../Components/Sections/sectionsList.ts | 2 +- .../Calculation/Elements/components.ts | 1 + .../Containers/Calculation/Elements/titles.ts | 1 + .../Containers/Calculation/Elements/values.ts | 1 + .../Containers/Calculation/types/elements.ts | 1 + src/client/process/used-pl/reactions.ts | 34 +++++++++++++++++++ .../reactions/loadKpReaction/mapKpToValues.ts | 1 + .../reactions/recalcWoRevisionReactions.ts | 1 + .../query/quote/fragments/quoteFields.graphql | 1 + .../services/CrmService/types/entities.ts | 1 + src/core/types/Calculation/Store/values.ts | 1 + 12 files changed, 51 insertions(+), 1 deletion(-) 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/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..bd9f5b2 100644 --- a/src/client/process/used-pl/reactions.ts +++ b/src/client/process/used-pl/reactions.ts @@ -338,4 +338,38 @@ export default function ($calculation: ICalculationStore) { }); }, ); + + /** VIN */ + + const vinRegex = /^[A-HJ-NPR-Za-hj-npr-z0-9]+$/; + + reaction( + () => { + return $calculation.getValue('vin'); + }, + 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' From 531c6cd26652d7352bebbd436a948b60d8ac17df Mon Sep 17 00:00:00 2001 From: Chika Date: Mon, 5 Sep 2022 14:24:28 +0300 Subject: [PATCH 2/4] =?UTF-8?q?reactions:=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5?= =?UTF-8?q?=D1=80=D0=BA=D0=B0=20vin.=20=D1=82=D1=80=D0=B8=D0=B3=D0=B3?= =?UTF-8?q?=D0=B5=D1=80=D1=8B:=20vin,=20leaseObjectCategory,=20leaseObject?= =?UTF-8?q?Used?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/process/used-pl/reactions.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/client/process/used-pl/reactions.ts b/src/client/process/used-pl/reactions.ts index bd9f5b2..462b881 100644 --- a/src/client/process/used-pl/reactions.ts +++ b/src/client/process/used-pl/reactions.ts @@ -345,9 +345,15 @@ export default function ($calculation: ICalculationStore) { reaction( () => { - return $calculation.getValue('vin'); + return { + ...$calculation.getValues([ + 'vin', + 'leaseObjectCategory', + 'leaseObjectUsed', + ]), + }; }, - vin => { + ({ vin }) => { if ($calculation.getValue('leaseObjectCategory')) { $calculation.setValidation( 'tbxVIN', From d693d40912d3486a3787618aaaad8a3d6c07fee7 Mon Sep 17 00:00:00 2001 From: Chika Date: Mon, 5 Sep 2022 14:31:27 +0300 Subject: [PATCH 3/4] =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD?= =?UTF-8?q?=D0=B4=D1=80=20=D0=A1=D0=B5=D0=BC=D0=BA=D0=B8=D0=BD,=20[05.09.2?= =?UTF-8?q?022=2014:30]=20=D1=82.=D0=B5.=20=D0=B2=D0=B5=D1=80=D0=B8=D1=84?= =?UTF-8?q?=D0=B8=D0=BA=D0=B0=D1=86=D0=B8=D1=8F=20=D0=BF=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=BE=D0=B4=D0=B8=D1=82=D1=81=D1=8F=20=D1=82=D0=BE=D0=BB=D1=8C?= =?UTF-8?q?=D0=BA=D0=BE=20=D0=B2=20=D1=81=D0=BB=D1=83=D1=87=D0=B0=D0=B5=20?= =?UTF-8?q?=D0=BD=D0=B0=D0=BB=D0=B8=D1=87=D0=B8=D1=8F=20=D0=B7=D0=BD=D0=B0?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B2=20=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Александр Семкин, [05.09.2022 14:30] т.е. я могу сделать расчет и без VIN --- src/client/process/used-pl/reactions.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/client/process/used-pl/reactions.ts b/src/client/process/used-pl/reactions.ts index 462b881..834cc53 100644 --- a/src/client/process/used-pl/reactions.ts +++ b/src/client/process/used-pl/reactions.ts @@ -354,13 +354,15 @@ export default function ($calculation: ICalculationStore) { }; }, ({ vin }) => { - if ($calculation.getValue('leaseObjectCategory')) { - $calculation.setValidation( - 'tbxVIN', - vin.length === 17 && vinRegex.test(vin), - ); - } else { - $calculation.setValidation('tbxVIN', vinRegex.test(vin)); + if (vin) { + if ($calculation.getValue('leaseObjectCategory')) { + $calculation.setValidation( + 'tbxVIN', + vin.length === 17 && vinRegex.test(vin), + ); + } else { + $calculation.setValidation('tbxVIN', vinRegex.test(vin)); + } } }, ); From df01646921e4cdffdb5e67bcc2f03b768d1c1804 Mon Sep 17 00:00:00 2001 From: Chika Date: Mon, 5 Sep 2022 14:37:54 +0300 Subject: [PATCH 4/4] =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD?= =?UTF-8?q?=D0=B4=D1=80=20=D0=A1=D0=B5=D0=BC=D0=BA=D0=B8=D0=BD,=20[05.09.2?= =?UTF-8?q?022=2014:33]=20=D0=92=D0=BB=D0=B0=D0=B4,=20=D0=B8=20=D0=B5?= =?UTF-8?q?=D1=89=D0=B5=20-=20=D0=B5=D1=81=D0=BB=D0=B8=20VIN=20=D1=83?= =?UTF-8?q?=D0=BA=D0=B0=D0=B7=D0=B0=D0=BD=20=D0=B8=20=D0=B5=D0=B3=D0=BE=20?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=8F=D1=8E=D1=82=20=D0=98=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B8=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=20=D1=80=D0=B0=D1=81=D1=87?= =?UTF-8?q?=D0=B5=D1=82=20=D0=AD=D0=9B=D0=A2=20=D0=9A=D0=90=D0=A1=D0=9A?= =?UTF-8?q?=D0=9E,=20=D1=82=D0=BE=20=D1=80=D0=B0=D1=81=D1=87=D0=B5=D1=82?= =?UTF-8?q?=20=D0=AD=D0=9B=D0=A2=20=D0=9A=D0=90=D0=A1=D0=9A=D0=9E=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=BB=D0=B6=D0=B5=D0=BD=20=D1=81=D0=BB=D0=B5=D1=82=D0=B0?= =?UTF-8?q?=D1=82=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Александр Семкин, [05.09.2022 14:34] потому что если они VIN меняют, то это совсем другой расчет может быть --- .../Calculation/Components/ELT/Kasko/lib/validation.ts | 1 + 1 file changed, 1 insertion(+) 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 {