From ff3247078141a7ff0418c7b4ffcbf5e70129cb0e Mon Sep 17 00:00:00 2001 From: D045778 Date: Fri, 24 Oct 2025 09:46:39 +0200 Subject: [PATCH] fix: adding new items to an order should not crash --- srv/orders-service.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/srv/orders-service.js b/srv/orders-service.js index 222129b..b79de7e 100644 --- a/srv/orders-service.js +++ b/srv/orders-service.js @@ -8,7 +8,8 @@ class OrdersService extends cds.ApplicationService { this.before ('UPDATE', 'Orders', async function(req) { const { ID, Items } = req.data if (Items) for (let { product_ID, quantity } of Items) { - const { quantity:before } = await SELECT.one.from (OrderItems, oi => oi.quantity) .where ({up__ID:ID, product_ID}) + const { quantity:before } = (await SELECT.one.from (OrderItems, oi => oi.quantity) .where ({up__ID:ID, product_ID})) || {} + if (!before) continue if (quantity != before) await this.orderChanged (product_ID, quantity-before) } })