This commit is contained in:
D065023
2020-01-29 14:13:15 +01:00
parent 61a318b250
commit 2787284aad
4 changed files with 10 additions and 6 deletions

View File

@@ -14,12 +14,16 @@ module.exports = cds.service.impl(async function () {
const orders = await cds.tx(msg).run(SELECT('ID').from(Orders).where({ createdBy: BUSINESSPARTNER }))
if (orders.length) {
const businessPartner = await bupaSrv.tx(msg).run(SELECT.one(BusinessPartners).where({ ID: BUSINESSPARTNER }))
if (businessPartner && businessPartner.IsMarkedForArchiving) {
orders.forEach(order => this.emit('OrderMadeObsolete', order) && console.log('>> Emitted', order))
if (businessPartner && businessPartner.BusinessPartnerIsBlocked) {
orders.forEach(order => this.emit('OrderBlocked', order) && console.log('>> Emitted', order))
}
}
})
this.on('OrderBlocked', msg => {
console.log('>>>> Received', msg.data)
})
/** Add some discount for overstocked books */
function _addDiscount2(each, discount) {
each.title += ` -- ${discount}% discount!`