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)));
}
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);
}
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());
}
Aggregations