Search in sources :

Example 21 with FinancialActionTypeEntity

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

the class SavingsCloseTest method setupChartOfAccountsAndFinancialTransactions.

@BeforeClass
public static void setupChartOfAccountsAndFinancialTransactions() {
    defaultCurrency = TestUtils.RUPEE;
    Money.setDefaultCurrency(defaultCurrency);
    Short glcodeId = Short.valueOf("1");
    String glcode = "123456";
    GLCodeEntity glCodeEntity = new GLCodeEntity(glcodeId, glcode);
    COABO coabo = new COABO("testAccountName", glCodeEntity);
    ChartOfAccountsCache chartOfAccountsCache = new ChartOfAccountsCache();
    chartOfAccountsCache.clear();
    chartOfAccountsCache.add(coabo);
    Map<FinancialActionConstants, String> actionToCreditAccount = new HashMap<FinancialActionConstants, String>();
    actionToCreditAccount.put(FinancialActionConstants.SAVINGS_INTERESTPOSTING, glcode);
    actionToCreditAccount.put(FinancialActionConstants.MANDATORYDEPOSIT, glcode);
    actionToCreditAccount.put(FinancialActionConstants.MANDATORYWITHDRAWAL, glcode);
    actionToCreditAccount.put(FinancialActionConstants.MANDATORYDEPOSIT_ADJUSTMENT, glcode);
    actionToCreditAccount.put(FinancialActionConstants.MANDATORYWITHDRAWAL_ADJUSTMENT, glcode);
    actionToCreditAccount.put(FinancialActionConstants.ROUNDING, glcode);
    FinancialRules.getInstance().setActionToCreditAccount(actionToCreditAccount);
    Map<FinancialActionConstants, String> actionToDebitAccount = new HashMap<FinancialActionConstants, String>();
    actionToDebitAccount.put(FinancialActionConstants.SAVINGS_INTERESTPOSTING, glcode);
    actionToDebitAccount.put(FinancialActionConstants.MANDATORYDEPOSIT, glcode);
    actionToDebitAccount.put(FinancialActionConstants.MANDATORYWITHDRAWAL, glcode);
    actionToDebitAccount.put(FinancialActionConstants.MANDATORYDEPOSIT_ADJUSTMENT, glcode);
    actionToDebitAccount.put(FinancialActionConstants.MANDATORYWITHDRAWAL_ADJUSTMENT, glcode);
    actionToDebitAccount.put(FinancialActionConstants.ROUNDING, glcode);
    FinancialRules.getInstance().setActionToDebitAccount(actionToDebitAccount);
    FinancialActionTypeEntity roundingAction = new FinancialActionTypeEntity();
    roundingAction.setId(FinancialActionConstants.ROUNDING.getValue());
    FinancialActionTypeEntity depositAction = new FinancialActionTypeEntity();
    depositAction.setId(FinancialActionConstants.MANDATORYDEPOSIT.getValue());
    FinancialActionTypeEntity withdrawalAction = new FinancialActionTypeEntity();
    withdrawalAction.setId(FinancialActionConstants.MANDATORYWITHDRAWAL.getValue());
    FinancialActionTypeEntity depositAdjustmentAction = new FinancialActionTypeEntity();
    depositAdjustmentAction.setId(FinancialActionConstants.MANDATORYDEPOSIT_ADJUSTMENT.getValue());
    FinancialActionTypeEntity withdrawalAdjustmentAction = new FinancialActionTypeEntity();
    withdrawalAdjustmentAction.setId(FinancialActionConstants.MANDATORYWITHDRAWAL_ADJUSTMENT.getValue());
    FinancialActionTypeEntity interestPostingAction = new FinancialActionTypeEntity();
    interestPostingAction.setId(FinancialActionConstants.SAVINGS_INTERESTPOSTING.getValue());
    FinancialActionCache.addToCache(depositAction);
    FinancialActionCache.addToCache(withdrawalAction);
    FinancialActionCache.addToCache(depositAdjustmentAction);
    FinancialActionCache.addToCache(withdrawalAdjustmentAction);
    FinancialActionCache.addToCache(interestPostingAction);
    FinancialActionCache.addToCache(roundingAction);
}
Also used : FinancialActionConstants(org.mifos.accounts.financial.util.helpers.FinancialActionConstants) FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity) HashMap(java.util.HashMap) ChartOfAccountsCache(org.mifos.accounts.financial.util.helpers.ChartOfAccountsCache) COABO(org.mifos.accounts.financial.business.COABO) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) BeforeClass(org.junit.BeforeClass)

Example 22 with FinancialActionTypeEntity

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

the class SavingsAdjustmentTest method setupChartOfAccountsAndFinancialTransactions.

