Beispiel #1
0
        public GLConsolReadMaint()
        {
            GLSetup setup = GLSetup.Current;

            PXCache cache = ConsolSetupRecords.Cache;

            SubaccountSegmentsView =
                new PXSelect <Segment, Where <Segment.dimensionID, Equal <SubAccountAttribute.dimensionName> > >(this);

            PXUIFieldAttribute.SetEnabled <GLConsolSetup.description>(cache, null, false);
            PXUIFieldAttribute.SetEnabled <GLConsolSetup.lastConsDate>(cache, null, false);
            PXUIFieldAttribute.SetEnabled <GLConsolSetup.lastPostPeriod>(cache, null, false);
            PXUIFieldAttribute.SetEnabled <GLConsolSetup.ledgerId>(cache, null, false);
            PXUIFieldAttribute.SetEnabled <GLConsolSetup.login>(cache, null, false);
            PXUIFieldAttribute.SetEnabled <GLConsolSetup.password>(cache, null, false);
            PXUIFieldAttribute.SetEnabled <GLConsolSetup.pasteFlag>(cache, null, false);
            PXUIFieldAttribute.SetEnabled <GLConsolSetup.segmentValue>(cache, null, false);
            PXUIFieldAttribute.SetEnabled <GLConsolSetup.url>(cache, null, false);

            cache.AllowInsert = false;
            cache.AllowDelete = false;

            ConsolSetupRecords.SetProcessDelegate <GLConsolReadMaint>(ProcessConsolidationRead);
            ConsolSetupRecords.SetProcessAllVisible(false);
        }
Beispiel #2
0
        public static void VerifyFinPeriod <fieldPeriod, fieldClosed>(PXGraph graph, PXCache cache, object row, PXSelectBase <FinPeriod> finperiod)
            where fieldPeriod : class, IBqlField
            where fieldClosed : class, IBqlField
        {
            if (finperiod.Current != null)
            {
                GLSetup glsetup = PXSetup <GLSetup> .Select(graph);

                object isClosed = finperiod.Cache.GetValue <fieldClosed>(finperiod.Current);

                if (finperiod.Current.Active != true || isClosed.Equals(true) && glsetup != null && glsetup.PostClosedPeriods != true)
                {
                    BqlCommand select = BqlCommand.CreateInstance(typeof(Select <FinPeriod,
                                                                                 Where <FinPeriod.active, Equal <True>,
                                                                                        And <FinPeriod.finPeriodID, Greater <Required <FinPeriod.finPeriodID> > > >,
                                                                                 OrderBy <Asc <FinPeriod.finPeriodID> > >))
                                        .WhereAnd(BqlCommand.Compose(typeof(Where <,>), typeof(fieldClosed), typeof(NotEqual <True>)));

                    object    docPeriod = cache.GetValue <fieldPeriod>(row);
                    FinPeriod firstopen = new PXView(graph, false, select).SelectSingle(docPeriod) as FinPeriod;

                    if (firstopen == null)
                    {
                        string userPeriod = Mask.Format("##-####", finperiod.Cache.GetValueExt <FinPeriod.finPeriodID>(finperiod.Current).ToString());
                        throw new PXSetPropertyException(GL.Messages.NoActivePeriodAfter, userPeriod);
                    }

                    cache.SetValue <fieldPeriod>(row, firstopen.FinPeriodID);
                }
            }
        }
