diff --git a/resources/PD_Orders/pdOrderController.js b/resources/PD_Orders/pdOrderController.js index 6de1af6..bebadc9 100644 --- a/resources/PD_Orders/pdOrderController.js +++ b/resources/PD_Orders/pdOrderController.js @@ -816,13 +816,13 @@ export const getProcessingInvoices = async (req, res) => { query.invoiceId = { $regex: invoiceId, $options: "i" }; } const invoices = await Invoice.find(query) - .sort({ createdAt: -1 }) - .skip(skip) - .limit(limit) - .populate({ - path: "orderId", - select: "uniqueId", - }); + .skip(skip) + .limit(limit) + .populate({ + path: "orderId", + select: "uniqueId", + }) + .sort({ "courierstatus_timeline.processing": -1 }); if (orderId) { const filteredInvoices = invoices.filter( @@ -1026,7 +1026,8 @@ export const getDispatchedInvoices = async (req, res) => { .populate({ path: "orderId", select: "uniqueId", - }); + }) + .sort({ "courierstatus_timeline.dispatched": -1 }); if (orderId) { const filteredInvoices = invoices.filter( @@ -1213,7 +1214,8 @@ export const getDeliveredInvoices = async (req, res) => { .populate({ path: "orderId", select: "uniqueId", - }); + }) + .sort({ "courierstatus_timeline.delivered": -1 }); if (orderId) { const filteredInvoices = invoices.filter(