transfer sales error fixed
gitea/salix/dev This commit looks good Details

This commit is contained in:
Joan Sanchez 2019-09-24 08:51:21 +02:00
parent 314b609060
commit 15183df65f
1 changed files with 3 additions and 2 deletions

View File

@ -162,6 +162,7 @@ module.exports = Self => {
if (sale.quantity > originalSale.quantity) if (sale.quantity > originalSale.quantity)
throw new UserError('Invalid quantity'); throw new UserError('Invalid quantity');
// Update original sale // Update original sale
const rest = originalSale.quantity - sale.quantity; const rest = originalSale.quantity - sale.quantity;
const updatedSale = await models.Sale.updateAll({ const updatedSale = await models.Sale.updateAll({
@ -173,7 +174,7 @@ module.exports = Self => {
newSale.ticketFk = ticketId; newSale.ticketFk = ticketId;
newSale.quantity = sale.quantity; newSale.quantity = sale.quantity;
await models.Sale.create(newSale, options); const createdSale = await models.Sale.create(newSale, options);
// Clone sale components // Clone sale components
const saleComponents = await models.SaleComponent.find({ const saleComponents = await models.SaleComponent.find({
@ -187,6 +188,6 @@ module.exports = Self => {
await models.SaleComponent.create(newComponents, options); await models.SaleComponent.create(newComponents, options);
return [updatedSale, createdSale]; return updatedSale;
} }
}; };