diff --git a/back/helpers.spec.js b/back/helpers.spec.js
new file mode 100644
index 000000000..ba8936d41
--- /dev/null
+++ b/back/helpers.spec.js
@@ -0,0 +1,5 @@
+const baseTime = null; // new Date(2022, 0, 19, 8, 0, 0, 0);
+if (baseTime) {
+ jasmine.clock().install();
+ jasmine.clock().mockDate(baseTime);
+}
diff --git a/back/methods/account/set-password.js b/back/methods/account/set-password.js
index fc54b5abe..ab4d3b3fe 100644
--- a/back/methods/account/set-password.js
+++ b/back/methods/account/set-password.js
@@ -1,16 +1,15 @@
-
module.exports = Self => {
Self.remoteMethod('setPassword', {
description: 'Sets the user password',
accepts: [
{
arg: 'id',
- type: 'Number',
+ type: 'number',
description: 'The user id',
http: {source: 'path'}
}, {
arg: 'newPassword',
- type: 'String',
+ type: 'string',
description: 'The new password',
required: true
}
diff --git a/back/methods/chat/sendQueued.js b/back/methods/chat/sendQueued.js
index c34642c7e..cf80817e5 100644
--- a/back/methods/chat/sendQueued.js
+++ b/back/methods/chat/sendQueued.js
@@ -10,7 +10,7 @@ module.exports = Self => {
},
http: {
path: `/sendQueued`,
- verb: 'POST'
+ verb: 'GET'
}
});
diff --git a/back/methods/dms/deleteTrashFiles.js b/back/methods/dms/deleteTrashFiles.js
index 9d16e9d81..7cfb9f8d1 100644
--- a/back/methods/dms/deleteTrashFiles.js
+++ b/back/methods/dms/deleteTrashFiles.js
@@ -1,3 +1,4 @@
+const UserError = require('vn-loopback/util/user-error');
const fs = require('fs-extra');
const path = require('path');
@@ -11,11 +12,11 @@ module.exports = Self => {
},
http: {
path: `/deleteTrashFiles`,
- verb: 'POST'
+ verb: 'GET'
}
});
- Self.deleteTrashFiles = async(options) => {
+ Self.deleteTrashFiles = async options => {
const tx = await Self.beginTransaction({});
const myOptions = {};
@@ -26,6 +27,9 @@ module.exports = Self => {
myOptions.transaction = tx;
try {
+ if (process.env.NODE_ENV == 'test')
+ throw new UserError(`Action not allowed on the test environment`);
+
const models = Self.app.models;
const DmsContainer = models.DmsContainer;
@@ -33,9 +37,15 @@ module.exports = Self => {
where: {code: 'trash'}
}, myOptions);
+ const date = new Date();
+ date.setMonth(date.getMonth() - 4);
+
const dmsToDelete = await models.Dms.find({
where: {
- dmsTypeFk: trashDmsType.id
+ and: [
+ {dmsTypeFk: trashDmsType.id},
+ {created: {lt: date}}
+ ]
}
}, myOptions);
@@ -43,14 +53,19 @@ module.exports = Self => {
const pathHash = DmsContainer.getHash(dms.id);
const dmsContainer = await DmsContainer.container(pathHash);
const dstFile = path.join(dmsContainer.client.root, pathHash, dms.file);
+ const dstFolder = path.join(dmsContainer.client.root, pathHash);
await fs.unlink(dstFile);
- await dms.destroy(myOptions);
+ try {
+ await fs.rmdir(dstFolder);
+ await dms.destroy(myOptions);
+ } catch (err) {
+ await dms.destroy(myOptions);
+ }
}
if (tx) await tx.commit();
-
} catch (e) {
if (tx) await tx.rollback();
-
+
throw e;
}
};
diff --git a/back/methods/edi/updateData.js b/back/methods/edi/updateData.js
index 121e96778..3dae2d47d 100644
--- a/back/methods/edi/updateData.js
+++ b/back/methods/edi/updateData.js
@@ -200,6 +200,31 @@ module.exports = Self => {
const toTable = table.toTable;
const baseName = table.fileName;
+ const firstEntry = entries[0];
+ const entryName = firstEntry.entryName;
+ const startIndex = (entryName.length - 10);
+ const endIndex = (entryName.length - 4);
+ const dateString = entryName.substring(startIndex, endIndex);
+
+ const lastUpdated = new Date();
+
+ let updated = null;
+ if (file.updated) {
+ updated = new Date(file.updated);
+ updated.setHours(0, 0, 0, 0);
+ }
+
+ // Format string date to a date object
+ lastUpdated.setFullYear(`20${dateString.substring(4, 6)}`);
+ lastUpdated.setMonth(parseInt(dateString.substring(2, 4)) - 1);
+ lastUpdated.setDate(dateString.substring(0, 2));
+ lastUpdated.setHours(0, 0, 0, 0);
+
+ if (updated && lastUpdated <= updated) {
+ console.debug(`Table ${toTable} already updated, skipping...`);
+ return;
+ }
+
const tx = await Self.beginTransaction({});
try {
diff --git a/back/models/warehouse.json b/back/models/warehouse.json
index eb86e2114..dcbf7f2d2 100644
--- a/back/models/warehouse.json
+++ b/back/models/warehouse.json
@@ -24,9 +24,6 @@
},
"isManaged":{
"type": "boolean"
- },
- "hasStowaway":{
- "type": "boolean"
}
},
"acls": [
diff --git a/db/Dockerfile b/db/Dockerfile
index 8980c34f4..cb3aa741c 100644
--- a/db/Dockerfile
+++ b/db/Dockerfile
@@ -1,4 +1,4 @@
-FROM mariadb:10.4.13
+FROM mariadb:10.7.3
ENV MYSQL_ROOT_PASSWORD root
ENV TZ Europe/Madrid
@@ -31,11 +31,13 @@ COPY \
import-changes.sh \
config.ini \
dump/mysqlPlugins.sql \
+ dump/mockDate.sql \
dump/structure.sql \
dump/dumpedFixtures.sql \
./
RUN gosu mysql docker-init.sh \
&& docker-dump.sh mysqlPlugins \
+ && docker-dump.sh mockDate \
&& docker-dump.sh structure \
&& docker-dump.sh dumpedFixtures \
&& gosu mysql docker-temp-stop.sh
diff --git a/db/changes/10470-family/00-accountingType.sql b/db/changes/10470-family/00-accountingType.sql
index f3c092a34..964027e3a 100644
--- a/db/changes/10470-family/00-accountingType.sql
+++ b/db/changes/10470-family/00-accountingType.sql
@@ -1,2 +1,3 @@
ALTER TABLE `vn`.`accountingType` ADD daysInFuture INT NULL;
-ALTER TABLE `vn`.`accountingType` MODIFY COLUMN daysInFuture int(11) DEFAULT 0 NULL;
\ No newline at end of file
+ALTER TABLE `vn`.`accountingType` MODIFY COLUMN daysInFuture int(11) DEFAULT 0 NULL;
+UPDATE `vn`.`accountingType` SET daysInFuture=1 WHERE id=8;
\ No newline at end of file
diff --git a/db/changes/10470-family/00-aclMdb.sql b/db/changes/10470-family/00-aclMdb.sql
index c57f60eb3..b02ddc451 100644
--- a/db/changes/10470-family/00-aclMdb.sql
+++ b/db/changes/10470-family/00-aclMdb.sql
@@ -1,14 +1,14 @@
-CREATE TABLE `vn`.`mdbBranch` (
+CREATE TABLE IF NOT EXISTS `vn`.`mdbBranch` (
`name` VARCHAR(255),
PRIMARY KEY(`name`)
);
-CREATE TABLE `vn`.`mdbVersion` (
+CREATE TABLE IF NOT EXISTS `vn`.`mdbVersion` (
`app` VARCHAR(255) NOT NULL,
`branchFk` VARCHAR(255) NOT NULL,
`version` INT,
CONSTRAINT `mdbVersion_branchFk` FOREIGN KEY (`branchFk`) REFERENCES `vn`.`mdbBranch` (`name`) ON DELETE CASCADE ON UPDATE CASCADE
);
-INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
- VALUES('MdbVersion', '*', '*', 'ALLOW', 'ROLE', 'developer');
+INSERT IGNORE INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
+ VALUES(318, 'MdbVersion', '*', '*', 'ALLOW', 'ROLE', 'developer');
diff --git a/db/changes/10480-june/00-creditInsurance.sql b/db/changes/10470-family/00-creditInsurance.sql
similarity index 100%
rename from db/changes/10480-june/00-creditInsurance.sql
rename to db/changes/10470-family/00-creditInsurance.sql
diff --git a/db/changes/10480-june/01-creditInsuranceTriggers.sql b/db/changes/10470-family/01-creditInsuranceTriggers.sql
similarity index 100%
rename from db/changes/10480-june/01-creditInsuranceTriggers.sql
rename to db/changes/10470-family/01-creditInsuranceTriggers.sql
diff --git a/db/changes/10471-family/00-chat.sql b/db/changes/10471-family/00-chat.sql
new file mode 100644
index 000000000..6f3c9d437
--- /dev/null
+++ b/db/changes/10471-family/00-chat.sql
@@ -0,0 +1,3 @@
+ALTER TABLE `vn`.`chat` MODIFY COLUMN message TEXT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL;
+ALTER TABLE `vn`.`chat` MODIFY COLUMN dated DATETIME DEFAULT NULL NULL;
+ALTER TABLE `vn`.`chat` ADD error TEXT NULL;
diff --git a/db/changes/10472-family/00-creditInsurance.sql b/db/changes/10472-family/00-creditInsurance.sql
new file mode 100644
index 000000000..4731cfb2a
--- /dev/null
+++ b/db/changes/10472-family/00-creditInsurance.sql
@@ -0,0 +1,3 @@
+ALTER TABLE `vn`.`creditInsurance`
+ ADD CONSTRAINT `creditInsurance_creditClassificationFk` FOREIGN KEY (`creditClassificationFk`)
+ REFERENCES `vn`.`creditClassification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
\ No newline at end of file
diff --git a/db/changes/10480-june/00-ACL.sql b/db/changes/10480-june/00-ACL.sql
new file mode 100644
index 000000000..b13e56e21
--- /dev/null
+++ b/db/changes/10480-june/00-ACL.sql
@@ -0,0 +1,21 @@
+INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
+ VALUES
+ ('InvoiceOut','refund','WRITE','ALLOW','ROLE','invoicing'),
+ ('InvoiceOut','refund','WRITE','ALLOW','ROLE','salesAssistant'),
+ ('InvoiceOut','refund','WRITE','ALLOW','ROLE','claimManager'),
+ ('Ticket','refund','WRITE','ALLOW','ROLE','invoicing'),
+ ('Ticket','refund','WRITE','ALLOW','ROLE','salesAssistant'),
+ ('Ticket','refund','WRITE','ALLOW','ROLE','claimManager'),
+ ('Sale','refund','WRITE','ALLOW','ROLE','salesAssistant'),
+ ('Sale','refund','WRITE','ALLOW','ROLE','claimManager'),
+ ('TicketRefund','*','WRITE','ALLOW','ROLE','invoicing'),
+ ('ClaimObservation','*','WRITE','ALLOW','ROLE','salesPerson'),
+ ('ClaimObservation','*','READ','ALLOW','ROLE','salesPerson'),
+ ('Client','setPassword','WRITE','ALLOW','ROLE','salesPerson'),
+ ('Client','updateUser','WRITE','ALLOW','ROLE','salesPerson');
+
+DELETE FROM `salix`.`ACL` WHERE id=313;
+
+UPDATE `salix`.`ACL`
+ SET principalId='invoicing'
+ WHERE id=297;
\ No newline at end of file
diff --git a/db/changes/10480-june/00-albaran_gestdoc.sql b/db/changes/10480-june/00-albaran_gestdoc.sql
new file mode 100644
index 000000000..a0ba93bd3
--- /dev/null
+++ b/db/changes/10480-june/00-albaran_gestdoc.sql
@@ -0,0 +1,2 @@
+ALTER TABLE `vn2008`.`albaran_gestdoc` DROP FOREIGN KEY fk_albaran_gestdoc_gestdoc1;
+ALTER TABLE `vn2008`.`albaran_gestdoc` ADD CONSTRAINT albaran_gestdoc_FK FOREIGN KEY (gestdoc_id) REFERENCES `vn`.`dms`(id) ON DELETE CASCADE ON UPDATE CASCADE;
\ No newline at end of file
diff --git a/db/changes/10480-june/00-client.sql b/db/changes/10480-june/00-client.sql
new file mode 100644
index 000000000..4a39bbdf9
--- /dev/null
+++ b/db/changes/10480-june/00-client.sql
@@ -0,0 +1,3 @@
+alter table `vn`.`client`
+ add hasIncoterms tinyint(1) default 0 not null comment 'Received incoterms authorization from client';
+
diff --git a/db/changes/10480-june/00-deprecations.sql b/db/changes/10480-june/00-deprecations.sql
new file mode 100644
index 000000000..68becd13e
--- /dev/null
+++ b/db/changes/10480-june/00-deprecations.sql
@@ -0,0 +1,13 @@
+DROP FUNCTION `account`.`userGetId`;
+DROP FUNCTION `account`.`myUserGetName`;
+DROP FUNCTION `account`.`myUserGetId`;
+DROP FUNCTION `account`.`myUserHasRole`;
+DROP FUNCTION `account`.`myUserHasRoleId`;
+DROP FUNCTION `account`.`userGetName`;
+DROP FUNCTION `account`.`userHasRole`;
+DROP FUNCTION `account`.`userHasRoleId`;
+DROP PROCEDURE `account`.`myUserLogout`;
+DROP PROCEDURE `account`.`userLogin`;
+DROP PROCEDURE `account`.`userLoginWithKey`;
+DROP PROCEDURE `account`.`userLoginWithName`;
+DROP PROCEDURE `account`.`userSetPassword`;
\ No newline at end of file
diff --git a/db/changes/10480-june/00-item.sql b/db/changes/10480-june/00-item.sql
new file mode 100644
index 000000000..a08d3f4c1
--- /dev/null
+++ b/db/changes/10480-june/00-item.sql
@@ -0,0 +1 @@
+ALTER TABLE `vn`.`item` MODIFY COLUMN description TEXT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL;
diff --git a/db/changes/10480-june/00-sample.sql b/db/changes/10480-june/00-sample.sql
new file mode 100644
index 000000000..18beb736d
--- /dev/null
+++ b/db/changes/10480-june/00-sample.sql
@@ -0,0 +1,2 @@
+INSERT INTO `vn`.`sample` (code, description, isVisible, hasCompany, hasPreview, datepickerEnabled)
+VALUES ('incoterms-authorization', 'Autorización de incoterms', 1, 1, 1, 0);
\ No newline at end of file
diff --git a/db/changes/10480-june/00-ticketRefund_beforeUpsert.sql b/db/changes/10480-june/00-ticketRefund_beforeUpsert.sql
new file mode 100644
index 000000000..e6506c5d7
--- /dev/null
+++ b/db/changes/10480-june/00-ticketRefund_beforeUpsert.sql
@@ -0,0 +1,21 @@
+DROP PROCEDURE IF EXISTS `vn`.`ticketRefund_beforeUpsert`;
+
+DELIMITER $$
+$$
+CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketRefund_beforeUpsert`(vRefundTicketFk INT, vOriginalTicketFk INT)
+BEGIN
+ DECLARE vAlreadyExists BOOLEAN DEFAULT FALSE;
+
+ IF vRefundTicketFk = vOriginalTicketFk THEN
+ CALL util.throw('Original ticket and refund ticket has same id');
+ END IF;
+
+ SELECT COUNT(*) INTO vAlreadyExists
+ FROM ticketRefund
+ WHERE originalTicketFk = vOriginalTicketFk;
+
+ IF vAlreadyExists > 0 THEN
+ CALL util.throw('This ticket is already a refund');
+ END IF;
+END$$
+DELIMITER ;
diff --git a/db/changes/10480-june/01-claimObservation.sql b/db/changes/10480-june/01-claimObservation.sql
new file mode 100644
index 000000000..8dc126a9e
--- /dev/null
+++ b/db/changes/10480-june/01-claimObservation.sql
@@ -0,0 +1,13 @@
+CREATE TABLE `vn`.`claimObservation` (
+ `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
+ `claimFk` int(10) unsigned NOT NULL,
+ `workerFk` int(10) unsigned DEFAULT NULL,
+ `text` text COLLATE utf8_unicode_ci NOT NULL,
+ `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (`id`),
+ KEY `worker_key` (`workerFk`),
+ KEY `claim_key` (`claimFk`),
+ KEY `claimObservation_created_IDX` (`created`) USING BTREE,
+ CONSTRAINT `claimObservation_ibfk_1` FOREIGN KEY (`claimFk`) REFERENCES `vn`.`claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `claimObservation_ibfk_2` FOREIGN KEY (`workerFk`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE
+) COMMENT='Todas las observaciones referentes a una reclamación'
\ No newline at end of file
diff --git a/db/changes/10480-june/02-claimTextMigration.sql b/db/changes/10480-june/02-claimTextMigration.sql
new file mode 100644
index 000000000..fa5f6fe83
--- /dev/null
+++ b/db/changes/10480-june/02-claimTextMigration.sql
@@ -0,0 +1,2 @@
+INSERT INTO `vn`.`claimObservation` (`claimFk`, `text`, `created`)
+SELECT `id`, `observation`, `created` FROM `vn`.`claim`
\ No newline at end of file
diff --git a/db/changes/10481-june/delete.keep b/db/changes/10481-june/delete.keep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql
index 464933607..3bcc07d94 100644
--- a/db/dump/dumpedFixtures.sql
+++ b/db/dump/dumpedFixtures.sql
@@ -1,6 +1,6 @@
USE `util`;
--- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64)
+-- MariaDB dump 10.19 Distrib 10.6.8-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: db.verdnatura.es Database: util
-- ------------------------------------------------------
@@ -22,7 +22,7 @@ USE `util`;
LOCK TABLES `config` WRITE;
/*!40000 ALTER TABLE `config` DISABLE KEYS */;
-INSERT INTO `config` VALUES (1,'10450',0,'production',NULL);
+INSERT INTO `config` VALUES (1,'10461',0,'production',NULL);
/*!40000 ALTER TABLE `config` ENABLE KEYS */;
UNLOCK TABLES;
@@ -32,7 +32,7 @@ UNLOCK TABLES;
LOCK TABLES `version` WRITE;
/*!40000 ALTER TABLE `version` DISABLE KEYS */;
-INSERT INTO `version` VALUES ('salix','10230','53f69ae8e526a4a5d827c237a5b076d38507b392','2020-11-09 11:06:43',NULL),('vn-database','10129','7ebb66d5a9e47920e2c5ebfdf373bdf9d1bd6221','2022-05-03 13:46:59','10131');
+INSERT INTO `version` VALUES ('salix','10230','53f69ae8e526a4a5d827c237a5b076d38507b392','2020-11-09 11:06:43',NULL),('vn-database','10216','19871f5aac4c06bac92a3c6e50dfc02a818e09de','2022-06-23 11:15:29','10216');
/*!40000 ALTER TABLE `version` ENABLE KEYS */;
UNLOCK TABLES;
@@ -42,7 +42,7 @@ UNLOCK TABLES;
LOCK TABLES `versionLog` WRITE;
/*!40000 ALTER TABLE `versionLog` DISABLE KEYS */;
-INSERT INTO `versionLog` VALUES ('vn-database','00001','00-test.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL),('vn-database','00003','00-sage.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL),('vn-database','10008','00-alterRoleConfig.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL),('vn-database','10014','00-rolePrefix.sql','jenkins@10.0.2.68','2022-02-11 00:13:25',NULL,NULL),('vn-database','10017','01-firstScript.sql','jenkins@10.0.2.70','2022-03-09 11:36:54',NULL,NULL),('vn-database','10021','00-bankAccount.sql','jenkins@10.0.2.69','2022-03-16 14:11:22',NULL,NULL),('vn-database','10023','00-firstScript.sql','jenkins@10.0.2.69','2022-03-16 15:05:29',NULL,NULL),('vn-database','10026','00-invoiceInIntrastat.sql','jenkins@10.0.2.69','2022-03-21 15:10:53',NULL,NULL),('vn-database','10027','00-Clientes_cedidos.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10028','00-item_last_buy_.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10029','00-bankToViewAccountingToTable.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10030','00-KkejarNiche.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10036','00-updateBuyConfig.sql','jenkins@10.0.2.69','2022-03-29 12:36:54',NULL,NULL),('vn-database','10037','00-firstScript.sql','jenkins@10.0.2.69','2022-03-28 11:14:26',NULL,NULL),('vn-database','10038','00-printServerQueue.sql','jenkins@10.0.2.69','2022-03-29 08:13:24',NULL,NULL),('vn-database','10048','00-firstScript.sql','jenkins@10.0.2.69','2022-03-30 12:29:06',NULL,NULL),('vn-database','10058','00-vehicleAddFields.sql','jenkins@10.0.2.69','2022-04-06 08:48:34',NULL,NULL),('vn-database','10060','00-firstScript.sql','jenkins@10.0.2.69','2022-04-07 08:50:11',NULL,NULL),('vn-database','10062','00-firstScript.sql','jenkins@10.0.2.69','2022-04-06 10:51:45',NULL,NULL),('vn-database','10064','00-firstScript.sql','jenkins@10.0.2.69','2022-04-06 13:57:11',NULL,NULL),('vn-database','10066','00-firstScript.sql','jenkins@10.0.2.69','2022-04-07 08:50:12',NULL,NULL),('vn-database','10067','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 10:18:20',NULL,NULL),('vn-database','10071','00-packingSiteLog.sql','jenkins@10.0.2.69','2022-04-08 09:37:30',NULL,NULL),('vn-database','10072','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 11:01:46',NULL,NULL),('vn-database','10073','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 13:40:56',NULL,NULL),('vn-database','10074','00-firstScript.sql','jenkins@10.0.2.69','2022-04-10 13:15:05',NULL,NULL),('vn-database','10077','00-firstScript.sql','jenkins@10.0.2.69','2022-04-12 08:07:15',NULL,NULL),('vn-database','10078','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 07:44:21',NULL,NULL),('vn-database','10079','00-firstScript.sql','jenkins@10.0.2.69','2022-04-12 12:01:37',NULL,NULL),('vn-database','10086','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 08:58:34',NULL,NULL),('vn-database','10087','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 09:39:49',NULL,NULL),('vn-database','10088','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 15:05:12',NULL,NULL),('vn-database','10089','00-firstScript.sql','jenkins@10.0.2.69','2022-04-18 14:12:52',NULL,NULL),('vn-database','10090','00-firstScript.sql','jenkins@10.0.2.69','2022-04-18 14:34:46',NULL,NULL),('vn-database','10092','00-firstScript.sql','jenkins@10.0.2.69','2022-04-19 14:45:46',NULL,NULL),('vn-database','10093','00-autoradioConfig.sql','jenkins@10.0.2.69','2022-05-03 09:16:47',NULL,NULL),('vn-database','10094','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 10:57:30',NULL,NULL),('vn-database','10099','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 14:35:27',NULL,NULL),('vn-database','10100','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 14:35:27',NULL,NULL),('vn-database','10101','00-firstScript.sql','jenkins@10.0.2.69','2022-04-21 14:59:31',NULL,NULL),('vn-database','10107','00-firstScript.sql','jenkins@10.0.2.69','2022-04-23 10:53:53',NULL,NULL),('vn-database','10114','00-updateConfig.sql','jenkins@10.0.2.69','2022-04-27 13:37:25',NULL,NULL),('vn-database','10116','00-firstScript.sql','jenkins@10.0.2.69','2022-04-28 11:10:14',NULL,NULL),('vn-database','10118','00-firstScript.sql','jenkins@10.0.2.69','2022-04-29 08:10:15',NULL,NULL),('vn-database','10127','00-firstScript.sql','jenkins@10.0.2.69','2022-05-02 11:04:46',NULL,NULL),('vn-database','10128','00-firstScript.sql','jenkins@10.0.2.69','2022-05-02 13:04:31',NULL,NULL),('vn-database','10129','00-firstScript.sql','jenkins@10.0.2.69','2022-05-03 08:21:01',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','00001','00-test.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL),('vn-database','00003','00-sage.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL),('vn-database','10008','00-alterRoleConfig.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL),('vn-database','10014','00-rolePrefix.sql','jenkins@10.0.2.68','2022-02-11 00:13:25',NULL,NULL),('vn-database','10017','01-firstScript.sql','jenkins@10.0.2.70','2022-03-09 11:36:54',NULL,NULL),('vn-database','10021','00-bankAccount.sql','jenkins@10.0.2.69','2022-03-16 14:11:22',NULL,NULL),('vn-database','10023','00-firstScript.sql','jenkins@10.0.2.69','2022-03-16 15:05:29',NULL,NULL),('vn-database','10026','00-invoiceInIntrastat.sql','jenkins@10.0.2.69','2022-03-21 15:10:53',NULL,NULL),('vn-database','10027','00-Clientes_cedidos.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10028','00-item_last_buy_.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10029','00-bankToViewAccountingToTable.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10030','00-KkejarNiche.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10036','00-updateBuyConfig.sql','jenkins@10.0.2.69','2022-03-29 12:36:54',NULL,NULL),('vn-database','10037','00-firstScript.sql','jenkins@10.0.2.69','2022-03-28 11:14:26',NULL,NULL),('vn-database','10038','00-printServerQueue.sql','jenkins@10.0.2.69','2022-03-29 08:13:24',NULL,NULL),('vn-database','10048','00-firstScript.sql','jenkins@10.0.2.69','2022-03-30 12:29:06',NULL,NULL),('vn-database','10058','00-vehicleAddFields.sql','jenkins@10.0.2.69','2022-04-06 08:48:34',NULL,NULL),('vn-database','10060','00-firstScript.sql','jenkins@10.0.2.69','2022-04-07 08:50:11',NULL,NULL),('vn-database','10062','00-firstScript.sql','jenkins@10.0.2.69','2022-04-06 10:51:45',NULL,NULL),('vn-database','10064','00-firstScript.sql','jenkins@10.0.2.69','2022-04-06 13:57:11',NULL,NULL),('vn-database','10066','00-firstScript.sql','jenkins@10.0.2.69','2022-04-07 08:50:12',NULL,NULL),('vn-database','10067','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 10:18:20',NULL,NULL),('vn-database','10071','00-packingSiteLog.sql','jenkins@10.0.2.69','2022-04-08 09:37:30',NULL,NULL),('vn-database','10072','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 11:01:46',NULL,NULL),('vn-database','10073','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 13:40:56',NULL,NULL),('vn-database','10074','00-firstScript.sql','jenkins@10.0.2.69','2022-04-10 13:15:05',NULL,NULL),('vn-database','10077','00-firstScript.sql','jenkins@10.0.2.69','2022-04-12 08:07:15',NULL,NULL),('vn-database','10078','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 07:44:21',NULL,NULL),('vn-database','10079','00-firstScript.sql','jenkins@10.0.2.69','2022-04-12 12:01:37',NULL,NULL),('vn-database','10086','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 08:58:34',NULL,NULL),('vn-database','10087','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 09:39:49',NULL,NULL),('vn-database','10088','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 15:05:12',NULL,NULL),('vn-database','10089','00-firstScript.sql','jenkins@10.0.2.69','2022-04-18 14:12:52',NULL,NULL),('vn-database','10090','00-firstScript.sql','jenkins@10.0.2.69','2022-04-18 14:34:46',NULL,NULL),('vn-database','10092','00-firstScript.sql','jenkins@10.0.2.69','2022-04-19 14:45:46',NULL,NULL),('vn-database','10093','00-autoradioConfig.sql','jenkins@10.0.2.69','2022-05-03 09:16:47',NULL,NULL),('vn-database','10094','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 10:57:30',NULL,NULL),('vn-database','10097','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:12:59',NULL,NULL),('vn-database','10099','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 14:35:27',NULL,NULL),('vn-database','10100','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 14:35:27',NULL,NULL),('vn-database','10101','00-firstScript.sql','jenkins@10.0.2.69','2022-04-21 14:59:31',NULL,NULL),('vn-database','10103','00-awbVolume.sql','jenkins@10.0.2.69','2022-05-05 10:12:59',NULL,NULL),('vn-database','10104','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:12:59',NULL,NULL),('vn-database','10105','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:13:00',NULL,NULL),('vn-database','10107','00-firstScript.sql','jenkins@10.0.2.69','2022-04-23 10:53:53',NULL,NULL),('vn-database','10112','00-firstScript.sql','jenkins@10.0.2.69','2022-05-09 09:14:53',NULL,NULL),('vn-database','10113','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:13:00',NULL,NULL),('vn-database','10114','00-updateConfig.sql','jenkins@10.0.2.69','2022-04-27 13:37:25',NULL,NULL),('vn-database','10116','00-firstScript.sql','jenkins@10.0.2.69','2022-04-28 11:10:14',NULL,NULL),('vn-database','10118','00-firstScript.sql','jenkins@10.0.2.69','2022-04-29 08:10:15',NULL,NULL),('vn-database','10119','00-AfegirFKPart1.sql','jenkins@10.0.2.69','2022-05-05 10:13:00',NULL,NULL),('vn-database','10119','01-AfegirFkPart2.sql','jenkins@10.0.2.69','2022-05-05 10:22:25',NULL,NULL),('vn-database','10125','00-firstScript.sql','jenkins@10.0.2.68','2022-05-18 18:44:30',NULL,NULL),('vn-database','10127','00-firstScript.sql','jenkins@10.0.2.69','2022-05-02 11:04:46',NULL,NULL),('vn-database','10128','00-firstScript.sql','jenkins@10.0.2.69','2022-05-02 13:04:31',NULL,NULL),('vn-database','10129','00-firstScript.sql','jenkins@10.0.2.69','2022-05-03 08:21:01',NULL,NULL),('vn-database','10132','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:22:25',NULL,NULL),('vn-database','10133','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 14:32:30',NULL,NULL),('vn-database','10134','00-firstScript.sql','jenkins@10.0.2.69','2022-05-06 07:45:25',NULL,NULL),('vn-database','10135','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 08:46:17',NULL,NULL),('vn-database','10136','00-workerTimeControl.sql','jenkins@10.0.2.69','2022-05-09 13:51:12',NULL,NULL),('vn-database','10138','00-firstScript.sql','jenkins@10.0.2.69','2022-05-10 13:58:05',NULL,NULL),('vn-database','10139','00-firstScript.sql','jenkins@10.0.2.68','2022-05-16 14:32:37',NULL,NULL),('vn-database','10139','01-secondScript.sql','jenkins@10.0.2.68','2022-05-17 12:16:13',NULL,NULL),('vn-database','10141','00-firstScript.sql','jenkins@10.0.2.70','2022-05-12 08:27:31',NULL,NULL),('vn-database','10142','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:20:31',NULL,NULL),('vn-database','10143','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:20:31',NULL,NULL),('vn-database','10144','00-AfegirFKPArt1.sql','jenkins@10.0.2.68','2022-05-20 09:22:33',NULL,NULL),('vn-database','10144','00-firstScript.sql','jenkins@10.0.2.68','2022-05-13 09:44:25',NULL,NULL),('vn-database','10147','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:33',NULL,NULL),('vn-database','10149','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:33',NULL,NULL),('vn-database','10150','00-firstScript.sql','jenkins@10.0.2.68','2022-05-17 09:57:16',NULL,NULL),('vn-database','10152','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:34',NULL,NULL),('vn-database','10153','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:34',NULL,NULL),('vn-database','10154','00-compressionKk.sql','jenkins@10.0.2.68','2022-05-20 09:22:34',NULL,NULL),('vn-database','10157','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:35',NULL,NULL),('vn-database','10158','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:21',NULL,NULL),('vn-database','10163','00-firstScript.sql','jenkins@10.0.2.68','2022-05-23 08:17:14',NULL,NULL),('vn-database','10164','00-borrarSectorsDesus.sql','jenkins@10.0.2.68','2022-06-02 12:47:21',NULL,NULL),('vn-database','10165','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10166','00-firstScript.sql','jenkins@10.0.2.68','2022-05-24 16:11:21',NULL,NULL),('vn-database','10167','00-renameVnActiveContrat.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10168','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10169','00-createTableBankEntityConfig.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10169','02-addNotNullToBankEntityBic.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10172','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10174','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 08:46:17',NULL,NULL),('vn-database','10175','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:03:41',NULL,NULL),('vn-database','10177','00-crearTablaSpecialLabels.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10178','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:24',NULL,NULL),('vn-database','10179','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:24',NULL,NULL),('vn-database','10183','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:24',NULL,NULL),('vn-database','10184','00-firstScript.sql','jenkins@10.0.2.68','2022-06-03 08:05:34',NULL,NULL),('vn-database','10185','00-firstScript.sql','jenkins@10.0.2.68','2022-06-06 09:07:45',NULL,NULL),('vn-database','10186','00-desactivar_trigger.sql','jenkins@10.0.2.68','2022-06-07 09:31:23',NULL,NULL),('vn-database','10186','01-alter_Table_buy.sql','jenkins@10.0.2.68','2022-06-07 09:34:47',NULL,NULL),('vn-database','10186','02-alter_table_entryConfig.sql','jenkins@10.0.2.68','2022-06-07 09:34:47',NULL,NULL),('vn-database','10186','04-regularizar_Sticker_Inventario.sql','jenkins@10.0.2.68','2022-06-07 09:34:51',NULL,NULL),('vn-database','10186','09-reactivar_trigger.sql','jenkins@10.0.2.68','2022-06-07 09:34:51',NULL,NULL),('vn-database','10187','00-firstScript.sql','jenkins@10.0.2.68','2022-06-06 12:37:31',NULL,NULL),('vn-database','10188','00-firstScript.sql','jenkins@10.0.2.68','2022-06-06 14:03:36',NULL,NULL),('vn-database','10189','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:03:41',NULL,NULL),('vn-database','10191','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:03:41',NULL,NULL),('vn-database','10194','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:03:41',NULL,NULL),('vn-database','10195','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:03:41',NULL,NULL),('vn-database','10200','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:04:00',NULL,NULL),('vn-database','10201','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:04:00',NULL,NULL),('vn-database','10202','00-Remove_FK_to_ediGenus.sql','jenkins@10.0.2.69','2022-06-17 09:04:00',NULL,NULL),('vn-database','10203','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:04:01',NULL,NULL),('vn-database','10204','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:04:01',NULL,NULL),('vn-database','10205','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:04:21',NULL,NULL),('vn-database','10207','00-Alter_table_entry.sql','jenkins@10.0.2.69','2022-06-16 07:22:50',NULL,NULL),('vn-database','10207','01-Update_invoiceAmount.sql','jenkins@10.0.2.69','2022-06-16 07:23:00',NULL,NULL),('vn-database','10209','00-firstScript.sql','jenkins@10.0.2.69','2022-06-16 08:47:40',NULL,NULL),('vn-database','10210','00-firstScript.sql','jenkins@10.0.2.69','2022-06-16 17:39:17',1046,'Base de datos no seleccionada'),('vn-database','10211','01-firstScript.sql','jenkins@10.0.2.69','2022-06-17 07:11:27',NULL,NULL),('vn-database','10216','00-firstScript.sql','jenkins@10.0.2.69','2022-06-23 11:15:28',NULL,NULL);
/*!40000 ALTER TABLE `versionLog` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
@@ -54,9 +54,9 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2022-05-04 15:58:27
+-- Dump completed on 2022-06-23 12:13:31
USE `account`;
--- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64)
+-- MariaDB dump 10.19 Distrib 10.6.8-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: db.verdnatura.es Database: account
-- ------------------------------------------------------
@@ -78,7 +78,7 @@ USE `account`;
LOCK TABLES `role` WRITE;
/*!40000 ALTER TABLE `role` DISABLE KEYS */;
-INSERT INTO `role` VALUES (1,'employee','Empleado básico',1,'2017-05-19 07:04:58','2017-11-29 10:06:31'),(2,'customer','Privilegios básicos de un cliente',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(3,'agency','Consultar tablas de predicciones de bultos',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(5,'administrative','Tareas relacionadas con la contabilidad',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(6,'guest','Privilegios para usuarios sin cuenta',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(9,'developer','Desarrolladores del sistema',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(11,'account','Privilegios relacionados con el login',0,'2017-05-19 07:04:58','2017-09-20 17:06:35'),(13,'teamBoss','Jefe de equipo/departamento',1,'2017-05-19 07:04:58','2021-06-30 13:29:30'),(15,'logistic','Departamento de compras, responsables de la logistica',1,'2017-05-19 07:04:58','2018-02-12 10:50:10'),(16,'logisticBoss','Jefe del departamento de logística',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(17,'adminBoss','Jefe del departamento de administración',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(18,'salesPerson','Departamento de ventas',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(19,'salesBoss','Jefe del departamento de ventas',1,'2017-05-19 07:04:58','2017-08-16 12:38:27'),(20,'manager','Departamento de gerencia',1,'2017-06-01 14:57:02','2017-06-01 14:57:51'),(21,'salesAssistant','Jefe auxiliar de ventas',1,'2017-08-16 12:40:52','2017-08-16 12:40:52'),(22,'teamManager','Jefe de departamento con privilegios de auxiliar de venta.',1,'2017-09-07 09:08:12','2017-09-07 09:08:12'),(30,'financialBoss','Director finaciero',1,'2017-09-21 11:05:36','2017-09-21 11:05:36'),(31,'freelancer','Trabajadores por cuenta ajena',1,'2017-10-10 12:57:26','2017-10-10 12:59:27'),(32,'ett','Trabajadores de empresa temporal',1,'2017-10-10 12:58:58','2017-10-10 12:59:20'),(33,'invoicing','Personal con acceso a facturación',0,'2018-01-29 16:43:34','2018-01-29 16:43:34'),(34,'agencyBoss','Jefe/a del departamento de agencias',1,'2018-01-29 16:44:39','2018-02-23 07:58:53'),(35,'buyer','Departamento de compras',1,'2018-02-12 10:35:42','2018-02-12 10:35:42'),(36,'replenisher','Trabajadores de camara',1,'2018-02-16 14:07:10','2019-04-12 05:38:08'),(37,'hr','Gestor/a de recursos humanos',1,'2018-02-22 17:34:53','2018-02-22 17:34:53'),(38,'hrBoss','Jefe/a de recursos humanos',1,'2018-02-22 17:35:09','2018-02-22 17:35:09'),(39,'adminAssistant','Jefe auxiliar administrativo',1,'2018-02-23 10:37:36','2018-02-23 10:38:41'),(40,'handmade','Departamento de confección',1,'2018-02-23 11:14:53','2018-02-23 11:39:12'),(41,'handmadeBoss','Jefe de departamento de confección',1,'2018-02-23 11:15:09','2018-02-23 11:39:26'),(42,'artificial','Departamento de artificial',1,'2018-02-23 11:39:59','2018-02-23 11:39:59'),(43,'artificialBoss','Jefe del departamento de artificial',1,'2018-02-23 11:40:16','2018-02-23 11:40:16'),(44,'accessory','Departamento de complementos',1,'2018-02-23 11:41:12','2018-02-23 11:41:12'),(45,'accessoryBoss','Jefe del departamento de complementos',1,'2018-02-23 11:41:23','2018-02-23 11:41:23'),(47,'cooler','Empleados de cámara',1,'2018-02-23 13:08:18','2018-02-23 13:08:18'),(48,'coolerBoss','Jefe del departamento de cámara',1,'2018-02-23 13:12:01','2018-02-23 13:12:01'),(49,'production','Empleado de producción',1,'2018-02-26 15:28:23','2021-02-12 09:42:35'),(50,'productionBoss','Jefe de producción',1,'2018-02-26 15:34:12','2018-02-26 15:34:12'),(51,'marketing','Departamento de marketing',1,'2018-03-01 07:28:39','2018-03-01 07:28:39'),(52,'marketingBoss','Jefe del departamento de marketing',1,'2018-03-01 07:28:57','2018-03-01 07:28:57'),(53,'insurance','Gestor de seguros de cambio',0,'2018-03-05 07:44:35','2019-02-01 13:47:57'),(54,'itemPicker','Sacador en cámara',1,'2018-03-05 12:08:17','2018-03-05 12:08:17'),(55,'itemPickerBoss','Jefe de sacadores',1,'2018-03-05 12:08:31','2018-03-05 12:08:31'),(56,'delivery','Personal de reparto',1,'2018-05-30 06:07:02','2018-05-30 06:07:02'),(57,'deliveryBoss','Jefe de personal de reparto',1,'2018-05-30 06:07:19','2018-05-30 06:07:19'),(58,'packager','Departamento encajadores',1,'2019-01-21 12:43:45','2019-01-21 12:43:45'),(59,'packagerBoss','Jefe departamento encajadores',1,'2019-01-21 12:44:10','2019-01-21 12:44:10'),(60,'productionAssi','Tareas relacionadas con producción y administración',1,'2019-01-29 13:29:01','2019-01-29 13:29:01'),(61,'replenisherBos','Jefe de Complementos/Camara',1,'2019-07-01 06:44:07','2019-07-01 06:44:07'),(62,'noLogin','Role without login access to MySQL',0,'2019-07-01 06:50:19','2019-07-02 13:42:05'),(64,'balanceSheet','Consulta de Balance',0,'2019-07-16 12:12:08','2019-07-16 12:12:08'),(65,'officeBoss','Jefe de filial',1,'2019-08-02 06:54:26','2019-08-02 06:54:26'),(66,'sysadmin','Administrador de sistema',1,'2019-08-08 06:58:56','2019-08-08 06:58:56'),(67,'adminOfficer','categoria profesional oficial de administración',1,'2020-01-03 08:09:23','2020-01-03 08:09:23'),(69,'coolerAssist','Empleado cámara con permiso compras',1,'2020-02-05 12:36:09','2020-02-05 12:36:09'),(70,'trainee','Alumno de prácticas',1,'2020-03-04 11:00:25','2020-03-04 11:00:25'),(71,'checker','Rol de revisor con privilegios de itemPicker',1,'2020-10-02 10:50:07','2020-10-02 10:50:07'),(72,'claimManager','Personal de reclamaciones',1,'2020-10-13 10:01:32','2020-10-26 07:29:46'),(73,'financial','Departamento de finanzas',1,'2020-11-16 09:30:27','2020-11-16 09:30:27'),(74,'userPhotos','Privilegios para subir fotos de usuario',1,'2021-02-03 10:24:27','2021-02-03 10:24:27'),(75,'catalogPhotos','Privilegios para subir fotos del catálogo',1,'2021-02-03 10:24:27','2021-02-03 10:24:27'),(76,'chat','Rol para utilizar el rocket chat',1,'2020-11-27 13:06:50','2020-12-17 07:49:41'),(100,'root','Rol con todos los privilegios',0,'2018-04-23 14:33:36','2020-11-12 06:50:07'),(101,'buyerBoss','Jefe del departamento de compras',1,'2021-06-16 09:53:17','2021-06-16 09:53:17'),(102,'preservedBoss','Responsable preservado',1,'2021-09-14 13:45:37','2021-09-14 13:45:37'),(103,'it','Departamento de informática',1,'2021-11-11 09:48:22','2021-11-11 09:48:22'),(104,'itBoss','Jefe de departamento de informática',1,'2021-11-11 09:48:49','2021-11-11 09:48:49'),(105,'grant','Adjudicar roles a usuarios',1,'2021-11-11 12:41:09','2021-11-11 12:41:09'),(106,'ext','Usuarios externos de la Base de datos',1,'2021-11-23 14:51:16','2021-11-23 14:51:16'),(107,'productionPlus','Creado para pepe por orden de Juanvi',1,'2022-02-08 06:47:10','2022-02-08 06:47:10');
+INSERT INTO `role` VALUES (1,'employee','Empleado básico',1,'2017-05-19 07:04:58','2017-11-29 10:06:31'),(2,'customer','Privilegios básicos de un cliente',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(3,'agency','Consultar tablas de predicciones de bultos',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(5,'administrative','Tareas relacionadas con la contabilidad',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(6,'guest','Privilegios para usuarios sin cuenta',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(9,'developer','Desarrolladores del sistema',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(11,'account','Privilegios relacionados con el login',0,'2017-05-19 07:04:58','2017-09-20 17:06:35'),(13,'teamBoss','Jefe de equipo/departamento',1,'2017-05-19 07:04:58','2021-06-30 13:29:30'),(15,'logistic','Departamento de compras, responsables de la logistica',1,'2017-05-19 07:04:58','2018-02-12 10:50:10'),(16,'logisticBoss','Jefe del departamento de logística',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(17,'adminBoss','Jefe del departamento de administración',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(18,'salesPerson','Departamento de ventas',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(19,'salesBoss','Jefe del departamento de ventas',1,'2017-05-19 07:04:58','2017-08-16 12:38:27'),(20,'manager','Departamento de gerencia',1,'2017-06-01 14:57:02','2017-06-01 14:57:51'),(21,'salesAssistant','Jefe auxiliar de ventas',1,'2017-08-16 12:40:52','2017-08-16 12:40:52'),(22,'teamManager','Jefe de departamento con privilegios de auxiliar de venta.',1,'2017-09-07 09:08:12','2017-09-07 09:08:12'),(30,'financialBoss','Director finaciero',1,'2017-09-21 11:05:36','2017-09-21 11:05:36'),(31,'freelancer','Trabajadores por cuenta ajena',1,'2017-10-10 12:57:26','2017-10-10 12:59:27'),(32,'ett','Trabajadores de empresa temporal',1,'2017-10-10 12:58:58','2017-10-10 12:59:20'),(33,'invoicing','Personal con acceso a facturación',0,'2018-01-29 16:43:34','2018-01-29 16:43:34'),(34,'agencyBoss','Jefe/a del departamento de agencias',1,'2018-01-29 16:44:39','2018-02-23 07:58:53'),(35,'buyer','Departamento de compras',1,'2018-02-12 10:35:42','2018-02-12 10:35:42'),(36,'replenisher','Trabajadores de camara',1,'2018-02-16 14:07:10','2019-04-12 05:38:08'),(37,'hr','Gestor/a de recursos humanos',1,'2018-02-22 17:34:53','2018-02-22 17:34:53'),(38,'hrBoss','Jefe/a de recursos humanos',1,'2018-02-22 17:35:09','2018-02-22 17:35:09'),(39,'adminAssistant','Jefe auxiliar administrativo',1,'2018-02-23 10:37:36','2018-02-23 10:38:41'),(40,'handmade','Departamento de confección',1,'2018-02-23 11:14:53','2018-02-23 11:39:12'),(41,'handmadeBoss','Jefe de departamento de confección',1,'2018-02-23 11:15:09','2018-02-23 11:39:26'),(42,'artificial','Departamento de artificial',1,'2018-02-23 11:39:59','2018-02-23 11:39:59'),(43,'artificialBoss','Jefe del departamento de artificial',1,'2018-02-23 11:40:16','2018-02-23 11:40:16'),(44,'accessory','Departamento de complementos',1,'2018-02-23 11:41:12','2018-02-23 11:41:12'),(45,'accessoryBoss','Jefe del departamento de complementos',1,'2018-02-23 11:41:23','2018-02-23 11:41:23'),(47,'cooler','Empleados de cámara',1,'2018-02-23 13:08:18','2018-02-23 13:08:18'),(48,'coolerBoss','Jefe del departamento de cámara',1,'2018-02-23 13:12:01','2018-02-23 13:12:01'),(49,'production','Empleado de producción',1,'2018-02-26 15:28:23','2021-02-12 09:42:35'),(50,'productionBoss','Jefe de producción',1,'2018-02-26 15:34:12','2018-02-26 15:34:12'),(51,'marketing','Departamento de marketing',1,'2018-03-01 07:28:39','2018-03-01 07:28:39'),(52,'marketingBoss','Jefe del departamento de marketing',1,'2018-03-01 07:28:57','2018-03-01 07:28:57'),(53,'insurance','Gestor de seguros de cambio',0,'2018-03-05 07:44:35','2019-02-01 13:47:57'),(54,'itemPicker','Sacador en cámara',1,'2018-03-05 12:08:17','2018-03-05 12:08:17'),(55,'itemPickerBoss','Jefe de sacadores',1,'2018-03-05 12:08:31','2018-03-05 12:08:31'),(56,'delivery','Personal de reparto',1,'2018-05-30 06:07:02','2018-05-30 06:07:02'),(57,'deliveryBoss','Jefe de personal de reparto',1,'2018-05-30 06:07:19','2018-05-30 06:07:19'),(58,'packager','Departamento encajadores',1,'2019-01-21 12:43:45','2019-01-21 12:43:45'),(59,'packagerBoss','Jefe departamento encajadores',1,'2019-01-21 12:44:10','2019-01-21 12:44:10'),(60,'productionAssi','Tareas relacionadas con producción y administración',1,'2019-01-29 13:29:01','2019-01-29 13:29:01'),(61,'replenisherBos','Jefe de Complementos/Camara',1,'2019-07-01 06:44:07','2019-07-01 06:44:07'),(62,'noLogin','Role without login access to MySQL',0,'2019-07-01 06:50:19','2019-07-02 13:42:05'),(64,'balanceSheet','Consulta de Balance',0,'2019-07-16 12:12:08','2019-07-16 12:12:08'),(65,'officeBoss','Jefe de filial',1,'2019-08-02 06:54:26','2019-08-02 06:54:26'),(66,'sysadmin','Administrador de sistema',1,'2019-08-08 06:58:56','2019-08-08 06:58:56'),(67,'adminOfficer','categoria profesional oficial de administración',1,'2020-01-03 08:09:23','2020-01-03 08:09:23'),(69,'coolerAssist','Empleado cámara con permiso compras',1,'2020-02-05 12:36:09','2020-02-05 12:36:09'),(70,'trainee','Alumno de prácticas',1,'2020-03-04 11:00:25','2020-03-04 11:00:25'),(71,'checker','Rol de revisor con privilegios de itemPicker',1,'2020-10-02 10:50:07','2020-10-02 10:50:07'),(72,'claimManager','Personal de reclamaciones',1,'2020-10-13 10:01:32','2020-10-26 07:29:46'),(73,'financial','Departamento de finanzas',1,'2020-11-16 09:30:27','2020-11-16 09:30:27'),(74,'userPhotos','Privilegios para subir fotos de usuario',1,'2021-02-03 10:24:27','2021-02-03 10:24:27'),(75,'catalogPhotos','Privilegios para subir fotos del catálogo',1,'2021-02-03 10:24:27','2021-02-03 10:24:27'),(76,'chat','Rol para utilizar el rocket chat',1,'2020-11-27 13:06:50','2020-12-17 07:49:41'),(100,'root','Rol con todos los privilegios',0,'2018-04-23 14:33:36','2020-11-12 06:50:07'),(101,'buyerBoss','Jefe del departamento de compras',1,'2021-06-16 09:53:17','2021-06-16 09:53:17'),(102,'preservedBoss','Responsable preservado',1,'2021-09-14 13:45:37','2021-09-14 13:45:37'),(103,'it','Departamento de informática',1,'2021-11-11 09:48:22','2021-11-11 09:48:22'),(104,'itBoss','Jefe de departamento de informática',1,'2021-11-11 09:48:49','2021-11-11 09:48:49'),(105,'grant','Adjudicar roles a usuarios',1,'2021-11-11 12:41:09','2021-11-11 12:41:09'),(106,'ext','Usuarios externos de la Base de datos',1,'2021-11-23 14:51:16','2021-11-23 14:51:16'),(107,'productionPlus','Creado para pepe por orden de Juanvi',1,'2022-02-08 06:47:10','2022-02-08 06:47:10'),(108,'system','System user',1,'2022-05-16 08:09:51','2022-05-16 08:09:51'),(109,'salesTeamBoss','Jefe de equipo de comerciales',1,'2022-06-14 13:45:56','2022-06-14 13:45:56');
/*!40000 ALTER TABLE `role` ENABLE KEYS */;
UNLOCK TABLES;
@@ -88,7 +88,7 @@ UNLOCK TABLES;
LOCK TABLES `roleInherit` WRITE;
/*!40000 ALTER TABLE `roleInherit` DISABLE KEYS */;
-INSERT INTO `roleInherit` VALUES (1,1,2),(2,1,3),(3,1,70),(4,2,11),(5,3,11),(6,5,1),(7,5,21),(8,5,33),(124,5,76),(167,9,103),(10,11,6),(11,13,1),(12,15,35),(143,15,49),(150,15,56),(114,15,76),(14,16,13),(15,16,15),(127,16,76),(16,17,20),(17,17,37),(18,17,39),(19,17,64),(145,17,67),(136,17,76),(20,18,1),(132,18,76),(21,19,21),(242,20,9),(22,20,13),(23,20,16),(24,20,65),(134,20,76),(25,21,13),(26,21,18),(27,21,53),(241,21,72),(131,21,76),(28,22,13),(29,22,21),(30,30,5),(31,30,20),(32,30,22),(33,30,53),(34,30,64),(118,30,76),(35,31,1),(36,32,1),(37,34,1),(38,34,13),(39,34,33),(40,35,1),(142,35,75),(129,35,76),(41,36,44),(42,36,47),(43,37,1),(139,37,74),(125,37,76),(146,38,13),(44,38,37),(45,38,64),(126,38,76),(46,39,5),(47,39,21),(48,39,57),(115,39,76),(49,40,1),(50,40,49),(51,41,13),(52,41,35),(53,41,40),(135,41,76),(54,42,35),(55,42,49),(128,42,76),(56,43,13),(57,43,42),(58,44,1),(59,45,13),(60,45,44),(61,47,1),(62,48,13),(153,48,35),(63,48,47),(64,49,36),(65,49,58),(66,50,13),(67,50,21),(68,50,35),(69,50,49),(70,50,57),(71,50,59),(133,50,76),(72,51,1),(140,51,74),(141,51,75),(73,52,13),(74,52,19),(75,52,35),(76,52,51),(137,52,76),(77,53,1),(78,54,1),(79,55,13),(80,55,54),(81,56,1),(82,57,13),(245,57,33),(83,57,56),(138,57,76),(84,58,1),(85,59,13),(109,59,50),(87,60,5),(89,60,50),(90,60,57),(130,60,76),(91,61,13),(92,61,36),(93,65,19),(94,65,35),(95,65,50),(117,65,76),(168,66,9),(237,66,103),(97,67,5),(98,67,37),(99,69,35),(152,69,47),(101,70,11),(102,71,1),(103,71,58),(104,72,13),(105,72,18),(106,73,5),(108,73,19),(107,73,64),(148,101,13),(147,101,35),(154,102,1),(173,103,1),(194,103,2),(181,103,3),(179,103,5),(201,103,6),(176,103,11),(231,103,13),(212,103,15),(213,103,16),(178,103,17),(230,103,18),(229,103,19),(238,103,20),(228,103,21),(232,103,22),(199,103,30),(200,103,31),(197,103,32),(207,103,33),(182,103,34),(186,103,35),(225,103,36),(204,103,37),(205,103,38),(177,103,39),(202,103,40),(203,103,41),(183,103,42),(184,103,43),(174,103,44),(175,103,45),(191,103,47),(193,103,48),(222,103,49),(224,103,50),(215,103,51),(216,103,52),(206,103,53),(210,103,54),(211,103,55),(195,103,56),(196,103,57),(219,103,58),(220,103,59),(223,103,60),(226,103,61),(185,103,64),(218,103,65),(180,103,67),(192,103,69),(233,103,70),(189,103,71),(190,103,72),(198,103,73),(234,103,74),(188,103,75),(172,103,76),(187,103,101),(221,103,102),(171,104,9),(170,104,66),(169,104,100),(166,104,103),(239,106,11),(240,107,60);
+INSERT INTO `roleInherit` VALUES (1,1,2),(2,1,3),(3,1,70),(4,2,11),(5,3,11),(6,5,1),(7,5,21),(8,5,33),(124,5,76),(167,9,103),(10,11,6),(11,13,1),(12,15,35),(143,15,49),(150,15,56),(114,15,76),(14,16,13),(15,16,15),(127,16,76),(16,17,20),(17,17,37),(18,17,39),(19,17,64),(145,17,67),(136,17,76),(20,18,1),(132,18,76),(21,19,21),(242,20,9),(22,20,13),(23,20,16),(24,20,65),(134,20,76),(25,21,13),(26,21,18),(27,21,53),(241,21,72),(131,21,76),(28,22,13),(29,22,21),(30,30,5),(31,30,20),(32,30,22),(33,30,53),(34,30,64),(118,30,76),(35,31,1),(36,32,1),(37,34,1),(38,34,13),(39,34,33),(40,35,1),(142,35,75),(129,35,76),(41,36,44),(42,36,47),(43,37,1),(139,37,74),(125,37,76),(146,38,13),(44,38,37),(45,38,64),(126,38,76),(46,39,5),(47,39,21),(48,39,57),(115,39,76),(49,40,1),(50,40,49),(51,41,13),(52,41,35),(53,41,40),(135,41,76),(54,42,35),(55,42,49),(128,42,76),(56,43,13),(57,43,42),(58,44,1),(59,45,13),(60,45,44),(61,47,1),(62,48,13),(153,48,35),(63,48,47),(64,49,36),(65,49,58),(66,50,13),(67,50,21),(68,50,35),(69,50,49),(70,50,57),(71,50,59),(133,50,76),(72,51,1),(140,51,74),(141,51,75),(73,52,13),(74,52,19),(75,52,35),(76,52,51),(137,52,76),(77,53,1),(78,54,1),(79,55,13),(80,55,54),(81,56,1),(82,57,13),(245,57,33),(83,57,56),(138,57,76),(84,58,1),(85,59,13),(109,59,50),(87,60,5),(89,60,50),(90,60,57),(130,60,76),(91,61,13),(92,61,36),(93,65,19),(94,65,35),(95,65,50),(117,65,76),(168,66,9),(237,66,103),(97,67,5),(98,67,37),(99,69,35),(152,69,47),(101,70,11),(102,71,1),(103,71,58),(104,72,13),(105,72,18),(106,73,5),(108,73,19),(107,73,64),(148,101,13),(147,101,35),(154,102,1),(248,102,13),(246,102,35),(173,103,1),(194,103,2),(181,103,3),(179,103,5),(201,103,6),(176,103,11),(231,103,13),(212,103,15),(213,103,16),(178,103,17),(230,103,18),(229,103,19),(238,103,20),(228,103,21),(232,103,22),(199,103,30),(200,103,31),(197,103,32),(207,103,33),(182,103,34),(186,103,35),(225,103,36),(204,103,37),(205,103,38),(177,103,39),(202,103,40),(203,103,41),(183,103,42),(184,103,43),(174,103,44),(175,103,45),(191,103,47),(193,103,48),(222,103,49),(224,103,50),(215,103,51),(216,103,52),(206,103,53),(210,103,54),(211,103,55),(195,103,56),(196,103,57),(219,103,58),(220,103,59),(223,103,60),(226,103,61),(185,103,64),(218,103,65),(180,103,67),(192,103,69),(233,103,70),(189,103,71),(190,103,72),(198,103,73),(234,103,74),(188,103,75),(172,103,76),(187,103,101),(221,103,102),(171,104,9),(170,104,66),(169,104,100),(166,104,103),(239,106,11),(240,107,60),(247,108,1),(250,109,13),(249,109,18);
/*!40000 ALTER TABLE `roleInherit` ENABLE KEYS */;
UNLOCK TABLES;
@@ -98,7 +98,7 @@ UNLOCK TABLES;
LOCK TABLES `roleRole` WRITE;
/*!40000 ALTER TABLE `roleRole` DISABLE KEYS */;
-INSERT INTO `roleRole` VALUES (85547,1,1),(85548,1,2),(85549,1,3),(85552,1,6),(85551,1,11),(85550,1,70),(85465,2,2),(85467,2,6),(85466,2,11),(85350,3,3),(85352,3,6),(85351,3,11),(85320,5,1),(85327,5,2),(85326,5,3),(85319,5,5),(85332,5,6),(85331,5,11),(85324,5,13),(85328,5,18),(85321,5,21),(85322,5,33),(85329,5,53),(85325,5,70),(85330,5,72),(85323,5,76),(85649,6,6),(85488,9,1),(85489,9,2),(85490,9,3),(85491,9,5),(85492,9,6),(85486,9,9),(85493,9,11),(85494,9,13),(85495,9,15),(85496,9,16),(85497,9,17),(85498,9,18),(85499,9,19),(85500,9,20),(85501,9,21),(85502,9,22),(85503,9,30),(85504,9,31),(85505,9,32),(85506,9,33),(85507,9,34),(85508,9,35),(85509,9,36),(85510,9,37),(85511,9,38),(85512,9,39),(85513,9,40),(85514,9,41),(85515,9,42),(85516,9,43),(85517,9,44),(85518,9,45),(85519,9,47),(85520,9,48),(85521,9,49),(85522,9,50),(85523,9,51),(85524,9,52),(85525,9,53),(85526,9,54),(85527,9,55),(85528,9,56),(85529,9,57),(85530,9,58),(85531,9,59),(85532,9,60),(85533,9,61),(85534,9,64),(85535,9,65),(85536,9,67),(85537,9,69),(85538,9,70),(85539,9,71),(85540,9,72),(85541,9,73),(85542,9,74),(85543,9,75),(85544,9,76),(85545,9,101),(85546,9,102),(85487,9,103),(85240,11,6),(85239,11,11),(86312,13,1),(86313,13,2),(86314,13,3),(86317,13,6),(86316,13,11),(86311,13,13),(86315,13,70),(85861,15,1),(85865,15,2),(85864,15,3),(85868,15,6),(85867,15,11),(85853,15,15),(85854,15,35),(85859,15,36),(85862,15,44),(85866,15,47),(85855,15,49),(85856,15,56),(85858,15,58),(85863,15,70),(85860,15,75),(85857,15,76),(85875,16,1),(85880,16,2),(85879,16,3),(85886,16,6),(85885,16,11),(85870,16,13),(85871,16,15),(85869,16,16),(85874,16,35),(85881,16,36),(85884,16,44),(85883,16,47),(85873,16,49),(85876,16,56),(85882,16,58),(85878,16,70),(85877,16,75),(85872,16,76),(85266,17,1),(85277,17,2),(85276,17,3),(85271,17,5),(85299,17,6),(85270,17,9),(85298,17,11),(85269,17,13),(85281,17,15),(85268,17,16),(85258,17,17),(85283,17,18),(85280,17,19),(85259,17,20),(85272,17,21),(85297,17,22),(85296,17,30),(85295,17,31),(85294,17,32),(85274,17,33),(85293,17,34),(85279,17,35),(85292,17,36),(85260,17,37),(85291,17,38),(85261,17,39),(85290,17,40),(85289,17,41),(85288,17,42),(85287,17,43),(85300,17,44),(85301,17,45),(85302,17,47),(85303,17,48),(85304,17,49),(85278,17,50),(85305,17,51),(85306,17,52),(85284,17,53),(85307,17,54),(85308,17,55),(85286,17,56),(85273,17,57),(85309,17,58),(85310,17,59),(85311,17,60),(85312,17,61),(85262,17,64),(85267,17,65),(85263,17,67),(85313,17,69),(85275,17,70),(85314,17,71),(85285,17,72),(85315,17,73),(85265,17,74),(85316,17,75),(85264,17,76),(85317,17,101),(85318,17,102),(85282,17,103),(86242,18,1),(86245,18,2),(86244,18,3),(86248,18,6),(86247,18,11),(86241,18,18),(86246,18,70),(86243,18,76),(86235,19,1),(86238,19,2),(86237,19,3),(86240,19,6),(86239,19,11),(86230,19,13),(86231,19,18),(86228,19,19),(86229,19,21),(86232,19,53),(86236,19,70),(86233,19,72),(86234,19,76),(85896,20,1),(85904,20,2),(85903,20,3),(85902,20,5),(85901,20,6),(85888,20,9),(85900,20,11),(85889,20,13),(85895,20,15),(85890,20,16),(85899,20,17),(85905,20,18),(85894,20,19),(85887,20,20),(85906,20,21),(85907,20,22),(85908,20,30),(85909,20,31),(85910,20,32),(85911,20,33),(85912,20,34),(85893,20,35),(85913,20,36),(85914,20,37),(85915,20,38),(85916,20,39),(85917,20,40),(85918,20,41),(85919,20,42),(85920,20,43),(85921,20,44),(85922,20,45),(85923,20,47),(85924,20,48),(85925,20,49),(85898,20,50),(85926,20,51),(85927,20,52),(85928,20,53),(85929,20,54),(85930,20,55),(85931,20,56),(85932,20,57),(85933,20,58),(85934,20,59),(85935,20,60),(85936,20,61),(85937,20,64),(85891,20,65),(85938,20,67),(85939,20,69),(85940,20,70),(85941,20,71),(85942,20,72),(85943,20,73),(85944,20,74),(85945,20,75),(85892,20,76),(85946,20,101),(85947,20,102),(85897,20,103),(86222,21,1),(86225,21,2),(86224,21,3),(86227,21,6),(86226,21,11),(86217,21,13),(86218,21,18),(86216,21,21),(86219,21,53),(86223,21,70),(86220,21,72),(86221,21,76),(86322,22,1),(86328,22,2),(86327,22,3),(86330,22,6),(86329,22,11),(86319,22,13),(86321,22,18),(86320,22,21),(86318,22,22),(86323,22,53),(86326,22,70),(86324,22,72),(86325,22,76),(85592,30,1),(85600,30,2),(85599,30,3),(85581,30,5),(85612,30,6),(85589,30,9),(85613,30,11),(85588,30,13),(85594,30,15),(85587,30,16),(85611,30,17),(85597,30,18),(85601,30,19),(85582,30,20),(85591,30,21),(85583,30,22),(85580,30,30),(85610,30,31),(85609,30,32),(85590,30,33),(85608,30,34),(85602,30,35),(85607,30,36),(85606,30,37),(85605,30,38),(85604,30,39),(85614,30,40),(85615,30,41),(85616,30,42),(85617,30,43),(85618,30,44),(85619,30,45),(85620,30,47),(85621,30,48),(85622,30,49),(85603,30,50),(85623,30,51),(85624,30,52),(85584,30,53),(85625,30,54),(85626,30,55),(85627,30,56),(85628,30,57),(85629,30,58),(85630,30,59),(85631,30,60),(85632,30,61),(85585,30,64),(85593,30,65),(85633,30,67),(85634,30,69),(85598,30,70),(85635,30,71),(85596,30,72),(85636,30,73),(85637,30,74),(85638,30,75),(85586,30,76),(85639,30,101),(85640,30,102),(85595,30,103),(85642,31,1),(85643,31,2),(85644,31,3),(85647,31,6),(85646,31,11),(85641,31,31),(85645,31,70),(85554,32,1),(85555,32,2),(85556,32,3),(85559,32,6),(85558,32,11),(85553,32,32),(85557,32,70),(85707,33,33),(85354,34,1),(85359,34,2),(85358,34,3),(85361,34,6),(85360,34,11),(85355,34,13),(85356,34,33),(85353,34,34),(85357,34,70),(85396,35,1),(85401,35,2),(85400,35,3),(85403,35,6),(85402,35,11),(85395,35,35),(85399,35,70),(85397,35,75),(85398,35,76),(86131,36,1),(86133,36,2),(86132,36,3),(86136,36,6),(86135,36,11),(86128,36,36),(86129,36,44),(86130,36,47),(86134,36,70),(85680,37,1),(85685,37,2),(85684,37,3),(85687,37,6),(85686,37,11),(85679,37,37),(85683,37,70),(85681,37,74),(85682,37,76),(85694,38,1),(85697,38,2),(85696,38,3),(85699,38,6),(85698,38,11),(85689,38,13),(85690,38,37),(85688,38,38),(85691,38,64),(85695,38,70),(85693,38,74),(85692,38,76),(85249,39,1),(85255,39,2),(85254,39,3),(85242,39,5),(85257,39,6),(85256,39,11),(85247,39,13),(85246,39,18),(85243,39,21),(85248,39,33),(85241,39,39),(85250,39,53),(85252,39,56),(85244,39,57),(85253,39,70),(85251,39,72),(85245,39,76),(85651,40,1),(85654,40,2),(85653,40,3),(85661,40,6),(85660,40,11),(85656,40,36),(85650,40,40),(85659,40,44),(85658,40,47),(85652,40,49),(85657,40,58),(85655,40,70),(85669,41,1),(85673,41,2),(85672,41,3),(85678,41,6),(85677,41,11),(85663,41,13),(85664,41,35),(85670,41,36),(85665,41,40),(85662,41,41),(85676,41,44),(85675,41,47),(85667,41,49),(85674,41,58),(85671,41,70),(85668,41,75),(85666,41,76),(85368,42,1),(85373,42,2),(85372,42,3),(85376,42,6),(85375,42,11),(85363,42,35),(85366,42,36),(85362,42,42),(85370,42,44),(85374,42,47),(85364,42,49),(85369,42,58),(85371,42,70),(85367,42,75),(85365,42,76),(85381,43,1),(85387,43,2),(85386,43,3),(85393,43,6),(85392,43,11),(85378,43,13),(85380,43,35),(85388,43,36),(85379,43,42),(85377,43,43),(85391,43,44),(85390,43,47),(85382,43,49),(85389,43,58),(85385,43,70),(85384,43,75),(85383,43,76),(85224,44,1),(85225,44,2),(85226,44,3),(85229,44,6),(85228,44,11),(85223,44,44),(85227,44,70),(85233,45,1),(85235,45,2),(85234,45,3),(85238,45,6),(85237,45,11),(85231,45,13),(85232,45,44),(85230,45,45),(85236,45,70),(85436,47,1),(85437,47,2),(85438,47,3),(85441,47,6),(85440,47,11),(85435,47,47),(85439,47,70),(85459,48,1),(85462,48,2),(85461,48,3),(85464,48,6),(85463,48,11),(85454,48,13),(85455,48,35),(85456,48,47),(85453,48,48),(85460,48,70),(85458,48,75),(85457,48,76),(86045,49,1),(86048,49,2),(86047,49,3),(86050,49,6),(86049,49,11),(86041,49,36),(86044,49,44),(86043,49,47),(86040,49,49),(86042,49,58),(86046,49,70),(86091,50,1),(86098,50,2),(86097,50,3),(86100,50,6),(86099,50,11),(86078,50,13),(86090,50,18),(86079,50,21),(86092,50,33),(86080,50,35),(86086,50,36),(86095,50,44),(86094,50,47),(86081,50,49),(86077,50,50),(86089,50,53),(86093,50,56),(86082,50,57),(86085,50,58),(86083,50,59),(86096,50,70),(86088,50,72),(86087,50,75),(86084,50,76),(85949,51,1),(85954,51,2),(85953,51,3),(85956,51,6),(85955,51,11),(85948,51,51),(85952,51,70),(85950,51,74),(85951,51,75),(85966,52,1),(85971,52,2),(85970,52,3),(85974,52,6),(85973,52,11),(85958,52,13),(85968,52,18),(85959,52,19),(85965,52,21),(85960,52,35),(85961,52,51),(85957,52,52),(85967,52,53),(85969,52,70),(85972,52,72),(85963,52,74),(85964,52,75),(85962,52,76),(85701,53,1),(85702,53,2),(85703,53,3),(85706,53,6),(85705,53,11),(85700,53,53),(85704,53,70),(85838,54,1),(85839,54,2),(85840,54,3),(85843,54,6),(85842,54,11),(85837,54,54),(85841,54,70),(85847,55,1),(85849,55,2),(85848,55,3),(85852,55,6),(85851,55,11),(85845,55,13),(85846,55,54),(85844,55,55),(85850,55,70),(85469,56,1),(85470,56,2),(85471,56,3),(85474,56,6),(85473,56,11),(85468,56,56),(85472,56,70),(85480,57,1),(85483,57,2),(85482,57,3),(85485,57,6),(85484,57,11),(85476,57,13),(85477,57,33),(85478,57,56),(85475,57,57),(85481,57,70),(85479,57,76),(86003,58,1),(86004,58,2),(86005,58,3),(86008,58,6),(86007,58,11),(86002,58,58),(86006,58,70),(86013,59,1),(86023,59,2),(86022,59,3),(86032,59,6),(86031,59,11),(86010,59,13),(86020,59,18),(86012,59,21),(86027,59,33),(86014,59,35),(86025,59,36),(86030,59,44),(86029,59,47),(86015,59,49),(86011,59,50),(86019,59,53),(86028,59,56),(86016,59,57),(86026,59,58),(86009,59,59),(86021,59,70),(86018,59,72),(86024,59,75),(86017,59,76),(86059,60,1),(86071,60,2),(86070,60,3),(86052,60,5),(86076,60,6),(86075,60,11),(86056,60,13),(86068,60,18),(86058,60,21),(86057,60,33),(86060,60,35),(86064,60,36),(86074,60,44),(86073,60,47),(86061,60,49),(86053,60,50),(86067,60,53),(86063,60,56),(86054,60,57),(86072,60,58),(86062,60,59),(86051,60,60),(86069,60,70),(86066,60,72),(86065,60,75),(86055,60,76),(86141,61,1),(86145,61,2),(86144,61,3),(86147,61,6),(86146,61,11),(86138,61,13),(86139,61,36),(86140,61,44),(86142,61,47),(86137,61,61),(86143,61,70),(85975,62,62),(85394,64,64),(85983,65,1),(85991,65,2),(85990,65,3),(86001,65,6),(86000,65,11),(85981,65,13),(85994,65,18),(85977,65,19),(85984,65,21),(85996,65,33),(85978,65,35),(85988,65,36),(85999,65,44),(85998,65,47),(85985,65,49),(85979,65,50),(85993,65,53),(85997,65,56),(85986,65,57),(85995,65,58),(85987,65,59),(85976,65,65),(85989,65,70),(85992,65,72),(85982,65,75),(85980,65,76),(86253,66,1),(86252,66,2),(86254,66,3),(86255,66,5),(86256,66,6),(86250,66,9),(86257,66,11),(86258,66,13),(86259,66,15),(86260,66,16),(86261,66,17),(86262,66,18),(86263,66,19),(86264,66,20),(86265,66,21),(86266,66,22),(86267,66,30),(86268,66,31),(86269,66,32),(86270,66,33),(86271,66,34),(86272,66,35),(86273,66,36),(86274,66,37),(86275,66,38),(86276,66,39),(86277,66,40),(86278,66,41),(86279,66,42),(86280,66,43),(86281,66,44),(86282,66,45),(86283,66,47),(86284,66,48),(86285,66,49),(86286,66,50),(86287,66,51),(86288,66,52),(86289,66,53),(86290,66,54),(86291,66,55),(86292,66,56),(86293,66,57),(86294,66,58),(86295,66,59),(86296,66,60),(86297,66,61),(86298,66,64),(86299,66,65),(86249,66,66),(86300,66,67),(86301,66,69),(86302,66,70),(86303,66,71),(86304,66,72),(86305,66,73),(86306,66,74),(86307,66,75),(86308,66,76),(86309,66,101),(86310,66,102),(86251,66,103),(85337,67,1),(85345,67,2),(85344,67,3),(85334,67,5),(85349,67,6),(85348,67,11),(85342,67,13),(85341,67,18),(85336,67,21),(85338,67,33),(85335,67,37),(85346,67,53),(85333,67,67),(85343,67,70),(85347,67,72),(85340,67,74),(85339,67,76),(85446,69,1),(85450,69,2),(85449,69,3),(85452,69,6),(85451,69,11),(85443,69,35),(85444,69,47),(85442,69,69),(85448,69,70),(85445,69,75),(85447,69,76),(86333,70,6),(86332,70,11),(86331,70,70),(85418,71,1),(85421,71,2),(85420,71,3),(85424,71,6),(85423,71,11),(85419,71,58),(85422,71,70),(85417,71,71),(85429,72,1),(85431,72,2),(85430,72,3),(85434,72,6),(85433,72,11),(85426,72,13),(85427,72,18),(85432,72,70),(85425,72,72),(85428,72,76),(85569,73,1),(85574,73,2),(85573,73,3),(85564,73,5),(85579,73,6),(85578,73,11),(85571,73,13),(85575,73,18),(85565,73,19),(85568,73,21),(85567,73,33),(85576,73,53),(85566,73,64),(85572,73,70),(85577,73,72),(85563,73,73),(85570,73,76),(86334,74,74),(85415,75,75),(85416,76,76),(86174,100,1),(86170,100,2),(86156,100,3),(86154,100,5),(86181,100,6),(86173,100,9),(86151,100,11),(86212,100,13),(86192,100,15),(86193,100,16),(86153,100,17),(86210,100,18),(86209,100,19),(86194,100,20),(86208,100,21),(86213,100,22),(86178,100,30),(86179,100,31),(86175,100,32),(86187,100,33),(86157,100,34),(86161,100,35),(86206,100,36),(86184,100,37),(86185,100,38),(86152,100,39),(86182,100,40),(86183,100,41),(86158,100,42),(86159,100,43),(86149,100,44),(86150,100,45),(86167,100,47),(86169,100,48),(86202,100,49),(86204,100,50),(86195,100,51),(86196,100,52),(86186,100,53),(86190,100,54),(86191,100,55),(86171,100,56),(86172,100,57),(86199,100,58),(86200,100,59),(86203,100,60),(86207,100,61),(86197,100,62),(86160,100,64),(86198,100,65),(86211,100,66),(86155,100,67),(86168,100,69),(86214,100,70),(86165,100,71),(86166,100,72),(86177,100,73),(86215,100,74),(86163,100,75),(86164,100,76),(86148,100,100),(86162,100,101),(86201,100,102),(86188,100,103),(86189,100,104),(86180,100,105),(86176,100,106),(86205,100,107),(85408,101,1),(85412,101,2),(85411,101,3),(85414,101,6),(85413,101,11),(85405,101,13),(85406,101,35),(85410,101,70),(85407,101,75),(85409,101,76),(85404,101,101),(86034,102,1),(86035,102,2),(86036,102,3),(86039,102,6),(86038,102,11),(86037,102,70),(86033,102,102),(85709,103,1),(85710,103,2),(85711,103,3),(85712,103,5),(85713,103,6),(85768,103,9),(85714,103,11),(85715,103,13),(85716,103,15),(85717,103,16),(85718,103,17),(85719,103,18),(85720,103,19),(85721,103,20),(85722,103,21),(85723,103,22),(85724,103,30),(85725,103,31),(85726,103,32),(85727,103,33),(85728,103,34),(85729,103,35),(85730,103,36),(85731,103,37),(85732,103,38),(85733,103,39),(85734,103,40),(85735,103,41),(85736,103,42),(85737,103,43),(85738,103,44),(85739,103,45),(85740,103,47),(85741,103,48),(85742,103,49),(85743,103,50),(85744,103,51),(85745,103,52),(85746,103,53),(85747,103,54),(85748,103,55),(85749,103,56),(85750,103,57),(85751,103,58),(85752,103,59),(85753,103,60),(85754,103,61),(85755,103,64),(85756,103,65),(85757,103,67),(85758,103,69),(85759,103,70),(85760,103,71),(85761,103,72),(85762,103,73),(85763,103,74),(85764,103,75),(85765,103,76),(85766,103,101),(85767,103,102),(85708,103,103),(85777,104,1),(85776,104,2),(85775,104,3),(85774,104,5),(85778,104,6),(85770,104,9),(85779,104,11),(85780,104,13),(85781,104,15),(85782,104,16),(85783,104,17),(85784,104,18),(85785,104,19),(85786,104,20),(85787,104,21),(85788,104,22),(85789,104,30),(85790,104,31),(85791,104,32),(85792,104,33),(85793,104,34),(85794,104,35),(85795,104,36),(85796,104,37),(85797,104,38),(85798,104,39),(85799,104,40),(85800,104,41),(85801,104,42),(85802,104,43),(85803,104,44),(85804,104,45),(85805,104,47),(85806,104,48),(85807,104,49),(85808,104,50),(85809,104,51),(85810,104,52),(85811,104,53),(85812,104,54),(85813,104,55),(85814,104,56),(85815,104,57),(85816,104,58),(85817,104,59),(85818,104,60),(85819,104,61),(85835,104,62),(85820,104,64),(85821,104,65),(85771,104,66),(85822,104,67),(85823,104,69),(85824,104,70),(85825,104,71),(85826,104,72),(85827,104,73),(85828,104,74),(85829,104,75),(85830,104,76),(85772,104,100),(85831,104,101),(85832,104,102),(85773,104,103),(85769,104,104),(85834,104,105),(85833,104,106),(85836,104,107),(85648,105,105),(85562,106,6),(85561,106,11),(85560,106,106),(86110,107,1),(86122,107,2),(86121,107,3),(86103,107,5),(86127,107,6),(86126,107,11),(86107,107,13),(86119,107,18),(86109,107,21),(86108,107,33),(86111,107,35),(86115,107,36),(86125,107,44),(86124,107,47),(86112,107,49),(86104,107,50),(86118,107,53),(86114,107,56),(86105,107,57),(86123,107,58),(86113,107,59),(86102,107,60),(86120,107,70),(86117,107,72),(86116,107,75),(86106,107,76),(86101,107,107);
+INSERT INTO `roleRole` VALUES (93925,1,1),(93926,1,2),(93927,1,3),(93930,1,6),(93929,1,11),(93928,1,70),(93843,2,2),(93845,2,6),(93844,2,11),(93728,3,3),(93730,3,6),(93729,3,11),(93698,5,1),(93705,5,2),(93704,5,3),(93697,5,5),(93710,5,6),(93709,5,11),(93702,5,13),(93706,5,18),(93699,5,21),(93700,5,33),(93707,5,53),(93703,5,70),(93708,5,72),(93701,5,76),(94027,6,6),(93866,9,1),(93867,9,2),(93868,9,3),(93869,9,5),(93870,9,6),(93864,9,9),(93871,9,11),(93872,9,13),(93873,9,15),(93874,9,16),(93875,9,17),(93876,9,18),(93877,9,19),(93878,9,20),(93879,9,21),(93880,9,22),(93881,9,30),(93882,9,31),(93883,9,32),(93884,9,33),(93885,9,34),(93886,9,35),(93887,9,36),(93888,9,37),(93889,9,38),(93890,9,39),(93891,9,40),(93892,9,41),(93893,9,42),(93894,9,43),(93895,9,44),(93896,9,45),(93897,9,47),(93898,9,48),(93899,9,49),(93900,9,50),(93901,9,51),(93902,9,52),(93903,9,53),(93904,9,54),(93905,9,55),(93906,9,56),(93907,9,57),(93908,9,58),(93909,9,59),(93910,9,60),(93911,9,61),(93912,9,64),(93913,9,65),(93914,9,67),(93915,9,69),(93916,9,70),(93917,9,71),(93918,9,72),(93919,9,73),(93920,9,74),(93921,9,75),(93922,9,76),(93923,9,101),(93924,9,102),(93865,9,103),(93618,11,6),(93617,11,11),(94715,13,1),(94716,13,2),(94717,13,3),(94720,13,6),(94719,13,11),(94714,13,13),(94718,13,70),(94241,15,1),(94245,15,2),(94244,15,3),(94248,15,6),(94247,15,11),(94233,15,15),(94234,15,35),(94239,15,36),(94242,15,44),(94246,15,47),(94235,15,49),(94236,15,56),(94238,15,58),(94243,15,70),(94240,15,75),(94237,15,76),(94255,16,1),(94260,16,2),(94259,16,3),(94266,16,6),(94265,16,11),(94250,16,13),(94251,16,15),(94249,16,16),(94254,16,35),(94261,16,36),(94264,16,44),(94263,16,47),(94253,16,49),(94256,16,56),(94262,16,58),(94258,16,70),(94257,16,75),(94252,16,76),(93644,17,1),(93655,17,2),(93654,17,3),(93649,17,5),(93677,17,6),(93648,17,9),(93676,17,11),(93647,17,13),(93659,17,15),(93646,17,16),(93636,17,17),(93661,17,18),(93658,17,19),(93637,17,20),(93650,17,21),(93675,17,22),(93674,17,30),(93673,17,31),(93672,17,32),(93652,17,33),(93671,17,34),(93657,17,35),(93670,17,36),(93638,17,37),(93669,17,38),(93639,17,39),(93668,17,40),(93667,17,41),(93666,17,42),(93665,17,43),(93678,17,44),(93679,17,45),(93680,17,47),(93681,17,48),(93682,17,49),(93656,17,50),(93683,17,51),(93684,17,52),(93662,17,53),(93685,17,54),(93686,17,55),(93664,17,56),(93651,17,57),(93687,17,58),(93688,17,59),(93689,17,60),(93690,17,61),(93640,17,64),(93645,17,65),(93641,17,67),(93691,17,69),(93653,17,70),(93692,17,71),(93663,17,72),(93693,17,73),(93643,17,74),(93694,17,75),(93642,17,76),(93695,17,101),(93696,17,102),(93660,17,103),(94628,18,1),(94631,18,2),(94630,18,3),(94634,18,6),(94633,18,11),(94627,18,18),(94632,18,70),(94629,18,76),(94621,19,1),(94624,19,2),(94623,19,3),(94626,19,6),(94625,19,11),(94616,19,13),(94617,19,18),(94614,19,19),(94615,19,21),(94618,19,53),(94622,19,70),(94619,19,72),(94620,19,76),(94276,20,1),(94284,20,2),(94283,20,3),(94282,20,5),(94281,20,6),(94268,20,9),(94280,20,11),(94269,20,13),(94275,20,15),(94270,20,16),(94279,20,17),(94285,20,18),(94274,20,19),(94267,20,20),(94286,20,21),(94287,20,22),(94288,20,30),(94289,20,31),(94290,20,32),(94291,20,33),(94292,20,34),(94273,20,35),(94293,20,36),(94294,20,37),(94295,20,38),(94296,20,39),(94297,20,40),(94298,20,41),(94299,20,42),(94300,20,43),(94301,20,44),(94302,20,45),(94303,20,47),(94304,20,48),(94305,20,49),(94278,20,50),(94306,20,51),(94307,20,52),(94308,20,53),(94309,20,54),(94310,20,55),(94311,20,56),(94312,20,57),(94313,20,58),(94314,20,59),(94315,20,60),(94316,20,61),(94317,20,64),(94271,20,65),(94318,20,67),(94319,20,69),(94320,20,70),(94321,20,71),(94322,20,72),(94323,20,73),(94324,20,74),(94325,20,75),(94272,20,76),(94326,20,101),(94327,20,102),(94277,20,103),(94608,21,1),(94611,21,2),(94610,21,3),(94613,21,6),(94612,21,11),(94603,21,13),(94604,21,18),(94602,21,21),(94605,21,53),(94609,21,70),(94606,21,72),(94607,21,76),(94725,22,1),(94731,22,2),(94730,22,3),(94733,22,6),(94732,22,11),(94722,22,13),(94724,22,18),(94723,22,21),(94721,22,22),(94726,22,53),(94729,22,70),(94727,22,72),(94728,22,76),(93970,30,1),(93978,30,2),(93977,30,3),(93959,30,5),(93990,30,6),(93967,30,9),(93991,30,11),(93966,30,13),(93972,30,15),(93965,30,16),(93989,30,17),(93975,30,18),(93979,30,19),(93960,30,20),(93969,30,21),(93961,30,22),(93958,30,30),(93988,30,31),(93987,30,32),(93968,30,33),(93986,30,34),(93980,30,35),(93985,30,36),(93984,30,37),(93983,30,38),(93982,30,39),(93992,30,40),(93993,30,41),(93994,30,42),(93995,30,43),(93996,30,44),(93997,30,45),(93998,30,47),(93999,30,48),(94000,30,49),(93981,30,50),(94001,30,51),(94002,30,52),(93962,30,53),(94003,30,54),(94004,30,55),(94005,30,56),(94006,30,57),(94007,30,58),(94008,30,59),(94009,30,60),(94010,30,61),(93963,30,64),(93971,30,65),(94011,30,67),(94012,30,69),(93976,30,70),(94013,30,71),(93974,30,72),(94014,30,73),(94015,30,74),(94016,30,75),(93964,30,76),(94017,30,101),(94018,30,102),(93973,30,103),(94020,31,1),(94021,31,2),(94022,31,3),(94025,31,6),(94024,31,11),(94019,31,31),(94023,31,70),(93932,32,1),(93933,32,2),(93934,32,3),(93937,32,6),(93936,32,11),(93931,32,32),(93935,32,70),(94085,33,33),(93732,34,1),(93737,34,2),(93736,34,3),(93739,34,6),(93738,34,11),(93733,34,13),(93734,34,33),(93731,34,34),(93735,34,70),(93774,35,1),(93779,35,2),(93778,35,3),(93781,35,6),(93780,35,11),(93773,35,35),(93777,35,70),(93775,35,75),(93776,35,76),(94515,36,1),(94517,36,2),(94516,36,3),(94520,36,6),(94519,36,11),(94512,36,36),(94513,36,44),(94514,36,47),(94518,36,70),(94058,37,1),(94063,37,2),(94062,37,3),(94065,37,6),(94064,37,11),(94057,37,37),(94061,37,70),(94059,37,74),(94060,37,76),(94072,38,1),(94075,38,2),(94074,38,3),(94077,38,6),(94076,38,11),(94067,38,13),(94068,38,37),(94066,38,38),(94069,38,64),(94073,38,70),(94071,38,74),(94070,38,76),(93627,39,1),(93633,39,2),(93632,39,3),(93620,39,5),(93635,39,6),(93634,39,11),(93625,39,13),(93624,39,18),(93621,39,21),(93626,39,33),(93619,39,39),(93628,39,53),(93630,39,56),(93622,39,57),(93631,39,70),(93629,39,72),(93623,39,76),(94029,40,1),(94032,40,2),(94031,40,3),(94039,40,6),(94038,40,11),(94034,40,36),(94028,40,40),(94037,40,44),(94036,40,47),(94030,40,49),(94035,40,58),(94033,40,70),(94047,41,1),(94051,41,2),(94050,41,3),(94056,41,6),(94055,41,11),(94041,41,13),(94042,41,35),(94048,41,36),(94043,41,40),(94040,41,41),(94054,41,44),(94053,41,47),(94045,41,49),(94052,41,58),(94049,41,70),(94046,41,75),(94044,41,76),(93746,42,1),(93751,42,2),(93750,42,3),(93754,42,6),(93753,42,11),(93741,42,35),(93744,42,36),(93740,42,42),(93748,42,44),(93752,42,47),(93742,42,49),(93747,42,58),(93749,42,70),(93745,42,75),(93743,42,76),(93759,43,1),(93765,43,2),(93764,43,3),(93771,43,6),(93770,43,11),(93756,43,13),(93758,43,35),(93766,43,36),(93757,43,42),(93755,43,43),(93769,43,44),(93768,43,47),(93760,43,49),(93767,43,58),(93763,43,70),(93762,43,75),(93761,43,76),(93602,44,1),(93603,44,2),(93604,44,3),(93607,44,6),(93606,44,11),(93601,44,44),(93605,44,70),(93611,45,1),(93613,45,2),(93612,45,3),(93616,45,6),(93615,45,11),(93609,45,13),(93610,45,44),(93608,45,45),(93614,45,70),(93814,47,1),(93815,47,2),(93816,47,3),(93819,47,6),(93818,47,11),(93813,47,47),(93817,47,70),(93837,48,1),(93840,48,2),(93839,48,3),(93842,48,6),(93841,48,11),(93832,48,13),(93833,48,35),(93834,48,47),(93831,48,48),(93838,48,70),(93836,48,75),(93835,48,76),(94429,49,1),(94432,49,2),(94431,49,3),(94434,49,6),(94433,49,11),(94425,49,36),(94428,49,44),(94427,49,47),(94424,49,49),(94426,49,58),(94430,49,70),(94475,50,1),(94482,50,2),(94481,50,3),(94484,50,6),(94483,50,11),(94462,50,13),(94474,50,18),(94463,50,21),(94476,50,33),(94464,50,35),(94470,50,36),(94479,50,44),(94478,50,47),(94465,50,49),(94461,50,50),(94473,50,53),(94477,50,56),(94466,50,57),(94469,50,58),(94467,50,59),(94480,50,70),(94472,50,72),(94471,50,75),(94468,50,76),(94329,51,1),(94334,51,2),(94333,51,3),(94336,51,6),(94335,51,11),(94328,51,51),(94332,51,70),(94330,51,74),(94331,51,75),(94346,52,1),(94351,52,2),(94350,52,3),(94354,52,6),(94353,52,11),(94338,52,13),(94348,52,18),(94339,52,19),(94345,52,21),(94340,52,35),(94341,52,51),(94337,52,52),(94347,52,53),(94349,52,70),(94352,52,72),(94343,52,74),(94344,52,75),(94342,52,76),(94079,53,1),(94080,53,2),(94081,53,3),(94084,53,6),(94083,53,11),(94078,53,53),(94082,53,70),(94218,54,1),(94219,54,2),(94220,54,3),(94223,54,6),(94222,54,11),(94217,54,54),(94221,54,70),(94227,55,1),(94229,55,2),(94228,55,3),(94232,55,6),(94231,55,11),(94225,55,13),(94226,55,54),(94224,55,55),(94230,55,70),(93847,56,1),(93848,56,2),(93849,56,3),(93852,56,6),(93851,56,11),(93846,56,56),(93850,56,70),(93858,57,1),(93861,57,2),(93860,57,3),(93863,57,6),(93862,57,11),(93854,57,13),(93855,57,33),(93856,57,56),(93853,57,57),(93859,57,70),(93857,57,76),(94383,58,1),(94384,58,2),(94385,58,3),(94388,58,6),(94387,58,11),(94382,58,58),(94386,58,70),(94393,59,1),(94403,59,2),(94402,59,3),(94412,59,6),(94411,59,11),(94390,59,13),(94400,59,18),(94392,59,21),(94407,59,33),(94394,59,35),(94405,59,36),(94410,59,44),(94409,59,47),(94395,59,49),(94391,59,50),(94399,59,53),(94408,59,56),(94396,59,57),(94406,59,58),(94389,59,59),(94401,59,70),(94398,59,72),(94404,59,75),(94397,59,76),(94443,60,1),(94455,60,2),(94454,60,3),(94436,60,5),(94460,60,6),(94459,60,11),(94440,60,13),(94452,60,18),(94442,60,21),(94441,60,33),(94444,60,35),(94448,60,36),(94458,60,44),(94457,60,47),(94445,60,49),(94437,60,50),(94451,60,53),(94447,60,56),(94438,60,57),(94456,60,58),(94446,60,59),(94435,60,60),(94453,60,70),(94450,60,72),(94449,60,75),(94439,60,76),(94525,61,1),(94529,61,2),(94528,61,3),(94531,61,6),(94530,61,11),(94522,61,13),(94523,61,36),(94524,61,44),(94526,61,47),(94521,61,61),(94527,61,70),(94355,62,62),(93772,64,64),(94363,65,1),(94371,65,2),(94370,65,3),(94381,65,6),(94380,65,11),(94361,65,13),(94374,65,18),(94357,65,19),(94364,65,21),(94376,65,33),(94358,65,35),(94368,65,36),(94379,65,44),(94378,65,47),(94365,65,49),(94359,65,50),(94373,65,53),(94377,65,56),(94366,65,57),(94375,65,58),(94367,65,59),(94356,65,65),(94369,65,70),(94372,65,72),(94362,65,75),(94360,65,76),(94649,66,1),(94648,66,2),(94650,66,3),(94651,66,5),(94652,66,6),(94646,66,9),(94653,66,11),(94654,66,13),(94655,66,15),(94656,66,16),(94657,66,17),(94658,66,18),(94659,66,19),(94660,66,20),(94661,66,21),(94662,66,22),(94663,66,30),(94664,66,31),(94665,66,32),(94666,66,33),(94667,66,34),(94668,66,35),(94669,66,36),(94670,66,37),(94671,66,38),(94672,66,39),(94673,66,40),(94674,66,41),(94675,66,42),(94676,66,43),(94677,66,44),(94678,66,45),(94679,66,47),(94680,66,48),(94681,66,49),(94682,66,50),(94683,66,51),(94684,66,52),(94685,66,53),(94686,66,54),(94687,66,55),(94688,66,56),(94689,66,57),(94690,66,58),(94691,66,59),(94692,66,60),(94693,66,61),(94694,66,64),(94695,66,65),(94645,66,66),(94696,66,67),(94697,66,69),(94698,66,70),(94699,66,71),(94700,66,72),(94701,66,73),(94702,66,74),(94703,66,75),(94704,66,76),(94705,66,101),(94706,66,102),(94647,66,103),(93715,67,1),(93723,67,2),(93722,67,3),(93712,67,5),(93727,67,6),(93726,67,11),(93720,67,13),(93719,67,18),(93714,67,21),(93716,67,33),(93713,67,37),(93724,67,53),(93711,67,67),(93721,67,70),(93725,67,72),(93718,67,74),(93717,67,76),(93824,69,1),(93828,69,2),(93827,69,3),(93830,69,6),(93829,69,11),(93821,69,35),(93822,69,47),(93820,69,69),(93826,69,70),(93823,69,75),(93825,69,76),(94736,70,6),(94735,70,11),(94734,70,70),(93796,71,1),(93799,71,2),(93798,71,3),(93802,71,6),(93801,71,11),(93797,71,58),(93800,71,70),(93795,71,71),(93807,72,1),(93809,72,2),(93808,72,3),(93812,72,6),(93811,72,11),(93804,72,13),(93805,72,18),(93810,72,70),(93803,72,72),(93806,72,76),(93947,73,1),(93952,73,2),(93951,73,3),(93942,73,5),(93957,73,6),(93956,73,11),(93949,73,13),(93953,73,18),(93943,73,19),(93946,73,21),(93945,73,33),(93954,73,53),(93944,73,64),(93950,73,70),(93955,73,72),(93941,73,73),(93948,73,76),(94737,74,74),(93793,75,75),(93794,76,76),(94558,100,1),(94554,100,2),(94540,100,3),(94538,100,5),(94565,100,6),(94557,100,9),(94535,100,11),(94598,100,13),(94576,100,15),(94577,100,16),(94537,100,17),(94594,100,18),(94593,100,19),(94578,100,20),(94592,100,21),(94599,100,22),(94562,100,30),(94563,100,31),(94559,100,32),(94571,100,33),(94541,100,34),(94545,100,35),(94590,100,36),(94568,100,37),(94569,100,38),(94536,100,39),(94566,100,40),(94567,100,41),(94542,100,42),(94543,100,43),(94533,100,44),(94534,100,45),(94551,100,47),(94553,100,48),(94586,100,49),(94588,100,50),(94579,100,51),(94580,100,52),(94570,100,53),(94574,100,54),(94575,100,55),(94555,100,56),(94556,100,57),(94583,100,58),(94584,100,59),(94587,100,60),(94591,100,61),(94581,100,62),(94544,100,64),(94582,100,65),(94596,100,66),(94539,100,67),(94552,100,69),(94600,100,70),(94549,100,71),(94550,100,72),(94561,100,73),(94601,100,74),(94547,100,75),(94548,100,76),(94532,100,100),(94546,100,101),(94585,100,102),(94572,100,103),(94573,100,104),(94564,100,105),(94560,100,106),(94589,100,107),(94597,100,108),(94595,100,109),(93786,101,1),(93790,101,2),(93789,101,3),(93792,101,6),(93791,101,11),(93783,101,13),(93784,101,35),(93788,101,70),(93785,101,75),(93787,101,76),(93782,101,101),(94414,102,1),(94419,102,2),(94418,102,3),(94423,102,6),(94422,102,11),(94415,102,13),(94416,102,35),(94417,102,70),(94420,102,75),(94421,102,76),(94413,102,102),(94087,103,1),(94088,103,2),(94089,103,3),(94090,103,5),(94091,103,6),(94146,103,9),(94092,103,11),(94093,103,13),(94094,103,15),(94095,103,16),(94096,103,17),(94097,103,18),(94098,103,19),(94099,103,20),(94100,103,21),(94101,103,22),(94102,103,30),(94103,103,31),(94104,103,32),(94105,103,33),(94106,103,34),(94107,103,35),(94108,103,36),(94109,103,37),(94110,103,38),(94111,103,39),(94112,103,40),(94113,103,41),(94114,103,42),(94115,103,43),(94116,103,44),(94117,103,45),(94118,103,47),(94119,103,48),(94120,103,49),(94121,103,50),(94122,103,51),(94123,103,52),(94124,103,53),(94125,103,54),(94126,103,55),(94127,103,56),(94128,103,57),(94129,103,58),(94130,103,59),(94131,103,60),(94132,103,61),(94133,103,64),(94134,103,65),(94135,103,67),(94136,103,69),(94137,103,70),(94138,103,71),(94139,103,72),(94140,103,73),(94141,103,74),(94142,103,75),(94143,103,76),(94144,103,101),(94145,103,102),(94086,103,103),(94155,104,1),(94154,104,2),(94153,104,3),(94152,104,5),(94156,104,6),(94148,104,9),(94157,104,11),(94158,104,13),(94159,104,15),(94160,104,16),(94161,104,17),(94162,104,18),(94163,104,19),(94164,104,20),(94165,104,21),(94166,104,22),(94167,104,30),(94168,104,31),(94169,104,32),(94170,104,33),(94171,104,34),(94172,104,35),(94173,104,36),(94174,104,37),(94175,104,38),(94176,104,39),(94177,104,40),(94178,104,41),(94179,104,42),(94180,104,43),(94181,104,44),(94182,104,45),(94183,104,47),(94184,104,48),(94185,104,49),(94186,104,50),(94187,104,51),(94188,104,52),(94189,104,53),(94190,104,54),(94191,104,55),(94192,104,56),(94193,104,57),(94194,104,58),(94195,104,59),(94196,104,60),(94197,104,61),(94213,104,62),(94198,104,64),(94199,104,65),(94149,104,66),(94200,104,67),(94201,104,69),(94202,104,70),(94203,104,71),(94204,104,72),(94205,104,73),(94206,104,74),(94207,104,75),(94208,104,76),(94150,104,100),(94209,104,101),(94210,104,102),(94151,104,103),(94147,104,104),(94212,104,105),(94211,104,106),(94214,104,107),(94216,104,108),(94215,104,109),(94026,105,105),(93940,106,6),(93939,106,11),(93938,106,106),(94494,107,1),(94506,107,2),(94505,107,3),(94487,107,5),(94511,107,6),(94510,107,11),(94491,107,13),(94503,107,18),(94493,107,21),(94492,107,33),(94495,107,35),(94499,107,36),(94509,107,44),(94508,107,47),(94496,107,49),(94488,107,50),(94502,107,53),(94498,107,56),(94489,107,57),(94507,107,58),(94497,107,59),(94486,107,60),(94504,107,70),(94501,107,72),(94500,107,75),(94490,107,76),(94485,107,107),(94708,108,1),(94709,108,2),(94710,108,3),(94713,108,6),(94712,108,11),(94711,108,70),(94707,108,108),(94639,109,1),(94641,109,2),(94640,109,3),(94644,109,6),(94643,109,11),(94636,109,13),(94637,109,18),(94642,109,70),(94638,109,76),(94635,109,109);
/*!40000 ALTER TABLE `roleRole` ENABLE KEYS */;
UNLOCK TABLES;
@@ -140,9 +140,9 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2022-05-04 15:58:27
+-- Dump completed on 2022-06-23 12:13:31
USE `salix`;
--- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64)
+-- MariaDB dump 10.19 Distrib 10.6.8-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: db.verdnatura.es Database: salix
-- ------------------------------------------------------
@@ -164,7 +164,7 @@ USE `salix`;
LOCK TABLES `ACL` WRITE;
/*!40000 ALTER TABLE `ACL` DISABLE KEYS */;
-INSERT INTO `ACL` VALUES (1,'Account','*','*','ALLOW','ROLE','employee'),(3,'Address','*','*','ALLOW','ROLE','employee'),(5,'AgencyService','*','READ','ALLOW','ROLE','employee'),(7,'Client','*','*','ALLOW','ROLE','employee'),(9,'ClientObservation','*','*','ALLOW','ROLE','employee'),(11,'ContactChannel','*','READ','ALLOW','ROLE','trainee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','trainee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','trainee'),(18,'State','*','READ','ALLOW','ROLE','employee'),(20,'TicketState','*','*','ALLOW','ROLE','employee'),(24,'Delivery','*','READ','ALLOW','ROLE','employee'),(25,'Zone','*','READ','ALLOW','ROLE','employee'),(26,'ClientCredit','*','*','ALLOW','ROLE','employee'),(27,'ClientCreditLimit','*','READ','ALLOW','ROLE','trainee'),(30,'GreugeType','*','READ','ALLOW','ROLE','trainee'),(31,'Mandate','*','READ','ALLOW','ROLE','trainee'),(32,'MandateType','*','READ','ALLOW','ROLE','trainee'),(33,'Company','*','READ','ALLOW','ROLE','trainee'),(34,'Greuge','*','READ','ALLOW','ROLE','trainee'),(35,'AddressObservation','*','*','ALLOW','ROLE','employee'),(36,'ObservationType','*','*','ALLOW','ROLE','employee'),(37,'Greuge','*','WRITE','ALLOW','ROLE','employee'),(38,'AgencyMode','*','READ','ALLOW','ROLE','employee'),(39,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(40,'ItemBotanical','*','WRITE','ALLOW','ROLE','buyer'),(41,'ItemBotanical','*','READ','ALLOW','ROLE','employee'),(42,'ItemPlacement','*','WRITE','ALLOW','ROLE','buyer'),(43,'ItemPlacement','*','WRITE','ALLOW','ROLE','replenisher'),(44,'ItemPlacement','*','READ','ALLOW','ROLE','employee'),(45,'ItemBarcode','*','READ','ALLOW','ROLE','employee'),(46,'ItemBarcode','*','WRITE','ALLOW','ROLE','buyer'),(47,'ItemBarcode','*','WRITE','ALLOW','ROLE','replenisher'),(51,'ItemTag','*','READ','ALLOW','ROLE','employee'),(53,'Item','*','READ','ALLOW','ROLE','employee'),(54,'Item','*','WRITE','ALLOW','ROLE','buyer'),(55,'Recovery','*','READ','ALLOW','ROLE','trainee'),(56,'Recovery','*','WRITE','ALLOW','ROLE','administrative'),(58,'CreditClassification','*','*','ALLOW','ROLE','insurance'),(60,'CreditInsurance','*','*','ALLOW','ROLE','insurance'),(61,'InvoiceOut','*','READ','ALLOW','ROLE','employee'),(62,'Ticket','*','*','ALLOW','ROLE','employee'),(63,'TicketObservation','*','*','ALLOW','ROLE','employee'),(64,'Route','*','READ','ALLOW','ROLE','employee'),(65,'Sale','*','READ','ALLOW','ROLE','employee'),(66,'TicketTracking','*','READ','ALLOW','ROLE','employee'),(68,'TicketPackaging','*','*','ALLOW','ROLE','employee'),(69,'Packaging','*','READ','ALLOW','ROLE','employee'),(70,'Packaging','*','WRITE','ALLOW','ROLE','logistic'),(71,'SaleChecked','*','READ','ALLOW','ROLE','employee'),(72,'SaleComponent','*','READ','ALLOW','ROLE','employee'),(73,'Expedition','*','READ','ALLOW','ROLE','employee'),(74,'Expedition','*','WRITE','ALLOW','ROLE','deliveryBoss'),(75,'Expedition','*','WRITE','ALLOW','ROLE','production'),(76,'AnnualAverageInvoiced','*','READ','ALLOW','ROLE','employee'),(77,'WorkerMana','*','READ','ALLOW','ROLE','employee'),(78,'TicketTracking','*','WRITE','ALLOW','ROLE','production'),(79,'TicketTracking','changeState','*','ALLOW','ROLE','employee'),(80,'Sale','deleteSales','*','ALLOW','ROLE','employee'),(81,'Sale','moveToTicket','*','ALLOW','ROLE','employee'),(82,'Sale','updateQuantity','*','ALLOW','ROLE','employee'),(83,'Sale','updatePrice','*','ALLOW','ROLE','employee'),(84,'Sale','updateDiscount','*','ALLOW','ROLE','employee'),(85,'SaleTracking','*','READ','ALLOW','ROLE','employee'),(86,'Order','*','*','ALLOW','ROLE','employee'),(87,'OrderRow','*','*','ALLOW','ROLE','employee'),(88,'ClientContact','*','*','ALLOW','ROLE','employee'),(89,'Sale','moveToNewTicket','*','ALLOW','ROLE','employee'),(90,'Sale','reserve','*','ALLOW','ROLE','employee'),(91,'TicketWeekly','*','READ','ALLOW','ROLE','employee'),(94,'Agency','landsThatDay','*','ALLOW','ROLE','employee'),(96,'ClaimEnd','*','READ','ALLOW','ROLE','employee'),(97,'ClaimEnd','*','WRITE','ALLOW','ROLE','claimManager'),(98,'ClaimBeginning','*','*','ALLOW','ROLE','employee'),(99,'ClaimDevelopment','*','READ','ALLOW','ROLE','employee'),(100,'ClaimDevelopment','*','WRITE','ALLOW','ROLE','claimManager'),(101,'Claim','*','*','ALLOW','ROLE','employee'),(102,'Claim','createFromSales','*','ALLOW','ROLE','employee'),(104,'Item','*','WRITE','ALLOW','ROLE','marketingBoss'),(105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketingBoss'),(106,'ItemBotanical','*','WRITE','ALLOW','ROLE','marketingBoss'),(108,'ItemPlacement','*','WRITE','ALLOW','ROLE','marketingBoss'),(109,'UserConfig','*','*','ALLOW','ROLE','employee'),(110,'Bank','*','READ','ALLOW','ROLE','trainee'),(111,'ClientLog','*','READ','ALLOW','ROLE','trainee'),(112,'Defaulter','*','READ','ALLOW','ROLE','employee'),(113,'ClientRisk','*','READ','ALLOW','ROLE','trainee'),(114,'Receipt','*','READ','ALLOW','ROLE','trainee'),(115,'Receipt','*','WRITE','ALLOW','ROLE','administrative'),(116,'BankEntity','*','*','ALLOW','ROLE','employee'),(117,'ClientSample','*','*','ALLOW','ROLE','employee'),(118,'WorkerTeam','*','*','ALLOW','ROLE','salesPerson'),(119,'Travel','*','READ','ALLOW','ROLE','employee'),(120,'Travel','*','WRITE','ALLOW','ROLE','buyer'),(121,'Item','regularize','*','ALLOW','ROLE','employee'),(122,'TicketRequest','*','*','ALLOW','ROLE','employee'),(123,'Worker','*','*','ALLOW','ROLE','employee'),(124,'Client','confirmTransaction','WRITE','ALLOW','ROLE','administrative'),(125,'Agency','getAgenciesWithWarehouse','*','ALLOW','ROLE','employee'),(126,'Client','activeWorkersWithRole','*','ALLOW','ROLE','employee'),(127,'TicketLog','*','READ','ALLOW','ROLE','employee'),(129,'TicketService','*','*','ALLOW','ROLE','employee'),(130,'Expedition','*','WRITE','ALLOW','ROLE','packager'),(131,'CreditInsurance','*','READ','ALLOW','ROLE','trainee'),(132,'CreditClassification','*','READ','ALLOW','ROLE','trainee'),(133,'ItemTag','*','WRITE','ALLOW','ROLE','marketingBoss'),(135,'ZoneGeo','*','READ','ALLOW','ROLE','employee'),(136,'ZoneCalendar','*','READ','ALLOW','ROLE','employee'),(137,'ZoneIncluded','*','READ','ALLOW','ROLE','employee'),(138,'LabourHoliday','*','READ','ALLOW','ROLE','employee'),(139,'LabourHolidayLegend','*','READ','ALLOW','ROLE','employee'),(140,'LabourHolidayType','*','READ','ALLOW','ROLE','employee'),(141,'Zone','*','*','ALLOW','ROLE','deliveryBoss'),(142,'ZoneCalendar','*','WRITE','ALLOW','ROLE','deliveryBoss'),(143,'ZoneIncluded','*','*','ALLOW','ROLE','deliveryBoss'),(144,'Stowaway','*','*','ALLOW','ROLE','employee'),(145,'Ticket','getPossibleStowaways','READ','ALLOW','ROLE','employee'),(147,'UserConfigView','*','*','ALLOW','ROLE','employee'),(148,'UserConfigView','*','*','ALLOW','ROLE','employee'),(149,'Sip','*','READ','ALLOW','ROLE','employee'),(150,'Sip','*','WRITE','ALLOW','ROLE','hr'),(151,'Department','*','READ','ALLOW','ROLE','employee'),(152,'Department','*','WRITE','ALLOW','ROLE','hr'),(153,'Route','*','READ','ALLOW','ROLE','employee'),(154,'Route','*','WRITE','ALLOW','ROLE','delivery'),(155,'Calendar','*','READ','ALLOW','ROLE','hr'),(156,'WorkerLabour','*','READ','ALLOW','ROLE','hr'),(157,'Calendar','absences','READ','ALLOW','ROLE','employee'),(158,'ItemTag','*','WRITE','ALLOW','ROLE','accessory'),(160,'TicketServiceType','*','READ','ALLOW','ROLE','employee'),(161,'TicketConfig','*','READ','ALLOW','ROLE','employee'),(162,'InvoiceOut','delete','WRITE','ALLOW','ROLE','invoicing'),(163,'InvoiceOut','book','WRITE','ALLOW','ROLE','invoicing'),(165,'TicketDms','*','*','ALLOW','ROLE','employee'),(167,'Worker','isSubordinate','READ','ALLOW','ROLE','employee'),(168,'Worker','mySubordinates','READ','ALLOW','ROLE','employee'),(169,'WorkerTimeControl','filter','READ','ALLOW','ROLE','employee'),(170,'WorkerTimeControl','addTime','WRITE','ALLOW','ROLE','employee'),(171,'TicketServiceType','*','WRITE','ALLOW','ROLE','administrative'),(172,'Sms','*','READ','ALLOW','ROLE','employee'),(173,'Sms','send','WRITE','ALLOW','ROLE','employee'),(174,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(175,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(176,'Device','*','*','ALLOW','ROLE','employee'),(177,'Device','*','*','ALLOW','ROLE','employee'),(178,'WorkerTimeControl','*','*','ALLOW','ROLE','employee'),(179,'ItemLog','*','READ','ALLOW','ROLE','employee'),(180,'RouteLog','*','READ','ALLOW','ROLE','employee'),(181,'Dms','removeFile','WRITE','ALLOW','ROLE','employee'),(182,'Dms','uploadFile','WRITE','ALLOW','ROLE','employee'),(183,'Dms','downloadFile','READ','ALLOW','ROLE','employee'),(184,'Client','uploadFile','WRITE','ALLOW','ROLE','employee'),(185,'ClientDms','removeFile','WRITE','ALLOW','ROLE','employee'),(186,'ClientDms','*','READ','ALLOW','ROLE','trainee'),(187,'Ticket','uploadFile','WRITE','ALLOW','ROLE','employee'),(190,'Route','updateVolume','WRITE','ALLOW','ROLE','deliveryBoss'),(191,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(192,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(194,'Postcode','*','WRITE','ALLOW','ROLE','deliveryBoss'),(195,'Ticket','addSale','WRITE','ALLOW','ROLE','employee'),(196,'Dms','updateFile','WRITE','ALLOW','ROLE','employee'),(197,'Dms','*','READ','ALLOW','ROLE','trainee'),(198,'ClaimDms','removeFile','WRITE','ALLOW','ROLE','employee'),(199,'ClaimDms','*','READ','ALLOW','ROLE','employee'),(200,'Claim','uploadFile','WRITE','ALLOW','ROLE','employee'),(201,'Sale','updateConcept','WRITE','ALLOW','ROLE','employee'),(202,'Claim','updateClaimAction','WRITE','ALLOW','ROLE','claimManager'),(203,'UserPhone','*','*','ALLOW','ROLE','employee'),(204,'WorkerDms','removeFile','WRITE','ALLOW','ROLE','hr'),(205,'WorkerDms','*','READ','ALLOW','ROLE','hr'),(206,'Chat','*','*','ALLOW','ROLE','employee'),(207,'Chat','sendMessage','*','ALLOW','ROLE','employee'),(208,'Sale','recalculatePrice','WRITE','ALLOW','ROLE','employee'),(209,'Ticket','recalculateComponents','WRITE','ALLOW','ROLE','employee'),(211,'TravelLog','*','READ','ALLOW','ROLE','buyer'),(212,'Thermograph','*','*','ALLOW','ROLE','buyer'),(213,'TravelThermograph','*','WRITE','ALLOW','ROLE','buyer'),(214,'Entry','*','*','ALLOW','ROLE','buyer'),(215,'TicketWeekly','*','WRITE','ALLOW','ROLE','buyer'),(216,'TravelThermograph','*','READ','ALLOW','ROLE','employee'),(218,'Intrastat','*','*','ALLOW','ROLE','buyer'),(219,'Account','acl','READ','ALLOW','ROLE','account'),(220,'Account','getCurrentUserData','READ','ALLOW','ROLE','account'),(221,'UserConfig','getUserConfig','READ','ALLOW','ROLE','account'),(222,'Client','*','READ','ALLOW','ROLE','trainee'),(226,'ClientObservation','*','READ','ALLOW','ROLE','trainee'),(227,'Address','*','READ','ALLOW','ROLE','trainee'),(228,'AddressObservation','*','READ','ALLOW','ROLE','trainee'),(230,'ClientCredit','*','READ','ALLOW','ROLE','trainee'),(231,'ClientContact','*','READ','ALLOW','ROLE','trainee'),(232,'ClientSample','*','READ','ALLOW','ROLE','trainee'),(233,'EntryLog','*','READ','ALLOW','ROLE','buyer'),(234,'WorkerLog','*','READ','ALLOW','ROLE','salesAssistant'),(235,'CustomsAgent','*','*','ALLOW','ROLE','employee'),(236,'Buy','*','*','ALLOW','ROLE','buyer'),(237,'WorkerDms','filter','*','ALLOW','ROLE','employee'),(238,'Town','*','WRITE','ALLOW','ROLE','deliveryBoss'),(239,'Province','*','WRITE','ALLOW','ROLE','deliveryBoss'),(240,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(241,'SupplierContact','*','WRITE','ALLOW','ROLE','administrative'),(242,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(244,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(246,'Account','changePassword','*','ALLOW','ROLE','account'),(247,'UserAccount','exists','*','ALLOW','ROLE','account'),(248,'RoleMapping','*','READ','ALLOW','ROLE','account'),(249,'UserPassword','*','READ','ALLOW','ROLE','account'),(250,'Town','*','WRITE','ALLOW','ROLE','deliveryBoss'),(251,'Province','*','WRITE','ALLOW','ROLE','deliveryBoss'),(252,'Supplier','*','READ','ALLOW','ROLE','employee'),(253,'Supplier','*','WRITE','ALLOW','ROLE','administrative'),(254,'SupplierLog','*','READ','ALLOW','ROLE','employee'),(256,'Image','*','WRITE','ALLOW','ROLE','employee'),(257,'FixedPrice','*','*','ALLOW','ROLE','buyer'),(258,'PayDem','*','READ','ALLOW','ROLE','employee'),(259,'Client','createReceipt','*','ALLOW','ROLE','salesAssistant'),(260,'PrintServerQueue','*','WRITE','ALLOW','ROLE','employee'),(261,'SupplierAccount','*','*','ALLOW','ROLE','administrative'),(262,'Entry','*','*','ALLOW','ROLE','administrative'),(263,'InvoiceIn','*','*','ALLOW','ROLE','administrative'),(264,'StarredModule','*','*','ALLOW','ROLE','employee'),(265,'ItemBotanical','*','WRITE','ALLOW','ROLE','logisticBoss'),(266,'ZoneLog','*','READ','ALLOW','ROLE','employee'),(267,'Genus','*','WRITE','ALLOW','ROLE','logisticBoss'),(268,'Specie','*','WRITE','ALLOW','ROLE','logisticBoss'),(269,'InvoiceOut','createPdf','WRITE','ALLOW','ROLE','employee'),(270,'SupplierAddress','*','*','ALLOW','ROLE','employee'),(271,'SalesMonitor','*','*','ALLOW','ROLE','employee'),(272,'InvoiceInLog','*','*','ALLOW','ROLE','employee'),(273,'InvoiceInTax','*','*','ALLOW','ROLE','administrative'),(274,'InvoiceInLog','*','READ','ALLOW','ROLE','administrative'),(275,'InvoiceOut','createManualInvoice','WRITE','ALLOW','ROLE','invoicing'),(276,'InvoiceOut','globalInvoicing','WRITE','ALLOW','ROLE','invoicing'),(277,'Role','*','*','ALLOW','ROLE','it'),(278,'RoleInherit','*','WRITE','ALLOW','ROLE','grant'),(279,'MailAlias','*','*','ALLOW','ROLE','marketing'),(282,'UserAccount','*','WRITE','ALLOW','ROLE','it'),(283,'EntryObservation','*','*','ALLOW','ROLE','buyer'),(284,'LdapConfig','*','*','ALLOW','ROLE','sysadmin'),(285,'SambaConfig','*','*','ALLOW','ROLE','sysadmin'),(286,'ACL','*','*','ALLOW','ROLE','developer'),(287,'AccessToken','*','*','ALLOW','ROLE','developer'),(288,'MailAliasAccount','*','*','ALLOW','ROLE','marketing'),(289,'MailAliasAccount','*','*','ALLOW','ROLE','hr'),(290,'MailAlias','*','*','ALLOW','ROLE','hr'),(291,'MailForward','*','*','ALLOW','ROLE','marketing'),(292,'MailForward','*','*','ALLOW','ROLE','hr'),(293,'RoleInherit','*','*','ALLOW','ROLE','it'),(294,'RoleRole','*','*','ALLOW','ROLE','it'),(295,'AccountConfig','*','*','ALLOW','ROLE','sysadmin'),(296,'Collection','*','READ','ALLOW','ROLE','employee'),(297,'Sale','payBack','WRITE','ALLOW','ROLE','employee'),(298,'InvoiceInDueDay','*','*','ALLOW','ROLE','administrative'),(299,'Collection','setSaleQuantity','*','ALLOW','ROLE','employee'),(300,'Docuware','*','*','ALLOW','ROLE','employee'),(301,'Agency','*','READ','ALLOW','ROLE','employee'),(302,'AgencyTerm','*','*','ALLOW','ROLE','administrative'),(303,'ClaimLog','*','READ','ALLOW','ROLE','claimManager'),(304,'Edi','updateData','WRITE','ALLOW','ROLE','employee'),(305,'EducationLevel','*','*','ALLOW','ROLE','employee'),(306,'InvoiceInIntrastat','*','*','ALLOW','ROLE','employee'),(307,'SupplierAgencyTerm','*','*','ALLOW','ROLE','administrative'),(308,'InvoiceInIntrastat','*','*','ALLOW','ROLE','employee');
+INSERT INTO `ACL` VALUES (1,'Account','*','*','ALLOW','ROLE','employee'),(3,'Address','*','*','ALLOW','ROLE','employee'),(5,'AgencyService','*','READ','ALLOW','ROLE','employee'),(7,'Client','*','*','ALLOW','ROLE','employee'),(9,'ClientObservation','*','*','ALLOW','ROLE','employee'),(11,'ContactChannel','*','READ','ALLOW','ROLE','trainee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','trainee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','trainee'),(18,'State','*','READ','ALLOW','ROLE','employee'),(20,'TicketState','*','*','ALLOW','ROLE','employee'),(24,'Delivery','*','READ','ALLOW','ROLE','employee'),(25,'Zone','*','READ','ALLOW','ROLE','employee'),(26,'ClientCredit','*','*','ALLOW','ROLE','employee'),(27,'ClientCreditLimit','*','READ','ALLOW','ROLE','trainee'),(30,'GreugeType','*','READ','ALLOW','ROLE','trainee'),(31,'Mandate','*','READ','ALLOW','ROLE','trainee'),(32,'MandateType','*','READ','ALLOW','ROLE','trainee'),(33,'Company','*','READ','ALLOW','ROLE','trainee'),(34,'Greuge','*','READ','ALLOW','ROLE','trainee'),(35,'AddressObservation','*','*','ALLOW','ROLE','employee'),(36,'ObservationType','*','*','ALLOW','ROLE','employee'),(37,'Greuge','*','WRITE','ALLOW','ROLE','employee'),(38,'AgencyMode','*','READ','ALLOW','ROLE','employee'),(39,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(40,'ItemBotanical','*','WRITE','ALLOW','ROLE','buyer'),(41,'ItemBotanical','*','READ','ALLOW','ROLE','employee'),(42,'ItemPlacement','*','WRITE','ALLOW','ROLE','buyer'),(43,'ItemPlacement','*','WRITE','ALLOW','ROLE','replenisher'),(44,'ItemPlacement','*','READ','ALLOW','ROLE','employee'),(45,'ItemBarcode','*','READ','ALLOW','ROLE','employee'),(46,'ItemBarcode','*','WRITE','ALLOW','ROLE','buyer'),(47,'ItemBarcode','*','WRITE','ALLOW','ROLE','replenisher'),(51,'ItemTag','*','READ','ALLOW','ROLE','employee'),(53,'Item','*','READ','ALLOW','ROLE','employee'),(54,'Item','*','WRITE','ALLOW','ROLE','buyer'),(55,'Recovery','*','READ','ALLOW','ROLE','trainee'),(56,'Recovery','*','WRITE','ALLOW','ROLE','administrative'),(58,'CreditClassification','*','*','ALLOW','ROLE','insurance'),(60,'CreditInsurance','*','*','ALLOW','ROLE','insurance'),(61,'InvoiceOut','*','READ','ALLOW','ROLE','employee'),(62,'Ticket','*','*','ALLOW','ROLE','employee'),(63,'TicketObservation','*','*','ALLOW','ROLE','employee'),(64,'Route','*','READ','ALLOW','ROLE','employee'),(65,'Sale','*','READ','ALLOW','ROLE','employee'),(66,'TicketTracking','*','READ','ALLOW','ROLE','employee'),(68,'TicketPackaging','*','*','ALLOW','ROLE','employee'),(69,'Packaging','*','READ','ALLOW','ROLE','employee'),(70,'Packaging','*','WRITE','ALLOW','ROLE','logistic'),(71,'SaleChecked','*','READ','ALLOW','ROLE','employee'),(72,'SaleComponent','*','READ','ALLOW','ROLE','employee'),(73,'Expedition','*','READ','ALLOW','ROLE','employee'),(74,'Expedition','*','WRITE','ALLOW','ROLE','deliveryBoss'),(75,'Expedition','*','WRITE','ALLOW','ROLE','production'),(76,'AnnualAverageInvoiced','*','READ','ALLOW','ROLE','employee'),(77,'WorkerMana','*','READ','ALLOW','ROLE','employee'),(78,'TicketTracking','*','WRITE','ALLOW','ROLE','production'),(79,'TicketTracking','changeState','*','ALLOW','ROLE','employee'),(80,'Sale','deleteSales','*','ALLOW','ROLE','employee'),(81,'Sale','moveToTicket','*','ALLOW','ROLE','employee'),(82,'Sale','updateQuantity','*','ALLOW','ROLE','employee'),(83,'Sale','updatePrice','*','ALLOW','ROLE','employee'),(84,'Sale','updateDiscount','*','ALLOW','ROLE','employee'),(85,'SaleTracking','*','READ','ALLOW','ROLE','employee'),(86,'Order','*','*','ALLOW','ROLE','employee'),(87,'OrderRow','*','*','ALLOW','ROLE','employee'),(88,'ClientContact','*','*','ALLOW','ROLE','employee'),(89,'Sale','moveToNewTicket','*','ALLOW','ROLE','employee'),(90,'Sale','reserve','*','ALLOW','ROLE','employee'),(91,'TicketWeekly','*','READ','ALLOW','ROLE','employee'),(94,'Agency','landsThatDay','*','ALLOW','ROLE','employee'),(96,'ClaimEnd','*','READ','ALLOW','ROLE','employee'),(97,'ClaimEnd','*','WRITE','ALLOW','ROLE','claimManager'),(98,'ClaimBeginning','*','*','ALLOW','ROLE','employee'),(99,'ClaimDevelopment','*','READ','ALLOW','ROLE','employee'),(100,'ClaimDevelopment','*','WRITE','ALLOW','ROLE','claimManager'),(101,'Claim','*','*','ALLOW','ROLE','employee'),(102,'Claim','createFromSales','*','ALLOW','ROLE','employee'),(104,'Item','*','WRITE','ALLOW','ROLE','marketingBoss'),(105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketingBoss'),(106,'ItemBotanical','*','WRITE','ALLOW','ROLE','marketingBoss'),(108,'ItemPlacement','*','WRITE','ALLOW','ROLE','marketingBoss'),(109,'UserConfig','*','*','ALLOW','ROLE','employee'),(110,'Bank','*','READ','ALLOW','ROLE','trainee'),(111,'ClientLog','*','READ','ALLOW','ROLE','trainee'),(112,'Defaulter','*','READ','ALLOW','ROLE','employee'),(113,'ClientRisk','*','READ','ALLOW','ROLE','trainee'),(114,'Receipt','*','READ','ALLOW','ROLE','trainee'),(115,'Receipt','*','WRITE','ALLOW','ROLE','administrative'),(116,'BankEntity','*','*','ALLOW','ROLE','employee'),(117,'ClientSample','*','*','ALLOW','ROLE','employee'),(118,'WorkerTeam','*','*','ALLOW','ROLE','salesPerson'),(119,'Travel','*','READ','ALLOW','ROLE','employee'),(120,'Travel','*','WRITE','ALLOW','ROLE','buyer'),(121,'Item','regularize','*','ALLOW','ROLE','employee'),(122,'TicketRequest','*','*','ALLOW','ROLE','employee'),(123,'Worker','*','*','ALLOW','ROLE','employee'),(124,'Client','confirmTransaction','WRITE','ALLOW','ROLE','administrative'),(125,'Agency','getAgenciesWithWarehouse','*','ALLOW','ROLE','employee'),(126,'Client','activeWorkersWithRole','*','ALLOW','ROLE','employee'),(127,'TicketLog','*','READ','ALLOW','ROLE','employee'),(129,'TicketService','*','*','ALLOW','ROLE','employee'),(130,'Expedition','*','WRITE','ALLOW','ROLE','packager'),(131,'CreditInsurance','*','READ','ALLOW','ROLE','trainee'),(132,'CreditClassification','*','READ','ALLOW','ROLE','trainee'),(133,'ItemTag','*','WRITE','ALLOW','ROLE','marketingBoss'),(135,'ZoneGeo','*','READ','ALLOW','ROLE','employee'),(136,'ZoneCalendar','*','READ','ALLOW','ROLE','employee'),(137,'ZoneIncluded','*','READ','ALLOW','ROLE','employee'),(138,'LabourHoliday','*','READ','ALLOW','ROLE','employee'),(139,'LabourHolidayLegend','*','READ','ALLOW','ROLE','employee'),(140,'LabourHolidayType','*','READ','ALLOW','ROLE','employee'),(141,'Zone','*','*','ALLOW','ROLE','deliveryBoss'),(142,'ZoneCalendar','*','WRITE','ALLOW','ROLE','deliveryBoss'),(143,'ZoneIncluded','*','*','ALLOW','ROLE','deliveryBoss'),(144,'Stowaway','*','*','ALLOW','ROLE','employee'),(145,'Ticket','getPossibleStowaways','READ','ALLOW','ROLE','employee'),(147,'UserConfigView','*','*','ALLOW','ROLE','employee'),(148,'UserConfigView','*','*','ALLOW','ROLE','employee'),(149,'Sip','*','READ','ALLOW','ROLE','employee'),(150,'Sip','*','WRITE','ALLOW','ROLE','hr'),(151,'Department','*','READ','ALLOW','ROLE','employee'),(152,'Department','*','WRITE','ALLOW','ROLE','hr'),(153,'Route','*','READ','ALLOW','ROLE','employee'),(154,'Route','*','WRITE','ALLOW','ROLE','delivery'),(155,'Calendar','*','READ','ALLOW','ROLE','hr'),(156,'WorkerLabour','*','READ','ALLOW','ROLE','hr'),(157,'Calendar','absences','READ','ALLOW','ROLE','employee'),(158,'ItemTag','*','WRITE','ALLOW','ROLE','accessory'),(160,'TicketServiceType','*','READ','ALLOW','ROLE','employee'),(161,'TicketConfig','*','READ','ALLOW','ROLE','employee'),(162,'InvoiceOut','delete','WRITE','ALLOW','ROLE','invoicing'),(163,'InvoiceOut','book','WRITE','ALLOW','ROLE','invoicing'),(165,'TicketDms','*','*','ALLOW','ROLE','employee'),(167,'Worker','isSubordinate','READ','ALLOW','ROLE','employee'),(168,'Worker','mySubordinates','READ','ALLOW','ROLE','employee'),(169,'WorkerTimeControl','filter','READ','ALLOW','ROLE','employee'),(170,'WorkerTimeControl','addTime','WRITE','ALLOW','ROLE','employee'),(171,'TicketServiceType','*','WRITE','ALLOW','ROLE','administrative'),(172,'Sms','*','READ','ALLOW','ROLE','employee'),(173,'Sms','send','WRITE','ALLOW','ROLE','employee'),(174,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(175,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(176,'Device','*','*','ALLOW','ROLE','employee'),(177,'Device','*','*','ALLOW','ROLE','employee'),(178,'WorkerTimeControl','*','*','ALLOW','ROLE','employee'),(179,'ItemLog','*','READ','ALLOW','ROLE','employee'),(180,'RouteLog','*','READ','ALLOW','ROLE','employee'),(181,'Dms','removeFile','WRITE','ALLOW','ROLE','employee'),(182,'Dms','uploadFile','WRITE','ALLOW','ROLE','employee'),(183,'Dms','downloadFile','READ','ALLOW','ROLE','employee'),(184,'Client','uploadFile','WRITE','ALLOW','ROLE','employee'),(185,'ClientDms','removeFile','WRITE','ALLOW','ROLE','employee'),(186,'ClientDms','*','READ','ALLOW','ROLE','trainee'),(187,'Ticket','uploadFile','WRITE','ALLOW','ROLE','employee'),(190,'Route','updateVolume','WRITE','ALLOW','ROLE','deliveryBoss'),(191,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(192,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(194,'Postcode','*','WRITE','ALLOW','ROLE','deliveryBoss'),(195,'Ticket','addSale','WRITE','ALLOW','ROLE','employee'),(196,'Dms','updateFile','WRITE','ALLOW','ROLE','employee'),(197,'Dms','*','READ','ALLOW','ROLE','trainee'),(198,'ClaimDms','removeFile','WRITE','ALLOW','ROLE','employee'),(199,'ClaimDms','*','READ','ALLOW','ROLE','employee'),(200,'Claim','uploadFile','WRITE','ALLOW','ROLE','employee'),(201,'Sale','updateConcept','WRITE','ALLOW','ROLE','employee'),(202,'Claim','updateClaimAction','WRITE','ALLOW','ROLE','claimManager'),(203,'UserPhone','*','*','ALLOW','ROLE','employee'),(204,'WorkerDms','removeFile','WRITE','ALLOW','ROLE','hr'),(205,'WorkerDms','*','READ','ALLOW','ROLE','hr'),(206,'Chat','*','*','ALLOW','ROLE','employee'),(207,'Chat','sendMessage','*','ALLOW','ROLE','employee'),(208,'Sale','recalculatePrice','WRITE','ALLOW','ROLE','employee'),(209,'Ticket','recalculateComponents','WRITE','ALLOW','ROLE','employee'),(211,'TravelLog','*','READ','ALLOW','ROLE','buyer'),(212,'Thermograph','*','*','ALLOW','ROLE','buyer'),(213,'TravelThermograph','*','WRITE','ALLOW','ROLE','buyer'),(214,'Entry','*','*','ALLOW','ROLE','buyer'),(215,'TicketWeekly','*','WRITE','ALLOW','ROLE','buyer'),(216,'TravelThermograph','*','READ','ALLOW','ROLE','employee'),(218,'Intrastat','*','*','ALLOW','ROLE','buyer'),(219,'Account','acl','READ','ALLOW','ROLE','account'),(220,'Account','getCurrentUserData','READ','ALLOW','ROLE','account'),(221,'UserConfig','getUserConfig','READ','ALLOW','ROLE','account'),(222,'Client','*','READ','ALLOW','ROLE','trainee'),(226,'ClientObservation','*','READ','ALLOW','ROLE','trainee'),(227,'Address','*','READ','ALLOW','ROLE','trainee'),(228,'AddressObservation','*','READ','ALLOW','ROLE','trainee'),(230,'ClientCredit','*','READ','ALLOW','ROLE','trainee'),(231,'ClientContact','*','READ','ALLOW','ROLE','trainee'),(232,'ClientSample','*','READ','ALLOW','ROLE','trainee'),(233,'EntryLog','*','READ','ALLOW','ROLE','buyer'),(234,'WorkerLog','*','READ','ALLOW','ROLE','salesAssistant'),(235,'CustomsAgent','*','*','ALLOW','ROLE','employee'),(236,'Buy','*','*','ALLOW','ROLE','buyer'),(237,'WorkerDms','filter','*','ALLOW','ROLE','employee'),(238,'Town','*','WRITE','ALLOW','ROLE','deliveryBoss'),(239,'Province','*','WRITE','ALLOW','ROLE','deliveryBoss'),(240,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(241,'SupplierContact','*','WRITE','ALLOW','ROLE','administrative'),(242,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(244,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(246,'Account','changePassword','*','ALLOW','ROLE','account'),(247,'UserAccount','exists','*','ALLOW','ROLE','account'),(248,'RoleMapping','*','READ','ALLOW','ROLE','account'),(249,'UserPassword','*','READ','ALLOW','ROLE','account'),(250,'Town','*','WRITE','ALLOW','ROLE','deliveryBoss'),(251,'Province','*','WRITE','ALLOW','ROLE','deliveryBoss'),(252,'Supplier','*','READ','ALLOW','ROLE','employee'),(253,'Supplier','*','WRITE','ALLOW','ROLE','administrative'),(254,'SupplierLog','*','READ','ALLOW','ROLE','employee'),(256,'Image','*','WRITE','ALLOW','ROLE','employee'),(257,'FixedPrice','*','*','ALLOW','ROLE','buyer'),(258,'PayDem','*','READ','ALLOW','ROLE','employee'),(259,'Client','createReceipt','*','ALLOW','ROLE','salesAssistant'),(260,'PrintServerQueue','*','WRITE','ALLOW','ROLE','employee'),(261,'SupplierAccount','*','*','ALLOW','ROLE','administrative'),(262,'Entry','*','*','ALLOW','ROLE','administrative'),(263,'InvoiceIn','*','*','ALLOW','ROLE','administrative'),(264,'StarredModule','*','*','ALLOW','ROLE','employee'),(265,'ItemBotanical','*','WRITE','ALLOW','ROLE','logisticBoss'),(266,'ZoneLog','*','READ','ALLOW','ROLE','employee'),(267,'Genus','*','WRITE','ALLOW','ROLE','logisticBoss'),(268,'Specie','*','WRITE','ALLOW','ROLE','logisticBoss'),(269,'InvoiceOut','createPdf','WRITE','ALLOW','ROLE','employee'),(270,'SupplierAddress','*','*','ALLOW','ROLE','employee'),(271,'SalesMonitor','*','*','ALLOW','ROLE','employee'),(272,'InvoiceInLog','*','*','ALLOW','ROLE','employee'),(273,'InvoiceInTax','*','*','ALLOW','ROLE','administrative'),(274,'InvoiceInLog','*','READ','ALLOW','ROLE','administrative'),(275,'InvoiceOut','createManualInvoice','WRITE','ALLOW','ROLE','invoicing'),(276,'InvoiceOut','globalInvoicing','WRITE','ALLOW','ROLE','invoicing'),(277,'Role','*','*','ALLOW','ROLE','it'),(278,'RoleInherit','*','WRITE','ALLOW','ROLE','grant'),(279,'MailAlias','*','*','ALLOW','ROLE','marketing'),(282,'UserAccount','*','WRITE','ALLOW','ROLE','it'),(283,'EntryObservation','*','*','ALLOW','ROLE','buyer'),(284,'LdapConfig','*','*','ALLOW','ROLE','sysadmin'),(285,'SambaConfig','*','*','ALLOW','ROLE','sysadmin'),(286,'ACL','*','*','ALLOW','ROLE','developer'),(287,'AccessToken','*','*','ALLOW','ROLE','developer'),(288,'MailAliasAccount','*','*','ALLOW','ROLE','marketing'),(289,'MailAliasAccount','*','*','ALLOW','ROLE','hr'),(290,'MailAlias','*','*','ALLOW','ROLE','hr'),(291,'MailForward','*','*','ALLOW','ROLE','marketing'),(292,'MailForward','*','*','ALLOW','ROLE','hr'),(293,'RoleInherit','*','*','ALLOW','ROLE','it'),(294,'RoleRole','*','*','ALLOW','ROLE','it'),(295,'AccountConfig','*','*','ALLOW','ROLE','sysadmin'),(296,'Collection','*','READ','ALLOW','ROLE','employee'),(297,'Sale','refund','WRITE','ALLOW','ROLE','employee'),(298,'InvoiceInDueDay','*','*','ALLOW','ROLE','administrative'),(299,'Collection','setSaleQuantity','*','ALLOW','ROLE','employee'),(300,'Docuware','*','*','ALLOW','ROLE','employee'),(301,'Agency','*','READ','ALLOW','ROLE','employee'),(302,'AgencyTerm','*','*','ALLOW','ROLE','administrative'),(303,'ClaimLog','*','READ','ALLOW','ROLE','claimManager'),(304,'Edi','updateData','WRITE','ALLOW','ROLE','employee'),(305,'EducationLevel','*','*','ALLOW','ROLE','employee'),(306,'InvoiceInIntrastat','*','*','ALLOW','ROLE','employee'),(307,'SupplierAgencyTerm','*','*','ALLOW','ROLE','administrative'),(308,'InvoiceInIntrastat','*','*','ALLOW','ROLE','employee'),(309,'Zone','getZoneClosing','*','ALLOW','ROLE','employee'),(310,'ExpeditionState','*','READ','ALLOW','ROLE','employee'),(311,'Expense','*','READ','ALLOW','ROLE','employee'),(312,'Expense','*','WRITE','ALLOW','ROLE','administrative'),(313,'Sale','refundAll','WRITE','ALLOW','ROLE','employee'),(314,'SupplierActivity','*','READ','ALLOW','ROLE','employee'),(315,'SupplierActivity','*','WRITE','ALLOW','ROLE','administrative'),(316,'Dms','deleteTrashFiles','WRITE','ALLOW','ROLE','employee'),(317,'ClientUnpaid','*','*','ALLOW','ROLE','administrative'),(318,'MdbVersion','*','*','ALLOW','ROLE','developer');
/*!40000 ALTER TABLE `ACL` ENABLE KEYS */;
UNLOCK TABLES;
@@ -206,9 +206,9 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2022-05-04 15:58:28
+-- Dump completed on 2022-06-23 12:13:32
USE `vn`;
--- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64)
+-- MariaDB dump 10.19 Distrib 10.6.8-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: db.verdnatura.es Database: vn
-- ------------------------------------------------------
@@ -320,7 +320,7 @@ UNLOCK TABLES;
LOCK TABLES `claimResponsible` WRITE;
/*!40000 ALTER TABLE `claimResponsible` DISABLE KEYS */;
-INSERT INTO `claimResponsible` VALUES (1,'Compradores',0),(2,'Proveedor',0),(3,'Entradores',0),(4,'Camareros',0),(6,'Sacadores',0),(7,'Revisadores',0),(8,'Calidad general',0),(9,'Encajadores',0),(11,'Comerciales',1),(12,'Clientes',1),(13,'Administración',0),(14,'Agencia',0),(15,'Repartidores',0),(16,'Informatica',0),(17,'Transp.origen',0),(18,'Confeccion',0),(19,'OTROS',0),(21,'Gerencia',0),(22,'Paletizadores',0),(23,'Preparación Previa',0),(24,'Almacén PCA',0),(25,'Huelga',0);
+INSERT INTO `claimResponsible` VALUES (1,'Compradores',0),(2,'Proveedor',0),(3,'Entradores',0),(4,'Camareros',0),(6,'Sacadores',0),(7,'Revisadores',0),(8,'Calidad general',0),(9,'Encajadores',0),(10,'Clima',0),(11,'Comerciales',1),(12,'Clientes',1),(13,'Administración',0),(14,'Agencia',0),(15,'Repartidores',0),(16,'Informatica',0),(17,'Transp.origen',0),(18,'Confeccion',0),(19,'OTROS',0),(21,'Gerencia',0),(22,'Paletizadores',0),(23,'Preparación Previa',0),(24,'Almacén PCA',0),(25,'Huelga',0);
/*!40000 ALTER TABLE `claimResponsible` ENABLE KEYS */;
UNLOCK TABLES;
@@ -390,7 +390,7 @@ UNLOCK TABLES;
LOCK TABLES `department` WRITE;
/*!40000 ALTER TABLE `department` DISABLE KEYS */;
-INSERT INTO `department` VALUES (1,NULL,'VERDNATURA',1,94,763,0,NULL,NULL,NULL,0,0,0,30,NULL,'/',NULL,0,NULL,0,0,0,0,NULL),(22,NULL,'COMPRAS',2,3,NULL,72,596,2,5,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(23,NULL,'CAMARA',13,14,NULL,72,3758,2,6,1,1,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,1,NULL),(31,'IT','INFORMATICA',4,5,NULL,72,127,3,9,0,0,1,0,1,'/1/','informatica-cau',1,NULL,1,0,0,0,NULL),(34,NULL,'CONTABILIDAD',6,7,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(35,NULL,'FINANZAS',8,9,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(36,NULL,'LABORAL',10,11,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(37,NULL,'PRODUCCION',12,27,NULL,72,3758,3,11,1,1,1,7,1,'/1/',NULL,0,NULL,0,1,1,1,NULL),(38,NULL,'SACADO',15,16,NULL,72,230,4,14,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(39,NULL,'ENCAJADO',17,18,NULL,72,3758,4,12,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(41,NULL,'ADMINISTRACION',28,29,NULL,72,599,3,8,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(43,'VT','VENTAS',30,49,NULL,0,NULL,NULL,NULL,0,0,1,9,1,'/1/',NULL,1,'',1,0,0,0,NULL),(44,NULL,'GERENCIA',50,51,NULL,72,300,2,7,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(45,NULL,'LOGISTICA',52,53,NULL,72,596,3,19,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(46,NULL,'REPARTO',54,55,NULL,72,659,3,10,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL),(48,NULL,'ALMACENAJE',56,57,NULL,0,3758,NULL,NULL,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(49,NULL,'PROPIEDAD',58,59,NULL,72,1008,1,1,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(52,NULL,'CARGA AEREA',60,61,NULL,72,163,4,28,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(53,NULL,'MARKETING Y COMUNICACIÓN',62,63,NULL,72,1238,0,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(54,NULL,'ORNAMENTALES',64,65,NULL,72,433,3,21,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(55,NULL,'TALLER NATURAL',66,67,3366,72,3758,2,23,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,1,0,1118),(56,NULL,'TALLER ARTIFICIAL',68,69,8470,72,1780,2,24,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,1,0,1927),(58,NULL,'CAMPOS',70,71,NULL,72,3758,2,2,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(59,NULL,'MANTENIMIENTO',72,73,NULL,72,1907,4,16,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(60,NULL,'RECLAMACIONES',74,75,NULL,72,563,3,20,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(61,NULL,'VNH',76,77,NULL,73,1297,3,17,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(63,NULL,'VENTAS FRANCIA',31,32,NULL,72,277,2,27,0,0,2,0,43,'/1/43/',NULL,0,NULL,0,0,0,0,NULL),(66,NULL,'VERDNAMADRID',78,79,NULL,72,163,3,18,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(68,NULL,'COMPLEMENTOS',19,20,NULL,72,617,3,26,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(69,NULL,'VERDNABARNA',80,81,NULL,74,432,3,22,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(80,NULL,'EQUIPO J VALLES',33,34,NULL,72,693,3,4,0,0,2,0,43,'/1/43/','jvp_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0,NULL),(86,NULL,'LIMPIEZA',82,83,NULL,72,599,0,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(89,NULL,'COORDINACION',84,85,NULL,0,3758,NULL,NULL,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(90,NULL,'TRAILER',86,87,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(91,NULL,'ARTIFICIAL',21,22,NULL,0,3758,NULL,NULL,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(92,NULL,'EQUIPO SILVERIO',35,36,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','sdc_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0,NULL),(93,NULL,'CONFECCION',88,89,NULL,0,3758,NULL,NULL,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,1,0,NULL),(94,NULL,'EQUIPO J BROCAL',37,38,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','jes_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0,NULL),(95,NULL,'EQUIPO C ZAMBRANO',39,40,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','czg_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0,NULL),(96,NULL,'EQUIPO C LOPEZ',41,42,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','cla_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0,NULL),(115,NULL,'EQUIPO CLAUDI',43,44,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','csr_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0,NULL),(123,NULL,'EQUIPO ELENA BASCUÑANA',45,46,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','ebt_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0,NULL),(124,NULL,'CONTROL INTERNO',90,91,NULL,72,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(125,NULL,'EQUIPO MIRIAM MAR',47,48,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','mir_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0,NULL),(126,NULL,'PRESERVADO',92,93,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,1,0,NULL),(128,NULL,'PALETIZADO',23,24,NULL,0,NULL,NULL,NULL,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(130,NULL,'REVISION',25,26,NULL,0,NULL,NULL,NULL,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL);
+INSERT INTO `department` VALUES (1,NULL,'VERDNATURA',1,94,763,0,NULL,NULL,NULL,0,0,0,30,NULL,'/',NULL,0,NULL,0,0,0,0,NULL),(22,NULL,'COMPRAS',2,3,NULL,72,596,2,5,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(23,NULL,'CAMARA',13,14,NULL,72,3758,2,6,1,1,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,1,NULL),(31,'IT','INFORMATICA',4,5,NULL,72,127,3,9,0,0,1,0,1,'/1/','informatica-cau',1,NULL,1,0,0,0,NULL),(34,NULL,'CONTABILIDAD',6,7,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(35,NULL,'FINANZAS',8,9,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(36,NULL,'LABORAL',10,11,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(37,NULL,'PRODUCCION',12,27,NULL,72,3758,3,11,1,1,1,7,1,'/1/',NULL,0,NULL,0,1,1,1,NULL),(38,NULL,'SACADO',15,16,NULL,72,230,4,14,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(39,NULL,'ENCAJADO',17,18,NULL,72,3758,4,12,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(41,NULL,'ADMINISTRACION',28,29,NULL,72,599,3,8,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(43,'VT','VENTAS',30,49,NULL,0,NULL,NULL,NULL,0,0,1,9,1,'/1/',NULL,1,'',1,0,0,0,NULL),(44,NULL,'GERENCIA',50,51,NULL,72,300,2,7,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(45,NULL,'LOGISTICA',52,53,NULL,72,596,3,19,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(46,NULL,'REPARTO',54,55,NULL,72,659,3,10,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL),(48,NULL,'ALMACENAJE',56,57,NULL,0,3758,NULL,NULL,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(49,NULL,'PROPIEDAD',58,59,NULL,72,1008,1,1,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(52,NULL,'CARGA AEREA',60,61,NULL,72,163,4,28,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(53,NULL,'MARKETING Y COMUNICACIÓN',62,63,NULL,72,1238,0,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(54,NULL,'ORNAMENTALES',64,65,NULL,72,433,3,21,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(55,NULL,'TALLER NATURAL',66,67,3366,72,3758,2,23,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,1,0,1118),(56,NULL,'TALLER ARTIFICIAL',68,69,8470,72,1780,2,24,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,1,0,1927),(58,NULL,'CAMPOS',70,71,NULL,72,3758,2,2,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(59,NULL,'MANTENIMIENTO',72,73,NULL,72,1907,4,16,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(60,NULL,'RECLAMACIONES',74,75,NULL,72,563,3,20,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(61,NULL,'VNH',76,77,NULL,73,1297,3,17,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(63,NULL,'VENTAS FRANCIA',31,32,NULL,72,277,2,27,0,0,2,0,43,'/1/43/',NULL,0,NULL,0,0,0,0,NULL),(66,NULL,'VERDNAMADRID',78,79,NULL,72,163,3,18,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(68,NULL,'COMPLEMENTOS',19,20,NULL,72,617,3,26,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(69,NULL,'VERDNABARNA',80,81,NULL,74,432,3,22,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(80,NULL,'EQUIPO J VALLES',33,34,4250,72,693,3,4,0,0,2,0,43,'/1/43/','jvp_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL),(86,NULL,'LIMPIEZA',82,83,NULL,72,599,0,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(89,NULL,'COORDINACION',84,85,NULL,0,3758,NULL,NULL,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(90,NULL,'TRAILER',86,87,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(91,NULL,'ARTIFICIAL',21,22,NULL,0,3758,NULL,NULL,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(92,NULL,'EQUIPO SILVERIO',35,36,1203,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','sdc_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL),(93,NULL,'CONFECCION',88,89,NULL,0,3758,NULL,NULL,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,1,0,NULL),(94,NULL,'EQUIPO J BROCAL',37,38,3797,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','jes_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL),(95,NULL,'EQUIPO C ZAMBRANO',39,40,4667,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','czg_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL),(96,NULL,'EQUIPO C LOPEZ',41,42,4661,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','cla_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL),(115,NULL,'EQUIPO CLAUDI',43,44,3810,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','csr_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL),(123,NULL,'EQUIPO ELENA BASCUÑANA',45,46,7102,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','ebt_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL),(124,NULL,'CONTROL INTERNO',90,91,NULL,72,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,0,NULL,1,0,0,0,NULL),(125,NULL,'EQUIPO MIRIAM MAR',47,48,1118,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','mir_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL),(126,NULL,'PRESERVADO',92,93,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,1,0,NULL),(128,NULL,'PALETIZADO',23,24,NULL,0,NULL,NULL,NULL,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(130,NULL,'REVISION',25,26,NULL,0,NULL,NULL,NULL,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL);
/*!40000 ALTER TABLE `department` ENABLE KEYS */;
UNLOCK TABLES;
@@ -430,7 +430,7 @@ UNLOCK TABLES;
LOCK TABLES `state` WRITE;
/*!40000 ALTER TABLE `state` DISABLE KEYS */;
-INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0,0,0,0,0,4,1,'alert'),(2,'Libre',2,0,'FREE',NULL,2,1,0,0,0,1,0,4,1,'notice'),(3,'OK',3,0,'OK',3,28,1,0,0,0,1,1,3,0,'success'),(4,'Impreso',4,0,'PRINTED',2,29,1,0,1,0,0,1,2,0,'success'),(5,'Preparación',6,1,'ON_PREPARATION',7,5,0,0,0,2,0,0,2,0,'warning'),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3,0,0,1,0,'warning'),(7,'Sin Acabar',1,0,'NOT_READY',NULL,7,0,0,0,0,0,0,4,1,'alert'),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3,0,0,1,0,'warning'),(9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0,0,0,1,0,NULL),(10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0,0,0,0,0,NULL),(11,'Facturado',0,3,'INVOICED',NULL,11,0,1,0,0,0,0,0,0,NULL),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0,0,0,4,1,'alert'),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0,0,0,0,0,NULL),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2,0,0,1,0,'warning'),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0,0,0,0,NULL),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0,0,0,0,0,NULL),(20,'Asignado',4,0,'PICKER_DESIGNED',NULL,20,1,0,0,0,0,0,2,0,'success'),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0,0,0,2,0,'success'),(22,'Pte. Ampliar',2,0,'EXPANDABLE',NULL,22,0,0,0,0,0,0,4,1,'alert'),(23,'URGENTE',5,1,'LAST_CALL',NULL,23,1,0,1,0,0,0,4,1,'success'),(24,'Encadenado',4,0,'CHAINED',4,24,0,0,0,0,0,0,3,1,'success'),(25,'Embarcando',3,0,'BOARDING',5,25,1,0,0,0,0,0,3,0,'alert'),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,28,0,0,0,1,0,0,2,0,'warning'),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0,0,0,2,0,'success'),(28,'Previa OK',3,1,'OK PREVIOUS',3,28,0,0,0,1,1,1,3,0,'warning'),(29,'Previa Impreso',4,1,'PRINTED PREVIOUS',2,29,0,0,1,1,0,1,3,0,'success'),(30,'Embarcado',4,1,'BOARD',5,30,0,0,0,2,0,0,3,0,'success'),(31,'Polizon Impreso',4,1,'PRINTED STOWAWAY',2,29,1,0,1,0,0,1,3,0,'success'),(32,'Polizon OK',3,1,'OK STOWAWAY',3,31,1,0,0,1,1,1,3,0,'warning'),(33,'Auto_Impreso',4,0,'PRINTED_AUTO',2,29,1,0,1,0,0,1,2,0,'success'),(34,'Pte Pago',3,0,'WAITING_FOR_PAYMENT',NULL,34,0,0,0,0,0,0,4,1,'alert'),(35,'Semi-Encajado',9,2,'HALF_PACKED',NULL,10,0,1,0,0,0,0,1,0,NULL),(36,'Control Previa',3,1,'PREVIOUS_CONTROL',1,36,0,1,0,4,0,1,3,0,'warning');
+INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0,0,0,0,0,4,1,'alert'),(2,'Libre',2,0,'FREE',NULL,2,1,0,0,0,1,0,4,1,'notice'),(3,'OK',3,0,'OK',3,28,1,0,0,0,1,1,3,0,'success'),(4,'Impreso',4,0,'PRINTED',2,29,1,0,1,0,0,1,2,0,'success'),(5,'Preparación',6,1,'ON_PREPARATION',7,5,0,0,0,2,0,0,2,0,'warning'),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3,0,0,1,0,'warning'),(7,'Sin Acabar',1,0,'NOT_READY',NULL,7,0,0,0,0,0,0,4,1,'alert'),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3,0,0,1,0,'warning'),(9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0,0,0,1,0,NULL),(10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0,0,0,0,0,NULL),(11,'Facturado',0,3,'INVOICED',NULL,11,0,1,0,0,0,0,0,0,NULL),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0,0,0,4,1,'alert'),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0,0,0,0,0,NULL),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2,0,0,1,0,'warning'),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0,0,0,0,NULL),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0,0,0,0,0,NULL),(20,'Asignado',4,0,'PICKER_DESIGNED',NULL,20,1,0,0,0,0,0,2,0,'success'),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0,0,0,2,0,'success'),(22,'Pte. Ampliar',2,0,'EXPANDABLE',NULL,22,0,0,0,0,0,0,4,1,'alert'),(23,'URGENTE',5,1,'LAST_CALL',NULL,23,1,0,1,0,0,0,4,1,'success'),(24,'Encadenado',4,0,'CHAINED',4,24,0,0,0,0,0,0,3,1,'success'),(25,'Embarcando',3,0,'BOARDING',5,25,1,0,0,0,0,0,3,0,'alert'),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,28,0,0,0,1,0,0,2,0,'warning'),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0,0,0,2,0,'success'),(28,'Previa OK',3,1,'OK PREVIOUS',3,28,1,0,0,1,1,1,3,0,'warning'),(29,'Previa Impreso',4,0,'PRINTED PREVIOUS',2,29,1,0,1,0,0,1,2,0,'success'),(30,'Embarcado',4,1,'BOARD',5,30,0,0,0,2,0,0,3,0,'success'),(31,'Polizon Impreso',4,1,'PRINTED STOWAWAY',2,29,1,0,1,0,0,1,2,0,'success'),(32,'Polizon OK',3,1,'OK STOWAWAY',3,31,1,0,0,1,1,1,3,0,'warning'),(33,'Auto_Impreso',4,0,'PRINTED_AUTO',2,29,1,0,1,0,0,1,2,0,'success'),(34,'Pte Pago',3,0,'WAITING_FOR_PAYMENT',NULL,34,0,0,0,0,0,0,4,1,'alert'),(35,'Semi-Encajado',9,2,'HALF_PACKED',NULL,10,0,1,0,0,0,0,1,0,NULL),(36,'Previa Revisando',3,1,'PREVIOUS_CONTROL',1,29,0,1,0,4,0,1,3,0,'warning'),(37,'Previa Revisado',3,1,'PREVIOUS_CONTROLLED',1,29,0,1,0,4,0,1,3,0,'warning');
/*!40000 ALTER TABLE `state` ENABLE KEYS */;
UNLOCK TABLES;
@@ -460,9 +460,19 @@ UNLOCK TABLES;
LOCK TABLES `volumeConfig` WRITE;
/*!40000 ALTER TABLE `volumeConfig` DISABLE KEYS */;
-INSERT INTO `volumeConfig` VALUES (2.67,1.60,0.8,150,0.30,120,57,2.0,75,200,50);
+INSERT INTO `volumeConfig` VALUES (2.67,1.60,0.8,150,0.30,120,57,2.0,150,200,50);
/*!40000 ALTER TABLE `volumeConfig` ENABLE KEYS */;
UNLOCK TABLES;
+
+--
+-- Dumping data for table `workCenter`
+--
+
+LOCK TABLES `workCenter` WRITE;
+/*!40000 ALTER TABLE `workCenter` DISABLE KEYS */;
+INSERT INTO `workCenter` VALUES (1,'Silla',20,859,1,'Av espioca 100',552703),(2,'Mercaflor',19,NULL,NULL,NULL,NULL),(3,'Marjales',26,20008,NULL,NULL,NULL),(4,'VNH',NULL,NULL,NULL,NULL,NULL),(5,'Madrid',28,2869,5,'Av constitución 3',554145),(6,'Vilassar',88,88038,NULL,'Cami del Crist, 33',556412),(7,'Tenerife',NULL,NULL,NULL,NULL,NULL),(8,'Silla-Agrario',26,NULL,NULL,NULL,NULL),(9,'Algemesi',20,1354,60,'Fenollars, 2',523549);
+/*!40000 ALTER TABLE `workCenter` ENABLE KEYS */;
+UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -472,9 +482,9 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2022-05-04 15:58:28
+-- Dump completed on 2022-06-23 12:13:32
USE `cache`;
--- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64)
+-- MariaDB dump 10.19 Distrib 10.6.8-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: db.verdnatura.es Database: cache
-- ------------------------------------------------------
@@ -508,9 +518,9 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2022-05-04 15:58:28
+-- Dump completed on 2022-06-23 12:13:32
USE `hedera`;
--- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64)
+-- MariaDB dump 10.19 Distrib 10.6.8-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: db.verdnatura.es Database: hedera
-- ------------------------------------------------------
@@ -592,7 +602,7 @@ UNLOCK TABLES;
LOCK TABLES `menu` WRITE;
/*!40000 ALTER TABLE `menu` DISABLE KEYS */;
-INSERT INTO `menu` VALUES (1,'Home','cms/home',6,NULL,1),(2,'Orders',NULL,11,NULL,1),(3,'Catalog','ecomerce/catalog',6,NULL,2),(5,'About',NULL,6,NULL,2),(6,'Location','cms/location',6,5,2),(7,'Administration',NULL,1,NULL,2),(8,'Users','admin/users',1,7,2),(9,'Connections','admin/connections',1,7,2),(11,'Agencies','agencies/packages',3,NULL,2),(12,'News','news/news',1,7,3),(14,'Why','cms/why',6,5,2),(15,'Photos','admin/photos',1,7,3),(16,'Training','cms/training',6,NULL,2),(17,'Configuration',NULL,11,NULL,3),(19,'Control panel','admin/links',1,7,1),(20,'About us','cms/about',6,5,1),(21,'Basket','ecomerce/basket',11,NULL,1),(22,'Last orders','ecomerce/orders',11,2,2),(23,'Invoices','ecomerce/invoices',11,2,2),(24,'Account','account/conf',11,17,1),(25,'Addresses','account/address-list',11,17,2),(26,'Shelves','reports/shelves',1,29,1),(27,'Items list','reports/items-form',1,29,1),(28,'Visits','admin/visits',1,7,2),(29,'Reports',NULL,1,NULL,2),(30,'Items','admin/items',1,7,3);
+INSERT INTO `menu` VALUES (1,'Home','cms/home',6,NULL,1),(2,'Orders',NULL,11,NULL,1),(3,'Catalog','ecomerce/catalog',6,NULL,2),(5,'About',NULL,6,NULL,2),(6,'Location','cms/location',6,5,2),(7,'Administration',NULL,1,NULL,2),(8,'Users','admin/users',1,7,2),(9,'Connections','admin/connections',1,7,2),(11,'Agencies','agencies/packages',3,NULL,2),(12,'News','news/news',1,7,3),(14,'Why','cms/why',6,5,2),(15,'Photos','admin/photos',1,7,3),(17,'Configuration',NULL,11,NULL,3),(19,'Control panel','admin/links',1,7,1),(20,'About us','cms/about',6,5,1),(21,'Basket','ecomerce/basket',11,NULL,1),(22,'Last orders','ecomerce/orders',11,2,2),(23,'Invoices','ecomerce/invoices',11,2,2),(24,'Account','account/conf',11,17,1),(25,'Addresses','account/address-list',11,17,2),(26,'Shelves','reports/shelves',1,29,1),(27,'Items list','reports/items-form',1,29,1),(28,'Visits','admin/visits',1,7,2),(29,'Reports',NULL,1,NULL,2),(30,'Items','admin/items',1,7,3);
/*!40000 ALTER TABLE `menu` ENABLE KEYS */;
UNLOCK TABLES;
@@ -632,7 +642,7 @@ UNLOCK TABLES;
LOCK TABLES `restPriv` WRITE;
/*!40000 ALTER TABLE `restPriv` DISABLE KEYS */;
-INSERT INTO `restPriv` VALUES (1,'tpv/transaction',2),(2,'dms/add',1),(3,'image/upload',1),(4,'misc/sms',1),(5,'core/supplant',1),(6,'core/sync-user',5),(7,'core/set-password',1),(8,'core/change-password',11),(9,'misc/access-version',9);
+INSERT INTO `restPriv` VALUES (1,'tpv/transaction',2),(3,'image/upload',1),(4,'misc/sms',1),(5,'core/supplant',104),(7,'core/set-password',5),(9,'misc/access-version',NULL),(10,'core/captcha',NULL),(11,'core/log',NULL),(12,'core/login',NULL),(13,'core/logout',NULL),(14,'core/query',NULL),(15,'core/recover-password',NULL),(16,'core/restore-password',NULL),(17,'dms/invoice',2),(18,'image/thumb',NULL),(19,'misc/contact',NULL),(20,'misc/production',NULL),(21,'tpv/confirm-post',NULL),(22,'tpv/confirm-soap',NULL),(23,'client/supplant',18),(24,'client/supplant',35);
/*!40000 ALTER TABLE `restPriv` ENABLE KEYS */;
UNLOCK TABLES;
@@ -674,9 +684,9 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2022-05-04 15:58:28
+-- Dump completed on 2022-06-23 12:13:33
USE `postgresql`;
--- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64)
+-- MariaDB dump 10.19 Distrib 10.6.8-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: db.verdnatura.es Database: postgresql
-- ------------------------------------------------------
@@ -741,16 +751,6 @@ LOCK TABLES `profile_type` WRITE;
INSERT INTO `profile_type` VALUES (1,'Laboral'),(2,'Personal'),(3,'Cliente'),(4,'Proveedor'),(5,'Banco'),(6,'Patronal');
/*!40000 ALTER TABLE `profile_type` ENABLE KEYS */;
UNLOCK TABLES;
-
---
--- Dumping data for table `workcenter`
---
-
-LOCK TABLES `workcenter` WRITE;
-/*!40000 ALTER TABLE `workcenter` DISABLE KEYS */;
-INSERT INTO `workcenter` VALUES (1,'Silla',20,NULL,1,'Av espioca 100',552703),(2,'Mercaflor',19,NULL,NULL,NULL,NULL),(3,'Marjales',26,20008,NULL,NULL,NULL),(4,'VNH',NULL,NULL,3,NULL,NULL),(5,'Madrid',28,2869,5,'Av constitución 3',554145),(6,'Vilassar',88,88038,2,'Cami del Crist, 33',556412),(7,'Tenerife',NULL,NULL,10,NULL,NULL),(8,NULL,NULL,NULL,NULL,NULL,NULL),(9,'Algemesi',20,1354,60,'Fenollars, 2',523549),(10,NULL,NULL,NULL,NULL,NULL,NULL);
-/*!40000 ALTER TABLE `workcenter` ENABLE KEYS */;
-UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -760,9 +760,9 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2022-05-04 15:58:28
+-- Dump completed on 2022-06-23 12:13:33
USE `sage`;
--- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64)
+-- MariaDB dump 10.19 Distrib 10.6.8-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: db.verdnatura.es Database: sage
-- ------------------------------------------------------
@@ -816,4 +816,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2022-05-04 15:58:29
+-- Dump completed on 2022-06-23 12:13:33
diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql
index 0a27b48b8..f6583f1bb 100644
--- a/db/dump/fixtures.sql
+++ b/db/dump/fixtures.sql
@@ -1,6 +1,9 @@
CREATE SCHEMA IF NOT EXISTS `vn2008`;
CREATE SCHEMA IF NOT EXISTS `tmp`;
+UPDATE `util`.`config`
+ SET `environment`= 'test';
+
ALTER TABLE `vn`.`itemTaxCountry` AUTO_INCREMENT = 1;
ALTER TABLE `vn`.`address` AUTO_INCREMENT = 1;
ALTER TABLE `vn`.`zoneGeo` AUTO_INCREMENT = 1;
@@ -8,8 +11,7 @@ ALTER TABLE `vn`.`ticket` AUTO_INCREMENT = 1;
INSERT INTO `salix`.`AccessToken` (`id`, `ttl`, `created`, `userId`)
VALUES
- ('DEFAULT_TOKEN', '1209600', CURDATE(), 66);
-
+ ('DEFAULT_TOKEN', '1209600', util.VN_CURDATE(), 66);
INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`)
VALUES
@@ -120,36 +122,36 @@ INSERT INTO `vn`.`currency`(`id`, `code`, `name`, `ratio`)
(3, 'GBP', 'Libra', 1),
(4, 'JPY', 'Yen Japones', 1);
-INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, `ibanLength`, `continentFk`, `hasDailyInvoice`, `CEE`)
+INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, `politicalCountryFk`, `ibanLength`, `continentFk`, `hasDailyInvoice`, `CEE`)
VALUES
- (1, 'España', 1, 'ES', 1, 24, 4, 0, 1),
- (2, 'Italia', 1, 'IT', 1, 27, 4, 0, 1),
- (3, 'Alemania', 1, 'DE', 1, 22, 4, 0, 1),
- (4, 'Rumania', 1, 'RO', 1, 24, 4, 0, 1),
- (5, 'Holanda', 1, 'NL', 1, 18, 4, 0, 1),
- (8, 'Portugal', 1, 'PT', 1, 27, 4, 0, 1),
- (13,'Ecuador', 0, 'EC', 1, 24, 2, 1, 2),
- (19,'Francia', 1, 'FR', 1, 27, 4, 0, 1),
- (30,'Canarias', 1, 'IC', 1, 24, 4, 1, 2);
+ (1, 'España', 1, 'ES', 1, 1, 24, 4, 0, 1),
+ (2, 'Italia', 1, 'IT', 1, 2, 27, 4, 0, 1),
+ (3, 'Alemania', 1, 'DE', 1, 3, 22, 4, 0, 1),
+ (4, 'Rumania', 1, 'RO', 1, 4, 24, 4, 0, 1),
+ (5, 'Holanda', 1, 'NL', 1, 5, 18, 4, 0, 1),
+ (8, 'Portugal', 1, 'PT', 1, 8, 27, 4, 0, 1),
+ (13,'Ecuador', 0, 'EC', 1, 13, 24, 2, 1, 2),
+ (19,'Francia', 1, 'FR', 1, 19, 27, 4, 0, 1),
+ (30,'Canarias', 1, 'IC', 1, 1, 24, 4, 1, 2);
INSERT INTO `vn`.`warehouseAlias`(`id`, `name`)
VALUES
(1, 'Main Warehouse'),
- (2, 'Silla');
+ (2, 'Gotham');
-INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasStowaway`, `hasDms`, `hasComission`, `aliasFk`, `countryFk`, `hasProduction`)
+INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasDms`, `hasComission`, `aliasFk`, `countryFk`, `hasProduction`)
VALUES
- (1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 1, 2, 1, 1),
- (2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 0, 1, 2, 13, 1),
- (3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1, 1),
- (4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1, 1),
- (5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1, 1),
- (13, 'Inventory', NULL, 1, 1, 1, 0, 0, 0, 0, 2, 1, 0);
+ (1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 2, 1, 1),
+ (2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 1, 2, 13, 1),
+ (3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
+ (4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
+ (5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
+ (13, 'Inventory', NULL, 1, 1, 1, 0, 0, 0, 2, 1, 0);
-INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`, `pickingPlacement`, `path`)
+INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`)
VALUES
- (1, 'First sector', 1, 1, 'FIRST', 999, 999),
- (2, 'Second sector', 2, 0, 'SECOND', 100, 150);
+ (1, 'First sector', 1, 1, 'FIRST'),
+ (2, 'Second sector', 2, 0, 'SECOND');
INSERT INTO `vn`.`parking` (`id`, `column`, `row`, `sectorFk`, `code`, `pickingOrder`)
VALUES
@@ -172,15 +174,19 @@ INSERT INTO `vn`.`accountingType`(`id`, `description`, `receiptDescription`,`cod
(6, 'Loans', NULL, NULL, NULL, 0),
(7, 'Leasing', NULL, NULL, NULL, 0),
(8, 'Compensations', 'Compensations', 'compensation', NULL, 0);
-
-INSERT INTO `vn`.`bank`(`id`, `bank`, `account`, `cash`, `entityFk`, `isActive`, `currencyFk`)
- VALUES
- (1, 'Pay on receipt', '5720000001', 3, 0, 1, 1),
- (2, 'Cash', '5700000001', 2, 0, 1, 1),
- (3, 'Compensation', '4000000000', 8, 0, 1, 1),
- (4, 'Transfers', '4000000001', 1, 0, 1, 1),
- (3117, 'Caixa Rural d''Algemesi', '5720000000', 8, 3117, 1, 1);
+INSERT INTO `vn`.`bankEntity`(`id`, `countryFk`, `name`, `bic`)
+ VALUES
+ (128, 1, 'The Best Bank', 'BBKKESMMMMMM'),
+ (2100, 1, 'Caixa Bank', 'CAIXESBB');
+
+INSERT INTO `vn`.`bank`(`id`, `bank`, `account`, `cash`, `entityFk`, `isActive`, `currencyFk`)
+ VALUES
+ (1, 'Pay on receipt', '5720000001', 3, 128, 1, 1),
+ (2, 'Cash', '5700000001', 2, 128, 1, 1),
+ (3, 'Compensation', '4000000000', 8, 128, 1, 1),
+ (4, 'Transfers', '4000000001', 1, 128, 1, 1),
+ (3117, 'Caixa Rural d''Algemesi', '5720000000', 8, 2100, 1, 1);
INSERT INTO `vn`.`deliveryMethod`(`id`, `code`, `description`)
VALUES
@@ -189,18 +195,18 @@ INSERT INTO `vn`.`deliveryMethod`(`id`, `code`, `description`)
(3, 'PICKUP', 'Recogida'),
(4, 'OTHER', 'Otros');
-INSERT INTO `vn`.`agency`(`id`, `name`, `warehouseFk`, `isVolumetric`, `bankFk`, `warehouseAliasFk`)
+INSERT INTO `vn`.`agency`(`id`, `name`, `warehouseFk`, `bankFk__`, `warehouseAliasFk`)
VALUES
- (1, 'inhouse pickup' , 1, 0, 1, 1),
- (2, 'Super-Man delivery' , 1, 0, 1, 1),
- (3, 'Teleportation device' , 1, 0, 1, 1),
- (4, 'Entanglement' , 1, 0, 1, 1),
- (5, 'Quantum break device' , 1, 0, 1, 1),
- (6, 'Walking' , 1, 0, 1, 1),
- (7, 'Silla247' , 1, 0, 1, 1),
- (8, 'Silla247Expensive' , 1, 0, 1, 1),
- (9, 'Refund' , 1, 0, 1, 1),
- (10, 'Other agency' , 1, 0, 1, 1);
+ (1, 'inhouse pickup' , 1, 1, 1),
+ (2, 'Super-Man delivery' , 1, 1, 1),
+ (3, 'Teleportation device' , 1, 1, 1),
+ (4, 'Entanglement' , 1, 1, 1),
+ (5, 'Quantum break device' , 1, 1, 1),
+ (6, 'Walking' , 1, 1, 1),
+ (7, 'Gotham247' , 1, 1, 1),
+ (8, 'Gotham247Expensive' , 1, 1, 1),
+ (9, 'Refund' , 1, 1, 1),
+ (10, 'Other agency' , 1, 1, 1);
UPDATE `vn`.`agencyMode` SET `id` = 1 WHERE `name` = 'inhouse pickup';
UPDATE `vn`.`agencyMode` SET `id` = 2 WHERE `name` = 'Super-Man delivery';
@@ -208,8 +214,8 @@ UPDATE `vn`.`agencyMode` SET `id` = 3 WHERE `name` = 'Teleportation device';
UPDATE `vn`.`agencyMode` SET `id` = 4 WHERE `name` = 'Entanglement';
UPDATE `vn`.`agencyMode` SET `id` = 5 WHERE `name` = 'Quantum break device';
UPDATE `vn`.`agencyMode` SET `id` = 6 WHERE `name` = 'Walking';
-UPDATE `vn`.`agencyMode` SET `id` = 7 WHERE `name` = 'Silla247';
-UPDATE `vn`.`agencyMode` SET `id` = 8 WHERE `name` = 'Silla247Expensive';
+UPDATE `vn`.`agencyMode` SET `id` = 7 WHERE `name` = 'Gotham247';
+UPDATE `vn`.`agencyMode` SET `id` = 8 WHERE `name` = 'Gotham247Expensive';
UPDATE `vn`.`agencyMode` SET `id` = 23 WHERE `name` = 'Refund';
UPDATE `vn`.`agencyMode` SET `id` = 10 WHERE `name` = 'Other agency';
@@ -261,7 +267,7 @@ INSERT INTO `vn`.`province`(`id`, `name`, `countryFk`, `autonomyFk`, `warehouseF
INSERT INTO `vn`.`town`(`id`, `name`, `provinceFk`)
VALUES
(1, 'Valencia', 1),
- (2, 'Silla', 1),
+ (2, 'Gotham', 1),
(3, 'Algemesi', 1),
(4, 'Alzira', 1),
(5, 'Quito', 5);
@@ -295,30 +301,30 @@ INSERT INTO `vn`.`contactChannel`(`id`, `name`)
INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`,`clientTypeFk`,`mailAddress`,`hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`, `businessTypeFk`)
VALUES
- (1101, 'Bruce Wayne', '84612325V', 'Batman', 'Alfred', '1007 Mountain Drive, Gotham', 'Silla', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'),
- (1102, 'Petter Parker', '87945234L', 'Spider man', 'Aunt May', '20 Ingram Street, Queens, USA', 'Silla', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'),
- (1103, 'Clark Kent', '06815934E', 'Super man', 'lois lane', '344 Clinton Street, Apartament 3-D', 'Silla', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'),
- (1104, 'Tony Stark', '06089160W', 'Iron man', 'Pepper Potts', '10880 Malibu Point, 90265', 'Silla', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'),
- (1105, 'Max Eisenhardt', '251628698', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Silla', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1, 'florist'),
- (1106, 'DavidCharlesHaller', '53136686Q', 'Legion', 'Charles Xavier', 'City of New York, New York, USA', 'Silla', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 19, 0, 1, 'florist'),
- (1107, 'Hank Pym', '09854837G', 'Ant man', 'Hawk', 'Anthill, San Francisco, California', 'Silla', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, 0, NULL, 0, 0, 19, 0, 1, 'florist'),
- (1108, 'Charles Xavier', '22641921P', 'Professor X', 'Beast', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Silla', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1, 'florist'),
- (1109, 'Bruce Banner', '16104829E', 'Hulk', 'Black widow', 'Somewhere in New York', 'Silla', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, 0, NULL, 0, 0, 9, 0, 1, 'florist'),
- (1110, 'Jessica Jones', '58282869H', 'Jessica Jones', 'Luke Cage', 'NYCC 2015 Poster', 'Silla', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, 0, NULL, 0, 0, NULL, 0, 1, 'florist'),
- (1111, 'Missing', NULL, 'Missing man', 'Anton', 'The space, Universe far away', 'Silla', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 1, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, NULL),
- (1112, 'Trash', NULL, 'Garbage man', 'Unknown name', 'New York city, Underground', 'Silla', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 1, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, NULL);
+ (1101, 'Bruce Wayne', '84612325V', 'Batman', 'Alfred', '1007 Mountain Drive, Gotham', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'),
+ (1102, 'Petter Parker', '87945234L', 'Spider man', 'Aunt May', '20 Ingram Street, Queens, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'),
+ (1103, 'Clark Kent', '06815934E', 'Super man', 'lois lane', '344 Clinton Street, Apartament 3-D', 'Gotham', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'),
+ (1104, 'Tony Stark', '06089160W', 'Iron man', 'Pepper Potts', '10880 Malibu Point, 90265', 'Gotham', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'),
+ (1105, 'Max Eisenhardt', '251628698', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Gotham', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1, 'florist'),
+ (1106, 'DavidCharlesHaller', '53136686Q', 'Legion', 'Charles Xavier', 'City of New York, New York, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 19, 0, 1, 'florist'),
+ (1107, 'Hank Pym', '09854837G', 'Ant man', 'Hawk', 'Anthill, San Francisco, California', 'Gotham', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, 0, NULL, 0, 0, 19, 0, 1, 'florist'),
+ (1108, 'Charles Xavier', '22641921P', 'Professor X', 'Beast', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1, 'florist'),
+ (1109, 'Bruce Banner', '16104829E', 'Hulk', 'Black widow', 'Somewhere in New York', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, 0, NULL, 0, 0, 9, 0, 1, 'florist'),
+ (1110, 'Jessica Jones', '58282869H', 'Jessica Jones', 'Luke Cage', 'NYCC 2015 Poster', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, 0, NULL, 0, 0, NULL, 0, 1, 'florist'),
+ (1111, 'Missing', NULL, 'Missing man', 'Anton', 'The space, Universe far away', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 1, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, NULL),
+ (1112, 'Trash', NULL, 'Garbage man', 'Unknown name', 'New York city, Underground', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 1, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, NULL);
INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `gestdocFk`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`)
- SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), CONCAT(name, 'Social'), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'SILLA', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, CURDATE(), 1
+ SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), CONCAT(name, 'Social'), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, util.VN_CURDATE(), 1
FROM `account`.`role` `r`
WHERE `r`.`hasLogin` = 1;
INSERT INTO `vn`.`clientManaCache`(`clientFk`, `mana`, `dated`)
VALUES
- (1101, 50, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)),
- (1102, 100, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)),
- (1103, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)),
- (1104, -30, DATE_ADD(CURDATE(), INTERVAL -1 MONTH));
+ (1101, 50, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
+ (1102, 100, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
+ (1103, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
+ (1104, -30, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH));
INSERT INTO `vn`.`clientConfig`(`riskTolerance`, `maxCreditRows`)
VALUES
@@ -326,51 +332,51 @@ INSERT INTO `vn`.`clientConfig`(`riskTolerance`, `maxCreditRows`)
INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `phone`, `mobile`, `isActive`, `clientFk`, `agencyModeFk`, `longitude`, `latitude`, `isEqualizated`, `isDefaultAddress`)
VALUES
- (1, 'Bruce Wayne', '1007 Mountain Drive, Gotham', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1101, 2, NULL, NULL, 0, 1),
- (2, 'Petter Parker', '20 Ingram Street', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 1),
- (3, 'Clark Kent', '344 Clinton Street', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 1),
- (4, 'Tony Stark', '10880 Malibu Point', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1104, 2, NULL, NULL, 0, 1),
- (5, 'Max Eisenhardt', 'Unknown Whereabouts', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 1),
- (6, 'DavidCharlesHaller', 'Evil hideout', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 1),
- (7, 'Hank Pym', 'Anthill', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 1),
- (8, 'Charles Xavier', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 1),
- (9, 'Bruce Banner', 'Somewhere in New York', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 1),
- (10, 'Jessica Jones', 'NYCC 2015 Poster', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1110, 2, NULL, NULL, 0, 1),
- (11, 'Missing', 'The space', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1111, 10, NULL, NULL, 0, 1),
- (12, 'Trash', 'New York city', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1112, 10, NULL, NULL, 0, 1),
- (101, 'Somewhere in Thailand', 'address 01', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
- (102, 'Somewhere in Poland', 'address 02', 'Silla', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0),
- (103, 'Somewhere in Japan', 'address 03', 'Silla', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0),
- (104, 'Somewhere in Spain', 'address 04', 'Silla', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0),
- (105, 'Somewhere in Potugal', 'address 05', 'Silla', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0),
- (106, 'Somewhere in UK', 'address 06', 'Silla', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0),
- (107, 'Somewhere in Valencia', 'address 07', 'Silla', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0),
- (108, 'Somewhere in Silla', 'address 08', 'Silla', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0),
- (109, 'Somewhere in London', 'address 09', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
- (110, 'Somewhere in Algemesi', 'address 10', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
- (111, 'Somewhere in Carlet', 'address 11', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
- (112, 'Somewhere in Campanar', 'address 12', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
- (113, 'Somewhere in Malilla', 'address 13', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
- (114, 'Somewhere in France', 'address 14', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
- (115, 'Somewhere in Birmingham', 'address 15', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
- (116, 'Somewhere in Scotland', 'address 16', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
- (117, 'Somewhere in nowhere', 'address 17', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
- (118, 'Somewhere over the rainbow', 'address 18', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
- (119, 'Somewhere in Alberic', 'address 19', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
- (120, 'Somewhere in Montortal', 'address 20', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
- (121, 'the bat cave', 'address 21', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1101, 2, NULL, NULL, 0, 0),
- (122, 'NY roofs', 'address 22', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 0),
- (123, 'The phone box', 'address 23', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 0),
- (124, 'Stark tower Silla', 'address 24', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1104, 2, NULL, NULL, 0, 0),
- (125, 'The plastic cell', 'address 25', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 0),
- (126, 'Many places', 'address 26', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 0),
- (127, 'Your pocket', 'address 27', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 0),
- (128, 'Cerebro', 'address 28', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 0),
- (129, 'Luke Cages Bar', 'address 29', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1110, 2, NULL, NULL, 0, 0),
- (130, 'Non valid address', 'address 30', 'Silla', 46460, 1, 1111111111, 222222222, 0, 1101, 2, NULL, NULL, 0, 0);
+ (1, 'Bruce Wayne', '1007 Mountain Drive, Gotham', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1101, 2, NULL, NULL, 0, 1),
+ (2, 'Petter Parker', '20 Ingram Street', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 1),
+ (3, 'Clark Kent', '344 Clinton Street', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 1),
+ (4, 'Tony Stark', '10880 Malibu Point', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1104, 2, NULL, NULL, 0, 1),
+ (5, 'Max Eisenhardt', 'Unknown Whereabouts', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 1),
+ (6, 'DavidCharlesHaller', 'Evil hideout', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 1),
+ (7, 'Hank Pym', 'Anthill', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 1),
+ (8, 'Charles Xavier', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 1),
+ (9, 'Bruce Banner', 'Somewhere in New York', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 1),
+ (10, 'Jessica Jones', 'NYCC 2015 Poster', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1110, 2, NULL, NULL, 0, 1),
+ (11, 'Missing', 'The space', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1111, 10, NULL, NULL, 0, 1),
+ (12, 'Trash', 'New York city', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1112, 10, NULL, NULL, 0, 1),
+ (101, 'Somewhere in Thailand', 'address 01', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
+ (102, 'Somewhere in Poland', 'address 02', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0),
+ (103, 'Somewhere in Japan', 'address 03', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0),
+ (104, 'Somewhere in Spain', 'address 04', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0),
+ (105, 'Somewhere in Potugal', 'address 05', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0),
+ (106, 'Somewhere in UK', 'address 06', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0),
+ (107, 'Somewhere in Valencia', 'address 07', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0),
+ (108, 'Somewhere in Gotham', 'address 08', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0),
+ (109, 'Somewhere in London', 'address 09', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
+ (110, 'Somewhere in Algemesi', 'address 10', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
+ (111, 'Somewhere in Carlet', 'address 11', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
+ (112, 'Somewhere in Campanar', 'address 12', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
+ (113, 'Somewhere in Malilla', 'address 13', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
+ (114, 'Somewhere in France', 'address 14', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
+ (115, 'Somewhere in Birmingham', 'address 15', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
+ (116, 'Somewhere in Scotland', 'address 16', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
+ (117, 'Somewhere in nowhere', 'address 17', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
+ (118, 'Somewhere over the rainbow', 'address 18', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
+ (119, 'Somewhere in Alberic', 'address 19', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
+ (120, 'Somewhere in Montortal', 'address 20', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
+ (121, 'the bat cave', 'address 21', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1101, 2, NULL, NULL, 0, 0),
+ (122, 'NY roofs', 'address 22', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 0),
+ (123, 'The phone box', 'address 23', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 0),
+ (124, 'Stark tower Gotham', 'address 24', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1104, 2, NULL, NULL, 0, 0),
+ (125, 'The plastic cell', 'address 25', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 0),
+ (126, 'Many places', 'address 26', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 0),
+ (127, 'Your pocket', 'address 27', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 0),
+ (128, 'Cerebro', 'address 28', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 0),
+ (129, 'Luke Cages Bar', 'address 29', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1110, 2, NULL, NULL, 0, 0),
+ (130, 'Non valid address', 'address 30', 'Gotham', 46460, 1, 1111111111, 222222222, 0, 1101, 2, NULL, NULL, 0, 0);
INSERT INTO `vn`.`address`( `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `isActive`, `clientFk`, `agencyModeFk`, `isDefaultAddress`)
- SELECT name, CONCAT(name, 'Street'), 'SILLA', 46460, 1, 1, id, 2, 1
+ SELECT name, CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, 1, id, 2, 1
FROM `account`.`role` `r`
WHERE `r`.`hasLogin` = 1;
@@ -400,20 +406,20 @@ DROP TEMPORARY TABLE tmp.address;
INSERT INTO `vn`.`clientCredit`(`id`, `clientFk`, `workerFk`, `amount`, `created`)
VALUES
- (1 , 1101, 5, 300, DATE_ADD(CURDATE(), INTERVAL -11 MONTH)),
- (2 , 1101, 5, 900, DATE_ADD(CURDATE(), INTERVAL -10 MONTH)),
- (3 , 1101, 5, 800, DATE_ADD(CURDATE(), INTERVAL -9 MONTH)),
- (4 , 1101, 5, 700, DATE_ADD(CURDATE(), INTERVAL -8 MONTH)),
- (5 , 1101, 5, 600, DATE_ADD(CURDATE(), INTERVAL -7 MONTH)),
- (6 , 1101, 5, 500, DATE_ADD(CURDATE(), INTERVAL -6 MONTH)),
- (7 , 1101, 5, 400, DATE_ADD(CURDATE(), INTERVAL -5 MONTH)),
- (8 , 1101, 9, 300, DATE_ADD(CURDATE(), INTERVAL -4 MONTH)),
- (9 , 1101, 9, 200, DATE_ADD(CURDATE(), INTERVAL -3 MONTH)),
- (10, 1101, 9, 100, DATE_ADD(CURDATE(), INTERVAL -2 MONTH)),
- (11, 1101, 9, 50 , DATE_ADD(CURDATE(), INTERVAL -1 MONTH)),
- (12, 1102, 9, 800, CURDATE()),
- (14, 1104, 9, 90 , CURDATE()),
- (15, 1105, 9, 90 , CURDATE());
+ (1 , 1101, 5, 300, DATE_ADD(util.VN_CURDATE(), INTERVAL -11 MONTH)),
+ (2 , 1101, 5, 900, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 MONTH)),
+ (3 , 1101, 5, 800, DATE_ADD(util.VN_CURDATE(), INTERVAL -9 MONTH)),
+ (4 , 1101, 5, 700, DATE_ADD(util.VN_CURDATE(), INTERVAL -8 MONTH)),
+ (5 , 1101, 5, 600, DATE_ADD(util.VN_CURDATE(), INTERVAL -7 MONTH)),
+ (6 , 1101, 5, 500, DATE_ADD(util.VN_CURDATE(), INTERVAL -6 MONTH)),
+ (7 , 1101, 5, 400, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 MONTH)),
+ (8 , 1101, 9, 300, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH)),
+ (9 , 1101, 9, 200, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH)),
+ (10, 1101, 9, 100, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)),
+ (11, 1101, 9, 50 , DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
+ (12, 1102, 9, 800, util.VN_CURDATE()),
+ (14, 1104, 9, 90 , util.VN_CURDATE()),
+ (15, 1105, 9, 90 , util.VN_CURDATE());
INSERT INTO `vn`.`clientCreditLimit`(`id`, `maxAmount`, `roleFk`)
VALUES
@@ -423,16 +429,16 @@ INSERT INTO `vn`.`clientCreditLimit`(`id`, `maxAmount`, `roleFk`)
INSERT INTO `vn`.`clientObservation`(`id`, `clientFk`, `workerFk`, `text`, `created`)
VALUES
- (1, 1101, 1, 'Madness, as you know, is like gravity, all it takes is a little push', CURDATE()),
- (2, 1102, 1, 'With great power, comes great responsibility', CURDATE()),
- (3, 1103, 3, 'this is a job for Super-Man!', CURDATE()),
- (4, 1104, 3, 'yes... I am Iron-Man', CURDATE()),
- (5, 1105, 5, 'They do understand. Our mutant powers make us superior', CURDATE()),
- (6, 1106, 5, 'My name is Legion, for we are many!', CURDATE()),
- (7, 1107, 9, 'I think our first move should be calling the Avengers..', CURDATE()),
- (8, 1108, 9, 'Just because someone stumbles and loses their path, does not mean they are lost forever.', CURDATE()),
- (9, 1109, 18, 'HULK SMASH! ...', CURDATE()),
- (10, 1110, 18, 'They say everyone is born a hero. But if you let it, life will push you over the line until you are the villain.', CURDATE());
+ (1, 1101, 1, 'Madness, as you know, is like gravity, all it takes is a little push', util.VN_CURDATE()),
+ (2, 1102, 1, 'With great power, comes great responsibility', util.VN_CURDATE()),
+ (3, 1103, 3, 'this is a job for Super-Man!', util.VN_CURDATE()),
+ (4, 1104, 3, 'yes... I am Iron-Man', util.VN_CURDATE()),
+ (5, 1105, 5, 'They do understand. Our mutant powers make us superior', util.VN_CURDATE()),
+ (6, 1106, 5, 'My name is Legion, for we are many!', util.VN_CURDATE()),
+ (7, 1107, 9, 'I think our first move should be calling the Avengers..', util.VN_CURDATE()),
+ (8, 1108, 9, 'Just because someone stumbles and loses their path, does not mean they are lost forever.', util.VN_CURDATE()),
+ (9, 1109, 18, 'HULK SMASH! ...', util.VN_CURDATE()),
+ (10, 1110, 18, 'They say everyone is born a hero. But if you let it, life will push you over the line until you are the villain.', util.VN_CURDATE());
INSERT INTO `vn`.`observationType`(`id`,`description`, `code`)
VALUES
@@ -452,27 +458,35 @@ INSERT INTO `vn`.`addressObservation`(`id`,`addressFk`,`observationTypeFk`,`desc
INSERT INTO `vn`.`creditClassification`(`id`, `client`, `dateStart`, `dateEnd`)
VALUES
- (1, 1101, CURDATE(), CURDATE()),
- (2, 1102, CURDATE(), CURDATE()),
- (3, 1103, CURDATE(), CURDATE()),
- (4, 1104, CURDATE(), CURDATE()),
- (5, 1105, CURDATE(), CURDATE());
+ (1, 1101, util.VN_CURDATE(), util.VN_CURDATE()),
+ (2, 1102, util.VN_CURDATE(), util.VN_CURDATE()),
+ (3, 1103, util.VN_CURDATE(), util.VN_CURDATE()),
+ (4, 1104, util.VN_CURDATE(), util.VN_CURDATE()),
+ (5, 1105, util.VN_CURDATE(), util.VN_CURDATE());
INSERT INTO `vn`.`creditInsurance`(`id`, `creditClassificationFk`, `credit`, `creationDate`, `grade`)
VALUES
- (1, 1, 3000, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), NULL),
- (2, 2, 6000, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), NULL),
- (3, 3, 10000, DATE_ADD(CURDATE(), INTERVAL -3 MONTH), NULL);
+ (1, 1, 3000, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL),
+ (2, 2, 6000, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL),
+ (3, 3, 10000, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL);
INSERT INTO `vn`.`companyGroup`(`id`, `code`)
VALUES
(1, 'wayneIndustries'),
(2, 'verdnatura');
-
-INSERT INTO `vn`.`bankEntity`(`id`, `countryFk`, `name`, `bic`)
+
+INSERT INTO `vn`.`supplierActivity`(`code`, `name`)
VALUES
- (128, 1, 'The Best Bank', 'BBKKESMMMMMM'),
- (2100, 1, 'Caixa Bank', 'CAIXESBB');
+ ('animals', 'Food and complements for pets'),
+ ('complements', 'Other complements'),
+ ('flowerPlants', 'Wholesale of flowers and plants'),
+ ('vegetablesFruits', 'Fruit and vegetable trade');
+
+INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`, `commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`, `workerFk`, `supplierActivityFk`, `isPayMethodChecked`, `healthRegister`)
+ VALUES
+ (1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, util.VN_CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'),
+ (2, 'Farmer King', 'The farmer', 4000020002, 1, '87945234L', 0, util.VN_CURDATE(), 1, 'supplier address 2', 'GOTHAM', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'),
+ (442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, util.VN_CURDATE(), 1, 'supplier address 3', 'GOTHAM', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V');
INSERT INTO `vn`.`supplierAccount`(`id`, `supplierFk`, `iban`, `bankEntityFk`)
VALUES
@@ -504,11 +518,11 @@ INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaF
INSERT INTO `vn`.`invoiceOut`(`id`, `serial`, `amount`, `issued`,`clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `hasPdf`)
VALUES
- (1, 'T', 1014.24, CURDATE(), 1101, CURDATE(), 442, CURDATE(), CURDATE(), 1, 0),
- (2, 'T', 121.36, CURDATE(), 1102, CURDATE(), 442, CURDATE(), CURDATE(), 1, 0),
- (3, 'T', 8.88, CURDATE(), 1103, CURDATE(), 442, CURDATE(), CURDATE(), 1, 0),
- (4, 'T', 8.88, CURDATE(), 1103, CURDATE(), 442, CURDATE(), CURDATE(), 1, 0),
- (5, 'A', 8.88, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1103, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 442, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 0);
+ (1, 'T', 1014.24, util.VN_CURDATE(), 1101, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0),
+ (2, 'T', 121.36, util.VN_CURDATE(), 1102, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0),
+ (3, 'T', 8.88, util.VN_CURDATE(), 1103, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0),
+ (4, 'T', 8.88, util.VN_CURDATE(), 1103, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0),
+ (5, 'A', 8.88, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1103, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 442, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 0);
UPDATE `vn`.`invoiceOut` SET ref = 'T1111111' WHERE id = 1;
UPDATE `vn`.`invoiceOut` SET ref = 'T2222222' WHERE id = 2;
@@ -541,29 +555,29 @@ INSERT INTO `vn`.`expence`(`id`, `taxTypeFk`, `name`, `isWithheld`)
INSERT INTO `vn`.`invoiceOutExpence`(`id`, `invoiceOutFk`, `amount`, `expenceFk`, `created`)
VALUES
- (1, 1, 813.06, 2000000000, CURDATE()),
- (2, 1, 33.80, 4751000000, CURDATE()),
- (3, 1, 70.70, 6210000567, CURDATE()),
- (4, 2, 110.33, 2000000000, CURDATE()),
- (5, 3, 8.07, 2000000000, CURDATE()),
- (6, 4, 8.07, 2000000000, CURDATE()),
- (7, 5, 8.07, 2000000000, CURDATE());
+ (1, 1, 813.06, 2000000000, util.VN_CURDATE()),
+ (2, 1, 33.80, 4751000000, util.VN_CURDATE()),
+ (3, 1, 70.70, 6210000567, util.VN_CURDATE()),
+ (4, 2, 110.33, 2000000000, util.VN_CURDATE()),
+ (5, 3, 8.07, 2000000000, util.VN_CURDATE()),
+ (6, 4, 8.07, 2000000000, util.VN_CURDATE()),
+ (7, 5, 8.07, 2000000000, util.VN_CURDATE());
INSERT INTO `vn`.`zone` (`id`, `name`, `hour`, `agencyModeFk`, `travelingDays`, `price`, `bonus`, `itemMaxSize`)
VALUES
- (1, 'Zone pickup A', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 100),
- (2, 'Zone pickup B', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 100),
- (3, 'Zone 247 A', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 7, 1, 2, 0, 100),
- (4, 'Zone 247 B', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 7, 1, 2, 0, 100),
- (5, 'Zone expensive A', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 8, 1, 1000, 0, 100),
- (6, 'Zone expensive B', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 8, 1, 1000, 0, 100),
- (7, 'Zone refund', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 23, 0, 0, 0, 100),
- (8, 'Zone others', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 10, 0, 0, 0, 100),
- (9, 'Zone superMan', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 2, 0, 0, 0, 100),
- (10, 'Zone teleportation', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 3, 0, 0, 0, 100),
- (11, 'Zone pickup C', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 100),
- (12, 'Zone entanglement', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 4, 0, 0, 0, 100),
- (13, 'Zone quantum break', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 5, 0, 0, 0, 100);
+ (1, 'Zone pickup A', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 100),
+ (2, 'Zone pickup B', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 100),
+ (3, 'Zone 247 A', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 7, 1, 2, 0, 100),
+ (4, 'Zone 247 B', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 7, 1, 2, 0, 100),
+ (5, 'Zone expensive A', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 8, 1, 1000, 0, 100),
+ (6, 'Zone expensive B', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 8, 1, 1000, 0, 100),
+ (7, 'Zone refund', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 23, 0, 0, 0, 100),
+ (8, 'Zone others', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 10, 0, 0, 0, 100),
+ (9, 'Zone superMan', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 2, 0, 0, 0, 100),
+ (10, 'Zone teleportation', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 3, 0, 0, 0, 100),
+ (11, 'Zone pickup C', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 100),
+ (12, 'Zone entanglement', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 4, 0, 0, 0, 100),
+ (13, 'Zone quantum break', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 5, 0, 0, 0, 100);
INSERT INTO `vn`.`zoneWarehouse` (`id`, `zoneFk`, `warehouseFk`)
VALUES
@@ -583,61 +597,61 @@ INSERT INTO `vn`.`zoneWarehouse` (`id`, `zoneFk`, `warehouseFk`)
INSERT INTO `vn`.`zoneClosure` (`zoneFk`, `dated`, `hour`)
VALUES
- (1, CURDATE(), '23:59'),
- (2, CURDATE(), '23:59'),
- (3, CURDATE(), '23:59'),
- (4, CURDATE(), '23:59'),
- (5, CURDATE(), '23:59'),
- (6, CURDATE(), '23:59'),
- (7, CURDATE(), '23:59'),
- (8, CURDATE(), '23:59'),
- (9, CURDATE(), '23:59'),
- (10, CURDATE(), '23:59'),
- (11, CURDATE(), '23:59'),
- (12, CURDATE(), '23:59'),
- (13, CURDATE(), '23:59');
+ (1, util.VN_CURDATE(), '23:59'),
+ (2, util.VN_CURDATE(), '23:59'),
+ (3, util.VN_CURDATE(), '23:59'),
+ (4, util.VN_CURDATE(), '23:59'),
+ (5, util.VN_CURDATE(), '23:59'),
+ (6, util.VN_CURDATE(), '23:59'),
+ (7, util.VN_CURDATE(), '23:59'),
+ (8, util.VN_CURDATE(), '23:59'),
+ (9, util.VN_CURDATE(), '23:59'),
+ (10, util.VN_CURDATE(), '23:59'),
+ (11, util.VN_CURDATE(), '23:59'),
+ (12, util.VN_CURDATE(), '23:59'),
+ (13, util.VN_CURDATE(), '23:59');
INSERT INTO `vn`.`zoneConfig` (`scope`) VALUES ('1');
INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agencyModeFk`, `description`, `m3`, `cost`, `started`, `finished`, `zoneFk`)
VALUES
- (1, '1899-12-30 12:15:00', 56, CURDATE(), 1, 1, 'first route', 1.8, 10, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1),
- (2, '1899-12-30 13:20:00', 56, CURDATE(), 1, 2, 'second route', 0.2, 20, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 9),
- (3, '1899-12-30 14:30:00', 56, CURDATE(), 2, 3, 'third route', 0.5, 30, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 10),
- (4, '1899-12-30 15:45:00', 56, CURDATE(), 3, 4, 'fourth route', 0, 40, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 12),
- (5, '1899-12-30 16:00:00', 56, CURDATE(), 4, 5, 'fifth route', 0.1, 50, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 13),
- (6, NULL, 57, CURDATE(), 5, 7, 'sixth route', 1.7, 60, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 3),
- (7, NULL, 57, CURDATE(), 6, 8, 'seventh route', 0, 70, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 5);
+ (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),
+ (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),
+ (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),
+ (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),
+ (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),
+ (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),
+ (7, NULL, 57, util.VN_CURDATE(), 6, 8, 'seventh route', 0, 70, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 5);
INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`)
VALUES
- (1 , 3, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 121, 'T1111111', 0, 1, 5, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)),
- (2 , 1, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, 'T1111111', 0, 1, 5, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)),
- (3 , 1, 7, 1, 6, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, 'T2222222', 0, 3, 5, 1, DATE_ADD(CURDATE(), INTERVAL -2 MONTH)),
- (4 , 3, 2, 1, 2, DATE_ADD(CURDATE(), INTERVAL -3 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, 'T3333333', 0, 9, 5, 1, DATE_ADD(CURDATE(), INTERVAL -3 MONTH)),
- (5 , 3, 3, 3, 3, DATE_ADD(CURDATE(), INTERVAL -4 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, 'T4444444', 0, 10, 5, 1, DATE_ADD(CURDATE(), INTERVAL -4 MONTH)),
- (6 , 1, 3, 3, 3, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Mountain Drive Gotham', 1, 'A1111111', 0, 10, 5, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)),
- (7 , NULL, 7, 1, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 3, 5, 1, CURDATE()),
- (8 , NULL, 7, 1, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1101, 'Bat cave', 121, NULL, 0, 3, 5, 1, CURDATE()),
- (9 , NULL, 7, 1, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, CURDATE()),
- (10, 1, 1, 5, 1, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1102, 'Ingram Street', 2, NULL, 0, 1, 5, 1, CURDATE()),
- (11, 1, 7, 1, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, CURDATE()),
- (12, 1, 8, 1, 1, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, CURDATE()),
- (13, 1, 7, 1, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 3, 5, 1, CURDATE()),
- (14, 1, 2, 1, NULL, CURDATE(), CURDATE(), 1104, 'Malibu Point', 4, NULL, 0, 9, 5, 1, CURDATE()),
- (15, 1, 7, 1, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1105, 'An incredibly long alias for testing purposes', 125, NULL, 0, 3, 5, 1, CURDATE()),
- (16, 1, 7, 1, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, CURDATE()),
- (17, 1, 7, 2, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, CURDATE()),
- (18, 1, 4, 4, 4, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1108, 'Cerebro', 128, NULL, 0, 12, 5, 1, CURDATE()),
- (19, 1, 5, 5, NULL, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 1, NULL, 5, 1, CURDATE()),
- (20, 1, 5, 5, 3, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 0, 13, 5, 1, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)),
- (21, NULL, 5, 5, 5, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Holland', 102, NULL, 0, 13, 5, 1, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)),
- (22, NULL, 5, 5, 5, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Japan', 103, NULL, 0, 13, 5, 1, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)),
- (23, NULL, 8, 1, 7, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1101, 'address 21', 121, NULL, 0, 5, 5, 1, CURDATE()),
- (24 ,NULL, 8, 1, 7, CURDATE(), CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 5, 5, 1, CURDATE()),
- (25 ,NULL, 8, 1, NULL, CURDATE(), CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 1, 5, 1, CURDATE()),
- (26 ,NULL, 8, 1, NULL, CURDATE(), CURDATE(), 1101, 'An incredibly long alias for testing purposes', 1, NULL, 0, 1, 5, 1, CURDATE()),
- (27 ,NULL, 8, 1, NULL, CURDATE(), CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, CURDATE());
+ (1 , 3, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 121, 'T1111111', 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
+ (2 , 1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, 'T1111111', 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
+ (3 , 1, 7, 1, 6, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, 'T2222222', 0, 3, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)),
+ (4 , 3, 2, 1, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, 'T3333333', 0, 9, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH)),
+ (5 , 3, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, 'T4444444', 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH)),
+ (6 , 1, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Mountain Drive Gotham', 1, 'A1111111', 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
+ (7 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 3, 5, 1, util.VN_CURDATE()),
+ (8 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Bat cave', 121, NULL, 0, 3, 5, 1, util.VN_CURDATE()),
+ (9 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, util.VN_CURDATE()),
+ (10, 1, 1, 5, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'Ingram Street', 2, NULL, 0, 1, 5, 1, util.VN_CURDATE()),
+ (11, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE()),
+ (12, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE()),
+ (13, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 3, 5, 1, util.VN_CURDATE()),
+ (14, 1, 2, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1104, 'Malibu Point', 4, NULL, 0, 9, 5, 1, util.VN_CURDATE()),
+ (15, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1105, 'An incredibly long alias for testing purposes', 125, NULL, 0, 3, 5, 1, util.VN_CURDATE()),
+ (16, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE()),
+ (17, 1, 7, 2, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE()),
+ (18, 1, 4, 4, 4, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1108, 'Cerebro', 128, NULL, 0, 12, 5, 1, util.VN_CURDATE()),
+ (19, 1, 5, 5, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 1, NULL, 5, 1, util.VN_CURDATE()),
+ (20, 1, 5, 5, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)),
+ (21, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Holland', 102, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)),
+ (22, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Japan', 103, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)),
+ (23, NULL, 8, 1, 7, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'address 21', 121, NULL, 0, 5, 5, 1, util.VN_CURDATE()),
+ (24 ,NULL, 8, 1, 7, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 5, 5, 1, util.VN_CURDATE()),
+ (25 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE()),
+ (26 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'An incredibly long alias for testing purposes', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE()),
+ (27 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE());
INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`)
VALUES
@@ -655,42 +669,38 @@ INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `des
(12, 11, 3, 'Delivery after 10am');
-- FIX for state hours on local, inter_afterInsert
-UPDATE vncontrol.inter SET odbc_date = DATE_ADD(CURDATE(), INTERVAL -10 SECOND);
+UPDATE vncontrol.inter SET odbc_date = DATE_ADD(util.VN_CURDATE(), INTERVAL -10 SECOND);
INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `workerFk`, `created`)
VALUES
- (1, 16, 5 , DATE_ADD(NOW(), INTERVAL -1 MONTH)),
- (2, 16, 5 , DATE_ADD(NOW(), INTERVAL -1 MONTH)),
- (3, 16, 5 , DATE_ADD(NOW(), INTERVAL -2 MONTH)),
- (4, 16, 5 , DATE_ADD(NOW(), INTERVAL -3 MONTH)),
- (5, 16, 18, DATE_ADD(NOW(), INTERVAL -4 MONTH)),
- (6, 16, 18, DATE_ADD(NOW(), INTERVAL -1 MONTH)),
- (7, 10, 18, NOW()),
- (8, 5, 19, NOW()),
- (9, 5, 19, NOW()),
- (10, 5, 19, NOW()),
- (11, 3, 19, NOW()),
- (12, 3, 19, NOW()),
- (13, 3, 19, NOW()),
- (14, 3, 19, NOW()),
- (15, 2, 19, NOW()),
- (16, 3, 19, NOW()),
- (17, 2, 19, NOW()),
- (18, 2, 19, NOW()),
- (19, 2, 19, NOW()),
- (20, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)),
- (21, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)),
- (22, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)),
- (23, 16, 21, NOW()),
- (24, 16, 21, NOW());
-
-INSERT INTO `vn`.`stowaway`(`id`, `shipFk`, `created`)
- VALUES
- (12, 13, CURDATE());
+ (1, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -1 MONTH)),
+ (2, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -1 MONTH)),
+ (3, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -2 MONTH)),
+ (4, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -3 MONTH)),
+ (5, 16, 18, DATE_ADD(util.VN_NOW(), INTERVAL -4 MONTH)),
+ (6, 16, 18, DATE_ADD(util.VN_NOW(), INTERVAL -1 MONTH)),
+ (7, 10, 18, util.VN_NOW()),
+ (8, 5, 19, util.VN_NOW()),
+ (9, 5, 19, util.VN_NOW()),
+ (10, 5, 19, util.VN_NOW()),
+ (11, 3, 19, util.VN_NOW()),
+ (12, 3, 19, util.VN_NOW()),
+ (13, 3, 19, util.VN_NOW()),
+ (14, 3, 19, util.VN_NOW()),
+ (15, 2, 19, util.VN_NOW()),
+ (16, 3, 19, util.VN_NOW()),
+ (17, 2, 19, util.VN_NOW()),
+ (18, 2, 19, util.VN_NOW()),
+ (19, 2, 19, util.VN_NOW()),
+ (20, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)),
+ (21, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)),
+ (22, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)),
+ (23, 16, 21, util.VN_NOW()),
+ (24, 16, 21, util.VN_NOW());
INSERT INTO `vn`.`deliveryPoint` (`id`, `name`, `ubication`)
VALUES
- (1, 'Silla','46460 Av Espioca 100-Silla');
+ (1, 'Gotham','1007 Mountain Drive, Gotham');
INSERT INTO `vn`.`vehicle`(`id`, `numberPlate`, `tradeMark`, `model`, `companyFk`, `warehouseFk`, `description`, `m3`, `isActive`, `deliveryPointFk`)
VALUES
@@ -703,7 +713,7 @@ INSERT INTO `vn`.`vehicle`(`id`, `numberPlate`, `tradeMark`, `model`, `companyFk
INSERT INTO `vn`.`config`(`id`, `mdbServer`, `fakeEmail`, `defaultersMaxAmount`, `inventoried`)
VALUES
- (1, 'beta-server', 'nightmare@mydomain.com', '200', DATE_ADD(CURDATE(),INTERVAL -1 MONTH));
+ (1, 'beta-server', 'nightmare@mydomain.com', '200', DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH));
INSERT INTO `vn`.`greugeType`(`id`, `name`, `code`)
VALUES
@@ -717,18 +727,18 @@ INSERT INTO `vn`.`greugeType`(`id`, `name`, `code`)
INSERT INTO `vn`.`greuge`(`id`, `clientFk`, `description`, `amount`, `shipped`, `created`, `greugeTypeFk`, `ticketFk`)
VALUES
- (1, 1101, 'some diff charges', -19.99, DATE_ADD(CURDATE(), INTERVAL 1 MONTH), CURDATE(), 1, 1),
- (2, 1101, 'more diff charges', 60, DATE_ADD(CURDATE(), INTERVAL 1 MONTH), CURDATE(), 2, 1),
- (3, 1101, 'even more! diff charges', -9.99, DATE_ADD(CURDATE(), INTERVAL 1 MONTH), CURDATE(), 3, 1),
- (4, 1101, 'insane diff charges', 60, DATE_ADD(CURDATE(), INTERVAL 1 MONTH), CURDATE(), 4, 1),
- (5, 1101, 'gargantuous diff charges', -9.99, DATE_ADD(CURDATE(), INTERVAL 1 MONTH), CURDATE(), 5, 1),
- (6, 1101, 'diff charges', 88.30, DATE_ADD(CURDATE(), INTERVAL 1 MONTH), CURDATE(), 6, 1),
- (7, 1101, 'unaffordable diff charges', -39.12, DATE_ADD(CURDATE(), INTERVAL 1 MONTH), CURDATE(), 1, 1),
- (8, 1101, 'some recovery charges', 29.35, DATE_ADD(CURDATE(), INTERVAL 1 MONTH), CURDATE(), 2, 1),
- (9, 1101, 'some manna charges', -9.99, DATE_ADD(CURDATE(), INTERVAL 1 MONTH), CURDATE(), 3, 1),
- (10, 1101, 'some claim charges', 13.13, DATE_ADD(CURDATE(), INTERVAL 1 MONTH), CURDATE(), 4, 1),
- (11, 1101, 'some heritage charges', -15.99, DATE_ADD(CURDATE(), INTERVAL 1 MONTH), CURDATE(), 5, 1),
- (12, 1101, 'some miscellaneous charges', 58.00, DATE_ADD(CURDATE(), INTERVAL 1 MONTH), CURDATE(), 6, 1);
+ (1, 1101, 'some diff charges', -19.99, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 1, 1),
+ (2, 1101, 'more diff charges', 60, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 2, 1),
+ (3, 1101, 'even more! diff charges', -9.99, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 3, 1),
+ (4, 1101, 'insane diff charges', 60, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 4, 1),
+ (5, 1101, 'gargantuous diff charges', -9.99, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 5, 1),
+ (6, 1101, 'diff charges', 88.30, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 6, 1),
+ (7, 1101, 'unaffordable diff charges', -39.12, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 1, 1),
+ (8, 1101, 'some recovery charges', 29.35, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 2, 1),
+ (9, 1101, 'some manna charges', -9.99, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 3, 1),
+ (10, 1101, 'some claim charges', 13.13, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 4, 1),
+ (11, 1101, 'some heritage charges', -15.99, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 5, 1),
+ (12, 1101, 'some miscellaneous charges', 58.00, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 6, 1);
INSERT INTO `vn`.`mandateType`(`id`, `name`)
VALUES
@@ -738,7 +748,7 @@ INSERT INTO `vn`.`mandateType`(`id`, `name`)
INSERT INTO `vn`.`mandate`(`id`, `clientFk`, `companyFk`, `code`, `created`, `mandateTypeFk`)
VALUES
- (1, 1102, 442, '1-1', CURDATE(), 2);
+ (1, 1102, 442, '1-1', util.VN_CURDATE(), 2);
INSERT INTO `vn`.`itemCategory`(`id`, `name`, `display`, `color`, `icon`, `code`)
VALUES
@@ -793,10 +803,10 @@ INSERT INTO `vn`.`taxType`(`id`, `nickname`, `isAccrued`, `serial`, `TIPOOPE`, `
INSERT INTO `vn`.`taxCode`(`id`, `dated`, `code`, `taxTypeFk`, `rate`, `equalizationTax`, `type`, `link`, `isActive`, `updated`, `transactionCode`)
VALUES
- (1 , CURDATE(), '1111111111', 1, 7.0 , 0.0, 'R', 1, 1, CURDATE(), 1),
- (2 , CURDATE(), '2222222222', 2, 16.0, 0.0, 'G', 2, 1, CURDATE(), 1),
- (21 , CURDATE(), '3333333333', 1, 7.0, 0.0, 'R', 3, 1, CURDATE(), 1),
- (108, CURDATE(), '4444444444', 2, 8.0 , 0.0, 'R', 4, 1, CURDATE(), 1);
+ (1 , util.VN_CURDATE(), '1111111111', 1, 7.0 , 0.0, 'R', 1, 1, util.VN_CURDATE(), 1),
+ (2 , util.VN_CURDATE(), '2222222222', 2, 16.0, 0.0, 'G', 2, 1, util.VN_CURDATE(), 1),
+ (21 , util.VN_CURDATE(), '3333333333', 1, 7.0, 0.0, 'R', 3, 1, util.VN_CURDATE(), 1),
+ (108, util.VN_CURDATE(), '4444444444', 2, 8.0 , 0.0, 'R', 4, 1, util.VN_CURDATE(), 1);
INSERT INTO `vn`.`taxClass`(`id`, `description`, `code`)
VALUES
@@ -805,9 +815,9 @@ INSERT INTO `vn`.`taxClass`(`id`, `description`, `code`)
INSERT INTO `vn`.`taxClassCode`(`taxClassFk`, `effectived`, `taxCodeFk`)
VALUES
- (1, CURDATE(), 1),
- (1, CURDATE(), 21),
- (2, CURDATE(), 2);
+ (1, util.VN_CURDATE(), 1),
+ (1, util.VN_CURDATE(), 21),
+ (2, util.VN_CURDATE(), 2);
INSERT INTO `vn`.`intrastat`(`id`, `description`, `taxClassFk`, `taxCodeFk`)
VALUES
@@ -847,9 +857,9 @@ UPDATE `vn`.`itemTaxCountry` SET `taxClassFk` = 2
INSERT INTO `vn`.`priceFixed`(`id`, `itemFk`, `rate0`, `rate1`, `rate2`, `rate3`, `started`, `ended`, `bonus`, `warehouseFk`, `created`)
VALUES
- (1, 1, 0, 0, 2.5, 2, CURDATE(), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 0, 1, CURDATE()),
- (2, 3, 10, 10, 10, 10, CURDATE(), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 0, 1, CURDATE()),
- (3, 13, 8.5, 10, 7.5, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 1, 2, CURDATE());
+ (1, 1, 0, 0, 2.5, 2, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 0, 1, util.VN_CURDATE()),
+ (2, 3, 10, 10, 10, 10, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 0, 1, util.VN_CURDATE()),
+ (3, 13, 8.5, 10, 7.5, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 1, 2, util.VN_CURDATE());
INSERT INTO `vn`.`expeditionBoxVol`(`boxFk`, `m3`, `ratio`)
VALUES
@@ -857,14 +867,14 @@ INSERT INTO `vn`.`expeditionBoxVol`(`boxFk`, `m3`, `ratio`)
INSERT INTO `vn`.`packaging`(`id`, `volume`, `width`, `height`, `depth`, `isPackageReturnable`, `created`, `itemFk`, `price`)
VALUES
- (1, 0.00, 10, 10, 0, 1, CURDATE(), 6, 1.50),
- (2, 100.00, 20, 20, 0, 1, CURDATE(), 7, 1.00),
- (3, 14000.00, 0, 0, 0, 1, CURDATE(), NULL, 0),
- (4, 218000.00, 0, 0, 0, 0, CURDATE(), NULL, 0),
- (5, 292000.00, 0, 0, 0, 0, CURDATE(), NULL, 0),
- (94, 140875.00, 49.00, 115.00, 25.00, 0, CURDATE(), 71, 0.00),
- ('cc', 1640038.00, 56.00, 220.00, 128.00, 1, CURDATE(), 15, 90.00),
- ('pallet 100', 2745600.00, 100.00, 220.00, 120.00, 1, CURDATE(), 16, 0.00);
+ (1, 0.00, 10, 10, 0, 1, util.VN_CURDATE(), 6, 1.50),
+ (2, 100.00, 20, 20, 0, 1, util.VN_CURDATE(), 7, 1.00),
+ (3, 14000.00, 0, 0, 0, 1, util.VN_CURDATE(), NULL, 0),
+ (4, 218000.00, 0, 0, 0, 0, util.VN_CURDATE(), NULL, 0),
+ (5, 292000.00, 0, 0, 0, 0, util.VN_CURDATE(), NULL, 0),
+ (94, 140875.00, 49.00, 115.00, 25.00, 0, util.VN_CURDATE(), 71, 0.00),
+ ('cc', 1640038.00, 56.00, 220.00, 128.00, 1, util.VN_CURDATE(), 15, 90.00),
+ ('pallet 100', 2745600.00, 100.00, 220.00, 120.00, 1, util.VN_CURDATE(), 16, 0.00);
INSERT INTO `vn`.`expeditionStateType`(`id`, `description`, `code`)
VALUES
@@ -873,70 +883,70 @@ INSERT INTO `vn`.`expeditionStateType`(`id`, `description`, `code`)
(3, 'Perdida', 'LOST');
-INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `created`, `itemFk`, `counter`, `checked`, `workerFk`, `externalId`, `packagingFk`, `stateTypeFk`)
+INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `created`, `itemFk`, `counter`, `workerFk`, `externalId`, `packagingFk`, `stateTypeFk`)
VALUES
- (1, 1, 1, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 15, 1, 1, 18, 'UR9000006041', 94, 1),
- (2, 1, 1, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 16, 2, 1, 18, 'UR9000006041', 94, 1),
- (3, 1, 1, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), NULL, 3, 1, 18, 'UR9000006041', 94, 2),
- (4, 1, 1, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), NULL, 4, 1, 18, 'UR9000006041', 94, 2),
- (5, 1, 2, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), NULL, 1, 1, 18, NULL, 94, 3),
- (6, 7, 3, 71, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), NULL, 1, 1, 18, NULL, 94, 3),
- (7, 2, 4, 71, DATE_ADD(CURDATE(), INTERVAL -3 MONTH), NULL, 1, 1, 18, NULL, 94, NULL),
- (8, 3, 5, 71, DATE_ADD(CURDATE(), INTERVAL -4 MONTH), NULL, 1, 1, 18, NULL, 94, 1),
- (9, 3, 6, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), NULL, 1, 1, 18, NULL, 94, 2),
- (10, 7, 7, 71, NOW(), NULL, 1, 1, 18, NULL, 94, 3);
+ (1, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 15, 1, 18, 'UR9000006041', 94, 1),
+ (2, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 16, 2, 18, 'UR9000006041', 94, 1),
+ (3, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 3, 18, 'UR9000006041', 94, 2),
+ (4, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 4, 18, 'UR9000006041', 94, 2),
+ (5, 1, 2, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 1, 18, NULL, 94, 3),
+ (6, 7, 3, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL, 1, 18, NULL, 94, 3),
+ (7, 2, 4, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL, 1, 18, NULL, 94, NULL),
+ (8, 3, 5, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL, 1, 18, NULL, 94, 1),
+ (9, 3, 6, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 1, 18, NULL, 94, 2),
+ (10, 7, 7, 71, NOW(), NULL, 1, 18, NULL, 94, 3);
INSERT INTO `vn`.`expeditionState`(`id`, `created`, `expeditionFk`, `typeFk`, `userFk`)
VALUES
- (1, CURDATE(), 1, 1, 1),
- (2, CURDATE(), 2, 1, 1),
- (3, CURDATE(), 3, 1, 1),
- (4, CURDATE(), 3, 2, 1106),
- (5, CURDATE(), 5, 1, 1106),
- (6, CURDATE(), 5, 3, 1106);
+ (1, util.VN_CURDATE(), 1, 1, 1),
+ (2, util.VN_CURDATE(), 2, 1, 1),
+ (3, util.VN_CURDATE(), 3, 1, 1),
+ (4, util.VN_CURDATE(), 3, 2, 1106),
+ (5, util.VN_CURDATE(), 5, 1, 1106),
+ (6, util.VN_CURDATE(), 5, 3, 1106);
INSERT INTO `vn`.`ticketPackaging`(`id`, `ticketFk`, `packagingFk`, `quantity`, `created`, `pvp`)
VALUES
- (1, 1, 2, 2, CURDATE(), NULL),
- (2, 2, 2, 1, CURDATE(), NULL),
- (3, 3, 2, 4, CURDATE(), NULL);
+ (1, 1, 2, 2, util.VN_CURDATE(), NULL),
+ (2, 2, 2, 1, util.VN_CURDATE(), NULL),
+ (3, 3, 2, 4, util.VN_CURDATE(), NULL);
INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `price`, `discount`, `reserved`, `isPicked`, `created`)
VALUES
- (1, 1, 1, 'Ranged weapon longbow 2m', 5, 100.39, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)),
- (2, 2, 1, 'Melee weapon combat fist 15cm', 10, 7.07, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)),
- (3, 1, 1, 'Ranged weapon longbow 2m', 2, 100.39, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)),
- (4, 4, 1, 'Melee weapon heavy shield 1x0.5m', 20, 1.69, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)),
- (5, 1, 2, 'Ranged weapon longbow 2m', 1, 110.33, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)),
- (6, 1, 3, 'Ranged weapon longbow 2m', 1, 110.33, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -2 MONTH)),
- (7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.44, 0, 0, 0, CURDATE()),
- (8, 4, 11, 'Melee weapon heavy shield 1x0.5m', 10, 1.79, 0, 0, 0, CURDATE()),
- (9, 1, 16, 'Ranged weapon longbow 2m', 1, 103.49, 0, 0, 0, CURDATE()),
- (10, 2, 16, 'Melee weapon combat fist 15cm', 10, 7.09, 0, 0, 0, CURDATE()),
- (11, 1, 16, 'Ranged weapon longbow 2m', 1, 103.49, 0, 0, 0, CURDATE()),
- (12, 4, 16, 'Melee weapon heavy shield 1x0.5m', 20, 1.71, 0, 0, 0, CURDATE()),
- (13, 2, 8, 'Melee weapon combat fist 15cm', 10, 7.08, 0, 0, 0, CURDATE()),
- (14, 1, 8, 'Ranged weapon longbow 2m', 2, 103.49, 0, 0, 0, CURDATE()),
- (15, 1, 19, 'Ranged weapon longbow 2m', 1, 103.49, 0, 0, 0, CURDATE()),
- (16, 2, 20, 'Melee weapon combat fist 15cm', 20, 7.07, 0, 0, 0, CURDATE()),
- (17, 2, 22, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)),
- (18, 4, 22, 'Melee weapon heavy shield 1x0.5m', 20, 1.69, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)),
- (19, 1, 4, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -3 MONTH)),
- (20, 1, 5, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -4 MONTH)),
- (21, 1, 6, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)),
- (22, 1, 7, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, CURDATE()),
- (23, 1, 9, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, CURDATE()),
- (24, 1, 10, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, CURDATE()),
- (25, 4, 12, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, CURDATE()),
- (26, 4, 13, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, CURDATE()),
- (27, 4, 14, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, CURDATE()),
- (28, 4, 15, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, CURDATE()),
- (29, 4, 17, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, CURDATE()),
- (30, 4, 18, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, CURDATE()),
- (31, 2, 23, 'Melee weapon combat fist 15cm', -5, 7.08, 0, 0, 0, CURDATE()),
- (32, 1, 24, 'Ranged weapon longbow 2m', -1, 8.07, 0, 0, 0, CURDATE()),
- (33, 5, 14, 'Ranged weapon pistol 9mm', 50, 1.79, 0, 0, 0, CURDATE());
+ (1, 1, 1, 'Ranged weapon longbow 2m', 5, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
+ (2, 2, 1, 'Melee weapon combat fist 15cm', 10, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
+ (3, 1, 1, 'Ranged weapon longbow 2m', 2, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
+ (4, 4, 1, 'Melee weapon heavy shield 1x0.5m', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
+ (5, 1, 2, 'Ranged weapon longbow 2m', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
+ (6, 1, 3, 'Ranged weapon longbow 2m', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)),
+ (7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.44, 0, 0, 0, util.VN_CURDATE()),
+ (8, 4, 11, 'Melee weapon heavy shield 1x0.5m', 10, 1.79, 0, 0, 0, util.VN_CURDATE()),
+ (9, 1, 16, 'Ranged weapon longbow 2m', 1, 103.49, 0, 0, 0, util.VN_CURDATE()),
+ (10, 2, 16, 'Melee weapon combat fist 15cm', 10, 7.09, 0, 0, 0, util.VN_CURDATE()),
+ (11, 1, 16, 'Ranged weapon longbow 2m', 1, 103.49, 0, 0, 0, util.VN_CURDATE()),
+ (12, 4, 16, 'Melee weapon heavy shield 1x0.5m', 20, 1.71, 0, 0, 0, util.VN_CURDATE()),
+ (13, 2, 8, 'Melee weapon combat fist 15cm', 10, 7.08, 0, 0, 0, util.VN_CURDATE()),
+ (14, 1, 8, 'Ranged weapon longbow 2m', 2, 103.49, 0, 0, 0, util.VN_CURDATE()),
+ (15, 1, 19, 'Ranged weapon longbow 2m', 1, 103.49, 0, 0, 0, util.VN_CURDATE()),
+ (16, 2, 20, 'Melee weapon combat fist 15cm', 20, 7.07, 0, 0, 0, util.VN_CURDATE()),
+ (17, 2, 22, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)),
+ (18, 4, 22, 'Melee weapon heavy shield 1x0.5m', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)),
+ (19, 1, 4, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH)),
+ (20, 1, 5, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH)),
+ (21, 1, 6, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
+ (22, 1, 7, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, util.VN_CURDATE()),
+ (23, 1, 9, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, util.VN_CURDATE()),
+ (24, 1, 10, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, util.VN_CURDATE()),
+ (25, 4, 12, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
+ (26, 4, 13, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
+ (27, 4, 14, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
+ (28, 4, 15, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
+ (29, 4, 17, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
+ (30, 4, 18, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
+ (31, 2, 23, 'Melee weapon combat fist 15cm', -5, 7.08, 0, 0, 0, util.VN_CURDATE()),
+ (32, 1, 24, 'Ranged weapon longbow 2m', -1, 8.07, 0, 0, 0, util.VN_CURDATE()),
+ (33, 5, 14, 'Ranged weapon pistol 9mm', 50, 1.79, 0, 0, 0, util.VN_CURDATE());
INSERT INTO `vn`.`saleChecked`(`saleFk`, `isChecked`)
VALUES
@@ -1098,10 +1108,10 @@ INSERT INTO `vncontrol`.`accion`(`accion_id`, `accion`)
INSERT INTO `vn`.`saleTracking`(`saleFk`, `isChecked`, `created`, `originalQuantity`, `workerFk`, `actionFk`, `id`, `stateFk`)
VALUES
- (1, 0, CURDATE(), 5, 55, 3, 1, 14),
- (1, 1, CURDATE(), 5, 54, 3, 2, 8),
- (2, 1, CURDATE(), 10, 40, 4, 3, 8),
- (3, 1, CURDATE(), 2, 40, 4, 4, 8);
+ (1, 0, util.VN_CURDATE(), 5, 55, 3, 1, 14),
+ (1, 1, util.VN_CURDATE(), 5, 54, 3, 2, 8),
+ (2, 1, util.VN_CURDATE(), 10, 40, 4, 3, 8),
+ (3, 1, util.VN_CURDATE(), 2, 40, 4, 4, 8);
INSERT INTO `vn`.`itemBarcode`(`id`, `itemFk`, `code`)
VALUES
@@ -1109,13 +1119,6 @@ INSERT INTO `vn`.`itemBarcode`(`id`, `itemFk`, `code`)
(2, 1, 2222222222),
(3, 1, 3333333333),
(4, 2, 4444444444);
-
-INSERT INTO `vn`.`itemPlacement`(`id`, `itemFk`, `warehouseFk`, `code`)
- VALUES
- (1, 1, 1, 'A11'),
- (2, 1, 2, 'A22'),
- (3, 1, 3, 'A33'),
- (4, 2, 1, 'A44');
INSERT INTO `vn`.`train`(`id`, `name`)
VALUES
@@ -1124,22 +1127,20 @@ INSERT INTO `vn`.`train`(`id`, `name`)
INSERT INTO `vn`.`collection`(`id`, `workerFk`, `stateFk`, `created`, `trainFk`)
VALUES
- (1, 1106, 5, DATE_ADD(CURDATE(),INTERVAL +1 DAY), 1),
- (2, 1106, 14, CURDATE(), 1);
+ (1, 1106, 5, DATE_ADD(util.VN_CURDATE(),INTERVAL +1 DAY), 1),
+ (2, 1106, 14, util.VN_CURDATE(), 1);
-INSERT INTO `vn`.`ticketCollection`(`id`, `ticketFk`, `collectionFk`)
+INSERT INTO `vn`.`ticketCollection`(`ticketFk`, `collectionFk`, `level`)
VALUES
- (2, 2, 1),
- (3, 3, 2);
+ (1, 1, 1),
+ (2, 1, NULL),
+ (3, 2, NULL),
+ (23, 1, NULL);
INSERT INTO `vn`.`parking` (`column`, `row`, `sectorFk`, `code`, `pickingOrder`)
VALUES
('100', '01', 1, '100-01', 1);
-INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `level`)
- VALUES
- (1, 1, 1);
-
INSERT INTO `vn`.`genus`(`id`, `name`)
VALUES
(1, 'Abelia'),
@@ -1284,9 +1285,9 @@ INSERT INTO `vn`.`itemTypeTag`(`id`, `itemTypeFk`, `tagFk`, `priority`)
VALUES
(1, 1, 1, 0),
(2, 2, 2, 0),
- (3, 3, 3, 1),
- (4, 1, 4, 1),
- (5, 1, 5, 1);
+ (3, 3, 3, 0),
+ (4, 1, 4, 4),
+ (5, 1, 5, 5);
CALL `vn`.`itemRefreshTags`(NULL);
@@ -1296,10 +1297,10 @@ INSERT INTO `vn`.`itemLog` (`id`, `originFk`, `userFk`, `action`, `description`)
INSERT INTO `vn`.`recovery`(`id`, `clientFk`, `started`, `finished`, `amount`, `period`)
VALUES
- (1, 1101, DATE_ADD(CURDATE(),INTERVAL -7 MONTH), DATE_ADD(CURDATE(),INTERVAL -3 MONTH), 50, 7),
- (2, 1102, DATE_ADD(CURDATE(),INTERVAL -5 MONTH), CURDATE(), 100, 1),
- (3, 1102, CURDATE(), DATE_ADD(CURDATE(),INTERVAL 1 MONTH), 50, 7),
- (4, 1103, CURDATE(), NULL, 50, 7);
+ (1, 1101, DATE_ADD(util.VN_CURDATE(),INTERVAL -7 MONTH), DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), 50, 7),
+ (2, 1102, DATE_ADD(util.VN_CURDATE(),INTERVAL -5 MONTH), util.VN_CURDATE(), 100, 1),
+ (3, 1102, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(),INTERVAL 1 MONTH), 50, 7),
+ (4, 1103, util.VN_CURDATE(), NULL, 50, 7);
INSERT INTO `vn`.`annualAverageInvoiced`(`clientFk`, `invoiced`)
VALUES
@@ -1309,13 +1310,6 @@ INSERT INTO `vn`.`annualAverageInvoiced`(`clientFk`, `invoiced`)
(1104, 500),
(1105, 5000);
-INSERT INTO `vn`.`supplierActivity`(`code`, `name`)
- VALUES
- ('animals', 'Food and complements for pets'),
- ('complements', 'Other complements'),
- ('flowerPlants', 'Wholesale of flowers and plants'),
- ('vegetablesFruits', 'Fruit and vegetable trade');
-
INSERT INTO `vn`.`supplierAddress`(`id`, `supplierFk`, `nickname`, `street`, `provinceFk`, `postalCode`, `city`, `phone`, `mobile`)
VALUES
(1, 1, 'Ace Chemicals', 'The Midtown', 1, '46000', 'Gotham', '111111111', '222222222'),
@@ -1325,12 +1319,6 @@ INSERT INTO `vn`.`supplierAddress`(`id`, `supplierFk`, `nickname`, `street`, `pr
(5, 442, 'GCR building', 'Bristol district', 1, '46000', 'Gotham', '111111111', '222222222'),
(6, 442, 'The Gotham Tonight building', 'Bristol district', 1, '46000', 'Gotham', '111111111', '222222222');
-INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`, `commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`, `workerFk`, `supplierActivityFk`, `isPayMethodChecked`, `healthRegister`)
- VALUES
- (1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'),
- (2, 'Farmer King', 'The farmer', 4000020002, 1, '87945234L', 0, CURDATE(), 1, 'supplier address 2', 'SILLA', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'),
- (442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, CURDATE(), 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V');
-
INSERT INTO `vn`.`supplierContact`(`id`, `supplierFk`, `phone`, `mobile`, `email`, `observation`, `name`)
VALUES
(1, 1, 123121212, 654789123, 'supplier1@email.es', 'observation1', 'the boss'),
@@ -1340,9 +1328,9 @@ INSERT INTO `vn`.`supplierContact`(`id`, `supplierFk`, `phone`, `mobile`, `email
INSERT INTO `cache`.`cache_calc`(`id`, `cache_id`, `cacheName`, `params`, `last_refresh`, `expires`, `created`, `connection_id`)
VALUES
- (1, 2, 'available', CONCAT_WS('/',1,CURDATE()), CURRENT_TIMESTAMP(), DATE_ADD(CURRENT_TIMESTAMP(),INTERVAL 15 MINUTE), CURDATE(), NULL),
- (2, 4, 'last_buy', CONCAT_WS('/',1,CURDATE()), CURRENT_TIMESTAMP(), DATE_ADD(CURRENT_TIMESTAMP(),INTERVAL 15 MINUTE), CURDATE(), NULL),
- (3, 8, 'visible', CONCAT_WS('/',1,CURDATE()), CURRENT_TIMESTAMP(), DATE_ADD(CURRENT_TIMESTAMP(),INTERVAL 15 MINUTE), CURDATE(), NULL);
+ (1, 2, 'available', CONCAT_WS('/',1,util.VN_CURDATE()), util.VN_NOW(), DATE_ADD(util.VN_NOW(),INTERVAL 15 MINUTE), util.VN_CURDATE(), NULL),
+ (2, 4, 'last_buy', CONCAT_WS('/',1,util.VN_CURDATE()), util.VN_NOW(), DATE_ADD(util.VN_NOW(),INTERVAL 15 MINUTE), util.VN_CURDATE(), NULL),
+ (3, 8, 'visible', CONCAT_WS('/',1,util.VN_CURDATE()), util.VN_NOW(), DATE_ADD(util.VN_NOW(),INTERVAL 15 MINUTE), util.VN_CURDATE(), NULL);
INSERT INTO `vn`.`ticketWeekly`(`ticketFk`, `weekDay`)
VALUES
@@ -1354,25 +1342,25 @@ INSERT INTO `vn`.`ticketWeekly`(`ticketFk`, `weekDay`)
INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`)
VALUES
- (1, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), DATE_ADD(CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1),
- (2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150, 2000, 'second travel', 2, 2),
- (3, CURDATE(), CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1),
- (4, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 3, 1, 50.00, 500, 'fourth travel', 0, 2),
- (5, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1),
- (6, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2),
- (7, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1),
- (8, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2);
+ (1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1),
+ (2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150, 2000, 'second travel', 2, 2),
+ (3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1),
+ (4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 3, 1, 50.00, 500, 'fourth travel', 0, 2),
+ (5, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1),
+ (6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2),
+ (7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1),
+ (8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2);
-INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `ref`,`isInventory`, `isRaid`, `notes`, `evaNotes`)
+INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `ref`,`isExcludedFromAvailable`, `isRaid`, `notes`, `evaNotes`)
VALUES
- (1, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'Movement 1', 0, 0, '', ''),
- (2, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 0, 442, 'Movement 2', 0, 0, 'this is the note two', 'observation two'),
- (3, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 3, 0, 442, 'Movement 3', 0, 0, 'this is the note three', 'observation three'),
- (4, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 0, 69, 'Movement 4', 0, 0, 'this is the note four', 'observation four'),
- (5, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 0, 442, 'Movement 5', 0, 0, 'this is the note five', 'observation five'),
- (6, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 6, 0, 442, 'Movement 6', 0, 0, 'this is the note six', 'observation six'),
- (7, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'Movement 7', 0, 0, 'this is the note seven', 'observation seven'),
- (8, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'Movement 8', 1, 1, '', '');
+ (1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'Movement 1', 0, 0, '', ''),
+ (2, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 442, 'Movement 2', 0, 0, 'this is the note two', 'observation two'),
+ (3, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 0, 442, 'Movement 3', 0, 0, 'this is the note three', 'observation three'),
+ (4, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 69, 'Movement 4', 0, 0, 'this is the note four', 'observation four'),
+ (5, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 0, 442, 'Movement 5', 0, 0, 'this is the note five', 'observation five'),
+ (6, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 6, 0, 442, 'Movement 6', 0, 0, 'this is the note six', 'observation six'),
+ (7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'Movement 7', 0, 0, 'this is the note seven', 'observation seven'),
+ (8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'Movement 8', 1, 1, '', '');
INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRate`, `priceIncreasing`, `packingRate`)
VALUES
@@ -1383,97 +1371,97 @@ INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRa
INSERT INTO `bs`.`waste`(`buyer`, `year`, `week`, `family`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleWaste`, `rate`)
VALUES
- ('CharlesXavier', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation', 1, 1, '1062', '51', '4.8'),
- ('CharlesXavier', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Colombia', 2, 1, '35074', '687', '2.0'),
- ('CharlesXavier', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Mini', 3, 1, '1777', '13', '0.7'),
- ('CharlesXavier', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Short', 4, 1, '3182', '59', '0.6'),
- ('CharlesXavier', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Crisantemo', 5, 1, '1747', '13', '0.7'),
- ('CharlesXavier', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Lilium Oriental', 6, 1, '7182', '59', '0.6'),
- ('CharlesXavier', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Alstroemeria', 7, 1, '1777', '13', '0.7'),
- ('CharlesXavier', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Cymbidium', 1, 1, '4181', '59', '0.6'),
- ('CharlesXavier', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Cymbidium', 2, 1, '7268', '59', '0.6'),
- ('DavidCharlesHaller', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Containers', 2, 1, '-74', '0', '0.0'),
- ('DavidCharlesHaller', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Packagings', 3, 1, '-7', '0', '0.0'),
- ('DavidCharlesHaller', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Freight', 4, 1, '1100', '0', '0.0'),
- ('HankPym', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Funeral Accessories', 5, 1, '848', '-187', '-22.1'),
- ('HankPym', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Miscellaneous Accessories', 6, 1, '186', '0', '0.0'),
- ('HankPym', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Adhesives', 7, 1, '277', '0', '0.0');
+ ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation', 1, 1, '1062', '51', '4.8'),
+ ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Colombia', 2, 1, '35074', '687', '2.0'),
+ ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Mini', 3, 1, '1777', '13', '0.7'),
+ ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Short', 4, 1, '3182', '59', '0.6'),
+ ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Crisantemo', 5, 1, '1747', '13', '0.7'),
+ ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Lilium Oriental', 6, 1, '7182', '59', '0.6'),
+ ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Alstroemeria', 7, 1, '1777', '13', '0.7'),
+ ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Cymbidium', 1, 1, '4181', '59', '0.6'),
+ ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Cymbidium', 2, 1, '7268', '59', '0.6'),
+ ('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Containers', 2, 1, '-74', '0', '0.0'),
+ ('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Packagings', 3, 1, '-7', '0', '0.0'),
+ ('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Freight', 4, 1, '1100', '0', '0.0'),
+ ('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Funeral Accessories', 5, 1, '848', '-187', '-22.1'),
+ ('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Miscellaneous Accessories', 6, 1, '186', '0', '0.0'),
+ ('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Adhesives', 7, 1, '277', '0', '0.0');
INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packageFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`,`producer`,`printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`)
VALUES
- (1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, NULL, 0, 1, 0, 1, DATE_ADD(CURDATE(), INTERVAL -2 MONTH)),
- (2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, NULL, 0, 1, 0, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)),
- (3, 3, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 0, NULL, 0.00, 99.6, 99.4, NULL, 0, 1, 0, 1, CURDATE()),
- (4, 2, 2, 5, 450, 3, 1, 1.000, 1.000, 0.000, 10, 10, 0, NULL, 0.00, 7.30, 7.00, NULL, 0, 1, 0, 2.5, CURDATE()),
- (5, 3, 3, 55, 500, 5, 1, 1.000, 1.000, 0.000, 1, 1, 0, NULL, 0.00, 78.3, 75.6, NULL, 0, 1, 0, 2.5, CURDATE()),
- (6, 4, 8, 50, 1000, 4, 1, 1.000, 1.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, NULL, 0, 1, 0, 2.5, CURDATE()),
- (7, 4, 9, 20, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 30.50, 29.00, NULL, 0, 1, 0, 2.5, CURDATE()),
- (8, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, NULL, 0, 1, 0, 2.5, CURDATE()),
- (9, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, NULL, 0, 1, 0, 4, CURDATE()),
- (10, 5, 1, 50, 10, 4, 1, 2.500, 2.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, NULL, 0, 1, 0, 4, CURDATE()),
- (11, 5, 4, 1.25, 10, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, NULL, 0, 1, 0, 4, CURDATE()),
- (12, 6, 4, 1.25, 0, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, NULL, 0, 1, 0, 4, CURDATE()),
- (13, 7, 1, 50, 0, 3, 1, 2.000, 2.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, NULL, 0, 1, 0, 4, CURDATE()),
- (14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 7.30, 7.00, NULL, 0, 1, 0, 4, CURDATE()),
- (15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, NULL, 0, 1, 0, 4, CURDATE());
+ (1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, NULL, 0, 1, 0, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)),
+ (2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, NULL, 0, 1, 0, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
+ (3, 3, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 0, NULL, 0.00, 99.6, 99.4, NULL, 0, 1, 0, 1, util.VN_CURDATE()),
+ (4, 2, 2, 5, 450, 3, 1, 1.000, 1.000, 0.000, 10, 10, 0, NULL, 0.00, 7.30, 7.00, NULL, 0, 1, 0, 2.5, util.VN_CURDATE()),
+ (5, 3, 3, 55, 500, 5, 1, 1.000, 1.000, 0.000, 1, 1, 0, NULL, 0.00, 78.3, 75.6, NULL, 0, 1, 0, 2.5, util.VN_CURDATE()),
+ (6, 4, 8, 50, 1000, 4, 1, 1.000, 1.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, NULL, 0, 1, 0, 2.5, util.VN_CURDATE()),
+ (7, 4, 9, 20, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 30.50, 29.00, NULL, 0, 1, 0, 2.5, util.VN_CURDATE()),
+ (8, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, NULL, 0, 1, 0, 2.5, util.VN_CURDATE()),
+ (9, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, NULL, 0, 1, 0, 4, util.VN_CURDATE()),
+ (10, 5, 1, 50, 10, 4, 1, 2.500, 2.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, NULL, 0, 1, 0, 4, util.VN_CURDATE()),
+ (11, 5, 4, 1.25, 10, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, NULL, 0, 1, 0, 4, util.VN_CURDATE()),
+ (12, 6, 4, 1.25, 0, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, NULL, 0, 1, 0, 4, util.VN_CURDATE()),
+ (13, 7, 1, 50, 0, 3, 1, 2.000, 2.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, NULL, 0, 1, 0, 4, util.VN_CURDATE()),
+ (14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 7.30, 7.00, NULL, 0, 1, 0, 4, util.VN_CURDATE()),
+ (15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, NULL, 0, 1, 0, 4, util.VN_CURDATE());
INSERT INTO `hedera`.`order`(`id`, `date_send`, `customer_id`, `delivery_method_id`, `agency_id`, `address_id`, `company_id`, `note`, `source_app`, `confirmed`,`total`, `date_make`, `first_row_stamp`, `confirm_date`)
VALUES
- (1, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 3, 1, 121, 442, NULL, 'TPV', 1,'155.89', DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH)),
- (2, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1104, 3, 1, 124, 442, NULL, 'WEB', 1,'100.10', DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH)),
- (3, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 1, 2, 124, 442, NULL, 'ANDROID', 1,'107.25', DATE_ADD(CURDATE(), INTERVAL -2 MONTH), DATE_ADD(CURDATE(), INTERVAL -2 MONTH), DATE_ADD(CURDATE(), INTERVAL -2 MONTH)),
- (4, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 1, 2, 124, 442, NULL, 'SALIX', 1,'10.01', DATE_ADD(CURDATE(), INTERVAL -3 MONTH), DATE_ADD(CURDATE(), INTERVAL -3 MONTH), DATE_ADD(CURDATE(), INTERVAL -3 MONTH)),
- (5, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 1, 3, 124, 442, NULL, 'SALIX', 1,'10.01', DATE_ADD(CURDATE(), INTERVAL -4 MONTH), DATE_ADD(CURDATE(), INTERVAL -4 MONTH), DATE_ADD(CURDATE(), INTERVAL -4 MONTH)),
- (6, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 1, 3, 1, 442, NULL, 'SALIX', 1,'10.01', DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH)),
- (7, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1101, 2, 7, 1, 442, NULL, 'SALIX', 0,'10.01', CURDATE(), CURDATE(), CURDATE()),
- (8, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1101, 2, 7, 121, 442, NULL, 'SALIX', 0,'123.53', CURDATE(), CURDATE(), CURDATE()),
- (9, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1104, 2, 7, 124, 442, NULL, 'SALIX', 0,'10.01', CURDATE(), CURDATE(), CURDATE()),
- (10, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1102, 3, 1, 2, 442, NULL, 'SALIX', 0,'10.01', CURDATE(), CURDATE(), CURDATE()),
- (11, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1102, 2, 7, 122, 442, NULL, 'SALIX', 0,'60.90', CURDATE(), CURDATE(), CURDATE()),
- (12, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1103, 3, 1, 3, 442, NULL, 'SALIX', 0,'72.60', CURDATE(), CURDATE(), CURDATE()),
- (13, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1103, 1, 2, 123, 442, NULL, 'SALIX', 0,'72.60', CURDATE(), CURDATE(), CURDATE()),
- (14, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1104, 1, 2, 4, 442, NULL, 'SALIX', 0,'72.60', CURDATE(), CURDATE(), CURDATE()),
- (15, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1105, 1, 3, 125, 442, NULL, 'SALIX', 0,'72.60', CURDATE(), CURDATE(), CURDATE()),
- (16, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1106, 2, 7, 126, 442, NULL, 'SALIX', 0,'155.89', CURDATE(), CURDATE(), CURDATE()),
- (17, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1107, 1, 4, 127, 442, NULL, 'SALIX', 0,'72.60', CURDATE(), CURDATE(), CURDATE()),
- (18, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1108, 1, 4, 128, 442, NULL, 'SALIX', 0,'72.60', CURDATE(), CURDATE(), CURDATE()),
- (19, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1109, 1, 5, 129, 442, NULL, 'SALIX', 0,'16.50', CURDATE(), CURDATE(), CURDATE()),
- (20, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 1, 5, 101, 442, NULL, 'SALIX', 0,'21.45', DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH)),
- (21, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 1, 5, 102, 442, NULL, 'SALIX', 0,'0.00', DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH)),
- (22, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 1, 5, 103, 442, NULL, 'SALIX', 0,'148.50', DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH));
+ (1, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 3, 1, 121, 442, NULL, 'TPV', 1,'155.89', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
+ (2, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1104, 3, 1, 124, 442, NULL, 'WEB', 1,'100.10', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
+ (3, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 1, 2, 124, 442, NULL, 'ANDROID', 1,'107.25', DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)),
+ (4, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 1, 2, 124, 442, NULL, 'SALIX', 1,'10.01', DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH)),
+ (5, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 1, 3, 124, 442, NULL, 'SALIX', 1,'10.01', DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH)),
+ (6, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 1, 3, 1, 442, NULL, 'SALIX', 1,'10.01', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
+ (7, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 2, 7, 1, 442, NULL, 'SALIX', 0,'10.01', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()),
+ (8, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 2, 7, 121, 442, NULL, 'SALIX', 0,'123.53', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()),
+ (9, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 2, 7, 124, 442, NULL, 'SALIX', 0,'10.01', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()),
+ (10, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 3, 1, 2, 442, NULL, 'SALIX', 0,'10.01', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()),
+ (11, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 2, 7, 122, 442, NULL, 'SALIX', 0,'60.90', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()),
+ (12, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 3, 1, 3, 442, NULL, 'SALIX', 0,'72.60', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()),
+ (13, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 1, 2, 123, 442, NULL, 'SALIX', 0,'72.60', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()),
+ (14, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 1, 2, 4, 442, NULL, 'SALIX', 0,'72.60', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()),
+ (15, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1105, 1, 3, 125, 442, NULL, 'SALIX', 0,'72.60', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()),
+ (16, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 2, 7, 126, 442, NULL, 'SALIX', 0,'155.89', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()),
+ (17, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1107, 1, 4, 127, 442, NULL, 'SALIX', 0,'72.60', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()),
+ (18, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1108, 1, 4, 128, 442, NULL, 'SALIX', 0,'72.60', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()),
+ (19, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1109, 1, 5, 129, 442, NULL, 'SALIX', 0,'16.50', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()),
+ (20, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 1, 5, 101, 442, NULL, 'SALIX', 0,'21.45', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)),
+ (21, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 1, 5, 102, 442, NULL, 'SALIX', 0,'0.00', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)),
+ (22, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 1, 5, 103, 442, NULL, 'SALIX', 0,'148.50', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH));
INSERT INTO `hedera`.`orderRow`(`id`, `orderFk`, `itemFk`, `warehouseFk`, `shipment`, `amount`, `price`, `rate`, `created`, `saleFk`)
VALUES
- (1, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 9.10, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1),
- (2, 1, 2, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 10, 1.07, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2),
- (3, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 9.10, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 3),
- (4, 1, 4, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 20, 3.06, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 4),
- (5, 2, 1, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 10, 9.10, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5),
- (6, 3, 1, 2, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), 15, 6.50, 0, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), 6),
- (7, 11, 2, 1, CURDATE(), 15, 1.30, 0, CURDATE(), 7),
- (8, 11, 4, 1, CURDATE(), 10, 3.26, 0, CURDATE(), 8),
- (9, 16, 1, 1, CURDATE(), 5, 9.10, 0, CURDATE(), 9),
- (10, 16, 2, 1, CURDATE(), 10, 1.07, 0, CURDATE(), 10),
- (11, 16, 1, 1, CURDATE(), 2, 9.10, 0, CURDATE(), 11),
- (12, 16, 4, 1, CURDATE(), 20, 3.06, 0, CURDATE(), 12),
- (13, 8, 2, 1, CURDATE(), 15, 1.30, 0, CURDATE(), 13),
- (14, 8, 1, 1, CURDATE(), 10, 9.28, 0, CURDATE(), 14),
- (15, 19, 1, 1, CURDATE(), 10, 1.50, 0, CURDATE(), 15),
- (16, 20, 2, 1, CURDATE(), 15, 1.30, 0, CURDATE(), 16),
- (17, 22, 2, 1, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 30, 2.30, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 17),
- (18, 22, 4, 1, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 20, 3.00, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 18),
- (19, 4, 1, 1, DATE_ADD(CURDATE(), INTERVAL -3 MONTH), 1, 9.10, 0, DATE_ADD(CURDATE(), INTERVAL -3 MONTH), 19),
- (20, 5, 1, 1, DATE_ADD(CURDATE(), INTERVAL -4 MONTH), 1, 9.10, 0, DATE_ADD(CURDATE(), INTERVAL -4 MONTH), 20),
- (21, 6, 1, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 9.10, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 21),
- (22, 7, 1, 1, CURDATE(), 1, 9.10, 0, CURDATE(), 22),
- (23, 9, 1, 1, CURDATE(), 1, 9.10, 0, CURDATE(), 23),
- (24, 10, 1, 1, CURDATE(), 1, 9.10, 0, CURDATE(), 24),
- (25, 12, 4, 1, CURDATE(), 20, 3.00, 0, CURDATE(), 25),
- (26, 13, 4, 1, CURDATE(), 20, 3.00, 0, CURDATE(), 26),
- (27, 14, 4, 1, CURDATE(), 20, 3.00, 0, CURDATE(), 27),
- (28, 15, 4, 1, CURDATE(), 20, 3.00, 0, CURDATE(), 28),
- (29, 17, 4, 1, CURDATE(), 20, 3.00, 0, CURDATE(), 29),
- (30, 18, 4, 1, CURDATE(), 20, 3.00, 0, CURDATE(), 30);
+ (1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 9.10, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1),
+ (2, 1, 2, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 10, 1.07, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2),
+ (3, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 9.10, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3),
+ (4, 1, 4, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 20, 3.06, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4),
+ (5, 2, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 10, 9.10, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5),
+ (6, 3, 1, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 15, 6.50, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 6),
+ (7, 11, 2, 1, util.VN_CURDATE(), 15, 1.30, 0, util.VN_CURDATE(), 7),
+ (8, 11, 4, 1, util.VN_CURDATE(), 10, 3.26, 0, util.VN_CURDATE(), 8),
+ (9, 16, 1, 1, util.VN_CURDATE(), 5, 9.10, 0, util.VN_CURDATE(), 9),
+ (10, 16, 2, 1, util.VN_CURDATE(), 10, 1.07, 0, util.VN_CURDATE(), 10),
+ (11, 16, 1, 1, util.VN_CURDATE(), 2, 9.10, 0, util.VN_CURDATE(), 11),
+ (12, 16, 4, 1, util.VN_CURDATE(), 20, 3.06, 0, util.VN_CURDATE(), 12),
+ (13, 8, 2, 1, util.VN_CURDATE(), 15, 1.30, 0, util.VN_CURDATE(), 13),
+ (14, 8, 1, 1, util.VN_CURDATE(), 10, 9.28, 0, util.VN_CURDATE(), 14),
+ (15, 19, 1, 1, util.VN_CURDATE(), 10, 1.50, 0, util.VN_CURDATE(), 15),
+ (16, 20, 2, 1, util.VN_CURDATE(), 15, 1.30, 0, util.VN_CURDATE(), 16),
+ (17, 22, 2, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 30, 2.30, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 17),
+ (18, 22, 4, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 20, 3.00, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 18),
+ (19, 4, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), 1, 9.10, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), 19),
+ (20, 5, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), 1, 9.10, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), 20),
+ (21, 6, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 9.10, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 21),
+ (22, 7, 1, 1, util.VN_CURDATE(), 1, 9.10, 0, util.VN_CURDATE(), 22),
+ (23, 9, 1, 1, util.VN_CURDATE(), 1, 9.10, 0, util.VN_CURDATE(), 23),
+ (24, 10, 1, 1, util.VN_CURDATE(), 1, 9.10, 0, util.VN_CURDATE(), 24),
+ (25, 12, 4, 1, util.VN_CURDATE(), 20, 3.00, 0, util.VN_CURDATE(), 25),
+ (26, 13, 4, 1, util.VN_CURDATE(), 20, 3.00, 0, util.VN_CURDATE(), 26),
+ (27, 14, 4, 1, util.VN_CURDATE(), 20, 3.00, 0, util.VN_CURDATE(), 27),
+ (28, 15, 4, 1, util.VN_CURDATE(), 20, 3.00, 0, util.VN_CURDATE(), 28),
+ (29, 17, 4, 1, util.VN_CURDATE(), 20, 3.00, 0, util.VN_CURDATE(), 29),
+ (30, 18, 4, 1, util.VN_CURDATE(), 20, 3.00, 0, util.VN_CURDATE(), 30);
INSERT INTO `hedera`.`orderRowComponent`(`rowFk`, `componentFk`, `price`)
VALUES
@@ -1661,43 +1649,43 @@ INSERT INTO `hedera`.`visitAgent`(`id`, `visitFk`)
INSERT INTO `hedera`.`visitAccess`(`id`, `agentFk`, `stamp`)
VALUES
- (1, 1, CURDATE()),
- (2, 2, CURDATE()),
- (3, 3, CURDATE()),
- (4, 4, CURDATE()),
- (5, 5, CURDATE()),
- (6, 6, CURDATE()),
- (7, 7, CURDATE()),
- (8, 8, CURDATE()),
- (9, 9, CURDATE()),
- (10, 10, CURDATE()),
- (11, 11, CURDATE());
+ (1, 1, util.VN_CURDATE()),
+ (2, 2, util.VN_CURDATE()),
+ (3, 3, util.VN_CURDATE()),
+ (4, 4, util.VN_CURDATE()),
+ (5, 5, util.VN_CURDATE()),
+ (6, 6, util.VN_CURDATE()),
+ (7, 7, util.VN_CURDATE()),
+ (8, 8, util.VN_CURDATE()),
+ (9, 9, util.VN_CURDATE()),
+ (10, 10, util.VN_CURDATE()),
+ (11, 11, util.VN_CURDATE());
INSERT INTO `hedera`.`visitUser`(`id`, `accessFk`, `userFk`, `stamp`)
VALUES
- (1, 1, 1101, CURDATE()),
- (2, 2, 1101, CURDATE()),
- (3, 3, 1101, CURDATE()),
- (4, 4, 1102, CURDATE()),
- (5, 5, 1102, CURDATE()),
- (6, 6, 1102, CURDATE()),
- (7, 7, 1103, CURDATE()),
- (8, 8, 1103, CURDATE()),
- (9, 9, 1103, CURDATE()),
- (10, 10, 1102, DATE_SUB(CURDATE(), INTERVAL 1 DAY)),
- (11, 11, 1103, DATE_SUB(CURDATE(), INTERVAL 1 DAY));
+ (1, 1, 1101, util.VN_CURDATE()),
+ (2, 2, 1101, util.VN_CURDATE()),
+ (3, 3, 1101, util.VN_CURDATE()),
+ (4, 4, 1102, util.VN_CURDATE()),
+ (5, 5, 1102, util.VN_CURDATE()),
+ (6, 6, 1102, util.VN_CURDATE()),
+ (7, 7, 1103, util.VN_CURDATE()),
+ (8, 8, 1103, util.VN_CURDATE()),
+ (9, 9, 1103, util.VN_CURDATE()),
+ (10, 10, 1102, DATE_SUB(util.VN_CURDATE(), INTERVAL 1 DAY)),
+ (11, 11, 1103, DATE_SUB(util.VN_CURDATE(), INTERVAL 1 DAY));
INSERT INTO `hedera`.`userSession`(`created`, `lastUpdate`, `ssid`, `data`, `userVisitFk`)
VALUES
- (CURDATE(), CURDATE(), '121', 'data', 1),
- (CURDATE(), CURDATE(), '122', 'data', 2),
- (CURDATE(), CURDATE(), '123', 'data', 3),
- (CURDATE(), CURDATE(), '124', 'data', 4),
- (CURDATE(), CURDATE(), '125', 'data', 5),
- (CURDATE(), CURDATE(), '126', 'data', 6),
- (CURDATE(), CURDATE(), '127', 'data', 7),
- (CURDATE(), CURDATE(), '128', 'data', 8),
- (CURDATE(), CURDATE(), '129', 'data', 9);
+ (util.VN_CURDATE(), util.VN_CURDATE(), '121', 'data', 1),
+ (util.VN_CURDATE(), util.VN_CURDATE(), '122', 'data', 2),
+ (util.VN_CURDATE(), util.VN_CURDATE(), '123', 'data', 3),
+ (util.VN_CURDATE(), util.VN_CURDATE(), '124', 'data', 4),
+ (util.VN_CURDATE(), util.VN_CURDATE(), '125', 'data', 5),
+ (util.VN_CURDATE(), util.VN_CURDATE(), '126', 'data', 6),
+ (util.VN_CURDATE(), util.VN_CURDATE(), '127', 'data', 7),
+ (util.VN_CURDATE(), util.VN_CURDATE(), '128', 'data', 8),
+ (util.VN_CURDATE(), util.VN_CURDATE(), '129', 'data', 9);
INSERT INTO `vn`.`clientContact`(`id`, `clientFk`, `name`, `phone`)
VALUES
@@ -1721,11 +1709,11 @@ call vn.manaSpellersRequery(18);
INSERT INTO `vn`.`clientSample`(`id`, `clientFk`, `typeFk`, `created`, `workerFk`, `userFk`, `companyFk`)
VALUES
- (1, 1101, 1, CURDATE(), 18, 18, 442),
- (2, 1101, 1, CURDATE(), 18, 18, 442),
- (3, 1101, 2, CURDATE(), 18, 18, 442),
- (4, 1102, 2, CURDATE(), 18, 18, 567),
- (5, 1102, 3, CURDATE(), 19, 19, 567);
+ (1, 1101, 1, util.VN_CURDATE(), 18, 18, 442),
+ (2, 1101, 1, util.VN_CURDATE(), 18, 18, 442),
+ (3, 1101, 2, util.VN_CURDATE(), 18, 18, 442),
+ (4, 1102, 2, util.VN_CURDATE(), 18, 18, 567),
+ (5, 1102, 3, util.VN_CURDATE(), 19, 19, 567);
INSERT INTO `vn`.`claimState`(`id`, `code`, `description`, `roleFk`, `priority`, `hasToNotify`)
VALUES
@@ -1737,12 +1725,19 @@ INSERT INTO `vn`.`claimState`(`id`, `code`, `description`, `roleFk`, `priority`,
( 6, 'mana', 'Mana', 1, 4, 0),
( 7, 'lack', 'Faltas', 1, 2, 0);
-INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `observation`, `clientFk`, `workerFk`, `responsibility`, `isChargedToMana`, `created`, `packages`)
+INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `clientFk`, `workerFk`, `responsibility`, `isChargedToMana`, `created`, `packages`)
VALUES
- (1, CURDATE(), 1, 'Cu nam labores lobortis definiebas, ei aliquyam salutatus persequeris quo, cum eu nemore fierent dissentiunt. Per vero dolor id, vide democritum scribentur eu vim, pri erroribus temporibus ex.', 1101, 18, 3, 0, CURDATE(), 0),
- (2, CURDATE(), 2, 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.', 1101, 18, 3, 0, CURDATE(), 1),
- (3, CURDATE(), 3, 'An vim commodo dolorem volutpat, cu expetendis voluptatum usu, et mutat consul adversarium his. His natum numquam legimus an, diam fabulas mei ut. Melius fabellas sadipscing vel id. Partem diceret mandamus mea ne, has te tempor nostrud. Aeque nostro eum no.', 1101, 18, 1, 1, CURDATE(), 5),
- (4, CURDATE(), 3, 'Wisi forensibus mnesarchum in cum. Per id impetus abhorreant, his no magna definiebas, inani rationibus in quo. Ut vidisse dolores est, ut quis nominavi mel. Ad pri quod apeirian concludaturque.', 1104, 18, 5, 0, CURDATE(), 10);
+ (1, util.VN_CURDATE(), 1, 1101, 18, 3, 0, util.VN_CURDATE(), 0),
+ (2, util.VN_CURDATE(), 2, 1101, 18, 3, 0, util.VN_CURDATE(), 1),
+ (3, util.VN_CURDATE(), 3, 1101, 18, 1, 1, util.VN_CURDATE(), 5),
+ (4, util.VN_CURDATE(), 3, 1104, 18, 5, 0, util.VN_CURDATE(), 10);
+
+INSERT INTO `vn`.`claimObservation` (`claimFk`, `workerFk`, `text`, `created`)
+ VALUES
+ (1, 18, 'Cu nam labores lobortis definiebas, ei aliquyam salutatus persequeris quo, cum eu nemore fierent dissentiunt. Per vero dolor id, vide democritum scribentur eu vim, pri erroribus temporibus ex.', util.VN_CURDATE()),
+ (2, 18, 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.', util.VN_CURDATE()),
+ (3, 18, 'An vim commodo dolorem volutpat, cu expetendis voluptatum usu, et mutat consul adversarium his. His natum numquam legimus an, diam fabulas mei ut. Melius fabellas sadipscing vel id. Partem diceret mandamus mea ne, has te tempor nostrud. Aeque nostro eum no.', util.VN_CURDATE()),
+ (4, 18, 'Wisi forensibus mnesarchum in cum. Per id impetus abhorreant, his no magna definiebas, inani rationibus in quo. Ut vidisse dolores est, ut quis nominavi mel. Ad pri quod apeirian concludaturque.', util.VN_CURDATE());
INSERT INTO `vn`.`claimBeginning`(`id`, `claimFk`, `saleFk`, `quantity`)
VALUES
@@ -1779,12 +1774,12 @@ INSERT INTO `hedera`.`tpvMerchant`(`id`, `description`, `companyFk`, `bankFk`, `
INSERT INTO `hedera`.`tpvTransaction`(`id`,`merchantFk`, `clientFk`,`receiptFk`, `amount`, `response`, `errorCode`, `status`, `created`)
VALUES
- (1, 1, 1101, NULL, 2000, NULL, 'SIS0042', 'ok', CURDATE()),
- (2, 1, 1101, NULL, 1000, NULL, 'SIS0051', 'started', CURDATE()),
- (3, 2, 1101, NULL, 7268, NULL, NULL, 'ok', CURDATE()),
- (4, 2, 1101, NULL, 4698, NULL, NULL, 'started', CURDATE()),
- (5, 1, 1104, NULL, 2000, NULL, 'SIS0043', 'ok', CURDATE()),
- (6, 2, 1104, NULL, 4000, NULL, 'SIS0044', 'started', CURDATE());
+ (1, 1, 1101, NULL, 2000, NULL, 'SIS0042', 'ok', util.VN_CURDATE()),
+ (2, 1, 1101, NULL, 1000, NULL, 'SIS0051', 'started', util.VN_CURDATE()),
+ (3, 2, 1101, NULL, 7268, NULL, NULL, 'ok', util.VN_CURDATE()),
+ (4, 2, 1101, NULL, 4698, NULL, NULL, 'started', util.VN_CURDATE()),
+ (5, 1, 1104, NULL, 2000, NULL, 'SIS0043', 'ok', util.VN_CURDATE()),
+ (6, 2, 1104, NULL, 4000, NULL, 'SIS0044', 'started', util.VN_CURDATE());
INSERT INTO `vn`.`orderTicket`(`orderFk`, `ticketFk`)
VALUES
@@ -1820,10 +1815,10 @@ INSERT INTO `vn`.`userConfig` (`userFk`, `warehouseFk`, `companyFk`)
INSERT INTO `vn`.`receipt`(`id`, `invoiceFk`, `amountPaid`, `payed`, `workerFk`, `bankFk`, `clientFk`, `created`, `companyFk`, `isConciliate`)
VALUES
- (1, 'Cobro web', 100.50, CURDATE(), 9, 1, 1101, CURDATE(), 442, 1),
- (2, 'Cobro web', 200.50, DATE_ADD(CURDATE(), INTERVAL -5 DAY), 9, 1, 1101, DATE_ADD(CURDATE(), INTERVAL -5 DAY), 442, 1),
- (3, 'Cobro en efectivo', 300.00, DATE_ADD(CURDATE(), INTERVAL -10 DAY), 9, 1, 1102, DATE_ADD(CURDATE(), INTERVAL -10 DAY), 442, 0),
- (4, 'Cobro en efectivo', 400.00, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 9, 1, 1103, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 442, 0);
+ (1, 'Cobro web', 100.50, util.VN_CURDATE(), 9, 1, 1101, util.VN_CURDATE(), 442, 1),
+ (2, 'Cobro web', 200.50, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 DAY), 9, 1, 1101, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 DAY), 442, 1),
+ (3, 'Cobro en efectivo', 300.00, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), 9, 1, 1102, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), 442, 0),
+ (4, 'Cobro en efectivo', 400.00, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY), 9, 1, 1103, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY), 442, 0);
INSERT INTO `vn`.`workerTeam`(`id`, `team`, `workerFk`)
VALUES
@@ -1837,11 +1832,11 @@ INSERT INTO `vn`.`workerTeam`(`id`, `team`, `workerFk`)
INSERT INTO `vn`.`ticketRequest`(`id`, `description`, `requesterFk`, `attenderFk`, `quantity`, `itemFk`, `price`, `isOk`, `saleFk`, `ticketFk`, `created`)
VALUES
- (1, 'Ranged weapon longbow 2m', 18, 35, 5, 1, 9.10, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY)),
- (2, 'Melee weapon combat first 15cm', 18, 35, 10, 2, 1.07, 0, NULL, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY)),
- (3, 'Melee weapon heavy shield 1x0.5m', 18, 35, 20, NULL, 3.06, NULL, NULL, 23, CURDATE()),
- (4, 'Melee weapon combat first 15cm', 18, 35, 15, NULL, 1.30, NULL, NULL, 11, CURDATE()),
- (5, 'Melee weapon combat first 15cm', 18, 35, 15, 4, 1.30, 0, NULL, 18, CURDATE());
+ (1, 'Ranged weapon longbow 2m', 18, 35, 5, 1, 9.10, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY)),
+ (2, 'Melee weapon combat first 15cm', 18, 35, 10, 2, 1.07, 0, NULL, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY)),
+ (3, 'Melee weapon heavy shield 1x0.5m', 18, 35, 20, NULL, 3.06, NULL, NULL, 23, util.VN_CURDATE()),
+ (4, 'Melee weapon combat first 15cm', 18, 35, 15, NULL, 1.30, NULL, NULL, 11, util.VN_CURDATE()),
+ (5, 'Melee weapon combat first 15cm', 18, 35, 15, 4, 1.30, 0, NULL, 18, util.VN_CURDATE());
INSERT INTO `vn`.`ticketServiceType`(`id`, `name`, `expenceFk`)
VALUES
@@ -1880,7 +1875,7 @@ INSERT INTO `postgresql`.`profile`(`profile_id`, `person_id`, `profile_type_id`)
FROM `postgresql`.`person` `p`;
INSERT INTO `postgresql`.`business`(`business_id`, `client_id`, `provider_id`, `date_start`, `date_end`, `workerBusiness`, `reasonEndFk`)
- SELECT p.profile_id, p.profile_id, 1000, CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL +1 YEAR)), '-01-25'), CONCAT('E-46-',RPAD(CONCAT(p.profile_id,9),8,p.profile_id)), NULL
+ SELECT p.profile_id, p.profile_id, 1000, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL +1 YEAR)), '-01-25'), CONCAT('E-46-',RPAD(CONCAT(p.profile_id,9),8,p.profile_id)), NULL
FROM `postgresql`.`profile` `p`;
INSERT INTO `postgresql`.`business_labour`(`business_id`, `notes`, `department_id`, `professional_category_id`, `incentivo`, `calendar_labour_type_id`, `porhoras`, `labour_agreement_id`, `workcenter_id`)
@@ -1888,10 +1883,14 @@ INSERT INTO `postgresql`.`business_labour`(`business_id`, `notes`, `department_i
FROM `postgresql`.`business` `b`;
INSERT INTO `postgresql`.`business` (`client_id`, `provider_id`, `date_start`, `date_end`, `workerBusiness`, `reasonEndFk`)
- SELECT p.profile_id, 1000, CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -2 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-12-24'), CONCAT('E-46-',RPAD(CONCAT(p.profile_id,9),8,p.profile_id)), NULL
+ SELECT p.profile_id, 1000, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -2 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-12-24'), CONCAT('E-46-',RPAD(CONCAT(p.profile_id,9),8,p.profile_id)), NULL
FROM `postgresql`.`profile` `p`
WHERE `p`.`profile_id` = 1109;
+UPDATE `postgresql`.`business`
+ SET `payedHolidays`= 8
+ WHERE `business_id`= 1106;
+
INSERT INTO `postgresql`.`business_labour` (`business_id`, `notes`, `department_id`, `professional_category_id`, `incentivo`, `calendar_labour_type_id`, `porhoras`, `labour_agreement_id`, `workcenter_id`)
VALUES
(1111, NULL, 23, 1, 0.0, 1, 1, 1, 1);
@@ -1917,19 +1916,14 @@ INSERT INTO `postgresql`.`profile_media`(`profile_media_id`, `profile_id`, `medi
(1, 1106, 1),
(2, 1107, 2);
-INSERT INTO `vn`.`workCenter` (`id`, `name`, `warehouseFk`)
- VALUES
- ('1', 'Silla', '1'),
- ('5', 'Madrid', '5');
-
INSERT INTO `vn`.`workCenterHoliday` (`workCenterFk`, `days`, `year`)
VALUES
- ('1', '27.5', YEAR(CURDATE())),
- ('5', '22', YEAR(CURDATE())),
- ('1', '24.5', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR))),
- ('5', '23', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)));
+ ('1', '27.5', YEAR(util.VN_CURDATE())),
+ ('5', '22', YEAR(util.VN_CURDATE())),
+ ('1', '24.5', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR))),
+ ('5', '23', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)));
-INSERT INTO `postgresql`.`calendar_state` (`calendar_state_id`, `type`, `rgb`, `code`, `holidayEntitlementRate`, `discountRate`)
+INSERT INTO `vn`.`absenceType` (`id`, `name`, `rgb`, `code`, `holidayEntitlementRate`, `discountRate`)
VALUES
(1, 'Holidays', '#FF4444', 'holiday', 0, 0),
(2, 'Leave of absence', '#C71585', 'absence', 0, 1),
@@ -1955,21 +1949,22 @@ INSERT INTO `postgresql`.`business_labour_payroll` (`business_id`, `cod_tarifa`,
INSERT INTO `postgresql`.`calendar_employee` (`business_id`, `calendar_state_id`, `date`)
VALUES
- (1, 6, IF(MONTH(CURDATE()) = 12 AND DAY(CURDATE()) > 10, DATE_ADD(CURDATE(), INTERVAL -10 DAY), DATE_ADD(CURDATE(), INTERVAL 10 DAY))),
- (1106, 1, IF(MONTH(CURDATE()) = 12 AND DAY(CURDATE()) > 10, DATE_ADD(CURDATE(), INTERVAL -10 DAY), DATE_ADD(CURDATE(), INTERVAL 10 DAY))),
- (1106, 1, IF(MONTH(CURDATE()) = 12 AND DAY(CURDATE()) > 10, DATE_ADD(CURDATE(), INTERVAL -11 DAY), DATE_ADD(CURDATE(), INTERVAL 11 DAY))),
- (1106, 1, IF(MONTH(CURDATE()) = 12 AND DAY(CURDATE()) > 10, DATE_ADD(CURDATE(), INTERVAL -12 DAY), DATE_ADD(CURDATE(), INTERVAL 12 DAY))),
- (1106, 1, IF(MONTH(CURDATE()) = 12 AND DAY(CURDATE()) > 10, DATE_ADD(CURDATE(), INTERVAL -20 DAY), DATE_ADD(CURDATE(), INTERVAL 20 DAY))),
- (1106, 2, IF(MONTH(CURDATE()) >= 1 AND DAY(CURDATE()) > 20, DATE_ADD(CURDATE(), INTERVAL -13 DAY), DATE_ADD(CURDATE(), INTERVAL 8 DAY))),
- (1106, 1, IF(MONTH(CURDATE()) >= 1 AND DAY(CURDATE()) > 20, DATE_ADD(CURDATE(), INTERVAL -14 DAY), DATE_ADD(CURDATE(), INTERVAL 9 DAY))),
- (1106, 2, IF(MONTH(CURDATE()) >= 1 AND DAY(CURDATE()) > 20, DATE_ADD(CURDATE(), INTERVAL -15 DAY), DATE_ADD(CURDATE(), INTERVAL 7 DAY))),
- (1107, 1, IF(MONTH(CURDATE()) = 12 AND DAY(CURDATE()) > 10, DATE_ADD(CURDATE(), INTERVAL -10 DAY), DATE_ADD(CURDATE(), INTERVAL 10 DAY))),
- (1107, 1, IF(MONTH(CURDATE()) = 12 AND DAY(CURDATE()) > 10, DATE_ADD(CURDATE(), INTERVAL -11 DAY), DATE_ADD(CURDATE(), INTERVAL 11 DAY))),
- (1107, 1, IF(MONTH(CURDATE()) = 12 AND DAY(CURDATE()) > 10, DATE_ADD(CURDATE(), INTERVAL -12 DAY), DATE_ADD(CURDATE(), INTERVAL 12 DAY))),
- (1107, 1, IF(MONTH(CURDATE()) = 12 AND DAY(CURDATE()) > 10, DATE_ADD(CURDATE(), INTERVAL -20 DAY), DATE_ADD(CURDATE(), INTERVAL 20 DAY))),
- (1107, 2, IF(MONTH(CURDATE()) >= 1 AND DAY(CURDATE()) > 20, DATE_ADD(CURDATE(), INTERVAL -13 DAY), DATE_ADD(CURDATE(), INTERVAL 8 DAY))),
- (1107, 1, IF(MONTH(CURDATE()) >= 1 AND DAY(CURDATE()) > 20, DATE_ADD(CURDATE(), INTERVAL -14 DAY), DATE_ADD(CURDATE(), INTERVAL 9 DAY))),
- (1107, 2, IF(MONTH(CURDATE()) >= 1 AND DAY(CURDATE()) > 20, DATE_ADD(CURDATE(), INTERVAL -15 DAY), DATE_ADD(CURDATE(), INTERVAL 7 DAY)));
+ (1, 6, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 10 DAY))),
+ (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 10 DAY))),
+ (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -11 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 11 DAY))),
+ (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -12 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 12 DAY))),
+ (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -20 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 20 DAY))),
+ (1106, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, DATE_ADD(util.VN_CURDATE(), INTERVAL -13 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 8 DAY))),
+ (1106, 1, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, DATE_ADD(util.VN_CURDATE(), INTERVAL -14 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 9 DAY))),
+ (1106, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 7 DAY))),
+ (1107, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 10 DAY))),
+ (1107, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -11 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 11 DAY))),
+ (1107, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -12 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 12 DAY))),
+ (1107, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -20 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 20 DAY))),
+ (1107, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, DATE_ADD(util.VN_CURDATE(), INTERVAL -13 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 8 DAY))),
+ (1107, 1, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, DATE_ADD(util.VN_CURDATE(), INTERVAL -14 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 9 DAY))),
+ (1107, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 7 DAY))),
+ (1107, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL - 16 DAY));
INSERT INTO `vn`.`smsConfig` (`id`, `uri`, `title`, `apiKey`)
VALUES
@@ -1977,12 +1972,12 @@ INSERT INTO `vn`.`smsConfig` (`id`, `uri`, `title`, `apiKey`)
INSERT INTO `vn`.`sharingClient`(`id`, `workerFk`, `started`, `ended`, `clientFk`)
VALUES
- (1, 19, DATE_ADD(CURDATE(), INTERVAL -5 DAY), DATE_ADD(CURDATE(), INTERVAL +15 DAY), 1101),
- (2, 18, DATE_ADD(CURDATE(), INTERVAL -5 DAY), DATE_ADD(CURDATE(), INTERVAL +15 DAY), 1106);
+ (1, 19, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY), 1101),
+ (2, 18, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY), 1106);
INSERT INTO `vn`.`sharingCart`(`id`, `workerFk`, `started`, `ended`, `workerSubstitute`, `created`)
VALUES
- (1, 18, DATE_ADD(CURDATE(), INTERVAL -5 DAY), DATE_ADD(CURDATE(), INTERVAL +15 DAY), 19, DATE_ADD(CURDATE(), INTERVAL -5 DAY));
+ (1, 18, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY), 19, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 DAY));
CALL `vn`.zoneGeo_calcTree(); -- this is an auto calculate for table vn.zoneGeo, columns: path,lft,rgt,depth,sons
@@ -2024,223 +2019,227 @@ INSERT INTO `vn`.`zoneIncluded` (`zoneFk`, `geoFk`, `isIncluded`)
INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `dated`)
VALUES
- (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=2, 2, 9) - DAYOFWEEK(CURDATE())) DAY)),
- (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=3, 3, 10) - DAYOFWEEK(CURDATE())) DAY)),
- (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=4, 4, 11) - DAYOFWEEK(CURDATE())) DAY)),
- (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=5, 5, 12) - DAYOFWEEK(CURDATE())) DAY)),
- (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=6, 6, 13) - DAYOFWEEK(CURDATE())) DAY)),
- (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=2, 2, 9) - DAYOFWEEK(CURDATE())) DAY)),
- (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=3, 3, 10) - DAYOFWEEK(CURDATE())) DAY)),
- (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=4, 4, 11) - DAYOFWEEK(CURDATE())) DAY)),
- (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=5, 5, 12) - DAYOFWEEK(CURDATE())) DAY)),
- (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=6, 6, 13) - DAYOFWEEK(CURDATE())) DAY)),
- (3, 'day', CURDATE()),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +1 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +2 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +3 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +4 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +5 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +6 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +7 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +8 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +9 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +10 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +11 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +12 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +13 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +14 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +15 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +16 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +17 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +18 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +19 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +20 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +21 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +22 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +23 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +24 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +25 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +26 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +27 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +28 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +29 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +30 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +31 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +32 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +33 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +34 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +35 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +36 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +37 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +38 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +39 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +40 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +41 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +42 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +43 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +44 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +45 DAY)),
- (3, 'day', DATE_ADD(CURDATE(), INTERVAL +46 DAY)),
- (4, 'day', CURDATE()),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +1 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +2 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +3 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +4 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +5 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +6 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +7 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +8 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +9 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +10 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +11 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +12 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +13 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +14 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +15 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +16 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +17 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +18 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +19 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +20 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +21 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +22 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +23 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +24 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +25 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +26 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +27 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +28 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +29 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +30 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +31 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +32 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +33 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +34 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +35 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +36 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +37 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +38 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +39 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +40 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +41 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +42 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +43 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +44 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +45 DAY)),
- (4, 'day', DATE_ADD(CURDATE(), INTERVAL +46 DAY)),
- (5, 'day', CURDATE()),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +1 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +2 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +3 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +4 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +5 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +6 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +7 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +8 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +9 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +10 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +11 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +12 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +13 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +14 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +15 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +16 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +17 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +18 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +19 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +20 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +21 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +22 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +23 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +24 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +25 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +26 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +27 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +28 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +29 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +30 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +31 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +32 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +33 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +34 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +35 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +36 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +37 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +38 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +39 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +40 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +41 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +42 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +43 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +44 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +45 DAY)),
- (5, 'day', DATE_ADD(CURDATE(), INTERVAL +46 DAY)),
- (6, 'day', CURDATE()),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +1 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +2 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +3 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +4 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +5 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +6 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +7 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +8 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +9 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +10 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +11 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +12 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +13 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +14 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +15 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +16 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +17 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +18 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +19 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +20 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +21 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +22 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +23 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +24 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +25 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +26 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +27 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +28 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +29 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +30 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +31 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +32 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +33 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +34 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +35 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +36 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +37 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +38 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +39 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +40 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +41 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +42 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +43 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +44 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +45 DAY)),
- (6, 'day', DATE_ADD(CURDATE(), INTERVAL +46 DAY)),
- (7, 'day', CURDATE()),
- (7, 'day', DATE_ADD(CURDATE(), INTERVAL +1 DAY)),
- (7, 'day', DATE_ADD(CURDATE(), INTERVAL +2 DAY)),
- (7, 'day', DATE_ADD(CURDATE(), INTERVAL +3 DAY)),
- (7, 'day', DATE_ADD(CURDATE(), INTERVAL +4 DAY)),
- (7, 'day', DATE_ADD(CURDATE(), INTERVAL +5 DAY)),
- (7, 'day', DATE_ADD(CURDATE(), INTERVAL +6 DAY));
+ (1, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=2, 2, 9) - DAYOFWEEK(util.VN_CURDATE())) DAY)),
+ (1, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=3, 3, 10) - DAYOFWEEK(util.VN_CURDATE())) DAY)),
+ (1, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=4, 4, 11) - DAYOFWEEK(util.VN_CURDATE())) DAY)),
+ (1, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=5, 5, 12) - DAYOFWEEK(util.VN_CURDATE())) DAY)),
+ (1, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=6, 6, 13) - DAYOFWEEK(util.VN_CURDATE())) DAY)),
+ (2, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=2, 2, 9) - DAYOFWEEK(util.VN_CURDATE())) DAY)),
+ (2, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=3, 3, 10) - DAYOFWEEK(util.VN_CURDATE())) DAY)),
+ (2, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=4, 4, 11) - DAYOFWEEK(util.VN_CURDATE())) DAY)),
+ (2, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=5, 5, 12) - DAYOFWEEK(util.VN_CURDATE())) DAY)),
+ (2, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=6, 6, 13) - DAYOFWEEK(util.VN_CURDATE())) DAY)),
+ (3, 'day', util.VN_CURDATE()),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +3 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +4 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +6 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +7 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +8 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +9 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +10 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +11 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +12 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +13 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +14 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +16 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +17 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +18 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +19 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +20 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +21 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +22 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +23 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +24 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +25 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +26 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +27 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +28 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +29 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +30 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +31 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +32 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +33 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +34 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +35 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +36 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +37 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +38 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +39 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +40 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +41 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +42 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +43 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +44 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +45 DAY)),
+ (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +46 DAY)),
+ (4, 'day', util.VN_CURDATE()),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +3 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +4 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +6 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +7 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +8 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +9 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +10 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +11 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +12 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +13 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +14 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +16 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +17 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +18 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +19 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +20 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +21 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +22 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +23 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +24 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +25 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +26 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +27 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +28 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +29 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +30 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +31 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +32 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +33 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +34 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +35 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +36 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +37 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +38 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +39 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +40 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +41 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +42 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +43 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +44 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +45 DAY)),
+ (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +46 DAY)),
+ (5, 'day', util.VN_CURDATE()),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +3 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +4 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +6 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +7 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +8 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +9 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +10 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +11 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +12 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +13 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +14 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +16 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +17 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +18 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +19 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +20 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +21 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +22 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +23 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +24 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +25 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +26 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +27 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +28 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +29 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +30 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +31 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +32 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +33 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +34 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +35 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +36 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +37 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +38 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +39 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +40 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +41 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +42 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +43 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +44 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +45 DAY)),
+ (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +46 DAY)),
+ (6, 'day', util.VN_CURDATE()),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +3 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +4 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +6 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +7 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +8 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +9 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +10 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +11 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +12 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +13 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +14 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +16 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +17 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +18 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +19 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +20 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +21 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +22 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +23 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +24 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +25 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +26 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +27 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +28 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +29 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +30 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +31 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +32 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +33 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +34 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +35 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +36 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +37 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +38 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +39 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +40 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +41 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +42 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +43 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +44 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +45 DAY)),
+ (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +46 DAY)),
+ (7, 'day', util.VN_CURDATE()),
+ (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)),
+ (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY)),
+ (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +3 DAY)),
+ (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +4 DAY)),
+ (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY)),
+ (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +6 DAY));
INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `weekDays`)
VALUES
(8, 'indefinitely', 'mon,tue,wed,thu,fri,sat,sun'),
(10, 'indefinitely', 'mon,tue,wed,thu,fri,sat,sun');
+INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `started`, `ended`)
+ VALUES
+ (9, 'range', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 YEAR));
+
INSERT INTO `vn`.`workerTimeControl`(`userFk`, `timed`, `manual`, `direction`)
VALUES
- (1106, CONCAT(CURDATE(), ' 07:00'), TRUE, 'in'),
- (1106, CONCAT(CURDATE(), ' 10:00'), TRUE, 'middle'),
- (1106, CONCAT(CURDATE(), ' 10:10'), TRUE, 'middle'),
- (1106, CONCAT(CURDATE(), ' 15:00'), TRUE, 'out');
+ (1106, CONCAT(util.VN_CURDATE(), ' 07:00'), TRUE, 'in'),
+ (1106, CONCAT(util.VN_CURDATE(), ' 10:00'), TRUE, 'middle'),
+ (1106, CONCAT(util.VN_CURDATE(), ' 10:20'), TRUE, 'middle'),
+ (1106, CONCAT(util.VN_CURDATE(), ' 14:50'), TRUE, 'out');
INSERT INTO `vn`.`dmsType`(`id`, `name`, `path`, `readRoleFk`, `writeRoleFk`, `code`)
VALUES
@@ -2267,14 +2266,14 @@ INSERT INTO `vn`.`dmsType`(`id`, `name`, `path`, `readRoleFk`, `writeRoleFk`, `c
INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `contentType`, `workerFk`, `warehouseFk`, `companyFk`, `hardCopyNumber`, `hasFile`, `reference`, `description`, `created`)
VALUES
- (1, 14, '1.txt', 'text/plain', 5, 1, 442, NULL, FALSE, 'Ticket:11', 'Ticket:11 dms for the ticket', CURDATE()),
- (2, 5, '2.txt', 'text/plain', 5, 1, 442, 1, TRUE, 'Client:104', 'Client:104 dms for the client', CURDATE()),
- (3, 5, '3.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'Client: 104', 'Client:104 readme', CURDATE()),
- (4, 3, '4.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'Worker: 106', 'Worker:106 readme', CURDATE()),
- (5, 5, '5.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'travel: 1', 'dmsForThermograph', CURDATE()),
- (6, 5, '6.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'NotExists', 'DoesNotExists', CURDATE()),
- (7, 20, '7.jpg', 'image/jpeg', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', CURDATE()),
- (8, 20, '8.mp4', 'video/mp4', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', CURDATE());
+ (1, 14, '1.txt', 'text/plain', 5, 1, 442, NULL, FALSE, 'Ticket:11', 'Ticket:11 dms for the ticket', util.VN_CURDATE()),
+ (2, 5, '2.txt', 'text/plain', 5, 1, 442, 1, TRUE, 'Client:104', 'Client:104 dms for the client', util.VN_CURDATE()),
+ (3, 5, '3.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'Client: 104', 'Client:104 readme', util.VN_CURDATE()),
+ (4, 3, '4.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'Worker: 106', 'Worker:106 readme', util.VN_CURDATE()),
+ (5, 5, '5.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'travel: 1', 'dmsForThermograph', util.VN_CURDATE()),
+ (6, 5, '6.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'NotExists', 'DoesNotExists', util.VN_CURDATE()),
+ (7, 20, '7.jpg', 'image/jpeg', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE()),
+ (8, 20, '8.mp4', 'video/mp4', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE());
INSERT INTO `vn`.`claimDms`(`claimFk`, `dmsFk`)
VALUES
@@ -2321,12 +2320,12 @@ INSERT INTO `vn`.`thermograph`(`id`, `model`)
INSERT INTO `vn`.`travelThermograph`(`thermographFk`, `created`, `warehouseFk`, `travelFk`, `temperatureFk`, `result`, `dmsFk`)
VALUES
- ('TMM190901395', CURDATE(), 1, 1, 'WARM', 'Ok', NULL),
- ('TL.BBA85422', DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 2, 'COOL', 'Ok', NULL),
- ('TL.BBA85422', CURDATE(), 2, 1, 'COOL', 'can not read the temperature', NULL),
- ('TZ1905012010', CURDATE(), 1, 1, 'WARM', 'Temperature in range', 5),
- ('138350-0', DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 1, 'WARM', NULL, 5),
- ('138350-0', CURDATE(), 1, NULL, 'COOL', NULL, NULL);
+ ('TMM190901395', util.VN_CURDATE(), 1, 1, 'WARM', 'Ok', NULL),
+ ('TL.BBA85422', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 2, 'COOL', 'Ok', NULL),
+ ('TL.BBA85422', util.VN_CURDATE(), 2, 1, 'COOL', 'can not read the temperature', NULL),
+ ('TZ1905012010', util.VN_CURDATE(), 1, 1, 'WARM', 'Temperature in range', 5),
+ ('138350-0', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 'WARM', NULL, 5),
+ ('138350-0', util.VN_CURDATE(), 1, NULL, 'COOL', NULL, NULL);
REPLACE INTO `vn`.`incoterms`(`code`, `name`)
VALUES
@@ -2349,18 +2348,18 @@ INSERT INTO `vn`.`tabletDepartment`(`tabletFk`, `departmentFk`)
INSERT INTO `vn`.`campaign`(`code`, `dated`)
VALUES
- ('valentinesDay', CONCAT(YEAR(CURDATE()), '-02-14')),
- ('valentinesDay', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-02-14')),
- ('valentinesDay', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -2 YEAR)), '-02-14')),
- ('valentinesDay', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -3 YEAR)), '-02-14')),
- ('mothersDay', CONCAT(YEAR(CURDATE()), '-05-05')),
- ('mothersDay', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-05-05')),
- ('mothersDay', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -2 YEAR)), '-05-05')),
- ('mothersDay', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -3 YEAR)), '-05-05')),
- ('allSaints', CONCAT(YEAR(CURDATE()), '-11-01')),
- ('allSaints', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-11-01')),
- ('allSaints', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -2 YEAR)), '-11-01')),
- ('allSaints', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -3 YEAR)), '-11-01'));
+ ('valentinesDay', CONCAT(YEAR(util.VN_CURDATE()), '-02-14')),
+ ('valentinesDay', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-02-14')),
+ ('valentinesDay', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -2 YEAR)), '-02-14')),
+ ('valentinesDay', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -3 YEAR)), '-02-14')),
+ ('mothersDay', CONCAT(YEAR(util.VN_CURDATE()), '-05-05')),
+ ('mothersDay', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-05-05')),
+ ('mothersDay', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -2 YEAR)), '-05-05')),
+ ('mothersDay', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -3 YEAR)), '-05-05')),
+ ('allSaints', CONCAT(YEAR(util.VN_CURDATE()), '-11-01')),
+ ('allSaints', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-11-01')),
+ ('allSaints', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -2 YEAR)), '-11-01')),
+ ('allSaints', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -3 YEAR)), '-11-01'));
INSERT INTO `hedera`.`imageCollectionSize`(`id`, `collectionFk`,`width`, `height`)
VALUES
@@ -2372,61 +2371,61 @@ INSERT INTO `vn`.`rateConfig`(`rate0`, `rate1`, `rate2`, `rate3`)
INSERT INTO `vn`.`rate`(`dated`, `warehouseFk`, `rate0`, `rate1`, `rate2`, `rate3`)
VALUES
- (DATE_ADD(CURDATE(), INTERVAL -1 YEAR), 1, 10, 15, 20, 25),
- (CURDATE(), 1, 12, 17, 22, 27);
+ (DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR), 1, 10, 15, 20, 25),
+ (util.VN_CURDATE(), 1, 12, 17, 22, 27);
INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk, taxFk)
VALUES
- (1, '07546501420', 67, 671, CURDATE(), 1761, 1, 1),
- (2, '07546491421', 252, 2769, CURDATE(), 5231, 1, 1),
- (3, '07546500823', 102, 1495, CURDATE(), 3221, 1, 1),
- (4, '99610288821', 252, 2777, CURDATE(), 3641, 1, 1),
- (5, '07546500834', 229, 3292, CURDATE(), 6601, 2, 1),
- (6, '22101929561', 37, 458, CURDATE(), 441, 2, 1),
- (7, '07546491432', 258, 3034, CURDATE(), 6441, 2, 1),
- (8, '99610288644', 476, 4461, CURDATE(), 5751, 442, 1),
- (9, '99610289193', 302, 2972, CURDATE(), 3871, 442, 1),
- (10, '07546500856', 185, 2364, CURDATE(), 5321, 442, 1);
+ (1, '07546501420', 67, 671, util.VN_CURDATE(), 1761, 1, 1),
+ (2, '07546491421', 252, 2769, util.VN_CURDATE(), 5231, 1, 1),
+ (3, '07546500823', 102, 1495, util.VN_CURDATE(), 3221, 1, 1),
+ (4, '99610288821', 252, 2777, util.VN_CURDATE(), 3641, 1, 1),
+ (5, '07546500834', 229, 3292, util.VN_CURDATE(), 6601, 2, 1),
+ (6, '22101929561', 37, 458, util.VN_CURDATE(), 441, 2, 1),
+ (7, '07546491432', 258, 3034, util.VN_CURDATE(), 6441, 2, 1),
+ (8, '99610288644', 476, 4461, util.VN_CURDATE(), 5751, 442, 1),
+ (9, '99610289193', 302, 2972, util.VN_CURDATE(), 3871, 442, 1),
+ (10, '07546500856', 185, 2364, util.VN_CURDATE(), 5321, 442, 1);
INSERT INTO `vn`.`dua` (id, code, awbFk, issued, operated, booked, bookEntried, gestdocFk, customsValue, companyFk)
VALUES
- (1, '19ES0028013A481523', 1, CURDATE(), CURDATE(), CURDATE(), CURDATE(), 1, 11276.95, 442),
- (2, '21ES00280136115760', 2, CURDATE(), CURDATE(), CURDATE(), CURDATE(), 2, 1376.20, 442),
- (3, '19ES00280131956004', 3, CURDATE(), CURDATE(), CURDATE(), CURDATE(), 3, 14268.50, 442),
- (4, '19ES00280131955995', 4, CURDATE(), CURDATE(), CURDATE(), CURDATE(), 1, 8242.50, 442),
- (5, '19ES00280132022070', 5, CURDATE(), CURDATE(), CURDATE(), CURDATE(), 2, 10012.49, 442),
- (6, '19ES00280132032308', 6, CURDATE(), CURDATE(), CURDATE(), CURDATE(), 2, 19914.25, 442),
- (7, '19ES00280132025489', 7, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), CURDATE(), CURDATE(), CURDATE(), 2, 1934.06, 442),
- (8, '19ES00280132025490', 8, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), CURDATE(), CURDATE(), CURDATE(), 2, 3618.52, 442),
- (9, '19ES00280132025491', 9, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), CURDATE(), CURDATE(), CURDATE(), 2, 7126.23, 442),
- (10, '19ES00280132025492', 10, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), CURDATE(), CURDATE(), CURDATE(), 2, 4631.45, 442);
+ (1, '19ES0028013A481523', 1, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 1, 11276.95, 442),
+ (2, '21ES00280136115760', 2, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 1376.20, 442),
+ (3, '19ES00280131956004', 3, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 3, 14268.50, 442),
+ (4, '19ES00280131955995', 4, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 1, 8242.50, 442),
+ (5, '19ES00280132022070', 5, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 10012.49, 442),
+ (6, '19ES00280132032308', 6, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 19914.25, 442),
+ (7, '19ES00280132025489', 7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 1934.06, 442),
+ (8, '19ES00280132025490', 8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 3618.52, 442),
+ (9, '19ES00280132025491', 9, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 7126.23, 442),
+ (10, '19ES00280132025492', 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 4631.45, 442);
REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issued`, `created`, `supplierRef`, `isBooked`, `companyFk`, `docFk`)
VALUES
- (1, 1001, 'R', 1, CURDATE(), CURDATE(), 1234, 0, 442, 1),
- (2, 1002, 'R', 1, CURDATE(), CURDATE(), 1235, 1, 442, 1),
- (3, 1003, 'R', 1, CURDATE(), CURDATE(), 1236, 0, 442, 1),
- (4, 1004, 'R', 1, CURDATE(), CURDATE(), 1237, 0, 442, 1),
- (5, 1005, 'R', 1, CURDATE(), CURDATE(), 1238, 1, 442, 1),
- (6, 1006, 'R', 2, CURDATE(), CURDATE(), 1239, 0, 442, 1),
- (7, 1007, 'R', 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1240, 1, 442, 1),
- (8, 1008, 'R', 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1241, 1, 442, 1),
- (9, 1009, 'R', 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1242, 1, 442, 1),
- (10, 1010, 'R', 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1243, 1, 442, 1);
+ (1, 1001, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1234, 0, 442, 1),
+ (2, 1002, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1235, 1, 442, 1),
+ (3, 1003, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1236, 0, 442, 1),
+ (4, 1004, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1237, 0, 442, 1),
+ (5, 1005, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1238, 1, 442, 1),
+ (6, 1006, 'R', 2, util.VN_CURDATE(), util.VN_CURDATE(), 1239, 0, 442, 1),
+ (7, 1007, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1240, 1, 442, 1),
+ (8, 1008, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1241, 1, 442, 1),
+ (9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 1, 442, 1),
+ (10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 1, 442, 1);
INSERT INTO `vn`.`invoiceInDueDay`(`invoiceInFk`, `dueDated`, `bankFk`, `amount`)
VALUES
- (1, CURDATE(), 1, 336.99),
- (1, CURDATE(), 1, 15.25),
- (2, CURDATE(), 1, 168),
- (2, CURDATE(), 1, 55.17),
- (3, CURDATE(), 1, 87.95),
- (3, CURDATE(), 1, 7.65),
- (4, CURDATE(), 1, 373.27),
- (4, CURDATE(), 1, 73.36),
- (5, CURDATE(), 1, 64.23),
- (6, CURDATE(), 1, 32.95),
- (7, CURDATE(), 1, 58.64);
+ (1, util.VN_CURDATE(), 1, 336.99),
+ (1, util.VN_CURDATE(), 1, 15.25),
+ (2, util.VN_CURDATE(), 1, 168),
+ (2, util.VN_CURDATE(), 1, 55.17),
+ (3, util.VN_CURDATE(), 1, 87.95),
+ (3, util.VN_CURDATE(), 1, 7.65),
+ (4, util.VN_CURDATE(), 1, 373.27),
+ (4, util.VN_CURDATE(), 1, 73.36),
+ (5, util.VN_CURDATE(), 1, 64.23),
+ (6, util.VN_CURDATE(), 1, 32.95),
+ (7, util.VN_CURDATE(), 1, 58.64);
INSERT INTO `vn`.`duaInvoiceIn`(`id`, `duaFk`, `invoiceInFk`)
VALUES
@@ -2480,24 +2479,24 @@ INSERT INTO `vn`.`zoneAgencyMode`(`id`, `agencyModeFk`, `zoneFk`)
INSERT INTO `vn`.`expeditionTruck` (`id`, `ETD`, `description`)
VALUES
- (1, CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL +3 YEAR))), 'Best truck in fleet');
+ (1, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL +3 YEAR))), 'Best truck in fleet');
INSERT INTO `vn`.`expeditionPallet` (`id`, `truckFk`, `built`, `position`, `isPrint`)
VALUES
- (1, 1, CURDATE(), 1, 1);
+ (1, 1, util.VN_CURDATE(), 1, 1);
INSERT INTO `vn`.`expeditionScan` (`id`, `expeditionFk`, `scanned`, `palletFk`)
VALUES
- (1, 1, CURDATE(), 1),
- (2, 2, CURDATE(), 1),
- (3, 3, CURDATE(), 1),
- (4, 4, CURDATE(), 1),
- (5, 5, CURDATE(), 1),
- (6, 6, CURDATE(), 1),
- (7, 7, CURDATE(), 1),
- (8, 8, CURDATE(), 1),
- (9, 9, CURDATE(), 1),
- (10, 10, CURDATE(), 1);
+ (1, 1, util.VN_CURDATE(), 1),
+ (2, 2, util.VN_CURDATE(), 1),
+ (3, 3, util.VN_CURDATE(), 1),
+ (4, 4, util.VN_CURDATE(), 1),
+ (5, 5, util.VN_CURDATE(), 1),
+ (6, 6, util.VN_CURDATE(), 1),
+ (7, 7, util.VN_CURDATE(), 1),
+ (8, 8, util.VN_CURDATE(), 1),
+ (9, 9, util.VN_CURDATE(), 1),
+ (10, 10, util.VN_CURDATE(), 1);
CALL `cache`.`last_buy_refresh`(FALSE);
@@ -2506,11 +2505,11 @@ UPDATE `vn`.`item` SET `genericFk` = 9
INSERT INTO `bs`.`defaulter` (`clientFk`, `amount`, `created`, `defaulterSinced`)
VALUES
- (1101, 500, CURDATE(), CURDATE()),
- (1102, 500, CURDATE(), CURDATE()),
- (1103, 500, CURDATE(), CURDATE()),
- (1107, 500, CURDATE(), CURDATE()),
- (1109, 500, CURDATE(), CURDATE());
+ (1101, 500, util.VN_CURDATE(), util.VN_CURDATE()),
+ (1102, 500, util.VN_CURDATE(), util.VN_CURDATE()),
+ (1103, 500, util.VN_CURDATE(), util.VN_CURDATE()),
+ (1107, 500, util.VN_CURDATE(), util.VN_CURDATE()),
+ (1109, 500, util.VN_CURDATE(), util.VN_CURDATE());
UPDATE `vn`.`route`
SET `invoiceInFk`=1
@@ -2521,16 +2520,16 @@ UPDATE `vn`.`route`
WHERE `id`=2;
INSERT INTO `bs`.`salesPerson` (`workerFk`, `year`, `month`, `portfolioWeight`)
VALUES
- (18, YEAR(CURDATE()), MONTH(CURDATE()), 807.23),
- (19, YEAR(CURDATE()), MONTH(CURDATE()), 34.40);
+ (18, YEAR(util.VN_CURDATE()), MONTH(util.VN_CURDATE()), 807.23),
+ (19, YEAR(util.VN_CURDATE()), MONTH(util.VN_CURDATE()), 34.40);
INSERT INTO `bs`.`sale` (`saleFk`, `amount`, `dated`, `typeFk`, `clientFk`)
VALUES
- (1, 501.95, CURDATE(), 2, 1101),
- (2, 70.7, CURDATE(), 2, 1101),
- (3, 200.78, CURDATE(), 2, 1101),
- (4, 33.8, CURDATE(), 1, 1101),
- (30, 34.4, CURDATE(), 1, 1108);
+ (1, 501.95, util.VN_CURDATE(), 2, 1101),
+ (2, 70.7, util.VN_CURDATE(), 2, 1101),
+ (3, 200.78, util.VN_CURDATE(), 2, 1101),
+ (4, 33.8, util.VN_CURDATE(), 1, 1101),
+ (30, 34.4, util.VN_CURDATE(), 1, 1108);
INSERT INTO `vn`.`docuware` (`code`, `fileCabinetName`, `dialogName` , `find`)
VALUES
@@ -2550,7 +2549,7 @@ INSERT INTO `vn`.`calendarHolidaysType` (`id`, `name`, `hexColour`)
INSERT INTO `vn`.`calendarHolidays` (`id`, `calendarHolidaysTypeFk`, `dated`, `calendarHolidaysNameFk`, `workCenterFk`)
VALUES
- (1, 1, CONCAT(YEAR(CURDATE()), '-12-09'), 1, 1);
+ (1, 1, CONCAT(YEAR(util.VN_CURDATE()), '-12-09'), 1, 1);
INSERT INTO `vn`.`supplierAgencyTerm` (`agencyFk`, `supplierFk`, `minimumPackages`, `kmPrice`, `packagePrice`, `routePrice`, `minimumKm`, `minimumM3`, `m3Price`)
VALUES
@@ -2578,10 +2577,10 @@ INSERT INTO `vn`.`machine` (`plate`, `maker`, `model`, `warehouseFk`, `departmen
INSERT INTO `vn`.`machineWorker` (`workerFk`, `machineFk`, `inTimed`, `outTimed`)
VALUES
- (1106, 1, CURDATE(), CURDATE()),
- (1106, 1, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), DATE_ADD(CURDATE(), INTERVAL +1 DAY)),
- (1106, 2, CURDATE(), NULL),
- (1106, 2, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), DATE_ADD(CURDATE(), INTERVAL +1 DAY));
+ (1106, 1, util.VN_CURDATE(), util.VN_CURDATE()),
+ (1106, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)),
+ (1106, 2, util.VN_CURDATE(), NULL),
+ (1106, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY));
INSERT INTO `vn`.`mdbBranch` (`name`)
VALUES
@@ -2591,4 +2590,24 @@ INSERT INTO `vn`.`mdbBranch` (`name`)
INSERT INTO `vn`.`mdbVersion` (`app`, `branchFk`, `version`)
VALUES
('tpv', 'test', '1'),
- ('lab', 'master', '1');
\ No newline at end of file
+ ('lab', 'master', '1');
+
+INSERT INTO `vn`.`saleGroup` (`userFk`, `parkingFk`, `sectorFk`)
+ VALUES
+ (1, 1, 1);
+
+INSERT INTO `vn`.`saleGroupDetail` (`saleFk`, `saleGroupFk`)
+ VALUES
+ (31, 1);
+
+INSERT INTO `vn`.`sectorCollection` (`userFk`, `sectorFk`)
+ VALUES
+ (1, 1);
+
+INSERT INTO `vn`.`sectorCollectionSaleGroup` (`sectorCollectionFk`, `saleGroupFk`)
+ VALUES
+ (1, 1);
+
+INSERT INTO `vn`.`workerTimeControlConfig` (`id`, `dayBreak`, `dayBreakDriver`, `shortWeekBreak`, `longWeekBreak`, `weekScope`, `mailPass`, `mailHost`, `mailSuccessFolder`, `mailErrorFolder`, `mailUser`, `minHoursToBreak`, `breakHours`, `hoursCompleteWeek`, `startNightlyHours`, `endNightlyHours`, `maxTimePerDay`, `breakTime`, `timeToBreakTime`, `dayMaxTime`, `shortWeekDays`, `longWeekDays`)
+ VALUES
+ (1, 43200, 32400, 129600, 259200, 604800, '', '', 'Leidos.exito', 'Leidos.error', 'timeControl', 5.33, 0.33, 40, '22:00:00', '06:00:00', 57600, 1200, 18000, 57600, 6, 13);
\ No newline at end of file
diff --git a/db/dump/mockDate.sql b/db/dump/mockDate.sql
new file mode 100644
index 000000000..c63c2d76c
--- /dev/null
+++ b/db/dump/mockDate.sql
@@ -0,0 +1,43 @@
+CREATE SCHEMA IF NOT EXISTS `util`;
+USE `util`;
+
+DELIMITER ;;
+DROP FUNCTION IF EXISTS `util`.`mockedDate`;
+CREATE FUNCTION `util`.`mockedDate`()
+RETURNS DATETIME
+DETERMINISTIC
+BEGIN
+ RETURN NOW();
+ -- '2022-01-19 08:00:00'
+END ;;
+DELIMITER ;
+
+DELIMITER ;;
+DROP FUNCTION IF EXISTS `util`.`VN_CURDATE`;
+CREATE FUNCTION `util`.`VN_CURDATE`()
+RETURNS DATE
+DETERMINISTIC
+BEGIN
+ RETURN DATE(mockedDate());
+END ;;
+DELIMITER ;
+
+DELIMITER ;;
+DROP FUNCTION IF EXISTS `util`.`VN_CURTIME`;
+CREATE FUNCTION `util`.`VN_CURTIME`()
+RETURNS TIME
+DETERMINISTIC
+BEGIN
+ RETURN TIME(mockedDate());
+END ;;
+DELIMITER ;
+
+DELIMITER ;;
+DROP FUNCTION IF EXISTS `util`.`VN_NOW`;
+CREATE FUNCTION `util`.`VN_NOW`()
+RETURNS DATETIME
+DETERMINISTIC
+BEGIN
+ RETURN mockedDate();
+END ;;
+DELIMITER ;
\ No newline at end of file
diff --git a/db/dump/structure.sql b/db/dump/structure.sql
index 21ef7758c..bb58c1955 100644
--- a/db/dump/structure.sql
+++ b/db/dump/structure.sql
@@ -1,4 +1,4 @@
--- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64)
+-- MariaDB dump 10.19 Distrib 10.6.8-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: db.verdnatura.es Database: account
-- ------------------------------------------------------
@@ -23,6 +23,7 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `account` /*!40100 DEFAULT CHARACTER SE
USE `account`;
+
--
-- Table structure for table `account`
--
@@ -456,6 +457,7 @@ CREATE TABLE `user` (
`sync` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Deprecated',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
+ UNIQUE KEY `mail` (`email`),
KEY `role` (`role`),
KEY `email` (`email`),
KEY `nickname` (`nickname`),
@@ -528,7 +530,7 @@ BEGIN
IF !(NEW.`password` <=> OLD.`password`) THEN
SET NEW.bcryptPassword = NULL;
- SET NEW.lastPassChange = NOW();
+ SET NEW.lastPassChange = util.VN_NOW();
END IF;
END */;;
DELIMITER ;
@@ -566,7 +568,7 @@ BEGIN
'jgallego@verdnatura.es',
'Rol modificado',
CONCAT(
- myUserGetName(),
+ myUser_getName(),
' ha modificado el rol del usuario ',
NEW.`name`, ' de ', OLD.role, ' a ', NEW.role)
);
@@ -652,6 +654,8 @@ CREATE TABLE `userSync` (
--
-- Dumping routines for database 'account'
--
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP FUNCTION IF EXISTS `myUserGetId` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -659,8 +663,6 @@ CREATE TABLE `userSync` (
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `myUserGetId`() RETURNS int(11)
READS SQL DATA
@@ -676,6 +678,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `myUserGetName` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -683,8 +687,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `myUserGetName`() RETURNS varchar(30) CHARSET utf8
NO SQL
@@ -700,6 +702,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `myUserHasRole` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -707,8 +711,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `myUserHasRole`(vRoleName VARCHAR(255)) RETURNS tinyint(1)
DETERMINISTIC
@@ -723,6 +725,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `myUserHasRoleId` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -730,8 +734,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `myUserHasRoleId`(vRoleId INT) RETURNS tinyint(1)
DETERMINISTIC
@@ -746,6 +748,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `myUser_checkLogin` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -753,8 +757,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `myUser_checkLogin`() RETURNS tinyint(1)
READS SQL DATA
@@ -785,6 +787,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `myUser_getId` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -792,8 +796,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `myUser_getId`() RETURNS int(11)
READS SQL DATA
@@ -821,6 +823,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `myUser_getName` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -828,8 +832,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `myUser_getName`() RETURNS varchar(30) CHARSET utf8
NO SQL
@@ -856,6 +858,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `myUser_hasRole` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -863,8 +867,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `myUser_hasRole`(vRoleName VARCHAR(255)) RETURNS tinyint(1)
DETERMINISTIC
@@ -882,6 +884,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `myUser_hasRoleId` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -889,8 +893,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `myUser_hasRoleId`(vRoleId INT) RETURNS tinyint(1)
DETERMINISTIC
@@ -901,13 +903,15 @@ BEGIN
* @param vRoleName Role id to check
* @return %TRUE if it has role, %FALSE otherwise
*/
- RETURN user_hasRoleId(myUserGetName(), vRoleId);
+ RETURN user_hasRoleId(myUser_getName(), vRoleId);
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 FUNCTION IF EXISTS `passwordGenerate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -915,8 +919,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `passwordGenerate`() RETURNS text CHARSET utf8 COLLATE utf8_unicode_ci
READS SQL DATA
@@ -972,6 +974,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `toUnixDays` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -979,8 +983,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `toUnixDays`(vDate DATE) RETURNS int(11)
DETERMINISTIC
@@ -998,6 +1000,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `userGetId` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -1005,8 +1009,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `userGetId`() RETURNS int(11)
READS SQL DATA
@@ -1022,6 +1024,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `userGetName` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -1029,8 +1033,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `userGetName`() RETURNS varchar(30) CHARSET utf8
NO SQL
@@ -1046,6 +1048,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `userHasRole` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -1053,8 +1057,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `userHasRole`(vUserName VARCHAR(255), vRoleName VARCHAR(255)) RETURNS tinyint(1)
DETERMINISTIC
@@ -1069,6 +1071,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `userHasRoleId` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -1076,8 +1080,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `userHasRoleId`(vUser VARCHAR(255), vRoleId INT) RETURNS tinyint(1)
DETERMINISTIC
@@ -1092,6 +1094,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `user_getMysqlRole` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -1099,8 +1103,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `user_getMysqlRole`(vUserName VARCHAR(255)) RETURNS varchar(255) CHARSET utf8 COLLATE utf8_unicode_ci
DETERMINISTIC
@@ -1127,6 +1129,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `user_getNameFromId` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -1134,8 +1138,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `user_getNameFromId`(vSelf INT) RETURNS varchar(30) CHARSET utf8 COLLATE utf8_unicode_ci
DETERMINISTIC
@@ -1159,6 +1161,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `user_hasRole` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -1166,8 +1170,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `user_hasRole`(vUserName VARCHAR(255), vRoleName VARCHAR(255)) RETURNS tinyint(1)
DETERMINISTIC
@@ -1195,6 +1197,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `user_hasRoleId` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -1202,8 +1206,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `user_hasRoleId`(vUser VARCHAR(255), vRoleId INT) RETURNS tinyint(1)
DETERMINISTIC
@@ -1231,6 +1233,8 @@ DELIMITER ;
/*!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 `myUserLogout` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -1238,8 +1242,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myUserLogout`()
BEGIN
@@ -1253,6 +1255,8 @@ DELIMITER ;
/*!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 `myUser_changePassword` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -1260,8 +1264,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myUser_changePassword`(vOldPassword VARCHAR(255), vPassword VARCHAR(255))
BEGIN
@@ -1278,6 +1280,8 @@ DELIMITER ;
/*!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 `myUser_login` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -1285,8 +1289,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myUser_login`(vUserName VARCHAR(255), vPassword VARCHAR(255))
READS SQL DATA
@@ -1316,6 +1318,8 @@ DELIMITER ;
/*!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 `myUser_loginWithKey` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -1323,8 +1327,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myUser_loginWithKey`(vUserName VARCHAR(255), vKey VARCHAR(255))
READS SQL DATA
@@ -1350,6 +1352,8 @@ DELIMITER ;
/*!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 `myUser_loginWithName` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -1357,8 +1361,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myUser_loginWithName`(vUserName VARCHAR(255))
READS SQL DATA
@@ -1387,6 +1389,8 @@ DELIMITER ;
/*!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 `myUser_logout` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -1394,8 +1398,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myUser_logout`()
BEGIN
@@ -1411,6 +1413,8 @@ DELIMITER ;
/*!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 `myUser_restorePassword` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -1418,8 +1422,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myUser_restorePassword`(vVerificationToken VARCHAR(255), vPassword VARCHAR(255))
BEGIN
@@ -1436,6 +1438,8 @@ DELIMITER ;
/*!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 `role_checkName` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -1443,8 +1447,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `role_checkName`(vRoleName VARCHAR(255))
BEGIN
@@ -1465,6 +1467,8 @@ DELIMITER ;
/*!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 `role_getDescendents` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -1472,8 +1476,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `role_getDescendents`(vSelf INT)
BEGIN
@@ -1542,6 +1544,8 @@ DELIMITER ;
/*!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 `role_sync` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -1549,8 +1553,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `role_sync`()
BEGIN
@@ -1606,6 +1608,8 @@ DELIMITER ;
/*!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 `role_syncPrivileges` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -1613,8 +1617,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `role_syncPrivileges`()
BEGIN
@@ -2185,6 +2187,8 @@ DELIMITER ;
/*!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 `userLogin` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -2192,8 +2196,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `userLogin`(vUserName VARCHAR(255), vPassword VARCHAR(255))
READS SQL DATA
@@ -2208,6 +2210,8 @@ DELIMITER ;
/*!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 `userLoginWithKey` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -2215,8 +2219,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `userLoginWithKey`(vUserName VARCHAR(255), vKey VARCHAR(255))
READS SQL DATA
@@ -2231,6 +2233,8 @@ DELIMITER ;
/*!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 `userLoginWithName` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -2238,8 +2242,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `userLoginWithName`(vUserName VARCHAR(255))
READS SQL DATA
@@ -2254,6 +2256,8 @@ DELIMITER ;
/*!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 `userSetPassword` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -2261,8 +2265,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `userSetPassword`(vUserName VARCHAR(255), vPassword VARCHAR(255))
BEGIN
@@ -2281,6 +2283,8 @@ DELIMITER ;
/*!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 `user_changePassword` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -2288,8 +2292,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `user_changePassword`(vSelf INT, vOldPassword VARCHAR(255), vPassword VARCHAR(255))
BEGIN
@@ -2319,6 +2321,8 @@ DELIMITER ;
/*!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 `user_checkName` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -2326,8 +2330,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `user_checkName`(vUserName VARCHAR(255))
BEGIN
@@ -2347,6 +2349,8 @@ DELIMITER ;
/*!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 `user_checkPassword` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -2354,8 +2358,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `user_checkPassword`(vPassword VARCHAR(255))
BEGIN
@@ -2415,6 +2417,8 @@ DELIMITER ;
/*!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 `user_restorePassword` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -2422,8 +2426,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `user_restorePassword`(vSelf INT, vVerificationToken VARCHAR(255), vPassword VARCHAR(255))
BEGIN
@@ -2453,6 +2455,8 @@ DELIMITER ;
/*!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 `user_setPassword` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -2460,8 +2464,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `user_setPassword`(vSelf INT, vPassword VARCHAR(255))
BEGIN
@@ -2862,86 +2864,6 @@ CREATE TABLE `m3` (
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Temporary table structure for view `m3Silla__`
---
-
-DROP TABLE IF EXISTS `m3Silla__`;
-/*!50001 DROP VIEW IF EXISTS `m3Silla__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `m3Silla__` (
- `fecha` tinyint NOT NULL,
- `year` tinyint NOT NULL,
- `month` tinyint NOT NULL,
- `week` tinyint NOT NULL,
- `day` tinyint NOT NULL,
- `dayName` tinyint NOT NULL,
- `Volumen` tinyint NOT NULL,
- `Euros` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
---
--- Temporary table structure for view `manaCustomer`
---
-
-DROP TABLE IF EXISTS `manaCustomer`;
-/*!50001 DROP VIEW IF EXISTS `manaCustomer`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `manaCustomer` (
- `Id_Cliente` tinyint NOT NULL,
- `Mana` tinyint NOT NULL,
- `dated` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
---
--- Temporary table structure for view `manaSpellersExcluded`
---
-
-DROP TABLE IF EXISTS `manaSpellersExcluded`;
-/*!50001 DROP VIEW IF EXISTS `manaSpellersExcluded`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `manaSpellersExcluded` (
- `workerFk` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
---
--- Temporary table structure for view `mana_spellers`
---
-
-DROP TABLE IF EXISTS `mana_spellers`;
-/*!50001 DROP VIEW IF EXISTS `mana_spellers`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `mana_spellers` (
- `Id_Trabajador` tinyint NOT NULL,
- `size` tinyint NOT NULL,
- `used` tinyint NOT NULL,
- `prices_modifier_rate` tinyint NOT NULL,
- `prices_modifier_activated` tinyint NOT NULL,
- `minRate` tinyint NOT NULL,
- `maxRate` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
---
--- Temporary table structure for view `mana_spellers_excluded`
---
-
-DROP TABLE IF EXISTS `mana_spellers_excluded`;
-/*!50001 DROP VIEW IF EXISTS `mana_spellers_excluded`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `mana_spellers_excluded` (
- `Id_Trabajador` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Table structure for table `mermasCache__`
--
@@ -3204,24 +3126,35 @@ CREATE TABLE `salePersonEvolution__` (
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Temporary table structure for view `sale__`
+-- Table structure for table `salesByItemTypeDay`
--
-DROP TABLE IF EXISTS `sale__`;
-/*!50001 DROP VIEW IF EXISTS `sale__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `sale__` (
- `saleFk` tinyint NOT NULL,
- `amount` tinyint NOT NULL,
- `surcharge` tinyint NOT NULL,
- `dated` tinyint NOT NULL,
- `typeFk` tinyint NOT NULL,
- `clientFk` tinyint NOT NULL,
- `companyFk` tinyint NOT NULL,
- `margin` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
+DROP TABLE IF EXISTS `salesByItemTypeDay`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `salesByItemTypeDay` (
+ `itemTypeFk` smallint(5) unsigned NOT NULL,
+ `itemCategoryFk` int(10) unsigned NOT NULL,
+ `dated` date NOT NULL,
+ `netSale` int(11) NOT NULL DEFAULT '0',
+ `stems` int(11) NOT NULL DEFAULT '0',
+ `references` int(11) NOT NULL DEFAULT '0',
+ `trash` int(11) NOT NULL DEFAULT '0',
+ `faults` int(11) NOT NULL DEFAULT '0',
+ `claimed` decimal(10,2) NOT NULL DEFAULT '0.00',
+ `accepted` decimal(10,2) NOT NULL DEFAULT '0.00',
+ `sale` decimal(10,2) NOT NULL DEFAULT '0.00',
+ `buy` decimal(10,2) NOT NULL DEFAULT '0.00',
+ `saleComponent` decimal(10,2) NOT NULL DEFAULT '0.00',
+ `costComponent` decimal(10,2) NOT NULL DEFAULT '0.00',
+ `marginComponent` decimal(10,2) NOT NULL DEFAULT '0.00',
+ PRIMARY KEY (`itemTypeFk`,`dated`),
+ KEY `itemTypeSalesByweek_itemCategoryFk_idx` (`itemCategoryFk`),
+ KEY `itemTypeSalesByweek_period_idx` (`dated`),
+ CONSTRAINT `itemTypeSalesByweek_itemCategoryFk` FOREIGN KEY (`itemCategoryFk`) REFERENCES `vn`.`itemCategory` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `itemTypeSalesByweek_itemTypeFk` FOREIGN KEY (`itemTypeFk`) REFERENCES `vn`.`itemType` (`id`) ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Ventas diarias agrupadas por reino y familia';
+/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `salesByWeek`
@@ -3384,48 +3317,6 @@ CREATE TABLE `salesPersonEvolution` (
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Evolución Comerciales';
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Temporary table structure for view `salesPerson__`
---
-
-DROP TABLE IF EXISTS `salesPerson__`;
-/*!50001 DROP VIEW IF EXISTS `salesPerson__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `salesPerson__` (
- `workerFk` tinyint NOT NULL,
- `year` tinyint NOT NULL,
- `month` tinyint NOT NULL,
- `amount` tinyint NOT NULL,
- `commission` tinyint NOT NULL,
- `leasedCommission` tinyint NOT NULL,
- `cededCommission` tinyint NOT NULL,
- `newCommission` tinyint NOT NULL,
- `leasedReplacement` tinyint NOT NULL,
- `itemTypeBorrowed` tinyint NOT NULL,
- `portfolioWeight` tinyint NOT NULL,
- `updated` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
---
--- Temporary table structure for view `v_ventas__`
---
-
-DROP TABLE IF EXISTS `v_ventas__`;
-/*!50001 DROP VIEW IF EXISTS `v_ventas__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `v_ventas__` (
- `importe` tinyint NOT NULL,
- `recargo` tinyint NOT NULL,
- `year` tinyint NOT NULL,
- `month` tinyint NOT NULL,
- `week` tinyint NOT NULL,
- `day` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Temporary table structure for view `vendedores`
--
@@ -3551,20 +3442,6 @@ CREATE TABLE `workerLabourDataByMonth` (
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Temporary table structure for view `workerMana`
---
-
-DROP TABLE IF EXISTS `workerMana`;
-/*!50001 DROP VIEW IF EXISTS `workerMana`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `workerMana` (
- `workerFk` tinyint NOT NULL,
- `amount` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Table structure for table `workerProductivity`
--
@@ -3701,6 +3578,8 @@ DELIMITER ;
--
-- Dumping routines for database 'bs'
--
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP FUNCTION IF EXISTS `tramo` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -3708,8 +3587,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `tramo`(vDateTime DATETIME) RETURNS varchar(20) CHARSET utf8 COLLATE utf8_unicode_ci
NO SQL
@@ -3733,57 +3610,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `analisisComponentes__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `analisisComponentes__`()
-BEGIN
-
-DECLARE vDateStart DATE DEFAULT '2016-01-01';
-DECLARE vDateEnd DATE DEFAULT '2016-11-30';
-DECLARE vDate DATE;
-
-SET vDate = vDateStart;
-
-DELETE FROM bs.ventasComponentes;
-
-WHILE vDate <= vDateEnd DO
-
- INSERT INTO bs.ventasComponentes
- SELECT vDate as Fecha, mc.Id_Componente, cast(sum(m.Cantidad * mc.Valor) AS DECIMAL(10,2)) as Importe
- FROM vn2008.Movimientos_componentes mc
- JOIN vn2008.Movimientos m ON m.Id_Movimiento = mc.Id_Movimiento
- JOIN bs.ventas v ON v.Id_Movimiento = mc.Id_Movimiento
- WHERE v.fecha = vDate
- AND empresa_id IN (442,567)
- GROUP BY mc.Id_Componente;
-
- SET vDate = TIMESTAMPADD(DAY,1,vDate);
-
- IF DAY(vDate) MOD 28 = 0 THEN
-
- SELECT vDate;
-
- END IF;
-
-END WHILE;
-
- SELECT vDate;
-
-
-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 DROP PROCEDURE IF EXISTS `bancos_evolution_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -3791,8 +3619,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `bancos_evolution_add`(vStartingDate DATE)
BEGIN
@@ -3802,8 +3628,8 @@ BEGIN
* @param vStartingDate Fecha desde la cual se recalculan la tabla bs.bancos_evolution
*/
DECLARE vCurrentDate DATE;
- DECLARE vMaxDate DATE DEFAULT TIMESTAMPADD(MONTH, 7, CURDATE());
- IF IFNULL(vStartingDate,0) < TIMESTAMPADD(YEAR, -5, CURDATE()) THEN
+ DECLARE vMaxDate DATE DEFAULT TIMESTAMPADD(MONTH, 7, util.VN_CURDATE());
+ IF IFNULL(vStartingDate,0) < TIMESTAMPADD(YEAR, -5, util.VN_CURDATE()) THEN
CALL util.throw('invalid date');
END IF;
DELETE FROM bs.bancos_evolution WHERE Fecha >= vStartingDate;
@@ -3858,8 +3684,8 @@ BEGIN
SELECT t.dated, p.id_banco, - importe
FROM vn.time t
join vn2008.pago p ON p.fecha <= t.dated
- WHERE t.dated BETWEEN CURDATE() AND vMaxDate
- AND p.fecha BETWEEN CURDATE() AND vMaxDate
+ WHERE t.dated BETWEEN util.VN_CURDATE() AND vMaxDate
+ AND p.fecha BETWEEN util.VN_CURDATE() AND vMaxDate
AND NOT conciliado
ON DUPLICATE KEY UPDATE saldo = saldo + VALUES(saldo);
@@ -3868,8 +3694,8 @@ BEGIN
SELECT t.dated, r.Id_Banco, SUM(Entregado)
FROM vn.time t
JOIN vn2008.Recibos r ON r.Fechacobro <= t.dated
- WHERE r.Fechacobro > CURDATE() AND r.Fechacobro <= vMaxDate
- AND t.dated BETWEEN CURDATE() AND vMaxDate
+ WHERE r.Fechacobro > util.VN_CURDATE() AND r.Fechacobro <= vMaxDate
+ AND t.dated BETWEEN util.VN_CURDATE() AND vMaxDate
GROUP BY t.dated, r.Id_Banco
ON DUPLICATE KEY UPDATE saldo = saldo + VALUES(saldo);
@@ -3909,122 +3735,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `bancos_evolution_add__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `bancos_evolution_add__`()
-BEGIN
-/**
- * Inserta en la tabla bancos_evolution los saldos acumulados de cada banco
- */
- DECLARE vCurrentDate DATE;
- DECLARE vStartingDate DATE DEFAULT '2016-01-01';
- DECLARE vMaxDate DATE DEFAULT TIMESTAMPADD(MONTH, 7, CURDATE());
-
- DELETE FROM bs.bancos_evolution WHERE Fecha > vStartingDate;
-
- SET vCurrentDate = vStartingDate;
-
- WHILE vCurrentDate < vMaxDate DO
-
- REPLACE bs.bancos_evolution(Fecha ,Id_Banco, saldo)
-
- SELECT vCurrentDate
- , Id_Banco
- , sum(saldo)
-
- FROM
- (
- SELECT Id_Banco ,saldo
- FROM bs.bancos_evolution
- WHERE Fecha = TIMESTAMPADD(DAY,-1,vCurrentDate) -- los saldos acumulados del dia anterior
-
- UNION ALL
-
- SELECT c.Id_Banco, IFNULL(sum(Entrada),0) - ifnull(sum(Salida),0) as saldo
- FROM vn2008.Cajas c
- JOIN vn2008.Bancos b using(Id_Banco) -- saldos de las cajas
- WHERE cash IN (0,3)
- AND Cajafecha = vCurrentDate
- AND (Serie = 'MB' OR cash = 3)
- GROUP BY Id_Banco
-
- )sub
- GROUP BY Id_Banco;
-
- SET vCurrentDate = TIMESTAMPADD(DAY,1,vCurrentDate);
-
- END WHILE;
-
- -- Ahora actualizamos la quilla
- UPDATE bs.bancos_evolution be
- JOIN
- (
- SELECT bp.Id_Banco, - sum(bp.importe) as quilla, t.dated
- FROM vn.time t
- JOIN vn2008.Bancos_poliza bp ON t.dated between apertura AND IFNULL(cierre, t.dated)
- GROUP BY Id_Banco, t.dated
- ) sub ON be.Id_Banco = sub.Id_Banco AND sub.dated = be.Fecha
- SET be.quilla = sub.quilla;
-
- -- pagos futuros no concilidados
- INSERT INTO bs.bancos_evolution(Fecha, Id_Banco, saldo)
- SELECT t.dated, p.id_banco, - importe
- FROM vn.time t
- join vn2008.pago p ON p.fecha <= t.dated
- WHERE p.fecha >= CURDATE()
- AND NOT conciliado
- ON DUPLICATE KEY UPDATE saldo = saldo - VALUES(saldo);
-
- -- cobros futuros
- INSERT INTO bs.bancos_evolution(Fecha, Id_Banco, saldo)
- SELECT t.dated, r.Id_Banco, SUM(Entregado)
- FROM vn.time t
- JOIN vn2008.Recibos r ON r.Fechacobro <= t.dated
- WHERE r.Fechacobro > CURDATE()
- GROUP BY t.dated, r.Id_Banco
- ON DUPLICATE KEY UPDATE saldo = saldo + VALUES(saldo);
-
- -- saldos de la tabla prevision
- INSERT INTO bs.bancos_evolution(Fecha, Id_Banco, saldo)
- SELECT t.dated, sp.Id_Banco, SUM(Importe)
- FROM vn.time t
- JOIN vn2008.Saldos_Prevision sp ON sp.Fecha <= t.dated
- JOIN vn2008.Bancos b ON sp.Id_Banco = b.Id_Banco
- WHERE b.cash IN (0,3)
- GROUP BY t.dated, sp.Id_Banco
- ON DUPLICATE KEY UPDATE saldo = saldo + VALUES(saldo);
-
- -- Utilizamos el saldo_auxiliar para calcular lo dispuesto en las polizas
- UPDATE bs.bancos_evolution be
- SET saldo_aux = saldo;
-
- -- Deuda
- UPDATE bs.bancos_evolution be
- JOIN vn2008.Bancos using(Id_Banco)
- SET be.deuda = IF(cash = 3, be.saldo_aux, 0)
- , be.saldo = IF(cash = 3, 0, be.saldo_aux)
- WHERE Fecha >= vStartingDate;
-
- -- Liquidez
- update bs.bancos_evolution set liquidez = saldo - quilla + deuda WHERE Fecha >= vStartingDate;
-
- -- Disponibilidad
- update bs.bancos_evolution set `disponibilidad ajena` = - quilla + deuda WHERE Fecha >= vStartingDate;
-
-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 DROP PROCEDURE IF EXISTS `campaignComparative` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -4032,8 +3744,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `campaignComparative`(vDateFrom DATE, vDateTo DATE)
BEGIN
@@ -4080,6 +3790,8 @@ DELIMITER ;
/*!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 `carteras_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -4087,8 +3799,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `carteras_add`()
BEGIN
@@ -4096,15 +3806,15 @@ BEGIN
* Inserta en @bs.carteras.
*/
DELETE FROM bs.carteras
- WHERE Año >= YEAR(CURDATE()) - 1;
-
+ WHERE Año >= YEAR(util.VN_CURDATE()) - 1;
+
INSERT INTO bs.carteras(Año,Mes,CodigoTrabajador,Peso)
SELECT t.year AS Año, t.month AS Mes, w.code AS CodigoTrabajador, SUM(v.importe) AS Peso
FROM vn.time t
JOIN bs.ventas v on t.dated = v.fecha
JOIN vn.client c on c.id = v.Id_Cliente
JOIN vn.worker w ON w.id = c.salesPersonFk
- WHERE t.year >= YEAR(CURDATE()) - 1
+ WHERE t.year >= YEAR(util.VN_CURDATE()) - 1
GROUP BY w.code, t.year , t.month;
END ;;
DELIMITER ;
@@ -4112,6 +3822,8 @@ DELIMITER ;
/*!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 `clean` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -4119,18 +3831,19 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `clean`()
BEGIN
DECLARE vFourYearsAgo DATETIME;
DECLARE vOneYearAgo DATETIME;
DECLARE vTwoYearAgo DATETIME;
+ DECLARE vThreeYearAgo DATETIME;
- SET vOneYearAgo = TIMESTAMPADD(YEAR, -1,CURDATE());
- SET vTwoYearAgo = TIMESTAMPADD(YEAR, -2,CURDATE());
- SET vFourYearsAgo = TIMESTAMPADD(YEAR, -4,CURDATE());
+
+ SET vOneYearAgo = TIMESTAMPADD(YEAR, -1,util.VN_CURDATE());
+ SET vTwoYearAgo = TIMESTAMPADD(YEAR, -2,util.VN_CURDATE());
+ SET vThreeYearAgo = TIMESTAMPADD(YEAR, -3,util.VN_CURDATE());
+ SET vFourYearsAgo = TIMESTAMPADD(YEAR, -4,util.VN_CURDATE());
DELETE FROM bs.clientNewBorn
WHERE lastShipped < vOneYearAgo;
@@ -4149,12 +3862,17 @@ BEGIN
DELETE FROM bs.m3
WHERE fecha < vTwoYearAgo;
+
+ DELETE FROM salesByItemTypeDay
+ WHERE dated < vThreeYearAgo;
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 `clientDied_recalc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -4162,45 +3880,46 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `clientDied_recalc`()
BEGIN
- SET @primerAviso := TIMESTAMPADD(MONTH,-1,CURDATE());
- SET @segundoAviso := TIMESTAMPADD(MONTH,-2,CURDATE());
- SET @tercerAviso := TIMESTAMPADD(MONTH,-3,CURDATE());
+ SET @primerAviso := TIMESTAMPADD(MONTH,-1,util.VN_CURDATE());
+ SET @segundoAviso := TIMESTAMPADD(MONTH,-2,util.VN_CURDATE());
+ SET @tercerAviso := TIMESTAMPADD(MONTH,-3,util.VN_CURDATE());
TRUNCATE TABLE bs.clientDied;
-
+
INSERT INTO bs.clientDied
- SELECT c.id,
- c.name as clientName,
- maxIssued as lastInvoiced,
- w.code AS workerCode,
- b.code AS Boss,
+ SELECT c.id,
+ c.name clientName,
+ maxIssued lastInvoiced,
+ w.code workerCode,
+ b.code Boss,
CASE
- WHEN IFNULL(maxIssued,'2000-01-01') < @tercerAviso THEN 'Tercer Aviso'
- WHEN maxIssued < @segundoAviso THEN 'Segundo Aviso'
- WHEN maxIssued < @primerAviso THEN 'Primer Aviso'
+ WHEN IFNULL(maxIssued,'2000-01-01') < @tercerAviso THEN 'Tercer Aviso'
+ WHEN maxIssued < @segundoAviso THEN 'Segundo Aviso'
+ WHEN maxIssued < @primerAviso THEN 'Primer Aviso'
END as Aviso
FROM vn.client c
JOIN vn.worker w ON w.id = c.salesPersonFk
JOIN vn.worker b ON b.id = w.bossFk
- JOIN bs.mana_spellers ms ON ms.Id_Trabajador = c.salesPersonFk
+ JOIN vn.workerMana wm ON wm.workerFk = c.salesPersonFk
LEFT JOIN (SELECT clientFk, max(issued) as maxIssued FROM vn.invoiceOut GROUP BY clientFk) io ON io.clientFk = c.id
WHERE (maxIssued IS NULL OR maxIssued < @primerAviso)
AND c.created < @tercerAviso;
DELETE cd.* FROM bs.clientDied cd
JOIN vn.ticket t ON t.clientFk = cd.id
- WHERE t.refFk IS NULL AND t.shipped >=TIMESTAMPADD(MONTH,-1,CURDATE());
+ WHERE t.refFk IS NULL
+ AND t.shipped >=TIMESTAMPADD(MONTH,-1,util.VN_CURDATE());
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 `clientNewBorn_recalc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -4208,8 +3927,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `clientNewBorn_recalc`()
BLOCK1: BEGIN
@@ -4233,7 +3950,7 @@ BLOCK1: BEGIN
FROM vn.client c
JOIN vn.ticket t on t.clientFk = c.id
LEFT JOIN clientNewBorn cb on cb.clientFk = c.id
- WHERE t.shipped BETWEEN TIMESTAMPADD(YEAR, -1, CURDATE()) AND CURDATE() AND cb.isModified is null
+ WHERE t.shipped BETWEEN TIMESTAMPADD(YEAR, -1, util.VN_CURDATE()) AND util.VN_CURDATE() AND cb.isModified is null
GROUP BY c.id;
OPEN cur;
@@ -4252,7 +3969,7 @@ BLOCK1: BEGIN
DECLARE cur2 CURSOR FOR
SELECT shipped
FROM vn.ticket
- WHERE clientFk = vClientFk AND shipped <= CURDATE()
+ WHERE clientFk = vClientFk AND shipped <= util.VN_CURDATE()
ORDER BY shipped DESC;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone2 = TRUE;
@@ -4291,8 +4008,8 @@ BLOCK1: BEGIN
LEFT JOIN (SELECT DISTINCT t.clientFk
FROM vn.ticket t
JOIN vn.productionConfig pc
- WHERE t.shipped BETWEEN curdate() + INTERVAL -(`notBuyingMonths`) MONTH
- AND curdate() + INTERVAL -(`pc`.`rookieDays`) DAY) notRookie ON notRookie.clientFk = cnb.clientFk
+ WHERE t.shipped BETWEEN util.VN_CURDATE() + INTERVAL -(`notBuyingMonths`) MONTH
+ AND util.VN_CURDATE() + INTERVAL -(`pc`.`rookieDays`) DAY) notRookie ON notRookie.clientFk = cnb.clientFk
SET cnd.isRookie = ISNULL(notRookie.clientFk);
END BLOCK1 ;;
@@ -4301,6 +4018,8 @@ DELIMITER ;
/*!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 `comercialesCompleto` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -4308,8 +4027,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `comercialesCompleto`(IN vWorker INT, vDate DATE)
BEGIN
@@ -4426,131 +4143,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `comercialesCompleto__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `comercialesCompleto__`(IN vWorker INT, vDate DATE)
-BEGIN
- DECLARE vAYearAgoStarted DATE DEFAULT DATE_FORMAT(TIMESTAMPADD(YEAR, - 1, vDate), '%Y-%m-01');
- DECLARE vAYearAgoEnded DATE DEFAULT TIMESTAMPADD(YEAR, - 1, LAST_DAY(vDate));
-
- CALL vn.worker_GetHierarchy(vWorker);
-
- INSERT IGNORE INTO tmp.workerHierarchyList (workerFk)
- SELECT wd2.workerFk
- FROM vn.workerDepartment wd2
- WHERE wd2.workerFk = vWorker;
-
- -- Falta que en algunos casos solo tenga en cuenta los tipos afectados.
- SELECT
- c.Id_Cliente id_cliente,
- c.calidad,
- c.Cliente cliente,
- cr.recobro * 100 tarifa,
- c.Telefono telefono,
- c.movil,
- c.POBLACION poblacion,
- p.`name` provincia,
- vn2008.red(f.futur) futur,
- c.Credito credito,
- pm.`name` forma_pago,
- vn2008.red(c365 / 12) consumo_medio365,
- vn2008.red(c365) consumo365,
- vn2008.red(CmLy.peso) peso_mes_año_pasado,
- vn2008.red(CmLy.peso * 1.19) objetivo,
- tr.CodigoTrabajador,
- vn2008.red(mes_actual.consumo) consumoMes,
- vn2008.red(IFNULL(mes_actual.consumo, 0) - IFNULL(CmLy.peso * 1.19, 0)) como_lo_llevo,
- DATE(LastTicket) ultimo_ticket,
- dead.muerto,
- g.Greuge,
- cr.recobro
- FROM
- vn2008.Clientes c
- LEFT JOIN
- (SELECT g.Id_Cliente, CAST( SUM(Importe) as DECIMAL(12,2)) AS Greuge
- FROM vn2008.Greuges g
- JOIN vn.`client` c ON c.id = g.Id_Cliente
- LEFT JOIN vn.worker w ON c.salesPersonFk = w.id
- WHERE (c.salesPersonFk = vWorker OR w.bossFk = vWorker)
- GROUP BY Id_Cliente
- ) g ON g.Id_Cliente = c.Id_Cliente
- LEFT JOIN
- vn2008.province p ON p.province_id = c.province_id
- JOIN
- vn2008.pay_met pm ON pm.id = c.pay_met_id
- LEFT JOIN
- vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador
- LEFT JOIN
- bi.claims_ratio cr on cr.Id_Cliente = c.Id_Cliente
- LEFT JOIN
- (SELECT v.Id_Cliente, SUM(importe) c365 -- optimizat de 6s /5.3s/ 4.7s a 0.3/0.4/0.3
- FROM bs.ventas v
- JOIN vn2008.Clientes c ON c.Id_Cliente = v.Id_Cliente
- WHERE v.fecha BETWEEN TIMESTAMPADD(YEAR, - 1, vDate) AND vDate
- GROUP BY v.Id_Cliente) c365 ON c365.Id_Cliente = c.Id_Cliente
- LEFT JOIN
- (SELECT
- Id_Cliente, SUM(importe) consumo
- FROM
- bs.ventas v
- INNER JOIN vn2008.Clientes c USING (Id_Cliente)
- LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador
- WHERE
- (c.Id_Trabajador = vWorker OR tr.boss = vWorker)
- AND (v.fecha BETWEEN TIMESTAMPADD(DAY, - DAY(vDate) + 1, vDate) AND TIMESTAMPADD(DAY, - 1, vDate))
- GROUP BY Id_Cliente) mes_actual ON mes_actual.Id_Cliente = c.Id_Cliente
- LEFT JOIN
- (SELECT t.Id_Cliente, SUM(m.preu * m.Cantidad * (1 - m.Descuento / 100)) futur
- FROM vn2008.Tickets t
- JOIN vn2008.Clientes c ON c.Id_Cliente = t.Id_Cliente
- JOIN vn2008.Movimientos m ON m.Id_Ticket = t.Id_Ticket
- LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador
- WHERE
- (c.Id_Trabajador = vWorker OR tr.boss = vWorker)
- AND t.Fecha BETWEEN vDate AND util.dayEnd(LAST_DAY(vDate))
- GROUP BY Id_Cliente) f ON c.Id_Cliente = f.Id_Cliente
- LEFT JOIN
- (SELECT MAX(t.Fecha) LastTicket, c.Id_Cliente
- FROM vn2008.Tickets t
- JOIN vn2008.Clientes c ON c.Id_cliente = t.Id_Cliente
- LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador
- WHERE
- (c.Id_Trabajador = vWorker OR tr.boss = vWorker)
- GROUP BY t.Id_Cliente) LastTicket ON LastTicket.Id_Cliente = c.Id_Cliente
- LEFT JOIN
- (
- SELECT SUM(importe) peso, c.Id_Cliente
- FROM bs.ventas v
- JOIN vn2008.Clientes c ON c.Id_Cliente = v.Id_Cliente
- LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador
- WHERE fecha BETWEEN vAYearAgoStarted and vAYearAgoEnded
- AND (c.Id_Trabajador = vWorker OR tr.boss = vWorker)
- GROUP BY c.Id_Cliente) CmLy ON CmLy.Id_Cliente = c.Id_Cliente
- LEFT JOIN
- (SELECT c.Id_Cliente,
- IF(MAX(Fecha) < DATE_FORMAT(TIMESTAMPADD(MONTH, - 1, vDate), '%Y- %m-01'), TRUE, FALSE) muerto
- FROM vn2008.Facturas f
- JOIN vn2008.Clientes c ON c.Id_cliente = f.Id_Cliente
- LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador
- WHERE (c.Id_Trabajador = vWorker OR tr.boss = vWorker)
- GROUP BY Id_Cliente) dead ON dead.Id_Cliente = c.Id_Cliente
- JOIN tmp.workerHierarchyList s ON s.workerFk = c.Id_Trabajador;
-
- DROP TEMPORARY TABLE tmp.workerHierarchyList;
-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 DROP PROCEDURE IF EXISTS `compradores_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -4558,8 +4152,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `compradores_add`(IN vYear INT, IN vWeekFrom INT, IN vWeekTo INT)
BEGIN
@@ -4585,6 +4177,8 @@ DELIMITER ;
/*!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 `compradores_add_launcher` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -4592,8 +4186,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `compradores_add_launcher`()
BEGIN
@@ -4639,6 +4231,8 @@ DELIMITER ;
/*!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 `compradores_evolution_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -4646,8 +4240,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `compradores_evolution_add`()
BEGIN
@@ -4681,7 +4273,7 @@ SELECT TIMESTAMPADD(DAY,1,MAX(fecha)) INTO datFEC FROM bs.compradores_evolution;
END IF;
- WHILE datFEC < CURDATE() DO
+ WHILE datFEC < util.VN_CURDATE() DO
IF i mod 150 = 0 THEN
SELECT datFEC;
@@ -4728,6 +4320,8 @@ DELIMITER ;
/*!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 `fondo_evolution_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -4735,8 +4329,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `fondo_evolution_add`()
BEGIN
@@ -4749,7 +4341,7 @@ BEGIN
INTO datFEC
FROM bs.fondo_maniobra;
- WHILE datFEC < CURDATE() DO
+ WHILE datFEC < util.VN_CURDATE() DO
IF DAY(datFEC) MOD 28 = 0 THEN -- esto solo sirve para no aburrirse mientras esperamos...
SELECT datFEC;
@@ -4806,6 +4398,8 @@ DELIMITER ;
/*!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 `fruitsEvolution` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -4813,8 +4407,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `fruitsEvolution`()
BEGIN
@@ -4836,6 +4428,8 @@ DELIMITER ;
/*!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 `indicatorsUpdate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -4843,8 +4437,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `indicatorsUpdate`(vDated DATE)
BEGIN
@@ -4892,39 +4484,35 @@ BEGIN
UPDATE indicators
SET countEmployee =
( SELECT CAST(SUM(hours_week) / 40 AS DECIMAL (10 , 2 ))
- FROM
- postgresql.business AS b
- JOIN postgresql.profile p ON p.profile_id = b.provider_id
- JOIN postgresql.person pe ON pe.person_id = p.person_id
- LEFT JOIN
- postgresql.business_labour AS bl ON bl.business_id = b.business_id
- LEFT JOIN
- postgresql.calendar_labour_type AS cl ON cl.calendar_labour_type_id = bl.calendar_labour_type_id
- WHERE
- (vDated BETWEEN b.date_start AND b.date_end OR (b.date_end IS NULL AND b.date_start <= vDated))
- AND pe.name = 'VERDNATURA LEVANTE SL'
+ FROM postgresql.business b
+ JOIN postgresql.profile p ON p.profile_id = b.provider_id
+ JOIN postgresql.person pe ON pe.person_id = p.person_id
+ LEFT JOIN postgresql.business_labour bl ON bl.business_id = b.business_id
+ LEFT JOIN postgresql.calendar_labour_type cl ON cl.calendar_labour_type_id = bl.calendar_labour_type_id
+ WHERE (vDated BETWEEN b.date_start AND b.date_end OR (b.date_end IS NULL AND b.date_start <= vDated))
+ AND pe.name = 'VERDNATURA LEVANTE SL'
)
WHERE updated = vDated;
-- Maná medio acumulado por comercial
- UPDATE indicators
- SET averageMana =
- (SELECT avg(used)
- FROM bs.mana_spellers
+ UPDATE indicators
+ SET averageMana =
+ (SELECT AVG(amount)
+ FROM vn.workerMana
)
WHERE updated = vDated;
-
+
-- Número de clientes que han comprado en los últimos 30 dias
- UPDATE indicators
+ UPDATE indicators
SET lastMonthActiveClients =
(SELECT COUNT(DISTINCT t.clientFk)
FROM vn.ticket t
WHERE t.shipped BETWEEN oneMonthBefore AND vDated
)
- WHERE updated = vDated;
-
- -- Número de clientes que no han comprado en los últimos 30 dias, pero compraron en los 30 anteriores
- UPDATE indicators
+ WHERE updated = vDated;
+
+ -- Número de clientes que no han comprado en los últimos 30 dias, pero compraron en los 30 anteriores
+ UPDATE indicators
SET lastMonthLostClients =
(SELECT COUNT(lm.clientFk)
FROM
@@ -4942,7 +4530,7 @@ BEGIN
) lm ON lm.clientFk = cm.clientFk
WHERE cm.clientFk IS NULL
)
- WHERE updated = vDated;
+ WHERE updated = vDated;
-- Número de clientes que han comprado en los últimos 30 dias, pero no compraron en los 30 anteriores
UPDATE indicators
@@ -4963,17 +4551,17 @@ BEGIN
) lm ON lm.clientFk = cm.clientFk
WHERE lm.clientFk IS NULL
)
- WHERE updated = vDated;
-
- -- Porcentaje de autopedidos sobre los pedidos totales
- UPDATE indicators
- SET lastMonthWebBuyingRate =
- ( SELECT (SUM(source_app != '') - SUM(source_app = 'TPV')) / SUM(source_app != '')
- FROM hedera.`order`
- WHERE date_send BETWEEN oneMonthBefore AND vDated
+ WHERE updated = vDated;
+
+ -- Porcentaje de autopedidos sobre los pedidos totales
+ UPDATE indicators
+ SET lastMonthWebBuyingRate =
+ ( SELECT (SUM(source_app != '') - SUM(source_app = 'TPV')) / SUM(source_app != '')
+ FROM hedera.`order`
+ WHERE date_send BETWEEN oneMonthBefore AND vDated
)
- WHERE updated = vDated;
-
+ WHERE updated = vDated;
+
/*
-- Indicadores de producción
UPDATE indicators i
@@ -4996,22 +4584,22 @@ BEGIN
WHERE dated=vDated INTO vWeek;
TRUNCATE `bs`.`salesByWeek`;
-
- INSERT INTO `bs`.`salesByWeek` (week,year,sales)
+
+ INSERT INTO `bs`.`salesByWeek` (week,year,sales)
SELECT `t`.`week` AS `week`,`t`.`year` AS `year`, SUM(`v`.`importe` + `v`.`recargo`) AS `sales`
FROM `bs`.`ventas` `v`
LEFT JOIN `vn`.`time` `t` ON `t`.`dated` = fecha
GROUP BY `t`.`week` , `t`.`year`
ORDER BY `t`.`week` , `t`.`year`;
-
- -- CAP Indicador Ventas semana actual
- UPDATE indicators i
+
+ -- CAP Indicador Ventas semana actual
+ UPDATE indicators i
JOIN `bs`.`salesByWeek` s ON s.week= vWeek AND s.year = YEAR(vDated)
SET i.thisWeekSales = s.sales
- WHERE updated = vDated;
-
- -- CAP indicador ventas semana actual en el año pasado
- UPDATE indicators i
+ WHERE updated = vDated;
+
+ -- CAP indicador ventas semana actual en el año pasado
+ UPDATE indicators i
JOIN `bs`.`salesByWeek` s ON s.week= vWeek AND s.year = YEAR(vDated)-1
SET i.lastYearWeekSales = s.sales
WHERE updated = vDated;
@@ -5022,6 +4610,8 @@ DELIMITER ;
/*!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 `indicatorsUpdateLauncher` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -5029,8 +4619,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `indicatorsUpdateLauncher`()
BEGIN
@@ -5041,7 +4629,7 @@ BEGIN
INTO vDated
FROM bs.indicators;
- WHILE vDated < CURDATE() DO
+ WHILE vDated < util.VN_CURDATE() DO
CALL indicatorsUpdate(vDated);
@@ -5057,6 +4645,8 @@ DELIMITER ;
/*!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 `inspeccionSS_2021_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -5064,8 +4654,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `inspeccionSS_2021_add`()
BEGIN
@@ -5111,6 +4699,8 @@ DELIMITER ;
/*!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 `m3Add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -5118,8 +4708,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `m3Add`()
BEGIN
@@ -5130,7 +4718,7 @@ BEGIN
SELECT TIMESTAMPADD(WEEK, -1,MAX(fecha)) INTO datSTART
FROM bs.m3;
- SET datEND = TIMESTAMPADD(DAY,-1,CURDATE());
+ SET datEND = TIMESTAMPADD(DAY,-1,util.VN_CURDATE());
DELETE FROM bs.m3
WHERE fecha >= datSTART;
@@ -5156,6 +4744,8 @@ DELIMITER ;
/*!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 `manaCustomerUpdate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -5163,8 +4753,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `manaCustomerUpdate`()
BEGIN
@@ -5204,7 +4792,7 @@ BEGIN
INTO vFromDated
FROM vn.clientManaCache;
- WHILE timestampadd(DAY,30,vFromDated) < CURDATE() DO
+ WHILE timestampadd(DAY,30,vFromDated) < util.VN_CURDATE() DO
SELECT
timestampadd(DAY,30,vFromDated),
@@ -5262,6 +4850,8 @@ DELIMITER ;
/*!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 `manaSpellers_actualize` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -5269,27 +4859,21 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `manaSpellers_actualize`()
BEGIN
+/**
+ * Recalcula el valor del campo con el modificador de precio para el componente de maná automático.
+ */
- /* PAK 2019/08/09 updated
- *
- * Recalcula el valor del campo con el modificador de precio para el componente de maná automático.
- * La tabla mana_spellers es una caché
- *
- */
-
- UPDATE mana_spellers me
+ UPDATE vn.workerMana wm
JOIN
- (SELECT Id_Trabajador, FLOOR(SUM(importe)/12) as pesoCarteraMensual
+ (SELECT Id_Trabajador workerFk, FLOOR(SUM(importe)/12) pesoCarteraMensual
FROM bs.vendedores
- WHERE año * 100 + mes >= (YEAR(CURDATE()) -1) * 100 + MONTH(CURDATE())
- GROUP BY Id_Trabajador
- ) lastYearSales USING(Id_Trabajador)
- SET me.prices_modifier_rate = GREATEST(me.minRate,LEAST(me.maxRate,ROUND(- me.used/lastYearSales.pesoCarteraMensual,3))) ;
+ WHERE año * 100 + mes >= (YEAR(util.VN_CURDATE()) -1) * 100 + MONTH(util.VN_CURDATE())
+ GROUP BY workerFk
+ ) lastYearSales USING(workerFk)
+ SET pricesModifierRate = GREATEST(minRate, LEAST(maxRate, ROUND(- amount/lastYearSales.pesoCarteraMensual,3)));
END ;;
DELIMITER ;
@@ -5297,43 +4881,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `mermasCacheUpdate__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `mermasCacheUpdate__`()
-BEGIN
-
- DECLARE vTimeRange INT DEFAULT 30;
- DECLARE vCurYearStarted DATE DEFAULT TIMESTAMPADD(DAY, - vTimeRange, CURDATE());
- DECLARE vCurYearFinished DATE DEFAULT CURDATE();
- DECLARE vLastYearStarted DATE DEFAULT TIMESTAMPADD(YEAR, -1 , vCurYearStarted);
- DECLARE vLastYearFinished DATE DEFAULT TIMESTAMPADD(YEAR, -1 , vCurYearFinished);
-
- REPLACE bs.mermasCache
- SELECT Comprador,
- IF(Fecha < vCurYearStarted, year(CURDATE()) - 1,year(CURDATE())) año,
- CAST(sum(Importe) as DECIMAL(10,0)) as Valor_Compra,
- CAST(sum(IF(Cliente LIKE 'FALTAS',Importe,0)) as DECIMAL(10,0)) as Faltas,
- CAST(sum(IF(Cliente LIKE 'BASURA',Importe,0)) as DECIMAL(10,0)) as Basura
- FROM bs.mermas
- WHERE Fecha BETWEEN vCurYearStarted AND vCurYearFinished
- OR Fecha BETWEEN vLastYearStarted AND vLastYearFinished
- GROUP BY año, Comprador;
-
-
-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 DROP PROCEDURE IF EXISTS `nightTask_launchAll` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -5341,8 +4890,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `nightTask_launchAll`()
BEGIN
@@ -5361,7 +4908,7 @@ BEGIN
DECLARE rs CURSOR FOR
SELECT id, `schema`, `procedure`
FROM nightTask
- WHERE finished <= CURDATE()
+ WHERE finished <= util.VN_CURDATE()
OR finished IS NULL
ORDER BY `order`;
@@ -5380,7 +4927,7 @@ BEGIN
END IF;
UPDATE nightTask
- SET `started` = NOW(),
+ SET `started` = util.VN_NOW(),
`finished` = NULL,
`error` = NULL,
`errorCode` = NULL
@@ -5403,8 +4950,8 @@ BEGIN
WHERE id = vId;
ELSE
UPDATE nightTask
- SET finished = NOW(),
- lastFinished = NOW()
+ SET finished = util.VN_NOW(),
+ lastFinished = util.VN_NOW()
WHERE id = vId;
END IF;
END LOOP;
@@ -5431,6 +4978,8 @@ DELIMITER ;
/*!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 `nightTask_launchTask` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -5438,8 +4987,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `nightTask_launchTask`(
vSchema VARCHAR(255),
@@ -5470,6 +5017,8 @@ DELIMITER ;
/*!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 `payMethodClientAdd` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -5477,13 +5026,11 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `payMethodClientAdd`()
BEGIN
INSERT IGNORE INTO `bs`.`payMethodClient` (dated, payMethodFk, clientFk)
- SELECT CURDATE(), c.payMethodFk, c.id
+ SELECT util.VN_CURDATE(), c.payMethodFk, c.id
FROM vn.client c
JOIN vn.payMethod p ON c.payMethodFk = p.id;
@@ -5504,6 +5051,8 @@ DELIMITER ;
/*!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 `produccionAdd` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -5511,8 +5060,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `produccionAdd`(vDate DATE)
BEGIN
@@ -5555,6 +5102,8 @@ DELIMITER ;
/*!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 `produccion_launcher` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -5562,8 +5111,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `produccion_launcher`(vDateFrom DATE, vDateTo DATE)
BEGIN
@@ -5617,6 +5164,8 @@ DELIMITER ;
/*!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 `produccion_launcher_auto` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -5624,15 +5173,13 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `produccion_launcher_auto`()
BEGIN
- DECLARE vDate DATE DEFAULT TIMESTAMPADD(WEEK, -1, CURDATE());
+ DECLARE vDate DATE DEFAULT TIMESTAMPADD(WEEK, -1, util.VN_CURDATE());
- WHILE vDate <= CURDATE() DO
+ WHILE vDate <= util.VN_CURDATE() DO
CALL bs.produccionAdd(vDate);
@@ -5640,9 +5187,9 @@ BEGIN
END WHILE;
- SET vDate = TIMESTAMPADD(DAY,-372, CURDATE());
+ SET vDate = TIMESTAMPADD(DAY,-372, util.VN_CURDATE());
- WHILE vDate <= TIMESTAMPADD(YEAR,-1, CURDATE()) DO
+ WHILE vDate <= TIMESTAMPADD(YEAR,-1, util.VN_CURDATE()) DO
CALL bs.produccionAdd(vDate);
@@ -5656,6 +5203,8 @@ DELIMITER ;
/*!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 `pruebas` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -5663,8 +5212,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `pruebas`(IN vDateStart DATE, IN vDateEnd DATE)
BEGIN
@@ -5696,6 +5243,8 @@ DELIMITER ;
/*!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 `saleGraphic` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -5703,8 +5252,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `saleGraphic`(IN vItemFk INT, IN vTypeFk INT, IN vCategoryFk INT, IN vFromDate DATE,
IN vToDate DATE, IN vProducerFk INT)
@@ -5718,8 +5265,8 @@ BEGIN
SET vItemFk = IFNULL(vItemFk,0);
SET vTypeFk = IFNULL(vTypeFk, 0);
SET vCategoryFk = IFNULL(vCategoryFk,0);
- SET vFromDate = IFNULL(vFromDate,CURDATE());
- SET vToDate = IFNULL(vToDate,CURDATE());
+ SET vFromDate = IFNULL(vFromDate,util.VN_CURDATE());
+ SET vToDate = IFNULL(vToDate,util.VN_CURDATE());
SET vProducerFk = IFNULL(vProducerFk,0);
SET vFromDateLastYear = TIMESTAMPADD(YEAR,-1,vFromDate);
@@ -5748,6 +5295,8 @@ DELIMITER ;
/*!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 `salePersonEvolutionAdd` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -5755,13 +5304,11 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `salePersonEvolutionAdd`(IN vDateStart DATETIME)
BEGIN
DELETE FROM bs.salePersonEvolution
- WHERE dated <= DATE_SUB(CURDATE(), INTERVAL 1 YEAR);
+ WHERE dated <= DATE_SUB(util.VN_CURDATE(), INTERVAL 1 YEAR);
INSERT INTO bs.salePersonEvolution (dated, amount, equalizationTax, salesPersonFk)
@@ -5781,6 +5328,8 @@ DELIMITER ;
/*!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 `salesByclientSalesPerson_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -5788,14 +5337,12 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `salesByclientSalesPerson_add`(vDatedFrom DATE)
BEGIN
IF vDatedFrom IS NULL THEN
- SELECT CURDATE() - INTERVAL DAY(CURDATE())-1 DAY - INTERVAL 1 MONTH INTO vDatedFrom;
+ SELECT util.VN_CURDATE() - INTERVAL DAY(util.VN_CURDATE())-1 DAY - INTERVAL 1 MONTH INTO vDatedFrom;
END IF;
INSERT INTO salesByclientSalesPerson( dated, salesPersonFk, clientFk, amount, equalizationTax)
@@ -5822,36 +5369,296 @@ DELIMITER ;
/*!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 `salesByItemTypeDay_add` */;
+/*!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=`root`@`localhost` PROCEDURE `salesByItemTypeDay_add`(vDateStart DATE, vDateEnd DATE)
+BEGIN
+/**
+ * Almacena datos relativos a las ventas de artículos agrupados por reino y familia
+ *
+ * @param vDateStart
+ * @param vDateEnd
+ */
+
+ DELETE FROM bs.salesByItemTypeDay
+ WHERE dated BETWEEN vDateStart AND vDateEnd;
+
+ INSERT INTO bs.salesByItemTypeDay (itemTypeFk, itemCategoryFk, dated)
+ SELECT id, categoryFk, dated
+ FROM vn.itemType
+ JOIN vn.`time`
+ WHERE dated BETWEEN vDateStart AND vDateEnd;
+
+ UPDATE bs.salesByItemTypeDay it
+ JOIN (SELECT ic.id itemCategoryFk,
+ it.id itemTypeFk,
+ bs.dated,
+ SUM(bs.amount) netSale
+ FROM bs.sale bs
+ JOIN vn.itemType it ON it.id = bs.typeFk
+ JOIN vn .itemCategory ic ON ic.id = it.categoryFk
+ JOIN vn.client c on c.id = bs.clientFk
+ JOIN vn.sale s ON s.id = bs.saleFk
+ JOIN vn.item i ON i.id = s.itemFk
+ JOIN vn.ticket t ON t.id = s.ticketFk
+ JOIN vn.`time` ti ON ti.dated = bs.dated
+ WHERE ic.merchandise
+ AND bs.dated BETWEEN vDateStart AND vDateEnd
+ GROUP BY ic.id, it.id, bs.dated) sub ON sub.dated = it.dated AND sub.itemCategoryFk = it.itemCategoryFk AND sub.itemTypeFk = it.itemTypeFk
+ SET it.netSale = sub.netSale;
+
+
+ UPDATE bs.salesByItemTypeDay it
+ JOIN (SELECT ic.id AS itemCategoryFk,
+ it.id AS itemTypeFk,
+ bs.dated,
+ SUM(i.stems * s.quantity) stems
+ FROM bs.sale bs
+ JOIN vn.itemType it ON it.id = bs.typeFk
+ JOIN vn.itemCategory ic ON ic.id = it.categoryFk
+ JOIN vn.sale s ON s.id = bs.saleFk
+ JOIN vn.ticket t ON t.id = s.ticketFk
+ JOIN vn.item i ON i.id = s.itemFk
+ JOIN vn.`time` tm ON tm.dated = bs.dated
+ WHERE ic.merchandise
+ AND bs.dated BETWEEN vDateStart AND vDateEnd
+ GROUP BY ic.id, it.id, bs.dated) sub ON sub.dated = it.dated AND sub.itemCategoryFk = it.itemCategoryFk AND sub.itemTypeFk = it.itemTypeFk
+ SET it.stems = sub.stems;
+
+
+ UPDATE bs.salesByItemTypeDay it
+ JOIN (SELECT ic.id AS itemCategoryFk,
+ it.id AS itemTypeFk,
+ DATE(t.shipped) dated,
+ COUNT(DISTINCT(i.id)) `references`
+ FROM vn.ticket t
+ JOIN vn.sale s ON s.ticketFk = t.id
+ JOIN vn.item i ON i.id = s.itemFk
+ JOIN vn.itemType it ON it.id = i.typeFk
+ JOIN vn.itemCategory ic ON ic.id = it.categoryFk
+ WHERE ic.merchandise
+ AND t.shipped BETWEEN vDateStart AND util.dayEnd(vDateEnd)
+ GROUP BY ic.id, it.id, dated) sub ON sub.dated = it.dated AND sub.itemCategoryFk = it.itemCategoryFk AND sub.itemTypeFk = it.itemTypeFk
+ SET it.`references` = sub.`references`;
+
+ UPDATE bs.salesByItemTypeDay it
+ JOIN (SELECT ic.id AS itemCategoryFk,
+ it.id AS itemTypeFk,
+ DATE(t.shipped) dated,
+ SUM(i.stems*s.quantity) AS trash
+ FROM vn.sale s
+ JOIN vn.ticket t ON t.id = s.ticketFk
+ JOIN vn.item i ON i.id = s.itemFk
+ JOIN vn.itemType it ON it.id = i.typeFk
+ JOIN vn.itemCategory ic ON ic.id = it.categoryFk
+ JOIN vn.client c ON c.id = t.clientFk
+ WHERE c.name = 'BASURA'
+ AND t.shipped BETWEEN vDateStart AND util.dayEnd(vDateEnd)
+ GROUP BY ic.id, it.id, dated) sub ON sub.dated = it.dated AND sub.itemCategoryFk = it.itemCategoryFk AND sub.itemTypeFk = it.itemTypeFk
+ SET it.trash = sub.trash;
+
+ UPDATE bs.salesByItemTypeDay it
+ JOIN (SELECT ic.id AS itemCategoryFk,
+ it.id AS itemTypeFk,
+ DATE(t.shipped) dated,
+ SUM(IFNULL(i.stems, 1) * s.quantity) AS faults
+ FROM vn.sale s
+ JOIN vn.ticket t ON t.id = s.ticketFk
+ JOIN vn.item i ON i.id = s.itemFk
+ JOIN vn.itemType it ON it.id = i.typeFk
+ JOIN vn.itemCategory ic ON ic.id = it.categoryFk
+ JOIN vn.client c ON c.id = t.clientFk
+ WHERE c.name = 'FALTAS'
+ AND t.shipped BETWEEN vDateStart AND util.dayEnd(vDateEnd)
+ GROUP BY ic.id, it.id, dated) sub ON sub.dated = it.dated AND sub.itemCategoryFk = it.itemCategoryFk AND sub.itemTypeFk = it.itemTypeFk
+ SET it.`faults` = sub.`faults`;
+
+ UPDATE bs.salesByItemTypeDay it
+ JOIN (SELECT ic.id AS itemCategoryFk,
+ it.id AS itemTypeFk,
+ DATE(t.shipped) dated,
+ SUM((cb.quantity * s.price * (100 - s.discount) / 100) * ((cc.maxResponsibility - c.responsibility )/4 )) accepted,
+ SUM(cb.quantity * s.price * (100 - s.discount) / 100) claimed
+ FROM vn.claim c
+ JOIN vn.claimBeginning cb ON cb.claimFk = c.id
+ JOIN vn.sale s ON s.id = cb.saleFk
+ JOIN vn.ticket t ON t.id = s.ticketFk
+ JOIN vn.item i ON i.id = s.itemFk
+ JOIN vn.itemType it ON it.id = i.typeFk
+ JOIN vn.itemCategory ic ON ic.id = it.categoryFk
+ JOIN vn.claimConfig cc
+ WHERE ic.merchandise
+ AND t.shipped BETWEEN vDateStart AND util.dayEnd(vDateEnd)
+ GROUP BY ic.id, it.id, dated) sub ON sub.dated = it.dated AND sub.itemCategoryFk = it.itemCategoryFk AND sub.itemTypeFk = it.itemTypeFk
+ SET it.accepted = sub.accepted,
+ it.claimed = sub.claimed;
+
+ UPDATE bs.salesByItemTypeDay it
+ JOIN(SELECT itemCategoryFk,
+ itemTypeFk,
+ dated,
+ CAST(SUM(sale) AS DECIMAL(10,2)) sale,
+ CAST(SUM(buy) AS DECIMAL(10,2))buy
+ FROM(SELECT ic.id itemCategoryFk,
+ it.id itemTypeFk,
+ bs.dated,
+ SUM(bs.amount) sale,
+ 0 buy
+ FROM bs.sale bs
+ JOIN vn.itemType it ON it.id = bs.typeFk
+ JOIN vn.itemCategory ic ON ic.id = it.categoryFk
+ JOIN vn.client c on c.id = bs.clientFk
+ JOIN vn.`time` tm ON tm.dated = bs.dated
+ JOIN vn.sale s ON s.id = bs.saleFk
+ JOIN vn.item i ON i.id = s.itemFk
+ WHERE ic.merchandise
+ AND bs.dated BETWEEN vDateStart AND vDateEnd
+ GROUP BY ic.id, it.id, bs.dated
+ UNION ALL
+ SELECT ic.id,
+ it.id,
+ t.landed,
+ 0 ,
+ SUM(b.buyingValue * b.quantity)
+ FROM vn.entry e
+ JOIN vn.travel t ON t.id = e.travelFk
+ JOIN vn.buy b ON b.entryFk = e.id
+ JOIN vn.item i ON i.id = b.itemFk
+ JOIN vn.itemType it ON it.id = i.typeFk
+ JOIN vn.itemCategory ic ON ic.id = it.categoryFk
+ WHERE ic.merchandise
+ AND t.landed BETWEEN vDateStart AND vDateEnd
+ GROUP BY ic.id, it.id, t.landed) sub
+ GROUP BY itemCategoryFk, itemTypeFk, dated) sub2 ON sub2.dated = it.dated AND sub2.itemCategoryFk = it.itemCategoryFk AND sub2.itemTypeFk = it.itemTypeFk
+ SET it.sale = sub2.sale,
+ it.buy = sub2.buy;
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.`component`;
+ CREATE TEMPORARY TABLE tmp.`component`
+ (PRIMARY KEY (`itemTypeFk`,`dated`),
+ KEY `salesByItemTypeDay_itemCategoryFk_idx` (`itemCategoryFk`),
+ KEY `salesByItemTypeDay_dated_idx` (`dated`))
+ ENGINE = MEMORY
+ SELECT DATE(t.shipped) dated,
+ ic.id itemCategoryFk,
+ it.id itemTypeFk,
+ SUM(s.quantity * IF(c.code = 'purchaseValue', sc.value,0)) costComponent,
+ SUM(s.quantity * IF(ct.isMargin, sc.value,0)) marginComponent
+ FROM vn.ticket t
+ JOIN vn.sale s ON t.id = s.ticketFk
+ JOIN vn.item i ON i.id = s.itemFk
+ JOIN vn.itemType it ON it.id = i.typeFk
+ JOIN vn.itemCategory ic ON ic.id = it.categoryFk
+ JOIN vn.saleComponent sc ON sc.saleFk = s.id
+ STRAIGHT_JOIN vn.component c ON c.id = sc.componentFk
+ JOIN vn.componentType ct ON ct.id = c.typeFk
+ WHERE t.shipped BETWEEN vDateStart AND util.dayEnd(vDateEnd)
+ GROUP BY ic.id, it.id, dated;
+
+ UPDATE bs.salesByItemTypeDay it
+ JOIN tmp.`component` c ON c.dated = it.dated AND c.itemCategoryFk = it.itemCategoryFk AND c.itemTypeFk = it.itemTypeFk
+ SET it.costComponent = c.costComponent,
+ it.marginComponent = c.marginComponent,
+ it.saleComponent = c.costComponent + c.marginComponent;
+
+ DROP TEMPORARY TABLE tmp.`component`;
+
+/* UPDATE bs.salesByItemTypeDay it
+ JOIN(SELECT DATE(t.shipped) dated,
+ ic.id itemCategoryFk,
+ it.id itemTypeFk,
+ SUM(s.quantity * IF(c.code = 'purchaseValue', sc.value,0)) costComponent,
+ SUM(s.quantity * IF(ct.isMargin, sc.value,0)) marginComponent
+ FROM vn.ticket t
+ JOIN vn.sale s ON t.id = s.ticketFk
+ JOIN vn.item i ON i.id = s.itemFk
+ JOIN vn.itemType it ON it.id = i.typeFk
+ JOIN vn.itemCategory ic ON ic.id = it.categoryFk
+ JOIN vn.saleComponent sc ON sc.saleFk = s.id
+ STRAIGHT_JOIN vn.component c ON c.id = sc.componentFk
+ JOIN vn.componentType ct ON ct.id = c.typeFk
+ JOIN vn.`time` tm ON tm.dated = DATE(t.shipped)
+ WHERE t.shipped BETWEEN vDateStart AND util.dayEnd(vDateEnd)
+ GROUP BY ic.id, it.id, dated)sub ON sub.dated = it.dated AND sub.itemCategoryFk = it.itemCategoryFk AND sub.itemTypeFk = it.itemTypeFk
+ SET it.costComponent = sub.costComponent,
+ it.marginComponent = sub.marginComponent,
+ it.saleComponent = sub.costComponent + sub.marginComponent;*/
+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 `salesByItemTypeDay_addLauncher` */;
+/*!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=`root`@`localhost` PROCEDURE `salesByItemTypeDay_addLauncher`()
+BEGIN
+ DECLARE vDateStart,vDateEnd INT;
+
+ SELECT DATE_SUB(util.VN_CURDATE(), INTERVAL 30 DAY), util.VN_CURDATE() INTO vDateStart,vDateEnd;
+ CALL bs.salesByItemTypeDay_add(vDateStart, vDateEnd);
+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 `salesMonthlySnapshot_add` */;
/*!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_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `salesMonthlySnapshot_add`()
BEGIN
- DECLARE vPlusNewClient INT DEFAULT 100;
- DECLARE vScoreNewClient INT DEFAULT 100;
+ DECLARE vExecutionDay INT;
+ DECLARE vPlusNewClient INT;
+ DECLARE vPlusDifference INT;
+ DECLARE vScoreNewClient INT;
+ DECLARE vScoreDifference INT;
+ DECLARE vMaxWorkersWithPlusNewClient INT;
DECLARE vRowCount INT DEFAULT 1;
DECLARE vMaxRow INT;
-
- IF(DAY(CURDATE()) = 5) THEN
+ DECLARE vPreviusMonth DATETIME DEFAULT util.VN_CURDATE();
+
+ SELECT executionDay, maxPlusNewClient, plusDifference, maxScoreNewClient, scoreDifference, salesPersonWithPlusNewClient
+ INTO vExecutionDay, vPlusNewClient, vPlusDifference, vScoreNewClient, vScoreDifference, vMaxWorkersWithPlusNewClient
+ FROM vn.commissionConfig;
+
+ IF(DAY(util.VN_CURDATE()) = vExecutionDay) THEN
-- COMERCIAL Y EQUIPO
DROP TEMPORARY TABLE IF EXISTS tmp.salesPersons;
CREATE TEMPORARY TABLE tmp.salesPersons
ENGINE = MEMORY
- SELECT u.id workerFk,
+ SELECT u.id workerFk,
u.name salesPersonName,
d.name teamName
- FROM vn.department d
+ FROM vn.department d
JOIN vn.workerDepartment wd ON wd.departmentFk = d.id
JOIN account.user u ON u.id = wd.workerFk
- WHERE d.name LIKE '%EQUIPO%';
-
+ JOIN vn.department d2 ON d2.id = d.parentFk
+ WHERE d2.code = 'VT';
+
-- VENTA, COMISIÓN
DROP TEMPORARY TABLE IF EXISTS tmp.sale;
CREATE TEMPORARY TABLE tmp.sale
@@ -5868,164 +5675,166 @@ BEGIN
JOIN vn.client c ON c.id = s.salesPersonFk
JOIN account.user u ON u.id = s.salesPersonFk
JOIN vn.commissionConfig cc
- WHERE dated BETWEEN util.firstDayOfMonth(DATE_SUB(CURDATE(), INTERVAL 1 MONTH)) AND LAST_DAY(DATE_SUB(CURDATE(), INTERVAL 1 MONTH))
+ WHERE dated BETWEEN util.firstDayOfMonth(vPreviusMonth) AND LAST_DAY(vPreviusMonth)
GROUP BY year, month, workerFk;
-
+
-- OBJETIVO EVALUABLE (GRUPO) Y OBJETIVO INCENTIVO (INDIVIDUAL)
DROP TEMPORARY TABLE IF EXISTS tmp.objectives;
CREATE TEMPORARY TABLE tmp.objectives
ENGINE = MEMORY
- SELECT sg.rank,
- sg.goal goalGroup,
- sg2.goal goalIncentive,
- sub.walletWeigth,
- sub.walletWeigth*sg2.goal/100 AS incentiveObjective,
- sub.walletWeigth*sg.goal/100 AS evaluableObjective,
- sub.workerFk,
- rb.bonus
- FROM (
- SELECT
- CASE
- WHEN portfolioWeight >= sg1.walletWeightFrom
- AND portfolioWeight <= sg1.walletWeightTo THEN 1
- WHEN portfolioWeight >= sg2.walletWeightFrom
- AND portfolioWeight <= sg2.walletWeightTo THEN 2
- WHEN portfolioWeight >= sg3.walletWeightFrom
- AND portfolioWeight <= sg3.walletWeightTo THEN 3
- WHEN portfolioWeight >= sg4.walletWeightFrom
- AND portfolioWeight <= sg4.walletWeightTo THEN 4
- WHEN portfolioWeight >= sg5.walletWeightFrom
- AND portfolioWeight <= sg5.walletWeightTo THEN 5
- END rank,
- u.id workerFk,
- IFNULL(v.portfolioWeight,0) AS walletWeigth
- FROM bs.vendedores v
- JOIN account.`user` u ON u.id = v.Id_Trabajador
- JOIN vn.saleGoal sg1 ON sg1.`rank` = 1 AND sg1.`year` = YEAR(DATE_SUB(CURDATE(), INTERVAL 1 MONTH)) AND sg1.`month` = MONTH(DATE_SUB(CURDATE(), INTERVAL 1 MONTH))
- JOIN vn.saleGoal sg2 ON sg2.`rank` = 2 AND sg2.`year` = YEAR(DATE_SUB(CURDATE(), INTERVAL 1 MONTH)) AND sg2.`month` = MONTH(DATE_SUB(CURDATE(), INTERVAL 1 MONTH))
- JOIN vn.saleGoal sg3 ON sg3.`rank` = 3 AND sg3.`year` = YEAR(DATE_SUB(CURDATE(), INTERVAL 1 MONTH)) AND sg3.`month` = MONTH(DATE_SUB(CURDATE(), INTERVAL 1 MONTH))
- JOIN vn.saleGoal sg4 ON sg4.`rank` = 4 AND sg4.`year` = YEAR(DATE_SUB(CURDATE(), INTERVAL 1 MONTH)) AND sg4.`month` = MONTH(DATE_SUB(CURDATE(), INTERVAL 1 MONTH))
- JOIN vn.saleGoal sg5 ON sg5.`rank` = 5 AND sg5.`year` = YEAR(DATE_SUB(CURDATE(), INTERVAL 1 MONTH)) AND sg5.`month` = MONTH(DATE_SUB(CURDATE(), INTERVAL 1 MONTH))
- WHERE v.año = YEAR(DATE_SUB(CURDATE(), INTERVAL 1 MONTH))-1 AND v.mes = MONTH(DATE_SUB(CURDATE(), INTERVAL 1 MONTH))
- GROUP BY u.id
- ) sub
- JOIN vn.saleGoal sg ON sg.`rank` = sub.rank AND sg.goalType = 'grupo' AND sg.`year` = YEAR(DATE_SUB(CURDATE(), INTERVAL 1 MONTH)) AND sg.`month` = MONTH(DATE_SUB(CURDATE(), INTERVAL 1 MONTH))
- JOIN vn.saleGoal sg2 ON sg2.`rank` = sub.rank AND sg2.goalType = 'individual' AND sg2.`year` = YEAR(DATE_SUB(CURDATE(), INTERVAL 1 MONTH)) AND sg2.`month` = MONTH(DATE_SUB(CURDATE(), INTERVAL 1 MONTH))
- JOIN vn.rankBonus rb ON rb.`rank` = sub.`rank`;
-
- -- PUNTUACIÓN EQUIPO, PLUS OBJETIVO EQUIPO Y PLUS VARIABLE JEFE DE EQUIPO
- DROP TEMPORARY TABLE IF EXISTS tmp.scoreTeam;
+ SELECT
+ sg.rank,
+ sg.goal goalGroup,
+ sg4.goal goalIncentive,
+ sub.walletWeigth,
+ sub.walletWeigth*sg4.goal/100 AS incentiveObjective,
+ sub.walletWeigth*sg.goal/100 AS evaluableObjective,
+ sub.workerFk,
+ rb.bonus
+ FROM (
+ SELECT sg.`rank` ,
+ u.id workerFk,
+ IFNULL(v.portfolioWeight,0) AS walletWeigth
+ FROM bs.vendedores v
+ JOIN account.`user` u ON u.id = v.Id_Trabajador
+ JOIN vn.saleGoal sg ON sg.`year` = YEAR(vPreviusMonth)
+ AND sg.`month` = MONTH(vPreviusMonth)
+ AND v.portfolioWeight BETWEEN sg.walletWeightFrom AND sg.walletWeightTo
+ WHERE v.año = YEAR(vPreviusMonth)-1 AND v.mes = MONTH(vPreviusMonth)
+ GROUP BY u.id
+ ) sub
+ JOIN vn.saleGoal sg ON sg.`rank` = sub.rank AND sg.goalType = '1' AND sg.`year` = YEAR(vPreviusMonth) AND sg.`month` = MONTH(vPreviusMonth)
+ JOIN vn.saleGoal sg4 ON sg4.`rank` = sub.rank AND sg4.goalType = '4' AND sg4.`year` = YEAR(vPreviusMonth) AND sg4.`month` = MONTH(vPreviusMonth)
+ LEFT JOIN account.`user` u2 ON u2.id = sub.workerFk
+ JOIN vn.rankBonus rb ON rb.`rank` = sub.`rank`;
+
+ -- PUNTUACIÓN EQUIPO, PLUS OBJETIVO EQUIPO
+ DROP TEMPORARY TABLE IF EXISTS tmp.scoreTeam;
CREATE TEMPORARY TABLE tmp.scoreTeam
ENGINE = MEMORY
- SELECT *,
- IF(sub1.teamScore >= sub1.minScoreForPlusTeam, sub1.plusTeamValue, 0) teamPlus,
- IF(sub1.teamScore >= sub1.minScoreForPlusBoss, countSalesPerson * sub1.plusBoss, 0) teamBossPlus
+ SELECT *,
+ IF(sub1.teamScore >= sub1.minScoreForPlusTeam, sub1.plusTeamValue, 0) teamPlus
FROM (
- SELECT *,
- (100/sub.countSalesPerson)*countGroupAchieved teamScore
+ SELECT *,
+ (100/sub.countSalesPerson)*countGroupAchieved teamScore
FROM (
SELECT COUNT(u.id) countSalesPerson,
u.id workerFk,
u.name salesPersonName,
+ d3.workerFk bossFk,
d.name teamName,
cc.minScoreForPlusTeam,
cc.minScoreForPlusBoss,
cc.plusTeam plusTeamValue,
cc.plusBoss,
SUM(IF(s.currentSale > r.evaluableObjective, 1, 0)) countGroupAchieved
- FROM vn.department d
+ FROM vn.department d
JOIN vn.workerDepartment wd ON wd.departmentFk = d.id
JOIN account.user u ON u.id = wd.workerFk
JOIN tmp.sale s ON s.workerFk = wd.workerFk
JOIN tmp.objectives r ON r.workerFk = wd.workerFk
- JOIN vn.commissionConfig cc
- WHERE d.name LIKE '%EQUIPO%'
+ JOIN vn.commissionConfig cc
+ JOIN vn.department d2 ON d2.id = d.parentFk
+ JOIN vn.department d3 ON d3.name = d.name
+ WHERE d2.code = 'VT'
GROUP BY d.name
) sub
) sub1;
-
+
+ -- PLUS VARIABLE JEFE DE EQUIPO
+ DROP TEMPORARY TABLE IF EXISTS tmp.plusBoss;
+ CREATE TEMPORARY TABLE tmp.plusBoss
+ ENGINE = MEMORY
+ SELECT d.workerFk,
+ IF(st.teamScore >= st.minScoreForPlusBoss , st.countSalesPerson * st.plusBoss, 0) teamBossPlus
+ FROM tmp.scoreTeam st
+ JOIN vn.department d ON d.name = st.teamName;
+
-- PLUS CLIENTES NUEVOS
DROP TEMPORARY TABLE IF EXISTS tmp.newClients;
CREATE TEMPORARY TABLE tmp.newClients (
- id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
- workerFk INTEGER(11),
- name VARCHAR(30),
- total DECIMAL(10,3),
- newClientPlus INTEGER(11),
- newClientScore INTEGER(11)
+ id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ workerFk INTEGER(11),
+ name VARCHAR(30),
+ total DECIMAL(10,3),
+ newClientPlus INTEGER(11),
+ newClientScore INTEGER(11)
);
-
+
INSERT INTO tmp.newClients (workerFk, total, name, newClientPlus)
SELECT u.id workerFk, u.name, SUM(v.importe) total, vPlusNewClient
- FROM bs.clientNewBorn cn
+ FROM bs.clientNewBorn cn
JOIN bs.ventas v ON DATE_ADD(cn.firstShipped, INTERVAL 1 YEAR) > v.fecha AND v.Id_Cliente = cn.clientFk
- JOIN vn.client c ON c.id = v.Id_Cliente
- JOIN account.user u ON u.id = c.salesPersonFk
- JOIN vn.workerDepartment wd ON wd.workerFk = u.id
- JOIN vn.department d On d.id = wd.departmentFk
- WHERE v.fecha >= util.firstDayOfMonth(DATE_SUB(CURDATE(), INTERVAL 1 MONTH))
- AND cn.firstShipped >= util.firstDayOfMonth(DATE_ADD(DATE_SUB(CURDATE(), INTERVAL 1 MONTH), INTERVAL -1 year))
- AND d.name LIKE 'EQUIPO%'
+ JOIN vn.client c ON c.id = v.Id_Cliente
+ JOIN account.user u ON u.id = c.salesPersonFk
+ JOIN vn.workerDepartment wd ON wd.workerFk = u.id
+ JOIN vn.department d On d.id = wd.departmentFk
+ JOIN vn.department d2 ON d2.id = d.parentFk
+ WHERE v.fecha >= util.firstDayOfMonth(vPreviusMonth)
+ AND cn.firstShipped >= util.firstDayOfMonth(DATE_ADD(vPreviusMonth, INTERVAL -1 year))
+ AND d2.code = 'VT'
GROUP BY u.id
ORDER BY total DESC;
-
+
SET vMaxRow = ROW_COUNT();
-
+
my_loop: LOOP
- UPDATE tmp.newClients SET newClientPlus = vPlusNewClient WHERE id = vRowCount;
- UPDATE tmp.newClients SET newClientScore = vScoreNewClient WHERE id = vRowCount;
-
- IF (vRowCount <= 20) THEN
- SET vPlusNewClient = vPlusNewClient - 5;
- ELSE
- SET vPlusNewClient = 0;
- END IF;
-
- SET vScoreNewClient = vScoreNewClient - 1;
- SET vRowCount = vRowCount + 1;
-
- IF vRowCount > vMaxRow THEN
- LEAVE my_loop;
- END IF;
- END LOOP my_loop;
-
- INSERT INTO bs.salesMonthlySnapshot (salesPersonName, teamName, `year`, `month`, currentSale, commissionSale, individualPlus, teamPlus, teamScore, newClientPlus, newClientScore, teamBossPlus)
- SELECT *
- FROM (
- SELECT sp.salesPersonName,
- sp.teamName,
- s.`year`,
- s.`month`,
- s.currentSale,
- s.commissionSale,
- IF(s.currentSale > s.minimumSalesByMonth AND s.currentSale > r.incentiveObjective, r.bonus, 0) individualPlus,
- np.teamPlus,
- np.teamScore,
- nc.newClientPlus,
- nc.newClientScore,
- np.teamBossPlus
- FROM tmp.salesPersons sp
- LEFT JOIN tmp.sale s ON s.workerFk = sp.workerFk
- LEFT JOIN tmp.objectives r ON r.workerFk = sp.workerFk
- LEFT JOIN tmp.scoreTeam np ON np.teamName = sp.teamName
- LEFT JOIN tmp.newClients nc ON nc.workerFk = sp.workerFk
- ) sub
- ORDER BY salesPersonName;
-
- DROP TEMPORARY TABLE
+ UPDATE tmp.newClients SET newClientPlus = vPlusNewClient WHERE id = vRowCount;
+ UPDATE tmp.newClients SET newClientScore = vScoreNewClient WHERE id = vRowCount;
+
+ IF (vRowCount <= vMaxWorkersWithPlusNewClient) THEN
+ SET vPlusNewClient = vPlusNewClient - vPlusDifference;
+ ELSE
+ SET vPlusNewClient = 0;
+ END IF;
+
+ SET vScoreNewClient = vScoreNewClient - vScoreDifference;
+ SET vRowCount = vRowCount + 1;
+
+ IF vRowCount > vMaxRow THEN
+ LEAVE my_loop;
+ END IF;
+ END LOOP my_loop;
+
+ INSERT INTO bs.salesMonthlySnapshot (salesPersonName, teamName, `year`, `month`, currentSale, commissionSale, individualPlus, teamPlus, teamScore, newClientPlus, newClientScore, teamBossPlus)
+ SELECT *
+ FROM (
+ SELECT sp.salesPersonName,
+ sp.teamName,
+ s.`year`,
+ s.`month`,
+ s.currentSale,
+ s.commissionSale,
+ IF(s.currentSale > s.minimumSalesByMonth AND s.currentSale > r.incentiveObjective, r.bonus, 0) individualPlus,
+ np.teamPlus,
+ np.teamScore,
+ nc.newClientPlus,
+ nc.newClientScore,
+ pb.teamBossPlus
+ FROM tmp.salesPersons sp
+ LEFT JOIN tmp.sale s ON s.workerFk = sp.workerFk
+ LEFT JOIN tmp.objectives r ON r.workerFk = sp.workerFk
+ LEFT JOIN tmp.scoreTeam np ON np.teamName = sp.teamName
+ LEFT JOIN tmp.plusBoss pb ON pb.workerFk = sp.workerFk
+ LEFT JOIN tmp.newClients nc ON nc.workerFk = sp.workerFk
+ ) sub
+ ORDER BY salesPersonName;
+
+ DROP TEMPORARY TABLE
tmp.salesPersons,
tmp.sale,
tmp.objectives,
tmp.scoreTeam,
tmp.newClients;
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_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `salesPersonEvolution_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -6033,8 +5842,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `salesPersonEvolution_add`()
BEGIN
@@ -6058,7 +5865,7 @@ BEGIN
SET vDated = TIMESTAMPADD(DAY, 1, vDated);
END IF;
- WHILE vDated < CURDATE() DO
+ WHILE vDated < util.VN_CURDATE() DO
SET vCont = vCont + 1;
@@ -6083,6 +5890,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `salesPerson_updatePortfolio` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -6090,8 +5899,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `salesPerson_updatePortfolio`()
BEGIN
@@ -6099,12 +5906,12 @@ BEGIN
* Actualiza el campo portfolioWeight que indica el peso de la cartera del comercial
*
*/
- DECLARE vStarted DATE DEFAULT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -17 MONTH), '%Y-%m-01');
+ DECLARE vStarted DATE DEFAULT DATE_FORMAT(DATE_ADD(util.VN_CURDATE(), INTERVAL -17 MONTH), '%Y-%m-01');
UPDATE vendedores v
JOIN vn.`time` t ON t.`year` = v.año AND t.`month` = v.mes
SET v.portfolioWeight = NULL
- WHERE t.dated BETWEEN vStarted AND CURDATE();
+ WHERE t.dated BETWEEN vStarted AND util.VN_CURDATE();
UPDATE vendedores v
JOIN (
@@ -6116,7 +5923,7 @@ BEGIN
STRAIGHT_JOIN bs.ventas v ON t.dated = v.fecha
JOIN vn.`client` c ON c.id = v.Id_Cliente
WHERE c.lastSalesPersonFk IS NOT NULL
- AND v.fecha BETWEEN vStarted AND CURDATE()
+ AND v.fecha BETWEEN vStarted AND util.VN_CURDATE()
GROUP BY c.lastSalesPersonFk, t.`year`, t.`month`
) sub ON sub.lastSalesPersonFk = v.Id_Trabajador AND sub.`year` = v.año AND sub.`month`= v.mes
SET v.portfolioWeight = sub.importe;
@@ -6126,6 +5933,8 @@ DELIMITER ;
/*!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 `vendedores_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -6133,8 +5942,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `vendedores_add`(intYEAR INT, vQuarter INT)
BEGIN
@@ -6203,6 +6010,8 @@ DELIMITER ;
/*!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 `vendedores_add_launcher` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -6210,16 +6019,14 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `vendedores_add_launcher`()
BEGIN
DECLARE vDatedFrom DATE;
- CALL bs.vendedores_add(YEAR(CURDATE()),QUARTER(CURDATE()));
+ CALL bs.vendedores_add(YEAR(util.VN_CURDATE()),QUARTER(util.VN_CURDATE()));
CALL bs.vendedores_evolution_add;
- SELECT util.firstDayOfMonth(CURDATE())- INTERVAL 1 MONTH INTO vDatedFrom;
+ SELECT util.firstDayOfMonth(util.VN_CURDATE())- INTERVAL 1 MONTH INTO vDatedFrom;
CALL bs.salesByclientSalesPerson_add(vDatedFrom);
END ;;
@@ -6228,29 +6035,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `vendedores_add_launcher__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `vendedores_add_launcher__`()
-BEGIN
-
- CALL bs.vendedores_add(YEAR(CURDATE()),QUARTER(CURDATE()));
- CALL bs.vendedores_evolution_add;
- CALL bs.salesPersonClient_add(YEAR(CURDATE()), QUARTER(CURDATE()));
-
-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 DROP PROCEDURE IF EXISTS `vendedores_evolution_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -6258,8 +6044,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `vendedores_evolution_add`()
BEGIN
@@ -6272,8 +6056,8 @@ Inserta en la tabla compradores_evolution las ventas acumuladas en el ultimo mes
DECLARE vDateFrom DATE;
DECLARE vDateTo DATE;
- SET vCurYear = year(CURDATE());
- SET vCurMonth = month(CURDATE());
+ SET vCurYear = year(util.VN_CURDATE());
+ SET vCurMonth = month(util.VN_CURDATE());
SELECT IFNULL(max(year),vCurYear-1), IFNULL(max(month),1)
INTO vYear, vMonth
@@ -6314,6 +6098,8 @@ DELIMITER ;
/*!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 `ventas_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -6321,8 +6107,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ventas_add`(IN datSTART DATETIME, IN datEND DATETIME)
BEGIN
@@ -6340,8 +6124,8 @@ BEGIN
DECLARE vEndingDate DATETIME;
DECLARE TIPO_PATRIMONIAL INT DEFAULT 188;
- IF datSTART < TIMESTAMPADD(YEAR,-5,CURDATE())
- OR datEND < TIMESTAMPADD(YEAR,-5,CURDATE()) THEN
+ IF datSTART < TIMESTAMPADD(YEAR,-5,util.VN_CURDATE())
+ OR datEND < TIMESTAMPADD(YEAR,-5,util.VN_CURDATE()) THEN
CALL util.throw('fechaDemasiadoAntigua');
END IF;
@@ -6406,6 +6190,8 @@ DELIMITER ;
/*!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 `ventas_add_launcher` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -6413,8 +6199,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ventas_add_launcher`()
BEGIN
@@ -6425,7 +6209,7 @@ BEGIN
*
**/
- CALL bs.ventas_add(timestampadd(week,-1,curdate()),curdate());
+ CALL bs.ventas_add(timestampadd(week,-1,util.VN_CURDATE()),util.VN_CURDATE());
END ;;
DELIMITER ;
@@ -6433,6 +6217,8 @@ DELIMITER ;
/*!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 `ventas_contables_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -6440,8 +6226,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ventas_contables_add`(IN vYear INT, IN vMonth INT)
BEGIN
@@ -6548,6 +6332,8 @@ DELIMITER ;
/*!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 `ventas_contables_add_launcher` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -6555,8 +6341,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ventas_contables_add_launcher`()
BEGIN
@@ -6567,7 +6351,7 @@ BEGIN
*
**/
- CALL bs.ventas_contables_add(YEAR(TIMESTAMPADD(MONTH,-1,CURDATE())), MONTH(TIMESTAMPADD(MONTH,-1,CURDATE())));
+ CALL bs.ventas_contables_add(YEAR(TIMESTAMPADD(MONTH,-1,util.VN_CURDATE())), MONTH(TIMESTAMPADD(MONTH,-1,util.VN_CURDATE())));
END ;;
DELIMITER ;
@@ -6575,92 +6359,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `ventas_contables_add__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ventas_contables_add__`(IN vYear INT, IN vMonth INT)
-BEGIN
-/**
- * Reemplaza las ventas contables. Es el origen de datos para el balance de Entradas
- *
- * @param vYear Año a reemplazar
- * @param vMonth Mes a reemplazar
- *
- *
- **/
-DECLARE TIPO_PATRIMONIAL INT DEFAULT 188;
-
-DELETE FROM bs.ventas_contables
- WHERE year = vYear
- AND month = vMonth;
-
-DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list;
-
-CREATE TEMPORARY TABLE tmp.ticket_list
- (PRIMARY KEY (Id_Ticket))
- SELECT Id_Ticket
- FROM vn2008.Tickets t
- JOIN vn2008.Facturas f ON f.Id_Factura = t.Factura
- WHERE year(f.Fecha) = vYear
- AND month(f.Fecha) = vMonth;
-
-
-INSERT INTO bs.ventas_contables(year
- , month
- , venta
- , grupo
- , reino_id
- , tipo_id
- , empresa_id
- , gasto)
-
- SELECT vYear
- , vMonth
- , round(sum(Cantidad * Preu * (100 - m.Descuento)/100))
- , if(
- e.empresa_grupo = e2.empresa_grupo
- ,1
- ,if(e2.empresa_grupo,2,0)
- ) as grupo
- , tp.reino_id
- , a.tipo_id
- , t.empresa_id
- , 7000000000
- + if(e.empresa_grupo = e2.empresa_grupo
- ,1
- ,if(e2.empresa_grupo,2,0)
- ) * 1000000
- + tp.reino_id * 10000 as Gasto
- FROM vn2008.Movimientos m
- JOIN vn2008.Tickets t on t.Id_Ticket = m.Id_Ticket
- JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna
- JOIN vn2008.Clientes c on c.Id_Cliente = cs.Id_Cliente
- JOIN tmp.ticket_list tt on tt.Id_Ticket = t.Id_Ticket
- JOIN vn2008.Articles a on m.Id_Article = a.Id_Article
- JOIN vn2008.empresa e on e.id = t.empresa_id
- LEFT JOIN vn2008.empresa e2 on e2.Id_Cliente = c.Id_Cliente
- JOIN vn2008.Tipos tp on tp.tipo_id = a.tipo_id
- WHERE Cantidad <> 0
- AND Preu <> 0
- AND m.Descuento <> 100
- AND a.tipo_id != TIPO_PATRIMONIAL
- GROUP BY grupo, reino_id, tipo_id, empresa_id, Gasto;
-
-
-DROP TEMPORARY TABLE tmp.ticket_list;
-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 DROP PROCEDURE IF EXISTS `ventas_contables_por_cliente` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -6668,8 +6368,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ventas_contables_por_cliente`(IN vYear INT, IN vMonth INT)
BEGIN
@@ -6721,6 +6419,8 @@ DELIMITER ;
/*!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 `vivosMuertos` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -6728,8 +6428,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `vivosMuertos`()
BEGIN
@@ -6742,8 +6440,8 @@ BEGIN
* @param @datEND Fecha de finalización a buscar
*/
- SET @datSTART = TIMESTAMPADD(YEAR,-2,CURDATE());
- SET @datEND = TIMESTAMPADD(DAY,-DAY(CURDATE()),CURDATE());
+ SET @datSTART = TIMESTAMPADD(YEAR,-2,util.VN_CURDATE());
+ SET @datEND = TIMESTAMPADD(DAY,-DAY(util.VN_CURDATE()),util.VN_CURDATE());
DROP TEMPORARY TABLE IF EXISTS tmp.VivosMuertos;
@@ -6797,6 +6495,8 @@ DELIMITER ;
/*!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 `waste_addSales` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -6804,8 +6504,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `waste_addSales`()
BEGIN
@@ -6815,7 +6513,7 @@ BEGIN
SELECT week, year
INTO vWeek, vYear
FROM vn.time
- WHERE dated = CURDATE();
+ WHERE dated = util.VN_CURDATE();
REPLACE bs.waste
SELECT *, 100 * mermas / total as porcentaje
@@ -6841,66 +6539,21 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `waste_addSales_lastWeek__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `waste_addSales_lastWeek__`()
-BEGIN
- DECLARE vWeek INT;
- DECLARE vYear INT;
-
- SELECT week, year
- INTO vWeek, vYear
- FROM vn.time
- WHERE dated = TIMESTAMPADD(WEEK, -1, CURDATE());
-
- REPLACE bs.waste
- SELECT *, 100 * mermas / total as porcentaje
- FROM (
- SELECT buyer,
- year,
- week,
- family,
- itemFk,
- itemTypeFk,
- floor(sum(value)) as total,
- floor(sum(IF(clientTypeFk = 'loses', value, 0))) as mermas
- FROM vn.saleValue
- where year = vYear and week = vWeek
-
- GROUP BY family, itemFk
-
- ) sub
- ORDER BY mermas DESC;
-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 DROP PROCEDURE IF EXISTS `workerLabour_getData` */;
/*!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_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerLabour_getData`()
BEGIN
/**
* Carga los datos de la plantilla de trabajadores, altas y bajas en la tabla workerLabourDataByMonth para facilitar el cálculo del gráfico en grafana.
* Se carga el día 21 de cada mes, elimina los registros del último año y los vuelve a calcular
- *
*/
DECLARE vFristDay DATE;
DECLARE vLastDay DATE;
@@ -6916,10 +6569,10 @@ BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
- IF DAY(CURDATE()) = 21 THEN
+ IF DAY(util.VN_CURDATE()) = 21 THEN
- SELECT util.firstDayOfMonth(DATE_SUB(CURDATE(), INTERVAL 12 MONTH)),
- LAST_DAY(DATE_SUB(CURDATE(), INTERVAL 1 MONTH))
+ SELECT util.firstDayOfMonth(DATE_SUB(util.VN_CURDATE(), INTERVAL 12 MONTH)),
+ LAST_DAY(DATE_SUB(util.VN_CURDATE(), INTERVAL 1 MONTH))
INTO vDateStarted,
vDateEnded;
@@ -6941,7 +6594,7 @@ BEGIN
INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent)
SELECT 'hiring', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(wbt.isPermanent)
FROM vn.workerLabour w
- JOIN postgresql.workcenter wc ON wc.workcenter_id = w.workCenterFk
+ JOIN vn.workCenter wc ON wc.id = w.workCenterFk
JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk
JOIN postgresql.person p ON p.id_trabajador = w.workerFk
LEFT JOIN vn.workerBusinessType wbt ON wbt.id = bl.cod_contrato
@@ -6951,7 +6604,7 @@ BEGIN
AND wl.workerFk = w.workerFk
WHERE w.started BETWEEN vFristDay AND vLastDay AND wl.ended
)sub ON sub.workerFk = w.workerFk
- WHERE wc.center_id IS NOT NULL
+ WHERE wc.payrollCenterFk IS NOT NULL
AND w.started BETWEEN vFristDay AND vLastDay
AND sub.workerFk IS NULL
AND NOT p.isFreelance;
@@ -6960,16 +6613,16 @@ BEGIN
INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent)
SELECT 'layoffs', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(wbt.isPermanent)
FROM vn.workerLabour w
- JOIN postgresql.workcenter wc ON wc.workcenter_id = w.workCenterFk
+ JOIN vn.workCenter wc ON wc.id = w.workCenterFk
JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk
JOIN postgresql.person p ON p.id_trabajador = w.workerFk
LEFT JOIN vn.workerBusinessType wbt ON wbt.id = bl.cod_contrato
LEFT JOIN (SELECT started, workerFk FROM vn.workerLabour) wl ON wl.started >= w.ended
AND wl.workerFk = w.workerFk
- WHERE wc.center_id IS NOT NULL
+ WHERE wc.payrollCenterFk IS NOT NULL
AND w.ended BETWEEN vFristDay AND vLastDay
AND wl.started IS NULL
- AND NOT p.isFreelance;
+ AND NOT p.isFreelance;
-- Anterior al periodo
SET vLastDay = LAST_DAY(DATE_SUB(vFristDay, INTERVAL 1 DAY));
@@ -6977,11 +6630,11 @@ BEGIN
INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent)
SELECT 'staff', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(wbt.isPermanent)
FROM vn.workerLabour w
- JOIN postgresql.workcenter wc ON wc.workcenter_id = w.workCenterFk
+ JOIN vn.workCenter wc ON wc.id = w.workCenterFk
JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk
JOIN postgresql.person p ON p.id_trabajador = w.workerFk
LEFT JOIN vn.workerBusinessType wbt ON wbt.id = bl.cod_contrato
- WHERE wc.center_id IS NOT NULL
+ WHERE wc.payrollCenterFk IS NOT NULL
AND vLastDay BETWEEN started AND IFNULL(ended, vLastDay)
AND NOT p.isFreelance;
@@ -6989,138 +6642,15 @@ BEGIN
INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent)
SELECT 'disabled', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(wbt.isPermanent)
FROM vn.workerLabour w
- JOIN postgresql.workcenter wc ON wc.workcenter_id = w.workCenterFk
+ JOIN vn.workCenter wc ON wc.id = w.workCenterFk
JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk
JOIN postgresql.person p ON p.id_trabajador = w.workerFk
LEFT JOIN vn.workerBusinessType wbt ON wbt.id = bl.cod_contrato
- WHERE wc.center_id IS NOT NULL
+ WHERE wc.payrollCenterFk IS NOT NULL
AND vLastDay BETWEEN started AND IFNULL(ended, vLastDay)
AND p.isDisable
- AND NOT p.isFreelance;
-
- END LOOP;
- CLOSE vCursor;
-
- 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 DROP PROCEDURE IF EXISTS `workerLabour_getData__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `workerLabour_getData__`()
-BEGIN
-/**
- * Carga los datos de la plantilla de trabajadores, altas y bajas en la tabla workerLabourDataByMonth para facilitar el cálculo del gráfico en grafana.
- * Se carga el día 21 de cada mes, elimina los registros del último año y los vuelve a calcular
- *
- */
- DECLARE vFristDay DATE;
- DECLARE vLastDay DATE;
- DECLARE vDone BOOL DEFAULT FALSE;
- DECLARE vDateStarted DATE;
- DECLARE vDateEnded DATE;
-
- DECLARE vCursor CURSOR FOR
- SELECT util.firstDayOfMonth(t.dated), LAST_DAY(t.dated)
- FROM vn.time t
- WHERE t.dated BETWEEN vDateStarted AND vDateEnded
- GROUP BY year,month;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
-
- IF DAY(CURDATE()) = 21 THEN
-
- SELECT util.firstDayOfMonth(DATE_SUB(CURDATE(), INTERVAL 12 MONTH)),
- LAST_DAY(DATE_SUB(CURDATE(), INTERVAL 1 MONTH))
- INTO vDateStarted,
- vDateEnded;
-
- DELETE FROM workerLabourDataByMonth
- WHERE CONCAT(`year`, '-',`month`, '-01') BETWEEN vDateStarted AND vDateEnded;
-
- OPEN vCursor;
-
- l: LOOP
- SET vDone = FALSE;
-
- FETCH vCursor INTO vFristDay, vLastDay;
-
- IF vDone THEN
- LEAVE l;
- END IF;
-
- -- Altas periodo
- INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent)
- SELECT 'hiring', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(pc.isPermanent)
- FROM vn.workerLabour w
- JOIN postgresql.workcenter wc ON wc.workcenter_id = w.workCenterFk
- JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk
- JOIN postgresql.person p ON p.id_trabajador = w.workerFk
- LEFT JOIN vn2008.payroll_contratos pc ON pc.CodContrato = bl.cod_contrato
- LEFT JOIN (SELECT w.workerFk
- FROM vn.workerLabour w
- LEFT JOIN (SELECT ended, workerFk FROM vn.workerLabour) wl ON wl.ended = DATE_SUB(w.started, INTERVAL 1 DAY)
- AND wl.workerFk = w.workerFk
- WHERE w.started BETWEEN vFristDay AND vLastDay AND wl.ended
- )sub ON sub.workerFk = w.workerFk
- WHERE wc.center_id IS NOT NULL
- AND w.started BETWEEN vFristDay AND vLastDay
- AND sub.workerFk IS NULL
- AND NOT p.isFreelance;
-
- -- Bajas periodo
- INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent)
- SELECT 'layoffs', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(pc.isPermanent)
- FROM vn.workerLabour w
- JOIN postgresql.workcenter wc ON wc.workcenter_id = w.workCenterFk
- JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk
- JOIN postgresql.person p ON p.id_trabajador = w.workerFk
- LEFT JOIN vn2008.payroll_contratos pc ON pc.CodContrato = bl.cod_contrato
- LEFT JOIN (SELECT started, workerFk FROM vn.workerLabour) wl ON wl.started >= w.ended
- AND wl.workerFk = w.workerFk
- WHERE wc.center_id IS NOT NULL
- AND w.ended BETWEEN vFristDay AND vLastDay
- AND wl.started IS NULL
- AND NOT p.isFreelance;
-
- -- Anterior al periodo
- SET vLastDay = LAST_DAY(DATE_SUB(vFristDay, INTERVAL 1 DAY));
-
- INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent)
- SELECT 'staff', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(pc.isPermanent)
- FROM vn.workerLabour w
- JOIN postgresql.workcenter wc ON wc.workcenter_id = w.workCenterFk
- JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk
- JOIN postgresql.person p ON p.id_trabajador = w.workerFk
- LEFT JOIN vn2008.payroll_contratos pc ON pc.CodContrato = bl.cod_contrato
- WHERE wc.center_id IS NOT NULL
- AND vLastDay BETWEEN started AND IFNULL(ended, vLastDay)
AND NOT p.isFreelance;
- -- Discapacidad
- INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent)
- SELECT 'disabled', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(pc.isPermanent)
- FROM vn.workerLabour w
- JOIN postgresql.workcenter wc ON wc.workcenter_id = w.workCenterFk
- JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk
- JOIN postgresql.person p ON p.id_trabajador = w.workerFk
- LEFT JOIN vn2008.payroll_contratos pc ON pc.CodContrato = bl.cod_contrato
- WHERE wc.center_id IS NOT NULL
- AND vLastDay BETWEEN started AND IFNULL(ended, vLastDay)
- AND p.isDisable
- AND NOT p.isFreelance;
-
END LOOP;
CLOSE vCursor;
@@ -7131,6 +6661,8 @@ DELIMITER ;
/*!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 `workerProductivity_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -7138,13 +6670,11 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerProductivity_add`()
BEGIN
DECLARE vDateFrom DATE;
- SELECT DATE_SUB(CURDATE(),INTERVAL 30 DAY) INTO vDateFrom;
+ SELECT DATE_SUB(util.VN_CURDATE(),INTERVAL 30 DAY) INTO vDateFrom;
DELETE FROM workerProductivity
WHERE dated >= vDateFrom;
@@ -7244,6 +6774,8 @@ DELIMITER ;
/*!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 `zone_ETD_byTime` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -7251,29 +6783,25 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_ETD_byTime`()
BEGIN
-
SET @m := 0;
SELECT MAX(hourTheoretical) INTO @h
FROM vn.zoneEstimatedDelivery ze
- WHERE ze.remainingVolume ;
+ WHERE ze.remainingVolume ;
DROP TEMPORARY TABLE IF EXISTS tmpZone;
-
CREATE TEMPORARY TABLE tmpZone
SELECT remainingVolume,
hourTheoretical,
@m := @m + minutesLess + HOUR(TIMEDIFF(@h, hourTheoretical)) * 60 + MINUTE(TIMEDIFF(@h, hourTheoretical)) totalMinutes,
- @h := hourTheoretical
+ @h := hourTheoretical previousHourTheoretical
FROM vn.zoneEstimatedDelivery ze
WHERE ze.remainingVolume
ORDER BY ze.hourTheoretical DESC;
-
+
TRUNCATE bs.zone_ETD_byTime ;
INSERT INTO bs.zone_ETD_byTime(theorical, practical, m3)
@@ -7284,7 +6812,6 @@ BEGIN
GROUP BY tz.hourTheoretical;
DROP TEMPORARY TABLE tmpZone;
-
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -7431,11 +6958,12 @@ DROP TABLE IF EXISTS `last_buy`;
CREATE TABLE `last_buy` (
`item_id` int(10) unsigned NOT NULL,
`warehouse_id` smallint(5) unsigned NOT NULL,
- `buy_id` int(10) unsigned DEFAULT NULL,
+ `buy_id` int(11) DEFAULT NULL,
`landing` date DEFAULT NULL,
UNIQUE KEY `item_id` (`item_id`,`warehouse_id`) USING HASH,
KEY `buy_id` (`buy_id`),
- KEY `warehouse_id` (`warehouse_id`) USING BTREE
+ KEY `warehouse_id` (`warehouse_id`) USING BTREE,
+ CONSTRAINT `last_buy_FK_1` FOREIGN KEY (`warehouse_id`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -7554,6 +7082,8 @@ DELIMITER ;
--
-- Dumping routines for database 'cache'
--
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `addressFriendship_Update` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -7561,8 +7091,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `addressFriendship_Update`()
BEGIN
@@ -7574,8 +7102,8 @@ BEGIN
SELECT t.routeFk, t.zoneFk, t.addressFk addressFk1, t2.addressFk addressFk2
FROM vn.ticket t
JOIN vn.ticket t2 USING(routeFk, zoneFk)
- WHERE t.shipped >= TIMESTAMPADD(MONTH,-3,CURDATE())
- AND t2.shipped >= TIMESTAMPADD(MONTH,-3,CURDATE())
+ WHERE t.shipped >= TIMESTAMPADD(MONTH,-3,util.VN_CURDATE())
+ AND t2.shipped >= TIMESTAMPADD(MONTH,-3,util.VN_CURDATE())
AND t.addressFk != t2.addressFk) sub
GROUP BY addressFk1, addressFk2;
@@ -7583,7 +7111,7 @@ BEGIN
SELECT r.agencyModeFk, t.zoneFk, count(*) friendship
FROM vn.route r
JOIN vn.ticket t ON t.routeFk = r.id
- WHERE t.shipped >= TIMESTAMPADD(MONTH,-3,CURDATE())
+ WHERE t.shipped >= TIMESTAMPADD(MONTH,-3,util.VN_CURDATE())
AND r.agencyModeFk
AND t.routeFk
AND t.zoneFk
@@ -7594,6 +7122,8 @@ DELIMITER ;
/*!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 `availableNoRaids_refresh` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -7601,8 +7131,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `availableNoRaids_refresh`(OUT `vCalc` INT, IN `vRefresh` INT, IN `vWarehouse` INT, IN `vDate` DATE)
proc: BEGIN
@@ -7618,7 +7146,7 @@ proc: BEGIN
RESIGNAL;
END;
- IF vDate < CURDATE() THEN
+ IF vDate < util.VN_CURDATE() THEN
LEAVE proc;
END IF;
@@ -7631,14 +7159,14 @@ proc: BEGIN
LEAVE proc;
END IF;
- -- Calcula algunos parámetros necesarios
+ -- Calcula algunos parametros necesarios
SET vStartDate = TIMESTAMP(vDate, '00:00:00');
SET vEndDate = TIMESTAMP(TIMESTAMPADD(DAY, 4, vDate), '23:59:59');
SELECT inventoried INTO vInventoryDate FROM vn.config;
- SELECT SUBTIME(NOW(), reserveTime) INTO vReserveDate
+ SELECT SUBTIME(util.VN_NOW(), reserveTime) INTO vReserveDate
FROM hedera.orderConfig;
-- Calcula el ultimo dia de vida para cada producto
@@ -7752,6 +7280,8 @@ DELIMITER ;
/*!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 `available_clean` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -7759,8 +7289,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `available_clean`()
BEGIN
@@ -7787,6 +7315,8 @@ DELIMITER ;
/*!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 `available_refresh` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -7794,13 +7324,10 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `available_refresh`(OUT `vCalc` INT, IN `vRefresh` INT, IN `vWarehouse` INT, IN `vDate` DATE)
proc: BEGIN
DECLARE vStartDate DATE;
- DECLARE vEndDate DATETIME;
DECLARE vReserveDate DATETIME;
DECLARE vParams CHAR(100);
DECLARE vInventoryDate DATE;
@@ -7812,7 +7339,7 @@ proc: BEGIN
RESIGNAL;
END;
- IF vDate < CURDATE() THEN
+ IF vDate < util.VN_CURDATE() THEN
LEAVE proc;
END IF;
@@ -7827,24 +7354,23 @@ proc: BEGIN
-- Invoca al procedimiento que genera el stock virtual de Logiflora, si coincide con la peticion de refresco del disponible
IF vn.isLogifloraDay(vDate, vWarehouse) THEN
-
+
-- CALL edi.floramondo_offerRefresh;
SET vIsLogifloraDay = TRUE;
-
+
ELSE
-
+
SET vIsLogifloraDay = FALSE;
-
- END IF;
-
+
+ END IF;
+
-- Calcula algunos parámetros necesarios
SET vStartDate = TIMESTAMP(vDate, '00:00:00');
- SET vEndDate = TIMESTAMP(TIMESTAMPADD(DAY, 4, vDate), '23:59:59');
SELECT inventoried INTO vInventoryDate FROM vn.config;
- SELECT SUBTIME(NOW(), reserveTime) INTO vReserveDate
+ SELECT SUBTIME(util.VN_NOW(), reserveTime) INTO vReserveDate
FROM hedera.orderConfig;
-- Calcula el ultimo dia de vida para cada producto
@@ -7863,7 +7389,7 @@ proc: BEGIN
JOIN vn.warehouse w ON w.id = t.warehouseInFk
WHERE t.landed BETWEEN vInventoryDate AND vStartDate
AND t.warehouseInFk = vWarehouse
- AND NOT e.isInventory
+ AND NOT e.isExcludedFromAvailable
GROUP BY b.itemFk
) c
JOIN vn.item i ON i.id = c.item_id
@@ -7876,17 +7402,17 @@ proc: BEGIN
CREATE TEMPORARY TABLE item_range_copy1 LIKE item_range;
INSERT INTO item_range_copy1
SELECT * FROM item_range;
-
+
DROP TEMPORARY TABLE IF EXISTS item_range_copy2;
CREATE TEMPORARY TABLE item_range_copy2 LIKE item_range;
INSERT INTO item_range_copy2
SELECT * FROM item_range;
-
+
DROP TEMPORARY TABLE IF EXISTS item_range_copy3;
CREATE TEMPORARY TABLE item_range_copy3 LIKE item_range;
INSERT INTO item_range_copy3
SELECT * FROM item_range;
-
+
DROP TEMPORARY TABLE IF EXISTS item_range_copy4;
CREATE TEMPORARY TABLE item_range_copy4 LIKE item_range;
INSERT INTO item_range_copy4
@@ -7902,8 +7428,10 @@ proc: BEGIN
FROM tmp.itemList il
JOIN item_range ir ON ir.item_id = il.itemFk
UNION ALL
- SELECT t.item_id, minacum(dt, amount, vDate) AS available FROM (
- SELECT itemFk AS item_id, DATE(dat) dt, SUM(quantity) amount FROM (
+ SELECT t.item_id, minacum(dt, amount, vDate) AS available
+ FROM (
+ SELECT itemFk AS item_id, DATE(dat) dt, SUM(quantity) amount
+ FROM (
SELECT i.itemFk, i.shipped AS dat, i.quantity
FROM vn.itemTicketOut i
JOIN item_range_copy1 ir ON ir.item_id = i.itemFk
@@ -7950,7 +7478,6 @@ proc: BEGIN
,item_range_copy3
,item_range_copy4;
-
CALL cache_calc_end (vCalc);
END ;;
DELIMITER ;
@@ -7958,6 +7485,8 @@ DELIMITER ;
/*!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 `cacheCalc_clean` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -7965,12 +7494,10 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `cacheCalc_clean`()
BEGIN
- DECLARE vCleanTime DATETIME DEFAULT TIMESTAMPADD(MINUTE, -5, NOW());
+ DECLARE vCleanTime DATETIME DEFAULT TIMESTAMPADD(MINUTE, -5, util.VN_NOW());
DELETE FROM cache_calc WHERE expires < vCleanTime;
END ;;
DELIMITER ;
@@ -7978,6 +7505,8 @@ DELIMITER ;
/*!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 `cache_calc_end` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -7985,8 +7514,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `cache_calc_end`(IN `v_calc` INT)
BEGIN
@@ -7997,8 +7524,8 @@ BEGIN
UPDATE cache_calc cc JOIN cache c ON c.id = cc.cache_id
SET
- cc.last_refresh = NOW(),
- cc.expires = LEAST(ADDTIME(NOW(), c.lifetime), util.midNight()),
+ cc.last_refresh = util.VN_NOW(),
+ cc.expires = LEAST(ADDTIME(util.VN_NOW(), c.lifetime), util.midNight()),
cc.connection_id = NULL
WHERE cc.id = v_calc;
@@ -8016,6 +7543,8 @@ DELIMITER ;
/*!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 `cache_calc_start` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -8023,8 +7552,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `cache_calc_start`(OUT `v_calc` INT, INOUT `v_refresh` INT, IN `v_cache_name` VARCHAR(50), IN `v_params` VARCHAR(100))
proc: BEGIN
@@ -8077,7 +7604,7 @@ proc: BEGIN
-- Si existe una calculo valido libera el bloqueo y devuelve su identificador.
- IF !v_refresh AND NOW() < v_expires
+ IF !v_refresh AND util.VN_NOW() < v_expires
THEN
DO RELEASE_LOCK(v_lock_id);
SET v_refresh = FALSE;
@@ -8115,6 +7642,8 @@ DELIMITER ;
/*!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 `cache_calc_unlock` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -8122,8 +7651,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `cache_calc_unlock`(IN `v_calc` INT)
proc: BEGIN
@@ -8150,6 +7677,8 @@ DELIMITER ;
/*!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 `cache_clean` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -8157,8 +7686,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `cache_clean`()
NO SQL
@@ -8171,6 +7698,8 @@ DELIMITER ;
/*!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 `clean` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -8178,15 +7707,13 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `clean`()
BEGIN
DECLARE vDateShort DATETIME;
- SET vDateShort = TIMESTAMPADD(MONTH, -1, CURDATE());
+ SET vDateShort = TIMESTAMPADD(MONTH, -1, util.VN_CURDATE());
DELETE FROM cache.departure_limit WHERE Fecha < vDateShort;
END ;;
@@ -8195,6 +7722,8 @@ DELIMITER ;
/*!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 `departure_timing` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -8202,8 +7731,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `departure_timing`(vWarehouseId INT)
BEGIN
@@ -8223,11 +7750,11 @@ DECLARE vLoadingDelay DECIMAL(5) DEFAULT 2;
DECLARE rs CURSOR FOR
SELECT Departure
, Sum(pb.m3)/(GREATEST(IFNULL(lhp.m3,0),IFNULL(dp.minSpeed,0))) AS Horas
- , curDate()+(Departure + vLoadingDelay -(Sum(pb.m3)/(GREATEST(IFNULL(lhp.m3,0),IFNULL(minSpeed,0))))/24) AS InicioPreparacion
+ , util.VN_CURDATE()+(Departure + vLoadingDelay -(Sum(pb.m3)/(GREATEST(IFNULL(lhp.m3,0),IFNULL(minSpeed,0))))/24) AS InicioPreparacion
FROM tmp.production_buffer pb
LEFT JOIN vn.lastHourProduction lhp ON lhp.warehouseFk = pb.warehouse_id
- LEFT JOIN cache.departure_limit dp ON dp.warehouse_id = pb.warehouse_id AND dp.fecha = CURDATE()
- WHERE pb.Fecha = CURDATE()
+ LEFT JOIN cache.departure_limit dp ON dp.warehouse_id = pb.warehouse_id AND dp.fecha = util.VN_CURDATE()
+ WHERE pb.Fecha = util.VN_CURDATE()
AND pb.graphCategory > 1
AND IFNULL(Departure,0) > 0
GROUP BY Departure
@@ -8235,7 +7762,7 @@ DECLARE rs CURSOR FOR
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
- SET myTime = HOUR(now()) + MINUTE(now()) / 60;
+ SET myTime = HOUR(util.VN_NOW()) + MINUTE(util.VN_NOW()) / 60;
OPEN rs;
@@ -8269,10 +7796,10 @@ DECLARE rs CURSOR FOR
SELECT minSpeed INTO myMinSpeed
FROM cache.departure_limit
WHERE warehouse_id = vWarehouseId
- AND fecha = CURDATE();
+ AND fecha = util.VN_CURDATE();
REPLACE cache.departure_limit(warehouse_id, fecha, hora, minSpeed)
- VALUES (vWarehouseId, CURDATE(), departureLimit, IFNULL(myMinSpeed,0));
+ VALUES (vWarehouseId, util.VN_CURDATE(), departureLimit, IFNULL(myMinSpeed,0));
CLOSE rs;
@@ -8282,95 +7809,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `departure_timing_beta__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `departure_timing_beta__`(vWarehouseId INT)
-BEGIN
-
-DECLARE done BOOL DEFAULT FALSE;
-DECLARE rsDeparture INT;
-DECLARE rsHoras DECIMAL(5,2);
-DECLARE rsInicio DECIMAL(5,2);
-DECLARE resto DECIMAL(5,2);
-DECLARE horasProd DECIMAL(5,2);
-DECLARE inicioProd DECIMAL(5,2) DEFAULT 24.00;
-DECLARE myTime DECIMAL(5,2);
-DECLARE departureLimit INT;
-
-DECLARE rs CURSOR FOR
- SELECT Departure
- , Sum(pb.m3)/GREATEST(v.m3,IFNULL(minSpeed,0)) AS Horas
- , curDate()+(Departure-(Sum(pb.m3)/GREATEST(v.m3,IFNULL(minSpeed,0)))/24) AS InicioPreparacion
- FROM tmp.production_buffer pb
- JOIN vn2008.v_encajado_ultima_hora v ON v.warehouse_id = pb.warehouse_id
- LEFT JOIN cache.departure_limit dp ON dp.warehouse_id = pb.warehouse_id AND dp.fecha = CURDATE()
- WHERE pb.Fecha = CURDATE()
- AND alert_level < 2
- AND IFNULL(Departure,0) > 0
- GROUP BY Departure
- ORDER BY Departure DESC;
-
-DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
-
-SET myTime = HOUR(now()) + MINUTE(now()) / 60;
-
-OPEN rs;
-
-FETCH rs INTO rsDeparture, rsHoras , rsInicio;
-
-SELECT rsDeparture, rsHoras , rsInicio, vWarehouseId, done;
-
-WHILE NOT done DO
-
- SET resto = IF(inicioProd < rsDeparture, rsDeparture - inicioProd,0);
-
- SET inicioProd = rsDeparture - rsHoras;
-
- SELECT rsDeparture, rsHoras , rsInicio, resto,inicioProd;
-
- IF inicioProd - resto < myTime THEN
-
- SET done = TRUE;
-
- ELSE
-
- SET departureLimit = rsDeparture;
-
- FETCH rs INTO rsDeparture, rsHoras , rsInicio;
-
- END IF;
-
-END WHILE;
-
-SELECT rsDeparture, rsHoras , rsInicio, resto,inicioProd;
-
-
-SET departureLimit = IFNULL(departureLimit,24);
-
-IF departureLimit > 0 THEN
-
- REPLACE cache.departure_limit(warehouse_id, fecha, hora, minSpeed)
- VALUES (vWarehouseId, CURDATE(), departureLimit, myMinSpeed);
-
-END IF;
-
-CLOSE rs;
-
-
-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 sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `last_buy_refresh` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -8378,8 +7818,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `last_buy_refresh`(vRefresh BOOL)
proc: BEGIN
@@ -8410,7 +7848,7 @@ proc: BEGIN
-- TODO: ¿Se puede usar la fecha del ultimo inventario?
SELECT inventoried INTO started FROM vn.config LIMIT 1;
- SET ended = CURDATE(); -- TIMESTAMPADD(DAY, -1, CURDATE());
+ SET ended = util.VN_CURDATE(); -- TIMESTAMPADD(DAY, -1, util.VN_CURDATE());
CALL vn.buyUltimateFromInterval(NULL, started, ended);
@@ -8429,6 +7867,8 @@ DELIMITER ;
/*!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 `prod_graphic_refresh` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -8436,8 +7876,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prod_graphic_refresh`(v_refresh BOOL, wh_id INT)
proc: BEGIN
@@ -8466,7 +7904,7 @@ proc: BEGIN
pb.Agencia
FROM tmp.production_buffer pb
JOIN vn.state st ON st.id = pb.state
- WHERE Fecha = CURDATE()
+ WHERE Fecha = util.VN_CURDATE()
GROUP BY wh_id, graphCategory
;
@@ -8478,6 +7916,8 @@ DELIMITER ;
/*!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 `stock_refresh` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -8485,8 +7925,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `stock_refresh`(v_refresh BOOL)
proc: BEGIN
@@ -8516,7 +7954,7 @@ proc: BEGIN
END IF;
SET v_date_inv = (SELECT inventoried FROM vn.config LIMIT 1);
- SET v_curdate = CURDATE();
+ SET v_curdate = util.VN_CURDATE();
DELETE FROM stock;
@@ -8544,70 +7982,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `stock_refresh__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `stock_refresh__`(v_refresh BOOL)
-proc: BEGIN
-/**
- * bernat: WORKING IN THIS FILE
- * Crea o actualiza la cache con el disponible hasta el día de
- * ayer. Esta cache es usada como base para otros procedimientos
- * como el cáculo del visible o del ATP.
- *
- * @param v_refresh %TRUE para forzar el recálculo de la cache
- **/
- DECLARE v_calc INT;
- DECLARE v_date_inv DATE;
- DECLARE v_curdate DATE;
- DECLARE v_last_refresh DATETIME;
-
- DECLARE EXIT HANDLER FOR SQLEXCEPTION
- BEGIN
- CALL cache_calc_unlock (v_calc);
- RESIGNAL;
- END;
-
- CALL cache_calc_start (v_calc, v_refresh, 'stock', NULL);
-
- IF !v_refresh
- THEN
- LEAVE proc;
- END IF;
-
- SET v_date_inv = (SELECT FechaInventario FROM vn2008.tblContadores LIMIT 1);
- SET v_curdate = CURDATE();
-
- DELETE FROM stock;
-
- INSERT INTO stock (item_id, warehouse_id, amount)
- SELECT item_id, warehouse_id, SUM(amount) amount FROM
- (
- SELECT item_id, warehouse_id, amount FROM vn2008.item_out
- WHERE dat >= v_date_inv AND dat < v_curdate
- UNION ALL
- SELECT item_id, warehouse_id, amount FROM vn2008.item_entry_in
- WHERE dat >= v_date_inv AND dat < v_curdate AND isVirtualStock is FALSE
- UNION ALL
- SELECT item_id ,warehouse_id, amount FROM vn2008.item_entry_out
- WHERE dat >= v_date_inv AND dat < v_curdate
- ) t
- GROUP BY item_id, warehouse_id HAVING amount != 0;
-
- CALL cache_calc_end (v_calc);
-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 DROP PROCEDURE IF EXISTS `visible_clean` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -8615,8 +7991,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `visible_clean`()
BEGIN
@@ -8638,6 +8012,8 @@ DELIMITER ;
/*!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 `visible_refresh` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -8645,8 +8021,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `visible_refresh`(OUT v_calc INT, v_refresh BOOL, v_warehouse INT)
proc: BEGIN
@@ -8674,63 +8048,7 @@ proc: BEGIN
WHERE warehouse_id = v_warehouse;
-- Calculamos los movimientos confirmados de hoy
-
- CALL vn.item_GetVisible(v_warehouse, NULL);
-
- DELETE FROM visible WHERE calc_id = v_calc;
-
- INSERT INTO visible (calc_id, item_id,visible)
- SELECT v_calc, item_id, visible FROM vn2008.tmp_item;
-
- CALL cache_calc_end (v_calc);
-
- DROP TEMPORARY TABLE vn2008.tmp_item;
-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 DROP PROCEDURE IF EXISTS `visible_refresh__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `visible_refresh__`(OUT v_calc INT, v_refresh BOOL, v_warehouse INT)
-proc: BEGIN
- -- bernat working in this file
- DECLARE EXIT HANDLER FOR SQLEXCEPTION
- BEGIN
- CALL cache_calc_unlock (v_calc);
- RESIGNAL;
- END;
-
- CALL cache_calc_start (v_calc, v_refresh, 'visible', v_warehouse);
-
- IF !v_refresh THEN
- LEAVE proc;
- END IF;
-
- -- Calculamos el stock hasta ayer
-
- CALL `cache`.stock_refresh(false);
-
- DROP TEMPORARY TABLE IF EXISTS vn2008.tmp_item;
- CREATE TEMPORARY TABLE vn2008.tmp_item
- (PRIMARY KEY (item_id))
- ENGINE = MEMORY
- SELECT item_id, amount stock, amount visible FROM `cache`.stock
- WHERE warehouse_id = v_warehouse;
-
- -- Calculamos los movimientos confirmados de hoy
-
- CALL vn2008.item_stock_visible(v_warehouse, NULL);
-
+ CALL vn.item_GetVisible(v_warehouse, NULL);
DELETE FROM visible WHERE calc_id = v_calc;
INSERT INTO visible (calc_id, item_id,visible)
@@ -8932,31 +8250,32 @@ DROP TABLE IF EXISTS `ekt`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `ekt` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `barcode` char(15) COLLATE utf8_unicode_ci DEFAULT NULL,
- `entryYear` smallint(5) unsigned NOT NULL,
- `deliveryNumber` bigint(20) unsigned DEFAULT NULL,
- `fec` date DEFAULT NULL,
- `hor` time DEFAULT NULL,
- `now` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
- `ptj` mediumint(8) unsigned DEFAULT NULL,
- `ref` int(11) NOT NULL,
- `item` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
- `pac` int(11) DEFAULT '0',
- `qty` int(10) NOT NULL,
- `ori` varchar(3) COLLATE utf8_unicode_ci DEFAULT 'NL',
- `cat` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL,
- `agj` int(11) DEFAULT NULL,
- `kop` int(11) DEFAULT NULL,
- `ptd` varchar(6) COLLATE utf8_unicode_ci DEFAULT NULL,
- `sub` mediumint(8) unsigned DEFAULT NULL,
- `pro` mediumint(8) unsigned NOT NULL,
- `pri` double NOT NULL,
- `package` int(10) unsigned DEFAULT NULL,
- `auction` smallint(5) unsigned DEFAULT NULL,
- `klo` smallint(5) unsigned DEFAULT NULL,
- `k1` smallint(5) unsigned DEFAULT NULL,
- `k2` smallint(5) unsigned DEFAULT NULL,
+ `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Id',
+ `barcode` char(15) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Generated auction barcode',
+ `entryYear` smallint(5) unsigned NOT NULL COMMENT 'Transaction year',
+ `batchNumber` bigint(20) unsigned DEFAULT NULL COMMENT 'RFF+BT',
+ `deliveryNumber` bigint(20) unsigned DEFAULT NULL COMMENT 'RFF+AAJ',
+ `fec` date DEFAULT NULL COMMENT 'DTM+97',
+ `hor` time DEFAULT NULL COMMENT 'UNB',
+ `util.VN_NOW` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time',
+ `ptj` mediumint(8) unsigned DEFAULT NULL COMMENT 'NAD+BY',
+ `ref` int(11) NOT NULL COMMENT 'LIN',
+ `item` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'IMD+S99',
+ `pac` int(11) DEFAULT '0' COMMENT 'QTY+52',
+ `qty` int(10) NOT NULL COMMENT 'QTY+66',
+ `ori` varchar(3) COLLATE utf8_unicode_ci DEFAULT 'NL' COMMENT 'IMD+S62',
+ `cat` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'IMD+S98',
+ `agj` int(11) DEFAULT NULL COMMENT 'RFF+AGJ',
+ `kop` int(11) DEFAULT NULL COMMENT 'RFF+ADZ',
+ `ptd` varchar(6) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'RFF+ACE',
+ `sub` mediumint(8) unsigned DEFAULT NULL COMMENT 'RFF+CTS',
+ `pro` mediumint(8) unsigned NOT NULL COMMENT 'NAD+MF',
+ `pri` double NOT NULL COMMENT 'PRI+INV',
+ `package` int(10) unsigned DEFAULT NULL COMMENT 'PAC',
+ `auction` smallint(5) unsigned DEFAULT NULL COMMENT 'NAD+FLA',
+ `klo` smallint(5) unsigned DEFAULT NULL COMMENT 'RFF+FAC',
+ `k1` smallint(5) unsigned DEFAULT NULL COMMENT 'IMD+K01',
+ `k2` smallint(5) unsigned DEFAULT NULL COMMENT 'IMD+K02',
`k3` tinyint(3) unsigned DEFAULT NULL,
`k4` tinyint(3) unsigned DEFAULT NULL,
`s1` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL,
@@ -8967,8 +8286,8 @@ CREATE TABLE `ekt` (
`s6` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL,
`ok` tinyint(4) NOT NULL DEFAULT '0',
`trolleyFk` int(11) DEFAULT NULL,
- `putOrderFk` bigint(20) unsigned DEFAULT NULL,
- `scanned` tinyint(1) NOT NULL DEFAULT '0',
+ `putOrderFk` bigint(20) unsigned DEFAULT NULL COMMENT 'RFF+ON',
+ `scanned` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Whether it''s been scanned',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `barcode_year` (`barcode`,`entryYear`),
UNIQUE KEY `entry_year` (`deliveryNumber`,`entryYear`) USING BTREE,
@@ -9464,6 +8783,7 @@ CREATE TABLE `param` (
`type` enum('INTEGER','DOUBLE','STRING','DATE','TIME') COLLATE utf8_unicode_ci NOT NULL,
`required` tinyint(3) unsigned NOT NULL DEFAULT '1',
PRIMARY KEY (`id`),
+ UNIQUE KEY `code` (`code`),
UNIQUE KEY `name` (`name`,`subname`)
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Parameters to capture of every exchange';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -9618,7 +8938,7 @@ BEGIN
JOIN vn.ticket t ON s.ticketFk = t.id
JOIN vn.item i ON i.id = s.itemFk
JOIN deliveryInformation di ON di.ID = NEW.deliveryInformationID
- WHERE t.clientFk = NEW.EndUserPartyGLN AND t.shipped >= CURDATE()
+ WHERE t.clientFk = NEW.EndUserPartyGLN AND t.shipped >= util.VN_CURDATE()
AND i.supplyResponseFk = NEW.supplyResponseID
LIMIT 1;
@@ -9627,7 +8947,7 @@ BEGIN
JOIN vn.item i ON i.id = s.itemFk
JOIN deliveryInformation di ON di.ID = NEW.deliveryInformationID
SET s.quantity = 0
- WHERE t.clientFk = NEW.EndUserPartyGLN AND t.shipped >= CURDATE()
+ WHERE t.clientFk = NEW.EndUserPartyGLN AND t.shipped >= util.VN_CURDATE()
AND i.supplyResponseFk = NEW.supplyResponseID;
INSERT INTO vn.mail (sender, `subject`, body)
@@ -9877,7 +9197,7 @@ BEGIN
WHERE i.supplyResponseFk = NEW.ID
AND am.name = 'LOGIFLORA'
AND e.isRaid
- AND tr.landed >= CURDATE();
+ AND tr.landed >= util.VN_CURDATE();
END */;;
DELIMITER ;
@@ -9990,6 +9310,8 @@ DELIMITER ;
--
-- Dumping routines for database 'edi'
--
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP FUNCTION IF EXISTS `imageName` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -9997,8 +9319,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `imageName`(vPictureReference VARCHAR(255)) RETURNS varchar(255) CHARSET utf8 COLLATE utf8_unicode_ci
DETERMINISTIC
@@ -10024,6 +9344,8 @@ DELIMITER ;
/*!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 `clean` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -10031,14 +9353,12 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `clean`()
BEGIN
- DECLARE vFourYearsAgo DATE DEFAULT TIMESTAMPADD(YEAR,-4,CURDATE());
- DECLARE vOneWeekAgo DATE DEFAULT TIMESTAMPADD(WEEK,-1,CURDATE());
+ DECLARE vFourYearsAgo DATE DEFAULT TIMESTAMPADD(YEAR,-4,util.VN_CURDATE());
+ DECLARE vOneWeekAgo DATE DEFAULT TIMESTAMPADD(WEEK,-1,util.VN_CURDATE());
DELETE FROM ekt WHERE fec < vFourYearsAgo;
@@ -10048,7 +9368,7 @@ BEGIN
WHERE di.LatestOrderDateTime < vOneWeekAgo OR di.ID IS NULL;
DELETE FROM putOrder
- WHERE created < TIMESTAMPADD(MONTH,-1,CURDATE());
+ WHERE created < TIMESTAMPADD(MONTH,-1,util.VN_CURDATE());
END ;;
DELIMITER ;
@@ -10056,6 +9376,8 @@ DELIMITER ;
/*!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 `deliveryInformation_Delete` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -10063,8 +9385,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `deliveryInformation_Delete`()
BEGIN
@@ -10095,6 +9415,8 @@ DELIMITER ;
/*!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 `ekt_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -10102,8 +9424,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ekt_add`(vPutOrderFk INT)
BEGIN
@@ -10135,7 +9455,7 @@ BEGIN
putOrderFk,
`ref`,
kop)
- SELECT year(curdate()) entryYear,
+ SELECT year(util.VN_CURDATE()) entryYear,
p.id deliveryNumber ,
DATE(di.LatestDeliveryDateTime) fec,
HOUR(di.LatestDeliveryDateTime) hor,
@@ -10172,6 +9492,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ekt_load` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -10179,8 +9501,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ekt_load`(IN `vSelf` INT)
proc:BEGIN
@@ -10304,7 +9624,7 @@ proc:BEGIN
AND IF(t.package, l.package = e.package, TRUE)
AND IF(t.item, l.item = e.item, TRUE)
AND i.isFloramondo = vIsFloramondoDirect
- ORDER BY l.now DESC, b.id ASC
+ ORDER BY l.util.VN_NOW DESC, b.id ASC
LIMIT 1;
END IF;
@@ -10462,6 +9782,8 @@ DELIMITER ;
/*!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 `ekt_loadNotBuy` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -10469,8 +9791,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ekt_loadNotBuy`()
BEGIN
@@ -10486,7 +9806,7 @@ BEGIN
DECLARE cursor1 CURSOR FOR SELECT e.id
FROM edi.ekt e
LEFT JOIN vn.buy b ON b.ektFk = e.id
- WHERE e.fec >= CURDATE()
+ WHERE e.fec >= util.VN_CURDATE()
AND ISNULL(b.ektFk);
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
@@ -10511,6 +9831,8 @@ DELIMITER ;
/*!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 `exchange_new` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -10518,48 +9840,46 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `exchange_new`(
IN `vMailFk` INT,
- IN `vItem` VARCHAR(255),
- IN `vType` MEDIUMINT,
- IN `vDeliveryNumber` BIGINT,
- IN `vDate` DATE,
- IN `vHour` TIME,
- IN `vRef` INT,
- IN `vAgj` INT,
- IN `vCat` VARCHAR(2),
- IN `vPac` INT,
- IN `vSub` MEDIUMINT,
- IN `vKop` INT,
- IN `vPtd` VARCHAR(6),
- IN `vPro` MEDIUMINT,
- IN `vOrigin` VARCHAR(3),
- IN `vPtj` MEDIUMINT,
- IN `vQuantiy` INT,
- IN `vPrice` DOUBLE,
- IN `vClock` SMALLINT,
- IN `vS1` VARCHAR(3),
- IN `vS2` VARCHAR(3),
- IN `vS3` VARCHAR(3),
- IN `vS4` VARCHAR(4),
- IN `vS5` VARCHAR(3),
- IN `vS6` VARCHAR(3),
- IN `vK1` SMALLINT,
- IN `vK2` SMALLINT,
- IN `vP1` TINYINT,
- IN `vP2` TINYINT,
- IN `vAuction` SMALLINT,
- IN `vPackage` INT,
- IN `vPutOrderFk` BIGINT)
+ IN `vItem` VARCHAR(255),
+ IN `vType` MEDIUMINT,
+ IN `vBatchNumber` BIGINT,
+ IN `vDeliveryNumber` BIGINT,
+ IN `vDate` DATE,
+ IN `vHour` TIME,
+ IN `vRef` INT,
+ IN `vAgj` INT,
+ IN `vCat` VARCHAR(2),
+ IN `vPac` INT,
+ IN `vSub` MEDIUMINT,
+ IN `vKop` INT,
+ IN `vPtd` VARCHAR(6),
+ IN `vPro` MEDIUMINT,
+ IN `vOrigin` VARCHAR(3),
+ IN `vPtj` MEDIUMINT,
+ IN `vQuantiy` INT,
+ IN `vPrice` DOUBLE,
+ IN `vClock` SMALLINT,
+ IN `vS1` VARCHAR(3),
+ IN `vS2` VARCHAR(3),
+ IN `vS3` VARCHAR(3),
+ IN `vS4` VARCHAR(4),
+ IN `vS5` VARCHAR(3),
+ IN `vS6` VARCHAR(3),
+ IN `vK1` SMALLINT,
+ IN `vK2` SMALLINT,
+ IN `vP1` TINYINT,
+ IN `vP2` TINYINT,
+ IN `vAuction` SMALLINT,
+ IN `vPackage` INT,
+ IN `vPutOrderFk` BIGINT)
BEGIN
/**
- * Adds a new exchange, generates it's barcode and
- * inserts/updates the transaction. When the referenced
- * transaction exists as provisional, updates it with
- * the new values.
+ * Adds a new exchange, generates it's barcode and inserts/updates the
+ * transaction. When the referenced transaction exists as provisional, updates
+ * it with the new values.
*/
DECLARE vEkt INT;
DECLARE vRewriteKop INT DEFAULT NULL;
@@ -10574,7 +9894,7 @@ BEGIN
-- Generates the barcode
- IF vAgj != 0 AND vAgj IS NOT NULL
+ IF vAgj != 0 AND vAgj IS NOT NULL
THEN
SET vBarcode = CONCAT(
LPAD(vAuction, 2, 0),
@@ -10587,22 +9907,6 @@ BEGIN
);
END IF;
- -- Generates the barcode
-
- /*IF vAgj != 0 AND vAgj IS NOT NULL
- THEN
- SET vBarcode = CONCAT(
- LPAD(vAuction, 2, 0),
- LPAD(IFNULL(vClock, 99), 2, 0),
- LPAD(DAYOFYEAR(vDate), 3, 0),
- IF(vClock IS NULL OR vClock = 99,
- LPAD(vAgj, 7, 0),
- CONCAT(LPAD(vAgj, 5, 0), '01')
- ),
- '0'
- );
- END IF;*/
-
-- Rewrites the kop parameter
IF vKop IS NULL THEN
@@ -10617,15 +9921,15 @@ BEGIN
SET vKop = IFNULL(vRewriteKop, vKop);
-- Inserts the new transaction
- call util.debugAdd('vBarcode',vBarcode);
- call util.debugAdd('vDeliveryNumber',vDeliveryNumber);
+
SET vIsDuplicated = FALSE;
SET vTruncatePutOrder = vPutOrderFk MOD 1000000;
INSERT INTO ekt SET
barcode = IFNULL(vBarcode, barcode)
- ,deliveryNumber = vDeliveryNumber
,entryYear = YEAR(vDate)
+ ,batchNumber = vBatchNumber
+ ,deliveryNumber = vDeliveryNumber
,fec = vDate
,hor = vHour
,ref = vRef
@@ -10654,11 +9958,11 @@ BEGIN
,k4 = vP2
,auction = vAuction
,package = vPackage
- ,putOrderFk = vTruncatePutOrder;
+ ,putOrderFk = vTruncatePutOrder;
-- If it exists duplicado updates it
- IF NOT vIsDuplicated
+ IF NOT vIsDuplicated
THEN
SET vEkt = LAST_INSERT_ID();
CALL ekt_load (vEkt);
@@ -10711,12 +10015,12 @@ BEGIN
,k4 = vP2
,auction = vAuction
,package = vPackage
- ,putOrderFk = IFNULL(vTruncatePutOrder, putOrderFk)
+ ,putOrderFk = IFNULL(vTruncatePutOrder, putOrderFk)
WHERE id = vEkt;
END IF;
-- Registers the exchange
-
+
INSERT INTO `exchange` SET
mailFk = vMailFk
,typeFk = vType
@@ -10727,15 +10031,15 @@ DELIMITER ;
/*!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 `floramondo_offerRefresh` */;
/*!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 = utf8 */ ;
-/*!50003 SET character_set_results = utf8 */ ;
-/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `floramondo_offerRefresh`()
proc: BEGIN
@@ -10765,7 +10069,7 @@ proc: BEGIN
RESIGNAL;
END;
- SET vStartingTime = NOW();
+ SET vStartingTime = util.VN_NOW();
TRUNCATE edi.offerList ;
@@ -10803,7 +10107,7 @@ proc: BEGIN
FROM (
SELECT *
FROM edi.supplyOffer
- ORDER BY (MarketPlaceID = vAalsmeerMarketPlaceID) DESC, NumberOfUnits DESC) t
+ ORDER BY (MarketPlaceID = vAalsmeerMarketPlaceID) DESC, NumberOfUnits DESC LIMIT 10000000000000000000) t
GROUP BY t.srId;
DROP TEMPORARY TABLE IF EXISTS edi.offer;
@@ -10881,19 +10185,19 @@ proc: BEGIN
AND i.quality <=> o.Quality
JOIN vn.itemType it ON it.id = i.typeFk
LEFT JOIN vn.sale s ON s.itemFk = i.id
- LEFT JOIN vn.ticket t ON t.id = s.ticketFk AND t.shipped > TIMESTAMPADD(WEEK, -1, CURDATE())
+ LEFT JOIN vn.ticket t ON t.id = s.ticketFk AND t.shipped > TIMESTAMPADD(WEEK, -1, util.VN_CURDATE())
LEFT JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk
LEFT JOIN edi.deliveryInformation di ON di.supplyResponseID = sr.ID
- LEFT JOIN edi.putOrder po ON po.supplyResponseID = i.supplyResponseFk AND po.OrderTradeLineDateTime > TIMESTAMPADD(WEEK, -1, CURDATE())
+ LEFT JOIN edi.putOrder po ON po.supplyResponseID = i.supplyResponseFk AND po.OrderTradeLineDateTime > TIMESTAMPADD(WEEK, -1, util.VN_CURDATE())
SET i.supplyResponseFk = o.srID
WHERE ( sr.ID IS NULL
OR sr.NumberOfUnits = 0
- OR di.LatestOrderDateTime < NOW()
+ OR di.LatestOrderDateTime < util.VN_NOW()
OR di.ID IS NULL)
AND it.isInventory
AND t.id IS NULL
AND po.id IS NULL;
- -- select now(),'Antes de crear ITO';
+ -- select util.VN_NOW(),'Antes de crear ITO';
DROP TEMPORARY TABLE IF EXISTS itemToInsert;
CREATE TEMPORARY TABLE itemToInsert ENGINE = MEMORY
SELECT o.*, CAST(NULL AS DECIMAL(6,0)) as itemFk
@@ -11074,7 +10378,7 @@ proc: BEGIN
JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID
JOIN vn.floramondoConfig fc
WHERE mp.isLatestOrderDateTimeRelevant
- AND di.LatestOrderDateTime > IF(fc.MaxLatestOrderHour > HOUR(NOW()), CURDATE(), TIMESTAMPADD(DAY,1,CURDATE()));
+ AND di.LatestOrderDateTime > IF(fc.MaxLatestOrderHour > HOUR(util.VN_NOW()), util.VN_CURDATE(), TIMESTAMPADD(DAY,1,util.VN_CURDATE()));
UPDATE vn.floramondoConfig
SET nextLanded = vLanded
@@ -11089,7 +10393,7 @@ proc: BEGIN
LEFT JOIN edi.supplyResponse sr ON i.supplyResponseFk = sr.ID
LEFT JOIN edi.deliveryInformation di ON di.ID = b.deliveryFk
SET b.quantity = 0
- WHERE (IFNULL(di.LatestOrderDateTime,NOW()) <= NOW()
+ WHERE (IFNULL(di.LatestOrderDateTime,util.VN_NOW()) <= util.VN_NOW()
OR i.supplyResponseFk IS NULL
OR sr.NumberOfUnits = 0)
AND am.name = 'LOGIFLORA'
@@ -11118,7 +10422,7 @@ proc: BEGIN
JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk;
*/
-- Se inserta el resto
- SET vLastInserted := NOW();
+ SET vLastInserted := util.VN_NOW();
-- Inserta la oferta
INSERT INTO vn.buy( entryFk,
@@ -11208,7 +10512,7 @@ proc: BEGIN
AND typeFk = 17;
INSERT INTO edi.log(tableName, fieldName,fieldValue)
- VALUES('floramondo_offerRefresh','Tiempo de proceso',TIMEDIFF(NOW(),vStartingTime));
+ VALUES('floramondo_offerRefresh','Tiempo de proceso',TIMEDIFF(util.VN_NOW(),vStartingTime));
@@ -11218,945 +10522,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `floramondo_offerRefresh_beta` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `floramondo_offerRefresh_beta`()
-proc: BEGIN
-
- DECLARE vLanded DATETIME;
- DECLARE done INT DEFAULT FALSE;
- DECLARE vFreeId INT;
- DECLARE vSupplyResponseFk INT;
- DECLARE vLastInserted DATETIME;
- DECLARE vIsAuctionDay BOOLEAN;
- DECLARE vMaxNewItems INT DEFAULT 10000;
- DECLARE vStartingTime DATETIME;
- DECLARE vAalsmeerMarketPlaceID VARCHAR(13) DEFAULT '8713783439043';
-
- DECLARE cur1 CURSOR FOR
- SELECT id
- FROM edi.item_free;
-
- DECLARE cur2 CURSOR FOR
- SELECT srId
- FROM itemToInsert;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
- DECLARE EXIT HANDLER FOR SQLSTATE '45000'
- BEGIN
- ROLLBACK;
- RESIGNAL;
- END;
-
- SET vStartingTime = NOW();
-
- TRUNCATE edi.offerList ;
-
- INSERT INTO edi.offerList(supplier, total)
- SELECT v.name, COUNT(DISTINCT sr.ID) total
- FROM edi.supplyResponse sr
- JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID
- WHERE sr.NumberOfUnits > 0
- AND sr.EmbalageCode != 999
- GROUP BY sr.vmpID;
-
- UPDATE edi.offerList o
- JOIN (SELECT v.name, COUNT(*) total
- FROM edi.supplyOffer sr
- JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID
- GROUP BY sr.vmpID) sub ON o.supplier = sub.name
- SET o.`filter` = sub.total;
-
- -- Refresca las fotos de los items existentes, con prioridad baja (0.7 seg)
- INSERT IGNORE INTO vn.itemImageQueue(itemFk, url,priority)
- SELECT i.id, sr.PictureReference , 100
- FROM edi.supplyResponse sr
- JOIN vn.item i ON i.supplyResponseFk = sr.ID
- WHERE i.image != edi.imageName(sr.PictureReference)
- AND sr.NumberOfUnits > 0;
-
- -- Elimina de la lista de items libres aquellos que ya existen
- DELETE itf.*
- FROM edi.item_free itf
- JOIN vn.item i ON i.id = itf.id;
-
- DROP TEMPORARY TABLE IF EXISTS tmp;
- CREATE TEMPORARY TABLE tmp (INDEX (`Item_ArticleCode`)) ENGINE = MEMORY
- SELECT t.*
- FROM (
- SELECT *
- FROM edi.supplyOffer
- ORDER BY (MarketPlaceID = vAalsmeerMarketPlaceID) DESC, NumberOfUnits DESC) t
- GROUP BY t.srId;
-
- DROP TEMPORARY TABLE IF EXISTS edi.offer;
- CREATE TEMPORARY TABLE edi.offer (INDEX (`srID`), INDEX (`EmbalageCode`),
- INDEX (`ef1`), INDEX (`ef2`), INDEX (`ef3`), INDEX (`ef4`),INDEX (`ef5`), INDEX (`ef6`),
- INDEX (`s1Value`), INDEX (`s2Value`), INDEX (`s3Value`), INDEX (`s4Value`),INDEX (`s5Value`), INDEX (`s6Value`))
- ENGINE = MEMORY
- SELECT so.*,
- ev1.type_description s1Value,
- ev2.type_description s2Value,
- ev3.type_description s3Value,
- ev4.type_description s4Value,
- ev5.type_description s5Value,
- ev6.type_description s6Value,
- eif1.feature ef1,
- eif2.feature ef2,
- eif3.feature ef3,
- eif4.feature ef4,
- eif5.feature ef5,
- eif6.feature ef6
- FROM tmp so
- LEFT JOIN edi.item_feature eif1 ON eif1.item_id = so.Item_ArticleCode
- AND eif1.presentation_order = 1 AND eif1.expiry_date IS NULL
- LEFT JOIN edi.item_feature eif2 ON eif2.item_id = so.Item_ArticleCode
- AND eif2.presentation_order = 2 AND eif2.expiry_date IS NULL
- LEFT JOIN edi.item_feature eif3 ON eif3.item_id = so.Item_ArticleCode
- AND eif3.presentation_order = 3 AND eif3.expiry_date IS NULL
- LEFT JOIN edi.item_feature eif4 ON eif4.item_id = so.Item_ArticleCode
- AND eif4.presentation_order = 4 AND eif4.expiry_date IS NULL
- LEFT JOIN edi.item_feature eif5 ON eif5.item_id = so.Item_ArticleCode
- AND eif5.presentation_order = 5 AND eif5.expiry_date IS NULL
- LEFT JOIN edi.item_feature eif6 ON eif6.item_id = so.Item_ArticleCode
- AND eif6.presentation_order = 6 AND eif6.expiry_date IS NULL
- LEFT JOIN edi.`value` ev1 ON ev1.type_id = eif1.feature AND so.s1 = ev1.type_value
- LEFT JOIN edi.`value` ev2 ON ev2.type_id = eif2.feature AND so.s2 = ev2.type_value
- LEFT JOIN edi.`value` ev3 ON ev3.type_id = eif3.feature AND so.s3 = ev3.type_value
- LEFT JOIN edi.`value` ev4 ON ev4.type_id = eif4.feature AND so.s4 = ev4.type_value
- LEFT JOIN edi.`value` ev5 ON ev5.type_id = eif5.feature AND so.s5 = ev5.type_value
- LEFT JOIN edi.`value` ev6 ON ev6.type_id = eif6.feature AND so.s6 = ev6.type_value
- ORDER BY Price;
-
- DROP TEMPORARY TABLE tmp;
-
- DELETE o
- FROM edi.offer o
- LEFT JOIN vn.tag t1 ON t1.ediTypeFk = o.ef1 AND t1.overwrite = 'size'
- LEFT JOIN vn.tag t2 ON t2.ediTypeFk = o.ef2 AND t2.overwrite = 'size'
- LEFT JOIN vn.tag t3 ON t3.ediTypeFk = o.ef3 AND t3.overwrite = 'size'
- LEFT JOIN vn.tag t4 ON t4.ediTypeFk = o.ef4 AND t4.overwrite = 'size'
- LEFT JOIN vn.tag t5 ON t5.ediTypeFk = o.ef5 AND t5.overwrite = 'size'
- LEFT JOIN vn.tag t6 ON t6.ediTypeFk = o.ef6 AND t6.overwrite = 'size'
- JOIN vn.floramondoConfig fc ON TRUE
- WHERE (t1.id IS NOT NULL AND CONVERT(s1Value, UNSIGNED) > fc.itemMaxSize)
- OR(t2.id IS NOT NULL AND CONVERT(s2Value, UNSIGNED) > fc.itemMaxSize)
- OR(t3.id IS NOT NULL AND CONVERT(s3Value, UNSIGNED) > fc.itemMaxSize)
- OR(t4.id IS NOT NULL AND CONVERT(s4Value, UNSIGNED) > fc.itemMaxSize)
- OR(t5.id IS NOT NULL AND CONVERT(s5Value, UNSIGNED) > fc.itemMaxSize)
- OR(t6.id IS NOT NULL AND CONVERT(s6Value, UNSIGNED) > fc.itemMaxSize);
-
- START TRANSACTION;
-
- -- Actualizamos el campo supplyResponseFk para aquellos articulos que ya estan creados y reutilizamos
- UPDATE IGNORE edi.offer o
- JOIN vn.item i
- ON i.name = o.product_name
- AND i.subname <=> o.company_name
- AND i.value5 <=> o.s1Value
- AND i.value6 <=> o.s2Value
- AND i.value7 <=> o.s3Value
- AND i.value8 <=> o.s4Value
- AND i.value9 <=> o.s5Value
- AND i.value10 <=> o.s6Value
- AND i.NumberOfItemsPerCask <=> o.NumberOfItemsPerCask
- AND i.EmbalageCode <=> o.EmbalageCode
- AND i.quality <=> o.Quality
- JOIN vn.itemType it ON it.id = i.typeFk
- LEFT JOIN vn.sale s ON s.itemFk = i.id
- LEFT JOIN vn.ticket t ON t.id = s.ticketFk AND t.shipped > TIMESTAMPADD(WEEK, -1, CURDATE())
- LEFT JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk
- LEFT JOIN edi.deliveryInformation di ON di.supplyResponseID = sr.ID
- LEFT JOIN edi.putOrder po ON po.supplyResponseID = i.supplyResponseFk AND po.OrderTradeLineDateTime > TIMESTAMPADD(WEEK, -1, CURDATE())
- SET i.supplyResponseFk = o.srID
- WHERE ( sr.ID IS NULL
- OR sr.NumberOfUnits = 0
- OR di.LatestOrderDateTime < NOW()
- OR di.ID IS NULL)
- AND it.isInventory
- AND t.id IS NULL
- AND po.id IS NULL;
- -- select now(),'Antes de crear ITO';
- DROP TEMPORARY TABLE IF EXISTS itemToInsert;
- CREATE TEMPORARY TABLE itemToInsert ENGINE = MEMORY
- SELECT o.*, CAST(NULL AS DECIMAL(6,0)) as itemFk
- FROM edi.offer o
- LEFT JOIN vn.item i ON i.supplyResponseFk = o.srId
- WHERE i.id IS NULL
- LIMIT vMaxNewItems;
-
- -- Reciclado de nº de item
- OPEN cur1;
- OPEN cur2;
-
- read_loop: LOOP
-
- FETCH cur2 INTO vSupplyResponseFk;
- FETCH cur1 INTO vFreeId;
-
- IF done THEN
- LEAVE read_loop;
- END IF;
-
- UPDATE itemToInsert
- SET itemFk = vFreeId
- WHERE srId = vSupplyResponseFk;
-
- END LOOP;
-
- CLOSE cur1;
- CLOSE cur2;
-
- -- Insertamos todos los items en Articles de la oferta
- INSERT INTO vn.item(id,
- `name`,
- longName,
- subName,
- expenceFk,
- typeFk,
- intrastatFk,
- originFk,
- supplyResponseFk,
- numberOfItemsPerCask,
- embalageCode,
- quality,
- isFloramondo)
- SELECT iti.itemFk,
- iti.product_name,
- iti.product_name,
- iti.company_name,
- iti.expenseFk,
- iti.itemTypeFk,
- iti.intrastatFk,
- iti.originFk,
- iti.`srId`,
- iti.NumberOfItemsPerCask,
- iti.EmbalageCode,
- iti.Quality,
- TRUE
- FROM itemToInsert iti;
-
- INSERT IGNORE INTO vn.itemImageQueue(itemFk, url)
- SELECT i.id, PictureReference
- FROM itemToInsert ii
- JOIN vn.item i ON i.supplyResponseFk = ii.srId
- WHERE PictureReference IS NOT NULL;
-
- INSERT INTO edi.log(tableName, fieldName,fieldValue)
- SELECT 'itemImageQueue','NumImagenesPtes', COUNT(*)
- FROM vn.itemImageQueue
- WHERE attempts = 0;
-
- -- Inserta si se añadiesen tags nuevos
- INSERT IGNORE INTO vn.tag (name, ediTypeFk)
- SELECT description, type_id FROM edi.type;
-
- -- Inserta los tags sólo en los articulos nuevos
-
- -- desabilita el trigger para recalcular los tags al final
- SET @isTriggerDisabled = TRUE;
-
- INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
- SELECT i.id, t.id , ii.product_name, 1
- FROM itemToInsert ii
- JOIN vn.tag t ON t.`name` = 'Producto'
- JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
- WHERE NOT ISNULL(ii.product_name);
-
- INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
- SELECT i.id, t.id , ii.Quality, 3
- FROM itemToInsert ii
- JOIN vn.tag t ON t.`name` = 'Calidad'
- JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
- WHERE NOT ISNULL(ii.Quality);
-
- INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
- SELECT i.id, t.id , ii.company_name, 4
- FROM itemToInsert ii
- JOIN vn.tag t ON t.`name` = 'Productor'
- JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
- WHERE NOT ISNULL(ii.company_name);
-
- INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
- SELECT i.id, t.id , s1Value, 5
- FROM itemToInsert ii
- JOIN vn.tag t ON t.ediTypeFk = ii.ef1
- JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
- WHERE NOT ISNULL(s1Value);
-
- INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
- SELECT i.id, t.id , s2Value, 6
- FROM itemToInsert ii
- JOIN vn.tag t ON t.ediTypeFk = ii.ef2
- JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
- WHERE NOT ISNULL(s2Value);
-
- INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
- SELECT i.id, t.id , s3Value, 7
- FROM itemToInsert ii
- JOIN vn.tag t ON t.ediTypeFk = ii.ef3
- JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
- WHERE NOT ISNULL(s3Value);
-
- INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
- SELECT i.id, t.id , s4Value, 8
- FROM itemToInsert ii
- JOIN vn.tag t ON t.ediTypeFk = ii.ef4
- JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
- WHERE NOT ISNULL(s4Value);
-
- INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
- SELECT i.id, t.id , s5Value, 9
- FROM itemToInsert ii
- JOIN vn.tag t ON t.ediTypeFk = ii.ef5
- JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
- WHERE NOT ISNULL(s5Value);
-
- INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
- SELECT i.id, t.id , s6Value, 10
- FROM itemToInsert ii
- JOIN vn.tag t ON t.ediTypeFk = ii.ef6
- JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
- WHERE NOT ISNULL(s6Value);
-
- INSERT IGNORE INTO vn.itemTag(itemFk, tagFk, value, priority)
- SELECT i.id, t.id, IFNULL(ink.name, ik.color), 11
- FROM itemToInsert ii
- JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
- JOIN vn.tag t ON t.`name` = 'Color'
- LEFT JOIN edi.feature f ON f.item_id = ii.Item_ArticleCode
- LEFT JOIN edi.`type` tp ON tp.type_id = f.feature_type_id AND tp.`description` = 'Hoofdkleur 1'
- LEFT JOIN vn.ink ON ink.dutchCode = f.feature_value
- LEFT JOIN vn.itemInk ik ON ik.longName = i.longName
- WHERE ink.name IS NOT NULL
- OR ik.color IS NOT NULL;
-
- UPDATE vn.item i
- JOIN itemToInsert ii ON i.supplyResponseFk = ii.`srId`
- JOIN vn.packaging p ON p.id LIKE ii.EmbalageCode AND hasCompressionVariations
- JOIN vn.itemTag diameter ON diameter.itemFk = i.id
- JOIN vn.tag tDiameter ON tDiameter.overwrite = 'diameter' AND tDiameter.id = diameter.tagFk
- JOIN vn.itemTag size ON size.itemFk = i.id
- JOIN vn.tag tSize ON tSize.overwrite = 'size' AND tSize.id = size.tagFk
- SET i.`compression` =
- (PI() * POW(diameter.`value`/ 2, 2) * size.`value`)
- /
- ((p.width * p.depth * p.height) / ii.NumberOfItemsPerCask);
-
- DROP TABLE IF EXISTS tmp.item;
- CREATE TABLE tmp.item
- (PRIMARY KEY (id))
- SELECT i.id FROM vn.item i
- JOIN itemToInsert ii ON i.supplyResponseFk = ii.`srId`;
-
- CALL vn.item_refreshTags();
-
- SET @isTriggerDisabled = FALSE;
-
- SELECT MIN(LatestDeliveryDateTime) INTO vLanded
- FROM edi.supplyResponse sr
- JOIN edi.deliveryInformation di ON di.supplyResponseID = sr.ID
- JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID
- JOIN vn.floramondoConfig fc
- WHERE mp.isLatestOrderDateTimeRelevant
- AND di.LatestOrderDateTime > IF(fc.MaxLatestOrderHour > HOUR(NOW()), CURDATE(), TIMESTAMPADD(DAY,1,CURDATE()));
-
- UPDATE vn.floramondoConfig
- SET nextLanded = vLanded
- WHERE vLanded IS NOT NULL;
-
- -- Elimina la oferta obsoleta
- UPDATE vn.buy b
- JOIN vn.entry e ON e.id = b.entryFk
- JOIN vn.travel tr ON tr.id = e.travelFk
- JOIN vn.agencyMode am ON am.id = tr.agencyFk
- JOIN vn.item i ON i.id = b.itemFk
- LEFT JOIN edi.supplyResponse sr ON i.supplyResponseFk = sr.ID
- LEFT JOIN edi.deliveryInformation di ON di.ID = b.deliveryFk
- SET b.quantity = 0
- WHERE (IFNULL(di.LatestOrderDateTime,NOW()) <= NOW()
- OR i.supplyResponseFk IS NULL
- OR sr.NumberOfUnits = 0)
- AND am.name = 'LOGIFLORA'
- AND e.isRaid;
-
- -- Localiza las entradas de cada almacen
- UPDATE edi.warehouseFloramondo
- SET entryFk = vn.entry_getForLogiflora(TIMESTAMPADD(DAY,travellingDays,vLanded), warehouseFk);
-
-
- IF vLanded IS NOT NULL THEN
- -- actualiza la oferta existente
- UPDATE vn.buy b
- JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk
- JOIN vn.item i ON i.id = b.itemFk
- JOIN edi.offer o ON i.supplyResponseFk = o.`srId`
- SET b.quantity = o.NumberOfUnits * o.NumberOfItemsPerCask,
- b.buyingValue = o.price
- WHERE (b.quantity <> o.NumberOfUnits * o.NumberOfItemsPerCask OR b.buyingValue <> o.price);
-/*
- -- Se eliminan las ofertas ya incluidas en las entradas
- DELETE o
- FROM edi.offer o
- JOIN vn.item i ON i.supplyResponseFk = o.srId
- JOIN vn.buy b ON i.id = b.itemFk
- JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk;
- */
- -- Se inserta el resto
- SET vLastInserted := NOW();
-
- -- Inserta la oferta
- INSERT INTO vn.buy( entryFk,
- itemFk,
- quantity,
- buyingValue,
- stickers,
- packing,
- `grouping`,
- groupingMode,
- packageFk,
- deliveryFk)
-
- SELECT wf.entryFk,
- i.id,
- o.NumberOfUnits * o.NumberOfItemsPerCask as quantity,
- o.Price,
- o.NumberOfUnits as etiquetas,
- o.NumberOfItemsPerCask as packing,
- GREATEST(1, IFNULL(o.MinimumQuantity,0)) * o.NumberOfItemsPerCask as `grouping`,
- 2, -- Obliga al Packing
- o.embalageCode,
- o.diId
- FROM edi.offer o
- JOIN vn.item i ON i.supplyResponseFk = o.srId
- JOIN edi.warehouseFloramondo wf
- JOIN vn.packaging p ON p.id LIKE o.embalageCode
- LEFT JOIN vn.buy b ON b.itemFk = i.id AND b.entryFk = wf.entryFk
- WHERE ISNULL(b.id); -- llevar esta linea i mirar de crear els packages a temps real
-
- DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc;
-
- CREATE TEMPORARY TABLE tmp.buyRecalc
- SELECT b.id
- FROM vn.buy b
- JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk
- WHERE b.created >= vLastInserted;
-
- CALL vn.buy_recalcPrices();
-
- UPDATE edi.offerList o
- JOIN (SELECT v.name, COUNT(DISTINCT b.itemFk) total
- FROM vn.buy b
- JOIN vn.item i ON i.id = b.itemFk
- JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk
- JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID
- JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk
- JOIN vn.warehouse w ON w.id = wf.warehouseFk
- WHERE w.name = 'VNH'
- AND b.quantity > 0
- GROUP BY sr.vmpID) sub ON o.supplier = sub.name
- SET o.vnh = sub.total;
-
- UPDATE edi.offerList o
- JOIN (SELECT v.name, COUNT(DISTINCT b.itemFk) total
- FROM vn.buy b
- JOIN vn.item i ON i.id = b.itemFk
- JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk
- JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID
- JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk
- JOIN vn.warehouse w ON w.id = wf.warehouseFk
- WHERE w.name = 'ALGEMESI'
- AND b.quantity > 0
- GROUP BY sr.vmpID) sub ON o.supplier = sub.name
- SET o.algemesi = sub.total;
-
-
- END IF;
-
- DROP TEMPORARY TABLE
- edi.offer,
- itemToInsert;
-
- DROP TABLE tmp.item;
-
- COMMIT;
-
- -- Esto habria que pasarlo a procesos programados o trabajar con tags y dejar las familias
- UPDATE vn.item i
- SET typeFk = 121
- WHERE i.longName LIKE 'Rosa Garden %'
- AND typeFk = 17;
-
- UPDATE vn.item i
- SET typeFk = 156
- WHERE i.longName LIKE 'Rosa ec %'
- AND typeFk = 17;
-
- INSERT INTO edi.log(tableName, fieldName,fieldValue)
- VALUES('floramondo_offerRefresh','Tiempo de proceso',TIMEDIFF(NOW(),vStartingTime));
-
-
-
-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 DROP PROCEDURE IF EXISTS `floramondo_offerRefresh__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `floramondo_offerRefresh__`()
-proc: BEGIN
-
- DECLARE vLanded DATETIME;
- DECLARE done INT DEFAULT FALSE;
- DECLARE vFreeId INT;
- DECLARE vSupplyResponseFk INT;
- DECLARE vLastInserted DATETIME;
- DECLARE vIsAuctionDay BOOLEAN;
- DECLARE vMaxNewItems INT DEFAULT 10000;
- DECLARE vStartingTime DATETIME;
- DECLARE vAalsmeerMarketPlaceID VARCHAR(13) DEFAULT '8713783439043';
-
- DECLARE cur1 CURSOR FOR
- SELECT id
- FROM edi.item_free;
-
- DECLARE cur2 CURSOR FOR
- SELECT srId
- FROM itemToInsert;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
- DECLARE EXIT HANDLER FOR SQLSTATE '45000'
- BEGIN
- ROLLBACK;
- RESIGNAL;
- END;
-
- SET vStartingTime = NOW();
-
- CALL util.debugAdd('edi.floramondo_offerRefresh',CONCAT('MaxItemId:' ,(SELECT MAX(id) FROM vn.item)));
-
- -- CALL vn.clean_logiflora();
-
- -- Refresca las fotos de los items existentes, con prioridad baja (0.7 seg)
- INSERT IGNORE INTO vn.itemImageQueue(itemFk, url,priority)
- SELECT i.id, sr.PictureReference , 100
- FROM edi.supplyResponse sr
- JOIN vn.item i ON i.supplyResponseFk = sr.ID
- WHERE i.image != edi.imageName(sr.PictureReference)
- AND sr.NumberOfUnits > 0;
-
- -- Elimina de la lista de items libres aquellos que ya existen
- DELETE itf.*
- FROM edi.item_free itf
- JOIN vn.item i ON i.id = itf.id;
-
- DROP TEMPORARY TABLE IF EXISTS tmp;
- CREATE TEMPORARY TABLE tmp (INDEX (`Item_ArticleCode`)) ENGINE = MEMORY
- SELECT t.*,
- IFNULL(idt.itemTypeFk, igo.itemTypeFk) itemTypeFk,
- igo.expenseFk ,
- igo.intrastatFk ,
- igo.originFk
- FROM (
- SELECT *
- FROM edi.supplyOffer
- ORDER BY (MarketPlaceID = vAalsmeerMarketPlaceID) DESC, NumberOfUnits DESC) t
- JOIN edi.item_groupToOffer igo ON igo.group_code = t.group_id
- LEFT JOIN edi.item_defaultType idt ON idt.item_id = t.Item_ArticleCode
- GROUP BY t.srId
- -- GROUP BY Item_ArticleCode, s1, s2, s3, s4, s5, s6, company_name, Quality, NumberOfItemsPerCask, EmbalageCode, Price, PictureReference
- ;
-
- -- select now(),'Antes de crear edi.offer';
-
- DROP TEMPORARY TABLE IF EXISTS edi.offer;
- CREATE TEMPORARY TABLE edi.offer (INDEX (`srID`), INDEX (`EmbalageCode`),
- INDEX (`ef1`), INDEX (`ef2`), INDEX (`ef3`), INDEX (`ef4`),INDEX (`ef5`), INDEX (`ef6`),
- INDEX (`s1Value`), INDEX (`s2Value`), INDEX (`s3Value`), INDEX (`s4Value`),INDEX (`s5Value`), INDEX (`s6Value`))
- ENGINE = MEMORY
- SELECT so.*, ev1.type_description s1Value, ev2.type_description s2Value, ev3.type_description s3Value,
- ev4.type_description s4Value, ev5.type_description s5Value, ev6.type_description s6Value,
- eif1.feature ef1, eif2.feature ef2, eif3.feature ef3, eif4.feature ef4, eif5.feature ef5, eif6.feature ef6
- FROM tmp so
- LEFT JOIN edi.item_feature eif1 ON eif1.item_id = so.Item_ArticleCode
- AND eif1.presentation_order = 1 AND eif1.expiry_date IS NULL
- LEFT JOIN edi.item_feature eif2 ON eif2.item_id = so.Item_ArticleCode
- AND eif2.presentation_order = 2 AND eif2.expiry_date IS NULL
- LEFT JOIN edi.item_feature eif3 ON eif3.item_id = so.Item_ArticleCode
- AND eif3.presentation_order = 3 AND eif3.expiry_date IS NULL
- LEFT JOIN edi.item_feature eif4 ON eif4.item_id = so.Item_ArticleCode
- AND eif4.presentation_order = 4 AND eif4.expiry_date IS NULL
- LEFT JOIN edi.item_feature eif5 ON eif5.item_id = so.Item_ArticleCode
- AND eif5.presentation_order = 5 AND eif5.expiry_date IS NULL
- LEFT JOIN edi.item_feature eif6 ON eif6.item_id = so.Item_ArticleCode
- AND eif6.presentation_order = 6 AND eif6.expiry_date IS NULL
- LEFT JOIN edi.`value` ev1 ON ev1.type_id = eif1.feature AND so.s1 = ev1.type_value
- LEFT JOIN edi.`value` ev2 ON ev2.type_id = eif2.feature AND so.s2 = ev2.type_value
- LEFT JOIN edi.`value` ev3 ON ev3.type_id = eif3.feature AND so.s3 = ev3.type_value
- LEFT JOIN edi.`value` ev4 ON ev4.type_id = eif4.feature AND so.s4 = ev4.type_value
- LEFT JOIN edi.`value` ev5 ON ev5.type_id = eif5.feature AND so.s5 = ev5.type_value
- LEFT JOIN edi.`value` ev6 ON ev6.type_id = eif6.feature AND so.s6 = ev6.type_value
- ORDER BY Price;
-
- DROP TEMPORARY TABLE tmp;
-
- DELETE o
- FROM edi.offer o
- LEFT JOIN vn.tag t1 ON t1.ediTypeFk = o.ef1 AND t1.overwrite = 'size'
- LEFT JOIN vn.tag t2 ON t2.ediTypeFk = o.ef2 AND t2.overwrite = 'size'
- LEFT JOIN vn.tag t3 ON t3.ediTypeFk = o.ef3 AND t3.overwrite = 'size'
- LEFT JOIN vn.tag t4 ON t4.ediTypeFk = o.ef4 AND t4.overwrite = 'size'
- LEFT JOIN vn.tag t5 ON t5.ediTypeFk = o.ef5 AND t5.overwrite = 'size'
- LEFT JOIN vn.tag t6 ON t6.ediTypeFk = o.ef6 AND t6.overwrite = 'size'
- JOIN vn.floramondoConfig fc ON TRUE
- WHERE (t1.id IS NOT NULL AND CONVERT(s1Value, UNSIGNED) > fc.itemMaxSize)
- OR(t2.id IS NOT NULL AND CONVERT(s2Value, UNSIGNED) > fc.itemMaxSize)
- OR(t3.id IS NOT NULL AND CONVERT(s3Value, UNSIGNED) > fc.itemMaxSize)
- OR(t4.id IS NOT NULL AND CONVERT(s4Value, UNSIGNED) > fc.itemMaxSize)
- OR(t5.id IS NOT NULL AND CONVERT(s5Value, UNSIGNED) > fc.itemMaxSize)
- OR(t6.id IS NOT NULL AND CONVERT(s6Value, UNSIGNED) > fc.itemMaxSize);
-
- START TRANSACTION;
-
- -- Actualizamos el campo supplyResponseFk para aquellos articulos que ya estan creados y reutilizamos
- UPDATE IGNORE edi.offer o
- JOIN vn.item i
- ON i.name = o.product_name
- AND i.subname <=> o.company_name
- AND i.value5 <=> o.s1Value
- AND i.value6 <=> o.s2Value
- AND i.value7 <=> o.s3Value
- AND i.value8 <=> o.s4Value
- AND i.value9 <=> o.s5Value
- AND i.value10 <=> o.s6Value
- AND i.NumberOfItemsPerCask <=> o.NumberOfItemsPerCask
- AND i.EmbalageCode <=> o.EmbalageCode
- AND i.quality <=> o.Quality
- JOIN vn.itemType it ON it.id = i.typeFk
- LEFT JOIN vn.sale s ON s.itemFk = i.id
- LEFT JOIN vn.ticket t ON t.id = s.ticketFk AND t.shipped > TIMESTAMPADD(WEEK, -1, CURDATE())
- LEFT JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk
- LEFT JOIN edi.deliveryInformation di ON di.supplyResponseID = sr.ID
- LEFT JOIN edi.putOrder po ON po.supplyResponseID = i.supplyResponseFk AND po.OrderTradeLineDateTime > TIMESTAMPADD(WEEK, -1, CURDATE())
- SET i.supplyResponseFk = o.srID
- WHERE ( sr.ID IS NULL
- OR sr.NumberOfUnits = 0
- OR di.LatestOrderDateTime < NOW()
- OR di.ID IS NULL)
- AND it.isInventory
- AND t.id IS NULL
- AND po.id IS NULL;
- -- select now(),'Antes de crear ITO';
- DROP TEMPORARY TABLE IF EXISTS itemToInsert;
- CREATE TEMPORARY TABLE itemToInsert ENGINE = MEMORY
- SELECT o.*, CAST(NULL AS DECIMAL(6,0)) as itemFk
- FROM edi.offer o
- LEFT JOIN vn.item i ON i.supplyResponseFk = o.srId
- WHERE i.id IS NULL
- LIMIT vMaxNewItems;
-
- -- Reciclado de nº de item
- OPEN cur1;
- OPEN cur2;
-
- read_loop: LOOP
-
- FETCH cur2 INTO vSupplyResponseFk;
- FETCH cur1 INTO vFreeId;
-
- IF done THEN
- LEAVE read_loop;
- END IF;
-
- UPDATE itemToInsert
- SET itemFk = vFreeId
- WHERE srId = vSupplyResponseFk;
-
- END LOOP;
-
- CLOSE cur1;
- CLOSE cur2;
-
- -- Insertamos todos los items en Articles de la oferta
- INSERT INTO vn.item( id,
- `name`,
- longName,
- subName,
- expenceFk,
- typeFk,
- intrastatFk,
- originFk,
- supplyResponseFk,
- numberOfItemsPerCask,
- embalageCode,
- quality,
- isFloramondo)
- SELECT iti.itemFk,
- iti.product_name,
- iti.product_name,
- iti.company_name,
- iti.expenseFk,
- iti.itemTypeFk,
- iti.intrastatFk,
- iti.originFk,
- iti.`srId`,
- iti.NumberOfItemsPerCask,
- iti.EmbalageCode,
- iti.Quality,
- TRUE
- FROM itemToInsert iti;
-
- INSERT IGNORE INTO vn.itemImageQueue(itemFk, url)
- SELECT i.id, PictureReference
- FROM itemToInsert ii
- JOIN vn.item i ON i.supplyResponseFk = ii.srId
- WHERE PictureReference IS NOT NULL;
-
- INSERT INTO edi.log(tableName, fieldName,fieldValue)
- SELECT 'itemImageQueue','NumImagenesPtes', COUNT(*)
- FROM vn.itemImageQueue
- WHERE attempts = 0;
-
- -- Inserta si se añadiesen tags nuevos
- INSERT IGNORE INTO vn.tag (name, ediTypeFk)
- SELECT description, type_id FROM edi.type;
-
- -- Inserta los tags sólo en los articulos nuevos
-
- -- desabilita el trigger para recalcular los tags al final
- SET @isTriggerDisabled = TRUE;
-
- INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
- SELECT i.id, t.id , ii.product_name, 1
- FROM itemToInsert ii
- JOIN vn.tag t ON t.`name` = 'Producto'
- JOIN vn.item i ON i.supplyResponseFk = ii.`srId`;
-
- INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
- SELECT i.id, t.id , ii.Quality, 3
- FROM itemToInsert ii
- JOIN vn.tag t ON t.`name` = 'Calidad'
- JOIN vn.item i ON i.supplyResponseFk = ii.`srId`;
-
- INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
- SELECT i.id, t.id , ii.company_name, 4
- FROM itemToInsert ii
- JOIN vn.tag t ON t.`name` = 'Productor'
- JOIN vn.item i ON i.supplyResponseFk = ii.`srId`;
-
- INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
- SELECT i.id, t.id , s1Value, 5
- FROM itemToInsert ii
- JOIN vn.tag t ON t.ediTypeFk = ii.ef1
- JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
- WHERE s1Value != '';
-
- INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
- SELECT i.id, t.id , s2Value, 6
- FROM itemToInsert ii
- JOIN vn.tag t ON t.ediTypeFk = ii.ef2
- JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
- WHERE s2Value != '';
-
- INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
- SELECT i.id, t.id , s3Value, 7
- FROM itemToInsert ii
- JOIN vn.tag t ON t.ediTypeFk = ii.ef3
- JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
- WHERE s3Value != '';
-
- INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
- SELECT i.id, t.id , s4Value, 8
- FROM itemToInsert ii
- JOIN vn.tag t ON t.ediTypeFk = ii.ef4
- JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
- WHERE s4Value != '';
-
- INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
- SELECT i.id, t.id , s5Value, 9
- FROM itemToInsert ii
- JOIN vn.tag t ON t.ediTypeFk = ii.ef5
- JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
- WHERE s5Value != '';
-
- INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
- SELECT i.id, t.id , s6Value, 10
- FROM itemToInsert ii
- JOIN vn.tag t ON t.ediTypeFk = ii.ef6
- JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
- WHERE s6Value != '';
-
- INSERT IGNORE INTO vn.itemTag(itemFk, tagFk, value, priority)
- SELECT i.id, t.id, IFNULL(ink.name, ik.color), 11
- FROM itemToInsert ii
- JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
- JOIN vn.tag t ON t.`name` = 'Color'
- LEFT JOIN edi.feature f ON f.item_id = ii.Item_ArticleCode
- LEFT JOIN edi.`type` tp ON tp.type_id = f.feature_type_id AND tp.`description` = 'Hoofdkleur 1'
- LEFT JOIN vn.ink ON ink.dutchCode = f.feature_value
- LEFT JOIN vn.itemInk ik ON ik.longName = i.longName
- WHERE ink.name IS NOT NULL
- OR ik.color IS NOT NULL;
-
- UPDATE vn.item i
- JOIN itemToInsert ii ON i.supplyResponseFk = ii.`srId`
- JOIN vn.packaging p ON p.id LIKE ii.EmbalageCode AND hasCompressionVariations
- JOIN vn.itemTag diameter ON diameter.itemFk = i.id
- JOIN vn.tag tDiameter ON tDiameter.overwrite = 'diameter' AND tDiameter.id = diameter.tagFk
- JOIN vn.itemTag size ON size.itemFk = i.id
- JOIN vn.tag tSize ON tSize.overwrite = 'size' AND tSize.id = size.tagFk
- SET i.`compression` =
- (PI() * POW(diameter.`value`/ 2, 2) * size.`value`)
- /
- ((p.width * p.depth * p.height) / ii.NumberOfItemsPerCask);
-
- DROP TABLE IF EXISTS tmp.item;
- CREATE TABLE tmp.item
- (PRIMARY KEY (id))
- SELECT i.id FROM vn.item i
- JOIN itemToInsert ii ON i.supplyResponseFk = ii.`srId`;
-
- CALL vn.item_refreshTags();
-
- SET @isTriggerDisabled = FALSE;
-
- SELECT MIN(LatestDeliveryDateTime) INTO vLanded
- FROM edi.supplyResponse sr
- JOIN edi.deliveryInformation di ON di.supplyResponseID = sr.ID
- JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID
- JOIN vn.floramondoConfig fc
- WHERE mp.isLatestOrderDateTimeRelevant
- AND di.LatestOrderDateTime > IF(fc.MaxLatestOrderHour > HOUR(NOW()), CURDATE(), TIMESTAMPADD(DAY,1,CURDATE()));
-
- UPDATE vn.floramondoConfig
- SET nextLanded = vLanded
- WHERE vLanded IS NOT NULL;
-
- -- Elimina la oferta obsoleta
- UPDATE vn.buy b
- JOIN vn.entry e ON e.id = b.entryFk
- JOIN vn.travel tr ON tr.id = e.travelFk
- JOIN vn.agencyMode am ON am.id = tr.agencyFk
- JOIN vn.item i ON i.id = b.itemFk
- LEFT JOIN edi.supplyResponse sr ON i.supplyResponseFk = sr.ID
- LEFT JOIN edi.deliveryInformation di ON di.ID = b.deliveryFk
- SET b.quantity = 0
- WHERE (IFNULL(di.LatestOrderDateTime,NOW()) <= NOW()
- OR i.supplyResponseFk IS NULL
- OR sr.NumberOfUnits = 0)
- AND am.name = 'LOGIFLORA'
- AND e.isRaid;
-
- -- Localiza las entradas de cada almacen
- UPDATE edi.warehouseFloramondo
- SET entryFk = vn.floramondo_getEntry(TIMESTAMPADD(DAY,travellingDays,vLanded), warehouseFk);
-
- IF vLanded IS NOT NULL THEN
- -- actualiza la oferta existente
- UPDATE vn.buy b
- JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk
- JOIN vn.item i ON i.id = b.itemFk
- JOIN edi.offer o ON i.supplyResponseFk = o.`srId`
- SET b.quantity = o.NumberOfUnits * o.NumberOfItemsPerCask,
- b.buyingValue = o.price
- WHERE (b.quantity <> o.NumberOfUnits * o.NumberOfItemsPerCask OR b.buyingValue <> o.price);
-
- -- Se eliminan las ofertas ya incluidas en las entradas
- DELETE o
- FROM edi.offer o
- JOIN vn.item i ON i.supplyResponseFk = o.srId
- JOIN vn.buy b ON i.id = b.itemFk
- JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk;
-
- -- Se inserta el resto
- SET vLastInserted := NOW();
-
- -- Inserta la oferta
- INSERT INTO vn.buy(entryFk,
- itemFk,
- quantity,
- buyingValue,
- stickers,
- packing,
- `grouping`,
- groupingMode,
- packageFk,
- deliveryFk)
-
- SELECT wf.entryFk,
- i.id,
- o.NumberOfUnits * o.NumberOfItemsPerCask as quantity,
- o.Price,
- o.NumberOfUnits as etiquetas,
- o.NumberOfItemsPerCask as packing,
- GREATEST(1, IFNULL(o.MinimumQuantity,0)) * o.NumberOfItemsPerCask as `grouping`,
- 2, -- Obliga al Packing
- o.embalageCode,
- o.diId
- FROM edi.offer o
- JOIN vn.item i ON i.supplyResponseFk = o.srId
- -- JOIN vn.itemType it ON it.id = i.typeFk
- JOIN edi.warehouseFloramondo wf
- JOIN vn.packaging p ON p.id LIKE o.embalageCode; -- llevar esta linea i mirar de crear els packages a temps real
-
- DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc;
-
- CREATE TEMPORARY TABLE tmp.buyRecalc
- SELECT b.id
- FROM vn.buy b
- JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk
- WHERE b.created >= vLastInserted;
-
- CALL vn.buy_recalcPrices();
-
- END IF;
-
- DROP TEMPORARY TABLE
- edi.offer,
- itemToInsert;
-
- DROP TABLE tmp.item;
-
- COMMIT;
-
- -- Esto habria que pasarlo a procesos programados o trabajar con tags y dejar las familias
- UPDATE vn.item i
- SET typeFk = 121
- WHERE i.longName LIKE 'Rosa Garden %'
- AND typeFk = 17;
-
- UPDATE vn.item i
- SET typeFk = 156
- WHERE i.longName LIKE 'Rosa ec %'
- AND typeFk = 17;
-
- INSERT INTO edi.log(tableName, fieldName,fieldValue)
- VALUES('floramondo_offerRefresh','Tiempo de proceso',TIMEDIFF(NOW(),vStartingTime));
-
-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 DROP PROCEDURE IF EXISTS `item_freeAdd` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -12164,8 +10531,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_freeAdd`()
BEGIN
@@ -12224,6 +10589,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `item_getNewByEkt` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -12231,8 +10598,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getNewByEkt`(vEktFk INT, OUT vItemFk INT)
BEGIN
@@ -12416,6 +10781,8 @@ DELIMITER ;
/*!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 `mail_new` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -12423,8 +10790,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `mail_new`(
vMessageId VARCHAR(100)
@@ -12469,66 +10834,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `orderLog__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `orderLog__`(vItemFk INT)
-BEGIN
-
- DECLARE vSupplyResponseFk INT;
- DECLARE vDescription VARCHAR(100);
-
- SELECT supplyResponseFk, CONCAT(id, ' ',longName) INTO vSupplyResponseFk, vDescription
- FROM vn.item
- WHERE id = vItemFk;
-
- SELECT * FROM
- (
- SELECT 'Cliente confirma' accion, or2.created hora, amount Cantidad
- FROM hedera.order_row or2
- JOIN vn.item i ON i.id = or2.item_id
- WHERE i.supplyResponseFk = vSupplyResponseFk
-
- UNION ALL
-
- SELECT vDescription, NULL, NULL
-
- UNION ALL
-
- SELECT 'Cliente se conecta' , o.date_make , NULL
- FROM hedera.`order` o
- JOIN hedera.order_row or2 ON or2.order_id = o.id
- JOIN vn.item i ON i.id = or2.item_id
- WHERE i.supplyResponseFk = vSupplyResponseFk
-
- UNION ALL
-
- SELECT DISTINCT 'Subasta cambia cantidad', srl.created, srl.NumberOfUnitsNew * sr.NumberOfItemsPerCask
- FROM edi.supplyResponseLog srl
- JOIN edi.supplyResponse sr ON sr.ID = srl.supplyResponseFk
- WHERE srl.supplyResponseFk = vSupplyResponseFk
-
- UNION ALL
-
- SELECT 'Linea de venta definitiva', s.created, s.quantity
- FROM vn.sale s
- JOIN vn.item i ON i.id = s.itemFk
- WHERE i.supplyResponseFk = vSupplyResponseFk) sub
- ORDER BY hora;
-
-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 DROP PROCEDURE IF EXISTS `ticket_calcCompByFloramondo` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -12536,8 +10843,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_calcCompByFloramondo`(vSelf INT)
BEGIN
@@ -13448,7 +11753,7 @@ BEGIN
'jgallego@verdnatura.es',
'noreply@verdnatura.es',
'Creada order al address 2850',
- CONCAT(account.myUserGetName(), ' ha creado la order ',NEW.id)
+ CONCAT(account.myUser_getName(), ' ha creado la order ',NEW.id)
);
END IF;
@@ -13485,7 +11790,7 @@ BEGIN
'jgallego@verdnatura.es',
'noreply@verdnatura.es',
'Actualizada order al address 2850',
- CONCAT(account.myUserGetName(), ' ha creado la order ',NEW.id)
+ CONCAT(account.myUser_getName(), ' ha creado la order ',NEW.id)
);
END IF;
END */;;
@@ -13583,8 +11888,10 @@ CREATE TABLE `orderRow` (
KEY `order_id` (`orderFk`),
KEY `created` (`created`),
KEY `warehouse_shipment` (`warehouseFk`,`shipment`),
+ KEY `orderRow_ibfk_4` (`saleFk`),
CONSTRAINT `orderRow_ibfk_2` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `orderRow_ibfk_3` FOREIGN KEY (`orderFk`) REFERENCES `order` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE
+ CONSTRAINT `orderRow_ibfk_3` FOREIGN KEY (`orderFk`) REFERENCES `order` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE,
+ CONSTRAINT `orderRow_ibfk_4` FOREIGN KEY (`saleFk`) REFERENCES `vn`.`sale` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
@@ -13607,7 +11914,7 @@ BEGIN
WHERE id = NEW.orderFk;
IF vIsFirst THEN
- UPDATE `order` SET first_row_stamp = NOW()
+ UPDATE `order` SET first_row_stamp = util.VN_NOW()
WHERE id = NEW.orderFk;
END IF;
END */;;
@@ -13759,7 +12066,7 @@ DROP TABLE IF EXISTS `restPriv`;
CREATE TABLE `restPriv` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`methodPath` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
- `role` int(10) unsigned NOT NULL,
+ `role` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `role` (`role`),
CONSTRAINT `restPriv_ibfk_1` FOREIGN KEY (`role`) REFERENCES `account`.`role` (`id`) ON UPDATE CASCADE
@@ -14143,6 +12450,8 @@ DELIMITER ;
--
-- Dumping routines for database 'hedera'
--
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP FUNCTION IF EXISTS `myBasket_getId` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -14150,8 +12459,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `MYBASKET_GETID`() RETURNS int(11)
DETERMINISTIC
@@ -14168,6 +12475,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `myClient_getDebt` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -14175,8 +12484,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `myClient_getDebt`(vDate DATE) RETURNS decimal(10,2)
DETERMINISTIC
@@ -14186,13 +12493,15 @@ BEGIN
*
* @return Saldo del cliente
*/
- RETURN vn.clientGetDebt(account.userGetId(), vDate);
+ RETURN vn.clientGetDebt(account.myUser_getId(), vDate);
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 FUNCTION IF EXISTS `myUser_checkRestPriv` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -14200,32 +12509,42 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `myUser_checkRestPriv`(vMethodPath VARCHAR(255)) RETURNS tinyint(1)
DETERMINISTIC
BEGIN
/**
- * Comprueba si el usuario actual tiene permiso para ejecutar
- * un servicio REST.
+ * Checks if the current user has permission to run a REST service.
*
- * @param vMethodPath Ruta del servicio REST a ejecutar
- * @return %TRUE si tiene permisos, %FALSE en caso contrario
- **/
- DECLARE vRole INT DEFAULT NULL;
+ * @param vMethodPath Route of the REST service
+ * @return %TRUE if it has permissions, otherwise %FALSE
+ */
+ DECLARE vCount INT;
+ DECLARE vHasRole INT DEFAULT NULL;
- SELECT role INTO vRole FROM restPriv
+ SELECT COUNT(*) INTO vCount FROM restPriv
WHERE methodPath = vMethodPath;
-
- RETURN vRole IS NULL
- OR account.myUserHasRoleId (vRole);
+
+ IF vCount = 0 THEN
+ RETURN FALSE;
+ END IF;
+
+ SELECT COUNT(*) > 0
+ INTO vHasRole
+ FROM restPriv
+ WHERE methodPath = vMethodPath
+ AND (`role` IS NULL OR account.myUser_hasRoleId(`role`))
+ LIMIT 1;
+
+ RETURN vHasRole;
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 FUNCTION IF EXISTS `order_getTotal` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -14233,8 +12552,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `order_getTotal`(vSelf INT) RETURNS decimal(10,2)
READS SQL DATA
@@ -14269,6 +12586,8 @@ DELIMITER ;
/*!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 `catalog_calcFromMyAddress` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -14276,8 +12595,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_calcFromMyAddress`(vDelivery DATE, vAddress INT)
BEGIN
@@ -14321,6 +12638,8 @@ DELIMITER ;
/*!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 `catalog_calcFromMyAddress_beta` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -14328,8 +12647,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_calcFromMyAddress_beta`(vDelivery DATE, vAddress INT)
BEGIN
@@ -14373,81 +12690,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `catalog_getTags__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_getTags__`(vLimit INT)
-BEGIN
-/**
- * Returns the main tags for a list of items.
- *
- * @table tItems The list of items
- * @select The main tags for the passed items
- */
- CALL catalogGetAvailable;
-
- DROP TEMPORARY TABLE IF EXISTS tTags;
- CREATE TEMPORARY TABLE tTags
- (INDEX (tagFk))
- ENGINE = MEMORY
- SELECT it.tagFk, SUM(it.priority) priority
- FROM vn.itemTag it
- JOIN tItems i ON i.id = it.itemFk
- GROUP BY tagFk
- LIMIT vLimit;
-
- SELECT l.id, l.name
- FROM tTags t
- JOIN vn.tagL10n l ON l.id = t.tagFk
- ORDER BY priority DESC;
-
- DROP TEMPORARY TABLE tTags;
-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 DROP PROCEDURE IF EXISTS `catalog_getTagValues__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_getTagValues__`(vTag INT)
-BEGIN
-/**
- * Returns the list of available values for a tag and a list of items.
- *
- * @table tItems The list of items
- * @param vTag The tag identifier
- * @select The list of available tags
- */
- CALL catalogGetAvailable;
-
- SELECT DISTINCT it.value
- FROM vn.itemTag it
- JOIN tItems i ON i.id = it.itemFk
- WHERE it.tagFk = vTag
- ORDER BY value
- LIMIT 200;
-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 DROP PROCEDURE IF EXISTS `image_ref` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -14455,8 +12699,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `image_ref`(
vCollection VARCHAR(255),
@@ -14486,6 +12728,8 @@ DELIMITER ;
/*!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 `image_unref` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -14493,8 +12737,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `image_unref`(
vCollection VARCHAR(255),
@@ -14516,6 +12758,8 @@ DELIMITER ;
/*!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 `item_calcCatalog` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -14523,8 +12767,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_calcCatalog`(
vSelf INT,
@@ -14564,6 +12806,8 @@ DELIMITER ;
/*!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 `item_getList` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -14571,8 +12815,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getList`(IN `vWarehouse` SMALLINT, IN `vShipping` DATE, IN `vCategory` INT, IN `vRate` TINYINT)
BEGIN
@@ -14613,6 +12855,8 @@ DELIMITER ;
/*!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 `item_getVisible` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -14620,8 +12864,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getVisible`(
vWarehouse TINYINT,
@@ -14689,7 +12931,7 @@ BEGIN
FROM vn.buy b
JOIN vn.entry e ON e.id = b.entryFk
JOIN vn.travel t ON t.id = e.travelFk
- WHERE t.shipped BETWEEN vDateInv AND CURDATE()
+ WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE()
AND t.warehouseOutFk = vWarehouse
AND NOT e.isRaid
AND t.isDelivered
@@ -14698,7 +12940,7 @@ BEGIN
FROM vn.sale m
JOIN vn.ticket t ON t.id = m.ticketFk
JOIN vn.ticketState s ON s.ticket = t.id
- WHERE t.shipped BETWEEN vDateInv AND CURDATE()
+ WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE()
AND t.warehouseFk = vWarehouse
AND s.alertLevel = 3
) t
@@ -14720,6 +12962,7 @@ BEGIN
AND b.price2 >= 0
AND b.packageFk IS NOT NULL
ORDER BY t.warehouseInFk = vWarehouse DESC, t.landed DESC
+ LIMIT 10000000000000000000
) t GROUP BY itemFk;
DROP TEMPORARY TABLE IF EXISTS tmp.itemVisible;
@@ -14749,127 +12992,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `item_getVisible__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getVisible__`(
- vWarehouse TINYINT,
- vDate DATE,
- vType INT,
- vPrefix VARCHAR(255))
-BEGIN
-/**
- * Gets visible items of the specified type at specified date.
- *
- * @param vWarehouse The warehouse id
- * @param vDate The visible date
- * @param vType The type id
- * @param vPrefix The article prefix to filter or %NULL for all
- * @return tmp.itemVisible Visible items
- */
- DECLARE vPrefixLen SMALLINT;
- DECLARE vFilter VARCHAR(255) DEFAULT NULL;
- DECLARE vDateInv DATE DEFAULT vn2008.date_inv();
-
- SET vPrefixLen = IFNULL(LENGTH(vPrefix), 0) + 1;
-
- IF vPrefixLen > 1 THEN
- SET vFilter = CONCAT(vPrefix, '%');
- END IF;
-
- DROP TEMPORARY TABLE IF EXISTS filter;
- CREATE TEMPORARY TABLE filter
- (INDEX (itemFk))
- ENGINE = MEMORY
- SELECT id itemFk FROM vn.item
- WHERE typeFk = vType
- AND (vFilter IS NULL OR `name` LIKE vFilter);
-
- DROP TEMPORARY TABLE IF EXISTS currentStock;
- CREATE TEMPORARY TABLE currentStock
- (INDEX (itemFk))
- ENGINE = MEMORY
- SELECT itemFk, SUM(quantity) quantity
- FROM (
- SELECT b.itemFk, b.quantity
- FROM vn.buy b
- JOIN vn.entry e ON e.id = b.entryFk
- JOIN vn.travel t ON t.id = e.travelFk
- WHERE t.landed BETWEEN vDateInv AND vDate
- AND t.warehouseInFk = vWarehouse
- AND NOT e.isRaid
- UNION ALL
- SELECT b.itemFk, -b.quantity
- FROM vn.buy b
- JOIN vn.entry e ON e.id = b.entryFk
- JOIN vn.travel t ON t.id = e.travelFk
- WHERE t.shipped BETWEEN vDateInv AND CURDATE()
- AND t.warehouseOutFk = vWarehouse
- AND NOT e.isRaid
- AND t.isDelivered
- UNION ALL
- SELECT m.itemFk, -m.quantity
- FROM vn.sale m
- JOIN vn.ticket t ON t.id = m.ticketFk
- JOIN vn.ticketState s ON s.ticket = t.id
- WHERE t.shipped BETWEEN vDateInv AND CURDATE()
- AND t.warehouseFk = vWarehouse
- AND s.alertLevel = 3
- ) t
- GROUP BY itemFk
- HAVING quantity > 0;
-
- DROP TEMPORARY TABLE IF EXISTS tmp;
- CREATE TEMPORARY TABLE tmp
- (INDEX (itemFk))
- ENGINE = MEMORY
- SELECT *
- FROM (
- SELECT b.itemFk, b.packageFk, b.packing
- FROM vn.buy b
- JOIN vn.entry e ON e.id = b.entryFk
- JOIN vn.travel t ON t.id = e.travelFk
- WHERE t.landed BETWEEN vDateInv AND vDate
- AND NOT b.isIgnored
- AND b.price2 >= 0
- AND b.packageFk IS NOT NULL
- ORDER BY t.warehouseInFk = vWarehouse DESC, t.landed DESC
- ) t GROUP BY itemFk;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.itemVisible;
- CREATE TEMPORARY TABLE tmp.itemVisible
- ENGINE = MEMORY
- SELECT i.id Id_Article,
- SUBSTRING(i.`name`, vPrefixLen) Article,
- t.packing, p.id Id_Cubo,
- IF(p.depth > 0, p.depth, 0) depth, p.width, p.height,
- CEIL(s.quantity / t.packing) etiquetas
- FROM vn.item i
- JOIN filter f ON f.itemFk = i.id
- JOIN currentStock s ON s.itemFk = i.id
- LEFT JOIN tmp t ON t.itemFk = i.id
- LEFT JOIN vn.packaging p ON p.id = t.packageFk
- WHERE CEIL(s.quantity / t.packing) > 0
- -- FIXME: Column Cubos.box not included in view vn.packaging
- /* AND p.box */;
-
- DROP TEMPORARY TABLE
- filter,
- currentStock,
- tmp;
-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 DROP PROCEDURE IF EXISTS `item_listAllocation` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -14877,8 +13001,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_listAllocation`(IN `vWh` TINYINT, IN `vDate` DATE, IN `vType` INT, IN `vPrefix` VARCHAR(255), IN `vUseIds` BOOLEAN)
BEGIN
@@ -14911,6 +13033,8 @@ DELIMITER ;
/*!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 `myBasket_addItem` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -14918,8 +13042,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_addItem`(
vWarehouse INT,
@@ -14933,6 +13055,8 @@ DELIMITER ;
/*!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 `myBasket_calcCatalogFromItem` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -14940,8 +13064,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_calcCatalogFromItem`(vItem INT)
BEGIN
@@ -14963,6 +13085,8 @@ DELIMITER ;
/*!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 `myBasket_calcCatalogFull` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -14970,8 +13094,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_calcCatalogFull`()
BEGIN
@@ -14993,6 +13115,8 @@ DELIMITER ;
/*!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 `myBasket_check` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -15000,8 +13124,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_check`()
BEGIN
@@ -15027,7 +13149,7 @@ BEGIN
THEN
CALL order_checkConfig(vSelf);
- IF vStatus = 'OK' AND vCreated < TIMESTAMPADD(DAY, -1, NOW())
+ IF vStatus = 'OK' AND vCreated < TIMESTAMPADD(DAY, -1, util.VN_NOW())
THEN
CALL order_update(vSelf);
SET vStatus = 'UPDATED';
@@ -15041,6 +13163,8 @@ DELIMITER ;
/*!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 `myBasket_configure` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -15048,8 +13172,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_configure`(
vDelivery DATE,
@@ -15098,7 +13220,7 @@ BEGIN
INSERT INTO `order`
SET
- customer_id = account.userGetId(),
+ customer_id = account.myUser_getId(),
date_send = vDelivery,
delivery_method_id = vDeliveryMethodId,
agency_id = vAgency,
@@ -15109,7 +13231,7 @@ BEGIN
SET vSelf = LAST_INSERT_ID();
INSERT INTO basketOrder SET
- clientFk = account.userGetId(),
+ clientFk = account.myUser_getId(),
orderFk = vSelf;
ELSE
UPDATE `order`
@@ -15133,6 +13255,8 @@ DELIMITER ;
/*!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 `myBasket_configureForGuest` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -15140,8 +13264,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_configureForGuest`()
BEGIN
@@ -15155,7 +13277,7 @@ BEGIN
FROM orderConfig
LIMIT 1;
- SET vDate = TIMESTAMPADD(DAY, 1, CURDATE());
+ SET vDate = TIMESTAMPADD(DAY, 1, util.VN_CURDATE());
IF WEEKDAY(vDate) BETWEEN 5 AND 6 THEN
SET vDate = TIMESTAMPADD(DAY, 7 - WEEKDAY(vDate), vDate);
@@ -15168,6 +13290,8 @@ DELIMITER ;
/*!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 `myBasket_confirm` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -15175,8 +13299,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_confirm`()
BEGIN
@@ -15194,6 +13316,8 @@ DELIMITER ;
/*!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 `myBasket_getAvailable` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -15201,8 +13325,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_getAvailable`()
BEGIN
@@ -15218,6 +13340,8 @@ DELIMITER ;
/*!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 `myBasket_getTax` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -15225,8 +13349,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_getTax`()
READS SQL DATA
@@ -15250,6 +13372,8 @@ DELIMITER ;
/*!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 `myOrder_addItem` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -15257,8 +13381,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myOrder_addItem`(
vSelf INT,
@@ -15281,6 +13403,8 @@ DELIMITER ;
/*!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 `myOrder_confirm` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -15288,8 +13412,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myOrder_confirm`(vSelf INT)
BEGIN
@@ -15308,6 +13430,8 @@ DELIMITER ;
/*!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 `myOrder_getAvailable` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -15315,8 +13439,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myOrder_getAvailable`(vSelf INT)
BEGIN
@@ -15341,6 +13463,8 @@ DELIMITER ;
/*!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 `myOrder_newWithAddress` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -15348,8 +13472,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myOrder_newWithAddress`(
OUT vSelf INT,
@@ -15394,7 +13516,7 @@ BEGIN
INSERT INTO `order`
SET
- customer_id = account.userGetId(),
+ customer_id = account.myUser_getId(),
date_send = vLandingDate,
delivery_method_id = vDeliveryMethodId,
agency_id = vAgencyMode,
@@ -15413,6 +13535,8 @@ DELIMITER ;
/*!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 `myOrder_newWithDate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -15420,8 +13544,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myOrder_newWithDate`(
OUT vSelf INT,
@@ -15466,7 +13588,7 @@ BEGIN
INSERT INTO `order`
SET
- customer_id = account.userGetId(),
+ customer_id = account.myUser_getId(),
date_send = vLandingDate,
delivery_method_id = vDeliveryMethodId,
agency_id = vAgencyMode,
@@ -15485,6 +13607,8 @@ DELIMITER ;
/*!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 `myTicket_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -15492,8 +13616,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myTicket_get`(vSelf INT)
BEGIN
@@ -15539,6 +13661,8 @@ DELIMITER ;
/*!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 `myTicket_getPackages` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -15546,8 +13670,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myTicket_getPackages`(vSelf INT)
BEGIN
@@ -15572,6 +13694,8 @@ DELIMITER ;
/*!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 `myTicket_getRows` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -15579,8 +13703,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myTicket_getRows`(vSelf INT)
BEGIN
@@ -15601,6 +13723,8 @@ DELIMITER ;
/*!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 `myTicket_getServices` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -15608,8 +13732,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myTicket_getServices`(vSelf INT)
BEGIN
@@ -15628,6 +13750,8 @@ DELIMITER ;
/*!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 `myTicket_list` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -15635,8 +13759,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myTicket_list`(vFrom DATE, vTo DATE)
BEGIN
@@ -15648,8 +13770,8 @@ BEGIN
* @param vTo To date, if %NULL current date
* @select The tickets list
*/
- SET vFrom = IFNULL(vFrom, DATE_FORMAT(TIMESTAMPADD(MONTH, -3, CURDATE()), '%Y-%m-01'));
- SET vTo = IFNULL(vTo, TIMESTAMPADD(YEAR, 1, CURDATE()));
+ SET vFrom = IFNULL(vFrom, DATE_FORMAT(TIMESTAMPADD(MONTH, -3, util.VN_CURDATE()), '%Y-%m-01'));
+ SET vTo = IFNULL(vTo, TIMESTAMPADD(YEAR, 1, util.VN_CURDATE()));
DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
CREATE TEMPORARY TABLE tmp.ticket
@@ -15680,6 +13802,8 @@ DELIMITER ;
/*!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 `myTicket_logAccess` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -15687,8 +13811,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myTicket_logAccess`(vSelf INT)
BEGIN
@@ -15699,7 +13821,7 @@ BEGIN
*/
INSERT INTO vn.ticketLog
(originFk, userFk, `action`, description)
- SELECT vSelf, account.userGetId(), 'select', 'Accede a ticket'
+ SELECT vSelf, account.myUser_getId(), 'select', 'Accede a ticket'
FROM myTicket t
WHERE t.id = vSelf;
END ;;
@@ -15708,6 +13830,8 @@ DELIMITER ;
/*!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 `myTpvTransaction_end` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -15715,8 +13839,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myTpvTransaction_end`(vSelf INT, vStatus VARCHAR(12))
BEGIN
@@ -15741,6 +13863,8 @@ DELIMITER ;
/*!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 `myTpvTransaction_start` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -15748,8 +13872,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `myTpvTransaction_start`(vAmount INT, vCompany INT)
BEGIN
@@ -15804,7 +13926,7 @@ BEGIN
INSERT INTO myTpvTransaction
SET
merchantFk = vMerchant
- ,clientFk = account.userGetId()
+ ,clientFk = account.myUser_getId()
,amount = vAmount;
SET vSelf = LAST_INSERT_ID();
@@ -15828,6 +13950,8 @@ DELIMITER ;
/*!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 `order_addItem` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -15835,8 +13959,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `order_addItem`(
vSelf INT,
@@ -15944,6 +14066,8 @@ DELIMITER ;
/*!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 `order_calcCatalog` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -15951,8 +14075,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `order_calcCatalog`(vSelf INT)
BEGIN
@@ -15991,6 +14113,8 @@ DELIMITER ;
/*!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 `order_calcCatalogFromItem` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -15998,8 +14122,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `order_calcCatalogFromItem`(vSelf INT, vItem INT)
BEGIN
@@ -16031,6 +14153,8 @@ DELIMITER ;
/*!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 `order_calcCatalogFull` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -16038,8 +14162,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `order_calcCatalogFull`(vSelf INT)
BEGIN
@@ -16066,7 +14188,7 @@ BEGIN
CALL vn.catalog_calculate(vDate, vAddress, vAgencyMode);
- IF account.myUserGetName() = 'visitor'
+ IF account.myUser_getName() = 'visitor'
THEN
DROP TEMPORARY TABLE tmp.ticketComponent;
UPDATE tmp.ticketCalculateItem SET price = NULL;
@@ -16077,6 +14199,8 @@ DELIMITER ;
/*!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 `order_checkConfig` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -16084,8 +14208,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `order_checkConfig`(vSelf INT)
BEGIN
@@ -16135,6 +14257,8 @@ DELIMITER ;
/*!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 `order_confirm` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -16142,8 +14266,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `order_confirm`(vSelf INT)
BEGIN
@@ -16153,7 +14275,7 @@ BEGIN
*
* @param vSelf The order identifier
*/
- DECLARE vUser INT DEFAULT account.userGetId();
+ DECLARE vUser INT DEFAULT account.myUser_getId();
CALL order_confirmWithUser(vSelf, vUser);
END ;;
DELIMITER ;
@@ -16161,6 +14283,8 @@ DELIMITER ;
/*!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 `order_confirmWithUser` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -16168,12 +14292,9 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `order_confirmWithUser`(IN `vOrder` INT, IN `vUserId` INT)
BEGIN
-
/**
* Confirms an order, creating each of its tickets on the corresponding
* date, store and user.
@@ -16201,8 +14322,8 @@ BEGIN
DECLARE vCompanyId INT;
DECLARE vAgencyModeId INT;
DECLARE TICKET_FREE INT DEFAULT 2;
- DECLARE vIsFloramondoWarehouse BOOL;
DECLARE vCalc INT;
+ DECLARE vIsLogifloraItem BOOL;
DECLARE cDates CURSOR FOR
SELECT zgs.shipped, r.warehouse_id
@@ -16212,8 +14333,8 @@ BEGIN
WHERE o.id = vOrder AND r.amount != 0
GROUP BY r.warehouse_id;
- DECLARE cRows CURSOR FOR
- SELECT r.id, r.item_id, i.name, r.amount, r.price, r.rate
+ DECLARE cRows CURSOR FOR
+ SELECT r.id, r.item_id, i.name, r.amount, r.price, r.rate, i.isFloramondo
FROM order_row r
JOIN vn.item i ON i.id = r.item_id
WHERE r.amount != 0
@@ -16232,14 +14353,33 @@ BEGIN
-- Carga los datos del pedido
SELECT o.date_send, o.address_id, o.note,
- a.clientFk, o.company_id, o.agency_id
- INTO vDelivery, vAddress, vNotes,
- vClientId, vCompanyId, vAgencyModeId
+ a.clientFk, o.company_id, o.agency_id
+ INTO vDelivery, vAddress, vNotes,
+ vClientId, vCompanyId, vAgencyModeId
FROM hedera.`order` o
JOIN vn.address a ON a.id = o.address_id
WHERE o.id = vOrder;
-
- -- Comprueba que el pedido no est? vac?o
+
+ -- Carga las fechas de salida de cada almac?n
+ CALL vn.zone_getShipped (vDelivery, vAddress, vAgencyModeId, FALSE);
+
+ -- Trabajador que realiza la accion
+ IF vUserId IS NULL THEN
+ SELECT employeeFk INTO vUserId FROM orderConfig;
+ END IF;
+
+ START TRANSACTION;
+ -- Comprueba que el pedido no esta confirmado
+ SELECT o.confirmed INTO vIsConfirmed
+ FROM hedera.`order` o
+ WHERE o.id = vOrder
+ FOR UPDATE;
+
+ IF vIsConfirmed THEN
+ CALL util.throw ('ORDER_ALREADY_CONFIRMED');
+ END IF;
+
+ -- Comprueba que el pedido no esta vacio
SELECT COUNT(*) > 0 INTO vOk
FROM order_row WHERE order_id = vOrder AND amount > 0;
@@ -16247,18 +14387,7 @@ BEGIN
CALL util.throw ('ORDER_EMPTY');
END IF;
- -- Carga las fechas de salida de cada almac?n
- CALL vn.zone_getShipped (vDelivery, vAddress, vAgencyModeId, FALSE);
-
- -- Trabajador que realiza la acci?n
- IF vUserId IS NULL THEN
- SELECT employeeFk INTO vUserId FROM orderConfig;
- END IF;
-
-- Crea los tickets del pedido
-
- START TRANSACTION;
-
OPEN cDates;
lDates:
@@ -16266,7 +14395,7 @@ BEGIN
SET vTicket = NULL;
SET vDone = FALSE;
FETCH cDates INTO vShipment, vWarehouse;
-
+
IF vDone THEN
LEAVE lDates;
END IF;
@@ -16280,20 +14409,20 @@ BEGIN
ON o.address_id = t.addressFk
AND vWarehouse = t.warehouseFk
-- AND o.agency_id = t.agencyModeFk
- AND o.date_send = t.landed
+ AND o.date_send = t.landed
AND vShipment = DATE(t.shipped)
WHERE o.id = vOrder
- AND t.invoiceOutFk IS NULL
+ AND t.refFk IS NULL
AND IFNULL(tls.alertLevel,0) = 0
LIMIT 1;
-
+
-- Crea el ticket en el caso de no existir uno adecuado
IF vTicket IS NULL
THEN
-
- SET vShipment = IFNULL(vShipment, CURDATE());
-
+
+ SET vShipment = IFNULL(vShipment, util.VN_CURDATE());
+
CALL vn.ticket_add(
vClientId,
vShipment,
@@ -16313,12 +14442,12 @@ BEGIN
Id_Trabajador = vUserId,
state_id = TICKET_FREE;
END IF;
-
+
INSERT IGNORE INTO vn.orderTicket
SET orderFk = vOrder,
ticketFk = vTicket;
- -- A?ade las notas
+ -- Añade las notas
IF vNotes IS NOT NULL AND vNotes != ''
THEN
@@ -16330,32 +14459,37 @@ BEGIN
`description` = CONCAT(VALUES(`description`),'. ', `description`);
END IF;
- -- A?ade los movimientos y sus componentes
+ -- Añade los movimientos y sus componentes
OPEN cRows;
lRows:
LOOP
+
SET vDone = FALSE;
- FETCH cRows INTO vRowId, vItem, vConcept, vAmount, vPrice, vRate;
+
+ FETCH cRows INTO vRowId, vItem, vConcept, vAmount, vPrice, vRate, vIsLogifloraItem;
IF vDone THEN
LEAVE lRows;
END IF;
+
SET vSale = NULL;
+
SELECT s.id INTO vSale
FROM vn.sale s
WHERE ticketFk = vTicket
AND price = vPrice
AND itemFk = vItem
- AND discount = 0
+ AND discount = 0
LIMIT 1;
+
IF vSale THEN
UPDATE vn.sale
SET quantity = quantity + vAmount
WHERE id = vSale;
ELSE
- INSERT INTO vn.sale
+ INSERT INTO vn.sale
SET
itemFk = vItem,
ticketFk = vTicket,
@@ -16375,37 +14509,37 @@ BEGIN
WHERE cm.order_row_id = vRowId
GROUP BY vSale, cm.component_id;
END IF;
- UPDATE order_row SET Id_Movimiento = vSale
+ UPDATE order_row SET Id_Movimiento = vSale
WHERE id = vRowId;
-
- -- Inserta en putOrder si la compra es de Floramondo
- IF vn.isLogifloraDay(vShipment, vWarehouse) THEN
-
+
+ -- Inserta en putOrder si la compra es de Floramondo
+ IF vIsLogifloraItem THEN
+
CALL cache.availableNoRaids_refresh(vCalc,FALSE,vWarehouse,vShipment);
-
+
SET @available := 0;
-
+
SELECT GREATEST(0,available) INTO @available
FROM cache.availableNoRaids
WHERE calc_id = vCalc
AND item_id = vItem;
-
- UPDATE cache.availableNoRaids
+
+ UPDATE cache.availableNoRaids
SET available = GREATEST(0,available - vAmount)
WHERE item_id = vItem
AND calc_id = vCalc;
-
- INSERT INTO edi.putOrder (deliveryInformationID,
- supplyResponseId,
- quantity ,
- EndUserPartyId,
+
+ INSERT INTO edi.putOrder (deliveryInformationID,
+ supplyResponseId,
+ quantity ,
+ EndUserPartyId,
EndUserPartyGLN,
FHAdminNumber,
saleFk)
- SELECT di.ID,
- i.supplyResponseFk,
- CEIL((vAmount - @available)/ sr.NumberOfItemsPerCask ),
- o.address_id ,
+ SELECT di.ID,
+ i.supplyResponseFk,
+ CEIL((vAmount - @available)/ sr.NumberOfItemsPerCask),
+ o.address_id ,
vClientId,
IFNULL(ca.fhAdminNumber, fhc.defaultAdminNumber),
vSale
@@ -16415,16 +14549,16 @@ BEGIN
LEFT JOIN edi.clientFHAdminNumber ca ON ca.clientFk = vClientId
JOIN edi.floraHollandConfig fhc
JOIN hedera.`order` o ON o.id = vOrder
- WHERE i.id = vItem
- AND di.LatestOrderDateTime > NOW()
+ WHERE i.id = vItem
+ AND di.LatestOrderDateTime > util.VN_NOW()
AND vAmount > @available
LIMIT 1;
-
+
END IF;
-
+
END LOOP;
-
- CLOSE cRows;
+
+ CLOSE cRows;
-- Fija el coste
DROP TEMPORARY TABLE IF EXISTS tComponents;
@@ -16449,19 +14583,8 @@ BEGIN
CLOSE cDates;
DELETE FROM basketOrder WHERE orderFk = vOrder;
-
- SELECT o.confirmed INTO vIsConfirmed
- FROM hedera.`order` o
- JOIN vn.address a ON a.id = o.address_id
- WHERE o.id = vOrder;
- -- Comprueba que el pedido no est? confirmado
-
- IF vIsConfirmed THEN
- CALL util.throw ('ORDER_ALREADY_CONFIRMED');
- END IF;
-
- UPDATE `order` SET confirmed = TRUE, confirm_date = NOW()
+ UPDATE `order` SET confirmed = TRUE, confirm_date = util.VN_NOW()
WHERE id = vOrder;
COMMIT;
@@ -16471,6 +14594,8 @@ DELIMITER ;
/*!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 `order_doRecalc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -16478,8 +14603,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `order_doRecalc`()
proc: BEGIN
@@ -16533,6 +14656,8 @@ DELIMITER ;
/*!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 `order_getAvailable` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -16540,8 +14665,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `order_getAvailable`(vSelf INT)
BEGIN
@@ -16578,6 +14701,8 @@ DELIMITER ;
/*!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 `order_getTax` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -16585,8 +14710,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `order_getTax`()
READS SQL DATA
@@ -16653,6 +14776,8 @@ DELIMITER ;
/*!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 `order_getTotal` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -16660,8 +14785,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `order_getTotal`()
BEGIN
@@ -16691,6 +14814,8 @@ DELIMITER ;
/*!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 `order_recalc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -16698,8 +14823,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `order_recalc`(vSelf INT)
BEGIN
@@ -16737,6 +14860,8 @@ DELIMITER ;
/*!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 `order_requestRecalc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -16744,8 +14869,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `order_requestRecalc`(vSelf INT)
proc: BEGIN
@@ -16765,6 +14888,8 @@ DELIMITER ;
/*!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 `order_update` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -16772,8 +14897,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `order_update`(vSelf INT)
proc: BEGIN
@@ -16835,7 +14958,7 @@ proc: BEGIN
CALL vn.ticketCalculatePurge;
END IF;
- UPDATE `order` SET date_make = NOW()
+ UPDATE `order` SET date_make = util.VN_NOW()
WHERE id = vSelf;
COMMIT;
@@ -16845,6 +14968,8 @@ DELIMITER ;
/*!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 `survey_vote` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -16852,8 +14977,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `survey_vote`(vAnswer INT)
BEGIN
@@ -16867,7 +14990,7 @@ BEGIN
INSERT INTO surveyVote SET
surveyFk = vSurvey,
- userFk = account.userGetId();
+ userFk = account.myUser_getId();
UPDATE surveyAnswer SET votes = votes + 1
WHERE id = vAnswer;
@@ -16877,6 +15000,8 @@ DELIMITER ;
/*!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 `tpvTransaction_confirm` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -16884,8 +15009,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `tpvTransaction_confirm`(
vAmount INT
@@ -17002,6 +15125,8 @@ DELIMITER ;
/*!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 `tpvTransaction_confirmAll` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -17009,8 +15134,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `tpvTransaction_confirmAll`(vDate DATE)
BEGIN
@@ -17053,6 +15176,8 @@ DELIMITER ;
/*!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 `tpvTransaction_confirmById` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -17060,8 +15185,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `tpvTransaction_confirmById`(vOrder INT)
BEGIN
@@ -17095,6 +15218,8 @@ DELIMITER ;
/*!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 `tpvTransaction_undo` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -17102,8 +15227,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `tpvTransaction_undo`(vSelf INT)
p: BEGIN
@@ -17189,6 +15312,8 @@ DELIMITER ;
/*!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 `visitUser_new` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -17196,8 +15321,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `visitUser_new`(
vAccess INT
@@ -17208,7 +15331,7 @@ BEGIN
INSERT INTO visitUser SET
accessFk = vAccess,
- userFk = account.userGetId();
+ userFk = account.myUser_getId();
SET vUserVisit = LAST_INSERT_ID();
@@ -17216,13 +15339,15 @@ BEGIN
WHERE ssid = vSsid;
DELETE FROM userSession
- WHERE lastUpdate < TIMESTAMPADD(HOUR, -1, NOW());
+ WHERE lastUpdate < TIMESTAMPADD(HOUR, -1, util.VN_NOW());
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 `visit_listByBrowser` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -17230,8 +15355,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `visit_listByBrowser`(vFrom DATE, vTo DATE)
BEGIN
@@ -17260,6 +15383,8 @@ DELIMITER ;
/*!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 `visit_register` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -17267,8 +15392,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `visit_register`(
vVisit INT
@@ -17438,6 +15561,8 @@ CREATE TABLE `nst` (
--
-- Dumping routines for database 'nst'
--
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `nodeAdd` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -17445,8 +15570,6 @@ CREATE TABLE `nst` (
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `nodeAdd`(IN `vScheme` VARCHAR(45), IN `vTable` VARCHAR(45), IN `vParentFk` INT, IN `vChild` VARCHAR(100))
BEGIN
@@ -17513,6 +15636,8 @@ DELIMITER ;
/*!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 `nodeDelete` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -17520,8 +15645,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `nodeDelete`(IN `vScheme` VARCHAR(45), IN `vTable` VARCHAR(45), IN `vNodeId` INT)
BEGIN
@@ -17556,6 +15679,8 @@ DELIMITER ;
/*!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 `nodeMove` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -17563,8 +15688,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `nodeMove`(IN `vScheme` VARCHAR(45), IN `vTable` VARCHAR(45), IN `vNodeId` INT, IN `vFatherId` INT)
BEGIN
@@ -17639,6 +15762,8 @@ DELIMITER ;
/*!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 `nodeRecalc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -17646,8 +15771,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `nodeRecalc`(IN `vScheme` VARCHAR(45), IN `vTable` VARCHAR(45))
BEGIN
@@ -17671,6 +15794,8 @@ DELIMITER ;
/*!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 `nodeTree` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -17678,8 +15803,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `nodeTree`(IN `vScheme` VARCHAR(45), IN `vTable` VARCHAR(45), IN `vGap` INT, IN `vShouldShow` BOOLEAN)
BEGIN
@@ -17714,6 +15837,8 @@ DELIMITER ;
/*!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 `nodeTree_pako` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -17721,8 +15846,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `nodeTree_pako`(IN `vScheme` VARCHAR(45), IN `vTable` VARCHAR(45), IN `vGap` INT, IN `vShouldShow` BOOLEAN)
BEGIN
@@ -18419,6 +16542,8 @@ CREATE TABLE `sipReg` (
--
-- Dumping routines for database 'pbx'
--
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP FUNCTION IF EXISTS `clientFromPhone` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -18426,8 +16551,6 @@ CREATE TABLE `sipReg` (
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `clientFromPhone`(vPhone VARCHAR(255)) RETURNS int(11)
DETERMINISTIC
@@ -18442,6 +16565,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `phone_format` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -18449,8 +16574,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `phone_format`(vPhone VARCHAR(255)) RETURNS varchar(255) CHARSET utf8
DETERMINISTIC
@@ -18490,6 +16613,8 @@ DELIMITER ;
/*!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 `phone_isValid` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -18497,8 +16622,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `phone_isValid`(vPhone VARCHAR(255))
BEGIN
@@ -18525,6 +16648,8 @@ DELIMITER ;
/*!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 `queue_isValid` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -18532,8 +16657,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `queue_isValid`(vQueue VARCHAR(255))
BEGIN
@@ -18558,6 +16681,8 @@ DELIMITER ;
/*!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 `sip_getExtension` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -18565,8 +16690,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sip_getExtension`(vUserId INT(10))
BEGIN
@@ -18588,6 +16711,8 @@ DELIMITER ;
/*!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 `sip_isValid` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -18595,8 +16720,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sip_isValid`(vExtension VARCHAR(255))
BEGIN
@@ -18622,6 +16745,8 @@ DELIMITER ;
/*!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 `sip_setPassword` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -18629,8 +16754,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sip_setPassword`(
vUser VARCHAR(255),
@@ -18849,10 +16972,10 @@ CREATE TABLE `business_labour` (
KEY `horario_tipo` (`calendar_labour_type_id`),
KEY `business_labour_department_idx` (`department_id`),
CONSTRAINT `bus_restriction` FOREIGN KEY (`business_id`) REFERENCES `business` (`business_id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `business_labour_FK` FOREIGN KEY (`workcenter_id`) REFERENCES `vn`.`workCenter` (`id`) ON UPDATE CASCADE,
CONSTRAINT `business_labour_agreement` FOREIGN KEY (`labour_agreement_id`) REFERENCES `labour_agreement` (`labour_agreement_id`) ON UPDATE CASCADE,
CONSTRAINT `business_labour_department_id` FOREIGN KEY (`department_id`) REFERENCES `vn`.`department` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `horario_tipo` FOREIGN KEY (`calendar_labour_type_id`) REFERENCES `calendar_labour_type` (`calendar_labour_type_id`) ON UPDATE CASCADE,
- CONSTRAINT `workcenter_labour` FOREIGN KEY (`workcenter_id`) REFERENCES `workcenter` (`workcenter_id`) ON UPDATE CASCADE
+ CONSTRAINT `horario_tipo` FOREIGN KEY (`calendar_labour_type_id`) REFERENCES `calendar_labour_type` (`calendar_labour_type_id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -18931,7 +17054,7 @@ CREATE TABLE `calendar_labour__` (
KEY `fki_workcenter_calendar` (`workcenter_id`),
CONSTRAINT `fk_calendar_labour_calendar_free1` FOREIGN KEY (`calendar_free_id`) REFERENCES `calendar_free__` (`calendar_free_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `fk_calendar_labour_legend_id` FOREIGN KEY (`calendar_labour_legend_id`) REFERENCES `calendar_labour_legend__` (`calendar_labour_legend_id`) ON DELETE NO ACTION ON UPDATE CASCADE,
- CONSTRAINT `workcenter_calendar` FOREIGN KEY (`workcenter_id`) REFERENCES `workcenter` (`workcenter_id`) ON UPDATE CASCADE
+ CONSTRAINT `workcenter_calendar` FOREIGN KEY (`workcenter_id`) REFERENCES `workcenter__` (`workcenter_id`) ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -18968,28 +17091,6 @@ CREATE TABLE `calendar_labour_type` (
) ENGINE=InnoDBDEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Table structure for table `calendar_state`
---
-
-DROP TABLE IF EXISTS `calendar_state`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `calendar_state` (
- `calendar_state_id` int(11) NOT NULL AUTO_INCREMENT,
- `type` varchar(30) NOT NULL,
- `rgb` varchar(7) NOT NULL,
- `color` bigint(20) DEFAULT '0',
- `permissionRate` decimal(3,2) DEFAULT NULL,
- `code` varchar(45) DEFAULT NULL,
- `isAllowedToWork` tinyint(4) NOT NULL DEFAULT '0',
- `isPrintable` tinyint(1) NOT NULL DEFAULT '0',
- `discountRate` decimal(3,2) DEFAULT NULL,
- `holidayEntitlementRate` decimal(3,2) DEFAULT '1.00',
- PRIMARY KEY (`calendar_state_id`)
-) ENGINE=InnoDBDEFAULT CHARSET=utf8;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
--
-- Table structure for table `currency__`
--
@@ -19150,13 +17251,13 @@ CREATE TABLE `nation__` (
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `periodos`
+-- Table structure for table `periodos__`
--
-DROP TABLE IF EXISTS `periodos`;
+DROP TABLE IF EXISTS `periodos__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `periodos` (
+CREATE TABLE `periodos__` (
`fecha` date NOT NULL,
`periodo` int(11) DEFAULT NULL,
PRIMARY KEY (`fecha`)
@@ -19179,7 +17280,6 @@ SET character_set_client = utf8;
`birth` tinyint NOT NULL,
`firstname` tinyint NOT NULL,
`p2` tinyint NOT NULL,
- `nis` tinyint NOT NULL,
`id_trabajador` tinyint NOT NULL,
`isDisable` tinyint NOT NULL,
`isFreelance` tinyint NOT NULL,
@@ -19359,13 +17459,13 @@ CREATE TABLE `townKk` (
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `workcenter`
+-- Table structure for table `workcenter__`
--
-DROP TABLE IF EXISTS `workcenter`;
+DROP TABLE IF EXISTS `workcenter__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `workcenter` (
+CREATE TABLE `workcenter__` (
`workcenter_id` int(11) NOT NULL AUTO_INCREMENT,
`name` longtext,
`center_id` int(11) DEFAULT NULL,
@@ -19920,15 +18020,15 @@ SET character_set_client = @saved_cs_client;
--
-- Dumping routines for database 'sage'
--
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `accountingMovements_add` */;
/*!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_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `accountingMovements_add`(vYear INT, vCompanyFk INT)
BEGIN
@@ -20181,6 +18281,7 @@ BEGIN
FROM vn.XDiario
WHERE enlazadoSage = FALSE
ORDER BY ASIEN, FECREGCON DESC, FECHA_EX DESC
+ LIMIT 10000000000000000000
) sub GROUP BY ASIEN
)sub2 ON sub2.ASIEN = x.ASIEN
LEFT JOIN ( SELECT DISTINCT(account),cu.code
@@ -20372,558 +18473,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `accountingMovements_add__` */;
-/*!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_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `accountingMovements_add__`(vYear INT, vCompanyFk INT)
-BEGIN
-/**
- * Traslada la info de contabilidad generada en base a vn.XDiario a la tabla sage.movConta para poder ejecutar posteriormente el proceso de importación de datos de SQL Server
- * Solo traladará los asientos marcados con el campo vn.XDiario.enlazadoSage = FALSE
- * @vYear Año contable del que se quiere trasladar la información
- * @vCompanyFk Empresa de la que se quiere trasladar datos
- */
- DECLARE vDatedFrom DATETIME;
- DECLARE vDatedTo DATETIME;
- DECLARE vDuaTransactionFk INT;
- DECLARE vTaxImportFk INT;
- DECLARE vTaxImportReducedFk INT;
- DECLARE vTransactionExportFk INT;
- DECLARE vTransactionExportTaxFreeFk INT;
- DECLARE vSerialDua VARCHAR(1) DEFAULT 'D';
- DECLARE vInvoiceTypeInformativeCode VARCHAR(1);
- DECLARE vCountryCanariasCode, vCountryCeutaMelillaCode VARCHAR(2) ;
- DECLARE vBookEntries TEXT;
-
- SELECT SiglaNacion INTO vCountryCanariasCode
- FROM Naciones
- WHERE Nacion ='ISLAS CANARIAS';
-
- SELECT SiglaNacion INTO vCountryCeutaMelillaCode
- FROM Naciones
- WHERE Nacion ='CEUTA Y MELILLA';
-
- SELECT CodigoTransaccion INTO vDuaTransactionFk
- FROM TiposTransacciones
- WHERE Transaccion = 'Import. bienes y serv. corrientes pdte. liquidar';
-
- SELECT CodigoIva INTO vTaxImportFk
- FROM TiposIva
- WHERE Iva = 'IVA 21% importaciones';
-
- SELECT CodigoIva INTO vTaxImportReducedFk
- FROM TiposIva
- WHERE Iva = 'IVA 10% importaciones';
-
- SELECT CodigoTransaccion INTO vTransactionExportFk
- FROM TiposTransacciones
- WHERE Transaccion = 'Exportaciones definitivas';
-
- SELECT CodigoTransaccion INTO vTransactionExportTaxFreeFk
- FROM TiposTransacciones
- WHERE Transaccion = 'Envíos definitivos a Canarias, Ceuta y Melilla';
-
- SELECT codeSage INTO vInvoiceTypeInformativeCode
- FROM invoiceType WHERE code ='informative';
-
- SELECT CAST(CONCAT(vYear, '-01-01') AS DATETIME), util.dayEnd(CAST(CONCAT(vYear, '-12-31') AS DATE))
- INTO vDatedFrom, vDatedTo;
-
- TRUNCATE movContaIVA;
-
- DELETE FROM movConta
- WHERE enlazadoSage = FALSE
- AND Asiento <> 1 ;
-
- CALL clientSupplier_add(vCompanyFk);
- CALL pgc_add(vCompanyFk);
- CALL invoiceOut_manager(vYear, vCompanyFk);
- CALL invoiceIn_manager(vYear, vCompanyFk);
-
- INSERT INTO movConta(TipoEntrada,
- Ejercicio,
- CodigoEmpresa,
- Asiento,
- CargoAbono,
- CodigoCuenta,
- Contrapartida,
- FechaAsiento,
- Comentario,
- ImporteAsiento,
- NumeroPeriodo,
- FechaGrabacion,
- CodigoDivisa,
- ImporteCambio,
- ImporteDivisa,
- FactorCambio,
- IdProcesoIME,
- TipoCarteraIME,
- TipoAnaliticaIME,
- StatusTraspasadoIME,
- TipoImportacionIME,
- Metalico347,
- BaseIva1,
- PorBaseCorrectora1,
- PorIva1,
- CuotaIva1,
- PorRecargoEquivalencia1,
- RecargoEquivalencia1,
- CodigoTransaccion1,
- BaseIva2,
- PorBaseCorrectora2,
- PorIva2,
- CuotaIva2,
- PorRecargoEquivalencia2,
- RecargoEquivalencia2,
- CodigoTransaccion2,
- BaseIva3,
- PorBaseCorrectora3,
- PorIva3,
- CuotaIva3,
- PorRecargoEquivalencia3,
- RecargoEquivalencia3,
- CodigoTransaccion3,
- BaseIva4,
- PorBaseCorrectora4,
- PorIva4,
- CuotaIva4,
- PorRecargoEquivalencia4,
- RecargoEquivalencia4,
- CodigoTransaccion4,
- Año,
- Serie,
- Factura,
- SuFacturaNo,
- FechaFactura,
- ImporteFactura,
- TipoFactura,
- CodigoCuentaFactura,
- CifDni,
- Nombre,
- CodigoRetencion,
- BaseRetencion,
- PorRetencion,
- ImporteRetencion,
- SiglaNacion,
- EjercicioFactura,
- FechaOperacion,
- Exclusion347,
- MantenerAsiento,
- ClaveOperacionFactura_,
- TipoRectificativa,
- FechaFacturaOriginal,
- BaseImponibleOriginal,
- CuotaIvaOriginal,
- ClaseAbonoRectificativas,
- RecargoEquivalenciaOriginal,
- LibreA1,
- CodigoIva1,
- CodigoIva2,
- CodigoIva3,
- CodigoIva4,
- IvaDeducible1,
- IvaDeducible2,
- IvaDeducible3,
- IvaDeducible4,
- Intracomunitaria
- )
- SELECT 'EN' TipoEntrada,
- YEAR(x.FECHA) Ejercicio,
- IF (@@hostname = 'db', c.companyCode, companyCodeTest) AS CodigoEmpresa,
- x.ASIEN Asiento,
- IF(EURODEBE <> 0 OR (EURODEBE = 0 AND EUROHABER IS NULL), 'D', 'H') CargoAbono,
- x.SUBCTA CodigoCuenta,
- x.CONTRA Contrapartida,
- x.FECHA FechaAsiento,
- x.CONCEPTO Comentario,
- IF(x.EURODEBE, x.EURODEBE, x.EUROHABER) ImporteAsiento,
- MONTH(x.FECHA) NumeroPeriodo,
- IF(sub2.FECREGCON IS NULL, sub2.FECHA_EX, sub2.FECREGCON) FechaGrabacion,
- IF(x.CAMBIO, IFNULL(mci.CodigoDivisa, sub3.code), '') CodigoDivisa,
- x.CAMBIO ImporteCambio,
- IFNULL(x.DEBEME, x.HABERME) ImporteDivisa,
- IF(x.CAMBIO, TRUE, FALSE) FactorCambio,
- NULL IdProcesoIME,
- 0 TipoCarteraIME,
- 0 TipoAnaliticaIME,
- 0 StatusTraspasadoIME,
- 0 TipoImportacionIME,
- x.METAL Metalico347,
- mci.BaseIva1,
- mci.PorBaseCorrectora1,
- mci.PorIva1,
- mci.CuotaIva1,
- mci.PorRecargoEquivalencia1,
- mci.RecargoEquivalencia1,
- mci.CodigoTransaccion1,
- mci.BaseIva2,
- mci.PorBaseCorrectora2,
- mci.PorIva2,
- mci.CuotaIva2,
- mci.PorRecargoEquivalencia2,
- mci.RecargoEquivalencia2,
- mci.CodigoTransaccion2,
- mci.BaseIva3,
- mci.PorBaseCorrectora3,
- mci.PorIva3,
- mci.CuotaIva3,
- mci.PorRecargoEquivalencia3,
- mci.RecargoEquivalencia3,
- mci.CodigoTransaccion3,
- mci.BaseIva4,
- mci.PorBaseCorrectora4,
- mci.PorIva4,
- mci.CuotaIva4,
- mci.PorRecargoEquivalencia4,
- mci.RecargoEquivalencia4,
- mci.CodigoTransaccion4,
- mci.Año,
- mci.Serie,
- mci.Factura,
- mci.SuFacturaNo,
- mci.FechaFactura,
- mci.ImporteFactura,
- mci.TipoFactura,
- mci.CodigoCuentaFactura,
- mci.CifDni,
- mci.Nombre,
- mci.CodigoRetencion,
- mci.BaseRetencion,
- mci.PorRetencion,
- mci.ImporteRetencion,
- mci.SiglaNacion,
- mci.EjercicioFactura,
- mci.FechaOperacion,
- mci.Exclusion347,
- TRUE,
- mci.ClaveOperacionFactura,
- mci.TipoRectificativa,
- mci.FechaFacturaOriginal,
- mci.BaseImponibleOriginal,
- mci.CuotaIvaOriginal,
- mci.ClaseAbonoRectificativas,
- mci.RecargoEquivalenciaOriginal,
- mci.LibreA1,
- mci.CodigoIva1,
- mci.CodigoIva2,
- mci.CodigoIva3,
- mci.CodigoIva4,
- mci.IvaDeducible1,
- mci.IvaDeducible2,
- mci.IvaDeducible3,
- mci.IvaDeducible4,
- mci.Intracomunitaria
- FROM vn.XDiario x
- JOIN vn.company c ON c.id = x.empresa_id
- LEFT JOIN movContaIVA mci ON mci.id = x.id
- LEFT JOIN (SELECT *
- FROM (SELECT DISTINCT ASIEN, FECREGCON, FECHA_EX
- FROM vn.XDiario
- WHERE enlazadoSage = FALSE
- ORDER BY ASIEN, FECREGCON DESC, FECHA_EX DESC
- ) sub GROUP BY ASIEN
- )sub2 ON sub2.ASIEN = x.ASIEN
- LEFT JOIN ( SELECT DISTINCT(account),cu.code
- FROM vn.bank b
- JOIN vn.currency cu ON cu.id = b.currencyFk
- WHERE cu.code <> 'EUR' -- no se informa cuando la divisa en EUR
- )sub3 ON sub3.account = x.SUBCTA
- WHERE x.enlazadoSage = FALSE
- AND x.empresa_id = vCompanyFk
- AND x.FECHA BETWEEN vDatedFrom AND vDatedTo;
-
--- Metálicos
- UPDATE movConta m
- JOIN (SELECT Asiento,
- c.socialName name,
- c.fi,
- n.SiglaNacion,
- m.CodigoCuenta,
- m.Contrapartida
- FROM movConta m
- LEFT JOIN vn.client c ON c.id = IF(m.CargoAbono = 'H',
- CAST(SUBSTRING(m.CodigoCuenta, 3, LENGTH(m.CodigoCuenta)) AS UNSIGNED),
- CAST(SUBSTRING(m.Contrapartida, 3, LENGTH(m.Contrapartida)) AS UNSIGNED))
- LEFT JOIN Naciones n ON n.countryFk = c.countryFk
- WHERE m.Metalico347 = TRUE
- AND m.enlazadoSage = FALSE
- )sub ON m.Asiento = sub.Asiento
- SET m.Metalico347 = TRUE,
- m.TipoFactura = vInvoiceTypeInformativeCode,
- m.CifDni = sub.fi,
- m.Nombre = sub.name,
- m.SiglaNacion = sub.SiglaNacion
- WHERE m.enlazadoSage = FALSE;
-
- UPDATE movConta m
- SET m.Metalico347 = FALSE,
- m.TipoFactura = ''
- WHERE m.CargoAbono = 'D'
- AND m.enlazadoSage = FALSE;
-
--- Elimina cuentas de cliente/proveedor que no se utilizarán en la importación
- DELETE cp
- FROM clientesProveedores cp
- LEFT JOIN movConta mc ON mc.codigoCuenta = cp.codigoCuenta
- AND mc.enlazadoSage = FALSE
- WHERE mc.codigoCuenta IS NULL;
-
--- Elimina cuentas contables que no se utilizarán en la importación
- DELETE pc
- FROM planCuentasPGC pc
- LEFT JOIN movConta mc ON mc.codigoCuenta = pc.codigoCuenta
- AND mc.enlazadoSage = FALSE
- WHERE mc.codigoCuenta IS NULL;
-
--- DUAS
- UPDATE movConta mci
- JOIN vn.XDiario x ON x.ASIEN = mci.Asiento
- JOIN TiposIva ti ON ti.CodigoIva = x.IVA
- JOIN vn.pgcMaster pm ON pm.code = mci.CodigoCuenta COLLATE utf8_general_ci
- SET mci.BaseIva1 = x.BASEEURO,
- mci.PorIva1 = x.IVA,
- mci.CuotaIva1 = CAST((x.IVA / 100) * x.BASEEURO AS DECIMAL(10, 2)),
- mci.CodigoTransaccion1 = vDuaTransactionFk,
- mci.CodigoIva1 = vTaxImportReducedFk,
- mci.IvaDeducible1 = TRUE,
- mci.FechaFacturaOriginal = x.FECHA_EX,
- mci.SuFacturaNo = x.FACTURAEX,
- mci.FechaOperacion = x.FECHA_OP,
- mci.ImporteFactura = mci.ImporteFactura + x.BASEEURO + CAST((x.IVA / 100) * x.BASEEURO AS DECIMAL(10, 2))
- WHERE pm.description = 'HP Iva pendiente'
- AND mci.enlazadoSage = FALSE
- AND x.SERIE = vSerialDua COLLATE utf8_general_ci
- AND ti.Iva = 'I.V.A. 10% Nacional';
-
- UPDATE movConta mci
- JOIN vn.XDiario x ON x.ASIEN = mci.Asiento
- JOIN TiposIva ti ON ti.CodigoIva = x.IVA
- JOIN vn.pgcMaster pm ON pm.code = mci.CodigoCuenta COLLATE utf8_general_ci
- SET mci.BaseIva2 = x.BASEEURO ,
- mci.PorIva2 = x.IVA,
- mci.CuotaIva2 = CAST((x.IVA / 100) * x.BASEEURO AS DECIMAL(10,2)),
- mci.CodigoTransaccion2 = vDuaTransactionFk ,
- mci.CodigoIva2 = vTaxImportFk,
- mci.IvaDeducible2 = TRUE,
- mci.ImporteFactura = mci.ImporteFactura + x.BASEEURO + CAST((x.IVA / 100) * x.BASEEURO AS DECIMAL(10, 2))
- WHERE pm.description = 'HP Iva pendiente'
- AND mci.enlazadoSage = FALSE
- AND x.SERIE = vSerialDua COLLATE utf8_general_ci
- AND ti.Iva = 'I.V.A. 21%';
-
--- Rectificativas
- UPDATE movConta mci
- JOIN (SELECT x.ASIEN, x.FECHA_RT, x.SERIE_RT, x.FACTU_RT
- FROM movConta mci
- JOIN vn.XDiario x ON x.ASIEN = mci.Asiento
- WHERE mci.TipoRectificativa > 0
- AND mci.enlazadoSage = FALSE
- AND x.FACTU_RT IS NOT NULL
- GROUP BY x.ASIEN
- ) sub ON sub.ASIEN = mci.Asiento
- SET mci.EjercicioFacturaOriginal = YEAR(sub.FECHA_RT),
- mci.SerieFacturaOriginal = sub.SERIE_RT,
- mci.NumeroFacturaOriginal = sub.FACTU_RT
- WHERE mci.TipoRectificativa > 0 AND
- mci.enlazadoSage = FALSE ;
-
--- Exportaciones Andorras y Canarias cambia TT (la cuenta es compartida)
- UPDATE movConta mci
- SET CodigoTransaccion1 = vTransactionExportTaxFreeFk,
- CodigoTransaccion2 = IF(CodigoTransaccion2 = 0, 0, vTransactionExportTaxFreeFk),
- CodigoTransaccion3 = IF(CodigoTransaccion3 = 0, 0, vTransactionExportTaxFreeFk),
- CodigoTransaccion4 = IF(CodigoTransaccion4 = 0, 0, vTransactionExportTaxFreeFk)
- WHERE enlazadoSage = FALSE
- AND (CodigoTransaccion1 = vTransactionExportFk
- OR CodigoTransaccion2 = vTransactionExportFk
- OR CodigoTransaccion3 = vTransactionExportFk
- OR CodigoTransaccion4 = vTransactionExportFk)
- AND SiglaNacion IN (vCountryCanariasCode COLLATE utf8_general_ci, vCountryCeutaMelillaCode COLLATE utf8_general_ci);
-
- UPDATE movConta mc
- SET CodigoDivisa = 'USD',
- FactorCambio = TRUE,
- ImporteCambio = ABS( CAST( IF( ImporteDivisa <> 0 AND ImporteCambio = 0, ImporteAsiento / ImporteDivisa, ImporteCambio) AS DECIMAL( 10, 2)))
- WHERE enlazadoSage = FALSE
- AND (ImporteCambio <> 0 OR ImporteDivisa <> 0 OR FactorCambio);
-
- UPDATE movConta mc
- SET importeDivisa= -importeDivisa
- WHERE enlazadoSage = FALSE
- AND importeDivisa > 0
- AND ImporteAsiento < 0;
-
- -- Comprobación que los importes e ivas sean correctos, avisa vía CAU
- SELECT GROUP_CONCAT(Asiento ORDER BY Asiento ASC SEPARATOR ' \n\r') INTO vBookEntries
- FROM(SELECT sub.Asiento
- FROM (SELECT mc.Asiento, SUM(mc.ImporteAsiento) amount
- FROM movConta mc
- WHERE mc.enlazadoSage = FALSE
- GROUP BY mc.Asiento)sub
- JOIN (SELECT x.ASIEN, SUM(IFNULL(x.EURODEBE,0) + IFNULL(x.EUROHABER,0)) amount
- FROM vn.XDiario x
- WHERE x.enlazadoSage = FALSE
- GROUP BY ASIEN)sub2 ON sub2.ASIEN = sub.Asiento
- WHERE sub.amount <> sub2.amount
- UNION ALL
- SELECT sub.Asiento
- FROM (SELECT Asiento, SUM(BaseIva1 + BaseIva2 + BaseIva3 + BaseIva4) amountTaxableBase
- FROM movConta
- WHERE TipoFactura <> 'I'
- AND enlazadoSage = FALSE
- GROUP BY Asiento) sub
- JOIN (SELECT ASIEN, SUM(BASEEURO) amountTaxableBase
- FROM (SELECT ASIEN, SUM(BASEEURO) BASEEURO
- FROM vn.XDiario
- WHERE FACTURA
- AND auxiliar <> '*'
- AND enlazadoSage = FALSE
- GROUP BY FACTURA, ASIEN)sub3
- GROUP BY ASIEN) sub2 ON sub2.ASIEN = sub.Asiento
- WHERE sub.amountTaxableBase<>sub2.amountTaxableBase
- AND sub.amountTaxableBase/2 <> sub2.amountTaxableBase) sub;
-
- IF vBookEntries IS NOT NULL THEN
- CALL vn.mail_insert('cau@verdnatura.es, administracion@verdnatura.es',
- 'noreply@verdnatura.es',
- CONCAT('Asientos contables importados incorrectamente'),
- CONCAT('
Existen asientos que difieren entre la info. de XDiario y la que se ha importado a Sage.
- Asientos nº ', vBookEntries, ''));
- 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 DROP PROCEDURE IF EXISTS `clientesProveedoresAdd__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `clientesProveedoresAdd__`()
-BEGIN
-TRUNCATE TABLE clientesProveedores;
- INSERT INTO clientesProveedores
- (CodigoEmpresa,
- ClienteOProveedor,
- CodigoClienteProveedor,
- RazonSocial,
- Nombre,
- Domicilio,
- CodigoCuenta,
- CifDni,
- CifEuropeo,
- CodigoPostal,
- Municipio,
- CodigoProvincia,
- Provincia,
- CodigoNacion,
- SiglaNacion,
- PersonaFisicaJuridica,
- TipoDocumentoPersona,
- CodigoIva,
- Nacion,
- Telefono,
- Telefono2,
- CodigoTransaccion,
- CodigoRetencion,
- Email1,
- iban)
- SELECT IF (@@hostname = 'db', c.companyCode, companyCodeTest) CodigoEmpresa,
- 'C' ClienteOProveedor,
- cl.id CodigoClienteProveedor,
- cl.socialName RazonSocial,
- cl.name Nombre,
- cl.street Domicilio,
- cl.accountingAccount CodigoCuenta,
- TRIM(IF(co.code = LEFT(cl.fi,2), MID(cl.fi,3, length(cl.fi)-1), cl.fi)) AS CifDni,
- IF(sn.NacionCEE,TRIM(CONCAT(co.code, IF(co.code = LEFT(cl.fi,2), MID(cl.fi,3, length(cl.fi)-1), cl.fi))) , "")AS CifEuropeo,
- cl.postcode CodigoPostal,
- cl.city Municipio,
- sp.CodigoProvincia CodigoProvincia,
- p.name Provincia,
- IF (sn.SiglaNacion = "XB",IF(sp.CodigoProvincia IN (51,52), 22, IF (sp.CodigoProvincia IN (35,38), 21, sn.CodigoNacion)), sn.CodigoNacion) CodigoNacion,
- IF (sn.SiglaNacion = "XB",IF(sp.CodigoProvincia IN (51,52), "XC",IF (sp.CodigoProvincia IN (35,38), "XB", sn.SiglaNacion)), sn.SiglaNacion) SiglaNacion,
- IF((cl.fi REGEXP '^([[:blank:]]|[[:digit:]])'), 'J','F') PersonaFisicaJuridica,
- IF((co.id = 1 OR co.id = 30), 1, IF((co.isUeeMember = 1 AND cl.isVies), 2, 4)) TipoDocumentoPersona,
- -- IF(cl.isEqualizated, 'R', IF ((cl.isVies AND cl.countryFk <> 1) OR (NOT co.isUeeMember),'E','I'))AS CodigoIva,
- cl.taxTypeSageFk CodigoIva,
- IF(sn.SiglaNacion = "XB", IF(sp.CodigoProvincia IN (51,52), "CEUTA Y MELILLA", IF (sp.CodigoProvincia IN (35,38), "ISLAS CANARIAS",sn.Nacion)) , sn.Nacion) Nacion,
- cl.phone Telefono,
- cl.mobile Telefono2,
- cl.transactionTypeSageFk CodigoTransaccion,
- 0 CodigoRetencion,
- SUBSTR(cl.email, 1, LOCATE(',', CONCAT(cl.email,','))-1) Email1,
- cl.iban iban
- FROM vn.client cl
- JOIN vn2008.v_xsubclien ON v_xsubclien.Id_Cliente = cl.id
- LEFT JOIN vn.country co ON co.id = cl.countryFk
- LEFT JOIN sage.Naciones sn ON sn.countryFk = co.id
- LEFT JOIN vn.province p ON p.id = cl.provinceFk
- LEFT JOIN sage.Provincias sp ON sp.provinceFk = p.id
- JOIN vn.company c ON c.id = v_xsubclien.empresa_id
- WHERE cl.isRelevant AND c.code = 'VNL'
- UNION ALL
- SELECT IF (@@hostname = 'db', c.companyCode, companyCodeTest) CodigoEmpresa,
- 'P' ClienteOProveedor,
- s.id CodigoClienteProveedor,
- s.name RazonSocial,
- s.name Nombre,
- s.street Domicilio,
- s.account CodigoCuenta,
- TRIM(IF(co.code = LEFT(s.nif,2), MID(s.nif,3, length(s.nif)-1), s.nif)) CifDni,
- IF(sn.NacionCEE,TRIM(CONCAT(co.code, IF(co.code = LEFT(s.nif,2), MID(s.nif,3, length(s.nif)-1), s.nif))), "") AS CifEuropeo,
- s.postCode CodigoPostal,
- s.city Municipio,
- sp.CodigoProvincia CodigoProvincia,
- p.name Provincia,
- sn.CodigoNacion CodigoNacion,
- sn.SiglaNacion SiglaNacion,
- IF((s.nif REGEXP '^([[:blank:]]|[[:digit:]])'),'J','F') PersonaFisicaJuridica,
- IF((co.id = 1 OR co.id = 30),1,IF((co.isUeeMember = 1), 2, 4)) TipoDocumentoPersona,
- -- 'I' CodigoIva,
- s.taxTypeSageFk CodigoIva,
- sn.Nacion Nacion,
- con.Telefono Telefono,
- con.Movil Telefono2,
- s.transactionTypeSageFk CodigoTransaccion,
- s.withholdingSageFk CodigoRetencion,
- SUBSTR(con.email,1,(COALESCE(NULLIF(LOCATE(',', con.email), 0), 99) - 1)) Email1,
- sa.iban iban
- FROM vn.supplier s
- JOIN vn2008.v_xsubprov xsp ON xsp.proveedor_id = s.id -- Proveedores activos los últimos 3 meses
- LEFT JOIN vn.country co ON co.id = s.countryFk
- LEFT JOIN sage.Naciones sn ON sn.countryFk = co.id
- LEFT JOIN vn.province p ON p.id = s.provinceFk
- LEFT JOIN sage.Provincias sp ON sp.provinceFk = p.id
- LEFT JOIN vn2008.Relaciones r ON r.Id_Proveedor = s.id
- LEFT JOIN vn.supplierAccount sa ON sa.supplierFk = s.id
- LEFT JOIN vn2008.Contactos con ON con.Id_Contacto = r.Id_Contacto
- JOIN vn.company c ON c.id = xsp.empresa_id
- WHERE
- c.code = 'VNL' AND
- s.isActive AND
- s.nif <> ''
-GROUP BY xsp.proveedor_id , xsp.empresa_id;
-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 DROP PROCEDURE IF EXISTS `clientSupplier_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -20931,8 +18482,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `clientSupplier_add`(vCompanyFk INT)
BEGIN
@@ -21038,11 +18587,11 @@ BEGIN
IF(co.country IN ('España', 'España exento'), 1,IF(co.isUeeMember = 1, 2, 4)),
IFNULL(s.taxTypeSageFk, 0),
n.Nacion,
- IFNULL(con.Telefono, ''),
- IFNULL(con.Movil, ''),
+ IFNULL(sc.phone, ''),
+ IFNULL(sc.mobile, ''),
IFNULL(s.transactionTypeSageFk, 0),
IFNULL(s.withholdingSageFk, '0'),
- IFNULL(SUBSTR(con.email, 1, (COALESCE(NULLIF(LOCATE(',', con.email), 0), 99) - 1)), ''),
+ IFNULL(SUBSTR(sc.email, 1, (COALESCE(NULLIF(LOCATE(',', sc.email), 0), 99) - 1)), ''),
IFNULL(iban, '')
FROM vn.supplier s
JOIN providerLastThreeMonths pl ON pl.supplierFk = s.id
@@ -21050,9 +18599,8 @@ BEGIN
LEFT JOIN Naciones n ON n.countryFk = co.id
LEFT JOIN vn.province p ON p.id = s.provinceFk
LEFT JOIN Provincias pr ON pr.provinceFk = p.id
- LEFT JOIN vn2008.Relaciones r ON r.Id_Proveedor = s.id
+ LEFT JOIN vn.supplierContact sc ON sc.supplierFk = s.id
LEFT JOIN vn.supplierAccount sa ON sa.supplierFk = s.id
- LEFT JOIN vn2008.Contactos con ON con.Id_Contacto = r.Id_Contacto
JOIN vn.company c ON c.id = pl.companyFk
WHERE c.id = vCompanyFk AND
s.isActive AND
@@ -21064,146 +18612,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `clientSupplier_add__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `clientSupplier_add__`(vCompanyFk INT)
-BEGIN
-/**
- * Prepara los datos de clientes y proveedores para exportarlos a Sage
- * @vCompanyFk Empresa dela que se quiere trasladar datos
- */
- DECLARE vCountryCeutaMelillaFk INT;
- DECLARE vCountryCanariasCode, vCountryCeutaMelillaCode VARCHAR(2);
-
- SELECT SiglaNacion INTO vCountryCanariasCode
- FROM Naciones
- WHERE Nacion ='ISLAS CANARIAS';
-
- SELECT CodigoNacion, SiglaNacion INTO vCountryCeutaMelillaFk, vCountryCeutaMelillaCode
- FROM Naciones
- WHERE Nacion ='CEUTA Y MELILLA';
-
- TRUNCATE TABLE clientesProveedores;
-
- INSERT INTO clientesProveedores
- (CodigoEmpresa,
- ClienteOProveedor,
- CodigoClienteProveedor,
- RazonSocial,
- Nombre,
- Domicilio,
- CodigoCuenta,
- CifDni,
- CifEuropeo,
- CodigoPostal,
- Municipio,
- CodigoProvincia,
- Provincia,
- CodigoNacion,
- SiglaNacion,
- PersonaFisicaJuridica,
- TipoDocumentoPersona,
- CodigoIva,
- Nacion,
- Telefono,
- Telefono2,
- CodigoTransaccion,
- CodigoRetencion,
- Email1,
- iban)
- SELECT
- IF (@@hostname = 'db', co.companyCode, co.companyCodeTest),
- 'C',
- c.id,
- c.socialName,
- c.name,
- IFNULL(c.street, ''),
- c.accountingAccount,
- TRIM(IF(cu.code = LEFT(c.fi, 2), MID(c.fi, 3, LENGTH(c.fi)-1), c.fi)),
- IF(n.NacionCEE,TRIM(CONCAT(cu.code, IF(cu.code = LEFT(c.fi,2), MID(c.fi,3, LENGTH(c.fi)-1), c.fi))) , ''),
- IFNULL(c.postcode, ''),
- IFNULL(c.city, ''),
- IFNULL(pr.CodigoProvincia, ''),
- IFNULL(p.name, ''),
- IF(n.SiglaNacion = vCountryCanariasCode COLLATE utf8_general_ci, IF(@isCeutaMelilla := IF(pr.Provincia IN ('CEUTA', 'MELILLA'), TRUE, FALSE), vCountryCeutaMelillaFk, IF (@isCanarias, vCountryCanariasCode, n.CodigoNacion)), n.CodigoNacion),
- IF(n.SiglaNacion = vCountryCanariasCode COLLATE utf8_general_ci, IF(@isCeutaMelilla, vCountryCeutaMelillaCode, IF (@isCanarias, vCountryCanariasCode, n.SiglaNacion)), n.SiglaNacion),
- IF((c.fi REGEXP '^([[:blank:]]|[[:digit:]])'), 'J','F'),
- IF(cu.code IN('ES','EX'),
- 1,
- IF((cu.isUeeMember AND c.isVies), 2, 4)),
- IFNULL(c.taxTypeSageFk,0),
- IF(n.SiglaNacion = vCountryCanariasCode COLLATE utf8_general_ci,
- IF(@isCeutaMelilla, 'CEUTA Y MELILLA', IF (@isCanarias, 'ISLAS CANARIAS', n.Nacion)),
- n.Nacion),
- IFNULL(c.phone, ''),
- IFNULL(c.mobile, ''),
- IFNULL(c.transactionTypeSageFk, 0),
- '0',
- IFNULL(SUBSTR(c.email, 1, LOCATE(',', CONCAT(c.email, ','))-1), ''),
- IFNULL(c.iban, '')
- FROM vn.`client` c
- JOIN clientLastTwoMonths clm ON clm.clientFk = c.id
- JOIN vn.company co ON co.id = clm.companyFk
- LEFT JOIN vn.country cu ON cu.id = c.countryFk
- LEFT JOIN Naciones n ON n.countryFk = cu.id
- LEFT JOIN vn.province p ON p.id = c.provinceFk
- LEFT JOIN Provincias pr ON pr.provinceFk = p.id
- WHERE c.isRelevant
- AND co.id = vCompanyFk
- UNION ALL
- SELECT IF (@@hostname = 'db', c.companyCode, companyCodeTest),
- 'P',
- s.id,
- s.name,
- s.name,
- IFNULL(s.street, ''),
- s.account,
- TRIM(IF(co.code = LEFT(s.nif, 2), MID(s.nif, 3, LENGTH(s.nif) - 1), s.nif)),
- IF(n.NacionCEE, TRIM(CONCAT(co.code, IF(co.code = LEFT(s.nif, 2), MID(s.nif, 3, LENGTH(s.nif) - 1), s.nif))), ''),
- IFNULL(s.postCode,''),
- IFNULL(s.city, ''),
- IFNULL(pr.CodigoProvincia, ''),
- IFNULL(p.name, ''),
- n.CodigoNacion,
- n.SiglaNacion COLLATE utf8_general_ci,
- IF((s.nif REGEXP '^([[:blank:]]|[[:digit:]])'),'J','F'),
- IF(co.country IN ('España', 'España exento'), 1,IF(co.isUeeMember = 1, 2, 4)),
- IFNULL(s.taxTypeSageFk, 0),
- n.Nacion,
- IFNULL(con.Telefono, ''),
- IFNULL(con.Movil, ''),
- IFNULL(s.transactionTypeSageFk, 0),
- IFNULL(s.withholdingSageFk, '0'),
- IFNULL(SUBSTR(con.email, 1, (COALESCE(NULLIF(LOCATE(',', con.email), 0), 99) - 1)), ''),
- IFNULL(iban, '')
- FROM vn.supplier s
- JOIN providerLastThreeMonths pl ON pl.supplierFk = s.id
- LEFT JOIN vn.country co ON co.id = s.countryFk
- LEFT JOIN Naciones n ON n.countryFk = co.id
- LEFT JOIN vn.province p ON p.id = s.provinceFk
- LEFT JOIN Provincias pr ON pr.provinceFk = p.id
- LEFT JOIN vn2008.Relaciones r ON r.Id_Proveedor = s.id
- LEFT JOIN vn.supplierAccount sa ON sa.supplierFk = s.id
- LEFT JOIN vn2008.Contactos con ON con.Id_Contacto = r.Id_Contacto
- JOIN vn.company c ON c.id = pl.companyFk
- WHERE c.id = vCompanyFk AND
- s.isActive AND
- s.nif <> ''
- GROUP BY pl.supplierFk, pl.companyFk;
-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 DROP PROCEDURE IF EXISTS `invoiceIn_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -21211,8 +18621,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceIn_add`(vInvoiceInFk INT, vXDiarioFk INT)
BEGIN
@@ -21382,6 +18790,7 @@ BEGIN
JOIN vn.invoiceInTax iit ON iit.invoiceInFk = ii.id
JOIN vn.expence e ON e.id = iit.expenceFk
JOIN TiposRetencion t ON t.CodigoRetencion = ii.withholdingSageFk
+ LEFT JOIN tmp.invoiceDua id ON id.id = mci.id
JOIN (SELECT SUM(x2.BASEEURO) taxableBase, SUM(x2.EURODEBE) taxBase
FROM vn.XDiario x1
JOIN vn.XDiario x2 ON x1.ASIEN = x2.ASIEN
@@ -21395,7 +18804,8 @@ BEGIN
mci.PorRetencion = t.PorcentajeRetencion,
mci.ImporteRetencion = iit.taxableBase * - 1
WHERE mci.id = vXDiarioFk
- AND e.name = 'Retenciones';
+ AND e.name = 'Retenciones'
+ AND id.id IS NULL;
END ;;
DELIMITER ;
@@ -21403,6 +18813,8 @@ DELIMITER ;
/*!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 `invoiceIn_manager` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -21410,8 +18822,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceIn_manager`(vYear INT, vCompanyFk INT)
BEGIN
@@ -21689,6 +19099,8 @@ DELIMITER ;
/*!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 `invoiceOut_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -21696,8 +19108,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOut_add`(IN vInvoiceOutFk INT, IN vXDiarioFk INT)
BEGIN
@@ -21889,6 +19299,8 @@ DELIMITER ;
/*!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 `invoiceOut_manager` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -21896,8 +19308,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOut_manager`(vYear INT, vCompanyFk INT)
BEGIN
@@ -21956,561 +19366,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `movContaAdd__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `movContaAdd__`()
-BEGIN
- /* Copia en movConta los asientos de XDiario para que luego los importe el proceso automático que hay en SQL Server
- */
- DECLARE vDated DATE;
- SELECT CONCAT(YEAR(CURDATE()), "-01-01") INTO vDated;
-SELECT "2021-01-01" INTO vDated;
- TRUNCATE XDiario_movConta_IVA;
- DELETE FROM movConta WHERE enlazadoSage = FALSE AND Asiento <> 1 ;
- CALL clientesProveedoresAdd;
- CALL planCuentasPgcAdd;
- CALL XDiario_movConta_IVA_InvoiceOutAdd_Manager;
- CALL XDiario_movConta_IVA_InvoiceInAdd_Manager;
- INSERT INTO movConta(
- TipoEntrada, -- VARCHAR(2)
- Ejercicio, -- Año
- CodigoEmpresa, -- ENT(2)
- Asiento, -- LONG(4), nº ASIENTO
- CargoAbono, -- VARCHAR(1) "D" debe ó "H" haber
- CodigoCuenta, -- VARCHAR(15) partida contable
- Contrapartida, -- VARCHAR(15) partida contable
- FechaAsiento, -- FECHA(8)
- Comentario, -- VARCHAR(40)
- ImporteAsiento, -- DOBLE(19)
- NumeroPeriodo, -- ENT(2) "-1" Al informar este valor se calcula automát. A partir de la fecha de asiento
- FechaGrabacion, -- FECHA(8)
- CodigoDivisa, -- VARCHAR(3)
- ImporteCambio, -- DOBLE(19)
- ImporteDivisa, -- DOBLE(19)
- FactorCambio, -- DOBLE(19)
- IdProcesoIME, -- GUID(16)
- TipoCarteraIME, -- ENT(2) "0" para que no genere cartera
- TipoAnaliticaIME, -- ENT(2)
- StatusTraspasadoIME, -- BYTE "0" para dejar como no importado aún
- TipoImportacionIME, -- BYTE "0" Alta "1" Baja
- Metalico347, -- ENT(2)
- /* ESTOS CAMPOS SOLO SE INFORMAN EN EL CASO DE SER FACTURA */
- BaseIva1, -- DOBLE(19)
- PorBaseCorrectora1, -- DOBLE(19)
- PorIva1, -- DOBLE(19)
- CuotaIva1, -- DOBLE(19)
- PorRecargoEquivalencia1,-- DOBLE(19)
- RecargoEquivalencia1, -- DOBLE(19)
- CodigoTransaccion1, -- BYTE "0" Nacional "1" Intracomunitario "2" Extracomunitario
- BaseIva2,
- PorBaseCorrectora2,
- PorIva2,
- CuotaIva2,
- PorRecargoEquivalencia2,
- RecargoEquivalencia2,
- CodigoTransaccion2,
- BaseIva3,
- PorBaseCorrectora3,
- PorIva3,
- CuotaIva3,
- PorRecargoEquivalencia3,
- RecargoEquivalencia3,
- CodigoTransaccion3,
- BaseIva4,
- PorBaseCorrectora4,
- PorIva4,
- CuotaIva4,
- PorRecargoEquivalencia4,
- RecargoEquivalencia4,
- CodigoTransaccion4,
- Año, -- ENT(2)
- Serie, -- VARCHAR(10)
- Factura, -- LONG(4)
- SuFacturaNo, -- VARCHAR(40)
- FechaFactura, -- FECHA(8)
- ImporteFactura, -- DOBLE(19)
- TipoFactura, -- VARCHAR(1) "E" / "R" / "I"
- CodigoCuentaFactura, -- VARCHAR(15) cuenta del cliente/proveedor
- CifDni, -- VARCHAR(13)
- Nombre, -- VARCHAR(35)
- CodigoRetencion, -- ENT(2)
- BaseRetencion, -- DOBLE(19)
- PorRetencion, -- DOBLE(19)
- ImporteRetencion, -- DOBLE(19)
- SiglaNacion, -- VARCHAR(2) "ES" por defecto
- EjercicioFactura, -- ENT(2)
- FechaOperacion, -- FECHA(8)
- Exclusion347, -- ENT(2)
- MantenerAsiento, -- BYTE "-1" mantener "0" Sage asigna nuevo
- ClaveOperacionFactura_, -- VARCHAR(1) P(4721000011,4721000021)-I(4721000015-4720000005-4720000006)-D (Rectificativas)
- TipoRectificativa, -- ENT(2)
- FechaFacturaOriginal, -- FECHA(8)
- BaseImponibleOriginal, -- DOBLE(19)
- CuotaIvaOriginal, -- DOBLE(19)
- ClaseAbonoRectificativas,-- ENT(2)
- RecargoEquivalenciaOriginal, -- DOBLE(19) */
- LibreA1,
- CodigoIva1, -- ENT(6)
- CodigoIva2, -- ENT(6)
- CodigoIva3, -- ENT(6)
- CodigoIva4, -- ENT(6)
- IvaDeducible1, -- Entero 2 ((-1))
- IvaDeducible2, -- Entero 2 ((-1))
- IvaDeducible3, -- Entero 2 ((-1))
- IvaDeducible4, -- Entero 2 ((-1))-- ENT(6)
- Intracomunitaria -- INT(2)
- )
- SELECT 'EN' as TipoEntrada,
- YEAR(x.FECHA) AS Ejercicio,
- IF (@@hostname = 'db', c.companyCode, companyCodeTest) AS CodigoEmpresa, -- ENT(2) c.companyCode AS CodigoEmpresa,
- x.ASIEN AS Asiento, -- LONG(4), nº ASIENTO
- IF(EURODEBE<>0 OR (EURODEBE=0 AND EUROHABER IS NULL),'D','H')AS CargoAbono, -- IF(EURODEBE IS NULL,"H","D") AS CargoAbono, VARCHAR(1) "D" debe ó "H" haber
- x.SUBCTA AS CodigoCuenta, -- VARCHAR(15) partida contable
- x.CONTRA AS Contrapartida, -- VARCHAR(15) partida contable
- x.FECHA AS FechaAsiento, -- FECHA(8)
- SUBSTRING(x.CONCEPTO, 1, 40) AS Comentario, -- VARCHAR(40)
- IF(x.EURODEBE,x.EURODEBE,x.EUROHABER) AS ImporteAsiento, -- DOBLE(19)
- MONTH(x.FECHA) AS NumeroPeriodo, -- ENT(2) "-1" Al informar este valor se calcula automát. A partir de la fecha de asiento
- IF( sub2.FECREGCON IS NULL, sub2.FECHA_EX, sub2.FECREGCON) FechaGrabacion, -- FECHA(8)
- IF(x.CAMBIO,IFNULL(xmi.CodigoDivisa, sub3.code),'') CodigoDivisa, -- VARCHAR(3)
- x.CAMBIO AS ImporteCambio, -- DOBLE(19)
- IFNULL(x.DEBEME,x.HABERME) AS ImporteDivisa, -- DOBLE(19)
- IF(x.CAMBIO,1,0) AS FactorCambio, -- DOBLE(19)
- NULL AS IdProcesoIME, -- GUID(16)
- 0 AS TipoCarteraIME, -- ENT(2) "0" para que no genere cartera
- 0 AS TipoAnaliticaIME, -- ENT(2)
- 0 AS StatusTraspasadoIME, -- BYTE "0" para dejar como no importado aún
- 0 AS TipoImportacionIME, -- BYTE "0" Alta "1" Baja
- x.METAL as Metalico347,
- /* ESTOS CAMPOS SOLO SE INFORMAN EN EL CASO DE SER FACTURA */
- xmi.BaseIva1, -- DOBLE(19)
- xmi.PorBaseCorrectora1, -- DOBLE(19)
- xmi.PorIva1, -- DOBLE(19)
- xmi.CuotaIva1, -- DOBLE(19)
- xmi.PorRecargoEquivalencia1,-- DOBLE(19)
- xmi.RecargoEquivalencia1, -- DOBLE(19)
- xmi.CodigoTransaccion1, -- BYTE "0" Nacional "1" Intracomunitario "2" Extracomunitario
- xmi.BaseIva2,
- xmi.PorBaseCorrectora2,
- xmi.PorIva2,
- xmi.CuotaIva2,
- xmi.PorRecargoEquivalencia2,
- xmi.RecargoEquivalencia2,
- xmi.CodigoTransaccion2,
- xmi.BaseIva3,
- xmi.PorBaseCorrectora3,
- xmi.PorIva3,
- xmi.CuotaIva3,
- xmi.PorRecargoEquivalencia3,
- xmi.RecargoEquivalencia3,
- xmi.CodigoTransaccion3,
- xmi.BaseIva4,
- xmi.PorBaseCorrectora4,
- xmi.PorIva4,
- xmi.CuotaIva4,
- xmi.PorRecargoEquivalencia4,
- xmi.RecargoEquivalencia4,
- xmi.CodigoTransaccion4,
- xmi.Año, -- ENT(2)
- xmi.Serie, -- VARCHAR(10)
- xmi.Factura, -- LONG(4)
- xmi.SuFacturaNo, -- VARCHAR(40)
- xmi.FechaFactura, -- FECHA(8)
- xmi.ImporteFactura, -- DOBLE(19)
- xmi.TipoFactura, -- VARCHAR(1) "E" / "R"
- xmi.CodigoCuentaFactura, -- VARCHAR(15) cuenta del cliente/proveedor
- xmi.CifDni, -- VARCHAR(13)
- xmi.Nombre, -- VARCHAR(35)
- xmi.CodigoRetencion, -- ENT(2)
- xmi.BaseRetencion, -- DOBLE(19)
- xmi.PorRetencion, -- DOBLE(19)
- xmi.ImporteRetencion, -- DOBLE(19)
- xmi.SiglaNacion, -- VARCHAR(2) "ES" por defecto
- xmi.EjercicioFactura, -- ENT(2)
- xmi.FechaOperacion, -- FECHA(8)
- xmi.Exclusion347, -- ENT(2)
- 1, -- xmi.MantenerAsiento BYTE "-1" mantener "0" Sage asigna nuevo
- xmi.ClaveOperacionFactura, -- VARCHAR(1)
- xmi.TipoRectificativa, -- ENT(2)
- xmi.FechaFacturaOriginal, -- FECHA(8)
- xmi.BaseImponibleOriginal, -- DOBLE(19)
- xmi.CuotaIvaOriginal, -- DOBLE(19)
- xmi.ClaseAbonoRectificativas,-- ENT(2)
- xmi.RecargoEquivalenciaOriginal,-- DOBLE(19) */
- xmi.LibreA1,
- xmi.CodigoIva1, -- ENT(6)
- xmi.CodigoIva2, -- ENT(6)
- xmi.CodigoIva3, -- ENT(6)
- xmi.CodigoIva4, -- ENT(6)
- xmi.IvaDeducible1, -- Entero 2 ((-1))
- xmi.IvaDeducible2, -- Entero 2 ((-1))
- xmi.IvaDeducible3, -- Entero 2 ((-1))
- xmi.IvaDeducible4, -- Entero 2 ((-1))-- ENT(6)
- xmi.Intracomunitaria -- TINYINT(1)
- FROM vn2008.XDiario x
- JOIN vn.company c ON c.id = x.empresa_id
- LEFT JOIN XDiario_movConta_IVA xmi ON xmi.id = x.id AND xmi.moveData > 0
- LEFT JOIN (SELECT ASIEN, FECREGCON, FECHA_EX
- FROM (SELECT DISTINCT ASIEN, FECREGCON, FECHA_EX
- FROM vn2008.XDiario
- ORDER BY ASIEN, FECREGCON DESC, FECHA_EX DESC
- ) sub GROUP BY ASIEN
- )sub2 ON sub2.ASIEN = x.ASIEN
- LEFT JOIN ( SELECT DISTINCT(account),cu.code
- FROM vn.bank b
- JOIN vn.currency cu ON cu.id = b.currencyFk
- WHERE cu.code <> "EUR" -- no se informa cuando la divisa en EUR
- )sub3 ON sub3.account = x.SUBCTA
- WHERE x.enlazadoSage = 0 AND
- c.companyCode AND
- x.FECHA >= vDated;
-
--- Prepara Metálicos
- UPDATE sage.movConta m
- JOIN (SELECT Asiento, SUBSTR(c.socialName,1,35) Nombre, c.fi, n.SiglaNacion
- FROM sage.movConta m
- JOIN vn.client c ON c.id = IF(m.CargoAbono = "H", m.CodigoCuenta-4300000000, m.Contrapartida-4300000000 )
- LEFT JOIN Naciones n ON n.countryFk = c.countryFk
- WHERE m.Metalico347 = TRUE AND
- m.enlazadoSage = FALSE
- ) AS sub ON m.Asiento = sub.Asiento
- SET m.Metalico347 = TRUE,
- m.TipoFactura = "I",
- m.CifDni = sub.fi ,
- m.Nombre = sub.Nombre,
- m.SiglaNacion = sub.SiglaNacion
- WHERE m.enlazadoSage = FALSE;
-
- UPDATE sage.movConta m
- SET Metalico347 = FALSE,
- m.TipoFactura = "",
- m.Metalico347 = FALSE
- WHERE CargoAbono = "D" AND
- m.enlazadoSage = FALSE;
-
--- Elimina cuentas de cliente/proveedor que no se utilizarán en la importación
- DELETE cp
- FROM clientesProveedores cp
- JOIN (SELECT cp.codigoCuenta
- FROM clientesProveedores cp
- LEFT JOIN movConta mc ON mc.codigoCuenta = cp.codigoCuenta AND mc.enlazadoSage = FALSE
- WHERE mc.codigoCuenta IS NULL
- GROUP BY cp.codigoCuenta
- ) sub ON sub.codigoCuenta = cp.codigoCuenta ;
-
--- Elimina cuentas contables que no se utilizarán en la importación
- DELETE pc
- FROM planCuentasPGC pc
- JOIN ( SELECT pc.codigoCuenta
- FROM planCuentasPGC pc
- LEFT JOIN movConta mc ON mc.codigoCuenta = pc.codigoCuenta AND mc.enlazadoSage = FALSE
- WHERE mc.codigoCuenta IS NULL
- GROUP BY pc.codigoCuenta
- ) sub ON sub.codigoCuenta = pc.codigoCuenta ;
-
--- DUAS
- UPDATE movConta m
- JOIN vn.XDiario x ON x.ASIEN = m.Asiento
- SET m.BaseIva1 = x.BASEEURO ,
- m.PorIva1 = x.IVA,
- m.CuotaIva1 = CAST((x.IVA/100) * x.BASEEURO AS DECIMAL(10,2)) ,
- m.CodigoTransaccion1 = 56 ,
- m.CodigoIva1 = 22,
- m.IvaDeducible1 = TRUE,
- m.FechaFacturaOriginal = x.FECHA_EX,
- m.SuFacturaNo = x.FACTURAEX,
- m.FechaOperacion = x.FECHA_OP,
- m.ImporteFactura = m.ImporteFactura + x.BASEEURO + CAST((x.IVA/100) * x.BASEEURO AS DECIMAL(10,2))
- WHERE m.CodigoCuenta = 4700000999
- AND m.enlazadoSage = FALSE
- AND x.SERIE='D'
- AND x.IVA = 10;
-
- UPDATE movConta m
- JOIN vn.XDiario x ON x.ASIEN = m.Asiento
- SET m.BaseIva2 = x.BASEEURO ,
- m.PorIva2 = x.IVA,
- m.CuotaIva2 = CAST((x.IVA/100) * x.BASEEURO AS DECIMAL(10,2)),
- m.CodigoTransaccion2 = 56 ,
- m.CodigoIva2 = 90,
- m.IvaDeducible2 = TRUE,
- m.ImporteFactura = m.ImporteFactura + x.BASEEURO + CAST((x.IVA/100) * x.BASEEURO AS DECIMAL(10,2))
- WHERE m.CodigoCuenta = 4700000999
- AND m.enlazadoSage = FALSE
- AND x.SERIE='D'
- AND x.IVA = 21;
-
--- Rectificativas
-UPDATE movConta m
- JOIN (SELECT x.ASIEN, x.FECHA_RT, x.SERIE_RT, x.FACTU_RT
- FROM movConta m
- JOIN vn.XDiario x ON x.ASIEN = m.Asiento
- WHERE m.TipoRectificativa>0 AND
- m.enlazadoSage = FALSE AND
- x.FACTU_RT IS NOT NULL
- GROUP BY x.ASIEN
- ) sub ON sub.ASIEN = m.Asiento
- SET m.EjercicioFacturaOriginal = YEAR(sub.FECHA_RT),
- m.SerieFacturaOriginal = sub.SERIE_RT,
- m.NumeroFacturaOriginal = sub.FACTU_RT
- WHERE m.TipoRectificativa > 0 AND
- m.enlazadoSage = FALSE ;
-
--- Exportaciones Andorras y Canarias cambia TT (la cuenta de taxCode es compartida, id:125)
-UPDATE sage.movConta m
- SET CodigoTransaccion1 = 15,
- CodigoTransaccion2 = IF(CodigoTransaccion2 = 0, 0, 15),
- CodigoTransaccion3 = IF(CodigoTransaccion3 = 0, 0, 15),
- CodigoTransaccion4 = IF(CodigoTransaccion4 = 0, 0, 15)
- WHERE enlazadoSage = FALSE AND
- (CodigoTransaccion1 = 14 OR CodigoTransaccion2 = 14 OR CodigoTransaccion3 = 14 OR CodigoTransaccion4 = 14) AND
- SiglaNAcion IN ('XC','XB');
-
--- Divisas
-
- UPDATE sage.movConta mc
- SET CodigoDivisa = 'USD',
- FactorCambio = 1,
- ImporteCambio = ABS( CAST( IF( ImporteDivisa <> 0 AND ImporteCambio=0, ImporteAsiento / ImporteDivisa, ImporteCambio) AS DECIMAL( 10, 2)))
- WHERE (ImporteCambio <> 0 OR ImporteDivisa <> 0 OR FactorCambio <> 0)
- AND enlazadoSage = FALSE ;
-
- UPDATE sage.movConta mc
- SET importeDivisa= importeDivisa * -1
- WHERE enlazadoSage = FALSE
- AND importeDivisa > 0
- AND ImporteAsiento < 0;
-
-
-
-/*-- Actualiza las facturas DUA para excluirlas del 347 y marcarlas como intracomunitarias
-/*UPDATE sage.movConta mc
- SET
- mc.Intracomunitaria = 1,
- mc.Exclusion347 = 1
-WHERE
- mc.CodigoCuenta = '4700000999'; */
-
-
--- MARCAR EN CASO DE SER INTRACOMUNITARIA
-/*
-UPDATE sage.movConta mc
- SET
- mc.Intracomunitaria = 1
-WHERE
- mc.CodigoTransaccion1 IN (20,29);
-*/
-
-
- -- LAS FACTURAS RTECTIFICATIVAS QUE TIENEN CUENTA DE IVA 477.2 SALE CON T.T. 1, TODAS ESTAS FACTURAS DEBEN DE TENER T.T. 15
-
- /*UPDATE sage.movConta mc
- JOIN
- (SELECT
- Asiento
- FROM
- sage.movConta
- WHERE
- CodigoCuenta = 4770000002) sub ON sub.Asiento = mc.Asiento
-SET
- CodigoTransaccion1 = CASE
- WHEN CodigoTransaccion1 = 1 THEN 15
- ELSE CodigoTransaccion1
- END,
- CodigoTransaccion2 = CASE
- WHEN CodigoTransaccion2 = 1 THEN 15
- ELSE CodigoTransaccion2
- END,
- CodigoTransaccion3 = CASE
- WHEN CodigoTransaccion3 = 1 THEN 15
- ELSE CodigoTransaccion3
- END,
- CodigoTransaccion4 = CASE
- WHEN CodigoTransaccion4 = 1 THEN 15
- ELSE CodigoTransaccion4
- END
-WHERE
- serie = 'R';
-
-*/
-
-/*
-Nombre Tipo Longitud Descripción campo / Valor por defecto
-MovPosicion Guid contador 16 Automático, no informar
-Ejercicio Entero 2 -1 -- Al informar este valor se calcula automát. A partir de la fecha de asiento
-CodigoEmpresa Entero 2 Empresa de Sage 200c donde va destinado el asiento
-Asiento Entero Largo 4 Número de asiento
-CargoAbono Texto 1 "D" - Debe / "H" - Haber
-CodigoCuenta Texto 15 Cuenta contable del movimiento
-Contrapartida Texto 15 Es informativo, no es necesario informarlo
-FechaAsiento Fecha 8 Fecha del asiento
-TipoDocumento Texto 6
-DocumentoConta Texto 9
-Comentario Texto 40 Comentario del asiento
-ImporteAsiento Doble 19 Importe del movimiento
-CodigoDiario Entero 2
-CodigoCanal Texto 10 Centro coste analítico (no necesario informar)
-CodigoActividad Texto 1
-FechaVencimiento Fecha 8 Si se tienen que generar efectos, será la fecha de vto. Del efecto. No informar
-NumeroPeriodo Entero 2 -1 -- Al informar este valor se calcula automát. A partir de la fecha de asiento
-CodigoUsuario Entero 2
-FechaGrabacion Fecha 8
-TipoEntrada Texto 2
-CodigoDepartamento Texto 10 Centro coste analítico (no necesario informar)
-CodigoSeccion Texto 10 Centro coste analítico (no necesario informar)
-CodigoDivisa Texto 3
-ImporteCambio Doble 19
-ImporteDivisa Doble 19
-FactorCambio Doble 19
-CodigoProyecto Texto 10 Centro coste analítico (no necesario informar)
-LibreN1 Entero Largo 4 Campo libre numérico
-LibreN2 Entero Largo 4 Campo libre numérico
-LibreA1 Texto 15 Campo libre alfanumérico
-LibreA2 Texto 15 Campo libre alfanumérico
-IdDelegacion Texto 10 Centro coste analítico (no necesario informar)
-OrdenMovimientos Contador 4 Número de orden de cada movimiento dentro de un mismo asiento, autonumerar para cada asiento
-MovCartera Guid 16
-IdProcesoIME Guid 16 guid igual para todos los registros que correspondan a una misma importación.
-TipoCarteraIME Entero 2 0 - Para que no genere cartera
-TipoAnaliticaIME Entero 2
-StatusTraspasadoIME Byte 1 0 - Para que quede marcado el movimiento como no importado todavía.
-TipoImportacionIME Byte 1 0 - Alta
-BaseIva1 Doble 19 Base para el IVA 1 (idéntico para cada posible IVA hasta el 4) (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor)
-PorBaseCorrectora1 Doble 19 Base correctora (en caso de que la haya) para el IVA 1 (idéntico para cada posible IVA hasta el 4) (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor)
-PorIva1 Doble 19 Porcentaje IVA 1 (idéntico para cada posible IVA hasta el 4) (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor)
-CuotaIva1 Doble 19 Cuota IVA 1 (idéntico para cada posible IVA hasta el 4) (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor)
-PorRecargoEquivalencia1 Doble 19 Si hay recargo - Porcentaje de recargo para el IVA 1 (idéntico para cada posible IVA hasta el 4) (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor)
-RecargoEquivalencia1 Doble 19 Si hay recargo - Importe de Recargo para el IVA 1 (idéntico para cada posible IVA hasta el 4) (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor)
-CodigoTransaccion1 Byte 1 Ver con dpto. de contabilidad - Depende de la naturaleza del asiento (Nacional, Intracoumunitario, etc…) (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor)
-BaseIva2 Doble 19 0
-PorBaseCorrectora2 Doble 19 0
-PorIva2 Doble 19 0
-CuotaIva2 Doble 19 0
-PorRecargoEquivalencia2 Doble 19 0
-RecargoEquivalencia2 Doble 19 0
-CodigoTransaccion2 Byte 1 0
-BaseIva3 Doble 19 0
-PorBaseCorrectora3 Doble 19 0
-PorIva3 Doble 19 0
-CuotaIva3 Doble 19 0
-PorRecargoEquivalencia3 Doble 19 0
-RecargoEquivalencia3 Doble 19 0
-CodigoTransaccion3 Byte 1 0
-BaseIva4 Doble 19 0
-PorBaseCorrectora4 Doble 19 0
-PorIva4 Doble 19 0
-CuotaIva4 Doble 19 0
-PorRecargoEquivalencia4 Doble 19 0
-RecargoEquivalencia4 Doble 19 0
-CodigoTransaccion4 Byte 1 0
-Año Entero 2 Ejercicio de la factura en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor)
-Serie Texto 10 Serie de la factura en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor)
-Factura Entero Largo 4 Número de la factura en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor)
-SuFacturaNo Texto 40 Número de la factura del proveedor para factura recibidas, en el caso de que el asiento sea de una factura. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor)
-FechaFactura Fecha 8 Fecha de la factura en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor)
-ImporteFactura Doble 19 Importe de la factura en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor)
-TipoFactura Texto 1 "E" - Factura emitida / "R" - Factura Recibida - en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor)
-CodigoCuentaFactura Texto 15 Cuenta contable del cliente / proveedor en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor)
-CifDni Texto 13 CIF del cliente / proveedor en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor)
-Nombre Texto 35 Nombre del cliente / proveedor en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor)
-CodigoRetencion Entero 2 Código de retención de la factura en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor)
-BaseRetencion Doble 19 Base de retención de la factura en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor)
-PorRetencion Doble 19 Porcentaje de retención de la factura en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor)
-ImporteRetencion Doble 19 Importe de retención de la factura en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor)
-AbonoIva Entero 2 0
-CodigoActividadF Texto 1 ('')
-Intracomunitaria Entero 2 0
-CodigoTerritorio Entero 2 0
-SiglaNacion Texto 2 Sigla de la nación de la factura en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor)
-RetencionInformativa Entero 2 0
-EjercicioFacturaOriginal Entero 2 0
-SerieFacturaOriginal Texto 10 ('')
-NumeroFacturaOriginal Entero Largo 4 0
-EjercicioFactura Entero 2 Ejercicio de la factura en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor)
-CobroPagoRetencion Texto 1 ('')
-FechaOperacion Fecha 8 Normalmente Fecha Factura en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor)
-Exclusion347 Entero 2 0
-MovIdentificadorIME Guid contador 16 (newid())
-Previsiones Texto 1 ('')
-MantenerAsiento Byte 1 -1 si se quiere mantener el número de asiento que se informa en la importación o "0" si se quiere que se asigne automáticamente el asiento en Sage 200c
-OrdenMovIME Entero 2 0
-Metalico347 Entero 2 0
-ClaveOperacionFactura_ Texto 1 Ver con dpto. de contabilidad - Depende de la naturaleza del asiento (Nacional, Intracoumunitario, etc…) (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor)
-SerieAgrupacion_ Texto 10 ('')
-NumeroFacturaInicial_ Entero Largo 4 0
-NumeroFacturaFinal_ Entero Largo 4 0
-IdAsientoExterno Texto 50 ('')
-IdDiarioExterno Texto 10 ('')
-IdFacturaExterno Texto 50 ('')
-IdMovimiento Texto 40 ('')
-IdCuadre Entero 2 ((0))
-FechaCuadre Fecha 8 (getdate())
-TipoCuadre Texto 4 ('')
-AgrupacionCuadre Entero Largo 4 ((0))
-StatusSaldo Entero 2 ((0))
-StatusConciliacion Entero 2 ((0))
-CodigoConciliacion Entero Largo 4 ((0))
-FechaConciliacion Fecha 8
-TipoConciliacion Entero 2 ((0))
-IndicadorContaBanco Texto 1 ('')
-Descripcion3 Texto 40 ('')
-Descripcion4 Texto 40 ('')
-Descripcion5 Texto 40 ('')
-Descripcion6 Texto 40 ('')
-Descripcion7 Texto 40 ('')
-Descripcion8 Texto 50 ('')
-Descripcion9 Texto 50 ('')
-Descripcion2 Texto 250 ('')
-Descripcion1 Texto 250 ('')
-Punteo1 Entero 2 ((0))
-Punteo9 Entero 2 ((0))
-Punteo8 Entero 2 ((0))
-Punteo7 Entero 2 ((0))
-Punteo6 Entero 2 ((0))
-Punteo5 Entero 2 ((0))
-Punteo4 Entero 2 ((0))
-Punteo3 Entero 2 ((0))
-Punteo2 Entero 2 ((0))
-CodigoIva1 Entero 2 ((0))
-CodigoIva2 Entero 2 ((0))
-CodigoIva3 Entero 2 ((0))
-CodigoIva4 Entero 2 ((0))
-CriterioIva Byte 1 ((0))
-FechaMaxVencimiento Fecha 8
-TipoCriterioCaja Byte 1 ((0))
-MovFacturaOrigenIME Texto 50 ('')
-IdFacturaExternoFinal Texto 50 ('')
-IdFacturaExternoInicial Texto 50 ('')
-IdFacturaExternoOriginal Texto 50 ('')
-NumFacturasExternoAgrupacion Entero Largo 4 ((0))
-CodigoMedioCobro Texto 1 ('')
-MedioCobro Texto 31 ('')
-IvaDeducible1 Entero 2 ((-1))
-IvaDeducible2 Entero 2 ((-1))
-IvaDeducible3 Entero 2 ((-1))
-IvaDeducible4 Entero 2 ((-1))
-TipoRectificativa Entero 2 ((0))
-FechaFacturaOriginal Fecha 8
-BaseImponibleOriginal Doble 19 ((0))
-CuotaIvaOriginal Doble 19 ((0))
-ClaseAbonoRectificativas Entero 2 ((0))
-RecargoEquivalenciaOriginal Doble 19 ((0))
-ObjetoFactura Texto 500 ('')
-*/
-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 DROP PROCEDURE IF EXISTS `pgc_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -22518,8 +19375,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `pgc_add`(vCompanyFk INT)
BEGIN
@@ -22565,793 +19420,6 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `planCuentasPgcAdd__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `planCuentasPgcAdd__`()
-BEGIN
-
-TRUNCATE TABLE planCuentasPGC;
-
-REPLACE INTO planCuentasPGC(
- CodigoEmpresa,
- CodigoCuenta,
- Cuenta,
- ClienteOProveedor
- )
- SELECT codigoEmpresa, CodigoCuenta, Cuenta, ClienteOProveedor
- FROM
- (
- SELECT
- IF (@@hostname = 'db', c.companyCode, companyCodeTest) AS codigoEmpresa,
- e.id AS CodigoCuenta,
- UCASE(e.name) AS Cuenta,
- '' AS ClienteOProveedor
- FROM
- (vn.expence e
- JOIN vn.company c)
- WHERE
- c.companyCode
- GROUP BY e.id
-
- UNION
- SELECT
- IF (@@hostname = 'db', c.companyCode, companyCodeTest) AS codigoEmpresa,
- b.account AS CodigoCuenta,
- UCASE(b.bank) AS Cuenta,
- '' AS ClienteOProveedor
- FROM
- (vn.bank b
- JOIN vn.company c)
- WHERE (c.companyCode AND b.isActive)
- AND b.account
- GROUP BY b.account
- UNION
- SELECT
- codigoEmpresa,
- CodigoCuenta,
- Nombre AS Cuenta,
- ClienteOProveedor
- FROM clientesProveedores
- GROUP BY CodigoCuenta
- ) pgc
- GROUP BY CodigoCuenta;
-
-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 DROP PROCEDURE IF EXISTS `XDiario_movConta_IVA_InvoiceInAdd_Manager__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `XDiario_movConta_IVA_InvoiceInAdd_Manager__`()
-BEGIN
- DECLARE done BOOL DEFAULT FALSE;
- DECLARE vInvoiceFk INT;
- DECLARE vXDiarioFk INT;
- DECLARE vDated DATE;
- DECLARE rs CURSOR FOR
- SELECT IFNULL(x.CLAVE,x.FACTURA) invoiceInFk, x.id XDiarioFk
- FROM vn2008.XDiario x
- JOIN(SELECT DISTINCT (x.ASIEN)
- FROM vn2008.XDiario x
- LEFT JOIN vn.invoiceIn ii ON x.CLAVE = ii.id
- LEFT JOIN vn.invoiceInTax it ON it.invoiceInFk = ii.id
- WHERE(it.taxTypeSageFk IS NOT NULL OR x.SERIE='D') AND
- x.enlazadoSage = FALSE AND
- x.FECHA >= vDated
- ) sub ON sub.ASIEN =x.ASIEN -- Elimina las Facturas con IVA 0 (-) no se trasladan a sage
- WHERE x.enlazadoSage = FALSE AND
- x.FECHA >= vDated AND
- x.CLAVE IS NOT NULL ;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
-
- SELECT CONCAT(YEAR(CURDATE()), "-01-01") INTO vDated;
- SELECT "2021-01-01" INTO vDated;
- DROP TEMPORARY TABLE IF EXISTS tmp.invoiceDua;
- CREATE TEMPORARY TABLE tmp.invoiceDua
- SELECT id
- FROM vn2008.XDiario x
- WHERE ASIEN IN (SELECT ASIEN
- FROM vn2008.XDiario x
- WHERE x.enlazadoSage = FALSE AND
- x.SUBCTA = '4700000999' AND
- x.FECHA >= vDated
- ) AND
- NOT CONTRA <=> "4330002067";
-
- DROP TEMPORARY TABLE IF EXISTS tmp.invoiceInList;
- CREATE TEMPORARY TABLE tmp.invoiceInList
- SELECT i.id id,
- i.supplierRef supplierRef,
- i.serial serial,
- i.supplierFk supplierFk,
- i.issued issued,
- IF(expenceFkDeductible, FALSE, i.isVatDeductible) isVatDeductible,
- i.serialNumber serialNumber,
- IF(c.code = "EUR", '',c.code) currencyFk
- FROM vn.invoiceIn i
- JOIN vn.currency c ON c.id = i.currencyFk
- WHERE i.bookEntried >= vDated
- UNION ALL
- SELECT d.id ,
- d.code ,
- 'D' ,
- d.companyFk ,
- d.issued ,
- FALSE,
- d.id,
- '' -- EUROS
- FROM vn.dua d
- WHERE d.issued IS NOT NULL AND
- code IS NOT NULL;
-
- OPEN rs;
- FETCH rs INTO vInvoiceFk, vXDiarioFk;
- WHILE NOT done DO
- CALL XDiario_movConta_IVA_InvoiceInAdd(vInvoiceFk, vXDiarioFk);
- FETCH rs INTO vInvoiceFk, vXDiarioFk;
- END WHILE;
- CLOSE rs;
-
- DROP TEMPORARY TABLE tmp.invoiceDua;
- DROP TEMPORARY TABLE tmp.invoiceInList;
-
- -- ASIENTOS CON IVA SOPORTADO 472. y 477. hay que informar 2 líneas la info de facturas una como tipo de factura emitida y otra como recibida
- DROP TEMPORARY TABLE IF EXISTS tmp.XDiario_movConta_IVA;
- CREATE TEMPORARY TABLE tmp.XDiario_movConta_IVA
- SELECT
- sub3.id,
- mc.CodigoDivisa,
- mc.BaseIva1,
- mc.PorBaseCorrectora1,
- mc.PorIva1,
- mc.CuotaIva1,
- mc.PorRecargoEquivalencia1,
- mc.RecargoEquivalencia1,
- mc.CodigoTransaccion1,
- mc.CodigoIva1,
- mc.BaseIva2,
- mc.PorBaseCorrectora2,
- mc.PorIva2,
- mc.CuotaIva2,
- mc.PorRecargoEquivalencia2,
- mc.RecargoEquivalencia2,
- mc.CodigoTransaccion2,
- mc.CodigoIva2,
- mc.BaseIva3,
- mc.PorBaseCorrectora3,
- mc.PorIva3,
- mc.CuotaIva3,
- mc.PorRecargoEquivalencia3,
- mc.RecargoEquivalencia3,
- mc.CodigoTransaccion3,
- mc.CodigoIva3,
- mc.BaseIva4,
- mc.PorBaseCorrectora4,
- mc.PorIva4,
- mc.CuotaIva4,
- mc.PorRecargoEquivalencia4,
- mc.RecargoEquivalencia4,
- mc.CodigoTransaccion4,
- mc.CodigoIva4,
- mc.Año,
- mc.Serie,
- mc.Factura,
- mc.SuFacturaNo,
- mc.FechaFactura,
- mc.ImporteFactura,
- 'E',
- mc.CodigoCuentaFactura,
- mc.CifDni,
- mc.Nombre,
- mc.CodigoRetencion,
- mc.BaseRetencion,
- mc.PorRetencion,
- mc.ImporteRetencion,
- mc.SiglaNacion,
- mc.EjercicioFactura,
- x.FECHA,
- mc.Exclusion347,
- mc.MantenerAsiento,
- mc.Metalico347,
- mc.ClaveOperacionFactura,
- mc.TipoRectificativa,
- mc.FechaFacturaOriginal,
- mc.CuotaIvaOriginal,
- mc.BaseImponibleOriginal,
- mc.ClaseAbonoRectificativas,
- mc.RecargoEquivalenciaOriginal,
- mc.LibreA1,
- mc.IvaDeducible1,
- mc.IvaDeducible2,
- mc.IvaDeducible3,
- mc.IvaDeducible4,
- mc.FechaGrabacion,
- mc.Intracomunitaria,
- mc.moveData
- FROM sage.XDiario_movConta_IVA mc
- JOIN vn.XDiario x ON x.id = mc.id
- JOIN (SELECT x.ASIEN, x.id
- FROM vn.XDiario x
- JOIN(SELECT DISTINCT(x.ASIEN) ASIEN
- FROM (SELECT DISTINCT(ASIEN)
- FROM vn.XDiario x
- WHERE SUBCTA LIKE '472%' AND
- x.enlazadoSage = FALSE AND
- x.FECHA >= vDated
- ) sub JOIN vn.XDiario x ON x.ASIEN = sub.ASIEN
- WHERE x.SUBCTA LIKE '477%'
- )sub2 ON sub2.ASIEN = x.ASIEN
- WHERE x.CONTRA IS NOT NULL AND x.SUBCTA LIKE '477%'
- GROUP BY x.ASIEN
- )sub3 ON sub3.ASIEN = x.ASIEN;
-
- INSERT INTO sage.XDiario_movConta_IVA
- (`id`,
- `CodigoDivisa`,
- `BaseIva1`,
- `PorBaseCorrectora1`,
- `PorIva1`,
- `CuotaIva1`,
- `PorRecargoEquivalencia1`,
- `RecargoEquivalencia1`,
- `CodigoTransaccion1`,
- `CodigoIva1`,
- `BaseIva2`,
- `PorBaseCorrectora2`,
- `PorIva2`,
- `CuotaIva2`,
- `PorRecargoEquivalencia2`,
- `RecargoEquivalencia2`,
- `CodigoTransaccion2`,
- `CodigoIva2`,
- `BaseIva3`,
- `PorBaseCorrectora3`,
- `PorIva3`,
- `CuotaIva3`,
- `PorRecargoEquivalencia3`,
- `RecargoEquivalencia3`,
- `CodigoTransaccion3`,
- `CodigoIva3`,
- `BaseIva4`,
- `PorBaseCorrectora4`,
- `PorIva4`,
- `CuotaIva4`,
- `PorRecargoEquivalencia4`,
- `RecargoEquivalencia4`,
- `CodigoTransaccion4`,
- `CodigoIva4`,
- `Año`,
- `Serie`,
- `Factura`,
- `SuFacturaNo`,
- `FechaFactura`,
- `ImporteFactura`,
- `TipoFactura`,
- `CodigoCuentaFactura`,
- `CifDni`,
- `Nombre`,
- `CodigoRetencion`,
- `BaseRetencion`,
- `PorRetencion`,
- `ImporteRetencion`,
- `SiglaNacion`,
- `EjercicioFactura`,
- `FechaOperacion`,
- `Exclusion347`,
- `MantenerAsiento`,
- `Metalico347`,
- `ClaveOperacionFactura`,
- `TipoRectificativa`,
- `FechaFacturaOriginal`,
- `CuotaIvaOriginal`,
- `BaseImponibleOriginal`,
- `ClaseAbonoRectificativas`,
- `RecargoEquivalenciaOriginal`,
- `LibreA1`,
- `IvaDeducible1`,
- `IvaDeducible2`,
- `IvaDeducible3`,
- `IvaDeducible4`,
- `FechaGrabacion`,
- `Intracomunitaria`,
- `moveData`)
- SELECT *
- FROM tmp.XDiario_movConta_IVA;
- DROP TEMPORARY TABLE tmp.XDiario_movConta_IVA;
-
-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 DROP PROCEDURE IF EXISTS `XDiario_movConta_IVA_InvoiceInAdd__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `XDiario_movConta_IVA_InvoiceInAdd__`(IN vInvoiceInFk INT, IN vXDiarioId INT)
-BEGIN
-
- DECLARE vDone BOOL DEFAULT FALSE;
- DECLARE vBase DOUBLE;
- DECLARE vVat DOUBLE;
- DECLARE vRate DOUBLE;
- DECLARE vTransactionCode INT;
- DECLARE vCounter INT DEFAULT 0;
- DECLARE vTransactionCodeOld INT;
- DECLARE vTaxCode INT;
- DECLARE vTaxCodeOld INT;
- DECLARE vOperationCode VARCHAR(1);
- DECLARE vIsIntracommunity BOOL DEFAULT FALSE;
- DECLARE vDuaExcluded INT;
-
- DECLARE rs CURSOR FOR -- IVA
- SELECT it.taxableBase BASEEURO,
- CAST((( it.taxableBase / 100) * t.PorcentajeIva) AS DECIMAL (10,2)) vat,
- t.PorcentajeIva rate,
- it.transactionTypeSageFk transactionCode,
- it.taxTypeSageFk taxCode,
- t.isIntracommunity,
- tt.ClaveOperacionDefecto operationCode,
- id.id
- FROM vn.invoiceIn i
- JOIN vn.invoiceInTax it ON it.InvoiceInFk = i.id
- JOIN TiposIva t ON t.CodigoIva = it.taxTypeSageFk
- JOIN TiposTransacciones tt ON tt.CodigoTransaccion = it.transactionTypeSageFk
- LEFT JOIN tmp.invoiceDua id ON id.id = vXDiarioId
- WHERE i.id = vInvoiceInFk
- AND i.id> 70000; -- los DUAS no son vInvoiceInFk, pero se pasan en el mismo parametro comparten id en tablas distintas de InvoiceIN (100000) dua(20000)
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
-
- DELETE FROM XDiario_movConta_IVA
- WHERE id = vXDiarioId;
-
- INSERT INTO XDiario_movConta_IVA(id, LibreA1)
- VALUES (vXDiarioId, vInvoiceInFk);
-
- OPEN rs;
- FETCH rs INTO vBase,
- vVat,
- vRate,
- vTransactionCode,
- vTaxCode,
- vIsIntracommunity,
- vOperationCode,
- vDuaExcluded;
-
- SET vTransactionCodeOld=vTransactionCode;
- SET vTaxCodeOld=vTaxCode;
-
- WHILE NOT vDone DO
- IF vOperationCode IS NOT NULL THEN
- UPDATE XDiario_movConta_IVA
- SET ClaveOperacionFactura = vOperationCode
- WHERE id = vXDiarioId;
- END IF;
-
- IF vTransactionCode IS NULL THEN
- SET vTransactionCode = vTransactionCodeOld;
- END IF;
-
- IF vTaxCodeOld IS NULL THEN
- SET vTaxCode = vTaxCodeOld;
- END IF;
-
- SET vCounter = vCounter + 1;
- CASE vCounter
- WHEN 1 THEN
- UPDATE XDiario_movConta_IVA
- SET BaseIva1 = vBase,
- PorIva1 = vRate,
- CuotaIva1 = vVat,
- CodigoTransaccion1 = vTransactionCode,
- CodigoIva1 = vTaxCode
- WHERE id = vXDiarioId;
- WHEN 2 THEN
- UPDATE XDiario_movConta_IVA
- SET BaseIva2 = vBase,
- PorIva2 = vRate,
- CuotaIva2 = vVat,
- CodigoTransaccion2 = vTransactionCode,
- CodigoIva2 = vTaxCode
- WHERE id = vXDiarioId;
- WHEN 3 THEN
- UPDATE XDiario_movConta_IVA
- SET BaseIva3 = vBase,
- PorIva3 = vRate,
- CuotaIva3 = vVat,
- CodigoTransaccion3 = vTransactionCode,
- CodigoIva3 = vTaxCode
- WHERE id = vXDiarioId;
- WHEN 4 THEN
- UPDATE XDiario_movConta_IVA
- SET BaseIva4 = vBase,
- PorIva4 = vRate,
- CuotaIva4 = vVat,
- CodigoTransaccion4 = vTransactionCode,
- CodigoIva4 = vTaxCode
- WHERE id = vXDiarioId;
- ELSE
- SELECT vXDiarioId INTO vXDiarioId;
- END CASE;
-
- IF vIsIntracommunity THEN
- UPDATE XDiario_movConta_IVA
- SET Intracomunitaria = TRUE
- WHERE id = vXDiarioId;
- END IF;
-
- SET vTransactionCodeOld=vTransactionCode;
- SET vTaxCodeOld=vTaxCode;
-
- FETCH rs INTO vBase,
- vVat,
- vRate,
- vTransactionCode,
- vTaxCode,
- vIsIntracommunity,
- vOperationCode,
- vDuaExcluded;
- END WHILE;
- CLOSE rs;
-
- UPDATE XDiario_movConta_IVA xmi
- JOIN tmp.invoiceInList ii ON ii.id = vInvoiceInFk
- JOIN vn2008.XDiario x ON x.id = xmi.id
- LEFT JOIN tmp.invoiceDua id ON id.id = xmi.id
- JOIN vn.supplier s ON s.id = ii.supplierFk
- JOIN Naciones n ON n.countryFk = s.countryFk
- SET xmi.CodigoDivisa = ii.currencyFk,
- xmi.Año = YEAR(ii.issued),
- xmi.Serie = ii.serial,
- xmi.Factura = ii.serialNumber, -- x.FACTURA, DUAS¿?
- xmi.FechaFactura = ii.issued,
- xmi.ImporteFactura = IFNULL(xmi.BaseIva1, 0) + IFNULL(xmi.CuotaIva1, 0) +
- IFNULL(xmi.BaseIva2, 0) + IFNULL(xmi.CuotaIva2, 0) +
- IFNULL(xmi.BaseIva3, 0) + IFNULL(xmi.CuotaIva3, 0) +
- IFNULL(xmi.BaseIva4, 0) + IFNULL(xmi.CuotaIva4, 0),
- xmi.TipoFactura = IF(id.id,IF( ii.serial = 'D', 'R','I'), 'R'), -- MARCAR I para informativa
- xmi.CodigoCuentaFactura = x.SUBCTA,
- xmi.CifDni = IF(LEFT(TRIM(s.nif),2) = n.SiglaNacion, SUBSTRING(TRIM(s.nif),3) ,s.nif),
- xmi.Nombre = s.name,
- xmi.SiglaNacion = n.SiglaNacion,
- xmi.EjercicioFactura = YEAR(ii.issued),
- xmi.FechaOperacion = ii.issued,
- xmi.MantenerAsiento = TRUE,
- xmi.SuFacturaNo = ii.supplierRef,
- xmi.IvaDeducible1 = IF(id.id, FALSE, IF(IFNULL(xmi.BaseIva1, FALSE) = FALSE, FALSE, ii.isVatDeductible)),
- xmi.IvaDeducible2 = IF(id.id, FALSE, IF(IFNULL(xmi.BaseIva2, FALSE) = FALSE, FALSE, ii.isVatDeductible)),
- xmi.IvaDeducible3 = IF(id.id, FALSE, IF(IFNULL(xmi.BaseIva3, FALSE) = FALSE, FALSE, ii.isVatDeductible)),
- xmi.IvaDeducible4 = IF(id.id, FALSE, IF(IFNULL(xmi.BaseIva4, FALSE) = FALSE, FALSE, ii.isVatDeductible)),
- xmi.FechaFacturaOriginal = x.FECHA_EX
- WHERE xmi.id = vXDiarioId;
-
- -- RETENCIONES
-
- UPDATE XDiario_movConta_IVA xmi
- JOIN vn.invoiceIn ii ON ii.id = vInvoiceInFk
- JOIN vn2008.XDiario x ON x.id = xmi.id
- JOIN vn.supplier s ON s.id = supplierFk
- JOIN vn.invoiceInTax iit ON iit.invoiceInFk = ii.id
- JOIN TiposRetencion t ON t.CodigoRetencion = ii.withholdingSageFk
- JOIN (SELECT SUM(BASEEURO) taxableBase, SUM(EURODEBE) taxBase
- FROM vn.XDiario
- WHERE BASEEURO <> 0 AND ASIEN = (SELECT ASIEN FROM vn.XDiario WHERE id = vXDiarioId)
- )sub
- SET xmi.CodigoRetencion = t.CodigoRetencion,
- xmi.ClaveOperacionFactura = IF( t.Retencion = 'ARRENDAMIENTO Y SUBARRENDAMIENTO', 'R', xmi.ClaveOperacionFactura),
- xmi.BaseRetencion = IF (t.CodigoRetencion = 2, sub.taxableBase + sub.taxBase, sub.taxableBase),
- xmi.PorRetencion = t.PorcentajeRetencion,
- xmi.ImporteRetencion = iit.taxableBase * - 1
- WHERE xmi.id = vXDiarioId AND iit.expenceFk = 4751000000;
-
-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 DROP PROCEDURE IF EXISTS `XDiario_movConta_IVA_InvoiceOutAdd_Manager__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `XDiario_movConta_IVA_InvoiceOutAdd_Manager__`()
-BEGIN
-
- DECLARE done BOOL DEFAULT FALSE;
- DECLARE vInvoiceFk INT;
- DECLARE vXDiarioFk INT;
- DECLARE vDated DATE;
-
- DECLARE rs CURSOR FOR
- SELECT io.id invoiceOutFk, x.XDiarioFk
- FROM vn.invoiceOut io
- JOIN (SELECT MIN(id) XDiarioFk, refFk
- FROM vn2008.XDiario x
- JOIN (SELECT x.ASIEN, CONCAT(x.SERIE,x.FACTURA) AS refFk
- FROM vn2008.XDiario x
- JOIN vn.company c ON c.id = x.empresa_id
- WHERE enlazadoSage = FALSE AND
- x.FACTURA AND
- c.companyCode AND
- x.FECHA >= vDated
- GROUP BY refFk
- ) a ON a.ASIEN = x.ASIEN
- GROUP BY refFk
- ) x ON x.refFk = io.ref;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
- SELECT CONCAT(YEAR(CURDATE()), "-01-01") INTO vDated;
-SELECT "2021-01-01" INTO vDated;
- OPEN rs;
- FETCH rs INTO vInvoiceFk, vXDiarioFk;
- WHILE NOT done DO
- CALL XDiario_movConta_IVA_InvoiceOutAdd(vInvoiceFk, vXDiarioFk);
- FETCH rs INTO vInvoiceFk, vXDiarioFk;
- END WHILE;
- CLOSE rs;
-
-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 DROP PROCEDURE IF EXISTS `XDiario_movConta_IVA_InvoiceOutAdd__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `XDiario_movConta_IVA_InvoiceOutAdd__`(IN vInvoiceOutFk INT, IN vXDiarioId INT)
-BEGIN
-
- DECLARE vDone BOOL DEFAULT FALSE;
- DECLARE vBase DOUBLE;
- DECLARE vVat DOUBLE;
- DECLARE vRate DOUBLE;
- DECLARE vIs340 DOUBLE;
- DECLARE vIs347 DOUBLE;
- DECLARE vVatRE DOUBLE;
- DECLARE vRateRE DOUBLE;
- DECLARE vTransactionCode INT;
- DECLARE vCounter INT DEFAULT 0;
- DECLARE vInvoiceOutCorrectedFk INT;
- DECLARE vTaxCode INT;
- DECLARE vIsIntracommunity BOOL DEFAULT FALSE;
- DECLARE vOperationCode VARCHAR(1);
-
- -- IVA
- DECLARE rs CURSOR FOR
- SELECT oit.taxableBase,
- oit.vat,
- pgc.rate,
- pgc.mod340,
- pgc.mod347,
- pgcRE.rate as rateRE,
- oitRE.vat as vatRE,
- tc.transactionCode ,
- tc.taxCode,
- tc.isIntracommunity,
- tc.operationcode
- FROM vn.invoiceOutTax oit
- JOIN vn.pgc ON pgc.code = oit.pgcFk
- LEFT JOIN vn.pgcEqu e ON e.vatFk = oit.pgcFk
- LEFT JOIN vn.pgcEqu eRE ON eRE.equFk = oit.pgcFk
- LEFT JOIN vn.invoiceOutTax oitRE ON oitRE.invoiceOutFk = oit.invoiceOutFk AND oitRE.pgcFk = e.equFk
- LEFT JOIN vn.pgc pgcRE ON pgcRE.code = oitRE.pgcFk
- LEFT JOIN vn.taxCode tc ON tc.code = pgc.code COLLATE 'utf8_general_ci'
- WHERE eRE.equFk Is NULL
- AND oit.invoiceOutFk = vInvoiceOutFk
- GROUP by pgc.code;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
-
- DELETE FROM XDiario_movConta_IVA
- WHERE id = vXDiarioId;
-
- INSERT INTO XDiario_movConta_IVA(id)
- VALUES (vXDiarioId);
- OPEN rs;
- FETCH rs INTO vBase,
- vVat,
- vRate,
- vIs340,
- vIs347,
- vVatRE,
- vRateRE,
- vTransactionCode,
- vTaxCode,
- vIsIntracommunity,
- vOperationCode;
-
- WHILE NOT vDone DO
-
- IF vOperationCode IS NOT NULL THEN
- UPDATE XDiario_movConta_IVA
- SET ClaveOperacionFactura = vOperationCode
- WHERE id = vXDiarioId;
- END IF;
-
- SET vCounter = vCounter + 1;
- CASE vCounter
- WHEN 1 THEN
- UPDATE XDiario_movConta_IVA
- SET BaseIva1 = vBase,
- PorIva1 = vRate,
- CuotaIva1 = vVat,
- PorRecargoEquivalencia1 = vVatRE,
- RecargoEquivalencia1 = vRateRE,
- CodigoTransaccion1 = vTransactionCode,
- CodigoIva1 = vTaxCode
- WHERE id = vXDiarioId;
- WHEN 2 THEN
- UPDATE XDiario_movConta_IVA
- SET BaseIva2 = vBase,
- PorIva2 = vRate,
- CuotaIva2 = vVat,
- PorRecargoEquivalencia2 = vVatRE,
- RecargoEquivalencia2 =vRateRE,
- CodigoTransaccion2 = vTransactionCode,
- CodigoIva2 = vTaxCode
- WHERE id = vXDiarioId;
- WHEN 3 THEN
- UPDATE XDiario_movConta_IVA
- SET BaseIva3 = vBase,
- PorIva3 = vRate,
- CuotaIva3 = vVat,
- PorRecargoEquivalencia3 = vVatRE,
- RecargoEquivalencia3 = vRateRE,
- CodigoTransaccion3 = vTransactionCode,
- CodigoIva3 = vTaxCode
- WHERE id = vXDiarioId;
- WHEN 4 THEN
- UPDATE XDiario_movConta_IVA
- SET BaseIva4 = vBase,
- PorIva4 = vRate,
- CuotaIva4 = vVat,
- PorRecargoEquivalencia4 = vVatRE,
- RecargoEquivalencia4 = vRateRE,
- CodigoTransaccion4 = vTransactionCode,
- CodigoIva4 = vTaxCode
- WHERE id = vXDiarioId;
- END CASE;
-
- UPDATE XDiario_movConta_IVA
- SET Exclusion347 = NOT vIs347
- WHERE id = vXDiarioId;
-
- IF vIsIntracommunity THEN
- UPDATE XDiario_movConta_IVA
- SET Intracomunitaria = TRUE
- WHERE id = vXDiarioId;
- END IF;
-
- FETCH rs INTO vBase,
- vVat,
- vRate,
- vIs340,
- vIs347,
- vVatRE,
- vRateRE,
- vTransactionCode,
- vTaxCode,
- vIsIntracommunity,
- vOperationCode;
- END WHILE;
- CLOSE rs;
- -- OTROS CAMPOS RELATIVOS A LAS FACTURAS
- UPDATE XDiario_movConta_IVA xmi
- JOIN vn.invoiceOut io ON io.id = vInvoiceOutFk
- LEFT JOIN vn.invoiceCorrection ic ON ic.correctedFk = vInvoiceOutFk
- LEFT JOIN vn.invoiceOut ioc ON ioc.id = ic.correctingFk
- JOIN vn2008.XDiario x ON x.id = xmi.id
- JOIN vn.client c ON c.id = io.clientFk
- JOIN Naciones n ON n.countryFk = c.countryFk
- JOIN vn.invoiceOutSerial ios ON ios.code = io.serial
- JOIN vn.taxArea ta ON ta.code = ios.taxAreaFk
- JOIN (SELECT SERIE
- FROM vn2008.XDiario
- WHERE ASIEN = (SELECT ASIEN
- FROM vn2008.XDiario
- WHERE id = vXDiarioId
- )
- AND SERIE IS NOT NULL
- ) sub
- SET xmi.Año = YEAR(io.issued),
- xmi.Serie = sub.SERIE,
- xmi.Factura = RIGHT(io.ref, LENGTH(io.ref) -1),
- xmi.FechaFactura = io.issued,
- xmi.ImporteFactura = io.amount,
- xmi.TipoFactura = "E",
- xmi.CodigoCuentaFactura = x.SUBCTA,
- xmi.CifDni = c.fi,
- xmi.Nombre = SUBSTR(c.socialName,1,35),
- xmi.SiglaNacion = n.SiglaNacion,
- xmi.EjercicioFactura = YEAR(io.issued),
- xmi.FechaOperacion = io.issued,
- xmi.MantenerAsiento = TRUE,
- xmi.FechaFacturaOriginal = x.FECHA_EX
- WHERE xmi.id = vXDiarioId;
-
- -- RECTIFICATIVAS
- SELECT correctedFk
- INTO vInvoiceOutCorrectedFk
- FROM vn.invoiceCorrection
- WHERE correctingFk = vInvoiceOutFk;
-
- IF vInvoiceOutCorrectedFk THEN
- UPDATE XDiario_movConta_IVA xmi
- JOIN vn.invoiceOut ioc ON ioc.id = vInvoiceOutCorrectedFk
- JOIN vn.invoiceCorrection ic ON ic.correctedFk = vInvoiceOutCorrectedFk
- JOIN vn.invoiceOut io ON io.id = vInvoiceOutCorrectedFk
- JOIN (
- SELECT sum(IF(IFNULL(e.vatFk,1),iot.taxableBase,0)) AS Base,
- sum(IF(IFNULL(e.vatFk,1),iot.vat,0)) AS CuotaIva,
- sum(IF(IFNULL(e.vatFk,1),0,iot.vat)) as RE
- FROM vn.invoiceOutTax iot
- LEFT JOIN vn.pgcEqu e ON e.vatFk = iot.pgcFk
- WHERE iot.invoiceOutFk = vInvoiceOutCorrectedFk
- ) iocTAX
- SET xmi.TipoRectificativa = 2,
- xmi.ClaseAbonoRectificativas = 1, -- ic.invoiceCorrectionTypeFk no coincide con las opcioens de SAGE *
- xmi.FechaFacturaOriginal = io.issued,
- xmi.FechaOperacion = io.issued,
- xmi.BaseImponibleOriginal = iocTAX.Base,
- xmi.CuotaIvaOriginal = iocTAX.CuotaIva,
- xmi.RecargoEquivalenciaOriginal = RE,
- xmi.ClaveOperacionFactura = 'D'
- WHERE xmi.id = vXDiarioId;
- /*
- Envases y embalajes / descuentos y bonificaciones / eror fundado
- Concurso de acreedores
- Creditos incobrables
- resto de tectificativas
- Restificativas de facturas simplificadas
- */
- 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 */ ;
--
-- Current Database: `salix`
@@ -23586,7 +19654,7 @@ DELIMITER ;;
BEFORE INSERT ON `inbound`
FOR EACH ROW
BEGIN
- SET NEW.isPicked = NEW.isPicked OR NEW.dated < CURDATE();
+ SET NEW.isPicked = NEW.isPicked OR NEW.dated < util.VN_CURDATE();
CALL visible_log(
NEW.isPicked,
@@ -23710,7 +19778,7 @@ DELIMITER ;;
FOR EACH ROW
BEGIN
SET NEW.lack = NEW.quantity;
- SET NEW.isPicked = NEW.isPicked OR NEW.dated < CURDATE();
+ SET NEW.isPicked = NEW.isPicked OR NEW.dated < util.VN_CURDATE();
CALL visible_log(
NEW.isPicked,
@@ -23820,6 +19888,8 @@ DELIMITER ;
--
-- Dumping routines for database 'stock'
--
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `inbound_addPick` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -23827,8 +19897,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `inbound_addPick`(
vSelf INT,
@@ -23849,6 +19917,8 @@ DELIMITER ;
/*!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 `inbound_removePick` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -23856,8 +19926,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `inbound_removePick`(
vSelf INT,
@@ -23882,6 +19950,8 @@ DELIMITER ;
/*!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 `inbound_requestQuantity` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -23889,8 +19959,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `inbound_requestQuantity`(
vSelf INT,
@@ -23956,6 +20024,8 @@ DELIMITER ;
/*!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 `inbound_sync` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -23963,8 +20033,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `inbound_sync`(vSelf INT)
BEGIN
@@ -24053,6 +20121,8 @@ DELIMITER ;
/*!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 `log_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -24060,8 +20130,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `log_add`(IN `vTableName` VARCHAR(255), IN `vNewId` VARCHAR(255), IN `vOldId` VARCHAR(255))
proc: BEGIN
@@ -24087,76 +20155,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `log_add_beta__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `log_add_beta__`(IN `vTableName` VARCHAR(255), IN `vNewId` VARCHAR(255), IN `vOldId` VARCHAR(255))
-proc: BEGIN
- -- XXX: Disabled while testing
- DECLARE vLanded DATE;
- DECLARE vWarehouseFk INT;
- DECLARE vBuyerFk INT;
- DECLARE vEntryFk INT;
- DECLARE vItemFk INT;
- DECLARE vItemName VARCHAR(50);
-
- -- LEAVE proc;
-
- IF vOldId IS NOT NULL AND !(vOldId <=> vNewId) THEN
- INSERT IGNORE INTO `log` SET
- tableName = vTableName,
- tableId = vOldId,
- operation = 'delete';
- END IF;
-
- IF vNewId IS NOT NULL THEN
- INSERT IGNORE INTO `log` SET
- tableName = vTableName,
- tableId = vNewId,
- operation = 'insert';
- END IF;
-
- IF vTableName = 'buy' THEN
-
- SELECT IFNULL(tr.landed,'2000-01-01')
- INTO vLanded
- FROM vn.travel tr
- JOIN vn.entry e ON e.travelFk = tr.id
- JOIN vn.buy b ON b.entryFk = e.id
- JOIN vn.warehouse w ON w.id = tr.warehouseInFk
- WHERE b.id = vNewId
- AND w.isBuyerToBeEmailed;
-
- IF vLanded = CURDATE() THEN
-
- SELECT it.workerFk, b.entryFk, i.id, i.longName
- INTO vBuyerFk, vEntryFk, vItemFk, vItemName
- FROM vn.itemType it
- JOIN vn.item i ON i.typeFk = it.id
- JOIN vn.buy b ON b.itemFk = i.id
- WHERE b.id = vNewId;
-
- CALL vn.mail_insert(CONCAT(account.user_getNameFromId(vBuyerFk),'@verdnatura.es'),
- CONCAT(account.myUser_getName(),'@verdnatura.es'),
- CONCAT('E-',vEntryFk,' Se ha modificado item ', vItemFk, ' ',vItemName),
- 'Este email se ha generado automáticamente');
-
- END IF;
- 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 DROP PROCEDURE IF EXISTS `log_clean` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -24164,8 +20164,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `log_clean`()
BEGIN
@@ -24177,6 +20175,8 @@ DELIMITER ;
/*!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 `log_delete` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -24184,8 +20184,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `log_delete`(vTableName VARCHAR(255), vTableId INT)
proc: BEGIN
@@ -24209,6 +20207,8 @@ DELIMITER ;
/*!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 `log_refreshAll` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -24216,8 +20216,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `log_refreshAll`()
BEGIN
@@ -24255,6 +20253,8 @@ DELIMITER ;
/*!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 `log_refreshBuy` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -24262,8 +20262,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `log_refreshBuy`(
`vTableName` VARCHAR(255),
@@ -24342,6 +20340,8 @@ DELIMITER ;
/*!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 `log_refreshOrder` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -24349,15 +20349,13 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `log_refreshOrder`(
`vTableName` VARCHAR(255),
`vTableId` INT)
BEGIN
DECLARE vExpireTime INT DEFAULT 20;
- DECLARE vExpired DATETIME DEFAULT TIMESTAMPADD(MINUTE, -vExpireTime, NOW());
+ DECLARE vExpired DATETIME DEFAULT TIMESTAMPADD(MINUTE, -vExpireTime, util.VN_NOW());
DROP TEMPORARY TABLE IF EXISTS tValues;
CREATE TEMPORARY TABLE tValues
@@ -24402,6 +20400,8 @@ DELIMITER ;
/*!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 `log_refreshSale` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -24409,8 +20409,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `log_refreshSale`(
`vTableName` VARCHAR(255),
@@ -24480,6 +20478,8 @@ DELIMITER ;
/*!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 `log_sync` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -24487,8 +20487,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `log_sync`(vSync BOOL)
proc: BEGIN
@@ -24561,7 +20559,7 @@ proc: BEGIN
-- Deletes expired outbounds
- DELETE FROM outbound WHERE expired <= NOW();
+ DELETE FROM outbound WHERE expired <= util.VN_NOW();
-- Attaches desync inbounds
@@ -24616,6 +20614,8 @@ DELIMITER ;
/*!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 `log_syncNoWait` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -24623,8 +20623,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `log_syncNoWait`()
BEGIN
@@ -24645,6 +20643,8 @@ DELIMITER ;
/*!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 `outbound_requestQuantity` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -24652,8 +20652,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `outbound_requestQuantity`(
vSelf INT,
@@ -24719,6 +20717,8 @@ DELIMITER ;
/*!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 `outbound_sync` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -24726,8 +20726,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `outbound_sync`(vSelf INT)
BEGIN
@@ -24810,6 +20808,8 @@ DELIMITER ;
/*!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 `visible_log` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -24817,8 +20817,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `visible_log`(
vIsPicked BOOL,
@@ -24914,7 +20912,7 @@ DROP TABLE IF EXISTS `versionLog`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `versionLog` (
- `code` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
+ `code` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`number` char(11) COLLATE utf8_unicode_ci NOT NULL,
`file` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`user` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
@@ -24953,6 +20951,8 @@ DELIMITER ;
--
-- Dumping routines for database 'util'
--
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP FUNCTION IF EXISTS `accountShortToStandard` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -24960,8 +20960,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `accountShortToStandard`(vAccount VARCHAR(10)) RETURNS varchar(10) CHARSET utf8 COLLATE utf8_unicode_ci
DETERMINISTIC
@@ -24973,6 +20971,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `capitalizeFirst` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -24980,8 +20980,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `capitalizeFirst`(vString VARCHAR(255)) RETURNS varchar(255) CHARSET utf8
NO SQL
@@ -25027,6 +21025,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `crypt` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25034,8 +21034,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `crypt`(vText VARCHAR(255), vKey VARCHAR(255)) RETURNS varchar(255) CHARSET utf8
READS SQL DATA
@@ -25053,6 +21051,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `cryptOff` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25060,8 +21060,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `cryptOff`(vText VARCHAR(255), vKey VARCHAR(255)) RETURNS varchar(255) CHARSET utf8
READS SQL DATA
@@ -25079,6 +21077,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `dayEnd` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25086,8 +21086,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `dayend`(vDated DATE) RETURNS datetime
NO SQL
@@ -25106,6 +21104,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `firstDayOfMonth` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25113,8 +21113,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `firstDayOfMonth`(vDate DATE) RETURNS date
NO SQL
@@ -25133,6 +21131,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `firstDayOfYear` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25140,8 +21140,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `firstDayOfYear`(vDate DATE) RETURNS date
NO SQL
@@ -25160,6 +21158,76 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `formatRow` */;
+/*!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=`root`@`localhost` FUNCTION `formatRow`(vType CHAR(3), vValues VARCHAR(512)) RETURNS varchar(512) CHARSET utf8 COLLATE utf8_unicode_ci
+ DETERMINISTIC
+BEGIN
+ DECLARE vRow VARCHAR(512);
+
+ IF vValues IS NOT NULL THEN
+ SET vRow = CONCAT('
+
+ ', vType ,' |
+ ', REPLACE(vValues, ',', ' | ') ,' |
+
+ ');
+ ELSE
+ SET vRow = '';
+ END IF;
+
+ RETURN vRow;
+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 FUNCTION IF EXISTS `formatTable` */;
+/*!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=`root`@`localhost` FUNCTION `formatTable`(vFields VARCHAR(512), vOldValues VARCHAR(512), vNewValues VARCHAR(512)) RETURNS text CHARSET utf8 COLLATE utf8_unicode_ci
+ DETERMINISTIC
+BEGIN
+ DECLARE vTable TEXT;
+
+ SET vTable = CONCAT('
+
+
+ type |
+ ', REPLACE(vFields, ',', ' | ') ,'
+ |
+
+ ', formatRow('old', vOldValues) ,'
+ ', formatRow('new', vNewValues) ,'
+
+
+ ');
+
+ RETURN vTable;
+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 FUNCTION IF EXISTS `hasDateOverlapped` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25167,8 +21235,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `hasDateOverlapped`(vSarted1 DATE, vEnded1 DATE, vSarted2 DATE, vEnded2 DATE) RETURNS tinyint(1)
DETERMINISTIC
@@ -25182,6 +21248,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `hmacSha2` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25189,8 +21257,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `hmacSha2`(`vAlg` SMALLINT, `vMsg` MEDIUMBLOB, `vKey` MEDIUMBLOB) RETURNS varchar(128) CHARSET utf8
NO SQL
@@ -25226,6 +21292,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `isLeapYear` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25233,8 +21301,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `isLeapYear`(vYear INT) RETURNS tinyint(1)
DETERMINISTIC
@@ -25248,6 +21314,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `lang` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25255,8 +21323,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `lang`() RETURNS char(2) CHARSET utf8
NO SQL
@@ -25274,6 +21340,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `lastDayOfYear` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25281,8 +21349,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `lastDayOfYear`(vDate DATE) RETURNS date
NO SQL
@@ -25301,6 +21367,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `midnight` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25308,14 +21376,12 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `midnight`() RETURNS datetime
READS SQL DATA
BEGIN
- RETURN TIMESTAMP(CURDATE(), '23:59:59');
+ RETURN TIMESTAMP(util.VN_CURDATE(), '23:59:59');
END ;;
DELIMITER ;
@@ -25323,6 +21389,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `nextWeek` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25330,8 +21398,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `nextWeek`(vYearWeek INT) RETURNS int(11)
DETERMINISTIC
@@ -25354,6 +21420,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `quarterFirstDay` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25361,8 +21429,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `quarterFirstDay`(vYear INT, vQuarter INT) RETURNS date
DETERMINISTIC
@@ -25374,6 +21440,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `stringXor` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25381,8 +21449,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `stringXor`(vString MEDIUMBLOB, vConst TINYINT UNSIGNED) RETURNS mediumblob
NO SQL
@@ -25410,6 +21476,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `today` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25417,26 +21485,26 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `today`() RETURNS date
DETERMINISTIC
BEGIN
/**
* Devuelve la fecha actual. Usar en lugar de la función nativa
- * CURDATE() en aquellos que se necesite rendimiento ya que la
+ * util.VN_CURDATE() en aquellos que se necesite rendimiento ya que la
* la última no es determinista.
*
* @return La fecha actual
*/
- RETURN CURDATE();
+ RETURN util.VN_CURDATE();
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 FUNCTION IF EXISTS `tomorrow` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25444,8 +21512,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `tomorrow`() RETURNS date
DETERMINISTIC
@@ -25455,13 +21521,15 @@ BEGIN
*
* @return La fecha de mañana
*/
- RETURN TIMESTAMPADD(DAY, 1, CURDATE());
+ RETURN TIMESTAMPADD(DAY, 1, util.VN_CURDATE());
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 FUNCTION IF EXISTS `twoDaysAgo` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25469,8 +21537,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `twoDaysAgo`() RETURNS date
DETERMINISTIC
@@ -25480,13 +21546,15 @@ BEGIN
*
* @return La fecha de antes de ayer
*/
- RETURN TIMESTAMPADD(DAY, -2, CURDATE());
+ RETURN TIMESTAMPADD(DAY, -2, util.VN_CURDATE());
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 FUNCTION IF EXISTS `yearRelativePosition` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25494,8 +21562,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `yearRelativePosition`(vYear INT) RETURNS varchar(20) CHARSET utf8
DETERMINISTIC
@@ -25507,7 +21573,7 @@ BEGIN
* @param vYear Año a evaluar
* @return La posicion relativa del año
*/
- DECLARE vCurYear INT DEFAULT YEAR(CURDATE());
+ DECLARE vCurYear INT DEFAULT YEAR(util.VN_CURDATE());
IF vYear = vCurYear THEN
RETURN 'curYear';
@@ -25528,6 +21594,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `yesterday` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25535,8 +21603,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `yesterday`() RETURNS date
DETERMINISTIC
@@ -25546,13 +21612,15 @@ BEGIN
*
* @return La fecha de ayer
*/
- RETURN TIMESTAMPADD(DAY, -1, CURDATE());
+ RETURN TIMESTAMPADD(DAY, -1, util.VN_CURDATE());
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 `compareObjects` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25560,8 +21628,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `compareObjects`(vChain VARCHAR(45),vCompare VARCHAR(45))
READS SQL DATA
@@ -25669,6 +21735,8 @@ DELIMITER ;
/*!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 `debugAdd` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25676,8 +21744,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `debugAdd`(vVariable VARCHAR(255), vValue VARCHAR(255))
MODIFIES SQL DATA
@@ -25702,6 +21768,8 @@ DELIMITER ;
/*!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 `exec` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25709,8 +21777,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `exec`(vSqlQuery TEXT)
BEGIN
@@ -25732,6 +21798,8 @@ DELIMITER ;
/*!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 `findObject` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25739,8 +21807,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `findObject`(vChain VARCHAR(45))
READS SQL DATA
@@ -25803,6 +21869,8 @@ DELIMITER ;
/*!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 `procNoOverlap` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25810,8 +21878,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `procNoOverlap`(procName VARCHAR(255))
SQL SECURITY INVOKER
@@ -25840,6 +21906,8 @@ DELIMITER ;
/*!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 `proc_changedPrivs` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25847,8 +21915,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_changedPrivs`()
BEGIN
@@ -25868,6 +21934,8 @@ DELIMITER ;
/*!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 `proc_restorePrivs` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25875,8 +21943,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_restorePrivs`()
BEGIN
@@ -25896,6 +21962,8 @@ DELIMITER ;
/*!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 `proc_savePrivs` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25903,8 +21971,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_savePrivs`()
BEGIN
@@ -25924,6 +21990,8 @@ DELIMITER ;
/*!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 `slowLog_prune` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25931,8 +21999,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `slowLog_prune`()
BEGIN
@@ -25945,7 +22011,7 @@ BEGIN
RENAME TABLE `mysql`.`slow_log` TO `mysql`.`slow_log_temp`;
DELETE FROM `mysql`.`slow_log_temp`
- WHERE start_time < TIMESTAMPADD(WEEK, -1, NOW());
+ WHERE start_time < TIMESTAMPADD(WEEK, -1, util.VN_NOW());
RENAME TABLE `mysql`.`slow_log_temp` TO `mysql`.`slow_log`;
SET GLOBAL slow_query_log = vSlowQueryLog;
@@ -25955,6 +22021,8 @@ DELIMITER ;
/*!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 `throw` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25962,8 +22030,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `throw`(vMessage CHAR(55))
BEGIN
@@ -25980,6 +22046,8 @@ DELIMITER ;
/*!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 `time_createTable` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -25987,8 +22055,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `time_createTable`(vStarted DATE, vEnded DATE)
BEGIN
@@ -26008,6 +22074,8 @@ DELIMITER ;
/*!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 `warn` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -26015,8 +22083,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `warn`(vCode CHAR(35))
BEGIN
@@ -26201,23 +22267,26 @@ SET character_set_client = utf8;
SET character_set_client = @saved_cs_client;
--
--- Temporary table structure for view `absenceType`
+-- Table structure for table `absenceType`
--
DROP TABLE IF EXISTS `absenceType`;
-/*!50001 DROP VIEW IF EXISTS `absenceType`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `absenceType` (
- `id` tinyint NOT NULL,
- `name` tinyint NOT NULL,
- `rgb` tinyint NOT NULL,
- `code` tinyint NOT NULL,
- `permissionRate` tinyint NOT NULL,
- `holidayEntitlementRate` tinyint NOT NULL,
- `discountRate` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `absenceType` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `name` varchar(30) NOT NULL,
+ `rgb` varchar(7) NOT NULL,
+ `color` bigint(20) DEFAULT '0',
+ `permissionRate` decimal(3,2) DEFAULT NULL,
+ `code` varchar(45) DEFAULT NULL,
+ `isAllowedToWork` tinyint(4) NOT NULL DEFAULT '0',
+ `isPrintable` tinyint(1) NOT NULL DEFAULT '0',
+ `discountRate` decimal(3,2) DEFAULT NULL,
+ `holidayEntitlementRate` decimal(3,2) DEFAULT '1.00',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDBDEFAULT CHARSET=utf8;
+/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `accounting`
@@ -26231,7 +22300,7 @@ CREATE TABLE `accounting` (
`bank` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`account` varchar(10) CHARACTER SET utf8 DEFAULT NULL,
`accountingTypeFk` smallint(6) NOT NULL DEFAULT '0',
- `entityFk` int(10) unsigned NOT NULL,
+ `entityFk` int(10) unsigned DEFAULT NULL,
`isActive` tinyint(4) NOT NULL DEFAULT '1',
`currencyFk` tinyint(3) unsigned DEFAULT '1',
`code` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
@@ -26241,6 +22310,7 @@ CREATE TABLE `accounting` (
KEY `foreignkey1_idx` (`accountingTypeFk`),
KEY `Bancoscurrency_idx` (`currencyFk`),
CONSTRAINT `Bancoscurrency` FOREIGN KEY (`currencyFk`) REFERENCES `currency` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `accounting_FK` FOREIGN KEY (`entityFk`) REFERENCES `bankEntity` (`id`) ON UPDATE CASCADE,
CONSTRAINT `bank_FK` FOREIGN KEY (`accountingTypeFk`) REFERENCES `accountingType` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Apunta a la vista vn.Accounting\nLa columna cash es la FK de vn.AccountingType';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -26265,13 +22335,13 @@ CREATE TABLE `accountingType` (
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `activeContrat`
+-- Table structure for table `activeContrat__`
--
-DROP TABLE IF EXISTS `activeContrat`;
+DROP TABLE IF EXISTS `activeContrat__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `activeContrat` (
+CREATE TABLE `activeContrat__` (
`date` date NOT NULL,
`business_id` int(11) NOT NULL,
PRIMARY KEY (`date`,`business_id`)
@@ -26531,22 +22601,23 @@ CREATE TABLE `agency` (
`id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(25) COLLATE utf8_unicode_ci NOT NULL,
`warehouseFk` smallint(5) unsigned DEFAULT NULL COMMENT 'A nulo si se puede enrutar desde todos los almacenes',
- `isVolumetric` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Si el calculo del porte se hacer por volumen',
- `bankFk` int(11) NOT NULL DEFAULT '8' COMMENT 'para realizar los reembolsos',
+ `isVolumetric__` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Si el calculo del porte se hacer por volumen',
+ `bankFk__` int(11) NOT NULL DEFAULT '8' COMMENT 'para realizar los reembolsos',
`warehouseAliasFk` smallint(5) unsigned DEFAULT NULL,
`isOwn` tinyint(1) NOT NULL DEFAULT '0',
- `labelZone` tinyint(4) NOT NULL DEFAULT '0',
+ `labelZone__` tinyint(4) NOT NULL DEFAULT '0',
`workCenterFk` int(11) DEFAULT NULL,
`supplierFk__` int(11) DEFAULT NULL,
`isAnyVolumeAllowed` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Permite vender productos que tengan vn.itemType.IsUnconventionalSize = TRUE',
PRIMARY KEY (`id`),
KEY `warehouse_id` (`warehouseFk`),
- KEY `Id_Banco` (`bankFk`),
+ KEY `Id_Banco` (`bankFk__`),
KEY `agencias_alias_idx` (`warehouseAliasFk`),
KEY `agency_ibfk_3_idx` (`workCenterFk`),
KEY `agency_ibfk_4_idx` (`supplierFk__`),
+ CONSTRAINT `agency_FK` FOREIGN KEY (`warehouseAliasFk`) REFERENCES `warehouseAlias` (`id`) ON UPDATE CASCADE,
CONSTRAINT `agency_ibfk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `agency_ibfk_2` FOREIGN KEY (`bankFk`) REFERENCES `accounting` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `agency_ibfk_2` FOREIGN KEY (`bankFk__`) REFERENCES `accounting` (`id`) ON UPDATE CASCADE,
CONSTRAINT `agency_ibfk_3` FOREIGN KEY (`workCenterFk`) REFERENCES `workCenter` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -26626,23 +22697,6 @@ CREATE TABLE `agencyMode` (
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Temporary table structure for view `agencyProvince__`
---
-
-DROP TABLE IF EXISTS `agencyProvince__`;
-/*!50001 DROP VIEW IF EXISTS `agencyProvince__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `agencyProvince__` (
- `provinceFk` tinyint NOT NULL,
- `agencyFk` tinyint NOT NULL,
- `zone` tinyint NOT NULL,
- `warehouseFk` tinyint NOT NULL,
- `isVolumetric` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Temporary table structure for view `agencyTerm`
--
@@ -26923,8 +22977,12 @@ CREATE TABLE `awb` (
KEY `carguera_id` (`freightFk`),
KEY `flight_id` (`flightFk`),
KEY `awbInvoiceIn` (`invoiceInFk`),
+ KEY `awb_FK` (`docFk`),
CONSTRAINT `awbInvoiceIn` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `awbTransitoryFk` FOREIGN KEY (`transitoryFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `awb_FK` FOREIGN KEY (`docFk`) REFERENCES `dms` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `awb_FK_1` FOREIGN KEY (`flightFk`) REFERENCES `vn2008`.`flight` (`flight_id`) ON UPDATE CASCADE,
+ CONSTRAINT `awb_FK_2` FOREIGN KEY (`freightFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE,
CONSTRAINT `awb_ibfk_1` FOREIGN KEY (`taxFk`) REFERENCES `taxCode` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -26942,33 +23000,9 @@ DELIMITER ;;
FOR EACH ROW
BEGIN
- SET NEW.year= year(CURDATE());
+ SET NEW.year= year(util.VN_CURDATE());
-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=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`awb_au`
- AFTER UPDATE ON `awb`
- FOR EACH ROW
-BEGIN
-
- IF NEW.amount <> OLD.amount THEN
- CALL vn2008.buy_tarifas_awb(NEW.code);
- END IF;
-
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -26977,36 +23011,17 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
--
--- Temporary table structure for view `awb__`
+-- Temporary table structure for view `awbVolume`
--
-DROP TABLE IF EXISTS `awb__`;
-/*!50001 DROP VIEW IF EXISTS `awb__`*/;
+DROP TABLE IF EXISTS `awbVolume`;
+/*!50001 DROP VIEW IF EXISTS `awbVolume`*/;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
-/*!50001 CREATE TABLE `awb__` (
- `id` tinyint NOT NULL,
- `code` tinyint NOT NULL,
- `package` tinyint NOT NULL,
- `weight` tinyint NOT NULL,
- `created` tinyint NOT NULL,
- `transitoryFk` tinyint NOT NULL,
- `taxFk` tinyint NOT NULL,
- `docFk` tinyint NOT NULL,
- `amount` tinyint NOT NULL,
- `freightFk` tinyint NOT NULL,
- `m3` tinyint NOT NULL,
- `stems` tinyint NOT NULL,
- `flightFk` tinyint NOT NULL,
- `volumeWeight` tinyint NOT NULL,
- `hb` tinyint NOT NULL,
- `rate` tinyint NOT NULL,
- `booked` tinyint NOT NULL,
- `issued` tinyint NOT NULL,
- `operated` tinyint NOT NULL,
- `bookEntried` tinyint NOT NULL,
- `invoiceInFk` tinyint NOT NULL,
- `isChecked` tinyint NOT NULL
+/*!50001 CREATE TABLE `awbVolume` (
+ `awbFk` tinyint NOT NULL,
+ `volume` tinyint NOT NULL,
+ `buyFk` tinyint NOT NULL
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
@@ -27041,13 +23056,69 @@ CREATE TABLE `bankEntity` (
`countryFk` mediumint(8) unsigned NOT NULL DEFAULT '1',
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(45) COLLATE utf8_unicode_ci NOT NULL,
- `bic` varchar(11) CHARACTER SET utf8 DEFAULT NULL,
+ `bic` varchar(11) CHARACTER SET utf8 NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `bic_UNIQUE` (`bic`),
KEY `fg_entity1_idx` (`countryFk`),
CONSTRAINT `fg_entity1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Entidades bancarias ';
/*!40101 SET character_set_client = @saved_cs_client */;
+/*!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=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`bankEntity_beforeInsert`
+ BEFORE INSERT ON `bankEntity`
+ FOR EACH ROW
+BEGIN
+ CALL bankEntity_checkBic(NEW.bic);
+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=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`bankEntity_beforeUpdate`
+ BEFORE UPDATE ON `bankEntity`
+ FOR EACH ROW
+BEGIN
+ IF NOT (NEW.bic <=> OLD.bic) THEN
+ CALL bankEntity_checkBic(NEW.bic);
+ 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 */ ;
+
+--
+-- Table structure for table `bankEntityConfig`
+--
+
+DROP TABLE IF EXISTS `bankEntityConfig`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `bankEntityConfig` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `bicLength` tinyint(4) DEFAULT '11' COMMENT 'Tamaño del campo bic',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Temporary table structure for view `bankPolicy`
@@ -27088,14 +23159,10 @@ DROP TABLE IF EXISTS `beach`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `beach` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `warehouseFk` smallint(6) NOT NULL,
- `x` int(11) NOT NULL,
- `y` int(11) NOT NULL,
- `name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
- `isShowed` tinyint(1) DEFAULT '0',
- PRIMARY KEY (`id`)
-) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Ubicaciones respecto a la playa del almacén';
+ `code` varchar(45) COLLATE utf8_unicode_ci NOT NULL,
+ `warehouseFk` smallint(6) NOT NULL DEFAULT '60',
+ PRIMARY KEY (`code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Ubicaciones respecto a la playa del almacén';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -27366,7 +23433,7 @@ CREATE TABLE `buy` (
`buyingValue` decimal(10,3) DEFAULT '0.000',
`freightValue` decimal(10,3) DEFAULT '0.000',
`isIgnored` tinyint(1) NOT NULL DEFAULT '0',
- `stickers` int(11) DEFAULT '0',
+ `stickers` int(11) NOT NULL DEFAULT '0',
`packing` int(11) DEFAULT '0',
`grouping` smallint(5) unsigned NOT NULL DEFAULT '1',
`groupingMode` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0=sin obligar 1=groping 2=packing',
@@ -27400,6 +23467,7 @@ CREATE TABLE `buy` (
KEY `buy_fk_4_idx` (`deliveryFk`),
KEY `buy_FK` (`itemOriginalFk`),
CONSTRAINT `buy_FK` FOREIGN KEY (`itemOriginalFk`) REFERENCES `item` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
+ CONSTRAINT `buy_FK_1` FOREIGN KEY (`containerFk`) REFERENCES `vn2008`.`container` (`container_id`) ON UPDATE CASCADE,
CONSTRAINT `buy_ektFk` FOREIGN KEY (`ektFk`) REFERENCES `edi`.`ekt` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `buy_fk_4` FOREIGN KEY (`deliveryFk`) REFERENCES `edi`.`deliveryInformation` (`ID`) ON DELETE SET NULL ON UPDATE SET NULL,
CONSTRAINT `buy_ibfk_1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE,
@@ -27427,18 +23495,16 @@ trig: BEGIN
DECLARE vGroupingMode TINYINT;
DECLARE vGenericFk INT;
DECLARE vGenericInDate BOOL;
-
- IF @isModeInventory THEN
+
+ IF @isModeInventory THEN
LEAVE trig;
END IF;
-
- CALL buy_checkGrouping(NEW.`grouping`);
+ CALL buy_checkGrouping(NEW.`grouping`);
SELECT t.warehouseInFk, t.landed INTO vWarehouse, vLanding
- FROM entry e
+ FROM entry e
JOIN travel t ON t.id = e.travelFk
WHERE e.id = NEW.entryFk;
-
SELECT b.`grouping`, b.groupingMode INTO vGrouping, vGroupingMode
FROM buy b
JOIN entry e ON e.id = b.entryFk
@@ -27448,40 +23514,32 @@ trig: BEGIN
AND !b.isIgnored
ORDER BY t.warehouseInFk = vWarehouse DESC, t.landed DESC, b.id DESC
LIMIT 1;
-
IF NEW.`grouping` IS NULL THEN
SET NEW.`grouping` = vGrouping;
END IF;
-
IF NEW.groupingMode IS NULL THEN
SET NEW.groupingMode = vGroupingMode;
END IF;
-
-- Generics
-
SELECT i.genericFk INTO vGenericFk
FROM vn.item i
WHERE i.id = NEW.itemFk;
-
+
IF vGenericFk THEN
-
+
SELECT COUNT(*) INTO vGenericInDate
- FROM vn.genericAllocation ga
+ FROM vn.genericAllocation ga
JOIN vn.entry e ON e.id = NEW.entryFk
JOIN vn.travel tr on tr.id = e.travelFk
WHERE ga.itemFk = vGenericFk
AND tr.landed BETWEEN ga.startDated AND ga.endDated;
-
IF vGenericInDate THEN
-
SET NEW.itemOriginalFk = NEW.itemFk;
-
+
SET NEW.itemFk = vGenericFk;
-
END IF;
-
- END IF;
+ END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -27501,13 +23559,31 @@ DELIMITER ;;
AFTER INSERT ON `buy`
FOR EACH ROW
trig: BEGIN
+ DECLARE vValues VARCHAR(255);
+
CALL stock.log_add('buy', NEW.id, NULL);
IF @isModeInventory THEN
LEAVE trig;
END IF;
- CALL buy_afterUpsert(NEW.id);
+ IF @isTriggerDisabled THEN
+ LEAVE trig;
+ END IF;
+
+ CALL buy_afterUpsert(NEW.id);
+
+ /*IF entry_isInventoryOrPrevious(NEW.entryFk) THEN
+ SET vValues = CONCAT_WS(',',
+ NEW.entryFk,
+ NEW.itemFk,
+ NEW.quantity,
+ NEW.price1,
+ NEW.price2,
+ NEW.price3
+ );
+ CALL entry_notifyChanged(NEW.entryFk, NEW.id, vValues, NULL);
+ END IF;*/
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -27526,43 +23602,43 @@ DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`buy_beforeUpdate`
BEFORE UPDATE ON `buy`
FOR EACH ROW
-trig:BEGIN
+trig:BEGIN
DECLARE vGenericFk INT;
DECLARE vGenericInDate BOOL;
-
- IF @isTriggerDisabled THEN
-
+ DECLARE vIsInventory BOOL;
+ IF @isTriggerDisabled THEN
LEAVE trig;
-
END IF;
-
- IF !(NEW.`grouping` <=> OLD.`grouping`) THEN
+ IF !(NEW.`grouping` <=> OLD.`grouping`) THEN
CALL buy_checkGrouping(NEW.`grouping`);
END IF;
-
-- Generics
-
SELECT i.genericFk INTO vGenericFk
FROM vn.item i
WHERE i.id = NEW.itemFk;
-
+
IF vGenericFk THEN
-
SELECT COUNT(*) INTO vGenericInDate
- FROM vn.genericAllocation ga
+ FROM vn.genericAllocation ga
JOIN vn.entry e ON e.id = NEW.entryFk
JOIN vn.travel tr on tr.id = e.travelFk
WHERE ga.itemFk = vGenericFk
AND tr.landed BETWEEN ga.startDated AND ga.endDated;
-
IF vGenericInDate THEN
-
SET NEW.itemOriginalFk = NEW.itemFk;
-
SET NEW.itemFk = vGenericFk;
-
END IF;
-
+ END IF;
+ SELECT COUNT(*) INTO vIsInventory
+ FROM vn.entry e
+ JOIN vn.supplier s ON s.id = e.supplierFk
+ JOIN vn.entryConfig ec ON ec.inventorySupplierFk = e.supplierFk
+ WHERE e.id = NEW.entryFk;
+
+ IF vIsInventory THEN
+ IF NOT NEW.printedStickers <=> OLD.printedStickers THEN
+ CALL util.throw("Stickers cannot be modified if they are inventory");
+ END IF;
END IF;
END */;;
DELIMITER ;
@@ -27588,7 +23664,8 @@ trig: BEGIN
DECLARE vIsBuyerToBeEmailed BOOL;
DECLARE vItemName VARCHAR(50);
DECLARE vIsInventory BOOL;
- DECLARE vEmail VARCHAR(255);
+ DECLARE vNewValues VARCHAR(255);
+ DECLARE vOldValues VARCHAR(255);
IF !(NEW.id <=> OLD.id)
OR !(NEW.entryFk <=> OLD.entryFk)
@@ -27602,6 +23679,10 @@ trig: BEGIN
LEAVE trig;
END IF;
+ IF @isTriggerDisabled THEN
+ LEAVE trig;
+ END IF;
+
CALL buy_afterUpsert(NEW.id);
IF !(NEW.weight <=> OLD.weight) AND NEW.weight THEN
@@ -27626,7 +23707,7 @@ trig: BEGIN
IF vIsBuyerToBeEmailed AND
vBuyerFk != account.myUser_getId() AND
- vLanded = CURDATE() THEN
+ vLanded = util.VN_CURDATE() THEN
IF !(NEW.itemFk <=> OLD.itemFk) OR
!(NEW.quantity <=> OLD.quantity) OR
!(NEW.packing <=> OLD.packing) OR
@@ -27641,33 +23722,55 @@ trig: BEGIN
);
END IF;
END IF;
-
- SELECT e.isInventory INTO vIsInventory
- FROM entry e
- WHERE e.id = NEW.entryFk;
-
- SELECT e.mailToNotify INTO vEmail
- FROM entryConfig e
- LIMIT 1;
-
- IF vIsInventory AND
- (!(NEW.quantity <=> OLD.quantity)
- OR !(NEW.price1<=>OLD.price1)
- OR !(NEW.price2<=>OLD.price2)
- OR !(NEW.price3<=>OLD.price3)) THEN
-
- CALL mail_insert(
- vEmail,
- NULL,
- CONCAT('Se ha modificado la entrada ', NEW.entryFk ,' del Artículo ', NEW.itemFk, ' siendo inventario'),
- CONCAT(
- 'Antes: Cantidad: ', OLD.quantity, ' Precio1: ', OLD.price1, ' Precio2: ', OLD.price2, ' Precio3: ', OLD.price3,
- '
',
- 'Despues: Cantidad: ', NEW.quantity, ' Precio1: ', NEW.price1, ' Precio2: ', NEW.price2, ' Precio3: ', NEW.price3
- )
+/*
+ IF (!(NEW.entryFk <=> OLD.entryFk)
+ OR !(NEW.quantity <=> OLD.quantity)
+ OR !(NEW.price1 <=> OLD.price1)
+ OR !(NEW.price2 <=> OLD.price2)
+ OR !(NEW.price3 <=> OLD.price3))
+ AND (entry_isInventoryOrPrevious(NEW.entryFk)
+ OR entry_isInventoryOrPrevious(OLD.entryFk)) THEN
+ SET vOldValues = CONCAT_WS(',',
+ OLD.entryFk,
+ OLD.itemFk,
+ OLD.quantity,
+ OLD.price1,
+ OLD.price2,
+ OLD.price3
);
- END IF;
-
+ SET vNewValues = CONCAT_WS(',',
+ NEW.entryFk,
+ NEW.itemFk,
+ NEW.quantity,
+ NEW.price1,
+ NEW.price2,
+ NEW.price3
+ );
+ CALL entry_notifyChanged(NEW.entryFk, NEW.id, vNewValues, vOldValues);
+ 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=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`buy_beforeDelete`
+ BEFORE DELETE ON buy
+ FOR EACH ROW
+BEGIN
+ IF OLD.printedStickers <> 0 THEN
+ CALL util.throw("it is not possible to delete buys with printed labels ");
+ END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -27686,8 +23789,26 @@ DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`buy_afterDelete`
AFTER DELETE ON `buy`
FOR EACH ROW
-BEGIN
+trig: BEGIN
+ DECLARE vValues VARCHAR(255);
+
+ IF @isTriggerDisabled THEN
+ LEAVE trig;
+ END IF;
+
CALL stock.log_add('buy', NULL, OLD.id);
+
+ /*IF entry_isInventoryOrPrevious(OLD.entryFk) THEN
+ SET vValues = CONCAT_WS(',',
+ OLD.entryFk,
+ OLD.itemFk,
+ OLD.quantity,
+ OLD.price1,
+ OLD.price2,
+ OLD.price3
+ );
+ CALL entry_notifyChanged(OLD.entryFk, OLD.id, NULL, vValues);
+ END IF;*/
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -27759,8 +23880,8 @@ CREATE TABLE `calendar` (
KEY `calendar_employee_business_labour_id_idx` (`businessFk`),
KEY `calendar_employee_calendar_state_calendar_state_id_idx` (`dayOffTypeFk`),
KEY `id_index` (`id`),
- CONSTRAINT `calendar_businessFk` FOREIGN KEY (`businessFk`) REFERENCES `postgresql`.`business` (`business_id`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `calendar_employee_state_id` FOREIGN KEY (`dayOffTypeFk`) REFERENCES `postgresql`.`calendar_state` (`calendar_state_id`) ON DELETE NO ACTION ON UPDATE CASCADE
+ CONSTRAINT `calendar_FK` FOREIGN KEY (`dayOffTypeFk`) REFERENCES `absenceType` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `calendar_businessFk` FOREIGN KEY (`businessFk`) REFERENCES `postgresql`.`business` (`business_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -27817,22 +23938,6 @@ CREATE TABLE `calendarHolidaysType` (
) ENGINE=InnoDBDEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Temporary table structure for view `calendar__`
---
-
-DROP TABLE IF EXISTS `calendar__`;
-/*!50001 DROP VIEW IF EXISTS `calendar__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `calendar__` (
- `id` tinyint NOT NULL,
- `businessFk` tinyint NOT NULL,
- `dayOffTypeFk` tinyint NOT NULL,
- `dated` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Table structure for table `campaign`
--
@@ -27994,6 +24099,7 @@ DROP TABLE IF EXISTS `claimConfig`;
CREATE TABLE `claimConfig` (
`id` int(11) NOT NULL,
`pickupContact` varchar(250) COLLATE utf8_unicode_ci DEFAULT NULL,
+ `maxResponsibility` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -28137,24 +24243,6 @@ CREATE TABLE `claimRatio` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Temporary table structure for view `claimRatio__`
---
-
-DROP TABLE IF EXISTS `claimRatio__`;
-/*!50001 DROP VIEW IF EXISTS `claimRatio__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `claimRatio__` (
- `clientFk` tinyint NOT NULL,
- `yearSale` tinyint NOT NULL,
- `claimAmount` tinyint NOT NULL,
- `claimingRate` tinyint NOT NULL,
- `priceIncreasing` tinyint NOT NULL,
- `packingRate` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Table structure for table `claimReason`
--
@@ -28243,14 +24331,14 @@ DROP TABLE IF EXISTS `client`;
CREATE TABLE `client` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
- `discount` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT 'obsoleta (comprobar)',
+ `discount__` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT 'obsoleta (comprobar)',
`defaultAddressFk` int(11) DEFAULT NULL,
`street` longtext COLLATE utf8_unicode_ci,
`fi` varchar(14) COLLATE utf8_unicode_ci DEFAULT NULL,
`phone` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL,
`fax__` varchar(11) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'obsoleta (comprobar)',
`email` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
- `cc` varchar(23) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'obsoleta (comprobar)',
+ `cc__` varchar(23) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'obsoleta (comprobar)',
`dueDay` smallint(6) NOT NULL DEFAULT '5',
`receipt__` int(11) DEFAULT '1' COMMENT 'obsoleta',
`isOfficial__` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'obsoleta (comprobar)',
@@ -28266,14 +24354,14 @@ CREATE TABLE `client` (
`wholesaler__` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'obsoleta (comprobar)',
`isReExpedition__` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'obsoleta (comprobar)',
`hasToInvoice` tinyint(1) NOT NULL DEFAULT '1',
- `notes` text COLLATE utf8_unicode_ci COMMENT 'obsoleta (comprobar)',
+ `notes__` text COLLATE utf8_unicode_ci COMMENT 'obsoleta (comprobar)',
`administrativeNotes__` text COLLATE utf8_unicode_ci NOT NULL COMMENT 'obsoleta (comprobar)',
`invoiceCopy__` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'obsoleta (comprobar)',
`hold__` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'obsoleta (comprobar)',
`isFreezed` tinyint(1) NOT NULL DEFAULT '0',
`salesPersonFk` int(10) unsigned DEFAULT NULL,
`credit` decimal(10,2) NOT NULL DEFAULT '0.00',
- `cyc` double DEFAULT NULL COMMENT 'obsoleta (comprobar)',
+ `cyc__` double DEFAULT NULL COMMENT 'obsoleta (comprobar)',
`countryFk` mediumint(8) unsigned NOT NULL DEFAULT '1',
`isActive` tinyint(1) NOT NULL DEFAULT '1',
`gestdocFk` int(11) DEFAULT NULL,
@@ -28303,12 +24391,12 @@ CREATE TABLE `client` (
`hasInvoiceSimplified` tinyint(1) NOT NULL DEFAULT '0',
`iban` varchar(45) CHARACTER SET utf8 DEFAULT NULL,
`hasLcr` tinyint(1) NOT NULL DEFAULT '0',
- `bankEntityFk` int(10) DEFAULT NULL,
+ `bankEntityFk` int(10) unsigned DEFAULT NULL,
`typeFk` varchar(20) CHARACTER SET utf8 NOT NULL DEFAULT 'normal',
`taxTypeSageFk` smallint(6) DEFAULT NULL COMMENT 'Tipo de Iva por defecto asociado al cliente en SAGE',
`transactionTypeSageFk` tinyint(4) DEFAULT NULL COMMENT 'Tipo de transacción por defecto asociado al cliente en SAGE',
`transferorFk` int(11) DEFAULT NULL COMMENT 'Cliente que le ha transmitido la titularidad de la empresa',
- `lastSalesPersonFk` int(11) DEFAULT NULL COMMENT 'ultimo comercial que tuvo, para el calculo del peso en los rankings de equipo',
+ `lastSalesPersonFk` int(10) unsigned DEFAULT NULL COMMENT 'ultimo comercial que tuvo, para el calculo del peso en los rankings de equipo',
`businessTypeFk` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `IF` (`fi`),
@@ -28329,8 +24417,12 @@ CREATE TABLE `client` (
KEY `client_transactionTypeSageFk_idx` (`transactionTypeSageFk`),
KEY `client_FK` (`businessTypeFk`),
KEY `client_lastSalesPersonFk_IDX` (`lastSalesPersonFk`) USING BTREE,
+ KEY `client_FK_3` (`transferorFk`),
CONSTRAINT `canal_nuevo_cliente` FOREIGN KEY (`contactChannelFk`) REFERENCES `contactChannel` (`id`) ON UPDATE CASCADE,
CONSTRAINT `client_FK` FOREIGN KEY (`businessTypeFk`) REFERENCES `businessType` (`code`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `client_FK_1` FOREIGN KEY (`bankEntityFk`) REFERENCES `bankEntity` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `client_FK_2` FOREIGN KEY (`lastSalesPersonFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `client_FK_3` FOREIGN KEY (`transferorFk`) REFERENCES `client` (`id`),
CONSTRAINT `client_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE,
CONSTRAINT `client_ibfk_2` FOREIGN KEY (`payMethodFk`) REFERENCES `payMethod` (`id`) ON UPDATE CASCADE,
CONSTRAINT `client_ibfk_3` FOREIGN KEY (`salesPersonFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
@@ -28511,6 +24603,8 @@ DROP TABLE IF EXISTS `clientConfig`;
CREATE TABLE `clientConfig` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`riskTolerance` int(11) DEFAULT NULL COMMENT 'Maximo riesgo de un cliente para preparar su pedido',
+ `maxCreditRows` int(11) DEFAULT NULL COMMENT 'Máximo número de registros a mantener en la tabla clientCredit',
+ `maxPriceIncreasingRatio` decimal(2,2) NOT NULL DEFAULT '0.25' COMMENT 'máximo recobro permitido',
PRIMARY KEY (`id`)
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -28617,7 +24711,7 @@ CREATE TABLE `clientDms` (
PRIMARY KEY (`dmsFk`),
KEY `gest_doc_id` (`dmsFk`),
KEY `fk_clientes_gestdoc_1_idx` (`clientFk`),
- CONSTRAINT `clientDms_ibfk_2` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE,
+ CONSTRAINT `clientDms_ibfk_2` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `fk_clientes_gestdoc_3` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -28721,21 +24815,6 @@ CREATE TABLE `clientManaCache` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Temporary table structure for view `clientManaCache__`
---
-
-DROP TABLE IF EXISTS `clientManaCache__`;
-/*!50001 DROP VIEW IF EXISTS `clientManaCache__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `clientManaCache__` (
- `clientFk` tinyint NOT NULL,
- `mana` tinyint NOT NULL,
- `dated` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Table structure for table `clientObservation`
--
@@ -28869,21 +24948,6 @@ CREATE TABLE `clientRisk` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Saldo de apertura < 2015-01-01';
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Temporary table structure for view `clientRisk__`
---
-
-DROP TABLE IF EXISTS `clientRisk__`;
-/*!50001 DROP VIEW IF EXISTS `clientRisk__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `clientRisk__` (
- `clientFk` tinyint NOT NULL,
- `companyFk` tinyint NOT NULL,
- `amount` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Table structure for table `clientSample`
--
@@ -28923,6 +24987,22 @@ CREATE TABLE `clientType` (
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Establece categorias para poder agrupar las ventas';
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `clientUnpaid`
+--
+
+DROP TABLE IF EXISTS `clientUnpaid`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `clientUnpaid` (
+ `clientFk` int(11) NOT NULL,
+ `dated` date NOT NULL,
+ `amount` double DEFAULT '0',
+ PRIMARY KEY (`clientFk`),
+ CONSTRAINT `clientUnpaid_clientFk` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `clientYoke`
--
@@ -28970,7 +25050,9 @@ CREATE TABLE `cmr` (
KEY `cmr_fk2_idx` (`companyFk`),
KEY `cmr_fk3_idx` (`addressToFk`),
KEY `cm_fk4_idx` (`supplierFk`),
+ KEY `cmr_FK` (`addressFromFk`),
CONSTRAINT `cm_fk4` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `cmr_FK` FOREIGN KEY (`addressFromFk`) REFERENCES `address` (`id`) ON UPDATE CASCADE,
CONSTRAINT `cmr_fk1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `cmr_fk2` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `cmr_fk3` FOREIGN KEY (`addressToFk`) REFERENCES `address` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
@@ -29192,26 +25274,6 @@ CREATE TABLE `collectionColors` (
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Recoge los colores para las baldas de las colecciones';
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Temporary table structure for view `collectionReportSource`
---
-
-DROP TABLE IF EXISTS `collectionReportSource`;
-/*!50001 DROP VIEW IF EXISTS `collectionReportSource`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `collectionReportSource` (
- `collectionFk` tinyint NOT NULL,
- `ticketFk` tinyint NOT NULL,
- `itemFk` tinyint NOT NULL,
- `concept` tinyint NOT NULL,
- `size` tinyint NOT NULL,
- `quantity` tinyint NOT NULL,
- `nicho` tinyint NOT NULL,
- `level` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Temporary table structure for view `collectionSmartTag`
--
@@ -29298,6 +25360,12 @@ CREATE TABLE `commissionConfig` (
`minScoreForPlusBoss` int(11) DEFAULT NULL,
`plusTeam` int(11) DEFAULT NULL,
`plusBoss` int(11) DEFAULT NULL COMMENT 'Este campo se deberá multiplicar x el número de miembros del equipo',
+ `executionDay` smallint(6) DEFAULT NULL,
+ `salesPersonWithPlusNewClient` int(11) DEFAULT NULL,
+ `maxPlusNewClient` int(11) DEFAULT NULL,
+ `plusDifference` int(11) DEFAULT NULL,
+ `maxScoreNewClient` int(11) DEFAULT NULL,
+ `scoreDifference` int(11) DEFAULT NULL,
PRIMARY KEY (`rate`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -29383,25 +25451,6 @@ CREATE TABLE `component` (
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Temporary table structure for view `componentRate__`
---
-
-DROP TABLE IF EXISTS `componentRate__`;
-/*!50001 DROP VIEW IF EXISTS `componentRate__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `componentRate__` (
- `id` tinyint NOT NULL,
- `name` tinyint NOT NULL,
- `componentTypeRate` tinyint NOT NULL,
- `classRate` tinyint NOT NULL,
- `tax` tinyint NOT NULL,
- `isRenewable` tinyint NOT NULL,
- `code` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Table structure for table `componentType`
--
@@ -29420,56 +25469,6 @@ CREATE TABLE `componentType` (
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Permite organizar de forma ordenada los distintos componentes';
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Temporary table structure for view `componentTypeRate__`
---
-
-DROP TABLE IF EXISTS `componentTypeRate__`;
-/*!50001 DROP VIEW IF EXISTS `componentTypeRate__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `componentTypeRate__` (
- `id` tinyint NOT NULL,
- `type` tinyint NOT NULL,
- `base` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
---
--- Temporary table structure for view `componentType__`
---
-
-DROP TABLE IF EXISTS `componentType__`;
-/*!50001 DROP VIEW IF EXISTS `componentType__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `componentType__` (
- `id` tinyint NOT NULL,
- `type` tinyint NOT NULL,
- `isBase` tinyint NOT NULL,
- `isMargin` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
---
--- Temporary table structure for view `component__`
---
-
-DROP TABLE IF EXISTS `component__`;
-/*!50001 DROP VIEW IF EXISTS `component__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `component__` (
- `id` tinyint NOT NULL,
- `name` tinyint NOT NULL,
- `typeFk` tinyint NOT NULL,
- `classRate` tinyint NOT NULL,
- `tax` tinyint NOT NULL,
- `isRenewable` tinyint NOT NULL,
- `code` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Table structure for table `confectionType`
--
@@ -29495,16 +25494,16 @@ CREATE TABLE `config` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ochoa` int(10) unsigned NOT NULL,
`invoiceOutFk` int(11) DEFAULT '0',
- `bookFk` int(11) DEFAULT '0',
- `serialAFk` int(11) DEFAULT '0',
- `serialEFk` int(11) DEFAULT '0',
- `serialRFk` int(11) DEFAULT '0',
- `serialCFk` int(11) DEFAULT '0',
- `serialHFk` int(11) NOT NULL,
- `serialPFk` int(11) DEFAULT '0',
- `serialTFk` int(11) DEFAULT '0',
+ `bookFk__` int(11) DEFAULT '0',
+ `serialAFk__` int(11) DEFAULT '0',
+ `serialEFk__` int(11) DEFAULT '0',
+ `serialRFk__` int(11) DEFAULT '0',
+ `serialCFk__` int(11) DEFAULT '0',
+ `serialHFk__` int(11) NOT NULL,
+ `serialPFk__` int(11) DEFAULT '0',
+ `serialTFk__` int(11) DEFAULT '0',
`inventoried` datetime DEFAULT NULL,
- `serialMFk` int(11) DEFAULT '0',
+ `serialMFk__` int(11) DEFAULT '0',
`itemLog` int(11) DEFAULT '0',
`weekGoal` int(11) DEFAULT NULL,
`photosPath` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
@@ -29760,7 +25759,10 @@ CREATE TABLE `country` (
KEY `currency_id_fk_idx` (`currencyFk`),
KEY `country_Ix4` (`country`),
KEY `continent_id_fk_idx` (`continentFk`),
+ KEY `country_FK_1` (`geoFk`),
CONSTRAINT `continent_id_fk` FOREIGN KEY (`continentFk`) REFERENCES `continent` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE,
+ CONSTRAINT `country_FK` FOREIGN KEY (`politicalCountryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `country_FK_1` FOREIGN KEY (`geoFk`) REFERENCES `zoneGeo` (`id`) ON UPDATE CASCADE,
CONSTRAINT `currency_id_fk` FOREIGN KEY (`currencyFk`) REFERENCES `currency` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -30271,7 +26273,7 @@ CREATE TABLE `department` (
`isSelected` tinyint(1) NOT NULL DEFAULT '0',
`depth` int(11) NOT NULL DEFAULT '0',
`sons` decimal(10,0) NOT NULL DEFAULT '0',
- `parentFk` int(10) unsigned DEFAULT '1',
+ `parentFk` int(11) DEFAULT '1',
`path` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`chatName` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
`isTeleworking` tinyint(1) DEFAULT '0',
@@ -30287,7 +26289,9 @@ CREATE TABLE `department` (
KEY `dep_org_ibfk_3_idx` (`companyFk`),
KEY `lft_rgt_depth_idx` (`lft`,`rgt`,`depth`),
KEY `department_FK` (`clientFk`),
+ KEY `department_FK_1` (`parentFk`),
CONSTRAINT `department_FK` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `department_FK_1` FOREIGN KEY (`parentFk`) REFERENCES `department` (`id`),
CONSTRAINT `fk_department_Trabajadores1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -30441,11 +26445,13 @@ DROP TABLE IF EXISTS `deviceLog`;
CREATE TABLE `deviceLog` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`android_id` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
- `userFk` int(11) DEFAULT NULL,
+ `userFk` int(10) unsigned DEFAULT NULL,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`nameApp` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
`versionApp` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ KEY `deviceLog_FK` (`userFk`),
+ CONSTRAINT `deviceLog_FK` FOREIGN KEY (`userFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -30505,7 +26511,7 @@ DELIMITER ;;
FOR EACH ROW
BEGIN
IF NEW.isAllUsersAllowed = 1 OR NEW.isAllUsersAllowed = -1 THEN
- SET @username := (SELECT account.userGetName());
+ SET @username := (SELECT account.myUser_getName());
INSERT INTO vn.mail (receiver, subject, body)
VALUES ('cau@verdnatura.es', 'Se ha activado la autenticación sin restricciones en la app',
CONCAT('El usuario ', @username,' ha habilitado la opción para que todos los usuarios puedan acceder a la app sin restricciones'));
@@ -30672,6 +26678,34 @@ DELIMITER ;
/*!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=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`dms_beforeDelete`
+ BEFORE DELETE ON `dms`
+ FOR EACH ROW
+BEGIN
+ DECLARE vCanNotBeDeleted INT;
+ SELECT COUNT(*) INTO vCanNotBeDeleted
+ FROM dmsType dt
+ WHERE NOT (code <=> 'trash')
+ AND dt.id = OLD.dmsTypeFk;
+
+ IF vCanNotBeDeleted THEN
+ CALL util.throw('A dms can not be deleted');
+ 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 */ ;
--
-- Table structure for table `dmsRecover`
@@ -30705,6 +26739,7 @@ CREATE TABLE `dmsType` (
`writeRoleFk` int(10) unsigned DEFAULT NULL,
`readRoleFk` int(10) unsigned DEFAULT NULL,
`code` varchar(45) COLLATE utf8_unicode_ci NOT NULL,
+ `monthToDelete` int(10) unsigned DEFAULT NULL COMMENT 'Meses en el pasado para ir borrando registros, dejar a null para no borrarlos nunca',
PRIMARY KEY (`id`),
KEY `readRoleFk` (`readRoleFk`),
KEY `writeRoleFk` (`writeRoleFk`),
@@ -31067,7 +27102,7 @@ CREATE TABLE `entry` (
`dated` datetime NOT NULL,
`ref` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`isBooked` tinyint(1) NOT NULL DEFAULT '0',
- `isInventory` tinyint(1) NOT NULL DEFAULT '0',
+ `isExcludedFromAvailable` tinyint(1) NOT NULL DEFAULT 0,
`notes` longtext COLLATE utf8_unicode_ci,
`isConfirmed` tinyint(1) NOT NULL DEFAULT '0',
`isOrdered` tinyint(1) NOT NULL DEFAULT '0',
@@ -31085,6 +27120,8 @@ CREATE TABLE `entry` (
`kop` int(11) DEFAULT NULL,
`sub` mediumint(8) unsigned DEFAULT NULL,
`pro` mediumint(8) unsigned DEFAULT NULL,
+ `invoiceAmount` decimal(10,2) DEFAULT NULL,
+ `buyerFk` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `Id_Proveedor` (`supplierFk`),
KEY `Fecha` (`dated`),
@@ -31092,7 +27129,9 @@ CREATE TABLE `entry` (
KEY `empresa_id` (`companyFk`),
KEY `gestdoc_id` (`gestDocFk`),
KEY `recibida_id` (`invoiceInFk`),
+ KEY `entry_FK` (`buyerFk`),
CONSTRAINT `Entradas_fk8` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
+ CONSTRAINT `entry_FK` FOREIGN KEY (`buyerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE,
CONSTRAINT `entry_ibfk_1` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE,
CONSTRAINT `entry_ibfk_6` FOREIGN KEY (`travelFk`) REFERENCES `travel` (`id`) ON UPDATE CASCADE,
CONSTRAINT `entry_ibfk_7` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE
@@ -31230,6 +27269,16 @@ BEGIN
CALL travel_requestRecalc(OLD.travelFk);
CALL travel_requestRecalc(NEW.travelFk);
END IF;
+
+ IF NOT (NEW.invoiceAmount <=> OLD.invoiceAmount) THEN
+ INSERT INTO vn.entryLog SET
+ `action` = 'update',
+ userFk = account.myUser_getId(),
+ originFk = NEW.id,
+ changedModel = 'Entry',
+ oldInstance = CONCAT('{"old invoiceAmount":', OLD.invoiceAmount, '}'),
+ newInstance = CONCAT('{"new invoiceAmount":', NEW.invoiceAmount, '}');
+ END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -31287,6 +27336,7 @@ DROP TABLE IF EXISTS `entryConfig`;
CREATE TABLE `entryConfig` (
`defaultEntry` int(11) NOT NULL,
`mailToNotify` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
+ `inventorySupplierFk` int(11) DEFAULT '4',
PRIMARY KEY (`defaultEntry`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -31665,17 +27715,18 @@ CREATE TABLE `expedition` (
`ticketFk` int(10) NOT NULL,
`isBox` int(11) DEFAULT '1' COMMENT 'Este campo realmente en un campo itemFk, haciendo referencia al artículo que nos va a facturar el proveedor de transporte.\nSe debería llamar freightItemFk',
`created` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
- `isRefund` bit(1) DEFAULT b'0',
- `isPickUp` bit(1) DEFAULT b'0',
+ `isRefund__` bit(1) DEFAULT b'0' COMMENT 'Deprecado 01/06/2022',
+ `isPickUp__` bit(1) DEFAULT b'0' COMMENT 'Deprecado 01/06/2022',
`itemFk` int(11) DEFAULT NULL COMMENT 'Este campo hace referencia al artículo que habria que facturar si las cajas no fueran incluidos.\\nSe debería llamar packageItemFk',
`counter` smallint(5) unsigned NOT NULL,
- `checked` tinyint(4) NOT NULL DEFAULT '0',
+ `checked__` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Deprecado 01/06/2022',
`workerFk` int(10) unsigned DEFAULT NULL,
`externalId` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
`packagingFk` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
`itemPackingTypeFk` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL,
`hostFk` varchar(6) COLLATE utf8_unicode_ci NOT NULL,
`stateTypeFk` int(11) DEFAULT NULL COMMENT 'Ultimo estado de la expedicion',
+ `hasNewRoute` bit(1) NOT NULL DEFAULT b'0',
PRIMARY KEY (`id`),
KEY `index1` (`agencyModeFk`),
KEY `index2` (`isBox`),
@@ -31803,7 +27854,8 @@ CREATE TABLE `expeditionBoxVol` (
`boxFk` int(11) NOT NULL,
`m3` double NOT NULL,
`ratio` double NOT NULL,
- PRIMARY KEY (`boxFk`)
+ PRIMARY KEY (`boxFk`),
+ CONSTRAINT `expeditionBoxVol_FK` FOREIGN KEY (`boxFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Establece el volumen de cada servicio para poder comparar el teorico y el real en el control de portes';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -31876,6 +27928,37 @@ DELIMITER ;
/*!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=`root`@`localhost`*/ /*!50003 TRIGGER vn.expeditionPallet_beforeDelete
+BEFORE DELETE
+ON expeditionPallet FOR EACH ROW
+BEGIN
+ DECLARE vIndex INT DEFAULT INSTR(USER(), '@');
+
+ CALL util.debugAdd('expeditionPallet_deleted', CONCAT(OLD.id,' ', vn.getWorkerCode()));
+
+ INSERT INTO util.debug(connectionId, `user`, host, variable, value)
+ SELECT CONNECTION_ID(),
+ LEFT(USER(), vIndex - 1),
+ RIGHT(USER(), CHAR_LENGTH(USER()) - vIndex),
+ 'expeditionScan_deleted',
+ es.id
+ FROM vn.expeditionScan es
+ WHERE es.palletFk = OLD.id;
+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 */ ;
--
-- Temporary table structure for view `expeditionPallet_Print`
@@ -31972,6 +28055,28 @@ BEGIN
SET NEW.workerFk = vn.getUser();
+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=`root`@`localhost`*/ /*!50003 TRIGGER vn.expeditionScan_afterDelete
+AFTER DELETE
+ON expeditionScan FOR EACH ROW
+BEGIN
+
+ CALL util.debugAdd('expeditionScan_deleted', CONCAT(OLD.id,' ', vn.getWorkerCode()));
+
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -32108,31 +28213,6 @@ SET character_set_client = utf8;
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
---
--- Temporary table structure for view `expeditionSticker__`
---
-
-DROP TABLE IF EXISTS `expeditionSticker__`;
-/*!50001 DROP VIEW IF EXISTS `expeditionSticker__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `expeditionSticker__` (
- `expeditionFk` tinyint NOT NULL,
- `ticketFk` tinyint NOT NULL,
- `addressFk` tinyint NOT NULL,
- `clientFk` tinyint NOT NULL,
- `street` tinyint NOT NULL,
- `postalCode` tinyint NOT NULL,
- `city` tinyint NOT NULL,
- `nickname` tinyint NOT NULL,
- `routeFk` tinyint NOT NULL,
- `beachFk` tinyint NOT NULL,
- `zona` tinyint NOT NULL,
- `province` tinyint NOT NULL,
- `phone` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Temporary table structure for view `expeditionTicket_NoBoxes`
--
@@ -32565,7 +28645,7 @@ DELIMITER ;;
BEFORE UPDATE ON `greuge`
FOR EACH ROW
BEGIN
- DECLARE vMaxDate DATETIME DEFAULT TIMESTAMPADD(YEAR,1,CURDATE());
+ DECLARE vMaxDate DATETIME DEFAULT TIMESTAMPADD(YEAR,1,util.VN_CURDATE());
IF NEW.shipped > vMaxDate THEN
SET NEW.shipped = vMaxDate;
@@ -32606,65 +28686,6 @@ CREATE TABLE `greugeType` (
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Temporary table structure for view `holidayDetail__`
---
-
-DROP TABLE IF EXISTS `holidayDetail__`;
-/*!50001 DROP VIEW IF EXISTS `holidayDetail__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `holidayDetail__` (
- `id` tinyint NOT NULL,
- `description` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
---
--- Temporary table structure for view `holidayLegend__`
---
-
-DROP TABLE IF EXISTS `holidayLegend__`;
-/*!50001 DROP VIEW IF EXISTS `holidayLegend__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `holidayLegend__` (
- `id` tinyint NOT NULL,
- `description` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
---
--- Temporary table structure for view `holidayType__`
---
-
-DROP TABLE IF EXISTS `holidayType__`;
-/*!50001 DROP VIEW IF EXISTS `holidayType__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `holidayType__` (
- `id` tinyint NOT NULL,
- `name` tinyint NOT NULL,
- `rgb` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
---
--- Temporary table structure for view `holiday__`
---
-
-DROP TABLE IF EXISTS `holiday__`;
-/*!50001 DROP VIEW IF EXISTS `holiday__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `holiday__` (
- `holidayDetailFk` tinyint NOT NULL,
- `holidayTypeFk` tinyint NOT NULL,
- `workCenterFk` tinyint NOT NULL,
- `dated` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Table structure for table `host`
--
@@ -32716,7 +28737,7 @@ DELIMITER ;;
BEFORE UPDATE ON `host`
FOR EACH ROW
BEGIN
- SET new.updated = NOW();
+ SET new.updated = util.VN_NOW();
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -32772,7 +28793,8 @@ CREATE TABLE `inkI18n` (
`inkFk` char(3) COLLATE utf8_unicode_ci NOT NULL,
`lang` char(2) CHARACTER SET utf8 NOT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
- PRIMARY KEY (`inkFk`,`lang`)
+ PRIMARY KEY (`inkFk`,`lang`),
+ CONSTRAINT `inkI18n_FK` FOREIGN KEY (`inkFk`) REFERENCES `ink` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -33119,21 +29141,6 @@ DELIMITER ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
---
--- Temporary table structure for view `invoiceInAwb__`
---
-
-DROP TABLE IF EXISTS `invoiceInAwb__`;
-/*!50001 DROP VIEW IF EXISTS `invoiceInAwb__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `invoiceInAwb__` (
- `invoiceInFk` tinyint NOT NULL,
- `awbFk` tinyint NOT NULL,
- `dua` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Table structure for table `invoiceInDueDay`
--
@@ -33177,14 +29184,14 @@ BEGIN
JOIN vn.payMethod pm ON pm.id = s.payMethodFk
WHERE ii.id = NEW.invoiceInFk;
- IF (NEW.dueDated <= CURDATE() AND vIsNotified)
+ IF (NEW.dueDated <= util.VN_CURDATE() AND vIsNotified)
THEN
CALL mail_insert(
'begonya@verdnatura.es',
'begonya@verdnatura.es',
'Añadido vencimiento en el pasado',
CONCAT(
- account.myUserGetName(), ' ha añadido un vencimiento de ',
+ account.myUser_getName(), ' ha añadido un vencimiento de ',
NEW.amount, '€ en una fecha pasada en la recibida ', NEW.invoiceInFk
)
);
@@ -33217,14 +29224,14 @@ BEGIN
JOIN vn.payMethod pm ON pm.id = s.payMethodFk
WHERE ii.id = NEW.invoiceInFk;
- IF (NEW.dueDated <= CURDATE() AND vIsNotified)
+ IF (NEW.dueDated <= util.VN_CURDATE() AND vIsNotified)
THEN
CALL mail_insert(
'begonya@verdnatura.es',
'begonya@verdnatura.es',
'Añadido vencimiento en el pasado',
CONCAT(
- account.myUserGetName(), ' ha añadido un vencimiento de ',
+ account.myUser_getName(), ' ha añadido un vencimiento de ',
NEW.amount,'€ en una fecha pasada en la recibida ',NEW.invoiceInFk
)
);
@@ -33237,25 +29244,6 @@ DELIMITER ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
---
--- Temporary table structure for view `invoiceInDueDay__`
---
-
-DROP TABLE IF EXISTS `invoiceInDueDay__`;
-/*!50001 DROP VIEW IF EXISTS `invoiceInDueDay__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `invoiceInDueDay__` (
- `id` tinyint NOT NULL,
- `invoiceInFk` tinyint NOT NULL,
- `dueDated` tinyint NOT NULL,
- `bankFk` tinyint NOT NULL,
- `amount` tinyint NOT NULL,
- `foreignValue` tinyint NOT NULL,
- `created` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Table structure for table `invoiceInIntrastat`
--
@@ -33281,27 +29269,6 @@ CREATE TABLE `invoiceInIntrastat` (
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Temporary table structure for view `invoiceInIntrastat2__`
---
-
-DROP TABLE IF EXISTS `invoiceInIntrastat2__`;
-/*!50001 DROP VIEW IF EXISTS `invoiceInIntrastat2__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `invoiceInIntrastat2__` (
- `id` tinyint NOT NULL,
- `invoiceInFk` tinyint NOT NULL,
- `net` tinyint NOT NULL,
- `intrastatFk` tinyint NOT NULL,
- `amount` tinyint NOT NULL,
- `stems` tinyint NOT NULL,
- `countryFk` tinyint NOT NULL,
- `dated` tinyint NOT NULL,
- `statisticalValue` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Table structure for table `invoiceInIntrastat__`
--
@@ -33457,39 +29424,6 @@ CREATE TABLE `invoiceInTaxBookingAccount` (
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Temporary table structure for view `invoiceIn__`
---
-
-DROP TABLE IF EXISTS `invoiceIn__`;
-/*!50001 DROP VIEW IF EXISTS `invoiceIn__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `invoiceIn__` (
- `id` tinyint NOT NULL,
- `serialNumber` tinyint NOT NULL,
- `serial` tinyint NOT NULL,
- `supplierFk` tinyint NOT NULL,
- `issued` tinyint NOT NULL,
- `supplierRef` tinyint NOT NULL,
- `isBooked` tinyint NOT NULL,
- `currencyFk` tinyint NOT NULL,
- `created` tinyint NOT NULL,
- `companyFk` tinyint NOT NULL,
- `docFk` tinyint NOT NULL,
- `booked` tinyint NOT NULL,
- `operated` tinyint NOT NULL,
- `cplusInvoiceType472Fk` tinyint NOT NULL,
- `cplusRectificationTypeFk` tinyint NOT NULL,
- `cplusSubjectOpFk` tinyint NOT NULL,
- `cplusTaxBreakFk` tinyint NOT NULL,
- `cplusTrascendency472Fk` tinyint NOT NULL,
- `bookEntried` tinyint NOT NULL,
- `isVatDeductible` tinyint NOT NULL,
- `withholdingSageFk` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Table structure for table `invoiceOut`
--
@@ -33563,7 +29497,7 @@ BEGIN
SELECT CONCAT(NEW.serial,
IFNULL(RIGHT(MAX(i.ref), LENGTH(i.ref)-1) ,
- RPAD(CONCAT(c.sage200Company, RIGHT(YEAR(CURDATE()), 2)), 7,'0')) + 1) INTO vRef
+ RPAD(CONCAT(c.sage200Company, RIGHT(YEAR(util.VN_CURDATE()), 2)), 7,'0')) + 1) INTO vRef
FROM invoiceOut i
LEFT JOIN company c ON c.id = i.companyFk
WHERE i.serial = NEW.serial
@@ -33573,7 +29507,7 @@ BEGIN
SELECT CONCAT(NEW.serial,
IFNULL(RIGHT(MAX(i.ref), LENGTH(i.ref)-1) ,
- RPAD(CONCAT(c.sage200Company, RIGHT(YEAR(CURDATE()), 2)), 8,'0')) + 1) INTO vRef
+ RPAD(CONCAT(c.sage200Company, RIGHT(YEAR(util.VN_CURDATE()), 2)), 8,'0')) + 1) INTO vRef
FROM invoiceOut i
LEFT JOIN company c ON c.id = i.companyFk
WHERE i.serial = NEW.serial
@@ -33753,6 +29687,23 @@ CREATE TABLE `invoiceOutTaxConfig` (
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `invoiceOut_queue`
+--
+
+DROP TABLE IF EXISTS `invoiceOut_queue`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `invoiceOut_queue` (
+ `invoiceFk` int(10) unsigned NOT NULL,
+ `queued` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ `printed` datetime DEFAULT NULL,
+ `status` varchar(50) COLLATE utf8_unicode_ci DEFAULT '',
+ PRIMARY KEY (`invoiceFk`),
+ CONSTRAINT `invoiceOut_queue_invoiceOut_id_fk` FOREIGN KEY (`invoiceFk`) REFERENCES `invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Queue for PDF invoicing';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `item`
--
@@ -33806,12 +29757,12 @@ CREATE TABLE `item` (
`value9` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`tag10` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
`value10` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
- `compression` decimal(5,2) NOT NULL DEFAULT '1.00' COMMENT 'Relacion de compresividad entre el volumen de las entradas en Silla y el empaquetado en los envios a clientes.\n\nMenor que 1 significa que se puede comprimir más que el volumen original.',
+ `compression__` decimal(5,2) NOT NULL DEFAULT '1.00' COMMENT 'Relacion de compresividad entre el volumen de las entradas en Silla y el empaquetado en los envios a clientes.',
`minimum` decimal(10,0) unsigned NOT NULL DEFAULT '3' COMMENT 'Cantidad máxima de cajas / cubos que cabe en un nicho',
`upToDown` decimal(10,0) unsigned NOT NULL DEFAULT '0' COMMENT 'Se muestra el precio por kilo ',
`supplyResponseFk` int(11) DEFAULT NULL,
`hasKgPrice` tinyint(1) NOT NULL DEFAULT '0',
- `sectorFk` int(11) DEFAULT NULL,
+ `sectorFk__` int(11) DEFAULT NULL,
`isFloramondo` tinyint(1) NOT NULL DEFAULT '0',
`isFragile` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'articulos solo para recogidas por su fragilidad',
`numberOfItemsPerCask` int(11) DEFAULT NULL COMMENT 'Campo para Floramondo',
@@ -33823,6 +29774,8 @@ CREATE TABLE `item` (
`packingOut` decimal(10,2) DEFAULT NULL COMMENT 'cantidad que cabe en una caja de verdnatura',
`genericFk` int(11) DEFAULT NULL COMMENT 'Item genérico',
`packingShelve` int(11) DEFAULT NULL COMMENT 'unidades que caben en una bandeja, en el caso de los sacadores',
+ `isLaid` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Indica si el producto se puede tumbar a efectos del transporte desde Holanda',
+ `lastUsed` datetime DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `item_supplyResponseFk_idx` (`supplyResponseFk`),
KEY `Color` (`inkFk`),
@@ -33832,7 +29785,7 @@ CREATE TABLE `item` (
KEY `tipo_id` (`typeFk`),
KEY `producer_id` (`producerFk`),
KEY `ArticlesIsActive_idx` (`isActive`),
- KEY `item_ibfk_6_idx` (`sectorFk`),
+ KEY `item_ibfk_6_idx` (`sectorFk__`),
KEY `item_expenceFk` (`expenceFk`),
KEY `Article` (`name`,`subName`,`value5`,`value6`,`value7`,`value8`,`value9`,`value10`),
KEY `item_id10` (`embalageCode`),
@@ -33842,6 +29795,7 @@ CREATE TABLE `item` (
KEY `item_FK` (`genericFk`),
KEY `item_size_IDX` (`size`) USING BTREE,
KEY `item_size_IDX2` (`longName`) USING BTREE,
+ KEY `item_lastUsed_IDX` (`lastUsed`) USING BTREE,
CONSTRAINT `item_FK` FOREIGN KEY (`genericFk`) REFERENCES `item` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `item_expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `expence` (`id`) ON UPDATE CASCADE,
CONSTRAINT `item_family` FOREIGN KEY (`family`) REFERENCES `itemFamily` (`code`) ON UPDATE CASCADE,
@@ -33849,7 +29803,6 @@ CREATE TABLE `item` (
CONSTRAINT `item_ibfk_2` FOREIGN KEY (`intrastatFk`) REFERENCES `intrastat` (`id`) ON UPDATE CASCADE,
CONSTRAINT `item_ibfk_4` FOREIGN KEY (`taxClassFk__`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE,
CONSTRAINT `item_ibfk_5` FOREIGN KEY (`typeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `item_ibfk_6` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `itemsupplyResponseFk` FOREIGN KEY (`supplyResponseFk`) REFERENCES `edi`.`supplyResponse` (`ID`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `producer_id` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
@@ -33868,32 +29821,24 @@ DELIMITER ;;
FOR EACH ROW
BEGIN
DECLARE vDensity DOUBLE;
- DECLARE vCompression DOUBLE;
DECLARE vItemPackingType VARCHAR(1);
IF NEW.density IS NULL THEN
SELECT density INTO vDensity
FROM itemType WHERE id = NEW.typeFk;
-
+
SET NEW.density = vDensity;
END IF;
-
- IF NEW.compression IS NULL OR NEW.compression = 1 THEN
- SELECT compression INTO vCompression
- FROM itemType WHERE id = NEW.typeFk;
-
- SET NEW.compression = vCompression;
+
+ IF NEW.itemPackingTypeFk IS NULL THEN
+
+ SELECT itemPackingTypeFk INTO vItemPackingType
+ FROM vn.itemType it
+ WHERE id = NEW.typeFk;
+
+ SET NEW.itemPackingTypeFk = vItemPackingType;
+
END IF;
-
- IF NEW.itemPackingTypeFk IS NULL THEN
-
- SELECT itemPackingTypeFk INTO vItemPackingType
- FROM vn.itemType it
- WHERE id = NEW.typeFk;
-
- SET NEW.itemPackingTypeFk = vItemPackingType;
-
- END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -34155,6 +30100,38 @@ SET character_set_client = utf8;
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
+--
+-- Table structure for table `itemCleanConfig`
+--
+
+DROP TABLE IF EXISTS `itemCleanConfig`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `itemCleanConfig` (
+ `id` int(11) NOT NULL,
+ `step` int(11) NOT NULL COMMENT 'Indica los items que procesa en cada ciclo',
+ `quantity` int(11) NOT NULL COMMENT 'Indica el número de items que va a procesar',
+ `isStop` tinyint(1) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `itemCleanCount`
+--
+
+DROP TABLE IF EXISTS `itemCleanCount`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `itemCleanCount` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `itemFrom` int(11) DEFAULT NULL COMMENT 'Indica el item por donde ha empezado',
+ `itemDeleted` int(11) DEFAULT NULL COMMENT 'Indica la cantidad de items que ha eliminado',
+ `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Temporary table structure for view `itemColor`
--
@@ -34177,7 +30154,8 @@ DROP TABLE IF EXISTS `itemConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `itemConfig` (
- `isItemTagTriggerDisabled` tinyint(1) NOT NULL DEFAULT '1'
+ `isItemTagTriggerDisabled` tinyint(1) NOT NULL DEFAULT '1',
+ `monthToDeactivate` int(3) NOT NULL DEFAULT '24'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -34272,7 +30250,7 @@ BEGIN
JOIN vn.route r ON r.id = t.routeFk
WHERE r.isOk = FALSE
AND ic.itemFk = NEW.itemFk
- AND r.created >= CURDATE()
+ AND r.created >= util.VN_CURDATE()
GROUP BY r.id;
IF NEW.cm3Delivery = 0 AND NEW.warehouseFk = 60 THEN
CALL mail_insert(
@@ -34450,77 +30428,6 @@ CREATE TABLE `itemPackingType` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Define la linea de encajado para cada producto';
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Table structure for table `itemPlacement`
---
-
-DROP TABLE IF EXISTS `itemPlacement`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `itemPlacement` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `itemFk` int(11) NOT NULL,
- `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '1',
- `code` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
- `modificationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
- `reserve` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
- `pickable` int(11) unsigned NOT NULL DEFAULT '0',
- `sectorFk` int(11) DEFAULT NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY `Id_Article_UNIQUE` (`itemFk`,`warehouseFk`),
- KEY `Articles_nicho_wh_fk` (`warehouseFk`),
- KEY `itemPlacement_fk3_idx` (`id`,`sectorFk`),
- KEY `itemPlacement_fk3_idx1` (`sectorFk`),
- CONSTRAINT `Articles_nicho_wh_fk` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `Articles_nichos_fk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `itemPlacement_fk3` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
-) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-/*!40101 SET character_set_client = @saved_cs_client */;
-/*!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=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemPlacement_BEFORE_INSERT`
- BEFORE INSERT ON `itemPlacement`
- FOR EACH ROW
-BEGIN
- IF LENGTH(NEW.code) < 3 THEN
- CALL util.throw('code too short');
- 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=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemPlacement_BEFORE_UPDATE`
- BEFORE UPDATE ON `itemPlacement`
- FOR EACH ROW
-BEGIN
- IF LENGTH(NEW.code) < 3 THEN
- CALL util.throw('code too short');
- 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 */ ;
-
--
-- Table structure for table `itemPlacementSupply`
--
@@ -34575,6 +30482,75 @@ SET character_set_client = utf8;
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
+--
+-- Table structure for table `itemPlacement__`
+--
+
+DROP TABLE IF EXISTS `itemPlacement__`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `itemPlacement__` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `itemFk` int(11) NOT NULL,
+ `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '1',
+ `code` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
+ `modificationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ `reserve` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
+ `pickable` int(11) unsigned NOT NULL DEFAULT '0',
+ `sectorFk` int(11) DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `Id_Article_UNIQUE` (`itemFk`,`warehouseFk`),
+ KEY `Articles_nicho_wh_fk` (`warehouseFk`),
+ KEY `itemPlacement_fk3_idx` (`id`,`sectorFk`),
+ KEY `itemPlacement_fk3_idx1` (`sectorFk`),
+ CONSTRAINT `Articles_nicho_wh_fk` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `Articles_nichos_fk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `itemPlacement_fk3` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
+) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+/*!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=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemPlacement_BEFORE_INSERT`
+ BEFORE INSERT ON `itemPlacement__` FOR EACH ROW
+BEGIN
+ IF LENGTH(NEW.code) < 3 THEN
+ CALL util.throw('code too short');
+ 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=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemPlacement_BEFORE_UPDATE`
+ BEFORE UPDATE ON `itemPlacement__` FOR EACH ROW
+BEGIN
+ IF LENGTH(NEW.code) < 3 THEN
+ CALL util.throw('code too short');
+ 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 */ ;
+
--
-- Temporary table structure for view `itemProductor`
--
@@ -34687,7 +30663,7 @@ DELIMITER ;;
FOR EACH ROW
BEGIN
- SET NEW.userFk = account.userGetId();
+ SET NEW.userFk = account.myUser_getId();
END */;;
@@ -34745,7 +30721,7 @@ DELIMITER ;;
BEFORE UPDATE ON `itemShelving`
FOR EACH ROW
BEGIN
- SET NEW.userFk = account.userGetId();
+ SET NEW.userFk = account.myUser_getId();
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -34774,7 +30750,7 @@ INSERT INTO vn.itemShelvingLog( itemShelvingFk,
packing,
stars)
VALUES( NEW.id,
- account.userGetId(),
+ account.myUser_getId(),
'CAMBIO',
NEW.itemFk,
NEW.shelvingFk,
@@ -34806,7 +30782,7 @@ INSERT INTO vn.itemShelvingLog(itemShelvingFk,
shelvingFk,
itemFk)
VALUES( OLD.id,
- account.userGetId(),
+ account.myUser_getId(),
'ELIMINADO',
OLD.shelvingFk,
OLD.itemFk) */;;
@@ -34920,7 +30896,7 @@ CREATE TABLE `itemShelvingPlacementSupply` (
KEY `itemShelvingPlacementSupply_fk3_idx` (`userFk`),
CONSTRAINT `itemShelvingPlacementSupply_fk1` FOREIGN KEY (`itemShelvingFk`) REFERENCES `itemShelving` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `itemShelvingPlacementSupply_fk2` FOREIGN KEY (`itemPlacementSupplyFk`) REFERENCES `itemPlacementSupply` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de los itemShelving afectados por las ordenes de reposicion de nicho';
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de los itemShelving afectados por las ordenes de reposicion de nicho';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -35112,6 +31088,7 @@ CREATE TABLE `itemTag` (
`priority` int(2) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `itemTagItemUq` (`itemFk`,`tagFk`),
+ UNIQUE KEY `itemTagItemPriority` (`itemFk`,`priority`),
KEY `tagFk` (`tagFk`,`value`),
KEY `priorityItem` (`priority`,`itemFk`),
KEY `value` (`value`),
@@ -35338,14 +31315,14 @@ CREATE TABLE `itemType` (
`id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`code` varchar(3) COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
- `gramsMin` int(11) DEFAULT NULL,
+ `gramsMin__` int(11) DEFAULT NULL,
`gramsMax` int(11) DEFAULT NULL,
`order` int(11) DEFAULT '0',
`categoryFk` int(10) unsigned NOT NULL,
`workerFk` int(10) unsigned NOT NULL,
`isInventory` tinyint(4) NOT NULL DEFAULT '1' COMMENT 'Se utiliza tanto en el cálculo del inventario, como en el del informe del inventario valorado',
`created` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
- `f11` tinyint(4) NOT NULL DEFAULT '0',
+ `f11__` tinyint(4) NOT NULL DEFAULT '0',
`transaction` tinyint(4) NOT NULL DEFAULT '0',
`making` int(10) unsigned DEFAULT NULL COMMENT 'Son productos de confección propia',
`location` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
@@ -35363,6 +31340,8 @@ CREATE TABLE `itemType` (
`itemPackingTypeFk` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL,
`temperatureFk` varchar(10) CHARACTER SET utf8 DEFAULT NULL,
`isUnconventionalSize` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'familia con productos cuyas medidas no son aptas para la cinta transportadora o paletizar',
+ `isLaid` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Indica si el producto se puede tumbar a efectos del transporte desde Holanda',
+ `maxRefs` int(10) unsigned DEFAULT NULL COMMENT 'Indica el número máximo de referencias',
PRIMARY KEY (`code`),
UNIQUE KEY `tipo_id_UNIQUE` (`id`),
UNIQUE KEY `Tipo_UNIQUE` (`name`,`categoryFk`),
@@ -35538,20 +31517,6 @@ SET character_set_client = utf8;
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
---
--- Table structure for table `labelReport`
---
-
-DROP TABLE IF EXISTS `labelReport`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `labelReport` (
- `id` tinyint(3) unsigned NOT NULL,
- `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
- PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
--
-- Table structure for table `labourTree`
--
@@ -35810,12 +31775,16 @@ CREATE TABLE `mail` (
`creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`attachment` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`status` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'OK',
- `senderFk` int(11) DEFAULT NULL,
- `recipientFk` int(11) DEFAULT NULL,
+ `senderFk` int(10) unsigned DEFAULT NULL,
+ `recipientFk` int(10) unsigned DEFAULT NULL,
`plainTextBody` text COLLATE utf8_unicode_ci,
PRIMARY KEY (`id`),
KEY `sent_idx` (`sent`),
- KEY `creation_idx` (`creationDate`)
+ KEY `creation_idx` (`creationDate`),
+ KEY `mail_FK_1` (`recipientFk`),
+ KEY `mail_FK` (`senderFk`),
+ CONSTRAINT `mail_FK` FOREIGN KEY (`senderFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `mail_FK_1` FOREIGN KEY (`recipientFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
@@ -35940,6 +31909,35 @@ CREATE TABLE `manuscript` (
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `mdbBranch`
+--
+
+DROP TABLE IF EXISTS `mdbBranch`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `mdbBranch` (
+ `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
+ PRIMARY KEY (`name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `mdbVersion`
+--
+
+DROP TABLE IF EXISTS `mdbVersion`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `mdbVersion` (
+ `app` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
+ `branchFk` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
+ `version` int(11) DEFAULT NULL,
+ KEY `mdbVersion_branchFk` (`branchFk`),
+ CONSTRAINT `mdbVersion_branchFk` FOREIGN KEY (`branchFk`) REFERENCES `mdbBranch` (`name`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `medicalCenter`
--
@@ -36087,7 +32085,11 @@ CREATE TABLE `mobileAppVersionControl` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`appName` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
`version` varchar(45) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0',
- `IsVersionCritical` tinyint(1) DEFAULT '0',
+ `isVersionCritical` tinyint(1) DEFAULT '0',
+ `urlProduction` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
+ `urlBeta` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
+ `versionBeta` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
+ `isVersionBetaCritical` tinyint(1) DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tabla para llevar el control de las Versions de las aplicaciones móvil ';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -36106,7 +32108,7 @@ CREATE TABLE `mrw` (
`shipped` date DEFAULT NULL,
`price` decimal(10,2) DEFAULT NULL,
PRIMARY KEY (`id`)
-) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -36126,23 +32128,6 @@ SET character_set_client = utf8;
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
---
--- Temporary table structure for view `newBornSales__`
---
-
-DROP TABLE IF EXISTS `newBornSales__`;
-/*!50001 DROP VIEW IF EXISTS `newBornSales__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `newBornSales__` (
- `amount` tinyint NOT NULL,
- `clientFk` tinyint NOT NULL,
- `userFk` tinyint NOT NULL,
- `dated` tinyint NOT NULL,
- `firstShipped` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Table structure for table `noticeCategory`
--
@@ -36239,8 +32224,8 @@ CREATE TABLE `origin` (
`code` varchar(3) COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`warehouseFk` smallint(5) unsigned DEFAULT '4',
- `flag` blob,
- `nl` tinyint(4) NOT NULL DEFAULT '0',
+ `flag__` blob,
+ `nl__` tinyint(4) NOT NULL DEFAULT '0',
`countryFk` mediumint(8) unsigned NOT NULL DEFAULT '1',
PRIMARY KEY (`id`),
UNIQUE KEY `Abreviatura` (`code`),
@@ -36377,7 +32362,9 @@ CREATE TABLE `packaging` (
KEY `packaging_fk1` (`itemFk`),
KEY `packaging_fk2_idx` (`freightItemFk`),
KEY `packaging_FK` (`conveyorBuildingClassFk`),
+ KEY `packaging_FK_1` (`packagingReturnFk`),
CONSTRAINT `packaging_FK` FOREIGN KEY (`conveyorBuildingClassFk`) REFERENCES `conveyorBuildingClass` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
+ CONSTRAINT `packaging_FK_1` FOREIGN KEY (`packagingReturnFk`) REFERENCES `vn2008`.`Cubos_Retorno` (`idCubos_Retorno`) ON UPDATE CASCADE,
CONSTRAINT `packaging_fk1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE,
CONSTRAINT `packaging_fk2` FOREIGN KEY (`freightItemFk`) REFERENCES `item` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
@@ -36582,20 +32569,6 @@ CREATE TABLE `payDemDetail` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Temporary table structure for view `payDemDetail__`
---
-
-DROP TABLE IF EXISTS `payDemDetail__`;
-/*!50001 DROP VIEW IF EXISTS `payDemDetail__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `payDemDetail__` (
- `id` tinyint NOT NULL,
- `detail` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Table structure for table `payMethod`
--
@@ -36640,7 +32613,7 @@ CREATE TABLE `payment` (
`companyFk` smallint(5) unsigned NOT NULL DEFAULT '442',
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`isConciliated` tinyint(1) unsigned zerofill NOT NULL DEFAULT '0',
- `exchangeInsuranceFk` int(11) DEFAULT NULL,
+ `exchangeInsuranceFk__` int(11) DEFAULT NULL,
`dueDated` date DEFAULT NULL,
`workerFk` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
@@ -36648,7 +32621,7 @@ CREATE TABLE `payment` (
KEY `id_banco` (`bankFk`),
KEY `id_moneda` (`currencyFk`),
KEY `pay_met` (`payMethodFk`),
- KEY `fk_pago_pago_sdc1_idx` (`exchangeInsuranceFk`),
+ KEY `fk_pago_pago_sdc1_idx` (`exchangeInsuranceFk__`),
KEY `pagoDueDatedIdx` (`dueDated`),
KEY `pago_ibfk_3` (`supplierFk`),
KEY `payment_FK` (`workerFk`),
@@ -36831,30 +32804,6 @@ DELIMITER ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
---
--- Temporary table structure for view `payment__`
---
-
-DROP TABLE IF EXISTS `payment__`;
-/*!50001 DROP VIEW IF EXISTS `payment__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `payment__` (
- `id` tinyint NOT NULL,
- `received` tinyint NOT NULL,
- `dueDated` tinyint NOT NULL,
- `supplierFk` tinyint NOT NULL,
- `amount` tinyint NOT NULL,
- `currencyFk` tinyint NOT NULL,
- `divisa` tinyint NOT NULL,
- `bankFk` tinyint NOT NULL,
- `payMethodFk` tinyint NOT NULL,
- `companyFk` tinyint NOT NULL,
- `exchangeInsuranceFk` tinyint NOT NULL,
- `isConciliated` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Table structure for table `pcs`
--
@@ -36936,7 +32885,7 @@ CREATE TABLE `person` (
`surnames` varchar(60) COLLATE utf8_unicode_ci NOT NULL,
`fi` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL,
`birth` date DEFAULT NULL,
- `readerId` int(11) DEFAULT NULL,
+ `readerId__` int(11) DEFAULT NULL,
`workerFk` int(10) unsigned DEFAULT NULL,
`isDisable` tinyint(1) NOT NULL DEFAULT '0',
`isFreelance` tinyint(1) NOT NULL DEFAULT '0',
@@ -36946,7 +32895,7 @@ CREATE TABLE `person` (
`sex` enum('M','F') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'F' COMMENT 'M Masculino F Femenino',
PRIMARY KEY (`id`),
UNIQUE KEY `nif` (`fi`),
- UNIQUE KEY `person_UN` (`readerId`),
+ UNIQUE KEY `person_UN` (`readerId__`),
KEY `nifIndex` (`fi`),
KEY `workerFk_idx` (`workerFk`),
CONSTRAINT `Person_ibfk_1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE
@@ -37022,6 +32971,22 @@ CREATE TABLE `pgcMaster` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='tan solo tiene las cuentas de contaplus';
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Temporary table structure for view `phoneBook`
+--
+
+DROP TABLE IF EXISTS `phoneBook`;
+/*!50001 DROP VIEW IF EXISTS `phoneBook`*/;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+/*!50001 CREATE TABLE `phoneBook` (
+ `Tipo` tinyint NOT NULL,
+ `Id` tinyint NOT NULL,
+ `Cliente` tinyint NOT NULL,
+ `Telefono` tinyint NOT NULL
+) ENGINE=MyISAM */;
+SET character_set_client = @saved_cs_client;
+
--
-- Table structure for table `plantpassport`
--
@@ -37365,6 +33330,67 @@ DELIMITER ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
+--
+-- Table structure for table `printQueue`
+--
+
+DROP TABLE IF EXISTS `printQueue`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `printQueue` (
+ `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `printerFk` tinyint(3) unsigned DEFAULT NULL,
+ `priorityFk` tinyint(3) unsigned NOT NULL DEFAULT '3' COMMENT '1 - high, 2 - normal, 3 - low',
+ `reportFk` tinyint(3) unsigned DEFAULT NULL,
+ `statusCode` enum('queued','error','printing') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'queued',
+ `started` datetime DEFAULT NULL,
+ `finished` datetime DEFAULT NULL,
+ `workerFk` int(11) DEFAULT NULL,
+ `error` text COLLATE utf8_unicode_ci,
+ `errorNumber` int(11) DEFAULT NULL,
+ `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (`id`),
+ KEY `statusCode` (`statusCode`),
+ KEY `printerFk` (`printerFk`),
+ KEY `priorityFk` (`priorityFk`),
+ KEY `workerFk` (`workerFk`),
+ KEY `printQueue_report` (`reportFk`),
+ CONSTRAINT `printQueue_printerFk` FOREIGN KEY (`printerFk`) REFERENCES `printer` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `printQueue_priorityFk` FOREIGN KEY (`priorityFk`) REFERENCES `queuePriority` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `printQueue_report` FOREIGN KEY (`reportFk`) REFERENCES `report` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `printQueueArgs`
+--
+
+DROP TABLE IF EXISTS `printQueueArgs`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `printQueueArgs` (
+ `printQueueFk` int(10) unsigned NOT NULL,
+ `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
+ `value` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
+ KEY `printQueueArgs_printQueueFk_idx` (`printQueueFk`),
+ CONSTRAINT `printQueueArgs_printQueueFk` FOREIGN KEY (`printQueueFk`) REFERENCES `printQueue` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Argumentos que se pasarán al informe para generarlos';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `printQueueConfig`
+--
+
+DROP TABLE IF EXISTS `printQueueConfig`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `printQueueConfig` (
+ `networkDrive` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'X:\\',
+ `dmsPath` varchar(45) COLLATE utf8_unicode_ci NOT NULL DEFAULT ' \\\\server\\dms',
+ `printQueueLimit` int(11) NOT NULL DEFAULT '30' COMMENT 'Número máximo de filas de la cola de impresión a mostrar al enviar correo a través del evento vn.printQueue_check'
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `printServerQueue`
--
@@ -37393,7 +33419,7 @@ CREATE TABLE `printServerQueue` (
KEY `Id_Prioridad` (`priorityFk`),
KEY `Id_Trabajador` (`workerFk`),
KEY `printServerQueue_FK` (`labelReportFk`),
- CONSTRAINT `printServerQueue_FK` FOREIGN KEY (`labelReportFk`) REFERENCES `labelReport` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `printServerQueue_FK` FOREIGN KEY (`labelReportFk`) REFERENCES `report` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `printServerQueue_ibfk_3` FOREIGN KEY (`priorityFk`) REFERENCES `queuePriority` (`id`) ON UPDATE CASCADE,
CONSTRAINT `printServerQueue_printerFk` FOREIGN KEY (`printerFk`) REFERENCES `printer` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
@@ -37425,7 +33451,38 @@ CREATE TABLE `printServerQueue2` (
KEY `Id_Impresora` (`printerFk`),
KEY `Id_Informe` (`reportFk`),
KEY `Id_Prioridad` (`priorityFk`),
- KEY `Id_Trabajador` (`workerFk`)
+ KEY `Id_Trabajador` (`workerFk`),
+ CONSTRAINT `printServerQueue2_FK_1` FOREIGN KEY (`printerFk`) REFERENCES `printer` (`id`),
+ CONSTRAINT `printServerQueue2_FK_2` FOREIGN KEY (`priorityFk`) REFERENCES `queuePriority` (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `printer`
+--
+
+DROP TABLE IF EXISTS `printer`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `printer` (
+ `id` tinyint(3) unsigned NOT NULL,
+ `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
+ `path` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
+ `modelFk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
+ `macWifi` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
+ `ipAddress` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL,
+ `reference` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
+ `isLabeler` tinyint(1) DEFAULT '0' COMMENT 'Indica si es impresora de etiquetas',
+ `sectorFk` int(11) DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `printer_UN` (`reference`),
+ UNIQUE KEY `printer_UN1` (`macWifi`),
+ UNIQUE KEY `printer_UN2` (`name`),
+ KEY `printer_FK` (`modelFk`),
+ KEY `printer_sectorFk_idx` (`id`,`sectorFk`),
+ KEY `printer_sectorFk` (`sectorFk`),
+ CONSTRAINT `printer_FK` FOREIGN KEY (`modelFk`) REFERENCES `printerModel` (`code`) ON UPDATE CASCADE,
+ CONSTRAINT `printer_sectorFk` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -37442,49 +33499,6 @@ CREATE TABLE `printerModel` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Temporary table structure for view `printer__`
---
-
-DROP TABLE IF EXISTS `printer__`;
-/*!50001 DROP VIEW IF EXISTS `printer__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `printer__` (
- `id` tinyint NOT NULL,
- `path` tinyint NOT NULL,
- `name` tinyint NOT NULL,
- `reference` tinyint NOT NULL,
- `isLabeler` tinyint NOT NULL,
- `description` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
---
--- Temporary table structure for view `printer`
---
-
-DROP TABLE IF EXISTS `printer`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `printer` (
- `id` tinyint(3) unsigned NOT NULL,
- `name` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
- `path` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
- `modelFk` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
- `macWifi` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
- `ipAddress` varchar(15) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
- `reference` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
- `isLabeler` tinyint(1) DEFAULT 0 COMMENT 'Indica si es impresora de etiquetas',
- PRIMARY KEY (`id`),
- UNIQUE KEY `printer_UN` (`reference`),
- UNIQUE KEY `printer_UN1` (`macWifi`),
- UNIQUE KEY `printer_UN2` (`name`),
- KEY `printer_FK` (`modelFk`),
- CONSTRAINT `printer_FK` FOREIGN KEY (`modelFk`) REFERENCES `printerModel` (`code`) ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
--
-- Table structure for table `printingQueueCheck`
--
@@ -37516,6 +33530,25 @@ CREATE TABLE `producer` (
UNIQUE KEY `name_UNIQUE` (`name`)
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+/*!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=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`producer_afterUpdate`
+ AFTER INSERT ON `producer` FOR EACH ROW
+BEGIN
+ CALL util.debugAdd('producer',CONCAT(NEW.name, NEW.id));
+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 */ ;
--
-- Table structure for table `productionConfig`
@@ -37751,7 +33784,7 @@ CREATE TABLE `propertyDms` (
PRIMARY KEY (`id`),
KEY `propertyDms_FK` (`dmsFk`),
KEY `propertyDms_FK_1` (`propertyFk`),
- CONSTRAINT `propertyDms_FK` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `propertyDms_FK` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `propertyDms_FK_1` FOREIGN KEY (`propertyFk`) REFERENCES `property` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -37942,6 +33975,7 @@ DROP TABLE IF EXISTS `queuePriority`;
CREATE TABLE `queuePriority` (
`id` tinyint(3) unsigned NOT NULL DEFAULT '0',
`priority` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
+ `code` varchar(6) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -37959,38 +33993,6 @@ CREATE TABLE `rankBonus` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Temporary table structure for view `rankingNewBornByQuarter__`
---
-
-DROP TABLE IF EXISTS `rankingNewBornByQuarter__`;
-/*!50001 DROP VIEW IF EXISTS `rankingNewBornByQuarter__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `rankingNewBornByQuarter__` (
- `total` tinyint NOT NULL,
- `name` tinyint NOT NULL,
- `time_sec` tinyint NOT NULL,
- `userFk` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
---
--- Temporary table structure for view `rankingSellingByQuarter__`
---
-
-DROP TABLE IF EXISTS `rankingSellingByQuarter__`;
-/*!50001 DROP VIEW IF EXISTS `rankingSellingByQuarter__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `rankingSellingByQuarter__` (
- `importe` tinyint NOT NULL,
- `name` tinyint NOT NULL,
- `userFk` tinyint NOT NULL,
- `time_sec` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Table structure for table `rate`
--
@@ -38029,25 +34031,6 @@ CREATE TABLE `rateConfig` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Temporary table structure for view `rate__`
---
-
-DROP TABLE IF EXISTS `rate__`;
-/*!50001 DROP VIEW IF EXISTS `rate__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `rate__` (
- `id` tinyint NOT NULL,
- `dated` tinyint NOT NULL,
- `warehouseFk` tinyint NOT NULL,
- `rate0` tinyint NOT NULL,
- `rate1` tinyint NOT NULL,
- `rate2` tinyint NOT NULL,
- `rate3` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Table structure for table `receipt`
--
@@ -38215,7 +34198,9 @@ CREATE TABLE `recipe` (
`inkFk` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `recipe_ix_1` (`element`),
- KEY `recipe_ix_2` (`itemFk`)
+ KEY `recipe_ix_2` (`itemFk`),
+ KEY `recipe_FK` (`inkFk`),
+ CONSTRAINT `recipe_FK` FOREIGN KEY (`inkFk`) REFERENCES `ink` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -38234,7 +34219,9 @@ CREATE TABLE `recipe_log` (
PRIMARY KEY (`id`),
KEY `recipe_log_ix1` (`recipe_ItemFk`),
KEY `recipe_log_ix2` (`element`),
- KEY `recipe_log_ix3` (`selected_ItemFk`)
+ KEY `recipe_log_ix3` (`selected_ItemFk`),
+ CONSTRAINT `recipe_log_FK` FOREIGN KEY (`recipe_ItemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `recipe_log_FK_1` FOREIGN KEY (`selected_ItemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena las decisiones tomadas al generar recetas';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -38305,6 +34292,20 @@ CREATE TABLE `referenceRateConfig` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `report`
+--
+
+DROP TABLE IF EXISTS `report`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `report` (
+ `id` tinyint(3) unsigned NOT NULL,
+ `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Temporary table structure for view `role`
--
@@ -38520,13 +34521,13 @@ CREATE TABLE `routeConfig` (
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `routeGate`
+-- Table structure for table `routeGate__`
--
-DROP TABLE IF EXISTS `routeGate`;
+DROP TABLE IF EXISTS `routeGate__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `routeGate` (
+CREATE TABLE `routeGate__` (
`deviceId` varchar(30) CHARACTER SET utf8 NOT NULL,
`displayText` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`status` set('idle','doing','done','') CHARACTER SET utf8 DEFAULT 'idle',
@@ -38555,8 +34556,7 @@ CREATE TABLE `routeGate` (
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`routeGateBeforeUpdate`
- BEFORE UPDATE ON `routeGate`
- FOR EACH ROW
+ BEFORE UPDATE ON `routeGate__` FOR EACH ROW
BEGIN
IF (NOT (NEW.expeditions <=> OLD.expeditions)
OR NOT (NEW.scanned <=> OLD.scanned))
@@ -38671,7 +34671,7 @@ CREATE TABLE `routesMonitor` (
`packages` int(11) DEFAULT NULL,
`note` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`dated` date DEFAULT NULL,
- `dockFk` int(11) DEFAULT NULL,
+ `dockFk` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
`m3` decimal(10,1) DEFAULT NULL,
`priority` int(11) NOT NULL DEFAULT '0',
`etd` time DEFAULT NULL,
@@ -38681,10 +34681,33 @@ CREATE TABLE `routesMonitor` (
`isPickingAllowed` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Los tickets de esta ruta se pueden preparar',
PRIMARY KEY (`routeFk`),
KEY `routesMonitor_FK` (`bufferFk`),
- CONSTRAINT `routesMonitor_FK` FOREIGN KEY (`bufferFk`) REFERENCES `srt`.`buffer` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
+ KEY `routesMonitor_FK_2` (`beachFk`),
+ KEY `routesMonitor_FK_1` (`dockFk`),
+ CONSTRAINT `routesMonitor_FK` FOREIGN KEY (`bufferFk`) REFERENCES `srt`.`buffer` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
+ CONSTRAINT `routesMonitor_FK_1` FOREIGN KEY (`dockFk`) REFERENCES `dock` (`code`) ON UPDATE CASCADE,
+ CONSTRAINT `routesMonitor_FK_2` FOREIGN KEY (`beachFk`) REFERENCES `beach` (`code`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Temporary table structure for view `routesReduced`
+--
+
+DROP TABLE IF EXISTS `routesReduced`;
+/*!50001 DROP VIEW IF EXISTS `routesReduced`*/;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+/*!50001 CREATE TABLE `routesReduced` (
+ `description` tinyint NOT NULL,
+ `name` tinyint NOT NULL,
+ `routeFk` tinyint NOT NULL,
+ `ETD` tinyint NOT NULL,
+ `bufferFk` tinyint NOT NULL,
+ `beachFk` tinyint NOT NULL,
+ `itempackingTypeFk` tinyint NOT NULL
+) ENGINE=MyISAM */;
+SET character_set_client = @saved_cs_client;
+
--
-- Table structure for table `sale`
--
@@ -38751,7 +34774,7 @@ BEGIN
JOIN vn.route r ON r.id = t.routeFk
WHERE r.isOk = FALSE
AND s.id = NEW.id
- AND r.created >= CURDATE()
+ AND r.created >= util.VN_CURDATE()
GROUP BY r.id;
END IF;
@@ -38878,7 +34901,7 @@ BEGIN
JOIN vn.route r ON r.id = t.routeFk
WHERE r.isOk = FALSE
AND s.id = NEW.id
- AND r.created >= CURDATE()
+ AND r.created >= util.VN_CURDATE()
GROUP BY r.id;
END IF;
@@ -38924,7 +34947,7 @@ BEGIN
JOIN vn.route r ON r.id = t.routeFk
WHERE r.isOk = FALSE
AND s.id = OLD.id
- AND r.created >= CURDATE()
+ AND r.created >= util.VN_CURDATE()
GROUP BY r.id;
END IF;
END */;;
@@ -39204,6 +35227,22 @@ CREATE TABLE `saleItemShelving__` (
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Temporary table structure for view `saleLabel`
+--
+
+DROP TABLE IF EXISTS `saleLabel`;
+/*!50001 DROP VIEW IF EXISTS `saleLabel`*/;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+/*!50001 CREATE TABLE `saleLabel` (
+ `saleFk` tinyint NOT NULL,
+ `label` tinyint NOT NULL,
+ `stem` tinyint NOT NULL,
+ `created` tinyint NOT NULL
+) ENGINE=MyISAM */;
+SET character_set_client = @saved_cs_client;
+
--
-- Table structure for table `saleMistake`
--
@@ -39246,24 +35285,6 @@ SET character_set_client = utf8;
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
---
--- Temporary table structure for view `saleMistake_list__`
---
-
-DROP TABLE IF EXISTS `saleMistake_list__`;
-/*!50001 DROP VIEW IF EXISTS `saleMistake_list__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `saleMistake_list__` (
- `saleFk` tinyint NOT NULL,
- `sacador` tinyint NOT NULL,
- `created` tinyint NOT NULL,
- `revisador` tinyint NOT NULL,
- `description` tinyint NOT NULL,
- `controlled` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Temporary table structure for view `saleMistake_list__2`
--
@@ -39347,7 +35368,7 @@ CREATE TABLE `saleTracking` (
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`originalQuantity` double DEFAULT NULL,
`workerFk` int(11) NOT NULL,
- `actionFk` int(11) NOT NULL,
+ `actionFk` int(11) DEFAULT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
`stateFk` tinyint(3) unsigned NOT NULL,
PRIMARY KEY (`id`),
@@ -39357,7 +35378,8 @@ CREATE TABLE `saleTracking` (
KEY `saleTracking_idx5` (`created`),
KEY `saleTracking_fk2_idx` (`actionFk`),
CONSTRAINT `fgnStateFk` FOREIGN KEY (`stateFk`) REFERENCES `state` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `saleTracking_FK` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+ CONSTRAINT `saleTracking_FK` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `saleTracking_FK_1` FOREIGN KEY (`actionFk`) REFERENCES `vncontrol`.`accion` (`accion_id`) ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
@@ -39569,39 +35591,6 @@ SET character_set_client = utf8;
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
---
--- Temporary table structure for view `salesToPrePrepare__`
---
-
-DROP TABLE IF EXISTS `salesToPrePrepare__`;
-/*!50001 DROP VIEW IF EXISTS `salesToPrePrepare__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `salesToPrePrepare__` (
- `Id_Ticket` tinyint NOT NULL,
- `Id_Movimiento` tinyint NOT NULL,
- `Id_Movimiento_mark` tinyint NOT NULL,
- `Id_Trabjador` tinyint NOT NULL,
- `isChecked` tinyint NOT NULL,
- `created` tinyint NOT NULL,
- `Id_Article` tinyint NOT NULL,
- `Concepte` tinyint NOT NULL,
- `subName` tinyint NOT NULL,
- `Cantidad` tinyint NOT NULL,
- `original_quantity` tinyint NOT NULL,
- `Hora` tinyint NOT NULL,
- `Departure` tinyint NOT NULL,
- `Minuto` tinyint NOT NULL,
- `agency_id` tinyint NOT NULL,
- `warehouse_id` tinyint NOT NULL,
- `province_id` tinyint NOT NULL,
- `picked` tinyint NOT NULL,
- `trabajador` tinyint NOT NULL,
- `sectorFk` tinyint NOT NULL,
- `stateFk` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Table structure for table `sample`
--
@@ -39634,11 +35623,11 @@ CREATE TABLE `sector` (
`warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '1',
`isPreviousPreparedByPacking` tinyint(4) NOT NULL DEFAULT '1',
`code` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL,
- `pickingPlacement` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL,
- `path` int(11) DEFAULT NULL,
+ `pickingPlacement__` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL,
+ `path__` int(11) DEFAULT NULL,
`isPreviousPrepared` tinyint(1) NOT NULL DEFAULT '0',
`isPackagingArea` tinyint(1) NOT NULL DEFAULT '0',
- `labelReportFk` tinyint(3) unsigned DEFAULT NULL,
+ `reportFk` tinyint(3) unsigned DEFAULT NULL,
`sonFk` int(11) DEFAULT NULL,
`isMain` tinyint(1) NOT NULL DEFAULT '0',
`itemPackingTypeFk` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL,
@@ -39650,9 +35639,11 @@ CREATE TABLE `sector` (
PRIMARY KEY (`id`,`warehouseFk`),
UNIQUE KEY `code_UNIQUE` (`code`),
KEY `sector_fk1_idx` (`warehouseFk`),
- KEY `sector_labelReport` (`labelReportFk`),
+ KEY `sector_report` (`reportFk`),
+ KEY `sector_FK` (`sonFk`,`warehouseFk`),
+ CONSTRAINT `sector_FK` FOREIGN KEY (`sonFk`, `warehouseFk`) REFERENCES `sector` (`id`, `warehouseFk`) ON UPDATE CASCADE,
CONSTRAINT `sector_fk1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `sector_labelReport` FOREIGN KEY (`labelReportFk`) REFERENCES `labelReport` (`id`)
+ CONSTRAINT `sector_report` FOREIGN KEY (`reportFk`) REFERENCES `report` (`id`)
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -39878,8 +35869,8 @@ DELIMITER ;;
BEFORE INSERT ON `sharingClient`
FOR EACH ROW
BEGIN
- SET NEW.ended = GREATEST(CURDATE(),NEW.ended);
- SET NEW.started = GREATEST(CURDATE(),NEW.started);
+ SET NEW.ended = GREATEST(util.VN_CURDATE(),NEW.ended);
+ SET NEW.started = GREATEST(util.VN_CURDATE(),NEW.started);
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -39899,8 +35890,8 @@ DELIMITER ;;
BEFORE UPDATE ON `sharingClient`
FOR EACH ROW
BEGIN
- SET NEW.ended = GREATEST(CURDATE(),NEW.ended);
- SET NEW.started = GREATEST(CURDATE(),NEW.started);
+ SET NEW.ended = GREATEST(util.VN_CURDATE(),NEW.ended);
+ SET NEW.started = GREATEST(util.VN_CURDATE(),NEW.started);
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -39970,17 +35961,6 @@ DELIMITER ;;
BEFORE UPDATE ON `shelving`
FOR EACH ROW
BEGIN
-
- IF OLD.parkingFk != NEW.parkingFk THEN
-
- UPDATE item i
- JOIN itemShelving ish ON ish.itemFk = i.id
- JOIN shelving sh ON sh.code = ish.shelvingFk
- JOIN parking p ON p.id = sh.parkingFk
- SET i.sectorFk = p.sectorFk
- WHERE sh.`code` = OLD.`code`;
-
- END IF;
IF NEW.code = "" THEN
@@ -40035,7 +36015,7 @@ CREATE TABLE `silexACL` (
`method` varchar(50) NOT NULL,
`role` varchar(20) NOT NULL,
PRIMARY KEY (`id`),
- UNIQUE KEY `module_UNIQUE` (`module`,`method`,`role`)
+ UNIQUE KEY `module_UNIQUE` (`module`,`method`) USING BTREE
) ENGINE=InnoDBDEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -40120,15 +36100,17 @@ DROP TABLE IF EXISTS `sms`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `sms` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
- `senderFk` int(11) NOT NULL,
- `destinationFk` int(11) DEFAULT NULL,
+ `senderFk` int(10) unsigned NOT NULL,
+ `destinationFk__` int(11) DEFAULT NULL,
`sender` varchar(15) CHARACTER SET utf8 NOT NULL DEFAULT '693474205',
`destination` varchar(15) CHARACTER SET utf8 NOT NULL,
`message` varchar(160) COLLATE utf8_unicode_ci NOT NULL,
`statusCode` smallint(9) DEFAULT '0',
`status` varchar(255) COLLATE utf8_unicode_ci DEFAULT 'OK',
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ KEY `sms_FK` (`senderFk`),
+ CONSTRAINT `sms_FK` FOREIGN KEY (`senderFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -40271,6 +36253,23 @@ CREATE TABLE `sorter` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `specialLabels`
+--
+
+DROP TABLE IF EXISTS `specialLabels`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `specialLabels` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `description` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
+ `reportName` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
+ `isVisible` tinyint(1) NOT NULL DEFAULT '0',
+ `image` blob,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `specialPrice`
--
@@ -40288,9 +36287,7 @@ CREATE TABLE `specialPrice` (
KEY `Id_Article` (`itemFk`),
KEY `Id_Cliente` (`clientFk`),
CONSTRAINT `sp_article_id` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `sp_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `{01A99AF1-3D3F-4B15-AC0C-C7A834F319A3}` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `{EE4ADEF6-0AC6-401F-B7C4-D797972FC065}` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE
+ CONSTRAINT `sp_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -40372,6 +36369,28 @@ CREATE TABLE `specieGeoInvasive` (
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Esta tabla recoge las prohibiciones de comerciar con especies invasoras de acuerdo con el Catálogo de Especies Exóticas Invasoras publicado por el Estado Español';
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `splitFilter`
+--
+
+DROP TABLE IF EXISTS `splitFilter`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `splitFilter` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `autonomyFk` int(11) DEFAULT NULL,
+ `clientFk` int(11) DEFAULT NULL,
+ `nickname` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `splitFilter_UN` (`autonomyFk`),
+ UNIQUE KEY `splitFilter_UN1` (`clientFk`),
+ KEY `splitFilter_FK` (`autonomyFk`),
+ KEY `splitFilter_FK_1` (`clientFk`),
+ CONSTRAINT `splitFilter_FK` FOREIGN KEY (`autonomyFk`) REFERENCES `autonomy` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `splitFilter_FK_1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='define los clientes que tienen split y el nombre a mostrar en la etiqueta';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `starredModule`
--
@@ -40401,12 +36420,12 @@ DROP TABLE IF EXISTS `state`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `state` (
`id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
- `name` varchar(15) COLLATE utf8_unicode_ci NOT NULL,
+ `name` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`order` tinyint(3) unsigned DEFAULT NULL,
`alertLevel` int(11) NOT NULL DEFAULT '0',
`code` varchar(45) CHARACTER SET utf8 NOT NULL,
`sectorProdPriority` tinyint(3) DEFAULT NULL,
- `nextStateFk` tinyint(4) NOT NULL COMMENT 'Estado al que tiene que cambiar el ticket despues de preparacion previa',
+ `nextStateFk` tinyint(3) unsigned NOT NULL COMMENT 'Estado al que tiene que cambiar el ticket despues de preparacion previa',
`isPreviousPreparable` tinyint(1) NOT NULL DEFAULT '0',
`isPicked` tinyint(1) NOT NULL DEFAULT '0',
`isPreparable` tinyint(1) NOT NULL DEFAULT '0',
@@ -40420,6 +36439,8 @@ CREATE TABLE `state` (
UNIQUE KEY `code_UNIQUE` (`code`),
KEY `state_id3` (`semaphore`),
KEY `alertLevel` (`alertLevel`),
+ KEY `state_FK` (`nextStateFk`),
+ CONSTRAINT `state_FK` FOREIGN KEY (`nextStateFk`) REFERENCES `state` (`id`) ON UPDATE CASCADE,
CONSTRAINT `state_ibfk_1` FOREIGN KEY (`alertLevel`) REFERENCES `alertLevel` (`id`)
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -40491,7 +36512,7 @@ CREATE TABLE `supplier` (
`isSerious` tinyint(1) unsigned NOT NULL DEFAULT '1',
`note` text CHARACTER SET utf8 COLLATE utf8_unicode_ci,
`postcodeFk` int(11) unsigned DEFAULT NULL,
- `postCode` char(5) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
+ `postCode` char(8) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
`isActive` tinyint(4) DEFAULT '1',
`taxTypeSageFk` smallint(6) DEFAULT NULL COMMENT 'Tipo de IVA SAGE',
`withholdingSageFk` smallint(6) DEFAULT NULL COMMENT 'Tipos de retención SAGE',
@@ -40571,20 +36592,22 @@ DROP TABLE IF EXISTS `supplierAccount`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `supplierAccount` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
- `supplierFk` int(11) NOT NULL,
+ `supplierFk` int(11) DEFAULT NULL,
`iban` varchar(30) CHARACTER SET utf8 DEFAULT NULL,
`office` varchar(4) CHARACTER SET utf8 DEFAULT NULL,
`DC` varchar(2) CHARACTER SET utf8 DEFAULT NULL,
`number` varchar(10) CHARACTER SET utf8 DEFAULT NULL,
`description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'obsoleta(comprobar)',
`bicSufix` varchar(3) CHARACTER SET utf8 NOT NULL DEFAULT '',
- `bankEntityFk` int(10) DEFAULT NULL,
+ `bankEntityFk` int(10) unsigned DEFAULT NULL,
`bankFk` int(11) DEFAULT NULL COMMENT 'obsoleta(comprobar)',
`beneficiary` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk_proveedores_proveedores_account_idx` (`supplierFk`),
KEY `fk_Proveedores_account_entity1_idx` (`bankEntityFk`),
- KEY `fk_banco_prov_account_idx` (`bankFk`)
+ KEY `fk_banco_prov_account_idx` (`bankFk`),
+ CONSTRAINT `supplierAccount_FK` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `supplierAccount_FK_1` FOREIGN KEY (`bankEntityFk`) REFERENCES `bankEntity` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
@@ -41050,10 +37073,10 @@ CREATE TABLE `ticket` (
`warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '1',
`shipped` datetime NOT NULL,
`nickname` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
- `notes` longtext COLLATE utf8_unicode_ci,
+ `notes__` longtext COLLATE utf8_unicode_ci,
`refFk` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
- `invoiceOutFk` int(10) unsigned DEFAULT NULL COMMENT 'eliminar',
- `isBooked` tinyint(1) NOT NULL DEFAULT '0',
+ `invoiceOutFk__` int(10) unsigned DEFAULT NULL COMMENT 'eliminar',
+ `isBooked__` tinyint(1) NOT NULL DEFAULT '0',
`addressFk` int(11) NOT NULL DEFAULT '0',
`workerFk` int(11) DEFAULT NULL,
`observations` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'eliminar',
@@ -41080,6 +37103,7 @@ CREATE TABLE `ticket` (
`zoneBonus` decimal(10,2) DEFAULT NULL,
`totalWithVat` decimal(10,2) DEFAULT NULL COMMENT 'cache calculada del total con iva',
`totalWithoutVat` decimal(10,2) DEFAULT NULL COMMENT 'cache calculada del total sin iva',
+ `weight` decimal(10,2) DEFAULT NULL COMMENT 'En caso de informar, se utilizará su valor para calcular el peso de la factura',
PRIMARY KEY (`id`),
KEY `Id_Cliente` (`clientFk`),
KEY `Id_Consigna` (`addressFk`),
@@ -41102,7 +37126,7 @@ CREATE TABLE `ticket` (
CONSTRAINT `ticket_ibfk_9` FOREIGN KEY (`routeFk`) REFERENCES `route` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `tickets_fk11` FOREIGN KEY (`collectionFk__`) REFERENCES `collection` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `tickets_zone_fk` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON UPDATE CASCADE
-) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+) ENGINE=InnoDB AUTO_INCREMENT=3750016 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -41146,8 +37170,8 @@ BEGIN
WHERE c.id = NEW.clientFk;
INSERT INTO bs.clientNewBorn(clientFk, firstShipped, lastShipped)
- VALUES(NEW.clientFk, IFNULL(vTransferorFirstShipped, CURDATE()), CURDATE())
- ON DUPLICATE KEY UPDATE lastShipped = CURDATE();
+ VALUES(NEW.clientFk, IFNULL(vTransferorFirstShipped, util.VN_CURDATE()), util.VN_CURDATE())
+ ON DUPLICATE KEY UPDATE lastShipped = util.VN_CURDATE();
END IF;
@@ -41178,7 +37202,7 @@ BEGIN
FROM vn.route r
WHERE r.isOk = FALSE
AND r.id IN (OLD.routeFk,NEW.routeFk)
- AND r.created >= CURDATE()
+ AND r.created >= util.VN_CURDATE()
GROUP BY r.id;
call util.debugAdd(NEW.id,CONCAT(OLD.routeFk,' ',NEW.routeFk));
END IF;
@@ -41202,7 +37226,7 @@ BEGIN
JOIN vn.route r ON r.id = t.routeFk
WHERE r.isOk = FALSE
AND t.id = NEW.id
- AND r.created >= CURDATE()
+ AND r.created >= util.VN_CURDATE()
GROUP BY r.id;
SET NEW.shipped = DATE_FORMAT(NEW.shipped, '2000-%m-%d %T');
SET NEW.landed = DATE_FORMAT(NEW.landed, '2000-%m-%d %T');
@@ -41275,9 +37299,17 @@ BEGIN
'jgallego@verdnatura.es',
'jgallego@verdnatura.es',
'Modificado ticket al cliente 2067',
- CONCAT(account.myUserGetName(), ' ha modificado el ticket ',NEW.id)
+ CONCAT(account.myUser_getName(), ' ha modificado el ticket ',NEW.id)
);
END IF;
+
+ IF NEW.routeFk <> OLD.routeFk THEN
+
+ UPDATE expedition
+ SET hasNewRoute = TRUE
+ WHERE ticketFk = NEW.id;
+
+ END IF;
END */;;
DELIMITER ;
@@ -41303,7 +37335,7 @@ BEGIN
FROM vn.route r
WHERE r.isOk = FALSE
AND r.id = OLD.routeFk
- AND r.created >= CURDATE()
+ AND r.created >= util.VN_CURDATE()
GROUP BY r.id;
DELETE FROM sale WHERE ticketFk = OLD.id;
@@ -41330,7 +37362,7 @@ CREATE TABLE `ticketCollection` (
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`level` int(11) DEFAULT NULL,
`wagon` int(11) NOT NULL DEFAULT '0',
- `smartTagFk` varchar(12) COLLATE utf8_unicode_ci DEFAULT NULL,
+ `smartTagFk` varchar(12) CHARACTER SET utf8 DEFAULT NULL,
`usedShelves` int(11) DEFAULT NULL COMMENT 'número de bandejas que ocupa un ticket en el carro',
`itemCount` int(11) DEFAULT NULL COMMENT 'número de productos distintos en el pedido',
`liters` int(11) DEFAULT NULL COMMENT 'volumen del pedido en litros',
@@ -41340,6 +37372,7 @@ CREATE TABLE `ticketCollection` (
KEY `ticketCollection_fk2_idx` (`ticketFk`),
KEY `ticketCollection_smartTagFk_IDX` (`smartTagFk`) USING BTREE,
KEY `ticketCollection_created_IDX` (`created`) USING BTREE,
+ CONSTRAINT `ticketCollection_FK` FOREIGN KEY (`smartTagFk`) REFERENCES `smartTag` (`code`) ON UPDATE CASCADE,
CONSTRAINT `ticketCollection_fk1` FOREIGN KEY (`collectionFk`) REFERENCES `collection` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `ticketCollection_fk2` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
@@ -41495,28 +37528,6 @@ CREATE TABLE `ticketDown_SelectionType` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Temporary table structure for view `ticketLabel_Source`
---
-
-DROP TABLE IF EXISTS `ticketLabel_Source`;
-/*!50001 DROP VIEW IF EXISTS `ticketLabel_Source`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `ticketLabel_Source` (
- `level` tinyint NOT NULL,
- `Id_Ticket` tinyint NOT NULL,
- `Agencia` tinyint NOT NULL,
- `Id_Cliente` tinyint NOT NULL,
- `Notas` tinyint NOT NULL,
- `Sacador` tinyint NOT NULL,
- `ncarro` tinyint NOT NULL,
- `horaagencia` tinyint NOT NULL,
- `fecha` tinyint NOT NULL,
- `urgente` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Table structure for table `ticketLastState`
--
@@ -41878,29 +37889,17 @@ CREATE TABLE `ticketRefund` (
/*!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 = utf8 */ ;
-/*!50003 SET character_set_results = utf8 */ ;
-/*!50003 SET collation_connection = utf8_general_ci */ ;
+/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketRefund_beforeInsert`
BEFORE INSERT ON `ticketRefund`
FOR EACH ROW
BEGIN
- DECLARE vAlreadyExists BOOLEAN DEFAULT FALSE;
-
- IF NEW.refundTicketFk = NEW.originalTicketFk THEN
- CALL util.throw('Original ticket and refund ticket has same id');
- END IF;
-
- SELECT COUNT(*) INTO vAlreadyExists
- FROM ticketRefund
- WHERE refundTicketFk = NEW.originalTicketFk;
-
- IF vAlreadyExists > 0 THEN
- CALL util.throw('This ticket is already a refund');
- END IF;
+ CALL ticketRefund_beforeUpsert(NEW.refundTicketFk, NEW.originalTicketFk);
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -41910,29 +37909,17 @@ 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 = utf8 */ ;
-/*!50003 SET character_set_results = utf8 */ ;
-/*!50003 SET collation_connection = utf8_general_ci */ ;
+/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketRefund_beforeUpdate`
BEFORE UPDATE ON `ticketRefund`
FOR EACH ROW
BEGIN
- DECLARE vAlreadyExists BOOLEAN DEFAULT FALSE;
-
- IF NEW.refundTicketFk = NEW.originalTicketFk THEN
- CALL util.throw('Original ticket and refund ticket has same id');
- END IF;
-
- SELECT COUNT(*) INTO vAlreadyExists
- FROM ticketRefund
- WHERE refundTicketFk = NEW.originalTicketFk;
-
- IF vAlreadyExists > 0 THEN
- CALL util.throw('This ticket is already a refund');
- END IF;
+ CALL ticketRefund_beforeUpsert(NEW.refundTicketFk, NEW.originalTicketFk);
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -42387,7 +38374,7 @@ BEGIN
`sender` = 'jgallego@verdnatura.es',
`replyTo` = 'jgallego@verdnatura.es',
`subject` = 'tabla time modificada',
- `body` = CONCAT(account.myUserGetName(), ' ha modificado la tabla time ',
+ `body` = CONCAT(account.myUser_getName(), ' ha modificado la tabla time ',
NEW.`dated`);*/
END */;;
DELIMITER ;
@@ -42396,25 +38383,6 @@ DELIMITER ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
---
--- Temporary table structure for view `time__`
---
-
-DROP TABLE IF EXISTS `time__`;
-/*!50001 DROP VIEW IF EXISTS `time__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `time__` (
- `dated` tinyint NOT NULL,
- `period` tinyint NOT NULL,
- `month` tinyint NOT NULL,
- `year` tinyint NOT NULL,
- `day` tinyint NOT NULL,
- `week` tinyint NOT NULL,
- `yearMonth` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Table structure for table `town`
--
@@ -42948,6 +38916,7 @@ CREATE TABLE `userConfig` (
`companyFk` smallint(5) unsigned DEFAULT NULL,
`created` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ `darkMode` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Salix interface dark mode',
PRIMARY KEY (`userFk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Configuración de usuario en Salix';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -43246,7 +39215,9 @@ CREATE TABLE `warehouse` (
KEY `isComparativeIdx` (`isComparative`),
KEY `warehouse_ibfk_1_idx` (`aliasFk`),
KEY `warehouse_FK` (`addressFk`),
+ KEY `warehouse_FK_1` (`pickUpAgencyModeFk`),
CONSTRAINT `warehouse_FK` FOREIGN KEY (`addressFk`) REFERENCES `address` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
+ CONSTRAINT `warehouse_FK_1` FOREIGN KEY (`pickUpAgencyModeFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE,
CONSTRAINT `warehouse_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`),
CONSTRAINT `warehouse_ibfk_2` FOREIGN KEY (`aliasFk`) REFERENCES `warehouseAlias` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
@@ -43325,7 +39296,7 @@ DROP TABLE IF EXISTS `workCenter`;
CREATE TABLE `workCenter` (
`id` int(11) NOT NULL DEFAULT '0',
`name` varchar(255) DEFAULT NULL,
- `payrollCenterFk` int(11) DEFAULT NULL,
+ `payrollCenterFk` int(11) DEFAULT NULL COMMENT 'Campo workcenter en A3',
`counter` bigint(20) DEFAULT NULL,
`warehouseFk` smallint(6) DEFAULT NULL,
`street` varchar(255) DEFAULT NULL,
@@ -43410,6 +39381,21 @@ CREATE TABLE `worker` (
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `workerAppTester`
+--
+
+DROP TABLE IF EXISTS `workerAppTester`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `workerAppTester` (
+ `workerFk` int(10) unsigned NOT NULL,
+ PRIMARY KEY (`workerFk`),
+ KEY `workerAppTester_FK` (`workerFk`),
+ CONSTRAINT `workerAppTester_FK_1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='La tabla incluye usuarios testers que actualizarán a una versión diferente que el resto para testear los cambios nuevos en las app';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `workerBosses`
--
@@ -43590,7 +39576,7 @@ CREATE TABLE `workerDocument` (
KEY `workerDocument_ibfk_1` (`worker`),
KEY `workerDocument_ibfk_2` (`document`),
CONSTRAINT `workerDocument_ibfk_1` FOREIGN KEY (`worker`) REFERENCES `worker` (`userFk`) ON UPDATE CASCADE,
- CONSTRAINT `workerDocument_ibfk_2` FOREIGN KEY (`document`) REFERENCES `dms` (`id`) ON UPDATE CASCADE
+ CONSTRAINT `workerDocument_ibfk_2` FOREIGN KEY (`document`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -43770,25 +39756,6 @@ CREATE TABLE `workerManaExcluded` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Usuarios que tienen que estar excluidos del cálculo del maná';
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Temporary table structure for view `workerMana__`
---
-
-DROP TABLE IF EXISTS `workerMana__`;
-/*!50001 DROP VIEW IF EXISTS `workerMana__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `workerMana__` (
- `workerFk` tinyint NOT NULL,
- `size` tinyint NOT NULL,
- `amount` tinyint NOT NULL,
- `pricesModifierRate` tinyint NOT NULL,
- `isPricesModifierActivated` tinyint NOT NULL,
- `minRate` tinyint NOT NULL,
- `maxRate` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Temporary table structure for view `workerMedia`
--
@@ -43976,6 +39943,7 @@ CREATE TABLE `workerTimeControl` (
PRIMARY KEY (`id`),
UNIQUE KEY `userFk_Timed_uniq` (`userFk`,`timed`),
KEY `warehouseFkfk1_idx` (`warehouseFk`),
+ KEY `timed_idx` (`timed`),
CONSTRAINT `warehouseFk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE,
CONSTRAINT `workerTimeControl_fk1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Fichadas';
@@ -43993,7 +39961,7 @@ DELIMITER ;;
AFTER INSERT ON `workerTimeControl`
FOR EACH ROW
BEGIN
- IF NEW.timed > DATE_ADD(NOW(), INTERVAL 1 DAY) THEN
+ IF NEW.timed > DATE_ADD(util.VN_NOW(), INTERVAL 1 DAY) THEN
CALL util.throw('date in the future');
END IF;
END */;;
@@ -44031,6 +39999,8 @@ CREATE TABLE `workerTimeControlConfig` (
`breakTime` int(11) DEFAULT NULL COMMENT 'Tiempo de descanso expresado en segundos',
`timeToBreakTime` int(11) DEFAULT NULL COMMENT 'Tiempo mínimo que se debe trabajar para añadir descanso, expresado en segundos',
`dayMaxTime` int(11) DEFAULT NULL COMMENT 'Tiempo máximo desde la entrada hasta la salida, expresado en segundos',
+ `shortWeekDays` int(11) DEFAULT NULL COMMENT 'Días a tener en cuenta para calcular el descanso corto',
+ `longWeekDays` int(11) DEFAULT NULL COMMENT 'Días a tener en cuenta para calcular el descanso largo',
PRIMARY KEY (`id`)
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='All values in seconds';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -44188,24 +40158,6 @@ SET character_set_client = utf8;
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
---
--- Temporary table structure for view `workerTimeControl_Journey__`
---
-
-DROP TABLE IF EXISTS `workerTimeControl_Journey__`;
-/*!50001 DROP VIEW IF EXISTS `workerTimeControl_Journey__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `workerTimeControl_Journey__` (
- `userFk` tinyint NOT NULL,
- `dated` tinyint NOT NULL,
- `Journey` tinyint NOT NULL,
- `dayName` tinyint NOT NULL,
- `name` tinyint NOT NULL,
- `firstname` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Temporary table structure for view `workerTimeJourneyNG`
--
@@ -44224,21 +40176,6 @@ SET character_set_client = utf8;
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
---
--- Temporary table structure for view `workerWithoutDevice__`
---
-
-DROP TABLE IF EXISTS `workerWithoutDevice__`;
-/*!50001 DROP VIEW IF EXISTS `workerWithoutDevice__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `workerWithoutDevice__` (
- `workerFk` tinyint NOT NULL,
- `Trabajador` tinyint NOT NULL,
- `Colecciones` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Temporary table structure for view `workerWithoutTractor`
--
@@ -44442,7 +40379,7 @@ DELIMITER ;;
BEFORE INSERT ON `workingHours`
FOR EACH ROW
BEGIN
- IF (SELECT COUNT(*) FROM workingHours WHERE userId = NEW.userId AND DATE(timeIn) = CURDATE()) > 0 THEN
+ IF (SELECT COUNT(*) FROM workingHours WHERE userId = NEW.userId AND DATE(timeIn) = util.VN_CURDATE()) > 0 THEN
CALL util.throw ('ALREADY_LOGGED');
END IF;
END */;;
@@ -44641,6 +40578,25 @@ DELIMITER ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
+--
+-- Table structure for table `zoneExclusionGeo`
+--
+
+DROP TABLE IF EXISTS `zoneExclusionGeo`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `zoneExclusionGeo` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `zoneExclusionFk` int(11) NOT NULL,
+ `geoFk` int(11) NOT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `zoneExclusionGeo_UN` (`zoneExclusionFk`,`geoFk`),
+ KEY `zoneExclusionGeo2_FK_1` (`geoFk`),
+ CONSTRAINT `zoneExclusionGeo_FK` FOREIGN KEY (`geoFk`) REFERENCES `zoneGeo` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `zoneExclusionGeo_FK_1` FOREIGN KEY (`zoneExclusionFk`) REFERENCES `zoneExclusion` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDBDEFAULT CHARSET=utf8;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `zoneFilter`
--
@@ -44825,26 +40781,6 @@ CREATE TABLE `zoneWarehouse` (
) ENGINE=InnoDBDEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Temporary table structure for view `zone_ETD__`
---
-
-DROP TABLE IF EXISTS `zone_ETD__`;
-/*!50001 DROP VIEW IF EXISTS `zone_ETD__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `zone_ETD__` (
- `zoneFk` tinyint NOT NULL,
- `HoraTeórica` tinyint NOT NULL,
- `volumenTotal` tinyint NOT NULL,
- `volumenPendiente` tinyint NOT NULL,
- `velocidad` tinyint NOT NULL,
- `HoraPráctica` tinyint NOT NULL,
- `minutesLess` tinyint NOT NULL,
- `etc` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Dumping events for database 'vn'
--
@@ -44947,38 +40883,43 @@ DELIMITER ;;
DECLARE vCurrentCount INT;
DECLARE vCheckSum INT;
- DECLARE vIsAlreadyNotified BOOLEAN;
- DECLARE vTableQueue TEXT;
+ DECLARE vIsAlreadyNotified BOOLEAN;
+ DECLARE vTableQueue TEXT;
DECLARE vLineQueue TEXT;
- DECLARE vDone BOOL DEFAULT FALSE;
- DECLARE vCur CURSOR FOR
- SELECT CONCAT('
+ DECLARE vDone BOOL DEFAULT FALSE;
+ DECLARE vPrintQueueLimit INT;
+
+ DECLARE vCur CURSOR FOR
+ SELECT CONCAT('
', IFNULL(pq.id, ''), ' |
', IFNULL(p.path, ''),' |
- ', IFNULL(lr.name, ''),' |
- ', IFNULL(e.Estado, ''),' |
+ ', IFNULL(r.name, ''),' |
+ ', IFNULL(pq.statusCode, ''),' |
', IFNULL(w.firstname, ''), " ", IFNULL(w.lastName, ''),' |
', IFNULL(pq.`error`, ''),' |
')
- FROM vn.printingQueue pq
- LEFT JOIN vn.worker w ON w.id = pq.worker
- LEFT JOIN vn.printer p ON p.id = pq.printer
- LEFT JOIN vn.labelReport lr ON lr.id = pq.report
- JOIN vn2008.Estados e ON e.Id_Estado = pq.state
- LIMIT 30;
+ FROM printQueue pq
+ LEFT JOIN worker w ON w.id = pq.workerFk
+ LEFT JOIN printer p ON p.id = pq.printerFk
+ LEFT JOIN report r ON r.id = pq.reportFk
+ JOIN printQueueConfig
+ LIMIT vPrintQueueLimit;
- DECLARE CONTINUE HANDLER FOR NOT FOUND
- SET vDone = TRUE;
+ DECLARE CONTINUE HANDLER FOR NOT FOUND
+ SET vDone = TRUE;
+
+ SELECT printQueueLimit INTO vPrintQueueLimit
+ FROM printQueueConfig;
SELECT COUNT(*), IFNULL(SUM(id),0) INTO vCurrentCount, vCheckSum
- FROM vn.printingQueue WHERE state = 1;
-
- SELECT isAlreadyNotified INTO vIsAlreadyNotified
- FROM printingQueueCheck;
+ FROM printQueue WHERE statusCode = 'queued';
+
+ SELECT isAlreadyNotified INTO vIsAlreadyNotified
+ FROM printingQueueCheck;
IF (SELECT lastCount FROM printingQueueCheck) = vCurrentCount AND
(SELECT lastCheckSum FROM printingQueueCheck) = vCheckSum AND
- vIsAlreadyNotified = FALSE AND vCurrentCount > 0
+ vIsAlreadyNotified = FALSE AND vCurrentCount > 0
THEN
SELECT '
@@ -44989,46 +40930,46 @@ DELIMITER ;;
Estado |
Trabajador |
Error |
- ' INTO vTableQueue;
+ ' INTO vTableQueue;
OPEN vCur;
-
+
l: LOOP
SET vDone = FALSE;
-
+
FETCH vCur INTO vLineQueue;
-
- IF vDone THEN
+
+ IF vDone THEN
LEAVE l;
END IF;
-
- SELECT CONCAT(vTableQueue, vLineQueue) INTO vTableQueue;
+
+ SELECT CONCAT(vTableQueue, vLineQueue) INTO vTableQueue;
END LOOP;
-
- CLOSE vCur;
-
- CALL mail_insert(
- 'cau@verdnatura.es',
- NULL,
+
+ CLOSE vCur;
+
+ CALL mail_insert(
+ 'cau@verdnatura.es',
+ NULL,
'Servidor de impresion parado',
- CONCAT('Hay ', vCurrentCount, ' lineas bloqueadas', vTableQueue, '
')
+ CONCAT('Hay ', vCurrentCount, ' lineas bloqueadas', vTableQueue, '')
);
-
- UPDATE printingQueueCheck SET isAlreadyNotified = TRUE;
+
+ UPDATE printingQueueCheck SET isAlreadyNotified = TRUE;
END IF;
-
- IF (SELECT lastCount FROM printingQueueCheck) > vCurrentCount AND
- vIsAlreadyNotified = TRUE
+
+ IF (SELECT lastCount FROM printingQueueCheck) > vCurrentCount AND
+ vIsAlreadyNotified = TRUE
THEN
UPDATE printingQueueCheck SET isAlreadyNotified = FALSE;
END IF;
-
+
UPDATE printingQueueCheck
SET lastCount = vCurrentCount,
lastCheckSum = vCheckSum;
-
+
END */ ;;
/*!50003 SET time_zone = @saved_time_zone */ ;;
/*!50003 SET sql_mode = @saved_sql_mode */ ;;
@@ -45065,7 +41006,7 @@ DELIMITER ;;
/*!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=`root`@`localhost`*/ /*!50106 EVENT `sale_checkWithoutComponents` ON SCHEDULE EVERY 10 MINUTE STARTS '2020-05-04 11:56:23' ON COMPLETION PRESERVE DISABLE DO call sale_checkNoComponents(DATE_ADD(NOW(), INTERVAL -10 MINUTE),DATE_ADD(NOW(), INTERVAL -1 MINUTE)) */ ;;
+/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `sale_checkWithoutComponents` ON SCHEDULE EVERY 10 MINUTE STARTS '2020-05-04 11:56:23' ON COMPLETION PRESERVE DISABLE DO call sale_checkNoComponents(DATE_ADD(util.VN_NOW(), INTERVAL -10 MINUTE),DATE_ADD(util.VN_NOW(), INTERVAL -1 MINUTE)) */ ;;
/*!50003 SET time_zone = @saved_time_zone */ ;;
/*!50003 SET sql_mode = @saved_sql_mode */ ;;
/*!50003 SET character_set_client = @saved_cs_client */ ;;
@@ -45083,7 +41024,7 @@ DELIMITER ;;
/*!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=`root`@`localhost`*/ /*!50106 EVENT `ticketClosure` ON SCHEDULE EVERY 1 DAY STARTS '2017-09-18 00:30:00' ON COMPLETION NOT PRESERVE DISABLE COMMENT 'Realiza el cierre de todos los almacenes del dia actual' DO CALL ticketClosureMultiWarehouse(DATE_ADD(CURDATE(), INTERVAL -1 DAY)) */ ;;
+/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `ticketClosure` ON SCHEDULE EVERY 1 DAY STARTS '2017-09-18 00:30:00' ON COMPLETION NOT PRESERVE DISABLE COMMENT 'Realiza el cierre de todos los almacenes del dia actual' DO CALL ticketClosureMultiWarehouse(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 DAY)) */ ;;
/*!50003 SET time_zone = @saved_time_zone */ ;;
/*!50003 SET sql_mode = @saved_sql_mode */ ;;
/*!50003 SET character_set_client = @saved_cs_client */ ;;
@@ -45142,7 +41083,7 @@ DELIMITER ;;
SELECT week,year INTO vWeek,vYear
FROM vn.time
- WHERE dated IN (DATE_ADD(CURDATE(), INTERVAL -10 DAY), DATE_ADD(CURDATE(), INTERVAL -4 DAY))
+ WHERE dated IN (DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL -4 DAY))
GROUP BY year,week
LIMIT 1;
@@ -45177,6 +41118,8 @@ DELIMITER ;
--
-- Dumping routines for database 'vn'
--
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP FUNCTION IF EXISTS `addressTaxArea` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -45184,8 +41127,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `addressTaxArea`(vAddresId INT, vCompanyId INT) RETURNS varchar(25) CHARSET utf8
DETERMINISTIC
@@ -45235,6 +41176,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `address_getGeo` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -45242,8 +41185,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `address_getGeo`(vSelf INT) RETURNS int(11)
DETERMINISTIC
@@ -45271,6 +41212,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP FUNCTION IF EXISTS `barcodeToItem` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -45278,8 +41221,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `barcodeToItem`(vBarcode VARCHAR(22)) RETURNS int(11)
DETERMINISTIC
@@ -45334,111 +41275,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP FUNCTION IF EXISTS `bionicCalcReverse__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` FUNCTION `bionicCalcReverse__`(vWarehouse INT,
- vMargin DECIMAL(10,3),
- vRetailedPrice DECIMAL(10,3),
- vM3 DECIMAL(10,3),
- vAddress INT,
- vAgencyMode INT) RETURNS decimal(10,3)
- DETERMINISTIC
-BEGIN
-
- -- OBSOLETO usar catalog_componentReverse JGF 2020-02-26
- DECLARE vGeneralInflationCoeficient INT;
- DECLARE vVerdnaturaVolumeBox BIGINT;
- DECLARE vClientFk INT;
- DECLARE vComponentRecovery VARCHAR(50) DEFAULT 'debtCollection';
- DECLARE vComponentMana VARCHAR(50) DEFAULT 'autoMana';
- DECLARE vComponentPort VARCHAR(50) DEFAULT 'delivery';
- DECLARE vComponentMargin VARCHAR(50) DEFAULT 'margin';
- DECLARE vComponentCost VARCHAR(50) DEFAULT 'purchaseValue';
- DECLARE vComponentCostValue DECIMAL(10,2);
- DECLARE vItem INT DEFAULT 98;
- DECLARE vItemCarryBox INT;
-
- CALL util.throw('Obsoleto hablar con Informática');
-
- SELECT generalInflationCoeFicient, verdnaturaVolumeBox, itemCarryBox
- INTO vGeneralInflationCoeficient, vVerdnaturaVolumeBox, vItemCarryBox
- FROM bionicConfig;
-
- SELECT clientFk INTO vClientFk FROM address WHERE id = vAddress;
-
- -- Creamos la tabla tmp.bionicComponent
- DROP TEMPORARY TABLE IF EXISTS tmp.bionicComponent;
- CREATE TEMPORARY TABLE tmp.bionicComponent(
- `warehouseFk` smallint(5) unsigned NOT NULL,
- `itemFk` int(11) NOT NULL,
- `componentFk` int(10) unsigned NOT NULL,
- `value` decimal(10,4) NOT NULL,
- UNIQUE KEY `itemWarehouseComponent` (`itemFk`,`warehouseFk`,`componentFk`) USING HASH,
- KEY `itemWarehouse` (`itemFk`,`warehouseFk`) USING BTREE
- ) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
- -- Margin
- INSERT INTO tmp.bionicComponent (warehouseFk, itemFk, componentFk, `value`)
- SELECT vWarehouse, vItem, id, vMargin
- FROM component
- WHERE code = vComponentMargin;
-
- -- Recobro
- INSERT INTO tmp.bionicComponent (warehouseFk, itemFk, componentFk, `value`)
- SELECT vWarehouse, vItem, c.id, ROUND(LEAST(cr.recobro,0.25), 3)
- FROM bi.claims_ratio cr
- JOIN component c ON c.code = vComponentRecovery
- WHERE cr.Id_Cliente = vClientFk AND cr.recobro > 0.009;
-
- -- Componente de maná automático, en función del maná acumulado por el comercial.
- INSERT INTO tmp.bionicComponent (warehouseFk, itemFk, componentFk, `value`)
- SELECT vWarehouse, vItem, co.id, ROUND(ms.prices_modifier_rate, 3)
- FROM client c
- JOIN bs.mana_spellers ms ON c.salesPersonFk = ms.Id_Trabajador
- JOIN component co ON co.code = vComponentMana
- WHERE ms.prices_modifier_activated AND c.id = vClientFk LIMIT 1;
-
- -- Reparto
- INSERT INTO tmp.bionicComponent (warehouseFk, itemFk, componentFk, `value`)
- SELECT vWarehouse, vItem, co.id, vGeneralInflationCoeficient
- * ROUND(
- vM3
- * az.price
- * az.inflation
- / vVerdnaturaVolumeBox, 4
- )
- FROM agencyMode ag
- JOIN address a ON a.id = vAddress AND ag.id = vAgencyMode
- JOIN agencyProvince ap ON ap.agencyFk = ag.agencyFk
- AND ap.warehouseFk = vWarehouse AND ap.provinceFk = a.provinceFk
- JOIN agencyModeZone az ON az.agencyModeFk = vAgencyMode
- AND az.zone = ap.zone AND az.itemFk = 71 AND az.warehouseFk = vWarehouse
- JOIN component co ON co.code = vComponentPort;
-
- -- Coste
- SELECT vRetailedPrice - SUM(`value`) INTO vComponentCostValue
- FROM tmp.bionicComponent;
-
- INSERT INTO tmp.bionicComponent (warehouseFk, itemFk, componentFk, `value`)
- SELECT vWarehouse, vItem, id,vComponentCostValue
- FROM component
- WHERE code = vComponentCost;
-
- RETURN vComponentCostValue;
-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 DROP FUNCTION IF EXISTS `botanicExport_isUpdatable` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -45446,8 +41284,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `botanicExport_isUpdatable`(vEdiGenusFk MEDIUMINT,vEdiSpecieFk MEDIUMINT,
vCountryFk MEDIUMINT,vRestriction MEDIUMINT) RETURNS int(11)
@@ -45467,6 +41303,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `buy_getUnitVolume` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -45474,8 +41312,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buy_getUnitVolume`(vSelf INT) RETURNS int(11)
DETERMINISTIC
@@ -45502,6 +41338,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `buy_getVolume` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -45509,8 +41347,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buy_getVolume`(vSelf INT) RETURNS int(11)
DETERMINISTIC
@@ -45535,50 +41371,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP FUNCTION IF EXISTS `buy_hasNotifyPassport__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` FUNCTION `buy_hasNotifyPassport__`(vBuyFk INT, vItemFk INT) RETURNS tinyint(1)
- READS SQL DATA
-BEGIN
- DECLARE vHasPassport BOOL;
- DECLARE vIsAlreadySent BOOL;
- DECLARE vItemCategoryFk INT;
- SELECT id INTO vItemCategoryFk FROM itemCategory WHERE code = 'plant';
-
- SELECT COUNT(*) INTO vHasPassport
- FROM botanicExport be
- JOIN itemBotanical ib
- ON be.ediGenusFk = ib.genusFk
- AND IFNULL(be.ediSpecieFk, ib.specieFk) = ib.specieFk
- AND be.`code` = 'phytosanitaryPassport'
- JOIN item i ON i.id = ib.itemFk
- JOIN itemType it ON it.id = i.typeFk
- WHERE ib.itemFk = vItemFk
- AND it.categoryFk = vItemCategoryFk;
-
- IF vHasPassport THEN
- SELECT COUNT(*) INTO vIsAlreadySent
- FROM mail m
- JOIN buy b ON b.id = vBuyFk
- WHERE m.`body` LIKE CONCAT('%', b.ektFk, '%')
- LIMIT 1;
- END IF;
-
- RETURN vHasPassport AND NOT vIsAlreadySent;
-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 DROP FUNCTION IF EXISTS `catalog_componentReverse` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -45586,8 +41380,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `catalog_componentReverse`(vWarehouse INT,
vCost DECIMAL(10,3),
@@ -45635,58 +41427,59 @@ BEGIN
INSERT INTO tmp.catalog_component (warehouseFk, itemFk, componentFk, cost)
SELECT vWarehouse, vItem, vComponentCost, vCost
FROM vn.rate
- WHERE dated <= CURDATE()
+ WHERE dated <= util.VN_CURDATE()
AND warehouseFk = vWarehouse
ORDER BY dated DESC
- LIMIT 1;
-
- -- Margen
- -- No se aplica margen, cau 12589
+ LIMIT 1;
+
+ -- Margen
+ -- No se aplica margen, cau 12589
/* INSERT INTO tmp.catalog_component (warehouseFk, itemFk, componentFk, cost)
SELECT vWarehouse, vItem, vComponentMargin, (vCost / ((100 - rate2) / 100)) - vCost
FROM vn.rate
- WHERE dated <= CURDATE()
+ WHERE dated <= util.VN_CURDATE()
AND warehouseFk = vWarehouse
ORDER BY dated DESC
- LIMIT 1;
- */
- -- Recobro
+ LIMIT 1;
+ */
+ -- Recobro
INSERT INTO tmp.catalog_component (warehouseFk, itemFk, componentFk, cost)
SELECT vWarehouse, vItem, vComponentRecovery, ROUND(LEAST(recobro,0.25), 3)
FROM bi.claims_ratio
WHERE Id_Cliente = vCustomer AND recobro > 0.009;
-
+
-- Componente de maná automático, en función del maná acumulado por el comercial.
INSERT INTO tmp.catalog_component (warehouseFk, itemFk, componentFk, cost)
- SELECT vWarehouse, vItem, vComponentMana, ROUND(prices_modifier_rate, 3)
- FROM client c
- JOIN bs.mana_spellers ms ON c.salesPersonFk = ms.Id_Trabajador
- WHERE ms.prices_modifier_activated AND c.id = vCustomer LIMIT 1;
-
+ SELECT vWarehouse, vItem, vComponentMana, ROUND(wm.pricesModifierRate, 3)
+ FROM client c
+ JOIN vn.workerMana wm ON c.salesPersonFk = wm.workerFk
+ WHERE wm.isPricesModifierActivated AND c.id = vCustomer LIMIT 1;
+
-- Reparto
INSERT INTO tmp.catalog_component (warehouseFk, itemFk, componentFk, cost)
SELECT vWarehouse, vItem, vDeliveryComponent,
ROUND(
- vM3
+ vM3
* (z.price - z.bonus)
* z.inflation
/ vBoxVolume, 4
)
- FROM zone z
+ FROM zone z
WHERE z.id = vZoneFk;
-
+
-- Precio de venta
SELECT SUM(cost) INTO vRetailedPrice
FROM tmp.catalog_component;
- RETURN vRetailedPrice;
-
+ RETURN vRetailedPrice;
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 FUNCTION IF EXISTS `clientGetDebt` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -45694,8 +41487,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `clientGetDebt`(`vClient` INT, `vDate` DATE) RETURNS decimal(10,2)
READS SQL DATA
@@ -45720,9 +41511,9 @@ BEGIN
RETURN 0;
END IF;
- SET vDate = IFNULL(vDate, CURDATE());
+ SET vDate = IFNULL(vDate, util.VN_CURDATE());
- SET vDateIni = TIMESTAMPADD(MONTH, -2, CURDATE());
+ SET vDateIni = TIMESTAMPADD(MONTH, -2, util.VN_CURDATE());
SET vDateEnd = TIMESTAMP(vDate, '23:59:59');
SELECT IFNULL(SUM(t.amount), 0) INTO vDebt
@@ -45756,6 +41547,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `clientGetMana` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -45763,8 +41556,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `clientGetMana`(vClient INT) RETURNS decimal(10,2)
DETERMINISTIC
@@ -45814,7 +41605,7 @@ BEGIN
JOIN saleComponent sc on sc.saleFk = s.id
WHERE sc.componentFk IN (vManaComponent, vAutoManaComponent)
AND t.shipped > vFromDated
- AND t.shipped < TIMESTAMPADD(DAY,1,CURDATE())
+ AND t.shipped < TIMESTAMPADD(DAY,1,util.VN_CURDATE())
AND a.clientFk = vClient
UNION ALL
SELECT - amountPaid
@@ -45822,7 +41613,7 @@ BEGIN
JOIN `client` c ON c.id = r.clientFk
WHERE r.bankFk = vManaBank
AND r.payed > vFromDated
- AND r.payed <= CURDATE()
+ AND r.payed <= util.VN_CURDATE()
AND c.id = vClient
UNION ALL
SELECT g.amount
@@ -45830,7 +41621,7 @@ BEGIN
JOIN `client` c ON c.id = g.clientFk
WHERE g.greugeTypeFk = vManaGreugeType
AND g.shipped > vFromDated
- AND g.shipped <= CURDATE()
+ AND g.shipped <= util.VN_CURDATE()
AND c.id = vClient
) sub;
RETURN IFNULL(vMana,0);
@@ -45840,6 +41631,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `clientGetSalesPerson` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -45847,8 +41640,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `clientGetSalesPerson`(vClientFk INT, vDated DATE) RETURNS int(11)
DETERMINISTIC
@@ -45863,6 +41654,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `clientTaxArea` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -45870,8 +41663,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `clientTaxArea`(vClientId INT, vCompanyId INT) RETURNS varchar(25) CHARSET utf8
READS SQL DATA
@@ -45911,6 +41702,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `client_getFromPhone` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -45918,8 +41711,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `client_getFromPhone`(vPhone VARCHAR(255)) RETURNS int(11)
DETERMINISTIC
@@ -45947,11 +41738,9 @@ BEGIN
WHERE phone = vPhone
OR mobile = vPhone
UNION
- SELECT r.id_cliente
- FROM vn2008.Relaciones r
- JOIN vn2008.Contactos c ON r.Id_Contacto = c.Id_Contacto
- WHERE c.telefono = vPhone
- OR c.movil = vPhone;
+ SELECT clientFk
+ FROM vn.clientContact
+ WHERE phone = vPhone;
SELECT t.clientFk INTO vClient
FROM tClient t
@@ -45968,6 +41757,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `client_getSalesPerson` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -45975,8 +41766,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `client_getSalesPerson`(vClientFk INT, vDated DATE) RETURNS int(11)
DETERMINISTIC
@@ -46022,7 +41811,7 @@ BEGIN
l: LOOP
SELECT workerSubstitute INTO vWorkerSubstituteFk
FROM sharingCart
- WHERE curdate() BETWEEN started AND ended
+ WHERE util.VN_CURDATE() BETWEEN started AND ended
AND workerFk = vSalesPersonFk
ORDER BY id
LIMIT 1;
@@ -46054,6 +41843,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `client_getSalesPersonByTicket` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -46061,8 +41852,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `client_getSalesPersonByTicket`(vTicketFk INT) RETURNS int(11)
DETERMINISTIC
@@ -46089,6 +41878,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `client_getSalesPersonCode` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -46096,8 +41887,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `client_getSalesPersonCode`(vClientFk INT, vDated DATE) RETURNS varchar(3) CHARSET utf8
DETERMINISTIC
@@ -46127,6 +41916,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `client_getSalesPersonCodeByTicket` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -46134,8 +41925,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `client_getSalesPersonCodeByTicket`(vTicketFk INT) RETURNS varchar(3) CHARSET utf8
DETERMINISTIC
@@ -46162,6 +41951,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `collectionExpeditionLacks` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -46169,8 +41960,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `collectionExpeditionLacks`(vCollectionFk INT) RETURNS varchar(100) CHARSET utf8 COLLATE utf8_unicode_ci
DETERMINISTIC
@@ -46203,6 +41992,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `currentRate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -46210,8 +42001,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `currentRate`(vCurrencyFk INT, vDated DATE) RETURNS decimal(10,4)
READS SQL DATA
@@ -46234,6 +42023,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `deviceProductionUser_accessGranted` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -46241,8 +42032,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `deviceProductionUser_accessGranted`(vUserFK INT(10) , android_id VARCHAR(50)) RETURNS tinyint(1)
DETERMINISTIC
@@ -46275,6 +42064,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `duaTax_getRate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -46282,8 +42073,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `duaTax_getRate`(vDua INT, vTaxClass INT) RETURNS decimal(5,2)
DETERMINISTIC
@@ -46299,10 +42088,11 @@ BEGIN
FROM
(SELECT taxClassFk, rate
FROM invoiceInTaxBookingAccount
- WHERE effectived <= CURDATE()
+ WHERE effectived <= util.VN_CURDATE()
AND countryFk = vCountryFk
AND taxClassFk = vTaxClass
ORDER BY effectived DESC
+ LIMIT 10000000000000000000
) ba1
GROUP BY taxClassFk);
END ;;
@@ -46311,6 +42101,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `ekt_getEntry` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -46318,8 +42110,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `ekt_getEntry`(vEktFk INT) RETURNS int(11)
READS SQL DATA
@@ -46402,6 +42192,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `ekt_getTravel` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -46409,8 +42201,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `ekt_getTravel`(vEktFk INT) RETURNS int(11)
READS SQL DATA
@@ -46501,47 +42291,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP FUNCTION IF EXISTS `entry_calcCommission__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` FUNCTION `entry_calcCommission__`(
- vCurrentCommission INT,
- vTravelFk INT,
- vCurrencyFk INT
-) RETURNS int(11)
- READS SQL DATA
-BEGIN
- -- DEPRECATED: use entry_getComission
- DECLARE vCommission INT;
-
- IF vCurrencyFk != 2 /* Dollar */ THEN
- RETURN vCurrentCommission;
- END IF;
-
- SELECT ROUND(-100 * (1 - (1 / r.rate))) INTO vCommission
- FROM travel t
- LEFT JOIN vn2008.reference_min r
- ON r.moneda_id = vCurrencyFk AND r.`date` <= t.shipped
- WHERE t.id = vTravelFk
- ORDER BY r.`date` DESC
- LIMIT 1;
-
- SET vCommission = IFNULL(vCommission, 0);
-
- RETURN vCommission;
-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 DROP FUNCTION IF EXISTS `entry_getCommission` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -46549,8 +42300,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `entry_getCommission`(
vTravelFk INT,
@@ -46612,53 +42361,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP FUNCTION IF EXISTS `entry_getCommission__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` FUNCTION `entry_getCommission__`(
- vTravelFk INT,
- vCurrencyFk INT,
- vSupplierFk INT
-) RETURNS int(11)
- READS SQL DATA
-BEGIN
- -- bernat: working in this file
- DECLARE vCommission INT;
- DECLARE vCurrentCommission INT;
- DECLARE vIsCurrencyUsd INT;
-
- SELECT count(*) INTO vIsCurrencyUsd
- FROM currency c
- WHERE c.code = 'USD' AND id = vCurrencyFk;
-
- IF NOT vIsCurrencyUsd THEN
- SELECT commission INTO vCurrentCommission
- FROM supplier s
- WHERE s.id = vSupplierFk;
- RETURN vCurrentCommission;
- END IF;
-
- SELECT ROUND(-100 * (1 - (1 / r.rate))) INTO vCommission
- FROM travel t
- LEFT JOIN vn2008.reference_min r ON r.moneda_id = vCurrencyFk AND r.`date` <= t.shipped
- WHERE t.id = vTravelFk
- ORDER BY r.`date` DESC
- LIMIT 1;
-
- RETURN IFNULL(vCommission, 0);
-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 DROP FUNCTION IF EXISTS `entry_getCurrency` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -46666,8 +42370,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `entry_getCurrency`(
vCurrency INT,
@@ -46691,6 +42393,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `entry_getForLogiflora` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -46698,8 +42402,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `entry_getForLogiflora`(vLanded DATE, vWarehouseFk INT) RETURNS int(11)
READS SQL DATA
@@ -46762,6 +42464,38 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `entry_isInventoryOrPrevious` */;
+/*!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=`root`@`localhost` FUNCTION `entry_isInventoryOrPrevious`(vSelf INT) RETURNS int(11)
+ DETERMINISTIC
+BEGIN
+ DECLARE vIsInventoryOrPrevious BOOL;
+
+ SELECT ec.inventorySupplierFk = e.supplierFk OR t.landed < c.inventoried
+ INTO vIsInventoryOrPrevious
+ FROM entry e
+ JOIN travel t ON e.travelFk = t.id
+ JOIN entryConfig ec
+ JOIN config c
+ WHERE e.id = vSelf;
+
+ RETURN vIsInventoryOrPrevious;
+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 FUNCTION IF EXISTS `expedition_checkRoute` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -46769,8 +42503,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `expedition_checkRoute`(vPalletFk INT,vExpeditionFk INT) RETURNS tinyint(1)
DETERMINISTIC
@@ -46806,6 +42538,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `firstDayOfWeek` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -46813,8 +42547,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `firstDayOfWeek`(vYear INT, vWeek INT) RETURNS date
DETERMINISTIC
@@ -46842,6 +42574,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `getAlert3State` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -46849,8 +42583,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `getAlert3State`(vTicket INT) RETURNS varchar(45) CHARSET utf8 COLLATE utf8_unicode_ci
READS SQL DATA
@@ -46892,6 +42624,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `getAlert3StateTest` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -46899,8 +42633,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `getAlert3StateTest`(vTicket INT) RETURNS varchar(45) CHARSET latin1
READS SQL DATA
@@ -46943,56 +42675,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP FUNCTION IF EXISTS `getAlert3State__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` FUNCTION `getAlert3State__`(vTicket INT) RETURNS varchar(45) CHARSET utf8 COLLATE utf8_unicode_ci
- READS SQL DATA
-BEGIN
- DECLARE vDeliveryType INTEGER DEFAULT 0;
- DECLARE isWaitingForPickUp BOOLEAN DEFAULT FALSE;
- DECLARE vCode VARCHAR(45);
-
- SELECT a.Vista
- INTO vDeliveryType
- FROM vn2008.Tickets t
- JOIN vn2008.Agencias a ON a.Id_Agencia = t.Id_Agencia
- WHERE Id_Ticket = vTicket;
-
- CASE vDeliveryType
- WHEN 1 THEN -- AGENCIAS
- SET vCode = 'DELIVERED';
-
- WHEN 2 THEN -- REPARTO
- SET vCode = 'ON_DELIVERY';
-
- ELSE -- MERCADO, OTROS
- SELECT MIN(t.warehouse_id <> w.warehouse_id) INTO isWaitingForPickUp
- FROM vn2008.Tickets t
- LEFT JOIN vn2008.warehouse_pickup w
- ON w.agency_id = t.Id_Agencia
- WHERE t.Id_Ticket = vTicket;
-
- IF isWaitingForPickUp THEN
- SET vCode = 'WAITING_FOR_PICKUP';
- ELSE
- SET vCode = 'DELIVERED';
- END IF;
- END CASE;
- RETURN vCode;
-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 DROP FUNCTION IF EXISTS `getDueDate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -47000,8 +42684,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `getDueDate`(vDated DATE, vDayToPay INT) RETURNS date
NO SQL
@@ -47021,6 +42703,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `getInventoryDate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -47028,8 +42712,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `getInventoryDate`() RETURNS date
DETERMINISTIC
@@ -47041,6 +42723,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `getNewItemId` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -47048,8 +42732,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `getNewItemId`() RETURNS int(11)
READS SQL DATA
@@ -47070,6 +42752,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `getNextDueDate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -47077,8 +42761,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `getNextDueDate`(vDated DATE, vGapDays INT, vPayDay INT) RETURNS date
NO SQL
@@ -47112,33 +42794,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP FUNCTION IF EXISTS `getPlacementReserve` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` FUNCTION `getPlacementReserve`(vItemFk INT, vWarehouseFk INT) RETURNS varchar(25) CHARSET utf8
- READS SQL DATA
-BEGIN
- DECLARE vPlacementReserve VARCHAR(25);
-
- SELECT CONCAT(IFNULL(`code`,'--'), ' / ', IFNULL(reserve,'--')) INTO vPlacementReserve
- FROM itemPlacement
- WHERE itemFk = vItemFk
- AND warehouseFk = vWarehouseFk;
-
- RETURN vPlacementReserve;
-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 DROP FUNCTION IF EXISTS `getShipmentHour` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -47146,8 +42803,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `getShipmentHour`(vTicket INT) RETURNS int(11)
READS SQL DATA
@@ -47184,6 +42839,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `getSpecialPrice` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -47191,8 +42848,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `getSpecialPrice`(vItemFk int(11),vClientFk int(11)) RETURNS decimal(10,2)
READS SQL DATA
@@ -47202,7 +42857,7 @@ BEGIN
SELECT rate3 INTO price
FROM vn.priceFixed
WHERE itemFk = vItemFk
- AND CURDATE() BETWEEN started AND ended ORDER BY created DESC LIMIT 1;
+ AND util.VN_CURDATE() BETWEEN started AND ended ORDER BY created DESC LIMIT 1;
SELECT `value` INTO price
FROM vn.specialPrice
@@ -47215,6 +42870,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `getTicketToPrepare` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -47222,8 +42879,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `getTicketToPrepare`(`vWorker` INT, `vWarehouse` INT) RETURNS int(11)
READS SQL DATA
@@ -47239,7 +42894,7 @@ BEGIN
* #PENDING REVIEW
**/
- DECLARE vToday DATETIME DEFAULT CURDATE();
+ DECLARE vToday DATETIME DEFAULT util.VN_CURDATE();
DECLARE vYesterday DATETIME;
DECLARE vTodayvMidniight DATETIME DEFAULT midnight(vToday);
DECLARE vTicket INT DEFAULT NULL;
@@ -47256,10 +42911,10 @@ BEGIN
FROM vn.sale s
JOIN vn.saleTracking st ON st.saleFk = s.id
JOIN vn.ticketStateToday tst ON tst.ticket = s.ticketFk
- WHERE st.created > CURDATE()
+ WHERE st.created > util.VN_CURDATE()
-- AND tst.`code` = 'ON_PREPARATION'
) sub ON sub.ticketFk = i.Id_Ticket
- WHERE odbc_date > CURDATE()
+ WHERE odbc_date > util.VN_CURDATE()
AND s.`code` = 'ON_PREPARATION'
AND i.Id_Trabajador = vWorker
AND sub.ticketFk IS NULL
@@ -47345,6 +43000,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `getTicketTrolleyLabelCount` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -47352,8 +43009,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `getTicketTrolleyLabelCount`(vTicket INT) RETURNS int(11)
READS SQL DATA
@@ -47376,6 +43031,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `getUser` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -47383,8 +43040,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `getUser`() RETURNS int(11)
DETERMINISTIC
@@ -47392,13 +43047,15 @@ BEGIN
/**
* @deprecated Use account.userGetId()
*/
- RETURN account.userGetId();
+ RETURN account.myUser_getId();
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 FUNCTION IF EXISTS `getUserId` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -47406,8 +43063,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `getUserId`(userName varchar(30)) RETURNS int(11)
READS SQL DATA
@@ -47426,6 +43081,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `getWorkerCode` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -47433,8 +43090,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `getWorkerCode`() RETURNS varchar(3) CHARSET utf8
READS SQL DATA
@@ -47443,7 +43098,7 @@ BEGIN
SELECT code INTO vUserCode
FROM worker
- WHERE userFk = account.userGetId();
+ WHERE userFk = account.myUser_getId();
RETURN vUserCode;
END ;;
@@ -47452,35 +43107,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP FUNCTION IF EXISTS `getWorker__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` FUNCTION `getWorker__`() RETURNS int(11)
- DETERMINISTIC
-BEGIN
-/**
- * @deprecated Use myWorker_getId()
- */
- DECLARE vUser INT;
-
- SELECT id INTO vUser
- FROM worker
- WHERE userFk = account.userGetId();
-
- RETURN vUser;
-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 DROP FUNCTION IF EXISTS `hasAnyNegativeBase` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -47488,8 +43116,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `hasAnyNegativeBase`() RETURNS tinyint(1)
DETERMINISTIC
@@ -47530,56 +43156,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP FUNCTION IF EXISTS `hasAnyNegativeBase__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` FUNCTION `hasAnyNegativeBase__`() RETURNS tinyint(1)
- DETERMINISTIC
-BEGIN
-
-/* Calcula si existe alguna base imponible negativa
-* Requiere la tabla temporal vn.ticketToInvoice(id)
-*
-* returns BOOLEAN
-*/
-
- DECLARE vCountry INT;
- DECLARE hasAnyNegativeBase BOOLEAN;
-
- SELECT s.countryFk
- INTO vCountry
- FROM supplier s
- JOIN ticket t ON t.companyFk = s.id
- JOIN vn.ticketToInvoice tl ON tl.id = t.id
- LIMIT 1;
-
- SELECT COUNT(*) INTO hasAnyNegativeBase
- FROM (
- SELECT SUM(ROUND(s.quantity * s.price * (100 - s.discount)/100,2)) taxableBase
- FROM sale s
- JOIN item i ON i.id = s.itemFk
- JOIN itemTaxCountry itc
- ON itc.itemFk = i.id AND itc.countryFk = vCountry
- JOIN vn.ticketToInvoice tl ON tl.id = s.ticketFk
- GROUP BY itc.taxClassFk
- HAVING taxableBase < 0
- ) t1 ;
-
- RETURN hasAnyNegativeBase;
-
-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 DROP FUNCTION IF EXISTS `hasItemsInSector` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -47587,8 +43165,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `hasItemsInSector`(vTicketFk INT, vSectorFk INT) RETURNS tinyint(1)
DETERMINISTIC
@@ -47612,6 +43188,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `hasSomeNegativeBase` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -47619,8 +43197,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `hasSomeNegativeBase`(vTicket INT) RETURNS tinyint(1)
READS SQL DATA
@@ -47653,6 +43229,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `invoiceOutAmount` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -47660,8 +43238,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `invoiceOutAmount`(vInvoiceRef VARCHAR(15)) RETURNS decimal(10,2)
READS SQL DATA
@@ -47682,12 +43258,48 @@ BEGIN
) t1;
RETURN totalAmount;
+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 FUNCTION IF EXISTS `invoiceOutAmount` */;
+/*!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=`root`@`localhost` FUNCTION `invoiceOut_getWeight`(vInvoice VARCHAR(15)) RETURNS decimal(10,2)
+ READS SQL DATA
+BEGIN
+ DECLARE vTotalWeight DECIMAL(10,2);
+
+ SELECT SUM(CAST(IFNULL(i.stems, 1) * s.quantity *
+ IF(ic.grams, ic.grams, i.density * ic.cm3delivery / 1000)
+ / 1000 AS DECIMAL(10,2)))
+ INTO vTotalWeight
+ FROM ticket t
+ JOIN sale s ON s.ticketFk = t.id
+ JOIN item i ON i.id = s.itemFk
+ JOIN itemCost ic ON ic.itemFk = i.id
+ AND ic.warehouseFk = t.warehouseFk
+ WHERE t.refFk = vInvoice
+ AND i.intrastatFk ;
+
+ RETURN vTotalWeight;
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 FUNCTION IF EXISTS `invoiceOut_getPath` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -47695,8 +43307,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `invoiceOut_getPath`(vSelf INT) RETURNS varchar(255) CHARSET utf8
DETERMINISTIC
@@ -47721,6 +43331,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `invoiceSerial` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -47728,8 +43340,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `invoiceSerial`(vClientFk INT, vCompanyFk INT, vType CHAR(1)) RETURNS char(1) CHARSET utf8
DETERMINISTIC
@@ -47759,6 +43369,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `invoiceSerialArea` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -47766,8 +43378,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `invoiceSerialArea`(vType CHAR(1), vTaxArea VARCHAR(25)) RETURNS char(1) CHARSET utf8 COLLATE utf8_unicode_ci
DETERMINISTIC
@@ -47818,6 +43428,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `isIntrastatEntry` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -47825,8 +43437,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `isIntrastatEntry`(vEntryFk INT) RETURNS int(11)
READS SQL DATA
@@ -47861,6 +43471,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `isLogifloraDay` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -47868,8 +43480,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `isLogifloraDay`(vShipped DATE, vWarehouse INT) RETURNS tinyint(1)
DETERMINISTIC
@@ -47892,6 +43502,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `isPalletHomogeneus` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -47899,8 +43511,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `isPalletHomogeneus`(vExpedition INT) RETURNS tinyint(1)
READS SQL DATA
@@ -47930,6 +43540,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `itemPacking` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -47937,8 +43549,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `itemPacking`(vBarcode VARCHAR(22), vWarehouseFk INT) RETURNS int(11)
DETERMINISTIC
@@ -47983,34 +43593,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP FUNCTION IF EXISTS `itemPlacementGet` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` FUNCTION `itemPlacementGet`(vItemFk INT, vWarehouseFk INT) RETURNS varchar(25) CHARSET utf8
- READS SQL DATA
-BEGIN
- DECLARE vPlacementReserve VARCHAR(25);
-
- SELECT CONCAT(IFNULL(`code`,'--'), ' / ', IFNULL(reserve,'--'))
- INTO vPlacementReserve
- FROM itemPlacement
- WHERE itemFk = vItemFk
- AND warehouseFk = vWarehouseFk;
-
- RETURN vPlacementReserve;
-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 DROP FUNCTION IF EXISTS `itemShelvingPlacementSupply_ClosestGet` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -48018,8 +43602,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `itemShelvingPlacementSupply_ClosestGet`(vParkingFk INT) RETURNS int(11)
READS SQL DATA
@@ -48055,6 +43637,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `itemsInSector_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -48062,8 +43646,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `itemsInSector_get`(vTicketFk INT, vSectorFk INT) RETURNS int(11)
READS SQL DATA
@@ -48087,6 +43669,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `itemTag_getIntValue` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -48094,8 +43678,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `itemTag_getIntValue`(vValue VARCHAR(255)) RETURNS int(11)
DETERMINISTIC
@@ -48111,6 +43693,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `item_getFhImage` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -48118,8 +43702,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `item_getFhImage`(itemFk INT) RETURNS varchar(255) CHARSET utf8 COLLATE utf8_unicode_ci
DETERMINISTIC
@@ -48140,6 +43722,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `item_getPackage` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -48147,8 +43731,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `item_getPackage`(vItemFk INT) RETURNS varchar(50) CHARSET utf8 COLLATE utf8_unicode_ci
DETERMINISTIC
@@ -48182,6 +43764,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `item_getVolume` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -48189,8 +43773,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `item_getVolume`(vSelf INT, vPackaging VARCHAR(10)) RETURNS int(11)
DETERMINISTIC
@@ -48221,6 +43803,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `lastDayOfWeek` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -48228,8 +43812,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `lastDayOfWeek`(vYear INT, vWeek INT) RETURNS date
DETERMINISTIC
@@ -48257,41 +43839,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP FUNCTION IF EXISTS `machineWorker_Worker` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` FUNCTION `machineWorker_Worker`(vWorkerFk VARCHAR(10)) RETURNS varchar(20) CHARSET utf8 COLLATE utf8_unicode_ci
- READS SQL DATA
-BEGIN
-/**
- * Comprueba si existen registros en las últimas 12 horas del trabajador vWorkerFk y si tiene a nulo la hora outTimed (indica la hora que deja el vehículo)
- *
- * @param vWorkerFk id del trabajador
- * @return Devuelve REGISTERED/UNREGISTERED en caso de que haya registros
- */
-
- IF (SELECT COUNT(*)
- FROM machineWorker m
- WHERE m.workerFk = vWorkerFk
- AND m.inTimed >= TIMESTAMPADD(HOUR , -12,NOW()) AND ISNULL(m.outTimed))
- THEN
- RETURN "REGISTERED";
- ELSE
- RETURN "UNREGISTERED";
- 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 DROP FUNCTION IF EXISTS `machine_checkPlate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -48299,8 +43848,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `machine_checkPlate`(vPlate VARCHAR(10)) RETURNS tinyint(1)
READS SQL DATA
@@ -48327,6 +43874,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `messageSend` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -48334,8 +43883,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `messageSend`(vRecipient VARCHAR(255) CHARSET utf8, vMessage TEXT CHARSET utf8) RETURNS int(11)
READS SQL DATA
@@ -48344,7 +43891,7 @@ BEGIN
DECLARE vSenderFk INT;
SELECT id INTO vSenderFk
- FROM account.user WHERE `name` = account.userGetName();
+ FROM account.user WHERE `name` = account.myUser_getName();
RETURN (SELECT messageSendWithUser(vSenderFk, vRecipient, vMessage));
END ;;
@@ -48353,6 +43900,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `messageSendWithUser` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -48360,8 +43909,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `messageSendWithUser`(vSenderFK INT, vRecipient VARCHAR(255) CHARSET utf8, vMessage TEXT CHARSET utf8) RETURNS int(11)
DETERMINISTIC
@@ -48369,7 +43916,7 @@ BEGIN
DECLARE vCount INT;
DECLARE vUuid VARCHAR(255);
- DECLARE vSendDate DATETIME DEFAULT NOW();
+ DECLARE vSendDate DATETIME DEFAULT util.VN_NOW();
DECLARE vSender VARCHAR(255) CHARSET utf8;
SELECT `name` INTO vSender
@@ -48418,6 +43965,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `MIDNIGHT` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -48425,8 +43974,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `MIDNIGHT`(vDate DATE) RETURNS datetime
DETERMINISTIC
@@ -48438,38 +43985,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP FUNCTION IF EXISTS `myWorker_getId__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` FUNCTION `myWorker_getId__`() RETURNS int(11)
- DETERMINISTIC
-BEGIN
-/**
- * Returns the current worker id or the default worker id
- * if current user cannot be retrieved.
- *
- * @return The worker id
- */
- DECLARE vWorker INT;
-
- SELECT w.id INTO vWorker
- FROM worker w, workerConfig__ c
- WHERE w.userFk = account.userGetId();
-
- RETURN vWorker;
-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 DROP FUNCTION IF EXISTS `nz` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -48477,8 +43994,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `nz`(vQuantity DOUBLE) RETURNS double
DETERMINISTIC
@@ -48496,6 +44011,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `orderTotalVolume` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -48503,8 +44020,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `orderTotalVolume`(vOrderId INT) RETURNS decimal(10,3)
READS SQL DATA
@@ -48527,6 +44042,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `orderTotalVolumeBoxes` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -48534,8 +44051,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `orderTotalVolumeBoxes`(vOrderId INT) RETURNS decimal(10,3)
READS SQL DATA
@@ -48563,6 +44078,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `phytoPassport` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -48570,8 +44087,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `phytoPassport`(vRef VARCHAR(15)) RETURNS text CHARSET utf8
DETERMINISTIC
@@ -48614,10 +44129,13 @@ WHERE
RETURN vPhyto;
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 FUNCTION IF EXISTS `routeProposal` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -48625,8 +44143,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `routeProposal`(vTicketFk INT) RETURNS int(11)
READS SQL DATA
@@ -48684,6 +44200,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `routeProposal_` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -48691,8 +44209,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `routeProposal_`(vTicketFk INT) RETURNS int(11)
READS SQL DATA
@@ -48725,6 +44241,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `routeProposal_beta` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -48732,8 +44250,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `routeProposal_beta`(vTicketFk INT) RETURNS int(11)
READS SQL DATA
@@ -48791,6 +44307,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `specie_IsForbidden` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -48798,8 +44316,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `specie_IsForbidden`(vItemFk INT, vAddressFk INT) RETURNS tinyint(1)
READS SQL DATA
@@ -48830,6 +44346,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `testCIF` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -48837,8 +44355,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `testCIF`(vCIF VARCHAR(9)) RETURNS varchar(10) CHARSET utf8 COLLATE utf8_unicode_ci
DETERMINISTIC
@@ -48915,6 +44431,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `testNIE` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -48922,8 +44440,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `testNIE`(vNIE VARCHAR(9)) RETURNS tinyint(1)
DETERMINISTIC
@@ -48982,6 +44498,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `testNIF` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -48989,8 +44507,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `testNIF`(vNIF VARCHAR(9)) RETURNS tinyint(1)
DETERMINISTIC
@@ -49023,6 +44539,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `ticketGetTotal` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -49030,8 +44548,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `ticketGetTotal`(vTicketId INT) RETURNS decimal(10,2)
READS SQL DATA
@@ -49066,6 +44582,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `ticketPositionInPath` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -49073,8 +44591,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `ticketPositionInPath`(vTicketId INT) RETURNS varchar(10) CHARSET utf8
DETERMINISTIC
@@ -49157,6 +44673,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `ticketSplitCounter` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -49164,18 +44682,16 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `ticketSplitCounter`(vTicketFk INT) RETURNS varchar(15) CHARSET utf8
READS SQL DATA
BEGIN
DECLARE vSplitCounter VARCHAR(15);
- SELECT CONCAT(OK,'/',Total, IF(OK = Total ,' LS','')) INTO vSplitCounter
+ SELECT CONCAT(printedStickers,'/',Total, IF(printedStickers = Total ,' LS','')) INTO vSplitCounter
FROM
(
- SELECT count(l.Id_Movimiento) as OK, COUNT(*) as Total
+ SELECT count(l.Id_Movimiento) as printedStickers, COUNT(*) as Total
FROM vn.sale s
LEFT JOIN vn2008.movement_label l ON l.Id_Movimiento = s.id
WHERE ticketFk = vTicketFk
@@ -49189,6 +44705,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `ticketTotalVolume` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -49196,8 +44714,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `ticketTotalVolume`(vTicketId INT) RETURNS decimal(10,3)
READS SQL DATA
@@ -49217,6 +44733,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `ticketTotalVolumeBoxes` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -49224,8 +44742,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `ticketTotalVolumeBoxes`(vTicketId INT) RETURNS decimal(10,1)
DETERMINISTIC
@@ -49254,6 +44770,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `ticketWarehouseGet` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -49261,8 +44779,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `ticketWarehouseGet`(vTicketFk INT) RETURNS int(11)
READS SQL DATA
@@ -49280,6 +44796,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `ticket_CC_volume` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -49287,8 +44805,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `ticket_CC_volume`(vTicketFk INT) RETURNS decimal(10,1)
READS SQL DATA
@@ -49313,6 +44829,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `ticket_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -49320,8 +44838,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `ticket_get`(vParamFk INT) RETURNS int(11)
READS SQL DATA
@@ -49341,7 +44857,7 @@ proc:BEGIN
JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id
JOIN vn.saleGroup sg ON sg.id = sgd.saleGroupFk
WHERE sg.id = vParamFk
- AND sg.created > TIMESTAMPADD(WEEK,-1, CURDATE())
+ AND sg.created > TIMESTAMPADD(WEEK,-1, util.VN_CURDATE())
LIMIT 1;
IF vValidFk THEN
@@ -49356,7 +44872,7 @@ proc:BEGIN
SELECT c.id INTO vValidFk
FROM vn.collection c
WHERE c.id = vParamFk
- AND c.created > TIMESTAMPADD(WEEK,-1, CURDATE());
+ AND c.created > TIMESTAMPADD(WEEK,-1, util.VN_CURDATE());
IF vValidFk THEN
@@ -49370,7 +44886,7 @@ proc:BEGIN
SELECT t.id INTO vValidFk
FROM vn.ticket t
WHERE t.id = vParamFk
- AND t.shipped > TIMESTAMPADD(WEEK,-1, CURDATE());
+ AND t.shipped > TIMESTAMPADD(WEEK,-1, util.VN_CURDATE());
IF vValidFk THEN
@@ -49388,6 +44904,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `ticket_getFreightCost` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -49395,8 +44913,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `ticket_getFreightCost`(vTicketFk INT) RETURNS decimal(10,2)
DETERMINISTIC
@@ -49428,6 +44944,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `ticket_getWeight` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -49435,8 +44953,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `ticket_getWeight`(vTicketFk INT) RETURNS decimal(10,3)
READS SQL DATA
@@ -49461,6 +44977,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `ticket_getWithParameters` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -49468,8 +44986,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `ticket_getWithParameters`(vClientFk INT, vWarehouseFk INT, vShipped DATE, vAddressFk INT, vCompanyFk INT, vAgencyModeFk INT) RETURNS int(11)
DETERMINISTIC
@@ -49500,7 +45016,7 @@ BEGIN
IF vTicket IS NULL THEN
CALL vn.ticket_add(
vClientFk,
- IFNULL(vShipped, CURDATE()),
+ IFNULL(vShipped, util.VN_CURDATE()),
vWarehouseFk,
vCompanyFk,
vAddressFk,
@@ -49520,6 +45036,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `ticket_HasUbication` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -49527,8 +45045,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `ticket_HasUbication`(vTicketFk INT) RETURNS tinyint(1)
READS SQL DATA
@@ -49550,6 +45066,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `till_new` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -49557,8 +45075,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `till_new`(
vClient INT
@@ -49642,6 +45158,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `timeWorkerControl_getDirection` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -49649,8 +45167,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `timeWorkerControl_getDirection`(vUserFk INT, vTimed DATETIME) RETURNS varchar(6) CHARSET utf8 COLLATE utf8_unicode_ci
READS SQL DATA
@@ -49718,6 +45234,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `time_getSalesYear` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -49725,8 +45243,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `time_getSalesYear`(vMonth INT, vYear INT) RETURNS int(11)
DETERMINISTIC
@@ -49743,6 +45259,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `travel_getForLogiflora` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -49750,8 +45268,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `travel_getForLogiflora`(vLanded DATE, vWarehouseFk INT) RETURNS int(11)
READS SQL DATA
@@ -49782,7 +45298,7 @@ BEGIN
IF NOT vTravelFk THEN
INSERT INTO vn.travel(landed, shipped, warehouseInFk, warehouseOutFk, agencyFk)
- SELECT vLanded, curdate(), vWarehouseFk, wOut.id, am.id
+ SELECT vLanded, util.VN_CURDATE(), vWarehouseFk, wOut.id, am.id
FROM vn.warehouse wOut
JOIN vn.agencyMode am ON am.name = 'LOGIFLORA'
WHERE wOut.name = 'Holanda';
@@ -49806,6 +45322,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `validationCode` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -49813,8 +45331,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `validationCode`(vString VARCHAR(255)) RETURNS int(11)
DETERMINISTIC
@@ -49847,6 +45363,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `validationCode_beta` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -49854,8 +45372,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `validationCode_beta`(vString VARCHAR(255)) RETURNS int(11)
DETERMINISTIC
@@ -49888,6 +45404,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `workerIsBoss` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -49895,8 +45413,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `workerIsBoss`(vUserId INT) RETURNS int(11)
DETERMINISTIC
@@ -49947,6 +45463,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `workerMachinery_isRegistered` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -49954,8 +45472,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `workerMachinery_isRegistered`(vWorkerFk VARCHAR(10)) RETURNS tinyint(1)
READS SQL DATA
@@ -49970,7 +45486,7 @@ BEGIN
IF (SELECT COUNT(*)
FROM machineWorker m
WHERE m.workerFk = vWorkerFk
- AND m.inTimed >= TIMESTAMPADD(HOUR , -(SELECT maxHours from machineWorkerConfig), NOW()) AND ISNULL(m.outTimed))
+ AND m.inTimed >= TIMESTAMPADD(HOUR , -(SELECT maxHours from machineWorkerConfig), util.VN_NOW()) AND ISNULL(m.outTimed))
THEN
RETURN TRUE;
ELSE
@@ -49983,6 +45499,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `workerNigthlyHours_calculate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -49990,8 +45508,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `workerNigthlyHours_calculate`(vTimeIn DATETIME, vTimeOut DATETIME) RETURNS decimal(5,2)
READS SQL DATA
@@ -50022,6 +45538,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `workerTimeControl_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -50029,8 +45547,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `workerTimeControl_add`( vUserFk INT, vWarehouseFk INT, vTimed DATETIME, vIsManual BOOL) RETURNS int(11)
DETERMINISTIC
@@ -50091,6 +45607,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `workerTimeControl_addDirection` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -50098,8 +45616,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `workerTimeControl_addDirection`( vUserFk INT, vWarehouseFk INT, vTimed DATETIME, vIsManual BOOL) RETURNS int(11)
DETERMINISTIC
@@ -50160,6 +45676,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `worker_isWorking` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -50167,8 +45685,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `worker_isWorking`(vWorkerFk INT) RETURNS tinyint(1)
READS SQL DATA
@@ -50199,6 +45715,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `xdiario_new` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -50206,8 +45724,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `xdiario_new`(
vAsiento INT,
@@ -50255,6 +45771,8 @@ DELIMITER ;
/*!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 FUNCTION IF EXISTS `zoneGeo_new` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -50262,8 +45780,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `zoneGeo_new`(vType VARCHAR(255), vName VARCHAR(255), vParentFk INT) RETURNS int(11)
NO SQL
@@ -50295,6 +45811,8 @@ DELIMITER ;
/*!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 `addNoteFromDelivery` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -50302,8 +45820,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `addNoteFromDelivery`(idTicket INT,nota TEXT)
BEGIN
@@ -50321,6 +45837,8 @@ DELIMITER ;
/*!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 `addressTaxArea` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -50328,8 +45846,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `addressTaxArea`()
READS SQL DATA
@@ -50369,6 +45885,8 @@ DELIMITER ;
/*!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 `agencyHourGetFirstShipped` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -50376,8 +45894,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `agencyHourGetFirstShipped`(vAgencyMode INT, vAddress INT, vWarehouse INT)
BEGIN
@@ -50392,7 +45908,7 @@ BEGIN
*/
DECLARE vAgency INT;
DECLARE vShipped DATE;
-DECLARE vLanded DATE DEFAULT CURDATE();
+DECLARE vLanded DATE DEFAULT util.VN_CURDATE();
SELECT agencyFk INTO vAgency FROM agencyMode WHERE id= vAgencyMode;
l: LOOP
@@ -50417,6 +45933,8 @@ DELIMITER ;
/*!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 `agencyHourGetLanded` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -50424,8 +45942,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `agencyHourGetLanded`(vDated DATE, vAddress INT, vAgency INT, vWarehouse INT)
BEGIN
@@ -50459,7 +45975,7 @@ BEGIN
) t
LIMIT 1
) t
- WHERE IF(vDated = CURDATE(), t.maxHour > HOUR(NOW()), TRUE) AND t.substractDay < 225;
+ WHERE IF(vDated = util.VN_CURDATE(), t.maxHour > HOUR(util.VN_NOW()), TRUE) AND t.substractDay < 225;
END ;;
DELIMITER ;
@@ -50467,6 +45983,8 @@ DELIMITER ;
/*!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 `agencyHourGetWarehouse` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -50474,8 +45992,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `agencyHourGetWarehouse`(vAddress INT, vDate DATE, vWarehouse INT)
BEGIN
@@ -50535,8 +46051,8 @@ BEGIN
AND (ah.provinceFk = a.provinceFk
OR ah.provinceFk IS NULL
OR vAddress IS NULL)
- AND TIMESTAMPADD(DAY, -ah.substractDay, vDate) >= CURDATE()
- AND IF(TIMESTAMPADD(DAY, -ah.substractDay, vDate) = CURDATE(), ah.maxHour > HOUR(NOW()), TRUE)
+ AND TIMESTAMPADD(DAY, -ah.substractDay, vDate) >= util.VN_CURDATE()
+ AND IF(TIMESTAMPADD(DAY, -ah.substractDay, vDate) = util.VN_CURDATE(), ah.maxHour > HOUR(util.VN_NOW()), TRUE)
ORDER BY (
(ah.weekDay IS NOT NULL) +
(ah.agencyFk IS NOT NULL) +
@@ -50558,6 +46074,8 @@ DELIMITER ;
/*!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 `agencyHourListGetShipped` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -50565,8 +46083,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `agencyHourListGetShipped`(vDate DATE, vAddress INT, vAgency INT)
BEGIN
@@ -50584,40 +46100,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `agencyVolume__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `agencyVolume__`(vDated DATE, vAgency INT)
-BEGIN
-
- SELECT ELT(it.temperature + 1,'Calientes','Frios','Secos') AS Temp,
- CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) *
- vn.item_getVolume(b.itemFk ,b.packageFk)) / vc.carro / 1000000 ,1) AS DECIMAL(10,2)) AS carros ,
- CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) *
- vn.item_getVolume(b.itemFk ,b.packageFk)) / vc.espai / 1000000,1) AS DECIMAL(10,2)) AS espais
- FROM vn.buy b
- INNER JOIN vn.entry e ON e.id = b.entryFk
- INNER JOIN vn.travel tr ON tr.id = e.travelFk
- INNER JOIN vn.volumeConfig vc
- INNER JOIN vn.item i ON i.id = b.itemFk
- INNER JOIN vn.itemType it ON it.id = i.typeFk
- WHERE tr.landed = vDated
- AND tr.agencyFk IN (0, vAgency)
- GROUP BY Temp;
-
-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 DROP PROCEDURE IF EXISTS `available_calc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -50625,8 +46109,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `available_calc`(
vDate DATE,
@@ -50688,76 +46170,40 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `available_calc__` */;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `bankEntity_checkBic` */;
/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `available_calc__`(
- vDate DATE,
- vAddress INT,
- vAgencyMode INT)
+CREATE DEFINER=`root`@`localhost` PROCEDURE `bankEntity_checkBic`(vBic VARCHAR(255))
BEGIN
-/**
- * Calculates the available for all available stores
- * according to the given parameters.
- *
- * @param vDate The delivery date
- * @param vAddress The delivery address id
- * @param vAgencyMode The shipping agency
- * @return tmp.availableCalc(calcFk) The available cache ids
- */
- DECLARE vCalcFk INT;
- DECLARE vShipment DATE;
- DECLARE vWarehouse INT;
- DECLARE vDone BOOL;
+ /**
+ * If the bic length is Incorrect throw exception
+ *
+ * @param vBic bic code
+ */
- DECLARE cWarehouses CURSOR FOR
- SELECT warehouseFk, shipped FROM tmp.zoneGetShipped;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND
- SET vDone = TRUE;
+ DECLARE vConfigBicLenght INT;
- -- Establecemos los almacenes y las fechas que van a entrar al disponible
-
- CALL vn.zone_getShippedWarehouse(vDate, vAddress, vAgencyMode);
-
- DROP TEMPORARY TABLE IF EXISTS tmp.availableCalc;
- CREATE TEMPORARY TABLE tmp.availableCalc(
- calcFk INT UNSIGNED,
- PRIMARY KEY (calcFk)
- )
- ENGINE = MEMORY;
-
- OPEN cWarehouses;
-
- l: LOOP
- SET vDone = FALSE;
- FETCH cWarehouses INTO vWarehouse, vShipment;
-
- IF vDone THEN
- LEAVE l;
- END IF;
-
- CALL `cache`.available_refresh(vCalcFk, FALSE, vWarehouse, vShipment);
-
- INSERT IGNORE INTO tmp.availableCalc
- SET calcFk = vCalcFk;
- END LOOP;
-
- CLOSE cWarehouses;
- DROP TEMPORARY TABLE tmp.zoneGetShipped;
+ SELECT bicLength INTO vConfigBicLenght
+ FROM vn.bankEntityConfig bec;
+
+ IF LENGTH(vBic) <> vConfigBicLenght THEN
+ CALL util.throw(CONCAT('bic must be of length ', vConfigBicLenght ));
+ 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_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `bankPolicy_notifyExpired` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -50765,8 +46211,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `bankPolicy_notifyExpired`()
BEGIN
@@ -50786,13 +46230,15 @@ BEGIN
ON s.id = bp.supplierFk
LEFT JOIN vn.bank b
ON b.id = bp.bankFk
- WHERE bp.insuranceExpired = CURDATE();
+ WHERE bp.insuranceExpired = util.VN_CURDATE();
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 `buyUltimate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -50800,8 +46246,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `buyUltimate`(vWarehouseFk SMALLINT, vDated DATE)
BEGIN
@@ -50823,7 +46267,7 @@ BEGIN
FROM cache.last_buy
WHERE warehouse_id = vWarehouseFk OR vWarehouseFk IS NULL;
- CALL buyUltimateFromInterval(vWarehouseFk, CURDATE(), vDated);
+ CALL buyUltimateFromInterval(vWarehouseFk, util.VN_CURDATE(), vDated);
REPLACE INTO tmp.buyUltimate
SELECT itemFk, buyFk, warehouseFk, landed landing
@@ -50843,6 +46287,8 @@ DELIMITER ;
/*!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 `buyUltimateFromInterval` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -50850,8 +46296,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `buyUltimateFromInterval`(vWarehouseFk SMALLINT, vStarted DATE, vEnded DATE)
BEGIN
@@ -50980,57 +46424,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `buyUltimate__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `buyUltimate__`(vWarehouseFk SMALLINT, vDated DATE)
-BEGIN
-/**
- * Calcula las �ltimas compras realizadas hasta una fecha
- *
- * @param vWarehouseFk Id del almacén
- * @param vDated Compras hasta fecha
- * @return tmp.buyUltimate
- */
- CALL cache.last_buy_refresh (FALSE);
-
- DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimate;
- CREATE TEMPORARY TABLE tmp.buyUltimate
- (PRIMARY KEY (itemFk, warehouseFk),
- INDEX(itemFk))
- ENGINE = MEMORY
- SELECT item_id itemFk, buy_id buyFk, warehouse_id warehouseFk
- FROM cache.last_buy
- WHERE warehouse_id = vWarehouseFk OR vWarehouseFk IS NULL;
-
- CALL buyUltimateFromInterval(vWarehouseFk, CURDATE(), vDated);
-
- REPLACE INTO tmp.buyUltimate
- SELECT itemFk, buyFk, warehouseFk
- FROM tmp.buyUltimateFromInterval
- WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL)
- AND landed <= vDated;
-
- INSERT IGNORE INTO tmp.buyUltimate
- SELECT itemFk, buyFk, warehouseFk
- FROM tmp.buyUltimateFromInterval
- WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL)
- AND landed > vDated;
-
- DROP TEMPORARY TABLE tmp.buyUltimateFromInterval;
-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 DROP PROCEDURE IF EXISTS `buy_afterUpsert` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -51038,8 +46433,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_afterUpsert`(vSelf INT)
BEGIN
@@ -51109,6 +46502,8 @@ DELIMITER ;
/*!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 `buy_checkGrouping` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -51116,8 +46511,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_checkGrouping`(vGrouping INT)
BEGIN
@@ -51136,6 +46529,138 @@ DELIMITER ;
/*!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 `buy_getSplit` */;
+/*!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=`root`@`localhost` PROCEDURE `buy_getSplit`(vSelf INT, vDated DATE)
+BEGIN
+/**
+ * Devuelve las ventas de una compra
+ *
+ * @param vSelf Identificador de vn.buy
+ */
+ DECLARE vItemFk INT;
+ DECLARE vPacking INT;
+ DECLARE vRemaining INT;
+ DECLARE vLabels INT;
+ DECLARE vSaleFk INT;
+ DECLARE vAmount INT;
+ DECLARE vDone BOOL DEFAULT FALSE;
+
+ DECLARE cur CURSOR FOR
+ SELECT s.id, s.quantity - IFNULL(l.stem, 0)
+ FROM vn.sale s
+ JOIN vn.ticket t ON t.id = s.ticketFk
+ JOIN vn.warehouse w ON w.id = t.warehouseFk
+ LEFT JOIN vn.saleLabel l ON l.saleFk = s.id
+ WHERE s.itemFk = vItemFk
+ AND t.shipped >= vDated
+ AND w.isLogiflora
+ AND IFNULL(l.stem, 0) < s.quantity
+ LOCK IN SHARE MODE;
+
+ DECLARE CONTINUE HANDLER FOR NOT FOUND
+ SET vDone = TRUE;
+
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ ROLLBACK;
+ RESIGNAL;
+ END;
+
+ START TRANSACTION;
+
+ -- Obtiene los datos de la compra
+
+ SELECT itemFk, packing, quantity
+ INTO vItemFk, vPacking, vRemaining
+ FROM vn.buy WHERE id = vSelf;
+
+ -- Crea splits de los tickets
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.split;
+ CREATE TEMPORARY TABLE tmp.split
+ (
+ id INT,
+ labels INT
+ )
+ ENGINE = MEMORY;
+
+ OPEN cur;
+
+ l: LOOP
+ SET vDone = FALSE;
+
+ FETCH cur INTO vSaleFk, vAmount;
+
+ IF vDone OR vRemaining = 0 THEN
+ LEAVE l;
+ END IF;
+
+ SET vAmount = LEAST(vAmount, vRemaining);
+
+ SET vRemaining = vRemaining - vAmount;
+
+ SET vLabels = vAmount DIV vPacking;
+
+ INSERT INTO tmp.split
+ VALUES (vSaleFk, vLabels);
+
+ INSERT INTO vn.saleLabel
+ SET
+ saleFk = vSaleFk,
+ stem = vAmount,
+ label = vLabels
+ ON DUPLICATE KEY UPDATE
+ stem = stem + VALUES(stem),
+ label = label + VALUES(label);
+
+ END LOOP;
+
+ CLOSE cur;
+
+ -- Devuelve los splits creados
+ SELECT
+ sp.labels,
+ COALESCE(sfc.nickname, sfa.nickname, a.nickname) destination,
+ s.itemFk,
+ i.longName,
+ i.`size`,
+ vn.ticketSplitCounter(t.id) counter,
+ IF(sfa.id OR sfc.id,
+ a.nickname,
+ CONCAT(a.id, ' ', p.`name`,' (', c.`code`,')')) destination2
+ FROM tmp.split sp
+ JOIN vn.sale s ON sp.id = s.id
+ JOIN vn.item i ON i.id = s.itemFk
+ JOIN vn.ticket t ON t.id = s.ticketFk
+ JOIN vn.address a ON a.id = t.addressFk
+ JOIN vn.province p ON p.id = a.provinceFk
+ JOIN vn.country c ON c.id = p.countryFk
+ LEFT JOIN vn.splitFilter sfa ON sfa.autonomyFk = p.autonomyFk
+ LEFT JOIN vn.splitFilter sfc ON sfc.clientFk = t.clientFk;
+
+ -- Limpia y confirma cambios
+
+ DROP TEMPORARY TABLE
+ tmp.split;
+
+ COMMIT;
+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 `buy_getVolume` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -51143,8 +46668,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_getVolume`()
BEGIN
@@ -51170,6 +46693,8 @@ DELIMITER ;
/*!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 `buy_getVolumeByAgency` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -51177,8 +46702,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_getVolumeByAgency`(vDated DATE, vAgencyFk INT)
BEGIN
@@ -51203,6 +46726,8 @@ DELIMITER ;
/*!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 `buy_getVolumeByEntry` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -51210,8 +46735,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_getVolumeByEntry`(vEntryFk INT)
BEGIN
@@ -51234,49 +46757,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `buy_notifyPassport__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_notifyPassport__`(
- IN vBuyFk INT,
- IN vItemFk INT,
- IN vStickers SMALLINT,
- IN vPacking SMALLINT
-)
-BEGIN
- /*INSERT INTO vn.mail(`subject`,`body`,`sender`)
- SELECT 'Solicitar pasaporte',
- CONCAT(
- 'Etiquetas: ', IFNULL(vStickers, 0),
- ', Packing: ', IFNULL(vPacking, 0),
- ', Nombre: ', IFNULL(i.`name`, 0),
- ', buy_edi: ', IFNULL(e.id, 0),
- ', Nombre botánico: ', IFNULL(g.latin_genus_name, ''), ' ', IFNULL(s.latin_species_name, ''),
- ', Productor: ',IFNULL(es.company_name, IFNULL(p.`name`, ''))
- )
- ,'ekt@verdnatura.es'
- FROM item i
- LEFT JOIN itemBotanical ib ON ib.itemFk = i.id
- LEFT JOIN edi.genus g ON g.genus_id = ib.genusFk
- LEFT JOIN edi.specie s ON IFNULL(s.specie_id, ib.specieFk) = ib.specieFk
- LEFT JOIN producer p ON p.id = i.producerFk
- LEFT JOIN buy b ON b.id = vBuyFk
- LEFT JOIN edi.ekt e ON b.ektFk = e.id
- LEFT JOIN edi.supplier es ON es.supplier_id = e.pro
- WHERE i.id = vItemFk; */
-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 DROP PROCEDURE IF EXISTS `buy_recalcPrices` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -51284,8 +46766,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_recalcPrices`()
BEGIN
@@ -51357,6 +46837,8 @@ DELIMITER ;
/*!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 `buy_updateGrouping` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -51364,8 +46846,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_updateGrouping`(vWarehouseFk INT, vItemFk INT, vGrouping INT)
BEGIN
@@ -51377,7 +46857,7 @@ BEGIN
* @param vGrouping Cantidad de grouping
*/
- CALL vn.buyUltimate(vWarehouseFk, CURDATE());
+ CALL vn.buyUltimate(vWarehouseFk, util.VN_CURDATE());
UPDATE vn.buy b
JOIN tmp.buyUltimate bu ON b.id = bu.buyFk
@@ -51392,6 +46872,8 @@ DELIMITER ;
/*!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 `buy_updatePacking` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -51399,8 +46881,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_updatePacking`(vWarehouseFk INT, vItemFk INT, vPacking INT)
BEGIN
@@ -51411,7 +46891,7 @@ BEGIN
* @param vItemFk id del item
* @param vPacking packing a actualizar
*/
- CALL buyUltimate(vWarehouseFk, CURDATE());
+ CALL buyUltimate(vWarehouseFk, util.VN_CURDATE());
UPDATE buy b
JOIN tmp.buyUltimate bu ON b.id = bu.buyFk
@@ -51427,281 +46907,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `camaraFutureVolume__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `camaraFutureVolume__`(vWarehouseFk INT, vDateStart DATE, vDateEnd DATE)
-BEGIN
-
- DECLARE vDated DATE;
- DECLARE vSectorVolume INT;
- DECLARE vLastDayVolume INT;
- DECLARE vMinCamara INT;
-
- SET vDated = vDateStart;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.camara;
-
- IF vDateStart = CURDATE() THEN
-
- CREATE TEMPORARY TABLE tmp.camara
- SELECT vDated as dated,
- CONCAT('sector ', sectorFk) as place,
- FLOOR(SUM(ish.visible * r.cm3)/1000000) as m3
- FROM vn.itemShelving ish
- JOIN bi.rotacion r ON r.Id_Article = ish.itemFk AND r.warehouse_id = vWarehouseFk
- JOIN vn.shelving sh ON sh.code = ish.shelvingFk
- JOIN vn.parking p ON p.id = sh.parkingFk
- JOIN vn.sector s ON s.id = p.sectorFk
- WHERE s.warehouseFk = vWarehouseFk
- GROUP BY p.sectorFk;
-
- SELECT m3
- INTO vSectorVolume
- FROM tmp.camara
- WHERE place LIKE 'sector%';
-
- CALL cache.visible_refresh(@calc_id, FALSE, 1);
-
- INSERT INTO tmp.camara(dated, place, m3)
- SELECT vDated, 'nicho',
- FLOOR((SUM(v.visible * r.cm3) / 1000000) - vSectorVolume ) as m3
- FROM cache.visible v
- JOIN bi.rotacion r ON r.Id_Article = v.item_id AND r.warehouse_id = vWarehouseFk
- JOIN vn.item i ON i.id = v.item_id
- JOIN vn.itemType it ON it.id = i.typeFk
- JOIN vn.itemCategory ic ON ic.id = it.categoryFk
- WHERE calc_id = @calc_id
- AND ic.display;
-
- INSERT INTO tmp.camara(dated, place, m3)
- SELECT vDated, 'entradas', FLOOR(SUM(iei.amount * r.cm3) / 1000000) as m3
- FROM vn2008.item_entry_in iei
- JOIN bi.rotacion r ON r.Id_Article = iei.item_id AND r.warehouse_id = vWarehouseFk
- JOIN vn.item i ON i.id = iei.item_id
- JOIN vn.itemType it ON it.id = i.typeFk
- JOIN vn.itemCategory ic ON ic.id = it.categoryFk
- WHERE ic.display
- AND dat = vDated
- AND NOT received
- AND NOT isVirtualStock
- AND iei.warehouse_id = vWarehouseFk;
-
- INSERT INTO tmp.camara(dated, place, m3)
- SELECT vDated, 'salidas', FLOOR(SUM(ieo.amount * r.cm3) / 1000000) as m3
- FROM vn2008.item_entry_out ieo
- JOIN bi.rotacion r ON r.Id_Article = ieo.item_id AND r.warehouse_id = vWarehouseFk
- JOIN vn.item i ON i.id = ieo.item_id
- JOIN vn.itemType it ON it.id = i.typeFk
- JOIN vn.itemCategory ic ON ic.id = it.categoryFk
- WHERE ic.display
- AND dat = vDated
- AND NOT delivered
- AND NOT isVirtualStock
- AND ieo.warehouse_id = vWarehouseFk;
-
- INSERT INTO tmp.camara(dated, place, m3)
- SELECT vDated, 'ventas', FLOOR(SUM(io.amount * r.cm3) / 1000000) as m3
- FROM vn2008.item_out io
- JOIN bi.rotacion r ON r.Id_Article = io.item_id AND r.warehouse_id = vWarehouseFk
- JOIN vn.item i ON i.id = io.item_id
- JOIN vn.itemType it ON it.id = i.typeFk
- JOIN vn.itemCategory ic ON ic.id = it.categoryFk
- JOIN vn.ticketStateToday tst ON tst.ticket = io.ticketFk
- JOIN vn.ticket t ON t.id = io.ticketFk
- WHERE ic.display
- AND ic.id != 7
- AND t.clientFk NOT IN (200,400,50,450)
- AND dat BETWEEN vDated AND util.dayend(vDated)
- AND NOT tst.isPicked
- AND io.warehouse_id = vWarehouseFk;
-
- ELSE
-
- CREATE TEMPORARY TABLE tmp.camara
- SELECT vDated as dated,
- 'entradas' as place,
- FLOOR(SUM(iei.amount * r.cm3) / 1000000) as m3
- FROM vn2008.item_entry_in iei
- JOIN bi.rotacion r ON r.Id_Article = iei.item_id AND r.warehouse_id = vWarehouseFk
- JOIN vn.item i ON i.id = iei.item_id
- JOIN vn.itemType it ON it.id = i.typeFk
- JOIN vn.itemCategory ic ON ic.id = it.categoryFk
- WHERE ic.display
- AND dat = vDated
- AND NOT isVirtualStock
- AND iei.warehouse_id = vWarehouseFk;
-
- INSERT INTO tmp.camara(dated, place, m3)
- SELECT vDated, 'salidas', FLOOR(SUM(ieo.amount * r.cm3) / 1000000) as m3
- FROM vn2008.item_entry_out ieo
- JOIN bi.rotacion r ON r.Id_Article = ieo.item_id AND r.warehouse_id = vWarehouseFk
- JOIN vn.item i ON i.id = ieo.item_id
- JOIN vn.itemType it ON it.id = i.typeFk
- JOIN vn.itemCategory ic ON ic.id = it.categoryFk
- WHERE ic.display
- AND dat = vDated
- AND ieo.warehouse_id = vWarehouseFk;
-
- INSERT INTO tmp.camara(dated, place, m3)
- SELECT vDated, 'ventas', FLOOR(SUM(io.amount * r.cm3) / 1000000) as m3
- FROM vn2008.item_out io
- JOIN bi.rotacion r ON r.Id_Article = io.item_id AND r.warehouse_id = vWarehouseFk
- JOIN vn.item i ON i.id = io.item_id
- JOIN vn.itemType it ON it.id = i.typeFk
- JOIN vn.itemCategory ic ON ic.id = it.categoryFk
- JOIN vn.ticket t ON t.id = io.ticketFk
- WHERE ic.display
- AND dat BETWEEN vDated AND util.dayend(vDated)
- AND ic.id != 7
- AND t.clientFk NOT IN (200,400,50,450)
- AND io.warehouse_id = vWarehouseFk;
-
- END IF;
-
- -- Resto de dias
- WHILE vDated < vDateEnd DO
-
- SELECT SUM(IFNULL(m3,0)) INTO vLastDayVolume
- FROM tmp.camara
- WHERE dated = vDated;
-
- SET vDated = TIMESTAMPADD(DAY, 1, vDated);
-
- INSERT INTO tmp.camara(dated, place, m3)
- VALUES( vDated, 'camara', vLastDayVolume);
-
- INSERT INTO tmp.camara(dated, place, m3)
- SELECT vDated, 'entradas', FLOOR(SUM(iei.amount * r.cm3) / 1000000) as m3
- FROM vn2008.item_entry_in iei
- JOIN bi.rotacion r ON r.Id_Article = iei.item_id AND r.warehouse_id = vWarehouseFk
- JOIN vn.item i ON i.id = iei.item_id
- JOIN vn.itemType it ON it.id = i.typeFk
- JOIN vn.itemCategory ic ON ic.id = it.categoryFk
- WHERE ic.display
- AND dat = vDated
- AND NOT isVirtualStock
- AND iei.warehouse_id = vWarehouseFk;
-
- INSERT INTO tmp.camara(dated, place, m3)
- SELECT vDated, 'salidas', FLOOR(SUM(ieo.amount * r.cm3) / 1000000) as m3
- FROM vn2008.item_entry_out ieo
- JOIN bi.rotacion r ON r.Id_Article = ieo.item_id AND r.warehouse_id = vWarehouseFk
- JOIN vn.item i ON i.id = ieo.item_id
- JOIN vn.itemType it ON it.id = i.typeFk
- JOIN vn.itemCategory ic ON ic.id = it.categoryFk
- WHERE ic.display
- AND dat = vDated
- AND ieo.warehouse_id = vWarehouseFk;
-
- INSERT INTO tmp.camara(dated, place, m3)
- SELECT vDated, 'ventas', FLOOR(SUM(io.amount * r.cm3) / 1000000) as m3
- FROM vn2008.item_out io
- JOIN bi.rotacion r ON r.Id_Article = io.item_id AND r.warehouse_id = vWarehouseFk
- JOIN vn.item i ON i.id = io.item_id
- JOIN vn.itemType it ON it.id = i.typeFk
- JOIN vn.itemCategory ic ON ic.id = it.categoryFk
- JOIN vn.ticket t ON t.id = io.ticketFk
- WHERE ic.display
- AND dat BETWEEN vDated AND util.dayend(vDated)
- AND ic.id != 7
- AND t.clientFk NOT IN (200,400,50,450)
- AND io.warehouse_id = vWarehouseFk;
-
- END WHILE;
-
- SELECT min(m3) INTO vMinCamara
- FROM
- (SELECT dated, sum(m3) m3
- FROM tmp.camara
- GROUP BY dated) sub;
-
- UPDATE tmp.camara
- SET m3 = m3 - vMinCamara
- WHERE place = 'camara';
-
- SELECT camara.* FROM tmp.camara;
-
-
-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 DROP PROCEDURE IF EXISTS `carrosOficialesANoOficiales__` */;
-/*!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_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `carrosOficialesANoOficiales__`()
-BEGIN
-
-DECLARE done BOOL DEFAULT FALSE;
-DECLARE vClientFk INT;
-DECLARE vQuantity INT;
-DECLARE vTicketFk INT;
-DECLARE vAgencyTypeFk INT DEFAULT 628;
-
-
-DECLARE rs CURSOR FOR
- SELECT clientFk, sum(quantity) as carros
- FROM `ticketPackaging` tp
- JOIN ticket t ON t.id = tp.ticketFk
- WHERE packagingFk = 'cc'
- and t.shipped between '2017-10-30' AND '2019-01-06 23:59:59'
- group by clientFk
- having carros != 0;
-
-DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
-
-OPEN rs;
-
-FETCH rs INTO vClientFk, vQuantity;
-
--- WHILE NOT done DO
-
- CALL vn.ticketCreate(vClientFk, '2019-01-06', 13, 442, NULL, vAgencyTypeFk, NULL, '2019-01-01', vTicketFk);
-
- INSERT INTO vn.ticketPackaging(ticketFk, packagingFk, quantity)
- VALUES (vTicketFk, 'cc', - VQuantity);
-
- INSERT INTO vn.ticketPackaging(ticketFk, packagingFk, quantity)
- VALUES (vTicketFk, 'dc', VQuantity);
-
- INSERT INTO vn.sale(ticketFk, itemFk, concept)
- VALUES (vTicketFk, 90, 'Regularización CCs 2019');
-
- CALL vn.`ticketStateUpdate`(vTicketFk, 'DELIVERED'); -- entregado
-
--- FETCH rs INTO vClientFk, vQuantity;
-
--- END WHILE;
-
-
-CLOSE rs;
-
-SELECT vTicketFk;
-
-
-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 DROP PROCEDURE IF EXISTS `catalog_calcFromItem` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -51709,8 +46916,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_calcFromItem`(
vLanded DATE,
@@ -51741,6 +46946,8 @@ DELIMITER ;
/*!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 `catalog_calculate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -51748,8 +46955,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_calculate`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT)
BEGIN
@@ -51920,6 +47125,7 @@ BEGIN
FROM tmp.ticketComponentPrice
WHERE warehouseFk = vWarehouseFk
ORDER BY (rate = 2) DESC
+ LIMIT 10000000000000000000
) sub
GROUP BY itemFk
) bl ON bl.itemFk = tl.itemFk
@@ -51937,6 +47143,8 @@ DELIMITER ;
/*!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 `catalog_componentCalculate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -51944,8 +47152,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_componentCalculate`( vZoneFk INT,
vAddressFk INT,
@@ -51969,7 +47175,6 @@ BEGIN
DECLARE vIsFrenchVNHBuyer BOOLEAN DEFAULT FALSE;
DECLARE vVNHWarehouseFk INT DEFAULT 7;
DECLARE vFrenchDiscount DECIMAL(3,2) DEFAULT 0.12;
- DECLARE visAnyVolumeAllowed BOOL;
SELECT clientFk INTO vClientFK
FROM address
@@ -51982,25 +47187,6 @@ BEGIN
JOIN vn.address a ON a.provinceFk = p.id
WHERE a.id = vAddressFk;
-
- -- Se eliminan los productos de tamaños no convencionales, salvo agencias que lo permitan
- SELECT a.isAnyVolumeAllowed INTO visAnyVolumeAllowed
- FROM vn.agency a
- JOIN vn.agencyMode am ON am.agencyFk = a.id
- JOIN vn.`zone`z ON z.agencyModeFk = am.id
- WHERE z.id = vZoneFk;
-
- IF NOT vIsAnyVolumeAllowed THEN
-
- DELETE tl.*
- FROM tmp.ticketLot tl
- JOIN vn.item i ON i.id = tl.itemFk
- JOIN vn.itemType it ON it.id = i.typeFk
- WHERE it.isUnconventionalSize;
-
- END IF;
-
-
DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCalculate;
CREATE TEMPORARY TABLE tmp.ticketComponentCalculate
@@ -52010,11 +47196,8 @@ BEGIN
tl.itemFk,
tl.warehouseFk,
tl.available,
- -- IF((@rate2 := IFNULL(pf.rate2, b.price2)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate2) rate2,
IF(i.hasMinPrice, GREATEST(i.minPrice,IFNULL(pf.rate2, b.price2)),IFNULL(pf.rate2, b.price2)) rate2,
IF(i.hasMinPrice, GREATEST(i.minPrice,IFNULL(pf.rate3, b.price3)),IFNULL(pf.rate3, b.price3)) rate3,
- -- @minPrice := IF((@rate3 := IFNULL(pf.rate3, b.price3)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate3) rate3,
- -- TRUE AS minPrice,
IFNULL(pf.packing, GREATEST(b.grouping, b.packing)) packing,
IFNULL(pf.`grouping`, b.`grouping`) `grouping`,
ABS(IFNULL(pf.box, b.groupingMode)) groupingMode,
@@ -52042,6 +47225,7 @@ BEGIN
AND zw.warehouseFk IN (pf.warehouseFk,0)
WHERE vShipped BETWEEN pf.started AND pf.ended
ORDER BY pf.itemFk, pf.warehouseFk DESC
+ LIMIT 10000000000000000000
) tpf
GROUP BY tpf.itemFk, tpf.warehouseFk
) pf ON pf.itemFk = tl.itemFk
@@ -52104,10 +47288,11 @@ BEGIN
IFNULL(cr1.priceIncreasing,0),
IFNULL(cr2.priceIncreasing,0))
),
- 0.25),
+ cc.maxPriceIncreasingRatio),
3)
FROM tmp.ticketComponentBase tcb
JOIN vn.component c2 ON c2.code = 'debtCollection'
+ JOIN vn.clientConfig cc
JOIN claimRatio cr ON cr.clientFk = vClientFk
LEFT JOIN clientYoke cy1 ON cy1.leftOx = cr.clientFk
LEFT JOIN claimRatio cr1 ON cr1.clientFk = cy1.rightOx
@@ -52177,15 +47362,6 @@ BEGIN
HAVING cost <> 0;
DROP TEMPORARY TABLE tmp.zoneOption;
- /*
- -- Extra reparto
- INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
- SELECT tcc.warehouseFk, tcc.itemFk, c2.id, ap.packagingValue cost
- FROM tmp.ticketComponentCalculate tcc
- JOIN vn.addressForPackaging ap
- JOIN vn.component c2 ON c2.code = 'bagged'
- WHERE ap.addressFk = vAddressFk;
- */
DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCopy;
CREATE TEMPORARY TABLE tmp.ticketComponentCopy ENGINE = MEMORY
@@ -52275,7 +47451,7 @@ BEGIN
INSERT INTO tmp.ticketComponentPrice (warehouseFk, itemFk, rate, `grouping`, price, priceKg)
SELECT * FROM (
- SELECT * FROM tmp.ticketComponentRate ORDER BY price
+ SELECT * FROM tmp.ticketComponentRate ORDER BY price LIMIT 10000000000000000000
) t
GROUP BY itemFk, warehouseFk, `grouping`;
@@ -52292,6 +47468,8 @@ DELIMITER ;
/*!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 `catalog_componentPrepare` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -52299,8 +47477,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_componentPrepare`()
BEGIN
@@ -52332,6 +47508,8 @@ DELIMITER ;
/*!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 `catalog_componentPurge` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -52339,8 +47517,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_componentPurge`()
BEGIN
@@ -52354,6 +47530,8 @@ DELIMITER ;
/*!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 `catalog_test` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -52361,8 +47539,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_test`()
proc: BEGIN
@@ -52380,7 +47556,7 @@ proc: BEGIN
* @return tmp.ticketComponentPrice
* @return tmp.zoneGetShipped
*/
- DECLARE vLanded DATE DEFAULT DATE_ADD(CURDATE(),INTERVAL 2 DAY);
+ DECLARE vLanded DATE DEFAULT DATE_ADD(util.VN_CURDATE(),INTERVAL 2 DAY);
DECLARE vAddressFk INT DEFAULT 24526;
DECLARE vAgencyModeFk INT DEFAULT 639;
DECLARE vAvailableCalc INT;
@@ -52498,7 +47674,8 @@ SELECT 6;
FROM (SELECT price, itemFk, priceKg
FROM tmp.ticketComponentPrice
WHERE warehouseFk = vWarehouseFk
- ORDER BY (rate = 2) DESC) sub
+ ORDER BY (rate = 2) DESC
+ LIMIT 10000000000000000000) sub
GROUP BY itemFk
) bl ON bl.itemFk = tl.itemFk
WHERE tl.zoneFk = vZoneFk AND tl.warehouseFk = vWarehouseFk
@@ -52517,15 +47694,15 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `clean` */;
/*!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 character_set_client = utf8 */ ;
+/*!50003 SET character_set_results = utf8 */ ;
+/*!50003 SET collation_connection = utf8_general_ci */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `clean`()
BEGIN
@@ -52537,37 +47714,37 @@ BEGIN
DECLARE v3Month DATE;
DECLARE vTrashId varchar(15);
- SET vDateShort = TIMESTAMPADD(MONTH, -2, CURDATE());
- SET vOneYearAgo = TIMESTAMPADD(YEAR,-1,CURDATE());
- SET vFourYearsAgo = TIMESTAMPADD(YEAR,-4,CURDATE());
- SET v18Month = TIMESTAMPADD(MONTH, -18,CURDATE());
- SET v26Month = TIMESTAMPADD(MONTH, -26,CURDATE());
- SET v3Month = TIMESTAMPADD(MONTH, -3, CURDATE());
+ SET vDateShort = TIMESTAMPADD(MONTH, -2, util.VN_CURDATE());
+ SET vOneYearAgo = TIMESTAMPADD(YEAR,-1,util.VN_CURDATE());
+ SET vFourYearsAgo = TIMESTAMPADD(YEAR,-4,util.VN_CURDATE());
+ SET v18Month = TIMESTAMPADD(MONTH, -18,util.VN_CURDATE());
+ SET v26Month = TIMESTAMPADD(MONTH, -26,util.VN_CURDATE());
+ SET v3Month = TIMESTAMPADD(MONTH, -3, util.VN_CURDATE());
DELETE FROM ticketParking WHERE created < vDateShort;
- DELETE FROM routesMonitor WHERE dated < vDateShort;
- DELETE FROM workerTimeControlLog WHERE created < vDateShort;
+ DELETE FROM routesMonitor WHERE dated < vDateShort;
+ DELETE FROM workerTimeControlLog WHERE created < vDateShort;
DELETE FROM `message` WHERE sendDate < vDateShort;
DELETE FROM messageInbox WHERE sendDate < vDateShort;
DELETE FROM messageInbox WHERE sendDate < vDateShort;
DELETE FROM workerTimeControl WHERE timed < vFourYearsAgo;
- DELETE FROM itemShelving WHERE created < CURDATE() AND visible = 0;
- DELETE FROM ticketDown WHERE created < TIMESTAMPADD(DAY,-1,CURDATE());
- DELETE FROM entryLog WHERE creationDate < vDateShort;
- DELETE IGNORE FROM expedition WHERE created < v26Month;
- DELETE FROM sms WHERE created < v18Month;
- DELETE FROM saleTracking WHERE created < vOneYearAgo;
- DELETE tobs FROM ticketObservation tobs
- JOIN ticket t ON tobs.ticketFk = t.id WHERE t.shipped < TIMESTAMPADD(YEAR,-2,CURDATE());
+ DELETE FROM itemShelving WHERE created < util.VN_CURDATE() AND visible = 0;
+ DELETE FROM ticketDown WHERE created < TIMESTAMPADD(DAY,-1,util.VN_CURDATE());
+ DELETE FROM entryLog WHERE creationDate < vDateShort;
+ DELETE IGNORE FROM expedition WHERE created < v26Month;
+ DELETE FROM sms WHERE created < v18Month;
+ DELETE FROM saleTracking WHERE created < vOneYearAgo;
+ DELETE tobs FROM ticketObservation tobs
+ JOIN ticket t ON tobs.ticketFk = t.id WHERE t.shipped < TIMESTAMPADD(YEAR,-2,util.VN_CURDATE());
DELETE sc.* FROM saleCloned sc JOIN sale s ON s.id = sc.saleClonedFk JOIN ticket t ON t.id = s.ticketFk WHERE t.shipped < vOneYearAgo;
DELETE FROM sharingCart where ended < vDateShort;
- DELETE FROM sharingClient where ended < vDateShort;
- DELETE tw.* FROM ticketWeekly tw
+ DELETE FROM sharingClient where ended < vDateShort;
+ DELETE tw.* FROM ticketWeekly tw
LEFT JOIN sale s ON s.ticketFk = tw.ticketFk WHERE s.itemFk IS NULL;
DELETE FROM claim WHERE ticketCreated < vFourYearsAgo;
DELETE FROM message WHERE sendDate < vDateShort;
- -- Robert ubicacion anterior de trevelLog comentario para debug
- DELETE sc FROM saleChecked sc
+ -- Robert ubicacion anterior de trevelLog comentario para debug
+ DELETE sc FROM saleChecked sc
JOIN sale s ON sc.saleFk = s.id WHERE s.created < vDateShort;
DELETE FROM zoneEvent WHERE `type` = 'day' AND dated < v3Month;
DELETE bm
@@ -52577,10 +47754,11 @@ BEGIN
JOIN travel t ON t.id = e.travelFk
WHERE t.landed <= vDateShort;
DELETE FROM stowaway WHERE created < v3Month;
- DELETE FROM vn.buy WHERE created < vDateShort AND entryFk = 9200;
- DELETE FROM vn.itemShelvingLog WHERE created < vDateShort;
- DELETE FROM vn.stockBuyed WHERE creationDate < vDateShort;
-
+ DELETE FROM vn.buy WHERE created < vDateShort AND entryFk = 9200;
+ DELETE FROM vn.itemShelvingLog WHERE created < vDateShort;
+ DELETE FROM vn.stockBuyed WHERE creationDate < vDateShort;
+
+
-- Equipos duplicados
DELETE w.*
FROM workerTeam w
@@ -52589,36 +47767,36 @@ BEGIN
GROUP BY team,workerFk
HAVING duplicated
) d ON d.team = w.team AND d.workerFk = w.workerFk AND d.id != w.id;
-
- DELETE sc
+
+ DELETE sc
FROM saleComponent sc
JOIN sale s ON s.id= sc.saleFk
JOIN ticket t ON t.id= s.ticketFk
WHERE t.shipped < v18Month;
-
- DELETE c
+
+ DELETE c
FROM vn.claim c
JOIN vn.claimState cs ON cs.id = c.claimStateFk
WHERE cs.description = "Anulado" AND
- c.created < vDateShort;
+ c.created < vDateShort;
DELETE
FROM vn.expeditionTruck
- WHERE ETD < v3Month;
-
- -- borrar travels sin entradas
+ WHERE ETD < v3Month;
+
+ -- borrar travels sin entradas
DROP TEMPORARY TABLE IF EXISTS tmp.thermographToDelete;
CREATE TEMPORARY TABLE tmp.thermographToDelete
SELECT th.id,th.dmsFk
FROM vn.travel t
LEFT JOIN vn.entry e ON e.travelFk = t.id
JOIN vn.travelThermograph th ON th.travelFk = t.id
- WHERE t.shipped < TIMESTAMPADD(MONTH, -3, CURDATE()) AND e.travelFk IS NULL;
-
- SELECT dt.id into vTrashId
- FROM vn.dmsType dt
- WHERE dt.code = 'trash';
+ WHERE t.shipped < TIMESTAMPADD(MONTH, -3, util.VN_CURDATE()) AND e.travelFk IS NULL;
- UPDATE tmp.thermographToDelete th
+ SELECT dt.id into vTrashId
+ FROM vn.dmsType dt
+ WHERE dt.code = 'trash';
+
+ UPDATE tmp.thermographToDelete th
JOIN vn.dms d ON d.id = th.dmsFk
SET d.dmsTypeFk = vTrashId;
@@ -52629,27 +47807,32 @@ BEGIN
DELETE t
FROM vn.travel t
LEFT JOIN vn.entry e ON e.travelFk = t.id
- WHERE t.shipped < TIMESTAMPADD(MONTH, -3, CURDATE()) AND e.travelFk IS NULL;
+ WHERE t.shipped < TIMESTAMPADD(MONTH, -3, util.VN_CURDATE()) AND e.travelFk IS NULL;
- -- borrar entradas sin compras
- DROP TEMPORARY TABLE IF EXISTS tmp.entryToDelete;
+ UPDATE dms d
+ JOIN dmsType dt ON dt.id = d.dmsTypeFk
+ SET d.dmsTypeFk = vTrashId
+ WHERE created < TIMESTAMPADD(MONTH, -dt.monthToDelete, util.VN_CURDATE());
+
+ -- borrar entradas sin compras
+ DROP TEMPORARY TABLE IF EXISTS tmp.entryToDelete;
CREATE TEMPORARY TABLE tmp.entryToDelete
SELECT e.*
FROM vn.entry e
LEFT JOIN vn.buy b ON b.entryFk = e.id
JOIN vn.entryConfig ec ON e.id != ec.defaultEntry
- WHERE e.dated < TIMESTAMPADD(MONTH, -3, CURDATE()) AND b.entryFK IS NULL;
+ WHERE e.dated < TIMESTAMPADD(MONTH, -3, util.VN_CURDATE()) AND b.entryFK IS NULL;
DELETE e
FROM vn.entry e
JOIN tmp.entryToDelete tmp ON tmp.id = e.id;
-
- -- borrar de route registros menores a 4 años
- DROP TEMPORARY TABLE IF EXISTS tmp.routeToDelete;
+
+ -- borrar de route registros menores a 4 años
+ DROP TEMPORARY TABLE IF EXISTS tmp.routeToDelete;
CREATE TEMPORARY TABLE tmp.routeToDelete
SELECT *
FROM vn.route r
- WHERE created < TIMESTAMPADD(YEAR,-4,CURDATE());
+ WHERE created < TIMESTAMPADD(YEAR,-4,util.VN_CURDATE());
UPDATE tmp.routeToDelete tmp
JOIN vn.dms d ON d.id = tmp.gestdocFk
@@ -52658,13 +47841,13 @@ BEGIN
DELETE r
FROM tmp.routeToDelete tmp
JOIN vn.route r ON r.id = tmp.id;
-
- -- borrar registros de dua y awb menores a 2 años
- DROP TEMPORARY TABLE IF EXISTS tmp.duaToDelete;
+
+ -- borrar registros de dua y awb menores a 2 años
+ DROP TEMPORARY TABLE IF EXISTS tmp.duaToDelete;
CREATE TEMPORARY TABLE tmp.duaToDelete
SELECT *
- FROM vn.dua
- WHERE operated < TIMESTAMPADD(YEAR,-2,CURDATE());
+ FROM vn.dua
+ WHERE operated < TIMESTAMPADD(YEAR,-2,util.VN_CURDATE());
UPDATE tmp.duaToDelete tm
JOIN vn.dms d ON d.id = tm.gestdocFk
@@ -52673,29 +47856,31 @@ BEGIN
DELETE d
FROM tmp.duaToDelete tmp
JOIN vn.dua d ON d.id = tmp.id;
-
- DELETE FROM vn.awb WHERE created < TIMESTAMPADD(YEAR,-2,CURDATE());
-
- -- Borra los ficheros gestDoc
- INSERT INTO vn.printServerQueue(priorityFk, labelReportFk)VALUES(1,11);
-
- -- Borra los registros de collection y ticketcollection
- DELETE FROM vn.collection WHERE created < vDateShort;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.thermographToDelete;
- DROP TEMPORARY TABLE IF EXISTS tmp.entryToDelete;
+
+ DELETE FROM vn.awb WHERE created < TIMESTAMPADD(YEAR,-2,util.VN_CURDATE());
+
+ -- Borra los ficheros gestDoc
+ INSERT INTO vn.printServerQueue(priorityFk, labelReportFk)VALUES(1,11);
+
+ -- Borra los registros de collection y ticketcollection
+ DELETE FROM vn.collection WHERE created < vDateShort;
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.thermographToDelete;
+ DROP TEMPORARY TABLE IF EXISTS tmp.entryToDelete;
DROP TEMPORARY TABLE IF EXISTS tmp.duaToDelete;
-
- DELETE FROM travelLog WHERE creationDate < v3Month;
-
+
+ DELETE FROM travelLog WHERE creationDate < v3Month;
+
CALL shelving_clean;
-
+
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 `clean_logiflora` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -52703,8 +47888,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `clean_logiflora`()
BEGIN
@@ -52712,7 +47895,7 @@ BEGIN
* item_clean, buy_clean
* */
- DECLARE vMaxDated DATE DEFAULT TIMESTAMPADD(DAY, - 7, CURDATE());
+ DECLARE vMaxDated DATE DEFAULT TIMESTAMPADD(DAY, - 7, util.VN_CURDATE());
DECLARE vDone INT DEFAULT FALSE;
DECLARE vBuyFk INT;
DECLARE cur1 CURSOR FOR SELECT id FROM tmp.buy;
@@ -52794,6 +47977,8 @@ DELIMITER ;
/*!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 `clearShelvingList` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -52801,22 +47986,20 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `clearShelvingList`(vShelvingFk VARCHAR(8))
BEGIN
-
- UPDATE vn.itemShelving
- SET visible = 0, available = 0
- WHERE shelvingFk COLLATE utf8_unicode_ci =vShelvingFk COLLATE utf8_unicode_ci;
-
+ UPDATE vn.itemShelving
+ SET visible = 0
+ WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk COLLATE utf8_unicode_ci;
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 `clientCreate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -52824,8 +48007,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `clientCreate`(
vFirstname VARCHAR(50),
@@ -52903,6 +48084,8 @@ DELIMITER ;
/*!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 `clientDebtSpray` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -52910,8 +48093,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `clientDebtSpray`(vClientFk INT)
BEGIN
@@ -52923,15 +48104,15 @@ BEGIN
DECLARE vClientDebt DOUBLE;
- SELECT vn.clientGetDebt(vClientFk, CURDATE()) INTO vClientDebt;
+ SELECT vn.clientGetDebt(vClientFk, util.VN_CURDATE()) INTO vClientDebt;
INSERT INTO vn.greuge(clientFk, description, amount, shipped, greugeTypeFk)
- VALUES (vClientFk, 'Saldo pendiente', vClientDebt, CURDATE(), 5);
+ VALUES (vClientFk, 'Saldo pendiente', vClientDebt, util.VN_CURDATE(), 5);
CALL vn.clientGreugeSpray(vClientFk, TRUE, '', TRUE);
INSERT INTO vn.greuge(clientFk, description, amount, shipped, greugeTypeFk)
- SELECT vClientFk, 'Liquidación cliente', sum(amount), CURDATE(), 5
+ SELECT vClientFk, 'Liquidación cliente', sum(amount), util.VN_CURDATE(), 5
FROM vn.greuge
WHERE clientFk = vClientFk;
@@ -52945,6 +48126,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `clientFreeze` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -52952,8 +48135,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `clientFreeze`()
BEGIN
@@ -52969,20 +48150,20 @@ BEGIN
SELECT id into vIsRemittanced
FROM receipt
WHERE invoiceFk LIKE 'REMESA%'
- AND payed > util.firstDayOfMonth(CURDATE())
+ AND payed > util.firstDayOfMonth(util.VN_CURDATE())
limit 1;
DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt;
CREATE TEMPORARY TABLE tmp.clientGetDebt
SELECT clientFk
FROM bs.defaulter
- WHERE created = CURDATE()
+ WHERE created = util.VN_CURDATE()
AND amount;
- CALL clientGetDebt(CURDATE());
+ CALL clientGetDebt(util.VN_CURDATE());
UPDATE client c
- JOIN bi.defaulters d ON d.client = c.id AND d.date = CURDATE()
+ JOIN bi.defaulters d ON d.client = c.id AND d.date = util.VN_CURDATE()
JOIN config ON TRUE
LEFT JOIN account.`user` u ON u.id = c.id AND u.active
LEFT JOIN worker w ON w.id = u.id
@@ -52990,7 +48171,7 @@ BEGIN
LEFT JOIN payMethod pm ON pm.id = c.payMethodFk
LEFT JOIN tmp.risk rk ON rk.clientFk = c.id
SET c.isFreezed = TRUE,
- d.frozened = CURDATE(),
+ d.frozened = util.VN_CURDATE(),
u.active = FALSE
WHERE (d.amount > config.defaultersMaxAmount
AND rk.risk > 0)
@@ -53006,6 +48187,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `clientGetDebt` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -53013,8 +48196,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `clientGetDebt`(vDate DATE)
BEGIN
@@ -53025,10 +48206,10 @@ BEGIN
* @param vDate Fecha maxima de los registros
* @return tmp.risk
*/
- DECLARE vStarted DATETIME DEFAULT TIMESTAMPADD(DAY, -35, CURDATE());
+ DECLARE vStarted DATETIME DEFAULT TIMESTAMPADD(DAY, -35, util.VN_CURDATE());
DECLARE vEnded DATETIME;
- SET vEnded = TIMESTAMP(IFNULL(vDate, CURDATE()), '23:59:59');
+ SET vEnded = TIMESTAMP(IFNULL(vDate, util.VN_CURDATE()), '23:59:59');
DROP TEMPORARY TABLE IF EXISTS tClientRisk;
CREATE TEMPORARY TABLE tClientRisk
@@ -53076,6 +48257,8 @@ DELIMITER ;
/*!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 `clientGetDebtDiary` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -53083,8 +48266,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `clientGetDebtDiary`(vClientFK INT, vCompanyFk INT)
BEGIN
@@ -53206,6 +48387,8 @@ DELIMITER ;
/*!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 `clientGreugeSpray` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -53213,8 +48396,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `clientGreugeSpray`(IN vClientFk INT, IN onlyForHisOwner BOOL, IN vWorkerCode VARCHAR(3), IN vWithMana BOOLEAN)
BEGIN
@@ -53223,25 +48404,25 @@ BEGIN
DECLARE vOwner INT;
DECLARE vTotalSale INT;
DECLARE vGreugeTypeFk INT DEFAULT 5; -- HERENCIA
- DECLARE vGreugeTypeMana INT DEFAULT 3;-- Maná
- DECLARE vMana DECIMAL(10,2);
-
- SELECT vn.clientGetMana(vClientFk) INTO vMana;
-
- IF vWithMana AND vMana THEN
-
+ DECLARE vGreugeTypeMana INT DEFAULT 3;-- Maná
+ DECLARE vMana DECIMAL(10,2);
+
+ SELECT vn.clientGetMana(vClientFk) INTO vMana;
+
+ IF vWithMana AND vMana THEN
+
INSERT INTO vn.greuge( clientFk,
description,
- amount,
- shipped,
- greugeTypeFk)
- VALUES( vClientFk,
+ amount,
+ shipped,
+ greugeTypeFk)
+ VALUES( vClientFk,
'Desasignación',
- -1 * vMana,
- CURDATE(),
- vGreugeTypeMana);
-
- END IF;
+ -1 * vMana,
+ util.VN_CURDATE(),
+ vGreugeTypeMana);
+
+ END IF;
SELECT sum(amount) INTO vGreuge
FROM vn.greuge
@@ -53265,13 +48446,13 @@ BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp.clientList;
CREATE TEMPORARY TABLE tmp.clientList
- SELECT DISTINCT t.clientFk, floor(cr.yearSale / 12) AS monthSale
+ SELECT DISTINCT t.clientFk, floor(cr.yearSale / 12) monthSale
FROM vn.ticket t
JOIN vn.client c ON c.id = t.clientFk
- JOIN vn.manaSpellers ms ON ms.worker = c.salesPersonFk
+ JOIN vn.workerMana wm ON wm.workerFk = c.salesPersonFk
JOIN vn.claimRatio cr ON cr.clientFk = c.id
- WHERE ms.worker = IF(onlyForHisOwner, vOwner, ms.worker)
- AND t.shipped >= TIMESTAMPADD(MONTH,-1,CURDATE())
+ WHERE wm.workerFk = IF(onlyForHisOwner, vOwner, wm.workerFk)
+ AND t.shipped >= TIMESTAMPADD(MONTH,-1,util.VN_CURDATE())
AND c.id != vClientFk
HAVING monthSale > 100;
@@ -53279,11 +48460,11 @@ BEGIN
FROM tmp.clientList;
INSERT INTO vn.greuge(clientFk, description, amount, shipped, greugeTypeFk)
- SELECT clientFk, CONCAT('Cliente: ',vClientFk), vGreuge * monthSale / vTotalSale, CURDATE(), vGreugeTypeFk
+ SELECT clientFk, CONCAT('Cliente: ',vClientFk), vGreuge * monthSale / vTotalSale, util.VN_CURDATE(), vGreugeTypeFk
FROM tmp.clientList
UNION ALL
- SELECT vClientFk, 'Reparto greuge', -vGreuge, CURDATE(), vGreugeTypeFk;
-
+ SELECT vClientFk, 'Reparto greuge', -vGreuge, util.VN_CURDATE(), vGreugeTypeFk;
+
END IF;
END ;;
@@ -53292,6 +48473,8 @@ DELIMITER ;
/*!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 `clientPackagingOverstock` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -53299,8 +48482,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `clientPackagingOverstock`(vClientFk INT, vGraceDays INT )
BEGIN
@@ -53373,7 +48554,7 @@ BEGIN
IFNULL(pe.equivalentFk, p.itemFk) itemFk,
NULL,
NULL,
- IF(tp.quantity > 0 AND t.shipped <= TIMESTAMPADD(DAY, - vGraceDays, CURDATE()), tp.quantity, NULL) SenttoClient,
+ IF(tp.quantity > 0 AND t.shipped <= TIMESTAMPADD(DAY, - vGraceDays, util.VN_CURDATE()), tp.quantity, NULL) SenttoClient,
IF(tp.quantity < 0, -tp.quantity, NULL) GotfromClient,
NULL AS refFk,
NULL,
@@ -53389,6 +48570,7 @@ BEGIN
GROUP BY x.id, x.itemFk
) t
ORDER BY itemFk, shipped DESC
+ LIMIT 10000000000000000000
) t2
GROUP BY itemFk;
END ;;
@@ -53397,6 +48579,8 @@ DELIMITER ;
/*!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 `clientPackagingOverstockReturn` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -53404,8 +48588,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `clientPackagingOverstockReturn`(vClientFk INT, vGraceDays INT )
BEGIN
@@ -53422,13 +48604,13 @@ BEGIN
CALL vn.ticket_add(
vClientFk
- ,CURDATE()
+ ,util.VN_CURDATE()
,vWarehouseFk -- Algemesi
,442 -- Verdnatura
,NULL -- address
,NULL -- agencia
,NULL -- route
- ,CURDATE()
+ ,util.VN_CURDATE()
,account.myUser_getId()
,TRUE
,vNewTicket);
@@ -53454,62 +48636,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `clientRandomSelection__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `clientRandomSelection__`(vNumero INT)
-BEGIN
-
- DECLARE vClient INT;
-
- SET @vIndex := 0;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.client;
-
- CREATE TEMPORARY TABLE tmp.client
- SELECT io.clientFk,
- FALSE as isSelected,
- @vIndex := @vIndex + 1 id
- FROM vn.client c
- JOIN vn.invoiceOut io ON io.clientFk = c.id
- JOIN vn.address a ON a.clientFk = c.id
- JOIN vn.province p ON p.id = a.provinceFk
- WHERE p.name = 'MADRID'
- AND io.issued = '2019-01-31'
- AND a.isDefaultAddress
- AND c.name NOT LIKE 'TR %';
-
- WHILE vNumero DO
-
- SET vClient = FLOOR(RAND() * @vIndex + 1);
-
- IF (SELECT isSelected FROM tmp.client WHERE id = vClient) = FALSE THEN
-
- UPDATE tmp.client
- SET isSelected = TRUE
- WHERE id = vClient;
-
- SET vNumero = vNumero - 1;
-
- END IF;
-
- END WHILE;
-
- SELECT * FROM tmp.client JOIN vn.client c ON c.id = 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 DROP PROCEDURE IF EXISTS `clientRemoveWorker` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -53517,8 +48645,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `clientRemoveWorker`()
BEGIN
@@ -53552,7 +48678,7 @@ BEGIN
CALL vn.clientGreugeSpray(vClientFk, TRUE, '',TRUE);
UPDATE vn.client SET salesPersonFk = NULL WHERE id = vClientFk;
INSERT INTO vn.clientLog (originFk, userFk, `action`, description)
- VALUES (vClientFk, account.userGetId(), 'update', CONCAT('Se ha desasignado el cliente por que no ha comprado en 3 meses'));
+ VALUES (vClientFk, account.myUser_getId(), 'update', CONCAT('Se ha desasignado el cliente por que no ha comprado en 3 meses'));
FETCH rs INTO vClientFk;
END WHILE;
CLOSE rs;
@@ -53563,6 +48689,8 @@ DELIMITER ;
/*!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 `clientRisk_update` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -53570,8 +48698,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `clientRisk_update`(vClientId INT, vCompanyId INT, vAmount DECIMAL(10,2))
BEGIN
@@ -53591,6 +48717,8 @@ DELIMITER ;
/*!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_checkBalance` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -53598,8 +48726,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `client_checkBalance`(IN vDateTo DATETIME, IN vIsConciliated BOOL)
BEGIN
@@ -53641,6 +48767,8 @@ DELIMITER ;
/*!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_RandomList` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -53648,8 +48776,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `client_RandomList`(vNumber INT)
BEGIN
@@ -53671,7 +48797,7 @@ BEGIN
INSERT INTO tmp.client(clientFk)
SELECT DISTINCT clientFk
FROM vn.invoiceOut
- WHERE issued > TIMESTAMPADD(MONTH, -2, CURDATE());
+ WHERE issued > TIMESTAMPADD(MONTH, -2, util.VN_CURDATE());
SELECT max(id) INTO maxClientFk
FROM tmp.client;
@@ -53713,152 +48839,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `clonTravelComplete__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `clonTravelComplete__`(IN `vTravelFk` INT, IN `vDateStart` DATE, IN `vDateEnd` DATE, IN `vRef` VARCHAR(255))
-BEGIN
--- DEPRECATED usar travel_cloneWithEntries. jgallego
-/*
- * Clona un travel, junto con sus entradas y compras
- * @param vTravelFk travel a clonar
- * @param vDateStart fecha de salida del nuevo travel
- * @param vDateEnd fecha de llegada del nuevo travel
- * @param vRef referencia del nuevo travel
-*/
- DECLARE vTravelNew INT;
- DECLARE vEntryNew INT;
- DECLARE vDone BOOLEAN DEFAULT FALSE;
- DECLARE vAuxEntryFk INT;
- DECLARE vRsEntry CURSOR FOR
- SELECT e.id
- FROM entry e
- JOIN travel t ON t.id = e.travelFk
- WHERE e.travelFk = vTravelFk;
-
- DECLARE vRsBuy CURSOR FOR
- SELECT b.*
- FROM buy b
- JOIN entry e ON b.entryFk = e.id
- WHERE e.travelFk = vTravelNew and b.entryFk = entryNew
- ORDER BY e.id;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
-
- DECLARE EXIT HANDLER FOR SQLEXCEPTION
- BEGIN
- ROLLBACK;
- RESIGNAL;
- END;
-
- START TRANSACTION;
-
- INSERT INTO travel (shipped,landed, warehouseInFk, warehouseOutFk, agencyFk, ref, isDelivered, isReceived, m3, kg)
- SELECT vDateStart, vDateEnd,warehouseInFk, warehouseOutFk, agencyFk, vRef, isDelivered, isReceived, m3, kg
- FROM travel
- WHERE id = vTravelFk;
-
- SET vTravelNew = LAST_INSERT_ID();
- SET vDone = FALSE;
- OPEN vRsEntry;
- FETCH vRsEntry INTO vAuxEntryFk;
-
- WHILE NOT vDone DO
- INSERT INTO entry (supplierFk,
- ref,
- isInventory,
- isConfirmed,
- isOrdered,
- isRaid,
- commission,
- created,
- evaNotes,
- travelFk,
- currencyFk,
- companyFk,
- gestDocFk,
- invoiceInFk)
- SELECT supplierFk,
- ref,
- isInventory,
- isConfirmed,
- isOrdered,
- isRaid,
- commission,
- created,
- evaNotes,
- vTravelNew,
- currencyFk,
- companyFk,
- gestDocFk,
- invoiceInFk
- FROM entry
- WHERE id = vAuxEntryFk;
-
- SET vEntryNew = LAST_INSERT_ID();
-
- INSERT INTO buy (entryFk,
- itemFk,
- quantity,
- buyingValue,
- packageFk,
- stickers,
- freightValue,
- packageValue,
- comissionValue,
- packing,
- `grouping`,
- groupingMode,
- location,
- price1,
- price2,
- price3,
- minPrice,
- producer,
- printedStickers,
- isChecked,
- weight)
- SELECT vEntryNew,
- itemFk,
- quantity,
- buyingValue,
- packageFk,
- stickers,
- freightValue,
- packageValue,
- comissionValue,
- packing,
- `grouping`,
- groupingMode,
- location,
- price1,
- price2,
- price3,
- minPrice,
- producer,
- printedStickers,
- isChecked,
- weight
- FROM buy
- WHERE entryFk = vAuxEntryFk;
-
- FETCH vRsEntry INTO vAuxEntryFk;
- END WHILE;
- CLOSE vRsEntry;
- COMMIT;
-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 DROP PROCEDURE IF EXISTS `cmr_getByTicket` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -53866,16 +48848,14 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `cmr_getByTicket`(vTicketFk INT)
BEGIN
- DECLARE vLandingDays INT;
+ DECLARE vLanded DATE;
- SELECT landingDays INTO vLandingDays
- FROM vn.cmrConfig;
+ SELECT DATE_ADD(util.VN_CURDATE(), INTERVAL landingDays DAY) INTO vLanded
+ FROM vn.cmrConfig;
IF vTicketFk THEN
@@ -53885,11 +48865,9 @@ BEGIN
ELSE
- INSERT INTO vn.cmr(ticketFk, companyFk, addressFromFk, addressToFk, supplierFk, ead)
- SELECT vTicketFk, t.companyFk, a.id, t.addressFk, ag.supplierFk, vLandingDays
+ INSERT INTO vn.cmr(ticketFk, companyFk, addressFromFk, addressToFk, ead)
+ SELECT vTicketFk, t.companyFk, a.id, t.addressFk, vLanded
FROM vn.ticket t
- JOIN vn.agencyMode am ON am.id = t.agencyModeFk
- JOIN vn.agency ag ON ag.id = am.agencyFk
JOIN vn.warehouse w ON w.id = t.warehouseFk
JOIN vn.address a ON a.id = w.addressFk
WHERE t.id = vTicketFk;
@@ -53900,7 +48878,7 @@ BEGIN
ELSE
- INSERT INTO vn.cmr(created, ead) VALUES(NOW(), NOW() + INTERVAL vLandingDays DAY);
+ INSERT INTO vn.cmr(ead) VALUES(vLanded);
SELECT LAST_INSERT_ID();
@@ -53911,55 +48889,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `cmr_new__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `cmr_new__`(vTicketFk INT)
-BEGIN
-
- IF vTicketFk THEN
-
- IF (SELECT count(ticketFk) FROM vn.cmr WHERE ticketFk = vTicketFk) THEN
-
- SELECT id FROM vn.cmr WHERE ticketFk = vTicketFk;
-
- ELSE
-
- INSERT INTO vn.cmr(ticketFk, companyFk, addressFromFk, addressToFk, supplierFk)
- SELECT vTicketFk, t.companyFk, a.id, t.addressFk, ag.supplierFk
- FROM vn.ticket t
- JOIN vn.agencyMode am ON am.id = t.agencyModeFk
- JOIN vn.agency ag ON ag.id = am.agencyFk
- JOIN vn.company cm ON cm.id = t.companyFk
- JOIN vn.client c ON c.id = cm.clientFk
- JOIN vn.address a ON a.clientFk = c.id AND a.isDefaultAddress
- WHERE t.id = vTicketFk;
-
- SELECT LAST_INSERT_ID();
-
- END IF;
-
- ELSE
-
- INSERT INTO vn.cmr(created) VALUES(NOW());
-
- SELECT LAST_INSERT_ID();
-
- 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 DROP PROCEDURE IF EXISTS `cmr_sendOverview` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -53967,8 +48898,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `cmr_sendOverview`()
BEGIN
@@ -53977,7 +48906,7 @@ BEGIN
*/
SET SESSION group_concat_max_len = 1000000;
--- IF (DAY(CURDATE()) = 5) THEN
+-- IF (DAY(util.VN_CURDATE()) = 5) THEN
INSERT INTO
vn.mail (receiver,
replyTo,
@@ -53994,7 +48923,7 @@ BEGIN
Estimado cliente,
- A continuación le enviamos el resumen menual de CMR ',UPPER(MONTHNAME(CURDATE() - INTERVAL 1 MONTH)),' ', YEAR(CURDATE() - INTERVAL 1 MONTH), '.
+ A continuación le enviamos el resumen menual de CMR ',UPPER(MONTHNAME(util.VN_CURDATE() - INTERVAL 1 MONTH)),' ', YEAR(util.VN_CURDATE() - INTERVAL 1 MONTH), '.
Le rogamos que nos devuelva el resumen firmado a cmr@verdnatura.es
|
@@ -54013,8 +48942,8 @@ BEGIN
JOIN vn.address a ON c.addressToFk = a.id
JOIN vn.client c2 ON a.clientFk = c2.id
WHERE c.state = 'Pending'
- AND MONTH(c.created) = MONTH(CURDATE() - INTERVAL 1 MONTH)
- AND YEAR(c.created) = YEAR(CURDATE() - INTERVAL 1 MONTH)
+ AND MONTH(c.created) = MONTH(util.VN_CURDATE() - INTERVAL 1 MONTH)
+ AND YEAR(c.created) = YEAR(util.VN_CURDATE() - INTERVAL 1 MONTH)
AND c2.email IS NOT NULL -- No cogemos los CMRs dirigidos a 'Verdnatura'
GROUP BY c2.id;
@@ -54022,8 +48951,8 @@ BEGIN
UPDATE vn.cmr c
SET c.state = 'Sent'
WHERE c.state = 'Pending'
- AND MONTH(c.created) = MONTH(CURDATE() - INTERVAL 1 MONTH)
- AND YEAR(c.created) = YEAR(CURDATE() - INTERVAL 1 MONTH);
+ AND MONTH(c.created) = MONTH(util.VN_CURDATE() - INTERVAL 1 MONTH)
+ AND YEAR(c.created) = YEAR(util.VN_CURDATE() - INTERVAL 1 MONTH);
-- END IF;
END ;;
DELIMITER ;
@@ -54031,50 +48960,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `collectionOrTicket_printSticker` */;
-/*!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_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `collectionOrTicket_printSticker`(vParam INT, vSectorFk INT)
-BEGIN
-
- /*Imprime una etiqueta amarilla a partir de una colección o ticket
- *
- * @param vParam colección o ticket a imprimir
- * @param vSectorFk id del sector
- */
-
- DECLARE vLabelReport INT;
-
- SELECT labelReportFk INTO vLabelReport
- FROM sector
- WHERE id = vSectorFk;
-
- IF vLabelReport THEN
-
- INSERT INTO ticketTrolley(ticket, labelCount)
- SELECT ticketFk, 1
- FROM ticketCollection
- WHERE collectionFk = vParam OR ticketFK = vParam
- ON DUPLICATE KEY UPDATE labelCount = labelCount + 1;
-
- INSERT INTO printServerQueue(labelReportFk, param1, workerFk)
- SELECT vLabelReport, vParam, getUser();
-
- 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 sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `collectionPlacement_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -54082,8 +48969,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `collectionPlacement_get`(vParamFk INT(11), vIsPicker bool)
BEGIN
@@ -54097,7 +48982,7 @@ BEGIN
DECLARE vCalcFk INT;
DECLARE vWarehouseFk INT;
DECLARE vWarehouseAliasFk INT;
- DECLARE vCurrentYear INT DEFAULT YEAR(NOW());
+ DECLARE vCurrentYear INT DEFAULT YEAR(util.VN_NOW());
DROP TEMPORARY TABLE IF EXISTS tmp.sale;
CREATE TEMPORARY TABLE tmp.sale
@@ -54171,7 +49056,7 @@ BEGIN
ts.itemFk,
CAST(0 AS DECIMAL(10,0)) as saleOrder,
IF(ts.isStowaway, - 100000, IF(ish.visible > 0 OR iss.id, 1, 100000)) * p.pickingOrder as `order`,
- IF(iss.id, TO_SECONDS(TIMESTAMPADD(YEAR,-vCurrentYear,iss.created)), TO_SECONDS(TIMESTAMPADD(YEAR,- year(ish.created),ish.created)) /* + TO_SECONDS(TIMESTAMPADD(YEAR,-vCurrentYear,NOW())) */) as priority,
+ IF(iss.id, TO_SECONDS(TIMESTAMPADD(YEAR,-vCurrentYear,iss.created)), TO_SECONDS(TIMESTAMPADD(YEAR,- year(ish.created),ish.created)) /* + TO_SECONDS(TIMESTAMPADD(YEAR,-vCurrentYear,util.VN_NOW())) */) as priority,
CONCAT(
IF( iss.id,
CONCAT('< ', IFNULL(wk.`code`, '---'),' > '),
@@ -54218,6 +49103,7 @@ BEGIN
IF(visible > 0 OR itemShelvingSaleFk,1,2),
IFNULL(shelvingPriority,0) DESC,
priority
+ LIMIT 10000000000000000000
) sub
GROUP BY saleFk;
@@ -54259,46 +49145,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `collectionSticker_print` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `collectionSticker_print`(vCollectionFk INT, vSectorFk INT)
-BEGIN
-
- /*@deprecated :utilizar collectionOrTicket_printSticker*/
-
- DECLARE vLabelReport INT;
-
- SELECT labelReportFk INTO vLabelReport
- FROM vn.sector
- WHERE id = vSectorFk;
-
- IF vLabelReport THEN
-
- INSERT INTO vn.ticketTrolley(ticket, labelCount)
- SELECT ticketFk, 1
- FROM vn.ticketCollection
- WHERE collectionFk = vCollectionFk
- ON DUPLICATE KEY UPDATE labelCount = labelCount + 1;
-
- INSERT INTO vn.printServerQueue(labelReportFk, param1, workerFk)
- SELECT vLabelReport, vCollectionFk, getUser();
-
- 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 DROP PROCEDURE IF EXISTS `collection_addItem` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -54306,8 +49154,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_addItem`(vItemFk INT, vQuantity INT, vTicketFk INT)
BEGIN
@@ -54320,7 +49166,7 @@ BEGIN
SELECT barcodeToItem(vItemFk) INTO itemFk;
- SELECT CONCAT(vn.getUser()," ",DATE_FORMAT(NOW( ), "%H:%i" )," ",i.name) INTO vConcept FROM vn.item i WHERE i.id = itemFk;
+ SELECT CONCAT(vn.getUser()," ",DATE_FORMAT(util.VN_NOW( ), "%H:%i" )," ",i.name) INTO vConcept FROM vn.item i WHERE i.id = itemFk;
SELECT name INTO vItemName FROM vn.item WHERE id = vItemFk;
SELECT CONCAT("Añadido articulo ", vItemName, " cantidad:", vQuantity) INTO vDescription;
@@ -54341,6 +49187,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `collection_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -54348,8 +49196,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_get`(vWorkerFk INT)
BEGIN
@@ -54366,7 +49212,7 @@ BEGIN
JOIN vn.state ss on ss.code = 'PREPARED'
LEFT JOIN vn.saleTracking st on st.saleFk = s.id AND st.stateFk = ss.id
WHERE c.workerFk = vWorkerFk
- AND c.created >= TIMESTAMPADD(HOUR , -6,NOW())
+ AND c.created >= TIMESTAMPADD(HOUR , -6,util.VN_NOW())
AND s.quantity != 0
GROUP BY c.id
HAVING totalRow > pickedRow;
@@ -54377,6 +49223,8 @@ DELIMITER ;
/*!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 `collection_getTickets` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -54384,8 +49232,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_getTickets`(vParamFk INT)
BEGIN
@@ -54450,6 +49296,8 @@ DELIMITER ;
/*!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 `collection_get_` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -54457,8 +49305,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_get_`(vWorkerFk INT)
BEGIN
@@ -54472,7 +49318,7 @@ BEGIN
FROM vn.collection c
LEFT JOIN vn.state s ON c.stateFk = s.id
WHERE c.workerFk = vWorkerFk AND s.code = 'ON_PREPARATION'
- AND created >= TIMESTAMPADD(HOUR , -6,NOW());
+ AND created >= TIMESTAMPADD(HOUR , -6,util.VN_NOW());
END ;;
@@ -54481,6 +49327,8 @@ DELIMITER ;
/*!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 `collection_kill` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -54488,8 +49336,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_kill`(vSelf INT)
BEGIN
@@ -54513,6 +49359,8 @@ DELIMITER ;
/*!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 `collection_missingTrash` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -54520,8 +49368,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_missingTrash`(vSaleFk BIGINT, vQuantity INT, vIsTrash BOOLEAN, vWarehouseFk INT, vNewQuantity INT)
BEGIN
@@ -54545,7 +49391,7 @@ BEGIN
INSERT INTO vn.ticketLog (originFk, userFk, action , description)
VALUES(vOrigin, vn.getUser(), 'update', vDescription);
- SELECT t.id INTO vTicketFk FROM vn.ticket t WHERE t.created > DATE_SUB(NOW(), INTERVAL 1 DAY) AND t.clientFk = vClientFk AND t.warehouseFk = vWarehouseFk LIMIT 1;
+ SELECT t.id INTO vTicketFk FROM vn.ticket t WHERE t.created > DATE_SUB(util.VN_NOW(), INTERVAL 1 DAY) AND t.clientFk = vClientFk AND t.warehouseFk = vWarehouseFk LIMIT 1;
IF vTicketFk IS NULL THEN
SELECT c.name , co.id INTO vClientName,vConsignatario
@@ -54555,22 +49401,22 @@ BEGIN
LIMIT 1;
CALL ticket_add(vClientFk,
- NOW(), vWarehouseFk,
+ util.VN_NOW(), vWarehouseFk,
442,
vConsignatario,
NULL,
NULL,
NULL,
- account.userGetId(),
+ account.myUser_getId(),
TRUE,
vTicketFk);
- SELECT t.id INTO vTicketFk FROM vn.ticket t WHERE t.created > DATE_SUB(NOW(), INTERVAL 1 DAY) AND t.clientFk = vClientFk AND t.warehouseFk = vWarehouseFk LIMIT 1;
+ SELECT t.id INTO vTicketFk FROM vn.ticket t WHERE t.created > DATE_SUB(util.VN_NOW(), INTERVAL 1 DAY) AND t.clientFk = vClientFk AND t.warehouseFk = vWarehouseFk LIMIT 1;
END IF;
INSERT INTO vn.sale (itemFk, ticketFk, concept, quantity, originalQuantity, price, discount, priceFixed, reserved, isPicked, isPriceFixed, created, isAdded)
- SELECT itemFk, vTicketFk, CONCAT(concept," ",vn.getWorkerCode(), " ",LEFT(CAST(NOW() AS TIME),5)), vQuantity, originalQuantity, price, discount, priceFixed, reserved, isPicked, isPriceFixed, created, isAdded
+ SELECT itemFk, vTicketFk, CONCAT(concept," ",vn.getWorkerCode(), " ",LEFT(CAST(util.VN_NOW() AS TIME),5)), vQuantity, originalQuantity, price, discount, priceFixed, reserved, isPicked, isPriceFixed, created, isAdded
FROM vn.sale s WHERE s.id = vSaleFk;
SELECT quantity INTO vOriginalQuantity FROM vn.sale WHERE id = vSaleFk;
@@ -54582,6 +49428,8 @@ DELIMITER ;
/*!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 `collection_newSmartTag` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -54589,523 +49437,61 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_newSmartTag`(vSectorFk INT)
proc:BEGIN
-
- DECLARE vIsPreviousPrepared BOOLEAN;
- DECLARE vCollectionFk INT;
- DECLARE vWarehouseFk INT;
- DECLARE vMaxTickets INT;
- DECLARE vStateFk INT;
- DECLARE vFirstTicketFk INT;
- DECLARE vHour INT;
- DECLARE vMinute INT;
- DECLARE vWorker INT;
- DECLARE vWorkerCode VARCHAR(3);
- DECLARE vWagon INT;
- DECLARE vWagonCounter INT;
- DECLARE vShelve INT;
- DECLARE vTicket INT;
- DECLARE vTicketToSplit INT;
- DECLARE myUserIsSalesPersonRole BOOLEAN;
- DECLARE vPrintedTickets INT;
- DECLARE vMaxTicketPrinted INT;
- DECLARE vItemPackingTypeFk VARCHAR(1);
- DECLARE hasAssignedTickets BOOLEAN;
- DECLARE vMaxNotReadyCollections INT DEFAULT 0;
- DECLARE vNotReadyCollections INT;
- DECLARE vSectorCode VARCHAR(20);
+ DECLARE vWorkerFk INT;
DECLARE vWagons INT;
-
- SELECT w.code, w.id INTO vWorkerCode, vWorker
+ DECLARE vCollectionFk INT;
+
+ SELECT w.id INTO vWorkerFk
FROM vn.worker w
WHERE w.id = vn.getUser();
-
--- Si hay colecciones sin terminar, sale del proceso
- SELECT count(*) INTO vNotReadyCollections
- FROM vn.collection c
- WHERE c.workerFk = vn.getUser()
- AND c.saleTotalCount > c.salePickedCount + 1
- AND c.created > TIMESTAMPADD(HOUR , -5,NOW());
- IF vMaxNotReadyCollections < vNotReadyCollections THEN
-
- LEAVE proc;
-
- END IF;
-
- -- Establecemos el almacén y si es un sector de preparación previa, así como el estado para los tickets que se vayan preparando
- SELECT isPreviousPrepared, warehouseFk, itemPackingTypeFk, code
- INTO vIsPreviousPrepared, vWarehouseFk, vItemPackingTypeFk, vSectorCode
- FROM vn.sector
- WHERE id = vSectorFk;
+ SELECT COUNT(ws.id) INTO vWagons
+ FROM workerShelving ws
+ WHERE ws.workerFk = vWorkerFk
+ AND ws.collectionFk IS NULL;
- -- Cogemos el numero de wagons del trabajador
- SELECT COUNT(ws.id)
- FROM workerShelving ws
- WHERE ws.workerFk = vWorker
- AND ws.collectionFk IS NULL
- INTO vWagons;
-
- SET vMaxTicketPrinted = 8 * vWagons;
- SET vMaxTickets = 3 * vWagons;
-
-
- IF vIsPreviousPrepared THEN
-
- LEAVE proc; -- Hasta que tengamos el altillo, vamos a cancelar esta opcion
-
- SELECT id INTO vStateFk
- FROM vn.state
- WHERE `code` = 'PREVIOUS_PREPARATION';
- ELSE
-
- SELECT id INTO vStateFk
- FROM vn.state
- WHERE `code` = 'ON_PREPARATION';
-
- END IF;
-
- -- Averiguamos si es comercial el usuario
- SELECT FALSE -- (r.name = 'salesPerson')
- INTO myUserIsSalesPersonRole
- FROM account.user u
- JOIN account.role r ON r.id = u.role
- WHERE u.id = vn.getUser();
-
- -- Se obtiene nº de colección y el buffer con los pedidos preparables
- INSERT INTO vn.collection
- SET workerFk = account.myUser_getId(),
- itemPackingTypeFk = vItemPackingTypeFk;
-
- SELECT LAST_INSERT_ID() INTO vCollectionFk;
+ CALL collection_newWithWagon(vSectorFk, vWagons);
- UPDATE workerShelving
- SET collectionFk = vCollectionFk
- WHERE workerFk = vWorker
- AND collectionFk IS NULL;
-
- CALL vn.productionControl(vWarehouseFk, 0);
-
- -- Comprobamos si hay tickets asignados. En ese caso, nos centramos exclusivamente en esos tickets
- -- y los sacamos independientemente de problemas o tamaños
- SELECT COUNT(*) INTO hasAssignedTickets
- FROM tmp.productionBuffer pb
- JOIN vn.state s ON s.id = pb.state
- WHERE s.code = 'PICKER_DESIGNED'
- AND pb.workerCode = vWorkerCode
- AND LENGTH(pb.problem) = 0;
-
- IF hasAssignedTickets THEN
-
- UPDATE vn.collection
- SET itemPackingTypeFk = NULL
- WHERE id = vCollectionFk;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketToSplit;
- CREATE TEMPORARY TABLE tmp.ticketToSplit
- SELECT pb.ticketFk
- FROM tmp.productionBuffer pb
- JOIN vn.state s ON s.id = pb.state
- WHERE s.code = 'PICKER_DESIGNED'
- AND pb.workerCode = vWorkerCode
- AND LENGTH(pb.problem) = 0
- ORDER BY HH,
- mm,
- s.`order` DESC,
- pb.m3 DESC;
-
- WHILE (SELECT COUNT(*) FROM tmp.ticketToSplit) DO
-
- SELECT MIN(ticketFk) INTO vTicketToSplit
- FROM tmp.ticketToSplit;
-
- CALL vn.ticket_splitItemPackingType(vTicketToSplit);
-
- INSERT INTO vn.ticketCollection(ticketFk, collectionFk)
- SELECT ticketFk, vCollectionFk
- FROM tmp.ticketIPT;
-
- DELETE FROM tmp.ticketToSplit
- WHERE ticketFk = vTicketToSplit;
-
- DROP TEMPORARY TABLE tmp.ticketIPT;
-
- END WHILE;
-
- CALL vn.productionControl(vWarehouseFk, 0);
-
- ELSE
-
- SELECT COUNT(*) INTO vPrintedTickets
- FROM tmp.productionBuffer pb
- JOIN vn.state s ON s.id = pb.state
- JOIN vn.agencyMode am ON am.id = pb.agencyModeFk
- JOIN vn.agency a ON a.id = am.agencyFk
- WHERE pb.shipped = CURDATE()
- AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE )
- AND s.isPreparable
- AND (pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH)
- OR pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV)
- OR pb.F > 0 AND vItemPackingTypeFk = 'F' AND ISNULL(pb.collectionF)
- OR pb.P > 0 AND vItemPackingTypeFk = 'P' AND ISNULL(pb.collectionP));
-
- SET vMaxTicketPrinted = vMaxTicketPrinted - vPrintedTickets;
- -- AutoPRINT
-
- IF vMaxTicketPrinted > 0 THEN
-
- INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador)
- SELECT s2.id, pb.ticketFk, vn.getUser()
- FROM tmp.productionBuffer pb
- JOIN vn.agencyMode am ON am.id = pb.agencyModeFk
- JOIN vn.agency a ON a.id = am.agencyFk
- JOIN vn.state s ON s.id = pb.state
- JOIN vn.state s2 ON s2.code = 'PRINTED_AUTO'
- JOIN vn.ticket t ON t.id = pb.ticketFk
- WHERE pb.shipped = CURDATE()
- AND LENGTH(pb.problem) = 0
- AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE )
- AND s.isPrintable
- AND (pb.m3 > 0.05 OR s.isOK)
- AND (pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH)
- OR pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV)
- OR pb.F > 0 AND vItemPackingTypeFk = 'F' AND ISNULL(pb.collectionF)
- OR pb.P > 0 AND vItemPackingTypeFk = 'P' AND ISNULL(pb.collectionP))
- AND t.created < TIMESTAMPADD(MINUTE, -10, NOW())
- ORDER BY HH,
- mm,
- s.`order` DESC,
- pb.m3 DESC
- LIMIT vMaxTicketPrinted;
-
- END IF;
-
- -- Se seleccionan los primeros tickets, asignando colección para dejarlos bloqueados a otros sacadores.
- -- Se splitan los tickets preparables, para que solo tengan un tipo de empaquetado
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketToSplit;
- CREATE TEMPORARY TABLE tmp.ticketToSplit
- SELECT pb.ticketFk
- FROM tmp.productionBuffer pb
- JOIN vn.agencyMode am ON am.id = pb.agencyModeFk
- JOIN vn.agency a ON a.id = am.agencyFk
- JOIN vn.ticketStateToday tst ON tst.ticket = pb.ticketFk
- JOIN vn.state s ON s.id = tst.state
- WHERE ( pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH)
- OR pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV)
- OR pb.F > 0 AND vItemPackingTypeFk = 'F' AND ISNULL(pb.collectionF)
- OR pb.P > 0 AND vItemPackingTypeFk = 'P' AND ISNULL(pb.collectionP))
- AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE )
- AND LENGTH(pb.problem) = 0
- AND s.isPreparable
- AND NOT myUserIsSalesPersonRole
- ORDER BY pb.HH, pb.mm, s.`order` DESC
- LIMIT vMaxTickets;
-
- WHILE (SELECT COUNT(*) FROM tmp.ticketToSplit) DO
-
- SELECT MIN(ticketFk) INTO vTicketToSplit
- FROM tmp.ticketToSplit;
-
- CALL vn.ticket_splitItemPackingType(vTicketToSplit);
-
- INSERT INTO vn.ticketCollection(ticketFk, collectionFk)
- SELECT ticketFk, vCollectionFk
- FROM tmp.ticketIPT
- WHERE itemPackingTypeFk = vItemPackingTypeFk;
-
- DELETE FROM tmp.ticketToSplit
- WHERE ticketFk = vTicketToSplit;
-
- DROP TEMPORARY TABLE tmp.ticketIPT;
-
- END WHILE;
-
- END IF;
+ SELECT id INTO vCollectionFk
+ FROM collection
+ WHERE workerFk = vWorkerFk
+ ORDER BY created DESC
+ LIMIT 1;
- -- Creamos una tabla temporal con los datos que necesitamos para depurar la colección
- DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
- CREATE TEMPORARY TABLE tmp.ticket
- SELECT pb.ticketFk,
- pb.`lines`,
- pb.m3 * 1000 liters,
- 0 as height,
- 0 as shelve,
- 0 as wagon,
- pb.productionOrder,
- pb.HH,
- pb.mm
- FROM tmp.productionBuffer pb
- JOIN vn.ticketCollection tc ON tc.ticketFk = pb.ticketFk
- WHERE tc.collectionFk = vCollectionFk
- LIMIT vMaxTickets;
-
- -- Es importante que el primer ticket se coja en todos los casos
- SET vFirstTicketFk = 0;
-
- SELECT ticketFk, HH, mm
- INTO vFirstTicketFk, vHour, vMinute
- FROM tmp.ticket
- ORDER BY productionOrder DESC, HH, mm
- LIMIT 1;
-
- -- Hay que excluir aquellos que no tengan la misma hora de preparación
- DELETE
- FROM tmp.ticket
- WHERE HH != vHour
- OR mm != vMinute;
-
- -- En el caso de pedidos de más volumen de un carro, la colección será monoticket. Pero si el primer pedido
- -- no es monoticket, excluimos a los de más de un carro
- IF (SELECT (t.liters > vc.trolleyM3 * 1000)
- FROM tmp.ticket t
- JOIN vn.volumeConfig vc
- WHERE t.ticketFk = vFirstTicketFk) THEN
-
- DELETE
- FROM tmp.ticket
- WHERE ticketFk != vFirstTicketFk;
-
- ELSE
-
- DELETE t.*
- FROM tmp.ticket t
- JOIN vn.volumeConfig vc
- WHERE t.liters > vc.trolleyM3 * 1000;
-
- END IF;
-
- -- Elimina los tickets bloqueados que no se van a preparar
- DELETE tc.*
- FROM vn.ticketCollection tc
- LEFT JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk
- WHERE tc.collectionFk = vCollectionFk
- AND t.ticketFk IS NULL;
-
- /*
- *
- * Construccion del tren
- *
- */
-
- -- Establece altura máxima por pedido, porque las plantas no se pueden recostar.
- UPDATE tmp.ticket t
- JOIN
- ( SELECT MAX(i.size) maxHeigth,
- tc.ticketFk
- FROM vn.ticketCollection tc
- JOIN vn.sale s ON s.ticketFk = tc.ticketFk
- JOIN vn.item i ON i.id = s.itemFk
- WHERE i.itemPackingTypeFk = 'V'
- AND tc.collectionFk = vCollectionFk
- GROUP BY tc.ticketFk) sub ON sub.ticketFk = t.ticketFk
- SET t.height = IFNULL(sub.maxHeigth,0);
-
- -- Vamos a generar una tabla con todas las posibilidades de asignacion de pedido
- DROP TEMPORARY TABLE IF EXISTS tmp.wagonsVolumetry;
- CREATE TEMPORARY TABLE tmp.wagonsVolumetry
- SELECT cv.`level` as shelve,
- 1 as wagon,
- cv.`lines`,
- cv.liters,
- cv.height
- FROM vn.collectionVolumetry cv;
-
- SET vWagonCounter = 1;
-
- WHILE vWagonCounter < vWagons DO
-
- SET vWagonCounter = vWagonCounter + 1;
-
- INSERT INTO tmp.wagonsVolumetry(shelve, wagon, `lines`, liters, height)
- SELECT cv.`level` as shelve,
- vWagonCounter as wagon,
- cv.`lines`,
- cv.liters,
- cv.height
- FROM vn.collectionVolumetry cv
- WHERE cv.itemPackingTypeFk = IFNULL(vItemPackingTypeFk, 'H');
-
- END WHILE;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketShelve;
- CREATE TEMPORARY TABLE tmp.ticketShelve
- SELECT ticketFk, shelve, wagon, linesDif, LitersDif, heightDif
+ UPDATE workerShelving ws
+ SET ws.collectionFk = vCollectionFk
+ WHERE ws.workerFk = vWorkerFk
+ AND ws.collectionFk IS NULL;
+
+ SET @wagon := 0;
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.smartTags;
+ CREATE TEMPORARY TABLE tmp.smartTags
+ SELECT s.code, sub.wagon, s.level
FROM (
- SELECT t.ticketFk,
- wv.shelve,
- wv.wagon,
- t.productionOrder,
- CAST(wv.`lines` AS SIGNED) - t.`lines` as linesDif,
- CAST(wv.liters AS SIGNED) - t.liters as litersDif,
- CAST(wv.height AS SIGNED) - t.height as heightDif
- FROM tmp.wagonsVolumetry wv
- JOIN tmp.ticket t
- ) sub
- WHERE linesDif >= 0
- AND litersDif >= 0
- AND heightDif >= 0
- ORDER BY productionOrder DESC, linesDif, LitersDif, heightDif ;
-
- -- Insertamos una opcion virtual para carro completo. Todo ticket tiene que poder entrar en un carro completo....
- INSERT INTO tmp.ticketShelve(ticketFk, shelve, wagon, linesDif, LitersDif, heightDif)
- SELECT t.ticketFk, 0, wv.wagon, 999, 999,999
- FROM tmp.ticket t
- JOIN tmp.wagonsVolumetry wv
- GROUP BY t.ticketFk, wv.wagon;
-
- SET vWagonCounter = 0;
-
- WHILE vWagonCounter < vWagons DO
-
- SET vWagonCounter = vWagonCounter + 1;
-
- -- Asignamos la primera balda util al primer pedido
- IF vWagonCounter = 1 THEN
-
- SELECT shelve INTO vShelve
- FROM tmp.ticketShelve
- WHERE ticketFk = vFirstTicketFk
- AND wagon = vWagonCounter
- ORDER BY heightDif, litersDif, linesDif
- LIMIT 1;
-
- ELSE
-
- SELECT shelve, ticketFk INTO vShelve, vFirstTicketFk
- FROM tmp.ticketShelve
- WHERE wagon = vWagonCounter
- ORDER BY heightDif, litersDif, linesDif
- LIMIT 1;
-
- END IF;
-
- IF vShelve > 0 THEN
-
- UPDATE tmp.ticket
- SET shelve = vShelve,
- wagon = vWagonCounter
- WHERE ticketFk = vFirstTicketFk;
-
- DELETE FROM tmp.ticketShelve
- WHERE ticketFk = vFirstTicketFk
- OR (shelve = vShelve AND wagon = vWagonCounter);
-
- WHILE (SELECT COUNT(*) FROM tmp.ticketShelve WHERE wagon = vWagonCounter) DO
-
- SELECT ticketFk, shelve
- INTO vTicket, vShelve
- FROM tmp.ticketShelve
- WHERE wagon = vWagonCounter
- LIMIT 1;
-
- UPDATE tmp.ticket
- SET shelve = vShelve,
- wagon = vWagonCounter
- WHERE ticketFk = vTicket;
-
- DELETE FROM tmp.ticketShelve
- WHERE ticketFk = vTicket
- OR (shelve = vShelve AND wagon = vWagonCounter);
-
- END WHILE;
-
- ELSE
-
- UPDATE tmp.ticket
- SET shelve = 1, wagon = vWagonCounter
- WHERE ticketFk = vFirstTicketFk;
-
- DELETE FROM tmp.ticketShelve
- WHERE ticketFk = vFirstTicketFk
- AND wagon != vWagonCounter;
-
- END IF;
-
- END WHILE;
-
- -- Eliminamos los que se han quedado sin balda
- DELETE FROM tmp.ticket WHERE shelve = 0;
-
- -- Elimina los tickets bloqueados que no se van a preparar
- DELETE tc.*
- FROM vn.ticketCollection tc
- LEFT JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk
- WHERE tc.collectionFk = vCollectionFk
- AND t.ticketFk IS NULL;
-
- -- Elimina los tickets que ya estan en otra coleccion
- DELETE tc.*
- FROM vn.ticketCollection tc
- JOIN vn.ticketCollection tc2 ON tc2.ticketFk = tc.ticketFk
- WHERE tc.collectionFk = vCollectionFk
- AND tc2.collectionFk != vCollectionFk;
-
- -- Actualiza el estado de la colección
- UPDATE vn.collection c
- JOIN vn.state st ON st.code = 'ON_PREPARATION'
- SET c.stateFk = st.id
- WHERE c.id = vCollectionFk;
-
- -- Asigna las bandejas y las smartTags
- SET @wagon := 0;
- UPDATE vn.ticketCollection tc
- JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk
- JOIN (SELECT @wagon:=@wagon+1 as wagon, ws.shelvingFk
+ SELECT @wagon:=@wagon+1 as wagon, ws.shelvingFk
FROM workerShelving ws
- WHERE ws.collectionFk = vCollectionFk) sub ON sub.wagon = t.wagon
- JOIN smartTag s ON s.shelvingFk = sub.shelvingFk AND s.`level` = t.shelve
- SET tc.`level` = t.shelve, tc.wagon = t.wagon, tc.smartTagFk = s.code;
+ WHERE ws.collectionFk = vCollectionFk) sub
+ JOIN smartTag s ON s.shelvingFk = sub.shelvingFk
+ ORDER BY wagon ASC, level ASC;
- -- Actualiza el estado de los tickets
- INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador)
- SELECT vStateFk, ticketFk, account.myUser_getId()
- FROM vn.ticketCollection tc
- WHERE tc.collectionFk = vCollectionFk;
-
- -- Aviso para la preparacion previa
- INSERT INTO vn.ticketDown(ticketFk, collectionFk)
- SELECT tc.ticketFk, tc.collectionFk
- FROM vn.ticketCollection tc
- WHERE tc.collectionFk = vCollectionFk;
-
- IF (SELECT count(*) FROM vn.ticketCollection WHERE collectionFk = vCollectionFk) THEN
-
- CALL vn.salesMerge_byCollection(vCollectionFk);
-
- UPDATE vn.collection c
- JOIN (SELECT count(*) saleTotalCount ,
- sum(s.isPicked != 0) salePickedCount
- FROM vn.ticketCollection tc
- JOIN vn.sale s ON s.ticketFk = tc.ticketFk
- WHERE tc.collectionFk = vCollectionFk
- AND s.quantity > 0
- ) sub
- SET c.saleTotalCount = sub.saleTotalCount,
- c.salePickedCount = sub.salePickedCount
- WHERE c.id = vCollectionFk;
-
- SELECT vCollectionFk;
-
- ELSE
-
- DELETE FROM vn.collection WHERE id = vCollectionFk;
- -- SELECT NULL;
-
- END IF;
-
- DROP TEMPORARY TABLE tmp.ticketToSplit;
-
+ UPDATE vn.ticketCollection tc
+ JOIN tmp.smartTags ts ON tc.wagon = ts.wagon AND tc.level = ts.level
+ SET tc.smartTagFk = ts.code
+ WHERE tc.collectionFk = vCollectionFk;
+
+ DROP TEMPORARY TABLE tmp.smartTags;
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 `collection_newWithWagon` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -55113,8 +49499,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_newWithWagon`(vSectorFk INT, vWagons INT)
proc:BEGIN
@@ -55154,7 +49538,7 @@ proc:BEGIN
SELECT w.code, w.id INTO vWorkerCode, vUserFk
FROM vn.worker w
- WHERE w.id =account.userGetId();
+ WHERE w.id =account.myUser_getId();
-- Establecemos el almacén y si es un sector de preparación previa, así como el estado para los tickets que se vayan preparando
SELECT isPreviousPrepared, warehouseFk, itemPackingTypeFk
@@ -55182,7 +49566,7 @@ proc:BEGIN
JOIN vn.state ss ON ss.code = 'PREPARED'
LEFT JOIN vn.saleTracking st ON st.saleFk = s.id AND st.stateFk = ss.id
WHERE c.workerFk = vUserFk
- AND c.created >= TIMESTAMPADD(HOUR , -6,NOW())
+ AND c.created >= TIMESTAMPADD(HOUR , -6,util.VN_NOW())
AND s.quantity != 0
GROUP BY c.id
HAVING totalRow > pickedRow) sub;
@@ -55301,7 +49685,7 @@ proc:BEGIN
JOIN vn.agencyMode am ON am.id = pb.agencyModeFk
JOIN vn.agency a ON a.id = am.agencyFk
JOIN vn.productionConfig pc
- WHERE pb.shipped = CURDATE()
+ WHERE pb.shipped = util.VN_CURDATE()
AND (pb.ubicacion IS NOT NULL
OR a.isOwn = FALSE )
AND s.isPreparable
@@ -55327,7 +49711,7 @@ proc:BEGIN
JOIN vn.ticket t ON t.id = pb.ticketFk
JOIN vn.ticketConfig tc
JOIN vn.productionConfig pc
- WHERE pb.shipped = CURDATE()
+ WHERE pb.shipped = util.VN_CURDATE()
AND (LENGTH(pb.problem) = 0
OR (pb.problem = 'PEQUEÑO' AND vTrainFk = 2))
AND (pb.ubicacion IS NOT NULL
@@ -55339,7 +49723,7 @@ proc:BEGIN
OR (pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV))
OR (pb.H = 0 AND pb.V = 0 AND pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV))
)
- AND t.created < TIMESTAMPADD(MINUTE, - tc.pickingDelay , NOW())
+ AND t.created < TIMESTAMPADD(MINUTE, - tc.pickingDelay , util.VN_NOW())
AND (pc.isPreviousPreparationRequired = FALSE
OR pb.previousWithoutParking = FALSE)
ORDER BY HH,
@@ -55710,6 +50094,8 @@ DELIMITER ;
/*!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 `collection_newWithWagon_beta` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -55717,8 +50103,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_newWithWagon_beta`(vUserFk INT, vSectorFk INT, vWagons INT)
proc:BEGIN
@@ -55746,7 +50130,7 @@ proc:BEGIN
DECLARE vTrainFk INT DEFAULT 1;
DECLARE vNow DATETIME;
- SELECT ticketPrintedMax * vWagons, ticketTrolleyMax * vWagons, pc.maxNotReadyCollections , NOW()
+ SELECT ticketPrintedMax * vWagons, ticketTrolleyMax * vWagons, pc.maxNotReadyCollections , util.VN_NOW()
INTO vMaxTicketPrinted, vMaxTickets, vMaxNotReadyCollections, vNow
FROM vn.productionConfig pc;
@@ -55779,7 +50163,7 @@ proc:BEGIN
JOIN vn.state ss ON ss.code = 'PREPARED'
LEFT JOIN vn.saleTracking st ON st.saleFk = s.id AND st.stateFk = ss.id
WHERE c.workerFk = vUserFk
- AND c.created >= TIMESTAMPADD(HOUR , -6,NOW())
+ AND c.created >= TIMESTAMPADD(HOUR , -6,util.VN_NOW())
AND s.quantity != 0
GROUP BY c.id
HAVING totalRow > pickedRow) sub;
@@ -55900,7 +50284,7 @@ call util.debugAdd('wargo',CONCAT('vNotReadyCollections ',vNotReadyCollections))
JOIN vn.agencyMode am ON am.id = pb.agencyModeFk
JOIN vn.agency a ON a.id = am.agencyFk
JOIN vn.productionConfig pc
- WHERE pb.shipped = CURDATE()
+ WHERE pb.shipped = util.VN_CURDATE()
AND (pb.ubicacion IS NOT NULL
OR a.isOwn = FALSE )
AND s.isPreparable
@@ -55929,7 +50313,7 @@ call util.debugAdd('wargo',CONCAT('vPrintedTickets ',vPrintedTickets));
JOIN vn.ticket t ON t.id = pb.ticketFk
JOIN vn.ticketConfig tc
JOIN vn.productionConfig pc
- WHERE pb.shipped = CURDATE()
+ WHERE pb.shipped = util.VN_CURDATE()
AND (LENGTH(pb.problem) = 0
OR (pb.problem = 'PEQUEÑO' AND vTrainFk = 2))
AND (pb.ubicacion IS NOT NULL
@@ -55941,7 +50325,7 @@ call util.debugAdd('wargo',CONCAT('vPrintedTickets ',vPrintedTickets));
OR (pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV))
OR (pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV))
)
- AND t.created < TIMESTAMPADD(MINUTE, - tc.pickingDelay , NOW())
+ AND t.created < TIMESTAMPADD(MINUTE, - tc.pickingDelay , util.VN_NOW())
AND (pc.isPreviousPreparationRequired = FALSE
OR pb.previousWithoutParking = FALSE)
ORDER BY HH,
@@ -56343,6 +50727,8 @@ DELIMITER ;
/*!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 `collection_printSticker` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -56350,47 +50736,68 @@ DELIMITER ;
/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_printSticker`(vCollection INT)
+CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_printSticker`(vSelf INT)
BEGIN
+/**
+ * Imprime una etiqueta amarilla a partir de una colección
+ *
+ * @param vSelf colección
+ * @param vPrinterFk id de la impresora
+ */
+ DECLARE vReportFk INT;
+ DECLARE vPrinterFk INT;
- /*Imprime una etiqueta amarilla a partir de una colección
- *
- * @param vCollection colección
- * @param vPrinterFk id de la impresora
- */
-
- DECLARE vLabelReportFk INT;
- DECLARE vLabelerFk INT;
-
-
- SELECT s.labelReportFk, w.labelerFk INTO vLabelReportFk, vLabelerFk
+ SELECT s.reportFk, w.labelerFk INTO vReportFk, vPrinterFk
FROM worker w
LEFT JOIN sector s ON s.id= w.sectorFk
- WHERE w.id=account.myUser_getId() ;
-
-
- IF vLabelReportFk AND vLabelerFk THEN
+ WHERE w.id = account.myUser_getId() ;
+ IF vReportFk AND vPrinterFk THEN
INSERT INTO ticketTrolley(ticket, labelCount)
SELECT ticketFk, 1
FROM ticketCollection
- WHERE collectionFk = vCollection
+ WHERE collectionFk = vSelf
ON DUPLICATE KEY UPDATE labelCount = labelCount + 1;
- INSERT INTO printServerQueue(labelReportFk, param1, workerFk,printerFk)
- SELECT vLabelReportFk, vCollection, getUser(),vLabelerFk;
-
+ INSERT INTO printQueue(priorityFk, reportFk, workerFk,printerFk)
+ SELECT qp.id, vReportFk, account.myUser_getId(), vPrinterFk
+ FROM queuePriority qp
+ WHERE qp.`code`= 'high';
+
+ INSERT INTO printQueueArgs (printQueueFk, `name`, `value` )
+ SELECT LAST_INSERT_ID(), 'param', vSelf;
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_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `collection_setParking` */;
+/*!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=`root`@`localhost` PROCEDURE `collection_setParking`(IN `vCollectionFk` VARCHAR(8), IN `vParkingFk` INT)
+proc: BEGIN
+ REPLACE vn.ticketParking(ticketFk, parkingFk)
+ SELECT tc.ticketFk, vParkingFk
+ FROM vn.ticketCollection tc
+ WHERE tc.collectionFk = vCollectionFk;
+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 `collection_updateSale` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -56398,8 +50805,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_updateSale`(
vSaleFk INT,
@@ -56442,6 +50847,8 @@ DELIMITER ;
/*!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 `company_getFiscaldata` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -56449,8 +50856,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `company_getFiscaldata`(workerFk INT)
BEGIN
@@ -56480,6 +50885,8 @@ DELIMITER ;
/*!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 `conveyorExpedition_Add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -56487,8 +50894,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `conveyorExpedition_Add`(vStarted DATETIME, vEnded DATETIME)
BEGIN
@@ -56545,6 +50950,8 @@ DELIMITER ;
/*!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 `copyComponentsFromSaleList` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -56552,8 +50959,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `copyComponentsFromSaleList`(vTargetTicketFk INT)
BEGIN
@@ -56592,6 +50997,8 @@ DELIMITER ;
/*!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 `createPedidoInterno` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -56599,8 +51006,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `createPedidoInterno`(vItemFk INT,vQuantity INT)
BEGIN
@@ -56614,115 +51019,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `cristalBall__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `cristalBall__`()
-BEGIN
-/*
-*se utiliza en campaña
-* sirve para tener un control del stock en Silla y fuentes
-*
-*/
-
-DECLARE vLastDate DATETIME DEFAULT '2019-10-30 23:59';
-DECLARE vWarehouse INT DEFAULT 1;
-DECLARE vPalletVolume INT DEFAULT 2200000;
-
-SELECT date(sub2.dat) dat,
- sub2.longName,
- sub2.size,
- sub2.subName,
- cast(sub2.entra as decimal(10,1)) as entra,
- cast(sub2.sale as decimal(10,1)) as sale,
- sub2.itemFk,
- @saldo := entra + sale + ifnull(fue.pal,0) + IF(sub2.itemFk = @item, @saldo, 0) as saldo,
- @item := sub2.itemFk as kk,
- cast(fue.pal as decimal(10,1)) as pal
-FROM
-(
- SELECT * FROM
- (
- SELECT e.dat,
- e.item_id as itemFk,
- i.longName,
- i.size,
- i.subName,
- sum(e.amount * r.cm3) / vPalletVolume as entra,
- 0 as sale
- FROM vn2008.item_entry_in e
- JOIN vn.item i ON i.id = e.item_id
- JOIN vn.itemType it ON it.id = i.typeFk
- JOIN vn.itemCategory ic ON ic.id = it.categoryFk
- JOIN bi.rotacion r ON r.Id_Article = e.item_id AND r.warehouse_id = e.warehouse_id
- WHERE e.dat BETWEEN CURDATE() AND vLastDate
- AND e.warehouse_id = vWarehouse
- AND ic.display
- AND e.isVirtualStock is FALSE
- GROUP BY e.dat, e.item_id
-
- UNION ALL
-
- SELECT s.dat,
- s.item_id as itemFk,
- i.longName,
- i.size,
- i.subName,
- 0 as entra,
- sum(s.amount * r.cm3) / vPalletVolume as sale
- FROM vn2008.item_out s
- JOIN vn.item i ON i.id = s.item_id
- JOIN vn.itemType it ON it.id = i.typeFk
- JOIN vn.itemCategory ic ON ic.id = it.categoryFk
- JOIN bi.rotacion r ON r.Id_Article = s.item_id AND r.warehouse_id = s.warehouse_id
- WHERE s.dat BETWEEN CURDATE() AND vLastDate
- AND s.warehouse_id = vWarehouse
- AND ic.display
- GROUP BY date(s.dat), s.item_id
-
- UNION ALL
-
- SELECT util.yesterday(),
- @item := st.item_id as itemFk,
- i.longName,
- i.size,
- i.subName,
- st.amount * r.cm3 / vPalletVolume ,
- @saldo := 0
- FROM cache.stock st
- JOIN vn.item i ON i.id = st.item_id
- JOIN vn.itemType it ON it.id = i.typeFk
- JOIN vn.itemCategory ic ON ic.id = it.categoryFk
- JOIN bi.rotacion r ON r.Id_Article = st.item_id AND r.warehouse_id = st.warehouse_id
- WHERE st.warehouse_id = vWarehouse
- AND ic.display
-
- ) sub
- ORDER BY itemFk, dat, entra DESC) sub2
- LEFT JOIN
- (
- SELECT itemFk,
- - sum(ish.visible ) * r.cm3 / vPalletVolume as pal
- FROM vn.itemShelving ish
- JOIN bi.rotacion r ON r.Id_Article = ish.itemFk AND r.warehouse_id = 1
- LEFT JOIN vn.shelving sh ON sh.code = ish.shelvingFk
- LEFT JOIN vn.parking p ON p.id = sh.parkingFk
- WHERE (sh.code = 'FUE' OR p.code = 'FUE-PI')
- GROUP BY itemFk) fue ON fue.itemFk = sub2.itemFk AND sub2.dat = util.yesterday()
- ;
-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 DROP PROCEDURE IF EXISTS `crypt` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -56730,8 +51028,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `crypt`(vText VARCHAR(255), vKey VARCHAR(255), OUT vResult VARCHAR(255) )
BEGIN
@@ -56793,6 +51089,8 @@ DELIMITER ;
/*!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 `cryptOff` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -56800,8 +51098,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `cryptOff`(vText VARCHAR(255), vKey VARCHAR(255), OUT vResult VARCHAR(255))
BEGIN
@@ -56860,6 +51156,8 @@ DELIMITER ;
/*!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 `dayMinuteWorker` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -56867,8 +51165,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `dayMinuteWorker`(vDateFrom DATETIME, vDateTo DATETIME)
BEGIN
@@ -56882,26 +51178,26 @@ BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp.dayMinuteWorker;
CREATE TEMPORARY TABLE tmp.dayMinuteWorker
SELECT sub3.id,
- sub3.hh AS `Hour`,
- sub3.mm AS Minut,
+ sub3.hh `Hour`,
+ sub3.mm Minut,
sub3.userFk,
- sub3.code AS workerCode,
- sub3.firstname AS name,
- sub3.lastName AS surnames,
- sub3.workcenterFk AS center,
- w.name AS centerName,
- w2.name AS warehouseName,
- w2.hasProduction AS production
- FROM postgresql.workcenter w
+ sub3.code workerCode,
+ sub3.firstname name,
+ sub3.lastName surnames,
+ sub3.workcenterFk center,
+ w.name centerName,
+ w2.name warehouseName,
+ w2.hasProduction production
+ FROM vn.workCenter w
JOIN(SELECT id,
hh,
mm,
userFk,
code,
firstname,
- lastName,
+ lastName,
@ordr := IF(@user != userFk,0,@ordr),
- IF(@ordr MOD 2, 'presente','--') AS state,
+ IF(@ordr MOD 2, 'presente','--') state,
@ordr := IFNULL(sub2.`order`,@ordr),
@user := IFNULL(sub2.`userFk`,@user),
workcenterFk
@@ -56923,7 +51219,7 @@ BEGIN
FROM vn.workerTimeControl wtc
JOIN vn.worker w ON w.userFk = wtc.userFk
JOIN vn.workerLabour wl ON wl.workerFK = w.id
- AND wtc.timed BETWEEN wl.started AND IFNULL(wl.ended, CURDATE())
+ AND wtc.timed BETWEEN wl.started AND IFNULL(wl.ended, util.VN_CURDATE())
WHERE wtc.timed BETWEEN vDateStart AND vDateEnd
) users
LEFT JOIN(SELECT `order`,
@@ -56935,7 +51231,7 @@ BEGIN
) sub ON sub.dayMinuteFk = dm.id AND sub.userFk = users.userFk
ORDER BY userFk,dm.id
) sub2
- ) sub3 ON sub3.workcenterFk = w.workcenter_id
+ ) sub3 ON sub3.workcenterFk = w.id
JOIN vn.warehouse w2 ON w2.id = w.warehouseFk
WHERE state = 'presente'
AND sub3.id BETWEEN HOUR(vDateFrom) *100 + MINUTE(vDateFrom)
@@ -56947,6 +51243,8 @@ DELIMITER ;
/*!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 `department_calcTree` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -56954,8 +51252,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `department_calcTree`()
BEGIN
@@ -56991,6 +51287,8 @@ DELIMITER ;
/*!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 `department_calcTreeRec` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -56998,8 +51296,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `department_calcTreeRec`(
vSelf INT,
@@ -57073,6 +51369,8 @@ DELIMITER ;
/*!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 `department_doCalc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -57080,8 +51378,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `department_doCalc`()
proc: BEGIN
@@ -57115,6 +51411,8 @@ DELIMITER ;
/*!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 `department_getHasMistake` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -57122,8 +51420,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `department_getHasMistake`()
BEGIN
@@ -57144,6 +51440,8 @@ DELIMITER ;
/*!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 `department_getLeaves` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -57151,8 +51449,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `department_getLeaves`(
vParentFk INT,
@@ -57235,6 +51531,8 @@ DELIMITER ;
/*!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 `deviceLog_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -57242,8 +51540,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `deviceLog_add`(vWorkerFk INT, vAppName VARCHAR(45), vAppVersion VARCHAR(45), vAndroid_id VARCHAR(100))
BEGIN
@@ -57264,6 +51560,8 @@ DELIMITER ;
/*!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 `deviceProductionUser_exists` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -57271,8 +51569,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `deviceProductionUser_exists`(vUserFk INT)
BEGIN
@@ -57288,6 +51584,8 @@ DELIMITER ;
/*!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 `deviceProductionUser_getWorker` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -57295,8 +51593,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `deviceProductionUser_getWorker`(vAndroid_id VARCHAR(50))
BEGIN
@@ -57318,6 +51614,8 @@ DELIMITER ;
/*!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 `deviceProduction_getnameDevice` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -57325,8 +51623,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `deviceProduction_getnameDevice`(vAndroid_id VARCHAR(50))
BEGIN
@@ -57347,6 +51643,8 @@ DELIMITER ;
/*!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 `device_checkLogin` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -57354,8 +51652,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `device_checkLogin`(vUserFk INT, vAndroidID VARCHAR(50))
BEGIN
@@ -57403,61 +51699,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `device_checkLogin__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `device_checkLogin__`(vUserFk INT, vAndroidID VARCHAR(50))
-BEGIN
-
-/*
- * Comprueba si está registrado el dispositivo mediante su androidId
- *
- * @param vUSerFk el id del user
- * @param vAndroidID es el identificador android_id del dispositivo
- */
- DECLARE vIsAuthorized BOOL DEFAULT TRUE;
- DECLARE vIsDepartment BOOL;
- DECLARE vMessage VARCHAR(200);
-
- SELECT COUNT(*) INTO vIsDepartment
- FROM vn.workerDepartment dp
- JOIN department d ON d.id = dp.departmentFk
- WHERE dp.workerFk = vUserFk AND d.name = "PRODUCCION";
-
- IF vIsDepartment THEN
-
- SELECT COUNT(*) INTO vIsAuthorized
- FROM vn.deviceProductionUser dpu
- JOIN vn.deviceProduction dp ON dp.id = dpu.deviceProductionFk
- WHERE dpu.userFk = vUserFk
- AND dp.android_id = vAndroidID;
-
-
- IF NOT vIsAuthorized THEN
-
- SET vMessage = 'Usuario no autorizado';
-
- END IF;
-
- END IF;
-
-
- #vIsAuthorized = TRUE; #Descomentar esta linea si se quiere quitar la comprobación de autorizacion
- SELECT vIsAuthorized,vMessage;
-
-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 DROP PROCEDURE IF EXISTS `duaEntryValueUpdate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -57465,8 +51708,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `duaEntryValueUpdate`(vDuaFk INT)
BEGIN
@@ -57499,6 +51740,8 @@ DELIMITER ;
/*!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 `duaInvoiceInBooking` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -57506,8 +51749,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `duaInvoiceInBooking`(vDuaFk INT)
BEGIN
@@ -57582,88 +51823,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `duaInvoiceInBooking__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `duaInvoiceInBooking__`(vDuaFk INT)
-BEGIN
- DECLARE done BOOL DEFAULT FALSE;
- DECLARE vInvoiceFk INT;
- DECLARE vASIEN BIGINT DEFAULT 0;
- DECLARE vCounter INT DEFAULT 0;
-
- DECLARE rs CURSOR FOR
- SELECT e.invoiceInFk
- FROM entry e
- JOIN duaEntry de ON de.entryFk = e.id
- JOIN invoiceIn ii ON ii.id = e.invoiceInFk
- WHERE de.duaFk = vDuaFk
- AND de.customsValue
- AND ii.isBooked = FALSE;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
-
- OPEN rs;
-
- UPDATE invoiceIn ii
- JOIN entry e ON e.invoiceInFk = ii.id
- JOIN duaEntry de ON de.entryFk = e.id
- JOIN dua d ON d.id = de.duaFk
- SET ii.isBooked = TRUE,
- ii.booked = IFNULL(ii.booked,d.booked),
- ii.operated = IFNULL(ii.operated,d.operated),
- ii.issued = IFNULL(ii.issued,d.issued),
- ii.bookEntried = IFNULL(ii.bookEntried,d.bookEntried),
- e.isConfirmed = TRUE
- WHERE d.id = vDuaFk;
-
- SELECT IFNULL(ASIEN,0) INTO vASIEN
- FROM dua
- WHERE id = vDuaFk;
-
- FETCH rs INTO vInvoiceFk;
-
- WHILE NOT done DO
-
- CALL invoiceInBookingMain(vInvoiceFk);
-
- IF vCounter > 0 OR vASIEN > 0 THEN
-
- UPDATE XDiario x
- JOIN config c ON c.ASIEN = x.ASIEN
- SET x.ASIEN = vASIEN;
-
- ELSE
-
- SELECT ASIEN INTO vASIEN FROM config;
-
- END IF;
-
- SET vCounter = vCounter + 1;
-
- FETCH rs INTO vInvoiceFk;
-
- END WHILE;
-
- CLOSE rs;
-
- UPDATE dua
- SET ASIEN = vASIEN
- WHERE id = vDuaFk;
-
-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 DROP PROCEDURE IF EXISTS `duaParcialMake` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -57671,8 +51832,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `duaParcialMake`(vDuaFk INT)
BEGIN
@@ -57698,6 +51857,8 @@ DELIMITER ;
/*!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 `duaTaxBooking` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -57705,8 +51866,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `duaTaxBooking`(vDuaFk INT)
BEGIN
@@ -57715,7 +51874,7 @@ BEGIN
DECLARE vDiff DECIMAL(10,2);
DECLARE vApunte BIGINT;
- SELECT ASIEN, IFNULL(bookEntried, CURDATE()) INTO vBookNumber, vBookDated
+ SELECT ASIEN, IFNULL(bookEntried, util.VN_CURDATE()) INTO vBookNumber, vBookDated
FROM dua
WHERE id = vDuaFk;
@@ -57819,6 +51978,7 @@ BEGIN
WHERE ta.effectived <= vBookDated
AND taxAreaFk = 'WORLD'
ORDER BY ta.effectived DESC
+ LIMIT 10000000000000000000
) tba
GROUP BY rate
) tr ON tr.rate = dt.rate
@@ -57845,250 +52005,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `duaTaxBooking__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `duaTaxBooking__`(vDuaFk INT)
-BEGIN
- DECLARE vBookNumber INT;
- DECLARE vBookDated DATE;
- DECLARE vDiff DECIMAL(10,2);
- DECLARE vApunte BIGINT;
-
- SELECT ASIEN, IFNULL(bookEntried, CURDATE()) INTO vBookNumber, vBookDated
- FROM dua
- WHERE id = vDuaFk;
-
- IF vBookNumber IS NULL OR NOT vBookNumber THEN
- CALL ledger_next(vBookNumber);
- END IF;
-
- -- Apunte de la aduana
-
- INSERT INTO XDiario(
- ASIEN,
- FECHA,
- SUBCTA,
- CONCEPTO,
- EUROHABER,
- SERIE,
- empresa_id,
- CLAVE,
- FACTURA)
-
- SELECT
- vBookNumber,
- d.bookEntried,
- '4700000999',
- CONCAT('DUA ',d.code),
- sum(di.amount * tr.rate / 100) EUROHABER,
- 'R',
- d.companyFk,
- vDuaFk,
- vDuaFk
- FROM duaIntrastat di
- JOIN intrastat ist ON ist.id = di.intrastatFk
- JOIN (SELECT rate, taxClassFk
- FROM
- (SELECT rate, taxClassFk
- FROM invoiceInTaxBookingAccount ta
- WHERE ta.effectived <= vBookDated
- ORDER BY ta.effectived DESC
- ) tba
- GROUP BY taxClassFk
- ) tr ON tr.taxClassFk = ist.taxClassFk
- JOIN dua d ON d.id = di.duaFk
- WHERE di.duaFk = vDuaFk;
-
- -- Apuntes por tipo de IVA y proveedor
-
- INSERT INTO XDiario(
- ASIEN,
- FECHA,
- SUBCTA,
- CONTRA,
- EURODEBE,
- BASEEURO,
- CONCEPTO,
- FACTURA,
- IVA,
- AUXILIAR,
- SERIE,
- FECHA_EX,
- FECHA_OP,
- FACTURAEX,
- NFACTICK,
- L340,
- LDIFADUAN,
- TIPOCLAVE,
- TIPOEXENCI,
- TIPONOSUJE,
- TIPOFACT,
- TIPORECTIF,
- TERIDNIF,
- TERNIF,
- TERNOM,
- empresa_id,
- FECREGCON
- )
-
- SELECT
- vBookNumber ASIEN,
- vBookDated FECHA,
- tr.account SUBCTA,
- '4330002067' CONTRA,
- sum(dt.tax) EURODEBE,
- sum(dt.base) BASEEURO,
- CONCAT('DUA nº',d.code) CONCEPTO,
- d.id FACTURA,
- dt.rate IVA,
- '*' AUXILIAR,
- 'D' SERIE,
- d.issued FECHA_EX,
- d.operated FECHA_OP,
- d.code FACTURAEX,
- 1 NFACTICK,
- 1 L340,
- TRUE LDIFADUAN,
- 1 TIPOCLAVE,
- 1 TIPOEXENCI,
- 1 TIPONOSUJE,
- 5 TIPOFACT,
- 1 TIPORECTIF,
- IF(s.countryFk IN (30, 1), 1, 4) TERIDNIF,
- s.nif TERNIF,
- s.name TERNOM,
- d.companyFk,
- d.booked FECREGCON
- FROM duaTax dt
- JOIN dua d ON dt.duaFk = d.id
- JOIN (SELECT account, rate
- FROM
- (SELECT rate, account
- FROM invoiceInTaxBookingAccount ta
- WHERE ta.effectived <= vBookDated
- AND taxAreaFk = 'WORLD'
- ORDER BY ta.effectived DESC
- ) tba
- GROUP BY rate
- ) tr ON tr.rate = dt.rate
- JOIN supplier s ON s.id = d.companyFk
- WHERE d.id = vDuaFk
- GROUP BY dt.rate;
-
- SELECT SUM(EURODEBE) -SUM(EUROHABER), MAX(id) INTO vDiff, vApunte
- FROM XDiario
- WHERE ASIEN = vBookNumber;
-
- UPDATE XDiario
- SET BASEEURO = 100 * (EURODEBE - vDiff) / IVA,
- EURODEBE = EURODEBE - vDiff
- WHERE id = vApunte;
-
- UPDATE dua
- SET ASIEN = vBookNumber
- WHERE id = vDuaFk;
-
-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 DROP PROCEDURE IF EXISTS `duaTaxUpdate__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `duaTaxUpdate__`(vDuaFk INT)
-BEGIN
-
- DECLARE vSPAIN INT DEFAULT 1;
- DECLARE vDated DATE;
- DECLARE vTotalDUABase DECIMAL(10,2);
-
- SELECT IFNULL(operated, CURDATE()) INTO vDated
- FROM dua
- WHERE id = vDuaFk;
-
- SELECT sum(amount) INTO vTotalDUABase
- FROM duaIntrastat
- WHERE duaFk = vDuaFk;
-
- DELETE FROM duaTax
- WHERE duaFk = vDuaFk;
-
- INSERT INTO duaTax(duaFk, supplierFk, taxClassFk, base)
- SELECT vDuaFk, supplierFk, taxClassFk, sum(sub.Base) as Base
- FROM intrastat ist
- JOIN
- (SELECT
- e.supplierFk,
- i.intrastatFk,
- CAST(sum(b.quantity * b.buyingValue * de.customsValue / de.value) * di.amount/ tei.Base AS DECIMAL(10,2)) as Base
- FROM buy b
- JOIN item i ON i.id = b.itemFk
- JOIN entry e ON e.id = b.entryFk
- JOIN duaEntry de ON de.entryFk = e.id
- JOIN
- (
- SELECT i.intrastatFk,
- CAST(sum(b.quantity * b.buyingValue * de.customsValue / de.value) AS DECIMAL(10,2)) as Base
- FROM buy b
- JOIN item i ON i.id = b.itemFk
- JOIN entry e ON e.id = b.entryFk
- JOIN duaEntry de ON de.entryFk = e.id
- WHERE de.duaFk = vDuaFk
- GROUP BY i.intrastatFk
-
- ) tei ON tei.intrastatFk = i.intrastatFk
- JOIN
- (
- SELECT intrastatFk, sum(amount) as amount
- FROM duaIntrastat
- WHERE duaFk = vDuaFk
- GROUP BY intrastatFK
- ) di ON di.intrastatFk = i.intrastatFk
- WHERE de.duaFk = vDuaFk
- GROUP BY e.supplierFk, i.intrastatFk
- HAVING Base
- ) sub ON ist.id = sub.intrastatFk
- GROUP BY ist.taxClassFk, sub.supplierFk;
-
- UPDATE duaTax dt
- JOIN
- (SELECT taxClassFk, rate
- FROM
- (SELECT taxClassFk, rate
- FROM invoiceInTaxBookingAccount
- WHERE effectived <= vDated
- AND countryFk = vSPAIN
- ORDER BY effectived DESC
- ) ba1
- GROUP BY taxClassFk
- ) ba2 ON dt.taxClassFk = ba2.taxClassFk
- SET dt.rate = ba2.rate,
- dt.tax = dt.base * ba2.rate / 100;
-
-
-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 DROP PROCEDURE IF EXISTS `duaTax_doRecalc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -58096,8 +52014,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `duaTax_doRecalc`(vDuaFk INT)
BEGIN
@@ -58151,6 +52067,8 @@ DELIMITER ;
/*!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 `ediTables_Update` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -58158,8 +52076,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ediTables_Update`()
BEGIN
@@ -58177,6 +52093,8 @@ DELIMITER ;
/*!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 `ektEntryAssign_setEntry` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -58184,8 +52102,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ektEntryAssign_setEntry`()
BEGIN
@@ -58194,13 +52110,13 @@ DECLARE done INT DEFAULT FALSE;
DECLARE vEntryFk INT;
DECLARE vTravelFk INT;
DECLARE vId INT;
-DECLARE vLanded DATE DEFAULT CURDATE();
+DECLARE vLanded DATE DEFAULT util.VN_CURDATE();
DECLARE cur1 CURSOR FOR SELECT id FROM vn.ektEntryAssign;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
- IF HOUR(NOW()) > 12 THEN
+ IF HOUR(util.VN_NOW()) > 12 THEN
SET vLanded = TIMESTAMPADD(DAY,1,vLanded);
@@ -58302,82 +52218,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `ekt_add__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ekt_add__`(vPutOrderFk INT)
-BEGIN
-
-/**
- * Añade ekt para las ordenes de compra de proveedores que no envian el ekt por email
- *
- * @param vPutOrderFk PutOrderId de donde coger los datos
- **/
-
- INSERT INTO edi.ekt(entryYear,
- deliveryNumber,
- fec,
- hor,
- item,
- pac,
- qty,
- ori,
- cat,
- pro,
- pri,
- package,
- s1,
- s2,
- s3,
- s4,
- s5,
- s6,
- putOrderFk,
- `ref`,
- kop)
- SELECT year(curdate()) entryYear,
- p.id deliveryNumber ,
- CURDATE() fec,
- CURTIME() hor,
- i.longName item,
- sr.NumberOfItemsPerCask pac,
- p.quantity qty,
- o.code ori,
- i.category cat,
- mp.supplierFk pro,
- sr.Price pri,
- sr.EmbalageCode package,
- i.value5 s1,
- i.value6 s2,
- i.value7 s3,
- i.value8 s4,
- i.value9 s5,
- i.value10 s6,
- p.id putOrderFk,
- sr.Item_ArticleCode,
- sr.vmpID
- FROM edi.putOrder p
- JOIN edi.supplyResponse sr ON sr.ID = p.supplyResponseID
- JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID
- JOIN vn.item i ON i.supplyResponseFk = sr.ID
- JOIN vn.origin o ON o.id = i.originFk
- WHERE p.id = vPutOrderFk;
-
- CALL edi.ekt_load(LAST_INSERT_ID());
-
-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 DROP PROCEDURE IF EXISTS `energyMeter_record` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -58385,8 +52227,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `energyMeter_record`(vInput INT, vActiveTime INT)
BEGIN
@@ -58399,7 +52239,7 @@ BEGIN
INSERT INTO vn.energyMeter
SET
`input` = vInput,
- `period` = DATE_FORMAT(NOW(), '%Y-%m-%d %H:00:00'),
+ `period` = DATE_FORMAT(util.VN_NOW(), '%Y-%m-%d %H:00:00'),
`activeTime` = vActiveTime,
`consumption` = CAST(IFNULL((vConsumption / 3600) * vActiveTime, 0) AS DECIMAL(10,2))
ON DUPLICATE KEY UPDATE
@@ -58411,233 +52251,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `entryConverter__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `entryConverter__`(IN `vEntry` INT)
-BEGIN
-
- DECLARE vWarehouseIn INT;
- DECLARE vWarehouseOut INT;
- DECLARE vTravel INT;
-
- DECLARE done BOOL DEFAULT FALSE;
-
- DECLARE vId_Entrada INT;
- DECLARE vId_Article INT;
- DECLARE vEtiquetas INT;
- DECLARE vId_Cubo VARCHAR(10);
- DECLARE vPacking INT;
- DECLARE vGrouping INT;
- DECLARE vCantidad INT;
- DECLARE vCostefijo DECIMAL(10,3);
- DECLARE vPortefijo DECIMAL(10,3);
- DECLARE vEmbalajefijo DECIMAL(10);
- DECLARE vComisionfija DECIMAL(10,3);
- DECLARE vCaja INT;
- DECLARE vNicho VARCHAR(5);
- DECLARE vTarifa1 DECIMAL(10,2);
- DECLARE vTarifa2 DECIMAL(10,2);
- DECLARE vTarifa3 DECIMAL(10,2);
- DECLARE vPVP DECIMAL(10,2);
- DECLARE vCompra INT;
-
- DECLARE rs CURSOR FOR
- SELECT
- b.Id_Entrada,
- b.Id_Article,
- b.Etiquetas,
- b.Id_Cubo,
- b.Packing,
- b.`grouping`,
- b.Cantidad,
- b.Costefijo,
- b.Portefijo,
- b.Embalajefijo,
- b.Comisionfija,
- b.caja,
- b.Nicho,
- b.Tarifa1,
- b.Tarifa2,
- b.Tarifa3,
- b.PVP
- FROM vn2008.Compres b
- JOIN vn.itemConversor ic ON ic.espItemFk = b.Id_Article
- WHERE Id_Entrada = vEntry;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
-
- SELECT warehouseInFk, warehouseOutFk, tr.id
- INTO vWarehouseIn, vWarehouseOut, vTravel
- FROM travel tr
- JOIN entry e ON e.travelFk = tr.id
- WHERE e.id = vEntry;
-
- UPDATE travel
- SET warehouseInFk = vWarehouseOut,
- warehouseOutFk = vWarehouseIn
- WHERE id = vTravel;
-
- UPDATE vn2008.Compres c
- LEFT JOIN vn.itemConversor ic ON ic.espItemFk = c.Id_Article
- SET Etiquetas = 0, Cantidad = 0
- WHERE c.Id_Entrada = vEntry
- AND ic.espItemFk IS NULL;
-
- OPEN rs;
-
- DELETE FROM vn2008.Compres WHERE Id_Entrada = vEntry;
-
- FETCH rs INTO
- vId_Entrada,
- vId_Article,
- vEtiquetas,
- vId_Cubo,
- vPacking,
- vGrouping,
- vCantidad,
- vCostefijo,
- vPortefijo,
- vEmbalajefijo,
- vComisionfija,
- vCaja,
- vNicho,
- vTarifa1,
- vTarifa2,
- vTarifa3,
- vPVP;
-
- WHILE NOT done DO
-
- -- Primero la linea original con las cantidades invertidas
- INSERT INTO vn2008.Compres
- (
- Id_Entrada,
- Id_Article,
- Etiquetas,
- Id_Cubo,
- Packing,
- `grouping`,
- Cantidad,
- Costefijo,
- Portefijo,
- Embalajefijo,
- Comisionfija,
- caja,
- Nicho,
- Tarifa1,
- Tarifa2,
- Tarifa3,
- PVP
- )
- VALUES
- (
- vId_Entrada,
- vId_Article,
- - vEtiquetas,
- vId_Cubo,
- vPacking,
- vGrouping,
- - vCantidad,
- vCostefijo,
- vPortefijo,
- vEmbalajefijo,
- vComisionfija,
- vCaja,
- vNicho,
- vTarifa1,
- vTarifa2,
- vTarifa3,
- vPVP);
-
- -- Ahora la linea nueva, con el item genérico
- INSERT INTO vn2008.Compres
- (
- Id_Entrada,
- Id_Article,
- Etiquetas,
- Id_Cubo,
- Packing,
- `grouping`,
- Cantidad,
- Costefijo,
- Portefijo,
- Embalajefijo,
- Comisionfija,
- caja,
- Nicho,
- Tarifa1,
- Tarifa2,
- Tarifa3,
- PVP
- )
- SELECT
- vId_Entrada,
- genItemFk as Id_Article,
- vEtiquetas,
- vId_Cubo,
- vPacking,
- vGrouping,
- vCantidad,
- vCostefijo,
- vPortefijo,
- vEmbalajefijo,
- vComisionfija,
- vCaja,
- vNicho,
- vTarifa1,
- vTarifa2,
- vTarifa3,
- vPVP
- FROM itemConversor
- WHERE espItemFk = vId_Article;
-
- SELECT LAST_INSERT_ID()
- INTO vCompra;
-
- REPLACE vn2008.Compres_mark(Id_Compra,`comment`)
- SELECT vCompra, vId_Article;
-
-
- FETCH rs INTO
- vId_Entrada,
- vId_Article,
- vEtiquetas,
- vId_Cubo,
- vPacking,
- vGrouping,
- vCantidad,
- vCostefijo,
- vPortefijo,
- vEmbalajefijo,
- vComisionfija,
- vCaja,
- vNicho,
- vTarifa1,
- vTarifa2,
- vTarifa3,
- vPVP;
-
- END WHILE;
-
-
- CLOSE rs;
-
-
-
-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 DROP PROCEDURE IF EXISTS `entryDelivered` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -58645,8 +52260,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `entryDelivered`(vDated DATE, vEntryFk INT)
BEGIN
@@ -58665,7 +52278,7 @@ BEGIN
ELSE
INSERT INTO vn.travel(shipped, landed, warehouseInFk, warehouseOutFk, agencyFk, ref, isDelivered, isReceived)
- SELECT LEAST(shipped, vDated), vDated, warehouseInFk, warehouseOutFk, agencyFk, CONCAT(account.userGetName(),' ', vEntryFk), TRUE, TRUE
+ SELECT LEAST(shipped, vDated), vDated, warehouseInFk, warehouseOutFk, agencyFk, CONCAT(account.myUser_getName(),' ', vEntryFk), TRUE, TRUE
FROM vn.travel WHERE id = vTravelFk;
SELECT LAST_INSERT_ID() INTO vTravelFk;
@@ -58682,125 +52295,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `entryPrepare__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `entryPrepare__`(IN `idE` BIGINT)
-BEGIN
- SELECT
- b.quantity / b.packing AS Paquetes,
- b.packing AS `Grouping`,
- barcode,
- 'ASEGURADO' AS asegurado,
- ic.name,
- ic.order,
- s.name AS Consignatario,
- e.supplierFk AS Id_Cliente,
- e.isOrdered,
- e.isConfirmed,
- 10 AS Calidad,
- LPAD(IFNULL(cpd.id, ip.code),
- 5,
- '0') AS path,
- b.entryFk AS Id_Ticket,
- t.landed AS Fecha,
- b.itemFk,
- b.quantity,
- i.name AS Concepte,
- i.size,
- i.inkFk,
- i.category,
- o.code AS Origen,
- 0 AS Bultos,
- wIn.`name` AS Tipo,
- 0 AS OK,
- 0 AS Reservado,
- i.stems,
- b.id AS Id_Movimiento,
- ip.code,
- 'PEDIDO ASEGURADO' AS MSG,
- 0 AS Seguro,
- i.image,
- pr.name AS producer
- FROM vn.buy b
- JOIN vn.entry e ON b.entryFk = e.id
- JOIN vn.travel t ON t.id = e.travelFk
- JOIN vn.warehouse wIn ON wIn.id = t.warehouseInFk
- JOIN vn.warehouse wOut ON wOut.id = t.warehouseOutFk
- JOIN vn.item i ON i.id = b.itemFk
- JOIN vn.itemType it ON it.id =i.typeFk
- JOIN vn.itemCategory ic ON ic.id = it.categoryFk
- JOIN vn.packaging pkg ON pkg.id = b.packageFk
- LEFT JOIN vn.itemPlacement ip ON i.id = ip.itemFk AND ip.warehouseFk = wIn.id AND ip.warehouseFk = t.warehouseOutFk
- LEFT JOIN (SELECT itemFk, code AS barcode FROM vn.itemBarcode GROUP BY itemFk) ib ON ib.itemFk = b.itemFk
- LEFT JOIN vn.origin o ON o.id = i.originFk
- LEFT JOIN vn.supplier s ON s.id = e.supplierFk
- LEFT JOIN vn.producer pr on pr.id = i.producerFk
- LEFT JOIN vn.coolerPathDetail cpd ON LEFT(ip.code, 3) = cpd.hallway
- WHERE
- NOT wIn.isFeedStock AND NOT e.isInventory AND NOT e.isRaid
- AND e.id = 158772
- AND i.typeFk IS NOT NULL
- AND ic.display IS NOT FALSE;
-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 DROP PROCEDURE IF EXISTS `entrySplit_move__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `entrySplit_move__`()
-BEGIN
-
- /* CREATED PAK 08/09/2019
- * PENDING REVIEW
- *
- *
- */
-
- DROP TEMPORARY TABLE IF EXISTS itemList;
-
- CREATE TEMPORARY TABLE itemList
- SELECT DISTINCT b.itemFk, es.delayedFk, es.receivedFk
- FROM vn.buy b
- JOIN vn.entrySplit es ON es.delayedFk = b.entryFk
- JOIN vn.itemPlacement ip ON ip.itemFk = b.itemFk
- WHERE ip.modificationDate > CURDATE();
-
- INSERT INTO itemList
- SELECT DISTINCT ish.itemFk, es.delayedFk, es.receivedFk
- FROM vn.buy b
- JOIN vn.entrySplit es ON es.delayedFk = b.entryFk
- JOIN vn.itemShelving ish ON ish.itemFk = b.itemFk
- WHERE ish.created > CURDATE();
-
-
- UPDATE vn.buy b
- JOIN vn.itemList il ON il.delayedFk = b.entryFk AND b.itemFk = il.itemFk
- SET b.entryFk = il.receivedFk;
-
-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 DROP PROCEDURE IF EXISTS `entryToTicket` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -58808,8 +52304,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `entryToTicket`(vEntryFk INT, vTicketFk INT)
BEGIN
@@ -58828,39 +52322,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `entryVolume__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `entryVolume__`(vEntryFk INT)
-BEGIN
-
- SELECT ELT(it.temperature + 1,'Calientes','Frios','Secos') AS Temp,
- CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) *
- vn.item_getVolume(b.itemFk ,b.packageFk)) / vc.carro / 1000000 ,1) AS DECIMAL(10,2)) AS carros ,
- CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) *
- vn.item_getVolume(b.itemFk ,b.packageFk)) / vc.espai / 1000000,1) AS DECIMAL(10,2)) AS espais
- FROM vn.buy b
- INNER JOIN vn.entry e ON e.id = b.entryFk
- INNER JOIN vn.travel tr ON tr.id = e.travelFk
- INNER JOIN vn.volumeConfig vc
- INNER JOIN vn.item i ON i.id = b.itemFk
- INNER JOIN vn.itemType it ON it.id = i.typeFk
- WHERE e.id = vEntryFk
- GROUP BY Temp;
-
-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 DROP PROCEDURE IF EXISTS `entryWithItem` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -58868,8 +52331,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `entryWithItem`(vShipmentWarehouse INT, vLandingWarehouse INT,vSale INT, vVolume INT, netCost DECIMAL(10,2), vInOutDate DATE)
BEGIN
@@ -58928,75 +52389,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `entryWithItem__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `entryWithItem__`(IN `vShipmentWarehouse` INT, IN `vLandingWarehouse` INT, IN `vSale` INT, IN `vVolume` INT, IN netCost DECIMAL(10,2), IN `vInOutDate` DATE)
-BEGIN
-
- DECLARE vTravel INT;
- DECLARE vEntry INT;
- DECLARE vBucket VARCHAR(10);
- DECLARE vAgencyDirectFromProvider INT DEFAULT 15;
- DECLARE vSupplierFk INT DEFAULT 963;
-
-
- -- seleccionamos travel
- SELECT t.id, e.id INTO vTravel, vEntry
- FROM travel t LEFT JOIN entry e ON t.id = e.travelFk
- WHERE t.landed = vInOutDate AND t.shipped = vInOutDate AND t.warehouseOutFk = vShipmentWarehouse
- AND t.warehouseInFk = vLandingWarehouse AND t.agencyFk = vAgencyDirectFromProvider AND e.supplierFk = vSupplierFk
- LIMIT 1;
-
- -- creamos el travel si es necesario
- IF IFNULL(vTravel, FALSE) = FALSE THEN
- INSERT INTO travel (shipped, landed, warehouseInFk, warehouseOutFk, agencyFk)
- VALUES (vInOutDate, vInOutDate, vLandingWarehouse, vShipmentWarehouse, vAgencyDirectFromProvider);
- SELECT LAST_INSERT_ID() INTO vTravel;
- END IF;
-
- -- creamos la Entrada si es necesario
- IF IFNULL(vEntry, FALSE) = FALSE THEN
- INSERT INTO entry (supplierFk, travelFk)
- VALUES (vSupplierFk, vTravel); -- proveedor 'CONFECCION ARTIFICIAL'
- SELECT LAST_INSERT_ID() INTO vEntry;
- END IF;
-
- -- creamos el cubo si es necesario
- SELECT id INTO vBucket FROM packaging WHERE volume = vVolume LIMIT 1;
- IF vBucket IS NULL THEN
- INSERT INTO packaging (id, volume)
- VALUES (CONCAT('dm',vVolume/1000), vVolume);
- -- SELECT LAST_INSERT_ID() INTO vBucket;
- SELECT id INTO vBucket FROM packaging WHERE volume = vVolume LIMIT 1;
- END IF;
-
- INSERT INTO buy(itemFk,quantity, entryFk, packageFk, packing, `grouping`, stickers, buyingValue, price2, price3)
- SELECT itemFk,
- quantity,
- vEntry,
- vBucket,
- 1 packing,
- 1 `grouping`,
- quantity,
- netCost,
- s.price,
- s.price
- FROM sale s
- WHERE s.id = vSale;
-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 sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `entry_clone` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59004,8 +52398,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_clone`(vSelf INT)
BEGIN
@@ -59075,6 +52467,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `entry_cloneWithoutBuy` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59082,8 +52476,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_cloneWithoutBuy`(vSelf INT, OUT vNewEntryFk INT)
BEGIN
@@ -59131,6 +52523,8 @@ DELIMITER ;
/*!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 `entry_fixMisfit` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59138,8 +52532,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_fixMisfit`(vSelf INT)
BEGIN
@@ -59154,7 +52546,7 @@ BEGIN
FROM vn.item i
WHERE i.description = 'MISFIT'
LIMIT 1;
-
+
INSERT INTO vn.buy(entryFk,
itemFk,
quantity,
@@ -59204,6 +52596,8 @@ DELIMITER ;
/*!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 `entry_getRate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59211,8 +52605,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_getRate`(vEntry INT)
BEGIN
@@ -59254,6 +52646,8 @@ DELIMITER ;
/*!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 `entry_moveNotPrinted` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59261,8 +52655,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_moveNotPrinted`(vSelf INT, vDays INT, vChangeEntry BOOL, OUT vNewEntryFk INT)
BEGIN
@@ -59297,29 +52689,31 @@ BEGIN
AND b.entryFk = vSelf;
END IF;
- INSERT INTO vn.buy( entryFk,
- itemFk,
- quantity,
- buyingValue,
- freightValue,
- isIgnored,
- stickers,
- packing,
- `grouping`,
- groupingMode,
- containerFk,
- comissionValue,
- packageValue,
- packageFk,
- price1,
- price2,
- price3,
- minPrice,
- producer,
- workerFk,
- weight,
- itemOriginalFk)
- SELECT vNewEntryFk,
+ INSERT INTO vn.buy(
+ entryFk,
+ itemFk,
+ quantity,
+ buyingValue,
+ freightValue,
+ isIgnored,
+ stickers,
+ packing,
+ `grouping`,
+ groupingMode,
+ containerFk,
+ comissionValue,
+ packageValue,
+ packageFk,
+ price1,
+ price2,
+ price3,
+ minPrice,
+ producer,
+ workerFk,
+ weight,
+ itemOriginalFk
+ )
+ SELECT vNewEntryFk,
itemFk,
((stickers - printedStickers) * packing) quantity,
buyingValue,
@@ -59401,12 +52795,71 @@ BEGIN
WHERE entryFk = vSelf
AND printedStickers != stickers;
END IF;
+
+ INSERT INTO entryLog
+ SET action = 'update',
+ description = CONCAT('Se ha creado la entrada ', vNewEntryFk,' transferida desde la ', vSelf),
+ userFk = account.myUser_getId(),
+ originFk = vSelf;
+
+ INSERT INTO entryLog
+ SET action = 'update',
+ description = CONCAT('Se ha creado la entrada ', vNewEntryFk,' transferida desde la ', vSelf),
+ userFk = account.myUser_getId(),
+ originFk = vNewEntryFk;
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 `entry_notifyChanged` */;
+/*!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=`root`@`localhost` PROCEDURE `entry_notifyChanged`(vSelf INT, vBuyFk INT, vOldValues VARCHAR(512), vNewValues VARCHAR(512))
+BEGIN
+ DECLARE vEmail VARCHAR(255);
+ DECLARE vFields VARCHAR(100);
+ DECLARE vMessage TEXT;
+
+ SELECT e.mailToNotify INTO vEmail
+ FROM entryConfig e
+ LIMIT 1;
+
+ SET vFields = CONCAT_WS(',',
+ 'entryFk',
+ 'itemFk',
+ 'quantity',
+ 'price1',
+ 'price2',
+ 'price3'
+ );
+ SET vMessage = util.formatTable(vFields, vOldValues, vNewValues);
+
+ CALL mail_insert(
+ vEmail,
+ NULL,
+ CONCAT(
+ 'Se ha modificado una línea de la entrada ', vSelf
+ ,' siendo inventario o anterior al mismo'
+ ),
+ vMessage
+ );
+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 `entry_recalc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59414,8 +52867,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_recalc`()
BEGIN
@@ -59454,6 +52905,8 @@ DELIMITER ;
/*!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 `entry_splitByShelving` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59461,8 +52914,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_splitByShelving`(vShelvingFk VARCHAR(3), vFromEntryFk INT, vToEntryFk INT)
BEGIN
@@ -59486,7 +52937,8 @@ BEGIN
JOIN (SELECT b.id, b.itemFk, b.stickers
FROM vn.buy b
WHERE b.entryFk = vFromEntryFk
- ORDER BY b.stickers DESC) bb ON bb.itemFk = ish.itemFk
+ ORDER BY b.stickers DESC
+ LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk
AND bb.stickers >= FLOOR(ish.visible / ish.packing)
WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci
GROUP BY ish.id;
@@ -59503,7 +52955,8 @@ BEGIN
LEFT JOIN (SELECT b.id, b.itemFk, b.stickers
FROM vn.buy b
WHERE b.entryFk = vFromEntryFk
- ORDER BY b.stickers DESC) bb ON bb.itemFk = ish.itemFk
+ ORDER BY b.stickers DESC
+ LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk
WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci
AND IFNULL(bb.stickers,0) < FLOOR(ish.visible / ish.packing)
GROUP BY ish.id;
@@ -59599,6 +53052,8 @@ DELIMITER ;
/*!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 `entry_splitMisfit` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59606,8 +53061,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_splitMisfit`(vSelf INT)
BEGIN
@@ -59646,6 +53099,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `errorProduction_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59653,8 +53108,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `errorProduction_add`(vAction VARCHAR(25), vDatedFrom DATETIME, vDatedTo DATETIME)
BEGIN
@@ -59803,6 +53256,8 @@ DELIMITER ;
/*!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 `errorProduction_addLauncher` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59810,15 +53265,13 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `errorProduction_addLauncher`()
BEGIN
DECLARE vDatedFrom DATETIME;
DECLARE vDatedTo DATETIME;
- SELECT DATE_SUB(CURDATE(),INTERVAL 1 DAY), CONCAT(DATE_SUB(CURDATE(),INTERVAL 1 DAY),' 23:59:59') INTO vDatedFrom, vDatedTo;
+ SELECT DATE_SUB(util.VN_CURDATE(),INTERVAL 1 DAY), CONCAT(DATE_SUB(util.VN_CURDATE(),INTERVAL 1 DAY),' 23:59:59') INTO vDatedFrom, vDatedTo;
CALL vn.errorProduction_add('SACAR', vDatedFrom, vDatedTo);
CALL vn.errorProduction_add('ENCAJAR', vDatedFrom, vDatedTo);
@@ -59829,128 +53282,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `errorProduction_addLauncher__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `errorProduction_addLauncher__`()
-BEGIN
- DECLARE vDatedFrom DATETIME;
- DECLARE vDatedTo DATETIME;
-
- IF (DAY(CURDATE()) = 5) THEN
- SELECT util.firstDayOfMonth(DATE_SUB(CURDATE(),INTERVAL 1 MONTH)), CONCAT(LAST_DAY(DATE_SUB(CURDATE(),INTERVAL 1 MONTH)),' 23:59:59') INTO vDatedFrom, vDatedTo;
-
- CALL vn.errorProduction_add('SACAR' ,'Sacadores','PREPARED', vDatedFrom, vDatedTo);
- CALL vn.errorProduction_add('ENCAJAR' ,'Encajadores','PACKED', vDatedFrom, vDatedTo);
- CALL vn.errorProduction_add('CONTROLAR' ,'Revisadores','CHECKED', vDatedFrom, vDatedTo);
- 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 DROP PROCEDURE IF EXISTS `errorProduction_add__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `errorProduction_add__`(vAction VARCHAR(25), vDepartment VARCHAR(25), vStateCode VARCHAR(25) CHARSET utf8, vDatedFrom DATETIME, vDatedTo DATETIME)
-BEGIN
- /**
- * Fill in the errorProduction table.
- */
- DROP TEMPORARY TABLE IF EXISTS tmp.total;
-
- IF (vDepartment = 'Encajadores')
- THEN
- CREATE TEMPORARY TABLE tmp.total
- ENGINE = MEMORY
- SELECT e.workerFk, Count(DISTINCT t.id) AS ticketCount
- FROM expedition e
- JOIN ticket t ON e.ticketFk = t.id
- WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo
- GROUP BY e.workerFk;
- ELSE
- CREATE TEMPORARY TABLE tmp.total
- ENGINE = MEMORY
- SELECT st.workerFk, Count(DISTINCT t.id) AS ticketCount
- FROM state ss
- JOIN vn.saleTracking st ON st.stateFk = ss.id
- JOIN vn.sale s ON s.id = st.saleFk
- JOIN ticket t ON s.ticketFk = t.id
- WHERE (t.shipped BETWEEN vDatedFrom AND vDatedTo) AND ss.code = vStateCode
- GROUP BY st.workerFk;
- END IF;
-
-
- INSERT INTO errorProduction(userFk, firstname, lastname, rol, ticketNumber, error, ratio, volume, month, year)
- SELECT sub1.id, sub1.firstName, sub1.lastName,
- CASE
- WHEN vDepartment = 'Encajadores' THEN 'Encajador'
- WHEN vDepartment = 'Sacadores' THEN 'Sacador'
- ELSE 'Revisador'
- END AS rol,
- CAST(sub1.totalTickets AS DECIMAL(10,0)) AS totalTickets,
- CAST(IFNULL(sub1.errors,0) + IFNULL(sub2.errors,0) AS DECIMAL(10,0)) AS errors,
- ((IFNULL(sub1.errors,0) + IFNULL(sub2.errors,0))/sub1.totalTickets)*100 AS ratio,
- IF(vDepartment = 'Revisadores', NULL, volume) AS volume,
- MONTH(vDatedFrom) AS month,
- YEAR(vDatedFrom) AS year
- FROM(
- SELECT w.id, w.code, w.firstName, w.lastName, t.ticketCount AS totalTickets, sub.errors, sub2.volume
- FROM tmp.total AS t
- JOIN worker w ON w.id = t.workerFk
- LEFT JOIN (
- SELECT COUNT(c.ticketFk) AS errors, cd.workerFk
- FROM claimDevelopment cd
- JOIN claim c ON cd.claimFk = c.id
- JOIN ticket t ON c.ticketFk = t.id
- JOIN claimResponsible cr ON cd.claimResponsibleFk = cr.id
- WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo AND cr.description = vDepartment
- GROUP BY cd.workerFk
- )sub ON t.workerFk = sub.workerFk
- LEFT JOIN ( -- Añadir volume
- SELECT SUM(w.volume) AS volume, w.workerFk
- FROM bs.workerProductivity w
- INNER JOIN vn.`role` r ON r.id=w.roleFk
- WHERE IF(vDepartment = 'Encajadores', r.name='packager', r.name='itemPicker') AND w.dated BETWEEN vDatedFrom AND vDatedTo
- GROUP BY w.workerFk) sub2 ON w.id = sub2.workerFk
- GROUP BY w.code) sub1
- LEFT JOIN(
- SELECT sub1.workerFk, COUNT(id) AS errors
- FROM (
- SELECT st.workerFk, t.id
- FROM vn.saleMistake sm
- JOIN vn.saleTracking st ON sm.saleFk = st.saleFk
- JOIN state ss ON ss.id = st.stateFk
- JOIN vncontrol.accion a ON a.accion_id = st.actionFk
- JOIN vn.sale s ON s.id = sm.saleFk
- JOIN vn.ticket t on t.id = s.ticketFk
- WHERE (t.shipped BETWEEN vDatedFrom AND vDatedTo) AND a.accion = vAction AND ss.code = vStateCode
- GROUP BY s.ticketFk
- ) sub1
- GROUP BY sub1.workerFk) sub2 ON sub2.workerFk = sub1.id;
-
- DROP TEMPORARY TABLE tmp.total;
-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 DROP PROCEDURE IF EXISTS `expeditionGetFromRoute` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59958,8 +53291,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionGetFromRoute`(
vExpeditionFk INT)
@@ -59967,27 +53298,37 @@ BEGIN
/**
* Get all expeditions from route
*/
- DECLARE vRouteFk INT DEFAULT 0;
-
- SELECT t.routeFk INTO vRouteFk
- FROM vn.expedition exp
- INNER JOIN ticket t on t.id = exp.ticketFk
- WHERE exp.id = vExpeditionFk;
-
-SELECT exp.id, exp.ticketFk, exp.checked, t.routeFk,t.packages AS bultos , ts.alertLevel, a.street, a.city,a.postalCode,a.id AS addressFk,w.name AS warehouse
- FROM vn.expedition exp
- INNER JOIN ticket t ON t.id = exp.ticketFk
- INNER JOIN vn.ticketState ts ON ts.ticketFk = exp.ticketFk
- LEFT JOIN vn.address a ON t.addressFk = a.id
- LEFT JOIN vn.warehouse w ON t.warehouseFk = w.id
- WHERE t.routeFk = vRouteFk AND exp.isBox > 0;
-
+ DECLARE vRouteFk INT DEFAULT 0;
+
+ SELECT t.routeFk INTO vRouteFk
+ FROM vn.expedition exp
+ INNER JOIN ticket t on t.id = exp.ticketFk
+ WHERE exp.id = vExpeditionFk;
+
+ SELECT exp.id,
+ exp.ticketFk,
+ t.routeFk,
+ t.packages bultos,
+ ts.alertLevel,
+ a.street,
+ a.city,
+ a.postalCode,
+ a.id addressFk,
+ w.name warehouse
+ FROM vn.expedition exp
+ INNER JOIN ticket t ON t.id = exp.ticketFk
+ INNER JOIN vn.ticketState ts ON ts.ticketFk = exp.ticketFk
+ LEFT JOIN vn.address a ON t.addressFk = a.id
+ LEFT JOIN vn.warehouse w ON t.warehouseFk = w.id
+ WHERE t.routeFk = vRouteFk AND exp.isBox > 0;
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 `expeditionPallet_Del` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -59995,8 +53336,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionPallet_Del`(vPalletFk INT)
BEGIN
@@ -60010,6 +53349,8 @@ DELIMITER ;
/*!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 `expeditionPallet_List` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60017,8 +53358,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionPallet_List`(vTruckFk INT)
BEGIN
@@ -60039,6 +53378,8 @@ DELIMITER ;
/*!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 `expeditionPallet_printLabel` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60046,74 +53387,37 @@ DELIMITER ;
/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionPallet_printLabel`(vPalletFk INT)
+CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionPallet_printLabel`(vSelf INT)
BEGIN
- DECLARE vLabel INT;
+ DECLARE vReport INT;
DECLARE vPrinterFk INT;
UPDATE vn.expeditionPallet
- SET isPrint = FALSE
- WHERE id = vPalletFk;
+ SET isPrint = FALSE
+ WHERE id = vSelf;
- SELECT s.labelReportFk, w.labelerFk INTO vLabel, vPrinterFK
+ SELECT s.reportFk, w.labelerFk INTO vReport, vPrinterFk
FROM worker w
LEFT JOIN sector s ON s.id= w.sectorFk
- WHERE w.id=account.myUser_getId() ;
+ WHERE w.id = account.myUser_getId();
- INSERT INTO printServerQueue (printerFk, labelReportFk, statusFk, param1, workerFk)
- VALUES(vPrinterFK, vLabel, 1, vPalletFk, account.myUser_getId());
+ INSERT INTO printQueue (printerFk, priorityFk, reportFk, workerFk)
+ SELECT vPrinterFk, qp.id, vReport, account.myUser_getId()
+ FROM queuePriority qp
+ WHERE qp.`code`= 'high';
+
+ INSERT INTO printQueueArgs (printQueueFk, `name`, `value` )
+ SELECT LAST_INSERT_ID(), 'palletFk', vSelf;
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 DROP PROCEDURE IF EXISTS `expeditionPallet_PrintSet` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionPallet_PrintSet`(vPalletFk INT,vSectorFk INT)
-BEGIN
-
- DECLARE vLabel INT;
- DECLARE vPrinterFk INT;
-
- UPDATE vn.expeditionPallet
- SET isPrint = FALSE
- WHERE id = vPalletFk;
-
- SELECT labelReportFk
- INTO vLabel
- FROM sector
- WHERE id=vSectorFk;
-
- SELECT printerFk
- INTO vPrinterFk
- FROM sector
- WHERE id=vSectorFk;
-
-
- INSERT INTO vn2008.Colas
-(Id_Cola, Id_Impresora, Id_Prioridad, Id_Informe, Id_Estado, Hora_Inicio, Hora_Fin, Cola, Id_Trabajador, Cola2, Cola3, error)
-VALUES(NULL, vPrinterFK, NULL, vLabel, 1, NULL, NULL, vPalletFk, NULL, vSectorFk, NULL, NULL);
-
-
-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 sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `expeditionPallet_View` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60121,8 +53425,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionPallet_View`(vPalletFk INT)
BEGIN
@@ -60143,6 +53445,8 @@ DELIMITER ;
/*!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 `expeditionScan_Add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60150,8 +53454,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionScan_Add`(vPalletFk INT, vTruckFk INT)
BEGIN
@@ -60183,6 +53485,8 @@ DELIMITER ;
/*!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 `expeditionScan_Del` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60190,8 +53494,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionScan_Del`(vScanFk INT)
BEGIN
@@ -60205,6 +53507,8 @@ DELIMITER ;
/*!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 `expeditionScan_List` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60212,8 +53516,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionScan_List`(vPalletFk INT)
BEGIN
@@ -60235,6 +53537,8 @@ DELIMITER ;
/*!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 `expeditionScan_Put` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60242,8 +53546,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionScan_Put`(vPalletFk INT, vExpeditionFk INT)
BEGIN
@@ -60259,6 +53561,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `expeditionState_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60266,8 +53570,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionState_add`(vParam INT, vStateCode VARCHAR(100))
BEGIN
@@ -60303,6 +53605,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `expeditionState_addByAdress` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60310,8 +53614,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionState_addByAdress`(vAdressFk INT, vRouteFk INT, vStateCode VARCHAR(100))
BEGIN
@@ -60337,6 +53639,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `expeditionState_addByExpedition` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60344,8 +53648,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionState_addByExpedition`(vExpeditionFk INT, vStateCode VARCHAR(100))
BEGIN
@@ -60368,6 +53670,8 @@ DELIMITER ;
/*!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 `expeditionState_addByPallet` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60375,8 +53679,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionState_addByPallet`(vPalletFk INT, vStateCode VARCHAR(100))
BEGIN
@@ -60404,6 +53706,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `expeditionState_addByRoute` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60411,8 +53715,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionState_addByRoute`(vRouteFk INT, vStateCode VARCHAR(100))
BEGIN
@@ -60437,6 +53739,8 @@ DELIMITER ;
/*!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 `expeditionTruck_Add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60444,14 +53748,12 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionTruck_Add`(vHour VARCHAR(5), vDescription VARCHAR(45))
BEGIN
INSERT INTO vn.expeditionTruck(ETD,description)
- VALUES(CONCAT(CURDATE(), ' ', vHour), vDescription);
+ VALUES(CONCAT(util.VN_CURDATE(), ' ', vHour), vDescription);
END ;;
DELIMITER ;
@@ -60459,6 +53761,8 @@ DELIMITER ;
/*!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 `expeditionTruck_List` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60466,8 +53770,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionTruck_List`()
BEGIN
@@ -60476,7 +53778,7 @@ BEGIN
ETD,
description Destino
FROM vn.expeditionTruck
- WHERE ETD BETWEEN CURDATE() AND util.dayend(CURDATE())
+ WHERE ETD BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
ORDER BY ETD;
END ;;
DELIMITER ;
@@ -60484,33 +53786,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `expeditionUpdateChecked` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionUpdateChecked`(
- vExpeditionFk INT, vChecked INT)
-BEGIN
-/**
- * Get all expeditions from route
- */
-
- UPDATE vn.expedition exp
- SET exp.checked = vChecked
- WHERE exp.id = vExpeditionFk;
-
-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 DROP PROCEDURE IF EXISTS `expedition_getFromRoute` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60518,8 +53795,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `expedition_getFromRoute`(vRouteFk INT)
BEGIN
@@ -60527,19 +53802,17 @@ BEGIN
* Obtiene las expediciones a partir de una ruta
* @param vRouteFk Id de la ruta
*/
-
- SELECT e.id,
- e.ticketFk,
- e.checked,
+ SELECT e.id,
+ e.ticketFk,
t.routeFk,
- ts.alertLevel,
- a.street,
+ ts.alertLevel,
+ a.street,
a.city,
a.postalCode,
- t.addressFk,
+ t.addressFk,
a.nickname,
sub2.itemPackingTypeConcat,
- est.code
+ est.code
FROM expedition e
JOIN ticket t ON t.id = e.ticketFk
JOIN ticketState ts ON ts.ticketFk = e.ticketFk
@@ -60557,13 +53830,14 @@ BEGIN
) sub2 ON sub2.ticketFk = t.id
LEFT JOIN expeditionStateType est ON est.id = e.stateTypeFk
WHERE t.routeFk = vRouteFk AND e.isBox <> FALSE;
-
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 `expedition_getState` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60571,8 +53845,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `expedition_getState`(vExpeditionFk INT)
BEGIN
@@ -60634,6 +53906,8 @@ DELIMITER ;
/*!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 `expedition_StateGet` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60641,8 +53915,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `expedition_StateGet`(vExpeditionFk INT)
BEGIN
@@ -60721,6 +53993,8 @@ DELIMITER ;
/*!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 `faultsReview` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60728,8 +54002,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `faultsReview`(vWarehouseFk INT)
BEGIN
@@ -60766,7 +54038,7 @@ BEGIN
JOIN vn.client c ON c.id = t.clientFk
WHERE c.typeFk = 'loses' COLLATE utf8_unicode_ci
AND s.isPicked = FALSE
- AND date(t.shipped) = CURDATE()
+ AND date(t.shipped) = util.VN_CURDATE()
AND t.warehouseFk = vWarehouseFk
) sub ON sub.itemFk = ishr.itemFk
;
@@ -60778,6 +54050,8 @@ DELIMITER ;
/*!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 `faultsReview_isChecked` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60785,8 +54059,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `faultsReview_isChecked`(vItemFk INT, vWarehouseFk INT)
BEGIN
@@ -60796,7 +54068,7 @@ BEGIN
JOIN vn.client c ON c.id = t.clientFk
SET s.isPicked = TRUE
WHERE c.typeFk = 'loses' COLLATE utf8_unicode_ci
- AND date(t.shipped) = CURDATE()
+ AND date(t.shipped) = util.VN_CURDATE()
AND t.warehouseFk = vWarehouseFk
AND s.itemFk = vItemFk;
@@ -60806,6 +54078,8 @@ DELIMITER ;
/*!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 `freelance_getInfo` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60813,25 +54087,26 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `freelance_getInfo`(workerFk INT)
BEGIN
- SELECT s.name, s.street, s.city, s.nif, s.postCode
+ SELECT s.name, s.street, s.city, s.nif, s.postCode
FROM route r
- JOIN agencyMode am ON r.agencyModeFk = am.id
- JOIN agency a ON am.agencyFk = a.id
- JOIN supplier s ON a.supplierFk = s.id
- WHERE r.workerFk = workerFk
- ORDER BY r.id DESC
- LIMIT 1;
+ JOIN agencyMode am ON r.agencyModeFk = am.id
+ JOIN agency a ON am.agencyFk = a.id
+ JOIN supplierAgencyTerm sat ON a.id = sat.agencyFk
+ JOIN supplier s ON sat.supplierFk = s.id
+ WHERE r.workerFk = workerFk
+ ORDER BY r.id DESC
+ LIMIT 1;
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 `fustControl` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60839,8 +54114,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `fustControl`(vFromDated DATE, vToDated DATE)
BEGIN
@@ -60924,6 +54197,8 @@ DELIMITER ;
/*!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 `fustControlDetail` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60931,8 +54206,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `fustControlDetail`(vFromDated DATE, vToDated DATE)
BEGIN
@@ -60973,6 +54246,8 @@ DELIMITER ;
/*!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 `fv_pca` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60980,8 +54255,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `fv_pca`()
BEGIN
@@ -61087,6 +54360,8 @@ DELIMITER ;
/*!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 `getDayExpeditions` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -61094,8 +54369,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `getDayExpeditions`()
BEGIN
@@ -61107,7 +54380,7 @@ BEGIN
t.routeFk as routeFk
FROM vn2008.expeditions e
INNER JOIN vn.ticket t ON t.id = e.ticket_id
- WHERE DATE(odbc_date) = CURDATE();
+ WHERE DATE(odbc_date) = util.VN_CURDATE();
END ;;
DELIMITER ;
@@ -61115,43 +54388,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `getDeliveryWorkers` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `getDeliveryWorkers`()
-BEGIN
-SELECT w.id,
- concat(p.firstname," ",p.name) AS fullName,
- w.code AS workerCode,
- pwc.name,
- rl.routeFk as routeLoader
- FROM postgresql.person AS p
- LEFT JOIN vn.worker AS w ON p.id_trabajador=w.id
- LEFT JOIN (SELECT MIN(profile_id) AS pid, person_id FROM postgresql.profile GROUP BY person_id) AS pp ON p.person_id=pp.person_id
- LEFT JOIN vn2008.profile_labour_payroll AS plp ON pp.pid=plp.profile_id
- LEFT JOIN (SELECT MAX(business_id) AS bimax, client_id FROM postgresql.business GROUP BY client_id) AS pbv ON pbv.client_id = plp.profile_id
- LEFT JOIN postgresql.business_labour AS pbl ON pbl.business_id = pbv.bimax
- LEFT JOIN vn.department AS pd ON pd.id = pbl.department_id
- LEFT JOIN postgresql.workcenter AS pwc ON pwc.workcenter_id=pbl.workcenter_id
- LEFT JOIN vn.user u ON u.id=w.userFK
- LEFT JOIN vn.routeLoadWorker rl ON rl.workerFk = w.id
- WHERE p.id_trabajador Is Not Null
- AND pd.name='REPARTO'
- AND u.active<>0
- ORDER BY pwc.name ASC,p.firstname ASC;
-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 DROP PROCEDURE IF EXISTS `getInfoDelivery` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -61159,8 +54397,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `getInfoDelivery`(vRouteFk INT)
BEGIN
@@ -61175,6 +54411,8 @@ DELIMITER ;
/*!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 `getItemUbication` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -61182,8 +54420,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `getItemUbication`(vItemFk VARCHAR(22))
BEGIN
@@ -61201,30 +54437,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `getItemVisibleAvailable__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `getItemVisibleAvailable__`(
- vItem INT,
- vDate DATE,
- vWarehouse TINYINT,
- vRefresh BOOL)
-BEGIN
- -- DEPRECADO - UTILIZAR vn.item_getVisibleAvailable() - JSB - 2019-11-20
- CALL item_getVisibleAvailable(vItem, vDate, vWarehouse, vRefresh);
-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 DROP PROCEDURE IF EXISTS `getPedidosInternos` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -61232,8 +54446,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `getPedidosInternos`()
BEGIN
@@ -61246,6 +54458,8 @@ DELIMITER ;
/*!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 `intrastat_data_neto_Update` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -61253,8 +54467,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `intrastat_data_neto_Update`(IN vInvoiceInFk INT)
BEGIN
@@ -61282,6 +54494,8 @@ DELIMITER ;
/*!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 `inventoryFailureAdd` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -61289,8 +54503,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `inventoryFailureAdd`()
BEGIN
@@ -61343,6 +54555,8 @@ DELIMITER ;
/*!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 `inventoryMake` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -61350,28 +54564,27 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `inventoryMake`(vDate DATE, vWh INT)
proc: BEGIN
/**
- * Recalcula los inventarios de todos los almacenes, si vWh = 0
- *
- * @param vDate Fecha de los nuevos inventarios
- * @param vWh almacen al cual hacer el inventario
- */
-
+* Recalcula los inventarios de todos los almacenes, si vWh = 0
+*
+* @param vDate Fecha de los nuevos inventarios
+* @param vWh almacen al cual hacer el inventario
+*/
+
DECLARE vDone BOOL;
DECLARE vEntryFk INT;
DECLARE vTravelFk INT;
- DECLARE vDateLastInventory DATE;
- DECLARE vDateYesterday DATETIME DEFAULT TIMESTAMPADD(SECOND,-1,vDate);
+ DECLARE vDateLastInventory DATE;
+ DECLARE vDateYesterday DATETIME DEFAULT TIMESTAMPADD(SECOND,-1,vDate);
DECLARE cWarehouses CURSOR FOR
- SELECT id
- FROM warehouse
- WHERE isInventory AND vWh IN (0,id);
+ SELECT id
+ FROM warehouse
+ WHERE isInventory
+ AND vWh IN (0,id);
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET vDone = TRUE;
@@ -61391,32 +54604,32 @@ proc: BEGIN
SELECT MAX(landed) INTO vDateLastInventory
FROM travel tr
- JOIN entry e ON e.travelFk = tr.id
- JOIN buy b ON b.entryFk = e.id
+ JOIN entry e ON e.travelFk = tr.id
+ JOIN buy b ON b.entryFk = e.id
WHERE warehouseOutFk = 13
AND landed < vDate
- AND e.supplierFk = 4
+ AND e.supplierFk = 4
AND warehouseInFk = vWh
- AND NOT isRaid;
-
+ AND NOT isRaid;
+
IF vDateLastInventory IS NULL THEN
SELECT inventoried INTO vDateLastInventory FROM config;
- END IF;
-
- -- Generamos travel, si no existe.
- SET vTravelFK = 0;
-
- SELECT id INTO vTravelFk
+ END IF;
+
+ -- Generamos travel, si no existe.
+ SET vTravelFK = 0;
+
+ SELECT id INTO vTravelFk
FROM travel
- WHERE warehouseOutFk = 13
+ WHERE warehouseOutFk = 13
AND warehouseInFk = vWh
- AND landed = vDate
- AND agencyFk = 53
- AND ref = 'inventario'
+ AND landed = vDate
+ AND agencyFk = 53
+ AND ref = 'inventario'
LIMIT 1;
-
- IF NOT vTravelFK THEN
-
+
+ IF NOT vTravelFK THEN
+
INSERT INTO travel SET
warehouseOutFk = 13,
warehouseInFk = vWh,
@@ -61427,17 +54640,17 @@ proc: BEGIN
isDelivered = TRUE,
isReceived = TRUE;
- SELECT LAST_INSERT_ID() INTO vTravelFk;
-
+ SELECT LAST_INSERT_ID() INTO vTravelFk;
+
END IF;
-
- -- Generamos entrada si no existe, o la vaciamos.
- SET vEntryFk = 0;
-
- SELECT id INTO vEntryFk
+
+ -- Generamos entrada si no existe, o la vaciamos.
+ SET vEntryFk = 0;
+
+ SELECT id INTO vEntryFk
FROM entry
- WHERE supplierFk = 4
- AND travelFk = vTravelFk;
+ WHERE supplierFk = 4
+ AND travelFk = vTravelFk;
IF NOT vEntryFk THEN
@@ -61448,82 +54661,82 @@ proc: BEGIN
travelFk = vTravelFk;
SELECT LAST_INSERT_ID() INTO vEntryFk;
-
+
ELSE
-
+
DELETE FROM buy WHERE entryFk = vEntryFk;
-
+
END IF;
-- Preparamos tabla auxilar
DROP TEMPORARY TABLE IF EXISTS tmp.inventory;
-
- CREATE TEMPORARY TABLE tmp.inventory
+
+ CREATE TEMPORARY TABLE tmp.inventory
(
- itemFk INT(11) NOT NULL PRIMARY KEY,
- quantity int(11) DEFAULT '0',
- buyingValue decimal(10,3) DEFAULT '0.000',
- freightValue decimal(10,3) DEFAULT '0.000',
- packing int(11) DEFAULT '0',
- `grouping` smallint(5) unsigned NOT NULL DEFAULT '1',
- groupingMode tinyint(4) NOT NULL DEFAULT 0 ,
- comissionValue decimal(10,3) DEFAULT '0.000',
- packageValue decimal(10,3) DEFAULT '0.000',
- packageFk varchar(10) COLLATE utf8_unicode_ci DEFAULT '--',
- price1 decimal(10,2) DEFAULT '0.00',
- price2 decimal(10,2) DEFAULT '0.00',
- price3 decimal(10,2) DEFAULT '0.00',
- minPrice decimal(10,2) DEFAULT '0.00',
- producer varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
+ itemFk INT(11) NOT NULL PRIMARY KEY,
+ quantity int(11) DEFAULT '0',
+ buyingValue decimal(10,3) DEFAULT '0.000',
+ freightValue decimal(10,3) DEFAULT '0.000',
+ packing int(11) DEFAULT '0',
+ `grouping` smallint(5) unsigned NOT NULL DEFAULT '1',
+ groupingMode tinyint(4) NOT NULL DEFAULT 0 ,
+ comissionValue decimal(10,3) DEFAULT '0.000',
+ packageValue decimal(10,3) DEFAULT '0.000',
+ packageFk varchar(10) COLLATE utf8_unicode_ci DEFAULT '--',
+ price1 decimal(10,2) DEFAULT '0.00',
+ price2 decimal(10,2) DEFAULT '0.00',
+ price3 decimal(10,2) DEFAULT '0.00',
+ minPrice decimal(10,2) DEFAULT '0.00',
+ producer varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
INDEX (itemFK))
ENGINE = MEMORY ;
-- Compras
- INSERT INTO tmp.inventory(itemFk,quantity)
+ INSERT INTO tmp.inventory(itemFk,quantity)
SELECT b.itemFk, sum(b.quantity)
FROM buy b
- JOIN entry e ON e.id = b.entryFk
- JOIN travel tr ON tr.id = e.travelFk
- WHERE tr.warehouseInFk = vWh
+ JOIN entry e ON e.id = b.entryFk
+ JOIN travel tr ON tr.id = e.travelFk
+ WHERE tr.warehouseInFk = vWh
AND tr.landed BETWEEN vDateLastInventory
- AND vDateYesterday
- AND NOT isRaid
+ AND vDateYesterday
+ AND NOT isRaid
GROUP BY b.itemFk;
- SELECT vDateLastInventory , vDateYesterday;
+ SELECT vDateLastInventory , vDateYesterday;
+
-- Traslados
- INSERT INTO tmp.inventory(itemFk,quantity)
+ INSERT INTO tmp.inventory(itemFk,quantity)
SELECT itemFk, quantityOut
- FROM (
+ FROM (
SELECT b.itemFk, -sum(b.quantity) quantityOut
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel tr ON tr.id = e.travelFk
WHERE tr.warehouseOutFk = vWh
- AND tr.shipped BETWEEN vDateLastInventory
- AND vDateYesterday
+ AND tr.shipped BETWEEN vDateLastInventory
+ AND vDateYesterday
AND NOT isRaid
GROUP BY b.itemFk
- ) sub
+ ) sub
ON DUPLICATE KEY UPDATE quantity = IFNULL(quantity,0) + sub.quantityOut;
-
+
-- Ventas
- INSERT INTO tmp.inventory(itemFk,quantity)
+ INSERT INTO tmp.inventory(itemFk,quantity)
SELECT itemFk, saleOut
- FROM (
+ FROM (
SELECT s.itemFk, -sum(s.quantity) saleOut
FROM sale s
JOIN ticket t ON t.id = s.ticketFk
WHERE t.warehouseFk = vWh
AND t.shipped BETWEEN vDateLastInventory AND vDateYesterday
GROUP BY s.itemFk
- ) sub
+ ) sub
ON DUPLICATE KEY UPDATE quantity = IFNULL(quantity,0) + sub.saleOut;
-- Actualiza valores de la ultima compra
-
UPDATE tmp.inventory inv
JOIN cache.last_buy lb ON lb.item_id = inv.itemFk AND lb.warehouse_id = vWh
- JOIN buy b ON b.id = lb.buy_id
+ JOIN buy b ON b.id = lb.buy_id
SET
inv.buyingValue = b.buyingValue,
inv.freightValue = b.freightValue,
@@ -61555,7 +54768,7 @@ proc: BEGIN
price3,
minPrice,
producer,
- entryFk)
+ entryFk)
SELECT itemFk,
GREATEST(quantity,0),
buyingValue,
@@ -61571,19 +54784,25 @@ proc: BEGIN
price3,
minPrice,
producer,
- vEntryFk
+ vEntryFk
FROM tmp.inventory;
- SELECT vWh, count(*), NOW() FROM tmp.inventory;
-
+ SELECT vWh, count(*), util.VN_NOW() FROM tmp.inventory;
+
+ -- Actualizamos el campo lastUsed de vn.item
+ UPDATE vn.item i
+ JOIN tmp.inventory i2 ON i2.itemFk = i.id
+ SET i.lastUsed = util.VN_NOW()
+ WHERE i2.quantity;
+
-- DROP TEMPORARY TABLE tmp.inventory;
-
+
END LOOP;
CLOSE cWarehouses;
UPDATE config SET inventoried = vDate;
- SET @isModeInventory := FALSE;
+ SET @isModeInventory := FALSE;
DROP TEMPORARY TABLE IF EXISTS tmp.entryToDelete;
CREATE TEMPORARY TABLE tmp.entryToDelete
@@ -61593,9 +54812,9 @@ proc: BEGIN
FROM vn.travel t
JOIN vn.entry e ON e.travelFk = t.id
WHERE e.supplierFk = 4
- AND t.shipped <= TIMESTAMPADD(DAY, -2, TIMESTAMPADD(DAY, -10, CURDATE()))
- AND (DAY(t.shipped) <> 1 OR shipped < TIMESTAMPADD(MONTH, -12, CURDATE()));
-
+ AND t.shipped <= TIMESTAMPADD(DAY, -2, TIMESTAMPADD(DAY, -10, util.VN_CURDATE()))
+ AND (DAY(t.shipped) <> 1 OR shipped < TIMESTAMPADD(MONTH, -12, util.VN_CURDATE()));
+
DELETE e
FROM vn.entry e
JOIN tmp.entryToDelete tmp ON tmp.entryId = e.id;
@@ -61609,6 +54828,8 @@ DELIMITER ;
/*!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 `inventoryMakeLauncher` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -61616,8 +54837,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `inventoryMakeLauncher`()
BEGIN
@@ -61625,7 +54844,7 @@ BEGIN
* Recalcula los inventarios de todos los almacenes.
*/
- call vn.inventoryMake(TIMESTAMPADD(DAY, -10, CURDATE()), 0);
+ call vn.inventoryMake(TIMESTAMPADD(DAY, -10, util.VN_CURDATE()), 0);
END ;;
DELIMITER ;
@@ -61633,257 +54852,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `inventoryMake__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `inventoryMake__`(vDate DATE, vWh INT)
-proc: BEGIN
-/**
- * bernat WORKING IN THIS FILE
- * Recalcula los inventarios de todos los almacenes, si vWh = 0
- *
- * @param vDate Fecha de los nuevos inventarios
- */
-
- DECLARE vDone BOOL;
- DECLARE vEntryFk INT;
- DECLARE vTravelFk INT;
- DECLARE vDateTime DATETIME DEFAULT TIMESTAMP(vDate, '00:00:00');
- DECLARE vDeleteDate DATE DEFAULT TIMESTAMPADD(DAY, -2, vDate);
- DECLARE vDateLastInventory DATE;
- DECLARE vDateYesterday DATETIME DEFAULT TIMESTAMPADD(SECOND,-1,vDate);
-
- DECLARE cWarehouses CURSOR FOR
- SELECT id FROM vn.warehouse WHERE isInventory AND vWh IN (0,id);
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND
- SET vDone = TRUE;
-
- SELECT vDateYesterday;
-
- OPEN cWarehouses;
- SET @isModeInventory := TRUE;
- l: LOOP
-
- SET vDone = FALSE;
- FETCH cWarehouses INTO vWh;
-
- IF vDone THEN
- LEAVE l;
- END IF;
-
- SELECT MAX(landed) INTO vDateLastInventory
- FROM vn.travel tr
- JOIN vn.entry e ON e.travelFk = tr.id
- JOIN vn.buy b ON b.entryFk = e.id
- WHERE warehouseOutFk = 13
- AND landed < vDate
- AND e.supplierFk = 4
- AND warehouseInFk = vWh
- AND NOT isRaid;
-
- -- Generamos travel, si no existe.
- SET vTravelFK = 0;
-
- SELECT id INTO vTravelFk
- FROM vn.travel
- WHERE warehouseOutFk = 13
- AND warehouseInFk = vWh
- AND landed = vDate
- AND agencyFk = 53
- AND ref = 'inventario'
- LIMIT 1;
-
- IF NOT vTravelFK THEN
-
- INSERT INTO vn.travel SET
- warehouseOutFk = 13,
- warehouseInFk = vWh,
- shipped = vDateTime,
- landed = vDate,
- agencyFk = 53,
- ref = 'inventario',
- isDelivered = TRUE,
- isReceived = TRUE;
-
- SELECT LAST_INSERT_ID() INTO vTravelFk;
-
- END IF;
-
- -- Generamos entrada si no existe, o la vaciamos.
- SET vEntryFk = 0;
-
- SELECT id INTO vEntryFk
- FROM vn.entry
- WHERE supplierFk = 4
- AND travelFk = vTravelFk;
-
- IF NOT vEntryFk THEN
-
- INSERT INTO entry SET
- supplierFk = 4,
- isConfirmed = TRUE,
- isOrdered = TRUE,
- travelFk = vTravelFk;
-
- SELECT LAST_INSERT_ID() INTO vEntryFk;
-
- ELSE
-
- DELETE FROM vn.buy WHERE entryFk = vEntryFk;
-
- END IF;
-
- -- Preparamos tabla auxilar
- DROP TEMPORARY TABLE IF EXISTS tmp.inventory;
-
- CREATE TEMPORARY TABLE tmp.inventory
- (
- itemFk INT(11) NOT NULL PRIMARY KEY,
- quantity int(11) DEFAULT '0',
- buyingValue decimal(10,3) DEFAULT '0.000',
- freightValue decimal(10,3) DEFAULT '0.000',
- packing int(11) DEFAULT '0',
- `grouping` smallint(5) unsigned NOT NULL DEFAULT '1',
- groupingMode tinyint(4) NOT NULL DEFAULT 0 ,
- comissionValue decimal(10,3) DEFAULT '0.000',
- packageValue decimal(10,3) DEFAULT '0.000',
- packageFk varchar(10) COLLATE utf8_unicode_ci DEFAULT '--',
- price1 decimal(10,2) DEFAULT '0.00',
- price2 decimal(10,2) DEFAULT '0.00',
- price3 decimal(10,2) DEFAULT '0.00',
- minPrice decimal(10,2) DEFAULT '0.00',
- producer varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
- INDEX (itemFK))
- ENGINE = MEMORY ;
-
- -- Compras
- INSERT INTO tmp.inventory(itemFk,quantity)
- SELECT b.itemFk, sum(b.quantity)
- FROM vn.buy b
- JOIN vn.entry e ON e.id = b.entryFk
- JOIN vn.travel tr ON tr.id = e.travelFk
- WHERE tr.warehouseInFk = vWh
- AND tr.landed BETWEEN vDateLastInventory
- AND vDateYesterday
- AND NOT isRaid
- GROUP BY b.itemFk;
- SELECT vDateLastInventory , vDateYesterday;
- -- Traslados
- INSERT INTO tmp.inventory(itemFk,quantity)
- SELECT itemFk, quantityOut
- FROM (
- SELECT b.itemFk, -sum(b.quantity) quantityOut
- FROM vn.buy b
- JOIN vn.entry e ON e.id = b.entryFk
- JOIN vn.travel tr ON tr.id = e.travelFk
- WHERE tr.warehouseOutFk = vWh
- AND tr.shipped BETWEEN vDateLastInventory
- AND vDateYesterday
- AND NOT isRaid
- GROUP BY b.itemFk
- ) sub
- ON DUPLICATE KEY UPDATE quantity = IFNULL(quantity,0) + sub.quantityOut;
-
- -- Ventas
- INSERT INTO tmp.inventory(itemFk,quantity)
- SELECT itemFk, saleOut
- FROM (
- SELECT s.itemFk, -sum(s.quantity) saleOut
- FROM vn.sale s
- JOIN vn.ticket t ON t.id = s.ticketFk
- WHERE t.warehouseFk = vWh
- AND t.shipped BETWEEN vDateLastInventory AND vDateYesterday
- GROUP BY s.itemFk
- ) sub
- ON DUPLICATE KEY UPDATE quantity = IFNULL(quantity,0) + sub.saleOut;
-
- -- Actualiza valores de la ultima compra
-
- UPDATE tmp.inventory inv
- JOIN cache.last_buy lb ON lb.item_id = inv.itemFk AND lb.warehouse_id = vWh
- JOIN vn.buy b ON b.id = lb.buy_id
- SET
- inv.buyingValue = b.buyingValue,
- inv.freightValue = b.freightValue,
- inv.packing = b.packing,
- inv.`grouping` = b.`grouping`,
- inv.groupingMode = b.groupingMode,
- inv.comissionValue = b.comissionValue,
- inv.packageValue = b.packageValue,
- inv.packageFk = b.packageFk,
- inv.price1 = b.price1,
- inv.price2 = b.price2,
- inv.price3 = b.price3,
- inv.minPrice = b.minPrice,
- inv.producer = b.producer;
-
-
- INSERT INTO vn.buy( itemFk,
- quantity,
- buyingValue,
- freightValue,
- packing,
- `grouping`,
- groupingMode,
- comissionValue,
- packageValue,
- packageFk,
- price1,
- price2,
- price3,
- minPrice,
- producer,
- entryFk)
- SELECT itemFk,
- quantity,
- buyingValue,
- freightValue,
- packing,
- `grouping`,
- groupingMode,
- comissionValue,
- packageValue,
- packageFk,
- price1,
- price2,
- price3,
- minPrice,
- producer,
- vEntryFk
- FROM tmp.inventory;
-
- SELECT vWh, count(*), NOW() FROM tmp.inventory;
-
- -- DROP TEMPORARY TABLE tmp.inventory;
-
- END LOOP;
-
- CLOSE cWarehouses;
-
- UPDATE vn2008.tblContadores SET FechaInventario = vDate;
- SET @isModeInventory := FALSE;
-
- DELETE e, t
- FROM vn.travel t
- JOIN vn.entry e ON e.travelFk = t.id
- WHERE e.supplierFk = 4
- AND t.shipped <= vDeleteDate
- AND (DAY(t.shipped) <> 1 OR shipped < TIMESTAMPADD(MONTH, -12, CURDATE()));
-
-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 DROP PROCEDURE IF EXISTS `inventory_repair` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -61891,8 +54861,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `inventory_repair`()
BEGIN
@@ -61932,7 +54900,7 @@ BEGIN
LEFT JOIN origin o ON o.id = i.originFk
) ON it.id = i.typeFk
LEFT JOIN edi.ekt ek ON b.ektFk = ek.id
- WHERE (b.packageFk = "--" OR b.price2 = 0 OR b.packing = 0 OR b.buyingValue = 0) AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-1,CURDATE())) AND s.name = 'INVENTARIO';
+ WHERE (b.packageFk = "--" OR b.price2 = 0 OR b.packing = 0 OR b.buyingValue = 0) AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-1,util.VN_CURDATE())) AND s.name = 'INVENTARIO';
DROP TEMPORARY TABLE IF EXISTS tmp.lastEntryOk;
CREATE TEMPORARY TABLE tmp.lastEntryOk
@@ -61969,7 +54937,7 @@ BEGIN
LEFT JOIN origin o ON o.id = i.originFk
) ON it.id = i.typeFk
LEFT JOIN edi.ekt ek ON b.ektFk = ek.id
- WHERE b.packageFk != "--" AND b.price2 != 0 AND b.packing != 0 AND b.buyingValue > 0 AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-2,CURDATE()))
+ WHERE b.packageFk != "--" AND b.price2 != 0 AND b.packing != 0 AND b.buyingValue > 0 AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-2,util.VN_CURDATE()))
ORDER BY tr.landed DESC;
DROP TEMPORARY TABLE IF EXISTS tmp.lastEntryOkGroup;
@@ -62008,6 +54976,8 @@ DELIMITER ;
/*!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 `invoiceExpenceMake` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -62015,8 +54985,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceExpenceMake`(IN vInvoice INT)
BEGIN
@@ -62051,47 +55019,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `invoiceExpenceMake__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceExpenceMake__`(IN vInvoice INT)
-BEGIN
-/* Inserta las partidas de gasto correspondientes a la factura
- * REQUIERE tabla ticketToInvoice
- *
- * @param vInvoice Numero de factura
- *
- */
- DELETE FROM invoiceOutExpence
- WHERE invoiceOutFk = vInvoice;
-
- INSERT INTO invoiceOutExpence(
- invoiceOutFk,
- expenceFk,
- amount
- )
- SELECT
- vInvoice,
- expenceFk,
- SUM(ROUND(quantity * price * (100 - discount)/100,2)) amount
- FROM ticketToInvoice t
- JOIN sale s ON s.ticketFk = t.id
- JOIN item i ON i.id = s.itemFk
- GROUP BY i.expenceFk
- HAVING amount != 0;
-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 DROP PROCEDURE IF EXISTS `invoiceFromAddress` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -62099,13 +55028,11 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceFromAddress`(vMaxTicketDate DATETIME,vAddress INT,vCompany INT)
BEGIN
- DECLARE vMinDateTicket DATE DEFAULT TIMESTAMPADD(MONTH, -3, CURDATE());
+ DECLARE vMinDateTicket DATE DEFAULT TIMESTAMPADD(MONTH, -3, util.VN_CURDATE());
SET vMaxTicketDate = vn2008.DAYEND(vMaxTicketDate);
@@ -62124,6 +55051,8 @@ DELIMITER ;
/*!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 `invoiceFromClient` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -62131,12 +55060,10 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceFromClient`(IN vMaxTicketDate datetime, IN vClientFk INT, IN vCompanyFk INT)
BEGIN
- DECLARE vMinTicketDate DATE DEFAULT TIMESTAMPADD(YEAR, -3, CURDATE());
+ DECLARE vMinTicketDate DATE DEFAULT TIMESTAMPADD(YEAR, -3, util.VN_CURDATE());
SET vMaxTicketDate = util.dayend(vMaxTicketDate);
DROP TEMPORARY TABLE IF EXISTS `ticketToInvoice`;
@@ -62154,6 +55081,8 @@ DELIMITER ;
/*!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 `invoiceFromTicket` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -62161,8 +55090,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceFromTicket`(IN vTicket INT)
BEGIN
@@ -62181,6 +55108,8 @@ DELIMITER ;
/*!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 `invoiceInBookingCommon` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -62188,8 +55117,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInBookingCommon`(vInvoiceInId INT, OUT vSerialNumber INT)
BEGIN
@@ -62241,6 +55168,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `invoiceInBookingMain` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -62248,8 +55177,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInBookingMain`(vInvoiceInId INT)
BEGIN
@@ -62499,545 +55426,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `invoiceInBookingMain__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInBookingMain__`(vInvoiceInId INT)
-BEGIN
- DECLARE vTotalAmount,vTotalAmountDivisa DECIMAL(10,2);
- DECLARE vBookNumber,vSerialNumber INT;
- DECLARE vRate DECIMAL(10,4);
- DECLARE vSerial VARCHAR(2);
-
- CALL invoiceInBookingCommon(vInvoiceInId,vSerialNumber);
-
- SELECT serial
- INTO vSerial
- FROM newInvoiceIn;
-
- SELECT SUM(iit.taxableBase * IF(vSerial = 'R' AND tc.`type` <> 'I', 1 +(tc.rate/100),1)),
- SUM(iit.foreignValue * IF(vSerial = 'R', 1 +(tc.rate/100),1)),
- iit.taxableBase/iit.foreignValue
- INTO vTotalAmount, vTotalAmountDivisa, vRate
- FROM newInvoiceIn i
- JOIN invoiceInTax iit ON iit.invoiceInFk = i.id
- JOIN taxCode tc ON iit.taxCodeFk = tc.id;
-
- CALL vn.ledger_next(vBookNumber);
-
- -- Apunte del proveedor
-
- INSERT INTO vn2008.XDiario(
- ASIEN,
- FECHA,
- SUBCTA,
- EUROHABER,
- CONCEPTO,
- CAMBIO,
- HABERME,
- NFACTICK,
- CLAVE,
- empresa_id)
- SELECT
- vBookNumber,
- n.bookEntried,
- s.supplierAccount,
- vTotalAmount EUROHABER,
- n.conceptWithSupplier,
- vRate,
- vTotalAmountDivisa,
- n.invoicesCount,
- vInvoiceInId,
- n.companyFk
- FROM newInvoiceIn n
- JOIN newSupplier s;
-
- -- ----------------------------------------------------------- Linea de Gastos
- INSERT INTO vn2008.XDiario (ASIEN,
- FECHA,
- SUBCTA,
- CONTRA,
- EURODEBE,
- EUROHABER,
- CONCEPTO,
- CAMBIO,
- DEBEME,
- HABERME,
- NFACTICK,
- empresa_id
- )
- SELECT vBookNumber ASIEN,
- n.bookEntried FECHA,
- IF(e.isWithheld , LPAD(RIGHT(s.supplierAccount,5),10,iit.expenceFk),iit.expenceFk) SUBCTA,
- s.supplierAccount CONTRA,
- IF(e.isWithheld AND iit.taxableBase < 0, NULL, ROUND(SUM(iit.taxableBase),2)) EURODEBE,
- IF(e.isWithheld AND iit.taxableBase < 0,ROUND(SUM(-iit.taxableBase),2),NULL) EUROHABER,
- n.conceptWithSupplier CONCEPTO,
- vRate,
- IF(e.isWithheld,NULL,ABS(ROUND(SUM(iit.foreignValue),2))) DEBEME,
- IF(e.isWithheld,ABS(ROUND(SUM(iit.foreignValue),2)),NULL) HABERME,
- n.invoicesCount NFACTICK,
- n.companyFk empresa_id
- FROM newInvoiceIn n
- JOIN newSupplier s
- JOIN invoiceInTax iit ON iit.invoiceInFk = n.id
- JOIN taxCode tc ON tc.id = iit.taxCodeFk
- JOIN expence e ON e.id = iit.expenceFk AND e.taxTypeFk = tc.taxTypeFk
- WHERE iit.expenceFk != 5660000002
- GROUP BY iit.expenceFk;
-
- -- --------------------------------------------------------------------
- -- ------- Lineas de IVA ---------------
- -- --------------------------------------------------------------------
-
- INSERT INTO vn2008.XDiario( ASIEN,
- FECHA,
- SUBCTA,
- CONTRA,
- EURODEBE,
- BASEEURO,
- CONCEPTO,
- FACTURA,
- IVA,
- AUXILIAR,
- SERIE,
- TIPOOPE,
- FECHA_EX,
- FECHA_OP,
- NFACTICK,
- FACTURAEX,
- L340,
- LRECT349,
- TIPOCLAVE,
- TIPOEXENCI,
- TIPONOSUJE,
- TIPOFACT,
- TIPORECTIF,
- TERIDNIF,
- TERNIF,
- TERNOM,
- FECREGCON,
- empresa_id
- )
- SELECT vBookNumber ASIEN,
- n.bookEntried FECHA,
- tc.code SUBCTA,
- s.supplierAccount CONTRA,
- SUM(ROUND(tc.rate * it.taxableBase / 100 /* + 0.0001*/, 2)) EURODEBE,
- SUM(it.taxableBase) BASEEURO,
- GROUP_CONCAT(DISTINCT e.`name` SEPARATOR ', ') CONCEPTO,
- vSerialNumber FACTURA,
- tc.rate IVA,
- IF(isUeeMember AND eWithheld.id IS NULL,'','*') AUXILIAR,
- n.serial SERIE,
- tt.TIPOOPE,
- n.issued FECHA_EX,
- n.operated FECHA_OP,
- n.invoicesCount NFACTICK,
- n.supplierRef FACTURAEX,
- TRUE L340,
- (isSameCountry OR NOT isUeeMember) LRECT349,
- n.cplusTrascendency472Fk TIPOCLAVE,
- n.cplusTaxBreakFk TIPOEXENCI,
- n.cplusSubjectOpFk TIPONOSUJE,
- n.cplusInvoiceType472Fk TIPOFACT,
- n.cplusRectificationTypeFk TIPORECTIF,
- iis.cplusTerIdNifFk TERIDNIF,
- s.nif AS TERNIF,
- s.name AS TERNOM,
- n.booked FECREGCON,
- n.companyFk
- FROM newInvoiceIn n
- JOIN newSupplier s
- JOIN invoiceInTax it ON n.id = it.invoiceInFk
- JOIN taxCode tc ON tc.id = it.taxCodeFk
- JOIN taxType tt ON tt.id = tc.taxTypeFk
- JOIN invoiceInSerial iis ON iis.code = tt.serial
- JOIN expence e ON e.id = it.expenceFk
- AND e.taxTypeFk = tc.taxTypeFk
- LEFT JOIN (SELECT eWithheld.id
- FROM invoiceInTax hold
- JOIN expence eWithheld ON eWithheld.id = hold.expenceFk AND eWithheld.isWithheld
- WHERE hold.invoiceInFk = vInvoiceInId LIMIT 1
- ) eWithheld ON TRUE
- WHERE tc.type != '-'
- AND tc.isActive
- GROUP BY tc.rate, e.id;
-
- -- Linea iva inversor sujeto pasivo
-
- INSERT INTO vn2008.XDiario( ASIEN,
- FECHA,
- SUBCTA,
- CONTRA,
- EUROHABER,
- BASEEURO,
- CONCEPTO,
- FACTURA,
- IVA,
- AUXILIAR,
- SERIE,
- TIPOOPE,
- FECHA_EX,
- FECHA_OP,
- NFACTICK,
- FACTURAEX,
- L340,
- LRECT349,
- TIPOCLAVE,
- TIPOEXENCI,
- TIPONOSUJE,
- TIPOFACT,
- TIPORECTIF,
- TERIDNIF,
- TERNIF,
- TERNOM,
- empresa_id
- )
-
- SELECT vBookNumber ASIEN,
- n.bookEntried FECHA,
- tcLink.code SUBCTA,
- s.supplierAccount CONTRA,
- SUM(ROUND(tcLink.rate * it.taxableBase / 100,2)) EUROHABER,
- ROUND(SUM(it.taxableBase),2) BASEEURO,
- GROUP_CONCAT(DISTINCT e.`name` SEPARATOR ', ') CONCEPTO,
- vSerialNumber FACTURA,
- tcLink.rate IVA,
- '*' AUXILIAR,
- n.serial SERIE,
- tt.TIPOOPE,
- n.issued FECHA_EX,
- n.operated FECHA_OP,
- n.invoicesCount NFACTICK,
- n.supplierRef FACTURAEX,
- FALSE L340,
- (isSameCountry OR NOT isUeeMember) LRECT349,
- 1 TIPOCLAVE,
- n.cplusTaxBreakFk TIPOEXENCI,
- n.cplusSubjectOpFk TIPONOSUJE,
- n.cplusInvoiceType472Fk TIPOFACT,
- n.cplusRectificationTypeFk TIPORECTIF,
- iis.cplusTerIdNifFk TERIDNIF,
- s.nif AS TERNIF,
- s.name AS TERNOM,
- n.companyFk
- FROM newInvoiceIn n
- JOIN newSupplier s
- JOIN invoiceInTax it ON n.id = it.invoiceInFk
- JOIN taxCode tc ON tc.id = it.taxCodeFk
- JOIN taxType tt ON tt.id = tc.taxTypeFk
- JOIN invoiceInSerial iis ON iis.code = tt.serial
- JOIN taxCode tcLink ON tcLink.link = tc.link
- AND tc.id != tcLink.id
- AND tc.link
- JOIN expence e ON e.id = it.expenceFk
- AND e.taxTypeFk = tc.taxTypeFk
- WHERE tc.isActive
- AND (tc.type in('S','I') OR MID(s.supplierAccount,4,1) = '1')
- GROUP BY tcLink.rate, e.id;
-
- -- Actualización del registro original
- UPDATE invoiceIn ii
- JOIN newInvoiceIn ni ON ii.id = ni.id
- SET ii.serialNumber = vSerialNumber,
- ii.isBooked = TRUE;
-
- -- Problemas derivados de la precisión en los decimales al calcular los impuestos
- UPDATE XDiario
- SET EURODEBE = EURODEBE -
- (SELECT IF(ABS(sub.difference) = 0.01, sub.difference, 0)
- FROM(SELECT SUM(IFNULL(ROUND(EURODEBE, 2),0)) - SUM(IFNULL(ROUND(EUROHABER, 2), 0)) difference
- FROM XDiario
- WHERE ASIEN = vBookNumber
- )sub
- )
- WHERE ASIEN = vBookNumber
- AND EURODEBE <> 0
- ORDER BY id DESC
- LIMIT 1;
-
- /*UPDATE XDiario
- SET EURODEBE = EURODEBE -
- (SELECT SUM(IFNULL(ROUND(EURODEBE,2),0))- SUM(IFNULL(ROUND(EUROHABER,2),0)) difference
- FROM XDiario
- WHERE ASIEN = vBookNumber
- HAVING ABS(difference) = 0.01)
- WHERE ASIEN = vBookNumber
- AND EURODEBE <> 0
- ORDER BY id DESC
- LIMIT 1;*/
-
-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 DROP PROCEDURE IF EXISTS `invoiceInBookingMain___` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInBookingMain___`(vInvoiceInId INT)
-BEGIN
- DECLARE vTotalAmount,vTotalAmountDivisa DECIMAL(10,2);
- DECLARE vBookNumber,vSerialNumber INT;
- DECLARE vRate DECIMAL(10,4);
- DECLARE vSerial VARCHAR(2);
-
- CALL invoiceInBookingCommon(vInvoiceInId,vSerialNumber);
-
- SELECT serial
- INTO vSerial
- FROM newInvoiceIn;
-
- SELECT SUM(iit.taxableBase * IF(vSerial = 'R' AND tc.`type` <> 'I', 1 +(tc.rate/100),1)),
- SUM(iit.foreignValue * IF(vSerial = 'R', 1 +(tc.rate/100),1)),
- iit.taxableBase/iit.foreignValue
- INTO vTotalAmount, vTotalAmountDivisa, vRate
- FROM newInvoiceIn i
- JOIN invoiceInTax iit ON iit.invoiceInFk = i.id
- JOIN taxCode tc ON iit.taxCodeFk = tc.id;
-
- CALL vn.ledger_next(vBookNumber);
-
- -- Apunte del proveedor
-
- INSERT INTO vn2008.XDiario(
- ASIEN,
- FECHA,
- SUBCTA,
- EUROHABER,
- CONCEPTO,
- CAMBIO,
- HABERME,
- NFACTICK,
- CLAVE,
- empresa_id)
- SELECT
- vBookNumber,
- n.bookEntried,
- s.supplierAccount,
- vTotalAmount EUROHABER,
- n.conceptWithSupplier,
- vRate,
- vTotalAmountDivisa,
- n.invoicesCount,
- vInvoiceInId,
- n.companyFk
- FROM newInvoiceIn n
- JOIN newSupplier s;
-
- -- ----------------------------------------------------------- Linea de Gastos
- INSERT INTO vn2008.XDiario (ASIEN,
- FECHA,
- SUBCTA,
- CONTRA,
- EURODEBE,
- EUROHABER,
- CONCEPTO,
- CAMBIO,
- DEBEME,
- HABERME,
- NFACTICK,
- empresa_id
- )
- SELECT vBookNumber ASIEN,
- n.bookEntried FECHA,
- IF(e.isWithheld , LPAD(RIGHT(s.supplierAccount,5),10,iit.expenceFk),iit.expenceFk) SUBCTA,
- s.supplierAccount CONTRA,
- IF(e.isWithheld AND iit.taxableBase < 0, NULL, ROUND(SUM(iit.taxableBase),2)) EURODEBE,
- IF(e.isWithheld AND iit.taxableBase < 0,ROUND(SUM(-iit.taxableBase),2),NULL) EUROHABER,
- n.conceptWithSupplier CONCEPTO,
- vRate,
- IF(e.isWithheld,NULL,ABS(ROUND(SUM(iit.foreignValue),2))) DEBEME,
- IF(e.isWithheld,ABS(ROUND(SUM(iit.foreignValue),2)),NULL) HABERME,
- n.invoicesCount NFACTICK,
- n.companyFk empresa_id
- FROM newInvoiceIn n
- JOIN newSupplier s
- JOIN invoiceInTax iit ON iit.invoiceInFk = n.id
- JOIN taxCode tc ON tc.id = iit.taxCodeFk
- JOIN expence e ON e.id = iit.expenceFk AND e.taxTypeFk = tc.taxTypeFk
- WHERE iit.expenceFk != 5660000002
- GROUP BY iit.expenceFk;
-
- -- --------------------------------------------------------------------
- -- ------- Lineas de IVA ---------------
- -- --------------------------------------------------------------------
-
- INSERT INTO vn2008.XDiario( ASIEN,
- FECHA,
- SUBCTA,
- CONTRA,
- EURODEBE,
- BASEEURO,
- CONCEPTO,
- FACTURA,
- IVA,
- AUXILIAR,
- SERIE,
- TIPOOPE,
- FECHA_EX,
- FECHA_OP,
- NFACTICK,
- FACTURAEX,
- L340,
- LRECT349,
- TIPOCLAVE,
- TIPOEXENCI,
- TIPONOSUJE,
- TIPOFACT,
- TIPORECTIF,
- TERIDNIF,
- TERNIF,
- TERNOM,
- FECREGCON,
- empresa_id
- )
- SELECT vBookNumber ASIEN,
- n.bookEntried FECHA,
- tc.code SUBCTA,
- s.supplierAccount CONTRA,
- SUM(ROUND(tc.rate * it.taxableBase / 100 /* + 0.0001*/, 2)) EURODEBE,
- SUM(it.taxableBase) BASEEURO,
- GROUP_CONCAT(DISTINCT e.`name` SEPARATOR ', ') CONCEPTO,
- vSerialNumber FACTURA,
- tc.rate IVA,
- IF(isUeeMember AND eWithheld.id IS NULL,'','*') AUXILIAR,
- n.serial SERIE,
- tt.TIPOOPE,
- n.issued FECHA_EX,
- n.operated FECHA_OP,
- n.invoicesCount NFACTICK,
- n.supplierRef FACTURAEX,
- TRUE L340,
- (isSameCountry OR NOT isUeeMember) LRECT349,
- n.cplusTrascendency472Fk TIPOCLAVE,
- n.cplusTaxBreakFk TIPOEXENCI,
- n.cplusSubjectOpFk TIPONOSUJE,
- n.cplusInvoiceType472Fk TIPOFACT,
- n.cplusRectificationTypeFk TIPORECTIF,
- iis.cplusTerIdNifFk TERIDNIF,
- s.nif AS TERNIF,
- s.name AS TERNOM,
- n.booked FECREGCON,
- n.companyFk
- FROM newInvoiceIn n
- JOIN newSupplier s
- JOIN invoiceInTax it ON n.id = it.invoiceInFk
- JOIN taxCode tc ON tc.id = it.taxCodeFk
- JOIN taxType tt ON tt.id = tc.taxTypeFk
- JOIN invoiceInSerial iis ON iis.code = tt.serial
- JOIN expence e ON e.id = it.expenceFk
- AND e.taxTypeFk = tc.taxTypeFk
- LEFT JOIN (SELECT eWithheld.id
- FROM invoiceInTax hold
- JOIN expence eWithheld ON eWithheld.id = hold.expenceFk AND eWithheld.isWithheld
- WHERE hold.invoiceInFk = vInvoiceInId LIMIT 1
- ) eWithheld ON TRUE
- WHERE tc.type != '-'
- AND tc.isActive
- GROUP BY tc.rate, e.id;
-
- -- Linea iva inversor sujeto pasivo
-
- INSERT INTO vn2008.XDiario( ASIEN,
- FECHA,
- SUBCTA,
- CONTRA,
- EUROHABER,
- BASEEURO,
- CONCEPTO,
- FACTURA,
- IVA,
- AUXILIAR,
- SERIE,
- TIPOOPE,
- FECHA_EX,
- FECHA_OP,
- NFACTICK,
- FACTURAEX,
- L340,
- LRECT349,
- TIPOCLAVE,
- TIPOEXENCI,
- TIPONOSUJE,
- TIPOFACT,
- TIPORECTIF,
- TERIDNIF,
- TERNIF,
- TERNOM,
- empresa_id
- )
-
- SELECT vBookNumber ASIEN,
- n.bookEntried FECHA,
- tcLink.code SUBCTA,
- s.supplierAccount CONTRA,
- SUM(ROUND(tcLink.rate * it.taxableBase / 100,2)) EUROHABER,
- ROUND(SUM(it.taxableBase),2) BASEEURO,
- GROUP_CONCAT(DISTINCT e.`name` SEPARATOR ', ') CONCEPTO,
- vSerialNumber FACTURA,
- tcLink.rate IVA,
- '*' AUXILIAR,
- n.serial SERIE,
- tt.TIPOOPE,
- n.issued FECHA_EX,
- n.operated FECHA_OP,
- n.invoicesCount NFACTICK,
- n.supplierRef FACTURAEX,
- FALSE L340,
- (isSameCountry OR NOT isUeeMember) LRECT349,
- 1 TIPOCLAVE,
- n.cplusTaxBreakFk TIPOEXENCI,
- n.cplusSubjectOpFk TIPONOSUJE,
- n.cplusInvoiceType472Fk TIPOFACT,
- n.cplusRectificationTypeFk TIPORECTIF,
- iis.cplusTerIdNifFk TERIDNIF,
- s.nif AS TERNIF,
- s.name AS TERNOM,
- n.companyFk
- FROM newInvoiceIn n
- JOIN newSupplier s
- JOIN invoiceInTax it ON n.id = it.invoiceInFk
- JOIN taxCode tc ON tc.id = it.taxCodeFk
- JOIN taxType tt ON tt.id = tc.taxTypeFk
- JOIN invoiceInSerial iis ON iis.code = tt.serial
- JOIN taxCode tcLink ON tcLink.link = tc.link
- AND tc.id != tcLink.id
- AND tc.link
- JOIN expence e ON e.id = it.expenceFk
- AND e.taxTypeFk = tc.taxTypeFk
- WHERE tc.isActive
- AND (tc.type in('S','I') OR MID(s.supplierAccount,4,1) = '1')
- GROUP BY tcLink.rate, e.id;
-
- -- Actualización del registro original
- UPDATE invoiceIn ii
- JOIN newInvoiceIn ni ON ii.id = ni.id
- SET ii.serialNumber = vSerialNumber,
- ii.isBooked = TRUE;
-
-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 sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `invoiceInDueDay_calculate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63045,8 +55435,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInDueDay_calculate`(vInvoiceInFk INT)
BEGIN
@@ -63095,58 +55483,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `invoiceInDueDay_calculate__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInDueDay_calculate__`(vInvoiceInFk INT)
-BEGIN
-
- IF !(SELECT COUNT(*)
- FROM invoiceInDueDay iid
- WHERE iid.invoiceInFk = vInvoiceInFk) THEN
-
- INSERT INTO invoiceInDueDay (invoiceInFk,
- dueDated,
- amount,
- foreignValue)
- SELECT vInvoiceInFk,
- IF(payDay, vn2008.next_venc(issued, detalle, payDay),TIMESTAMPADD(DAY, GREATEST(detalle, 2), issued)),
- IF((@cont:=@cont + 1) < cont, TRUNCATE(venc / cont, 2),venc-(TRUNCATE(venc / cont, 2) * (cont - 1))),
- IF(@cont < cont, TRUNCATE(foreignValue / cont, 2), foreignValue - (TRUNCATE(foreignValue / cont, 2) * (cont - 1)))
- FROM ( SELECT SUM((1 + (IFNULL(ti.PorcentajeIva, 0) / 100)*(s.countryFk = s2.countryFk)) * iit.taxableBase)/COUNT(DISTINCT(pdd.detalle)) venc,
- SUM(iit.foreignValue)/COUNT(DISTINCT(pdd.detalle)) foreignValue,
- s.payDemFk,
- ii.companyFk,
- COUNT(DISTINCT(pdd.detalle)) cont,
- s.payDay,
- ii.issued
- FROM invoiceIn ii
- JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id
- LEFT JOIN sage.TiposIva AS ti ON ti.CodigoIva= iit.taxTypeSageFk
- JOIN supplier s ON s.id = ii.supplierFk
- JOIN supplier s2 ON s2.id = ii.companyFk
- JOIN vn2008.pay_dem_det pdd ON pdd.id = s.payDemFk
- WHERE ii.id = vInvoiceInFk
- GROUP BY ii.id
- ) sub
- JOIN (SELECT @cont:=0) sub2
- JOIN vn2008.pay_dem_det pdd ON pdd.id = sub.payDemFk
- GROUP BY detalle;
- 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 DROP PROCEDURE IF EXISTS `invoiceInDueDay_recalc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63154,8 +55492,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInDueDay_recalc`(vInvoiceInFk INT)
BEGIN
@@ -63171,6 +55507,8 @@ DELIMITER ;
/*!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 `invoiceInTaxMakeByDua` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63178,8 +55516,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInTaxMakeByDua`(vDuaFk INT)
BEGIN
@@ -63216,6 +55552,8 @@ DELIMITER ;
/*!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 `invoiceInTax_getFromDua` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63223,8 +55561,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInTax_getFromDua`(vDuaFk INT)
BEGIN
@@ -63261,6 +55597,8 @@ DELIMITER ;
/*!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 `invoiceInTax_getFromEntries` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63268,8 +55606,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInTax_getFromEntries`(IN vId INT)
BEGIN
@@ -63319,6 +55655,8 @@ DELIMITER ;
/*!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 `invoiceOutAgain` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63326,8 +55664,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOutAgain`(IN vInvoiceRef VARCHAR(15), vTaxArea VARCHAR(25))
BEGIN
@@ -63389,6 +55725,8 @@ DELIMITER ;
/*!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 `invoiceOutBooking` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63396,8 +55734,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOutBooking`(IN vInvoice INT)
BEGIN
@@ -63589,7 +55925,7 @@ BEGIN
WHERE iot.invoiceOutFk = vInvoice;
UPDATE invoiceOut
- SET booked = CURDATE()
+ SET booked = util.VN_CURDATE()
WHERE id = vInvoice;
END ;;
DELIMITER ;
@@ -63597,6 +55933,8 @@ DELIMITER ;
/*!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 `invoiceOutBookingRange` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63604,8 +55942,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOutBookingRange`()
BEGIN
@@ -63657,6 +55993,8 @@ DELIMITER ;
/*!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 `invoiceOutDelete` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63664,8 +56002,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOutDelete`(vRef VARCHAR(15))
BEGIN
@@ -63736,126 +56072,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `invoiceOutDelete__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOutDelete__`(vRef VARCHAR(15))
-BEGIN
-
- UPDATE ticket
- SET refFk = NULL
- WHERE refFk = vRef;
-
- DELETE
- FROM invoiceOut
- WHERE ref = vRef;
-
-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 DROP PROCEDURE IF EXISTS `invoiceOutFix_BI_RE_IVA__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOutFix_BI_RE_IVA__`()
-BEGIN
-
-DECLARE done BOOL DEFAULT FALSE;
-DECLARE vInvoice INT;
-
-DECLARE rs CURSOR FOR
- SELECT factura_id
- FROM vn2008.Facturas
- WHERE Importe != BI7 + BI16 + RE4 + RE1 + IVA7 + IVA16
- AND Fecha >= '2017-07-01';
-
-DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
-
-OPEN rs;
-
-FETCH rs INTO vInvoice;
-
-SELECT vInvoice, done;
-
-WHILE NOT done DO
-
- UPDATE invoiceOut io
- JOIN (
- SELECT SUM(amount) AS total
- FROM invoiceOutExpence
- WHERE invoiceOutFk = vInvoice
- ) base
- JOIN (
- SELECT SUM(vat) AS total
- FROM invoiceOutTax
- WHERE invoiceOutFk = vInvoice
- ) vat
- SET io.amount = base.total + vat.total
- WHERE io.id = vInvoice;
-
- UPDATE vn2008.Facturas
- SET BI16 = 0,
- BI7 = 0,
- RE1 = 0,
- RE4 = 0,
- IVA7 = 0,
- IVA16 = 0
- WHERE factura_id = vInvoice;
-
- UPDATE vn2008.Facturas f
- JOIN invoiceOutTax iot ON iot.invoiceOutFk = f.factura_id
- SET f.BI16 = iot.taxableBase, f.IVA16 = iot.vat
- WHERE f.factura_id = vInvoice
- AND iot.pgcFk IN ('4770000021' ,'4770000215', '4770000002','4771000000','4770000000','4770000020');
-
- UPDATE vn2008.Facturas f
- JOIN invoiceOutTax iot ON iot.invoiceOutFk = f.factura_id
- SET f.RE4 = iot.vat
- WHERE f.factura_id = vInvoice
- AND iot.pgcFk = '4770000521';
-
- UPDATE vn2008.Facturas f
- JOIN invoiceOutTax iot ON iot.invoiceOutFk = f.factura_id
- SET f.BI7 = iot.taxableBase, f.IVA7 = iot.vat
- WHERE f.factura_id = vInvoice
- AND iot.pgcFk IN ('4770000010' ,'4770000101');
-
- UPDATE vn2008.Facturas f
- JOIN invoiceOutTax iot ON iot.invoiceOutFk = f.factura_id
- SET f.RE1 = iot.vat
- WHERE f.factura_id = vInvoice
- AND iot.pgcFk = '4770000110';
-
-FETCH rs INTO vInvoice;
-
-END WHILE;
-
-
-CLOSE rs;
-
-
-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 DROP PROCEDURE IF EXISTS `invoiceOutListByCompany` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63863,8 +56081,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOutListByCompany`(vCompany INT, vStarted DATE, vEnded DATE)
BEGIN
@@ -63896,6 +56112,8 @@ DELIMITER ;
/*!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 `invoiceOutTaxAndExpence` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63903,8 +56121,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOutTaxAndExpence`()
BEGIN
@@ -63985,15 +56201,15 @@ DELIMITER ;
/*!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 `invoiceOut_new` */;
/*!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_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOut_new`(
vSerial VARCHAR(255),
@@ -64029,7 +56245,7 @@ BEGIN
DECLARE vNewInvoiceInId INT;
DECLARE vIsInterCompany BOOL;
- SET vInvoiceDate = IFNULL(vInvoiceDate,CURDATE());
+ SET vInvoiceDate = IFNULL(vInvoiceDate,util.VN_CURDATE());
SELECT t.clientFk, t.companyFk
INTO vClient, vCompany
@@ -64108,7 +56324,7 @@ BEGIN
INSERT INTO ticketLog (action, userFk,originFk, description)
- SELECT 'UPDATE',account.userGetId(),ti.id, CONCAT('Crea factura ',vNewRef)
+ SELECT 'UPDATE',account.myUser_getId(),ti.id, CONCAT('Crea factura ',vNewRef)
FROM ticketToInvoice ti;
CALL invoiceExpenceMake(vNewInvoiceId);
@@ -64220,6 +56436,8 @@ DELIMITER ;
/*!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 `invoiceOut_newFromClient` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -64227,8 +56445,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOut_newFromClient`(IN vClientFk int, IN vSerial char(2), IN vMaxShipped date,
IN vCompanyFk int, IN vTaxArea varchar(25),
@@ -64258,7 +56474,7 @@ BEGIN
END IF;
CALL invoiceFromClient(vMaxShipped, vClientFk, vCompanyFk);
- CALL invoiceOut_new(vSerial, CURDATE(), vTaxArea, vInvoiceId);
+ CALL invoiceOut_new(vSerial, util.VN_CURDATE(), vTaxArea, vInvoiceId);
UPDATE invoiceOut
SET `ref` = vRef
@@ -64274,6 +56490,8 @@ DELIMITER ;
/*!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 `invoiceOut_newFromTicket` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -64281,8 +56499,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOut_newFromTicket`(IN vTicketFk int, IN vSerial char(2), IN vTaxArea varchar(25),
IN vRef varchar(25), OUT vInvoiceId int)
@@ -64297,7 +56513,7 @@ BEGIN
*/
DECLARE vIsRefEditable BOOLEAN;
CALL invoiceFromTicket(vTicketFk);
- CALL invoiceOut_new(vSerial, CURDATE(), vTaxArea, vInvoiceId);
+ CALL invoiceOut_new(vSerial, util.VN_CURDATE(), vTaxArea, vInvoiceId);
IF vRef IS NOT NULL THEN
SELECT isRefEditable INTO vIsRefEditable
@@ -64321,158 +56537,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `invoiceOut_new__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOut_new__`(
- vSerial VARCHAR(255),
- vInvoiceDate DATETIME,
- vTaxArea VARCHAR(25),
- OUT vNewInvoiceId INT)
-BEGIN
-
-/* Creación de facturas emitidas.
-* REQUIERE previamente tabla ticketToInvoice.
-*
-* @param vSerial, vInvoiceDate,vTaxArea
-*
-* @return vNewInvoiceId
-*/
-
- DECLARE vSpainCountryCode INT DEFAULT 1;
- DECLARE vIsAnySaleToInvoice BOOL;
- DECLARE vNewRef VARCHAR(255);
- DECLARE vWorker INT DEFAULT account.myUser_getId();
- DECLARE vCompany INT;
- DECLARE vClient INT;
- DECLARE vCplusStandardInvoiceTypeFk INT DEFAULT 1;
- DECLARE vCplusCorrectingInvoiceTypeFk INT DEFAULT 6;
- DECLARE vCplusSimplifiedInvoiceTypeFk INT DEFAULT 2;
- DECLARE vCorrectingSerial VARCHAR(1) DEFAULT 'R';
- DECLARE vSimplifiedSerial VARCHAR(1) DEFAULT 'S';
-
- SET vInvoiceDate = IFNULL(vInvoiceDate,CURDATE());
-
- SELECT t.clientFk, t.companyFk
- INTO vClient, vCompany
- FROM ticketToInvoice tt
- JOIN ticket t ON t.id = tt.id
- LIMIT 1;
-
- -- Elimina tickets sense moviments
-/* UPDATE ticket t
- JOIN ticketToInvoice ti ON ti.id = t.id
- LEFT JOIN sale s ON s.ticketFk = ti.id
- LEFT JOIN expedition e ON e.ticketFk = t.id
- LEFT JOIN ticketPackaging tp ON tp.ticketFk = t.id
- SET t.shipped = '2000-02-01 00:00:00'
- WHERE s.ticketFk IS NULL AND e.ticketFk IS NULL AND e.ticketFk IS NULL;
-*/
- -- Eliminem de ticketToInvoice els tickets que no han de ser facturats
- DELETE ti.*
- FROM ticketToInvoice ti
- JOIN ticket t ON t.id = ti.id
- JOIN client c ON c.id = t.clientFk
- WHERE YEAR(t.shipped) < 2001
- OR c.isTaxDataChecked = FALSE
- OR t.isDeleted
- OR c.hasToInvoice = FALSE;
-
- SELECT SUM(quantity * price * (100 - discount)/100)
- INTO vIsAnySaleToInvoice
- FROM sale s
- JOIN ticketToInvoice t on t.id = s.ticketFk;
-
- IF vIsAnySaleToInvoice THEN
-
- -- el trigger añade el siguiente Id_Factura correspondiente a la vSerial
- -- el trigger añade el siguiente Id_Factura correspondiente a la vSerial
- INSERT INTO invoiceOut
- (
- ref,
- serial,
- issued,
- clientFk,
- dued,
- companyFk,
- cplusInvoiceType477Fk
- )
- SELECT
- 1,
- vSerial,
- vInvoiceDate,
- vClient,
- getDueDate(vInvoiceDate, dueDay),
- vCompany,
- IF(vSerial = vCorrectingSerial,
- vCplusCorrectingInvoiceTypeFk,
- IF(vSerial = vSimplifiedSerial,
- vCplusSimplifiedInvoiceTypeFk,
- vCplusStandardInvoiceTypeFk))
- FROM client
- WHERE id = vClient;
-
-
- SET vNewInvoiceId = LAST_INSERT_ID();
-
- SELECT ref
- INTO vNewRef
- FROM invoiceOut
- WHERE id = vNewInvoiceId;
-
- UPDATE ticket t
- JOIN ticketToInvoice ti ON ti.id = t.id
- SET t.refFk = vNewRef;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.updateInter;
- CREATE TEMPORARY TABLE tmp.updateInter ENGINE = MEMORY
- SELECT s.id,ti.id ticket_id,vWorker Id_Trabajador
- FROM ticketToInvoice ti
- LEFT JOIN vn.ticketState ts ON ti.id = ts.ticket
- JOIN state s
- WHERE IFNULL(ts.alertLevel,0) < 3 and s.`code` = vn.getAlert3State(ti.id);
-
- INSERT INTO vncontrol.inter(state_id,Id_Ticket,Id_Trabajador)
- SELECT * FROM tmp.updateInter;
-
-
- INSERT INTO ticketLog (action, userFk,originFk, description)
- SELECT 'UPDATE',account.userGetId(),ti.id, CONCAT('Crea factura ',vNewRef)
- FROM ticketToInvoice ti;
-
- CALL invoiceExpenceMake(vNewInvoiceId);
- CALL invoiceTaxMake(vNewInvoiceId,vTaxArea);
-
- UPDATE invoiceOut io
- JOIN (
- SELECT SUM(amount) AS total
- FROM invoiceOutExpence
- WHERE invoiceOutFk = vNewInvoiceId
- ) base
- JOIN (
- SELECT SUM(vat) AS total
- FROM invoiceOutTax
- WHERE invoiceOutFk = vNewInvoiceId
- ) vat
- SET io.amount = base.total + vat.total
- WHERE io.id = vNewInvoiceId;
-
- END IF;
-
- DROP TEMPORARY TABLE `ticketToInvoice`;
-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 DROP PROCEDURE IF EXISTS `invoiceTaxMake` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -64480,8 +56546,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceTaxMake`(vInvoice INT, vTaxArea VARCHAR(25))
BEGIN
@@ -64530,62 +56594,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `invoiceTaxMake__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceTaxMake__`(vInvoice INT, vTaxArea VARCHAR(25))
-BEGIN
-/**
- * Factura un conjunto de tickets.
- *
- * @param vInvoice, vTaxAreaFk
- * @table tmp.ticket(ticketFk) Identificadores de los tickets a calcular
- * @return tmp.ticketAmount
- * @return tmp.ticketTax Impuesto desglosado para cada ticket.
- */
- DELETE FROM invoiceOutTax
- WHERE invoiceOutFk = vInvoice;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
- CREATE TEMPORARY TABLE tmp.ticket
- (KEY (ticketFk))
- ENGINE = MEMORY
- SELECT id ticketFk
- FROM ticketToInvoice;
-
- CALL ticket_getTax(vTaxArea);
-
- INSERT INTO invoiceOutTax(
- invoiceOutFk,
- pgcFk,
- taxableBase,
- vat
- )
- SELECT vInvoice,
- pgcFk,
- SUM(taxableBase) as BASE,
- CAST(SUM(taxableBase) * rate / 100 AS DECIMAL (10,2))
- FROM tmp.ticketTax
- GROUP BY pgcFk
- HAVING BASE;
-
- DROP TEMPORARY TABLE tmp.ticket;
- DROP TEMPORARY TABLE tmp.ticketTax;
- DROP TEMPORARY TABLE tmp.ticketAmount;
-
-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 DROP PROCEDURE IF EXISTS `itemBarcode_update` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -64593,8 +56603,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemBarcode_update`(vItemFk INT,vCode VARCHAR(22), vDelete BOOL)
BEGIN
@@ -64610,321 +56618,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `itemCard` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemCard`(IN `vBarcode` VARCHAR(22), IN `vWarehouseFk` INT, IN isBarcode BOOL)
-BEGIN
-
- /*
- * @deprecated: Utilizar item_getInfo
- */
-
- DECLARE vCacheVisibleFk INT;
- DECLARE vCacheAvailableFk INT;
- DECLARE vVisibleAltillo INT;
- DECLARE vItemFk INT;
-
- IF isBarcode THEN
- SELECT vn.barcodeToItem(vBarcode) INTO vItemFk;
- ELSE
- SELECT i.id INTO vItemFk
- FROM vn.item i
- WHERE i.name LIKE CONCAT('%',vBarcode,'%')
- ORDER BY i.id ASC
- LIMIT 1;
- END IF;
-
- IF vItemFk IS NULL THEN
- SELECT vn.barcodeToItem(vBarcode) INTO vItemFk;
- END IF;
-
- CALL cache.visible_refresh(vCacheVisibleFk, FALSE,vWarehouseFk);
- CALL cache.available_refresh(vCacheAvailableFk, FALSE,vWarehouseFk, CURDATE());
-
- SELECT SUM(visible) INTO vVisibleAltillo
- FROM vn.itemShelvingStock
- WHERE itemFk = vItemFk AND warehouseFk = vWarehouseFk;
-
- CALL vn.buyUltimate(vWarehouseFk, CURDATE());
-
- SELECT i.id,
- i.longName,
- i.tag5,
- i.value5,
- i.tag6,
- i.value6,
- i.tag7,
- i.value7,
- i.image,
- i.size,
- i.stems,
- i.category,
- i.minimum as min,
- i.upToDown as repo,
- p.name as producer,
- o.code as origin,
- ip.code as nicho,
- ip.reserve as reserva,
- v.visible - IFNULL(vVisibleAltillo,0) as enNicho,
- a.available,
- vVisibleAltillo as enAltillo,
- v.visible as total,
- c.`grouping` as `grouping`,
- c.Packing as packing,
- CONCAT('https://verdnatura.es/vn-image-data/catalog/200x200/', i.image) as urlImage200,
- CONCAT('https://verdnatura.es/vn-image-data/catalog/1600x900/', i.image) as urlImage,
- i.itemPackingTypeFk,
- i.comment as referencia
- FROM vn.item i
- LEFT JOIN vn.producer p ON p.id = i.producerFk
- LEFT JOIN vn.origin o ON o.id = i.originFk
- LEFT JOIN vn.itemPlacement ip ON ip.itemFk = i.id
- LEFT JOIN cache.visible v ON v.calc_id = vCacheVisibleFk AND v.item_id = i.id
- LEFT JOIN cache.available a ON a.calc_id = vCacheAvailableFk AND a.item_id = i.id
- LEFT JOIN (
- SELECT b.itemFk, b2.`grouping`, b2.packing
- FROM tmp.buyUltimate b
- JOIN vn.buy b2 ON b2.id = b.buyFk
- WHERE b.warehouseFk = vWarehouseFk
- ) c ON i.id = c.itemFk
- WHERE i.id = vItemFk;
-
- DROP TEMPORARY TABLE tmp.buyUltimate;
-
-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 DROP PROCEDURE IF EXISTS `itemCard__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemCard__`(IN `vBarcode` VARCHAR(22), IN `vWarehouseFk` INT, isBarcode BOOL)
-BEGIN
-
- DECLARE vCacheVisibleFk INT;
- DECLARE vCacheAvailableFk INT;
- DECLARE vVisibleAltillo INT;
- DECLARE vItemFk INT;
-
- IF isBarcode THEN
- SELECT vn.barcodeToItem(vBarcode) INTO vItemFk;
- ELSE
- SELECT i.id INTO vItemFk
- FROM vn.item i
- WHERE i.name LIKE CONCAT('%',vBarcode,'%')
- ORDER BY i.id ASC
- LIMIT 1;
- END IF;
-
- IF vItemFk IS NULL THEN
- SELECT vn.barcodeToItem(vBarcode) INTO vItemFk;
- END IF;
-
- CALL cache.visible_refresh(vCacheVisibleFk, TRUE,vWarehouseFk);
- CALL cache.available_refresh(vCacheAvailableFk, TRUE,vWarehouseFk, CURDATE());
-
- SELECT SUM(visible) INTO vVisibleAltillo
- FROM vn.itemShelvingStock
- WHERE itemFk = vItemFk AND warehouseFk = vWarehouseFk;
-
- CALL vn2008.item_last_buy_(vWarehouseFk,vItemFk);
-
- SELECT i.id,
- i.longName,
- i.tag5,
- i.value5,
- i.tag6,
- i.value6,
- i.tag7,
- i.value7,
- i.image,
- i.size,
- i.stems,
- i.category,
- i.minimum as min,
- i.upToDown as repo,
- p.name as producer,
- o.code as origin,
- ip.code as nicho,
- ip.reserve as reserva,
- v.visible - IFNULL(vVisibleAltillo,0) as enNicho,
- a.available,
- vVisibleAltillo as enAltillo,
- v.visible as total,
- c.`grouping` as `grouping`,
- c.Packing as packing,
- CONCAT('https://verdnatura.es/vn-image-data/catalog/200x200/', i.image) as urlImage200,
- CONCAT('https://verdnatura.es/vn-image-data/catalog/1600x900/', i.image) as urlImage,
- i.itemPackingTypeFk
- FROM vn.item i
- LEFT JOIN vn.producer p ON p.id = i.producerFk
- LEFT JOIN vn.origin o ON o.id = i.originFk
- LEFT JOIN vn.itemPlacement ip ON ip.itemFk = i.id
- LEFT JOIN cache.visible v ON v.calc_id = vCacheVisibleFk AND v.item_id = i.id
- LEFT JOIN cache.available a ON a.calc_id = vCacheAvailableFk AND a.item_id = i.id
- LEFT JOIN
- (SELECT b.item_id,c.`grouping`,c.Packing
- FROM vn2008.t_item_last_buy b
- INNER JOIN vn2008.Compres c ON c.Id_Compra = b.buy_id
- where b.warehouse_id = vWarehouseFk) c
- ON i.id= c.item_id
- WHERE i.id = vItemFk;
-
- DROP TEMPORARY TABLE vn2008.t_item_last_buy;
-
-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 DROP PROCEDURE IF EXISTS `itemDiary__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemDiary__`(IN vItemId INT, IN vWarehouse INT)
-BEGIN
- DECLARE vDateInventory DATETIME;
- DECLARE vCurdate DATE DEFAULT CURDATE();
- DECLARE vDayEnd DATETIME DEFAULT util.dayEnd(vCurdate);
-
- SELECT vn.barcodeToItem(vItemId) INTO vItemId;
-
- -- traduccion: date, alertLevel, origin, reference, name, In, Out, Balance
- SELECT inventoried INTO vDateInventory FROM config;
- SET @a = 0;
- SELECT DATE(date) AS date,
- alertLevel,
- stateName,
- origin,
- reference,
- clientFk,
- name,
- `in`,
- `out`,
- @a := @a + IFNULL(`in`,0) - IFNULL(`out`,0) as balance,
- isPicked,
- isTicket,
- `in` as invalue
- FROM
- ( SELECT tr.landed as date,
- b.quantity as `in`,
- NULL as `out`,
- IF(tr.isReceived != FALSE,3, IF(tr.isDelivered,1,0)) as alertLevel,
- st.name AS stateName,
- s.name as name,
- e.ref as reference,
- e.id as origin,
- s.id as clientFk,
- TRUE isPicked,
- FALSE AS isTicket
- FROM buy b
- JOIN entry e ON e.id = b.entryFk
- JOIN travel tr ON tr.id = e.travelFk
- JOIN supplier s ON s.id = e.supplierFk
- JOIN alertLevel al ON al.id =
- CASE
- WHEN tr.isReceived != FALSE THEN 3
- WHEN tr.isDelivered THEN 1
- ELSE 0
- END
- JOIN state st ON st.code = al.code
- WHERE tr.landed >= vDateInventory
- AND vWarehouse = tr.warehouseInFk
- AND b.itemFk = vItemId
- AND e.isInventory = 0
- AND e.isRaid = 0
- UNION ALL
-
- SELECT tr.shipped as date,
- NULL as `in`,
- b.quantity as `out`,
- IF(tr.isReceived != FALSE,3, IF(tr.isDelivered,1,0)) as alertLevel,
- st.name AS stateName,
- s.name as name,
- e.ref as reference,
- e.id as origin,
- s.id as clientFk,
- TRUE isPicked,
- FALSE AS isTicket
- FROM buy b
- JOIN entry e ON e.id = b.entryFk
- JOIN travel tr ON tr.id = e.travelFk
- JOIN warehouse w ON w.id = tr.warehouseOutFk
- JOIN supplier s ON s.id = e.supplierFk
- JOIN alertLevel al ON al.id =
- CASE
- WHEN tr.isReceived != FALSE THEN 3
- WHEN tr.isDelivered THEN 1
- ELSE 0
- END
- JOIN state st ON st.code = al.code
- WHERE tr.shipped >= vDateInventory
- AND vWarehouse =tr.warehouseOutFk
- AND s.id <> 4
- AND b.itemFk = vItemId
- AND e.isInventory = 0
- AND w.isFeedStock = 0
- AND e.isRaid = 0
- UNION ALL
-
- SELECT t.shipped as date,
- NULL as `in`,
- s.quantity as `out`,
- al.id as alertLevel,
- st.name AS stateName,
- t.nickname as name,
- t.refFk as reference,
- t.id as origin,
- t.clientFk,
- stk.id as isPicked, -- TRUE as isPicked
- TRUE as isTicket
- FROM sale s
- JOIN ticket t ON t.id = s.ticketFk
- LEFT JOIN ticketState ts ON ts.ticket = t.id
- LEFT JOIN state st ON st.code = ts.code
- JOIN client c ON c.id = t.clientFk
- JOIN alertLevel al ON al.id =
- CASE
- WHEN t.shipped < vCurdate THEN 3
- WHEN t.shipped > vDayEnd THEN 0
- ELSE IFNULL(ts.alertLevel, 0)
- END
- LEFT JOIN saleTracking stk ON stk.saleFk = s.id AND stk.stateFk = 14 -- comentar
- WHERE t.shipped >= vDateInventory
- AND s.itemFk = vItemId
- AND vWarehouse =t.warehouseFk
- ) AS itemDiary
- ORDER BY date, isTicket, alertLevel DESC, isPicked DESC, `in` DESC, `out` DESC;
-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 DROP PROCEDURE IF EXISTS `itemFreight_Show` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -64932,8 +56627,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemFreight_Show`(vItemFk INT, vWarehouseFk INT)
BEGIN
@@ -64965,6 +56658,8 @@ DELIMITER ;
/*!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 `itemFuentesBalance` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -64972,8 +56667,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemFuentesBalance`(vDaysInFuture INT)
BEGIN
@@ -65028,14 +56721,14 @@ BEGIN
LEFT JOIN (
SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as venta
FROM vn2008.item_out
- WHERE dat BETWEEN CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(curdate()))
+ WHERE dat BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(util.VN_CURDATE()))
AND warehouse_id = vWarehouseFk
GROUP BY item_id
) sale ON sale.item_id = i.id
LEFT JOIN (
SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as compra
FROM vn2008.item_entry_in
- WHERE dat BETWEEN CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(curdate()))
+ WHERE dat BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(util.VN_CURDATE()))
AND warehouse_id = vWarehouseFk
AND isVirtualStock = FALSE
GROUP BY item_id
@@ -65043,7 +56736,7 @@ BEGIN
LEFT JOIN (
SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as traslado
FROM vn2008.item_entry_out
- WHERE dat BETWEEN CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(curdate()))
+ WHERE dat BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(util.VN_CURDATE()))
AND warehouse_id = vWarehouseFk
GROUP BY item_id
) mov ON mov.item_id = i.id
@@ -65058,80 +56751,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `itemGetVisibleAvailable__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemGetVisibleAvailable__`(
- vItem INT,
- vDate DATE,
- vWarehouse TINYINT,
- vRefresh BOOL)
-BEGIN
- -- DEPRECADO - UTILIZAR vn.item_getVisibleAvailable() - JSB - 2019-11-20
- CALL item_getVisibleAvailable(vItem, vDate, vWarehouse, vRefresh);
-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 DROP PROCEDURE IF EXISTS `itemLastEntries__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemLastEntries__`(IN `vItem` INT, IN `vDays` DATE)
-BEGIN
- SELECT
- w.id AS warehouseFk,
- w.name AS warehouse,
- tr.landed,
- b.entryFk,
- b.isIgnored,
- b.price2,
- b.price3,
- b.stickers,
- b.packing,
- b.`grouping`,
- b.groupingMode,
- b.weight,
- i.stems,
- b.quantity,
- b.buyingValue,
- b.packageFk ,
- s.id AS supplierFk,
- s.name AS supplier
- FROM itemType it
- RIGHT JOIN (entry e
- LEFT JOIN supplier s ON s.id = e.supplierFk
- RIGHT JOIN buy b ON b.entryFk = e.id
- LEFT JOIN item i ON i.id = b.itemFk
- LEFT JOIN ink ON ink.id = i.inkFk
- LEFT JOIN travel tr ON tr.id = e.travelFk
- LEFT JOIN warehouse w ON w.id = tr.warehouseInFk
- LEFT JOIN origin o ON o.id = i.originFk
- ) ON it.id = i.typeFk
- LEFT JOIN edi.ekt ek ON b.ektFk = ek.id
- WHERE b.itemFk = vItem And tr.shipped BETWEEN vDays AND DATE_ADD(CURDATE(), INTERVAl + 10 DAY)
- ORDER BY tr.landed DESC , b.id DESC;
-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 DROP PROCEDURE IF EXISTS `itemPlacementFromTicket` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -65139,8 +56760,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemPlacementFromTicket`(vTicket INT)
BEGIN
@@ -65169,106 +56788,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `itemPlacementReloadVisible` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemPlacementReloadVisible`()
-BEGIN
-/**
- * Reemplaza únicamente el campo itemPlacement.pickable
- * restando al cache.visible los valores de las tablas
- * itemShelving y los tickets con estado impreso
- * que aun no han sido preparados.
- */
-
- DECLARE vCalc INT;
- DECLARE vTodayIni DATE DEFAULT CURDATE();
- DECLARE vTodayEnd DATETIME DEFAULT util.dayend(vTodayIni);
- DECLARE vproductionOrderPrinted INT DEFAULT 4;
- DECLARE vWarehouseSillaFv INT DEFAULT 1;
-
- UPDATE itemPlacement SET pickable = 0;
-
- CALL cache.visible_refresh(vCalc, FALSE, vWarehouseSillaFv);
--- SELECT * FROM cache.visible v;
- DROP TEMPORARY TABLE IF EXISTS tmp.itemShelving;
- CREATE TEMPORARY TABLE tmp.itemShelving
- SELECT itemFk, IFNULL(SUM(visible),0) visible
- FROM itemShelving its
- GROUP BY its.itemFk;
--- SELECT * FROM tmp.itemShelving;
- DROP TEMPORARY TABLE IF EXISTS tmp.itemPlacement;
- CREATE TEMPORARY TABLE tmp.itemPlacement
- SELECT s.itemFk, cast(SUM(s.quantity) AS UNSIGNED) visible
- FROM ticket t
- JOIN ticketState ts ON ts.ticketFk = t.id AND productionOrder = vproductionOrderPrinted
- JOIN sale s ON s.ticketFk = t.id
- WHERE t.shipped BETWEEN vTodayIni AND vTodayEnd
- GROUP BY s.itemFk;
--- SELECT * FROM tmp.itemPlacement;
-
-/*SELECT v.item_id, vWarehouseSillaFv, v.visible - IFNULL(tis.visible,0) - IFNULL(tip.visible,0)
- FROM cache.visible v
- LEFT JOIN tmp.itemShelving tis ON tis.itemFk = v.item_id
- LEFT JOIN tmp.itemPlacement tip ON tip.itemFk = v.item_id
- WHERE v.calc_id = vCalc;
- */
- INSERT INTO itemPlacement(itemFk, warehouseFk, pickable)
- SELECT v.item_id, vWarehouseSillaFv, v.visible - IFNULL(tis.visible,0) - IFNULL(tip.visible,0)
- FROM cache.visible v
- LEFT JOIN tmp.itemShelving tis ON tis.itemFk = v.item_id
- LEFT JOIN tmp.itemPlacement tip ON tip.itemFk = v.item_id
- WHERE v.calc_id = vCalc
- ON DUPLICATE KEY UPDATE pickable = VALUES(pickable);
-
- DROP TEMPORARY TABLE tmp.itemShelving;
- DROP TEMPORARY TABLE tmp.itemPlacement;
-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 DROP PROCEDURE IF EXISTS `itemPlacementSave` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemPlacementSave`(
- vCode VARCHAR(22),
- vPlacement VARCHAR(10),
- vWarehouseFk INT )
-BEGIN
- DECLARE vItemFk INT;
- SET vItemFk = barcodeToItem(vCode);
-
- IF ASCII(vPlacement) > 57 THEN
- INSERT INTO itemPlacement(itemFk, warehouseFk, reserve, pickable)
- VALUES(vItemFk, vWarehouseFk, vPlacement, 0)
- ON DUPLICATE KEY UPDATE reserve = vPlacement, modificationDate = NOW();
- ELSE
- INSERT INTO itemPlacement(itemFk, warehouseFk, code)
- VALUES(vItemFk, vWarehouseFk, vPlacement)
- ON DUPLICATE KEY UPDATE code = vPlacement, modificationDate = NOW();
- 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 DROP PROCEDURE IF EXISTS `itemPlacementSupplyAiming` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -65276,8 +56797,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemPlacementSupplyAiming`(vShelvingFk VARCHAR(10), quantity INT, vItemFk INT)
BEGIN
@@ -65312,6 +56831,8 @@ DELIMITER ;
/*!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 `itemPlacementSupplyCloseOrder` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -65319,8 +56840,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemPlacementSupplyCloseOrder`(vId INT, vQuantity INT)
BEGIN
@@ -65335,6 +56854,8 @@ DELIMITER ;
/*!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 `itemPlacementSupplyGetOrder` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -65342,8 +56863,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemPlacementSupplyGetOrder`(vSector INT )
BEGIN
@@ -65385,6 +56904,8 @@ DELIMITER ;
/*!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 `itemPlacementSupplyStockGetTargetList` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -65392,8 +56913,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemPlacementSupplyStockGetTargetList`(vItemFk INT,vSectorFk INT)
BEGIN
@@ -65435,84 +56954,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `itemPlacementUpdateVisible` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemPlacementUpdateVisible`()
-BEGIN
-/**
- * Reemplaza únicamente el campo itemPlacement.pickable
- * de los articulos de la tabla temporal tmp.itemPlacement(itemFk)
- * restando al cache.visible los valores de las tablas
- * itemShelving y los tickets con estado impreso
- * que aun no han sido preparados.
- */
- DECLARE vCalc INT;
- DECLARE vTodayIni DATE DEFAULT CURDATE();
- DECLARE vTodayEnd DATETIME DEFAULT util.dayend(vTodayIni);
- DECLARE vproductionOrderPrinted INT DEFAULT 4;
- DECLARE vWarehouseSillaFv INT DEFAULT 1;
-
- UPDATE itemPlacement SET pickable = 0;
-
- CALL cache.visible_refresh(vCalc, FALSE, vWarehouseSillaFv);
-SELECT * FROM cache.visible v;
- DROP TEMPORARY TABLE IF EXISTS tmp.itemShelving;
- CREATE TEMPORARY TABLE tmp.itemShelving
- SELECT its.itemFk, IFNULL(SUM(visible),0) visible
- FROM itemShelving its
- JOIN tmp.itemPlacement tip ON tip.itemFk = its.itemFk
- GROUP BY its.itemFk;
-SELECT * FROM tmp.itemShelving;
-
-SELECT s.itemFk, cast(SUM(s.quantity) AS UNSIGNED) visible
- FROM ticket t
- JOIN ticketState ts ON ts.ticketFk = t.id AND productionOrder = vproductionOrderPrinted
- JOIN sale s ON s.ticketFk = t.id
- JOIN tmp.itemPlacement tip ON tip.itemFk = s.itemFk
- WHERE t.shipped BETWEEN vTodayIni AND vTodayEnd
- GROUP BY s.itemFk;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
- CREATE TEMPORARY TABLE tmp.ticket
- SELECT s.itemFk, cast(SUM(s.quantity) AS UNSIGNED) visible
- FROM ticket t
- JOIN ticketState ts ON ts.ticketFk = t.id AND productionOrder = vproductionOrderPrinted
- JOIN sale s ON s.ticketFk = t.id
- JOIN tmp.itemPlacement tip ON tip.itemFk = s.itemFk
- WHERE t.shipped BETWEEN vTodayIni AND vTodayEnd
- GROUP BY s.itemFk;
-SELECT * FROM tmp.ticket;
-
-SELECT v.item_id, vWarehouseSillaFv, v.visible - IFNULL(tis.visible,0) - IFNULL(tik.visible,0)
- FROM cache.visible v
- LEFT JOIN tmp.itemShelving tis ON tis.itemFk = v.item_id
- LEFT JOIN tmp.ticket tik ON tik.itemFk = v.item_id
- WHERE v.calc_id = vCalc;
-
- INSERT INTO itemPlacement(itemFk, warehouseFk, pickable)
- SELECT v.item_id, vWarehouseSillaFv, v.visible - IFNULL(tis.visible,0) - IFNULL(tik.visible,0)
- FROM cache.visible v
- LEFT JOIN tmp.itemShelving tis ON tis.itemFk = v.item_id
- LEFT JOIN tmp.ticket tik ON tik.itemFk = v.item_id
- WHERE v.calc_id = vCalc
- ON DUPLICATE KEY UPDATE pickable = VALUES(pickable);
-
- DROP TEMPORARY TABLE tmp.itemShelving;
- DROP TEMPORARY TABLE tmp.ticket;
-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 DROP PROCEDURE IF EXISTS `itemProposal` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -65520,8 +56963,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemProposal`(vItemFk INT, vTicketFk INT,vShowType BOOL)
BEGIN
@@ -65613,6 +57054,8 @@ DELIMITER ;
/*!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 `itemProposal_Add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -65620,8 +57063,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemProposal_Add`(vSaleFk INT, vMateFk INT, vQuantity INT)
BEGIN
@@ -65685,6 +57126,8 @@ DELIMITER ;
/*!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 `itemProposal_beta` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -65692,8 +57135,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemProposal_beta`(vItemFk INT, vTicketFk INT)
BEGIN
@@ -65774,180 +57215,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `itemProposal__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemProposal__`(vItemFk INT, vTicketFk INT)
-BEGIN
-
- DECLARE vWarehouseFk INT;
- DECLARE vShipped DATE;
- DECLARE vCalcFk INT;
- DECLARE vTypeFk INT;
- DECLARE vResultsMax INT DEFAULT 10;
-
- DECLARE vTag5 VARCHAR(25);
- DECLARE vTag6 VARCHAR(25);
- DECLARE vTag7 VARCHAR(25);
- DECLARE vTag8 VARCHAR(25);
-
- DECLARE vValue5 VARCHAR(50);
- DECLARE vValue6 VARCHAR(50);
- DECLARE vValue7 VARCHAR(50);
- DECLARE vValue8 VARCHAR(50);
-
- SELECT warehouseFk, shipped INTO vWarehouseFk, vShipped
- FROM vn.ticket
- WHERE id = vTicketFk;
-
- SELECT typeFk, tag5, value5, tag6, value6, tag7, value7, tag8, value8
- INTO vTypeFk, vTag5, vValue5, vTag6, vValue6, vTag7, vValue7, vTag8, vValue8
- FROM vn.item i
- LEFT JOIN vn.tag t5 ON t5.name = i.tag5 COLLATE utf8_general_ci
- LEFT JOIN vn.tag t6 ON t6.name = i.tag6 COLLATE utf8_general_ci
- LEFT JOIN vn.tag t7 ON t7.name = i.tag7 COLLATE utf8_general_ci
- LEFT JOIN vn.tag t8 ON t8.name = i.tag8 COLLATE utf8_general_ci
- WHERE i.id = vItemFk;
-
- CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vShipped);
-
- SELECT i.id itemFk,
- i.longName,
- i.subName,
- i.tag5,
- i.value5,
- (i.value5 <=> vValue5 COLLATE utf8_general_ci) match5,
- i.tag6,
- i.value6,
- (i.value6 <=> vValue6 COLLATE utf8_general_ci) match6,
- i.tag7,
- i.value7,
- (i.value7 <=> vValue7 COLLATE utf8_general_ci) match7,
- i.tag8,
- i.value8,
- (i.value8 <=> vValue8 COLLATE utf8_general_ci) match8,
- a.available,
- IFNULL(ip.counter,0) counter
- FROM vn.item i
- JOIN cache.available a ON a.item_id = i.id
- LEFT JOIN vn.itemProposal ip ON ip.mateFk = i.id AND ip.itemFk = vItemFk
- WHERE a.calc_id = vCalcFk
- AND available > 0
- AND i.typeFk = vTypeFk
- AND i.id != vItemFk
- ORDER BY counter DESC,
- (i.tag5 = vTag5 COLLATE utf8_general_ci) DESC,
- (i.value5 = vValue5 COLLATE utf8_general_ci) DESC,
- (i.tag6 = vTag6 COLLATE utf8_general_ci) DESC,
- (i.value6 = vValue6 COLLATE utf8_general_ci) DESC,
- (i.tag7 = vTag7 COLLATE utf8_general_ci) DESC,
- (i.value7 = vValue7 COLLATE utf8_general_ci) DESC,
- (i.tag8 = vTag8 COLLATE utf8_general_ci) DESC,
- (i.value8 = vValue8 COLLATE utf8_general_ci) DESC
- LIMIT vResultsMax;
-
-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 DROP PROCEDURE IF EXISTS `itemProposal__2` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemProposal__2`(vItemFk INT, vTicketFk INT)
-BEGIN
-
- DECLARE vWarehouseFk INT;
- DECLARE vShipped DATE;
- DECLARE vCalcFk INT;
- DECLARE vTypeFk INT;
- DECLARE vResultsMax INT DEFAULT 10;
-
- DECLARE vTag1 VARCHAR(25);
- DECLARE vTag5 VARCHAR(25);
- DECLARE vTag6 VARCHAR(25);
- DECLARE vTag7 VARCHAR(25);
- DECLARE vTag8 VARCHAR(25);
-
- DECLARE vValue1 VARCHAR(50);
- DECLARE vValue5 VARCHAR(50);
- DECLARE vValue6 VARCHAR(50);
- DECLARE vValue7 VARCHAR(50);
- DECLARE vValue8 VARCHAR(50);
-
- SELECT warehouseFk, shipped INTO vWarehouseFk, vShipped
- FROM vn.ticket
- WHERE id = vTicketFk;
-
- SELECT typeFk, tag5, value5, tag6, value6, tag7, value7, tag8, value8, t1.name, it1.value
- INTO vTypeFk, vTag5, vValue5, vTag6, vValue6, vTag7, vValue7, vTag8, vValue8, vTag1, vValue1
- FROM vn.item i
- LEFT JOIN vn.itemTag it1 ON it1.itemFk = i.id AND it1.priority = 1
- LEFT JOIN vn.tag t1 ON t1.id = it1.tagFk
- WHERE i.id = vItemFk;
-
- CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vShipped);
-
- SELECT i.id itemFk,
- i.longName,
- i.subName,
- i.tag5,
- i.value5,
- (i.value5 <=> vValue5 COLLATE utf8_general_ci) match5,
- i.tag6,
- i.value6,
- (i.value6 <=> vValue6 COLLATE utf8_general_ci) match6,
- i.tag7,
- i.value7,
- (i.value7 <=> vValue7 COLLATE utf8_general_ci) match7,
- i.tag8,
- i.value8,
- (i.value8 <=> vValue8 COLLATE utf8_general_ci) match8,
- a.available,
- IFNULL(ip.counter,0) counter
- FROM vn.item i
- JOIN cache.available a ON a.item_id = i.id
- LEFT JOIN vn.itemProposal ip ON ip.mateFk = i.id AND ip.itemFk = vItemFk
- LEFT JOIN vn.itemTag it1 ON it1.itemFk = i.id AND it1.priority = 1
- LEFT JOIN vn.tag t1 ON t1.id = it1.tagFk
- WHERE a.calc_id = vCalcFk
- AND available > 0
- AND i.typeFk = vTypeFk
- AND i.id != vItemFk
- ORDER BY counter DESC,
- (t1.name = vTag1 COLLATE utf8_general_ci) DESC,
- (it1.value = vValue1 COLLATE utf8_general_ci) DESC,
- (i.tag5 = vTag5 COLLATE utf8_general_ci) DESC,
- (i.value5 = vValue5 COLLATE utf8_general_ci) DESC,
- (i.tag6 = vTag6 COLLATE utf8_general_ci) DESC,
- (i.value6 = vValue6 COLLATE utf8_general_ci) DESC,
- (i.tag7 = vTag7 COLLATE utf8_general_ci) DESC,
- (i.value7 = vValue7 COLLATE utf8_general_ci) DESC,
- (i.tag8 = vTag8 COLLATE utf8_general_ci) DESC,
- (i.value8 = vValue8 COLLATE utf8_general_ci) DESC
- LIMIT vResultsMax;
-
-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 DROP PROCEDURE IF EXISTS `itemRefreshTags` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -65955,8 +57224,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemRefreshTags`(IN vItem INT)
BEGIN
@@ -65981,6 +57248,8 @@ DELIMITER ;
/*!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 `itemSale_byWeek` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -65988,8 +57257,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemSale_byWeek`(vWeek INT, IN vYear INT, vItemFk INT, vWarehouseFk INT)
BEGIN
@@ -66040,66 +57307,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `itemSale_byWeek__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemSale_byWeek__`(vWeek INT, IN vYear INT, vItemFk INT, vWarehouseFk INT)
-BEGIN
-
- DECLARE vStarted DATE;
- DECLARE vEnded DATETIME;
-
- SELECT MIN(dated), util.dayEnd(MAX(dated)) INTO vStarted, vEnded
- FROM vn.`time` t
- WHERE CONCAT(vYear, vWeek) = t.period;
-
- SELECT
- t.shipped,
- w.name warehouse,
- s.ticketFk,
- c.quality,
- t.nickname AS client,
- am.name AS agencyName,
- wk.code AS salesPerson,
- s.itemFk,
- IFNULL(CONCAT(ig.longName,' ',ig.`size`,' ',ig.subName), s.concept) AS concept,
- s.quantity,
- s.price,
- s.priceFixed,
- s.discount,
- tls.name stateName,
- sb.buyFk,
- s.id saleFk,
- wk.id salesPersonFk
- FROM vn.sale s
- JOIN vn.ticket t ON t.id = s.ticketFk
- JOIN vn.warehouse w ON w.id = t.warehouseFk
- JOIN vn.address a ON a.id = t.addressFk
- LEFT JOIN vn.agencyMode am ON am.id = t.agencyModeFk
- JOIN vn.client c ON c.id = a.clientFk
- LEFT JOIN vn.worker wk ON wk.id = c.salesPersonFk
- LEFT JOIN vn.ticketLastState tls ON tls.ticketFk = t.id
- LEFT JOIN vn.saleBuy sb ON sb.saleFk = s.id
- LEFT JOIN vn.buy b ON b.id = sb.buyFk
- LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk
- WHERE s.itemFk = vItemFk
- AND t.shipped BETWEEN vStarted and vEnded
- AND IF(vWarehouseFk = 0, w.hasComission , t.warehouseFk= vWarehouseFk)
- ORDER BY t.shipped, t.id;
-
-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 DROP PROCEDURE IF EXISTS `itemSaveMin` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66107,8 +57316,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemSaveMin`(min INT,vBarcode VARCHAR(22))
BEGIN
@@ -66126,6 +57333,8 @@ DELIMITER ;
/*!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 `itemSearchShelving` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66133,8 +57342,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemSearchShelving`(`vShelvingFk` VARCHAR(3))
BEGIN
@@ -66148,6 +57355,8 @@ DELIMITER ;
/*!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 `itemShelvingDelete` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66155,8 +57364,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingDelete`(vId INT)
BEGIN
@@ -66169,6 +57376,8 @@ DELIMITER ;
/*!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 `itemShelvingLog_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66176,8 +57385,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingLog_get`(vShelvingFk VARCHAR(10) )
BEGIN
@@ -66217,6 +57424,8 @@ DELIMITER ;
/*!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 `itemShelvingMakeFromDate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66224,8 +57433,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingMakeFromDate`(IN `vShelvingFk` VARCHAR(8), IN `vBarcode` VARCHAR(22), IN `vShelve` VARCHAR(2), IN `vQuantity` INT, IN `vPackagingFk` VARCHAR(10), IN `vGrouping` INT, IN `vPacking` INT, IN `vWarehouseFk` INT, `vCreated` VARCHAR(22))
BEGIN
@@ -66290,6 +57497,8 @@ DELIMITER ;
/*!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 `itemShelvingMatch` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66297,8 +57506,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingMatch`(vEntryFk INT, vAllTravel BOOLEAN, vFromTimed DATETIME, vToTimed DATETIME)
BEGIN
@@ -66334,6 +57541,8 @@ DELIMITER ;
/*!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 `itemShelvingPlacementSupplyAdd` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66341,8 +57550,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingPlacementSupplyAdd`(vItemShelvingFk INT, vItemPlacementSupplyFk INT, vQuantity INT)
BEGIN
@@ -66367,6 +57574,8 @@ DELIMITER ;
/*!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 `itemShelvingProblem` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66374,8 +57583,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingProblem`(vSectorFk INT)
BEGIN
@@ -66416,7 +57623,7 @@ BEGIN
AND IFNULL(sub3.transit,0) < s.quantity
AND s.isPicked = FALSE
AND s.reserved = FALSE
- AND t.shipped BETWEEN CURDATE() AND MIDNIGHT(CURDATE())
+ AND t.shipped BETWEEN util.VN_CURDATE() AND MIDNIGHT(util.VN_CURDATE())
AND tst.isPreviousPreparable = TRUE
AND t.warehouseFk = vWarehouseFk
AND iss.sectorFk = vSectorFk
@@ -66429,6 +57636,8 @@ DELIMITER ;
/*!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 `itemShelvingRadar` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66436,8 +57645,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingRadar`(vSectorFk INT)
proc:BEGIN
@@ -66483,7 +57690,7 @@ proc:BEGIN
WHERE id = vSectorFk;
CALL cache.visible_refresh(vCalcVisibleFk, TRUE, vWarehouseFk);
- CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, CURDATE());
+ CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, util.VN_CURDATE());
DROP TEMPORARY TABLE IF EXISTS tmp.itemShelvingRadar;
@@ -66560,7 +57767,7 @@ proc:BEGIN
SELECT iss.itemFk,
0 `hour`,
0 `minute`,
- IFNULL(ip.`code`,'--') itemPlacementCode,
+ '--' itemPlacementCode,
i.longName,
i.size,
i.subName producer,
@@ -66577,7 +57784,6 @@ proc:BEGIN
iss.sectorFk
FROM vn.itemShelvingStock iss
JOIN vn.item i on i.id = iss.itemFk
- LEFT JOIN vn.itemPlacement ip ON ip.itemFk = iss.itemFk AND ip.warehouseFk = vWarehouseFk
LEFT JOIN cache.last_buy lb ON lb.item_id = iss.itemFk AND lb.warehouse_id = vWarehouseFk
LEFT JOIN vn.buy b ON b.id = lb.buy_id
LEFT JOIN cache.available a ON a.item_id = iss.itemFk AND a.calc_id = vCalcAvailableFk
@@ -66613,15 +57819,15 @@ proc:BEGIN
LEFT JOIN vn.zone z ON z.id = t.zoneFk
LEFT JOIN (SELECT DISTINCT saleFk
FROM vn.saleTracking st
- WHERE st.created > CURDATE()
+ WHERE st.created > util.VN_CURDATE()
AND st.isChecked
) stPrevious ON `stPrevious`.`saleFk` = io.saleFk
WHERE t.warehouseFk = vWarehouseFk
AND s.isPicked = 0
AND NOT io.Reservado
AND stPrevious.saleFk IS NULL
- AND io.dat >= CURDATE()
- AND io.dat < CURDATE()+1
+ AND io.dat >= util.VN_CURDATE()
+ AND io.dat < util.VN_CURDATE()+1
) sub
GROUP BY itemFk, hours, minutes;
@@ -66650,6 +57856,8 @@ DELIMITER ;
/*!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 `itemShelvingRadar_Entry` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66657,8 +57865,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingRadar_Entry`(vEntryFk INT)
BEGIN
@@ -66666,10 +57872,10 @@ BEGIN
DECLARE vWarehouseFk INT DEFAULT 1;
DECLARE vCalcVisibleFk INT;
DECLARE vCalcAvailableFk INT;
- DECLARE vTodayDayEnd DATETIME DEFAULT util.dayEnd(CURDATE());
+ DECLARE vTodayDayEnd DATETIME DEFAULT util.dayEnd(util.VN_CURDATE());
CALL cache.visible_refresh(vCalcVisibleFk, FALSE, 1);
- CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, CURDATE());
+ CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, util.VN_CURDATE());
DROP TEMPORARY TABLE IF EXISTS tmp.item;
CREATE TEMPORARY TABLE tmp.item
@@ -66699,7 +57905,7 @@ BEGIN
JOIN tmp.item2 ti ON ti.itemFk = s.itemFk
JOIN vn.ticket t ON t.id = s.ticketFk
LEFT JOIN vn.ticketState tst ON tst.ticketFk = t.id
- WHERE t.shipped BETWEEN CURDATE() AND vTodayDayEnd
+ WHERE t.shipped BETWEEN util.VN_CURDATE() AND vTodayDayEnd
AND t.warehouseFk = vWarehouseFk
AND IFNULL(tst.productionOrder,0) < 5
GROUP BY s.itemFK
@@ -66715,6 +57921,8 @@ DELIMITER ;
/*!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 `itemShelvingRadar_Entry_State_beta` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66722,8 +57930,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingRadar_Entry_State_beta`(vEntryFk INT)
BEGIN
@@ -66731,10 +57937,10 @@ BEGIN
DECLARE vWarehouseFk INT DEFAULT 1;
DECLARE vCalcVisibleFk INT;
DECLARE vCalcAvailableFk INT;
- DECLARE vTodayDayEnd DATETIME DEFAULT util.dayEnd(CURDATE());
+ DECLARE vTodayDayEnd DATETIME DEFAULT util.dayEnd(util.VN_CURDATE());
CALL cache.visible_refresh(vCalcVisibleFk, FALSE, 1);
- CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, CURDATE());
+ CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, util.VN_CURDATE());
DROP TEMPORARY TABLE IF EXISTS tmp.item;
CREATE TEMPORARY TABLE tmp.item
@@ -66766,6 +57972,8 @@ DELIMITER ;
/*!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 `itemShelvingRadar_Urgent` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66773,8 +57981,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingRadar_Urgent`()
BEGIN
@@ -66819,7 +58025,7 @@ BEGIN
LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk
JOIN client c on c.id = t.clientFk
JOIN clientType ct ON ct.id = c.clientTypeFk
- WHERE t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE())
+ WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
AND ISNULL(st.saleFk)
AND ct.code IN ('normal', 'trust')
GROUP BY s.itemFk
@@ -66846,7 +58052,7 @@ BEGIN
LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk
JOIN client c on c.id = t.clientFk
JOIN clientType ct ON ct.id = c.clientTypeFk
- WHERE t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE())
+ WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
AND ISNULL(st.saleFk)
AND ct.code IN ('normal', 'trust')
GROUP BY s.itemFk
@@ -66862,57 +58068,23 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingSaleAdd` */;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingSale_Add` */;
/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingSaleAdd`(vItemShelvingFk INT, saleFk INT, vQuantity INT)
-BEGIN
-
- IF saleFk <> 0 THEN
- INSERT INTO vn.itemShelvingSale(itemShelvingFk,
- saleFk,
- quantity,
- userFk)
- VALUES (vItemShelvingFk,
- saleFk,
- vQuantity,
- getUser());
-
- END IF;
-
- UPDATE vn.itemShelving
- SET visible = (visible - vQuantity)
- WHERE id = vItemShelvingFk;
-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 DROP PROCEDURE IF EXISTS `itemShelvingSaleSupplyAdd` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingSaleSupplyAdd`(vItemShelvingFk INT, saleFk INT, vQuantity INT)
+CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingSale_Add`(vItemShelvingFk INT, vSaleFk INT, vQuantity INT)
BEGIN
/**
* Añade línea a itemShelvingSale y regulariza el carro
*
* @param vItemShelvingFk Id itemShelving
- * @param saleFk Id de sale
+ * @param vSaleFk Id de sale
* @param vQuantity cantidad a regularizar
*/
INSERT INTO itemShelvingSale(itemShelvingFk,
@@ -66920,7 +58092,7 @@ BEGIN
quantity,
userFk)
VALUES (vItemShelvingFk,
- saleFk,
+ vSaleFk,
vQuantity,
getUser());
@@ -66928,9 +58100,9 @@ BEGIN
SET visible = visible - vQuantity
WHERE id = vItemShelvingFk;
- UPDATE vn2008.Movimientos_mark
- SET valor = 1
- WHERE Id_Movimiento = saleFk;
+ UPDATE vn.saleTracking
+ SET isChecked = 1
+ WHERE saleFk = vSaleFk;
END ;;
DELIMITER ;
@@ -66938,6 +58110,8 @@ DELIMITER ;
/*!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 `itemShelvingTransfer` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66945,8 +58119,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingTransfer`(vItemShelvingFk INT,shelvingFkD VARCHAR(22))
BEGIN
@@ -66963,6 +58135,8 @@ DELIMITER ;
/*!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 `itemShelving_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66970,8 +58144,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vShelve VARCHAR(2), IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT)
BEGIN
@@ -67042,6 +58214,8 @@ DELIMITER ;
/*!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 `itemShelving_addByClaim` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67049,8 +58223,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_addByClaim`(vClaimFk INT, vShelvingFk VARCHAR(3))
BEGIN
@@ -67068,7 +58240,7 @@ BEGIN
JOIN ticket t ON t.id = c.ticketFk
WHERE c.id = vClaimFk;
- CALL buyUltimate (vWarehouseFk, CURDATE());
+ CALL buyUltimate (vWarehouseFk, util.VN_CURDATE());
INSERT INTO itemShelving (itemFk, shelvingFk, packing, `grouping`, visible)
SELECT s.itemFk, vShelvingFk, b.packing, b.`grouping`, cb.quantity AS visible
@@ -67085,6 +58257,8 @@ DELIMITER ;
/*!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 `itemShelving_BuyerGet` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67092,8 +58266,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_BuyerGet`( )
BEGIN
@@ -67106,6 +58278,8 @@ DELIMITER ;
/*!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 `itemShelving_BuyerTask` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67113,8 +58287,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_BuyerTask`(vWorkerFk INT )
BEGIN
@@ -67145,6 +58317,8 @@ DELIMITER ;
/*!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 `itemShelving_filterBuyer` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67152,8 +58326,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_filterBuyer`(vBuyerFk INT, vWarehouseFk INT)
proc:BEGIN
@@ -67205,7 +58377,7 @@ proc:BEGIN
JOIN ticket t ON t.id = s.ticketFk
JOIN client c on c.id = t.clientFk
JOIN clientType ct ON ct.id = c.clientTypeFk
- WHERE t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE())
+ WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
AND ISNULL(st.saleFk)
AND ct.code IN ('normal', 'trust')
GROUP BY s.itemFk
@@ -67230,7 +58402,7 @@ proc:BEGIN
JOIN ticket t ON t.id = s.ticketFk
JOIN client c on c.id = t.clientFk
JOIN clientType ct ON ct.id = c.clientTypeFk
- WHERE t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE())
+ WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
AND ISNULL(st.saleFk)
AND ct.code IN ('normal', 'trust')
GROUP BY s.itemFk
@@ -67247,6 +58419,8 @@ DELIMITER ;
/*!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 `itemShelving_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67254,8 +58428,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_get`(IN vShelvingFk VARCHAR(8))
BEGIN
@@ -67289,6 +58461,8 @@ DELIMITER ;
/*!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 `itemShelving_getInfo` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67296,8 +58470,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_getInfo`(vItemFk VARCHAR(22))
BEGIN
@@ -67326,6 +58498,8 @@ DELIMITER ;
/*!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 `itemShelving_getSaleDate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67333,8 +58507,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_getSaleDate`(vShelvingFk VARCHAR(3))
BEGIN
@@ -67377,11 +58549,11 @@ BEGIN
FROM (
SELECT * FROM (
SELECT t2.* FROM (
- SELECT item_id itemFk, amount, CURDATE() dated
+ SELECT item_id itemFk, amount, util.VN_CURDATE() dated
FROM cache.stock
WHERE warehouse_id = vWarehouseFk
UNION ALL
- SELECT ish.itemFk, - sum(visible), CURDATE()
+ SELECT ish.itemFk, - sum(visible), util.VN_CURDATE()
FROM vn.itemShelving ish
JOIN shelving sh ON sh.code = ish.shelvingFk
JOIN parking p ON sh.parkingFk = p.id
@@ -67391,21 +58563,21 @@ BEGIN
UNION ALL
SELECT item_id, sum(iei.amount), dat
FROM vn2008.item_entry_in iei
- WHERE dat >= CURDATE()
+ WHERE dat >= util.VN_CURDATE()
AND warehouse_id = vWarehouseFk
AND isVirtualStock = FALSE
GROUP BY item_id, dat
UNION ALL
SELECT item_id, sum(ieo.amount), dat
FROM vn2008.item_entry_out ieo
- WHERE dat >= CURDATE()
+ WHERE dat >= util.VN_CURDATE()
AND warehouse_id = vWarehouseFk
GROUP BY item_id, dat
UNION ALL
SELECT i.itemFk, sum(io.amount), dat
FROM vn2008.item_out io
JOIN tmp.item i ON i.itemFk = io.item_id
- WHERE io.dat >= CURDATE()
+ WHERE io.dat >= util.VN_CURDATE()
AND io.warehouse_id = vWarehouseFk
GROUP BY io.item_id, io.dat
) t2
@@ -67429,6 +58601,8 @@ DELIMITER ;
/*!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 `itemShelving_inventory` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67436,8 +58610,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_inventory`(vParkingFromFk INT, vParkingToFk INT)
BEGIN
@@ -67486,6 +58658,43 @@ DELIMITER ;
/*!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 `itemShelving_return` */;
+/*!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=`root`@`localhost` PROCEDURE `itemShelving_return`(vShelving VARCHAR(10))
+BEGIN
+/**
+ * Devuelve un listado de posibles ubicaciones a ubicar los item de la matricula
+ * del carro que se le ha pasado.
+ *
+ * @param vShelving matricula del carro
+ */
+ SELECT is2.id,is2.shelvingFk , p.code, is2.itemFk , i.longName , is2.visible
+ FROM vn.itemShelving is2
+ JOIN vn.item i ON i.id = is2.itemFk
+ JOIN vn.shelving sh ON sh.code = is2.shelvingFk
+ JOIN vn.parking p ON p.id = sh.parkingFk
+ JOIN vn.sector s ON s.id = p.sectorFk
+ LEFT JOIN vn.worker w ON w.sectorFk = s.id AND w.id = account.myUser_getId()
+ JOIN vn.warehouse wh ON wh.id = s.warehouseFk
+ JOIN vn.itemShelving is3 ON is3.itemFk = is2.itemFk AND is3.shelvingFk = vShelving COLLATE utf8_unicode_ci
+ GROUP BY is2.id
+ ORDER BY p.pickingOrder DESC;
+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 `itemShelving_StarsUpdate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67493,8 +58702,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_StarsUpdate`(vId INT, vStars INT)
BEGIN
@@ -67509,6 +58716,8 @@ DELIMITER ;
/*!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 `itemShelving_update` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67516,8 +58725,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_update`(vVisible INT, vPacking INT, vShelf INT ,vGrouping INT )
BEGIN
@@ -67541,6 +58748,8 @@ DELIMITER ;
/*!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 `itemStock` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67548,8 +58757,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemStock`(vWarehouseFk SMALLINT, vDated DATETIME, vItemFk INT)
BEGIN
@@ -67574,21 +58781,21 @@ BEGIN
SELECT itemFk, SUM(quantity) stock, SUM(quantity) visible, SUM(quantity) available FROM (
SELECT itemFk, quantity
FROM itemTicketOut
- WHERE shipped >= CURDATE() AND shipped < vDated
+ WHERE shipped >= util.VN_CURDATE() AND shipped < vDated
AND warehouseFk = vWarehouseFk
AND (vItemFk IS NULL OR itemFk = vItemFk)
UNION ALL
SELECT itemFk, quantity
FROM itemEntryIn i
LEFT JOIN edi.warehouseFloramondo wf ON wf.entryFk = i.entryFk
- WHERE i.landed >= CURDATE() AND i.landed < vDated
+ WHERE i.landed >= util.VN_CURDATE() AND i.landed < vDated
AND i.warehouseInFk = vWarehouseFk
AND (vItemFk IS NULL OR i.itemFk = vItemFk)
AND (ISNULL(wf.entryFk) OR vIsLogifloraDay)
UNION ALL
SELECT itemFk, quantity
FROM itemEntryOut
- WHERE shipped >= CURDATE() AND shipped < vDated
+ WHERE shipped >= util.VN_CURDATE() AND shipped < vDated
AND warehouseOutFk = vWarehouseFk
AND (vItemFk IS NULL OR itemFk = vItemFk)
) t
@@ -67610,90 +58817,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `itemStockUpdate__` */;
-/*!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_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemStockUpdate__`(
- vItemFk INT,
- vWarehouseFk INT,
- vNewVisible INT,
- vIsTrash BOOLEAN)
-BEGIN
-
- DECLARE vTicketFk INT;
- DECLARE vClientFk INT;
- DECLARE vCompanyVnlFk INT DEFAULT 442;
- DECLARE vVisible INT DEFAULT 0;
- DECLARE vCalc INT;
- DECLARE vParkedStuff INT;
-
- SELECT barcodeToItem(vItemFk) INTO vItemFk;
-
- CALL cache.visible_refresh(vCalc, TRUE, vWarehouseFk);
-
- SELECT IFNULL(visible,0) INTO vVisible
- FROM cache.visible
- WHERE calc_id = vCalc
- AND item_id = vItemFk;
-
- SELECT sum(visible) INTO vParkedStuff
- FROM itemShelvingStock
- WHERE warehouseFk = vWarehouseFk
- AND itemFk = vItemFk;
-
- SET vNewVisible = vNewVisible + IFNULL(vParkedStuff,0);
-
- SELECT IF(vIsTrash, 200, 400) INTO vClientFk;
-
- SELECT t.id INTO vTicketFk
- FROM ticket t
- JOIN address a ON a.id=t.addressFk
- WHERE t.warehouseFk = vWarehouseFk
- AND t.clientFk = vClientFk
- AND DATE(t.shipped) = CURDATE()
- AND a.isDefaultAddress
- LIMIT 1;
-
- IF vTicketFk IS NULL THEN
-
- CALL ticket_add(
- vClientFk,
- CURDATE(),
- vWarehouseFk,
- vCompanyVnlFk,
- NULL,
- NULL,
- NULL,
- CURDATE(),
- account.userGetId(),
- FALSE,
- vTicketFk);
-
- END IF;
-
- INSERT INTO sale(ticketFk, itemFk, concept, quantity, price, discount)
- SELECT vTicketFk, vItemFk, CONCAT(longName,' ', getWorkerCode(), ' ',LEFT(CAST(NOW() AS TIME),5)), vVisible - vNewVisible, 0, 0
- FROM item
- WHERE id = vItemFk;
-
- UPDATE cache.visible
- SET visible = vNewVisible
- WHERE calc_id = vCalc
- AND item_id = vItemFk;
-
-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 sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemTagMake` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67701,8 +58826,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTagMake`(vItemFk INT)
BEGIN
@@ -67763,6 +58886,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemTagReorder` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67770,8 +58895,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTagReorder`(itemTypeFk INT)
BEGIN
@@ -67803,6 +58926,8 @@ DELIMITER ;
/*!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 `itemTagReorderByName` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67810,8 +58935,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTagReorderByName`(vName VARCHAR(255))
BEGIN
@@ -67843,142 +58966,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `itemTagReorderByName__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTagReorderByName__`(vName VARCHAR(255))
-BEGIN
-
-DECLARE vDone BOOL DEFAULT FALSE;
- DECLARE vItem INT;
-
- DECLARE cur CURSOR FOR
- SELECT id
- FROM upda;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
-
- SET @isTriggerDisabled = TRUE;
-
- DROP TEMPORARY TABLE IF EXISTS upda;
- CREATE TEMPORARY TABLE upda
- SELECT DISTINCT i.id
- FROM vn.item i
- WHERE i.name LIKE CONCAT(vName,'%');
-
- UPDATE itemTag it
- JOIN item i ON i.id = it.itemFk
- JOIN itemTypeTag itt ON itt.itemTypeFk = i.typeFk AND itt.tagFk = it.tagFk
- SET it.priority = itt.priority
- WHERE itt.itemTypeFk = itemTypeFk;
-
- OPEN cur;
- proc: LOOP
- SET vDone = FALSE;
- FETCH cur INTO vItem;
- IF vDone THEN
- LEAVE proc;
- END IF;
- CALL vn.itemRefreshTags(vItem);
- END LOOP;
- CLOSE cur;
- SET @isTriggerDisabled = FALSE;
-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 DROP PROCEDURE IF EXISTS `itemTagReorder__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTagReorder__`(itemTypeFk INT)
-BEGIN
-
-DECLARE vDone BOOL DEFAULT FALSE;
- DECLARE vItem INT;
-
- DECLARE cur CURSOR FOR
- SELECT id
- FROM upda;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
-
- SET @isTriggerDisabled = TRUE;
-
- DROP TEMPORARY TABLE IF EXISTS upda;
- create temporary table upda
- SELECT DISTINCT i.id
- FROM vn.item i
- WHERE i.typeFk = itemTypeFk;
-
- UPDATE itemTag it
- JOIN item i ON i.id = it.itemFk
- JOIN itemTypeTag itt ON itt.itemTypeFk = i.typeFk AND itt.tagFk = it.tagFk
- SET it.priority = itt.priority
- WHERE itt.itemTypeFk = itemTypeFk;
-
- OPEN cur;
- proc: LOOP
- SET vDone = FALSE;
- FETCH cur INTO vItem;
- IF vDone THEN
- LEAVE proc;
- END IF;
- CALL vn.itemRefreshTags(vItem);
- END LOOP;
- CLOSE cur;
- SET @isTriggerDisabled = FALSE;
-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 DROP PROCEDURE IF EXISTS `itemTagReplace__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTagReplace__`(fromItemFk INT, toItemFk INT)
-BEGIN
-
-/*
- * deprecated use itemTag_replace
- */
- DELETE FROM itemTag
- WHERE itemFk = toItemFk;
-
- INSERT INTO itemTag(itemFk, tagFk, value, priority)
- SELECT toItemFk, tagFk, value, priority
- FROM itemTag
- WHERE itemFk = fromItemFk;
-
-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 DROP PROCEDURE IF EXISTS `itemTag_replace` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67986,8 +58975,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTag_replace`(vItemFromFk INT, vItemToFk INT, vPicture VARCHAR(100))
BEGIN
@@ -68027,6 +59014,8 @@ DELIMITER ;
/*!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 `itemTopSeller` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68034,8 +59023,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTopSeller`()
BEGIN
@@ -68056,7 +59043,7 @@ BEGIN
SELECT s.itemFk, SUM(s.quantity) AS total, v.tipo_id typeFk
FROM vn.sale s
INNER JOIN bs.ventas v ON v.Id_Movimiento = s.id
- WHERE v.fecha BETWEEN TIMESTAMPADD(DAY, - 7, CURDATE()) AND CURDATE()
+ WHERE v.fecha BETWEEN TIMESTAMPADD(DAY, - 7, util.VN_CURDATE()) AND util.VN_CURDATE()
GROUP BY s.itemFk;
DROP TABLE IF EXISTS tmp.topSeller;
@@ -68103,6 +59090,8 @@ DELIMITER ;
/*!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 `itemTrash` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68110,8 +59099,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTrash`(
vItemFk INT,
@@ -68134,7 +59121,7 @@ BEGIN
JOIN address a ON a.id=t.addressFk
WHERE t.warehouseFk = vWarehouseFk
AND t.clientFk = vClientFk
- AND DATE(t.shipped) = CURDATE()
+ AND DATE(t.shipped) = util.VN_CURDATE()
AND a.isDefaultAddress
LIMIT 1;
@@ -68144,14 +59131,14 @@ BEGIN
CALL ticket_add(
vClientFk,
- CURDATE(),
+ util.VN_CURDATE(),
vWarehouseFk,
vCompanyVnlFk,
NULL,
NULL,
NULL,
- CURDATE(),
- account.userGetId(),
+ util.VN_CURDATE(),
+ account.myUser_getId(),
FALSE,
vTicketFk);
END IF;
@@ -68159,7 +59146,7 @@ BEGIN
INSERT INTO sale(ticketFk, itemFk, concept, quantity)
SELECT vTicketFk,
vItemFk,
- CONCAT(longName,' ',getWorkerCode(), ' ', LEFT(CAST(NOW() AS TIME),5)),
+ CONCAT(longName,' ',getWorkerCode(), ' ', LEFT(CAST(util.VN_NOW() AS TIME),5)),
vQuantity
FROM item
WHERE id = vItemFk;
@@ -68175,6 +59162,8 @@ DELIMITER ;
/*!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 `itemUpdateTag` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68182,8 +59171,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemUpdateTag`(IN vItem BIGINT)
BEGIN
@@ -68229,28 +59216,33 @@ DELIMITER ;
/*!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 `item_clean` */;
/*!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_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `item_clean`(vItemFrom INT, vItemTo INT)
+CREATE DEFINER=`root`@`localhost` PROCEDURE `item_clean`(OUT vHasError BOOL)
BEGIN
-
-/*
- * Elimina todos los items repetidos y los sustituye por el que tiene menor id
+/**
+ * Elimina todos los items repetidos y los sustituye
+ * por el que tiene menor id
+ *
+ * @return Si da error devuelve a true vHasError
*/
-
- START TRANSACTION;
+ DECLARE CONTINUE HANDLER FOR SQLSTATE '40001'
+ BEGIN
+ SET vHasError = TRUE;
+ END;
SET @isModeInventory:= TRUE;
-- Deletes
+ START TRANSACTION;
UPDATE IGNORE vn.itemCost ic
JOIN tmp.itemsToReplace itr ON ic.itemFk = itr.idOld
@@ -68295,12 +59287,11 @@ BEGIN
DELETE itc.*
FROM vn.itemTaxCountry itc
JOIN tmp.itemsToReplace itr ON itc.itemFk = itr.idOld;
-
- DELETE ip.*
- FROM vn.itemPlacement ip
- JOIN tmp.itemsToReplace itr ON ip.itemFk = itr.idOld;
+
+ COMMIT;
-- Updates
+ START TRANSACTION;
UPDATE vn.buy b
JOIN tmp.itemsToReplace itr ON b.itemFk = itr.idOld
@@ -68349,16 +59340,20 @@ BEGIN
UPDATE vn.itemPlacementSupply ips
JOIN tmp.itemsToReplace itr ON ips.itemFk = itr.idOld
SET ips.itemFk = itr.idNew;
+
+ COMMIT;
-- Eliminamos los items repetidos
+ START TRANSACTION;
DELETE i.*
FROM vn.item i
JOIN tmp.itemsToReplace itr ON i.id = itr.idOld;
+
+ COMMIT;
SET @isModeInventory:= FALSE;
-
- COMMIT;
+ SET vHasError = FALSE;
END ;;
DELIMITER ;
@@ -68366,73 +59361,87 @@ DELIMITER ;
/*!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 `item_cleanLauncher` */;
/*!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_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_cleanLauncher`()
BEGIN
-
+/**
+ * Inicia el procedimiento vn.item_clean
+ */
DECLARE vItemTo INT DEFAULT 0;
- DECLARE vStep INT DEFAULT 500;
+ DECLARE vStep INT DEFAULT 0;
DECLARE vCounter INT DEFAULT 0;
DECLARE vItemFrom INT;
DECLARE vItemEnd INT;
+ DECLARE vQuantity INT;
+ DECLARE vHasError BOOL;
SELECT itemFrom INTO vItemFrom
- FROM tmp.itemCleanCount
+ FROM vn.itemCleanCount
ORDER BY created DESC
LIMIT 1;
+
+ IF ISNULL(vItemFrom) THEN
+ SELECT MIN(id) INTO vItemFrom
+ FROM vn.item i
+ WHERE isFloramondo;
+ END IF;
+
+ SELECT quantity, step
+ INTO vQuantity, vStep
+ FROM vn.itemCleanConfig;
- SET vItemEnd = vItemFrom + 100000;
+ SET vItemEnd = vItemFrom + vQuantity;
DROP TEMPORARY TABLE IF EXISTS tmp.itemsToReplaceSource;
CREATE TEMPORARY TABLE tmp.itemsToReplaceSource
SELECT i.id idOld,
i2.id idNew
FROM vn.item i
- JOIN ( SELECT i.id,
- i.name,
- i.subname,
- i.value5,
- i.value6,
- i.value7,
- i.value8,
- i.value9,
- i.value10,
- i.NumberOfItemsPerCask,
- i.EmbalageCode,
- i.quality
- FROM vn.item i
- LEFT JOIN (SELECT i.id,
- sr.NumberOfUnits,
- MAX(di.LatestOrderDateTime) lodt
- FROM vn.item i
- JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk
- JOIN edi.deliveryInformation di ON di.supplyResponseID = i.supplyResponseFk
- GROUP BY i.id) sub ON sub.id = i.id
- WHERE i.id > 170000
- AND (ISNULL(i.supplyResponseFk)
- OR sub.NumberOfUnits=0
- OR sub.lodt < NOW())
- GROUP BY i.name,
- subname,
- value5,
- value6,
- value7,
- value8,
- value9,
- value10,
- NumberOfItemsPerCask,
- EmbalageCode,
- quality
- ORDER BY i.id) i2 ON i2.name <=> i.name
+ JOIN (SELECT i.id,
+ i.name,
+ i.subname,
+ i.value5,
+ i.value6,
+ i.value7,
+ i.value8,
+ i.value9,
+ i.value10,
+ i.NumberOfItemsPerCask,
+ i.EmbalageCode,
+ i.quality
+ FROM vn.item i
+ LEFT JOIN (SELECT i.id,
+ sr.NumberOfUnits,
+ MAX(di.LatestOrderDateTime) lodt
+ FROM vn.item i
+ JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk
+ JOIN edi.deliveryInformation di ON di.supplyResponseID = i.supplyResponseFk
+ GROUP BY i.id) sub ON sub.id = i.id
+ WHERE isFloramondo
+ AND (ISNULL(i.supplyResponseFk)
+ OR sub.NumberOfUnits = 0
+ OR sub.lodt < util.VN_NOW())
+ GROUP BY i.name,
+ subname,
+ value5,
+ value6,
+ value7,
+ value8,
+ value9,
+ value10,
+ NumberOfItemsPerCask,
+ EmbalageCode,
+ quality
+ ORDER BY i.id) i2 ON i2.name <=> i.name
AND i2.subname <=> i.subname
AND i2.value5 <=> i.value5
AND i2.value6 <=> i.value6
@@ -68443,32 +59452,32 @@ BEGIN
AND i2.NumberOfItemsPerCask <=> i.NumberOfItemsPerCask
AND i2.EmbalageCode <=> i.EmbalageCode
AND i2.quality <=> i.quality
- WHERE i.id > 170000
- AND i.id <> i2.id
+ WHERE isFloramondo
+ AND i.id <> i2.id
ORDER BY i2.id;
- WHILE vItemTo < vItemEnd AND NOT (SELECT isStop FROM tmp.stoper) DO
+ WHILE vItemTo < vItemEnd AND NOT (SELECT isStop FROM vn.itemCleanConfig) DO
SET vItemTo = LEAST(vItemEnd, vItemFrom + vStep);
SELECT COUNT(*) INTO vCounter
FROM tmp.itemsToReplaceSource
- WHERE idNew BETWEEN vItemFrom
- AND vItemTo;
+ WHERE idNew BETWEEN vItemFrom AND vItemTo;
DROP TEMPORARY TABLE IF EXISTS tmp.itemsToReplace;
CREATE TEMPORARY TABLE tmp.itemsToReplace
SELECT *
FROM tmp.itemsToReplaceSource
- WHERE idNew BETWEEN vItemFrom
- AND vItemTo;
+ WHERE idNew BETWEEN vItemFrom AND vItemTo;
- CALL vn.item_clean(vItemFrom, vItemTo);
-
- SET vItemFrom = vItemTo;
+ CALL vn.item_clean(vHasError);
+
+ IF NOT vHasError THEN
+ SET vItemFrom = vItemTo;
+ END IF;
- INSERT INTO tmp.itemCleanCount(itemFrom, itemDeleted)
- VALUES (vItemFrom, vCounter);
+ INSERT INTO vn.itemCleanCount(itemFrom, itemDeleted)
+ VALUES (vItemFrom, vCounter);
END WHILE;
@@ -68481,6 +59490,53 @@ DELIMITER ;
/*!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 `item_deactivateUnused` */;
+/*!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=`root`@`localhost` PROCEDURE `item_deactivateUnused`()
+BEGIN
+/**
+ * Cambia a false el campo isActive de la tabla vn.item
+ * para todos aquellos items que no se han comprado
+ * en los últimos meses configurados en
+ * vn.itemConfig.monthToDeactivate
+ */
+ DECLARE vMonthToDeactivate INT;
+
+ SELECT monthToDeactivate INTO vMonthToDeactivate
+ FROM vn.itemConfig;
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.buyMaxCreated;
+ CREATE TEMPORARY TABLE tmp.buyMaxCreated
+ ENGINE = MEMORY
+ SELECT b.itemFk,
+ MAX(b.created) created
+ FROM vn.buy b
+ JOIN vn.item i ON i.id = b.itemFk
+ WHERE i.isActive
+ GROUP BY itemFk;
+
+ UPDATE vn.item i
+ JOIN tmp.buyMaxCreated bmc ON bmc.itemFk = i.id
+ SET i.isActive = FALSE
+ WHERE bmc.created < util.VN_CURDATE() - INTERVAL vMonthToDeactivate MONTH;
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.buyMaxCreated;
+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 `item_getBalance` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68488,13 +59544,11 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getBalance`(IN vItemId int, IN vWarehouse int)
BEGIN
DECLARE vDateInventory DATETIME;
- DECLARE vCurdate DATE DEFAULT CURDATE();
+ DECLARE vCurdate DATE DEFAULT util.VN_CURDATE();
DECLARE vDayEnd DATETIME DEFAULT util.dayEnd(vCurdate);
SELECT inventoried INTO vDateInventory FROM config;
@@ -68512,8 +59566,8 @@ BEGIN
`in` AS invalue,
`out`,
@a := @a + IFNULL(`in`,0) - IFNULL(`out`,0) as balance,
- @currentLineFk := IF (@shipped < CURDATE()
- OR (@shipped = CURDATE() AND (isPicked OR alertLevel >= 2)),
+ @currentLineFk := IF (@shipped < util.VN_CURDATE()
+ OR (@shipped = util.VN_CURDATE() AND (isPicked OR alertLevel >= 2)),
lineFk,@currentLineFk) lastPreparedLineFk,
isTicket,
lineFk,
@@ -68542,15 +59596,15 @@ BEGIN
JOIN supplier s ON s.id = e.supplierFk
JOIN alertLevel al ON al.id =
CASE
- WHEN tr.landed < CURDATE() THEN 3
- WHEN tr.landed = CURDATE() AND tr.isReceived = TRUE THEN 3
+ WHEN tr.landed < util.VN_CURDATE() THEN 3
+ WHEN tr.landed = util.VN_CURDATE() AND tr.isReceived = TRUE THEN 3
ELSE 0
END
JOIN state st ON st.code = al.code
WHERE tr.landed >= vDateInventory
AND vWarehouse = tr.warehouseInFk
AND b.itemFk = vItemId
- AND e.isInventory = FALSE
+ AND e.isExcludedFromAvailable = FALSE
AND e.isRaid = FALSE
UNION ALL
@@ -68576,8 +59630,8 @@ BEGIN
JOIN supplier s ON s.id = e.supplierFk
JOIN alertLevel al ON al.id =
CASE
- WHEN tr.shipped < CURDATE() THEN 3
- WHEN tr.shipped = CURDATE() AND tr.isReceived = TRUE THEN 3
+ WHEN tr.shipped < util.VN_CURDATE() THEN 3
+ WHEN tr.shipped = util.VN_CURDATE() AND tr.isReceived = TRUE THEN 3
ELSE 0
END
JOIN state st ON st.code = al.code
@@ -68585,7 +59639,7 @@ BEGIN
AND vWarehouse =tr.warehouseOutFk
AND s.id <> 4
AND b.itemFk = vItemId
- AND e.isInventory = FALSE
+ AND e.isExcludedFromAvailable = FALSE
AND w.isFeedStock = FALSE
AND e.isRaid = FALSE
UNION ALL
@@ -68613,8 +59667,8 @@ BEGIN
JOIN clientType ct ON ct.id = c.clientTypeFk
JOIN alertLevel al ON al.id =
CASE
- WHEN t.shipped < curdate() THEN 3
- WHEN t.shipped > util.dayEnd(curdate()) THEN 0
+ WHEN t.shipped < util.VN_CURDATE() THEN 3
+ WHEN t.shipped > util.dayEnd(util.VN_CURDATE()) THEN 0
ELSE IFNULL(ts.alertLevel, 0)
END
LEFT JOIN state stPrep ON stPrep.`code` = 'PREPARED'
@@ -68632,6 +59686,8 @@ DELIMITER ;
/*!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 `item_getInfo` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68639,8 +59695,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getInfo`(IN `vBarcode` VARCHAR(22), IN `vWarehouseFk` INT)
BEGIN
@@ -68653,60 +59707,62 @@ BEGIN
*/
DECLARE vCacheVisibleFk INT;
- DECLARE vCacheAvailableFk INT;
- DECLARE vVisibleItemShelving INT;
- DECLARE vItemFk INT;
-
- SELECT vn.barcodeToItem(vBarcode) INTO vItemFk;
-
- CALL cache.visible_refresh(vCacheVisibleFk, FALSE,vWarehouseFk);
- CALL cache.available_refresh(vCacheAvailableFk, FALSE,vWarehouseFk, CURDATE());
+ DECLARE vCacheAvailableFk INT;
+ DECLARE vVisibleItemShelving INT;
+ DECLARE vItemFk INT;
- SELECT SUM(visible) INTO vVisibleItemShelving
+ SELECT vn.barcodeToItem(vBarcode) INTO vItemFk;
+
+ CALL cache.visible_refresh(vCacheVisibleFk, FALSE,vWarehouseFk);
+ CALL cache.available_refresh(vCacheAvailableFk, FALSE,vWarehouseFk, util.VN_CURDATE());
+
+ SELECT SUM(visible) INTO vVisibleItemShelving
FROM vn.itemShelvingStock
- WHERE itemFk = vItemFk AND warehouseFk = vWarehouseFk;
-
- CALL vn.buyUltimate(vWarehouseFk, CURDATE());
+ WHERE itemFk = vItemFk AND warehouseFk = vWarehouseFk;
+
+ CALL vn.buyUltimate(vWarehouseFk, util.VN_CURDATE());
SELECT i.id,
- i.longName,
- i.tag5,
- i.value5,
- i.tag6,
- i.value6,
- i.tag7,
- i.value7,
- i.image,
- i.size,
- i.stems,
- i.category,
- i.minimum as min,
- p.name as producer,
- o.code as origin,
- v.visible - IFNULL(vVisibleItemShelving,0) as unlocated,
- a.available,
- vVisibleItemShelving,
- v.visible,
- c.`grouping`,
- c.packing,
- CONCAT('https://verdnatura.es/vn-image-data/catalog/200x200/', i.image) as urlImage200,
- CONCAT('https://verdnatura.es/vn-image-data/catalog/1600x900/', i.image) as urlImage,
- i.itemPackingTypeFk,
- i.comment as reference
- FROM vn.item i
+ i.longName,
+ i.tag5,
+ i.value5,
+ i.tag6,
+ i.value6,
+ i.tag7,
+ i.value7,
+ i.image,
+ i.size,
+ i.stems,
+ i.category,
+ i.minimum as min,
+ p.name as producer,
+ o.code as origin,
+ v.visible - IFNULL(vVisibleItemShelving,0) as unlocated,
+ a.available,
+ vVisibleItemShelving,
+ v.visible,
+ c.`grouping`,
+ c.packing,
+ CONCAT('https://verdnatura.es/vn-image-data/catalog/200x200/', i.image) as urlImage200,
+ CONCAT('https://verdnatura.es/vn-image-data/catalog/1600x900/', i.image) as urlImage,
+ i.itemPackingTypeFk,
+ i.comment reference,
+ u.name buyer
+ FROM vn.item i
LEFT JOIN vn.producer p ON p.id = i.producerFk
- LEFT JOIN vn.origin o ON o.id = i.originFk
- LEFT JOIN cache.visible v ON v.calc_id = vCacheVisibleFk AND v.item_id = i.id
+ LEFT JOIN vn.origin o ON o.id = i.originFk
+ LEFT JOIN cache.visible v ON v.calc_id = vCacheVisibleFk AND v.item_id = i.id
LEFT JOIN cache.available a ON a.calc_id = vCacheAvailableFk AND a.item_id = i.id
LEFT JOIN (
SELECT b.itemFk, b2.`grouping`, b2.packing
- FROM tmp.buyUltimate b
- JOIN vn.buy b2 ON b2.id = b.buyFk
- WHERE b.warehouseFk = vWarehouseFk
- ) c ON i.id = c.itemFk
- WHERE i.id = vItemFk;
-
- DROP TEMPORARY TABLE tmp.buyUltimate;
+ FROM tmp.buyUltimate b
+ JOIN vn.buy b2 ON b2.id = b.buyFk
+ WHERE b.warehouseFk = vWarehouseFk
+ ) c ON i.id = c.itemFk
+ JOIN vn.itemType it ON it.id = i.typeFk
+ JOIN account.user u ON u.id = it.workerFk
+ WHERE i.id = vItemFk;
+ DROP TEMPORARY TABLE tmp.buyUltimate;
END ;;
DELIMITER ;
@@ -68714,6 +59770,8 @@ DELIMITER ;
/*!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 `item_getLack` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68721,8 +59779,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getLack`(IN vForce BOOLEAN, IN vDays INT)
BEGIN
@@ -68734,7 +59790,7 @@ BEGIN
**/
CALL `cache`.stock_refresh(vForce);
- CALL item_getMinacum(NULL, CURDATE(), vDays, NULL);
+ CALL item_getMinacum(NULL, util.VN_CURDATE(), vDays, NULL);
CALL item_getMinETD();
SELECT i.id itemFk,
@@ -68765,7 +59821,6 @@ BEGIN
JOIN itemCategory ic ON ic.id = it.categoryFk
LEFT JOIN tmp.itemMinETD im ON im.itemFk = i.id
WHERE w.isForTicket
- AND it.making IS NULL
AND ic.display <> 0
AND it.code != 'GEN'
GROUP BY i.id, w.id
@@ -68779,6 +59834,8 @@ DELIMITER ;
/*!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 `item_getMinacum` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68786,8 +59843,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getMinacum`(IN vWarehouseFk TINYINT, IN vDatedFrom DATETIME, IN vRange INT, IN vItemFk INT)
BEGIN
@@ -68838,7 +59893,7 @@ BEGIN
LEFT JOIN travel t ON t.id = e.travelFk
WHERE t.landed BETWEEN vDatedFrom AND vDatedTo
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
- AND !e.isInventory
+ AND !e.isExcludedFromAvailable
AND b.quantity != 0
AND (vItemFk IS NULL OR b.itemFk = vItemFk)
UNION ALL
@@ -68851,7 +59906,7 @@ BEGIN
LEFT JOIN travel t ON t.id = e.travelFk
WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo
AND (vWarehouseFk IS NULL OR t.warehouseOutFk = vWarehouseFk)
- AND !e.isInventory
+ AND !e.isExcludedFromAvailable
AND b.quantity != 0
AND (vItemFk IS NULL OR b.itemFk = vItemFk)
AND !e.isRaid
@@ -68867,6 +59922,8 @@ DELIMITER ;
/*!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 `item_getMinETD` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68874,8 +59931,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getMinETD`()
BEGIN
@@ -68896,7 +59951,7 @@ BEGIN
FROM ticket t
JOIN sale s ON s.ticketFk = t.id
LEFT JOIN `zone` z ON z.id = t.zoneFk
- WHERE t.shipped BETWEEN CURDATE() AND vMidnight
+ WHERE t.shipped BETWEEN util.VN_CURDATE() AND vMidnight
GROUP BY s.itemFk;
END ;;
DELIMITER ;
@@ -68904,6 +59959,8 @@ DELIMITER ;
/*!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 `item_getSimilar` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68911,8 +59968,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getSimilar`(vItemFk INT, vWarehouseFk INT, vDate DATE, vIsShowedByType BOOL)
BEGIN
@@ -69001,6 +60056,8 @@ DELIMITER ;
/*!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 `item_GetVisible` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -69008,12 +60065,10 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_GetVisible`(vWarehouse SMALLINT, vItem INT)
BEGIN
- DECLARE vTomorrow DATETIME DEFAULT TIMESTAMPADD(DAY, 1, CURDATE());
+ DECLARE vTomorrow DATETIME DEFAULT TIMESTAMPADD(DAY, 1, util.VN_CURDATE());
INSERT INTO vn2008.tmp_item (item_id, visible)
SELECT item_id, SUM(amount) amount
@@ -69025,19 +60080,18 @@ BEGIN
LEFT JOIN (SELECT DISTINCT saleFk
FROM saleTracking st
JOIN state s ON s.id = st.stateFk
- WHERE st.created > CURDATE()
+ WHERE st.created > util.VN_CURDATE()
AND (s.isPicked OR st.isChecked)
) stPrevious ON `stPrevious`.`saleFk` = i.saleFk
WHERE i.warehouseFk = vWarehouse
AND (vItem IS NULL OR i.itemFk = vItem)
AND (s.isPicked OR i.reserved OR stPrevious.saleFk )
- AND i.shipped >= CURDATE() AND i.shipped < vTomorrow
+ AND i.shipped >= util.VN_CURDATE() AND i.shipped < vTomorrow
UNION ALL
SELECT iei.itemFk, quantity
FROM itemEntryIn iei
- LEFT JOIN itemPlacement ip ON ip.itemFk = iei.itemFk AND ip.warehouseFk = vWarehouse
- WHERE (iei.isReceived != FALSE /*OR ip.modificationDate > CURDATE()*/)
- AND iei.landed >= CURDATE() AND iei.landed < vTomorrow
+ WHERE (iei.isReceived != FALSE /*OR ip.modificationDate > util.VN_CURDATE()*/)
+ AND iei.landed >= util.VN_CURDATE() AND iei.landed < vTomorrow
AND iei.warehouseInFk = vWarehouse
AND (vItem IS NULL OR iei.itemFk = vItem)
AND iei.isVirtualStock is FALSE
@@ -69045,7 +60099,7 @@ BEGIN
SELECT itemFk, quantity
FROM itemEntryOut
WHERE isDelivered != FALSE
- AND shipped >= CURDATE() AND shipped < vTomorrow
+ AND shipped >= util.VN_CURDATE() AND shipped < vTomorrow
AND warehouseOutFk = vWarehouse
AND (vItem IS NULL OR itemFk = vItem)
) t
@@ -69058,84 +60112,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `item_getVisibleAvailable__` */;
-/*!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_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getVisibleAvailable__`(
- vItem INT,
- vDate DATE,
- vWarehouse TINYINT,
- vRefresh BOOL)
-BEGIN
- DECLARE vVisibleCalc INT;
- DECLARE vAvailableCalc INT;
- DECLARE vVisibleAltillo INT;
-
- CALL cache.available_refresh(vAvailableCalc, FALSE /*vRefresh*/ , vWarehouse, vDate);
- CALL cache.visible_refresh(vVisibleCalc, FALSE,vWarehouse);
-
- SELECT SUM(visible) INTO vVisibleAltillo
- FROM vn.itemShelvingStock
- WHERE itemFk = vItem
- AND warehouseFk = vWarehouse;
-
- IF vRefresh THEN
-
- DROP TEMPORARY TABLE IF EXISTS vn2008.tmp_item;
- CREATE TEMPORARY TABLE vn2008.tmp_item
- (PRIMARY KEY (item_id))
- ENGINE = MEMORY
- SELECT vItem item_id, 0 stock, 0 visible;
-
- SELECT i.id, i.longName, i.box, i.typeFk,
- i.tag5,i.value5,i.tag6,i.value6,i.tag7,i.value7,i.tag8,i.value8,
- ip.code, ip.reserve,
- vi.visible - IFNULL(vVisibleAltillo,0) AS visible,
- av.available
- FROM vn.item i
- LEFT JOIN vn.itemPlacement ip
- ON i.id = ip.itemFk AND ip.warehouseFk = vWarehouse
- LEFT JOIN vn2008.tmp_item v
- ON v.item_id = i.id
- LEFT JOIN cache.available av
- ON av.calc_id = vAvailableCalc AND av.item_id = i.id
- LEFT JOIN cache.visible vi
- ON vi.calc_id = vVisibleCalc AND vi.item_id = i.id
- LEFT JOIN cache.stock st
- ON st.warehouse_id = vWarehouse AND st.item_id = i.id
- WHERE (vItem IS NULL OR i.id = vItem);
-
- ELSE
-
- SELECT i.id, i.longName, i.box, i.typeFk,
- i.tag5,i.value5,i.tag6,i.value6,i.tag7,i.value7,i.tag8,i.value8,
- ip.code, ip.reserve,
- v.visible - IFNULL(vVisibleAltillo,0) AS visible,
- av.available
- FROM vn.item i
- LEFT JOIN vn.itemPlacement ip
- ON i.id = ip.itemFk AND ip.warehouseFk = vWarehouse
- LEFT JOIN cache.visible v
- ON v.item_id = i.id AND v.calc_id = vVisibleCalc
- LEFT JOIN cache.available av
- ON av.item_id = i.id AND av.calc_id = vAvailableCalc
- WHERE (vItem IS NULL OR i.id = vItem);
-
- 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 sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `item_refreshTags` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -69143,8 +60121,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_refreshTags`()
BEGIN
@@ -69289,6 +60265,8 @@ DELIMITER ;
/*!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 `item_refreshTags_beta` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -69296,8 +60274,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_refreshTags_beta`()
BEGIN
@@ -69432,135 +60408,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `item_refreshTags__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `item_refreshTags__`()
-BEGIN
-/**
- * Actualiza la tabla item, los campos "cache" de tags
- * Para actualizar mas de un registro, la tabla NO tiene que ser en memoria
- * Error Code: 1137. No puedo reabrir tabla: 'tmpI
- *
- * @param temporary table tmp.item(id) del articulo
- **/
- DROP TEMPORARY TABLE IF EXISTS tmp.itemToRefresh;
- CREATE TEMPORARY TABLE tmp.itemToRefresh
- SELECT id from tmp.item;
-
- UPDATE item i
- JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id
- LEFT JOIN itemTag it1 ON it1.priority = 1 AND it1.itemFk = i.id
- LEFT JOIN itemTag it2 ON it2.priority = 2 AND it2.itemFk = i.id
- LEFT JOIN itemTag it3 ON it3.priority = 3 AND it3.itemFk = i.id
- SET i.longName = CONCAT_WS(' ', it1.`value`, it2.`value`, IF(it3.`value` = 'A1','',it3.`value`));
-
- UPDATE item i
- JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id
- LEFT JOIN itemTag it1 ON it1.priority = 1 AND it1.itemFk = i.id
- LEFT JOIN tagAbbreviation ta1 ON ta1.`value` = it1.`value`
- LEFT JOIN itemTag it2 ON it2.priority = 2 AND it2.itemFk = i.id
- LEFT JOIN tagAbbreviation ta2 ON ta2.`value` = it2.`value`
- LEFT JOIN itemTag it3 ON it3.priority = 3 AND it3.itemFk = i.id
- LEFT JOIN tagAbbreviation ta3 ON ta3.`value` = it3.`value`
- SET i.`name` = CONCAT_WS(' ',
- IFNULL(ta1.abbreviation,it1.`value`),
- IFNULL(ta2.abbreviation,it2.`value`),
- IF(i.id > 400000,'',IFNULL(ta3.abbreviation,it3.`value`)));
-
- UPDATE item i
- JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id
- LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 4
- SET i.subName = it.`value`;
-
- UPDATE item i
- JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id
- LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 5
- LEFT JOIN tag t ON t.id = it.tagFk
- SET tag5 = t.name, value5 = it.`value`;
-
- UPDATE item i
- JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id
- LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 6
- LEFT JOIN tag t ON t.id = it.tagFk
- SET tag6 = t.name, value6 = it.`value`;
-
- UPDATE item i
- JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id
- LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 7
- LEFT JOIN tag t ON t.id = it.tagFk
- SET i.tag7 = t.name, i.value7 = it.`value`;
-
- UPDATE item i
- JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id
- LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 8
- LEFT JOIN tag t ON t.id = it.tagFk
- SET tag8 = t.name, value8 = it.`value`;
-
- UPDATE item i
- JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id
- LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 9
- LEFT JOIN tag t ON t.id = it.tagFk
- SET tag9 = t.name, value9 = it.`value`;
-
- UPDATE item i
- JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id
- LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 10
- LEFT JOIN tag t ON t.id = it.tagFk
- SET tag10 = t.name, value10 = it.`value`;
-
- -- Al insertar el tag color se modifica también el antiguo campo color
- UPDATE item i
- JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id
- JOIN tag t ON t.overwrite = 'inkFk'
- JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = t.id
- JOIN ink ON ink.`name` = it.`value`
- SET i.inkFk = ink.id;
-
- -- Al insertar el tag origen se modifica también en la tabla item
- UPDATE item i
- JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id
- JOIN tag t ON t.overwrite = 'originFk'
- JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = t.id
- JOIN origin o ON o.`name` = it.`value`
- SET i.originFk = o.id;
-
- -- Al insertar el tag medida se modifica también en la tabla item
- UPDATE item i
- JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id
- JOIN tag t ON t.overwrite = 'size'
- JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = t.id
- SET i.size = it.`value`;
-
- -- Al insertar el tag productor se modifica también en la tabla item
- UPDATE item i
- JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id
- JOIN tag t ON t.overwrite = 'producerFk'
- JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = t.id
- JOIN producer p ON p.`name` = it.`value`
- SET i.producerFk = p.id;
-
- -- Al insertar el tag tallos se modifica también en la tabla item
- UPDATE item i
- JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id
- JOIN tag t ON t.overwrite = 'stems'
- JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = t.id
- SET i.stems = it.`value`;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.itemToRefresh;
-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 DROP PROCEDURE IF EXISTS `item_saveReference` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -69568,8 +60417,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_saveReference`(vBarcode VARCHAR(22), vReference VARCHAR(150))
BEGIN
@@ -69593,70 +60440,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `item_setCompression__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `item_setCompression__`()
-BEGIN
- /**
- * Actualiza la compression de los articulos con un packing.hasCompressionVariations = TRUE
- *
- */
- DECLARE done INT DEFAULT FALSE;
- DECLARE vBuyFk INT;
- DECLARE cur1 CURSOR FOR SELECT b.id
- FROM vn.item i
- JOIN edi.supplyResponse ii ON i.supplyResponseFk = ii.ID
- JOIN vn.packaging p ON p.id = ii.EmbalageCode AND hasCompressionVariations
- JOIN vn.itemTag diameter ON diameter.itemFk = i.id
- JOIN vn.tag tDiameter ON tDiameter.overwrite = 'diameter' AND tDiameter.id = diameter.tagFk
- JOIN vn.itemTag size ON size.itemFk = i.id
- JOIN vn.tag tSize ON tSize.overwrite = 'size' AND tSize.id = size.tagFk
- JOIN vn.buy b ON b.itemFk = i.id;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
-
- UPDATE vn.item i
- JOIN edi.supplyResponse ii ON i.supplyResponseFk = ii.ID
- JOIN vn.packaging p ON p.id = ii.EmbalageCode AND hasCompressionVariations
- JOIN vn.itemTag diameter ON diameter.itemFk = i.id
- JOIN vn.tag tDiameter ON tDiameter.overwrite = 'diameter' AND tDiameter.id = diameter.tagFk
- JOIN vn.itemTag size ON size.itemFk = i.id
- JOIN vn.tag tSize ON tSize.overwrite = 'size' AND tSize.id = size.tagFk
- SET i.`compression` = (PI() * POW(diameter.`value`/ 2, 2) * size.`value`)
- /
- ((p.width * p.depth * p.height) / ii.NumberOfItemsPerCask)
- WHERE (PI() * POW(diameter.`value`/ 2, 2) * size.`value`)
- /
- ((p.width * p.depth * p.height) / ii.NumberOfItemsPerCask) <> 0;
-
- OPEN cur1;
-
- read_loop: LOOP
- SET done = FALSE;
- FETCH cur1 INTO vBuyFk;
- IF done THEN
- LEAVE read_loop;
- END IF;
-
- call vn.buy_afterUpsert(vBuyFk);
-
- END LOOP;
-
- CLOSE cur1;
-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 DROP PROCEDURE IF EXISTS `item_setGeneric` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -69664,8 +60449,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_setGeneric`(vSelf INT)
BEGIN
@@ -69675,7 +60458,7 @@ BEGIN
* @param vSelf identificador de vn.item
*/
DECLARE vGenericFk INT;
-
+
SELECT itemFk INTO vGenericFk
FROM (
SELECT itemFk, (sum(matches) = maxMatches) `match`
@@ -69715,6 +60498,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `item_updatePackingShelve` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -69722,8 +60507,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_updatePackingShelve`(vSelf INT, vPacking INT)
BEGIN
@@ -69745,6 +60528,8 @@ DELIMITER ;
/*!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 `item_updatePackingType` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -69752,8 +60537,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_updatePackingType`(vItem INT, vItemPackingTypeFk VARCHAR(1))
BEGIN
@@ -69771,6 +60554,8 @@ DELIMITER ;
/*!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 `item_ValuateInventory` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -69778,8 +60563,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_ValuateInventory`(IN vDated DATE, IN vIsDetailed BOOLEAN)
BEGIN
@@ -69855,7 +60638,7 @@ BEGIN
JOIN itemType t ON t.id = i.typeFk
JOIN warehouse w ON w.id = tr.warehouseInFk
WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd
- AND IF(tr.landed = CURDATE(), tr.isReceived, trUE)
+ AND IF(tr.landed = util.VN_CURDATE(), tr.isReceived, trUE)
AND NOT e.isRaid
AND w.valuatedInventory
AND t.isInventory
@@ -69888,7 +60671,7 @@ BEGIN
AND it.isInventory
ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + s.quantity * IF(vHasNotInventory,1,-1);
- IF vDated = CURDATE() THEN -- volver a poner lo que esta aun en las estanterias
+ IF vDated = util.VN_CURDATE() THEN -- volver a poner lo que esta aun en las estanterias
INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen)
SELECT w.id, s.itemFk, s.quantity * IF(vHasNotInventory,0,1), w.`name`
@@ -69976,201 +60759,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `item_ValuateInventory__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `item_ValuateInventory__`(IN vDated DATE, IN vIsDetailed BOOLEAN)
-BEGIN
-
- DECLARE vInventoried DATE;
- DECLARE vHasNotInventory BOOLEAN DEFAULT 0;
- DECLARE vInventoried2 DATE;
- DECLARE vDateDayEnd DATETIME;
-
- SET vDateDayEnd = util.dayEnd(vDated);
- SELECT landed INTO vInventoried
- FROM travel tr
- JOIN entry E ON E.travelFk = tr.id
- WHERE landed <= vDateDayEnd
- AND E.supplierFk = 4
- ORDER BY landed DESC
- LIMIT 1;
-
- SET vHasNotInventory = IF (vInventoried is null, TRUE, FALSE);
-
- IF vHasNotInventory THEN
-
- SELECT landed INTO vInventoried2
- FROM travel tr
- JOIN entry E ON E.travelFk = tr.id
- WHERE landed >= vDated
- AND E.supplierFk = 4
- ORDER BY landed ASC
- LIMIT 1;
-
- SET vInventoried = TIMESTAMPADD(DAY,1,vDated);
- SET vDateDayEnd = vInventoried2;
-
- END IF;
-
- DROP TEMPORARY TABLE IF EXISTS inv;
-
- CREATE TEMPORARY TABLE inv
- (warehouseFk SMALLINT,
- Id_Article BIGINT,
- cantidad INT,
- coste DOUBLE DEFAULT 0,
- total DOUBLE DEFAULT 0,
- Almacen VARCHAR(20),
- PRIMARY KEY (Almacen, Id_Article) USING HASH)
- ENGINE = MEMORY;
-
- IF vHasNotInventory = TRUE THEN
-
- INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen)
- SELECT tr.warehouseInFk, b.itemFk, SUM(b.quantity), w.`name`
- FROM buy b
- JOIN item i ON i.id = b.itemFk
- JOIN entry e ON e.id = b.entryFk
- JOIN travel tr ON tr.id = e.travelFk
- JOIN itemType t ON t.id = i.typeFk
- JOIN warehouse w ON w.id = warehouseInFk
- WHERE landed = vDateDayEnd
- AND e.supplierFk = 4
- AND w.valuatedInventory
- AND t.isInventory
- GROUP BY tr.warehouseInFk, b.itemFk;
-
- END IF;
-
- INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen)
- SELECT tr.warehouseInFk, b.itemFk, b.quantity * IF(vHasNotInventory,-1,1), w.`name`
- FROM buy b
- JOIN item i ON i.id = b.itemFk
- JOIN entry e ON e.id = b.entryFk
- JOIN travel tr ON tr.id = e.travelFk
- JOIN itemType t ON t.id = i.typeFk
- JOIN warehouse w ON w.id = tr.warehouseInFk
- WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd
- AND IF(tr.landed = CURDATE(), tr.isReceived, trUE)
- AND NOT e.isRaid
- AND w.valuatedInventory
- AND t.isInventory
- ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + (b.quantity * IF(vHasNotInventory,-1,1));
-
- INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen)
- SELECT tr.warehouseOutFk, b.itemFk, b.quantity * IF(vHasNotInventory,1,-1), w.`name`
- FROM buy b
- JOIN item i ON i.id = b.itemFk
- JOIN entry e ON e.id = b.entryFk
- JOIN travel tr ON tr.id = e.travelFk
- JOIN itemType t ON t.id = i.typeFk
- JOIN warehouse w ON w.id = tr.warehouseOutFk
- WHERE tr.shipped BETWEEN vInventoried AND vDateDayEnd
- AND NOT e.isRaid
- AND w.valuatedInventory
- AND t.isInventory
- ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + (b.quantity * IF(vHasNotInventory,1,-1));
-
- INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen)
- SELECT w.id, s.itemFk, s.quantity * IF(vHasNotInventory,1,-1), w.`name`
- FROM sale s
- JOIN ticket t ON t.id = s.ticketFk
- JOIN `client` c ON c.id = t.clientFk
- JOIN item i ON i.id = s.itemFk
- JOIN itemType it ON it.id = i.typeFk
- JOIN warehouse w ON w.id = t.warehouseFk
- WHERE t.shipped BETWEEN vInventoried AND vDateDayEnd
- AND w.valuatedInventory
- AND it.isInventory
- ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + s.quantity * IF(vHasNotInventory,1,-1);
-
- IF vDated = CURDATE() THEN -- volver a poner lo que esta aun en las estanterias
-
- INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen)
- SELECT w.id, s.itemFk, s.quantity * IF(vHasNotInventory,0,1), w.`name`
- FROM sale s
- JOIN ticket t ON t.id = s.ticketFk
- JOIN `client` c ON c.id = t.clientFk
- JOIN item i ON i.id = s.itemFk
- JOIN itemType it ON it.id = i.typeFk
- JOIN warehouse w ON w.id = t.warehouseFk
- WHERE t.shipped BETWEEN vDated AND vDateDayEnd
- AND (s.isPicked <> 0 or t.isLabeled <> 0 )
- AND w.valuatedInventory
- AND it.isInventory
- ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + s.quantity * IF(vHasNotInventory,0,1);
-
- END IF;
-
- -- Mercancia en transito
- INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen)
- SELECT tr.warehouseInFk, b.itemFk, b.quantity, CONCAT(wOut.`name`,' - ', wIn.`name`)
- FROM buy b
- JOIN item i ON i.id = b.itemFk
- JOIN entry e ON e.id = b.entryFk
- JOIN travel tr ON tr.id = e.travelFk
- JOIN itemType t ON t.id = i.typeFk
- JOIN warehouse wIn ON wIn.id = tr.warehouseInFk
- JOIN warehouse wOut ON wOut.id = tr.warehouseOutFk
- WHERE vDated >= tr.shipped AND vDated < tr.landed
- AND NOT isRaid
- AND wIn.valuatedInventory
- AND t.isInventory
- AND e.isConfirmed
- ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + (b.quantity);
-
- CALL vn.buyUltimate(NULL,vDateDayEnd);
-
- UPDATE inv i
- JOIN tmp.buyUltimate bu ON i.warehouseFk = bu.warehouseFk AND i.Id_Article = bu.itemFk
- JOIN buy b ON b.id = bu.buyFk
- SET total = i.cantidad * (ifnull(b.buyingValue,0) + IFNULL(b.packageValue,0) + IFNULL(b.freightValue,0) + IFNULL(b.comissionValue,0)),
- coste = ifnull(b.buyingValue,0) + IFNULL(b.packageValue,0) + IFNULL(b.freightValue,0) + IFNULL(b.comissionValue,0)
- WHERE i.cantidad <> 0;
-
- DELETE FROM inv WHERE Cantidad IS NULL or Cantidad = 0;
-
- IF vIsDetailed THEN
-
- SELECT inv.warehouseFk, i.id, i.name, i.size, inv.Cantidad, tp.code,
- tp.categoryFk, inv.coste, cast(inv.total as decimal(10,2)) total,Almacen
- FROM inv
- JOIN warehouse w on w.id = warehouseFk
- JOIN item i ON i.id = inv.Id_Article
- JOIN itemType tp ON tp.id = i.typeFk
- WHERE w.valuatedInventory
- and inv.total > 0
- order by inv.total desc;
-
- ELSE
-
- SELECT i.Almacen, ic.name as Reino, cast(i.total as decimal(10,2)) as Euros, w.code as Comprador,it.id
- FROM inv i
- JOIN warehouse wh on wh.id = warehouseFk
- JOIN item it ON it.id = i.Id_Article
- JOIN itemType itp ON itp.id = it.typeFk
- LEFT JOIN worker w ON w.id = itp.workerFk
- JOIN itemCategory ic ON ic.id = itp.categoryFk
- WHERE wh.valuatedInventory
- AND i.total > 0;
-
- END IF;
- DROP TEMPORARY TABLE tmp.buyUltimate;
- DROP TEMPORARY TABLE inv;
-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 DROP PROCEDURE IF EXISTS `ledger_doCompensation` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70178,8 +60768,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ledger_doCompensation`(vDated DATE, vCompensationAccount VARCHAR(10) , vBankFk VARCHAR(10), vConcept VARCHAR(255), vAmount DECIMAL(10,2), vCompanyFk INT, vOriginalAccount VARCHAR(10))
BEGIN
@@ -70262,6 +60850,8 @@ DELIMITER ;
/*!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 `ledger_next` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70269,8 +60859,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ledger_next`(OUT vNewBookEntry INT)
BEGIN
@@ -70284,6 +60872,8 @@ DELIMITER ;
/*!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 `logAdd` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70291,8 +60881,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `logAdd`(vOriginFk INT, vActionCode VARCHAR(45), vEntity VARCHAR(45), vDescription TEXT)
BEGIN
@@ -70305,13 +60893,15 @@ BEGIN
* @param descripcion Descripción de la acción realizada por el usuario
*/
- CALL logAddWithUser(vOriginFk, account.userGetId(), vActionCode, vEntity, vDescription);
+ CALL logAddWithUser(vOriginFk, account.myUser_getId(), vActionCode, vEntity, vDescription);
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 `logAddWithUser` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70319,8 +60909,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `logAddWithUser`(vOriginFk INT, vUserId INT, vActionCode VARCHAR(45), vEntity VARCHAR(45), vDescription TEXT)
BEGIN
@@ -70353,6 +60941,8 @@ DELIMITER ;
/*!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 `logShow` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70360,8 +60950,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `logShow`(vOriginFk INT, vEntity VARCHAR(45))
BEGIN
@@ -70389,6 +60977,8 @@ DELIMITER ;
/*!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 `lungSize_generator` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70396,8 +60986,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `lungSize_generator`(vDate DATE)
BEGIN
@@ -70450,6 +61038,8 @@ DELIMITER ;
/*!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 `machineWorker_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70457,8 +61047,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `machineWorker_add`(vPlate VARCHAR(10), vWorkerFk INT)
BEGIN
@@ -70471,7 +61059,7 @@ BEGIN
*/
UPDATE vn.machineWorker mw
JOIN vn.machine m ON m.id = mw.machineFk
- SET mw.outTimed = NOW()
+ SET mw.outTimed = util.VN_NOW()
WHERE (mw.workerFk = vWorkerFk OR m.plate = vPlate)
AND ISNULL(mw.outTimed);
@@ -70485,6 +61073,8 @@ DELIMITER ;
/*!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 `machineWorker_getHistorical` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70492,8 +61082,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `machineWorker_getHistorical`(vPlate VARCHAR(20), vWorkerFk INT)
BEGIN
@@ -70519,6 +61107,8 @@ DELIMITER ;
/*!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 `machineWorker_update` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70526,8 +61116,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `machineWorker_update`(vPlate VARCHAR(10), vWorkerFk INT)
BEGIN
@@ -70553,12 +61141,12 @@ BEGIN
IF (SELECT COUNT(*)
FROM machineWorker m
WHERE m.workerFk = vWorkerFk
- AND m.inTimed >= TIMESTAMPADD(HOUR , -vMaxHours, NOW()) AND ISNULL(m.outTimed)) THEN
+ AND m.inTimed >= TIMESTAMPADD(HOUR , -vMaxHours, util.VN_NOW()) AND ISNULL(m.outTimed)) THEN
UPDATE machineWorker m
SET m.outTimed = CURRENT_TIMESTAMP()
WHERE m.workerFk = vWorkerFk
- AND m.inTimed >= TIMESTAMPADD(HOUR , -vMaxHours, NOW())
+ AND m.inTimed >= TIMESTAMPADD(HOUR , -vMaxHours, util.VN_NOW())
AND ISNULL(m.outTimed)
AND m.machineFk = vMachineFk;
@@ -70570,6 +61158,8 @@ DELIMITER ;
/*!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 `machine_getWorkerPlate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70577,8 +61167,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `machine_getWorkerPlate`(vWorkerFk INT)
BEGIN
@@ -70593,7 +61181,7 @@ BEGIN
SELECT m.plate
FROM machine m
JOIN machineWorker mw ON mw.machineFk = m.id
- WHERE mw.inTimed >= TIMESTAMPADD(HOUR , -12,NOW())
+ WHERE mw.inTimed >= TIMESTAMPADD(HOUR , -12,util.VN_NOW())
AND ISNULL(mw.outTimed)
AND mw.workerFk = vWorkerFk;
@@ -70603,6 +61191,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `mail_insert` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70610,8 +61200,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `mail_insert`(
vReceiver VARCHAR(255),
@@ -70632,7 +61220,7 @@ BEGIN
SELECT COUNT(*) INTO vIsRepeated
FROM vn.mail
- WHERE creationDate >= CURDATE()
+ WHERE creationDate >= util.VN_CURDATE()
AND `receiver` = vReceiver
AND `replyTo` = vReplyTo
AND `subject` = vSubject
@@ -70654,6 +61242,8 @@ DELIMITER ;
/*!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 `makeNewItem` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70661,8 +61251,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `makeNewItem`()
BEGIN
@@ -70683,6 +61271,8 @@ DELIMITER ;
/*!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 `makePCSGraf` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70690,8 +61280,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `makePCSGraf`(vDated DATE)
BEGIN
@@ -70735,15 +61323,15 @@ DELIMITER ;
/*!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 `manaSpellersRequery` */;
/*!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 = utf8 */ ;
-/*!50003 SET character_set_results = utf8 */ ;
-/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `manaSpellersRequery`(vWorkerFk INTEGER)
BEGIN
@@ -70754,17 +61342,17 @@ BEGIN
*/
DECLARE vWorkerIsExcluded BOOLEAN;
DECLARE vFromDated DATE;
- DECLARE vToDated DATE DEFAULT TIMESTAMPADD(DAY,1,CURDATE());
+ DECLARE vToDated DATE DEFAULT TIMESTAMPADD(DAY,1,util.VN_CURDATE());
DECLARE vMana INT;
- DECLARE vAutoMana INT;
- DECLARE vClaimMana INT;
- DECLARE vManaBank INT;
- DECLARE vManaGreugeType INT;
-
- SELECT COUNT(*) INTO vWorkerIsExcluded
+ DECLARE vAutoMana INT;
+ DECLARE vClaimMana INT;
+ DECLARE vManaBank INT;
+ DECLARE vManaGreugeType INT;
+
+ SELECT COUNT(*) INTO vWorkerIsExcluded
FROM workerManaExcluded
WHERE workerFk = vWorkerFk;
-
+
IF NOT vWorkerIsExcluded THEN
SELECT id INTO vMana
FROM `component` WHERE code = 'mana';
@@ -70783,8 +61371,8 @@ BEGIN
SELECT max(dated) INTO vFromDated
FROM clientManaCache;
-
- REPLACE workerMana (workerFk, amount)
+
+ REPLACE workerMana (workerFk, amount)
SELECT vWorkerFk, sum(mana) FROM
(
SELECT s.quantity * sc.value as mana
@@ -70806,7 +61394,7 @@ BEGIN
FROM greuge g
JOIN client c ON c.id = g.clientFk
WHERE c.salesPersonFk = vWorkerFk AND g.greugeTypeFk = vManaGreugeType
- AND g.shipped > vFromDated and g.shipped < CURDATE()
+ AND g.shipped > vFromDated and g.shipped < util.VN_CURDATE()
UNION ALL
SELECT cc.mana
FROM clientManaCache cc
@@ -70820,52 +61408,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `mergeTicketUnattended` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `mergeTicketUnattended`(IN vMainTicket INT(11), IN hasSameAgency BOOLEAN)
-BEGIN
-
- DECLARE isBilled BOOLEAN;
- DECLARE arrayTickets VARCHAR(255);
-
- SELECT Factura IS NOT NULL INTO isBilled FROM vn2008.Tickets WHERE Id_Ticket = vMainTicket;
-
- IF NOT isBilled THEN
-
- SELECT GROUP_CONCAT(distinct T.Id_Ticket) INTO arrayTickets
- FROM vn2008.Tickets T LEFT JOIN vn.ticketState ts ON T.Id_Ticket = ts.ticket
- JOIN vn2008.Tickets ticketOriginal ON ticketOriginal.Id_Ticket = vMainTicket
- AND T.empresa_id = ticketOriginal.empresa_id
- AND T.Id_Consigna = ticketOriginal.Id_Consigna
- AND DATE(T.Fecha) = DATE(ticketOriginal.Fecha)
- AND T.warehouse_id = ticketOriginal.warehouse_id
- AND IF(hasSameAgency <> 0,T.Id_Agencia = ticketOriginal.Id_Agencia,TRUE)
- LEFT JOIN vn.ticketState tsOriginal ON ticketOriginal.Id_Ticket = tsOriginal.ticket
- WHERE ts.alertLevel < 3
- AND T.Factura IS NULL
- AND T.Anotadoencaja = FALSE
- AND T.Id_Ticket <> vMainTicket
- AND ts.alertLevel = tsOriginal.alertLevel;
-
- CALL mergeTicketWithArray(vMainTicket,arrayTickets);
-
- 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 DROP PROCEDURE IF EXISTS `mergeTicketWithArray` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70873,8 +61417,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `mergeTicketWithArray`(IN vMainTicket INT(11), IN arrayTickets VARCHAR(50))
BEGIN
@@ -70890,7 +61432,7 @@ BEGIN
IF NOT isBilled THEN
- SELECT Id_Trabajador INTO worker from vn2008.Trabajadores where user_id = account.userGetId();
+ SELECT Id_Trabajador INTO worker from vn2008.Trabajadores where user_id = account.myUser_getId();
DROP TEMPORARY TABLE IF EXISTS vn2008.Tickets_to_fusion;
@@ -70967,6 +61509,8 @@ DELIMITER ;
/*!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 `mysqlConnectionsSorter_kill` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -70974,8 +61518,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `mysqlConnectionsSorter_kill`()
BEGIN
@@ -71017,6 +61559,8 @@ DELIMITER ;
/*!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 `mysqlPreparedCount_check` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71024,8 +61568,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `mysqlPreparedCount_check`()
BEGIN
@@ -71051,188 +61593,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `nestAdd__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `nestAdd__`(IN `vScheme` VARCHAR(45), IN `vTable` VARCHAR(45), IN `vParentFk` INT, IN `vChild` VARCHAR(100))
-BEGIN
- DECLARE vSql TEXT;
- DECLARE vTableClone VARCHAR(45);
-
- SET vTableClone = CONCAT(vTable, 'Clone');
-
- CALL util.exec(CONCAT('DROP TEMPORARY TABLE IF EXISTS tmp.', vTableClone));
- CALL util.exec(CONCAT(
- 'CREATE TEMPORARY TABLE tmp.', vTableClone,
- ' ENGINE = MEMORY'
- ' SELECT * FROM ', vScheme, '.', vTable
- ));
-
- -- Check parent childs
- SET vSql = sql_printf('
- SELECT COUNT(c.id) INTO @childs
- FROM %t.%t p
- LEFT JOIN %t.%t c ON c.lft BETWEEN p.lft AND p.rgt AND c.id != %v
- WHERE p.id = %v',
- vScheme, vTable, 'tmp', vTableClone, vParentFk, vParentFk);
- SET @qrySql := vSql;
-
- PREPARE stmt FROM @qrySql;
- EXECUTE stmt;
- DEALLOCATE PREPARE stmt;
-
- -- Select left from last child
- IF @childs = 0 THEN
- SET vSql = sql_printf('SELECT lft INTO @vLeft FROM %t.%t WHERE id = %v', vScheme, vTable, vParentFk);
- SET @qrySql := vSql;
- ELSE
- SET vSql = sql_printf('
- SELECT c.rgt INTO @vLeft
- FROM %t.%t p
- JOIN %t.%t c ON c.lft BETWEEN p.lft AND p.rgt
- WHERE p.id = %v
- ORDER BY c.lft
- DESC LIMIT 1',
- vScheme, vTable, 'tmp', vTableClone, vParentFk);
- SET @qrySql := vSql;
- END IF;
-
- PREPARE stmt FROM @qrySql;
- EXECUTE stmt;
- DEALLOCATE PREPARE stmt;
-
- -- Update right
- SET vSql = sql_printf('UPDATE %t.%t SET rgt = rgt + 2 WHERE rgt > %v ORDER BY rgt DESC', vScheme, vTable, @vLeft);
- SET @qrySql := vSql;
-
- PREPARE stmt FROM @qrySql;
- EXECUTE stmt;
- DEALLOCATE PREPARE stmt;
-
- SET vSql = sql_printf('UPDATE %t.%t SET lft = lft + 2 WHERE lft > %v ORDER BY lft DESC', vScheme, vTable, @vLeft);
- SET @qrySql := vSql;
-
- PREPARE stmt FROM @qrySql;
- EXECUTE stmt;
- DEALLOCATE PREPARE stmt;
-
- -- Escape character
- SET vChild = REPLACE(vChild, "'", "\\'");
-
- -- Add child
- SET vSql = sql_printf('INSERT INTO %t.%t (name, lft, rgt) VALUES (%v, %v, %v)', vScheme, vTable, vChild, @vLeft + 1, @vLeft + 2);
- SET @qrySql := vSql;
-
- PREPARE stmt FROM @qrySql;
- EXECUTE stmt;
- DEALLOCATE PREPARE stmt;
-
- CALL util.exec(CONCAT('DROP TEMPORARY TABLE tmp.', vTableClone));
-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 DROP PROCEDURE IF EXISTS `nestLeave__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `nestLeave__`(vScheme VARCHAR(45), vTable VARCHAR(45), vParentFk INT)
-BEGIN
- DROP TEMPORARY TABLE IF EXISTS tmp.tree;
-
- CALL util.exec(CONCAT(
- 'CREATE TEMPORARY TABLE tmp.tree ',
- 'SELECT
- node.id,
- node.name,
- node.lft,
- node.rgt,
- node.depth,
- node.sons
- FROM ',
- vScheme, '.', vTable, ' AS node, ',
- vScheme, '.', vTable, ' AS parent ',
- 'WHERE
- node.lft BETWEEN parent.lft AND parent.rgt
- AND node.depth = parent.depth + 1
- AND parent.id = ', vParentFk, ' '
- 'GROUP BY node.id
- ORDER BY node.lft'));
-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 DROP PROCEDURE IF EXISTS `nestTree__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `nestTree__`(
- vSourceSchema VARCHAR(45),
- vSourceTable VARCHAR(45),
- vDestinationSchema VARCHAR(45),
- vDestinationTable VARCHAR(45))
-BEGIN
- DECLARE vTableClone VARCHAR(45);
-
- SET vTableClone = CONCAT(vSourceTable, 'Clone');
-
- CALL util.exec(CONCAT('DROP TEMPORARY TABLE IF EXISTS tmp.', vTableClone));
- CALL util.exec(CONCAT(
- 'CREATE TEMPORARY TABLE tmp.', vTableClone,
- ' ENGINE = MEMORY',
- ' SELECT * FROM ', vSourceSchema, '.', vSourceTable
- ));
-
- CALL util.exec(CONCAT(
- 'TRUNCATE TABLE ', vDestinationSchema, '.', vDestinationTable));
- CALL util.exec(CONCAT(
- 'INSERT INTO ', vDestinationSchema, '.', vDestinationTable,
- '(id, name, lft, rgt, depth, sons)',
- 'SELECT
- node.id,
- node.name,
- node.lft,
- node.rgt,
- COUNT(parent.id) - 1 depth,
- CAST((node.rgt - node.lft - 1) / 2 as DECIMAL) as sons
- FROM ',
- vSourceSchema, '.', vSourceTable, ' AS node,',
- 'tmp.', vTableClone, ' AS parent ',
- 'WHERE node.lft
- BETWEEN parent.lft AND parent.rgt
- GROUP BY node.id
- ORDER BY node.lft'));
-
- CALL util.exec(CONCAT('DROP TEMPORARY TABLE tmp.', vTableClone));
-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 DROP PROCEDURE IF EXISTS `nextShelvingCodeMake` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71240,8 +61602,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `nextShelvingCodeMake`()
BEGIN
@@ -71287,6 +61647,8 @@ DELIMITER ;
/*!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 `observationAdd` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71294,8 +61656,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `observationAdd`(vOriginFk INT, vTableCode VARCHAR(45), vDescription TEXT)
BEGIN
@@ -71316,7 +61676,7 @@ BEGIN
SET @qryLog := CONCAT(
'INSERT INTO ', vTableName, ' (originFk, userFk, description)',
- ' VALUES (', vOriginFk, ', ', account.userGetId(), ', "', vDescription, '")'
+ ' VALUES (', vOriginFk, ', ', account.myUser_getId(), ', "', vDescription, '")'
);
PREPARE stmt FROM @qryLog;
@@ -71328,6 +61688,8 @@ DELIMITER ;
/*!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 `orderCreate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71335,8 +61697,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `orderCreate`(
vLanded DATE,
@@ -71368,6 +61728,8 @@ DELIMITER ;
/*!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 `orderDelete` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71375,8 +61737,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `orderDelete`(IN vId INT)
BEGIN
@@ -71389,6 +61749,8 @@ DELIMITER ;
/*!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 `orderListCreate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71396,8 +61758,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `orderListCreate`(
vLanded DATE,
@@ -71416,6 +61776,8 @@ DELIMITER ;
/*!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 `orderListVolume` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71423,8 +61785,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `orderListVolume`(IN vOrderId INT)
BEGIN
@@ -71445,6 +61805,8 @@ DELIMITER ;
/*!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 `packageInvoicing` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71452,8 +61814,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `packageInvoicing`(
IN vClient INT,
@@ -71526,7 +61886,7 @@ BEGIN
NULL,
NULL,
vDateEnd,
- account.userGetId(),
+ account.myUser_getId(),
TRUE,
vNewTicket);
@@ -71579,6 +61939,8 @@ DELIMITER ;
/*!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 `packingListPrinted` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71586,8 +61948,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `packingListPrinted`(ticketFk INT)
BEGIN
@@ -71605,6 +61965,8 @@ DELIMITER ;
/*!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 `packingListSwitch` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71612,8 +61974,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `packingListSwitch`(saleFk INT)
BEGIN
@@ -71638,6 +61998,8 @@ DELIMITER ;
/*!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 `parking_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71645,8 +62007,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `parking_add`(vFromColumn INT, vToColumn INT, vFromRow INT, vToRow INT, vSectorFk INT, vIsLetterMode BOOLEAN)
BEGIN
@@ -71692,60 +62052,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `parking_add__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `parking_add__`(vFromColumn INT, vToColumn INT, vFromRow INT, vToRow INT, vSectorFk INT, vIsLetterMode BOOLEAN)
-BEGIN
-
- DECLARE vColumn INT;
- DECLARE vRow INT;
- DECLARE vLetters VARCHAR(26) DEFAULT 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
- DECLARE vMaxId INT;
- DECLARE vCode VARCHAR(8);
-
- SET vColumn = vFromColumn;
- SET vRow = vFromRow;
- SET vCode = CONCAT(LPAD(vColumn,3,'0'),'-',IF(vIsLetterMode, MID(vLetters, vRow, 1), LPAD(vRow, 2,'0')));
-
- SELECT MAX(id) INTO vMaxId
- FROM vn.parking;
-
- WHILE vColumn <= vToColumn DO
-
- WHILE vRow <= vToRow DO
-
- INSERT IGNORE INTO vn.parking(`column`, `row`, sectorFk, `code`, pickingOrder)
- VALUES (vColumn, vRow, vSectorFk, vCode, vColumn * 100 + vRow )
- ON DUPLICATE KEY UPDATE `code` = vCode;
-
- SET vRow = vRow + 1;
- SET vCode = CONCAT(LPAD(vColumn,3,'0'),'-',IF(vIsLetterMode, MID(vLetters, vRow, 1), LPAD(vRow, 2,'0')));
-
- END WHILE;
-
- SET vRow = vFromRow;
- SET vColumn = vColumn + 1;
-
- SET vCode = CONCAT(LPAD(vColumn,3,'0'),'-',IF(vIsLetterMode, MID(vLetters, vRow, 1), LPAD(vRow, 2,'0')));
-
- END WHILE;
-
- SELECT * FROM vn.parking WHERE `column` BETWEEN vFromColumn AND vToColumn;
-
-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 DROP PROCEDURE IF EXISTS `parking_algemesi` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71753,8 +62061,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `parking_algemesi`(vFromRow INT, vToRow INT, vSectorFk INT, vLetter VARCHAR(1), vPickingOrder INT, vTrolleysByLine INT)
BEGIN
@@ -71821,6 +62127,8 @@ DELIMITER ;
/*!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 `parking_new` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71828,8 +62136,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `parking_new`(vStart INT, vEnd INT, vSectorFk INT)
BEGIN
@@ -71866,51 +62172,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `parking_new__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `parking_new__`(vStart INT, vEnd INT, vSectorFk INT)
-BEGIN
-
- DECLARE vRow INT;
- DECLARE vColumn INT;
- DECLARE vLetters VARCHAR(200);
- DECLARE vLettersLength INT;
-
- SET vColumn = vStart;
- SET vRow = 1;
- SET vLetters = 'ABCDEF';
- SET vLettersLength = LENGTH(vLetters);
-
- WHILE vColumn <= vEnd DO
-
- REPLACE vn.parking(`column`, `row`, `code`, sectorFk)
- VALUES(vColumn, vRow, CONCAT(vColumn,MID(vLetters,vRow,1)), vSectorFk);
-
- SET vRow = vRow + 1;
-
- IF vRow > vLettersLength THEN
-
- SET vRow = 1;
- SET vColumn = vColumn + 1;
-
- END IF;
-
- END WHILE;
-
-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 DROP PROCEDURE IF EXISTS `parking_setOrder` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71918,8 +62181,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `parking_setOrder`(vWarehouseFk INT)
BEGIN
@@ -71951,81 +62212,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `payRoll__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `payRoll__`(IN vFromDated DATE, IN vToDated DATE, IN vFromPaid DATE, IN vToPaid DATE, IN vPartTime BOOL)
-BEGIN
-
- SET @userFk := 0;
-
- SELECT CONCAT(w.lastName,', ',w.firstname) AS Trabajador,
- CAST(Sum((wj.total + wj.permission + wj.lunch)* wj.priceOrdinaryHour + wj.hollyday * wj.priceHollydayHour
- + wj.nocturn * wj.priceNocturnHour
- + wj.extra * wj.priceExtraHour) AS DECIMAL(10,2)) AS salario,
- CAST(Sum(wj.permission) AS DECIMAL(10,2)) AS permission,
- CAST(Sum(wj.total) AS DECIMAL(10,2)) AS total,
- CAST(Sum(wj.nocturn) AS DECIMAL(10,2)) AS nocturn,
- CAST(Sum(wj.hollyday) AS DECIMAL(10,2)) AS hollyday,
- CAST(Sum(wj.lunch) AS DECIMAL(10,2)) AS lunch,
- CAST(Sum(wj.extra) AS DECIMAL(10,2)) AS extra,
- CAST(Sum(wj.contractJourney) AS DECIMAL(10,2)) AS contractJourney,
- d.name AS departamento,
- CAST(Sum((wj.contractJourney + wj.permission) * wj.priceOrdinaryHour) AS DECIMAL(10,2)) AS teorico,
- CAST(Sum((wj.lunch + wj.permission + wj.total) * wj.priceordinaryhour) AS DECIMAL(10,2)) AS practico,
- CAST(Sum(wj.nocturn * wj.pricenocturnhour) AS DECIMAL(10,2)) AS nocturno,
- CAST(Sum(wj.hollyday * wj.priceHollydayHour) AS DECIMAL(10,2)) AS festivos,
- CAST(Sum(wj.extra * wj.priceextrahour) AS DECIMAL(10,2)) AS extras,
- MAX(wj.businessFk) as businessFk,
- IF(sub.workerFk IS NULL, FALSE, TRUE) isLastBusiness,
- Min(b.date_start) AS fromDated,
- Max(b.date_end) AS toDated,
- blp.importepactado,
- bl.porhoras,
- IF(wj.userFk != @userFk, CAST(IFNULL(a.Anticipos,0) AS DECIMAL(10,2)), 0) AS Anticipos,
- IF(wj.userFk != @userFk, CAST(IFNULL(se.SaldoEuros,0) AS DECIMAL(10,2)), 0) AS SaldoEuros,
- @userFk := wj.userFk as userFk
- FROM worker w
- JOIN workerJourney wj ON w.id = wj.userFk
- JOIN postgresql.business b ON b.business_id = wj.businessFk
- JOIN postgresql.business_labour bl ON bl.business_id = b.business_id
- JOIN postgresql.calendar_labour_type cl ON cl.calendar_labour_type_id = bl.calendar_labour_type_id
- JOIN postgresql.business_labour_payroll blp ON blp.business_id = b.business_id
- JOIN department d ON bl.department_id = d.id
- LEFT JOIN (SELECT pe.id_trabajador, SUM(debe) Anticipos
- FROM postgresql.income_employee ie
- JOIN postgresql.person pe ON ie.person_id = pe.person_id
- WHERE odbc_date BETWEEN vFromPaid AND vToPaid
- AND id_incomeType = 14 -- Salario
- GROUP BY pe.id_trabajador
- ) a ON a.id_trabajador = w.id
- LEFT JOIN (SELECT pe.id_trabajador, SUM(debe) - SUM(haber) as SaldoEuros
- FROM postgresql.income_employee ie
- JOIN postgresql.person pe ON ie.person_id = pe.person_id
- GROUP BY pe.id_trabajador
- ) se ON se.id_trabajador = w.id
- LEFT JOIN (SELECT MAX(IFNULL(ended, DATE_ADD(vToDated, INTERVAL 1 DAY )))dated,wl.workerFk
- FROM vn.workerLabour wl
- GROUP BY wl.workerFk
- HAVING dated<=vToDated
- ) sub ON sub.workerFk = w.id
- WHERE wj.dated BETWEEN vFromDated AND vToDated
- AND IF(vPartTime, cl.hours_week <= 40, cl.hours_week = 40)
- GROUP BY w.id
- ORDER BY w.lastName, w.firstname;
-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 DROP PROCEDURE IF EXISTS `placement_test` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -72033,100 +62221,74 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `placement_test`(vParamFk INT(11))
BEGIN
-
DECLARE vCalcFk INT;
- DECLARE vWarehouseFk INT;
- DECLARE vWarehouseAliasFk INT;
- DECLARE vCurrentYear INT DEFAULT YEAR(NOW());
-
- DROP TEMPORARY TABLE IF EXISTS tmp.sale;
- CREATE TEMPORARY TABLE tmp.sale
- ENGINE = MEMORY
+ DECLARE vWarehouseFk INT;
+ DECLARE vWarehouseAliasFk INT;
+ DECLARE vCurrentYear INT DEFAULT YEAR(util.VN_NOW());
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.sale;
+ CREATE TEMPORARY TABLE tmp.sale
+ ENGINE = MEMORY
SELECT 0000000 as ticketFk,
0000000 as saleFk,
- 0000000 as itemFk,
- FALSE as isStowaway,
- 0 as quantity;
-
- INSERT INTO tmp.sale(ticketFk, saleFk, itemFk, isStowaway)
+ 0000000 as itemFk,
+ FALSE as isStowaway,
+ 0 as quantity;
+
+ INSERT INTO tmp.sale(ticketFk, saleFk, itemFk, isStowaway)
SELECT s.ticketFk, s.id, s.itemFk, FALSE
FROM vn.ticketCollection tc
- JOIN vn.collection c ON c.id = tc.collectionFk
+ JOIN vn.collection c ON c.id = tc.collectionFk
JOIN vn.sale s ON s.ticketFk = tc.ticketFk
JOIN vn.item i ON i.id = s.itemFk
WHERE tc.collectionFk = vParamFk
AND (i.itemPackingTypeFk = c.itemPackingTypeFk OR ISNULL(c.itemPackingTypeFk))
- UNION ALL
+ UNION ALL
SELECT s.ticketFk, s.id, s.itemFk, FALSE
FROM vn.sale s
WHERE s.ticketFk = vParamFk;
-
-
- /* UNION ALL
- SELECT sw.shipFk, s.id, s.itemFk, TRUE
- FROM vn.sale s
- JOIN vn.stowaway sw ON sw.id = s.ticketFk
- JOIN vn.ticketCollection tc ON tc.ticketFk = sw.shipFk
- WHERE tc.collectionFk = vParamFk;
-
- INSERT INTO tmp.sale(ticketFk, saleFk, itemFk, isStowaway)
- SELECT s.ticketFk, s.id, s.itemFk, FALSE
- FROM vn.sale s
- JOIN vn.ticket t ON t.id = s.ticketFk
- WHERE s.ticketFk = vParamFk
- AND t.shipped > '2020-01-01'
- UNION ALL
- SELECT sw.shipFk, s.id, s.itemFk, TRUE
- FROM vn.sale s
- JOIN vn.stowaway sw ON sw.id = s.ticketFk
- WHERE sw.shipFk = vParamFk;
-
- DELETE FROM tmp.sale
- WHERE saleFk = 0;
- */
- SELECT t.warehouseFk, w.aliasFk
+
+ SELECT t.warehouseFk, w.aliasFk
INTO vWarehouseFk, vWarehouseAliasFk
- FROM vn.ticket t
+ FROM vn.ticket t
JOIN tmp.sale ts ON ts.ticketFk = t.id
- JOIN vn.warehouse w ON w.id = t.warehouseFk
- LIMIT 1;
-
+ JOIN vn.warehouse w ON w.id = t.warehouseFk
+ LIMIT 1;
+
CALL cache.visible_refresh(vCalcFk,FALSE,vWarehouseFk);
-
+
UPDATE tmp.sale ts
JOIN ( SELECT itemFk, sum(visible) as visible
- FROM vn.itemShelvingStock iss
+ FROM vn.itemShelvingStock iss
JOIN vn.warehouse w ON w.id = iss.warehouseFk
WHERE w.aliasFk = vWarehouseAliasFk
GROUP BY iss.itemFk ) iss ON iss.itemFk = ts.itemFk
SET ts.quantity = iss.visible;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.sale2;
- CREATE TEMPORARY TABLE tmp.sale2
- ENGINE = MEMORY
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.sale2;
+ CREATE TEMPORARY TABLE tmp.sale2
+ ENGINE = MEMORY
SELECT * FROM tmp.sale;
-
-
- DROP TEMPORARY TABLE IF EXISTS tmp.`grouping`;
- CREATE TEMPORARY TABLE tmp.`grouping`
- (PRIMARY KEY (itemFk))
+
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.`grouping`;
+ CREATE TEMPORARY TABLE tmp.`grouping`
+ (PRIMARY KEY (itemFk))
ENGINE = MEMORY
SELECT b.itemFk,
- CASE b.groupingMode
- WHEN 0 THEN 1
- WHEN 2 THEN b.packing
- ELSE b.`grouping`
+ CASE b.groupingMode
+ WHEN 0 THEN 1
+ WHEN 2 THEN b.packing
+ ELSE b.`grouping`
END AS `grouping`
FROM buy b
JOIN cache.last_buy lb ON lb.buy_id = b.id
WHERE lb.warehouse_id = vWarehouseFk
;
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.grouping2;
CREATE TEMPORARY TABLE tmp.grouping2
ENGINE = MEMORY
@@ -72136,87 +62298,89 @@ BEGIN
CREATE TEMPORARY TABLE tmp.salePlacementList
ENGINE = MEMORY
- SELECT ts.saleFk,
+ SELECT ts.saleFk,
ts.itemFk,
CONCAT(
- IF( iss.id,
- CONCAT('< ', IFNULL(wk.`code`, '---'),' > '),
- ''),
+ IF( iss.id,
+ CONCAT('< ', IFNULL(wk.`code`, '---'),' > '),
+ ''),
p.`code`) COLLATE utf8_general_ci as placement ,
sh.code COLLATE utf8_general_ci as shelving,
ish.created,
ish.visible,
IF(ts.isStowaway, - 100000, IF(ish.visible > 0 OR iss.id, 1, 100000)) * p.pickingOrder as `order`,
- IFNULL(IF(sc.isPreviousPreparedByPacking, ish.packing, g.`grouping`),1) as `grouping`,
- IF(iss.id, TO_SECONDS(TIMESTAMPADD(YEAR,-vCurrentYear,iss.created)), TO_SECONDS(TIMESTAMPADD(YEAR,- year(ish.created),ish.created)) + TO_SECONDS(TIMESTAMPADD(YEAR,-vCurrentYear,NOW()))) as priority,
- 0 as saleOrder,
- sc.isPreviousPrepared,
- iss.id as itemShelvingSaleFk,
- ts.ticketFk
- ,iss.id
- , st.saleFk as salePreviousPrepared
- , iss.userFk
- FROM tmp.sale ts
- LEFT JOIN (SELECT DISTINCT saleFk
+ IFNULL(IF(sc.isPreviousPreparedByPacking, ish.packing, g.`grouping`),1) as `grouping`,
+ IF(iss.id, TO_SECONDS(TIMESTAMPADD(YEAR,-vCurrentYear,iss.created)), TO_SECONDS(TIMESTAMPADD(YEAR,- year(ish.created),ish.created)) + TO_SECONDS(TIMESTAMPADD(YEAR,-vCurrentYear,util.VN_NOW()))) as priority,
+ 0 as saleOrder,
+ sc.isPreviousPrepared,
+ iss.id as itemShelvingSaleFk,
+ ts.ticketFk
+ ,iss.id
+ , st.saleFk as salePreviousPrepared
+ , iss.userFk
+ FROM tmp.sale ts
+ LEFT JOIN (SELECT DISTINCT saleFk
FROM vn.saleTracking st
- JOIN vn.state s ON s.id = st.stateFk
+ JOIN vn.state s ON s.id = st.stateFk
WHERE st.isChecked
AND s.semaphore = 1) st ON st.saleFk = ts.saleFk
- JOIN vn.itemShelving ish ON ish.itemFk = ts.itemFk
- JOIN vn.shelving sh ON sh.code = ish.shelvingFk
- JOIN vn.parking p ON p.id = sh.parkingFk
- JOIN vn.sector sc ON sc.id = p.sectorFk
- JOIN vn.warehouse w ON w.id = sc.warehouseFk
- LEFT JOIN tmp.`grouping` g ON g.itemFk = ts.itemFk
- LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = ts.saleFk AND iss.itemShelvingFk = ish.id
- LEFT JOIN vn.worker wk ON wk.id = iss.userFk
+ JOIN vn.itemShelving ish ON ish.itemFk = ts.itemFk
+ JOIN vn.shelving sh ON sh.code = ish.shelvingFk
+ JOIN vn.parking p ON p.id = sh.parkingFk
+ JOIN vn.sector sc ON sc.id = p.sectorFk
+ JOIN vn.warehouse w ON w.id = sc.warehouseFk
+ LEFT JOIN tmp.`grouping` g ON g.itemFk = ts.itemFk
+ LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = ts.saleFk AND iss.itemShelvingFk = ish.id
+ LEFT JOIN vn.worker wk ON wk.id = iss.userFk
WHERE w.aliasFk = vWarehouseAliasFk
- HAVING (iss.id AND st.saleFk) OR salePreviousPrepared IS NULL
- ;
-
+ HAVING (iss.id AND st.saleFk) OR salePreviousPrepared IS NULL
+ ;
+
DROP TEMPORARY TABLE IF EXISTS tmp.salePlacementList_2;
CREATE TEMPORARY TABLE tmp.salePlacementList_2
ENGINE MEMORY
- SELECT saleFk, priority as olderPriority
+ SELECT saleFk, priority as olderPriority
FROM (SELECT saleFk, priority
FROM tmp.salePlacementList
ORDER BY IF(isPreviousPrepared,2,1), IF(visible > 0 OR itemShelvingSaleFk,1,2), priority
- ) sub
- GROUP BY saleFk;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.salePlacementList_3;
+ LIMIT 10000000000000000000
+ ) sub
+ GROUP BY saleFk;
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.salePlacementList_3;
CREATE TEMPORARY TABLE tmp.salePlacementList_3
ENGINE MEMORY
- SELECT s1.saleFk, `order`as saleOrder
+ SELECT s1.saleFk, `order`as saleOrder
FROM tmp.salePlacementList s1
- JOIN tmp.salePlacementList_2 s2 ON s2.saleFk = s1.saleFk AND s2.olderPriority = s1.priority;
-
- UPDATE tmp.salePlacementList s1
+ JOIN tmp.salePlacementList_2 s2 ON s2.saleFk = s1.saleFk AND s2.olderPriority = s1.priority;
+
+ UPDATE tmp.salePlacementList s1
JOIN tmp.salePlacementList_3 s3 ON s3.saleFk = s1.saleFk
- SET s1.saleOrder = s3.saleOrder;
- /*
- -- Anula el orden de antigüedad y ordena por ubicación */
- UPDATE tmp.salePlacementList
- SET saleOrder = `order`;
-
- SELECT *
+ SET s1.saleOrder = s3.saleOrder;
+ /*
+ -- Anula el orden de antigüedad y ordena por ubicación */
+ UPDATE tmp.salePlacementList
+ SET saleOrder = `order`;
+
+ SELECT *
FROM tmp.salePlacementList
- ORDER BY visible <> 0 DESC,saleOrder, IF(isPreviousPrepared,2,1), IF(itemShelvingSaleFk,1,2),priority;
-
+ ORDER BY visible <> 0 DESC,saleOrder, IF(isPreviousPrepared,2,1), IF(itemShelvingSaleFk,1,2),priority;
+
DROP TEMPORARY TABLE
tmp.sale,
- tmp.sale2,
- tmp.`grouping`,
- tmp.grouping2,
- tmp.salePlacementList_2,
- tmp.salePlacementList_3;
-
+ tmp.sale2,
+ tmp.`grouping`,
+ tmp.grouping2,
+ tmp.salePlacementList_2,
+ tmp.salePlacementList_3;
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 `prepareClientList` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -72224,8 +62388,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prepareClientList`()
BEGIN
@@ -72246,6 +62408,8 @@ DELIMITER ;
/*!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 `prepareTicketList` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -72253,8 +62417,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `prepareTicketList`(vStartingDate DATETIME, vEndingDate DATETIME)
BEGIN
@@ -72269,11 +62431,11 @@ BEGIN
JOIN vn.client c ON c.id = t.clientFk
WHERE c.typeFk IN ('normal','handMaking','internalUse')
AND (
- t.shipped BETWEEN CURDATE() AND vEndingDate
+ t.shipped BETWEEN util.VN_CURDATE() AND vEndingDate
OR (
ts.alertLevel < 3
AND t.shipped >= vStartingDate
- AND t.shipped < CURDATE()
+ AND t.shipped < util.VN_CURDATE()
)
);
END ;;
@@ -72282,46 +62444,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `previousPreparationSticker_get__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `previousPreparationSticker_get__`(vTicketFk INT)
-BEGIN
-
- SELECT t.id ticketFk,
- p.code as location,
- t.observations,
- IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) shippingHour,
- IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) shippingMinute ,
- i.itemPackingTypeFk ,
- count(*) items
- FROM vn.ticket t
- JOIN vn.sale s ON s.ticketFk = t.id
- JOIN vn.item i ON i.id = s.itemFk
- -- JOIN vn.itemShelvingStock iss ON iss.itemFk = s.itemFk AND iss.sectorFk = 38
- JOIN vn.saleTracking st ON st.saleFk = s.id
- JOIN vn.state ss ON ss.id = st.stateFk
- LEFT JOIN vn.zone z ON z.id = t.zoneFk
- LEFT JOIN vn.shelving sh ON sh.code = t.id
- LEFT JOIN vn.parking p ON p.id = sh.parkingFk
- WHERE t.id = vTicketFk
- AND ss.code = 'PREVIOUS_PREPARATION'
- AND st.isChecked = FALSE
- GROUP BY i.itemPackingTypeFk ;
-
-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 DROP PROCEDURE IF EXISTS `previousSticker_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -72329,8 +62453,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `previousSticker_get`(vSaleGroupFk INT)
BEGIN
@@ -72390,290 +62512,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `printTrolleyLabel` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `printTrolleyLabel`(vTicket INT, vPrinter INT, vReport INT)
-BEGIN
-/**
- * Inserta en la cola de impresion una nueva etiqueta de carro, para el sacador
- *
- * @param vTicket Numero del ticket
- * @param vPrinter Numero de impresora
- * @param vReport Numero del informe
- **/
- DECLARE vlabelCount INT DEFAULT 0;
- DECLARE PRIORITY INT DEFAULT 3;
- DECLARE vWorker INT;
- DECLARE vShipmentHour VARCHAR(10);
-
- SELECT getTicketTrolleyLabelCount(vTicket) INTO vLabelCount;
- SELECT account.myUser_getId() INTO vWorker;
- SELECT CONCAT(getShipmentHour(vTicket),':00') INTO vShipmentHour;
-
- INSERT INTO printingQueue(printer
- , priority
- , report
- , `text`
- , worker
- , text2
- , text3)
- VALUES (vPrinter
- , PRIORITY
- , vReport
- , vTicket
- , vWorker
- , vLabelCount
- , vShipmentHour);
-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 DROP PROCEDURE IF EXISTS `prod` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `prod`(vWarehouseFk INT, vScopeDays INT)
-proc: BEGIN
-
- DECLARE vEndingDate DATETIME DEFAULT TIMESTAMPADD(DAY,vScopeDays,util.dayEnd(CURDATE()));
-
- DECLARE vIsTodayRelative BOOLEAN;
-
- SELECT isTodayRelative INTO vIsTodayRelative
- FROM vn.worker
- WHERE userFk = vn.getUser();
-
- CALL vn.prepareTicketList(TIMESTAMPADD(DAY,-1,CURDATE()), vEndingDate);
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
- CREATE TEMPORARY TABLE tmp.ticket
- SELECT * FROM tmp.productionTicket;
-
- CALL vn.prepareClientList();
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketGetProblems;
- CREATE TEMPORARY TABLE tmp.ticketGetProblems
- (INDEX (ticketFk)) ENGINE = MEMORY
- SELECT tt.ticketFk, tt.clientFk, t.warehouseFk, t.shipped
- FROM tmp.productionTicket tt
- JOIN vn.ticket t ON t.id = tt.ticketFk;
-
- CALL vn.ticketGetProblems(vIsTodayRelative);
-
- DROP TEMPORARY TABLE IF EXISTS tmp.productionBuffer;
- CREATE TEMPORARY TABLE tmp.productionBuffer
- (PRIMARY KEY(ticketFk))
- ENGINE = MEMORY
- SELECT tt.ticketFk
- , tt.clientFk
- , t.warehouseFk
- , t.nickname
- , t.packages
- , IF(HOUR(t.shipped), HOUR(t.shipped), IFNULL(HOUR(zc.hour),HOUR(z.hour))) as HH
- , IFNULL(HOUR(zc.hour),HOUR(z.hour)) as Departure
- , IF(MINUTE(t.shipped), MINUTE(t.shipped), IFNULL(MINUTE(zc.hour), MINUTE(z.hour))) as mm
- , t.routeFk
- , IF(am.deliveryMethodFk = 2,z.`id`,0) as zona
- , t.nickname addressNickname
- , a.postalCode
- , a.city
- , p.name province
- , CONCAT(z.`name`,' ',IFNULL(RIGHT(t.routeFk,3),'')) agency
- , am.id agencyModeFk
- , 0 AS `lines`
- , CAST( 0 AS DECIMAL(5,2)) AS m3
- , CAST( 0 AS DECIMAL(5,2)) AS preparationRate
- , "" as problem
- , IFNULL(tls.state,2) AS state
- , w.code workerCode
- , DATE(t.shipped) shipped
- , wk.code AS salesPersonCode
- , p.id provinceFk
- , tls.productionOrder
- , ifnull(tls.alertLevel,0) alertLevel
- , t.isBoxed as palletized
- , rg.deviceId ubicacion
- , tlu.lastUpdated
- -- , tls.updated lastUpdated
- , ifnull(st.graphCategory,0) graphCategory
- , pk.code as parking
- , 0 AS H
- , 0 AS V
- , 0 AS F
- , 0 AS P
- , st.isOk
- , ag.isOwn
- FROM tmp.productionTicket tt
- JOIN vn.ticket t on tt.ticketFk = t.id
- LEFT JOIN vn.ticketStateToday tst ON tst.ticket = t.id
- LEFT JOIN vn.state st ON st.id = tst.state
- LEFT JOIN vn.client c ON c.id = t.clientFk
- LEFT JOIN vn.worker wk ON wk.id = c.salesPersonFk
- JOIN vn.address a on a.id = t.addressFk
- LEFT JOIN vn.province p on p.id = a.provinceFk
- JOIN vn.agencyMode am ON am.id = t.agencyModeFk
- JOIN vn.agency ag ON ag.id = am.agencyFk
- LEFT JOIN vn.ticketState tls on tls.ticket = tt.ticketFk
- LEFT JOIN vn.ticketLastUpdated tlu ON tlu.ticketFk = tt.ticketFk
- LEFT JOIN vn.worker w on w.id = tls.worker
- LEFT JOIN vn.routeGate rg ON rg.routeFk = t.routeFk
- LEFT JOIN vn.zone z ON z.id = t.zoneFk
- LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk AND date(t.shipped) = zc.dated
- LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id
- LEFT JOIN vn.parking pk ON pk.id = tp.parkingFk
- WHERE t.warehouseFk = vWarehouseFk
- AND am.deliveryMethodFk IN (1,2,3);
-
- ALTER TABLE tmp.productionBuffer
- CHANGE COLUMN `problem` `problem` VARCHAR(255),
- ADD COLUMN `collectionH` INT,
- ADD COLUMN `collectionV` INT,
- ADD COLUMN `collectionF` INT,
- ADD COLUMN `collectionP` INT;
-
- -- Líneas y volumen por ticket
- UPDATE tmp.productionBuffer pb
- JOIN (
- SELECT tt.ticketFk,
- COUNT(*) as `lines`,
- sum(sv.volume) as m3,
- IFNULL(sum(IF(sv.isPicked,sv.volume,0)) / sum(sv.volume),0) as rate
- FROM tmp.productionTicket tt
- JOIN vn.saleVolume sv on sv.ticketFk = tt.ticketFk
- GROUP BY tt.ticketFk
- ) m on m.ticketFk = pb.ticketFk
- SET pb.`lines` = m.`lines`,
- pb.m3 = m.m3,
- pb.preparationRate = m.rate;
-
- DELETE FROM tmp.productionBuffer
- WHERE `lines`= 0;
-
- -- Lineas por linea de encajado
- UPDATE tmp.productionBuffer pb
- JOIN ( SELECT ticketFk,
- sum(sub.H) H,
- sum(sub.V) V,
- sum(sub.F) F,
- sum(sub.P) P
- FROM (
- SELECT t.ticketFk,
- sum(i.itemPackingTypeFk = 'H') H,
- sum(i.itemPackingTypeFk = 'V') V,
- sum(i.itemPackingTypeFk = 'F') F,
- sum(i.itemPackingTypeFk = 'P') P
- FROM tmp.productionTicket t
- JOIN vn.sale s ON s.ticketFk = t.ticketFk
- JOIN vn.item i ON i.id = s.itemFk
- GROUP BY t.ticketFk, i.itemPackingTypeFk) sub
- GROUP BY ticketFk
- ) sub2 ON sub2.ticketFk = pb.ticketFk
- SET pb.H = sub2.H,
- pb.V = sub2.V,
- pb.F = sub2.F,
- pb.P = sub2.P;
-
- -- Colecciones segun tipo de encajado
- UPDATE tmp.productionBuffer pb
- JOIN vn.ticketCollection tc ON pb.ticketFk = tc.ticketFk
- JOIN vn.collection c ON c.id = tc.collectionFk
- SET pb.collectionH = c.id
- WHERE c.itemPackingTypeFk = 'H' OR ISNULL(c.itemPackingTypeFk);
-
- UPDATE tmp.productionBuffer pb
- JOIN vn.ticketCollection tc ON pb.ticketFk = tc.ticketFk
- JOIN vn.collection c ON c.id = tc.collectionFk
- SET pb.collectionV = c.id
- WHERE c.itemPackingTypeFk = 'V' OR ISNULL(c.itemPackingTypeFk);
-
- UPDATE tmp.productionBuffer pb
- JOIN vn.ticketCollection tc ON pb.ticketFk = tc.ticketFk
- JOIN vn.collection c ON c.id = tc.collectionFk
- SET pb.collectionF = c.id
- WHERE c.itemPackingTypeFk = 'F' OR ISNULL(c.itemPackingTypeFk);
-
- UPDATE tmp.productionBuffer pb
- JOIN vn.ticketCollection tc ON pb.ticketFk = tc.ticketFk
- JOIN vn.collection c ON c.id = tc.collectionFk
- SET pb.collectionP = c.id
- WHERE c.itemPackingTypeFk = 'P' OR ISNULL(c.itemPackingTypeFk);
-
- -- Cajas
- ALTER TABLE tmp.productionBuffer
- ADD Cajas DOUBLE DEFAULT NULL;
- /*
- -- Problemas por ticket
- UPDATE tmp.productionBuffer pb
- JOIN tmp.ticketProblems tp ON tp.ticketFk = pb.ticketFk
- SET pb.problem = CAST(CONCAT( IFNULL(tp.itemShortage,''),
- IFNULL(tp.itemDelay,''),
- IF(tp.isFreezed,' CONGELADO',''),
- IF(tp.risk,' RIESGO',''),
- IF(tp.hasTicketRequest, ' COD 100',''),
- IF(tp.isTaxDataChecked, '',' FICHA INCOMPLETA'),
- IF(tp.componentLack,' COMPONENTES', '')
- ) as char(255));
- */
- -- Refresca la caché para el cierre dinámico de agencias
- -- CALL cache.departure_timing(vWarehouseFk);
-/*
- -- Tickets de recogida
- REPLACE tmp.productionBuffer(
- shipped
- , ticketFk
- , agency
- , clientFk
- , addressNickname
- , state
- , workerCode
- , alertLevel
- , warehouseFk
- )
- SELECT DATE(t.shipped)
- , t.id
- , am.name
- , t.clientFk
- , a.nickname
- , s.id as state
- , w.code
- , ifnull(tls.alertLevel,0) alert_level
- , vWarehouseFk
- FROM vn.ticket t
- JOIN vn.address a on a.id = t.addressFk
- JOIN vn.agencyMode am ON am.id = t.agencyModeFk
- LEFT JOIN vn2008.warehouse_pickup wp ON wp.agency_id = am.id
- LEFT JOIN vn.ticketState tls on tls.ticket = t.id
- LEFT JOIN vn.state s ON s.id = tls.state
- LEFT JOIN vn.worker w on w.id = tls.worker
- WHERE t.shipped between TIMESTAMPADD(WEEK,-1,CURDATE()) AND util.dayend(TIMESTAMPADD(DAY,-1,CURDATE()))
- AND wp.warehouse_id = vWarehouseFk;
-*/
- DROP TEMPORARY TABLE tmp.productionTicket;
- DROP TEMPORARY TABLE tmp.ticket;
- DROP TEMPORARY TABLE IF EXISTS tmp.risk;
-
-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 DROP PROCEDURE IF EXISTS `productionControl` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -72681,8 +62521,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `productionControl`(vWarehouseFk INT, vScopeDays INT)
proc: BEGIN
@@ -72696,7 +62534,7 @@ proc: BEGIN
* @return Table tmp.productionBuffer
*/
- DECLARE vEndingDate DATETIME DEFAULT TIMESTAMPADD(DAY,vScopeDays,util.dayEnd(CURDATE()));
+ DECLARE vEndingDate DATETIME DEFAULT TIMESTAMPADD(DAY,vScopeDays,util.dayEnd(util.VN_CURDATE()));
DECLARE vIsTodayRelative BOOLEAN;
@@ -72704,7 +62542,7 @@ proc: BEGIN
FROM vn.worker
WHERE userFk = vn.getUser();
- CALL vn.prepareTicketList(TIMESTAMPADD(DAY,-1,CURDATE()), vEndingDate);
+ CALL vn.prepareTicketList(TIMESTAMPADD(DAY,-1,util.VN_CURDATE()), vEndingDate);
DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
CREATE TEMPORARY TABLE tmp.ticket
@@ -72801,7 +62639,7 @@ proc: BEGIN
IF(tp.hasTicketRequest, ' COD 100',''),
IF(tp.isTaxDataChecked, '',' FICHA INCOMPLETA'),
IF(tp.hasComponentLack,' COMPONENTES', ''),
- IF(HOUR(NOW()) < pb.HH AND tp.isTooLittle,' PEQUEÑO', '')
+ IF(HOUR(util.VN_NOW()) < pb.HH AND tp.isTooLittle,' PEQUEÑO', '')
) as char(255)));
-- Clientes Nuevos o Recuperados
@@ -72870,7 +62708,7 @@ proc: BEGIN
salesInParkingCount INT DEFAULT 0)
ENGINE = MEMORY;
- -- Insertamos todos los tickets que tienen productos parkineados en sectores de previa, segun el sector
+-- Insertamos todos los tickets que tienen productos parkineados en sectores de previa, segun el sector
INSERT INTO tmp.ticketWithPrevia(ticketFk, salesCount)
SELECT pb.ticketFk, COUNT(DISTINCT s.id)
FROM tmp.productionBuffer pb
@@ -72880,7 +62718,7 @@ proc: BEGIN
JOIN vn.item i ON i.id = iss.itemFk
WHERE iss.isPreviousPrepared
AND (ISNULL(sc.itemPackingTypeFk)
- OR ISNULL(i.itemPackingTypeFk)
+ OR (ISNULL(i.itemPackingTypeFk) AND NOT pb.V)
OR sc.itemPackingTypeFk = i.itemPackingTypeFk )
GROUP BY pb.ticketFk;
@@ -72901,42 +62739,6 @@ proc: BEGIN
SET pb.previousWithoutParking = TRUE
WHERE twp.salesCount > twp.salesInParkingCount;
-/*
- -- Refresca la caché para el cierre dinámico de agencias
- CALL cache.departure_timing(vWarehouseFk);
-
- -- Tickets de recogida
- REPLACE tmp.productionBuffer(
- shipped
- , ticketFk
- , agency
- , clientFk
- , addressNickname
- , state
- , workerCode
- , alertLevel
- , warehouseFk
- )
- SELECT DATE(t.shipped)
- , t.id
- , am.name
- , t.clientFk
- , a.nickname
- , s.id as state
- , w.code
- , ifnull(tls.alertLevel,0) alert_level
- , vWarehouseFk
- FROM vn.ticket t
- JOIN vn.address a on a.id = t.addressFk
- JOIN vn.agencyMode am ON am.id = t.agencyModeFk
- LEFT JOIN vn2008.warehouse_pickup wp ON wp.agency_id = am.id
- LEFT JOIN vn.ticketState tls on tls.ticket = t.id
- LEFT JOIN vn.state s ON s.id = tls.state
- LEFT JOIN vn.worker w on w.id = tls.worker
- WHERE t.shipped between TIMESTAMPADD(WEEK,-1,CURDATE()) AND util.dayend(TIMESTAMPADD(DAY,-1,CURDATE()))
- AND wp.warehouse_id = vWarehouseFk;
-*/
-
DROP TEMPORARY TABLE tmp.productionTicket;
DROP TEMPORARY TABLE tmp.ticket;
DROP TEMPORARY TABLE tmp.risk;
@@ -72949,282 +62751,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `productionControl__` */;
-/*!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_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `productionControl__`(vWarehouseFk INT, vScopeDays INT)
-proc: BEGIN
-
- /**
- * Devuelve un listado de tickets con parámetros relativos a la producción de los días en rango
- *
- * @param vWarehouseFk Identificador de vn.warehouse
- * @param vScopeDays Número de días desde hoy en adelante que entran en el cálculo.
- *
- * @return Table tmp.productionBuffer
- */
-
- DECLARE vEndingDate DATETIME DEFAULT TIMESTAMPADD(DAY,vScopeDays,util.dayEnd(CURDATE()));
-
- DECLARE vIsTodayRelative BOOLEAN;
-
- SELECT isTodayRelative INTO vIsTodayRelative
- FROM vn.worker
- WHERE userFk = vn.getUser();
-
- CALL vn.prepareTicketList(TIMESTAMPADD(DAY,-1,CURDATE()), vEndingDate);
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
- CREATE TEMPORARY TABLE tmp.ticket
- SELECT * FROM tmp.productionTicket;
-
- CALL vn.prepareClientList();
-
- DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems;
- CREATE TEMPORARY TABLE tmp.sale_getProblems
- (INDEX (ticketFk)) ENGINE = MEMORY
- SELECT tt.ticketFk, tt.clientFk, t.warehouseFk, t.shipped
- FROM tmp.productionTicket tt
- JOIN vn.ticket t ON t.id = tt.ticketFk;
-
- CALL vn.ticket_getProblems(vIsTodayRelative);
-
- DROP TEMPORARY TABLE IF EXISTS tmp.productionBuffer;
- CREATE TEMPORARY TABLE tmp.productionBuffer
- (PRIMARY KEY(ticketFk))
- ENGINE = MEMORY
- SELECT tt.ticketFk
- , tt.clientFk
- , t.warehouseFk
- , t.nickname
- , t.packages
- , IF(HOUR(t.shipped), HOUR(t.shipped), IFNULL(HOUR(zc.hour),HOUR(z.hour))) as HH
- , IFNULL(HOUR(zc.hour),HOUR(z.hour)) as Departure
- , IF(MINUTE(t.shipped), MINUTE(t.shipped), IFNULL(MINUTE(zc.hour), MINUTE(z.hour))) as mm
- , t.routeFk
- , IF(am.deliveryMethodFk = 2,z.`id`,0) as zona
- , t.nickname addressNickname
- , a.postalCode
- , a.city
- , p.name province
- , CONCAT(z.`name`,' ',IFNULL(RIGHT(t.routeFk,3),'')) agency
- , am.id agencyModeFk
- , 0 AS `lines`
- , CAST( 0 AS DECIMAL(5,2)) AS m3
- , CAST( 0 AS DECIMAL(5,2)) AS preparationRate
- , "" as problem
- , IFNULL(tls.state,2) AS state
- , w.code workerCode
- , DATE(t.shipped) shipped
- , wk.code AS salesPersonCode
- , p.id provinceFk
- , tls.productionOrder
- , ifnull(tls.alertLevel,0) alertLevel
- , t.isBoxed as palletized
- , IF(rm.isPickingAllowed ,rm.bufferFk, NULL) ubicacion
- , tlu.lastUpdated
- , ifnull(st.graphCategory,0) graphCategory
- , pk.code as parking
- , 0 AS H
- , 0 AS V
- , 0 AS N
- , st.isOk
- , ag.isOwn
- FROM tmp.productionTicket tt
- JOIN vn.ticket t on tt.ticketFk = t.id
- LEFT JOIN vn.ticketStateToday tst ON tst.ticket = t.id
- LEFT JOIN vn.state st ON st.id = tst.state
- LEFT JOIN vn.client c ON c.id = t.clientFk
- LEFT JOIN vn.worker wk ON wk.id = c.salesPersonFk
- JOIN vn.address a on a.id = t.addressFk
- LEFT JOIN vn.province p on p.id = a.provinceFk
- JOIN vn.agencyMode am ON am.id = t.agencyModeFk
- JOIN vn.agency ag ON ag.id = am.agencyFk
- LEFT JOIN vn.ticketState tls on tls.ticket = tt.ticketFk
- LEFT JOIN vn.ticketLastUpdated tlu ON tlu.ticketFk = tt.ticketFk
- LEFT JOIN vn.worker w on w.id = tls.worker
- LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk
- LEFT JOIN vn.zone z ON z.id = t.zoneFk
- LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk AND date(t.shipped) = zc.dated
- LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id
- LEFT JOIN vn.parking pk ON pk.id = tp.parkingFk
- WHERE t.warehouseFk = vWarehouseFk
- AND am.deliveryMethodFk IN (1,2,3);
-
- -- Problemas por ticket
- ALTER TABLE tmp.productionBuffer
- CHANGE COLUMN `problem` `problem` VARCHAR(255),
- ADD COLUMN `collectionH` INT,
- ADD COLUMN `collectionV` INT;
-
- UPDATE tmp.productionBuffer pb
- JOIN tmp.ticket_problems tp ON tp.ticketFk = pb.ticketFk
- SET pb.problem = TRIM(CAST(CONCAT( IFNULL(tp.itemShortage,''),
- IFNULL(tp.itemDelay,''),
- IF(tp.isFreezed,' CONGELADO',''),
- IF(tp.hasHighRisk,' RIESGO',''),
- IF(tp.hasTicketRequest, ' COD 100',''),
- IF(tp.isTaxDataChecked, '',' FICHA INCOMPLETA'),
- IF(tp.hasComponentLack,' COMPONENTES', ''),
- IF(HOUR(NOW()) < pb.HH AND tp.isTooLittle,' PEQUEÑO', '')
- ) as char(255)));
-
- -- Clientes Nuevos o Recuperados
- UPDATE tmp.productionBuffer pb
- LEFT JOIN bs.clientNewBorn cnb ON cnb.clientFk = pb.clientFk
- SET pb.problem = TRIM(CAST(CONCAT('NUEVO ', pb.problem) AS CHAR(255)))
- WHERE ISNULL(cnb.clientFk) OR cnb.isRookie ;
-
- -- Líneas y volumen por ticket
- UPDATE tmp.productionBuffer pb
- JOIN (
- SELECT tt.ticketFk,
- COUNT(*) as `lines`,
- sum(sv.volume) as m3,
- IFNULL(sum(IF(sv.isPicked,sv.volume,0)) / sum(sv.volume),0) as rate
- FROM tmp.productionTicket tt
- JOIN vn.saleVolume sv on sv.ticketFk = tt.ticketFk
- GROUP BY tt.ticketFk
- ) m on m.ticketFk = pb.ticketFk
- SET pb.`lines` = m.`lines`,
- pb.m3 = m.m3,
- pb.preparationRate = m.rate;
-
- DELETE FROM tmp.productionBuffer
- WHERE `lines`= 0;
-
- -- Lineas por linea de encajado
- UPDATE tmp.productionBuffer pb
- JOIN ( SELECT ticketFk,
- sum(sub.H) H,
- sum(sub.V) V,
- sum(sub.N) N
- FROM (
- SELECT t.ticketFk,
- sum(i.itemPackingTypeFk = 'H') H,
- sum(i.itemPackingTypeFk = 'V') V,
- sum(ISNULL(i.itemPackingTypeFk)) N
- FROM tmp.productionTicket t
- JOIN vn.sale s ON s.ticketFk = t.ticketFk
- JOIN vn.item i ON i.id = s.itemFk
- GROUP BY t.ticketFk, i.itemPackingTypeFk) sub
- GROUP BY ticketFk
- ) sub2 ON sub2.ticketFk = pb.ticketFk
- SET pb.H = sub2.H,
- pb.V = sub2.V,
- pb.N = sub2.N;
-
- -- Colecciones segun tipo de encajado
- UPDATE tmp.productionBuffer pb
- JOIN vn.ticketCollection tc ON pb.ticketFk = tc.ticketFk
- JOIN vn.collection c ON c.id = tc.collectionFk
- SET pb.collectionH = c.id
- WHERE (c.itemPackingTypeFk = 'H' OR ISNULL(c.itemPackingTypeFk))
- AND pb.H;
-
- UPDATE tmp.productionBuffer pb
- JOIN vn.ticketCollection tc ON pb.ticketFk = tc.ticketFk
- JOIN vn.collection c ON c.id = tc.collectionFk
- SET pb.collectionV = c.id
- WHERE (c.itemPackingTypeFk = 'V' OR ISNULL(c.itemPackingTypeFk))
- AND pb.V;
-
- -- Previa pendiente
- ALTER TABLE tmp.productionBuffer
- ADD previousWithoutParking BOOL DEFAULT FALSE;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketWithPrevia;
- CREATE TEMPORARY TABLE tmp.ticketWithPrevia
- (ticketFk INT PRIMARY KEY,
- salesCount INT DEFAULT 0,
- salesInParkingCount INT DEFAULT 0)
- ENGINE = MEMORY;
-
- -- Insertamos todos los tickets que tienen productos parkineados en sectores de previa, segun el sector
- INSERT INTO tmp.ticketWithPrevia(ticketFk, salesCount)
- SELECT pb.ticketFk, COUNT(DISTINCT s.id)
- FROM tmp.productionBuffer pb
- JOIN vn.sale s ON s.ticketFk = pb.ticketFk
- JOIN vn.itemShelvingStock iss ON iss.itemFk = s.itemFk
- JOIN vn.sector sc ON sc.id = iss.sectorFk
- JOIN vn.item i ON i.id = iss.itemFk
- WHERE iss.isPreviousPrepared
- AND (ISNULL(sc.itemPackingTypeFk)
- OR ISNULL(i.itemPackingTypeFk)
- OR sc.itemPackingTypeFk = i.itemPackingTypeFk )
- GROUP BY pb.ticketFk;
-
- -- Se calcula la cantidad de productos que estan ya preparados porque su saleGroup está aparcado
- UPDATE tmp.ticketWithPrevia twp
- JOIN ( SELECT pb.ticketFk, count(DISTINCT s.id) salesInParkingCount
- FROM tmp.productionBuffer pb
- JOIN vn.sale s ON s.ticketFk = pb.ticketFk
- JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id
- JOIN vn.saleGroup sg ON sg.id = sgd.saleGroupFk
- WHERE NOT ISNULL(sg.parkingFk)
- GROUP BY pb.ticketFk ) sub ON twp.ticketFk = sub.ticketFk
- SET twp.salesInParkingCount = sub.salesInParkingCount;
-
- -- Marcamos como pendientes aquellos que no coinciden las cantidades
- UPDATE tmp.productionBuffer pb
- JOIN tmp.ticketWithPrevia twp ON twp.ticketFk = pb.ticketFk
- SET pb.previousWithoutParking = TRUE
- WHERE twp.salesCount > twp.salesInParkingCount;
-
-/*
- -- Refresca la caché para el cierre dinámico de agencias
- CALL cache.departure_timing(vWarehouseFk);
-
- -- Tickets de recogida
- REPLACE tmp.productionBuffer(
- shipped
- , ticketFk
- , agency
- , clientFk
- , addressNickname
- , state
- , workerCode
- , alertLevel
- , warehouseFk
- )
- SELECT DATE(t.shipped)
- , t.id
- , am.name
- , t.clientFk
- , a.nickname
- , s.id as state
- , w.code
- , ifnull(tls.alertLevel,0) alert_level
- , vWarehouseFk
- FROM vn.ticket t
- JOIN vn.address a on a.id = t.addressFk
- JOIN vn.agencyMode am ON am.id = t.agencyModeFk
- LEFT JOIN vn2008.warehouse_pickup wp ON wp.agency_id = am.id
- LEFT JOIN vn.ticketState tls on tls.ticket = t.id
- LEFT JOIN vn.state s ON s.id = tls.state
- LEFT JOIN vn.worker w on w.id = tls.worker
- WHERE t.shipped between TIMESTAMPADD(WEEK,-1,CURDATE()) AND util.dayend(TIMESTAMPADD(DAY,-1,CURDATE()))
- AND wp.warehouse_id = vWarehouseFk;
-*/
- DROP TEMPORARY TABLE tmp.productionTicket;
- DROP TEMPORARY TABLE tmp.ticket;
- DROP TEMPORARY TABLE tmp.risk;
- DROP TEMPORARY TABLE tmp.ticket_problems;
- DROP TEMPORARY TABLE tmp.ticketWithPrevia;
-
-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 sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `productionSectorList` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73232,8 +62760,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `productionSectorList`(vSectorFk INT)
BEGIN
@@ -73257,7 +62783,7 @@ BEGIN
FROM vn.sale s
JOIN vn.item i ON i.id = s.itemFk
JOIN vn.ticket t ON t.id = s.ticketFk
- WHERE t.shipped BETWEEN CURDATE() AND TIMESTAMPADD(HOUR, 23, CURDATE())
+ WHERE t.shipped BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(HOUR, 23, util.VN_CURDATE())
GROUP BY s.ticketFk
HAVING saleNum = iptNull;
@@ -73269,7 +62795,7 @@ BEGIN
JOIN vn.item i ON i.id = s.itemFk
JOIN vn.ticket t ON t.id = s.ticketFk
JOIN vn.sector sc ON sc.id = vSectorFk
- WHERE t.shipped BETWEEN CURDATE() AND TIMESTAMPADD(HOUR, 23, CURDATE())
+ WHERE t.shipped BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(HOUR, 23, util.VN_CURDATE())
GROUP BY s.ticketFk
HAVING iptSector;
@@ -73351,6 +62877,8 @@ DELIMITER ;
/*!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 `rangeDateInfo` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73358,8 +62886,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `rangeDateInfo`(vStarted DATE, vEnded DATE)
BEGIN
@@ -73401,6 +62927,8 @@ DELIMITER ;
/*!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 `rankingTeamByQuarter` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73408,8 +62936,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `rankingTeamByQuarter`(vYear INT, vQuarter INT)
BEGIN
@@ -73466,7 +62992,7 @@ BEGIN
AND d.name LIKE 'EQUIPO%'
AND CEIL(v.mes / 3) = vQuarter
GROUP BY wd.departmentFk
- ORDER BY SUM(v.importe) DESC) sub2 ON (sub1.name = sub2.name))
+ ORDER BY SUM(v.importe) DESC LIMIT 10000000000000000000) sub2 ON (sub1.name = sub2.name))
JOIN (SELECT COUNT(0) AS countPeople,
wd.departmentFk AS departmentFk
FROM
@@ -73482,6 +63008,8 @@ DELIMITER ;
/*!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 `rate_getPrices` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73489,8 +63017,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `rate_getPrices`(vDated DATE, vWarehouseFk INT)
BEGIN
@@ -73526,6 +63052,8 @@ DELIMITER ;
/*!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 `rate_getPrices2` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73533,8 +63061,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `rate_getPrices2`(vLanded DATE, vWarehouseFk INT)
BEGIN
@@ -73565,47 +63091,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `rate_getPrices__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `rate_getPrices__`(vLanded DATE, vWarehouseFk INT)
-BEGIN
-
- -- Prepara una tabla con las tarifas aplicables en funcion de la fecha y el almacén
-
- DROP TEMPORARY TABLE IF EXISTS tmp.rate;
- CREATE TEMPORARY TABLE tmp.rate
- ENGINE = MEMORY
- SELECT * FROM
- (
- SELECT * FROM
- (
- SELECT DISTINCT rate0, rate1, rate2, rate3
- FROM vn.rate
- WHERE dated <= vLanded
- AND warehouseFk = vWarehouseFk
- ORDER BY dated DESC
-
- ) sub
- UNION ALL
- SELECT rate0, rate1, rate2, rate3
- FROM rateConfig
- ) sub2
- LIMIT 1;
-
-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 DROP PROCEDURE IF EXISTS `recipe_Cook` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73613,8 +63100,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `recipe_Cook`(vItemFk INT, vBunchesQuantity INT, vDate DATE)
BEGIN
@@ -73693,6 +63178,8 @@ DELIMITER ;
/*!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 `recipe_Plaster` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73700,8 +63187,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `recipe_Plaster`(vItemFk INT, vTicketFk INT, vQuantity INT)
BEGIN
@@ -73790,6 +63275,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `refund` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73797,8 +63284,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `refund`(IN vOriginTicket INT, OUT vNewTicket INT)
BEGIN
@@ -73850,13 +63335,13 @@ BEGIN
)
SELECT
vCustomer,
- CURDATE(),
+ util.VN_CURDATE(),
vAddress,
vRefundAgencyMode,
a.nickname,
vWarehouse,
vCompany,
- CURDATE(),
+ util.VN_CURDATE(),
vZoneFk
FROM address a
WHERE a.id = vAddress;
@@ -73890,6 +63375,8 @@ DELIMITER ;
/*!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 `replaceMovimientosMark` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73897,8 +63384,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `replaceMovimientosMark`(
idMovimiento INT,
@@ -73929,6 +63414,8 @@ DELIMITER ;
/*!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 `reportLabelCollection_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73936,8 +63423,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `reportLabelCollection_get`(vParam INT)
BEGIN
@@ -73946,12 +63431,11 @@ BEGIN
*
* @param vParam Ticket/Colección del que sacar los datos
*/
- DECLARE vIsTicket BOOL;
+ DECLARE vIsCollection BOOL;
- SELECT IF(id, TRUE, FALSE) INTO vIsTicket
- FROM ticket
- WHERE created > (CURRENT_DATE() - INTERVAL 1 MONTH)
- AND id = vParam;
+ SELECT IF(id, TRUE, FALSE) INTO vIsCollection
+ FROM vn.collection c
+ WHERE id = vParam;
SELECT c.itemPackingTypeFk,
CONCAT(tc.collectionFk, ' ', LEFT(cc.code, 4)) color,
@@ -73983,7 +63467,7 @@ BEGIN
JOIN agencyMode am ON am.id = t.agencyModeFk
LEFT JOIN ticketTrolley tt ON tt.ticket = t.id
LEFT JOIN `zone` zo ON t.zoneFk = zo.id
- WHERE IF(vIsTicket, tc.ticketFk = vParam, tc.collectionFk = vParam)
+ WHERE IF(vIsCollection, tc.collectionFk = vParam, tc.ticketFk = vParam)
GROUP BY t.id
ORDER BY cc.`code`;
END ;;
@@ -73992,6 +63476,8 @@ DELIMITER ;
/*!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 `riskAllClients` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -73999,8 +63485,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `riskAllClients`(maxRiskDate DATE)
BEGIN
@@ -74034,134 +63518,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `routeGateAsign__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `routeGateAsign__`(vDevice VARCHAR(30), vRouteFk INT)
-BEGIN
- /*
- UPDATE routeGate
- SET displayText = NULL,
- routeFk = NULL,
- freeTickets = NULL,
- expeditions = NULL,
- scanned = NULL,
- flag = NULL,
- pallets = NULL,
- lastScanned = NULL
- WHERE routeFk = vRouteFk;
- */
- IF ISNULL(vDevice) THEN
-
- DELETE FROM routeGate
- WHERE routeFk = vRouteFk;
-
- ELSE
-
- REPLACE routeGate(routeFk, deviceId)
- VALUES(vRouteFk, vDevice);
-
- END IF;
- /*
- UPDATE vn.route r
- JOIN vn.beach b ON b.name = vDevice
- SET r.beachFk = b.id
- WHERE r.id = vRouteFk;
- */
-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 DROP PROCEDURE IF EXISTS `routeGateUpdate` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `routeGateUpdate`()
-BEGIN
-
- UPDATE vn.routeGate rg
- LEFT JOIN vn.routesControl rc ON rg.routeFk = rc.routeFk
- LEFT JOIN vn.route r ON r.id = rg.routeFk
- LEFT JOIN vn.agencyMode a ON a.id = r.agencyModeFk
- LEFT JOIN
- (
- SELECT Id_Ruta, count(*) AS pedidosLibres
- FROM vn2008.Tickets t
- JOIN vn2008.Tickets_state ts ON t.Id_Ticket = ts.Id_Ticket
- JOIN vncontrol.inter i ON i.inter_id = ts.inter_id
- JOIN vn2008.state s ON i.state_id = s.id AND s.alert_level < 2
- WHERE t.Fecha BETWEEN CURDATE() AND util.dayend(CURDATE())
- AND t.warehouse_id IN (1,44)
- AND Id_Ruta
- GROUP BY Id_Ruta
- ) t ON t.Id_Ruta = rg.routeFk
- SET rg.scanned = rc.scanned,
- rg.expeditions = rc.expeditions,
- rg.flag = a.flag,
- rg.freeTickets = t.pedidosLibres,
- rg.pallets = rc.pallets,
- rg.lastScanned = rc.lastScanned,
- rg.displayText = IF(rg.routeFk is null, rg.displayText, rg.routeFk MOD 1000),
- rg.ready = IF(rg.freeTickets, FALSE, rg.ready);
-
-
-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 DROP PROCEDURE IF EXISTS `routeGate_assignDevice` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `routeGate_assignDevice`(vDevice VARCHAR(30), vRouteFk INT)
-BEGIN
-/**
- * Asigna el dispositivo la ruta
- *
- * @param vDevice Dispositivo a remplazar
- * @param vRouteFk Ruta a la cual asignarlo
- */
- IF ISNULL(vDevice) THEN
-
- DELETE FROM routeGate
- WHERE routeFk = vRouteFk;
-
- ELSE
-
- REPLACE routeGate(routeFk, deviceId)
- VALUES(vRouteFk, vDevice);
-
- 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 DROP PROCEDURE IF EXISTS `routeGuessPriority` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74169,8 +63527,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `routeGuessPriority`(IN vRuta INT)
BEGIN
@@ -74183,7 +63539,7 @@ UPDATE ticket mt
SELECT tt.addressFk, ROUND(IFNULL(AVG(t.priority),0),0) AS priority
FROM ticket t
JOIN ticket tt ON tt.addressFk = t.addressFk
- WHERE t.shipped > TIMESTAMPADD(YEAR,-1,CURDATE())
+ WHERE t.shipped > TIMESTAMPADD(YEAR,-1,util.VN_CURDATE())
AND tt.routeFk = vRuta
GROUP BY addressFk
) sub ON sub.addressFk = mt.addressFk
@@ -74195,6 +63551,8 @@ DELIMITER ;
/*!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 `routeInfo` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74202,8 +63560,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `routeInfo`(vRouteFk INT)
BEGIN
@@ -74241,6 +63597,8 @@ DELIMITER ;
/*!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 `routeMonitor_calculate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74248,8 +63606,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `routeMonitor_calculate`(vDate DATE)
BEGIN
@@ -74354,6 +63710,8 @@ DELIMITER ;
/*!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 `routeSetOk` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74361,8 +63719,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `routeSetOk`(
vRouteFk INT)
@@ -74378,6 +63734,8 @@ DELIMITER ;
/*!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 `routeUpdateM3` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74385,8 +63743,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `routeUpdateM3`(vRoute INT)
BEGIN
@@ -74400,6 +63756,8 @@ DELIMITER ;
/*!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 `route_doRecalc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74407,8 +63765,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `route_doRecalc`()
proc: BEGIN
@@ -74461,6 +63817,8 @@ DELIMITER ;
/*!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 `route_getTickets` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74468,8 +63826,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `route_getTickets`(vRouteFk INT)
BEGIN
@@ -74536,6 +63892,8 @@ DELIMITER ;
/*!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 `route_updateM3` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74543,8 +63901,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `route_updateM3`(vRoute INT)
BEGIN
@@ -74563,6 +63919,8 @@ DELIMITER ;
/*!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 `rutasAnalyze` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74570,8 +63928,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `rutasAnalyze`(vYear INT, vMonth INT)
BEGIN
@@ -74741,6 +64097,8 @@ DELIMITER ;
/*!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 `saleBuy_Add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74748,8 +64106,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `saleBuy_Add`(vSaleFk INT, vBuyFk INT)
BEGIN
@@ -74780,6 +64136,8 @@ DELIMITER ;
/*!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 `saleGroup_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74787,8 +64145,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `saleGroup_add`(vSectorFk INT)
BEGIN
@@ -74807,158 +64163,32 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `saleItemShelvingDelete__` */;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `saleGroup_setParking` */;
/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `saleItemShelvingDelete__`(vSaleFk INT)
-BEGIN
+CREATE DEFINER=`root`@`localhost` PROCEDURE `saleGroup_setParking`(IN `vSaleGroupFk` VARCHAR(8), IN `vParkingFk` INT)
+proc: BEGIN
+ UPDATE vn.saleGroup sg
+ SET sg.parkingFk = vParkingFk
+ WHERE sg.id = vSaleGroupFk
+ AND sg.created >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE());
- UPDATE vn.itemShelving ish
- JOIN vn.saleItemShelving sis ON sis.itemShelvingFk = ish.id
- SET ish.visible = sis.quantity + ish.visible,
- ish.available = sis.quantity + ish.visible
- WHERE sis.saleFk = vSaleFk;
-
- DELETE FROM vn.saleItemShelving
- WHERE saleFk = vSaleFk;
-
+ CALL vn.ticket_setNextState(vn.ticket_get(vSaleGroupFk));
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 DROP PROCEDURE IF EXISTS `saleItemShelvingIsPicked__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `saleItemShelvingIsPicked__`(vTicketFk INT, vIsPicked BOOL)
-BEGIN
-
- DECLARE vStateFk INT;
-
- SELECT id INTO vStateFk
- FROM state
- WHERE code = 'PREVIOUS_PREPARATION';
-
- UPDATE vn.sale s
- JOIN vn.saleItemShelving sis ON sis.saleFk = s.id
- SET s.isPicked = vIsPicked
- WHERE s.ticketFk = vTicketFk;
-
- REPLACE vn2008.Movimientos_mark(Id_Movimiento, Valor, original_quantity, Id_Trabajador, stateFk)
- SELECT s.id, s.isPicked, s.quantity, account.myUser_getId(), vStateFk
- FROM sale s
- JOIN vn.saleItemShelving sis ON sis.saleFk = s.id
- WHERE s.ticketFk = vTicketFk;
-
-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 DROP PROCEDURE IF EXISTS `saleItemShelvingMake__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `saleItemShelvingMake__`(IN `vTicketFk` INT, IN `vSectorFk` INT)
-BEGIN
-
- SET @rest:= CAST(0 AS DECIMAL(10,0));
- SET @saleFk := CAST(0 AS DECIMAL(10,0));
- SET @reserved := CAST(0 AS DECIMAL(10,0));
-
- UPDATE vn.itemShelving ish
- JOIN vn.saleItemShelving sis ON sis.itemShelvingFk = ish.id
- JOIN sale s ON s.id = sis.saleFk
- SET ish.visible = sis.quantity + ish.visible,
- ish.available = sis.quantity + ish.visible
- WHERE s.ticketFk = vTicketFk;
-
- DELETE sis.*
- FROM saleItemShelving sis
- JOIN sale s ON s.id = sis.saleFk
- WHERE s.ticketFk = vTicketFk;
-
- INSERT INTO saleItemShelving( saleFk,
- itemShelvingFk,
- quantity,
- ubication)
- SELECT saleFk,
- itemShelvingFk,
- CAST(Reserved as DECIMAL(10,0)) as Reserved,
- ubication
- FROM
- (SELECT saleFk,
- itemShelvingFk,
- ubication,
- @rest := IF(@saleFk = saleFk, @rest, quantity) as Falta,
- @reserved := IF(available < @rest, available, IF(@rest < packing,0,@rest)) as Reserved,
- @rest := @rest - @reserved,
- @saleFk := saleFk
- FROM
- ( SELECT s.id as saleFk,
- ish.created,
- ish.id as itemShelvingFk,
- ish.available,
- s.quantity,
- ish.packing,
- CONCAT(p.`column`, '-',p.`row`,': ', sh.code ) as ubication
- FROM vn.sale s
- JOIN vn.ticket t ON t.id = s.ticketFk
- JOIN vn.sector sc ON sc.warehouseFk = t.warehouseFk
- JOIN vn.parking p ON p.sectorFk = sc.id
- JOIN vn.shelving sh ON sh.parkingFk = p.id
- JOIN vn.itemShelving ish ON ish.shelvingFk = sh.code AND ish.itemFk = s.itemFk
- WHERE t.id = vTicketFk
- AND sc.id = vSectorFk
- AND s.quantity MOD ish.packing = 0
- AND s.quantity >= ish.packing
- ORDER BY s.id,
- sh.priority DESC,
- ish.packing DESC,
- ish.created
- ) sub
- ) sub2
- WHERE Reserved > 0;
-
- UPDATE vn.itemShelving ish
- JOIN vn.saleItemShelving sis ON sis.itemShelvingFk = ish.id
- JOIN vn.sale s ON s.id = sis.saleFk
- SET ish.available = ish.visible - sis.quantity,
- ish.visible = ish.visible - sis.quantity
- WHERE s.ticketFk = vTicketFk
- AND s.isPicked = FALSE;
-
- CALL vn.saleItemShelvingIsPicked(vTicketFk, TRUE);
-
-
-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 DROP PROCEDURE IF EXISTS `saleMistake_Add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74966,8 +64196,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `saleMistake_Add`(vSaleFk INT, vUserFk INT, vTypeFk INT)
BEGIN
@@ -74981,6 +64209,8 @@ DELIMITER ;
/*!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 `saleMove` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -74988,8 +64218,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `saleMove`(IN vSaleFk BIGINT, IN vQuantity BIGINT)
BEGIN
@@ -75072,37 +64300,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `saleParking_add__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `saleParking_add__`(vSaleFk INT, vParkingCode VARCHAR(10))
-BEGIN
-
- /*
- * Inserta registro en saleParking
- *
- * vSaleFk Identificador de vn.sale
- * vParkingCode Code de vn.parking
- */
-
- INSERT INTO vn.saleParking(saleFk, parkingFk, userFk)
- SELECT vSaleFk, p.id, account.myUser_getId()
- FROM vn.parking p
- WHERE p.code = vParkingCode COLLATE utf8_unicode_ci;
-
-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 DROP PROCEDURE IF EXISTS `salePreparingList` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -75110,59 +64309,52 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `salePreparingList`(IN ticketFk BIGINT)
BEGIN
-CALL cache.last_buy_refresh(FALSE);
+ CALL cache.last_buy_refresh(FALSE);
- SELECT t.clientFk,
+ SELECT t.clientFk,
t.shipped,
- a.nickname,
+ a.nickname,
s.ticketFk,
s.itemFk,
s.quantity,
s.concept,
s.reserved,
s.id saleFk,
- i.size,
+ i.size,
i.inkFk,
i.stems,
i.image,
i.subName,
b.`grouping`,
- ip.code as placement,
- lpad(ifnull(cooler_path_detail_id, ip.code),5,'0') as path,
- IF(stPrevious.saleFk,TRUE,FALSE) as isPreviousSelected,
+ IF(stPrevious.saleFk,TRUE,FALSE) as isPreviousSelected,
stPrevious.isChecked as isPrevious,
- stPrepared.isChecked as isPrepared,
- stControled.isChecked as isControled,
- ib.code as barcode
-
- FROM vn.ticket t
- JOIN vn.address a ON a.id = t.addressFk
- JOIN vn.sale s ON s.ticketFk = t.id
- JOIN vn.item i ON i.id = s.itemFk
- LEFT JOIN vn.itemPlacement ip ON i.id = ip.itemFk AND ip.warehouseFk = t.warehouseFk
- LEFT JOIN vn2008.cooler_path_detail cpd on left(ip.code,3) = cpd.pasillo
- LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = t.warehouseFk
- LEFT JOIN vn.buy b ON b.id = lb.buy_id
- LEFT JOIN vn.saleTracking stPrevious ON stPrevious.saleFk = s.id AND stPrevious.stateFk = 26
- LEFT JOIN vn.saleTracking stPrepared ON stPrepared.saleFk = s.id AND stPrepared.stateFk = 14
- LEFT JOIN vn.saleTracking stControled ON stControled.saleFk = s.id AND stControled.stateFk = 8
- LEFT JOIN vn.itemBarcode ib ON ib.itemFk = i.id
-
- WHERE t.id = ticketFk
- GROUP BY s.id;
-
+ stPrepared.isChecked as isPrepared,
+ stControled.isChecked as isControled,
+ ib.code as barcode
+ FROM vn.ticket t
+ JOIN vn.address a ON a.id = t.addressFk
+ JOIN vn.sale s ON s.ticketFk = t.id
+ JOIN vn.item i ON i.id = s.itemFk
+ LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = t.warehouseFk
+ LEFT JOIN vn.buy b ON b.id = lb.buy_id
+ LEFT JOIN vn.saleTracking stPrevious ON stPrevious.saleFk = s.id AND stPrevious.stateFk = 26
+ LEFT JOIN vn.saleTracking stPrepared ON stPrepared.saleFk = s.id AND stPrepared.stateFk = 14
+ LEFT JOIN vn.saleTracking stControled ON stControled.saleFk = s.id AND stControled.stateFk = 8
+ LEFT JOIN vn.itemBarcode ib ON ib.itemFk = i.id
+ WHERE t.id = ticketFk
+ GROUP BY s.id;
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 `salesMerge` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -75170,8 +64362,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `salesMerge`(vTicketFk INT)
BEGIN
@@ -75203,6 +64393,8 @@ DELIMITER ;
/*!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 `salesMerge_byCollection` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -75210,8 +64402,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `salesMerge_byCollection`(vCollectionFk INT)
BEGIN
@@ -75253,6 +64443,8 @@ DELIMITER ;
/*!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 `saleSplit` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -75260,8 +64452,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `saleSplit`(vSaleFk INT, vQuantity INT)
BEGIN
@@ -75309,6 +64499,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `saleTracking_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -75316,8 +64508,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_add`(vSaleGroupFk INT)
BEGIN
@@ -75348,6 +64538,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `saleTracking_addPreparedSaleGroup` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -75355,8 +64547,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_addPreparedSaleGroup`(vSaleGroupFk INT)
BEGIN
@@ -75380,6 +64570,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `saleTracking_addPrevOK` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -75387,8 +64579,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_addPrevOK`(vSectorCollectionFk INT)
BEGIN
@@ -75422,6 +64612,8 @@ DELIMITER ;
/*!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 `saleTracking_del` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -75429,8 +64621,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_del`(vSaleFk INT, vState VARCHAR(50))
BEGIN
@@ -75450,6 +64640,8 @@ DELIMITER ;
/*!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 `saleTracking_new` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -75457,8 +64649,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_new`( vSaleFK INT,
vIsChecked BOOLEAN,
@@ -75491,6 +64681,8 @@ DELIMITER ;
/*!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 `saleTracking_Replace` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -75498,8 +64690,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_Replace`(vSaleFk INT, vIsChecked INT, vOriginalQuantity INT, vStateFk INT)
BEGIN
@@ -75511,6 +64701,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `saleTracking_updateIsChecked` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -75518,8 +64710,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_updateIsChecked`(vSaleFk INT, vIsChecked BOOL)
BEGIN
@@ -75551,6 +64741,8 @@ DELIMITER ;
/*!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 `sale_calculateComponent` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -75558,8 +64750,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_calculateComponent`(vSale INT, vOption INT)
proc: BEGIN
@@ -75584,219 +64774,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `sale_calculateComponent__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_calculateComponent__`(vSale INT, vOption INT)
-proc: BEGIN
-/**
- * Actualiza los componentes
- *
- * @param vSale Delivery date
- * @param vOption indica en que componente pone el descuadre, NULL en casos habituales
- * @return tmp.ticketLot(warehouseFk, available, itemFk, buyFk)
- * @return tmp.sale(saleFk, warehouseFk)
- */
- DECLARE vShipped DATE;
- DECLARE vWarehouseFk SMALLINT;
- DECLARE vAgencyModeFk INT;
- DECLARE vAddressFk INT;
- DECLARE vTicket BIGINT;
- DECLARE vItem BIGINT;
- DECLARE vLanded DATE;
- DECLARE vTicketFree BOOLEAN DEFAULT TRUE;
- DECLARE vZoneFk INTEGER;
-
- SELECT NOT (t.refFk IS NOT NULL OR ts.alertLevel > 0) OR s.price = 0, s.ticketFk, s.itemFk , t.zoneFk
- INTO vTicketFree, vTicket, vItem, vZoneFk
- FROM vn.ticket t
- JOIN vn.sale s ON s.ticketFk = t.id
- LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id
- WHERE s.id = vSale
- LIMIT 1;
-
- SELECT t.warehouseFk, DATE(t.shipped), t.addressFk, t.agencyModeFk, t.landed
- INTO vWarehouseFk, vShipped, vAddressFk, vAgencyModeFk, vLanded
- FROM agencyMode a
- JOIN ticket t ON t.agencyModeFk = a.id
- WHERE t.id = vTicket;
-
- IF IFNULL(vZoneFk,0) = 0 THEN
- CALL util.throw('ticket dont have zone');
- END IF;
-
- CALL buyUltimate (vWarehouseFk, vShipped);
-
- DELETE FROM tmp.buyUltimate WHERE itemFk != vItem;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
- CREATE TEMPORARY TABLE tmp.ticketLot
- SELECT vWarehouseFk warehouseFk, NULL available, vItem itemFk, buyFk
- FROM tmp.buyUltimate
- WHERE itemFk = vItem;
-
- CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped);
-
- DROP TEMPORARY TABLE IF EXISTS tmp.sale;
- CREATE TEMPORARY TABLE tmp.sale
- (PRIMARY KEY (saleFk)) ENGINE = MEMORY
- SELECT vSale saleFk,vWarehouseFk warehouseFk;
-
- IF vOption IS NULL THEN
- SET vOption = IF(vTicketFree,1,6);
- END IF;
-
- CALL ticketComponentUpdateSale(vOption);
-
- INSERT INTO vn.ticketLog (originFk, userFk, `action`, description)
- VALUES (vTicket, account.userGetId(), 'update', CONCAT('Bionizo linea id ', vSale));
-
- DROP TEMPORARY TABLE tmp.buyUltimate;
-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 DROP PROCEDURE IF EXISTS `sale_calculateComponent__2` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_calculateComponent__2`()
-proc: BEGIN
-/**
- * Actualiza los componentes
- *
- * @param vSale Delivery date
- * @param vOption indica en que componente pone el descuadre, NULL en casos habituales
- */
- DECLARE vShipped DATE;
- DECLARE vWarehouseFk SMALLINT;
- DECLARE vAgencyModeFk INT;
- DECLARE vAddressFk INT;
- DECLARE vTicketFk BIGINT;
- DECLARE vItemFk BIGINT;
- DECLARE vLanded DATE;
- DECLARE vIsEditable BOOLEAN;
- DECLARE vZoneFk INTEGER;
-
- DECLARE vSaleFk INTEGER;
- DECLARE v_done BOOL DEFAULT FALSE;
-
- DECLARE vCur CURSOR FOR
- select id from tmp.ticketRose;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET v_done = TRUE;
-
- OPEN vCur;
-
- l: LOOP
- SET v_done = FALSE;
- FETCH vCur INTO vSaleFk;
-
- IF v_done THEN
- LEAVE l;
- END IF;
-
- SELECT t.refFk IS NULL AND (IFNULL(ts.alertLevel, 0) = 0 OR s.price = 0),
- s.ticketFk,
- s.itemFk ,
- t.zoneFk,
- t.warehouseFk,
- t.shipped,
- t.addressFk,
- t.agencyModeFk,
- t.landed
- INTO vIsEditable,
- vTicketFk,
- vItemFk,
- vZoneFk,
- vWarehouseFk,
- vShipped,
- vAddressFk,
- vAgencyModeFk,
- vLanded
- FROM ticket t
- JOIN sale s ON s.ticketFk = t.id
- LEFT JOIN ticketState ts ON ts.ticketFk = t.id
- WHERE s.id = vSaleFk;
-
-
- CALL zone_getLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk, TRUE);
-
- IF (SELECT COUNT(*) FROM tmp.zoneGetLanded LIMIT 1) > 0 THEN
-
- IF vLanded IS NULL OR vZoneFk IS NULL THEN
-
- UPDATE ticket t
- SET t.landed = (SELECT landed FROM tmp.zoneGetLanded LIMIT 1)
- WHERE t.id = vTicketFk AND t.landed IS NULL;
-
- IF vZoneFk IS NULL THEN
- SELECT zoneFk INTO vZoneFk FROM tmp.zoneGetLanded LIMIT 1;
- UPDATE ticket t
- SET t.zoneFk = vZoneFk
- WHERE t.id = vTicketFk AND t.zoneFk IS NULL;
- END IF;
- DROP TEMPORARY TABLE tmp.zoneGetLanded;
-
- END IF;
-
- -- rellena la tabla buyUltimate con la ultima compra
- CALL buyUltimate (vWarehouseFk, vShipped);
-
- DELETE FROM tmp.buyUltimate WHERE itemFk != vItemFk;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
- CREATE TEMPORARY TABLE tmp.ticketLot
- SELECT vWarehouseFk warehouseFk, NULL available, vItemFk itemFk, buyFk, vZoneFk zoneFk
- FROM tmp.buyUltimate
- WHERE itemFk = vItemFk;
-
- CALL catalog_componentPrepare();
- CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk);
-
- DROP TEMPORARY TABLE IF EXISTS tmp.sale;
- CREATE TEMPORARY TABLE tmp.sale
- (PRIMARY KEY (saleFk)) ENGINE = MEMORY
- SELECT vSaleFk saleFk,vWarehouseFk warehouseFk;
- /*
- IF vOption IS NULL THEN
- SET vOption = IF(vIsEditable, 1, 6);
- END IF;
- */
-
- CALL ticketComponentUpdateSale(1);
- CALL catalog_componentPurge();
-
- DROP TEMPORARY TABLE tmp.buyUltimate;
- DROP TEMPORARY TABLE tmp.sale;
-
- ELSE
- INSERT INTO tmp.ticketFail (id) values (vSaleFk);
- END IF;
-
- END LOOP;
- CLOSE vCur;
-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 DROP PROCEDURE IF EXISTS `sale_checkNoComponents` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -75804,8 +64783,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_checkNoComponents`(vCreatedFrom DATETIME, vCreatedTo DATETIME)
BEGIN
@@ -75881,108 +64858,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `sale_fruitWithoutLot__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_fruitWithoutLot__`()
-BEGIN
-/**
-*
-* Manda correo a el usuario encargado de fruta y verdura
-* de las lineas de tickets a las que no ha sido asignada
-* un lote.
-*
-*/
- SET SESSION group_concat_max_len = 102400;
-
- INSERT INTO mail (receiver,replyTo,subject,body)
- SELECT CONCAT(sub.name, '@verdnatura.es') receiver,
- 'noreply@verdnatura.es' replyTo,
- CONCAT(
- 'El ',
- CONCAT (CAST((SUM(sub.fail)/COUNT(*))*100 AS DECIMAL(10,2)), ' %'),
- CONCAT(' de los artículos han sido vendidos sin lote con fecha: ', DATE_SUB(CURDATE(), INTERVAL 3 DAY ))
- ) subject,
- GROUP_CONCAT(sub.ticket SEPARATOR '
') body
- FROM (SELECT IF (sb.saleFk IS NULL,1, 0) fail,
- u.name,
- IF (sb.saleFk IS NULL,CONCAT('Artículo ',i.id,', ',i.name,':
- https://salix.verdnatura.es/#!/ticket/',t.id,'/sale'), NULL) ticket
- FROM ticket t
- JOIN sale s ON s.ticketFk = t.id
- LEFT JOIN saleBuy sb ON sb.saleFk = s.id
- JOIN item i ON i.id = s.itemFk
- JOIN itemType it ON it.id = i.typeFk
- JOIN account.user u ON u.id = it.workerFk
- JOIN itemCategory ic ON ic.id = it.categoryFk
- WHERE t.shipped = DATE_SUB(CURDATE(), INTERVAL 1 DAY)
- AND ic.code='fruit')sub;
-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 DROP PROCEDURE IF EXISTS `sale_getForSijsner__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_getForSijsner__`(vDated DATE)
-BEGIN
-
- /**
- * Devuelve el listado de ventas que tiene que etiquetar Sijsner para la fecha dada
- *
- * @param vDated Fecha de preparación de los tickets
- */
-
- SELECT b.printedStickers OR s.isPicked isPrinted,
- t.shipped ,
- t.nickname ,
- s.ticketFk ,
- s.itemFk ,
- FLOOR(s.quantity / e.pac) stickers,
- CONCAT(FLOOR(s.quantity / e.pac) , ' x ', e.pac ) amount,
- s.concept,
- e.kop,
- e.sub,
- sp.company_name supplier,
- b.id buyFk
- FROM vn.sale s
- JOIN vn.ticket t ON t.id = s.ticketFk
- JOIN vn.warehouse w ON w.id = t.warehouseFk
- JOIN vn.address a ON a.id = t.addressFk
- JOIN vn.province p ON p.id = a.provinceFk
- JOIN vn.country c ON c.id = p.countryFk
- JOIN vn.item i ON i.id = s.itemFk
- JOIN cache.last_buy lb ON lb.item_id = s.itemFk AND lb.warehouse_id = t.warehouseFk
- JOIN vn.buy b ON b.id = lb.buy_id
- LEFT JOIN edi.ekt e ON e.id = b.ektFk
- LEFT JOIN edi.supplier sp ON sp.supplier_id = e.pro
- WHERE t.shipped BETWEEN vDated AND TIMESTAMPADD(HOUR,23,vDated)
- AND c.code != 'ES'
- AND w.code IN ('FLM','VNH')
- AND s.quantity ;
-
-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 DROP PROCEDURE IF EXISTS `sale_getFromTicketOrCollection` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -75990,18 +64867,15 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_getFromTicketOrCollection`(vParam INT)
BEGIN
/**
* Visualizar lineas de la tabla sale a través del parámetro vParam que puede
* ser ticket o collection.
- *
+ *
* @param vParam Identificador de ticket o collection
*/
- DECLARE vItemPackingTypeFk VARCHAR(1);
DECLARE vIsCollection BOOL;
SELECT COUNT(*) INTO vIsCollection
@@ -76011,7 +64885,7 @@ BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
DROP TEMPORARY TABLE IF EXISTS tmp.ticket2;
- IF vIsCollection THEN
+ IF vIsCollection THEN
CREATE TEMPORARY TABLE tmp.ticket
(INDEX (id))
ENGINE = MEMORY
@@ -76019,7 +64893,7 @@ BEGIN
FROM ticketCollection tc
JOIN ticket t ON t.id = tc.ticketFk
WHERE tc.collectionFk = vParam;
-
+
CREATE TEMPORARY TABLE tmp.ticket2
(INDEX (id))
ENGINE = MEMORY
@@ -76027,7 +64901,7 @@ BEGIN
FROM ticketCollection tc
JOIN ticket t ON t.id = tc.ticketFk
WHERE tc.collectionFk = vParam;
- ELSE
+ ELSE
CREATE TEMPORARY TABLE tmp.ticket
(INDEX (id))
ENGINE = MEMORY
@@ -76088,7 +64962,8 @@ BEGIN
FROM tmp.ticket2 t
JOIN sale s ON s.ticketFk = t.id
JOIN saleTracking st ON st.saleFk = s.id
- ORDER BY st.id DESC) sub
+ ORDER BY st.id DESC
+ LIMIT 10000000000000000000) sub
GROUP BY sub.saleFk, sub.stateFK) sub2 ON sub2.saleFk = s.id AND sub2.isChecked = 1
LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id
LEFT JOIN state st ON st.id = sub2.stateFk
@@ -76109,6 +64984,8 @@ DELIMITER ;
/*!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 `sale_getProblems` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -76116,8 +64993,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_getProblems`(IN vIsTodayRelative tinyint(1))
BEGIN
@@ -76136,10 +65011,10 @@ BEGIN
DECLARE vComponentCount INT;
DECLARE vCursor CURSOR FOR
- SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, CURDATE(), date(tt.shipped))
+ SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, util.VN_CURDATE(), date(tt.shipped))
FROM tmp.sale_getProblems tt
- WHERE DATE(tt.shipped) BETWEEN CURDATE()
- AND TIMESTAMPADD(DAY, IF(vIsTodayRelative, 9.9, 1.9), CURDATE());
+ WHERE DATE(tt.shipped) BETWEEN util.VN_CURDATE()
+ AND TIMESTAMPADD(DAY, IF(vIsTodayRelative, 9.9, 1.9), util.VN_CURDATE());
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1;
@@ -76188,12 +65063,12 @@ BEGIN
FROM tmp.ticket_list tl
JOIN vn.saleVolume sv ON sv.ticketFk = tl.ticketFk
JOIN vn.ticket t ON t.id = tl.ticketFk
- JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk AND zc.dated = CURDATE()
+ JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk AND zc.dated = util.VN_CURDATE()
JOIN vn.agencyMode am ON am.id = t.agencyModeFk
JOIN vn.deliveryMethod dm ON dm.id = am.deliveryMethodFk
- WHERE NOW() < TIMESTAMPADD(MINUTE,MINUTE(zc.`hour`) ,TIMESTAMPADD(HOUR,HOUR(zc.`hour`),CURDATE()))
+ WHERE util.VN_NOW() < TIMESTAMPADD(MINUTE,MINUTE(zc.`hour`) ,TIMESTAMPADD(HOUR,HOUR(zc.`hour`),util.VN_CURDATE()))
AND dm.code IN('AGENCY','DELIVERY','PICKUP')
- AND t.shipped BETWEEN CURDATE() AND util.midnight()
+ AND t.shipped BETWEEN util.VN_CURDATE() AND util.midnight()
GROUP BY t.addressFk) sub ON sub.addressFk = t.addressFk
JOIN vn.volumeConfig vc
WHERE sub.litros < vc.minTicketVolume
@@ -76228,7 +65103,7 @@ BEGIN
SELECT DISTINCT clientFk
FROM tmp.ticket_list;
- CALL clientGetDebt(CURDATE());
+ CALL clientGetDebt(util.VN_CURDATE());
INSERT INTO tmp.sale_problems(ticketFk, risk, hasHighRisk)
SELECT DISTINCT tl.ticketFk, r.risk, ((r.risk - cc.riskTolerance) > c.credit + 10)
@@ -76305,7 +65180,7 @@ BEGIN
AND ic.merchandise = TRUE
AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate)
AND NOT i.generic
- AND CURDATE() = vDate
+ AND util.VN_CURDATE() = vDate
AND t.warehouseFk = vWarehouseFk
GROUP BY tl.ticketFk) sub
ON DUPLICATE KEY UPDATE itemShortage = sub.problem, saleFk = sub.saleFk;
@@ -76331,7 +65206,7 @@ BEGIN
AND ic.merchandise = TRUE
AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate)
AND NOT i.generic
- AND CURDATE() = vDate
+ AND util.VN_CURDATE() = vDate
AND t.warehouseFk = vWarehouseFk
GROUP BY tl.ticketFk) sub
ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk;
@@ -76359,7 +65234,7 @@ BEGIN
AND ic.merchandise = TRUE
AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate)
AND NOT i.generic
- AND CURDATE() = vDate
+ AND util.VN_CURDATE() = vDate
AND t.warehouseFk = vWarehouseFk
GROUP BY tl.ticketFk) sub
ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk;
@@ -76383,6 +65258,8 @@ DELIMITER ;
/*!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 `sale_getProblemsByTicket` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -76390,8 +65267,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_getProblemsByTicket`(IN vTicketFk INT, IN vIsTodayRelative TINYINT(1))
BEGIN
@@ -76422,225 +65297,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `sale_getProblems__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_getProblems__`(IN vIsTodayRelative tinyint(1))
-BEGIN
-/**
- * Calcula los problemas de cada venta
- * para un conjunto de tickets.
- *
- * @table tmp.sale_getProblems(ticketFk, clientFk, warehouseFk, shipped) Identificadores de los tickets a calcular
- * @return tmp.sale_problems
- */
- DECLARE vWarehouse INT;
- DECLARE vDate DATE;
- DECLARE vAvailableCache INT;
- DECLARE vDone INT DEFAULT 0;
- DECLARE vComponentCount INT;
-
- DECLARE vCursor CURSOR FOR
- SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, CURDATE(), date(tt.shipped))
- FROM tmp.sale_getProblems tt
- WHERE DATE(tt.shipped) BETWEEN CURDATE()
- AND TIMESTAMPADD(DAY, IF(vIsTodayRelative, 9.9, 1.9), CURDATE());
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.sale_problems;
- CREATE TEMPORARY TABLE tmp.sale_problems (
- ticketFk INT(11),
- saleFk INT(11),
- isFreezed INTEGER(1) DEFAULT 0,
- risk DECIMAL(10,2) DEFAULT 0,
- hasHighRisk TINYINT(1) DEFAULT 0,
- hasTicketRequest INTEGER(1) DEFAULT 0,
- isAvailable INTEGER(1) DEFAULT 1,
- itemShortage VARCHAR(250),
- isTaxDataChecked INTEGER(1) DEFAULT 1,
- itemDelay VARCHAR(250),
- hasComponentLack INTEGER(1),
- isTooLittle BOOL DEFAULT FALSE,
- PRIMARY KEY (ticketFk, saleFk)
- ) ENGINE = MEMORY;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list;
- CREATE TEMPORARY TABLE tmp.ticket_list
- (PRIMARY KEY (ticketFk))
- ENGINE = MEMORY
- SELECT tp.ticketFk, c.id clientFk
- FROM tmp.sale_getProblems tp
- JOIN vn.client c ON c.id = tp.clientFk;
-
- SELECT COUNT(*) INTO vComponentCount
- FROM vn.component c
- WHERE c.isRequired;
-
- INSERT INTO tmp.sale_problems(ticketFk, isTooLittle)
- SELECT sub.ticketFk, TRUE
- FROM (SELECT tl.ticketFk, SUM(sv.litros) litros
- FROM tmp.ticket_list tl
- JOIN vn.saleVolume sv ON sv.ticketFk = tl.ticketFk
- JOIN vn.ticket t ON t.id = tl.ticketFk
- JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk AND zc.dated = CURDATE()
- WHERE NOW() < TIMESTAMPADD(MINUTE,MINUTE(zc.`hour`) ,TIMESTAMPADD(HOUR,HOUR(zc.`hour`),CURDATE()))
- GROUP BY tl.ticketFk) sub
- JOIN vn.volumeConfig vc
- WHERE sub.litros < vc.minTicketVolume;
-
- INSERT INTO tmp.sale_problems(ticketFk, hasComponentLack, saleFk)
- SELECT tl.ticketFk, (COUNT(DISTINCT s.id) * vComponentCount > COUNT(c.id)), s.id
- FROM tmp.ticket_list tl
- JOIN vn.sale s ON s.ticketFk = tl.ticketFk
- LEFT JOIN vn.saleComponent sc ON sc.saleFk = s.id
- LEFT JOIN vn.component c ON c.id = sc.componentFk AND c.isRequired
- JOIN vn.ticket t ON t.id = tl.ticketFk
- JOIN vn.agencyMode am ON am.id = t.agencyModeFk
- JOIN vn.deliveryMethod dm ON dm.id = am.deliveryMethodFk
- WHERE dm.code IN('AGENCY','DELIVERY','PICKUP')
- GROUP BY tl.ticketFk, s.id;
-
- INSERT INTO tmp.sale_problems(ticketFk, isFreezed)
- SELECT DISTINCT tl.ticketFk, TRUE
- FROM tmp.ticket_list tl
- JOIN vn.client c ON c.id = tl.clientFk
- WHERE c.isFreezed
- ON DUPLICATE KEY UPDATE
- isFreezed = c.isFreezed;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt;
- CREATE TEMPORARY TABLE tmp.clientGetDebt
- (PRIMARY KEY (clientFk))
- ENGINE = MEMORY
- SELECT DISTINCT clientFk
- FROM tmp.ticket_list;
-
- CALL clientGetDebt(CURDATE());
-
- INSERT INTO tmp.sale_problems(ticketFk, risk, hasHighRisk)
- SELECT DISTINCT tl.ticketFk, r.risk, ((r.risk - cc.riskTolerance) > c.credit + 10)
- FROM tmp.ticket_list tl
- JOIN vn.ticket t ON t.id = tl.ticketFk
- JOIN vn.agencyMode a ON t.agencyModeFk = a.id
- JOIN tmp.risk r ON r.clientFk = t.clientFk
- JOIN vn.client c ON c.id = t.clientFk
- JOIN vn.clientConfig cc
- WHERE r.risk > c.credit + 10
- AND a.isRiskFree = FALSE
- ON DUPLICATE KEY UPDATE
- risk = r.risk, hasHighRisk = ((r.risk - cc.riskTolerance) > c.credit + 10);
-
- INSERT INTO tmp.sale_problems(ticketFk, hasTicketRequest)
- SELECT DISTINCT tl.ticketFk, TRUE
- FROM tmp.ticket_list tl
- JOIN vn.ticketRequest tr ON tr.ticketFk = tl.ticketFk
- WHERE tr.isOK IS NULL
- ON DUPLICATE KEY UPDATE
- hasTicketRequest = TRUE;
-
- OPEN vCursor;
-
- WHILE NOT vDone
- DO
- FETCH vCursor INTO vWarehouse, vDate;
-
- CALL cache.available_refresh(vAvailableCache, FALSE, vWarehouse, vDate);
-
- INSERT INTO tmp.sale_problems(ticketFk, isAvailable, saleFk)
- SELECT tl.ticketFk, FALSE, s.id
- FROM tmp.ticket_list tl
- JOIN vn.ticket t ON t.id = tl.ticketFk
- JOIN vn.sale s ON s.ticketFk = t.id
- JOIN vn.item i ON i.id = s.itemFk
- JOIN vn.itemType it on it.id = i.typeFk
- LEFT JOIN cache.available av ON av.item_id = i.id
- AND av.calc_id = vAvailableCache
- WHERE date(t.shipped) = vDate
- AND it.categoryFk != 6
- AND IFNULL(av.available, 0) < 0
- AND s.isPicked = FALSE
- AND NOT i.generic
- AND vWarehouse = t.warehouseFk
- GROUP BY tl.ticketFk
- ON DUPLICATE KEY UPDATE
- isAvailable = FALSE, saleFk = VALUES(saleFk);
-
- INSERT INTO tmp.sale_problems(ticketFk, itemShortage, saleFk)
- SELECT ticketFk, problem, saleFk
- FROM (
- SELECT tl.ticketFk, CONCAT('F: ',GROUP_CONCAT(i.id, ' ', i.longName, ' ')) problem, s.id AS saleFk
- FROM tmp.ticket_list tl
- JOIN vn.ticket t ON t.id = tl.ticketFk
- JOIN vn.sale s ON s.ticketFk = t.id
- JOIN vn.item i ON i.id = s.itemFk
- JOIN vn.itemType it on it.id = i.typeFk
- LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk
- LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache
- WHERE IFNULL(av.available, 0) < 0
- AND s.quantity > IFNULL(issw.visible, 0)
- AND s.quantity > 0
- AND s.isPicked = FALSE
- AND s.reserved = FALSE
- AND it.categoryFk != 6
- AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate)
- AND NOT i.generic
- AND CURDATE() = vDate
- AND t.warehouseFk = vWarehouse
- GROUP BY tl.ticketFk LIMIT 1) sub
- ON DUPLICATE KEY UPDATE
- itemShortage = sub.problem, saleFk = sub.saleFk;
-
- INSERT INTO tmp.sale_problems(ticketFk, itemDelay, saleFk)
- SELECT ticketFk, problem, saleFk
- FROM (
- SELECT tl.ticketFk, GROUP_CONCAT('I: ',i.id, ' ', i.longName, ' ') problem, s.id AS saleFk
- FROM tmp.ticket_list tl
- JOIN vn.ticket t ON t.id = tl.ticketFk
- JOIN vn.sale s ON s.ticketFk = t.id
- JOIN vn.item i ON i.id = s.itemFk
- JOIN vn.itemType it on it.id = i.typeFk
- LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk
- WHERE s.quantity > IFNULL(issw.visible, 0)
- AND s.quantity > 0
- AND s.isPicked = FALSE
- AND s.reserved = FALSE
- AND it.categoryFk != 6
- AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate)
- AND NOT i.generic
- AND CURDATE() = vDate
- AND t.warehouseFk = vWarehouse
- GROUP BY tl.ticketFk LIMIT 1) sub
- ON DUPLICATE KEY UPDATE
- itemDelay = sub.problem, saleFk = sub.saleFk;
- END WHILE;
-
- CLOSE vCursor;
-
- INSERT INTO tmp.sale_problems(ticketFk, isTaxDataChecked)
- SELECT DISTINCT tl.ticketFk, FALSE
- FROM tmp.ticket_list tl
- JOIN vn.client c ON c.id = tl.clientFk
- WHERE c.isTaxDataChecked = FALSE
- ON DUPLICATE KEY UPDATE
- isTaxDataChecked = FALSE;
-
- DROP TEMPORARY TABLE
- tmp.clientGetDebt,
- tmp.ticket_list;
-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 sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `sale_PriceFix` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -76648,8 +65306,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_PriceFix`(vTicketFk INT)
BEGIN
@@ -76676,6 +65332,8 @@ DELIMITER ;
/*!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 `sale_recalcComponent` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -76683,8 +65341,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_recalcComponent`(vOption INT)
proc: BEGIN
@@ -76805,6 +65461,8 @@ DELIMITER ;
/*!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 `sale_setQuantity` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -76812,8 +65470,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_setQuantity`(vSaleFk INT, vQuantity INT)
BEGIN
@@ -76847,6 +65503,8 @@ DELIMITER ;
/*!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 `sale_updateOriginalQuantity` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -76854,8 +65512,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_updateOriginalQuantity`(vSale INT, vQuantity INT)
proc: BEGIN
@@ -76871,6 +65527,8 @@ DELIMITER ;
/*!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 `saveLoadWorker` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -76878,8 +65536,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `saveLoadWorker`(routeFk INT, workerFk INT)
BEGIN
@@ -76894,50 +65550,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `scanTreeCreate__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `scanTreeCreate__`()
-BEGIN
- CALL nestTree(
- 'vn2008',
- 'scan',
- 'vn2008',
- 'scanTree'
- );
-
- UPDATE vn2008.scanTree st
- JOIN (
- SELECT sl.scan_id,
- MAX(sl.odbc_date) lastScanned,
- COUNT(DISTINCT t.routeFk) routeCount,
- MIN(t.routeFk) mod 1000 as minRoute,
- MAX(t.routeFk) mod 1000 as maxRoute,
- COUNT(sl.scan_line_id) as scanned
- FROM vn2008.scan_line sl
- JOIN expedition e ON e.id = sl.`code`
- JOIN ticket t ON t.id = e.ticketFk
- WHERE t.routeFk
- GROUP BY sl.scan_id
- ) rs ON rs.scan_id = st.id
- SET st.lastScanned = rs.lastScanned,
- st.routeCount = rs.routeCount,
- st.minRoute = rs.minRoute,
- st.maxRoute = IF(rs.minRoute != rs.maxRoute, rs.maxRoute,NULL),
- st.scanned = rs.scanned;
-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 sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `sectorCollectionSaleGroup_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -76945,8 +65559,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sectorCollectionSaleGroup_add`(vSaleGroupFk INT, vSectorCollectionFk INT)
BEGIN
@@ -76997,6 +65609,8 @@ DELIMITER ;
/*!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 `sectorCollection_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77004,8 +65618,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sectorCollection_get`(vSectorFk INT)
BEGIN
@@ -77027,7 +65639,7 @@ BEGIN
AND (ISNULL(scsg.sectorCollectionFk)
OR
(NOT st.isChecked AND sl.quantity > 0))
- AND sc.created > CURDATE();
+ AND sc.created > util.VN_CURDATE();
END ;;
DELIMITER ;
@@ -77035,6 +65647,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `sectorCollection_getSale` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77042,8 +65656,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sectorCollection_getSale`(vSelf INT)
BEGIN
@@ -77082,6 +65694,8 @@ DELIMITER ;
/*!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 `sectorCollection_new` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77089,17 +65703,14 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sectorCollection_new`(vSectorFk INT)
BEGIN
-
/**
* Inserta una nueva colección, si el usuario no tiene ninguna vacia.
* Esto se hace para evitar que por error se generen colecciones sin sentido.
*
- * @param vSectorFk Identificador de vn.sector
+ * @param vSectorFk Identificador de #vn.sector
*/
DECLARE hasEmptyCollections BOOL;
DECLARE vUserFk INT;
@@ -77112,8 +65723,8 @@ BEGIN
WHERE ISNULL(scsg.id)
AND sc.userFk = vUserFk
AND sc.sectorFk = vSectorFk
- AND sc.created >= CURDATE();
-
+ AND sc.created >= util.VN_CURDATE();
+
IF NOT hasEmptyCollections THEN
INSERT INTO vn.sectorCollection(userFk, sectorFk)
VALUES(vUserFk, vSectorFk);
@@ -77124,15 +65735,15 @@ DELIMITER ;
/*!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 `sectorProductivity_add` */;
/*!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_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sectorProductivity_add`()
BEGIN
@@ -77140,7 +65751,7 @@ BEGIN
DECLARE vDatedFrom DATETIME;
DECLARE vDatedTo DATETIME;
- SELECT DATE_SUB(CURDATE(),INTERVAL 1 DAY), CONCAT(DATE_SUB(CURDATE(),INTERVAL 1 DAY),' 23:59:59') INTO vDatedFrom, vDatedTo;
+ SELECT DATE_SUB(util.VN_CURDATE(),INTERVAL 1 DAY), CONCAT(DATE_SUB(util.VN_CURDATE(),INTERVAL 1 DAY),' 23:59:59') INTO vDatedFrom, vDatedTo;
DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate;
DROP TEMPORARY TABLE IF EXISTS tmp.errorsByChecker;
@@ -77150,20 +65761,15 @@ BEGIN
CREATE TEMPORARY TABLE tmp.errorsByChecker
ENGINE = MEMORY
- SELECT sub1.workerFk, COUNT(sub1.id) errorsByChecker
- FROM (
- SELECT st.workerFk, t.id
- FROM saleMistake sm
- JOIN saleTracking st ON sm.saleFk = st.saleFk
- JOIN vncontrol.accion a ON a.accion_id = st.actionFk
- JOIN sale s ON s.id = sm.saleFk
- JOIN ticket t on t.id = s.ticketFk
- JOIN vn.item i ON i.id = s.itemFk
- JOIN vn.sector se ON se.id = i.sectorFk
- WHERE (t.shipped BETWEEN vDatedFrom AND vDatedTo) AND a.accion = 'PRESACAR' AND se.code IN ('ALGEMESI ARTIFI','COMPLEMENTOS')
- GROUP BY s.ticketFk
- ) sub1
- GROUP BY sub1.workerFk;
+ SELECT sc.userFk workerFk, COUNT(DISTINCT s.ticketFk) errorsByChecker
+ FROM saleMistake sm
+ JOIN vn.saleGroupDetail sgd on sgd.saleFk = sm.saleFk
+ JOIN vn.sectorCollectionSaleGroup scsg on scsg.saleGroupFk = sgd.saleGroupFk
+ JOIN vn.sectorCollection sc on sc.id = scsg.sectorCollectionFk
+ JOIN sale s ON s.id = sm.saleFk
+ JOIN ticket t on t.id = s.ticketFk
+ WHERE (t.shipped BETWEEN vDatedFrom AND vDatedTo)
+ GROUP BY sc.userFk ;
CREATE TEMPORARY TABLE tmp.previousErrors -- Errores de previa, derivadores de los revisadores (por reclamación)
ENGINE = MEMORY
@@ -77177,30 +65783,34 @@ BEGIN
WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo AND cr.description = 'Revisadores' AND s.code = 'OK PREVIOUS'
GROUP BY workerFk;
+ DELETE FROM sectorProductivity
+ WHERE dated = vDatedFrom
+ AND sector IN ('Algemesi Artificial','Algemesi Complementos');
+
INSERT INTO sectorProductivity(workerFk, firstName, lastName, sector, ticketCount, saleCount, error, volume, hourWorked, dated)
SELECT w.id workerFk,
w.firstName,
w.lastName,
se.description sector,
- COUNT(DISTINCT t.id) ticketCount,
- COUNT(st.saleFk) saleCount,
+ COUNT(DISTINCT s.ticketFk) ticketCount,
+ COUNT(sgd.id) saleCount,
IFNULL(ec2.errorsByChecker,0) + IFNULL(pe.errorsByClaim, 0) errors,
wp.volume,
IFNULL(CAST(tc.timeWorkDecimal AS DECIMAL (10,2)) , 0) AS hourWorked,
DATE(vDatedFrom) dated
- FROM vn.saleTracking st
- LEFT JOIN vn.worker w ON w.id = st.workerFk
- LEFT JOIN vn.sale s ON s.id = st.saleFk
- LEFT JOIN vn.item i ON i.id = s.itemFk
- LEFT JOIN vn.sector se ON se.id = i.sectorFk
- LEFT JOIN vn.ticket t ON s.ticketFk = t.id
- LEFT JOIN vncontrol.accion a ON a.accion_id = st.actionFk
+ FROM vn.saleGroupDetail sgd
+ JOIN vn.saleGroup sg on sg.id = sgd.saleGroupFk
+ JOIN vn.sectorCollectionSaleGroup scsg on scsg.saleGroupFk = sgd.saleGroupFk
+ JOIN vn.sectorCollection sc on sc.id = scsg.sectorCollectionFk
+ join vn.sector se on se.id = sc.sectorFk
+ JOIN vn.worker w ON w.id = sc.userFk
+ LEFT JOIN vn.sale s ON s.id = sgd.saleFk
LEFT JOIN tmp.timeControlCalculate tc ON tc.userFk = w.id
- LEFT JOIN bs.workerProductivity wp ON wp.workerFk = w.id AND a.accion = 'PRESACAR'
+ LEFT JOIN bs.workerProductivity wp ON wp.workerFk = w.id
+ LEFT JOIN vncontrol.accion a ON a.accion_id = wp.actionFk AND a.accion = 'PRESACAR'
LEFT JOIN tmp.errorsByChecker ec2 ON ec2.workerFk = w.id
LEFT JOIN tmp.previousErrors pe ON pe.workerFk = w.id
- WHERE DATE(st.created) = vDatedFrom
- AND se.code IN ('ALGEMESI ARTIFI','COMPLEMENTOS')
+ WHERE DATE(sc.created) = vDatedFrom
AND wp.dated = vDatedFrom
GROUP BY w.id;
@@ -77214,6 +65824,8 @@ DELIMITER ;
/*!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 `sector_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77221,8 +65833,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sector_get`()
BEGIN
@@ -77240,6 +65850,8 @@ DELIMITER ;
/*!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 `sector_getWarehouse` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77247,8 +65859,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sector_getWarehouse`(vSectorFk INT)
BEGIN
@@ -77263,49 +65873,85 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `setPlacementReserve` */;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `setParking` */;
/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `setPlacementReserve`(vItemFk INT, vPlacement VARCHAR(10), vWarehouseFk INT )
-BEGIN
+CREATE DEFINER=`root`@`localhost` PROCEDURE `setParking`(IN `vParam` VARCHAR(8), IN `vParkingCode` VARCHAR(8))
+proc: BEGIN
- DECLARE vReserve VARCHAR(10);
- DECLARE vReserveOLD VARCHAR(10);
- DECLARE vPlacementOLD VARCHAR(10);
-
- SELECT code, reserve INTO vPlacementOLD, vReserveOLD
- FROM itemPlacement
- WHERE itemFk = vItemFk
- AND warehouseFk = vWarehouseFk;
-
- IF ASCII(vPlacement) > 57 THEN
-
- SET vReserve = vPlacement;
- SET vPlacement = vPlacementOLD;
-
- ELSE
-
- SET vReserve = vReserveOLD;
-
+/*
+ * Aparca una colección, un ticket, un saleGroup o un shelving en un parking
+ *
+ * @param vParam id del ticket, colección, saleGroup o shelving
+ * @param vParkingCode código del parking
+ *
+ */
+
+ DECLARE vParkingFk INT;
+ DECLARE vIsSaleGroup BOOL;
+ DECLARE vIsTicket BOOL;
+ DECLARE vIsCollection BOOL;
+
+ SET vParkingCode = replace(vParkingCode,' ','');
+
+ SELECT id INTO vParkingFk
+ FROM vn.parking
+ WHERE code = vParkingCode COLLATE utf8_unicode_ci;
+
+ IF vParkingFk IS NULL THEN
+ CALL util.throw('parkingNotExist');
+ LEAVE proc;
+ END IF;
+
+ -- Se comprueba si es una preparación previa
+ SELECT COUNT(*) INTO vIsSaleGroup
+ FROM vn.saleGroup sg
+ WHERE sg.id = vParam;
+
+ IF vIsSaleGroup THEN
+ CALL vn.saleGroup_setParking(vParam, vParkingFk);
+ LEAVE proc;
END IF;
-
- REPLACE itemPlacement(itemFk, warehouseFk, code,reserve)
- VALUES(vItemFk, vWarehouseFk, vPlacement, vReserve);
+ -- Se comprueba si es un ticket
+ SELECT COUNT(*) INTO vIsTicket
+ FROM vn.ticket t
+ WHERE t.id = vParam
+ AND t.shipped >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE());
+ IF vIsTicket THEN
+ CALL vn.ticket_setParking(vParam, vParkingFk);
+ LEAVE proc;
+ END IF;
+
+ -- Se comprueba si es una coleccion de tickets
+ SELECT COUNT(*) INTO vIsCollection
+ FROM vn.collection c
+ WHERE c.id = vParam
+ AND c.created >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE());
+
+ IF vIsCollection THEN
+ CALL vn.collection_setParking(vParam, vParkingFk);
+ LEAVE proc;
+ END IF;
+
+ -- Por descarte, se considera una matrícula
+ CALL vn.shelving_setParking(vParam, vParkingFk);
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 `shelvingChange` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77313,8 +65959,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `shelvingChange`(IN `vShelvingO` VARCHAR(8), IN `vShelvingD` VARCHAR(8))
BEGIN
@@ -77330,185 +65974,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `shelvingFuture__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `shelvingFuture__`(vSectorFk INT)
-BEGIN
-
- DECLARE vDone BOOL DEFAULT FALSE;
- DECLARE vItemFk INT;
- DECLARE vItemShelvingRest INT;
- DECLARE vItemShelvingFk INT;
- DECLARE vItemShelvingCreated DATE;
- DECLARE vSaleRest INT;
- DECLARE vSaleDated DATE;
- DECLARE vWarehouseFk INT;
-
- DECLARE rsItem CURSOR FOR
- SELECT DISTINCT itemFk
- FROM vn.itemShelvingStock
- WHERE sectorFk = vSectorFk
- AND visible > 0;
-
- DECLARE rsItemShelving CURSOR FOR
- SELECT ish.id,
- ish.visible,
- date(ish.created)
- FROM vn.itemShelving ish
- JOIN vn.shelving sh ON sh.code = ish.shelvingFk
- JOIN vn.parking p ON p.id = sh.parkingFk
- WHERE ish.itemFk = vItemFk
- AND ish.visible > 0
- AND p.sectorFk = vSectorFk
- ORDER BY date(ish.created), ish.visible;
-
- DECLARE rsSale CURSOR FOR
- SELECT - floor(sum(io.amount)) as sold,
- date(io.dat) as dated
- FROM vn2008.item_out io
- LEFT JOIN tmp.ticketFree tf ON tf.ticketFk = io.ticketFk
- WHERE (dat BETWEEN util.tomorrow() AND '2019-10-31'
- OR
- (dat BETWEEN CURDATE() AND util.dayEnd(CURDATE()) AND tf.ticketFk IS NOT NULL))
- AND item_id = vItemFk
- AND io.warehouse_id = vWarehouseFk
- GROUP BY dated;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND
- SET vDone = TRUE;
-
- SELECT warehouseFk INTO vWarehouseFk
- FROM vn.sector
- WHERE id = vSectorFk;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketFree;
- CREATE TEMPORARY TABLE tmp.ticketFree
- SELECT ticket as ticketFk
- FROM vn.ticketStateToday tst
- JOIN vn.state s ON s.id = tst.state
- WHERE s.isPicked = FALSE;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.result;
- CREATE TEMPORARY TABLE tmp.result
- SELECT ish.id as itemShelvingFk,
- date(ish.created) as created,
- ish.visible,
- 0 as reserve,
- CAST('2019-10-31' AS DATE) as picked,
- ish.shelvingFk,
- 0 as Litros,
- p.code as parkingCode
- FROM vn.itemShelving ish
- JOIN vn.shelving sh ON sh.code = ish.shelvingFk
- JOIN vn.parking p ON p.id = sh.parkingFk
- WHERE ish.visible > 0
- AND p.sectorFk = vSectorFk
- ORDER BY date(ish.created), ish.visible;
-
- UPDATE tmp.result r
- JOIN (SELECT ish.id, floor(sum(ish.visible * r.cm3) / 1000) as Litros
- FROM vn.itemShelving ish
- JOIN bi.rotacion r ON r.Id_Article = ish.itemFk AND r.warehouse_id = vWarehouseFk
- GROUP BY ish.id) sub ON r.itemShelvingFk = sub.id
- SET r.Litros = sub.Litros;
-
- ALTER TABLE tmp.result
- ADD PRIMARY KEY (itemShelvingFk);
-
- OPEN rsItem;
-
- FETCH rsItem INTO vItemFk;
-
- -- TRUNCATE tmp.log;
-
- WHILE NOT vDone DO
-
- OPEN rsItemShelving;
- OPEN rsSale;
-
- FETCH rsSale INTO vSaleRest, vSaleDated;
- FETCH rsItemShelving INTO vItemShelvingFk, vItemShelvingRest, vItemShelvingCreated;
- /*
- INSERT INTO tmp.log(vItemFk, vItemShelvingRest, vSaleRest, vSalePicked,ifSide)
- VALUES (vItemFk, vItemShelvingRest, vSaleRest, vSaleDated, '0');
- */
- bucle: LOOP
-
- IF vDone THEN
-
- LEAVE bucle;
-
- END IF;
-
- IF vSaleRest >= vItemShelvingRest THEN
- /*
- INSERT INTO tmp.log(vItemFk, vItemShelvingRest, vSaleRest, vSalePicked,ifSide)
- VALUES (vItemFk, vItemShelvingRest, vSaleRest, vSaleDated, '1');
- */
- SET vSaleRest = vSaleRest - vItemShelvingRest;
-
- UPDATE tmp.result
- SET reserve = reserve + vItemShelvingRest,
- picked = LEAST(picked, vSaleDated)
- WHERE itemShelvingFk = vItemShelvingFk;
-
- FETCH rsItemShelving INTO vItemShelvingFk, vItemShelvingRest, vItemShelvingCreated;
-
- IF vSaleRest = 0 THEN
-
- FETCH rsSale INTO vSaleRest, vSaleDated;
-
- END IF;
-
- ELSE
- /*
- INSERT INTO tmp.log(vItemFk, vItemShelvingRest, vSaleRest, vSalePicked,ifSide)
- VALUES (vItemFk, vItemShelvingRest, vSaleRest, vSaleDated, '2');
- */
- SET vItemShelvingRest = vItemShelvingRest - vSaleRest;
-
- UPDATE tmp.result
- SET reserve = reserve + vSaleRest,
- picked = LEAST(picked, vSaleDated)
- WHERE itemShelvingFk = vItemShelvingFk;
-
- FETCH rsSale INTO vSaleRest, vSaleDated;
-
- END IF;
-
- END LOOP;
-
- CLOSE rsItemShelving;
- CLOSE rsSale;
- /*
- INSERT INTO tmp.log(vItemFk, vItemShelvingRest, vSaleRest, vSalePicked,ifSide)
- VALUES (vItemFk, vItemShelvingRest, vSaleRest, vSaleDated, '4');
- */
- SET vDone = FALSE;
-
- FETCH rsItem INTO vItemFk;
-
- END WHILE;
-
- CLOSE rsItem;
-
- SELECT * FROM tmp.result
- ORDER BY created, visible;
-
-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 DROP PROCEDURE IF EXISTS `shelvingLog_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77516,8 +65983,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `shelvingLog_get`(shelvingFk VARCHAR(10))
BEGIN
@@ -77540,6 +66005,8 @@ DELIMITER ;
/*!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 `shelvingPark` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77547,8 +66014,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `shelvingPark`(IN `vParam` VARCHAR(8), IN `vParkingCode` VARCHAR(8))
proc: BEGIN
@@ -77603,7 +66068,7 @@ proc: BEGIN
UPDATE vn.saleGroup sg
SET sg.parkingFk = vParkingFk
WHERE sg.id = vParam
- AND sg.created >= TIMESTAMPADD(WEEK,-1,CURDATE());
+ AND sg.created >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE());
CALL vn.ticket_setNextState(vn.ticket_get(vParam));
@@ -77615,7 +66080,7 @@ proc: BEGIN
SELECT COUNT(*) INTO vIsTicket
FROM vn.ticket t
WHERE t.id = vParam
- AND t.shipped >= TIMESTAMPADD(WEEK,-1,CURDATE());
+ AND t.shipped >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE());
IF vIsTicket THEN
@@ -77650,7 +66115,7 @@ proc: BEGIN
SELECT COUNT(*) INTO vIsCollection
FROM vn.collection c
WHERE c.id = vParam
- AND c.created >= TIMESTAMPADD(WEEK,-1,CURDATE());
+ AND c.created >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE());
IF vIsCollection THEN
@@ -77665,13 +66130,13 @@ proc: BEGIN
-- Por descarte, se considera una matrícula
INSERT INTO vn.shelvingLog (originFk, userFk, action , description)
- SELECT vParam, account.userGetId(), 'update', CONCAT("Cambio parking ",vParam," de ", p.code," a ", vParkingCode)
+ SELECT vParam, account.myUser_getId(), 'update', CONCAT("Cambio parking ",vParam," de ", p.code," a ", vParkingCode)
FROM parking p
JOIN shelving s ON s.parkingFk = p.id
WHERE s.code = vParam COLLATE utf8_unicode_ci;
UPDATE vn.shelving
- SET parkingFk = vParkingFk, parked = NOW(), isPrinted = TRUE
+ SET parkingFk = vParkingFk, parked = util.VN_NOW(), isPrinted = TRUE
WHERE `code` = vParam COLLATE utf8_unicode_ci;
END ;;
@@ -77680,6 +66145,8 @@ DELIMITER ;
/*!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 `shelvingParking_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77687,8 +66154,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `shelvingParking_get`(vShelvingFk VARCHAR(10), vWarehouseFk INT, vDayRange INT)
BEGIN
@@ -77703,7 +66168,7 @@ SELECT s.itemFk,
JOIN vn.ticket t ON t.id = s.ticketFk
LEFT JOIN vn.itemShelvingStock ist ON ist.itemFk = s.itemFk AND ist.warehouseFk = vWarehouseFk
JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk AND ish.shelvingFk = vShelvingFk COLLATE utf8_general_ci
- WHERE t.shipped BETWEEN CURDATE() AND util.dayend(TIMESTAMPADD(DAY, GREATEST(0,vDayRange), CURDATE()))
+ WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(TIMESTAMPADD(DAY, GREATEST(0,vDayRange), util.VN_CURDATE()))
AND iss.saleFk IS NULL
AND t.warehouseFk = vWarehouseFk
GROUP BY s.itemFk
@@ -77716,118 +66181,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `shelvingPark__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `shelvingPark__`(IN `vParam` VARCHAR(8), IN `vParkingCode` VARCHAR(8))
-proc: BEGIN
-
- /* Aparca una colección, un ticket, un saleGroup o un shelving en un parking
- *
- * @param vParam
- *
- */
- DECLARE vParkingFk INT;
- DECLARE vColumn VARCHAR(3);
- DECLARE vRow VARCHAR(2);
- DECLARE vReturn VARCHAR(50);
- DECLARE vIsSaleGroup BOOL;
- DECLARE vIsTicket BOOL;
- DECLARE vIsCollection BOOL;
-
- SET vParkingCode = replace(vParkingCode,' ','') ;
-
- SELECT id INTO vParkingFk
- FROM vn.parking
- WHERE code = vParkingCode COLLATE utf8_unicode_ci;
-
- IF vParkingFk IS NULL THEN
-
- LEAVE proc;
-
- END IF;
-
- -- Se comprueba si es una preparación previa
- SELECT COUNT(*) INTO vIsSaleGroup
- FROM vn.saleGroup sg
- WHERE sg.id = vParam;
-
- IF vIsSaleGroup THEN
-
- UPDATE vn.saleGroup sg
- SET sg.parkingFk = vParkingFk
- WHERE sg.id = vParam
- AND sg.created >= TIMESTAMPADD(WEEK,-1,CURDATE());
-
- CALL vn.ticket_setPreviousState(vn.ticket_get(vParam));
-
- LEAVE proc;
-
- END IF;
-
- -- Se comprueba si es un ticket
- SELECT COUNT(*) INTO vIsTicket
- FROM vn.ticket t
- WHERE t.id = vParam
- AND t.shipped >= TIMESTAMPADD(WEEK,-1,CURDATE());
-
- IF vIsTicket THEN
-
- REPLACE vn.ticketParking(ticketFk,parkingFk)
- VALUES (vParam, vParkingFk);
-
- CALL vn.ticket_setPreviousState(vParam);
-
- LEAVE proc;
-
- END IF;
-
- -- Se comprueba si es una coleccion de tickets
- SELECT COUNT(*) INTO vIsCollection
- FROM vn.collection c
- WHERE c.id = vParam
- AND c.created >= TIMESTAMPADD(WEEK,-1,CURDATE());
-
- IF vIsCollection THEN
-
- REPLACE vn.ticketParking(ticketFk,parkingFk)
- SELECT tc.ticketFk, vParkingFk
- FROM vn.ticketCollection tc
- WHERE tc.collectionFk = vParam;
-
- LEAVE proc;
-
- END IF;
-
- -- Por descarte, se considera una matrícula
- INSERT INTO vn.shelvingLog (originFk, userFk, action , description)
- SELECT vParam, getUser(), 'update', CONCAT("Cambio parking ",vParam," de ", p.code," a ", vParkingCode)
- FROM parking p
- JOIN shelving s ON s.parkingFk = p.id
- WHERE s.code = vParam COLLATE utf8_unicode_ci;
-
- UPDATE vn.shelving
- SET parkingFk = vParkingFk, parked = NOW(), isPrinted = 1
- WHERE `code` = vParam COLLATE utf8_unicode_ci;
-
- SELECT (COUNT(*) > 0) AS IsUpdated
- FROM vn.shelving
- WHERE parkingFk = vParkingFk
- AND `code` = vParam COLLATE utf8_unicode_ci;
-
-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 DROP PROCEDURE IF EXISTS `shelvingPriority_update` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77835,8 +66190,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `shelvingPriority_update`(priority INT,vShelvingFk VARCHAR(10))
BEGIN
@@ -77849,6 +66202,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `shelving_clean` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77856,25 +66211,23 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `shelving_clean`()
BEGIN
DELETE FROM vn.shelving
WHERE length(code) > 3
- AND parked < TIMESTAMPADD(WEEK,-1,CURDATE());
+ AND parked < TIMESTAMPADD(WEEK,-1,util.VN_CURDATE());
DELETE FROM vn.itemShelving
WHERE visible <= 0
- AND created < TIMESTAMPADD(MONTH,-1,CURDATE());
+ AND created < TIMESTAMPADD(MONTH,-1,util.VN_CURDATE());
DELETE ish.*
FROM vn.itemShelving ish
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
WHERE sh.parkingFk IS NULL
- AND ish.created < TIMESTAMPADD(WEEK,-1,CURDATE());
+ AND ish.created < TIMESTAMPADD(WEEK,-1,util.VN_CURDATE());
UPDATE vn.shelving sh
LEFT JOIN vn.itemShelving its ON its.shelvingFk = sh.`code`
@@ -77884,7 +66237,7 @@ BEGIN
AND sh.isRecyclable
AND ( sh.parked IS NULL
OR
- sh.parked < TIMESTAMPADD(MONTH,-1,CURDATE())
+ sh.parked < TIMESTAMPADD(MONTH,-1,util.VN_CURDATE())
);
END ;;
@@ -77893,6 +66246,8 @@ DELIMITER ;
/*!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 `shelving_getSpam` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77900,8 +66255,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `shelving_getSpam`(vDated DATE, vWarehouseFk INT)
BEGIN
@@ -77941,14 +66294,14 @@ BEGIN
LEFT JOIN (
SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as venta
FROM vn2008.item_out
- WHERE dat BETWEEN CURDATE() AND util.dayend(vDated)
+ WHERE dat BETWEEN util.VN_CURDATE() AND util.dayend(vDated)
AND warehouse_id = vWarehouseFk
GROUP BY item_id
) sale ON sale.item_id = i.id
LEFT JOIN (
SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as compra
FROM vn2008.item_entry_in
- WHERE dat BETWEEN CURDATE() AND util.dayend(vDated)
+ WHERE dat BETWEEN util.VN_CURDATE() AND util.dayend(vDated)
AND warehouse_id = vWarehouseFk
AND isVirtualStock = FALSE
GROUP BY item_id
@@ -77956,7 +66309,7 @@ BEGIN
LEFT JOIN (
SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as traslado
FROM vn2008.item_entry_out
- WHERE dat BETWEEN CURDATE() AND util.dayend(vDated)
+ WHERE dat BETWEEN util.VN_CURDATE() AND util.dayend(vDated)
AND warehouse_id = vWarehouseFk
GROUP BY item_id
) mov ON mov.item_id = i.id
@@ -77979,7 +66332,7 @@ BEGIN
JOIN vn.warehouse w ON w.id = s.warehouseFk
LEFT JOIN tmp.stock s ON s.itemFk = ish.itemFk
WHERE (w.name = 'Algemesi'
- OR (w.name = 'NuncaJamas' AND ish.created < curdate()))
+ OR (w.name = 'NuncaJamas' AND ish.created < util.VN_CURDATE()))
AND ish.visible
GROUP BY ish.shelvingFk
HAVING lineas = spam OR isSpam;
@@ -77992,139 +66345,44 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `silla_algemesi__` */;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `shelving_setParking` */;
/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `silla_algemesi__`(vDate DATE, vItemFk INT, vQuantity INT)
-BEGIN
+CREATE DEFINER=`root`@`localhost` PROCEDURE `shelving_setParking`(IN `vShelvingCode` VARCHAR(8), IN `vParkingFk` INT)
+proc: BEGIN
-DECLARE done INT DEFAULT FALSE;
-DECLARE vWarehouseFk INT DEFAULT 60;
-DECLARE vTicketFk INT;
-DECLARE vSaleFk INT;
-DECLARE vClonTicket INT DEFAULT 0;
-DECLARE i INT DEFAULT 0;
+/*
+ * Aparca una matrícula en un parking
+ *
+ * @param vShelvingCode code de la matrícula
+ * @param vParkingFk id del parking
+ *
+ */
-DECLARE cur1 CURSOR FOR
- select distinct s.ticketFk, s.id
- from vn.sale s
- join vn.ticket t ON t.id = s.ticketFk
- left join vn.ticketStateToday tss ON tss.ticket = t.id
- join vn.itemShelving ish ON ish.itemFk = s.itemFk
- join vn.shelving sh ON sh.code = ish.shelvingFk
- join vn.parking p ON p.id = sh.parkingFk
- where t.shipped between vDate and util.dayend(vDate)
- and p.sectorFk = 37
- and left(t.nickname,1) != '-'
- and t.warehouseFk = 1
- and s.quantity mod ish.packing = 0
- and vItemFk IN (0,s.itemFk)
- and IFNULL(tss.alertLevel,0) = 0
- and s.quantity >= ish.packing
- and s.quantity >= vQuantity
- and s.itemFk NOT IN (1, 130, 60002, 1778, 3899);
+INSERT INTO vn.shelvingLog (originFk, userFk, action , description)
+ SELECT vShelvingCode, account.myUser_getId(), 'update', CONCAT("Cambio parking ",vShelvingCode," de ", p.code," a ", vParkingFk)
+ FROM parking p
+ JOIN shelving s ON s.parkingFk = p.id
+ WHERE s.code = vShelvingCode COLLATE utf8_unicode_ci;
-
-DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
-
-OPEN cur1;
-
-FETCH cur1 INTO vTicketFk, vSaleFk;
-
- WHILE done = 0 DO
-
- SELECT t.id INTO vClonTicket
- FROM vn.ticket t
- JOIN (SELECT t.addressFk, t.shipped
- FROM vn.ticket t
- LEFT JOIN vn.ticketStateToday tss ON tss.ticket = t.id
- WHERE id = vTicketFk
- and IFNULL(tss.alertLevel,0) = 0 ) sub USING(addressFk, shipped)
- WHERE t.warehouseFk = vWarehouseFk
- LIMIT 1;
-
- -- SELECT vTicketFk, vClonTicket;
-
- IF vClonTicket = 0 THEN
-
- INSERT INTO ticket (
- clientFk,
- shipped,
- addressFk,
- agencyModeFk,
- nickname,
- warehouseFk,
- companyFk,
- landed,
- zoneFk,
- zonePrice,
- zoneBonus,
- routeFk
- )
- SELECT
- clientFk,
- shipped,
- addressFk,
- agencyModeFk,
- nickname,
- vWarehouseFk,
- companyFk,
- landed,
- zoneFk,
- zonePrice,
- zoneBonus,
- routeFk
-
- FROM ticket
- WHERE id = vTicketFk;
-
- SET vClonTicket = LAST_INSERT_ID();
-
- -- SELECT 'lstID', vClonTicket;
-
- INSERT IGNORE INTO ticketObservation(ticketFk, observationTypeFk, description)
- SELECT vClonTicket, ao.observationTypeFk, ao.description
- FROM addressObservation ao
- JOIN ticket t ON t.addressFk = ao.addressFk
- WHERE t.id = vTicketFk;
-
- INSERT IGNORE INTO ticketLog
- SET originFk = vClonTicket, userFk = account.myUser_getId(), `action` = 'insert',
- description = CONCAT('Ha creado el ticket:', ' ', vClonTicket, ' clonando el ', vTicketFk);
-
- END IF;
-
- UPDATE vn.sale
- SET ticketFk = vClonTicket
- WHERE id = vSaleFk;
- -- SELECT vTicketFk, vClonTicket;
-
- SET vClonTicket = 0;
-
- SET done = 0;
- FETCH cur1 INTO vTicketFk, vSaleFk;
-
- SET i = i + 1;
-
- END WHILE;
-
- CLOSE cur1;
-
- SELECT i;
-
+ UPDATE vn.shelving
+ SET parkingFk = vParkingFk, parked = util.VN_NOW(), isPrinted = TRUE
+ WHERE code = vShelvingCode COLLATE utf8_unicode_ci;
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 `sleep_X_min` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -78132,8 +66390,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sleep_X_min`()
BEGIN
@@ -78147,6 +66403,8 @@ DELIMITER ;
/*!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 `solunionRiskRequest` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -78154,8 +66412,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `solunionRiskRequest`()
BEGIN
@@ -78167,9 +66423,10 @@ BEGIN
SELECT * FROM (SELECT cc.client Id_Cliente, ci.grade FROM vn.creditClassification cc
JOIN vn.creditInsurance ci ON cc.id = ci.creditClassification
WHERE dateEnd IS NULL
- ORDER BY ci.creationDate DESC) t1 GROUP BY Id_Cliente;
+ ORDER BY ci.creationDate DESC
+ LIMIT 10000000000000000000) t1 GROUP BY Id_Cliente;
- CALL vn2008.risk_vs_client_list(CURDATE());
+ CALL vn2008.risk_vs_client_list(util.VN_CURDATE());
SELECT
c.Id_Cliente, c.Cliente, c.Credito credito_vn, c.creditInsurance solunion, cast(r.risk as DECIMAL(10,0)) riesgo_vivo,
@@ -78190,6 +66447,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `stockBuyedByWorker` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -78197,8 +66456,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `stockBuyedByWorker`(vDate DATE, vWorker INT)
BEGIN
@@ -78228,41 +66485,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `stockBuyedByWorkerTest__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `stockBuyedByWorkerTest__`(vDate DATE, vWorker INT)
-BEGIN
-
- DECLARE vVolume DECIMAL(10,2);
- DECLARE vWarehouse INT DEFAULT 7;
- CALL stockTraslationTest(vDate);
-
- SELECT Volumen INTO vVolume FROM vn2008.Cubos WHERE Id_Cubo = 'cc' LIMIT 1;
-
- SELECT c.Id_Entrada, a.Id_Article, a.Article, i.amount Cantidad, (0.6 * ( i.amount / c.packing ) * vn.buy_getVolume(Id_Compra))/vVolume buyed
- FROM tmp.item i
- JOIN vn2008.Articles a ON a.Id_Article = i.item_id
- JOIN vn2008.Tipos t ON a.tipo_id = t.tipo_id
- JOIN vn2008.reinos r ON r.id = t.reino_id
- JOIN vn2008.Trabajadores tr ON tr.Id_Trabajador = t.Id_Trabajador
- JOIN vn2008.t_item_last_buy ilb ON ilb.item_id = a.Id_Article AND ilb.warehouse_id = vWarehouse
- JOIN vn2008.Compres c ON c.Id_compra = ilb.buy_id
- WHERE r.display <> 0 AND tr.user_id = vWorker;
- DROP TEMPORARY TABLE IF EXISTS tmp_item;
-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 DROP PROCEDURE IF EXISTS `stockBuyed_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -78270,8 +66494,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `stockBuyed_add`(vDated DATE)
BEGIN
@@ -78326,6 +66548,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `stockTraslation` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -78333,8 +66557,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `stockTraslation`(vDate DATE)
BEGIN
@@ -78355,7 +66577,7 @@ BEGIN
SELECT item_id, SUM(amount) amount
FROM vn2008.item_entry_in
WHERE dat = vDate
- AND vDate >= CURDATE()
+ AND vDate >= util.VN_CURDATE()
AND warehouse_id = vWarehouse
AND isVirtualStock is FALSE
GROUP BY item_id
@@ -78377,202 +66599,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `stockTraslationTest__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `stockTraslationTest__`(vDate DATE)
-BEGIN
- /**
- * Calcula el stock del vWarehouse desde FechaInventario hasta v_date
- sin tener en cuenta las salidas del mismo dia vDate
- para ver el transporte a reservar
- **/
-
- DECLARE vWarehouse INT DEFAULT 7;
-
- DELETE FROM stockBuyed WHERE `date` = vDate;
- DROP TEMPORARY TABLE IF EXISTS tmp.item;
-
- CREATE TEMPORARY TABLE tmp.item (
- `item_id` INT,
- `amount` DECIMAL(10, 2) DEFAULT 0.00,
- PRIMARY KEY(item_id)
- ) ENGINE = MEMORY;
-
-
- IF vDate >= CURDATE() THEN
- INSERT INTO tmp.item
- SELECT item_id, SUM(amount) amount
- FROM vn2008.item_entry_in
- WHERE dat = vDate
- AND warehouse_id = vWarehouse
- GROUP BY item_id HAVING amount != 0;
- END IF;
-
- CALL `cache`.stock_refresh (FALSE);
-
- INSERT INTO tmp.item (item_id,amount)
- SELECT item_id,s.amount FROM `cache`.stock s
- WHERE warehouse_id = vWarehouse
- ON DUPLICATE KEY UPDATE
- amount = tmp.item.amount + VALUES(amount);
-
- CALL vn2008.item_last_buy_(vWarehouse,vDate);
-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 DROP PROCEDURE IF EXISTS `stowawayBoarding__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `stowawayBoarding__`(IN vShipFk INT, IN vStowawayFk INT)
-BEGIN
-
- REPLACE stowaway(shipFk, id)
- VALUES (vShipFk, vStowawayFk);
-
- INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador)
- SELECT id, vShipFk, myWorker_getId()
- FROM state
- WHERE code = 'BOARDING';
-
- -- FIXME No crear ticket 98
- INSERT INTO sale(ticketFk, itemFk, quantity, concept)
- VALUES(vShipFk, 98,1, CONCAT('POLIZÓN! ',vStowawayFk));
-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 DROP PROCEDURE IF EXISTS `stowawayControl__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `stowawayControl__`(vDated DATE)
-BEGIN
-
- SELECT t.id ticketFV,
- tst.code as stateFV,
- sw.id ticketPCA,
- w.code,
- w.firstName,
- w.lastName,
- s.itemFk,
- s.concept,
- MAX(IF(s.isPicked,'OK',st.code)) situacion
- FROM vn.ticket t
- LEFT JOIN vn.ticketState tst ON tst.ticketFk = t.id
- JOIN vn.stowaway sw ON sw.shipFk = t.id
- LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = t.id
- LEFT JOIN vn.collection c ON c.id = tc.collectionFk
- LEFT JOIN vn.worker w ON w.id = c.workerFk
- JOIN vn.sale s ON s.ticketFk = sw.id
- LEFT JOIN vn.saleTracking str ON str.saleFk = s.id AND str.isChecked = 1
- LEFT JOIN vn.state st ON st.id = str.stateFk AND st.code = 'PREPARED'
- WHERE t.shipped BETWEEN vDated AND util.dayend(vDated)
- GROUP BY s.id;
-
-
-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 DROP PROCEDURE IF EXISTS `stowaway_launchShip__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `stowaway_launchShip__`(vStowawayFk INT)
-BEGIN
-
- DECLARE myShipFk INT;
-
- SELECT shipFk INTO myShipFk
- FROM vn.stowaway
- WHERE id = vStowawayFk;
-
- IF myShipFk THEN
-
- INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador)
- SELECT id, myShipFk, account.myUser_getId()
- FROM state
- WHERE code = 'OK STOWAWAY';
-
- 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 DROP PROCEDURE IF EXISTS `stowaway_unboarding__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `stowaway_unboarding__`(vShipFk INT, vStowawayFk INT)
-BEGIN
- DECLARE vWorker VARCHAR(255);
-
- DELETE FROM stowaway
- WHERE shipFk = vShipFk AND id = vStowawayFk;
-
- DELETE tt FROM ticketTracking tt
- JOIN state s ON s.id = tt.stateFk
- WHERE code = 'BOARDING' AND ticketFk = vShipFk;
-
- DELETE FROM sale
- WHERE ticketFk = vShipFk
- AND itemFk = 98
- AND concept = CONCAT('POLIZÓN! ',vStowawayFk);
-
- SELECT u.`name` INTO vWorker
- FROM account.user u JOIN worker w ON w.userFk = u.id
- WHERE w.id = client_getSalesPersonByTicket(vStowawayFk);
-
- SELECT messageSend(vWorker,CONCAT('El ticket: ', vStowawayFk, ' ha dejado de ser un polizón')) INTO @a;
-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 DROP PROCEDURE IF EXISTS `subordinateGetList` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -78580,8 +66608,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `subordinateGetList`(vBossFk INT)
BEGIN
@@ -78636,6 +66662,8 @@ DELIMITER ;
/*!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 `supplierExpenses` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -78643,8 +66671,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `supplierExpenses`(vEnded DATE)
BEGIN
@@ -78728,6 +66754,8 @@ DELIMITER ;
/*!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 `supplierPackaging_ReportSource` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -78735,8 +66763,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `supplierPackaging_ReportSource`(vFromDated DATE, vSupplierFk INT)
BEGIN
@@ -78890,6 +66916,8 @@ DELIMITER ;
/*!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 `supplier_checkBalance` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -78897,8 +66925,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `supplier_checkBalance`(IN vDateTo DATETIME, IN vIsConciliated BOOL)
BEGIN
@@ -78945,6 +66971,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `supplier_disablePayMethodChecked` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -78952,8 +66980,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `supplier_disablePayMethodChecked`()
BEGIN
@@ -78969,7 +66995,7 @@ BEGIN
FROM vn.payment p
LEFT JOIN vn.supplier s ON s.id = p.supplierFk
LEFT JOIN vn.payMethod pm ON pm.id = s.payMethodFk
- WHERE p.created < (CURDATE() - INTERVAL pm.graceMonthsDisableChecked MONTH)
+ WHERE p.created < (util.VN_CURDATE() - INTERVAL pm.graceMonthsDisableChecked MONTH)
AND pm.graceMonthsDisableChecked
AND s.isPayMethodChecked
GROUP BY p.supplierFk) sdpmc ON sdpmc.supplierFk = s.id
@@ -78981,6 +67007,8 @@ DELIMITER ;
/*!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 `test` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -78988,8 +67016,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `test`()
BEGIN
@@ -79000,6 +67026,8 @@ DELIMITER ;
/*!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 `ticketBoxesView` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -79007,8 +67035,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketBoxesView`(IN vTicketFk INT)
BEGIN
@@ -79038,6 +67064,8 @@ DELIMITER ;
/*!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 `ticketBuiltTime` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -79045,8 +67073,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketBuiltTime`(vDate DATE)
BEGIN
@@ -79073,6 +67099,7 @@ BEGIN
vncontrol.inter
WHERE odbc_date BETWEEN vDateStart AND vDateEnd
ORDER BY Id_Ticket, odbc_date DESC
+ LIMIT 10000000000000000000
) sub
GROUP BY ticketFk
) sub2 ON sub2.ticketFk = t.id
@@ -79088,6 +67115,8 @@ DELIMITER ;
/*!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 `ticketCalculateClon` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -79095,8 +67124,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCalculateClon`(IN vTicketNew INT, vTicketOld INT)
BEGIN
@@ -79188,102 +67215,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `ticketCalculateClon__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCalculateClon__`(IN vTicketNew INT, vTicketOld INT)
-BEGIN
- /*
- * @vTicketNew id del nuevo ticket clonado
- * @vTicketOld id ticket original, a partir del qual se clonara el nuevo
- * Este procedimiento "rebioniza" una linea, eliminando los componentes existentes e insertandolos de nuevo
- */
- DECLARE vShipped DATE;
- DECLARE vClient INT;
- DECLARE vWarehouse SMALLINT;
- DECLARE vAgencyMode INT;
- DECLARE vAddress INT;
- DECLARE vLanded DATE;
- DECLARE vAgency INT;
- DECLARE vZoneFk INT;
-
- REPLACE INTO orderTicket(orderFk,ticketFk)
- SELECT orderFk, vTicketNew
- FROM orderTicket
- WHERE ticketFk = vTicketOld;
-
- SELECT t.clientFk, t.warehouseFk, date(t.shipped), t.addressFk, t.agencyModeFk, t.landed, a.agencyFk, t.zoneFk
- INTO vClient, vWarehouse, vShipped, vAddress, vAgencyMode, vLanded, vAgency, vZoneFk
- FROM vn.agencyMode a
- JOIN vn.ticket t ON t.agencyModeFk = a.id
- WHERE t.id = vTicketNew;
-
- IF vLanded IS NULL THEN
- CALL zone_getLanded(vShipped, vAddress, vAgency, vWarehouse);
- UPDATE ticket t
- JOIN tmp.zoneGetLanded zgl ON t.warehouseFk = zgl.warehouseFk
- SET t.landed = zgl.landed,
- t.zone = zgl.zoneFk
- WHERE t.id = vTicketNew;
-
- SELECT zoneFk INTO vZoneFk FROM tmp.zoneGetLanded LIMIT 1;
- DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetLanded;
- END IF;
-
- -- rellena la tabla tmp.buyUltimate con la ultima compra
- CALL buyUltimate(vWarehouse, vShipped);
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
- CREATE TEMPORARY TABLE tmp.ticketLot
- SELECT vWarehouse warehouseFk, NULL available, s.itemFk, bu.buyFk
- FROM sale s
- LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
- WHERE s.ticketFk = vTicketOld GROUP BY s.itemFk;
-
- CALL catalog_componentCalculate(vZoneFk, vAddress, vAgencyMode);
-
- -- Bionizamos lineas con Preu = 0
- DROP TEMPORARY TABLE IF EXISTS tmp.sale;
- CREATE TEMPORARY TABLE tmp.sale
- (PRIMARY KEY (saleFk)) ENGINE = MEMORY
- SELECT s.id saleFk, vWarehouse warehouseFk
- FROM sale s
- JOIN ticket t on t.id = s.ticketFk WHERE s.ticketFk = vTicketNew AND s.price = 0;
-
- CALL ticketComponentUpdateSale(1);
-
- -- Bionizamos lineas con Preu > 0
- DROP TEMPORARY TABLE IF EXISTS tmp.sale;
- CREATE TEMPORARY TABLE tmp.sale
- (PRIMARY KEY (saleFk)) ENGINE = MEMORY
- SELECT s.id saleFk, vWarehouse warehouseFk
- FROM sale s
- JOIN ticket t on t.id = s.ticketFk WHERE s.ticketFk = vTicketNew
- AND s.price > 0;
-
- CALL ticketComponentUpdateSale(6);
-
- -- Log
- CALL `logAdd`(vTicketNew, 'update', ' ticket' , 'Bioniza Ticket');
-
- -- Limpieza
- DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimate;
- DROP TEMPORARY TABLE IF EXISTS tmp.sale;
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
- DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetLanded;
-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 DROP PROCEDURE IF EXISTS `ticketCalculateFromType` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -79291,8 +67224,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCalculateFromType`( vLanded DATE,
vAddressFk INT,
@@ -79315,6 +67246,8 @@ DELIMITER ;
/*!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 `ticketCalculatePurge` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -79322,8 +67255,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCalculatePurge`()
BEGIN
@@ -79339,231 +67270,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `ticketCalculateSaleForcePrice2__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCalculateSaleForcePrice2__`(IN vSale BIGINT)
-proc: BEGIN
-
- DECLARE vShipped DATE;
- DECLARE vWarehouseFk SMALLINT;
- DECLARE vAddressFk INT;
- DECLARE vTicket BIGINT;
- DECLARE vItem BIGINT;
- DECLARE vZoneFk INT;
-
- SELECT ticketFk, itemFk
- INTO vTicket, vItem
- FROM sale
- WHERE id = vSale;
-
- SELECT t.warehouseFk, DATE(t.shipped), t.addressFk, t.zoneFk
- INTO vWarehouseFk, vShipped, vAddressFk, vZoneFk
- FROM agencyMode a
- JOIN ticket t ON t.agencyModeFk = a.id
- WHERE t.id = vTicket;
-
- IF vZoneFk IS NULL THEN
- CALL util.throw('ticket without zone');
- END IF;
-
- CALL buyUltimate (vWarehouseFk, vShipped);
-
- DELETE FROM tmp.buyUltimate WHERE itemFk != vItem;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
- CREATE TEMPORARY TABLE tmp.ticketLot
- SELECT vWarehouseFk warehouseFk, NULL available, vItem itemFk, buyFk
- FROM tmp.buyUltimate
- WHERE itemFk = vItem;
-
- CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped);
-
- DROP TEMPORARY TABLE IF EXISTS tmp.sale;
- CREATE TEMPORARY TABLE tmp.sale
- (PRIMARY KEY (saleFk)) ENGINE = MEMORY
- SELECT vSale saleFk,vWarehouseFk warehouseFk;
-
- CALL ticketComponentUpdateSale(1);
-
- INSERT INTO vn.ticketLog (originFk, userFk, `action`, description)
- VALUES (vTicket, account.userGetId(), 'update', CONCAT('Bionizo linea id ', vSale));
-
- DROP TEMPORARY TABLE tmp.buyUltimate;
-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 DROP PROCEDURE IF EXISTS `ticketCalculateSaleForcePrice__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCalculateSaleForcePrice__`(IN vSale BIGINT)
-proc: BEGIN
-
- DECLARE vShipped DATE;
- DECLARE vWarehouseFk SMALLINT;
- DECLARE vAddressFk INT;
- DECLARE vTicket BIGINT;
- DECLARE vItem BIGINT;
- DECLARE vZoneFk INT;
-
- SELECT ticketFk, itemFk
- INTO vTicket, vItem
- FROM sale
- WHERE id = vSale;
-
- SELECT t.warehouseFk, DATE(t.shipped), t.addressFk, t.zoneFk
- INTO vWarehouseFk, vShipped, vAddressFk, vZoneFk
- FROM agencyMode a
- JOIN ticket t ON t.agencyModeFk = a.id
- WHERE t.id = vTicket;
-
- IF vZoneFk IS NULL THEN
- CALL util.throw('ticket without zone');
- END IF;
-
- CALL buyUltimate (vWarehouseFk, vShipped);
-
- DELETE FROM tmp.buyUltimate WHERE itemFk != vItem;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
- CREATE TEMPORARY TABLE tmp.ticketLot
- SELECT vWarehouseFk warehouseFk, NULL available, vItem itemFk, buyFk
- FROM tmp.buyUltimate
- WHERE itemFk = vItem;
-
- CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped);
-
- DROP TEMPORARY TABLE IF EXISTS tmp.sale;
- CREATE TEMPORARY TABLE tmp.sale
- (PRIMARY KEY (saleFk)) ENGINE = MEMORY
- SELECT vSale saleFk,vWarehouseFk warehouseFk;
-
- CALL ticketComponentUpdateSale(1);
-
- INSERT INTO vn.ticketLog (originFk, userFk, `action`, description)
- VALUES (vTicket, account.userGetId(), 'update', CONCAT('Bionizo linea id ', vSale));
-
- DROP TEMPORARY TABLE tmp.buyUltimate;
-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 DROP PROCEDURE IF EXISTS `ticketCalculateSale__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCalculateSale__`(IN vSale BIGINT)
-proc: BEGIN
--- OBSOLETO USAR: sale_calculateComponent(vSale, NULL)
- DECLARE vShipped DATE;
- DECLARE vWarehouseFk SMALLINT;
- DECLARE vAgencyModeFk INT;
- DECLARE vAddressFk INT;
- DECLARE vTicket BIGINT;
- DECLARE vItem BIGINT;
- DECLARE vLanded DATE;
- DECLARE vTicketFree BOOLEAN DEFAULT TRUE;
- DECLARE vZoneFk INTEGER;
-
- SELECT NOT (t.refFk IS NOT NULL OR ts.alertLevel > 0) OR s.price = 0, s.ticketFk, s.itemFk , t.zoneFk
- INTO vTicketFree, vTicket, vItem, vZoneFk
- FROM vn.ticket t
- JOIN vn.sale s ON s.ticketFk = t.id
- LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id
- WHERE s.id = vSale
- LIMIT 1;
-
- SELECT t.warehouseFk, DATE(t.shipped), t.addressFk, t.agencyModeFk, t.landed
- INTO vWarehouseFk, vShipped, vAddressFk, vAgencyModeFk, vLanded
- FROM agencyMode a
- JOIN ticket t ON t.agencyModeFk = a.id
- WHERE t.id = vTicket;
-
- IF IFNULL(vZoneFk,0) = 0 THEN
- CALL util.throw('ticket dont have zone');
- END IF;
-
- CALL buyUltimate (vWarehouseFk, vShipped);
-
- DELETE FROM tmp.buyUltimate WHERE itemFk != vItem;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
- CREATE TEMPORARY TABLE tmp.ticketLot
- SELECT vWarehouseFk warehouseFk, NULL available, vItem itemFk, buyFk, vZoneFk zoneFk
- FROM tmp.buyUltimate
- WHERE itemFk = vItem;
-
- CALL vn.catalog_componentCalculate;
- CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk);
-
- DROP TEMPORARY TABLE IF EXISTS tmp.sale;
- CREATE TEMPORARY TABLE tmp.sale
- (PRIMARY KEY (saleFk)) ENGINE = MEMORY
- SELECT vSale saleFk,vWarehouseFk warehouseFk;
-
- CALL ticketComponentUpdateSale(IF(vTicketFree,1,6));
-
- INSERT INTO vn.ticketLog (originFk, userFk, `action`, description)
- VALUES (vTicket, account.userGetId(), 'update', CONCAT('Bionizo linea id ', vSale));
-
- CALL catalog_componentPurge();
- DROP TEMPORARY TABLE tmp.buyUltimate;
- DROP TEMPORARY TABLE IF EXISTS tmp.sale;
-
-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 DROP PROCEDURE IF EXISTS `ticketCalculate__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCalculate__`(
- vLanded DATE,
- vAddressFk INT,
- vAgencyModeFk INT)
-proc: BEGIN
--- OBSOLETO utilizar catalog_calculate
- CALL vn.catalog_calculate(vLanded, vAddressFk, vAgencyModeFk);
-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 DROP PROCEDURE IF EXISTS `ticketClon` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -79571,8 +67279,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketClon`(vTicketFk INT, vNewShipped DATE)
BEGIN
@@ -79589,7 +67295,7 @@ BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
- SET vNewShipped = IFNULL(vNewShipped, CURDATE());
+ SET vNewShipped = IFNULL(vNewShipped, util.VN_CURDATE());
CALL vn.ticket_Clone(vTicketFk, vNewTicketFk);
@@ -79632,6 +67338,8 @@ DELIMITER ;
/*!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 `ticketClon_OneYear` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -79639,8 +67347,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketClon_OneYear`(vTicketFk INT)
BEGIN
@@ -79667,170 +67373,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `ticketClosureAgencyListAdd__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketClosureAgencyListAdd__`(vAgencyModeFk INT)
-BEGIN
-/**
- * Prepara un listado de agencias sobre los que se realizará el cierre.
- * Es necesario llamar al procedimiento por cada agencia.
- *
- * @param vAgencyModeFk Id almacén
- */
- CREATE TEMPORARY TABLE IF NOT EXISTS tmp.ticketClosureAgencyList (
- `agencyModeFk` INT,
- PRIMARY KEY(agencyModeFk)) ENGINE = MEMORY;
-
- INSERT INTO tmp.ticketClosureAgencyList(agencyModeFk) VALUES(vAgencyModeFk);
-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 DROP PROCEDURE IF EXISTS `ticketClosureAgencyList__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketClosureAgencyList__`(vWarehouseFk INT, vDateTo DATE)
-BEGIN
-/**
- * Inserta los tickets de todos los almacenes en la tabla temporal
- * para ser cerrados.
- *
- * @param vWarehouseFk Id del almacén
- * @param vDate Fecha del cierre
- */
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketClosure;
-
- CREATE TEMPORARY TABLE tmp.ticketClosure ENGINE = MEMORY (
- SELECT
- t.id AS ticketFk
- FROM expedition e
- INNER JOIN ticket t ON t.id = e.ticketFk
- INNER JOIN tmp.ticketClosureAgencyList al ON al.agencyModeFk = t.agencyModeFk
- LEFT JOIN ticketState ts ON ts.ticketFk = t.id
- WHERE
- ts.alertLevel = 2
- AND t.warehouseFk = vWarehouseFk
- AND DATE(t.shipped) BETWEEN DATE_ADD(vDateTo, INTERVAL -2 DAY) AND vDateTo
- AND t.refFk IS NULL
- GROUP BY e.ticketFk);
-
- DROP TEMPORARY TABLE tmp.ticketClosureAgencyList;
-
- CALL ticketClosure();
-
- DROP TEMPORARY TABLE tmp.ticketClosure;
-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 DROP PROCEDURE IF EXISTS `ticketClosureRoute__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketClosureRoute__`( vRouteFk INT)
-BEGIN
-/**
- * Inserta los tickets de la ruta en la tabla temporal
- * para ser cerrados.
- *
- * @param vWarehouseFk Almacén a cerrar
- * @param vRouteFk Ruta a cerrar
- * @param vDate Fecha del cierre
- */
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketClosure;
-
- CREATE TEMPORARY TABLE tmp.ticketClosure ENGINE = MEMORY (
- SELECT
- t.id AS ticketFk
- FROM expedition e
- INNER JOIN ticket t ON t.id = e.ticketFk
- LEFT JOIN ticketState ts ON ts.ticketFk = t.id
- WHERE
- ts.alertLevel = 2
- AND t.routeFk = vRouteFk
- AND t.refFk IS NULL
- GROUP BY e.ticketFk);
-
- CALL ticketClosure();
-
- DROP TEMPORARY TABLE tmp.ticketClosure;
-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 DROP PROCEDURE IF EXISTS `ticketClosureTicket__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketClosureTicket__`(vTicketFk INT)
-BEGIN
-
-/**
- * @deprecated Use ticket_closeByTicket()
- * Inserta el ticket en la tabla temporal
- * para ser cerrado.
- *
- * @param vTicketFk Id del ticket
- */
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketClosure;
-
- CREATE TEMPORARY TABLE tmp.ticketClosure ENGINE = MEMORY (
- SELECT
- t.id AS ticketFk
- FROM expedition e
- INNER JOIN ticket t ON t.id = e.ticketFk
- LEFT JOIN ticketState ts ON ts.ticketFk = t.id
- WHERE
- ts.alertLevel = 2
- AND t.id = vTicketFk
- AND t.refFk IS NULL
- GROUP BY e.ticketFk);
-
- CALL ticketClosure();
-
- DROP TEMPORARY TABLE tmp.ticketClosure;
-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 DROP PROCEDURE IF EXISTS `ticketCollection_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -79838,8 +67382,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCollection_get`(vTicketFk INT)
BEGIN
@@ -79854,6 +67396,8 @@ DELIMITER ;
/*!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 `ticketCollection_setUsedShelves` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -79861,8 +67405,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCollection_setUsedShelves`(vTicketFk INT, vUsedShelves INT)
BEGIN
@@ -79884,6 +67426,8 @@ DELIMITER ;
/*!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 `ticketComponentUpdate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -79891,8 +67435,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketComponentUpdate`(
vTicketFk INT,
@@ -79962,6 +67504,8 @@ DELIMITER ;
/*!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 `ticketComponentUpdateSale` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -79969,8 +67513,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketComponentUpdateSale`(vOption INT)
BEGIN
@@ -80159,6 +67701,8 @@ DELIMITER ;
/*!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 `ticketCreate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -80166,8 +67710,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCreate`(
vClientId INT
@@ -80180,13 +67722,15 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCreate`(
,vlanded DATE
,OUT vNewTicket INT)
BEGIN
- CALL `ticketCreateWithUser`(vClientId, vShipped, vWarehouseId, vCompanyFk, vAddressFk, vAgencyType, vRouteFk, vlanded, account.userGetId(), vNewTicket);
+ CALL `ticketCreateWithUser`(vClientId, vShipped, vWarehouseId, vCompanyFk, vAddressFk, vAgencyType, vRouteFk, vlanded, account.myUser_getId(), vNewTicket);
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 `ticketCreateWithUser` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -80194,8 +67738,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCreateWithUser`(
vClientId INT
@@ -80228,6 +67770,8 @@ DELIMITER ;
/*!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 `ticketDown_PrintableSelection` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -80235,8 +67779,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketDown_PrintableSelection`(vSectorFk INT)
BEGIN
@@ -80263,254 +67805,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `ticketFilter__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketFilter__`()
-BEGIN
-/**
- * Obtiene un listado de tickets
- * junto con el precio total y los problemas
- *
- * @table tmp.ticket(ticketFk) Identificadores de los tickets a calcular
- * @return Listado de tickets
- */
- CALL ticketGetTotal();
- CALL ticketGetProblems(FALSE);
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketFilter;
- CREATE TEMPORARY TABLE tmp.ticketFilter ENGINE = MEMORY
- SELECT t.*, tt.total, tp.problem
- FROM tmp.ticket t
- JOIN tmp.ticketTotal tt ON tt.ticketFk = t.ticketFk
- LEFT JOIN tmp.ticketProblems tp ON tp.ticketFk = t.ticketFk;
-
- DROP TEMPORARY TABLE
- tmp.ticket,
- tmp.ticketTotal,
- tmp.ticketProblems;
-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 DROP PROCEDURE IF EXISTS `ticketGetProblems__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketGetProblems__`(IN vIsTodayRelative TINYINT(1))
-BEGIN
-/**
- * @deprecated Use ticket_getProblems() instead
- *
- * Hay que revisar los dos procesos y unificarlos. No son equivalentes. PAK 04/06/21
- *
- */
- DECLARE vWarehouse INT;
- DECLARE vDate DATE;
- DECLARE vAvailableCache INT;
- DECLARE vDone INT DEFAULT 0;
- DECLARE vComponentCount INT;
- DECLARE vHasUbications BOOL;
-
- DECLARE vCursor CURSOR FOR
- SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, CURDATE(), date(tt.shipped)), w.hasUbications
- FROM tmp.ticketGetProblems tt
- JOIN vn.warehouse w ON w.id = tt.warehouseFk
- WHERE DATE(tt.shipped) BETWEEN CURDATE()
- AND TIMESTAMPADD(DAY, IF(vIsTodayRelative, 9.9, 1.9), CURDATE());
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketProblems;
- CREATE TEMPORARY TABLE tmp.ticketProblems (
- ticketFk INT(11) PRIMARY KEY,
- isFreezed INTEGER(1) DEFAULT 0,
- risk DECIMAL(10,2) DEFAULT 0,
- hasTicketRequest INTEGER(1) DEFAULT 0,
- isAvailable INTEGER(1) DEFAULT 1,
- itemShortage VARCHAR(250),
- isTaxDataChecked INTEGER(1) DEFAULT 1,
- itemDelay VARCHAR(250),
- componentLack INTEGER(1)
- ) ENGINE = MEMORY;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketList;
- CREATE TEMPORARY TABLE tmp.ticketList
- (PRIMARY KEY (ticketFk))
- ENGINE = MEMORY
- SELECT tp.ticketFk, c.id clientFk
- FROM tmp.ticketGetProblems tp
- JOIN vn.client c ON c.id = tp.clientFk;
-
- SELECT COUNT(*) INTO vComponentCount
- FROM vn.component c
- WHERE c.isRequired;
-
- INSERT INTO tmp.ticketProblems(ticketFk, componentLack)
- SELECT tl.ticketFk,
- (COUNT(DISTINCT s.id) * (vComponentCount - (dm.code = 'PICKUP')) > COUNT(c.id))
- FROM tmp.ticketList tl
- JOIN vn.sale s ON s.ticketFk = tl.ticketFk
- JOIN vn.ticket t ON t.id = tl.ticketFk
- JOIN vn.agencyMode am ON am.id = t.agencyModeFk
- JOIN vn.deliveryMethod dm ON dm.id = am.deliveryMethodFk
- LEFT JOIN vn.saleComponent sc ON sc.saleFk = s.id
- LEFT JOIN vn.component c ON c.id = sc.componentFk AND c.isRequired
- GROUP BY tl.ticketFk;
-
- INSERT INTO tmp.ticketProblems(ticketFk, isFreezed)
- SELECT DISTINCT tl.ticketFk, 1
- FROM tmp.ticketList tl
- JOIN vn.client c ON c.id = tl.clientFk
- WHERE c.isFreezed
- ON DUPLICATE KEY UPDATE
- isFreezed = c.isFreezed;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt;
- CREATE TEMPORARY TABLE tmp.clientGetDebt
- (PRIMARY KEY (clientFk))
- ENGINE = MEMORY
- SELECT DISTINCT clientFk
- FROM tmp.ticketList;
-
- CALL clientGetDebt(CURDATE());
-
- INSERT INTO tmp.ticketProblems(ticketFk, risk)
- SELECT DISTINCT tl.ticketFk, r.risk
- FROM tmp.ticketList tl
- JOIN vn.ticket t ON t.id = tl.ticketFk
- JOIN vn.agencyMode a ON t.agencyModeFk = a.id
- JOIN tmp.risk r ON r.clientFk = t.clientFk
- JOIN vn.client c ON c.id = t.clientFk
- JOIN vn.clientConfig cc
- WHERE r.risk - cc.riskTolerance > c.credit + 10
- AND a.isRiskFree = FALSE
- ON DUPLICATE KEY UPDATE
- risk = r.risk;
-
- INSERT INTO tmp.ticketProblems(ticketFk, hasTicketRequest)
- SELECT DISTINCT tl.ticketFk, 1
- FROM tmp.ticketList tl
- JOIN vn.ticketRequest tr ON tr.ticketFk = tl.ticketFk
- WHERE tr.isOK IS NULL AND tr.saleFk IS NOT NULL
- ON DUPLICATE KEY UPDATE
- hasTicketRequest = 1;
-
- OPEN vCursor;
-
- WHILE NOT vDone
- DO
- FETCH vCursor INTO vWarehouse, vDate, vHasUbications;
-
- CALL cache.available_refresh(vAvailableCache, FALSE, vWarehouse, vDate);
-
- INSERT INTO tmp.ticketProblems(ticketFk, isAvailable)
- SELECT tl.ticketFk, 0
- FROM tmp.ticketList tl
- JOIN vn.ticket t ON t.id = tl.ticketFk
- JOIN vn.sale s ON s.ticketFk = t.id
- JOIN vn.item i ON i.id = s.itemFk
- JOIN vn.itemType it on it.id = i.typeFk
- LEFT JOIN cache.available av ON av.item_id = i.id
- AND av.calc_id = vAvailableCache
- WHERE date(t.shipped) = vDate
- AND it.categoryFk != 6
- AND IFNULL(av.available, 0) < 0
- AND s.isPicked = FALSE
- AND NOT i.generic
- AND vWarehouse = t.warehouseFk
- GROUP BY tl.ticketFk
- ON DUPLICATE KEY UPDATE
- isAvailable = 0;
-
- IF vHasUbications THEN
-
- INSERT INTO tmp.ticketProblems(ticketFk, itemShortage)
- SELECT ticketFk, problem
- FROM (
- SELECT tl.ticketFk, CONCAT('F: ',GROUP_CONCAT(i.id, ' ', i.longName, ' ')) problem
- FROM tmp.ticketList tl
- JOIN vn.ticket t ON t.id = tl.ticketFk
- JOIN vn.sale s ON s.ticketFk = t.id
- JOIN vn.item i ON i.id = s.itemFk
- JOIN vn.itemType it on it.id = i.typeFk
- LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk
- LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache
- WHERE IFNULL(av.available, 0) < 0
- AND s.quantity > IFNULL(issw.visible, 0)
- AND s.quantity > 0
- AND s.isPicked = FALSE
- AND s.reserved = FALSE
- AND it.categoryFk != 6
- AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate)
- AND NOT i.generic
- AND CURDATE() = vDate
- AND t.warehouseFk = vWarehouse
- GROUP BY tl.ticketFk) sub
- ON DUPLICATE KEY UPDATE
- itemShortage = sub.problem;
-
- INSERT INTO tmp.ticketProblems(ticketFk, itemDelay)
- SELECT ticketFk, problem
- FROM (
- SELECT tl.ticketFk, GROUP_CONCAT('I: ',i.id, ' ', i.longName, ' ') problem
- FROM tmp.ticketList tl
- JOIN vn.ticket t ON t.id = tl.ticketFk
- JOIN vn.sale s ON s.ticketFk = t.id
- JOIN vn.item i ON i.id = s.itemFk
- JOIN vn.itemType it on it.id = i.typeFk
- LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk
- WHERE s.quantity > IFNULL(issw.visible, 0)
- AND s.quantity > 0
- AND s.isPicked = FALSE
- AND s.reserved = FALSE
- AND it.categoryFk != 6
- AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate)
- AND NOT i.generic
- AND CURDATE() = vDate
- AND t.warehouseFk = vWarehouse
- GROUP BY tl.ticketFk) sub
- ON DUPLICATE KEY UPDATE
- itemDelay = sub.problem;
-
- END IF;
-
- END WHILE;
-
- CLOSE vCursor;
-
- INSERT INTO tmp.ticketProblems(ticketFk, isTaxDataChecked)
- SELECT DISTINCT tl.ticketFk, FALSE
- FROM tmp.ticketList tl
- JOIN vn.client c ON c.id = tl.clientFk
- WHERE c.isTaxDataChecked= FALSE
- ON DUPLICATE KEY UPDATE
- isTaxDataChecked = FALSE;
-
- DROP TEMPORARY TABLE
- tmp.clientGetDebt,
- tmp.ticketList;
-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 DROP PROCEDURE IF EXISTS `ticketGetTaxAdd` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -80518,8 +67814,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketGetTaxAdd`(vTicketFk INT)
BEGIN
@@ -80555,6 +67849,8 @@ DELIMITER ;
/*!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 `ticketGetTax_new` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -80562,8 +67858,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketGetTax_new`()
READS SQL DATA
@@ -80634,133 +67928,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `ticketGetTax__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketGetTax__`()
- READS SQL DATA
-BEGIN
-/**
- * Calcula la base imponible, el IVA y el recargo de equivalencia para
- * un conjunto de tickets.
- *
- * @table tmp.ticket(ticketFk) Identificadores de los tickets a calcular
- * @return tmp.ticketAmount
- * @return tmp.ticketTax Impuesto desglosado para cada ticket.
-
- */
- DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany;
- CREATE TEMPORARY TABLE tmp.addressCompany
- (INDEX (addressFk, companyFk))
- ENGINE = MEMORY
- SELECT DISTINCT t.addressFk, t.companyFk
- FROM tmp.ticket tmpTicket
- JOIN ticket t ON t.id = tmpTicket.ticketFk;
-
- CALL addressTaxArea ();
-
-
- /** Solo se calcula la base imponible (taxableBase) y el impuesto se calculará posteriormente
- * No se debería cambiar el sistema por problemas con los decimales
- */
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketTax;
- CREATE TEMPORARY TABLE tmp.ticketTax
- (INDEX (ticketFk))
- ENGINE = MEMORY
- SELECT tmpTicket.ticketFk,
- bp.pgcFk,
- SUM(s.quantity * s.price * (100 - s.discount)/100 ) AS taxableBase,
- pgc.rate,
- tc.code
- FROM tmp.ticket tmpTicket
- JOIN sale s ON s.ticketFk = tmpTicket.ticketFk
- JOIN item i ON i.id = s.itemFk
- JOIN ticket t ON t.id = tmpTicket.ticketFk
- JOIN supplier su ON su.id = t.companyFk
- JOIN tmp.addressTaxArea ata
- ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk
- JOIN itemTaxCountry itc
- ON itc.itemFk = i.id AND itc.countryFk = su.countryFk
- JOIN bookingPlanner bp
- ON bp.countryFk = su.countryFk
- AND bp.taxAreaFk = ata.areaFk
- AND bp.taxClassFk = itc.taxClassFk
- JOIN pgc ON pgc.code = bp.pgcFk
- JOIN taxClass tc ON tc.id = bp.taxClassFk
- GROUP BY tmpTicket.ticketFk, pgc.code,pgc.rate
- HAVING taxableBase != 0;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketServiceTax;
- CREATE TEMPORARY TABLE tmp.ticketServiceTax
- (INDEX (ticketFk))
- ENGINE = MEMORY
- SELECT tt.ticketFk,
- SUM(ts.quantity * ts.price) AS taxableBase,
- pgc.rate,
- tc.code
- FROM tmp.ticketTax tt
- JOIN ticketService ts ON ts.ticketFk = tt.ticketFk
- JOIN ticket t ON t.id = tt.ticketFk
- JOIN supplier su ON su.id = t.companyFk
- JOIN tmp.addressTaxArea ata
- ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk
- JOIN bookingPlanner bp
- ON bp.countryFk = su.countryFk
- AND bp.taxAreaFk = ata.areaFk
- AND bp.taxClassFk = ts.taxClassFk
- JOIN pgc ON pgc.code = bp.pgcFk AND pgc.rate = tt.rate
- JOIN taxClass tc ON tc.id = bp.taxClassFk
- GROUP BY tt.ticketFk, tt.code,tt.rate
- HAVING taxableBase != 0;
-
- UPDATE tmp.ticketTax tt
- JOIN tmp.ticketServiceTax ts ON tt.ticketFk = ts.ticketFk AND tt.code = ts.code AND tt.rate = ts.rate
- SET tt.taxableBase = tt.taxableBase + ts.taxableBase;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketAmount;
- CREATE TEMPORARY TABLE tmp.ticketAmount
- (INDEX (ticketFk))
- ENGINE = MEMORY
- SELECT ticketFk, taxableBase, SUM(CAST(taxableBase * rate / 100 AS DECIMAL(10, 2))) tax,code
- FROM tmp.ticketTax
- GROUP BY ticketFk, code;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany;
- DROP TEMPORARY TABLE IF EXISTS tmp.addressTaxArea;
-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 DROP PROCEDURE IF EXISTS `ticketGetTax__2` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketGetTax__2`()
- READS SQL DATA
-BEGIN
- CALL ticket_getTax(NULL);
-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 DROP PROCEDURE IF EXISTS `ticketGetTotal` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -80768,8 +67937,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketGetTotal`()
BEGIN
@@ -80800,6 +67967,8 @@ DELIMITER ;
/*!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 `ticketGetVisibleAvailable` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -80807,8 +67976,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketGetVisibleAvailable`(
vTicket INT)
@@ -80825,10 +67992,10 @@ BEGIN
WHERE t.id = vTicket;
IF vAlertLevel IS NULL OR vAlertLevel = 0 THEN
- IF vShipped >= CURDATE() THEN
+ IF vShipped >= util.VN_CURDATE() THEN
CALL cache.available_refresh(vAvailableCalc, FALSE, vWarehouse, vShipped);
END IF;
- IF vShipped = CURDATE() THEN
+ IF vShipped = util.VN_CURDATE() THEN
CALL cache.visible_refresh(vVisibleCalc, FALSE, vWarehouse);
END IF;
END IF;
@@ -80846,6 +68013,8 @@ DELIMITER ;
/*!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 `ticketManaToPromo` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -80853,8 +68022,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketManaToPromo`(vTicketFk INT)
BEGIN
@@ -80882,6 +68049,8 @@ DELIMITER ;
/*!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 `ticketMissed_List` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -80889,8 +68058,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketMissed_List`(vTicketFk INT)
BEGIN
@@ -80944,6 +68111,8 @@ DELIMITER ;
/*!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 `ticketNotInvoicedByClient` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -80951,8 +68120,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketNotInvoicedByClient`(vClientFk INT)
BEGIN
@@ -80987,6 +68154,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketObservation_addNewBorn` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -80994,8 +68163,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketObservation_addNewBorn`(vTicketFk INT)
BEGIN
@@ -81020,75 +68187,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `ticketPackagingRecovery__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketPackagingRecovery__`()
-BEGIN
-
- /* Recupera los embalajes que han caido en el cliente 31 */
-
- DECLARE done BOOL DEFAULT FALSE;
- DECLARE vClientFk INT;
- DECLARE vTicketFk INT;
- DECLARE vTicketNewFk INT;
- DECLARE vWarehouseFk INT;
- DECLARE vShipped DATE;
- DECLARE vCompanyFk INT;
-
- DECLARE rs CURSOR FOR
- SELECT DISTINCT tp.ticketFk, a.clientFk, t.warehouseFk, t.shipped, t.companyFk
- FROM ticket t
- JOIN ticketPackaging tp ON t.id = tp.ticketFk
- JOIN address a ON a.id = t.addressFk
- WHERE t.clientFk = 31
- AND t.shipped > '2001-01-01';
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
-
- OPEN rs;
-
- FETCH rs INTO vTicketFk, vClientFk, vWarehouseFk, vShipped, vCompanyFk;
-
- WHILE NOT done DO
-
- CALL vn.ticket_add(vClientFk,
- vShipped,
- vWarehouseFk,
- vCompanyFk,
- NULL,
- NULL,
- NULL,
- vShipped,
- account.userGetId(),
- TRUE,
- vTicketNewFk);
-
- UPDATE vn.ticketPackaging set ticketFk = vTicketNewFk WHERE ticketFk = vTicketFk;
-
- CALL vn.ticketStateUpdate(vTicketNewFk, 'DELIVERED');
-
- INSERT INTO vn.sale(ticketFk, itemFk, concept) VALUES(vTicketNewFk,90,CONCAT('Embalajes ',vTicketFk));
-
- FETCH rs INTO vTicketFk, vClientFk, vWarehouseFk, vShipped, vCompanyFk;
-
- END WHILE;
-
- CLOSE rs;
-
-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 DROP PROCEDURE IF EXISTS `ticketParking_findSkipped` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -81096,8 +68196,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketParking_findSkipped`(vTicketFk INT, vItemPackingTypeFk VARCHAR(1))
BEGIN
@@ -81166,6 +68264,39 @@ DELIMITER ;
/*!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 `ticketRefund_beforeUpsert` */;
+/*!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=`root`@`localhost` PROCEDURE `ticketRefund_beforeUpsert`(vRefundTicketFk INT, vOriginalTicketFk INT)
+BEGIN
+ DECLARE vAlreadyExists BOOLEAN DEFAULT FALSE;
+
+ IF vRefundTicketFk = vOriginalTicketFk THEN
+ CALL util.throw('Original ticket and refund ticket has same id');
+ END IF;
+
+ SELECT COUNT(*) INTO vAlreadyExists
+ FROM ticketRefund
+ WHERE refundTicketFk = vOriginalTicketFk;
+
+ IF vAlreadyExists > 0 THEN
+ CALL util.throw('This ticket is already a refund');
+ 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_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketRequest_Add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -81173,8 +68304,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketRequest_Add`(vDescription VARCHAR(255), vQuantity INT, vPrice DOUBLE, vTicketFk INT, vBuyerCode VARCHAR(3))
BEGIN
@@ -81198,181 +68327,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `ticketSplitCounter` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketSplitCounter`(vTicketFk INT)
-BEGIN
-
-SELECT CONCAT(OK,'/',Total, IF(OK = Total ,' LS',''))
- FROM
- (
- SELECT sum(if(l.Id_Movimiento != 0,1,0)) as OK, COUNT(*) as Total
- FROM vn.sale s
- LEFT JOIN movement_label l ON l.Id_Movimiento = s.id
- WHERE ticketFk = vTicketFk
- ) sub;
-
-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 DROP PROCEDURE IF EXISTS `ticketStatePrevious__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketStatePrevious__`(vTicketFk INT)
-BEGIN
-
- DECLARE vControlFk INT;
- DECLARE vLastWorkerFk INT;
- DECLARE vStateId INT;
-
- SELECT MAX(inter_id) INTO vControlFk
- FROM vncontrol.inter
- WHERE Id_Ticket = vTicketFk;
-
- IF (SELECT s.code
- FROM vn.state s
- JOIN vncontrol.inter i ON i.state_id = s.id
- WHERE i.inter_id = vControlFk)
- = 'PREVIOUS_PREPARATION' THEN
-
- SELECT inter_id, Id_Trabajador
- INTO vControlFk,vLastWorkerFk
- FROM vncontrol.inter i
- JOIN vn.state s ON i.state_id = s.id
- WHERE Id_Ticket = vTicketFk
- AND inter_id < vControlFk
- AND s.code != 'PREVIOUS_PREPARATION'
- ORDER BY inter_id DESC
- LIMIT 1;
- /*
- INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador, Id_Supervisor)
- SELECT state_id, Id_Ticket, vLastWorkerFk, vn.getWorker()
- FROM vncontrol.inter
- WHERE inter_id = vControlFk;
- */
- INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador, Id_Supervisor)
- SELECT s.nextStateFk, i.Id_Ticket, vLastWorkerFk, account.myUser_getId()
- FROM vncontrol.inter i
- JOIN vn.state s ON i.state_id = s.id
- WHERE inter_id = vControlFk;
-
- SELECT state_id INTO vStateId
- FROM vncontrol.inter
- WHERE inter_id = vControlFk;
-
- END IF;
-
- /*DELETE FROM vn2008.Movimientos_mark
- WHERE Id_Movimiento IN (SELECT Id_Movimiento FROM vn2008.Movimientos WHERE Id_Ticket = vTicketFk)
- AND valor <> 1
- AND stateFk = 26; */
-
- SELECT TRUE AS IsUpdated;
-
-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 DROP PROCEDURE IF EXISTS `ticketStateToday_setOnchecking__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketStateToday_setOnchecking__`(vParamFk INT)
-BEGIN
- /*
- * @deprecated:utilizar ticketStateToday_setState
- */
-
- DECLARE vAlertLevel INT;
-
- SELECT s.alertLevel INTO vAlertLevel
- FROM vn.state s
- JOIN vn.ticketStateToday tst ON tst.state = s.id
- WHERE tst.ticket = vParamFk
- LIMIT 1;
-
- IF vAlertLevel < 2 THEN
-
- CALL vn.ticketStateUpdate(vParamFk, 'ON_CHECKING');
-
- 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 DROP PROCEDURE IF EXISTS `ticketStateToday_setOnPreviousChecking__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketStateToday_setOnPreviousChecking__`(vParamFk INT)
-BEGIN
-
- /*
- * @deprecated:utilizar ticketStateToday_setState
- */
-
-
- /*
- * Cambia el estado del ticket al estado de "control previa"
- *
- * @param vParamFk ticket a cambiar el estado
- *
- */
- DECLARE vAlertLevel INT;
-
- SELECT s.alertLevel INTO vAlertLevel
- FROM state s
- JOIN ticketStateToday tst ON tst.state = s.id
- WHERE tst.ticket = vParamFk
- LIMIT 1;
-
- IF vAlertLevel < 2 THEN
-
- CALL ticketStateUpdate(vParamFk, 'PREVIOUS_CONTROL');
-
- 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 DROP PROCEDURE IF EXISTS `ticketStateToday_setState` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -81380,8 +68336,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketStateToday_setState`(vTicketFk INT, vStateCode VARCHAR(45))
BEGIN
@@ -81413,6 +68367,8 @@ DELIMITER ;
/*!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 `ticketStateUpdate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -81420,8 +68376,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketStateUpdate`(vTicketFk INT, vStateCode VARCHAR(45))
BEGIN
@@ -81452,6 +68406,8 @@ DELIMITER ;
/*!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 `ticketToInvoiceByAddress` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -81459,8 +68415,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketToInvoiceByAddress`(
vStarted DATE,
@@ -81488,6 +68442,8 @@ DELIMITER ;
/*!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 `ticketToInvoiceByDate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -81495,8 +68451,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketToInvoiceByDate`(
vStarted DATE,
@@ -81524,6 +68478,8 @@ DELIMITER ;
/*!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 `ticketToInvoiceByRef` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -81531,8 +68487,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketToInvoiceByRef`(IN vInvoiceRef VARCHAR(15))
BEGIN
@@ -81584,170 +68538,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `ticketToPrePrepare` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketToPrePrepare`(IN vSaleGroupFk INT, IN vSectorFk INT)
-BEGIN
-
-/* Devuelve las lineas de vn.sale para preparación previa según el saleGroup
- *
- *
- * @param vSaleGroupFk Identificador de vn.saleGroup
-*/
- DECLARE vIsResetCode BOOLEAN;
-
- SELECT (vSaleGroupFk = 2000000) INTO vIsResetCode;
-
- IF vIsResetCode THEN
-
- UPDATE vn.saleTracking st
- JOIN vn.state s ON s.code = 'OK PREVIOUS'
- JOIN vn.state s2 ON s2.id = st.stateFk
- SET st.stateFk = s.id
- WHERE workerFk = vn.getUser()
- AND s2.code = 'PREVIOUS_PREPARATION';
-
- ELSE
-
- UPDATE vn.saleTracking st
- JOIN vn.saleGroupDetail sgd ON sgd.saleFk = st.saleFk
- SET workerFk = vn.getUser()
- WHERE sgd.saleGroupFk = vSaleGroupFk;
-
- UPDATE vn.saleGroup sg
- SET sg.userFk = vn.getUser()
- WHERE sg.id = vSaleGroupFk;
-
- SELECT s.ticketFk,
- s.itemFk,
- i.longName,
- IFNULL(i.itemPackingTypeFk,' ') itemPackingTypeFk,
- IFNULL(i.subName ,' ') subName,
- s.quantity originalQuantity ,
- s.quantity,
- w.code workerCode,
- sgd.saleFk,
- IFNULL(iss.quantity,0) pickedQuantity,
- vSectorFk,
- c.salesPersonFk
- FROM vn.sale s
- JOIN vn.item i ON i.id = s.itemFk
- JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id
- JOIN vn.saleTracking st ON st.saleFk = s.id
- JOIN vn.state stt ON stt.id = st.stateFk
- JOIN vn.worker w ON w.id = st.workerFk
- LEFT JOIN vn.itemShelvingSaleSum iss ON iss.saleFk = s.id
- JOIN vn.ticket t ON t.id= s.ticketFk
- JOIN vn.client c ON c.id=t.clientFk
- WHERE st.workerFk = account.myUser_getId()
- AND stt.code = 'PREVIOUS_PREPARATION';
-
- 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 DROP PROCEDURE IF EXISTS `ticketToPrePrepare__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketToPrePrepare__`(IN vIdTicket INT, IN viewAll BOOL, IN vSectorFk INT)
-BEGIN
-
-/* Tickets de preparacion previa (artificial) 21/03/2021 PAK
-*/
-
-/* Tickets de preparacion previa (artificial) 21/03/2021 PAK
-*/
-
- DECLARE vIsResetCode BOOLEAN;
-
-IF viewAll IS true THEN
-
- SELECT (vIdTicket = 2000000) INTO vIsResetCode;
-
- IF vIsResetCode THEN
-
- UPDATE vn.saleTracking st
- JOIN vn.state s ON s.code = 'OK PREVIOUS'
- JOIN vncontrol.accion a ON a.accion_id = st.actionFk
- JOIN vn.state s2 ON s2.id = st.stateFk
- SET st.stateFk = s.id
- WHERE workerFk = vn.getUser()
- AND (a.accion = 'PRESACAR')
- AND st.created > TIMESTAMPADD(HOUR, -10, NOW());
-
- ELSE
-
- UPDATE vn.saleTracking st
- JOIN vn.salesToPrePrepare stpp ON stpp.Id_Movimiento_mark = st.id
- SET workerFk = vn.getUser()
- WHERE stpp.Id_Ticket = vIdTicket
- AND stpp.isChecked = FALSE;
-
- SELECT stpp.Id_Ticket,
- stpp.Id_Movimiento,
- stpp.Id_Movimiento_mark,
- stpp.Id_Trabjador,
- stpp.Id_Article,
- i.itemPackingTypeFk packingType,
- stpp.Concepte Concepte,
- stpp.subName,
- stpp.Cantidad,
- stpp.original_quantity,
- stpp.Hora,
- stpp.Departure,
- stpp.Minuto,
- stpp.agency_id,
- stpp.warehouse_id,
- stpp.province_id,
- stpp.picked,
- stpp.trabajador,
- ispss.created,
- ispss.sectorFk
- FROM vn.salesToPrePrepare stpp
- JOIN vn.worker w ON w.code = stpp.trabajador
- LEFT JOIN vn.itemShelvingPlacementSupplyStock ispss
- ON ispss.itemShelvingFk = ( SELECT itemShelvingFk
- FROM vn.itemShelvingPlacementSupplyStock
- WHERE itemFk = stpp.Id_Article
- AND sectorFk = vSectorFk
- ORDER BY parking ASC
- LIMIT 1)
- LEFT JOIN vn.parking p ON p.id = ispss.parkingFk
- LEFT JOIN vn.item i ON i.id = stpp.Id_Article
- JOIN vn.state s ON s.id = stpp.stateFk
- WHERE w.id = vn.getUser()
- AND stpp.created > CURDATE()
- AND s.code = 'PREVIOUS_PREPARATION'
- ORDER BY p.pickingOrder, p.column ASC;
-
- END IF;
-
-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 DROP PROCEDURE IF EXISTS `ticketTrackingAdd` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -81755,8 +68547,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketTrackingAdd`(vTicketFk INT, vState VARCHAR(25) CHARSET UTF8, vWorkerFk INT)
BEGIN
@@ -81774,120 +68564,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `ticketVolumeByDate_ventas_Artificial__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketVolumeByDate_ventas_Artificial__`(vDate DATE)
-BEGIN
-
- DECLARE vDateStart DATETIME DEFAULT DATE(vDate);
- DECLARE vDateEnd DATETIME DEFAULT util.dayEnd(vDate);
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketVolumeByDate_Artificial;
-
- CREATE TEMPORARY TABLE tmp.ticketVolumeByDate_Artificial
- ENGINE = MEMORY
- SELECT s.ticketFk,
- CAST(SUM(r.cm3 * s.quantity) / 1000000 AS DECIMAL(10,2)) as m3
- FROM sale s
- JOIN bs.ventas v ON v.Id_Movimiento = s.id
- JOIN vn.item i ON i.id = s.itemFk
- JOIN vn.sector sc ON sc.id = i.sectorFk
- JOIN vn.ticket t on t.id = s.ticketFk
- JOIN bi.rotacion r ON r.Id_Article = s.itemFk AND r.warehouse_id = t.warehouseFk
- WHERE sc.description = 'Artificial'
- AND t.shipped BETWEEN vDateStart AND vDateEnd
- GROUP BY s.ticketFk;
-
-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 DROP PROCEDURE IF EXISTS `ticketVolumeByDate_ventas__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketVolumeByDate_ventas__`(vDate DATE)
-BEGIN
-
- DECLARE vDateStart DATETIME DEFAULT DATE(vDate);
- DECLARE vDateEnd DATETIME DEFAULT util.dayEnd(vDate);
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketVolumeByDate;
-
- CREATE TEMPORARY TABLE tmp.ticketVolumeByDate
- ENGINE = MEMORY
- SELECT s.ticketFk,
- CAST(SUM(r.cm3 * s.quantity) / 1000000 AS DECIMAL(10,2)) as m3
- FROM sale s
- JOIN bs.ventas v ON v.Id_Movimiento = s.id
- JOIN vn.item i ON i.id = s.itemFk
- JOIN vn.itemType it ON it.id = i.typeFk
- JOIN vn.itemCategory ic ON ic.id = it.categoryFk
- JOIN vn.ticket t on t.id = s.ticketFk
- JOIN bi.rotacion r ON r.Id_Article = s.itemFk AND r.warehouse_id = t.warehouseFk
- WHERE ic.merchandise
- AND t.shipped BETWEEN vDateStart AND vDateEnd
- AND it.name NOT IN ('Accesorios Funerarios','Composiciones planta','Composición bajo pedido','Coronas y centros')
- GROUP BY s.ticketFk;
-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 DROP PROCEDURE IF EXISTS `ticketVolumeByDate__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketVolumeByDate__`(vDate DATE)
-BEGIN
-
- DECLARE vDateStart DATETIME DEFAULT DATE(vDate);
- DECLARE vDateEnd DATETIME DEFAULT util.dayEnd(vDate);
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketVolumeByDate;
-
- CREATE TEMPORARY TABLE tmp.ticketVolumeByDate
- ENGINE = MEMORY
- SELECT s.ticketFk,
- CAST(SUM(ic.cm3delivery * s.quantity) / 1000000 AS DECIMAL(10,2)) as m3
- FROM sale s
- JOIN vn.item i ON i.id = s.itemFk
- JOIN vn.itemType it ON it.id = i.typeFk
- JOIN vn.itemCategory c ON c.id = it.categoryFk
- JOIN vn.ticket t on t.id = s.ticketFk
- JOIN vn.itemCost ic ON ic.itemFk = s.itemFk AND ic.warehouseFk = t.warehouseFk
- WHERE c.merchandise
- AND t.shipped BETWEEN vDateStart AND vDateEnd
- GROUP BY s.ticketFk;
-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 DROP PROCEDURE IF EXISTS `ticket_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -81895,8 +68573,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_add`(
vClientId INT
@@ -82000,6 +68676,8 @@ DELIMITER ;
/*!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 `ticket_administrativeCopy` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -82007,8 +68685,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_administrativeCopy`(vOriginalTicket INT, OUT vNewTicket INT)
BEGIN
@@ -82032,6 +68708,8 @@ DELIMITER ;
/*!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 `ticket_canAdvance` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -82039,8 +68717,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_canAdvance`(vDated DATE, vWarehouseFk INT)
BEGIN
@@ -82048,7 +68724,7 @@ BEGIN
* Devuelve los tickets y la cantidad de lineas de venta que se pueden adelantar.
*
* @param vDated Fecha de los tickets que se quieren adelantar.
- * @param vWarehouseFk Almacén
+ * @param vWarehouseFk AlmacénitemEntryIn
*/
DECLARE vDateInventory DATE;
DECLARE vDateToAdvance DATE;
@@ -82125,6 +68801,8 @@ DELIMITER ;
/*!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 `ticket_canMerge` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -82132,8 +68810,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_canMerge`(vDated DATE, vScopeDays INT, vLitersMax INT, vLinesMax INT, vWarehouseFk INT)
BEGIN
@@ -82167,25 +68843,26 @@ BEGIN
JOIN vn.alertLevel al ON al.id = ts.alertLevel
LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id
LEFT JOIN (
- SELECT * FROM (
- SELECT
- t.addressFk ,
- t.id,
- t.shipped,
- st.name state,
- GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) iptd
- FROM vn.ticket t
- JOIN vn.ticketState ts ON ts.ticketFk = t.id
- JOIN vn.state st ON st.id = ts.stateFk
- JOIN vn.sale s ON s.ticketFk = t.id
- JOIN vn.item i ON i.id = s.itemFk
- WHERE t.shipped BETWEEN TIMESTAMPADD(DAY, vScopeDays,vDated)
- AND util.dayend(TIMESTAMPADD(DAY, vScopeDays,vDated))
- AND t.warehouseFk = vWarehouseFk
- GROUP BY t.id
- ) sub
- GROUP BY sub.addressFk
- ) sub2 ON sub2.addressFk = t.addressFk AND t.id != sub2.id
+ SELECT *
+ FROM (
+ SELECT
+ t.addressFk ,
+ t.id,
+ t.shipped,
+ st.name state,
+ GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) iptd
+ FROM vn.ticket t
+ JOIN vn.ticketState ts ON ts.ticketFk = t.id
+ JOIN vn.state st ON st.id = ts.stateFk
+ JOIN vn.sale s ON s.ticketFk = t.id
+ JOIN vn.item i ON i.id = s.itemFk
+ WHERE t.shipped BETWEEN TIMESTAMPADD(DAY, vScopeDays,vDated)
+ AND util.dayend(TIMESTAMPADD(DAY, vScopeDays,vDated))
+ AND t.warehouseFk = vWarehouseFk
+ GROUP BY t.id
+ ) sub
+ GROUP BY sub.addressFk
+ ) sub2 ON sub2.addressFk = t.addressFk AND t.id != sub2.id
WHERE t.shipped BETWEEN vDated AND util.dayend(vDated)
AND t.warehouseFk = vWarehouseFk
AND al.code = 'FREE'
@@ -82198,66 +68875,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `ticket_canMerge__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_canMerge__`(vDated DATE, vScopeDays INT, vLitersMax INT, vLinesMax INT, vWarehouseFk INT)
-BEGIN
-
- /* Devuelve un listado de tickets susceptibles de fusionarse con otros tickets en el futuro
- *
- * @param vDated Fecha en cuestión
- * @param vScopeDays Dias en el futuro a sondear
- * @param vLitersMax Volumen máximo de los tickets a catapultar
- * @param vLinesMax Número máximo de lineas de los tickets a catapultar
- * @param vWarehouseFk Identificador de vn.warehouse
- */
-
- SELECT sv.ticketFk ,
- CAST(sum(litros) AS DECIMAL(10,0)) liters,
- CAST(count(*) AS DECIMAL(10,0)) `lines`,
- sub2.id ticketFuture,
- sub2.shipped
- FROM vn.saleVolume sv
- JOIN vn.ticket t ON t.id = sv.ticketFk
- JOIN vn.address a ON a.id = t.addressFk
- JOIN vn.province p ON p.id = a.provinceFk
- JOIN vn.country c ON c.id = p.countryFk
- JOIN vn.ticketState ts ON ts.ticketFk = t.id
- JOIN vn.alertLevel al ON al.id = ts.alertLevel
- LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id
- LEFT JOIN tmp.routeDayMove ra ON ra.routeFk = t.routeFk
- LEFT JOIN (
- SELECT * FROM (
- SELECT t.addressFk , t.id, t.shipped
- FROM vn.ticket t
- WHERE t.shipped BETWEEN TIMESTAMPADD(DAY, vScopeDays,vDated)
- AND util.dayend(TIMESTAMPADD(DAY, vScopeDays,vDated))
- AND t.warehouseFk = vWarehouseFk
- ) sub
- GROUP BY sub.addressFk
- ) sub2 ON sub2.addressFk = t.addressFk AND t.id != sub2.id
- WHERE t.shipped BETWEEN vDated AND util.dayend(vDated)
- AND t.warehouseFk = vWarehouseFk
- AND al.code = 'FREE'
- AND tp.ticketFk IS NULL
- AND ra.routeFk IS NULL
- GROUP BY sv.ticketFk
- HAVING liters <= vLitersMax AND `lines` <= vLinesMax AND ticketFuture;
-
-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 DROP PROCEDURE IF EXISTS `ticket_changeClient` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -82265,8 +68884,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_changeClient`(vNewClient INT, vUserFk INT)
BEGIN
@@ -82305,6 +68922,8 @@ DELIMITER ;
/*!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 `ticket_checkFullyControlled` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -82312,8 +68931,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_checkFullyControlled`(vWorkerFk INT, vTicketFk INT )
BEGIN
@@ -82334,16 +68951,16 @@ BEGIN
LEFT JOIN (SELECT tc.collectionFk
FROM ticketCollection tc
WHERE ticketFk = vTicketFk
- AND tc.created >= CURDATE()
+ AND tc.created >= util.VN_CURDATE()
)sub ON sub.collectionFk = tc.collectionFk
WHERE ts.workerFk = vWorkerFk
AND sub.collectionFk IS NULL
- AND tc.created >= CURDATE()
+ AND tc.created >= util.VN_CURDATE()
GROUP BY tc.collectionFk
)sub ON sub.collectionFk = tc.collectionFk
JOIN ticketState ts ON ts.ticketFk = t.id
WHERE ts.code IN ('ON_PREPARATION', 'PREPARED', 'PREVIOUS_PREPARATION', 'OK PREVIOUS')
- AND t.shipped >= CURDATE()
+ AND t.shipped >= util.VN_CURDATE()
AND s.quantity <>0
LIMIT 1;
@@ -82353,6 +68970,8 @@ DELIMITER ;
/*!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 `ticket_checkNoComponents` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -82360,8 +68979,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_checkNoComponents`(vShippedFrom DATETIME, vShippedTo DATETIME)
BEGIN
@@ -82431,6 +69048,8 @@ DELIMITER ;
/*!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 `ticket_Clone` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -82438,8 +69057,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_Clone`(vOriginalTicket INT, OUT vNewTicket INT)
BEGIN
@@ -82512,6 +69129,8 @@ DELIMITER ;
/*!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 `ticket_cloneWeekly` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -82519,8 +69138,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_cloneWeekly`(IN vWeek INT)
BEGIN
@@ -82544,7 +69161,7 @@ BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE;
- SET vYear = YEAR(CURDATE()) + IF(vWeek < WEEK(CURDATE()),1, 0);
+ SET vYear = YEAR(util.VN_CURDATE()) + IF(vWeek < WEEK(util.VN_CURDATE()),1, 0);
OPEN rsTicket;
myLoop: LOOP
@@ -82596,7 +69213,7 @@ BEGIN
vAgencyModeFk,
NULL,
vLanding,
- account.userGetId(),
+ account.myUser_getId(),
FALSE,
vNewTicket);
@@ -82662,6 +69279,8 @@ DELIMITER ;
/*!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 `ticket_close` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -82669,8 +69288,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_close`()
BEGIN
@@ -82778,133 +69395,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `ticket_closeAll__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_closeAll__`()
-BEGIN
-/**
- * Realiza el cierre de todos los
- * tickets de la tabla tmp.ticketClosure.
- *
- * @param vTicketFk Id del ticket
- */
- DECLARE vDone BOOL;
- DECLARE vClientFk INT;
- DECLARE vCurTicketFk INT;
- DECLARE vIsTaxDataChecked BOOL;
- DECLARE vCompanyFk INT;
- DECLARE vShipped DATE;
- DECLARE vNewInvoiceId INT;
- DECLARE vHasDailyInvoice BOOL;
- DECLARE vWithPackage BOOL;
- DECLARE vHasToInvoice BOOL;
-
- DECLARE cur CURSOR FOR
- SELECT ticketFk FROM tmp.ticketClosure;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
- DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN
- RESIGNAL;
- END;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketClosure2;
- CREATE TEMPORARY TABLE tmp.ticketClosure2
- SELECT ticketFk FROM tmp.ticketClosure;
-
- INSERT INTO tmp.ticketClosure
- SELECT id FROM stowaway s
- JOIN tmp.ticketClosure2 tc ON s.shipFk = tc.ticketFk;
- OPEN cur;
-
- proc: LOOP
- SET vDone = FALSE;
-
- FETCH cur INTO vCurTicketFk;
-
- IF vDone THEN
- LEAVE proc;
- END IF;
-
- -- ticketClosure start
- SELECT
- c.id,
- c.isTaxDataChecked,
- t.companyFk,
- t.shipped,
- co.hasDailyInvoice,
- w.isManaged,
- c.hasToInvoice
- INTO vClientFk,
- vIsTaxDataChecked,
- vCompanyFk,
- vShipped,
- vHasDailyInvoice,
- vWithPackage,
- vHasToInvoice
- FROM ticket t
- JOIN `client` c ON c.id = t.clientFk
- JOIN province p ON p.id = c.provinceFk
- JOIN country co ON co.id = p.countryFk
- JOIN warehouse w ON w.id = t.warehouseFk
- WHERE t.id = vCurTicketFk;
-
- INSERT INTO ticketPackaging (ticketFk, packagingFk, quantity)
- (SELECT vCurTicketFk, p.id, COUNT(*)
- FROM expedition e
- JOIN packaging p ON p.itemFk = e.itemFk
- WHERE e.ticketFk = vCurTicketFk AND p.isPackageReturnable
- AND vWithPackage
- GROUP BY p.itemFk);
-
- -- No retornables o no catalogados
- INSERT INTO sale (itemFk, ticketFk, concept, quantity, price, isPriceFixed)
- (SELECT e.itemFk, vCurTicketFk, i.name, COUNT(*) AS amount, getSpecialPrice(e.itemFk, vClientFk), 1
- FROM expedition e
- JOIN item i ON i.id = e.itemFk
- LEFT JOIN packaging p ON p.itemFk = i.id
- WHERE e.ticketFk = vCurTicketFk AND IFNULL(p.isPackageReturnable, 0) = 0
- AND getSpecialPrice(e.itemFk, vClientFk) > 0
- GROUP BY e.itemFk);
-
- CALL vn.zonePromo_Make();
-
- IF(vHasDailyInvoice) AND vHasToInvoice THEN
-
- -- Facturacion rapida
- CALL ticketTrackingAdd(vCurTicketFk, 'DELIVERED', NULL);
- -- Facturar si está contabilizado
- IF vIsTaxDataChecked THEN
- CALL invoiceOut_newFromClient(
- vClientFk,
- (SELECT invoiceSerial(vClientFk, vCompanyFk, 'M')),
- vShipped,
- vCompanyFk,
- NULL,
- NULL,
- vNewInvoiceId);
- END IF;
- ELSE
- CALL ticketTrackingAdd(vCurTicketFk, (SELECT vn.getAlert3State(vCurTicketFk)), NULL);
- END IF;
- END LOOP;
-
- CLOSE cur;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketClosure;
-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 DROP PROCEDURE IF EXISTS `ticket_closeByTicket` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -82912,8 +69404,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_closeByTicket`(IN vTicketFk int)
BEGIN
@@ -82948,6 +69438,8 @@ DELIMITER ;
/*!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 `ticket_componentMakeUpdate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -82955,8 +69447,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_componentMakeUpdate`(IN vTicketFk INT, IN vClientFk INT,
IN vNickname VARCHAR(50), IN vAgencyModeFk INT,
@@ -83052,6 +69542,8 @@ DELIMITER ;
/*!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 `ticket_componentPreview` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -83059,8 +69551,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_componentPreview`(
vTicketFk INT,
@@ -83166,213 +69656,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `ticket_componentPreview__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_componentPreview__`(
- vTicketFk INT,
- vLanded DATE,
- vAddressFk INT,
- vZoneFk INT,
- vWarehouseFk SMALLINT)
-BEGIN
-/**
- * Calcula los componentes de los articulos de un ticket
- *
- * @param vTicketFk id del ticket
- * @param vLanded nueva fecha de entrega
- * @param vAddressFk nuevo consignatario
- * @param vZoneFk nueva zona
- * @param vWarehouseFk nuevo warehouse
- *
- * @return tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost)
- */
- DECLARE vShipped DATE;
- DECLARE vBuyOrderItem INT DEFAULT 100;
-
- DECLARE vHasDataChanged BOOL DEFAULT FALSE;
- DECLARE vHasAddressChanged BOOL;
- DECLARE vHasZoneChanged BOOL DEFAULT FALSE;
- DECLARE vHasWarehouseChanged BOOL DEFAULT FALSE;
-
- DECLARE vAddressTypeRateFk INT DEFAULT NULL;
- DECLARE vAgencyModeTypeRateFk INT DEFAULT NULL;
-
- DECLARE vHasChangeAll BOOL DEFAULT FALSE;
-
- SELECT DATE(landed) <> vLanded,
- addressFk <> vAddressFk,
- zoneFk <> vZoneFk,
- warehouseFk <> vWarehouseFk
- INTO
- vHasDataChanged,
- vHasAddressChanged,
- vHasZoneChanged,
- vHasWarehouseChanged
- FROM vn.ticket t
- WHERE t.id = vTicketFk;
-
- IF vHasDataChanged OR vHasWarehouseChanged THEN
- SET vHasChangeAll = TRUE;
- END IF;
-
- IF vHasAddressChanged THEN
- SET vAddressTypeRateFk = 5;
- END IF;
-
- IF vHasZoneChanged THEN
- SET vAgencyModeTypeRateFk = 6;
- END IF;
-
- SELECT TIMESTAMPADD(DAY, -travelingDays, vLanded) INTO vShipped
- FROM zone
- WHERE id = vZoneFk;
-
- CALL buyUltimate(vWarehouseFk, vShipped);
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
- CREATE TEMPORARY TABLE tmp.ticketLot ENGINE = MEMORY (
- SELECT
- vWarehouseFk AS warehouseFk,
- NULL AS available,
- s.itemFk,
- bu.buyFk
- FROM sale s
- LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
- WHERE s.ticketFk = vTicketFk
- AND s.itemFk != vBuyOrderItem
- GROUP BY bu.warehouseFk, bu.itemFk);
-
- CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped);
-
- REPLACE INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost)
- SELECT t.warehouseFk, s.itemFk, sc.componentFk, sc.value
- FROM saleComponent sc
- JOIN sale s ON s.id = sc.saleFk
- JOIN ticket t ON t.id = s.ticketFk
- JOIN `component` c ON c.id = sc.componentFk
- WHERE s.ticketFk = vTicketFk
- AND (c.isRenewable = FALSE
- OR
- (NOT vHasChangeAll
- AND (NOT (c.typeFk <=> vAddressTypeRateFk
- OR c.typeFk <=> vAgencyModeTypeRateFk))));
-
- SET @shipped = vShipped;
-
- DROP TEMPORARY TABLE
- tmp.buyUltimate,
- tmp.ticketLot;
-
- IF vShipped IS NULL THEN
- CALL util.throw('NO_ZONE_AVAILABLE');
- END IF;
-
- IF vShipped < CURDATE() THEN
- CALL util.throw('ERROR_PAST_SHIPMENT');
- 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 DROP PROCEDURE IF EXISTS `ticket_componentUpdate__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_componentUpdate__`(
- vTicketFk INT,
- vClientFk INT,
- vAgencyModeFk INT,
- vAddressFk INT,
- vZoneFk INT,
- vWarehouseFk TINYINT,
- vCompanyFk SMALLINT,
- vShipped DATETIME,
- vLanded DATE,
- vIsDeleted BOOLEAN,
- vHasToBeUnrouted BOOLEAN,
- vOption INT)
-BEGIN
- DECLARE vPrice DECIMAL(10,2);
- DECLARE vBonus DECIMAL(10,2);
- DECLARE EXIT HANDLER FOR SQLEXCEPTION
- BEGIN
- ROLLBACK;
- RESIGNAL;
- END;
-
- START TRANSACTION;
-
- IF (SELECT addressFk FROM ticket WHERE id = vTicketFk) <> vAddressFk THEN
-
- UPDATE ticket t
- JOIN address a ON a.id = vAddressFk
- SET t.nickname = a.nickname
- WHERE t.id = vTicketFk;
-
- END IF;
-
- CALL vn.zone_getShippedWarehouse(vlanded, vAddressFk, vAgencyModeFk);
-
- SELECT zoneFk, price, bonus INTO vZoneFk, vPrice, vBonus
- FROM tmp.zoneGetShipped
- WHERE shipped = vShipped AND warehouseFk = vWarehouseFk LIMIT 1;
-
- UPDATE ticket t
- SET
- t.clientFk = vClientFk,
- t.agencyModeFk = vAgencyModeFk,
- t.addressFk = vAddressFk,
- t.zoneFk = vZoneFk,
- t.zonePrice = vPrice,
- t.zoneBonus = vBonus,
- t.warehouseFk = vWarehouseFk,
- t.companyFk = vCompanyFk,
- t.landed = vLanded,
- t.shipped = vShipped,
- t.isDeleted = vIsDeleted
- WHERE
- t.id = vTicketFk;
-
- IF vHasToBeUnrouted THEN
- UPDATE ticket t SET t.routeFk = NULL
- WHERE t.id = vTicketFk;
- END IF;
-
- IF vOption <> 8 THEN
- DROP TEMPORARY TABLE IF EXISTS tmp.sale;
- CREATE TEMPORARY TABLE tmp.sale
- (PRIMARY KEY (saleFk))
- ENGINE = MEMORY
- SELECT id AS saleFk, vWarehouseFk warehouseFk
- FROM sale s WHERE s.ticketFk = vTicketFk;
-
- CALL ticketComponentUpdateSale (vOption);
-
- DROP TEMPORARY TABLE tmp.sale;
- END IF;
- COMMIT;
-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 DROP PROCEDURE IF EXISTS `ticket_DelayTruck` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -83380,8 +69665,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_DelayTruck`(vWarehouserFk INT, vHour INT, vMinute INT)
BEGIN
@@ -83398,7 +69681,7 @@ BEGIN
CREATE TEMPORARY TABLE tmp.ticket
SELECT ticketFk
FROM tmp.productionBuffer
- WHERE shipped = curdate()
+ WHERE shipped = util.VN_CURDATE()
AND problem LIKE '%I:%'
AND (HH <= vHour OR HH = vHour AND mm < vMinute)
AND alertLevel = 0;
@@ -83425,6 +69708,8 @@ DELIMITER ;
/*!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 `ticket_DelayTruckSplit` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -83432,8 +69717,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_DelayTruckSplit`(vTicketFk INT)
BEGIN
@@ -83491,6 +69774,8 @@ DELIMITER ;
/*!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 `ticket_doRecalc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -83498,8 +69783,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_doRecalc`()
proc: BEGIN
@@ -83577,6 +69860,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_doRefund` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -83584,8 +69869,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_doRefund`(IN vOriginTicket INT, OUT vNewTicket INT)
BEGIN
@@ -83604,10 +69887,17 @@ BEGIN
DECLARE vSaleNew INT;
DECLARE vSaleMain INT;
DECLARE vZoneFk INT;
+ DECLARE vDescription VARCHAR(50);
+ DECLARE vTaxClassFk INT;
+ DECLARE vTicketServiceTypeFk INT;
- DECLARE vRsMainTicket CURSOR FOR
+ DECLARE cSales CURSOR FOR
SELECT *
FROM tmp.sale;
+
+ DECLARE cTicketServices CURSOR FOR
+ SELECT *
+ FROM tmp.ticketService;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1;
@@ -83636,13 +69926,13 @@ BEGIN
)
SELECT
vCustomer,
- CURDATE(),
+ util.VN_CURDATE(),
vAddress,
vRefundAgencyMode,
a.nickname,
vWarehouse,
vCompany,
- CURDATE(),
+ util.VN_CURDATE(),
vZoneFk
FROM address a
WHERE a.id = vAddress;
@@ -83650,8 +69940,8 @@ BEGIN
SET vNewTicket = LAST_INSERT_ID();
SET vDone := 0;
- OPEN vRsMainTicket ;
- FETCH vRsMainTicket INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount;
+ OPEN cSales;
+ FETCH cSales INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount;
WHILE NOT vDone DO
@@ -83665,10 +69955,24 @@ BEGIN
FROM vn.saleComponent
WHERE saleFk = vSaleMain;
- FETCH vRsMainTicket INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount;
+ FETCH cSales INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount;
END WHILE;
- CLOSE vRsMainTicket;
+ CLOSE cSales;
+
+ SET vDone := 0;
+ OPEN cTicketServices;
+ FETCH cTicketServices INTO vDescription, vQuantity, vPrice, vTaxClassFk, vTicketServiceTypeFk;
+
+ WHILE NOT vDone DO
+
+ INSERT INTO vn.ticketService(description, quantity, price, taxClassFk, ticketFk, ticketServiceTypeFk)
+ VALUES(vDescription, vQuantity, vPrice, vTaxClassFk, vNewTicket, vTicketServiceTypeFk);
+
+ FETCH cTicketServices INTO vDescription, vQuantity, vPrice, vTaxClassFk, vTicketServiceTypeFk;
+
+ END WHILE;
+ CLOSE cTicketServices;
INSERT INTO vn.ticketRefund(refundTicketFk, originalTicketFk)
VALUES(vNewTicket, vOriginTicket);
@@ -83679,6 +69983,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_getFromFloramondo` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -83686,8 +69992,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getFromFloramondo`(vDateFrom DATE, vDateTo DATE)
BEGIN
@@ -83796,6 +70100,8 @@ DELIMITER ;
/*!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 `ticket_getMovable` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -83803,8 +70109,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getMovable`(vTicketFk INT, vDatedNew DATETIME, vWarehouseFk INT)
BEGIN
@@ -83853,6 +70157,8 @@ DELIMITER ;
/*!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 `ticket_getProblems` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -83860,8 +70166,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getProblems`(IN vIsTodayRelative tinyint(1))
BEGIN
@@ -83918,65 +70222,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `ticket_getProblems__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getProblems__`(IN vIsTodayRelative tinyint(1))
-BEGIN
-/**
- * Calcula los problemas para un conjunto de tickets.
- * Agrupados por ticket
- *
- * @table tmp.sale_getProblems(ticketFk, clientFk, warehouseFk, shipped) Identificadores de los tickets a calcular
- * @return tmp.ticket_problems
- */
- CALL sale_getProblems(vIsTodayRelative);
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticket_problems;
- CREATE TEMPORARY TABLE tmp.ticket_problems
- (PRIMARY KEY (ticketFk))
- ENGINE = MEMORY
- SELECT
- ticketFk,
- MAX(p.isFreezed) AS isFreezed,
- MAX(p.risk) AS risk,
- MAX(p.hasHighRisk) AS hasHighRisk,
- MAX(p.hasTicketRequest) AS hasTicketRequest,
- MIN(p.isAvailable) AS isAvailable,
- MAX(p.itemShortage) AS itemShortage,
- MIN(p.isTaxDataChecked) AS isTaxDataChecked,
- MAX(p.hasComponentLack) AS hasComponentLack,
- MAX(p.isTooLittle) AS isTooLittle,
- 0 AS totalProblems
- FROM tmp.sale_problems p
- GROUP BY ticketFk;
-
- UPDATE tmp.ticket_problems tp
- SET tp.totalProblems = (
- (tp.isFreezed) +
- IF(tp.risk, TRUE, FALSE) +
- (tp.hasTicketRequest) +
- (tp.isAvailable = 0) +
- (tp.isTaxDataChecked = 0) +
- (tp.hasComponentLack) +
- (tp.isTooLittle)
- );
-
- DROP TEMPORARY TABLE
- tmp.sale_problems;
-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 DROP PROCEDURE IF EXISTS `ticket_getShip` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -83984,8 +70231,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getShip`(vTicketFk INT)
BEGIN
@@ -83997,6 +70242,8 @@ DELIMITER ;
/*!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 `ticket_getSplitList` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -84004,8 +70251,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getSplitList`(vDated DATE, vHour TIME, vWarehouseFk INT)
BEGIN
@@ -84019,7 +70264,7 @@ BEGIN
DECLARE vAvailableCache INT;
DECLARE vVisibleCache INT;
- CALL cache.available_refresh(vAvailableCache, FALSE, vWarehouseFk, CURDATE());
+ CALL cache.available_refresh(vAvailableCache, FALSE, vWarehouseFk, util.VN_CURDATE());
CALL cache.visible_refresh(vVisibleCache, FALSE, vWarehouseFk);
CALL `vn`.`zoneClosure_recalc`();
@@ -84046,7 +70291,7 @@ BEGIN
AND s.isPicked = FALSE
AND s.reserved = FALSE
AND ic.merchandise = TRUE
- AND t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE())
+ AND t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
AND NOT i.generic
AND t.warehouseFk = vWarehouseFk;
@@ -84065,7 +70310,7 @@ BEGIN
AND s.isPicked = FALSE
AND s.reserved = FALSE
AND ic.merchandise = TRUE
- AND t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE())
+ AND t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
AND NOT i.generic
AND t.warehouseFk = vWarehouseFk;
@@ -84086,7 +70331,7 @@ BEGIN
AND s.isPicked = FALSE
AND s.reserved = FALSE
AND ic.merchandise = TRUE
- AND t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE())
+ AND t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
AND NOT i.generic
AND t.warehouseFk = vWarehouseFk;
@@ -84133,8 +70378,8 @@ BEGIN
LEFT JOIN vn.ticketState tst ON tst.ticketFk = t.id
LEFT JOIN vn.state st2 ON st2.id = tst.stateFk
WHERE (t.id IS NULL
- OR (vDated > CURDATE())
- OR (vDated = CURDATE() AND vHour >= zc.`hour`))
+ OR (vDated > util.VN_CURDATE())
+ OR (vDated = util.VN_CURDATE() AND vHour >= zc.`hour`))
AND ts.etd <= vHour
GROUP BY ts.ticketFk, t.id
ORDER BY ts.etd, ts.ticketFk;
@@ -84147,6 +70392,8 @@ DELIMITER ;
/*!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 `ticket_getTax` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -84154,8 +70401,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getTax`(IN vTaxArea VARCHAR(25))
BEGIN
@@ -84263,118 +70508,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `ticket_getTax__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getTax__`(vTaxArea VARCHAR(25))
- READS SQL DATA
-BEGIN
-/**
- * Calcula la base imponible, el IVA y el recargo de equivalencia para
- * un conjunto de tickets.
- *
- * @table tmp.ticket(ticketFk) Identificadores de los tickets a calcular
- * @return tmp.ticketAmount
- * @return tmp.ticketTax Impuesto desglosado para cada ticket.
- */
- DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany;
- CREATE TEMPORARY TABLE tmp.addressCompany
- (INDEX (addressFk, companyFk))
- ENGINE = MEMORY
- SELECT DISTINCT t.addressFk, t.companyFk
- FROM tmp.ticket tmpTicket
- JOIN ticket t ON t.id = tmpTicket.ticketFk;
-
- CALL addressTaxArea ();
-
- IF vTaxArea > '' THEN
- UPDATE tmp.addressTaxArea
- SET areaFk = vTaxArea;
- END IF;
- /** Solo se calcula la base imponible (taxableBase) y el impuesto se calculará posteriormente
- * No se debería cambiar el sistema por problemas con los decimales
- */
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketTax;
- CREATE TEMPORARY TABLE tmp.ticketTax
- (INDEX (ticketFk))
- ENGINE = MEMORY
- SELECT * FROM (
- SELECT tmpTicket.ticketFk,
- bp.pgcFk,
- SUM(s.quantity * s.price * (100 - s.discount)/100 ) AS taxableBase,
- pgc.rate,
- tc.code,
- bp.priority
- FROM tmp.ticket tmpTicket
- JOIN sale s ON s.ticketFk = tmpTicket.ticketFk
- JOIN item i ON i.id = s.itemFk
- JOIN ticket t ON t.id = tmpTicket.ticketFk
- JOIN supplier su ON su.id = t.companyFk
- JOIN tmp.addressTaxArea ata
- ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk
- JOIN itemTaxCountry itc
- ON itc.itemFk = i.id AND itc.countryFk = su.countryFk
- JOIN bookingPlanner bp
- ON bp.countryFk = su.countryFk
- AND bp.taxAreaFk = ata.areaFk
- AND bp.taxClassFk = itc.taxClassFk
- JOIN pgc ON pgc.code = bp.pgcFk
- JOIN taxClass tc ON tc.id = bp.taxClassFk
- GROUP BY tmpTicket.ticketFk, pgc.code,pgc.rate
- HAVING taxableBase != 0) t
- ORDER BY priority;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketServiceTax;
- CREATE TEMPORARY TABLE tmp.ticketServiceTax
- (INDEX (ticketFk))
- ENGINE = MEMORY
- SELECT tt.ticketFk,
- SUM(ts.quantity * ts.price) AS taxableBase,
- pgc.rate,
- tc.code
- FROM tmp.ticketTax tt
- JOIN ticketService ts ON ts.ticketFk = tt.ticketFk
- JOIN ticket t ON t.id = tt.ticketFk
- JOIN supplier su ON su.id = t.companyFk
- JOIN tmp.addressTaxArea ata
- ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk
- JOIN bookingPlanner bp
- ON bp.countryFk = su.countryFk
- AND bp.taxAreaFk = ata.areaFk
- AND bp.taxClassFk = ts.taxClassFk
- JOIN pgc ON pgc.code = bp.pgcFk AND pgc.rate = tt.rate
- JOIN taxClass tc ON tc.id = bp.taxClassFk
- GROUP BY tt.ticketFk, tt.code,tt.rate
- HAVING taxableBase != 0;
-
- UPDATE tmp.ticketTax tt
- JOIN tmp.ticketServiceTax ts ON tt.ticketFk = ts.ticketFk AND tt.code = ts.code AND tt.rate = ts.rate
- SET tt.taxableBase = tt.taxableBase + ts.taxableBase;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketAmount;
- CREATE TEMPORARY TABLE tmp.ticketAmount
- (INDEX (ticketFk))
- ENGINE = MEMORY
- SELECT ticketFk, taxableBase, SUM(CAST(taxableBase * rate / 100 AS DECIMAL(10, 2))) tax,code
- FROM tmp.ticketTax
- GROUP BY ticketFk, code;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany;
- DROP TEMPORARY TABLE IF EXISTS tmp.addressTaxArea;
-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 DROP PROCEDURE IF EXISTS `ticket_insertZone` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -84382,8 +70517,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_insertZone`()
BEGIN
@@ -84418,6 +70551,8 @@ DELIMITER ;
/*!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 `ticket_merge` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -84425,8 +70560,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_merge`(vSelf INT, vTicketTargetFk INT)
BEGIN
@@ -84444,7 +70577,7 @@ BEGIN
WHERE s.ticketFk = vSelf;
UPDATE vn.ticket t
- SET t.shipped = TIMESTAMPADD(YEAR, - YEAR(NOW()) MOD 2000, t.shipped )
+ SET t.shipped = TIMESTAMPADD(YEAR, - YEAR(util.VN_NOW()) MOD 2000, t.shipped )
WHERE t.id = vSelf;
END ;;
@@ -84453,6 +70586,8 @@ DELIMITER ;
/*!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 `ticket_priceDifference` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -84460,8 +70595,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_priceDifference`(
vTicketFk INT,
@@ -84510,6 +70643,8 @@ DELIMITER ;
/*!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 `ticket_recalc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -84517,8 +70652,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_recalc`(vTicketId INT)
BEGIN
@@ -84549,6 +70682,8 @@ DELIMITER ;
/*!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 `ticket_recalcComponents` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -84556,8 +70691,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_recalcComponents`(IN vTicketFk BIGINT, vIsTicketEditable BOOLEAN)
proc: BEGIN
@@ -84651,201 +70784,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `ticket_recalcComponentsForcePrice__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_recalcComponentsForcePrice__`(IN vTicketFk BIGINT, vIsTicketEditable BOOLEAN )
-proc: BEGIN
-
-/**
- * Este procedimiento trata de "rebionizar" un ticket,
- * eliminando los componentes existentes e insertandolos de nuevo
- *
- * @param vTicketFk Id del ticket
- * @return tmp.buyUltimate
- */
- DECLARE vShipped DATE;
- DECLARE vWarehouseFk SMALLINT;
- DECLARE vAgencyModeFk INT;
- DECLARE vAddressFk INT;
- DECLARE vLanded DATE;
- DECLARE vZoneFk INTEGER;
-
- IF vIsTicketEditable IS NULL THEN
- SELECT (IFNULL(ts.alertLevel,0) >0 or IFNULL(t.refFk,"") != "") = FALSE, t.zoneFk
- INTO vIsTicketEditable, vZoneFk
- FROM ticket t LEFT JOIN ticketState ts ON t.id = ts.ticket
- WHERE id = vTicketFk;
- END IF;
- SELECT warehouseFk, date(shipped), addressFk, agencyModeFk, landed
- INTO vWarehouseFk, vShipped, vAddressFk, vAgencyModeFk, vLanded
- FROM ticket
- WHERE id = vTicketFk;
-
- CALL vn.zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, TRUE);
-
- CALL vn.buyUltimate (vWarehouseFk, vShipped); -- rellena la tabla buyUltimate con la ultima compra
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
- CREATE TEMPORARY TABLE tmp.ticketLot
- SELECT vWarehouseFk warehouseFk, NULL available,
- s.itemFk, bu.buyFk
- FROM sale s
- LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
- WHERE s.ticketFk = vTicketFk
- GROUP BY s.itemFk;
-
- CALL vn.catalog_componentCalculate(vZoneFk, vAddressFk, vShipped);
-
- DROP TEMPORARY TABLE IF EXISTS tmp.sale;
- CREATE TEMPORARY TABLE tmp.sale
- (PRIMARY KEY (saleFk)) ENGINE = MEMORY
- SELECT id saleFk, vWarehouseFk warehouseFk
- FROM sale s
- WHERE s.ticketFk = vTicketFk;
-
- CALL vn.ticketComponentUpdateSale(IF(vIsTicketEditable,1,6)); -- si el ticket esta facturado, respeta los precios
-
- IF vLanded IS NULL THEN
-
- CALL zone_getLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk);
-
- UPDATE vn2008.Tickets t
- SET t.landing = (SELECT landed FROM tmp.zoneGetLanded)
- WHERE Id_Ticket = vTicketFk;
-
- DROP TEMPORARY TABLE tmp.zoneGetLanded;
-
- END IF;
-
- DROP TEMPORARY TABLE tmp.buyUltimate;
- DROP TEMPORARY TABLE tmp.ticketComponentPrice;
- DROP TEMPORARY TABLE tmp.ticketComponent;
- DROP TEMPORARY TABLE tmp.sale;
-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 DROP PROCEDURE IF EXISTS `ticket_recalcComponents__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_recalcComponents__`(IN vTicketFk BIGINT, vIsTicketEditable BOOLEAN)
-proc: BEGIN
-
-/**
- * Este procedimiento recalcula los componentes de un ticket,
- * eliminando los componentes existentes e insertandolos de nuevo
- *
- * @param vTicketFk Id del ticket
- * @param vIsTicketEditable si no se quiere forzar llamar con NULL
- */
- DECLARE vShipped DATE;
- DECLARE vWarehouseFk SMALLINT;
- DECLARE vAgencyModeFk INT;
- DECLARE vAddressFk INT;
- DECLARE vLanded DATE;
- DECLARE vZoneFk INTEGER;
-
- -- Santos 2021, borrar a partir del dia 31 PAK
- IF (SELECT COUNT(*)
- FROM tmp.routeDayMove ra
- JOIN vn.ticket t ON t.routeFk = ra.routeFk
- WHERE t.id = vTicketFk) THEN
-
- LEAVE proc;
-
- END IF;
-
- IF vIsTicketEditable IS NULL THEN
- SELECT IFNULL(ts.alertLevel,0) = 0 AND IFNULL(t.refFk,'') = ''
- INTO vIsTicketEditable
- FROM ticket t LEFT JOIN ticketState ts ON t.id = ts.ticket
- WHERE id = vTicketFk;
- END IF;
-
- SELECT t.warehouseFk,
- t.shipped,
- t.addressFk,
- t.agencyModeFk,
- t.landed,
- t.zoneFk
- INTO vWarehouseFk, vShipped, vAddressFk, vAgencyModeFk, vLanded, vZoneFk
- FROM ticket t LEFT JOIN ticketState ts ON t.id = ts.ticket
- WHERE t.id = vTicketFk;
-
- IF vLanded IS NULL OR vZoneFk IS NULL THEN
-
- CALL zone_getLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk, TRUE);
-
- IF (SELECT COUNT(*) FROM tmp.zoneGetLanded LIMIT 1) = 0 THEN
- CALL util.throw('There is no zone for these parameters');
- END IF;
-
- UPDATE ticket t
- SET t.landed = (SELECT landed FROM tmp.zoneGetLanded LIMIT 1)
- WHERE t.id = vTicketFk AND t.landed IS NULL;
-
- IF vZoneFk IS NULL THEN
- SELECT zoneFk INTO vZoneFk FROM tmp.zoneGetLanded LIMIT 1;
- UPDATE ticket t
- SET t.zoneFk = vZoneFk
- WHERE t.id = vTicketFk AND t.zoneFk IS NULL;
- END IF;
- DROP TEMPORARY TABLE tmp.zoneGetLanded;
-
- END IF;
-
- -- rellena la tabla buyUltimate con la ultima compra
- CALL buyUltimate (vWarehouseFk, vShipped);
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
- CREATE TEMPORARY TABLE tmp.ticketLot
- SELECT vWarehouseFk warehouseFk, NULL available,
- s.itemFk, bu.buyFk, vZoneFk zoneFk
- FROM sale s
- LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
- WHERE s.ticketFk = vTicketFk
- GROUP BY s.itemFk;
-
- CALL catalog_componentPrepare();
- CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk);
-
- DROP TEMPORARY TABLE IF EXISTS tmp.sale;
- CREATE TEMPORARY TABLE tmp.sale
- (PRIMARY KEY (saleFk)) ENGINE = MEMORY
- SELECT id saleFk, vWarehouseFk warehouseFk
- FROM sale s
- WHERE s.ticketFk = vTicketFk;
-
- -- si el ticket esta facturado, respeta los precios
- CALL ticketComponentUpdateSale(IF(vIsTicketEditable, 1, 6));
-
- CALL catalog_componentPurge();
- DROP TEMPORARY TABLE
- tmp.buyUltimate,
- tmp.sale;
-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 sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_requestRecalc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -84853,8 +70793,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_requestRecalc`(vSelf INT)
proc: BEGIN
@@ -84874,6 +70812,8 @@ DELIMITER ;
/*!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 `ticket_setNextState` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -84881,8 +70821,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setNextState`(vSelf INT)
BEGIN
@@ -84905,13 +70843,66 @@ BEGIN
INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador)
VALUES (vNewStateFk, vSelf, account.myUser_getId());
- SELECT TRUE AS IsUpdated;
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 `ticket_setParking` */;
+/*!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=`root`@`localhost` PROCEDURE `ticket_setParking`(IN `vTicketFk` VARCHAR(8), IN `vParkingFk` INT)
+proc: BEGIN
+ DECLARE vDone INT DEFAULT FALSE;
+ DECLARE vCollectionTicketFk INT;
+ DECLARE vCursor CURSOR FOR
+
+ SELECT IFNULL(tc2.ticketFk, t.id)
+ FROM ticket t
+ LEFT JOIN ticketCollection tc1 ON tc1.ticketFk = t.id
+ LEFT JOIN ticketCollection tc2 ON tc2.collectionFk = tc1.collectionFk
+ WHERE t.id = vTicketFk;
+
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
+
+ INSERT INTO vn.ticketParking(ticketFk, parkingFk)
+ SELECT IFNULL(tc2.ticketFk, t.id), vParkingFk
+ FROM ticket t
+ LEFT JOIN ticketCollection tc1 ON tc1.ticketFk = t.id
+ LEFT JOIN ticketCollection tc2 ON tc2.collectionFk = tc1.collectionFk
+ WHERE t.id = vTicketFk
+ ON DUPLICATE KEY UPDATE parkingFk = vParkingFk;
+
+ OPEN vCursor;
+ l: LOOP
+
+ FETCH vCursor INTO vCollectionTicketFk;
+
+ IF vDone THEN
+ LEAVE l;
+ END IF;
+
+ CALL vn.ticket_setNextState(vCollectionTicketFk);
+
+ END LOOP;
+
+ CLOSE vCursor;
+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 `ticket_setPreviousState` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -84919,8 +70910,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setPreviousState`(vTicketFk INT)
BEGIN
@@ -84954,15 +70943,14 @@ BEGIN
WHERE inter_id = vControlFk;
END IF;
-
- SELECT TRUE AS IsUpdated;
-
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 `ticket_setState` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -84970,8 +70958,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setState`(vTicketFk INT, vStateCode VARCHAR(45))
BEGIN
@@ -85004,6 +70990,8 @@ DELIMITER ;
/*!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 `ticket_split` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -85011,8 +70999,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_split`(vTicketFk INT, vTicketFutureFk INT, vDated DATE)
proc:BEGIN
@@ -85044,7 +71030,7 @@ proc:BEGIN
UPDATE vn.ticket
SET landed = vDated + 1,
shipped = vDated,
- nickname = CONCAT('(',DAY(curdate()),') ', nickname )
+ nickname = CONCAT('(',DAY(util.VN_CURDATE()),') ', nickname )
WHERE id = vTicketFk;
SELECT CONCAT("Se ha cambiado el ticket ", vTicketFk, " al dia ", vDated);
@@ -85094,6 +71080,8 @@ DELIMITER ;
/*!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 `ticket_splitItemPackingType` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -85101,8 +71089,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_splitItemPackingType`(vTicketFk INT)
proc:BEGIN
@@ -85223,6 +71209,8 @@ DELIMITER ;
/*!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 `ticket_splitPackingComplete` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -85230,8 +71218,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_splitPackingComplete`(vTicketFk INT, vSectorFk INT)
BEGIN
@@ -85278,6 +71264,8 @@ DELIMITER ;
/*!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 `ticket_WeightDeclaration` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -85285,8 +71273,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_WeightDeclaration`(vClientFk INT, vDated DATE)
BEGIN
@@ -85341,6 +71327,8 @@ DELIMITER ;
/*!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 `timeBusiness_calculate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -85348,12 +71336,9 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `timeBusiness_calculate`(vDatedFrom DATETIME, vDatedTo DATETIME)
BEGIN
-
/**
* Horas que debe trabajar un empleado según contrato y día.
* @param vDatedFrom workerTimeControl
@@ -85361,7 +71346,6 @@ BEGIN
* @table tmp.user(userFk)
* @return tmp.timeBusinessCalculate
*/
-
DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate;
CREATE TEMPORARY TABLE tmp.timeBusinessCalculate
@@ -85378,7 +71362,7 @@ BEGIN
timeWorkSeconds timeBusinessSeconds,
SEC_TO_TIME(timeWorkSeconds) timeBusinessSexagesimal,
timeWorkSeconds / 3600 timeBusinessDecimal,
- type,
+ name type,
permissionRate,
hoursWeek,
discountRate,
@@ -85391,27 +71375,27 @@ BEGIN
IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.end,5) ORDER BY j.end ASC SEPARATOR ' - ')) hourEnd,
IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.start,5), " - ", LEFT(j.end,5) ORDER BY j.end ASC SEPARATOR ' - ')) timeTable,
IF(j.start = NULL, 0, IFNULL(SUM(TIME_TO_SEC(j.end)) - SUM(TIME_TO_SEC(j.start)),0)) timeWorkSeconds,
- cs.type,
- cs.permissionRate,
- cs.discountRate,
+ at2.name,
+ at2.permissionRate,
+ at2.discountRate,
cl.hours_week hoursWeek,
- cs.isAllowedToWork
+ at2.isAllowedToWork
FROM vn.time t
- LEFT JOIN postgresql.business b ON t.dated BETWEEN b.date_start AND ifnull(b.date_end, vDatedTo )
- LEFT JOIN postgresql.profile AS pr ON b.client_id = pr.profile_id
- LEFT JOIN postgresql.person AS p ON pr.person_id = p.person_id
- LEFT JOIN vn.worker AS w ON p.id_trabajador = w.id
+ LEFT JOIN postgresql.business b ON t.dated BETWEEN b.date_start AND IFNULL(b.date_end, vDatedTo )
+ LEFT JOIN postgresql.profile pr ON b.client_id = pr.profile_id
+ LEFT JOIN postgresql.person p ON pr.person_id = p.person_id
+ LEFT JOIN vn.worker w ON p.id_trabajador = w.id
JOIN tmp.`user` u ON u.userFK = w.userFK
- JOIN postgresql.business_labour AS bl ON b.business_id = bl.business_id
- LEFT JOIN postgresql.business_labour_payroll AS bp ON bl.business_id = bp.business_id
- LEFT JOIN postgresql.professional_category AS pc ON bl.professional_category_id = pc.professional_category_id
- LEFT JOIN postgresql.workcenter AS wc ON bl.workcenter_id = wc.workcenter_id
- LEFT JOIN postgresql.calendar_labour_type AS cl ON bl.calendar_labour_type_id = cl.calendar_labour_type_id
- LEFT JOIN postgresql.journey AS j ON j.business_id = b.business_id and j.day_id=WEEKDAY(t.dated)+1
- LEFT JOIN postgresql.calendar_employee ce ON ce.business_id=b.business_id and ce.date = t.dated
- LEFT JOIN postgresql.calendar_state cs ON cs.calendar_state_id = ce.calendar_state_id
+ JOIN postgresql.business_labour bl ON b.business_id = bl.business_id
+ LEFT JOIN postgresql.business_labour_payroll bp ON bl.business_id = bp.business_id
+ LEFT JOIN postgresql.professional_category pc ON bl.professional_category_id = pc.professional_category_id
+ LEFT JOIN vn.workCenter wc ON bl.workcenter_id = wc.id
+ LEFT JOIN postgresql.calendar_labour_type cl ON bl.calendar_labour_type_id = cl.calendar_labour_type_id
+ LEFT JOIN postgresql.journey j ON j.business_id = b.business_id AND j.day_id=WEEKDAY(t.dated)+1
+ LEFT JOIN postgresql.calendar_employee ce ON ce.business_id=b.business_id AND ce.date = t.dated
+ LEFT JOIN vn.absenceType at2 ON at2.id = ce.calendar_state_id
WHERE t.dated BETWEEN vDatedFrom AND vDatedTo
- GROUP BY w.userFk,dated
+ GROUP BY w.userFk,dated
)sub;
UPDATE tmp.timeBusinessCalculate t
@@ -85446,6 +71430,8 @@ DELIMITER ;
/*!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 `timeBusiness_calculateAll` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -85453,8 +71439,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `timeBusiness_calculateAll`(vDatedFrom DATETIME, vDatedTo DATETIME)
BEGIN
@@ -85482,6 +71466,8 @@ DELIMITER ;
/*!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 `timeBusiness_calculateByDepartment` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -85489,8 +71475,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `timeBusiness_calculateByDepartment`(vDepartmentFk INT, vDatedFrom DATETIME, vDatedTo DATETIME)
BEGIN
@@ -85527,6 +71511,8 @@ DELIMITER ;
/*!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 `timeBusiness_calculateByUser` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -85534,8 +71520,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `timeBusiness_calculateByUser`(vUserFk INT, vDatedFrom DATETIME, vDatedTo DATETIME)
BEGIN
@@ -85562,6 +71546,8 @@ DELIMITER ;
/*!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 `timeBusiness_calculateByWorker` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -85569,8 +71555,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `timeBusiness_calculateByWorker`(vWorkerFk INT, vDatedFrom DATETIME, vDatedTo DATETIME)
BEGIN
@@ -85599,123 +71583,15 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `timeBusiness_calculate__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `timeBusiness_calculate__`(vDatedFrom DATETIME, vDatedTo DATETIME)
-BEGIN
-
-/**
- * Horas que debe trabajar un empleado según contrato y día.
- * @param vDatedFrom workerTimeControl
- * @param vDatedTo workerTimeControl
- * @table tmp.user(userFk)
- * @return tmp.timeBusinessCalculate
- */
-
- DROP TABLE IF EXISTS tmp.timeBusinessCalculate;
- DROP TEMPORARY TABLE IF EXISTS tmp.businessFullTime;
-
- CALL rangeDateInfo(vDatedFrom, vDatedTo);
-
- CREATE TABLE tmp.timeBusinessCalculate
- SELECT dated,
- businessFk,
- userFk,
- departmentFk,
- hourStart,
- hourEnd,
- timeTable,
- timeWorkSeconds,
- SEC_TO_TIME(timeWorkSeconds) timeWorkSexagesimal,
- timeWorkSeconds / 3600 timeWorkDecimal,
- timeWorkSeconds timeBusinessSeconds,
- SEC_TO_TIME(timeWorkSeconds) timeBusinessSexagesimal,
- timeWorkSeconds / 3600 timeBusinessDecimal,
- type,
- permissionRate,
- hoursWeek,
- discountRate
- FROM(SELECT rd.dated,
- b.business_id businessFk,
- w.userFk,
- bl.department_id departmentFk,
- IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.start,5) ORDER BY j.start ASC SEPARATOR ' - ')) hourStart ,
- IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.end,5) ORDER BY j.end ASC SEPARATOR ' - ')) hourEnd,
- IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.start,5), " - ", LEFT(j.end,5) ORDER BY j.end ASC SEPARATOR ' - ')) timeTable,
- IF(j.start = NULL, 0, IFNULL(SUM(TIME_TO_SEC(j.end)) - SUM(TIME_TO_SEC(j.start)),0)) timeWorkSeconds,
- cs.type,
- cs.permissionRate,
- cs.discountRate,
- cl.hours_week hoursWeek
- FROM tmp.rangeDate rd
- LEFT JOIN postgresql.business b ON rd.dated BETWEEN b.date_start AND ifnull(b.date_end, vDatedTo )
- LEFT JOIN postgresql.profile AS pr ON b.client_id = pr.profile_id
- LEFT JOIN postgresql.person AS p ON pr.person_id = p.person_id
- LEFT JOIN vn.worker AS w ON p.id_trabajador = w.id
- JOIN tmp.`user` u ON u.userFK = w.userFK
- JOIN postgresql.business_labour AS bl ON b.business_id = bl.business_id
- LEFT JOIN postgresql.business_labour_payroll AS bp ON bl.business_id = bp.business_id
- LEFT JOIN postgresql.professional_category AS pc ON bl.professional_category_id = pc.professional_category_id
- LEFT JOIN postgresql.workcenter AS wc ON bl.workcenter_id = wc.workcenter_id
- LEFT JOIN postgresql.calendar_labour_type AS cl ON bl.calendar_labour_type_id = cl.calendar_labour_type_id
- LEFT JOIN postgresql.journey AS j ON j.business_id = b.business_id and j.day_id=WEEKDAY(rd.dated)+1
- LEFT JOIN postgresql.calendar_employee ce ON ce.business_id=b.business_id and ce.date = rd.dated
- LEFT JOIN postgresql.calendar_state cs ON cs.calendar_state_id = ce.calendar_state_id
- WHERE rd.dated BETWEEN vDatedFrom AND vDatedTo
- GROUP BY w.userFk,dated
- )sub;
-
-
- UPDATE tmp.timeBusinessCalculate t
- LEFT JOIN postgresql.journey j ON j.business_id = t.businessFk
- SET t.timeWorkSeconds = t.hoursWeek / 5 * 3600,
- t.timeWorkSexagesimal = SEC_TO_TIME( t.hoursWeek / 5 * 3600),
- t.timeWorkDecimal = t.hoursWeek / 5,
- t.timeBusinessSeconds = t.hoursWeek / 5 * 3600,
- t.timeBusinessSexagesimal = SEC_TO_TIME( t.hoursWeek / 5 * 3600),
- t.timeBusinessDecimal = t.hoursWeek / 5
- WHERE DAYOFWEEK(t.dated) IN(2,3,4,5,6) AND j.journey_id IS NULL ;
-
- UPDATE tmp.timeBusinessCalculate t
- SET t.timeWorkSeconds = t.timeWorkSeconds - (t.timeWorkSeconds * permissionRate) ,
- t.timeWorkSexagesimal = SEC_TO_TIME ((t.timeWorkDecimal - (t.timeWorkDecimal * permissionRate)) * 3600),
- t.timeWorkDecimal = t.timeWorkDecimal - (t.timeWorkDecimal * permissionRate)
- WHERE permissionRate <> 0;
-
-UPDATE tmp.timeBusinessCalculate t
- JOIN vn.calendarHolidays ch ON ch.dated = t.dated
- JOIN postgresql.business_labour bl ON bl.business_id = t.businessFk AND bl.workcenter_id = ch.workcenterFk
- SET t.timeWorkSeconds = 0,
- t.timeWorkSexagesimal = 0,
- t.timeWorkDecimal = 0,
- t.permissionrate = 1,
- t.type = 'Festivo'
- WHERE t.type IS NULL;
-
-DROP TEMPORARY TABLE IF EXISTS tmp.rangeDate;
-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 DROP PROCEDURE IF EXISTS `timeControl_calculate` */;
/*!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_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_calculate`(vDatedFrom DATETIME, vDatedTo DATETIME)
BEGIN
@@ -85847,6 +71723,7 @@ BEGIN
wtc.userFk
FROM tmp.workerTimeControl wtc
ORDER BY wtc.userFk, wtc.timed, wtc.id
+ LIMIT 10000000000000000000
)sub
GROUP BY sub.userFk, sub.dated
HAVING SUM(sub.timeWork) >= vTimeToBreakTime;
@@ -85892,6 +71769,8 @@ DELIMITER ;
/*!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 `timeControl_calculateAll` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -85899,8 +71778,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_calculateAll`(vDatedFrom DATETIME, vDatedTo DATETIME)
BEGIN
@@ -85928,6 +71805,8 @@ DELIMITER ;
/*!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 `timeControl_calculateByDepartment` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -85935,8 +71814,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_calculateByDepartment`(vDepartmentFk INT, vDatedFrom DATETIME, vDatedTo DATETIME)
BEGIN
@@ -85973,6 +71850,8 @@ DELIMITER ;
/*!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 `timeControl_calculateByUser` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -85980,8 +71859,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_calculateByUser`(vUserFk INT, vDatedFrom DATETIME, vDatedTo DATETIME)
BEGIN
@@ -86008,6 +71885,8 @@ DELIMITER ;
/*!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 `timeControl_calculateByWorker` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -86015,8 +71894,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_calculateByWorker`(vWorkerFk INT, vDatedFrom DATETIME, vDatedTo DATETIME)
BEGIN
@@ -86045,70 +71922,15 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `timeControl_calculate__` */;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `timeControl_getError` */;
/*!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_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_calculate__`(vDatedFrom DATETIME, vDatedTo DATETIME)
-BEGIN
- SET @vIsOdd := TRUE;
- SET @vUser := NULL;
- SET @vDated := NULL;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate;
-
- CREATE TEMPORARY TABLE tmp.timeControlCalculate
- SELECT
- userFk,
- dated,
- IF( timeWork >= 18000, @timeWork:=timeWork + 1200, @timeWork:=timeWork) timeWorkSeconds,
- SEC_TO_TIME(@timeWork ) timeWorkSexagesimal,
- @timeWork / 3600 timeWorkDecimal,
- timed
- FROM (SELECT SUM(timeWork) timeWork,
- userFk,
- dated,
- GROUP_CONCAT(DATE_FORMAT(sub.timed,"%H:%i") ORDER BY sub.timed ASC SEPARATOR ' - ') timed
- FROM (SELECT IF(@vUser = wtc.userFk, @vUser :=@vUser, @vUser := wtc.userFk),
- IF(@vIsOdd, @vIsOdd := FALSE, @vIsOdd := TRUE),
- IF(direction='in', @vIsOdd := TRUE, @vIsOdd := @vIsOdd),
- IF(@vIsOdd, @vLastTimed:=UNIX_TIMESTAMP(timed),@vLastTimed:=@vLastTimed),
- IF(@vIsOdd, 0, UNIX_TIMESTAMP(timed)-@vLastTimed) timeWork,
- IF(direction='in', @vDated := DATE(wtc.timed), @vDated) dated,
- wtc.timed timed,
- wtc.userFk,
- direction
- FROM (SELECT DISTINCT(wtc.id), wtc.userFk, wtc.timed, wtc.direction
- FROM workerTimeControl wtc
- JOIN tmp.`user` w ON w.userFk = wtc.userFk
- WHERE wtc.timed BETWEEN vDatedFrom AND vDatedTo
- ORDER BY userFk, timed ASC
- ) wtc
- WHERE wtc.timed BETWEEN vDatedFrom AND vDatedTo
- ) sub
- GROUP BY userFk, dated
- )sub2;
-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 DROP PROCEDURE IF EXISTS `timeControl_getError` */;
-/*!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 = utf8 */ ;
-/*!50003 SET character_set_results = utf8 */ ;
-/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_getError`(vDatedFrom DATETIME, vDatedTo DATETIME)
BEGIN
@@ -86156,33 +71978,35 @@ BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp.timeControlError;
CREATE TEMPORARY TABLE tmp.timeControlError
- (INDEX(id))
- ENGINE = MEMORY
+ (INDEX(id))
+ ENGINE = MEMORY
SELECT id
FROM tmp.timeControlAux tca
- JOIN (SELECT journeyCounter,
- UNIX_TIMESTAMP(MAX(timed)) - UNIX_TIMESTAMP(MIN(timed)) timeWork,
- SUM(direction = 'in') totalIn,
- SUM(direction = 'out') totalOut,
- timed
- FROM tmp.timeControl
- GROUP BY journeyCounter
- HAVING COUNT(*) MOD 2 = 1
- OR totalIn <> 1
- OR totalOut <> 1
- OR timeWork >= vDayMaxTime
- )sub ON sub.journeyCounter = tca.journeyCounter
+ JOIN (
+ SELECT journeyCounter,
+ UNIX_TIMESTAMP(MAX(timed)) - UNIX_TIMESTAMP(MIN(timed)) timeWork,
+ SUM(direction = 'in') totalIn,
+ SUM(direction = 'out') totalOut,
+ timed
+ FROM tmp.timeControl
+ GROUP BY journeyCounter
+ HAVING COUNT(*) MOD 2 = 1
+ OR totalIn <> 1
+ OR totalOut <> 1
+ OR timeWork >= vDayMaxTime
+ )sub ON sub.journeyCounter = tca.journeyCounter
WHERE sub.timed BETWEEN vDatedFrom AND vDatedTo;
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.timeControl;
DROP TEMPORARY TABLE IF EXISTS tmp.timeControlAux;
-
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 `timeWorkerControl_check` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -86190,8 +72014,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `timeWorkerControl_check`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100))
proc: BEGIN
@@ -86206,6 +72028,8 @@ DELIMITER ;
/*!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 `tpvTransaction_checkStatus` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -86213,8 +72037,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `tpvTransaction_checkStatus`()
BEGIN
@@ -86235,7 +72057,7 @@ BEGIN
FROM hedera.tpvTransaction t
WHERE t.receiptFk IS NULL
AND t.status = 'ok'
- AND t.created < DATE_ADD(NOW(),INTERVAL - 2 DAY)
+ AND t.created < DATE_ADD(util.VN_NOW(),INTERVAL - 2 DAY)
GROUP BY t.clientFk;
END ;;
@@ -86244,6 +72066,8 @@ DELIMITER ;
/*!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 `travelVolume` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -86251,8 +72075,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `travelVolume`(vTravelFk INT)
BEGIN
@@ -86287,6 +72109,8 @@ DELIMITER ;
/*!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 `travelVolume_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -86294,8 +72118,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `travelVolume_get`(vFromDated DATE, vToDated DATE, vWarehouseFk INT)
BEGIN
@@ -86319,6 +72141,8 @@ DELIMITER ;
/*!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 `travel_checkDates` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -86326,8 +72150,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_checkDates`(vShipped DATE, vLanded DATE)
BEGIN
@@ -86349,6 +72171,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `travel_clone` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -86356,8 +72180,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_clone`(vSelf INT, vDays INT, OUT vNewTravelFk INT)
BEGIN
@@ -86414,6 +72236,8 @@ DELIMITER ;
/*!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 `travel_cloneWithEntries` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -86421,8 +72245,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_cloneWithEntries`(
IN vTravelFk INT,
@@ -86570,148 +72392,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `travel_cloneWithEntries__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_cloneWithEntries__`(IN vTravelFk INT, IN vDateStart DATE, IN vDateEnd DATE,
- IN vRef VARCHAR(255), OUT vNewTravelFk INT)
-BEGIN
- DECLARE vEntryNew INT;
- DECLARE vDone BOOLEAN DEFAULT FALSE;
- DECLARE vAuxEntryFk INT;
- DECLARE vRsEntry CURSOR FOR
- SELECT e.id
- FROM entry e
- JOIN travel t
- ON t.id = e.travelFk
- WHERE e.travelFk = vTravelFk;
-
- DECLARE vRsBuy CURSOR FOR
- SELECT b.*
- FROM buy b
- JOIN entry e
- ON b.entryFk = e.id
- WHERE e.travelFk = vNewTravelFk and b.entryFk=vNewTravelFk
- ORDER BY e.id;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
-
- DECLARE EXIT HANDLER FOR SQLEXCEPTION
- BEGIN
- ROLLBACK;
- RESIGNAL;
- END;
-
- START TRANSACTION;
-
- INSERT INTO travel (shipped,landed, warehouseInFk, warehouseOutFk, agencyFk, ref, isDelivered, isReceived, m3, kg)
- SELECT vDateStart, vDateEnd,warehouseInFk, warehouseOutFk, agencyFk, vRef, isDelivered, isReceived, m3, kg
- FROM travel
- WHERE id = vTravelFk;
-
- SET vNewTravelFk = LAST_INSERT_ID();
- SET vDone = FALSE;
- OPEN vRsEntry ;
- FETCH vRsEntry INTO vAuxEntryFk;
-
- WHILE NOT vDone DO
- INSERT INTO entry (supplierFk,
- ref,
- isInventory,
- isConfirmed,
- isOrdered,
- isRaid,
- commission,
- created,
- evaNotes,
- travelFk,
- currencyFk,
- companyFk,
- gestDocFk,
- invoiceInFk)
- SELECT supplierFk,
- ref,
- isInventory,
- isConfirmed,
- isOrdered,
- isRaid,
- commission,
- created,
- evaNotes,
- vNewTravelFk,
- currencyFk,
- companyFk,
- gestDocFk,
- invoiceInFk
- FROM entry
- WHERE id = vAuxEntryFk;
-
- SET vEntryNew = LAST_INSERT_ID();
-
-
- INSERT INTO buy (entryFk,
- itemFk,
- quantity,
- buyingValue,
- packageFk,
- stickers,
- freightValue,
- packageValue,
- comissionValue,
- packing,
- `grouping`,
- groupingMode,
- location,
- price1,
- price2,
- price3,
- minPrice,
- producer,
- printedStickers,
- isChecked,
- weight)
- SELECT vEntryNew,
- itemFk,
- quantity,
- buyingValue,
- packageFk,
- stickers,
- freightValue,
- packageValue,
- comissionValue,
- packing,
- `grouping`,
- groupingMode,
- location,
- price1,
- price2,
- price3,
- minPrice,
- producer,
- printedStickers,
- isChecked,
- weight
- FROM buy
- WHERE entryFk = vAuxEntryFk;
-
-
- FETCH vRsEntry INTO vAuxEntryFk;
- END WHILE;
- CLOSE vRsEntry;
- COMMIT;
-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 DROP PROCEDURE IF EXISTS `travel_doRecalc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -86719,8 +72401,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_doRecalc`()
BEGIN
@@ -86765,6 +72445,8 @@ DELIMITER ;
/*!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 `travel_moveRaids` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -86772,8 +72454,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_moveRaids`()
BEGIN
@@ -86824,7 +72504,7 @@ BEGIN
SET tr.landed = TIMESTAMPADD(DAY, 1, tr.landed);
INSERT INTO travelLog (originFk, userFk , action, description)
- SELECT ttr.id, account.userGetId(), 'update', CONCAT('Se ha cambiado la fecha del travel al dia ', util.tomorrow())
+ SELECT ttr.id, account.myUser_getId(), 'update', CONCAT('Se ha cambiado la fecha del travel al dia ', util.tomorrow())
FROM tmp.travel ttr;
OPEN vCur;
@@ -86854,6 +72534,8 @@ DELIMITER ;
/*!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 `travel_requestRecalc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -86861,8 +72543,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_requestRecalc`(vSelf INT)
proc: BEGIN
@@ -86882,6 +72562,8 @@ DELIMITER ;
/*!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 `travel_weeklyClone` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -86889,8 +72571,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_weeklyClone`(vSinceWeek INT, vToWeek INT)
BEGIN
@@ -86912,7 +72592,7 @@ BEGIN
DECLARE vDone BOOLEAN DEFAULT FALSE;
DECLARE vRsTravel CURSOR FOR
SELECT travelFk,
- @a := TIMESTAMPADD(DAY,vCounter * 7 - WEEKDAY(CURDATE()) - 1 + weekDay,CURDATE()),
+ @a := TIMESTAMPADD(DAY,vCounter * 7 - WEEKDAY(util.VN_CURDATE()) - 1 + weekDay,util.VN_CURDATE()),
@a := TIMESTAMPADD(DAY,duration,@a),
warehouseOutFk,
warehouseInFk,
@@ -86926,7 +72606,7 @@ BEGIN
SET vCounter = vSinceWeek;
vWeekLoop :LOOP
INSERT IGNORE INTO travel (shipped, landed, warehouseOutFk, warehouseInFk, agencyFk, ref, cargoSupplierFk, kg)
- SELECT @a := TIMESTAMPADD(DAY, vCounter * 7 - WEEKDAY(CURDATE()) - 1 + weekDay,CURDATE()),
+ SELECT @a := TIMESTAMPADD(DAY, vCounter * 7 - WEEKDAY(util.VN_CURDATE()) - 1 + weekDay,util.VN_CURDATE()),
@a := TIMESTAMPADD(DAY, duration, @a),
warehouseOutFk,
warehouseInFk,
@@ -86958,6 +72638,8 @@ DELIMITER ;
/*!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 `typeTagMake` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -86965,8 +72647,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `typeTagMake`(vTypeFk INT)
BEGIN
@@ -87029,6 +72709,8 @@ DELIMITER ;
/*!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 `updatePedidosInternos` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -87036,8 +72718,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `updatePedidosInternos`(vItemFk INT)
BEGIN
@@ -87051,6 +72731,8 @@ DELIMITER ;
/*!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 `visible_getMisfit` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -87058,8 +72740,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `visible_getMisfit`(vSectorFk INT)
BEGIN
@@ -87110,6 +72790,8 @@ DELIMITER ;
/*!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 `warehouseFitting` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -87117,8 +72799,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `warehouseFitting`(IN vWhOrigin INT , IN vWhDestiny INT)
BEGIN
@@ -87148,6 +72828,8 @@ DELIMITER ;
/*!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 `warehouseFitting_byTravel` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -87155,8 +72837,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `warehouseFitting_byTravel`(IN vTravelFk INT)
BEGIN
@@ -87176,6 +72856,8 @@ DELIMITER ;
/*!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 `workerCalculateBoss` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -87183,8 +72865,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerCalculateBoss`(vWorker INT)
BEGIN
@@ -87217,6 +72897,8 @@ DELIMITER ;
/*!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 `workerCalendar_calculateBusiness` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -87224,8 +72906,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerCalendar_calculateBusiness`(vYear INT, vBusinessFk INT)
BEGIN
@@ -87290,79 +72970,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `workerCalendar_calculateBusiness__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `workerCalendar_calculateBusiness__`(vYear INT, vBusinessFk INT)
-BEGIN
-
-/**
- * Calcula los días y horas de vacaciones en función de un contrato y año
- *
- * @param vYear
- * @param vBusinessFk
- * @return tmp.workerCalendarCalculateBusiness (days, hours, daysEnjoyed, hoursEnjoyed)
- */
-
- DECLARE vStarted DATE;
- DECLARE vEnded DATE;
- DECLARE vDaysHoliday DECIMAL(5,2);
- DECLARE vHoursWeek DECIMAL(5,2);
- DECLARE vDaysToSubtract DECIMAL(5,2);
- DECLARE vDaysHolidayEnjoyed DECIMAL(5,2);
- DECLARE vDifDays INT;
-
- SELECT IF(b.date_start < CONCAT(vYear,"-01-01"), CONCAT(vYear,"-01-01"),b.date_start),
- IF(b.date_end IS NULL OR YEAR(b.date_end)>vYear , CONCAT(vYear,"-12-31"), b.date_end),
- IF(hasHolidayEntilement, w.days, 0),
- c.hours_week
- INTO vStarted,
- vEnded,
- vDaysHoliday,
- vHoursWeek
- FROM postgresql.business b
- JOIN postgresql.business_labour_payroll blp ON blp.business_id = b.business_id
- JOIN vn2008.payroll_contratos p ON p.CodContrato = cod_contrato
- JOIN postgresql.business_labour bl ON bl.business_id = b.business_id
- JOIN workCenterHoliday w ON w.workcenterFk = bl.workcenter_id
- LEFT JOIN postgresql.calendar_labour_type c ON c.calendar_labour_type_id=bl.calendar_labour_type_id
- WHERE b.business_id= vBusinessFk
- AND w.year = vYear;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.workerCalendarCalculateBusiness;
-
- IF vStarted < vEnded THEN
- SET vDifDays = DAYOFYEAR(vEnded) - DAYOFYEAR(vStarted) + 1;
-
- SELECT IFNULL(SUM(holidayEntitlementRate), 0) ,
- SUM(-(discountRate - 1))
- INTO vDaysToSubtract,
- vDaysHolidayEnjoyed
- FROM workerCalendar w
- JOIN absenceType a ON a.id = w.absenceTypeFk
- WHERE w.businessFk = vBusinessFk
- AND YEAR(dated) = vYear;
- END IF;
-
- CREATE TEMPORARY TABLE tmp.workerCalendarCalculateBusiness
- ENGINE = MEMORY
- SELECT @days := IFNULL(ROUND((vDaysHoliday * (vDifDays - vDaysToSubtract) / IF(util.isLeapYear(vYear) , 366, 365)), 1), 0) days,
- @days * (vHoursWeek / 5) hours,
- @daysEnjoyed := IFNULL(ROUND(vDaysHolidayEnjoyed, 1), 0) daysEnjoyed,
- @daysEnjoyed * (vHoursWeek / 5) hoursEnjoyed;
-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 DROP PROCEDURE IF EXISTS `workerCalendar_calculateYear` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -87370,8 +72979,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerCalendar_calculateYear`(vYear INT, vWorkerFk INT)
BEGIN
@@ -87438,6 +73045,8 @@ DELIMITER ;
/*!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 `workerCreate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -87445,8 +73054,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerCreate`(
vFirstname VARCHAR(50),
@@ -87468,6 +73075,8 @@ DELIMITER ;
/*!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 `workerCreateExternal` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -87475,8 +73084,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerCreateExternal`(
vFirstName VARCHAR(50),
@@ -87516,37 +73123,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `workerCreate__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `workerCreate__`(
- vFirstname VARCHAR(50),
- vSurnames VARCHAR(50),
- vFi VARCHAR(9),
- vWorkerCode CHAR(3),
- vBossFk INT,
- vUserFk INT
-)
-BEGIN
-/**
- * Create new worker
- *
- */
- INSERT INTO worker(code, firstName, lastName, fi, userFk, bossFk)
- VALUES (vWorkerCode, vFirstname, vSurnames, vFi, vUserFk, vBossFk);
-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 DROP PROCEDURE IF EXISTS `workerDepartmentByDate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -87554,8 +73132,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerDepartmentByDate`(vDate DATE)
BEGIN
@@ -87593,6 +73169,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerDisable` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -87600,13 +73178,11 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerDisable`(vUserId int)
mainLabel:BEGIN
- IF (SELECT COUNT(*) FROM workerDisableExcluded WHERE workerFk = vUserId AND (dated > CURDATE() OR dated IS NULL)) > 0 THEN
+ IF (SELECT COUNT(*) FROM workerDisableExcluded WHERE workerFk = vUserId AND (dated > util.VN_CURDATE() OR dated IS NULL)) > 0 THEN
LEAVE mainLabel;
END IF;
DELETE FROM account.account
@@ -87633,6 +73209,8 @@ DELIMITER ;
/*!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 `workerDisableAll` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -87640,8 +73218,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerDisableAll`()
BEGIN
@@ -87652,7 +73228,8 @@ BEGIN
SELECT a.id
FROM ((SELECT * FROM (select date_end,date_start,business_id, client_id
FROM postgresql.business
- ORDER BY client_id, date_end IS NULL DESC , date_end DESC)
+ ORDER BY client_id, date_end IS NULL DESC , date_end DESC
+ LIMIT 10000000000000000000)
c GROUP BY client_id) c
INNER JOIN postgresql.business b ON c.client_id = b.client_id AND c.business_id = b.business_id
INNER JOIN postgresql.profile pr ON b.client_id = pr.profile_id
@@ -87661,8 +73238,8 @@ BEGIN
INNER JOIN vn.worker w ON p.id_trabajador = w.id)
INNER JOIN account.account a ON w.userFk = a.id
WHERE ((b.date_end) IS NOT NULL
- AND (b.date_end) < CURDATE()
- AND (b.date_end) > TIMESTAMPADD(DAY, -70,CURDATE()) );
+ AND (b.date_end) < util.VN_CURDATE()
+ AND (b.date_end) > TIMESTAMPADD(DAY, -70,util.VN_CURDATE()) );
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
@@ -87684,42 +73261,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `workerDisable__` */;
-/*!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_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `workerDisable__`(vUserId int)
-mainLabel:BEGIN
-
- IF vUserId = 14255 THEN
- LEAVE mainLabel;
- END IF;
- DELETE FROM account.account
- WHERE id = vUserId;
-
- UPDATE account.user
- SET role = 2
- WHERE id = vUserId;
-
- DELETE FROM pbx.sip
- WHERE user_id = vUserId;
-
- UPDATE `client` c
- JOIN payMethod p ON p.name = 'CONTADO'
- SET c.credit = 0, c.payMethodFk = p.id, hasCoreVnl = FALSE
- WHERE c.id = vUserId;
-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 sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerForAllCalculateBoss` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -87727,8 +73270,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerForAllCalculateBoss`()
BEGIN
@@ -87766,322 +73307,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `workerJourneyReplaceLauncher__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `workerJourneyReplaceLauncher__`()
-BEGIN
-
- DECLARE vDateStart DATE;
- DECLARE vDateEnd DATE;
-
- SET vDateStart = TIMESTAMPADD(MONTH,-1,CURDATE());
- SET vDateEnd = util.yesterday();
-
- CALL vn.workerJourneyReplace(vDateStart,vDateEnd,0);
-
-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 DROP PROCEDURE IF EXISTS `workerJourneyReplace__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `workerJourneyReplace__`(vFromDate DATE, vToDate DATE, vUserFk INT)
-BEGIN
-
- /* Actualiza la tabla workerJourney para que actue como caché permanente revisable de las jornadas laborales.
- * vUserFk es opcional. El valor 0 indica que se tenga en cuenta a todos los usuarios.
- *
- * PAK Julio '18
- */
-
- DELETE
- FROM workerJourney
- WHERE dated BETWEEN vFromDate AND vToDate
- AND isPaid = FALSE
- AND isUpdated = FALSE
- AND vUserFk IN (0,userFk);
-
-
- -- Se inicia la tabla con todas las fechas posibles para cada uno de los trabajadores que han fichado en el rango de fechas.
- INSERT IGNORE INTO workerJourney(userFk, dated, businessFk)
- SELECT w.userFk, tm.dated, b.business_id
- FROM vn.worker w
- JOIN postgresql.person pe ON pe.id_trabajador = w.id
- JOIN postgresql.profile p ON p.person_id = pe.person_id
- JOIN postgresql.business b ON b.client_id = p.profile_id
- JOIN postgresql.business_labour bl ON bl.business_id = b.business_id
- JOIN vn.time tm ON tm.dated BETWEEN b.date_start AND IFNULL(b.date_end,CURDATE())
- WHERE b.date_start <= vToDate
- AND IFNULL(b.date_end, CURDATE()) >= vFromDate
- -- AND bl.porhoras
- AND vUserFk IN (0,w.userFk);
-
-
-
-
-
- -- Se actualiza la cantidad total de horas prácticas, así como el tiempo de almuerzo remunerado, si corresponde
-
- /*UPDATE workerJourney wj
- JOIN workerTimeControl_Journey j ON wj.dated = j.dated AND wj.userFk = j.userFk
- SET wj.total = j.Journey,
- wj.lunch = IF(j.Journey < 5,0,0.33)
- WHERE wj.dated BETWEEN vFromDate AND vToDate
- AND wj.isPaid = FALSE
- AND wj.isUpdated = FALSE
- AND vUserFk IN (0,wj.userFk); */
-
-
- IF vUserFk = 0 THEN
- CALL vn.timeControl_calculateAll( vFromDate , CONCAT(REPLACE(vToDate, '00:00:00', ''), ' 23:59:59'));
- ELSE
- CALL vn.timeControl_calculateByUser( vUserFk, vFromDate , CONCAT(REPLACE(vToDate, '00:00:00', ''), ' 23:59:59'));
- END IF;
-
- UPDATE workerJourney wj
- JOIN tmp.timeControlCalculate t ON wj.dated = t.dated AND wj.userFk = t.userFk
- SET wj.total = CAST(IF(t.timeWorkDecimal >= 5.33,t.timeWorkDecimal-0.33,t.timeWorkDecimal) AS DECIMAL (10,2)),
- wj.lunch = IF(t.timeWorkDecimal >= 5.33,0.33,0)
- WHERE wj.dated BETWEEN vFromDate AND vToDate
- AND wj.isPaid = FALSE
- AND wj.isUpdated = FALSE
- AND vUserFk IN (0,wj.userFk);
-
- DROP TEMPORARY TABLE tmp.timeControlCalculate;
-
-
-
- /********** NOCTURNIDAD ************/
- DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControl;
-
- CREATE TEMPORARY TABLE tmp.workerTimeControl
- SELECT w.*, 0 as Non
- FROM vn.workerTimeControl w
- WHERE timed BETWEEN vFromDate AND vToDate
- AND vUserFk IN (0,userFk)
- ORDER BY userFk, timed;
-
- -- Regalamos un segundo para evitar que hayan fichadas en las horas claves de inicio y fin de la nocturnidad.
- UPDATE tmp.workerTimeControl
- SET timed = TIMESTAMPADD(SECOND,-1,timed)
- WHERE TIME(timed) IN ('06:00:00','22:00:00');
-
- -- Fichada virtual a las 6:00 h, hora en que empieza la jornada diurna
- INSERT INTO tmp.workerTimeControl(userFk, timed)
- SELECT userFk, TIMESTAMPADD(HOUR, 6, DATE(timed))
- FROM vn.workerTimeControl
- WHERE vUserFk IN (0,userFk)
- GROUP BY userFk, DATE(timed);
-
- -- Fichada virtual a las 22:00 h, momento en que empieza la jornada nocturna.
- INSERT INTO tmp.workerTimeControl(userFk, timed)
- SELECT userFk, TIMESTAMPADD(HOUR, 22, DATE(timed))
- FROM vn.workerTimeControl
- WHERE vUserFk IN (0,userFk)
- GROUP BY userFk, DATE(timed);
-
- -- Establece el orden en que se han de leer las fichadas
- CALL vn.workerTimeControlSetOrder;
-
- -- Marca los impares para facilitar la consulta siguiente
- UPDATE tmp.workerTimeControl
- SET Non = 1
- WHERE `order` mod 2;
-
- -- Actualizamos la nocturnidad
- UPDATE workerJourney wj
- JOIN
- ( SELECT userFk, Dia, sum(Nocturnidad) as Nocturnidad FROM
- (
- SELECT userFk,
- date(timed) as Dia,
- ((
- IF( TIME(timed) < '06:00:00' OR (TIME(timed) = '06:00:00' AND Non = FALSE ) , IF(Non,-1,1),0)
- +
- IF(TIME(timed) > '22:00:00' OR (TIME(timed) = '22:00:00' AND Non = TRUE), If(Non,-1,1),0)
- )
- * (HOUR(`timed`) + MINUTE(`timed`) / 60)
- ) as Nocturnidad
- FROM tmp.workerTimeControl
- ) sub
- GROUP BY Dia, userFk
- HAVING Nocturnidad
- ) night ON night.userFk = wj.userFk AND night.Dia = wj.dated
- SET wj.nocturn = night.Nocturnidad
- WHERE wj.isPaid = FALSE AND isUpdated = FALSE;
-
- -- Horas téoricas y precio de la hora ordinaria
- UPDATE vn.workerJourney wj
- JOIN postgresql.business_labour_payroll blp ON blp.business_id = wj.businessFk
- JOIN postgresql.business_labour bl ON bl.business_id = wj.businessFk
- JOIN postgresql.calendar_labour_type pclt ON pclt.calendar_labour_type_id = bl.calendar_labour_type_id
- SET wj.priceOrdinaryHour = (12 * blp.importepactado) / (52 * pclt.hours_week),
- wj.contractJourney = pclt.hours_week/5
- WHERE wj.dated BETWEEN vFromDate AND vToDate
- AND vUserFk IN (0,wj.userFk)
- AND wj.isPaid = FALSE
- AND isUpdated = FALSE;
-
- -- Precio Extras, Vacaciones y Nocturnas
- UPDATE vn.workerJourney wj
- JOIN
- (
- SELECT dated, hollidayInc, nightInc, extraInc
- FROM (
- SELECT tm.dated , hollidayInc, nightInc, extraInc
- FROM vn.time tm
- JOIN vn.workerHourPrice whp ON tm.dated >= whp.dated
- ORDER BY tm.dated, whp.dated DESC
- ) sub
- GROUP BY dated
- ) conv ON conv.dated = wj.dated
- SET wj.priceHollydayHour = wj.priceOrdinaryHour * conv.hollidayInc,
- wj.priceNocturnHour = wj.priceOrdinaryHour * conv.nightInc,
- wj.priceExtraHour = wj.priceOrdinaryHour * conv.extraInc
- WHERE wj.dated BETWEEN vFromDate AND vToDate
- AND vUserFk IN (0,wj.userFk)
- AND wj.isPaid = FALSE
- AND wj.isUpdated = FALSE;
-
- -- Elimina el precio de las horas extras para los contratos parciales.
- UPDATE vn.workerJourney wj
- JOIN postgresql.business_labour bl ON bl.business_id = wj.businessFk
- JOIN postgresql.calendar_labour_type clt ON clt.calendar_labour_type_id = bl.calendar_labour_type_id
- SET wj.priceExtraHour = 0
- WHERE clt.isPartial
- AND wj.dated BETWEEN vFromDate AND vToDate
- AND vUserFk IN (0,wj.userFk)
- AND wj.isPaid = FALSE
- AND wj.isUpdated = FALSE;
-
- -- Bajas, vacaciones y festivos personales
- /* UPDATE vn.workerJourney wj
- JOIN postgresql.calendar_employee pce ON pce.date = wj.dated AND pce.business_id = wj.businessFk
- JOIN postgresql.business_labour bl ON bl.business_id = wj.businessFk
- SET wj.permission = IF(pce.calendar_state_id = 6, 0.5, 1) * wj.contractJourney,
- wj.contractJourney = IF(pce.calendar_state_id = 6, 0.5, 0) * wj.contractJourney,-- Vacaciones medio dia
- wj.hollyday = wj.total - IF(pce.calendar_state_id = 6, 0.5, 0) * wj.contractJourney
- WHERE wj.dated BETWEEN vFromDate AND vToDate
- AND vUserFk IN (0,wj.userFk)
- AND wj.isPaid = FALSE
- AND wj.isUpdated = FALSE;*/
-
- UPDATE vn.workerJourney wj
- JOIN postgresql.calendar_employee pce ON pce.date = wj.dated AND pce.business_id = wj.businessFk
- JOIN postgresql.business_labour bl ON bl.business_id = wj.businessFk
- JOIN postgresql.calendar_state cs ON cs.calendar_state_id = pce.calendar_state_id
- SET wj.permission = cs.permissionRate * wj.contractJourney,
- wj.contractJourney = IF(cs.permissionRate = 1, 0, cs.permissionRate) * wj.contractJourney,
- wj.hollyday = wj.total - IF(cs.permissionRate = 1, 0, cs.permissionRate) * wj.contractJourney
- WHERE cs.permissionRate > 0
- AND wj.dated BETWEEN vFromDate AND vToDate
- AND vUserFk IN (0,wj.userFk)
- AND wj.isPaid = FALSE
- AND wj.isUpdated = FALSE;
-
-
-
-
- -- Festivos por centro de trabajo
-UPDATE vn.workerJourney wj
- JOIN vn.calendarHolidays ch ON ch.dated = wj.dated
- JOIN postgresql.business_labour pbl ON wj.businessFk = pbl.business_id AND pbl.workcenter_id = ch.workcenterFk
- SET wj.hollyday = wj.total,
- wj.permission = wj.contractJourney,
- wj.contractJourney = 0
- WHERE wj.dated BETWEEN vFromDate AND vToDate
- AND vUserFk IN (0,wj.userFk)
- AND wj.isPaid = FALSE
- AND wj.isUpdated = FALSE;
-
- -- Domingos
- UPDATE vn.workerJourney
- SET hollyday = total,
- contractJourney = 0
- WHERE weekday(dated) = 6
- AND dated BETWEEN vFromDate AND vToDate
- AND vUserFk IN (0,userFk)
- AND isPaid = FALSE
- AND isUpdated = FALSE;
-
- -- Sábados
- UPDATE vn.workerJourney
- SET contractJourney = 0
- WHERE weekday(dated) = 5
- AND dated BETWEEN vFromDate AND vToDate
- AND vUserFk IN (0,userFk)
- AND isPaid = FALSE
- AND isUpdated = FALSE;
-
-
- -- Horas extras
- UPDATE workerJourney
- SET extra = lunch + total - contractJourney
- WHERE dated BETWEEN vFromDate AND vToDate
- AND vUserFk IN (0,userFk)
- AND isPaid = FALSE
- AND isUpdated = FALSE;
-
- -- Contratos NO por horas
- INSERT IGNORE INTO workerJourney( userFk,
- dated,
- businessFk,
- priceOrdinaryHour,
- contractJourney,
- total)
- SELECT w.userFk,
- tm.dated,
- b.business_id,
- (12 * blp.importepactado) / (52 * pclt.hours_week) as priceOrdinaryHour,
- IF(weekday(tm.dated) IN (5,6),0, pclt.hours_week/5) as contractJourney,
- IF(weekday(tm.dated) IN (5,6),0, pclt.hours_week/5) as total
- FROM vn.worker w
- JOIN postgresql.person pe ON pe.id_trabajador = w.id
- JOIN postgresql.profile p ON p.person_id = pe.person_id
- JOIN postgresql.business b ON b.client_id = p.profile_id
- JOIN postgresql.business_labour bl ON bl.business_id = b.business_id
- JOIN postgresql.calendar_labour_type pclt ON pclt.calendar_labour_type_id = bl.calendar_labour_type_id
- JOIN postgresql.business_labour_payroll blp ON blp.business_id = b.business_id
- JOIN vn.time tm ON tm.dated BETWEEN b.date_start AND IFNULL(b.date_end,CURDATE())
- WHERE b.date_start <= vToDate
- AND IFNULL(b.date_end, CURDATE()) >= vFromDate
- AND bl.porhoras = FALSE
- AND vUserFk IN (0,w.userFk);
-
- -- Elimina dias sin fichadas ni contrato
- /* DELETE FROM workerJourney
- WHERE contractJourney = 0
- AND total = 0
- AND permission = 0
- AND dated BETWEEN vFromDate AND vToDate
- AND vUserFk IN (0,userFk)
- AND isPaid = FALSE
- AND isUpdated = FALSE;
-*/
-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 DROP PROCEDURE IF EXISTS `workerJourney_replace` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -88089,8 +73316,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerJourney_replace`(vDatedFrom DATE, vDatedTo DATE, vWorkerFk INT)
BEGIN
@@ -88131,7 +73356,7 @@ BEGIN
INSERT IGNORE INTO workerJourney(userFk, dated, businessFk)
SELECT w.workerFk, t.dated, w.businessFk
FROM workerLabour w
- JOIN time t ON t.dated BETWEEN w.started AND IFNULL(w.ended,CURDATE())
+ JOIN time t ON t.dated BETWEEN w.started AND IFNULL(w.ended,util.VN_CURDATE())
WHERE t.dated BETWEEN vDatedFrom AND vDatedTo
AND (vWorkerFk IS NULL OR w.workerFk = vWorkerFk)
ORDER BY w.workerFk, t.dated, w.businessFk;
@@ -88269,6 +73494,7 @@ BEGIN
WHERE wtc.timed BETWEEN vDatedFrom AND util.dayEnd(vDatedToTomorrow)
AND tce.id IS NULL
ORDER BY userFk, timed ASC
+ LIMIT 10000000000000000000
) wtc
)sub
WHERE sub.dated BETWEEN vDatedFrom AND vDatedTo
@@ -88373,194 +73599,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `workerJourney_replace__` */;
-/*!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_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `workerJourney_replace__`(vDatedFrom DATE, vDatedTo DATE, vWorkerFk INT)
-BEGIN
-/**
- * Actualiza la tabla workerJourney para que actue como caché permanente revisable de las jornadas laborales.
- * @param vDatedFrom workerTimeControl
- * @param vDatedTo workerTimeControl
- * @param vWorkerFk, en caso de pasar 0 ó NULL se aplica a todos
- */
-
- DECLARE vDatedTimeTo DATETIME;
- DECLARE vMaxTimePerDay INT;
- DECLARE vMinHoursToBreak DECIMAL(10,2);
- DECLARE vBreakHours DECIMAL(10,2);
- DECLARE vMonthByYear INT;
- DECLARE vWeeksByYear INT DEFAULT 52;
- DECLARE vMonthsByYear INT DEFAULT 12;
- DECLARE vDaysByWeek INT DEFAULT 5;
-
- SET vDatedTimeTo = util.dayEnd(vDatedTo);
-
- SELECT minHoursToBreak, breakHours, maxTimePerDay
- INTO vMinHoursToBreak, vBreakHours, vMaxTimePerDay
- FROM workerTimeControlConfig;
-
- DELETE FROM workerJourney
- WHERE dated BETWEEN vDatedFrom AND vDatedTo
- AND NOT isPaid
- AND NOT isUpdated
- AND (vWorkerFk IS NULL OR userFK = vWorkerFk);
-
- -- Se inserta todos los días del periodo por worker y business en el rango de fechas.
- INSERT IGNORE INTO workerJourney(userFk, dated, businessFk)
- SELECT w.workerFk, t.dated, w.businessFk
- FROM workerLabour w
- JOIN time t ON t.dated BETWEEN w.started AND IFNULL(w.ended,CURDATE())
- WHERE t.dated BETWEEN vDatedFrom AND vDatedTo
- AND (vWorkerFk IS NULL OR w.workerFk = vWorkerFk)
- ORDER BY w.workerFk, t.dated, w.businessFk;
-
- IF vWorkerFk THEN
- CALL timeControl_calculateByUser(vWorkerFk, vDatedFrom , vDatedTimeTo);
- ELSE
- CALL timeControl_calculateAll(vDatedFrom, vDatedTimeTo);
- END IF;
-
- UPDATE workerJourney wj
- JOIN tmp.timeControlCalculate t ON wj.dated = t.dated AND wj.userFk = t.userFk
- SET wj.total = CAST(IF(t.timeWorkDecimal >= vMinHoursToBreak, t.timeWorkDecimal - vBreakHours, t.timeWorkDecimal) AS DECIMAL (10,2)),
- wj.lunch = IF(t.timeWorkDecimal >= vMinHoursToBreak , vBreakHours , 0)
- WHERE wj.dated BETWEEN vDatedFrom AND vDatedTo
- AND NOT wj.isPaid
- AND NOT wj.isUpdated
- AND (vWorkerFk IS NULL OR wj.userFk = vWorkerFk);
-
- -- NOCTURNIDAD
-
- SET @vIsOdd := TRUE;
- SET @vDated := NULL;
- CALL vn.workerTimeControl_calculateOddDays();
-
- UPDATE workerJourney wj
- JOIN (SELECT sub.dated, userFk, SUM(NigthlyHours) NigthlyHours
- FROM(SELECT IF(@vIsOdd, @vIsOdd := FALSE, @vIsOdd := TRUE),
- IF(direction='in', @vIsOdd := TRUE, @vIsOdd := @vIsOdd),
- IF(@vIsOdd, @vLastTimed:=UNIX_TIMESTAMP(timed),@vLastTimed:=@vLastTimed),
- IF(direction='in', @vDated := DATE(wtc.timed), @vDated :=@vDated) dated,
- wtc.userFk,
- IF(UNIX_TIMESTAMP(timed)- @vLastTimed < vMaxTimePerDay,
- vn.workerNigthlyHours_calculate(FROM_UNIXTIME(@vLastTimed), wtc.timed),
- 0) NigthlyHours
- FROM (SELECT DISTINCT(wtc.id), wtc.userFk, wtc.timed, wtc.direction
- FROM workerTimeControl wtc
- WHERE wtc.timed BETWEEN vDatedFrom AND util.dayEnd(DATE_ADD(vDatedTo, INTERVAL 1 DAY))
- ORDER BY userFk, timed ASC
- ) wtc
- )sub
- LEFT JOIN tmp.workerTimeControlOddDays wo ON wo.workerFk = sub.userFk
- AND wo.dated = sub.dated
- WHERE sub.dated BETWEEN vDatedFrom AND vDatedTo
- AND wo.workerFk IS NULL
- GROUP BY userFk, sub.dated
- )night ON night.userFk = wj.userFk AND night.dated = wj.dated
- SET wj.nocturn = night.NigthlyHours
- WHERE NOT wj.isPaid
- AND NOT isUpdated
- AND night.NigthlyHours <> 0;
-
- -- Horas téoricas y precio de la hora ordinaria
- UPDATE workerJourney wj
- JOIN postgresql.business_labour_payroll blp ON blp.business_id = wj.businessFk
- JOIN postgresql.business_labour bl ON bl.business_id = wj.businessFk
- JOIN postgresql.calendar_labour_type cl ON cl.calendar_labour_type_id = bl.calendar_labour_type_id
- SET wj.priceOrdinaryHour = (vMonthsByYear * blp.importepactado) / (vWeeksByYear * cl.hours_week),
- wj.contractJourney = cl.hours_week / vDaysByWeek
- WHERE wj.dated BETWEEN vDatedFrom AND vDatedTo
- AND (vWorkerFk IS NULL OR wj.userFk = vWorkerFk)
- AND NOT wj.isPaid
- AND NOT isUpdated;
-
- -- Precio Extras, Vacaciones y Nocturnas
- UPDATE workerJourney wj
- JOIN(SELECT MAX(w.dated), t.dated, w.holidayInc, w.nightInc, w.extraInc
- FROM time t
- JOIN workerHourPrice w ON w.dated <= t.dated
- WHERE t.dated BETWEEN vDatedFrom AND vDatedTo
- GROUP BY t.dated
- ) sub ON sub.dated = wj.dated
- SET wj.priceHolidayHour = wj.priceOrdinaryHour * sub.holidayInc,
- wj.priceNocturnHour = wj.priceOrdinaryHour * sub.nightInc,
- wj.priceExtraHour = wj.priceOrdinaryHour * sub.extraInc
- WHERE wj.dated BETWEEN vDatedFrom AND vDatedTo
- AND (vWorkerFk IS NULL OR wj.userFk = vWorkerFk)
- AND NOT wj.isPaid
- AND NOT wj.isUpdated;
-
- -- Elimina el precio de las horas extras para los contratos parciales.
- UPDATE workerJourney wj
- JOIN postgresql.business_labour bl ON bl.business_id = wj.businessFk
- JOIN postgresql.calendar_labour_type cl ON cl.calendar_labour_type_id = bl.calendar_labour_type_id
- SET wj.priceExtraHour = 0
- WHERE cl.isPartial
- AND wj.dated BETWEEN vDatedFrom AND vDatedTo
- AND (vWorkerFk IS NULL OR wj.userFk = vWorkerFk)
- AND NOT wj.isPaid
- AND NOT wj.isUpdated;
-
- -- Ausencias
- UPDATE workerJourney wj
- JOIN businessCalendar bc ON bc.businessFk = wj.businessFk AND bc.dated = wj.dated
- JOIN absenceType ab ON ab.id = bc.absenceTypeFk
- JOIN postgresql.business_labour bl ON bl.business_id = wj.businessFk
- SET wj.permission = ab.permissionRate * wj.contractJourney,
- wj.contractJourney = IF(ab.permissionRate = 1, 0, ab.permissionRate) * wj.contractJourney
- WHERE ab.permissionRate > 0
- AND wj.dated BETWEEN vDatedFrom AND vDatedTo
- AND (vWorkerFk IS NULL OR wj.userFk = vWorkerFk)
- AND NOT wj.isPaid
- AND NOT wj.isUpdated;
-
- -- Sábados / Domingos
- UPDATE workerJourney
- SET holiday = IF(DAYNAME(dated)='sábado', 0, total),
- contractJourney = 0
- WHERE DAYNAME(dated) IN ('sábado', 'domingo')
- AND dated BETWEEN vDatedFrom AND vDatedTo
- AND (vWorkerFk IS NULL OR userFk = vWorkerFk)
- AND NOT isPaid
- AND NOT isUpdated;
-
- -- Festivos por centro de trabajo
- UPDATE workerJourney wj
- JOIN calendarHolidays ch ON ch.dated = wj.dated
- JOIN postgresql.business_labour bl ON bl.business_id = wj.businessFk
- AND bl.workcenter_id = ch.workcenterFk
- SET wj.holiday = wj.total,
- wj.permission = wj.contractJourney,
- wj.contractJourney = 0
- WHERE wj.dated BETWEEN vDatedFrom AND vDatedTo
- AND (vWorkerFk IS NULL OR wj.userFk = vWorkerFk)
- AND NOT wj.isPaid
- AND NOT wj.isUpdated;
-
- -- Horas extras
- UPDATE workerJourney
- SET extra = lunch + total - contractJourney
- WHERE dated BETWEEN vDatedFrom AND vDatedTo
- AND (vWorkerFk IS NULL OR userFk = vWorkerFk)
- AND NOT isPaid
- AND NOT isUpdated;
-
- DROP TEMPORARY TABLE tmp.timeControlCalculate;
- DROP TEMPORARY TABLE tmp.workerTimeControlOddDays;
-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 sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerMistakeType_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -88568,8 +73608,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerMistakeType_get`()
BEGIN
@@ -88588,6 +73626,8 @@ DELIMITER ;
/*!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 `workerMistake_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -88595,8 +73635,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerMistake_add`(vWorkerFk INT, vWorkerMistakeTypeFk VARCHAR(10), vUserFk INT )
BEGIN
@@ -88626,6 +73664,8 @@ DELIMITER ;
/*!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 `workerShelving_Add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -88633,8 +73673,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerShelving_Add`(vWorkerFk INT, vBarcode VARCHAR(12))
BEGIN
@@ -88665,6 +73703,8 @@ DELIMITER ;
/*!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 `workerShelving_delete` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -88672,8 +73712,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerShelving_delete`(vWorkerFk INT, vBarcode VARCHAR(12))
BEGIN
@@ -88708,6 +73746,8 @@ DELIMITER ;
/*!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 `workerTimeControlAdd` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -88715,8 +73755,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControlAdd`(IN vUserFk INT, IN vWarehouseFk INT, IN vDated DATETIME)
BEGIN
@@ -88726,7 +73764,7 @@ BEGIN
CALL vn.workerTimeControlSOWP(vUserFk , vDated);*/
- CALL vn.workerTimeControl_add(vUserFk,vWarehouseFk,NOW(),FALSE);
+ CALL vn.workerTimeControl_add(vUserFk,vWarehouseFk,util.VN_NOW(),FALSE);
END ;;
@@ -88735,45 +73773,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControlNonDays__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControlNonDays__`()
-BEGIN
- SET @cont := 0;
- SELECT sub2.userFk, sub2.dated Fecha, CONCAT (w.firstName," ", w.lastName) worker, au.name Boss, d.name
- FROM (SELECT userFk,
- dated,
- COUNT(*) cont2
- FROM (SELECT DATE(wtc.timed) dated,
- userFk,
- IFNULL(@cont, @cont := 0 ),
- IF(direction = 'in', @cont:=@cont+1, TRUE),
- @cont cont
- FROM vn.workerTimeControl wtc
- WHERE wtc.timed BETWEEN TIMESTAMPADD(YEAR,-1,CURDATE()) AND CURDATE()
- ORDER BY userFk, timed)sub
- GROUP BY cont
- HAVING cont2 MOD 2 = 1)sub2
- JOIN worker w ON w.userFk = sub2.userFk
- LEFT JOIN worker wb ON wb.id = w.bossFk
- LEFT JOIN account.user au ON au.id = wb.userFK
- LEFT JOIN workerDepartment wd ON wd.workerFk = w.id
- LEFT JOIN department d ON d.id = wd.departmentFk
- ORDER BY Boss ASC;
-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 DROP PROCEDURE IF EXISTS `workerTimeControlPinGenerate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -88781,8 +73782,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControlPinGenerate`(
vWorkerFk INT)
@@ -88800,6 +73799,8 @@ DELIMITER ;
/*!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 `workerTimeControlSetOrder` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -88807,8 +73808,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControlSetOrder`()
BEGIN
@@ -88829,6 +73828,8 @@ DELIMITER ;
/*!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 `workerTimeControlSetOrder_by_User_and_dateRange` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -88836,8 +73837,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControlSetOrder_by_User_and_dateRange`(vUserFk INT, vStarted DATE, vFinished DATE)
BEGIN
@@ -88857,6 +73856,8 @@ DELIMITER ;
/*!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 `workerTimeControlSOWP` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -88864,8 +73865,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControlSOWP`(IN vUserFk INT, IN vDated DATE)
BEGIN
@@ -88883,6 +73882,8 @@ DELIMITER ;
/*!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 `workerTimeControl_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -88890,8 +73891,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_add`(IN vUserFk INT, IN vWarehouseFk INT, IN vTimed DATETIME, IN vIsManual BOOL)
BEGIN
@@ -88904,70 +73903,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_add__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_add__`(IN vUserFk INT, IN vWarehouseFk INT, IN vTimed DATETIME, IN vIsManual BOOL)
-BEGIN
-
- DECLARE vDirection VARCHAR(6);
- DECLARE vLastIn DATETIME;
- DECLARE vDayStayMax INT;
- DECLARE vHasDirectionOut INT;
-
- SELECT dayStayMax INTO vDayStayMax
- FROM vn.workerTimeControlParams;
-
- SELECT vn.timeWorkerControl_getDirection(vUserFk,vTimed) INTO vDirection;
-
- IF vDirection = 'out' THEN
-
- SELECT MAX(timed) INTO vLastIn
- FROM vn.workerTimeControl
- WHERE userFk = vUserFk
- AND direction = 'in'
- AND timed < vTimed;
-
- UPDATE vn.workerTimeControl wtc
- SET wtc.direction = 'middle'
- WHERE userFk = vUserFk
- AND direction = 'out'
- AND timed BETWEEN vLastIn AND vTimed;
-
- ELSE IF vDirection = 'in' THEN
-
- SELECT COUNT(*) INTO vHasDirectionOut
- FROM vn.workerTimeControl wtc
- WHERE userFk = vUserFk
- AND direction = 'out'
- AND timed BETWEEN vTimed AND TIMESTAMPADD(SECOND, 50400, vTimed);
-
- UPDATE vn.workerTimeControl wtc
- SET wtc.direction = IF (vHasDirectionOut,'middle','out')
- WHERE userFk = vUserFk
- AND direction = 'in'
- AND timed BETWEEN vTimed AND TIMESTAMPADD(SECOND, 50400, vTimed);
-
- END IF;
- END IF;
-
- INSERT INTO workerTimeControl(userFk, timed, warehouseFk, direction, manual)
- VALUES(vUserFk, vTimed, vWarehouseFk, vDirection, vIsManual);
-
- CALL vn.workerTimeControlSOWP(vUserFk, vTimed);
-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 DROP PROCEDURE IF EXISTS `workerTimeControl_calculateOddDays` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -88975,42 +73912,47 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_calculateOddDays`()
BEGIN
-/*
- * Calculo de las fichadas impares por empleado y dia
+/**
+ * Calculo de las fichadas impares por empleado y dia.
+ *
* @return tmp.workerTimeControlOddDays (userFk, dated)
*/
SET @cont := FALSE;
SET @lastUserFk:= NULL;
- DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControlOddDays;
- CREATE TEMPORARY TABLE tmp.workerTimeControlOddDays
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControlOddDays;
+ CREATE TEMPORARY TABLE tmp.workerTimeControlOddDays
SELECT sub2.userFk workerFk, sub2.dated
- FROM (SELECT userFk,
- dated,
- COUNT(*) cont2
- FROM (SELECT DATE(wtc.timed) dated,
- userFk,
- IFNULL(@cont, @cont := TRUE ),
- IF(direction = 'in' OR userFk <> @lastUserFk, @cont := @cont+1, TRUE),
- @cont cont,
- @lastUserFk := userFk
+ FROM (
+ SELECT userFk,
+ dated,
+ COUNT(*) cont2
+ FROM (
+ SELECT DATE(wtc.timed) dated,
+ userFk,
+ IFNULL(@cont, @cont := TRUE ),
+ IF(direction = 'in' OR userFk <> @lastUserFk, @cont := @cont+1, TRUE),
+ @cont cont,
+ @lastUserFk := userFk
FROM workerTimeControl wtc
- WHERE wtc.timed BETWEEN TIMESTAMPADD(YEAR,-1,CURDATE()) AND util.dayEnd(CURDATE())
- ORDER BY userFk, timed)sub
- GROUP BY cont
- HAVING cont2 MOD 2 = 1)sub2
- JOIN worker w ON w.userFk = sub2.userFk;
-
+ WHERE wtc.timed BETWEEN TIMESTAMPADD(YEAR,-1,util.VN_CURDATE()) AND util.dayEnd(util.VN_CURDATE())
+ ORDER BY userFk, timed
+ LIMIT 10000000000000000000)sub
+ GROUP BY cont
+ HAVING cont2 MOD 2 = 1
+ )sub2
+ JOIN worker w ON w.userFk = sub2.userFk;
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 `workerTimeControl_check` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -89018,8 +73960,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_check`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100))
proc: BEGIN
@@ -89030,93 +73970,93 @@ proc: BEGIN
* @return Retorna si encuentra un problema 'odd','maxTimeWork','breakDay','breakWeek' ;
* En caso de tener algun problema retorna el primero que encuentra
*/
- DECLARE vLastIn DATETIME ;
- DECLARE vLastOut DATETIME ;
- DECLARE vDayWorkMax INT;
- DECLARE vDayBreak INT;
- DECLARE vWeekBreak INT ;
+ DECLARE vLastIn DATETIME ;
+ DECLARE vLastOut DATETIME ;
+ DECLARE vDayWorkMax INT;
+ DECLARE vDayBreak INT;
+ DECLARE vWeekBreak INT ;
DECLARE vWeekScope INT;
- DECLARE vDayStayMax INT;
- DECLARE vProblem VARCHAR(20) DEFAULT NULL;
- DECLARE vTimedWorked INT;
- DECLARE vCalendarStateType VARCHAR(20) DEFAULT NULL;
- DECLARE vDepartmentFk INT;
- DECLARE vTo VARCHAR(50) DEFAULT NULL;
- DECLARE vUserName VARCHAR(50) DEFAULT NULL;
- DECLARE vBody VARCHAR(255) DEFAULT NULL;
-
+ DECLARE vDayStayMax INT;
+ DECLARE vProblem VARCHAR(20) DEFAULT NULL;
+ DECLARE vTimedWorked INT;
+ DECLARE vCalendarStateType VARCHAR(20) DEFAULT NULL;
+ DECLARE vDepartmentFk INT;
+ DECLARE vTo VARCHAR(50) DEFAULT NULL;
+ DECLARE vUserName VARCHAR(50) DEFAULT NULL;
+ DECLARE vBody VARCHAR(255) DEFAULT NULL;
+
SELECT dayBreak, weekBreak, weekScope, dayWorkMax, dayStayMax
INTO vDayBreak, vWeekBreak, vWeekScope, vDayWorkMax, vDayStayMax
FROM workerTimeControlParams;
- SELECT MAX(timed) INTO vLastIn
+ SELECT MAX(timed) INTO vLastIn
FROM workerTimeControl
- WHERE userFk = vUserFk
+ WHERE userFk = vUserFk
AND direction = 'in';
-
- SELECT MAX(timed) INTO vLastOut
+
+ SELECT MAX(timed) INTO vLastOut
FROM workerTimeControl
- WHERE userFk = vUserFk
+ WHERE userFk = vUserFk
AND direction = 'out';
-
- SELECT CONCAT(u.name,'@verdnatura.es') INTO vTo
+
+ SELECT CONCAT(u.name,'@verdnatura.es') INTO vTo
FROM account.user u
- WHERE u.id = (SELECT bossFk FROM worker WHERE id = vUserFk);
-
+ WHERE u.id = (SELECT bossFk FROM worker WHERE id = vUserFk);
+
SELECT CONCAT(firstName,' ',lastName) INTO vUserName
FROM worker w
- WHERE w.id = vUserFk;
-
-
- IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastIn) > vDayStayMax THEN -- NUEVA JORNADA
-
- -- VERIFICAR DESCANSO DIARIO
- IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastOut) < vDayBreak THEN
- SELECT "Descansos 12 h" AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
+ WHERE w.id = vUserFk;
+
+
+ IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastIn) > vDayStayMax THEN -- NUEVA JORNADA
+
+ -- VERIFICAR DESCANSO DIARIO
+ IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastOut) < vDayBreak THEN
+ SELECT "Descansos 12 h" AS problem;
+ -- ENVIAMOS CORREO AL BOSSFK
SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos 12 h") INTO vBody;
CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
- END IF;
-
- -- VERIFICAR FICHADAS IMPARES DEL ÚLTIMO DÍA QUE SE FICHÓ
+ LEAVE proc;
+ END IF;
+
+ -- VERIFICAR FICHADAS IMPARES DEL ÚLTIMO DÍA QUE SE FICHÓ
IF (SELECT MOD(COUNT(*),2) -- <>0
FROM workerTimeControl
WHERE userFk = vUserFk
AND timed >= vLastIn
) THEN
SELECT "Dias con fichadas impares" AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
+ -- ENVIAMOS CORREO AL BOSSFK
SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Dias con fichadas impares") INTO vBody;
CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
+ LEAVE proc;
END IF;
-
- -- VERIFICAR VACACIONES
- SELECT cs.type INTO vCalendarStateType
+
+ -- VERIFICAR VACACIONES
+ SELECT at2.name INTO vCalendarStateType
FROM postgresql.calendar_employee ce
JOIN postgresql.business b USING(business_id)
JOIN postgresql.profile pr ON pr.profile_id = b.client_id
JOIN postgresql.person p ON p.person_id = pr.person_id
- JOIN postgresql.calendar_state cs USING(calendar_state_id)
+ JOIN vn.absenceType at2 ON at2.id = ce.calendar_state_id
JOIN worker w ON w.id = p.id_trabajador
- WHERE ce.date = CURDATE()
- AND cs.isAllowedToWork = FALSE
+ WHERE ce.date = util.VN_CURDATE()
+ AND at2.isAllowedToWork = FALSE
AND w.userFk = vUserFk
LIMIT 1;
-
- IF(LENGTH(vCalendarStateType)) THEN
+
+ IF(LENGTH(vCalendarStateType)) THEN
SELECT vCalendarStateType AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
+ -- ENVIAMOS CORREO AL BOSSFK
SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Vacaciones") INTO vBody;
CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
-
- END IF;
-
-
- -- VERIFICAR CONTRATO EN VIGOR
- IF (SELECT COUNT(*)
+ LEAVE proc;
+
+ END IF;
+
+
+ -- VERIFICAR CONTRATO EN VIGOR
+ IF (SELECT COUNT(*)
FROM postgresql.business b
JOIN postgresql.profile pr ON pr.profile_id = b.client_id
JOIN postgresql.person p ON p.person_id = pr.person_id
@@ -89125,58 +74065,58 @@ proc: BEGIN
AND b.date_start <= vDated
AND IFNULL(b.date_end,vDated) >= vDated
) = 0 THEN
- SELECT "No hay un contrato en vigor" AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
+ SELECT "No hay un contrato en vigor" AS problem;
+ -- ENVIAMOS CORREO AL BOSSFK
SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"No hay un contrato en vigor") INTO vBody;
CALL mail_insert(vTo,vTo,'error al fichar',vBody);
LEAVE proc;
-
+
END IF;
- -- VERIFICAR DESCANSO SEMANAL
+ -- VERIFICAR DESCANSO SEMANAL
SET @vHasBreakWeek:= FALSE;
- SET @vLastTimed:= UNIX_TIMESTAMP((NOW() - INTERVAL vWeekScope SECOND));
-
+ SET @vLastTimed:= UNIX_TIMESTAMP((util.VN_NOW() - INTERVAL vWeekScope SECOND));
+
DROP TEMPORARY TABLE IF EXISTS tmp.trash;
CREATE TEMPORARY TABLE tmp.trash
- SELECT IF(vWeekBreak-(UNIX_TIMESTAMP(timed)-@vLastTimed) <= 0, @vHasBreakWeek:=TRUE, TRUE) alias,
+ SELECT IF(vWeekBreak-(UNIX_TIMESTAMP(timed)-@vLastTimed) <= 0, @vHasBreakWeek:=TRUE, TRUE) alias,
@vLastTimed:= UNIX_TIMESTAMP(timed)
FROM workerTimeControl
- WHERE timed>= (NOW() - INTERVAL vWeekScope SECOND)
+ WHERE timed>= (util.VN_NOW() - INTERVAL vWeekScope SECOND)
AND userFk= vUserFk
AND direction IN ('in','out')
ORDER BY timed ASC;
-
- IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastOut) < vWeekBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA
+
+ IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastOut) < vWeekBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA
SELECT "Descansos 36 h" AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
+ -- ENVIAMOS CORREO AL BOSSFK
SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos 36 h") INTO vBody;
CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
+ LEAVE proc;
END IF;
- DROP TEMPORARY TABLE tmp.trash;
-
- ELSE -- DIA ACTUAL
+ DROP TEMPORARY TABLE tmp.trash;
+
+ ELSE -- DIA ACTUAL
-- VERIFICA QUE EL TIEMPO EFECTIVO NO SUPERE EL MÁXIMO
- SELECT IFNULL(SUM(if( mod(wtc.order,2)=1, -UNIX_TIMESTAMP(timed), UNIX_TIMESTAMP(timed))),0) - IF( MOD(COUNT(*),2), UNIX_TIMESTAMP(NOW()), 0) INTO vTimedWorked
+ SELECT IFNULL(SUM(if( mod(wtc.order,2)=1, -UNIX_TIMESTAMP(timed), UNIX_TIMESTAMP(timed))),0) - IF( MOD(COUNT(*),2), UNIX_TIMESTAMP(util.VN_NOW()), 0) INTO vTimedWorked
FROM workerTimeControl wtc
WHERE userFk = vUserFk
AND timed >= vLastIn
ORDER BY timed;
- IF vTimedWorked > vDayWorkMax THEN
- SELECT "Jornadas" AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
+ IF vTimedWorked > vDayWorkMax THEN
+ SELECT "Jornadas" AS problem;
+ -- ENVIAMOS CORREO AL BOSSFK
SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Jornadas") INTO vBody;
CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
+ LEAVE proc;
END IF;
END IF;
-
- -- VERIFICAR DEPARTAMENTO
+
+ -- VERIFICAR DEPARTAMENTO
/* IF vTabletFk IS NOT NULL THEN
SELECT wtcu.departmentFk INTO vDepartmentFk
FROM workerTimeControlUserInfo wtcu
@@ -89186,7 +74126,7 @@ proc: BEGIN
WHERE td.tabletFk = vTabletFk AND td.departmentFk = vDepartmentFk
) = 0 THEN
SELECT "No perteneces a este departamento." AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
+ -- ENVIAMOS CORREO AL BOSSFK
SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"No perteneces a este departamento.") INTO vBody;
CALL mail_insert(vTo,vTo,'error al fichar',vBody);
LEAVE proc;
@@ -89199,386 +74139,175 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_checkTest` */;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_checkBreak` */;
/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_checkTest`(vUserFk INT, vTimed DATETIME, vTabletFk VARCHAR(100))
+CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_checkBreak`(vStarted DATE)
BEGIN
-
/**
- * Verifica si el empleado puede fichar en el momento actual, si puede fichar llama a vn.workerTimeControlAdd
- * @param vUserFk Identificador del trabajador
- * @return Retorna si encuentra un problema 'odd','maxTimeWork','breakDay','breakWeek' ;
- * En caso de tener algun problema retorna el primero que encuentra
+ * Retorna los trabajadores que no han respetado el descanso semanal de 36/72 horas
+ * El sistema verificará el descanso corto en la siguiente semana
+ * o el largo en las 2 siguientes semanas a partir de la fecha dada
+ * @param vStarted día inicio de la semana en el que se quiere verificar
+ * @return tmp.workerWithoutWeekBreak (workerFk)
*/
- DECLARE vLastIn DATETIME ;
- DECLARE vLastOut DATETIME ;
- DECLARE vDayWorkMax INT;
- DECLARE vDayBreak INT;
- DECLARE vWeekBreak INT ;
- DECLARE vWeekMaxBreak INT;
- DECLARE vWeekScope INT;
- DECLARE vWeekMaxScope INT;
- DECLARE vDayStayMax INT;
- DECLARE vAskInOut INT;
- DECLARE vTimedWorked INT;
- DECLARE vCalendarStateType VARCHAR(20) DEFAULT NULL;
- DECLARE vDepartmentFk INT;
- DECLARE vTo VARCHAR(50) DEFAULT NULL;
- DECLARE vUserName VARCHAR(50) DEFAULT NULL;
- DECLARE vBody VARCHAR(255) DEFAULT NULL;
+ DECLARE vShortEnded DATETIME;
+ DECLARE vLongEnded DATETIME;
+ DECLARE vShortWeekBreak INT;
+ DECLARE vLongWeekBreak INT;
- IF (vTimed IS NULL) THEN
- SET vTimed = NOW();
- END IF;
+ SELECT util.dayEnd(DATE_ADD(vStarted, INTERVAL shortWeekDays DAY)),
+ util.dayEnd(DATE_ADD(vStarted, INTERVAL longWeekDays DAY)),
+ shortWeekBreak,
+ longWeekBreak
+ INTO vShortEnded, vLongEnded, vShortWeekBreak, vLongWeekBreak
+ FROM workerTimeControlConfig;
- SELECT dayBreak, weekBreak, weekScope, dayWorkMax, dayStayMax, weekMaxBreak, weekMaxScope, askInOut
- INTO vDayBreak, vWeekBreak, vWeekScope, vDayWorkMax, vDayStayMax, vWeekMaxBreak, vWeekMaxScope, vAskInOut
- FROM vn.workerTimeControlParams;
-
- SELECT MAX(timed) INTO vLastIn
- FROM vn.workerTimeControl
- WHERE userFk = vUserFk AND
- direction = 'in';
-
- SELECT MAX(timed) INTO vLastOut
- FROM vn.workerTimeControl
- WHERE userFk = vUserFk AND
- direction = 'out';
-
+ SET @previousTimed:= UNIX_TIMESTAMP(vStarted);
+ SET @lastUserFk := NULL;
- SELECT email INTO vTo
- FROM account.user w
- WHERE w.id = (SELECT bossFk FROM vn.worker WHERE id = vUserFk);
-
- SELECT CONCAT(firstName,' ',lastName) INTO vUserName
- FROM vn.worker w
- WHERE w.id = vUserFk;
+ -- Descanso corto en la semana
- -- VERIFICAR CONTRATO EN VIGOR
- IF (SELECT COUNT(*)
- FROM postgresql.business b
- JOIN postgresql.profile pr ON pr.profile_id = b.client_id
- JOIN postgresql.person p ON p.person_id = pr.person_id
- JOIN vn.worker w ON w.id = p.id_trabajador
- WHERE w.userFk = vUserFk AND
- b.date_start <= CURDATE() AND
- IFNULL(b.date_end,CURDATE()) >= CURDATE()
- ) = 0 THEN
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"No hay un contrato en vigor") INTO vBody;
- CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody);
- CALL util.throw("No hay un contrato en vigor");
- END IF;
-
- -- VERIFICAR DEPARTAMENTO
- /*IF vTabletFk IS NOT NULL THEN
- IF ( SELECT COUNT(*)
- FROM vn.tabletDepartment td
- JOIN vn.workerTimeControlUserInfo wtcu ON wtcu.departmentFk = td.departmentFk
- WHERE td.tabletFk = vTabletFk AND wtcu.userFk = vUserFk
- ) = 0 THEN
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"No perteneces a este departamento.") INTO vBody;
- CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody);
- CALL util.throw("No perteneces a este departamento.");
- END IF;
- END IF;*/
-
- SELECT IFNULL(dayBreak, vDayBreak) INTO vDayBreak
- FROM postgresql.business b
- JOIN postgresql.profile pr ON pr.profile_id = b.client_id
- JOIN postgresql.person p ON p.person_id = pr.person_id
- JOIN postgresql. business_labour bl ON b.business_id = bl.business_id
- JOIN postgresql.professional_category pc ON bl.professional_category_id = pc.professional_category_id
- WHERE p.id_trabajador = vUserFk AND
- b.date_start <= DATE(vTimed) AND
- IFNULL(b.date_end, DATE(vTimed)) >= DATE(vTimed);
- -- VERIFICAR DESCANSO DIARIO
- -- 12 / 9 horas dependiendo del valor de vDayBreak
- IF UNIX_TIMESTAMP(vTimed) - UNIX_TIMESTAMP(vLastOut) < vDayBreak THEN
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos ", FORMAT(vDayBreak/3600,0) ," h") INTO vBody;
- CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody);
- CALL util.throw(CONCAT("Descansos ", FORMAT(vDayBreak/3600,0) ," h"));
- END IF;
-
- -- VERIFICAR FICHADAS IMPARES DEL ÚLTIMO DÍA QUE SE FICHÓ
- IF (SELECT MOD(COUNT(*),2) -- <>0
- FROM vn.workerTimeControl
- WHERE userFk = vUserFk AND
- timed >= vLastIn
- ) THEN
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Dias con fichadas impares") INTO vBody;
- CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody);
- CALL util.throw("Dias con fichadas impares");
- END IF;
- -- VERIFICAR VACACIONES
- SELECT cs.type INTO vCalendarStateType
- FROM postgresql.calendar_employee ce
- JOIN postgresql.business b USING(business_id)
- JOIN postgresql.profile pr ON pr.profile_id = b.client_id
- JOIN postgresql.person p ON p.person_id = pr.person_id
- JOIN postgresql.calendar_state cs USING(calendar_state_id)
- JOIN vn.worker w ON w.id = p.id_trabajador
- WHERE ce.date = CURDATE() AND
- cs.isAllowedToWork = FALSE AND
- w.userFk = vUserFk
- LIMIT 1;
-
- IF(LENGTH(vCalendarStateType)) THEN
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Vacaciones") INTO vBody;
- CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody);
- CALL util.throw(vCalendarStateType);
- END IF;
-
- -- VERIFICAR DESCANSO SEMANAL
- SET @vHasBreakWeek:= FALSE;
- SET @vLastTimed:= UNIX_TIMESTAMP((vTimed - INTERVAL vWeekScope SECOND));
-
- DROP TEMPORARY TABLE IF EXISTS tmp.trash;
- CREATE TEMPORARY TABLE tmp.trash
- SELECT IF(vWeekBreak-(UNIX_TIMESTAMP(timed)-@vLastTimed) <= 0, @vHasBreakWeek:=TRUE, TRUE) alias,
- @vLastTimed:= UNIX_TIMESTAMP(timed)
+ DROP TEMPORARY TABLE IF EXISTS tmp.worker;
+ CREATE TEMPORARY TABLE tmp.worker
+ (PRIMARY KEY(workerFk))
+ ENGINE = MEMORY
+ SELECT DISTINCT userFk workerFk
FROM workerTimeControl
- WHERE timed>= (vTimed - INTERVAL vWeekScope SECOND) AND
- userFk= vUserFk AND
- direction IN ('in','out')
- ORDER BY timed ASC;
-
- IF UNIX_TIMESTAMP(vTimed) - UNIX_TIMESTAMP(vLastOut) < vWeekBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA
- SET @vHasBreakWeek:= FALSE;
- SET @vLastTimed:= UNIX_TIMESTAMP((vTimed - INTERVAL vWeekMaxScope SECOND));
- DROP TEMPORARY TABLE tmp.trash;
- CREATE TEMPORARY TABLE tmp.trash
- SELECT IF(vWeekMaxBreak-(UNIX_TIMESTAMP(timed)-@vLastTimed) <= 0, @vHasBreakWeek:=TRUE, TRUE) alias,
- @vLastTimed:= UNIX_TIMESTAMP(timed)
- FROM workerTimeControl
- WHERE timed>= (vTimed - INTERVAL vWeekMaxScope SECOND) AND
- userFk= vUserFk AND
- direction IN ('in','out')
- ORDER BY timed ASC;
- IF UNIX_TIMESTAMP(vTimed) - UNIX_TIMESTAMP(vLastOut) < vWeekMaxBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos ", FORMAT(vWeekMaxBreak/3600,0) ," h") INTO vBody;
- CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody);
- CALL util.throw(CONCAT( "Descansos ", FORMAT(vWeekMaxBreak/3600,0) ," h"));
- END IF;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos ", FORMAT(vWeekBreak/3600,0) ," h") INTO vBody;
- CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody);
- CALL util.warn(CONCAT( "Descansos ", FORMAT(vWeekBreak/3600,0) ," h"));
- END IF;
- DROP TEMPORARY TABLE tmp.trash;
+ WHERE timed BETWEEN vStarted AND vShortEnded
+ AND direction IN ('in', 'out');
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.worker2;
+ CREATE TEMPORARY TABLE tmp.worker2
+ (PRIMARY KEY(workerFk))
+ ENGINE = MEMORY
+ SELECT workerFk
+ FROM tmp.worker;
- -- Preguntar dirección de la fichada
- IF UNIX_TIMESTAMP(vTimed) - UNIX_TIMESTAMP(vLastIn) >= vAskInOut AND (SELECT MOD(COUNT(*),2)
- FROM vn.workerTimeControl WHERE userFk = vUserFk AND timed >= vLastIn) THEN
- CALL util.warn("AskInOut");
- END IF ;
+ DROP TEMPORARY TABLE IF EXISTS tmp.workerWithoutShortWeekBreak;
+ CREATE TEMPORARY TABLE tmp.workerWithoutShortWeekBreak
+ SELECT sub2.userFk workerFk
+ FROM(SELECT sub.userFk,
+ IF(sub.userFk <> @lastUserFk,
+ @previousTimed:= sub.timed,
+ FALSE),
+ IF(sub.timed - @previousTimed >= vShortWeekBreak,
+ TRUE,
+ FALSE) hasShortWeekBreak,
+ @previousTimed:= sub.timed,
+ @lastUserFk:= sub.userFk
+ FROM (
+ SELECT userFk, UNIX_TIMESTAMP(timed) timed
+ FROM workerTimeControl
+ WHERE timed BETWEEN vStarted AND vShortEnded
+ AND direction IN ('in', 'out')
+ UNION
+ SELECT w.workerFk,
+ UNIX_TIMESTAMP(IFNULL(
+ MIN(wtc.timed),
+ DATE_ADD(vShortEnded, INTERVAL vShortWeekBreak SECOND)))
+ FROM tmp.worker w
+ LEFT JOIN workerTimeControl wtc
+ ON wtc.userFk = w.workerFk
+ AND wtc.timed BETWEEN vShortEnded
+ AND DATE_ADD(vShortEnded, INTERVAL vShortWeekBreak SECOND)
+ GROUP BY w.workerFk
+ UNION
+ SELECT w.workerFk,
+ UNIX_TIMESTAMP(IFNULL(
+ MAX(wtc.timed),
+ DATE_SUB(vStarted, INTERVAL vShortWeekBreak SECOND)))
+ FROM tmp.worker2 w
+ LEFT JOIN workerTimeControl wtc
+ ON wtc.userFk = w.workerFk
+ AND wtc.timed BETWEEN
+ DATE_SUB(vStarted, INTERVAL vShortWeekBreak SECOND)
+ AND vStarted
+ GROUP BY w.workerFk
+ ORDER BY userFk, timed
+ LIMIT 10000000000000000000
+ )sub
+ )sub2
+ GROUP BY sub2.userFk
+ HAVING NOT SUM(hasShortWeekBreak);
+
+ -- Descanso largo en las 2 siguientes semanas
+ DROP TEMPORARY TABLE tmp.worker;
+ CREATE TEMPORARY TABLE tmp.worker
+ (PRIMARY KEY(workerFk))
+ ENGINE = MEMORY
+ SELECT workerFk
+ FROM tmp.workerWithoutShortWeekBreak;
+
+ DROP TEMPORARY TABLE tmp.worker2;
+ CREATE TEMPORARY TABLE tmp.worker2
+ (PRIMARY KEY(workerFk))
+ ENGINE = MEMORY
+ SELECT workerFk
+ FROM tmp.workerWithoutShortWeekBreak;
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.workerWithoutWeekBreak;
+ CREATE TEMPORARY TABLE tmp.workerWithoutWeekBreak
+ (PRIMARY KEY(workerFk))
+ ENGINE = MEMORY
+ SELECT sub2.userFk workerFk
+ FROM(SELECT userFk,
+ IF(userFk <> @lastUserFk,
+ @previousTimed:= timed,
+ TRUE),
+ IF(timed - @previousTimed >= vLongWeekBreak,
+ TRUE,
+ FALSE) hasLongWeekBreak,
+ @previousTimed:= timed,
+ @lastUserFk:= userFk
+ FROM (SELECT userFk, UNIX_TIMESTAMP(timed) timed
+ FROM workerTimeControl wtc
+ JOIN tmp.workerWithoutShortWeekBreak wws ON wws.workerFk = wtc.userFk
+ WHERE timed BETWEEN vStarted AND vLongEnded
+ AND direction IN ('in', 'out')
+ UNION
+ SELECT w.workerFk,
+ UNIX_TIMESTAMP(IFNULL(MIN(wtc.timed),
+ DATE_ADD(vLongEnded, INTERVAL vLongWeekBreak SECOND)))
+ FROM tmp.worker w
+ LEFT JOIN workerTimeControl wtc
+ ON wtc.userFk = w.workerFk
+ AND timed BETWEEN vLongEnded
+ AND DATE_ADD(vLongEnded, INTERVAL vLongWeekBreak SECOND)
+ GROUP BY w.workerFk
+ UNION
+ SELECT w.workerFk,
+ UNIX_TIMESTAMP(IFNULL(MAX(wtc.timed),
+ DATE_SUB(vStarted, INTERVAL vLongWeekBreak SECOND)))
+ FROM tmp.worker2 w
+ LEFT JOIN workerTimeControl wtc
+ ON wtc.userFk = w.workerFk
+ AND timed BETWEEN DATE_SUB(vStarted, INTERVAL vLongWeekBreak SECOND)
+ AND vStarted
+ GROUP BY w.workerFk
+ ORDER BY userFk, timed
+ LIMIT 10000000000000000000
+ )sub
+ )sub2
+ GROUP BY userFk
+ HAVING NOT SUM(hasLongWeekBreak);
+
+ DROP TEMPORARY TABLE tmp.workerWithoutShortWeekBreak, tmp.worker, tmp.worker2;
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 DROP PROCEDURE IF EXISTS `workerTimeControl_check__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_check__`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100))
-proc: BEGIN
-/**
- * Verifica si el empleado puede fichar en el momento actual, si puede fichar llama a workerTimeControlAdd
- *
- * @param vUserFk Identificador del trabajador
- * @return Retorna si encuentra un problema 'odd','maxTimeWork','breakDay','breakWeek' ;
- * En caso de tener algun problema retorna el primero que encuentra
- */
- DECLARE vLastIn DATETIME ;
- DECLARE vLastOut DATETIME ;
- DECLARE vDayWorkMax INT;
- DECLARE vDayBreak INT;
- DECLARE vWeekBreak INT ;
- DECLARE vWeekScope INT;
- DECLARE vDayStayMax INT;
- DECLARE vProblem VARCHAR(20) DEFAULT NULL;
- DECLARE vTimedWorked INT;
- DECLARE vCalendarStateType VARCHAR(20) DEFAULT NULL;
- DECLARE vDepartmentFk INT;
- DECLARE vTo VARCHAR(50) DEFAULT NULL;
- DECLARE vUserName VARCHAR(50) DEFAULT NULL;
- DECLARE vBody VARCHAR(255) DEFAULT NULL;
-
- SELECT dayBreak, weekBreak, weekScope, dayWorkMax, dayStayMax
- INTO vDayBreak, vWeekBreak, vWeekScope, vDayWorkMax, vDayStayMax
- FROM workerTimeControlParams;
-
- SELECT MAX(timed) INTO vLastIn
- FROM workerTimeControl
- WHERE userFk = vUserFk
- AND direction = 'in';
-
- SELECT MAX(timed) INTO vLastOut
- FROM workerTimeControl
- WHERE userFk = vUserFk
- AND direction = 'out';
-
- SELECT CONCAT(u.name,'@verdnatura.es') INTO vTo
- FROM account.user u
- WHERE u.id = (SELECT bossFk FROM worker WHERE id = vUserFk);
-
- SELECT CONCAT(firstName,' ',lastName) INTO vUserName
- FROM worker w
- WHERE w.id = vUserFk;
-
-
- IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastIn) > vDayStayMax THEN -- NUEVA JORNADA
-
- -- VERIFICAR DESCANSO DIARIO
- IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastOut) < vDayBreak THEN
- SELECT "Descansos 12 h" AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"Descansos 12 h") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
- END IF;
-
- -- VERIFICAR FICHADAS IMPARES DEL ÚLTIMO DÍA QUE SE FICHÓ
- IF (SELECT MOD(COUNT(*),2) -- <>0
- FROM workerTimeControl
- WHERE userFk = vUserFk
- AND timed >= vLastIn
- ) THEN
- SELECT "Dias con fichadas impares" AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"Dias con fichadas impares") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
- END IF;
-
- -- VERIFICAR VACACIONES
- SELECT cs.type INTO vCalendarStateType
- FROM postgresql.calendar_employee ce
- JOIN postgresql.business b USING(business_id)
- JOIN postgresql.profile pr ON pr.profile_id = b.client_id
- JOIN postgresql.person p ON p.person_id = pr.person_id
- JOIN postgresql.calendar_state cs USING(calendar_state_id)
- JOIN worker w ON w.id = p.id_trabajador
- WHERE ce.date = CURDATE()
- AND cs.isAllowedToWork = FALSE
- AND w.userFk = vUserFk
- LIMIT 1;
-
- IF(LENGTH(vCalendarStateType)) THEN
- SELECT vCalendarStateType AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"Vacaciones") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
-
- END IF;
-
-
- -- VERIFICAR CONTRATO EN VIGOR
- IF (SELECT COUNT(*)
- FROM postgresql.business b
- JOIN postgresql.profile pr ON pr.profile_id = b.client_id
- JOIN postgresql.person p ON p.person_id = pr.person_id
- JOIN worker w ON w.id = p.id_trabajador
- WHERE w.userFk = vUserFk
- AND b.date_start <= vDated
- AND IFNULL(b.date_end,vDated) >= vDated
- ) = 0 THEN
- SELECT "No hay un contrato en vigor" AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"No hay un contrato en vigor") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
-
- END IF;
-
- -- VERIFICAR DESCANSO SEMANAL
- SET @vHasBreakWeek:= FALSE;
- SET @vLastTimed:= UNIX_TIMESTAMP((NOW() - INTERVAL vWeekScope SECOND));
-
- DROP TEMPORARY TABLE IF EXISTS tmp.trash;
- CREATE TEMPORARY TABLE tmp.trash
- SELECT IF(vWeekBreak-(UNIX_TIMESTAMP(timed)-@vLastTimed) <= 0, @vHasBreakWeek:=TRUE, TRUE) alias,
- @vLastTimed:= UNIX_TIMESTAMP(timed)
- FROM workerTimeControl
- WHERE timed>= (NOW() - INTERVAL vWeekScope SECOND)
- AND userFk= vUserFk
- AND direction IN ('in','out')
- ORDER BY timed ASC;
-
- IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastOut) < vWeekBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA
- SELECT "Descansos 36 h" AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"Descansos 36 h") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
- END IF;
-
- DROP TEMPORARY TABLE tmp.trash;
-
- ELSE -- DIA ACTUAL
-
- -- VERIFICA QUE EL TIEMPO EFECTIVO NO SUPERE EL MÁXIMO
- SELECT IFNULL(SUM(if( mod(wtc.order,2)=1, -UNIX_TIMESTAMP(timed), UNIX_TIMESTAMP(timed))),0) - IF( MOD(COUNT(*),2), UNIX_TIMESTAMP(NOW()), 0) INTO vTimedWorked
- FROM workerTimeControl wtc
- WHERE userFk = vUserFk
- AND timed >= vLastIn
- ORDER BY timed;
-
- IF vTimedWorked > vDayWorkMax THEN
- SELECT "Jornadas" AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"Jornadas") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
- END IF;
-
- END IF;
-
- -- VERIFICAR DEPARTAMENTO
- IF vTabletFk IS NOT NULL THEN
- SELECT wtcu.departmentFk INTO vDepartmentFk
- FROM workerTimeControlUserInfo wtcu
- WHERE wtcu.userFk = vUserFk;
- IF (SELECT COUNT(td.tabletFk)
- FROM tabletDepartment td
- WHERE td.tabletFk = vTabletFk AND td.departmentFk = vDepartmentFk
- ) = 0 THEN
- SELECT "No perteneces a este departamento." AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"No perteneces a este departamento.") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
- END IF;
- 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 DROP PROCEDURE IF EXISTS `workerTimeControl_clockIn` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -89586,18 +74315,22 @@ DELIMITER ;
/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_clockIn`(vWorker INT, vTimed DATETIME, vDirection VARCHAR(10))
+CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_clockIn`(
+ vWorker INT,
+ vTimed DATETIME,
+ vDirection VARCHAR(10))
BEGIN
/**
* Verifica si el empleado puede fichar
* @param vWorker Identificador del trabajador
- * @param vTimed valor de la fichada, IF vTimed IS NULL vTimed = NOW()
- * @param vDirection solo se pueden pasa los valores del campo workerTimeControl.direction ENUM('in', 'out', 'middle')
- * @return Si todo es correcto, retorna el número de id la tabla workerTimeControl. Si hay algún problema, devuelve el mesaje a que se debe mostrar al usuario
- * Solo retorna el primer problema, en caso de no ocurrir ningún error se añadirá fichada a la tabla vn.workerTimeControl
+ * @param vTimed valor de la fichada, IF vTimed IS NULL vTimed = util.VN_NOW()
+ * @param vDirection solo se pueden pasa los valores del campo
+ * workerTimeControl.direction ENUM('in', 'out', 'middle')
+ * @return Si todo es correcto, retorna el número de id la tabla workerTimeControl.
+ * Si hay algún problema, devuelve el mesaje a que se debe mostrar al usuario
+ * Solo retorna el primer problema, en caso de no ocurrir ningún error se añadirá
+ * fichada a la tabla vn.workerTimeControl
*/
DECLARE vLastIn DATETIME;
DECLARE vLastOut DATETIME;
@@ -89617,42 +74350,39 @@ BEGIN
DECLARE vDated DATE;
DECLARE vIsAllowedToWork VARCHAR(50);
DECLARE vDepartmentFk INT;
- DECLARE vTimedLoop INT;
- DECLARE vTimedLoopPrevious INT;
+ DECLARE vTimedLoop BIGINT;
+ DECLARE vTimedLoopPrevious BIGINT;
DECLARE vHasBreakWeek BOOLEAN DEFAULT FALSE;
DECLARE vManual BOOLEAN DEFAULT TRUE;
DECLARE vDone INT DEFAULT FALSE;
DECLARE vCursor CURSOR FOR
- SELECT UNIX_TIMESTAMP(NOW() - INTERVAL vGap SECOND)
- UNION
- SELECT UNIX_TIMESTAMP(NOW())
- UNION
- (SELECT UNIX_TIMESTAMP(timed)
- FROM workerTimeControl
- WHERE timed BETWEEN (vTimed - INTERVAL vGap SECOND) AND vTimed AND
- userFk = vWorker AND
- direction IN ('in', 'out')
- ORDER BY timed ASC);
-
- DECLARE vCursor2 CURSOR FOR
- SELECT UNIX_TIMESTAMP(NOW() - INTERVAL vGap SECOND)
- UNION
- SELECT UNIX_TIMESTAMP(NOW())
+ SELECT UNIX_TIMESTAMP(vTimed) timed
UNION
SELECT UNIX_TIMESTAMP(timed)
FROM workerTimeControl
- WHERE timed BETWEEN vTimed AND (vTimed - INTERVAL vGap SECOND) AND
- userFk = vWorker AND
- direction IN ('in', 'out')
- ORDER BY timed ASC;
+ WHERE timed BETWEEN (vTimed - INTERVAL vGap SECOND) AND vTimed
+ AND userFk = vWorker
+ AND direction IN ('in', 'out')
+ ORDER BY timed ASC;
+
+ DECLARE vCursor2 CURSOR FOR
+ SELECT UNIX_TIMESTAMP(vTimed) timed
+ UNION
+ SELECT UNIX_TIMESTAMP(timed)
+ FROM workerTimeControl
+ WHERE timed BETWEEN vTimed AND (vTimed + INTERVAL vGap SECOND)
+ AND userFk = vWorker
+ AND direction IN ('in', 'out')
+ ORDER BY timed ASC;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
DECLARE EXIT HANDLER FOR SQLSTATE '45000'
BEGIN
- SELECT CONCAT(u.name, '@verdnatura.es'), CONCAT(w.firstName, ' ', w.lastName)
+ SELECT CONCAT(u.name, '@verdnatura.es'),
+ CONCAT(w.firstName, ' ', w.lastName)
INTO vMailTo, vUserName
FROM account.user u
JOIN worker w ON w.bossFk = u.id
@@ -89668,7 +74398,8 @@ BEGIN
WHEN 'ODD_WORKERTIMECONTROL' THEN
SELECT 'Fichadas impares' INTO vErrorMessage;
WHEN 'BREAK_DAY' THEN
- SELECT CONCAT('Descanso diario ', FORMAT(vDayBreak/3600, 0) , 'h.') INTO vErrorMessage;
+ SELECT CONCAT('Descanso diario ', FORMAT(vDayBreak/3600, 0), 'h.')
+ INTO vErrorMessage;
WHEN 'BREAK_WEEK' THEN
SELECT CONCAT('Descanso semanal ',
FORMAT(vShortWeekBreak / 3600,0) ,'h. / ',
@@ -89680,29 +74411,35 @@ BEGIN
END CASE;
SELECT vErrorMessage `error`;
- SELECT CONCAT(vUserName, ' no ha podido fichar por el siguiente problema: ', vErrorMessage) INTO vErrorMessage;
+ SELECT CONCAT(vUserName,
+ ' no ha podido fichar por el siguiente problema: ',
+ vErrorMessage)
+ INTO vErrorMessage;
CALL mail_insert( vMailTo, vMailTo, 'Error al fichar', vErrorMessage);
END;
IF (vTimed IS NULL) THEN
- SET vTimed = NOW();
+ SET vTimed = util.VN_NOW();
SET vManual = FALSE;
END IF;
SET vDated = DATE(vTimed);
- SELECT IF(pc.category_name = 'Conductor +3500kg', wc.dayBreakDriver, wc.dayBreak),
- wc.shortWeekBreak,
- wc.longWeekBreak,
- wc.weekScope
+ SELECT IF(pc.category_name = 'Conductor +3500kg',
+ wc.dayBreakDriver,
+ wc.dayBreak),
+ wc.shortWeekBreak,
+ wc.longWeekBreak,
+ wc.weekScope
INTO vDayBreak,
- vShortWeekBreak,
- vLongWeekBreak,
- vWeekScope
+ vShortWeekBreak,
+ vLongWeekBreak,
+ vWeekScope
FROM workerLabour w
JOIN postgresql.business_labour bl ON bl.business_id = w.businessFk
- JOIN postgresql.professional_category pc ON pc.professional_category_id = bl.professional_category_id
+ JOIN postgresql.professional_category pc
+ ON pc.professional_category_id = bl.professional_category_id
JOIN workerTimeControlConfig wc ON TRUE
WHERE w.workerFk = vWorker
AND vDated BETWEEN w.started AND IFNULL(w.ended, vDated);
@@ -89746,7 +74483,7 @@ BEGIN
LIMIT 1;
-- FICHADAS A FUTURO
- IF vTimed > DATE_ADD(NOW(), INTERVAL 60 SECOND) THEN
+ IF vTimed > DATE_ADD(util.VN_NOW(), INTERVAL 60 SECOND) THEN
SET vErrorCode = 'IS_NOT_ALLOWED_FUTURE';
CALL util.throw(vErrorCode);
END IF;
@@ -89769,10 +74506,18 @@ BEGIN
END IF;
-- DIRECCION CORRECTA
- CALL vn.workerTimeControl_direction(vWorker, vTimed);
- IF (SELECT IF(IF(option1 IN ('inMiddle', 'outMiddle'), 'middle', option1) <> vDirection
- AND IF(option2 IN ('inMiddle', 'outMiddle'), 'middle', IFNULL(option2, '')) <> vDirection, TRUE , FALSE)
- FROM tmp.workerTimeControlDirection) THEN
+ CALL workerTimeControl_direction(vWorker, vTimed);
+ IF (SELECT
+ IF(IF(option1 IN ('inMiddle', 'outMiddle'),
+ 'middle',
+ option1) <> vDirection
+ AND IF(option2 IN ('inMiddle', 'outMiddle'),
+ 'middle',
+ IFNULL(option2, '')) <> vDirection,
+ TRUE ,
+ FALSE)
+ FROM tmp.workerTimeControlDirection
+ ) THEN
SET vIsError = TRUE;
END IF;
@@ -89783,7 +74528,9 @@ BEGIN
END IF;
-- FICHADAS IMPARES
- IF (SELECT IF(vDirection = 'in', MOD(COUNT(*), 2) , IF (vDirection = 'out', NOT MOD(COUNT(*), 2), FALSE))
+ IF (SELECT IF(vDirection = 'in',
+ MOD(COUNT(*), 2) ,
+ IF (vDirection = 'out', NOT MOD(COUNT(*), 2), FALSE))
FROM workerTimeControl
WHERE userFk = vWorker
AND timed BETWEEN vLastIn AND vTimed
@@ -89822,7 +74569,7 @@ BEGIN
IF vDone THEN
LEAVE l;
END IF;
- IF vShortWeekBreak - (vTimedLoop - vTimedLoopPrevious) < 0 THEN
+ IF vShortWeekBreak - (vTimedLoop - vTimedLoopPrevious) <= 0 THEN
SET vHasBreakWeek = TRUE;
LEAVE l;
END IF;
@@ -89832,7 +74579,7 @@ BEGIN
-- VERIFICA DESCANSO LARGO EN LA ÚLTIMAS 2 SEMANAS
IF NOT vHasBreakWeek THEN
SET vGap = vWeekScope * 2;
- SET vTimedLoopPrevious = UNIX_TIMESTAMP((vTimed - INTERVAL vGap SECOND));
+ SET vTimedLoopPrevious = UNIX_TIMESTAMP(vTimed - INTERVAL vGap SECOND);
SET vDone = FALSE;
OPEN vCursor;
l:LOOP
@@ -89840,7 +74587,7 @@ BEGIN
IF vDone THEN
LEAVE l;
END IF;
- IF vLongWeekBreak - (vTimedLoop - vTimedLoopPrevious) < 0 THEN
+ IF vLongWeekBreak - (vTimedLoop - vTimedLoopPrevious) <= 0 THEN
SET vHasBreakWeek = TRUE;
LEAVE l;
END IF;
@@ -89854,37 +74601,37 @@ BEGIN
SET vGap = vWeekScope;
SET vTimedLoopPrevious = vTimed;
SET vDone = FALSE;
- OPEN vCursor;
+ OPEN vCursor2;
l:LOOP
- FETCH vCursor INTO vTimedLoop;
+ FETCH vCursor2 INTO vTimedLoop;
IF vDone THEN
LEAVE l;
END IF;
- IF vShortWeekBreak - (vTimedLoop - vTimedLoopPrevious) < 0 THEN
+ IF vShortWeekBreak - (vTimedLoop - vTimedLoopPrevious) <= 0 THEN
SET vHasBreakWeek = TRUE;
LEAVE l;
END IF;
SET vTimedLoopPrevious = vTimedLoop;
END LOOP l;
- CLOSE vCursor;
+ CLOSE vCursor2;
-- VERIFICA DESCANSO LARGO EN LAS PRÓXIMAS 2 SEMANAS
IF NOT vHasBreakWeek THEN
SET vGap = vWeekScope * 2;
SET vTimedLoopPrevious = vTimed;
SET vDone = FALSE;
- OPEN vCursor;
+ OPEN vCursor2;
l:LOOP
- FETCH vCursor INTO vTimedLoop;
+ FETCH vCursor2 INTO vTimedLoop;
IF vDone THEN
LEAVE l;
END IF;
- IF vShortWeekBreak - (vTimedLoop - vTimedLoopPrevious) < 0 THEN
+ IF vShortWeekBreak - (vTimedLoop - vTimedLoopPrevious) <= 0 THEN
SET vHasBreakWeek = TRUE;
LEAVE l;
END IF;
SET vTimedLoopPrevious = vTimedLoop;
END LOOP l;
- CLOSE vCursor;
+ CLOSE vCursor2;
END IF;
END IF;
IF NOT vHasBreakWeek THEN
@@ -89892,7 +74639,7 @@ BEGIN
CALL util.throw(vErrorCode);
END IF;
END IF;
-
+
-- SE PERMITE FICHAR
INSERT INTO workerTimeControl(userFk, timed, direction, manual)
VALUES(vWorker, vTimed, vDirection, vManual);
@@ -89904,6 +74651,8 @@ DELIMITER ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_direction` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -89911,8 +74660,6 @@ DELIMITER ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_direction`(vWorkerFk VARCHAR(10), vTimed DATETIME)
BEGIN
@@ -89926,7 +74673,7 @@ BEGIN
DECLARE vIsMiddleOdd BOOLEAN ;
IF (vTimed IS NULL) THEN
- SET vTimed = NOW();
+ SET vTimed = util.VN_NOW();
END IF;
SELECT timed INTO vLastIn
@@ -89941,7 +74688,7 @@ BEGIN
FROM workerTimeControl
WHERE userFk = vWorkerFk
AND direction = 'middle'
- AND timed BETWEEN vLastIn AND NOW();
+ AND timed BETWEEN vLastIn AND util.VN_NOW();
DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControlDirection;
CREATE TEMPORARY TABLE tmp.workerTimeControlDirection
@@ -89978,77 +74725,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_direction__` */;
-/*!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_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_direction__`(vWorkerFk VARCHAR(10), vTimed DATETIME)
-BEGIN
-/**
- * Devuelve que direcciones de fichadas son lógicas a partir de la anterior fichada
- * @param vWorkerFk Identificador del trabajador
- * @return (option1, option2)
- * Los valores posibles de retorno son ('in', 'inMiddle', 'outMiddle', 'out')
- */
- DECLARE vLastIn DATETIME ;
- DECLARE vIsMiddleOdd BOOLEAN ;
-
- IF (vTimed IS NULL) THEN
- SET vTimed = NOW();
- END IF;
-
- SELECT timed INTO vLastIn
- FROM workerTimeControl
- WHERE userFk = vWorkerFk
- AND direction = 'in'
- AND timed < vTimed
- ORDER BY timed DESC
- LIMIT 1;
-
- SELECT (COUNT(*)mod 2 = 1) INTO vIsMiddleOdd
- FROM workerTimeControl
- WHERE userFk = vWorkerFk
- AND direction = 'middle'
- AND timed BETWEEN vLastIn AND NOW();
-
- DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControlDirection;
-
- CREATE TEMPORARY TABLE tmp.workerTimeControlDirection
- SELECT CASE WHEN w.direction ='in' THEN 'inMiddle'
- WHEN w.direction = 'out' THEN 'in'
- WHEN w.direction = 'middle' AND vIsMiddleOdd THEN 'outMiddle'
- WHEN w.direction IS NULL THEN 'in'
- ELSE 'inMiddle'
- END option1,
- CASE WHEN w.direction ='in' THEN 'out'
- WHEN w.direction = 'out' THEN NULL
- WHEN w.direction = 'middle' AND vIsMiddleOdd THEN NULL
- WHEN w.direction IS NULL THEN NULL
- ELSE 'out'
- END option2
- FROM workerTimeControl w
- WHERE w.timed <= vTimed
- AND w.userFk = vWorkerFk
- ORDER BY w.timed DESC
- LIMIT 1;
-
- IF (SELECT IF(COUNT(*)=0, TRUE, FALSE) FROM tmp.workerTimeControlDirection ) THEN
- INSERT INTO tmp.workerTimeControlDirection (option1, option2)
- VALUES('in', NULL);
- 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 sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_getClockIn` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -90056,102 +74734,90 @@ DELIMITER ;
/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_getClockIn`(vUserFk INT, vDated DATE)
+CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_getClockIn`(
+ vUserFk INT,
+ vDated DATE)
BEGIN
-
/**
* Muestra una tabla con los 7 días inmediatamente anteriores a la fecha proporcionada
- * y las fichadas de cada dia, en columnas por día
- *
+ * y las fichadas de cada día, en columnas por día
+ * @param vUserFk Identificador del trabajador
+ * @param vDated Fecha proporcionada
*/
-
- CALL workerTimeControl_setOrder(vUserFk,TIMESTAMPADD(DAY,-8,vDated),vDated);
-
- DROP TEMPORARY TABLE IF EXISTS tmp.workerWeekTiming;
- CREATE TEMPORARY TABLE tmp.workerWeekTiming
- SELECT orden `orden`,
- max(hace7dias) 7_dias_antes,
- max(hace6dias) 6_dias_antes,
- max(hace5dias) 5_dias_antes,
- max(hace4dias) 4_dias_antes,
- max(hace3dias) 3_dias_antes,
- max(antesdeayer) 2_dias_antes,
- max(ayer) 1_dia_antes,
- max(hoy) mismo_dia
- FROM
- (
- SELECT IF(dias = 7, fichada, '') as hace7dias,
- IF(dias = 6, fichada, '') as hace6dias,
- IF(dias = 5, fichada, '') as hace5dias,
- IF(dias = 4, fichada, '') as hace4dias,
- IF(dias = 3, fichada, '') as hace3dias,
- IF(dias = 2, fichada, '') as antesdeayer,
- IF(dias = 1, fichada, '') as ayer,
- IF(dias = 0, fichada, '') as hoy,
- orden
-
- FROM
- (
- SELECT `order` as orden, datediff(vDated, timed) as dias, date(timed) as fecha, TIME_FORMAT(timed,'%H:%i') as fichada
- FROM vn.workerTimeControl wtc
- WHERE userFk = vUserFk
- AND timed >= TIMESTAMPADD(DAY, -7, vDated)
- ) sub
- )sub2
- GROUP BY orden;
+ CALL timeControl_calculateByWorker(
+ vUserFk,
+ DATE_SUB(vDated, INTERVAL 6 DAY), util.dayEnd(vDated));
- DROP TEMPORARY TABLE IF EXISTS tmp.workerWeekTiming_Aux;
- CREATE TEMPORARY TABLE tmp.workerWeekTiming_Aux
- SELECT * FROM tmp.workerWeekTiming;
+ SET @position := 0;
+ SET @lastDated := NULL;
- INSERT INTO tmp.workerWeekTiming( 7_dias_antes, 6_dias_antes, 5_dias_antes, 4_dias_antes, 3_dias_antes, 2_dias_antes, 1_dia_antes, mismo_dia)
- VALUES('total','','','','','','','');
-
- INSERT INTO tmp.workerWeekTiming( orden, 7_dias_antes, 6_dias_antes, 5_dias_antes, 4_dias_antes, 3_dias_antes, 2_dias_antes, 1_dia_antes, mismo_dia)
- SELECT 0,
- IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(7_dias_antes), TIME_TO_SEC(7_dias_antes)))),'%H:%i'),''),
- IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(6_dias_antes), TIME_TO_SEC(6_dias_antes)))),'%H:%i'),''),
- IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(5_dias_antes), TIME_TO_SEC(5_dias_antes)))),'%H:%i'),''),
- IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(4_dias_antes), TIME_TO_SEC(4_dias_antes)))),'%H:%i'),''),
- IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(3_dias_antes), TIME_TO_SEC(3_dias_antes)))),'%H:%i'),''),
- IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(2_dias_antes), TIME_TO_SEC(2_dias_antes)))),'%H:%i'),''),
- IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(1_dia_antes), TIME_TO_SEC(1_dia_antes)))),'%H:%i'),''),
- ''
- FROM tmp.workerWeekTiming_Aux;
-
- INSERT INTO tmp.workerWeekTiming_Aux( orden, 1_dia_antes)
- SELECT 0, ROUND((
- IFNULL(TIME_TO_SEC(7_dias_antes),0) +
- IFNULL(TIME_TO_SEC(6_dias_antes),0) +
- IFNULL(TIME_TO_SEC(5_dias_antes),0) +
- IFNULL(TIME_TO_SEC(4_dias_antes),0) +
- IFNULL(TIME_TO_SEC(3_dias_antes),0) +
- IFNULL(TIME_TO_SEC(2_dias_antes),0) +
- IFNULL(TIME_TO_SEC(1_dia_antes),0)
- ) / 3600,1)
- FROM tmp.workerWeekTiming
- WHERE orden = 0;
-
-
- INSERT INTO tmp.workerWeekTiming( 7_dias_antes,6_dias_antes,5_dias_antes,4_dias_antes,3_dias_antes,2_dias_antes,1_dia_antes,mismo_dia)
- SELECT '','','','','','',1_dia_antes,''
- FROM tmp.workerWeekTiming_Aux
- WHERE orden = 0;
-
- SELECT 7_dias_antes, 6_dias_antes, 5_dias_antes, 4_dias_antes, 3_dias_antes, 2_dias_antes, 1_dia_antes, mismo_dia FROM tmp.workerWeekTiming;
-
- DROP TEMPORARY TABLE tmp.workerWeekTiming;
- DROP TEMPORARY TABLE tmp.workerWeekTiming_Aux;
+ SELECT *
+ FROM( SELECT MAX(6daysAgo) 6daysAgo,
+ MAX(6daysAgoDirection) 6daysAgoDirection,
+ MAX(5daysAgo) 5daysAgo,
+ MAX(5daysAgoDirection) 5daysAgoDirection,
+ MAX(4daysAgo) 4daysAgo,
+ MAX(4daysAgoDirection) 4daysAgoDirection,
+ MAX(3daysAgo) 3daysAgo,
+ MAX(3daysAgoDirection) 3daysAgoDirection,
+ MAX(2daysAgo) 2daysAgo,
+ MAX(2daysAgoDirection) 2daysAgoDirection,
+ MAX(1daysAgo) 1daysAgo,
+ MAX(1daysAgoDirection) 1daysAgoDirection,
+ MAX(0daysAgo) 0daysAgo,
+ MAX(0daysAgoDirection) 0daysAgoDirection
+ FROM(SELECT IF(daysAgo = 6, timed, '') 6daysAgo,
+ IF(daysAgo = 5, timed, '') 5daysAgo,
+ IF(daysAgo = 4, timed, '') 4daysAgo,
+ IF(daysAgo = 3, timed, '') 3daysAgo,
+ IF(daysAgo = 2, timed, '') 2daysAgo,
+ IF(daysAgo = 1, timed, '') 1daysAgo,
+ IF(daysAgo = 0, timed, '') 0daysAgo,
+ IF(daysAgo = 6, direction, '') 6daysAgoDirection,
+ IF(daysAgo = 5, direction, '') 5daysAgoDirection,
+ IF(daysAgo = 4, direction, '') 4daysAgoDirection,
+ IF(daysAgo = 3, direction, '') 3daysAgoDirection,
+ IF(daysAgo = 2, direction, '') 2daysAgoDirection,
+ IF(daysAgo = 1, direction, '') 1daysAgoDirection,
+ IF(daysAgo = 0, direction, '') 0daysAgoDirection,
+ direction,
+ position
+ FROM(SELECT DATEDIFF(vDated, timed) daysAgo,
+ TIME_FORMAT(timed,'%H:%i') timed,
+ IF(DATE(timed) <> @lastDated, @position := 0, NULL),
+ @position := @position+1 position,
+ @lastDated := DATE(timed),
+ direction
+ FROM workerTimeControl wtc
+ WHERE wtc.userFk = vUserFk
+ AND wtc.timed >= TIMESTAMPADD(DAY, -6,vDated)
+ ORDER BY wtc.timed
+ LIMIT 10000000000000000000
+ )sub
+ )sub2
+ GROUP BY position) sub3
+ JOIN (SELECT MAX(IF(daysAgo = 6, timeWorkSeconds, 0)) 6daysAgoTotal,
+ MAX(IF(daysAgo = 5, timeWorkSeconds, 0)) 5daysAgoTotal,
+ MAX(IF(daysAgo = 4, timeWorkSeconds, 0)) 4daysAgoTotal,
+ MAX(IF(daysAgo = 3, timeWorkSeconds, 0)) 3daysAgoTotal,
+ MAX(IF(daysAgo = 2, timeWorkSeconds, 0)) 2daysAgoTotal,
+ MAX(IF(daysAgo = 1, timeWorkSeconds, 0)) 1daysAgoTotal,
+ MAX(IF(daysAgo = 0, timeWorkSeconds, 0)) 0daysAgoTotal
+ FROM (SELECT DATEDIFF(vDated, dated) daysAgo,
+ timeWorkSeconds
+ FROM tmp.timeControlCalculate) sub4)sub5 ON TRUE;
+
+ DROP TEMPORARY TABLE tmp.timeControlCalculate;
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 `workerTimeControl_login` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -90159,8 +74825,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_login`(vWorkerFk VARCHAR(10))
BEGIN
@@ -90171,7 +74835,7 @@ BEGIN
* @return (name, surname, userFk, departmentFk, button1, button2)
* Los valores posibles para button son ('in', 'inMiddle', 'outMiddle', 'out')
*/
- CALL vn.workerTimeControl_direction(vWorkerFk, NOW());
+ CALL vn.workerTimeControl_direction(vWorkerFk, util.VN_NOW());
SELECT wi.name,
wi.surname,
@@ -90191,6 +74855,8 @@ DELIMITER ;
/*!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 `workerTimeControl_remove` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -90198,8 +74864,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_remove`(IN vUserFk INT, IN vTimed DATETIME)
BEGIN
@@ -90253,6 +74917,8 @@ DELIMITER ;
/*!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 `workerTimeControl_repair` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -90260,8 +74926,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_repair`()
proc: BEGIN
@@ -90305,6 +74969,8 @@ DELIMITER ;
/*!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 `workerTimeControl_sendMail` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -90312,8 +74978,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_sendMail`(vWeek INT, vYear INT, vWorkerFk INT)
BEGIN
@@ -90349,7 +75013,8 @@ BEGIN
DECLARE vPermissionRate DECIMAL(5,2);
DECLARE vIsTeleworking BOOL;
DECLARE vIsTeleworkingOld BOOL;
-
+ DECLARE vError BOOL DEFAULT FALSE;
+
DECLARE vCursor CURSOR FOR
SELECT CONCAT(u.name, '@verdnatura.es'), u.id, tb.dated, tb.timeWorkDecimal, LEFT(tb.timeWorkSexagesimal,5) timeWorkSexagesimal,
tb.timeTable, tc.timeWorkDecimal timeWorkedDecimal, LEFT(tc.timeWorkSexagesimal,5) timeWorkedSexagesimal, tb.type, tb.businessFk,tb.permissionRate, d.isTeleworking
@@ -90359,6 +75024,8 @@ BEGIN
JOIN postgresql.business b ON b.business_id = tb.businessFk
JOIN company c ON c.id = b.provider_id
LEFT JOIN tmp.timeControlCalculate tc ON tc.userFk = tb.userFk AND tc.dated = tb.dated
+ LEFT JOIN worker w ON w.id = u.id
+ LEFT JOIN `user` u2 ON u2.id = w.bossFk
JOIN (SELECT tb.userFk,
SUM(IF(tb.type IS NULL,
IF(tc.timeWorkDecimal > 0, FALSE, IF(tb.timeWorkDecimal > 0, TRUE, FALSE)),
@@ -90375,12 +75042,23 @@ BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
+ DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
+ BEGIN
+ SET vError = TRUE;
+
+ INSERT INTO tmp.error(workerFk)
+ SELECT vWorkerFk;
+ END;
+
DROP TABLE IF EXISTS tmp.timeControlCalculate;
DROP TABLE IF EXISTS tmp.timeBusinessCalculate;
DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate;
DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate;
DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate1;
DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate1;
+ DROP TEMPORARY TABLE IF EXISTS tmp.error;
+
+ CREATE TEMPORARY TABLE tmp.error (workerFk INT);
SELECT CONCAT (MIN(dated), ' 00:00:00'), CONCAT (MAX(dated), ' 23:59:59') INTO vStarted, vEnded
FROM time
@@ -90393,7 +75071,7 @@ BEGIN
isSendMail;
UPDATE workerTimeControlMail
- SET updated = NOW(), state = 'SENDED'
+ SET updated = util.VN_NOW(), state = 'SENDED'
WHERE year = vYear AND
week = vWeek AND
IFNULL(vWorkerFk, workerFk) = workerFk ;
@@ -90423,6 +75101,9 @@ proc: LOOP
LEAVE proc;
END IF;
+ START TRANSACTION;
+ SET vError = FALSE;
+
IF vTimeWorkDecimal>0 AND vTimeWorkedDecimal IS NULL AND IFNULL(vPermissionRate, TRUE) THEN
IF vTimeTable IS NULL THEN
INSERT INTO workerTimeControl (userFk, timed, manual, direction, isSendMail)
@@ -90552,7 +75233,7 @@ proc: LOOP
");
- IF vIsTeleworkingOld THEN
+ IF vIsTeleworkingOld AND NOT vError THEN
CALL mail_insert(
vReceiverOld,
'timecontrol@verdnatura.es',
@@ -90562,6 +75243,8 @@ proc: LOOP
INSERT IGNORE INTO workerTimeControlMail (workerFk, year, week)
VALUES(vWorkerFkOld, vYear, vWeek);
+ ELSE
+ ROLLBACK;
END IF;
SET vBody = '';
@@ -90570,19 +75253,32 @@ proc: LOOP
SET vIsTeleworkingOld = vIsTeleworking;
SET vReceiverOld = vReceiver;
END IF;
+ COMMIT;
END LOOP;
CLOSE vCursor;
-
+
+ INSERT INTO mail (receiver, replyTo, subject, body)
+ SELECT CONCAT(u.name, '@verdnatura.es'),
+ CONCAT('Error registro de horas semana ', vWeek, ' año ', vYear) ,
+ CONCAT('No se ha podido enviar el registro de horas al empleado/s: ', GROUP_CONCAT(DISTINCT CONCAT('
', w.id, ' ', w.firstName, ' ', w.lastName)))
+ FROM tmp.error e
+ JOIN worker w ON w.id = e.workerFk
+ JOIN user u ON u.id = w.bossFk
+ GROUP BY w.bossFk;
+
DROP TABLE tmp.timeControlCalculate;
DROP TABLE tmp.timeBusinessCalculate;
DROP TABLE tmp.timeControlCalculate1;
DROP TABLE tmp.timeBusinessCalculate1;
+ DROP TABLE tmp.error;
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 `workerTimeControl_sendMailByDepartment` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -90590,8 +75286,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_sendMailByDepartment`(IN vDatedFrom DATETIME, IN vDatedTo DATETIME, IN vWorkerFk INT)
BEGIN
@@ -90724,6 +75418,8 @@ DELIMITER ;
/*!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 `workerTimeControl_sendMailByDepartmentLauncher` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -90731,15 +75427,13 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_sendMailByDepartmentLauncher`()
BEGIN
DECLARE vDatedFrom, vDatedTo DATETIME;
- IF (DAYNAME(CURDATE()) = 'miércoles') THEN
- SELECT DATE_SUB(CURDATE(), INTERVAL 9 DAY), CONCAT(DATE_SUB(CURDATE(), INTERVAL 3 DAY), ' 23:59:59') INTO vDatedFrom, vDatedTo;
+ IF (DAYNAME(util.VN_CURDATE()) = 'miércoles') THEN
+ SELECT DATE_SUB(util.VN_CURDATE(), INTERVAL 9 DAY), CONCAT(DATE_SUB(util.VN_CURDATE(), INTERVAL 3 DAY), ' 23:59:59') INTO vDatedFrom, vDatedTo;
CALL vn.workerTimeControl_sendMailByDepartment(vDatedFrom, vDatedTo, NULL);
END IF;
@@ -90749,6 +75443,8 @@ DELIMITER ;
/*!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 `workerTimeControl_setOrder` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -90756,8 +75452,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_setOrder`(vUserFk INT, vStarted DATE, vFinished DATE)
BEGIN
@@ -90777,6 +75471,57 @@ DELIMITER ;
/*!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 `workerTimeControl_weekCheckBreak` */;
+/*!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=`root`@`localhost` PROCEDURE `workerTimeControl_weekCheckBreak`(vStarted DATE, vEnded DATE)
+BEGIN
+/**
+ * Retorna los trabajadores que no han respetado el descanso semanal de 36/72 horas
+ * El sistema verificará el descanso corto en la siguiente semana
+ * o el largo en las 2 siguientes semanas a partir de las fechas dadas
+ * @param vStarted día inicio para verificar
+ * @param vEnded día final para verificar
+ * @return tmp.workerWithoutWeekBreak (workerFk)
+ */
+ DECLARE vDone INT DEFAULT FALSE;
+
+ IF(vStarted > vEnded) then
+ CALL util.throw ('Date end can not be greater then start');
+ END IF;
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.workerWithoutWeekBreakInWeek;
+ CREATE TEMPORARY TABLE tmp.workerWithoutWeekBreakInWeek
+ (workerFk INT,
+ PRIMARY KEY(workerFk))
+ ENGINE = MEMORY;
+
+
+ WHILE vStarted <= vEnded DO
+
+ CALL workerTimeControl_checkBreak(vStarted);
+ INSERT IGNORE INTO tmp.workerWithoutWeekBreakInWeek
+ SELECT workerFk
+ FROM tmp.workerWithoutWeekBreak;
+ DROP TEMPORARY TABLE IF EXISTS tmp.workerWithoutWeekBreak;
+ SET vStarted = DATE_ADD(vStarted, INTERVAL 1 DAY);
+
+ END WHILE;
+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 `workerWeekControl` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -90784,183 +75529,151 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerWeekControl`(vUserFk INT, vDated DATE, vTabletFk VARCHAR(100))
BEGIN
-
-/* Devuelve la cantidad de descansos de 12h y de 36 horas que ha disfrutado el trabajador
-* en la semana inmediatamente anterior a la fecha que pasa como parámetro.
-*
-* UPDATED PAK 2019/09/02
-* PENDING REVIEW
+/*
+* Devuelve la cantidad de descansos de 12h y de 36 horas que ha disfrutado el trabajador
+* en la semana inmediatamente anterior a la fecha que pasa como parámetro.
+* UPDATED PAK 2019/09/02
+* PENDING REVIEW
*/
+ DECLARE vDescansos12h INT;
+ DECLARE vDescansos36h INT;
+ DECLARE vJornadas INT;
+ DECLARE vImpares INT;
+ DECLARE vHasSignedToday BOOLEAN;
+ DECLARE v12hoursInMinutes INT DEFAULT 719;
+ DECLARE v36hoursInMinutes INT DEFAULT 2159;
+ DECLARE vCantWork VARCHAR(50) DEFAULT '';
+ DECLARE vDepartmentFk INT;
+ DECLARE isEnabled BOOLEAN DEFAULT TRUE;
-DECLARE vDescansos12h INT;
-DECLARE vDescansos36h INT;
-DECLARE vJornadas INT;
-DECLARE vImpares INT;
-DECLARE vHasSignedToday BOOLEAN;
-DECLARE v12hoursInMinutes INT DEFAULT 719;
-DECLARE v36hoursInMinutes INT DEFAULT 2159;
-DECLARE vCantWork VARCHAR(50) DEFAULT '';
-DECLARE vDepartmentFk INT;
-DECLARE isEnabled BOOLEAN DEFAULT TRUE;
+ SELECT COUNT(*) INTO vHasSignedToday
+ FROM vn.workerTimeControl WHERE timed >= vDated AND userFk = vUserFk;
+ SET @day := 0;
+ SET @lastTimed := util.VN_NOW();
-SELECT COUNT(*) INTO vHasSignedToday
- FROM vn.workerTimeControl WHERE timed >= vDated AND userFk = vUserFk;
-
-SET @day := 0;
-SET @lastTimed := NOW();
-
-SELECT SUM(IF(interval_in_minutes >= v12hoursInMinutes,1,0)), SUM(FLOOR(interval_in_minutes/ v36hoursInMinutes)) , SUM(jornadas)
- INTO vDescansos12h, vDescansos36h, vJornadas
- FROM
- (
- SELECT fichada_anterior, fichada_actual, interval_in_minutes, jornadas
- FROM
- (
- SELECT @lastTimed fichada_anterior,
- timed,
- CAST(time_to_sec(timediff(timed,@lastTimed )) / 60 AS UNSIGNED) as interval_in_minutes,
- IF(day(timed) != @day, 1, 0) as jornadas,
- @day := day(timed) dia_del_mes,
- @lastTimed := timed fichada_actual
- FROM
- (
- SELECT day(timed) as dayNumber, dayname(timed) as dayName, timed
- FROM
- (SELECT TIMESTAMPADD(DAY, -11, NOW()) as timed, vUserFk as userFk -- Fichada virtual para los en los que no se ha trabajado la semana anterior
- UNION ALL
- SELECT timed, userFk
- FROM vn.workerTimeControl wtc
- WHERE userFk = vUserFk
- AND timed >= TIMESTAMPADD(DAY, -10,vDated)
- UNION ALL
- SELECT IF(vHasSignedToday, '2000-01-01 00:00', NOW()) as timed, vUserFk
- ) sub4
- ORDER BY timed
- ) sub
-
- ) sub2
- WHERE fichada_actual >= TIMESTAMPADD(WEEK, -1, vDated)
- ) sub3 ;
-
-SELECT IFNULL(SUM(impar),0) into vImpares
-FROM (
- SELECT day(timed) as dayNumber,
- count(*) mod 2 as impar
- FROM vn.workerTimeControl wtc
- WHERE userFk = vUserFk
- AND timed >= TIMESTAMPADD(WEEK, -1,vDated) AND timed < vDated
- GROUP BY dayNumber
- ) sub;
-
--- Vacaciones
-SELECT cs.type INTO vCantWork
- FROM postgresql.calendar_employee ce
- JOIN postgresql.business b USING(business_id)
- JOIN postgresql.profile pr ON pr.profile_id = b.client_id
- JOIN postgresql.person p ON p.person_id = pr.person_id
- JOIN postgresql.calendar_state cs USING(calendar_state_id)
- JOIN vn.worker w ON w.id = p.id_trabajador
- WHERE ce.date = CURDATE()
- AND cs.isAllowedToWork = FALSE
- AND w.userFk = vUserFk
- LIMIT 1;
-
--- Contrato en vigor
-SELECT IF(COUNT(*),vCantWork,'Sin contrato') INTO vCantWork
- FROM postgresql.business b
- JOIN postgresql.profile pr ON pr.profile_id = b.client_id
- JOIN postgresql.person p ON p.person_id = pr.person_id
- JOIN vn.worker w ON w.id = p.id_trabajador
- WHERE w.userFk = vUserFk
- AND b.date_start <= vDated
- AND IFNULL(b.date_end,vDated) >= vDated;
-
--- Departamento si vTabletFk es 0 no hacemos comprobacion (Madrid y Vilassar)
-IF vTabletFk <> '0' THEN
--- 1 Obtener el departamento del usuario
- SELECT wtcu.departmentFk INTO vDepartmentFk
- FROM vn.workerTimeControlUserInfo wtcu
- WHERE wtcu.userFk = vUserFk;
--- 2 Comprobar si la tablet pertenece al departamento
- SELECT COUNT(td.tabletFk) INTO isEnabled
- FROM vn.tabletDepartment td
- WHERE td.tabletFk = vTabletFk AND td.departmentFk = vDepartmentFk;
-
-END IF;
-
-
-
-IF vJornadas IS NOT NULL THEN
-
- SELECT 'Jornadas' as Item, vJornadas as Cantidad, 'Correcto' AS Análisis
-
- UNION ALL
-
- SELECT 'Descansos 12 h' as Item, vDescansos12h as Cantidad, IF(vDescansos12h >= vJornadas, 'Correcto','Error: 1 por jornada') as Análisis
-
- UNION ALL
-
- SELECT 'Descansos 36 h' as Item, vDescansos36h as Cantidad, IF(vDescansos36h / 2 >= FLOOR(vJornadas/10), 'Correcto','Error: mínimo 2 cada 14 dias') as Análisis
-
- UNION ALL
-
- SELECT 'Dias con fichadas impares' as Item, vImpares as Cantidad, IF(vImpares = 0, 'Correcto','Error') as Análisis
-
- UNION ALL
-
- SELECT IF (LENGTH(vCantWork),CONCAT('Dia no laborable: ', vCantWork),'Dia laborable') as Item,
- '' as Cantidad,
- IF(LENGTH(vCantWork),'Error', 'Correcto') as Análisis
+ SELECT SUM(IF(interval_in_minutes >= v12hoursInMinutes,1,0)), SUM(FLOOR(interval_in_minutes/ v36hoursInMinutes)) , SUM(jornadas)
+ INTO vDescansos12h, vDescansos36h, vJornadas
+ FROM
+ (
+ SELECT fichada_anterior, fichada_actual, interval_in_minutes, jornadas
+ FROM
+ (
+ SELECT @lastTimed fichada_anterior,
+ timed,
+ CAST(time_to_sec(timediff(timed,@lastTimed )) / 60 AS UNSIGNED) as interval_in_minutes,
+ IF(day(timed) != @day, 1, 0) as jornadas,
+ @day := day(timed) dia_del_mes,
+ @lastTimed := timed fichada_actual
+ FROM
+ (
+ SELECT day(timed) as dayNumber, dayname(timed) as dayName, timed
+ FROM
+ (SELECT TIMESTAMPADD(DAY, -11, util.VN_NOW()) as timed, vUserFk as userFk -- Fichada virtual para los en los que no se ha trabajado la semana anterior
+ UNION ALL
+ SELECT timed, userFk
+ FROM vn.workerTimeControl wtc
+ WHERE userFk = vUserFk
+ AND timed >= TIMESTAMPADD(DAY, -10,vDated)
+ UNION ALL
+ SELECT IF(vHasSignedToday, '2000-01-01 00:00', util.VN_NOW()) as timed, vUserFk
+ ) sub4
+ ORDER BY timed
+ ) sub
- UNION ALL
+ ) sub2
+ WHERE fichada_actual >= TIMESTAMPADD(WEEK, -1, vDated)
+ ) sub3 ;
- SELECT 'El fichador no pertenece a tu departamento.' as Item, '' as Cantidad, IF(isEnabled, 'Correcto','Error') as Análisis
-
- ;
+ SELECT IFNULL(SUM(impar),0) into vImpares
+ FROM (
+ SELECT day(timed) as dayNumber,
+ count(*) mod 2 as impar
+ FROM vn.workerTimeControl wtc
+ WHERE userFk = vUserFk
+ AND timed >= TIMESTAMPADD(WEEK, -1,vDated) AND timed < vDated
+ GROUP BY dayNumber
+ ) sub;
-ELSE
-
-
- SELECT 'Jornadas' as Item, vJornadas as Cantidad, 'Correcto' AS Análisis
-
- UNION ALL
-
- SELECT 'Descansos 12 h' as Item, vDescansos12h as Cantidad, 'Correcto' as Análisis
-
- UNION ALL
-
- SELECT 'Descansos 36 h' as Item, vDescansos36h as Cantidad, 'Correcto' as Análisis
-
- UNION ALL
-
- SELECT 'Dias con fichadas impares' as Item, vImpares as Cantidad, 'Correcto' as Análisis
+ -- Vacaciones
+ SELECT at2.name INTO vCantWork
+ FROM postgresql.calendar_employee ce
+ JOIN postgresql.business b USING(business_id)
+ JOIN postgresql.profile pr ON pr.profile_id = b.client_id
+ JOIN postgresql.person p ON p.person_id = pr.person_id
+ JOIN vn.absenceType at2 ON at2.id = ce.calendar_state_id
+ JOIN vn.worker w ON w.id = p.id_trabajador
+ WHERE ce.date = util.VN_CURDATE()
+ AND at2.isAllowedToWork = FALSE
+ AND w.userFk = vUserFk
+ LIMIT 1;
- UNION ALL
-
- SELECT IF (LENGTH(vCantWork),CONCAT('Dia no laborable: ', vCantWork),'Dia laborable') as Item,
- '' as Cantidad, IF(LENGTH(vCantWork),'Error', 'Correcto') as Análisis
-
- UNION ALL
-
- SELECT 'El fichador no pertenece a tu departamento.' as Item, '' as Cantidad, IF(isEnabled, 'Correcto','Error') as Análisis
- ;
-
-END IF;
+ -- Contrato en vigor
+ SELECT IF(COUNT(*),vCantWork,'Sin contrato') INTO vCantWork
+ FROM postgresql.business b
+ JOIN postgresql.profile pr ON pr.profile_id = b.client_id
+ JOIN postgresql.person p ON p.person_id = pr.person_id
+ JOIN vn.worker w ON w.id = p.id_trabajador
+ WHERE w.userFk = vUserFk
+ AND b.date_start <= vDated
+ AND IFNULL(b.date_end,vDated) >= vDated;
+
+ -- Departamento si vTabletFk es 0 no hacemos comprobacion (Madrid y Vilassar)
+ IF vTabletFk <> '0' THEN
+ -- 1 Obtener el departamento del usuario
+ SELECT wtcu.departmentFk INTO vDepartmentFk
+ FROM vn.workerTimeControlUserInfo wtcu
+ WHERE wtcu.userFk = vUserFk;
+ -- 2 Comprobar si la tablet pertenece al departamento
+ SELECT COUNT(td.tabletFk) INTO isEnabled
+ FROM vn.tabletDepartment td
+ WHERE td.tabletFk = vTabletFk AND td.departmentFk = vDepartmentFk;
+
+ END IF;
+
+ IF vJornadas IS NOT NULL THEN
+
+ SELECT 'Jornadas' as Item, vJornadas as Cantidad, 'Correcto' AS Análisis
+ UNION ALL
+ SELECT 'Descansos 12 h' as Item, vDescansos12h as Cantidad, IF(vDescansos12h >= vJornadas, 'Correcto','Error: 1 por jornada') as Análisis
+ UNION ALL
+ SELECT 'Descansos 36 h' as Item, vDescansos36h as Cantidad, IF(vDescansos36h / 2 >= FLOOR(vJornadas/10), 'Correcto','Error: mínimo 2 cada 14 dias') as Análisis
+ UNION ALL
+ SELECT 'Dias con fichadas impares' as Item, vImpares as Cantidad, IF(vImpares = 0, 'Correcto','Error') as Análisis
+ UNION ALL
+ SELECT IF (LENGTH(vCantWork),CONCAT('Dia no laborable: ', vCantWork),'Dia laborable') as Item,
+ '' as Cantidad,
+ IF(LENGTH(vCantWork),'Error', 'Correcto') as Análisis
+ UNION ALL
+ SELECT 'El fichador no pertenece a tu departamento.' as Item, '' as Cantidad, IF(isEnabled, 'Correcto','Error') as Análisis;
+ ELSE
+ SELECT 'Jornadas' as Item, vJornadas as Cantidad, 'Correcto' AS Análisis
+ UNION ALL
+ SELECT 'Descansos 12 h' as Item, vDescansos12h as Cantidad, 'Correcto' as Análisis
+ UNION ALL
+ SELECT 'Descansos 36 h' as Item, vDescansos36h as Cantidad, 'Correcto' as Análisis
+ UNION ALL
+ SELECT 'Dias con fichadas impares' as Item, vImpares as Cantidad, 'Correcto' as Análisis
+ UNION ALL
+ SELECT IF (LENGTH(vCantWork),CONCAT('Dia no laborable: ', vCantWork),'Dia laborable') as Item,
+ '' as Cantidad, IF(LENGTH(vCantWork),'Error', 'Correcto') as Análisis
+ UNION ALL
+ SELECT 'El fichador no pertenece a tu departamento.' as Item, '' as Cantidad, IF(isEnabled, 'Correcto','Error') as Análisis;
+ 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_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerWeekTiming` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -90968,8 +75681,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerWeekTiming`(vUserFk INT, vDated DATE)
BEGIN
@@ -91065,6 +75776,8 @@ DELIMITER ;
/*!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 `worker_calculateCommission` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -91072,8 +75785,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_calculateCommission`(vYear INT, vQuarter INT)
BEGIN
@@ -91204,141 +75915,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `worker_calculateCommission__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_calculateCommission__`(vYear INT, vQuarter INT)
-BEGIN
-
- DECLARE vQuarterFirstDayLastYear DATE;
- DECLARE vQuarterFirstDay DATE;
-/*
- -- Jerarquia
- DROP TEMPORARY TABLE IF EXISTS rankingHierarchy;
- CREATE TEMPORARY TABLE rankingHierarchy
- SELECT COUNT(*) - 1 teamMembers, wb.bossFk
- FROM vn.worker ww
- JOIN vn.worker wb ON ww.id = wb.bossFk
- GROUP BY wb.bossFk;
- */
-
- -- Ranking ventas
- SELECT MIN(dated) INTO vQuarterFirstDay
- FROM `time` t
- WHERE QUARTER(dated) = vQuarter AND t.`year` = vYear;
-
- SET vQuarterFirstDayLastYear = DATE_ADD(vQuarterFirstDay, INTERVAL -1 YEAR);
-
- SET @position:= 0;
- DROP TEMPORARY TABLE IF EXISTS rankingSelling;
- CREATE TEMPORARY TABLE rankingSelling
- (PRIMARY KEY(userFk)) ENGINE = MEMORY
- SELECT userFk, @position:= @position + 1 position
- FROM (
- SELECT SUM(`v`.`importe`) AS `importe`,
- `u`.`name` AS `name`,
- `u`.`id` AS `userFk`
- FROM
- (`bs`.`vendedores` `v`
- JOIN `account`.`user` `u` ON (`u`.`id` = `v`.`Id_Trabajador`))
- WHERE
- `v`.`año` = vYear
- AND CEIL(`v`.`mes` / 3) = vQuarter
- AND `u`.`name` NOT IN ('ismaelalcolea' , 'ruben')
- GROUP BY `v`.`Id_Trabajador`
- ORDER BY SUM(`v`.`importe`) DESC
- LIMIT 10
- ) t;
-
- CALL rankingTeamByQuarter(vYear, vQuarter);
-
- -- comerciales que computan / total integrantes
- DROP TEMPORARY TABLE IF EXISTS teamNames;
- CREATE TEMPORARY TABLE teamNames
- (PRIMARY KEY(departmentFk)) ENGINE = MEMORY
- SELECT DISTINCT departmentFk, teamPeople
- FROM tmp.rankingTeam;
-
- -- Ranking por equipos
- DROP TEMPORARY TABLE IF EXISTS rankingTeam;
- CREATE TEMPORARY TABLE rankingTeam
- (PRIMARY KEY(departmentFk)) ENGINE = MEMORY
- SELECT DISTINCT departmentFk
- FROM teamNames
- LIMIT 3;
-
- -- Ranking por nuevos clientes
- SET @position:= 0;
- DROP TEMPORARY TABLE IF EXISTS rankingNewBorn;
- CREATE TEMPORARY TABLE rankingNewBorn
- (PRIMARY KEY(userFk)) ENGINE = MEMORY
- SELECT userFk, @position:= @position + 1 position
- FROM (
- SELECT SUM(amount) AS total,
- n.userFk
- FROM newBornSales n
- WHERE n.dated >= vQuarterFirstDay
- AND n.firstShipped >= vQuarterFirstDayLastYear
- GROUP BY userFk
- ORDER BY SUM(amount) DESC
- LIMIT 10
- ) t;
-
- -- Ventas
- DROP TEMPORARY TABLE IF EXISTS rankingSale;
- CREATE TEMPORARY TABLE rankingSale
- (PRIMARY KEY(workerFk)) ENGINE = MEMORY
- SELECT IF(SUM(v.importe) > 120000,
- SUM(IFNULL(v.comision,0)),0) as commission,
- SUM(v.importe) sales,
- v.Id_Trabajador workerFk
- FROM bs.vendedores v
- WHERE v.año = vYear AND CEIL(mes/3) = vQuarter
- GROUP BY v.Id_Trabajador;
-
- -- Sumatorio de ventas
- SELECT uBoss.`name` as team,
- u.`name`,
- r.commission,
- -- IF(rh.bossFk, 200 + (teamMembers * 30), 0) plusResponsibility,
- @plusRankingSellers := (11 - rs.position) * 40 plusRankingSellers,
- @plusRankingTeam := IF(rt.departmentFk, 800, 0) plusRankingTeam,
- @plusRankingNewBorn := (11 - rnb.position) * 40 plusRankingNewBorn,
- IFNULL(r.commission,0) + IFNULL(@plusRankingSellers,0) + @plusRankingTeam + IFNULL(@plusRankingNewBorn, 0) total,
- sales, rs.position, teamPeople,
- vYear year,
- vQuarter quarter
- FROM rankingSale r
- -- LEFT JOIN rankingHierarchy rh ON rh.bossFk = r.workerFk
- JOIN account.user u ON u.id = r.workerFk
- JOIN vn2008.jerarquia j ON j.worker_id = r.workerFk
- LEFT JOIN `account`.`user` uBoss ON uBoss.id = j.boss_id
- LEFT JOIN rankingSelling rs ON rs.userFk = r.workerFk
- LEFT JOIN workerDepartment wd ON wd.workerFk = r.workerFk
- LEFT JOIN rankingTeam rt ON rt.departmentFk = wd.departmentFk AND r.commission
- LEFT JOIN teamNames tn ON tn.departmentFk = wd.departmentFk
- LEFT JOIN vn.rankingNewBorn rnb ON rnb.userFk = r.workerFk;
-
- DROP TEMPORARY TABLE tmp.rankingTeam;
- DROP TEMPORARY TABLE
- rankingSelling,
- rankingTeam,
- teamNames,
- rankingNewBorn,
- rankingSale;
-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 DROP PROCEDURE IF EXISTS `worker_calculateSalaryRoleDelivery` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -91346,8 +75924,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_calculateSalaryRoleDelivery`(vWorkerFk INTEGER,vDateFrom DATE,vDateTo DATE)
BEGIN
@@ -91486,7 +76062,7 @@ BEGIN
JOIN agencyMode am ON am.id= r.agencyModeFk
JOIN agency a ON a.id = am.agencyFk
JOIN workerDistributionCategory wdc ON wdc.workerFk = vWorkerFk
- JOIN workerLabour wl ON r.created BETWEEN wl.started AND IFNULL(wl.ended, CURDATE()) AND wl.workerFk = wdc.workerFk AND a.workCenterFk = wl.workCenterFk
+ JOIN workerLabour wl ON r.created BETWEEN wl.started AND IFNULL(wl.ended, util.VN_CURDATE()) AND wl.workerFk = wdc.workerFk AND a.workCenterFk = wl.workCenterFk
JOIN department v ON v.id = departmentFk
JOIN routeConfig rc
WHERE r.m3>0 AND created BETWEEN vDateFrom AND vDateTo AND
@@ -91513,7 +76089,7 @@ BEGIN
ORDER BY dated DESC LIMIT 1
) sub
JOIN routeConfig rc
- JOIN workerLabour wl ON r.created BETWEEN wl.started AND IFNULL(wl.ended, CURDATE()) AND
+ JOIN workerLabour wl ON r.created BETWEEN wl.started AND IFNULL(wl.ended, util.VN_CURDATE()) AND
wl.workerFk = sub.workerFk
JOIN department v ON v.id = departmentFk
WHERE r.m3>0 AND
@@ -91597,254 +76173,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `worker_calculateSalaryRoleDelivery__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_calculateSalaryRoleDelivery__`(vWorkerFk INTEGER,vDateFrom DATE,vDateTo DATE)
-BEGIN
-/**
- * Calcula el salario de trabajadores para los departamentos de reparto, paletizado
- *
- * @param vDateFrom
- * @param vDateTo
- * @param vWorkerFk
- * @return tmp.workerSalaryRoleDelivery
- */
- DROP TEMPORARY TABLE IF EXISTS tmp.workerSalaryRoleDelivery;
-
- CREATE TEMPORARY TABLE tmp.workerSalaryRoleDelivery
- SELECT w.id workerFk,
- r.created dated,
- r.id,
- SUM(t.packages) packages,
- CAST(time_to_sec(TIMEDIFF( DATE_FORMAT(r.finished, '%H:%i:%s'),DATE_FORMAT(r.time, '%H:%i:%s'))) / (60 * 60) AS DECIMAL(10, 1)) hours ,
- r.kmEnd-r.kmStart km,
- r.m3 m3Delivery,
- CAST(r.m3/loadWorker AS DECIMAL(10,2)) m3Load,
- CAST(rc.m3Distribution*m3 AS DECIMAL(10,2)) amountDelivery ,
- CASE loadWorker
- WHEN 1 THEN CAST(r.m3/ loadWorker*rc.load1m3 AS DECIMAL(10,2))
- WHEN 2 THEN CAST(r.m3/ loadWorker*rc.load2m3 AS DECIMAL(10,2))
- WHEN 3 THEN CAST(r.m3/ loadWorker*rc.load3m3 AS DECIMAL(10,2))
- WHEN 4 THEN CAST(r.m3/ loadWorker*rc.load4m3 AS DECIMAL(10,2))
- WHEN 5 THEN CAST(r.m3/ loadWorker*rc.load5m3 AS DECIMAL(10,2))
- ELSE CAST(r.m3/ loadWorker*rc.load6m3 AS DECIMAL(10,2))
- END amountLoad,
- rc.kmRate*(r.kmEnd-r.kmStart) amountKm,
- w.code,
- CAST('' AS CHAR(45)) description,
- CAST( 0 AS DECIMAL(10,2)) extra
- FROM ticket t
- LEFT JOIN route r ON t.routeFk = r.id
- LEFT JOIN worker w ON w.id = r.workerFk
- LEFT JOIN routeConfig rc ON TRUE
- LEFT JOIN (SELECT rw.routeFk, COUNT(rw.workerFk) loadWorker
- FROM routeLoadWorker rw
- JOIN routeLoadWorker rw2 ON rw.routeFk = rw2.routeFk AND rw2.workerFk = vWorkerFk
- GROUP BY rw2.routeFk
- ) sub ON sub.routeFk=r.id
- WHERE r.created BETWEEN vDateFrom AND vDateTo AND w.id = vWorkerFk
- GROUP BY r.id;
-
- INSERT INTO tmp.workerSalaryRoleDelivery
- SELECT w.id workerFk,
- r.created dated,
- r.id,
- SUM(t.packages) packages,
- NULL hours,
- r.kmEnd-r.kmStart km,
- NULL m3Delivery,
- CAST(r.m3/loadWorker AS DECIMAL(10,2)) m3Load,
- NULL amountDelivery,
- CASE loadWorker
- WHEN 1 THEN CAST(r.m3/ loadWorker*rc.load1m3 AS DECIMAL(10,2))
- WHEN 2 THEN CAST(r.m3/ loadWorker*rc.load2m3 AS DECIMAL(10,2))
- WHEN 3 THEN CAST(r.m3/ loadWorker*rc.load3m3 AS DECIMAL(10,2))
- WHEN 4 THEN CAST(r.m3/ loadWorker*rc.load4m3 AS DECIMAL(10,2))
- WHEN 5 THEN CAST(r.m3/ loadWorker*rc.load5m3 AS DECIMAL(10,2))
- ELSE CAST(r.m3/ loadWorker*rc.load6m3 AS DECIMAL(10,2))
- END amountLoad,
- NULL amountKm,
- w.code,
- NULL description,
- NULL extra
- FROM (SELECT rw.routeFk, COUNT(rw.workerFk) loadWorker
- FROM routeLoadWorker rw
- JOIN routeLoadWorker rw2 ON rw.routeFk = rw2.routeFk AND rw2.workerFk = vWorkerFk
- GROUP BY rw2.routeFk) sub
- LEFT JOIN route r ON sub.routeFk = r.id
- LEFT JOIN ticket t ON t.routeFk = r.id
- LEFT JOIN worker w ON w.id = r.workerFk
- LEFT JOIN routeConfig rc ON TRUE
- WHERE r.created BETWEEN vDateFrom AND vDateTo AND w.id <> vWorkerFk
- GROUP BY r.id;
-
- INSERT INTO tmp.workerSalaryRoleDelivery
- SELECT workerFk,
- dated,
- NULL id,
- NULL packages,
- NULL hours,
- NULL km,
- NULL m3Delivery,
- NULL m3Load,
- NULL amountDelivery,
- NULL amountLoad,
- NULL amountKm,
- NULL workerCode,
- GROUP_CONCAT(ra.name) description,
- CAST(SUM(rc.price) AS DECIMAL(9,2)) extra
- FROM routeComplement rc
- JOIN routeAction ra ON rc.routeActionFk=ra.id
- WHERE dated BETWEEN vDateFrom AND vDateTo AND workerFk=vWorkerFk
- GROUP BY dated;
-
- CALL timeBusiness_calculateByWorker(vWorkerFk, vDateFrom, vDateTo);
-
- INSERT INTO tmp.workerSalaryRoleDelivery
- SELECT w.id workerFk,
- tb.dated,
- NULL id,
- NULL packages,
- NULL hours,
- NULL km,
- NULL m3Delivery,
- NULL m3Load,
- NULL amountDelivery,
- NULL amountLoad,
- NULL amountKm,
- NULL workerCode,
- tb.type COLLATE utf8_general_ci description,
- CASE
- WHEN tb.type = 'Vacaciones 1/2 día' OR tb.type = 'Permiso retribuido 1/2 día'
- THEN CAST(((12 * blp.importepactado) / (52 * tb.hoursWeek)) * 4 AS DECIMAL(10,2))
- WHEN tb.type = 'Vacaciones' OR tb.type = 'Baja enfermedad común' OR tb.type = 'Permiso retribuido' OR tb.type = 'Festivo'
- THEN CAST(((12 * blp.importepactado) / (52 * tb.hoursWeek)) * 8 AS DECIMAL(10,2))
- END extra
- FROM worker w
- JOIN tmp.timeBusinessCalculate tb ON tb.userFk = w.id
- JOIN postgresql.business_labour_payroll blp ON blp.business_id = tb.businessFk
- JOIN time tm ON tm.dated = tb.dated
- WHERE tb.dated BETWEEN vDateFrom AND vDateTo AND
- w.id = vWorkerFk AND
- tb.type IN ('Vacaciones 1/2 día', 'Vacaciones', 'Baja enfermedad común','Festivo','Permiso retribuido 1/2 día','Permiso retribuido')
- GROUP BY tb.dated;
-
- INSERT INTO tmp.workerSalaryRoleDelivery
- SELECT sub.workerFk workerFk,
- r.created dated,
- NULL id,
- NULL packages,
- NULL hours,
- NULL km,
- SUM(r.m3) m3Delivery,
- NULL m3Load,
- NULL amountDelivery,
- CAST( (SUM(r.m3)*sub.percentage /100) * rc.m3Management AS DECIMAL (10,2) ) amountLoad,
- NULL amountKm,
- NULL workerCode,
- 'Gestión de la distribución' description,
- NULL extra
- FROM route r
- JOIN agencyMode am ON am.id= r.agencyModeFk
- JOIN agency a ON a.id = am.agencyFk
- JOIN (SELECT percentage,workerFk ,dated
- FROM routeUserPercentage ru
- WHERE workerFk = vWorkerFk AND ru.dated <= vDateTo
- ORDER BY dated DESC LIMIT 1
- ) sub
- JOIN workerLabour wl ON r.created BETWEEN wl.started AND IFNULL(wl.ended, CURDATE()) AND wl.workerFk = sub.workerFk AND a.workCenterFk = wl.workCenterFk
- JOIN department v ON v.id = departmentFk
- JOIN routeConfig rc
- WHERE r.m3>0 AND created BETWEEN vDateFrom AND vDateTo AND
- am.name NOT LIKE "REC_%" AND
- v.name= "REPARTO"
- GROUP BY r.created;
-
- INSERT INTO tmp.workerSalaryRoleDelivery
- SELECT sub.workerFk workerFk,
- r.created dated,
- NULL id,
- NULL packages,
- NULL hours,
- NULL km,
- SUM(r.m3) m3Delivery,
- NULL m3Load,
- NULL amountDelivery,
- CAST( (SUM(r.m3)*sub.percentage /100) * rc.m3Palletization AS DECIMAL (10,2) ) amountLoad,
- NULL amountKm,
- NULL workerCode,
- 'Gestión de paletizado' description,
- NULL extra
- FROM route r
- JOIN agencyMode am ON am.id= r.agencyModeFk
- JOIN agency a ON a.id = am.agencyFk
- JOIN (SELECT percentage,workerFk ,dated
- FROM routeUserPercentage ru
- WHERE workerFk = vWorkerFk AND ru.dated <= vDateTo
- ORDER BY dated DESC LIMIT 1
- ) sub
- JOIN routeConfig rc
- JOIN workerLabour wl ON r.created BETWEEN wl.started AND IFNULL(wl.ended, CURDATE()) AND
- wl.workerFk = sub.workerFk
- JOIN department v ON v.id = departmentFk
- WHERE r.m3>0 AND
- r.created BETWEEN vDateFrom AND vDateTo AND
- am.name NOT LIKE "REC_%" AND
- v.name= "PALETIZADO"
- GROUP BY r.created;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.daysToRateHoliday;
- CREATE TEMPORARY TABLE tmp.daysToRateHoliday
- SELECT *
- FROM tmp.workerSalaryRoleDelivery tb
- WHERE (tb.description IN ('Festivo') OR dayofweek(tb.dated)=1) AND tb.extra = 0 ;
-
- INSERT INTO tmp.workerSalaryRoleDelivery (workerFk,dated,id,packages,hours,km,m3Delivery,m3Load,amountDelivery,amountLoad,AmountKm,code,description, extra)
- SELECT workerFk,
- dated,
- d.id,
- packages,
- hours,
- km,
- m3Delivery,
- m3Load,
- amountDelivery * r.rateHoliday,
- amountLoad * r.rateHoliday,
- AmountKm * r.rateHoliday,
- code,
- CONCAT('Plus festivo: ',description),
- extra
- FROM tmp.daysToRateHoliday d
- LEFT JOIN routeConfig r ON TRUE;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.daysToDelete;
- CREATE TEMPORARY TABLE tmp.daysToDelete
- SELECT dated
- FROM tmp.workerSalaryRoleDelivery d
- WHERE d.description IN ('Baja enfermedad común');
-
- DELETE d
- FROM tmp.workerSalaryRoleDelivery d
- JOIN tmp.daysToDelete dd on dd.dated = d.dated
- WHERE d.description NOT IN ('Baja enfermedad común');
-
- DROP TEMPORARY TABLE tmp.daysToRateHoliday;
- DROP TEMPORARY TABLE tmp.daysToDelete;
- DROP TEMPORARY TABLE tmp.timeBusinessCalculate;
-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 DROP PROCEDURE IF EXISTS `worker_getFromHasMistake` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -91852,8 +76182,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_getFromHasMistake`(vDepartmentFk INT)
BEGIN
@@ -91877,6 +76205,8 @@ DELIMITER ;
/*!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 `worker_getHierarchy` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -91884,8 +76214,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_getHierarchy`(vBoss INT)
BEGIN
@@ -91933,153 +76261,15 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `worker_getHierarch__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_getHierarch__`(vBoss INT)
-BEGIN
--- eliminar no se usa
- -- usar worker_getHierarchy
- DECLARE EXIT HANDLER FOR 1062 BEGIN
- CALL util.throw('INFINITE_LOOP');
- END;
-
- DROP TEMPORARY TABLE IF EXISTS workerHierarch;
- CREATE TEMPORARY TABLE workerHierarch
- (PRIMARY KEY (workerFk))
- ENGINE = MEMORY
- SELECT vBoss AS workerFk;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.workerHierarchList;
- CREATE TEMPORARY TABLE tmp.workerHierarchList
- (PRIMARY KEY (workerFk))
- ENGINE = MEMORY
- SELECT vBoss AS workerFk, 0 AS isChecked;
-
-
- WHILE (SELECT COUNT(*) FROM tmp.workerHierarchList WHERE NOT isChecked) > 0 DO
-
- INSERT INTO tmp.workerHierarchList
- SELECT w.id, 0
- FROM worker w
- JOIN workerHierarch wh ON wh.workerFk = w.bossFk;
-
- UPDATE tmp.workerHierarchList whl
- JOIN workerHierarch wh ON wh.workerFk = whl.workerFk
- SET whl.isChecked = 1;
-
- TRUNCATE workerHierarch;
-
- INSERT INTO workerHierarch
- SELECT workerFk
- FROM tmp.workerHierarchList
- WHERE NOT isChecked;
-
- END WHILE;
-
- DROP TEMPORARY TABLE IF EXISTS workerHierarch;
-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 DROP PROCEDURE IF EXISTS `worker_getProductionErrors__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_getProductionErrors__`(vAction VARCHAR(25), vDepartment VARCHAR(25), vStateCode VARCHAR(25) CHARSET utf8, vDatedFrom DATETIME, vDatedTo DATETIME)
-BEGIN
-
- DROP TEMPORARY TABLE IF EXISTS tmp.total;
-
- IF (vDepartment = 'Encajadores')
- THEN
- CREATE TEMPORARY TABLE tmp.total
- ENGINE = MEMORY
- SELECT e.workerFk, Count(DISTINCT t.id) AS ticketCount
- FROM expedition e
- JOIN ticket t ON e.ticketFk = t.id
- WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo
- GROUP BY e.workerFk;
- ELSE
- CREATE TEMPORARY TABLE tmp.total
- ENGINE = MEMORY
- SELECT st.workerFk, Count(DISTINCT t.id) AS ticketCount
- FROM state ss
- JOIN vn.saleTracking st ON st.stateFk = ss.id
- JOIN vn.sale s ON s.id = st.saleFk
- JOIN ticket t ON s.ticketFk = t.id
- WHERE (t.shipped BETWEEN vDatedFrom AND vDatedTo) AND ss.code = vStateCode
- GROUP BY st.workerFk;
- END IF;
-
- SELECT sub1.id, sub1.firstName, sub1.lastName, CAST(sub1.totalTickets AS DECIMAL(10,0)) AS totalTickets, CAST(IFNULL(sub1.errors,0) + IFNULL(sub2.errors,0) AS DECIMAL(10,0)) AS errors, (IFNULL(sub1.errors,0) + IFNULL(sub2.errors,0))/sub1.totalTickets AS ratio, IF(vDepartment = 'Revisadores', NULL, volume) AS volume
- FROM(
- SELECT w.id, w.code, w.firstName, w.lastName, t.ticketCount AS totalTickets, sub.errors, sub2.volume
- FROM tmp.total AS t
- JOIN worker w ON w.id = t.workerFk
- LEFT JOIN (
- SELECT COUNT(c.ticketFk) AS errors, cd.workerFk
- FROM claimDevelopment cd
- JOIN claim c ON cd.claimFk = c.id
- JOIN ticket t ON c.ticketFk = t.id
- JOIN claimResponsible cr ON cd.claimResponsibleFk = cr.id
- WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo AND cr.description = vDepartment
- GROUP BY cd.workerFk
- )sub ON t.workerFk = sub.workerFk
- LEFT JOIN ( -- Añadir volume
- SELECT SUM(w.volume) AS volume, w.workerFk
- FROM bs.workerProductivity w
- INNER JOIN vn.`role` r ON r.id=w.roleFk
- WHERE IF(vDepartment = 'Encajadores', r.name='packager', r.name='itemPicker') AND w.dated BETWEEN vDatedFrom AND vDatedTo
- GROUP BY w.workerFk) sub2 ON w.id = sub2.workerFk
- GROUP BY w.code) sub1
- LEFT JOIN(
- SELECT sub1.workerFk, COUNT(id) AS errors
- FROM (
- SELECT st.workerFk, t.id
- FROM vn.saleMistake sm
- JOIN vn.saleTracking st ON sm.saleFk = st.saleFk
- JOIN state ss ON ss.id = st.stateFk
- JOIN vncontrol.accion a ON a.accion_id = st.actionFk
- JOIN vn.sale s ON s.id = sm.saleFk
- JOIN vn.ticket t on t.id = s.ticketFk
- WHERE (t.shipped BETWEEN vDatedFrom AND vDatedTo) AND a.accion = vAction AND ss.code = vStateCode
- GROUP BY s.ticketFk
- ) sub1
- GROUP BY sub1.workerFk) sub2 ON sub2.workerFk = sub1.id;
-
- DROP TEMPORARY TABLE tmp.total;
-
-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 DROP PROCEDURE IF EXISTS `worker_getSector` */;
/*!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_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_getSector`()
BEGIN
@@ -92091,7 +76281,7 @@ BEGIN
SELECT s.id,s.description,s.warehouseFk
FROM sector s
JOIN worker w ON w.sectorFk = s.id
- WHERE w.id = account.userGetId();
+ WHERE w.id = account.myUser_getId();
END ;;
DELIMITER ;
@@ -92099,15 +76289,15 @@ DELIMITER ;
/*!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 `worker_updateSector` */;
/*!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_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_updateSector`(vSectorFk INT)
BEGIN
@@ -92119,7 +76309,7 @@ BEGIN
*/
UPDATE worker
SET sectorFk = vSectorFk
- WHERE id = account.userGetId();
+ WHERE id = account.myUser_getId();
END ;;
@@ -92128,6 +76318,8 @@ DELIMITER ;
/*!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 `workingHours` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -92135,8 +76327,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workingHours`(username varchar(255), logon boolean)
BEGIN
@@ -92157,6 +76347,8 @@ DELIMITER ;
/*!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 `workingHoursTimeIn` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -92164,19 +76356,19 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workingHoursTimeIn`(vUserId INT(11))
BEGIN
INSERT INTO vn.workingHours (timeIn, userId)
- VALUES (NOW(),vUserId);
+ VALUES (util.VN_NOW(),vUserId);
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 `workingHoursTimeOut` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -92184,21 +76376,21 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workingHoursTimeOut`(vUserId INT(11))
BEGIN
UPDATE vn.workingHours
- SET timeOut = NOW()
+ SET timeOut = util.VN_NOW()
WHERE userId = vUserId
- AND DATE(timeIn) = CURDATE();
+ AND DATE(timeIn) = util.VN_CURDATE();
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 `wrongEqualizatedClient` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -92206,8 +76398,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wrongEqualizatedClient`()
BEGIN
@@ -92239,46 +76429,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `xdiarioNextId__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `xdiarioNextId__`()
-BEGIN
-/**
- * @deprecated Use ledger_next
- */
- DECLARE vNewAsien INT;
- DECLARE EXIT HANDLER FOR SQLEXCEPTION
- BEGIN
- ROLLBACK;
- RESIGNAL;
- END;
-
- START TRANSACTION;
-
- SELECT bookFk + 1 INTO vNewAsien FROM config FOR UPDATE;
- UPDATE config SET bookFk = vNewAsien;
- COMMIT;
-
- SELECT vNewAsien;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.xdiarioNextId;
- CREATE TEMPORARY TABLE tmp.xdiarioNextId AS
- SELECT vNewAsien ;
-
-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 DROP PROCEDURE IF EXISTS `zoneClosure_recalc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -92286,8 +76438,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneClosure_recalc`()
proc: BEGIN
@@ -92296,7 +76446,7 @@ proc: BEGIN
*/
DECLARE vScope INT;
DECLARE vCounter INT DEFAULT 0;
- DECLARE vShipped DATE DEFAULT CURDATE();
+ DECLARE vShipped DATE DEFAULT util.VN_CURDATE();
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
BEGIN
@@ -92339,72 +76489,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `zoneClosure_recalc_beta__` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneClosure_recalc_beta__`()
-proc: BEGIN
-/**
- * Recalculates the delivery time (hour) for every zone in days + scope in future
- */
- DECLARE vScope INT;
- DECLARE vCounter INT DEFAULT 0;
- DECLARE vShipped DATE DEFAULT CURDATE();
-
- DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
- BEGIN
- DO RELEASE_LOCK('vn.zoneClosure_recalc');
- RESIGNAL;
- END;
-
- IF NOT GET_LOCK('vn.zoneClosure_recalc', 0) THEN
- LEAVE proc;
- END IF;
-
- SELECT scope INTO vScope
- FROM zoneConfig;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.zone;
- CREATE TEMPORARY TABLE tmp.zone
- (INDEX (id))
- ENGINE = MEMORY
- SELECT id FROM zone;
-
- WHILE vCounter <= vScope DO
-
- DELETE FROM zoneClosure
- WHERE dated = vShipped;
-
- SELECT vShipped;
-
- CALL zone_getOptionsForShipment_beta(vShipped, TRUE);
-
- REPLACE zoneClosure(zoneFk, dated, `hour`)
- SELECT zoneFk, vShipped, `hour`
- FROM tmp.zoneOption;
-
- SET vCounter = vCounter + 1;
- SET vShipped = TIMESTAMPADD(DAY, 1, vShipped);
- END WHILE;
-
- SELECT *
- FROM tmp.zoneOption;
-
- -- DROP TEMPORARY TABLE tmp.zone;
- DO RELEASE_LOCK('vn.zoneClosure_recalc');
-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 DROP PROCEDURE IF EXISTS `zoneGeo_calcTree` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -92412,8 +76498,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_calcTree`()
BEGIN
@@ -92449,6 +76533,8 @@ DELIMITER ;
/*!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 `zoneGeo_calcTreeRec` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -92456,8 +76542,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_calcTreeRec`(
vSelf INT,
@@ -92531,6 +76615,8 @@ DELIMITER ;
/*!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 `zoneGeo_checkName` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -92538,8 +76624,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_checkName`(vName VARCHAR(255))
BEGIN
@@ -92553,6 +76637,8 @@ DELIMITER ;
/*!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 `zoneGeo_delete` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -92560,8 +76646,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_delete`(vSelf INT)
BEGIN
@@ -92579,6 +76663,8 @@ DELIMITER ;
/*!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 `zoneGeo_doCalc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -92586,8 +76672,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_doCalc`()
proc: BEGIN
@@ -92621,6 +76705,8 @@ DELIMITER ;
/*!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 `zoneGeo_setParent` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -92628,8 +76714,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_setParent`(vSelf INT, vParentFk INT)
BEGIN
@@ -92650,6 +76734,8 @@ DELIMITER ;
/*!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 `zoneGeo_throwNotEditable` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -92657,8 +76743,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_throwNotEditable`()
BEGIN
@@ -92670,69 +76754,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `zone_doCalcInitialize` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_doCalcInitialize`()
-proc: BEGIN
-/**
- * Initialize ticket
- */
- DECLARE vDone BOOL;
- DECLARE vLanded DATE;
- DECLARE vZoneFk INT;
-
- DECLARE cCur CURSOR FOR
- SELECT t.landed, t.zoneFk
- FROM ticket t
- WHERE shipped >= '2020-03-01'
- AND zoneFk IS NOT NULL and zonePrice IS NULL
- GROUP BY zoneFk, shipped;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND
- SET vDone = TRUE;
-
- OPEN cCur;
-
- myLoop: LOOP
- SET vDone = FALSE;
- FETCH cCur INTO vLanded, vZoneFk;
-
- IF vDone THEN
- LEAVE myLoop;
- END IF;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.zone;
- CREATE TEMPORARY TABLE tmp.zone
- (INDEX (id))
- ENGINE = MEMORY
- SELECT vZoneFk id;
-
- CALL zone_getOptionsForLanding(vLanded, TRUE);
-
- UPDATE ticket t
- LEFT JOIN tmp.zoneOption zo ON TRUE
- SET zonePrice = zo.price, zoneBonus = zo.bonus
- WHERE t.zoneFk = vZoneFk AND t.landed = vLanded
- AND t.zonePrice IS NULL;
-
- END LOOP;
-
- CLOSE cCur;
-
-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 DROP PROCEDURE IF EXISTS `zone_ETD_byTime` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -92740,8 +76763,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_ETD_byTime`()
BEGIN
@@ -92767,6 +76788,40 @@ DELIMITER ;
/*!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 `zone_excludeFromGeo` */;
+/*!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=`root`@`localhost` PROCEDURE `zone_excludeFromGeo`(vZoneGeo INT)
+BEGIN
+/**
+ * Excluye zonas a partir un geoFk.
+ *
+ * @table tmp.zoneOption(zoneFk, hour, travelingDays, price, bonus, landed, shipped) The computed options
+ * @param vZoneGeo The zone geo
+ * @return tmp.zoneOption The computed options
+ */
+ DELETE t FROM tmp.zoneOption t
+ JOIN zoneExclusion e ON e.zoneFk = t.zoneFk AND e.`dated` = t.landed
+ LEFT JOIN zoneExclusionGeo eg ON eg.zoneExclusionFk = e.id
+ JOIN zoneGeo zg1 ON zg1.id = eg.geoFk
+ JOIN zoneGeo zg2 ON zg2.id = vZoneGeo
+ WHERE zg2.`path` LIKE CONCAT(zg1.`path`,'%');
+
+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 `zone_getAgency` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -92774,8 +76829,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getAgency`(vAddress INT, vLanded DATE)
BEGIN
@@ -92815,6 +76868,8 @@ DELIMITER ;
/*!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 `zone_getAvailable` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -92822,8 +76877,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getAvailable`(vAddress INT, vLanded DATE)
BEGIN
@@ -92841,6 +76894,8 @@ DELIMITER ;
/*!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 `zone_getClosed` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -92848,8 +76903,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getClosed`()
proc:BEGIN
@@ -92879,7 +76932,7 @@ proc:BEGIN
JOIN vn.productionConfig pc
WHERE a.isOwn
AND pc.isZoneClosedByExpeditionActivated
- AND e.created >= CURDATE()
+ AND e.created >= util.VN_CURDATE()
GROUP BY t.zoneFk, t.warehouseFk
HAVING numTickets >= minTicketsToCloseZone) sub;
END ;;
@@ -92888,6 +76941,8 @@ DELIMITER ;
/*!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 `zone_getCollisions` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -92895,8 +76950,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getCollisions`()
BEGIN
@@ -92921,7 +76974,7 @@ BEGIN
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
WHERE dm.code IN ('AGENCY','DELIVERY');
- CALL zone_getOptionsForShipment(CURDATE(),FALSE);
+ CALL zone_getOptionsForShipment(util.VN_CURDATE(),FALSE);
DROP TEMPORARY TABLE IF EXISTS tmp.zoneNodes;
CREATE TEMPORARY TABLE tmp.zoneNodes (
@@ -92989,7 +77042,7 @@ BEGIN
INSERT INTO mail (receiver,replyTo,subject,body)
SELECT 'pepe@verdnatura.es' receiver,
'noreply@verdnatura.es' replyTo,
- CONCAT('Colisiones en zonas ', CURDATE()) subject,
+ CONCAT('Colisiones en zonas ', util.VN_CURDATE()) subject,
CONCAT(vTableCollisions,
GROUP_CONCAT(sub.td SEPARATOR ''),
'') body
@@ -93026,6 +77079,8 @@ DELIMITER ;
/*!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 `zone_getEvents` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -93033,8 +77088,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getEvents`(
vGeoFk INT,
@@ -93090,7 +77143,11 @@ BEGIN
SELECT e.zoneFk, e.dated
FROM tZone t
- JOIN zoneExclusion e ON e.zoneFk = t.id;
+ JOIN zoneExclusion e ON e.zoneFk = t.id
+ LEFT JOIN zoneExclusionGeo eg ON eg.zoneExclusionFk = e.id
+ JOIN zoneGeo zg1 ON zg1.id = eg.geoFk
+ JOIN zoneGeo zg2 ON zg2.id = vGeoFk
+ WHERE eg.zoneExclusionFk IS NULL OR zg2.`path` LIKE CONCAT(zg1.`path`,'%');
DROP TEMPORARY TABLE tZone;
END ;;
@@ -93099,6 +77156,8 @@ DELIMITER ;
/*!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 `zone_getFromGeo` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -93106,8 +77165,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getFromGeo`(vGeoFk INT)
BEGIN
@@ -93156,6 +77213,7 @@ BEGIN
FROM tNodes n
JOIN zoneIncluded i ON i.geoFk = n.id
ORDER BY zoneFk, n.`level`
+ LIMIT 10000000000000000000
) t
GROUP BY id HAVING isIncluded
) t;
@@ -93167,6 +77225,8 @@ DELIMITER ;
/*!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 `zone_getLanded` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -93174,8 +77234,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getLanded`(vShipped DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT, vShowExpiredZones BOOLEAN)
BEGIN
@@ -93189,10 +77247,13 @@ BEGIN
* @param vWarehouseFk vWarehouseFk
* @table tmp.zoneGetLanded Datos de recepción
*/
- CALL vn.zone_getFromGeo(address_getGeo(vAddressFk));
+ DECLARE vZoneGeo INT;
+ SELECT address_getGeo(vAddressFk) INTO vZoneGeo;
+
+ CALL vn.zone_getFromGeo(vZoneGeo);
CALL vn.zone_getOptionsForShipment(vShipped, vShowExpiredZones);
-
+ CALL vn.zone_excludeFromGeo(vZoneGeo);
CALL vn.zone_getClosed();
DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetLanded;
@@ -93207,7 +77268,7 @@ BEGIN
LEFT JOIN tmp.closedZones cz
ON cz.warehouseFk = zw.warehouseFk
AND cz.zoneFk = zw.zoneFk
- AND zo.shipped = CURDATE()
+ AND zo.shipped = util.VN_CURDATE()
WHERE z.agencyModeFk = vAgencyModeFk
AND zw.warehouseFk = vWarehouseFk
AND (ISNULL(cz.zoneFk) OR vShowExpiredZones);
@@ -93222,6 +77283,8 @@ DELIMITER ;
/*!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 `zone_getLeaves` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -93229,8 +77292,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getLeaves`(vSelf INT, vParentFk INT, vSearch VARCHAR(255))
BEGIN
@@ -93331,6 +77392,8 @@ DELIMITER ;
/*!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 `zone_getLeaves2` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -93338,8 +77401,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getLeaves2`(vSelf INT, vParentFk INT, vSearch VARCHAR(255))
BEGIN
@@ -93448,110 +77509,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `zone_getLeaves___` */;
-/*!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 ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getLeaves___`(
- vSelf INT,
- vParentFk INT,
- vSearch VARCHAR(255)
-)
-BEGIN
- DECLARE vIsNumber BOOL;
- DECLARE vIsSearch BOOL DEFAULT vSearch IS NOT NULL AND vSearch != '';
-
- DROP TEMPORARY TABLE IF EXISTS tNodes;
- CREATE TEMPORARY TABLE tNodes
- (UNIQUE (id))
- ENGINE = MEMORY
- SELECT id FROM zoneGeo LIMIT 0;
-
- IF vIsSearch THEN
- SET vIsNumber = vSearch REGEXP '^[0-9]+$';
-
- INSERT INTO tNodes
- SELECT id FROM zoneGeo
- WHERE (vIsNumber AND `name` = vSearch)
- OR (!vIsNumber AND `name` LIKE CONCAT('%', vSearch, '%'))
- LIMIT 1000;
- ELSEIF vParentFk IS NULL THEN
- INSERT INTO tNodes
- SELECT geoFk FROM zoneIncluded
- WHERE zoneFk = vSelf;
- END IF;
-
- IF vParentFk IS NULL THEN
- DROP TEMPORARY TABLE IF EXISTS tChilds;
- CREATE TEMPORARY TABLE tChilds
- ENGINE = MEMORY
- SELECT id FROM tNodes;
-
- DROP TEMPORARY TABLE IF EXISTS tParents;
- CREATE TEMPORARY TABLE tParents
- ENGINE = MEMORY
- SELECT id FROM zoneGeo LIMIT 0;
-
- myLoop: LOOP
- DELETE FROM tParents;
- INSERT INTO tParents
- SELECT parentFk id
- FROM zoneGeo g
- JOIN tChilds c ON c.id = g.id
- WHERE g.parentFk IS NOT NULL;
-
- INSERT IGNORE INTO tNodes
- SELECT id FROM tParents;
-
- IF ROW_COUNT() = 0 THEN
- LEAVE myLoop;
- END IF;
-
- DELETE FROM tChilds;
- INSERT INTO tChilds
- SELECT id FROM tParents;
- END LOOP;
-
- DROP TEMPORARY TABLE
- tChilds,
- tParents;
- END IF;
-
- IF !vIsSearch THEN
- INSERT IGNORE INTO tNodes
- SELECT id FROM zoneGeo
- WHERE parentFk <=> vParentFk;
- END IF;
-
-
- INSERT IGNORE INTO zoneNodes(geoFk, name, parentFk, sons, isChecked, zoneFk)
- SELECT g.id,
- g.`name`,
- g.parentFk,
- g.sons,
- NOT g.sons OR type = 'country',
- vSelf
- FROM zoneGeo g
- JOIN tNodes n ON n.id = g.id
- LEFT JOIN zoneIncluded i
- ON i.geoFk = g.id AND i.zoneFk = vSelf
- WHERE (i.isIncluded = TRUE
- OR (i.isIncluded IS NULL AND vParentFk IS NOT NULL))
- ;
-
- DROP TEMPORARY TABLE tNodes;
-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 DROP PROCEDURE IF EXISTS `zone_getOptionsForLanding` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -93559,8 +77518,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getOptionsForLanding`(vLanded DATE, vShowExpiredZones BOOLEAN)
BEGIN
@@ -93580,6 +77537,7 @@ BEGIN
travelingDays,
price,
bonus,
+ vLanded landed,
TIMESTAMPADD(DAY, -travelingDays, vLanded) shipped
FROM (
SELECT t.id zoneFk,
@@ -93608,17 +77566,19 @@ BEGIN
THEN 2
ELSE 3
END
+ LIMIT 10000000000000000000
) t
- GROUP BY zoneFk;
-
+ GROUP BY zoneFk;
+
DELETE t FROM tmp.zoneOption t
- JOIN zoneExclusion e
- ON e.zoneFk = t.zoneFk AND e.`dated` = vLanded;
-
+ JOIN zoneExclusion e ON e.zoneFk = t.zoneFk AND e.`dated` = t.landed
+ LEFT JOIN zoneExclusionGeo eg ON eg.zoneExclusionFk = e.id
+ WHERE eg.zoneExclusionFk IS NULL;
+
IF NOT vShowExpiredZones THEN
DELETE FROM tmp.zoneOption
- WHERE shipped < CURDATE()
- OR (shipped = CURDATE() AND CURTIME() > `hour`);
+ WHERE shipped < util.VN_CURDATE()
+ OR (shipped = util.VN_CURDATE() AND util.VN_CURTIME() > `hour`);
END IF;
END ;;
DELIMITER ;
@@ -93626,6 +77586,8 @@ DELIMITER ;
/*!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 `zone_getOptionsForShipment` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -93633,8 +77595,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getOptionsForShipment`(vShipped DATE, vShowExpiredZones BOOLEAN)
BEGIN
@@ -93645,7 +77605,7 @@ BEGIN
* @param vShipped The shipping date
* @return tmp.zoneOption(zoneFk, hour, travelingDays, price, bonus, specificity) The computed options
*/
- DECLARE vHour TIME DEFAULT TIME(NOW());
+ DECLARE vHour TIME DEFAULT TIME(util.VN_NOW());
DROP TEMPORARY TABLE IF EXISTS tLandings;
CREATE TEMPORARY TABLE tLandings
@@ -93692,19 +77652,21 @@ BEGIN
THEN 2
ELSE 3
END
+ LIMIT 10000000000000000000
) t
GROUP BY zoneFk;
DROP TEMPORARY TABLE tLandings;
DELETE t FROM tmp.zoneOption t
- JOIN zoneExclusion e
- ON e.zoneFk = t.zoneFk AND e.`dated` = t.landed;
+ JOIN zoneExclusion e ON e.zoneFk = t.zoneFk AND e.`dated` = t.landed
+ LEFT JOIN zoneExclusionGeo eg ON eg.zoneExclusionFk = e.id
+ WHERE eg.zoneExclusionFk IS NULL;
IF NOT vShowExpiredZones THEN
DELETE FROM tmp.zoneOption
- WHERE vShipped < CURDATE()
- OR (vShipped = CURDATE() AND CURTIME() > `hour`);
+ WHERE vShipped < util.VN_CURDATE()
+ OR (vShipped = util.VN_CURDATE() AND util.VN_CURTIME() > `hour`);
END IF;
END ;;
DELIMITER ;
@@ -93712,6 +77674,8 @@ DELIMITER ;
/*!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 `zone_getShipped` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -93719,8 +77683,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getShipped`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT, vShowExpiredZones BOOLEAN)
BEGIN
@@ -93733,8 +77695,13 @@ BEGIN
* @param vAgencyModeFk Id de la agencia
* @return tmp.zoneGetShipped
*/
- CALL vn.zone_getFromGeo(address_getGeo(vAddressFk));
+ DECLARE vZoneGeo INT;
+
+ SELECT address_getGeo(vAddressFk) INTO vZoneGeo;
+
+ CALL vn.zone_getFromGeo(vZoneGeo);
CALL vn.zone_getOptionsForLanding(vLanded, vShowExpiredZones);
+ CALL vn.zone_excludeFromGeo(vZoneGeo);
CALL vn.zone_getClosed();
DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetShipped;
@@ -93754,10 +77721,11 @@ BEGIN
LEFT JOIN tmp.closedZones cz
ON cz.warehouseFk = zw.warehouseFk
AND cz.zoneFk = zw.zoneFk
- AND zo.shipped = CURDATE()
+ AND zo.shipped = util.VN_CURDATE()
WHERE z.agencyModeFk = vAgencyModeFk
AND (ISNULL(cz.zoneFk) OR vShowExpiredZones)
- ORDER BY shipped) t
+ ORDER BY shipped
+ LIMIT 10000000000000000000) t
GROUP BY warehouseFk;
DROP TEMPORARY TABLE
@@ -93770,6 +77738,8 @@ DELIMITER ;
/*!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 `zone_getState` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -93777,8 +77747,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getState`(vDated DATE)
BEGIN
@@ -93803,7 +77771,7 @@ BEGIN
SELECT zo.zoneFk,
zo.`hour`etd,
- (zo.`hour` <= TIME(now())) isLate,
+ (zo.`hour` <= TIME(util.VN_NOW())) isLate,
!ISNULL(cz.zoneFk) isFull,
zw.warehouseFk,
zo.landed
@@ -93825,6 +77793,8 @@ DELIMITER ;
/*!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 `zone_getWarehouse` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -93832,8 +77802,6 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getWarehouse`(vAddress INT, vLanded DATE, vWarehouse INT)
BEGIN
@@ -93875,15 +77843,15 @@ DELIMITER ;
/*!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 `zone_upcomingDeliveries` */;
/*!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_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_upcomingDeliveries`()
BEGIN
@@ -93891,7 +77859,7 @@ BEGIN
DECLARE vForwardDays INT;
SELECT forwardDays INTO vForwardDays FROM zoneConfig;
- CALL util.time_createTable(CURDATE(), DATE_ADD(CURDATE(), INTERVAL vForwardDays DAY));
+ CALL util.time_createTable(util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL vForwardDays DAY));
DROP TEMPORARY TABLE IF EXISTS tLandings;
CREATE TEMPORARY TABLE tLandings
@@ -93903,7 +77871,7 @@ BEGIN
ti.dated shipped
FROM zone z
JOIN zoneEvent e ON e.zoneFk = z.id
- JOIN tmp.time ti ON ti.dated BETWEEN curdate() AND TIMESTAMPADD(DAY, vForwardDays, curdate());
+ JOIN tmp.time ti ON ti.dated BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY, vForwardDays, util.VN_CURDATE());
DROP TEMPORARY TABLE IF EXISTS tmp.zoneOption;
CREATE TEMPORARY TABLE tmp.zoneOption
@@ -93938,12 +77906,14 @@ BEGIN
THEN 2
ELSE 3
END
+ LIMIT 10000000000000000000
) t
GROUP BY zoneFk, landed;
DELETE t FROM tmp.zoneOption t
- JOIN zoneExclusion e
- ON e.zoneFk = t.zoneFk AND e.`dated` = t.landed;
+ JOIN zoneExclusion e ON e.zoneFk = t.zoneFk AND e.`dated` = t.landed
+ LEFT JOIN zoneExclusionGeo eg ON eg.zoneExclusionFk = e.id
+ WHERE eg.zoneExclusionFk IS NULL;
SELECT MAX(zo.`hour`) `hour`, zg.`name`, zo.shipped, zo.zoneFk
FROM tmp.zoneOption zo
@@ -94187,6 +78157,8 @@ DELIMITER ;
--
-- Dumping routines for database 'vncontrol'
--
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `clean` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -94194,12 +78166,10 @@ DELIMITER ;
/*!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 ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `clean`()
BEGIN
- DECLARE vDate DATETIME DEFAULT TIMESTAMPADD(MONTH, -2, CURDATE());
+ DECLARE vDate DATETIME DEFAULT TIMESTAMPADD(MONTH, -2, util.VN_CURDATE());
DELETE i FROM inter i JOIN vn.ticket t ON i.Id_Ticket = t.id
WHERE t.shipped <= vDate;
END ;;
@@ -94286,7 +78256,7 @@ USE `account`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `myUser` AS select `u`.`id` AS `id`,`u`.`name` AS `name`,`u`.`active` AS `active`,`u`.`email` AS `email`,`u`.`nickname` AS `nickname`,`u`.`lang` AS `lang`,`u`.`role` AS `role`,`u`.`recoverPass` AS `recoverPass` from `user` `u` where (`u`.`name` = `myUserGetName`()) */
+/*!50001 VIEW `myUser` AS select `u`.`id` AS `id`,`u`.`name` AS `name`,`u`.`active` AS `active`,`u`.`email` AS `email`,`u`.`nickname` AS `nickname`,`u`.`lang` AS `lang`,`u`.`role` AS `role`,`u`.`recoverPass` AS `recoverPass` from `user` `u` where (`u`.`name` = `myUser_getName`()) */
/*!50002 WITH CASCADED CHECK OPTION */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
@@ -94312,7 +78282,7 @@ USE `bs`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `bajasLaborales` AS select `p`.`firstname` AS `firstname`,`p`.`name` AS `name`,`b`.`business_id` AS `business_id`,max(`ce`.`date`) AS `lastDate`,max(ifnull(`b`.`date_end`,curdate())) AS `endContract`,`cs`.`type` AS `type`,cast(count(0) as decimal(10,0)) AS `dias`,`w`.`userFk` AS `userFk` from (((((`postgresql`.`calendar_employee` `ce` join `postgresql`.`business` `b` on((`b`.`business_id` = `ce`.`business_id`))) join `postgresql`.`profile` `pr` on((`pr`.`profile_id` = `b`.`client_id`))) join `postgresql`.`person` `p` on((`p`.`person_id` = `pr`.`person_id`))) join `postgresql`.`calendar_state` `cs` on((`cs`.`calendar_state_id` = `ce`.`calendar_state_id`))) join `vn`.`worker` `w` on((`w`.`id` = `p`.`id_trabajador`))) where ((`ce`.`date` >= (curdate() + interval -(1) year)) and (`cs`.`type` not in ('Vacaciones','Vacaciones 1/2 día','Compensar','Festivo'))) group by `p`.`firstname`,`p`.`name`,`cs`.`type` having (`endContract` >= curdate()) */;
+/*!50001 VIEW `bajasLaborales` AS select `p`.`firstname` AS `firstname`,`p`.`name` AS `name`,`b`.`business_id` AS `business_id`,max(`ce`.`date`) AS `lastDate`,max(ifnull(`b`.`date_end`,util.VN_CURDATE())) AS `endContract`,`at`.`name` AS `type`,cast(count(0) as decimal(10,0)) AS `dias`,`w`.`userFk` AS `userFk` from (((((`postgresql`.`calendar_employee` `ce` join `postgresql`.`business` `b` on((`b`.`business_id` = `ce`.`business_id`))) join `postgresql`.`profile` `pr` on((`pr`.`profile_id` = `b`.`client_id`))) join `postgresql`.`person` `p` on((`p`.`person_id` = `pr`.`person_id`))) join `vn`.`absenceType` `at` on((`at`.`id` = `ce`.`calendar_state_id`))) join `vn`.`worker` `w` on((`w`.`id` = `p`.`id_trabajador`))) where ((`ce`.`date` >= (util.VN_CURDATE() + interval -(1) year)) and (`at`.`name` not in ('Vacaciones','Vacaciones 1/2 día','Compensar','Festivo'))) group by `p`.`firstname`,`p`.`name`,`at`.`name` having (`endContract` >= util.VN_CURDATE()) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -94336,101 +78306,6 @@ USE `bs`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
---
--- Final view structure for view `m3Silla__`
---
-
-/*!50001 DROP TABLE IF EXISTS `m3Silla__`*/;
-/*!50001 DROP VIEW IF EXISTS `m3Silla__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `m3Silla__` AS select `m3`.`fecha` AS `fecha`,`m3`.`year` AS `year`,`m3`.`month` AS `month`,`m3`.`week` AS `week`,`m3`.`day` AS `day`,`m3`.`dayName` AS `dayName`,cast(sum(`m3`.`m3`) as decimal(10,0)) AS `Volumen`,cast(sum(`m3`.`euros`) as decimal(10,0)) AS `Euros` from `m3` where (`m3`.`warehouseFk` in (1,44)) group by `m3`.`fecha` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `manaCustomer`
---
-
-/*!50001 DROP TABLE IF EXISTS `manaCustomer`*/;
-/*!50001 DROP VIEW IF EXISTS `manaCustomer`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `manaCustomer` AS select `cmc`.`clientFk` AS `Id_Cliente`,`cmc`.`mana` AS `Mana`,`cmc`.`dated` AS `dated` from `vn`.`clientManaCache` `cmc` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `manaSpellersExcluded`
---
-
-/*!50001 DROP TABLE IF EXISTS `manaSpellersExcluded`*/;
-/*!50001 DROP VIEW IF EXISTS `manaSpellersExcluded`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `manaSpellersExcluded` AS select `m`.`Id_Trabajador` AS `workerFk` from `bs`.`mana_spellers_excluded` `m` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `mana_spellers`
---
-
-/*!50001 DROP TABLE IF EXISTS `mana_spellers`*/;
-/*!50001 DROP VIEW IF EXISTS `mana_spellers`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `mana_spellers` AS select `wm`.`workerFk` AS `Id_Trabajador`,`wm`.`size` AS `size`,`wm`.`amount` AS `used`,`wm`.`pricesModifierRate` AS `prices_modifier_rate`,`wm`.`isPricesModifierActivated` AS `prices_modifier_activated`,`wm`.`minRate` AS `minRate`,`wm`.`maxRate` AS `maxRate` from `vn`.`workerMana` `wm` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `mana_spellers_excluded`
---
-
-/*!50001 DROP TABLE IF EXISTS `mana_spellers_excluded`*/;
-/*!50001 DROP VIEW IF EXISTS `mana_spellers_excluded`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `mana_spellers_excluded` AS select `wme`.`workerFk` AS `Id_Trabajador` from `vn`.`workerManaExcluded` `wme` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
--
-- Final view structure for view `packingSpeed`
--
@@ -94445,7 +78320,7 @@ USE `bs`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `packingSpeed` AS select hour(`e`.`created`) AS `hora`,minute(`e`.`created`) AS `minuto`,ifnull(`p`.`volume`,((`p`.`width` * `p`.`height`) * `p`.`depth`)) AS `cm3`,`t`.`warehouseFk` AS `warehouse_id`,`e`.`created` AS `odbc_date` from ((`vn`.`expedition` `e` join `vn`.`packaging` `p` on((`p`.`id` = `e`.`packagingFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `e`.`ticketFk`))) where (`e`.`created` between curdate() and `util`.`dayend`(curdate())) */;
+/*!50001 VIEW `packingSpeed` AS select hour(`e`.`created`) AS `hora`,minute(`e`.`created`) AS `minuto`,ifnull(`p`.`volume`,((`p`.`width` * `p`.`height`) * `p`.`depth`)) AS `cm3`,`t`.`warehouseFk` AS `warehouse_id`,`e`.`created` AS `odbc_date` from ((`vn`.`expedition` `e` join `vn`.`packaging` `p` on((`p`.`id` = `e`.`packagingFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `e`.`ticketFk`))) where (`e`.`created` between util.VN_CURDATE() and `util`.`dayend`(util.VN_CURDATE())) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -94488,63 +78363,6 @@ USE `bs`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
---
--- Final view structure for view `sale__`
---
-
-/*!50001 DROP TABLE IF EXISTS `sale__`*/;
-/*!50001 DROP VIEW IF EXISTS `sale__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_general_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `sale__` AS select `v`.`Id_Movimiento` AS `saleFk`,`v`.`importe` AS `amount`,`v`.`recargo` AS `surcharge`,`v`.`fecha` AS `dated`,`v`.`tipo_id` AS `typeFk`,`v`.`Id_Cliente` AS `clientFk`,`v`.`empresa_id` AS `companyFk`,`v`.`margen` AS `margin` from `ventas` `v` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `salesPerson__`
---
-
-/*!50001 DROP TABLE IF EXISTS `salesPerson__`*/;
-/*!50001 DROP VIEW IF EXISTS `salesPerson__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_general_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `salesPerson__` AS select `v`.`Id_Trabajador` AS `workerFk`,`v`.`año` AS `year`,`v`.`mes` AS `month`,`v`.`importe` AS `amount`,`v`.`comision` AS `commission`,`v`.`comisionArrendada` AS `leasedCommission`,`v`.`comisionCedida` AS `cededCommission`,`v`.`comisionNuevos` AS `newCommission`,`v`.`sustitucionArrendada` AS `leasedReplacement`,`v`.`itemTypeBorrowed` AS `itemTypeBorrowed`,`v`.`portfolioWeight` AS `portfolioWeight`,`v`.`updated` AS `updated` from `vendedores` `v` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `v_ventas__`
---
-
-/*!50001 DROP TABLE IF EXISTS `v_ventas__`*/;
-/*!50001 DROP VIEW IF EXISTS `v_ventas__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `v_ventas__` AS select (`ventas`.`importe` * `Movimientos`.`Cantidad`) AS `importe`,`ventas`.`recargo` AS `recargo`,`time`.`year` AS `year`,`time`.`month` AS `month`,`time`.`week` AS `week`,`time`.`day` AS `day` from ((`bs`.`ventas` join `vn2008`.`time` on((`time`.`date` = `ventas`.`fecha`))) join `vn2008`.`Movimientos` on((`ventas`.`Id_Movimiento` = `Movimientos`.`Id_Movimiento`))) group by `time`.`date` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
--
-- Final view structure for view `vendedores`
--
@@ -94583,25 +78401,6 @@ USE `bs`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
---
--- Final view structure for view `workerMana`
---
-
-/*!50001 DROP TABLE IF EXISTS `workerMana`*/;
-/*!50001 DROP VIEW IF EXISTS `workerMana`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `workerMana` AS select `m`.`Id_Trabajador` AS `workerFk`,`m`.`used` AS `amount` from `bs`.`mana_spellers` `m` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
--
-- Current Database: `cache`
--
@@ -94628,7 +78427,7 @@ USE `edi`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `errorList` AS select `po`.`id` AS `id`,`c`.`name` AS `name`,`i`.`longName` AS `longName`,`po`.`quantity` AS `quantity`,left(`po`.`error`,4) AS `stock`,`po`.`error` AS `error`,`po`.`deliveryInformationID` AS `deliveryInformationID`,`po`.`supplyResponseID` AS `supplyResponseID`,`po`.`OrderTradeLineDateTime` AS `OrderTradeLineDateTime`,`po`.`EndUserPartyGLN` AS `EndUserPartyGLN` from ((`edi`.`putOrder` `po` left join `vn`.`client` `c` on((`c`.`id` = `po`.`EndUserPartyGLN`))) left join `vn`.`item` `i` on((`i`.`supplyResponseFk` = `po`.`supplyResponseID`))) where ((`po`.`OrderTradeLineDateTime` > (curdate() + interval -(12) hour)) and (`po`.`OrderStatus` = 3) and (left(`po`.`error`,4) <> '(0) ')) */;
+/*!50001 VIEW `errorList` AS select `po`.`id` AS `id`,`c`.`name` AS `name`,`i`.`longName` AS `longName`,`po`.`quantity` AS `quantity`,left(`po`.`error`,4) AS `stock`,`po`.`error` AS `error`,`po`.`deliveryInformationID` AS `deliveryInformationID`,`po`.`supplyResponseID` AS `supplyResponseID`,`po`.`OrderTradeLineDateTime` AS `OrderTradeLineDateTime`,`po`.`EndUserPartyGLN` AS `EndUserPartyGLN` from ((`edi`.`putOrder` `po` left join `vn`.`client` `c` on((`c`.`id` = `po`.`EndUserPartyGLN`))) left join `vn`.`item` `i` on((`i`.`supplyResponseFk` = `po`.`supplyResponseID`))) where ((`po`.`OrderTradeLineDateTime` > (util.VN_CURDATE() + interval -(12) hour)) and (`po`.`OrderStatus` = 3) and (left(`po`.`error`,4) <> '(0) ')) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -94647,7 +78446,7 @@ USE `edi`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `supplyOffer` AS select `sr`.`vmpID` AS `vmpID`,`di`.`ID` AS `diId`,`sr`.`ID` AS `srId`,`sr`.`Item_ArticleCode` AS `Item_ArticleCode`,`sr`.`VBNOmschrijving` AS `product_name`,`s`.`company_name` AS `company_name`,cast(`sr`.`Price` as decimal(10,3)) AS `Price`,`sr`.`Quality` AS `Quality`,`sr`.`s1` AS `s1`,`sr`.`s2` AS `s2`,`sr`.`s3` AS `s3`,`sr`.`s4` AS `s4`,`sr`.`s5` AS `s5`,`sr`.`s6` AS `s6`,`sr`.`NumberOfUnits` AS `NumberOfUnits`,least(if((`sr`.`EmbalageCode` = 800),((`sr`.`EmbalageCode` * 10) + `sr`.`NumberOfItemsPerCask`),`sr`.`EmbalageCode`),ifnull(`idt`.`bucket_id`,'999')) AS `EmbalageCode`,`di`.`LatestDeliveryDateTime` AS `LatestDeliveryDateTime`,`di`.`EarliestDespatchDateTime` AS `EarliestDespatchDateTime`,`di`.`FirstOrderDateTime` AS `FirstOrderDateTime`,`di`.`LatestOrderDateTime` AS `LatestOrderDateTime`,`sr`.`NumberOfItemsPerCask` AS `NumberOfItemsPerCask`,`sr`.`NumberOfLayersPerTrolley` AS `NumberOfLayersPerTrolley`,`sr`.`MinimumNumberToOrder` AS `MinimumNumberToOrder`,`sr`.`MaximumNumberToOrder` AS `MaximumNumberToOrder`,`sr`.`IncrementalOrderableQuantity` AS `IncrementalOrderableQuantity`,`sr`.`PackingPrice` AS `PackingPrice`,`sr`.`MarketPlaceID` AS `MarketPlaceID`,`sr`.`PictureReference` AS `PictureReference`,`sr`.`updated` AS `supplyResponseUpdated`,`i`.`group_id` AS `group_id`,`mp`.`name` AS `marketPlace`,`di`.`DeliveryPrice` AS `DeliveryPrice`,`di`.`ChargeAmount` AS `ChargeAmount`,`di`.`MinimumQuantity` AS `MinimumQuantity`,`di`.`MaximumQuantity Integer` AS `MaximumQuantity`,cast((`sr`.`MinimumNumberToOrder` * (case `sr`.`MinimumOrderUnitType` when 1 then 1 when 2 then (`sr`.`NumberOfItemsPerCask` / `sr`.`NumberBunchesPerCask`) when 3 then `sr`.`NumberOfItemsPerCask` when 4 then (floor(((128 * 56) / (`b`.`x_size` * `b`.`y_size`))) * `sr`.`NumberOfItemsPerCask`) when 5 then ((floor(((128 * 56) / (`b`.`x_size` * `b`.`y_size`))) * `sr`.`NumberOfItemsPerCask`) * `sr`.`NumberOfLayersPerTrolley`) end)) as decimal(10,0)) AS `OrderUnit`,cast((`sr`.`IncrementalOrderableQuantity` * (case `sr`.`IncrementalOrderableQuantityType` when 1 then 1 when 2 then (`sr`.`NumberOfItemsPerCask` / `sr`.`NumberBunchesPerCask`) when 3 then `sr`.`NumberOfItemsPerCask` when 4 then (floor(((128 * 56) / (`b`.`x_size` * `b`.`y_size`))) * `sr`.`NumberOfItemsPerCask`) when 5 then ((floor(((128 * 56) / (`b`.`x_size` * `b`.`y_size`))) * `sr`.`NumberOfItemsPerCask`) * `sr`.`NumberOfLayersPerTrolley`) end)) as decimal(10,0)) AS `IncrementalOrderUnit`,`mp`.`isEarlyBird` AS `isEarlyBird`,`v`.`isVNHSupplier` AS `isVNHSupplier`,`igo`.`expenseFk` AS `expenseFk`,`igo`.`intrastatFk` AS `intrastatFk`,`igo`.`originFk` AS `originFk`,ifnull(`idt`.`itemTypeFk`,`igo`.`itemTypeFk`) AS `itemTypeFk` from (((((((((`edi`.`deliveryInformation` `di` join `edi`.`supplyResponse` `sr` on((`sr`.`ID` = `di`.`supplyResponseID`))) left join `edi`.`supplier` `s` on((`s`.`glnAddressCode` = `sr`.`SupplierGLN`))) join `edi`.`bucket` `b` on((`b`.`bucket_id` = `sr`.`EmbalageCode`))) join `edi`.`item` `i` on((`i`.`id` = `sr`.`Item_ArticleCode`))) join `edi`.`marketPlace` `mp` on((`mp`.`id` = `sr`.`MarketPlaceID`))) join `vn`.`floramondoConfig` `fm`) left join `edi`.`item_defaultType` `idt` on((`idt`.`item_id` = `i`.`id`))) join `edi`.`VMPSettings` `v` on((`v`.`VMPID` = `sr`.`vmpID`))) join `edi`.`item_groupToOffer` `igo` on((`igo`.`group_code` = `i`.`group_id`))) where ((`v`.`isBlocked` = 0) and (`s`.`isBanned` = 0) and (`sr`.`NumberOfUnits` > 0) and (now() between `di`.`FirstOrderDateTime` and `di`.`LatestOrderDateTime`) and (`mp`.`isOffered` = 1) and (`di`.`LatestDeliveryDateTime` between cast(`fm`.`nextLanded` as date) and concat(cast(`fm`.`nextLanded` as date),' ',`fm`.`MaxLatestDeliveryHour`))) group by `sr`.`ID` having (`EmbalageCode` <> 999) */;
+/*!50001 VIEW `supplyOffer` AS select `sr`.`vmpID` AS `vmpID`,`di`.`ID` AS `diId`,`sr`.`ID` AS `srId`,`sr`.`Item_ArticleCode` AS `Item_ArticleCode`,`sr`.`VBNOmschrijving` AS `product_name`,`s`.`company_name` AS `company_name`,cast(`sr`.`Price` as decimal(10,3)) AS `Price`,`sr`.`Quality` AS `Quality`,`sr`.`s1` AS `s1`,`sr`.`s2` AS `s2`,`sr`.`s3` AS `s3`,`sr`.`s4` AS `s4`,`sr`.`s5` AS `s5`,`sr`.`s6` AS `s6`,`sr`.`NumberOfUnits` AS `NumberOfUnits`,least(if((`sr`.`EmbalageCode` = 800),((`sr`.`EmbalageCode` * 10) + `sr`.`NumberOfItemsPerCask`),`sr`.`EmbalageCode`),ifnull(`idt`.`bucket_id`,'999')) AS `EmbalageCode`,`di`.`LatestDeliveryDateTime` AS `LatestDeliveryDateTime`,`di`.`EarliestDespatchDateTime` AS `EarliestDespatchDateTime`,`di`.`FirstOrderDateTime` AS `FirstOrderDateTime`,`di`.`LatestOrderDateTime` AS `LatestOrderDateTime`,`sr`.`NumberOfItemsPerCask` AS `NumberOfItemsPerCask`,`sr`.`NumberOfLayersPerTrolley` AS `NumberOfLayersPerTrolley`,`sr`.`MinimumNumberToOrder` AS `MinimumNumberToOrder`,`sr`.`MaximumNumberToOrder` AS `MaximumNumberToOrder`,`sr`.`IncrementalOrderableQuantity` AS `IncrementalOrderableQuantity`,`sr`.`PackingPrice` AS `PackingPrice`,`sr`.`MarketPlaceID` AS `MarketPlaceID`,`sr`.`PictureReference` AS `PictureReference`,`sr`.`updated` AS `supplyResponseUpdated`,`i`.`group_id` AS `group_id`,`mp`.`name` AS `marketPlace`,`di`.`DeliveryPrice` AS `DeliveryPrice`,`di`.`ChargeAmount` AS `ChargeAmount`,`di`.`MinimumQuantity` AS `MinimumQuantity`,`di`.`MaximumQuantity Integer` AS `MaximumQuantity`,cast((`sr`.`MinimumNumberToOrder` * (case `sr`.`MinimumOrderUnitType` when 1 then 1 when 2 then (`sr`.`NumberOfItemsPerCask` / `sr`.`NumberBunchesPerCask`) when 3 then `sr`.`NumberOfItemsPerCask` when 4 then (floor(((128 * 56) / (`b`.`x_size` * `b`.`y_size`))) * `sr`.`NumberOfItemsPerCask`) when 5 then ((floor(((128 * 56) / (`b`.`x_size` * `b`.`y_size`))) * `sr`.`NumberOfItemsPerCask`) * `sr`.`NumberOfLayersPerTrolley`) end)) as decimal(10,0)) AS `OrderUnit`,cast((`sr`.`IncrementalOrderableQuantity` * (case `sr`.`IncrementalOrderableQuantityType` when 1 then 1 when 2 then (`sr`.`NumberOfItemsPerCask` / `sr`.`NumberBunchesPerCask`) when 3 then `sr`.`NumberOfItemsPerCask` when 4 then (floor(((128 * 56) / (`b`.`x_size` * `b`.`y_size`))) * `sr`.`NumberOfItemsPerCask`) when 5 then ((floor(((128 * 56) / (`b`.`x_size` * `b`.`y_size`))) * `sr`.`NumberOfItemsPerCask`) * `sr`.`NumberOfLayersPerTrolley`) end)) as decimal(10,0)) AS `IncrementalOrderUnit`,`mp`.`isEarlyBird` AS `isEarlyBird`,`v`.`isVNHSupplier` AS `isVNHSupplier`,`igo`.`expenseFk` AS `expenseFk`,`igo`.`intrastatFk` AS `intrastatFk`,`igo`.`originFk` AS `originFk`,ifnull(`idt`.`itemTypeFk`,`igo`.`itemTypeFk`) AS `itemTypeFk` from (((((((((`edi`.`deliveryInformation` `di` join `edi`.`supplyResponse` `sr` on((`sr`.`ID` = `di`.`supplyResponseID`))) left join `edi`.`supplier` `s` on((`s`.`glnAddressCode` = `sr`.`SupplierGLN`))) join `edi`.`bucket` `b` on((`b`.`bucket_id` = `sr`.`EmbalageCode`))) join `edi`.`item` `i` on((`i`.`id` = `sr`.`Item_ArticleCode`))) join `edi`.`marketPlace` `mp` on((`mp`.`id` = `sr`.`MarketPlaceID`))) join `vn`.`floramondoConfig` `fm`) left join `edi`.`item_defaultType` `idt` on((`idt`.`item_id` = `i`.`id`))) join `edi`.`VMPSettings` `v` on((`v`.`VMPID` = `sr`.`vmpID`))) join `edi`.`item_groupToOffer` `igo` on((`igo`.`group_code` = `i`.`group_id`))) where ((`v`.`isBlocked` = 0) and (`s`.`isBanned` = 0) and (`sr`.`NumberOfUnits` > 0) and (util.VN_NOW() between `di`.`FirstOrderDateTime` and `di`.`LatestOrderDateTime`) and (`mp`.`isOffered` = 1) and (`di`.`LatestDeliveryDateTime` between cast(`fm`.`nextLanded` as date) and concat(cast(`fm`.`nextLanded` as date),' ',`fm`.`MaxLatestDeliveryHour`))) group by `sr`.`ID` having (`EmbalageCode` <> 999) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -95191,7 +78990,7 @@ USE `postgresql`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `person` AS select `p`.`id` AS `person_id`,`p`.`surnames` AS `name`,`p`.`nickname` AS `nickname`,`p`.`fi` AS `nif`,`p`.`birth` AS `birth`,`p`.`firstname` AS `firstname`,`p`.`p2` AS `p2`,`p`.`readerId` AS `nis`,`p`.`workerFk` AS `id_trabajador`,`p`.`isDisable` AS `isDisable`,`p`.`isFreelance` AS `isFreelance`,`p`.`isSsDiscounted` AS `isSsDiscounted`,`p`.`sex` AS `sex` from `vn`.`person` `p` */;
+/*!50001 VIEW `person` AS select `p`.`id` AS `person_id`,`p`.`surnames` AS `name`,`p`.`nickname` AS `nickname`,`p`.`fi` AS `nif`,`p`.`birth` AS `birth`,`p`.`firstname` AS `firstname`,`p`.`p2` AS `p2`,`p`.`workerFk` AS `id_trabajador`,`p`.`isDisable` AS `isDisable`,`p`.`isFreelance` AS `isFreelance`,`p`.`isSsDiscounted` AS `isSsDiscounted`,`p`.`sex` AS `sex` from `vn`.`person` `p` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -95216,7 +79015,7 @@ USE `sage`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `clientLastTwoMonths` AS select `vn`.`invoiceOut`.`clientFk` AS `clientFk`,`vn`.`invoiceOut`.`companyFk` AS `companyFk` from `vn`.`invoiceOut` where (`vn`.`invoiceOut`.`issued` > (curdate() - interval 2 month)) union select `vn`.`receipt`.`clientFk` AS `clientFk`,`vn`.`receipt`.`companyFk` AS `companyFk` from `vn`.`receipt` where (`vn`.`receipt`.`payed` > (curdate() - interval 2 month)) */;
+/*!50001 VIEW `clientLastTwoMonths` AS select `vn`.`invoiceOut`.`clientFk` AS `clientFk`,`vn`.`invoiceOut`.`companyFk` AS `companyFk` from `vn`.`invoiceOut` where (`vn`.`invoiceOut`.`issued` > (util.VN_CURDATE() - interval 2 month)) union select `vn`.`receipt`.`clientFk` AS `clientFk`,`vn`.`receipt`.`companyFk` AS `companyFk` from `vn`.`receipt` where (`vn`.`receipt`.`payed` > (util.VN_CURDATE() - interval 2 month)) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -95235,7 +79034,7 @@ USE `sage`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `invoiceInList` AS select `vn`.`invoiceIn`.`id` AS `id`,`vn`.`invoiceIn`.`supplierRef` AS `supplierRef`,`vn`.`invoiceIn`.`serial` AS `serial`,`vn`.`invoiceIn`.`supplierFk` AS `supplierFk`,`vn`.`invoiceIn`.`issued` AS `issued`,if((`vn`.`invoiceIn`.`expenceFkDeductible` > 0),1,0) AS `isVatDeductible`,`vn`.`invoiceIn`.`serialNumber` AS `serialNumber` from `vn`.`invoiceIn` where (`vn`.`invoiceIn`.`issued` >= (date_format(curdate(),'%Y-01-01') + interval -(1) year)) union all select `vn`.`dua`.`id` AS `id`,`vn`.`dua`.`code` AS `code`,'D' AS `D`,`c`.`id` AS `supplierFk`,`vn`.`dua`.`issued` AS `issued`,0 AS `FALSE`,`vn`.`dua`.`id` AS `serialNumber` from (`vn`.`dua` join `vn`.`company` `c` on((`c`.`code` = 'VNL'))) */;
+/*!50001 VIEW `invoiceInList` AS select `vn`.`invoiceIn`.`id` AS `id`,`vn`.`invoiceIn`.`supplierRef` AS `supplierRef`,`vn`.`invoiceIn`.`serial` AS `serial`,`vn`.`invoiceIn`.`supplierFk` AS `supplierFk`,`vn`.`invoiceIn`.`issued` AS `issued`,if((`vn`.`invoiceIn`.`expenceFkDeductible` > 0),1,0) AS `isVatDeductible`,`vn`.`invoiceIn`.`serialNumber` AS `serialNumber` from `vn`.`invoiceIn` where (`vn`.`invoiceIn`.`issued` >= (date_format(util.VN_CURDATE(),'%Y-01-01') + interval -(1) year)) union all select `vn`.`dua`.`id` AS `id`,`vn`.`dua`.`code` AS `code`,'D' AS `D`,`c`.`id` AS `supplierFk`,`vn`.`dua`.`issued` AS `issued`,0 AS `FALSE`,`vn`.`dua`.`id` AS `serialNumber` from (`vn`.`dua` join `vn`.`company` `c` on((`c`.`code` = 'VNL'))) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -95254,7 +79053,7 @@ USE `sage`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `providerLastThreeMonths` AS select `vn`.`invoiceIn`.`supplierFk` AS `supplierFk`,`vn`.`invoiceIn`.`companyFk` AS `companyFk` from `vn`.`invoiceIn` where (`vn`.`invoiceIn`.`issued` > (curdate() - interval 3 month)) union select `vn`.`payment`.`supplierFk` AS `supplierFk`,`vn`.`payment`.`companyFk` AS `companyFk` from `vn`.`payment` where (`vn`.`payment`.`received` > (curdate() + interval -(3) month)) */;
+/*!50001 VIEW `providerLastThreeMonths` AS select `vn`.`invoiceIn`.`supplierFk` AS `supplierFk`,`vn`.`invoiceIn`.`companyFk` AS `companyFk` from `vn`.`invoiceIn` where (`vn`.`invoiceIn`.`issued` > (util.VN_CURDATE() - interval 3 month)) union select `vn`.`payment`.`supplierFk` AS `supplierFk`,`vn`.`payment`.`companyFk` AS `companyFk` from `vn`.`payment` where (`vn`.`payment`.`received` > (util.VN_CURDATE() + interval -(3) month)) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -95373,7 +79172,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `NewView` AS select `c`.`id` AS `clientFk`,max(`t`.`shipped`) AS `lastShipped`,`pc`.`notBuyingMonths` AS `notBuyingMonths` from ((`client` `c` join `productionConfig` `pc`) left join `ticket` `t` on(((`c`.`id` = `t`.`clientFk`) and (`t`.`shipped` < (curdate() + interval -(`pc`.`rookieDays`) day))))) group by `c`.`id` having (isnull(`lastShipped`) or (`lastShipped` < (curdate() + interval -(`notBuyingMonths`) month))) */;
+/*!50001 VIEW `NewView` AS select `c`.`id` AS `clientFk`,max(`t`.`shipped`) AS `lastShipped`,`pc`.`notBuyingMonths` AS `notBuyingMonths` from ((`client` `c` join `productionConfig` `pc`) left join `ticket` `t` on(((`c`.`id` = `t`.`clientFk`) and (`t`.`shipped` < (util.VN_CURDATE() + interval -(`pc`.`rookieDays`) day))))) group by `c`.`id` having (isnull(`lastShipped`) or (`lastShipped` < (util.VN_CURDATE() + interval -(`notBuyingMonths`) month))) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -95397,44 +79196,6 @@ USE `vn`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
---
--- Final view structure for view `absenceType`
---
-
-/*!50001 DROP TABLE IF EXISTS `absenceType`*/;
-/*!50001 DROP VIEW IF EXISTS `absenceType`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `absenceType` AS select `cs`.`calendar_state_id` AS `id`,`cs`.`type` AS `name`,`cs`.`rgb` AS `rgb`,`cs`.`code` AS `code`,`cs`.`permissionRate` AS `permissionRate`,`cs`.`holidayEntitlementRate` AS `holidayEntitlementRate`,`cs`.`discountRate` AS `discountRate` from `postgresql`.`calendar_state` `cs` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `agencyProvince__`
---
-
-/*!50001 DROP TABLE IF EXISTS `agencyProvince__`*/;
-/*!50001 DROP VIEW IF EXISTS `agencyProvince__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `agencyProvince__` AS select `a`.`province_id` AS `provinceFk`,`a`.`agency_id` AS `agencyFk`,`a`.`zona` AS `zone`,`a`.`warehouse_id` AS `warehouseFk`,`a`.`isVolumetric` AS `isVolumetric` from `vn2008`.`Agencias_province` `a` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
--
-- Final view structure for view `agencyTerm`
--
@@ -95474,11 +79235,11 @@ USE `vn`;
/*!50001 SET collation_connection = @saved_col_connection */;
--
--- Final view structure for view `awb__`
+-- Final view structure for view `awbVolume`
--
-/*!50001 DROP TABLE IF EXISTS `awb__`*/;
-/*!50001 DROP VIEW IF EXISTS `awb__`*/;
+/*!50001 DROP TABLE IF EXISTS `awbVolume`*/;
+/*!50001 DROP VIEW IF EXISTS `awbVolume`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
@@ -95487,7 +79248,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `awb__` AS select `a`.`id` AS `id`,`a`.`codigo` AS `code`,`a`.`bultos` AS `package`,`a`.`peso` AS `weight`,`a`.`MYSQL_TIME` AS `created`,`a`.`transitario_id` AS `transitoryFk`,`a`.`iva_id` AS `taxFk`,`a`.`gestdoc_id` AS `docFk`,`a`.`importe` AS `amount`,`a`.`carguera_id` AS `freightFk`,`a`.`m3` AS `m3`,`a`.`stems` AS `stems`,`a`.`flight_id` AS `flightFk`,`a`.`volume_weight` AS `volumeWeight`,`a`.`hb` AS `hb`,`a`.`rate` AS `rate`,`a`.`booked` AS `booked`,`a`.`issued` AS `issued`,`a`.`operated` AS `operated`,`a`.`bookEntried` AS `bookEntried`,`a`.`invoiceInFk` AS `invoiceInFk`,`a`.`isChecked` AS `isChecked` from `vn2008`.`awb` `a` */;
+/*!50001 VIEW `awbVolume` AS select `d`.`awbFk` AS `awbFk`,(((`b`.`stickers` * `i`.`density`) * if((`p`.`volume` > 0),`p`.`volume`,((`p`.`width` * `p`.`depth`) * if((`p`.`height` = 0),(`i`.`size` + 10),`p`.`height`)))) / 167000) AS `volume`,`b`.`id` AS `buyFk` from (((((((`buy` `b` join `item` `i` on((`b`.`itemFk` = `i`.`id`))) join `itemType` `it` on((`i`.`typeFk` = `it`.`id`))) join `packaging` `p` on((`p`.`id` = `b`.`packageFk`))) join `entry` `e` on((`b`.`entryFk` = `e`.`id`))) join `travel` `t` on((`t`.`id` = `e`.`travelFk`))) join `duaEntry` `de` on((`de`.`entryFk` = `e`.`id`))) join `dua` `d` on((`d`.`id` = `de`.`duaFk`))) where (`t`.`shipped` > makedate((year(util.VN_CURDATE()) - 1),1)) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -95587,44 +79348,6 @@ USE `vn`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
---
--- Final view structure for view `calendar__`
---
-
-/*!50001 DROP TABLE IF EXISTS `calendar__`*/;
-/*!50001 DROP VIEW IF EXISTS `calendar__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `calendar__` AS select `ce`.`id` AS `id`,`ce`.`business_id` AS `businessFk`,`ce`.`calendar_state_id` AS `dayOffTypeFk`,`ce`.`date` AS `dated` from `postgresql`.`calendar_employee` `ce` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `claimRatio__`
---
-
-/*!50001 DROP TABLE IF EXISTS `claimRatio__`*/;
-/*!50001 DROP VIEW IF EXISTS `claimRatio__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `claimRatio__` AS select `claims_ratio`.`Id_Cliente` AS `clientFk`,`claims_ratio`.`Consumo` AS `yearSale`,`claims_ratio`.`Reclamaciones` AS `claimAmount`,`claims_ratio`.`Ratio` AS `claimingRate`,`claims_ratio`.`recobro` AS `priceIncreasing`,`claims_ratio`.`inflacion` AS `packingRate` from `bi`.`claims_ratio` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
--
-- Final view structure for view `clientLost`
--
@@ -95639,26 +79362,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `clientLost` AS select `c`.`id` AS `clientFk`,max(`t`.`shipped`) AS `lastShipped`,`pc`.`notBuyingMonths` AS `notBuyingMonths` from ((`client` `c` join `productionConfig` `pc`) left join `ticket` `t` on(((`c`.`id` = `t`.`clientFk`) and (`t`.`shipped` < (curdate() + interval -(`pc`.`rookieDays`) day))))) group by `c`.`id` having (isnull(`lastShipped`) or (`lastShipped` < (curdate() + interval -(`notBuyingMonths`) month))) */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `clientManaCache__`
---
-
-/*!50001 DROP TABLE IF EXISTS `clientManaCache__`*/;
-/*!50001 DROP VIEW IF EXISTS `clientManaCache__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `clientManaCache__` AS select `mc`.`Id_Cliente` AS `clientFk`,`mc`.`Mana` AS `mana`,`mc`.`dated` AS `dated` from `bs`.`manaCustomer` `mc` */;
+/*!50001 VIEW `clientLost` AS select `c`.`id` AS `clientFk`,max(`t`.`shipped`) AS `lastShipped`,`pc`.`notBuyingMonths` AS `notBuyingMonths` from ((`client` `c` join `productionConfig` `pc`) left join `ticket` `t` on(((`c`.`id` = `t`.`clientFk`) and (`t`.`shipped` < (util.VN_CURDATE() + interval -(`pc`.`rookieDays`) day))))) group by `c`.`id` having (isnull(`lastShipped`) or (`lastShipped` < (util.VN_CURDATE() + interval -(`notBuyingMonths`) month))) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -95682,25 +79386,6 @@ USE `vn`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
---
--- Final view structure for view `clientRisk__`
---
-
-/*!50001 DROP TABLE IF EXISTS `clientRisk__`*/;
-/*!50001 DROP VIEW IF EXISTS `clientRisk__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `clientRisk__` AS select `c`.`customer_id` AS `clientFk`,`c`.`company_id` AS `companyFk`,`c`.`amount` AS `amount` from `bi`.`customer_risk__` `c` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
--
-- Final view structure for view `cmr_list`
--
@@ -95720,25 +79405,6 @@ USE `vn`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
---
--- Final view structure for view `collectionReportSource`
---
-
-/*!50001 DROP TABLE IF EXISTS `collectionReportSource`*/;
-/*!50001 DROP VIEW IF EXISTS `collectionReportSource`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `collectionReportSource` AS select `tc`.`collectionFk` AS `collectionFk`,`tc`.`ticketFk` AS `ticketFk`,`s`.`itemFk` AS `itemFk`,`s`.`concept` AS `concept`,`i`.`size` AS `size`,`s`.`quantity` AS `quantity`,`ip`.`code` AS `nicho`,`tc`.`level` AS `level` from (((((`collection` `c` join `ticketCollection` `tc` on((`tc`.`collectionFk` = `c`.`id`))) join `ticket` `t` on((`t`.`id` = `tc`.`ticketFk`))) join `sale` `s` on((`s`.`ticketFk` = `t`.`id`))) join `item` `i` on((`i`.`id` = `s`.`itemFk`))) left join `itemPlacement` `ip` on(((`ip`.`itemFk` = `s`.`itemFk`) and (`ip`.`warehouseFk` = `t`.`warehouseFk`)))) */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
--
-- Final view structure for view `collectionSmartTag`
--
@@ -95777,82 +79443,6 @@ USE `vn`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
---
--- Final view structure for view `componentRate__`
---
-
-/*!50001 DROP TABLE IF EXISTS `componentRate__`*/;
-/*!50001 DROP VIEW IF EXISTS `componentRate__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `componentRate__` AS select `t`.`Id_Componente` AS `id`,`t`.`Componente` AS `name`,`t`.`tarifa_componentes_series_id` AS `componentTypeRate`,`t`.`tarifa_class` AS `classRate`,`t`.`tax` AS `tax`,`t`.`is_renewable` AS `isRenewable`,`t`.`code` AS `code` from `bi`.`tarifa_componentes` `t` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `componentTypeRate__`
---
-
-/*!50001 DROP TABLE IF EXISTS `componentTypeRate__`*/;
-/*!50001 DROP VIEW IF EXISTS `componentTypeRate__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `componentTypeRate__` AS select `t`.`tarifa_componentes_series_id` AS `id`,`t`.`Serie` AS `type`,`t`.`base` AS `base` from `bi`.`tarifa_componentes_series` `t` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `componentType__`
---
-
-/*!50001 DROP TABLE IF EXISTS `componentType__`*/;
-/*!50001 DROP VIEW IF EXISTS `componentType__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `componentType__` AS select `t`.`tarifa_componentes_series_id` AS `id`,`t`.`Serie` AS `type`,`t`.`base` AS `isBase`,`t`.`margen` AS `isMargin` from `bi`.`tarifa_componentes_series` `t` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `component__`
---
-
-/*!50001 DROP TABLE IF EXISTS `component__`*/;
-/*!50001 DROP VIEW IF EXISTS `component__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `component__` AS select `t`.`Id_Componente` AS `id`,`t`.`Componente` AS `name`,`t`.`tarifa_componentes_series_id` AS `typeFk`,`t`.`tarifa_class` AS `classRate`,`t`.`tax` AS `tax`,`t`.`is_renewable` AS `isRenewable`,`t`.`code` AS `code` from `bi`.`tarifa_componentes` `t` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
--
-- Final view structure for view `defaulter`
--
@@ -95962,7 +79552,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `entryList` AS select `e`.`id` AS `entryFk`,if(`tr`.`isReceived`,' x','') AS `isHere`,`tr`.`landed` AS `landed`,ifnull(`s`.`nickname`,`s`.`name`) AS `supplier`,`e`.`ref` AS `entryRef`,`a`.`name` AS `agency`,`tr`.`ref` AS `travelRef`,`tr`.`appointment` AS `appointment`,`e`.`supplierFk` AS `supplierFk`,`tr`.`warehouseInFk` AS `warehouseInFk` from (((`entry` `e` join `travel` `tr` on((`tr`.`id` = `e`.`travelFk`))) join `supplier` `s` on((`s`.`id` = `e`.`supplierFk`))) left join `agency` `a` on((`tr`.`agencyFk` = `a`.`id`))) where (`tr`.`landed` between (curdate() + interval -(1) week) and (curdate() + interval 3 month)) order by (`tr`.`landed` < (curdate() + interval 2 day)) desc,`tr`.`landed` desc,ifnull(`s`.`nickname`,`s`.`name`),`e`.`id` desc */;
+/*!50001 VIEW `entryList` AS select `e`.`id` AS `entryFk`,if(`tr`.`isReceived`,' x','') AS `isHere`,`tr`.`landed` AS `landed`,ifnull(`s`.`nickname`,`s`.`name`) AS `supplier`,`e`.`ref` AS `entryRef`,`a`.`name` AS `agency`,`tr`.`ref` AS `travelRef`,`tr`.`appointment` AS `appointment`,`e`.`supplierFk` AS `supplierFk`,`tr`.`warehouseInFk` AS `warehouseInFk` from (((`entry` `e` join `travel` `tr` on((`tr`.`id` = `e`.`travelFk`))) join `supplier` `s` on((`s`.`id` = `e`.`supplierFk`))) left join `agency` `a` on((`tr`.`agencyFk` = `a`.`id`))) where (`tr`.`landed` between (util.VN_CURDATE() + interval -(1) week) and (util.VN_CURDATE() + interval 3 month)) order by (`tr`.`landed` < (util.VN_CURDATE() + interval 2 day)) desc,`tr`.`landed` desc,ifnull(`s`.`nickname`,`s`.`name`),`e`.`id` desc */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -95981,7 +79571,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `exchangeInsuranceEntry` AS select max(`tr`.`landed`) AS `dated`,cast(sum(((`b`.`buyingValue` + `b`.`freightValue`) * `b`.`quantity`)) as decimal(10,2)) AS `Dolares`,cast((sum(((`b`.`buyingValue` + `b`.`freightValue`) * `b`.`quantity`)) / sum(((((100 + `e`.`commission`) / 100) * (`b`.`buyingValue` + `b`.`freightValue`)) * `b`.`quantity`))) as decimal(10,4)) AS `rate` from ((`entry` `e` join `buy` `b` on((`e`.`id` = `b`.`entryFk`))) join `travel` `tr` on((`tr`.`id` = `e`.`travelFk`))) where ((`tr`.`landed` between '2016-01-31' and curdate()) and (`e`.`commission` < 0) and (`e`.`currencyFk` = 2)) group by month(`tr`.`landed`),year(`tr`.`landed`) */;
+/*!50001 VIEW `exchangeInsuranceEntry` AS select max(`tr`.`landed`) AS `dated`,cast(sum(((`b`.`buyingValue` + `b`.`freightValue`) * `b`.`quantity`)) as decimal(10,2)) AS `Dolares`,cast((sum(((`b`.`buyingValue` + `b`.`freightValue`) * `b`.`quantity`)) / sum(((((100 + `e`.`commission`) / 100) * (`b`.`buyingValue` + `b`.`freightValue`)) * `b`.`quantity`))) as decimal(10,4)) AS `rate` from ((`entry` `e` join `buy` `b` on((`e`.`id` = `b`.`entryFk`))) join `travel` `tr` on((`tr`.`id` = `e`.`travelFk`))) where ((`tr`.`landed` between '2016-01-31' and util.VN_CURDATE()) and (`e`.`commission` < 0) and (`e`.`currencyFk` = 2)) group by month(`tr`.`landed`),year(`tr`.`landed`) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -96057,7 +79647,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `expeditionCommon` AS select `et`.`id` AS `truckFk`,`et`.`ETD` AS `etd`,ifnull(ucase(`et`.`description`),'SIN ESCANEAR') AS `description`,`es`.`palletFk` AS `palletFk`,`t`.`routeFk` AS `routeFk`,`es`.`id` AS `scanFk`,`e`.`id` AS `expeditionFk`,`r`.`expeditionTruckFk` AS `expeditionTruckFk`,`t`.`warehouseFk` AS `warehouseFk`,`e`.`created` AS `lastPacked`,`t`.`id` AS `ticketFk` from (((((`expeditionTruck` `et` left join `routesMonitor` `r` on((`et`.`id` = `r`.`expeditionTruckFk`))) left join `ticket` `t` on((`r`.`routeFk` = `t`.`routeFk`))) left join `expedition` `e` on((`t`.`id` = `e`.`ticketFk`))) left join `expeditionScan` `es` on((`e`.`id` = `es`.`expeditionFk`))) left join `expeditionPallet` `ep` on((`es`.`palletFk` = `ep`.`id`))) where (`et`.`ETD` >= curdate()) */;
+/*!50001 VIEW `expeditionCommon` AS select `et`.`id` AS `truckFk`,`et`.`ETD` AS `etd`,ifnull(ucase(`et`.`description`),'SIN ESCANEAR') AS `description`,`es`.`palletFk` AS `palletFk`,`t`.`routeFk` AS `routeFk`,`es`.`id` AS `scanFk`,`e`.`id` AS `expeditionFk`,`r`.`expeditionTruckFk` AS `expeditionTruckFk`,`t`.`warehouseFk` AS `warehouseFk`,`e`.`created` AS `lastPacked`,`t`.`id` AS `ticketFk` from (((((`expeditionTruck` `et` left join `routesMonitor` `r` on((`et`.`id` = `r`.`expeditionTruckFk`))) left join `ticket` `t` on((`r`.`routeFk` = `t`.`routeFk`))) left join `expedition` `e` on((`t`.`id` = `e`.`ticketFk`))) left join `expeditionScan` `es` on((`e`.`id` = `es`.`expeditionFk`))) left join `expeditionPallet` `ep` on((`es`.`palletFk` = `ep`.`id`))) where (`et`.`ETD` >= util.VN_CURDATE()) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -96076,7 +79666,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `expeditionPallet_Print` AS select `et2`.`description` AS `truck`,`t`.`routeFk` AS `routeFk`,`r`.`description` AS `zone`,count(`es`.`id`) AS `eti`,`ep`.`id` AS `palletFk`,(`et`.`id` <=> `rm`.`expeditionTruckFk`) AS `isMatch`,`t`.`warehouseFk` AS `warehouseFk`,if((`r`.`created` > (curdate() + interval 1 day)),ucase(dayname(`r`.`created`)),NULL) AS `nombreDia` from (((((((`vn`.`expeditionTruck` `et` join `vn`.`expeditionPallet` `ep` on((`ep`.`truckFk` = `et`.`id`))) join `vn`.`expeditionScan` `es` on((`es`.`palletFk` = `ep`.`id`))) join `vn`.`expedition` `e` on((`e`.`id` = `es`.`expeditionFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `e`.`ticketFk`))) join `vn`.`route` `r` on((`r`.`id` = `t`.`routeFk`))) left join `vn2008`.`Rutas_monitor` `rm` on((`rm`.`Id_Ruta` = `r`.`id`))) left join `vn`.`expeditionTruck` `et2` on((`et2`.`id` = `rm`.`expeditionTruckFk`))) where (`ep`.`isPrint` = 0) group by `ep`.`id`,`t`.`routeFk` */;
+/*!50001 VIEW `expeditionPallet_Print` AS select `et2`.`description` AS `truck`,`t`.`routeFk` AS `routeFk`,`r`.`description` AS `zone`,count(`es`.`id`) AS `eti`,`ep`.`id` AS `palletFk`,(`et`.`id` <=> `rm`.`expeditionTruckFk`) AS `isMatch`,`t`.`warehouseFk` AS `warehouseFk`,if((`r`.`created` > (util.VN_CURDATE() + interval 1 day)),ucase(dayname(`r`.`created`)),NULL) AS `nombreDia` from (((((((`vn`.`expeditionTruck` `et` join `vn`.`expeditionPallet` `ep` on((`ep`.`truckFk` = `et`.`id`))) join `vn`.`expeditionScan` `es` on((`es`.`palletFk` = `ep`.`id`))) join `vn`.`expedition` `e` on((`e`.`id` = `es`.`expeditionFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `e`.`ticketFk`))) join `vn`.`route` `r` on((`r`.`id` = `t`.`routeFk`))) left join `vn2008`.`Rutas_monitor` `rm` on((`rm`.`Id_Ruta` = `r`.`id`))) left join `vn`.`expeditionTruck` `et2` on((`et2`.`id` = `rm`.`expeditionTruckFk`))) where (`ep`.`isPrint` = 0) group by `ep`.`id`,`t`.`routeFk` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -96152,26 +79742,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `expeditionSticker` AS select `e`.`id` AS `expeditionFk`,`e`.`ticketFk` AS `ticketFk`,`t`.`addressFk` AS `addressFk`,`t`.`clientFk` AS `clientFk`,`a`.`street` AS `street`,`a`.`postalCode` AS `postalCode`,`a`.`city` AS `city`,`a`.`nickname` AS `nickname`,concat('R(',convert(right(`t`.`routeFk`,3) using utf8mb4),')') AS `routeFk`,`rm`.`beachFk` AS `beachFk`,if(`t`.`routeFk`,replace(`am`.`name`,'ZONA ','Z'),`z`.`name`) AS `zona`,`p`.`name` AS `province`,ifnull(`c`.`mobile`,ifnull(`a`.`mobile`,ifnull(`c`.`phone`,`a`.`phone`))) AS `phone`,`w`.`code` AS `workerCode` from ((((((((((`expedition` `e` join `ticket` `t` on((`t`.`id` = `e`.`ticketFk`))) join `address` `a` on((`a`.`id` = `t`.`addressFk`))) join `province` `p` on((`p`.`id` = `a`.`provinceFk`))) left join `routesMonitor` `rm` on((`rm`.`routeFk` = `t`.`routeFk`))) left join `beach` `b` on((`b`.`id` = `rm`.`beachFk`))) left join `zone` `z` on((`z`.`id` = `t`.`zoneFk`))) left join `route` `r` on((`r`.`id` = `t`.`routeFk`))) left join `agencyMode` `am` on((`am`.`id` = `r`.`agencyModeFk`))) join `client` `c` on((`c`.`id` = `a`.`clientFk`))) join `worker` `w` on((`w`.`id` = `e`.`workerFk`))) */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `expeditionSticker__`
---
-
-/*!50001 DROP TABLE IF EXISTS `expeditionSticker__`*/;
-/*!50001 DROP VIEW IF EXISTS `expeditionSticker__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `expeditionSticker__` AS select `e`.`id` AS `expeditionFk`,`e`.`ticketFk` AS `ticketFk`,`t`.`addressFk` AS `addressFk`,`t`.`clientFk` AS `clientFk`,`a`.`street` AS `street`,`a`.`postalCode` AS `postalCode`,`a`.`city` AS `city`,`a`.`nickname` AS `nickname`,concat('R(',convert(right(`t`.`routeFk`,4) using utf8mb4),')') AS `routeFk`,`rm`.`beachFk` AS `beachFk`,if(`t`.`routeFk`,replace(`z`.`name`,'ZONA ','Z'),`am`.`name`) AS `zona`,`p`.`name` AS `province`,ifnull(`a`.`mobile`,`a`.`phone`) AS `phone` from (((((((`expedition` `e` join `ticket` `t` on((`t`.`id` = `e`.`ticketFk`))) join `address` `a` on((`a`.`id` = `t`.`addressFk`))) join `province` `p` on((`p`.`id` = `a`.`provinceFk`))) left join `routesMonitor` `rm` on((`rm`.`routeFk` = `t`.`routeFk`))) left join `beach` `b` on((`b`.`id` = `rm`.`beachFk`))) left join `zone` `z` on((`z`.`id` = `t`.`zoneFk`))) join `agencyMode` `am` on((`t`.`agencyModeFk` = `am`.`id`))) */;
+/*!50001 VIEW `expeditionSticker` AS select `e`.`id` AS `expeditionFk`,`e`.`ticketFk` AS `ticketFk`,`t`.`addressFk` AS `addressFk`,`t`.`clientFk` AS `clientFk`,`a`.`street` AS `street`,`a`.`postalCode` AS `postalCode`,`a`.`city` AS `city`,`a`.`nickname` AS `nickname`,concat('R(',convert(right(`t`.`routeFk`,3) using utf8mb4),')') AS `routeFk`,`rm`.`beachFk` AS `beachFk`,if(`t`.`routeFk`,replace(`am`.`name`,'ZONA ','Z'),`z`.`name`) AS `zona`,`p`.`name` AS `province`,ifnull(`c`.`mobile`,ifnull(`a`.`mobile`,ifnull(`c`.`phone`,`a`.`phone`))) AS `phone`,`w`.`code` AS `workerCode` from ((((((((((`expedition` `e` join `ticket` `t` on((`t`.`id` = `e`.`ticketFk`))) join `address` `a` on((`a`.`id` = `t`.`addressFk`))) join `province` `p` on((`p`.`id` = `a`.`provinceFk`))) left join `routesMonitor` `rm` on((`rm`.`routeFk` = `t`.`routeFk`))) left join `beach` `b` on((`b`.`code` = `rm`.`beachFk`))) left join `zone` `z` on((`z`.`id` = `t`.`zoneFk`))) left join `route` `r` on((`r`.`id` = `t`.`routeFk`))) left join `agencyMode` `am` on((`am`.`id` = `r`.`agencyModeFk`))) join `client` `c` on((`c`.`id` = `a`.`clientFk`))) join `worker` `w` on((`w`.`id` = `e`.`workerFk`))) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -96190,7 +79761,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `expeditionTicket_NoBoxes` AS select `t`.`id` AS `ticketFk`,`t`.`warehouseFk` AS `warehouseFk`,`t`.`routeFk` AS `routeFk`,`et`.`description` AS `description` from (((`ticket` `t` left join `expedition` `e` on((`e`.`ticketFk` = `t`.`id`))) join `routesMonitor` `rm` on((`rm`.`routeFk` = `t`.`routeFk`))) join `expeditionTruck` `et` on((`et`.`id` = `rm`.`expeditionTruckFk`))) where (isnull(`e`.`id`) and (`et`.`ETD` > curdate())) */;
+/*!50001 VIEW `expeditionTicket_NoBoxes` AS select `t`.`id` AS `ticketFk`,`t`.`warehouseFk` AS `warehouseFk`,`t`.`routeFk` AS `routeFk`,`et`.`description` AS `description` from (((`ticket` `t` left join `expedition` `e` on((`e`.`ticketFk` = `t`.`id`))) join `routesMonitor` `rm` on((`rm`.`routeFk` = `t`.`routeFk`))) join `expeditionTruck` `et` on((`et`.`id` = `rm`.`expeditionTruckFk`))) where (isnull(`e`.`id`) and (`et`.`ETD` > util.VN_CURDATE())) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -96209,7 +79780,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `expeditionTimeExpended` AS select `e`.`ticketFk` AS `ticketFk`,min(`e`.`created`) AS `started`,max(`e`.`created`) AS `finished`,max(`e`.`counter`) AS `cajas`,`w`.`code` AS `code`,`t`.`warehouseFk` AS `warehouseFk` from ((`expedition` `e` join `worker` `w` on((`w`.`id` = `e`.`workerFk`))) join `ticket` `t` on((`t`.`id` = `e`.`ticketFk`))) where (`e`.`created` > curdate()) group by `e`.`ticketFk` */;
+/*!50001 VIEW `expeditionTimeExpended` AS select `e`.`ticketFk` AS `ticketFk`,min(`e`.`created`) AS `started`,max(`e`.`created`) AS `finished`,max(`e`.`counter`) AS `cajas`,`w`.`code` AS `code`,`t`.`warehouseFk` AS `warehouseFk` from ((`expedition` `e` join `worker` `w` on((`w`.`id` = `e`.`workerFk`))) join `ticket` `t` on((`t`.`id` = `e`.`ticketFk`))) where (`e`.`created` > util.VN_CURDATE()) group by `e`.`ticketFk` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -96309,82 +79880,6 @@ USE `vn`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
---
--- Final view structure for view `holidayDetail__`
---
-
-/*!50001 DROP TABLE IF EXISTS `holidayDetail__`*/;
-/*!50001 DROP VIEW IF EXISTS `holidayDetail__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `holidayDetail__` AS select `cll`.`calendar_labour_legend_id` AS `id`,`cll`.`descripcion` AS `description` from `postgresql`.`calendar_labour_legend__` `cll` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `holidayLegend__`
---
-
-/*!50001 DROP TABLE IF EXISTS `holidayLegend__`*/;
-/*!50001 DROP VIEW IF EXISTS `holidayLegend__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `holidayLegend__` AS select `cll`.`calendar_labour_legend_id` AS `id`,`cll`.`descripcion` AS `description` from `postgresql`.`calendar_labour_legend__` `cll` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `holidayType__`
---
-
-/*!50001 DROP TABLE IF EXISTS `holidayType__`*/;
-/*!50001 DROP VIEW IF EXISTS `holidayType__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `holidayType__` AS select `cf`.`calendar_free_id` AS `id`,`cf`.`type` AS `name`,`cf`.`rgb` AS `rgb` from `postgresql`.`calendar_free__` `cf` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `holiday__`
---
-
-/*!50001 DROP TABLE IF EXISTS `holiday__`*/;
-/*!50001 DROP VIEW IF EXISTS `holiday__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `holiday__` AS select `cl`.`calendar_labour_legend_id` AS `holidayDetailFk`,`cl`.`calendar_free_id` AS `holidayTypeFk`,`cl`.`workcenter_id` AS `workCenterFk`,`cl`.`day` AS `dated` from `postgresql`.`calendar_labour__` `cl` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
--
-- Final view structure for view `inkL10n`
--
@@ -96418,83 +79913,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `invoiceCorrectionDataSource` AS select `s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`s`.`price` AS `price`,`s`.`discount` AS `discount`,`t`.`refFk` AS `refFk`,`s`.`id` AS `saleFk`,`t`.`shipped` AS `shipped` from (`sale` `s` join `ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) where (`t`.`shipped` > (curdate() + interval -(3) year)) */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `invoiceInAwb__`
---
-
-/*!50001 DROP TABLE IF EXISTS `invoiceInAwb__`*/;
-/*!50001 DROP VIEW IF EXISTS `invoiceInAwb__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `invoiceInAwb__` AS select `a`.`recibida_id` AS `invoiceInFk`,`a`.`awb_id` AS `awbFk`,`a`.`dua` AS `dua` from `vn2008`.`awb_recibida` `a` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `invoiceInDueDay__`
---
-
-/*!50001 DROP TABLE IF EXISTS `invoiceInDueDay__`*/;
-/*!50001 DROP VIEW IF EXISTS `invoiceInDueDay__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `invoiceInDueDay__` AS select `r`.`id` AS `id`,`r`.`recibida_id` AS `invoiceInFk`,`r`.`fecha` AS `dueDated`,`r`.`banco_id` AS `bankFk`,`r`.`cantidad` AS `amount`,`r`.`divisa` AS `foreignValue`,`r`.`stamp` AS `created` from `vn2008`.`recibida_vencimiento` `r` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `invoiceInIntrastat2__`
---
-
-/*!50001 DROP TABLE IF EXISTS `invoiceInIntrastat2__`*/;
-/*!50001 DROP VIEW IF EXISTS `invoiceInIntrastat2__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `invoiceInIntrastat2__` AS select `id`.`id` AS `id`,`id`.`recibida_id` AS `invoiceInFk`,`id`.`neto` AS `net`,`id`.`intrastat_id` AS `intrastatFk`,`id`.`importe` AS `amount`,`id`.`unidades` AS `stems`,`id`.`Paises_Id` AS `countryFk`,`id`.`odbc_date` AS `dated`,`id`.`valorestadistico` AS `statisticalValue` from `vn2008`.`intrastat_data` `id` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `invoiceIn__`
---
-
-/*!50001 DROP TABLE IF EXISTS `invoiceIn__`*/;
-/*!50001 DROP VIEW IF EXISTS `invoiceIn__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `invoiceIn__` AS select `r`.`id` AS `id`,`r`.`num_recibida` AS `serialNumber`,`r`.`serie` AS `serial`,`r`.`proveedor_id` AS `supplierFk`,`r`.`fecha` AS `issued`,`r`.`sref` AS `supplierRef`,`r`.`contabilizada` AS `isBooked`,`r`.`moneda_id` AS `currencyFk`,`r`.`MYSQL_TIME` AS `created`,`r`.`empresa_id` AS `companyFk`,`r`.`gestdoc_id` AS `docFk`,`r`.`dateBooking` AS `booked`,`r`.`dateOperation` AS `operated`,`r`.`cplusInvoiceType472Fk` AS `cplusInvoiceType472Fk`,`r`.`cplusRectificationTypeFk` AS `cplusRectificationTypeFk`,`r`.`cplusSubjectOpFk` AS `cplusSubjectOpFk`,`r`.`cplusTaxBreakFk` AS `cplusTaxBreakFk`,`r`.`cplusTrascendency472Fk` AS `cplusTrascendency472Fk`,`r`.`bookEntried` AS `bookEntried`,`r`.`isVatDeductible` AS `isVatDeductible`,`r`.`withholdingSageFk` AS `withholdingSageFk` from `vn2008`.`recibida` `r` */;
+/*!50001 VIEW `invoiceCorrectionDataSource` AS select `s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`s`.`price` AS `price`,`s`.`discount` AS `discount`,`t`.`refFk` AS `refFk`,`s`.`id` AS `saleFk`,`t`.`shipped` AS `shipped` from (`sale` `s` join `ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) where (`t`.`shipped` > (util.VN_CURDATE() + interval -(3) year)) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -96570,7 +79989,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `itemEntryIn` AS select `t`.`warehouseInFk` AS `warehouseInFk`,`t`.`landed` AS `landed`,`b`.`itemFk` AS `itemFk`,`b`.`quantity` AS `quantity`,`t`.`isReceived` AS `isReceived`,`e`.`isRaid` AS `isVirtualStock`,`e`.`id` AS `entryFk` from ((`buy` `b` join `entry` `e` on((`b`.`entryFk` = `e`.`id`))) join `travel` `t` on((`e`.`travelFk` = `t`.`id`))) where ((`e`.`isInventory` = 0) and (`b`.`quantity` <> 0)) */;
+/*!50001 VIEW `itemEntryIn` AS select `t`.`warehouseInFk` AS `warehouseInFk`,`t`.`landed` AS `landed`,`b`.`itemFk` AS `itemFk`,`b`.`quantity` AS `quantity`,`t`.`isReceived` AS `isReceived`,`e`.`isRaid` AS `isVirtualStock`,`e`.`id` AS `entryFk` from ((`buy` `b` join `entry` `e` on((`b`.`entryFk` = `e`.`id`))) join `travel` `t` on((`e`.`travelFk` = `t`.`id`))) where ((`e`.`isExcludedFromAvailable` = 0) and (`b`.`quantity` <> 0)) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -96589,7 +80008,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `itemEntryOut` AS select `t`.`warehouseOutFk` AS `warehouseOutFk`,`t`.`shipped` AS `shipped`,`b`.`itemFk` AS `itemFk`,-(`b`.`quantity`) AS `quantity`,`t`.`isDelivered` AS `isDelivered`,`e`.`id` AS `entryFk` from ((`buy` `b` join `entry` `e` on((`b`.`entryFk` = `e`.`id`))) join `travel` `t` on((`e`.`travelFk` = `t`.`id`))) where ((`e`.`isInventory` = 0) and (`e`.`isRaid` = 0) and (`b`.`quantity` <> 0)) */;
+/*!50001 VIEW `itemEntryOut` AS select `t`.`warehouseOutFk` AS `warehouseOutFk`,`t`.`shipped` AS `shipped`,`b`.`itemFk` AS `itemFk`,-(`b`.`quantity`) AS `quantity`,`t`.`isDelivered` AS `isDelivered`,`e`.`id` AS `entryFk` from ((`buy` `b` join `entry` `e` on((`b`.`entryFk` = `e`.`id`))) join `travel` `t` on((`e`.`travelFk` = `t`.`id`))) where ((`e`.`isExcludedFromAvailable` = 0) and (`e`.`isRaid` = 0) and (`b`.`quantity` <> 0)) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -96627,7 +80046,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `itemPlacementSupplyList` AS select `ips`.`id` AS `id`,`ips`.`itemFk` AS `itemFk`,`ips`.`quantity` AS `quantity`,`ips`.`priority` AS `priority`,ifnull(`isps`.`created`,`ips`.`created`) AS `created`,`ips`.`userFk` AS `userFk`,`ips`.`repoUserFk` AS `repoUserFk`,(`ips`.`quantity` - sum(ifnull(`isps`.`quantity`,0))) AS `saldo`,concat(`i`.`longName`,' ',`i`.`size`) AS `longName`,`i`.`subName` AS `subName`,`i`.`size` AS `size`,`w`.`code` AS `workerCode`,`rw`.`code` AS `repoCode`,`ips`.`sectorFk` AS `sectorFk` from ((((`itemPlacementSupply` `ips` join `item` `i` on((`i`.`id` = `ips`.`itemFk`))) left join `worker` `w` on((`w`.`userFk` = `ips`.`userFk`))) left join `worker` `rw` on((`rw`.`userFk` = `ips`.`repoUserFk`))) left join `itemShelvingPlacementSupply` `isps` on((`isps`.`itemPlacementSupplyFk` = `ips`.`id`))) where (`ips`.`created` >= curdate()) group by `ips`.`priority`,`ips`.`id`,`ips`.`sectorFk` */;
+/*!50001 VIEW `itemPlacementSupplyList` AS select `ips`.`id` AS `id`,`ips`.`itemFk` AS `itemFk`,`ips`.`quantity` AS `quantity`,`ips`.`priority` AS `priority`,ifnull(`isps`.`created`,`ips`.`created`) AS `created`,`ips`.`userFk` AS `userFk`,`ips`.`repoUserFk` AS `repoUserFk`,(`ips`.`quantity` - sum(ifnull(`isps`.`quantity`,0))) AS `saldo`,concat(`i`.`longName`,' ',`i`.`size`) AS `longName`,`i`.`subName` AS `subName`,`i`.`size` AS `size`,`w`.`code` AS `workerCode`,`rw`.`code` AS `repoCode`,`ips`.`sectorFk` AS `sectorFk` from ((((`itemPlacementSupply` `ips` join `item` `i` on((`i`.`id` = `ips`.`itemFk`))) left join `worker` `w` on((`w`.`userFk` = `ips`.`userFk`))) left join `worker` `rw` on((`rw`.`userFk` = `ips`.`repoUserFk`))) left join `itemShelvingPlacementSupply` `isps` on((`isps`.`itemPlacementSupplyFk` = `ips`.`id`))) where (`ips`.`created` >= util.VN_CURDATE()) group by `ips`.`priority`,`ips`.`id`,`ips`.`sectorFk` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -96684,7 +80103,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `itemShelvingAvailable` AS select `s`.`id` AS `saleFk`,`tst`.`updated` AS `Modificado`,`s`.`ticketFk` AS `ticketFk`,0 AS `isPicked`,`s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`i`.`size` AS `size`,`st`.`name` AS `Estado`,`st`.`sectorProdPriority` AS `sectorProdPriority`,`stock`.`visible` AS `available`,`stock`.`sectorFk` AS `sectorFk`,`stock`.`shelvingFk` AS `matricula`,`stock`.`parkingFk` AS `parking`,`stock`.`itemShelvingFk` AS `itemShelving`,`am`.`name` AS `Agency`,`t`.`shipped` AS `shipped`,`stock`.`grouping` AS `grouping`,`stock`.`packing` AS `packing`,`z`.`hour` AS `hour`,`st`.`isPreviousPreparable` AS `isPreviousPreparable`,`sv`.`physicalVolume` AS `physicalVolume`,`t`.`warehouseFk` AS `warehouseFk` from (((((((((`vn`.`sale` `s` join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) join `vn`.`ticketStateToday` `tst` on((`tst`.`ticket` = `t`.`id`))) join `vn`.`state` `st` on((`st`.`id` = `tst`.`state`))) join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`itemShelvingStock` `stock` on((`stock`.`itemFk` = `i`.`id`))) left join `vn`.`saleTracking` `stk` on((`stk`.`saleFk` = `s`.`id`))) left join `vn`.`zone` `z` on((`z`.`id` = `t`.`zoneFk`))) left join `vn`.`saleVolume` `sv` on((`sv`.`saleFk` = `s`.`id`))) where ((`t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(curdate())) and isnull(`stk`.`id`) and (`stock`.`visible` > 0) and isnull(`stk`.`saleFk`) and `st`.`isPreviousPreparable`) */;
+/*!50001 VIEW `itemShelvingAvailable` AS select `s`.`id` AS `saleFk`,`tst`.`updated` AS `Modificado`,`s`.`ticketFk` AS `ticketFk`,0 AS `isPicked`,`s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`i`.`size` AS `size`,`st`.`name` AS `Estado`,`st`.`sectorProdPriority` AS `sectorProdPriority`,`stock`.`visible` AS `available`,`stock`.`sectorFk` AS `sectorFk`,`stock`.`shelvingFk` AS `matricula`,`stock`.`parkingFk` AS `parking`,`stock`.`itemShelvingFk` AS `itemShelving`,`am`.`name` AS `Agency`,`t`.`shipped` AS `shipped`,`stock`.`grouping` AS `grouping`,`stock`.`packing` AS `packing`,`z`.`hour` AS `hour`,`st`.`isPreviousPreparable` AS `isPreviousPreparable`,`sv`.`physicalVolume` AS `physicalVolume`,`t`.`warehouseFk` AS `warehouseFk` from (((((((((`vn`.`sale` `s` join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) join `vn`.`ticketStateToday` `tst` on((`tst`.`ticket` = `t`.`id`))) join `vn`.`state` `st` on((`st`.`id` = `tst`.`state`))) join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`itemShelvingStock` `stock` on((`stock`.`itemFk` = `i`.`id`))) left join `vn`.`saleTracking` `stk` on((`stk`.`saleFk` = `s`.`id`))) left join `vn`.`zone` `z` on((`z`.`id` = `t`.`zoneFk`))) left join `vn`.`saleVolume` `sv` on((`sv`.`saleFk` = `s`.`id`))) where ((`t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(util.VN_CURDATE())) and isnull(`stk`.`id`) and (`stock`.`visible` > 0) and isnull(`stk`.`saleFk`) and `st`.`isPreviousPreparable`) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -96931,7 +80350,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `lastHourProduction` AS select `t`.`warehouseFk` AS `warehouseFk`,cast(sum((ifnull(`p`.`volume`,((`p`.`width` * `p`.`height`) * `p`.`depth`)) / 1000000)) as decimal(5,1)) AS `m3` from (((`warehouse` `w` join `ticket` `t` on((`t`.`warehouseFk` = `w`.`id`))) left join `expedition` `e` on((`t`.`id` = `e`.`ticketFk`))) left join `packaging` `p` on((`p`.`id` = `e`.`packagingFk`))) where (`e`.`created` between (now() - interval 1 hour) and now()) group by `t`.`warehouseFk` */;
+/*!50001 VIEW `lastHourProduction` AS select `t`.`warehouseFk` AS `warehouseFk`,cast(sum((ifnull(`p`.`volume`,((`p`.`width` * `p`.`height`) * `p`.`depth`)) / 1000000)) as decimal(5,1)) AS `m3` from (((`warehouse` `w` join `ticket` `t` on((`t`.`warehouseFk` = `w`.`id`))) left join `expedition` `e` on((`t`.`id` = `e`.`ticketFk`))) left join `packaging` `p` on((`p`.`id` = `e`.`packagingFk`))) where (`e`.`created` between (util.VN_NOW() - interval 1 hour) and util.VN_NOW()) group by `t`.`warehouseFk` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -96969,7 +80388,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `lastTopClaims` AS select `s`.`itemFk` AS `itemFk`,`i`.`longName` AS `itemName`,`it`.`name` AS `itemTypeName`,count(0) AS `claimsNumber`,round(sum(((((`cb`.`quantity` * `s`.`price`) * (1 - ((`c`.`responsibility` - 1) / 4))) * (100 - `s`.`discount`)) / 100)),2) AS `claimedAmount`,round(sum((((`cb`.`quantity` * `s`.`price`) * (100 - `s`.`discount`)) / 100)),2) AS `totalAmount` from ((((`claim` `c` join `claimBeginning` `cb` on((`cb`.`claimFk` = `c`.`id`))) join `sale` `s` on((`s`.`id` = `cb`.`saleFk`))) join `item` `i` on((`i`.`id` = `s`.`itemFk`))) join `itemType` `it` on((`it`.`id` = `i`.`typeFk`))) where (`c`.`created` >= (curdate() + interval -(1) week)) group by `s`.`itemFk` having (((`claimedAmount` > 100) and (`claimsNumber` > 2)) or (`claimsNumber` > 4)) order by `claimsNumber` desc */;
+/*!50001 VIEW `lastTopClaims` AS select `s`.`itemFk` AS `itemFk`,`i`.`longName` AS `itemName`,`it`.`name` AS `itemTypeName`,count(0) AS `claimsNumber`,round(sum(((((`cb`.`quantity` * `s`.`price`) * (1 - ((`c`.`responsibility` - 1) / 4))) * (100 - `s`.`discount`)) / 100)),2) AS `claimedAmount`,round(sum((((`cb`.`quantity` * `s`.`price`) * (100 - `s`.`discount`)) / 100)),2) AS `totalAmount` from ((((`claim` `c` join `claimBeginning` `cb` on((`cb`.`claimFk` = `c`.`id`))) join `sale` `s` on((`s`.`id` = `cb`.`saleFk`))) join `item` `i` on((`i`.`id` = `s`.`itemFk`))) join `itemType` `it` on((`it`.`id` = `i`.`typeFk`))) where (`c`.`created` >= (util.VN_CURDATE() + interval -(1) week)) group by `s`.`itemFk` having (((`claimedAmount` > 100) and (`claimsNumber` > 2)) or (`claimsNumber` > 4)) order by `claimsNumber` desc */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -97031,25 +80450,6 @@ USE `vn`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
---
--- Final view structure for view `newBornSales__`
---
-
-/*!50001 DROP TABLE IF EXISTS `newBornSales__`*/;
-/*!50001 DROP VIEW IF EXISTS `newBornSales__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `newBornSales__` AS select `v`.`importe` AS `amount`,`v`.`Id_Cliente` AS `clientFk`,`c`.`salesPersonFk` AS `userFk`,`v`.`fecha` AS `dated`,`cn`.`firstShipped` AS `firstShipped` from (((`bs`.`clientNewBorn` `cn` join `bs`.`ventas` `v` on((((`cn`.`firstShipped` + interval 1 year) > `v`.`fecha`) and (`v`.`Id_Cliente` = `cn`.`clientFk`)))) join `vn`.`client` `c` on((`c`.`id` = `v`.`Id_Cliente`))) join `account`.`user` `u` on((`u`.`id` = `c`.`salesPersonFk`))) where ((`u`.`role` = 18) and (`u`.`name` not in ('ismaelalcolea','ruben'))) */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
--
-- Final view structure for view `originL10n`
--
@@ -97088,44 +80488,6 @@ USE `vn`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
---
--- Final view structure for view `payDemDetail__`
---
-
-/*!50001 DROP TABLE IF EXISTS `payDemDetail__`*/;
-/*!50001 DROP VIEW IF EXISTS `payDemDetail__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_general_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `payDemDetail__` AS select `pdd`.`id` AS `id`,`pdd`.`detalle` AS `detail` from `vn2008`.`pay_dem_det` `pdd` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `payment__`
---
-
-/*!50001 DROP TABLE IF EXISTS `payment__`*/;
-/*!50001 DROP VIEW IF EXISTS `payment__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `payment__` AS select `p`.`id` AS `id`,`p`.`fecha` AS `received`,`p`.`dueDated` AS `dueDated`,`p`.`id_proveedor` AS `supplierFk`,`p`.`importe` AS `amount`,`p`.`id_moneda` AS `currencyFk`,`p`.`divisa` AS `divisa`,`p`.`id_banco` AS `bankFk`,`p`.`pay_met_id` AS `payMethodFk`,`p`.`empresa_id` AS `companyFk`,`p`.`pago_sdc_id` AS `exchangeInsuranceFk`,`p`.`conciliado` AS `isConciliated` from `vn2008`.`pago` `p` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
--
-- Final view structure for view `personMedia`
--
@@ -97146,11 +80508,11 @@ USE `vn`;
/*!50001 SET collation_connection = @saved_col_connection */;
--
--- Final view structure for view `printer__`
+-- Final view structure for view `phoneBook`
--
-/*!50001 DROP TABLE IF EXISTS `printer__`*/;
-/*!50001 DROP VIEW IF EXISTS `printer__`*/;
+/*!50001 DROP TABLE IF EXISTS `phoneBook`*/;
+/*!50001 DROP VIEW IF EXISTS `phoneBook`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
@@ -97159,7 +80521,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `printer__` AS select `i`.`Id_Impresora` AS `id`,`i`.`Ruta` AS `path`,`i`.`Impresora` AS `name`,`i`.`referencia` AS `reference`,`i`.`isLabeler` AS `isLabeler`,`i`.`description` AS `description` from `vn2008`.`Impresoras__` `i` */;
+/*!50001 VIEW `phoneBook` AS select 'C' AS `Tipo`,`client`.`id` AS `Id`,`client`.`name` AS `Cliente`,`client`.`phone` AS `Telefono` from `client` where (`client`.`phone` is not null) union select 'C' AS `Tipo`,`client`.`id` AS `Id`,`client`.`name` AS `Cliente`,`client`.`mobile` AS `Movil` from `client` where (`client`.`mobile` is not null) union select 'C' AS `Tipo`,`clientContact`.`clientFk` AS `clientFk`,`clientContact`.`name` AS `name`,`clientContact`.`phone` AS `phone` from `clientContact` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -97178,7 +80540,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `productionVolume` AS select hour(`e`.`created`) AS `hora`,minute(`e`.`created`) AS `minuto`,ifnull(`p`.`volume`,ifnull(((`p`.`width` * `p`.`height`) * `p`.`depth`),94500)) AS `cm3`,`t`.`warehouseFk` AS `warehouseFk`,`e`.`created` AS `created` from (((`expedition` `e` left join `packaging` `p` on((`p`.`itemFk` = `e`.`itemFk`))) join `ticket` `t` on((`t`.`id` = `e`.`ticketFk`))) join `client` `c` on((`c`.`id` = `t`.`clientFk`))) where ((`e`.`created` between curdate() and `util`.`dayend`(curdate())) and `c`.`isRelevant`) */;
+/*!50001 VIEW `productionVolume` AS select hour(`e`.`created`) AS `hora`,minute(`e`.`created`) AS `minuto`,ifnull(`p`.`volume`,ifnull(((`p`.`width` * `p`.`height`) * `p`.`depth`),94500)) AS `cm3`,`t`.`warehouseFk` AS `warehouseFk`,`e`.`created` AS `created` from (((`expedition` `e` left join `packaging` `p` on((`p`.`itemFk` = `e`.`itemFk`))) join `ticket` `t` on((`t`.`id` = `e`.`ticketFk`))) join `client` `c` on((`c`.`id` = `t`.`clientFk`))) where ((`e`.`created` between util.VN_CURDATE() and `util`.`dayend`(util.VN_CURDATE())) and `c`.`isRelevant`) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -97197,64 +80559,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `productionVolume_LastHour` AS select cast(sum((`productionVolume`.`cm3` / 1000000)) as decimal(10,0)) AS `m3`,`productionVolume`.`warehouseFk` AS `warehouseFk` from `productionVolume` where ((`productionVolume`.`created` > (now() + interval -(1) hour)) and (`productionVolume`.`warehouseFk` in (1,44,60))) group by `productionVolume`.`warehouseFk` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `rankingNewBornByQuarter__`
---
-
-/*!50001 DROP TABLE IF EXISTS `rankingNewBornByQuarter__`*/;
-/*!50001 DROP VIEW IF EXISTS `rankingNewBornByQuarter__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `rankingNewBornByQuarter__` AS select sum(`v`.`importe`) AS `total`,`u`.`name` AS `name`,now() AS `time_sec`,`u`.`id` AS `userFk` from (((`bs`.`clientNewBorn` `cn` join `bs`.`ventas` `v` on((((`cn`.`firstShipped` + interval 1 year) > `v`.`fecha`) and (`v`.`Id_Cliente` = `cn`.`clientFk`)))) join `vn`.`client` `c` on((`c`.`id` = `v`.`Id_Cliente`))) join `account`.`user` `u` on((`u`.`id` = `c`.`salesPersonFk`))) where ((`v`.`fecha` >= '2020-07-01') and (`cn`.`firstShipped` >= '2019-07-01') and (`u`.`role` = 18) and (`u`.`name` not in ('ismaelalcolea','ruben'))) group by `u`.`id` order by sum(`v`.`importe`) desc limit 20 */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `rankingSellingByQuarter__`
---
-
-/*!50001 DROP TABLE IF EXISTS `rankingSellingByQuarter__`*/;
-/*!50001 DROP VIEW IF EXISTS `rankingSellingByQuarter__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `rankingSellingByQuarter__` AS select sum(`v`.`importe`) AS `importe`,`u`.`name` AS `name`,`u`.`id` AS `userFk`,now() AS `time_sec` from (`bs`.`vendedores` `v` join `account`.`user` `u` on((`u`.`id` = `v`.`Id_Trabajador`))) where ((`v`.`año` = year(curdate())) and (quarter(concat(year(curdate()),'-',`v`.`mes`,'-01')) = quarter(curdate())) and (`u`.`name` not in ('ismaelalcolea','ruben'))) group by `v`.`Id_Trabajador` order by sum(`v`.`importe`) desc limit 15 */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `rate__`
---
-
-/*!50001 DROP TABLE IF EXISTS `rate__`*/;
-/*!50001 DROP VIEW IF EXISTS `rate__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `rate__` AS select `r`.`tarifa_id` AS `id`,`r`.`fecha` AS `dated`,`r`.`warehouse_id` AS `warehouseFk`,`r`.`t0` AS `rate0`,`r`.`t1` AS `rate1`,`r`.`t2` AS `rate2`,`r`.`t3` AS `rate3` from `vn2008`.`tarifas` `r` */;
+/*!50001 VIEW `productionVolume_LastHour` AS select cast(sum((`productionVolume`.`cm3` / 1000000)) as decimal(10,0)) AS `m3`,`productionVolume`.`warehouseFk` AS `warehouseFk` from `productionVolume` where ((`productionVolume`.`created` > (util.VN_NOW() + interval -(1) hour)) and (`productionVolume`.`warehouseFk` in (1,44,60))) group by `productionVolume`.`warehouseFk` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -97278,6 +80583,25 @@ USE `vn`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
+--
+-- Final view structure for view `routesReduced`
+--
+
+/*!50001 DROP TABLE IF EXISTS `routesReduced`*/;
+/*!50001 DROP VIEW IF EXISTS `routesReduced`*/;
+/*!50001 SET @saved_cs_client = @@character_set_client */;
+/*!50001 SET @saved_cs_results = @@character_set_results */;
+/*!50001 SET @saved_col_connection = @@collation_connection */;
+/*!50001 SET character_set_client = utf8mb4 */;
+/*!50001 SET character_set_results = utf8mb4 */;
+/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `routesReduced` AS select `et`.`description` AS `description`,`rm`.`name` AS `name`,`t`.`routeFk` AS `routeFk`,`et`.`ETD` AS `ETD`,`rm`.`bufferFk` AS `bufferFk`,`rm`.`beachFk` AS `beachFk`,`i`.`itemPackingTypeFk` AS `itempackingTypeFk` from (((((((`vn`.`expeditionTruck` `et` join `vn`.`routesMonitor` `rm` on((`rm`.`expeditionTruckFk` = `et`.`id`))) join `vn`.`ticket` `t` on((`t`.`routeFk` = `rm`.`routeFk`))) join `vn`.`ticketState` `ts` on((`ts`.`ticketFk` = `t`.`id`))) join `vn`.`state` `st` on((`st`.`id` = `ts`.`stateFk`))) join `vn`.`sale` `s` on((`s`.`ticketFk` = `t`.`id`))) join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`config` `c`) where (`et`.`ETD` > `util`.`yesterday`()) group by `t`.`routeFk` order by `et`.`ETD`,`t`.`routeFk` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
+
--
-- Final view structure for view `saleCost`
--
@@ -97297,6 +80621,25 @@ USE `vn`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
+--
+-- Final view structure for view `saleLabel`
+--
+
+/*!50001 DROP TABLE IF EXISTS `saleLabel`*/;
+/*!50001 DROP VIEW IF EXISTS `saleLabel`*/;
+/*!50001 SET @saved_cs_client = @@character_set_client */;
+/*!50001 SET @saved_cs_results = @@character_set_results */;
+/*!50001 SET @saved_col_connection = @@collation_connection */;
+/*!50001 SET character_set_client = utf8mb4 */;
+/*!50001 SET character_set_results = utf8mb4 */;
+/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `saleLabel` AS select `ml`.`Id_movimiento` AS `saleFk`,`ml`.`label` AS `label`,`ml`.`stem` AS `stem`,`ml`.`created` AS `created` from `vn2008`.`movement_label` `ml` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
+
--
-- Final view structure for view `saleMistakeList`
--
@@ -97316,25 +80659,6 @@ USE `vn`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
---
--- Final view structure for view `saleMistake_list__`
---
-
-/*!50001 DROP TABLE IF EXISTS `saleMistake_list__`*/;
-/*!50001 DROP VIEW IF EXISTS `saleMistake_list__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `saleMistake_list__` AS select `st`.`saleFk` AS `saleFk`,concat(`w2`.`firstName`,' ',`w2`.`lastName`) AS `sacador`,`st`.`created` AS `created`,concat(`w`.`firstName`,' ',`w`.`lastName`) AS `revisador`,`mt`.`description` AS `description`,`sm`.`created` AS `controlled` from (((((`vn`.`saleTracking` `st` join `vn`.`worker` `w2` on((`w2`.`id` = `st`.`workerFk`))) join `vncontrol`.`accion` `a` on(((`a`.`accion_id` = `st`.`actionFk`) and (`a`.`accion` = 'SACAR')))) left join `vn`.`saleMistake` `sm` on((`st`.`saleFk` = `sm`.`saleFk`))) left join `vn`.`mistakeType` `mt` on((`mt`.`id` = `sm`.`typeFk`))) left join `vn`.`worker` `w` on((`w`.`id` = `sm`.`userFk`))) where (`st`.`created` > '2020-10-01') */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
--
-- Final view structure for view `saleMistake_list__2`
--
@@ -97368,7 +80692,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `saleSaleTracking` AS select distinct `st`.`saleFk` AS `saleFk` from `saleTracking` `st` where (`st`.`created` >= (curdate() + interval -(1) day)) */;
+/*!50001 VIEW `saleSaleTracking` AS select distinct `st`.`saleFk` AS `saleFk` from `saleTracking` `st` where (`st`.`created` >= (util.VN_CURDATE() + interval -(1) day)) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -97425,7 +80749,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `saleVolume_Today_VNH` AS select `t`.`nickname` AS `Cliente`,`p`.`name` AS `Provincia`,`c`.`country` AS `Pais`,cast(sum(`sv`.`volume`) as decimal(5,1)) AS `volume` from (((((`saleVolume` `sv` join `ticket` `t` on((`t`.`id` = `sv`.`ticketFk`))) join `address` `a` on((`a`.`id` = `t`.`addressFk`))) join `province` `p` on((`p`.`id` = `a`.`provinceFk`))) join `country` `c` on((`c`.`id` = `p`.`countryFk`))) join `warehouse` `w` on((`w`.`id` = `t`.`warehouseFk`))) where ((`w`.`name` = 'VNH') and (`t`.`shipped` between curdate() and `util`.`dayend`(curdate()))) group by `t`.`nickname`,`p`.`name` */;
+/*!50001 VIEW `saleVolume_Today_VNH` AS select `t`.`nickname` AS `Cliente`,`p`.`name` AS `Provincia`,`c`.`country` AS `Pais`,cast(sum(`sv`.`volume`) as decimal(5,1)) AS `volume` from (((((`saleVolume` `sv` join `ticket` `t` on((`t`.`id` = `sv`.`ticketFk`))) join `address` `a` on((`a`.`id` = `t`.`addressFk`))) join `province` `p` on((`p`.`id` = `a`.`provinceFk`))) join `country` `c` on((`c`.`id` = `p`.`countryFk`))) join `warehouse` `w` on((`w`.`id` = `t`.`warehouseFk`))) where ((`w`.`name` = 'VNH') and (`t`.`shipped` between util.VN_CURDATE() and `util`.`dayend`(util.VN_CURDATE()))) group by `t`.`nickname`,`p`.`name` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -97482,7 +80806,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `salesPreparedLastHour` AS select `t`.`warehouseFk` AS `warehouseFk`,`st`.`saleFk` AS `saleFk`,`st`.`isChecked` AS `isChecked`,`st`.`originalQuantity` AS `originalQuantity`,`a`.`accion` AS `accion`,`st`.`created` AS `created`,`e`.`code` AS `code`,`w`.`firstName` AS `firstname`,`w`.`lastName` AS `lastName`,`w`.`code` AS `workerCode`,((`ic`.`cm3delivery` * `s`.`quantity`) / 1000) AS `litros`,`s`.`concept` AS `concept`,`d`.`name` AS `departmentName` from (((((((((`vn`.`saleTracking` `st` left join `vn`.`salesPreviousPreparated` `prevPrepSales` on((`prevPrepSales`.`saleFk` = `st`.`saleFk`))) join `vn`.`sale` `s` on((`s`.`id` = `st`.`saleFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`itemCost` `ic` on(((`ic`.`warehouseFk` = `t`.`warehouseFk`) and (`ic`.`itemFk` = `s`.`itemFk`)))) join `vn`.`worker` `w` on((`w`.`id` = `st`.`workerFk`))) join `vn`.`state` `e` on((`e`.`id` = `st`.`stateFk`))) join `vncontrol`.`accion` `a` on((`a`.`accion_id` = `st`.`actionFk`))) join `vn`.`workerDepartment` `wd` on((`wd`.`workerFk` = `st`.`workerFk`))) join `vn`.`department` `d` on((`d`.`id` = `wd`.`departmentFk`))) where ((`st`.`created` > (now() + interval -(1) hour)) and isnull(`prevPrepSales`.`saleFk`) and (not((`d`.`name` like 'EQUIPO%')))) */;
+/*!50001 VIEW `salesPreparedLastHour` AS select `t`.`warehouseFk` AS `warehouseFk`,`st`.`saleFk` AS `saleFk`,`st`.`isChecked` AS `isChecked`,`st`.`originalQuantity` AS `originalQuantity`,`a`.`accion` AS `accion`,`st`.`created` AS `created`,`e`.`code` AS `code`,`w`.`firstName` AS `firstname`,`w`.`lastName` AS `lastName`,`w`.`code` AS `workerCode`,((`ic`.`cm3delivery` * `s`.`quantity`) / 1000) AS `litros`,`s`.`concept` AS `concept`,`d`.`name` AS `departmentName` from (((((((((`vn`.`saleTracking` `st` left join `vn`.`salesPreviousPreparated` `prevPrepSales` on((`prevPrepSales`.`saleFk` = `st`.`saleFk`))) join `vn`.`sale` `s` on((`s`.`id` = `st`.`saleFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`itemCost` `ic` on(((`ic`.`warehouseFk` = `t`.`warehouseFk`) and (`ic`.`itemFk` = `s`.`itemFk`)))) join `vn`.`worker` `w` on((`w`.`id` = `st`.`workerFk`))) join `vn`.`state` `e` on((`e`.`id` = `st`.`stateFk`))) join `vncontrol`.`accion` `a` on((`a`.`accion_id` = `st`.`actionFk`))) join `vn`.`workerDepartment` `wd` on((`wd`.`workerFk` = `st`.`workerFk`))) join `vn`.`department` `d` on((`d`.`id` = `wd`.`departmentFk`))) where ((`st`.`created` > (util.VN_NOW() + interval -(1) hour)) and isnull(`prevPrepSales`.`saleFk`) and (not((`d`.`name` like 'EQUIPO%')))) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -97501,26 +80825,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `salesPreviousPreparated` AS select `st`.`saleFk` AS `saleFk` from (`saleTracking` `st` join `state` `e` on((`e`.`id` = `st`.`stateFk`))) where ((`st`.`created` > curdate()) and (`e`.`code` like 'PREVIOUS_PREPARATION')) */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `salesToPrePrepare__`
---
-
-/*!50001 DROP TABLE IF EXISTS `salesToPrePrepare__`*/;
-/*!50001 DROP VIEW IF EXISTS `salesToPrePrepare__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `salesToPrePrepare__` AS select `m`.`ticketFk` AS `Id_Ticket`,`mk`.`Id_Movimiento` AS `Id_Movimiento`,`mk`.`Id_Movimiento_mark` AS `Id_Movimiento_mark`,`mk`.`Id_Trabajador` AS `Id_Trabjador`,`mk`.`valor` AS `isChecked`,`mk`.`odbc_date` AS `created`,`m`.`itemFk` AS `Id_Article`,`m`.`concept` AS `Concepte`,`art`.`subName` AS `subName`,ifnull(`m`.`quantity`,0) AS `Cantidad`,ifnull(`m`.`originalQuantity`,`m`.`quantity`) AS `original_quantity`,hour(`t`.`shipped`) AS `Hora`,hour(`t`.`shipped`) AS `Departure`,minute(`t`.`shipped`) AS `Minuto`,`am`.`agencyFk` AS `agency_id`,`t`.`warehouseFk` AS `warehouse_id`,`a`.`provinceFk` AS `province_id`,`is`.`quantity` AS `picked`,`t`.`CodigoTrabajador` AS `trabajador`,`is`.`sectorFk` AS `sectorFk`,`mk`.`stateFk` AS `stateFk` from ((((((((`vn2008`.`Movimientos_mark` `mk` join `vn`.`state` `st` on((`st`.`id` = `mk`.`stateFk`))) join `vn`.`sale` `m` on((`m`.`id` = `mk`.`Id_Movimiento`))) join `vn`.`ticket` `t` on((`m`.`ticketFk` = `t`.`id`))) join `vn`.`agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) join `vn`.`address` `a` on((`a`.`id` = `t`.`addressFk`))) left join `vn`.`itemShelvingSaleSum` `is` on((`is`.`saleFk` = `mk`.`Id_Movimiento`))) join `vn2008`.`Articles` `art` on((`art`.`Id_Article` = `m`.`itemFk`))) left join `vn2008`.`Trabajadores` `t` on((`t`.`Id_Trabajador` = `mk`.`Id_Trabajador`))) where (`st`.`code` like 'PREVIOUS_PREPARATION') */;
+/*!50001 VIEW `salesPreviousPreparated` AS select `st`.`saleFk` AS `saleFk` from (`saleTracking` `st` join `state` `e` on((`e`.`id` = `st`.`stateFk`))) where ((`st`.`created` > util.VN_CURDATE()) and (`e`.`code` like 'PREVIOUS_PREPARATION')) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -97563,25 +80868,6 @@ USE `vn`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
---
--- Final view structure for view `ticketLabel_Source`
---
-
-/*!50001 DROP TABLE IF EXISTS `ticketLabel_Source`*/;
-/*!50001 DROP VIEW IF EXISTS `ticketLabel_Source`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `ticketLabel_Source` AS select concat(`tc`.`collectionFk`,' ',`tc`.`wagon`,'-',`tc`.`level`) AS `level`,`t`.`id` AS `Id_Ticket`,(case when (`t`.`routeFk` is not null) then if(`agr`.`showAgencyName`,concat(right(left(`agr`.`name`,(locate(' ',`agr`.`name`) - 1)),2),'- R',convert(right(`t`.`routeFk`,3) using utf8)),`agr`.`name`) else if((`am`.`deliveryMethodFk` = 2),`zo`.`name`,`am`.`name`) end) AS `Agencia`,`t`.`clientFk` AS `Id_Cliente`,`t`.`notes` AS `Notas`,'CDT' AS `Sacador`,1 AS `ncarro`,if(hour(`t`.`shipped`),date_format(`t`.`shipped`,'%H:%i'),date_format(`zo`.`hour`,'%H:%i')) AS `horaagencia`,`t`.`shipped` AS `fecha`,if(((now() + interval 1 hour) > `ze`.`etc`),'!!!','') AS `urgente` from (((((((`vn`.`ticket` `t` join `vn`.`agencyMode` `am` on((`t`.`agencyModeFk` = `am`.`id`))) left join `vn`.`address` `a` on((`a`.`id` = `t`.`addressFk`))) left join `vn`.`route` `r` on((`t`.`routeFk` = `r`.`id`))) left join `vn`.`zoneEstimatedDelivery` `ze` on((`ze`.`zoneFk` = `t`.`zoneFk`))) left join `vn`.`ticketCollection` `tc` on((`tc`.`ticketFk` = `t`.`id`))) left join `vn`.`agencyMode` `agr` on((`r`.`agencyModeFk` = `agr`.`id`))) left join `vn`.`zone` `zo` on((`t`.`zoneFk` = `zo`.`id`))) where (`t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(curdate())) */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
--
-- Final view structure for view `ticketLastUpdated`
--
@@ -97615,7 +80901,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `ticketLastUpdatedList` AS select `s`.`ticketFk` AS `ticketFk`,`st`.`created` AS `created` from (`vn`.`saleTracking` `st` join `vn`.`sale` `s` on((`s`.`id` = `st`.`saleFk`))) where (`st`.`created` > curdate()) union all select `i`.`Id_Ticket` AS `Id_Ticket`,`i`.`odbc_date` AS `odbc_date` from `vncontrol`.`inter` `i` where (`i`.`odbc_date` > curdate()) union all select `s`.`ticketFk` AS `ticketFk`,`iss`.`created` AS `created` from (`vn`.`itemShelvingSale` `iss` join `vn`.`sale` `s` on((`s`.`id` = `iss`.`saleFk`))) where (`iss`.`created` > curdate()) */;
+/*!50001 VIEW `ticketLastUpdatedList` AS select `s`.`ticketFk` AS `ticketFk`,`st`.`created` AS `created` from (`vn`.`saleTracking` `st` join `vn`.`sale` `s` on((`s`.`id` = `st`.`saleFk`))) where (`st`.`created` > util.VN_CURDATE()) union all select `i`.`Id_Ticket` AS `Id_Ticket`,`i`.`odbc_date` AS `odbc_date` from `vncontrol`.`inter` `i` where (`i`.`odbc_date` > util.VN_CURDATE()) union all select `s`.`ticketFk` AS `ticketFk`,`iss`.`created` AS `created` from (`vn`.`itemShelvingSale` `iss` join `vn`.`sale` `s` on((`s`.`id` = `iss`.`saleFk`))) where (`iss`.`created` > util.VN_CURDATE()) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -97710,7 +80996,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `ticketPreviousPreparingList` AS select `s`.`ticketFk` AS `ticketFk`,`w`.`code` AS `code`,count(`s`.`id`) AS `saleLines`,sum((`s`.`isPicked` <> 0)) AS `alreadyMadeSaleLines`,(sum((`s`.`isPicked` <> 0)) / count(`s`.`id`)) AS `madeRate`,`sg`.`created` AS `created`,`p`.`code` AS `parking`,`iss`.`sectorFk` AS `sectorFk`,`al`.`code` AS `alertCode` from (((((((`vn`.`saleGroup` `sg` join `vn`.`saleGroupDetail` `sgd` on((`sgd`.`saleGroupFk` = `sg`.`id`))) join `vn`.`sale` `s` on((`s`.`id` = `sgd`.`saleFk`))) join `vn`.`ticketState` `tls` on((`tls`.`ticketFk` = `s`.`ticketFk`))) join `vn`.`alertLevel` `al` on((`al`.`id` = `tls`.`alertLevel`))) join `vn`.`worker` `w` on((`w`.`id` = `sg`.`userFk`))) left join `vn`.`parking` `p` on((`p`.`id` = `sg`.`parkingFk`))) join `vn`.`itemShelvingStock` `iss` on((`iss`.`itemFk` = `s`.`itemFk`))) where (`sg`.`created` >= (curdate() + interval 0.1 day)) group by `sg`.`id` */;
+/*!50001 VIEW `ticketPreviousPreparingList` AS select `s`.`ticketFk` AS `ticketFk`,`w`.`code` AS `code`,count(`s`.`id`) AS `saleLines`,sum((`s`.`isPicked` <> 0)) AS `alreadyMadeSaleLines`,(sum((`s`.`isPicked` <> 0)) / count(`s`.`id`)) AS `madeRate`,`sg`.`created` AS `created`,`p`.`code` AS `parking`,`iss`.`sectorFk` AS `sectorFk`,`al`.`code` AS `alertCode` from (((((((`vn`.`saleGroup` `sg` join `vn`.`saleGroupDetail` `sgd` on((`sgd`.`saleGroupFk` = `sg`.`id`))) join `vn`.`sale` `s` on((`s`.`id` = `sgd`.`saleFk`))) join `vn`.`ticketState` `tls` on((`tls`.`ticketFk` = `s`.`ticketFk`))) join `vn`.`alertLevel` `al` on((`al`.`id` = `tls`.`alertLevel`))) join `vn`.`worker` `w` on((`w`.`id` = `sg`.`userFk`))) left join `vn`.`parking` `p` on((`p`.`id` = `sg`.`parkingFk`))) join `vn`.`itemShelvingStock` `iss` on((`iss`.`itemFk` = `s`.`itemFk`))) where (`sg`.`created` >= (util.VN_CURDATE() + interval 0.1 day)) group by `sg`.`id` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -97748,7 +81034,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `ticketStateToday` AS select `ts`.`ticket` AS `ticket`,`ts`.`state` AS `state`,`ts`.`productionOrder` AS `productionOrder`,`ts`.`alertLevel` AS `alertLevel`,`ts`.`worker` AS `worker`,`ts`.`code` AS `code`,`ts`.`updated` AS `updated`,`ts`.`isPicked` AS `isPicked` from (`vn`.`ticketState` `ts` join `vn`.`ticket` `t` on((`t`.`id` = `ts`.`ticket`))) where (`t`.`shipped` between curdate() and `MIDNIGHT`(curdate())) */;
+/*!50001 VIEW `ticketStateToday` AS select `ts`.`ticket` AS `ticket`,`ts`.`state` AS `state`,`ts`.`productionOrder` AS `productionOrder`,`ts`.`alertLevel` AS `alertLevel`,`ts`.`worker` AS `worker`,`ts`.`code` AS `code`,`ts`.`updated` AS `updated`,`ts`.`isPicked` AS `isPicked` from (`vn`.`ticketState` `ts` join `vn`.`ticket` `t` on((`t`.`id` = `ts`.`ticket`))) where (`t`.`shipped` between util.VN_CURDATE() and `MIDNIGHT`(util.VN_CURDATE())) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -97772,25 +81058,6 @@ USE `vn`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
---
--- Final view structure for view `time__`
---
-
-/*!50001 DROP TABLE IF EXISTS `time__`*/;
-/*!50001 DROP VIEW IF EXISTS `time__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `time__` AS select `t`.`date` AS `dated`,`t`.`period` AS `period`,`t`.`month` AS `month`,`t`.`year` AS `year`,`t`.`day` AS `day`,`t`.`week` AS `week`,`t`.`yearMonth` AS `yearMonth` from `vn2008`.`time` `t` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
--
-- Final view structure for view `tr2`
--
@@ -97881,7 +81148,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `workerBusinessDated` AS select `t`.`dated` AS `dated`,`b`.`business_id` AS `business_id`,`w`.`id` AS `workerFk` from ((((`vn`.`time` `t` left join `postgresql`.`business` `b` on((`t`.`dated` between `b`.`date_start` and ifnull(`b`.`date_end`,curdate())))) left join `postgresql`.`profile` `pr` on((`b`.`client_id` = `pr`.`profile_id`))) left join `postgresql`.`person` `p` on((`pr`.`person_id` = `p`.`person_id`))) left join `vn`.`worker` `w` on((`p`.`id_trabajador` = `w`.`id`))) where (`t`.`dated` > (curdate() + interval -(2) year)) */;
+/*!50001 VIEW `workerBusinessDated` AS select `t`.`dated` AS `dated`,`b`.`business_id` AS `business_id`,`w`.`id` AS `workerFk` from ((((`vn`.`time` `t` left join `postgresql`.`business` `b` on((`t`.`dated` between `b`.`date_start` and ifnull(`b`.`date_end`,util.VN_CURDATE())))) left join `postgresql`.`profile` `pr` on((`b`.`client_id` = `pr`.`profile_id`))) left join `postgresql`.`person` `p` on((`pr`.`person_id` = `p`.`person_id`))) left join `vn`.`worker` `w` on((`p`.`id_trabajador` = `w`.`id`))) where (`t`.`dated` > (util.VN_CURDATE() + interval -(2) year)) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -97919,7 +81186,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `workerDepartment` AS select `p`.`id_trabajador` AS `workerFk`,`d`.`id` AS `departmentFk` from (((`postgresql`.`person` `p` join `postgresql`.`profile` `pr` on((`pr`.`person_id` = `p`.`person_id`))) left join (`postgresql`.`business` `b` left join `postgresql`.`business_labour` `bl` on((`b`.`business_id` = `bl`.`business_id`))) on((`pr`.`profile_id` = `b`.`client_id`))) join `vn`.`department` `d` on((`d`.`id` = `bl`.`department_id`))) where ((isnull(`b`.`date_end`) and (`b`.`date_start` <= curdate())) or ((`b`.`date_end` >= curdate()) and (`b`.`date_start` <= curdate()))) */;
+/*!50001 VIEW `workerDepartment` AS select `p`.`id_trabajador` AS `workerFk`,`d`.`id` AS `departmentFk` from (((`postgresql`.`person` `p` join `postgresql`.`profile` `pr` on((`pr`.`person_id` = `p`.`person_id`))) left join (`postgresql`.`business` `b` left join `postgresql`.`business_labour` `bl` on((`b`.`business_id` = `bl`.`business_id`))) on((`pr`.`profile_id` = `b`.`client_id`))) join `vn`.`department` `d` on((`d`.`id` = `bl`.`department_id`))) where ((isnull(`b`.`date_end`) and (`b`.`date_start` <= util.VN_CURDATE())) or ((`b`.`date_end` >= util.VN_CURDATE()) and (`b`.`date_start` <= util.VN_CURDATE()))) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -97938,7 +81205,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `workerDepartmentTest` AS select `p`.`workerFk` AS `workerFk`,`d`.`id` AS `departmentFk` from ((((`vn`.`person` `p` join `postgresql`.`profile` `pr` on((`pr`.`person_id` = `p`.`id`))) join `postgresql`.`business` `b` on((`b`.`client_id` = `pr`.`profile_id`))) join `postgresql`.`business_labour` `bl` on((`b`.`business_id` = `bl`.`business_id`))) join `vn`.`department` `d` on((`d`.`id` = `bl`.`department_id`))) where (curdate() between `b`.`date_start` and ifnull(`b`.`date_end`,curdate())) */;
+/*!50001 VIEW `workerDepartmentTest` AS select `p`.`workerFk` AS `workerFk`,`d`.`id` AS `departmentFk` from ((((`vn`.`person` `p` join `postgresql`.`profile` `pr` on((`pr`.`person_id` = `p`.`id`))) join `postgresql`.`business` `b` on((`b`.`client_id` = `pr`.`profile_id`))) join `postgresql`.`business_labour` `bl` on((`b`.`business_id` = `bl`.`business_id`))) join `vn`.`department` `d` on((`d`.`id` = `bl`.`department_id`))) where (util.VN_CURDATE() between `b`.`date_start` and ifnull(`b`.`date_end`,util.VN_CURDATE())) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -97962,25 +81229,6 @@ USE `vn`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
---
--- Final view structure for view `workerMana__`
---
-
-/*!50001 DROP TABLE IF EXISTS `workerMana__`*/;
-/*!50001 DROP VIEW IF EXISTS `workerMana__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `workerMana__` AS select `ms`.`Id_Trabajador` AS `workerFk`,`ms`.`size` AS `size`,`ms`.`used` AS `amount`,`ms`.`prices_modifier_rate` AS `pricesModifierRate`,`ms`.`prices_modifier_activated` AS `isPricesModifierActivated`,`ms`.`minRate` AS `minRate`,`ms`.`maxRate` AS `maxRate` from `bs`.`mana_spellers` `ms` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
--
-- Final view structure for view `workerMedia`
--
@@ -98014,7 +81262,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `workerSpeedExpedition` AS select `sv`.`ticketFk` AS `ticketFk`,sum(`sv`.`litros`) AS `litros`,sum(if((`sub`.`started` > (now() + interval -(1) hour)),`sv`.`litros`,0)) AS `literLastHour`,cast(((60 * sum(`sv`.`litros`)) / time_to_sec(timediff(max(`sub`.`finished`),min(`sub`.`started`)))) as decimal(10,1)) AS `litersByMinute`,`sub`.`code` AS `workerCode`,`sub`.`cajas` AS `cajas`,`sub`.`warehouseFk` AS `warehouseFk` from (`saleVolume` `sv` join `expeditionTimeExpended` `sub` on((`sub`.`ticketFk` = `sv`.`ticketFk`))) group by `workerCode` */;
+/*!50001 VIEW `workerSpeedExpedition` AS select `sv`.`ticketFk` AS `ticketFk`,sum(`sv`.`litros`) AS `litros`,sum(if((`sub`.`started` > (util.VN_NOW() + interval -(1) hour)),`sv`.`litros`,0)) AS `literLastHour`,cast(((60 * sum(`sv`.`litros`)) / time_to_sec(timediff(max(`sub`.`finished`),min(`sub`.`started`)))) as decimal(10,1)) AS `litersByMinute`,`sub`.`code` AS `workerCode`,`sub`.`cajas` AS `cajas`,`sub`.`warehouseFk` AS `warehouseFk` from (`saleVolume` `sv` join `expeditionTimeExpended` `sub` on((`sub`.`ticketFk` = `sv`.`ticketFk`))) group by `workerCode` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -98033,7 +81281,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `workerSpeedSaleTracking` AS select `salesPreparedLastHour`.`warehouseFk` AS `warehouseFk`,`salesPreparedLastHour`.`accion` AS `accion`,`salesPreparedLastHour`.`workerCode` AS `workerCode`,sum(`salesPreparedLastHour`.`litros`) AS `sumaLitros`,min(`salesPreparedLastHour`.`created`) AS `started`,max(`salesPreparedLastHour`.`created`) AS `finished`,sum(if((`salesPreparedLastHour`.`created` >= (now() + interval -(1) hour)),`salesPreparedLastHour`.`litros`,0)) AS `sumaLitrosLastHour`,cast(((60 * sum(`salesPreparedLastHour`.`litros`)) / time_to_sec(timediff(max(`salesPreparedLastHour`.`created`),min(`salesPreparedLastHour`.`created`)))) as decimal(10,1)) AS `litersByMinute`,`salesPreparedLastHour`.`departmentName` AS `departmentName` from `vn`.`salesPreparedLastHour` group by `salesPreparedLastHour`.`warehouseFk`,`salesPreparedLastHour`.`accion`,`salesPreparedLastHour`.`workerCode` */;
+/*!50001 VIEW `workerSpeedSaleTracking` AS select `salesPreparedLastHour`.`warehouseFk` AS `warehouseFk`,`salesPreparedLastHour`.`accion` AS `accion`,`salesPreparedLastHour`.`workerCode` AS `workerCode`,sum(`salesPreparedLastHour`.`litros`) AS `sumaLitros`,min(`salesPreparedLastHour`.`created`) AS `started`,max(`salesPreparedLastHour`.`created`) AS `finished`,sum(if((`salesPreparedLastHour`.`created` >= (util.VN_NOW() + interval -(1) hour)),`salesPreparedLastHour`.`litros`,0)) AS `sumaLitrosLastHour`,cast(((60 * sum(`salesPreparedLastHour`.`litros`)) / time_to_sec(timediff(max(`salesPreparedLastHour`.`created`),min(`salesPreparedLastHour`.`created`)))) as decimal(10,1)) AS `litersByMinute`,`salesPreparedLastHour`.`departmentName` AS `departmentName` from `vn`.`salesPreparedLastHour` group by `salesPreparedLastHour`.`warehouseFk`,`salesPreparedLastHour`.`accion`,`salesPreparedLastHour`.`workerCode` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -98090,26 +81338,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `workerTimeControlWorking` AS select `wtc`.`userFk` AS `userFk`,`wtc`.`timed` AS `timed`,`w`.`firstName` AS `name`,`w`.`lastName` AS `surname`,`pm`.`mediaValue` AS `phone`,`wm`.`mediaValue` AS `workerPhone`,`d`.`name` AS `department`,`wc`.`name` AS `workerCenter`,count(`wtc`.`order`) AS `maxOrder` from (((((((`vn`.`workerTimeControl` `wtc` join `vn`.`worker` `w` on((`w`.`userFk` = `wtc`.`userFk`))) left join `vn`.`personMedia` `pm` on((`pm`.`workerFk` = `w`.`id`))) left join `vn`.`workerMedia` `wm` on((`wm`.`workerFk` = `w`.`id`))) left join `vn`.`workerDepartment` `wd` on((`wd`.`workerFk` = `w`.`id`))) left join `vn`.`department` `d` on((`d`.`id` = `wd`.`departmentFk`))) left join `vn`.`workerLabour` `wl` on((`wl`.`businessFk` = (select `wl2`.`businessFk` from `vn`.`workerLabour` `wl2` where (`wl2`.`workerFk` = `w`.`id`) order by `wl2`.`started` desc limit 1)))) left join `vn`.`workCenter` `wc` on((`wc`.`id` = `wl`.`workCenterFk`))) where (cast(`wtc`.`timed` as date) = curdate()) group by `wtc`.`userFk` having ((`maxOrder` % 2) = 1) order by `wtc`.`timed` desc */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `workerTimeControl_Journey__`
---
-
-/*!50001 DROP TABLE IF EXISTS `workerTimeControl_Journey__`*/;
-/*!50001 DROP VIEW IF EXISTS `workerTimeControl_Journey__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `workerTimeControl_Journey__` AS select `wtc`.`userFk` AS `userFk`,cast(`wtc`.`timed` as date) AS `dated`,cast(sum((if((`wtc`.`order` % 2),-(1),1) * (hour(`wtc`.`timed`) + (minute(`wtc`.`timed`) / 60)))) as decimal(10,2)) AS `Journey`,dayname(`wtc`.`timed`) AS `dayName`,`w`.`lastName` AS `name`,`w`.`firstName` AS `firstname` from (`workerTimeControl` `wtc` join `worker` `w` on((`w`.`userFk` = `wtc`.`userFk`))) group by cast(`wtc`.`timed` as date),`wtc`.`userFk` */;
+/*!50001 VIEW `workerTimeControlWorking` AS select `wtc`.`userFk` AS `userFk`,`wtc`.`timed` AS `timed`,`w`.`firstName` AS `name`,`w`.`lastName` AS `surname`,`pm`.`mediaValue` AS `phone`,`wm`.`mediaValue` AS `workerPhone`,`d`.`name` AS `department`,`wc`.`name` AS `workerCenter`,count(`wtc`.`order`) AS `maxOrder` from (((((((`vn`.`workerTimeControl` `wtc` join `vn`.`worker` `w` on((`w`.`userFk` = `wtc`.`userFk`))) left join `vn`.`personMedia` `pm` on((`pm`.`workerFk` = `w`.`id`))) left join `vn`.`workerMedia` `wm` on((`wm`.`workerFk` = `w`.`id`))) left join `vn`.`workerDepartment` `wd` on((`wd`.`workerFk` = `w`.`id`))) left join `vn`.`department` `d` on((`d`.`id` = `wd`.`departmentFk`))) left join `vn`.`workerLabour` `wl` on((`wl`.`businessFk` = (select `wl2`.`businessFk` from `vn`.`workerLabour` `wl2` where (`wl2`.`workerFk` = `w`.`id`) order by `wl2`.`started` desc limit 1)))) left join `vn`.`workCenter` `wc` on((`wc`.`id` = `wl`.`workCenterFk`))) where (cast(`wtc`.`timed` as date) = util.VN_CURDATE()) group by `wtc`.`userFk` having ((`maxOrder` % 2) = 1) order by `wtc`.`timed` desc */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -98133,25 +81362,6 @@ USE `vn`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
---
--- Final view structure for view `workerWithoutDevice__`
---
-
-/*!50001 DROP TABLE IF EXISTS `workerWithoutDevice__`*/;
-/*!50001 DROP VIEW IF EXISTS `workerWithoutDevice__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `workerWithoutDevice__` AS select `c`.`workerFk` AS `workerFk`,`cl`.`name` AS `Trabajador`,count(distinct `c`.`id`) AS `Colecciones` from ((`collection` `c` join `client` `cl` on((`cl`.`id` = `c`.`workerFk`))) left join `deviceProductionUser` `dpu` on((`dpu`.`userFk` = `c`.`workerFk`))) where ((`c`.`created` > curdate()) and isnull(`dpu`.`userFk`)) group by `c`.`workerFk` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
--
-- Final view structure for view `workerWithoutTractor`
--
@@ -98166,7 +81376,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `workerWithoutTractor` AS select `c`.`workerFk` AS `workerFk`,`cl`.`name` AS `Trabajador`,count(distinct `c`.`id`) AS `Colecciones`,max(`c`.`created`) AS `created` from ((`collection` `c` join `client` `cl` on((`cl`.`id` = `c`.`workerFk`))) left join `machineWorker` `mw` on(((`mw`.`workerFk` = `c`.`workerFk`) and (`mw`.`inTimed` > curdate())))) where ((`c`.`created` > curdate()) and isnull(`mw`.`workerFk`)) group by `c`.`workerFk` */;
+/*!50001 VIEW `workerWithoutTractor` AS select `c`.`workerFk` AS `workerFk`,`cl`.`name` AS `Trabajador`,count(distinct `c`.`id`) AS `Colecciones`,max(`c`.`created`) AS `created` from ((`collection` `c` join `client` `cl` on((`cl`.`id` = `c`.`workerFk`))) left join `machineWorker` `mw` on(((`mw`.`workerFk` = `c`.`workerFk`) and (`mw`.`inTimed` > util.VN_CURDATE())))) where ((`c`.`created` > util.VN_CURDATE()) and isnull(`mw`.`workerFk`)) group by `c`.`workerFk` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -98185,26 +81395,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `zoneEstimatedDelivery` AS select `t`.`zoneFk` AS `zoneFk`,cast((curdate() + interval ((hour(ifnull(`zc`.`hour`,`z`.`hour`)) * 60) + minute(ifnull(`zc`.`hour`,`z`.`hour`))) minute) as time) AS `hourTheoretical`,cast(sum(`sv`.`volume`) as decimal(5,1)) AS `totalVolume`,cast(sum(if((`s`.`alertLevel` < 2),`sv`.`volume`,0)) as decimal(5,1)) AS `remainingVolume`,greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0)) AS `speed`,cast((`zc`.`hour` + interval ((-(sum(if((`s`.`alertLevel` < 2),`sv`.`volume`,0))) * 60) / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0))) minute) as time) AS `hourEffective`,floor(((-(sum(if((`s`.`alertLevel` < 2),`sv`.`volume`,0))) * 60) / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0)))) AS `minutesLess`,cast((`zc`.`hour` + interval ((-(sum(if((`s`.`alertLevel` < 2),`sv`.`volume`,0))) * 60) / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0))) minute) as time) AS `etc` from (((((((((`vn`.`ticket` `t` join `vn`.`ticketStateToday` `tst` on((`tst`.`ticket` = `t`.`id`))) join `vn`.`state` `s` on((`s`.`id` = `tst`.`state`))) join `vn`.`saleVolume` `sv` on((`sv`.`ticketFk` = `t`.`id`))) left join `vn`.`lastHourProduction` `lhp` on((`lhp`.`warehouseFk` = `t`.`warehouseFk`))) join `vn`.`warehouse` `w` on((`w`.`id` = `t`.`warehouseFk`))) join `vn`.`warehouseAlias` `wa` on((`wa`.`id` = `w`.`aliasFk`))) join `vn`.`zone` `z` on((`z`.`id` = `t`.`zoneFk`))) left join `vn`.`zoneClosure` `zc` on(((`zc`.`zoneFk` = `t`.`zoneFk`) and (`zc`.`dated` = curdate())))) left join `cache`.`departure_limit` `dl` on(((`dl`.`warehouse_id` = `t`.`warehouseFk`) and (`dl`.`fecha` = curdate())))) where (`w`.`hasProduction` and (cast(`t`.`shipped` as date) = curdate())) group by `t`.`zoneFk` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `zone_ETD__`
---
-
-/*!50001 DROP TABLE IF EXISTS `zone_ETD__`*/;
-/*!50001 DROP VIEW IF EXISTS `zone_ETD__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `zone_ETD__` AS select `zed`.`zoneFk` AS `zoneFk`,`zed`.`hourTheoretical` AS `HoraTeórica`,`zed`.`totalVolume` AS `volumenTotal`,`zed`.`remainingVolume` AS `volumenPendiente`,`zed`.`speed` AS `velocidad`,`zed`.`hourEffective` AS `HoraPráctica`,`zed`.`minutesLess` AS `minutesLess`,`zed`.`etc` AS `etc` from `vn`.`zoneEstimatedDelivery` `zed` */;
+/*!50001 VIEW `zoneEstimatedDelivery` AS select `t`.`zoneFk` AS `zoneFk`,cast((util.VN_CURDATE() + interval ((hour(ifnull(`zc`.`hour`,`z`.`hour`)) * 60) + minute(ifnull(`zc`.`hour`,`z`.`hour`))) minute) as time) AS `hourTheoretical`,cast(sum(`sv`.`volume`) as decimal(5,1)) AS `totalVolume`,cast(sum(if((`s`.`alertLevel` < 2),`sv`.`volume`,0)) as decimal(5,1)) AS `remainingVolume`,greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0)) AS `speed`,cast((`zc`.`hour` + interval ((-(sum(if((`s`.`alertLevel` < 2),`sv`.`volume`,0))) * 60) / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0))) minute) as time) AS `hourEffective`,floor(((-(sum(if((`s`.`alertLevel` < 2),`sv`.`volume`,0))) * 60) / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0)))) AS `minutesLess`,cast((`zc`.`hour` + interval ((-(sum(if((`s`.`alertLevel` < 2),`sv`.`volume`,0))) * 60) / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0))) minute) as time) AS `etc` from (((((((((`vn`.`ticket` `t` join `vn`.`ticketStateToday` `tst` on((`tst`.`ticket` = `t`.`id`))) join `vn`.`state` `s` on((`s`.`id` = `tst`.`state`))) join `vn`.`saleVolume` `sv` on((`sv`.`ticketFk` = `t`.`id`))) left join `vn`.`lastHourProduction` `lhp` on((`lhp`.`warehouseFk` = `t`.`warehouseFk`))) join `vn`.`warehouse` `w` on((`w`.`id` = `t`.`warehouseFk`))) join `vn`.`warehouseAlias` `wa` on((`wa`.`id` = `w`.`aliasFk`))) join `vn`.`zone` `z` on((`z`.`id` = `t`.`zoneFk`))) left join `vn`.`zoneClosure` `zc` on(((`zc`.`zoneFk` = `t`.`zoneFk`) and (`zc`.`dated` = util.VN_CURDATE())))) left join `cache`.`departure_limit` `dl` on(((`dl`.`warehouse_id` = `t`.`warehouseFk`) and (`dl`.`fecha` = util.VN_CURDATE())))) where (`w`.`hasProduction` and (cast(`t`.`shipped` as date) = util.VN_CURDATE())) group by `t`.`zoneFk` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -98224,4 +81415,4 @@ USE `vncontrol`;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2022-05-04 15:56:23
+-- Dump completed on 2022-06-23 12:12:10
diff --git a/db/export-data.sh b/db/export-data.sh
index 900e630f7..bbbeb7152 100755
--- a/db/export-data.sh
+++ b/db/export-data.sh
@@ -65,6 +65,7 @@ TABLES=(
ticketUpdateAction
time
volumeConfig
+ workCenter
)
dump_tables ${TABLES[@]}
@@ -101,7 +102,6 @@ TABLES=(
media_type
professional_category
profile_type
- workcenter
)
dump_tables ${TABLES[@]}
@@ -111,4 +111,4 @@ TABLES=(
TiposTransacciones
TiposRetencion
)
-dump_tables ${TABLES[@]}
\ No newline at end of file
+dump_tables ${TABLES[@]}
diff --git a/db/export-structure.sh b/db/export-structure.sh
index 9b23f43ac..88508f098 100755
--- a/db/export-structure.sh
+++ b/db/export-structure.sh
@@ -96,5 +96,12 @@ mysqldump \
--databases \
${SCHEMAS[@]} \
${IGNORETABLES[@]} \
+ | sed 's/\bCURDATE\b/util.VN_CURDATE/ig'\
+ | sed 's/\bCURTIME\b/util.VN_CURTIME/ig' \
+ | sed 's/\bNOW\b/util.VN_NOW/ig' \
+ | sed 's/\bCURRENT_DATE\b/util.VN_CURDATE/ig' \
+ | sed 's/\bCURRENT_TIME\b/util.VN_CURTIME/ig' \
+ | sed 's/\bLOCALTIME\b/util.VN_NOW/ig' \
+ | sed 's/\bLOCALTIMESTAMP\b/util.VN_NOW/ig' \
| sed 's/ AUTO_INCREMENT=[0-9]* //g' \
- > dump/structure.sql
+ > dump/structure.sql
\ No newline at end of file
diff --git a/db/tests/vn/zone_getLanded.spec.js b/db/tests/vn/zone_getLanded.spec.js
index 6673879e4..5f82156d3 100644
--- a/db/tests/vn/zone_getLanded.spec.js
+++ b/db/tests/vn/zone_getLanded.spec.js
@@ -5,8 +5,9 @@ describe('zone zone_getLanded()', () => {
it(`should return data for a shipped in the past`, async() => {
let stmts = [];
let stmt;
-
stmts.push('START TRANSACTION');
+ const date = new Date();
+ date.setHours(0, 0, 0, 0);
let params = {
addressFk: 121,
@@ -14,7 +15,8 @@ describe('zone zone_getLanded()', () => {
warehouseFk: 1,
showExpiredZones: true};
- stmt = new ParameterizedSQL('CALL zone_getLanded(DATE_ADD(CURDATE(), INTERVAL -1 DAY), ?, ?, ?, ?)', [
+ stmt = new ParameterizedSQL('CALL zone_getLanded(DATE_ADD(?, INTERVAL -1 DAY), ?, ?, ?, ?)', [
+ date,
params.addressFk,
params.agencyModeFk,
params.warehouseFk,
@@ -38,6 +40,8 @@ describe('zone zone_getLanded()', () => {
it(`should return data for a shipped tomorrow`, async() => {
let stmts = [];
let stmt;
+ const date = new Date();
+ date.setHours(0, 0, 0, 0);
stmts.push('START TRANSACTION');
@@ -47,7 +51,8 @@ describe('zone zone_getLanded()', () => {
warehouseFk: 1,
showExpiredZones: false};
- stmt = new ParameterizedSQL('CALL zone_getLanded(DATE_ADD(CURDATE(), INTERVAL +2 DAY), ?, ?, ?, ?)', [
+ stmt = new ParameterizedSQL('CALL zone_getLanded(DATE_ADD(?, INTERVAL +2 DAY), ?, ?, ?, ?)', [
+ date,
params.addressFk,
params.agencyModeFk,
params.warehouseFk,
diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js
index 770911d0e..37f7308a5 100644
--- a/e2e/helpers/selectors.js
+++ b/e2e/helpers/selectors.js
@@ -55,6 +55,7 @@ export default {
setPassword: '.vn-menu [name="setPassword"]',
activateAccount: '.vn-menu [name="enableAccount"]',
activateUser: '.vn-menu [name="activateUser"]',
+ deactivateUser: '.vn-menu [name="deactivateUser"]',
newPassword: 'vn-textfield[ng-model="$ctrl.newPassword"]',
repeatPassword: 'vn-textfield[ng-model="$ctrl.repeatPassword"]',
newRole: 'vn-autocomplete[ng-model="$ctrl.newRole"]',
@@ -275,6 +276,7 @@ export default {
clientWebAccess: {
enableWebAccessCheckbox: 'vn-check[label="Enable web access"]',
userName: 'vn-client-web-access vn-textfield[ng-model="$ctrl.account.name"]',
+ email: 'vn-client-web-access vn-textfield[ng-model="$ctrl.account.email"]',
saveButton: 'button[type=submit]'
},
clientNotes: {
@@ -542,7 +544,8 @@ export default {
searchResultDate: 'vn-ticket-summary [label=Landed] span',
topbarSearch: 'vn-searchbar',
moreMenu: 'vn-ticket-index vn-icon-button[icon=more_vert]',
- sixthWeeklyTicket: 'vn-ticket-weekly-index vn-table vn-tr:nth-child(6)',
+ fourthWeeklyTicket: 'vn-ticket-weekly-index vn-table vn-tbody vn-tr:nth-child(4)',
+ fiveWeeklyTicket: 'vn-ticket-weekly-index vn-table vn-tbody vn-tr:nth-child(5)',
weeklyTicket: 'vn-ticket-weekly-index vn-table > div > vn-tbody > vn-tr',
firstWeeklyTicketDeleteIcon: 'vn-ticket-weekly-index vn-tr:nth-child(1) vn-icon-button[icon="delete"]',
firstWeeklyTicketAgency: 'vn-ticket-weekly-index vn-tr:nth-child(1) [ng-model="weekly.agencyModeFk"]',
@@ -562,8 +565,6 @@ export default {
isDeletedIcon: 'vn-ticket-descriptor vn-icon[icon="icon-deletedTicket"]',
goBackToModuleIndexButton: 'vn-ticket-descriptor a[ui-sref="ticket.index"]',
moreMenu: 'vn-ticket-descriptor vn-ticket-descriptor-menu > vn-icon-button[icon=more_vert]',
- moreMenuAddStowaway: '.vn-menu [name="addStowaway"]',
- moreMenuDeleteStowawayButton: '.vn-menu [name="deleteStowaway"]',
moreMenuAddToTurn: '.vn-menu [name="addTurn"]',
moreMenuDeleteTicket: '.vn-menu [name="deleteTicket"]',
moreMenuRestoreTicket: '.vn-menu [name="restoreTicket"]',
@@ -576,8 +577,6 @@ export default {
sendSMSbutton: 'button[response="accept"]',
changeShippedHourDialog: '.vn-dialog.shown',
changeShippedHour: '.vn-dialog.shown vn-input-time[ng-model="$ctrl.newShipped"]',
- addStowawayDialogFirstTicket: '.vn-dialog.shown vn-table vn-tbody vn-tr',
- shipButton: 'vn-ticket-descriptor vn-icon[icon="icon-stowaway"]',
thursdayButton: '.vn-popup.shown vn-tool-bar > vn-button:nth-child(4)',
saturdayButton: '.vn-popup.shown vn-tool-bar > vn-button:nth-child(6)',
acceptDialog: '.vn-dialog.shown button[response="accept"]',
@@ -585,7 +584,6 @@ export default {
descriptorDeliveryDate: 'vn-ticket-descriptor slot-body > .attributes > vn-label-value:nth-child(4) > section > span',
descriptorDeliveryAgency: 'vn-ticket-descriptor slot-body > .attributes > vn-label-value:nth-child(5) > section > span',
acceptInvoiceOutButton: '.vn-confirm.shown button[response="accept"]',
- acceptDeleteStowawayButton: '.vn-dialog.shown button[response="accept"]'
},
ticketNotes: {
firstNoteRemoveButton: 'vn-icon[icon="delete"]',
@@ -595,7 +593,7 @@ export default {
submitNotesButton: 'button[type=submit]'
},
ticketExpedition: {
- secondExpeditionRemoveButton: 'vn-ticket-expedition vn-table div > vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(1) > vn-icon-button[icon="delete"]',
+ thirdExpeditionRemoveButton: 'vn-ticket-expedition vn-table div > vn-tbody > vn-tr:nth-child(3) > vn-td:nth-child(1) > vn-icon-button[icon="delete"]',
expeditionRow: 'vn-ticket-expedition vn-table vn-tbody > vn-tr'
},
ticketPackages: {
@@ -727,7 +725,7 @@ export default {
claimSummary: {
header: 'vn-claim-summary > vn-card > h5',
state: 'vn-claim-summary vn-label-value[label="State"] > section > span',
- observation: 'vn-claim-summary vn-textarea[ng-model="$ctrl.summary.claim.observation"]',
+ observation: 'vn-claim-summary vn-horizontal.text',
firstSaleItemId: 'vn-claim-summary vn-horizontal > vn-auto:nth-child(5) vn-table > div > vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(1) > span',
firstSaleDescriptorImage: '.vn-popover.shown vn-item-descriptor img',
itemDescriptorPopover: '.vn-popover.shown vn-item-descriptor',
@@ -739,7 +737,6 @@ export default {
},
claimBasicData: {
claimState: 'vn-claim-basic-data vn-autocomplete[ng-model="$ctrl.claim.claimStateFk"]',
- observation: 'vn-textarea[ng-model="$ctrl.claim.observation"]',
packages: 'vn-input-number[ng-model="$ctrl.claim.packages"]',
hasToPickUpCheckbox: 'vn-claim-basic-data vn-check[ng-model="$ctrl.claim.hasToPickUp"]',
saveButton: `button[type=submit]`
@@ -769,6 +766,12 @@ export default {
secondClaimRedelivery: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.claimRedeliveryFk"]',
saveDevelopmentButton: 'button[type=submit]'
},
+ claimNote: {
+ addNoteFloatButton: 'vn-float-button',
+ note: 'vn-textarea[ng-model="$ctrl.note.text"]',
+ saveButton: 'button[type=submit]',
+ firstNoteText: 'vn-claim-note .text'
+ },
claimAction: {
importClaimButton: 'vn-claim-action vn-button[label="Import claim"]',
anyLine: 'vn-claim-action vn-tbody > vn-tr',
@@ -903,52 +906,16 @@ export default {
dialogTimeInput: '.vn-dialog.shown vn-input-time[ng-model="$ctrl.newTimeEntry.timed"]',
dialogTimeDirection: '.vn-dialog.shown vn-autocomplete[ng-model="$ctrl.newTimeEntry.direction"]',
mondayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(1) > vn-icon-button',
- tuesdayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(2) > vn-icon-button',
- wednesdayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(3) > vn-icon-button',
- thursdayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(4) > vn-icon-button',
- fridayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(5) > vn-icon-button',
- saturdayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(6) > vn-icon-button',
- sundayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(7) > vn-icon-button',
firstEntryOfMonday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(1) > vn-chip > div:nth-child(2)',
- firstEntryOfTuesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(1) > vn-chip > div:nth-child(2)',
- firstEntryOfWednesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(1) > vn-chip > div:nth-child(2)',
- firstEntryOfThursday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(1) > vn-chip > div:nth-child(2)',
- firstEntryOfFriday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(1) > vn-chip > div:nth-child(2)',
- firstEntryOfSaturday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(1) > vn-chip > div:nth-child(2)',
- firstEntryOfSunday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(1) > vn-chip > div:nth-child(2)',
+ firstEntryOfMondayDelete: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(1) > vn-chip > vn-icon[icon="cancel"]',
secondEntryOfMonday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(2) > vn-chip > div:nth-child(2)',
- secondEntryOfTuesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(2) > vn-chip > div:nth-child(2)',
- secondEntryOfWednesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(2) > vn-chip > div:nth-child(2)',
- secondEntryOfThursday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(2) > vn-chip > div:nth-child(2)',
- secondEntryOfFriday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(2) > vn-chip > div:nth-child(2)',
- secondEntryOfSaturday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(2) > vn-chip > div:nth-child(2)',
- secondEntryOfSunday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(2) > vn-chip > div:nth-child(2)',
- thirdEntryOfMonday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(3) > vn-chip > div:nth-child(2)',
- thirdEntryOfMondayDelete: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(3) > vn-chip > vn-icon[icon="cancel"]',
- thirdEntryOfTuesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(3) > vn-chip > div:nth-child(2)',
- thirdEntryOfWednesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(3) > vn-chip > div:nth-child(2)',
- thirdEntryOfThursday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(3) > vn-chip > div:nth-child(2)',
- thirdEntryOfFriday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(3) > vn-chip > div:nth-child(2)',
- thirdEntryOfSaturday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(3) > vn-chip > div:nth-child(2)',
- thirdEntryOfSunday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(3) > vn-chip > div:nth-child(2)',
- fourthEntryOfMonday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(4) > vn-chip > div:nth-child(2)',
- fourthEntryOfTuesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(4) > vn-chip > div:nth-child(2)',
- fourthEntryOfWednesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(4) > vn-chip > div:nth-child(2)',
- fourthEntryOfThursday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(4) > vn-chip > div:nth-child(2)',
- fourthEntryOfFriday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(4) > vn-chip > div:nth-child(2)',
- fourthEntryOfSaturday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(4) > vn-chip > div:nth-child(2)',
- fourthEntryOfSunday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(4) > vn-chip > div:nth-child(2)',
mondayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(1)',
- tuesdayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(2)',
- wednesdayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(3)',
- thursdayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(4)',
- fridayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(5)',
- saturdayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(6)',
- sundayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(7)',
weekWorkedHours: 'vn-worker-time-control vn-side-menu vn-label-value > section > span',
nextMonthButton: 'vn-worker-time-control vn-side-menu vn-calendar vn-button[icon=keyboard_arrow_right]',
previousMonthButton: 'vn-worker-time-control vn-side-menu vn-calendar vn-button[icon=keyboard_arrow_left]',
+ monthName: 'vn-worker-time-control vn-side-menu vn-calendar div > .title',
secondWeekDay: 'vn-worker-time-control vn-side-menu vn-calendar .day:nth-child(8) > .day-number',
+ thrirdWeekDay: 'vn-worker-time-control vn-side-menu vn-calendar .day:nth-child(15) > .day-number',
navigateBackToIndex: 'vn-worker-descriptor [name="goToModuleIndex"]'
},
workerCalendar: {
@@ -1135,7 +1102,7 @@ export default {
company: 'vn-entry-basic-data vn-autocomplete[ng-model="$ctrl.entry.companyFk"]',
ordered: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isOrdered"]',
confirmed: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isConfirmed"]',
- inventory: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isInventory"]',
+ inventory: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isExcludedFromAvailable"]',
raid: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isRaid"]',
booked: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isBooked"]',
save: 'vn-entry-basic-data button[type=submit]',
diff --git a/e2e/paths/02-client/03_edit_fiscal_data.spec.js b/e2e/paths/02-client/03_edit_fiscal_data.spec.js
index 4ae1d4eca..2a56cb535 100644
--- a/e2e/paths/02-client/03_edit_fiscal_data.spec.js
+++ b/e2e/paths/02-client/03_edit_fiscal_data.spec.js
@@ -276,7 +276,7 @@ describe('Client Edit fiscalData path', () => {
// confirm invoice by address checkbox gets checked if the EQtax differs between addresses step 2
it(`should click on the 1st edit icon to access the address details and uncheck EQtax checkbox`, async() => {
await page.waitToClick(selectors.clientAddresses.firstEditAddress);
- await page.waitForTextInField(selectors.clientAddresses.city, 'Silla');
+ await page.waitForTextInField(selectors.clientAddresses.city, 'Gotham');
await page.waitToClick(selectors.clientAddresses.equalizationTaxCheckbox);
await page.waitToClick(selectors.clientAddresses.saveButton);
const message = await page.waitForSnackbar();
diff --git a/e2e/paths/02-client/05_add_address.spec.js b/e2e/paths/02-client/05_add_address.spec.js
index c35237ab4..0581635d0 100644
--- a/e2e/paths/02-client/05_add_address.spec.js
+++ b/e2e/paths/02-client/05_add_address.spec.js
@@ -45,7 +45,7 @@ describe('Client Add address path', () => {
expect(province).toContain('Province five');
});
- it(`should receive an error after clicking save button as consignee, incoterms and customsAgent are empty`, async() => {
+ it(`should throw after clicking save button as consignee, incoterms and customsAgent are empty`, async() => {
await page.write(selectors.clientAddresses.consignee, 'Bruce Bunner');
await page.write(selectors.clientAddresses.streetAddress, '320 Park Avenue New York');
await page.waitToClick(selectors.clientAddresses.saveButton);
diff --git a/e2e/paths/02-client/07_edit_web_access.spec.js b/e2e/paths/02-client/07_edit_web_access.spec.js
index bcd476f6b..8d8036373 100644
--- a/e2e/paths/02-client/07_edit_web_access.spec.js
+++ b/e2e/paths/02-client/07_edit_web_access.spec.js
@@ -1,3 +1,4 @@
+/* eslint max-len: ["error", { "code": 150 }]*/
import selectors from '../../helpers/selectors';
import getBrowser from '../../helpers/puppeteer';
@@ -8,7 +9,7 @@ describe('Client Edit web access path', () => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('employee', 'client');
- await page.accessToSearchResult('Bruce Banner');
+ await page.accessToSearchResult('max');
await page.accessToSection('client.card.webAccess');
});
@@ -26,7 +27,16 @@ describe('Client Edit web access path', () => {
it(`should update the name`, async() => {
await page.clearInput(selectors.clientWebAccess.userName);
- await page.write(selectors.clientWebAccess.userName, 'Hulk');
+ await page.write(selectors.clientWebAccess.userName, 'Legion');
+ await page.waitToClick(selectors.clientWebAccess.saveButton);
+ const message = await page.waitForSnackbar();
+
+ expect(message.text).toContain('Data saved!');
+ });
+
+ it(`should update the email`, async() => {
+ await page.clearInput(selectors.clientWebAccess.email);
+ await page.write(selectors.clientWebAccess.email, 'legion@marvel.com');
await page.waitToClick(selectors.clientWebAccess.saveButton);
const message = await page.waitForSnackbar();
@@ -43,30 +53,36 @@ describe('Client Edit web access path', () => {
it('should confirm web access name have been updated', async() => {
const result = await page.waitToGetProperty(selectors.clientWebAccess.userName, 'value');
- expect(result).toEqual('Hulk');
+ expect(result).toEqual('Legion');
+ });
+
+ it('should confirm web access email have been updated', async() => {
+ const result = await page.waitToGetProperty(selectors.clientWebAccess.email, 'value');
+
+ expect(result).toEqual('legion@marvel.com');
});
it(`should navigate to the log section`, async() => {
await page.accessToSection('client.card.log');
});
- it(`should confirm the last log is showing the updated client name and no modifications on the active checkbox`, async() => {
+ it(`should confirm the last log shows the updated client name and no modifications on active checkbox`, async() => {
let lastModificationPreviousValue = await page
.waitToGetProperty(selectors.clientLog.lastModificationPreviousValue, 'innerText');
let lastModificationCurrentValue = await page
.waitToGetProperty(selectors.clientLog.lastModificationCurrentValue, 'innerText');
- expect(lastModificationPreviousValue).toEqual('name BruceBanner active false');
- expect(lastModificationCurrentValue).toEqual('name Hulk active false');
+ expect(lastModificationPreviousValue).toEqual('name MaxEisenhardt active false');
+ expect(lastModificationCurrentValue).toEqual('name Legion active false');
});
- it(`should confirm the penultimate log is showing the updated avtive field and no modifications on the client name`, async() => {
+ it(`should confirm the penultimate log shows the updated active and no modifications on client name`, async() => {
let penultimateModificationPreviousValue = await page
.waitToGetProperty(selectors.clientLog.penultimateModificationPreviousValue, 'innerText');
let penultimateModificationCurrentValue = await page
.waitToGetProperty(selectors.clientLog.penultimateModificationCurrentValue, 'innerText');
- expect(penultimateModificationPreviousValue).toEqual('name BruceBanner active true');
- expect(penultimateModificationCurrentValue).toEqual('name BruceBanner active false');
+ expect(penultimateModificationPreviousValue).toEqual('name MaxEisenhardt active true');
+ expect(penultimateModificationCurrentValue).toEqual('name MaxEisenhardt active false');
});
});
diff --git a/e2e/paths/03-worker/04_time_control.spec.js b/e2e/paths/03-worker/04_time_control.spec.js
index 5709e6207..be8df3cf0 100644
--- a/e2e/paths/03-worker/04_time_control.spec.js
+++ b/e2e/paths/03-worker/04_time_control.spec.js
@@ -1,3 +1,4 @@
+/* eslint max-len: ["error", { "code": 150 }]*/
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
@@ -10,414 +11,105 @@ describe('Worker time control path', () => {
await page.loginAndModule('salesBoss', 'worker');
await page.accessToSearchResult('HankPym');
await page.accessToSection('worker.card.timeControl');
- await page.waitToClick(selectors.workerTimeControl.previousMonthButton);
- await page.waitToClick(selectors.workerTimeControl.secondWeekDay);
});
afterAll(async() => {
await browser.close();
});
- describe('as salesBoss', () => {
- describe('on Monday', () => {
- it('should scan in Hank Pym', async() => {
- const scanTime = '07:00';
+ const eightAm = '08:00';
+ const fourPm = '16:00';
+ const hankPymId = 1107;
- await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
- await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
- await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in');
- await page.respondToDialog('accept');
- const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfMonday, 'innerText');
+ it('should go to the next month', async() => {
+ const date = new Date();
+ date.setMonth(date.getMonth() + 1);
+ const month = date.toLocaleString('default', {month: 'long'});
- expect(result).toEqual(scanTime);
- });
+ await page.waitToClick(selectors.workerTimeControl.nextMonthButton);
+ const result = await page.waitToGetProperty(selectors.workerTimeControl.monthName, 'innerText');
- it(`should scan out Hank Pym for break`, async() => {
- const scanTime = '10:00';
-
- await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
- await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
- await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate');
- await page.respondToDialog('accept');
- const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfMonday, 'innerText');
-
- expect(result).toEqual(scanTime);
- });
-
- it(`should scan in Hank Pym for a wrong hour and forget to scan in from the break`, async() => {
- const scanTime = '18:00';
-
- await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
- await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
- await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate');
- await page.respondToDialog('accept');
- const result = await page.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfMonday, 'innerText');
-
- expect(result).toEqual(scanTime);
- });
-
- it(`should delete the wrong entry for Hank Pym`, async() => {
- const wrongScanTime = '18:00';
-
- await page.waitForTextInElement(selectors.workerTimeControl.thirdEntryOfMonday, wrongScanTime);
- await page.waitToClick(selectors.workerTimeControl.thirdEntryOfMondayDelete);
- await page.respondToDialog('accept');
- const message = await page.waitForSnackbar();
-
- expect(message.text).toContain('Entry removed');
- });
-
- it(`should scan out Hank Pym to leave early`, async() => {
- const scanTime = '14:00';
-
- await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
- await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
- await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out');
- await page.respondToDialog('accept');
- const result = await page.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfMonday, 'innerText');
-
- expect(result).toEqual(scanTime);
- });
-
- it(`should add the break's scan in for Hank Pym and be in the right order`, async() => {
- const scanTime = '10:20';
-
- await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
- await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
- await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate');
- await page.respondToDialog('accept');
- const result = await page.waitToGetProperty(selectors.workerTimeControl.fourthEntryOfMonday, 'innerText');
-
- expect(result).toEqual('14:00');
- });
-
- it(`should the third entry be the scan in from break`, async() => {
- const scanTime = '10:20';
-
- const result = await page
- .waitToGetProperty(selectors.workerTimeControl.thirdEntryOfMonday, 'innerText');
-
- expect(result).toEqual(scanTime);
- });
-
- it(`should check Hank Pym worked 6:40 hours`, async() => {
- await page.waitForTextInElement(selectors.workerTimeControl.mondayWorkedHours, '06:40 h.');
- });
- });
-
- describe('on Tuesday', () => {
- it('should happily scan in Hank Pym', async() => {
- const scanTime = '08:00';
-
- await page.waitToClick(selectors.workerTimeControl.tuesdayAddTimeButton);
- await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
- await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in');
- await page.respondToDialog('accept');
- const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfTuesday, 'innerText');
-
- expect(result).toEqual(scanTime);
- });
-
- it(`should happily scan out Hank Pym for break`, async() => {
- const scanTime = '10:00';
-
- await page.waitToClick(selectors.workerTimeControl.tuesdayAddTimeButton);
- await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
- await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate');
- await page.respondToDialog('accept');
- const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfTuesday, 'innerText');
-
- expect(result).toEqual(scanTime);
- });
-
- it(`should happily scan in Hank Pym from the break`, async() => {
- const scanTime = '10:20';
-
- await page.waitToClick(selectors.workerTimeControl.tuesdayAddTimeButton);
- await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
- await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate');
- await page.respondToDialog('accept');
- const result = await page.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfTuesday, 'innerText');
-
- expect(result).toEqual(scanTime);
- });
-
- it(`should happily scan out Hank Pym for the day`, async() => {
- const scanTime = '16:00';
-
- await page.waitToClick(selectors.workerTimeControl.tuesdayAddTimeButton);
- await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
- await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out');
- await page.respondToDialog('accept');
- const result = await page.waitToGetProperty(selectors.workerTimeControl.fourthEntryOfTuesday, 'innerText');
-
- expect(result).toEqual(scanTime);
- });
-
- it(`should check Hank Pym worked 7:40 hours`, async() => {
- await page.waitForTextInElement(selectors.workerTimeControl.tuesdayWorkedHours, '07:40 h.');
- });
- });
-
- describe('on Wednesday', () => {
- it('should cheerfully scan in Hank Pym', async() => {
- const scanTime = '09:00';
-
- await page.waitToClick(selectors.workerTimeControl.wednesdayAddTimeButton);
- await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
- await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in');
- await page.respondToDialog('accept');
- const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfWednesday, 'innerText');
-
- expect(result).toEqual(scanTime);
- });
-
- it(`should cheerfully scan out Hank Pym for break`, async() => {
- const scanTime = '10:00';
-
- await page.waitToClick(selectors.workerTimeControl.wednesdayAddTimeButton);
- await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
- await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate');
- await page.respondToDialog('accept');
- const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfWednesday, 'innerText');
-
- expect(result).toEqual(scanTime);
- });
-
- it(`should cheerfully scan in Hank Pym from the break`, async() => {
- const scanTime = '10:20';
-
- await page.waitToClick(selectors.workerTimeControl.wednesdayAddTimeButton);
- await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
- await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate');
- await page.respondToDialog('accept');
- const result = await page.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfWednesday, 'innerText');
-
- expect(result).toEqual(scanTime);
- });
-
- it(`should cheerfully scan out Hank Pym for the day`, async() => {
- const scanTime = '17:00';
-
- await page.waitToClick(selectors.workerTimeControl.wednesdayAddTimeButton);
- await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
- await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out');
- await page.respondToDialog('accept');
- const result = await page.waitToGetProperty(selectors.workerTimeControl.fourthEntryOfWednesday, 'innerText');
-
- expect(result).toEqual(scanTime);
- });
-
- it(`should check Hank Pym worked 7:40 cheerfull hours`, async() => {
- await page.waitForTextInElement(selectors.workerTimeControl.wednesdayWorkedHours, '07:40 h.');
- });
- });
-
- describe('on Thursday', () => {
- it('should joyfully scan in Hank Pym', async() => {
- const scanTime = '09:59';
-
- await page.waitToClick(selectors.workerTimeControl.thursdayAddTimeButton);
- await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
- await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in');
- await page.respondToDialog('accept');
- const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfThursday, 'innerText');
-
- expect(result).toEqual(scanTime);
- });
-
- it(`should joyfully scan out Hank Pym for break`, async() => {
- const scanTime = '10:00';
- await page.waitToClick(selectors.workerTimeControl.thursdayAddTimeButton);
- await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
- await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate');
- await page.respondToDialog('accept');
- const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfThursday, 'innerText');
-
- expect(result).toEqual(scanTime);
- });
-
- it(`should joyfully scan in Hank Pym from the break`, async() => {
- const scanTime = '10:20';
- await page.waitToClick(selectors.workerTimeControl.thursdayAddTimeButton);
- await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
- await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate');
- await page.respondToDialog('accept');
- const result = await page.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfThursday, 'innerText');
-
- expect(result).toEqual(scanTime);
- });
-
- it(`should joyfully scan out Hank Pym for the day`, async() => {
- const scanTime = '17:59';
- await page.waitToClick(selectors.workerTimeControl.thursdayAddTimeButton);
- await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
- await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out');
- await page.respondToDialog('accept');
- const result = await page.waitToGetProperty(selectors.workerTimeControl.fourthEntryOfThursday, 'innerText');
-
- expect(result).toEqual(scanTime);
- });
-
- it(`should check Hank Pym worked 7:40 joyfull hours`, async() => {
- await page.waitForTextInElement(selectors.workerTimeControl.thursdayWorkedHours, '07:40 h.');
- });
- });
-
- describe('on Friday', () => {
- it('should smilingly scan in Hank Pym', async() => {
- const scanTime = '07:30';
- await page.waitToClick(selectors.workerTimeControl.fridayAddTimeButton);
- await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
- await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in');
- await page.respondToDialog('accept');
- const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfFriday, 'innerText');
-
- expect(result).toEqual(scanTime);
- });
-
- it(`should smilingly scan out Hank Pym for break`, async() => {
- const scanTime = '10:00';
- await page.waitToClick(selectors.workerTimeControl.fridayAddTimeButton);
- await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
- await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate');
- await page.respondToDialog('accept');
- const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfFriday, 'innerText');
-
- expect(result).toEqual(scanTime);
- });
-
- it(`should smilingly scan in Hank Pym from the break`, async() => {
- const scanTime = '10:20';
- await page.waitToClick(selectors.workerTimeControl.fridayAddTimeButton);
- await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
- await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate');
- await page.respondToDialog('accept');
- const result = await page.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfFriday, 'innerText');
-
- expect(result).toEqual(scanTime);
- });
-
- it(`should smilingly scan out Hank Pym for the day`, async() => {
- const scanTime = '15:30';
- await page.waitToClick(selectors.workerTimeControl.fridayAddTimeButton);
- await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
- await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out');
- await page.respondToDialog('accept');
- const result = await page.waitToGetProperty(selectors.workerTimeControl.fourthEntryOfFriday, 'innerText');
-
- expect(result).toEqual(scanTime);
- });
-
- it(`should check Hank Pym worked 7:40 hours with a smile on his face`, async() => {
- await page.waitForTextInElement(selectors.workerTimeControl.fridayWorkedHours, '07:40 h.');
- });
- });
+ expect(result).toContain(month);
});
- describe('as HHRR', () => {
- describe('on Saturday', () => {
- it('should log in as hr and pick the worker module', async() => {
- await page.loginAndModule('hr', 'worker');
- });
+ it('should go to current month', async() => {
+ const date = new Date();
+ const month = date.toLocaleString('default', {month: 'long'});
- it('should search for a worker and access to its summary', async() => {
- await page.accessToSearchResult('HankPym');
- await page.waitForState('worker.card.summary');
- });
+ await page.waitToClick(selectors.workerTimeControl.previousMonthButton);
+ const result = await page.waitToGetProperty(selectors.workerTimeControl.monthName, 'innerText');
- it('should access to the time control section', async() => {
- await page.accessToSection('worker.card.timeControl');
- await page.waitForState('worker.card.timeControl');
- await page.waitToClick(selectors.workerTimeControl.previousMonthButton);
- await page.waitToClick(selectors.workerTimeControl.secondWeekDay);
- });
-
- it('should lovingly scan in Hank Pym', async() => {
- const scanTime = '06:00';
- await page.waitForTimeout(1000); // without this timeout the dialog doesn't pop up
- await page.waitToClick(selectors.workerTimeControl.saturdayAddTimeButton);
- await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
- await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in');
- await page.respondToDialog('accept');
- const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfSaturday, 'innerText');
-
- expect(result).toEqual(scanTime);
- });
-
- it(`should lovingly scan out Hank Pym for the day with no break to leave a bit early`, async() => {
- const scanTime = '13:40';
- await page.waitToClick(selectors.workerTimeControl.saturdayAddTimeButton);
- await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
- await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out');
- await page.respondToDialog('accept');
- const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfSaturday, 'innerText');
-
- expect(result).toEqual(scanTime);
- });
-
- it(`should check Hank Pym worked 7:40 hours with all his will`, async() => {
- await page.waitForTextInElement(selectors.workerTimeControl.saturdayWorkedHours, '07:40 h.');
- });
- });
-
- describe('on Sunday', () => {
- it('should gladly scan in Hank Pym', async() => {
- const scanTime = '05:00';
- await page.waitToClick(selectors.workerTimeControl.sundayAddTimeButton);
- await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
- await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in');
- await page.respondToDialog('accept');
- const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfSunday, 'innerText');
-
- expect(result).toEqual(scanTime);
- });
-
- it(`should gladly scan out Hank Pym for the day with no break to leave a bit early`, async() => {
- const scanTime = '12:40';
- await page.waitToClick(selectors.workerTimeControl.sundayAddTimeButton);
- await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
- await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out');
- await page.respondToDialog('accept');
- const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfSunday, 'innerText');
-
- expect(result).toEqual(scanTime);
- });
-
- it(`should check Hank Pym worked 7:40 glad hours`, async() => {
- await page.waitForTextInElement(selectors.workerTimeControl.sundayWorkedHours, '07:40 h.');
- });
-
- it(`should check Hank Pym doesn't have hours set on the next months second week`, async() => {
- await page.waitToClick(selectors.workerTimeControl.nextMonthButton);
- await page.waitToClick(selectors.workerTimeControl.secondWeekDay);
- await page.waitForTextInElement(selectors.workerTimeControl.weekWorkedHours, '00:00 h.');
- });
-
- it(`should check he didn't scan in this week yet`, async() => {
- await page.waitToClick(selectors.workerTimeControl.navigateBackToIndex);
- await page.accessToSearchResult('salesBoss');
- await page.accessToSection('worker.card.timeControl');
-
- const wholeWeekHours = await page
- .waitToGetProperty(selectors.workerTimeControl.weekWorkedHours, 'innerText');
-
- expect(wholeWeekHours).toEqual('00:00 h.');
- });
- });
+ expect(result).toContain(month);
});
- describe('after all this amazing week', () => {
- it('should log in Hank', async() => {
- await page.loginAndModule('HankPym', 'worker');
- await page.accessToSearchResult('HankPym');
- await page.accessToSection('worker.card.timeControl');
- await page.waitToClick(selectors.workerTimeControl.previousMonthButton);
- await page.waitToClick(selectors.workerTimeControl.secondWeekDay);
- });
+ it('should go 1 month in the past', async() => {
+ const date = new Date();
+ date.setMonth(date.getMonth() - 1);
+ const timestamp = Math.round(date.getTime() / 1000);
+ const month = date.toLocaleString('default', {month: 'long'});
- it('should check his weekly hours are alright', async() => {
- await page.waitForTextInElement(selectors.workerTimeControl.weekWorkedHours, '52:40 h.');
- });
+ await page.loginAndModule('salesBoss', 'worker');
+ await page.goto(`http://localhost:5000/#!/worker/${hankPymId}/time-control?timestamp=${timestamp}`);
+ await page.waitToClick(selectors.workerTimeControl.secondWeekDay);
+
+ const result = await page.waitToGetProperty(selectors.workerTimeControl.monthName, 'innerText');
+
+ expect(result).toContain(month);
+ });
+
+ it(`should return error when insert 'out' of first entry`, async() => {
+ await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
+ await page.pickTime(selectors.workerTimeControl.dialogTimeInput, eightAm);
+ await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out');
+ await page.respondToDialog('accept');
+ const message = await page.waitForSnackbar();
+
+ expect(message.text).toBeDefined();
+ });
+
+ it(`should insert 'in' monday`, async() => {
+ await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
+ await page.pickTime(selectors.workerTimeControl.dialogTimeInput, eightAm);
+ await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in');
+ await page.respondToDialog('accept');
+ const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfMonday, 'innerText');
+
+ expect(result).toEqual(eightAm);
+ });
+
+ it(`should insert 'out' monday`, async() => {
+ await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
+ await page.pickTime(selectors.workerTimeControl.dialogTimeInput, fourPm);
+ await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out');
+ await page.respondToDialog('accept');
+ const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfMonday, 'innerText');
+
+ expect(result).toEqual(fourPm);
+ });
+
+ it(`should check Hank Pym worked 8:20 hours`, async() => {
+ await page.waitForTextInElement(selectors.workerTimeControl.mondayWorkedHours, '08:20 h.');
+ await page.waitForTextInElement(selectors.workerTimeControl.weekWorkedHours, '08:20 h.');
+ });
+
+ it('should remove first entry of monday', async() => {
+ await page.waitForTextInElement(selectors.workerTimeControl.firstEntryOfMonday, eightAm);
+ await page.waitForTextInElement(selectors.workerTimeControl.secondEntryOfMonday, fourPm);
+ await page.waitToClick(selectors.workerTimeControl.firstEntryOfMondayDelete);
+ await page.respondToDialog('accept');
+ const message = await page.waitForSnackbar();
+
+ expect(message.text).toContain('Entry removed');
+ });
+
+ it(`should be the 'out' the first entry of monday`, async() => {
+ const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfMonday, 'innerText');
+
+ expect(result).toEqual(fourPm);
+ });
+
+ it('should change week of month', async() => {
+ await page.waitToClick(selectors.workerTimeControl.thrirdWeekDay);
+ await page.waitForTextInElement(selectors.workerTimeControl.mondayWorkedHours, '00:00 h.');
});
});
diff --git a/e2e/paths/05-ticket/02_expeditions_and_log.spec.js b/e2e/paths/05-ticket/02_expeditions_and_log.spec.js
index 0e6482c94..dd2525f43 100644
--- a/e2e/paths/05-ticket/02_expeditions_and_log.spec.js
+++ b/e2e/paths/05-ticket/02_expeditions_and_log.spec.js
@@ -18,7 +18,7 @@ describe('Ticket expeditions and log path', () => {
});
it(`should delete a former expedition and confirm the remaining expedition are the expected ones`, async() => {
- await page.waitToClick(selectors.ticketExpedition.secondExpeditionRemoveButton);
+ await page.waitToClick(selectors.ticketExpedition.thirdExpeditionRemoveButton);
await page.waitToClick(selectors.globalItems.acceptButton);
await page.reloadSection('ticket.card.expedition');
diff --git a/e2e/paths/05-ticket/06_basic_data_steps.spec.js b/e2e/paths/05-ticket/06_basic_data_steps.spec.js
index fa118c25d..46cbf29b8 100644
--- a/e2e/paths/05-ticket/06_basic_data_steps.spec.js
+++ b/e2e/paths/05-ticket/06_basic_data_steps.spec.js
@@ -42,7 +42,7 @@ describe('Ticket Edit basic data path', () => {
expect(disabled).toBeFalsy();
});
- it(`should check the zone is for Silla247`, async() => {
+ it(`should check the zone is for Gotham247`, async() => {
let zone = await page
.waitToGetProperty(selectors.ticketBasicData.zone, 'value');
@@ -63,7 +63,7 @@ describe('Ticket Edit basic data path', () => {
let zone = await page
.waitToGetProperty(selectors.ticketBasicData.agency, 'value');
- expect(zone).toContain('Silla247Expensive');
+ expect(zone).toContain('Gotham247Expensive');
});
it(`should click next`, async() => {
@@ -92,7 +92,7 @@ describe('Ticket Edit basic data path', () => {
});
it(`should split ticket without negatives`, async() => {
- const newAgency = 'Silla247';
+ const newAgency = 'Gotham247';
const newDate = new Date();
newDate.setDate(newDate.getDate() - 1);
diff --git a/e2e/paths/05-ticket/09_weekly.spec.js b/e2e/paths/05-ticket/09_weekly.spec.js
index 2392de28f..d04138ee5 100644
--- a/e2e/paths/05-ticket/09_weekly.spec.js
+++ b/e2e/paths/05-ticket/09_weekly.spec.js
@@ -45,7 +45,7 @@ describe('Ticket descriptor path', () => {
it('should confirm the ticket 11 was added to thursday', async() => {
await page.accessToSection('ticket.weekly.index');
- const result = await page.waitToGetProperty(selectors.ticketsIndex.sixthWeeklyTicket, 'value');
+ const result = await page.waitToGetProperty(selectors.ticketsIndex.fourthWeeklyTicket, 'value');
expect(result).toEqual('Thursday');
});
@@ -80,7 +80,7 @@ describe('Ticket descriptor path', () => {
it('should confirm the ticket 11 was added on saturday', async() => {
await page.accessToSection('ticket.weekly.index');
- const result = await page.waitToGetProperty(selectors.ticketsIndex.sixthWeeklyTicket, 'value');
+ const result = await page.waitToGetProperty(selectors.ticketsIndex.fiveWeeklyTicket, 'value');
expect(result).toEqual('Saturday');
});
@@ -108,7 +108,7 @@ describe('Ticket descriptor path', () => {
});
it('should update the agency then remove it afterwards', async() => {
- await page.autocompleteSearch(selectors.ticketsIndex.firstWeeklyTicketAgency, 'Silla247');
+ await page.autocompleteSearch(selectors.ticketsIndex.firstWeeklyTicketAgency, 'Gotham247');
let message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
diff --git a/e2e/paths/05-ticket/12_descriptor.spec.js b/e2e/paths/05-ticket/12_descriptor.spec.js
index 3429acc89..ca6fb8290 100644
--- a/e2e/paths/05-ticket/12_descriptor.spec.js
+++ b/e2e/paths/05-ticket/12_descriptor.spec.js
@@ -75,59 +75,6 @@ describe('Ticket descriptor path', () => {
});
});
- describe('Add stowaway', () => {
- it('should search for a ticket', async() => {
- await page.accessToSearchResult('16');
- await page.waitForState('ticket.card.summary');
- });
-
- it('should open the add stowaway dialog', async() => {
- await page.waitForFunction(() => {
- let element = document.querySelector('vn-ticket-descriptor-menu');
- return element.$ctrl.canShowStowaway === true;
- });
- await page.waitToClick(selectors.ticketDescriptor.moreMenu);
- await page.waitToClick(selectors.ticketDescriptor.moreMenuAddStowaway);
- await page.waitForSelector(selectors.ticketDescriptor.addStowawayDialogFirstTicket);
- const isVisible = await page.isVisible(selectors.ticketDescriptor.addStowawayDialogFirstTicket);
-
- expect(isVisible).toBeTruthy();
- });
-
- it('should add a ticket as stowaway', async() => {
- await page.waitToClick(selectors.ticketDescriptor.addStowawayDialogFirstTicket);
- const message = await page.waitForSnackbar();
-
- expect(message.text).toContain('Data saved!');
- });
-
- it(`should check the state of the stowaway ticket is embarked`, async() => {
- await page.waitForState('ticket.card.summary');
- const state = await page.waitToGetProperty(selectors.ticketDescriptor.stateLabelValue, 'innerText');
-
- expect(state).toEqual('State Embarcando');
- });
-
- it(`should navigate back to the added ticket using the descriptors ship button`, async() => {
- await page.waitToClick(selectors.ticketDescriptor.shipButton);
- await page.waitForState('ticket.card.summary');
- });
-
- it('should delete the stowaway', async() => {
- await page.waitToClick(selectors.ticketDescriptor.moreMenu);
- await page.waitForContentLoaded();
- await page.waitToClick(selectors.ticketDescriptor.moreMenuDeleteStowawayButton);
- await page.waitToClick(selectors.ticketDescriptor.acceptDeleteStowawayButton);
- const message = await page.waitForSnackbar();
-
- expect(message.text).toContain('Data saved!');
- });
-
- it(`should confirm the ship buton doesn't exisist any more`, async() => {
- await page.waitForSelector(selectors.ticketDescriptor.shipButton, {hidden: true});
- });
- });
-
describe('Make invoice', () => {
it('should login as administrative role then search for a ticket', async() => {
const invoiceableTicketId = '14';
diff --git a/e2e/paths/05-ticket/13_services.spec.js b/e2e/paths/05-ticket/13_services.spec.js
index 03e57b588..50df23582 100644
--- a/e2e/paths/05-ticket/13_services.spec.js
+++ b/e2e/paths/05-ticket/13_services.spec.js
@@ -23,9 +23,9 @@ describe('Ticket services path', () => {
await page.waitForClassPresent(selectors.ticketService.firstAddServiceTypeButton, 'disabled');
await page.waitToClick(selectors.ticketService.addServiceButton);
await page.waitForSelector(selectors.ticketService.firstAddServiceTypeButton);
- const result = await page.isDisabled(selectors.ticketService.firstAddServiceTypeButton);
+ const disabled = await page.isDisabled(selectors.ticketService.firstAddServiceTypeButton);
- expect(result).toBe(true);
+ expect(disabled).toBe(true);
});
it('should receive an error if you attempt to save a service without access rights', async() => {
diff --git a/e2e/paths/05-ticket/14_create_ticket.spec.js b/e2e/paths/05-ticket/14_create_ticket.spec.js
index bfaa08775..48b4ebdd0 100644
--- a/e2e/paths/05-ticket/14_create_ticket.spec.js
+++ b/e2e/paths/05-ticket/14_create_ticket.spec.js
@@ -6,7 +6,6 @@ describe('Ticket create path', () => {
let page;
let nextMonth = new Date();
nextMonth.setMonth(nextMonth.getMonth() + 1);
- let stowawayTicketId;
beforeAll(async() => {
browser = await getBrowser();
@@ -27,7 +26,7 @@ describe('Ticket create path', () => {
await page.autocompleteSearch(selectors.createTicketView.client, 'Clark Kent');
await page.pickDate(selectors.createTicketView.deliveryDate, nextMonth);
await page.autocompleteSearch(selectors.createTicketView.warehouse, 'Warehouse Two');
- await page.autocompleteSearch(selectors.createTicketView.agency, 'Silla247');
+ await page.autocompleteSearch(selectors.createTicketView.agency, 'Gotham247');
await page.waitToClick(selectors.createTicketView.createButton);
const message = await page.waitForSnackbar();
@@ -36,8 +35,6 @@ describe('Ticket create path', () => {
it('should check the url is now the summary of the ticket', async() => {
await page.waitForState('ticket.card.summary');
- stowawayTicketId = await page.waitToGetProperty(selectors.ticketSummary.descriptorTicketId, 'innerText');
- stowawayTicketId = stowawayTicketId.substring(1);
});
it('should again open the new ticket form', async() => {
@@ -50,7 +47,7 @@ describe('Ticket create path', () => {
await page.autocompleteSearch(selectors.createTicketView.client, 'Clark Kent');
await page.pickDate(selectors.createTicketView.deliveryDate, nextMonth);
await page.autocompleteSearch(selectors.createTicketView.warehouse, 'Warehouse One');
- await page.autocompleteSearch(selectors.createTicketView.agency, 'Silla247');
+ await page.autocompleteSearch(selectors.createTicketView.agency, 'Gotham247');
await page.waitToClick(selectors.createTicketView.createButton);
const message = await page.waitForSnackbar();
@@ -61,15 +58,6 @@ describe('Ticket create path', () => {
await page.waitForState('ticket.card.summary');
});
- it('should make the previously created ticket the stowaway of the current ticket', async() => {
- await page.waitToClick(selectors.ticketDescriptor.moreMenu);
- await page.waitToClick(selectors.ticketDescriptor.moreMenuAddStowaway);
- await page.waitToClick(selectors.ticketDescriptor.addStowawayDialogFirstTicket);
- const message = await page.waitForSnackbar();
-
- expect(message.text).toContain('Data saved!');
- });
-
it('should delete the current ticket', async() => {
await page.waitToClick(selectors.ticketDescriptor.moreMenu);
await page.waitToClick(selectors.ticketDescriptor.moreMenuDeleteTicket);
@@ -78,11 +66,4 @@ describe('Ticket create path', () => {
expect(message.text).toContain('Ticket deleted. You can undo this action within the first hour');
});
-
- it('should search for the stowaway ticket of the previously deleted ticket', async() => {
- await page.accessToSearchResult(stowawayTicketId);
- const result = await page.countElement(selectors.ticketDescriptor.shipButton);
-
- expect(result).toBe(0);
- });
});
diff --git a/e2e/paths/06-claim/01_basic_data.spec.js b/e2e/paths/06-claim/01_basic_data.spec.js
index 2e2286939..0a08cad9f 100644
--- a/e2e/paths/06-claim/01_basic_data.spec.js
+++ b/e2e/paths/06-claim/01_basic_data.spec.js
@@ -22,8 +22,6 @@ describe('Claim edit basic data path', () => {
it(`should edit claim state and observation fields`, async() => {
await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Gestionado');
- await page.clearTextarea(selectors.claimBasicData.observation);
- await page.write(selectors.claimBasicData.observation, 'edited observation');
await page.clearInput(selectors.claimBasicData.packages);
await page.write(selectors.claimBasicData.packages, '2');
await page.waitToClick(selectors.claimBasicData.saveButton);
@@ -59,13 +57,6 @@ describe('Claim edit basic data path', () => {
expect(hasToPickUpCheckbox).toBe('checked');
});
- it('should confirm the claim observation was edited', async() => {
- const result = await page
- .waitToGetProperty(selectors.claimBasicData.observation, 'value');
-
- expect(result).toEqual('edited observation');
- });
-
it('should confirm the claim packages was edited', async() => {
const result = await page
.waitToGetProperty(selectors.claimBasicData.packages, 'value');
@@ -75,8 +66,6 @@ describe('Claim edit basic data path', () => {
it(`should edit the claim to leave it untainted`, async() => {
await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Pendiente');
- await page.clearTextarea(selectors.claimBasicData.observation);
- await page.write(selectors.claimBasicData.observation, 'Observation one');
await page.clearInput(selectors.claimBasicData.packages);
await page.write(selectors.claimBasicData.packages, '0');
await page.waitToClick(selectors.claimBasicData.saveButton);
diff --git a/e2e/paths/06-claim/05_summary.spec.js b/e2e/paths/06-claim/05_summary.spec.js
index 589b3b6cb..00b021f88 100644
--- a/e2e/paths/06-claim/05_summary.spec.js
+++ b/e2e/paths/06-claim/05_summary.spec.js
@@ -37,7 +37,7 @@ describe('Claim summary path', () => {
});
it('should display the observation', async() => {
- const result = await page.waitToGetProperty(selectors.claimSummary.observation, 'value');
+ const result = await page.waitToGetProperty(selectors.claimSummary.observation, 'innerText');
expect(result).toContain('Wisi forensibus mnesarchum in cum. Per id impetus abhorreant');
});
diff --git a/e2e/paths/06-claim/07_note.spec.js b/e2e/paths/06-claim/07_note.spec.js
new file mode 100644
index 000000000..830f77cbe
--- /dev/null
+++ b/e2e/paths/06-claim/07_note.spec.js
@@ -0,0 +1,46 @@
+import selectors from '../../helpers/selectors';
+import getBrowser from '../../helpers/puppeteer';
+
+describe('Claim Add note path', () => {
+ let browser;
+ let page;
+ beforeAll(async() => {
+ browser = await getBrowser();
+ page = browser.page;
+ await page.loginAndModule('salesPerson', 'claim');
+ await page.accessToSearchResult('2');
+ await page.accessToSection('claim.card.note.index');
+ });
+
+ afterAll(async() => {
+ await browser.close();
+ });
+
+ it(`should reach the claim note index`, async() => {
+ await page.waitForState('claim.card.note.index');
+ });
+
+ it(`should click on the add new note button`, async() => {
+ await page.waitToClick(selectors.claimNote.addNoteFloatButton);
+ await page.waitForState('claim.card.note.create');
+ });
+
+ it(`should create a new note`, async() => {
+ await page.waitForSelector(selectors.claimNote.note);
+ await page.type(`${selectors.claimNote.note} textarea`, 'The delivery was unsuccessful');
+ await page.waitToClick(selectors.claimNote.saveButton);
+ const message = await page.waitForSnackbar();
+
+ expect(message.text).toContain('Data saved!');
+ });
+
+ it(`should redirect back to the claim notes page`, async() => {
+ await page.waitForState('claim.card.note.index');
+ });
+
+ it('should confirm the note was created', async() => {
+ const result = await page.waitToGetProperty(selectors.claimNote.firstNoteText, 'innerText');
+
+ expect(result).toEqual('The delivery was unsuccessful');
+ });
+});
diff --git a/e2e/paths/07-order/01_summary.spec.js b/e2e/paths/07-order/01_summary.spec.js
index 9b9e37998..922d5eeee 100644
--- a/e2e/paths/07-order/01_summary.spec.js
+++ b/e2e/paths/07-order/01_summary.spec.js
@@ -34,7 +34,7 @@ describe('Order summary path', () => {
it('should check the summary contains the order consignee', async() => {
const result = await page.waitToGetProperty(selectors.orderSummary.consignee, 'innerText');
- expect(result).toEqual('address 26 - Silla (Province one)');
+ expect(result).toEqual('address 26 - Gotham (Province one)');
});
it('should check the summary contains the order subtotal', async() => {
diff --git a/e2e/paths/08-route/01_summary.spec.js b/e2e/paths/08-route/01_summary.spec.js
index 02cc71f2f..b6052dff6 100644
--- a/e2e/paths/08-route/01_summary.spec.js
+++ b/e2e/paths/08-route/01_summary.spec.js
@@ -9,7 +9,7 @@ describe('Route summary path', () => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('employee', 'route');
- await page.waitToClick('vn-route-index vn-tbody > a:nth-child(1)');
+ await page.waitToClick('vn-route-index vn-tbody > a:nth-child(7)');
});
afterAll(async() => {
diff --git a/e2e/paths/14-account/01_create_and_basic_data.spec.js b/e2e/paths/14-account/01_create_and_basic_data.spec.js
index 4048413ba..0fc657375 100644
--- a/e2e/paths/14-account/01_create_and_basic_data.spec.js
+++ b/e2e/paths/14-account/01_create_and_basic_data.spec.js
@@ -36,8 +36,7 @@ describe('Account create and basic data path', () => {
await page.waitForState('account.card.basicData');
});
- it('should reload the section and check the name is as expected', async() => {
- await page.reloadSection('account.card.basicData');
+ it('should check the name is as expected', async() => {
const result = await page.waitToGetProperty(selectors.accountBasicData.name, 'value');
expect(result).toEqual('Remy');
@@ -103,25 +102,39 @@ describe('Account create and basic data path', () => {
});
});
- // creating the account without the active property set to true seems to be creating an active user anyways
- // describe('activate user', () => {
- // it(`should check the inactive user icon is present in the descriptor`, async() => {
- // await page.waitForSelector(selectors.accountDescriptor.activeUserIcon, {visible: true});
- // });
+ describe('deactivate user', () => {
+ it(`should check the inactive user icon isn't present in the descriptor just yet`, async() => {
+ await page.waitForNumberOfElements(selectors.accountDescriptor.activeUserIcon, 0);
+ });
- // it('should activate the user using the descriptor menu', async() => {
- // await page.waitToClick(selectors.accountDescriptor.menuButton);
- // await page.waitToClick(selectors.accountDescriptor.activateUser);
- // await page.waitToClick(selectors.accountDescriptor.acceptButton);
- // const message = await page.waitForSnackbar();
+ it('should deactivate the user using the descriptor menu', async() => {
+ await page.waitToClick(selectors.accountDescriptor.menuButton);
+ await page.waitToClick(selectors.accountDescriptor.deactivateUser);
+ await page.waitToClick(selectors.accountDescriptor.acceptButton);
+ const message = await page.waitForSnackbar();
- // expect(message.text).toContain('user enabled?');
- // });
+ expect(message.text).toContain('User deactivated!');
+ });
- // it('should check the inactive user icon is not present anymore', async() => {
- // await page.waitForNumberOfElements(selectors.accountDescriptor.activeUserIcon, 0);
- // });
- // });
+ it('should check the inactive user icon is now present', async() => {
+ await page.waitForNumberOfElements(selectors.accountDescriptor.activeUserIcon, 1);
+ });
+ });
+
+ describe('activate user', () => {
+ it('should activate the user using the descriptor menu', async() => {
+ await page.waitToClick(selectors.accountDescriptor.menuButton);
+ await page.waitToClick(selectors.accountDescriptor.activateUser);
+ await page.waitToClick(selectors.accountDescriptor.acceptButton);
+ const message = await page.waitForSnackbar();
+
+ expect(message.text).toContain('User activated!');
+ });
+
+ it('should check the inactive user icon is not present anymore', async() => {
+ await page.waitForNumberOfElements(selectors.accountDescriptor.activeUserIcon, 0);
+ });
+ });
describe('mail forwarding', () => {
it('should activate the mail forwarding and set the recipent email', async() => {
diff --git a/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js b/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js
index 0514899bc..dd35dd740 100644
--- a/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js
+++ b/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js
@@ -56,7 +56,7 @@ describe('Account Alias create and basic data path', () => {
expect(result).toContain('psykers');
});
- it('should search for the IT alias group then access to the users section then check the role listed is the expected one', async() => {
+ it('should search IT alias then access the user section to check the role listed is the expected one', async() => {
await page.accessToSearchResult('IT');
await page.accessToSection('account.alias.card.users');
const rolesCount = await page.countElement(selectors.accountAliasUsers.anyResult);
diff --git a/front/core/services/app.js b/front/core/services/app.js
index 6b2cd1d2a..889b24d01 100644
--- a/front/core/services/app.js
+++ b/front/core/services/app.js
@@ -10,6 +10,7 @@ export default class App {
constructor() {
this.loaderStatus = 0;
this.loading = false;
+ this.versionInterval = setInterval(this.getVersion.bind(this), 300000);
}
showMessage(message) {
@@ -38,6 +39,21 @@ export default class App {
if (this.loaderStatus === 0)
this.loading = false;
}
+
+ getVersion() {
+ this.logger.$http.get('Applications/status');
+ }
+
+ setVersion(newVersion) {
+ if (newVersion) {
+ const currentVersion = localStorage.getItem('salix-version');
+ if (newVersion != currentVersion) {
+ this.hasNewVersion = true;
+ clearInterval(this.versionInterval);
+ }
+ localStorage.setItem('salix-version', newVersion);
+ }
+ }
}
ngModule.service('vnApp', App);
diff --git a/front/core/services/interceptor.js b/front/core/services/interceptor.js
index b7cf3a0ec..3f3d9912b 100644
--- a/front/core/services/interceptor.js
+++ b/front/core/services/interceptor.js
@@ -30,14 +30,17 @@ function interceptor($q, vnApp, vnToken, $translate) {
},
response(response) {
vnApp.popLoader();
+ const newVersion = response.headers('salix-version');
+ vnApp.setVersion(newVersion);
+
return response;
},
responseError(rejection) {
vnApp.popLoader();
- let err = new HttpError(rejection.statusText);
+ const err = new HttpError(rejection.statusText);
Object.assign(err, rejection);
return $q.reject(err);
- }
+ },
};
}
ngModule.factory('vnInterceptor', interceptor);
diff --git a/front/core/styles/icons/salixfont.css b/front/core/styles/icons/salixfont.css
index c500f976d..2dee94c3b 100644
--- a/front/core/styles/icons/salixfont.css
+++ b/front/core/styles/icons/salixfont.css
@@ -343,9 +343,6 @@
.icon-splur:before {
content: "\e970";
}
-.icon-stowaway:before {
- content: "\e94f";
-}
.icon-supplier:before {
content: "\e925";
}
diff --git a/front/core/styles/icons/salixfont.svg b/front/core/styles/icons/salixfont.svg
index 2b8b1ac8a..96a584734 100644
--- a/front/core/styles/icons/salixfont.svg
+++ b/front/core/styles/icons/salixfont.svg
@@ -85,8 +85,6 @@
-
-
diff --git a/front/salix/components/layout/index.html b/front/salix/components/layout/index.html
index cd13c565e..5a525ef77 100644
--- a/front/salix/components/layout/index.html
+++ b/front/salix/components/layout/index.html
@@ -19,6 +19,14 @@
+
+
-
-
+
{{ticket.description}}
-
{{$t('stowaway')}}: {{ticket.shipFk}}
diff --git a/print/templates/reports/driver-route/locale/es.yml b/print/templates/reports/driver-route/locale/es.yml
index 4c922ba64..3fb6b6885 100644
--- a/print/templates/reports/driver-route/locale/es.yml
+++ b/print/templates/reports/driver-route/locale/es.yml
@@ -20,7 +20,6 @@ phone: Teléfono
warehouse: Almacén
salesPerson: Comercial
import: Importe
-stowaway: Encajado dentro del ticket
route: Ruta
routeId: Ruta {0}
ticket: Ticket
\ No newline at end of file
diff --git a/print/templates/reports/driver-route/sql/tickets.sql b/print/templates/reports/driver-route/sql/tickets.sql
index 8806a0473..09e73819b 100644
--- a/print/templates/reports/driver-route/sql/tickets.sql
+++ b/print/templates/reports/driver-route/sql/tickets.sql
@@ -17,7 +17,6 @@ SELECT
0 AS import,
am.name ticketAgency,
tob.description,
- s.shipFk,
u.nickName salesPersonName,
ipkg.itemPackingTypes
FROM route r
@@ -30,7 +29,6 @@ FROM route r
LEFT JOIN province p ON a.provinceFk = p.id
LEFT JOIN warehouse wh ON wh.id = t.warehouseFk
LEFT JOIN agencyMode am ON am.id = t.agencyModeFk
- LEFT JOIN stowaway s ON s.id = t.id
LEFT JOIN (
SELECT t.id AS ticketFk,
GROUP_CONCAT(DISTINCT(i.itemPackingTypeFk)) AS itemPackingTypes
diff --git a/print/templates/reports/exportation/exportation.js b/print/templates/reports/exportation/exportation.js
index fbf663249..a7e018c48 100755
--- a/print/templates/reports/exportation/exportation.js
+++ b/print/templates/reports/exportation/exportation.js
@@ -5,14 +5,14 @@ const reportFooter = new Component('report-footer');
module.exports = {
name: 'exportation',
async serverPrefetch() {
- this.invoice = await this.fetchInvoice(this.invoiceId);
+ this.invoice = await this.fetchInvoice(this.refFk);
if (!this.invoice)
throw new Error('Something went wrong');
},
methods: {
- fetchInvoice(invoiceId) {
- return this.findOneFromDef('invoice', [invoiceId]);
+ fetchInvoice(refFk) {
+ return this.findOneFromDef('invoice', [refFk]);
}
},
computed: {
@@ -27,7 +27,7 @@ module.exports = {
'report-footer': reportFooter.build()
},
props: {
- invoiceId: {
+ refFk: {
type: [Number, String],
required: true
}
diff --git a/print/templates/reports/exportation/sql/invoice.sql b/print/templates/reports/exportation/sql/invoice.sql
index 8e92333dd..7ea55e481 100644
--- a/print/templates/reports/exportation/sql/invoice.sql
+++ b/print/templates/reports/exportation/sql/invoice.sql
@@ -3,4 +3,5 @@ SELECT
io.ref,
io.issued
FROM invoiceOut io
-WHERE io.id = ?
\ No newline at end of file
+ LEFT JOIN ticket t ON t.refFk = io.ref
+WHERE t.refFk = ?
\ No newline at end of file
diff --git a/print/templates/reports/cmr-authorization/assets/css/import.js b/print/templates/reports/incoterms-authorization/assets/css/import.js
similarity index 100%
rename from print/templates/reports/cmr-authorization/assets/css/import.js
rename to print/templates/reports/incoterms-authorization/assets/css/import.js
diff --git a/print/templates/reports/cmr-authorization/assets/css/style.css b/print/templates/reports/incoterms-authorization/assets/css/style.css
similarity index 69%
rename from print/templates/reports/cmr-authorization/assets/css/style.css
rename to print/templates/reports/incoterms-authorization/assets/css/style.css
index adfe4b4c9..34545c951 100644
--- a/print/templates/reports/cmr-authorization/assets/css/style.css
+++ b/print/templates/reports/incoterms-authorization/assets/css/style.css
@@ -2,13 +2,8 @@
font-size: 1.2em
}
-.signature .dummy-signature {
- width: 400px;
- height: 190px;
- display: block;
- content: '';
- overflow: hidden;
- clear:both
+.signature {
+ margin-top: 100px
}
.signature img {
diff --git a/print/templates/reports/cmr-authorization/assets/images/signature.png b/print/templates/reports/incoterms-authorization/assets/images/signature.png
similarity index 100%
rename from print/templates/reports/cmr-authorization/assets/images/signature.png
rename to print/templates/reports/incoterms-authorization/assets/images/signature.png
diff --git a/print/templates/reports/cmr-authorization/cmr-authorization.html b/print/templates/reports/incoterms-authorization/incoterms-authorization.html
similarity index 72%
rename from print/templates/reports/cmr-authorization/cmr-authorization.html
rename to print/templates/reports/incoterms-authorization/incoterms-authorization.html
index 2d8342a47..27cad97b1 100644
--- a/print/templates/reports/cmr-authorization/cmr-authorization.html
+++ b/print/templates/reports/incoterms-authorization/incoterms-authorization.html
@@ -23,9 +23,10 @@
@@ -53,13 +54,13 @@
-
{{$t('signature')}}
+
{{ company.name }}
-
Juan Vicente Ferrer Roig
-
Director
+
{{company.manager}}
+
{{$t('manager')}}
{{$t('issued', [
- 'Algemesí',
+ company.city,
issued.getDate(),
$t('months')[issued.getMonth()],
issued.getFullYear()])
@@ -68,22 +69,6 @@
-
diff --git a/print/templates/reports/cmr-authorization/cmr-authorization.js b/print/templates/reports/incoterms-authorization/incoterms-authorization.js
similarity index 69%
rename from print/templates/reports/cmr-authorization/cmr-authorization.js
rename to print/templates/reports/incoterms-authorization/incoterms-authorization.js
index 1adc75fa6..656a9d7b0 100755
--- a/print/templates/reports/cmr-authorization/cmr-authorization.js
+++ b/print/templates/reports/incoterms-authorization/incoterms-authorization.js
@@ -3,13 +3,12 @@ const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer');
module.exports = {
- name: 'cmr-authorization',
+ name: 'incoterms-authorization',
async serverPrefetch() {
- this.ticket = await this.findOneFromDef('ticket', [this.ticketId]);
- if (!this.ticket)
+ this.client = await this.findOneFromDef('client', [this.recipientId]);
+ this.company = await this.findOneFromDef('company', [this.companyId]);
+ if (!this.client)
throw new Error('Something went wrong');
-
- this.client = await this.findOneFromDef('client', [this.ticket.clientFk]);
},
computed: {
issued: function() {
@@ -21,7 +20,11 @@ module.exports = {
'report-footer': reportFooter.build()
},
props: {
- ticketId: {
+ recipientId: {
+ type: [Number, String],
+ required: true
+ },
+ companyId: {
type: [Number, String],
required: true
}
diff --git a/print/templates/reports/cmr-authorization/locale/es.yml b/print/templates/reports/incoterms-authorization/locale/es.yml
similarity index 58%
rename from print/templates/reports/cmr-authorization/locale/es.yml
rename to print/templates/reports/incoterms-authorization/locale/es.yml
index 37e40202d..6936ebda9 100644
--- a/print/templates/reports/cmr-authorization/locale/es.yml
+++ b/print/templates/reports/incoterms-authorization/locale/es.yml
@@ -1,32 +1,32 @@
-reportName: autorizacion-cmr
+reportName: autorizacion-incoterms
description: '{socialName} una sociedad debidamente constituida con responsabilidad limitada
y registrada conforme al derecho de sociedades de {country} y aquí representada por
___________________. {socialName}, con domicilio en {address},
CIF {fiscalID}. En adelante denominada {name}.'
issued: 'En {0}, a {1} de {2} de {3}'
-client: 'Client {0}'
+client: 'Cliente {0}'
declaration: '{socialName} declara por la presente que:'
declarations:
- - 'Todas las compras realizadas por {socialName} con Verdnatura Levante, S.L. se
-entregan, Ex Works (Incoterms), en el almacén de Verdnatura Levante, S.L. situado en
-{destinationWarehouse}.'
- - '{socialName} reconoce que es importante para Verdnatura Levante, S.L. tener
+ - 'Todas las compras realizadas por {socialName} con {companyName} se
+entregan, Ex Works (Incoterms), en el almacén de {companyName} situado en
+{companyCity}.'
+ - '{socialName} reconoce que es importante para {companyName} tener
comprobante de la entrega intracomunitaria de la mercancía a {destinationCountry} para
poder facturar con 0% de IVA.'
- 'Por tanto, al firmar este acuerdo, {socialName} declara que todos los bienes que
-se compren a Verdnatura Levante, S.L. serán entregados a {destinationCountry}.'
- - 'Además, {socialName} deberá, a primera solicitud de Verdnatura Levante, S.L.,
-proporcionar una prueba de que todos los productos comprados a Verdnatura Levante, S.L. han
+se compren a {companyName} serán entregados a {destinationCountry}.'
+ - 'Además, {socialName} deberá, a primera solicitud de {companyName},
+proporcionar una prueba de que todos los productos comprados a {companyName} han
sido entregados en {destinationCountry}.'
- - 'Además de lo anterior, Verdnatura Levante, S.L. proporcionará a {socialName}
+ - 'Además de lo anterior, {companyName} proporcionará a {socialName}
un resumen mensual en el que se incluyen todas las facturas (y las entregas correspondientes).
-{socialName} firmará y devolverá el resumen mensual a Verdnatura Levante,
+{socialName} firmará y devolverá el resumen mensual a {companyName},
S.L. dentro de los 5 días posteriores a la recepción del resumen.'
-signature: Verdnatura Levante, S.L.
signer:
representative: Representante
representativeRole: Cargo del representante
signed: Fecha de firma
+manager: Gerente
months:
- 'Enero'
- 'Febrero'
diff --git a/print/templates/reports/incoterms-authorization/locale/fr.yml b/print/templates/reports/incoterms-authorization/locale/fr.yml
new file mode 100644
index 000000000..f1aeb0eff
--- /dev/null
+++ b/print/templates/reports/incoterms-authorization/locale/fr.yml
@@ -0,0 +1,38 @@
+reportName: autorizacion-incoterms
+description: '{socialName} une société dûment constituée à responsabilité limitée
+et enregistrée en vertu du droit des sociétés de {country} et représentée aux présentes par
+___________________. {socialName}, ayant son siège social {address},
+CIF {fiscalID}. Ci-après dénommé {name}.'
+issued: 'A {0}, le {1} {2} {3}'
+client: 'Client {0}'
+declaration: '{socialName} déclare par la présente que:'
+declarations:
+ - "Tous les achats réalisés par {socialName} avec {companyName}
+sont livrés, Ex Works (Incoterms), sur l'entrepôt de {companyName} situé à {companyCity}."
+ - "{socialName} reconnaît qu'il est important pou {companyName} d'avoir
+la preuve de la livraison intracommunautaire des biens à {destinationCountry} afin de pouvoir facturer à 0% de TVA."
+ - 'Par conséquent, en signant cet accord, {socialName} déclare que tous les biens achetés à {companyName} seront livrés à {destinationCountry}.'
+ - 'En outre, {socialName} doit, à la première demande de {companyName},
+fournir la preuve que tous les biens achetés à {companyName} ont été livrés à {destinationCountry}.'
+ - 'En plus de ce qui précède, {companyName} fournira à {socialName}
+un résumé mensuel comprenant toutes les factures (et les livraisons correspondantes).
+{socialName} signera et retournera le résumé mensuel à {companyName},
+dans les 5 jours suivant la réception du résumé.'
+signer:
+ representative: Représentant
+ representativeRole: Position du représentant
+ signed: Date de la signature
+manager: Gérente
+months:
+ - 'Janvier'
+ - 'Fevrier'
+ - 'Mars'
+ - 'Avril'
+ - 'Mai'
+ - 'Juin'
+ - 'Juillet'
+ - 'Août'
+ - 'Septembre'
+ - 'Octobre'
+ - 'Novembre'
+ - 'Decembre'
\ No newline at end of file
diff --git a/print/templates/reports/incoterms-authorization/locale/pt.yml b/print/templates/reports/incoterms-authorization/locale/pt.yml
new file mode 100644
index 000000000..2d33e6a1a
--- /dev/null
+++ b/print/templates/reports/incoterms-authorization/locale/pt.yml
@@ -0,0 +1,42 @@
+reportName: autorizacion-incoterms
+description: '{socialName} uma sociedade devidamente constituída com responsabilidade limitada e registada
+conforme ao direito de sociedades da {country} e aqui representada por
+___________________. {socialName}, com domicílio em {address},
+CIF {fiscalID}. Em adiante denominada {name}.'
+issued: 'Em {0}, em {1} de {2} de {3}'
+client: 'Cliente {0}'
+declaration: '{socialName} declara através da presente que:'
+declarations:
+ - 'Todas as compras realizadas por {socialName} a {companyName} se entregam,
+ Ex Works (Incoterms), no armazém da {companyName} situado em
+{companyCity}.'
+ - '{socialName} reconhece ser importante para {companyName}
+ ter o comprovante da entrega intracomunitária da mercadoria a {destinationCountry}
+ para poder faturar com 0% de IVA.'
+ - 'Portanto, ao assinar este acordo, {socialName} declara que todos os bens
+ que se comprem na {companyName} serão entregues na {destinationCountry}.'
+ - 'Além disto, {socialName} deverá, na primeira solicitude da {companyName},
+ proporcionar uma prova de que todos os produtos comprados na {companyName}
+ foram entregues na {destinationCountry}.'
+ - 'Além do anterio, {companyName} proporcionará a {socialName}
+um resumo mensal onde se incluem todas as faturas (e as entregas correspondentes).
+{socialName} assinará e devolverá o resumo mensal à {companyName},
+dentro dos 5 dias posteriores à receção do resumo.'
+signer:
+ representative: Representante
+ representativeRole: Cargo de representante
+ signed: Data da assinatura
+manager: Gerente
+months:
+ - 'Janeiro'
+ - 'Fevereiro'
+ - 'Marchar'
+ - 'abril'
+ - 'Poderia'
+ - 'Junho'
+ - 'Julho'
+ - 'Agosto'
+ - 'Setembro'
+ - 'Outubro'
+ - 'Novembro'
+ - 'Dezembro'
\ No newline at end of file
diff --git a/print/templates/reports/cmr-authorization/sql/client.sql b/print/templates/reports/incoterms-authorization/sql/client.sql
similarity index 100%
rename from print/templates/reports/cmr-authorization/sql/client.sql
rename to print/templates/reports/incoterms-authorization/sql/client.sql
diff --git a/print/templates/reports/incoterms-authorization/sql/company.sql b/print/templates/reports/incoterms-authorization/sql/company.sql
new file mode 100644
index 000000000..39c3290d1
--- /dev/null
+++ b/print/templates/reports/incoterms-authorization/sql/company.sql
@@ -0,0 +1,8 @@
+SELECT
+ s.name,
+ s.city,
+ cl.name AS manager
+FROM company c
+ JOIN supplier s ON s.id = c.id
+ JOIN client cl ON cl.id = c.workerManagerFk
+WHERE c.id = ?
\ No newline at end of file
diff --git a/print/templates/reports/invoice-incoterms/invoice-incoterms.js b/print/templates/reports/invoice-incoterms/invoice-incoterms.js
index 99e23e15f..99a4e2e73 100755
--- a/print/templates/reports/invoice-incoterms/invoice-incoterms.js
+++ b/print/templates/reports/invoice-incoterms/invoice-incoterms.js
@@ -5,9 +5,9 @@ const reportFooter = new Component('report-footer');
module.exports = {
name: 'invoice-incoterms',
async serverPrefetch() {
- this.invoice = await this.fetchInvoice(this.invoiceId);
- this.client = await this.fetchClient(this.invoiceId);
- this.incoterms = await this.fetchIncoterms(this.invoiceId);
+ this.invoice = await this.fetchInvoice(this.refFk);
+ this.client = await this.fetchClient(this.refFk);
+ this.incoterms = await this.fetchIncoterms(this.refFk);
if (!this.invoice)
throw new Error('Something went wrong');
@@ -16,14 +16,14 @@ module.exports = {
},
methods: {
- fetchInvoice(invoiceId) {
- return this.findOneFromDef('invoice', [invoiceId]);
+ fetchInvoice(refFk) {
+ return this.findOneFromDef('invoice', [refFk]);
},
- fetchClient(invoiceId) {
- return this.findOneFromDef('client', [invoiceId]);
+ fetchClient(refFk) {
+ return this.findOneFromDef('client', [refFk]);
},
- fetchIncoterms(invoiceId) {
- return this.findOneFromDef('incoterms', [invoiceId, invoiceId, invoiceId]);
+ fetchIncoterms(refFk) {
+ return this.findOneFromDef('incoterms', [refFk, refFk, refFk]);
}
},
components: {
@@ -31,7 +31,7 @@ module.exports = {
'report-footer': reportFooter.build()
},
props: {
- invoiceId: {
+ refFk: {
type: [Number, String],
required: true
}
diff --git a/print/templates/reports/invoice-incoterms/sql/client.sql b/print/templates/reports/invoice-incoterms/sql/client.sql
index dd6035222..3e66c15c9 100644
--- a/print/templates/reports/invoice-incoterms/sql/client.sql
+++ b/print/templates/reports/invoice-incoterms/sql/client.sql
@@ -9,4 +9,5 @@ FROM vn.invoiceOut io
JOIN vn.country cty ON cty.id = c.countryFk
LEFT JOIN vn.invoiceOutSerial ios ON ios.code = io.serial
AND ios.taxAreaFk = 'CEE'
-WHERE io.id = ?
\ No newline at end of file
+ LEFT JOIN ticket t ON t.refFk = io.ref
+WHERE t.refFk = ?
\ No newline at end of file
diff --git a/print/templates/reports/invoice-incoterms/sql/incoterms.sql b/print/templates/reports/invoice-incoterms/sql/incoterms.sql
index 5d894a4b2..6bb895129 100644
--- a/print/templates/reports/invoice-incoterms/sql/incoterms.sql
+++ b/print/templates/reports/invoice-incoterms/sql/incoterms.sql
@@ -51,7 +51,7 @@ SELECT io.issued,
FROM vn.invoiceOut io
JOIN vn.ticket t ON t.refFk = io.ref
JOIN vn.saleVolume sv ON sv.ticketFk = t.id
- WHERE io.id = ?
+ WHERE t.refFk = ?
) sub2 ON TRUE
JOIN vn.itemTaxCountry itc ON itc.countryFk = su.countryFk AND itc.itemFk = s.itemFk
JOIN vn.taxClass tc ON tc.id = itc.taxClassFk
@@ -66,6 +66,7 @@ SELECT io.issued,
JOIN vn.sale s ON t.id = s.ticketFk
JOIN vn.item i ON i.id = s.itemFk
JOIN vn.intrastat ir ON ir.id = i.intrastatFk
- WHERE io.id = ?
+ WHERE t.refFk = ?
)sub3 ON TRUE
- WHERE io.id = ?
+ WHERE t.refFk = ?
+
diff --git a/print/templates/reports/invoice-incoterms/sql/invoice.sql b/print/templates/reports/invoice-incoterms/sql/invoice.sql
index b9a929183..571ea2af3 100644
--- a/print/templates/reports/invoice-incoterms/sql/invoice.sql
+++ b/print/templates/reports/invoice-incoterms/sql/invoice.sql
@@ -14,4 +14,5 @@ FROM invoiceOut io
JOIN company cny ON cny.id = io.companyFk
JOIN supplierAccount sa ON sa.id = cny.supplierAccountFk
LEFT JOIN invoiceOutSerial ios ON ios.code = io.serial
-WHERE io.id = ?
\ No newline at end of file
+ LEFT JOIN ticket t ON t.refFk = io.ref
+WHERE t.refFk = ?
\ No newline at end of file
diff --git a/print/templates/reports/invoice/invoice.js b/print/templates/reports/invoice/invoice.js
index c5abfad7e..fd4acd4b5 100755
--- a/print/templates/reports/invoice/invoice.js
+++ b/print/templates/reports/invoice/invoice.js
@@ -7,15 +7,15 @@ const invoiceIncoterms = new Report('invoice-incoterms');
module.exports = {
name: 'invoice',
async serverPrefetch() {
- this.invoice = await this.fetchInvoice(this.invoiceId);
- this.client = await this.fetchClient(this.invoiceId);
- this.taxes = await this.fetchTaxes(this.invoiceId);
- this.intrastat = await this.fetchIntrastat(this.invoiceId);
- this.rectified = await this.fetchRectified(this.invoiceId);
- this.hasIncoterms = await this.fetchHasIncoterms(this.invoiceId);
+ this.invoice = await this.fetchInvoice(this.refFk);
+ this.client = await this.fetchClient(this.refFk);
+ this.taxes = await this.fetchTaxes(this.refFk);
+ this.intrastat = await this.fetchIntrastat(this.refFk);
+ this.rectified = await this.fetchRectified(this.refFk);
+ this.hasIncoterms = await this.fetchHasIncoterms(this.refFk);
- const tickets = await this.fetchTickets(this.invoiceId);
- const sales = await this.fetchSales(this.invoiceId);
+ const tickets = await this.fetchTickets(this.refFk);
+ const sales = await this.fetchSales(this.refFk);
const map = new Map();
@@ -65,29 +65,29 @@ module.exports = {
}
},
methods: {
- fetchInvoice(invoiceId) {
- return this.findOneFromDef('invoice', [invoiceId]);
+ fetchInvoice(refFk) {
+ return this.findOneFromDef('invoice', [refFk]);
},
- fetchClient(invoiceId) {
- return this.findOneFromDef('client', [invoiceId]);
+ fetchClient(refFk) {
+ return this.findOneFromDef('client', [refFk]);
},
- fetchTickets(invoiceId) {
- return this.rawSqlFromDef('tickets', [invoiceId]);
+ fetchTickets(refFk) {
+ return this.rawSqlFromDef('tickets', [refFk]);
},
- fetchSales(invoiceId) {
- return this.rawSqlFromDef('sales', [invoiceId, invoiceId]);
+ fetchSales(refFk) {
+ return this.rawSqlFromDef('sales', [refFk, refFk]);
},
- fetchTaxes(invoiceId) {
- return this.rawSqlFromDef(`taxes`, [invoiceId]);
+ fetchTaxes(refFk) {
+ return this.rawSqlFromDef(`taxes`, [refFk]);
},
- fetchIntrastat(invoiceId) {
- return this.rawSqlFromDef(`intrastat`, [invoiceId]);
+ fetchIntrastat(refFk) {
+ return this.rawSqlFromDef(`intrastat`, [refFk, refFk, refFk]);
},
- fetchRectified(invoiceId) {
- return this.rawSqlFromDef(`rectified`, [invoiceId]);
+ fetchRectified(refFk) {
+ return this.rawSqlFromDef(`rectified`, [refFk]);
},
- fetchHasIncoterms(invoiceId) {
- return this.findValueFromDef(`hasIncoterms`, [invoiceId]);
+ fetchHasIncoterms(refFk) {
+ return this.findValueFromDef(`hasIncoterms`, [refFk]);
},
saleImport(sale) {
const price = sale.quantity * sale.price;
@@ -115,9 +115,8 @@ module.exports = {
'invoice-incoterms': invoiceIncoterms.build()
},
props: {
- invoiceId: {
- type: [Number, String],
- required: true
+ refFk: {
+ type: String
}
}
};
diff --git a/print/templates/reports/invoice/sql/client.sql b/print/templates/reports/invoice/sql/client.sql
index dd6035222..4c35838f2 100644
--- a/print/templates/reports/invoice/sql/client.sql
+++ b/print/templates/reports/invoice/sql/client.sql
@@ -9,4 +9,5 @@ FROM vn.invoiceOut io
JOIN vn.country cty ON cty.id = c.countryFk
LEFT JOIN vn.invoiceOutSerial ios ON ios.code = io.serial
AND ios.taxAreaFk = 'CEE'
-WHERE io.id = ?
\ No newline at end of file
+ LEFT JOIN vn.ticket t ON t.refFk = io.ref
+WHERE t.refFk = ?
\ No newline at end of file
diff --git a/print/templates/reports/invoice/sql/hasIncoterms.sql b/print/templates/reports/invoice/sql/hasIncoterms.sql
index 27f61f57c..40a6db384 100644
--- a/print/templates/reports/invoice/sql/hasIncoterms.sql
+++ b/print/templates/reports/invoice/sql/hasIncoterms.sql
@@ -3,6 +3,6 @@ SELECT IF(incotermsFk IS NULL, FALSE, TRUE) AS hasIncoterms
JOIN invoiceOut io ON io.ref = t.refFk
JOIN client c ON c.id = t.clientFk
JOIN address a ON a.id = t.addressFk
- WHERE io.id = ?
+ WHERE t.refFk = ?
AND IF(c.hasToinvoiceByAddress = FALSE, c.defaultAddressFk, TRUE)
LIMIT 1
\ No newline at end of file
diff --git a/print/templates/reports/invoice/sql/intrastat.sql b/print/templates/reports/invoice/sql/intrastat.sql
index 6bf72c158..e2ee47667 100644
--- a/print/templates/reports/invoice/sql/intrastat.sql
+++ b/print/templates/reports/invoice/sql/intrastat.sql
@@ -1,18 +1,22 @@
-SELECT
- ir.id AS code,
- ir.description AS description,
- CAST(SUM(IFNULL(i.stems,1) * s.quantity) AS DECIMAL(10,2)) as stems,
- CAST(SUM(IF(sv.physicalWeight, sv.physicalWeight, i.density * sub.cm3delivery/1000000)) AS DECIMAL(10,2)) netKg,
- CAST(SUM((s.quantity * s.price * (100 - s.discount) / 100 )) AS DECIMAL(10,2)) AS subtotal
- FROM vn.sale s
- LEFT JOIN (SELECT ic.itemFk, ic.cm3, ic.cm3delivery
- FROM vn.itemCost ic
- WHERE ic.cm3
- GROUP BY ic.itemFk) sub ON s.itemFk = sub.itemFk
- LEFT JOIN vn.saleVolume sv ON sv.saleFk = s.id
- LEFT JOIN vn.ticket t ON t.id = s.ticketFk
- LEFT JOIN vn.invoiceOut io ON io.ref = t.refFk
- LEFT JOIN vn.item i ON i.id = s.itemFk
- JOIN vn.intrastat ir ON ir.id = i.intrastatFk
- WHERE io.id = ?
- GROUP BY i.intrastatFk;
\ No newline at end of file
+SELECT
+ ir.id code,
+ ir.description description,
+ CAST(SUM(IFNULL(i.stems, 1) * s.quantity) AS DECIMAL(10,2)) stems,
+ CAST(SUM(CAST(IFNULL(i.stems, 1) * s.quantity * IF(ic.grams, ic.grams, i.density * ic.cm3delivery / 1000) / 1000 AS DECIMAL(10,2)) *
+ IF(sub.weight, sub.weight / vn.invoiceOut_getWeight(?), 1)) AS DECIMAL(10,2)) netKg,
+ CAST(SUM((s.quantity * s.price * (100 - s.discount) / 100 )) AS DECIMAL(10,2)) subtotal
+ FROM vn.ticket t
+ JOIN vn.sale s ON s.ticketFk = t.id
+ JOIN vn.item i ON i.id = s.itemFk
+ JOIN vn.itemCost ic ON ic.itemFk = i.id AND ic.warehouseFk = t.warehouseFk
+ JOIN vn.intrastat ir ON ir.id = i.intrastatFk
+ LEFT JOIN (
+ SELECT t2.weight
+ FROM vn.ticket t2
+ WHERE refFk = ? AND weight
+ LIMIT 1
+ ) sub ON TRUE
+ WHERE t.refFk = ?
+ AND i.intrastatFk
+ GROUP BY i.intrastatFk
+ ORDER BY i.intrastatFk;
\ No newline at end of file
diff --git a/print/templates/reports/invoice/sql/invoice.sql b/print/templates/reports/invoice/sql/invoice.sql
index aacbb0016..0f12e4f53 100644
--- a/print/templates/reports/invoice/sql/invoice.sql
+++ b/print/templates/reports/invoice/sql/invoice.sql
@@ -13,4 +13,5 @@ FROM invoiceOut io
JOIN company cny ON cny.id = io.companyFk
JOIN supplierAccount sa ON sa.id = cny.supplierAccountFk
LEFT JOIN invoiceOutSerial ios ON ios.code = io.serial
-WHERE io.id = ?
\ No newline at end of file
+ LEFT JOIN ticket t ON t.refFk = io.ref
+WHERE t.refFk = ?
\ No newline at end of file
diff --git a/print/templates/reports/invoice/sql/rectified.sql b/print/templates/reports/invoice/sql/rectified.sql
index 1255b973c..ea814a05a 100644
--- a/print/templates/reports/invoice/sql/rectified.sql
+++ b/print/templates/reports/invoice/sql/rectified.sql
@@ -6,4 +6,5 @@ SELECT
FROM vn.invoiceCorrection ic
JOIN vn.invoiceOut io ON io.id = ic.correctedFk
JOIN vn.invoiceCorrectionType ict ON ict.id = ic.invoiceCorrectionTypeFk
-where ic.correctingFk = ?
\ No newline at end of file
+ LEFT JOIN ticket t ON t.refFk = io.ref
+WHERE t.refFk = ?
\ No newline at end of file
diff --git a/print/templates/reports/invoice/sql/sales.sql b/print/templates/reports/invoice/sql/sales.sql
index cff8794db..f5721a594 100644
--- a/print/templates/reports/invoice/sql/sales.sql
+++ b/print/templates/reports/invoice/sql/sales.sql
@@ -37,7 +37,7 @@ SELECT
JOIN vn.itemTaxCountry itc ON itc.countryFk = su.countryFk
AND itc.itemFk = s.itemFk
JOIN vn.taxClass tc ON tc.id = itc.taxClassFk
- WHERE io.id = ?
+ WHERE t.refFk = ?
UNION ALL
SELECT
io.ref,
@@ -69,4 +69,4 @@ SELECT
JOIN vn.company co ON co.id = io.companyFk
JOIN vn.supplierAccount sa ON sa.id = co.supplierAccountFk
JOIN vn.taxClass tc ON tc.id = ts.taxClassFk
- WHERE io.id = ?
\ No newline at end of file
+ WHERE t.refFk = ?
\ No newline at end of file
diff --git a/print/templates/reports/invoice/sql/taxes.sql b/print/templates/reports/invoice/sql/taxes.sql
index 19b1cc00e..2203d8b8a 100644
--- a/print/templates/reports/invoice/sql/taxes.sql
+++ b/print/templates/reports/invoice/sql/taxes.sql
@@ -6,6 +6,7 @@ SELECT
FROM invoiceOutTax iot
JOIN pgc ON pgc.code = iot.pgcFk
LEFT JOIN pgcEqu pe ON pe.equFk = pgc.code
- JOIN invoiceOut io ON io.id = iot.invoiceOutFk
- WHERE invoiceOutFk = ?
+ JOIN invoiceOut io ON io.id = iot.invoiceOutFk
+ LEFT JOIN ticket t ON t.refFk = io.ref
+ WHERE t.refFk = ?
ORDER BY iot.id
\ No newline at end of file
diff --git a/print/templates/reports/invoice/sql/tickets.sql b/print/templates/reports/invoice/sql/tickets.sql
index 7d135bd03..162f043e2 100644
--- a/print/templates/reports/invoice/sql/tickets.sql
+++ b/print/templates/reports/invoice/sql/tickets.sql
@@ -4,5 +4,5 @@ SELECT
t.nickname
FROM invoiceOut io
JOIN ticket t ON t.refFk = io.ref
-WHERE io.id = ?
+WHERE t.refFk = ?
ORDER BY t.shipped
\ No newline at end of file