Search in sources :

Example 1 with FinancialTransactionBO

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

Example 2 with FinancialTransactionBO

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

the class DepositAccountingEntryTest method verifyCreatedTransactions.

private void verifyCreatedTransactions(String transactionAmount, SavingsDepositFinancialActivity mockedFinancialActivity, SavingsTrxnDetailEntity mockedIncomingTransaction, FinancialActionTypeEntity mockedFinancialAction, GLCodeEntity mockedBankGLCode, GLCodeEntity mockedSavingsDepositGLCode, GLCategoryType bankCategoryType, FinancialConstants bankDebitCredit, GLCategoryType savingsCategoryType, FinancialConstants savingsDebitCredit) {
    Iterator<FinancialTransactionBO> it = getIteratorOnSortedTransactions(mockedFinancialActivity, 2);
    /*
         * Verify the post to the bank's asset account
         */
    verifyCreatedFinancialTransaction(it.next(), mockedIncomingTransaction, null, mockedFinancialAction, mockedBankGLCode, transactionActionDate.toDate(), transactionCreator, (short) 1, new Money(currency, transactionAmount), comments, bankDebitCredit.getValue(), transactionPostedDate.toDate());
    /*
         * Verify the post to the savings liability account
         */
    verifyCreatedFinancialTransaction(it.next(), mockedIncomingTransaction, null, mockedFinancialAction, mockedSavingsDepositGLCode, transactionActionDate.toDate(), transactionCreator, (short) 1, new Money(currency, transactionAmount), comments, savingsDebitCredit.getValue(), transactionPostedDate.toDate());
}
Also used : Money(org.mifos.framework.util.helpers.Money) FinancialTransactionBO(org.mifos.accounts.financial.business.FinancialTransactionBO)

Example 3 with FinancialTransactionBO

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

the class AccountBO method getTransactionHistoryView.

public List<TransactionHistoryDto> getTransactionHistoryView() {
    List<TransactionHistoryDto> trxnHistory = new ArrayList<TransactionHistoryDto>();
    for (AccountPaymentEntity accountPayment : getAccountPayments()) {
        for (AccountTrxnEntity accountTrxn : accountPayment.getAccountTrxns()) {
            for (FinancialTransactionBO financialTrxn : accountTrxn.getFinancialTransactions()) {
                TransactionHistoryDto transactionHistory = new TransactionHistoryDto();
                setFinancialEntries(financialTrxn, transactionHistory);
                setAccountingEntries(accountTrxn, transactionHistory);
                trxnHistory.add(transactionHistory);
            }
        }
    }
    return trxnHistory;
}
Also used : FinancialTransactionBO(org.mifos.accounts.financial.business.FinancialTransactionBO) ArrayList(java.util.ArrayList) TransactionHistoryDto(org.mifos.dto.screen.TransactionHistoryDto)

Example 4 with FinancialTransactionBO

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

the class BaseAccountingEntry method addAccountEntryDetails.

protected void addAccountEntryDetails(final Money postedMoney, final FinancialActionTypeEntity financialAction, final GLCodeEntity glcode, final FinancialConstants debitCredit) {
    if (postedMoney.isNonZero()) {
        Money amountToPost = removeSign(postedMoney);
        FinancialTransactionBO financialTransaction = new FinancialTransactionBO(financialActivity.getAccountTrxn(), null, financialAction, glcode, financialActivity.getAccountTrxn().getActionDate(), financialActivity.getAccountTrxn().getPersonnel(), (short) 1, amountToPost, financialActivity.getAccountTrxn().getComments(), debitCredit.getValue(), financialActivity.getAccountTrxn().getTrxnCreatedDate());
        financialActivity.addFinancialTransaction(financialTransaction);
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) FinancialTransactionBO(org.mifos.accounts.financial.business.FinancialTransactionBO)

Example 5 with FinancialTransactionBO

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

Aggregations

FinancialTransactionBO (org.mifos.accounts.financial.business.FinancialTransactionBO)10 Test (org.junit.Test)5 Money (org.mifos.framework.util.helpers.Money)5 Date (java.sql.Date)4 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)4 ArrayList (java.util.ArrayList)3 AccountTrxnEntity (org.mifos.accounts.business.AccountTrxnEntity)3 LoanTrxnDetailEntity (org.mifos.accounts.loan.business.LoanTrxnDetailEntity)3 PaymentTypeEntity (org.mifos.application.master.business.PaymentTypeEntity)3 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)2 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)2 TransactionHistoryDto (org.mifos.dto.screen.TransactionHistoryDto)2 Timestamp (java.sql.Timestamp)1 DateMidnight (org.joda.time.DateMidnight)1 FeesTrxnDetailEntity (org.mifos.accounts.business.FeesTrxnDetailEntity)1 AccountException (org.mifos.accounts.exceptions.AccountException)1 SavingsInterestPostingFinancialActivity (org.mifos.accounts.financial.business.service.activity.SavingsInterestPostingFinancialActivity)1 LoanBO (org.mifos.accounts.loan.business.LoanBO)1 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)1 PaymentData (org.mifos.accounts.util.helpers.PaymentData)1