Search in sources :

Example 1 with SavingsScheduleEntity

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

the class SavingsOverDueDepositsTag method buildUI.

StringBuilder buildUI(List<AccountActionDateEntity> installmentsInArrears, Locale locale) {
    StringBuilder builder = new StringBuilder();
    SavingsScheduleEntity installment = null;
    Date actionDate = null;
    Collections.sort(installmentsInArrears, new Comparator<AccountActionDateEntity>() {

        @Override
        public int compare(AccountActionDateEntity actionDate1, AccountActionDateEntity actionDate2) {
            return actionDate1.getActionDate().compareTo(actionDate2.getActionDate());
        }
    });
    for (int i = 0; i < installmentsInArrears.size(); ) {
        actionDate = installmentsInArrears.get(i).getActionDate();
        Money totalAmount = new Money(installmentsInArrears.get(i).getAccount().getCurrency());
        do {
            installment = (SavingsScheduleEntity) installmentsInArrears.get(i);
            if (!(installment.getCustomer().getCustomerLevel().getId().equals(CustomerLevel.CLIENT.getValue()) && installment.getCustomer().getStatus().equals(CustomerStatus.CLIENT_CLOSED))) {
                totalAmount = totalAmount.add(installment.getTotalDepositDue());
            }
            i++;
        } while (i < installmentsInArrears.size() && actionDate.equals(installmentsInArrears.get(i).getActionDate()));
        if (totalAmount.isGreaterThanZero()) {
            builder.append(buildDepositDueUIRow(locale, actionDate, totalAmount));
        }
    }
    return builder;
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) Money(org.mifos.framework.util.helpers.Money) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Date(java.sql.Date)

Example 2 with SavingsScheduleEntity

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

the class SavingsBOIntegrationTest method testGetTotalAmountInArrearsForSingleInstallmentDue.

@Test
public void testGetTotalAmountInArrearsForSingleInstallmentDue() throws Exception {
    savings = getSavingsAccount();
    AccountActionDateEntity accountActionDateEntity = savings.getAccountActionDate((short) 1);
    ((SavingsScheduleEntity) accountActionDateEntity).setActionDate(offSetCurrentDate(1));
    savings = (SavingsBO) saveAndFetch(savings);
    Assert.assertEquals(TestUtils.createMoney(200.0), savings.getTotalAmountInArrears());
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Test(org.junit.Test)

Example 3 with SavingsScheduleEntity

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

the class SavingsBOIntegrationTest method testGetDetailsOfInstallmentsInArrearsForTwoInstallmentsDue.

@Test
public void testGetDetailsOfInstallmentsInArrearsForTwoInstallmentsDue() throws Exception {
    savings = getSavingsAccount();
    AccountActionDateEntity accountActionDateEntity = savings.getAccountActionDate((short) 1);
    ((SavingsScheduleEntity) accountActionDateEntity).setActionDate(offSetCurrentDate(2));
    AccountActionDateEntity accountActionDateEntity2 = savings.getAccountActionDate((short) 2);
    ((SavingsScheduleEntity) accountActionDateEntity2).setActionDate(offSetCurrentDate(1));
    savings = (SavingsBO) saveAndFetch(savings);
    Assert.assertEquals(savings.getDetailsOfInstallmentsInArrears().size(), 2);
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Test(org.junit.Test)

Example 4 with SavingsScheduleEntity

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

the class SavingsBOIntegrationTest method testGetTotalAmountDueWithPaymentDone.

@Test
public void testGetTotalAmountDueWithPaymentDone() throws Exception {
    savings = getSavingsAccount();
    AccountActionDateEntity accountActionDateEntity = savings.getAccountActionDate((short) 1);
    ((SavingsScheduleEntity) accountActionDateEntity).setActionDate(offSetCurrentDate(1));
    accountActionDateEntity.setPaymentStatus(PaymentStatus.PAID);
    savings = (SavingsBO) saveAndFetch(savings);
    Assert.assertEquals(savings.getTotalAmountDue(), TestUtils.createMoney(200.0));
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Test(org.junit.Test)

Example 5 with SavingsScheduleEntity

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

the class SavingsBOIntegrationTest method testGetTotalAmountInArrearsWithPartialPayment.

@Test
public void testGetTotalAmountInArrearsWithPartialPayment() throws Exception {
    savings = getSavingsAccount();
    SavingsScheduleEntity accountActionDateEntity = (SavingsScheduleEntity) savings.getAccountActionDate((short) 1);
    accountActionDateEntity.setDepositPaid(new Money(getCurrency(), "20.0"));
    accountActionDateEntity.setActionDate(offSetCurrentDate(1));
    savings = (SavingsBO) saveAndFetch(savings);
    Assert.assertEquals(TestUtils.createMoney(180.0), savings.getTotalAmountInArrears());
}
Also used : Money(org.mifos.framework.util.helpers.Money) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) 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