Search in sources :

Example 16 with Money

use of org.mifos.framework.util.helpers.Money in project head by mifos.

the class LoanBO method waivePenaltyAmountDue.

private void waivePenaltyAmountDue() throws AccountException {
    List<AccountActionDateEntity> accountActionDateList = getApplicableIdsForNextInstallmentAndArrears();
    LoanScheduleEntity accountActionDateEntity = (LoanScheduleEntity) accountActionDateList.get(accountActionDateList.size() - 1);
    Money principal = new Money(getCurrency());
    Money interest = new Money(getCurrency());
    Money fee = new Money(getCurrency());
    Money chargeWaived = accountActionDateEntity.waivePenaltyCharges();
    if (chargeWaived != null && chargeWaived.isGreaterThanZero()) {
        updateTotalPenaltyAmount(chargeWaived);
        updateAccountActivity(principal, interest, fee, chargeWaived, userContext.getId(), LoanConstants.PENALTY_WAIVED);
        waiveChargesFromMemberAccounts(LoanConstants.PENALTY_WAIVED);
    }
    try {
        getlegacyLoanDao().createOrUpdate(this);
    } catch (PersistenceException e) {
        throw new AccountException(e);
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) Money(org.mifos.framework.util.helpers.Money) AccountException(org.mifos.accounts.exceptions.AccountException) PersistenceException(org.mifos.framework.exceptions.PersistenceException)

Example 17 with Money

use of org.mifos.framework.util.helpers.Money in project head by mifos.

the class LoanBO method getTotalInterestToBePaid.

public Money getTotalInterestToBePaid() {
    Money amount = new Money(getCurrency());
    List<AccountActionDateEntity> actionDateList = getAllInstallments();
    for (AccountActionDateEntity accountActionDateEntity : actionDateList) {
        LoanScheduleEntity loanScheduleEntity = (LoanScheduleEntity) accountActionDateEntity;
        amount = amount.add(loanScheduleEntity.getInterest());
    }
    return amount;
}
Also used : Money(org.mifos.framework.util.helpers.Money) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity)

Example 18 with Money

use of org.mifos.framework.util.helpers.Money in project head by mifos.

the class LoanPenaltyScheduleEntity method waiveCharges.

protected Money waiveCharges() {
    Money chargeWaived = new Money(accountPenalty.getAccount().getCurrency());
    chargeWaived = chargeWaived.add(getPenaltyDue());
    setPenaltyAmount(getPenaltyAmountPaid());
    return chargeWaived;
}
Also used : Money(org.mifos.framework.util.helpers.Money)

Example 19 with Money

use of org.mifos.framework.util.helpers.Money in project head by mifos.

the class LoanPenaltyScheduleEntity method adjustPenalties.

void adjustPenalties(PenaltiesTrxnDetailEntity penaltiesTrxnDetailEntity) {
    Money penaltyAmntAdjusted = penaltiesTrxnDetailEntity.getPenaltyAmount();
    setPenaltyAmountPaid(getPenaltyAmountPaid().add(penaltyAmntAdjusted));
}
Also used : Money(org.mifos.framework.util.helpers.Money)

Example 20 with Money

use of org.mifos.framework.util.helpers.Money in project head by mifos.

the class LoanScheduleEntity method payPenalty.

private Money payPenalty(final Money amount) {
    Money payable = min(amount, (getPenalty().subtract(getPenaltyPaid())));
    Money balance = amount;
    allocatePenalty(payable);
    for (LoanPenaltyScheduleEntity loanPenaltyScheduleEntity : getLoanPenaltyScheduleEntities()) {
        balance = loanPenaltyScheduleEntity.payPenalty(balance);
        Integer penaltyId = loanPenaltyScheduleEntity.getLoanPenaltyScheduleEntityId();
        if (penaltyId == null) {
            // special workaround for MIFOS-4517
            penaltyId = loanPenaltyScheduleEntity.hashCode();
        }
        Money penaltyAllocated = loanPenaltyScheduleEntity.getPenaltyAllocated();
        paymentAllocation.allocateForPenalty(penaltyId, penaltyAllocated);
    }
    return amount.subtract(payable);
}
Also used : Money(org.mifos.framework.util.helpers.Money)

Aggregations

Money (org.mifos.framework.util.helpers.Money)688 Test (org.junit.Test)326 Date (java.util.Date)110 ArrayList (java.util.ArrayList)93 LocalDate (org.joda.time.LocalDate)90 Date (java.sql.Date)85 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)80 DateTime (org.joda.time.DateTime)67 LoanBO (org.mifos.accounts.loan.business.LoanBO)64 MeetingBO (org.mifos.application.meeting.business.MeetingBO)57 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)56 BigDecimal (java.math.BigDecimal)53 ProductDefinitionException (org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException)49 AccountException (org.mifos.accounts.exceptions.AccountException)48 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)46 UserContext (org.mifos.security.util.UserContext)46 CustomerBO (org.mifos.customers.business.CustomerBO)39 MifosUser (org.mifos.security.MifosUser)35 RepaymentScheduleInstallment (org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment)34 PaymentData (org.mifos.accounts.util.helpers.PaymentData)34