Compare commits

..

9 Commits

Author SHA1 Message Date
Christian Georgi
f28bfbb768 Update README.md 2020-04-20 17:12:04 +02:00
Christian Georgi
7d8ca4d4a1 Add package-lock.json, fix readme 2020-04-02 16:15:51 +02:00
Christian Georgi
61aa81a806 Update readme 2020-03-23 17:11:22 +01:00
D065023
e7c395671b rm other packages 2020-03-20 10:54:25 +01:00
Dr. David Kunz
cd245c4641 Update package.json 2020-02-11 11:50:15 +01:00
D065023
d081438a6a default 2020-01-29 15:22:26 +01:00
D065023
79c3a22224 rm amqp and req 2020-01-29 15:21:13 +01:00
D065023
9c30ad7584 package.json 2020-01-29 14:58:14 +01:00
D065023
c58bcf905f rm eventing 2020-01-29 14:51:42 +01:00
6 changed files with 1 additions and 37 deletions

View File

@@ -11,7 +11,7 @@ In SAP Business Application Studio, open a terminal.
Then clone the repo with this specific branch:
```sh
git clone https://github.com/sap-samples/cloud-cap-samples projects/cloud-cap-samples -b openSAP-week4-unit3-final
git clone https://github.com/sap-samples/cloud-cap-samples projects/cloud-cap-samples -b openSAP-week4-unit2-final
cd projects/cloud-cap-samples
```

View File

@@ -20,12 +20,8 @@
"kind": "odata",
"model": "srv/external/API_BUSINESS_PARTNER",
"--credentials": {
"prefix": "sap/S4HANAOD/c098/BO",
"destination": "cap-api098"
}
},
"--messaging": {
"kind": "enterprise-messaging"
}
}
}

View File

@@ -1,6 +0,0 @@
PATCH http://localhost:4004/api-business-partner/A_BusinessPartner('ALICE')
Content-Type: application/json
{
"BusinessPartnerIsBlocked": true
}

View File

@@ -16,10 +16,6 @@ service CatalogService {
BusinessPartnerIsBlocked
};
event OrderBlocked {
ID: UUID;
};
@requires_: 'authenticated-user'
@insertonly entity Orders as projection on my.Orders;

View File

@@ -8,19 +8,6 @@ module.exports = cds.service.impl(async function () {
this.before('CREATE', Orders, _reduceStock)
this.on('READ', BusinessPartners, req => bupaSrv.tx(req).run(req.query))
/** Block orders if business partner is blocked */
bupaSrv.on('BusinessPartner/Changed', async msg => {
console.log('>> Received BusinessPartner/Changed', msg.data)
const BUSINESSPARTNER = msg.data.KEY[0].BUSINESSPARTNER
const tx = cds.tx(msg)
const orders = await tx.run(SELECT('ID').from(Orders).where({ createdBy: BUSINESSPARTNER, status: 'processing' }))
if (!orders.length) return
const businessPartner = await bupaSrv.tx(msg).run(SELECT.one('BusinessPartnerIsBlocked').from(BusinessPartners).where({ ID: BUSINESSPARTNER }))
if (!businessPartner || !businessPartner.BusinessPartnerIsBlocked) return
await Promise.all(orders.map(order => tx.run(UPDATE(Orders).where(order).set({ status: 'blocked' }))))
orders.forEach(order => this.emit('OrderBlocked', order) && console.log('>> Emitted OrderBlocked', order))
})
/** Add some discount for overstocked books */
function _addDiscount2(each, discount) {
each.title += ` -- ${discount}% discount!`

View File

@@ -1,9 +0,0 @@
module.exports = srv => {
srv.on(['CREATE', 'UPDATE', 'DELETE'], req => {
const payload = {
KEY: [{ BUSINESSPARTNER: req.data.BusinessPartner }]
}
srv.emit('BusinessPartner/Changed', payload)
console.log('<< Emitted BusinessPartner/Changed', payload)
})
}