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