From 446ffac7f848c3dc47f7667e001778c939baabde Mon Sep 17 00:00:00 2001
From: robert <robert@verdnatura.es>
Date: Thu, 9 Jan 2025 13:44:59 +0100
Subject: [PATCH 1/6] feat: sendCheckingPresence debug

---
 back/methods/chat/sendCheckingPresence.js | 69 +++++++++++++----------
 1 file changed, 39 insertions(+), 30 deletions(-)

diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js
index 7ab5d63fef..83e8da304d 100644
--- a/back/methods/chat/sendCheckingPresence.js
+++ b/back/methods/chat/sendCheckingPresence.js
@@ -27,38 +27,47 @@ module.exports = Self => {
     });
 
     Self.sendCheckingPresence = async(ctx, recipientId, message) => {
-        if (!recipientId) return false;
-        const models = Self.app.models;
-
         const userId = ctx.req.accessToken.userId;
-        const sender = await models.VnUser.findById(userId, {fields: ['id']});
-        const recipient = await models.VnUser.findById(recipientId, null);
-
-        // Prevent sending messages to yourself
-        if (recipientId == userId) return false;
-        if (!recipient)
-            throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`);
-
-        if (!isProduction())
-            message = `[Test:Environment to user ${userId}] ` + message;
-
-        const chat = await models.Chat.create({
-            senderFk: sender.id,
-            recipient: `@${recipient.name}`,
-            dated: Date.vnNew(),
-            checkUserStatus: 1,
-            message: message,
-            status: 'sending',
-            attempts: 0
-        });
-
         try {
-            await Self.sendCheckingUserStatus(chat);
-            await Self.updateChat(chat, 'sent');
-        } catch (error) {
-            await Self.updateChat(chat, 'error', error);
-        }
+            const models = Self.app.models;
+            const sender = await models.VnUser.findById(userId, {fields: ['id']});
+            const error = `Could not send message from user ${userId}`;
 
-        return true;
+            if (!recipientId) throw new Error(error);
+            const recipient = await models.VnUser.findById(recipientId, null);
+            if (!recipient)
+                throw new Error(error);
+
+            // Prevent sending messages to yourself
+            if (recipientId == userId) return false;
+
+            if (!isProduction())
+                message = `[Test:Environment to user ${userId}] ` + message;
+
+            const chat = await models.Chat.create({
+                senderFk: sender.id,
+                recipient: `@${recipient.name}`,
+                dated: Date.vnNew(),
+                checkUserStatus: 1,
+                message: message,
+                status: 'sending',
+                attempts: 0
+            });
+
+            try {
+                await Self.sendCheckingUserStatus(chat);
+                await Self.updateChat(chat, 'sent');
+            } catch (error) {
+                await Self.updateChat(chat, 'error', error);
+            }
+
+            return true;
+        } catch (e) {
+            await Self.rawSql(`
+                INSERT INTO util.debug (variable, value)
+                    VALUES ('sendCheckingPresence_error', ?)
+            `, [`User: ${userId}, recipient: ${recipientId}, message: ${message}, error: ${e}`]);
+            throw e;
+        }
     };
 };

From 1ac75d87ade3d238585c075813fc136601417f3c Mon Sep 17 00:00:00 2001
From: sergiodt <sergiodt@verdnatura.es>
Date: Fri, 10 Jan 2025 08:55:45 +0100
Subject: [PATCH 2/6] fix: refs #6861 refs#6861 addPrevOK

---
 db/routines/vn/procedures/saleTracking_addPrevOK.sql | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/db/routines/vn/procedures/saleTracking_addPrevOK.sql b/db/routines/vn/procedures/saleTracking_addPrevOK.sql
index 34d1cfac8c..9f823e9a09 100644
--- a/db/routines/vn/procedures/saleTracking_addPrevOK.sql
+++ b/db/routines/vn/procedures/saleTracking_addPrevOK.sql
@@ -16,10 +16,11 @@ BEGIN
 				TRUE,
 				sc.userFk,
 				s.id
-			FROM vn.sectorCollection sc
-				JOIN vn.sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id
-				JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk
-				JOIN vn.state s ON s.code = 'OK PREVIOUS'
+			FROM sectorCollection sc
+				JOIN sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id
+				JOIN saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk
+				JOIN state s ON s.code = 'OK PREVIOUS'
+				JOIN itemShelvingSale iss ON iss.saleFk = sgd.saleFk
 			WHERE sc.id = vSectorCollectionFk;
 END$$
 DELIMITER ;

From 9d05b16404da3a7d3d7d5e14300f7b4a9d8baa9f Mon Sep 17 00:00:00 2001
From: alexm <alexm@verdnatura.es>
Date: Mon, 13 Jan 2025 09:18:46 +0100
Subject: [PATCH 3/6] fix: canBeInvoiced only in makeInvoice

---
 loopback/locale/en.json                       |  3 +-
 loopback/locale/es.json                       |  2 +-
 loopback/locale/fr.json                       |  2 +-
 loopback/locale/pt.json                       |  2 +-
 .../methods/invoiceOut/clientsToInvoice.js    |  6 ---
 .../invoiceOut/specs/clientsToInvoice.spec.js | 54 +++++++++++--------
 6 files changed, 38 insertions(+), 31 deletions(-)

diff --git a/loopback/locale/en.json b/loopback/locale/en.json
index 80da13ae59..8d5eab4bc5 100644
--- a/loopback/locale/en.json
+++ b/loopback/locale/en.json
@@ -211,6 +211,7 @@
 	"Name should be uppercase": "Name should be uppercase",
 	"You cannot update these fields": "You cannot update these fields",
 	"CountryFK cannot be empty": "Country cannot be empty",
+    "No tickets to invoice": "There are no tickets to invoice that meet the invoicing requirements",
 	"You are not allowed to modify the alias": "You are not allowed to modify the alias",
 	"You already have the mailAlias": "You already have the mailAlias",
 	"This machine is already in use.": "This machine is already in use.",
@@ -251,4 +252,4 @@
 	"Price cannot be blank": "Price cannot be blank",
 	"There are tickets to be invoiced": "There are tickets to be invoiced",
 	"The address of the customer must have information about Incoterms and Customs Agent": "The address of the customer must have information about Incoterms and Customs Agent"
-}
\ No newline at end of file
+}
diff --git a/loopback/locale/es.json b/loopback/locale/es.json
index fcee0e1119..cde81e0cb3 100644
--- a/loopback/locale/es.json
+++ b/loopback/locale/es.json
@@ -339,7 +339,7 @@
 	"Incorrect pin": "Pin incorrecto.",
 	"You already have the mailAlias": "Ya tienes este alias de correo",
 	"The alias cant be modified": "Este alias de correo no puede ser modificado",
-	"No tickets to invoice": "No hay tickets para facturar",
+	"No tickets to invoice": "No hay tickets para facturar que cumplan los requisitos de facturación",
 	"this warehouse has not dms": "El Almacén no acepta documentos",
 	"This ticket already has a cmr saved": "Este ticket ya tiene un cmr guardado",
 	"Name should be uppercase": "El nombre debe ir en mayúscula",
diff --git a/loopback/locale/fr.json b/loopback/locale/fr.json
index 9941358be6..f49196a8fd 100644
--- a/loopback/locale/fr.json
+++ b/loopback/locale/fr.json
@@ -339,7 +339,7 @@
 	"Incorrect pin": "Pin incorrect.",
 	"You already have the mailAlias": "Vous avez déjà cet alias de courrier",
 	"The alias cant be modified": "Cet alias de courrier ne peut pas être modifié",
-	"No tickets to invoice": "Pas de tickets à facturer",
+	"No tickets to invoice": "Il n'y a pas de tickets à facturer qui répondent aux exigences de facturation",
 	"this warehouse has not dms": "L'entrepôt n'accepte pas les documents",
 	"This ticket already has a cmr saved": "Ce ticket a déjà un cmr enregistré",
 	"Name should be uppercase": "Le nom doit être en majuscules",
diff --git a/loopback/locale/pt.json b/loopback/locale/pt.json
index e84b30f3d1..e2374d35f3 100644
--- a/loopback/locale/pt.json
+++ b/loopback/locale/pt.json
@@ -339,7 +339,7 @@
 	"Incorrect pin": "PIN incorreto.",
 	"You already have the mailAlias": "Você já tem o alias de e-mail",
 	"The alias cant be modified": "O alias não pode ser modificado",
-	"No tickets to invoice": "Não há tickets para faturar",
+	"No tickets to invoice": "Não há bilhetes para faturar que atendam aos requisitos de faturamento",
 	"this warehouse has not dms": "Este armazém não tem DMS",
 	"This ticket already has a cmr saved": "Este ticket já tem um CMR salvo",
 	"Name should be uppercase": "O nome deve estar em maiúsculas",
diff --git a/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js
index 7befdcbeb9..f662214099 100644
--- a/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js
+++ b/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js
@@ -49,12 +49,6 @@ module.exports = Self => {
         }
 
         try {
-            const clientCanBeInvoiced =
-                await Self.app.models.Client.canBeInvoiced(clientId, companyFk, myOptions);
-
-            if (!clientCanBeInvoiced)
-                throw new UserError(`This client can't be invoiced`);
-
             const vIsAllInvoiceable = false;
             await Self.rawSql('CALL ticketPackaging_add(?, ?, ?, ?)', [
                 clientId,
diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/clientsToInvoice.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/clientsToInvoice.spec.js
index df0566c540..6e536f4331 100644
--- a/modules/invoiceOut/back/methods/invoiceOut/specs/clientsToInvoice.spec.js
+++ b/modules/invoiceOut/back/methods/invoiceOut/specs/clientsToInvoice.spec.js
@@ -1,4 +1,5 @@
 const models = require('vn-loopback/server/server').models;
+const LoopBackContext = require('loopback-context');
 
 describe('InvoiceOut clientsToInvoice()', () => {
     const userId = 1;
@@ -20,6 +21,21 @@ describe('InvoiceOut clientsToInvoice()', () => {
         headers: {origin: 'http://localhost'}
     };
     const ctx = {req: activeCtx};
+    let tx;
+    let options;
+
+    beforeEach(async() => {
+        LoopBackContext.getCurrentContext = () => ({
+            active: activeCtx,
+        });
+
+        tx = await models.InvoiceOut.beginTransaction({});
+        options = {transaction: tx};
+    });
+
+    afterEach(async() => {
+        await tx.rollback();
+    });
 
     it('should return a list of clients to invoice', async() => {
         spyOn(models.InvoiceOut, 'rawSql').and.callFake(query => {
@@ -37,24 +53,14 @@ describe('InvoiceOut clientsToInvoice()', () => {
             }
         });
 
-        const tx = await models.InvoiceOut.beginTransaction({});
-        const options = {transaction: tx};
+        const addresses = await models.InvoiceOut.clientsToInvoice(
+            ctx, clientId, invoiceDate, maxShipped, companyFk, options);
 
-        try {
-            const addresses = await models.InvoiceOut.clientsToInvoice(
-                ctx, clientId, invoiceDate, maxShipped, companyFk, options);
-
-            expect(addresses.length).toBeGreaterThan(0);
-            expect(addresses[0].clientId).toBe(clientId);
-            expect(addresses[0].clientName).toBe('Test Client');
-            expect(addresses[0].id).toBe(1);
-            expect(addresses[0].nickname).toBe('Address 1');
-
-            await tx.rollback();
-        } catch (e) {
-            await tx.rollback();
-            throw e;
-        }
+        expect(addresses.length).toBeGreaterThan(0);
+        expect(addresses[0].clientId).toBe(clientId);
+        expect(addresses[0].clientName).toBe('Test Client');
+        expect(addresses[0].id).toBe(1);
+        expect(addresses[0].nickname).toBe('Address 1');
     });
 
     it('should handle errors and rollback transaction', async() => {
@@ -62,14 +68,20 @@ describe('InvoiceOut clientsToInvoice()', () => {
             return Promise.reject(new Error('Test Error'));
         });
 
-        const tx = await models.InvoiceOut.beginTransaction({});
-        const options = {transaction: tx};
-
         try {
             await models.InvoiceOut.clientsToInvoice(ctx, clientId, invoiceDate, maxShipped, companyFk, options);
         } catch (e) {
             expect(e.message).toBe('Test Error');
-            await tx.rollback();
         }
     });
+
+    it('should return all list', async() => {
+        const minShipped = Date.vnNew();
+        minShipped.setFullYear(maxShipped.getFullYear() - 1);
+
+        const toInvoice = await models.InvoiceOut.clientsToInvoice(
+            ctx, null, invoiceDate, maxShipped, companyFk, options);
+
+        expect(toInvoice).toBeDefined();
+    });
 });

From 6e56bdeeb1159473d8a6797eb82a2656e89f5e0f Mon Sep 17 00:00:00 2001
From: alexm <alexm@verdnatura.es>
Date: Mon, 13 Jan 2025 15:24:01 +0100
Subject: [PATCH 4/6] fix: refs #8389 prevent error propagation

---
 back/methods/chat/sendCheckingPresence.js | 1 -
 1 file changed, 1 deletion(-)

diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js
index 83e8da304d..955ed0240a 100644
--- a/back/methods/chat/sendCheckingPresence.js
+++ b/back/methods/chat/sendCheckingPresence.js
@@ -67,7 +67,6 @@ module.exports = Self => {
                 INSERT INTO util.debug (variable, value)
                     VALUES ('sendCheckingPresence_error', ?)
             `, [`User: ${userId}, recipient: ${recipientId}, message: ${message}, error: ${e}`]);
-            throw e;
         }
     };
 };

From 00577056ddd933b153bd63c8ee9cc8734d1e6f8e Mon Sep 17 00:00:00 2001
From: alexm <alexm@verdnatura.es>
Date: Mon, 13 Jan 2025 15:24:12 +0100
Subject: [PATCH 5/6] build: refs #8389 changelog

---
 CHANGELOG.md | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index c4eb7d29af..67ffe9f12a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,31 @@
+# Version 25.00 - 2025-01-14
+
+### Added 🆕
+
+- feat: refs #7235 add serialType parameter to getInvoiceDate and implement corresponding tests  by:jgallego
+- feat: refs #7301 update lastEntriesFilter to include landedDate and enhance test cases  (origin/7301-removeRedundantInventories) by:pablone
+- feat: refs #7880 error code and translations  by:ivanm
+- feat: refs #7924 add isCustomInspectionRequired field to item and update related logic  by:jgallego
+- feat: refs #8167 update canBeInvoiced method to include active status check and improve test cases  by:jgallego
+- feat: refs #8167 update locale and improve invoicing logic with error handling  by:jgallego
+- feat: refs #8246 added relation for the front's new field  by:Jon
+- feat: refs #8266 added itemFk and needed fixtures  by:jtubau
+- feat: refs #8324 country unique  by:Carlos Andrés
+
+### Changed 📦
+
+
+### Fixed 🛠️
+
+- feat: refs #8266 added itemFk and needed fixtures  by:jtubau
+- fix: add isCustomInspectionRequired column to item table for customs inspection indication  by:jgallego
+- fix: canBeInvoiced only in makeInvoice  by:alexm
+- fix: hotFix getMondayWeekYear  by:alexm
+- fix: refs #6598 update ACL property assignment  by:jorgep
+- fix: refs #6861 refs#6861 addPrevOK  by:sergiodt
+- fix: refs #7301 remove debug console log and update test cases in lastEntriesFilter  by:pablone
+- fix: refs #7301 update SQL fixtures and improve lastEntriesFilter logic  by:pablone
+
 # Version 24.52 - 2024-01-07
 
 ### Added 🆕

From 6aa898ee596b29347fba4e88f3bd712cd4be3e19 Mon Sep 17 00:00:00 2001
From: alexm <alexm@verdnatura.es>
Date: Tue, 14 Jan 2025 07:39:52 +0100
Subject: [PATCH 6/6] build: refs #8389 dump db

---
 db/dump/.dump/data.sql       | 31 ++++++++++++++++-----------
 db/dump/.dump/privileges.sql |  4 ++++
 db/dump/.dump/structure.sql  | 41 +++++++++++++++++++++++-------------
 db/dump/.dump/triggers.sql   |  2 +-
 4 files changed, 50 insertions(+), 28 deletions(-)

diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql
index a2df342180..b95890b0d7 100644
--- a/db/dump/.dump/data.sql
+++ b/db/dump/.dump/data.sql
@@ -4,7 +4,7 @@ USE `util`;
 /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
 /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
 
-INSERT INTO `version` VALUES ('vn-database','11385','72bf27f08d3ddf646ec0bb6594fc79cecd4b72f2','2025-01-07 07:46:33','11395');
+INSERT INTO `version` VALUES ('vn-database','11391','43edb1f82e88dcc44eedc8501b93c1fac66d71e9','2025-01-14 07:32:09','11407');
 
 INSERT INTO `versionLog` VALUES ('vn-database','10107','00-firstScript.sql','jenkins@10.0.2.69','2022-04-23 10:53:53',NULL,NULL);
 INSERT INTO `versionLog` VALUES ('vn-database','10112','00-firstScript.sql','jenkins@10.0.2.69','2022-05-09 09:14:53',NULL,NULL);
@@ -1078,6 +1078,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','11315','00-firstScript.sql','jen
 INSERT INTO `versionLog` VALUES ('vn-database','11316','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL);
 INSERT INTO `versionLog` VALUES ('vn-database','11317','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL);
 INSERT INTO `versionLog` VALUES ('vn-database','11319','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11320','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2025-01-14 07:32:07',NULL,NULL);
 INSERT INTO `versionLog` VALUES ('vn-database','11321','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL);
 INSERT INTO `versionLog` VALUES ('vn-database','11322','00-entryAcl.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL);
 INSERT INTO `versionLog` VALUES ('vn-database','11324','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-13 10:49:47',NULL,NULL);
@@ -1139,6 +1140,9 @@ INSERT INTO `versionLog` VALUES ('vn-database','11379','00-firstScript.sql','jen
 INSERT INTO `versionLog` VALUES ('vn-database','11379','01-secScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2025-01-07 07:46:32',NULL,NULL);
 INSERT INTO `versionLog` VALUES ('vn-database','11384','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2025-01-07 07:46:32',NULL,NULL);
 INSERT INTO `versionLog` VALUES ('vn-database','11385','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2025-01-07 07:46:33',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11390','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2025-01-14 07:32:08',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11391','00-itemAlter.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2025-01-14 07:32:08',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11400','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2025-01-09 09:55:24',NULL,NULL);
 
 /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
 /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
@@ -1515,6 +1519,7 @@ INSERT INTO `roleInherit` VALUES (378,101,15,19294);
 INSERT INTO `roleInherit` VALUES (379,103,121,19294);
 INSERT INTO `roleInherit` VALUES (381,119,123,19295);
 INSERT INTO `roleInherit` VALUES (382,48,72,783);
+INSERT INTO `roleInherit` VALUES (383,114,111,19295);
 
 INSERT INTO `userPassword` VALUES (1,7,1,0,2,1);
 
@@ -2311,9 +2316,9 @@ INSERT INTO `ACL` VALUES (938,'Worker','__get__mail','READ','ALLOW','ROLE','hr',
 INSERT INTO `ACL` VALUES (939,'Machine','*','*','ALLOW','ROLE','productionBoss',10578);
 INSERT INTO `ACL` VALUES (940,'ItemTypeLog','find','READ','ALLOW','ROLE','employee',10578);
 INSERT INTO `ACL` VALUES (941,'Entry','buyLabel','READ','ALLOW','ROLE','employee',10578);
-INSERT INTO `ACL` VALUES (942,'Cmr','filter','READ','ALLOW','ROLE','production',10578);
-INSERT INTO `ACL` VALUES (943,'Cmr','downloadZip','READ','ALLOW','ROLE','production',10578);
-INSERT INTO `ACL` VALUES (944,'Cmr','print','READ','ALLOW','ROLE','production',10578);
+INSERT INTO `ACL` VALUES (942,'Cmr','filter','READ','ALLOW','ROLE','employee',19295);
+INSERT INTO `ACL` VALUES (943,'Cmr','downloadZip','READ','ALLOW','ROLE','employee',19295);
+INSERT INTO `ACL` VALUES (944,'Cmr','print','READ','ALLOW','ROLE','employee',19295);
 INSERT INTO `ACL` VALUES (945,'Collection','create','WRITE','ALLOW','ROLE','productionBoss',10578);
 INSERT INTO `ACL` VALUES (946,'Collection','upsert','WRITE','ALLOW','ROLE','productionBoss',10578);
 INSERT INTO `ACL` VALUES (947,'Collection','replaceById','WRITE','ALLOW','ROLE','productionBoss',10578);
@@ -2327,7 +2332,6 @@ INSERT INTO `ACL` VALUES (954,'RouteComplement','find','READ','ALLOW','ROLE','de
 INSERT INTO `ACL` VALUES (955,'RouteComplement','create','WRITE','ALLOW','ROLE','delivery',10578);
 INSERT INTO `ACL` VALUES (956,'RouteComplement','deleteById','WRITE','ALLOW','ROLE','delivery',10578);
 INSERT INTO `ACL` VALUES (957,'SaleGroup','find','READ','ALLOW','ROLE','production',10578);
-INSERT INTO `ACL` VALUES (958,'Worker','canCreateAbsenceInPast','WRITE','ALLOW','ROLE','hr',10578);
 INSERT INTO `ACL` VALUES (959,'WorkerRelative','updateAttributes','*','ALLOW','ROLE','hr',10578);
 INSERT INTO `ACL` VALUES (960,'WorkerRelative','crud','WRITE','ALLOW','ROLE','hr',10578);
 INSERT INTO `ACL` VALUES (961,'WorkerRelative','findById','*','ALLOW','ROLE','hr',10578);
@@ -2383,6 +2387,8 @@ INSERT INTO `ACL` VALUES (1010,'InventoryConfig','find','READ','ALLOW','ROLE','b
 INSERT INTO `ACL` VALUES (1011,'SiiTypeInvoiceIn','find','READ','ALLOW','ROLE','salesPerson',10578);
 INSERT INTO `ACL` VALUES (1012,'OsrmConfig','optimize','READ','ALLOW','ROLE','employee',10578);
 INSERT INTO `ACL` VALUES (1013,'Route','optimizePriority','*','ALLOW','ROLE','employee',10578);
+INSERT INTO `ACL` VALUES (1014,'Worker','canModifyAbsenceInPast','WRITE','ALLOW','ROLE','hr',10578);
+INSERT INTO `ACL` VALUES (1015,'Worker','__get__sip','READ','ALLOW','ROLE','employee',19294);
 
 INSERT INTO `fieldAcl` VALUES (1,'Client','name','update','employee');
 INSERT INTO `fieldAcl` VALUES (2,'Client','contact','update','employee');
@@ -2725,7 +2731,7 @@ INSERT INTO `department` VALUES (124,NULL,'CONTROL INTERNO',122,123,NULL,72,0,0,
 INSERT INTO `department` VALUES (125,'spainTeam3','EQUIPO ESPAÑA 3',59,60,1118,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
 INSERT INTO `department` VALUES (126,NULL,'PRESERVADO',29,30,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,NULL,NULL,NULL,NULL);
 INSERT INTO `department` VALUES (128,NULL,'PALETIZADO',31,32,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'PALLETIZING');
-INSERT INTO `department` VALUES (130,NULL,'REVISION',33,34,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,'ON_CHECKING');
+INSERT INTO `department` VALUES (130,'reviewers','REVISION',33,34,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,'ON_CHECKING');
 INSERT INTO `department` VALUES (131,'greenhouse','INVERNADERO',105,106,NULL,0,0,0,2,0,58,'/1/58/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL);
 INSERT INTO `department` VALUES (132,NULL,'EQUIPO DC',61,62,1731,0,0,0,2,0,43,'/1/43/','dc_equipo',1,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
 INSERT INTO `department` VALUES (133,'franceTeamManagement','EQUIPO GESTIÓN FRANCIA',63,64,9751,72,0,0,2,0,43,'/1/43/','fr_equipo',1,'gestionfrancia@verdnatura.es',0,0,0,0,NULL,NULL,'3300',NULL);
@@ -2740,12 +2746,12 @@ INSERT INTO `department` VALUES (146,NULL,'VERDNACOLOMBIA',3,4,NULL,72,0,0,2,0,2
 INSERT INTO `department` VALUES (147,'spainTeamAsia','EQUIPO ESPAÑA ASIA',71,72,40214,0,0,0,2,0,43,'/1/43/','esA_equipo',1,'esA@verdnatura.es',0,0,0,0,NULL,NULL,'5500',NULL);
 INSERT INTO `department` VALUES (148,'franceTeamCatchment','EQUIPO CAPTACIÓN FRANCIA',73,74,25178,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,'6000',NULL);
 INSERT INTO `department` VALUES (149,'spainTeamCatchment','EQUIPO ESPAÑA CAPTACIÓN',75,76,1203,0,0,0,2,0,43,'/1/43/','es_captacion_equipo',1,'es_captacion@verdnatura.es',0,0,0,0,NULL,NULL,'5700',NULL);
-INSERT INTO `department` VALUES (150,'spainTeamLevanteIslands','EQUIPO ESPAÑA LEVANTE',77,78,1118,0,0,0,2,0,43,'/1/43/','es_levante_equipo',1,'levanteislas.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5000',NULL);
-INSERT INTO `department` VALUES (151,'spainTeamNorthwest','EQUIPO ESPAÑA NOROESTE',79,80,7102,0,0,0,2,0,43,'/1/43/','es_noroeste_equipo',1,'noroeste.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5300',NULL);
-INSERT INTO `department` VALUES (152,'spainTeamNortheast','EQUIPO ESPAÑA NORESTE',81,82,1118,0,0,0,2,0,43,'/1/43/','es_noreste_equipo',1,'noreste.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5200',NULL);
-INSERT INTO `department` VALUES (153,'spainTeamSouth','EQUIPO ESPAÑA SUR',83,84,36578,0,0,0,2,0,43,'/1/43/','es_sur_equipo',1,'sur.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5400',NULL);
-INSERT INTO `department` VALUES (154,'spainTeamCenter','EQUIPO ESPAÑA CENTRO',85,86,4661,0,0,0,2,0,43,'/1/43/','es_centro_equipo',1,'centro.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5100',NULL);
-INSERT INTO `department` VALUES (155,'spainTeamVip','EQUIPO ESPAÑA VIP',87,88,5432,0,0,0,2,0,43,'/1/43/','es_vip_equipo',1,'vip.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5600',NULL);
+INSERT INTO `department` VALUES (150,'spainTeamLevanteIslands','EQUIPO ESPAÑA LEVANTE',77,78,1118,0,0,0,2,0,43,'/1/43/','es_levante_equipo',1,'es_levante@verdnatura.es',0,0,0,0,NULL,NULL,'5000',NULL);
+INSERT INTO `department` VALUES (151,'spainTeamNorthwest','EQUIPO ESPAÑA NOROESTE',79,80,7102,0,0,0,2,0,43,'/1/43/','es_noroeste_equipo',1,'es_noroeste@verdnatura.es',0,0,0,0,NULL,NULL,'5300',NULL);
+INSERT INTO `department` VALUES (152,'spainTeamNortheast','EQUIPO ESPAÑA NORESTE',81,82,1118,0,0,0,2,0,43,'/1/43/','es_noreste_equipo',1,'es_noreste@verdnatura.es',0,0,0,0,NULL,NULL,'5200',NULL);
+INSERT INTO `department` VALUES (153,'spainTeamSouth','EQUIPO ESPAÑA SUR',83,84,36578,0,0,0,2,0,43,'/1/43/','es_sur_equipo',1,'es_sur@verdnatura.es',0,0,0,0,NULL,NULL,'5400',NULL);
+INSERT INTO `department` VALUES (154,'spainTeamCenter','EQUIPO ESPAÑA CENTRO',85,86,4661,0,0,0,2,0,43,'/1/43/','es_centro_equipo',1,'es_centro@verdnatura.es',0,0,0,0,NULL,NULL,'5100',NULL);
+INSERT INTO `department` VALUES (155,'spainTeamVip','EQUIPO ESPAÑA VIP',87,88,5432,0,0,0,2,0,43,'/1/43/','es_vip_equipo',1,'es_vip@verdnatura.es',0,0,0,0,NULL,NULL,'5600',NULL);
 
 INSERT INTO `docuware` VALUES (1,'deliveryNote','Albaranes cliente','find','find','N__ALBAR_N',NULL);
 INSERT INTO `docuware` VALUES (2,'deliveryNote','Albaranes cliente','store','Archivar','N__ALBAR_N',NULL);
@@ -3046,6 +3052,7 @@ INSERT INTO `message` VALUES (20,'clientNotVerified','Incomplete tax data, pleas
 INSERT INTO `message` VALUES (21,'quantityLessThanMin','The quantity cannot be less than the minimum');
 INSERT INTO `message` VALUES (22,'ORDER_ROW_UNAVAILABLE','The ordered quantity exceeds the available');
 INSERT INTO `message` VALUES (23,'AMOUNT_NOT_MATCH_GROUPING','The quantity ordered does not match the grouping');
+INSERT INTO `message` VALUES (24,'orderLinesWithZero','There are empty lines. Please delete them');
 
 INSERT INTO `metatag` VALUES (2,'title','Verdnatura Levante SL, mayorista de flores, plantas y complementos para floristería y decoración');
 INSERT INTO `metatag` VALUES (3,'description','Verdnatura Levante SL, mayorista de flores, plantas y complementos para floristería y decoración. Envío a toda España, pedidos por internet o por teléfono.');
diff --git a/db/dump/.dump/privileges.sql b/db/dump/.dump/privileges.sql
index 460256b564..598bfdf75f 100644
--- a/db/dump/.dump/privileges.sql
+++ b/db/dump/.dump/privileges.sql
@@ -1494,6 +1494,10 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','travelThermograph','
 INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','thermograph','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
 INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerSalesAssistant','Tickets','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update','');
 INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','sim','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','zoneGeo','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','itemCampaign','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemCampaign','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','campaign','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
 /*!40000 ALTER TABLE `tables_priv` ENABLE KEYS */;
 
 /*!40000 ALTER TABLE `columns_priv` DISABLE KEYS */;
diff --git a/db/dump/.dump/structure.sql b/db/dump/.dump/structure.sql
index e52ed2a510..58f1e7591d 100644
--- a/db/dump/.dump/structure.sql
+++ b/db/dump/.dump/structure.sql
@@ -6249,19 +6249,27 @@ BEGIN
  * @param vDateFrom Fecha desde
  * @param vDateTo Fecha hasta
  */
-	IF vDateFrom IS NULL THEN
-		SET vDateFrom = util.VN_CURDATE() - INTERVAL WEEKDAY(util.VN_CURDATE()) DAY;
+	DECLARE vDaysInYear INT;
+	SET vDaysInYear = DATEDIFF(util.lastDayOfYear(CURDATE()), util.firstDayOfYear(CURDATE()));
+
+	SET vDateFrom = COALESCE(vDateFrom, util.VN_CURDATE());
+	SET vDateTo = COALESCE(vDateTo, util.VN_CURDATE());
+
+	IF DATEDIFF(vDateTo, vDateFrom) > vDaysInYear THEN
+		CALL util.throw('The period cannot be longer than one year');
 	END IF;
 
-	IF vDateTo IS NULL THEN
-		SET vDateTo = vDateFrom + INTERVAL 6 DAY;
-	END IF;
+	-- Obtiene el primer día de la semana de esa fecha
+	SET vDateFrom = DATE_SUB(vDateFrom, INTERVAL ((WEEKDAY(vDateFrom) + 1) % 7) DAY);
+
+	-- Obtiene el último día de la semana de esa fecha
+	SET vDateTo = DATE_ADD(vDateTo, INTERVAL (6 - ((WEEKDAY(vDateTo) + 1) % 7)) DAY);
 
 	CALL cache.last_buy_refresh(FALSE);
 
 	REPLACE bs.waste
-		SELECT YEAR(t.shipped),
-				WEEK(t.shipped, 4),
+		SELECT YEARWEEK(t.shipped, 6) DIV 100,
+				WEEK(t.shipped, 6),
 				it.workerFk,
 				it.id,
 				s.itemFk,
@@ -6307,9 +6315,9 @@ BEGIN
 				JOIN cache.last_buy lb ON lb.item_id = i.id
 					AND lb.warehouse_id = w.id
 				JOIN vn.buy b ON b.id = lb.buy_id
-			WHERE t.shipped BETWEEN vDateFrom AND vDateTo
+			WHERE t.shipped BETWEEN vDateFrom AND util.dayEnd(vDateTo)
 				AND w.isManaged
-			GROUP BY YEAR(t.shipped), WEEK(t.shipped, 4), i.id;
+			GROUP BY YEARWEEK(t.shipped, 6) DIV 100, WEEK(t.shipped, 6), i.id;
 END ;;
 DELIMITER ;
 /*!50003 SET sql_mode              = @saved_sql_mode */ ;
@@ -13807,7 +13815,7 @@ BEGIN
 	) INTO vHas0Amount;
 
 	IF vHas0Amount THEN
-		CALL util.throw('Hay líneas vacías. Por favor, elimínelas');
+		CALL util.throw('orderLinesWithZero');
 	END IF;
 
 	START TRANSACTION;
@@ -28922,6 +28930,7 @@ CREATE TABLE `country` (
   `isSocialNameUnique` tinyint(1) NOT NULL DEFAULT 1,
   PRIMARY KEY (`id`),
   UNIQUE KEY `country_unique` (`code`),
+  UNIQUE KEY `country_unique_name` (`name`),
   KEY `currency_id_fk_idx` (`currencyFk`),
   KEY `country_Ix4` (`name`),
   KEY `continent_id_fk_idx` (`continentFk`),
@@ -31971,6 +31980,7 @@ CREATE TABLE `item` (
   `value12` varchar(50) DEFAULT NULL,
   `tag13` varchar(20) DEFAULT NULL,
   `value13` varchar(50) DEFAULT NULL,
+  `isCustomInspectionRequired` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Indicates if the item requires physical inspection at customs',
   PRIMARY KEY (`id`),
   UNIQUE KEY `item_supplyResponseFk_idx` (`supplyResponseFk`),
   KEY `Color` (`inkFk`),
@@ -68661,10 +68671,11 @@ BEGIN
 				TRUE,
 				sc.userFk,
 				s.id
-			FROM vn.sectorCollection sc
-				JOIN vn.sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id
-				JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk
-				JOIN vn.state s ON s.code = 'OK PREVIOUS'
+			FROM sectorCollection sc
+				JOIN sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id
+				JOIN saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk
+				JOIN state s ON s.code = 'OK PREVIOUS'
+				JOIN itemShelvingSale iss ON iss.saleFk = sgd.saleFk
 			WHERE sc.id = vSectorCollectionFk;
 END ;;
 DELIMITER ;
@@ -90882,4 +90893,4 @@ USE `vn2008`;
 /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
 /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
 
--- Dump completed on 2025-01-07  6:51:38
+-- Dump completed on 2025-01-14  6:39:04
diff --git a/db/dump/.dump/triggers.sql b/db/dump/.dump/triggers.sql
index 039dbb2a86..fb72e98995 100644
--- a/db/dump/.dump/triggers.sql
+++ b/db/dump/.dump/triggers.sql
@@ -11499,4 +11499,4 @@ USE `vn2008`;
 /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
 /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
 
--- Dump completed on 2025-01-07  6:51:57
+-- Dump completed on 2025-01-14  6:39:25