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
@@ -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 }}