working
This commit is contained in:
@@ -18,6 +18,10 @@ service CatalogService {
|
|||||||
Country
|
Country
|
||||||
};
|
};
|
||||||
|
|
||||||
|
event ContactDetailsChanged {
|
||||||
|
orders: array of my.Orders
|
||||||
|
}
|
||||||
|
|
||||||
@requires_: 'authenticated-user'
|
@requires_: 'authenticated-user'
|
||||||
@insertonly entity Orders as projection on my.Orders;
|
@insertonly entity Orders as projection on my.Orders;
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,12 @@ module.exports = cds.service.impl(async function () {
|
|||||||
this.after('READ', Books, each => each.stock > 111 && _addDiscount2(each, 11))
|
this.after('READ', Books, each => each.stock > 111 && _addDiscount2(each, 11))
|
||||||
this.before('CREATE', Orders, _reduceStock)
|
this.before('CREATE', Orders, _reduceStock)
|
||||||
this.on('READ', Addresses, req => bupaSrv.tx(req).run(req.query))
|
this.on('READ', Addresses, req => bupaSrv.tx(req).run(req.query))
|
||||||
this.on('BusinessPartner/Changed', async msg => {
|
bupaSrv.on('BusinessPartner/Changed', async msg => {
|
||||||
console.log('>> Received message', msg.data)
|
console.log('>> Received message', msg.data)
|
||||||
const BUSINESSPARTNER = msg.data.KEY[0].BUSINESSPARTNER
|
const BUSINESSPARTNER = msg.data.KEY[0].BUSINESSPARTNER
|
||||||
const orders = await cds.tx(msg).run(SELECT.from(Orders).where({ createdBy: BUSINESSPARTNER }))
|
const orders = await cds.tx(msg).run(SELECT.from(Orders).where({ createdBy: BUSINESSPARTNER }))
|
||||||
console.log(orders)
|
this.emit('ContactDetailsChanged', { orders })
|
||||||
|
console.log('=== EMITTED ====')
|
||||||
})
|
})
|
||||||
|
|
||||||
/** Add some discount for overstocked books */
|
/** Add some discount for overstocked books */
|
||||||
|
|||||||
Reference in New Issue
Block a user