Date roDate = RequestUtil.getDate(req.getData().get("roDate"));
String remarks = RequestUtil.getString(req.getData().get("remarks"));
String status = RequestUtil.getString(req.getData().get("status"));
Boolean isCompleted = false;
ReceivingOrder ro = coreManager.get(ReceivingOrder.class, id);
if(status != null){
Status oldStatus = ro.getStatus();
Status newStatus = Status.fromString(status);
isCompleted = (!oldStatus.equals(newStatus) && newStatus == Status.COMPLETED);
}
try {
ReceivingOrder roResp;
if(isCompleted){
roResp = coreManager.updateCompleteReceivingOrder(ro.getId());
}else{
ro.setRoDate(roDate);
ro.setRemarks(remarks);