use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.
the class SavingsAccountSchedulesIntegrationTest method shouldGenerateSavingsAccountSchedulesForActiveClientsOfCenter.
@Test
public void shouldGenerateSavingsAccountSchedulesForActiveClientsOfCenter() throws Exception {
createCenterGroupClientHierarchy(aWeeklyMeeting);
SavingsOfferingBO savingsProduct = new SavingsProductBuilder().mandatory().withMandatoryAmount("33.0").appliesToCentersOnly().buildForIntegrationTests();
SavingsBO savingsAccount = new SavingsAccountBuilder().active().withActivationDate(mondayTwoWeeksAgo()).withSavingsProduct(savingsProduct).withCustomer(center).withMember(client).withCreatedBy(IntegrationTestObjectMother.testUser()).buildJointSavingsAccount();
IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
List<AccountActionDateEntity> savingSchedules = savingsAccount.getAccountActionDatesSortedByInstallmentId();
for (AccountActionDateEntity savingSchedule : savingSchedules) {
assertThat("saving schedule should be generated for active client belong to center savings account", savingSchedule.getCustomer().getCustomerId(), is(client.getCustomerId()));
}
}
use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.
the class GroupValidationTest method givenAnActiveSavingsAccountExistsOnClientOfGroupGroupTransferToCenterShouldFailValidation.
@Test
public void givenAnActiveSavingsAccountExistsOnClientOfGroupGroupTransferToCenterShouldFailValidation() {
// setup
CenterBO center = new CenterBuilder().build();
GroupBO group = new GroupBuilder().withParentCustomer(center).build();
ClientBO client = new ClientBuilder().withParentCustomer(group).active().buildForUnitTests();
group.addChild(client);
SavingsBO savings = new SavingsAccountBuilder().active().withCustomer(group).build();
client.addAccount(savings);
// exercise test
try {
group.validateNoActiveAccountsExist();
fail("should fail validation");
} catch (CustomerException e) {
assertThat(e.getKey(), is(CustomerConstants.ERRORS_CHILDREN_HAS_ACTIVE_ACCOUNT));
}
}
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);
}
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());
}
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)));
}
Aggregations