diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index a90492dc..7d926453 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -7087,9 +7087,10 @@ export class OrganizationController extends Controller { (x) => x.orgChild1Id == null && // x.current_holderId != null && - x.posMasterOrder <= 3 && x.isDirector === true, ) + .sort((a, b) => a.posMasterOrder - b.posMasterOrder) // Sort by posMasterOrder ASC + .slice(0, 3) // Select the first 3 rows .map(async (x) => ({ posmasterId: x.id, posNo: orgRoot.orgRootShortName + x.posMasterNo, @@ -7134,9 +7135,10 @@ export class OrganizationController extends Controller { (x) => x.orgChild2Id == null && // x.current_holderId != null && - x.posMasterOrder <= 3 && x.isDirector === true, ) + .sort((a, b) => a.posMasterOrder - b.posMasterOrder) // Sort by posMasterOrder ASC + .slice(0, 3) // Select the first 3 rows .map(async (x) => ({ posmasterId: x.id, posNo: orgChild1.orgChild1ShortName + x.posMasterNo, @@ -7189,9 +7191,10 @@ export class OrganizationController extends Controller { (x) => x.orgChild3Id == null && // x.current_holderId != null && - x.posMasterOrder <= 3 && x.isDirector === true, ) + .sort((a, b) => a.posMasterOrder - b.posMasterOrder) // Sort by posMasterOrder ASC + .slice(0, 3) // Select the first 3 rows .map(async (x) => ({ posmasterId: x.id, posNo: orgChild2.orgChild2ShortName + x.posMasterNo, @@ -7251,9 +7254,10 @@ export class OrganizationController extends Controller { (x) => x.orgChild4Id == null && // x.current_holderId != null && - x.posMasterOrder <= 3 && x.isDirector === true, ) + .sort((a, b) => a.posMasterOrder - b.posMasterOrder) // Sort by posMasterOrder ASC + .slice(0, 3) // Select the first 3 rows .map(async (x) => ({ posmasterId: x.id, posNo: orgChild3.orgChild3ShortName + x.posMasterNo, @@ -7319,8 +7323,10 @@ export class OrganizationController extends Controller { .filter( (x) => // x.current_holderId != null && - x.posMasterOrder <= 3 && x.isDirector === true, + x.isDirector === true, ) + .sort((a, b) => a.posMasterOrder - b.posMasterOrder) // Sort by posMasterOrder ASC + .slice(0, 3) // Select the first 3 rows .map(async (x) => ({ posmasterId: x.id, posNo: orgChild4.orgChild4ShortName + x.posMasterNo,