Beispiel #1
0
        public static List <BO_Sales> GetSales(JQueryDataTableParamModel Param)
        {
            using (AprosysAccountingEntities db_aa = new AprosysAccountingEntities())
            {
                //Param.Start_Date = BL_Common.GetDatetime().AddDays(-7);
                Param.End_Date = Param.End_Date.AddDays(1);
                var             lst       = db_aa.GetSaleInvoiceList(Param.Start_Date, Param.End_Date);
                List <BO_Sales> lst_Sales = new List <BO_Sales>();
                BO_Sales        obj;
                var             partial = BL_CreditSales.GetAllPartialPayments().GroupBy(x => x.InvoiceNum).ToDictionary(x => x.Key);
                foreach (var _sales in lst.ToList())
                {
                    obj              = new BO_Sales();
                    obj.invoiceNo    = _sales.InvoiceNo;
                    obj.sellDate     = _sales.ActivityTimestamp.Value;
                    obj.customerName = _sales.cstName;
                    obj.netAmount    = _sales.NETAMOUNT ?? 0;
                    obj.paid         = _sales.PAID;
                    if (_sales.IsSalesCredit.GetValueOrDefault())
                    {
                        obj.paid = 0;
                        if (partial.ContainsKey(obj.invoiceNo))
                        {
                            obj.paid           = partial[obj.invoiceNo].Sum(x => x.Amount);
                            obj.creditPaidDate = partial[obj.invoiceNo].Max(x => x.CreatedDate);
                        }
                    }

                    obj.isCustomerDeleted = _sales.isCustomerActive;
                    obj.isSalesCredit     = _sales.IsSalesCredit ?? false;
                    obj.creditPaidDate    = _sales.CreditPaidDate;
                    lst_Sales.Add(obj);
                }
                return(lst_Sales.OrderByDescending(x => (Convert.ToInt32(x.invoiceNo.Remove(0, 4)))).ToList());
            }
        }