Exemple #1
0
        protected virtual IEnumerable assets()
        {
            DisposalFilter filter = Filter.Current;

            PXSelectBase <FixedAsset> cmd = new PXSelectJoin <FixedAsset,
                                                              InnerJoin <FADetails, On <FixedAsset.assetID, Equal <FADetails.assetID> >,
                                                                         LeftJoin <Account, On <FixedAsset.fAAccountID, Equal <Account.accountID> > > >,
                                                              Where <FADetails.status, NotEqual <FixedAssetStatus.disposed>,
                                                                     And <FADetails.status, NotEqual <FixedAssetStatus.hold>,
                                                                          And <FADetails.status, NotEqual <FixedAssetStatus.suspended> > > > >(this);

            if (filter.BookID != null)
            {
                cmd.Join <InnerJoin <FABookBalance, On <FABookBalance.assetID, Equal <FixedAsset.assetID> > > >();
                cmd.WhereAnd <Where <FABookBalance.bookID, Equal <Current <DisposalFilter.bookID> > > >();
            }

            if (filter.ClassID != null)
            {
                cmd.WhereAnd <Where <FixedAsset.classID, Equal <Current <DisposalFilter.classID> > > >();
            }
            if (PXAccess.FeatureInstalled <FeaturesSet.multipleCalendarsSupport>() || filter.OrgBAccountID != null)
            {
                cmd.WhereAnd <Where <FixedAsset.branchID, Inside <Current <DisposalFilter.orgBAccountID> > > >();
            }
            if (filter.ParentAssetID != null)
            {
                cmd.WhereAnd <Where <FixedAsset.parentAssetID, Equal <Current <DisposalFilter.parentAssetID> > > >();
            }

            int startRow  = PXView.StartRow;
            int totalRows = 0;

            List <PXFilterRow> newFilters = new List <PXFilterRow>();

            foreach (PXFilterRow f in PXView.Filters)
            {
                if (f.DataField.ToLower() == "status")
                {
                    f.DataField = "FADetails__Status";
                }
                newFilters.Add(f);
            }
            List <object> list = cmd.View.Select(PXView.Currents, null, PXView.Searches, PXView.SortColumns, PXView.Descendings, newFilters.ToArray(), ref startRow, PXView.MaximumRows, ref totalRows);

            PXView.StartRow = 0;
            return(list);
        }
        protected virtual IEnumerable balances()
        {
            BalanceFilter filter = Filter.Current;

            PXSelectBase <FABookBalance> cmd;

            //PXFilteredProcessing sets IsDirty = false when processing all records and all records are placed in cache,
            //until _Header refresh we will return readonly result, after it _InProc will be returned bypassing this delegate
            //if (false)
            //{
            //    cmd = new PXSelectReadonly2<FABookBalance,
            //        InnerJoin<FixedAsset, On<FixedAsset.assetID, Equal<FABookBalance.assetID>>,
            //        InnerJoin<FADetails, On<FADetails.assetID, Equal<FABookBalance.assetID>>>>,
            //        Where<FABookBalance.depreciate, Equal<True>, And<FABookBalance.status, Equal<FixedAssetStatus.active>, And<FADetails.status, Equal<FixedAssetStatus.active>>>>>(this);
            //}
            //else
            {
                cmd = new PXSelectJoin <FABookBalance,
                                        InnerJoin <FixedAsset, On <FixedAsset.assetID, Equal <FABookBalance.assetID> >,
                                                   InnerJoin <FADetails, On <FADetails.assetID, Equal <FABookBalance.assetID> > > >,
                                        Where <FABookBalance.depreciate, Equal <True>, And <FABookBalance.status, Equal <FixedAssetStatus.active>, And <FADetails.status, Equal <FixedAssetStatus.active> > > > >(this);
            }
            if (filter.BookID != null)
            {
                cmd.WhereAnd <Where <FABookBalance.bookID, Equal <Current <BalanceFilter.bookID> > > >();
            }
            if (filter.ClassID != null)
            {
                cmd.WhereAnd <Where <FixedAsset.classID, Equal <Current <BalanceFilter.classID> > > >();
            }
            if (filter.BranchID != null)
            {
                cmd.Join <LeftJoin <FALocationHistory, On <FALocationHistory.revisionID, Equal <FADetails.locationRevID>,
                                                           And <FALocationHistory.assetID, Equal <FADetails.assetID> > > > >();
                cmd.WhereAnd <Where <FALocationHistory.locationID, Equal <Current <BalanceFilter.branchID> > > >();
            }
            if (!string.IsNullOrEmpty(filter.PeriodID))
            {
                cmd.WhereAnd <Where <FABookBalance.currDeprPeriod, LessEqual <Current <BalanceFilter.periodID> > > >();
            }
            if (filter.ParentAssetID != null)
            {
                cmd.WhereAnd <Where <FixedAsset.parentAssetID, Equal <Current <BalanceFilter.parentAssetID> > > >();
            }

            int startRow  = PXView.StartRow;
            int totalRows = 0;

            List <PXFilterRow> newFilters = new List <PXFilterRow>();

            foreach (PXFilterRow f in PXView.Filters)
            {
                if (f.DataField.ToLower() == "status")
                {
                    f.DataField = "FADetails__Status";
                }
                newFilters.Add(f);
            }
            List <object> list = cmd.View.Select(PXView.Currents, null, PXView.Searches, PXView.SortColumns, PXView.Descendings, newFilters.ToArray(), ref startRow, PXView.MaximumRows, ref totalRows);

            PXView.StartRow = 0;
            return(list);
        }