vn-cc-vmp/queries.js

43 lines
1.2 KiB
JavaScript

function getInsertSupply(){
var sql = `INSERT INTO edi.supplyResponse( \
marketPlace, \
imageReference, \
supplierParty, \
productVnhCode, \
productDescription, \
quantity, \
incrementalOrderableQuantity, \
chargeAmount, \
unitCode, \
packageQuantity, \
earliestDespatch, \
latestDelivery, \
) VALUES ?`;
return sql;
}
function getValuesSupply(supplyResponse){
var insertRows = [];
for (let aux of supplyResponse.Body.SupplyResponseDetails.SupplyTradeLineItem){
insertRows.push(
[
aux.ID._,
aux.TradingTerms.MarketPlace.ID._,
aux.SupplierParty.PrimaryID._ ,
aux.Product.IndustryAssignedID._,
aux.Product.DescriptionText._,
aux.Quantity._,
aux.IncrementalOrderableQuantity._,
aux.Price.ChargeAmount._,
aux.Quantity.$.unitCode,
aux.Packing.Package.Quantity._,
aux.Delivery[0].LatestDeliveryDateTime,
aux.Delivery[0].LatestDeliveryDateTime
]);
}
return insertRows;
}
exports.getInsertSupply = getInsertSupply;
exports.getValuesSupply = getValuesSupply;