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