コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }
コード例 #4
0
        public IHttpActionResult GetInventoryTransactionByItemID(int itemid)
        {
            string error = "";
            List <InventoryTransactionModel> invtms = InventoryTransactionRepo.GetInventoryTransactionsByItemID(itemid, out error);

            if (error != "" || invtms == null)
            {
                if (error == ConError.Status.NOTFOUND)
                {
                    return(Content(HttpStatusCode.NotFound, "InventoryTransaction Not Found"));
                }
                return(Content(HttpStatusCode.BadRequest, error));
            }
            return(Ok(invtms));
        }
コード例 #5
0
        public IHttpActionResult UpdateInventoryTransaction(InventoryTransactionModel invt)
        {
            string error = "";
            InventoryTransactionModel invtm = InventoryTransactionRepo.UpdateInventoryTransaction(invt, out error);

            if (error != "" || invtm == null)
            {
                if (error == ConError.Status.NOTFOUND)
                {
                    return(Content(HttpStatusCode.NotFound, "InventoryTransaction Not Found"));
                }
                return(Content(HttpStatusCode.BadRequest, error));
            }
            return(Ok(invtm));
        }
コード例 #6
0
        public IHttpActionResult GetInventoryTransactionByTransDate(DateTime startdate, DateTime enddate)
        {
            string error = "";
            List <InventoryTransactionModel> invtms = InventoryTransactionRepo.GetInventoryTransactionsByTransDateRange(startdate, enddate.AddDays(1), out error);

            if (error != "" || invtms == null)
            {
                if (error == ConError.Status.NOTFOUND)
                {
                    return(Content(HttpStatusCode.NotFound, "InventoryTransaction Not Found"));
                }
                return(Content(HttpStatusCode.BadRequest, error));
            }
            return(Ok(invtms));
        }
コード例 #7
0
        public IHttpActionResult GetAllInventoryTransactions()
        {
            // declare and initialize error variable to accept the error from Repo
            string error = "";

            // get the list from inventorytransactionrepo and will insert the error if there is one
            List <InventoryTransactionModel> invtms = InventoryTransactionRepo.GetAllInventoryTransactions(out error);

            // if the erorr is not blank or the inventorytransaction list is null
            if (error != "" || invtms == null)
            {
                // if the error is 404
                if (error == ConError.Status.NOTFOUND)
                {
                    return(Content(HttpStatusCode.NotFound, "InventoryTransactions Not Found"));
                }
                // if the error is other one
                return(Content(HttpStatusCode.BadRequest, error));
            }
            // if there is no error
            return(Ok(invtms));
        }