use of org.apache.struts.action.ActionMessage in project head by mifos.
the class ClientCustActionForm method validateSpouseNames.
@SuppressWarnings({ "unchecked" })
private void validateSpouseNames(ActionErrors errors, HttpServletRequest request) {
boolean mandatorySpouseType = false;
Map<Short, List<FieldConfigurationEntity>> entityMandatoryFieldMap = (Map<Short, List<FieldConfigurationEntity>>) request.getSession().getServletContext().getAttribute(Constants.FIELD_CONFIGURATION);
List<FieldConfigurationEntity> mandatoryfieldList = entityMandatoryFieldMap.get(EntityType.CLIENT.getValue());
for (FieldConfigurationEntity fieldConfigurationEntity : mandatoryfieldList) {
if (HiddenMandatoryFieldNamesConstants.SPOUSE_FATHER_INFORMATION.equals(fieldConfigurationEntity.getFieldName())) {
if (fieldConfigurationEntity.isMandatory()) {
mandatorySpouseType = true;
break;
}
}
}
// issue 2929: when the spouse/father fields are hidden, then the values are null instead empty string - this need to be fixed here
if (spouseName.getFirstName() == null) {
spouseName.setFirstName("");
}
if (spouseName.getMiddleName() == null) {
spouseName.setMiddleName("");
}
if (spouseName.getSecondLastName() == null) {
spouseName.setSecondLastName("");
}
if (spouseName.getLastName() == null) {
spouseName.setLastName("");
}
if (spouseName.getNameType() == null && (mandatorySpouseType || !StringUtils.isBlank(spouseName.getFirstName()) || !StringUtils.isBlank(spouseName.getMiddleName()) || !StringUtils.isBlank(spouseName.getSecondLastName()) || !StringUtils.isBlank(spouseName.getLastName()))) {
errors.add(CustomerConstants.SPOUSE_TYPE, new ActionMessage(CustomerConstants.ERRORS_MANDATORY, getLocalizedMessage("Customer.SpouseType")));
}
if (mandatorySpouseType && StringUtils.isBlank(spouseName.getFirstName())) {
errors.add(CustomerConstants.SPOUSE_FIRST_NAME, new ActionMessage(CustomerConstants.ERRORS_MANDATORY, getLocalizedMessage("Customer.SpouseFirstName")));
}
if (mandatorySpouseType && StringUtils.isBlank(spouseName.getLastName())) {
errors.add(CustomerConstants.SPOUSE_LAST_NAME, new ActionMessage(CustomerConstants.ERRORS_MANDATORY, getLocalizedMessage("Customer.SpouseLastName")));
}
}
use of org.apache.struts.action.ActionMessage in project head by mifos.
the class ClientCustActionForm method validateSelectedOfferings.
@SuppressWarnings("unchecked")
private void validateSelectedOfferings(ActionErrors errors, HttpServletRequest request) {
boolean duplicateFound = false;
for (int i = 0; i < selectedOfferings.size() - 1; i++) {
for (int j = i + 1; j < selectedOfferings.size(); j++) {
if (selectedOfferings.get(i) != null && selectedOfferings.get(j) != null && selectedOfferings.get(i).equals(selectedOfferings.get(j))) {
String selectedOffering = "";
try {
List<SavingsDetailDto> offeringsList = (List<SavingsDetailDto>) SessionUtils.getAttribute(ClientConstants.SAVINGS_OFFERING_LIST, request);
for (SavingsDetailDto savingsOffering : offeringsList) {
if (selectedOfferings.get(i).equals(savingsOffering.getPrdOfferingId())) {
selectedOffering = savingsOffering.getPrdOfferingName();
}
break;
}
} catch (PageExpiredException pee) {
}
errors.add(ClientConstants.ERRORS_DUPLICATE_OFFERING_SELECTED, new ActionMessage(ClientConstants.ERRORS_DUPLICATE_OFFERING_SELECTED, selectedOffering));
duplicateFound = true;
break;
}
}
if (duplicateFound) {
break;
}
}
}
use of org.apache.struts.action.ActionMessage in project head by mifos.
the class CollectionSheetEntryDtoPostPreviewValidator method validatePopulatedData.
private ActionErrors validatePopulatedData(final CollectionSheetEntryDto parent, final ActionErrors errors, final Locale locale) {
List<CollectionSheetEntryDto> children = parent.getCollectionSheetEntryChildren();
String acCollections = MessageLookup.getLocalizedMessage(CollectionSheetEntryConstants.AC_COLLECTION);
if (null != children) {
for (CollectionSheetEntryDto collectionSheetEntryDto : children) {
validatePopulatedData(collectionSheetEntryDto, errors, locale);
}
}
for (LoanAccountsProductDto accountView : parent.getLoanAccountDetails()) {
if (accountView.isDisburseLoanAccountPresent() || accountView.getLoanAccountViews().size() > 1) {
Money enteredAmount = new Money(Money.getDefaultCurrency(), 0.0);
if (null != accountView.getEnteredAmount() && accountView.isValidAmountEntered()) {
enteredAmount = new Money(Money.getDefaultCurrency(), getDoubleValue(accountView.getEnteredAmount()));
}
Money enteredDisbursalAmount = new Money(Money.getDefaultCurrency(), 0.0);
if (null != accountView.getDisBursementAmountEntered() && accountView.isValidDisbursementAmount()) {
enteredDisbursalAmount = new Money(Money.getDefaultCurrency(), getDoubleValue(accountView.getDisBursementAmountEntered()));
}
Money totalDueAmount = new Money(Money.getDefaultCurrency(), accountView.getTotalAmountDue());
Money totalDisburtialAmount = new Money(Money.getDefaultCurrency(), accountView.getTotalDisburseAmount());
if (totalDisburtialAmount.isGreaterThanZero()) {
if ((!accountView.isValidDisbursementAmount() || accountView.getDisBursementAmountEntered() == null || !enteredDisbursalAmount.toString().equals(totalDisburtialAmount.toString())) && !enteredDisbursalAmount.isZero()) {
errors.add(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT, new ActionMessage(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT, accountView.getPrdOfferingShortName(), parent.getCustomerDetail().getDisplayName()));
}
}
if (totalDueAmount.isGreaterThanZero()) {
if ((!accountView.isValidAmountEntered() || accountView.getEnteredAmount() == null || !enteredAmount.toString().equals(totalDueAmount.toString())) && !enteredAmount.isZero()) {
errors.add(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT, new ActionMessage(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT, accountView.getPrdOfferingShortName(), parent.getCustomerDetail().getDisplayName()));
}
}
boolean moreThanTwoLoanAccountsToPrepaid = isThereMoreThanTwoLoanAccountsToPrepaid(accountView.getLoanAccountViews());
if (totalDisburtialAmount.isLessThanOrEqualZero() && totalDueAmount.isLessThanOrEqualZero()) {
if (!accountView.isValidAmountEntered() || !accountView.isValidDisbursementAmount() || !enteredDisbursalAmount.isZero() || (!moreThanTwoLoanAccountsToPrepaid && !enteredAmount.isZero())) {
errors.add(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT, new ActionMessage(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT, accountView.getPrdOfferingShortName(), parent.getCustomerDetail().getDisplayName()));
} else if (moreThanTwoLoanAccountsToPrepaid && !enteredAmount.isZero()) {
errors.add(CollectionSheetEntryConstants.BULKENTRYINVALIDPREPAYAMOUNT, new ActionMessage(CollectionSheetEntryConstants.BULKENTRYINVALIDPREPAYAMOUNT, accountView.getPrdOfferingShortName(), parent.getCustomerDetail().getDisplayName()));
}
}
}
}
for (SavingsAccountDto savingsAccountDto : parent.getSavingsAccountDetails()) {
if (!savingsAccountDto.isValidDepositAmountEntered() || !savingsAccountDto.isValidWithDrawalAmountEntered()) {
errors.add(CollectionSheetEntryConstants.ERRORINVALIDAMOUNT, new ActionMessage(CollectionSheetEntryConstants.ERRORINVALIDAMOUNT, savingsAccountDto.getSavingsOfferingShortName(), parent.getCustomerDetail().getDisplayName()));
}
}
CustomerAccountDto customerAccountDto = parent.getCustomerAccountDetails();
Double customerAccountAmountEntered = 0.0;
if (null != customerAccountDto.getCustomerAccountAmountEntered() && customerAccountDto.isValidCustomerAccountAmountEntered()) {
customerAccountAmountEntered = getDoubleValue(customerAccountDto.getCustomerAccountAmountEntered());
}
if (!customerAccountDto.isValidCustomerAccountAmountEntered() || customerAccountAmountEntered < 0.0) {
errors.add(CollectionSheetEntryConstants.BULKENTRYINVALIDACCOLLECTIONS, new ActionMessage(CollectionSheetEntryConstants.BULKENTRYINVALIDACCOLLECTIONS, acCollections, parent.getCustomerDetail().getDisplayName()));
}
return errors;
}
use of org.apache.struts.action.ActionMessage in project head by mifos.
the class BulkEntryActionForm method receiptDateValidate.
private ActionErrors receiptDateValidate(ActionErrors errors) {
if (StringUtils.isNotBlank(getReceiptDate()) && !DateUtils.isValidDate(getReceiptDate())) {
String rcptdate = getLocalizedMessage(CollectionSheetEntryConstants.RECEIPTDATE);
errors.add(CollectionSheetEntryConstants.INVALID_RECEIPT_DATE, new ActionMessage(CollectionSheetEntryConstants.INVALID_RECEIPT_DATE, rcptdate));
}
return errors;
}
use of org.apache.struts.action.ActionMessage in project head by mifos.
the class BulkEntryActionForm method mandatoryCheck.
private ActionErrors mandatoryCheck(Date meetingDate, UserContext userContext, short isCenterHierarchyExists) {
String loanOfficer = getLocalizedMessage(CollectionSheetEntryConstants.LOANOFFICERS);
String modeOfPayment = getLocalizedMessage(CollectionSheetEntryConstants.MODE_OF_PAYMENT);
String dateOfTransaction = getLocalizedMessage(CollectionSheetEntryConstants.DATEOFTRXN);
ActionErrors errors = receiptDateValidate(new ActionErrors());
java.sql.Date currentDate = null;
try {
currentDate = DateUtils.getLocaleDate(userContext.getPreferredLocale(), DateUtils.getCurrentDate(userContext.getPreferredLocale()));
} catch (InvalidDateException ide) {
errors.add(CollectionSheetEntryConstants.INVALIDDATE, new ActionMessage(CollectionSheetEntryConstants.INVALIDDATE));
}
java.sql.Date trxnDate = null;
String customerLabel = isCenterHierarchyExists == Constants.YES ? ConfigurationConstants.CENTER : ConfigurationConstants.GROUP;
if (officeId == null || "".equals(officeId.trim())) {
errors.add(CollectionSheetEntryConstants.MANDATORYFIELDS, new ActionMessage(CollectionSheetEntryConstants.MANDATORYFIELDS, getMessageText(ConfigurationConstants.BRANCHOFFICE)));
}
if (loanOfficerId == null || "".equals(loanOfficerId.trim())) {
errors.add(CollectionSheetEntryConstants.MANDATORYFIELDS, new ActionMessage(CollectionSheetEntryConstants.MANDATORYFIELDS, loanOfficer));
}
if (customerId == null || "".equals(customerId.trim())) {
errors.add(CollectionSheetEntryConstants.MANDATORYFIELDS, new ActionMessage(CollectionSheetEntryConstants.MANDATORYFIELDS, getLabel(customerLabel)));
}
if (getTransactionDate() != null && !getTransactionDate().equals("")) {
try {
trxnDate = DateUtils.getDateAsSentFromBrowser(getTransactionDate());
} catch (InvalidDateException ide) {
errors.add(CollectionSheetEntryConstants.MANDATORYFIELDS, new ActionMessage(AccountConstants.ERROR_INVALID_TRXN));
}
} else {
errors.add(CollectionSheetEntryConstants.MANDATORYFIELDS, new ActionMessage(CollectionSheetEntryConstants.MANDATORYENTER, dateOfTransaction));
}
if (currentDate != null && meetingDate != null && trxnDate != null && (meetingDate.compareTo(trxnDate) > 0 || trxnDate.compareTo(currentDate) > 0)) {
errors.add(CollectionSheetEntryConstants.MANDATORYFIELDS, new ActionMessage(CollectionSheetEntryConstants.INVALIDENDDATE, dateOfTransaction));
} else if (meetingDate == null && trxnDate != null && trxnDate.compareTo(currentDate) != 0) {
errors.add(CollectionSheetEntryConstants.MANDATORYFIELDS, new ActionMessage(CollectionSheetEntryConstants.MEETINGDATEEXCEPTION, dateOfTransaction));
}
if (paymentId == null || "".equals(paymentId.trim())) {
errors.add(CollectionSheetEntryConstants.MANDATORYFIELDS, new ActionMessage(CollectionSheetEntryConstants.MANDATORYFIELDS, modeOfPayment));
}
return errors;
}
Aggregations