fixed a bug

This commit is contained in:
D065023
2019-12-11 16:37:51 +01:00
parent 348a7b191e
commit b298c9b708
6 changed files with 84 additions and 79 deletions

View File

@@ -1,6 +1,6 @@
namespace sap.capire.bookshop;
using { Currency, managed, cuid } from '@sap/cds/common';
using { API_BUSINESS_PARTNER.A_BusinessPartnerAddress as extAddresses } from '../srv/external/API_BUSINESS_PARTNER.csn';
using { API_BUSINESS_PARTNER.A_BusinessPartnerAddress as extAddresses } from '../srv/external/API_BUSINESS_PARTNER';
entity Books : managed {
key ID : Integer;

View File

@@ -22,7 +22,7 @@
}
},
"messaging": {
"kind": "file-based-messaging"
"kind": "enterprise-messaging"
}
},
"auth": {

View File

@@ -54,11 +54,13 @@ bupaSrv.on('sap/messaging/ccf/BO/BusinessPartner/Changed', async msg => {
try {
const remoteAddresses = await txExt.run(selectQl)
const qlsToUpdateDifferences = _qlsToUpdateDifferences(ownAddresses, remoteAddresses)
const tx2 = cds.transaction()
await Promise.all(qlsToUpdateDifferences.map(ql =>
tx2.run(ql)
))
tx2.commit()
if (qlsToUpdateDifferences.length) {
const tx2 = cds.transaction()
await Promise.all(qlsToUpdateDifferences.map(ql =>
tx2.run(ql)
))
tx2.commit()
}
} catch (e) {
console.error(e)
}

View File

@@ -0,0 +1,3 @@
BusinessPartner;AddressID;CityName;PostalCode;Country;StreetName;HouseNumber
ALICE;62640;Walldorf;69190;GER;Dietmer-Hopp-Allee;16
ALICE;62641;Berlin;69390;GER;Berlin-Street;19
1 BusinessPartner AddressID CityName PostalCode Country StreetName HouseNumber
2 ALICE 62640 Walldorf 69190 GER Dietmer-Hopp-Allee 16
3 ALICE 62641 Berlin 69390 GER Berlin-Street 19

72
packages/bookshop/srv/external/init.js vendored Normal file
View File

@@ -0,0 +1,72 @@
// module.exports = db => {
// const { A_BusinessPartnerAddress: Addresses } = db.entities(
// 'API_BUSINESS_PARTNER'
// )
// DELETE.from(Addresses)
// INSERT.into(Addresses).entries(
// {
// BusinessPartner: 'ANONYMOUS',
// AddressID: '62640',
// CityName: 'Walldorf',
// PostalCode: '69190',
// Country: 'GER',
// StreetName: 'Dietmar-Hopp-Allee',
// HouseNumber: '16'
// },
// {
// BusinessPartner: 'ANONYMOUS',
// AddressID: '22222',
// CityName: 'St. Leon-Rot',
// PostalCode: '68789',
// Country: 'GER',
// StreetName: 'SAP-Allee',
// HouseNumber: '25'
// },
// {
// BusinessPartner: 'ALICE',
// AddressID: '62640',
// CityName: 'Walldorf',
// PostalCode: '69190',
// Country: 'GER',
// StreetName: 'Dietmar-Hopp-Allee',
// HouseNumber: '16'
// },
// {
// BusinessPartner: 'ALICE',
// AddressID: '22222',
// CityName: 'St. Leon-Rot',
// PostalCode: '68789',
// Country: 'GER',
// StreetName: 'SAP-Allee',
// HouseNumber: '25'
// },
// {
// BusinessPartner: '1003765',
// AddressID: '28241',
// CityName: 'Palo Alto',
// PostalCode: '94306',
// Country: 'USA',
// StreetName: 'Hillview Avenue',
// HouseNumber: '26'
// },
// {
// BusinessPartner: '1003766',
// AddressID: '28244',
// CityName: 'Hallbergmoos',
// PostalCode: '85396',
// Country: 'GER',
// StreetName: 'Zeppelinstraße',
// HouseNumber: '93'
// },
// {
// BusinessPartner: '1003767',
// AddressID: '28247',
// CityName: 'Potsdam',
// PostalCode: '14467',
// Country: 'GER',
// StreetName: 'Konrad-Zuse-Ring',
// HouseNumber: '29'
// }
// )
// }

View File

@@ -1,72 +0,0 @@
module.exports = db => {
const { A_BusinessPartnerAddress: Addresses } = db.entities(
'API_BUSINESS_PARTNER'
)
DELETE.from(Addresses)
INSERT.into(Addresses).entries(
{
BusinessPartner: 'ANONYMOUS',
AddressID: '62640',
CityName: 'Walldorf',
PostalCode: '69190',
Country: 'GER',
StreetName: 'Dietmar-Hopp-Allee',
HouseNumber: '16'
},
{
BusinessPartner: 'ANONYMOUS',
AddressID: '22222',
CityName: 'St. Leon-Rot',
PostalCode: '68789',
Country: 'GER',
StreetName: 'SAP-Allee',
HouseNumber: '25'
},
{
BusinessPartner: 'ALICE',
AddressID: '62640',
CityName: 'Walldorf',
PostalCode: '69190',
Country: 'GER',
StreetName: 'Dietmar-Hopp-Allee',
HouseNumber: '16'
},
{
BusinessPartner: 'ALICE',
AddressID: '22222',
CityName: 'St. Leon-Rot',
PostalCode: '68789',
Country: 'GER',
StreetName: 'SAP-Allee',
HouseNumber: '25'
},
{
BusinessPartner: '1003765',
AddressID: '28241',
CityName: 'Palo Alto',
PostalCode: '94306',
Country: 'USA',
StreetName: 'Hillview Avenue',
HouseNumber: '26'
},
{
BusinessPartner: '1003766',
AddressID: '28244',
CityName: 'Hallbergmoos',
PostalCode: '85396',
Country: 'GER',
StreetName: 'Zeppelinstraße',
HouseNumber: '93'
},
{
BusinessPartner: '1003767',
AddressID: '28247',
CityName: 'Potsdam',
PostalCode: '14467',
Country: 'GER',
StreetName: 'Konrad-Zuse-Ring',
HouseNumber: '29'
}
)
}