日期:2014-05-18 浏览次数:20882 次
this.dailyRevenueList = //(from p in (from p in dc.Sales join sd in dc.SaleDetails on p.GUID equals sd.MasterGUID join ch in dc.Checks on p.GUID equals ch.MasterGUID into ch_table from ch in ch_table.DefaultIfEmpty() join c in dc.Customers on p.CustomerGUID equals c.GUID into c_table from c in c_table.DefaultIfEmpty() join u in dc.Users on p.MarkerUserGUID equals u.GUID into u_table from u in u_table.DefaultIfEmpty() where p.DateTime >= dateTimeFrom && p.DateTime <= dateTimeTo && p.IsApproved == true select new DailyRevenueViews { GUID = p.GUID, No = p.No, // DateTime = p.DateTime, CustomerName = c.Name, CustomerTaxNo = c.TaxNo, //金额=销售单价*销售数量*实际折扣 Amount = dc.SaleDetails.Where(t => t.MasterGUID == p.GUID).Sum(t => t.UnitPrice * t.Quantity * t.DiscountRateFact), //税额=(销售含税单价-销售单价)*销售数量*实际折扣 TaxAmount = dc.SaleDetails.Where(t => t.MasterGUID == p.GUID).Sum(t => (t.UnitPriceTax - t.UnitPrice) * t.Quantity * t.DiscountRateFact), //应收金额 TotalAmount = dc.SaleDetails.Where(t => t.MasterGUID == p.GUID).Sum(t => t.UnitPriceTax * t.Quantity * t.DiscountRateFact), //现金收款 CashRevenue = p.Receipt, //支票/转账/饭票收款 CheckRevenue = dc.Checks.Where(t => t.MasterGUID == p.GUID && t.IsCashed == true).Sum(t => t.Amount), //CheckRevenue =ch_table.Where(t=>t.IsCashed==true).Sum(t=>t.Amount), //合计收款 TotalRevenue = 0, // 发票 RelationNo1 = p.InvoiceGUID != null ? dc.Invoices.Where(t => t.GUID == p.InvoiceGUID).FirstOrDefault().No : "", // 送货单 RelationNo2 = p.WaybillGUID != null ? dc.Waybills.Where(t => t.GUID == p.WaybillGUID).FirstOrDefault().No : "", //IsApproved = p.IsApproved, //IsClose = p.IsClosed, Remark = p.Remark, MarkerUser = u.Name, }).Distinct().ToList();
this.dailyRevenueList = (from p in (from p in dc.Sales join sd in dc.SaleDetails on p.GUID equals sd.MasterGUID join ch in dc.Checks on p.GUID equals ch.MasterGUID into ch_table from ch in ch_table.DefaultIfEmpty() join c in dc.Customers on p.CustomerGUID equals c.GUID into c_table from c in c_table.DefaultIfEmpty() join u in dc.Users on p.MarkerUserGUID equals u.GUID into u_table