use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.
the class TestObjectFactory method createSavingsAccount.
/**
* Also see {@link SavingsTestHelper#createSavingsAccount(SavingsOfferingBO, CustomerBO, AccountState, UserContext)}
* which is less elaborate.
*/
public static SavingsBO createSavingsAccount(final String globalNum, final CustomerBO customer, final AccountState state, final Date startDate, final SavingsOfferingBO savingsOffering, UserContext userContext) throws Exception {
userContext = TestUtils.makeUserWithLocales();
SavingsBO savings = new SavingsBO(userContext, savingsOffering, customer, state, savingsOffering.getRecommendedAmount(), getCustomFieldView());
savings.save();
SavingBOTestUtils.setActivationDate(savings, new DateTimeService().getCurrentJavaDateTime());
StaticHibernateUtil.flushSession();
return getObject(SavingsBO.class, savings.getAccountId());
}
use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.
the class TestObjectFactory method deleteSpecificAccount.
private static void deleteSpecificAccount(final AccountBO account, final Session session) {
if (account instanceof LoanBO) {
LoanBO loan = (LoanBO) account;
if (null != loan.getLoanSummary()) {
session.delete(loan.getLoanSummary());
}
session.delete(account);
loan.getLoanOffering().getLoanOfferingMeeting().setMeeting(null);
session.delete(loan.getLoanOffering().getLoanOfferingMeeting());
session.delete(loan.getLoanOffering());
}
if (account instanceof SavingsBO) {
SavingsBO savings = (SavingsBO) account;
session.delete(account);
// FIXME - no longer create a meeting to track intereswt calculation for each savings account, instead we always use value from savigns product.
// session.delete(savings.getTimePerForInstcalc());
PrdOfferingMeetingEntity prdOfferingMeeting1 = savings.getSavingsOffering().getTimePerForInstcalc();
prdOfferingMeeting1.setMeeting(null);
session.delete(prdOfferingMeeting1);
PrdOfferingMeetingEntity prdOfferingMeeting2 = savings.getSavingsOffering().getFreqOfPostIntcalc();
prdOfferingMeeting2.setMeeting(null);
session.delete(prdOfferingMeeting2);
session.delete(savings.getSavingsOffering());
} else {
session.delete(account);
}
}
use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.
the class CustomerBOIntegrationTest method testgetSavingsBalance.
@Test
public void testgetSavingsBalance() throws Exception {
SavingsBO savings = getSavingsAccount("fsaf4", "ads4");
SavingBOTestUtils.setBalance(savings, new Money(getCurrency(), "1000"));
savings.update();
StaticHibernateUtil.flushAndClearSession();
savings = TestObjectFactory.getObject(SavingsBO.class, savings.getAccountId());
client = TestObjectFactory.getClient(client.getCustomerId());
Assert.assertEquals(new Money(getCurrency(), "1000.0"), savings.getSavingsBalance());
Assert.assertEquals(new Money(getCurrency(), "1000.0"), client.getSavingsBalance(getCurrency()));
StaticHibernateUtil.flushSession();
center = TestObjectFactory.getCenter(center.getCustomerId());
group = TestObjectFactory.getGroup(group.getCustomerId());
client = TestObjectFactory.getClient(client.getCustomerId());
savings = TestObjectFactory.getObject(SavingsBO.class, savings.getAccountId());
savings = null;
}
use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.
the class GroupValidationTest method givenAnActiveSavingsAccountExistsGroupTransferToCenterShouldFailValidation.
@Test
public void givenAnActiveSavingsAccountExistsGroupTransferToCenterShouldFailValidation() {
// setup
CenterBO center = new CenterBuilder().build();
GroupBO group = new GroupBuilder().withParentCustomer(center).build();
SavingsBO savings = new SavingsAccountBuilder().active().withCustomer(group).build();
group.addAccount(savings);
// exercise test
try {
group.validateNoActiveAccountsExist();
fail("should fail validation");
} catch (CustomerException e) {
assertThat(e.getKey(), is(CustomerConstants.ERRORS_HAS_ACTIVE_ACCOUNT));
}
}
use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.
the class CenterServiceFacadeWebTier method waiveChargesDue.
@Override
public void waiveChargesDue(Integer accountId, Integer waiveType) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
try {
AccountBO account = new AccountBusinessService().getAccount(accountId);
account.updateDetails(userContext);
PersonnelBO loggedInUser = this.personnelDao.findPersonnelById(userContext.getId());
WaiveEnum waiveEnum = WaiveEnum.fromInt(waiveType);
if (account.getPersonnel() != null) {
new AccountBusinessService().checkPermissionForWaiveDue(waiveEnum, account.getType(), account.getCustomer().getLevel(), userContext, account.getOffice().getOfficeId(), account.getPersonnel().getPersonnelId());
} else {
new AccountBusinessService().checkPermissionForWaiveDue(waiveEnum, account.getType(), account.getCustomer().getLevel(), userContext, account.getOffice().getOfficeId(), userContext.getId());
}
try {
this.transactionHelper.startTransaction();
if (account instanceof LoanBO) {
((LoanBO) account).waiveAmountDue(waiveEnum);
} else if (account instanceof SavingsBO) {
((SavingsBO) account).waiveNextDepositAmountDue(loggedInUser);
} else {
((CustomerAccountBO) account).waiveAmountDue();
}
this.customerDao.save(account);
this.transactionHelper.commitTransaction();
} catch (Exception e) {
this.transactionHelper.rollbackTransaction();
throw new BusinessRuleException(account.getAccountId().toString(), e);
} finally {
this.transactionHelper.closeSession();
}
} catch (ServiceException e) {
throw new MifosRuntimeException(e);
} catch (ApplicationException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
Aggregations