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,