insertItems.setString(4, item.getType()); insertItems.setString(5, item.getTitle()); insertItems.setLong(6, item.getQuantity()); insertItems.setBigDecimal(7, item.getUnitPrice()); insertItems.setBigDecimal(8, item.getItemTotal());
@Override public void onEvent(Event event, Object source, Object data) { // Update stocks for bought products Order order = (Order) source; List<OrderItem> items = order.getOrderItems(); for (OrderItem item : items) { UUID itemId = item.getPurchasableId(); if (itemId == null) { return; } Long quantity = item.getQuantity(); try { Product product = productStore.get().findById(itemId); if (product.getStock() != null) { productStore.get().updateStock(itemId, -quantity.intValue()); } else if (product.getParentId() != null) { Product parent = productStore.get().findById(product.getParentId()); productStore.get().updateStock(product.getParentId(), -quantity.intValue()); } } catch (EntityDoesNotExistException e) { // Ignore, there is just no stock to update } } } }
Map<String, Object> orderItem = Maps.newHashMap(); orderItem.put("title", item.getTitle()); orderItem.put("quantity", item.getQuantity());
.print(Money.of(currencyUnit, item.getItemTotal(), RoundingMode.HALF_EVEN))); itemData.put("title", item.getTitle()); itemData.put("quantity", item.getQuantity()); itemData.put("vatRate", item.getVatRate().longValue()); itemsData.add(itemData);