示例#1
0
        public JsonResult ReguestMemo(MemoViewModel memoModel, string usercode)
        {
            try
            {
                memoModel.ImprestMemo.Ref    = GenerateRefNo();
                memoModel.ImprestMemo.Status = "Pending";
                var erpUser = _unitOfWork.Users.GetUsersByCode(usercode);
                memoModel.ImprestMemo.Personnel = erpUser?.UserCode ?? "";
                memoModel.ImprestMemoDetail.ForEach(d => {
                    d.Ref = memoModel.ImprestMemo.Ref;
                    _unitOfWork.ImprestMemoDetail.Add(d);
                });

                _unitOfWork.ImprestMemo.Add(memoModel.ImprestMemo);

                var procOnlineReq = new ProcOnlineReq
                {
                    ReqRef   = memoModel.ImprestMemo.Ref,
                    DocType  = "ONLINE MEMO",
                    Rdate    = DateTime.UtcNow,
                    Rtime    = DateTime.UtcNow,
                    Usercode = usercode,
                    Status   = "Pending"
                };

                var docId = _unitOfWork.Wfrouting.GetFirstOrDefault(r => r.Document.ToUpper() == procOnlineReq.DocType.ToUpper())?.Id.ToString();
                if (string.IsNullOrEmpty(docId))
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = false,
                        Message = "Sorry, " + procOnlineReq.DocType.ToUpper() + " Not supported at the moment. Please contact the admin"
                    }));
                }

                var user           = _unitOfWork.HrpEmployee.GetFirstOrDefault(e => e.EmpNo.ToUpper().Equals(usercode.ToUpper()));
                var workFlowStatus = utils.SaveToWorkFlowCenter(procOnlineReq, user, docId);
                if (!workFlowStatus.Success)
                {
                    return(Json(workFlowStatus));
                }

                _unitOfWork.Save();
                return(Json(new ReturnData <string>
                {
                    Success = true,
                    Message = "Memo saved successifully"
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ReturnData <string>
                {
                    Success = false,
                    Message = "An error occurred"
                }));
            }
        }
示例#2
0
        public JsonResult BookVehicle(FLBooking booking)
        {
            try
            {
                booking.Ref       = GenerateRefNo();
                booking.Status    = "Pending";
                booking.Personnel = booking.EmpNo;
                var procOnlineReq = new ProcOnlineReq
                {
                    ReqRef   = booking.Ref,
                    DocType  = "VEHICLE BOOKING",
                    Rdate    = DateTime.UtcNow.Date,
                    Rtime    = DateTime.UtcNow,
                    Usercode = booking.EmpNo,
                    Status   = "Pending"
                };

                var docId = _unitOfWork.Wfrouting.GetFirstOrDefault(r => r.Document.ToUpper() == procOnlineReq.DocType.ToUpper())?.Id.ToString();
                if (string.IsNullOrEmpty(docId))
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = false,
                        Message = "Sorry, " + procOnlineReq.DocType.ToUpper() + " Not supported at the moment. Please contact the admin"
                    }));
                }

                var user           = _unitOfWork.HrpEmployee.GetFirstOrDefault(e => e.EmpNo.ToUpper().Equals(booking.EmpNo.ToUpper()));
                var workFlowStatus = utils.SaveToWorkFlowCenter(procOnlineReq, user, docId);
                if (!workFlowStatus.Success)
                {
                    return(Json(workFlowStatus));
                }

                booking.DDate   = booking.DDate.GetValueOrDefault().Date;
                booking.RetDate = booking.RetDate.GetValueOrDefault().Date;
                booking.RDate   = booking.RDate.GetValueOrDefault().Date;
                _unitOfWork.FLBooking.Add(booking);
                _unitOfWork.Save();

                return(Json(new ReturnData <string>
                {
                    Success = true,
                    Message = "Applied Successfully"
                }));
            }
            catch (Exception e)
            {
                return(Json(new ReturnData <string>
                {
                    Success = false,
                    Message = "Opps, An error occured"
                }));
            }
        }
