From 145f15f962975b2bb279e23a5ea52b1dbee77a1d Mon Sep 17 00:00:00 2001 From: Muhammed Tareq Aziz Date: Wed, 5 Oct 2016 18:18:35 +0600 Subject: [PATCH] asset userid added on summary report --- calculate.js | 7 +++++-- excelCreator.js | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) 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) {