use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.
the class SavingsActionStrutsTest method createAndAddObjects.
private void createAndAddObjects() throws Exception {
createInitialObjects();
Date currentDate = new Date(System.currentTimeMillis());
savingsOffering = TestObjectFactory.createSavingsProduct("sav prd1", "prd1", currentDate, RecommendedAmountUnit.COMPLETE_GROUP);
SavingsBO savingsObj = new SavingsBO(userContext, savingsOffering, group, AccountState.SAVINGS_ACTIVE, savingsOffering.getRecommendedAmount(), getCustomFieldView());
SessionUtils.setAttribute(Constants.BUSINESS_KEY, savingsObj, request);
addRequestParameter("selectedPrdOfferingId", savingsOffering.getPrdOfferingId().toString());
}
use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.
the class SavingsActionStrutsTest method testSuccessfulGetBySystemId.
@Test
public void testSuccessfulGetBySystemId() throws Exception {
setMifosUserFromContext();
createAndAddObjects(AccountState.SAVINGS_PARTIAL_APPLICATION);
addRequestParameter("globalAccountNum", savings.getGlobalAccountNum());
setRequestPathInfo("/savingsAction.do");
addRequestParameter("method", "get");
performNoErrors();
verifyForward("get_success");
SavingsBO savingsObj = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
Assert.assertEquals(savings.getGlobalAccountNum(), savingsObj.getGlobalAccountNum());
Assert.assertEquals(savingsOffering.getRecommendedAmount(), savingsObj.getRecommendedAmount());
savingsOffering = null;
Assert.assertNotNull(SessionUtils.getAttribute(MasterConstants.SAVINGS_TYPE, request));
Assert.assertNotNull(SessionUtils.getAttribute(MasterConstants.RECOMMENDED_AMOUNT_UNIT, request));
Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.CUSTOM_FIELDS, request));
Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.RECENTY_ACTIVITY_DETAIL_PAGE, request));
Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.NOTES, request));
}
use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.
the class CenterActionStrutsTest method testGet.
@Test
public void testGet() throws Exception {
setNonLoanOfficerMifosUser();
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
savingsBO = getSavingsAccount("fsaf6", "ads6", center);
StaticHibernateUtil.flushSession();
setRequestPathInfo("/centerCustAction.do");
addRequestParameter("method", "get");
addRequestParameter("globalCustNum", center.getGlobalCustNum());
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
actionPerform();
verifyForward(ActionForwards.get_success.toString());
CustomerBO centerBO = (CenterBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
Assert.assertNotNull(center);
Assert.assertEquals(center.getCustomerId(), centerBO.getCustomerId());
CenterInformationDto centerInformation = (CenterInformationDto) SessionUtils.getAttribute("centerInformationDto", request);
List<CustomerDetailDto> children = centerInformation.getGroupsOtherThanClosedAndCancelled();
Assert.assertNotNull(children);
Assert.assertEquals(1, children.size());
Assert.assertEquals("Size of the active accounts should be 1", 1, centerInformation.getSavingsAccountsInUse().size());
StaticHibernateUtil.flushSession();
center = TestObjectFactory.getCenter(center.getCustomerId());
group = TestObjectFactory.getGroup(group.getCustomerId());
savingsBO = TestObjectFactory.getObject(SavingsBO.class, savingsBO.getAccountId());
}
use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.
the class GroupPerformanceHistoryUsingCustomerServiceIntegrationTest method shouldGetTotalSavingsBalance.
@Test
public void shouldGetTotalSavingsBalance() throws Exception {
// setup
SavingsOfferingBO groupSavingsProduct = new SavingsProductBuilder().appliesToGroupsOnly().voluntary().withName("groupSavings").withShortName("GSP").buildForIntegrationTests();
IntegrationTestObjectMother.createProduct(groupSavingsProduct);
SavingsBO groupSavingsAccount = new SavingsAccountBuilder().withSavingsProduct(groupSavingsProduct).withCustomer(existingActiveClient).withCreatedBy(IntegrationTestObjectMother.testUser()).withSavingsOfficer(existingLoanOfficer).withBalanceOf(new Money(Money.getDefaultCurrency(), "200.0")).build();
IntegrationTestObjectMother.saveSavingsAccount(groupSavingsAccount);
SavingsOfferingBO clientSavingsProduct = new SavingsProductBuilder().appliesToClientsOnly().voluntary().withName("clientSavings").withShortName("CSP").buildForIntegrationTests();
IntegrationTestObjectMother.createProduct(clientSavingsProduct);
SavingsBO clientSavingsAccount = new SavingsAccountBuilder().withSavingsProduct(clientSavingsProduct).withCustomer(existingActiveClient).withCreatedBy(IntegrationTestObjectMother.testUser()).withSavingsOfficer(existingLoanOfficer).withBalanceOf(new Money(Money.getDefaultCurrency(), "550.0")).build();
IntegrationTestObjectMother.saveSavingsAccount(clientSavingsAccount);
existingGroup = customerDao.findGroupBySystemId(existingGroup.getGlobalCustNum());
// exercise test
Money savingsAmount = existingGroup.getGroupPerformanceHistory().getTotalSavingsAmount();
// verification
assertThat(savingsAmount.getAmountDoubleValue(), is(750.0));
}
use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.
the class IntegrationTestObjectMother method saveSavingsProductAndAssociatedSavingsAccounts.
public static void saveSavingsProductAndAssociatedSavingsAccounts(final SavingsOfferingBO savingsProduct, final SavingsBO... relatedSavingsAccounts) {
try {
customerPersistence.createOrUpdate(savingsProduct);
for (SavingsBO savingAccount : relatedSavingsAccounts) {
customerPersistence.createOrUpdate(savingAccount);
}
StaticHibernateUtil.flushSession();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations