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)); }
public ActionResult ConfirmReceipt(int id) { var item = InventoryReceipt.TryFind(id); if (item == null || item.IsCompleted || item.IsCancelled) { return(RedirectToAction("Receipts")); } item.Store = item.Warehouse.Store; try { item.Serial = (from x in InventoryReceipt.Queryable where x.Store.Id == item.Store.Id select x.Serial).Max() + 1; } catch { item.Serial = 1; } item.IsCompleted = true; item.ModificationTime = DateTime.Now; using (var scope = new TransactionScope()) { item.UpdateAndFlush(); foreach (var x in item.Details) { InventoryHelpers.ChangeNotification(TransactionType.InventoryReceipt, item.Id, item.ModificationTime, item.Warehouse, null, x.Product, x.Quantity); } } return(RedirectToAction("Receipts")); }
public ActionResult CancelReceipt(int id) { var item = InventoryReceipt.Find(id); item.IsCancelled = true; using (var scope = new TransactionScope()) { item.UpdateAndFlush(); } return(RedirectToAction("Receipts")); }
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")); }
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)); }
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)); } }
private InventoryReceipt BuildReceipt(string warehouseId, List <ShopifyInventoryLevel> inventory) { var postingDate = DateTime.UtcNow.Date; var controlQty = inventory.ControlQty(); var controlCost = inventory.CogsControlTotal(); var receipt = new InventoryReceipt(); receipt.Date = postingDate.ToValue(); receipt.ControlCost = controlCost.ToValue(); receipt.ControlQty = ((double)controlQty).ToValue(); receipt.Details = new List <InventoryReceiptDetails>(); receipt.Hold = false.ToValue(); foreach (var inventoryLevel in inventory) { if (inventoryLevel.ShopifyAvailableQuantity <= 0) { continue; } var variant = inventoryLevel.ShopifyVariant; var location = inventoryLevel.ShopifyLocation; var stockItemId = variant.AcumaticaStockItemId(); var unitCogs = (double)inventoryLevel.ShopifyVariant.ShopifyCost; var qty = (double)inventoryLevel.ShopifyAvailableQuantity; var detail = new InventoryReceiptDetails(); detail.InventoryID = stockItemId.ToValue(); detail.UnitCost = unitCogs.ToValue(); detail.Qty = qty.ToValue(); detail.WarehouseID = warehouseId.ToValue(); receipt.Details.Add(detail); } return(receipt); }
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 })); }
public ActionResult NewReceipt(InventoryReceipt item) { if (!ModelState.IsValid) { return(PartialView("Receipts/_Create", item)); } item.CreationTime = DateTime.Now; item.ModificationTime = item.CreationTime; item.Creator = CurrentUser.Employee; item.Updater = item.Creator; item.Warehouse = Warehouse.Find(item.WarehouseId); item.Store = item.Warehouse.Store; using (var scope = new TransactionScope()) { item.CreateAndFlush(); } return(PartialView("Receipts/_CreateSuccesful", new InventoryReceipt { Id = item.Id })); }
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")); }
public ViewResult Receipt(int id) { var item = InventoryReceipt.Find(id); return(View("Receipts/View", item)); }
public ActionResult GetTotalQuantityReceipt(int id) { return(PartialView("Receipts/_TotalQuantity", InventoryReceipt.Find(id))); }
public ActionResult DiscardReceiptChanges(int id) { return(PartialView("Receipts/_MasterView", InventoryReceipt.TryFind(id))); }
public ActionResult NewReceipt(InventoryReceipt item) { if (!ModelState.IsValid) return PartialView ("Receipts/_Create", item); item.CreationTime = DateTime.Now; item.ModificationTime = item.CreationTime; item.Creator = CurrentUser.Employee; item.Updater = item.Creator; item.Warehouse = Warehouse.Find (item.WarehouseId); item.Store = item.Warehouse.Store; using (var scope = new TransactionScope ()) { item.CreateAndFlush (); } return PartialView ("Receipts/_CreateSuccesful", new InventoryReceipt { Id = item.Id }); }
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); }
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"); }