Search in sources :

Example 16 with FeeBO

use of org.mifos.accounts.fees.business.FeeBO in project head by mifos.

the class LoanPrdAction method getFeeViewList.

private List<FeeDto> getFeeViewList(UserContext userContext, List<FeeBO> fees) {
    logger.debug("start getFeeViewList method of Loan Product Action ");
    List<FeeDto> feeDtos = new ArrayList<FeeDto>();
    if (fees != null && fees.size() > 0) {
        for (FeeBO fee : fees) {
            feeDtos.add(new FeeDto(userContext, fee));
        }
    }
    logger.debug("getFeeViewList method of Loan Product Action called");
    return feeDtos.size() > 0 ? feeDtos : null;
}
Also used : ArrayList(java.util.ArrayList) FeeDto(org.mifos.accounts.fees.business.FeeDto) FeeBO(org.mifos.accounts.fees.business.FeeBO)

Example 17 with FeeBO

use of org.mifos.accounts.fees.business.FeeBO in project head by mifos.

the class LoanPrdAction method getFeeList.

private List<FeeBO> getFeeList(List<FeeBO> fees, String[] feesSelected) {
    logger.debug("start getFeeList method of Loan Product Action ");
    List<FeeBO> feeList = new ArrayList<FeeBO>();
    if (feesSelected != null && feesSelected.length > 0 && fees != null && fees.size() > 0) {
        for (String feeSelected : feesSelected) {
            FeeBO fee = getFeeFromList(fees, feeSelected);
            if (fee != null) {
                feeList.add(fee);
            }
        }
    }
    logger.debug("getFeeList method of Loan Product Action called");
    return feeList;
}
Also used : ArrayList(java.util.ArrayList) FeeBO(org.mifos.accounts.fees.business.FeeBO)

Example 18 with FeeBO

use of org.mifos.accounts.fees.business.FeeBO in project head by mifos.

the class LegacyLoanDaoIntegrationTest method testSaveAndGetOriginalLoanScheduleEntityWithFees.

@Test
public void testSaveAndGetOriginalLoanScheduleEntityWithFees() throws PersistenceException {
    ArrayList<OriginalLoanScheduleEntity> originalLoanScheduleEntities = new ArrayList<OriginalLoanScheduleEntity>();
    Date date = new Date(new java.util.Date().getTime());
    Short installmentId = new Short("1");
    FeeBO upfrontFee = TestObjectFactory.createOneTimeRateFee("Upfront Fee", FeeCategory.LOAN, Double.valueOf("20"), FeeFormula.AMOUNT, FeePayment.UPFRONT, null);
    AccountFeesEntity accountUpfrontFee = new AccountFeesEntity(goodAccount, upfrontFee, new Double("20.0"), FeeStatus.ACTIVE.getValue(), null, date);
    AccountTestUtils.addAccountFees(accountUpfrontFee, goodAccount);
    TestObjectFactory.updateObject(goodAccount);
    goodAccount = (LoanBO) TestObjectFactory.getObject(AccountBO.class, goodAccount.getAccountId());
    LoanScheduleEntity loanScheduleEntity = new LoanScheduleEntity(goodAccount, group, installmentId, date, PaymentStatus.UNPAID, Money.zero(), Money.zero());
    LoanFeeScheduleEntity feesEntity = new LoanFeeScheduleEntity(loanScheduleEntity, upfrontFee, accountUpfrontFee, Money.zero());
    loanScheduleEntity.addAccountFeesAction(feesEntity);
    OriginalLoanScheduleEntity originalLoanScheduleEntity = new OriginalLoanScheduleEntity(loanScheduleEntity);
    OriginalLoanFeeScheduleEntity scheduleEntityFee = new OriginalLoanFeeScheduleEntity(feesEntity, originalLoanScheduleEntity);
    originalLoanScheduleEntities.add(originalLoanScheduleEntity);
    legacyLoanDao.saveOriginalSchedule(originalLoanScheduleEntities);
    List<OriginalLoanScheduleEntity> actual = legacyLoanDao.getOriginalLoanScheduleEntity(goodAccount.getAccountId());
    List<OriginalLoanFeeScheduleEntity> fees = new ArrayList<OriginalLoanFeeScheduleEntity>(actual.get(0).getAccountFeesActionDetails());
    Assert.assertEquals(1, actual.size());
    Assert.assertEquals(1, fees.size());
    assertThat(actual, is(new OriginalLoanScheduleEntitiesMatcher(originalLoanScheduleEntities)));
    assertThat(fees.get(0), is(new OriginalLoanFeeScheduleEntityMatcher(scheduleEntityFee)));
}
Also used : OriginalLoanScheduleEntity(org.mifos.accounts.loan.business.OriginalLoanScheduleEntity) LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) OriginalLoanScheduleEntity(org.mifos.accounts.loan.business.OriginalLoanScheduleEntity) OriginalLoanFeeScheduleEntityMatcher(org.mifos.accounts.loan.business.matchers.OriginalLoanFeeScheduleEntityMatcher) ArrayList(java.util.ArrayList) Date(java.sql.Date) OriginalLoanScheduleEntitiesMatcher(org.mifos.accounts.loan.business.matchers.OriginalLoanScheduleEntitiesMatcher) OriginalLoanFeeScheduleEntity(org.mifos.accounts.loan.business.OriginalLoanFeeScheduleEntity) FeeBO(org.mifos.accounts.fees.business.FeeBO) LoanFeeScheduleEntity(org.mifos.accounts.loan.business.LoanFeeScheduleEntity) OriginalLoanFeeScheduleEntity(org.mifos.accounts.loan.business.OriginalLoanFeeScheduleEntity) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Example 19 with FeeBO

