use of org.mifos.rest.approval.domain.RESTApprovalEntity in project head by mifos.
the class ApprovalController method details.
@RequestMapping("restApproval/id-{id}/details.ftl")
public ModelAndView details(@PathVariable Long id) {
ModelAndView mav = new ModelAndView("approval/details");
mav.addObject("waitingForApprovalList", approvalService.getAllWaiting());
RESTApprovalEntity approval = approvalService.getDetails(id);
mav.addObject("approval", approval);
PersonnelInformationDto p = personnelServiceFacade.getPersonnelInformationDto(approval.getCreatedBy().longValue(), null);
mav.addObject("createdBy", p.getDisplayName());
if (!approval.getState().equals(ApprovalState.WAITING)) {
p = personnelServiceFacade.getPersonnelInformationDto(approval.getApprovedBy().longValue(), null);
mav.addObject("approvedBy", p.getDisplayName());
}
return mav;
}
use of org.mifos.rest.approval.domain.RESTApprovalEntity in project head by mifos.
the class StandardApprovalService method create.
@Transactional(noRollbackFor = RESTCallInterruptException.class)
@Override
public void create(ApprovalMethod method) throws Exception {
if (!skipCreate) {
RESTApprovalEntity entity = new RESTApprovalEntity();
entity.setApprovalMethod(method);
entity.setState(ApprovalState.WAITING);
entity.setCreatedBy(getCurrentUserId());
entity.setCreatedOn(new DateTime());
approvalDao.create(entity);
throw new RESTCallInterruptException(entity.getId());
}
}
use of org.mifos.rest.approval.domain.RESTApprovalEntity in project head by mifos.
the class StandardApprovalService method reject.
@Transactional
@Override
public void reject(Long id) {
RESTApprovalEntity entity = approvalDao.getDetails(id);
entity.setApprovedBy(getCurrentUserId());
entity.setApprovedOn(new DateTime());
entity.setState(ApprovalState.REJECTED);
approvalDao.update(entity);
}
use of org.mifos.rest.approval.domain.RESTApprovalEntity in project head by mifos.
the class ApprovalServiceTest method testCreate.
@Test
public void testCreate() throws Exception {
createApprovalMethod();
RESTApprovalEntity rae = approvalService.getDetails(1L);
assertNotNull(rae);
assertEquals(StubRESTController.class.getSimpleName().replace("RESTController", ""), rae.getType());
assertNotNull(rae.getCreatedOn());
assertEquals(getCurrentUserId(), rae.getCreatedBy());
assertNull(rae.getApprovedOn());
assertNull(rae.getApprovedBy());
assertEquals(ApprovalState.WAITING, rae.getState());
}
use of org.mifos.rest.approval.domain.RESTApprovalEntity in project head by mifos.
the class ApprovalServiceTest method testApproveState.
@Test
public void testApproveState() throws Exception {
createApprovalMethod();
RESTApprovalEntity rae = approvalService.getAllWaiting().get(0);
assertNotNull(rae);
assertEquals(ApprovalState.WAITING, rae.getState());
approvalService.reject(rae.getId());
rae = approvalService.getAllNotWaiting().get(0);
assertEquals(ApprovalState.REJECTED, rae.getState());
assertNotNull(rae.getApprovedOn());
assertEquals(getCurrentUserId(), rae.getApprovedBy());
approvalService.approve(rae.getId());
rae = approvalService.getAllNotWaiting().get(0);
assertEquals(ApprovalState.APPROVED, rae.getState());
}
Aggregations