Exemplo n.º 1
0
        protected virtual bool IsSourceInterlacingWithDictionary(GLAllocationSource aSrc, Dictionary <AllocationProcess.BranchAccountSubKey, AllocationSourceDetail> aSrcDict)
        {
            string acctCDWildCard = SubCDUtils.CreateSubCDWildcard(aSrc.AccountCD, AccountAttribute.DimensionName);
            string subCDWildCard  = SubCDUtils.CreateSubCDWildcard(aSrc.SubCD, SubAccountAttribute.DimensionName);

            foreach (Account iAcct in PXSelect <Account, Where <Account.accountCD, Like <Required <Account.accountCD> > > > .Select(this, acctCDWildCard))
            {
                foreach (Sub iSub in PXSelect <Sub, Where <Sub.subCD, Like <Required <Sub.subCD> > > > .Select(this, subCDWildCard))
                {
                    AllocationProcess.BranchAccountSubKey key = new AllocationProcess.BranchAccountSubKey(aSrc.BranchID.Value, iAcct.AccountID.Value, iSub.SubID.Value);
                    if (aSrcDict.ContainsKey(key))
                    {
                        return(true);
                    }
                    else
                    {
                        AllocationSourceDetail detail = new AllocationSourceDetail(aSrc);

                        detail.AccountID = iAcct.AccountID;
                        detail.SubID     = iSub.SubID;
                        if (detail.ContraAccountID != null && detail.ContraSubID == null)
                        {
                            detail.ContraSubID = detail.SubID;
                        }
                        aSrcDict[key] = detail;
                    }
                }
            }
            return(false);
        }
Exemplo n.º 2
0
        public virtual IEnumerable showPreload(PXAdapter adapter)
        {
            GLBudgetTree parentNode = PXSelect <GLBudgetTree, Where <GLBudgetTree.groupID, Equal <Required <GLBudgetTree.groupID> > > > .Select(this, this.CurrentSelected.Group);

            PXStringState subStrState = (PXStringState)Details.Cache.GetStateExt(null, typeof(GLBudgetTree.subID).Name);
            string        subWildCard = new String('?', subStrState.InputMask.Length - 1);

            if (parentNode != null)
            {
                PreloadFilter.Current.AccountCDWildcard = SubCDUtils.CreateSubCDWildcard(parentNode != null ? parentNode.AccountMask : string.Empty, AccountAttribute.DimensionName);
                if (parentNode.AccountMask != null)
                {
                    Account AcctFrom = PXSelect <Account, Where <Account.active, Equal <True>,
                                                                 And <Account.accountCD, Like <Required <SelectedNode.accountMaskWildcard> > > >,
                                                 OrderBy <Asc <Account.accountCD> > > .SelectWindowed(this, 0, 1, PreloadFilter.Current.AccountCDWildcard);

                    Account AcctTo = PXSelect <Account, Where <Account.active, Equal <True>,
                                                               And <Account.accountCD, Like <Required <AccountsPreloadFilter.accountCDWildcard> > > >,
                                               OrderBy <Desc <Account.accountCD> > > .SelectWindowed(this, 0, 1, PreloadFilter.Current.AccountCDWildcard);

                    PreloadFilter.Current.FromAccount = AcctFrom != null ? AcctFrom.AccountID : null;
                    PreloadFilter.Current.ToAccount   = AcctTo != null ? AcctTo.AccountID : null;
                }
                else
                {
                    PreloadFilter.Current.FromAccount = null;
                    PreloadFilter.Current.ToAccount   = null;
                }
                PreloadFilter.Current.SubIDFilter = parentNode.SubMask ?? subWildCard;
            }
            else
            {
                PreloadFilter.Current.FromAccount = null;
                PreloadFilter.Current.ToAccount   = null;
                PreloadFilter.Current.SubIDFilter = subWildCard;
            }
            if (PreloadFilter.Current != null)
            {
                if (parentNode != null)
                {
                    if (parentNode.AccountMask != null && PreloadFilter.Current.FromAccount == null)
                    {
                        if (Details.Ask(Messages.BudgetTreePreloadArticlesTitle, String.Format(PXMessages.LocalizeNoPrefix(Messages.BudgetTreePreloadArticlesMessage), parentNode.AccountMask), MessageButtons.OK) == WebDialogResult.OK)
                        {
                            return(adapter.Get());
                        }
                    }
                }
            }
            Details.AskExt();
            return(adapter.Get());
        }
