Search in sources :

Example 16 with PersonnelBuilder

use of org.mifos.domain.builders.PersonnelBuilder in project head by mifos.

the class GroupValidationTest method givenReceivingCenterIsNullShouldFailValidation.

@Test
public void givenReceivingCenterIsNullShouldFailValidation() {
    PersonnelBO formedBy = new PersonnelBuilder().build();
    group = new GroupBuilder().withName("group-On-center").withParentCustomer(center).formedBy(formedBy).build();
    CenterBO toCenter = null;
    try {
        group.validateReceivingCenter(toCenter);
        fail("givenReceivingCenterIsNullShouldThrowCustomerException");
    } catch (CustomerException e) {
        assertThat(e.getKey(), is(CustomerConstants.INVALID_PARENT));
    }
}
Also used : PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) CustomerException(org.mifos.customers.exceptions.CustomerException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) CenterBO(org.mifos.customers.center.business.CenterBO) Test(org.junit.Test)

Example 17 with PersonnelBuilder

use of org.mifos.domain.builders.PersonnelBuilder in project head by mifos.

the class PersonnelDaoHibernateIntegrationTest method shouldFindAppUserWithNoRolesByUsername.

@Test
public void shouldFindAppUserWithNoRolesByUsername() {
    OfficeBO office = IntegrationTestObjectMother.sampleBranchOffice();
    PersonnelBO userWithNoRoles = new PersonnelBuilder().withUsername("noRoles").asLoanOfficer().with(office).build();
    IntegrationTestObjectMother.createPersonnel(userWithNoRoles);
    // exercise test
    MifosUser user = personnelDao.findAuthenticatedUserByUsername("noRoles");
    // verification
    assertNotNull(user);
}
Also used : PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) MifosUser(org.mifos.security.MifosUser) Test(org.junit.Test)

Example 18 with PersonnelBuilder

use of org.mifos.domain.builders.PersonnelBuilder in project head by mifos.

the class SavingsPostInterestTest method whenPostingInterestASavingsAcitvityIsAddedWithCorrectDetails.

@Test
public void whenPostingInterestASavingsAcitvityIsAddedWithCorrectDetails() {
    // setup
    InterestScheduledEvent postingSchedule = new MonthlyOnLastDayOfMonthInterestScheduledEvent(1);
    DateTime activationDate = new DateTime().withDate(2010, 7, 20);
    DateTime nextInterestPostingDate = new DateTime().withDate(2010, 7, 31);
    savingsAccount = new SavingsAccountBuilder().active().withActivationDate(activationDate).withNextInterestPostingDateOf(nextInterestPostingDate).withSavingsProduct(savingsProduct).withCustomer(client).build();
    // pre verification
    assertThat(new LocalDate(savingsAccount.getNextIntPostDate()), is(nextInterestPostingDate.toLocalDate()));
    InterestCalculationPeriodResult calculationPeriod = new InterestCalculationPeriodResultBuilder().withCalculatedInterest("100").build();
    InterestPostingPeriodResult interestPostingPeriodResult = new InterestPostingPeriodResultBuilder().from(nextInterestPostingDate.toLocalDate()).to(nextInterestPostingDate.toLocalDate()).with(calculationPeriod).build();
    PersonnelBO createdBy = new PersonnelBuilder().build();
    // exercise
    savingsAccount.postInterest(postingSchedule, interestPostingPeriodResult, createdBy);
    // verification
    List<SavingsActivityEntity> savingsActivityityDetails = new ArrayList<SavingsActivityEntity>(savingsAccount.getSavingsActivityDetails());
    SavingsActivityEntity interestPostingActivity = savingsActivityityDetails.get(0);
    assertThat(interestPostingActivity.getAccount(), is((AccountBO) savingsAccount));
    assertThat(interestPostingActivity.getActivity().getId(), is(AccountActionTypes.SAVINGS_INTEREST_POSTING.getValue()));
    assertThat(interestPostingActivity.getAmount(), is(TestUtils.createMoney("100")));
    assertThat(datePartOf(interestPostingActivity.getTrxnCreatedDate()), is(nextInterestPostingDate.toLocalDate()));
}
Also used : InterestPostingPeriodResult(org.mifos.accounts.savings.interest.InterestPostingPeriodResult) PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) InterestCalculationPeriodResult(org.mifos.accounts.savings.interest.InterestCalculationPeriodResult) InterestPostingPeriodResultBuilder(org.mifos.accounts.savings.interest.InterestPostingPeriodResultBuilder) ArrayList(java.util.ArrayList) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) AccountBO(org.mifos.accounts.business.AccountBO) MonthlyOnLastDayOfMonthInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent) MonthlyOnLastDayOfMonthInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent) InterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) InterestCalculationPeriodResultBuilder(org.mifos.accounts.savings.interest.InterestCalculationPeriodResultBuilder) SavingsActivityEntity(org.mifos.accounts.savings.business.SavingsActivityEntity) Test(org.junit.Test)

