Search in sources :

Example 1 with AccountNotesEntityBuilder

use of org.mifos.accounts.business.AccountNotesEntityBuilder in project head by mifos.

the class SavingsCloseTest method whenClosingAccountShouldWithdrawRemainingBalanceOnAccount.

@Test
public void whenClosingAccountShouldWithdrawRemainingBalanceOnAccount() {
    Money remainingBalance = TestUtils.createMoney("100");
    savingsAccount = new SavingsAccountBuilder().active().withSavingsProduct(savingsProduct).withCustomer(client).withBalanceOf(remainingBalance).build();
    AccountPaymentEntity payment = new AccountPaymentEntityBuilder().with(savingsAccount).with(remainingBalance).build();
    AccountNotesEntity notes = new AccountNotesEntityBuilder().build();
    CustomerBO customer = new ClientBuilder().buildForUnitTests();
    PersonnelBO loggedInUser = new PersonnelBuilder().build();
    // pre verification
    assertTrue(savingsAccount.getAccountPayments().isEmpty());
    // exercise test
    savingsAccount.closeAccount(payment, notes, customer, loggedInUser);
    // verification
    assertFalse(savingsAccount.getAccountPayments().isEmpty());
    AccountPaymentEntity withdrawalPayment = savingsAccount.getAccountPayments().get(0);
    assertThat(withdrawalPayment.getAmount(), is(TestUtils.createMoney("100")));
}
Also used : PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) Money(org.mifos.framework.util.helpers.Money) AccountNotesEntityBuilder(org.mifos.accounts.business.AccountNotesEntityBuilder) AccountPaymentEntityBuilder(org.mifos.accounts.business.AccountPaymentEntityBuilder) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) AccountNotesEntity(org.mifos.accounts.business.AccountNotesEntity) CustomerBO(org.mifos.customers.business.CustomerBO) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Example 2 with AccountNotesEntityBuilder

use of org.mifos.accounts.business.AccountNotesEntityBuilder in project head by mifos.

the class SavingsCloseTest method whenClosingAccountShouldSetClosedDate.

@Test
public void whenClosingAccountShouldSetClosedDate() {
    Money remainingBalance = TestUtils.createMoney("100");
    savingsAccount = new SavingsAccountBuilder().active().withSavingsProduct(savingsProduct).withCustomer(client).withBalanceOf(remainingBalance).build();
    AccountPaymentEntity payment = new AccountPaymentEntityBuilder().with(savingsAccount).with(remainingBalance).build();
    AccountNotesEntity notes = new AccountNotesEntityBuilder().build();
    CustomerBO customer = new ClientBuilder().buildForUnitTests();
    PersonnelBO loggedInUser = new PersonnelBuilder().build();
    // exercise test
    savingsAccount.closeAccount(payment, notes, customer, loggedInUser);
    // verification
    assertThat(new LocalDate(savingsAccount.getClosedDate()), is(new LocalDate()));
}
Also used : PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) Money(org.mifos.framework.util.helpers.Money) AccountNotesEntityBuilder(org.mifos.accounts.business.AccountNotesEntityBuilder) AccountPaymentEntityBuilder(org.mifos.accounts.business.AccountPaymentEntityBuilder) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) AccountNotesEntity(org.mifos.accounts.business.AccountNotesEntity) CustomerBO(org.mifos.customers.business.CustomerBO) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) LocalDate(org.joda.time.LocalDate) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Example 3 with AccountNotesEntityBuilder

use of org.mifos.accounts.business.AccountNotesEntityBuilder in project head by mifos.

the class SavingsCloseTest method whenClosingAccountShouldPostInterestWhenRemainingSavingsBalanceIsLessThanAmountBeingWithdrawn.

@Test
public void whenClosingAccountShouldPostInterestWhenRemainingSavingsBalanceIsLessThanAmountBeingWithdrawn() {
    Money remainingBalance = TestUtils.createMoney("100");
    savingsAccount = new SavingsAccountBuilder().active().withSavingsProduct(savingsProduct).withCustomer(client).withBalanceOf(remainingBalance).build();
    Money withdrawalAtCloseAmount = TestUtils.createMoney("105.56");
    AccountPaymentEntity payment = new AccountPaymentEntityBuilder().with(savingsAccount).with(withdrawalAtCloseAmount).build();
    AccountNotesEntity notes = new AccountNotesEntityBuilder().build();
    CustomerBO customer = new ClientBuilder().buildForUnitTests();
    PersonnelBO loggedInUser = new PersonnelBuilder().build();
    // pre verification
    assertTrue(savingsAccount.getAccountPayments().isEmpty());
    // exercise test
    savingsAccount.closeAccount(payment, notes, customer, loggedInUser);
    // verification
    assertFalse(savingsAccount.getAccountPayments().isEmpty());
    assertThat(savingsAccount.getAccountPayments().size(), is(2));
    AccountPaymentEntity interestPayment = savingsAccount.getAccountPayments().get(0);
    assertThat(interestPayment.getAmount(), is(TestUtils.createMoney("5.56")));
    AccountPaymentEntity withdrawalPayment = savingsAccount.getAccountPayments().get(1);
    assertThat(withdrawalPayment.getAmount(), is(TestUtils.createMoney("105.56")));
}
Also used : PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) Money(org.mifos.framework.util.helpers.Money) AccountNotesEntityBuilder(org.mifos.accounts.business.AccountNotesEntityBuilder) AccountPaymentEntityBuilder(org.mifos.accounts.business.AccountPaymentEntityBuilder) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) AccountNotesEntity(org.mifos.accounts.business.AccountNotesEntity) CustomerBO(org.mifos.customers.business.CustomerBO) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Example 4 with AccountNotesEntityBuilder

