use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.
the class CollectionSheetServiceImplRetrieveSavingsAccountsIntegrationTest method testCollectionSheetRetrieveOnlyReturnsActiveAndInactiveSavingsAccounts.
/**
* need to clean up test data set up
*/
@Ignore
@Test
public void testCollectionSheetRetrieveOnlyReturnsActiveAndInactiveSavingsAccounts() throws Exception {
UserContext userContext = TestUtils.makeUser();
collectionSheetRetrieveSavingsAccountsUtils.createSampleCenterHierarchy();
SavingsBO centerSavingsAccount = (SavingsBO) legacyAccountDao.getAccount(collectionSheetRetrieveSavingsAccountsUtils.getCenterSavingsAccount().getAccountId());
centerSavingsAccount.setUserContext(userContext);
PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
centerSavingsAccount.changeStatus(AccountState.SAVINGS_INACTIVE, Short.valueOf("1"), "Make Center Savings Account Inactive", loggedInUser);
SavingsBO clientSavings = (SavingsBO) legacyAccountDao.getAccount(collectionSheetRetrieveSavingsAccountsUtils.getClientOfGroupCompleteGroupSavingsAccount().getAccountId());
AccountPaymentEntity payment = new AccountPaymentEntity(clientSavings, new Money(clientSavings.getCurrency()), null, null, new PaymentTypeEntity(Short.valueOf("1")), new Date());
AccountNotesEntity notes = new AccountNotesEntity(new java.sql.Date(System.currentTimeMillis()), "close client savings account", TestObjectFactory.getPersonnel(userContext.getId()), clientSavings);
clientSavings.setUserContext(userContext);
clientSavings.closeAccount(payment, notes, clientSavings.getCustomer(), loggedInUser);
IntegrationTestObjectMother.saveSavingsAccount(clientSavings);
StaticHibernateUtil.flushSession();
CollectionSheetDto collectionSheet = collectionSheetService.retrieveCollectionSheet(collectionSheetRetrieveSavingsAccountsUtils.getCenter().getCustomerId(), new LocalDate());
List<CollectionSheetCustomerDto> customers = collectionSheet.getCollectionSheetCustomer();
for (CollectionSheetCustomerDto customer : customers) {
for (CollectionSheetCustomerSavingDto customerSaving : customer.getCollectionSheetCustomerSaving()) {
Boolean accountIsActiveOrInactive = false;
AccountBO accountBO = legacyAccountDao.getAccount(customerSaving.getAccountId());
if ((accountBO.getState().equals(AccountState.SAVINGS_ACTIVE)) || (accountBO.getState().equals(AccountState.SAVINGS_INACTIVE))) {
accountIsActiveOrInactive = true;
}
Assert.assertTrue("Found Account State: " + accountBO.getState().toString() + " - Only Active and Inactive Savings Accounts are Allowed", accountIsActiveOrInactive);
}
}
}
use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.
the class SaveCollectionSheetStructureValidatorIntegrationTest method ignore_testShouldGetINVALID_SAVINGS_ACCOUNT_STATUSIfSavingsAccountClosed.
public void ignore_testShouldGetINVALID_SAVINGS_ACCOUNT_STATUSIfSavingsAccountClosed() throws Exception {
LocalDate transactionDate = new LocalDate();
// create a center hierarchy with savings accounts
collectionSheetRetrieveSavingsAccountsUtils.createSampleCenterHierarchy();
// retrieve the collection sheet for today
CollectionSheetService collectionSheetService = ApplicationContextProvider.getBean(CollectionSheetService.class);
CollectionSheetDto collectionSheet = collectionSheetService.retrieveCollectionSheet(collectionSheetRetrieveSavingsAccountsUtils.getCenter().getCustomerId(), transactionDate);
// assemble dto for saving collection sheet
SaveCollectionSheetDto saveCollectionSheet = saveCollectionSheetUtils.assembleSaveCollectionSheetDto(collectionSheet, transactionDate);
// close a savings account that is about to be saved
UserContext userContext = TestUtils.makeUser();
SavingsBO clientSavings = (SavingsBO) legacyAccountDao.getAccount(collectionSheetRetrieveSavingsAccountsUtils.getClientOfGroupCompleteGroupSavingsAccount().getAccountId());
AccountPaymentEntity payment = new AccountPaymentEntity(clientSavings, new Money(clientSavings.getCurrency()), null, null, new PaymentTypeEntity(Short.valueOf("1")), new Date());
AccountNotesEntity notes = new AccountNotesEntity(new java.sql.Date(System.currentTimeMillis()), "close client savings account", TestObjectFactory.getPersonnel(userContext.getId()), clientSavings);
clientSavings.setUserContext(userContext);
// clientSavings.closeAccount(payment, notes, clientSavings.getCustomer());
StaticHibernateUtil.flushSession();
// Save collection sheet and test for errors returned
verifyInvalidReason(saveCollectionSheet, InvalidSaveCollectionSheetReason.INVALID_SAVINGS_ACCOUNT_STATUS);
}
use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.
the class CustomerPersistenceIntegrationTest method testRetrieveSavingsAccountForCustomer.
@Test
public void testRetrieveSavingsAccountForCustomer() throws Exception {
java.util.Date currentDate = new java.util.Date();
CustomerPersistence customerPersistence = new CustomerPersistence();
center = createCenter();
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center);
savingsOffering = TestObjectFactory.createSavingsProduct("SavingPrd1", "S", currentDate, RecommendedAmountUnit.COMPLETE_GROUP);
UserContext user = new UserContext();
user.setId(PersonnelConstants.SYSTEM_USER);
account = TestObjectFactory.createSavingsAccount("000100000000020", group, AccountState.SAVINGS_ACTIVE, currentDate, savingsOffering, user);
List<SavingsBO> savingsList = customerPersistence.retrieveSavingsAccountForCustomer(group.getCustomerId());
Assert.assertEquals(1, savingsList.size());
account = savingsList.get(0);
group = account.getCustomer();
center = group.getParentCustomer();
}
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));
}
}
Aggregations