Search in sources :

Example 6 with LoanTrxnDetailEntity

use of org.mifos.accounts.loan.business.LoanTrxnDetailEntity 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 7 with LoanTrxnDetailEntity

use of org.mifos.accounts.loan.business.LoanTrxnDetailEntity 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 8 with LoanTrxnDetailEntity

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

the class FinancialBusinessServiceIntegrationTest method testLoanRescheduleAccountingEntries.

@Test
public void testLoanRescheduleAccountingEntries() 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.LOAN_RESCHEDULED, accountActionDateEntity.getInstallmentId(), accountActionDateEntity.getActionDate(), personnel, new Date(System.currentTimeMillis()), ((LoanScheduleEntity) accountActionDateEntity).getPrincipal(), "Loan Rescheduled", 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("23")) && 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("23")) && finTrxn.isDebitEntry()) {
            Assert.assertEquals(finTrxn.getPostedAmount(), TestUtils.createMoney("100"));
            Assert.assertEquals(finTrxn.getBalanceAmount(), TestUtils.createMoney("100"));
            Assert.assertEquals(finTrxn.getGlcode().getGlcodeId(), Short.valueOf("7"));
        } else {
            Assert.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)

Example 9 with LoanTrxnDetailEntity

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

the class FinancialBusinessServiceIntegrationTest method getAccountTrxnObj.

private AccountTrxnEntity getAccountTrxnObj(AccountPaymentEntity accountPaymentEntity) throws Exception {
    Date currentDate = new Date(System.currentTimeMillis());
    LoanScheduleEntity accountAction = (LoanScheduleEntity) loan.getAccountActionDate(Short.valueOf("1"));
    LoanTrxnDetailEntity accountTrxnEntity = new LoanTrxnDetailEntity(accountPaymentEntity, AccountActionTypes.LOAN_ADJUSTMENT, Short.valueOf("1"), accountAction.getActionDate(), TestObjectFactory.getPersonnel(PersonnelConstants.SYSTEM_USER), currentDate, TestUtils.createMoney(630), "test for loan adjustment", null, TestUtils.createMoney(200), TestUtils.createMoney(300), TestUtils.createMoney(), TestUtils.createMoney(10), TestUtils.createMoney(20), null, null);
    for (AccountFeesActionDetailEntity accountFeesActionDetailEntity : accountAction.getAccountFeesActionDetails()) {
        LoanBOTestUtils.setFeeAmountPaid(accountFeesActionDetailEntity, TestUtils.createMoney(100));
        FeesTrxnDetailEntity feeTrxn = new FeesTrxnDetailEntity(accountTrxnEntity, accountFeesActionDetailEntity.getAccountFee(), accountFeesActionDetailEntity.getFeeAmount());
        accountTrxnEntity.addFeesTrxnDetail(feeTrxn);
    }
    return accountTrxnEntity;
}
Also used : LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) AccountFeesActionDetailEntity(org.mifos.accounts.business.AccountFeesActionDetailEntity) LoanTrxnDetailEntity(org.mifos.accounts.loan.business.LoanTrxnDetailEntity) Date(java.sql.Date) FeesTrxnDetailEntity(org.mifos.accounts.business.FeesTrxnDetailEntity)

Example 10 with LoanTrxnDetailEntity

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

the class AccountBOIntegrationTest method testLoanAdjustment.

@Test
public void testLoanAdjustment() throws Exception {
    Date currentDate = new Date(System.currentTimeMillis());
    LoanBO loan = groupLoan;
    loan.setUserContext(TestUtils.makeUser());
    List<AccountActionDateEntity> accntActionDates = new ArrayList<AccountActionDateEntity>();
    accntActionDates.add(loan.getAccountActionDate(Short.valueOf("1")));
    PaymentData accountPaymentDataView = TestObjectFactory.getLoanAccountPaymentData(accntActionDates, TestUtils.createMoney(216), null, loan.getPersonnel(), "receiptNum", Short.valueOf("1"), currentDate, currentDate);
    IntegrationTestObjectMother.applyAccountPayment(loan, accountPaymentDataView);
    loan = IntegrationTestObjectMother.findLoanBySystemId(loan.getGlobalAccountNum());
    loan.setUserContext(TestUtils.makeUser());
    IntegrationTestObjectMother.applyAccountPayment(loan, TestObjectFactory.getLoanAccountPaymentData(null, TestUtils.createMoney(600), null, loan.getPersonnel(), "receiptNum", Short.valueOf("1"), currentDate, currentDate));
    loan = IntegrationTestObjectMother.findLoanBySystemId(loan.getGlobalAccountNum());
    loan.setUserContext(TestUtils.makeUser());
    PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
    loan.adjustPmnt("loan account has been adjusted by test code", loggedInUser);
    IntegrationTestObjectMother.saveLoanAccount(loan);
    Assert.assertEquals("The amount returned for the payment should have been 0", 0.0, loan.getLastPmntAmnt());
    LoanTrxnDetailEntity lastLoanTrxn = null;
    for (AccountTrxnEntity accntTrxn : loan.findMostRecentPaymentByPaymentDate().getAccountTrxns()) {
        lastLoanTrxn = (LoanTrxnDetailEntity) accntTrxn;
        break;
    }
    AccountActionDateEntity installment = loan.getAccountActionDate(lastLoanTrxn.getInstallmentId());
    Assert.assertFalse("The installment adjusted should now be marked unpaid(due).", installment.isPaid());
}
Also used : PaymentData(org.mifos.accounts.util.helpers.PaymentData) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList) 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