bugs solved
This commit is contained in:
parent
84e61c6cdf
commit
467df7acbe
|
@ -50,7 +50,8 @@ module.exports = Self => {
|
|||
'isToBeMailed',
|
||||
'hasToInvoiceByAddress',
|
||||
'isEqualizated',
|
||||
'isTaxDataVerified'
|
||||
'isTaxDataVerified',
|
||||
'isTaxDataChecked'
|
||||
];
|
||||
|
||||
for (const key in params) {
|
||||
|
|
|
@ -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});
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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');
|
||||
|
|
Loading…
Reference in New Issue