예제 #1
0
        private Model应收应付 应收应付及明细(string Id)
        {
            var yingShou = ReceivableWithDetails(Id);
            var yingFu   = PayableWithDetails(Id);

            var yingShouYingFu = new Model应收应付
            {
                单位编号 = Id,
                单位名称 = _pinhuaContext.往来单位.AsNoTracking().FirstOrDefault(p => p.单位编号 == Id)?.单位名称,
                应收合计 = (yingShou.应收合计 ?? 0) + (yingFu.应收合计 ?? 0),
                明细   = yingShou.明细.Union(yingFu.明细).OrderByDescending(x => x.Date).ThenByDescending(x => x.OrderId).ToList()
            };

            if (yingShou.明细.FindAll(x => x.TypeDescription == "上期结算").Any() && yingFu.明细.FindAll(x => x.TypeDescription == "上期结算").Any())
            {
                var row = yingShou.明细.Find(x => x.TypeDescription == "上期结算");
                row.Amount = -yingFu.明细.Find(x => x.TypeDescription == "上期结算").Amount;
                yingShouYingFu.明细.RemoveAll(x => x.TypeDescription == "上期结算");
                yingShouYingFu.明细.Add(row);
            }
            return(yingShouYingFu);
        }
예제 #2
0
        private Model应收应付 PayableWithDetails(string Id)
        {
            var last日期 = statementResultList(Id).Any() ? statementResultList(Id).Max(x => x.日期) : new DateTime(1900, 1, 1); // 最新对账日期
            //var last金额 = statementResultList(Id)
            //    .Where(x => x.日期 == last日期)
            //    .Select(x => new Model应收应付明细
            //    {
            //        Date = x.日期,
            //        Amount = -x.应付,
            //        TypeDescription = "结算",
            //        OrderId = "Settlement"
            //    }); // 最新对账金额

            // 对账后的收发详情
            // var listOf出库After = listOf出库(Id).Where(x => x.Record.送货日期 > last日期);
            var listOf入库After = GetPayableList(Id).Where(x => x.Record.Date > last日期);
            // 对账后的收款详情
            var listOf付款After = from p in paymentList(Id)
                                where p.付款日期 > last日期
                                select new Model应收应付明细
            {
                Date            = p.付款日期,
                Amount          = p.付款金额,
                Remarks         = p.备注,
                TypeDescription = "付款",
                OrderId         = p.付款单号,
            };
            var hello = from p in listOf入库After
                        group p by p.Record.OrderId into g
                        select new
            {
                g.Key,
                单据应付合计 = g.Sum(e => e.RecordDetail.Amount)
            };

            var yingFu = (from p in listOf入库After
                          join p2 in hello on p.Record.OrderId equals p2.Key
                          select new Model应收应付明细
            {
                Type = p.Record.Type,
                TypeDescription = p.Record.TypeDescription,
                Date = p.Record.Date,
                OrderId = p.Record.OrderId,
                ItemId = p.RecordDetail.ItemId,
                ItemDescription = p.RecordDetail.Description,
                Specification = p.RecordDetail.Specification,
                Qty = p.RecordDetail.Qty,
                UnitQty = p.RecordDetail.UnitQty,
                Unit = p.RecordDetail.Unit,
                Price = p.RecordDetail.Price,
                Amount = -p.RecordDetail.Amount,
                TotalAmount = -p2.单据应付合计
            })
                         .Union(listOf付款After);
            //.Union(last金额);

            // 应收与明细
            var yingFuWithDetails = new Model应收应付
            {
                单位编号 = Id,
                明细   = yingFu.OrderByDescending(x => x.Date).ThenByDescending(x => x.OrderId).ToList(),
                应收合计 = yingFu.Sum(x => x.Amount)
            };

            return(yingFuWithDetails);
        }
예제 #3
0
        private Model应收应付 ReceivableWithDetails(string Id)
        {
            var last日期 = statementResultList(Id).Any() ? statementResultList(Id).Max(x => x.日期) : new DateTime(1900, 1, 1); // 最新对账日期
            var last金额 = statementResultList(Id)
                         .Where(x => x.日期 == last日期)
                         .Select(x => new Model应收应付明细
            {
                Date            = x.日期,
                Amount          = x.应收 - x.应付,
                TypeDescription = "结算",
                OrderId         = "Settlement"
            });     // 最新对账金额

            // 对账后的收发详情
            var listOf出库After = GetReceivableList(Id).Where(x => x.Record.Date > last日期);
            // var listOf入库After = listOf入库(Id).Where(x => x.Record.送货日期 > last日期);
            // 对账后的收款详情
            var listOf收款After = from p in collectionList(Id)
                                where p.收款日期 > last日期
                                select new Model应收应付明细
            {
                Date            = p.收款日期,
                Amount          = -p.收款金额,
                Remarks         = p.备注,
                TypeDescription = "收款",
                OrderId         = p.收款单号,
                RcId            = p.ExcelServerRcid
            };
            var hello = from p in listOf出库After
                        group p by p.Record.OrderId into g
                        select new
            {
                g.Key,
                单据应收合计 = g.Sum(e => e.RecordDetail.Amount)
            };
            var yingShou = (from p in listOf出库After
                            join p2 in hello on p.Record.OrderId equals p2.Key
                            select new Model应收应付明细
            {
                Type = p.Record.Type,
                TypeDescription = p.Record.TypeDescription,
                Date = p.Record.Date,
                OrderId = p.Record.OrderId,
                ItemId = p.RecordDetail.ItemId,
                ItemDescription = p.RecordDetail.Description,
                Specification = p.RecordDetail.Specification,
                Qty = p.RecordDetail.Qty,
                UnitQty = p.RecordDetail.UnitQty,
                Unit = p.RecordDetail.Unit,
                Price = p.RecordDetail.Price,
                Amount = p.RecordDetail.Amount,
                Remarks = p.Record.Remarks,
                TotalAmount = p2.单据应收合计
            })
                           .Union(listOf收款After)
                           .Union(last金额);

            // 应收与明细
            var yingShouWithDetails = new Model应收应付
            {
                单位编号 = Id,
                明细   = yingShou.OrderByDescending(x => x.Date).ThenByDescending(x => x.OrderId).ToList(),
                应收合计 = yingShou.Sum(x => x.Amount)
            };

            return(yingShouWithDetails);
        }
예제 #4
0
 public void OnGet(string Id)
 {
     this.Id       = Id;
     StatementData = 应收应付及明细(Id);
 }
예제 #5
0
 public void OnGet()
 {
     StatementData = 应收应付及明细(CustomerId);
 }