This commit is contained in:
Wolfgang Koch
2021-07-06 15:40:39 +02:00
parent b7ff0cd100
commit 60ba27ff3c
14 changed files with 1517 additions and 1755 deletions

View File

@@ -5,6 +5,7 @@ class OrdersService extends cds.ApplicationService {
init(){
const { Orders_Items:OrderItems } = this.entities
/**
this.before ('UPDATE', 'Orders', async function(req) {
const { ID, Items } = req.data
if (Items) for (let { product_ID, amount } of Items) {
@@ -14,7 +15,9 @@ class OrdersService extends cds.ApplicationService {
if (amount != before) await this.orderChanged (product_ID, amount-before)
}
})
**/
/**
this.before ('DELETE', 'Orders', async function(req) {
const { ID } = req.data
const Items = await cds.tx(req).run (
@@ -22,8 +25,10 @@ class OrdersService extends cds.ApplicationService {
)
if (Items) await Promise.all (Items.map(it => this.orderChanged (it.product_ID, -it.amount)))
})
**/
return super.init()
}
/** order changed -> broadcast event */