Search in sources :

Example 11 with LoanTrxnDetailEntity

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

the class TestObjectFactory method deleteAccountPayment.

private static void deleteAccountPayment(final AccountPaymentEntity accountPayment, final Session session) {
    Set<AccountTrxnEntity> loanTrxns = accountPayment.getAccountTrxns();
    for (AccountTrxnEntity accountTrxn : loanTrxns) {
        if (accountTrxn instanceof LoanTrxnDetailEntity) {
            LoanTrxnDetailEntity loanTrxn = (LoanTrxnDetailEntity) accountTrxn;
            for (FeesTrxnDetailEntity feesTrxn : loanTrxn.getFeesTrxnDetails()) {
                session.delete(feesTrxn);
            }
            for (FinancialTransactionBO financialTrxn : loanTrxn.getFinancialTransactions()) {
                session.delete(financialTrxn);
            }
            session.delete(loanTrxn);
        }
    }
    session.delete(accountPayment);
}
Also used : AccountTrxnEntity(org.mifos.accounts.business.AccountTrxnEntity) FinancialTransactionBO(org.mifos.accounts.financial.business.FinancialTransactionBO) LoanTrxnDetailEntity(org.mifos.accounts.loan.business.LoanTrxnDetailEntity) FeesTrxnDetailEntity(org.mifos.accounts.business.FeesTrxnDetailEntity)

Example 12 with LoanTrxnDetailEntity

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

the class PenaltyAccountingEntry method applySpecificAccountActionEntry.