Example 19 with PersonnelBuilder

use of org.mifos.domain.builders.PersonnelBuilder in project head by mifos.

the class SavingsPostInterestTest method whenPostingInterestSavingsAccountBalanceIsUpdatedWithAmountToBePosted.

@Test
public void whenPostingInterestSavingsAccountBalanceIsUpdatedWithAmountToBePosted() {
    // setup
    InterestScheduledEvent postingSchedule = new MonthlyOnLastDayOfMonthInterestScheduledEvent(1);
    DateTime activationDate = new DateTime().withDate(2010, 7, 20);
    savingsAccount = new SavingsAccountBuilder().active().withActivationDate(activationDate).withSavingsProduct(savingsProduct).withCustomer(client).build();
    // pre verification
    assertThat(savingsAccount.getSavingsBalance(), is(TestUtils.createMoney("0")));
    InterestCalculationPeriodResult calculationPeriod = new InterestCalculationPeriodResultBuilder().withCalculatedInterest("100").build();
    InterestPostingPeriodResult interestPostingPeriodResult = new InterestPostingPeriodResultBuilder().with(calculationPeriod).build();
    PersonnelBO createdBy = new PersonnelBuilder().build();
    // exercise
    savingsAccount.postInterest(postingSchedule, interestPostingPeriodResult, createdBy);
    // verification
    assertThat(savingsAccount.getSavingsBalance(), is(TestUtils.createMoney("100")));
}
Also used : InterestPostingPeriodResult(org.mifos.accounts.savings.interest.InterestPostingPeriodResult) PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) MonthlyOnLastDayOfMonthInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent) InterestCalculationPeriodResult(org.mifos.accounts.savings.interest.InterestCalculationPeriodResult) MonthlyOnLastDayOfMonthInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent) InterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) InterestPostingPeriodResultBuilder(org.mifos.accounts.savings.interest.InterestPostingPeriodResultBuilder) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) InterestCalculationPeriodResultBuilder(org.mifos.accounts.savings.interest.InterestCalculationPeriodResultBuilder) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 20 with PersonnelBuilder

use of org.mifos.domain.builders.PersonnelBuilder 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

PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)31 PersonnelBuilder (org.mifos.domain.builders.PersonnelBuilder)31 Test (org.junit.Test)27 SavingsAccountBuilder (org.mifos.domain.builders.SavingsAccountBuilder)18 Money (org.mifos.framework.util.helpers.Money)12 DateTime (org.joda.time.DateTime)10 InterestCalculationPeriodResult (org.mifos.accounts.savings.interest.InterestCalculationPeriodResult)8 InterestCalculationPeriodResultBuilder (org.mifos.accounts.savings.interest.InterestCalculationPeriodResultBuilder)8 InterestPostingPeriodResult (org.mifos.accounts.savings.interest.InterestPostingPeriodResult)8 InterestPostingPeriodResultBuilder (org.mifos.accounts.savings.interest.InterestPostingPeriodResultBuilder)8 InterestScheduledEvent (org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent)8 MonthlyOnLastDayOfMonthInterestScheduledEvent (org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent)8 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)7 OfficeBO (org.mifos.customers.office.business.OfficeBO)7 OfficeBuilder (org.mifos.domain.builders.OfficeBuilder)7 LocalDate (org.joda.time.LocalDate)6 GroupBuilder (org.mifos.domain.builders.GroupBuilder)6 ArrayList (java.util.ArrayList)5 AccountNotesEntity (org.mifos.accounts.business.AccountNotesEntity)5 AccountNotesEntityBuilder (org.mifos.accounts.business.AccountNotesEntityBuilder)5