From 43c194b18ab4f5a748983934949e8d5b55ff194d Mon Sep 17 00:00:00 2001 From: Chika Date: Thu, 27 Jan 2022 13:03:08 +0300 Subject: [PATCH 1/2] calculationStore: fix subsidy reactions --- .../Effects/reactions/otherReactions.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts index a4398d0..adad752 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts @@ -1710,7 +1710,7 @@ const reactionEffects: IReactionEffect[] = [ brand, brand => - brand?.evo_vehicle_type && + brand?.evo_vehicle_type?.length && intersection( brand.evo_vehicle_type?.filter(x => x > 0), leaseObjectType.evo_vehicle_type, @@ -1719,7 +1719,7 @@ const reactionEffects: IReactionEffect[] = [ brand => brand && - (!subsidy?.evo_brands || + (!subsidy?.evo_brands?.length || subsidy?.evo_brands?.filter( x => x.evo_brandid === brand.evo_brandid, )?.length), @@ -1773,7 +1773,7 @@ const reactionEffects: IReactionEffect[] = [ calculationStore.setFilter('selectLeaseObjectType', types => types.filter( type => - !subsidy?.evo_leasingobject_types || + !subsidy?.evo_leasingobject_types?.length || subsidy.evo_leasingobject_types.filter( x => x.evo_leasingobject_typeid === type.evo_leasingobject_typeid, )?.length, @@ -1783,7 +1783,7 @@ const reactionEffects: IReactionEffect[] = [ calculationStore.setFilter('selectDealer', dealers => dealers.filter( dealer => - !subsidy?.accounts || + !subsidy?.accounts?.length || subsidy.accounts.filter(x => x.accountid === dealer.accountid) ?.length, ), @@ -1792,7 +1792,7 @@ const reactionEffects: IReactionEffect[] = [ calculationStore.setFilter('selectDealerPerson', dealerPersons => dealerPersons.filter( dealerPerson => - !subsidy?.accounts || + !subsidy?.accounts?.length || subsidy.accounts.filter(x => x.accountid === dealerPerson.accountid) ?.length, ), From a9b0eee6bf8ca57829982856953e5497b848709f Mon Sep 17 00:00:00 2001 From: Chika Date: Thu, 27 Jan 2022 13:21:41 +0300 Subject: [PATCH 2/2] calculationStore: fix selectFuelCard filter --- .../Effects/reactions/otherReactions.ts | 29 ------------------- .../CalculationStore/config/initialFilters.ts | 5 +--- 2 files changed, 1 insertion(+), 33 deletions(-) diff --git a/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts index adad752..7065651 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts @@ -1469,35 +1469,6 @@ const reactionEffects: IReactionEffect[] = [ }, }), - (calculationStore, calculationProcess) => ({ - expression: () => { - return calculationStore.getValue('leasingPeriod'); - }, - effect: () => { - if (calculationProcess.hasProcess(Process.LoadKp)) { - return; - } - - const fuelCard = calculationStore.getOption('selectFuelCard'); - if (fuelCard) { - const selectFuelCard_filter = - calculationStore.getFilter('selectFuelCard'); - const selectFueldCard_options = - calculationStore.getOptions('selectFuelCard'); - - if (selectFuelCard_filter && selectFueldCard_options) { - const filtered_technicalCards = selectFuelCard_filter( - selectFueldCard_options, - ); - calculationStore.setValue( - 'fuelCard', - filtered_technicalCards?.[0]?.evo_addproduct_typeid, - ); - } - } - }, - }), - calculationStore => ({ expression: () => { const { diff --git a/src/client/stores/CalculationStore/config/initialFilters.ts b/src/client/stores/CalculationStore/config/initialFilters.ts index a84cd75..96bd1a1 100644 --- a/src/client/stores/CalculationStore/config/initialFilters.ts +++ b/src/client/stores/CalculationStore/config/initialFilters.ts @@ -6,9 +6,6 @@ import { TElementFilter } from 'core/types/Calculation/Store/filters'; const initialFilters: TElements = {}; -export const noResetValueElements: ElementsNames[] = [ - 'selectTechnicalCard', - 'selectFuelCard', -]; +export const noResetValueElements: ElementsNames[] = ['selectTechnicalCard']; export default initialFilters;