Beispiel #3
0
        public Closing()
        {
            GLSetup setup       = GLSetup.Current;
            APSetup apSetup     = APSetup.Select();
            ARSetup arSetup     = ARSetup.Select();
            INSetup inSetup     = INSetup.Select();
            CASetup caSetup     = CASetup.Select();
            FASetup faSetup     = FASetup.Select();
            PRSetup prSetup     = PRSetup.Select();
            PXCache periodCache = Caches[typeof(FinPeriod)];

            PXUIFieldAttribute.SetEnabled <FinPeriod.finPeriodID>(periodCache, null, false);
            PXUIFieldAttribute.SetEnabled <FinPeriod.descr>(periodCache, null, false);

            PXUIFieldAttribute.SetVisible <FinPeriod.aPClosed>(periodCache, null, apSetup != null);
            PXUIFieldAttribute.SetVisible <FinPeriod.aRClosed>(periodCache, null, arSetup != null);
            PXUIFieldAttribute.SetVisible <FinPeriod.iNClosed>(periodCache, null, inSetup != null);
            PXUIFieldAttribute.SetVisible <FinPeriod.cAClosed>(periodCache, null, caSetup != null);
            PXUIFieldAttribute.SetVisible <FinPeriod.fAClosed>(periodCache, null, faSetup != null);
            PXUIFieldAttribute.SetVisible <FinPeriod.pRClosed>(periodCache, null, prSetup != null);

            Caches[typeof(FinPeriod)].AllowInsert = false;
            Caches[typeof(FinPeriod)].AllowDelete = false;

            if (this.GetType() != typeof(Closing))
            {
                ShowDocuments.SetCaption(PXMessages.LocalizeNoPrefix(GL.Messages.ShowDocumentsNonGL));
            }
        }
        protected virtual void GLSetup_YtdNetIncAccountID_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            GLSetup row = (GLSetup)e.Row;

            if (row == null)
            {
                return;
            }

            if (e.NewValue != null)
            {
                Account YtdAccNew = PXSelect <Account, Where <Account.accountID, Equal <Required <GLSetup.ytdNetIncAccountID> > > > .Select(this, e.NewValue);

                if ((int?)e.NewValue == row.RetEarnAccountID)
                {
                    Account YtdAcc = PXSelect <Account, Where <Account.accountID, Equal <Current <GLSetup.ytdNetIncAccountID> > > > .SelectSingleBound(this, new object[] { row });

                    Account REAcc = PXSelect <Account, Where <Account.accountID, Equal <Current <GLSetup.retEarnAccountID> > > > .SelectSingleBound(this, new object[] { row });

                    e.NewValue = YtdAcc == null ? null : YtdAcc.AccountCD;
                    throw new PXSetPropertyException(CS.Messages.Entry_NE, REAcc.AccountCD);
                }

                if (YtdAccNew.GLConsolAccountCD != null)
                {
                    throw new PXSetPropertyException(Messages.AccountCannotBeSpecifiedAsTheYTDNetIncome);
                }

                if (GLUtility.IsAccountHistoryExist(this, (int?)e.NewValue))
                {
                    e.NewValue = YtdAccNew == null ? null : YtdAccNew.AccountCD;
                    throw new PXSetPropertyException(Messages.AccountExistsHistory2);
                }
            }
        }
        public ScheduleRun()
        {
            GLSetup setup = GLSetup.Current;

            Schedule_List.SetProcessCaption(Messages.ProcRunSelected);
            Schedule_List.SetProcessAllCaption(Messages.ProcRunAll);
        }
        public ScheduleRun()
        {
            GLSetup setup = GLSetup.Current;

            Schedule_List.WhereAnd <Where <
                                        Schedule.module, Equal <BatchModule.moduleGL> > >();
        }
        public AccountHistoryBySubEnq()
        {
            GLSetup setup = glsetup.Current;

            EnqResult.Cache.AllowInsert = false;
            EnqResult.Cache.AllowDelete = false;
            EnqResult.Cache.AllowUpdate = false;
        }
        public AccountHistoryByYearEnq()
        {
            GLSetup setup = glsetup.Current;

            //SWUIFieldAttribute.SetEnabled(EnqResult.Cache, null, false);
            EnqResult.Cache.AllowInsert = false;
            EnqResult.Cache.AllowDelete = false;
            EnqResult.Cache.AllowUpdate = false;
        }
Beispiel #9
0
        public BatchRelease()
        {
            GLSetup setup = GLSetup.Current;

            BatchList.SetProcessDelegate <PostGraph>(ReleaseBatch);
            BatchList.SetProcessCaption(Messages.ProcRelease);
            BatchList.SetProcessAllCaption(Messages.ProcReleaseAll);
            PXNoteAttribute.ForcePassThrow <Batch.noteID>(BatchList.Cache);
        }
Beispiel #10
0
        public AllocationMaint()
        {
            GLSetup setup = GLSetup.Current;

            PXUIFieldAttribute.SetEnabled(this.Batches.Cache, null, false);
            this.Batches.Cache.AllowInsert = false;
            this.Batches.Cache.AllowDelete = false;
            this.Batches.Cache.AllowUpdate = false;
        }
        public GLHistoryValidate()
        {
            GLSetup setup = glsetup.Current;

            LedgerList.SetProcessCaption(Messages.ProcValidate);
            LedgerList.SetProcessAllCaption(Messages.ProcValidateAll);

            PXUIFieldAttribute.SetEnabled <Ledger.selected>(LedgerList.Cache, null, true);
            PXUIFieldAttribute.SetEnabled <Ledger.ledgerCD>(LedgerList.Cache, null, false);
            PXUIFieldAttribute.SetEnabled <Ledger.descr>(LedgerList.Cache, null, false);
        }
        public ScheduleMaint()
        {
            GLSetup gls = GLSetup.Current;

            Batch_History.Cache.AllowDelete = false;
            Batch_History.Cache.AllowInsert = false;
            Batch_History.Cache.AllowUpdate = false;
            CopyPaste.SetVisible(false);

            Views.Caches.Remove(typeof(Batch));
        }
