From f2c647a44d8fb4f761eb8d73eccb02418d168383 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Thu, 3 Jun 2021 18:07:59 +0300 Subject: [PATCH] selectRegistration filter --- .../Effects/reactions/gibddReactions.ts | 50 +++++++++++++------ 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/src/client/stores/CalculationStore/Effects/reactions/gibddReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/gibddReactions.ts index d6724ad..92e1fb9 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/gibddReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/gibddReactions.ts @@ -355,21 +355,41 @@ const gibddReactions: IReactionEffect[] = [ typePTS, }) => { calculationStore.setFilter('selectRegistration', options => - options.filter(x => { - return ( - x.evo_whom_register === objectRegistration && - (typePTS - ? x.evo_pts_type && - x.evo_pts_type.filter(x => x > 0).includes(typePTS) - : true) && - x.evo_gibdd_region === - (objectRegionRegistration.evo_regionid === regionRegistration) && - (x.accountid - ? objectRegionRegistration.accounts - .map(x => x.accountid) - .includes(x.evo_accountid) - : true) - ); + options.filter((x, i) => { + if (!(x.evo_whom_register === objectRegistration)) { + return false; + } + + if ( + !( + x.evo_gibdd_region === + (objectRegionRegistration.evo_regionid === regionRegistration) + ) + ) { + return false; + } + + if ( + (typePTS && + (!x.evo_pts_type || + x.evo_pts_type.filter(t => t > 0).length === 0)) || + x.evo_pts_type?.filter(t => t > 0).includes(typePTS) === false + ) { + return false; + } + + if ( + (x.evo_accountid && + (!objectRegionRegistration.accounts || + objectRegionRegistration.accounts.length === 0)) || + objectRegionRegistration.accounts + .map(r => r.accountid) + .includes(x.evo_accountid) === false + ) { + return false; + } + + return true; }), ); },