public string GenerateDisbursementOfStockClerk(List <DisbursementController.Entry> entries) { if (entries == null || entries.Count == 0) { return("Failed"); } HashSet <long> deptIds = new HashSet <long>(); List <DisbursementList> disbursementLists = new List <DisbursementList>(); entries.ForEach(e => deptIds.Add(e.deptId)); foreach (var deptId in deptIds) { List <DisbursementListDetails> disbursementListDetails = new List <DisbursementListDetails>(); foreach (var entry in entries) { if (entry.deptId == deptId) { Inventory i = new Inventory() { ItemId = entry.itemId, }; DisbursementListDetails dDets = new DisbursementListDetails() { Item = i, Quantity = entry.quantity }; disbursementListDetails.Add(dDets); } } DisbursementList d = new DisbursementList() { Department = new Department() { DeptId = deptId, }, DisbursementListDetails = disbursementListDetails, date = DateTime.Now }; disbursementLists.Add(d); } DisbursementListService.CreateDisbursementLists(disbursementLists); return("Success"); }
public string UpdateDisbursementsOfClerk(DisburmentDTO dto) { foreach (var item in dto.Items) { Inventory i = new Inventory() { ItemId = item.itemId }; DisbursementListDetails disbursementDetails = new DisbursementListDetails() { Quantity = item.quantity, Item = i }; DisbursementListService.UpdateDisbursementListDetails(dto.ListId, disbursementDetails); } return("Success"); }
public Dictionary <string, object> GetAllRetrievalFormsOfStockClerk() { List <RetrievalForm> retrievalForms = retrievalForms = RetrievalFormService.ViewRetrievalForm(); bool isPending = (DisbursementListService.CheckForPendingDisbursements().Count != 0); for (int i = 0; i < retrievalForms.Count; i++) { Inventory inv = CatalogueService.GetCatalogueById(retrievalForms[i].itemId); retrievalForms[i].totalRetrieved = inv.StockLevel; } Dictionary <string, object> retrievalDict = new Dictionary <string, object> { { "retrievalForms", retrievalForms }, { "pending", isPending } }; return(retrievalDict); }
private void UpdateChargeBack(long listId) { /* Move the following code to RestRepresentativeController*/ ////Attention: DisbursementList can only disburse once, date for that list is not null ///*The following code is for ChargeBack table*/ ////By the time disburse item, calculate the amount of this list, update ChargeBack table DisbursementList disbursementList = DisbursementListService.GetDisbursementListByListId(listId); List <DisbursementListDetails> disbursementListDetails = DisbursementListDetailsDAO.ViewDetails(listId); foreach (DisbursementListDetails details in disbursementListDetails) { PriceList priceList = PriceListService.GetPriceListByItemId(details.Item.ItemId); double price = 0; if (priceList != null) { price = priceList.Supplier1UnitPrice; } double amount = price * details.Quantity; ChargeBackService.UpdateChargeBackData(amount, disbursementList); ///*The following code is for StockCard table*/ ////By the time disburse item, update StockCard table with itemId, deptId and date, souceType = 2 int balance = CatalogueService.GetCatalogueById(details.Item.ItemId).StockLevel - details.Quantity; StockCardService.CreateStockCardFromDisburse(details, disbursementList, balance); StockDAO.UpdateWithReduceInventoryStockById(details.Item.ItemId, details.Quantity); ////following code will update and close requisitions int disbursedAmount = details.Quantity; List <Requisition> requisitions = RequisitionDAO.GetOutstandingRequisitionsAndDetailsByDeptIdAndItemId(disbursementList.Department.DeptId, details.Item.ItemId, listId); //will get those status assigned/partially completed(assigned) foreach (var requisition in requisitions) { if (requisition.RequisitionDetail.Balance <= disbursedAmount) // if the balance is less than what was disbursed { RequisitionDetailsDAO.UpdateBalanceAmount(requisition.ReqId, details.Item.ItemId, 0); //change balance to 0 if (RequisitionDetailsDAO.GetRemainingRequisitionDetailsByReqId(requisition.ReqId).Count > 0) //will get those the remaining amounts !=0 if { RequisitionDAO.UpdateStatus(requisition.ReqId, "Partially Completed"); } else { RequisitionDAO.UpdateStatus(requisition.ReqId, "Completed"); } disbursedAmount -= requisition.RequisitionDetail.Balance; // minusing the balance from what was disbursed } else// when the balance amount is more than the remainder of the disbursed amount { RequisitionDetailsDAO.UpdateBalanceAmount(requisition.ReqId, details.Item.ItemId, disbursedAmount);// change balance to remainder of disbursed amount RequisitionDAO.UpdateStatus(requisition.ReqId, "Partially Completed"); break;//break out of for loop when disbursed amount become 0 } } } }