fixing
This commit is contained in:
parent
291eb17238
commit
2c6e38094c
@ -1,10 +1,8 @@
|
||||
import { Inventory } from "../Inventory/InventoryModel.js";
|
||||
import User from "../user/userModel.js";
|
||||
import { KYC } from "../KYC/KycModel.js";
|
||||
import ShippingAddress from "../ShippingAddresses/ShippingAddressModel.js";
|
||||
import TerritoryManager from "../TerritoryManagers/TerritoryManagerModel.js";
|
||||
import SalesCoordinator from "../SalesCoOrdinators/SalesCoOrdinatorModel.js";
|
||||
import crypto from "crypto";
|
||||
import RetailDistributor from "../RetailDistributor/RetailDistributorModel.js";
|
||||
import { RDStock } from "../Stock/RdStockModel.js";
|
||||
// Add inventory data
|
||||
@ -125,7 +123,7 @@ export const getDistributors = async (req, res) => {
|
||||
})
|
||||
);
|
||||
} else {
|
||||
// For RetailDistributor, fetch approved KYC documents
|
||||
// For RetailDistributor
|
||||
distributors = await RetailDistributor.find(query)
|
||||
.populate("kyc")
|
||||
.sort({ createdAt: -1 });
|
||||
@ -197,8 +195,8 @@ export const getAllInventories = async (req, res) => {
|
||||
addedForData.shippingAddress?.tradeName?.toLowerCase() || "";
|
||||
}
|
||||
} else if (inventory.addedFor === "RetailDistributor") {
|
||||
addedForData = await KYC.findById(inventory.addedForId);
|
||||
tradeName = addedForData?.trade_name?.toLowerCase() || "";
|
||||
addedForData = await RetailDistributor.findById(inventory.addedForId).populate("kyc");
|
||||
tradeName = addedForData?.kyc?.trade_name?.toLowerCase() || "";
|
||||
}
|
||||
|
||||
return {
|
||||
@ -275,7 +273,7 @@ export const getSingleInventory = async (req, res) => {
|
||||
shippingAddress,
|
||||
};
|
||||
} else if (inventory.addedFor === "RetailDistributor") {
|
||||
addedForData = await KYC.findById(inventory.addedForId);
|
||||
addedForData = await RetailDistributor.findById(inventory.addedForId).populate("kyc");
|
||||
}
|
||||
|
||||
res.status(200).json({
|
||||
|
Loading…
Reference in New Issue
Block a user