diff --git a/services/loopback/common/methods/client/updateFiscalData.js b/services/loopback/common/methods/client/updateFiscalData.js index 37d6677a4..36f7268e8 100644 --- a/services/loopback/common/methods/client/updateFiscalData.js +++ b/services/loopback/common/methods/client/updateFiscalData.js @@ -50,7 +50,8 @@ module.exports = Self => { 'isToBeMailed', 'hasToInvoiceByAddress', 'isEqualizated', - 'isTaxDataVerified' + 'isTaxDataVerified', + 'isTaxDataChecked' ]; for (const key in params) { diff --git a/services/loopback/common/methods/sale/updateDiscount.js b/services/loopback/common/methods/sale/updateDiscount.js index 0201582e0..a46dc1f7d 100644 --- a/services/loopback/common/methods/sale/updateDiscount.js +++ b/services/loopback/common/methods/sale/updateDiscount.js @@ -20,7 +20,7 @@ module.exports = Self => { }); Self.updateDiscount = async params => { - if (isNAN(params.editLines[0].discount)) + if (isNaN(params.editLines[0].discount)) throw new Error(`The value should be a number`); let model = Self.app.models; @@ -52,7 +52,7 @@ module.exports = Self => { for (let i = 0; i < params.editLines.length; i++) { let currentLine = await model.Sale.findOne({where: {id: params.editLines[i].id}, fields: 'price'}); - let value = (-currentLine.price * params.editLines[i].discount / 100); + let value = ((-currentLine.price * params.editLines[i].discount) / 100); await model.SaleComponent.upsert({saleFk: params.editLines[i].id, value: value, componentFk: componentToUse}); await model.Sale.update({id: params.editLines[i].id}, {discount: params.editLines[i].discount}); diff --git a/services/loopback/common/methods/sale/updatePrice.js b/services/loopback/common/methods/sale/updatePrice.js index b92fdc0ae..5f38d1440 100644 --- a/services/loopback/common/methods/sale/updatePrice.js +++ b/services/loopback/common/methods/sale/updatePrice.js @@ -20,7 +20,7 @@ module.exports = Self => { }); Self.updatePrice = async params => { - if (isNAN(params.price)) + if (isNaN(params.price)) throw new Error(`The value should be a number`); if (!params.price) params.price = 0; let model = Self.app.models; diff --git a/services/loopback/common/methods/sale/updateQuantity.js b/services/loopback/common/methods/sale/updateQuantity.js index eac9ac309..5fd66866a 100644 --- a/services/loopback/common/methods/sale/updateQuantity.js +++ b/services/loopback/common/methods/sale/updateQuantity.js @@ -25,6 +25,9 @@ module.exports = Self => { }); Self.updateQuantity = async(id, quantity) => { + if (isNaN(params.editLines[0].discount)) + throw new Error(`The value should be a number`); + let currentLine = await Self.app.models.Sale.findOne({where: {id: id}, fields: ['quantity']}); if (quantity > currentLine.quantity) throw new Error('The new quantity should be smaller than the old one');