fixed minor issues
This commit is contained in:
@@ -2,6 +2,7 @@ const cds = require('@sap/cds')
|
||||
const { Books, ShippingAddresses, Orders } = cds.entities
|
||||
const RELEVANT_ADDRESS_COLUMNS = [
|
||||
'AddressID',
|
||||
'BusinessPartner',
|
||||
'CityName',
|
||||
'StreetName',
|
||||
'PostalCode',
|
||||
@@ -57,10 +58,10 @@ module.exports = cds.service.impl(function () {
|
||||
})
|
||||
|
||||
async function _readAddresses (req) {
|
||||
const BusinessPartner = req.user.id
|
||||
const businessPartner = req.user.id
|
||||
const tx = bupaSrv.transaction(req)
|
||||
const ql = SELECT.from('API_BUSINESS_PARTNER.A_BusinessPartnerAddress').where(
|
||||
{ BusinessPartner }
|
||||
{ BusinessPartner: businessPartner.toUpperCase() }
|
||||
)
|
||||
if (req.query && req.query.SELECT && req.query.SELECT.columns) {
|
||||
ql.columns(req.query.SELECT.columns)
|
||||
@@ -78,18 +79,17 @@ async function _readAddresses (req) {
|
||||
/** Fill Address data from external service */
|
||||
async function _fillAddress (req) {
|
||||
if (req.data.shippingAddress_AddressID) {
|
||||
const BusinessPartner = req.user.id
|
||||
const businessPartner = req.user.id
|
||||
const tx = bupaSrv.transaction(req)
|
||||
const response = await tx.run(
|
||||
SELECT.from('API_BUSINESS_PARTNER.A_BusinessPartnerAddress')
|
||||
.columns(RELEVANT_ADDRESS_COLUMNS)
|
||||
.where({
|
||||
AddressID: req.data.shippingAddress_AddressID,
|
||||
BusinessPartner
|
||||
BusinessPartner: businessPartner.toUpperCase()
|
||||
})
|
||||
)
|
||||
if (response && response.length > 0) {
|
||||
response[0].BusinessPartner = BusinessPartner
|
||||
console.log('to be inserted: ', response)
|
||||
const tx2 = cds.transaction(req)
|
||||
try {
|
||||
|
||||
@@ -6,7 +6,7 @@ module.exports = db => {
|
||||
DELETE.from(Addresses)
|
||||
INSERT.into(Addresses).entries(
|
||||
{
|
||||
BusinessPartner: 'anonymous',
|
||||
BusinessPartner: 'ANONYMOUS',
|
||||
AddressID: '62640',
|
||||
CityName: 'Walldorf',
|
||||
PostalCode: '69190',
|
||||
@@ -15,7 +15,7 @@ module.exports = db => {
|
||||
HouseNumber: '16'
|
||||
},
|
||||
{
|
||||
BusinessPartner: 'anonymous',
|
||||
BusinessPartner: 'ANONYMOUS',
|
||||
AddressID: '22222',
|
||||
CityName: 'St. Leon-Rot',
|
||||
PostalCode: '68789',
|
||||
|
||||
Reference in New Issue
Block a user