public IHttpActionResult CreateDisbursementDetails(DisbursementDetailsModel dism) { string error = ""; DisbursementDetailsModel disbm = DisbursementDetailsRepo.CreateDisbursementDetails(dism, out error); // get the inventory using the item id from Requisition details InventoryModel invm = InventoryRepo.GetInventoryByItemid(dism.Itemid, out error); // subtract the stock accoring to qty invm.Stock -= dism.Qty; // update the inventory invm = InventoryRepo.UpdateInventory(invm, out error); InventoryTransactionModel invtm = new InventoryTransactionModel { InvID = invm.Invid, ItemID = invm.Itemid, Qty = dism.Qty * -1, TransType = ConInventoryTransaction.TransType.DISBURSEMENT, TransDate = DateTime.Now, Remark = dism.Disid.ToString() }; invtm = InventoryTransactionRepo.CreateInventoryTransaction(invtm, out error); if (error != "" || disbm == null) { return(Content(HttpStatusCode.BadRequest, error)); } return(Ok(disbm)); }
public IHttpActionResult CreateInventoryTransaction(InventoryTransactionModel invt) { string error = ""; InventoryTransactionModel invtm = InventoryTransactionRepo.CreateInventoryTransaction(invt, out error); if (error != "" || invtm == null) { return(Content(HttpStatusCode.BadRequest, error)); } return(Ok(invtm)); }
public IHttpActionResult UpdatePOStatusComplete(PurchaseOrderModel po) { string error = ""; po = PurchaseOrderRepo.GetPurchaseOrderByID(po.PoId, out error); // if the staff has already updated the status to "received" if (po.Status == ConPurchaseOrder.Status.RECEIVED) { return(Ok(po)); } po.Status = ConPurchaseOrder.Status.RECEIVED; List <PurchaseOrderDetailModel> podms = PurchaseOrderDetailRepo.GetPurchaseOrderDetailByID(po.PoId, out error); // if the purchase order is completed, the stock must be updated according to deliver qty. foreach (PurchaseOrderDetailModel podm in podms) { // get the inventory using the item id from purchaseorder detail model InventoryModel invm = InventoryRepo.GetInventoryByItemid(podm.Itemid, out error); // adding the stock accoring to deliver qty invm.Stock += podm.DelivQty; // update the inventory invm = InventoryRepo.UpdateInventory(invm, out error); InventoryTransactionModel invtm = new InventoryTransactionModel(); invtm.InvID = invm.Invid; invtm.ItemID = invm.Itemid; invtm.Qty = podm.DelivQty; invtm.TransType = ConInventoryTransaction.TransType.PURCHASEORDER_RECEIEVED; invtm.TransDate = DateTime.Now; invtm.Remark = podm.PoId.ToString(); invtm = InventoryTransactionRepo.CreateInventoryTransaction(invtm, out error); } // updating the status PurchaseOrderModel pom = PurchaseOrderRepo.UpdatePurchaseOrder(po, out error); if (error != "" || pom == null) { if (error == ConError.Status.NOTFOUND) { return(Content(HttpStatusCode.NotFound, "PO Not Found")); } return(Content(HttpStatusCode.BadRequest, error)); } return(Ok(pom)); }