cosmetics
This commit is contained in:
@@ -37,16 +37,16 @@ module.exports = cds.service.impl(async () => {
|
|||||||
bupa.on('BusinessPartner/Changed', async msg => {
|
bupa.on('BusinessPartner/Changed', async msg => {
|
||||||
console.log('>> received:', msg.data)
|
console.log('>> received:', msg.data)
|
||||||
|
|
||||||
const BPID = msg.data.KEY[0].BUSINESSPARTNER
|
const contact = msg.data.KEY[0].BUSINESSPARTNER
|
||||||
const { SELECT, UPDATE } = cds.ql(msg) //> convenient alternative to <srv>.transaction(req).run(SELECT...)
|
const { SELECT, UPDATE } = cds.ql(msg) //> convenient alternative to <srv>.transaction(req).run(SELECT...)
|
||||||
|
|
||||||
// fetch affected entries from local replicas
|
// fetch affected entries from local replicas
|
||||||
const replicas = await SELECT.from(Addresses).where({ contact: BPID })
|
const replicas = await SELECT.from(Addresses).where({ contact })
|
||||||
if (replicas.length === 0) return //> not affected
|
if (replicas.length === 0) return //> not affected
|
||||||
|
|
||||||
// fetch changed data from S/4 -> might be less than local due to deletes
|
// fetch changed data from S/4 -> might be less than local due to deletes
|
||||||
const changed = (await SELECT.from(externalAddresses).where({
|
const changed = (await SELECT.from(externalAddresses).where({
|
||||||
contact: BPID
|
contact
|
||||||
})).filter(({ ID }) => replicas.some(rep => ID === rep.ID))
|
})).filter(({ ID }) => replicas.some(rep => ID === rep.ID))
|
||||||
|
|
||||||
// update local replicas with changes from S/4
|
// update local replicas with changes from S/4
|
||||||
|
|||||||
Reference in New Issue
Block a user