bug fix
This commit is contained in:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user