示例#3
0
        public JsonResult ApproveLeave(LeaveApproveVm approveVm)
        {
            try
            {
                var leave         = _context.HrpLeaveApp.FirstOrDefault(l => l.Ref.ToUpper().Equals(approveVm.LeaveRef.ToUpper()));
                var procOnlineReq = new ProcOnlineReq
                {
                    ReqRef   = leave.Ref,
                    DocType  = "LEAVE APPLICATION",
                    Rdate    = DateTime.UtcNow.Date,
                    Rtime    = DateTime.UtcNow.AddHours(3),
                    Usercode = leave.EmpNo,
                    Status   = "Pending"
                };
                var user           = _context.HrpEmployee.FirstOrDefault(u => u.EmpNo.ToUpper().Equals(leave.EmpNo.ToUpper()));
                var description    = $"Type of Leave: {leave.LeaveType}; Number of days requested: {leave.LeaveDays}; From: {String.Format("{0:d}", leave.Sdate)} To: {String.Format("{0:d}", leave.Edate)}";
                var docId          = _context.Wfrouting.FirstOrDefault(r => r.Document.ToUpper() == procOnlineReq.DocType.ToUpper())?.Id.ToString() ?? "";
                var workFlowStatus = utils.SaveToWorkFlowCenter(procOnlineReq, user, docId, description);
                if (!workFlowStatus.Success)
                {
                    return(Json(workFlowStatus));
                }

                return(Json(new ReturnData <string> {
                    Success = true,
                    Message = "Leave Approved successfully"
                }));
            }
            catch (Exception)
            {
                return(Json(new ReturnData <string>
                {
                    Success = false,
                    Message = "Sorry, An error occurred"
                }));
            }
        }
示例#4
0
        public ReturnData <string> SaveToWorkFlowCenter(ProcOnlineReq procOnlineReq, HrpEmployee userDetails, string docId, string notes = null)
        {
            var wkDocCenter = new WfdocCentre
            {
                Type        = procOnlineReq.DocType.ToUpper(),
                DocNo       = procOnlineReq.ReqRef,
                Description = string.IsNullOrEmpty(notes) ? "N/A" : notes,
                UserRef     = userDetails.EmpNo,
                Names       = userDetails.Names,
                Department  = userDetails.Department,
                Rdate       = DateTime.UtcNow,
                Rtime       = DateTime.UtcNow.ToLocalTime(),
                Personnel   = userDetails.EmpNo,
                FinalStatus = "Pending"
            };

            db.WfdocCentre.Add(wkDocCenter);
            db.SaveChanges();

            var documentCenterId = db.WfdocCentre.FirstOrDefault(d => d.DocNo == procOnlineReq.ReqRef)?.Id;

            var WFRoutingDetails = db.WfroutingDetails.Where(d => d.Ref == docId).ToList();

            var departmentHeadTitle = "HEAD OF DEPARTMENT";
            var supervisorTitle     = "SUPERVISOR";
            var deanTitle           = "Dean";

            foreach (var detail in WFRoutingDetails)
            {
                var approver       = db.Wfapprovers.FirstOrDefault(a => a.Title == detail.Approver);
                var approverId     = approver?.Id.ToString();
                var approversCodes = db.WfapproversDetails.Join(db.Users,
                                                                approverDetail => approverDetail.UserCode,
                                                                users => users.UserCode,
                                                                (approverDetail, users) => new
                {
                    approverDetail.Ref,
                    approverDetail.UserCode,
                    users.Department
                }).Where(u => u.Ref == approverId).Select(u => u.UserCode).Distinct().ToList();

                if (detail.Approver.ToLower().Contains(departmentHeadTitle.ToLower()))
                {
                    approversCodes = db.WfapproversDetails.Join(db.Users,
                                                                approverDetail => approverDetail.UserCode,
                                                                users => users.UserCode,
                                                                (approverDetail, users) => new
                    {
                        approverDetail.Ref,
                        approverDetail.UserCode,
                        users.Department
                    }).Where(u => u.Department == userDetails.Department && u.Ref == approverId).Select(u => u.UserCode).Distinct().ToList();
                }

                if (detail.Approver.ToLower().Contains(supervisorTitle.ToLower()))
                {
                    var employeeSupervisor = db.HrpEmployee.FirstOrDefault(e => e.EmpNo == userDetails.EmpNo)?.Supervisor;

                    approversCodes = db.Users.Where(u => u.EmpNo == employeeSupervisor).Select(u => u.UserCode).Distinct().ToList();
                }

                if (detail.Approver.ToLower().Contains(deanTitle.ToLower()))
                {
                    approversCodes = db.Schools.Join(db.Users,
                                                     schools => schools.DeanUserName,
                                                     users => users.UserCode,
                                                     (schools, users) => new
                    {
                        users.UserCode
                    }).Select(u => u.UserCode).Distinct().ToList();
                }

                foreach (var approverCode in approversCodes)
                {
                    var wkDocCenterDetails = new WfdocCentreDetails
                    {
                        Ref            = Convert.ToString(documentCenterId),
                        Approver       = detail.Approver,
                        Level          = detail.Level,
                        UserCode       = approverCode,
                        Action         = "Approval",
                        Reason         = null,
                        Rdate          = DateTime.UtcNow,
                        ActionSelected = null,
                        Station        = null
                    };

                    db.WfdocCentreDetails.Add(wkDocCenterDetails);
                }
            }

            db.SaveChanges();

            return(new ReturnData <string>
            {
                Success = true,
                Data = ""
            });
        }
