use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class LoanBOForReversalIntegrationTest method adjustLastPayment.
private void adjustLastPayment() throws AccountException {
loan = retrieveLoanAccount();
loan.setUserContext(userContext);
PersonnelBO loggedInUser = legacyPersonnelDao.findPersonnelById(userContext.getId());
loan.adjustPmnt("loan account has been adjusted by test code", loggedInUser);
StaticHibernateUtil.flushSession();
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class LoanBOTest method repayInstallmentsShouldPopulateCalculatedInterestsForDIPBLoans.
@Test
public void repayInstallmentsShouldPopulateCalculatedInterestsForDIPBLoans() throws PersistenceException {
final LegacyLoanDao legacyLoanDao = mock(LegacyLoanDao.class);
final CustomerBO customerBO = mock(CustomerBO.class);
final LoanSummaryEntity loanSummaryEntity = mock(LoanSummaryEntity.class);
LoanBO loanBO = new LoanBO() {
@Override
public boolean isDecliningBalanceInterestRecalculation() {
return true;
}
@Override
public LegacyLoanDao getlegacyLoanDao() {
return legacyLoanDao;
}
@Override
public CustomerBO getCustomer() {
return customerBO;
}
@Override
public LoanSummaryEntity getLoanSummary() {
return loanSummaryEntity;
}
};
AccountActionTypes accountActionTypes = AccountActionTypes.LOAN_REPAYMENT;
AccountActionEntity accountActionEntity = mock(AccountActionEntity.class);
AccountPaymentEntity accountPaymentEntity = new AccountPaymentEntityBuilder().with(loanBO).build();
PersonnelBO user = new PersonnelBO();
Money extraInterestDue = new Money(rupee, "0.98");
Money interest = new Money(rupee, "10");
Money interestDue = new Money(rupee, "2.07");
when(legacyLoanDao.getPersistentObject(AccountActionEntity.class, accountActionTypes.getValue())).thenReturn(accountActionEntity);
when(loanScheduleEntity.getPrincipalDue()).thenReturn(new Money(rupee, "1000"));
when(loanScheduleEntity.getTotalFeeDueWithMiscFeeDue()).thenReturn(new Money(rupee, "10"));
when(loanScheduleEntity.getPenaltyDue()).thenReturn(new Money(rupee, "10"));
when(loanScheduleEntity.getPenalty()).thenReturn(new Money(rupee, "100"));
when(loanScheduleEntity.getExtraInterestDue()).thenReturn(extraInterestDue);
when(loanScheduleEntity.getExtraInterestPaid()).thenReturn(extraInterestDue);
when(loanScheduleEntity.getInterest()).thenReturn(interest);
when(loanScheduleEntity.getInterestDue()).thenReturn(interestDue);
loanBO.repayInstallment(loanScheduleEntity, accountPaymentEntity, accountActionTypes, user, "", interestDue);
Set<AccountTrxnEntity> accountTrxns = accountPaymentEntity.getAccountTrxns();
AccountTrxnEntity accountTrxnEntity = accountTrxns.toArray(new AccountTrxnEntity[accountTrxns.size()])[0];
LoanTrxnDetailEntity loanTrxnDetailEntity = (LoanTrxnDetailEntity) accountTrxnEntity;
assertThat(loanTrxnDetailEntity.getInterestAmount().getAmount().doubleValue(), is(3.05));
CalculatedInterestOnPayment calculatedInterestOnPayment = loanTrxnDetailEntity.getCalculatedInterestOnPayment();
assertNotNull(calculatedInterestOnPayment);
assertThat(calculatedInterestOnPayment.getExtraInterestPaid(), is(extraInterestDue));
assertThat(calculatedInterestOnPayment.getInterestDueTillPaid(), is(interestDue));
assertThat(calculatedInterestOnPayment.getOriginalInterest(), is(interest));
Mockito.verify(loanScheduleEntity).makeEarlyRepaymentEntries(LoanConstants.PAY_FEES_PENALTY_INTEREST, interestDue, accountPaymentEntity.getPaymentDate());
}
use of org.mifos.customers.personnel.business.PersonnelBO 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.customers.personnel.business.PersonnelBO in project head by mifos.
the class AccountBOIntegrationTest method testAdjustmentForClosedAccnt.
@Test
public void testAdjustmentForClosedAccnt() throws Exception {
Date currentDate = new Date(System.currentTimeMillis());
LoanBO loan = groupLoan;
loan.setUserContext(TestUtils.makeUser());
List<AccountActionDateEntity> accntActionDates = new ArrayList<AccountActionDateEntity>();
accntActionDates.addAll(loan.getAccountActionDates());
PaymentData accountPaymentDataView = TestObjectFactory.getLoanAccountPaymentData(accntActionDates, TestUtils.createMoney(712), null, loan.getPersonnel(), "receiptNum", Short.valueOf("1"), currentDate, currentDate);
IntegrationTestObjectMother.applyAccountPayment(loan, accountPaymentDataView);
loan.setAccountState(new AccountStateEntity(AccountState.LOAN_CLOSED_OBLIGATIONS_MET));
TestObjectFactory.updateObject(loan);
try {
PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
loan.adjustPmnt("loan account has been adjusted by test code", loggedInUser);
} catch (AccountException e) {
Assert.assertEquals("exception.accounts.ApplicationException.CannotAdjust", e.getKey());
}
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class AccountBOIntegrationTest method testGetTransactionHistoryViewByOtherUser.
@Test
public void testGetTransactionHistoryViewByOtherUser() throws Exception {
Date currentDate = new Date(System.currentTimeMillis());
LoanBO loan = groupLoan;
loan.setUserContext(TestUtils.makeUser());
List<AccountActionDateEntity> accntActionDates = new ArrayList<AccountActionDateEntity>();
accntActionDates.addAll(loan.getAccountActionDates());
PersonnelBO personnel = legacyPersonnelDao.getPersonnel(Short.valueOf("2"));
PaymentData accountPaymentDataView = TestObjectFactory.getLoanAccountPaymentData(accntActionDates, TestUtils.createMoney(100), null, personnel, "receiptNum", Short.valueOf("1"), currentDate, currentDate);
IntegrationTestObjectMother.applyAccountPayment(loan, accountPaymentDataView);
loan = TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
loan.setUserContext(TestUtils.makeUser());
List<TransactionHistoryDto> trxnHistlist = loan.getTransactionHistoryView();
Assert.assertNotNull("Account TrxnHistoryView list object should not be null", trxnHistlist);
Assert.assertTrue("Account TrxnHistoryView list object Size should be greater than zero", trxnHistlist.size() > 0);
for (TransactionHistoryDto transactionHistoryDto : trxnHistlist) {
Assert.assertEquals(transactionHistoryDto.getPostedBy(), personnel.getDisplayName());
}
StaticHibernateUtil.flushSession();
groupLoan = TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
}
Aggregations