use of org.mifos.framework.util.helpers.DoubleConversionResult in project head by mifos.
the class OpenBalanceActionForm method mandatoryCheck.
private ActionErrors mandatoryCheck(UserContext userContext) {
Locale locale = userContext.getPreferredLocale();
ResourceBundle resources = ResourceBundle.getBundle(FilePaths.SIMPLE_ACCOUNTING_RESOURCE, locale);
String financial_year = resources.getString(SimpleAccountingConstants.FINANCIALYEAR);
String office_Hierarchy = resources.getString(SimpleAccountingConstants.OFFICE_HIERARCHY);
String officeId = resources.getString(SimpleAccountingConstants.OFFICE);
String coa_name = resources.getString(SimpleAccountingConstants.COANAME);
String open_balance = resources.getString(SimpleAccountingConstants.OPENBALANCE);
ActionErrors errors = new ActionErrors();
if (financialYear == null || "".equals(financialYear.trim())) {
errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, financial_year));
}
if (officeHierarchy == null || "".equals(officeHierarchy.trim())) {
errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, office_Hierarchy));
}
if (office == null || "".equals(office.trim())) {
errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, officeId));
}
if (coaName == null || "".equals(coaName.trim())) {
errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, coa_name));
}
if (openBalance == null || "".equals(openBalance.trim())) {
errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, open_balance));
}
if (StringUtils.isNotBlank(getOpenBalance())) {
DoubleConversionResult conversionResult = validateAmount(getOpenBalance(), open_balance, errors);
if (conversionResult.getErrors().size() == 0 && !(conversionResult.getDoubleValue() > 0.0)) {
addError(errors, SimpleAccountingConstants.AMOUNT, SimpleAccountingConstants.ERRORS_MUST_BE_GREATER_THAN_ZERO, open_balance);
}
}
return errors;
}
use of org.mifos.framework.util.helpers.DoubleConversionResult in project head by mifos.
the class ViewStageTransactionActionForm method mandatoryCheck.
private ActionErrors mandatoryCheck(UserContext userContext) {
Locale locale = userContext.getPreferredLocale();
ResourceBundle resources = ResourceBundle.getBundle(FilePaths.SIMPLE_ACCOUNTING_RESOURCE, locale);
String trxn_Date = resources.getString(SimpleAccountingConstants.TRXNDATE);
String trxn_Type = resources.getString(SimpleAccountingConstants.TRXNTYPE);
String office_Hierarchy = resources.getString(SimpleAccountingConstants.OFFICE_HIERARCHY);
String officeId = resources.getString(SimpleAccountingConstants.OFFICE);
String main_Account = resources.getString(SimpleAccountingConstants.MAIN_ACCOUNT);
String subAccount = resources.getString(SimpleAccountingConstants.ACCOUNT_HEAD);
String Amount = resources.getString(SimpleAccountingConstants.AMOUNT);
String Notes = resources.getString(SimpleAccountingConstants.TRXN_NOTES);
String cheque_date = resources.getString(SimpleAccountingConstants.CHEQUE_DATE);
ActionErrors errors = new ActionErrors();
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 (getStageTrxnDate() == null || "".equals(getStageTrxnDate())) {
errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, trxn_Date));
} else if (getStageTrxnDate() != null && !getStageTrxnDate().equals("") && !DateUtils.isValidDate(getStageTrxnDate())) {
errors = trxnDateValidate(errors, locale);
} else if (DateUtils.isValidDate(getStageTrxnDate())) {
try {
trxnDate = DateUtils.getDateAsSentFromBrowser(getStageTrxnDate());
} 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 (stageTrxnType == null || "".equals(stageTrxnType.trim())) {
errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, trxn_Type));
}
if (stageOfficeHierarchy == null || "".equals(stageOfficeHierarchy.trim())) {
errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, office_Hierarchy));
}
if (stageOffice == null || "".equals(stageOffice.trim())) {
errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, officeId));
}
if (stageMainAccount == null || "".equals(stageMainAccount.trim())) {
errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, main_Account));
}
if (stageAccountHead == null || "".equals(stageAccountHead.trim())) {
errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, subAccount));
}
if (stageAmount == null || "".equals(stageAmount.trim())) {
errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, Amount));
}
if (StringUtils.isNotBlank(getStageAmount())) {
DoubleConversionResult conversionResult = validateAmount(getStageAmount(), Amount, errors);
if (conversionResult.getErrors().size() == 0 && !(conversionResult.getDoubleValue() > 0.0)) {
addError(errors, SimpleAccountingConstants.AMOUNT, SimpleAccountingConstants.ERRORS_MUST_BE_GREATER_THAN_ZERO, Amount);
}
}
if (stageNotes == null || "".equals(stageNotes.trim())) {
errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, Notes));
}
java.sql.Date chkDate = null;
if (getChequeDate() != null && !getChequeDate().equals("") && !DateUtils.isValidDate(getChequeDate())) {
errors = trxnDateValidate(errors, locale);
} else if (DateUtils.isValidDate(getChequeDate())) {
try {
chkDate = DateUtils.getDateAsSentFromBrowser(getChequeDate());
} catch (InvalidDateException ide) {
errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.INVALID_CHEQUE_DATE, cheque_date));
}
}
if (getChequeDate() != null && !getChequeDate().equals("") && !DateUtils.isValidDate(getChequeDate()))
errors = chequeDateValidate(errors, locale);
return errors;
}
use of org.mifos.framework.util.helpers.DoubleConversionResult in project head by mifos.
the class InstallmentFormatValidatorImpl method setTotalAmountValue.
private void setTotalAmountValue(RepaymentScheduleInstallment installment, String identifier, List<ErrorEntry> errorEntries) {
LocalizationConverter localizationConverter = new LocalizationConverter(installment.getCurrency());
DoubleConversionResult conversionResult = localizationConverter.parseDoubleForInstallmentTotalAmount(installment.getTotal());
List<ConversionError> conversionErrors = conversionResult.getErrors();
if (conversionErrors.isEmpty()) {
installment.setTotalValue(conversionResult.getDoubleValue());
} else {
processConversionErrors(installment, identifier, conversionErrors, errorEntries);
}
}
Aggregations