private int GetAvailableStockForWaitlistApprovedItems(int stationeryId) { int reqInTransitCount = requisitionDetailRepo.GetRequisitionCountForUnfulfilledStationery(stationeryId); int openAdjustmentCount = adjustmentVoucherRepo.GetOpenAdjustmentVoucherCountForStationery(stationeryId); int totalCount = stationeryRepo.FindById(stationeryId).Quantity; return(totalCount + openAdjustmentCount - reqInTransitCount); }
private int getReservedBalanceForExistingCartItem(CartDetail cd) { //Q - requisition reserved - adjustment open - total in front of queue int reservedCount = requisitionDetailRepo.GetReservedCountForStationery(cd.StationeryId); int foqCartCount = cartDetailRepo.GetFrontOfQueueCartCountForStationery(cd.StationeryId, cd.DateTime); int openAdjustmentCount = adjustmentVoucherRepo.GetOpenAdjustmentVoucherCountForStationery(cd.StationeryId); int totalCount = stationeryRepo.FindById(cd.StationeryId).Quantity; int netCount = totalCount - reservedCount - foqCartCount + openAdjustmentCount; if (netCount <= 0) { return(0); } else if (netCount >= cd.Quantity) { return(cd.Quantity); } else { return(netCount); } }