Beispiel #13
0
        public GLBudgetRelease()
        {
            GLSetup setup = GLSetup.Current;

            BudgetArticles.SetProcessCaption(Messages.ProcRelease);
            BudgetArticles.SetProcessAllCaption(Messages.ProcReleaseAll);
            BudgetArticles.SetProcessDelegate(Approve);

            PXUIFieldAttribute.SetVisible <GLBudgetLine.branchID>(BudgetArticles.Cache, null, true);
            PXUIFieldAttribute.SetVisible <GLBudgetLine.ledgerID>(BudgetArticles.Cache, null, true);
            PXUIFieldAttribute.SetVisible <GLBudgetLine.finYear>(BudgetArticles.Cache, null, true);
        }
        public ScheduleRun()
        {
            GLSetup setup = GLSetup.Current;

            Schedule_List.WhereAnd <Where <
                                        Schedule.module, Equal <BatchModule.moduleGL> > >();

            Schedule_List.WhereAnd <Where <Exists <
                                               Select <Batch,
                                                       Where <Batch.scheduleID, Equal <Schedule.scheduleID>,
                                                              And <Batch.scheduled, Equal <True> > > > > > >();
        }
        public ScheduleMaint()
        {
            GLSetup gls = GLSetup.Current;

            Batch_History.Cache.AllowDelete = false;
            Batch_History.Cache.AllowInsert = false;
            Batch_History.Cache.AllowUpdate = false;

            Schedule_Header.WhereAnd <Where <Schedule.module, Equal <BatchModule.moduleGL> > >();

            Views.Caches.Remove(typeof(Batch));
        }
        protected virtual void GLSetup_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e)
        {
            GLSetup setup = e.Row as GLSetup;

            if (setup == null)
            {
                return;
            }
            if (PXAccess.FeatureInstalled <FeaturesSet.multicurrency>() || PXAccess.FeatureInstalled <FeaturesSet.invoiceRounding>())
            {
                basecurrency.Cache.SetStatus(basecurrency.Current, PXEntryStatus.Updated);
            }
        }
        protected virtual void GLSetup_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            GLSetup setup      = e.Row as GLSetup;
            bool    hasHistory = GLUtility.IsAccountHistoryExist(this, setup.YtdNetIncAccountID);

            PXUIFieldAttribute.SetEnabled <GLSetup.ytdNetIncAccountID>(GLSetupRecord.Cache, setup, !hasHistory);
            PXUIFieldAttribute.SetEnabled <GLSetup.retEarnAccountID>(GLSetupRecord.Cache, setup, true);
        }
        public GLHistoryValidate()
        {
            GLSetup setup = glsetup.Current;
            GLIntegrityCheckFilter filter = Filter.Current;

            LedgerList.SetProcessCaption(Messages.ProcValidate);
            LedgerList.SetProcessAllCaption(Messages.ProcValidateAll);
            LedgerList.SetProcessDelegate((PostGraph postGraph, Ledger ledger) => Validate(postGraph, ledger, filter));

            PXUIFieldAttribute.SetEnabled <Ledger.selected>(LedgerList.Cache, null, true);
            PXUIFieldAttribute.SetEnabled <Ledger.ledgerCD>(LedgerList.Cache, null, false);
            PXUIFieldAttribute.SetEnabled <Ledger.descr>(LedgerList.Cache, null, false);
        }
        public BatchPost()
        {
            GLSetup setup = GLSetup.Current;

            BatchList.SetProcessDelegate <PostGraph>(
                delegate(PostGraph pg, Batch batch)
            {
                pg.Clear();
                pg.PostBatchProc(batch);
            }
                );
            BatchList.SetProcessCaption(Messages.ProcPost);
            BatchList.SetProcessAllCaption(Messages.ProcPostAll);
            PXNoteAttribute.ForcePassThrow <Batch.noteID>(BatchList.Cache);
        }
        protected virtual void GLSetup_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            GLSetup OldRow = (GLSetup)PXSelectReadonly <GLSetup> .Select(this);

            GLSetup NewRow = (GLSetup)e.Row;

            if ((OldRow == null || OldRow.COAOrder != NewRow.COAOrder) && NewRow.COAOrder < 4)
            {
                for (short i = 0; i < 4; i++)
                {
                    PXDatabase.Update <Account>(new PXDataFieldAssign("COAOrder", Convert.ToInt32(AccountType.COAOrderOptions[(int)NewRow.COAOrder].Substring((int)i, 1))),
                                                new PXDataFieldRestrict("Type", AccountType.Literal(i)));
                    PXDatabase.Update <PM.PMAccountGroup>(new PXDataFieldAssign(typeof(PM.PMAccountGroup.sortOrder).Name, Convert.ToInt32(AccountType.COAOrderOptions[(int)NewRow.COAOrder].Substring((int)i, 1))),
                                                          new PXDataFieldRestrict(typeof(PM.PMAccountGroup.type).Name, AccountType.Literal(i)));
                }
            }
        }
        protected virtual void GLSetup_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            GLSetup setup = (GLSetup)e.Row;

            var consColVisible = setup.ConsolSegmentId != null;

            PXUIFieldAttribute.SetEnabled <GLConsolSetup.segmentValue>(ConsolSetupRecords.Cache, null, consColVisible);
            PXUIFieldAttribute.SetEnabled <GLConsolSetup.pasteFlag>(ConsolSetupRecords.Cache, null, consColVisible);

            PXUIFieldAttribute.SetVisible <GLConsolSetup.segmentValue>(ConsolSetupRecords.Cache, null, consColVisible);
            PXUIFieldAttribute.SetVisible <GLConsolSetup.pasteFlag>(ConsolSetupRecords.Cache, null, consColVisible);

            PXDefaultAttribute.SetPersistingCheck <GLConsolSetup.segmentValue>(ConsolSetupRecords.Cache, null,
                                                                               consColVisible ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing);
        }
