From 8be7f9153ead745f24f6af5f6e4469c5891618d3 Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 1 Feb 2022 14:50:24 +0100 Subject: [PATCH 1/2] Removed non compatible ECMA options --- modules/ticket/back/methods/ticket/componentUpdate.js | 6 ++++-- modules/ticket/back/methods/ticket/priceDifference.js | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/ticket/back/methods/ticket/componentUpdate.js b/modules/ticket/back/methods/ticket/componentUpdate.js index de06212c7..0fa26c9ea 100644 --- a/modules/ticket/back/methods/ticket/componentUpdate.js +++ b/modules/ticket/back/methods/ticket/componentUpdate.js @@ -138,7 +138,9 @@ module.exports = Self => { const params = [args.id, args.shipped, args.warehouseFk]; const [salesMovable] = await Self.rawSql(query, params, myOptions); - const salesNewTicket = salesMovable.filter(sale => (sale.movable ?? 0) >= sale.quantity); + const saleMovable = sale.movable ? sale.movable : 0; + + const salesNewTicket = salesMovable.filter(sale => saleMovable >= sale.quantity); if (salesNewTicket.length) { const newTicket = await models.Ticket.transferSales(ctx, args.id, null, salesNewTicket, myOptions); args.id = newTicket.id; @@ -250,7 +252,7 @@ module.exports = Self => { res.id = args.id; if (tx) await tx.commit(); - + return res; } catch (e) { if (tx) await tx.rollback(); diff --git a/modules/ticket/back/methods/ticket/priceDifference.js b/modules/ticket/back/methods/ticket/priceDifference.js index c91956ece..d47fabd51 100644 --- a/modules/ticket/back/methods/ticket/priceDifference.js +++ b/modules/ticket/back/methods/ticket/priceDifference.js @@ -114,7 +114,7 @@ module.exports = Self => { const ticketOrigin = await models.Ticket.findById(args.id, null, myOptions); const differenceShipped = ticketOrigin.shipped.getTime() != args.shipped.getTime(); const differenceWarehouse = ticketOrigin.warehouseFk != args.warehouseId; - + salesObj.haveDifferences = differenceShipped || differenceWarehouse; let query = `CALL ticket_getMovable(?,?,?)`; @@ -122,8 +122,10 @@ module.exports = Self => { const [salesMovable] = await Self.rawSql(query, params, myOptions); const itemMovable = new Map(); - for (sale of salesMovable) - itemMovable.set(sale.id, sale.movable ?? 0); + for (sale of salesMovable) { + const saleMovable = sale.movable ? sale.movable : 0; + itemMovable.set(sale.id, saleMovable); + } // Sale price component, one per sale query = `CALL vn.ticket_priceDifference(?, ?, ?, ?, ?)`; @@ -152,7 +154,7 @@ module.exports = Self => { } if (tx) await tx.commit(); - + return salesObj; } catch (e) { if (tx) await tx.rollback(); From 483a67e8b53fcfda2bc6174d71404e154b295395 Mon Sep 17 00:00:00 2001 From: joan Date: Wed, 2 Feb 2022 09:26:33 +0100 Subject: [PATCH 2/2] fix(salesFilter): search by ticket id --- modules/monitor/back/methods/sales-monitor/salesFilter.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 1f1d4d88a..047095abc 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -133,6 +133,10 @@ module.exports = Self => { const where = buildFilter(ctx.args, (param, value) => { switch (param) { + case 'search': + return /^\d+$/.test(value) + ? {'t.id': {inq: value}} + : {'t.nickname': {like: `%${value}%`}}; case 'from': return {'t.shipped': {gte: value}}; case 'to':