Skip to content

Commit

Permalink
merged product search
Browse files Browse the repository at this point in the history
  • Loading branch information
tareq89 committed Mar 8, 2017
2 parents da728cb + 2c3fd5f commit 4c4ab99
Show file tree
Hide file tree
Showing 9 changed files with 175,567 additions and 47 deletions.
25 changes: 13 additions & 12 deletions calculate.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,20 @@ module.exports = {
var entry = {};

entry.trackingNumber = job.HRID
entry.DeliveryType = job.Order.Type;

if (job.Order.Type == "ClassifiedDelivery" && job.Order.Variant == "enterprise") {
entry.DeliveryType = "B2B Delivery";
} else if (job.Order.Type == "ClassifiedDelivery" && job.Order.Variant == "default") {
entry.DeliveryType = "B2B with Cash Delivery";
} else {
entry.DeliveryType = "Delivery";
}
entry.Status = job.State;
entry.PaymentStatus = job.PaymentStatus;

entry.OrderingDate = utility.getDate(job.CreateTime);
entry.OrderingTime = utility.getTime(job.CreateTime);

entry.CompletionETADate = "Not Completed";
entry.CompletionETATime = "Not Completed";
entry.CompletionETADate = utility.getDate(job.Order.ETA);
entry.CompletionETATime = utility.getTime(job.Order.ETA);
if (job.Order.ETA !== undefined) {
entry.CompletionETADate = utility.getDate(job.ETA);
entry.CompletionETATime = utility.getTime(job.ETA);
Expand Down Expand Up @@ -107,7 +111,7 @@ module.exports = {
entry.PickupStatus = job.Tasks[1].State;
entry.PickupETADate;
entry.PickupETATime = "Not Mentioned";
if (job.Order.JobTaskETAPreference !== undefined && job.Order.JobTaskETAPreference.length > 0) {
if (job.Order.JobTaskETAPreference !== null && job.Order.JobTaskETAPreference !== undefined && job.Order.JobTaskETAPreference.length > 0) {
var pickupEta = utility.getJobTaskPreferenceETA("PackagePickUp" ,job.Order.JobTaskETAPreference);
if (pickupEta) {
entry.PickupETADate = utility.getDate(pickupEta.ETA);
Expand All @@ -127,7 +131,7 @@ module.exports = {
entry.DeliveryETADate;
entry.DeliveryETATime = "Not Mentioned";

if (job.Order.JobTaskETAPreference !== undefined && job.Order.JobTaskETAPreference.length > 0) {
if (job.Order.JobTaskETAPreference !== null && job.Order.JobTaskETAPreference !== undefined && job.Order.JobTaskETAPreference.length > 0) {
var deliveryEta = utility.getJobTaskPreferenceETA("Delivery" ,job.Order.JobTaskETAPreference);
if (deliveryEta) {
entry.DeliveryETADate = utility.getDate(deliveryEta.ETA);
Expand Down Expand Up @@ -157,7 +161,7 @@ module.exports = {

entry.CashDeliveryETADate;
entry.CashDeliveryETATime = "Not Mentioned";
if (job.Order.JobTaskETAPreference !== undefined && job.Order.JobTaskETAPreference.length > 0) {
if (job.Order.JobTaskETAPreference !== null && job.Order.JobTaskETAPreference !== undefined && job.Order.JobTaskETAPreference.length > 0) {
var cashDeliveryEta = utility.getJobTaskPreferenceETA("SecureCashDelivery" ,job.Order.JobTaskETAPreference);
if (cashDeliveryEta) {
entry.CashDeliveryETADate = utility.getDate(cashDeliveryEta.ETA);
Expand All @@ -170,10 +174,7 @@ module.exports = {
entry.CashDeliveryCompleteTime = utility.getTime(job.Tasks[3].CompletionTime);
entry.TotalCashDeliveryTime = utility.getHoursDifference(job.Tasks[3].InitiationTime, job.Tasks[3].CompletionTime);
}



entry.VendorInvoiceNo = null;
entry.VendorInvoiceNo = job.Order.ReferenceInvoiceId;
entry.Commission = null;
entry.CashRecieved = null;
entry.KM = null;
Expand Down
86 changes: 71 additions & 15 deletions excelCreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ module.exports = {
var workbookName = Date.now().toString() + 'summary.xlsx';
var reportFileName = directoryName + workbookName;

var workbook = excelbuilder.createWorkbook(directoryName, workbookName);
console.log(Object.keys(report).length)
var workbook = excelbuilder.createWorkbook(directoryName, workbookName);

var sheet1 = workbook.createSheet('sheet1', 8, Object.keys(report).length+1);
sheet1.set(1, 1, 'Name');
sheet1.set(2, 1, 'Delivery');
Expand All @@ -16,16 +16,13 @@ module.exports = {
sheet1.set(5, 1, 'Completed');
sheet1.set(6, 1, 'Cancelled');
sheet1.set(7, 1, 'ProductPrice');
sheet1.set(8, 1, 'DeliveryCharge');
console.log(Object.keys(report).length);
sheet1.set(8, 1, 'DeliveryCharge');
for (var row = 2; row <= Object.keys(report).length + 1; row++) {
var reportBaseIndex = row - 2;
console.log(reportBaseIndex)
var reportBaseIndex = row - 2;
var key = Object.keys(report)[reportBaseIndex];
sheet1.set(1, row, key);
if (report[key].TotalDelivery === undefined) {
console.log()
console.log(report[key])
if (report[key].TotalDelivery === undefined) {

}
sheet1.set(2, row, report[key].TotalDelivery);
sheet1.set(3, row, report[key].TotalPending);
Expand All @@ -49,7 +46,7 @@ module.exports = {
var reportFileName = directoryName + workbookName;

var workbook = excelbuilder.createWorkbook(directoryName, workbookName);
var sheet1 = workbook.createSheet('sheet1', 55, report.length + 1);
var sheet1 = workbook.createSheet('sheet1', 56, report.length + 1);

sheet1.set(1, 1, 'trackingNumber');
sheet1.set(2, 1, 'DeliveryType');
Expand Down Expand Up @@ -106,11 +103,10 @@ module.exports = {
sheet1.set(53, 1, 'KM');
sheet1.set(54, 1, 'ProductType');
sheet1.set(55, 1, 'Comment');

console.log(report.length);
sheet1.set(56, 1, 'NoteToDeliveryMan');

for (var row = 2; row <= (report.length+1); row++) {
var e = report[row-2];
console.log(row-2);
var e = report[row-2];
sheet1.set(1, row, e.trackingNumber);
sheet1.set(2, row, e.DeliveryType);
sheet1.set(3, row, e.OrderingDate);
Expand Down Expand Up @@ -166,13 +162,73 @@ module.exports = {
sheet1.set(53, row, e.KM);
sheet1.set(54, row, e.ProductType);
sheet1.set(55, row, e.Comment);

sheet1.set(56, row, e.SpecialNote);
}

return {
workbookFilePath: reportFileName,
workbook: workbook
}
},

getDetailsSummaryReport: function (report) {
var excelbuilder = require('msexcel-builder');
var directoryName = __dirname + "/excel/";
var workbookName = Date.now().toString() + 'details.xlsx';
var reportFileName = directoryName + workbookName;

var workbook = excelbuilder.createWorkbook(directoryName, workbookName);
var sheet1 = workbook.createSheet('sheet1', 19, report.length + 1);
function returnTaskStatus(report) {
return "Pickup: " + report.PickupStatus + ", Completion Date: " + report.PickupCompleteDate + "\n" +
"Delivery: " + report.DeliveryStatus + ", Completion Date: " + report.DeliveryCompleteDate + "\n" +
"CashDelivery: " + report.CashDeliveryStatus + ", Completion Date: " + report.CashDeliveryCompleteDate;
}
sheet1.set(1, 1, 'TrackingNumber');
sheet1.set(2, 1, 'VendorInvoiceNo');
sheet1.set(3, 1, 'Status');
sheet1.set(4, 1, 'Pickup Status');
sheet1.set(5, 1, 'Delivery Status');
sheet1.set(6, 1, 'Cash Delivery Status');
sheet1.set(7, 1, 'DeliveryType');
sheet1.set(8, 1, 'OrderingDate');
sheet1.set(9, 1, 'CompleteDate');
sheet1.set(10, 1, 'UserName');
sheet1.set(11, 1, 'PickupAddress');
sheet1.set(12, 1, 'DeliveryAddress');
sheet1.set(13, 1, 'Product');
sheet1.set(14, 1, 'Weight');
sheet1.set(15, 1, 'DeliveryCharge');
sheet1.set(16, 1, 'Commission');
sheet1.set(17, 1, 'TotalProductPrice');
sheet1.set(18, 1, 'Total');
sheet1.set(19, 1, 'PaymentStatus');
for (var row = 2; row <= (report.length+1); row++) {
var e = report[row-2];
sheet1.set(1, row, e.trackingNumber);
sheet1.set(2, row, e.VendorInvoiceNo);
sheet1.set(3, row, e.Status);
sheet1.set(4, row, e.PickupStatus + "\nDate: " + e.PickupCompleteDate);
sheet1.set(5, row, e.DeliveryStatus + "\nDate: " + e.DeliveryCompleteDate);
sheet1.set(6, row, e.CashDeliveryStatus + "\nDate: " + e.CashDeliveryCompleteDate);
sheet1.set(7, row, e.DeliveryType);
sheet1.set(8, row, e.OrderingDate);
sheet1.set(9, row, e.CompleteDate);
sheet1.set(10, row, e.UserName);
sheet1.set(11, row, e.PickupAddress);
sheet1.set(12, row, e.DeliveryAddress);
sheet1.set(13, row, e.Product);
sheet1.set(14, row, e.Weight);
sheet1.set(15, row, e.DeliveryCharge);
sheet1.set(16, row, e.Commission);
sheet1.set(17, row, e.TotalProductPrice);
sheet1.set(18, row, e.Total);
sheet1.set(19, row, e.PaymentStatus);
}

return {
workbookFilePath: reportFileName,
workbook: workbook
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"body-parser": "^1.15.2",
"cors": "^2.8.1",
"express": "^4.14.0",
"moment": "^2.15.1",
"moment": "^2.15.2",
"mongodb": "^2.2.10",
"mongoose": "^4.6.0",
"msexcel-builder": "0.0.2"
Expand Down
Loading

0 comments on commit 4c4ab99

Please sign in to comment.