Enhanced filament schema and related service functions to include vendor information. Updated route handlers to support vendor population in filament queries and exports, improving data management and retrieval capabilities.
Some checks failed
farmcontrol/farmcontrol-api/pipeline/head There was a failure building this commit
Some checks failed
farmcontrol/farmcontrol-api/pipeline/head There was a failure building this commit
This commit is contained in:
parent
fa74c464f9
commit
5ee8f332e2
@ -6,6 +6,7 @@ const { Schema } = mongoose;
|
||||
const filamentSchema = new mongoose.Schema({
|
||||
_reference: { type: String, default: () => generateId()() },
|
||||
name: { required: true, type: String },
|
||||
vendor: { type: Schema.Types.ObjectId, ref: 'vendor', required: false },
|
||||
barcode: { required: false, type: String },
|
||||
url: { required: false, type: String },
|
||||
image: { required: false, type: Buffer },
|
||||
|
||||
@ -39,7 +39,7 @@ export const listFilamentsRouteHandler = async (
|
||||
search,
|
||||
sort,
|
||||
order,
|
||||
populate: ['costTaxRate', 'material'],
|
||||
populate: ['costTaxRate', 'material', 'vendor'],
|
||||
});
|
||||
|
||||
if (result?.error) {
|
||||
@ -98,7 +98,7 @@ export const getFilamentRouteHandler = async (req, res) => {
|
||||
const result = await getObject({
|
||||
model: filamentModel,
|
||||
id,
|
||||
populate: ['costTaxRate', 'material'],
|
||||
populate: ['costTaxRate', 'material', 'vendor'],
|
||||
});
|
||||
if (result?.error) {
|
||||
logger.warn(`Filament not found with supplied id.`);
|
||||
@ -117,6 +117,7 @@ export const editFilamentRouteHandler = async (req, res) => {
|
||||
const updateData = {
|
||||
updatedAt: new Date(),
|
||||
name: req.body.name,
|
||||
vendor: req.body.vendor,
|
||||
barcode: req.body.barcode,
|
||||
url: req.body.url,
|
||||
image: req.body.image,
|
||||
@ -133,7 +134,7 @@ export const editFilamentRouteHandler = async (req, res) => {
|
||||
id,
|
||||
updateData,
|
||||
user: req.user,
|
||||
populate: ['costTaxRate', 'material'],
|
||||
populate: ['costTaxRate', 'material', 'vendor'],
|
||||
});
|
||||
|
||||
if (result.error) {
|
||||
@ -151,6 +152,7 @@ export const editMultipleFilamentsRouteHandler = async (req, res) => {
|
||||
const updates = req.body.map((update) => ({
|
||||
_id: update._id,
|
||||
name: update.name,
|
||||
vendor: update.vendor,
|
||||
barcode: update.barcode,
|
||||
url: update.url,
|
||||
image: update.image,
|
||||
@ -189,6 +191,7 @@ export const newFilamentRouteHandler = async (req, res) => {
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
name: req.body.name,
|
||||
vendor: req.body.vendor,
|
||||
barcode: req.body.barcode,
|
||||
url: req.body.url,
|
||||
image: req.body.image,
|
||||
|
||||
@ -13,8 +13,8 @@ export const EXPORT_FILTER_BY_TYPE = {
|
||||
subJob: ['job'],
|
||||
filamentStock: ['filament', 'filament._id', 'filamentSku'],
|
||||
gcodeFile: ['filament', 'filament._id', 'filamentSku'],
|
||||
filament: ['material', 'material._id', 'name', 'diameter', 'cost'],
|
||||
filamentSku: ['filament', 'vendor', 'costTaxRate'],
|
||||
filament: ['material', 'material._id', 'vendor', 'name', 'diameter', 'cost'],
|
||||
filamentSku: ['filament', 'filament.vendor', 'costTaxRate'],
|
||||
material: ['name', 'tags'],
|
||||
partStock: ['partSku'],
|
||||
partSku: ['part', 'vendor', 'priceTaxRate', 'costTaxRate'],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user