Search in sources :

Example 1 with SavingsActivityEntity

use of org.mifos.accounts.savings.business.SavingsActivityEntity in project head by mifos.

the class SavingsPostInterestTest method whenPostingInterestASavingsAcitvityIsAddedForInterestPostingEvent.

@Test
public void whenPostingInterestASavingsAcitvityIsAddedForInterestPostingEvent() {
    // 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
    List<SavingsActivityEntity> preSavingsActivityityDetails = new ArrayList<SavingsActivityEntity>(savingsAccount.getSavingsActivityDetails());
    assertThat(preSavingsActivityityDetails.size(), is(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
    List<SavingsActivityEntity> savingsActivityityDetails = new ArrayList<SavingsActivityEntity>(savingsAccount.getSavingsActivityDetails());
    assertThat(savingsActivityityDetails.size(), is(1));
}
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) DateTime(org.joda.time.DateTime) 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) SavingsActivityEntity(org.mifos.accounts.savings.business.SavingsActivityEntity) InterestCalculationPeriodResultBuilder(org.mifos.accounts.savings.interest.InterestCalculationPeriodResultBuilder) Test(org.junit.Test)

Example 2 with SavingsActivityEntity

use of org.mifos.accounts.savings.business.SavingsActivityEntity in project head by mifos.

the class SavingsDaoHibernate method prepareForInterestRecalculation.

@Override
public void prepareForInterestRecalculation(SavingsBO savingsAccount, Date fromDate) {
    List<AccountPaymentEntity> paymentsForRemoval = savingsAccount.getInterestPostingPaymentsForRemoval(fromDate);
    this.save(savingsAccount);
    for (AccountPaymentEntity payment : paymentsForRemoval) {
        this.baseDao.delete(payment);
    }
    List<SavingsActivityEntity> activitesForRemoval = savingsAccount.getInterestPostingActivitesForRemoval(fromDate);
    for (SavingsActivityEntity activity : activitesForRemoval) {
        this.baseDao.delete(activity);
    }
}
Also used : AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) SavingsActivityEntity(org.mifos.accounts.savings.business.SavingsActivityEntity)

Example 3 with SavingsActivityEntity

use of org.mifos.accounts.savings.business.SavingsActivityEntity 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 4 with SavingsActivityEntity

use of org.mifos.accounts.savings.business.SavingsActivityEntity in project head by mifos.

the class SavingsAdjustmentTest method accountActivitysRecordAdjustmentOfLastTransactionWithAReversalAndWithdrawalTransactions.

@Test
public void accountActivitysRecordAdjustmentOfLastTransactionWithAReversalAndWithdrawalTransactions() {
    savingsAccount = new SavingsAccountBuilder().active().withSavingsProduct(savingsProduct).withCustomer(client).withBalanceOf(TestUtils.createMoney("100")).withWithdrawalOf("15").build();
    Money amountAdjustedTo = TestUtils.createMoney("25");
    String adjustmentNote = "testAdjustment";
    PersonnelBO updatedBy = new PersonnelBuilder().build();
    // pre verification
    List<SavingsActivityEntity> activitysBefore = new ArrayList<SavingsActivityEntity>(savingsAccount.getSavingsActivityDetails());
    assertThat(activitysBefore.size(), is(1));
    // exercise test
    savingsAccount.adjustLastUserAction(amountAdjustedTo, adjustmentNote, updatedBy);
    // verification
    List<SavingsActivityEntity> activitysAfter = new ArrayList<SavingsActivityEntity>(savingsAccount.getSavingsActivityDetails());
    assertThat(activitysAfter.size(), is(3));
}
Also used : PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) Money(org.mifos.framework.util.helpers.Money) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ArrayList(java.util.ArrayList) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) SavingsActivityEntity(org.mifos.accounts.savings.business.SavingsActivityEntity) Test(org.junit.Test)

Example 5 with SavingsActivityEntity

use of org.mifos.accounts.savings.business.SavingsActivityEntity in project head by mifos.

the class SavingsAdjustmentTest method accountActivitysRecordAdjustmentOfLastTransactionWithAReversalAndDepositTransactions.

@Test
public void accountActivitysRecordAdjustmentOfLastTransactionWithAReversalAndDepositTransactions() {
    savingsAccount = new SavingsAccountBuilder().active().withSavingsProduct(savingsProduct).withCustomer(client).withBalanceOf(TestUtils.createMoney("0")).withDepositOf("15").build();
    Money amountAdjustedTo = TestUtils.createMoney("25");
    String adjustmentNote = "testAdjustment";
    PersonnelBO updatedBy = new PersonnelBuilder().build();
    // pre verification
    List<SavingsActivityEntity> activitysBefore = new ArrayList<SavingsActivityEntity>(savingsAccount.getSavingsActivityDetails());
    assertThat(activitysBefore.size(), is(1));
    // exercise test
    savingsAccount.adjustLastUserAction(amountAdjustedTo, adjustmentNote, updatedBy);
    // verification
    List<SavingsActivityEntity> activitysAfter = new ArrayList<SavingsActivityEntity>(savingsAccount.getSavingsActivityDetails());
    assertThat(activitysAfter.size(), is(3));
}
Also used : PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) Money(org.mifos.framework.util.helpers.Money) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ArrayList(java.util.ArrayList) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) SavingsActivityEntity(org.mifos.accounts.savings.business.SavingsActivityEntity) Test(org.junit.Test)

Aggregations

SavingsActivityEntity (org.mifos.accounts.savings.business.SavingsActivityEntity)6 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)4 PersonnelBuilder (org.mifos.domain.builders.PersonnelBuilder)4 SavingsAccountBuilder (org.mifos.domain.builders.SavingsAccountBuilder)4 Money (org.mifos.framework.util.helpers.Money)3 DateTime (org.joda.time.DateTime)2 InterestCalculationPeriodResult (org.mifos.accounts.savings.interest.InterestCalculationPeriodResult)2 InterestCalculationPeriodResultBuilder (org.mifos.accounts.savings.interest.InterestCalculationPeriodResultBuilder)2 InterestPostingPeriodResult (org.mifos.accounts.savings.interest.InterestPostingPeriodResult)2 InterestPostingPeriodResultBuilder (org.mifos.accounts.savings.interest.InterestPostingPeriodResultBuilder)2 InterestScheduledEvent (org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent)2 MonthlyOnLastDayOfMonthInterestScheduledEvent (org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent)2 Date (java.util.Date)1 LocalDate (org.joda.time.LocalDate)1 AccountBO (org.mifos.accounts.business.AccountBO)1 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)1 SavingsRecentActivityDto (org.mifos.dto.screen.SavingsRecentActivityDto)1