diff --git a/back/methods/collection/getTickets.js b/back/methods/collection/getTickets.js index 3c2f6cb2d8..677c9e4444 100644 --- a/back/methods/collection/getTickets.js +++ b/back/methods/collection/getTickets.js @@ -63,7 +63,8 @@ module.exports = Self => { p.pickingOrder pickingOrder, iss.id itemShelvingSaleFk, iss.isPicked, - iss.itemShelvingFk + iss.itemShelvingFk, + st.code stateCode FROM ticketCollection tc LEFT JOIN collection c ON c.id = tc.collectionFk JOIN sale s ON s.ticketFk = tc.ticketFk @@ -77,6 +78,7 @@ module.exports = Self => { LEFT JOIN parking p ON p.id = sh.parkingFk LEFT JOIN itemColor ic ON ic.itemFk = s.itemFk LEFT JOIN origin o ON o.id = i.originFk + LEFT JOIN state st ON st.id = sg.stateFk WHERE tc.collectionFk = ? GROUP BY s.id, ish.id, p.code, p2.code UNION ALL @@ -104,7 +106,8 @@ module.exports = Self => { p.pickingOrder, iss.id itemShelvingSaleFk, iss.isPicked, - iss.itemShelvingFk + iss.itemShelvingFk, + st.code stateCode FROM sectorCollection sc JOIN sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id JOIN saleGroup sg ON sg.id = ss.saleGroupFk @@ -118,6 +121,7 @@ module.exports = Self => { LEFT JOIN parking p ON p.id = sh.parkingFk LEFT JOIN itemColor ic ON ic.itemFk = s.itemFk LEFT JOIN origin o ON o.id = i.originFk + LEFT JOIN state st ON st.id = sg.stateFk WHERE sc.id = ? AND sgd.saleGroupFk GROUP BY s.id, ish.id, p.code, p2.code`, [id, id], myOptions); diff --git a/db/versions/11362-limeLilium/00-firstScript.sql b/db/versions/11362-limeLilium/00-firstScript.sql new file mode 100644 index 0000000000..4a7c5b7424 --- /dev/null +++ b/db/versions/11362-limeLilium/00-firstScript.sql @@ -0,0 +1,4 @@ + + +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) +VALUES('SaleGroup', 'find', 'READ', 'ALLOW', 'ROLE', 'production'); \ No newline at end of file diff --git a/modules/entry/back/methods/entry/print.js b/modules/entry/back/methods/entry/labelSupplier.js similarity index 87% rename from modules/entry/back/methods/entry/print.js rename to modules/entry/back/methods/entry/labelSupplier.js index 5b9de9a695..32d80c4277 100644 --- a/modules/entry/back/methods/entry/print.js +++ b/modules/entry/back/methods/entry/labelSupplier.js @@ -1,6 +1,6 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { - Self.remoteMethodCtx('print', { + Self.remoteMethodCtx('labelSupplier', { description: 'Print stickers of all entries', accessType: 'READ', accepts: [ @@ -28,13 +28,13 @@ module.exports = Self => { } ], http: { - path: '/:id/print', + path: '/:id/labelSupplier', verb: 'GET' }, accessScopes: ['DEFAULT', 'read:multimedia'] }); - Self.print = async function(ctx, id, options) { + Self.labelSupplier = async function(ctx, id, options) { const models = Self.app.models; const myOptions = {}; if (typeof options == 'object') @@ -48,7 +48,8 @@ module.exports = Self => { for (const buy of buys) { if (buy.stickers < 1) continue; ctx.args.id = buy.id; - const pdfBuffer = await models.Entry.buyLabel(ctx, myOptions); + ctx.args.copies = buy.stickers; + const pdfBuffer = await models.Entry.buyLabelSupplier(ctx, myOptions); await merger.add(new Uint8Array(pdfBuffer[0])); } diff --git a/modules/entry/back/models/entry.js b/modules/entry/back/models/entry.js index 8ca79f5316..dc5022adab 100644 --- a/modules/entry/back/models/entry.js +++ b/modules/entry/back/models/entry.js @@ -11,7 +11,8 @@ module.exports = Self => { require('../methods/entry/addFromPackaging')(Self); require('../methods/entry/addFromBuy')(Self); require('../methods/entry/buyLabel')(Self); - require('../methods/entry/print')(Self); + require('../methods/entry/labelSupplier')(Self); + require('../methods/entry/buyLabelSupplier')(Self); Self.observe('before save', async function(ctx, options) { if (ctx.isNewInstance) return; diff --git a/modules/ticket/back/models/saleGroup.json b/modules/ticket/back/models/saleGroup.json index aa78b4167b..5f432b514a 100644 --- a/modules/ticket/back/models/saleGroup.json +++ b/modules/ticket/back/models/saleGroup.json @@ -29,6 +29,11 @@ "type": "belongsTo", "model": "Parking", "foreignKey": "parkingFk" + }, + "state": { + "type": "belongsTo", + "model": "State", + "foreignKey": "stateFk" } } -} +} \ No newline at end of file