feat: enhance getCompatibileAnnunci query to include additional delivery month conditions
This commit is contained in:
parent
d6cd5f86b8
commit
6a20a7fb36
1 changed files with 26 additions and 14 deletions
|
|
@ -1311,21 +1311,33 @@ export const getCompatibileAnnunci = async ({
|
||||||
}
|
}
|
||||||
|
|
||||||
qry = qry.where("prezzo", "<=", servizio.budget * 1e2 * 1.2); // Allow 20% margin
|
qry = qry.where("prezzo", "<=", servizio.budget * 1e2 * 1.2); // Allow 20% margin
|
||||||
|
const { entromese } = servizio;
|
||||||
const month = new Date().getMonth() + 1; // Months are 0-indexed in JS
|
const month = new Date().getMonth() + 1; // Months are 0-indexed in JS
|
||||||
if (servizio.entromese === month) {
|
if (entromese !== null) {
|
||||||
qry = qry.where((eb) =>
|
if (entromese === month) {
|
||||||
eb.or([
|
qry = qry.where((eb) =>
|
||||||
eb("consegna", "=", 0),
|
eb.or([
|
||||||
eb("consegna", "=", servizio.entromese),
|
eb("consegna", "=", 0),
|
||||||
]),
|
eb("consegna", "=", entromese),
|
||||||
);
|
eb("consegna", "=", entromese + 1),
|
||||||
} else if (servizio.entromese === 0) {
|
]),
|
||||||
qry = qry.where((eb) =>
|
);
|
||||||
eb.or([eb("consegna", "=", 0), eb("consegna", "=", month)]),
|
} else if (entromese === 0) {
|
||||||
);
|
qry = qry.where((eb) =>
|
||||||
} else {
|
eb.or([
|
||||||
qry = qry.where("consegna", "=", servizio.entromese);
|
eb("consegna", "=", 0),
|
||||||
|
eb("consegna", "=", month),
|
||||||
|
eb("consegna", "=", month + 1),
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
qry = qry.where((eb) =>
|
||||||
|
eb.or([
|
||||||
|
eb("consegna", "=", entromese),
|
||||||
|
eb("consegna", "=", entromese + 1),
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return await qry.execute();
|
return await qry.execute();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue