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");
}
}
}
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());
}
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;
}
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);
}
}
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");
}
}
}
Aggregations