This commit is contained in:
D065023
2020-01-29 14:57:38 +01:00
parent c58bcf905f
commit 9861b05f2d
4 changed files with 3 additions and 25 deletions

View File

@@ -1,12 +1,10 @@
const cds = require('@sap/cds')
/** Service implementation for CatalogService */
module.exports = cds.service.impl(async function () {
const { Books, Orders, BusinessPartners } = this.entities
const bupaSrv = await cds.connect.to('API_BUSINESS_PARTNER')
module.exports = cds.service.impl(function () {
const { Books, Orders } = this.entities
this.after('READ', Books, each => each.stock > 111 && _addDiscount2(each, 11))
this.before('CREATE', Orders, _reduceStock)
this.on('READ', BusinessPartners, req => bupaSrv.tx(req).run(req.query))
/** Add some discount for overstocked books */
function _addDiscount2(each, discount) {