Exemplo n.º 1
0
        public ActionResult ZeroOut(int id)
        {
            var    entity = InventoryReceipt.Find(id);
            string sql    = @"SELECT p.code Code, p.name Name, s.lot_number LotNumber, s.expiration_date ExpirationDate, s.serial_number SerialNumber, SUM(s.quantity) Quantity
                            FROM lot_serial_tracking s
                            INNER JOIN product p ON s.product = p.product_id
                            WHERE s.warehouse = :warehouse AND s.date < :date
                            GROUP BY s.product, s.lot_number, s.expiration_date, s.serial_number
                            HAVING SUM(s.quantity) <> 0";

            var items = (IList <dynamic>) ActiveRecordMediator <Product> .Execute(delegate(ISession session, object instance) {
                var query = session.CreateSQLQuery(sql);

                query.AddScalar("Code", NHibernateUtil.String);
                query.AddScalar("Name", NHibernateUtil.String);
                query.AddScalar("LotNumber", NHibernateUtil.String);
                query.AddScalar("ExpirationDate", NHibernateUtil.Date);
                query.AddScalar("SerialNumber", NHibernateUtil.String);
                query.AddScalar("Quantity", NHibernateUtil.Decimal);

                query.SetInt32("warehouse", entity.Warehouse.Id);
                query.SetDateTime("date", entity.ModificationTime);

                return(query.DynamicList());
            }, null);

            return(View("PhysicalCountAdjustment", items));
        }
Exemplo n.º 2
0
        public ActionResult CancelReceipt(int id)
        {
            var item = InventoryReceipt.Find(id);

            item.IsCancelled = true;

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

            return(RedirectToAction("Receipts"));
        }
Exemplo n.º 3
0
        public ActionResult PhysicalCountAdjustmentConfirmed(int id)
        {
            var    entity = InventoryReceipt.Find(id);
            string sql    = @"SELECT s.product ProductId, s.lot_number LotNumber, s.expiration_date ExpirationDate, s.serial_number SerialNumber, SUM(s.quantity) Quantity
                            FROM lot_serial_tracking s
                            INNER JOIN inventory_receipt_detail d ON s.product = d.product
                            WHERE d.receipt = :id AND s.warehouse = :warehouse AND s.date < :date
                            GROUP BY s.product, s.lot_number, s.expiration_date, s.serial_number
                            HAVING SUM(s.quantity) <> 0";

            var items = (IList <dynamic>) ActiveRecordMediator <Product> .Execute(delegate(ISession session, object instance) {
                var query = session.CreateSQLQuery(sql);

                query.AddScalar("ProductId", NHibernateUtil.Int32);
                query.AddScalar("LotNumber", NHibernateUtil.String);
                query.AddScalar("ExpirationDate", NHibernateUtil.Date);
                query.AddScalar("SerialNumber", NHibernateUtil.String);
                query.AddScalar("Quantity", NHibernateUtil.Decimal);

                query.SetInt32("id", entity.Id);
                query.SetInt32("warehouse", entity.Warehouse.Id);
                query.SetDateTime("date", entity.ModificationTime);

                return(query.DynamicList());
            }, null);

            using (var scope = new TransactionScope()) {
                var dt = entity.ModificationTime.AddMilliseconds(-1);

                foreach (var x in items)
                {
                    var item = new LotSerialTracking {
                        Source         = TransactionType.InventoryAdjustment,
                        Reference      = entity.Id,
                        Date           = dt,
                        Warehouse      = entity.Warehouse,
                        Product        = Product.Find(x.ProductId),
                        Quantity       = -x.Quantity,
                        LotNumber      = x.LotNumber,
                        ExpirationDate = x.ExpirationDate,
                        SerialNumber   = x.SerialNumber
                    };

                    item.Create();
                }

                scope.Flush();
            }

            return(RedirectToAction("Receipts"));
        }
Exemplo n.º 4
0
        public ActionResult EditReceipt(InventoryReceipt item)
        {
            var movement = InventoryReceipt.Find(item.Id);

            movement.Warehouse        = Warehouse.Find(item.WarehouseId);
            movement.Store            = movement.Warehouse.Store;
            movement.Updater          = CurrentUser.Employee;
            movement.ModificationTime = DateTime.Now;
            movement.Comment          = item.Comment;

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

            return(PartialView("Receipts/_MasterView", movement));
        }
Exemplo n.º 5
0
        public ActionResult EditReceipt(int id)
        {
            var item = InventoryReceipt.Find(id);

            if (item.IsCompleted || item.IsCancelled)
            {
                return(RedirectToAction("Receipt", new {
                    id = item.Id
                }));
            }

            if (Request.IsAjaxRequest())
            {
                return(PartialView("Receipts/_MasterEditView", item));
            }
            else
            {
                return(View("Receipts/Edit", item));
            }
        }
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 ViewResult Receipt(int id)
        {
            var item = InventoryReceipt.Find(id);

            return(View("Receipts/View", item));
        }
Exemplo n.º 8
0
 public ActionResult GetTotalQuantityReceipt(int id)
 {
     return(PartialView("Receipts/_TotalQuantity", InventoryReceipt.Find(id)));
 }