From 699f4319695bb026e2166f40f621d3bc27a3c454 Mon Sep 17 00:00:00 2001 From: Chika Date: Mon, 30 May 2022 19:13:18 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20=D1=84=D0=B8=D0=BB=D1=8C=D1=82=D1=80=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=BF=D0=BE=D0=BB=D1=8F=20selectProduct=20(=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D1=83=20=D0=9A=D0=9F?= =?UTF-8?q?)=20=D0=B5=D1=81=D0=BB=D0=B8=20=20recalcWithRevision=3DTrue,=20?= =?UTF-8?q?=D1=82=D0=BE=20=D0=B2=20=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B5=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D1=8F=20selectProduct=20=D0=B4=D0=BE=D0=BB?= =?UTF-8?q?=D0=B6=D0=BD=D1=8B=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6?= =?UTF-8?q?=D0=B0=D1=82=D1=8C=D1=81=D1=8F=20=D0=B7=D0=B0=D0=BF=D0=B8=D1=81?= =?UTF-8?q?=D0=B8=20quote.evo=5Fbaseproductid=20=D0=B8=D0=B7=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D1=8F=20=D0=9F=D1=80=D0=B5=D0=B4=D0=BB=D0=BE=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20selectQuote=20+=20=D0=B4=D0=B0=D1=82?= =?UTF-8?q?=D1=8C=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D1=8C=20=D0=B2=D1=8B=D0=B1=D0=B8=D1=80=D0=B0=D1=82=D1=8C?= =?UTF-8?q?=20=D0=BF=D1=80=D0=BE=D0=B4=D1=83=D0=BA=D1=82,=20=D1=81=D0=B2?= =?UTF-8?q?=D1=8F=D0=B7=D0=B0=D0=BD=D0=BD=D1=8B=D0=B9=20=D1=81=20=D0=BEquo?= =?UTF-8?q?te.evo=5Fbaseproductid=20=D0=B8=D0=B7=20=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=9F=D1=80=D0=B5=D0=B4=D0=BB=D0=BE=D0=B6=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20selectQuote=20=D0=BF=D0=BE=20=D1=81=D0=B2=D1=8F?= =?UTF-8?q?=D0=B7=D0=B8=20=20evo=5Fevo=5Fbaseproduct=5Fevo=5Fbaseproduct?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/configurator/reactions/filters.ts | 28 +++++++++++++++++++ .../reactions/recalcWoRevisionReactions.ts | 1 - .../CalculationStore/config/initialFilters.ts | 4 +-- .../query/options/main_options.graphql | 5 ++++ .../query/quote/fragments/quoteFields.graphql | 1 - .../quote/fragments/quoteFieldsLite.graphql | 1 + .../services/CrmService/types/entities.ts | 1 + src/core/types/Calculation/Store/filters.ts | 9 ++++-- src/core/types/Calculation/Store/index.ts | 2 +- 9 files changed, 45 insertions(+), 7 deletions(-) diff --git a/src/client/process/configurator/reactions/filters.ts b/src/client/process/configurator/reactions/filters.ts index 37d786d..d950ee2 100644 --- a/src/client/process/configurator/reactions/filters.ts +++ b/src/client/process/configurator/reactions/filters.ts @@ -192,4 +192,32 @@ export default function ($calculation: ICalculationStore) { }, { fireImmediately: true }, ); + + /** + * @description + * Добавить фильтр для поля selectProduct (работает на загрузку КП) + * если recalcWithRevision=True, то в списке поля selectProduct должны отображаться + * записи quote.evo_baseproductid из поля Предложение selectQuote + дать возможность выбирать продукт, + * связанный с оquote.evo_baseproductid из поля Предложение selectQuote по связи evo_evo_baseproduct_evo_baseproduct + */ + reaction( + () => $calculation.getOption('selectQuote'), + quote => { + if ($calculation.getValue('recalcWithRevision')) { + const quote_product = $calculation.getOption('selectProduct', { + evo_baseproductid: quote?.evo_baseproductid, + }); + $calculation.setFilter('selectProduct', products => + products.filter(product => + quote_product?.evo_baseproducts + ?.map(x => x.evo_baseproductid) + .concat(quote?.evo_baseproductid) + .includes(product.evo_baseproductid), + ), + ); + } else { + $calculation.setFilter('selectProduct', undefined); + } + }, + ); } diff --git a/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts index 599774b..893a743 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts @@ -587,7 +587,6 @@ const elementsToDisable: (InteractionElementsNames | TableNames)[] = [ 'tablePayments', 'selectLead', 'selectOpportunity', - 'selectProduct', 'selectClientRisk', 'selectClientType', 'tbxLeasingPeriod', diff --git a/src/client/stores/CalculationStore/config/initialFilters.ts b/src/client/stores/CalculationStore/config/initialFilters.ts index 46c32bb..3b4cfda 100644 --- a/src/client/stores/CalculationStore/config/initialFilters.ts +++ b/src/client/stores/CalculationStore/config/initialFilters.ts @@ -4,10 +4,10 @@ import { TElementFilter } from 'core/types/Calculation/Store/filters'; const initialFilters: Partial> = { selectSubsidy: subsidies => subsidies.filter(x => - [100_000_000, 100_000_001].includes(x.evo_subsidy_type), + [100_000_000, 100_000_001].includes(x.evo_subsidy_type!), ), selectImportProgram: subsidies => - subsidies.filter(x => [100_000_002].includes(x.evo_subsidy_type)), + subsidies.filter(x => [100_000_002].includes(x.evo_subsidy_type!)), }; export const noResetValueElements: ElementsNames[] = [ diff --git a/src/core/services/CrmService/graphql/query/options/main_options.graphql b/src/core/services/CrmService/graphql/query/options/main_options.graphql index 33d59c1..b7f09e1 100644 --- a/src/core/services/CrmService/graphql/query/options/main_options.graphql +++ b/src/core/services/CrmService/graphql/query/options/main_options.graphql @@ -79,6 +79,11 @@ query GetMainOptions( evo_cut_proportion_bonus_director evo_cut_irr_with_bonus evo_calculation_method + evo_baseproducts { + evo_id + evo_name + evo_baseproductid + } } selectRegistration: evo_addproduct_types( statecode: $statecode 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 d2cffb9..f423869 100644 --- a/src/core/services/CrmService/graphql/query/quote/fragments/quoteFields.graphql +++ b/src/core/services/CrmService/graphql/query/quote/fragments/quoteFields.graphql @@ -65,7 +65,6 @@ fragment quoteFields on quote { evo_accept_control_addproduct_typeid evo_payment_redemption_sum - evo_baseproductid evo_client_typeid evo_supplier_currency_price evo_transactioncurrencyid diff --git a/src/core/services/CrmService/graphql/query/quote/fragments/quoteFieldsLite.graphql b/src/core/services/CrmService/graphql/query/quote/fragments/quoteFieldsLite.graphql index d9e5606..69b84fe 100644 --- a/src/core/services/CrmService/graphql/query/quote/fragments/quoteFieldsLite.graphql +++ b/src/core/services/CrmService/graphql/query/quote/fragments/quoteFieldsLite.graphql @@ -24,4 +24,5 @@ fragment quoteFieldsLite on quote { evo_one_year_insurance evo_last_payment_perc evo_purchases_participation + evo_baseproductid } diff --git a/src/core/services/CrmService/types/entities.ts b/src/core/services/CrmService/types/entities.ts index 3508472..f44285c 100644 --- a/src/core/services/CrmService/types/entities.ts +++ b/src/core/services/CrmService/types/entities.ts @@ -213,6 +213,7 @@ export interface IEvoBaseproduct extends BaseEntity { evo_cut_proportion_bonus_director?: boolean; evo_cut_irr_with_bonus?: boolean; evo_calculation_method?: number[]; + evo_baseproducts?: IEvoBaseproduct[]; } export interface IEvoLeasingObjectType extends BaseEntity { diff --git a/src/core/types/Calculation/Store/filters.ts b/src/core/types/Calculation/Store/filters.ts index fd316ef..8503645 100644 --- a/src/core/types/Calculation/Store/filters.ts +++ b/src/core/types/Calculation/Store/filters.ts @@ -1,4 +1,9 @@ -import { TOptionizedEntity } from 'core/services/CrmService/types/common'; +import { + IBaseOption, + TOptionizedEntity, +} from 'core/services/CrmService/types/common'; +import { CRMEntity } from 'core/services/CrmService/types/entities'; + export type TElementFilter = ( - options: TOptionizedEntity[], + options: (IBaseOption & CRMEntity)[], ) => TOptionizedEntity[]; diff --git a/src/core/types/Calculation/Store/index.ts b/src/core/types/Calculation/Store/index.ts index 24137d2..7157ce7 100644 --- a/src/core/types/Calculation/Store/index.ts +++ b/src/core/types/Calculation/Store/index.ts @@ -39,7 +39,7 @@ interface ICalculationValues { options: Record; getOption: ( elementName: ElementsNames, - fields?: { [field in keyof TOptionizedEntity]?: any }, + fields?: { [field in keyof (IBaseOption & CRMEntity)]?: any }, ) => (IBaseOption & CRMEntity) | undefined; getOptions: ( elementName: ElementsNames,