Search in sources :

Example 56 with PersonnelBO

use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.

the class AccountBOIntegrationTest method testUpdatePerformanceHistoryOnAdjustment.

@Test
public void testUpdatePerformanceHistoryOnAdjustment() throws Exception {
    Date currentDate = new Date(System.currentTimeMillis());
    List<AccountActionDateEntity> accntActionDates = new ArrayList<AccountActionDateEntity>();
    PaymentData paymentData1 = TestObjectFactory.getLoanAccountPaymentData(accntActionDates, TestUtils.createMoney(212), null, groupLoan.getPersonnel(), "receiptNum", Short.valueOf("1"), currentDate, currentDate);
    IntegrationTestObjectMother.applyAccountPayment(groupLoan, paymentData1);
    IntegrationTestObjectMother.saveLoanAccount(groupLoan);
    LoanBO loan = IntegrationTestObjectMother.findLoanBySystemId(groupLoan.getGlobalAccountNum());
    PaymentData paymentData2 = TestObjectFactory.getLoanAccountPaymentData(null, TestUtils.createMoney(600), null, loan.getPersonnel(), "receiptNum", Short.valueOf("1"), currentDate, currentDate);
    IntegrationTestObjectMother.applyAccountPayment(loan, paymentData2);
    IntegrationTestObjectMother.saveLoanAccount(groupLoan);
    groupLoan = IntegrationTestObjectMother.findLoanBySystemId(groupLoan.getGlobalAccountNum());
    groupLoan.setUserContext(TestUtils.makeUser());
    PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
    groupLoan.adjustPmnt("loan account has been adjusted by test code", loggedInUser);
    IntegrationTestObjectMother.saveLoanAccount(groupLoan);
}
Also used : PaymentData(org.mifos.accounts.util.helpers.PaymentData) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList) Date(java.sql.Date) Test(org.junit.Test)

Example 57 with PersonnelBO

use of org.mifos.customers.personnel.business.PersonnelBO 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 58 with PersonnelBO

use of org.mifos.customers.personnel.business.PersonnelBO 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 59 with PersonnelBO

use of org.mifos.customers.personnel.business.PersonnelBO 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 60 with PersonnelBO

use of org.mifos.customers.personnel.business.PersonnelBO 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)

Aggregations

PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)239 Test (org.junit.Test)91 UserContext (org.mifos.security.util.UserContext)65 ArrayList (java.util.ArrayList)62 Money (org.mifos.framework.util.helpers.Money)46 MifosRuntimeException (org.mifos.core.MifosRuntimeException)44 OfficeBO (org.mifos.customers.office.business.OfficeBO)44 MifosUser (org.mifos.security.MifosUser)44 PersistenceException (org.mifos.framework.exceptions.PersistenceException)41 Date (java.util.Date)39 LocalDate (org.joda.time.LocalDate)37 AccountException (org.mifos.accounts.exceptions.AccountException)37 DateTime (org.joda.time.DateTime)36 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)34 BusinessRuleException (org.mifos.service.BusinessRuleException)33 PersonnelBuilder (org.mifos.domain.builders.PersonnelBuilder)31 MeetingBO (org.mifos.application.meeting.business.MeetingBO)30 CustomerBO (org.mifos.customers.business.CustomerBO)27 ServiceException (org.mifos.framework.exceptions.ServiceException)27 LoanBO (org.mifos.accounts.loan.business.LoanBO)25