示例#5
0
        public JsonResult SaveEmployeeImprest(ImprestReq imprestReq)
        {
            try
            {
                imprestReq.Rdate    = DateTime.Today;
                imprestReq.Usercode = imprestReq.EmpNo;
                var user = _context.HrpEmployee.FirstOrDefault(u => u.EmpNo == imprestReq.EmpNo);
                if (_studentServices.CheckIfGenesis().Data)
                {
                    var memo = _context.ImprestMemo.Any(m => m.Ref.ToUpper().Equals(imprestReq.MemoRef.ToUpper()) &&
                                                        m.Status.ToUpper().Equals("APPROVED"));
                    if (!memo)
                    {
                        return(Json(new ReturnData <string>
                        {
                            Success = false,
                            Message = "Sorry, Only approved memos can be used to request for an imprest. Kindly contact admin"
                        }));
                    }

                    var memoDetails = _context.ImprestMemoDetail.Any(d => d.EmpNo.ToUpper().Equals(imprestReq.EmpNo.ToUpper()) &&
                                                                     d.Ref.ToUpper().Equals(imprestReq.MemoRef.ToUpper()));

                    if (!memoDetails)
                    {
                        return(Json(new ReturnData <string>
                        {
                            Success = false,
                            Message = $"{user.Names} is not one of the participants on the Memo reference number entered."
                        }));
                    }
                }

                var message = "";
                if (imprestReq.Amount < 0)
                {
                    message = "Amount must be greater than 0";
                }

                if (Convert.ToDateTime(imprestReq.Edate).Date < DateTime.Now.Date)
                {
                    message = "Expected date should be greater than today";
                }

                var imprestNumber = getImprestNumber();

                var procOnlineReq = new ProcOnlineReq
                {
                    ReqRef   = imprestNumber,
                    DocType  = "IMPREST WARRANT",
                    Rdate    = DateTime.Today,
                    Rtime    = DateTime.UtcNow.AddHours(3),
                    Usercode = user.EmpNo,
                    Status   = "Pending",
                };

                //var wfRouting = _staffServices.GetWfRouting(procOnlineReq.DocType);
                //if (!wfRouting.Success)
                //	return Json(wfRouting);

                //if (string.IsNullOrEmpty(wfRouting.Data.Id.ToString()))
                //	return Json(wfRouting);

                //var workFlowStatus = utils.SaveToWorkFlowCenter(procOnlineReq, user, wfRouting.Data.Id.ToString());
                //if (!workFlowStatus.Success)
                //	return Json(workFlowStatus);

                _context.ImprestReq.Add(imprestReq);
                _context.SaveChanges();
                message = "Your imprest has been successfully saved";

                return(Json(new ReturnData <string>
                {
                    Success = true,
                    Message = message
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ReturnData <bool>
                {
                    Success = false,
                    Message = "Oops,seems like an error occurred while processing your request",
                    Error = new Error(ex)
                }));
            }
        }
示例#6
0
        public JsonResult ApplyLeave(HrpLeaveApp leave, bool leaveRelieverMandatory)
        {
            try
            {
                leave.LeavePeriod = _context.HrpLeavePeriod.OrderByDescending(p => p.EndDate).FirstOrDefault(p => p.StartDate.Year == DateTime.UtcNow.Year)?.Names ?? DateTime.UtcNow.Year.ToString();
                leave.Reliever    = leave.Reliever ?? "";
                var reliverDetails = leave.Reliever.Split("-(");
                if (reliverDetails.Count() > 1)
                {
                    leave.Reliever = reliverDetails[1] ?? "";
                }
                leave.Reliever = leave.Reliever.Replace(")", "");
                if (leave.LeaveType.ToLower().Equals("maternity leave"))
                {
                    if (!CanApplyMaternityLeave(leave.EmpNo, leave.LeaveType))
                    {
                        return(Json(new ReturnData <HrpLeaveApp>
                        {
                            Success = false,
                            Message = "Application failed. Only Female can apply for this leave",
                            Data = leave
                        }));
                    }
                }

                var leaveExists = _context.HrpLeaveApp.Any(l => l.Status.Equals("Pending") &&
                                                           l.LeaveType.Equals(leave.LeaveType) && l.EmpNo.Equals(leave.EmpNo));
                if (leaveExists)
                {
                    return(Json(new ReturnData <HrpLeaveApp>
                    {
                        Success = false,
                        Message = $"You have a Pending {leave.LeaveType} Application",
                        Data = leave
                    }));
                }

                leave.Ref = GenerateAppNo();
                //var leaveDaysDetails = _staffServices.GetEmpLeaveDays(leave.EmpNo);
                //if (!leaveDaysDetails.Success)
                //	return Json(leaveDaysDetails);

                //var days = leaveDaysDetails.Data.Where(l => l.LeaveType.CaseInsensitiveContains(leave.LeaveType)).Sum(x => x.LeaveDays) ?? 0;
                var days          = _staffServices.GetUserLeavesEntitled(leave.EmpNo, leave.LeaveType);
                var procOnlineReq = new ProcOnlineReq
                {
                    ReqRef   = leave.Ref,
                    DocType  = "LEAVE APPLICATION",
                    Rdate    = DateTime.UtcNow.Date,
                    Rtime    = DateTime.UtcNow.AddHours(3),
                    Usercode = leave.EmpNo,
                    Status   = "Pending"
                };

                var docId = _context.Wfrouting.FirstOrDefault(r => r.Document.ToUpper() == procOnlineReq.DocType.ToUpper())?.Id.ToString();
                if (string.IsNullOrEmpty(docId))
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = false,
                        Message = "Sorry, " + procOnlineReq.DocType.ToUpper() + " Not supported at the moment. Please contact the admin"
                    }));
                }

                if (days < 1)
                {
                    return(Json(new ReturnData <HrpLeaveApp>
                    {
                        Success = false,
                        Message = string.Format("Application failed. Your have {0} days for this leave", days),
                        Data = leave
                    }));
                }

                if (!leaveRelieverMandatory)
                {
                    var user           = _context.HrpEmployee.FirstOrDefault(u => u.EmpNo == leave.EmpNo);
                    var description    = $"Type of Leave: {leave.LeaveType}; Number of days requested: {leave.LeaveDays}; From: {String.Format("{0:d}", leave.Sdate)} To: {String.Format("{0:d}", leave.Edate)}";
                    var workFlowStatus = utils.SaveToWorkFlowCenter(procOnlineReq, user, docId, description);
                    if (!workFlowStatus.Success)
                    {
                        return(Json(workFlowStatus));
                    }
                }

                _context.HrpLeaveApp.Add(leave);
                _context.SaveChanges();
                return(Json(new ReturnData <HrpLeaveApp>
                {
                    Success = true,
                    Message = "Your leave application was submited succesfully",
                    Data = leave
                }));
            }
            catch (Exception e)
            {
                return(Json(new ReturnData <string>
                {
                    Success = false,
                    Message = "There was a problem while trying to apply leave.",
                    Error = new Error(e)
                }));
            }
        }
