use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class LoginAction method cancel.
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward cancel(ActionMapping mapping, ActionForm form, @SuppressWarnings("unused") HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
String username = ((LoginActionForm) form).getUserName();
PersonnelBO personnelBO = this.personnelDao.findPersonnelByUsername(username);
String actionForward = getCancelForward(personnelBO.getPasswordChanged());
return mapping.findForward(actionForward);
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class WebTierAccountServiceFacadeTest method shouldNotAdjustBackdatedPaymentMadeOnAccountIfNotAllowed.
@Test
public void shouldNotAdjustBackdatedPaymentMadeOnAccountIfNotAllowed() throws ServiceException, AccountException, PersistenceException {
String globalAccountNum = "123";
String adjustmentNote = "note";
Short personnelId = Short.valueOf("1");
PersonnelBO personnelBO = mock(PersonnelBO.class);
Date paymentDate = TestUtils.getDate(10, 10, 2010);
new DateTimeService().setCurrentDateTime(TestUtils.getDateTime(11, 10, 2010));
AccountPaymentEntity lastPmntToBeAdjusted = mock(AccountPaymentEntity.class);
Short recordOfficeId = new Short("1");
Short recordLoanOfficer = new Short("1");
PersonnelBO loanOfficer = mock(PersonnelBO.class);
when(loanBO.getPersonnel()).thenReturn(loanOfficer);
when(loanBO.getUserContext()).thenReturn(userContext);
when(loanOfficer.getPersonnelId()).thenReturn(recordOfficeId);
when(loanBO.getOfficeId()).thenReturn(recordOfficeId);
when(loanBO.getLastPmntToBeAdjusted()).thenReturn(lastPmntToBeAdjusted);
when(lastPmntToBeAdjusted.getPaymentDate()).thenReturn(paymentDate);
when(accountBusinessService.findBySystemId(globalAccountNum)).thenReturn(loanBO);
when(personnelPersistence.findPersonnelById(personnelId)).thenReturn(personnelBO);
doThrow(new ServiceException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED)).when(accountBusinessService).checkPermissionForAdjustmentOnBackDatedPayments(paymentDate, userContext, recordOfficeId, recordLoanOfficer);
try {
accountServiceFacade.applyAdjustment(globalAccountNum, adjustmentNote, personnelId);
} catch (MifosRuntimeException e) {
assertThat((ServiceException) e.getCause(), CoreMatchers.any(ServiceException.class));
assertThat(((ServiceException) e.getCause()).getKey(), is(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED));
}
verify(accountBusinessService, atLeastOnce()).findBySystemId(globalAccountNum);
verify(lastPmntToBeAdjusted).getPaymentDate();
verify(accountBusinessService).checkPermissionForAdjustmentOnBackDatedPayments(paymentDate, userContext, recordOfficeId, recordLoanOfficer);
verify(personnelPersistence, never()).findPersonnelById(personnelId);
verify(loanBO, never()).adjustLastPayment(anyString(), Matchers.<PersonnelBO>anyObject());
verify(legacyAccountDao, never()).createOrUpdate(loanBO);
verify(loanBO).setUserContext(userContext);
verify(transactionHelper, never()).startTransaction();
verify(transactionHelper, never()).commitTransaction();
verify(transactionHelper).rollbackTransaction();
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class WebTierAccountServiceFacadeTest method shouldAdjustBackdatedPaymentMadeOnAccountIfAllowed.
@Test
public void shouldAdjustBackdatedPaymentMadeOnAccountIfAllowed() throws ServiceException, AccountException, PersistenceException {
String globalAccountNum = "123";
String adjustmentNote = "note";
Short personnelId = Short.valueOf("1");
PersonnelBO personnelBO = mock(PersonnelBO.class);
PersonnelBO loanOfficer = mock(PersonnelBO.class);
Date paymentDate = TestUtils.getDate(10, 10, 2010);
new DateTimeService().setCurrentDateTime(TestUtils.getDateTime(11, 10, 2010));
Short recordOfficeId = new Short("1");
Short recordLoanOfficer = new Short("1");
Integer paymentId = 1;
AccountPaymentEntity lastPmntToBeAdjusted = mock(AccountPaymentEntity.class);
when(loanBO.getLastPmntToBeAdjusted()).thenReturn(lastPmntToBeAdjusted);
when(loanBO.getOfficeId()).thenReturn(recordOfficeId);
when(loanBO.getPersonnel()).thenReturn(loanOfficer);
when(loanBO.getUserContext()).thenReturn(userContext);
when(loanBO.findPaymentById(paymentId)).thenReturn(lastPmntToBeAdjusted);
when(loanOfficer.getPersonnelId()).thenReturn(recordOfficeId);
when(lastPmntToBeAdjusted.getPaymentDate()).thenReturn(paymentDate);
when(lastPmntToBeAdjusted.getPaymentId()).thenReturn(paymentId);
when(accountBusinessService.findBySystemId(globalAccountNum)).thenReturn(loanBO);
when(personnelPersistence.findPersonnelById(personnelId)).thenReturn(personnelBO);
accountServiceFacade.applyAdjustment(globalAccountNum, adjustmentNote, personnelId);
verify(accountBusinessService, atLeastOnce()).findBySystemId(globalAccountNum);
verify(personnelPersistence).findPersonnelById(personnelId);
verify(loanBO).adjustLastPayment(adjustmentNote, personnelBO);
verify(loanBO, atLeastOnce()).setUserContext(userContext);
verify(legacyAccountDao).createOrUpdate(loanBO);
verify(transactionHelper).startTransaction();
verify(transactionHelper).commitTransaction();
verify(accountBusinessService).checkPermissionForAdjustmentOnBackDatedPayments(paymentDate, userContext, recordOfficeId, recordLoanOfficer);
verify(lastPmntToBeAdjusted, times(2)).getPaymentDate();
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class ApplyAdjustmentActionStrutsTest method testApplyAdjustment.
@Ignore
@Test
public void testApplyAdjustment() throws Exception {
PersonnelBO personnel = legacyPersonnelDao.getPersonnel(PersonnelConstants.SYSTEM_USER);
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
loan = (LoanBO) getLoanAccount();
applyPayment(loan, 212);
loan = TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
applyPayment(loan, 700);
loan = TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
AccountStatusChangeHistoryEntity historyEntity = new AccountStatusChangeHistoryEntity(new AccountStateEntity(AccountState.LOAN_ACTIVE_IN_GOOD_STANDING), new AccountStateEntity(AccountState.LOAN_ACTIVE_IN_GOOD_STANDING), personnel, loan);
AccountTestUtils.addToAccountStatusChangeHistory(loan, historyEntity);
TestObjectFactory.updateObject(loan);
StaticHibernateUtil.flushAndClearSession();
loan = TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
loan.setUserContext(userContext);
for (AccountStatusChangeHistoryEntity accountStatus : loan.getAccountStatusChangeHistory()) {
Assert.assertEquals(loan.getAccountId(), accountStatus.getAccount().getAccountId());
Assert.assertNotNull(accountStatus.getAccountStatusChangeId());
Assert.assertEquals(AccountState.LOAN_ACTIVE_IN_GOOD_STANDING.getValue(), accountStatus.getNewStatus().getId());
Assert.assertEquals(personnel.getPersonnelId(), accountStatus.getPersonnel().getPersonnelId());
Assert.assertEquals(personnel.getDisplayName(), accountStatus.getPersonnel().getDisplayName());
Assert.assertEquals("-", accountStatus.getOldStatusName());
Assert.assertNotNull(accountStatus.getNewStatusName());
Assert.assertNull(accountStatus.getLocale());
Assert.assertNotNull(accountStatus.getUserPrefferedTransactionDate());
}
SessionUtils.setAttribute(Constants.BUSINESS_KEY, loan, request);
setRequestPathInfo("/applyAdjustment");
addRequestParameter("method", "applyAdjustment");
addRequestParameter("adjustmentNote", "Loan adjustment testing");
addRequestParameter("globalAccountNum", loan.getGlobalAccountNum());
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
setUpSecurityContext();
getRequest().getSession().setAttribute(Constants.USERCONTEXT, TestUtils.makeUser());
actionPerform();
loan = (LoanBO) TestObjectFactory.getObject(AccountBO.class, loan.getAccountId());
verifyForward("applyadj_success");
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class ApplyPaymentActionStrutsTest method xtestApplyPaymentForLoanWhenReceiptDateisNull.
public void xtestApplyPaymentForLoanWhenReceiptDateisNull() throws Exception {
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
accountBO = createLoanAccount();
SessionUtils.setAttribute(Constants.ACCOUNT_VERSION, accountBO.getVersionNo(), request);
SessionUtils.setAttribute(Constants.ACCOUNT_TYPE, AccountTypes.getAccountType(accountBO.getAccountType().getAccountTypeId()).name(), request);
SessionUtils.setAttribute(Constants.ACCOUNT_ID, accountBO.getAccountId(), request);
accountBO.setUserContext(TestObjectFactory.getContext());
PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
accountBO.changeStatus(AccountState.LOAN_ACTIVE_IN_BAD_STANDING, null, "", loggedInUser);
AccountApplyPaymentActionForm accountApplyPaymentActionForm = new AccountApplyPaymentActionForm();
accountApplyPaymentActionForm.setAmount("212");
request.getSession().setAttribute("applyPaymentActionForm", accountApplyPaymentActionForm);
setRequestPathInfo("/applyPaymentAction");
addRequestParameter("input", "loan");
addRequestParameter("method", "applyPayment");
addRequestParameter("accountId", accountBO.getAccountId().toString());
addRequestParameter("receiptId", "101");
String currentDate = DateUtils.makeDateAsSentFromBrowser();
addRequestDateParameter("receiptDate", "");
addRequestDateParameter("transactionDate", currentDate);
addRequestParameter("paymentTypeId", "1");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
actionPerform();
verifyForward("loan_detail_page");
Assert.assertEquals(new Money(getCurrency()), accountBO.getTotalPaymentDue());
Assert.assertEquals(0, accountBO.getTotalInstallmentsDue().size());
Assert.assertEquals(AccountStates.LOANACC_ACTIVEINGOODSTANDING, accountBO.getAccountState().getId().shortValue());
}
Aggregations