use of org.mifos.framework.util.LocalizationConverter in project head by mifos.
the class BaseActionFormTest method xtestGetDoubleValue_is_IS.
/**
* Currently broken -- incomplete support for multiple locales for numeric
* input.
*/
@Ignore
@Test
public void xtestGetDoubleValue_is_IS() throws Exception {
Locale locale = Localization.getInstance().getConfiguredLocale();
LocalizationConverter converter = new LocalizationConverter();
double dValue = 2.34;
Assert.assertEquals(dValue, baseActionForm.getDoubleValue("2,34"));
}
use of org.mifos.framework.util.LocalizationConverter in project head by mifos.
the class BaseActionFormTest method xtestParseDoubleForInterest_is_IS.
/**
* Currently broken -- incomplete support for multiple locales for numeric
* input.
*/
@Ignore
@Test
public void xtestParseDoubleForInterest_is_IS() {
LocalizationConverter converter = new LocalizationConverter();
String doubleStr = "222.12345";
Double value = 222.12345;
DoubleConversionResult result = baseActionForm.parseDoubleForInterest("222,12345");
Assert.assertEquals(value, result.getDoubleValue());
doubleStr = "222.12345";
result = baseActionForm.parseDoubleForInterest(doubleStr);
Assert.assertEquals(ConversionError.NOT_ALL_NUMBER, result.getErrors().get(0));
doubleStr = "2a2";
result = baseActionForm.parseDoubleForInterest(doubleStr);
Assert.assertEquals(ConversionError.NOT_ALL_NUMBER, result.getErrors().get(0));
doubleStr = "222,123456";
result = baseActionForm.parseDoubleForInterest(doubleStr);
Assert.assertEquals(ConversionError.EXCEEDING_NUMBER_OF_DIGITS_AFTER_DECIMAL_SEPARATOR_FOR_INTEREST, result.getErrors().get(0));
doubleStr = "12345678910,12345";
result = baseActionForm.parseDoubleForInterest(doubleStr);
Assert.assertEquals(ConversionError.EXCEEDING_NUMBER_OF_DIGITS_BEFORE_DECIMAL_SEPARATOR_FOR_INTEREST, result.getErrors().get(0));
}
use of org.mifos.framework.util.LocalizationConverter in project head by mifos.
the class BaseActionFormTest method xtestGetStringValue_is_IS.
/**
* Currently broken -- incomplete support for multiple locales for numeric
* input.
*/
@Ignore
@Test
public void xtestGetStringValue_is_IS() throws Exception {
String strValue = "0.25";
Locale locale = Localization.getInstance().getConfiguredLocale();
LocalizationConverter converter = new LocalizationConverter();
strValue = "0,25";
Assert.assertEquals(strValue, baseActionForm.getStringValue(0.25));
}
use of org.mifos.framework.util.LocalizationConverter in project head by mifos.
the class BaseActionFormTest method testParseDoubleForMoney.
@Test
public void testParseDoubleForMoney() {
LocalizationConverter converter = new LocalizationConverter();
String doubleStr = "222.4";
Double value = 222.4;
DoubleConversionResult result = baseActionForm.parseDoubleForMoney(doubleStr);
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 = "222222222222222.4";
result = baseActionForm.parseDoubleForMoney(doubleStr);
Assert.assertEquals(ConversionError.EXCEEDING_NUMBER_OF_DIGITS_BEFORE_DECIMAL_SEPARATOR_FOR_MONEY, result.getErrors().get(0));
}
use of org.mifos.framework.util.LocalizationConverter in project head by mifos.
the class AccountBusinessService method populaleApplicableCharge.
private void populaleApplicableCharge(List<ApplicableCharge> applicableChargeList, List<FeeBO> feeList, UserContext userContext) {
for (FeeBO fee : feeList) {
ApplicableCharge applicableCharge = new ApplicableCharge();
applicableCharge.setFeeId(fee.getFeeId().toString());
applicableCharge.setFeeName(fee.getFeeName());
applicableCharge.setIsPenaltyType(false);
if (fee.getFeeType().getValue().equals(RateAmountFlag.RATE.getValue())) {
applicableCharge.setAmountOrRate(new LocalizationConverter().getDoubleStringForInterest(((RateFeeBO) fee).getRate()));
applicableCharge.setFormula(((RateFeeBO) fee).getFeeFormula().getFormulaStringThatHasName());
applicableCharge.setIsRateType(true);
} else {
applicableCharge.setAmountOrRate(((AmountFeeBO) fee).getFeeAmount().toString());
applicableCharge.setIsRateType(false);
}
MeetingBO meeting = fee.getFeeFrequency().getFeeMeetingFrequency();
if (meeting != null) {
applicableCharge.setPeriodicity(new MeetingHelper().getDetailMessageWithFrequency(meeting, userContext));
} else {
applicableCharge.setPaymentType(fee.getFeeFrequency().getFeePayment().getName());
}
applicableChargeList.add(applicableCharge);
}
}
Aggregations