/** * This method checks business rules related to Budget Personnel Budget functionality * * @param budgetDocument * @return */ protected boolean processBudgetPersonnelBudgetBusinessRules(BudgetDocument budgetDocument) { boolean valid = true; MessageMap errorMap = GlobalVariables.getMessageMap(); List<BudgetPeriod> budgetPeriods = budgetDocument.getBudget().getBudgetPeriods(); int i = 0; int j = 0; int k = 0; for (BudgetPeriod budgetPeriod : budgetPeriods) { j = 0; List<BudgetLineItem> budgetLineItems = budgetPeriod.getBudgetLineItems(); k = 0; for (BudgetLineItem budgetLineItem : budgetLineItems) { for (BudgetPersonnelDetails budgetPersonnelDetails : budgetLineItem.getBudgetPersonnelDetailsList()) { if (budgetPersonnelDetails != null && budgetPersonnelDetails.getStartDate() != null && budgetPersonnelDetails.getStartDate().before(budgetLineItem.getStartDate())) { errorMap.putError( "budgetPeriod[" + i + "].budgetLineItems[" + j + "].budgetPersonnelDetailsList[" + k + "].startDate", KeyConstants.ERROR_PERSONNELBUDGETLINEITEM_STARTDATE_BEFORE_LINEITEM_STARTDATE); valid = false; } if (budgetPersonnelDetails != null && budgetPersonnelDetails.getEndDate() != null && budgetPersonnelDetails.getEndDate().after(budgetLineItem.getEndDate())) { errorMap.putError( "budgetPeriod[" + i + "].budgetLineItems[" + j + "].budgetPersonnelDetailsList[" + k + "].endDate", KeyConstants.ERROR_PERSONNELBUDGETLINEITEM_ENDDATE_AFTER_LINEITEM_ENDDATE); valid = false; } if (budgetPersonnelDetails.getPercentEffort().isGreaterThan(new ScaleTwoDecimal(100))) { errorMap.putError( "budgetPeriod[" + i + "].budgetLineItems[" + j + "].budgetPersonnelDetailsList[" + k + "].percentEffort", KeyConstants.ERROR_PERCENTAGE, Constants.PERCENT_EFFORT_FIELD); } if (budgetPersonnelDetails.getPercentCharged().isGreaterThan(new ScaleTwoDecimal(100))) { errorMap.putError( "budgetPeriod[" + i + "].budgetLineItems[" + j + "].budgetPersonnelDetailsList[" + k + "].percentCharged", KeyConstants.ERROR_PERCENTAGE, Constants.PERCENT_CHARGED_FIELD); } if (budgetPersonnelDetails .getPercentCharged() .isGreaterThan(budgetPersonnelDetails.getPercentEffort())) { errorMap.putError( "budgetPeriod[" + i + "].budgetLineItems[" + j + "].budgetPersonnelDetailsList[" + k + "].percentCharged", KeyConstants.ERROR_PERCENT_EFFORT_LESS_THAN_PERCENT_CHARGED); } k++; } j++; } i++; } return valid; }
@Deprecated private boolean personnelDatesCheck( BudgetLineItem budgetLineItem, BudgetPersonnelDetails budgetPersonnelDetails, String errorPath) { boolean errorFound = false; if (budgetPersonnelDetails.getStartDate() == null) { GlobalVariables.getMessageMap() .putError( "startDate", RiceKeyConstants.ERROR_REQUIRED, new String[] {"Start Date (Start Date)"}); errorFound = true; } if (budgetPersonnelDetails.getEndDate() == null) { GlobalVariables.getMessageMap() .putError( "endDate", RiceKeyConstants.ERROR_REQUIRED, new String[] {"End Date (End Date)"}); errorFound = true; } if (!errorFound) { if (budgetPersonnelDetails.getEndDate().compareTo(budgetPersonnelDetails.getStartDate()) < 0) { GlobalVariables.getMessageMap() .putError("endDate", KeyConstants.ERROR_PERSONNEL_DETAIL_DATES); errorFound = true; } if (budgetLineItem.getEndDate().compareTo(budgetPersonnelDetails.getEndDate()) < 0) { GlobalVariables.getMessageMap() .putError( "endDate", KeyConstants.ERROR_PERSONNEL_DETAIL_END_DATE, new String[] {"can not be after", "end date"}); errorFound = true; } if (budgetLineItem.getStartDate().compareTo(budgetPersonnelDetails.getEndDate()) > 0) { GlobalVariables.getMessageMap() .putError( "endDate", KeyConstants.ERROR_PERSONNEL_DETAIL_END_DATE, new String[] {"can not be before", "start date"}); errorFound = true; } if (budgetLineItem.getStartDate().compareTo(budgetPersonnelDetails.getStartDate()) > 0) { GlobalVariables.getMessageMap() .putError( "startDate", KeyConstants.ERROR_PERSONNEL_DETAIL_START_DATE, new String[] {"can not be before", "start date"}); errorFound = true; } if (budgetLineItem.getEndDate().compareTo(budgetPersonnelDetails.getStartDate()) < 0) { GlobalVariables.getMessageMap() .putError( "startDate", KeyConstants.ERROR_PERSONNEL_DETAIL_START_DATE, new String[] {"can not be after", "end date"}); errorFound = true; } } return errorFound; }