Compare commits

..

No commits in common. "dev" and "Fix-priceDifferenceError" have entirely different histories.

66 changed files with 970 additions and 1336 deletions

View File

@ -1,49 +1,3 @@
# Version 25.04 - 2025-01-28
### Added 🆕
- feat: refs #7202 added new field by:Jon
- feat: refs #7343 delete sending to user by:ivanm
- feat: refs #7569 refs#7569 sendEmailNotification by:sergiodt
- feat: refs #7569 refs#7569 sendMail by:sergiodt
- feat: refs #7584 changes request by:robert
- feat: refs #7584 workerTimeControl_afterDelete by:robert
- feat: refs #7832 implement refund ticket restrictions and add unit tests for ticket service updates by:jgallego
- feat: refs #7882 Added coords to create a address by:guillermo
- feat: refs #8073 change names and primary key by:ivanm
- feat: refs #8073 new comment message by:ivanm
- feat: refs #8073 #refs 8073 create vn.productionCountryVolume by:ivanm
- feat: refs #8117 add worker first and last name to item type query by:jtubau
- feat: refs #8247 added new acl for VnUser model by:Jon
- feat: refs #8258 added uppercase validation on supplier create (origin/8258-uppercaseInputs) by:provira
- feat: refs #8298 add priceOptimum and packagesDiscountFactor to zone and client tables by:jgallego
- feat: refs #8298 add priceOptimum column to zoneEvent and update zone fixture data by:jgallego
- feat: refs #8298 update price calculation logic and add packagesDiscountFactor column to client table by:jgallego
- feat: refs #8357 Agregados triggers para manejar exclusiones de trabajadores en la tabla workerMana by:guillermo
- feat: refs #8361 add hasToDownloadRate field to currency model and update exchange rate logic by:jgallego
- feat: refs #8381 add initial and final temperature fields to entry model and queries by:jgallego
### Changed 📦
- refactor: order by id by:alexm
- refactor: refs #7202 modified new invoice procedure and incoterms sql by:Jon
- refactor: refs #7202 modified procedure to include customsAgent field when creating an invoice by:Jon
- refactor: refs #8378 deprecate bi.f_tvc by:ivanm
### Fixed 🛠️
- feat: refs #8298 add priceOptimum column to zoneEvent and update zone fixture data by:jgallego
- fix: prevent slow update (HEAD -> 8452-testToMaster, origin/test, origin/8452-testToMaster, test) by:alexm
- fix: refs #7202 fixed back test by:Jon
- fix: refs #7202 fixed sql by:Jon
- fix: refs #7569 refs·6861 ticketOrderReserve by:sergiodt
- fix: refs #7569 refs·6861 ticketOrderReserve (origin/7569-sendEmailOrderTicket) by:sergiodt
- fix: refs #7569 refs#8188 add IfNotExists by:sergiodt
- fix: refs #7832 update ticketService model test suite to correct describe block by:jgallego
- fix: refs #8298 remove duplicate entry in English locale file by:jgallego
- fix: refs #8361 streamline transaction handling in exchangeRateUpdate by:jgallego
- test: refs #8448 fix e2e by:alexm
# Version 25.00 - 2025-01-14 # Version 25.00 - 2025-01-14
### Added 🆕 ### Added 🆕

View File