Beispiel #22
0
        protected virtual void GLSetup_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            GLSetup setup = (GLSetup)e.Row;

            if (setup.ConsolSegmentId == null)
            {
                PXUIFieldAttribute.SetVisible <GLConsolSetup.segmentValue>(ConsolSetupRecords.Cache, null, false);
                PXDefaultAttribute.SetPersistingCheck <GLConsolSetup.segmentValue>(ConsolSetupRecords.Cache, null, PXPersistingCheck.Nothing);
                PXUIFieldAttribute.SetVisible <GLConsolSetup.pasteFlag>(ConsolSetupRecords.Cache, null, false);
            }
            else
            {
                PXUIFieldAttribute.SetVisible <GLConsolSetup.segmentValue>(ConsolSetupRecords.Cache, null, true);
                PXDefaultAttribute.SetPersistingCheck <GLConsolSetup.segmentValue>(ConsolSetupRecords.Cache, null, PXPersistingCheck.NullOrBlank);
                PXUIFieldAttribute.SetVisible <GLConsolSetup.pasteFlag>(ConsolSetupRecords.Cache, null, true);
            }
        }
Beispiel #23
0
        public GLConsolReadMaint()
        {
            GLSetup setup = GLSetup.Current;

            PXCache cache = ConsolSetupRecords.Cache;

            PXUIFieldAttribute.SetEnabled <GLConsolSetup.description>(cache, null, false);
            PXUIFieldAttribute.SetEnabled <GLConsolSetup.lastConsDate>(cache, null, false);
            PXUIFieldAttribute.SetEnabled <GLConsolSetup.lastPostPeriod>(cache, null, false);
            PXUIFieldAttribute.SetEnabled <GLConsolSetup.ledgerId>(cache, null, false);
            PXUIFieldAttribute.SetEnabled <GLConsolSetup.login>(cache, null, false);
            PXUIFieldAttribute.SetEnabled <GLConsolSetup.password>(cache, null, false);
            PXUIFieldAttribute.SetEnabled <GLConsolSetup.pasteFlag>(cache, null, false);
            PXUIFieldAttribute.SetEnabled <GLConsolSetup.segmentValue>(cache, null, false);
            PXUIFieldAttribute.SetEnabled <GLConsolSetup.url>(cache, null, false);

            cache.AllowInsert = false;
            cache.AllowDelete = false;

            ConsolSetupRecords.SetProcessDelegate <GLConsolReadMaint>(ProcessConsolidationRead);
            ConsolSetupRecords.SetProcessAllVisible(false);
        }