示例#7
0
        public ReturnData <string> AddEClaim(EclaimUnits eclaimUnits, string userCode, string description)
        {
            description = description ?? "";
            try
            {
                var claimRef = GenerateRefNo();
                eclaimUnits.Ecref = claimRef;
                var procOnlineReq = new ProcOnlineReq
                {
                    ReqRef   = claimRef,
                    DocType  = "IMPREST WARRANT",
                    Rdate    = DateTime.UtcNow,
                    Rtime    = DateTime.UtcNow,
                    Usercode = userCode,
                    Status   = "Pending"
                };

                var docId = _unitOfWork.Wfrouting.GetFirstOrDefault(r => r.Document.ToUpper() == procOnlineReq.DocType.ToUpper())?.Id.ToString();
                if (string.IsNullOrEmpty(docId))
                {
                    return new ReturnData <string>
                           {
                               Success = false,
                               Message = "Sorry, " + procOnlineReq.DocType.ToUpper() + " Not supported at the moment. Please contact the admin"
                           }
                }
                ;

                var user           = _unitOfWork.HrpEmployee.GetFirstOrDefault(e => e.EmpNo.ToUpper().Equals(userCode.ToUpper()));
                var workFlowStatus = utils.SaveToWorkFlowCenter(procOnlineReq, user, docId);
                if (!workFlowStatus.Success)
                {
                    return(workFlowStatus);
                }

                _unitOfWork.EclaimUnits.Add(eclaimUnits);
                _unitOfWork.Eclaim.Add(new Eclaim
                {
                    Ecref       = claimRef,
                    PayeeRef    = userCode,
                    Description = description.ToUpper(),
                    Status      = "Pending",
                    Rdate       = DateTime.UtcNow,
                    Personnel   = userCode,
                    Amount      = eclaimUnits.Amount,
                    Names       = $"{user.Title} {user.Names}"
                });

                _unitOfWork.Save();
                return(new ReturnData <string>
                {
                    Success = true,
                    Message = "Expense claim added successfully"
                });
            }
            catch (Exception e)
            {
                return(new ReturnData <string>
                {
                    Success = false,
                    Message = "Sorry, An error occurred"
                });
            }
        }
