Search in sources :

Example 16 with FinancialActionTypeEntity

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

the class CustomerAccountFeesAccountingEntry method applySpecificAccountActionEntry.

@Override
protected void applySpecificAccountActionEntry() throws FinancialException {
    CustomerTrxnDetailEntity customertrxn = (CustomerTrxnDetailEntity) financialActivity.getAccountTrxn();
    Set<FeesTrxnDetailEntity> feesTrxns = customertrxn.getFeesTrxnDetails();
    FinancialActionTypeEntity finActionFee = getFinancialAction(FinancialActionConstants.FEEPOSTING);
    for (FeesTrxnDetailEntity feeTrxn : feesTrxns) {
        addAccountEntryDetails(feeTrxn.getFeeAmount(), finActionFee, feeTrxn.getAccountFees().getFees().getGlCode(), FinancialConstants.CREDIT);
        addAccountEntryDetails(feeTrxn.getFeeAmount(), finActionFee, getGLcode(finActionFee.getApplicableDebitCharts()), FinancialConstants.DEBIT);
    }
    // For Misc Fee
    FinancialActionTypeEntity finActionMiscFee = FinancialActionCache.getFinancialAction(FinancialActionConstants.CUSTOMERACCOUNTMISCFEESPOSTING);
    addAccountEntryDetails(customertrxn.getMiscFeeAmount(), finActionMiscFee, getGLcode(finActionMiscFee.getApplicableDebitCharts()), FinancialConstants.DEBIT);
    addAccountEntryDetails(customertrxn.getMiscFeeAmount(), finActionMiscFee, getGLcode(finActionMiscFee.getApplicableCreditCharts()), FinancialConstants.CREDIT);
}
Also used : CustomerTrxnDetailEntity(org.mifos.customers.business.CustomerTrxnDetailEntity) FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity) FeesTrxnDetailEntity(org.mifos.accounts.business.FeesTrxnDetailEntity)

Example 17 with FinancialActionTypeEntity

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

the class FeesAccountingEntry method applySpecificAccountActionEntry.

@Override
protected void applySpecificAccountActionEntry() throws FinancialException {
    LoanTrxnDetailEntity loanTrxn = (LoanTrxnDetailEntity) financialActivity.getAccountTrxn();
    Set<FeesTrxnDetailEntity> feesTrxn = loanTrxn.getFeesTrxnDetails();
    Iterator<FeesTrxnDetailEntity> iterFees = feesTrxn.iterator();
    FinancialActionTypeEntity finActionFee = getFinancialAction(FinancialActionConstants.FEEPOSTING);
    while (iterFees.hasNext()) {
        FeesTrxnDetailEntity feeTrxn = iterFees.next();
        addAccountEntryDetails(feeTrxn.getFeeAmount(), finActionFee, feeTrxn.getAccountFees().getFees().getGlCode(), FinancialConstants.CREDIT);
        addAccountEntryDetails(feeTrxn.getFeeAmount(), finActionFee, getGLcode(finActionFee.getApplicableDebitCharts()), FinancialConstants.DEBIT);
    }
    // For Misc Fee
    FinancialActionTypeEntity finActionMiscFee = FinancialActionCache.getFinancialAction(FinancialActionConstants.MISCFEEPOSTING);
    addAccountEntryDetails(loanTrxn.getMiscFeeAmount(), finActionMiscFee, getGLcode(finActionMiscFee.getApplicableDebitCharts()), FinancialConstants.DEBIT);
    addAccountEntryDetails(loanTrxn.getMiscFeeAmount(), finActionMiscFee, getGLcode(finActionMiscFee.getApplicableCreditCharts()), FinancialConstants.CREDIT);
}
Also used : FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity) LoanTrxnDetailEntity(org.mifos.accounts.loan.business.LoanTrxnDetailEntity) FeesTrxnDetailEntity(org.mifos.accounts.business.FeesTrxnDetailEntity)

Example 18 with FinancialActionTypeEntity

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

the class InterestAccountingEntry method applySpecificAccountActionEntry.

@Override
protected void applySpecificAccountActionEntry() throws FinancialException {
    LoanTrxnDetailEntity loanTrxn = (LoanTrxnDetailEntity) financialActivity.getAccountTrxn();
    GLCodeEntity glcodeCredit = ((LoanBO) loanTrxn.getAccount()).getLoanOffering().getInterestGLcode();
    FinancialActionTypeEntity finActionInterest = FinancialActionCache.getFinancialAction(FinancialActionConstants.INTERESTPOSTING);
    addAccountEntryDetails(loanTrxn.getInterestAmount(), finActionInterest, getGLcode(finActionInterest.getApplicableDebitCharts()), FinancialConstants.DEBIT);
    addAccountEntryDetails(loanTrxn.getInterestAmount(), finActionInterest, glcodeCredit, FinancialConstants.CREDIT);
    LoanBO loan = (LoanBO) loanTrxn.getAccount();
    // interest account
    if (!loan.isLegacyLoan()) {
        boolean isLastPayment = ((LoanBO) loanTrxn.getAccount()).isLastInstallment(loanTrxn.getInstallmentId());
        // if the final payment is made early there will be no interest
        // charged so no 999 account
        boolean interestIsCharged = loanTrxn.getInterestAmount().isGreaterThanZero();
        if (isLastPayment && interestIsCharged) {
            log999Account(loanTrxn, isLastPayment, glcodeCredit);
        }
    }
}
Also used : 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 19 with FinancialActionTypeEntity

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

the class InterestAccountingEntry method log999Account.

private void log999Account(LoanTrxnDetailEntity loanTrxn, boolean isLastPayment, GLCodeEntity glcodeCredit) throws FinancialException {
    Money account999 = ((LoanBO) loanTrxn.getAccount()).calculate999Account(isLastPayment);
    Money zeroAmount = new Money(account999.getCurrency(), "0");
    // only log if amount > or < 0
    if (account999.equals(zeroAmount)) {
        return;
    }
    FinancialActionTypeEntity finActionRounding = FinancialActionCache.getFinancialAction(FinancialActionConstants.ROUNDING);
    GLCodeEntity codeToDebit = null;
    GLCodeEntity codeToCredit = null;
    if (account999.isGreaterThanZero()) {
        // this code is defined as below in chart of account
        // <GLAccount code="31401" name="Income from 999 Account" />
        codeToDebit = glcodeCredit;
        codeToCredit = getGLcode(finActionRounding.getApplicableCreditCharts());
    } else if (account999.isLessThanZero()) {
        codeToDebit = getGLcode(finActionRounding.getApplicableDebitCharts());
        codeToCredit = glcodeCredit;
        account999 = account999.negate();
    }
    addAccountEntryDetails(account999, finActionRounding, codeToDebit, FinancialConstants.DEBIT);
    addAccountEntryDetails(account999, finActionRounding, codeToCredit, 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)

Example 20 with FinancialActionTypeEntity

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

the class FinancialActionCacheIntegrationTest method testFinancialActionCache.

@Test
public void testFinancialActionCache() throws FinancialException {
    FinancialActionCache.addToCache(createFinancialAction());
    FinancialActionTypeEntity principalAction = FinancialActionCache.getFinancialAction(FinancialActionConstants.PRINCIPALPOSTING);
    Assert.assertEquals(principalAction.getId().shortValue(), 1);
}
Also used : FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity) Test(org.junit.Test)

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