Beispiel #24
0
        public Closing()
        {
            GLSetup setup       = GLSetup.Current;
            APSetup apSetup     = APSetup.Select();
            ARSetup arSetup     = ARSetup.Select();
            INSetup inSetup     = INSetup.Select();
            CASetup caSetup     = CASetup.Select();
            FASetup faSetup     = FASetup.Select();
            PXCache periodCache = Caches[typeof(FinPeriod)];

            PXUIFieldAttribute.SetEnabled <FinPeriod.finPeriodID>(periodCache, null, false);
            PXUIFieldAttribute.SetEnabled <FinPeriod.descr>(periodCache, null, false);

            PXUIFieldAttribute.SetVisible <FinPeriod.aPClosed>(periodCache, null, apSetup != null);
            PXUIFieldAttribute.SetVisible <FinPeriod.aRClosed>(periodCache, null, arSetup != null);
            PXUIFieldAttribute.SetVisible <FinPeriod.iNClosed>(periodCache, null, inSetup != null);
            PXUIFieldAttribute.SetVisible <FinPeriod.cAClosed>(periodCache, null, caSetup != null);
            PXUIFieldAttribute.SetVisible <FinPeriod.fAClosed>(periodCache, null, faSetup != null);

            Caches[typeof(FinPeriod)].AllowInsert = false;
            Caches[typeof(FinPeriod)].AllowDelete = false;
        }
        protected virtual void GLSetup_RetEarnAccountID_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            GLSetup row = (GLSetup)e.Row;

            if (row == null)
            {
                return;
            }

            if (e.NewValue != null && (int?)e.NewValue == row.YtdNetIncAccountID)
            {
                Account YtdAcc = PXSelect <Account, Where <Account.accountID, Equal <Current <GLSetup.ytdNetIncAccountID> > > > .SelectSingleBound(this, new object[] { row });

                Account REAcc = PXSelect <Account, Where <Account.accountID, Equal <Current <GLSetup.retEarnAccountID> > > > .SelectSingleBound(this, new object[] { row });

                e.NewValue = REAcc == null ? null : REAcc.AccountCD;
                throw new PXSetPropertyException(CS.Messages.Entry_NE, YtdAcc.AccountCD);
            }

            if (e.NewValue != null && GLUtility.IsAccountHistoryExist(this, (int?)e.NewValue))
            {
                sender.RaiseExceptionHandling <GLSetup.retEarnAccountID>(e.Row, null, new PXSetPropertyException(Messages.AccountExistsHistory2, PXErrorLevel.Warning));
            }
        }
        public GLConsolSetupMaint()
        {
            GLSetup setup = glsetup.Current;

            ConsolSetupRecords.SetProcessCaption(Messages.ProcSynchronize);
            ConsolSetupRecords.SetProcessAllCaption(Messages.ProcSynchronizeAll);
            ConsolSetupRecords.SetProcessDelegate <GLConsolSetupMaint>(Synchronize);
            PXUIFieldAttribute.SetEnabled(ConsolSetupRecords.Cache, null, true);
            PXUIFieldAttribute.SetEnabled <GLConsolSetup.lastPostPeriod>(ConsolSetupRecords.Cache, null, false);
            PXUIFieldAttribute.SetEnabled <GLConsolSetup.lastConsDate>(ConsolSetupRecords.Cache, null, false);
            ConsolSetupRecords.SetAutoPersist(true);
            ConsolSetupRecords.Cache.AllowDelete = true;
            ConsolSetupRecords.Cache.AllowInsert = true;

            PXUIFieldAttribute.SetRequired <GLConsolSetup.segmentValue>(ConsolSetupRecords.Cache, true);
            PXUIFieldAttribute.SetRequired <GLConsolSetup.sourceLedgerCD>(ConsolSetupRecords.Cache, true);

            Save.StateSelectingEvents += new PXFieldSelecting(delegate(PXCache sender, PXFieldSelectingEventArgs e)
            {
                e.ReturnState = PXButtonState.CreateInstance(e.ReturnState, null, null, null, null, null, false,
                                                             PXConfirmationType.Unspecified, null, null, null, null, null, null, null, null, null, null, null, null);
                ((PXButtonState)e.ReturnState).Enabled = !PXLongOperation.Exists(this.UID);
            });
        }
 public FinPeriodStatusProcess()
 {
     GLSetup setup = glsetup.Current;
 }
