use of org.mifos.framework.util.LocalizationConverter in project head by mifos.
the class DateTag method prepareOutputString.
String prepareOutputString(String format, String dateName, String ddValue, String mmValue, String yyValue, String separator, String userfrmt) {
StringBuilder dateFunction = new StringBuilder();
dateFunction.append("onBlur,");
dateFunction.append("makeDateString(");
String dateSeparator = new LocalizationConverter().getDateSeparatorForCurrentLocale();
StringTokenizer tokenizer = new StringTokenizer(format, dateSeparator);
while (tokenizer.hasMoreTokens()) {
String ch = tokenizer.nextToken();
if (ch.equalsIgnoreCase("D")) {
dateFunction.append("'" + dateName + "DD',");
} else if (ch.equalsIgnoreCase("M")) {
dateFunction.append("'" + dateName + "MM',");
} else {
dateFunction.append("'" + dateName + "YY',");
}
}
dateFunction.append("'" + dateName + "'");
dateFunction.append(",'" + separator + "')");
String date = "";
if (ddValue != null && !ddValue.equals("") && mmValue != null && !mmValue.equals("") && yyValue != null && !yyValue.equals("")) {
date = DateUtils.createDateString(ddValue, mmValue, yyValue, format);
}
XmlBuilder htmlBuilder = makeUserFields(dateName, ddValue, mmValue, yyValue, dateFunction.toString(), format, dateSeparator);
htmlBuilder.singleTag("input", "type", "hidden", "id", dateName, "name", dateName, "value", date);
htmlBuilder.singleTag("input", "type", "hidden", "id", dateName + "Format", "name", dateName + "Format", "value", format);
htmlBuilder.singleTag("input", "type", "hidden", "id", "datePattern", "name", "datePattern", "value", userfrmt);
return htmlBuilder.toString();
}
use of org.mifos.framework.util.LocalizationConverter 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);
}
}
use of org.mifos.framework.util.LocalizationConverter in project head by mifos.
the class LoanBusinessService method populaleApplicableCharge.
private void populaleApplicableCharge(List<ApplicableCharge> applicableChargeList, List<PenaltyBO> penaltyList, UserContext userContext) {
for (PenaltyBO penalty : penaltyList) {
ApplicableCharge applicableCharge = new ApplicableCharge();
applicableCharge.setFeeId(penalty.getPenaltyId().toString());
applicableCharge.setFeeName(penalty.getPenaltyName());
applicableCharge.setIsPenaltyType(true);
if (penalty instanceof RatePenaltyBO) {
applicableCharge.setAmountOrRate(new LocalizationConverter().getDoubleStringForInterest(((RatePenaltyBO) penalty).getRate()));
applicableCharge.setFormula(((RatePenaltyBO) penalty).getFormula().getFormulaStringThatHasName());
applicableCharge.setIsRateType(true);
} else {
applicableCharge.setAmountOrRate(((AmountPenaltyBO) penalty).getAmount().toString());
applicableCharge.setIsRateType(false);
}
if (!penalty.isOneTime()) {
applicableCharge.setPeriodicity("true");
applicableCharge.setFormula(penalty.getPenaltyFrequency().getName());
}
applicableChargeList.add(applicableCharge);
}
}
use of org.mifos.framework.util.LocalizationConverter in project head by mifos.
the class BaseActionFormTest method xtestParseDoubleForMoney_is_IS.
/**
* Currently broken -- incomplete support for multiple locales for numeric
* input.
*/
@Ignore
@Test
public void xtestParseDoubleForMoney_is_IS() {
LocalizationConverter converter = new LocalizationConverter();
String doubleStr = "222.12345";
Double value = 222.12345;
DoubleConversionResult result = baseActionForm.parseDoubleForInterest("222,12345");
result = baseActionForm.parseDoubleForMoney("222,4");
Assert.assertEquals(value, result.getDoubleValue());
doubleStr = "222.4";
result = baseActionForm.parseDoubleForMoney(doubleStr);
Assert.assertEquals(ConversionError.NOT_ALL_NUMBER, result.getErrors().get(0));
doubleStr = "222a4";
result = baseActionForm.parseDoubleForMoney(doubleStr);
Assert.assertEquals(ConversionError.NOT_ALL_NUMBER, result.getErrors().get(0));
doubleStr = "222,40000";
result = baseActionForm.parseDoubleForMoney(doubleStr);
Assert.assertEquals(ConversionError.EXCEEDING_NUMBER_OF_DIGITS_AFTER_DECIMAL_SEPARATOR_FOR_MONEY, result.getErrors().get(0));
doubleStr = "222222222222,4";
result = baseActionForm.parseDoubleForMoney(doubleStr);
Assert.assertEquals(ConversionError.EXCEEDING_NUMBER_OF_DIGITS_BEFORE_DECIMAL_SEPARATOR_FOR_MONEY, result.getErrors().get(0));
// converter.setCurrentLocale(locale);
}
Aggregations