diff --git a/src/store/order/list.js b/src/store/order/list.js index 29dcf0b..a755152 100644 --- a/src/store/order/list.js +++ b/src/store/order/list.js @@ -62,6 +62,7 @@ export default function list(provider) { (typeof opts.search === 'string' && opts.search.trim() !== '') || opts.onlyUnpaid === true || opts.onlyUndelivered === true || + opts.entityId !== undefined || opts.seekMonths !== undefined ); @@ -92,6 +93,16 @@ export default function list(provider) { type: orderType, }; + // Filter by entityId + if (opts?.entityId !== undefined && opts.entityId !== null) { + const entityId = Number(opts.entityId); + if (!Number.isInteger(entityId) || entityId <= 0) { + throw new Error('Invalid entityId'); + } + params.entityId = entityId; + conditions.push('m.entity_id = @entityId'); + } + // Date cutoff via seekMonths (strictly integer) if (opts?.seekMonths !== undefined) { if (typeof opts.seekMonths !== 'number' || !Number.isInteger(opts.seekMonths)) { diff --git a/src/store/quote/list.js b/src/store/quote/list.js index 9bb8797..bac56de 100644 --- a/src/store/quote/list.js +++ b/src/store/quote/list.js @@ -53,6 +53,7 @@ export default function list(provider) { opts.offset !== undefined || opts.limit !== undefined || (typeof opts.search === 'string' && opts.search.trim() !== '') || + opts.entityId !== undefined || opts.seekMonths !== undefined ); @@ -83,6 +84,16 @@ export default function list(provider) { type: quoteType, }; + // Filter by entityId + if (opts?.entityId !== undefined && opts.entityId !== null) { + const entityId = Number(opts.entityId); + if (!Number.isInteger(entityId) || entityId <= 0) { + throw new Error('Invalid entityId'); + } + params.entityId = entityId; + conditions.push('m.entity_id = @entityId'); + } + // Date cutoff via seekMonths (strictly integer) if (opts?.seekMonths !== undefined) { if (typeof opts.seekMonths !== 'number' || !Number.isInteger(opts.seekMonths)) { diff --git a/src/store/shipment/list.js b/src/store/shipment/list.js index 8e9c376..18be821 100644 --- a/src/store/shipment/list.js +++ b/src/store/shipment/list.js @@ -90,6 +90,16 @@ export default function list(provider) { conditions.push(`m.${isSqlite ? '"date"' : '[date]'} <= @dateTo`); } + // Filter by entityId + if (opts?.entityId !== undefined && opts.entityId !== null) { + const entityId = Number(opts.entityId); + if (!Number.isInteger(entityId) || entityId <= 0) { + throw new Error('Invalid entityId'); + } + params.entityId = entityId; + conditions.push('m.entity_id = @entityId'); + } + // Parent order id filter if (opts?.orderId !== undefined && opts?.orderId !== null) { const parsedOrderId = Number(opts.orderId);