From c713c3a5c0b5dcd94e10436cf3b01cb2137f9c10 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 29 Jul 2024 09:21:35 +0200 Subject: [PATCH] fix: refs #6861 Unhandled error --- loopback/locale/es.json | 5 +++-- modules/item/back/methods/item-shelving/updateFromSale.js | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index e2be5d013..acc3d69f6 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -367,5 +367,6 @@ "It has been invoiced but the PDF of refund not be generated": "Se ha facturado pero no se ha podido generar el PDF del abono", "Payment method is required": "El método de pago es obligatorio", "Cannot send mail": "Não é possível enviar o email", - "CONSTRAINT `supplierAccountTooShort` failed for `vn`.`supplier`": "La cuenta debe tener exactamente 10 dígitos" -} + "CONSTRAINT `supplierAccountTooShort` failed for `vn`.`supplier`": "La cuenta debe tener exactamente 10 dígitos", + "The sale not exists in the item shelving": "La venta no existe en la estantería del artículo" +} \ No newline at end of file diff --git a/modules/item/back/methods/item-shelving/updateFromSale.js b/modules/item/back/methods/item-shelving/updateFromSale.js index 2b9f49cae..167509074 100644 --- a/modules/item/back/methods/item-shelving/updateFromSale.js +++ b/modules/item/back/methods/item-shelving/updateFromSale.js @@ -1,3 +1,4 @@ +const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethod('updateFromSale', { description: 'Update the visible items', @@ -32,6 +33,9 @@ module.exports = Self => { include: {relation: 'itemShelving'} }, myOptions); + if (!itemShelvingSale?.itemShelving()) + throw new UserError('The sale not exists in the item shelving'); + const itemShelving = itemShelvingSale.itemShelving(); const quantity = itemShelving.visible + itemShelvingSale.quantity;