Search in sources :

Example 6 with LocalizationConverter

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"));
}
Also used : Locale(java.util.Locale) LocalizationConverter(org.mifos.framework.util.LocalizationConverter) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 7 with LocalizationConverter

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));
}
Also used : LocalizationConverter(org.mifos.framework.util.LocalizationConverter) DoubleConversionResult(org.mifos.framework.util.helpers.DoubleConversionResult) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 8 with LocalizationConverter

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));
}
Also used : Locale(java.util.Locale) LocalizationConverter(org.mifos.framework.util.LocalizationConverter) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 9 with LocalizationConverter

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));
}
Also used : LocalizationConverter(org.mifos.framework.util.LocalizationConverter) DoubleConversionResult(org.mifos.framework.util.helpers.DoubleConversionResult) Test(org.junit.Test)

Example 10 with LocalizationConverter

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);
    }
}
Also used : RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) LocalizationConverter(org.mifos.framework.util.LocalizationConverter) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ApplicableCharge(org.mifos.dto.domain.ApplicableCharge) FeeBO(org.mifos.accounts.fees.business.FeeBO) RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) MeetingHelper(org.mifos.application.meeting.util.helpers.MeetingHelper) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO)

Aggregations

LocalizationConverter (org.mifos.framework.util.LocalizationConverter)19 Test (org.junit.Test)6 Ignore (org.junit.Ignore)5 Locale (java.util.Locale)4 FeeBO (org.mifos.accounts.fees.business.FeeBO)4 DoubleConversionResult (org.mifos.framework.util.helpers.DoubleConversionResult)4 ArrayList (java.util.ArrayList)3 AccountBO (org.mifos.accounts.business.AccountBO)3 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)3 StringTokenizer (java.util.StringTokenizer)2 ApplicableAccountFeeDto (org.mifos.dto.domain.ApplicableAccountFeeDto)2 ApplicableCharge (org.mifos.dto.domain.ApplicableCharge)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 GregorianCalendar (java.util.GregorianCalendar)1 SimpleTimeZone (java.util.SimpleTimeZone)1 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)1 RateFeeBO (org.mifos.accounts.fees.business.RateFeeBO)1 LoanAccountsProductDto (org.mifos.accounts.loan.util.helpers.LoanAccountsProductDto)1