internal List <InventoryStockVm> GetStockReportList(InventoryReportVm reportVm)
        {
            List <InventorySale> sales  = _reportDal.GetSalesByReportVm(reportVm);
            List <Order>         orders = _reportDal.GetOrdersByReportVm(reportVm);

            if (orders != null)
            {
                foreach (var item in orders)
                {
                    foreach (var itemDes in item.OrderDetail)
                    {
                        InventoryStockVm stockVm = new InventoryStockVm();
                        if (StockReportList.Any(m => m.ItemName == itemDes.Item.Name) == false)
                        {
                            stockVm.ItemName         = itemDes.Item.Name;
                            stockVm.StockQuantity    = _common.GetItemStockById(itemDes.Item.Id);
                            stockVm.CategoryFullPath = GetCategoryFullPathById(itemDes.Item.Id);
                            stockVm.Price            = itemDes.Item.CostPrice;
                            StockReportList.Add(stockVm);
                        }
                    }
                }
            }
            return(StockReportList.ToList());
        }
        internal InventoryIncomeVm GetIncomeVmByReportVm(InventoryReportVm reportVm)
        {
            decimal totalIncome         = 0;
            decimal totalSales          = 0;
            decimal totalOrder          = 0;
            List <InventorySale> sales  = _reportDal.GetSalesByReportVm(reportVm);
            List <Order>         orders = _reportDal.GetOrdersByReportVm(reportVm);

            if (sales != null)
            {
                foreach (var item in sales)
                {
                    totalSales = totalSales + item.Total;
                }
            }
            if (orders != null)
            {
                foreach (var item in orders)
                {
                    totalOrder = totalOrder + item.Total;
                }
            }

            totalIncome = totalSales - totalOrder;
            InventoryIncomeVm incomeVm = new InventoryIncomeVm();

            incomeVm.Sales       = sales;
            incomeVm.Orders      = orders;
            incomeVm.SalesTotal  = totalSales;
            incomeVm.OrdersTotal = totalOrder;
            incomeVm.TotalIncome = totalIncome;
            return(incomeVm);
        }
        public ActionResult SalesReport(InventoryReportVm reportVm)
        {
            List <InventorySale> inventorySales = _reportBll.GetSalesByReportVm(reportVm);

            _salesPdf        = inventorySales;
            ViewBag.OutletId = _reportBll.GetOutlet();
            return(View(inventorySales));
        }
        public ActionResult OrderReport(InventoryReportVm reportVm)
        {
            List <Order> orders = _reportBll.GetOrdersByReportVm(reportVm);

            OrdersPdf        = orders;
            ViewBag.OutletId = _reportBll.GetOutlet();
            return(View(orders));
        }
        public ActionResult Expense(InventoryReportVm reportVm)
        {
            List <Expense> Expenses = _reportBll.GetExpensesByReportVm(reportVm);

            ExpensesPdf      = Expenses;
            ViewBag.OutletId = _reportBll.GetOutlet();
            return(View(Expenses));
        }
        public ActionResult StockReport(InventoryReportVm reportVm)
        {
            List <InventoryStockVm> stockReportList = _reportBll.GetStockReportList(reportVm);

            _stockReportListPdf = stockReportList;
            ViewBag.OutletId    = _reportBll.GetOutlet();
            return(View(stockReportList));
        }
        public ActionResult IncomeReport(InventoryReportVm reportVm)
        {
            InventoryIncomeVm incomeVm = _reportBll.GetIncomeVmByReportVm(reportVm);

            _incomeVmForPdf  = incomeVm;
            ViewBag.OutletId = _reportBll.GetOutlet();
            return(View(incomeVm));
        }
        internal List <Order> GetOrdersByReportVm(InventoryReportVm reportVm)
        {
            var orders = _db.Orders.AsQueryable();

            if (reportVm.OutletId != null)
            {
                orders = orders.Where(m => m.OutletId == reportVm.OutletId && m.IsDeleted == false).AsQueryable();
            }
            if (reportVm.Code != null)
            {
                orders = orders.Where(m => m.Id == reportVm.Code && m.IsDeleted == false).AsQueryable();
            }
            if (reportVm.FromDate != null)
            {
                orders = orders.Where(m => m.OrderDate >= reportVm.FromDate && m.IsDeleted == false).AsQueryable();
            }
            if (reportVm.ToDate != null)
            {
                orders = orders.Where(m => m.OrderDate <= reportVm.ToDate && m.IsDeleted == false).AsQueryable();
            }
            return(orders.ToList());
        }
        internal List <InventorySale> GetSalesByReportVm(InventoryReportVm reportVm)
        {
            var sales = _db.InventorySales.AsQueryable();

            if (reportVm.OutletId != null)
            {
                sales = sales.Where(m => m.OutletId == reportVm.OutletId && m.IsDeleted == false).AsQueryable();
            }
            if (reportVm.Code != null)
            {
                sales = sales.Where(m => m.Id == reportVm.Code && m.IsDeleted == false).AsQueryable();
            }
            if (reportVm.FromDate != null)
            {
                sales = sales.Where(m => m.SaleDate >= reportVm.FromDate && m.IsDeleted == false).AsQueryable();
            }
            if (reportVm.ToDate != null)
            {
                sales = sales.Where(m => m.SaleDate <= reportVm.ToDate && m.IsDeleted == false).AsQueryable();
            }
            return(sales.ToList());
        }
        internal List <Expense> GetExpensesByReportVm(InventoryReportVm reportVm)
        {
            var expenses = _db.Expenses.AsQueryable();

            if (reportVm.OutletId != null)
            {
                expenses = expenses.Where(m => m.OutletId == reportVm.OutletId && m.IsDeleted == false).AsQueryable();
            }
            if (reportVm.Code != null)
            {
                expenses = expenses.Where(m => m.Id == reportVm.Code && m.IsDeleted == false).AsQueryable();
            }
            if (reportVm.FromDate != null)
            {
                expenses = expenses.Where(m => m.ExpenseDate >= reportVm.FromDate && m.IsDeleted == false).AsQueryable();
            }
            if (reportVm.ToDate != null)
            {
                expenses = expenses.Where(m => m.ExpenseDate <= reportVm.ToDate && m.IsDeleted == false).AsQueryable();
            }

            return(expenses.ToList());
        }
        internal List <InventorySale> GetSalesByReportVm(InventoryReportVm reportVm)
        {
            List <InventorySale> sales = _reportDal.GetSalesByReportVm(reportVm);

            return(sales);
        }
        internal List <Order> GetOrdersByReportVm(InventoryReportVm reportVm)
        {
            List <Order> orders = _reportDal.GetOrdersByReportVm(reportVm);

            return(orders);
        }
        internal List <Expense> GetExpensesByReportVm(InventoryReportVm reportVm)
        {
            List <Expense> expenses = _reportDal.GetExpensesByReportVm(reportVm);

            return(expenses);
        }