From f725d48fb90e01bca6106d0d1a752bab01882363 Mon Sep 17 00:00:00 2001 From: Chika Date: Thu, 21 Apr 2022 11:49:45 +0300 Subject: [PATCH] =?UTF-8?q?loadKP:=20=D1=81=D1=82=D0=B0=D1=82=D1=83=D1=81?= =?UTF-8?q?=D1=8B=20=D0=B3=D1=80=D0=B0=D1=84=D0=B8=D0=BA=D0=B0=20=D1=81=20?= =?UTF-8?q?=D0=B3=D0=B8=D0=B1=D0=BA=D0=BE=D0=B9=20=D0=B4=D0=B5=D0=B3=D1=80?= =?UTF-8?q?=D0=B5=D1=81=D1=81=D0=B8=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Effects/reactions/loadKpReaction/index.ts | 22 +++++++++++-------- .../services/CrmService/types/entities.ts | 1 + 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts index b833910..6502f48 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts @@ -3,7 +3,7 @@ import { resetIns } from 'client/Containers/Calculation/Components/ELT/lib/reset import { numberElementsProps } from 'client/Containers/Calculation/Elements/props/common'; import { getTitle, - getValueName, + getValueName } from 'client/Containers/Calculation/Elements/tools'; import { ElementsNames } from 'client/Containers/Calculation/types/elements'; import { openNotification } from 'client/Elements/Notification'; @@ -13,7 +13,7 @@ import { mainOptionsForQuoteQuery, quoteQuery, secondaryOptionsForQuoteQuery, - singleOptionsForQuoteQuery, + singleOptionsForQuoteQuery } from 'core/services/CrmService/graphql/query/quote'; import { TOptionizedEntity } from 'core/services/CrmService/types/common'; import { @@ -21,7 +21,7 @@ import { IAccount, IEvoGraph, IEvoTown, - IQuote, + IQuote } from 'core/services/CrmService/types/entities'; import { currentISODate } from 'core/tools/date'; import { NIL } from 'core/tools/uuid'; @@ -40,10 +40,12 @@ const map_add_product_types_to_values = { fuelCard: 100000005, }; -const tablePaymentsStatuses = (graphType, leasingPeriod) => { +const tablePaymentsStatuses = (graphType, seasonType, leasingPeriod) => { switch (graphType) { case 100000001: { - return Array.from({ length: leasingPeriod - 3 }, (_, i) => i + 2); + if (seasonType === 100_000_007) + return Array.from({ length: leasingPeriod - 3 }, (_, i) => i + 2); + break; } case 100000003: { return Array.from({ length: 12 }, (_, i) => i + 1); @@ -248,16 +250,18 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ (a, b) => b.createdon - a.createdon, )[0]; if (evo_graph.evo_planpayments) { + const statuses = tablePaymentsStatuses( + quote.evo_graph_type, + quote.evo_seasons_type, + quote.evo_period, + ); const payments = evo_graph.evo_planpayments .slice(1, evo_graph.evo_planpayments.length - 1) .map((evo_planpayment, i) => ({ paymentRelation: { validation: undefined, value: evo_planpayment.evo_payment_ratio, - status: tablePaymentsStatuses( - quote.evo_graph_type, - quote.evo_period, - )?.includes(i + 1) + status: statuses?.includes(i + 1) ? ElementStatus.Default : ElementStatus.Disabled, }, diff --git a/src/core/services/CrmService/types/entities.ts b/src/core/services/CrmService/types/entities.ts index 1296bda..a630834 100644 --- a/src/core/services/CrmService/types/entities.ts +++ b/src/core/services/CrmService/types/entities.ts @@ -102,6 +102,7 @@ export interface IOpportunity extends BaseEntity { } export interface IQuote extends BaseEntity { + evo_seasons_type?: number; evo_engine_hours?: number; evo_client_riskid?: string; evo_addproduct_types?: IEvoAddproductType[];