This commit is contained in:
parent
072280cc9c
commit
55b490160b
|
@ -1,3 +1,4 @@
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('addSaleByCode', {
|
Self.remoteMethodCtx('addSaleByCode', {
|
||||||
description: 'Add a collection',
|
description: 'Add a collection',
|
||||||
|
@ -42,7 +43,9 @@ module.exports = Self => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const [[item]] = await Self.rawSql('CALL vn.item_getInfo(?,?)', [barcode, warehouseFk], myOptions);
|
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();
|
if (tx) await tx.commit();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
Loading…
Reference in New Issue