@Override
protected void applySpecificAccountActionEntry() throws FinancialException {
    if (financialActivity.getAccountTrxn() instanceof LoanTrxnDetailEntity) {
        LoanTrxnDetailEntity loanTrxn = (LoanTrxnDetailEntity) financialActivity.getAccountTrxn();
        Set<PenaltiesTrxnDetailEntity> penaltiesTrxn = loanTrxn.getPenaltiesTrxnDetails();
        Iterator<PenaltiesTrxnDetailEntity> iterPenalties = penaltiesTrxn.iterator();
        FinancialActionTypeEntity finActionPenalty = getFinancialAction(FinancialActionConstants.PENALTYPOSTING);
        while (iterPenalties.hasNext()) {
            PenaltiesTrxnDetailEntity penaltyTrxn = iterPenalties.next();
            addAccountEntryDetails(penaltyTrxn.getPenaltyAmount(), finActionPenalty, penaltyTrxn.getAccountPenalties().getPenalty().getGlCode(), FinancialConstants.CREDIT);
            addAccountEntryDetails(penaltyTrxn.getPenaltyAmount(), finActionPenalty, getGLcode(finActionPenalty.getApplicableDebitCharts()), FinancialConstants.DEBIT);
        }
        FinancialActionTypeEntity finActionMiscPenalty = FinancialActionCache.getFinancialAction(FinancialActionConstants.MISCPENALTYPOSTING);
        addAccountEntryDetails(loanTrxn.getMiscPenaltyAmount(), finActionMiscPenalty, getGLcode(finActionMiscPenalty.getApplicableDebitCharts()), FinancialConstants.DEBIT);
        addAccountEntryDetails(loanTrxn.getMiscPenaltyAmount(), finActionMiscPenalty, getGLcode(finActionMiscPenalty.getApplicableCreditCharts()), FinancialConstants.CREDIT);
    } else {
        Money amount = financialActivity.getMiscPenaltyAmount();
        FinancialActionTypeEntity finActionMiscPenalty = FinancialActionCache.getFinancialAction(FinancialActionConstants.MISCPENALTYPOSTING);
        addAccountEntryDetails(amount, finActionMiscPenalty, getGLcode(finActionMiscPenalty.getApplicableDebitCharts()), FinancialConstants.DEBIT);
        addAccountEntryDetails(amount, finActionMiscPenalty, getGLcode(finActionMiscPenalty.getApplicableCreditCharts()), FinancialConstants.CREDIT);
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity) LoanTrxnDetailEntity(org.mifos.accounts.loan.business.LoanTrxnDetailEntity) PenaltiesTrxnDetailEntity(org.mifos.accounts.business.PenaltiesTrxnDetailEntity)

Example 13 with LoanTrxnDetailEntity

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

the class PrincipalAccountingEntry method applySpecificAccountActionEntry.

@Override
protected void applySpecificAccountActionEntry() throws FinancialException {
    LoanTrxnDetailEntity loanTrxn = (LoanTrxnDetailEntity) financialActivity.getAccountTrxn();
    GLCodeEntity glcodeCredit = ((LoanBO) loanTrxn.getAccount()).getLoanOffering().getPrincipalGLcode();
    Money principalAmountNotRounded = loanTrxn.getPrincipalAmount();
    Money amountToPost = null;
    if (((LoanBO) loanTrxn.getAccount()).isLastInstallment(loanTrxn.getInstallmentId())) {
        amountToPost = Money.round(loanTrxn.getPrincipalAmount(), AccountingRules.getFinalRoundOffMultiple(loanTrxn.getPrincipalAmount().getCurrency()), AccountingRules.getCurrencyRoundingMode());
    } else {
        amountToPost = principalAmountNotRounded;
    }
    FinancialActionTypeEntity finActionPrincipal = FinancialActionCache.getFinancialAction(FinancialActionConstants.PRINCIPALPOSTING);
    addAccountEntryDetails(amountToPost, finActionPrincipal, getGLcode(finActionPrincipal.getApplicableDebitCharts()), FinancialConstants.DEBIT);
    addAccountEntryDetails(amountToPost, finActionPrincipal, glcodeCredit, FinancialConstants.CREDIT);
    LoanBO loan = (LoanBO) loanTrxn.getAccount();
    // interest account and not to the principal account
    if (!loan.isLegacyLoan()) {
        return;
    }
    // v1 version log the 999 account to the principal account
    // check if rounding is required
    FinancialActionTypeEntity finActionRounding = FinancialActionCache.getFinancialAction(FinancialActionConstants.ROUNDING);
    if (amountToPost.getAmount().compareTo(principalAmountNotRounded.getAmount()) > 0) {
        addAccountEntryDetails(amountToPost.subtract(principalAmountNotRounded), finActionRounding, glcodeCredit, FinancialConstants.DEBIT);
        addAccountEntryDetails(amountToPost.subtract(principalAmountNotRounded), finActionRounding, getGLcode(finActionRounding.getApplicableCreditCharts()), FinancialConstants.CREDIT);
    } else if (amountToPost.getAmount().compareTo(principalAmountNotRounded.getAmount()) < 0) {
        addAccountEntryDetails(principalAmountNotRounded.subtract(amountToPost), finActionRounding, getGLcode(finActionRounding.getApplicableDebitCharts()), FinancialConstants.DEBIT);
        addAccountEntryDetails(principalAmountNotRounded.subtract(amountToPost), finActionRounding, glcodeCredit, FinancialConstants.CREDIT);
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity) LoanBO(org.mifos.accounts.loan.business.LoanBO) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) LoanTrxnDetailEntity(org.mifos.accounts.loan.business.LoanTrxnDetailEntity)

Example 14 with LoanTrxnDetailEntity

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

the class PrincipalAdjustmentAccountingEntry method applySpecificAccountActionEntry.

@Override
protected void applySpecificAccountActionEntry() throws FinancialException {
    LoanTrxnDetailEntity loanTrxn = (LoanTrxnDetailEntity) financialActivity.getAccountTrxn();
    GLCodeEntity glcodeCredit = ((LoanBO) loanTrxn.getAccount()).getLoanOffering().getPrincipalGLcode();
    FinancialActionTypeEntity finActionPrincipal = FinancialActionCache.getFinancialAction(FinancialActionConstants.PRINCIPALPOSTING);
    addAccountEntryDetails(loanTrxn.getPrincipalAmount(), finActionPrincipal, getGLcode(finActionPrincipal.getApplicableDebitCharts()), FinancialConstants.CREDIT);
    addAccountEntryDetails(loanTrxn.getPrincipalAmount(), finActionPrincipal, glcodeCredit, FinancialConstants.DEBIT);
    LoanBO loan = (LoanBO) loanTrxn.getAccount();
    if (!loan.isLegacyLoan()) {
        return;
    }
    // check if rounding is required
    Money roundedAmount = Money.round(loanTrxn.getPrincipalAmount(), loanTrxn.getPrincipalAmount().getCurrency().getRoundingAmount(), AccountingRules.getCurrencyRoundingMode());
    if (!roundedAmount.equals(loanTrxn.getPrincipalAmount())) {
        FinancialActionTypeEntity finActionRounding = FinancialActionCache.getFinancialAction(FinancialActionConstants.ROUNDING);
        addAccountEntryDetails(roundedAmount.subtract(loanTrxn.getPrincipalAmount()).negate(), finActionRounding, getGLcode(finActionPrincipal.getApplicableCreditCharts()), FinancialConstants.CREDIT);
        addAccountEntryDetails(roundedAmount.subtract(loanTrxn.getPrincipalAmount()), finActionRounding, getGLcode(finActionRounding.getApplicableCreditCharts()), FinancialConstants.DEBIT);
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity) LoanBO(org.mifos.accounts.loan.business.LoanBO) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) LoanTrxnDetailEntity(org.mifos.accounts.loan.business.LoanTrxnDetailEntity)

Example 15 with LoanTrxnDetailEntity

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

the class RescheduleAccountingEntry method applySpecificAccountActionEntry.

@Override
protected void applySpecificAccountActionEntry() throws FinancialException {
    LoanTrxnDetailEntity loanTrxn = (LoanTrxnDetailEntity) financialActivity.getAccountTrxn();
    FinancialActionTypeEntity finActionReschedule = FinancialActionCache.getFinancialAction(FinancialActionConstants.RESCHEDULE);
    addAccountEntryDetails(loanTrxn.getPrincipalAmount(), finActionReschedule, getGLcode(finActionReschedule.getApplicableDebitCharts()), FinancialConstants.DEBIT);
    GLCodeEntity glcodeCredit = ((LoanBO) loanTrxn.getAccount()).getLoanOffering().getPrincipalGLcode();
    addAccountEntryDetails(loanTrxn.getPrincipalAmount(), finActionReschedule, glcodeCredit, FinancialConstants.CREDIT);
// no 999 account entries are made for close-rescheduled loans because
// if some payments have already been made
// the 999 account amount is probably very small and is ignored in 1.1
// release. In the future if we want to
// calculate the 999 amount in this case we need to store the raw amount
// for each installment.
}
Also used : FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) LoanTrxnDetailEntity(org.mifos.accounts.loan.business.LoanTrxnDetailEntity)

