Search in sources :

Example 26 with SavingsScheduleEntity

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

the class SavingsBOTest method overpayingMandatoryOrVoluntaryDepositAmountCausesAnExcessTransactionToBeCreated.

@Ignore
@Test
public void overpayingMandatoryOrVoluntaryDepositAmountCausesAnExcessTransactionToBeCreated() throws AccountException {
    // setup
    SavingsOfferingBO savingsProduct = new SavingsProductBuilder().mandatory().buildForUnitTests();
    savingsAccount = savingsAccountBuilder.withSavingsProduct(savingsProduct).build();
    final SavingsScheduleEntity unpaidSaving1 = new SavingsScheduleBuilder().withAccount(savingsAccount).withCustomer(payingCustomer).build();
    final List<SavingsScheduleEntity> unpaidDepositsForPayingCustomer = Arrays.asList(unpaidSaving1);
    final Money zero = new Money(defaultCurrency);
    SavingsOfferingBO manSavingsProduct = new SavingsProductBuilder().mandatory().buildForUnitTests();
    savingsAccount = savingsAccountBuilder.withSavingsProduct(manSavingsProduct).withBalanceOf(zero).withPayments(unpaidDepositsForPayingCustomer).buildForUnitTests();
    final Money amountToDeposit = new Money(TestUtils.RUPEE, "100.0");
    final Date dateOfDeposit = new DateTime().toDate();
    final Money excessDepositAmount = new Money(TestUtils.RUPEE, "25.0");
    final Money expectedTotalBalance = amountToDeposit.add(zero);
    // stubbing
    when(accountPayment.getAmount()).thenReturn(amountToDeposit);
    when(accountPayment.getPaymentDate()).thenReturn(dateOfDeposit);
    when(paymentStrategy.makeScheduledPayments(accountPayment, unpaidDepositsForPayingCustomer, payingCustomer, SavingsType.MANDATORY, zero)).thenReturn(excessDepositAmount);
    // exercise test
    savingsAccount.deposit(accountPayment, payingCustomer);
    // verification
    verify(this.savingsTransactionActivityHelper).createSavingsTrxnForDeposit(accountPayment, excessDepositAmount, payingCustomer, null, expectedTotalBalance);
}
Also used : SavingsScheduleBuilder(org.mifos.domain.builders.SavingsScheduleBuilder) Money(org.mifos.framework.util.helpers.Money) SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 27 with SavingsScheduleEntity

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

the class SavingsBOTest method generateNextSetOfMeetingDatesMoratoriumOn2ndInstallment.

/**
     * passing locally on eclipse but not on maven.
     */
@Ignore
@Test
public void generateNextSetOfMeetingDatesMoratoriumOn2ndInstallment() throws Exception {
    // setup
    Holiday moratorium = new HolidayBuilder().from(new DateMidnight().toDateTime().plusWeeks(1)).to(new DateMidnight().toDateTime().plusWeeks(1)).withRepaymentMoratoriumRule().build();
    List<Holiday> withMoratorium = new ArrayList<Holiday>();
    withMoratorium.add(moratorium);
    when(savingsAccountCustomer.getCustomerMeeting()).thenReturn(customerMeetingEntity);
    when(customerMeetingEntity.getMeeting()).thenReturn(defaultWeeklyCustomerMeeting);
    when(savingsAccountCustomer.getCustomerLevel()).thenReturn(customerLevelEntity);
    when(customerLevelEntity.getId()).thenReturn(CustomerLevel.CLIENT.getValue());
    // exercise test
    savingsAccount = savingsAccountBuilder.with(moratorium).buildForUnitTests();
    savingsAccount.generateNextSetOfMeetingDates(allWorkingDays, withMoratorium);
    // verify
    List<SavingsScheduleEntity> sortedSavingsSchedules = getSortedSavingsScheduleEntities();
    assertThat(sortedSavingsSchedules.size(), is(20));
    DateTime installmentDate = new DateMidnight().toDateTime();
    int installmentId = 1;
    for (SavingsScheduleEntity savingsScheduleEntity : getSortedSavingsScheduleEntities()) {
        if (installmentId < 2) {
            assertThat("Installment " + installmentId, savingsScheduleEntity.getActionDate(), is(installmentDate.toDate()));
        } else {
            // Second and later deposits are pushed out one week by the moratorium
            assertThat("Installment " + installmentId, savingsScheduleEntity.getActionDate(), is(installmentDate.plusWeeks(1).toDate()));
        }
        assertThat(savingsScheduleEntity.getDeposit(), is(new Money(TestUtils.RUPEE, "13.0")));
        assertThat(savingsScheduleEntity.getDepositPaid(), is(new Money(TestUtils.RUPEE, "0.0")));
        installmentDate = installmentDate.plusWeeks(1);
        installmentId++;
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) Holiday(org.mifos.application.holiday.business.Holiday) DateMidnight(org.joda.time.DateMidnight) ArrayList(java.util.ArrayList) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) DateTime(org.joda.time.DateTime) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 28 with SavingsScheduleEntity

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

the class SavingsBOTest method shouldPayOffAnyPaymentsAssociatedWithPayingCustomerAndMandatorySavingsAccount.

