Search in sources :

Example 11 with LoanScheduleEntity

use of org.mifos.accounts.loan.business.LoanScheduleEntity in project head by mifos.

the class FirstInstallmentRoudingDifferenceLoanScheduleRounder method roundGracePeriodInstallments.

private void roundGracePeriodInstallments(Integer gracePeriodInstallmentsCount, GraceType graceType, Short gracePeriodDuration, List<LoanScheduleEntity> unroundedLoanSchedules, List<LoanScheduleEntity> roundedLoanSchedules, RepaymentTotals totals) {
    int installmentNum = 0;
    while (installmentNum < gracePeriodInstallmentsCount) {
        LoanScheduleEntity currentInstallment = unroundedLoanSchedules.get(installmentNum);
        LoanScheduleEntity roundedInstallment = currentInstallment;
        installmentNum++;
        roundedInstallment = loanScheduleInstallmentRounder.roundAndAdjustGraceInstallment_v2(roundedInstallment);
        loanScheduleInstallmentRounder.updateRunningTotals_v2(totals, roundedInstallment);
        roundedLoanSchedules.add(roundedInstallment);
    }
}
Also used : LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity)

Example 12 with LoanScheduleEntity

use of org.mifos.accounts.loan.business.LoanScheduleEntity in project head by mifos.

the class ApplicationInitializer method applyMifos4948Fix.

@SuppressWarnings("unchecked")
private void applyMifos4948Fix() throws AccountException {
    Session session = StaticHibernateUtil.getSessionTL();
    List<LoanBO> fixLoans;
    Query query = session.getNamedQuery("fetchMissingInstalmentsForWriteOffsAndReschedules");
    fixLoans = query.list();
    if (fixLoans != null && fixLoans.size() > 0) {
        for (LoanBO fixLoan : fixLoans) {
            Set<AccountActionDateEntity> fixLoanSchedules = fixLoan.getAccountActionDates();
            Money totalMissedPayment = new Money(fixLoan.getCurrency());
            if (fixLoanSchedules != null && fixLoanSchedules.size() > 0) {
                for (AccountActionDateEntity fixLoanSchedule : fixLoanSchedules) {
                    LoanScheduleEntity loanInstallment = (LoanScheduleEntity) fixLoanSchedule;
                    totalMissedPayment = totalMissedPayment.add(loanInstallment.getPrincipalDue());
                }
            }
            logger.info("MIFOS-4948 - Loan: " + fixLoan.getGlobalAccountNum() + " - Adding payment: " + totalMissedPayment + " to fix instalments that should have been written-off or rescheduled.");
            fixLoan.applyMifos4948FixPayment(totalMissedPayment);
        }
        logger.info(fixLoans.size() + " Account Payments created to fix data related to MIFOS-4948");
    }
}
Also used : LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) Money(org.mifos.framework.util.helpers.Money) Query(org.hibernate.Query) LoanBO(org.mifos.accounts.loan.business.LoanBO) Session(org.hibernate.Session)

Example 13 with LoanScheduleEntity

use of org.mifos.accounts.loan.business.LoanScheduleEntity in project head by mifos.

the class AccountActionDateEntityIntegrationTest method testGetPrincipal.

@Test
public void testGetPrincipal() {
    Set<AccountActionDateEntity> accountActionDates = groupLoan.getAccountActionDates();
    for (AccountActionDateEntity accountActionDate : accountActionDates) {
        Money principal = ((LoanScheduleEntity) accountActionDate).getPrincipal();
        Assert.assertEquals(100.0, principal.getAmount().doubleValue(), DELTA);
    }
}
Also used : LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) Money(org.mifos.framework.util.helpers.Money) Test(org.junit.Test)

Example 14 with LoanScheduleEntity

use of org.mifos.accounts.loan.business.LoanScheduleEntity in project head by mifos.

the class AccountFeesActionDetailEntityIntegrationTest method testMakeEarlyRepaymentEnteriesForFeePayment.

@Test
public void testMakeEarlyRepaymentEnteriesForFeePayment() {
    for (AccountActionDateEntity installment : accountBO.getAccountActionDates()) {
        LoanScheduleEntity accountActionDateEntity = (LoanScheduleEntity) installment;
        for (AccountFeesActionDetailEntity accountFeesActionDetailEntity : accountActionDateEntity.getAccountFeesActionDetails()) {
            accountFeesActionDetailEntity.makeRepaymentEnteries(LoanConstants.PAY_FEES_PENALTY_INTEREST);
            Assert.assertEquals(accountFeesActionDetailEntity.getFeeAmount(), accountFeesActionDetailEntity.getFeeAmountPaid());
        }
    }
}
Also used : LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) Test(org.junit.Test)

Example 15 with LoanScheduleEntity

use of org.mifos.accounts.loan.business.LoanScheduleEntity in project head by mifos.

the class AccountFeesActionDetailEntityIntegrationTest method testMakeEarlyRepaymentEnteriesForFeePaymentWithInterestWaiver.

@Test
public void testMakeEarlyRepaymentEnteriesForFeePaymentWithInterestWaiver() {
    for (AccountActionDateEntity installment : accountBO.getAccountActionDates()) {
        LoanScheduleEntity accountActionDateEntity = (LoanScheduleEntity) installment;
        for (AccountFeesActionDetailEntity accountFeesActionDetailEntity : accountActionDateEntity.getAccountFeesActionDetails()) {
            accountFeesActionDetailEntity.makeRepaymentEnteries(LoanConstants.PAY_FEES_PENALTY);
            Assert.assertEquals(accountFeesActionDetailEntity.getFeeAmount(), accountFeesActionDetailEntity.getFeeAmountPaid());
        }
    }
}
Also used : LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) Test(org.junit.Test)

Aggregations

LoanScheduleEntity (org.mifos.accounts.loan.business.LoanScheduleEntity)54 Money (org.mifos.framework.util.helpers.Money)32 ArrayList (java.util.ArrayList)19 OriginalLoanScheduleEntity (org.mifos.accounts.loan.business.OriginalLoanScheduleEntity)18 Test (org.junit.Test)16 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)14 BigDecimal (java.math.BigDecimal)11 AccountFeesActionDetailEntity (org.mifos.accounts.business.AccountFeesActionDetailEntity)8 LoanBO (org.mifos.accounts.loan.business.LoanBO)8 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)7 Date (java.util.Date)5 CustomerBO (org.mifos.customers.business.CustomerBO)5 UserContext (org.mifos.security.util.UserContext)5 LocalDate (org.joda.time.LocalDate)4 AccountPenaltiesEntity (org.mifos.accounts.business.AccountPenaltiesEntity)4 OriginalLoanScheduleEntitiesMatcher (org.mifos.accounts.loan.business.matchers.OriginalLoanScheduleEntitiesMatcher)4 InstallmentDetailsDto (org.mifos.dto.domain.InstallmentDetailsDto)4 LoanInstallmentDetailsDto (org.mifos.dto.domain.LoanInstallmentDetailsDto)4 MifosUser (org.mifos.security.MifosUser)4 Date (java.sql.Date)3