Exemplo n.º 1
0
        public JsonResult RemoveReceiptDetail(int id)
        {
            var item = InventoryReceiptDetail.Find(id);

            using (var scope = new TransactionScope()) {
                item.DeleteAndFlush();
            }

            return(Json(new {
                id = id,
                result = true
            }));
        }
Exemplo n.º 2
0
        public JsonResult EditReceiptDetailQuantity(int id, decimal value)
        {
            var detail = InventoryReceiptDetail.Find(id);

            if (value >= 0)
            {
                detail.Quantity = value;

                using (var scope = new TransactionScope()) {
                    detail.UpdateAndFlush();
                }
            }

            return(Json(new {
                id = id,
                value = detail.Quantity
            }));
        }
Exemplo n.º 3
0
        public JsonResult AddReceiptDetail(int movement, int product)
        {
            var p = Product.Find(product);

            var item = new InventoryReceiptDetail {
                Receipt         = InventoryReceipt.Find(movement),
                Product         = p,
                ProductCode     = p.Code,
                ProductName     = p.Name,
                Quantity        = 1,
                QuantityOrdered = 0
            };

            using (var scope = new TransactionScope()) {
                item.CreateAndFlush();
            }

            return(Json(new {
                id = item.Id
            }));
        }
Exemplo n.º 4
0
        public ActionResult Confirm(int id)
        {
            PurchaseOrder item = PurchaseOrder.Find(id);

            var qry = from x in item.Details
                      group x by x.Warehouse into g
                      select new {
                Warehouse = g.Key,
                Details   = g.ToList()
            };

            var dt       = DateTime.Now;
            var employee = CurrentUser.Employee;

            using (var scope = new TransactionScope()) {
                foreach (var x in qry)
                {
                    var master = new InventoryReceipt {
                        Order            = item,
                        Warehouse        = x.Warehouse,
                        CreationTime     = dt,
                        ModificationTime = dt,
                        Creator          = employee,
                        Updater          = employee,
                        Store            = x.Warehouse.Store
                    };

                    master.Create();

                    foreach (var y in x.Details)
                    {
                        var detail = new InventoryReceiptDetail {
                            Receipt         = master,
                            Product         = y.Product,
                            QuantityOrdered = y.Quantity,
                            Quantity        = y.Quantity,
                            ProductCode     = y.ProductCode,
                            ProductName     = y.ProductName
                        };

                        detail.Create();

                        InventoryHelpers.ChangeNotification(TransactionType.PurchaseOrder, item.Id,
                                                            item.ModificationTime, x.Warehouse, null, y.Product, y.Quantity);
                    }
                }

                foreach (var x in item.Details)
                {
                    var price = x.Product.Prices.SingleOrDefault(t => t.List.Id == 0);

                    if (price == null)
                    {
                        price = new ProductPrice {
                            List    = PriceList.Find(0),
                            Product = x.Product
                        };
                    }

                    price.Value = x.Price;
                    price.Save();
                }

                item.IsCompleted      = true;
                item.ModificationTime = DateTime.Now;
                item.UpdateAndFlush();
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 5
0
 public ActionResult GetReceiptItem(int id)
 {
     return(PartialView("Receipts/_DetailEditView", InventoryReceiptDetail.Find(id)));
 }
Exemplo n.º 6
0
        public JsonResult AddReceiptDetail(int movement, int product)
        {
            var p = Product.Find (product);

            var item = new InventoryReceiptDetail {
                Receipt = InventoryReceipt.Find (movement),
                Product = p,
                ProductCode = p.Code,
                ProductName = p.Name,
                Quantity = 1,
                QuantityOrdered = 0
            };

            using (var scope = new TransactionScope ()) {
                item.CreateAndFlush ();
            }

            return Json (new {
                id = item.Id
            });
        }
Exemplo n.º 7
0
        public ActionResult Confirm(int id)
        {
            PurchaseOrder item = PurchaseOrder.Find (id);

            var qry = from x in item.Details
                  group x by x.Warehouse into g
                  select new {
                      Warehouse = g.Key,
                      Details = g.ToList ()
                  };

            var dt = DateTime.Now;
            var employee = CurrentUser.Employee;

            using (var scope = new TransactionScope ()) {
                foreach (var x in qry) {
                    var master = new InventoryReceipt {
                        Order = item,
                        Warehouse = x.Warehouse,
                        CreationTime = dt,
                        ModificationTime = dt,
                        Creator = employee,
                        Updater = employee,
                        Store = x.Warehouse.Store
                    };

                    master.Create ();

                    foreach (var y in x.Details) {
                        var detail = new InventoryReceiptDetail {
                            Receipt = master,
                            Product = y.Product,
                            QuantityOrdered = y.Quantity,
                            Quantity = y.Quantity,
                            ProductCode = y.ProductCode,
                            ProductName = y.ProductName
                        };

                        detail.Create ();

                        InventoryHelpers.ChangeNotification (TransactionType.PurchaseOrder, item.Id,
                            item.ModificationTime, x.Warehouse, null, y.Product, y.Quantity);
                    }
                }

                foreach (var x in item.Details) {
                    var price = x.Product.Prices.SingleOrDefault (t => t.List.Id == 0);

                    if (price == null) {
                        price = new ProductPrice {
                            List = PriceList.Find (0),
                            Product = x.Product
                        };
                    }

                    price.Value = x.Price;
                    price.Save ();
                }

                item.IsCompleted = true;
                item.ModificationTime = DateTime.Now;
                item.UpdateAndFlush ();
            }

            return RedirectToAction ("Index");
        }