示例#8
0
        public JsonResult CreateAnSor(CreateSorModel sor)
        {
            try
            {
                var sorNo = GenerateRefNo();
                var user  = _context.HrpEmployee.FirstOrDefault(u => u.EmpNo == sor.Details.Usercode);

                var procOnlineReq = new ProcOnlineReq
                {
                    ReqRef   = sorNo,
                    DocType  = "SPECIFICATION OF REQUIREMENT",
                    Rdate    = DateTime.UtcNow.Date,
                    Rtime    = DateTime.UtcNow.AddHours(3),
                    Usercode = sor.Details.Usercode,
                    Reaction = "",
                    Status   = "Pending",
                    Notes    = sor.Details.Notes
                };

                var wfRouting = _staffServices.GetWfRouting(procOnlineReq.DocType);
                if (!wfRouting.Success)
                {
                    return(Json(wfRouting));
                }

                if (string.IsNullOrEmpty(wfRouting.Data.Id.ToString()))
                {
                    return(Json(wfRouting));
                }

                var workFlowStatus = utils.SaveToWorkFlowCenter(procOnlineReq, user, wfRouting.Data.Id.ToString());
                if (!workFlowStatus.Success)
                {
                    return(Json(workFlowStatus));
                }

                _context.ProcOnlineReq.Add(procOnlineReq);

                foreach (var soritem in sor.Items)
                {
                    _context.ProcOnlineReqDetail.Add(new ProcOnlineReqDetail {
                        Amount      = soritem.Totalamount,
                        Cost        = soritem.Unitamount,
                        Qty         = soritem.Quantity,
                        ReqRef      = procOnlineReq.ReqRef,
                        UoM         = soritem.Unitmeasure,
                        Description = soritem.Description
                    });
                }

                _context.SaveChanges();

                return(Json(new ReturnData <CreateSorModel>
                {
                    Success = true,
                    Message = "SOR submited successfully"
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ReturnData <CreateSorModel>
                {
                    Success = false,
                    Message = "Sorry. Something went wrong.Please try again",
                    Error = new Error(ex)
                }));
            }
        }
示例#9
0
        public JsonResult Apply(StudClearance clearance, Role role)
        {
            try
            {
                if (role == Role.Student)
                {
                    var cleared = _context.StudClearances.FirstOrDefault(c => c.AdmnNo.ToUpper().Equals(clearance.AdmnNo.ToUpper()));
                    if (cleared != null)
                    {
                        var message = cleared.Status.ToLower().Equals("approved") ? "You have already cleared" : $"Your clearance is {cleared.Status.ToLower()}";
                        return(Json(new ReturnData <string>
                        {
                            Success = false,
                            Message = message
                        }));
                    }
                }
                if (role == Role.Staff)
                {
                    var cleared = _context.HrpStaffClearance.FirstOrDefault(c => c.EmpNo.ToUpper().Equals(clearance.AdmnNo.ToUpper()));
                    if (cleared != null)
                    {
                        var message = cleared.Status.ToLower().Equals("approved") ? "You have already cleared" : $"Your clearance is {cleared.Status.ToLower()}";
                        return(Json(new ReturnData <string>
                        {
                            Success = false,
                            Message = message
                        }));
                    }
                }

                var docType       = role == Role.Student ? "STUDENT CLEARANCE" : "STAFF CLEARANCE";
                var procOnlineReq = new ProcOnlineReq
                {
                    ReqRef   = clearance.AdmnNo,
                    DocType  = docType.ToUpper(),
                    Rdate    = DateTime.Today,
                    Rtime    = DateTime.UtcNow,
                    Usercode = clearance.AdmnNo,
                    Status   = "Pending"
                };

                var docId = _context.Wfrouting
                            .FirstOrDefault(r => r.Document.ToUpper() == procOnlineReq.DocType.ToUpper())
                            ?.Id.ToString();

                if (string.IsNullOrEmpty(docId))
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = false,
                        Message = "Sorry, " + procOnlineReq.DocType.ToUpper() + " " +
                                  "Not supported at the moment. Please contact the admin"
                    }));
                }

                var user = new HrpEmployee();
                if (role == Role.Staff)
                {
                    user = _context.HrpEmployee.FirstOrDefault(u => u.EmpNo.ToUpper().Equals(clearance.AdmnNo.ToUpper()));
                }
                else
                {
                    user = _context.Register.Join(_context.Programme, r => r.Programme, p => p.Names,
                                                  (r, p) => new HrpEmployee
                    {
                        EmpNo      = r.AdmnNo,
                        Names      = r.Names,
                        Department = p.Department
                    }).FirstOrDefault(r => r.EmpNo.Equals(clearance.AdmnNo));
                }

                var workFlowStatus = _utils.SaveToWorkFlowCenter(procOnlineReq, user, docId, clearance.Notes);
                if (!workFlowStatus.Success)
                {
                    return(Json(workFlowStatus));
                }

                if (role == Role.Student)
                {
                    _context.StudClearances.Add(clearance);
                }
                if (role == Role.Staff)
                {
                    _context.HrpStaffClearance.Add(new HrpStaffClearance {
                        EmpNo     = clearance.AdmnNo,
                        Status    = clearance.Status,
                        Personnel = clearance.Personnel,
                        Notes     = clearance.Notes
                    });
                }

                _context.SaveChanges();

                var msg = $"Your clearance application {clearance.AdmnNo} submited succesfully.";
                return(Json(new ReturnData <string>
                {
                    Success = true,
                    Message = msg,
                    Data = clearance.AdmnNo
                }));
            }
            catch (Exception e)
            {
                return(Json(new ReturnData <string>
                {
                    Success = false,
                    Message = "There was a problem while trying to apply for clearance.",
                    Error = new Error(e)
                }));
            }
        }
