From 10d2d4c9c4de6c3642f415cbe93fad694cc7a8fa Mon Sep 17 00:00:00 2001
From: ivanm <ivanm@verdnatura.es>
Date: Tue, 26 Nov 2024 18:01:49 +0100
Subject: [PATCH 01/11] fix: hotfix entry_splitByShelving

---
 db/routines/vn/procedures/entry_splitByShelving.sql | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/db/routines/vn/procedures/entry_splitByShelving.sql b/db/routines/vn/procedures/entry_splitByShelving.sql
index 3201900e65..f5de360980 100644
--- a/db/routines/vn/procedures/entry_splitByShelving.sql
+++ b/db/routines/vn/procedures/entry_splitByShelving.sql
@@ -23,12 +23,13 @@ BEGIN
 				LEAST(bb.stickers, FLOOR(ish.visible / ish.packing)) ishStickers,
 				bb.stickers buyStickers
 			FROM itemShelving ish
+				JOIN shelving sh ON sh.id = ish.shelvingFk
 				JOIN (SELECT b.id, b.itemFk, b.stickers 
 						FROM buy b
 						WHERE b.entryFk = vFromEntryFk
 						ORDER BY b.stickers DESC
 						LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk
-			WHERE ish.shelvingFk = vShelvingCode COLLATE utf8_general_ci
+			WHERE sh.code = vShelvingCode COLLATE utf8_general_ci
 				AND NOT ish.isSplit
 			GROUP BY ish.id;
 			

From c550f711c6cc52802f40511612aef21eddfc09e1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= <carlosap@verdnatura.es>
Date: Tue, 26 Nov 2024 17:55:36 +0000
Subject: [PATCH 02/11] Actualizar
 db/routines/vn/triggers/travel_beforeUpdate.sql

---
 db/routines/vn/triggers/travel_beforeUpdate.sql | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/db/routines/vn/triggers/travel_beforeUpdate.sql b/db/routines/vn/triggers/travel_beforeUpdate.sql
index 5a27b43b42..256dd35f87 100644
--- a/db/routines/vn/triggers/travel_beforeUpdate.sql
+++ b/db/routines/vn/triggers/travel_beforeUpdate.sql
@@ -20,10 +20,6 @@ BEGIN
 		CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
 	END IF;
 
-	IF NOT (NEW.isRaid <=> OLD.isRaid)  OR NOT (NEW.daysInForward <=> OLD.daysInForward) THEN
-		CALL travel_checkRaid(NEW.isRaid, NEW.daysInForward);
-	END IF;
-
 	IF NOT (NEW.awbFk <=> OLD.awbFk)THEN
 		SELECT COUNT(*) INTO vHasAnyInvoiceBooked
 			FROM travel t

From 0afae5c2d62f651abbae46b6313eb09f512a1152 Mon Sep 17 00:00:00 2001
From: guillermo <guillermo@verdnatura.es>
Date: Wed, 27 Nov 2024 10:40:47 +0100
Subject: [PATCH 03/11] fix: refs #7266 Minor changes

---
 .../reports/buy-label-barcode/buy-label-barcode.html | 12 ++++++------
 .../reports/buy-label-barcode/buy-label-barcode.js   |  5 ++++-
 .../reports/buy-label-qr/assets/css/style.css        |  3 +++
 .../templates/reports/buy-label-qr/buy-label-qr.html | 11 +++++------
 print/templates/reports/buy-label-qr/buy-label-qr.js |  5 ++++-
 5 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/print/templates/reports/buy-label-barcode/buy-label-barcode.html b/print/templates/reports/buy-label-barcode/buy-label-barcode.html
index f14f0b70b5..c787942c43 100644
--- a/print/templates/reports/buy-label-barcode/buy-label-barcode.html
+++ b/print/templates/reports/buy-label-barcode/buy-label-barcode.html
@@ -38,7 +38,7 @@
 			<tr>
 				<td class="md-txt xl-width bold center">
 					<div class="overflow-line">
-						{{buy.itemFk}}
+						{{formatNumber(buy.itemFk)}}
 					</div>
 				</td>
 				<td colspan="2" class="md-txt md-width center">
@@ -56,7 +56,7 @@
 						{{'LAID'}}
 					</div>
 					<div v-else class="overflow-line">
-						{{buy.entryFk}}
+						{{formatNumber(buy.entryFk)}}
 					</div>
 				</td>
 			</tr>
@@ -73,17 +73,17 @@
 				</td>
 			</tr>
 			<tr>
-				<td class="center xl-width">
+				<td class="center xs-txt xl-width">
 					<div class="overflow-line">
-						{{buy.buyFk}}
+						{{formatNumber(buy.buyFk)}}
 					</div>
 				</td>
-				<td class="xs-txt sm-width center">
+				<td class="center xs-txt sm-width">
 					<div class="overflow-line">
 						{{date}}
 					</div>
 				</td>
-				<td class="xs-txt sm-width cursive center bold">
+				<td class="cursive center bold xs-txt sm-width">
 					<div class="overflow-line">
 						{{`${buy.labelNum}/${buy.quantity / (packing || buy.packing)}`}}
 					</div>
diff --git a/print/templates/reports/buy-label-barcode/buy-label-barcode.js b/print/templates/reports/buy-label-barcode/buy-label-barcode.js
index 8c39a7046f..509d9f5020 100755
--- a/print/templates/reports/buy-label-barcode/buy-label-barcode.js
+++ b/print/templates/reports/buy-label-barcode/buy-label-barcode.js
@@ -9,7 +9,7 @@ module.exports = {
         this.date = Date.vnNew();
         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');
+        this.date = moment(this.date).format('WW/DD');
     },
     methods: {
         getBarcode(data) {
@@ -25,6 +25,9 @@ module.exports = {
                 margin: 0
             });
             return new XMLSerializer().serializeToString(svgNode);
+        },
+        formatNumber(number) {
+            return new Intl.NumberFormat('es-ES', {maximumFractionDigits: 0}).format(number);
         }
     },
     props: {
diff --git a/print/templates/reports/buy-label-qr/assets/css/style.css b/print/templates/reports/buy-label-qr/assets/css/style.css
index 0e288704bc..36db0fdefe 100644
--- a/print/templates/reports/buy-label-qr/assets/css/style.css
+++ b/print/templates/reports/buy-label-qr/assets/css/style.css
@@ -34,6 +34,9 @@ html {
     background-color: black;
     color: white;
 }
+.sm-txt {
+    font-size: 18px;
+}
 .md-txt {
     font-size: 20px;
 }
diff --git a/print/templates/reports/buy-label-qr/buy-label-qr.html b/print/templates/reports/buy-label-qr/buy-label-qr.html
index 00e64b57d7..00ede54880 100644
--- a/print/templates/reports/buy-label-qr/buy-label-qr.html
+++ b/print/templates/reports/buy-label-qr/buy-label-qr.html
@@ -11,8 +11,8 @@
 				</td>
 			</tr>
 			<tr>
-				<td colspan="2">
-					{{buy.buyFk}}
+				<td colspan="2" class="sm-txt">
+					{{formatNumber(buy.buyFk)}}
 				</td>
 			</tr>
 			<tr>
@@ -28,7 +28,7 @@
 		<tr>
 			<td colspan="3" class="lg-width black-bg center bold xl-txt padding">
 				<div class="overflow-line">
-					{{buy.itemFk}}
+					{{formatNumber(buy.itemFk)}}
 				</div>
 			</td>
 		</tr>
@@ -78,8 +78,7 @@
 				<div v-if="buy.isLaid && typeId === 'buy'" class="overflow-line black-bg bold">
 					{{'LAID'}}
 				</div>
-				<div v-else class="overflow-line">
-					{{buy.entryFk}}
+				<div v-else class="overflow-line xs-txt">
 				</div>
 			</td>
 		</tr>
@@ -103,7 +102,7 @@
 		<tr>
 			<td class="sm-width">
 				<div class="overflow-line">
-					<i>Entrada:</i> {{buy.entryFk}}
+					<i>Entrada:</i> {{formatNumber(buy.entryFk)}}
 				</div>
 			</td>
 		</tr>
diff --git a/print/templates/reports/buy-label-qr/buy-label-qr.js b/print/templates/reports/buy-label-qr/buy-label-qr.js
index 74470ad6dc..614e408168 100755
--- a/print/templates/reports/buy-label-qr/buy-label-qr.js
+++ b/print/templates/reports/buy-label-qr/buy-label-qr.js
@@ -9,7 +9,7 @@ module.exports = {
         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');
+        this.date = moment(this.date).format('WW/DD');
     },
     methods: {
         getQr(data) {
@@ -24,6 +24,9 @@ module.exports = {
                 margin: 0,
                 errorCorrectionLevel: 'L'
             });
+        },
+        formatNumber(number) {
+            return new Intl.NumberFormat('es-ES', {maximumFractionDigits: 0}).format(number);
         }
     },
     props: {

From 8fd133c5e8a10edb4b35b3796887be898d6ff442 Mon Sep 17 00:00:00 2001
From: jorgep <jorgep@verdnatura.es>
Date: Wed, 27 Nov 2024 12:51:09 +0100
Subject: [PATCH 04/11] feat: refs #6818 define prefix model

---
 back/model-config.json                        |  3 +++
 back/models/prefix.json                       | 27 +++++++++++++++++++
 modules/client/back/methods/client/summary.js |  2 +-
 3 files changed, 31 insertions(+), 1 deletion(-)
 create mode 100644 back/models/prefix.json

diff --git a/back/model-config.json b/back/model-config.json
index b543071c9b..e0bc922002 100644
--- a/back/model-config.json
+++ b/back/model-config.json
@@ -133,6 +133,9 @@
     "Postcode": {
         "dataSource": "vn"
     },
+    "Prefix": {
+        "dataSource": "vn"
+    },
     "ReferenceRate": {
         "dataSource": "vn"
     },
diff --git a/back/models/prefix.json b/back/models/prefix.json
new file mode 100644
index 0000000000..762354caa2
--- /dev/null
+++ b/back/models/prefix.json
@@ -0,0 +1,27 @@
+{
+    "name": "Prefix",
+    "base": "VnModel",
+    "options": {
+        "mysql": {
+            "table": "pbx.prefix"
+        }
+    },
+    "properties": {
+        "country": {
+            "type": "string",
+            "id": true
+        },
+        "prefix": {
+            "type": "string"
+        }
+    },
+    "acls": [
+        {
+            "property": "*",
+            "accessType": "READ",
+            "principalType": "ROLE",
+            "principalId": "employee",
+            "permission": "ALLOW"
+        }
+    ]
+}
\ No newline at end of file
diff --git a/modules/client/back/methods/client/summary.js b/modules/client/back/methods/client/summary.js
index 9242fbd442..9c1420b611 100644
--- a/modules/client/back/methods/client/summary.js
+++ b/modules/client/back/methods/client/summary.js
@@ -54,7 +54,7 @@ module.exports = Self => {
                 {
                     relation: 'country',
                     scope: {
-                        fields: ['id', 'name'],
+                        fields: ['id', 'name', 'code'],
                         include: {
                             relation: 'saySimpleCountry',
                         }

From 2231add129128bfb8c6c9645ac298e7d0d172253 Mon Sep 17 00:00:00 2001
From: guillermo <guillermo@verdnatura.es>
Date: Wed, 27 Nov 2024 12:58:32 +0100
Subject: [PATCH 05/11] fix: refs #7266 Minor changes

---
 print/templates/reports/buy-label-barcode/assets/css/style.css | 3 +++
 .../templates/reports/buy-label-barcode/buy-label-barcode.html | 2 +-
 print/templates/reports/buy-label-barcode/buy-label-barcode.js | 2 +-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/print/templates/reports/buy-label-barcode/assets/css/style.css b/print/templates/reports/buy-label-barcode/assets/css/style.css
index fabecd28e1..eece20acb0 100644
--- a/print/templates/reports/buy-label-barcode/assets/css/style.css
+++ b/print/templates/reports/buy-label-barcode/assets/css/style.css
@@ -32,6 +32,9 @@ td {
 .md-txt {
     font-size: 26px;
 }
+.lg-txt {
+    font-size: 32px;
+}
 .xl-txt {
     font-size: 50px;
 }
diff --git a/print/templates/reports/buy-label-barcode/buy-label-barcode.html b/print/templates/reports/buy-label-barcode/buy-label-barcode.html
index c787942c43..c1725f5c06 100644
--- a/print/templates/reports/buy-label-barcode/buy-label-barcode.html
+++ b/print/templates/reports/buy-label-barcode/buy-label-barcode.html
@@ -36,7 +36,7 @@
 				</td>
 			</tr>
 			<tr>
-				<td class="md-txt xl-width bold center">
+				<td class="lg-txt xl-width bold center">
 					<div class="overflow-line">
 						{{formatNumber(buy.itemFk)}}
 					</div>
diff --git a/print/templates/reports/buy-label-barcode/buy-label-barcode.js b/print/templates/reports/buy-label-barcode/buy-label-barcode.js
index 509d9f5020..8e9f186b51 100755
--- a/print/templates/reports/buy-label-barcode/buy-label-barcode.js
+++ b/print/templates/reports/buy-label-barcode/buy-label-barcode.js
@@ -21,7 +21,7 @@ module.exports = {
                 format: 'code128',
                 displayValue: false,
                 width: 3.8,
-                height: 85,
+                height: 80,
                 margin: 0
             });
             return new XMLSerializer().serializeToString(svgNode);

From 9c495ada133537f28ca87b5309e6b8b1790d8dab Mon Sep 17 00:00:00 2001
From: guillermo <guillermo@verdnatura.es>
Date: Wed, 27 Nov 2024 12:59:27 +0100
Subject: [PATCH 06/11] fix: refs #7266 Minor changes x2

---
 print/templates/reports/buy-label-barcode/buy-label-barcode.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/print/templates/reports/buy-label-barcode/buy-label-barcode.js b/print/templates/reports/buy-label-barcode/buy-label-barcode.js
index 8e9f186b51..a0359acc92 100755
--- a/print/templates/reports/buy-label-barcode/buy-label-barcode.js
+++ b/print/templates/reports/buy-label-barcode/buy-label-barcode.js
@@ -21,7 +21,7 @@ module.exports = {
                 format: 'code128',
                 displayValue: false,
                 width: 3.8,
-                height: 80,
+                height: 75,
                 margin: 0
             });
             return new XMLSerializer().serializeToString(svgNode);

From 15c755087c929a58f90a8cfcc57d675e4f65e8f8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= <carlosap@verdnatura.es>
Date: Wed, 27 Nov 2024 14:28:50 +0100
Subject: [PATCH 07/11] fix: refs #8221 duaInvoiceIn unique

---
 db/versions/11369-azureChrysanthemum/00-firstScript.sql | 5 +++++
 1 file changed, 5 insertions(+)
 create mode 100644 db/versions/11369-azureChrysanthemum/00-firstScript.sql

diff --git a/db/versions/11369-azureChrysanthemum/00-firstScript.sql b/db/versions/11369-azureChrysanthemum/00-firstScript.sql
new file mode 100644
index 0000000000..3a86c0c598
--- /dev/null
+++ b/db/versions/11369-azureChrysanthemum/00-firstScript.sql
@@ -0,0 +1,5 @@
+ALTER TABLE vn.duaInvoiceIn DROP KEY IF EXISTS duaFk_UNIQUE;
+ALTER TABLE vn.duaInvoiceIn DROP KEY IF EXISTS duaInvoiceIn_unique;
+ALTER TABLE vn.duaInvoiceIn ADD CONSTRAINT duaInvoiceIn_unique
+	UNIQUE KEY (invoiceInFk);
+

From d872f164fda67e1803c538863014c3fc3b6261de Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= <carlosap@verdnatura.es>
Date: Wed, 27 Nov 2024 14:55:30 +0000
Subject: [PATCH 08/11] Actualizar modules/entry/back/models/entry.js

---
 modules/entry/back/models/entry.js | 1 +
 1 file changed, 1 insertion(+)

diff --git a/modules/entry/back/models/entry.js b/modules/entry/back/models/entry.js
index 8ca79f5316..49c3d2ec38 100644
--- a/modules/entry/back/models/entry.js
+++ b/modules/entry/back/models/entry.js
@@ -12,6 +12,7 @@ module.exports = Self => {
     require('../methods/entry/addFromBuy')(Self);
     require('../methods/entry/buyLabel')(Self);
     require('../methods/entry/print')(Self);
+    require('../methods/entry/buyLabelSupplier')(Self);
 
     Self.observe('before save', async function(ctx, options) {
         if (ctx.isNewInstance) return;

From 30cc7a49a0f859e9c1d254a3a12d654a9dca045e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= <carlosap@verdnatura.es>
Date: Wed, 27 Nov 2024 15:38:50 +0000
Subject: [PATCH 09/11] Actualizar modules/entry/back/methods/entry/print.js

---
 modules/entry/back/methods/entry/print.js | 1 +
 1 file changed, 1 insertion(+)

diff --git a/modules/entry/back/methods/entry/print.js b/modules/entry/back/methods/entry/print.js
index 5b9de9a695..b604adce66 100644
--- a/modules/entry/back/methods/entry/print.js
+++ b/modules/entry/back/methods/entry/print.js
@@ -48,6 +48,7 @@ module.exports = Self => {
         for (const buy of buys) {
             if (buy.stickers < 1) continue;
             ctx.args.id = buy.id;
+            ctx.args.copies = buy.stickers;
             const pdfBuffer = await models.Entry.buyLabel(ctx, myOptions);
             await merger.add(new Uint8Array(pdfBuffer[0]));
         }

From 93388461d184de74a0fe01df4083c48b79fc37ae Mon Sep 17 00:00:00 2001
From: guillermo <guillermo@verdnatura.es>
Date: Thu, 28 Nov 2024 08:59:08 +0100
Subject: [PATCH 10/11] fix: refs #7266 Changed method name and corrections

---
 .../back/methods/entry/{print.js => labelSupplier.js}     | 8 ++++----
 modules/entry/back/models/entry.js                        | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)
 rename modules/entry/back/methods/entry/{print.js => labelSupplier.js} (89%)

diff --git a/modules/entry/back/methods/entry/print.js b/modules/entry/back/methods/entry/labelSupplier.js
similarity index 89%
rename from modules/entry/back/methods/entry/print.js
rename to modules/entry/back/methods/entry/labelSupplier.js
index b604adce66..32d80c4277 100644
--- a/modules/entry/back/methods/entry/print.js
+++ b/modules/entry/back/methods/entry/labelSupplier.js
@@ -1,6 +1,6 @@
 const UserError = require('vn-loopback/util/user-error');
 module.exports = Self => {
-    Self.remoteMethodCtx('print', {
+    Self.remoteMethodCtx('labelSupplier', {
         description: 'Print stickers of all entries',
         accessType: 'READ',
         accepts: [
@@ -28,13 +28,13 @@ module.exports = Self => {
             }
         ],
         http: {
-            path: '/:id/print',
+            path: '/:id/labelSupplier',
             verb: 'GET'
         },
         accessScopes: ['DEFAULT', 'read:multimedia']
     });
 
-    Self.print = async function(ctx, id, options) {
+    Self.labelSupplier = async function(ctx, id, options) {
         const models = Self.app.models;
         const myOptions = {};
         if (typeof options == 'object')
@@ -49,7 +49,7 @@ module.exports = Self => {
             if (buy.stickers < 1) continue;
             ctx.args.id = buy.id;
             ctx.args.copies = buy.stickers;
-            const pdfBuffer = await models.Entry.buyLabel(ctx, myOptions);
+            const pdfBuffer = await models.Entry.buyLabelSupplier(ctx, myOptions);
             await merger.add(new Uint8Array(pdfBuffer[0]));
         }
 
diff --git a/modules/entry/back/models/entry.js b/modules/entry/back/models/entry.js
index 49c3d2ec38..dc5022adab 100644
--- a/modules/entry/back/models/entry.js
+++ b/modules/entry/back/models/entry.js
@@ -11,7 +11,7 @@ module.exports = Self => {
     require('../methods/entry/addFromPackaging')(Self);
     require('../methods/entry/addFromBuy')(Self);
     require('../methods/entry/buyLabel')(Self);
-    require('../methods/entry/print')(Self);
+    require('../methods/entry/labelSupplier')(Self);
     require('../methods/entry/buyLabelSupplier')(Self);
 
     Self.observe('before save', async function(ctx, options) {

From 51d96a89c590ecd93ee41f3f589ca67a8f10b902 Mon Sep 17 00:00:00 2001
From: guillermo <guillermo@verdnatura.es>
Date: Thu, 28 Nov 2024 11:15:58 +0100
Subject: [PATCH 11/11] fix: refs #7266 Increased size item id buy-label

---
 .../templates/reports/buy-label-barcode/assets/css/style.css  | 4 +++-
 .../reports/buy-label-barcode/buy-label-barcode.html          | 4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/print/templates/reports/buy-label-barcode/assets/css/style.css b/print/templates/reports/buy-label-barcode/assets/css/style.css
index eece20acb0..ce1924878c 100644
--- a/print/templates/reports/buy-label-barcode/assets/css/style.css
+++ b/print/templates/reports/buy-label-barcode/assets/css/style.css
@@ -33,7 +33,9 @@ td {
     font-size: 26px;
 }
 .lg-txt {
-    font-size: 32px;
+    font-size: 40px;
+    padding: 0px;
+    line-height: 1;
 }
 .xl-txt {
     font-size: 50px;
diff --git a/print/templates/reports/buy-label-barcode/buy-label-barcode.html b/print/templates/reports/buy-label-barcode/buy-label-barcode.html
index c1725f5c06..ebddb60ecb 100644
--- a/print/templates/reports/buy-label-barcode/buy-label-barcode.html
+++ b/print/templates/reports/buy-label-barcode/buy-label-barcode.html
@@ -36,12 +36,12 @@
 				</td>
 			</tr>
 			<tr>
-				<td class="lg-txt xl-width bold center">
+				<td class="bold center lg-txt xl-width">
 					<div class="overflow-line">
 						{{formatNumber(buy.itemFk)}}
 					</div>
 				</td>
-				<td colspan="2" class="md-txt md-width center">
+				<td colspan="2" class="center md-txt md-width">
 					<div class="overflow-line">
 						{{`${(packing || buy.packing)} x ${buy.stems || ''}`}}
 					</div>