private PXAccess.Organization GetOrganizationByBAccountCD(string bAccountCD)
        {
            PXGraph   graph    = PXGraph.CreateInstance <PXGraph>();
            BAccountR bAccount = SelectFrom <BAccountR>
                                 .Where <BAccountR.acctCD.IsEqual <@P.AsString> >
                                 .View.Select(graph, bAccountCD);

            return(PXAccess.GetOrganizationByBAccountID(bAccount?.BAccountID)
                   ?? PXAccess.GetParentOrganization(PXAccess.GetBranchByBAccountID(bAccount?.BAccountID)?.BranchID));
        }
Exemple #2
0
        public override IEnumerable tree([PXString] string AcctCD)
        {
            List <BranchItem> result = new List <BranchItem>();

            foreach (PXResult <BAccountR, Branch, Organization> row in
                     SelectFrom <BAccountR>
                     .LeftJoin <Branch>
                     .On <BAccountR.bAccountID.IsEqual <Branch.bAccountID> >
                     .InnerJoin <Organization>
                     .On <Branch.organizationID.IsEqual <Organization.organizationID>
                          .Or <BAccountR.bAccountID.IsEqual <Organization.bAccountID> > >
                     .Where <Brackets <Branch.branchID.IsNull
                                       .Or <Branch.bAccountID.IsEqual <Organization.bAccountID> >
                                       .Or <Branch.branchID.IsNotNull
                                            .And <Organization.reporting1099ByBranches.IsEqual <True> > > >
                             .And <MatchWithBranch <Branch.branchID> >
                             .And <MatchWithOrganization <Organization.organizationID> >
                             .And <Branch.branchID.IsNull.Or <Branch.active.IsEqual <True> > >
                             .And <Organization.organizationID.IsNull.Or <Organization.active.IsEqual <True> > > >
                     .View
                     .Select(_Graph))
            {
                BAccountR    bAccount     = row;
                Branch       branch       = row;
                Organization organization = row;

                BranchItem item = new BranchItem
                {
                    BAccountID = bAccount.BAccountID,
                    AcctCD     = bAccount.AcctCD,
                    AcctName   = bAccount.AcctName
                };

                if (branch?.BAccountID != null && organization.BAccountID != branch.BAccountID)
                {
                    item.ParentBAccountID = PXAccess.GetParentOrganization(branch.BranchID).BAccountID;
                }

                result.Add(item);
            }
            return(result);
        }