use of org.mifos.accounts.business.AccountNotesEntityBuilder in project head by mifos.

the class SavingsCloseTest method whenClosingAccountShouldCreateStatusChangeHistoryForClosure.

@Test
public void whenClosingAccountShouldCreateStatusChangeHistoryForClosure() {
    Money remainingBalance = TestUtils.createMoney("100");
    savingsAccount = new SavingsAccountBuilder().active().withSavingsProduct(savingsProduct).withCustomer(client).withBalanceOf(remainingBalance).build();
    AccountPaymentEntity payment = new AccountPaymentEntityBuilder().with(savingsAccount).with(remainingBalance).build();
    AccountNotesEntity notes = new AccountNotesEntityBuilder().build();
    CustomerBO customer = new ClientBuilder().buildForUnitTests();
    PersonnelBO loggedInUser = new PersonnelBuilder().build();
    // pre verification
    assertThat(savingsAccount.getAccountStatusChangeHistory().size(), is(1));
    // exercise test
    savingsAccount.closeAccount(payment, notes, customer, loggedInUser);
    // verification
    assertThat(savingsAccount.getAccountStatusChangeHistory().size(), is(2));
    AccountStatusChangeHistoryEntity closure = savingsAccount.getAccountStatusChangeHistory().get(1);
    assertThat(closure.getAccount(), is((AccountBO) savingsAccount));
    assertTrue(closure.getOldStatus().isInState(AccountState.SAVINGS_ACTIVE));
    assertTrue(closure.getNewStatus().isInState(AccountState.SAVINGS_CLOSED));
}
Also used : PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) Money(org.mifos.framework.util.helpers.Money) AccountBO(org.mifos.accounts.business.AccountBO) AccountNotesEntityBuilder(org.mifos.accounts.business.AccountNotesEntityBuilder) AccountPaymentEntityBuilder(org.mifos.accounts.business.AccountPaymentEntityBuilder) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) AccountNotesEntity(org.mifos.accounts.business.AccountNotesEntity) CustomerBO(org.mifos.customers.business.CustomerBO) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) AccountStatusChangeHistoryEntity(org.mifos.accounts.business.AccountStatusChangeHistoryEntity) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Example 5 with AccountNotesEntityBuilder

use of org.mifos.accounts.business.AccountNotesEntityBuilder in project head by mifos.

the class SavingsCloseTest method whenClosingAccountShouldSetStatusAsClosed.

@Test
public void whenClosingAccountShouldSetStatusAsClosed() {
    Money remainingBalance = TestUtils.createMoney("100");
    savingsAccount = new SavingsAccountBuilder().active().withSavingsProduct(savingsProduct).withCustomer(client).withBalanceOf(remainingBalance).build();
    AccountPaymentEntity payment = new AccountPaymentEntityBuilder().with(savingsAccount).with(remainingBalance).build();
    AccountNotesEntity notes = new AccountNotesEntityBuilder().build();
    CustomerBO customer = new ClientBuilder().buildForUnitTests();
    PersonnelBO loggedInUser = new PersonnelBuilder().build();
    // exercise test
    savingsAccount.closeAccount(payment, notes, customer, loggedInUser);
    // verification
    assertTrue(savingsAccount.getAccountState().isInState(AccountState.SAVINGS_CLOSED));
}
Also used : PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) Money(org.mifos.framework.util.helpers.Money) AccountNotesEntityBuilder(org.mifos.accounts.business.AccountNotesEntityBuilder) AccountPaymentEntityBuilder(org.mifos.accounts.business.AccountPaymentEntityBuilder) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) AccountNotesEntity(org.mifos.accounts.business.AccountNotesEntity) CustomerBO(org.mifos.customers.business.CustomerBO) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 AccountNotesEntity (org.mifos.accounts.business.AccountNotesEntity)5 AccountNotesEntityBuilder (org.mifos.accounts.business.AccountNotesEntityBuilder)5 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)5 AccountPaymentEntityBuilder (org.mifos.accounts.business.AccountPaymentEntityBuilder)5 CustomerBO (org.mifos.customers.business.CustomerBO)5 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)5 ClientBuilder (org.mifos.domain.builders.ClientBuilder)5 PersonnelBuilder (org.mifos.domain.builders.PersonnelBuilder)5 SavingsAccountBuilder (org.mifos.domain.builders.SavingsAccountBuilder)5 Money (org.mifos.framework.util.helpers.Money)5 LocalDate (org.joda.time.LocalDate)1 AccountBO (org.mifos.accounts.business.AccountBO)1 AccountStatusChangeHistoryEntity (org.mifos.accounts.business.AccountStatusChangeHistoryEntity)1