public async Task <IActionResult> MISReport(DateTime fromDate, DateTime toDate)
        {
            if (fromDate == default(DateTime))
            {
                fromDate = DateTime.Now.AddDays(-30);
            }
            if (toDate == default(DateTime))
            {
                toDate = DateTime.Now.Date;
            }

            var purchases = await _context.Purchases
                            .Include(p => p.Vendor)
                            .Include(p => p.WareHouse)
                            .Include(p => p.Product.ProductCatagory)
                            .Include(p => p.PackSize)
                            .Include(p => p.Product)
                            .OrderByDescending(m => m.PurchaseDate)
                            .Where(m => m.PurchaseDate >= fromDate && m.PurchaseDate <= toDate && m.Status == 1)
                            .ToListAsync();

            StockMethod stockMethod = new StockMethod(_context);

            var misVM = stockMethod.GetMisReport(purchases);


            ViewData["misVM"]    = misVM;
            ViewData["FromDate"] = fromDate.Date;
            ViewData["ToDate"]   = toDate.Date;
            return(View());
        }
        public ActionResult WareHouseStockIndex(int id)
        {
            StockMethod stockMethod = new StockMethod(_context);

            List <StockViewModel> stockViewModels = stockMethod.GetWareHouseStock(id);

            var wareHouse = _context.WareHouses.Where(m => m.Id == id).FirstOrDefault();

            ViewData["StockItems"] = stockViewModels;
            ViewData["WareHouse"]  = wareHouse;
            return(View());
        }
        public ActionResult StockIndex(int id)
        {
            StockMethod stockMethod = new StockMethod(_context);

            List <StockViewModel> stockViewModels = stockMethod.GetProductStock(id);

            var product = _context.Products.Where(m => m.Id == id).FirstOrDefault();

            ViewData["StockItems"] = stockViewModels;
            ViewData["Product"]    = product;

            return(View());
        }
Exemple #4
0
        // GET: PurchaseReturns/Create
        public IActionResult Create(int purchaseId)
        {
            var purchase = _context.Purchases
                           .Include(m => m.Product)
                           .Include(m => m.PackSize)
                           .Where(m => m.Id == purchaseId).FirstOrDefault();
            StockMethod stockMethod          = new StockMethod(_context);
            var         purchaseStockDetails = stockMethod.GetPurchaseStock(purchaseId);

            ViewData["Purchase"]     = purchase;
            ViewData["StockDetails"] = purchaseStockDetails;
            return(View());
        }
        public JsonResult GetPurchaseProductById(int id)
        {
            if (id == 0)
            {
                return(Json(false));
            }

            StockMethod stockMethod = new StockMethod(_context);

            var purchaseVM = stockMethod.GetPurchaseStock(id);


            if (purchaseVM == null)
            {
                return(Json(false));
            }
            return(Json(purchaseVM));
        }
Exemple #6
0
        // GET: Sales
        public async Task <IActionResult> Index()
        {
            var applicationDbContext = _context.Sales
                                       .Include(s => s.Broker)
                                       .Include(s => s.Purchase.Product)
                                       .Include(s => s.Purchase.WareHouse)
                                       .Include(s => s.Purchase.PackSize)
                                       .Include(s => s.Purchase)
                                       .Include(s => s.Client)
                                       .Include(s => s.Payments)
                                       .Include(s => s.Purchase.Product.ProductCatagory)
                                       .OrderByDescending(m => m.SaleDate);

            var purchases = await _context.Purchases.Where(m => m.Status == 1).ToListAsync();

            List <Purchase> finalPurchases = new List <Purchase>();

            foreach (var purchase in purchases)
            {
                StockMethod    stockMethod = new StockMethod(_context);
                StockViewModel stockVM     = stockMethod.GetPurchaseStock(purchase.Id);
                if (stockVM.CurrentStockPack != 0 && stockVM.CurrentStockTon != 0)
                {
                    finalPurchases.Add(purchase);
                }
            }


            ViewData["BrokerId"]          = new SelectList(_context.Brokers, "Id", "Name");
            ViewData["PurchaseId"]        = new SelectList(finalPurchases, "Id", "VoucharNo");
            ViewData["ProductId"]         = new SelectList(_context.Products, "Id", "Name");
            ViewData["WareHouseId"]       = new SelectList(_context.WareHouses, "Id", "Name");
            ViewData["ClientId"]          = new SelectList(_context.Clients, "Id", "Name");
            ViewData["ProductCatagoryId"] = new SelectList(_context.ProductCatagories, "Id", "Name");
            return(View(await applicationDbContext.ToListAsync()));
        }
Exemple #7
0
        public async Task <IActionResult> Create(PurchaseReturn purchaseReturn)
        {
            int count = _context.PurchaseReturns.Count() + 1;

            purchaseReturn.VoucharNo = "PRV000" + count.ToString();
            purchaseReturn.Status    = 0;
            if (ModelState.IsValid)
            {
                _context.Add(purchaseReturn);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            var purchase = _context.Purchases
                           .Include(m => m.Product)
                           .Include(m => m.PackSize)
                           .Where(m => m.Id == purchaseReturn.PurchaseId).FirstOrDefault();
            StockMethod stockMethod          = new StockMethod(_context);
            var         purchaseStockDetails = stockMethod.GetPurchaseStock(purchaseReturn.PurchaseId);

            ViewData["Purchase"]     = purchase;
            ViewData["StockDetails"] = purchaseStockDetails;
            return(View(purchaseReturn));
        }
        // GET: RentWareHouses/Edit/5
        public async Task <IActionResult> RentItemIndex(int?rentWareHouseId)
        {
            if (rentWareHouseId == null)
            {
                return(NotFound());
            }

            var rentWareHouse = await _context.RentWareHouses
                                .Include(m => m.RentWareHouseItems)
                                .ThenInclude(m => m.Purchase)
                                .Where(m => m.Id == rentWareHouseId)
                                .FirstOrDefaultAsync();

            var purchases = await _context.Purchases.Where(m => m.Status == 1).ToListAsync();

            List <Purchase> finalPurchases = new List <Purchase>();

            foreach (var purchase in purchases)
            {
                StockMethod    stockMethod = new StockMethod(_context);
                StockViewModel stockVM     = stockMethod.GetPurchaseStock(purchase.Id);
                if (stockVM.CurrentStockPack != 0 && stockVM.CurrentStockTon != 0)
                {
                    finalPurchases.Add(purchase);
                }
            }
            ViewData["PurchaseId"]      = finalPurchases;
            ViewData["RentWareHouseId"] = rentWareHouseId;


            if (rentWareHouse == null)
            {
                return(NotFound());
            }
            return(View(rentWareHouse));
        }