small update in get SUB

This commit is contained in:
ROSHAN GARG 2024-09-24 14:31:58 +05:30
parent 2968131835
commit a6d632e663
8 changed files with 22 additions and 16 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

View File

@ -806,13 +806,13 @@ export const getProcessingInvoices = async (req, res) => {
try {
const page = parseInt(req.query.page, 10) || 1;
const limit = parseInt(req.query.limit, 10) || 5;
const { invoiceId, orderId } = req.query;
const { invoiceId, orderId } = req.query;
const skip = (page - 1) * limit;
let query = { courierStatus: "processing" };
if (invoiceId) {
query.invoiceId = { $regex: invoiceId, $options: "i" };
query.invoiceId = { $regex: invoiceId, $options: "i" };
}
const invoices = await Invoice.find(query)
.sort({ createdAt: -1 })
@ -824,9 +824,11 @@ export const getProcessingInvoices = async (req, res) => {
});
if (orderId) {
const filteredInvoices = invoices.filter(invoice =>
invoice.orderId && invoice.orderId.uniqueId &&
invoice.orderId.uniqueId.toLowerCase().includes(orderId.toLowerCase())
const filteredInvoices = invoices.filter(
(invoice) =>
invoice.orderId &&
invoice.orderId.uniqueId &&
invoice.orderId.uniqueId.toLowerCase().includes(orderId.toLowerCase())
);
res.status(200).json({
totalCount: filteredInvoices.length,
@ -858,7 +860,7 @@ export const getInvoiceDetailsById = async (req, res) => {
populate: {
path: "addedBy",
model: "User",
select: "name email phone", // Select only specific fields
select: "name email phone SBU", // Select only specific fields
},
});
@ -1008,13 +1010,13 @@ export const getDispatchedInvoices = async (req, res) => {
try {
const page = parseInt(req.query.page, 10) || 1;
const limit = parseInt(req.query.limit, 10) || 5;
const { invoiceId, orderId } = req.query;
const { invoiceId, orderId } = req.query;
const skip = (page - 1) * limit;
let query = { courierStatus: "dispatched" };
if (invoiceId) {
query.invoiceId = { $regex: invoiceId, $options: "i" };
query.invoiceId = { $regex: invoiceId, $options: "i" };
}
const invoices = await Invoice.find(query)
.sort({ createdAt: -1 })
@ -1026,9 +1028,11 @@ export const getDispatchedInvoices = async (req, res) => {
});
if (orderId) {
const filteredInvoices = invoices.filter(invoice =>
invoice.orderId && invoice.orderId.uniqueId &&
invoice.orderId.uniqueId.toLowerCase().includes(orderId.toLowerCase())
const filteredInvoices = invoices.filter(
(invoice) =>
invoice.orderId &&
invoice.orderId.uniqueId &&
invoice.orderId.uniqueId.toLowerCase().includes(orderId.toLowerCase())
);
res.status(200).json({
totalCount: filteredInvoices.length,
@ -1193,13 +1197,13 @@ export const getDeliveredInvoices = async (req, res) => {
try {
const page = parseInt(req.query.page, 10) || 1;
const limit = parseInt(req.query.limit, 10) || 5;
const { invoiceId, orderId } = req.query;
const { invoiceId, orderId } = req.query;
const skip = (page - 1) * limit;
let query = { courierStatus: "delivered" };
if (invoiceId) {
query.invoiceId = { $regex: invoiceId, $options: "i" };
query.invoiceId = { $regex: invoiceId, $options: "i" };
}
const invoices = await Invoice.find(query)
.sort({ createdAt: -1 })
@ -1211,9 +1215,11 @@ export const getDeliveredInvoices = async (req, res) => {
});
if (orderId) {
const filteredInvoices = invoices.filter(invoice =>
invoice.orderId && invoice.orderId.uniqueId &&
invoice.orderId.uniqueId.toLowerCase().includes(orderId.toLowerCase())
const filteredInvoices = invoices.filter(
(invoice) =>
invoice.orderId &&
invoice.orderId.uniqueId &&
invoice.orderId.uniqueId.toLowerCase().includes(orderId.toLowerCase())
);
res.status(200).json({
totalCount: filteredInvoices.length,