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
|