Beispiel #28
0
        protected virtual IEnumerable enqResult()
        {
            GLHistoryEnqFilter filter = (GLHistoryEnqFilter)this.Filter.Current;
            bool showCurrency         = filter.ShowCuryDetail.HasValue && filter.ShowCuryDetail.Value;

            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyID>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyPtdCreditTotal>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyPtdDebitTotal>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyBegBalance>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyEndBalance>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.signCuryBegBalance>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.signCuryEndBalance>(EnqResult.Cache, null, showCurrency);
            if (filter.LedgerID == null || filter.FinPeriodID == null)
            {
                yield break;                 //Prevent code from accessing database;
            }
            #region cmd
            PXSelectBase <GLHistoryByPeriod> cmd = new PXSelectJoinGroupBy <GLHistoryByPeriod,
                                                                            InnerJoin <Account,
                                                                                       On <GLHistoryByPeriod.accountID, Equal <Account.accountID>, And <Match <Account, Current <AccessInfo.userName> > > >,
                                                                                       InnerJoin <Sub,
                                                                                                  On <GLHistoryByPeriod.subID, Equal <Sub.subID>, And <Match <Sub, Current <AccessInfo.userName> > > >,
                                                                                                  LeftJoin <GLHistory, On <GLHistoryByPeriod.accountID, Equal <GLHistory.accountID>,
                                                                                                                           And <GLHistoryByPeriod.ledgerID, Equal <GLHistory.ledgerID>,
                                                                                                                                And <GLHistoryByPeriod.branchID, Equal <GLHistory.branchID>,
                                                                                                                                     And <GLHistoryByPeriod.subID, Equal <GLHistory.subID>,
                                                                                                                                          And <GLHistoryByPeriod.finPeriodID, Equal <GLHistory.finPeriodID> > > > > >,
                                                                                                            LeftJoin <AH, On <GLHistoryByPeriod.ledgerID, Equal <AH.ledgerID>,
                                                                                                                              And <GLHistoryByPeriod.branchID, Equal <AH.branchID>,
                                                                                                                                   And <GLHistoryByPeriod.accountID, Equal <AH.accountID>,
                                                                                                                                        And <GLHistoryByPeriod.subID, Equal <AH.subID>,
                                                                                                                                             And <GLHistoryByPeriod.lastActivityPeriod, Equal <AH.finPeriodID> > > > > > > > > >,
                                                                            Where <GLHistoryByPeriod.ledgerID, Equal <Current <GLHistoryEnqFilter.ledgerID> >,
                                                                                   And <GLHistoryByPeriod.finPeriodID, Equal <Current <GLHistoryEnqFilter.finPeriodID> >,
                                                                                        And <
                                                                                            Where2 <
                                                                                                Where <Account.accountID, NotEqual <Current <GLSetup.ytdNetIncAccountID> >, And <Where <Account.type, Equal <AccountType.asset>,
                                                                                                                                                                                        Or <Account.type, Equal <AccountType.liability> > > > >,
                                                                                                Or <Where <GLHistoryByPeriod.lastActivityPeriod, GreaterEqual <Required <GLHistoryByPeriod.lastActivityPeriod> >,
                                                                                                           And <Where <Account.type, Equal <AccountType.expense>,
                                                                                                                       Or <Account.type, Equal <AccountType.income>,
                                                                                                                           Or <Account.accountID, Equal <Current <GLSetup.ytdNetIncAccountID> > > > > > > > > > > >,
                                                                            Aggregate <
                                                                                Sum <AH.finYtdBalance,
                                                                                     Sum <AH.tranYtdBalance,
                                                                                          Sum <AH.curyFinYtdBalance,
                                                                                               Sum <AH.curyTranYtdBalance,
                                                                                                    Sum <GLHistory.finPtdDebit,
                                                                                                         Sum <GLHistory.tranPtdDebit,
                                                                                                              Sum <GLHistory.finPtdCredit,
                                                                                                                   Sum <GLHistory.tranPtdCredit,
                                                                                                                        Sum <GLHistory.finBegBalance,
                                                                                                                             Sum <GLHistory.tranBegBalance,
                                                                                                                                  Sum <GLHistory.finYtdBalance,
                                                                                                                                       Sum <GLHistory.tranYtdBalance,
                                                                                                                                            Sum <GLHistory.curyFinBegBalance,
                                                                                                                                                 Sum <GLHistory.curyTranBegBalance,
                                                                                                                                                      Sum <GLHistory.curyFinYtdBalance,
                                                                                                                                                           Sum <GLHistory.curyTranYtdBalance,
                                                                                                                                                                Sum <GLHistory.curyFinPtdCredit,
                                                                                                                                                                     Sum <GLHistory.curyTranPtdCredit,
                                                                                                                                                                          Sum <GLHistory.curyFinPtdDebit,
                                                                                                                                                                               Sum <GLHistory.curyTranPtdDebit,
                                                                                                                                                                                    GroupBy <GLHistoryByPeriod.branchID,
                                                                                                                                                                                             GroupBy <GLHistoryByPeriod.ledgerID,
                                                                                                                                                                                                      GroupBy <GLHistoryByPeriod.accountID,
                                                                                                                                                                                                               GroupBy <GLHistoryByPeriod.finPeriodID
                                                                                                                                                                                                                        > > > > > > > > > > > > > > > > > > > > > > > > > >(this);

            if (filter.LedgerID != null)
            {
                Ledger ledger = (Ledger)PXSelectorAttribute.Select <GLHistoryEnqFilter.ledgerID>(Filter.Cache, filter);
                if (ledger?.BalanceType == LedgerBalanceType.Budget)
                {
                    // we shouldn't select history from the previous years for the budget ledgers
                    cmd.WhereAnd <Where <Substring <GLHistoryByPeriod.finPeriodID, int1, int4>, Equal <Substring <GLHistoryByPeriod.lastActivityPeriod, int1, int4> > > >();
                }
            }
            if (filter.AccountID != null)
            {
                cmd.WhereAnd <Where <GLHistoryByPeriod.accountID, Equal <Current <GLHistoryEnqFilter.accountID> > > >();
            }
            if (filter.AccountClassID != null)
            {
                cmd.WhereAnd <Where <Account.accountClassID, Equal <Current <GLHistoryEnqFilter.accountClassID> > > >();
            }

            if (filter.SubID != null)
            {
                cmd.WhereAnd <Where <GLHistoryByPeriod.subID, Equal <Current <GLHistoryEnqFilter.subID> > > >();
            }

            int[] branchIDs = null;

            if (filter.BranchID != null)
            {
                cmd.WhereAnd <Where <GLHistoryByPeriod.branchID, Equal <Current <GLHistoryEnqFilter.branchID> > > >();
            }
            else if (filter.OrganizationID != null)
            {
                branchIDs = PXAccess.GetChildBranchIDs(filter.OrganizationID, false);

                cmd.WhereAnd <Where <GLHistoryByPeriod.branchID, In <Required <GLHistoryEnqFilter.branchID> >,
                                     And <MatchWithBranch <GLHistoryByPeriod.branchID> > > >();
            }

            if (!SubCDUtils.IsSubCDEmpty(filter.SubCD))
            {
                cmd.WhereAnd <Where <Sub.subCD, Like <Current <GLHistoryEnqFilter.subCDWildcard> > > >();
            }
            //cmd.WhereAnd<Where<Match<Current<AccessInfo.userName>>>>();
            #endregion
            string  yearBegPeriod = filter.BegFinPeriod;
            GLSetup glSetup       = glsetup.Current;
            bool    reverseSign   = (glSetup != null) && (glSetup.TrialBalanceSign == GLSetup.trialBalanceSign.Reversed);
            foreach (PXResult <GLHistoryByPeriod, Account, Sub, GLHistory, AH> it in cmd.Select(yearBegPeriod, branchIDs))
            {
                GLHistoryByPeriod baseview = (GLHistoryByPeriod)it;
                Account           acct     = (Account)it;
                GLHistory         ah       = (GLHistory)it;
                AH ah1 = (AH)it;
                ah.FinFlag  = filter.UseMasterCalendar != true;
                ah1.FinFlag = filter.UseMasterCalendar != true;

                if (reverseSign && acct.AccountID == glSetup.YtdNetIncAccountID)
                {
                    continue;
                }

                GLHistoryEnquiryResult item = new GLHistoryEnquiryResult();
                item.BranchID           = baseview.BranchID;
                item.LedgerID           = baseview.LedgerID;
                item.AccountID          = baseview.AccountID;
                item.AccountCD          = acct.AccountCD;
                item.Type               = acct.Type;
                item.Description        = acct.Description;
                item.LastActivityPeriod = baseview.LastActivityPeriod;
                item.PtdCreditTotal     = ah.PtdCredit ?? 0m;
                item.PtdDebitTotal      = ah.PtdDebit ?? 0m;
                item.EndBalance         = ah1.YtdBalance ?? 0m;
                item.ConsolAccountCD    = acct.GLConsolAccountCD;
                item.AccountClassID     = acct.AccountClassID;
                if (!(string.IsNullOrEmpty(ah.CuryID) && string.IsNullOrEmpty(ah1.CuryID)))
                {
                    item.CuryEndBalance     = ah1.CuryYtdBalance ?? 0m;
                    item.CuryPtdCreditTotal = ah.CuryPtdCredit ?? 0m;
                    item.CuryPtdDebitTotal  = ah.CuryPtdDebit ?? 0m;
                    item.CuryID             = string.IsNullOrEmpty(ah.CuryID) ? ah1.CuryID : ah.CuryID;
                }
                else
                {
                    item.CuryEndBalance     = null;
                    item.CuryPtdCreditTotal = null;
                    item.CuryPtdDebitTotal  = null;
                    item.CuryID             = null;
                }

                item.recalculate(true);                 // End balance is considered as correct digit - so we need to calculate begBalance base on ending one
                item.recalculateSignAmount(reverseSign);
                yield return(item);
            }
        }
