From 19bf606330b622c947a8056eb997703123ef276a Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 28 Jun 2024 12:57:27 +0200 Subject: [PATCH 1/5] refs #7644 First commit --- .../entry/back/methods/entry/entryLabel.js | 36 ++++++++ modules/entry/back/models/entry.js | 1 + .../reports/entry-label/assets/css/import.js | 12 +++ .../reports/entry-label/assets/css/style.css | 58 ++++++++++++ .../reports/entry-label/entry-label.html | 89 +++++++++++++++++++ .../reports/entry-label/entry-label.js | 36 ++++++++ .../reports/entry-label/locale/es.yml | 1 + .../reports/entry-label/options.json | 11 +++ .../reports/entry-label/sql/entry.sql | 17 ++++ 9 files changed, 261 insertions(+) create mode 100644 modules/entry/back/methods/entry/entryLabel.js create mode 100644 print/templates/reports/entry-label/assets/css/import.js create mode 100644 print/templates/reports/entry-label/assets/css/style.css create mode 100644 print/templates/reports/entry-label/entry-label.html create mode 100755 print/templates/reports/entry-label/entry-label.js create mode 100644 print/templates/reports/entry-label/locale/es.yml create mode 100644 print/templates/reports/entry-label/options.json create mode 100644 print/templates/reports/entry-label/sql/entry.sql diff --git a/modules/entry/back/methods/entry/entryLabel.js b/modules/entry/back/methods/entry/entryLabel.js new file mode 100644 index 000000000..50e82b54c --- /dev/null +++ b/modules/entry/back/methods/entry/entryLabel.js @@ -0,0 +1,36 @@ +module.exports = Self => { + Self.remoteMethodCtx('entryLabel', { + description: 'Returns the entry labels', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'The entry id', + http: {source: 'path'} + } + ], + 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/entry-label', + verb: 'GET' + } + }); + + Self.entryLabel = (ctx, id) => Self.printReport(ctx, id, 'entry-label'); +}; diff --git a/modules/entry/back/models/entry.js b/modules/entry/back/models/entry.js index 6148ae559..10f63b9f0 100644 --- a/modules/entry/back/models/entry.js +++ b/modules/entry/back/models/entry.js @@ -9,6 +9,7 @@ module.exports = Self => { require('../methods/entry/entryOrderPdf')(Self); require('../methods/entry/addFromPackaging')(Self); require('../methods/entry/addFromBuy')(Self); + require('../methods/entry/entryLabel')(Self); Self.observe('before save', async function(ctx, options) { if (ctx.isNewInstance) return; diff --git a/print/templates/reports/entry-label/assets/css/import.js b/print/templates/reports/entry-label/assets/css/import.js new file mode 100644 index 000000000..37a98dfdd --- /dev/null +++ b/print/templates/reports/entry-label/assets/css/import.js @@ -0,0 +1,12 @@ +const Stylesheet = require(`vn-print/core/stylesheet`); + +const path = require('path'); +const vnPrintPath = path.resolve('print'); + +module.exports = new Stylesheet([ + `${vnPrintPath}/common/css/spacing.css`, + `${vnPrintPath}/common/css/misc.css`, + `${vnPrintPath}/common/css/layout.css`, + `${vnPrintPath}/common/css/report.css`, + `${__dirname}/style.css`]) + .mergeStyles(); diff --git a/print/templates/reports/entry-label/assets/css/style.css b/print/templates/reports/entry-label/assets/css/style.css new file mode 100644 index 000000000..ccafa7078 --- /dev/null +++ b/print/templates/reports/entry-label/assets/css/style.css @@ -0,0 +1,58 @@ +html { + height: 100%; + margin-top: -6px; +} +* { + box-sizing: border-box; + font-family: "Roboto", "Helvetica", "Arial", sans-serif; + font-size: 28px; +} +table { + border: 1px solid; + width: 100%; + font-size: inherit; +} +td { + border: 1px solid; + padding: 5px; + width: 100%; +} +#barcode { + text-align: center; +} +span { + font-size: 48px; + font-weight: bold; +} +.lbl { + color: gray; + font-weight: lighter; + font-size: 18px; + display: block; +} +.flex-container { + display: flex; + justify-content: space-between; +} +.flex-item { + flex: 1; +} +.section { + height: 50px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +#variant { + width: 314px; +} +#producer { + width: 471px; +} +.cell { + width: 157px; +} + +#leftBox { + border-right: 1px solid; +} \ No newline at end of file diff --git a/print/templates/reports/entry-label/entry-label.html b/print/templates/reports/entry-label/entry-label.html new file mode 100644 index 000000000..6973adbea --- /dev/null +++ b/print/templates/reports/entry-label/entry-label.html @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ Variedad: + {{buy.name}} +
+
+
+ Medida: + {{buy.size}} +
+
+
+ Categoría: + {{buy.category}} +
+
+
+ Color: + {{buy.color}} +
+
+
+ Origen: + {{buy.origin}} +
+
+
+ Packing: + {{buy.packing}} +
+
+
+ Grouping: + {{buy.grouping}} +
+
+
+ Und. venta: + {{buy.stems}} +
+
+
+ {{buy.id}} +
+
+ Productor: + {{buy.producer}} +
+
+
+
+ Control: + 06/11 +
+
+ Caja nº: + {{`${buy.labelNum} / ${maxLabelNum}`}} +
+
+
+ diff --git a/print/templates/reports/entry-label/entry-label.js b/print/templates/reports/entry-label/entry-label.js new file mode 100755 index 000000000..62186df4c --- /dev/null +++ b/print/templates/reports/entry-label/entry-label.js @@ -0,0 +1,36 @@ +const vnReport = require('../../../core/mixins/vn-report.js'); +const {DOMImplementation, XMLSerializer} = require('xmldom'); +const jsBarcode = require('jsbarcode'); + +module.exports = { + name: 'entry-label', + mixins: [vnReport], + async serverPrefetch() { + this.buys = await this.rawSqlFromDef('entry', [this.id]); + const maxLabelNum = Math.max(...this.buys.map(buy => buy.labelNum)); + this.maxLabelNum = maxLabelNum; + }, + methods: { + getBarcode(id) { + const xmlSerializer = new XMLSerializer(); + const document = new DOMImplementation().createDocument('http://www.w3.org/1999/xhtml', 'html', null); + const svgNode = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + + jsBarcode(svgNode, id, { + xmlDocument: document, + format: 'code128', + displayValue: false, + width: 3.8, + height: 115, + }); + return xmlSerializer.serializeToString(svgNode); + } + }, + props: { + id: { + type: Number, + required: true, + description: 'The entry id' + } + } +}; diff --git a/print/templates/reports/entry-label/locale/es.yml b/print/templates/reports/entry-label/locale/es.yml new file mode 100644 index 000000000..278946f3e --- /dev/null +++ b/print/templates/reports/entry-label/locale/es.yml @@ -0,0 +1 @@ +reportName: Etiqueta \ No newline at end of file diff --git a/print/templates/reports/entry-label/options.json b/print/templates/reports/entry-label/options.json new file mode 100644 index 000000000..d2ed03e32 --- /dev/null +++ b/print/templates/reports/entry-label/options.json @@ -0,0 +1,11 @@ +{ + "width": "10cm", + "height": "10.3cm", + "margin": { + "top": "0.17cm", + "right": "0.2cm", + "bottom": "0cm", + "left": "0cm" + }, + "printBackground": true +} \ No newline at end of file diff --git a/print/templates/reports/entry-label/sql/entry.sql b/print/templates/reports/entry-label/sql/entry.sql new file mode 100644 index 000000000..21511df64 --- /dev/null +++ b/print/templates/reports/entry-label/sql/entry.sql @@ -0,0 +1,17 @@ +SELECT ROW_NUMBER() OVER(ORDER BY b.id) labelNum, + i.name, + i.`size`, + i.category, + ink.id color, + o.code origin, + b.packing, + b.`grouping`, + i.stems, + b.id, + p.name producer + FROM buy b + JOIN item i ON i.id = b.itemFk + LEFT JOIN producer p ON p.id = i.producerFk + LEFT JOIN ink ON ink.id = i.inkFk + LEFT JOIN origin o ON o.id = i.originFk + WHERE b.entryFk = ? \ No newline at end of file From 85c7336d923edccbac888dfd8f367744a8ed5a56 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 28 Jun 2024 14:52:19 +0200 Subject: [PATCH 2/5] refs #7644 Minor changes --- .../reports/entry-label/assets/css/style.css | 29 +++--------- .../reports/entry-label/entry-label.html | 46 +++++++++---------- .../reports/entry-label/entry-label.js | 3 +- .../reports/entry-label/options.json | 2 +- .../reports/entry-label/sql/entry.sql | 2 +- 5 files changed, 32 insertions(+), 50 deletions(-) diff --git a/print/templates/reports/entry-label/assets/css/style.css b/print/templates/reports/entry-label/assets/css/style.css index ccafa7078..0d4a2891d 100644 --- a/print/templates/reports/entry-label/assets/css/style.css +++ b/print/templates/reports/entry-label/assets/css/style.css @@ -1,10 +1,6 @@ html { - height: 100%; - margin-top: -6px; -} -* { - box-sizing: border-box; font-family: "Roboto", "Helvetica", "Arial", sans-serif; + margin-top: -7px; font-size: 28px; } table { @@ -17,9 +13,6 @@ td { padding: 5px; width: 100%; } -#barcode { - text-align: center; -} span { font-size: 48px; font-weight: bold; @@ -30,29 +23,19 @@ span { font-size: 18px; display: block; } -.flex-container { - display: flex; - justify-content: space-between; -} -.flex-item { - flex: 1; -} -.section { +.cell { + width: 157px; height: 50px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.barcode { + text-align: center; +} #variant { width: 314px; } #producer { width: 471px; -} -.cell { - width: 157px; -} - -#leftBox { - border-right: 1px solid; } \ No newline at end of file diff --git a/print/templates/reports/entry-label/entry-label.html b/print/templates/reports/entry-label/entry-label.html index 6973adbea..53980c534 100644 --- a/print/templates/reports/entry-label/entry-label.html +++ b/print/templates/reports/entry-label/entry-label.html @@ -4,14 +4,14 @@ -
- Variedad: +
+ Variedad {{buy.name}}
- Medida: + Medida {{buy.size}}
@@ -19,68 +19,68 @@
- Categoría: + Categoría {{buy.category}}
- Color: + Color {{buy.color}}
- Origen: - {{buy.origin}} + Origen + {{buy.code}}
- Packing: + Packing {{buy.packing}}
- Grouping: + Grouping {{buy.grouping}}
- Und. venta: + Ud. venta {{buy.stems}}
- +
{{buy.id}} -
- Productor: +
+ Productor {{buy.producer}}
- -
-
- Control: - 06/11 -
-
- Caja nº: - {{`${buy.labelNum} / ${maxLabelNum}`}} -
+ +
+ Control + 06 / 11 +
+ + +
+ Caja nº + {{`${buy.labelNum} / ${maxLabelNum}`}}
diff --git a/print/templates/reports/entry-label/entry-label.js b/print/templates/reports/entry-label/entry-label.js index 62186df4c..e3788261a 100755 --- a/print/templates/reports/entry-label/entry-label.js +++ b/print/templates/reports/entry-label/entry-label.js @@ -7,8 +7,7 @@ module.exports = { mixins: [vnReport], async serverPrefetch() { this.buys = await this.rawSqlFromDef('entry', [this.id]); - const maxLabelNum = Math.max(...this.buys.map(buy => buy.labelNum)); - this.maxLabelNum = maxLabelNum; + this.maxLabelNum = Math.max(...this.buys.map(buy => buy.labelNum)); }, methods: { getBarcode(id) { diff --git a/print/templates/reports/entry-label/options.json b/print/templates/reports/entry-label/options.json index d2ed03e32..4ed0461b3 100644 --- a/print/templates/reports/entry-label/options.json +++ b/print/templates/reports/entry-label/options.json @@ -1,6 +1,6 @@ { "width": "10cm", - "height": "10.3cm", + "height": "10cm", "margin": { "top": "0.17cm", "right": "0.2cm", diff --git a/print/templates/reports/entry-label/sql/entry.sql b/print/templates/reports/entry-label/sql/entry.sql index 21511df64..50b34bd03 100644 --- a/print/templates/reports/entry-label/sql/entry.sql +++ b/print/templates/reports/entry-label/sql/entry.sql @@ -3,7 +3,7 @@ SELECT ROW_NUMBER() OVER(ORDER BY b.id) labelNum, i.`size`, i.category, ink.id color, - o.code origin, + o.code, b.packing, b.`grouping`, i.stems, From 7bf55c68154aeaa4771c12621bae19c75af123b5 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 1 Jul 2024 08:00:27 +0200 Subject: [PATCH 3/5] refs #7644 Added control source --- print/templates/reports/entry-label/entry-label.html | 2 +- print/templates/reports/entry-label/entry-label.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/print/templates/reports/entry-label/entry-label.html b/print/templates/reports/entry-label/entry-label.html index 53980c534..65fbfb806 100644 --- a/print/templates/reports/entry-label/entry-label.html +++ b/print/templates/reports/entry-label/entry-label.html @@ -74,7 +74,7 @@
Control - 06 / 11 + {{`${weekNum} / ${dayNum}`}}
diff --git a/print/templates/reports/entry-label/entry-label.js b/print/templates/reports/entry-label/entry-label.js index e3788261a..08d2acc49 100755 --- a/print/templates/reports/entry-label/entry-label.js +++ b/print/templates/reports/entry-label/entry-label.js @@ -1,6 +1,7 @@ const vnReport = require('../../../core/mixins/vn-report.js'); const {DOMImplementation, XMLSerializer} = require('xmldom'); const jsBarcode = require('jsbarcode'); +const moment = require('moment'); module.exports = { name: 'entry-label', @@ -8,6 +9,9 @@ module.exports = { async serverPrefetch() { this.buys = await this.rawSqlFromDef('entry', [this.id]); this.maxLabelNum = Math.max(...this.buys.map(buy => buy.labelNum)); + const date = new Date(); + this.weekNum = moment(date).isoWeek(); + this.dayNum = moment(date).day(); }, methods: { getBarcode(id) { From 5c8d8ba2800d3496956681bc6ebcdc4bf9f628a4 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 1 Jul 2024 09:07:36 +0200 Subject: [PATCH 4/5] refs #7644 Added locales and changed name of method --- .../entry/{entryLabel.js => buyLabel.js} | 8 +++---- modules/entry/back/models/entry.js | 2 +- .../assets/css/import.js | 0 .../assets/css/style.css | 0 .../buy-label.html} | 22 +++++++++---------- .../entry-label.js => buy-label/buy-label.js} | 4 ++-- .../templates/reports/buy-label/locale/en.yml | 12 ++++++++++ .../templates/reports/buy-label/locale/es.yml | 12 ++++++++++ .../{entry-label => buy-label}/options.json | 0 .../sql/entry.sql => buy-label/sql/buys.sql} | 0 .../reports/entry-label/locale/es.yml | 1 - 11 files changed, 42 insertions(+), 19 deletions(-) rename modules/entry/back/methods/entry/{entryLabel.js => buyLabel.js} (78%) rename print/templates/reports/{entry-label => buy-label}/assets/css/import.js (100%) rename print/templates/reports/{entry-label => buy-label}/assets/css/style.css (100%) rename print/templates/reports/{entry-label/entry-label.html => buy-label/buy-label.html} (73%) rename print/templates/reports/{entry-label/entry-label.js => buy-label/buy-label.js} (93%) create mode 100644 print/templates/reports/buy-label/locale/en.yml create mode 100644 print/templates/reports/buy-label/locale/es.yml rename print/templates/reports/{entry-label => buy-label}/options.json (100%) rename print/templates/reports/{entry-label/sql/entry.sql => buy-label/sql/buys.sql} (100%) delete mode 100644 print/templates/reports/entry-label/locale/es.yml diff --git a/modules/entry/back/methods/entry/entryLabel.js b/modules/entry/back/methods/entry/buyLabel.js similarity index 78% rename from modules/entry/back/methods/entry/entryLabel.js rename to modules/entry/back/methods/entry/buyLabel.js index 50e82b54c..650b05c97 100644 --- a/modules/entry/back/methods/entry/entryLabel.js +++ b/modules/entry/back/methods/entry/buyLabel.js @@ -1,6 +1,6 @@ module.exports = Self => { - Self.remoteMethodCtx('entryLabel', { - description: 'Returns the entry labels', + Self.remoteMethodCtx('buyLabel', { + description: 'Returns the entry buys labels', accessType: 'READ', accepts: [ { @@ -27,10 +27,10 @@ module.exports = Self => { } ], http: { - path: '/:id/entry-label', + path: '/:id/buy-label', verb: 'GET' } }); - Self.entryLabel = (ctx, id) => Self.printReport(ctx, id, 'entry-label'); + Self.buyLabel = (ctx, id) => Self.printReport(ctx, id, 'buy-label'); }; diff --git a/modules/entry/back/models/entry.js b/modules/entry/back/models/entry.js index 10f63b9f0..6e27e1ece 100644 --- a/modules/entry/back/models/entry.js +++ b/modules/entry/back/models/entry.js @@ -9,7 +9,7 @@ module.exports = Self => { require('../methods/entry/entryOrderPdf')(Self); require('../methods/entry/addFromPackaging')(Self); require('../methods/entry/addFromBuy')(Self); - require('../methods/entry/entryLabel')(Self); + require('../methods/entry/buyLabel')(Self); Self.observe('before save', async function(ctx, options) { if (ctx.isNewInstance) return; diff --git a/print/templates/reports/entry-label/assets/css/import.js b/print/templates/reports/buy-label/assets/css/import.js similarity index 100% rename from print/templates/reports/entry-label/assets/css/import.js rename to print/templates/reports/buy-label/assets/css/import.js diff --git a/print/templates/reports/entry-label/assets/css/style.css b/print/templates/reports/buy-label/assets/css/style.css similarity index 100% rename from print/templates/reports/entry-label/assets/css/style.css rename to print/templates/reports/buy-label/assets/css/style.css diff --git a/print/templates/reports/entry-label/entry-label.html b/print/templates/reports/buy-label/buy-label.html similarity index 73% rename from print/templates/reports/entry-label/entry-label.html rename to print/templates/reports/buy-label/buy-label.html index 65fbfb806..494cdcbc5 100644 --- a/print/templates/reports/entry-label/entry-label.html +++ b/print/templates/reports/buy-label/buy-label.html @@ -5,13 +5,13 @@
- Variedad + {{$t('variety')}} {{buy.name}}
- Medida + {{$t('size')}} {{buy.size}}
@@ -19,19 +19,19 @@
- Categoría + {{$t('category')}} {{buy.category}}
- Color + {{$t('color')}} {{buy.color}}
- Origen + {{$t('origin')}} {{buy.code}}
@@ -39,19 +39,19 @@
- Packing + {{$t('packing')}} {{buy.packing}}
- Grouping + {{$t('grouping')}} {{buy.grouping}}
- Ud. venta + {{$t('saleUnit')}} {{buy.stems}}
@@ -65,7 +65,7 @@
- Productor + {{$t('producer')}} {{buy.producer}}
@@ -73,13 +73,13 @@
- Control + {{$t('control')}} {{`${weekNum} / ${dayNum}`}}
- Caja nº + {{$t('boxNum')}} {{`${buy.labelNum} / ${maxLabelNum}`}}
diff --git a/print/templates/reports/entry-label/entry-label.js b/print/templates/reports/buy-label/buy-label.js similarity index 93% rename from print/templates/reports/entry-label/entry-label.js rename to print/templates/reports/buy-label/buy-label.js index 08d2acc49..b6e0a5031 100755 --- a/print/templates/reports/entry-label/entry-label.js +++ b/print/templates/reports/buy-label/buy-label.js @@ -4,10 +4,10 @@ const jsBarcode = require('jsbarcode'); const moment = require('moment'); module.exports = { - name: 'entry-label', + name: 'buy-label', mixins: [vnReport], async serverPrefetch() { - this.buys = await this.rawSqlFromDef('entry', [this.id]); + this.buys = await this.rawSqlFromDef('buys', [this.id]); this.maxLabelNum = Math.max(...this.buys.map(buy => buy.labelNum)); const date = new Date(); this.weekNum = moment(date).isoWeek(); diff --git a/print/templates/reports/buy-label/locale/en.yml b/print/templates/reports/buy-label/locale/en.yml new file mode 100644 index 000000000..d48d00771 --- /dev/null +++ b/print/templates/reports/buy-label/locale/en.yml @@ -0,0 +1,12 @@ +reportName: Entry buys +variety: Bariety +size: Size +category: Category +color: Color +origin: Origin +packing: Packing +grouping: Grouping +unitSale: Un. sale +producer: Producer +control: Control +boxNum: Box no. \ No newline at end of file diff --git a/print/templates/reports/buy-label/locale/es.yml b/print/templates/reports/buy-label/locale/es.yml new file mode 100644 index 000000000..33a4a499d --- /dev/null +++ b/print/templates/reports/buy-label/locale/es.yml @@ -0,0 +1,12 @@ +reportName: Etiqueta de compras +variety: Variedad +size: Medida +category: Categoría +color: Color +origin: Origen +packing: Packing +grouping: Grouping +saleUnit: Sale un. +producer: Productor +control: Control +boxNum: Caja nº \ No newline at end of file diff --git a/print/templates/reports/entry-label/options.json b/print/templates/reports/buy-label/options.json similarity index 100% rename from print/templates/reports/entry-label/options.json rename to print/templates/reports/buy-label/options.json diff --git a/print/templates/reports/entry-label/sql/entry.sql b/print/templates/reports/buy-label/sql/buys.sql similarity index 100% rename from print/templates/reports/entry-label/sql/entry.sql rename to print/templates/reports/buy-label/sql/buys.sql diff --git a/print/templates/reports/entry-label/locale/es.yml b/print/templates/reports/entry-label/locale/es.yml deleted file mode 100644 index 278946f3e..000000000 --- a/print/templates/reports/entry-label/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -reportName: Etiqueta \ No newline at end of file From a0ea742f9e523a9fec3ef12304a9399ec28840fa Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 1 Jul 2024 13:38:25 +0200 Subject: [PATCH 5/5] fix: refs #7486 Hotfix --- db/routines/vn/procedures/ticket_splitItemPackingType.sql | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/ticket_splitItemPackingType.sql b/db/routines/vn/procedures/ticket_splitItemPackingType.sql index b28b16432..d6e8e8a53 100644 --- a/db/routines/vn/procedures/ticket_splitItemPackingType.sql +++ b/db/routines/vn/procedures/ticket_splitItemPackingType.sql @@ -44,7 +44,6 @@ BEGIN WHERE s.ticketFk = vTicketFk; CREATE OR REPLACE TEMPORARY TABLE tmp.saleGroup - (PRIMARY KEY (itemPackingTypeFk)) ENGINE = MEMORY SELECT itemPackingTypeFk, SUM(litros) totalLitros FROM tmp.sale @@ -56,8 +55,7 @@ BEGIN CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT ( ticketFk INT, - itemPackingTypeFk VARCHAR(1), - PRIMARY KEY (ticketFk) + itemPackingTypeFk VARCHAR(1) ) ENGINE = MEMORY; CASE vPackingTypesToSplit