diff --git a/calculate.js b/calculate.js index 2473548..b925c24 100644 --- a/calculate.js +++ b/calculate.js @@ -6,7 +6,7 @@ module.exports = { if (Object.keys(job.Assets) && Object.keys(job.Assets).length !== 0) { // FIXME: more than one asset can be assigned to a job var assetKey = Object.keys(job.Assets)[0]; - key = job.Assets[assetKey].UserName; + key = job.Assets[assetKey].UserName; } else { key = "Not Assigned"; } @@ -19,6 +19,9 @@ module.exports = { } if (report[key] === undefined) { report[key] = {}; + if (params.query.usertype === "BIKE_MESSENGER") { + report[key].UserId = Object.keys(job.Assets)[0]; + } report[key].TotalDelivery = 0; report[key].TotalProductPrice = 0; report[key].TotalDeliveryCharge = 0; @@ -28,7 +31,7 @@ module.exports = { report[key].TotalCancelled = 0; } - if (report[key] !== undefined) { + if (report[key] !== undefined) { report[key].TotalDelivery += 1; report[key].TotalProductPrice += parseInt(job.Order.OrderCart.SubTotal); report[key].TotalDeliveryCharge += parseInt(job.Order.OrderCart.ServiceCharge); diff --git a/excelCreator.js b/excelCreator.js index db414cf..b3ad0dc 100644 --- a/excelCreator.js +++ b/excelCreator.js @@ -16,8 +16,10 @@ module.exports = { sheet1.set(6, 1, 'Cancelled'); sheet1.set(7, 1, 'ProductPrice'); sheet1.set(8, 1, 'DeliveryCharge'); - for (var row = 2; row <= Object.keys(report).length; row++) { + console.log(Object.keys(report).length); + for (var row = 2; row <= Object.keys(report).length + 1; row++) { var reportBaseIndex = row - 2; + console.log(reportBaseIndex) var key = Object.keys(report)[reportBaseIndex]; sheet1.set(1, row, key); if (report[key].TotalDelivery === undefined) {