We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7e49d70 commit ff32470Copy full SHA for ff32470
1 file changed
srv/orders-service.js
@@ -8,7 +8,8 @@ class OrdersService extends cds.ApplicationService {
8
this.before ('UPDATE', 'Orders', async function(req) {
9
const { ID, Items } = req.data
10
if (Items) for (let { product_ID, quantity } of Items) {
11
- 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})) || {}
12
+ if (!before) continue
13
if (quantity != before) await this.orderChanged (product_ID, quantity-before)
14
}
15
})
0 commit comments