use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class CustomerAccountBOIntegrationTest method testActivityForMultiplePayments.
@Test
public void testActivityForMultiplePayments() throws Exception {
// setup
createCenter();
CustomerAccountBO customerAccount = center.getCustomerAccount();
Assert.assertNotNull(customerAccount);
Date transactionDate = incrementCurrentDate(14);
final Money paymentForThisInstallmentAndLastTwoInstallmentsInArrears = TestUtils.createMoney("300.0");
List<AccountActionDateEntity> dueActionDates = TestObjectFactory.getDueActionDatesForAccount(customerAccount.getAccountId(), transactionDate);
Assert.assertEquals("The size of the due insallments is ", dueActionDates.size(), 3);
PaymentData accountPaymentDataView = TestObjectFactory.getCustomerAccountPaymentDataView(dueActionDates, paymentForThisInstallmentAndLastTwoInstallmentsInArrears, null, center.getPersonnel(), "3424324", Short.valueOf("1"), transactionDate, transactionDate);
center = TestObjectFactory.getCustomer(center.getCustomerId());
customerAccount = center.getCustomerAccount();
// exercise test
customerAccount.applyPayment(accountPaymentDataView);
// verification
assertThat(customerAccount.getCustomerActivitDetails().size(), is(1));
assertThat("The size of the payments done is", customerAccount.getAccountPayments().size(), is(1));
assertThat("The size of the due insallments after payment is", TestObjectFactory.getDueActionDatesForAccount(customerAccount.getAccountId(), transactionDate).size(), is(0));
assertThat(customerAccount.getAccountPayments().size(), is(1));
for (AccountPaymentEntity accountPayment : customerAccount.getAccountPayments()) {
assertThat(accountPayment.getAccountTrxns().size(), is(3));
for (AccountTrxnEntity accountTrxnEntity : accountPayment.getAccountTrxns()) {
assertThat(accountTrxnEntity.getFinancialTransactions().size(), is(2));
}
}
}
use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class CenterScheduleCreationUsingCustomerServiceIntegrationTest method validateOnePeriodicFee.
private void validateOnePeriodicFee(String centerSystemId, String expectedPeriodicFeeName, double... expectedFees) {
CenterBO retrievedCenter = customerDao.findCenterBySystemId(centerSystemId);
for (AccountActionDateEntity accountActionDate : getActionDatesSortedByDate(retrievedCenter.getCustomerAccount())) {
CustomerScheduleEntity scheduleEntity = (CustomerScheduleEntity) accountActionDate;
assertThat(scheduleEntity.getAccountFeesActionDetails().size(), is(1));
assertThat(scheduleEntity.getAccountFeesActionDetailsSortedByFeeId().get(0).getFee().getFeeName(), is(expectedPeriodicFeeName));
assertThat(scheduleEntity.getAccountFeesActionDetailsSortedByFeeId().get(0).getFeeAmount().getAmountDoubleValue(), is(expectedFees[scheduleEntity.getInstallmentId() - 1]));
}
}
use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class PortfolioAtRiskCalculationIntegrationTest method changeFirstInstallmentDate.
private void changeFirstInstallmentDate(AccountBO accountBO, int numberOfDays) {
Calendar currentDateCalendar = new GregorianCalendar();
int year = currentDateCalendar.get(Calendar.YEAR);
int month = currentDateCalendar.get(Calendar.MONTH);
int day = currentDateCalendar.get(Calendar.DAY_OF_MONTH);
currentDateCalendar = new GregorianCalendar(year, month, day - numberOfDays);
for (AccountActionDateEntity accountActionDateEntity : accountBO.getAccountActionDates()) {
LoanBOTestUtils.setActionDate(accountActionDateEntity, new java.sql.Date(currentDateCalendar.getTimeInMillis()));
break;
}
}
use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class PortfolioAtRiskHelperIntegrationTest method changeFirstInstallmentDate.
private void changeFirstInstallmentDate(AccountBO accountBO, int numberOfDays) {
Calendar currentDateCalendar = new GregorianCalendar();
int year = currentDateCalendar.get(Calendar.YEAR);
int month = currentDateCalendar.get(Calendar.MONTH);
int day = currentDateCalendar.get(Calendar.DAY_OF_MONTH);
currentDateCalendar = new GregorianCalendar(year, month, day - numberOfDays);
for (AccountActionDateEntity accountActionDateEntity : accountBO.getAccountActionDates()) {
LoanBOTestUtils.setActionDate(accountActionDateEntity, new java.sql.Date(currentDateCalendar.getTimeInMillis()));
break;
}
}
use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class LoanBO method waiveFeeAmountDue.
private void waiveFeeAmountDue() throws AccountException {
List<AccountActionDateEntity> accountActionDateList = getApplicableIdsForNextInstallmentAndArrears();
LoanScheduleEntity accountActionDateEntity = (LoanScheduleEntity) accountActionDateList.get(accountActionDateList.size() - 1);
Money chargeWaived = accountActionDateEntity.waiveFeeCharges();
Money principal = new Money(getCurrency());
Money interest = new Money(getCurrency());
Money penalty = new Money(getCurrency());
if (chargeWaived != null && chargeWaived.isGreaterThanZero()) {
updateTotalFeeAmount(chargeWaived);
updateAccountActivity(principal, interest, chargeWaived, penalty, userContext.getId(), LoanConstants.FEE_WAIVED);
waiveChargesFromMemberAccounts(LoanConstants.FEE_WAIVED);
}
try {
getlegacyLoanDao().createOrUpdate(this);
} catch (PersistenceException e) {
throw new AccountException(e);
}
}
Aggregations