private void CascadeToRequisitionDetails(string action, int requisitionId)
 {
     //get all requisitiondetails belonging to this requisition
     if (action.Equals("cancel"))
     {
         List <RequisitionDetail> rds = (List <RequisitionDetail>)requisitionDetailRepo.FindBy(x => x.RequisitionId == requisitionId);
         foreach (RequisitionDetail rd in rds)
         {
             RequisitionDetail reqDet = requisitionDetailRepo.FindById(rd.Id);
             reqDet.Status = RequisitionDetailStatusEnum.CANCELLED.ToString();
             requisitionDetailRepo.Update(reqDet);
         }
     }
 }
示例#2
0
        public void CompleteDisbursementProcess(Models.MobileDTOs.DisbursementDTO disbursement)
        {
            List <Models.MobileDTOs.RequisitionDetailDTO> requisitionDetails = disbursement.RequisitionDetails;
            List <RequisitionDetail> unfulfilledRds = new List <RequisitionDetail>();

            foreach (Models.MobileDTOs.RequisitionDetailDTO rd in requisitionDetails)
            {
                if (rd.QuantityOrdered != rd.QuantityDelivered)
                {
                    int qtyDifference = (int)rd.QuantityDelivered - rd.QuantityOrdered;
                    AdjustmentVoucher targetAdjustmentVoucher = retrievalService.retrieveNewOrAvailableAdjustmentVoucherForClerk(disbursement.DeliveredEmployeeId);
                    retrievalService.createNewAdjustmentVoucherDetail(targetAdjustmentVoucher, rd.StationeryId, qtyDifference);
                    if (rd.QuantityDelivered > 0)
                    {
                        RequisitionDetail rd1 = requisitionDetailRepo.FindById(rd.Id);
                        rd1.QuantityDelivered = rd.QuantityDelivered;
                        rd1.Status            = RequisitionDetailStatusEnum.COLLECTED.ToString();
                        requisitionDetailRepo.Update(rd1);
                        int diff = rd.QuantityOrdered - (int)rd.QuantityDelivered;
                        int availStockForUnfulfilled = requisitionCatalogueService.GetAvailStockForUnfulfilledRd(rd.StationeryId, rd.Id);
                        if (availStockForUnfulfilled < diff) //insufficient stock
                        {
                            int waitlistCount = diff - availStockForUnfulfilled;
                            requisitionCatalogueService.createNewRequisitionDetail(waitlistCount, rd.RequisitionId, rd.StationeryId, RequisitionDetailStatusEnum.WAITLIST_APPROVED);

                            if (availStockForUnfulfilled > 0)
                            {
                                requisitionCatalogueService.createNewRequisitionDetail(availStockForUnfulfilled, rd.RequisitionId, rd.StationeryId, RequisitionDetailStatusEnum.PREPARING);
                            }
                        }
                        else
                        {
                            requisitionCatalogueService.createNewRequisitionDetail(diff, rd.RequisitionId, rd.StationeryId, RequisitionDetailStatusEnum.PREPARING);
                        }
                    }
                }
                else
                {
                    RequisitionDetail rd1 = requisitionDetailRepo.FindById(rd.Id);
                    rd1.QuantityDelivered = rd.QuantityDelivered;
                    rd1.Status            = RequisitionDetailStatusEnum.COLLECTED.ToString();
                    requisitionDetailRepo.Update(rd1);
                }
            }
            requisitionCatalogueService.CheckRequisitionCompletenessAfterDisbursement(disbursement.Id, disbursement);
        }
        private void CascadeToRequisitionDetails(string action, int requisitionId)
        {
            List <RequisitionDetail> rds = (List <RequisitionDetail>)requisitionDetailRepo.FindBy(x => x.RequisitionId == requisitionId);

            if (action.Equals("approve"))
            {
                foreach (RequisitionDetail rd in rds)
                {
                    int rdId = rd.Id;
                    RequisitionDetail reqDet = requisitionDetailRepo.FindById(rdId);
                    if (rd.Status.Equals(RequisitionDetailStatusEnum.RESERVED_PENDING.ToString()))
                    {
                        //change from reserved pending to preparing
                        //rd.Status = RequisitionDetailStatusEnum.PREPARING.ToString();

                        reqDet.Status = RequisitionDetailStatusEnum.PREPARING.ToString();
                        requisitionDetailRepo.Update(reqDet);
                    }
                    else if (rd.Status.Equals(RequisitionDetailStatusEnum.WAITLIST_PENDING.ToString()))
                    {
                        //any stock at present for them?
                        //int availStock = GetAvailableStockForWaitlistApprovedItems(rd.StationeryId);

                        //change waitlist pending to waitlist approved
                        reqDet.Status = RequisitionDetailStatusEnum.WAITLIST_APPROVED.ToString();
                        requisitionDetailRepo.Update(reqDet);

                        NotifyClerkAboutAnyShortFallInWaitlistApprovedStationery(rd.StationeryId, (int)rd.Requisition.Employee.Department.CollectionPoint.EmployeeId);
                    }
                    else
                    {
                        //throw new Exception("This RD shouldnt belong to a pending Requsition!");
                    }
                }
            }
            else
            {
                //rejected
                foreach (RequisitionDetail rd in rds)
                {
                    rd.Status = RequisitionDetailStatusEnum.REJECTED.ToString();
                    requisitionDetailRepo.Update(rd);
                }
            }
        }
 public void createNewDisbursementsFromUpdatedRequisitionDetails(List <RequisitionDetail> reqDetailList, int deliveredEmployeeId)
 {
     foreach (RequisitionDetail entry in reqDetailList)
     {
         Requisition       affectedReq        = (Requisition)requisitionRepo.FindOneBy(x => x.Id == entry.RequisitionId);
         int               targetDeptId       = (int)employeeRepo.FindOneBy(x => x.Id == affectedReq.EmployeeId).DepartmentId;
         int               receivedEmployeeId = (int)employeeRepo.FindOneBy(x => x.DepartmentId == targetDeptId && x.RoleId == (int)Enums.Roles.DepartmentRepresentative).Id;
         RequisitionDetail target             = (RequisitionDetail)requisitionDetailRepo.FindBy(x => x.Id == entry.Id).FirstOrDefault();
         int               targetDisId        = retrieveNewOrAvailableDisbursementIdForDept(deliveredEmployeeId, receivedEmployeeId);
         target.DisbursementId = targetDisId;
         requisitionDetailRepo.Update(target);
     }
 }