use of org.mifos.accounts.fees.business.FeeBO 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)

Example 20 with FeeBO

use of org.mifos.accounts.fees.business.FeeBO in project head by mifos.

the class AccountBusinessService method filterDisbursementFee.

private void filterDisbursementFee(List<FeeBO> feeList, AccountBO account) {
    for (Iterator<FeeBO> iter = feeList.iterator(); iter.hasNext(); ) {
        FeeBO fee = iter.next();
        FeePaymentEntity feePaymentEntity = fee.getFeeFrequency().getFeePayment();
        if (feePaymentEntity != null) {
            Short paymentType = feePaymentEntity.getId();
            if (paymentType.equals(FeePayment.TIME_OF_DISBURSEMENT.getValue())) {
                AccountState accountState = account.getState();
                if (accountState == AccountState.LOAN_PARTIAL_APPLICATION || accountState == AccountState.LOAN_PENDING_APPROVAL || accountState == AccountState.LOAN_APPROVED || accountState == AccountState.LOAN_DISBURSED_TO_LOAN_OFFICER) {
                    continue;
                } else {
                    iter.remove();
                }
            }
        }
    }
}
Also used : FeePaymentEntity(org.mifos.accounts.fees.business.FeePaymentEntity) FeeBO(org.mifos.accounts.fees.business.FeeBO) RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) AccountState(org.mifos.accounts.util.helpers.AccountState)

Aggregations

FeeBO (org.mifos.accounts.fees.business.FeeBO)89 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)50 ArrayList (java.util.ArrayList)40 Test (org.junit.Test)37 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)25 RateFeeBO (org.mifos.accounts.fees.business.RateFeeBO)21 Money (org.mifos.framework.util.helpers.Money)21 MeetingBO (org.mifos.application.meeting.business.MeetingBO)17 Date (java.sql.Date)15 FeeDto (org.mifos.accounts.fees.business.FeeDto)13 MifosRuntimeException (org.mifos.core.MifosRuntimeException)13 GLCodeEntity (org.mifos.accounts.financial.business.GLCodeEntity)11 FundBO (org.mifos.accounts.fund.business.FundBO)10 ApplicationException (org.mifos.framework.exceptions.ApplicationException)10 UserContext (org.mifos.security.util.UserContext)10 AccountBO (org.mifos.accounts.business.AccountBO)9 FeeFrequencyTypeEntity (org.mifos.accounts.fees.business.FeeFrequencyTypeEntity)9 FeeInstallment (org.mifos.accounts.util.helpers.FeeInstallment)9 ScheduledEventBuilder (org.mifos.domain.builders.ScheduledEventBuilder)9 CategoryTypeEntity (org.mifos.accounts.fees.business.CategoryTypeEntity)8