@Ignore
@Test
public void shouldPayOffAnyPaymentsAssociatedWithPayingCustomerAndMandatorySavingsAccount() throws AccountException {
    // setup
    SavingsOfferingBO savingsProduct = new SavingsProductBuilder().mandatory().buildForUnitTests();
    savingsAccount = savingsAccountBuilder.withSavingsProduct(savingsProduct).buildForUnitTests();
    final SavingsScheduleEntity unpaidSaving1 = new SavingsScheduleBuilder().withAccount(savingsAccount).withCustomer(payingCustomer).build();
    final List<SavingsScheduleEntity> unpaidDepositsForPayingCustomer = Arrays.asList(unpaidSaving1);
    final Money zero = new Money(defaultCurrency);
    SavingsOfferingBO manSavingsProduct = new SavingsProductBuilder().mandatory().buildForUnitTests();
    savingsAccount = savingsAccountBuilder.withSavingsProduct(manSavingsProduct).withBalanceOf(zero).withPayments(unpaidDepositsForPayingCustomer).buildForUnitTests();
    final Money amountToDeposit = new Money(TestUtils.RUPEE, "100.0");
    final Date dateOfDeposit = new DateTime().toDate();
    // stubbing
    when(accountPayment.getAmount()).thenReturn(amountToDeposit);
    when(accountPayment.getPaymentDate()).thenReturn(dateOfDeposit);
    // exercise test
    savingsAccount.deposit(accountPayment, payingCustomer);
    // verification
    verify(paymentStrategy).makeScheduledPayments(accountPayment, unpaidDepositsForPayingCustomer, payingCustomer, SavingsType.MANDATORY, zero);
}
Also used : SavingsScheduleBuilder(org.mifos.domain.builders.SavingsScheduleBuilder) Money(org.mifos.framework.util.helpers.Money) SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 29 with SavingsScheduleEntity

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

the class SavingsBOTest method generateNextSetOfMeetingDatesNoHoliday.

@Ignore
@Test
public void generateNextSetOfMeetingDatesNoHoliday() throws Exception {
    // setup
    when(savingsAccountCustomer.getCustomerMeeting()).thenReturn(customerMeetingEntity);
    when(customerMeetingEntity.getMeeting()).thenReturn(defaultWeeklyCustomerMeeting);
    when(savingsAccountCustomer.getCustomerLevel()).thenReturn(customerLevelEntity);
    when(customerLevelEntity.getId()).thenReturn(CustomerLevel.CLIENT.getValue());
    // exercise test
    savingsAccount = savingsAccountBuilder.buildForUnitTests();
    savingsAccount.generateNextSetOfMeetingDates(allWorkingDays, emptyListOfHolidays);
    // verify
    List<SavingsScheduleEntity> sortedSavingsSchedules = getSortedSavingsScheduleEntities();
    assertThat(sortedSavingsSchedules.size(), is(20));
    DateTime installmentDate = new DateMidnight().toDateTime();
    int installmentId = 1;
    for (SavingsScheduleEntity savingsScheduleEntity : getSortedSavingsScheduleEntities()) {
        assertThat(savingsScheduleEntity.getActionDate(), is(installmentDate.toDate()));
        assertThat(savingsScheduleEntity.getDeposit(), is(new Money(TestUtils.RUPEE, "13.0")));
        assertThat(savingsScheduleEntity.getDepositPaid(), is(new Money(TestUtils.RUPEE, "0.0")));
        installmentDate = installmentDate.plusWeeks(1);
        installmentId++;
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) DateMidnight(org.joda.time.DateMidnight) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) DateTime(org.joda.time.DateTime) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 30 with SavingsScheduleEntity

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

the class SavingsTestHelper method createAccountActionDate.

public AccountActionDateEntity createAccountActionDate(AccountBO account, short installmentId, Date dueDate, Date paymentDate, CustomerBO customer, Money deposit, Money depositPaid, PaymentStatus paymentStatus) {
    SavingsScheduleEntity actionDate = new SavingsScheduleEntity(account, customer, installmentId, new java.sql.Date(dueDate.getTime()), paymentStatus, deposit);
    SavingBOTestUtils.setDepositPaid(actionDate, depositPaid);
    if (paymentDate != null) {
        SavingBOTestUtils.setPaymentDate(actionDate, new java.sql.Date(paymentDate.getTime()));
    }
    return actionDate;
}
Also used : SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity)

Aggregations

SavingsScheduleEntity (org.mifos.accounts.savings.business.SavingsScheduleEntity)56 Test (org.junit.Test)48 Money (org.mifos.framework.util.helpers.Money)33 DateTime (org.joda.time.DateTime)32 Date (java.util.Date)27 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)19 SavingsScheduleBuilder (org.mifos.domain.builders.SavingsScheduleBuilder)18 LocalDate (org.joda.time.LocalDate)13 Ignore (org.junit.Ignore)13 DateMidnight (org.joda.time.DateMidnight)6 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)5 ArrayList (java.util.ArrayList)4 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)3 Holiday (org.mifos.application.holiday.business.Holiday)3 MeetingBO (org.mifos.application.meeting.business.MeetingBO)3 HolidayBuilder (org.mifos.domain.builders.HolidayBuilder)3 SavingsProductBuilder (org.mifos.domain.builders.SavingsProductBuilder)3 Session (org.hibernate.Session)2 AccountTrxnEntity (org.mifos.accounts.business.AccountTrxnEntity)2 UserContext (org.mifos.security.util.UserContext)2