Search in sources :

Example 56 with SavingsScheduleEntity

use of org.mifos.accounts.savings.business.SavingsScheduleEntity 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

SavingsScheduleEntity (org.mifos.accounts.savings.business.SavingsScheduleEntity)56 Test (org.junit.Test)48 Money (org.mifos.framework.util.helpers.Money)33 DateTime (org.joda.time.DateTime)32 Date (java.util.Date)27 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)19 SavingsScheduleBuilder (org.mifos.domain.builders.SavingsScheduleBuilder)18 LocalDate (org.joda.time.LocalDate)13 Ignore (org.junit.Ignore)13 DateMidnight (org.joda.time.DateMidnight)6 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)5 ArrayList (java.util.ArrayList)4 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)3 Holiday (org.mifos.application.holiday.business.Holiday)3 MeetingBO (org.mifos.application.meeting.business.MeetingBO)3 HolidayBuilder (org.mifos.domain.builders.HolidayBuilder)3 SavingsProductBuilder (org.mifos.domain.builders.SavingsProductBuilder)3 Session (org.hibernate.Session)2 AccountTrxnEntity (org.mifos.accounts.business.AccountTrxnEntity)2 UserContext (org.mifos.security.util.UserContext)2