rm bug
This commit is contained in:
@@ -13,15 +13,14 @@ module.exports = cds.service.impl(async function () {
|
|||||||
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)
|
console.log(orders)
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
/** 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!`
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Reduce stock of ordered books if available stock suffices */
|
/** Reduce stock of ordered books if available stock suffices */
|
||||||
async function _reduceStock(req) {
|
async function _reduceStock(req) {
|
||||||
const { Items: OrderItems } = req.data
|
const { Items: OrderItems } = req.data
|
||||||
return cds.transaction(req).run(() => OrderItems.map(order =>
|
return cds.transaction(req).run(() => OrderItems.map(order =>
|
||||||
UPDATE(Books).set('stock -=', order.amount)
|
UPDATE(Books).set('stock -=', order.amount)
|
||||||
@@ -31,4 +30,5 @@ async function _reduceStock(req) {
|
|||||||
`${OrderItems[i].amount} exceeds stock for book #${OrderItems[i].book_ID}`
|
`${OrderItems[i].amount} exceeds stock for book #${OrderItems[i].book_ID}`
|
||||||
)
|
)
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user