Search in sources :

Example 86 with SavingsBO

use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.

the class ApplyHolidayChangesHelperIntegrationTest method getSavingsAccountAndVerifyDates.

private void getSavingsAccountAndVerifyDates(SavingsBO savings, LocalDate[] expectedResultDates) {
    SavingsBO refreshedSavingsAccount = (SavingsBO) StaticHibernateUtil.getSessionTL().get(SavingsBO.class, savings.getAccountId());
    verifyAccountActionDates(refreshedSavingsAccount.getAccountActionDates(), expectedResultDates);
}
Also used : SavingsBO(org.mifos.accounts.savings.business.SavingsBO)

Example 87 with SavingsBO

use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.

the class SavingsAccountSchedulesIntegrationTest method shouldNotGenerateSavingsAccountSchedulesForGroupWithoutActiveClients.

@Test
public void shouldNotGenerateSavingsAccountSchedulesForGroupWithoutActiveClients() throws Exception {
    createCenterAndGroupHierarchyWithNoClients(aWeeklyMeeting);
    SavingsOfferingBO savingsProduct = new SavingsProductBuilder().mandatory().withMandatoryAmount("33.0").appliesToGroupsOnly().trackedPerIndividual().buildForIntegrationTests();
    SavingsBO savingsAccount = new SavingsAccountBuilder().active().withActivationDate(mondayTwoWeeksAgo()).withSavingsProduct(savingsProduct).withCustomer(group).withCreatedBy(IntegrationTestObjectMother.testUser()).buildJointSavingsAccount();
    IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
    List<AccountActionDateEntity> savingSchedules = savingsAccount.getAccountActionDatesSortedByInstallmentId();
    assertTrue(savingSchedules.isEmpty());
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) Test(org.junit.Test)

Example 88 with SavingsBO

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

use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.

the class SavingsBOIntegrationTest method testSuccessfulFlagSave.

@Test
public void testSuccessfulFlagSave() throws Exception {
    Session session = StaticHibernateUtil.getSessionTL();
    StaticHibernateUtil.startTransaction();
    createInitialObjects();
    savingsOffering = helper.createSavingsOffering("dfasdasd1", "sad1");
    savings = helper.createSavingsAccount("000X00000000013", savingsOffering, group, AccountStates.SAVINGS_ACC_APPROVED, userContext);
    savings.setUserContext(TestObjectFactory.getContext());
    PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
    savings.changeStatus(AccountState.SAVINGS_CANCELLED, null, "", loggedInUser);
    savings.setUserContext(this.userContext);
    AccountStateEntity state = (AccountStateEntity) session.get(AccountStateEntity.class, (short) 15);
    for (AccountStateFlagEntity flag : state.getFlagSet()) {
        AccountTestUtils.addAccountFlag(flag, savings);
    }
    savings.update();
    session = StaticHibernateUtil.getSessionTL();
    SavingsBO savingsNew = (SavingsBO) (session.get(SavingsBO.class, Integer.valueOf(savings.getAccountId())));
    Assert.assertEquals(savingsNew.getAccountFlags().size(), 3);
    session.evict(savingsNew);
}
Also used : AccountStateFlagEntity(org.mifos.accounts.business.AccountStateFlagEntity) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) Session(org.hibernate.Session) Test(org.junit.Test)

Example 90 with SavingsBO

use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.

the class SavingsBOIntegrationTest method testSuccessfulSaveInApprovedState.

@Test
public void testSuccessfulSaveInApprovedState() throws Exception {
    center = helper.createCenter();
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center);
    client1 = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_CLOSED, group);
    client2 = TestObjectFactory.createClient("client2", CustomerStatus.CLIENT_ACTIVE, group);
    savingsOffering = TestObjectFactory.createSavingsProduct("dfasdasd2", "sad2", RecommendedAmountUnit.PER_INDIVIDUAL);
    savings = new SavingsBO(userContext, savingsOffering, group, AccountState.SAVINGS_ACTIVE, savingsOffering.getRecommendedAmount(), getCustomFieldView());
    savings.save();
    StaticHibernateUtil.flushSession();
    ;
    savings = TestObjectFactory.getObject(SavingsBO.class, savings.getAccountId());
    verifyFields();
    Assert.assertEquals(AccountState.SAVINGS_ACTIVE.getValue(), savings.getAccountState().getId());
    Assert.assertEquals(savingsOffering.getRecommendedAmount(), savings.getRecommendedAmount());
}
Also used : SavingsBO(org.mifos.accounts.savings.business.SavingsBO) Test(org.junit.Test)

Aggregations

SavingsBO (org.mifos.accounts.savings.business.SavingsBO)111 UserContext (org.mifos.security.util.UserContext)43 MifosRuntimeException (org.mifos.core.MifosRuntimeException)30 AccountException (org.mifos.accounts.exceptions.AccountException)28 LocalDate (org.joda.time.LocalDate)27 MifosUser (org.mifos.security.MifosUser)26 Test (org.junit.Test)25 Money (org.mifos.framework.util.helpers.Money)24 ArrayList (java.util.ArrayList)22 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)22 PersistenceException (org.mifos.framework.exceptions.PersistenceException)22 Date (java.util.Date)20 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)19 BusinessRuleException (org.mifos.service.BusinessRuleException)18 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)17 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)17 CustomerBO (org.mifos.customers.business.CustomerBO)15 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)14 ServiceException (org.mifos.framework.exceptions.ServiceException)13 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)12