date wise order sort

This commit is contained in:
Sibunnayak 2024-09-25 10:24:51 +05:30
parent 24018d4bdf
commit bd44ab91b6

View File

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