Search in sources :

Example 16 with SavingsTestHelper

use of org.mifos.accounts.savings.util.helpers.SavingsTestHelper in project head by mifos.

the class SavingsBOIntegrationTest method testGenerateMeetingForNextYear.

@Test
public void testGenerateMeetingForNextYear() throws Exception {
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
    center = TestObjectFactory.createWeeklyFeeCenter("center1", meeting);
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    SavingsTestHelper SavingsTestHelper = new SavingsTestHelper();
    SavingsOfferingBO savingsOfferingBO = SavingsTestHelper.createSavingsOffering("dfasdasd1", "sad1");
    savingsOfferingBO.setRecommendedAmntUnit(RecommendedAmountUnit.COMPLETE_GROUP);
    SavingsBO savingsBO = SavingsTestHelper.createSavingsAccount(savingsOfferingBO, group, AccountState.SAVINGS_ACTIVE, TestUtils.makeUser());
    Short LastInstallmentId = savingsBO.getLastInstallmentId();
    AccountActionDateEntity lastYearLastInstallment = savingsBO.getAccountActionDate(LastInstallmentId);
    Integer installmetId = lastYearLastInstallment.getInstallmentId().intValue() + (short) 1;
    List<Days> workingDays = new FiscalCalendarRules().getWorkingDaysAsJodaTimeDays();
    List<Holiday> holidays = new ArrayList<Holiday>();
    savingsBO.generateNextSetOfMeetingDates(workingDays, holidays);
    TestObjectFactory.updateObject(savingsBO);
    TestObjectFactory.updateObject(center);
    TestObjectFactory.updateObject(group);
    TestObjectFactory.updateObject(savingsBO);
    center = (CustomerBO) StaticHibernateUtil.getSessionTL().get(CustomerBO.class, center.getCustomerId());
    group = (CustomerBO) StaticHibernateUtil.getSessionTL().get(CustomerBO.class, group.getCustomerId());
    savingsBO = (SavingsBO) StaticHibernateUtil.getSessionTL().get(SavingsBO.class, savingsBO.getAccountId());
    MeetingBO meetingBO = center.getCustomerMeeting().getMeeting();
    meetingBO.setMeetingStartDate(lastYearLastInstallment.getActionDate());
    List<Date> meetingDates = TestObjectFactory.getMeetingDates(group.getOfficeId(), meetingBO, 10);
    meetingDates.remove(0);
    Date FirstSavingInstallmetDate = savingsBO.getAccountActionDate(installmetId.shortValue()).getActionDate();
    Calendar calendar2 = Calendar.getInstance();
    calendar2.setTime(meetingDates.get(0));
    Calendar calendar3 = Calendar.getInstance();
    calendar3.setTime(FirstSavingInstallmetDate);
    Assert.assertEquals(0, new GregorianCalendar(calendar3.get(Calendar.YEAR), calendar3.get(Calendar.MONTH), calendar3.get(Calendar.DATE), 0, 0, 0).compareTo(new GregorianCalendar(calendar2.get(Calendar.YEAR), calendar2.get(Calendar.MONTH), calendar2.get(Calendar.DATE), 0, 0, 0)));
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) GregorianCalendar(java.util.GregorianCalendar) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) Date(java.util.Date) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) Holiday(org.mifos.application.holiday.business.Holiday) Days(org.joda.time.Days) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsTestHelper(org.mifos.accounts.savings.util.helpers.SavingsTestHelper) FiscalCalendarRules(org.mifos.config.FiscalCalendarRules) Test(org.junit.Test)

Example 17 with SavingsTestHelper

use of org.mifos.accounts.savings.util.helpers.SavingsTestHelper in project head by mifos.

the class SavingsActionStrutsTest method ignore_testSuccessfulGetStatusHistory.

/**
     * ignoring as test fails due to lazy init which doesnt happen in application
     */
public void ignore_testSuccessfulGetStatusHistory() throws Exception {
    SavingsTestHelper helper = new SavingsTestHelper();
    createInitialObjects();
    savingsOffering = helper.createSavingsOffering("asfddsf", "213a");
    savings = helper.createSavingsAccount("000100000000017", savingsOffering, group, AccountStates.SAVINGS_ACC_PARTIALAPPLICATION, userContext);
    Hibernate.initialize(savings);
    savingsOffering = null;
    AccountStateMachines.getInstance().initialize(AccountTypes.SAVINGS_ACCOUNT, null);
    PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
    savings.changeStatus(AccountState.SAVINGS_PENDING_APPROVAL, null, "notes", loggedInUser);
    Assert.assertEquals(AccountStates.SAVINGS_ACC_PENDINGAPPROVAL, savings.getAccountState().getId().shortValue());
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, savings, request);
    SessionUtils.setAttribute(Constants.USER_CONTEXT_KEY, TestUtils.makeUser(), request.getSession());
    setRequestPathInfo("/savingsAction.do");
    addRequestParameter("method", "getStatusHistory");
    addRequestParameter("globalAccountNum", savings.getGlobalAccountNum());
    actionPerform();
    verifyForward("getStatusHistory_success");
    verifyNoActionErrors();
    verifyNoActionMessages();
    Assert.assertEquals(2, ((List<SavingsTransactionHistoryDto>) SessionUtils.getAttribute(SavingsConstants.STATUS_CHANGE_HISTORY_LIST, request)).size());
}
Also used : PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) SavingsTransactionHistoryDto(org.mifos.dto.screen.SavingsTransactionHistoryDto) SavingsTestHelper(org.mifos.accounts.savings.util.helpers.SavingsTestHelper)

Example 18 with SavingsTestHelper

use of org.mifos.accounts.savings.util.helpers.SavingsTestHelper in project head by mifos.

the class SavingsOverDueDepositsTagIntegrationTest method createInitialObjects.

private void createInitialObjects() throws Exception {
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
    center = TestObjectFactory.createWeeklyFeeCenter("Center_Active_test", meeting);
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group_Active_test", CustomerStatus.GROUP_ACTIVE, center);
    SavingsTestHelper helper = new SavingsTestHelper();
    savingsOffering = helper.createSavingsOffering("2333dsf", "2132");
    savings = helper.createSavingsAccount(savingsOffering, group, AccountState.SAVINGS_ACTIVE, TestUtils.makeUser());
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) SavingsTestHelper(org.mifos.accounts.savings.util.helpers.SavingsTestHelper)

Aggregations

SavingsTestHelper (org.mifos.accounts.savings.util.helpers.SavingsTestHelper)18 Test (org.junit.Test)14 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)8 MeetingBO (org.mifos.application.meeting.business.MeetingBO)6 Date (java.util.Date)4 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)4 Calendar (java.util.Calendar)3 GregorianCalendar (java.util.GregorianCalendar)3 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)3 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)2 ArrayList (java.util.ArrayList)1 DateTime (org.joda.time.DateTime)1 Days (org.joda.time.Days)1 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)1 SavingsTrxnDetailEntity (org.mifos.accounts.savings.business.SavingsTrxnDetailEntity)1 Holiday (org.mifos.application.holiday.business.Holiday)1 FiscalCalendarRules (org.mifos.config.FiscalCalendarRules)1 SavingsTransactionHistoryDto (org.mifos.dto.screen.SavingsTransactionHistoryDto)1 PersistenceException (org.mifos.framework.exceptions.PersistenceException)1 DateTimeService (org.mifos.framework.util.DateTimeService)1