From a35c10adabbb4ea937fe43d55d8ca617a0f8d312 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 17 Oct 2024 08:35:24 +0200 Subject: [PATCH] fix: refs #7457 error on empty from param and add translate --- loopback/locale/en.json | 3 ++- loopback/locale/es.json | 3 ++- loopback/locale/fr.json | 5 +++-- loopback/locale/pt.json | 3 ++- modules/order/back/methods/order/filter.js | 9 +++------ 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index ea84cb6eb..0f6457754 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -240,5 +240,6 @@ "There is already a tray with the same height": "There is already a tray with the same height", "The height must be greater than 50cm": "The height must be greater than 50cm", "The maximum height of the wagon is 200cm": "The maximum height of the wagon is 200cm", - "The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line" + "The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line", + "The from field is required": "The 'from' field is required" } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 9308fd4ec..8118b6f65 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -382,5 +382,6 @@ "This buyer has already made a reservation for this date": "Este comprador ya ha hecho una reserva para esta fecha", "No valid travel thermograph found": "No se encontró un termógrafo válido", "The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea", - "type cannot be blank": "Se debe rellenar el tipo" + "type cannot be blank": "Se debe rellenar el tipo", + "The from field is required": "El campo 'desde' es obligatorio" } \ No newline at end of file diff --git a/loopback/locale/fr.json b/loopback/locale/fr.json index a6648b186..5bc98c3dd 100644 --- a/loopback/locale/fr.json +++ b/loopback/locale/fr.json @@ -123,7 +123,7 @@ "Added sale to ticket": "J'ai ajouté la ligne suivante au ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}", "Changed sale discount": "J'ai changé le rabais des lignes suivantes du ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Created claim": "J'ai créé la réclamation [{{claimId}}]({{{claimUrl}}}) des lignes suivantes du ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Changed sale price": " le prix de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* du ticket [{{ticketId}}]({{{ticketUrl}}})",, + "Changed sale price": " le prix de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* du ticket [{{ticketId}}]({{{ticketUrl}}})", "Changed sale quantity": "J'ai changé {{changes}} du ticket [{{ticketId}}]({{{ticketUrl}}})", "Changes in sales": "la quantité de {{itemId}} {{concept}} de {{oldQuantity}} ➔ {{newQuantity}}", "State": "État", @@ -362,5 +362,6 @@ "It has been invoiced but the PDF of refund not be generated": "Il a été facturé mais le PDF de remboursement n'a pas été généré", "Cannot send mail": "Impossible d'envoyer le mail", "Original invoice not found": "Facture originale introuvable", - "The quantity claimed cannot be greater than the quantity of the line": "Le montant réclamé ne peut pas être supérieur au montant de la ligne" + "The quantity claimed cannot be greater than the quantity of the line": "Le montant réclamé ne peut pas être supérieur au montant de la ligne", + "The from field is required": "Le champ de est requis" } diff --git a/loopback/locale/pt.json b/loopback/locale/pt.json index a43f0e780..91dc372c3 100644 --- a/loopback/locale/pt.json +++ b/loopback/locale/pt.json @@ -362,5 +362,6 @@ "It has been invoiced but the PDF of refund not be generated": "Foi faturado mas não foi gerado o PDF do reembolso", "Original invoice not found": "Fatura original não encontrada", "Cannot send mail": "Não é possível enviar o email", - "The quantity claimed cannot be greater than the quantity of the line": "O valor reclamado não pode ser superior ao valor da linha" + "The quantity claimed cannot be greater than the quantity of the line": "O valor reclamado não pode ser superior ao valor da linha", + "The from field is required": "O campo de origem é obrigatório" } diff --git a/modules/order/back/methods/order/filter.js b/modules/order/back/methods/order/filter.js index affa53a55..5b5fe8701 100644 --- a/modules/order/back/methods/order/filter.js +++ b/modules/order/back/methods/order/filter.js @@ -2,6 +2,7 @@ const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; const buildFilter = require('vn-loopback/util/filter').buildFilter; const mergeFilters = require('vn-loopback/util/filter').mergeFilters; +const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethod('filter', { @@ -84,6 +85,8 @@ module.exports = Self => { const args = ctx.args; + if (!args.from) + throw new UserError('The from field is required'); // Apply filter by team const teamMembersId = []; if (args.myTeam != null) { @@ -106,12 +109,6 @@ module.exports = Self => { if (args?.to) args.to.setHours(23, 59, 0, 0); - if (!args.from) { - const yesterday = new Date(); - yesterday.setDate(yesterday.getDate() - 1); - args.from = yesterday.toISOString().split('T')[0]; - } - const where = buildFilter(args, (param, value) => { switch (param) { case 'search':