use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class SavingsBOIntegrationTest method testGetTotalAmountDueForCenter.
@Test
public void testGetTotalAmountDueForCenter() throws Exception {
savings = getSavingsAccountForCenter();
Money dueAmount = new Money(getCurrency());
for (AccountActionDateEntity actionDate : savings.getAccountActionDates()) {
dueAmount = dueAmount.add(((SavingsScheduleEntity) actionDate).getDeposit());
break;
}
dueAmount = dueAmount.add(dueAmount);
Assert.assertEquals(dueAmount, savings.getTotalAmountDue());
}
use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class SavingsBOIntegrationTest method testGetTotalAmountDueForTwoInstallmentsDue.
@Test
public void testGetTotalAmountDueForTwoInstallmentsDue() 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.getTotalAmountInArrears(), TestUtils.createMoney(400.0));
}
use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class SavingsBOIntegrationTest method testGetTotalAmountDueForTwoInstallments.
@Test
public void testGetTotalAmountDueForTwoInstallments() 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.getTotalAmountDue(), TestUtils.createMoney(600.0));
}
use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class SavingsBOIntegrationTest method createObjectToCheckForTotalInstallmentDue.
private void createObjectToCheckForTotalInstallmentDue(final SavingsType savingsType) throws Exception {
createInitialObjects();
savingsOffering = helper.createSavingsOffering("prd1df", InterestCalcType.MINIMUM_BALANCE, savingsType);
savings = helper.createSavingsAccount(savingsOffering, group, AccountState.SAVINGS_PENDING_APPROVAL, userContext);
Calendar cal1 = Calendar.getInstance();
Calendar cal2 = Calendar.getInstance();
cal2.setLenient(true);
cal2.set(Calendar.DAY_OF_MONTH, cal1.get(Calendar.DAY_OF_MONTH) - 1);
Date paymentDate = helper.getDate("09/05/2006");
Money recommendedAmnt = new Money(currency, "500.0");
AccountActionDateEntity actionDate1 = helper.createAccountActionDate(savings, Short.valueOf("1"), cal2.getTime(), paymentDate, savings.getCustomer(), recommendedAmnt, new Money(getCurrency()), PaymentStatus.UNPAID);
AccountActionDateEntity actionDate2 = helper.createAccountActionDate(savings, Short.valueOf("2"), new Date(), paymentDate, savings.getCustomer(), recommendedAmnt, new Money(getCurrency()), PaymentStatus.UNPAID);
AccountTestUtils.addAccountActionDate(actionDate1, savings);
AccountTestUtils.addAccountActionDate(actionDate2, savings);
savings.update();
}
use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class LoanBO method removeFeesAssociatedWithUpcomingAndAllKnownFutureInstallments.
/**
* Remove the fee from all unpaid current or future installments, and update the loan accordingly.
*/
@Override
public final void removeFeesAssociatedWithUpcomingAndAllKnownFutureInstallments(final Short feeId, final Short personnelId) throws AccountException {
List<Short> installmentIds = getApplicableInstallmentIdsForRemoveFees();
Money totalFeeAmount;
if (installmentIds != null && installmentIds.size() != 0 && isFeeActive(feeId)) {
FeeBO fee = getAccountFeesObject(feeId);
if (havePaymentsBeenMade() && fee.doesFeeInvolveFractionalAmounts()) {
throw new AccountException(AccountExceptionConstants.CANT_REMOVE_FEE_EXCEPTION);
}
if (fee.isTimeOfDisbursement()) {
AccountFeesEntity accountFee = getAccountFees(feeId);
totalFeeAmount = accountFee.getAccountFeeAmount();
removeAccountFee(accountFee);
this.delete(accountFee);
} else {
totalFeeAmount = updateAccountActionDateEntity(installmentIds, feeId);
updateAccountFeesEntity(feeId);
}
updateTotalFeeAmount(totalFeeAmount);
String description = fee.getFeeName() + " " + AccountConstants.FEES_REMOVED;
updateAccountActivity(null, null, totalFeeAmount, null, personnelId, description);
if (!havePaymentsBeenMade()) {
LoanScheduleRounderHelper loanScheduleRounderHelper = new DefaultLoanScheduleRounderHelper();
LoanScheduleRounder loanScheduleInstallmentRounder = getLoanScheduleRounder(loanScheduleRounderHelper);
List<LoanScheduleEntity> unroundedLoanSchedules = new ArrayList<LoanScheduleEntity>();
List<LoanScheduleEntity> allExistingLoanSchedules = new ArrayList<LoanScheduleEntity>();
List<AccountActionDateEntity> installmentsToRound = getInstallmentsToRound();
for (AccountActionDateEntity installment : installmentsToRound) {
unroundedLoanSchedules.add((LoanScheduleEntity) installment);
}
List<AccountActionDateEntity> allExistingInstallments = this.getAllInstallments();
for (AccountActionDateEntity installment : allExistingInstallments) {
allExistingLoanSchedules.add((LoanScheduleEntity) installment);
}
List<LoanScheduleEntity> roundedLoanSchedules = loanScheduleInstallmentRounder.round(this.gracePeriodType.asEnum(), this.gracePeriodDuration, this.loanAmount, this.interestType.asEnum(), unroundedLoanSchedules, allExistingLoanSchedules);
// applyRounding_v2();
}
try {
ApplicationContextProvider.getBean(LegacyAccountDao.class).createOrUpdate(this);
} catch (PersistenceException e) {
throw new AccountException(e);
}
}
}
Aggregations