示例#10
0
        public JsonResult CreateIR(CreateSorModel createIR, string usercode)
        {
            try
            {
                var RefNo = GenerateRefNo("IRQ");
                var user  = _context.HrpEmployee.FirstOrDefault(u => u.EmpNo == usercode);

                var procOnlineReq = new ProcOnlineReq
                {
                    ReqRef   = RefNo,
                    DocType  = "Internal Requisition",
                    Usercode = usercode,
                    Reaction = "",
                    Notes    = createIR.Details.Notes,
                    Rdate    = DateTime.UtcNow.Date,
                    Rtime    = DateTime.UtcNow.AddHours(3),
                    Status   = "Pending"
                };

                var wfRouting = _staffServices.GetWfRouting(procOnlineReq.DocType);
                if (!wfRouting.Success)
                {
                    procOnlineReq.DocType = "STORES REQUISITION";
                    wfRouting             = _staffServices.GetWfRouting(procOnlineReq.DocType);
                    if (!wfRouting.Success)
                    {
                        return(Json(wfRouting));
                    }
                }

                if (string.IsNullOrEmpty(wfRouting.Data.Id.ToString()))
                {
                    return(Json(wfRouting));
                }

                var workFlowStatus = utils.SaveToWorkFlowCenter(procOnlineReq, user, wfRouting.Data.Id.ToString());
                if (!workFlowStatus.Success)
                {
                    return(Json(workFlowStatus));
                }

                _context.ProcOnlineReq.Add(procOnlineReq);

                foreach (var irItem in createIR.Items)
                {
                    _context.ProcOnlineReqDetail.Add(new ProcOnlineReqDetail
                    {
                        Amount      = irItem.Totalamount,
                        Cost        = irItem.Unitamount,
                        Qty         = irItem.Quantity,
                        ReqRef      = procOnlineReq.ReqRef,
                        UoM         = irItem.Unitmeasure,
                        Description = irItem.Description
                    });
                }

                _context.SaveChanges();

                return(Json(new ReturnData <ProcOnlineReq>
                {
                    Success = true,
                    Message = "Internal Requisition submited successfully"
                }));
            }
            catch (Exception e)
            {
                return(Json(new ReturnData <ProcOnlineReq>
                {
                    Success = false,
                    Message = "Sorry. Something went wrong.Please try again"
                }));
            }
        }