Search in sources :

Example 51 with MifosCurrency

use of org.mifos.application.master.business.MifosCurrency in project head by mifos.

the class CollectionSheetDtoTranslatorImplTest method setupStaticClientRules.

@BeforeClass
public static void setupStaticClientRules() {
    defaultCurrency = new MifosCurrency(defaultCurrencyId, null, null, null);
    Money.setDefaultCurrency(defaultCurrency);
}
Also used : MifosCurrency(org.mifos.application.master.business.MifosCurrency) BeforeClass(org.junit.BeforeClass)

Example 52 with MifosCurrency

use of org.mifos.application.master.business.MifosCurrency in project head by mifos.

the class LoanAccountServiceFacadeWebTierTest method setupAndInjectDependencies.

@Before
public void setupAndInjectDependencies() {
    loanAccountServiceFacade = new LoanAccountServiceFacadeWebTier(officeDao, loanProductDao, customerDao, personnelDao, fundDao, loanDao, accountService, scheduleCalculatorAdaptor, loanBusinessService, loanScheduleService, installmentsValidator, holidayServiceFacade, monthClosingServiceFacade, customerPersistence, configurationPersistence, clientServiceFacade, savingsServiceFacade);
    ((LoanAccountServiceFacadeWebTier) loanAccountServiceFacade).setTransactionHelper(hibernateTransactionHelper);
    rupee = new MifosCurrency(Short.valueOf("1"), "Rupee", BigDecimal.valueOf(1), "INR");
    userContext = TestUtils.makeUser();
}
Also used : MifosCurrency(org.mifos.application.master.business.MifosCurrency) Before(org.junit.Before)

Example 53 with MifosCurrency

use of org.mifos.application.master.business.MifosCurrency in project head by mifos.

the class LocalizationConverterTest method testParseDoubleForCashFlowValidations.

@Test
public void testParseDoubleForCashFlowValidations() {
    MifosCurrency mifosCurrency = new MifosCurrency(Short.valueOf("1"), "Rupee", BigDecimal.valueOf(1), "INR");
    LocalizationConverter localizationConverter = new LocalizationConverter(mifosCurrency);
    DoubleConversionResult result = parseForCashFlow(localizationConverter, "22.59");
    assertThat(result.getDoubleValue(), is(22.59));
    result = parseForCashFlow(localizationConverter, "222,59562");
    assertThat(result.getErrors().get(0), is(ConversionError.NOT_ALL_NUMBER));
    result = parseForCashFlow(localizationConverter, "2a5922");
    assertThat(result.getErrors().get(0), is(ConversionError.NOT_ALL_NUMBER));
    result = parseForCashFlow(localizationConverter, "22222222222.5");
    assertThat(result.getErrors().get(0), is(ConversionError.EXCEEDING_NUMBER_OF_DIGITS_BEFORE_DECIMAL_SEPARATOR_FOR_CASHFLOW_VALIDATION));
    result = parseForCashFlow(localizationConverter, "222.595690");
    assertThat(result.getErrors().get(0), is(ConversionError.EXCEEDING_NUMBER_OF_DIGITS_AFTER_DECIMAL_SEPARATOR_FOR_CASHFLOW_VALIDATION));
    result = parseForCashFlow(localizationConverter, "222.59");
    assertThat(result.getErrors().get(0), is(ConversionError.CASH_FLOW_THRESHOLD_OUT_OF_RANGE));
}
Also used : DoubleConversionResult(org.mifos.framework.util.helpers.DoubleConversionResult) MifosCurrency(org.mifos.application.master.business.MifosCurrency) Test(org.junit.Test)

Example 54 with MifosCurrency

use of org.mifos.application.master.business.MifosCurrency in project head by mifos.

the class TestObjectFactory method createSavingsAccount.

public static SavingsBO createSavingsAccount(final String globalNum, final CustomerBO customer, final Short accountStateId, final Date startDate, final SavingsOfferingBO savingsOffering) throws Exception {
    UserContext userContext = TestUtils.makeUserWithLocales();
    MifosCurrency currency = testObjectPersistence.getCurrency();
    MeetingBO meeting = createLoanMeeting(customer.getCustomerMeeting().getMeeting());
    SavingsBO savings = new SavingsBO(userContext, savingsOffering, customer, AccountState.SAVINGS_PARTIAL_APPLICATION, new Money(currency, "300.0"), null);
    savings.save();
    savings.setUserContext(TestObjectFactory.getContext());
    PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
    savings.changeStatus(AccountState.fromShort(accountStateId), null, "", loggedInUser);
    SavingBOTestUtils.setActivationDate(savings, new Date(System.currentTimeMillis()));
    List<Date> meetingDates = getMeetingDates(customer.getOfficeId(), meeting, 3);
    short installment = 0;
    for (Date date : meetingDates) {
        SavingsScheduleEntity actionDate = new SavingsScheduleEntity(savings, customer, ++installment, new java.sql.Date(date.getTime()), PaymentStatus.UNPAID, new Money(currency, "200.0"));
        AccountTestUtils.addAccountActionDate(actionDate, savings);
    }
    StaticHibernateUtil.flushSession();
    return getObject(SavingsBO.class, savings.getAccountId());
}
Also used : PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) UserContext(org.mifos.security.util.UserContext) MeetingBO(org.mifos.application.meeting.business.MeetingBO) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) MifosCurrency(org.mifos.application.master.business.MifosCurrency) Date(java.util.Date) LocalDate(org.joda.time.LocalDate)

Aggregations

MifosCurrency (org.mifos.application.master.business.MifosCurrency)54 Money (org.mifos.framework.util.helpers.Money)26 ArrayList (java.util.ArrayList)16 Test (org.junit.Test)12 BigDecimal (java.math.BigDecimal)10 Date (java.util.Date)10 HashMap (java.util.HashMap)10 Before (org.junit.Before)8 List (java.util.List)7 Locale (java.util.Locale)7 MifosRuntimeException (org.mifos.core.MifosRuntimeException)7 RepaymentScheduleInstallment (org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment)5 RepaymentScheduleInstallmentBuilder (org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallmentBuilder)5 MeetingBO (org.mifos.application.meeting.business.MeetingBO)4 LocalDate (org.joda.time.LocalDate)3 GLCodeEntity (org.mifos.accounts.financial.business.GLCodeEntity)3 PersistenceException (org.mifos.framework.exceptions.PersistenceException)3 DoubleConversionResult (org.mifos.framework.util.helpers.DoubleConversionResult)3 BigInteger (java.math.BigInteger)2 Calendar (java.util.Calendar)2