Beispiel #29
0
 public GLBudgetTreeMaint()
 {
     GLSetup setup = GLSetup.Current;
 }
        protected virtual IEnumerable enqResult()
        {
            AccountByYearFilter filter = this.CurrentFilter;
            bool showCurrency          = filter.ShowCuryDetail.HasValue && filter.ShowCuryDetail.Value;

            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyID>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyPtdCreditTotal>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyPtdDebitTotal>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyBegBalance>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyEndBalance>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.signCuryBegBalance>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.signCuryEndBalance>(EnqResult.Cache, null, showCurrency);

            if (filter.AccountID == null || filter.LedgerID == null || filter.FinYear == null)
            {
                yield break;                 //Prevent code from accessing database;
            }

            PXSelectBase <GLHistoryByPeriod> cmd = new PXSelectJoinGroupBy <GLHistoryByPeriod,
                                                                            InnerJoin <Account,
                                                                                       On <GLHistoryByPeriod.accountID, Equal <Account.accountID>, And <Match <Account, Current <AccessInfo.userName> > > >,
                                                                                       InnerJoin <FinPeriod,
                                                                                                  On <GLHistoryByPeriod.finPeriodID, Equal <FinPeriod.finPeriodID> >,
                                                                                                  InnerJoin <Sub,
                                                                                                             On <GLHistoryByPeriod.subID, Equal <Sub.subID>, And <Match <Sub, Current <AccessInfo.userName> > > >,
                                                                                                             LeftJoin <GLHistory, On <GLHistoryByPeriod.accountID, Equal <GLHistory.accountID>,
                                                                                                                                      And <GLHistoryByPeriod.subID, Equal <GLHistory.subID>,
                                                                                                                                           And <GLHistoryByPeriod.branchID, Equal <GLHistory.branchID>,
                                                                                                                                                And <GLHistoryByPeriod.ledgerID, Equal <GLHistory.ledgerID>,
                                                                                                                                                     And <GLHistoryByPeriod.finPeriodID, Equal <GLHistory.finPeriodID> > > > > >,
                                                                                                                       LeftJoin <AH, On <GLHistoryByPeriod.ledgerID, Equal <AH.ledgerID>,
                                                                                                                                         And <GLHistoryByPeriod.branchID, Equal <AH.branchID>,
                                                                                                                                              And <GLHistoryByPeriod.accountID, Equal <AH.accountID>,
                                                                                                                                                   And <GLHistoryByPeriod.subID, Equal <AH.subID>,
                                                                                                                                                        And <GLHistoryByPeriod.lastActivityPeriod, Equal <AH.finPeriodID> > > > > > > > > > >,
                                                                            Where <GLHistoryByPeriod.ledgerID, Equal <Current <AccountByYearFilter.ledgerID> >,
                                                                                   And <FinPeriod.finYear, Equal <Current <AccountByYearFilter.finYear> >,
                                                                                        And <GLHistoryByPeriod.accountID, Equal <Current <AccountByYearFilter.accountID> >,
                                                                                             And <
                                                                                                 Where2 <
                                                                                                     Where <Account.accountID, NotEqual <Current <GLSetup.ytdNetIncAccountID> >, And <Where <Account.type, Equal <AccountType.asset>,
                                                                                                                                                                                             Or <Account.type, Equal <AccountType.liability> > > > >,
                                                                                                     Or <
                                                                                                         Where <GLHistoryByPeriod.lastActivityPeriod, GreaterEqual <Required <GLHistoryByPeriod.lastActivityPeriod> >,
                                                                                                                And <Where <Account.type, Equal <AccountType.expense>,
                                                                                                                            Or <Account.type, Equal <AccountType.income>,
                                                                                                                                Or <Account.accountID, Equal <Current <GLSetup.ytdNetIncAccountID> > > > > > > > > > > > >,
                                                                            Aggregate <
                                                                                Sum <AH.finYtdBalance,
                                                                                     Sum <AH.curyFinYtdBalance,
                                                                                          Sum <GLHistory.finPtdDebit,
                                                                                               Sum <GLHistory.finPtdCredit,
                                                                                                    Sum <GLHistory.finBegBalance,
                                                                                                         Sum <GLHistory.finYtdBalance,
                                                                                                              Sum <GLHistory.curyFinBegBalance,
                                                                                                                   Sum <GLHistory.curyFinYtdBalance,
                                                                                                                        Sum <GLHistory.curyFinPtdCredit,
                                                                                                                             Sum <GLHistory.curyFinPtdDebit,
                                                                                                                                  GroupBy <GLHistoryByPeriod.ledgerID,
                                                                                                                                           GroupBy <GLHistoryByPeriod.accountID,
                                                                                                                                                    GroupBy <GLHistoryByPeriod.finPeriodID
                                                                                                                                                             > > > > > > > > > > > > > > >(this);

            if (filter.SubID != null)
            {
                cmd.WhereAnd <Where <GLHistoryByPeriod.subID, Equal <Current <AccountByYearFilter.subID> > > >();
            }

            if (filter.BranchID != null)
            {
                cmd.WhereAnd <Where <GLHistoryByPeriod.branchID, Equal <Current <AccountByYearFilter.branchID> > > >();
            }

            if (!SubCDUtils.IsSubCDEmpty(filter.SubCD))
            {
                cmd.WhereAnd <Where <Sub.subCD, Like <Current <AccountByYearFilter.subCDWildcard> > > >();
            }

            string  yearBegPeriod = filter.BegFinPeriod;
            GLSetup glSetup       = glsetup.Current;
            bool    reverseSign   = (glSetup != null) && (glSetup.TrialBalanceSign == GLSetup.trialBalanceSign.Reversed);

            foreach (PXResult <GLHistoryByPeriod, Account, FinPeriod, Sub, GLHistory, AH> it in cmd.Select(yearBegPeriod))
            {
                GLHistoryByPeriod baseview = (GLHistoryByPeriod)it;
                Account           acct     = (Account)it;
                GLHistory         ah       = (GLHistory)it;
                AH ah1 = (AH)it;

                if (reverseSign && acct.AccountID == glSetup.YtdNetIncAccountID)
                {
                    continue;
                }

                GLHistoryEnquiryResult item = new GLHistoryEnquiryResult();
                item.AccountID          = baseview.AccountID;
                item.LedgerID           = baseview.LedgerID;
                item.LastActivityPeriod = baseview.FinPeriodID;
                item.PtdCreditTotal     = ah.FinPtdCredit;
                item.PtdDebitTotal      = ah.FinPtdDebit;
                item.CuryID             = ah1.CuryID;
                item.Type       = acct.Type;
                item.EndBalance = ah1.FinYtdBalance;
                if (!string.IsNullOrEmpty(ah1.CuryID))
                {
                    item.CuryEndBalance     = ah1.CuryFinYtdBalance;                         //
                    item.CuryPtdCreditTotal = ah.CuryFinPtdCredit;
                    item.CuryPtdDebitTotal  = ah.CuryFinPtdDebit;
                }
                else
                {
                    item.CuryEndBalance     = null;
                    item.CuryPtdCreditTotal = null;
                    item.CuryPtdDebitTotal  = null;
                }
                item.recalculate(true);                         // End balance is considered as correct digit - so we need to calculate begBalance base on ending one
                item.recalculateSignAmount(reverseSign);
                yield return(item);
            }
        }