Search in sources :

Example 31 with SavingsScheduleEntity

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

the class TestObjectFactory method getBulkEntryAccountActionView.

public static CollectionSheetEntryInstallmentDto getBulkEntryAccountActionView(final AccountActionDateEntity accountActionDateEntity) {
    CollectionSheetEntryInstallmentDto bulkEntryAccountActionView = null;
    if (accountActionDateEntity instanceof LoanScheduleEntity) {
        LoanScheduleEntity actionDate = (LoanScheduleEntity) accountActionDateEntity;
        CollectionSheetEntryLoanInstallmentDto installmentView = new CollectionSheetEntryLoanInstallmentDto(actionDate.getAccount().getAccountId(), actionDate.getCustomer().getCustomerId(), actionDate.getInstallmentId(), actionDate.getActionDateId(), actionDate.getActionDate(), actionDate.getPrincipal(), actionDate.getPrincipalPaid(), actionDate.getInterest(), actionDate.getInterestPaid(), actionDate.getMiscFee(), actionDate.getMiscFeePaid(), actionDate.getPenalty(), actionDate.getPenaltyPaid(), actionDate.getMiscPenalty(), actionDate.getMiscPenaltyPaid(), TestUtils.RUPEE);
        installmentView.setCollectionSheetEntryAccountFeeActions(getBulkEntryAccountFeeActionViews(accountActionDateEntity));
        bulkEntryAccountActionView = installmentView;
    } else if (accountActionDateEntity instanceof SavingsScheduleEntity) {
        SavingsScheduleEntity actionDate = (SavingsScheduleEntity) accountActionDateEntity;
        CollectionSheetEntrySavingsInstallmentDto installmentView = new CollectionSheetEntrySavingsInstallmentDto(actionDate.getAccount().getAccountId(), actionDate.getCustomer().getCustomerId(), actionDate.getInstallmentId(), actionDate.getActionDateId(), actionDate.getActionDate(), actionDate.getDeposit(), actionDate.getDepositPaid());
        bulkEntryAccountActionView = installmentView;
    } else if (accountActionDateEntity instanceof CustomerScheduleEntity) {
        CustomerScheduleEntity actionDate = (CustomerScheduleEntity) accountActionDateEntity;
        CollectionSheetEntryCustomerAccountInstallmentDto installmentView = new CollectionSheetEntryCustomerAccountInstallmentDto(actionDate.getAccount().getAccountId(), actionDate.getCustomer().getCustomerId(), actionDate.getInstallmentId(), actionDate.getActionDateId(), actionDate.getActionDate(), actionDate.getMiscFee(), actionDate.getMiscFeePaid(), actionDate.getMiscPenalty(), actionDate.getMiscPenaltyPaid(), TestUtils.RUPEE);
        installmentView.setCollectionSheetEntryAccountFeeActions(getBulkEntryAccountFeeActionViews(accountActionDateEntity));
        bulkEntryAccountActionView = installmentView;
    }
    return bulkEntryAccountActionView;
}
Also used : LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) CollectionSheetEntryLoanInstallmentDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryLoanInstallmentDto) CustomerScheduleEntity(org.mifos.customers.business.CustomerScheduleEntity) CollectionSheetEntrySavingsInstallmentDto(org.mifos.application.collectionsheet.business.CollectionSheetEntrySavingsInstallmentDto) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) CollectionSheetEntryCustomerAccountInstallmentDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryCustomerAccountInstallmentDto) CollectionSheetEntryInstallmentDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryInstallmentDto)

Example 32 with SavingsScheduleEntity

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

the class SavingsDaoHibernate method updateSavingScheduleEntity.

@Override
public void updateSavingScheduleEntity(List<SavingsScheduleEntity> savingScheduleList) {
    for (SavingsScheduleEntity savingsScheduleEntity : savingScheduleList) {
        savingsScheduleEntity.setDeposit(Money.zero());
        this.baseDao.createOrUpdate(savingsScheduleEntity);
    }
}
Also used : SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity)

Example 33 with SavingsScheduleEntity

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

the class LegacyAccountDaoIntegrationTest method testGetSavingsSchedulesForAccountThatAreWithinDates.

@Test
public void testGetSavingsSchedulesForAccountThatAreWithinDates() throws Exception {
    savingsBO = new TestCollectionSheetRetrieveSavingsAccountsUtils().createSavingsAccount(group, "clm", "3.0", false, false);
    DateTime fromDate = new DateMidnight().toDateTime().plusDays(1);
    DateTime thruDate = new DateMidnight().toDateTime().plusDays(37);
    List<SavingsScheduleEntity> affectedDates = legacyAccountDao.getSavingsSchedulesForAccountThatAreWithinDates(savingsBO.getAccountId(), fromDate, thruDate);
    Assert.assertNotNull(affectedDates);
    Assert.assertEquals(5, affectedDates.size());
}
Also used : DateMidnight(org.joda.time.DateMidnight) TestCollectionSheetRetrieveSavingsAccountsUtils(org.mifos.application.servicefacade.TestCollectionSheetRetrieveSavingsAccountsUtils) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 34 with SavingsScheduleEntity

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

the class SavingsBOTest method shouldPayOffAnyPaymentsAssociatedWithPayingCustomerAndVoluntarySavingsAccount.

@Ignore
@Test
public void shouldPayOffAnyPaymentsAssociatedWithPayingCustomerAndVoluntarySavingsAccount() throws AccountException {
    // setup
    savingsAccount = savingsAccountBuilder.build();
    final SavingsScheduleEntity unpaidSaving1 = new SavingsScheduleBuilder().withAccount(savingsAccount).withCustomer(payingCustomer).build();
    final List<SavingsScheduleEntity> unpaidDepositsForPayingCustomer = Arrays.asList(unpaidSaving1);
    SavingsOfferingBO volSavingsProduct = new SavingsProductBuilder().voluntary().buildForUnitTests();
    final Money zero = new Money(defaultCurrency);
    savingsAccount = savingsAccountBuilder.withSavingsProduct(volSavingsProduct).withBalanceOf(zero).completeGroup().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.VOLUNTARY, 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 35 with SavingsScheduleEntity

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

the class SavingsBOTest method depositScheduleIsGeneratedOnCreationNoHoliday.

@Ignore
@Test
public void depositScheduleIsGeneratedOnCreationNoHoliday() {
    //  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();
    // verify
    List<SavingsScheduleEntity> sortedSavingsSchedules = getSortedSavingsScheduleEntities();
    assertThat(sortedSavingsSchedules.size(), is(10));
    DateTime installmentDate = new DateMidnight().toDateTime();
    for (SavingsScheduleEntity savingsScheduleEntity : sortedSavingsSchedules) {
        assertThat(new LocalDate(savingsScheduleEntity.getActionDate()), is(new LocalDate(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);
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) DateMidnight(org.joda.time.DateMidnight) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Ignore(org.junit.Ignore) Test(org.junit.Test)

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