async style
This commit is contained in:
@@ -19,7 +19,7 @@ function _addDiscount2 (each, discount) {
|
||||
/** Reduce stock of ordered books if available stock suffices */
|
||||
async function _reduceStock(req) {
|
||||
const { Items: OrderItems } = req.data
|
||||
return cds
|
||||
const all = await cds
|
||||
.transaction(req)
|
||||
.run(() =>
|
||||
OrderItems.map(order =>
|
||||
@@ -29,7 +29,6 @@ async function _reduceStock (req) {
|
||||
.and('stock >=', order.amount)
|
||||
)
|
||||
)
|
||||
.then(all =>
|
||||
all.forEach((affectedRows, i) => {
|
||||
if (affectedRows === 0)
|
||||
req.error(
|
||||
@@ -39,5 +38,4 @@ async function _reduceStock (req) {
|
||||
}`
|
||||
)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user