bugs solved

This commit is contained in:
gerard 2018-07-16 09:19:38 +02:00
parent 84e61c6cdf
commit 467df7acbe
4 changed files with 8 additions and 4 deletions

View File

@ -50,7 +50,8 @@ module.exports = Self => {
'isToBeMailed',
'hasToInvoiceByAddress',
'isEqualizated',
'isTaxDataVerified'
'isTaxDataVerified',
'isTaxDataChecked'
];
for (const key in params) {

View File

@ -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});

View File

@ -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;

View File

@ -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');