@ -65,8 +65,7 @@ module.exports = Self => {
iss.id itemShelvingSaleFk, iss.id itemShelvingSaleFk,
iss.isPicked, iss.isPicked,
iss.itemShelvingFk, iss.itemShelvingFk,
st.code stateCode, st.code stateCode
ac.username
FROM ticketCollection tc FROM ticketCollection tc
LEFT JOIN collection c ON c.id = tc.collectionFk LEFT JOIN collection c ON c.id = tc.collectionFk
JOIN sale s ON s.ticketFk = tc.ticketFk JOIN sale s ON s.ticketFk = tc.ticketFk
@ -81,7 +80,6 @@ module.exports = Self => {
LEFT JOIN itemColor ic ON ic.itemFk = s.itemFk LEFT JOIN itemColor ic ON ic.itemFk = s.itemFk
LEFT JOIN origin o ON o.id = i.originFk LEFT JOIN origin o ON o.id = i.originFk
LEFT JOIN state st ON st.id = sg.stateFk LEFT JOIN state st ON st.id = sg.stateFk
LEFT JOIN account.user ac ON ac.id = iss.userFk
WHERE tc.collectionFk = ? WHERE tc.collectionFk = ?
GROUP BY s.id, ish.id, p.code, p2.code GROUP BY s.id, ish.id, p.code, p2.code
UNION ALL UNION ALL
@ -111,8 +109,7 @@ module.exports = Self => {
iss.id itemShelvingSaleFk, iss.id itemShelvingSaleFk,
iss.isPicked, iss.isPicked,
iss.itemShelvingFk, iss.itemShelvingFk,
st.code stateCode, st.code stateCode
ac.username
FROM sectorCollection sc FROM sectorCollection sc
JOIN sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id JOIN sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id
JOIN saleGroup sg ON sg.id = ss.saleGroupFk JOIN saleGroup sg ON sg.id = ss.saleGroupFk
@ -127,7 +124,6 @@ module.exports = Self => {
LEFT JOIN itemColor ic ON ic.itemFk = s.itemFk LEFT JOIN itemColor ic ON ic.itemFk = s.itemFk
LEFT JOIN origin o ON o.id = i.originFk LEFT JOIN origin o ON o.id = i.originFk
LEFT JOIN state st ON st.id = sg.stateFk LEFT JOIN state st ON st.id = sg.stateFk
LEFT JOIN account.user ac ON ac.id = sg.userFk
WHERE sc.id = ? WHERE sc.id = ?
AND sgd.saleGroupFk AND sgd.saleGroupFk
GROUP BY s.id, ish.id, p.code, p2.code`, [id, id], myOptions); GROUP BY s.id, ish.id, p.code, p2.code`, [id, id], myOptions);

View File

@ -52,7 +52,7 @@
}, },
"payMethod": { "payMethod": {
"type": "belongsTo", "type": "belongsTo",
"model": "PayMethod", "model": "PayMethodFk",
"foreignKey": "payMethodFk" "foreignKey": "payMethodFk"
}, },
"company": { "company": {

View File

@ -4,7 +4,7 @@ USE `util`;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
INSERT INTO `version` VALUES ('vn-database','11410','7a02af9a3acae14a658de1557baa44542c24d480','2025-01-28 07:44:02','11423'); 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','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); INSERT INTO `versionLog` VALUES ('vn-database','10112','00-firstScript.sql','jenkins@10.0.2.69','2022-05-09 09:14:53',NULL,NULL);
@ -1041,7 +1041,6 @@ INSERT INTO `versionLog` VALUES ('vn-database','11261','00-firstScript.sql','jen
INSERT INTO `versionLog` VALUES ('vn-database','11262','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:43',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11262','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:43',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11263','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-27 12:05:32',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11263','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-27 12:05:32',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11264','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:15',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11264','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:15',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11269','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2025-01-28 07:43:58',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11271','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:15',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11271','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:15',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11272','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:15',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11272','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:15',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11273','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 10:50:51',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11273','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 10:50:51',NULL,NULL);
@ -1141,24 +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','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','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','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','11387','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2025-01-28 07:43:58',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','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','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','11396','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2025-01-28 07:43:58',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11398','00-zoneEventPriceOptimum.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2025-01-28 07:43:59',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11398','00-zonePriceOptimum.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2025-01-28 07:43:59',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11398','01-zoneUpdate.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2025-01-28 07:43:59',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11398','02-clientAlter.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2025-01-28 07:43:59',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11398','03-clientConfig.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2025-01-28 07:43:59',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); 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);
INSERT INTO `versionLog` VALUES ('vn-database','11405','00-entryAlter.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2025-01-28 07:44:00',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11406','00-currrencyAlter.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2025-01-28 07:44:00',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11406','01-currrencyUpdate.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2025-01-28 07:44:00',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11407','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2025-01-28 07:44:00',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11410','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2025-01-28 07:44:00',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11415','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2025-01-20 08:12:38',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11418','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2025-01-21 11:03:27',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11423','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2025-01-23 15:19:32',NULL,NULL);
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
@ -1257,7 +1241,6 @@ INSERT INTO `role` VALUES (127,'timeControl','Tablet para fichar',1,'2024-01-09
INSERT INTO `role` VALUES (129,'buyerAssistant','Comprador que tienes mas permisos para ayudar al buyerBoss en algunas tareas',1,'2024-02-06 06:59:12','2024-02-06 06:59:12',783); INSERT INTO `role` VALUES (129,'buyerAssistant','Comprador que tienes mas permisos para ayudar al buyerBoss en algunas tareas',1,'2024-02-06 06:59:12','2024-02-06 06:59:12',783);
INSERT INTO `role` VALUES (130,'reviewer','Revisor de producción',1,'2024-06-11 00:00:00','2024-06-11 00:00:00',10578); INSERT INTO `role` VALUES (130,'reviewer','Revisor de producción',1,'2024-06-11 00:00:00','2024-06-11 00:00:00',10578);
INSERT INTO `role` VALUES (131,'supplier','Privilegios básicos de un proveedor',1,'2024-07-05 10:18:58','2024-07-05 10:18:58',19295); INSERT INTO `role` VALUES (131,'supplier','Privilegios básicos de un proveedor',1,'2024-07-05 10:18:58','2024-07-05 10:18:58',19295);
INSERT INTO `role` VALUES (132,'salesPersonClaim','Departamento de ventas con funciones de reclamaciones',1,'2025-01-17 07:07:40','2025-01-17 07:07:40',19295);
INSERT INTO `roleInherit` VALUES (1,1,2,NULL); INSERT INTO `roleInherit` VALUES (1,1,2,NULL);
INSERT INTO `roleInherit` VALUES (2,1,3,NULL); INSERT INTO `roleInherit` VALUES (2,1,3,NULL);
@ -1269,6 +1252,7 @@ INSERT INTO `roleInherit` VALUES (8,5,33,NULL);
INSERT INTO `roleInherit` VALUES (10,11,6,NULL); INSERT INTO `roleInherit` VALUES (10,11,6,NULL);
INSERT INTO `roleInherit` VALUES (11,13,1,NULL); INSERT INTO `roleInherit` VALUES (11,13,1,NULL);
INSERT INTO `roleInherit` VALUES (12,15,35,NULL); INSERT INTO `roleInherit` VALUES (12,15,35,NULL);
INSERT INTO `roleInherit` VALUES (16,17,20,NULL);
INSERT INTO `roleInherit` VALUES (17,17,37,NULL); INSERT INTO `roleInherit` VALUES (17,17,37,NULL);
INSERT INTO `roleInherit` VALUES (18,17,39,NULL); INSERT INTO `roleInherit` VALUES (18,17,39,NULL);
INSERT INTO `roleInherit` VALUES (19,17,64,NULL); INSERT INTO `roleInherit` VALUES (19,17,64,NULL);
@ -1343,6 +1327,7 @@ INSERT INTO `roleInherit` VALUES (105,72,18,NULL);
INSERT INTO `roleInherit` VALUES (106,73,5,NULL); INSERT INTO `roleInherit` VALUES (106,73,5,NULL);
INSERT INTO `roleInherit` VALUES (107,73,64,NULL); INSERT INTO `roleInherit` VALUES (107,73,64,NULL);
INSERT INTO `roleInherit` VALUES (108,73,19,NULL); INSERT INTO `roleInherit` VALUES (108,73,19,NULL);
INSERT INTO `roleInherit` VALUES (109,59,50,NULL);
INSERT INTO `roleInherit` VALUES (115,39,76,NULL); INSERT INTO `roleInherit` VALUES (115,39,76,NULL);
INSERT INTO `roleInherit` VALUES (117,65,76,NULL); INSERT INTO `roleInherit` VALUES (117,65,76,NULL);
INSERT INTO `roleInherit` VALUES (118,30,76,NULL); INSERT INTO `roleInherit` VALUES (118,30,76,NULL);
@ -1535,9 +1520,6 @@ INSERT INTO `roleInherit` VALUES (379,103,121,19294);
INSERT INTO `roleInherit` VALUES (381,119,123,19295); INSERT INTO `roleInherit` VALUES (381,119,123,19295);
INSERT INTO `roleInherit` VALUES (382,48,72,783); INSERT INTO `roleInherit` VALUES (382,48,72,783);
INSERT INTO `roleInherit` VALUES (383,114,111,19295); INSERT INTO `roleInherit` VALUES (383,114,111,19295);
INSERT INTO `roleInherit` VALUES (384,132,18,19295);
INSERT INTO `roleInherit` VALUES (385,132,72,19295);
INSERT INTO `roleInherit` VALUES (386,109,132,19295);
INSERT INTO `userPassword` VALUES (1,7,1,0,2,1); INSERT INTO `userPassword` VALUES (1,7,1,0,2,1);
@ -2407,7 +2389,6 @@ INSERT INTO `ACL` VALUES (1012,'OsrmConfig','optimize','READ','ALLOW','ROLE','em
INSERT INTO `ACL` VALUES (1013,'Route','optimizePriority','*','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 (1014,'Worker','canModifyAbsenceInPast','WRITE','ALLOW','ROLE','hr',10578);
INSERT INTO `ACL` VALUES (1015,'Worker','__get__sip','READ','ALLOW','ROLE','employee',19294); INSERT INTO `ACL` VALUES (1015,'Worker','__get__sip','READ','ALLOW','ROLE','employee',19294);
INSERT INTO `ACL` VALUES (1016,'VnUser','adminUser','WRITE','ALLOW','ROLE','sysadmin',10578);
INSERT INTO `fieldAcl` VALUES (1,'Client','name','update','employee'); INSERT INTO `fieldAcl` VALUES (1,'Client','name','update','employee');
INSERT INTO `fieldAcl` VALUES (2,'Client','contact','update','employee'); INSERT INTO `fieldAcl` VALUES (2,'Client','contact','update','employee');
@ -2706,72 +2687,71 @@ INSERT INTO `continent` VALUES (3,'África','AF');
INSERT INTO `continent` VALUES (4,'Europa','EU'); INSERT INTO `continent` VALUES (4,'Europa','EU');
INSERT INTO `continent` VALUES (5,'Oceanía','OC'); INSERT INTO `continent` VALUES (5,'Oceanía','OC');
INSERT INTO `department` VALUES (1,'VN','VERDNATURA',1,132,763,0,0,0,0,26,NULL,'/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (1,'VN','VERDNATURA',1,130,763,0,0,0,0,26,NULL,'/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (22,'shopping','COMPRAS',2,5,NULL,72,0,0,1,1,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (22,'shopping','COMPRAS',2,5,NULL,72,0,0,1,1,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (23,'CMA','CAMARA',15,16,NULL,72,1,1,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,1,NULL,NULL,NULL,'PREVIOUS'); INSERT INTO `department` VALUES (23,'CMA','CAMARA',15,16,NULL,72,1,1,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,1,NULL,NULL,NULL,'PREVIOUS');
INSERT INTO `department` VALUES (31,'it','INFORMATICA',6,7,NULL,72,0,0,1,0,1,'/1/','informatica-cau',1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (31,'it','INFORMATICA',6,7,NULL,72,0,0,1,0,1,'/1/','informatica-cau',1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (34,'accounting','CONTABILIDAD',8,9,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (34,'accounting','CONTABILIDAD',8,9,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (35,'finance','FINANZAS',10,11,NULL,0,0,0,1,0,1,'/1/',NULL,1,'begonya@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (35,'finance','FINANZAS',10,11,NULL,0,0,0,1,0,1,'/1/',NULL,1,'begonya@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (36,'labor','LABORAL',12,13,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (36,'labor','LABORAL',12,13,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (37,'PROD','PRODUCCION',14,39,NULL,72,1,1,1,12,1,'/1/',NULL,0,NULL,0,1,1,1,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (37,'PROD','PRODUCCION',14,37,NULL,72,1,1,1,11,1,'/1/',NULL,0,NULL,0,1,1,1,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (38,'picking','SACADO',17,18,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,0,1,NULL,NULL,NULL,'ON_PREPARATION'); INSERT INTO `department` VALUES (38,'picking','SACADO',17,18,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,0,1,NULL,NULL,NULL,'ON_PREPARATION');
INSERT INTO `department` VALUES (39,'packing','ENCAJADO',19,20,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,'PACKING'); INSERT INTO `department` VALUES (39,'packing','ENCAJADO',19,20,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,'PACKING');
INSERT INTO `department` VALUES (41,'administration','ADMINISTRACION',40,41,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (41,'administration','ADMINISTRACION',38,39,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (43,'VT','VENTAS',42,91,NULL,0,0,0,1,24,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (43,'VT','VENTAS',40,89,NULL,0,0,0,1,24,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (44,'management','GERENCIA',92,93,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (44,'management','GERENCIA',90,91,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (45,'logistic','LOGISTICA',94,95,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (45,'logistic','LOGISTICA',92,93,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (46,'delivery','REPARTO',96,97,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,'DELIVERY'); INSERT INTO `department` VALUES (46,'delivery','REPARTO',94,95,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,'DELIVERY');
INSERT INTO `department` VALUES (48,'storage','ALMACENAJE',98,99,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'STORAGE'); INSERT INTO `department` VALUES (48,'storage','ALMACENAJE',96,97,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'STORAGE');
INSERT INTO `department` VALUES (49,NULL,'PROPIEDAD',100,101,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (49,NULL,'PROPIEDAD',98,99,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (52,NULL,'CARGA AEREA',102,103,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (52,NULL,'CARGA AEREA',100,101,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (53,'marketing','MARKETING Y COMUNICACIÓN',43,44,NULL,72,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (53,'marketing','MARKETING Y COMUNICACIÓN',41,42,NULL,72,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (54,NULL,'ORNAMENTALES',104,105,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (54,NULL,'ORNAMENTALES',102,103,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (55,NULL,'TALLER NATURAL',21,22,14548,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1118,NULL,NULL,NULL); INSERT INTO `department` VALUES (55,NULL,'TALLER NATURAL',21,22,14548,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1118,NULL,NULL,NULL);
INSERT INTO `department` VALUES (56,NULL,'TALLER ARTIFICIAL',23,24,8470,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1927,NULL,NULL,NULL); INSERT INTO `department` VALUES (56,NULL,'TALLER ARTIFICIAL',23,24,8470,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1927,NULL,NULL,NULL);
INSERT INTO `department` VALUES (58,'CMP','CAMPOS',106,109,NULL,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'FIELD'); INSERT INTO `department` VALUES (58,'CMP','CAMPOS',104,107,NULL,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'FIELD');
INSERT INTO `department` VALUES (59,'maintenance','MANTENIMIENTO',110,111,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (59,'maintenance','MANTENIMIENTO',108,109,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (60,'claims','RECLAMACIONES',45,46,NULL,72,0,0,2,0,43,'/1/43/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,'CLAIM'); INSERT INTO `department` VALUES (60,'claims','RECLAMACIONES',43,44,NULL,72,0,0,2,0,43,'/1/43/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,'CLAIM');
INSERT INTO `department` VALUES (61,NULL,'VNH',112,115,NULL,73,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (61,NULL,'VNH',110,113,NULL,73,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (66,NULL,'VERDNAMADRID',116,117,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (66,NULL,'VERDNAMADRID',114,115,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (68,NULL,'COMPLEMENTOS',25,26,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (68,NULL,'COMPLEMENTOS',25,26,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (69,NULL,'VERDNABARNA',118,119,NULL,74,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (69,NULL,'VERDNABARNA',116,117,NULL,74,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (80,'spainTeam5','EQUIPO ESPAÑA 5',47,48,4250,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (80,'spainTeam5','EQUIPO ESPAÑA 5',45,46,4250,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (86,NULL,'LIMPIEZA',120,121,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (86,NULL,'LIMPIEZA',118,119,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (89,NULL,'COORDINACION',122,123,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (89,NULL,'COORDINACION',120,121,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (90,NULL,'TRAILER',113,114,NULL,0,0,0,2,0,61,'/1/61/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (90,NULL,'TRAILER',111,112,NULL,0,0,0,2,0,61,'/1/61/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (91,'artificial','ARTIFICIAL',27,28,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'PREVIOUS'); INSERT INTO `department` VALUES (91,'artificial','ARTIFICIAL',27,28,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'PREVIOUS');
INSERT INTO `department` VALUES (92,NULL,'EQUIPO SILVERIO',49,50,1203,0,0,0,2,0,43,'/1/43/','sdc_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (92,NULL,'EQUIPO SILVERIO',47,48,1203,0,0,0,2,0,43,'/1/43/','sdc_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (94,'spainTeam2','EQUIPO ESPAÑA 2',51,52,3797,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (94,'spainTeam2','EQUIPO ESPAÑA 2',49,50,3797,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (95,'spainTeam1','EQUIPO ESPAÑA 1',53,54,24065,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (95,'spainTeam1','EQUIPO ESPAÑA 1',51,52,24065,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (96,NULL,'EQUIPO C LOPEZ',55,56,4661,0,0,0,2,0,43,'/1/43/','cla_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (96,NULL,'EQUIPO C LOPEZ',53,54,4661,0,0,0,2,0,43,'/1/43/','cla_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (115,NULL,'EQUIPO CLAUDI',57,58,3810,0,0,0,2,0,43,'/1/43/','csr_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (115,NULL,'EQUIPO CLAUDI',55,56,3810,0,0,0,2,0,43,'/1/43/','csr_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (123,NULL,'EQUIPO ELENA BASCUÑANA',59,60,7102,0,0,0,2,0,43,'/1/43/','ebt_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (123,NULL,'EQUIPO ELENA BASCUÑANA',57,58,7102,0,0,0,2,0,43,'/1/43/','ebt_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (124,NULL,'CONTROL INTERNO',124,125,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (124,NULL,'CONTROL INTERNO',122,123,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (125,'spainTeam3','EQUIPO ESPAÑA 3',61,62,1118,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); 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 (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 (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,'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 (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',107,108,NULL,0,0,0,2,0,58,'/1/58/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); 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',63,64,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 (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',65,66,9751,72,0,0,2,0,43,'/1/43/','fr_equipo',1,'gestionfrancia@verdnatura.es',0,0,0,0,NULL,NULL,'3300',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);
INSERT INTO `department` VALUES (134,'portugalTeam','EQUIPO PORTUGAL',67,68,8964,0,0,0,2,0,43,'/1/43/','pt_equipo',1,'portugal@verdnatura.es',0,0,0,0,NULL,NULL,'3500',NULL); INSERT INTO `department` VALUES (134,'portugalTeam','EQUIPO PORTUGAL',65,66,8964,0,0,0,2,0,43,'/1/43/','pt_equipo',1,'portugal@verdnatura.es',0,0,0,0,NULL,NULL,'3500',NULL);
INSERT INTO `department` VALUES (135,'routers','ENRUTADORES',126,127,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (135,'routers','ENRUTADORES',124,125,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (136,'heavyVehicles','VEHICULOS PESADOS',128,129,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (136,'heavyVehicles','VEHICULOS PESADOS',126,127,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (137,'sorter','SORTER',130,131,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (137,'sorter','SORTER',128,129,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (139,'spainTeam4','EQUIPO ESPAÑA 4',69,70,3803,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (139,'spainTeam4','EQUIPO ESPAÑA 4',67,68,3803,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (140,'internationalTeam','EQUIPO INTERNACIONAL',71,72,24065,0,0,0,2,0,43,'/1/43/','int_equipo',1,'international@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (140,'internationalTeam','EQUIPO INTERNACIONAL',69,70,24065,0,0,0,2,0,43,'/1/43/','int_equipo',1,'international@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (141,NULL,'PREVIA',35,36,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,'PREVIOUS'); INSERT INTO `department` VALUES (141,NULL,'PREVIA',35,36,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,'PREVIOUS');
INSERT INTO `department` VALUES (146,NULL,'VERDNACOLOMBIA',3,4,NULL,72,0,0,2,0,22,'/1/22/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (146,NULL,'VERDNACOLOMBIA',3,4,NULL,72,0,0,2,0,22,'/1/22/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (147,'spainTeamAsia','EQUIPO ESPAÑA ASIA',73,74,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 (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',75,76,25178,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,'6000',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',77,78,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 (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',79,80,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 (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',81,82,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 (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',83,84,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 (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',85,86,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 (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',87,88,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 (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',89,90,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 `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 `department` VALUES (156,NULL,'COCINA',37,38,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `docuware` VALUES (1,'deliveryNote','Albaranes cliente','find','find','N__ALBAR_N',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); INSERT INTO `docuware` VALUES (2,'deliveryNote','Albaranes cliente','store','Archivar','N__ALBAR_N',NULL);

View File

@ -602,7 +602,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','projectState'
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','entrySplit__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','entrySplit__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','entryType','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','entryType','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','projectNotes','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','projectNotes','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','project','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','project','juan@10.5.1.1','0000-00-00 00:00:00','Select,Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','productionConfig','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','productionConfig','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','manager','productionConfig','alexm@%','0000-00-00 00:00:00','Update',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','manager','productionConfig','alexm@%','0000-00-00 00:00:00','Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','creditInsurance','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','creditInsurance','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
@ -1498,13 +1498,6 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','zoneGeo','guillermo
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','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','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',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','campaign','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','awb','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','awbComponent','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','awbComponentType','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','itemSoldOutTag','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','itemDurationTag','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','itemGrowingTag','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminBoss','receipt','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update,Delete','');
/*!40000 ALTER TABLE `tables_priv` ENABLE KEYS */; /*!40000 ALTER TABLE `tables_priv` ENABLE KEYS */;
/*!40000 ALTER TABLE `columns_priv` DISABLE KEYS */; /*!40000 ALTER TABLE `columns_priv` DISABLE KEYS */;
@ -2149,7 +2142,6 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','srt','delivery','buffer_settypebynam
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expedition_getstate','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expedition_getstate','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','srt','delivery','expedition_scan','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','srt','delivery','expedition_scan','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_get','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_get','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financial','remittance_calc','PROCEDURE','jgallego@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_add','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_add','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_getsaledate','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_getsaledate','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_filterbuyer','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_filterbuyer','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
@ -2212,6 +2204,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','entry_getTransfe
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','entry_getTransfer','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','entry_getTransfer','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','intrastat_estimateNet','FUNCTION','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','intrastat_estimateNet','FUNCTION','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','artificialBoss','confection_controlSource','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','artificialBoss','confection_controlSource','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financial','remittance_calc','PROCEDURE','alexm@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','util','developer','connection_kill','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','util','developer','connection_kill','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financial','client_getRisk','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financial','client_getRisk','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','account','developer','user_hasRole','FUNCTION','root@localhost','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','account','developer','user_hasRole','FUNCTION','root@localhost','Execute','0000-00-00 00:00:00');
@ -2319,7 +2312,6 @@ INSERT IGNORE INTO `global_priv` VALUES ('','root','{\"access\": 549755781119, \
INSERT IGNORE INTO `global_priv` VALUES ('','salesAssistant','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); INSERT IGNORE INTO `global_priv` VALUES ('','salesAssistant','{\"access\":0,\"version_id\":101106,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','salesBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); INSERT IGNORE INTO `global_priv` VALUES ('','salesBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','salesPerson','{\"access\": 0, \"is_role\": true,\"version_id\":101106}'); INSERT IGNORE INTO `global_priv` VALUES ('','salesPerson','{\"access\": 0, \"is_role\": true,\"version_id\":101106}');
INSERT IGNORE INTO `global_priv` VALUES ('','salesPersonClaim','{\"access\":0,\"version_id\":101106,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','salesTeamBoss','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); INSERT IGNORE INTO `global_priv` VALUES ('','salesTeamBoss','{\"access\":0,\"version_id\":100707,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','salix','{\"access\":33555456,\"version_id\":100707,\"is_role\":true}'); INSERT IGNORE INTO `global_priv` VALUES ('','salix','{\"access\":33555456,\"version_id\":100707,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','sysadmin','{\"access\": 201326592, \"is_role\": true, \"version_id\": 100707}'); INSERT IGNORE INTO `global_priv` VALUES ('','sysadmin','{\"access\": 201326592, \"is_role\": true, \"version_id\": 100707}');

View File

@ -2543,17 +2543,17 @@ CREATE TABLE `defaulting` (
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
-- --
-- Table structure for table `f_tvc__` -- Table structure for table `f_tvc`
-- --
DROP TABLE IF EXISTS `f_tvc__`; DROP TABLE IF EXISTS `f_tvc`;
/*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */; /*!40101 SET character_set_client = utf8 */;
CREATE TABLE `f_tvc__` ( CREATE TABLE `f_tvc` (
`Id_Ticket` int(11) NOT NULL, `Id_Ticket` int(11) NOT NULL,
PRIMARY KEY (`Id_Ticket`), PRIMARY KEY (`Id_Ticket`),
CONSTRAINT `id_ticket_to_comisionantes` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn`.`ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE CONSTRAINT `id_ticket_to_comisionantes` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn`.`ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='@deprecated 2025-01-15'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Almacenamos la lista de tickets para agilizar la consulta. Corresponde a los clientes REAL y en los almacenes COMISIONANTES';
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
-- --
@ -25878,7 +25878,7 @@ CREATE TABLE `address` (
`isActive` tinyint(4) NOT NULL DEFAULT 1, `isActive` tinyint(4) NOT NULL DEFAULT 1,
`longitude` decimal(11,7) DEFAULT NULL COMMENT 'Indica la última longitud proporcionada por tabla delivery', `longitude` decimal(11,7) DEFAULT NULL COMMENT 'Indica la última longitud proporcionada por tabla delivery',
`latitude` decimal(11,7) DEFAULT NULL COMMENT 'Indica la última latitud proporcionada por tabla delivery', `latitude` decimal(11,7) DEFAULT NULL COMMENT 'Indica la última latitud proporcionada por tabla delivery',
`isEqualizated` tinyint(1) DEFAULT NULL, `isEqualizated` tinyint(1) NOT NULL DEFAULT 0,
`customsAgentFk` int(11) DEFAULT NULL, `customsAgentFk` int(11) DEFAULT NULL,
`incotermsFk` varchar(3) DEFAULT NULL, `incotermsFk` varchar(3) DEFAULT NULL,
`isLogifloraAllowed` tinyint(4) NOT NULL DEFAULT 0, `isLogifloraAllowed` tinyint(4) NOT NULL DEFAULT 0,
@ -27725,7 +27725,6 @@ CREATE TABLE `client` (
`hasDailyInvoice` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Indica si el cliente requiere facturación diaria por defecto se copiará lo que tenga country.hasDailyInvoice', `hasDailyInvoice` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Indica si el cliente requiere facturación diaria por defecto se copiará lo que tenga country.hasDailyInvoice',
`geoFk` int(11) DEFAULT NULL, `geoFk` int(11) DEFAULT NULL,
`editorFk` int(10) unsigned DEFAULT NULL, `editorFk` int(10) unsigned DEFAULT NULL,
`packagesDiscountFactor` decimal(4,3) NOT NULL DEFAULT 1.000 COMMENT 'Porcentaje de ajuste entre el numero de bultos medio del cliente, y el número medio óptimo para las zonas en las que compra',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `IF` (`fi`), UNIQUE KEY `IF` (`fi`),
KEY `Id_Trabajador` (`salesPersonFk`), KEY `Id_Trabajador` (`salesPersonFk`),
@ -27805,8 +27804,6 @@ CREATE TABLE `clientConfig` (
`defaultHasCoreVnl` tinyint(1) DEFAULT NULL, `defaultHasCoreVnl` tinyint(1) DEFAULT NULL,
`defaultMandateTypeFk` smallint(5) DEFAULT NULL, `defaultMandateTypeFk` smallint(5) DEFAULT NULL,
`monthsToDisableUser` int(10) unsigned DEFAULT NULL, `monthsToDisableUser` int(10) unsigned DEFAULT NULL,
`packagesOptimum` int(10) unsigned NOT NULL DEFAULT 20 COMMENT 'Numero de bultos por cliente/dia para conseguir el precio optimo',
`monthsToCalcOptimumPrice` tinyint(3) unsigned NOT NULL DEFAULT 3 COMMENT 'Número de meses a usar para el cálculo de client.packagesDiscountFactor',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `clientNewConfigPayMethod_FK` (`defaultPayMethodFk`), KEY `clientNewConfigPayMethod_FK` (`defaultPayMethodFk`),
KEY `clientNewConfigMandateType_FK` (`defaultMandateTypeFk`), KEY `clientNewConfigMandateType_FK` (`defaultMandateTypeFk`),
@ -29064,7 +29061,6 @@ CREATE TABLE `currency` (
`code` varchar(3) NOT NULL, `code` varchar(3) NOT NULL,
`name` varchar(45) DEFAULT NULL, `name` varchar(45) DEFAULT NULL,
`ratio` double NOT NULL DEFAULT 1, `ratio` double NOT NULL DEFAULT 1,
`hasToDownloadRate` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Si se guarda el tipo de cambio diariamente en referenceRate',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `Moneda_UNIQUE` (`code`) UNIQUE KEY `Moneda_UNIQUE` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
@ -29976,8 +29972,6 @@ CREATE TABLE `entry` (
`editorFk` int(10) unsigned DEFAULT NULL, `editorFk` int(10) unsigned DEFAULT NULL,
`lockerUserFk` int(10) unsigned DEFAULT NULL, `lockerUserFk` int(10) unsigned DEFAULT NULL,
`locked` datetime DEFAULT current_timestamp(), `locked` datetime DEFAULT current_timestamp(),
`initialTemperature` decimal(10,2) DEFAULT NULL COMMENT 'Temperatura de como lo recibimos del proveedor ej. en colombia',
`finalTemperature` decimal(10,2) DEFAULT NULL COMMENT 'Temperatura final de como llega a nuestras instalaciones',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `Id_Proveedor` (`supplierFk`), KEY `Id_Proveedor` (`supplierFk`),
KEY `Fecha` (`dated`), KEY `Fecha` (`dated`),
@ -31780,8 +31774,6 @@ CREATE TABLE `invoiceOut` (
`cplusTaxBreakFk` int(10) unsigned NOT NULL DEFAULT 1, `cplusTaxBreakFk` int(10) unsigned NOT NULL DEFAULT 1,
`cplusSubjectOpFk` int(10) unsigned NOT NULL DEFAULT 1, `cplusSubjectOpFk` int(10) unsigned NOT NULL DEFAULT 1,
`siiTrascendencyInvoiceOutFk` int(10) unsigned NOT NULL DEFAULT 1, `siiTrascendencyInvoiceOutFk` int(10) unsigned NOT NULL DEFAULT 1,
`customsAgentFk` int(11) DEFAULT NULL,
`incotermsFk` varchar(3) DEFAULT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `invoiceOut_unique` (`ref`), UNIQUE KEY `invoiceOut_unique` (`ref`),
KEY `Id_Banco` (`bankFk`), KEY `Id_Banco` (`bankFk`),
@ -31794,13 +31786,9 @@ CREATE TABLE `invoiceOut` (
KEY `Facturas_ibfk_5_idx` (`siiTrascendencyInvoiceOutFk`), KEY `Facturas_ibfk_5_idx` (`siiTrascendencyInvoiceOutFk`),
KEY `Facturas_idx_Vencimiento` (`dued`), KEY `Facturas_idx_Vencimiento` (`dued`),
KEY `invoiceOut_serial` (`serial`), KEY `invoiceOut_serial` (`serial`),
KEY `invoiceOut_customsAgentFk` (`customsAgentFk`),
KEY `invoiceOut_incotermsFk` (`incotermsFk`),
CONSTRAINT `invoiceOut_customsAgentFk` FOREIGN KEY (`customsAgentFk`) REFERENCES `customsAgent` (`id`) ON UPDATE CASCADE,
CONSTRAINT `invoiceOut_ibfk_2` FOREIGN KEY (`siiTypeInvoiceOutFk`) REFERENCES `siiTypeInvoiceOut` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoiceOut_ibfk_2` FOREIGN KEY (`siiTypeInvoiceOutFk`) REFERENCES `siiTypeInvoiceOut` (`id`) ON UPDATE CASCADE,
CONSTRAINT `invoiceOut_ibfk_3` FOREIGN KEY (`cplusSubjectOpFk`) REFERENCES `cplusSubjectOp` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoiceOut_ibfk_3` FOREIGN KEY (`cplusSubjectOpFk`) REFERENCES `cplusSubjectOp` (`id`) ON UPDATE CASCADE,
CONSTRAINT `invoiceOut_ibfk_4` FOREIGN KEY (`cplusTaxBreakFk`) REFERENCES `cplusTaxBreak` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoiceOut_ibfk_4` FOREIGN KEY (`cplusTaxBreakFk`) REFERENCES `cplusTaxBreak` (`id`) ON UPDATE CASCADE,
CONSTRAINT `invoiceOut_incotermsFk` FOREIGN KEY (`incotermsFk`) REFERENCES `incoterms` (`code`) ON UPDATE CASCADE,
CONSTRAINT `invoiceOut_serial` FOREIGN KEY (`serial`) REFERENCES `invoiceOutSerial` (`code`), CONSTRAINT `invoiceOut_serial` FOREIGN KEY (`serial`) REFERENCES `invoiceOutSerial` (`code`),
CONSTRAINT `invoice_bank_id` FOREIGN KEY (`bankFk`) REFERENCES `accounting` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoice_bank_id` FOREIGN KEY (`bankFk`) REFERENCES `accounting` (`id`) ON UPDATE CASCADE,
CONSTRAINT `invoice_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE CONSTRAINT `invoice_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE
@ -32271,21 +32259,6 @@ CREATE TABLE `itemCost` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Almacena los valores de rotacion en los ultimos 365 dias'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Almacena los valores de rotacion en los ultimos 365 dias';
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `itemDurationTag`
--
DROP TABLE IF EXISTS `itemDurationTag`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `itemDurationTag` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name_UNIQUE` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
-- --
-- Temporary table structure for view `itemEntryIn` -- Temporary table structure for view `itemEntryIn`
-- --
@ -32350,21 +32323,6 @@ CREATE TABLE `itemFarmingTag` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `itemGrowingTag`
--
DROP TABLE IF EXISTS `itemGrowingTag`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `itemGrowingTag` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name_UNIQUE` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
-- --
-- Table structure for table `itemImageQueue` -- Table structure for table `itemImageQueue`
-- --
@ -32913,21 +32871,6 @@ SET character_set_client = utf8;
1 AS `removed` */; 1 AS `removed` */;
SET character_set_client = @saved_cs_client; SET character_set_client = @saved_cs_client;
--
-- Table structure for table `itemSoldOutTag`
--
DROP TABLE IF EXISTS `itemSoldOutTag`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `itemSoldOutTag` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name_UNIQUE` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
-- --
-- Table structure for table `itemStateTag` -- Table structure for table `itemStateTag`
-- --
@ -35517,21 +35460,6 @@ CREATE TABLE `productionConfigLog` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `productionCountry`
--
DROP TABLE IF EXISTS `productionCountry`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `productionCountry` (
`countryFk` mediumint(8) unsigned NOT NULL,
`volumeGrowthEstimatePercent` decimal(6,2) DEFAULT NULL COMMENT 'Porcentaje estimado de crecimiento del volumen',
PRIMARY KEY (`countryFk`),
CONSTRAINT `productionCountryVolume_countryFK` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Datos de producción por país';
/*!40101 SET character_set_client = @saved_cs_client */;
-- --
-- Table structure for table `productionError` -- Table structure for table `productionError`
-- --
@ -38064,7 +37992,7 @@ CREATE TABLE `supplier` (
`payDay` tinyint(4) unsigned DEFAULT NULL, `payDay` tinyint(4) unsigned DEFAULT NULL,
`payDemFk` tinyint(3) unsigned NOT NULL DEFAULT 7, `payDemFk` tinyint(3) unsigned NOT NULL DEFAULT 7,
`created` timestamp NOT NULL DEFAULT current_timestamp(), `created` timestamp NOT NULL DEFAULT current_timestamp(),
`isReal` tinyint(1) unsigned NOT NULL DEFAULT 1, `isReal` tinyint(1) unsigned NOT NULL DEFAULT 0,
`note` text CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, `note` text CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL,
`postcodeFk` int(11) unsigned DEFAULT NULL, `postcodeFk` int(11) unsigned DEFAULT NULL,
`postCode` char(8) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, `postCode` char(8) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL,
@ -38657,7 +38585,6 @@ CREATE TABLE `ticket` (
KEY `tickets_zone_fk_idx` (`zoneFk`), KEY `tickets_zone_fk_idx` (`zoneFk`),
KEY `ticket_fk_editor` (`editorFk`), KEY `ticket_fk_editor` (`editorFk`),
KEY `ticket_cmrFk` (`cmrFk`), KEY `ticket_cmrFk` (`cmrFk`),
KEY `ticket_landed_IDX` (`landed`) USING BTREE,
CONSTRAINT `ticketCompany_Fk` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticketCompany_Fk` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE,
CONSTRAINT `ticket_cmrFk` FOREIGN KEY (`cmrFk`) REFERENCES `cmr` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticket_cmrFk` FOREIGN KEY (`cmrFk`) REFERENCES `cmr` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `ticket_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticket_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE,
@ -41334,7 +41261,6 @@ CREATE TABLE `zone` (
`agencyModeFk` int(11) NOT NULL, `agencyModeFk` int(11) NOT NULL,
`travelingDays` int(11) NOT NULL DEFAULT 1, `travelingDays` int(11) NOT NULL DEFAULT 1,
`price` decimal(10,2) DEFAULT NULL, `price` decimal(10,2) DEFAULT NULL,
`priceOptimum` decimal(10,2) NOT NULL COMMENT 'Precio mínimo que puede pagar un bulto',
`bonus` double NOT NULL DEFAULT 0, `bonus` double NOT NULL DEFAULT 0,
`isVolumetric` tinyint(1) NOT NULL DEFAULT 0, `isVolumetric` tinyint(1) NOT NULL DEFAULT 0,
`inflation` decimal(5,2) NOT NULL DEFAULT 1.00, `inflation` decimal(5,2) NOT NULL DEFAULT 1.00,
@ -41351,8 +41277,7 @@ CREATE TABLE `zone` (
KEY `zone_address_FK` (`addressFk`), KEY `zone_address_FK` (`addressFk`),
CONSTRAINT `fk_zone_2` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_zone_2` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `zone_address_FK` FOREIGN KEY (`addressFk`) REFERENCES `address` (`id`) ON UPDATE CASCADE, CONSTRAINT `zone_address_FK` FOREIGN KEY (`addressFk`) REFERENCES `address` (`id`) ON UPDATE CASCADE,
CONSTRAINT `zone_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `zone_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`)
CONSTRAINT `ck_zone_priceOptimum` CHECK (`priceOptimum` <= `price`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
@ -41445,7 +41370,6 @@ CREATE TABLE `zoneEvent` (
`hour` datetime DEFAULT NULL, `hour` datetime DEFAULT NULL,
`travelingDays` int(11) DEFAULT NULL, `travelingDays` int(11) DEFAULT NULL,
`price` decimal(10,2) DEFAULT NULL, `price` decimal(10,2) DEFAULT NULL,
`priceOptimum` decimal(10,2) DEFAULT NULL COMMENT 'Precio mínimo que puede pagar un bulto',
`bonus` decimal(10,2) DEFAULT NULL, `bonus` decimal(10,2) DEFAULT NULL,
`m3Max` decimal(10,2) unsigned DEFAULT NULL, `m3Max` decimal(10,2) unsigned DEFAULT NULL,
`editorFk` int(10) unsigned DEFAULT NULL, `editorFk` int(10) unsigned DEFAULT NULL,
@ -41453,8 +41377,7 @@ CREATE TABLE `zoneEvent` (
UNIQUE KEY `zoneFk` (`zoneFk`,`type`,`dated`), UNIQUE KEY `zoneFk` (`zoneFk`,`type`,`dated`),
KEY `zoneEvent_fk_editor` (`editorFk`), KEY `zoneEvent_fk_editor` (`editorFk`),
CONSTRAINT `zoneEvent_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `zoneEvent_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`),
CONSTRAINT `zoneEvent_ibfk_1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `zoneEvent_ibfk_1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
CONSTRAINT `ck_zoneEvent_priceOptimum` CHECK (`priceOptimum` <= `price`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
@ -41688,24 +41611,6 @@ END */ ;;
/*!50003 SET character_set_client = @saved_cs_client */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;;
/*!50003 SET character_set_results = @saved_cs_results */ ;; /*!50003 SET character_set_results = @saved_cs_results */ ;;
/*!50003 SET collation_connection = @saved_col_connection */ ;; /*!50003 SET collation_connection = @saved_col_connection */ ;;
/*!50106 DROP EVENT IF EXISTS `client_setPackagesDiscountFactor` */;;
DELIMITER ;;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;;
/*!50003 SET character_set_client = utf8mb4 */ ;;
/*!50003 SET character_set_results = utf8mb4 */ ;;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;;
/*!50003 SET @saved_time_zone = @@time_zone */ ;;
/*!50003 SET time_zone = 'SYSTEM' */ ;;
/*!50106 CREATE*/ /*!50117 DEFINER=`vn`@`localhost`*/ /*!50106 EVENT `client_setPackagesDiscountFactor` ON SCHEDULE EVERY 1 DAY STARTS '2024-10-18 03:00:00' ON COMPLETION PRESERVE ENABLE DO CALL client_setPackagesDiscountFactor() */ ;;
/*!50003 SET time_zone = @saved_time_zone */ ;;
/*!50003 SET sql_mode = @saved_sql_mode */ ;;
/*!50003 SET character_set_client = @saved_cs_client */ ;;
/*!50003 SET character_set_results = @saved_cs_results */ ;;
/*!50003 SET collation_connection = @saved_col_connection */ ;;
/*!50106 DROP EVENT IF EXISTS `client_unassignSalesPerson` */;; /*!50106 DROP EVENT IF EXISTS `client_unassignSalesPerson` */;;
DELIMITER ;; DELIMITER ;;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;; /*!50003 SET @saved_cs_client = @@character_set_client */ ;;
@ -49329,19 +49234,7 @@ BEGIN
SELECT tcc.warehouseFK, SELECT tcc.warehouseFK,
tcc.itemFk, tcc.itemFk,
c2.id, c2.id,
z.inflation z.inflation * ROUND(ic.cm3delivery * (IFNULL(zo.price,5000) - IFNULL(zo.bonus,0)) / (1000 * vc.standardFlowerBox) , 4) cost
* ROUND(
ic.cm3delivery
* (
(
zo.priceOptimum + (( zo.price - zo.priceOptimum) * 2 * ( 1 - c.packagesDiscountFactor))
)
- IFNULL(zo.bonus, 0)
)
/ (1000 * vc.standardFlowerBox),
4
) cost
FROM tmp.ticketComponentCalculate tcc FROM tmp.ticketComponentCalculate tcc
JOIN item i ON i.id = tcc.itemFk JOIN item i ON i.id = tcc.itemFk
JOIN tmp.zoneOption zo ON zo.zoneFk = vZoneFk JOIN tmp.zoneOption zo ON zo.zoneFk = vZoneFk
@ -49349,7 +49242,6 @@ BEGIN
JOIN agencyMode am ON am.id = z.agencyModeFk JOIN agencyMode am ON am.id = z.agencyModeFk
JOIN vn.volumeConfig vc JOIN vn.volumeConfig vc
JOIN vn.component c2 ON c2.code = 'delivery' JOIN vn.component c2 ON c2.code = 'delivery'
JOIN `client` c on c.id = vClientFk
LEFT JOIN itemCost ic ON ic.warehouseFk = tcc.warehouseFk LEFT JOIN itemCost ic ON ic.warehouseFk = tcc.warehouseFk
AND ic.itemFk = tcc.itemFk AND ic.itemFk = tcc.itemFk
HAVING cost <> 0; HAVING cost <> 0;
@ -51052,41 +50944,6 @@ BEGIN
ORDER BY clientFk; ORDER BY clientFk;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `client_setPackagesDiscountFactor` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
CREATE DEFINER=`vn`@`localhost` PROCEDURE `client_setPackagesDiscountFactor`()
BEGIN
/**
* Set the discount factor for the packages of the clients.
*/
UPDATE client c
JOIN (
SELECT t.clientFk,
LEAST((
SUM(t.packages) / COUNT(DISTINCT DATE(t.shipped))
) / cc.packagesOptimum, 1) discountFactor
FROM ticket t
JOIN clientConfig cc ON TRUE
WHERE t.shipped > util.VN_CURDATE() - INTERVAL cc.monthsToCalcOptimumPrice MONTH
AND t.packages
GROUP BY t.clientFk
) ca ON c.id = ca.clientFk
SET c.packagesDiscountFactor = ca.discountFactor;
END ;; END ;;
DELIMITER ; DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET sql_mode = @saved_sql_mode */ ;
@ -58880,7 +58737,6 @@ BEGIN
DECLARE vMaxShipped DATE; DECLARE vMaxShipped DATE;
DECLARE vDone BOOL; DECLARE vDone BOOL;
DECLARE vTicketFk INT; DECLARE vTicketFk INT;
DECLARE vAddressFk INT;
DECLARE vCursor CURSOR FOR DECLARE vCursor CURSOR FOR
SELECT id SELECT id
FROM tmp.ticketToInvoice; FROM tmp.ticketToInvoice;
@ -58895,13 +58751,11 @@ BEGIN
DATE(vInvoiceDate) >= invoiceOut_getMaxIssued( DATE(vInvoiceDate) >= invoiceOut_getMaxIssued(
vSerial, vSerial,
t.companyFk, t.companyFk,
YEAR(vInvoiceDate)), YEAR(vInvoiceDate))
t.addressFk
INTO vClientFk, INTO vClientFk,
vCompanyFk, vCompanyFk,
vMaxShipped, vMaxShipped,
vIsCorrectInvoiceDate, vIsCorrectInvoiceDate
vAddressFk
FROM tmp.ticketToInvoice tt FROM tmp.ticketToInvoice tt
JOIN ticket t ON t.id = tt.id; JOIN ticket t ON t.id = tt.id;
@ -58954,9 +58808,7 @@ BEGIN
clientFk, clientFk,
dued, dued,
companyFk, companyFk,
siiTypeInvoiceOutFk, siiTypeInvoiceOutFk
customsAgentFk,
incotermsFk
) )
SELECT SELECT
1, 1,
@ -58969,12 +58821,9 @@ BEGIN
vCplusCorrectingInvoiceTypeFk, vCplusCorrectingInvoiceTypeFk,
IF(vSerial = vSimplifiedSerial, IF(vSerial = vSimplifiedSerial,
vCplusSimplifiedInvoiceTypeFk, vCplusSimplifiedInvoiceTypeFk,
vCplusStandardInvoiceTypeFk)), vCplusStandardInvoiceTypeFk))
a.customsAgentFk, FROM client
a.incotermsFk WHERE id = vClientFk;
FROM client c
JOIN address a ON a.id = vAddressFk
WHERE c.id = vClientFk;
SET vNewInvoiceId = LAST_INSERT_ID(); SET vNewInvoiceId = LAST_INSERT_ID();
@ -67642,14 +67491,14 @@ DELIMITER ;
/*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `remittance_calc` */; /*!50003 DROP PROCEDURE IF EXISTS `remittance_calc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;; DELIMITER ;;
CREATE DEFINER=`vn`@`localhost` PROCEDURE `remittance_calc`( CREATE DEFINER=`vn`@`localhost` PROCEDURE `remittance_calc`(
vDated DATE vDated DATE
@ -67713,7 +67562,7 @@ BEGIN
) risk ON risk.clientFk = c.id ) risk ON risk.clientFk = c.id
GROUP BY risk.companyFk, c.id GROUP BY risk.companyFk, c.id
HAVING receipt > 1 HAVING receipt > 10
) sub ON sub.id = c.id ) sub ON sub.id = c.id
JOIN supplier s ON s.id = sub.companyFk JOIN supplier s ON s.id = sub.companyFk
JOIN company co ON co.id = sub.companyFk JOIN company co ON co.id = sub.companyFk
@ -74655,6 +74504,9 @@ BEGIN
IFNULL(sat.supplierFk, su.id) supplierFk, IFNULL(sat.supplierFk, su.id) supplierFk,
t.landed t.landed
FROM ticket t FROM ticket t
JOIN ticketState ts ON ts.ticketFk = t.id
JOIN `state` s ON s.id = ts.stateFk
JOIN alertLevel al ON al.id = s.alertLevel
JOIN client c ON c.id = t.clientFk JOIN client c ON c.id = t.clientFk
JOIN `address` a ON a.id = t.addressFk JOIN `address` a ON a.id = t.addressFk
JOIN province p ON p.id = a.provinceFk JOIN province p ON p.id = a.provinceFk
@ -74671,7 +74523,8 @@ BEGIN
LEFT JOIN agency ag ON ag.id = am.agencyFk LEFT JOIN agency ag ON ag.id = am.agencyFk
LEFT JOIN supplierAgencyTerm sat ON sat.agencyFk = ag.id LEFT JOIN supplierAgencyTerm sat ON sat.agencyFk = ag.id
AND wo.isFreelance AND wo.isFreelance
WHERE co.code <> 'ES' WHERE al.code IN ('PACKED', 'DELIVERED')
AND co.code <> 'ES'
AND am.name <> 'ABONO' AND am.name <> 'ABONO'
AND w.code = 'ALG' AND w.code = 'ALG'
AND t.id = vSelf AND t.id = vSelf
@ -81738,27 +81591,26 @@ DELIMITER ;
DELIMITER ;; DELIMITER ;;
CREATE DEFINER=`vn`@`localhost` PROCEDURE `zone_getAddresses`( CREATE DEFINER=`vn`@`localhost` PROCEDURE `zone_getAddresses`(
vSelf INT, vSelf INT,
vLanded DATE, vShipped DATE,
vDepartmentFk INT vDepartmentFk INT
) )
BEGIN BEGIN
/** /**
* Devuelve un listado de todos los clientes activos * Devuelve un listado de todos los clientes activos
* con consignatarios a los que se les puede * con consignatarios a los que se les puede
* entregar producto para esa zona. * vender producto para esa zona.
* *
* @param vSelf Id de zona * @param vSelf Id de zona
* @param vLanded Fecha de entrega * @param vShipped Fecha de envio
* @param vDepartmentFk Id de departamento | NULL para mostrar todos * @param vDepartmentFk Id de departamento
* @return Un select * @return Un select
*/ */
CALL zone_getPostalCode(vSelf); CALL zone_getPostalCode(vSelf);
WITH clientWithTicket AS ( WITH clientWithTicket AS (
SELECT DISTINCT clientFk SELECT clientFk
FROM vn.ticket FROM vn.ticket
WHERE landed BETWEEN vLanded AND util.dayEnd(vLanded) WHERE shipped BETWEEN vShipped AND util.dayEnd(vShipped)
AND NOT isDeleted
) )
SELECT c.id, SELECT c.id,
c.name, c.name,
@ -81768,7 +81620,7 @@ BEGIN
u.name username, u.name username,
aai.invoiced, aai.invoiced,
cnb.lastShipped, cnb.lastShipped,
IF(cwt.clientFk, TRUE, FALSE) hasTicket cwt.clientFk
FROM vn.client c FROM vn.client c
JOIN vn.worker w ON w.id = c.salesPersonFk JOIN vn.worker w ON w.id = c.salesPersonFk
JOIN vn.workerDepartment wd ON wd.workerFk = w.id JOIN vn.workerDepartment wd ON wd.workerFk = w.id
@ -81788,7 +81640,7 @@ BEGIN
AND c.isActive AND c.isActive
AND ct.code = 'normal' AND ct.code = 'normal'
AND bt.code <> 'worker' AND bt.code <> 'worker'
AND (d.id = vDepartmentFk OR vDepartmentFk IS NULL) AND (d.id = vDepartmentFk OR NOT vDepartmentFk)
GROUP BY c.id; GROUP BY c.id;
DROP TEMPORARY TABLE tmp.zoneNodes; DROP TEMPORARY TABLE tmp.zoneNodes;
@ -82501,7 +82353,6 @@ BEGIN
TIME(IFNULL(e.`hour`, z.`hour`)) `hour`, TIME(IFNULL(e.`hour`, z.`hour`)) `hour`,
l.travelingDays, l.travelingDays,
IFNULL(e.price, z.price) price, IFNULL(e.price, z.price) price,
IFNULL(e.priceOptimum, z.priceOptimum) priceOptimum,
IFNULL(e.bonus, z.bonus) bonus, IFNULL(e.bonus, z.bonus) bonus,
l.landed, l.landed,
vShipped shipped vShipped shipped
@ -91042,4 +90893,4 @@ USE `vn2008`;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2025-01-28 7:08:42 -- Dump completed on 2025-01-14 6:39:04

View File

@ -6804,30 +6804,6 @@ DELIMITER ;;
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
SET NEW.editorFk = account.myUser_getId(); SET NEW.editorFk = account.myUser_getId();
IF NOT(NEW.`countryFk` <=> OLD.`countryFk`) OR NOT(NEW.`itemFk` <=> OLD.`itemFk`) THEN
CALL util.throw('Only the VAT can be modified');
END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTaxCountry_beforeDelete`
BEFORE DELETE ON `itemTaxCountry`
FOR EACH ROW
BEGIN
CALL util.throw('Records in this table cannot be deleted');
END */;; END */;;
DELIMITER ; DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET sql_mode = @saved_sql_mode */ ;
@ -11043,92 +11019,6 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;; DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerMana_beforeInsert`
BEFORE INSERT ON `workerMana`
FOR EACH ROW
BEGIN
IF (SELECT EXISTS(SELECT TRUE FROM workerManaExcluded WHERE workerFk = NEW.workerFk)) THEN
CALL util.throw('Worker is excluded from mana');
END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerMana_beforeUpdate`
BEFORE UPDATE ON `workerMana`
FOR EACH ROW
BEGIN
IF (SELECT EXISTS(SELECT TRUE FROM workerManaExcluded WHERE workerFk = NEW.workerFk)) THEN
CALL util.throw('Worker is excluded from mana');
END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerManaExcluded_beforeInsert`
BEFORE INSERT ON `workerManaExcluded`
FOR EACH ROW
BEGIN
DELETE FROM workerMana
WHERE workerFk = NEW.workerFk;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerManaExcluded_beforeUpdate`
BEFORE UPDATE ON `workerManaExcluded`
FOR EACH ROW
BEGIN
DELETE FROM workerMana
WHERE workerFk = NEW.workerFk;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerTimeControl_beforeInsert` /*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerTimeControl_beforeInsert`
BEFORE INSERT ON `workerTimeControl` BEFORE INSERT ON `workerTimeControl`
FOR EACH ROW FOR EACH ROW
@ -11195,13 +11085,11 @@ DELIMITER ;;
AFTER DELETE ON `workerTimeControl` AFTER DELETE ON `workerTimeControl`
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
IF account.myUser_getId() IS NOT NULL THEN
INSERT INTO workerLog INSERT INTO workerLog
SET `action` = 'delete', SET `action` = 'delete',
`changedModel` = 'WorkerTimeControl', `changedModel` = 'WorkerTimeControl',
`changedModelId` = OLD.id, `changedModelId` = OLD.id,
`userFk` = account.myUser_getId(); `userFk` = account.myUser_getId();
END IF;
END */;; END */;;
DELIMITER ; DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET sql_mode = @saved_sql_mode */ ;
@ -11611,4 +11499,4 @@ USE `vn2008`;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2025-01-28 7:09:01 -- Dump completed on 2025-01-14 6:39:25

View File

@ -321,11 +321,6 @@ UPDATE `vn`.`agencyMode` SET `web` = 1, `reportMail` = 'no-reply@gothamcity.com'
UPDATE `vn`.`agencyMode` SET `code` = 'refund' WHERE `id` = 23; UPDATE `vn`.`agencyMode` SET `code` = 'refund' WHERE `id` = 23;
INSERT INTO `vn`.`agencyIncoming`(`agencyModeFk`)
VALUES
(1),
(2);
INSERT INTO `vn`.`payMethod`(`id`,`code`, `name`, `graceDays`, `outstandingDebt`, `isIbanRequiredForClients`, `isIbanRequiredForSuppliers`, `hasVerified`) INSERT INTO `vn`.`payMethod`(`id`,`code`, `name`, `graceDays`, `outstandingDebt`, `isIbanRequiredForClients`, `isIbanRequiredForSuppliers`, `hasVerified`)
VALUES VALUES
(1, NULL, 'PayMethod one', 0, 001, 0, 0, 0), (1, NULL, 'PayMethod one', 0, 001, 0, 0, 0),
@ -752,15 +747,13 @@ INSERT INTO `vn`.`zoneConfig` (`id`, `scope`) VALUES (1, '1');
INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agencyModeFk`, `description`, `m3`, `cost`, `started`, `finished`, `zoneFk`, `dated`) INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agencyModeFk`, `description`, `m3`, `cost`, `started`, `finished`, `zoneFk`, `dated`)
VALUES VALUES
(1, '1899-12-30 12:15:00', 133, util.VN_CURDATE(), 1, 1, 'first route', 1.8, 10, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1, util.VN_CURDATE()), (1, '1899-12-30 12:15:00', 56, util.VN_CURDATE(), 1, 1, 'first route', 1.8, 10, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1, util.VN_CURDATE()),
(2, '1899-12-30 13:20:00', 56, util.VN_CURDATE(), 1, 2, 'second route', 0.2, 20, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 9, util.VN_CURDATE()), (2, '1899-12-30 13:20:00', 56, util.VN_CURDATE(), 1, 2, 'second route', 0.2, 20, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 9, util.VN_CURDATE()),
(3, '1899-12-30 14:30:00', 56, util.VN_CURDATE(), 2, 3, 'third route', 0.5, 30, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 10, util.VN_CURDATE()), (3, '1899-12-30 14:30:00', 56, util.VN_CURDATE(), 2, 3, 'third route', 0.5, 30, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 10, util.VN_CURDATE()),
(4, '1899-12-30 15:45:00', 56, util.VN_CURDATE(), 3, 4, 'fourth route', 0, 40, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 12, util.VN_CURDATE()), (4, '1899-12-30 15:45:00', 56, util.VN_CURDATE(), 3, 4, 'fourth route', 0, 40, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 12, util.VN_CURDATE()),
(5, '1899-12-30 16:00:00', 56, util.VN_CURDATE(), 4, 5, 'fifth route', 0.1, 50, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 13, util.VN_CURDATE()), (5, '1899-12-30 16:00:00', 56, util.VN_CURDATE(), 4, 5, 'fifth route', 0.1, 50, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 13, util.VN_CURDATE()),
(6, NULL, 57, util.VN_CURDATE(), 5, 7, 'sixth route', 1.7, 60, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 3, util.VN_CURDATE()), (6, NULL, 57, util.VN_CURDATE(), 5, 7, 'sixth route', 1.7, 60, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 3, util.VN_CURDATE()),
(7, NULL, 57, util.VN_CURDATE(), 6, 8, 'seventh route', 0, 70, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 5, util.VN_CURDATE()), (7, NULL, 57, util.VN_CURDATE(), 6, 8, 'seventh route', 0, 70, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 5, util.VN_CURDATE());
(8, NULL, 133, util.VN_CURDATE(), 1, 1, 'eighth route', 1.8, 10.0, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1, util.VN_CURDATE()),
(9, NULL, 133, util.VN_CURDATE(), 1, 2, 'ninth route', 0.2, 20.0, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 9, util.VN_CURDATE());
INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`, `weight`, `cmrFk`, `problem`, `risk`) INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`, `weight`, `cmrFk`, `problem`, `risk`)
VALUES VALUES
@ -2641,9 +2634,9 @@ REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issu
(9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 0, 442, 1,util.VN_CURDATE()), (9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 0, 442, 1,util.VN_CURDATE()),
(10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 0, 442, 1,util.VN_CURDATE()); (10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 0, 442, 1,util.VN_CURDATE());
INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageFarmerWithholdingFk`, `daysAgo`, `balanceStartingDate`) INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageFarmerWithholdingFk`, `daysAgo`)
VALUES VALUES
(1, -2, '2% retention', 2, 45, '2000-01-01'); (1, -2, '2% retention', 2, 45);
INSERT INTO `vn`.`invoiceInDueDay`(`invoiceInFk`, `dueDated`, `bankFk`, `amount`) INSERT INTO `vn`.`invoiceInDueDay`(`invoiceInFk`, `dueDated`, `bankFk`, `amount`)
VALUES VALUES
@ -4052,9 +4045,6 @@ INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel)
INSERT INTO vn.workerIrpf (workerFk,spouseNif, geographicMobilityDate) INSERT INTO vn.workerIrpf (workerFk,spouseNif, geographicMobilityDate)
VALUES (1106,'26493101E','2019-09-20'); VALUES (1106,'26493101E','2019-09-20');
INSERT INTO vn.payment (received, supplierFk, amount, currencyFk, divisa, bankFk, payMethodFk, bankingFees, concept, companyFk, created, isConciliated, dueDated, workerFk) VALUES
(util.VN_CURDATE(), 1, 1000.00, 1, NULL, 1, 1, 0.0, 'n/pago', 442, util.VN_CURDATE(), 1, util.VN_CURDATE(), 9);
INSERT INTO vn.referenceRate (currencyFk, dated, value) INSERT INTO vn.referenceRate (currencyFk, dated, value)
VALUES (2, '2000-12-01', 1.0495), VALUES (2, '2000-12-01', 1.0495),
(2, '2001-01-01', 1.0531), (2, '2001-01-01', 1.0531),
@ -4066,8 +4056,3 @@ INSERT IGNORE INTO vn.osrmConfig (id,url,tolerance)
INSERT IGNORE INTO vn.inventoryConfig INSERT IGNORE INTO vn.inventoryConfig
SET id = 1, SET id = 1,
supplierFk = 4; supplierFk = 4;
UPDATE vn.worker
SET isFreelance=1
WHERE firstName='deliveryFreelancer';

View File

@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_refres
OUT `vCalc` INT, OUT `vCalc` INT,
`vRefresh` INT, `vRefresh` INT,
`vWarehouse` INT, `vWarehouse` INT,
`vAvailabled` DATETIME `vDated` DATE
) )
proc: BEGIN proc: BEGIN
DECLARE vStartDate DATE; DECLARE vStartDate DATE;
@ -12,7 +12,6 @@ proc: BEGIN
DECLARE vInventoryDate DATE; DECLARE vInventoryDate DATE;
DECLARE vLifeScope DATE; DECLARE vLifeScope DATE;
DECLARE vWarehouseFkInventory INT; DECLARE vWarehouseFkInventory INT;
DECLARE vDated DATE;
DECLARE EXIT HANDLER FOR SQLEXCEPTION DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN BEGIN
@ -20,17 +19,13 @@ proc: BEGIN
RESIGNAL; RESIGNAL;
END; END;
IF vAvailabled < util.VN_CURDATE() THEN IF vDated < util.VN_CURDATE() THEN
LEAVE proc; LEAVE proc;
END IF; END IF;
SET vDated = DATE(vAvailabled);
SET vAvailabled = vDated + INTERVAL HOUR(vAvailabled) HOUR;
CALL vn.item_getStock(vWarehouse, vDated, NULL); CALL vn.item_getStock(vWarehouse, vDated, NULL);
SET vParams = CONCAT_WS('/', vWarehouse, vAvailabled); SET vParams = CONCAT_WS('/', vWarehouse, vDated);
CALL cache_calc_start (vCalc, vRefresh, 'available', vParams); CALL cache_calc_start (vCalc, vRefresh, 'available', vParams);
IF !vRefresh THEN IF !vRefresh THEN
@ -92,10 +87,11 @@ proc: BEGIN
SELECT i.itemFk, i.landed, i.quantity SELECT i.itemFk, i.landed, i.quantity
FROM vn.itemEntryIn i FROM vn.itemEntryIn i
JOIN itemRange ir ON ir.itemFk = i.itemFk JOIN itemRange ir ON ir.itemFk = i.itemFk
LEFT JOIN edi.warehouseFloramondo wf ON wf.entryFk = i.entryFk
WHERE i.landed >= vStartDate WHERE i.landed >= vStartDate
AND IFNULL(i.availabled, i.landed) <= vAvailabled
AND (ir.ended IS NULL OR i.landed <= ir.ended) AND (ir.ended IS NULL OR i.landed <= ir.ended)
AND i.warehouseInFk = vWarehouse AND i.warehouseInFk = vWarehouse
AND ISNULL(wf.entryFk)
UNION ALL UNION ALL
SELECT i.itemFk, i.shipped, i.quantity SELECT i.itemFk, i.shipped, i.quantity
FROM vn.itemEntryOut i FROM vn.itemEntryOut i

View File

@ -23,7 +23,6 @@ BEGIN
DECLARE vInvoiceTypeInformativeCode VARCHAR(1); DECLARE vInvoiceTypeInformativeCode VARCHAR(1);
DECLARE vCountryCanariasCode, vCountryCeutaMelillaCode VARCHAR(2); DECLARE vCountryCanariasCode, vCountryCeutaMelillaCode VARCHAR(2);
DECLARE vCompanyCode INT; DECLARE vCompanyCode INT;
DECLARE vHasErrorTax BOOL DEFAULT FALSE;
SELECT SiglaNacion INTO vCountryCanariasCode SELECT SiglaNacion INTO vCountryCanariasCode
FROM Naciones FROM Naciones
@ -67,24 +66,6 @@ BEGIN
WHERE enlazadoSage = FALSE WHERE enlazadoSage = FALSE
AND Asiento <> 1 ; AND Asiento <> 1 ;
SELECT EXISTS (
SELECT TRUE
FROM vn.XDiario x
JOIN vn.invoiceIn ii ON ii.id = x.CLAVE
JOIN vn.invoiceInTax it ON it.invoiceInFk = ii.id
LEFT JOIN TiposIva ti ON ti.CodigoIva = it.taxTypeSageFk
LEFT JOIN taxType tt ON tt.id = it.taxTypeSageFk
WHERE x.FECHA BETWEEN vDatedFrom AND vDatedTo
AND NOT x.enlazadoSage
AND x.empresa_id = vCompanyFk
AND it.taxTypeSageFk
AND (ti.CodigoIva IS NULL OR tt.id IS NULL)
) INTO vHasErrorTax;
IF vHasErrorTax tHEN
CALL util.throw ('Error in tables for received invoices tax');
END IF;
CALL invoiceOut_manager(vYear, vCompanyFk); CALL invoiceOut_manager(vYear, vCompanyFk);
CALL invoiceIn_manager(vYear, vCompanyFk); CALL invoiceIn_manager(vYear, vCompanyFk);

View File

@ -1,31 +1,20 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_clone`( CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_clone`(vSelf INT)
vSelf INT,
OUT vOutputEntryFk INT
)
BEGIN BEGIN
/** /**
* clones an entry. * clones an entry.
* *
* @param vSelf The entry id * @param vSelf The entry id
* @param vOutputEntryFk The new entry id
*/ */
DECLARE vNewEntryFk INT; DECLARE vNewEntryFk INT;
DECLARE vIsRequiredTx BOOL DEFAULT NOT @@in_transaction; START TRANSACTION;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
CALL util.tx_rollback(vIsRequiredTx);
RESIGNAL;
END;
CALL util.tx_start(vIsRequiredTx);
CALL entry_cloneHeader(vSelf, vNewEntryFk, NULL); CALL entry_cloneHeader(vSelf, vNewEntryFk, NULL);
CALL entry_copyBuys(vSelf, vNewEntryFk); CALL entry_copyBuys(vSelf, vNewEntryFk);
CALL util.tx_commit(vIsRequiredTx); COMMIT;
SET vOutputEntryFk = vNewEntryFk;
SELECT vNewEntryFk;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -1,158 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_transfer`(
vOriginalEntry INT,
OUT vNewEntryFk INT
)
BEGIN
/**
* Adelanta a mañana la mercancia de una entrada a partir de lo que hay ubicado en el almacén
*
* @param vOriginalEntry entrada que se quiera adelantar
* @param vNewEntry nueva entrada creada
*/
DECLARE vTravelFk INT;
DECLARE vWarehouseFk INT;
DECLARE vWarehouseInFk INT;
DECLARE vWarehouseOutFk INT;
DECLARE vRef INT;
DECLARE vIsReceived INT;
DECLARE vAgencyModeFk INT;
DECLARE vTomorrow DATETIME DEFAULT util.tomorrow();
DECLARE vCurDate DATE DEFAULT util.VN_CURDATE();
DECLARE vIsRequiredTx BOOL DEFAULT NOT @@in_transaction;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
CALL util.tx_rollback(vIsRequiredTx);
RESIGNAL;
END;
-- Clonar la entrada
CALL entry_clone(vOriginalEntry, vNewEntryFk);
CALL util.tx_start(vIsRequiredTx);
/* Hay que crear un nuevo travel, con salida hoy y llegada mañana y
asignar la entrada nueva al nuevo travel.*/
SELECT t.warehouseInFk, t.warehouseOutFk, t.`ref`, t.isReceived, t.agencyModeFk
INTO vWarehouseInFk, vWarehouseOutFk, vRef, vIsReceived, vAgencyModeFk
FROM travel t
JOIN entry e ON e.travelFk = t.id
WHERE e.id = vOriginalEntry;
SELECT id INTO vTravelFk
FROM travel t
WHERE shipped = vCurDate
AND landed = vTomorrow
AND warehouseInFk = vWarehouseInFk
AND warehouseOutFk = vWarehouseOutFk
AND `ref` = vRef
AND isReceived =vIsReceived
AND agencyModeFk = vAgencyModeFk;
IF vTravelFk IS NULL THEN
INSERT INTO travel(
shipped,
landed,
warehouseInFk,
warehouseOutFk,
`ref`,
isReceived,
agencyModeFk)
SELECT vCurDate,
vTomorrow,
t.warehouseInFk,
t.warehouseOutFk,
t.`ref`,
t.isReceived,
t.agencyModeFk
FROM travel t
JOIN entry e ON e.travelFk = t.id
WHERE e.id = vOriginalEntry;
SET vTravelFk = LAST_INSERT_ID();
END IF;
UPDATE entry
SET travelFk = vTravelFk,
evaNotes = vOriginalEntry
WHERE id = vNewEntryFk;
-- Poner a 0 las cantidades
UPDATE buy b
SET b.quantity = 0, b.stickers = 0
WHERE b.entryFk = vNewEntryFk;
-- Eliminar duplicados
DELETE b
FROM buy b
LEFT JOIN (SELECT b.id, b.itemFk
FROM buy b
WHERE b.entryFk = vNewEntryFk
GROUP BY b.itemFk) tBuy ON tBuy.id = b.id
WHERE b.entryFk = vNewEntryFk
AND tBuy.id IS NULL;
SELECT t.warehouseInFk INTO vWarehouseFk
FROM travel t
JOIN entry e ON e.travelFk = t.id
WHERE e.id = vOriginalEntry;
/* Actualizar nueva entrada con lo que no está ubicado HOY,
descontando lo vendido HOY de esas ubicaciones*/
CREATE OR REPLACE TEMPORARY TABLE buys
WITH tBuy AS (
SELECT b.itemFk, SUM(b.quantity) totalQuantity
FROM vn.buy b
WHERE b.entryFk = vOriginalEntry
GROUP BY b.itemFk
),
itemShelvings AS (
SELECT ish.itemFk, SUM(ish.visible) visible
FROM vn.itemShelving ish
JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
JOIN vn.sector s ON s.id = p.sectorFk
JOIN vn.buy b ON b.id = ish.buyFk
JOIN vn.entry e ON e.id = b.entryFk
JOIN tBuy t ON t.itemFk = ish.itemFk
WHERE s.warehouseFk = vWarehouseFk
AND sh.parked >= vCurDate
GROUP BY ish.itemFk
),
sales AS (
SELECT s.itemFk, SUM(s.quantity) sold
FROM vn.ticket t
JOIN vn.sale s ON s.ticketFk = t.id
JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id
JOIN vn.itemShelving is2 ON is2.id = iss.itemShelvingFk
JOIN vn.shelving s2 ON s2.id = is2.shelvingFk
JOIN tBuy t ON t.itemFk = s.itemFk
WHERE t.shipped BETWEEN vCurDate AND util.dayend(vCurDate)
AND s2.parked >= vCurDate
GROUP BY s.itemFk
)
SELECT tmp.itemFk,
IFNULL(iss.visible, 0) visible,
tmp.totalQuantity,
IFNULL(s.sold, 0) sold
FROM tBuy tmp
LEFT JOIN itemShelvings iss ON tmp.itemFk = iss.itemFk
LEFT JOIN sales s ON s.itemFk = tmp.itemFk
WHERE visible < tmp.totalQuantity
OR iss.itemFk IS NULL;
UPDATE buy b
JOIN buys tmp ON tmp.itemFk = b.itemFk
SET b.quantity = tmp.totalQuantity - tmp.visible - tmp.sold
WHERE b.entryFk = vNewEntryFk;
-- Limpia la nueva entrada
DELETE FROM buy WHERE entryFk = vNewEntryFk AND quantity = 0;
CALL util.tx_commit(vIsRequiredTx);
CALL cache.visible_refresh(@c,TRUE,vWarehouseFk);
CALL cache.available_refresh(@c, TRUE, vWarehouseFk, vCurDate);
END$$
DELIMITER ;

View File

@ -15,6 +15,8 @@ BEGIN
* *
* @return tmp.itemList(itemFk, stock, visible, available) * @return tmp.itemList(itemFk, stock, visible, available)
*/ */
DECLARE vIsLogifloraDay BOOL DEFAULT vn.isLogifloraDay(vDated, vWarehouseFk);
SET vDated = TIMESTAMP(vDated, '00:00:00'); SET vDated = TIMESTAMP(vDated, '00:00:00');
CREATE OR REPLACE TEMPORARY TABLE tmp.itemList CREATE OR REPLACE TEMPORARY TABLE tmp.itemList
@ -34,11 +36,14 @@ BEGIN
UNION ALL UNION ALL
SELECT iei.itemFk, iei.quantity SELECT iei.itemFk, iei.quantity
FROM itemEntryIn iei FROM itemEntryIn iei
LEFT JOIN edi.warehouseFloramondo wf ON wf.entryFk = iei.entryFk
JOIN item i ON i.id = iei.itemFk JOIN item i ON i.id = iei.itemFk
WHERE iei.landed >= util.VN_CURDATE() WHERE iei.landed >= util.VN_CURDATE()
AND iei.landed < vDated AND iei.landed < vDated
AND iei.warehouseInFk = vWarehouseFk AND iei.warehouseInFk = vWarehouseFk
AND (vItemFk IS NULL OR iei.itemFk = vItemFk) AND (vItemFk IS NULL OR iei.itemFk = vItemFk)
AND (wf.entryFk IS NULL OR vIsLogifloraDay)
AND NOT (iei.landed > util.VN_CURDATE() AND i.isFloramondo)
UNION ALL UNION ALL
SELECT ieo.itemFk, ieo.quantity SELECT ieo.itemFk, ieo.quantity
FROM itemEntryOut ieo FROM itemEntryOut ieo
@ -47,6 +52,7 @@ BEGIN
AND ieo.shipped < vDated AND ieo.shipped < vDated
AND ieo.warehouseOutFk = vWarehouseFk AND ieo.warehouseOutFk = vWarehouseFk
AND (vItemFk IS NULL OR ieo.itemFk = vItemFk) AND (vItemFk IS NULL OR ieo.itemFk = vItemFk)
AND NOT (ieo.shipped > util.VN_CURDATE() AND i.isFloramondo)
) sub ) sub
GROUP BY itemFk GROUP BY itemFk
HAVING stock; HAVING stock;

View File

@ -41,7 +41,6 @@ BEGIN
) currencyBalance ) currencyBalance
FROM ( FROM (
SELECT NULL bankFk, SELECT NULL bankFk,
NULL bank,
ii.companyFk, ii.companyFk,
ii.serial, ii.serial,
ii.id, ii.id,
@ -75,7 +74,6 @@ BEGIN
GROUP BY iid.id, ii.id GROUP BY iid.id, ii.id
UNION ALL UNION ALL
SELECT p.bankFk, SELECT p.bankFk,
a.bank,
p.companyFk, p.companyFk,
NULL, NULL,
p.id, p.id,
@ -111,7 +109,6 @@ BEGIN
AND (vIsConciliated = p.isConciliated OR NOT vIsConciliated) AND (vIsConciliated = p.isConciliated OR NOT vIsConciliated)
UNION ALL UNION ALL
SELECT NULL, SELECT NULL,
NULL bankFk,
companyFk, companyFk,
NULL, NULL,
se.id, se.id,
@ -139,7 +136,6 @@ BEGIN
AND (vIsConciliated = se.isConciliated OR NOT vIsConciliated) AND (vIsConciliated = se.isConciliated OR NOT vIsConciliated)
UNION ALL UNION ALL
SELECT NULL bankFk, SELECT NULL bankFk,
NULL,
e.companyFk, e.companyFk,
'E' serial, 'E' serial,
e.invoiceNumber id, e.invoiceNumber id,
@ -158,7 +154,7 @@ BEGIN
JOIN travel tr ON tr.id = e.travelFk JOIN travel tr ON tr.id = e.travelFk
JOIN currency c ON c.id = e.currencyFk JOIN currency c ON c.id = e.currencyFk
WHERE e.supplierFk = vSupplierFk WHERE e.supplierFk = vSupplierFk
AND tr.landed >= util.VN_CURDATE() AND tr.landed >= CURDATE()
AND e.invoiceInFk IS NULL AND e.invoiceInFk IS NULL
AND vHasEntries AND vHasEntries
ORDER BY (dated IS NULL AND NOT isBooked), ORDER BY (dated IS NULL AND NOT isBooked),

View File

@ -21,6 +21,9 @@ BEGIN
IFNULL(sat.supplierFk, su.id) supplierFk, IFNULL(sat.supplierFk, su.id) supplierFk,
t.landed t.landed
FROM ticket t FROM ticket t
JOIN ticketState ts ON ts.ticketFk = t.id
JOIN `state` s ON s.id = ts.stateFk
JOIN alertLevel al ON al.id = s.alertLevel
JOIN client c ON c.id = t.clientFk JOIN client c ON c.id = t.clientFk
JOIN `address` a ON a.id = t.addressFk JOIN `address` a ON a.id = t.addressFk
JOIN province p ON p.id = a.provinceFk JOIN province p ON p.id = a.provinceFk
@ -37,7 +40,8 @@ BEGIN
LEFT JOIN agency ag ON ag.id = am.agencyFk LEFT JOIN agency ag ON ag.id = am.agencyFk
LEFT JOIN supplierAgencyTerm sat ON sat.agencyFk = ag.id LEFT JOIN supplierAgencyTerm sat ON sat.agencyFk = ag.id
AND wo.isFreelance AND wo.isFreelance
WHERE co.code <> 'ES' WHERE al.code IN ('PACKED', 'DELIVERED')
AND co.code <> 'ES'
AND am.name <> 'ABONO' AND am.name <> 'ABONO'
AND w.code = 'ALG' AND w.code = 'ALG'
AND t.id = vSelf AND t.id = vSelf

View File

@ -16,9 +16,5 @@ BEGIN
IF NEW.awbFk IS NOT NULL THEN IF NEW.awbFk IS NOT NULL THEN
CALL travel_throwAwb(NEW.id); CALL travel_throwAwb(NEW.id);
END IF; END IF;
IF NEW.availabled < NEW.landed THEN
CALL util.throw('The travel availabled cannot be earlier than landed');
END IF;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -40,9 +40,5 @@ BEGIN
IF (NOT(NEW.awbFk <=> OLD.awbFk)) AND NEW.awbFk IS NOT NULL THEN IF (NOT(NEW.awbFk <=> OLD.awbFk)) AND NEW.awbFk IS NOT NULL THEN
CALL travel_throwAwb(NEW.id); CALL travel_throwAwb(NEW.id);
END IF; END IF;
IF NEW.availabled < NEW.landed THEN
CALL util.throw('The travel availabled cannot be earlier than landed');
END IF;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -1,9 +0,0 @@
CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`agencyModeIncoming` AS
SELECT
am.id,
am.name
FROM `vn`.`agencyMode` AS am
JOIN `vn`.`agencyIncoming` AS ai
ON am.id = ai.agencyModeFk;

View File

@ -7,8 +7,7 @@ AS SELECT `t`.`warehouseInFk` AS `warehouseInFk`,
`b`.`quantity` AS `quantity`, `b`.`quantity` AS `quantity`,
`t`.`isReceived` AS `isReceived`, `t`.`isReceived` AS `isReceived`,
`t`.`isRaid` AS `isVirtualStock`, `t`.`isRaid` AS `isVirtualStock`,
`e`.`id` AS `entryFk`, `e`.`id` AS `entryFk`
`t`.`availabled`
FROM ( FROM (
( (
`vn`.`buy` `b` `vn`.`buy` `b`

View File

@ -7,9 +7,9 @@ ALTER TABLE vn.invoiceOut ADD CONSTRAINT invoiceOut_customsAgentFk FOREIGN KEY (
ALTER TABLE vn.invoiceOut ADD CONSTRAINT invoiceOut_incotermsFk FOREIGN KEY (incotermsFk) ALTER TABLE vn.invoiceOut ADD CONSTRAINT invoiceOut_incotermsFk FOREIGN KEY (incotermsFk)
REFERENCES vn.incoterms (`code`) ON DELETE RESTRICT ON UPDATE CASCADE; REFERENCES vn.incoterms (`code`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- UPDATE vn.invoiceOut io UPDATE vn.invoiceOut io
-- JOIN vn.client c ON c.id = io.clientFk JOIN vn.client c ON c.id = io.clientFk
-- JOIN vn.ticket t ON t.clientFk = c.id JOIN vn.ticket t ON t.clientFk = c.id
-- JOIN vn.address a ON a.id = t.addressFk JOIN vn.address a ON a.id = t.addressFk
-- SET io.customsAgentFk = a.customsAgentFk, SET io.customsAgentFk = a.customsAgentFk,
-- io.incotermsFk = a.incotermsFk; io.incotermsFk = a.incotermsFk;

View File

@ -1,10 +0,0 @@
UPDATE vn.town t
LEFT JOIN vn.zoneGeo zg ON zg.id = t.geoFk
SET t.geoFk = NULL
WHERE zg.id IS NULL;
ALTER TABLE vn.town
ADD CONSTRAINT town_zoneGeo_FK FOREIGN KEY (geoFk)
REFERENCES vn.zoneGeo(id)
ON DELETE RESTRICT
ON UPDATE CASCADE;

View File

@ -1,10 +0,0 @@
UPDATE vn.postCode pc
LEFT JOIN vn.zoneGeo zg ON zg.id = pc.geoFk
SET pc.geoFk = NULL
WHERE zg.id IS NULL;
ALTER TABLE vn.postCode
ADD CONSTRAINT postCode_zoneGeo_FK FOREIGN KEY (geoFk)
REFERENCES vn.zoneGeo(id)
ON DELETE RESTRICT
ON UPDATE CASCADE;

View File

@ -1,10 +0,0 @@
UPDATE vn.province p
LEFT JOIN vn.zoneGeo zg ON zg.id = p.geoFk
SET p.geoFk = NULL
WHERE zg.id IS NULL;
ALTER TABLE vn.province
ADD CONSTRAINT province_zoneGeo_FK FOREIGN KEY (geoFk)
REFERENCES vn.zoneGeo(id)
ON DELETE RESTRICT
ON UPDATE CASCADE;

View File

@ -1,19 +0,0 @@
INSERT INTO account.`role` (name,description,hasLogin)
VALUES ('deliveryFreelancer','Repartidor autónomo',1);
INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
VALUES
('Route', 'getTickets', 'READ', 'ALLOW', 'ROLE', 'deliveryFreelancer'),
('AgencyTerm', 'filter', 'READ', 'ALLOW', 'ROLE', 'deliveryFreelancer'),
('Route', 'summary', 'READ', 'ALLOW', 'ROLE', 'deliveryFreelancer'),
('Route', 'getRouteByAgency', 'WRITE', 'ALLOW', 'ROLE', 'deliveryFreelancer'),
('Route','filter','READ','ALLOW','ROLE','deliveryFreelancer'),
('UserConfig','getUserConfig','*','ALLOW','ROLE','deliveryFreelancer'),
('Route', 'getTickets', 'READ', 'ALLOW', 'ROLE', 'deliveryFreelancer'),
('Route','guessPriority','WRITE','ALLOW','ROLE','deliveryFreelancer'),
('Route','getDeliveryPoint','READ','ALLOW','ROLE','deliveryFreelancer'),
('Route', 'findById', 'READ', 'ALLOW', 'ROLE', 'deliveryFreelancer'),
('Route','sendSms','WRITE','ALLOW','ROLE','deliveryFreelancer'),
('Ticket','updateAttributes','WRITE','ALLOW','ROLE','deliveryFreelancer'),
('Client','findById','READ','ALLOW','ROLE','deliveryFreelancer');
;

View File

@ -1,13 +0,0 @@
use `vn`;
DELETE ai from
`vn`.`agencyIncoming` ai
LEFT JOIN `vn`.`agencyMode` am ON
am.id = ai.agencyModeFk
WHERE am.id IS null;
ALTER TABLE `vn`.`agencyIncoming`
ADD CONSTRAINT `fk_agencyIncoming_agencyMode`
FOREIGN KEY (`agencyModeFk`)
REFERENCES `agencyMode`(`id`)
ON DELETE CASCADE
ON UPDATE CASCADE;

View File

@ -1,7 +0,0 @@
ALTER TABLE `vn`.`travelThermograph`
ADD COLUMN `agencyModeFk` INT(11) NULL AFTER `editorFk`,
ADD CONSTRAINT `travelThermograph_agencyIncoming_fk`
FOREIGN KEY (`agencyModeFk`)
REFERENCES `agencyIncoming`(`agencyModeFk`)
ON DELETE RESTRICT
ON UPDATE CASCADE;

View File

@ -1,2 +0,0 @@
ALTER TABLE `vn`.`tag`
ADD COLUMN IF NOT EXISTS `validationRegex` varchar(50) DEFAULT NULL;

View File

@ -1 +0,0 @@
ALTER TABLE vn.address MODIFY COLUMN isEqualizated tinyint(1) NULL;

View File

@ -1,3 +0,0 @@
-- Place your SQL code here
ALTER TABLE vn.travel ADD IF NOT EXISTS availabled DATETIME NULL
COMMENT 'Indicates the moment in time when the goods become available for picking';

View File

@ -1,2 +0,0 @@
INSERT IGNORE INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
VALUES('Entry', 'transfer', 'WRITE', 'ALLOW', 'ROLE', 'coolerBoss');

View File

@ -0,0 +1,65 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('Client defaulter path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('insurance', 'client');
await page.accessToSection('client.defaulter');
});
afterAll(async() => {
await browser.close();
});
it('should count the amount of clients in the turns section', async() => {
const result = await page.countElement(selectors.clientDefaulter.anyClient);
expect(result).toEqual(6);
});
it('should check contain expected client', async() => {
const clientName =
await page.waitToGetProperty(selectors.clientDefaulter.firstClientName, 'innerText');
const salesPersonName =
await page.waitToGetProperty(selectors.clientDefaulter.firstSalesPersonName, 'innerText');
expect(clientName).toEqual('Ororo Munroe');
expect(salesPersonName).toEqual('salesperson');
});
it('should first observation not changed', async() => {
const expectedObservation = 'Madness, as you know, is like gravity, all it takes is a little push';
const result = await page.waitToGetProperty(selectors.clientDefaulter.firstObservation, 'value');
expect(result).toContain(expectedObservation);
});
it('should not add empty observation', async() => {
await page.waitToClick(selectors.clientDefaulter.allDefaulterCheckbox);
await page.waitToClick(selectors.clientDefaulter.addObservationButton);
await page.write(selectors.clientDefaulter.observation, '');
await page.waitToClick(selectors.clientDefaulter.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toContain(`The message can't be empty`);
});
it('should checked all defaulters', async() => {
await page.loginAndModule('insurance', 'client');
await page.accessToSection('client.defaulter');
await page.waitToClick(selectors.clientDefaulter.allDefaulterCheckbox);
});
it('should add observation for all clients', async() => {
await page.waitToClick(selectors.clientDefaulter.addObservationButton);
await page.write(selectors.clientDefaulter.observation, 'My new observation');
await page.waitToClick(selectors.clientDefaulter.saveButton);
});
});

View File

@ -43,14 +43,6 @@ module.exports = Self => {
arg: 'postcode', arg: 'postcode',
type: 'string', type: 'string',
}, },
{
arg: 'sageTransactionTypeFk',
type: 'number',
},
{
arg: 'sageTaxTypeFk',
type: 'number',
},
{ {
arg: 'provinceFk', arg: 'provinceFk',
type: 'number', type: 'number',
@ -87,10 +79,6 @@ module.exports = Self => {
return /^\d+$/.test(value) return /^\d+$/.test(value)
? {'c.id': {inq: value}} ? {'c.id': {inq: value}}
: {'c.name': {like: `%${value}%`}}; : {'c.name': {like: `%${value}%`}};
case 'sageTaxTypeFk':
return {'sti.CodigoIva': value};
case 'sageTransactionTypeFk':
return {'stt.CodigoTransaccion': value};
case 'name': case 'name':
case 'salesPersonFk': case 'salesPersonFk':
case 'fi': case 'fi':

View File

@ -157,52 +157,4 @@ describe('Address updateAddress', () => {
throw e; throw e;
} }
}); });
it('should update ticket observations when updateObservations is true', async() => {
const tx = await models.Client.beginTransaction({});
const client = 1103;
const address = 123;
const ticket = 31;
const observationType = 3;
const salesAssistantId = 21;
const addressObservation = 'nuevo texto';
const ticketObservation = 'texto a modificar';
try {
const options = {transaction: tx};
ctx.req.accessToken.userId = salesAssistantId;
ctx.args = {
updateObservations: true,
incotermsFk: incotermsId,
provinceFk: provinceId,
customsAgentFk: customAgentOneId
};
await models.AddressObservation.create({
addressFk: address,
observationTypeFk: observationType,
description: addressObservation
}, options);
await models.TicketObservation.create({
ticketFk: ticket,
observationTypeFk: observationType,
description: ticketObservation
}, options);
await models.Client.updateAddress(ctx, client, address, options);
const updatedObservation = await models.TicketObservation.findOne({
where: {ticketFk: ticket, observationTypeFk: observationType}
}, options);
expect(updatedObservation.description).toEqual(addressObservation);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
}); });

View File

@ -80,10 +80,6 @@ module.exports = function(Self) {
{ {
arg: 'latitude', arg: 'latitude',
type: 'any', type: 'any',
},
{
arg: 'updateObservations',
type: 'boolean'
} }
], ],
returns: { returns: {
@ -139,17 +135,6 @@ module.exports = function(Self) {
delete args.ctx; // Remove unwanted properties delete args.ctx; // Remove unwanted properties
const updatedAddress = await address.updateAttributes(ctx.args, myOptions); const updatedAddress = await address.updateAttributes(ctx.args, myOptions);
if (args.updateObservations) {
const ticket = await Self.rawSql(`
UPDATE ticketObservation to2
JOIN ticket t ON t.id = to2.ticketFk
JOIN address a ON a.id = t.addressFk
JOIN addressObservation ao ON ao.addressFk = a.id
SET to2.description = ao.description
WHERE ao.observationTypeFk = to2.observationTypeFk
AND a.id = ?
AND t.shipped >= util.VN_CURDATE()`, [addressId], myOptions);
}
return updatedAddress; return updatedAddress;
}; };

View File

@ -21,7 +21,7 @@ module.exports = Self => {
} }
], ],
returns: { returns: {
type: 'object', type: ['object'],
root: true root: true
}, },
http: { http: {
@ -41,28 +41,23 @@ module.exports = Self => {
switch (param) { switch (param) {
case 'search': case 'search':
return {or: [ return {or: [
{'c.id': value}, {'d.clientFk': value},
{'c.name': {like: `%${value}%`}} {'d.clientName': {like: `%${value}%`}}
]}; ]};
} }
}); });
const date = Date.vnNew(); filter = mergeFilters(ctx.args.filter, {where});
date.setHours(0, 0, 0, 0);
filter = mergeFilters({where: {'d.created': date, 'd.amount': {gt: 0}}}, ctx.args.filter);
filter = mergeFilters(filter, {where});
const stmts = []; const stmts = [];
let stmt = new ParameterizedSQL( const date = Date.vnNew();
`CREATE OR REPLACE TEMPORARY TABLE tmp.defaulters date.setHours(0, 0, 0, 0);
WITH clientObservations AS const stmt = new ParameterizedSQL(
(SELECT clientFk,text, created, workerFk `SELECT *
FROM vn.clientObservation FROM (
GROUP BY clientFk SELECT
ORDER BY created DESC DISTINCT c.id clientFk,
)SELECT c.id clientFk,
c.name clientName, c.name clientName,
c.salesPersonFk, c.salesPersonFk,
c.businessTypeFk = 'worker' isWorker, c.businessTypeFk = 'worker' isWorker,
@ -85,43 +80,36 @@ module.exports = Self => {
JOIN client c ON c.id = d.clientFk JOIN client c ON c.id = d.clientFk
JOIN country cn ON cn.id = c.countryFk JOIN country cn ON cn.id = c.countryFk
JOIN payMethod pm ON pm.id = c.payMethodFk JOIN payMethod pm ON pm.id = c.payMethodFk
LEFT JOIN clientObservations co ON co.clientFk = c.id LEFT JOIN clientObservation co ON co.clientFk = c.id
LEFT JOIN account.user u ON u.id = c.salesPersonFk LEFT JOIN account.user u ON u.id = c.salesPersonFk
LEFT JOIN account.user uw ON uw.id = co.workerFk LEFT JOIN account.user uw ON uw.id = co.workerFk
LEFT JOIN ( LEFT JOIN (
SELECT r1.started, r1.clientFk, r1.finished SELECT r1.started, r1.clientFk, r1.finished
FROM recovery r1 FROM recovery r1
JOIN ( JOIN (
SELECT MAX(started) maxStarted, clientFk SELECT MAX(started) AS maxStarted, clientFk
FROM recovery FROM recovery
GROUP BY clientFk GROUP BY clientFk
) r2 ON r1.clientFk = r2.clientFk ) r2 ON r1.clientFk = r2.clientFk
AND r1.started = r2.maxStarted AND r1.started = r2.maxStarted
WHERE r1.finished
GROUP BY r1.clientFk
) r ON r.clientFk = c.id ) r ON r.clientFk = c.id
LEFT JOIN workerDepartment wd ON wd.workerFk = u.id LEFT JOIN workerDepartment wd ON wd.workerFk = u.id
LEFT JOIN department dp ON dp.id = wd.departmentFk`); LEFT JOIN department dp ON dp.id = wd.departmentFk
WHERE
d.created = ?
AND d.amount > 0
ORDER BY co.created DESC) d`
, [date]);
stmt.merge(conn.makeWhere(filter.where)); stmt.merge(conn.makeWhere(filter.where));
stmts.push(stmt); stmt.merge(`GROUP BY d.clientFk`);
stmt = new ParameterizedSQL(`
SELECT SUM(amount) amount
FROM tmp.defaulters
`);
stmts.push(stmt);
stmt = new ParameterizedSQL(`
SELECT *
FROM tmp.defaulters
`);
stmt.merge(conn.makeOrderBy(filter.order)); stmt.merge(conn.makeOrderBy(filter.order));
stmt.merge(conn.makeLimit(filter));
const itemsIndex = stmts.push(stmt) - 1; const itemsIndex = stmts.push(stmt) - 1;
const sql = ParameterizedSQL.join(stmts, ';'); const sql = ParameterizedSQL.join(stmts, ';');
const result = await conn.executeStmt(sql, myOptions); const result = await conn.executeStmt(sql, myOptions);
return {defaulters: result[itemsIndex], amount: result[itemsIndex - 1][0].amount}; return itemsIndex === 0 ? result : result[itemsIndex];
}; };
}; };

View File

@ -11,10 +11,10 @@ describe('defaulter filter()', () => {
const ctx = {req: {accessToken: {userId: authUserId}}, args: {filter: filter}}; const ctx = {req: {accessToken: {userId: authUserId}}, args: {filter: filter}};
const result = await models.Defaulter.filter(ctx, null, options); const result = await models.Defaulter.filter(ctx, null, options);
const firstRow = result.defaulters[0]; const firstRow = result[0];
expect(firstRow.clientFk).toEqual(1101); expect(firstRow.clientFk).toEqual(1101);
expect(result.defaulters.length).toEqual(5); expect(result.length).toEqual(5);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {
@ -31,7 +31,7 @@ describe('defaulter filter()', () => {
const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 1101}}; const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 1101}};
const result = await models.Defaulter.filter(ctx, null, options); const result = await models.Defaulter.filter(ctx, null, options);
const firstRow = result.defaulters[0]; const firstRow = result[0];
expect(firstRow.clientFk).toEqual(1101); expect(firstRow.clientFk).toEqual(1101);
@ -50,7 +50,7 @@ describe('defaulter filter()', () => {
const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 'Petter Parker'}}; const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 'Petter Parker'}};
const result = await models.Defaulter.filter(ctx, null, options); const result = await models.Defaulter.filter(ctx, null, options);
const firstRow = result.defaulters[0]; const firstRow = result[0];
expect(firstRow.clientName).toEqual('Petter Parker'); expect(firstRow.clientName).toEqual('Petter Parker');
@ -60,23 +60,4 @@ describe('defaulter filter()', () => {
throw e; throw e;
} }
}); });
it('should return the defaulter the sum of every defaulters', async() => {
const tx = await models.Defaulter.beginTransaction({});
try {
const options = {transaction: tx};
const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 1101}};
const {defaulters, amount} = await models.Defaulter.filter(ctx, null, options);
const total = defaulters.reduce((total, row) => total + row.amount, 0);
expect(total).toEqual(amount);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
}); });

View File

@ -1,2 +1,200 @@
<vn-crud-model
vn-id="model"
url="Defaulters/filter"
filter="::$ctrl.filter"
limit="20"
order="amount DESC"
data="$ctrl.defaulters"
on-data-change="$ctrl.reCheck()"
auto-load="true">
</vn-crud-model>
<vn-portal slot="topbar">
<vn-searchbar
vn-focus
placeholder="Search client"
info="Search client by id or name"
auto-state="false"
model="model">
</vn-searchbar>
</vn-portal>
<vn-card> <vn-card>
<smart-table
model="model"
options="$ctrl.smartTableOptions"
expr-builder="$ctrl.exprBuilder(param, value)">
<slot-actions>
<div>
<div class="totalBox" style="text-align: center;">
<h6 translate>Total</h6>
<vn-label-value
label="Balance due"
value="{{$ctrl.balanceDueTotal | currency: 'EUR': 2}}">
</vn-label-value>
</div>
</div>
<div class="vn-pa-md">
<vn-button
disabled="$ctrl.checked.length == 0"
ng-click="notesDialog.show()"
name="notesDialog"
vn-tooltip="Add observation"
icon="icon-notes">
</vn-button>
</div>
</slot-actions>
<slot-table>
<table>
<thead>
<tr>
<th shrink>
<vn-multi-check
model="model">
</vn-multi-check>
</th>
<th field="clientFk">
<span translate>Client</span>
</th>
<th field="isWorker">
<span translate>Es trabajador</span>
</th>
<th field="salesPersonFk">
<span translate>Comercial</span>
</th>
<th field="countryFk">
<span translate>Country</span>
</th>
<th field="payMethod"
vn-tooltip="Pay Method">
<span translate>P.Method</span>
</th>
<th
field="amount"
vn-tooltip="Balance due">
<span translate>Balance D.</span>
</th>
<th
field="workerFk"
vn-tooltip="Worker who made the last observation">
<span translate>Author</span>
</th>
<th field="observation" expand>
<span translate>Last observation</span>
</th>
<th
vn-tooltip="Last observation date"
field="created">
<span translate>L. O. Date</span>
</th>
<th
vn-tooltip="Credit insurance"
field="creditInsurance"
shrink>
<span translate>Credit I.</span>
</th>
<th field="defaulterSinced">
<span translate>From</span>
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="defaulter in $ctrl.defaulters">
<td shrink>
<vn-check
ng-model="defaulter.checked"
on-change="$ctrl.saveChecked(defaulter.clientFk)"
vn-click-stop>
</vn-check>
</td>
<td title="{{::defaulter.clientName}}">
<span
vn-click-stop="clientDescriptor.show($event, defaulter.clientFk)"
title ="{{::defaulter.clientName}}"
class="link">
{{::defaulter.clientName}}
</span>
</td>
<td>
<vn-check
ng-model="defaulter.isWorker"
disabled="true">
</vn-check>
</td>
<td>
<span
title="{{::defaulter.salesPersonName}}"
vn-click-stop="workerDescriptor.show($event, defaulter.salesPersonFk)"
class="link">
{{::defaulter.salesPersonName | dashIfEmpty}}
</span>
</td>
<td>
{{::defaulter.country}}
</td>
<td>
{{::defaulter.payMethod}}
</td>
<td>{{::defaulter.amount | currency: 'EUR': 2}}</td>
<td>
<span
title="{{::defaulter.workerName}}"
vn-click-stop="workerDescriptor.show($event, defaulter.workerFk)"
class="link">
{{::defaulter.workerName | dashIfEmpty}}
</span>
</td>
<td expand>
<vn-textarea
vn-three
disabled="true"
ng-model="defaulter.observation">
</vn-textarea>
</td>
<td shrink-date>
<span class="chip {{::$ctrl.chipColor(defaulter.created)}}">
{{::defaulter.created | date: 'dd/MM/yyyy'}}
</span>
</td>
<td shrink>{{::defaulter.creditInsurance | currency: 'EUR': 2}}</td>
<td shrink-date>{{::defaulter.defaulterSinced | date: 'dd/MM/yyyy'}}</td>
</tr>
</tbody>
</table>
</slot-table>
</smart-table>
</vn-card> </vn-card>
<vn-client-descriptor-popover
vn-id="client-descriptor">
</vn-client-descriptor-popover>
<vn-worker-descriptor-popover
vn-id="worker-descriptor">
</vn-worker-descriptor-popover>
<vn-popup vn-id="dialog-summary-client">
<vn-client-summary
client="$ctrl.clientSelected">
</vn-client-summary>
</vn-popup>
<!-- Dialog of add notes button -->
<vn-dialog
vn-id="notesDialog"
on-accept="$ctrl.onResponse()">
<tpl-body>
<section class="SMSDialog">
<h5 class="vn-py-sm">{{$ctrl.$t('Add observation to all selected clients', {total: $ctrl.checked.length})}}</h5>
<vn-horizontal>
<vn-textarea vn-one
vn-id="message"
label="Message"
ng-model="$ctrl.defaulter.observation"
rows="3"
required="true"
rule>
</vn-textarea>
</vn-horizontal>
</section>
</tpl-body>
<tpl-buttons>
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
<button response="accept" translate>Save</button>
</tpl-buttons>
</vn-dialog>

View File

@ -1,13 +1,199 @@
import ngModule from '../module'; import ngModule from '../module';
import Section from 'salix/components/section'; import Section from 'salix/components/section';
import UserError from 'core/lib/user-error';
export default class Controller extends Section { export default class Controller extends Section {
constructor($element, $) { constructor($element, $) {
super($element, $); super($element, $);
this.defaulter = {};
this.defaulters = [];
this.checkedDefaulers = [];
this.smartTableOptions = {
activeButtons: {
search: true
},
columns: [
{
field: 'clientFk',
autocomplete: {
url: 'Clients',
showField: 'name',
valueField: 'id'
} }
async $onInit() { }, {
this.$state.go('customer.defaulter', {id: this.$params.id}); field: 'salesPersonFk',
window.location.href = await this.vnApp.getUrl(`customer/defaulter`); autocomplete: {
url: 'Workers/activeWithInheritedRole',
where: `{role: 'salesPerson'}`,
searchFunction: '{firstName: $search}',
showField: 'name',
valueField: 'id',
}
}, {
field: 'countryFk',
autocomplete: {
url: 'Countries',
showField: 'country',
valueField: 'id'
}
}, {
field: 'payMethodFk',
autocomplete: {
showField: 'name',
valueField: 'id'
}
},
{
field: 'workerFk',
autocomplete: {
url: 'Workers/activeWithInheritedRole',
searchFunction: '{firstName: $search}',
showField: 'name',
valueField: 'id',
}
},
{
field: 'observation',
searchable: false
},
{
field: 'isWorker',
checkbox: true,
},
{
field: 'created',
datepicker: true
},
{
field: 'defaulterSinced',
datepicker: true
}
]
};
this.getBalanceDueTotal();
}
set defaulters(value) {
if (!value || !value.length) return;
this._defaulters = value;
}
get defaulters() {
return this._defaulters;
}
get checked() {
const clients = this.$.model.data || [];
const checkedLines = [];
for (let defaulter of clients) {
if (defaulter.checked)
checkedLines.push(defaulter);
}
return checkedLines;
}
saveChecked(clientId) {
this.checkedDefaulers = this.checkedDefaulers.includes(clientId) ?
this.checkedDefaulers.filter(id => id !== clientId) : [...this.checkedDefaulers, clientId];
}
reCheck() {
if (!this.$.model.data || !this.checkedDefaulers.length) return;
this.$.model.data.forEach(defaulter => {
defaulter.checked = this.checkedDefaulers.includes(defaulter.clientFk);
});
}
getBalanceDueTotal() {
this.$http.get('Defaulters/filter')
.then(res => {
if (!res.data) return 0;
this.balanceDueTotal = res.data.reduce(
(accumulator, currentValue) => {
return accumulator + (currentValue['amount'] || 0);
}, 0);
});
}
chipColor(date) {
const day = 24 * 60 * 60 * 1000;
const today = Date.vnNew();
today.setHours(0, 0, 0, 0);
const observationShipped = new Date(date);
observationShipped.setHours(0, 0, 0, 0);
const difference = today - observationShipped;
if (difference > (day * 20))
return 'alert';
if (difference > (day * 10))
return 'warning';
}
onResponse() {
if (!this.defaulter.observation)
throw new UserError(`The message can't be empty`);
const params = [];
for (let defaulter of this.checked) {
params.push({
text: this.defaulter.observation,
clientFk: defaulter.clientFk
});
}
this.$http.post(`ClientObservations`, params) .then(() => {
this.vnApp.showSuccess(this.$t('Observation saved!'));
this.sendMail();
this.$state.reload();
});
}
sendMail() {
const params = {
defaulters: this.checked,
observation: this.defaulter.observation,
};
this.$http.post(`Defaulters/observationEmail`, params);
}
exprBuilder(param, value) {
switch (param) {
case 'isWorker':
return {isWorker: value};
case 'creditInsurance':
case 'amount':
case 'clientFk':
case 'workerFk':
case 'countryFk':
case 'payMethod':
case 'salesPersonFk':
return {[`d.${param}`]: value};
case 'created':
return {'d.created': {
between: this.dateRange(value)}
};
case 'defaulterSinced':
return {'d.defaulterSinced': {
between: this.dateRange(value)}
};
}
}
dateRange(value) {
const minHour = new Date(value);
minHour.setHours(0, 0, 0, 0);
const maxHour = new Date(value);
maxHour.setHours(23, 59, 59, 59);
return [minHour, maxHour];
} }
} }

View File

@ -0,0 +1,179 @@
import './index';
import crudModel from 'core/mocks/crud-model';
describe('client defaulter', () => {
describe('Component vnClientDefaulter', () => {
let controller;
let $httpBackend;
beforeEach(ngModule('client'));
beforeEach(inject(($componentController, _$httpBackend_) => {
$httpBackend = _$httpBackend_;
const $element = angular.element('<vn-client-defaulter></vn-client-defaulter>');
controller = $componentController('vnClientDefaulter', {$element});
controller.$.model = crudModel;
controller.$.model.data = [
{clientFk: 1101, amount: 125},
{clientFk: 1102, amount: 500},
{clientFk: 1103, amount: 250}
];
}));
describe('checked() getter', () => {
it('should return the checked lines', () => {
const data = controller.$.model.data;
data[1].checked = true;
data[2].checked = true;
const checkedRows = controller.checked;
const firstCheckedRow = checkedRows[0];
const secondCheckedRow = checkedRows[1];
expect(firstCheckedRow.clientFk).toEqual(1102);
expect(secondCheckedRow.clientFk).toEqual(1103);
});
});
describe('chipColor()', () => {
it('should return undefined when the date is the present', () => {
let today = Date.vnNew();
let result = controller.chipColor(today);
expect(result).toEqual(undefined);
});
it('should return warning when the date is 10 days in the past', () => {
let pastDate = Date.vnNew();
pastDate = pastDate.setDate(pastDate.getDate() - 11);
let result = controller.chipColor(pastDate);
expect(result).toEqual('warning');
});
it('should return alert when the date is 20 days in the past', () => {
let pastDate = Date.vnNew();
pastDate = pastDate.setDate(pastDate.getDate() - 21);
let result = controller.chipColor(pastDate);
expect(result).toEqual('alert');
});
});
describe('onResponse()', () => {
it('should return error for empty message', () => {
let error;
try {
controller.onResponse();
} catch (e) {
error = e;
}
expect(error).toBeDefined();
expect(error.message).toBe(`The message can't be empty`);
});
it('should return saved message', () => {
const data = controller.$.model.data;
data[1].checked = true;
controller.defaulter = {observation: 'My new observation'};
const params = [{text: controller.defaulter.observation, clientFk: data[1].clientFk}];
jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expect('GET', `Defaulters/filter`).respond(200);
$httpBackend.expect('POST', `ClientObservations`, params).respond(200, params);
$httpBackend.expect('POST', `Defaulters/observationEmail`).respond(200);
controller.onResponse();
$httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Observation saved!');
});
});
describe('exprBuilder()', () => {
it('should search by sales person', () => {
const expr = controller.exprBuilder('salesPersonFk', '5');
expect(expr).toEqual({'d.salesPersonFk': '5'});
});
it('should search by client', () => {
const expr = controller.exprBuilder('clientFk', '5');
expect(expr).toEqual({'d.clientFk': '5'});
});
});
describe('getBalanceDueTotal()', () => {
it('should return balance due total', () => {
const defaulters = controller.$.model.data;
$httpBackend.when('GET', `Defaulters/filter`).respond(defaulters);
controller.getBalanceDueTotal();
$httpBackend.flush();
expect(controller.balanceDueTotal).toEqual(875);
});
});
describe('dateRange()', () => {
it('should return two dates with the hours at the start and end of the given date', () => {
const now = Date.vnNew();
const today = now.getDate();
const dateRange = controller.dateRange(now);
const start = dateRange[0].toString();
const end = dateRange[1].toString();
expect(start).toContain(today);
expect(start).toContain('00:00:00');
expect(end).toContain(today);
expect(end).toContain('23:59:59');
});
});
describe('reCheck()', () => {
it(`should recheck buys`, () => {
controller.$.model.data = [
{checked: false, clientFk: 1},
{checked: false, clientFk: 2},
{checked: false, clientFk: 3},
{checked: false, clientFk: 4},
];
controller.checkedDefaulers = [1, 2];
controller.reCheck();
expect(controller.$.model.data[0].checked).toEqual(true);
expect(controller.$.model.data[1].checked).toEqual(true);
expect(controller.$.model.data[2].checked).toEqual(false);
expect(controller.$.model.data[3].checked).toEqual(false);
});
});
describe('saveChecked()', () => {
it(`should check buy`, () => {
const buyCheck = 3;
controller.checkedDefaulers = [1, 2];
controller.saveChecked(buyCheck);
expect(controller.checkedDefaulers[2]).toEqual(buyCheck);
});
it(`should uncheck buy`, () => {
const buyUncheck = 3;
controller.checkedDefaulers = [1, 2, 3];
controller.saveChecked(buyUncheck);
expect(controller.checkedDefaulers[2]).toEqual(undefined);
});
});
});
});

View File

@ -0,0 +1,14 @@
Add observation: Añadir observación
Add observation to all selected clients: Añadir observación a {{total}} cliente(s) seleccionado(s)
Balance D.: Saldo V.
Credit I.: Crédito A.
Last observation: Última observación
L. O. Date: Fecha Ú. O.
Last observation date: Fecha última observación
Search client: Buscar clientes
Worker who made the last observation: Trabajador que ha realizado la última observación
Email sended!: Email enviado!
Observation saved!: Observación añadida!
P.Method: F.Pago
Pay Method: Forma de Pago
Country: Pais

View File

@ -1,43 +0,0 @@
const models = require('vn-loopback/server/server').models;
describe('Transfer merchandise from one entry to the next day()', () => {
it('should Transfer buys not located', async() => {
const tx = await models.ItemShelving.beginTransaction({});
const options = {transaction: tx};
try {
const id = 3;
const item = 8;
const buy = 6;
const originalEntry = 4;
const ctx = {req: {accessToken: {userId: 48}}};
const currentItemShelving = await models.ItemShelving.findOne({where: {id}}, options);
await currentItemShelving.updateAttributes({itemFk: item, buyFk: buy}, options);
const {newEntryFk} = await models.Entry.transfer(ctx, originalEntry, options);
const originalEntrybuys = await models.Buy.find({where: {entryFk: originalEntry}}, options);
const newEntrybuys = await models.Buy.find({where: {entryFk: newEntryFk}}, options);
const itemShelvingsWithBuys = await models.Buy.find({
include: {
relation: 'itemShelving',
scope: {
fields: ['id'],
},
},
where: {entryFk: originalEntry},
}, options);
const hasItemShelving = await itemShelvingsWithBuys.filter(buy => buy.itemShelving().length);
expect(newEntrybuys.length).toEqual(originalEntrybuys.length - hasItemShelving.length);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -1,46 +0,0 @@
module.exports = Self => {
Self.remoteMethodCtx('transfer', {
description: 'Transfer merchandise from one entry to the next day',
accessType: 'WRITE',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
http: {source: 'path'}
}
],
http: {
path: '/:id/transfer',
verb: 'POST'
},
returns: {
arg: 'newEntryFk',
type: 'number'
}
});
Self.transfer = async(ctx, id, options) => {
const myOptions = {userId: ctx.req.accessToken.userId};
let tx;
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
await Self.rawSql('CALL vn.entry_transfer(?, @vNewEntry)', [id], myOptions);
const [newEntryFk] = await Self.rawSql('SELECT @vNewEntry newEntryFk', null, myOptions);
if (tx) await tx.commit();
return newEntryFk;
} catch (e) {
if (tx) await tx.rollback();
throw e;
}
};
};

View File

@ -114,11 +114,6 @@
"type": "belongsTo", "type": "belongsTo",
"model": "Delivery", "model": "Delivery",
"foreignKey": "deliveryFk" "foreignKey": "deliveryFk"
},
"itemShelving": {
"type": "hasMany",
"model": "ItemShelving",
"foreignKey": "buyFk"
} }
} }
} }

View File

@ -12,7 +12,6 @@ module.exports = Self => {
require('../methods/entry/addFromPackaging')(Self); require('../methods/entry/addFromPackaging')(Self);
require('../methods/entry/addFromBuy')(Self); require('../methods/entry/addFromBuy')(Self);
require('../methods/entry/buyLabel')(Self); require('../methods/entry/buyLabel')(Self);
require('../methods/entry/transfer')(Self);
require('../methods/entry/labelSupplier')(Self); require('../methods/entry/labelSupplier')(Self);
require('../methods/entry/buyLabelSupplier')(Self); require('../methods/entry/buyLabelSupplier')(Self);

View File

@ -61,11 +61,6 @@
"type": "belongsTo", "type": "belongsTo",
"model": "Shelving", "model": "Shelving",
"foreignKey": "shelvingFk" "foreignKey": "shelvingFk"
},
"buy": {
"type": "belongsTo",
"model": "Buy",
"foreignKey": "buyFk"
} }
} }
} }

View File

@ -10,27 +10,4 @@ module.exports = Self => {
return new UserError(`Tag value cannot be blank`); return new UserError(`Tag value cannot be blank`);
return err; return err;
}); });
Self.observe('before save', async ctx => {
let tagFk;
let value;
if (ctx.isNewInstance) {
tagFk = ctx.instance.tagFk;
value = ctx.instance.value;
} else {
tagFk = ctx.currentInstance.tagFk;
value = ctx.data.value;
}
const models = Self.app.models;
const validTag = await models.Tag.findById(tagFk);
if (validTag.validationRegex) {
const regexString = validTag.validationRegex.replace(/\\\\/g, '\\');
const validExpresion = new RegExp(regexString);
if (value && !validExpresion.test(value))
throw new UserError('The value must be a number or a range of numbers');
}
});
}; };

View File

@ -30,9 +30,6 @@
"mysql": { "mysql": {
"columnName": "isQuantitatif" "columnName": "isQuantitatif"
} }
},
"validationRegex": {
"type": "string"
} }
}, },
"acls": [ "acls": [

View File

@ -18,7 +18,7 @@ describe('AgencyTerm filter()', () => {
const firstAgencyTerm = agencyTerms[0]; const firstAgencyTerm = agencyTerms[0];
expect(firstAgencyTerm.routeFk).toEqual(1); expect(firstAgencyTerm.routeFk).toEqual(1);
expect(agencyTerms.length).toEqual(7); expect(agencyTerms.length).toEqual(5);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {
@ -49,7 +49,7 @@ describe('AgencyTerm filter()', () => {
let result = await app.models.AgencyTerm.filter(ctx); let result = await app.models.AgencyTerm.filter(ctx);
expect(result.length).toEqual(4); expect(result.length).toEqual(2);
}); });
it('should return results matching "from" and "to"', async() => { it('should return results matching "from" and "to"', async() => {
@ -72,7 +72,7 @@ describe('AgencyTerm filter()', () => {
const results = await models.AgencyTerm.filter(ctx, options); const results = await models.AgencyTerm.filter(ctx, options);
expect(results.length).toBe(7); expect(results.length).toBe(5);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {
@ -90,7 +90,7 @@ describe('AgencyTerm filter()', () => {
let result = await app.models.AgencyTerm.filter(ctx); let result = await app.models.AgencyTerm.filter(ctx);
expect(result.length).toEqual(2); expect(result.length).toEqual(1);
expect(result[0].routeFk).toEqual(1); expect(result[0].routeFk).toEqual(1);
}); });
@ -103,7 +103,7 @@ describe('AgencyTerm filter()', () => {
let result = await app.models.AgencyTerm.filter(ctx); let result = await app.models.AgencyTerm.filter(ctx);
expect(result.length).toEqual(2); expect(result.length).toEqual(1);
expect(result[0].routeFk).toEqual(2); expect(result[0].routeFk).toEqual(2);
}); });
}); });

View File

@ -0,0 +1,109 @@
const app = require('vn-loopback/server/server');
const models = require('vn-loopback/server/server').models;
describe('AgencyTerm filter()', () => {
const authUserId = 9;
const today = Date.vnNew();
today.setHours(2, 0, 0, 0);
it('should return all results matching the filter', async() => {
const tx = await models.AgencyTerm.beginTransaction({});
try {
const options = {transaction: tx};
const filter = {};
const ctx = {req: {accessToken: {userId: authUserId}}};
const agencyTerms = await models.AgencyTerm.filter(ctx, filter, options);
const firstAgencyTerm = agencyTerms[0];
expect(firstAgencyTerm.routeFk).toEqual(1);
expect(agencyTerms.length).toEqual(5);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should return results matching "search" searching by integer', async() => {
let ctx = {
args: {
search: 1,
}
};
let result = await app.models.AgencyTerm.filter(ctx);
expect(result.length).toEqual(1);
expect(result[0].routeFk).toEqual(1);
});
it('should return results matching "search" searching by string', async() => {
let ctx = {
args: {
search: 'Plants SL',
}
};
let result = await app.models.AgencyTerm.filter(ctx);
expect(result.length).toEqual(2);
});
it('should return results matching "from" and "to"', async() => {
const tx = await models.Buy.beginTransaction({});
const options = {transaction: tx};
try {
const from = Date.vnNew();
from.setHours(0, 0, 0, 0);
const to = Date.vnNew();
to.setHours(23, 59, 59, 999);
const ctx = {
args: {
from: from,
to: to
}
};
const results = await models.AgencyTerm.filter(ctx, options);
expect(results.length).toBe(5);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should return results matching "agencyModeFk"', async() => {
let ctx = {
args: {
agencyModeFk: 1,
}
};
let result = await app.models.AgencyTerm.filter(ctx);
expect(result.length).toEqual(1);
expect(result[0].routeFk).toEqual(1);
});
it('should return results matching "agencyFk"', async() => {
let ctx = {
args: {
agencyFk: 2,
}
};
let result = await app.models.AgencyTerm.filter(ctx);
expect(result.length).toEqual(1);
expect(result[0].routeFk).toEqual(2);
});
});

View File

@ -87,8 +87,6 @@ module.exports = Self => {
Self.filter = async(ctx, filter) => { Self.filter = async(ctx, filter) => {
let conn = Self.dataSource.connector; let conn = Self.dataSource.connector;
const userId = ctx.req.accessToken.userId;
const models = Self.app.models;
let where = buildFilter(ctx.args, (param, value) => { let where = buildFilter(ctx.args, (param, value) => {
switch (param) { switch (param) {
@ -112,13 +110,6 @@ module.exports = Self => {
filter = mergeFilters(filter, {where}); filter = mergeFilters(filter, {where});
const worker = await models.Worker.findById(userId, {fields: ['isFreelance']});
const getMyRoute = await models.ACL.checkAccessAcl(ctx, 'Route', 'getRouteByAgency', 'WRITE');
if (userId && getMyRoute && worker.isFreelance) {
if (!filter.where) filter.where = {};
filter.where[`workerFk`] = userId;
}
let stmts = []; let stmts = [];
let stmt; let stmt;

View File

@ -8,32 +8,14 @@ describe('Route filter()', () => {
it('should return the routes matching "search"', async() => { it('should return the routes matching "search"', async() => {
const ctx = { const ctx = {
args: { args: {
search: 5, search: 1,
},
req: {
accessToken: {
userId: 9
}
} }
}; };
const result = await app.models.Route.filter(ctx); const result = await app.models.Route.filter(ctx);
expect(result.length).toEqual(1); expect(result.length).toEqual(1);
expect(result[0].id).toEqual(5); expect(result[0].id).toEqual(1);
});
it('should return all results matching the filter', async() => {
const ctx = {
req: {
accessToken: {
userId: 133
}
}
};
const result = await app.models.Route.filter(ctx);
expect(result.length).toEqual(3);
}); });
it('should return results matching "from" and "to"', async() => { it('should return results matching "from" and "to"', async() => {
@ -50,16 +32,12 @@ describe('Route filter()', () => {
args: { args: {
from: from, from: from,
to: to to: to
},
req: {
accessToken: {
userId: 9
}
} }
}; };
const results = await models.Route.filter(ctx, options); const results = await models.Route.filter(ctx, options);
expect(results.length).toBe(9); expect(results.length).toBe(7);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {
@ -72,11 +50,6 @@ describe('Route filter()', () => {
const ctx = { const ctx = {
args: { args: {
m3: 0.1, m3: 0.1,
},
req: {
accessToken: {
userId: 9
}
} }
}; };
@ -89,11 +62,6 @@ describe('Route filter()', () => {
const ctx = { const ctx = {
args: { args: {
description: 'third route', description: 'third route',
},
req: {
accessToken: {
userId: 9
}
} }
}; };
@ -106,33 +74,24 @@ describe('Route filter()', () => {
const ctx = { const ctx = {
args: { args: {
workerFk: 56, workerFk: 56,
},
req: {
accessToken: {
userId: 9
}
} }
}; };
const result = await app.models.Route.filter(ctx); const result = await app.models.Route.filter(ctx);
expect(result.length).toEqual(4); expect(result.length).toEqual(5);
}); });
it('should return the routes matching "warehouseFk"', async() => { it('should return the routes matching "warehouseFk"', async() => {
const ctx = { const ctx = {
args: { args: {
warehouseFk: 1, warehouseFk: 1,
},
req: {
accessToken: {
userId: 9
}
} }
}; };
let result = await app.models.Route.filter(ctx); let result = await app.models.Route.filter(ctx);
expect(result.length).toEqual(9); expect(result.length).toEqual(7);
ctx.args.warehouseFk = 2; ctx.args.warehouseFk = 2;
@ -145,13 +104,9 @@ describe('Route filter()', () => {
const ctx = { const ctx = {
args: { args: {
vehicleFk: 2, vehicleFk: 2,
},
req: {
accessToken: {
userId: 9
}
} }
}; };
const result = await app.models.Route.filter(ctx); const result = await app.models.Route.filter(ctx);
expect(result.length).toEqual(1); expect(result.length).toEqual(1);
@ -161,11 +116,6 @@ describe('Route filter()', () => {
const ctx = { const ctx = {
args: { args: {
agencyModeFk: 7, agencyModeFk: 7,
},
req: {
accessToken: {
userId: 9
}
} }
}; };

View File

@ -22,7 +22,7 @@ describe('route summary()', () => {
}); });
it(`should return a summary object containing it's worker`, async() => { it(`should return a summary object containing it's worker`, async() => {
const result = await app.models.Route.summary(2); const result = await app.models.Route.summary(1);
const worker = result.route.worker().user(); const worker = result.route.worker().user();
expect(worker.name).toEqual('delivery'); expect(worker.name).toEqual('delivery');

View File

@ -1,100 +0,0 @@
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
const {buildFilter, mergeFilters} = require('vn-loopback/util/filter');
module.exports = Self => {
Self.remoteMethodCtx('receipts', {
description: 'Find all suppliers matched by the filter',
accessType: 'READ',
accepts: [
{
arg: 'filter',
type: 'object',
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
http: {source: 'query'}
}, {
arg: 'supplierId',
type: 'number',
description: 'The supplier id',
},
{
arg: 'companyId',
type: 'number',
description: 'The company id',
},
{
arg: 'currencyFk',
type: 'number',
description: 'The currency',
default: 1,
},
{
arg: 'bankFk',
type: 'number',
description: 'The bank',
default: 1,
},
{
arg: 'orderBy',
type: 'string',
description: 'The supplier fiscal id',
enum: ['issued', ' bookEntried', ' booked', ' dueDate'],
},
{
arg: 'isConciliated',
default: false,
type: 'boolean',
},
],
returns: {
type: ['object'],
root: true
},
http: {
path: `/receipts`,
verb: 'GET'
}
});
Self.receipts = async(ctx, filter, options) => {
const conn = Self.dataSource.connector;
const myOptions = {userId: ctx.req.accessToken.userId};
const args = ctx.args;
if (typeof options == 'object')
Object.assign(myOptions, options);
const where = buildFilter(ctx.args, (param, value) => {
switch (param) {
case 'bankFk':
return {[param]: value};
}
});
let stmts = [];
stmts.push(new ParameterizedSQL('CALL vn.supplier_statementWithEntries(?,?,?,?,?,?)', [
args.supplierId,
args.currencyFk,
args.companyId,
args.orderBy ?? 'issued',
args.isConciliated ?? false,
false
]));
const stmt = new ParameterizedSQL(`
SELECT *
FROM tmp.supplierStatement`);
filter = mergeFilters(args.filter, {where});
stmt.merge(conn.makeSuffix(filter));
stmts.push(stmt);
stmts.push(`DROP TEMPORARY TABLE tmp.supplierStatement`);
const sql = ParameterizedSQL.join(stmts, ';');
const results = await conn.executeStmt(sql);
const resultsIndex = stmts.length - 2;
const result = results[resultsIndex];
return result;
};
};

View File

@ -8,7 +8,6 @@ module.exports = Self => {
require('../methods/supplier/updateFiscalData')(Self); require('../methods/supplier/updateFiscalData')(Self);
require('../methods/supplier/consumption')(Self); require('../methods/supplier/consumption')(Self);
require('../methods/supplier/freeAgencies')(Self); require('../methods/supplier/freeAgencies')(Self);
require('../methods/supplier/receipts')(Self);
require('../methods/supplier/campaignMetricsPdf')(Self); require('../methods/supplier/campaignMetricsPdf')(Self);
require('../methods/supplier/campaignMetricsEmail')(Self); require('../methods/supplier/campaignMetricsEmail')(Self);
require('../methods/supplier/newSupplier')(Self); require('../methods/supplier/newSupplier')(Self);

View File

@ -22,16 +22,14 @@ describe('Ticket transferClient()', () => {
it('should throw an error as the ticket is not editable', async() => { it('should throw an error as the ticket is not editable', async() => {
try { try {
const ticketId = 4; const ticketId = 4;
const addressFk = null; await models.Ticket.transferClient(ctx, ticketId, clientId, options);
await models.Ticket.transferClient(ctx, ticketId, clientId, addressFk, options);
} catch (e) { } catch (e) {
expect(e.message).toEqual('This ticket is locked'); expect(e.message).toEqual('This ticket is locked');
} }
}); });
it('should be assigned a different clientFk and nickname in the original ticket', async() => { it('should be assigned a different clientFk and nickname in the original ticket', async() => {
const addressFk = null; await models.Ticket.transferClient(ctx, 2, clientId, options);
await models.Ticket.transferClient(ctx, 2, clientId, addressFk, options);
const afterTransfer = await models.Ticket.findById(2, null, options); const afterTransfer = await models.Ticket.findById(2, null, options);
const client = await models.Client.findById(clientId, {fields: ['defaultAddressFk']}, options); const client = await models.Client.findById(clientId, {fields: ['defaultAddressFk']}, options);
const address = await models.Address.findById(client.defaultAddressFk, {fields: ['nickname']}, options); const address = await models.Address.findById(client.defaultAddressFk, {fields: ['nickname']}, options);
@ -41,8 +39,7 @@ describe('Ticket transferClient()', () => {
}); });
it('should be assigned a different clientFk and nickname in the original and refund ticket and claim', async() => { it('should be assigned a different clientFk and nickname in the original and refund ticket and claim', async() => {
const addressFk = null; await models.Ticket.transferClient(ctx, originalTicketId, clientId, options);
await models.Ticket.transferClient(ctx, originalTicketId, clientId, addressFk, options);
const [originalTicket, refundTicket] = await models.Ticket.find({ const [originalTicket, refundTicket] = await models.Ticket.find({
where: {id: {inq: [originalTicketId, refundTicketId]}} where: {id: {inq: [originalTicketId, refundTicketId]}}
@ -62,39 +59,4 @@ describe('Ticket transferClient()', () => {
expect(originalTicket.nickname).toEqual(address.nickname); expect(originalTicket.nickname).toEqual(address.nickname);
expect(refundTicket.nickname).toEqual(address.nickname); expect(refundTicket.nickname).toEqual(address.nickname);
}); });
it('should be assigned a different addressFk and nickname in the original and refund ticket', async() => {
const addressFk = 131;
await models.Ticket.transferClient(ctx, originalTicketId, clientId, addressFk, options);
const [originalTicket, refundTicket] = await models.Ticket.find({
where: {id: {inq: [originalTicketId, refundTicketId]}}
}, options);
const claim = await models.Claim.findOne({
where: {ticketFk: originalTicketId}
}, options);
const address = await models.Address.findById(addressFk, {fields: ['id', 'nickname', 'clientFk']}, options);
expect(originalTicket.clientFk).toEqual(clientId);
expect(originalTicket.clientFk).toEqual(address.clientFk);
expect(refundTicket.clientFk).toEqual(clientId);
expect(refundTicket.clientFk).toEqual(address.clientFk);
expect(claim.clientFk).toEqual(clientId);
expect(claim.clientFk).toEqual(address.clientFk);
expect(originalTicket.nickname).toEqual(address.nickname);
expect(refundTicket.nickname).toEqual(address.nickname);
});
it('should be thrown an error if the new address is not belong to the client', async() => {
const addressFk = 1;
try {
await models.Ticket.transferClient(ctx, originalTicketId, clientId, addressFk, options);
fail('Expected an error to be thrown, but none was thrown.');
} catch (e) {
expect(e.message).toEqual('The address does not belong to the client');
}
});
}); });

View File

@ -72,8 +72,7 @@ module.exports = Self => {
}, { }, {
relation: 'address', relation: 'address',
scope: { scope: {
fields: ['street', 'city', 'provinceFk', 'phone', 'mobile', fields: ['street', 'city', 'provinceFk', 'phone', 'mobile', 'postalCode', 'isEqualizated'],
'postalCode', 'isEqualizated', 'nickname'],
include: { include: {
relation: 'province', relation: 'province',
scope: { scope: {

View File

@ -1,4 +1,3 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('transferClient', { Self.remoteMethodCtx('transferClient', {
description: 'Transferring ticket to another client', description: 'Transferring ticket to another client',
@ -13,10 +12,6 @@ module.exports = Self => {
arg: 'clientFk', arg: 'clientFk',
type: 'number', type: 'number',
required: true, required: true,
}, {
arg: 'addressFk',
type: 'number',
required: false,
}], }],
http: { http: {
path: `/:id/transferClient`, path: `/:id/transferClient`,
@ -24,7 +19,7 @@ module.exports = Self => {
} }
}); });
Self.transferClient = async(ctx, id, clientFk, addressFk, options) => { Self.transferClient = async(ctx, id, clientFk, options) => {
const models = Self.app.models; const models = Self.app.models;
const myOptions = {}; const myOptions = {};
let tx; let tx;
@ -48,12 +43,10 @@ module.exports = Self => {
const client = await models.Client.findById(clientFk, const client = await models.Client.findById(clientFk,
{fields: ['id', 'defaultAddressFk']}, myOptions); {fields: ['id', 'defaultAddressFk']}, myOptions);
const address = await models.Address.findById(addressFk ? addressFk : client.defaultAddressFk, const address = await models.Address.findById(client.defaultAddressFk,
{fields: ['id', 'nickname', 'clientFk']}, myOptions); {fields: ['id', 'nickname']}, myOptions);
if (address.clientFk !== clientFk) throw new UserError('The address does not belong to the client'); const attributes = {clientFk, addressFk: client.defaultAddressFk, nickname: address.nickname};
const attributes = {clientFk, addressFk: address.id, nickname: address.nickname};
const tickets = []; const tickets = [];
const ticketIds = []; const ticketIds = [];

View File

@ -57,10 +57,6 @@ module.exports = Self => {
arg: 'hasFileAttached', arg: 'hasFileAttached',
type: 'Boolean', type: 'Boolean',
description: 'True if has an attached file' description: 'True if has an attached file'
}, {
arg: 'agencyModeFk',
type: 'Number',
description: 'Carrier'
}], }],
returns: {type: 'object', root: true}, returns: {type: 'object', root: true},
http: {path: `/:id/saveThermograph`, verb: 'POST'} http: {path: `/:id/saveThermograph`, verb: 'POST'}
@ -80,7 +76,6 @@ module.exports = Self => {
reference, reference,
description, description,
hasFileAttached, hasFileAttached,
agencyModeFk,
options options
) => { ) => {
const models = Self.app.models; const models = Self.app.models;
@ -124,7 +119,6 @@ module.exports = Self => {
minTemperature, minTemperature,
temperatureFk, temperatureFk,
warehouseFk: warehouseId, warehouseFk: warehouseId,
agencyModeFk,
}, myOptions); }, myOptions);
if (tx) await tx.commit(); if (tx) await tx.commit();

View File

@ -9,7 +9,6 @@ describe('Thermograph saveThermograph()', () => {
const maxTemperature = 30; const maxTemperature = 30;
const minTemperature = 10; const minTemperature = 10;
const temperatureFk = 'COOL'; const temperatureFk = 'COOL';
const agencyModeFk = 1;
let tx; let tx;
let options; let options;
@ -47,16 +46,13 @@ describe('Thermograph saveThermograph()', () => {
null, null,
null, null,
null, null,
null, null, options
agencyModeFk,
options
); );
expect(updatedThermograph.result).toEqual(state); expect(updatedThermograph.result).toEqual(state);
expect(updatedThermograph.maxTemperature).toEqual(maxTemperature); expect(updatedThermograph.maxTemperature).toEqual(maxTemperature);
expect(updatedThermograph.minTemperature).toEqual(minTemperature); expect(updatedThermograph.minTemperature).toEqual(minTemperature);
expect(updatedThermograph.temperatureFk).toEqual(temperatureFk); expect(updatedThermograph.temperatureFk).toEqual(temperatureFk);
expect(updatedThermograph.agencyModeFk).toEqual(agencyModeFk);
expect(updatedThermograph.dmsFk).toEqual(dmsFk); expect(updatedThermograph.dmsFk).toEqual(dmsFk);
}); });

View File

@ -22,8 +22,5 @@
}, },
"Temperature": { "Temperature": {
"dataSource": "vn" "dataSource": "vn"
},
"AgencyModeIncoming": {
"dataSource": "vn"
} }
} }

View File

@ -1,27 +0,0 @@
{
"name": "AgencyModeIncoming",
"base": "VnModel",
"options": {
"mysql": {
"table": "agencyModeIncoming"
}
},
"properties": {
"id": {
"type": "number",
"id": true,
"description": "Identifier"
},
"name": {
"type": "string"
}
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
}
]
}

View File

@ -58,11 +58,6 @@
"type": "belongsTo", "type": "belongsTo",
"model": "Thermograph", "model": "Thermograph",
"foreignKey": "thermographFk" "foreignKey": "thermographFk"
},
"agencyMode": {
"type": "belongsTo",
"model": "AgencyMode",
"foreignKey": "agencyModeFk"
} }
} }
} }

View File

@ -166,11 +166,12 @@ module.exports = Self => {
LEFT JOIN account.emailUser eu ON eu.userFk = u.id` LEFT JOIN account.emailUser eu ON eu.userFk = u.id`
); );
stmt.merge(conn.makeSuffix(filter)); stmt.merge(conn.makeWhere(filter.where));
let itemsIndex = stmts.push(stmt) - 1; stmts.push(stmt);
let sql = ParameterizedSQL.join(stmts, ';'); const itemsIndex = stmts.push(stmt) - 1;
let result = await conn.executeStmt(sql); const sql = ParameterizedSQL.join(stmts, ';');
return itemsIndex === 0 ? result : result[itemsIndex]; const result = await conn.executeStmt(sql, myOptions);
return result[itemsIndex];
}; };
}; };