Esempio n. 1
0
        // Update
        // Store clerk presses submit on the stationery retrieval form screen
        public void submitRetrievalForm(int disDutyId, Dictionary <string, int> itemsAndQtys)
        {
            DisbursementDuty disbursementDuty = getDisbursementDutyById(disDutyId);

            // Allocate the retrieved items into respective Disbursements. Priority is on a first-come-first-serve basis.
            foreach (KeyValuePair <string, int> item in itemsAndQtys)
            {
                int qty = Math.Min(item.Value, stockManagementService.getStockCountOfItem(item.Key));
                stockManagementService.addStockTransaction(item.Key, "Retrieval", disbursementDuty.StoreClerkID, -qty);

                // Get all requisition details served by disbursement duty
                List <Disbursement>      disbursements      = disbursementDuty.Disbursements.ToList();
                List <RequisitionDetail> requisitionDetails = new List <RequisitionDetail>();
                disbursements.ForEach(d => requisitionDetails
                                      .AddRange(d.Requisition.RequisitionDetails.Where(rd => rd.ItemID == item.Key).ToList()));

                allocateRetrievalToDisbursementDetails(requisitionDetails, disbursementDuty, qty);
            }

            // update retrieval status of each requisition within disbursement duty to retrieved
            disbursementDuty.Disbursements.ToList().ForEach(d => d.Requisition.RetrievalStatusID = 4);
            disbursementDuty.isRetrieved = true;
            context.SaveChanges();
        }
        // Update
        public void updateQtyRecievedOfOrderSupplierDetail(int orderSupplierDetailId, int qty, string empId)
        {
            OrderSupplierDetail orderSupplierDetail = getOrderSupplierDetail(orderSupplierDetailId);

            orderSupplierDetail.ActualQuantityReceived = Math.Min(qty, orderSupplierDetail.Quantity); // excess rejected
            stockManagementService.addStockTransaction(orderSupplierDetail.ItemID, "restock", empId, qty);

            if (context.OrderSupplierDetails
                .Count(o => o.OrderSupplierID == orderSupplierDetail.OrderSupplierID && o.ActualQuantityReceived == null) == 0)
            {
                confirmDeliveryOfOrderSupplier(orderSupplierDetail.OrderSupplierID);
            }

            context.SaveChanges();
        }