Compare commits

...

2 Commits

133 changed files with 782 additions and 3 deletions

View File

@ -416,6 +416,34 @@ export const listObjects = async ({
}
};
export const searchObjects = async ({ model, search, populate = [] }) => {
try {
const isRefOrIdSearch = search.match(/^.{3}:/);
let query = null;
if (isRefOrIdSearch) {
const lookupValue = search.split(':')[1];
if (lookupValue.length <= 12) {
query = model.find({ _reference: lookupValue });
} else {
query = model.find({ _id: lookupValue });
}
} else {
query = model.find({ $text: { $search: search } });
}
if (populate) {
for (const pop of populate) {
query = query.populate(pop);
}
}
const queryResult = await query.lean();
const result = queryResult.map((item) => expandObjectIds(item));
return result;
} catch (error) {
logger.error('Object search error:', error);
return { error: error, code: 500 };
}
};
// New function to list unique property values
export const listPropertyValues = async ({ model, property, filter = {}, search = '' }) => {
let aggregateCommand = [];

View File

@ -54,6 +54,8 @@ const invoiceSchema = new Schema(
{ timestamps: true }
);
invoiceSchema.index({ orderType: 'text', fromType: 'text', toType: 'text' });
const rollupConfigs = [
{
name: 'draft',

View File

@ -24,6 +24,8 @@ const paymentSchema = new Schema(
{ timestamps: true }
);
paymentSchema.index({ paymentMethod: 'text', notes: 'text' });
const rollupConfigs = [
{
name: 'draft',

View File

@ -19,6 +19,8 @@ const taxRecordSchema = new Schema(
{ timestamps: true }
);
taxRecordSchema.index({ transactionType: 'text' });
taxRecordSchema.virtual('id').get(function () {
return this._id;
});

View File

@ -49,6 +49,8 @@ const filamentStockSchema = new Schema(
{ timestamps: true }
);
filamentStockSchema.index({ 'state.type': 'text' });
filamentStockSchema.pre('validate', async function () {
if (!this.filament && this.filamentSku) {
const sku = await mongoose

View File

@ -69,6 +69,8 @@ const orderItemSchema = new Schema(
{ timestamps: true }
);
orderItemSchema.index({ name: 'text', itemType: 'text', orderType: 'text' });
const rollupConfigs = [
{
name: 'shipped',

View File

@ -43,6 +43,8 @@ const partStockSchema = new Schema(
{ timestamps: true }
);
partStockSchema.index({ sourceType: 'text', 'state.type': 'text' });
const rollupConfigs = [
{
name: 'totalCurrentQuantity',

View File

@ -49,6 +49,8 @@ const productStockSchema = new Schema(
{ timestamps: true }
);
productStockSchema.index({ 'state.type': 'text' });
const rollupConfigs = [
{
name: 'totalCurrentQuantity',

View File

@ -25,6 +25,8 @@ const purchaseOrderSchema = new Schema(
{ timestamps: true }
);
purchaseOrderSchema.index({ 'state.type': 'text' });
const rollupConfigs = [
{
name: 'draft',

View File

@ -34,6 +34,8 @@ const shipmentSchema = new Schema(
{ timestamps: true }
);
shipmentSchema.index({ trackingNumber: 'text', orderType: 'text' });
shipmentSchema.statics.recalculate = async function (shipment, user) {
if (shipment.orderType !== 'purchaseOrder' && shipment.orderType !== 'salesOrder') {
return;

View File

@ -28,6 +28,8 @@ const stockAuditSchema = new Schema(
{ timestamps: true }
);
stockAuditSchema.index({ type: 'text', status: 'text', notes: 'text' });
// Add virtual id getter
stockAuditSchema.virtual('id').get(function () {
return this._id;

View File

@ -32,6 +32,8 @@ const stockEventSchema = new Schema(
{ timestamps: true }
);
stockEventSchema.index({ parentType: 'text', ownerType: 'text', unit: 'text' });
// Add virtual id getter
stockEventSchema.virtual('id').get(function () {
return this._id;

View File

@ -21,6 +21,8 @@ const stockLocationSchema = new Schema(
{ timestamps: true }
);
stockLocationSchema.index({ name: 'text' });
stockLocationSchema.statics.stats = async function () {
const total = await this.countDocuments({});
return { total: { count: total } };

View File

@ -48,6 +48,8 @@ const stockTransferSchema = new Schema(
{ timestamps: true }
);
stockTransferSchema.index({ name: 'text' });
stockTransferSchema.statics.stats = async function () {
const [draft, posted] = await Promise.all([
this.countDocuments({ 'state.type': 'draft' }),

View File

@ -13,6 +13,8 @@ const appPasswordSchema = new mongoose.Schema(
{ timestamps: true }
);
appPasswordSchema.index({ name: 'text' });
appPasswordSchema.virtual('id').get(function () {
return this._id;
});

View File

@ -36,6 +36,8 @@ const auditLogSchema = new Schema(
{ timestamps: true }
);
auditLogSchema.index({ operation: 'text', parentType: 'text', ownerType: 'text' });
// Add virtual id getter
auditLogSchema.virtual('id').get(function () {
return this._id;

View File

@ -14,6 +14,8 @@ const courierSchema = new mongoose.Schema(
{ timestamps: true }
);
courierSchema.index({ name: 'text', website: 'text', email: 'text', phone: 'text', contact: 'text', country: 'text' });
courierSchema.virtual('id').get(function () {
return this._id;
});

View File

@ -15,6 +15,8 @@ const courierServiceSchema = new mongoose.Schema(
{ timestamps: true }
);
courierServiceSchema.index({ name: 'text', website: 'text' });
courierServiceSchema.virtual('id').get(function () {
return this._id;
});

View File

@ -39,6 +39,8 @@ const documentJobSchema = new Schema(
{ timestamps: true }
);
documentJobSchema.index({ name: 'text', objectType: 'text' });
// Add virtual id getter
documentJobSchema.virtual('id').get(function () {
return this._id;

View File

@ -38,6 +38,8 @@ const documentPrinterSchema = new Schema(
{ timestamps: true }
);
documentPrinterSchema.index({ name: 'text', tags: 'text' });
// Add virtual id getter
documentPrinterSchema.virtual('id').get(function () {
return this._id;

View File

@ -29,6 +29,8 @@ const documentSizeSchema = new Schema(
{ timestamps: true }
);
documentSizeSchema.index({ name: 'text' });
// Add virtual id getter
documentSizeSchema.virtual('id').get(function () {
return this._id;

View File

@ -52,6 +52,8 @@ const documentTemplateSchema = new Schema(
{ timestamps: true }
);
documentTemplateSchema.index({ name: 'text', tags: 'text', objectType: 'text' });
// Add virtual id getter
documentTemplateSchema.virtual('id').get(function () {
return this._id;

View File

@ -18,6 +18,8 @@ const filamentSchema = new mongoose.Schema({
costWithTax: { type: Number, required: false },
}, { timestamps: true });
filamentSchema.index({ name: 'text', barcode: 'text', url: 'text' });
filamentSchema.virtual('id').get(function () {
return this._id;
});

View File

@ -19,6 +19,8 @@ const filamentSkuSchema = new Schema(
{ timestamps: true }
);
filamentSkuSchema.index({ name: 'text', barcode: 'text', description: 'text', color: 'text' });
// Add virtual id getter
filamentSkuSchema.virtual('id').get(function () {
return this._id;

View File

@ -13,6 +13,8 @@ const fileSchema = new mongoose.Schema(
{ timestamps: true }
);
fileSchema.index({ name: 'text', type: 'text', extension: 'text' });
fileSchema.virtual('id').get(function () {
return this._id;
});

View File

@ -63,6 +63,8 @@ const hostSchema = new mongoose.Schema(
{ timestamps: true }
);
hostSchema.index({ name: 'text', tags: 'text' });
hostSchema.virtual('id').get(function () {
return this._id;
});

View File

@ -11,6 +11,8 @@ const materialSchema = new mongoose.Schema(
{ timestamps: true }
);
materialSchema.index({ name: 'text', url: 'text', tags: 'text' });
materialSchema.virtual('id').get(function () {
return this._id;
});

View File

@ -23,6 +23,8 @@ const noteTypeSchema = new Schema(
{ timestamps: true }
);
noteTypeSchema.index({ name: 'text' });
// Add virtual id getter
noteTypeSchema.virtual('id').get(function () {
return this._id;

View File

@ -21,6 +21,8 @@ const partSchema = new Schema(
{ timestamps: true }
);
partSchema.index({ name: 'text' });
// Add virtual id getter
partSchema.virtual('id').get(function () {
return this._id;

View File

@ -25,6 +25,8 @@ const partSkuSchema = new Schema(
{ timestamps: true }
);
partSkuSchema.index({ name: 'text', barcode: 'text', description: 'text' });
// Add virtual id getter
partSkuSchema.virtual('id').get(function () {
return this._id;

View File

@ -23,6 +23,9 @@ const productSchema = new Schema(
},
{ timestamps: true }
);
productSchema.index({ name: 'text', tags: 'text', version: 'text' });
// Add virtual id getter
productSchema.virtual('id').get(function () {
return this._id;

View File

@ -9,6 +9,8 @@ const productCategorySchema = new mongoose.Schema(
{ timestamps: true }
);
productCategorySchema.index({ name: 'text' });
productCategorySchema.virtual('id').get(function () {
return this._id;
});

View File

@ -32,6 +32,8 @@ const productSkuSchema = new Schema(
{ timestamps: true }
);
productSkuSchema.index({ name: 'text', barcode: 'text', description: 'text' });
// Add virtual id getter
productSkuSchema.virtual('id').get(function () {
return this._id;

View File

@ -16,6 +16,8 @@ const taxRateSchema = new mongoose.Schema(
{ timestamps: true }
);
taxRateSchema.index({ name: 'text', description: 'text', country: 'text' });
taxRateSchema.virtual('id').get(function () {
return this._id;
});

View File

@ -15,6 +15,8 @@ const userSchema = new mongoose.Schema(
{ timestamps: true }
);
userSchema.index({ username: 'text', name: 'text', firstName: 'text', lastName: 'text', email: 'text' });
userSchema.virtual('id').get(function () {
return this._id;
});

View File

@ -26,6 +26,8 @@ const vendorSchema = new mongoose.Schema(
{ timestamps: true }
);
vendorSchema.index({ name: 'text', website: 'text', email: 'text', phone: 'text', contact: 'text', country: 'text' });
vendorSchema.virtual('id').get(function () {
return this._id;
});

View File

@ -30,7 +30,7 @@ gcodeFileSchema.pre('validate', async function () {
}
});
gcodeFileSchema.index({ name: 'text', brand: 'text' });
gcodeFileSchema.index({ name: 'text', gcodeFileName: 'text' });
gcodeFileSchema.virtual('id').get(function () {
return this._id;

View File

@ -32,6 +32,8 @@ const jobSchema = new mongoose.Schema(
{ timestamps: true }
);
jobSchema.index({ 'state.type': 'text' });
const rollupConfigs = [
{
name: 'queued',

View File

@ -57,6 +57,8 @@ const printerSchema = new Schema(
{ timestamps: true }
);
printerSchema.index({ name: 'text', tags: 'text', firmware: 'text' });
const rollupConfigs = [
{
name: 'standby',

View File

@ -43,6 +43,8 @@ const subJobSchema = new mongoose.Schema({
finishedAt: { required: false, type: Date, default: null },
});
subJobSchema.index({ moonrakerJobId: 'text', 'state.type': 'text' });
subJobSchema.virtual('id').get(function () {
return this._id;
});

View File

@ -26,6 +26,8 @@ const clientSchema = new mongoose.Schema(
{ timestamps: true }
);
clientSchema.index({ name: 'text', email: 'text', phone: 'text', country: 'text', tags: 'text' });
clientSchema.virtual('id').get(function () {
return this._id;
});

View File

@ -26,6 +26,8 @@ const listingSchema = new Schema(
{ timestamps: true }
);
listingSchema.index({ title: 'text', url: 'text' });
listingSchema.virtual('id').get(function () {
return this._id;
});

View File

@ -25,6 +25,8 @@ const listingVarientSchema = new Schema(
{ timestamps: true }
);
listingVarientSchema.index({ currency: 'text', 'state.type': 'text' });
listingVarientSchema.virtual('id').get(function () {
return this._id;
});

View File

@ -28,6 +28,8 @@ const marketplaceSchema = new mongoose.Schema(
{ timestamps: true }
);
marketplaceSchema.index({ name: 'text', provider: 'text' });
marketplaceSchema.virtual('id').get(function () {
return this._id;
});

View File

@ -30,6 +30,8 @@ const salesOrderSchema = new Schema(
{ timestamps: true }
);
salesOrderSchema.index({ 'state.type': 'text' });
const rollupConfigs = [
{
name: 'draft',

View File

@ -16,6 +16,7 @@ import {
acknowledgeInvoiceRouteHandler,
cancelInvoiceRouteHandler,
postInvoiceRouteHandler,
searchInvoicesRouteHandler
} from '../../services/finance/invoices.js';
// list of invoices
@ -54,6 +55,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
}
listInvoicesByPropertiesRouteHandler(req, res, properties, filter, masterFilter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchInvoicesRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newInvoiceRouteHandler(req, res);

View File

@ -17,6 +17,7 @@ import {
authorisePaymentRouteHandler,
declinePaymentRouteHandler,
cancelPaymentRouteHandler,
searchPaymentsRouteHandler
} from '../../services/finance/payments.js';
// list of payments
@ -54,6 +55,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
}
listPaymentsByPropertiesRouteHandler(req, res, properties, filter, masterFilter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchPaymentsRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newPaymentRouteHandler(req, res);

View File

@ -12,6 +12,7 @@ import {
listTaxRecordsByPropertiesRouteHandler,
getTaxRecordStatsRouteHandler,
getTaxRecordHistoryRouteHandler,
searchTaxRecordsRouteHandler
} from '../../services/finance/taxrecords.js';
// list of tax records
@ -28,6 +29,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
const filter = getFilter(req.query, allowedFilters, false);
listTaxRecordsByPropertiesRouteHandler(req, res, properties, filter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchTaxRecordsRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newTaxRecordRouteHandler(req, res);

View File

@ -13,6 +13,7 @@ import {
listFilamentStocksByPropertiesRouteHandler,
getFilamentStockStatsRouteHandler,
getFilamentStockHistoryRouteHandler,
searchFilamentStocksRouteHandler
} from '../../services/inventory/filamentstocks.js';
// list of filament stocks
@ -49,6 +50,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
}
listFilamentStocksByPropertiesRouteHandler(req, res, properties, filter, masterFilter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchFilamentStocksRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newFilamentStockRouteHandler(req, res);

View File

@ -13,6 +13,7 @@ import {
listOrderItemsByPropertiesRouteHandler,
getOrderItemStatsRouteHandler,
getOrderItemHistoryRouteHandler,
searchOrderItemsRouteHandler
} from '../../services/inventory/orderitems.js';
// list of order items
@ -53,6 +54,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
}
listOrderItemsByPropertiesRouteHandler(req, res, properties, filter, masterFilter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchOrderItemsRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newOrderItemRouteHandler(req, res);

View File

@ -13,6 +13,7 @@ import {
listPartStocksByPropertiesRouteHandler,
getPartStockStatsRouteHandler,
getPartStockHistoryRouteHandler,
searchPartStocksRouteHandler
} from '../../services/inventory/partstocks.js';
// list of part stocks
@ -41,6 +42,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
}
listPartStocksByPropertiesRouteHandler(req, res, properties, filter, masterFilter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchPartStocksRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newPartStockRouteHandler(req, res);

View File

@ -14,6 +14,7 @@ import {
listProductStocksByPropertiesRouteHandler,
getProductStockStatsRouteHandler,
getProductStockHistoryRouteHandler,
searchProductStocksRouteHandler
} from '../../services/inventory/productstocks.js';
router.get('/', isAuthenticated, (req, res) => {
@ -40,6 +41,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
}
listProductStocksByPropertiesRouteHandler(req, res, properties, filter, masterFilter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchProductStocksRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newProductStockRouteHandler(req, res);

View File

@ -16,6 +16,7 @@ import {
postPurchaseOrderRouteHandler,
acknowledgePurchaseOrderRouteHandler,
cancelPurchaseOrderRouteHandler,
searchPurchaseOrdersRouteHandler
} from '../../services/inventory/purchaseorders.js';
// list of purchase orders
@ -58,6 +59,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
}
listPurchaseOrdersByPropertiesRouteHandler(req, res, properties, filter, masterFilter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchPurchaseOrdersRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newPurchaseOrderRouteHandler(req, res);

View File

@ -16,6 +16,7 @@ import {
shipShipmentRouteHandler,
receiveShipmentRouteHandler,
cancelShipmentRouteHandler,
searchShipmentsRouteHandler
} from '../../services/inventory/shipments.js';
// list of shipments
@ -43,6 +44,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
}
listShipmentsByPropertiesRouteHandler(req, res, properties, filter, masterFilter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchShipmentsRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newShipmentRouteHandler(req, res);

View File

@ -11,6 +11,7 @@ import {
deleteStockAuditRouteHandler,
getStockAuditStatsRouteHandler,
getStockAuditHistoryRouteHandler,
searchStockAuditsRouteHandler
} from '../../services/inventory/stockaudits.js';
// List stock audits
@ -39,6 +40,11 @@ router.post('/', isAuthenticated, (req, res) => {
});
// get stock audit stats
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchStockAuditsRouteHandler(req, res, search);
});
router.get('/stats', isAuthenticated, (req, res) => {
getStockAuditStatsRouteHandler(req, res);
});

View File

@ -13,6 +13,7 @@ import {
listStockEventsByPropertiesRouteHandler,
getStockEventStatsRouteHandler,
getStockEventHistoryRouteHandler,
searchStockEventsRouteHandler
} from '../../services/inventory/stockevents.js';
// list of stock events
@ -33,6 +34,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
}
listStockEventsByPropertiesRouteHandler(req, res, properties, filter, masterFilter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchStockEventsRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newStockEventRouteHandler(req, res);

View File

@ -13,6 +13,7 @@ import {
listStockLocationsByPropertiesRouteHandler,
getStockLocationStatsRouteHandler,
getStockLocationHistoryRouteHandler,
searchStockLocationsRouteHandler
} from '../../services/inventory/stocklocations.js';
router.get('/', isAuthenticated, (req, res) => {
@ -32,6 +33,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
}
listStockLocationsByPropertiesRouteHandler(req, res, properties, filter, masterFilter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchStockLocationsRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newStockLocationRouteHandler(req, res);

View File

@ -14,6 +14,7 @@ import {
listStockTransfersByPropertiesRouteHandler,
getStockTransferStatsRouteHandler,
getStockTransferHistoryRouteHandler,
searchStockTransfersRouteHandler
} from '../../services/inventory/stocktransfers.js';
router.get('/', isAuthenticated, (req, res) => {
@ -33,6 +34,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
}
listStockTransfersByPropertiesRouteHandler(req, res, properties, filter, masterFilter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchStockTransfersRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newStockTransferRouteHandler(req, res);

View File

@ -13,6 +13,7 @@ import {
getAppPasswordStatsRouteHandler,
getAppPasswordHistoryRouteHandler,
regenerateSecretRouteHandler,
searchAppPasswordsRouteHandler
} from '../../services/management/apppasswords.js';
router.get('/', isAuthenticated, (req, res) => {
@ -29,6 +30,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
const masterFilter = req.query.masterFilter ? JSON.parse(req.query.masterFilter) : {};
listAppPasswordsByPropertiesRouteHandler(req, res, properties, filter, masterFilter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchAppPasswordsRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newAppPasswordRouteHandler(req, res);

View File

@ -5,6 +5,7 @@ import {
getAuditLogRouteHandler,
getAuditLogStatsRouteHandler,
getAuditLogHistoryRouteHandler,
searchAuditLogsRouteHandler
} from '../../services/management/auditlogs.js';
import { parseFilter } from '../../utils.js';
@ -30,6 +31,11 @@ router.get('/', isAuthenticated, async (req, res) => {
});
// get audit log stats
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchAuditLogsRouteHandler(req, res, search);
});
router.get('/stats', isAuthenticated, (req, res) => {
getAuditLogStatsRouteHandler(req, res);
});

View File

@ -12,6 +12,7 @@ import {
listCouriersByPropertiesRouteHandler,
getCourierStatsRouteHandler,
getCourierHistoryRouteHandler,
searchCouriersRouteHandler
} from '../../services/management/courier.js';
// list of couriers
@ -28,6 +29,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
const filter = getFilter(req.query, allowedFilters, false);
listCouriersByPropertiesRouteHandler(req, res, properties, filter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchCouriersRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newCourierRouteHandler(req, res);

View File

@ -12,6 +12,7 @@ import {
listCourierServicesByPropertiesRouteHandler,
getCourierServiceStatsRouteHandler,
getCourierServiceHistoryRouteHandler,
searchCourierServicesRouteHandler
} from '../../services/management/courierservice.js';
// list of courier services
@ -28,6 +29,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
const filter = getFilter(req.query, allowedFilters, false);
listCourierServicesByPropertiesRouteHandler(req, res, properties, filter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchCourierServicesRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newCourierServiceRouteHandler(req, res);

View File

@ -12,6 +12,7 @@ import {
listDocumentJobsByPropertiesRouteHandler,
getDocumentJobStatsRouteHandler,
getDocumentJobHistoryRouteHandler,
searchDocumentJobsRouteHandler
} from '../../services/management/documentjobs.js';
// list of document jobs
@ -28,6 +29,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
const filter = getFilter(req.query, allowedFilters, false);
listDocumentJobsByPropertiesRouteHandler(req, res, properties, filter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchDocumentJobsRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newDocumentJobRouteHandler(req, res);

View File

@ -12,6 +12,7 @@ import {
listDocumentPrintersByPropertiesRouteHandler,
getDocumentPrinterStatsRouteHandler,
getDocumentPrinterHistoryRouteHandler,
searchDocumentPrintersRouteHandler
} from '../../services/management/documentprinters.js';
// list of document printers
@ -28,6 +29,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
const filter = getFilter(req.query, allowedFilters, false);
listDocumentPrintersByPropertiesRouteHandler(req, res, properties, filter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchDocumentPrintersRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newDocumentPrinterRouteHandler(req, res);

View File

@ -12,6 +12,7 @@ import {
listDocumentSizesByPropertiesRouteHandler,
getDocumentSizeStatsRouteHandler,
getDocumentSizeHistoryRouteHandler,
searchDocumentSizesRouteHandler
} from '../../services/management/documentsizes.js';
// list of document sizes
@ -28,6 +29,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
const filter = getFilter(req.query, allowedFilters, false);
listDocumentSizesByPropertiesRouteHandler(req, res, properties, filter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchDocumentSizesRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newDocumentSizeRouteHandler(req, res);

View File

@ -12,6 +12,7 @@ import {
listDocumentTemplatesByPropertiesRouteHandler,
getDocumentTemplateStatsRouteHandler,
getDocumentTemplateHistoryRouteHandler,
searchDocumentTemplatesRouteHandler
} from '../../services/management/documenttemplates.js';
// list of document templates
@ -32,6 +33,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
}
listDocumentTemplatesByPropertiesRouteHandler(req, res, properties, filter, masterFilter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchDocumentTemplatesRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newDocumentTemplateRouteHandler(req, res);

View File

@ -13,6 +13,7 @@ import {
deleteFilamentRouteHandler,
getFilamentStatsRouteHandler,
getFilamentHistoryRouteHandler,
searchFilamentsRouteHandler
} from '../../services/management/filaments.js';
// list of filaments
@ -47,6 +48,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
const filter = getFilter(req.query, allowedFilters, false);
listFilamentsByPropertiesRouteHandler(req, res, properties, filter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchFilamentsRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newFilamentRouteHandler(req, res);

View File

@ -12,6 +12,7 @@ import {
listFilamentSkusByPropertiesRouteHandler,
getFilamentSkuStatsRouteHandler,
getFilamentSkuHistoryRouteHandler,
searchFilamentSkusRouteHandler
} from '../../services/management/filamentskus.js';
router.get('/', isAuthenticated, (req, res) => {
@ -31,6 +32,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
}
listFilamentSkusByPropertiesRouteHandler(req, res, properties, filter, masterFilter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchFilamentSkusRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newFilamentSkuRouteHandler(req, res);

View File

@ -14,6 +14,7 @@ import {
listFilesByPropertiesRouteHandler,
getFileStatsRouteHandler,
getFileHistoryRouteHandler,
searchFilesRouteHandler
} from '../../services/management/files.js';
// list of files
@ -30,6 +31,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
const filter = getFilter(req.query, allowedFilters, false);
listFilesByPropertiesRouteHandler(req, res, properties, filter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchFilesRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newFileRouteHandler(req, res);

View File

@ -12,6 +12,7 @@ import {
listHostsByPropertiesRouteHandler,
getHostStatsRouteHandler,
getHostHistoryRouteHandler,
searchHostsRouteHandler
} from '../../services/management/hosts.js';
// list of hosts
@ -28,6 +29,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
const filter = getFilter(req.query, allowedFilters, false);
listHostsByPropertiesRouteHandler(req, res, properties, filter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchHostsRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newHostRouteHandler(req, res);

View File

@ -11,6 +11,7 @@ import {
newMaterialRouteHandler,
getMaterialStatsRouteHandler,
getMaterialHistoryRouteHandler,
searchMaterialsRouteHandler,
} from '../../services/management/materials.js';
// list of materials
@ -37,6 +38,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
listMaterialsByPropertiesRouteHandler(req, res, properties, filter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchMaterialsRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newMaterialRouteHandler(req, res);
});

View File

@ -12,6 +12,7 @@ import {
listNoteTypesByPropertiesRouteHandler,
getNoteTypeStatsRouteHandler,
getNoteTypeHistoryRouteHandler,
searchNoteTypesRouteHandler
} from '../../services/management/notetypes.js';
// list of note types
@ -32,6 +33,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
}
listNoteTypesByPropertiesRouteHandler(req, res, properties, filter, masterFilter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchNoteTypesRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newNoteTypeRouteHandler(req, res);

View File

@ -12,6 +12,7 @@ import {
listPartsByPropertiesRouteHandler,
getPartStatsRouteHandler,
getPartHistoryRouteHandler,
searchPartsRouteHandler
} from '../../services/management/parts.js';
// list of parts
@ -28,6 +29,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
const filter = getFilter(req.query, allowedFilters, false);
listPartsByPropertiesRouteHandler(req, res, properties, filter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchPartsRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newPartRouteHandler(req, res);

View File

@ -12,6 +12,7 @@ import {
listPartSkusByPropertiesRouteHandler,
getPartSkuStatsRouteHandler,
getPartSkuHistoryRouteHandler,
searchPartSkusRouteHandler
} from '../../services/management/partskus.js';
router.get('/', isAuthenticated, (req, res) => {
@ -31,6 +32,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
}
listPartSkusByPropertiesRouteHandler(req, res, properties, filter, masterFilter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchPartSkusRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newPartSkuRouteHandler(req, res);

View File

@ -10,6 +10,7 @@ import {
listProductCategoriesByPropertiesRouteHandler,
listProductCategoriesRouteHandler,
newProductCategoryRouteHandler,
searchProductCategoriesRouteHandler
} from '../../services/management/productcategories.js';
const router = express.Router();
@ -27,6 +28,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
const filter = getFilter(req.query, allowedFilters, false);
listProductCategoriesByPropertiesRouteHandler(req, res, properties, filter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchProductCategoriesRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newProductCategoryRouteHandler(req, res);

View File

@ -12,6 +12,7 @@ import {
listProductsByPropertiesRouteHandler,
getProductStatsRouteHandler,
getProductHistoryRouteHandler,
searchProductsRouteHandler
} from '../../services/management/products.js';
// list of products
@ -28,6 +29,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
const filter = getFilter(req.query, allowedFilters, false);
listProductsByPropertiesRouteHandler(req, res, properties, filter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchProductsRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newProductRouteHandler(req, res);

View File

@ -12,6 +12,7 @@ import {
listProductSkusByPropertiesRouteHandler,
getProductSkuStatsRouteHandler,
getProductSkuHistoryRouteHandler,
searchProductSkusRouteHandler
} from '../../services/management/productskus.js';
router.get('/', isAuthenticated, (req, res) => {
@ -31,6 +32,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
}
listProductSkusByPropertiesRouteHandler(req, res, properties, filter, masterFilter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchProductSkusRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newProductSkuRouteHandler(req, res);

View File

@ -12,6 +12,7 @@ import {
listTaxRatesByPropertiesRouteHandler,
getTaxRateStatsRouteHandler,
getTaxRateHistoryRouteHandler,
searchTaxRatesRouteHandler
} from '../../services/management/taxrates.js';
// list of tax rates
@ -28,6 +29,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
const filter = getFilter(req.query, allowedFilters, false);
listTaxRatesByPropertiesRouteHandler(req, res, properties, filter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchTaxRatesRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newTaxRateRouteHandler(req, res);

View File

@ -11,6 +11,7 @@ import {
getUserStatsRouteHandler,
getUserHistoryRouteHandler,
setAppPasswordRouteHandler,
searchUsersRouteHandler
} from '../../services/management/users.js';
// list of document templates
@ -31,6 +32,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
}
listUsersByPropertiesRouteHandler(req, res, properties, filter, masterFilter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchUsersRouteHandler(req, res, search);
});
// get user stats
router.get('/stats', isAuthenticated, (req, res) => {

View File

@ -12,6 +12,7 @@ import {
listVendorsByPropertiesRouteHandler,
getVendorStatsRouteHandler,
getVendorHistoryRouteHandler,
searchVendorsRouteHandler
} from '../../services/management/vendors.js';
// list of vendors
@ -28,6 +29,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
const filter = getFilter(req.query, allowedFilters, false);
listVendorsByPropertiesRouteHandler(req, res, properties, filter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchVendorsRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newVendorRouteHandler(req, res);

View File

@ -10,6 +10,7 @@ import {
listGCodeFilesByPropertiesRouteHandler,
getGCodeFileContentRouteHandler,
getGCodeFileStatsRouteHandler,
searchGCodeFilesRouteHandler
} from '../../services/production/gcodefiles.js';
import { convertPropertiesString, getFilter } from '../../utils.js';
@ -27,6 +28,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
const filter = getFilter(req.query, allowedFilters, false);
listGCodeFilesByPropertiesRouteHandler(req, res, properties, filter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchGCodeFilesRouteHandler(req, res, search);
});
// create new gcodeFile
router.post('/', isAuthenticated, (req, res) => {

View File

@ -10,6 +10,7 @@ import {
deleteJobRouteHandler,
getJobStatsRouteHandler,
getJobHistoryRouteHandler,
searchJobsRouteHandler
} from '../../services/production/jobs.js';
import { convertPropertiesString, getFilter } from '../../utils.js';
@ -27,6 +28,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
const filter = getFilter(req.query, allowedFilters, false);
listJobsByPropertiesRouteHandler(req, res, properties, filter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchJobsRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newJobRouteHandler(req, res);

View File

@ -10,6 +10,7 @@ import {
getPrinterStatsRouteHandler,
listPrintersByPropertiesRouteHandler,
getPrinterHistoryRouteHandler,
searchPrintersRouteHandler
} from '../../services/production/printers.js';
import { convertPropertiesString, getFilter } from '../../utils.js';
@ -27,6 +28,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
const filter = getFilter(req.query, allowedFilters, false);
listPrintersByPropertiesRouteHandler(req, res, properties, filter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchPrintersRouteHandler(req, res, search);
});
// create new printer
router.post('/', isAuthenticated, (req, res) => {

View File

@ -8,6 +8,7 @@ import {
getSubJobRouteHandler,
getSubJobStatsRouteHandler,
getSubJobHistoryRouteHandler,
searchSubJobsRouteHandler
} from '../../services/production/subjobs.js';
import { getFilter, convertPropertiesString } from '../../utils.js';
@ -25,6 +26,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
const filter = getFilter(req.query, allowedFilters, false);
listSubJobsByPropertiesRouteHandler(req, res, properties, filter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchSubJobsRouteHandler(req, res, search);
});
// get sub job stats
router.get('/stats', isAuthenticated, (req, res) => {

View File

@ -12,6 +12,7 @@ import {
listClientsByPropertiesRouteHandler,
getClientStatsRouteHandler,
getClientHistoryRouteHandler,
searchClientsRouteHandler
} from '../../services/sales/clients.js';
// list of clients
@ -28,6 +29,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
const filter = getFilter(req.query, allowedFilters, false);
listClientsByPropertiesRouteHandler(req, res, properties, filter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchClientsRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newClientRouteHandler(req, res);

View File

@ -14,6 +14,7 @@ import {
getListingHistoryRouteHandler,
publishListingRouteHandler,
unpublishListingRouteHandler,
searchListingsRouteHandler
} from '../../services/sales/listings.js';
router.get('/', isAuthenticated, (req, res) => {
@ -47,6 +48,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
const filter = getFilter(req.query, allowedFilters, false);
listListingsByPropertiesRouteHandler(req, res, properties, filter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchListingsRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newListingRouteHandler(req, res);

View File

@ -14,6 +14,7 @@ import {
getListingVarientHistoryRouteHandler,
publishListingVarientRouteHandler,
unpublishListingVarientRouteHandler,
searchListingVarientsRouteHandler
} from '../../services/sales/listingvarients.js';
router.get('/', isAuthenticated, (req, res) => {
@ -47,6 +48,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
const filter = getFilter(req.query, allowedFilters, false);
listListingVarientsByPropertiesRouteHandler(req, res, properties, filter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchListingVarientsRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newListingVarientRouteHandler(req, res);

View File

@ -18,6 +18,7 @@ import {
syncMarketplaceItemsRouteHandler,
syncMarketplaceOrdersRouteHandler,
marketplaceWebhookRouteHandler,
searchMarketplacesRouteHandler
} from '../../services/sales/marketplaces.js';
router.get('/', isAuthenticated, (req, res) => {
@ -33,6 +34,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
const filter = getFilter(req.query, allowedFilters, false);
listMarketplacesByPropertiesRouteHandler(req, res, properties, filter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchMarketplacesRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newMarketplaceRouteHandler(req, res);

View File

@ -16,6 +16,7 @@ import {
postSalesOrderRouteHandler,
confirmSalesOrderRouteHandler,
cancelSalesOrderRouteHandler,
searchSalesOrdersRouteHandler
} from '../../services/sales/salesorders.js';
// list of sales orders
@ -36,6 +37,11 @@ router.get('/properties', isAuthenticated, (req, res) => {
}
listSalesOrdersByPropertiesRouteHandler(req, res, properties, filter, masterFilter);
});
router.get('/search', isAuthenticated, (req, res) => {
const { search } = req.query;
searchSalesOrdersRouteHandler(req, res, search);
});
router.post('/', isAuthenticated, (req, res) => {
newSalesOrderRouteHandler(req, res);

View File

@ -13,6 +13,7 @@ import {
getModelStats,
getModelHistory,
checkStates,
searchObjects
} from '../../database/database.js';
import { orderItemModel } from '../../database/schemas/inventory/orderitem.schema.js';
import { shipmentModel } from '../../database/schemas/inventory/shipment.schema.js';
@ -82,6 +83,14 @@ export const listInvoicesByPropertiesRouteHandler = async (
res.send(result);
};
export const searchInvoicesRouteHandler = async (req, res, search) => {
const result = await searchObjects({
model: invoiceModel,
search,
});
res.send(result);
};
export const getInvoiceRouteHandler = async (req, res) => {
const id = req.params.id;
const populateFields = [

View File

@ -13,6 +13,7 @@ import {
getModelStats,
getModelHistory,
checkStates,
searchObjects
} from '../../database/database.js';
import { invoiceModel } from '../../database/schemas/finance/invoice.schema.js';
@ -79,6 +80,14 @@ export const listPaymentsByPropertiesRouteHandler = async (
res.send(result);
};
export const searchPaymentsRouteHandler = async (req, res, search) => {
const result = await searchObjects({
model: paymentModel,
search,
});
res.send(result);
};
export const getPaymentRouteHandler = async (req, res) => {
const id = req.params.id;
const populateFields = [{ path: 'vendor' }, { path: 'client' }, { path: 'invoice' }];

View File

@ -11,6 +11,7 @@ import {
listObjectsByProperties,
getModelStats,
getModelHistory,
searchObjects
} from '../../database/database.js';
const logger = log4js.getLogger('TaxRecords');
logger.level = config.server.logLevel;
@ -69,6 +70,14 @@ export const listTaxRecordsByPropertiesRouteHandler = async (
res.send(result);
};
export const searchTaxRecordsRouteHandler = async (req, res, search) => {
const result = await searchObjects({
model: taxRecordModel,
search,
});
res.send(result);
};
export const getTaxRecordRouteHandler = async (req, res) => {
const id = req.params.id;
const result = await getObject({

View File

@ -12,6 +12,7 @@ import {
listObjectsByProperties,
getModelStats,
getModelHistory,
searchObjects
} from '../../database/database.js';
const logger = log4js.getLogger('Filament Stocks');
logger.level = config.server.logLevel;
@ -78,6 +79,14 @@ export const listFilamentStocksByPropertiesRouteHandler = async (
res.send(result);
};
export const searchFilamentStocksRouteHandler = async (req, res, search) => {
const result = await searchObjects({
model: filamentStockModel,
search,
});
res.send(result);
};
export const getFilamentStockRouteHandler = async (req, res) => {
const id = req.params.id;
const result = await getObject({

View File

@ -13,6 +13,7 @@ import {
listObjectsByProperties,
getModelStats,
getModelHistory,
searchObjects
} from '../../database/database.js';
const logger = log4js.getLogger('Order Items');
logger.level = config.server.logLevel;
@ -123,6 +124,14 @@ export const listOrderItemsByPropertiesRouteHandler = async (
res.send(result);
};
export const searchOrderItemsRouteHandler = async (req, res, search) => {
const result = await searchObjects({
model: orderItemModel,
search,
});
res.send(result);
};
export const getOrderItemRouteHandler = async (req, res) => {
const id = req.params.id;
const result = await getObject({

View File

@ -12,6 +12,7 @@ import {
listObjectsByProperties,
getModelStats,
getModelHistory,
searchObjects
} from '../../database/database.js';
const logger = log4js.getLogger('Part Stocks');
logger.level = config.server.logLevel;
@ -74,6 +75,14 @@ export const listPartStocksByPropertiesRouteHandler = async (
res.send(result);
};
export const searchPartStocksRouteHandler = async (req, res, search) => {
const result = await searchObjects({
model: partStockModel,
search,
});
res.send(result);
};
export const getPartStockRouteHandler = async (req, res) => {
const id = req.params.id;
const result = await getObject({

View File

@ -13,6 +13,7 @@ import {
getModelStats,
getModelHistory,
checkStates,
searchObjects
} from '../../database/database.js';
import { productSkuModel } from '../../database/schemas/management/productsku.schema.js';
const logger = log4js.getLogger('Product Stocks');
@ -80,6 +81,14 @@ export const listProductStocksByPropertiesRouteHandler = async (
res.send(result);
};
export const searchProductStocksRouteHandler = async (req, res, search) => {
const result = await searchObjects({
model: productStockModel,
search,
});
res.send(result);
};
export const getProductStockRouteHandler = async (req, res) => {
const id = req.params.id;
const result = await getObject({

View File

@ -13,6 +13,7 @@ import {
getModelStats,
getModelHistory,
checkStates,
searchObjects
} from '../../database/database.js';
import { orderItemModel } from '../../database/schemas/inventory/orderitem.schema.js';
import { shipmentModel } from '../../database/schemas/inventory/shipment.schema.js';
@ -78,6 +79,14 @@ export const listPurchaseOrdersByPropertiesRouteHandler = async (
res.send(result);
};
export const searchPurchaseOrdersRouteHandler = async (req, res, search) => {
const result = await searchObjects({
model: purchaseOrderModel,
search,
});
res.send(result);
};
export const getPurchaseOrderRouteHandler = async (req, res) => {
const id = req.params.id;
const result = await getObject({

View File

@ -13,6 +13,7 @@ import {
getModelStats,
getModelHistory,
checkStates,
searchObjects
} from '../../database/database.js';
const logger = log4js.getLogger('Shipments');
logger.level = config.server.logLevel;
@ -76,6 +77,14 @@ export const listShipmentsByPropertiesRouteHandler = async (
res.send(result);
};
export const searchShipmentsRouteHandler = async (req, res, search) => {
const result = await searchObjects({
model: shipmentModel,
search,
});
res.send(result);
};
export const getShipmentRouteHandler = async (req, res) => {
const id = req.params.id;
const result = await getObject({

View File

@ -3,7 +3,10 @@ import { stockAuditModel } from '../../database/schemas/inventory/stockaudit.sch
import log4js from 'log4js';
import mongoose from 'mongoose';
import { getAuditLogs } from '../../utils.js';
import { getModelStats, getModelHistory } from '../../database/database.js';
import {
getModelStats, getModelHistory,
searchObjects
} from '../../database/database.js';
const logger = log4js.getLogger('Stock Audits');
logger.level = config.server.logLevel;
@ -58,6 +61,14 @@ export const listStockAuditsRouteHandler = async (
}
};
export const searchStockAuditsRouteHandler = async (req, res, search) => {
const result = await searchObjects({
model: stockAuditModel,
search,
});
res.send(result);
};
export const getStockAuditRouteHandler = async (req, res) => {
try {
const id = new mongoose.Types.ObjectId(req.params.id);

View File

@ -12,6 +12,7 @@ import {
listObjectsByProperties,
getModelStats,
getModelHistory,
searchObjects
} from '../../database/database.js';
const logger = log4js.getLogger('Stock Events');
logger.level = config.server.logLevel;
@ -76,6 +77,14 @@ export const listStockEventsByPropertiesRouteHandler = async (
res.send(result);
};
export const searchStockEventsRouteHandler = async (req, res, search) => {
const result = await searchObjects({
model: stockEventModel,
search,
});
res.send(result);
};
export const getStockEventRouteHandler = async (req, res) => {
const id = req.params.id;
const result = await getObject({

Some files were not shown because too many files have changed in this diff Show More