From c43bdb502155dec92ed51787bd65ed98902cecd6 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 28 Oct 2024 11:29:15 +0100 Subject: [PATCH 1/3] feat: refs #7266 Added details and improvements in item label reports --- .../back/methods/entry/labelBarcodePdf.js | 48 ++++++++++++++++++ .../entry/back/methods/entry/labelQrPdf.js | 49 +++++++++++++++++++ modules/entry/back/models/buy.js | 2 + .../item/back/methods/item/labelBarcodePdf.js | 11 ++--- modules/item/back/methods/item/labelQrPdf.js | 12 ++--- .../item-label-barcode/assets/css/style.css | 6 +-- .../item-label-barcode.html | 5 +- .../item-label-barcode/item-label-barcode.js | 25 +++++----- .../reports/item-label-barcode/options.json | 2 +- .../reports/item-label-barcode/sql/item.sql | 3 +- .../item-label-qr/assets/css/style.css | 2 +- .../reports/item-label-qr/item-label-qr.html | 9 +++- .../reports/item-label-qr/item-label-qr.js | 24 +++++---- .../reports/item-label-qr/options.json | 2 +- .../reports/item-label-qr/sql/item.sql | 3 +- 15 files changed, 157 insertions(+), 46 deletions(-) create mode 100644 modules/entry/back/methods/entry/labelBarcodePdf.js create mode 100644 modules/entry/back/methods/entry/labelQrPdf.js diff --git a/modules/entry/back/methods/entry/labelBarcodePdf.js b/modules/entry/back/methods/entry/labelBarcodePdf.js new file mode 100644 index 000000000..847859aeb --- /dev/null +++ b/modules/entry/back/methods/entry/labelBarcodePdf.js @@ -0,0 +1,48 @@ +module.exports = Self => { + Self.remoteMethodCtx('labelBarcodePdf', { + description: 'Returns the item label pdf with barcode', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'The item id', + http: {source: 'path'} + }, { + arg: 'packing', + type: 'number', + required: false + }, { + arg: 'copies', + type: 'number', + required: false + } + ], + returns: [ + { + arg: 'body', + type: 'file', + root: true + }, { + arg: 'Content-Type', + type: 'String', + http: {target: 'header'} + }, { + arg: 'Content-Disposition', + type: 'String', + http: {target: 'header'} + } + ], + http: { + path: '/:id/label-barcode-pdf', + verb: 'GET' + }, + accessScopes: ['DEFAULT', 'read:multimedia'] + }); + + Self.labelBarcodePdf = (ctx, id) => { + ctx.args.typeId = 'buy'; + return Self.printReport(ctx, id, 'item-label-barcode'); + }; +}; diff --git a/modules/entry/back/methods/entry/labelQrPdf.js b/modules/entry/back/methods/entry/labelQrPdf.js new file mode 100644 index 000000000..9668dfffd --- /dev/null +++ b/modules/entry/back/methods/entry/labelQrPdf.js @@ -0,0 +1,49 @@ +module.exports = Self => { + Self.remoteMethodCtx('labelQrPdf', { + description: 'Returns the item label pdf with qr', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'The item id', + http: {source: 'path'} + }, { + arg: 'packing', + type: 'number', + required: false + }, { + arg: 'copies', + type: 'number', + required: false + } + ], + returns: [ + { + arg: 'body', + type: 'file', + root: true + }, { + arg: 'Content-Type', + type: 'String', + http: {target: 'header'} + }, { + arg: 'Content-Disposition', + type: 'String', + http: {target: 'header'} + } + ], + http: { + path: '/:id/label-qr-pdf', + verb: 'GET' + }, + accessScopes: ['DEFAULT', 'read:multimedia'] + }); + + Self.labelQrPdf = (ctx, id) => { + ctx.args.userId = ctx.req.accessToken.userId; + ctx.args.typeId = 'buy'; + return Self.printReport(ctx, id, 'item-label-qr'); + }; +}; diff --git a/modules/entry/back/models/buy.js b/modules/entry/back/models/buy.js index 34f19e765..70d92195c 100644 --- a/modules/entry/back/models/buy.js +++ b/modules/entry/back/models/buy.js @@ -2,4 +2,6 @@ module.exports = Self => { require('../methods/entry/editLatestBuys')(Self); require('../methods/entry/latestBuysFilter')(Self); require('../methods/entry/deleteBuys')(Self); + require('../methods/entry/labelBarcodePdf')(Self); + require('../methods/entry/labelQrPdf')(Self); }; diff --git a/modules/item/back/methods/item/labelBarcodePdf.js b/modules/item/back/methods/item/labelBarcodePdf.js index 3325e3da1..8e28ddfe2 100644 --- a/modules/item/back/methods/item/labelBarcodePdf.js +++ b/modules/item/back/methods/item/labelBarcodePdf.js @@ -21,12 +21,6 @@ module.exports = Self => { arg: 'copies', type: 'number', required: false - }, { - arg: 'userId', - type: 'number', - description: 'The user id from accessToken', - http: ctx => ctx.req.accessToken.userId, - required: true } ], returns: [ @@ -51,5 +45,8 @@ module.exports = Self => { accessScopes: ['DEFAULT', 'read:multimedia'] }); - Self.labelBarcodePdf = (ctx, id) => Self.printReport(ctx, id, 'item-label-barcode'); + Self.labelBarcodePdf = (ctx, id) => { + ctx.args.typeId = 'item'; + return Self.printReport(ctx, id, 'item-label-barcode'); + }; }; diff --git a/modules/item/back/methods/item/labelQrPdf.js b/modules/item/back/methods/item/labelQrPdf.js index 4d0e34528..2c42a978a 100644 --- a/modules/item/back/methods/item/labelQrPdf.js +++ b/modules/item/back/methods/item/labelQrPdf.js @@ -21,12 +21,6 @@ module.exports = Self => { arg: 'copies', type: 'number', required: false - }, { - arg: 'userId', - type: 'number', - description: 'The user id from accessToken', - http: ctx => ctx.req.accessToken.userId, - required: true } ], returns: [ @@ -51,5 +45,9 @@ module.exports = Self => { accessScopes: ['DEFAULT', 'read:multimedia'] }); - Self.labelQrPdf = (ctx, id) => Self.printReport(ctx, id, 'item-label-qr'); + Self.labelQrPdf = (ctx, id) => { + ctx.args.userId = ctx.req.accessToken.userId; + ctx.args.typeId = 'item'; + return Self.printReport(ctx, id, 'item-label-qr'); + }; }; diff --git a/print/templates/reports/item-label-barcode/assets/css/style.css b/print/templates/reports/item-label-barcode/assets/css/style.css index 884faef56..fabecd28e 100644 --- a/print/templates/reports/item-label-barcode/assets/css/style.css +++ b/print/templates/reports/item-label-barcode/assets/css/style.css @@ -1,7 +1,7 @@ html { font-family: "Roboto", "Helvetica", "Arial", sans-serif; margin-top: -9px; - margin-left: -6px; + margin-left: -3px; } table { width: 100%; @@ -52,8 +52,8 @@ td { max-height: 50px; } .md-height { - height: 75px; - max-height: 75px; + height: 70px; + max-height: 70px; } .sm-width { width: 60px; diff --git a/print/templates/reports/item-label-barcode/item-label-barcode.html b/print/templates/reports/item-label-barcode/item-label-barcode.html index 929ce5fe2..8bf3ce8eb 100644 --- a/print/templates/reports/item-label-barcode/item-label-barcode.html +++ b/print/templates/reports/item-label-barcode/item-label-barcode.html @@ -52,7 +52,10 @@
-
+
+ {{'LAID'}} +
+
{{item.entryFk}}
diff --git a/print/templates/reports/item-label-barcode/item-label-barcode.js b/print/templates/reports/item-label-barcode/item-label-barcode.js index 5f9a11ea1..e2945ae39 100755 --- a/print/templates/reports/item-label-barcode/item-label-barcode.js +++ b/print/templates/reports/item-label-barcode/item-label-barcode.js @@ -6,17 +6,18 @@ const jsbarcode = require('jsbarcode'); module.exports = { name: 'item-label-barcode', async serverPrefetch() { - this.company = await this.findOneFromDef('company', [this.warehouseId]); - if (!this.company) - throw new UserError(`There is no company associated with that warehouse`); - this.date = Date.vnNew(); - this.lastBuy = await this.findOneFromDef('lastBuy', [ - this.id, - this.warehouseId, - this.date - ]); - this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.lastBuy.id]); + if (this.typeId === 'item') { + this.company = await this.findOneFromDef('company', [this.warehouseId]); + if (!this.company) + throw new UserError(`There is no company associated with that warehouse`); + this.lastBuy = await this.findOneFromDef('lastBuy', [ + this.id, + this.warehouseId, + this.date + ]); + } + this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.lastBuy?.id || this.id]); if (!this.items.length) throw new UserError(`Empty data source`); this.date = moment(this.date).format('WW/E'); }, @@ -51,8 +52,8 @@ module.exports = { copies: { type: Number }, - userId: { - type: Number + typeId: { + type: String } } }; diff --git a/print/templates/reports/item-label-barcode/options.json b/print/templates/reports/item-label-barcode/options.json index 1ae2630b0..17c43e69f 100644 --- a/print/templates/reports/item-label-barcode/options.json +++ b/print/templates/reports/item-label-barcode/options.json @@ -3,7 +3,7 @@ "height": "4.9cm", "margin": { "top": "0.17cm", - "right": "0.745cm", + "right": "0.37cm", "bottom": "0cm", "left": "0cm" }, diff --git a/print/templates/reports/item-label-barcode/sql/item.sql b/print/templates/reports/item-label-barcode/sql/item.sql index 3cb42d139..c56097c8d 100644 --- a/print/templates/reports/item-label-barcode/sql/item.sql +++ b/print/templates/reports/item-label-barcode/sql/item.sql @@ -22,7 +22,8 @@ SELECT ROW_NUMBER() OVER() labelNum, ig.longName, ig.subName, i.comment, - w.code buyerName + w.code buyerName, + i.isLaid FROM vn.buy b JOIN vn.item i ON i.id = b.itemFk LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk diff --git a/print/templates/reports/item-label-qr/assets/css/style.css b/print/templates/reports/item-label-qr/assets/css/style.css index fe6668c9a..0e288704b 100644 --- a/print/templates/reports/item-label-qr/assets/css/style.css +++ b/print/templates/reports/item-label-qr/assets/css/style.css @@ -1,7 +1,7 @@ html { font-family: "Roboto", "Helvetica", "Arial", sans-serif; margin-top: -7px; - margin-left: -6px; + margin-left: -3px; } .leftTable { width: 47%; diff --git a/print/templates/reports/item-label-qr/item-label-qr.html b/print/templates/reports/item-label-qr/item-label-qr.html index 712bd6c7d..6218a4513 100644 --- a/print/templates/reports/item-label-qr/item-label-qr.html +++ b/print/templates/reports/item-label-qr/item-label-qr.html @@ -74,7 +74,14 @@ Productor: {{item.producerName || item.producerFk}}
- + +
+ {{'LAID'}} +
+
+ {{item.entryFk}} +
+ diff --git a/print/templates/reports/item-label-qr/item-label-qr.js b/print/templates/reports/item-label-qr/item-label-qr.js index 1a0ef767b..ab57783a8 100755 --- a/print/templates/reports/item-label-qr/item-label-qr.js +++ b/print/templates/reports/item-label-qr/item-label-qr.js @@ -5,17 +5,18 @@ const qrcode = require('qrcode'); module.exports = { name: 'item-label-qr', async serverPrefetch() { - this.company = await this.findOneFromDef('company', [this.warehouseId]); - if (!this.company) - throw new UserError(`There is no company associated with that warehouse`); - this.date = Date.vnNew(); - this.lastBuy = await this.findOneFromDef('lastBuy', [ - this.id, - this.warehouseId, - this.date - ]); - this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.lastBuy.id]); + if (this.typeId === 'item') { + this.company = await this.findOneFromDef('company', [this.warehouseId]); + if (!this.company) + throw new UserError(`There is no company associated with that warehouse`); + this.lastBuy = await this.findOneFromDef('lastBuy', [ + this.id, + this.warehouseId, + this.date + ]); + } + this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.lastBuy?.id || this.id]); if (!this.items.length) throw new UserError(`Empty data source`); this.qr = await this.getQr(this.items[0].buyFk); this.date = moment(this.date).format('WW/E'); @@ -52,6 +53,9 @@ module.exports = { }, userId: { type: Number + }, + typeId: { + type: String } } }; diff --git a/print/templates/reports/item-label-qr/options.json b/print/templates/reports/item-label-qr/options.json index c3c395040..c6ffaddea 100644 --- a/print/templates/reports/item-label-qr/options.json +++ b/print/templates/reports/item-label-qr/options.json @@ -3,7 +3,7 @@ "height": "4.9cm", "margin": { "top": "0.17cm", - "right": "0.6cm", + "right": "0.3cm", "bottom": "0cm", "left": "0cm" }, diff --git a/print/templates/reports/item-label-qr/sql/item.sql b/print/templates/reports/item-label-qr/sql/item.sql index 3cb42d139..c56097c8d 100644 --- a/print/templates/reports/item-label-qr/sql/item.sql +++ b/print/templates/reports/item-label-qr/sql/item.sql @@ -22,7 +22,8 @@ SELECT ROW_NUMBER() OVER() labelNum, ig.longName, ig.subName, i.comment, - w.code buyerName + w.code buyerName, + i.isLaid FROM vn.buy b JOIN vn.item i ON i.id = b.itemFk LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk From a37b7b71a872fc696918ae29ce54ba63d0591449 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 28 Oct 2024 14:51:19 +0100 Subject: [PATCH 2/3] feat: refs #7266 Requested changes and improvements --- modules/entry/back/methods/entry/buyLabel.js | 27 ++++++++-- ...labelBarcodePdf.js => buyLabelSupplier.js} | 21 ++------ .../entry/back/methods/entry/labelQrPdf.js | 49 ----------------- modules/entry/back/models/buy.js | 3 +- .../item/back/methods/item/labelBarcodePdf.js | 52 ------------------ modules/item/back/methods/item/labelQrPdf.js | 53 ------------------- modules/item/back/models/item.js | 2 - .../assets/css/import.js | 0 .../assets/css/style.css | 0 .../buy-label-barcode.html} | 34 ++++++------ .../buy-label-barcode.js} | 16 ++---- .../locale/es.yml | 0 .../options.json | 0 .../sql/buy.sql} | 5 +- .../assets/css/import.js | 0 .../assets/css/style.css | 0 .../buy-label-qr.html} | 36 ++++++------- .../buy-label-qr.js} | 20 ++----- .../locale/es.yml | 0 .../options.json | 0 .../sql/item.sql => buy-label-qr/sql/buy.sql} | 5 +- .../assets/css/import.js | 0 .../assets/css/style.css | 0 .../buy-label-supplier.html} | 0 .../buy-label-supplier.js} | 2 +- .../locale/en.yml | 0 .../locale/es.yml | 0 .../options.json | 0 .../sql/buy.sql | 0 .../item-label-barcode/sql/company.sql | 5 -- .../item-label-barcode/sql/lastBuy.sql | 1 - .../reports/item-label-qr/sql/company.sql | 5 -- .../reports/item-label-qr/sql/lastBuy.sql | 1 - 33 files changed, 81 insertions(+), 256 deletions(-) rename modules/entry/back/methods/entry/{labelBarcodePdf.js => buyLabelSupplier.js} (57%) delete mode 100644 modules/entry/back/methods/entry/labelQrPdf.js delete mode 100644 modules/item/back/methods/item/labelBarcodePdf.js delete mode 100644 modules/item/back/methods/item/labelQrPdf.js rename print/templates/reports/{buy-label => buy-label-barcode}/assets/css/import.js (100%) rename print/templates/reports/{item-label-barcode => buy-label-barcode}/assets/css/style.css (100%) rename print/templates/reports/{item-label-barcode/item-label-barcode.html => buy-label-barcode/buy-label-barcode.html} (69%) rename print/templates/reports/{item-label-barcode/item-label-barcode.js => buy-label-barcode/buy-label-barcode.js} (66%) rename print/templates/reports/{item-label-barcode => buy-label-barcode}/locale/es.yml (100%) rename print/templates/reports/{item-label-barcode => buy-label-barcode}/options.json (100%) rename print/templates/reports/{item-label-barcode/sql/item.sql => buy-label-barcode/sql/buy.sql} (84%) rename print/templates/reports/{item-label-barcode => buy-label-qr}/assets/css/import.js (100%) rename print/templates/reports/{item-label-qr => buy-label-qr}/assets/css/style.css (100%) rename print/templates/reports/{item-label-qr/item-label-qr.html => buy-label-qr/buy-label-qr.html} (72%) rename print/templates/reports/{item-label-qr/item-label-qr.js => buy-label-qr/buy-label-qr.js} (59%) rename print/templates/reports/{item-label-qr => buy-label-qr}/locale/es.yml (100%) rename print/templates/reports/{item-label-qr => buy-label-qr}/options.json (100%) rename print/templates/reports/{item-label-qr/sql/item.sql => buy-label-qr/sql/buy.sql} (84%) rename print/templates/reports/{item-label-qr => buy-label-supplier}/assets/css/import.js (100%) rename print/templates/reports/{buy-label => buy-label-supplier}/assets/css/style.css (100%) rename print/templates/reports/{buy-label/buy-label.html => buy-label-supplier/buy-label-supplier.html} (100%) rename print/templates/reports/{buy-label/buy-label.js => buy-label-supplier/buy-label-supplier.js} (97%) rename print/templates/reports/{buy-label => buy-label-supplier}/locale/en.yml (100%) rename print/templates/reports/{buy-label => buy-label-supplier}/locale/es.yml (100%) rename print/templates/reports/{buy-label => buy-label-supplier}/options.json (100%) rename print/templates/reports/{buy-label => buy-label-supplier}/sql/buy.sql (100%) delete mode 100644 print/templates/reports/item-label-barcode/sql/company.sql delete mode 100644 print/templates/reports/item-label-barcode/sql/lastBuy.sql delete mode 100644 print/templates/reports/item-label-qr/sql/company.sql delete mode 100644 print/templates/reports/item-label-qr/sql/lastBuy.sql diff --git a/modules/entry/back/methods/entry/buyLabel.js b/modules/entry/back/methods/entry/buyLabel.js index 919f7c4d7..fb807fb5f 100644 --- a/modules/entry/back/methods/entry/buyLabel.js +++ b/modules/entry/back/methods/entry/buyLabel.js @@ -1,14 +1,28 @@ module.exports = Self => { Self.remoteMethodCtx('buyLabel', { - description: 'Returns the entry buy labels', + description: 'Returns the buy label', accessType: 'READ', accepts: [ { arg: 'id', type: 'number', required: true, - description: 'The entry id', + description: 'The buy id', http: {source: 'path'} + }, { + arg: 'labelType', + type: 'string', + required: true, + description: 'The label type', + http: {source: 'path'} + }, { + arg: 'packing', + type: 'number', + required: false + }, { + arg: 'copies', + type: 'number', + required: false } ], returns: [ @@ -27,11 +41,16 @@ module.exports = Self => { } ], http: { - path: '/:id/buy-label', + path: '/:id/:labelType/buy-label', verb: 'GET' }, accessScopes: ['DEFAULT', 'read:multimedia'] }); - Self.buyLabel = (ctx, id) => Self.printReport(ctx, id, 'buy-label'); + Self.buyLabel = (ctx, id, labelType) => { + if (labelType == 'qr') + return Self.printReport(ctx, id, 'buy-label-qr'); + else + return Self.printReport(ctx, id, 'buy-label-barcode'); + }; }; diff --git a/modules/entry/back/methods/entry/labelBarcodePdf.js b/modules/entry/back/methods/entry/buyLabelSupplier.js similarity index 57% rename from modules/entry/back/methods/entry/labelBarcodePdf.js rename to modules/entry/back/methods/entry/buyLabelSupplier.js index 847859aeb..61938f2f8 100644 --- a/modules/entry/back/methods/entry/labelBarcodePdf.js +++ b/modules/entry/back/methods/entry/buyLabelSupplier.js @@ -1,22 +1,14 @@ module.exports = Self => { - Self.remoteMethodCtx('labelBarcodePdf', { - description: 'Returns the item label pdf with barcode', + Self.remoteMethodCtx('buyLabelSupplier', { + description: 'Returns the entry buy labels', accessType: 'READ', accepts: [ { arg: 'id', type: 'number', required: true, - description: 'The item id', + description: 'The entry id', http: {source: 'path'} - }, { - arg: 'packing', - type: 'number', - required: false - }, { - arg: 'copies', - type: 'number', - required: false } ], returns: [ @@ -35,14 +27,11 @@ module.exports = Self => { } ], http: { - path: '/:id/label-barcode-pdf', + path: '/:id/buy-label-supplier', verb: 'GET' }, accessScopes: ['DEFAULT', 'read:multimedia'] }); - Self.labelBarcodePdf = (ctx, id) => { - ctx.args.typeId = 'buy'; - return Self.printReport(ctx, id, 'item-label-barcode'); - }; + Self.buyLabelSupplier = (ctx, id) => Self.printReport(ctx, id, 'buy-label-supplier'); }; diff --git a/modules/entry/back/methods/entry/labelQrPdf.js b/modules/entry/back/methods/entry/labelQrPdf.js deleted file mode 100644 index 9668dfffd..000000000 --- a/modules/entry/back/methods/entry/labelQrPdf.js +++ /dev/null @@ -1,49 +0,0 @@ -module.exports = Self => { - Self.remoteMethodCtx('labelQrPdf', { - description: 'Returns the item label pdf with qr', - accessType: 'READ', - accepts: [ - { - arg: 'id', - type: 'number', - required: true, - description: 'The item id', - http: {source: 'path'} - }, { - arg: 'packing', - type: 'number', - required: false - }, { - arg: 'copies', - type: 'number', - required: false - } - ], - returns: [ - { - arg: 'body', - type: 'file', - root: true - }, { - arg: 'Content-Type', - type: 'String', - http: {target: 'header'} - }, { - arg: 'Content-Disposition', - type: 'String', - http: {target: 'header'} - } - ], - http: { - path: '/:id/label-qr-pdf', - verb: 'GET' - }, - accessScopes: ['DEFAULT', 'read:multimedia'] - }); - - Self.labelQrPdf = (ctx, id) => { - ctx.args.userId = ctx.req.accessToken.userId; - ctx.args.typeId = 'buy'; - return Self.printReport(ctx, id, 'item-label-qr'); - }; -}; diff --git a/modules/entry/back/models/buy.js b/modules/entry/back/models/buy.js index 70d92195c..a027a861e 100644 --- a/modules/entry/back/models/buy.js +++ b/modules/entry/back/models/buy.js @@ -2,6 +2,5 @@ module.exports = Self => { require('../methods/entry/editLatestBuys')(Self); require('../methods/entry/latestBuysFilter')(Self); require('../methods/entry/deleteBuys')(Self); - require('../methods/entry/labelBarcodePdf')(Self); - require('../methods/entry/labelQrPdf')(Self); + require('../methods/entry/buyLabel')(Self); }; diff --git a/modules/item/back/methods/item/labelBarcodePdf.js b/modules/item/back/methods/item/labelBarcodePdf.js deleted file mode 100644 index 8e28ddfe2..000000000 --- a/modules/item/back/methods/item/labelBarcodePdf.js +++ /dev/null @@ -1,52 +0,0 @@ -module.exports = Self => { - Self.remoteMethodCtx('labelBarcodePdf', { - description: 'Returns the item label pdf with barcode', - accessType: 'READ', - accepts: [ - { - arg: 'id', - type: 'number', - required: true, - description: 'The item id', - http: {source: 'path'} - }, { - arg: 'warehouseId', - type: 'number', - required: true - }, { - arg: 'packing', - type: 'number', - required: false - }, { - arg: 'copies', - type: 'number', - required: false - } - ], - returns: [ - { - arg: 'body', - type: 'file', - root: true - }, { - arg: 'Content-Type', - type: 'String', - http: {target: 'header'} - }, { - arg: 'Content-Disposition', - type: 'String', - http: {target: 'header'} - } - ], - http: { - path: '/:id/label-barcode-pdf', - verb: 'GET' - }, - accessScopes: ['DEFAULT', 'read:multimedia'] - }); - - Self.labelBarcodePdf = (ctx, id) => { - ctx.args.typeId = 'item'; - return Self.printReport(ctx, id, 'item-label-barcode'); - }; -}; diff --git a/modules/item/back/methods/item/labelQrPdf.js b/modules/item/back/methods/item/labelQrPdf.js deleted file mode 100644 index 2c42a978a..000000000 --- a/modules/item/back/methods/item/labelQrPdf.js +++ /dev/null @@ -1,53 +0,0 @@ -module.exports = Self => { - Self.remoteMethodCtx('labelQrPdf', { - description: 'Returns the item label pdf with qr', - accessType: 'READ', - accepts: [ - { - arg: 'id', - type: 'number', - required: true, - description: 'The item id', - http: {source: 'path'} - }, { - arg: 'warehouseId', - type: 'number', - required: true - }, { - arg: 'packing', - type: 'number', - required: false - }, { - arg: 'copies', - type: 'number', - required: false - } - ], - returns: [ - { - arg: 'body', - type: 'file', - root: true - }, { - arg: 'Content-Type', - type: 'String', - http: {target: 'header'} - }, { - arg: 'Content-Disposition', - type: 'String', - http: {target: 'header'} - } - ], - http: { - path: '/:id/label-qr-pdf', - verb: 'GET' - }, - accessScopes: ['DEFAULT', 'read:multimedia'] - }); - - Self.labelQrPdf = (ctx, id) => { - ctx.args.userId = ctx.req.accessToken.userId; - ctx.args.typeId = 'item'; - return Self.printReport(ctx, id, 'item-label-qr'); - }; -}; diff --git a/modules/item/back/models/item.js b/modules/item/back/models/item.js index d39586a90..44a51594c 100644 --- a/modules/item/back/models/item.js +++ b/modules/item/back/models/item.js @@ -15,8 +15,6 @@ module.exports = Self => { require('../methods/item/getWasteByItem')(Self); require('../methods/item/createIntrastat')(Self); require('../methods/item/buyerWasteEmail')(Self); - require('../methods/item/labelBarcodePdf')(Self); - require('../methods/item/labelQrPdf')(Self); require('../methods/item/setVisibleDiscard')(Self); require('../methods/item/get')(Self); diff --git a/print/templates/reports/buy-label/assets/css/import.js b/print/templates/reports/buy-label-barcode/assets/css/import.js similarity index 100% rename from print/templates/reports/buy-label/assets/css/import.js rename to print/templates/reports/buy-label-barcode/assets/css/import.js diff --git a/print/templates/reports/item-label-barcode/assets/css/style.css b/print/templates/reports/buy-label-barcode/assets/css/style.css similarity index 100% rename from print/templates/reports/item-label-barcode/assets/css/style.css rename to print/templates/reports/buy-label-barcode/assets/css/style.css diff --git a/print/templates/reports/item-label-barcode/item-label-barcode.html b/print/templates/reports/buy-label-barcode/buy-label-barcode.html similarity index 69% rename from print/templates/reports/item-label-barcode/item-label-barcode.html rename to print/templates/reports/buy-label-barcode/buy-label-barcode.html index 8bf3ce8eb..f14f0b70b 100644 --- a/print/templates/reports/item-label-barcode/item-label-barcode.html +++ b/print/templates/reports/buy-label-barcode/buy-label-barcode.html @@ -1,16 +1,16 @@ - + @@ -18,64 +18,64 @@ diff --git a/print/templates/reports/item-label-barcode/item-label-barcode.js b/print/templates/reports/buy-label-barcode/buy-label-barcode.js similarity index 66% rename from print/templates/reports/item-label-barcode/item-label-barcode.js rename to print/templates/reports/buy-label-barcode/buy-label-barcode.js index e2945ae39..8c39a7046 100755 --- a/print/templates/reports/item-label-barcode/item-label-barcode.js +++ b/print/templates/reports/buy-label-barcode/buy-label-barcode.js @@ -4,21 +4,11 @@ const moment = require('moment'); const jsbarcode = require('jsbarcode'); module.exports = { - name: 'item-label-barcode', + name: 'buy-label-barcode', async serverPrefetch() { this.date = Date.vnNew(); - if (this.typeId === 'item') { - this.company = await this.findOneFromDef('company', [this.warehouseId]); - if (!this.company) - throw new UserError(`There is no company associated with that warehouse`); - this.lastBuy = await this.findOneFromDef('lastBuy', [ - this.id, - this.warehouseId, - this.date - ]); - } - this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.lastBuy?.id || this.id]); - if (!this.items.length) throw new UserError(`Empty data source`); + this.buys = await this.rawSqlFromDef('buy', [this.copies || 1, this.id]); + if (!this.buys.length) throw new UserError(`Empty data source`); this.date = moment(this.date).format('WW/E'); }, methods: { diff --git a/print/templates/reports/item-label-barcode/locale/es.yml b/print/templates/reports/buy-label-barcode/locale/es.yml similarity index 100% rename from print/templates/reports/item-label-barcode/locale/es.yml rename to print/templates/reports/buy-label-barcode/locale/es.yml diff --git a/print/templates/reports/item-label-barcode/options.json b/print/templates/reports/buy-label-barcode/options.json similarity index 100% rename from print/templates/reports/item-label-barcode/options.json rename to print/templates/reports/buy-label-barcode/options.json diff --git a/print/templates/reports/item-label-barcode/sql/item.sql b/print/templates/reports/buy-label-barcode/sql/buy.sql similarity index 84% rename from print/templates/reports/item-label-barcode/sql/item.sql rename to print/templates/reports/buy-label-barcode/sql/buy.sql index c56097c8d..739f8449f 100644 --- a/print/templates/reports/item-label-barcode/sql/item.sql +++ b/print/templates/reports/buy-label-barcode/sql/buy.sql @@ -23,7 +23,8 @@ SELECT ROW_NUMBER() OVER() labelNum, ig.subName, i.comment, w.code buyerName, - i.isLaid + i.isLaid, + c.code company FROM vn.buy b JOIN vn.item i ON i.id = b.itemFk LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk @@ -31,5 +32,7 @@ SELECT ROW_NUMBER() OVER() labelNum, LEFT JOIN vn.producer p ON p.id = i.producerFk JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.worker w ON w.id = it.workerFk + JOIN vn.entry e ON e.id = b.entryFk + JOIN vn.company c ON c.id = e.companyFk JOIN numbers num WHERE b.id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label-barcode/assets/css/import.js b/print/templates/reports/buy-label-qr/assets/css/import.js similarity index 100% rename from print/templates/reports/item-label-barcode/assets/css/import.js rename to print/templates/reports/buy-label-qr/assets/css/import.js diff --git a/print/templates/reports/item-label-qr/assets/css/style.css b/print/templates/reports/buy-label-qr/assets/css/style.css similarity index 100% rename from print/templates/reports/item-label-qr/assets/css/style.css rename to print/templates/reports/buy-label-qr/assets/css/style.css diff --git a/print/templates/reports/item-label-qr/item-label-qr.html b/print/templates/reports/buy-label-qr/buy-label-qr.html similarity index 72% rename from print/templates/reports/item-label-qr/item-label-qr.html rename to print/templates/reports/buy-label-qr/buy-label-qr.html index 6218a4513..00e64b57d 100644 --- a/print/templates/reports/item-label-qr/item-label-qr.html +++ b/print/templates/reports/buy-label-qr/buy-label-qr.html @@ -1,6 +1,6 @@ - +
- {{item.item}} + {{buy.item}}
- {{item.size}} + {{buy.size}}
{{ - (item.longName && item.size && item.subName) - ? `${item.longName} ${item.size} ${item.subName}` - : item.comment + (buy.longName && buy.size && buy.subName) + ? `${buy.longName} ${buy.size} ${buy.subName}` + : buy.comment }}
- {{item.producerName || item.producerFk}} + {{buy.producerName || buy.producerFk}}
- {{item.inkFk}} + {{buy.inkFk}}
- {{item.itemFk}} + {{buy.itemFk}}
- {{`${(packing || item.packing)} x ${item.stems || ''}`}} + {{`${(packing || buy.packing)} x ${buy.stems || ''}`}}
-
+
-
+
{{'LAID'}}
- {{item.entryFk}} + {{buy.entryFk}}
- {{item.buyerName}} + {{buy.buyerName}}
- {{item.origin}} + {{buy.origin}}
- {{item.buyFk}} + {{buy.buyFk}}
@@ -85,7 +85,7 @@
- {{`${item.labelNum}/${item.quantity / (packing || item.packing)}`}} + {{`${buy.labelNum}/${buy.quantity / (packing || buy.packing)}`}}
@@ -28,65 +28,65 @@ @@ -111,9 +111,9 @@ diff --git a/print/templates/reports/item-label-qr/item-label-qr.js b/print/templates/reports/buy-label-qr/buy-label-qr.js similarity index 59% rename from print/templates/reports/item-label-qr/item-label-qr.js rename to print/templates/reports/buy-label-qr/buy-label-qr.js index ab57783a8..74470ad6d 100755 --- a/print/templates/reports/item-label-qr/item-label-qr.js +++ b/print/templates/reports/buy-label-qr/buy-label-qr.js @@ -3,28 +3,18 @@ const moment = require('moment'); const qrcode = require('qrcode'); module.exports = { - name: 'item-label-qr', + name: 'buy-label-qr', async serverPrefetch() { this.date = Date.vnNew(); - if (this.typeId === 'item') { - this.company = await this.findOneFromDef('company', [this.warehouseId]); - if (!this.company) - throw new UserError(`There is no company associated with that warehouse`); - this.lastBuy = await this.findOneFromDef('lastBuy', [ - this.id, - this.warehouseId, - this.date - ]); - } - this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.lastBuy?.id || this.id]); - if (!this.items.length) throw new UserError(`Empty data source`); - this.qr = await this.getQr(this.items[0].buyFk); + this.buys = await this.rawSqlFromDef('buy', [this.copies || 1, this.id]); + if (!this.buys.length) throw new UserError(`Empty data source`); + this.qr = await this.getQr(this.buys[0].buyFk); this.date = moment(this.date).format('WW/E'); }, methods: { getQr(data) { data = { - company: this.company, + company: this.buys.company, user: this.userId, created: this.date, table: 'buy', diff --git a/print/templates/reports/item-label-qr/locale/es.yml b/print/templates/reports/buy-label-qr/locale/es.yml similarity index 100% rename from print/templates/reports/item-label-qr/locale/es.yml rename to print/templates/reports/buy-label-qr/locale/es.yml diff --git a/print/templates/reports/item-label-qr/options.json b/print/templates/reports/buy-label-qr/options.json similarity index 100% rename from print/templates/reports/item-label-qr/options.json rename to print/templates/reports/buy-label-qr/options.json diff --git a/print/templates/reports/item-label-qr/sql/item.sql b/print/templates/reports/buy-label-qr/sql/buy.sql similarity index 84% rename from print/templates/reports/item-label-qr/sql/item.sql rename to print/templates/reports/buy-label-qr/sql/buy.sql index c56097c8d..739f8449f 100644 --- a/print/templates/reports/item-label-qr/sql/item.sql +++ b/print/templates/reports/buy-label-qr/sql/buy.sql @@ -23,7 +23,8 @@ SELECT ROW_NUMBER() OVER() labelNum, ig.subName, i.comment, w.code buyerName, - i.isLaid + i.isLaid, + c.code company FROM vn.buy b JOIN vn.item i ON i.id = b.itemFk LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk @@ -31,5 +32,7 @@ SELECT ROW_NUMBER() OVER() labelNum, LEFT JOIN vn.producer p ON p.id = i.producerFk JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.worker w ON w.id = it.workerFk + JOIN vn.entry e ON e.id = b.entryFk + JOIN vn.company c ON c.id = e.companyFk JOIN numbers num WHERE b.id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label-qr/assets/css/import.js b/print/templates/reports/buy-label-supplier/assets/css/import.js similarity index 100% rename from print/templates/reports/item-label-qr/assets/css/import.js rename to print/templates/reports/buy-label-supplier/assets/css/import.js diff --git a/print/templates/reports/buy-label/assets/css/style.css b/print/templates/reports/buy-label-supplier/assets/css/style.css similarity index 100% rename from print/templates/reports/buy-label/assets/css/style.css rename to print/templates/reports/buy-label-supplier/assets/css/style.css diff --git a/print/templates/reports/buy-label/buy-label.html b/print/templates/reports/buy-label-supplier/buy-label-supplier.html similarity index 100% rename from print/templates/reports/buy-label/buy-label.html rename to print/templates/reports/buy-label-supplier/buy-label-supplier.html diff --git a/print/templates/reports/buy-label/buy-label.js b/print/templates/reports/buy-label-supplier/buy-label-supplier.js similarity index 97% rename from print/templates/reports/buy-label/buy-label.js rename to print/templates/reports/buy-label-supplier/buy-label-supplier.js index 289483051..3cef5f295 100755 --- a/print/templates/reports/buy-label/buy-label.js +++ b/print/templates/reports/buy-label-supplier/buy-label-supplier.js @@ -5,7 +5,7 @@ const jsBarcode = require('jsbarcode'); const moment = require('moment'); module.exports = { - name: 'buy-label', + name: 'buy-label-supplier', mixins: [vnReport], async serverPrefetch() { const buy = await models.Buy.findById(this.id, null); diff --git a/print/templates/reports/buy-label/locale/en.yml b/print/templates/reports/buy-label-supplier/locale/en.yml similarity index 100% rename from print/templates/reports/buy-label/locale/en.yml rename to print/templates/reports/buy-label-supplier/locale/en.yml diff --git a/print/templates/reports/buy-label/locale/es.yml b/print/templates/reports/buy-label-supplier/locale/es.yml similarity index 100% rename from print/templates/reports/buy-label/locale/es.yml rename to print/templates/reports/buy-label-supplier/locale/es.yml diff --git a/print/templates/reports/buy-label/options.json b/print/templates/reports/buy-label-supplier/options.json similarity index 100% rename from print/templates/reports/buy-label/options.json rename to print/templates/reports/buy-label-supplier/options.json diff --git a/print/templates/reports/buy-label/sql/buy.sql b/print/templates/reports/buy-label-supplier/sql/buy.sql similarity index 100% rename from print/templates/reports/buy-label/sql/buy.sql rename to print/templates/reports/buy-label-supplier/sql/buy.sql diff --git a/print/templates/reports/item-label-barcode/sql/company.sql b/print/templates/reports/item-label-barcode/sql/company.sql deleted file mode 100644 index 4047786a9..000000000 --- a/print/templates/reports/item-label-barcode/sql/company.sql +++ /dev/null @@ -1,5 +0,0 @@ -SELECT co.code - FROM warehouse w - JOIN address a ON a.id = w.addressFk - JOIN company co ON co.clientFk = a.clientFk - WHERE w.id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label-barcode/sql/lastBuy.sql b/print/templates/reports/item-label-barcode/sql/lastBuy.sql deleted file mode 100644 index d10339998..000000000 --- a/print/templates/reports/item-label-barcode/sql/lastBuy.sql +++ /dev/null @@ -1 +0,0 @@ -SELECT buy_getUltimate(?, ?, ?) id \ No newline at end of file diff --git a/print/templates/reports/item-label-qr/sql/company.sql b/print/templates/reports/item-label-qr/sql/company.sql deleted file mode 100644 index 4047786a9..000000000 --- a/print/templates/reports/item-label-qr/sql/company.sql +++ /dev/null @@ -1,5 +0,0 @@ -SELECT co.code - FROM warehouse w - JOIN address a ON a.id = w.addressFk - JOIN company co ON co.clientFk = a.clientFk - WHERE w.id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label-qr/sql/lastBuy.sql b/print/templates/reports/item-label-qr/sql/lastBuy.sql deleted file mode 100644 index d10339998..000000000 --- a/print/templates/reports/item-label-qr/sql/lastBuy.sql +++ /dev/null @@ -1 +0,0 @@ -SELECT buy_getUltimate(?, ?, ?) id \ No newline at end of file From bfc446ab79b839d83045f82820307872ff88d235 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 28 Oct 2024 14:56:01 +0100 Subject: [PATCH 3/3] feat: refs #7266 Requested changes and improvements --- db/versions/11325-navyEucalyptus/00-firstScript.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 db/versions/11325-navyEucalyptus/00-firstScript.sql diff --git a/db/versions/11325-navyEucalyptus/00-firstScript.sql b/db/versions/11325-navyEucalyptus/00-firstScript.sql new file mode 100644 index 000000000..8bc4bd82b --- /dev/null +++ b/db/versions/11325-navyEucalyptus/00-firstScript.sql @@ -0,0 +1,7 @@ +UPDATE salix.ACL + SET property='buyLabelSupplier' + WHERE property = 'buyLabel' + AND model = 'Entry'; + +INSERT IGNORE INTO salix.ACL (model,property,principalId) + VALUES ('Entry','buyLabel','employee');
@@ -12,7 +12,7 @@
- {{item.buyFk}} + {{buy.buyFk}}
- {{item.itemFk}} + {{buy.itemFk}}
- {{item.item}} + {{buy.item}}
- {{item.size}} + {{buy.size}}
- Color: {{item.inkFk}} + Color: {{buy.inkFk}}
- {{packing || item.packing}} + {{packing || buy.packing}}
- {{item.stems}} + {{buy.stems}}
- Origen: {{item.origin}} + Origen: {{buy.origin}}
- Productor: {{item.producerName || item.producerFk}} + Productor: {{buy.producerName || buy.producerFk}}
-
+
{{'LAID'}}
- {{item.entryFk}} + {{buy.entryFk}}
- Comprador: {{item.buyerName}} + Comprador: {{buy.buyerName}}
@@ -96,14 +96,14 @@
- {{`${item.labelNum}/${item.quantity / (packing || item.packing)}`}} + {{`${buy.labelNum}/${buy.quantity / (packing || buy.packing)}`}}
- Entrada: {{item.entryFk}} + Entrada: {{buy.entryFk}}
{{ - (item.longName && item.size && item.subName) - ? `${item.longName} ${item.size} ${item.subName}` - : item.comment + (buy.longName && buy.size && buy.subName) + ? `${buy.longName} ${buy.size} ${buy.subName}` + : buy.comment }}