@RequestParam String referenceNumber,
@RequestParam String orderType, @RequestParam Date orderDate,
@RequestParam Date dueDate, @RequestParam String comments,
@RequestParam Object items) {
try {
PurchaseOrderUI order = new PurchaseOrderUI();
order.setOrderId(orderId);
order.setUserName(userName);
order.setReferenceNumber(referenceNumber);
order.setOrderType(orderType);
order.setOrderDate(orderDate);
order.setDueDate(dueDate);
order.setComments(comments);
List<PurchaseOrderItemsUI> pItems = itemsJson
.getListFromJSON((String) items);
order.setItems(pItems);
logger.debug("Purchased Items :: " + pItems);
logger.debug("Purchas Order :: " + order);
if (service.findByOrderId(order.getOrderId()).getOrderId() != null) {
return response.mapError("Order Id already exists.");
}
PurchaseOrderUI saved = service.create(order);
logger.debug("Purchas Order Created Successfully :: " + saved);
return response.mapOK(saved, "Purchase Order Created Succesfully");
} catch (Exception e) {
logger.error("Error trying to create purchase order.");
return response.mapError("Error trying to create purchase order.");