Search in sources :

Example 1 with LoanTrxnDetailEntity

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

the class DisbursalAmountReversalAccountingEntry method applySpecificAccountActionEntry.

@Override
protected void applySpecificAccountActionEntry() throws FinancialException {
    LoanTrxnDetailEntity loanTrxn = (LoanTrxnDetailEntity) financialActivity.getAccountTrxn();
    FinancialActionTypeEntity finloanDibursal = getFinancialAction(FinancialActionConstants.DISBURSAL);
    // debit take form the prd offering
    GLCodeEntity glcodeDebit = ((LoanBO) loanTrxn.getAccount()).getLoanOffering().getPrincipalGLcode();
    addAccountEntryDetails(loanTrxn.getAmount(), finloanDibursal, glcodeDebit, FinancialConstants.CREDIT);
    addAccountEntryDetails(loanTrxn.getAmount(), finloanDibursal, getGLcode(finloanDibursal.getApplicableCreditCharts()), FinancialConstants.DEBIT);
}
Also used : FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) LoanTrxnDetailEntity(org.mifos.accounts.loan.business.LoanTrxnDetailEntity)

Example 2 with LoanTrxnDetailEntity

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

the class DisbursementAccountingEntry method applySpecificAccountActionEntry.

@Override
protected void applySpecificAccountActionEntry() throws FinancialException {
    LoanTrxnDetailEntity loanTrxn = (LoanTrxnDetailEntity) financialActivity.getAccountTrxn();
    FinancialActionTypeEntity finloanDibursal = getFinancialAction(FinancialActionConstants.DISBURSAL);
    // debit take form the prd offering
    GLCodeEntity glcodeDebit = ((LoanBO) loanTrxn.getAccount()).getLoanOffering().getPrincipalGLcode();
    addAccountEntryDetails(loanTrxn.getAmount(), finloanDibursal, glcodeDebit, FinancialConstants.DEBIT);
    Set<COABO> creditCharts = finloanDibursal.getApplicableCreditCharts();
    GLCodeEntity glcodeCredit = getGLcode(creditCharts);
    addAccountEntryDetails(loanTrxn.getAmount(), finloanDibursal, glcodeCredit, FinancialConstants.CREDIT);
}
Also used : FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity) COABO(org.mifos.accounts.financial.business.COABO) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) LoanTrxnDetailEntity(org.mifos.accounts.loan.business.LoanTrxnDetailEntity)

Example 3 with LoanTrxnDetailEntity

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

the class FeesAdjustmentAccountingEntry 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.DEBIT);
        addAccountEntryDetails(feeTrxn.getFeeAmount(), finActionFee, getGLcode(finActionFee.getApplicableDebitCharts()), FinancialConstants.CREDIT);
    }
    // For Misc Fee
    FinancialActionTypeEntity finActionMiscFee = FinancialActionCache.getFinancialAction(FinancialActionConstants.MISCFEEPOSTING);
    addAccountEntryDetails(loanTrxn.getMiscFeeAmount(), finActionMiscFee, getGLcode(finActionMiscFee.getApplicableDebitCharts()), FinancialConstants.CREDIT);
    addAccountEntryDetails(loanTrxn.getMiscFeeAmount(), finActionMiscFee, getGLcode(finActionMiscFee.getApplicableCreditCharts()), FinancialConstants.DEBIT);
}
Also used : FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity) LoanTrxnDetailEntity(org.mifos.accounts.loan.business.LoanTrxnDetailEntity) FeesTrxnDetailEntity(org.mifos.accounts.business.FeesTrxnDetailEntity)

Example 4 with LoanTrxnDetailEntity

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

the class InterestAdjustmentAccountingEntry method applySpecificAccountActionEntry.

@Override
protected void applySpecificAccountActionEntry() throws FinancialException {
    LoanTrxnDetailEntity loanTrxn = (LoanTrxnDetailEntity) financialActivity.getAccountTrxn();
    LoanBO loan = (LoanBO) loanTrxn.getAccount();
    if (loan.isLegacyLoan()) {
        logTransactions_v1(loanTrxn);
    } else {
        logTransactions_v2(loanTrxn);
    }
}
Also used : LoanBO(org.mifos.accounts.loan.business.LoanBO) LoanTrxnDetailEntity(org.mifos.accounts.loan.business.LoanTrxnDetailEntity)

Example 5 with LoanTrxnDetailEntity

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

the class FinancialBusinessServiceIntegrationTest method testLoanWriteOffAccountingEntries.

@Test
public void testLoanWriteOffAccountingEntries() throws Exception {
    loan = getLoanAccount();
    loan.setUserContext(TestUtils.makeUser());
    AccountPaymentEntity accountPaymentEntity = new AccountPaymentEntity(loan, TestUtils.createMoney(630), null, null, new PaymentTypeEntity(Short.valueOf("1")), new Date(System.currentTimeMillis()));
    FinancialBusinessService financialBusinessService = new FinancialBusinessService();
    AccountActionDateEntity accountActionDateEntity = loan.getAccountActionDate(Short.valueOf("1"));
    PersonnelBO personnel = legacyPersonnelDao.getPersonnel(loan.getUserContext().getId());
    LoanTrxnDetailEntity loanTrxnDetailEntity = new LoanTrxnDetailEntity(accountPaymentEntity, AccountActionTypes.WRITEOFF, accountActionDateEntity.getInstallmentId(), accountActionDateEntity.getActionDate(), personnel, new Date(System.currentTimeMillis()), ((LoanScheduleEntity) accountActionDateEntity).getPrincipal(), "Loan Written Off", null, ((LoanScheduleEntity) accountActionDateEntity).getPrincipal(), new Money(getCurrency()), new Money(getCurrency()), new Money(getCurrency()), new Money(getCurrency()), null, null);
    accountPaymentEntity.addAccountTrxn(loanTrxnDetailEntity);
    AccountTestUtils.addAccountPayment(accountPaymentEntity, loan);
    financialBusinessService.buildAccountingEntries(loanTrxnDetailEntity);
    TestObjectFactory.updateObject(loan);
    Set<FinancialTransactionBO> finTrxnSet = loanTrxnDetailEntity.getFinancialTransactions();
    Assert.assertEquals(finTrxnSet.size(), 2);
    for (FinancialTransactionBO finTrxn : finTrxnSet) {
        if (finTrxn.getFinancialAction().getId().equals(Short.valueOf("22")) && finTrxn.isCreditEntry()) {
            Assert.assertEquals(finTrxn.getPostedAmount(), TestUtils.createMoney("100"));
            Assert.assertEquals(finTrxn.getBalanceAmount(), TestUtils.createMoney("100"));
            Assert.assertEquals(finTrxn.getGlcode().getGlcodeId(), Short.valueOf("22"));
        } else if (finTrxn.getFinancialAction().getId().equals(Short.valueOf("22")) && finTrxn.isDebitEntry()) {
            Assert.assertEquals(finTrxn.getPostedAmount(), TestUtils.createMoney("100"));
            Assert.assertEquals(finTrxn.getBalanceAmount(), TestUtils.createMoney("100"));
            Assert.assertEquals(finTrxn.getGlcode().getGlcodeId(), Short.valueOf("24"));
        } else {
        //--fail("There should not be any other entry");
        }
    }
}
Also used : PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) Money(org.mifos.framework.util.helpers.Money) FinancialTransactionBO(org.mifos.accounts.financial.business.FinancialTransactionBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) LoanTrxnDetailEntity(org.mifos.accounts.loan.business.LoanTrxnDetailEntity) Date(java.sql.Date) Test(org.junit.Test)

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