示例#1
0
        public virtual IEnumerable ViewDetails(PXAdapter adapter)
        {
            Amounts amt = Amts.Current;
            AccBalanceByAssetFilter filter = Filter.Current;

            if (amt != null && filter != null)
            {
                FACostDetailsInq graph = CreateInstance <FACostDetailsInq>();

                AccountFilter filterDetails =
                    graph.Filter.Current =
                        new AccountFilter()
                {
                    AssetID     = amt.AssetID,
                    EndPeriodID = filter.PeriodID,
                    AccountID   = filter.AccountID,
                    SubID       = filter.SubID
                };
                filterDetails = graph.Filter.Insert(filterDetails);

                filterDetails.StartPeriodID = null;
                filterDetails.BookID        = filter.BookID;
                graph.Filter.Cache.IsDirty  = false;
                throw new PXRedirectRequiredException(graph, true, "ViewDetails")
                      {
                          Mode = PXBaseRedirectException.WindowMode.Same
                      };
            }

            return(adapter.Get());
        }
示例#2
0
        protected virtual IEnumerable filter()
        {
            PXCache cache = this.Caches[typeof(AccBalanceByAssetFilter)];
            AccBalanceByAssetFilter filter = (AccBalanceByAssetFilter)cache.Current;

            if (filter != null)
            {
                filter.Balance = decimal.Zero;
                foreach (Amounts amt in Amts.Select())
                {
                    filter.Balance += amt.ItdAmt;
                }
            }

            yield return(cache.Current);

            cache.IsDirty = false;
        }
示例#3
0
        public virtual IEnumerable amts(PXAdapter adapter)
        {
            AccBalanceByAssetFilter filter = Filter.Current;

            if (filter == null)
            {
                yield break;
            }

            PXSelectBase <FATran> select = new PXSelectJoin <FATran,
                                                             InnerJoin <FixedAsset, On <FixedAsset.assetID, Equal <FATran.assetID>, And <FixedAsset.recordType, Equal <FARecordType.assetType> > >,
                                                                        InnerJoin <FADetails, On <FADetails.assetID, Equal <FixedAsset.assetID> >,
                                                                                   InnerJoin <Branch, On <FixedAsset.branchID, Equal <Branch.branchID> >,
                                                                                              InnerJoin <FALocationHistoryCurrent, On <FALocationHistoryCurrent.assetID, Equal <FixedAsset.assetID> >,
                                                                                                         InnerJoin <FALocationHistory, On <FALocationHistory.assetID, Equal <FixedAsset.assetID>,
                                                                                                                                           And <FALocationHistory.periodID, Equal <FALocationHistoryCurrent.lastPeriodID>,
                                                                                                                                                And <FALocationHistory.revisionID, Equal <FALocationHistoryCurrent.lastRevisionID> > > > > > > > >,
                                                             Where <FATran.released, Equal <True>,
                                                                    And <FATran.finPeriodID, LessEqual <Current <AccBalanceByAssetFilter.periodID> >,
                                                                         And <FATran.bookID, Equal <Current <AccBalanceByAssetFilter.bookID> >,
                                                                              And2 <Where <FALocationHistory.fAAccountID, Equal <Current <AccBalanceByAssetFilter.accountID> >,
                                                                                           And <FALocationHistory.fASubID, Equal <Current <AccBalanceByAssetFilter.subID> >,
                                                                                                Or <FALocationHistory.accumulatedDepreciationAccountID, Equal <Current <AccBalanceByAssetFilter.accountID> >,
                                                                                                    And <FALocationHistory.accumulatedDepreciationSubID, Equal <Current <AccBalanceByAssetFilter.subID> > > > > >,
                                                                                    And <Where <FATran.debitAccountID, Equal <Current <AccBalanceByAssetFilter.accountID> >,
                                                                                                And <FATran.debitSubID, Equal <Current <AccBalanceByAssetFilter.subID> >,
                                                                                                     Or <FATran.creditAccountID, Equal <Current <AccBalanceByAssetFilter.accountID> >,
                                                                                                         And <FATran.creditSubID, Equal <Current <AccBalanceByAssetFilter.subID> > > > > > > > > > > >(this);

            if (PXAccess.FeatureInstalled <FeaturesSet.multipleCalendarsSupport>() || filter.OrganizationID != null)
            {
                select.WhereAnd <Where <Branch.organizationID, Equal <Current <AccBalanceByAssetFilter.organizationID> >, And <MatchWithBranch <Branch.branchID> > > >();
            }
            if (filter.BranchID != null)
            {
                select.WhereAnd <Where <Branch.branchID, Equal <Current <AccBalanceByAssetFilter.branchID> > > >();
            }

            Dictionary <int?, Amounts> dict = new Dictionary <int?, Amounts>();

            foreach (PXResult <FATran, FixedAsset, FADetails, Branch, FALocationHistoryCurrent, FALocationHistory> res in select.Select())
            {
                FATran            tran     = (FATran)res;
                FixedAsset        asset    = (FixedAsset)res;
                FADetails         details  = (FADetails)res;
                FALocationHistory location = (FALocationHistory)res;

                Amounts record = null;
                if (!dict.TryGetValue(asset.AssetID, out record))
                {
                    record = new Amounts
                    {
                        AssetID            = asset.AssetID,
                        Description        = asset.Description,
                        Status             = details.Status,
                        ClassID            = asset.ClassID,
                        DepreciateFromDate = details.DepreciateFromDate,
                        BranchID           = location.BranchID,
                        Department         = location.Department,
                        ItdAmt             = decimal.Zero,
                        YtdAmt             = decimal.Zero,
                        PtdAmt             = decimal.Zero
                    };
                }

                decimal tranAmt = tran.TranAmt ?? decimal.Zero;
                decimal amount  = tran.DebitAccountID == tran.CreditAccountID && tran.DebitSubID == tran.CreditSubID
                                        ? decimal.Zero
                                        : tran.DebitAccountID == filter.AccountID && tran.DebitSubID == filter.SubID ? tranAmt : -tranAmt;

                record.ItdAmt += amount;
                record.YtdAmt += (FinPeriodUtils.FinPeriodEqual(filter.PeriodID, tran.FinPeriodID, FinPeriodUtils.FinPeriodComparison.Year) ? amount : decimal.Zero);
                record.PtdAmt += (filter.PeriodID == tran.FinPeriodID ? amount : decimal.Zero);

                dict[asset.AssetID] = record;
            }

            foreach (Amounts amt in dict.Values)
            {
                if (amt.ItdAmt != decimal.Zero || amt.YtdAmt != decimal.Zero || amt.PtdAmt != decimal.Zero)
                {
                    yield return(amt);
                }
            }
        }