public void Test_UpdateCash() { m_AccountingService.UpdateCash(); CashStatisticsVO cashStatisticsVO = m_AccountingService.GetCashStatisticsVO(DateTime.Today); Assert.IsNotNull(cashStatisticsVO); }
public void Test_UpdateCashByPeriod() { DateTime dateFrom = DateTime.Parse("2016/01/01"); DateTime dateTo = DateTime.Today.AddDays(-1); m_AccountingService.UpdateCashByPeriod(dateFrom, dateTo); CashStatisticsVO cashStatisticsVO = m_AccountingService.GetCashStatisticsVO(DateTime.Today); Assert.IsNotNull(cashStatisticsVO); }
public void UpdateCashByPeriod(DateTime dateFrom, DateTime dateTo) { m_Log.Debug("UpdateCashByPeriod dateFrom: " + dateFrom.ToString("yyyy/MM/dd")); m_Log.Debug("UpdateCashByPeriod dateTo: " + dateTo.ToString("yyyy/MM/dd")); NodeVO node = PostService.GetNodeByName("#每日結帳"); for (DateTime day = dateFrom; day.Date <= dateTo; day = day.AddDays(1)) { m_Log.Debug("UpdateCashByPeriod day: " + day.ToString("yyyy/MM/dd")); CashStatisticsVO cashStatisticsVO = GetCashStatisticsVO(day); if (cashStatisticsVO != null) { //找出有沒有這天的舊的結帳資料,有的話刪除 Dictionary <string, string> conditionsOldCash = new Dictionary <string, string>(); conditionsOldCash.Add("Flag", "1"); conditionsOldCash.Add("NodeId", node.NodeId.ToString()); conditionsOldCash.Add("CloseDate", day.ToString("yyyy/MM/dd")); conditionsOldCash.Add("PageIndex", "0"); conditionsOldCash.Add("PageSize", "1"); IList <PostVO> cashList = PostService.GetPostList(conditionsOldCash); if (cashList != null && cashList.Count > 0) { PostService.DeletePost(cashList[0]); } PostVO post = new PostVO(); post.Node = node; post.Title = "每日結帳"; post.CreatedBy = "admin"; post.UpdatedBy = "admin"; post.CloseDate = cashStatisticsVO.CloseDate; post.Price = cashStatisticsVO.CashToday; PostService.CreatePost(post); } } }
private void LoadDataToUI() { DateTime date; if (DateTime.TryParse(txtDate.Text.Trim(), out date)) { ////今日目前的結餘 CashStatisticsVO cashStatisticsVO = m_AccountingService.GetCashStatisticsVO(date); if (cashStatisticsVO != null) { lblCashYesterday.Text = cashStatisticsVO.CashYesterday.ToString(); SetLabelColor(lblCashYesterday); lblCashToday.Text = cashStatisticsVO.CashToday.ToString(); SetLabelColor(lblCashToday); lblTotalToday.Text = cashStatisticsVO.TotalToday.ToString(); SetLabelColor(lblTotalToday); lblBuyToday.Text = cashStatisticsVO.BuyToday.ToString(); SetLabelColor(lblBuyToday); lblSellToday.Text = cashStatisticsVO.SellToday.ToString(); SetLabelColor(lblSellToday); lblMobileToday.Text = cashStatisticsVO.MobileToday.ToString(); SetLabelColor(lblMobileToday); lblSpecialToday.Text = cashStatisticsVO.SpecialToday.ToString(); SetLabelColor(lblSpecialToday); ////今日進貨 Dictionary <string, string> conditionsBuyToday = new Dictionary <string, string>(); conditionsBuyToday.Add("Flag", "1"); conditionsBuyToday.Add("NodeId", "2"); conditionsBuyToday.Add("ShowDate", date.ToString("yyyy/MM/dd")); gvBuyToday.DataSource = m_PostService.GetPostList(conditionsBuyToday); gvBuyToday.DataBind(); ////今日銷貨 Dictionary <string, string> conditionsSellToday = new Dictionary <string, string>(); conditionsSellToday.Add("Flag", "1"); conditionsSellToday.Add("NodeId", "2"); conditionsSellToday.Add("Type", "1"); //conditionsSellToday.Add("WithOutMemberId", "1"); conditionsSellToday.Add("CloseDate", date.ToString("yyyy/MM/dd")); gvSellToday.DataSource = m_PostService.GetPostList(conditionsSellToday); gvSellToday.DataBind(); ////今日門號 IList <NodeVO> storeList = m_PostService.GetNodeListByParentName("店家"); Dictionary <string, string> conditionsMember = new Dictionary <string, string>(); conditionsMember.Add("Status", "1"); conditionsMember.Add("ApplyDate2", date.ToString("yyyy/MM/dd")); conditionsMember.Add("Store", storeList[0].Name); gvMobileToday.DataSource = m_MemberService.GetMemberList(conditionsMember); gvMobileToday.DataBind(); ////特別收支 NodeVO nodeSpecial = m_PostService.GetNodeByName("#特別現金收支"); Dictionary <string, string> conditionsSpecial = new Dictionary <string, string>(); conditionsSpecial.Add("Flag", "1"); conditionsSpecial.Add("NodeId", nodeSpecial.NodeId.ToString()); conditionsSpecial.Add("CloseDate", date.ToString("yyyy/MM/dd")); gvSpecialToday.DataSource = m_PostService.GetPostList(conditionsSpecial); gvSpecialToday.DataBind(); } else { ShowMode(); } } else { ShowMode(); } }
public void Test_GetCashStatisticsVO() { CashStatisticsVO cashStatisticsVO = m_AccountingService.GetCashStatisticsVO(DateTime.Parse("2016/02/02")); Assert.IsNotNull(cashStatisticsVO); }
/// <summary> /// 取得結帳資訊 By 日期 /// </summary> /// <param name="day"></param> /// <returns>如果沒有前一天的結帳金額,則回傳null</returns> public CashStatisticsVO GetCashStatisticsVO(DateTime day) { m_Log.Debug("GetCashStatisticsVO day: " + day.ToString("yyyy/MM/dd")); ////抓前一日的結帳金額,有的話才計算該天的結帳 NodeVO node = PostService.GetNodeByName("#每日結帳"); Dictionary <string, string> conditionsYesterdayCash = new Dictionary <string, string>(); conditionsYesterdayCash.Add("Flag", "1"); conditionsYesterdayCash.Add("NodeId", node.NodeId.ToString()); conditionsYesterdayCash.Add("CloseDate", day.AddDays(-1).ToString("yyyy/MM/dd")); conditionsYesterdayCash.Add("PageIndex", "0"); conditionsYesterdayCash.Add("PageSize", "1"); IList <PostVO> postYesterdayCashList = PostService.GetPostList(conditionsYesterdayCash); if (postYesterdayCashList != null && postYesterdayCashList.Count > 0) { CashStatisticsVO cashStatisticsVO = new CashStatisticsVO(); cashStatisticsVO.CashYesterday = postYesterdayCashList[0].Price; cashStatisticsVO.CloseDate = DateTime.Parse(day.ToString("yyyy/MM/dd")); //今日庫存進貨 Dictionary <string, string> conditionsBuyToday = new Dictionary <string, string>(); conditionsBuyToday.Add("Flag", "1"); conditionsBuyToday.Add("NodeId", "2"); conditionsBuyToday.Add("ShowDate", day.ToString("yyyy/MM/dd")); IList <PostVO> postBuyTodayList = PostService.GetPostList(conditionsBuyToday); if (postBuyTodayList != null && postBuyTodayList.Count > 0) { cashStatisticsVO.BuyToday -= postBuyTodayList.Sum(p => p.Price * p.Quantity); } //今日庫存銷貨 Dictionary <string, string> conditionsSellToday = new Dictionary <string, string>(); conditionsSellToday.Add("Flag", "1"); conditionsSellToday.Add("NodeId", "2"); conditionsSellToday.Add("Type", "1"); //conditionsSellToday.Add("WithOutMemberId", "1"); conditionsSellToday.Add("CloseDate", day.ToString("yyyy/MM/dd")); IList <PostVO> postSellTodayList = PostService.GetPostList(conditionsSellToday); if (postSellTodayList != null && postSellTodayList.Count > 0) { cashStatisticsVO.SellToday = postSellTodayList.Sum(p => p.SellPrice * p.Quantity); } //門號 IList <NodeVO> storeList = PostService.GetNodeListByParentName("店家"); Dictionary <string, string> conditionsMember = new Dictionary <string, string>(); conditionsMember.Add("Status", "1"); conditionsMember.Add("ApplyDate2", day.ToString("yyyy/MM/dd")); conditionsMember.Add("Store", storeList[0].Name); IList <MemberVO> memberList = MemberService.GetMemberList(conditionsMember); if (memberList != null && memberList.Count > 0) { cashStatisticsVO.MobileToday = memberList.Sum(m => m.PhoneSellPrice - m.PhonePrice - m.BreakMoney); //如果沒有幫客戶預繳, 則現金要加上預繳金額 cashStatisticsVO.MobileToday += memberList.Where(m => m.Prepayment > 0 && !"是".Equals(m.SelfPrepayment)).Sum(m => m.Prepayment); foreach (MemberVO member in memberList) { if (member.Posts != null && member.Posts.Count > 0) { //如果這個客戶的手機是來自庫存的, 那麼手機進價要移除支出的部分 cashStatisticsVO.MobileToday += member.PhonePrice; } } } //特別現金收支 NodeVO nodeSpecial = PostService.GetNodeByName("#特別現金收支"); Dictionary <string, string> conditionsSpecial = new Dictionary <string, string>(); conditionsSpecial.Add("Flag", "1"); conditionsSpecial.Add("NodeId", nodeSpecial.NodeId.ToString()); conditionsSpecial.Add("CloseDate", day.ToString("yyyy/MM/dd")); IList <PostVO> postSpecialList = PostService.GetPostList(conditionsSpecial); if (postSpecialList != null && postSpecialList.Count > 0) { cashStatisticsVO.SpecialToday = postSpecialList.Sum(p => p.Price); } //最後總計 cashStatisticsVO.TotalToday = cashStatisticsVO.BuyToday + cashStatisticsVO.SellToday + cashStatisticsVO.MobileToday + cashStatisticsVO.SpecialToday; cashStatisticsVO.CashToday = cashStatisticsVO.CashYesterday + cashStatisticsVO.TotalToday; return(cashStatisticsVO); } else { return(null); } }