use of org.mifos.application.admin.servicefacade.InvalidDateException in project head by mifos.
the class DateComponentValidator method validate.
@Override
public Date validate(Object input) throws ValidationError {
input = super.validate(input);
Map inputMap = (Map) input;
if (inputMap.size() == 0) {
throw makeError(input, ErrorType.MISSING);
}
try {
String dayValue = (String) inputMap.get("DD");
String monthValue = (String) inputMap.get("MM");
String yearValue = (String) inputMap.get("YY");
return DateUtils.parseBrowserDateFields(yearValue, monthValue, dayValue);
} catch (InvalidDateException e) {
throw makeError(input, ErrorType.DATE_FORMAT);
}
}
use of org.mifos.application.admin.servicefacade.InvalidDateException in project head by mifos.
the class DateUtils method convertDbToUserFmt.
public static String convertDbToUserFmt(String dbDate, String userPattern) throws InvalidDateException {
try {
SimpleDateFormat databaseFormat = new SimpleDateFormat(dbFormat, dateLocale);
java.util.Date date = databaseFormat.parse(dbDate);
SimpleDateFormat userFormat = new SimpleDateFormat(userPattern);
return userFormat.format(date);
} catch (ParseException e) {
throw new InvalidDateException(dbDate, e);
}
}
use of org.mifos.application.admin.servicefacade.InvalidDateException in project head by mifos.
the class DateUtils method getDateAsSentFromBrowser.
/**
* "as sent from browser" is a bit of a misnomer; it really is (at least in
* many cases), as formatted by a routine on the server side like
* ClientCustActionForm#getDateOfBirth()
*
* @throws InvalidDateException
*/
public static java.sql.Date getDateAsSentFromBrowser(String value) throws InvalidDateException {
if (value == null || value == "") {
return null;
}
try {
String formatStr = "d" + dateSeparator + "M" + dateSeparator + "yy";
SimpleDateFormat format = new SimpleDateFormat(formatStr, internalLocale);
format.setLenient(false);
return new java.sql.Date(format.parse(value).getTime());
} catch (ParseException e) {
throw new InvalidDateException(value);
}
}
use of org.mifos.application.admin.servicefacade.InvalidDateException in project head by mifos.
the class LoanAccountActionForm method checkValidationForPreviewBefore.
private void checkValidationForPreviewBefore(ActionErrors errors, HttpServletRequest request) throws ApplicationException {
LoanOfferingBO loanOffering = (LoanOfferingBO) SessionUtils.getAttribute(LoanConstants.LOANOFFERING, request);
if (!((configService.isNewGlimEnabled() || configService.isGlimEnabled()) && getCustomer(request).isGroup())) {
checkForMinMax(errors, loanAmount, amountRange, this.getLocalizedMessage("loan.amount"));
}
checkForMinMax(errors, interestRate, maxInterestRate, minInterestRate, this.getLocalizedMessage("loan.interestRate"));
checkForMinMax(errors, noOfInstallments, installmentRange, this.getLocalizedMessage("loan.noOfInstallments"));
if (StringUtils.isBlank(getDisbursementDate())) {
addError(errors, "Proposed/Actual disbursal date", "errors.validandmandatory", this.getLocalizedMessage("loan.disbursalDate"));
}
// Check for invalid data format
try {
DateUtils.getLocaleDate(Locale.ENGLISH, getDisbursementDate());
} catch (InvalidDateException ide) {
addError(errors, "Proposed/Actual disbursal date", LoanExceptionConstants.ERROR_INVALID_DISBURSEMENT_DATE_FORMAT, this.getLocalizedMessage("loan.disbursalDate"));
}
if (isInterestDedAtDisbValue()) {
setGracePeriodDuration("0");
}
if (((!isInterestDedAtDisbValue()) && StringUtils.isBlank(getGracePeriodDuration())) || (getDoubleValue(getGracePeriodDuration()) != null && getDoubleValue(getNoOfInstallments()) != null && getDoubleValue(getGracePeriodDuration()) >= getDoubleValue(getNoOfInstallments()))) {
String gracePeriodForRepayments = this.getLocalizedMessage("loan.grace_period");
String noInst = StringUtils.isBlank(getNoOfInstallments()) ? getStringValue(installmentRange.getMaxNoOfInstall()) : getNoOfInstallments();
addError(errors, LoanConstants.GRACEPERIODDURATION, LoanConstants.GRACEPERIODERROR, gracePeriodForRepayments, noInst);
}
}
use of org.mifos.application.admin.servicefacade.InvalidDateException in project head by mifos.
the class VoucherBranchMappingActionForm method mandatoryCheck.
private ActionErrors mandatoryCheck(UserContext userContext) {
Locale locale = userContext.getPreferredLocale();
ResourceBundle resources = ResourceBundle.getBundle(FilePaths.SIMPLE_ACCOUNTING_RESOURCE, locale);
ActionErrors errors = new ActionErrors();
String branchname = resources.getString(SimpleAccountingConstants.BRANCH_NAME);
String Amount = resources.getString(SimpleAccountingConstants.AMOUNT);
String trxn_Type = resources.getString(SimpleAccountingConstants.TRXNTYPE);
String main_Account = resources.getString(SimpleAccountingConstants.MAIN_ACCOUNT);
String Notes = resources.getString(SimpleAccountingConstants.TRXN_NOTES);
String trxn_Date = resources.getString(SimpleAccountingConstants.TRXNDATE);
String[] amts = getAmount();
String[] trannotes = getTransactionnotes();
// String[] canames=getCoaname();
List<CoaNamesDto> coaNamesDtolist = new ArrayList<CoaNamesDto>();
if (amts.length < 0 || "".equals(amts)) {
errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, Amount));
}
for (int i = 0; i < amts.length; i++) {
if (amts[i].equalsIgnoreCase("0")) {
errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, Amount));
}
}
if (trannotes == null || "".equals(trannotes)) {
errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, Notes));
}
{
for (int i = 0; i < getAmount().length; i++) {
CoaNamesDto coanamesob = new CoaNamesDto();
coanamesob.setAmount(amts[i]);
coanamesob.setTrxnnotes(trannotes[i]);
// coanamesob.setCoaName(canames[i]);
coaNamesDtolist.add(coanamesob);
}
}
java.sql.Date currentDate = null;
try {
currentDate = DateUtils.getLocaleDate(userContext.getPreferredLocale(), DateUtils.getCurrentDate(userContext.getPreferredLocale()));
} catch (InvalidDateException ide) {
errors.add(SimpleAccountingConstants.INVALIDDATE, new ActionMessage(SimpleAccountingConstants.INVALIDDATE));
}
java.sql.Date trxnDate = null;
if (getTransactiondate() == null || "".equals(getTransactiondate())) {
errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, trxn_Date));
} else if (getTransactiondate() != null && !getTransactiondate().equals("") && !DateUtils.isValidDate(getTransactiondate())) {
errors = trxnDateValidate(errors, locale);
} else if (DateUtils.isValidDate(getTransactiondate())) {
try {
trxnDate = DateUtils.getDateAsSentFromBrowser(getTransactiondate());
} catch (InvalidDateException ide) {
errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.INVALID_TRXN_DATE, trxn_Date));
}
if (trxnDate.compareTo(currentDate) > 0) {
errors.add(SimpleAccountingConstants.INVALID_FUTURE, new ActionMessage(SimpleAccountingConstants.INVALID_FUTURE, trxn_Date));
}
}
if (getBranch() == null || "".equals(getBranch())) {
errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, branchname));
}
if (transactiontype == null || "".equals(transactiontype.trim())) {
errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, trxn_Type));
}
if (mainAccount == null || "".equals(mainAccount.trim())) {
errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, main_Account));
}
return errors;
}
Aggregations