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;
}
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());
}
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);
}
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));
}
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());
}
Aggregations