예제 #1
0
        public List <SoQuyTienMat> GetTienGuiNganHang(DateTime fromDate, DateTime toDate)
        {
            var psData = ReportDAO.GetTienGuiNganHang(fromDate, toDate);
            var dkData = BalanceLogic.GetBalanceList(fromDate);

            dkData = dkData
                     .Where(o => o.AccountID.StartsWith("112"))
                     .GroupBy(o => new { o.AccountID, o.AccountDetailID })
                     .Select(o => new GetBalance
            {
                AccountID       = o.Key.AccountID,
                AccountDetailID = o.Key.AccountDetailID,
                AccountName     = o.Max(s => s.AccountName),
                DebitBalance    = o.Sum(s => s.DebitBalance),
                CreditBalance   = o.Sum(s => s.CreditBalance)
            })
                     .ToList();


            if (psData != null && psData.Count > 0)
            {
                string  preAccountID = string.Empty, preAccountDetailID = string.Empty;
                decimal DKNo = 0;
                // có phát sinh
                foreach (var item in psData)
                {
                    if (preAccountID != item.AccountID || preAccountDetailID != item.AccountDetailID)
                    {
                        preAccountID       = item.AccountID;
                        preAccountDetailID = item.AccountDetailID;
                        var find = dkData.Find(o => o.AccountID == preAccountID && o.AccountDetailID == preAccountDetailID);

                        if (find != null)
                        {
                            DKNo = find.DebitBalance - find.CreditBalance;
                        }
                        else
                        {
                            DKNo = 0;
                        }
                    }

                    item.DebitBalance = DKNo;
                }
            }
            else
            {
                // Không có phát sinh
                return(null);
            }

            return(psData);
        }