use of org.mifos.application.admin.servicefacade.InvalidDateException in project head by mifos.
the class CustomerServiceImpl method updateClientPersonalInfo.
@Override
public final void updateClientPersonalInfo(UserContext userContext, ClientPersonalInfoUpdate personalInfo) throws CustomerException {
ClientBO client = (ClientBO) this.customerDao.findCustomerById(personalInfo.getCustomerId());
client.validateVersion(personalInfo.getOriginalClientVersionNumber());
client.updateDetails(userContext);
LocalDate currentDOB = new LocalDate(client.getDateOfBirth());
LocalDate newDOB = currentDOB;
try {
// updating Date of birth
// doesn''t sound normal but it can be required in certain cases
// see http://mifosforge.jira.com/browse/MIFOS-4368
newDOB = new LocalDate(DateUtils.getDateAsSentFromBrowser(personalInfo.getDateOfBirth()));
} catch (InvalidDateException e) {
throw new MifosRuntimeException(e);
}
if (!currentDOB.isEqual(newDOB)) {
customerDao.validateClientForDuplicateNameOrGovtId(personalInfo.getClientDisplayName(), newDOB.toDateMidnight().toDate(), null);
}
try {
hibernateTransactionHelper.startTransaction();
hibernateTransactionHelper.beginAuditLoggingFor(client);
client.updatePersonalInfo(personalInfo);
clientPhotoService.update(personalInfo.getCustomerId().longValue(), personalInfo.getPicture());
customerDao.save(client);
hibernateTransactionHelper.commitTransaction();
} catch (ApplicationException e) {
hibernateTransactionHelper.rollbackTransaction();
throw new CustomerException(e.getKey(), e);
} catch (Exception e) {
hibernateTransactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
hibernateTransactionHelper.commitTransaction();
}
}
use of org.mifos.application.admin.servicefacade.InvalidDateException in project head by mifos.
the class LoanAccountAction method handleIndividualLoans.
void handleIndividualLoans(final LoanBO loanBO, final LoanAccountActionForm loanAccountActionForm, final boolean isRepaymentIndepOfMeetingEnabled, final List<LoanAccountDetailsDto> loanAccountDetailsList, final List<LoanBO> individualLoans, final Locale locale) throws AccountException, ServiceException {
List<Integer> foundLoans = new ArrayList<Integer>();
for (final LoanAccountDetailsDto loanAccountDetail : loanAccountDetailsList) {
Predicate predicateOldGlim = new Predicate() {
@Override
public boolean evaluate(final Object object) {
return ((LoanBO) object).getCustomer().getCustomerId().toString().equals(loanAccountDetail.getClientId());
}
};
LoanBO individualLoan = (LoanBO) CollectionUtils.find(individualLoans, predicateOldGlim);
if (individualLoan == null) {
// glimLoanUpdater.createIndividualLoan(loanAccountActionForm, loanBO, isRepaymentIndepOfMeetingEnabled,
// loanAccountDetail);
} else {
foundLoans.add(individualLoan.getAccountId());
try {
if (!AccountingRules.isGroupLoanWithMembers() && loanAccountActionForm.getLoanAmount() != null) {
loanAccountDetail.setLoanAmount(loanAccountActionForm.getLoanAmountAsBigDecimal().divide(individualLoan.calcFactorOfEntireLoan(), 10, RoundingMode.HALF_UP).toString());
}
glimLoanUpdater.updateIndividualLoan(loanAccountActionForm.getDisbursementDateValue(locale), loanAccountActionForm.getInterestDoubleValue(), loanAccountActionForm.getNoOfInstallmentsValue(), loanAccountDetail, individualLoan);
} catch (InvalidDateException e) {
e.printStackTrace();
}
}
}
for (LoanBO loan : individualLoans) {
if (!foundLoans.contains(loan.getAccountId())) {
glimLoanUpdater.delete(loan);
}
}
}
use of org.mifos.application.admin.servicefacade.InvalidDateException in project head by mifos.
the class LoanAccountActionForm method checkValidationForManagePreview.
private void checkValidationForManagePreview(ActionErrors errors, MifosCurrency currency, HttpServletRequest request) throws ApplicationException {
Locale locale = getUserContext(request).getPreferredLocale();
if (getState().equals(AccountState.LOAN_PARTIAL_APPLICATION) || getState().equals(AccountState.LOAN_PENDING_APPROVAL)) {
checkValidationForPreviewBefore(errors, request);
checkValidationForPreview(errors, currency, request);
// approval, it cannot be edited.
try {
// only validate if the disbursement date has changed
if (!getDisbursementDateValue(getUserContext(request).getPreferredLocale()).equals(getOriginalDisbursementDate())) {
validateDisbursementDate(errors, getCustomer(request), getDisbursementDateValue(getUserContext(request).getPreferredLocale()));
}
} catch (InvalidDateException dateException) {
addError(errors, LoanExceptionConstants.ERROR_INVALIDDISBURSEMENTDATE);
}
}
performGlimSpecificValidations(errors, currency, request);
validateCustomFields(request, errors);
validateRepaymentDayRequired(errors);
if (!configService.isNewGlimEnabled() || !configService.isGlimEnabled() || !getCustomer(request).isGroup()) {
validatePurposeOfLoanFields(errors, getMandatoryFields(request));
}
validateSourceOfFundFields(errors, getMandatoryFields(request));
validateExternalIDFields(errors, getMandatoryFields(request));
validateLoanAmount(errors, locale, currency);
validateInterest(errors, locale);
validateCollateralNotes(errors, locale);
}
use of org.mifos.application.admin.servicefacade.InvalidDateException in project head by mifos.
the class SavingsClosureActionForm method validateDate.
private ActionErrors validateDate(String date, String fieldName) {
ActionErrors errors = new ActionErrors();
java.sql.Date sqlDate = null;
if (date != null && !date.equals("")) {
try {
sqlDate = DateUtils.getDateAsSentFromBrowser(date);
if (DateUtils.whichDirection(sqlDate) > 0) {
errors = new ActionErrors();
errors.add(AccountConstants.ERROR_FUTUREDATE, new ActionMessage(AccountConstants.ERROR_FUTUREDATE, fieldName));
}
} catch (InvalidDateException e) {
errors.add(AccountConstants.ERROR_INVALIDDATE, new ActionMessage(AccountConstants.ERROR_INVALIDDATE, fieldName));
}
} else {
errors = new ActionErrors();
errors.add(AccountConstants.ERROR_MANDATORY, new ActionMessage(AccountConstants.ERROR_MANDATORY, fieldName));
}
return errors;
}
use of org.mifos.application.admin.servicefacade.InvalidDateException in project head by mifos.
the class SavingsDepositWithdrawalActionForm method validateTrxnDate.
private ActionErrors validateTrxnDate(String date, String fieldName) {
ActionErrors errors = new ActionErrors();
try {
if (lastTrxnDate != null && dateFallsBeforeDate(getDateAsSentFromBrowser(date), lastTrxnDate)) {
errors = new ActionErrors();
errors.add(AccountConstants.ERROR_PAYMENT_DATE_BEFORE_LAST_PAYMENT, new ActionMessage(AccountConstants.ERROR_PAYMENT_DATE_BEFORE_LAST_PAYMENT, fieldName));
}
} catch (InvalidDateException e) {
//date format was already validated
}
return errors;
}
Aggregations