Search in sources :

Example 26 with FinancialActionTypeEntity

use of org.mifos.accounts.financial.business.FinancialActionTypeEntity 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 27 with FinancialActionTypeEntity

use of org.mifos.accounts.financial.business.FinancialActionTypeEntity 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 28 with FinancialActionTypeEntity

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

Example 29 with FinancialActionTypeEntity

use of org.mifos.accounts.financial.business.FinancialActionTypeEntity in project head by mifos.

the class SavingsAdjustmentAccountingEntry method adjustWithdrawal.

private void adjustWithdrawal(SavingsBO savings, SavingsTrxnDetailEntity savingsTrxn) throws FinancialException {
    FinancialActionTypeEntity finActionWithrawal = null;
    if (savings.isMandatory()) {
        finActionWithrawal = getFinancialAction(FinancialActionConstants.MANDATORYWITHDRAWAL_ADJUSTMENT);
    } else if (savings.isVoluntary()) {
        finActionWithrawal = getFinancialAction(FinancialActionConstants.VOLUNTARYWITHDRAWAL_ADJUSTMENT);
    }
    addAccountEntryDetails(savingsTrxn.getWithdrawlAmount(), finActionWithrawal, savings.getSavingsOffering().getDepositGLCode(), FinancialConstants.CREDIT);
    addAccountEntryDetails(savingsTrxn.getWithdrawlAmount(), finActionWithrawal, getGLcode(finActionWithrawal.getApplicableDebitCharts()), FinancialConstants.DEBIT);
}
Also used : FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity)

Example 30 with FinancialActionTypeEntity

use of org.mifos.accounts.financial.business.FinancialActionTypeEntity in project head by mifos.

the class SavingsAdjustmentAccountingEntry method adjustDeposit.

private void adjustDeposit(SavingsBO savings, SavingsTrxnDetailEntity savingsTrxn) throws FinancialException {
    FinancialActionTypeEntity finActionDeposit = null;
    if (savings.isMandatory()) {
        finActionDeposit = getFinancialAction(FinancialActionConstants.MANDATORYDEPOSIT_ADJUSTMENT);
    } else if (savings.isVoluntary()) {
        finActionDeposit = getFinancialAction(FinancialActionConstants.VOLUNTARYDEPOSIT_ADJUSTMENT);
    }
    addAccountEntryDetails(savingsTrxn.getDepositAmount(), finActionDeposit, getGLcode(finActionDeposit.getApplicableCreditCharts()), FinancialConstants.CREDIT);
    addAccountEntryDetails(savingsTrxn.getDepositAmount(), finActionDeposit, savings.getSavingsOffering().getDepositGLCode(), FinancialConstants.DEBIT);
}
Also used : FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity)

Aggregations

FinancialActionTypeEntity (org.mifos.accounts.financial.business.FinancialActionTypeEntity)31 GLCodeEntity (org.mifos.accounts.financial.business.GLCodeEntity)14 LoanTrxnDetailEntity (org.mifos.accounts.loan.business.LoanTrxnDetailEntity)10 Money (org.mifos.framework.util.helpers.Money)7 COABO (org.mifos.accounts.financial.business.COABO)6 LoanBO (org.mifos.accounts.loan.business.LoanBO)5 FeesTrxnDetailEntity (org.mifos.accounts.business.FeesTrxnDetailEntity)4 BeforeClass (org.junit.BeforeClass)3 FinancialActionConstants (org.mifos.accounts.financial.util.helpers.FinancialActionConstants)3 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)3 SavingsTrxnDetailEntity (org.mifos.accounts.savings.business.SavingsTrxnDetailEntity)3 CustomerTrxnDetailEntity (org.mifos.customers.business.CustomerTrxnDetailEntity)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 FinancialException (org.mifos.accounts.financial.exceptions.FinancialException)2 ChartOfAccountsCache (org.mifos.accounts.financial.util.helpers.ChartOfAccountsCache)2 IOException (java.io.IOException)1 Query (org.hibernate.Query)1 Session (org.hibernate.Session)1