7152-devToTest_2414 #2228

Merged
alexm merged 636 commits from 7152-devToTest_2414 into test 2024-03-28 08:26:34 +00:00
1 changed files with 4 additions and 1 deletions
Showing only changes of commit 55b490160b - Show all commits

View File

@ -1,3 +1,4 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('addSaleByCode', {
description: 'Add a collection',
@ -42,7 +43,9 @@ module.exports = Self => {
try {
const [[item]] = await Self.rawSql('CALL vn.item_getInfo(?,?)', [barcode, warehouseFk], myOptions);
await Self.addSale(ctx, ticketFk, item.id, quantity, myOptions);
if (!item?.available) throw new UserError('We do not have availability for the selected item');
await Self.rawSql('CALL vn.collection_addItem(?, ?, ?)', [item.id, quantity, ticketFk], myOptions);
if (tx) await tx.commit();
} catch (e) {