private boolean isSelectedFeePeriodic(FeeView selectedFee, List<FeeView> additionalFeeList) { for (FeeView fee : additionalFeeList) { if (fee.getFeeId().equals(selectedFee.getFeeId())) { return fee.isPeriodic(); } } return false; }
protected void validateForFeeRecurrence(HttpServletRequest request, ActionErrors errors) throws ApplicationException { MeetingBO meeting = getCustomerMeeting(request); if (meeting != null) { List<FeeView> feeList = getDefaultFees(); for (FeeView fee : feeList) { if (!fee.isRemoved() && fee.isPeriodic() && !isFrequencyMatches(fee, meeting)) { errors.add( CustomerConstants.ERRORS_FEE_FREQUENCY_MISMATCH, new ActionMessage(CustomerConstants.ERRORS_FEE_FREQUENCY_MISMATCH)); return; } } List<FeeView> additionalFeeList = (List<FeeView>) SessionUtils.getAttribute(CustomerConstants.ADDITIONAL_FEES_LIST, request); for (FeeView selectedFee : getAdditionalFees()) { for (FeeView fee : additionalFeeList) { if (selectedFee.getFeeIdValue() != null && selectedFee.getFeeId().equals(fee.getFeeId())) { if (fee.isPeriodic() && !isFrequencyMatches(fee, meeting)) { errors.add( CustomerConstants.ERRORS_FEE_FREQUENCY_MISMATCH, new ActionMessage(CustomerConstants.ERRORS_FEE_FREQUENCY_MISMATCH)); return; } } } } } }
public List<FeeView> getFeesToApply() { List<FeeView> feesToApply = new ArrayList<FeeView>(); for (FeeView fee : getAdditionalFees()) { if (fee.getFeeIdValue() != null) { feesToApply.add(fee); } } for (FeeView fee : getDefaultFees()) { if (!fee.isRemoved()) { feesToApply.add(fee); } } return feesToApply; }
protected void validateForFeeAmount(ActionErrors errors, Locale locale) { List<FeeView> feeList = getFeesToApply(); for (FeeView fee : feeList) { if (StringUtils.isBlank(fee.getAmount())) { errors.add( CustomerConstants.FEE, new ActionMessage(CustomerConstants.ERRORS_SPECIFY_FEE_AMOUNT)); } else { validateAmount( fee.getAmount(), CustomerConstants.FEE, errors, locale, FilePaths.CUSTOMER_UI_RESOURCE_PROPERTYFILE); } } }
protected void validateForDuplicatePeriodicFee(HttpServletRequest request, ActionErrors errors) throws ApplicationException { List<FeeView> additionalFeeList = (List<FeeView>) SessionUtils.getAttribute(CustomerConstants.ADDITIONAL_FEES_LIST, request); for (FeeView selectedFee : getAdditionalFees()) { int count = 0; for (FeeView duplicateSelectedfee : getAdditionalFees()) { if (selectedFee.getFeeIdValue() != null && selectedFee.getFeeId().equals(duplicateSelectedfee.getFeeId())) { if (isSelectedFeePeriodic(selectedFee, additionalFeeList)) { count++; } } } if (count > 1) { errors.add( CustomerConstants.FEE, new ActionMessage(CustomerConstants.ERRORS_DUPLICATE_PERIODIC_FEE)); break; } } }
private boolean isFrequencyMatches(FeeView fee, MeetingBO meeting) { return (fee.getFrequencyType().equals(RecurrenceType.MONTHLY) && meeting.isMonthly()) || (fee.getFrequencyType().equals(RecurrenceType.WEEKLY) && meeting.isWeekly()); }