@BeforeClass
public static void setupChartOfAccountsAndFinancialTransactions() {
    defaultCurrency = TestUtils.RUPEE;
    Money.setDefaultCurrency(defaultCurrency);
    Short glcodeId = Short.valueOf("1");
    String glcode = "123456";
    GLCodeEntity glCodeEntity = new GLCodeEntity(glcodeId, glcode);
    COABO coabo = new COABO("testAccountName", glCodeEntity);
    ChartOfAccountsCache chartOfAccountsCache = new ChartOfAccountsCache();
    chartOfAccountsCache.clear();
    chartOfAccountsCache.add(coabo);
    Map<FinancialActionConstants, String> actionToCreditAccount = new HashMap<FinancialActionConstants, String>();
    actionToCreditAccount.put(FinancialActionConstants.MANDATORYDEPOSIT, glcode);
    actionToCreditAccount.put(FinancialActionConstants.MANDATORYWITHDRAWAL, glcode);
    actionToCreditAccount.put(FinancialActionConstants.MANDATORYDEPOSIT_ADJUSTMENT, glcode);
    actionToCreditAccount.put(FinancialActionConstants.MANDATORYWITHDRAWAL_ADJUSTMENT, glcode);
    FinancialRules.getInstance().setActionToCreditAccount(actionToCreditAccount);
    Map<FinancialActionConstants, String> actionToDebitAccount = new HashMap<FinancialActionConstants, String>();
    actionToDebitAccount.put(FinancialActionConstants.MANDATORYDEPOSIT, glcode);
    actionToDebitAccount.put(FinancialActionConstants.MANDATORYWITHDRAWAL, glcode);
    actionToDebitAccount.put(FinancialActionConstants.MANDATORYDEPOSIT_ADJUSTMENT, glcode);
    actionToDebitAccount.put(FinancialActionConstants.MANDATORYWITHDRAWAL_ADJUSTMENT, glcode);
    FinancialRules.getInstance().setActionToDebitAccount(actionToDebitAccount);
    FinancialActionTypeEntity depositAction = new FinancialActionTypeEntity();
    depositAction.setId(FinancialActionConstants.MANDATORYDEPOSIT.getValue());
    FinancialActionTypeEntity withdrawalAction = new FinancialActionTypeEntity();
    withdrawalAction.setId(FinancialActionConstants.MANDATORYWITHDRAWAL.getValue());
    FinancialActionTypeEntity depositAdjustmentAction = new FinancialActionTypeEntity();
    depositAdjustmentAction.setId(FinancialActionConstants.MANDATORYDEPOSIT_ADJUSTMENT.getValue());
    FinancialActionTypeEntity withdrawalAdjustmentAction = new FinancialActionTypeEntity();
    withdrawalAdjustmentAction.setId(FinancialActionConstants.MANDATORYWITHDRAWAL_ADJUSTMENT.getValue());
    FinancialActionCache.addToCache(depositAction);
    FinancialActionCache.addToCache(withdrawalAction);
    FinancialActionCache.addToCache(depositAdjustmentAction);
    FinancialActionCache.addToCache(withdrawalAdjustmentAction);
}
Also used : FinancialActionConstants(org.mifos.accounts.financial.util.helpers.FinancialActionConstants) FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity) HashMap(java.util.HashMap) ChartOfAccountsCache(org.mifos.accounts.financial.util.helpers.ChartOfAccountsCache) COABO(org.mifos.accounts.financial.business.COABO) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) BeforeClass(org.junit.BeforeClass)

Example 23 with FinancialActionTypeEntity

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

the class InterestAdjustmentAccountingEntry method logTransactions_v2.

private void logTransactions_v2(LoanTrxnDetailEntity loanTrxn) throws FinancialException {
    GLCodeEntity glcodeCredit = ((LoanBO) loanTrxn.getAccount()).getLoanOffering().getInterestGLcode();
    FinancialActionTypeEntity finActionInterest = FinancialActionCache.getFinancialAction(FinancialActionConstants.INTERESTPOSTING);
    addAccountEntryDetails(loanTrxn.getInterestAmount(), finActionInterest, getGLcode(finActionInterest.getApplicableDebitCharts()), FinancialConstants.CREDIT);
    addAccountEntryDetails(loanTrxn.getInterestAmount(), finActionInterest, glcodeCredit, FinancialConstants.DEBIT);
    boolean isLastPayment = ((LoanBO) loanTrxn.getAccount()).isLastInstallment(loanTrxn.getInstallmentId());
    if (!isLastPayment) {
        return;
    }
    boolean interestWasCharged = loanTrxn.getInterestAmount().isLessThanZero();
    // log the reversed 999 account
    if (!interestWasCharged) {
        return;
    }
    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 = getGLcode(finActionRounding.getApplicableCreditCharts());
        codeToCredit = glcodeCredit;
    } else if (account999.isLessThanZero()) {
        codeToDebit = glcodeCredit;
        codeToCredit = getGLcode(finActionRounding.getApplicableDebitCharts());
        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 24 with FinancialActionTypeEntity

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

the class InterestAdjustmentAccountingEntry method logTransactions_v1.

private void logTransactions_v1(LoanTrxnDetailEntity loanTrxn) throws FinancialException {
    GLCodeEntity glcodeCredit = ((LoanBO) loanTrxn.getAccount()).getLoanOffering().getInterestGLcode();
    FinancialActionTypeEntity finActionInterest = FinancialActionCache.getFinancialAction(FinancialActionConstants.INTERESTPOSTING);
    addAccountEntryDetails(loanTrxn.getInterestAmount(), finActionInterest, getGLcode(finActionInterest.getApplicableDebitCharts()), FinancialConstants.CREDIT);
    addAccountEntryDetails(loanTrxn.getInterestAmount(), finActionInterest, glcodeCredit, FinancialConstants.DEBIT);
    // check if rounding is required
    Money roundedAmount = Money.round(loanTrxn.getInterestAmount(), loanTrxn.getInterestAmount().getCurrency().getRoundingAmount(), AccountingRules.getCurrencyRoundingMode());
    if (!roundedAmount.equals(loanTrxn.getInterestAmount())) {
        FinancialActionTypeEntity finActionRounding = FinancialActionCache.getFinancialAction(FinancialActionConstants.ROUNDING);
        addAccountEntryDetails(roundedAmount.subtract(loanTrxn.getInterestAmount()).negate(), finActionRounding, getGLcode(finActionInterest.getApplicableCreditCharts()), FinancialConstants.DEBIT);
        addAccountEntryDetails(roundedAmount.subtract(loanTrxn.getInterestAmount()), finActionRounding, getGLcode(finActionRounding.getApplicableCreditCharts()), FinancialConstants.CREDIT);
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity)

Example 25 with FinancialActionTypeEntity

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

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