Aggregations

LoanTrxnDetailEntity (org.mifos.accounts.loan.business.LoanTrxnDetailEntity)16 FinancialActionTypeEntity (org.mifos.accounts.financial.business.FinancialActionTypeEntity)10 GLCodeEntity (org.mifos.accounts.financial.business.GLCodeEntity)7 LoanBO (org.mifos.accounts.loan.business.LoanBO)5 Money (org.mifos.framework.util.helpers.Money)5 Date (java.sql.Date)4 FeesTrxnDetailEntity (org.mifos.accounts.business.FeesTrxnDetailEntity)4 Test (org.junit.Test)3 FinancialTransactionBO (org.mifos.accounts.financial.business.FinancialTransactionBO)3 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)3 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)2 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)2 PaymentTypeEntity (org.mifos.application.master.business.PaymentTypeEntity)2 ArrayList (java.util.ArrayList)1 AccountFeesActionDetailEntity (org.mifos.accounts.business.AccountFeesActionDetailEntity)1 AccountTrxnEntity (org.mifos.accounts.business.AccountTrxnEntity)1 PenaltiesTrxnDetailEntity (org.mifos.accounts.business.PenaltiesTrxnDetailEntity)1 COABO (org.mifos.accounts.financial.business.COABO)1 LoanScheduleEntity (org.mifos.accounts.loan.business.LoanScheduleEntity)1 PaymentData (org.mifos.accounts.util.helpers.PaymentData)1