Search in sources :

Example 26 with PersonnelBO

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

the class SavingsBOMoreIntegrationTest method changingSavingsAccountToInactiveRemovesRecommendedAmountsFromFutureInstallments.

@Test
public void changingSavingsAccountToInactiveRemovesRecommendedAmountsFromFutureInstallments() throws Exception {
    assertAllFutureSchedulesAreAsExpected(savings, recommendedAmount);
    //
    PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
    savings.changeStatus(AccountState.SAVINGS_INACTIVE, null, "Make Inactive", loggedInUser);
    savings.save();
    StaticHibernateUtil.flushSession();
    // refresh hibernate data
    savings = (SavingsBO) legacyAccountDao.getAccount(savings.getAccountId());
    Money zero = new Money(Money.getDefaultCurrency());
    assertAllFutureSchedulesAreAsExpected(savings, zero);
}
Also used : Money(org.mifos.framework.util.helpers.Money) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) Test(org.junit.Test)

Example 27 with PersonnelBO

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

the class SavingsBOMoreIntegrationTest method changingSavingsAccountFromInactiveToActiveResetsRecommendedAmountsFromFutureInstallments.

@Test
public void changingSavingsAccountFromInactiveToActiveResetsRecommendedAmountsFromFutureInstallments() throws Exception {
    //make inactive first
    PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
    savings.changeStatus(AccountState.SAVINGS_INACTIVE, null, "Make Inactive", loggedInUser);
    savings.save();
    StaticHibernateUtil.flushSession();
    // refresh hibernate data
    savings = (SavingsBO) legacyAccountDao.getAccount(savings.getAccountId());
    Money zero = new Money(Money.getDefaultCurrency());
    assertAllFutureSchedulesAreAsExpected(savings, zero);
    //make active again
    savings.changeStatus(AccountState.SAVINGS_ACTIVE, null, "Make Active Again", loggedInUser);
    savings.save();
    StaticHibernateUtil.flushSession();
    // refresh hibernate data
    savings = (SavingsBO) legacyAccountDao.getAccount(savings.getAccountId());
    assertAllFutureSchedulesAreAsExpected(savings, recommendedAmount);
}
Also used : Money(org.mifos.framework.util.helpers.Money) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) Test(org.junit.Test)

Example 28 with PersonnelBO

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

the class SavingsPersistenceIntegrationTest method testRetrieveLastTransaction.

@Test
public void testRetrieveLastTransaction() throws Exception {
    try {
        SavingsTestHelper helper = new SavingsTestHelper();
        createInitialObjects();
        PersonnelBO createdBy = legacyPersonnelDao.getPersonnel(userContext.getId());
        savingsOffering = helper.createSavingsOffering("effwe", "231");
        savings = new SavingsBO(userContext, savingsOffering, group, AccountState.SAVINGS_ACTIVE, savingsOffering.getRecommendedAmount(), null);
        AccountPaymentEntity payment = helper.createAccountPaymentToPersist(savings, new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "700.0"), new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "1700.0"), helper.getDate("15/01/2006"), AccountActionTypes.SAVINGS_DEPOSIT.getValue(), savings, createdBy, group);
        AccountTestUtils.addAccountPayment(payment, savings);
        savings.save();
        StaticHibernateUtil.flushSession();
        payment = helper.createAccountPaymentToPersist(savings, new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "1000.0"), new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "2700.0"), helper.getDate("20/02/2006"), AccountActionTypes.SAVINGS_DEPOSIT.getValue(), savings, createdBy, group);
        AccountTestUtils.addAccountPayment(payment, savings);
        savings.update();
        StaticHibernateUtil.flushSession();
        savings = savingsDao.findById(savings.getAccountId());
        savings.setUserContext(userContext);
        payment = helper.createAccountPaymentToPersist(savings, new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "500.0"), new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "2200.0"), helper.getDate("10/03/2006"), AccountActionTypes.SAVINGS_WITHDRAWAL.getValue(), savings, createdBy, group);
        AccountTestUtils.addAccountPayment(payment, savings);
        savings.update();
        StaticHibernateUtil.flushSession();
        savings = savingsDao.findById(savings.getAccountId());
        savings.setUserContext(userContext);
        payment = helper.createAccountPaymentToPersist(savings, new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "1200.0"), new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "3400.0"), helper.getDate("15/03/2006"), AccountActionTypes.SAVINGS_DEPOSIT.getValue(), savings, createdBy, group);
        AccountTestUtils.addAccountPayment(payment, savings);
        savings.update();
        StaticHibernateUtil.flushSession();
        savings = savingsDao.findById(savings.getAccountId());
        savings.setUserContext(userContext);
        payment = helper.createAccountPaymentToPersist(savings, new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "2500.0"), new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "900.0"), helper.getDate("25/03/2006"), AccountActionTypes.SAVINGS_WITHDRAWAL.getValue(), savings, createdBy, group);
        AccountTestUtils.addAccountPayment(payment, savings);
        savings.update();
        StaticHibernateUtil.flushSession();
        savings = savingsDao.findById(savings.getAccountId());
        savings.setUserContext(userContext);
        SavingsTrxnDetailEntity trxn = savingsPersistence.retrieveLastTransaction(savings.getAccountId(), helper.getDate("12/03/2006"));
        Assert.assertEquals(TestUtils.createMoney("500"), trxn.getAmount());
        group = savings.getCustomer();
        center = group.getParentCustomer();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) SavingsTrxnDetailEntity(org.mifos.accounts.savings.business.SavingsTrxnDetailEntity) SavingsTestHelper(org.mifos.accounts.savings.util.helpers.SavingsTestHelper) PersistenceException(org.mifos.framework.exceptions.PersistenceException) Test(org.junit.Test)

Example 29 with PersonnelBO

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

the class SavingsPostInterestTest method whenPostingInterestASingleAccountPaymentIsMade.

@Test
public void whenPostingInterestASingleAccountPaymentIsMade() {
    // setup
    InterestScheduledEvent postingSchedule = new MonthlyOnLastDayOfMonthInterestScheduledEvent(1);
    Money interestToBePosted = TestUtils.createMoney("100");
    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
    assertTrue(savingsAccount.getAccountPayments().isEmpty());
    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
    assertFalse(savingsAccount.getAccountPayments().isEmpty());
    AccountPaymentEntity interestPostingPayment = savingsAccount.getAccountPayments().get(0);
    assertThat(interestPostingPayment.getAccount(), is((AccountBO) savingsAccount));
    assertThat(interestPostingPayment.getAmount(), is(interestToBePosted));
    assertThat(interestPostingPayment.getPaymentType().getId(), is(SavingsConstants.DEFAULT_PAYMENT_TYPE));
    assertThat(new LocalDate(interestPostingPayment.getPaymentDate()), 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) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Money(org.mifos.framework.util.helpers.Money) 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) Test(org.junit.Test)

Example 30 with PersonnelBO

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

the class SavingsPostInterestTest method whenPostingInterestNextInterestPostingDateIsPopulatedWithNextPostingDate.

@Test
public void whenPostingInterestNextInterestPostingDateIsPopulatedWithNextPostingDate() {
    // 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
    assertThat(new LocalDate(savingsAccount.getNextIntPostDate()), is(endOfMonthAfter(nextInterestPostingDate)));
}
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) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) 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