Integer id = RequestUtil.getInteger(getRequestAttributes().get("id"));
String remarks = RequestUtil.getString(req.getData().get("remarks"));
String status = RequestUtil.getString(req.getData().get("status"));
Status TOStatus = Status.fromString(status);
TransferOrder transferResp = null;
TransferOrder to = coreManager.get(TransferOrder.class, id);
Status oldStatus = to.getStatus();
Boolean isProcessed = (!oldStatus.equals(TOStatus) && TOStatus == Status.PROCESSED);
Boolean isCancelledFromProcessed = (oldStatus == Status.PROCESSED && TOStatus == Status.CANCELLED);
Boolean isCancelledFromNew = (oldStatus == Status.NEW && TOStatus == Status.CANCELLED);
Boolean isCompleted = (!oldStatus.equals(TOStatus) && TOStatus == Status.COMPLETED);
try {
if(isProcessed){
transferResp = coreManager.updateProcessTransferOrder(id);
}else if(isCancelledFromNew){
transferResp = coreManager.updateCancelNewTransferOrder(id);
}else if(isCancelledFromProcessed){
transferResp = coreManager.updateCancelProcessTransferOrder(id);
}else if(isCompleted){
transferResp = coreManager.updateCompletedTransferOrder(id);
}else{
to.setRemarks(remarks);
to.setStatus(TOStatus);
transferResp = coreManager.save(TransferOrder.class, to);
}
DisplayTransferOrder dto = mapper.map(transferResp, DisplayTransferOrder.class);
resp = dto;
} catch (Exception e) {