Search in sources :

Example 36 with AccountFeesActionDetailEntity

use of org.mifos.accounts.business.AccountFeesActionDetailEntity in project head by mifos.

the class CustomerAccountBO method updateInstallmentAfterAdjustment.

@Override
protected void updateInstallmentAfterAdjustment(final List<AccountTrxnEntity> reversedTrxns, PersonnelBO loggedInUser) throws AccountException {
    if (null != reversedTrxns && reversedTrxns.size() > 0) {
        Money totalAmountAdj = new Money(getCurrency());
        for (AccountTrxnEntity accntTrxn : reversedTrxns) {
            CustomerTrxnDetailEntity custTrxn = (CustomerTrxnDetailEntity) accntTrxn;
            CustomerScheduleEntity accntActionDate = (CustomerScheduleEntity) getAccountActionDate(custTrxn.getInstallmentId());
            accntActionDate.setPaymentStatus(PaymentStatus.UNPAID);
            accntActionDate.setPaymentDate(null);
            accntActionDate.setMiscFeePaid(accntActionDate.getMiscFeePaid().add(custTrxn.getMiscFeeAmount()));
            totalAmountAdj = totalAmountAdj.add(removeSign(custTrxn.getMiscFeeAmount()));
            accntActionDate.setMiscPenaltyPaid(accntActionDate.getMiscPenaltyPaid().add(custTrxn.getMiscPenaltyAmount()));
            totalAmountAdj = totalAmountAdj.add(removeSign(custTrxn.getMiscPenaltyAmount()));
            if (null != accntActionDate.getAccountFeesActionDetails() && accntActionDate.getAccountFeesActionDetails().size() > 0) {
                for (AccountFeesActionDetailEntity accntFeesAction : accntActionDate.getAccountFeesActionDetails()) {
                    Money feeAmntAdjusted = custTrxn.getFeesTrxn(accntFeesAction.getAccountFee().getAccountFeeId()).getFeeAmount();
                    ((CustomerFeeScheduleEntity) accntFeesAction).setFeeAmountPaid(accntFeesAction.getFeeAmountPaid().add(feeAmntAdjusted));
                    totalAmountAdj = totalAmountAdj.add(removeSign(feeAmntAdjusted));
                }
            }
        }
        addCustomerActivity(buildCustomerActivity(totalAmountAdj, AccountConstants.AMNT_ADJUSTED, userContext.getId()));
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) AccountTrxnEntity(org.mifos.accounts.business.AccountTrxnEntity) AccountFeesActionDetailEntity(org.mifos.accounts.business.AccountFeesActionDetailEntity)

Example 37 with AccountFeesActionDetailEntity

use of org.mifos.accounts.business.AccountFeesActionDetailEntity in project head by mifos.

the class CustomerAccountBO method dueAmountForCustomerSchedule.

private BigDecimal dueAmountForCustomerSchedule(CustomerScheduleEntity customerSchedule) {
    BigDecimal totalAllUnpaidInstallments = customerSchedule.getMiscFeeDue().getAmount();
    totalAllUnpaidInstallments = totalAllUnpaidInstallments.add(customerSchedule.getMiscPenaltyDue().getAmount());
    for (AccountFeesActionDetailEntity accountFeesActionDetail : customerSchedule.getAccountFeesActionDetails()) {
        CustomerFeeScheduleEntity customerFeeSchedule = (CustomerFeeScheduleEntity) accountFeesActionDetail;
        totalAllUnpaidInstallments = totalAllUnpaidInstallments.add(customerFeeSchedule.getFeeDue().getAmount());
    }
    return totalAllUnpaidInstallments;
}
Also used : AccountFeesActionDetailEntity(org.mifos.accounts.business.AccountFeesActionDetailEntity) BigDecimal(java.math.BigDecimal)

Example 38 with AccountFeesActionDetailEntity

use of org.mifos.accounts.business.AccountFeesActionDetailEntity in project head by mifos.

the class CustomerAccountBO method updateUpcomingAndFutureInstallments.

private void updateUpcomingAndFutureInstallments(final AccountFeesEntity fee) {
    CustomerScheduleEntity nextInstallment = (CustomerScheduleEntity) getDetailsOfNextInstallment();
    AccountFeesActionDetailEntity nextAccountFeesActionDetail = null;
    if (nextInstallment != null) {
        nextAccountFeesActionDetail = nextInstallment.getAccountFeesAction(fee.getAccountFeeId());
    }
    if (nextAccountFeesActionDetail != null) {
        ((CustomerFeeScheduleEntity) nextAccountFeesActionDetail).setFeeAmount(fee.getAccountFeeAmount());
    }
    List<AccountActionDateEntity> futureInstallments = getFutureInstallments();
    for (AccountActionDateEntity accountActionDateEntity : futureInstallments) {
        CustomerScheduleEntity installment = (CustomerScheduleEntity) accountActionDateEntity;
        AccountFeesActionDetailEntity accountFeesActionDetail = installment.getAccountFeesAction(fee.getAccountFeeId());
        if (accountFeesActionDetail != null) {
            ((CustomerFeeScheduleEntity) accountFeesActionDetail).setFeeAmount(fee.getAccountFeeAmount());
        }
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) AccountFeesActionDetailEntity(org.mifos.accounts.business.AccountFeesActionDetailEntity)

Example 39 with AccountFeesActionDetailEntity

use of org.mifos.accounts.business.AccountFeesActionDetailEntity in project head by mifos.

the class DefaultLoanScheduleRounderHelper method adjustLastInstallmentFees_v2.

/**
     * adjust the first fee in the installment's set of fees
     */
private void adjustLastInstallmentFees_v2(final LoanScheduleEntity lastInstallment, final RepaymentTotals totals, MifosCurrency mifosCurrency) {
    Set<AccountFeesActionDetailEntity> feeDetails = lastInstallment.getAccountFeesActionDetails();
    if (!(feeDetails == null) && !feeDetails.isEmpty()) {
        Money lastInstallmentFeeSum = new Money(mifosCurrency);
        for (AccountFeesActionDetailEntity e : feeDetails) {
            lastInstallmentFeeSum = lastInstallmentFeeSum.add(e.getFeeAmount());
        }
        for (Object element : feeDetails) {
            AccountFeesActionDetailEntity e = (AccountFeesActionDetailEntity) element;
            e.adjustFeeAmount(totals.getRoundedAccountFeesDue().subtract(totals.getRunningAccountFees()).subtract(lastInstallmentFeeSum));
            // just adjust the first fee
            return;
        }
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) AccountFeesActionDetailEntity(org.mifos.accounts.business.AccountFeesActionDetailEntity)

Aggregations

AccountFeesActionDetailEntity (org.mifos.accounts.business.AccountFeesActionDetailEntity)39 Money (org.mifos.framework.util.helpers.Money)21 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)9 ArrayList (java.util.ArrayList)8 LoanScheduleEntity (org.mifos.accounts.loan.business.LoanScheduleEntity)8 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)7 BigDecimal (java.math.BigDecimal)6 FeesTrxnDetailEntity (org.mifos.accounts.business.FeesTrxnDetailEntity)6 Date (java.sql.Date)5 CustomerScheduleEntity (org.mifos.customers.business.CustomerScheduleEntity)5 Date (java.util.Date)4 LocalDate (org.joda.time.LocalDate)4 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)4 AccountException (org.mifos.accounts.exceptions.AccountException)4 FeeBO (org.mifos.accounts.fees.business.FeeBO)4 MeetingBO (org.mifos.application.meeting.business.MeetingBO)4 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)4 Test (org.junit.Test)3 AccountTrxnEntity (org.mifos.accounts.business.AccountTrxnEntity)3 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)3