blocked
This commit is contained in:
@@ -2,5 +2,5 @@ PATCH http://localhost:4004/api-business-partner/A_BusinessPartner('ALICE')
|
|||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
|
||||||
{
|
{
|
||||||
"IsMarkedForArchiving": true
|
"BusinessPartnerIsBlocked": true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ service CatalogService {
|
|||||||
FirstName,
|
FirstName,
|
||||||
MiddleName,
|
MiddleName,
|
||||||
LastName,
|
LastName,
|
||||||
IsMarkedForArchiving
|
BusinessPartnerIsBlocked
|
||||||
};
|
};
|
||||||
|
|
||||||
event OrderMadeObsolete {
|
event OrderBlocked {
|
||||||
ID: UUID;
|
ID: UUID;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -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 }))
|
const orders = await cds.tx(msg).run(SELECT('ID').from(Orders).where({ createdBy: BUSINESSPARTNER }))
|
||||||
if (orders.length) {
|
if (orders.length) {
|
||||||
const businessPartner = await bupaSrv.tx(msg).run(SELECT.one(BusinessPartners).where({ ID: BUSINESSPARTNER }))
|
const businessPartner = await bupaSrv.tx(msg).run(SELECT.one(BusinessPartners).where({ ID: BUSINESSPARTNER }))
|
||||||
if (businessPartner && businessPartner.IsMarkedForArchiving) {
|
if (businessPartner && businessPartner.BusinessPartnerIsBlocked) {
|
||||||
orders.forEach(order => this.emit('OrderMadeObsolete', order) && console.log('>> Emitted', order))
|
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 */
|
/** Add some discount for overstocked books */
|
||||||
function _addDiscount2(each, discount) {
|
function _addDiscount2(each, discount) {
|
||||||
each.title += ` -- ${discount}% discount!`
|
each.title += ` -- ${discount}% discount!`
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
BusinessPartner;FirstName;MiddleName;LastName;IsMarkedForArchiving
|
BusinessPartner;FirstName;MiddleName;LastName;BusinessPartnerIsBlocked
|
||||||
ALICE;Alice;In;Wonderland;false
|
ALICE;Alice;In;Wonderland;false
|
||||||
BOB;Bob;The;Builder;false
|
BOB;Bob;The;Builder;false
|
||||||
JABBA;Jabba;The;Hutt;true
|
JABBA;Jabba;The;Hutt;true
|
||||||
|
Reference in New Issue
Block a user