public static Boolean routeForApproval(TNF tnf) { User currentUser = null; Workflow currentWorkflow = wfDAO.getCurrentActiveWorkflow(); List <User> users = new List <User>(); string tnfType = ""; Boolean gotBudget = false; //getting the type if it's individual or group if (tnf.getType().Equals("Individual")) { currentUser = tnf.getUser(); tnfType = "Individual"; } else { users = tnf.getUsers(); tnfType = "Group"; } // check if not group then check individual duration, else check each individual in the group int probationPeriod = currentWorkflow.getProbationPeriod(); if (!users.Any()) { if (currentUser.getLengthOfSevice() < probationPeriod) { // to do logic for > probationPeriod } } else { foreach (User user in users) { // check duration for each user // to do logic if user’s duration is < probationPeriod } } //To check budget, variable checking is gotBudget if (gotBudget) { if (tnfType.Equals("Individual")) { return(routeIndividual(tnf)); } else { return(routeGroup(tnf)); } } else { //updateTNFStatus("Rejected.Department no budget"); //to use tnfDAO to update status return(false); } }
public static Boolean routeForApproval(TNF tnf) { User currentUser = null; Workflow currentWorkflow = wfDAO.getCurrentActiveWorkflow(tnf.getType()); List <User> users = new List <User>(); string tnfType = ""; Boolean gotBudget = false; //getting the type if it's individual or group if (tnf.getType().Equals("individual")) { currentUser = tnf.getUser(); tnfType = "Individual"; } else { users = tnf.getUsers(); tnfType = "Group"; } //To check budget if (tnfType.Equals("Individual")) { Department currentDept = deptDAO.getDeptByName(tnf.getUser().getDepartment()); Course currentCourse = tnfDAO.getCourseFromTNF(tnf.getTNFID()); double courseCost = currentCourse.getPrice(); gotBudget = deptDAO.checkDeptBudget(currentDept.getDeptName(), currentCourse.getPrice()); } else { //check budget for each member of group } if (gotBudget) { if (tnfType.Equals("Individual")) { return(routeIndividual(tnf)); } else { return(routeGroup(tnf)); } } else { tnfDAO.updateTNFStatus(tnf.getTNFID(), "Rejected. Department no budget."); return(false); } }