Exemplo n.º 3
0
        protected virtual bool ValidateSrcAccountsForCurrency()
        {
            PXSelectBase <Account> acctSel = new PXSelect <Account, Where <Account.accountCD, Like <Required <Account.accountCD> >,
                                                                           And <Account.curyID, IsNotNull, And <Account.curyID, NotEqual <Current <Company.baseCuryID> > > > > >(this);

            foreach (GLAllocationSource iSrc in this.Source.Select())
            {
                string acctCDWildCard = SubCDUtils.CreateSubCDWildcard(iSrc.AccountCD, AccountAttribute.DimensionName);
                foreach (Account iAcct in acctSel.Select(acctCDWildCard))
                {
                    if (iAcct != null)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Exemplo n.º 4
0
        protected virtual IEnumerable details(
            [PXGuid]
            Guid?groupID
            )
        {
            if (groupID == null)
            {
                groupID = this.Tree.Current != null
                                                                ? this.Tree.Current.GroupID
                                                                : Guid.Empty;
            }

            this.CurrentSelected.Group = groupID;

            GLBudgetTree parentNode = PXSelect <GLBudgetTree, Where <GLBudgetTree.groupID, Equal <Required <GLBudgetTree.groupID> > > > .Select(this, this.CurrentSelected.Group);

            if (parentNode != null)
            {
                this.CurrentSelected.AccountID = parentNode.AccountID != null ? parentNode.AccountID : Int32.MinValue;
                this.CurrentSelected.SubID     = parentNode.SubID != null ? parentNode.SubID : Int32.MinValue;
                this.CurrentSelected.GroupMask = parentNode.GroupMask;
            }
            else
            {
                this.CurrentSelected.AccountID = Int32.MinValue;
                this.CurrentSelected.SubID     = Int32.MinValue;
                this.CurrentSelected.GroupMask = null;
            }
            this.CurrentSelected.AccountMaskWildcard = SubCDUtils.CreateSubCDWildcard(parentNode != null ? parentNode.AccountMask : string.Empty, AccountAttribute.DimensionName);
            this.CurrentSelected.SubMaskWildcard     = parentNode != null ? parentNode.SubMask : string.Empty;

            List <GLBudgetTree> nodes = new List <GLBudgetTree>();

            foreach (GLBudgetTree node in PXSelect <GLBudgetTree,
                                                    Where <GLBudgetTree.parentGroupID, Equal <Required <GLBudgetTree.parentGroupID> >,
                                                           And <GLBudgetTree.parentGroupID, NotEqual <GLBudgetTree.groupID>,
                                                                And <Match <Current <AccessInfo.userName> > > > > > .Select(this, groupID))
            {
                if (node.GroupMask != null)
                {
                    foreach (byte b in node.GroupMask)
                    {
                        if (b != 0x00)
                        {
                            node.Secured = true;
                        }
                    }
                }
                nodes.Add(node);
            }

            if (PXSelect <GLBudgetTree, Where <GLBudgetTree.groupID, Equal <Required <GLBudgetTree.groupID> >, And <Match <Current <AccessInfo.userName> > > > > .Select(this, groupID).Count == 0 && groupID != Guid.Empty)
            {
                Details.Cache.AllowInsert = false;
                Details.Cache.AllowDelete = false;
                Details.Cache.AllowUpdate = false;
            }
            else
            {
                Details.Cache.AllowInsert = true;
                Details.Cache.AllowDelete = true;
                Details.Cache.AllowUpdate = true;
            }

            return(nodes);
        }
Exemplo n.º 5
0
        public virtual IEnumerable preload(PXAdapter adapter)
        {
            if (PreloadFilter.Current.FromAccount == null)
            {
                PreloadFilter.Cache.RaiseExceptionHandling <AccountsPreloadFilter.fromAccount>(PreloadFilter.Current, PreloadFilter.Current.FromAccount, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, PXErrorLevel.RowError));
                PreloadFilter.Cache.RaiseExceptionHandling <AccountsPreloadFilter.toAccount>(PreloadFilter.Current, PreloadFilter.Current.ToAccount, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, PXErrorLevel.RowError));
                return(adapter.Get());
            }
            GLBudgetTree currentItem = ((GLBudgetTree)PXSelect <GLBudgetTree,
                                                                Where <GLBudgetTree.groupID,
                                                                       Equal <Required <GLBudgetTree.groupID> > > > .Select(this, this.CurrentSelected.Group));

            PreloadFilter.Current.AccountCDWildcard = SubCDUtils.CreateSubCDWildcard(currentItem != null ? currentItem.AccountMask : string.Empty, AccountAttribute.DimensionName);

            GLBudgetTree LastItem = PXSelect <GLBudgetTree,
                                              Where <GLBudgetTree.parentGroupID,
                                                     Equal <Required <GLBudgetTree.parentGroupID> > >, OrderBy <Desc <GLBudgetTree.sortOrder> > > .SelectWindowed(this, 0, 1, this.CurrentSelected.Group);

            int  LastSortNum                  = LastItem == null ? 1 : LastItem.SortOrder.Value + 1;
            bool noLinesPreloaded             = true;
            List <GLBudgetTree> nodesToInsert = new List <GLBudgetTree>();

            foreach (PXResult <Account> account in PXSelect <Account, Where <Account.accountCD,
                                                                             GreaterEqual <Required <Account.accountCD> >,
                                                                             And <Account.active, Equal <True>,
                                                                                  And <Account.accountCD, LessEqual <Required <Account.accountCD> >,
                                                                                       And <Account.accountID, NotEqual <Current <GL.GLSetup.ytdNetIncAccountID> > > > > > > .Select(this,
                                                                                                                                                                                     PreloadFilter.Current.FromAccount != null ?
                                                                                                                                                                                     ((Account)PXSelect <Account, Where <Account.accountID, Equal <Current <AccountsPreloadFilter.fromAccount> > > > .Select(this)).AccountCD :
                                                                                                                                                                                     ((Account)PXSelect <Account> .Select(this).First()).AccountCD,
                                                                                                                                                                                     PreloadFilter.Current.ToAccount != null ?
                                                                                                                                                                                     ((Account)PXSelect <Account, Where <Account.accountID, Equal <Current <AccountsPreloadFilter.toAccount> > > > .Select(this)).AccountCD :
                                                                                                                                                                                     ((Account)PXSelect <Account> .Select(this).Last()).AccountCD))
            {
                foreach (PXResult <Sub> sub in PXSelect <Sub, Where <Sub.active, Equal <True>, And <Sub.subCD, Like <Current <AccountsPreloadFilter.subCDWildcard> > > > > .Select(this))
                {
                    Account      acct    = account;
                    Sub          subAcct = sub;
                    GLBudgetTree group   = new GLBudgetTree();
                    if (currentItem == null || acct.AccountID != currentItem.AccountID || subAcct.SubID != currentItem.SubID)
                    {
                        group.AccountID = acct.AccountID;
                        group.SubID     = subAcct.SubID;

                        group.SortOrder = LastSortNum++;

                        group.GroupMask = CurrentSelected.GroupMask;

                        nodesToInsert.Add(group);
                        noLinesPreloaded = false;
                    }
                }
            }
            if (noLinesPreloaded)
            {
                if (Details.Ask(Messages.BudgetTreePreloadArticlesTitle, Messages.BudgetTreePreloadArticlesNothingToPreload, MessageButtons.OK) == WebDialogResult.OK)
                {
                    return(adapter.Get());
                }
            }
            if (nodesToInsert.Count > 500)
            {
                if (Details.Ask(Messages.Confirmation, String.Format(PXMessages.LocalizeNoPrefix(Messages.BudgetTreePreloadArticlesTooManyMessage), nodesToInsert.Count), MessageButtons.OKCancel) == WebDialogResult.OK)
                {
                    InsertPreloadedNodes(nodesToInsert);
                }
            }
            else
            {
                InsertPreloadedNodes(nodesToInsert);
            }
            return(adapter.Get());
        }