This commit is contained in:
seb
2026-10-19 13:24:59 +02:00
parent 5259e3bef9
commit a5eee3f3d0
3 changed files with 32 additions and 0 deletions

View File

@@ -62,6 +62,7 @@ export default function list(provider) {
(typeof opts.search === 'string' && opts.search.trim() !== '') || (typeof opts.search === 'string' && opts.search.trim() !== '') ||
opts.onlyUnpaid === true || opts.onlyUnpaid === true ||
opts.onlyUndelivered === true || opts.onlyUndelivered === true ||
opts.entityId !== undefined ||
opts.seekMonths !== undefined opts.seekMonths !== undefined
); );
@@ -92,6 +93,16 @@ export default function list(provider) {
type: orderType, 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) // Date cutoff via seekMonths (strictly integer)
if (opts?.seekMonths !== undefined) { if (opts?.seekMonths !== undefined) {
if (typeof opts.seekMonths !== 'number' || !Number.isInteger(opts.seekMonths)) { if (typeof opts.seekMonths !== 'number' || !Number.isInteger(opts.seekMonths)) {

View File

@@ -53,6 +53,7 @@ export default function list(provider) {
opts.offset !== undefined || opts.offset !== undefined ||
opts.limit !== undefined || opts.limit !== undefined ||
(typeof opts.search === 'string' && opts.search.trim() !== '') || (typeof opts.search === 'string' && opts.search.trim() !== '') ||
opts.entityId !== undefined ||
opts.seekMonths !== undefined opts.seekMonths !== undefined
); );
@@ -83,6 +84,16 @@ export default function list(provider) {
type: quoteType, 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) // Date cutoff via seekMonths (strictly integer)
if (opts?.seekMonths !== undefined) { if (opts?.seekMonths !== undefined) {
if (typeof opts.seekMonths !== 'number' || !Number.isInteger(opts.seekMonths)) { if (typeof opts.seekMonths !== 'number' || !Number.isInteger(opts.seekMonths)) {

View File

@@ -90,6 +90,16 @@ export default function list(provider) {
conditions.push(`m.${isSqlite ? '"date"' : '[date]'} <= @dateTo`); 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 // Parent order id filter
if (opts?.orderId !== undefined && opts?.orderId !== null) { if (opts?.orderId !== undefined && opts?.orderId !== null) {
const parsedOrderId = Number(opts.orderId); const parsedOrderId = Number(opts.orderId);