Search in sources :

Example 41 with AccountActionDateEntity

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());
}
Also used : Money(org.mifos.framework.util.helpers.Money) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Test(org.junit.Test)

Example 42 with AccountActionDateEntity

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));
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Test(org.junit.Test)

Example 43 with AccountActionDateEntity

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));
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Test(org.junit.Test)

Example 44 with AccountActionDateEntity

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();
}
Also used : Money(org.mifos.framework.util.helpers.Money) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) Date(java.util.Date)

Example 45 with AccountActionDateEntity

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);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) DefaultLoanScheduleRounderHelper(org.mifos.clientportfolio.newloan.domain.DefaultLoanScheduleRounderHelper) Money(org.mifos.framework.util.helpers.Money) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) AccountException(org.mifos.accounts.exceptions.AccountException) LegacyAccountDao(org.mifos.accounts.persistence.LegacyAccountDao) FirstInstallmentRoudingDifferenceLoanScheduleRounder(org.mifos.clientportfolio.newloan.domain.FirstInstallmentRoudingDifferenceLoanScheduleRounder) LoanScheduleRounder(org.mifos.clientportfolio.newloan.domain.LoanScheduleRounder) DefaultLoanScheduleRounder(org.mifos.clientportfolio.newloan.domain.DefaultLoanScheduleRounder) PersistenceException(org.mifos.framework.exceptions.PersistenceException) FeeBO(org.mifos.accounts.fees.business.FeeBO) RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) DefaultLoanScheduleRounderHelper(org.mifos.clientportfolio.newloan.domain.DefaultLoanScheduleRounderHelper) LoanScheduleRounderHelper(org.mifos.clientportfolio.newloan.domain.LoanScheduleRounderHelper) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity)

Aggregations

AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)211 Money (org.mifos.framework.util.helpers.Money)80 Test (org.junit.Test)69 ArrayList (java.util.ArrayList)58 LocalDate (org.joda.time.LocalDate)42 Date (java.util.Date)39 DateTime (org.joda.time.DateTime)33 MeetingBO (org.mifos.application.meeting.business.MeetingBO)33 AccountException (org.mifos.accounts.exceptions.AccountException)24 PaymentData (org.mifos.accounts.util.helpers.PaymentData)24 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)21 Date (java.sql.Date)19 SavingsScheduleEntity (org.mifos.accounts.savings.business.SavingsScheduleEntity)19 LoanBO (org.mifos.accounts.loan.business.LoanBO)17 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)15 LoanScheduleEntity (org.mifos.accounts.loan.business.LoanScheduleEntity)14 UserContext (org.mifos.security.util.UserContext)14 Calendar (java.util.Calendar)13 GregorianCalendar (java.util.GregorianCalendar)13 CenterBuilder (org.mifos.domain.builders.CenterBuilder)13