diff --git a/back/methods/edi/specs/syncData.spec.js b/back/methods/edi/specs/syncData.spec.js
new file mode 100644
index 0000000000..7fe24cca9c
--- /dev/null
+++ b/back/methods/edi/specs/syncData.spec.js
@@ -0,0 +1,59 @@
+const models = require('vn-loopback/server/server').models;
+
+describe('edi syncData()', function() {
+ const ediModel = models.Edi;
+
+ it('should be insert into the table', async() => {
+ const tx = await ediModel.beginTransaction({});
+ const options = {transaction: tx};
+ let error;
+ try {
+ await models.FloricodeConfig.create({
+ id: 1,
+ url: 'http://sample.com',
+ user: 'sample',
+ password: 'sample'
+ }, options);
+
+ spyOn(ediModel, 'getToken').and.returnValue(Promise.resolve('sampleToken'));
+ spyOn(ediModel, 'getData').and.returnValue(Promise.resolve([
+ {
+ expiry_date: '2001-01-01',
+ entry_date: '2001-01-01',
+ genus_id: 1,
+ latin_genus_name: 'Oasis',
+ change_date_time: '2001-03-15T10:30:15+01:00',
+ }, {
+ expiry_date: null,
+ entry_date: '2001-01-02',
+ genus_id: 2,
+ latin_genus_name: 'Ibiza',
+ change_date_time: '2001-02-03T18:20:42+00:00',
+ }
+ ]));
+
+ await ediModel.syncData(options);
+
+ const data = await ediModel.rawSql('SELECT * FROM edi.genus', [], options);
+ // The table is deleted within the method itself; it will always be 2
+ expect(data.length).toEqual(2);
+
+ await tx.rollback();
+ } catch (e) {
+ error = e;
+ await tx.rollback();
+ }
+
+ expect(error).toBeUndefined();
+ });
+
+ it('should throw an error if floricode service is not configured', async function() {
+ let error;
+ try {
+ await ediModel.syncData();
+ } catch (e) {
+ error = e;
+ }
+ expect(error).toBeDefined();
+ });
+});
diff --git a/back/methods/edi/syncData.js b/back/methods/edi/syncData.js
new file mode 100644
index 0000000000..36c527aaa2
--- /dev/null
+++ b/back/methods/edi/syncData.js
@@ -0,0 +1,93 @@
+const UserError = require('vn-loopback/util/user-error');
+const fs = require('fs-extra');
+const fastCsv = require("fast-csv");
+const axios = require('axios');
+const path = require('path');
+const { pipeline } = require('stream/promises');
+
+module.exports = Self => {
+ Self.remoteMethod('syncData', {
+ description: 'Sync schema data from external provider',
+ accessType: 'WRITE',
+ returns: {
+ type: 'object',
+ root: true
+ },
+ http: {
+ path: `/syncData`,
+ verb: 'POST'
+ }
+ });
+
+ Self.syncData = async options => {
+ const models = Self.app.models;
+ const myOptions = {};
+ if (typeof options == 'object')
+ Object.assign(myOptions, options);
+ let tx, ws;
+ try {
+ const floricodeConfig = await models.FloricodeConfig.findOne({}, myOptions);
+ if (!floricodeConfig) throw new UserError(`Floricode service is not configured`);
+
+ const tables = await models.TableMultiConfig.find({}, myOptions);
+ if (!tables?.length) throw new UserError(`No tables to sync`);
+
+ const token = await Self.getToken(floricodeConfig);
+ for (const table of tables) {
+ const data = await Self.getData(floricodeConfig.url, table.method, token);
+ if (!data) continue;
+
+ if (!myOptions.transaction) {
+ tx = await Self.beginTransaction({});
+ myOptions.transaction = tx;
+ }
+
+ await Self.rawSql(`DELETE FROM edi.??`, [table.toTable], myOptions);
+ ws = fs.createWriteStream(path.join(__dirname, `/${table.toTable}.csv`));
+ await pipeline(fastCsv.write(data, { delimiter: ';' }), ws);
+ const templatePath = path.join(__dirname, `./syncSql/${table.toTable}.sql`);
+ const sqlTemplate = await fs.readFile(templatePath, 'utf8');
+ await Self.rawSql(sqlTemplate, [ws.path], myOptions);
+
+ await fs.remove(ws.path);
+ await table.updateAttribute('updated', Date.vnNew(), myOptions);
+ if (tx) {
+ await tx.commit();
+ delete myOptions.transaction;
+ }
+ }
+ } catch (e) {
+ if (tx) await tx.rollback();
+ if (await fs.pathExists(ws?.path))
+ await fs.remove(ws?.path);
+ throw e;
+ }
+ };
+
+ Self.getToken = async function ({ url, user, password}) {
+ return (await axios.post(`${url}/oauth/token`, {
+ grant_type: 'client_credentials',
+ client_id: user,
+ client_secret: password
+ }, {
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
+ }
+ )).data.access_token;
+ };
+
+ Self.getData = async function (url, method, token) {
+ let data = [];
+ let count = 0;
+ const maxCount = (await Self.get(`${url}/v2/${method}?$count=true`, token))["@odata.count"];
+ while (count < maxCount) {
+ const response = await Self.get(`${url}/v2/${method}?$skip=${count}`, token)
+ data.push(...response.value);
+ count += response.value.length;
+ }
+ return data;
+ };
+
+ Self.get = async function get(url, token) {
+ return (await axios.get(url, { headers: { Authorization: `Bearer ${token}` } })).data;
+ };
+};
diff --git a/back/methods/edi/syncSql/bucket.sql b/back/methods/edi/syncSql/bucket.sql
new file mode 100644
index 0000000000..0effaaf98a
--- /dev/null
+++ b/back/methods/edi/syncSql/bucket.sql
@@ -0,0 +1,14 @@
+LOAD DATA LOCAL INFILE ?
+ INTO TABLE `edi`.`bucket`
+ FIELDS TERMINATED BY ';'
+ LINES TERMINATED BY '\n'
+ (@col1, @col2, @col3, @col4, @col5, @col6, @col7, @col8, @col9, @col10, @col11)
+ SET bucket_id = @col3,
+ bucket_type_id = @col5,
+ description = @col6,
+ x_size = @col7,
+ y_size = @col8,
+ z_size = @col9,
+ entry_date = STR_TO_DATE(@col2, '%Y-%m-%d'),
+ expiry_date = STR_TO_DATE(@col1, '%Y-%m-%d'),
+ change_date_time = STR_TO_DATE(REGEXP_REPLACE(@col11, '\\+.*$', ''), '%Y-%m-%dT%H:%i:%s')
diff --git a/back/methods/edi/syncSql/bucket_type.sql b/back/methods/edi/syncSql/bucket_type.sql
new file mode 100644
index 0000000000..570f26ae29
--- /dev/null
+++ b/back/methods/edi/syncSql/bucket_type.sql
@@ -0,0 +1,10 @@
+LOAD DATA LOCAL INFILE ?
+ INTO TABLE `edi`.`bucket_type`
+ FIELDS TERMINATED BY ';'
+ LINES TERMINATED BY '\n'
+ (@col1, @col2, @col3, @col4, @col5)
+ SET bucket_type_id = @col3,
+ description = @col4,
+ entry_date = STR_TO_DATE(@col2, '%Y-%m-%d'),
+ expiry_date = STR_TO_DATE(@col1, '%Y-%m-%d'),
+ change_date_time = STR_TO_DATE(REGEXP_REPLACE(@col5, '\\+.*$', ''), '%Y-%m-%dT%H:%i:%s')
diff --git a/back/methods/edi/syncSql/feature.sql b/back/methods/edi/syncSql/feature.sql
new file mode 100644
index 0000000000..3cfb98a096
--- /dev/null
+++ b/back/methods/edi/syncSql/feature.sql
@@ -0,0 +1,11 @@
+LOAD DATA LOCAL INFILE ?
+ INTO TABLE `edi`.`feature`
+ FIELDS TERMINATED BY ';'
+ LINES TERMINATED BY '\n'
+ (@col1, @col2, @col3, @col4, @col5, @col6)
+ SET item_id = @col3,
+ feature_type_id = @col4,
+ feature_value = @col5,
+ entry_date = STR_TO_DATE(@col2, '%Y-%m-%d'),
+ expiry_date = STR_TO_DATE(@col1, '%Y-%m-%d'),
+ change_date_time = STR_TO_DATE(REGEXP_REPLACE(@col6, '\\+.*$', ''), '%Y-%m-%dT%H:%i:%s')
diff --git a/back/methods/edi/syncSql/genus.sql b/back/methods/edi/syncSql/genus.sql
new file mode 100644
index 0000000000..9e4fddb4d5
--- /dev/null
+++ b/back/methods/edi/syncSql/genus.sql
@@ -0,0 +1,10 @@
+LOAD DATA LOCAL INFILE ?
+ INTO TABLE `edi`.`genus`
+ FIELDS TERMINATED BY ';'
+ LINES TERMINATED BY '\n'
+ (@col1, @col2, @col3, @col4, @col5)
+ SET genus_id = @col3,
+ latin_genus_name = @col4,
+ entry_date = STR_TO_DATE(@col2, '%Y-%m-%d'),
+ expiry_date = STR_TO_DATE(@col1, '%Y-%m-%d'),
+ change_date_time = STR_TO_DATE(REGEXP_REPLACE(@col5, '\\+.*$', ''), '%Y-%m-%dT%H:%i:%s')
diff --git a/back/methods/edi/syncSql/item.sql b/back/methods/edi/syncSql/item.sql
new file mode 100644
index 0000000000..8f605d2ffa
--- /dev/null
+++ b/back/methods/edi/syncSql/item.sql
@@ -0,0 +1,14 @@
+LOAD DATA LOCAL INFILE ?
+ INTO TABLE `edi`.`item`
+ CHARACTER SET ascii
+ FIELDS TERMINATED BY ';'
+ LINES TERMINATED BY '\n'
+ (@col1, @col2, @col3, @col4, @col5, @col6, @col7, @col8, @col9, @col10, @col11)
+ SET id = @col3,
+ product_name = @col5,
+ name = @col6,
+ plant_id = @col8,
+ group_id = @col10,
+ entry_date = STR_TO_DATE(@col2, '%Y-%m-%d'),
+ expiry_date = STR_TO_DATE(@col1, '%Y-%m-%d'),
+ change_date_time = STR_TO_DATE(REGEXP_REPLACE(@col11, '\\+.*$', ''), '%Y-%m-%dT%H:%i:%s')
diff --git a/back/methods/edi/syncSql/item_feature.sql b/back/methods/edi/syncSql/item_feature.sql
new file mode 100644
index 0000000000..fd4926ee5f
--- /dev/null
+++ b/back/methods/edi/syncSql/item_feature.sql
@@ -0,0 +1,12 @@
+LOAD DATA LOCAL INFILE ?
+ INTO TABLE `edi`.`item_feature`
+ FIELDS TERMINATED BY ';'
+ LINES TERMINATED BY '\n'
+ (@col1, @col2, @col3, @col4, @col5, @col6, @col7)
+ SET item_id = @col3,
+ feature = @col4,
+ regulation_type = @col5,
+ presentation_order = @col6,
+ entry_date = STR_TO_DATE(@col2, '%Y-%m-%d'),
+ expiry_date = STR_TO_DATE(@col1, '%Y-%m-%d'),
+ change_date_time = STR_TO_DATE(REGEXP_REPLACE(@col7, '\\+.*$', ''), '%Y-%m-%dT%H:%i:%s')
diff --git a/back/methods/edi/syncSql/item_group.sql b/back/methods/edi/syncSql/item_group.sql
new file mode 100644
index 0000000000..a330969d7d
--- /dev/null
+++ b/back/methods/edi/syncSql/item_group.sql
@@ -0,0 +1,10 @@
+LOAD DATA LOCAL INFILE ?
+ INTO TABLE `edi`.`item_group`
+ FIELDS TERMINATED BY ';'
+ LINES TERMINATED BY '\n'
+ (@col1, @col2, @col3, @col4, @col5)
+ SET group_code = @col3,
+ dutch_group_description = @col4,
+ entry_date = STR_TO_DATE(@col2, '%Y-%m-%d'),
+ expiry_date = STR_TO_DATE(@col1, '%Y-%m-%d'),
+ change_date_time = STR_TO_DATE(REGEXP_REPLACE(@col5, '\\+.*$', ''), '%Y-%m-%dT%H:%i:%s')
diff --git a/back/methods/edi/syncSql/plant.sql b/back/methods/edi/syncSql/plant.sql
new file mode 100644
index 0000000000..9ece3d245e
--- /dev/null
+++ b/back/methods/edi/syncSql/plant.sql
@@ -0,0 +1,11 @@
+LOAD DATA LOCAL INFILE ?
+ INTO TABLE `edi`.`plant`
+ FIELDS TERMINATED BY ';'
+ LINES TERMINATED BY '\n'
+ (@col1, @col2, @col3, @col4, @col5, @col6, @col7, @col8)
+ SET plant_id = @col4,
+ genus_id = @col5,
+ specie_id = @col6,
+ entry_date = STR_TO_DATE(@col2, '%Y-%m-%d'),
+ expiry_date = STR_TO_DATE(@col1, '%Y-%m-%d'),
+ change_date_time = STR_TO_DATE(REGEXP_REPLACE(@col8, '\\+.*$', ''), '%Y-%m-%dT%H:%i:%s')
diff --git a/back/methods/edi/syncSql/specie.sql b/back/methods/edi/syncSql/specie.sql
new file mode 100644
index 0000000000..9fce2a810d
--- /dev/null
+++ b/back/methods/edi/syncSql/specie.sql
@@ -0,0 +1,11 @@
+LOAD DATA LOCAL INFILE ?
+ INTO TABLE `edi`.`specie`
+ FIELDS TERMINATED BY ';'
+ LINES TERMINATED BY '\n'
+ (@col1, @col2, @col3, @col4, @col5, @col6)
+ SET specie_id = @col3,
+ genus_id = @col4,
+ latin_species_name = @col5,
+ entry_date = STR_TO_DATE(@col2, '%Y-%m-%d'),
+ expiry_date = STR_TO_DATE(@col1, '%Y-%m-%d'),
+ change_date_time = STR_TO_DATE(REGEXP_REPLACE(@col6, '\\+.*$', ''), '%Y-%m-%dT%H:%i:%s')
diff --git a/back/methods/edi/syncSql/supplier.sql b/back/methods/edi/syncSql/supplier.sql
new file mode 100644
index 0000000000..0a83d360eb
--- /dev/null
+++ b/back/methods/edi/syncSql/supplier.sql
@@ -0,0 +1,11 @@
+LOAD DATA LOCAL INFILE ?
+ INTO TABLE `edi`.`supplier`
+ FIELDS TERMINATED BY ';'
+ LINES TERMINATED BY '\n'
+ (@col1, @col2, @col3, @col4, @col5, @col6, @col7, @col8, @col9, @col10, @col11, @col12, @col13, @col14, @col15, @col16, @col17, @col18, @col19, @col20, @col21)
+ SET GLNAddressCode = @col3,
+ supplier_id = @col9,
+ company_name = @col4,
+ entry_date = STR_TO_DATE(@col2, '%Y-%m-%d'),
+ expiry_date = STR_TO_DATE(@col1, '%Y-%m-%d'),
+ change_date_time = STR_TO_DATE(REGEXP_REPLACE(@col17, '\\+.*$', ''), '%Y-%m-%dT%H:%i:%s')
diff --git a/back/methods/edi/syncSql/type.sql b/back/methods/edi/syncSql/type.sql
new file mode 100644
index 0000000000..eec5b0dcc3
--- /dev/null
+++ b/back/methods/edi/syncSql/type.sql
@@ -0,0 +1,10 @@
+LOAD DATA LOCAL INFILE ?
+ INTO TABLE `edi`.`type`
+ FIELDS TERMINATED BY ';'
+ LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6)
+ SET type_id = @col3,
+ type_group_id = @col4,
+ description = @col5,
+ entry_date = STR_TO_DATE(@col2, '%Y-%m-%d'),
+ expiry_date = STR_TO_DATE(@col1, '%Y-%m-%d'),
+ change_date_time = STR_TO_DATE(REGEXP_REPLACE(@col6, '\\+.*$', ''), '%Y-%m-%dT%H:%i:%s')
diff --git a/back/methods/edi/syncSql/value.sql b/back/methods/edi/syncSql/value.sql
new file mode 100644
index 0000000000..ea49eb3e48
--- /dev/null
+++ b/back/methods/edi/syncSql/value.sql
@@ -0,0 +1,10 @@
+LOAD DATA LOCAL INFILE ?
+ INTO TABLE `edi`.`value`
+ FIELDS TERMINATED BY ';'
+ LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6)
+ SET type_id = @col3,
+ type_value = @col4,
+ type_description = @col5,
+ entry_date = STR_TO_DATE(@col2, '%Y-%m-%d'),
+ expiry_date = STR_TO_DATE(@col1, '%Y-%m-%d'),
+ change_date_time = STR_TO_DATE(REGEXP_REPLACE(@col6, '\\+.*$', ''), '%Y-%m-%dT%H:%i:%s')
diff --git a/back/methods/workerActivity/add.js b/back/methods/workerActivity/add.js
index 89131491d1..b5b1bd65de 100644
--- a/back/methods/workerActivity/add.js
+++ b/back/methods/workerActivity/add.js
@@ -13,6 +13,11 @@ module.exports = Self => {
type: 'string',
description: 'Origin model from insert'
},
+ {
+ arg: 'description',
+ type: 'string',
+ description: 'Action description'
+ },
],
http: {
@@ -21,7 +26,7 @@ module.exports = Self => {
}
});
- Self.add = async(ctx, code, model, options) => {
+ Self.add = async(ctx, code, model, description, options) => {
const userId = ctx.req.accessToken.userId;
const myOptions = {};
@@ -29,8 +34,8 @@ module.exports = Self => {
Object.assign(myOptions, options);
return await Self.rawSql(`
- INSERT INTO workerActivity (workerFk, workerActivityTypeFk, model)
- SELECT ?, ?, ?
+ INSERT INTO workerActivity (workerFk, workerActivityTypeFk, model, description)
+ SELECT ?, ?, ?, ?
FROM workerTimeControlConfig wtcc
LEFT JOIN (
SELECT wa.workerFk,
@@ -43,8 +48,8 @@ module.exports = Self => {
LIMIT 1
) sub ON TRUE
WHERE sub.workerFk IS NULL
- OR sub.code <> ?
+ OR sub.code <> ?
OR TIMESTAMPDIFF(SECOND, sub.created, util.VN_NOW()) > wtcc.dayBreak;`
- , [userId, code, model, userId, code], myOptions);
+ , [userId, code, model, description, userId, code], myOptions);
};
};
diff --git a/back/methods/workerActivity/specs/add.spec.js b/back/methods/workerActivity/specs/add.spec.js
index 751cce009e..ad6cc7fa70 100644
--- a/back/methods/workerActivity/specs/add.spec.js
+++ b/back/methods/workerActivity/specs/add.spec.js
@@ -13,7 +13,7 @@ describe('workerActivity insert()', () => {
{'code': 'TEST', 'description': 'TEST'}, options
);
- await models.WorkerActivity.add(ctx, 'TEST', 'APP', options);
+ await models.WorkerActivity.add(ctx, 'TEST', 'APP', 'description', options);
count = await models.WorkerActivity.count(
{'workerFK': 1106}, options
diff --git a/back/model-config.json b/back/model-config.json
index 2ced867f7a..ee98809b62 100644
--- a/back/model-config.json
+++ b/back/model-config.json
@@ -70,6 +70,9 @@
"Expedition_PrintOut": {
"dataSource": "vn"
},
+ "FloricodeConfig": {
+ "dataSource": "vn"
+ },
"Image": {
"dataSource": "vn"
},
@@ -154,6 +157,9 @@
"SaySimpleConfig": {
"dataSource": "vn"
},
+ "TableMultiConfig": {
+ "dataSource": "vn"
+ },
"TempContainer": {
"dataSource": "tempStorage"
},
diff --git a/back/models/agency-workCenter.json b/back/models/agency-workCenter.json
index adf1e5bcb0..71de17cb25 100644
--- a/back/models/agency-workCenter.json
+++ b/back/models/agency-workCenter.json
@@ -24,7 +24,7 @@
"relations": {
"agency": {
"type": "belongsTo",
- "model": "WorkCenter",
+ "model": "Agency",
"foreignKey": "agencyFk"
},
"workCenter": {
diff --git a/back/models/edi.js b/back/models/edi.js
index bfddf2746e..b639938ab1 100644
--- a/back/models/edi.js
+++ b/back/models/edi.js
@@ -1,3 +1,4 @@
module.exports = Self => {
require('../methods/edi/updateData')(Self);
+ require('../methods/edi/syncData')(Self);
};
diff --git a/back/models/floricode-config.json b/back/models/floricode-config.json
new file mode 100644
index 0000000000..9e6976d2b2
--- /dev/null
+++ b/back/models/floricode-config.json
@@ -0,0 +1,28 @@
+{
+ "name": "FloricodeConfig",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "edi.floricodeConfig"
+ }
+ },
+ "properties": {
+ "id": {
+ "type": "number",
+ "id": true,
+ "required": true
+ },
+ "url": {
+ "type": "string",
+ "required": true
+ },
+ "user": {
+ "type": "string",
+ "required": false
+ },
+ "password": {
+ "type": "string",
+ "required": false
+ }
+ }
+}
diff --git a/back/models/table-multi-config.json b/back/models/table-multi-config.json
new file mode 100644
index 0000000000..b973ba7a54
--- /dev/null
+++ b/back/models/table-multi-config.json
@@ -0,0 +1,24 @@
+{
+ "name": "TableMultiConfig",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "edi.tableMultiConfig"
+ }
+ },
+ "properties": {
+ "id": {
+ "type": "number",
+ "required": true
+ },
+ "toTable": {
+ "type": "string"
+ },
+ "method": {
+ "type": "string"
+ },
+ "updated": {
+ "type": "date"
+ }
+ }
+}
diff --git a/db/.pullinfo.json b/db/.pullinfo.json
index b890ffc31b..423d99bb94 100644
--- a/db/.pullinfo.json
+++ b/db/.pullinfo.json
@@ -3,8 +3,8 @@
"shaSums": {
"srt": {
"view": {
- "routePalletized": "765f8933a6a5a86dfe8f22825cc77351bc8620cdf1be9d3f25abb130460f3a61",
- "ticketPalletized": "c327f3243e717cc607f01d3747967ba68158f90ef1038986b0aa6ae6d5ce7309"
+ "routePalletized": "98d228ced59c8ec590bbaf106cebf47689a02b32e895ba76b5b6e5c05d73cf14",
+ "ticketPalletized": "60d527908d473b92b70ba2ceed4e9be1f3be7509782f2c0d66d0cb98ecfeee2f"
}
},
"vn": {
diff --git a/db/dump/db.cnf b/db/dump/db.cnf
index 3dafaf5146..48523062dd 100644
--- a/db/dump/db.cnf
+++ b/db/dump/db.cnf
@@ -1,4 +1,5 @@
[mysqld]
+bind-address = 0.0.0.0
log-bin = bin.log
max_binlog_size = 1GB
binlog_row_image = noblob
diff --git a/db/dump/dump.before.sql b/db/dump/dump.before.sql
index 20a365c83b..4e0628dbb8 100644
--- a/db/dump/dump.before.sql
+++ b/db/dump/dump.before.sql
@@ -6,9 +6,10 @@ GRANT SELECT,
INSERT,
UPDATE,
DELETE,
- DROP,
CREATE TEMPORARY TABLES,
EXECUTE,
EVENT,
- TRIGGER
+ TRIGGER, -- EXECUTE TRIGGER
+ RELOAD, -- FLUSH PRIVILEGES
+ DROP -- TRUNCATE TABLE
ON *.* TO 'vn'@'localhost';
diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql
index e68a8a7260..4eb5b040d2 100644
--- a/db/dump/fixtures.after.sql
+++ b/db/dump/fixtures.after.sql
@@ -16,8 +16,8 @@ INSERT INTO vn.entryConfig (defaultEntry, mailToNotify, inventorySupplierFk, max
*/
-- XXX: eti
-INSERT INTO vn.travel (id,shipped,landed,warehouseInFk,warehouseOutFk,`ref`,m3,kg,cargoSupplierFk)
- VALUES (9,'2022-05-20','2022-05-20',13,4,'nine travel',69.0,600,1);
+INSERT INTO vn.travel (id,shipped,landed,availabled,warehouseInFk,warehouseOutFk,`ref`,m3,kg,cargoSupplierFk)
+ VALUES (9,'2022-05-20','2022-05-20','2022-05-20',13,4,'nine travel',69.0,600,1);
/* #5483
INSERT INTO vn.entry (id, supplierFk, dated, invoiceNumber, evaNotes, travelFk, companyFk)
VALUES
@@ -278,6 +278,15 @@ INSERT INTO `hedera`.`tpvConfig` (currency, terminal, transactionType, maxAmount
INSERT INTO hedera.tpvMerchantEnable (merchantFk, companyFk)
VALUES (1, 442);
+/* UPDATE vn.ticket t
+ JOIN vn.zone z ON z.id = t.zoneFk
+ SET t.shipped = DATE(t.shipped) +
+ INTERVAL HOUR(z.hour) HOUR +
+ INTERVAL MINUTE(z.hour) MINUTE;
+*/
+UPDATE vn.travel
+ SET availabled = landed
+ WHERE availabled IS NULL;
-- XXX
SET foreign_key_checks = 1;
diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql
index 8dc363590c..df62cc7873 100644
--- a/db/dump/fixtures.before.sql
+++ b/db/dump/fixtures.before.sql
@@ -195,7 +195,7 @@ INSERT INTO `vn`.`sectorType` (`id`, `code`)
INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `code`, `typeFk`)
VALUES
(1, 'First sector', 1, 'FIRST', 1),
- (2, 'Second sector', 2, 'SECOND',1);
+ (2, 'Second sector', 6, 'SECOND',1);
INSERT INTO `vn`.`printer` (`id`, `name`, `path`, `isLabeler`, `sectorFk`, `ipAddress`)
VALUES
@@ -730,7 +730,8 @@ INSERT INTO `vn`.`zoneWarehouse` (`id`, `zoneFk`, `warehouseFk`)
(10, 10, 3),
(11, 11, 5),
(12, 12, 4),
- (13, 13, 5);
+ (13, 13, 5),
+ (14, 7, 4);
INSERT INTO `vn`.`zoneClosure` (`zoneFk`, `dated`, `hour`)
VALUES
@@ -853,7 +854,8 @@ INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `userFk`, `created`)
INSERT INTO `vn`.`deliveryPoint` (`id`, `name`, `ubication`)
VALUES
- (1, 'Gotham','1007 Mountain Drive, Gotham');
+ (1, 'Gotham','1007 Mountain Drive, Gotham'),
+ (6, 'Stark Tower','200 Park Avenue, Nueva York');
INSERT INTO `vn`.`vehicle`(`id`, `numberPlate`, `tradeMark`, `model`, `companyFk`, `warehouseFk`, `description`, `m3`, `isActive`, `deliveryPointFk`, `chassis`, `leasing`, `supplierFk`, `fuelTypeFk`, `bankPolicyFk`)
VALUES
@@ -1302,9 +1304,10 @@ INSERT INTO `vn`.`train`(`id`, `name`)
INSERT INTO `vn`.`operator` (`workerFk`, `numberOfWagons`, `trainFk`, `itemPackingTypeFk`, `warehouseFk`, `sectorFk`, `labelerFk`)
VALUES
- ('1106', '1', '1', 'H', '1', '1', '1'),
- ('9', '2', '1', 'H', '1', '1', '1'),
- ('1107', '1', '1', 'V', '1', '1', '1');
+ (1106, '1', '1', 'H', '1', '1', '1'),
+ (9, '2', '1', 'H', '1', '1', '1'),
+ (1107, '1', '1', 'V', '1', '1', '1'),
+ (72, '1', '1', 'V', '1', '1', '1');
INSERT INTO `vn`.`collection`(`id`, `workerFk`, `stateFk`, `created`, `trainFk`)
VALUES
@@ -1534,20 +1537,20 @@ INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk
(9, '99610289193', 302, 2972, util.VN_CURDATE(), 3871, 442, 1),
(10, '07546500856', 185, 2364, util.VN_CURDATE(), 5321, 442, 1);
-INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`, `awbFK`, `isRaid`, `daysInForward`)
- VALUES (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, 1, FALSE, NULL),
- (2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150.00, 2000, 'second travel', 2, 2, 2, FALSE, NULL),
- (3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1, 3, FALSE, NULL),
- (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, 4, FALSE, NULL),
- (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, 5, FALSE, NULL),
- (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, 6, FALSE,NULL),
- (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, 7, TRUE, 2),
- (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, 10, FALSE, NULL),
- (10, DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10, TRUE, 2),
- (11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL),
- (12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL),
- (13, util.VN_CURDATE() - INTERVAL 1 MONTH - INTERVAL 1 DAY, util.VN_CURDATE() - INTERVAL 1 MONTH, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL),
- (14, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL);
+INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `availabled`,`warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`, `awbFK`, `isRaid`, `daysInForward`)
+ VALUES (1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 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, 1, FALSE, NULL),
+ (2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150.00, 2000, 'second travel', 2, 2, 2, FALSE, NULL),
+ (3, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1, 3, FALSE, NULL),
+ (4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 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, 4, FALSE, NULL),
+ (5, 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, 3, 1, 50.00, 500, 'fifth travel', 1, 1, 5, FALSE, NULL),
+ (6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 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, 6, FALSE,NULL),
+ (7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 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, 7, TRUE, 2),
+ (8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 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, 10, FALSE, NULL),
+ (10, DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10, TRUE, 2),
+ (11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL),
+ (12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL),
+ (13, util.VN_CURDATE() - INTERVAL 1 MONTH - INTERVAL 1 DAY, util.VN_CURDATE() - INTERVAL 1 MONTH, util.VN_CURDATE() - INTERVAL 1 MONTH, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL),
+ (14, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE() + INTERVAL 1 DAY,util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL);
INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `evaNotes`, `typeFk`)
VALUES
@@ -1615,6 +1618,7 @@ INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `sal
(19, 100, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'grouping', NULL, 0.00, 99.6, 99.4, 0, 1, 0, NULL, 1, util.VN_CURDATE()),
(20, 100, 2, 5, 450, 3, 2, 1.000, 1.000, 0.000, 10, 10, NULL, NULL, 0.00, 7.30, 7.00, 0, 1, 0, NULL, 2.5, util.VN_CURDATE()),
(21, 100,72, 55, 500, 5, 3, 1.000, 1.000, 0.000, 1, 1, 'packing', NULL, 0.00, 78.3, 75.6, 0, 1, 0, 1, 3, util.VN_CURDATE()),
+ (22, 100, 4, 55, 0, 5, 0, 0, 0, 0.000, 1, 1, 'packing', NULL, 0.00, 78.3, 75.6, 0, 1, 0, 1, 3, util.VN_CURDATE()),
(10000002, 12,88, 50.0000, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'grouping', NULL, 0.00, 99.60, 99.40, 0, 1, 0, 1.00, 1,util.VN_CURDATE() - INTERVAL 2 MONTH);
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`)
@@ -1957,11 +1961,11 @@ INSERT INTO `vn`.`claimBeginning`(`id`, `claimFk`, `saleFk`, `quantity`)
INSERT INTO `vn`.`claimDestination`(`id`, `description`, `addressFk`)
VALUES
- (1, 'Bueno', NULL),
- (2, 'Basura/Perd.', 12),
+ (1, 'Bueno', 11),
+ (2, 'Basura/Perd.', NULL),
(3, 'Confeccion', NULL),
- (4, 'Reclam.PRAG', 12),
- (5, 'Corregido', 11);
+ (4, 'Reclam.PRAG', NULL),
+ (5, 'Corregido', NULL);
INSERT INTO `vn`.`claimDevelopment`(`id`, `claimFk`, `claimResponsibleFk`, `workerFk`, `claimReasonFk`, `claimResultFk`, `claimRedeliveryFk`, `claimDestinationFk`)
VALUES
@@ -1976,9 +1980,9 @@ INSERT INTO `vn`.`claimEnd`(`id`, `saleFk`, `claimFk`, `workerFk`, `claimDestina
(1, 31, 4, 21, 2),
(2, 32, 3, 21, 3);
-INSERT INTO `vn`.`claimConfig`(`id`, `maxResponsibility`, `monthsToRefund`, `minShipped`,`daysToClaim`)
+INSERT INTO `vn`.`claimConfig`(`id`, `maxResponsibility`, `monthsToRefund`, `minShipped`,`daysToClaim`, `pickupDeliveryFk`, `warehouseFk`)
VALUES
- (1, 5, 4, '2016-10-01', 7);
+ (1, 5, 4, '2016-10-01', 7, 8, 4);
INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRate`, `priceIncreasing`, `packingRate`)
VALUES
@@ -2140,6 +2144,9 @@ UPDATE `vn`.`business`
UPDATE `vn`.`business` b
SET b.`workerBusinessProfessionalCategoryFk` = 2
WHERE b.`workerFk` = 1110;
+UPDATE `vn`.`business` b
+ SET b.`departmentFk` = 53
+ WHERE b.`workerFk` = 72;
UPDATE `vn`.`business` b
SET b.`departmentFk` = 43
@@ -2829,12 +2836,18 @@ INSERT INTO `bs`.`defaulter` (`clientFk`, `amount`, `created`, `defaulterSinced`
(1109, 500, util.VN_CURDATE(), util.VN_CURDATE());
UPDATE `vn`.`route`
- SET `invoiceInFk`=1
- WHERE `id`=1;
+ SET
+ `invoiceInFk` = 1,
+ `kmStart` = 0,
+ `kmEnd` = 0
+ WHERE `id` = 1;
UPDATE `vn`.`route`
- SET `invoiceInFk`=2
- WHERE `id`=2;
+ SET
+ `invoiceInFk` = 2,
+ `kmStart` = 0,
+ `kmEnd` = 0
+ WHERE `id` = 2;
INSERT INTO `bs`.`sale` (`saleFk`, `amount`, `dated`, `typeFk`, `clientFk`)
VALUES
@@ -3063,9 +3076,10 @@ INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
('salix', 'development', 'http://localhost:5000/#!/'),
('docuware', 'development', 'http://docuware');
-INSERT INTO `vn`.`report` (`id`, `name`, `paperSizeFk`, `method`)
+INSERT INTO `vn`.`report` (`name`, `method`)
VALUES
- (3, 'invoice', NULL, 'InvoiceOuts/{refFk}/invoice-out-pdf');
+ ('invoice', 'InvoiceOuts/{refFk}/invoice-out-pdf'),
+ ('LabelBuy', 'Entries/{id}/{labelType}/buy-label');
INSERT INTO `vn`.`payDemDetail` (`id`, `detail`)
VALUES
@@ -3327,6 +3341,7 @@ INSERT IGNORE INTO vn.itemType
INSERT IGNORE INTO vn.travel
SET id = 99,
shipped = CURDATE(),
+ availabled = CURDATE(),
landed = CURDATE(),
warehouseInFk = 999,
warehouseOutFk = 1,
@@ -4142,3 +4157,9 @@ INSERT IGNORE INTO vn.vehicleType (id, name)
(2, 'furgoneta'),
(3, 'cabeza tractora'),
(4, 'remolque');
+
+INSERT INTO edi.tableMultiConfig (fileName, toTable, file, `method`, updated)
+ VALUES ('FG', 'genus', 'florecompc2', 'VBN/Genus', '2001-01-01');
+
+INSERT INTO vn.addressWaste (addressFk, type)
+ VALUES (11, 'fault');
diff --git a/db/dump/mockDate.sql b/db/dump/mockDate.sql
index 1ed5d76bef..b74bc9bb6f 100644
--- a/db/dump/mockDate.sql
+++ b/db/dump/mockDate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION util.mockTime()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION util.mockTime()
RETURNS DATETIME
DETERMINISTIC
BEGIN
@@ -8,7 +8,7 @@ END$$
DELIMITER ;
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION util.mockUtcTime()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION util.mockUtcTime()
RETURNS DATETIME
DETERMINISTIC
BEGIN
diff --git a/db/routines/account/functions/myUser_checkLogin.sql b/db/routines/account/functions/myUser_checkLogin.sql
index ed55f0d13f..76cf6da04a 100644
--- a/db/routines/account/functions/myUser_checkLogin.sql
+++ b/db/routines/account/functions/myUser_checkLogin.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `account`.`myUser_checkLogin`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `account`.`myUser_checkLogin`()
RETURNS tinyint(1)
DETERMINISTIC
READS SQL DATA
diff --git a/db/routines/account/functions/myUser_getId.sql b/db/routines/account/functions/myUser_getId.sql
index bc86c87dc8..864e798a99 100644
--- a/db/routines/account/functions/myUser_getId.sql
+++ b/db/routines/account/functions/myUser_getId.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `account`.`myUser_getId`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `account`.`myUser_getId`()
RETURNS int(11)
DETERMINISTIC
READS SQL DATA
diff --git a/db/routines/account/functions/myUser_getName.sql b/db/routines/account/functions/myUser_getName.sql
index 541f7c0866..e91681329e 100644
--- a/db/routines/account/functions/myUser_getName.sql
+++ b/db/routines/account/functions/myUser_getName.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `account`.`myUser_getName`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `account`.`myUser_getName`()
RETURNS varchar(30) CHARSET utf8mb3 COLLATE utf8mb3_general_ci
DETERMINISTIC
NO SQL
diff --git a/db/routines/account/functions/myUser_hasPriv.sql b/db/routines/account/functions/myUser_hasPriv.sql
index b53580d740..8105e9baa4 100644
--- a/db/routines/account/functions/myUser_hasPriv.sql
+++ b/db/routines/account/functions/myUser_hasPriv.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `account`.`myUser_hasPriv`(vChain VARCHAR(100),
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `account`.`myUser_hasPriv`(vChain VARCHAR(100),
vPrivilege ENUM('SELECT','INSERT','UPDATE','DELETE')
)
RETURNS tinyint(1)
diff --git a/db/routines/account/functions/myUser_hasRole.sql b/db/routines/account/functions/myUser_hasRole.sql
index 8cc8aafb59..53fd143fd5 100644
--- a/db/routines/account/functions/myUser_hasRole.sql
+++ b/db/routines/account/functions/myUser_hasRole.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `account`.`myUser_hasRole`(vRoleName VARCHAR(255))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `account`.`myUser_hasRole`(vRoleName VARCHAR(255))
RETURNS tinyint(1)
DETERMINISTIC
BEGIN
diff --git a/db/routines/account/functions/myUser_hasRoleId.sql b/db/routines/account/functions/myUser_hasRoleId.sql
index d059b095d0..fd8b3fb198 100644
--- a/db/routines/account/functions/myUser_hasRoleId.sql
+++ b/db/routines/account/functions/myUser_hasRoleId.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `account`.`myUser_hasRoleId`(vRoleId INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `account`.`myUser_hasRoleId`(vRoleId INT)
RETURNS tinyint(1)
DETERMINISTIC
BEGIN
diff --git a/db/routines/account/functions/myUser_hasRoutinePriv.sql b/db/routines/account/functions/myUser_hasRoutinePriv.sql
index 9e9563a5f6..517e36f5cd 100644
--- a/db/routines/account/functions/myUser_hasRoutinePriv.sql
+++ b/db/routines/account/functions/myUser_hasRoutinePriv.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `account`.`myUser_hasRoutinePriv`(vType ENUM('PROCEDURE', 'FUNCTION'),
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `account`.`myUser_hasRoutinePriv`(vType ENUM('PROCEDURE', 'FUNCTION'),
vChain VARCHAR(100)
)
RETURNS tinyint(1)
diff --git a/db/routines/account/functions/passwordGenerate.sql b/db/routines/account/functions/passwordGenerate.sql
index 952a8912cc..a4cff0ab9c 100644
--- a/db/routines/account/functions/passwordGenerate.sql
+++ b/db/routines/account/functions/passwordGenerate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `account`.`passwordGenerate`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `account`.`passwordGenerate`()
RETURNS text CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci
NOT DETERMINISTIC
READS SQL DATA
diff --git a/db/routines/account/functions/toUnixDays.sql b/db/routines/account/functions/toUnixDays.sql
index db908060b1..931c29cb01 100644
--- a/db/routines/account/functions/toUnixDays.sql
+++ b/db/routines/account/functions/toUnixDays.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `account`.`toUnixDays`(vDate DATE)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `account`.`toUnixDays`(vDate DATE)
RETURNS int(11)
DETERMINISTIC
BEGIN
diff --git a/db/routines/account/functions/user_getMysqlRole.sql b/db/routines/account/functions/user_getMysqlRole.sql
index 91540bc6ba..e507264800 100644
--- a/db/routines/account/functions/user_getMysqlRole.sql
+++ b/db/routines/account/functions/user_getMysqlRole.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `account`.`user_getMysqlRole`(vUserName VARCHAR(255))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `account`.`user_getMysqlRole`(vUserName VARCHAR(255))
RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci
DETERMINISTIC
BEGIN
diff --git a/db/routines/account/functions/user_getNameFromId.sql b/db/routines/account/functions/user_getNameFromId.sql
index b06facd7a3..27ea434e8c 100644
--- a/db/routines/account/functions/user_getNameFromId.sql
+++ b/db/routines/account/functions/user_getNameFromId.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `account`.`user_getNameFromId`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `account`.`user_getNameFromId`(vSelf INT)
RETURNS varchar(30) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci
DETERMINISTIC
BEGIN
diff --git a/db/routines/account/functions/user_hasPriv.sql b/db/routines/account/functions/user_hasPriv.sql
index 83bdfaa194..fc74b197a1 100644
--- a/db/routines/account/functions/user_hasPriv.sql
+++ b/db/routines/account/functions/user_hasPriv.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `account`.`user_hasPriv`(vChain VARCHAR(100),
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `account`.`user_hasPriv`(vChain VARCHAR(100),
vPrivilege ENUM('SELECT','INSERT','UPDATE','DELETE'),
vUserFk INT
)
diff --git a/db/routines/account/functions/user_hasRole.sql b/db/routines/account/functions/user_hasRole.sql
index fb88efeecd..71bd7bcaee 100644
--- a/db/routines/account/functions/user_hasRole.sql
+++ b/db/routines/account/functions/user_hasRole.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `account`.`user_hasRole`(vUserName VARCHAR(255), vRoleName VARCHAR(255))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `account`.`user_hasRole`(vUserName VARCHAR(255), vRoleName VARCHAR(255))
RETURNS tinyint(1)
DETERMINISTIC
BEGIN
diff --git a/db/routines/account/functions/user_hasRoleId.sql b/db/routines/account/functions/user_hasRoleId.sql
index a35624d3d6..1ba5fae75c 100644
--- a/db/routines/account/functions/user_hasRoleId.sql
+++ b/db/routines/account/functions/user_hasRoleId.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `account`.`user_hasRoleId`(vUser VARCHAR(255), vRoleId INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `account`.`user_hasRoleId`(vUser VARCHAR(255), vRoleId INT)
RETURNS tinyint(1)
DETERMINISTIC
BEGIN
diff --git a/db/routines/account/functions/user_hasRoutinePriv.sql b/db/routines/account/functions/user_hasRoutinePriv.sql
index 6f87f160c4..b19ed6c2a7 100644
--- a/db/routines/account/functions/user_hasRoutinePriv.sql
+++ b/db/routines/account/functions/user_hasRoutinePriv.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `account`.`user_hasRoutinePriv`(vType ENUM('PROCEDURE', 'FUNCTION'),
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `account`.`user_hasRoutinePriv`(vType ENUM('PROCEDURE', 'FUNCTION'),
vChain VARCHAR(100),
vUserFk INT
)
diff --git a/db/routines/account/procedures/account_enable.sql b/db/routines/account/procedures/account_enable.sql
index 9f43c97a38..9441e46c8f 100644
--- a/db/routines/account/procedures/account_enable.sql
+++ b/db/routines/account/procedures/account_enable.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `account`.`account_enable`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `account`.`account_enable`(vSelf INT)
BEGIN
/**
* Enables an account and sets up email configuration.
diff --git a/db/routines/account/procedures/myUser_login.sql b/db/routines/account/procedures/myUser_login.sql
index be547292e5..013dc55d7d 100644
--- a/db/routines/account/procedures/myUser_login.sql
+++ b/db/routines/account/procedures/myUser_login.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `account`.`myUser_login`(vUserName VARCHAR(255), vPassword VARCHAR(255))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `account`.`myUser_login`(vUserName VARCHAR(255), vPassword VARCHAR(255))
READS SQL DATA
BEGIN
/**
diff --git a/db/routines/account/procedures/myUser_loginWithKey.sql b/db/routines/account/procedures/myUser_loginWithKey.sql
index 67d8c99232..dab21e433c 100644
--- a/db/routines/account/procedures/myUser_loginWithKey.sql
+++ b/db/routines/account/procedures/myUser_loginWithKey.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `account`.`myUser_loginWithKey`(vUserName VARCHAR(255), vKey VARCHAR(255))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `account`.`myUser_loginWithKey`(vUserName VARCHAR(255), vKey VARCHAR(255))
READS SQL DATA
BEGIN
/**
diff --git a/db/routines/account/procedures/myUser_loginWithName.sql b/db/routines/account/procedures/myUser_loginWithName.sql
index 522da77dd8..c71b7ae7b2 100644
--- a/db/routines/account/procedures/myUser_loginWithName.sql
+++ b/db/routines/account/procedures/myUser_loginWithName.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `account`.`myUser_loginWithName`(vUserName VARCHAR(255))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `account`.`myUser_loginWithName`(vUserName VARCHAR(255))
READS SQL DATA
BEGIN
/**
diff --git a/db/routines/account/procedures/myUser_logout.sql b/db/routines/account/procedures/myUser_logout.sql
index a1d7db361a..8740a1b254 100644
--- a/db/routines/account/procedures/myUser_logout.sql
+++ b/db/routines/account/procedures/myUser_logout.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `account`.`myUser_logout`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `account`.`myUser_logout`()
BEGIN
/**
* Logouts the user.
diff --git a/db/routines/account/procedures/role_checkName.sql b/db/routines/account/procedures/role_checkName.sql
index 55d9d80a9c..5f5a8b8457 100644
--- a/db/routines/account/procedures/role_checkName.sql
+++ b/db/routines/account/procedures/role_checkName.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `account`.`role_checkName`(vRoleName VARCHAR(255))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `account`.`role_checkName`(vRoleName VARCHAR(255))
BEGIN
/**
* Checks that role name meets the necessary syntax requirements, otherwise it
diff --git a/db/routines/account/procedures/role_getDescendents.sql b/db/routines/account/procedures/role_getDescendents.sql
index ecd4a8790b..fcc9536fdd 100644
--- a/db/routines/account/procedures/role_getDescendents.sql
+++ b/db/routines/account/procedures/role_getDescendents.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `account`.`role_getDescendents`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `account`.`role_getDescendents`(vSelf INT)
BEGIN
/**
* Gets the identifiers of all the subroles implemented by a role (Including
diff --git a/db/routines/account/procedures/role_sync.sql b/db/routines/account/procedures/role_sync.sql
index 139193a31a..645f1f6149 100644
--- a/db/routines/account/procedures/role_sync.sql
+++ b/db/routines/account/procedures/role_sync.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `account`.`role_sync`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `account`.`role_sync`()
BEGIN
/**
* Synchronize the @roleRole table with the current role hierarchy. This
diff --git a/db/routines/account/procedures/role_syncPrivileges.sql b/db/routines/account/procedures/role_syncPrivileges.sql
index cf265b4bdf..cfdb815936 100644
--- a/db/routines/account/procedures/role_syncPrivileges.sql
+++ b/db/routines/account/procedures/role_syncPrivileges.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `account`.`role_syncPrivileges`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `account`.`role_syncPrivileges`()
BEGIN
/**
* Synchronizes permissions of MySQL role users based on role hierarchy.
diff --git a/db/routines/account/procedures/user_checkName.sql b/db/routines/account/procedures/user_checkName.sql
index 6fab173615..ca12a67a2f 100644
--- a/db/routines/account/procedures/user_checkName.sql
+++ b/db/routines/account/procedures/user_checkName.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `account`.`user_checkName`(vUserName VARCHAR(255))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `account`.`user_checkName`(vUserName VARCHAR(255))
BEGIN
/**
* Checks that username meets the necessary syntax requirements, otherwise it
diff --git a/db/routines/account/procedures/user_checkPassword.sql b/db/routines/account/procedures/user_checkPassword.sql
index eb09905334..d696c51cd5 100644
--- a/db/routines/account/procedures/user_checkPassword.sql
+++ b/db/routines/account/procedures/user_checkPassword.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `account`.`user_checkPassword`(vPassword VARCHAR(255))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `account`.`user_checkPassword`(vPassword VARCHAR(255))
BEGIN
/**
* Comprueba si la contraseña cumple los requisitos de seguridad
diff --git a/db/routines/account/triggers/account_afterDelete.sql b/db/routines/account/triggers/account_afterDelete.sql
index be0e5901fb..5249b358d4 100644
--- a/db/routines/account/triggers/account_afterDelete.sql
+++ b/db/routines/account/triggers/account_afterDelete.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`account_afterDelete`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `account`.`account_afterDelete`
AFTER DELETE ON `account`
FOR EACH ROW
BEGIN
diff --git a/db/routines/account/triggers/account_afterInsert.sql b/db/routines/account/triggers/account_afterInsert.sql
index be2959ab67..0fe35867ed 100644
--- a/db/routines/account/triggers/account_afterInsert.sql
+++ b/db/routines/account/triggers/account_afterInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`account_afterInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `account`.`account_afterInsert`
AFTER INSERT ON `account`
FOR EACH ROW
BEGIN
diff --git a/db/routines/account/triggers/account_beforeInsert.sql b/db/routines/account/triggers/account_beforeInsert.sql
index 43b611990a..b4e9f06f71 100644
--- a/db/routines/account/triggers/account_beforeInsert.sql
+++ b/db/routines/account/triggers/account_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`account_beforeInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `account`.`account_beforeInsert`
BEFORE INSERT ON `account`
FOR EACH ROW
BEGIN
diff --git a/db/routines/account/triggers/account_beforeUpdate.sql b/db/routines/account/triggers/account_beforeUpdate.sql
index bbcea028d7..05d3ec3aeb 100644
--- a/db/routines/account/triggers/account_beforeUpdate.sql
+++ b/db/routines/account/triggers/account_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`account_beforeUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `account`.`account_beforeUpdate`
BEFORE UPDATE ON `account`
FOR EACH ROW
BEGIN
diff --git a/db/routines/account/triggers/mailAliasAccount_afterDelete.sql b/db/routines/account/triggers/mailAliasAccount_afterDelete.sql
index 83af7169c2..32b5b620eb 100644
--- a/db/routines/account/triggers/mailAliasAccount_afterDelete.sql
+++ b/db/routines/account/triggers/mailAliasAccount_afterDelete.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`mailAliasAccount_afterDelete`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `account`.`mailAliasAccount_afterDelete`
AFTER DELETE ON `mailAliasAccount`
FOR EACH ROW
BEGIN
diff --git a/db/routines/account/triggers/mailAliasAccount_beforeInsert.sql b/db/routines/account/triggers/mailAliasAccount_beforeInsert.sql
index a435832f20..171c7bc7af 100644
--- a/db/routines/account/triggers/mailAliasAccount_beforeInsert.sql
+++ b/db/routines/account/triggers/mailAliasAccount_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`mailAliasAccount_beforeInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `account`.`mailAliasAccount_beforeInsert`
BEFORE INSERT ON `mailAliasAccount`
FOR EACH ROW
BEGIN
diff --git a/db/routines/account/triggers/mailAliasAccount_beforeUpdate.sql b/db/routines/account/triggers/mailAliasAccount_beforeUpdate.sql
index 471a349006..4d05fc32ab 100644
--- a/db/routines/account/triggers/mailAliasAccount_beforeUpdate.sql
+++ b/db/routines/account/triggers/mailAliasAccount_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`mailAliasAccount_beforeUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `account`.`mailAliasAccount_beforeUpdate`
BEFORE UPDATE ON `mailAliasAccount`
FOR EACH ROW
BEGIN
diff --git a/db/routines/account/triggers/mailAlias_afterDelete.sql b/db/routines/account/triggers/mailAlias_afterDelete.sql
index fe944246d2..ec01b1a4b6 100644
--- a/db/routines/account/triggers/mailAlias_afterDelete.sql
+++ b/db/routines/account/triggers/mailAlias_afterDelete.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`mailAlias_afterDelete`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `account`.`mailAlias_afterDelete`
AFTER DELETE ON `mailAlias`
FOR EACH ROW
BEGIN
diff --git a/db/routines/account/triggers/mailAlias_beforeInsert.sql b/db/routines/account/triggers/mailAlias_beforeInsert.sql
index 37a9546ca7..02f900f563 100644
--- a/db/routines/account/triggers/mailAlias_beforeInsert.sql
+++ b/db/routines/account/triggers/mailAlias_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`mailAlias_beforeInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `account`.`mailAlias_beforeInsert`
BEFORE INSERT ON `mailAlias`
FOR EACH ROW
BEGIN
diff --git a/db/routines/account/triggers/mailAlias_beforeUpdate.sql b/db/routines/account/triggers/mailAlias_beforeUpdate.sql
index e3940cfda6..0f14dcf3f0 100644
--- a/db/routines/account/triggers/mailAlias_beforeUpdate.sql
+++ b/db/routines/account/triggers/mailAlias_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`mailAlias_beforeUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `account`.`mailAlias_beforeUpdate`
BEFORE UPDATE ON `mailAlias`
FOR EACH ROW
BEGIN
diff --git a/db/routines/account/triggers/mailForward_afterDelete.sql b/db/routines/account/triggers/mailForward_afterDelete.sql
index cb02b746d8..c1eef93deb 100644
--- a/db/routines/account/triggers/mailForward_afterDelete.sql
+++ b/db/routines/account/triggers/mailForward_afterDelete.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`mailForward_afterDelete`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `account`.`mailForward_afterDelete`
AFTER DELETE ON `mailForward`
FOR EACH ROW
BEGIN
diff --git a/db/routines/account/triggers/mailForward_beforeInsert.sql b/db/routines/account/triggers/mailForward_beforeInsert.sql
index bc4e5ef172..bf5bd1369a 100644
--- a/db/routines/account/triggers/mailForward_beforeInsert.sql
+++ b/db/routines/account/triggers/mailForward_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`mailForward_beforeInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `account`.`mailForward_beforeInsert`
BEFORE INSERT ON `mailForward`
FOR EACH ROW
BEGIN
diff --git a/db/routines/account/triggers/mailForward_beforeUpdate.sql b/db/routines/account/triggers/mailForward_beforeUpdate.sql
index 88594979a2..590b203474 100644
--- a/db/routines/account/triggers/mailForward_beforeUpdate.sql
+++ b/db/routines/account/triggers/mailForward_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`mailForward_beforeUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `account`.`mailForward_beforeUpdate`
BEFORE UPDATE ON `mailForward`
FOR EACH ROW
BEGIN
diff --git a/db/routines/account/triggers/roleInherit_afterDelete.sql b/db/routines/account/triggers/roleInherit_afterDelete.sql
index c7c82eedb0..84e2cbc67d 100644
--- a/db/routines/account/triggers/roleInherit_afterDelete.sql
+++ b/db/routines/account/triggers/roleInherit_afterDelete.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`roleInherit_afterDelete`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `account`.`roleInherit_afterDelete`
AFTER DELETE ON `roleInherit`
FOR EACH ROW
BEGIN
diff --git a/db/routines/account/triggers/roleInherit_beforeInsert.sql b/db/routines/account/triggers/roleInherit_beforeInsert.sql
index 77932c12d1..a964abecbb 100644
--- a/db/routines/account/triggers/roleInherit_beforeInsert.sql
+++ b/db/routines/account/triggers/roleInherit_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`roleInherit_beforeInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `account`.`roleInherit_beforeInsert`
BEFORE INSERT ON `roleInherit`
FOR EACH ROW
BEGIN
diff --git a/db/routines/account/triggers/roleInherit_beforeUpdate.sql b/db/routines/account/triggers/roleInherit_beforeUpdate.sql
index 05aef0b95a..05b2ae8b5e 100644
--- a/db/routines/account/triggers/roleInherit_beforeUpdate.sql
+++ b/db/routines/account/triggers/roleInherit_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`roleInherit_beforeUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `account`.`roleInherit_beforeUpdate`
BEFORE UPDATE ON `roleInherit`
FOR EACH ROW
BEGIN
diff --git a/db/routines/account/triggers/role_afterDelete.sql b/db/routines/account/triggers/role_afterDelete.sql
index be382cba63..731f1c978e 100644
--- a/db/routines/account/triggers/role_afterDelete.sql
+++ b/db/routines/account/triggers/role_afterDelete.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`role_afterDelete`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `account`.`role_afterDelete`
AFTER DELETE ON `role`
FOR EACH ROW
BEGIN
diff --git a/db/routines/account/triggers/role_beforeInsert.sql b/db/routines/account/triggers/role_beforeInsert.sql
index f68a211a76..35e493bf7e 100644
--- a/db/routines/account/triggers/role_beforeInsert.sql
+++ b/db/routines/account/triggers/role_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`role_beforeInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `account`.`role_beforeInsert`
BEFORE INSERT ON `role`
FOR EACH ROW
BEGIN
diff --git a/db/routines/account/triggers/role_beforeUpdate.sql b/db/routines/account/triggers/role_beforeUpdate.sql
index a2f471b646..588d2271d1 100644
--- a/db/routines/account/triggers/role_beforeUpdate.sql
+++ b/db/routines/account/triggers/role_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`role_beforeUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `account`.`role_beforeUpdate`
BEFORE UPDATE ON `role`
FOR EACH ROW
BEGIN
diff --git a/db/routines/account/triggers/user_afterDelete.sql b/db/routines/account/triggers/user_afterDelete.sql
index eabe60d8cf..710549cc66 100644
--- a/db/routines/account/triggers/user_afterDelete.sql
+++ b/db/routines/account/triggers/user_afterDelete.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`user_afterDelete`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `account`.`user_afterDelete`
AFTER DELETE ON `user`
FOR EACH ROW
BEGIN
diff --git a/db/routines/account/triggers/user_afterInsert.sql b/db/routines/account/triggers/user_afterInsert.sql
index 31f992c16b..2cc4da49b0 100644
--- a/db/routines/account/triggers/user_afterInsert.sql
+++ b/db/routines/account/triggers/user_afterInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`user_afterInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `account`.`user_afterInsert`
AFTER INSERT ON `user`
FOR EACH ROW
BEGIN
diff --git a/db/routines/account/triggers/user_afterUpdate.sql b/db/routines/account/triggers/user_afterUpdate.sql
index 7fb4e644f5..7e5415ee7f 100644
--- a/db/routines/account/triggers/user_afterUpdate.sql
+++ b/db/routines/account/triggers/user_afterUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`user_afterUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `account`.`user_afterUpdate`
AFTER UPDATE ON `user`
FOR EACH ROW
BEGIN
diff --git a/db/routines/account/triggers/user_beforeInsert.sql b/db/routines/account/triggers/user_beforeInsert.sql
index 6cafa8b3ff..e15f8faa51 100644
--- a/db/routines/account/triggers/user_beforeInsert.sql
+++ b/db/routines/account/triggers/user_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`user_beforeInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `account`.`user_beforeInsert`
BEFORE INSERT ON `user`
FOR EACH ROW
BEGIN
diff --git a/db/routines/account/triggers/user_beforeUpdate.sql b/db/routines/account/triggers/user_beforeUpdate.sql
index 849dfbd91b..ae8d648e29 100644
--- a/db/routines/account/triggers/user_beforeUpdate.sql
+++ b/db/routines/account/triggers/user_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`user_beforeUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `account`.`user_beforeUpdate`
BEFORE UPDATE ON `user`
FOR EACH ROW
BEGIN
diff --git a/db/routines/account/views/accountDovecot.sql b/db/routines/account/views/accountDovecot.sql
index 1e30946f3f..d3d03ca641 100644
--- a/db/routines/account/views/accountDovecot.sql
+++ b/db/routines/account/views/accountDovecot.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `account`.`accountDovecot`
AS SELECT `u`.`name` AS `name`,
diff --git a/db/routines/account/views/emailUser.sql b/db/routines/account/views/emailUser.sql
index dcb4354540..d6a66719c6 100644
--- a/db/routines/account/views/emailUser.sql
+++ b/db/routines/account/views/emailUser.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `account`.`emailUser`
AS SELECT `u`.`id` AS `userFk`,
diff --git a/db/routines/account/views/myRole.sql b/db/routines/account/views/myRole.sql
index 68364f0bc1..036300db58 100644
--- a/db/routines/account/views/myRole.sql
+++ b/db/routines/account/views/myRole.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `account`.`myRole`
AS SELECT `r`.`inheritsFrom` AS `id`
diff --git a/db/routines/account/views/myUser.sql b/db/routines/account/views/myUser.sql
index 8d927dc0f3..faf7f76aec 100644
--- a/db/routines/account/views/myUser.sql
+++ b/db/routines/account/views/myUser.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `account`.`myUser`
AS SELECT `u`.`id` AS `id`,
diff --git a/db/routines/bi/procedures/Greuge_Evolution_Add.sql b/db/routines/bi/procedures/Greuge_Evolution_Add.sql
index 6480155cb1..bf5693ad28 100644
--- a/db/routines/bi/procedures/Greuge_Evolution_Add.sql
+++ b/db/routines/bi/procedures/Greuge_Evolution_Add.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`Greuge_Evolution_Add`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bi`.`Greuge_Evolution_Add`()
BEGIN
/*
Inserta en la tabla Greuge_Evolution el saldo acumulado de cada cliente,
diff --git a/db/routines/bi/procedures/analisis_ventas_evolution_add.sql b/db/routines/bi/procedures/analisis_ventas_evolution_add.sql
index 7c2cc5678d..bbee190ea6 100644
--- a/db/routines/bi/procedures/analisis_ventas_evolution_add.sql
+++ b/db/routines/bi/procedures/analisis_ventas_evolution_add.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`analisis_ventas_evolution_add`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bi`.`analisis_ventas_evolution_add`()
BEGIN
DECLARE vPreviousPeriod INT;
DECLARE vCurrentPeriod INT;
diff --git a/db/routines/bi/procedures/analisis_ventas_simple.sql b/db/routines/bi/procedures/analisis_ventas_simple.sql
index 5c67584eed..597d9bcd48 100644
--- a/db/routines/bi/procedures/analisis_ventas_simple.sql
+++ b/db/routines/bi/procedures/analisis_ventas_simple.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`analisis_ventas_simple`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bi`.`analisis_ventas_simple`()
BEGIN
/**
* Vacia y rellena la tabla 'analisis_grafico_simple' desde 'analisis_grafico_ventas'
diff --git a/db/routines/bi/procedures/analisis_ventas_update.sql b/db/routines/bi/procedures/analisis_ventas_update.sql
index ef3e165a03..a7bb463876 100644
--- a/db/routines/bi/procedures/analisis_ventas_update.sql
+++ b/db/routines/bi/procedures/analisis_ventas_update.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`analisis_ventas_update`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bi`.`analisis_ventas_update`()
BEGIN
DECLARE vLastMonth DATE;
diff --git a/db/routines/bi/procedures/clean.sql b/db/routines/bi/procedures/clean.sql
index a1eb991660..4c3994dd52 100644
--- a/db/routines/bi/procedures/clean.sql
+++ b/db/routines/bi/procedures/clean.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`clean`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bi`.`clean`()
BEGIN
DECLARE vDateShort DATETIME;
DECLARE vDateLong DATETIME;
diff --git a/db/routines/bi/procedures/defaultersFromDate.sql b/db/routines/bi/procedures/defaultersFromDate.sql
index bfe1337506..88828a6e1d 100644
--- a/db/routines/bi/procedures/defaultersFromDate.sql
+++ b/db/routines/bi/procedures/defaultersFromDate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`defaultersFromDate`(IN vDate DATE)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bi`.`defaultersFromDate`(IN vDate DATE)
BEGIN
SELECT t1.*, c.name Cliente, w.code workerCode, c.payMethodFk pay_met_id, c.dueDay Vencimiento
diff --git a/db/routines/bi/procedures/defaulting.sql b/db/routines/bi/procedures/defaulting.sql
index d20232b8b0..db030fa0f3 100644
--- a/db/routines/bi/procedures/defaulting.sql
+++ b/db/routines/bi/procedures/defaulting.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`defaulting`(IN `vDate` DATE)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bi`.`defaulting`(IN `vDate` DATE)
BEGIN
DECLARE vDone BOOLEAN;
DECLARE vClient INT;
diff --git a/db/routines/bi/procedures/defaulting_launcher.sql b/db/routines/bi/procedures/defaulting_launcher.sql
index 585abdc09b..a0df72adf9 100644
--- a/db/routines/bi/procedures/defaulting_launcher.sql
+++ b/db/routines/bi/procedures/defaulting_launcher.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`defaulting_launcher`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bi`.`defaulting_launcher`()
BEGIN
/**
* Calcula la morosidad de los clientes.
diff --git a/db/routines/bi/procedures/facturacion_media_anual_update.sql b/db/routines/bi/procedures/facturacion_media_anual_update.sql
index e8810cc219..62f5d623d5 100644
--- a/db/routines/bi/procedures/facturacion_media_anual_update.sql
+++ b/db/routines/bi/procedures/facturacion_media_anual_update.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`facturacion_media_anual_update`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bi`.`facturacion_media_anual_update`()
BEGIN
TRUNCATE TABLE bs.clientAnnualConsumption;
diff --git a/db/routines/bi/procedures/greuge_dif_porte_add.sql b/db/routines/bi/procedures/greuge_dif_porte_add.sql
index 330ff92b81..b86524f59c 100644
--- a/db/routines/bi/procedures/greuge_dif_porte_add.sql
+++ b/db/routines/bi/procedures/greuge_dif_porte_add.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`greuge_dif_porte_add`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bi`.`greuge_dif_porte_add`()
BEGIN
/**
diff --git a/db/routines/bi/procedures/nigthlyAnalisisVentas.sql b/db/routines/bi/procedures/nigthlyAnalisisVentas.sql
index c21a3bae5d..2568600ae6 100644
--- a/db/routines/bi/procedures/nigthlyAnalisisVentas.sql
+++ b/db/routines/bi/procedures/nigthlyAnalisisVentas.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`nigthlyAnalisisVentas`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bi`.`nigthlyAnalisisVentas`()
BEGIN
CALL analisis_ventas_update;
CALL analisis_ventas_simple;
diff --git a/db/routines/bi/procedures/rutasAnalyze.sql b/db/routines/bi/procedures/rutasAnalyze.sql
index 1f103bde0e..a5f051dfac 100644
--- a/db/routines/bi/procedures/rutasAnalyze.sql
+++ b/db/routines/bi/procedures/rutasAnalyze.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`rutasAnalyze`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bi`.`rutasAnalyze`(
vDatedFrom DATE,
vDatedTo DATE
)
diff --git a/db/routines/bi/procedures/rutasAnalyze_launcher.sql b/db/routines/bi/procedures/rutasAnalyze_launcher.sql
index 02f5e1b9c7..9cc6f0eeb5 100644
--- a/db/routines/bi/procedures/rutasAnalyze_launcher.sql
+++ b/db/routines/bi/procedures/rutasAnalyze_launcher.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`rutasAnalyze_launcher`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bi`.`rutasAnalyze_launcher`()
BEGIN
/**
* Call rutasAnalyze
diff --git a/db/routines/bi/views/analisis_grafico_ventas.sql b/db/routines/bi/views/analisis_grafico_ventas.sql
index f5956f27a1..566f24c2ee 100644
--- a/db/routines/bi/views/analisis_grafico_ventas.sql
+++ b/db/routines/bi/views/analisis_grafico_ventas.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `bi`.`analisis_grafico_ventas`
AS SELECT `bi`.`analisis_ventas`.`Año` AS `Año`,
diff --git a/db/routines/bi/views/analisis_ventas_simple.sql b/db/routines/bi/views/analisis_ventas_simple.sql
index 109378c8a6..8651f3d05e 100644
--- a/db/routines/bi/views/analisis_ventas_simple.sql
+++ b/db/routines/bi/views/analisis_ventas_simple.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `bi`.`analisis_ventas_simple`
AS SELECT `bi`.`analisis_ventas`.`Año` AS `Año`,
diff --git a/db/routines/bi/views/claims_ratio.sql b/db/routines/bi/views/claims_ratio.sql
index cfd9b62316..39ceae56d2 100644
--- a/db/routines/bi/views/claims_ratio.sql
+++ b/db/routines/bi/views/claims_ratio.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `bi`.`claims_ratio`
AS SELECT `cr`.`clientFk` AS `Id_Cliente`,
diff --git a/db/routines/bi/views/customerRiskOverdue.sql b/db/routines/bi/views/customerRiskOverdue.sql
index 27ef7ca471..8b8deb3ca6 100644
--- a/db/routines/bi/views/customerRiskOverdue.sql
+++ b/db/routines/bi/views/customerRiskOverdue.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `bi`.`customerRiskOverdue`
AS SELECT `cr`.`clientFk` AS `customer_id`,
diff --git a/db/routines/bi/views/defaulters.sql b/db/routines/bi/views/defaulters.sql
index 9275032451..e5922a7461 100644
--- a/db/routines/bi/views/defaulters.sql
+++ b/db/routines/bi/views/defaulters.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `bi`.`defaulters`
AS SELECT `d`.`clientFk` AS `client`,
diff --git a/db/routines/bi/views/facturacion_media_anual.sql b/db/routines/bi/views/facturacion_media_anual.sql
index 2e0c2ca6e8..8b1cde492b 100644
--- a/db/routines/bi/views/facturacion_media_anual.sql
+++ b/db/routines/bi/views/facturacion_media_anual.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `bi`.`facturacion_media_anual`
AS SELECT `cac`.`clientFk` AS `Id_Cliente`,
diff --git a/db/routines/bi/views/tarifa_componentes.sql b/db/routines/bi/views/tarifa_componentes.sql
index 42ea9fa81d..614e84eb98 100644
--- a/db/routines/bi/views/tarifa_componentes.sql
+++ b/db/routines/bi/views/tarifa_componentes.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `bi`.`tarifa_componentes`
AS SELECT `c`.`id` AS `Id_Componente`,
diff --git a/db/routines/bi/views/tarifa_componentes_series.sql b/db/routines/bi/views/tarifa_componentes_series.sql
index ed2f8e29a4..508a78fb30 100644
--- a/db/routines/bi/views/tarifa_componentes_series.sql
+++ b/db/routines/bi/views/tarifa_componentes_series.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `bi`.`tarifa_componentes_series`
AS SELECT `ct`.`id` AS `tarifa_componentes_series_id`,
diff --git a/db/routines/bs/events/clientDied_recalc.sql b/db/routines/bs/events/clientDied_recalc.sql
index db912658af..9a9a5ebb31 100644
--- a/db/routines/bs/events/clientDied_recalc.sql
+++ b/db/routines/bs/events/clientDied_recalc.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `bs`.`clientDied_recalc`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `bs`.`clientDied_recalc`
ON SCHEDULE EVERY 1 DAY
STARTS '2023-06-01 03:00:00.000'
ON COMPLETION PRESERVE
diff --git a/db/routines/bs/events/inventoryDiscrepancy_launch.sql b/db/routines/bs/events/inventoryDiscrepancy_launch.sql
index 3ee165846f..015425dfdd 100644
--- a/db/routines/bs/events/inventoryDiscrepancy_launch.sql
+++ b/db/routines/bs/events/inventoryDiscrepancy_launch.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `bs`.`inventoryDiscrepancy_launch`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `bs`.`inventoryDiscrepancy_launch`
ON SCHEDULE EVERY 15 MINUTE
STARTS '2023-07-18 00:00:00.000'
ON COMPLETION PRESERVE
diff --git a/db/routines/bs/events/nightTask_launchAll.sql b/db/routines/bs/events/nightTask_launchAll.sql
index 1a55ca1a31..f1f20f1cc6 100644
--- a/db/routines/bs/events/nightTask_launchAll.sql
+++ b/db/routines/bs/events/nightTask_launchAll.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `bs`.`nightTask_launchAll`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `bs`.`nightTask_launchAll`
ON SCHEDULE EVERY 1 DAY
STARTS '2022-02-08 04:14:00.000'
ON COMPLETION PRESERVE
diff --git a/db/routines/bs/functions/tramo.sql b/db/routines/bs/functions/tramo.sql
index 0415cfc92d..a45860409a 100644
--- a/db/routines/bs/functions/tramo.sql
+++ b/db/routines/bs/functions/tramo.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `bs`.`tramo`(vDateTime DATETIME)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `bs`.`tramo`(vDateTime DATETIME)
RETURNS varchar(20) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci
NOT DETERMINISTIC
NO SQL
diff --git a/db/routines/bs/procedures/campaignComparative.sql b/db/routines/bs/procedures/campaignComparative.sql
index 6b4b983b5e..27957976ab 100644
--- a/db/routines/bs/procedures/campaignComparative.sql
+++ b/db/routines/bs/procedures/campaignComparative.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`campaignComparative`(vDateFrom DATE, vDateTo DATE)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`campaignComparative`(vDateFrom DATE, vDateTo DATE)
BEGIN
SELECT
workerName,
diff --git a/db/routines/bs/procedures/carteras_add.sql b/db/routines/bs/procedures/carteras_add.sql
index 5143b4bb56..8c806e1d95 100644
--- a/db/routines/bs/procedures/carteras_add.sql
+++ b/db/routines/bs/procedures/carteras_add.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`carteras_add`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`carteras_add`()
BEGIN
/**
* Inserta en la tabla @bs.carteras las ventas desde el año pasado
diff --git a/db/routines/bs/procedures/clean.sql b/db/routines/bs/procedures/clean.sql
index eff2faadbb..a1d393122b 100644
--- a/db/routines/bs/procedures/clean.sql
+++ b/db/routines/bs/procedures/clean.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`clean`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`clean`()
BEGIN
DECLARE vOneYearAgo DATE DEFAULT util.VN_CURDATE() - INTERVAL 1 YEAR;
diff --git a/db/routines/bs/procedures/clientDied_recalc.sql b/db/routines/bs/procedures/clientDied_recalc.sql
index 1b5cb5ac82..d76c61968b 100644
--- a/db/routines/bs/procedures/clientDied_recalc.sql
+++ b/db/routines/bs/procedures/clientDied_recalc.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`clientDied_recalc`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`clientDied_recalc`(
vDays INT,
vCountryCode VARCHAR(2)
)
diff --git a/db/routines/bs/procedures/clientNewBorn_recalc.sql b/db/routines/bs/procedures/clientNewBorn_recalc.sql
index bb6b02aa7b..02a3387cff 100644
--- a/db/routines/bs/procedures/clientNewBorn_recalc.sql
+++ b/db/routines/bs/procedures/clientNewBorn_recalc.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`clientNewBorn_recalc`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`clientNewBorn_recalc`()
BLOCK1: BEGIN
DECLARE vClientFk INT;
diff --git a/db/routines/bs/procedures/compradores_evolution_add.sql b/db/routines/bs/procedures/compradores_evolution_add.sql
index e9b073e28d..1049122a0e 100644
--- a/db/routines/bs/procedures/compradores_evolution_add.sql
+++ b/db/routines/bs/procedures/compradores_evolution_add.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`compradores_evolution_add`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`compradores_evolution_add`()
BEGIN
/**
* Inserta en la tabla compradores_evolution las ventas acumuladas en los ultimos 365 dias
diff --git a/db/routines/bs/procedures/fondo_evolution_add.sql b/db/routines/bs/procedures/fondo_evolution_add.sql
index 3ca91e6473..22f73ff8dc 100644
--- a/db/routines/bs/procedures/fondo_evolution_add.sql
+++ b/db/routines/bs/procedures/fondo_evolution_add.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`fondo_evolution_add`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`fondo_evolution_add`()
BEGIN
/**
* Inserta en la tabla fondo_maniobra los saldos acumulados en los ultimos 365 dias
diff --git a/db/routines/bs/procedures/fruitsEvolution.sql b/db/routines/bs/procedures/fruitsEvolution.sql
index c689f4b760..15ce35ebe3 100644
--- a/db/routines/bs/procedures/fruitsEvolution.sql
+++ b/db/routines/bs/procedures/fruitsEvolution.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`fruitsEvolution`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`fruitsEvolution`()
BEGIN
select Id_Cliente,
Cliente, count(semana) as semanas, (w.code IS NOT NULL) isWorker
diff --git a/db/routines/bs/procedures/indicatorsUpdate.sql b/db/routines/bs/procedures/indicatorsUpdate.sql
index d66e52a614..958aae0176 100644
--- a/db/routines/bs/procedures/indicatorsUpdate.sql
+++ b/db/routines/bs/procedures/indicatorsUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`indicatorsUpdate`(vDated DATE)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`indicatorsUpdate`(vDated DATE)
BEGIN
DECLARE oneYearBefore DATE DEFAULT TIMESTAMPADD(YEAR,-1, vDated);
diff --git a/db/routines/bs/procedures/indicatorsUpdateLauncher.sql b/db/routines/bs/procedures/indicatorsUpdateLauncher.sql
index 8ede28ec84..b4f7685221 100644
--- a/db/routines/bs/procedures/indicatorsUpdateLauncher.sql
+++ b/db/routines/bs/procedures/indicatorsUpdateLauncher.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`indicatorsUpdateLauncher`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`indicatorsUpdateLauncher`()
BEGIN
DECLARE vDated DATE;
diff --git a/db/routines/bs/procedures/inventoryDiscrepancyDetail_replace.sql b/db/routines/bs/procedures/inventoryDiscrepancyDetail_replace.sql
index 6894b29289..045f06f299 100644
--- a/db/routines/bs/procedures/inventoryDiscrepancyDetail_replace.sql
+++ b/db/routines/bs/procedures/inventoryDiscrepancyDetail_replace.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`inventoryDiscrepancyDetail_replace`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`inventoryDiscrepancyDetail_replace`()
BEGIN
/**
* Replace all records in table inventoryDiscrepancyDetail and insert new
diff --git a/db/routines/bs/procedures/m3Add.sql b/db/routines/bs/procedures/m3Add.sql
index 0ec2c8ce29..63159815b2 100644
--- a/db/routines/bs/procedures/m3Add.sql
+++ b/db/routines/bs/procedures/m3Add.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`m3Add`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`m3Add`()
BEGIN
DECLARE datSTART DATE;
diff --git a/db/routines/bs/procedures/manaCustomerUpdate.sql b/db/routines/bs/procedures/manaCustomerUpdate.sql
index e9ba704234..f2bcc942ec 100644
--- a/db/routines/bs/procedures/manaCustomerUpdate.sql
+++ b/db/routines/bs/procedures/manaCustomerUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`manaCustomerUpdate`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`manaCustomerUpdate`()
BEGIN
DECLARE vToDated DATE;
DECLARE vFromDated DATE;
diff --git a/db/routines/bs/procedures/manaSpellers_actualize.sql b/db/routines/bs/procedures/manaSpellers_actualize.sql
index 20b0f84f8c..818ef40a62 100644
--- a/db/routines/bs/procedures/manaSpellers_actualize.sql
+++ b/db/routines/bs/procedures/manaSpellers_actualize.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`manaSpellers_actualize`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`manaSpellers_actualize`()
BEGIN
/**
* Recalcula el valor del campo con el modificador de precio
diff --git a/db/routines/bs/procedures/nightTask_launchAll.sql b/db/routines/bs/procedures/nightTask_launchAll.sql
index e61e88bb6f..9c3788b509 100644
--- a/db/routines/bs/procedures/nightTask_launchAll.sql
+++ b/db/routines/bs/procedures/nightTask_launchAll.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`nightTask_launchAll`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`nightTask_launchAll`()
BEGIN
/**
* Runs all nightly tasks.
diff --git a/db/routines/bs/procedures/nightTask_launchTask.sql b/db/routines/bs/procedures/nightTask_launchTask.sql
index aa4c540e8e..042df9d5d4 100644
--- a/db/routines/bs/procedures/nightTask_launchTask.sql
+++ b/db/routines/bs/procedures/nightTask_launchTask.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`nightTask_launchTask`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`nightTask_launchTask`(
vSchema VARCHAR(255),
vProcedure VARCHAR(255),
OUT vError VARCHAR(255),
diff --git a/db/routines/bs/procedures/payMethodClientAdd.sql b/db/routines/bs/procedures/payMethodClientAdd.sql
index 0c19f453ac..6ed39538a9 100644
--- a/db/routines/bs/procedures/payMethodClientAdd.sql
+++ b/db/routines/bs/procedures/payMethodClientAdd.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`payMethodClientAdd`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`payMethodClientAdd`()
BEGIN
INSERT IGNORE INTO `bs`.`payMethodClient` (dated, payMethodFk, clientFk)
SELECT util.VN_CURDATE(), c.payMethodFk, c.id
diff --git a/db/routines/bs/procedures/saleGraphic.sql b/db/routines/bs/procedures/saleGraphic.sql
index e1e3879800..cdf04ed194 100644
--- a/db/routines/bs/procedures/saleGraphic.sql
+++ b/db/routines/bs/procedures/saleGraphic.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`saleGraphic`(IN vItemFk INT, IN vTypeFk INT, IN vCategoryFk INT, IN vFromDate DATE,
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`saleGraphic`(IN vItemFk INT, IN vTypeFk INT, IN vCategoryFk INT, IN vFromDate DATE,
IN vToDate DATE, IN vProducerFk INT)
BEGIN
diff --git a/db/routines/bs/procedures/salePersonEvolutionAdd.sql b/db/routines/bs/procedures/salePersonEvolutionAdd.sql
index 33e31b6995..8894e85463 100644
--- a/db/routines/bs/procedures/salePersonEvolutionAdd.sql
+++ b/db/routines/bs/procedures/salePersonEvolutionAdd.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`salePersonEvolutionAdd`(IN vDateStart DATETIME)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`salePersonEvolutionAdd`(IN vDateStart DATETIME)
BEGIN
DELETE FROM bs.salePersonEvolution
WHERE dated <= DATE_SUB(util.VN_CURDATE(), INTERVAL 1 YEAR);
diff --git a/db/routines/bs/procedures/sale_add.sql b/db/routines/bs/procedures/sale_add.sql
index c50d27b814..37f4f41c45 100644
--- a/db/routines/bs/procedures/sale_add.sql
+++ b/db/routines/bs/procedures/sale_add.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`sale_add`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`sale_add`(
IN vStarted DATE,
IN vEnded DATE
)
diff --git a/db/routines/bs/procedures/salesByItemTypeDay_add.sql b/db/routines/bs/procedures/salesByItemTypeDay_add.sql
index 5c12081a0e..fe7d36dc8e 100644
--- a/db/routines/bs/procedures/salesByItemTypeDay_add.sql
+++ b/db/routines/bs/procedures/salesByItemTypeDay_add.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`salesByItemTypeDay_add`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`salesByItemTypeDay_add`(
vDateStart DATE,
vDateEnd DATE
)
diff --git a/db/routines/bs/procedures/salesByItemTypeDay_addLauncher.sql b/db/routines/bs/procedures/salesByItemTypeDay_addLauncher.sql
index 63677def67..c2b3f4b489 100644
--- a/db/routines/bs/procedures/salesByItemTypeDay_addLauncher.sql
+++ b/db/routines/bs/procedures/salesByItemTypeDay_addLauncher.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`salesByItemTypeDay_addLauncher`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`salesByItemTypeDay_addLauncher`()
BEGIN
CALL bs.salesByItemTypeDay_add(util.VN_CURDATE() - INTERVAL 30 DAY, util.VN_CURDATE());
END$$
diff --git a/db/routines/bs/procedures/salesByclientSalesPerson_add.sql b/db/routines/bs/procedures/salesByclientSalesPerson_add.sql
index eb441c07bb..4e0af84bf0 100644
--- a/db/routines/bs/procedures/salesByclientSalesPerson_add.sql
+++ b/db/routines/bs/procedures/salesByclientSalesPerson_add.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`salesByclientSalesPerson_add`(vDatedFrom DATE)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`salesByclientSalesPerson_add`(vDatedFrom DATE)
BEGIN
/**
* Agrupa las ventas por cliente/comercial/fecha en la tabla bs.salesByclientSalesPerson
diff --git a/db/routines/bs/procedures/salesPersonEvolution_add.sql b/db/routines/bs/procedures/salesPersonEvolution_add.sql
index ea150e182a..3474352c31 100644
--- a/db/routines/bs/procedures/salesPersonEvolution_add.sql
+++ b/db/routines/bs/procedures/salesPersonEvolution_add.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`salesPersonEvolution_add`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`salesPersonEvolution_add`()
BEGIN
/**
* Calcula los datos para los gráficos de evolución agrupado por salesPersonFk y día.
diff --git a/db/routines/bs/procedures/sales_addLauncher.sql b/db/routines/bs/procedures/sales_addLauncher.sql
index 38cb5e2198..403e76bd5e 100644
--- a/db/routines/bs/procedures/sales_addLauncher.sql
+++ b/db/routines/bs/procedures/sales_addLauncher.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`sales_addLauncher`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`sales_addLauncher`()
BEGIN
/**
* Añade las ventas a la tabla bs.sale que se realizaron desde hace un mes hasta hoy
diff --git a/db/routines/bs/procedures/vendedores_add_launcher.sql b/db/routines/bs/procedures/vendedores_add_launcher.sql
index c0718a6593..562b02c5cf 100644
--- a/db/routines/bs/procedures/vendedores_add_launcher.sql
+++ b/db/routines/bs/procedures/vendedores_add_launcher.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`vendedores_add_launcher`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`vendedores_add_launcher`()
BEGIN
CALL bs.salesByclientSalesPerson_add(util.VN_CURDATE()- INTERVAL 45 DAY);
diff --git a/db/routines/bs/procedures/ventas_contables_add.sql b/db/routines/bs/procedures/ventas_contables_add.sql
index c82cb96d9c..e9d578462c 100644
--- a/db/routines/bs/procedures/ventas_contables_add.sql
+++ b/db/routines/bs/procedures/ventas_contables_add.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`ventas_contables_add`(IN vYear INT, IN vMonth INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`ventas_contables_add`(IN vYear INT, IN vMonth INT)
BEGIN
/**
diff --git a/db/routines/bs/procedures/ventas_contables_add_launcher.sql b/db/routines/bs/procedures/ventas_contables_add_launcher.sql
index ac74c47bf5..e4b9c89a0a 100644
--- a/db/routines/bs/procedures/ventas_contables_add_launcher.sql
+++ b/db/routines/bs/procedures/ventas_contables_add_launcher.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`ventas_contables_add_launcher`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`ventas_contables_add_launcher`()
BEGIN
/**
diff --git a/db/routines/bs/procedures/waste_addSales.sql b/db/routines/bs/procedures/waste_addSales.sql
index 4a34d74b3c..4697a0aa3b 100644
--- a/db/routines/bs/procedures/waste_addSales.sql
+++ b/db/routines/bs/procedures/waste_addSales.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSales`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`waste_addSales`(
vDateFrom DATE,
vDateTo DATE
)
@@ -11,7 +11,7 @@ BEGIN
* @param vDateTo Fecha hasta
*/
DECLARE vDaysInYear INT;
- SET vDaysInYear = DATEDIFF(util.lastDayOfYear(CURDATE()), util.firstDayOfYear(CURDATE()));
+ SET vDaysInYear = DATEDIFF(util.lastDayOfYear(util.VN_CURDATE()), util.firstDayOfYear(util.VN_CURDATE()));
SET vDateFrom = COALESCE(vDateFrom, util.VN_CURDATE());
SET vDateTo = COALESCE(vDateTo, util.VN_CURDATE());
@@ -26,7 +26,76 @@ BEGIN
-- Obtiene el último día de la semana de esa fecha
SET vDateTo = DATE_ADD(vDateTo, INTERVAL (6 - ((WEEKDAY(vDateTo) + 1) % 7)) DAY);
- CALL cache.last_buy_refresh(FALSE);
+ -- !! Cálculo del coste por warehouse y artículo (Reglas Ricardo) !!
+ -- Coste de las compras de la última semana (Sin inventario y arreglos stock)
+ CREATE OR REPLACE TEMPORARY TABLE tItemCalcCost
+ (PRIMARY KEY (warehouseFk, itemFk))
+ ENGINE = MEMORY
+ SELECT w.id warehouseFk,
+ b.itemFk,
+ IF(COUNT(*) > 1,
+ SUM((b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * b.quantity) / SUM(b.quantity),
+ (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue)
+ ) cost
+ FROM vn.buy b
+ JOIN vn.entry e ON e.id = b.entryFk
+ JOIN vn.travel tr ON tr.id = e.travelFk
+ JOIN vn.warehouse w ON w.id = tr.warehouseInFk
+ WHERE tr.landed BETWEEN util.VN_CURDATE() - INTERVAL 1 WEEK AND util.VN_CURDATE()
+ AND e.supplierFk NOT IN (
+ (SELECT supplierFk FROM vn.inventoryConfig),
+ (SELECT id FROM vn.supplier WHERE name = 'ARREGLOS STOCK')
+ )
+ GROUP BY w.id, b.itemFk;
+
+ -- Proveedores reales
+ INSERT IGNORE INTO tItemCalcCost(warehouseFk, itemFk, cost)
+ WITH wBuysNumered AS (
+ SELECT ROW_NUMBER() OVER(
+ PARTITION BY tr.warehouseInFk, b.itemFk
+ ORDER BY tr.landed DESC, b.buyingValue DESC, b.id DESC
+ ) num,
+ w.id warehouseFk,
+ b.itemFk,
+ b.id
+ FROM vn.buy b
+ JOIN vn.entry e ON e.id = b.entryFk
+ JOIN vn.travel tr ON tr.id = e.travelFk
+ JOIN vn.warehouse w ON w.id = tr.warehouseInFk
+ JOIN vn.supplier s ON s.id = e.supplierFk
+ WHERE tr.landed BETWEEN util.VN_CURDATE() - INTERVAL 1 YEAR AND util.VN_CURDATE()
+ AND s.isReal
+ )
+ SELECT bn.warehouseFk,
+ b.itemFk,
+ (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) cost
+ FROM wBuysNumered bn
+ JOIN vn.buy b ON b.id = bn.id
+ WHERE num = 1;
+
+ -- Como último recurso, se coge cualquier compra
+ INSERT IGNORE INTO tItemCalcCost(warehouseFk, itemFk, cost)
+ WITH wBuysNumered AS (
+ SELECT ROW_NUMBER() OVER(
+ PARTITION BY tr.warehouseInFk, b.itemFk
+ ORDER BY tr.landed DESC, b.buyingValue DESC, b.id DESC
+ ) num,
+ w.id warehouseFk,
+ b.itemFk,
+ b.id
+ FROM vn.buy b
+ JOIN vn.entry e ON e.id = b.entryFk
+ JOIN vn.travel tr ON tr.id = e.travelFk
+ JOIN vn.warehouse w ON w.id = tr.warehouseInFk
+ JOIN vn.supplier s ON s.id = e.supplierFk
+ WHERE tr.landed BETWEEN util.VN_CURDATE() - INTERVAL 1 YEAR AND util.VN_CURDATE()
+ )
+ SELECT bn.warehouseFk,
+ b.itemFk,
+ (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) cost
+ FROM wBuysNumered bn
+ JOIN vn.buy b ON b.id = bn.id
+ WHERE num = 1;
REPLACE bs.waste
SELECT YEARWEEK(t.shipped, 6) DIV 100,
@@ -34,35 +103,35 @@ BEGIN
it.workerFk,
it.id,
s.itemFk,
- SUM((b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity),
+ SUM((icc.cost) * s.quantity),
SUM(IF(aw.`type`, s.quantity, 0)),
SUM(IF(
aw.`type` = 'external',
- (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
+ (icc.cost) * s.quantity,
0
)
),
SUM(IF(
aw.`type` = 'fault',
- (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
+ (icc.cost) * s.quantity,
0
)
),
SUM(IF(
aw.`type` = 'container',
- (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
+ (icc.cost) * s.quantity,
0
)
),
SUM(IF(
aw.`type` = 'break',
- (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
+ (icc.cost) * s.quantity,
0
)
),
SUM(IF(
aw.`type` = 'other',
- (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
+ (icc.cost) * s.quantity,
0
)
)
@@ -73,11 +142,12 @@ BEGIN
JOIN vn.address a FORCE INDEX (PRIMARY) ON a.id = t.addressFk
LEFT JOIN vn.addressWaste aw ON aw.addressFk = a.id
JOIN vn.warehouse w ON w.id = t.warehouseFk
- JOIN cache.last_buy lb ON lb.item_id = i.id
- AND lb.warehouse_id = w.id
- JOIN vn.buy b ON b.id = lb.buy_id
+ JOIN tItemCalcCost icc ON icc.itemFk = i.id
+ AND icc.warehouseFk = w.id
WHERE t.shipped BETWEEN vDateFrom AND util.dayEnd(vDateTo)
AND w.isManaged
GROUP BY YEARWEEK(t.shipped, 6) DIV 100, WEEK(t.shipped, 6), i.id;
+
+ DROP TEMPORARY TABLE tItemCalcCost;
END$$
DELIMITER ;
diff --git a/db/routines/bs/procedures/waste_addSalesLauncher.sql b/db/routines/bs/procedures/waste_addSalesLauncher.sql
index 5eaea9be4d..a735ba25a3 100644
--- a/db/routines/bs/procedures/waste_addSalesLauncher.sql
+++ b/db/routines/bs/procedures/waste_addSalesLauncher.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSalesLauncher`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`waste_addSalesLauncher`()
BEGIN
CALL waste_addSales(NULL, NULL);
END$$
diff --git a/db/routines/bs/procedures/workerLabour_getData.sql b/db/routines/bs/procedures/workerLabour_getData.sql
index 1f5a39fe0c..28e80365a9 100644
--- a/db/routines/bs/procedures/workerLabour_getData.sql
+++ b/db/routines/bs/procedures/workerLabour_getData.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`workerLabour_getData`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`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.
diff --git a/db/routines/bs/procedures/workerProductivity_add.sql b/db/routines/bs/procedures/workerProductivity_add.sql
index 3d7dbdca96..00d8ba9e82 100644
--- a/db/routines/bs/procedures/workerProductivity_add.sql
+++ b/db/routines/bs/procedures/workerProductivity_add.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`workerProductivity_add`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `bs`.`workerProductivity_add`()
BEGIN
DECLARE vDateFrom DATE;
SELECT DATE_SUB(util.VN_CURDATE(),INTERVAL 30 DAY) INTO vDateFrom;
diff --git a/db/routines/bs/triggers/clientNewBorn_beforeUpdate.sql b/db/routines/bs/triggers/clientNewBorn_beforeUpdate.sql
index a88567a21b..33e5ad3bdb 100644
--- a/db/routines/bs/triggers/clientNewBorn_beforeUpdate.sql
+++ b/db/routines/bs/triggers/clientNewBorn_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `bs`.`clientNewBorn_beforeUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `bs`.`clientNewBorn_beforeUpdate`
BEFORE UPDATE ON `clientNewBorn`
FOR EACH ROW
BEGIN
diff --git a/db/routines/bs/triggers/nightTask_beforeInsert.sql b/db/routines/bs/triggers/nightTask_beforeInsert.sql
index 96f2b52913..6d0313425b 100644
--- a/db/routines/bs/triggers/nightTask_beforeInsert.sql
+++ b/db/routines/bs/triggers/nightTask_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `bs`.`nightTask_beforeInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `bs`.`nightTask_beforeInsert`
BEFORE INSERT ON `nightTask`
FOR EACH ROW
BEGIN
diff --git a/db/routines/bs/triggers/nightTask_beforeUpdate.sql b/db/routines/bs/triggers/nightTask_beforeUpdate.sql
index 1da1da8c3c..70186202cf 100644
--- a/db/routines/bs/triggers/nightTask_beforeUpdate.sql
+++ b/db/routines/bs/triggers/nightTask_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `bs`.`nightTask_beforeUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `bs`.`nightTask_beforeUpdate`
BEFORE UPDATE ON `nightTask`
FOR EACH ROW
BEGIN
diff --git a/db/routines/bs/views/lastIndicators.sql b/db/routines/bs/views/lastIndicators.sql
index 3fa04abd3e..15de2d97fd 100644
--- a/db/routines/bs/views/lastIndicators.sql
+++ b/db/routines/bs/views/lastIndicators.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `bs`.`lastIndicators`
AS SELECT `i`.`updated` AS `updated`,
diff --git a/db/routines/bs/views/packingSpeed.sql b/db/routines/bs/views/packingSpeed.sql
index 517706b158..10b70c9406 100644
--- a/db/routines/bs/views/packingSpeed.sql
+++ b/db/routines/bs/views/packingSpeed.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `bs`.`packingSpeed`
AS SELECT HOUR(`e`.`created`) AS `hora`,
diff --git a/db/routines/bs/views/ventas.sql b/db/routines/bs/views/ventas.sql
index 1fab2e91b4..3ebaf67c5f 100644
--- a/db/routines/bs/views/ventas.sql
+++ b/db/routines/bs/views/ventas.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `bs`.`ventas`
AS SELECT `s`.`saleFk` AS `Id_Movimiento`,
diff --git a/db/routines/cache/events/cacheCalc_clean.sql b/db/routines/cache/events/cacheCalc_clean.sql
index e13bae98b4..e201dac3aa 100644
--- a/db/routines/cache/events/cacheCalc_clean.sql
+++ b/db/routines/cache/events/cacheCalc_clean.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `cache`.`cacheCalc_clean`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `cache`.`cacheCalc_clean`
ON SCHEDULE EVERY 30 MINUTE
STARTS '2022-01-28 09:29:18.000'
ON COMPLETION NOT PRESERVE
diff --git a/db/routines/cache/events/cache_clean.sql b/db/routines/cache/events/cache_clean.sql
index c5e247bd4b..6b83f71a0d 100644
--- a/db/routines/cache/events/cache_clean.sql
+++ b/db/routines/cache/events/cache_clean.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `cache`.`cache_clean`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `cache`.`cache_clean`
ON SCHEDULE EVERY 5 MINUTE
STARTS '2022-01-28 09:29:18.000'
ON COMPLETION NOT PRESERVE
diff --git a/db/routines/cache/procedures/addressFriendship_Update.sql b/db/routines/cache/procedures/addressFriendship_Update.sql
index f7fab8b9b4..5e59d957a0 100644
--- a/db/routines/cache/procedures/addressFriendship_Update.sql
+++ b/db/routines/cache/procedures/addressFriendship_Update.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`addressFriendship_Update`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `cache`.`addressFriendship_Update`()
BEGIN
REPLACE cache.addressFriendship
diff --git a/db/routines/cache/procedures/availableNoRaids_refresh.sql b/db/routines/cache/procedures/availableNoRaids_refresh.sql
index 447300305c..b16a91ebfa 100644
--- a/db/routines/cache/procedures/availableNoRaids_refresh.sql
+++ b/db/routines/cache/procedures/availableNoRaids_refresh.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`availableNoRaids_refresh`(OUT `vCalc` INT, IN `vRefresh` INT, IN `vWarehouse` INT, IN `vDated` DATE)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `cache`.`availableNoRaids_refresh`(OUT `vCalc` INT, IN `vRefresh` INT, IN `vWarehouse` INT, IN `vDated` DATE)
proc: BEGIN
DECLARE vStartDate DATE;
DECLARE vEndDate DATETIME;
diff --git a/db/routines/cache/procedures/available_clean.sql b/db/routines/cache/procedures/available_clean.sql
index bb1f7302c9..5a6401dc27 100644
--- a/db/routines/cache/procedures/available_clean.sql
+++ b/db/routines/cache/procedures/available_clean.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_clean`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `cache`.`available_clean`()
BEGIN
DROP TEMPORARY TABLE IF EXISTS tCalc;
CREATE TEMPORARY TABLE tCalc
diff --git a/db/routines/cache/procedures/available_refresh.sql b/db/routines/cache/procedures/available_refresh.sql
index 528e07d4f1..eeb85d5799 100644
--- a/db/routines/cache/procedures/available_refresh.sql
+++ b/db/routines/cache/procedures/available_refresh.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_refresh`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `cache`.`available_refresh`(
OUT `vCalc` INT,
`vRefresh` INT,
`vWarehouse` INT,
diff --git a/db/routines/cache/procedures/available_updateItem.sql b/db/routines/cache/procedures/available_updateItem.sql
index 8e94a9d75e..3f5d58d9a7 100644
--- a/db/routines/cache/procedures/available_updateItem.sql
+++ b/db/routines/cache/procedures/available_updateItem.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_updateItem`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `cache`.`available_updateItem`(
`vItem` INT,
`vWarehouse` INT,
`vDated` DATE,
diff --git a/db/routines/cache/procedures/cacheCalc_clean.sql b/db/routines/cache/procedures/cacheCalc_clean.sql
index 5c588687e0..ddaf649105 100644
--- a/db/routines/cache/procedures/cacheCalc_clean.sql
+++ b/db/routines/cache/procedures/cacheCalc_clean.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`cacheCalc_clean`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `cache`.`cacheCalc_clean`()
BEGIN
DECLARE vCleanTime DATETIME DEFAULT TIMESTAMPADD(MINUTE, -5, NOW());
DELETE FROM cache_calc WHERE expires < vCleanTime;
diff --git a/db/routines/cache/procedures/cache_calc_end.sql b/db/routines/cache/procedures/cache_calc_end.sql
index b74a1b7fde..eb4ea3207f 100644
--- a/db/routines/cache/procedures/cache_calc_end.sql
+++ b/db/routines/cache/procedures/cache_calc_end.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`cache_calc_end`(IN `v_calc` INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `cache`.`cache_calc_end`(IN `v_calc` INT)
BEGIN
DECLARE v_cache_name VARCHAR(255);
DECLARE v_params VARCHAR(255);
diff --git a/db/routines/cache/procedures/cache_calc_start.sql b/db/routines/cache/procedures/cache_calc_start.sql
index 933d926ef7..74526b36b1 100644
--- a/db/routines/cache/procedures/cache_calc_start.sql
+++ b/db/routines/cache/procedures/cache_calc_start.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`cache_calc_start`(OUT `v_calc` INT, INOUT `v_refresh` INT, IN `v_cache_name` VARCHAR(50), IN `v_params` VARCHAR(100))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `cache`.`cache_calc_start`(OUT `v_calc` INT, INOUT `v_refresh` INT, IN `v_cache_name` VARCHAR(50), IN `v_params` VARCHAR(100))
proc: BEGIN
DECLARE v_valid BOOL;
DECLARE v_lock_id VARCHAR(100);
diff --git a/db/routines/cache/procedures/cache_calc_unlock.sql b/db/routines/cache/procedures/cache_calc_unlock.sql
index 5dc46d9259..35733b7726 100644
--- a/db/routines/cache/procedures/cache_calc_unlock.sql
+++ b/db/routines/cache/procedures/cache_calc_unlock.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`cache_calc_unlock`(IN `v_calc` INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `cache`.`cache_calc_unlock`(IN `v_calc` INT)
proc: BEGIN
DECLARE v_cache_name VARCHAR(50);
DECLARE v_params VARCHAR(100);
diff --git a/db/routines/cache/procedures/cache_clean.sql b/db/routines/cache/procedures/cache_clean.sql
index 0fca75e630..afeea93701 100644
--- a/db/routines/cache/procedures/cache_clean.sql
+++ b/db/routines/cache/procedures/cache_clean.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`cache_clean`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `cache`.`cache_clean`()
NO SQL
BEGIN
CALL available_clean;
diff --git a/db/routines/cache/procedures/clean.sql b/db/routines/cache/procedures/clean.sql
index 5e66286896..3aeafe79a7 100644
--- a/db/routines/cache/procedures/clean.sql
+++ b/db/routines/cache/procedures/clean.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`clean`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `cache`.`clean`()
BEGIN
DELETE FROM cache.departure_limit WHERE Fecha < util.VN_CURDATE() - INTERVAL 1 MONTH;
END$$
diff --git a/db/routines/cache/procedures/departure_timing.sql b/db/routines/cache/procedures/departure_timing.sql
index 778c2cd743..d683a75d9a 100644
--- a/db/routines/cache/procedures/departure_timing.sql
+++ b/db/routines/cache/procedures/departure_timing.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`departure_timing`(vWarehouseId INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `cache`.`departure_timing`(vWarehouseId INT)
BEGIN
DECLARE done BOOL DEFAULT FALSE;
diff --git a/db/routines/cache/procedures/last_buy_refresh.sql b/db/routines/cache/procedures/last_buy_refresh.sql
index 86a5e8d8cc..0b41915e44 100644
--- a/db/routines/cache/procedures/last_buy_refresh.sql
+++ b/db/routines/cache/procedures/last_buy_refresh.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`last_buy_refresh`(vRefresh BOOL)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `cache`.`last_buy_refresh`(vRefresh BOOL)
proc: BEGIN
/**
* Crea o actualiza la cache con la última compra y fecha de cada
diff --git a/db/routines/cache/procedures/stock_refresh.sql b/db/routines/cache/procedures/stock_refresh.sql
index ed69e63e5f..0035d037d6 100644
--- a/db/routines/cache/procedures/stock_refresh.sql
+++ b/db/routines/cache/procedures/stock_refresh.sql
@@ -1,9 +1,8 @@
DELIMITER $$
-$$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`stock_refresh`(v_refresh BOOL)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `cache`.`stock_refresh`(v_refresh BOOL)
proc: BEGIN
/**
- * Crea o actualiza la cache con el disponible hasta el día de
+ * 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álculo del visible o del ATP.
*
@@ -29,26 +28,26 @@ proc: BEGIN
SET v_date_inv = vn.getInventoryDate();
SET vCURDATE = util.VN_CURDATE();
-
+
DELETE FROM stock;
-
+
INSERT INTO stock (item_id, warehouse_id, amount)
SELECT item_id, warehouse_id, SUM(amount) amount FROM
(
- SELECT itemFk AS item_id, warehouseFk AS warehouse_id, quantity AS amount
+ SELECT itemFk AS item_id, warehouseFk AS warehouse_id, quantity AS amount
FROM vn.itemTicketOut
- WHERE shipped >= v_date_inv
+ WHERE shipped >= v_date_inv
AND shipped < vCURDATE
UNION ALL
- SELECT itemFk ASitem_id, warehouseInFk AS warehouse_id, quantity AS amount
+ SELECT itemFk ASitem_id, warehouseInFk AS warehouse_id, quantity AS amount
FROM vn.itemEntryIn
WHERE availabled >= v_date_inv
AND availabled < vCURDATE
AND isVirtualStock is FALSE
UNION ALL
- SELECT itemFk AS item_id ,warehouseOutFk AS warehouse_id, quantity AS amount
+ SELECT itemFk AS item_id ,warehouseOutFk AS warehouse_id, quantity AS amount
FROM vn.itemEntryOut
- WHERE shipped >= v_date_inv
+ WHERE shipped >= v_date_inv
AND shipped < vCURDATE
) t
GROUP BY item_id, warehouse_id HAVING amount != 0;
diff --git a/db/routines/cache/procedures/visible_clean.sql b/db/routines/cache/procedures/visible_clean.sql
index b6f03c5635..5bc0c0fc18 100644
--- a/db/routines/cache/procedures/visible_clean.sql
+++ b/db/routines/cache/procedures/visible_clean.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`visible_clean`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `cache`.`visible_clean`()
BEGIN
DROP TEMPORARY TABLE IF EXISTS tCalc;
CREATE TEMPORARY TABLE tCalc
diff --git a/db/routines/cache/procedures/visible_refresh.sql b/db/routines/cache/procedures/visible_refresh.sql
index a673969d2d..fa88de1e2a 100644
--- a/db/routines/cache/procedures/visible_refresh.sql
+++ b/db/routines/cache/procedures/visible_refresh.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`visible_refresh`(OUT v_calc INT, v_refresh BOOL, v_warehouse INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `cache`.`visible_refresh`(OUT v_calc INT, v_refresh BOOL, v_warehouse INT)
proc:BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
diff --git a/db/routines/dipole/procedures/clean.sql b/db/routines/dipole/procedures/clean.sql
index a9af64e15e..9054124b39 100644
--- a/db/routines/dipole/procedures/clean.sql
+++ b/db/routines/dipole/procedures/clean.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `dipole`.`clean`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `dipole`.`clean`()
BEGIN
DECLARE vFromDated DATE;
diff --git a/db/routines/dipole/procedures/expedition_add.sql b/db/routines/dipole/procedures/expedition_add.sql
index 70bc7930ef..6d6fb2fd8c 100644
--- a/db/routines/dipole/procedures/expedition_add.sql
+++ b/db/routines/dipole/procedures/expedition_add.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `dipole`.`expedition_add`(vExpeditionFk INT, vPrinterFk INT, vIsPrinted BOOLEAN)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `dipole`.`expedition_add`(vExpeditionFk INT, vPrinterFk INT, vIsPrinted BOOLEAN)
BEGIN
/** Insert records to print agency stickers and to inform sorter with new box
*
diff --git a/db/routines/dipole/views/expeditionControl.sql b/db/routines/dipole/views/expeditionControl.sql
index e26e83440a..9a2c0a731f 100644
--- a/db/routines/dipole/views/expeditionControl.sql
+++ b/db/routines/dipole/views/expeditionControl.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `dipole`.`expeditionControl`
AS SELECT cast(`epo`.`created` AS date) AS `fecha`,
diff --git a/db/routines/edi/functions/imageName.sql b/db/routines/edi/functions/imageName.sql
index f2e52558f5..a5cf33ff88 100644
--- a/db/routines/edi/functions/imageName.sql
+++ b/db/routines/edi/functions/imageName.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `edi`.`imageName`(vPictureReference VARCHAR(255))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `edi`.`imageName`(vPictureReference VARCHAR(255))
RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci
DETERMINISTIC
BEGIN
diff --git a/db/routines/edi/procedures/clean.sql b/db/routines/edi/procedures/clean.sql
index 71dd576e93..ce35b3e1d8 100644
--- a/db/routines/edi/procedures/clean.sql
+++ b/db/routines/edi/procedures/clean.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`clean`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `edi`.`clean`()
BEGIN
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
BEGIN
diff --git a/db/routines/edi/procedures/deliveryInformation_Delete.sql b/db/routines/edi/procedures/deliveryInformation_Delete.sql
index b4f51515a6..ac5b67e6f0 100644
--- a/db/routines/edi/procedures/deliveryInformation_Delete.sql
+++ b/db/routines/edi/procedures/deliveryInformation_Delete.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`deliveryInformation_Delete`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `edi`.`deliveryInformation_Delete`()
BEGIN
DECLARE vID INT;
diff --git a/db/routines/edi/procedures/ekt_add.sql b/db/routines/edi/procedures/ekt_add.sql
index 1cc67bb935..377c9b411a 100644
--- a/db/routines/edi/procedures/ekt_add.sql
+++ b/db/routines/edi/procedures/ekt_add.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`ekt_add`(vPutOrderFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `edi`.`ekt_add`(vPutOrderFk INT)
BEGIN
/**
diff --git a/db/routines/edi/procedures/ekt_load.sql b/db/routines/edi/procedures/ekt_load.sql
index 190b09a864..76f530183a 100644
--- a/db/routines/edi/procedures/ekt_load.sql
+++ b/db/routines/edi/procedures/ekt_load.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`ekt_load`(IN `vSelf` INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `edi`.`ekt_load`(IN `vSelf` INT)
proc:BEGIN
/**
* Carga los datos esenciales para el sistema EKT.
diff --git a/db/routines/edi/procedures/ekt_loadNotBuy.sql b/db/routines/edi/procedures/ekt_loadNotBuy.sql
index 52697adc04..867c99ab76 100644
--- a/db/routines/edi/procedures/ekt_loadNotBuy.sql
+++ b/db/routines/edi/procedures/ekt_loadNotBuy.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`ekt_loadNotBuy`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `edi`.`ekt_loadNotBuy`()
BEGIN
/**
* Ejecuta ekt_load para aquellos ekt de hoy que no tienen vn.buy
diff --git a/db/routines/edi/procedures/ekt_refresh.sql b/db/routines/edi/procedures/ekt_refresh.sql
index 8ba438c0ac..2df736b0e6 100644
--- a/db/routines/edi/procedures/ekt_refresh.sql
+++ b/db/routines/edi/procedures/ekt_refresh.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`ekt_refresh`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `edi`.`ekt_refresh`(
`vSelf` INT, vMailFk INT)
BEGIN
/**
diff --git a/db/routines/edi/procedures/ekt_scan.sql b/db/routines/edi/procedures/ekt_scan.sql
index 0cf8bb4669..c42e57ca4d 100644
--- a/db/routines/edi/procedures/ekt_scan.sql
+++ b/db/routines/edi/procedures/ekt_scan.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`ekt_scan`(vBarcode VARCHAR(512))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `edi`.`ekt_scan`(vBarcode VARCHAR(512))
BEGIN
/**
* Busca transaciones a partir de un codigo de barras, las marca como escaneadas
diff --git a/db/routines/edi/procedures/item_freeAdd.sql b/db/routines/edi/procedures/item_freeAdd.sql
index cb572e1b10..93842af6e1 100644
--- a/db/routines/edi/procedures/item_freeAdd.sql
+++ b/db/routines/edi/procedures/item_freeAdd.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`item_freeAdd`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `edi`.`item_freeAdd`()
BEGIN
/**
* Rellena la tabla item_free con los id ausentes en vn.item
diff --git a/db/routines/edi/procedures/item_getNewByEkt.sql b/db/routines/edi/procedures/item_getNewByEkt.sql
index a80d04817b..e169a0f00c 100644
--- a/db/routines/edi/procedures/item_getNewByEkt.sql
+++ b/db/routines/edi/procedures/item_getNewByEkt.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`item_getNewByEkt`(vEktFk INT, OUT vItemFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `edi`.`item_getNewByEkt`(vEktFk INT, OUT vItemFk INT)
BEGIN
/**
diff --git a/db/routines/edi/procedures/mail_new.sql b/db/routines/edi/procedures/mail_new.sql
index 7bbf3f5cf3..4ed3d0c377 100644
--- a/db/routines/edi/procedures/mail_new.sql
+++ b/db/routines/edi/procedures/mail_new.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`mail_new`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `edi`.`mail_new`(
vMessageId VARCHAR(100)
,vSender VARCHAR(150)
,OUT vSelf INT
diff --git a/db/routines/edi/triggers/item_feature_beforeInsert.sql b/db/routines/edi/triggers/item_feature_beforeInsert.sql
index 4e3e9cc0e1..f2aabb91fc 100644
--- a/db/routines/edi/triggers/item_feature_beforeInsert.sql
+++ b/db/routines/edi/triggers/item_feature_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `edi`.`item_feature_beforeInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `edi`.`item_feature_beforeInsert`
BEFORE INSERT ON `item_feature`
FOR EACH ROW
BEGIN
diff --git a/db/routines/edi/triggers/putOrder_afterUpdate.sql b/db/routines/edi/triggers/putOrder_afterUpdate.sql
index b56ae4c669..00bb228c5e 100644
--- a/db/routines/edi/triggers/putOrder_afterUpdate.sql
+++ b/db/routines/edi/triggers/putOrder_afterUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `edi`.`putOrder_afterUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `edi`.`putOrder_afterUpdate`
AFTER UPDATE ON `putOrder`
FOR EACH ROW
BEGIN
diff --git a/db/routines/edi/triggers/putOrder_beforeInsert.sql b/db/routines/edi/triggers/putOrder_beforeInsert.sql
index beddd191cf..13274c33ca 100644
--- a/db/routines/edi/triggers/putOrder_beforeInsert.sql
+++ b/db/routines/edi/triggers/putOrder_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `edi`.`putOrder_beforeInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `edi`.`putOrder_beforeInsert`
BEFORE INSERT ON `putOrder`
FOR EACH ROW
BEGIN
diff --git a/db/routines/edi/triggers/putOrder_beforeUpdate.sql b/db/routines/edi/triggers/putOrder_beforeUpdate.sql
index f18b77a0cd..c532f75d14 100644
--- a/db/routines/edi/triggers/putOrder_beforeUpdate.sql
+++ b/db/routines/edi/triggers/putOrder_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `edi`.`putOrder_beforeUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `edi`.`putOrder_beforeUpdate`
BEFORE UPDATE ON `putOrder`
FOR EACH ROW
BEGIN
diff --git a/db/routines/edi/triggers/supplyResponse_afterUpdate.sql b/db/routines/edi/triggers/supplyResponse_afterUpdate.sql
index f3e5aaefdb..721cab8cd3 100644
--- a/db/routines/edi/triggers/supplyResponse_afterUpdate.sql
+++ b/db/routines/edi/triggers/supplyResponse_afterUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `edi`.`supplyResponse_afterUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `edi`.`supplyResponse_afterUpdate`
AFTER UPDATE ON `supplyResponse`
FOR EACH ROW
BEGIN
diff --git a/db/routines/edi/views/ektK2.sql b/db/routines/edi/views/ektK2.sql
index 299d26b015..5c06221b13 100644
--- a/db/routines/edi/views/ektK2.sql
+++ b/db/routines/edi/views/ektK2.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `edi`.`ektK2`
AS SELECT `eek`.`id` AS `id`,
diff --git a/db/routines/edi/views/ektRecent.sql b/db/routines/edi/views/ektRecent.sql
index 66ff7875e5..83f839bd9d 100644
--- a/db/routines/edi/views/ektRecent.sql
+++ b/db/routines/edi/views/ektRecent.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `edi`.`ektRecent`
AS SELECT `e`.`id` AS `id`,
diff --git a/db/routines/edi/views/errorList.sql b/db/routines/edi/views/errorList.sql
index 4e7cbc840e..0273f81105 100644
--- a/db/routines/edi/views/errorList.sql
+++ b/db/routines/edi/views/errorList.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `edi`.`errorList`
AS SELECT `po`.`id` AS `id`,
diff --git a/db/routines/edi/views/supplyOffer.sql b/db/routines/edi/views/supplyOffer.sql
index c4a8582a12..e4e84df744 100644
--- a/db/routines/edi/views/supplyOffer.sql
+++ b/db/routines/edi/views/supplyOffer.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `edi`.`supplyOffer`
AS SELECT `sr`.`vmpID` AS `vmpID`,
diff --git a/db/routines/floranet/procedures/catalogue_findById.sql b/db/routines/floranet/procedures/catalogue_findById.sql
index aca6ca4d61..ab97d1adae 100644
--- a/db/routines/floranet/procedures/catalogue_findById.sql
+++ b/db/routines/floranet/procedures/catalogue_findById.sql
@@ -1,6 +1,6 @@
DELIMITER $$
$$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE floranet.catalogue_findById(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE floranet.catalogue_findById(vSelf INT)
READS SQL DATA
BEGIN
/**
diff --git a/db/routines/floranet/procedures/catalogue_get.sql b/db/routines/floranet/procedures/catalogue_get.sql
index 1e224c8103..d4dd0c69fc 100644
--- a/db/routines/floranet/procedures/catalogue_get.sql
+++ b/db/routines/floranet/procedures/catalogue_get.sql
@@ -1,6 +1,6 @@
DELIMITER $$
$$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE floranet.catalogue_get(vLanded DATE, vPostalCode VARCHAR(15))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE floranet.catalogue_get(vLanded DATE, vPostalCode VARCHAR(15))
READS SQL DATA
proc:BEGIN
/**
diff --git a/db/routines/floranet/procedures/contact_request.sql b/db/routines/floranet/procedures/contact_request.sql
index 2132a86fc0..6d05edaf7a 100644
--- a/db/routines/floranet/procedures/contact_request.sql
+++ b/db/routines/floranet/procedures/contact_request.sql
@@ -2,7 +2,7 @@ DROP PROCEDURE IF EXISTS floranet.contact_request;
DELIMITER $$
$$
-CREATE DEFINER=`root`@`localhost`
+CREATE DEFINER=`vn`@`localhost`
PROCEDURE floranet.contact_request(
vName VARCHAR(100),
vPhone VARCHAR(15),
diff --git a/db/routines/floranet/procedures/deliveryDate_get.sql b/db/routines/floranet/procedures/deliveryDate_get.sql
index 70cb488184..84620dfeda 100644
--- a/db/routines/floranet/procedures/deliveryDate_get.sql
+++ b/db/routines/floranet/procedures/deliveryDate_get.sql
@@ -1,6 +1,6 @@
DELIMITER $$
$$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `floranet`.`deliveryDate_get`(vPostalCode VARCHAR(15))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `floranet`.`deliveryDate_get`(vPostalCode VARCHAR(15))
READS SQL DATA
BEGIN
/**
diff --git a/db/routines/floranet/procedures/order_confirm.sql b/db/routines/floranet/procedures/order_confirm.sql
index 98e15bbab4..2e59ed7377 100644
--- a/db/routines/floranet/procedures/order_confirm.sql
+++ b/db/routines/floranet/procedures/order_confirm.sql
@@ -1,7 +1,7 @@
DELIMITER $$
$$
-CREATE OR REPLACE DEFINER=`root`@`localhost`PROCEDURE floranet.order_confirm(vCatalogueFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost`PROCEDURE floranet.order_confirm(vCatalogueFk INT)
READS SQL DATA
proc:BEGIN
diff --git a/db/routines/floranet/procedures/order_put.sql b/db/routines/floranet/procedures/order_put.sql
index c5eb714728..7ab766a8df 100644
--- a/db/routines/floranet/procedures/order_put.sql
+++ b/db/routines/floranet/procedures/order_put.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE floranet.order_put(vJsonData JSON)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE floranet.order_put(vJsonData JSON)
READS SQL DATA
BEGIN
/**
diff --git a/db/routines/floranet/procedures/sliders_get.sql b/db/routines/floranet/procedures/sliders_get.sql
index bafda47324..096cfbde6a 100644
--- a/db/routines/floranet/procedures/sliders_get.sql
+++ b/db/routines/floranet/procedures/sliders_get.sql
@@ -2,7 +2,7 @@ DROP PROCEDURE IF EXISTS floranet.sliders_get;
DELIMITER $$
$$
-CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.sliders_get()
+CREATE DEFINER=`vn`@`localhost` PROCEDURE floranet.sliders_get()
READS SQL DATA
BEGIN
/**
diff --git a/db/routines/hedera/functions/myClient_getDebt.sql b/db/routines/hedera/functions/myClient_getDebt.sql
index 7f981904e0..7a3678c621 100644
--- a/db/routines/hedera/functions/myClient_getDebt.sql
+++ b/db/routines/hedera/functions/myClient_getDebt.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `hedera`.`myClient_getDebt`(vDate DATE)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `hedera`.`myClient_getDebt`(vDate DATE)
RETURNS decimal(10,2)
DETERMINISTIC
BEGIN
diff --git a/db/routines/hedera/functions/myUser_checkRestPriv.sql b/db/routines/hedera/functions/myUser_checkRestPriv.sql
index 874499ce97..c074a20737 100644
--- a/db/routines/hedera/functions/myUser_checkRestPriv.sql
+++ b/db/routines/hedera/functions/myUser_checkRestPriv.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `hedera`.`myUser_checkRestPriv`(vMethodPath VARCHAR(255))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `hedera`.`myUser_checkRestPriv`(vMethodPath VARCHAR(255))
RETURNS tinyint(1)
DETERMINISTIC
BEGIN
diff --git a/db/routines/hedera/functions/order_getTotal.sql b/db/routines/hedera/functions/order_getTotal.sql
index 2edb6340d9..2a6c901828 100644
--- a/db/routines/hedera/functions/order_getTotal.sql
+++ b/db/routines/hedera/functions/order_getTotal.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `hedera`.`order_getTotal`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `hedera`.`order_getTotal`(vSelf INT)
RETURNS decimal(10,2)
DETERMINISTIC
READS SQL DATA
diff --git a/db/routines/hedera/procedures/catalog_calcFromMyAddress.sql b/db/routines/hedera/procedures/catalog_calcFromMyAddress.sql
index c9fa54f36c..d25346f345 100644
--- a/db/routines/hedera/procedures/catalog_calcFromMyAddress.sql
+++ b/db/routines/hedera/procedures/catalog_calcFromMyAddress.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`catalog_calcFromMyAddress`(vDelivery DATE, vAddress INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`catalog_calcFromMyAddress`(vDelivery DATE, vAddress INT)
BEGIN
/**
* Gets the available items list.
diff --git a/db/routines/hedera/procedures/image_ref.sql b/db/routines/hedera/procedures/image_ref.sql
index 4c6e925fe7..8fb344c1cf 100644
--- a/db/routines/hedera/procedures/image_ref.sql
+++ b/db/routines/hedera/procedures/image_ref.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`image_ref`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`image_ref`(
vCollection VARCHAR(255),
vName VARCHAR(255)
)
diff --git a/db/routines/hedera/procedures/image_unref.sql b/db/routines/hedera/procedures/image_unref.sql
index 146fc486b9..95dda10439 100644
--- a/db/routines/hedera/procedures/image_unref.sql
+++ b/db/routines/hedera/procedures/image_unref.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`image_unref`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`image_unref`(
vCollection VARCHAR(255),
vName VARCHAR(255)
)
diff --git a/db/routines/hedera/procedures/item_calcCatalog.sql b/db/routines/hedera/procedures/item_calcCatalog.sql
index fae89bd5cc..0afe79d5a2 100644
--- a/db/routines/hedera/procedures/item_calcCatalog.sql
+++ b/db/routines/hedera/procedures/item_calcCatalog.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`item_calcCatalog`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`item_calcCatalog`(
vSelf INT,
vLanded DATE,
vAddressFk INT,
diff --git a/db/routines/hedera/procedures/item_getVisible.sql b/db/routines/hedera/procedures/item_getVisible.sql
index d5bbe9d76c..ffb04bf689 100644
--- a/db/routines/hedera/procedures/item_getVisible.sql
+++ b/db/routines/hedera/procedures/item_getVisible.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`item_getVisible`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`item_getVisible`(
vWarehouse TINYINT,
vDate DATE,
vType INT,
diff --git a/db/routines/hedera/procedures/item_listAllocation.sql b/db/routines/hedera/procedures/item_listAllocation.sql
index 4a9c723f52..c7fdf6aa7c 100644
--- a/db/routines/hedera/procedures/item_listAllocation.sql
+++ b/db/routines/hedera/procedures/item_listAllocation.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`item_listAllocation`(IN `vWh` TINYINT, IN `vDate` DATE, IN `vType` INT, IN `vPrefix` VARCHAR(255), IN `vUseIds` BOOLEAN)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`item_listAllocation`(IN `vWh` TINYINT, IN `vDate` DATE, IN `vType` INT, IN `vPrefix` VARCHAR(255), IN `vUseIds` BOOLEAN)
BEGIN
/**
* Lists visible items and it's box sizes of the specified
diff --git a/db/routines/hedera/procedures/myOrder_addItem.sql b/db/routines/hedera/procedures/myOrder_addItem.sql
index b5ea34ea23..90804017c7 100644
--- a/db/routines/hedera/procedures/myOrder_addItem.sql
+++ b/db/routines/hedera/procedures/myOrder_addItem.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`myOrder_addItem`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`myOrder_addItem`(
vSelf INT,
vWarehouse INT,
vItem INT,
diff --git a/db/routines/hedera/procedures/myOrder_calcCatalogFromItem.sql b/db/routines/hedera/procedures/myOrder_calcCatalogFromItem.sql
index 05c2a41f2e..dd6e1b476c 100644
--- a/db/routines/hedera/procedures/myOrder_calcCatalogFromItem.sql
+++ b/db/routines/hedera/procedures/myOrder_calcCatalogFromItem.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`myOrder_calcCatalogFromItem`(vSelf INT, vItem INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`myOrder_calcCatalogFromItem`(vSelf INT, vItem INT)
BEGIN
/**
* Gets the availability and prices for the given item
diff --git a/db/routines/hedera/procedures/myOrder_calcCatalogFull.sql b/db/routines/hedera/procedures/myOrder_calcCatalogFull.sql
index b83286a2ba..b593b64926 100644
--- a/db/routines/hedera/procedures/myOrder_calcCatalogFull.sql
+++ b/db/routines/hedera/procedures/myOrder_calcCatalogFull.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`myOrder_calcCatalogFull`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`myOrder_calcCatalogFull`(vSelf INT)
BEGIN
/**
* Gets the availability and prices for the given items
diff --git a/db/routines/hedera/procedures/myOrder_checkConfig.sql b/db/routines/hedera/procedures/myOrder_checkConfig.sql
index ca810805c9..ca33db032d 100644
--- a/db/routines/hedera/procedures/myOrder_checkConfig.sql
+++ b/db/routines/hedera/procedures/myOrder_checkConfig.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`myOrder_checkConfig`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`myOrder_checkConfig`(vSelf INT)
proc: BEGIN
/**
* Comprueba que la cesta esta creada y que su configuración es
diff --git a/db/routines/hedera/procedures/myOrder_checkMine.sql b/db/routines/hedera/procedures/myOrder_checkMine.sql
index 7e00b2f7f1..7ac370cb60 100644
--- a/db/routines/hedera/procedures/myOrder_checkMine.sql
+++ b/db/routines/hedera/procedures/myOrder_checkMine.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`myOrder_checkMine`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`myOrder_checkMine`(vSelf INT)
proc: BEGIN
/**
* Check that order is owned by current user, otherwise throws an error.
diff --git a/db/routines/hedera/procedures/myOrder_configure.sql b/db/routines/hedera/procedures/myOrder_configure.sql
index 185384fc07..c16406ee7f 100644
--- a/db/routines/hedera/procedures/myOrder_configure.sql
+++ b/db/routines/hedera/procedures/myOrder_configure.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`myOrder_configure`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`myOrder_configure`(
vSelf INT,
vDelivery DATE,
vDeliveryMethod VARCHAR(45),
diff --git a/db/routines/hedera/procedures/myOrder_configureForGuest.sql b/db/routines/hedera/procedures/myOrder_configureForGuest.sql
index 9d4ede5e0d..aa4d0fde7c 100644
--- a/db/routines/hedera/procedures/myOrder_configureForGuest.sql
+++ b/db/routines/hedera/procedures/myOrder_configureForGuest.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`myOrder_configureForGuest`(OUT vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`myOrder_configureForGuest`(OUT vSelf INT)
BEGIN
DECLARE vMethod VARCHAR(255);
DECLARE vAgency INT;
diff --git a/db/routines/hedera/procedures/myOrder_confirm.sql b/db/routines/hedera/procedures/myOrder_confirm.sql
index 2117ea4489..4966bbf9f9 100644
--- a/db/routines/hedera/procedures/myOrder_confirm.sql
+++ b/db/routines/hedera/procedures/myOrder_confirm.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`myOrder_confirm`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`myOrder_confirm`(vSelf INT)
BEGIN
CALL myOrder_checkMine(vSelf);
CALL order_checkConfig(vSelf);
diff --git a/db/routines/hedera/procedures/myOrder_create.sql b/db/routines/hedera/procedures/myOrder_create.sql
index 251948bc64..f945c5af53 100644
--- a/db/routines/hedera/procedures/myOrder_create.sql
+++ b/db/routines/hedera/procedures/myOrder_create.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`myOrder_create`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`myOrder_create`(
OUT vSelf INT,
vDelivery DATE,
vDeliveryMethod VARCHAR(45),
diff --git a/db/routines/hedera/procedures/myOrder_getAvailable.sql b/db/routines/hedera/procedures/myOrder_getAvailable.sql
index 00ac605636..c94a339a6c 100644
--- a/db/routines/hedera/procedures/myOrder_getAvailable.sql
+++ b/db/routines/hedera/procedures/myOrder_getAvailable.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`myOrder_getAvailable`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`myOrder_getAvailable`(vSelf INT)
BEGIN
/**
* Gets the available items list.
diff --git a/db/routines/hedera/procedures/myOrder_getTax.sql b/db/routines/hedera/procedures/myOrder_getTax.sql
index 826a37efdd..68b2dd4c82 100644
--- a/db/routines/hedera/procedures/myOrder_getTax.sql
+++ b/db/routines/hedera/procedures/myOrder_getTax.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`myOrder_getTax`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`myOrder_getTax`(vSelf INT)
READS SQL DATA
BEGIN
/**
diff --git a/db/routines/hedera/procedures/myOrder_newWithAddress.sql b/db/routines/hedera/procedures/myOrder_newWithAddress.sql
index ec3f07d9f4..b4ec4aed46 100644
--- a/db/routines/hedera/procedures/myOrder_newWithAddress.sql
+++ b/db/routines/hedera/procedures/myOrder_newWithAddress.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`myOrder_newWithAddress`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`myOrder_newWithAddress`(
OUT vSelf INT,
vLandingDate DATE,
vAddressFk INT)
diff --git a/db/routines/hedera/procedures/myOrder_newWithDate.sql b/db/routines/hedera/procedures/myOrder_newWithDate.sql
index 4d1837e2b7..a9c4c8f7f6 100644
--- a/db/routines/hedera/procedures/myOrder_newWithDate.sql
+++ b/db/routines/hedera/procedures/myOrder_newWithDate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`myOrder_newWithDate`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`myOrder_newWithDate`(
OUT vSelf INT,
vLandingDate DATE)
BEGIN
diff --git a/db/routines/hedera/procedures/myTicket_get.sql b/db/routines/hedera/procedures/myTicket_get.sql
index 7d203aca64..1c95aea36b 100644
--- a/db/routines/hedera/procedures/myTicket_get.sql
+++ b/db/routines/hedera/procedures/myTicket_get.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`myTicket_get`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`myTicket_get`(vSelf INT)
BEGIN
/**
* Returns a current user ticket header.
diff --git a/db/routines/hedera/procedures/myTicket_getPackages.sql b/db/routines/hedera/procedures/myTicket_getPackages.sql
index 8ed486dffc..8a03a6e354 100644
--- a/db/routines/hedera/procedures/myTicket_getPackages.sql
+++ b/db/routines/hedera/procedures/myTicket_getPackages.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`myTicket_getPackages`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`myTicket_getPackages`(vSelf INT)
BEGIN
/**
* Returns a current user ticket packages.
diff --git a/db/routines/hedera/procedures/myTicket_getRows.sql b/db/routines/hedera/procedures/myTicket_getRows.sql
index 0a99ce892e..53547f2b21 100644
--- a/db/routines/hedera/procedures/myTicket_getRows.sql
+++ b/db/routines/hedera/procedures/myTicket_getRows.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`myTicket_getRows`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`myTicket_getRows`(vSelf INT)
BEGIN
SELECT r.itemFk, r.quantity, r.concept, r.price, r.discount,
i.category, i.size, i.stems, i.inkFk,
diff --git a/db/routines/hedera/procedures/myTicket_getServices.sql b/db/routines/hedera/procedures/myTicket_getServices.sql
index 56ca52c19c..3d982d25af 100644
--- a/db/routines/hedera/procedures/myTicket_getServices.sql
+++ b/db/routines/hedera/procedures/myTicket_getServices.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`myTicket_getServices`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`myTicket_getServices`(vSelf INT)
BEGIN
/**
* Returns a current user ticket services.
diff --git a/db/routines/hedera/procedures/myTicket_list.sql b/db/routines/hedera/procedures/myTicket_list.sql
index b063ce25cd..cfbc064e31 100644
--- a/db/routines/hedera/procedures/myTicket_list.sql
+++ b/db/routines/hedera/procedures/myTicket_list.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`myTicket_list`(vFrom DATE, vTo DATE)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`myTicket_list`(vFrom DATE, vTo DATE)
BEGIN
/**
* Returns the current user list of tickets between two dates reange.
diff --git a/db/routines/hedera/procedures/myTicket_logAccess.sql b/db/routines/hedera/procedures/myTicket_logAccess.sql
index 1dcee8dd68..aa0a1d380e 100644
--- a/db/routines/hedera/procedures/myTicket_logAccess.sql
+++ b/db/routines/hedera/procedures/myTicket_logAccess.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`myTicket_logAccess`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`myTicket_logAccess`(vSelf INT)
BEGIN
/**
* Logs an access to a ticket.
diff --git a/db/routines/hedera/procedures/myTpvTransaction_end.sql b/db/routines/hedera/procedures/myTpvTransaction_end.sql
index 3884f0e374..1972078337 100644
--- a/db/routines/hedera/procedures/myTpvTransaction_end.sql
+++ b/db/routines/hedera/procedures/myTpvTransaction_end.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`myTpvTransaction_end`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`myTpvTransaction_end`(
vSelf INT,
vStatus VARCHAR(12))
BEGIN
diff --git a/db/routines/hedera/procedures/myTpvTransaction_start.sql b/db/routines/hedera/procedures/myTpvTransaction_start.sql
index 71bae97fa6..e3d5023b8f 100644
--- a/db/routines/hedera/procedures/myTpvTransaction_start.sql
+++ b/db/routines/hedera/procedures/myTpvTransaction_start.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`myTpvTransaction_start`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`myTpvTransaction_start`(
vAmount INT,
vCompany INT)
BEGIN
diff --git a/db/routines/hedera/procedures/order_addItem.sql b/db/routines/hedera/procedures/order_addItem.sql
index 1470ddf356..d448f1a0df 100644
--- a/db/routines/hedera/procedures/order_addItem.sql
+++ b/db/routines/hedera/procedures/order_addItem.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_addItem`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`order_addItem`(
vSelf INT,
vWarehouse INT,
vItem INT,
diff --git a/db/routines/hedera/procedures/order_calcCatalog.sql b/db/routines/hedera/procedures/order_calcCatalog.sql
index 239e017886..efdb9d190d 100644
--- a/db/routines/hedera/procedures/order_calcCatalog.sql
+++ b/db/routines/hedera/procedures/order_calcCatalog.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_calcCatalog`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`order_calcCatalog`(vSelf INT)
BEGIN
/**
* Gets the availability and prices for order items.
diff --git a/db/routines/hedera/procedures/order_calcCatalogFromItem.sql b/db/routines/hedera/procedures/order_calcCatalogFromItem.sql
index 517e9dab91..ae57ad5ba9 100644
--- a/db/routines/hedera/procedures/order_calcCatalogFromItem.sql
+++ b/db/routines/hedera/procedures/order_calcCatalogFromItem.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_calcCatalogFromItem`(vSelf INT, vItem INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`order_calcCatalogFromItem`(vSelf INT, vItem INT)
BEGIN
/**
* Gets the availability and prices for the given item
diff --git a/db/routines/hedera/procedures/order_calcCatalogFull.sql b/db/routines/hedera/procedures/order_calcCatalogFull.sql
index 41408c5e80..fedb739031 100644
--- a/db/routines/hedera/procedures/order_calcCatalogFull.sql
+++ b/db/routines/hedera/procedures/order_calcCatalogFull.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_calcCatalogFull`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`order_calcCatalogFull`(vSelf INT)
BEGIN
/**
* Gets the availability and prices for the given items
diff --git a/db/routines/hedera/procedures/order_checkConfig.sql b/db/routines/hedera/procedures/order_checkConfig.sql
index 9dbea1a76a..88799b2deb 100644
--- a/db/routines/hedera/procedures/order_checkConfig.sql
+++ b/db/routines/hedera/procedures/order_checkConfig.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_checkConfig`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`order_checkConfig`(vSelf INT)
BEGIN
/**
* Comprueba que la configuración del pedido es correcta.
diff --git a/db/routines/hedera/procedures/order_checkEditable.sql b/db/routines/hedera/procedures/order_checkEditable.sql
index 512e6e6f10..8ff7e59962 100644
--- a/db/routines/hedera/procedures/order_checkEditable.sql
+++ b/db/routines/hedera/procedures/order_checkEditable.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_checkEditable`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`order_checkEditable`(vSelf INT)
BEGIN
/**
* Cheks if order is editable.
diff --git a/db/routines/hedera/procedures/order_configure.sql b/db/routines/hedera/procedures/order_configure.sql
index b03acec086..42b4034443 100644
--- a/db/routines/hedera/procedures/order_configure.sql
+++ b/db/routines/hedera/procedures/order_configure.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_configure`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`order_configure`(
vSelf INT,
vDelivery DATE,
vDeliveryMethod VARCHAR(45),
diff --git a/db/routines/hedera/procedures/order_confirm.sql b/db/routines/hedera/procedures/order_confirm.sql
index 6fd53b4ea8..bf70b4645a 100644
--- a/db/routines/hedera/procedures/order_confirm.sql
+++ b/db/routines/hedera/procedures/order_confirm.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_confirm`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`order_confirm`(vSelf INT)
BEGIN
/**
* Confirms an order, creating each of its tickets on
diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql
index db83cba5c3..dee927e254 100644
--- a/db/routines/hedera/procedures/order_confirmWithUser.sql
+++ b/db/routines/hedera/procedures/order_confirmWithUser.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_confirmWithUser`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`order_confirmWithUser`(
vSelf INT,
vUserFk INT
)
diff --git a/db/routines/hedera/procedures/order_getAvailable.sql b/db/routines/hedera/procedures/order_getAvailable.sql
index 2b7d60e331..12a5297d63 100644
--- a/db/routines/hedera/procedures/order_getAvailable.sql
+++ b/db/routines/hedera/procedures/order_getAvailable.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_getAvailable`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`order_getAvailable`(vSelf INT)
BEGIN
/**
* Gets the available items list.
diff --git a/db/routines/hedera/procedures/order_getTax.sql b/db/routines/hedera/procedures/order_getTax.sql
index 371416c297..59674564f3 100644
--- a/db/routines/hedera/procedures/order_getTax.sql
+++ b/db/routines/hedera/procedures/order_getTax.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_getTax`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`order_getTax`()
READS SQL DATA
BEGIN
/**
diff --git a/db/routines/hedera/procedures/order_getTotal.sql b/db/routines/hedera/procedures/order_getTotal.sql
index c0b8d40ae7..a8c872aece 100644
--- a/db/routines/hedera/procedures/order_getTotal.sql
+++ b/db/routines/hedera/procedures/order_getTotal.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_getTotal`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`order_getTotal`()
BEGIN
/**
* Calcula el total con IVA para un conjunto de orders.
diff --git a/db/routines/hedera/procedures/order_recalc.sql b/db/routines/hedera/procedures/order_recalc.sql
index 1398b49f65..a76c34f2c1 100644
--- a/db/routines/hedera/procedures/order_recalc.sql
+++ b/db/routines/hedera/procedures/order_recalc.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_recalc`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`order_recalc`(vSelf INT)
BEGIN
/**
* Recalculates the order total.
diff --git a/db/routines/hedera/procedures/order_update.sql b/db/routines/hedera/procedures/order_update.sql
index 207cad09f8..0a7981072a 100644
--- a/db/routines/hedera/procedures/order_update.sql
+++ b/db/routines/hedera/procedures/order_update.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_update`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`order_update`(vSelf INT)
proc: BEGIN
/**
* Actualiza las líneas de un pedido.
diff --git a/db/routines/hedera/procedures/survey_vote.sql b/db/routines/hedera/procedures/survey_vote.sql
index 46c31393a3..b54ce2736c 100644
--- a/db/routines/hedera/procedures/survey_vote.sql
+++ b/db/routines/hedera/procedures/survey_vote.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`survey_vote`(vAnswer INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`survey_vote`(vAnswer INT)
BEGIN
DECLARE vSurvey INT;
DECLARE vCount TINYINT;
diff --git a/db/routines/hedera/procedures/tpvTransaction_confirm.sql b/db/routines/hedera/procedures/tpvTransaction_confirm.sql
index 60a6d8452a..e14340b6bb 100644
--- a/db/routines/hedera/procedures/tpvTransaction_confirm.sql
+++ b/db/routines/hedera/procedures/tpvTransaction_confirm.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`tpvTransaction_confirm`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`tpvTransaction_confirm`(
vAmount INT
,vOrder INT
,vMerchant INT
diff --git a/db/routines/hedera/procedures/tpvTransaction_confirmAll.sql b/db/routines/hedera/procedures/tpvTransaction_confirmAll.sql
index b6a71af016..d6cfafd6c7 100644
--- a/db/routines/hedera/procedures/tpvTransaction_confirmAll.sql
+++ b/db/routines/hedera/procedures/tpvTransaction_confirmAll.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`tpvTransaction_confirmAll`(vDate DATE)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`tpvTransaction_confirmAll`(vDate DATE)
BEGIN
/**
* Confirma todas las transacciones confirmadas por el cliente pero no
diff --git a/db/routines/hedera/procedures/tpvTransaction_confirmById.sql b/db/routines/hedera/procedures/tpvTransaction_confirmById.sql
index 7cbdb65c66..a6a476e5bc 100644
--- a/db/routines/hedera/procedures/tpvTransaction_confirmById.sql
+++ b/db/routines/hedera/procedures/tpvTransaction_confirmById.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`tpvTransaction_confirmById`(vOrder INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`tpvTransaction_confirmById`(vOrder INT)
BEGIN
/**
* Confirma manualmente una transacción espedificando su identificador.
diff --git a/db/routines/hedera/procedures/tpvTransaction_confirmFromExport.sql b/db/routines/hedera/procedures/tpvTransaction_confirmFromExport.sql
index 7ca0e44e2e..8082f9abca 100644
--- a/db/routines/hedera/procedures/tpvTransaction_confirmFromExport.sql
+++ b/db/routines/hedera/procedures/tpvTransaction_confirmFromExport.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`tpvTransaction_confirmFromExport`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`tpvTransaction_confirmFromExport`()
BEGIN
/**
* Confirms multiple transactions comming from Redsys "canales" exported CSV.
diff --git a/db/routines/hedera/procedures/tpvTransaction_end.sql b/db/routines/hedera/procedures/tpvTransaction_end.sql
index ec0a0224d5..1c03ffe744 100644
--- a/db/routines/hedera/procedures/tpvTransaction_end.sql
+++ b/db/routines/hedera/procedures/tpvTransaction_end.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`tpvTransaction_end`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`tpvTransaction_end`(
vSelf INT,
vStatus VARCHAR(12))
BEGIN
diff --git a/db/routines/hedera/procedures/tpvTransaction_start.sql b/db/routines/hedera/procedures/tpvTransaction_start.sql
index 55fd922daf..7ed63c1245 100644
--- a/db/routines/hedera/procedures/tpvTransaction_start.sql
+++ b/db/routines/hedera/procedures/tpvTransaction_start.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`tpvTransaction_start`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`tpvTransaction_start`(
vAmount INT,
vCompany INT,
vUser INT)
diff --git a/db/routines/hedera/procedures/tpvTransaction_undo.sql b/db/routines/hedera/procedures/tpvTransaction_undo.sql
index f31ba6a80a..8eabba3c16 100644
--- a/db/routines/hedera/procedures/tpvTransaction_undo.sql
+++ b/db/routines/hedera/procedures/tpvTransaction_undo.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`tpvTransaction_undo`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`tpvTransaction_undo`(vSelf INT)
p: BEGIN
DECLARE vCustomer INT;
DECLARE vAmount DOUBLE;
diff --git a/db/routines/hedera/procedures/visitUser_new.sql b/db/routines/hedera/procedures/visitUser_new.sql
index 3c299f209e..1a4e3a08c2 100644
--- a/db/routines/hedera/procedures/visitUser_new.sql
+++ b/db/routines/hedera/procedures/visitUser_new.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`visitUser_new`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`visitUser_new`(
vAccess INT
,vSsid VARCHAR(64)
)
diff --git a/db/routines/hedera/procedures/visit_listByBrowser.sql b/db/routines/hedera/procedures/visit_listByBrowser.sql
index 2fa45b8f21..dcf3fdad94 100644
--- a/db/routines/hedera/procedures/visit_listByBrowser.sql
+++ b/db/routines/hedera/procedures/visit_listByBrowser.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`visit_listByBrowser`(vFrom DATE, vTo DATE)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`visit_listByBrowser`(vFrom DATE, vTo DATE)
BEGIN
/**
* Lists visits grouped by browser.
diff --git a/db/routines/hedera/procedures/visit_register.sql b/db/routines/hedera/procedures/visit_register.sql
index 80b6f16a9d..345527b257 100644
--- a/db/routines/hedera/procedures/visit_register.sql
+++ b/db/routines/hedera/procedures/visit_register.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`visit_register`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`visit_register`(
vVisit INT
,vPlatform VARCHAR(30)
,vBrowser VARCHAR(30)
diff --git a/db/routines/hedera/triggers/link_afterDelete.sql b/db/routines/hedera/triggers/link_afterDelete.sql
index 571540cbac..e9efa7f91f 100644
--- a/db/routines/hedera/triggers/link_afterDelete.sql
+++ b/db/routines/hedera/triggers/link_afterDelete.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`link_afterDelete`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `hedera`.`link_afterDelete`
AFTER DELETE ON `link`
FOR EACH ROW
BEGIN
diff --git a/db/routines/hedera/triggers/link_afterInsert.sql b/db/routines/hedera/triggers/link_afterInsert.sql
index e3f163a9e2..af6989e444 100644
--- a/db/routines/hedera/triggers/link_afterInsert.sql
+++ b/db/routines/hedera/triggers/link_afterInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`link_afterInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `hedera`.`link_afterInsert`
AFTER INSERT ON `link`
FOR EACH ROW
BEGIN
diff --git a/db/routines/hedera/triggers/link_afterUpdate.sql b/db/routines/hedera/triggers/link_afterUpdate.sql
index 7ffe2a3353..c10f20b252 100644
--- a/db/routines/hedera/triggers/link_afterUpdate.sql
+++ b/db/routines/hedera/triggers/link_afterUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`link_afterUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `hedera`.`link_afterUpdate`
AFTER UPDATE ON `link`
FOR EACH ROW
BEGIN
diff --git a/db/routines/hedera/triggers/news_afterDelete.sql b/db/routines/hedera/triggers/news_afterDelete.sql
index 07a0403e07..73a85ba7b7 100644
--- a/db/routines/hedera/triggers/news_afterDelete.sql
+++ b/db/routines/hedera/triggers/news_afterDelete.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`news_afterDelete`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `hedera`.`news_afterDelete`
AFTER DELETE ON `news`
FOR EACH ROW
BEGIN
diff --git a/db/routines/hedera/triggers/news_afterInsert.sql b/db/routines/hedera/triggers/news_afterInsert.sql
index 61e6078ef6..7d5c4ded71 100644
--- a/db/routines/hedera/triggers/news_afterInsert.sql
+++ b/db/routines/hedera/triggers/news_afterInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`news_afterInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `hedera`.`news_afterInsert`
AFTER INSERT ON `news`
FOR EACH ROW
BEGIN
diff --git a/db/routines/hedera/triggers/news_afterUpdate.sql b/db/routines/hedera/triggers/news_afterUpdate.sql
index 15ea32f1d9..e0a74f1caa 100644
--- a/db/routines/hedera/triggers/news_afterUpdate.sql
+++ b/db/routines/hedera/triggers/news_afterUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`news_afterUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `hedera`.`news_afterUpdate`
AFTER UPDATE ON `news`
FOR EACH ROW
BEGIN
diff --git a/db/routines/hedera/triggers/orderRow_afterInsert.sql b/db/routines/hedera/triggers/orderRow_afterInsert.sql
index 7196dce10f..11809e3c5c 100644
--- a/db/routines/hedera/triggers/orderRow_afterInsert.sql
+++ b/db/routines/hedera/triggers/orderRow_afterInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`orderRow_afterInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `hedera`.`orderRow_afterInsert`
AFTER INSERT ON `orderRow`
FOR EACH ROW
BEGIN
diff --git a/db/routines/hedera/triggers/orderRow_beforeInsert.sql b/db/routines/hedera/triggers/orderRow_beforeInsert.sql
index 0c9f31bab7..b35123f4a9 100644
--- a/db/routines/hedera/triggers/orderRow_beforeInsert.sql
+++ b/db/routines/hedera/triggers/orderRow_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`orderRow_beforeInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `hedera`.`orderRow_beforeInsert`
BEFORE INSERT ON `orderRow`
FOR EACH ROW
BEGIN
diff --git a/db/routines/hedera/triggers/order_afterInsert.sql b/db/routines/hedera/triggers/order_afterInsert.sql
index 2fe83ee8f6..7070ede026 100644
--- a/db/routines/hedera/triggers/order_afterInsert.sql
+++ b/db/routines/hedera/triggers/order_afterInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`order_afterInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `hedera`.`order_afterInsert`
AFTER INSERT ON `order`
FOR EACH ROW
BEGIN
diff --git a/db/routines/hedera/triggers/order_afterUpdate.sql b/db/routines/hedera/triggers/order_afterUpdate.sql
index 25f51b3f03..3b1cd9df1d 100644
--- a/db/routines/hedera/triggers/order_afterUpdate.sql
+++ b/db/routines/hedera/triggers/order_afterUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`order_afterUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `hedera`.`order_afterUpdate`
AFTER UPDATE ON `order`
FOR EACH ROW
BEGIN
diff --git a/db/routines/hedera/triggers/order_beforeDelete.sql b/db/routines/hedera/triggers/order_beforeDelete.sql
index eb602be897..da6259248a 100644
--- a/db/routines/hedera/triggers/order_beforeDelete.sql
+++ b/db/routines/hedera/triggers/order_beforeDelete.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`order_beforeDelete`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `hedera`.`order_beforeDelete`
BEFORE DELETE ON `order`
FOR EACH ROW
BEGIN
diff --git a/db/routines/hedera/views/mainAccountBank.sql b/db/routines/hedera/views/mainAccountBank.sql
index 3130a1614a..9fc3b3c3a1 100644
--- a/db/routines/hedera/views/mainAccountBank.sql
+++ b/db/routines/hedera/views/mainAccountBank.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `hedera`.`mainAccountBank`
AS SELECT `e`.`name` AS `name`,
diff --git a/db/routines/hedera/views/messageL10n.sql b/db/routines/hedera/views/messageL10n.sql
index 6488de6a91..80f6638ada 100644
--- a/db/routines/hedera/views/messageL10n.sql
+++ b/db/routines/hedera/views/messageL10n.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `hedera`.`messageL10n`
AS SELECT `m`.`code` AS `code`,
diff --git a/db/routines/hedera/views/myAddress.sql b/db/routines/hedera/views/myAddress.sql
index ee8d87759e..80809c5ea1 100644
--- a/db/routines/hedera/views/myAddress.sql
+++ b/db/routines/hedera/views/myAddress.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `hedera`.`myAddress`
AS SELECT `t`.`id` AS `id`,
diff --git a/db/routines/hedera/views/myBasketDefaults.sql b/db/routines/hedera/views/myBasketDefaults.sql
index 475212da10..43df186871 100644
--- a/db/routines/hedera/views/myBasketDefaults.sql
+++ b/db/routines/hedera/views/myBasketDefaults.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `hedera`.`myBasketDefaults`
AS SELECT coalesce(`dm`.`code`, `cm`.`code`) AS `deliveryMethod`,
diff --git a/db/routines/hedera/views/myClient.sql b/db/routines/hedera/views/myClient.sql
index ef7159549c..032cc5f5ff 100644
--- a/db/routines/hedera/views/myClient.sql
+++ b/db/routines/hedera/views/myClient.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `hedera`.`myClient`
AS SELECT `c`.`id` AS `id`,
diff --git a/db/routines/hedera/views/myInvoice.sql b/db/routines/hedera/views/myInvoice.sql
index dd1a917ada..40527ac0ce 100644
--- a/db/routines/hedera/views/myInvoice.sql
+++ b/db/routines/hedera/views/myInvoice.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `hedera`.`myInvoice`
AS SELECT `i`.`id` AS `id`,
diff --git a/db/routines/hedera/views/myMenu.sql b/db/routines/hedera/views/myMenu.sql
index 94e58835d1..60f464e7ac 100644
--- a/db/routines/hedera/views/myMenu.sql
+++ b/db/routines/hedera/views/myMenu.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `hedera`.`myMenu`
AS SELECT `t`.`id` AS `id`,
diff --git a/db/routines/hedera/views/myOrder.sql b/db/routines/hedera/views/myOrder.sql
index 78becd8840..ca92832985 100644
--- a/db/routines/hedera/views/myOrder.sql
+++ b/db/routines/hedera/views/myOrder.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `hedera`.`myOrder`
AS SELECT `o`.`id` AS `id`,
diff --git a/db/routines/hedera/views/myOrderRow.sql b/db/routines/hedera/views/myOrderRow.sql
index af42b07455..ddf91a24fc 100644
--- a/db/routines/hedera/views/myOrderRow.sql
+++ b/db/routines/hedera/views/myOrderRow.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `hedera`.`myOrderRow`
AS SELECT `orw`.`id` AS `id`,
diff --git a/db/routines/hedera/views/myOrderTicket.sql b/db/routines/hedera/views/myOrderTicket.sql
index fa8220b554..5fa5418559 100644
--- a/db/routines/hedera/views/myOrderTicket.sql
+++ b/db/routines/hedera/views/myOrderTicket.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `hedera`.`myOrderTicket`
AS SELECT `o`.`id` AS `orderFk`,
diff --git a/db/routines/hedera/views/myTicket.sql b/db/routines/hedera/views/myTicket.sql
index f17cda9a46..4edb742c85 100644
--- a/db/routines/hedera/views/myTicket.sql
+++ b/db/routines/hedera/views/myTicket.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `hedera`.`myTicket`
AS SELECT `t`.`id` AS `id`,
diff --git a/db/routines/hedera/views/myTicketRow.sql b/db/routines/hedera/views/myTicketRow.sql
index 5afff812b2..69b11625f7 100644
--- a/db/routines/hedera/views/myTicketRow.sql
+++ b/db/routines/hedera/views/myTicketRow.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `hedera`.`myTicketRow`
AS SELECT `s`.`id` AS `id`,
diff --git a/db/routines/hedera/views/myTicketService.sql b/db/routines/hedera/views/myTicketService.sql
index feb839873b..7cb23a862e 100644
--- a/db/routines/hedera/views/myTicketService.sql
+++ b/db/routines/hedera/views/myTicketService.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `hedera`.`myTicketService`
AS SELECT `s`.`id` AS `id`,
diff --git a/db/routines/hedera/views/myTicketState.sql b/db/routines/hedera/views/myTicketState.sql
index 530441e3b2..8d3d276b81 100644
--- a/db/routines/hedera/views/myTicketState.sql
+++ b/db/routines/hedera/views/myTicketState.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `hedera`.`myTicketState`
AS SELECT `t`.`id` AS `id`,
diff --git a/db/routines/hedera/views/myTpvTransaction.sql b/db/routines/hedera/views/myTpvTransaction.sql
index 98694065fa..a860ed29d7 100644
--- a/db/routines/hedera/views/myTpvTransaction.sql
+++ b/db/routines/hedera/views/myTpvTransaction.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `hedera`.`myTpvTransaction`
AS SELECT `t`.`id` AS `id`,
diff --git a/db/routines/hedera/views/orderTicket.sql b/db/routines/hedera/views/orderTicket.sql
index c350779357..b0c55bc7de 100644
--- a/db/routines/hedera/views/orderTicket.sql
+++ b/db/routines/hedera/views/orderTicket.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `hedera`.`orderTicket`
AS SELECT `b`.`orderFk` AS `orderFk`,
diff --git a/db/routines/hedera/views/order_component.sql b/db/routines/hedera/views/order_component.sql
index b3eb7522b7..e83114724c 100644
--- a/db/routines/hedera/views/order_component.sql
+++ b/db/routines/hedera/views/order_component.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `hedera`.`order_component`
AS SELECT `t`.`rowFk` AS `order_row_id`,
diff --git a/db/routines/hedera/views/order_row.sql b/db/routines/hedera/views/order_row.sql
index f69fd98a36..ab25774f6b 100644
--- a/db/routines/hedera/views/order_row.sql
+++ b/db/routines/hedera/views/order_row.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `hedera`.`order_row`
AS SELECT `t`.`id` AS `id`,
diff --git a/db/routines/pbx/functions/clientFromPhone.sql b/db/routines/pbx/functions/clientFromPhone.sql
index dc18810aaa..b8186e0e02 100644
--- a/db/routines/pbx/functions/clientFromPhone.sql
+++ b/db/routines/pbx/functions/clientFromPhone.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `pbx`.`clientFromPhone`(vPhone VARCHAR(255))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `pbx`.`clientFromPhone`(vPhone VARCHAR(255))
RETURNS int(11)
DETERMINISTIC
BEGIN
diff --git a/db/routines/pbx/functions/phone_format.sql b/db/routines/pbx/functions/phone_format.sql
index dc697386af..b42dfe96b1 100644
--- a/db/routines/pbx/functions/phone_format.sql
+++ b/db/routines/pbx/functions/phone_format.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `pbx`.`phone_format`(vPhone VARCHAR(255))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `pbx`.`phone_format`(vPhone VARCHAR(255))
RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_general_ci
DETERMINISTIC
BEGIN
diff --git a/db/routines/pbx/procedures/phone_isValid.sql b/db/routines/pbx/procedures/phone_isValid.sql
index 083a3e54b6..be3d2968a7 100644
--- a/db/routines/pbx/procedures/phone_isValid.sql
+++ b/db/routines/pbx/procedures/phone_isValid.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `pbx`.`phone_isValid`(vPhone VARCHAR(255))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `pbx`.`phone_isValid`(vPhone VARCHAR(255))
BEGIN
/**
* Check if an phone has the correct format and
diff --git a/db/routines/pbx/procedures/queue_isValid.sql b/db/routines/pbx/procedures/queue_isValid.sql
index 52c752e092..a07bc342b4 100644
--- a/db/routines/pbx/procedures/queue_isValid.sql
+++ b/db/routines/pbx/procedures/queue_isValid.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `pbx`.`queue_isValid`(vQueue VARCHAR(255))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `pbx`.`queue_isValid`(vQueue VARCHAR(255))
BEGIN
/**
* Check if an queue has the correct format and
diff --git a/db/routines/pbx/procedures/sip_getExtension.sql b/db/routines/pbx/procedures/sip_getExtension.sql
index 25047fa1f5..640da5a3e0 100644
--- a/db/routines/pbx/procedures/sip_getExtension.sql
+++ b/db/routines/pbx/procedures/sip_getExtension.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `pbx`.`sip_getExtension`(vUserId INT(10))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `pbx`.`sip_getExtension`(vUserId INT(10))
BEGIN
/*
diff --git a/db/routines/pbx/procedures/sip_isValid.sql b/db/routines/pbx/procedures/sip_isValid.sql
index 4a0182bcce..d9c45831de 100644
--- a/db/routines/pbx/procedures/sip_isValid.sql
+++ b/db/routines/pbx/procedures/sip_isValid.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `pbx`.`sip_isValid`(vExtension VARCHAR(255))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `pbx`.`sip_isValid`(vExtension VARCHAR(255))
BEGIN
/**
* Check if an extension has the correct format and
diff --git a/db/routines/pbx/procedures/sip_setPassword.sql b/db/routines/pbx/procedures/sip_setPassword.sql
index 14e0b05c55..146e7a5022 100644
--- a/db/routines/pbx/procedures/sip_setPassword.sql
+++ b/db/routines/pbx/procedures/sip_setPassword.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `pbx`.`sip_setPassword`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `pbx`.`sip_setPassword`(
vUser VARCHAR(255),
vPassword VARCHAR(255)
)
diff --git a/db/routines/pbx/triggers/blacklist_beforeInsert.sql b/db/routines/pbx/triggers/blacklist_beforeInsert.sql
index ff55c2647e..6bc7909d82 100644
--- a/db/routines/pbx/triggers/blacklist_beforeInsert.sql
+++ b/db/routines/pbx/triggers/blacklist_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `pbx`.`blacklist_beforeInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `pbx`.`blacklist_beforeInsert`
BEFORE INSERT ON `blacklist`
FOR EACH ROW
BEGIN
diff --git a/db/routines/pbx/triggers/blacklist_berforeUpdate.sql b/db/routines/pbx/triggers/blacklist_berforeUpdate.sql
index 84f2c4bbb0..741b34c0ae 100644
--- a/db/routines/pbx/triggers/blacklist_berforeUpdate.sql
+++ b/db/routines/pbx/triggers/blacklist_berforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `pbx`.`blacklist_berforeUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `pbx`.`blacklist_berforeUpdate`
BEFORE UPDATE ON `blacklist`
FOR EACH ROW
BEGIN
diff --git a/db/routines/pbx/triggers/followme_beforeInsert.sql b/db/routines/pbx/triggers/followme_beforeInsert.sql
index 69f11c5e64..38413f53a4 100644
--- a/db/routines/pbx/triggers/followme_beforeInsert.sql
+++ b/db/routines/pbx/triggers/followme_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `pbx`.`followme_beforeInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `pbx`.`followme_beforeInsert`
BEFORE INSERT ON `followme`
FOR EACH ROW
BEGIN
diff --git a/db/routines/pbx/triggers/followme_beforeUpdate.sql b/db/routines/pbx/triggers/followme_beforeUpdate.sql
index 697c18974b..67c243c7fd 100644
--- a/db/routines/pbx/triggers/followme_beforeUpdate.sql
+++ b/db/routines/pbx/triggers/followme_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `pbx`.`followme_beforeUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `pbx`.`followme_beforeUpdate`
BEFORE UPDATE ON `followme`
FOR EACH ROW
BEGIN
diff --git a/db/routines/pbx/triggers/queuePhone_beforeInsert.sql b/db/routines/pbx/triggers/queuePhone_beforeInsert.sql
index debe9c2019..015a227ae7 100644
--- a/db/routines/pbx/triggers/queuePhone_beforeInsert.sql
+++ b/db/routines/pbx/triggers/queuePhone_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `pbx`.`queuePhone_beforeInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `pbx`.`queuePhone_beforeInsert`
BEFORE INSERT ON `queuePhone`
FOR EACH ROW
BEGIN
diff --git a/db/routines/pbx/triggers/queuePhone_beforeUpdate.sql b/db/routines/pbx/triggers/queuePhone_beforeUpdate.sql
index 9734cc2779..892a10acdb 100644
--- a/db/routines/pbx/triggers/queuePhone_beforeUpdate.sql
+++ b/db/routines/pbx/triggers/queuePhone_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `pbx`.`queuePhone_beforeUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `pbx`.`queuePhone_beforeUpdate`
BEFORE UPDATE ON `queuePhone`
FOR EACH ROW
BEGIN
diff --git a/db/routines/pbx/triggers/queue_beforeInsert.sql b/db/routines/pbx/triggers/queue_beforeInsert.sql
index 4644dea892..f601d8688a 100644
--- a/db/routines/pbx/triggers/queue_beforeInsert.sql
+++ b/db/routines/pbx/triggers/queue_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `pbx`.`queue_beforeInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `pbx`.`queue_beforeInsert`
BEFORE INSERT ON `queue`
FOR EACH ROW
BEGIN
diff --git a/db/routines/pbx/triggers/queue_beforeUpdate.sql b/db/routines/pbx/triggers/queue_beforeUpdate.sql
index a2923045ea..22e0afc672 100644
--- a/db/routines/pbx/triggers/queue_beforeUpdate.sql
+++ b/db/routines/pbx/triggers/queue_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `pbx`.`queue_beforeUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `pbx`.`queue_beforeUpdate`
BEFORE UPDATE ON `queue`
FOR EACH ROW
BEGIN
diff --git a/db/routines/pbx/triggers/sip_afterInsert.sql b/db/routines/pbx/triggers/sip_afterInsert.sql
index 7f0643a986..ab1123106e 100644
--- a/db/routines/pbx/triggers/sip_afterInsert.sql
+++ b/db/routines/pbx/triggers/sip_afterInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `pbx`.`sip_afterInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `pbx`.`sip_afterInsert`
AFTER INSERT ON `sip`
FOR EACH ROW
BEGIN
diff --git a/db/routines/pbx/triggers/sip_afterUpdate.sql b/db/routines/pbx/triggers/sip_afterUpdate.sql
index d14df040cc..2556d574c1 100644
--- a/db/routines/pbx/triggers/sip_afterUpdate.sql
+++ b/db/routines/pbx/triggers/sip_afterUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `pbx`.`sip_afterUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `pbx`.`sip_afterUpdate`
AFTER UPDATE ON `sip`
FOR EACH ROW
BEGIN
diff --git a/db/routines/pbx/triggers/sip_beforeInsert.sql b/db/routines/pbx/triggers/sip_beforeInsert.sql
index 8322321196..500f300775 100644
--- a/db/routines/pbx/triggers/sip_beforeInsert.sql
+++ b/db/routines/pbx/triggers/sip_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `pbx`.`sip_beforeInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `pbx`.`sip_beforeInsert`
BEFORE INSERT ON `sip`
FOR EACH ROW
BEGIN
diff --git a/db/routines/pbx/triggers/sip_beforeUpdate.sql b/db/routines/pbx/triggers/sip_beforeUpdate.sql
index e23b8e22e0..95c943100d 100644
--- a/db/routines/pbx/triggers/sip_beforeUpdate.sql
+++ b/db/routines/pbx/triggers/sip_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `pbx`.`sip_beforeUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `pbx`.`sip_beforeUpdate`
BEFORE UPDATE ON `sip`
FOR EACH ROW
BEGIN
diff --git a/db/routines/pbx/views/cdrConf.sql b/db/routines/pbx/views/cdrConf.sql
index adf24c87d6..e4b8ad60a4 100644
--- a/db/routines/pbx/views/cdrConf.sql
+++ b/db/routines/pbx/views/cdrConf.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `pbx`.`cdrConf`
AS SELECT `c`.`call_date` AS `calldate`,
diff --git a/db/routines/pbx/views/followmeConf.sql b/db/routines/pbx/views/followmeConf.sql
index 75eb25ff2b..7c92301d1c 100644
--- a/db/routines/pbx/views/followmeConf.sql
+++ b/db/routines/pbx/views/followmeConf.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `pbx`.`followmeConf`
AS SELECT `f`.`extension` AS `name`,
diff --git a/db/routines/pbx/views/followmeNumberConf.sql b/db/routines/pbx/views/followmeNumberConf.sql
index c83b639a8a..f80dd5a9de 100644
--- a/db/routines/pbx/views/followmeNumberConf.sql
+++ b/db/routines/pbx/views/followmeNumberConf.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `pbx`.`followmeNumberConf`
AS SELECT `f`.`extension` AS `name`,
diff --git a/db/routines/pbx/views/queueConf.sql b/db/routines/pbx/views/queueConf.sql
index 107989801f..8416bdb52e 100644
--- a/db/routines/pbx/views/queueConf.sql
+++ b/db/routines/pbx/views/queueConf.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `pbx`.`queueConf`
AS SELECT `q`.`name` AS `name`,
diff --git a/db/routines/pbx/views/queueMemberConf.sql b/db/routines/pbx/views/queueMemberConf.sql
index 7007daa1ee..734313c7bb 100644
--- a/db/routines/pbx/views/queueMemberConf.sql
+++ b/db/routines/pbx/views/queueMemberConf.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `pbx`.`queueMemberConf`
AS SELECT `m`.`id` AS `uniqueid`,
diff --git a/db/routines/pbx/views/sipConf.sql b/db/routines/pbx/views/sipConf.sql
index 0765264bcd..302f967ec1 100644
--- a/db/routines/pbx/views/sipConf.sql
+++ b/db/routines/pbx/views/sipConf.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `pbx`.`sipConf`
AS SELECT `s`.`user_id` AS `id`,
diff --git a/db/routines/psico/procedures/answerSort.sql b/db/routines/psico/procedures/answerSort.sql
index 75a317b370..c7fd7e48db 100644
--- a/db/routines/psico/procedures/answerSort.sql
+++ b/db/routines/psico/procedures/answerSort.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `psico`.`answerSort`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `psico`.`answerSort`()
BEGIN
UPDATE answer
diff --git a/db/routines/psico/procedures/examNew.sql b/db/routines/psico/procedures/examNew.sql
index 4f27212f6f..5b8eada3ac 100644
--- a/db/routines/psico/procedures/examNew.sql
+++ b/db/routines/psico/procedures/examNew.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `psico`.`examNew`(vFellow VARCHAR(50), vType INT, vQuestionsNumber INT, OUT vExamFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `psico`.`examNew`(vFellow VARCHAR(50), vType INT, vQuestionsNumber INT, OUT vExamFk INT)
BEGIN
DECLARE done BOOL DEFAULT FALSE;
diff --git a/db/routines/psico/procedures/getExamQuestions.sql b/db/routines/psico/procedures/getExamQuestions.sql
index 9ab1eb6d0e..7545a3e792 100644
--- a/db/routines/psico/procedures/getExamQuestions.sql
+++ b/db/routines/psico/procedures/getExamQuestions.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `psico`.`getExamQuestions`(vExamFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `psico`.`getExamQuestions`(vExamFk INT)
BEGIN
SELECT p.text,p.examFk,p.questionFk,p.answerFk,p.id ,a.text AS answerText,a.correct, a.id AS answerFk
diff --git a/db/routines/psico/procedures/getExamType.sql b/db/routines/psico/procedures/getExamType.sql
index d829950e65..25bda6682b 100644
--- a/db/routines/psico/procedures/getExamType.sql
+++ b/db/routines/psico/procedures/getExamType.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `psico`.`getExamType`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `psico`.`getExamType`()
BEGIN
SELECT id,name
diff --git a/db/routines/psico/procedures/questionSort.sql b/db/routines/psico/procedures/questionSort.sql
index 56c5ef4a92..6e47c1c463 100644
--- a/db/routines/psico/procedures/questionSort.sql
+++ b/db/routines/psico/procedures/questionSort.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `psico`.`questionSort`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `psico`.`questionSort`()
BEGIN
UPDATE question
diff --git a/db/routines/psico/views/examView.sql b/db/routines/psico/views/examView.sql
index 1aa7689193..c8bc1a8ef3 100644
--- a/db/routines/psico/views/examView.sql
+++ b/db/routines/psico/views/examView.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `psico`.`examView`
AS SELECT `q`.`text` AS `text`,
diff --git a/db/routines/psico/views/results.sql b/db/routines/psico/views/results.sql
index 1d7945d32d..ad61099f37 100644
--- a/db/routines/psico/views/results.sql
+++ b/db/routines/psico/views/results.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `psico`.`results`
AS SELECT `eq`.`examFk` AS `examFk`,
diff --git a/db/routines/sage/functions/company_getCode.sql b/db/routines/sage/functions/company_getCode.sql
index bdb8c17fbf..412552086b 100644
--- a/db/routines/sage/functions/company_getCode.sql
+++ b/db/routines/sage/functions/company_getCode.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `sage`.`company_getCode`(vCompanyFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `sage`.`company_getCode`(vCompanyFk INT)
RETURNS int(2)
NOT DETERMINISTIC
READS SQL DATA
diff --git a/db/routines/sage/procedures/accountingMovements_add.sql b/db/routines/sage/procedures/accountingMovements_add.sql
index 060d89a3fb..229a105296 100644
--- a/db/routines/sage/procedures/accountingMovements_add.sql
+++ b/db/routines/sage/procedures/accountingMovements_add.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `sage`.`accountingMovements_add`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `sage`.`accountingMovements_add`(
vYear INT,
vCompanyFk INT
)
diff --git a/db/routines/sage/procedures/clean.sql b/db/routines/sage/procedures/clean.sql
index f1175c4dc6..9e52d787a8 100644
--- a/db/routines/sage/procedures/clean.sql
+++ b/db/routines/sage/procedures/clean.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `sage`.`clean`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `sage`.`clean`()
BEGIN
/**
* Maintains tables over time by removing unnecessary data
diff --git a/db/routines/sage/procedures/clientSupplier_add.sql b/db/routines/sage/procedures/clientSupplier_add.sql
index 2d1a518820..177b0a7cb1 100644
--- a/db/routines/sage/procedures/clientSupplier_add.sql
+++ b/db/routines/sage/procedures/clientSupplier_add.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `sage`.`clientSupplier_add`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `sage`.`clientSupplier_add`(
vCompanyFk INT
)
BEGIN
diff --git a/db/routines/sage/procedures/importErrorNotification.sql b/db/routines/sage/procedures/importErrorNotification.sql
index 75b0cffc87..1eae584e91 100644
--- a/db/routines/sage/procedures/importErrorNotification.sql
+++ b/db/routines/sage/procedures/importErrorNotification.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `sage`.`importErrorNotification`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `sage`.`importErrorNotification`()
BEGIN
/**
* Inserta notificaciones con los errores detectados durante la importación
diff --git a/db/routines/sage/procedures/invoiceIn_add.sql b/db/routines/sage/procedures/invoiceIn_add.sql
index 8fdbb9ce32..e91e337c7a 100644
--- a/db/routines/sage/procedures/invoiceIn_add.sql
+++ b/db/routines/sage/procedures/invoiceIn_add.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `sage`.`invoiceIn_add`(vInvoiceInFk INT, vXDiarioFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `sage`.`invoiceIn_add`(vInvoiceInFk INT, vXDiarioFk INT)
BEGIN
/**
* Traslada la info de contabilidad relacionada con las facturas recibidas
diff --git a/db/routines/sage/procedures/invoiceIn_manager.sql b/db/routines/sage/procedures/invoiceIn_manager.sql
index f9bf0e92fb..ba99ae9f2f 100644
--- a/db/routines/sage/procedures/invoiceIn_manager.sql
+++ b/db/routines/sage/procedures/invoiceIn_manager.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `sage`.`invoiceIn_manager`(vYear INT, vCompanyFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `sage`.`invoiceIn_manager`(vYear INT, vCompanyFk INT)
BEGIN
/**
* Traslada la info de contabilidad relacionada con las facturas recibidas
diff --git a/db/routines/sage/procedures/invoiceOut_add.sql b/db/routines/sage/procedures/invoiceOut_add.sql
index f9c6f6b87a..3b9643a36d 100644
--- a/db/routines/sage/procedures/invoiceOut_add.sql
+++ b/db/routines/sage/procedures/invoiceOut_add.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `sage`.`invoiceOut_add`(IN vInvoiceOutFk INT, IN vXDiarioFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `sage`.`invoiceOut_add`(IN vInvoiceOutFk INT, IN vXDiarioFk INT)
BEGIN
/**
* Traslada la info de contabilidad relacionada con las facturas emitidas
diff --git a/db/routines/sage/procedures/invoiceOut_manager.sql b/db/routines/sage/procedures/invoiceOut_manager.sql
index 58c0f2a213..cfacc330d7 100644
--- a/db/routines/sage/procedures/invoiceOut_manager.sql
+++ b/db/routines/sage/procedures/invoiceOut_manager.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `sage`.`invoiceOut_manager`(vYear INT, vCompanyFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `sage`.`invoiceOut_manager`(vYear INT, vCompanyFk INT)
BEGIN
/**
* Traslada la info de contabilidad relacionada con las facturas emitidas
diff --git a/db/routines/sage/procedures/pgc_add.sql b/db/routines/sage/procedures/pgc_add.sql
index 78d80a9fe4..67e3f59cd7 100644
--- a/db/routines/sage/procedures/pgc_add.sql
+++ b/db/routines/sage/procedures/pgc_add.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `sage`.`pgc_add`(vCompanyFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `sage`.`pgc_add`(vCompanyFk INT)
BEGIN
/**
* Añade cuentas del plan general contable para exportarlos a Sage
diff --git a/db/routines/sage/triggers/movConta_beforeUpdate.sql b/db/routines/sage/triggers/movConta_beforeUpdate.sql
index 316b28b7f8..f152ebe7f2 100644
--- a/db/routines/sage/triggers/movConta_beforeUpdate.sql
+++ b/db/routines/sage/triggers/movConta_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `sage`.`movConta_beforeUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `sage`.`movConta_beforeUpdate`
BEFORE UPDATE ON `movConta`
FOR EACH ROW
BEGIN
diff --git a/db/routines/sage/views/clientLastTwoMonths.sql b/db/routines/sage/views/clientLastTwoMonths.sql
index 059cb07800..24e85796b2 100644
--- a/db/routines/sage/views/clientLastTwoMonths.sql
+++ b/db/routines/sage/views/clientLastTwoMonths.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `sage`.`clientLastTwoMonths`
AS SELECT `vn`.`invoiceOut`.`clientFk` AS `clientFk`,
diff --git a/db/routines/sage/views/supplierLastThreeMonths.sql b/db/routines/sage/views/supplierLastThreeMonths.sql
index f841fd98cc..8fff1d42c7 100644
--- a/db/routines/sage/views/supplierLastThreeMonths.sql
+++ b/db/routines/sage/views/supplierLastThreeMonths.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `sage`.`supplierLastThreeMonths`
AS SELECT `vn`.`invoiceIn`.`supplierFk` AS `supplierFk`,
diff --git a/db/routines/salix/events/accessToken_prune.sql b/db/routines/salix/events/accessToken_prune.sql
index 28b04699f6..adcbb23019 100644
--- a/db/routines/salix/events/accessToken_prune.sql
+++ b/db/routines/salix/events/accessToken_prune.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `salix`.`accessToken_prune`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `salix`.`accessToken_prune`
ON SCHEDULE EVERY 1 DAY
STARTS '2023-03-14 05:14:00.000'
ON COMPLETION PRESERVE
diff --git a/db/routines/salix/procedures/accessToken_prune.sql b/db/routines/salix/procedures/accessToken_prune.sql
index f1a8a0fe8e..06ccbe96a1 100644
--- a/db/routines/salix/procedures/accessToken_prune.sql
+++ b/db/routines/salix/procedures/accessToken_prune.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `salix`.`accessToken_prune`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `salix`.`accessToken_prune`()
BEGIN
/**
* Borra de la tabla salix.AccessToken todos aquellos tokens que hayan caducado
diff --git a/db/routines/salix/triggers/ACL_afterDelete.sql b/db/routines/salix/triggers/ACL_afterDelete.sql
index b7e6071fc2..3528a87477 100644
--- a/db/routines/salix/triggers/ACL_afterDelete.sql
+++ b/db/routines/salix/triggers/ACL_afterDelete.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `salix`.`ACL_afterDelete`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `salix`.`ACL_afterDelete`
AFTER DELETE ON `ACL`
FOR EACH ROW
BEGIN
diff --git a/db/routines/salix/triggers/ACL_beforeInsert.sql b/db/routines/salix/triggers/ACL_beforeInsert.sql
index cb0b5761b2..953ddfba1b 100644
--- a/db/routines/salix/triggers/ACL_beforeInsert.sql
+++ b/db/routines/salix/triggers/ACL_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `salix`.`ACL_beforeInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `salix`.`ACL_beforeInsert`
BEFORE INSERT ON `ACL`
FOR EACH ROW
BEGIN
diff --git a/db/routines/salix/triggers/ACL_beforeUpdate.sql b/db/routines/salix/triggers/ACL_beforeUpdate.sql
index b214fc9f63..006a91ae93 100644
--- a/db/routines/salix/triggers/ACL_beforeUpdate.sql
+++ b/db/routines/salix/triggers/ACL_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `salix`.`ACL_beforeUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `salix`.`ACL_beforeUpdate`
BEFORE UPDATE ON `ACL`
FOR EACH ROW
BEGIN
diff --git a/db/routines/salix/views/Account.sql b/db/routines/salix/views/Account.sql
index 080e3e50b4..0b75ab6204 100644
--- a/db/routines/salix/views/Account.sql
+++ b/db/routines/salix/views/Account.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `salix`.`Account`
AS SELECT `u`.`id` AS `id`,
diff --git a/db/routines/salix/views/Role.sql b/db/routines/salix/views/Role.sql
index b04ad82a6b..8fcd7c6bef 100644
--- a/db/routines/salix/views/Role.sql
+++ b/db/routines/salix/views/Role.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `salix`.`Role`
AS SELECT `r`.`id` AS `id`,
diff --git a/db/routines/salix/views/RoleMapping.sql b/db/routines/salix/views/RoleMapping.sql
index 48500a05ed..834ec07279 100644
--- a/db/routines/salix/views/RoleMapping.sql
+++ b/db/routines/salix/views/RoleMapping.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `salix`.`RoleMapping`
AS SELECT `u`.`id` * 1000 + `r`.`inheritsFrom` AS `id`,
diff --git a/db/routines/salix/views/User.sql b/db/routines/salix/views/User.sql
index e03803870e..b7536d6b17 100644
--- a/db/routines/salix/views/User.sql
+++ b/db/routines/salix/views/User.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `salix`.`User`
AS SELECT `account`.`user`.`id` AS `id`,
diff --git a/db/routines/srt/events/moving_clean.sql b/db/routines/srt/events/moving_clean.sql
index 18644a9f8a..17490609a1 100644
--- a/db/routines/srt/events/moving_clean.sql
+++ b/db/routines/srt/events/moving_clean.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `srt`.`moving_clean`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `srt`.`moving_clean`
ON SCHEDULE EVERY 15 MINUTE
STARTS '2022-01-21 00:00:00.000'
ON COMPLETION PRESERVE
diff --git a/db/routines/srt/functions/bid.sql b/db/routines/srt/functions/bid.sql
index ee4ffc7d3f..84e30ed115 100644
--- a/db/routines/srt/functions/bid.sql
+++ b/db/routines/srt/functions/bid.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `srt`.`bid`(vCode VARCHAR(3))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `srt`.`bid`(vCode VARCHAR(3))
RETURNS int(11)
DETERMINISTIC
BEGIN
diff --git a/db/routines/srt/functions/bufferPool_get.sql b/db/routines/srt/functions/bufferPool_get.sql
index 1576381f58..f3e9d2596d 100644
--- a/db/routines/srt/functions/bufferPool_get.sql
+++ b/db/routines/srt/functions/bufferPool_get.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `srt`.`bufferPool_get`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `srt`.`bufferPool_get`()
RETURNS int(11)
NOT DETERMINISTIC
READS SQL DATA
diff --git a/db/routines/srt/functions/buffer_get.sql b/db/routines/srt/functions/buffer_get.sql
index 55150bd991..b666548394 100644
--- a/db/routines/srt/functions/buffer_get.sql
+++ b/db/routines/srt/functions/buffer_get.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `srt`.`buffer_get`(vExpeditionFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `srt`.`buffer_get`(vExpeditionFk INT)
RETURNS int(11)
NOT DETERMINISTIC
READS SQL DATA
diff --git a/db/routines/srt/functions/buffer_getRandom.sql b/db/routines/srt/functions/buffer_getRandom.sql
index bc7229594d..12134c1e3c 100644
--- a/db/routines/srt/functions/buffer_getRandom.sql
+++ b/db/routines/srt/functions/buffer_getRandom.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `srt`.`buffer_getRandom`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `srt`.`buffer_getRandom`()
RETURNS int(11)
NOT DETERMINISTIC
READS SQL DATA
diff --git a/db/routines/srt/functions/buffer_getState.sql b/db/routines/srt/functions/buffer_getState.sql
index b5c4ac2e4e..79d4551382 100644
--- a/db/routines/srt/functions/buffer_getState.sql
+++ b/db/routines/srt/functions/buffer_getState.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `srt`.`buffer_getState`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `srt`.`buffer_getState`(vSelf INT)
RETURNS varchar(20) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci
NOT DETERMINISTIC
READS SQL DATA
diff --git a/db/routines/srt/functions/buffer_getType.sql b/db/routines/srt/functions/buffer_getType.sql
index 4b4194b3c2..0db73a0d3e 100644
--- a/db/routines/srt/functions/buffer_getType.sql
+++ b/db/routines/srt/functions/buffer_getType.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `srt`.`buffer_getType`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `srt`.`buffer_getType`(vSelf INT)
RETURNS varchar(20) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci
NOT DETERMINISTIC
READS SQL DATA
diff --git a/db/routines/srt/functions/buffer_isFull.sql b/db/routines/srt/functions/buffer_isFull.sql
index a1ae08484e..b404a60d6f 100644
--- a/db/routines/srt/functions/buffer_isFull.sql
+++ b/db/routines/srt/functions/buffer_isFull.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `srt`.`buffer_isFull`(vBufferFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `srt`.`buffer_isFull`(vBufferFk INT)
RETURNS tinyint(1)
NOT DETERMINISTIC
READS SQL DATA
diff --git a/db/routines/srt/functions/dayMinute.sql b/db/routines/srt/functions/dayMinute.sql
index ab66dd7d23..a103678630 100644
--- a/db/routines/srt/functions/dayMinute.sql
+++ b/db/routines/srt/functions/dayMinute.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `srt`.`dayMinute`(vDateTime DATETIME)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `srt`.`dayMinute`(vDateTime DATETIME)
RETURNS int(11)
NOT DETERMINISTIC
READS SQL DATA
diff --git a/db/routines/srt/functions/expedition_check.sql b/db/routines/srt/functions/expedition_check.sql
index 314cafd96c..948ef449a3 100644
--- a/db/routines/srt/functions/expedition_check.sql
+++ b/db/routines/srt/functions/expedition_check.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `srt`.`expedition_check`(vExpeditionFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `srt`.`expedition_check`(vExpeditionFk INT)
RETURNS int(11)
NOT DETERMINISTIC
READS SQL DATA
diff --git a/db/routines/srt/functions/expedition_getDayMinute.sql b/db/routines/srt/functions/expedition_getDayMinute.sql
index 01ff534f57..1882dec0fd 100644
--- a/db/routines/srt/functions/expedition_getDayMinute.sql
+++ b/db/routines/srt/functions/expedition_getDayMinute.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `srt`.`expedition_getDayMinute`(vExpeditionFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `srt`.`expedition_getDayMinute`(vExpeditionFk INT)
RETURNS int(11)
NOT DETERMINISTIC
READS SQL DATA
diff --git a/db/routines/srt/procedures/buffer_getExpCount.sql b/db/routines/srt/procedures/buffer_getExpCount.sql
index 5ead3d4213..d01feee79e 100644
--- a/db/routines/srt/procedures/buffer_getExpCount.sql
+++ b/db/routines/srt/procedures/buffer_getExpCount.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`buffer_getExpCount`(IN vBufferFk INT, OUT vExpCount INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`buffer_getExpCount`(IN vBufferFk INT, OUT vExpCount INT)
BEGIN
/* Devuelve el número de expediciones de un buffer
*
diff --git a/db/routines/srt/procedures/buffer_getStateType.sql b/db/routines/srt/procedures/buffer_getStateType.sql
index bba8202db0..4140cb3a63 100644
--- a/db/routines/srt/procedures/buffer_getStateType.sql
+++ b/db/routines/srt/procedures/buffer_getStateType.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`buffer_getStateType`(vBufferFk INT, OUT vStateFk INT, OUT vTypeFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`buffer_getStateType`(vBufferFk INT, OUT vStateFk INT, OUT vTypeFk INT)
BEGIN
/**
diff --git a/db/routines/srt/procedures/buffer_giveBack.sql b/db/routines/srt/procedures/buffer_giveBack.sql
index f8d3499144..755951e7ba 100644
--- a/db/routines/srt/procedures/buffer_giveBack.sql
+++ b/db/routines/srt/procedures/buffer_giveBack.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`buffer_giveBack`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`buffer_giveBack`(vSelf INT)
BEGIN
/* Devuelve una caja al celluveyor *
diff --git a/db/routines/srt/procedures/buffer_readPhotocell.sql b/db/routines/srt/procedures/buffer_readPhotocell.sql
index 2bf2cfa1dc..e2e1af8bbb 100644
--- a/db/routines/srt/procedures/buffer_readPhotocell.sql
+++ b/db/routines/srt/procedures/buffer_readPhotocell.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`buffer_readPhotocell`(vSelf INT, vNumber INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`buffer_readPhotocell`(vSelf INT, vNumber INT)
BEGIN
/**
* Establece el estado de un buffer en función del número de fotocélulas activas
diff --git a/db/routines/srt/procedures/buffer_setEmpty.sql b/db/routines/srt/procedures/buffer_setEmpty.sql
index e97d397ed8..776b25310b 100644
--- a/db/routines/srt/procedures/buffer_setEmpty.sql
+++ b/db/routines/srt/procedures/buffer_setEmpty.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`buffer_setEmpty`(vBufferFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`buffer_setEmpty`(vBufferFk INT)
BEGIN
/**
diff --git a/db/routines/srt/procedures/buffer_setState.sql b/db/routines/srt/procedures/buffer_setState.sql
index f0f1369425..3ac3c60da6 100644
--- a/db/routines/srt/procedures/buffer_setState.sql
+++ b/db/routines/srt/procedures/buffer_setState.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`buffer_setState`(vBufferFk INT(11), vStateFk INT(11))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`buffer_setState`(vBufferFk INT(11), vStateFk INT(11))
BEGIN
/**
diff --git a/db/routines/srt/procedures/buffer_setStateType.sql b/db/routines/srt/procedures/buffer_setStateType.sql
index 954a380acd..a9f66509e4 100644
--- a/db/routines/srt/procedures/buffer_setStateType.sql
+++ b/db/routines/srt/procedures/buffer_setStateType.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`buffer_setStateType`(vBufferFk INT, vState VARCHAR(25), vType VARCHAR(25))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`buffer_setStateType`(vBufferFk INT, vState VARCHAR(25), vType VARCHAR(25))
BEGIN
/**
diff --git a/db/routines/srt/procedures/buffer_setType.sql b/db/routines/srt/procedures/buffer_setType.sql
index 7d6c508dc4..b880262dd7 100644
--- a/db/routines/srt/procedures/buffer_setType.sql
+++ b/db/routines/srt/procedures/buffer_setType.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`buffer_setType`(vBufferFk INT(11), vTypeFk INT(11))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`buffer_setType`(vBufferFk INT(11), vTypeFk INT(11))
BEGIN
/**
* Cambia el tipo de un buffer, si está permitido
diff --git a/db/routines/srt/procedures/buffer_setTypeByName.sql b/db/routines/srt/procedures/buffer_setTypeByName.sql
index 9365d53992..ad6caff42b 100644
--- a/db/routines/srt/procedures/buffer_setTypeByName.sql
+++ b/db/routines/srt/procedures/buffer_setTypeByName.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`buffer_setTypeByName`(vBufferFk INT(11), vTypeName VARCHAR(100))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`buffer_setTypeByName`(vBufferFk INT(11), vTypeName VARCHAR(100))
BEGIN
/**
diff --git a/db/routines/srt/procedures/clean.sql b/db/routines/srt/procedures/clean.sql
index 3d02ae0cd8..3e90533004 100644
--- a/db/routines/srt/procedures/clean.sql
+++ b/db/routines/srt/procedures/clean.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`clean`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`clean`()
BEGIN
DECLARE vLastDated DATE DEFAULT TIMESTAMPADD(WEEK,-2,util.VN_CURDATE());
diff --git a/db/routines/srt/procedures/expeditionLoading_add.sql b/db/routines/srt/procedures/expeditionLoading_add.sql
index 7fb53c2c60..bb68e395cb 100644
--- a/db/routines/srt/procedures/expeditionLoading_add.sql
+++ b/db/routines/srt/procedures/expeditionLoading_add.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`expeditionLoading_add`(vExpeditionFk INT, vBufferFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`expeditionLoading_add`(vExpeditionFk INT, vBufferFk INT)
BEGIN
DECLARE vMessage VARCHAR(50) DEFAULT '';
diff --git a/db/routines/srt/procedures/expedition_arrived.sql b/db/routines/srt/procedures/expedition_arrived.sql
index 2d2c093bc2..03108e90d8 100644
--- a/db/routines/srt/procedures/expedition_arrived.sql
+++ b/db/routines/srt/procedures/expedition_arrived.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`expedition_arrived`(vExpeditionFk INT, vBufferFk INT, OUT vTypeFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`expedition_arrived`(vExpeditionFk INT, vBufferFk INT, OUT vTypeFk INT)
BEGIN
/**
* La expedición ha entrado en un buffer, superando fc2
diff --git a/db/routines/srt/procedures/expedition_bufferOut.sql b/db/routines/srt/procedures/expedition_bufferOut.sql
index 69e1fb7919..56d32614b9 100644
--- a/db/routines/srt/procedures/expedition_bufferOut.sql
+++ b/db/routines/srt/procedures/expedition_bufferOut.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`expedition_bufferOut`(vBufferToFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`expedition_bufferOut`(vBufferToFk INT)
BEGIN
/**
diff --git a/db/routines/srt/procedures/expedition_entering.sql b/db/routines/srt/procedures/expedition_entering.sql
index f1b773edb2..2eab7d0e05 100644
--- a/db/routines/srt/procedures/expedition_entering.sql
+++ b/db/routines/srt/procedures/expedition_entering.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`expedition_entering`(vExpeditionFk INT, OUT vExpeditionOutFk INT )
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`expedition_entering`(vExpeditionFk INT, OUT vExpeditionOutFk INT )
BEGIN
/**
diff --git a/db/routines/srt/procedures/expedition_get.sql b/db/routines/srt/procedures/expedition_get.sql
index 91a0e2ace1..d0edd4b159 100644
--- a/db/routines/srt/procedures/expedition_get.sql
+++ b/db/routines/srt/procedures/expedition_get.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`expedition_get`(vAntennaFk INT, OUT vExpeditionOutFk INT )
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`expedition_get`(vAntennaFk INT, OUT vExpeditionOutFk INT )
BEGIN
DECLARE vId INT;
diff --git a/db/routines/srt/procedures/expedition_groupOut.sql b/db/routines/srt/procedures/expedition_groupOut.sql
index 5c4540ff6d..3400492381 100644
--- a/db/routines/srt/procedures/expedition_groupOut.sql
+++ b/db/routines/srt/procedures/expedition_groupOut.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`expedition_groupOut`(vDayMinute INT, vBufferToFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`expedition_groupOut`(vDayMinute INT, vBufferToFk INT)
BEGIN
/**
diff --git a/db/routines/srt/procedures/expedition_in.sql b/db/routines/srt/procedures/expedition_in.sql
index c6f75876cd..ca783e78ff 100644
--- a/db/routines/srt/procedures/expedition_in.sql
+++ b/db/routines/srt/procedures/expedition_in.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`expedition_in`(vBufferFk INT, OUT vExpeditionFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`expedition_in`(vBufferFk INT, OUT vExpeditionFk INT)
proc:BEGIN
/**
diff --git a/db/routines/srt/procedures/expedition_moving.sql b/db/routines/srt/procedures/expedition_moving.sql
index 1277ed2bde..095c5f6b1a 100644
--- a/db/routines/srt/procedures/expedition_moving.sql
+++ b/db/routines/srt/procedures/expedition_moving.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`expedition_moving`(vBufferFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`expedition_moving`(vBufferFk INT)
BEGIN
/**
diff --git a/db/routines/srt/procedures/expedition_out.sql b/db/routines/srt/procedures/expedition_out.sql
index 5e66085615..7c5bb85268 100644
--- a/db/routines/srt/procedures/expedition_out.sql
+++ b/db/routines/srt/procedures/expedition_out.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`expedition_out`(vBufferFk INT, OUT vTypeFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`expedition_out`(vBufferFk INT, OUT vTypeFk INT)
proc:BEGIN
/**
* Una expedición ha salido de un buffer por el extremo distal
diff --git a/db/routines/srt/procedures/expedition_outAll.sql b/db/routines/srt/procedures/expedition_outAll.sql
index ffe925c9dc..109ddc8174 100644
--- a/db/routines/srt/procedures/expedition_outAll.sql
+++ b/db/routines/srt/procedures/expedition_outAll.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`expedition_outAll`(vBufferFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`expedition_outAll`(vBufferFk INT)
BEGIN
/**
diff --git a/db/routines/srt/procedures/expedition_relocate.sql b/db/routines/srt/procedures/expedition_relocate.sql
index 0f940beff6..8a5e41ca92 100644
--- a/db/routines/srt/procedures/expedition_relocate.sql
+++ b/db/routines/srt/procedures/expedition_relocate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`expedition_relocate`(vExpeditionFk INT, vBufferToFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`expedition_relocate`(vExpeditionFk INT, vBufferToFk INT)
proc:BEGIN
/**
diff --git a/db/routines/srt/procedures/expedition_reset.sql b/db/routines/srt/procedures/expedition_reset.sql
index 153edfad22..fd76981456 100644
--- a/db/routines/srt/procedures/expedition_reset.sql
+++ b/db/routines/srt/procedures/expedition_reset.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`expedition_reset`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`expedition_reset`()
BEGIN
DELETE FROM srt.moving;
diff --git a/db/routines/srt/procedures/expedition_routeOut.sql b/db/routines/srt/procedures/expedition_routeOut.sql
index d40384e1f0..325a6bb944 100644
--- a/db/routines/srt/procedures/expedition_routeOut.sql
+++ b/db/routines/srt/procedures/expedition_routeOut.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`expedition_routeOut`(vRouteFk INT, vBufferToFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`expedition_routeOut`(vRouteFk INT, vBufferToFk INT)
BEGIN
/**
diff --git a/db/routines/srt/procedures/expedition_scan.sql b/db/routines/srt/procedures/expedition_scan.sql
index e3fcfddef4..81caa4befb 100644
--- a/db/routines/srt/procedures/expedition_scan.sql
+++ b/db/routines/srt/procedures/expedition_scan.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`expedition_scan`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`expedition_scan`(vSelf INT)
BEGIN
/* Actualiza el estado de una expedicion a OUT, al ser escaneada manualmente
diff --git a/db/routines/srt/procedures/expedition_setDimensions.sql b/db/routines/srt/procedures/expedition_setDimensions.sql
index 0b4fea28fe..fba5f373cb 100644
--- a/db/routines/srt/procedures/expedition_setDimensions.sql
+++ b/db/routines/srt/procedures/expedition_setDimensions.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`expedition_setDimensions`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`expedition_setDimensions`(
vExpeditionFk INT,
vWeight DECIMAL(10,2),
vLength INT,
diff --git a/db/routines/srt/procedures/expedition_weighing.sql b/db/routines/srt/procedures/expedition_weighing.sql
index bb35edb274..3722125496 100644
--- a/db/routines/srt/procedures/expedition_weighing.sql
+++ b/db/routines/srt/procedures/expedition_weighing.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`expedition_weighing`(vWeight DECIMAL(10,2), vExpeditionFk INT, OUT vExpeditionOutFk INT )
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`expedition_weighing`(vWeight DECIMAL(10,2), vExpeditionFk INT, OUT vExpeditionOutFk INT )
BEGIN
/**
diff --git a/db/routines/srt/procedures/failureLog_add.sql b/db/routines/srt/procedures/failureLog_add.sql
index b572e85036..5ca49a2e05 100644
--- a/db/routines/srt/procedures/failureLog_add.sql
+++ b/db/routines/srt/procedures/failureLog_add.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`failureLog_add`(vDescription VARCHAR(100))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`failureLog_add`(vDescription VARCHAR(100))
BEGIN
/* Añade un registro a srt.failureLog
diff --git a/db/routines/srt/procedures/lastRFID_add.sql b/db/routines/srt/procedures/lastRFID_add.sql
index ec3c83d983..704e1baa86 100644
--- a/db/routines/srt/procedures/lastRFID_add.sql
+++ b/db/routines/srt/procedures/lastRFID_add.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`lastRFID_add`(vCode VARCHAR(20), vAntennaFk INT, vAntennaPortFk INT, vPeakRssi INT, vSeenCount INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`lastRFID_add`(vCode VARCHAR(20), vAntennaFk INT, vAntennaPortFk INT, vPeakRssi INT, vSeenCount INT)
BEGIN
/* Insert a new record in lastRFID table
diff --git a/db/routines/srt/procedures/lastRFID_add_beta.sql b/db/routines/srt/procedures/lastRFID_add_beta.sql
index bbeb32410e..01ad90affe 100644
--- a/db/routines/srt/procedures/lastRFID_add_beta.sql
+++ b/db/routines/srt/procedures/lastRFID_add_beta.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`lastRFID_add_beta`(vCode VARCHAR(20), vAntennaFk INT, vAntennaPortFk INT, vPeakRssi INT, vSeenCount INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`lastRFID_add_beta`(vCode VARCHAR(20), vAntennaFk INT, vAntennaPortFk INT, vPeakRssi INT, vSeenCount INT)
BEGIN
/* Insert a new record in lastRFID table
diff --git a/db/routines/srt/procedures/moving_CollidingSet.sql b/db/routines/srt/procedures/moving_CollidingSet.sql
index 69c4f9d9e9..bfaca4bbf5 100644
--- a/db/routines/srt/procedures/moving_CollidingSet.sql
+++ b/db/routines/srt/procedures/moving_CollidingSet.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`moving_CollidingSet`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`moving_CollidingSet`()
BEGIN
diff --git a/db/routines/srt/procedures/moving_between.sql b/db/routines/srt/procedures/moving_between.sql
index 41822d3418..ccb54353fe 100644
--- a/db/routines/srt/procedures/moving_between.sql
+++ b/db/routines/srt/procedures/moving_between.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`moving_between`(vBufferA INT, vBufferB INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`moving_between`(vBufferA INT, vBufferB INT)
BEGIN
DECLARE vExpeditionFk INT;
diff --git a/db/routines/srt/procedures/moving_clean.sql b/db/routines/srt/procedures/moving_clean.sql
index a5bbc7e70f..2380d17098 100644
--- a/db/routines/srt/procedures/moving_clean.sql
+++ b/db/routines/srt/procedures/moving_clean.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`moving_clean`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`moving_clean`()
BEGIN
/**
* Elimina movimientos por inactividad
diff --git a/db/routines/srt/procedures/moving_delete.sql b/db/routines/srt/procedures/moving_delete.sql
index 38491105af..926b4b5953 100644
--- a/db/routines/srt/procedures/moving_delete.sql
+++ b/db/routines/srt/procedures/moving_delete.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`moving_delete`(vExpeditionFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`moving_delete`(vExpeditionFk INT)
BEGIN
/* Elimina un movimiento
diff --git a/db/routines/srt/procedures/moving_groupOut.sql b/db/routines/srt/procedures/moving_groupOut.sql
index d901f0ca9f..28556d20df 100644
--- a/db/routines/srt/procedures/moving_groupOut.sql
+++ b/db/routines/srt/procedures/moving_groupOut.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`moving_groupOut`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`moving_groupOut`()
proc: BEGIN
DECLARE vDayMinute INT;
diff --git a/db/routines/srt/procedures/moving_next.sql b/db/routines/srt/procedures/moving_next.sql
index 6c76b8373d..75270aed10 100644
--- a/db/routines/srt/procedures/moving_next.sql
+++ b/db/routines/srt/procedures/moving_next.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`moving_next`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`moving_next`()
BEGIN
DECLARE vExpeditionFk INT;
diff --git a/db/routines/srt/procedures/photocell_setActive.sql b/db/routines/srt/procedures/photocell_setActive.sql
index c89e9dc9da..63858a83c5 100644
--- a/db/routines/srt/procedures/photocell_setActive.sql
+++ b/db/routines/srt/procedures/photocell_setActive.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`photocell_setActive`(vBufferFk int, vPosition int, vIsActive bool)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`photocell_setActive`(vBufferFk int, vPosition int, vIsActive bool)
BEGIN
REPLACE srt.photocell VALUES (vbufferFk, vPosition, vIsActive);
END$$
diff --git a/db/routines/srt/procedures/randomMoving.sql b/db/routines/srt/procedures/randomMoving.sql
index b4bdd6591b..01a9eaca46 100644
--- a/db/routines/srt/procedures/randomMoving.sql
+++ b/db/routines/srt/procedures/randomMoving.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`randomMoving`(vBufferMin INT, vBufferMax INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`randomMoving`(vBufferMin INT, vBufferMax INT)
BEGIN
DECLARE vBufferOld INT DEFAULT 0;
DECLARE vBufferFk INT;
diff --git a/db/routines/srt/procedures/randomMoving_Launch.sql b/db/routines/srt/procedures/randomMoving_Launch.sql
index 031e548732..84003a50a9 100644
--- a/db/routines/srt/procedures/randomMoving_Launch.sql
+++ b/db/routines/srt/procedures/randomMoving_Launch.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`randomMoving_Launch`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`randomMoving_Launch`()
BEGIN
DECLARE i INT DEFAULT 5;
diff --git a/db/routines/srt/procedures/restart.sql b/db/routines/srt/procedures/restart.sql
index 96adb3bfa9..41871863c5 100644
--- a/db/routines/srt/procedures/restart.sql
+++ b/db/routines/srt/procedures/restart.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`restart`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`restart`()
BEGIN
/*
diff --git a/db/routines/srt/procedures/start.sql b/db/routines/srt/procedures/start.sql
index 8e5250796c..51a0a300b8 100644
--- a/db/routines/srt/procedures/start.sql
+++ b/db/routines/srt/procedures/start.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`start`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`start`()
BEGIN
/*
diff --git a/db/routines/srt/procedures/stop.sql b/db/routines/srt/procedures/stop.sql
index a6fd12bb2e..d649412aa7 100644
--- a/db/routines/srt/procedures/stop.sql
+++ b/db/routines/srt/procedures/stop.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`stop`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`stop`()
BEGIN
/*
diff --git a/db/routines/srt/procedures/test.sql b/db/routines/srt/procedures/test.sql
index 59a76eb818..571e415f29 100644
--- a/db/routines/srt/procedures/test.sql
+++ b/db/routines/srt/procedures/test.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`test`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`test`()
BEGIN
SELECT 'procedimiento ejecutado con éxito';
diff --git a/db/routines/srt/triggers/buffer_afterDelete.sql b/db/routines/srt/triggers/buffer_afterDelete.sql
index d554e63647..bb92687dd9 100644
--- a/db/routines/srt/triggers/buffer_afterDelete.sql
+++ b/db/routines/srt/triggers/buffer_afterDelete.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `srt`.`buffer_afterDelete`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `srt`.`buffer_afterDelete`
AFTER DELETE ON `buffer`
FOR EACH ROW
BEGIN
diff --git a/db/routines/srt/triggers/buffer_beforeInsert.sql b/db/routines/srt/triggers/buffer_beforeInsert.sql
index 6b1e05362c..9a13dde964 100644
--- a/db/routines/srt/triggers/buffer_beforeInsert.sql
+++ b/db/routines/srt/triggers/buffer_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `srt`.`buffer_beforeInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `srt`.`buffer_beforeInsert`
BEFORE INSERT ON `buffer`
FOR EACH ROW
BEGIN
diff --git a/db/routines/srt/triggers/buffer_beforeUpdate.sql b/db/routines/srt/triggers/buffer_beforeUpdate.sql
index 86418a5510..ed6727855e 100644
--- a/db/routines/srt/triggers/buffer_beforeUpdate.sql
+++ b/db/routines/srt/triggers/buffer_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `srt`.`buffer_beforeUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `srt`.`buffer_beforeUpdate`
BEFORE UPDATE ON `buffer`
FOR EACH ROW
BEGIN
diff --git a/db/routines/srt/triggers/config_afterDelete.sql b/db/routines/srt/triggers/config_afterDelete.sql
index 1e4af91047..e07925f3e5 100644
--- a/db/routines/srt/triggers/config_afterDelete.sql
+++ b/db/routines/srt/triggers/config_afterDelete.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `srt`.`config_afterDelete`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `srt`.`config_afterDelete`
AFTER DELETE ON `config`
FOR EACH ROW
BEGIN
diff --git a/db/routines/srt/triggers/config_beforeInsert.sql b/db/routines/srt/triggers/config_beforeInsert.sql
index 7d83896463..59819654ea 100644
--- a/db/routines/srt/triggers/config_beforeInsert.sql
+++ b/db/routines/srt/triggers/config_beforeInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `srt`.`config_beforeInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `srt`.`config_beforeInsert`
BEFORE INSERT ON `config`
FOR EACH ROW
BEGIN
diff --git a/db/routines/srt/triggers/config_beforeUpdate.sql b/db/routines/srt/triggers/config_beforeUpdate.sql
index 0002fb4d63..bd7faaf421 100644
--- a/db/routines/srt/triggers/config_beforeUpdate.sql
+++ b/db/routines/srt/triggers/config_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `srt`.`config_beforeUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `srt`.`config_beforeUpdate`
BEFORE UPDATE ON `config`
FOR EACH ROW
BEGIN
diff --git a/db/routines/srt/triggers/expedition_beforeUpdate.sql b/db/routines/srt/triggers/expedition_beforeUpdate.sql
index b8933aaf51..335c69bab1 100644
--- a/db/routines/srt/triggers/expedition_beforeUpdate.sql
+++ b/db/routines/srt/triggers/expedition_beforeUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `srt`.`expedition_beforeUpdate`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `srt`.`expedition_beforeUpdate`
BEFORE UPDATE ON `expedition`
FOR EACH ROW
BEGIN
diff --git a/db/routines/srt/triggers/moving_afterInsert.sql b/db/routines/srt/triggers/moving_afterInsert.sql
index aaa09c99c4..dcf8a977ef 100644
--- a/db/routines/srt/triggers/moving_afterInsert.sql
+++ b/db/routines/srt/triggers/moving_afterInsert.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `srt`.`moving_afterInsert`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `srt`.`moving_afterInsert`
AFTER INSERT ON `moving`
FOR EACH ROW
BEGIN
diff --git a/db/routines/srt/views/bufferDayMinute.sql b/db/routines/srt/views/bufferDayMinute.sql
index d2108e513b..0156b74f56 100644
--- a/db/routines/srt/views/bufferDayMinute.sql
+++ b/db/routines/srt/views/bufferDayMinute.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `srt`.`bufferDayMinute`
AS SELECT `b`.`id` AS `bufferFk`,
diff --git a/db/routines/srt/views/bufferFreeLength.sql b/db/routines/srt/views/bufferFreeLength.sql
index 4edf1db471..7035220a0e 100644
--- a/db/routines/srt/views/bufferFreeLength.sql
+++ b/db/routines/srt/views/bufferFreeLength.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `srt`.`bufferFreeLength`
AS SELECT cast(`b`.`id` AS decimal(10, 0)) AS `bufferFk`,
diff --git a/db/routines/srt/views/bufferStock.sql b/db/routines/srt/views/bufferStock.sql
index ca04d3c012..dd0b2f1c2a 100644
--- a/db/routines/srt/views/bufferStock.sql
+++ b/db/routines/srt/views/bufferStock.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `srt`.`bufferStock`
AS SELECT `e`.`id` AS `expeditionFk`,
diff --git a/db/routines/srt/views/routePalletized.sql b/db/routines/srt/views/routePalletized.sql
index 15b493c6a0..05113242a3 100644
--- a/db/routines/srt/views/routePalletized.sql
+++ b/db/routines/srt/views/routePalletized.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `srt`.`routePalletized`
AS SELECT `t`.`routeFk` AS `routeFk`,
diff --git a/db/routines/srt/views/ticketPalletized.sql b/db/routines/srt/views/ticketPalletized.sql
index 04ac24291e..812e3659e0 100644
--- a/db/routines/srt/views/ticketPalletized.sql
+++ b/db/routines/srt/views/ticketPalletized.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `srt`.`ticketPalletized`
AS SELECT `t`.`id` AS `ticketFk`,
diff --git a/db/routines/srt/views/upperStickers.sql b/db/routines/srt/views/upperStickers.sql
index 1cd72c12bd..fff8890f55 100644
--- a/db/routines/srt/views/upperStickers.sql
+++ b/db/routines/srt/views/upperStickers.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `srt`.`upperStickers`
AS SELECT `e`.`id` AS `expeditionFk`,
diff --git a/db/routines/stock/events/log_clean.sql b/db/routines/stock/events/log_clean.sql
deleted file mode 100644
index 973561a89c..0000000000
--- a/db/routines/stock/events/log_clean.sql
+++ /dev/null
@@ -1,8 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `stock`.`log_clean`
- ON SCHEDULE EVERY 1 DAY
- STARTS '2022-01-28 09:29:18.000'
- ON COMPLETION PRESERVE
- ENABLE
-DO CALL log_clean$$
-DELIMITER ;
diff --git a/db/routines/stock/events/log_syncNoWait.sql b/db/routines/stock/events/log_syncNoWait.sql
deleted file mode 100644
index 954d372193..0000000000
--- a/db/routines/stock/events/log_syncNoWait.sql
+++ /dev/null
@@ -1,8 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `stock`.`log_syncNoWait`
- ON SCHEDULE EVERY 5 SECOND
- STARTS '2017-06-27 17:15:02.000'
- ON COMPLETION NOT PRESERVE
- DISABLE
-DO CALL log_syncNoWait$$
-DELIMITER ;
diff --git a/db/routines/stock/events/stock_clean.sql b/db/routines/stock/events/stock_clean.sql
new file mode 100644
index 0000000000..86f8a15fc8
--- /dev/null
+++ b/db/routines/stock/events/stock_clean.sql
@@ -0,0 +1,8 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `stock`.`stock_clean`
+ ON SCHEDULE EVERY 60 SECOND
+ STARTS '2025-01-01 00:00:00.000'
+ ON COMPLETION PRESERVE
+ ENABLE
+DO CALL stock_clean$$
+DELIMITER ;
diff --git a/db/routines/stock/events/stock_sync.sql b/db/routines/stock/events/stock_sync.sql
new file mode 100644
index 0000000000..d598cfc81a
--- /dev/null
+++ b/db/routines/stock/events/stock_sync.sql
@@ -0,0 +1,8 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `stock`.`stock_sync`
+ ON SCHEDULE EVERY 5 SECOND
+ STARTS '2025-01-01 00:00:00.000'
+ ON COMPLETION PRESERVE
+ DISABLE
+DO CALL stock_sync$$
+DELIMITER ;
diff --git a/db/routines/stock/procedures/buyLot_refresh.sql b/db/routines/stock/procedures/buyLot_refresh.sql
new file mode 100644
index 0000000000..dcfcd4bb8c
--- /dev/null
+++ b/db/routines/stock/procedures/buyLot_refresh.sql
@@ -0,0 +1,91 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `stock`.`buyLot_refresh`(
+ `vTable` ENUM('lot', 'entry', 'travel'),
+ `vId` INT)
+BEGIN
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ ROLLBACK;
+ RESIGNAL;
+ END;
+
+ CREATE OR REPLACE TEMPORARY TABLE tBuyAlive
+ ENGINE = MEMORY
+ SELECT
+ t.id travelFk,
+ t.landed,
+ t.landingHour,
+ t.warehouseInFk,
+ t.isReceived,
+ t.isRaid,
+ e.id entryFk,
+ b.lotFk,
+ b.itemFk,
+ b.life,
+ b.quantity
+ FROM tLotStatus ls
+ JOIN vn.buy b ON b.lotFk = ls.lotFk
+ JOIN vn.entry e ON e.id = b.entryFk
+ JOIN vn.travel t ON t.id = e.travelFk
+ WHERE ls.isIncluded;
+
+ START TRANSACTION;
+
+ -- Delete excluded/deleted/dead lots
+
+ DELETE l FROM buyLot l
+ JOIN tLotStatus ls USING(lotFk)
+ WHERE NOT ls.isIncluded;
+
+ -- Delete undead lot picks
+
+ UPDATE buyOut o
+ JOIN buyPick p ON p.outFk = o.outFk
+ JOIN tLotStatus ls ON ls.lotFk = p.lotFk
+ SET o.isSync = FALSE,
+ o.lack = o.lack + p.quantity
+ WHERE ls.isExcluded OR ls.isIncluded;
+
+ DELETE p FROM buyPick p
+ JOIN tLotStatus ls USING(lotFk)
+ WHERE ls.isExcluded OR ls.isIncluded;
+
+ -- Update alive outs
+
+ INSERT INTO buyLot (
+ lotFk,
+ isSync,
+ isPicked,
+ warehouseFk,
+ itemFk,
+ dated,
+ expired,
+ quantity,
+ available
+ )
+ SELECT
+ lotFk,
+ FALSE,
+ isReceived,
+ warehouseInFk,
+ itemFk,
+ @dated := ADDTIME(landed, IFNULL(landingHour, '00:00:00')),
+ @dated + INTERVAL life DAY,
+ quantity,
+ NULL
+ FROM tBuyAlive
+ ON DUPLICATE KEY UPDATE
+ isSync = VALUES(isSync),
+ isPicked = VALUES(isPicked),
+ warehouseFk = VALUES(warehouseFk),
+ itemFk = VALUES(itemFk),
+ dated = VALUES(dated),
+ expired = VALUES(expired),
+ quantity = VALUES(quantity),
+ available = VALUES(available);
+
+ COMMIT;
+
+ DROP TEMPORARY TABLE tBuyAlive;
+END$$
+DELIMITER ;
diff --git a/db/routines/stock/procedures/buyLot_requestQuantity.sql b/db/routines/stock/procedures/buyLot_requestQuantity.sql
new file mode 100644
index 0000000000..c04f778528
--- /dev/null
+++ b/db/routines/stock/procedures/buyLot_requestQuantity.sql
@@ -0,0 +1,64 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `stock`.`buyLot_requestQuantity`(
+ vSelf INT,
+ vRequested INT,
+ vDated DATETIME,
+ vOutFk INT,
+ OUT vSupplied INT)
+BEGIN
+/**
+ * Disassociates lot picks after the given date until the demanded quantity is
+ * satisfied.
+ *
+ * @param vSelf The buyLot reference
+ * @param vRequested The requested quantity
+ * @param vDate The starting date for the associated outs
+ * @param vOutFk The if of requesting out
+ * @param vSupplied The supplied quantity
+ */
+ DECLARE vPickFk INT;
+ DECLARE vPickOutFk INT;
+ DECLARE vPickQuantity INT;
+ DECLARE vPickGranted INT;
+ DECLARE vDone BOOL;
+
+ DECLARE vPicks CURSOR FOR
+ SELECT p.id, o.outFk, p.quantity
+ FROM buyPick p
+ JOIN buyOut o USING(outFk)
+ WHERE p.lotFk = vSelf
+ AND (o.dated, o.outFk) > (vDated, vOutFk)
+ ORDER BY o.dated DESC, o.created DESC, o.outFk DESC;
+
+ DECLARE CONTINUE HANDLER FOR NOT FOUND
+ SET vDone = TRUE;
+
+ SET vSupplied = 0;
+
+ OPEN vPicks;
+
+ myLoop: LOOP
+ SET vDone = FALSE;
+ FETCH vPicks INTO vPickFk, vPickOutFk, vPickQuantity;
+
+ IF vDone THEN
+ LEAVE myLoop;
+ END IF;
+
+ SET vPickGranted = LEAST(vRequested - vSupplied, vPickQuantity);
+ SET vSupplied = vSupplied + vPickGranted;
+ CALL buyPick_remove(vPickFk, vPickGranted, vPickQuantity);
+
+ UPDATE buyOut
+ SET isSync = FALSE,
+ lack = lack + vPickGranted
+ WHERE outFk = vPickOutFk;
+
+ IF vSupplied >= vRequested THEN
+ LEAVE myLoop;
+ END IF;
+ END LOOP;
+
+ CLOSE vPicks;
+END$$
+DELIMITER ;
diff --git a/db/routines/stock/procedures/inbound_sync.sql b/db/routines/stock/procedures/buyLot_sync.sql
similarity index 65%
rename from db/routines/stock/procedures/inbound_sync.sql
rename to db/routines/stock/procedures/buyLot_sync.sql
index 77d3e42f7e..a9bc81d071 100644
--- a/db/routines/stock/procedures/inbound_sync.sql
+++ b/db/routines/stock/procedures/buyLot_sync.sql
@@ -1,10 +1,10 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`inbound_sync`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `stock`.`buyLot_sync`(vSelf INT)
BEGIN
/**
- * Associates a inbound with their possible outbounds, updating it's available.
+ * Associates a lot with their possible outs, updating it's available.
*
- * @param vSelf The inbound identifier
+ * @param vSelf The lot id
*/
DECLARE vDated DATETIME;
DECLARE vExpired DATETIME;
@@ -14,37 +14,37 @@ BEGIN
DECLARE vAvailable INT;
DECLARE vSupplied INT;
DECLARE vSuppliedFromRequest INT;
- DECLARE vOutboundFk INT;
+ DECLARE vOutFk INT;
DECLARE vLack INT;
DECLARE vHasPicks BOOL;
DECLARE vDone BOOL;
- DECLARE vOutbounds CURSOR FOR
- SELECT id, lack, lack < quantity
- FROM outbound
+ DECLARE vOuts CURSOR FOR
+ SELECT outFk, lack, lack < quantity
+ FROM buyOut
WHERE warehouseFk = vWarehouse
AND itemFk = vItem
AND dated >= vDated
AND (vExpired IS NULL OR dated < vExpired)
- ORDER BY dated, created;
+ ORDER BY dated, created, outFk;
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET vDone = TRUE;
SELECT warehouseFk, itemFk, available, quantity, expired, dated
INTO vWarehouse, vItem, vAvailable, vQuantity, vExpired, vDated
- FROM inbound
- WHERE id = vSelf;
+ FROM buyLot
+ WHERE lotFk = vSelf;
IF vAvailable IS NULL THEN
SET vAvailable = vQuantity;
END IF;
- OPEN vOutbounds;
+ OPEN vOuts;
myLoop: LOOP
SET vDone = FALSE;
- FETCH vOutbounds INTO vOutboundFk, vLack, vHasPicks;
+ FETCH vOuts INTO vOutFk, vLack, vHasPicks;
IF vDone THEN
LEAVE myLoop;
@@ -54,19 +54,19 @@ BEGIN
IF vSupplied > 0 THEN
SET vAvailable = vAvailable - vSupplied;
- UPDATE outbound
+ UPDATE buyOut
SET lack = lack - vSupplied
- WHERE id = vOutboundFk;
+ WHERE outFk = vOutFk;
END IF;
IF vHasPicks AND vAvailable > 0 THEN
- CALL outbound_requestQuantity(vOutboundFk, vAvailable, vDated, vSuppliedFromRequest);
+ CALL buyOut_requestQuantity(vOutFk, vAvailable, vDated, vSelf, vSuppliedFromRequest);
SET vSupplied = vSupplied + vSuppliedFromRequest;
SET vAvailable = vAvailable - vSuppliedFromRequest;
END IF;
IF vSupplied > 0 THEN
- CALL inbound_addPick(vSelf, vOutboundFk, vSupplied);
+ CALL buyPick_add(vSelf, vOutFk, vSupplied);
END IF;
IF vAvailable <= 0 THEN
@@ -74,11 +74,11 @@ BEGIN
END IF;
END LOOP;
- CLOSE vOutbounds;
+ CLOSE vOuts;
- UPDATE inbound
+ UPDATE buyLot
SET isSync = TRUE,
available = vAvailable
- WHERE id = vSelf;
+ WHERE lotFk = vSelf;
END$$
DELIMITER ;
diff --git a/db/routines/stock/procedures/buyOut_refresh.sql b/db/routines/stock/procedures/buyOut_refresh.sql
new file mode 100644
index 0000000000..895e28716c
--- /dev/null
+++ b/db/routines/stock/procedures/buyOut_refresh.sql
@@ -0,0 +1,95 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `stock`.`buyOut_refresh`(
+ `vTable` VARCHAR(255),
+ `vId` INT,
+ `vSource` VARCHAR(255))
+BEGIN
+/**
+ * This procedure contains the common code used to refresh the out lot cache.
+ *
+ * @param vTable The id source table
+ * @param vId The lot id
+ * @param vSource The lot source
+ * @table tLotStatus Lots to modify
+ * @table tLotAlive Updated/Created alive lots data
+ */
+ DECLARE vHasLots BOOL;
+
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ ROLLBACK;
+ RESIGNAL;
+ END;
+
+ IF vTable = 'lot' THEN
+ SELECT COUNT(*) > 0 INTO vHasLots FROM tLotStatus;
+
+ IF NOT vHasLots THEN
+ INSERT INTO tLotStatus
+ SET lotFk = vId,
+ isExcluded = TRUE,
+ isIncluded = FALSE;
+ END IF;
+ END IF;
+
+ START TRANSACTION;
+
+ -- Delete excluded/deleted/dead outs
+
+ DELETE o FROM buyOut o
+ JOIN tLotStatus ls ON ls.lotFk = o.outFk
+ WHERE NOT ls.isIncluded;
+
+ -- Delete undead out picks
+
+ UPDATE buyLot l
+ JOIN buyPick p ON p.lotFk = l.lotFk
+ JOIN tLotStatus ls ON ls.lotFk = p.outFk
+ SET l.isSync = FALSE,
+ l.available = l.available + p.quantity
+ WHERE ls.isExcluded OR ls.isIncluded;
+
+ DELETE p FROM buyPick p
+ JOIN tLotStatus ls ON ls.lotFk = p.outFk
+ WHERE ls.isExcluded OR ls.isIncluded;
+
+ -- Update alive outs
+
+ INSERT INTO buyOut (
+ outFk,
+ source,
+ isSync,
+ warehouseFk,
+ dated,
+ itemFk,
+ quantity,
+ lack,
+ created,
+ isPicked
+ )
+ SELECT
+ lotFk,
+ vSource,
+ FALSE,
+ warehouseFk,
+ dated,
+ itemFk,
+ quantity,
+ quantity,
+ created,
+ isPicked
+ FROM tLotAlive
+ ON DUPLICATE KEY UPDATE
+ source = VALUES(source),
+ warehouseFk = VALUES(warehouseFk),
+ dated = VALUES(dated),
+ itemFk = VALUES(itemFk),
+ quantity = VALUES(quantity),
+ lack = VALUES(lack),
+ created = VALUES(created),
+ isPicked = VALUES(isPicked),
+ isSync = VALUES(isSync);
+
+ COMMIT;
+END$$
+DELIMITER ;
diff --git a/db/routines/stock/procedures/buyOut_refreshBuy.sql b/db/routines/stock/procedures/buyOut_refreshBuy.sql
new file mode 100644
index 0000000000..69b3878358
--- /dev/null
+++ b/db/routines/stock/procedures/buyOut_refreshBuy.sql
@@ -0,0 +1,39 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `stock`.`buyOut_refreshBuy`(
+ `vTable` VARCHAR(255),
+ `vId` INT)
+BEGIN
+ CREATE OR REPLACE TEMPORARY TABLE tLotStatus
+ ENGINE = MEMORY
+ SELECT lotFk,
+ @isExcluded := b.quantity <= 0 isExcluded,
+ NOT @isExcluded AND b.isAlive isIncluded
+ FROM vn.buy b
+ JOIN vn.entry e ON e.id = b.entryFk
+ WHERE
+ (vTable = 'lot' AND b.lotFk = vId)
+ OR (vTable = 'entry' AND e.id = vId)
+ OR (vTable = 'travel' AND e.travelFk = vId);
+
+ CREATE OR REPLACE TEMPORARY TABLE tLotAlive
+ ENGINE = MEMORY
+ SELECT
+ ls.lotFk,
+ t.warehouseOutFk warehouseFk,
+ ADDTIME(t.shipped, IFNULL(shipmentHour, '00:00:00')) dated,
+ t.isDelivered isPicked,
+ b.itemFk,
+ b.quantity,
+ b.created
+ FROM tLotStatus ls
+ JOIN vn.buy b ON b.lotFk = ls.lotFk
+ JOIN vn.entry e ON e.id = b.entryFk
+ JOIN vn.travel t ON t.id = e.travelFk
+ WHERE ls.isIncluded;
+
+ CALL buyOut_refresh(vTable, vId, 'buy');
+ CALL buyLot_refresh(vTable, vId);
+
+ DROP TEMPORARY TABLE tLotStatus, tLotAlive;
+END$$
+DELIMITER ;
diff --git a/db/routines/stock/procedures/buyOut_refreshOrder.sql b/db/routines/stock/procedures/buyOut_refreshOrder.sql
new file mode 100644
index 0000000000..610630ea20
--- /dev/null
+++ b/db/routines/stock/procedures/buyOut_refreshOrder.sql
@@ -0,0 +1,36 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `stock`.`buyOut_refreshOrder`(
+ `vTable` VARCHAR(255),
+ `vId` INT)
+BEGIN
+ CREATE OR REPLACE TEMPORARY TABLE tLotStatus
+ ENGINE = MEMORY
+ SELECT lotFk,
+ @isExcluded := o.confirmed OR NOT isReserved OR r.amount <= 0 isExcluded,
+ NOT @isExcluded isIncluded
+ FROM hedera.orderRow r
+ JOIN hedera.`order` o ON o.id = r.orderFk
+ WHERE
+ (vTable = 'lot' AND r.lotFk = vId)
+ OR (vTable = 'order' AND o.id = vId);
+
+ CREATE OR REPLACE TEMPORARY TABLE tLotAlive
+ ENGINE = MEMORY
+ SELECT
+ ls.lotFk,
+ r.warehouseFk,
+ r.shipment dated,
+ r.itemFk,
+ r.amount quantity,
+ r.created,
+ FALSE isPicked
+ FROM tLotStatus ls
+ JOIN hedera.orderRow r ON r.lotFk = ls.lotFk
+ JOIN hedera.`order` o ON o.id = r.orderFk
+ WHERE ls.isIncluded;
+
+ CALL buyOut_refresh(vTable, vId, 'orderRow');
+
+ DROP TEMPORARY TABLE tLotStatus, tLotAlive;
+END$$
+DELIMITER ;
diff --git a/db/routines/stock/procedures/buyOut_refreshSale.sql b/db/routines/stock/procedures/buyOut_refreshSale.sql
new file mode 100644
index 0000000000..48ddbf499a
--- /dev/null
+++ b/db/routines/stock/procedures/buyOut_refreshSale.sql
@@ -0,0 +1,42 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `stock`.`buyOut_refreshSale`(
+ `vTable` VARCHAR(255),
+ `vId` INT)
+BEGIN
+ DECLARE vAliveDate DATE;
+
+ SELECT util.VN_CURDATE() - INTERVAL saleLife MONTH
+ INTO vAliveDate
+ FROM config LIMIT 1;
+
+ CREATE OR REPLACE TEMPORARY TABLE tLotStatus
+ ENGINE = MEMORY
+ SELECT lotFk,
+ @isExcluded := s.quantity < 0 isExcluded,
+ NOT @isExcluded AND t.isAlive isIncluded
+ FROM vn.sale s
+ JOIN vn.ticket t ON t.id = s.ticketFk
+ WHERE
+ (vTable = 'lot' AND s.lotFk = vId)
+ OR (vTable = 'ticket' AND t.id = vId);
+
+ CREATE OR REPLACE TEMPORARY TABLE tLotAlive
+ ENGINE = MEMORY
+ SELECT
+ ls.lotFk,
+ t.warehouseFk,
+ t.shipped dated,
+ s.itemFk,
+ s.quantity,
+ s.created,
+ s.isPicked
+ FROM tLotStatus ls
+ JOIN vn.sale s ON s.lotFk = ls.lotFk
+ JOIN vn.ticket t ON t.id = s.ticketFk
+ WHERE ls.isIncluded;
+
+ CALL buyOut_refresh(vTable, vId, 'sale');
+
+ DROP TEMPORARY TABLE tLotStatus, tLotAlive;
+END$$
+DELIMITER ;
diff --git a/db/routines/stock/procedures/buyOut_requestQuantity.sql b/db/routines/stock/procedures/buyOut_requestQuantity.sql
new file mode 100644
index 0000000000..bd475e4b02
--- /dev/null
+++ b/db/routines/stock/procedures/buyOut_requestQuantity.sql
@@ -0,0 +1,64 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `stock`.`buyOut_requestQuantity`(
+ vSelf INT,
+ vRequested INT,
+ vDated DATETIME,
+ vLotFk INT,
+ OUT vSupplied INT)
+BEGIN
+/**
+ * Disassociates out picks after the given date until the demanded quantity is
+ * satisfied.
+ *
+ * @param vSelf The buyOut reference
+ * @param vRequested The requested quantity
+ * @param vDate The starting date for the associated lots
+ * @param vLotFk The if of requesting lot
+ * @param vSupplied The supplied quantity
+ */
+ DECLARE vPickFk INT;
+ DECLARE vPickLotFk INT;
+ DECLARE vPickQuantity INT;
+ DECLARE vPickGranted INT;
+ DECLARE vDone BOOL;
+
+ DECLARE vPicks CURSOR FOR
+ SELECT p.id, p.lotFk, p.quantity
+ FROM buyPick p
+ JOIN buyLot l USING(lotFk)
+ WHERE p.outFk = vSelf
+ AND (l.dated, p.lotFk) > (vDated, vLotFk)
+ ORDER BY l.dated, p.lotFk;
+
+ DECLARE CONTINUE HANDLER FOR NOT FOUND
+ SET vDone = TRUE;
+
+ SET vSupplied = 0;
+
+ OPEN vPicks;
+
+ myLoop: LOOP
+ SET vDone = FALSE;
+ FETCH vPicks INTO vPickFk, vPickLotFk, vPickQuantity;
+
+ IF vDone THEN
+ LEAVE myLoop;
+ END IF;
+
+ SET vPickGranted = LEAST(vRequested - vSupplied, vPickQuantity);
+ SET vSupplied = vSupplied + vPickGranted;
+ CALL buyPick_remove(vPickFk, vPickGranted, vPickQuantity);
+
+ UPDATE buyLot
+ SET isSync = FALSE,
+ available = available + vPickGranted
+ WHERE lotFk = vPickLotFk;
+
+ IF vSupplied >= vRequested THEN
+ LEAVE myLoop;
+ END IF;
+ END LOOP;
+
+ CLOSE vPicks;
+END$$
+DELIMITER ;
diff --git a/db/routines/stock/procedures/outbound_sync.sql b/db/routines/stock/procedures/buyOut_sync.sql
similarity index 61%
rename from db/routines/stock/procedures/outbound_sync.sql
rename to db/routines/stock/procedures/buyOut_sync.sql
index 0de3521761..fc212f082c 100644
--- a/db/routines/stock/procedures/outbound_sync.sql
+++ b/db/routines/stock/procedures/buyOut_sync.sql
@@ -1,10 +1,10 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`outbound_sync`(vSelf INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `stock`.`buyOut_sync`(vSelf INT)
BEGIN
/**
- * Attaches a outbound with available inbounds.
+ * Attaches an out with available lots.
*
- * @param vSelf The outbound reference
+ * @param vSelf The buyOut reference
*/
DECLARE vDated DATETIME;
DECLARE vItem INT;
@@ -12,33 +12,33 @@ BEGIN
DECLARE vLack INT;
DECLARE vSupplied INT;
DECLARE vSuppliedFromRequest INT;
- DECLARE vInboundFk INT;
+ DECLARE vLotFk INT;
DECLARE vAvailable INT;
DECLARE vHasPicks BOOL;
DECLARE vDone BOOL;
- DECLARE vInbounds CURSOR FOR
- SELECT id, available, available < quantity
- FROM inbound
+ DECLARE vBuyLots CURSOR FOR
+ SELECT lotFk, available, available < quantity
+ FROM buyLot
WHERE warehouseFk = vWarehouse
AND itemFk = vItem
AND dated <= vDated
AND (expired IS NULL OR expired > vDated)
- ORDER BY dated;
+ ORDER BY dated, lotFk;
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET vDone = TRUE;
SELECT warehouseFk, itemFk, dated, lack
INTO vWarehouse, vItem, vDated, vLack
- FROM outbound
- WHERE id = vSelf;
+ FROM buyOut
+ WHERE outFk = vSelf;
- OPEN vInbounds;
+ OPEN vBuyLots;
myLoop: LOOP
SET vDone = FALSE;
- FETCH vInbounds INTO vInboundFk, vAvailable, vHasPicks;
+ FETCH vBuyLots INTO vLotFk, vAvailable, vHasPicks;
IF vDone THEN
LEAVE myLoop;
@@ -48,19 +48,19 @@ BEGIN
IF vSupplied > 0 THEN
SET vLack = vLack - vSupplied;
- UPDATE inbound
+ UPDATE buyLot
SET available = available - vSupplied
- WHERE id = vInboundFk;
+ WHERE lotFk = vLotFk;
END IF;
IF vHasPicks AND vLack > 0 THEN
- CALL inbound_requestQuantity(vInboundFk, vLack, vDated, vSuppliedFromRequest);
+ CALL buyLot_requestQuantity(vLotFk, vLack, vDated, vSelf, vSuppliedFromRequest);
SET vSupplied = vSupplied + vSuppliedFromRequest;
SET vLack = vLack - vSuppliedFromRequest;
END IF;
IF vSupplied > 0 THEN
- CALL inbound_addPick(vInboundFk, vSelf, vSupplied);
+ CALL buyPick_add(vLotFk, vSelf, vSupplied);
END IF;
IF vLack = 0 THEN
@@ -68,11 +68,11 @@ BEGIN
END IF;
END LOOP;
- CLOSE vInbounds;
+ CLOSE vBuyLots;
- UPDATE outbound
+ UPDATE buyOut
SET isSync = TRUE,
lack = vLack
- WHERE id = vSelf;
+ WHERE outFk = vSelf;
END$$
DELIMITER ;
diff --git a/db/routines/stock/procedures/buyPick_add.sql b/db/routines/stock/procedures/buyPick_add.sql
new file mode 100644
index 0000000000..79012f50f0
--- /dev/null
+++ b/db/routines/stock/procedures/buyPick_add.sql
@@ -0,0 +1,15 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `stock`.`buyPick_add`(
+ vLotFk INT,
+ vOutFk INT,
+ vQuantity INT
+)
+BEGIN
+ INSERT INTO buyPick
+ SET lotFk = vLotFk,
+ outFk = vOutFk,
+ quantity = vQuantity
+ ON DUPLICATE KEY UPDATE
+ quantity = quantity + vQuantity;
+END$$
+DELIMITER ;
diff --git a/db/routines/stock/procedures/buyPick_remove.sql b/db/routines/stock/procedures/buyPick_remove.sql
new file mode 100644
index 0000000000..9cef0e9865
--- /dev/null
+++ b/db/routines/stock/procedures/buyPick_remove.sql
@@ -0,0 +1,17 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `stock`.`buyPick_remove`(
+ vSelf INT,
+ vQuantity INT,
+ vTotalQuantity INT
+)
+BEGIN
+ IF vQuantity < vTotalQuantity THEN
+ UPDATE buyPick
+ SET quantity = quantity - vQuantity
+ WHERE id = vSelf;
+ ELSE
+ DELETE FROM buyPick
+ WHERE id = vSelf;
+ END IF;
+END$$
+DELIMITER ;
diff --git a/db/routines/stock/procedures/inbound_addPick.sql b/db/routines/stock/procedures/inbound_addPick.sql
deleted file mode 100644
index 41b93a9868..0000000000
--- a/db/routines/stock/procedures/inbound_addPick.sql
+++ /dev/null
@@ -1,16 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`inbound_addPick`(
- vSelf INT,
- vOutboundFk INT,
- vQuantity INT
-)
-BEGIN
- INSERT INTO inboundPick
- SET
- inboundFk = vSelf,
- outboundFk = vOutboundFk,
- quantity = vQuantity
- ON DUPLICATE KEY UPDATE
- quantity = quantity + vQuantity;
-END$$
-DELIMITER ;
diff --git a/db/routines/stock/procedures/inbound_removePick.sql b/db/routines/stock/procedures/inbound_removePick.sql
deleted file mode 100644
index e183e11712..0000000000
--- a/db/routines/stock/procedures/inbound_removePick.sql
+++ /dev/null
@@ -1,20 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`inbound_removePick`(
- vSelf INT,
- vOutboundFk INT,
- vQuantity INT,
- vTotalQuantity INT
-)
-BEGIN
- IF vQuantity < vTotalQuantity THEN
- UPDATE inboundPick
- SET quantity = quantity - vQuantity
- WHERE inboundFk = vSelf
- AND outboundFk = vOutboundFk;
- ELSE
- DELETE FROM inboundPick
- WHERE inboundFk = vSelf
- AND outboundFk = vOutboundFk;
- END IF;
-END$$
-DELIMITER ;
diff --git a/db/routines/stock/procedures/inbound_requestQuantity.sql b/db/routines/stock/procedures/inbound_requestQuantity.sql
deleted file mode 100644
index 1cbc1908bf..0000000000
--- a/db/routines/stock/procedures/inbound_requestQuantity.sql
+++ /dev/null
@@ -1,61 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`inbound_requestQuantity`(
- vSelf INT,
- vRequested INT,
- vDated DATETIME,
- OUT vSupplied INT)
-BEGIN
-/**
- * Disassociates inbound picks after the given date until the
- * demanded quantity is satisfied.
- *
- * @param vSelf The inbound reference
- * @param vRequested The requested quantity
- * @param vDate The starting date for the associated outbounds
- * @param vSupplied The supplied quantity
- */
- DECLARE vOutboundFk INT;
- DECLARE vPickQuantity INT;
- DECLARE vPickGranted INT;
- DECLARE vDone BOOL;
-
- DECLARE vPicks CURSOR FOR
- SELECT p.outboundFk, p.quantity
- FROM inboundPick p
- JOIN outbound o ON o.id = p.outboundFk
- WHERE p.inboundFk = vSelf
- AND o.dated > vDated
- ORDER BY o.dated DESC, o.created DESC;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND
- SET vDone = TRUE;
-
- SET vSupplied = 0;
-
- OPEN vPicks;
-
- myLoop: LOOP
- SET vDone = FALSE;
- FETCH vPicks INTO vOutboundFk, vPickQuantity;
-
- IF vDone THEN
- LEAVE myLoop;
- END IF;
-
- SET vPickGranted = LEAST(vRequested - vSupplied, vPickQuantity);
- SET vSupplied = vSupplied + vPickGranted;
- CALL inbound_removePick(vSelf, vOutboundFk, vPickGranted, vPickQuantity);
-
- UPDATE outbound
- SET isSync = FALSE,
- lack = lack + vPickGranted
- WHERE id = vOutboundFk;
-
- IF vSupplied >= vRequested THEN
- LEAVE myLoop;
- END IF;
- END LOOP;
-
- CLOSE vPicks;
-END$$
-DELIMITER ;
diff --git a/db/routines/stock/procedures/log_clean.sql b/db/routines/stock/procedures/log_clean.sql
deleted file mode 100644
index 56634b371a..0000000000
--- a/db/routines/stock/procedures/log_clean.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`log_clean`()
-BEGIN
- DELETE FROM inbound WHERE dated = vn.getInventoryDate();
- DELETE FROM outbound WHERE dated = vn.getInventoryDate();
-END$$
-DELIMITER ;
diff --git a/db/routines/stock/procedures/log_delete.sql b/db/routines/stock/procedures/log_delete.sql
deleted file mode 100644
index e3b631b4ea..0000000000
--- a/db/routines/stock/procedures/log_delete.sql
+++ /dev/null
@@ -1,19 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`log_delete`(vTableName VARCHAR(255), vTableId INT)
-proc: BEGIN
-/**
- * Processes orphan transactions.
- */
- IF vTableName NOT IN ('buy', 'sale', 'orderRow') THEN
- LEAVE proc;
- END IF;
-
- DELETE FROM inbound
- WHERE tableName = vTableName COLLATE utf8_general_ci
- AND tableId = vTableId;
-
- DELETE FROM outbound
- WHERE tableName = vTableName COLLATE utf8_general_ci
- AND tableId = vTableId;
-END$$
-DELIMITER ;
diff --git a/db/routines/stock/procedures/log_refreshAll.sql b/db/routines/stock/procedures/log_refreshAll.sql
deleted file mode 100644
index 3eaad07f21..0000000000
--- a/db/routines/stock/procedures/log_refreshAll.sql
+++ /dev/null
@@ -1,33 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`log_refreshAll`()
-BEGIN
-/**
- * Recalculates the entire cache. It takes a considerable time,
- * please avoid calls to this procedure from commonly used operations.
- */
- DECLARE EXIT HANDLER FOR SQLEXCEPTION
- BEGIN
- DO RELEASE_LOCK('stock.log_sync');
- RESIGNAL;
- END;
-
- IF !GET_LOCK('stock.log_sync', 30) THEN
- CALL util.throw('Lock timeout exceeded');
- END IF;
-
- TRUNCATE TABLE stock.`log`;
- TRUNCATE TABLE stock.`inbound`;
- TRUNCATE TABLE stock.`inboundPick`;
- TRUNCATE TABLE stock.`outbound`;
- TRUNCATE TABLE stock.`visible`;
-
- CALL log_refreshSale(NULL, NULL);
- CALL log_refreshBuy(NULL, NULL);
- CALL log_refreshOrder(NULL, NULL);
-
- UPDATE outbound SET isSync = TRUE;
- CALL log_sync(TRUE);
-
- DO RELEASE_LOCK('stock.log_sync');
-END$$
-DELIMITER ;
diff --git a/db/routines/stock/procedures/log_refreshBuy.sql b/db/routines/stock/procedures/log_refreshBuy.sql
deleted file mode 100644
index 874e140725..0000000000
--- a/db/routines/stock/procedures/log_refreshBuy.sql
+++ /dev/null
@@ -1,73 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`log_refreshBuy`(
- `vTableName` VARCHAR(255),
- `vTableId` INT)
-BEGIN
- DROP TEMPORARY TABLE IF EXISTS tValues;
- CREATE TEMPORARY TABLE tValues
- ENGINE = MEMORY
- SELECT b.id buyFk,
- e.id entryFk,
- t.id travelFk,
- b.itemFk,
- t.isRaid,
- ADDTIME(t.shipped,
- IFNULL(t.shipmentHour, '00:00:00')) shipped,
- t.warehouseOutFk,
- t.isDelivered,
- ADDTIME(t.landed,
- IFNULL(t.landingHour, '00:00:00')) landed,
- t.warehouseInFk,
- t.isReceived,
- tp.life,
- ABS(b.quantity) quantity,
- b.created,
- b.quantity > 0 isIn,
- t.shipped < vn.getInventoryDate() lessThanInventory
- FROM vn.buy b
- JOIN vn.entry e ON e.id = b.entryFk
- JOIN vn.travel t ON t.id = e.travelFk
- JOIN vn.item i ON i.id = b.itemFk
- JOIN vn.itemType tp ON tp.id = i.typeFk
- WHERE (
- vTableId IS NULL
- OR (vTableName = 'travel' AND t.id = vTableId)
- OR (vTableName = 'entry' AND e.id = vTableId)
- OR (vTableName = 'buy' AND b.id = vTableId)
- )
- AND t.landed >= vn.getInventoryDate()
- AND b.quantity != 0;
-
- REPLACE INTO inbound (
- tableName, tableId, warehouseFk, dated,
- itemFk, expired, quantity, isPicked
- )
- SELECT 'buy',
- buyFk,
- IF(isIn, warehouseInFk, warehouseOutFk),
- @dated := IF(isIn, landed, shipped),
- itemFk,
- TIMESTAMPADD(DAY, life, @dated),
- quantity,
- IF(isIn, isReceived, isDelivered) AND NOT isRaid
- FROM tValues
- WHERE isIn OR !lessThanInventory;
-
- REPLACE INTO outbound (
- tableName, tableId, warehouseFk, dated,
- itemFk, created, quantity, isPicked
- )
- SELECT 'buy',
- buyFk,
- IF(isIn, warehouseOutFk, warehouseInFk),
- IF(isIn, shipped, landed),
- itemFk,
- created,
- quantity,
- IF(isIn, isDelivered, isReceived) AND NOT isRaid
- FROM tValues
- WHERE !isIn OR !lessThanInventory;
-
- DROP TEMPORARY TABLE tValues;
-END$$
-DELIMITER ;
diff --git a/db/routines/stock/procedures/log_refreshOrder.sql b/db/routines/stock/procedures/log_refreshOrder.sql
deleted file mode 100644
index ce5b31cc8e..0000000000
--- a/db/routines/stock/procedures/log_refreshOrder.sql
+++ /dev/null
@@ -1,47 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`log_refreshOrder`(
- `vTableName` VARCHAR(255),
- `vTableId` INT)
-BEGIN
- DECLARE vExpireTime INT DEFAULT 20;
- DECLARE vExpired DATETIME DEFAULT TIMESTAMPADD(MINUTE, -vExpireTime, util.VN_NOW());
-
- DROP TEMPORARY TABLE IF EXISTS tValues;
- CREATE TEMPORARY TABLE tValues
- ENGINE = MEMORY
- SELECT
- r.id rowFk,
- r.itemFk,
- r.warehouseFk,
- r.shipment shipped,
- r.amount quantity,
- r.created
- FROM hedera.orderRow r
- JOIN hedera.`order` o ON o.id = r.orderFk
- WHERE (
- vTableId IS NULL
- OR (vTableName = 'order' AND o.id = vTableId)
- OR (vTableName = 'orderRow' AND r.id = vTableId)
- )
- AND !o.confirmed
- AND r.shipment >= vn.getInventoryDate()
- AND r.created >= vExpired
- AND r.amount != 0;
-
- REPLACE INTO outbound (
- tableName, tableId, warehouseFk, dated,
- itemFk, created, expired, quantity
- )
- SELECT 'orderRow',
- rowFk,
- warehouseFk,
- shipped,
- itemFk,
- created,
- TIMESTAMPADD(MINUTE, vExpireTime, created),
- quantity
- FROM tValues;
-
- DROP TEMPORARY TABLE tValues;
-END$$
-DELIMITER ;
diff --git a/db/routines/stock/procedures/log_refreshSale.sql b/db/routines/stock/procedures/log_refreshSale.sql
deleted file mode 100644
index 3054f8ecb2..0000000000
--- a/db/routines/stock/procedures/log_refreshSale.sql
+++ /dev/null
@@ -1,66 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`log_refreshSale`(
- `vTableName` VARCHAR(255),
- `vTableId` INT)
-BEGIN
- DROP TEMPORARY TABLE IF EXISTS tValues;
- CREATE TEMPORARY TABLE tValues
- ENGINE = MEMORY
- SELECT
- m.id saleFk,
- m.ticketFk,
- m.itemFk,
- t.warehouseFk,
- t.shipped,
- ABS(m.quantity) quantity,
- m.created,
- TIMESTAMPADD(DAY, tp.life, t.shipped) expired,
- m.quantity < 0 isIn,
- m.isPicked OR s.alertLevel > al.id isPicked
- FROM vn.sale m
- JOIN vn.ticket t ON t.id = m.ticketFk
- JOIN vn.ticketState s ON s.ticketFk = t.id
- JOIN vn.item i ON i.id = m.itemFk
- JOIN vn.itemType tp ON tp.id = i.typeFk
- JOIN vn.alertLevel al ON al.code = 'ON_PREPARATION'
- WHERE (
- vTableId IS NULL
- OR (vTableName = 'ticket' AND t.id = vTableId)
- OR (vTableName = 'sale' AND m.id = vTableId)
- )
- AND t.shipped >= vn.getInventoryDate()
- AND m.quantity != 0;
-
- REPLACE INTO inbound (
- tableName, tableId, warehouseFk, dated,
- itemFk, expired, quantity, isPicked
- )
- SELECT 'sale',
- saleFk,
- warehouseFk,
- shipped,
- itemFk,
- expired,
- quantity,
- isPicked
- FROM tValues
- WHERE isIn;
-
- REPLACE INTO outbound (
- tableName, tableId, warehouseFk, dated,
- itemFk, created, quantity, isPicked
- )
- SELECT 'sale',
- saleFk,
- warehouseFk,
- shipped,
- itemFk,
- created,
- quantity,
- isPicked
- FROM tValues
- WHERE !isIn;
-
- DROP TEMPORARY TABLE tValues;
-END$$
-DELIMITER ;
diff --git a/db/routines/stock/procedures/log_sync.sql b/db/routines/stock/procedures/log_sync.sql
deleted file mode 100644
index 5b03b6ab0e..0000000000
--- a/db/routines/stock/procedures/log_sync.sql
+++ /dev/null
@@ -1,123 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`log_sync`(vSync BOOL)
-proc: BEGIN
- DECLARE vDone BOOL;
- DECLARE vLogId INT;
- DECLARE vHasPendingSync BOOL;
- DECLARE vOperation VARCHAR(255);
- DECLARE vTableName VARCHAR(255);
- DECLARE vTableId VARCHAR(255);
- DECLARE vInboundFk INT;
- DECLARE vOutboundFk INT;
-
- DECLARE cInbound CURSOR FOR
- SELECT id FROM inbound
- WHERE !isSync
- ORDER BY dated;
-
- DECLARE cOutbound CURSOR FOR
- SELECT id FROM outbound
- WHERE !isSync
- ORDER BY dated;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND
- SET vDone = TRUE;
-
- DECLARE EXIT HANDLER FOR SQLEXCEPTION
- BEGIN
- ROLLBACK;
- RESIGNAL;
- END;
-
- -- Applies changes
-
- opsLoop: LOOP
- START TRANSACTION;
-
- SET vDone = FALSE;
- SELECT id, operation, tableName, tableId
- INTO vLogId, vOperation, vTableName, vTableId
- FROM `log`
- ORDER BY id LIMIT 1
- FOR UPDATE;
-
- IF vDone THEN
- COMMIT;
- LEAVE opsLoop;
- END IF;
-
- CALL log_delete(vTableName, vTableId);
-
- IF vOperation = 'insert' THEN
- IF vTableName IN ('travel', 'entry', 'buy') THEN
- CALL log_refreshBuy(vTableName, vTableId);
- ELSEIF vTableName IN ('ticket', 'sale') THEN
- CALL log_refreshSale(vTableName, vTableId);
- ELSEIF vTableName IN ('order', 'orderRow') THEN
- CALL log_refreshOrder(vTableName, vTableId);
- END IF;
- END IF;
-
- DELETE FROM `log` WHERE id = vLogId;
- SET vSync = TRUE;
-
- COMMIT;
- END LOOP;
-
- IF !vSync THEN
- LEAVE proc;
- END IF;
-
- -- Deletes expired outbounds
-
- DELETE FROM outbound WHERE expired <= util.VN_NOW();
-
- -- Attaches desync inbounds
-
- REPEAT
- OPEN cInbound;
- SET vHasPendingSync = FALSE;
-
- inboundLoop: LOOP
- SET vDone = FALSE;
- FETCH cInbound INTO vInboundFk;
-
- IF vDone THEN
- LEAVE inboundLoop;
- END IF;
-
- START TRANSACTION;
- CALL inbound_sync(vInboundFk);
- COMMIT;
-
- SET vHasPendingSync = TRUE;
- END LOOP;
-
- CLOSE cInbound;
- UNTIL !vHasPendingSync END REPEAT;
-
- -- Attaches desync outbounds
-
- REPEAT
- OPEN cOutbound;
- SET vHasPendingSync = FALSE;
-
- outboundLoop: LOOP
- SET vDone = FALSE;
- FETCH cOutbound INTO vOutboundFk;
-
- IF vDone THEN
- LEAVE outboundLoop;
- END IF;
-
- START TRANSACTION;
- CALL outbound_sync(vOutboundFk);
- COMMIT;
-
- SET vHasPendingSync = TRUE;
- END LOOP;
-
- CLOSE cOutbound;
- UNTIL !vHasPendingSync END REPEAT;
-END$$
-DELIMITER ;
diff --git a/db/routines/stock/procedures/log_syncNoWait.sql b/db/routines/stock/procedures/log_syncNoWait.sql
deleted file mode 100644
index 00cc215fd4..0000000000
--- a/db/routines/stock/procedures/log_syncNoWait.sql
+++ /dev/null
@@ -1,16 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`log_syncNoWait`()
-BEGIN
- DECLARE EXIT HANDLER FOR SQLEXCEPTION
- BEGIN
- DO RELEASE_LOCK('stock.log_sync');
- RESIGNAL;
- END;
-
- IF GET_LOCK('stock.log_sync', 0) THEN
- CALL log_sync(FALSE);
- END IF;
-
- DO RELEASE_LOCK('stock.log_sync');
-END$$
-DELIMITER ;
diff --git a/db/routines/stock/procedures/outbound_requestQuantity.sql b/db/routines/stock/procedures/outbound_requestQuantity.sql
deleted file mode 100644
index 7ddc3545ca..0000000000
--- a/db/routines/stock/procedures/outbound_requestQuantity.sql
+++ /dev/null
@@ -1,61 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`outbound_requestQuantity`(
- vSelf INT,
- vRequested INT,
- vDated DATETIME,
- OUT vSupplied INT)
-BEGIN
-/**
- * Disassociates outbound picks after the given date until the
- * demanded quantity is satisfied.
- *
- * @param vSelf The outbound reference
- * @param vRequested The requested quantity
- * @param vDate The starting date for the associated inbounds
- * @param vSupplied The supplied quantity
- */
- DECLARE vInboundFk INT;
- DECLARE vPickQuantity INT;
- DECLARE vPickGranted INT;
- DECLARE vDone BOOL;
-
- DECLARE vPicks CURSOR FOR
- SELECT p.inboundFk, p.quantity
- FROM inboundPick p
- JOIN inbound i ON i.id = p.inboundFk
- WHERE p.outboundFk = vSelf
- AND i.dated > vDated
- ORDER BY i.dated DESC;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND
- SET vDone = TRUE;
-
- SET vSupplied = 0;
-
- OPEN vPicks;
-
- myLoop: LOOP
- SET vDone = FALSE;
- FETCH vPicks INTO vInboundFk, vPickQuantity;
-
- IF vDone THEN
- LEAVE myLoop;
- END IF;
-
- SET vPickGranted = LEAST(vRequested - vSupplied, vPickQuantity);
- SET vSupplied = vSupplied + vPickGranted;
- CALL inbound_removePick(vInboundFk, vSelf, vPickGranted, vPickQuantity);
-
- UPDATE inbound
- SET isSync = FALSE,
- available = available + vPickGranted
- WHERE id = vInboundFk;
-
- IF vSupplied >= vRequested THEN
- LEAVE myLoop;
- END IF;
- END LOOP;
-
- CLOSE vPicks;
-END$$
-DELIMITER ;
diff --git a/db/routines/stock/procedures/stock_clean.sql b/db/routines/stock/procedures/stock_clean.sql
new file mode 100644
index 0000000000..fda30b7754
--- /dev/null
+++ b/db/routines/stock/procedures/stock_clean.sql
@@ -0,0 +1,32 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `stock`.`stock_clean`()
+BEGIN
+/**
+ * Cleans current time dependent cache records.
+ */
+ DECLARE vExpired DATETIME;
+ DECLARE vAliveDate DATE;
+
+ -- Expired order reserves
+
+ SELECT SUBTIME(util.VN_NOW(), reserveTime)
+ INTO vExpired
+ FROM hedera.orderConfig LIMIT 1;
+
+ UPDATE hedera.order
+ SET isReserved = FALSE
+ WHERE created < vExpired
+ AND isReserved;
+
+ -- Frozen old sales
+
+ SELECT util.VN_CURDATE() - INTERVAL saleLife DAY
+ INTO vAliveDate
+ FROM config LIMIT 1;
+
+ UPDATE vn.ticket
+ SET isAlive = FALSE
+ WHERE shipped < vAliveDate
+ AND isAlive;
+END$$
+DELIMITER ;
diff --git a/db/routines/stock/procedures/stock_refreshAll.sql b/db/routines/stock/procedures/stock_refreshAll.sql
new file mode 100644
index 0000000000..3c811a3207
--- /dev/null
+++ b/db/routines/stock/procedures/stock_refreshAll.sql
@@ -0,0 +1,90 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `stock`.`stock_refreshAll`()
+BEGIN
+/**
+ * Recalculates the entire cache. It takes a considerable time,
+ * please avoid calls to this procedure from commonly used operations.
+ */
+ DECLARE vDone BOOL;
+ DECLARE vId INT;
+
+ DECLARE vEntries CURSOR FOR
+ SELECT DISTINCT e.id
+ FROM vn.buy b
+ JOIN vn.entry e ON b.entryFk = e.id
+ WHERE b.isAlive;
+
+ DECLARE vTickets CURSOR FOR
+ SELECT id FROM vn.ticket WHERE isAlive;
+
+ DECLARE vOrderRows CURSOR FOR
+ SELECT lotFk FROM hedera.orderRow WHERE isReserved;
+
+ DECLARE CONTINUE HANDLER FOR NOT FOUND
+ SET vDone = TRUE;
+
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ DO RELEASE_LOCK('stock.stock_refreshAll');
+ RESIGNAL;
+ END;
+
+ IF NOT GET_LOCK('stock.stock_refreshAll', 30) THEN
+ CALL util.throw('Lock timeout exceeded');
+ END IF;
+
+ -- Prune cache
+
+ DELETE p FROM buyPick p JOIN buyLot l USING(lotFk);
+ TRUNCATE TABLE buyLot;
+ TRUNCATE TABLE buyOut;
+
+ -- Populate cache
+
+ OPEN vEntries;
+ buyLoop: LOOP
+ SET vDone = FALSE;
+ FETCH vEntries INTO vId;
+
+ IF vDone THEN
+ LEAVE buyLoop;
+ END IF;
+
+ CALL buyOut_refreshBuy('entry', vId);
+ END LOOP;
+ CLOSE vEntries;
+
+ OPEN vOrderRows;
+ orderLoop: LOOP
+ SET vDone = FALSE;
+ FETCH vOrderRows INTO vId;
+
+ IF vDone THEN
+ LEAVE orderLoop;
+ END IF;
+
+ CALL buyOut_refreshOrder('lot', vId);
+ END LOOP;
+ CLOSE vOrderRows;
+
+ OPEN vTickets;
+ saleLoop: LOOP
+ SET vDone = FALSE;
+ FETCH vTickets INTO vId;
+
+ IF vDone THEN
+ LEAVE saleLoop;
+ END IF;
+
+ CALL buyOut_refreshSale('ticket', vId);
+ END LOOP;
+ CLOSE vTickets;
+
+ -- Synchronize
+
+ UPDATE buyOut SET isSync = TRUE;
+ CALL stock_sync;
+
+ DO RELEASE_LOCK('stock.stock_refreshAll');
+END$$
+DELIMITER ;
diff --git a/db/routines/stock/procedures/stock_sync.sql b/db/routines/stock/procedures/stock_sync.sql
new file mode 100644
index 0000000000..41501f4f1f
--- /dev/null
+++ b/db/routines/stock/procedures/stock_sync.sql
@@ -0,0 +1,34 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `stock`.`stock_sync`()
+BEGIN
+/**
+ * Synchronizes all out of sync items. It can be called in parallel
+ * since it generates a lock for each item (and warehouse) synchronization
+ * process, see stock_syncItem().
+ */
+ DECLARE vDone BOOL;
+ DECLARE vWarehouseFk INT;
+ DECLARE vItemFk INT;
+
+ DECLARE vItems CURSOR FOR
+ SELECT itemFk, warehouseFk FROM buyLot WHERE NOT isSync
+ UNION
+ SELECT itemFk, warehouseFk FROM buyOut WHERE NOT isSync;
+
+ DECLARE CONTINUE HANDLER FOR NOT FOUND
+ SET vDone = TRUE;
+
+ OPEN vItems;
+ itemLoop: LOOP
+ SET vDone = FALSE;
+ FETCH vItems INTO vItemFk, vWarehouseFk;
+
+ IF vDone THEN
+ LEAVE itemLoop;
+ END IF;
+
+ CALL stock_syncItem(vItemFk, vWarehouseFk, 0);
+ END LOOP;
+ CLOSE vItems;
+END$$
+DELIMITER ;
diff --git a/db/routines/stock/procedures/stock_syncItem.sql b/db/routines/stock/procedures/stock_syncItem.sql
new file mode 100644
index 0000000000..65ef46736b
--- /dev/null
+++ b/db/routines/stock/procedures/stock_syncItem.sql
@@ -0,0 +1,88 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `stock`.`stock_syncItem`(
+ vItemFk INT,
+ vWarehouseFk INT,
+ vWait INT)
+myProc: BEGIN
+/**
+ * Synchronizes out of sync item. It generates a lock for each item and
+ * warehouse synchronization process.
+ *
+ * @param vItemFk The item id
+ * @param vWarehouseFk The item warehouse id
+ * @param vWait Maximum waiting time, see GET_LOCK()
+ */
+ DECLARE vDone BOOL;
+ DECLARE vHasPendingSync BOOL;
+ DECLARE vLotFk INT;
+ DECLARE vOutFk INT;
+ DECLARE vLock VARCHAR(255);
+
+ DECLARE vLots CURSOR FOR
+ SELECT lotFk FROM buyLot
+ WHERE NOT isSync
+ AND (itemFk, warehouseFk) = (vItemFk, vWarehouseFk)
+ ORDER BY dated, lotFk;
+
+ DECLARE vOuts CURSOR FOR
+ SELECT outFk FROM buyOut
+ WHERE NOT isSync
+ AND (itemFk, warehouseFk) = (vItemFk, vWarehouseFk)
+ ORDER BY dated, created, outFk;
+
+ DECLARE CONTINUE HANDLER FOR NOT FOUND
+ SET vDone = TRUE;
+
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ DO RELEASE_LOCK(vLock);
+ ROLLBACK;
+ RESIGNAL;
+ END;
+
+ SET vLock = CONCAT_WS('/', 'stock.stock_syncItem', vWarehouseFk, vItemFk);
+
+ IF NOT GET_LOCK(vLock, vWait) THEN
+ LEAVE myProc;
+ END IF;
+
+ REPEAT
+ SET vHasPendingSync = FALSE;
+
+ OPEN vLots;
+ lotLoop: LOOP
+ SET vDone = FALSE;
+ FETCH vLots INTO vLotFk;
+
+ IF vDone THEN
+ LEAVE lotLoop;
+ END IF;
+
+ START TRANSACTION;
+ CALL buyLot_sync(vLotFk);
+ COMMIT;
+
+ SET vHasPendingSync = TRUE;
+ END LOOP;
+ CLOSE vLots;
+
+ OPEN vOuts;
+ outLoop: LOOP
+ SET vDone = FALSE;
+ FETCH vOuts INTO vOutFk;
+
+ IF vDone THEN
+ LEAVE outLoop;
+ END IF;
+
+ START TRANSACTION;
+ CALL buyOut_sync(vOutFk);
+ COMMIT;
+
+ SET vHasPendingSync = TRUE;
+ END LOOP;
+ CLOSE vOuts;
+
+ UNTIL NOT vHasPendingSync END REPEAT;
+END$$
+DELIMITER ;
diff --git a/db/routines/stock/procedures/visible_log.sql b/db/routines/stock/procedures/visible_log.sql
deleted file mode 100644
index cc88d3205e..0000000000
--- a/db/routines/stock/procedures/visible_log.sql
+++ /dev/null
@@ -1,20 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`visible_log`(
- vIsPicked BOOL,
- vWarehouseFk INT,
- vItemFk INT,
- vQuantity INT
-)
-proc: BEGIN
- IF !vIsPicked THEN
- LEAVE proc;
- END IF;
-
- INSERT INTO visible
- SET itemFk = vItemFk,
- warehouseFk = vWarehouseFk,
- quantity = vQuantity
- ON DUPLICATE KEY UPDATE
- quantity = quantity + VALUES(quantity);
-END$$
-DELIMITER ;
diff --git a/db/routines/stock/triggers/inbound_afterDelete.sql b/db/routines/stock/triggers/inbound_afterDelete.sql
deleted file mode 100644
index 451dcc5995..0000000000
--- a/db/routines/stock/triggers/inbound_afterDelete.sql
+++ /dev/null
@@ -1,22 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `stock`.`inbound_afterDelete`
- AFTER DELETE ON `inbound`
- FOR EACH ROW
-BEGIN
- UPDATE outbound o
- JOIN inboundPick ou ON ou.outboundFk = o.id
- SET o.lack = o.lack + ou.quantity,
- o.isSync = FALSE
- WHERE ou.inboundFk = OLD.id;
-
- DELETE FROM inboundPick
- WHERE inboundFk = OLD.id;
-
- CALL visible_log(
- OLD.isPicked,
- OLD.warehouseFk,
- OLD.itemFk,
- -OLD.quantity
- );
-END$$
-DELIMITER ;
diff --git a/db/routines/stock/triggers/inbound_beforeInsert.sql b/db/routines/stock/triggers/inbound_beforeInsert.sql
deleted file mode 100644
index 723cb3222f..0000000000
--- a/db/routines/stock/triggers/inbound_beforeInsert.sql
+++ /dev/null
@@ -1,15 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `stock`.`inbound_beforeInsert`
- BEFORE INSERT ON `inbound`
- FOR EACH ROW
-BEGIN
- SET NEW.isPicked = NEW.isPicked OR NEW.dated < util.VN_CURDATE();
-
- CALL visible_log(
- NEW.isPicked,
- NEW.warehouseFk,
- NEW.itemFk,
- NEW.quantity
- );
-END$$
-DELIMITER ;
diff --git a/db/routines/stock/triggers/outbound_afterDelete.sql b/db/routines/stock/triggers/outbound_afterDelete.sql
deleted file mode 100644
index e7d756871d..0000000000
--- a/db/routines/stock/triggers/outbound_afterDelete.sql
+++ /dev/null
@@ -1,22 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `stock`.`outbound_afterDelete`
- AFTER DELETE ON `outbound`
- FOR EACH ROW
-BEGIN
- UPDATE inbound i
- JOIN inboundPick ou ON ou.inboundFk = i.id
- SET i.available = i.available + ou.quantity,
- i.isSync = FALSE
- WHERE ou.outboundFk = OLD.id;
-
- DELETE FROM inboundPick
- WHERE outboundFk = OLD.id;
-
- CALL visible_log(
- OLD.isPicked,
- OLD.warehouseFk,
- OLD.itemFk,
- OLD.quantity
- );
-END$$
-DELIMITER ;
diff --git a/db/routines/stock/triggers/outbound_beforeInsert.sql b/db/routines/stock/triggers/outbound_beforeInsert.sql
deleted file mode 100644
index 86546413e9..0000000000
--- a/db/routines/stock/triggers/outbound_beforeInsert.sql
+++ /dev/null
@@ -1,16 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `stock`.`outbound_beforeInsert`
- BEFORE INSERT ON `outbound`
- FOR EACH ROW
-BEGIN
- SET NEW.lack = NEW.quantity;
- SET NEW.isPicked = NEW.isPicked OR NEW.dated < util.VN_CURDATE();
-
- CALL visible_log(
- NEW.isPicked,
- NEW.warehouseFk,
- NEW.itemFk,
- -NEW.quantity
- );
-END$$
-DELIMITER ;
diff --git a/db/routines/tmp/events/clean.sql b/db/routines/tmp/events/clean.sql
index 34b7139ccc..75f0223626 100644
--- a/db/routines/tmp/events/clean.sql
+++ b/db/routines/tmp/events/clean.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `tmp`.`clean`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `tmp`.`clean`
ON SCHEDULE EVERY 1 HOUR
STARTS '2022-03-01 00:00:00.000'
ON COMPLETION PRESERVE
diff --git a/db/routines/tmp/procedures/clean.sql b/db/routines/tmp/procedures/clean.sql
index a15f98311c..90ea692167 100644
--- a/db/routines/tmp/procedures/clean.sql
+++ b/db/routines/tmp/procedures/clean.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `tmp`.`clean`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `tmp`.`clean`()
BEGIN
DECLARE vTableName VARCHAR(255);
DECLARE vDone BOOL;
diff --git a/db/routines/util/events/log_clean.sql b/db/routines/util/events/log_clean.sql
index 8447069e6b..225dd35644 100644
--- a/db/routines/util/events/log_clean.sql
+++ b/db/routines/util/events/log_clean.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `util`.`log_clean`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `util`.`log_clean`
ON SCHEDULE EVERY 1 DAY
STARTS '2024-07-09 00:30:00.000'
ON COMPLETION PRESERVE
diff --git a/db/routines/util/events/slowLog_prune.sql b/db/routines/util/events/slowLog_prune.sql
index aa9b0c1844..1b339fbcda 100644
--- a/db/routines/util/events/slowLog_prune.sql
+++ b/db/routines/util/events/slowLog_prune.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `util`.`slowLog_prune`
+CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `util`.`slowLog_prune`
ON SCHEDULE EVERY 1 DAY
STARTS '2021-10-08 00:00:00.000'
ON COMPLETION PRESERVE
diff --git a/db/routines/util/functions/VN_CURDATE.sql b/db/routines/util/functions/VN_CURDATE.sql
index 692f097a0f..0ceb0c4ede 100644
--- a/db/routines/util/functions/VN_CURDATE.sql
+++ b/db/routines/util/functions/VN_CURDATE.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`VN_CURDATE`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`VN_CURDATE`()
RETURNS date
DETERMINISTIC
BEGIN
diff --git a/db/routines/util/functions/VN_CURTIME.sql b/db/routines/util/functions/VN_CURTIME.sql
index ae66ea500e..954ed2273a 100644
--- a/db/routines/util/functions/VN_CURTIME.sql
+++ b/db/routines/util/functions/VN_CURTIME.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`VN_CURTIME`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`VN_CURTIME`()
RETURNS time
DETERMINISTIC
BEGIN
diff --git a/db/routines/util/functions/VN_NOW.sql b/db/routines/util/functions/VN_NOW.sql
index 47b1bb4fdb..44e3ece447 100644
--- a/db/routines/util/functions/VN_NOW.sql
+++ b/db/routines/util/functions/VN_NOW.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`VN_NOW`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`VN_NOW`()
RETURNS datetime
DETERMINISTIC
BEGIN
diff --git a/db/routines/util/functions/VN_UNIX_TIMESTAMP.sql b/db/routines/util/functions/VN_UNIX_TIMESTAMP.sql
index 7174598621..c168df9fd1 100644
--- a/db/routines/util/functions/VN_UNIX_TIMESTAMP.sql
+++ b/db/routines/util/functions/VN_UNIX_TIMESTAMP.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`VN_UNIX_TIMESTAMP`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`VN_UNIX_TIMESTAMP`()
RETURNS int(11)
DETERMINISTIC
BEGIN
diff --git a/db/routines/util/functions/VN_UTC_DATE.sql b/db/routines/util/functions/VN_UTC_DATE.sql
index 2b40b7dc29..803b6026fb 100644
--- a/db/routines/util/functions/VN_UTC_DATE.sql
+++ b/db/routines/util/functions/VN_UTC_DATE.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`VN_UTC_DATE`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`VN_UTC_DATE`()
RETURNS date
DETERMINISTIC
BEGIN
diff --git a/db/routines/util/functions/VN_UTC_TIME.sql b/db/routines/util/functions/VN_UTC_TIME.sql
index 930333d238..3eaa7f4314 100644
--- a/db/routines/util/functions/VN_UTC_TIME.sql
+++ b/db/routines/util/functions/VN_UTC_TIME.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`VN_UTC_TIME`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`VN_UTC_TIME`()
RETURNS time
DETERMINISTIC
BEGIN
diff --git a/db/routines/util/functions/VN_UTC_TIMESTAMP.sql b/db/routines/util/functions/VN_UTC_TIMESTAMP.sql
index 97d1258741..530198cb9d 100644
--- a/db/routines/util/functions/VN_UTC_TIMESTAMP.sql
+++ b/db/routines/util/functions/VN_UTC_TIMESTAMP.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`VN_UTC_TIMESTAMP`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`VN_UTC_TIMESTAMP`()
RETURNS datetime
DETERMINISTIC
BEGIN
diff --git a/db/routines/util/functions/accountNumberToIban.sql b/db/routines/util/functions/accountNumberToIban.sql
index 49d3c917e5..8119545476 100644
--- a/db/routines/util/functions/accountNumberToIban.sql
+++ b/db/routines/util/functions/accountNumberToIban.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`accountNumberToIban`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`accountNumberToIban`(
vAccount VARCHAR(20)
)
RETURNS varchar(4) CHARSET utf8mb3 COLLATE utf8mb3_general_ci
diff --git a/db/routines/util/functions/accountShortToStandard.sql b/db/routines/util/functions/accountShortToStandard.sql
index 71e360bf37..a3379d9892 100644
--- a/db/routines/util/functions/accountShortToStandard.sql
+++ b/db/routines/util/functions/accountShortToStandard.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`accountShortToStandard`(vAccount VARCHAR(10))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`accountShortToStandard`(vAccount VARCHAR(10))
RETURNS varchar(10) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci
DETERMINISTIC
BEGIN
diff --git a/db/routines/util/functions/binlogQueue_getDelay.sql b/db/routines/util/functions/binlogQueue_getDelay.sql
index d6cf49377d..adbf0e98a5 100644
--- a/db/routines/util/functions/binlogQueue_getDelay.sql
+++ b/db/routines/util/functions/binlogQueue_getDelay.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`binlogQueue_getDelay`(vCode VARCHAR(255))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`binlogQueue_getDelay`(vCode VARCHAR(255))
RETURNS BIGINT
READS SQL DATA
NOT DETERMINISTIC
diff --git a/db/routines/util/functions/capitalizeFirst.sql b/db/routines/util/functions/capitalizeFirst.sql
index 859777de20..50e5f508e2 100644
--- a/db/routines/util/functions/capitalizeFirst.sql
+++ b/db/routines/util/functions/capitalizeFirst.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`capitalizeFirst`(vString VARCHAR(255))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`capitalizeFirst`(vString VARCHAR(255))
RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_general_ci
DETERMINISTIC
NO SQL
diff --git a/db/routines/util/functions/checkPrintableChars.sql b/db/routines/util/functions/checkPrintableChars.sql
index a4addce247..a327ed41df 100644
--- a/db/routines/util/functions/checkPrintableChars.sql
+++ b/db/routines/util/functions/checkPrintableChars.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`checkPrintableChars`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`checkPrintableChars`(
vString VARCHAR(255)
) RETURNS tinyint(1)
DETERMINISTIC
diff --git a/db/routines/util/functions/crypt.sql b/db/routines/util/functions/crypt.sql
index 664563cd0b..98308729e8 100644
--- a/db/routines/util/functions/crypt.sql
+++ b/db/routines/util/functions/crypt.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`crypt`(vText VARCHAR(255), vKey VARCHAR(255))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`crypt`(vText VARCHAR(255), vKey VARCHAR(255))
RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_general_ci
NOT DETERMINISTIC
READS SQL DATA
diff --git a/db/routines/util/functions/cryptOff.sql b/db/routines/util/functions/cryptOff.sql
index bc281e4ece..1c268f0700 100644
--- a/db/routines/util/functions/cryptOff.sql
+++ b/db/routines/util/functions/cryptOff.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`cryptOff`(vText VARCHAR(255), vKey VARCHAR(255))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`cryptOff`(vText VARCHAR(255), vKey VARCHAR(255))
RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_general_ci
NOT DETERMINISTIC
READS SQL DATA
diff --git a/db/routines/util/functions/dayEnd.sql b/db/routines/util/functions/dayEnd.sql
index 1da4dcfe6f..767e490d8a 100644
--- a/db/routines/util/functions/dayEnd.sql
+++ b/db/routines/util/functions/dayEnd.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`dayEnd`(vDated DATE)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`dayEnd`(vDated DATE)
RETURNS datetime
DETERMINISTIC
NO SQL
diff --git a/db/routines/util/functions/firstDayOfMonth.sql b/db/routines/util/functions/firstDayOfMonth.sql
index 77971c7b86..298dba95af 100644
--- a/db/routines/util/functions/firstDayOfMonth.sql
+++ b/db/routines/util/functions/firstDayOfMonth.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`firstDayOfMonth`(vDate DATE)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`firstDayOfMonth`(vDate DATE)
RETURNS date
DETERMINISTIC
NO SQL
diff --git a/db/routines/util/functions/firstDayOfYear.sql b/db/routines/util/functions/firstDayOfYear.sql
index 710c3a6884..f7a9f8dafb 100644
--- a/db/routines/util/functions/firstDayOfYear.sql
+++ b/db/routines/util/functions/firstDayOfYear.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`firstDayOfYear`(vDate DATE)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`firstDayOfYear`(vDate DATE)
RETURNS date
DETERMINISTIC
NO SQL
diff --git a/db/routines/util/functions/formatRow.sql b/db/routines/util/functions/formatRow.sql
index b119df0155..b80e60e9fc 100644
--- a/db/routines/util/functions/formatRow.sql
+++ b/db/routines/util/functions/formatRow.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`formatRow`(vType CHAR(3), vValues VARCHAR(512))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`formatRow`(vType CHAR(3), vValues VARCHAR(512))
RETURNS varchar(512) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci
DETERMINISTIC
BEGIN
diff --git a/db/routines/util/functions/formatTable.sql b/db/routines/util/functions/formatTable.sql
index 00a2b50bf7..a717e8c072 100644
--- a/db/routines/util/functions/formatTable.sql
+++ b/db/routines/util/functions/formatTable.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`formatTable`(vFields VARCHAR(512), vOldValues VARCHAR(512), vNewValues VARCHAR(512))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`formatTable`(vFields VARCHAR(512), vOldValues VARCHAR(512), vNewValues VARCHAR(512))
RETURNS text CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci
DETERMINISTIC
BEGIN
diff --git a/db/routines/util/functions/hasDateOverlapped.sql b/db/routines/util/functions/hasDateOverlapped.sql
index 9441e201c2..ea73390e6f 100644
--- a/db/routines/util/functions/hasDateOverlapped.sql
+++ b/db/routines/util/functions/hasDateOverlapped.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`hasDateOverlapped`(vSarted1 DATE, vEnded1 DATE, vSarted2 DATE, vEnded2 DATE)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`hasDateOverlapped`(vSarted1 DATE, vEnded1 DATE, vSarted2 DATE, vEnded2 DATE)
RETURNS tinyint(1)
DETERMINISTIC
BEGIN
diff --git a/db/routines/util/functions/hmacSha2.sql b/db/routines/util/functions/hmacSha2.sql
index 78611c118b..cb36cac873 100644
--- a/db/routines/util/functions/hmacSha2.sql
+++ b/db/routines/util/functions/hmacSha2.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`hmacSha2`(`vAlg` SMALLINT, `vMsg` MEDIUMBLOB, `vKey` MEDIUMBLOB)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`hmacSha2`(`vAlg` SMALLINT, `vMsg` MEDIUMBLOB, `vKey` MEDIUMBLOB)
RETURNS varchar(128) CHARSET utf8mb3 COLLATE utf8mb3_general_ci
DETERMINISTIC
NO SQL
diff --git a/db/routines/util/functions/isLeapYear.sql b/db/routines/util/functions/isLeapYear.sql
index 2c7c96f3d5..c51e98cda1 100644
--- a/db/routines/util/functions/isLeapYear.sql
+++ b/db/routines/util/functions/isLeapYear.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`isLeapYear`(vYear INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`isLeapYear`(vYear INT)
RETURNS tinyint(1)
DETERMINISTIC
BEGIN
diff --git a/db/routines/util/functions/json_removeNulls.sql b/db/routines/util/functions/json_removeNulls.sql
index 5fa7413809..45797e1bfa 100644
--- a/db/routines/util/functions/json_removeNulls.sql
+++ b/db/routines/util/functions/json_removeNulls.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`json_removeNulls`(vObject JSON)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`json_removeNulls`(vObject JSON)
RETURNS longtext CHARSET utf8mb4 COLLATE utf8mb4_bin
DETERMINISTIC
BEGIN
diff --git a/db/routines/util/functions/lang.sql b/db/routines/util/functions/lang.sql
index 3431cdcc71..e7832993dd 100644
--- a/db/routines/util/functions/lang.sql
+++ b/db/routines/util/functions/lang.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`lang`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`lang`()
RETURNS char(2) CHARSET utf8mb3 COLLATE utf8mb3_general_ci
DETERMINISTIC
NO SQL
diff --git a/db/routines/util/functions/lastDayOfYear.sql b/db/routines/util/functions/lastDayOfYear.sql
index 52607ae218..b60fc2cc78 100644
--- a/db/routines/util/functions/lastDayOfYear.sql
+++ b/db/routines/util/functions/lastDayOfYear.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`lastDayOfYear`(vDate DATE)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`lastDayOfYear`(vDate DATE)
RETURNS date
DETERMINISTIC
NO SQL
diff --git a/db/routines/util/functions/log_formatDate.sql b/db/routines/util/functions/log_formatDate.sql
index 84c2690279..0004461d13 100644
--- a/db/routines/util/functions/log_formatDate.sql
+++ b/db/routines/util/functions/log_formatDate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`log_formatDate`(vInstance JSON)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`log_formatDate`(vInstance JSON)
RETURNS longtext CHARSET utf8mb4 COLLATE utf8mb4_bin
DETERMINISTIC
BEGIN
diff --git a/db/routines/util/functions/midnight.sql b/db/routines/util/functions/midnight.sql
index b374156829..b36a9668c3 100644
--- a/db/routines/util/functions/midnight.sql
+++ b/db/routines/util/functions/midnight.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`midnight`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`midnight`()
RETURNS datetime
DETERMINISTIC
READS SQL DATA
diff --git a/db/routines/util/functions/mockTime.sql b/db/routines/util/functions/mockTime.sql
index ab7859e7d5..4dd050cf2d 100644
--- a/db/routines/util/functions/mockTime.sql
+++ b/db/routines/util/functions/mockTime.sql
@@ -1,11 +1,11 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`mockTime`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`mockTime`()
RETURNS datetime
DETERMINISTIC
BEGIN
/**
* Returns current dateTime
- *
+ *
* @return current datetime
*/
RETURN NOW();
diff --git a/db/routines/util/functions/mockTimeBase.sql b/db/routines/util/functions/mockTimeBase.sql
deleted file mode 100644
index 7b3ea1a4ac..0000000000
--- a/db/routines/util/functions/mockTimeBase.sql
+++ /dev/null
@@ -1,26 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`mockTimeBase`(vIsUtc BOOL)
- RETURNS datetime
- DETERMINISTIC
-BEGIN
-/**
- * Returns the date formatted to utc if vIsUtc or config.mocTz if not
- *
- * @param vIsUtc If date must be returned as UTC format
- * @return The formatted mock time
- */
-DECLARE vMockUtcTime DATETIME;
- DECLARE vMockTz VARCHAR(255);
-
- SELECT mockUtcTime, mockTz
- INTO vMockUtcTime, vMockTz
- FROM config
- LIMIT 1;
-
- IF vIsUtc OR vMockTz IS NULL THEN
- RETURN vMockUtcTime;
- ELSE
- RETURN CONVERT_TZ(vMockUtcTime, '+00:00', vMockTz);
- END IF;
-END$$
-DELIMITER ;
diff --git a/db/routines/util/functions/mockUtcTime.sql b/db/routines/util/functions/mockUtcTime.sql
index e79c3b2410..1a11872a26 100644
--- a/db/routines/util/functions/mockUtcTime.sql
+++ b/db/routines/util/functions/mockUtcTime.sql
@@ -1,25 +1,13 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`mockUtcTime`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`mockUtcTime`()
RETURNS datetime
DETERMINISTIC
BEGIN
/**
- * Returns the UTC datetime in mockTime format or timeStamp depending on config table
+ * Returns current UTC dateTime
*
* @return The UTC datetime format
*/
--- FIXME: #5041 Commented because there is slowness when querying a table
-/*
- DECLARE vMockEnabled BOOL;
-
- SELECT mockEnabled INTO vMockEnabled FROM config LIMIT 1;
-
- IF vMockEnabled THEN
- RETURN mockTimeBase(TRUE);
- ELSE
- RETURN UTC_TIMESTAMP();
- END IF;
-*/
RETURN UTC_TIMESTAMP();
END$$
DELIMITER ;
diff --git a/db/routines/util/functions/nextWeek.sql b/db/routines/util/functions/nextWeek.sql
index f764201aa4..fc6abc40d2 100644
--- a/db/routines/util/functions/nextWeek.sql
+++ b/db/routines/util/functions/nextWeek.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`nextWeek`(vYearWeek INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`nextWeek`(vYearWeek INT)
RETURNS int(11)
DETERMINISTIC
BEGIN
diff --git a/db/routines/util/functions/notification_send.sql b/db/routines/util/functions/notification_send.sql
index 981cde2d6d..87f5ec43aa 100644
--- a/db/routines/util/functions/notification_send.sql
+++ b/db/routines/util/functions/notification_send.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`notification_send`(vNotificationName VARCHAR(255), vParams TEXT, vAuthorFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`notification_send`(vNotificationName VARCHAR(255), vParams TEXT, vAuthorFk INT)
RETURNS int(11)
NOT DETERMINISTIC
MODIFIES SQL DATA
diff --git a/db/routines/util/functions/quarterFirstDay.sql b/db/routines/util/functions/quarterFirstDay.sql
index b8239ffc8e..a8d4c35ada 100644
--- a/db/routines/util/functions/quarterFirstDay.sql
+++ b/db/routines/util/functions/quarterFirstDay.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`quarterFirstDay`(vYear INT, vQuarter INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`quarterFirstDay`(vYear INT, vQuarter INT)
RETURNS date
DETERMINISTIC
BEGIN
diff --git a/db/routines/util/functions/quoteIdentifier.sql b/db/routines/util/functions/quoteIdentifier.sql
index 1c0c4c5436..96161b3ef8 100644
--- a/db/routines/util/functions/quoteIdentifier.sql
+++ b/db/routines/util/functions/quoteIdentifier.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`quoteIdentifier`(vString TEXT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`quoteIdentifier`(vString TEXT)
RETURNS text CHARSET utf8mb3 COLLATE utf8mb3_general_ci
DETERMINISTIC
NO SQL
diff --git a/db/routines/util/functions/stringXor.sql b/db/routines/util/functions/stringXor.sql
index 252cd00400..e16ca4c430 100644
--- a/db/routines/util/functions/stringXor.sql
+++ b/db/routines/util/functions/stringXor.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`stringXor`(vString MEDIUMBLOB, vConst TINYINT UNSIGNED)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`stringXor`(vString MEDIUMBLOB, vConst TINYINT UNSIGNED)
RETURNS mediumblob
DETERMINISTIC
NO SQL
diff --git a/db/routines/util/functions/today.sql b/db/routines/util/functions/today.sql
index d57b04071e..5f65fe2e14 100644
--- a/db/routines/util/functions/today.sql
+++ b/db/routines/util/functions/today.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`today`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`today`()
RETURNS date
DETERMINISTIC
BEGIN
diff --git a/db/routines/util/functions/tomorrow.sql b/db/routines/util/functions/tomorrow.sql
index 71fbcf8f51..e85af114eb 100644
--- a/db/routines/util/functions/tomorrow.sql
+++ b/db/routines/util/functions/tomorrow.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`tomorrow`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`tomorrow`()
RETURNS date
DETERMINISTIC
BEGIN
diff --git a/db/routines/util/functions/twoDaysAgo.sql b/db/routines/util/functions/twoDaysAgo.sql
index 2612ed6893..e00d965a47 100644
--- a/db/routines/util/functions/twoDaysAgo.sql
+++ b/db/routines/util/functions/twoDaysAgo.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`twoDaysAgo`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`twoDaysAgo`()
RETURNS date
DETERMINISTIC
BEGIN
diff --git a/db/routines/util/functions/yearRelativePosition.sql b/db/routines/util/functions/yearRelativePosition.sql
index e62e50eb45..bede2d809b 100644
--- a/db/routines/util/functions/yearRelativePosition.sql
+++ b/db/routines/util/functions/yearRelativePosition.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`yearRelativePosition`(vYear INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`yearRelativePosition`(vYear INT)
RETURNS varchar(20) CHARSET utf8mb3 COLLATE utf8mb3_general_ci
DETERMINISTIC
BEGIN
diff --git a/db/routines/util/functions/yesterday.sql b/db/routines/util/functions/yesterday.sql
index a1938ab10f..bc21a263ae 100644
--- a/db/routines/util/functions/yesterday.sql
+++ b/db/routines/util/functions/yesterday.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`yesterday`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`yesterday`()
RETURNS date
DETERMINISTIC
BEGIN
diff --git a/db/routines/util/procedures/checkHex.sql b/db/routines/util/procedures/checkHex.sql
index 3cd5452e81..8fc4003f48 100644
--- a/db/routines/util/procedures/checkHex.sql
+++ b/db/routines/util/procedures/checkHex.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`checkHex`(vParam VARCHAR(255))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `util`.`checkHex`(vParam VARCHAR(255))
BEGIN
/**
* Comprueba si vParam es un número hexadecimal que empieza por # y tiene una longitud total de 7 dígitos
diff --git a/db/routines/util/procedures/connection_kill.sql b/db/routines/util/procedures/connection_kill.sql
index b38509d1bc..3b9ea17f37 100644
--- a/db/routines/util/procedures/connection_kill.sql
+++ b/db/routines/util/procedures/connection_kill.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`connection_kill`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `util`.`connection_kill`(
vConnectionId BIGINT
)
BEGIN
diff --git a/db/routines/util/procedures/debugAdd.sql b/db/routines/util/procedures/debugAdd.sql
index a8f7b3aa2e..cf1c92606c 100644
--- a/db/routines/util/procedures/debugAdd.sql
+++ b/db/routines/util/procedures/debugAdd.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`debugAdd`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `util`.`debugAdd`(
vVariable VARCHAR(255),
vValue TEXT
)
diff --git a/db/routines/util/procedures/exec.sql b/db/routines/util/procedures/exec.sql
index ca66884a57..5fec91ec7b 100644
--- a/db/routines/util/procedures/exec.sql
+++ b/db/routines/util/procedures/exec.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`exec`(vSqlQuery TEXT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `util`.`exec`(vSqlQuery TEXT)
SQL SECURITY INVOKER
BEGIN
/**
diff --git a/db/routines/util/procedures/log_add.sql b/db/routines/util/procedures/log_add.sql
index a5b1519c43..aa0ec23881 100644
--- a/db/routines/util/procedures/log_add.sql
+++ b/db/routines/util/procedures/log_add.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`log_add`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `util`.`log_add`(
vSchema VARCHAR(45),
vEntity VARCHAR(45),
vChangedModel VARCHAR(45),
diff --git a/db/routines/util/procedures/log_addWithUser.sql b/db/routines/util/procedures/log_addWithUser.sql
index 2e20821a69..50c86ecedb 100644
--- a/db/routines/util/procedures/log_addWithUser.sql
+++ b/db/routines/util/procedures/log_addWithUser.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`log_addWithUser`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `util`.`log_addWithUser`(
vSchema VARCHAR(45),
vEntity VARCHAR(45),
vChangedModel VARCHAR(45),
diff --git a/db/routines/util/procedures/log_clean.sql b/db/routines/util/procedures/log_clean.sql
index aeed9dc442..484279b62a 100644
--- a/db/routines/util/procedures/log_clean.sql
+++ b/db/routines/util/procedures/log_clean.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`log_clean`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `util`.`log_clean`()
BEGIN
/**
* Hace limpieza de los datos de las tablas log,
diff --git a/db/routines/util/procedures/log_cleanInstances.sql b/db/routines/util/procedures/log_cleanInstances.sql
index 756a8d1f35..029b50eea4 100644
--- a/db/routines/util/procedures/log_cleanInstances.sql
+++ b/db/routines/util/procedures/log_cleanInstances.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`log_cleanInstances`(
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `util`.`log_cleanInstances`(
vActionCode VARCHAR(45),
INOUT vOldInstance JSON,
INOUT vNewInstance JSON)
diff --git a/db/routines/util/procedures/procNoOverlap.sql b/db/routines/util/procedures/procNoOverlap.sql
index 9bb2f109ea..2a00138c47 100644
--- a/db/routines/util/procedures/procNoOverlap.sql
+++ b/db/routines/util/procedures/procNoOverlap.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`procNoOverlap`(procName VARCHAR(255))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `util`.`procNoOverlap`(procName VARCHAR(255))
SQL SECURITY INVOKER
proc: BEGIN
/**
diff --git a/db/routines/util/procedures/proc_changedPrivs.sql b/db/routines/util/procedures/proc_changedPrivs.sql
index 220652d1a7..69b2125994 100644
--- a/db/routines/util/procedures/proc_changedPrivs.sql
+++ b/db/routines/util/procedures/proc_changedPrivs.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`proc_changedPrivs`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `util`.`proc_changedPrivs`()
BEGIN
SELECT s.*
FROM proc_privs s
diff --git a/db/routines/util/procedures/proc_restorePrivs.sql b/db/routines/util/procedures/proc_restorePrivs.sql
index 0d502a6db9..8e7c287c2c 100644
--- a/db/routines/util/procedures/proc_restorePrivs.sql
+++ b/db/routines/util/procedures/proc_restorePrivs.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`proc_restorePrivs`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `util`.`proc_restorePrivs`()
BEGIN
/**
* Restores the privileges saved by proc_savePrivs().
diff --git a/db/routines/util/procedures/proc_savePrivs.sql b/db/routines/util/procedures/proc_savePrivs.sql
index 75c289f7b7..25545ca699 100644
--- a/db/routines/util/procedures/proc_savePrivs.sql
+++ b/db/routines/util/procedures/proc_savePrivs.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`proc_savePrivs`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `util`.`proc_savePrivs`()
BEGIN
/**
* Saves routine privileges, used to simplify the task of keeping
diff --git a/db/routines/util/procedures/slowLog_prune.sql b/db/routines/util/procedures/slowLog_prune.sql
index d676ae3d9c..59327c1c28 100644
--- a/db/routines/util/procedures/slowLog_prune.sql
+++ b/db/routines/util/procedures/slowLog_prune.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`slowLog_prune`()
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `util`.`slowLog_prune`()
BEGIN
/**
* Prunes MySQL slow query log table deleting all records older than one week.
diff --git a/db/routines/util/procedures/throw.sql b/db/routines/util/procedures/throw.sql
index 260915e0db..b391d38804 100644
--- a/db/routines/util/procedures/throw.sql
+++ b/db/routines/util/procedures/throw.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`throw`(vMessage CHAR(55))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `util`.`throw`(vMessage CHAR(55))
BEGIN
/**
* Throws a user-defined exception.
diff --git a/db/routines/util/procedures/time_generate.sql b/db/routines/util/procedures/time_generate.sql
index 14cc1edc59..cc93cd372b 100644
--- a/db/routines/util/procedures/time_generate.sql
+++ b/db/routines/util/procedures/time_generate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`time_generate`(vStarted DATE, vEnded DATE)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `util`.`time_generate`(vStarted DATE, vEnded DATE)
BEGIN
/**
* Generate a temporary table between the days passed as parameters
diff --git a/db/routines/util/procedures/tx_commit.sql b/db/routines/util/procedures/tx_commit.sql
index 35f96df8df..1f708c5339 100644
--- a/db/routines/util/procedures/tx_commit.sql
+++ b/db/routines/util/procedures/tx_commit.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_commit`(vIsTx BOOL)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `util`.`tx_commit`(vIsTx BOOL)
BEGIN
/**
* Confirma los cambios asociados a una transacción.
diff --git a/db/routines/util/procedures/tx_rollback.sql b/db/routines/util/procedures/tx_rollback.sql
index 4b00f9ec1a..38ee77613d 100644
--- a/db/routines/util/procedures/tx_rollback.sql
+++ b/db/routines/util/procedures/tx_rollback.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_rollback`(vIsTx BOOL)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `util`.`tx_rollback`(vIsTx BOOL)
BEGIN
/**
* Deshace los cambios asociados a una transacción.
diff --git a/db/routines/util/procedures/tx_start.sql b/db/routines/util/procedures/tx_start.sql
index 41f8c94eea..ac1a443d3f 100644
--- a/db/routines/util/procedures/tx_start.sql
+++ b/db/routines/util/procedures/tx_start.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_start`(vIsTx BOOL)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `util`.`tx_start`(vIsTx BOOL)
BEGIN
/**
* Inicia una transacción.
diff --git a/db/routines/util/procedures/warn.sql b/db/routines/util/procedures/warn.sql
index e1dd33c9c4..92e40a83d9 100644
--- a/db/routines/util/procedures/warn.sql
+++ b/db/routines/util/procedures/warn.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`warn`(vCode CHAR(35))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `util`.`warn`(vCode CHAR(35))
BEGIN
DECLARE w VARCHAR(1) DEFAULT '__';
SET @warn = vCode;
diff --git a/db/routines/util/views/eventLogGrouped.sql b/db/routines/util/views/eventLogGrouped.sql
index 8615458b5e..8f3c9f264b 100644
--- a/db/routines/util/views/eventLogGrouped.sql
+++ b/db/routines/util/views/eventLogGrouped.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `util`.`eventLogGrouped`
AS SELECT max(`t`.`date`) AS `lastHappened`,
diff --git a/db/routines/vn/functions/item_getLife.sql b/db/routines/vn/functions/item_getLife.sql
new file mode 100644
index 0000000000..e413399003
--- /dev/null
+++ b/db/routines/vn/functions/item_getLife.sql
@@ -0,0 +1,15 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`item_getLife`(vItemFk INT)
+ RETURNS INT
+ NOT DETERMINISTIC
+BEGIN
+ DECLARE vLife INT;
+
+ SELECT t.life INTO vLife
+ FROM itemType t
+ JOIN item i ON i.typeFk = t.id
+ WHERE i.id = vItemFk;
+
+ RETURN vLife;
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/procedures/catalog_calculate.sql b/db/routines/vn/procedures/catalog_calculate.sql
index a253ba91bf..f15cbb19a1 100644
--- a/db/routines/vn/procedures/catalog_calculate.sql
+++ b/db/routines/vn/procedures/catalog_calculate.sql
@@ -4,7 +4,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`catalog_calculate`(
vAddressFk INT,
vAgencyModeFk INT,
vShowExpiredZones BOOLEAN)
-BEGIN
+BEGIN
/**
* Calcula los articulos disponibles y sus precios
*
@@ -12,7 +12,7 @@ BEGIN
* @param vLanded Fecha de recepcion de mercancia
* @param vAddressFk Id del consignatario
* @param vAgencyModeFk Id de la agencia
- * @return tmp.ticketCalculateItem(itemFk, available, producer,
+ * @return tmp.ticketCalculateItem(itemFk, available, producer,
* item, size, stems, category, inkFk, image, origin, price)
* @return tmp.ticketLot(warehouseFk, itemFk, available, buyFk)
* @return tmp.ticketComponent
@@ -48,34 +48,34 @@ BEGIN
CALL catalog_componentPrepare();
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem(
- itemFk INT(11) NOT NULL,
+ itemFk INT(11) NOT NULL,
available INT(11),
- producer VARCHAR(50),
- item VARCHAR(50),
- size INT(10) UNSIGNED,
- stems INT(11),
- category VARCHAR(3),
- inkFk VARCHAR(3),
+ producer VARCHAR(50),
+ item VARCHAR(50),
+ size INT(10) UNSIGNED,
+ stems INT(11),
+ category VARCHAR(3),
+ inkFk VARCHAR(3),
image VARCHAR(50),
- origin VARCHAR(3),
+ origin VARCHAR(3),
price DECIMAL(10,2),
priceKg DECIMAL(10,2),
`grouping` INT(10) UNSIGNED,
minQuantity INT(10) UNSIGNED,
PRIMARY KEY `itemFk` (`itemFk`)
) ENGINE = MEMORY DEFAULT CHARSET=utf8;
-
+
OPEN cTravelTree;
l: LOOP
SET vDone = FALSE;
FETCH cTravelTree INTO vZoneFk, vWarehouseFk, vShipped, vHour;
-
+
SET vAvailabled = vShipped + INTERVAL HOUR(vHour) HOUR;
IF vDone THEN
LEAVE l;
END IF;
-
+
CALL `cache`.available_refresh(vAvailableCalc, FALSE, vWarehouseFk, vAvailabled);
CALL buy_getUltimate(NULL, vWarehouseFk, vShipped);
@@ -89,19 +89,19 @@ BEGIN
JOIN tmp.item i ON i.itemFk = a.item_id
JOIN item it ON it.id = i.itemFk
JOIN `zone` z ON z.id = vZoneFk
- LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = a.item_id
+ LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = a.item_id
JOIN agencyMode am ON am.id = vAgencyModeFk
JOIN agency ag ON ag.id = am.agencyFk
JOIN itemType itt ON itt.id = it.typeFk
JOIN itemCategory itc on itc.id = itt.categoryFk
JOIN address ad ON ad.id = vAddressFk
- LEFT JOIN clientItemType cit
+ LEFT JOIN clientItemType cit
ON cit.clientFk = ad.clientFk
AND cit.itemTypeFk = itt.id
- LEFT JOIN zoneItemType zit
+ LEFT JOIN zoneItemType zit
ON zit.zoneFk = vZoneFk
AND zit.itemTypeFk = itt.id
- LEFT JOIN agencyModeItemType ait
+ LEFT JOIN agencyModeItemType ait
ON ait.agencyModeFk = vAgencyModeFk
AND ait.itemTypeFk = itt.id
LEFT JOIN (
diff --git a/db/routines/vn/procedures/item_getLack.sql b/db/routines/vn/procedures/item_getLack.sql
index 1a54f03962..51c09e5226 100644
--- a/db/routines/vn/procedures/item_getLack.sql
+++ b/db/routines/vn/procedures/item_getLack.sql
@@ -9,7 +9,9 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_getLack`(
vSize INT,
vOrigen INT,
vLack INT,
- vWarehouseFk INT
+ vWarehouseFk INT,
+ vCategoryFk INT,
+ vTypeFk INT
)
BEGIN
/**
@@ -26,10 +28,12 @@ BEGIN
SELECT i.id itemFk,
i.longName,
+ i.name,
w.id warehouseFk,
p.`name` producer,
i.`size`,
i.category,
+ it.categoryFk,
w.name warehouse,
SUM(IFNULL(sub.amount,0)) lack,
i.inkFk,
@@ -59,13 +63,15 @@ BEGIN
AND ic.display
AND it.code != 'GEN'
AND (vSelf IS NULL OR i.id = vSelf)
- AND (vLongname IS NULL OR i.name = vLongname)
+ AND (vLongname IS NULL OR i.longName LIKE CONCAT('%', vLongname, '%'))
AND (vProducerName IS NULL OR p.`name` LIKE CONCAT('%', vProducerName, '%'))
AND (vColor IS NULL OR vColor = i.inkFk)
AND (vSize IS NULL OR vSize = i.`size`)
AND (vOrigen IS NULL OR vOrigen = w.id)
AND (vLack IS NULL OR vLack = sub.amount)
AND (vWarehouseFk IS NULL OR vWarehouseFk = w.id)
+ AND (vCategoryFk IS NULL OR vCategoryFk = it.categoryFk)
+ AND (vTypeFk IS NULL OR vTypeFk = i.typeFk)
GROUP BY i.id, w.id
HAVING lack < 0;
diff --git a/db/routines/vn/procedures/report_print.sql b/db/routines/vn/procedures/report_print.sql
index a5e08538eb..17c0c921bb 100644
--- a/db/routines/vn/procedures/report_print.sql
+++ b/db/routines/vn/procedures/report_print.sql
@@ -1,83 +1,86 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`report_print`(
- vReportName VARCHAR(100),
- vPrinterFk INT,
- vUserFk INT,
- vParams JSON,
- vPriorityName VARCHAR(100)
- )
+ vReportName VARCHAR(100),
+ vPrinterFk INT,
+ vUserFk INT,
+ vParams JSON,
+ vPriorityName VARCHAR(100)
+)
BEGIN
-/**
- * Inserts in the print queue the report to be printed and the necessary parameters for this
- * one taking into account the paper size of both the printer and the report.
- *
- * @param vReportName the report to be printed.
- * @param vPrinterFk the printer selected.
- * @param vUserFk user id.
- * @param vParams JSON with report parameters.
- * @param vPriorityName the printing priority.
- */
- DECLARE vI INT DEFAULT 0;
- DECLARE vKeys TEXT DEFAULT JSON_KEYS(vParams);
- DECLARE vLength INT DEFAULT JSON_LENGTH(vKeys);
- DECLARE vKey VARCHAR(255);
- DECLARE vVal VARCHAR(255);
- DECLARE vPrintQueueFk INT;
- DECLARE vReportSize VARCHAR(255);
- DECLARE vIsThePrinterReal INT;
- DECLARE vPrinteSize VARCHAR(255);
- DECLARE vPriorityFk INT;
- DECLARE vReportFk INT;
- DECLARE EXIT HANDLER FOR SQLEXCEPTION
- BEGIN
- ROLLBACK;
- RESIGNAL;
- END;
+ /**
+ * Inserts in the print queue the report to be printed and the necessary parameters for this
+ * one taking into account the paper size of both the printer and the report.
+ *
+ * @param vReportName the report to be printed.
+ * @param vPrinterFk the printer selected.
+ * @param vUserFk user id.
+ * @param vParams JSON with report parameters.
+ * @param vPriorityName the printing priority.
+ */
+ DECLARE vI INT DEFAULT 0;
+ DECLARE vKeys TEXT DEFAULT JSON_KEYS(vParams);
+ DECLARE vLength INT DEFAULT JSON_LENGTH(vKeys);
+ DECLARE vKey VARCHAR(255);
+ DECLARE vVal VARCHAR(255);
+ DECLARE vPrintQueueFk INT;
+ DECLARE vReportSize VARCHAR(255);
+ DECLARE vIsThePrinterReal INT;
+ DECLARE vPrinterSize VARCHAR(255);
+ DECLARE vPriorityFk INT;
+ DECLARE vReportFk INT;
+ DECLARE vTx BOOLEAN DEFAULT NOT @@in_transaction;
- SELECT id, paperSizeFk INTO vReportFk, vReportSize
- FROM report
- WHERE name = vReportName;
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ CALL util.tx_rollback(vTx);
+ RESIGNAL;
+ END;
- SELECT id, paperSizeFk INTO vIsThePrinterReal, vPrinteSize
- FROM printer
- WHERE id = vPrinterFk;
- SELECT id INTO vPriorityFk
- FROM queuePriority
- WHERE code = vPriorityName;
+ SELECT id, paperSizeFk INTO vReportFk, vReportSize
+ FROM report
+ WHERE name = vReportName;
- IF vIsThePrinterReal IS NULL THEN
- CALL util.throw('printerNotExists');
- END IF;
+ SELECT id, paperSizeFk INTO vIsThePrinterReal, vPrinterSize
+ FROM printer
+ WHERE id = vPrinterFk;
- IF vReportFk IS NULL THEN
- CALL util.throw('reportNotExists');
- END IF;
+ SELECT id INTO vPriorityFk
+ FROM queuePriority
+ WHERE code = vPriorityName;
- IF vReportSize <> vPrinteSize THEN
- CALL util.throw('incorrectSize');
- END IF;
+ IF vIsThePrinterReal IS NULL THEN
+ CALL util.throw('printerNotExists');
+ END IF;
- START TRANSACTION;
- INSERT INTO printQueue
- SET printerFk = vPrinterFk,
- priorityFk = vPriorityFk,
- reportFk = vReportFk,
- workerFk = vUserFk;
-
- SET vPrintQueueFk = LAST_INSERT_ID();
+ IF vReportFk IS NULL THEN
+ CALL util.throw('reportNotExists');
+ END IF;
- WHILE vI < vLength DO
- SET vKey = JSON_VALUE(vKeys, CONCAT('$[', vI ,']'));
- SET vVal = JSON_VALUE(vParams, CONCAT('$.', vKey));
+ IF vReportSize <> vPrinterSize THEN
+ CALL util.throw('incorrectSize');
+ END IF;
+ CALL util.tx_start(vTx);
+ INSERT INTO printQueue
+ SET printerFk = vPrinterFk,
+ priorityFk = vPriorityFk,
+ reportFk = vReportFk,
+ workerFk = vUserFk;
- INSERT INTO printQueueArgs
- SET printQueueFk = vPrintQueueFk,
- name = vKey,
- value = vVal;
+ SET vPrintQueueFk = LAST_INSERT_ID();
- SET vI = vI + 1;
- END WHILE;
- COMMIT;
+ WHILE vI < vLength DO
+ SET vKey = JSON_VALUE(vKeys, CONCAT('$[', vI ,']'));
+ SET vVal = JSON_VALUE(vParams, CONCAT('$.', vKey));
+
+ INSERT INTO printQueueArgs
+ SET printQueueFk = vPrintQueueFk,
+ name = vKey,
+ value = vVal;
+
+ SET vI = vI + 1;
+ END WHILE;
+
+ CALL util.tx_commit(vTx);
END$$
DELIMITER ;
diff --git a/db/routines/vn/procedures/workerTimeControl_clockIn.sql b/db/routines/vn/procedures/workerTimeControl_clockIn.sql
index 522546918d..714d9637ae 100644
--- a/db/routines/vn/procedures/workerTimeControl_clockIn.sql
+++ b/db/routines/vn/procedures/workerTimeControl_clockIn.sql
@@ -18,14 +18,13 @@ BEGIN
* 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;
DECLARE vNextIn DATETIME;
DECLARE vNextOut DATETIME;
DECLARE vNextDirection ENUM('in', 'out');
DECLARE vLastDirection ENUM('in', 'out');
- DECLARE vDayMaxTime INTEGER;
+ DECLARE vDayMaxTime INTEGER;
DECLARE vDayBreak INT;
DECLARE vShortWeekBreak INT;
DECLARE vLongWeekBreak INT;
@@ -40,6 +39,7 @@ BEGIN
DECLARE vIsManual BOOLEAN DEFAULT TRUE;
DECLARE vMaxWorkShortCycle INT;
DECLARE vMaxWorkLongCycle INT;
+ DECLARE vReentryWaitTime TIME DEFAULT NULL;
DECLARE EXIT HANDLER FOR SQLSTATE '45000'
BEGIN
@@ -52,19 +52,19 @@ BEGIN
WHERE w.id = vWorkerFk;
SELECT `description` INTO vErrorMessage
- FROM workerTimeControlError
+ FROM workerTimeControlError
WHERE `code` = vErrorCode;
IF vErrorMessage IS NULL THEN
SET vErrorMessage = 'Error sin definir';
END IF;
- SELECT vErrorMessage `error`;
+ SELECT CONCAT(vErrorMessage, IFNULL(DATE_FORMAT(vReentryWaitTime, '%i:%s'), '')) `error`;
SELECT CONCAT(vUserName,
' no ha podido fichar por el siguiente problema: ',
vErrorMessage)
INTO vErrorMessage;
-
+
CALL mail_insert( vMailTo, vMailTo, 'Error al fichar', vErrorMessage);
END;
@@ -97,19 +97,19 @@ BEGIN
JOIN workerTimeControlConfig wc
WHERE b.workerFk = vWorkerFk
AND vDated BETWEEN b.started AND IFNULL(b.ended, vDated);
-
+
-- CONTRATO EN VIGOR
IF vDayBreak IS NULL THEN
SET vErrorCode = 'INACTIVE_BUSINESS';
CALL util.throw(vErrorCode);
END IF;
-
+
-- FICHADAS A FUTURO
IF vTimed > util.VN_NOW() + INTERVAL 1 MINUTE THEN
SET vErrorCode = 'IS_NOT_ALLOWED_FUTURE';
CALL util.throw(vErrorCode);
END IF;
-
+
-- VERIFICAR SI ESTÁ PERMITIDO TRABAJAR
CALL timeBusiness_calculateByWorker(vWorkerFk, vDated, vDated);
SELECT isAllowedToWork INTO vIsAllowedToWork
@@ -124,6 +124,16 @@ BEGIN
-- DIRECCION CORRECTA
CALL workerTimeControl_direction(vWorkerFk, vTimed);
+
+ SELECT reentryWaitTime INTO vReentryWaitTime
+ FROM tmp.workerTimeControlDirection
+ LIMIT 1;
+
+ IF vReentryWaitTime IS NOT NULL THEN
+ SET vErrorCode = 'WAIT_TIME';
+ CALL util.throw(vErrorCode);
+ END IF;
+
IF (SELECT
IF((IF(option1 IN ('inMiddle', 'outMiddle'),
'middle',
@@ -138,13 +148,13 @@ BEGIN
) THEN
SET vIsError = TRUE;
END IF;
-
-
+
+
IF vIsError THEN
SET vErrorCode = 'WRONG_DIRECTION';
IF(SELECT option1 IS NULL AND option2 IS NULL
FROM tmp.workerTimeControlDirection) THEN
-
+
SET vErrorCode = 'DAY_MAX_TIME';
END IF;
CALL util.throw(vErrorCode);
@@ -158,7 +168,7 @@ BEGIN
AND timed < vTimed
ORDER BY timed DESC
LIMIT 1;
-
+
IF (SELECT IF(vDirection = 'in',
MOD(COUNT(*), 2) ,
IF (vDirection = 'out', NOT MOD(COUNT(*), 2), FALSE))
@@ -169,7 +179,7 @@ BEGIN
SET vErrorCode = 'ODD_WORKERTIMECONTROL';
CALL util.throw(vErrorCode);
END IF;
-
+
-- DESCANSO DIARIO
SELECT timed INTO vLastOut
FROM workerTimeControl
@@ -178,7 +188,7 @@ BEGIN
AND timed < vTimed
ORDER BY timed DESC
LIMIT 1;
-
+
SELECT timed INTO vNextIn
FROM workerTimeControl
WHERE userFk = vWorkerFk
@@ -186,7 +196,7 @@ BEGIN
AND timed > vTimed
ORDER BY timed ASC
LIMIT 1;
-
+
CASE vDirection
WHEN 'in' THEN
IF UNIX_TIMESTAMP(vTimed) - UNIX_TIMESTAMP(vLastOut) <= vDayBreak THEN
@@ -204,11 +214,9 @@ BEGIN
CALL util.throw(vErrorCode);
END IF;
-
-
IF (vDirection IN('in', 'out')) THEN
-- VERIFICA MAXIMO TIEMPO DESDE ENTRADA HASTA LA SALIDA
-
+
SELECT timed INTO vNextOut
FROM workerTimeControl
WHERE userFk = vWorkerFk
@@ -216,7 +224,7 @@ BEGIN
AND timed > vTimed
ORDER BY timed ASC
LIMIT 1;
-
+
SELECT direction INTO vNextDirection
FROM workerTimeControl
WHERE userFk = vWorkerFk
@@ -224,7 +232,7 @@ BEGIN
AND timed > vTimed
ORDER BY timed ASC
LIMIT 1;
-
+
SELECT direction INTO vLastDirection
FROM workerTimeControl
WHERE userFk = vWorkerFk
@@ -232,34 +240,34 @@ BEGIN
AND timed < vTimed
ORDER BY timed ASC
LIMIT 1;
-
- IF (vDirection ='in'
- AND vNextDirection = 'out'
+
+ IF (vDirection ='in'
+ AND vNextDirection = 'out'
AND UNIX_TIMESTAMP(vNextOut) - UNIX_TIMESTAMP(vTimed) > vDayMaxTime) OR
- (vDirection ='out'
+ (vDirection ='out'
AND vLastDirection = 'in'
- AND UNIX_TIMESTAMP(vTimed) -UNIX_TIMESTAMP(vLastIn) > vDayMaxTime) THEN
+ AND UNIX_TIMESTAMP(vTimed) - UNIX_TIMESTAMP(vLastIn) > vDayMaxTime) THEN
SET vErrorCode = 'DAY_MAX_TIME';
CALL util.throw(vErrorCode);
END IF;
-
+
-- VERIFICA DESCANSO SEMANAL
-
+
WITH wtc AS(
- (SELECT timed
- FROM vn.workerTimeControl
+ (SELECT timed
+ FROM vn.workerTimeControl
WHERE userFk = vWorkerFk
AND direction IN ('in', 'out')
- AND timed BETWEEN vTimed - INTERVAL (vWeekScope * 2) SECOND
+ AND timed BETWEEN vTimed - INTERVAL (vWeekScope * 2) SECOND
AND vTimed + INTERVAL (vWeekScope * 2) SECOND )
- UNION
+ UNION
(SELECT vTimed)
), wtcGap AS(
SELECT timed,
- TIMESTAMPDIFF(SECOND, LAG(timed) OVER (ORDER BY timed), timed) gap
+ TIMESTAMPDIFF(SECOND, LAG(timed) OVER (ORDER BY timed), timed) gap
FROM wtc
ORDER BY timed
- ), wtcBreak AS(
+ ), wtcBreak AS(
SELECT timed,
IF(IFNULL(gap, 0) > vShortWeekBreak, TRUE, FALSE) hasShortBreak,
IF(IFNULL(gap, 0) > vLongWeekBreak, TRUE, FALSE) hasLongBreak
@@ -270,8 +278,8 @@ BEGIN
SUM(hasShortBreak) OVER (ORDER BY timed) breakCounter ,
LEAD(hasLongBreak) OVER (ORDER BY timed) nextHasLongBreak
FROM wtcBreak
- )SELECT TIMESTAMPDIFF(SECOND, MIN(timed), MAX(timed)) > vMaxWorkLongCycle OR
- (TIMESTAMPDIFF(SECOND, MIN(timed), MAX(timed))> vMaxWorkShortCycle
+ )SELECT TIMESTAMPDIFF(SECOND, MIN(timed), MAX(timed)) > vMaxWorkLongCycle OR
+ (TIMESTAMPDIFF(SECOND, MIN(timed), MAX(timed))> vMaxWorkShortCycle
AND NOT SUM(IFNULL(nextHasLongBreak, 1)))
hasError INTO vIsError
FROM wtcBreakCounter
@@ -291,5 +299,6 @@ BEGIN
SELECT LAST_INSERT_ID() id;
-END$$
+END
+$$
DELIMITER ;
diff --git a/db/routines/vn/procedures/workerTimeControl_direction.sql b/db/routines/vn/procedures/workerTimeControl_direction.sql
index 84db396cc4..70a7b40c0b 100644
--- a/db/routines/vn/procedures/workerTimeControl_direction.sql
+++ b/db/routines/vn/procedures/workerTimeControl_direction.sql
@@ -1,39 +1,45 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerTimeControl_direction`(vWorkerFk VARCHAR(10), vTimed DATETIME)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerTimeControl_direction`(
+ vWorkerFk VARCHAR(10),
+ vTimed DATETIME
+)
BEGIN
/**
- * Devuelve que direcciones de fichadas son lógicas a partir de la anterior fichada
+ * 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')
+ * @return tmp.workerTimeControlDirection(option1, option2, reentryWaitTime)
+ * Valores posibles options('in', 'inMiddle', 'outMiddle', 'out')
*/
- DECLARE vLastIn DATETIME ;
- DECLARE vIsMiddleOdd BOOLEAN ;
+ DECLARE vLastIn DATETIME;
+ DECLARE vLastMiddleIn DATETIME;
+ DECLARE vIsMiddleOdd BOOLEAN;
DECLARE vMailTo VARCHAR(50) DEFAULT NULL;
DECLARE vUserName VARCHAR(50) DEFAULT NULL;
+ DECLARE vReentryWaitTime TIME;
- IF (vTimed IS NULL) THEN
+ IF (vTimed IS NULL) THEN
SET vTimed = util.VN_NOW();
END IF;
-
+
SELECT timed INTO vLastIn
- FROM workerTimeControl
+ FROM workerTimeControl
WHERE userFk = vWorkerFk
- AND direction = 'in'
+ AND direction = 'in'
AND timed < vTimed
ORDER BY timed DESC
LIMIT 1;
-
+
SELECT (COUNT(*)mod 2 = 1) INTO vIsMiddleOdd
- FROM workerTimeControl
+ FROM workerTimeControl
WHERE userFk = vWorkerFk
- AND direction = 'middle'
+ AND direction = 'middle'
AND timed BETWEEN vLastIn AND vTimed;
DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControlDirection;
CREATE TEMPORARY TABLE tmp.workerTimeControlDirection
SELECT IF(isCorrect, option1, NULL) option1,
- IF(isCorrect, option2, NULL) option2
+ IF(isCorrect, option2, NULL) option2,
+ CAST(NULL AS TIME) reentryWaitTime
FROM( SELECT IF(w.direction <> 'out' AND (UNIX_TIMESTAMP(vTimed) - UNIX_TIMESTAMP(w.timed) > wc.dayBreak), FALSE, TRUE) isCorrect,
CASE WHEN w.direction ='in' THEN 'inMiddle'
WHEN w.direction = 'out' THEN 'in'
@@ -59,6 +65,26 @@ BEGIN
VALUES('in', NULL);
END IF;
+ IF (SELECT option1 ='outMiddle' AND option2 IS NULL FROM tmp.workerTimeControlDirection) THEN
+ SELECT timed INTO vLastMiddleIn
+ FROM workerTimeControl
+ WHERE userFk = vWorkerFk
+ AND timed < vTimed
+ ORDER BY timed DESC
+ LIMIT 1;
+
+ SELECT TIMEDIFF(vLastMiddleIn + INTERVAL wtc.maxTimeToBreak SECOND, vTimed) INTO vReentryWaitTime
+ FROM tmp.workerTimeControlDirection wt
+ JOIN workerTimeControlConfig wtc
+ WHERE TIME(vLastMiddleIn) BETWEEN wtc.mandatoryBreakFrom AND wtc.mandatoryBreakTo
+ AND TIMESTAMPDIFF(SECOND, vLastMiddleIn, vTimed) < wtc.maxTimeToBreak;
+
+ IF vReentryWaitTime THEN
+ UPDATE tmp.workerTimeControlDirection
+ SET reentryWaitTime = vReentryWaitTime;
+ END IF;
+ END IF;
+
IF (SELECT option1 IS NULL AND option2 IS NULL FROM tmp.workerTimeControlDirection) THEN
SELECT CONCAT(u.name, '@verdnatura.es'), CONCAT(w.firstName, ' ', w.lastName)
INTO vMailTo, vUserName
@@ -66,10 +92,10 @@ BEGIN
JOIN worker w ON w.bossFk = u.id
WHERE w.id = vWorkerFk;
- CALL mail_insert(
- vMailTo,
- vMailTo,
- 'Error al fichar',
+ CALL mail_insert(
+ vMailTo,
+ vMailTo,
+ 'Error al fichar',
CONCAT(vUserName, ' tiene problemas para fichar'));
END IF;
END$$
diff --git a/db/routines/vn/triggers/buy_beforeInsert.sql b/db/routines/vn/triggers/buy_beforeInsert.sql
index 9c10592661..112b35e416 100644
--- a/db/routines/vn/triggers/buy_beforeInsert.sql
+++ b/db/routines/vn/triggers/buy_beforeInsert.sql
@@ -22,6 +22,10 @@ trig: BEGIN
SET NEW.editorFk = account.myUser_getId();
+ IF NEW.life IS NULL THEN
+ SET NEW.life = item_getLife(NEW.itemFk);
+ END IF;
+
SELECT it.workerFk INTO vBuyerFk
FROM item i
JOIN itemType it ON it.id = i.typeFk
@@ -57,7 +61,7 @@ trig: BEGIN
IF NEW.groupingMode IS NULL THEN
SET NEW.groupingMode = vGroupingMode;
END IF;
-
+
-- Generics
SELECT i.genericFk INTO vGenericFk
FROM item i
@@ -78,7 +82,7 @@ trig: BEGIN
END IF;
IF NEW.quantity < 0 THEN
- SET NEW.isIgnored = TRUE;
+ SET NEW.isIgnored = TRUE;
END IF;
IF NEW.weight AND NEW.packing
diff --git a/db/routines/vn/triggers/buy_beforeUpdate.sql b/db/routines/vn/triggers/buy_beforeUpdate.sql
index c67d44f6f3..f3a672a479 100644
--- a/db/routines/vn/triggers/buy_beforeUpdate.sql
+++ b/db/routines/vn/triggers/buy_beforeUpdate.sql
@@ -25,6 +25,10 @@ trig:BEGIN
SET NEW.editorFk = account.myUser_getId();
+ IF NOT (NEW.itemFk <=> OLD.itemFk) AND NEW.life <=> OLD.life THEN
+ SET NEW.life = item_getLife(NEW.itemFk);
+ END IF;
+
SELECT defaultEntry INTO vDefaultEntry
FROM entryConfig;
diff --git a/db/routines/vn/triggers/claim_beforeInsert.sql b/db/routines/vn/triggers/claim_beforeInsert.sql
index dc3ef8c7a2..25d103c4cf 100644
--- a/db/routines/vn/triggers/claim_beforeInsert.sql
+++ b/db/routines/vn/triggers/claim_beforeInsert.sql
@@ -4,5 +4,9 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`claim_beforeInsert`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
+
+ IF (SELECT shipped FROM ticket WHERE id = NEW.ticketFk) > util.VN_NOW() THEN
+ CALL util.throw('Future ticket date not allowed');
+ END IF;
END$$
DELIMITER ;
diff --git a/db/routines/vn/triggers/travel_beforeInsert.sql b/db/routines/vn/triggers/travel_beforeInsert.sql
index 4997cc5fc8..874f1a8304 100644
--- a/db/routines/vn/triggers/travel_beforeInsert.sql
+++ b/db/routines/vn/triggers/travel_beforeInsert.sql
@@ -17,8 +17,14 @@ BEGIN
CALL travel_throwAwb(NEW.id);
END IF;
+ IF NEW.availabled IS NULL THEN
+ SET NEW.availabled = NEW.landed;
+ END IF;
+
IF NEW.availabled < NEW.landed THEN
SET NEW.availabled = NEW.landed;
END IF;
+
+
END$$
DELIMITER ;
diff --git a/db/routines/vn/triggers/travel_beforeUpdate.sql b/db/routines/vn/triggers/travel_beforeUpdate.sql
index 6efad4a658..2c78bf54eb 100644
--- a/db/routines/vn/triggers/travel_beforeUpdate.sql
+++ b/db/routines/vn/triggers/travel_beforeUpdate.sql
@@ -40,10 +40,10 @@ BEGIN
IF (NOT(NEW.awbFk <=> OLD.awbFk)) AND NEW.awbFk IS NOT NULL THEN
CALL travel_throwAwb(NEW.id);
END IF;
-
+
IF NEW.availabled < NEW.landed THEN
SET NEW.availabled = NEW.landed;
END IF;
-
+
END$$
DELIMITER ;
diff --git a/db/routines/vn2008/views/Agencias.sql b/db/routines/vn2008/views/Agencias.sql
index 1176d02c41..ae5a9e5103 100644
--- a/db/routines/vn2008/views/Agencias.sql
+++ b/db/routines/vn2008/views/Agencias.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Agencias`
AS SELECT `am`.`id` AS `Id_Agencia`,
diff --git a/db/routines/vn2008/views/Articles.sql b/db/routines/vn2008/views/Articles.sql
index 87f1b6d5ef..dd6b3a1963 100644
--- a/db/routines/vn2008/views/Articles.sql
+++ b/db/routines/vn2008/views/Articles.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Articles`
AS SELECT `i`.`id` AS `Id_Article`,
diff --git a/db/routines/vn2008/views/Bancos.sql b/db/routines/vn2008/views/Bancos.sql
index 6e850f365a..7f8d289f9f 100644
--- a/db/routines/vn2008/views/Bancos.sql
+++ b/db/routines/vn2008/views/Bancos.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Bancos`
AS SELECT `a`.`id` AS `Id_Banco`,
diff --git a/db/routines/vn2008/views/Bancos_poliza.sql b/db/routines/vn2008/views/Bancos_poliza.sql
index 4cd443545b..915f6a64d9 100644
--- a/db/routines/vn2008/views/Bancos_poliza.sql
+++ b/db/routines/vn2008/views/Bancos_poliza.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Bancos_poliza`
AS SELECT `bp`.`id` AS `poliza_id`,
diff --git a/db/routines/vn2008/views/Cajas.sql b/db/routines/vn2008/views/Cajas.sql
index 54b9ee1892..59b96a1cc1 100644
--- a/db/routines/vn2008/views/Cajas.sql
+++ b/db/routines/vn2008/views/Cajas.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Cajas`
AS SELECT `t`.`id` AS `Id_Caja`,
diff --git a/db/routines/vn2008/views/Clientes.sql b/db/routines/vn2008/views/Clientes.sql
index 9f8ef712e1..ef5d4e410f 100644
--- a/db/routines/vn2008/views/Clientes.sql
+++ b/db/routines/vn2008/views/Clientes.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Clientes`
AS SELECT `c`.`id` AS `id_cliente`,
diff --git a/db/routines/vn2008/views/Comparativa.sql b/db/routines/vn2008/views/Comparativa.sql
index 875a5c370e..92e8adf1fe 100644
--- a/db/routines/vn2008/views/Comparativa.sql
+++ b/db/routines/vn2008/views/Comparativa.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Comparativa`
AS SELECT `c`.`timePeriod` AS `Periodo`,
diff --git a/db/routines/vn2008/views/Compres.sql b/db/routines/vn2008/views/Compres.sql
index b99dd2b73c..786aef3cba 100644
--- a/db/routines/vn2008/views/Compres.sql
+++ b/db/routines/vn2008/views/Compres.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Compres`
AS SELECT `c`.`id` AS `Id_Compra`,
diff --git a/db/routines/vn2008/views/Consignatarios.sql b/db/routines/vn2008/views/Consignatarios.sql
index 13a426f4da..df7d07fb3c 100644
--- a/db/routines/vn2008/views/Consignatarios.sql
+++ b/db/routines/vn2008/views/Consignatarios.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Consignatarios`
AS SELECT `a`.`id` AS `id_consigna`,
diff --git a/db/routines/vn2008/views/Cubos.sql b/db/routines/vn2008/views/Cubos.sql
index 7ca82e66e8..c09376595e 100644
--- a/db/routines/vn2008/views/Cubos.sql
+++ b/db/routines/vn2008/views/Cubos.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Cubos`
AS SELECT `p`.`id` AS `Id_Cubo`,
diff --git a/db/routines/vn2008/views/Cubos_Retorno.sql b/db/routines/vn2008/views/Cubos_Retorno.sql
index bc56f275b0..152d72c99a 100644
--- a/db/routines/vn2008/views/Cubos_Retorno.sql
+++ b/db/routines/vn2008/views/Cubos_Retorno.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Cubos_Retorno`
AS SELECT `rb`.`id` AS `idCubos_Retorno`,
diff --git a/db/routines/vn2008/views/Entradas.sql b/db/routines/vn2008/views/Entradas.sql
index 78b73bb246..b6a029e57f 100644
--- a/db/routines/vn2008/views/Entradas.sql
+++ b/db/routines/vn2008/views/Entradas.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Entradas`
AS SELECT `e`.`id` AS `Id_Entrada`,
diff --git a/db/routines/vn2008/views/Entradas_orden.sql b/db/routines/vn2008/views/Entradas_orden.sql
index 66f46a929b..ddc2948486 100644
--- a/db/routines/vn2008/views/Entradas_orden.sql
+++ b/db/routines/vn2008/views/Entradas_orden.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Entradas_orden`
AS SELECT `eo`.`entryFk` AS `Id_Entrada`,
diff --git a/db/routines/vn2008/views/Impresoras.sql b/db/routines/vn2008/views/Impresoras.sql
index c4782ab72a..76118af1e1 100644
--- a/db/routines/vn2008/views/Impresoras.sql
+++ b/db/routines/vn2008/views/Impresoras.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Impresoras`
AS SELECT `vn`.`printer`.`id` AS `Id_impresora`,
diff --git a/db/routines/vn2008/views/Monedas.sql b/db/routines/vn2008/views/Monedas.sql
index 3693885be2..88a2cf495a 100644
--- a/db/routines/vn2008/views/Monedas.sql
+++ b/db/routines/vn2008/views/Monedas.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Monedas`
AS SELECT `c`.`id` AS `Id_Moneda`,
diff --git a/db/routines/vn2008/views/Movimientos.sql b/db/routines/vn2008/views/Movimientos.sql
index da41c51bb5..458ae4d48d 100644
--- a/db/routines/vn2008/views/Movimientos.sql
+++ b/db/routines/vn2008/views/Movimientos.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Movimientos`
AS SELECT `m`.`id` AS `Id_Movimiento`,
diff --git a/db/routines/vn2008/views/Movimientos_componentes.sql b/db/routines/vn2008/views/Movimientos_componentes.sql
index 440fbfb6af..a88e5f7d1b 100644
--- a/db/routines/vn2008/views/Movimientos_componentes.sql
+++ b/db/routines/vn2008/views/Movimientos_componentes.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Movimientos_componentes`
AS SELECT `sc`.`saleFk` AS `Id_Movimiento`,
diff --git a/db/routines/vn2008/views/Movimientos_mark.sql b/db/routines/vn2008/views/Movimientos_mark.sql
index 10ef2fc086..cc42e565e8 100644
--- a/db/routines/vn2008/views/Movimientos_mark.sql
+++ b/db/routines/vn2008/views/Movimientos_mark.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Movimientos_mark`
AS SELECT `mm`.`saleFk` AS `Id_Movimiento`,
diff --git a/db/routines/vn2008/views/Ordenes.sql b/db/routines/vn2008/views/Ordenes.sql
index de31f8f99c..a8266ab98f 100644
--- a/db/routines/vn2008/views/Ordenes.sql
+++ b/db/routines/vn2008/views/Ordenes.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Ordenes`
AS SELECT `tr`.`id` AS `Id_ORDEN`,
diff --git a/db/routines/vn2008/views/Origen.sql b/db/routines/vn2008/views/Origen.sql
index 5bb1d9b7fa..58658a1af7 100644
--- a/db/routines/vn2008/views/Origen.sql
+++ b/db/routines/vn2008/views/Origen.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Origen`
AS SELECT `o`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/Paises.sql b/db/routines/vn2008/views/Paises.sql
index 99d2835f06..72636de442 100644
--- a/db/routines/vn2008/views/Paises.sql
+++ b/db/routines/vn2008/views/Paises.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Paises`
AS SELECT `c`.`id` AS `Id`,
diff --git a/db/routines/vn2008/views/PreciosEspeciales.sql b/db/routines/vn2008/views/PreciosEspeciales.sql
index cea9f87fd8..a175035330 100644
--- a/db/routines/vn2008/views/PreciosEspeciales.sql
+++ b/db/routines/vn2008/views/PreciosEspeciales.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`PreciosEspeciales`
AS SELECT `sp`.`id` AS `Id_PrecioEspecial`,
diff --git a/db/routines/vn2008/views/Proveedores.sql b/db/routines/vn2008/views/Proveedores.sql
index 203d4295f3..293732d236 100644
--- a/db/routines/vn2008/views/Proveedores.sql
+++ b/db/routines/vn2008/views/Proveedores.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Proveedores`
AS SELECT `s`.`id` AS `Id_Proveedor`,
diff --git a/db/routines/vn2008/views/Proveedores_cargueras.sql b/db/routines/vn2008/views/Proveedores_cargueras.sql
index c1dc6ad236..4ff9bd6278 100644
--- a/db/routines/vn2008/views/Proveedores_cargueras.sql
+++ b/db/routines/vn2008/views/Proveedores_cargueras.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Proveedores_cargueras`
AS SELECT `fs`.`supplierFk` AS `Id_Proveedor`
diff --git a/db/routines/vn2008/views/Proveedores_gestdoc.sql b/db/routines/vn2008/views/Proveedores_gestdoc.sql
index c25623b8b0..1a27f7a7db 100644
--- a/db/routines/vn2008/views/Proveedores_gestdoc.sql
+++ b/db/routines/vn2008/views/Proveedores_gestdoc.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Proveedores_gestdoc`
AS SELECT `sd`.`supplierFk` AS `Id_Proveedor`,
diff --git a/db/routines/vn2008/views/Recibos.sql b/db/routines/vn2008/views/Recibos.sql
index 93ec7bc6fe..8b710cb230 100644
--- a/db/routines/vn2008/views/Recibos.sql
+++ b/db/routines/vn2008/views/Recibos.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Recibos`
AS SELECT `r`.`Id` AS `Id`,
diff --git a/db/routines/vn2008/views/Remesas.sql b/db/routines/vn2008/views/Remesas.sql
index 9e8c18ada6..2986ec6f25 100644
--- a/db/routines/vn2008/views/Remesas.sql
+++ b/db/routines/vn2008/views/Remesas.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Remesas`
AS SELECT `r`.`id` AS `Id_Remesa`,
diff --git a/db/routines/vn2008/views/Rutas.sql b/db/routines/vn2008/views/Rutas.sql
index c8ade24e94..eabfbfd724 100644
--- a/db/routines/vn2008/views/Rutas.sql
+++ b/db/routines/vn2008/views/Rutas.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Rutas`
AS SELECT `r`.`id` AS `Id_Ruta`,
diff --git a/db/routines/vn2008/views/Split.sql b/db/routines/vn2008/views/Split.sql
index eec90a5f8e..812cec8fe1 100644
--- a/db/routines/vn2008/views/Split.sql
+++ b/db/routines/vn2008/views/Split.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Splits`
AS SELECT `s`.`id` AS `Id_Split`,
diff --git a/db/routines/vn2008/views/Tickets.sql b/db/routines/vn2008/views/Tickets.sql
index 59dcb91006..18646dbaba 100644
--- a/db/routines/vn2008/views/Tickets.sql
+++ b/db/routines/vn2008/views/Tickets.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Tickets`
AS SELECT `t`.`id` AS `Id_Ticket`,
diff --git a/db/routines/vn2008/views/Tickets_state.sql b/db/routines/vn2008/views/Tickets_state.sql
index be59a750f3..fbbc00170f 100644
--- a/db/routines/vn2008/views/Tickets_state.sql
+++ b/db/routines/vn2008/views/Tickets_state.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Tickets_state`
AS SELECT `t`.`ticketFk` AS `Id_Ticket`,
diff --git a/db/routines/vn2008/views/Tickets_turno.sql b/db/routines/vn2008/views/Tickets_turno.sql
index 28bc2d55fa..6d16a57804 100644
--- a/db/routines/vn2008/views/Tickets_turno.sql
+++ b/db/routines/vn2008/views/Tickets_turno.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Tickets_turno`
AS SELECT `tw`.`ticketFk` AS `Id_Ticket`,
diff --git a/db/routines/vn2008/views/Tintas.sql b/db/routines/vn2008/views/Tintas.sql
index 2299aa759a..729cfa9d6c 100644
--- a/db/routines/vn2008/views/Tintas.sql
+++ b/db/routines/vn2008/views/Tintas.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Tintas`
AS SELECT `i`.`id` AS `Id_Tinta`,
diff --git a/db/routines/vn2008/views/Tipos.sql b/db/routines/vn2008/views/Tipos.sql
index 5b96c1766c..5a99e2aca3 100644
--- a/db/routines/vn2008/views/Tipos.sql
+++ b/db/routines/vn2008/views/Tipos.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Tipos`
AS SELECT `it`.`id` AS `tipo_id`,
diff --git a/db/routines/vn2008/views/Trabajadores.sql b/db/routines/vn2008/views/Trabajadores.sql
index 72b53e54e3..a5c8353d2b 100644
--- a/db/routines/vn2008/views/Trabajadores.sql
+++ b/db/routines/vn2008/views/Trabajadores.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Trabajadores`
AS SELECT `w`.`id` AS `Id_Trabajador`,
diff --git a/db/routines/vn2008/views/Tramos.sql b/db/routines/vn2008/views/Tramos.sql
index 6919a610b2..a9847a1b15 100644
--- a/db/routines/vn2008/views/Tramos.sql
+++ b/db/routines/vn2008/views/Tramos.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Tramos`
AS SELECT `s`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/V_edi_item_track.sql b/db/routines/vn2008/views/V_edi_item_track.sql
index 64cfdc1c58..8e01827194 100644
--- a/db/routines/vn2008/views/V_edi_item_track.sql
+++ b/db/routines/vn2008/views/V_edi_item_track.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`V_edi_item_track`
AS SELECT `edi`.`item_track`.`item_id` AS `item_id`,
diff --git a/db/routines/vn2008/views/Vehiculos_consumo.sql b/db/routines/vn2008/views/Vehiculos_consumo.sql
index 422a774994..2808371c70 100644
--- a/db/routines/vn2008/views/Vehiculos_consumo.sql
+++ b/db/routines/vn2008/views/Vehiculos_consumo.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Vehiculos_consumo`
AS SELECT `vc`.`id` AS `Vehiculos_consumo_id`,
diff --git a/db/routines/vn2008/views/account_conciliacion.sql b/db/routines/vn2008/views/account_conciliacion.sql
index 66db78eee6..e652648f58 100644
--- a/db/routines/vn2008/views/account_conciliacion.sql
+++ b/db/routines/vn2008/views/account_conciliacion.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`account_conciliacion`
AS SELECT `ar`.`id` AS `idaccount_conciliacion`,
diff --git a/db/routines/vn2008/views/account_detail.sql b/db/routines/vn2008/views/account_detail.sql
index 74d35ae41a..874f1f90cf 100644
--- a/db/routines/vn2008/views/account_detail.sql
+++ b/db/routines/vn2008/views/account_detail.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`account_detail`
AS SELECT `ac`.`id` AS `account_detail_id`,
diff --git a/db/routines/vn2008/views/account_detail_type.sql b/db/routines/vn2008/views/account_detail_type.sql
index 6def86a9a6..5f6f22cd92 100644
--- a/db/routines/vn2008/views/account_detail_type.sql
+++ b/db/routines/vn2008/views/account_detail_type.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`account_detail_type`
AS SELECT `adt`.`id` AS `account_detail_type_id`,
diff --git a/db/routines/vn2008/views/agency.sql b/db/routines/vn2008/views/agency.sql
index 637bb09101..015149e605 100644
--- a/db/routines/vn2008/views/agency.sql
+++ b/db/routines/vn2008/views/agency.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`agency`
AS SELECT `a`.`id` AS `agency_id`,
diff --git a/db/routines/vn2008/views/airline.sql b/db/routines/vn2008/views/airline.sql
index 786206b1c1..364e61ab16 100644
--- a/db/routines/vn2008/views/airline.sql
+++ b/db/routines/vn2008/views/airline.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`airline`
AS SELECT `a`.`id` AS `airline_id`,
diff --git a/db/routines/vn2008/views/airport.sql b/db/routines/vn2008/views/airport.sql
index 0e8ab39d29..3e4238e51e 100644
--- a/db/routines/vn2008/views/airport.sql
+++ b/db/routines/vn2008/views/airport.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`airport`
AS SELECT `a`.`id` AS `airport_id`,
diff --git a/db/routines/vn2008/views/albaran.sql b/db/routines/vn2008/views/albaran.sql
index b1055ff56a..1851834cd4 100644
--- a/db/routines/vn2008/views/albaran.sql
+++ b/db/routines/vn2008/views/albaran.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`albaran`
AS SELECT `dn`.`id` AS `albaran_id`,
diff --git a/db/routines/vn2008/views/albaran_gestdoc.sql b/db/routines/vn2008/views/albaran_gestdoc.sql
index ffde86937d..d4d0ecbce5 100644
--- a/db/routines/vn2008/views/albaran_gestdoc.sql
+++ b/db/routines/vn2008/views/albaran_gestdoc.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`albaran_gestdoc`
AS SELECT `dnd`.`dmsFk` AS `gestdoc_id`,
diff --git a/db/routines/vn2008/views/albaran_state.sql b/db/routines/vn2008/views/albaran_state.sql
index a15938f45d..03056d7f07 100644
--- a/db/routines/vn2008/views/albaran_state.sql
+++ b/db/routines/vn2008/views/albaran_state.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`albaran_state`
AS SELECT `dn`.`id` AS `albaran_state_id`,
diff --git a/db/routines/vn2008/views/awb.sql b/db/routines/vn2008/views/awb.sql
index a325718888..c37a425b75 100644
--- a/db/routines/vn2008/views/awb.sql
+++ b/db/routines/vn2008/views/awb.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`awb`
AS SELECT `a`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/awb_component.sql b/db/routines/vn2008/views/awb_component.sql
index 8053c4a590..39eec27332 100644
--- a/db/routines/vn2008/views/awb_component.sql
+++ b/db/routines/vn2008/views/awb_component.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`awb_component`
AS SELECT `ac`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/awb_component_template.sql b/db/routines/vn2008/views/awb_component_template.sql
index bc8fd1cd8f..cdf178fe17 100644
--- a/db/routines/vn2008/views/awb_component_template.sql
+++ b/db/routines/vn2008/views/awb_component_template.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`awb_component_template`
AS SELECT`act`.`id` AS `awb_component_template_id`,
diff --git a/db/routines/vn2008/views/awb_component_type.sql b/db/routines/vn2008/views/awb_component_type.sql
index 45921e11cb..f65df513ff 100644
--- a/db/routines/vn2008/views/awb_component_type.sql
+++ b/db/routines/vn2008/views/awb_component_type.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`awb_component_type`
AS SELECT `act`.`id` AS `awb_component_type_id`,
diff --git a/db/routines/vn2008/views/awb_gestdoc.sql b/db/routines/vn2008/views/awb_gestdoc.sql
index 6b5c58d56a..16715ce6b7 100644
--- a/db/routines/vn2008/views/awb_gestdoc.sql
+++ b/db/routines/vn2008/views/awb_gestdoc.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`awb_gestdoc`
AS SELECT `ad`.`id` AS `awb_gestdoc_id`,
diff --git a/db/routines/vn2008/views/awb_recibida.sql b/db/routines/vn2008/views/awb_recibida.sql
index c7586214d1..9f04e0e35e 100644
--- a/db/routines/vn2008/views/awb_recibida.sql
+++ b/db/routines/vn2008/views/awb_recibida.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`awb_recibida`
AS SELECT `aii`.`awbFk` AS `awb_id`,
diff --git a/db/routines/vn2008/views/awb_role.sql b/db/routines/vn2008/views/awb_role.sql
index 5ef0042445..3905ee5722 100644
--- a/db/routines/vn2008/views/awb_role.sql
+++ b/db/routines/vn2008/views/awb_role.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`awb_role`
AS SELECT `ar`.`id` AS `awb_role_id`,
diff --git a/db/routines/vn2008/views/awb_unit.sql b/db/routines/vn2008/views/awb_unit.sql
index 7d1193105b..28ad75204a 100644
--- a/db/routines/vn2008/views/awb_unit.sql
+++ b/db/routines/vn2008/views/awb_unit.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`awb_unit`
AS SELECT `au`.`id` AS `awb_unit_id`,
diff --git a/db/routines/vn2008/views/balance_nest_tree.sql b/db/routines/vn2008/views/balance_nest_tree.sql
index 66d048d7f6..e232edba82 100644
--- a/db/routines/vn2008/views/balance_nest_tree.sql
+++ b/db/routines/vn2008/views/balance_nest_tree.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`balance_nest_tree`
AS SELECT `bnt`.`lft` AS `lft`,
diff --git a/db/routines/vn2008/views/barcodes.sql b/db/routines/vn2008/views/barcodes.sql
index f366e15fa0..8cf8be064a 100644
--- a/db/routines/vn2008/views/barcodes.sql
+++ b/db/routines/vn2008/views/barcodes.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`barcodes`
AS SELECT `b`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/buySource.sql b/db/routines/vn2008/views/buySource.sql
index 8504838330..d6db662a7a 100644
--- a/db/routines/vn2008/views/buySource.sql
+++ b/db/routines/vn2008/views/buySource.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`buySource`
AS SELECT `b`.`entryFk` AS `Id_Entrada`,
diff --git a/db/routines/vn2008/views/buy_edi.sql b/db/routines/vn2008/views/buy_edi.sql
index d00196e95b..85e4a6b28a 100644
--- a/db/routines/vn2008/views/buy_edi.sql
+++ b/db/routines/vn2008/views/buy_edi.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`buy_edi`
AS SELECT `t`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/buy_edi_k012.sql b/db/routines/vn2008/views/buy_edi_k012.sql
index 8ef89e5c9f..790e330790 100644
--- a/db/routines/vn2008/views/buy_edi_k012.sql
+++ b/db/routines/vn2008/views/buy_edi_k012.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`buy_edi_k012`
AS SELECT `eek`.`id` AS `buy_edi_k012_id`,
diff --git a/db/routines/vn2008/views/buy_edi_k03.sql b/db/routines/vn2008/views/buy_edi_k03.sql
index 04ca10ef55..aef0fb391e 100644
--- a/db/routines/vn2008/views/buy_edi_k03.sql
+++ b/db/routines/vn2008/views/buy_edi_k03.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`buy_edi_k03`
AS SELECT `eek`.`id` AS `buy_edi_k03_id`,
diff --git a/db/routines/vn2008/views/buy_edi_k04.sql b/db/routines/vn2008/views/buy_edi_k04.sql
index 3c32e3b88b..e207e4317c 100644
--- a/db/routines/vn2008/views/buy_edi_k04.sql
+++ b/db/routines/vn2008/views/buy_edi_k04.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`buy_edi_k04`
AS SELECT `eek`.`id` AS `buy_edi_k04_id`,
diff --git a/db/routines/vn2008/views/cdr.sql b/db/routines/vn2008/views/cdr.sql
index 9d0d2f1720..d13c7dd32b 100644
--- a/db/routines/vn2008/views/cdr.sql
+++ b/db/routines/vn2008/views/cdr.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`cdr`
AS SELECT `c`.`call_date` AS `calldate`,
diff --git a/db/routines/vn2008/views/chanel.sql b/db/routines/vn2008/views/chanel.sql
index 9d2ed0d9c6..0480ca5881 100644
--- a/db/routines/vn2008/views/chanel.sql
+++ b/db/routines/vn2008/views/chanel.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`chanel`
AS SELECT `c`.`id` AS `chanel_id`,
diff --git a/db/routines/vn2008/views/cl_act.sql b/db/routines/vn2008/views/cl_act.sql
index a62ac3efe9..9678d2fbbd 100644
--- a/db/routines/vn2008/views/cl_act.sql
+++ b/db/routines/vn2008/views/cl_act.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`cl_act`
AS SELECT `c`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/cl_cau.sql b/db/routines/vn2008/views/cl_cau.sql
index a835a94c95..8bb352710e 100644
--- a/db/routines/vn2008/views/cl_cau.sql
+++ b/db/routines/vn2008/views/cl_cau.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`cl_cau`
AS SELECT `c`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/cl_con.sql b/db/routines/vn2008/views/cl_con.sql
index b4f596d566..c224a01aa9 100644
--- a/db/routines/vn2008/views/cl_con.sql
+++ b/db/routines/vn2008/views/cl_con.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`cl_con`
AS SELECT `c`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/cl_det.sql b/db/routines/vn2008/views/cl_det.sql
index cef5c821d3..80c87c51ea 100644
--- a/db/routines/vn2008/views/cl_det.sql
+++ b/db/routines/vn2008/views/cl_det.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`cl_det`
AS SELECT `c`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/cl_main.sql b/db/routines/vn2008/views/cl_main.sql
index ef0c2cb8ab..04d0e10cdd 100644
--- a/db/routines/vn2008/views/cl_main.sql
+++ b/db/routines/vn2008/views/cl_main.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`cl_main`
AS SELECT `c`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/cl_mot.sql b/db/routines/vn2008/views/cl_mot.sql
index 60fb27041f..6dfdb702af 100644
--- a/db/routines/vn2008/views/cl_mot.sql
+++ b/db/routines/vn2008/views/cl_mot.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`cl_mot`
AS SELECT `c`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/cl_res.sql b/db/routines/vn2008/views/cl_res.sql
index e82ee73b0d..31c1da6c18 100644
--- a/db/routines/vn2008/views/cl_res.sql
+++ b/db/routines/vn2008/views/cl_res.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`cl_res`
AS SELECT `c`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/cl_sol.sql b/db/routines/vn2008/views/cl_sol.sql
index 23f2b8594e..3321ce0e4f 100644
--- a/db/routines/vn2008/views/cl_sol.sql
+++ b/db/routines/vn2008/views/cl_sol.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`cl_sol`
AS SELECT `c`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/config_host.sql b/db/routines/vn2008/views/config_host.sql
index 2d4d6fa4c0..b9dbaae359 100644
--- a/db/routines/vn2008/views/config_host.sql
+++ b/db/routines/vn2008/views/config_host.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`config_host`
AS SELECT `vn`.`host`.`code` AS `config_host_id`,
diff --git a/db/routines/vn2008/views/consignatarios_observation.sql b/db/routines/vn2008/views/consignatarios_observation.sql
index 1f4c2eeb22..13bbe431a2 100644
--- a/db/routines/vn2008/views/consignatarios_observation.sql
+++ b/db/routines/vn2008/views/consignatarios_observation.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`consignatarios_observation`
AS SELECT `co`.`id` AS `consignatarios_observation_id`,
diff --git a/db/routines/vn2008/views/credit.sql b/db/routines/vn2008/views/credit.sql
index 0de60b9679..e1f71e267d 100644
--- a/db/routines/vn2008/views/credit.sql
+++ b/db/routines/vn2008/views/credit.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`credit`
AS SELECT
diff --git a/db/routines/vn2008/views/definitivo.sql b/db/routines/vn2008/views/definitivo.sql
index 1bc5541614..397b33dbd6 100644
--- a/db/routines/vn2008/views/definitivo.sql
+++ b/db/routines/vn2008/views/definitivo.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`definitivo`
AS SELECT `d`.`id` AS `definitivo_id`,
diff --git a/db/routines/vn2008/views/edi_article.sql b/db/routines/vn2008/views/edi_article.sql
index 34bb641498..68c7a581a1 100644
--- a/db/routines/vn2008/views/edi_article.sql
+++ b/db/routines/vn2008/views/edi_article.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`edi_article`
AS SELECT `edi`.`item`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/edi_bucket.sql b/db/routines/vn2008/views/edi_bucket.sql
index 1af487a6c0..0d744e6a73 100644
--- a/db/routines/vn2008/views/edi_bucket.sql
+++ b/db/routines/vn2008/views/edi_bucket.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`edi_bucket`
AS SELECT cast(
diff --git a/db/routines/vn2008/views/edi_bucket_type.sql b/db/routines/vn2008/views/edi_bucket_type.sql
index 8e3af20801..845124d495 100644
--- a/db/routines/vn2008/views/edi_bucket_type.sql
+++ b/db/routines/vn2008/views/edi_bucket_type.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`edi_bucket_type`
AS SELECT `edi`.`bucket_type`.`bucket_type_id` AS `bucket_type_id`,
diff --git a/db/routines/vn2008/views/edi_specie.sql b/db/routines/vn2008/views/edi_specie.sql
index 33e38482ed..c25a5601c9 100644
--- a/db/routines/vn2008/views/edi_specie.sql
+++ b/db/routines/vn2008/views/edi_specie.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`edi_specie`
AS SELECT `edi`.`specie`.`specie_id` AS `specie_id`,
diff --git a/db/routines/vn2008/views/edi_supplier.sql b/db/routines/vn2008/views/edi_supplier.sql
index 51f96b83d6..d7dd6c3538 100644
--- a/db/routines/vn2008/views/edi_supplier.sql
+++ b/db/routines/vn2008/views/edi_supplier.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`edi_supplier`
AS SELECT `edi`.`supplier`.`supplier_id` AS `supplier_id`,
diff --git a/db/routines/vn2008/views/empresa.sql b/db/routines/vn2008/views/empresa.sql
index 8c80a06e82..6c93cb910a 100644
--- a/db/routines/vn2008/views/empresa.sql
+++ b/db/routines/vn2008/views/empresa.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`empresa`
AS SELECT `c`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/empresa_grupo.sql b/db/routines/vn2008/views/empresa_grupo.sql
index 35ba272793..a626f2c60d 100644
--- a/db/routines/vn2008/views/empresa_grupo.sql
+++ b/db/routines/vn2008/views/empresa_grupo.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`empresa_grupo`
AS SELECT `vn`.`companyGroup`.`id` AS `empresa_grupo_id`,
diff --git a/db/routines/vn2008/views/entrySource.sql b/db/routines/vn2008/views/entrySource.sql
index 7326036177..25909de5c9 100644
--- a/db/routines/vn2008/views/entrySource.sql
+++ b/db/routines/vn2008/views/entrySource.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`entrySource`
AS SELECT `e`.`gestDocFk` AS `gestdoc_id`,
@@ -31,7 +31,8 @@ AS SELECT `e`.`gestDocFk` AS `gestdoc_id`,
`e`.`invoiceAmount` AS `invoiceAmount`,
`w`.`code` AS `buyerCode`,
`e`.`typeFk` AS `typeFk`,
- `w3`.`code` AS `observationWorkerCode`
+ `w3`.`code` AS `observationWorkerCode`,
+ `tr`.`availabled`
FROM (
(
(
diff --git a/db/routines/vn2008/views/financialProductType.sql b/db/routines/vn2008/views/financialProductType.sql
index 89a0638569..10a8ece21e 100644
--- a/db/routines/vn2008/views/financialProductType.sql
+++ b/db/routines/vn2008/views/financialProductType.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`financialProductType`AS
SELECT * FROM vn.financialProductType;
\ No newline at end of file
diff --git a/db/routines/vn2008/views/flight.sql b/db/routines/vn2008/views/flight.sql
index 2df5362f77..194cb5a94d 100644
--- a/db/routines/vn2008/views/flight.sql
+++ b/db/routines/vn2008/views/flight.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`flight`
AS SELECT
diff --git a/db/routines/vn2008/views/gastos_resumen.sql b/db/routines/vn2008/views/gastos_resumen.sql
index d40d6d229c..8db91c1b60 100644
--- a/db/routines/vn2008/views/gastos_resumen.sql
+++ b/db/routines/vn2008/views/gastos_resumen.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`gastos_resumen`
AS SELECT
diff --git a/db/routines/vn2008/views/integra2.sql b/db/routines/vn2008/views/integra2.sql
index 05840d6bbd..cb0847e8a5 100644
--- a/db/routines/vn2008/views/integra2.sql
+++ b/db/routines/vn2008/views/integra2.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`integra2`
AS SELECT
diff --git a/db/routines/vn2008/views/integra2_province.sql b/db/routines/vn2008/views/integra2_province.sql
index bc099adb32..f0a5e13ee4 100644
--- a/db/routines/vn2008/views/integra2_province.sql
+++ b/db/routines/vn2008/views/integra2_province.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`integra2_province`
AS SELECT
diff --git a/db/routines/vn2008/views/mail.sql b/db/routines/vn2008/views/mail.sql
index 3074dfa95d..c0d4de6026 100644
--- a/db/routines/vn2008/views/mail.sql
+++ b/db/routines/vn2008/views/mail.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`mail`
AS SELECT `m`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/mandato.sql b/db/routines/vn2008/views/mandato.sql
index dde43b48dc..a2dbc4be62 100644
--- a/db/routines/vn2008/views/mandato.sql
+++ b/db/routines/vn2008/views/mandato.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`mandato`
AS SELECT `m`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/mandato_tipo.sql b/db/routines/vn2008/views/mandato_tipo.sql
index bc3f746328..b2c5a3990c 100644
--- a/db/routines/vn2008/views/mandato_tipo.sql
+++ b/db/routines/vn2008/views/mandato_tipo.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`mandato_tipo`
AS SELECT `m`.`id` AS `idmandato_tipo`,
diff --git a/db/routines/vn2008/views/pago.sql b/db/routines/vn2008/views/pago.sql
index 546496070b..08506afda7 100644
--- a/db/routines/vn2008/views/pago.sql
+++ b/db/routines/vn2008/views/pago.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`pago`
AS SELECT `p`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/pago_sdc.sql b/db/routines/vn2008/views/pago_sdc.sql
index 29480e3769..ef75741fb2 100644
--- a/db/routines/vn2008/views/pago_sdc.sql
+++ b/db/routines/vn2008/views/pago_sdc.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`pago_sdc`
AS SELECT `ei`.`id` AS `pago_sdc_id`,
diff --git a/db/routines/vn2008/views/pay_dem.sql b/db/routines/vn2008/views/pay_dem.sql
index 1ef00d645d..55468d6e33 100644
--- a/db/routines/vn2008/views/pay_dem.sql
+++ b/db/routines/vn2008/views/pay_dem.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`pay_dem`
AS SELECT `pd`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/pay_dem_det.sql b/db/routines/vn2008/views/pay_dem_det.sql
index 822897ed85..b9b4485d93 100644
--- a/db/routines/vn2008/views/pay_dem_det.sql
+++ b/db/routines/vn2008/views/pay_dem_det.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`pay_dem_det`
AS SELECT `pdd`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/pay_met.sql b/db/routines/vn2008/views/pay_met.sql
index 63e2b30e06..c64d01ce47 100644
--- a/db/routines/vn2008/views/pay_met.sql
+++ b/db/routines/vn2008/views/pay_met.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`pay_met`
AS SELECT `pm`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/payrollWorker.sql b/db/routines/vn2008/views/payrollWorker.sql
index 6199e98b89..7557d61ec5 100644
--- a/db/routines/vn2008/views/payrollWorker.sql
+++ b/db/routines/vn2008/views/payrollWorker.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`payroll_employee` AS
SELECT
diff --git a/db/routines/vn2008/views/payroll_categorias.sql b/db/routines/vn2008/views/payroll_categorias.sql
index b71e69019f..b1eb5f5960 100644
--- a/db/routines/vn2008/views/payroll_categorias.sql
+++ b/db/routines/vn2008/views/payroll_categorias.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`payroll_categorias`
AS SELECT `pc`.`id` AS `codcategoria`,
diff --git a/db/routines/vn2008/views/payroll_centros.sql b/db/routines/vn2008/views/payroll_centros.sql
index b7e162f906..2160234671 100644
--- a/db/routines/vn2008/views/payroll_centros.sql
+++ b/db/routines/vn2008/views/payroll_centros.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`payroll_centros`
AS SELECT `pwc`.`workCenterFkA3` AS `cod_centro`,
diff --git a/db/routines/vn2008/views/payroll_conceptos.sql b/db/routines/vn2008/views/payroll_conceptos.sql
index a7c6ece5bd..e96ca1d29f 100644
--- a/db/routines/vn2008/views/payroll_conceptos.sql
+++ b/db/routines/vn2008/views/payroll_conceptos.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`payroll_conceptos`
AS SELECT `pc`.`id` AS `conceptoid`,
diff --git a/db/routines/vn2008/views/plantpassport.sql b/db/routines/vn2008/views/plantpassport.sql
index b1be6a80b2..c983fab0a8 100644
--- a/db/routines/vn2008/views/plantpassport.sql
+++ b/db/routines/vn2008/views/plantpassport.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`plantpassport`
AS SELECT `pp`.`producerFk` AS `producer_id`,
diff --git a/db/routines/vn2008/views/plantpassport_authority.sql b/db/routines/vn2008/views/plantpassport_authority.sql
index 4548bbeded..b8566a8f3a 100644
--- a/db/routines/vn2008/views/plantpassport_authority.sql
+++ b/db/routines/vn2008/views/plantpassport_authority.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`plantpassport_authority`
AS SELECT `ppa`.`id` AS `plantpassport_authority_id`,
diff --git a/db/routines/vn2008/views/price_fixed.sql b/db/routines/vn2008/views/price_fixed.sql
index ce8170e7c7..306e9d8878 100644
--- a/db/routines/vn2008/views/price_fixed.sql
+++ b/db/routines/vn2008/views/price_fixed.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`price_fixed`
AS SELECT `pf`.`itemFk` AS `item_id`,
diff --git a/db/routines/vn2008/views/producer.sql b/db/routines/vn2008/views/producer.sql
index babfb887ea..dbf7833ca6 100644
--- a/db/routines/vn2008/views/producer.sql
+++ b/db/routines/vn2008/views/producer.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`producer`
AS SELECT `p`.`id` AS `producer_id`,
diff --git a/db/routines/vn2008/views/promissoryNote.sql b/db/routines/vn2008/views/promissoryNote.sql
index 0db0fa86f0..e8d3b8718f 100644
--- a/db/routines/vn2008/views/promissoryNote.sql
+++ b/db/routines/vn2008/views/promissoryNote.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Pagares`
AS SELECT `p`.`id` AS `Id_Pagare`,
diff --git a/db/routines/vn2008/views/proveedores_clientes.sql b/db/routines/vn2008/views/proveedores_clientes.sql
index e08f4a3a7c..1e5c75f544 100644
--- a/db/routines/vn2008/views/proveedores_clientes.sql
+++ b/db/routines/vn2008/views/proveedores_clientes.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`proveedores_clientes`
AS SELECT `Proveedores`.`Id_Proveedor` AS `Id_Proveedor`,
diff --git a/db/routines/vn2008/views/province.sql b/db/routines/vn2008/views/province.sql
index 1477ec8034..1a08497bc0 100644
--- a/db/routines/vn2008/views/province.sql
+++ b/db/routines/vn2008/views/province.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`province`
AS SELECT `p`.`id` AS `province_id`,
diff --git a/db/routines/vn2008/views/recibida.sql b/db/routines/vn2008/views/recibida.sql
index 76b86505e1..ae48debb6d 100644
--- a/db/routines/vn2008/views/recibida.sql
+++ b/db/routines/vn2008/views/recibida.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`recibida`
AS SELECT `r`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/recibida_intrastat.sql b/db/routines/vn2008/views/recibida_intrastat.sql
index 402781931e..fd472c55aa 100644
--- a/db/routines/vn2008/views/recibida_intrastat.sql
+++ b/db/routines/vn2008/views/recibida_intrastat.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`recibida_intrastat`
AS SELECT `i`.`invoiceInFk` AS `recibida_id`,
diff --git a/db/routines/vn2008/views/recibida_iva.sql b/db/routines/vn2008/views/recibida_iva.sql
index 7d948a6ffb..96f5c1736e 100644
--- a/db/routines/vn2008/views/recibida_iva.sql
+++ b/db/routines/vn2008/views/recibida_iva.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`recibida_iva`
AS SELECT `i`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/recibida_vencimiento.sql b/db/routines/vn2008/views/recibida_vencimiento.sql
index 813ae40d7a..d06230e37a 100644
--- a/db/routines/vn2008/views/recibida_vencimiento.sql
+++ b/db/routines/vn2008/views/recibida_vencimiento.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`recibida_vencimiento`
AS SELECT `r`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/recovery.sql b/db/routines/vn2008/views/recovery.sql
index 5bbff31247..905ffc347c 100644
--- a/db/routines/vn2008/views/recovery.sql
+++ b/db/routines/vn2008/views/recovery.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`recovery`
AS SELECT `r`.`id` AS `recovery_id`,
diff --git a/db/routines/vn2008/views/reference_rate.sql b/db/routines/vn2008/views/reference_rate.sql
index eb0f1c25ec..e0d09db58e 100644
--- a/db/routines/vn2008/views/reference_rate.sql
+++ b/db/routines/vn2008/views/reference_rate.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`reference_rate`
AS SELECT `rr`.`currencyFk` AS `moneda_id`,
diff --git a/db/routines/vn2008/views/reinos.sql b/db/routines/vn2008/views/reinos.sql
index 4d98d1f09b..3b1299bb02 100644
--- a/db/routines/vn2008/views/reinos.sql
+++ b/db/routines/vn2008/views/reinos.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`reinos`
AS SELECT `r`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/state.sql b/db/routines/vn2008/views/state.sql
index 9f7fcccd81..3602e257d2 100644
--- a/db/routines/vn2008/views/state.sql
+++ b/db/routines/vn2008/views/state.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`state`
AS SELECT `s`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/tag.sql b/db/routines/vn2008/views/tag.sql
index 25b3ab82e1..9a1c5c6753 100644
--- a/db/routines/vn2008/views/tag.sql
+++ b/db/routines/vn2008/views/tag.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`tag`
AS SELECT `t`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/tarifa_componentes.sql b/db/routines/vn2008/views/tarifa_componentes.sql
index bec53abd94..72f15bfeef 100644
--- a/db/routines/vn2008/views/tarifa_componentes.sql
+++ b/db/routines/vn2008/views/tarifa_componentes.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`tarifa_componentes`
AS SELECT `tarifa_componentes`.`Id_Componente` AS `Id_Componente`,
diff --git a/db/routines/vn2008/views/tarifa_componentes_series.sql b/db/routines/vn2008/views/tarifa_componentes_series.sql
index a1d1887094..ecf425b198 100644
--- a/db/routines/vn2008/views/tarifa_componentes_series.sql
+++ b/db/routines/vn2008/views/tarifa_componentes_series.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`tarifa_componentes_series`
AS SELECT `tarifa_componentes_series`.`tarifa_componentes_series_id` AS `tarifa_componentes_series_id`,
diff --git a/db/routines/vn2008/views/tblContadores.sql b/db/routines/vn2008/views/tblContadores.sql
index 129d3ce8be..360171a8b3 100644
--- a/db/routines/vn2008/views/tblContadores.sql
+++ b/db/routines/vn2008/views/tblContadores.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`tblContadores`
AS SELECT `c`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/thermograph.sql b/db/routines/vn2008/views/thermograph.sql
index f51b83d243..209d89e912 100644
--- a/db/routines/vn2008/views/thermograph.sql
+++ b/db/routines/vn2008/views/thermograph.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`thermograph`
AS SELECT `t`.`id` AS `thermograph_id`,
diff --git a/db/routines/vn2008/views/ticket_observation.sql b/db/routines/vn2008/views/ticket_observation.sql
index deb85e4b6b..d2aa4733b3 100644
--- a/db/routines/vn2008/views/ticket_observation.sql
+++ b/db/routines/vn2008/views/ticket_observation.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`ticket_observation`
AS SELECT `to`.`id` AS `ticket_observation_id`,
diff --git a/db/routines/vn2008/views/tickets_gestdoc.sql b/db/routines/vn2008/views/tickets_gestdoc.sql
index a8682db577..707ca8ad86 100644
--- a/db/routines/vn2008/views/tickets_gestdoc.sql
+++ b/db/routines/vn2008/views/tickets_gestdoc.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`tickets_gestdoc`
AS SELECT `td`.`ticketFk` AS `Id_Ticket`,
diff --git a/db/routines/vn2008/views/time.sql b/db/routines/vn2008/views/time.sql
index f3bbc86076..72104e5706 100644
--- a/db/routines/vn2008/views/time.sql
+++ b/db/routines/vn2008/views/time.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`time`
AS SELECT `t`.`dated` AS `date`,
diff --git a/db/routines/vn2008/views/travel.sql b/db/routines/vn2008/views/travel.sql
index 5dc993d330..3c27f6566a 100644
--- a/db/routines/vn2008/views/travel.sql
+++ b/db/routines/vn2008/views/travel.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`travel`
AS SELECT `t`.`id` AS `id`,
diff --git a/db/routines/vn2008/views/v_Articles_botanical.sql b/db/routines/vn2008/views/v_Articles_botanical.sql
index 8640bb6380..18db5bf2e3 100644
--- a/db/routines/vn2008/views/v_Articles_botanical.sql
+++ b/db/routines/vn2008/views/v_Articles_botanical.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`v_Articles_botanical`
AS SELECT `ib`.`itemFk` AS `itemFk`,
diff --git a/db/routines/vn2008/views/v_compres.sql b/db/routines/vn2008/views/v_compres.sql
index 633feb4717..8d9c6b96b7 100644
--- a/db/routines/vn2008/views/v_compres.sql
+++ b/db/routines/vn2008/views/v_compres.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`v_compres`
AS SELECT `TP`.`Id_Tipo` AS `Familia`,
diff --git a/db/routines/vn2008/views/v_empresa.sql b/db/routines/vn2008/views/v_empresa.sql
index 5a6d6e0f59..16c9646c23 100644
--- a/db/routines/vn2008/views/v_empresa.sql
+++ b/db/routines/vn2008/views/v_empresa.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`v_empresa`
AS SELECT `e`.`logo` AS `logo`,
diff --git a/db/routines/vn2008/views/versiones.sql b/db/routines/vn2008/views/versiones.sql
index 3d27f4f927..3066327c9c 100644
--- a/db/routines/vn2008/views/versiones.sql
+++ b/db/routines/vn2008/views/versiones.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`versiones`
AS SELECT `m`.`app` AS `programa`,
diff --git a/db/routines/vn2008/views/warehouse_pickup.sql b/db/routines/vn2008/views/warehouse_pickup.sql
index c3a7268a17..739d6d9750 100644
--- a/db/routines/vn2008/views/warehouse_pickup.sql
+++ b/db/routines/vn2008/views/warehouse_pickup.sql
@@ -1,5 +1,5 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
+CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`warehouse_pickup`
AS SELECT
diff --git a/db/versions/10996-pinkPhormium/03-dropStockLog.sql b/db/versions/10996-pinkPhormium/03-dropStockLog.sql
new file mode 100644
index 0000000000..ab5b0a254f
--- /dev/null
+++ b/db/versions/10996-pinkPhormium/03-dropStockLog.sql
@@ -0,0 +1 @@
+DROP TABLE stock.log;
diff --git a/db/versions/11009-tealRuscus/00-buyPick.sql b/db/versions/11009-tealRuscus/00-buyPick.sql
new file mode 100644
index 0000000000..806329e78e
--- /dev/null
+++ b/db/versions/11009-tealRuscus/00-buyPick.sql
@@ -0,0 +1,16 @@
+DROP TABLE IF EXISTS stock.inboundPick;
+
+CREATE TABLE stock.buyPick (
+ id INT UNSIGNED auto_increment NOT NULL,
+ lotFk INT(11) NOT NULL
+ COMMENT 'Buy id',
+ outFk INT(11) NOT NULL
+ COMMENT 'Out id',
+ quantity INT UNSIGNED NOT NULL
+ COMMENT 'Picked quantity',
+ PRIMARY KEY (id),
+ CONSTRAINT buyPick_unique UNIQUE KEY (lotFk, outFk)
+)
+ENGINE=InnoDB
+DEFAULT CHARSET=utf8mb3
+COLLATE=utf8mb3_unicode_ci;
diff --git a/db/versions/11009-tealRuscus/01-alterBuy.sql b/db/versions/11009-tealRuscus/01-alterBuy.sql
new file mode 100644
index 0000000000..0b40452b38
--- /dev/null
+++ b/db/versions/11009-tealRuscus/01-alterBuy.sql
@@ -0,0 +1,6 @@
+ALTER TABLE vn.buy
+ ADD life INT UNSIGNED NULL
+ COMMENT 'Lot life expressed in days',
+ ADD isAlive BOOL NOT NULL DEFAULT TRUE
+ COMMENT 'Whether it is alive',
+ ADD INDEX(isAlive);
diff --git a/db/versions/11009-tealRuscus/01-alterOrderRow.sql b/db/versions/11009-tealRuscus/01-alterOrderRow.sql
new file mode 100644
index 0000000000..5fed7b23da
--- /dev/null
+++ b/db/versions/11009-tealRuscus/01-alterOrderRow.sql
@@ -0,0 +1,4 @@
+ALTER TABLE hedera.orderRow
+ ADD isReserved BOOL NOT NULL DEFAULT TRUE
+ COMMENT 'Whether has an available reservation',
+ ADD INDEX(isReserved);
diff --git a/db/versions/11009-tealRuscus/01-alterTicket.sql b/db/versions/11009-tealRuscus/01-alterTicket.sql
new file mode 100644
index 0000000000..857415838a
--- /dev/null
+++ b/db/versions/11009-tealRuscus/01-alterTicket.sql
@@ -0,0 +1,4 @@
+ALTER TABLE vn.ticket
+ ADD isAlive BOOL NOT NULL DEFAULT TRUE
+ COMMENT 'Whether it is alive',
+ ADD INDEX(isAlive);
diff --git a/db/versions/11009-tealRuscus/02-buyLot.sql b/db/versions/11009-tealRuscus/02-buyLot.sql
new file mode 100644
index 0000000000..cfdca064b9
--- /dev/null
+++ b/db/versions/11009-tealRuscus/02-buyLot.sql
@@ -0,0 +1,10 @@
+RENAME TABLE IF EXISTS stock.inbound TO stock.buyLot;
+
+ALTER TABLE stock.buyLot
+ DROP KEY source,
+ DROP COLUMN tableName,
+ CHANGE tableId lotFk int(10) unsigned NOT NULL,
+ CHANGE isSync isSync tinyint(4) NOT NULL AFTER lotFk,
+ DROP PRIMARY KEY,
+ DROP COLUMN id,
+ ADD PRIMARY KEY (lotFk);
diff --git a/db/versions/11009-tealRuscus/03-removeStockVisible.sql b/db/versions/11009-tealRuscus/03-removeStockVisible.sql
new file mode 100644
index 0000000000..bc5c9a84eb
--- /dev/null
+++ b/db/versions/11009-tealRuscus/03-removeStockVisible.sql
@@ -0,0 +1 @@
+DROP TABLE stock.visible;
diff --git a/db/versions/11009-tealRuscus/04-buyOut.sql b/db/versions/11009-tealRuscus/04-buyOut.sql
new file mode 100644
index 0000000000..e2be18da56
--- /dev/null
+++ b/db/versions/11009-tealRuscus/04-buyOut.sql
@@ -0,0 +1,10 @@
+RENAME TABLE IF EXISTS stock.outbound TO stock.buyOut;
+
+ALTER TABLE stock.buyOut
+ CHANGE IF EXISTS tableName source enum('buy','sale','orderRow') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
+ CHANGE IF EXISTS id outFk int(10) UNSIGNED NOT NULL,
+ DROP INDEX IF EXISTS source,
+ DROP COLUMN IF EXISTS tableId,
+ DROP INDEX IF EXISTS expired,
+ DROP COLUMN IF EXISTS expired,
+ ADD INDEX IF NOT EXISTS (source);
diff --git a/db/versions/11009-tealRuscus/05-stockConfig.sql b/db/versions/11009-tealRuscus/05-stockConfig.sql
new file mode 100644
index 0000000000..3813206aec
--- /dev/null
+++ b/db/versions/11009-tealRuscus/05-stockConfig.sql
@@ -0,0 +1,8 @@
+CREATE TABLE stock.config (
+ id INT UNSIGNED auto_increment NOT NULL,
+ saleLife INT UNSIGNED NOT NULL COMMENT 'Maximum sales cache lifetime in days',
+ CONSTRAINT config_pk PRIMARY KEY (id)
+)
+ENGINE=InnoDB
+DEFAULT CHARSET=utf8mb3
+COLLATE=utf8mb3_general_ci;
diff --git a/db/versions/11009-tealRuscus/06-stockConfigInsert.sql b/db/versions/11009-tealRuscus/06-stockConfigInsert.sql
new file mode 100644
index 0000000000..780e5222f6
--- /dev/null
+++ b/db/versions/11009-tealRuscus/06-stockConfigInsert.sql
@@ -0,0 +1,2 @@
+INSERT INTO stock.config (id, saleLife)
+ VALUES (1, 90);
diff --git a/db/versions/11009-tealRuscus/07-buyLotSeq.sql b/db/versions/11009-tealRuscus/07-buyLotSeq.sql
new file mode 100644
index 0000000000..8b97509d97
--- /dev/null
+++ b/db/versions/11009-tealRuscus/07-buyLotSeq.sql
@@ -0,0 +1 @@
+CREATE SEQUENCE IF NOT EXISTS vn.buyLot;
diff --git a/db/versions/11009-tealRuscus/08-saleLotFk.sql b/db/versions/11009-tealRuscus/08-saleLotFk.sql
new file mode 100644
index 0000000000..6f32413a55
--- /dev/null
+++ b/db/versions/11009-tealRuscus/08-saleLotFk.sql
@@ -0,0 +1,2 @@
+ALTER TABLE vn.sale
+ ADD COLUMN IF NOT EXISTS lotFk INT UNSIGNED NOT NULL DEFAULT nextval(vn.buyLot) AFTER id;
diff --git a/db/versions/11009-tealRuscus/09-orderRowLotFk.sql b/db/versions/11009-tealRuscus/09-orderRowLotFk.sql
new file mode 100644
index 0000000000..fde39f7e7d
--- /dev/null
+++ b/db/versions/11009-tealRuscus/09-orderRowLotFk.sql
@@ -0,0 +1,2 @@
+ALTER TABLE hedera.orderRow
+ ADD COLUMN IF NOT EXISTS lotFk INT UNSIGNED NOT NULL DEFAULT nextval(vn.buyLot) AFTER id;
diff --git a/db/versions/11009-tealRuscus/10-buyLotFk.sql b/db/versions/11009-tealRuscus/10-buyLotFk.sql
new file mode 100644
index 0000000000..602c9fc2c5
--- /dev/null
+++ b/db/versions/11009-tealRuscus/10-buyLotFk.sql
@@ -0,0 +1,2 @@
+ALTER TABLE vn.buy
+ ADD COLUMN IF NOT EXISTS lotFk INT UNSIGNED NOT NULL DEFAULT nextval(vn.buyLot) AFTER id;
diff --git a/db/versions/11009-tealRuscus/11-saleLotIndex.sql b/db/versions/11009-tealRuscus/11-saleLotIndex.sql
new file mode 100644
index 0000000000..75042be564
--- /dev/null
+++ b/db/versions/11009-tealRuscus/11-saleLotIndex.sql
@@ -0,0 +1,2 @@
+ALTER TABLE vn.sale
+ ADD UNIQUE IF NOT EXISTS (lotFk);
diff --git a/db/versions/11009-tealRuscus/12-orderRowLotIndex.sql b/db/versions/11009-tealRuscus/12-orderRowLotIndex.sql
new file mode 100644
index 0000000000..80d25e5803
--- /dev/null
+++ b/db/versions/11009-tealRuscus/12-orderRowLotIndex.sql
@@ -0,0 +1,2 @@
+ALTER TABLE hedera.orderRow
+ ADD UNIQUE IF NOT EXISTS (lotFk);
diff --git a/db/versions/11009-tealRuscus/13-buyLotIndex.sql b/db/versions/11009-tealRuscus/13-buyLotIndex.sql
new file mode 100644
index 0000000000..12e3b709be
--- /dev/null
+++ b/db/versions/11009-tealRuscus/13-buyLotIndex.sql
@@ -0,0 +1,2 @@
+ALTER TABLE vn.buy
+ ADD UNIQUE IF NOT EXISTS (lotFk);
diff --git a/db/versions/11401-azureMoss/00-claimConfig.sql b/db/versions/11401-azureMoss/00-claimConfig.sql
new file mode 100644
index 0000000000..8942de33b4
--- /dev/null
+++ b/db/versions/11401-azureMoss/00-claimConfig.sql
@@ -0,0 +1,14 @@
+ALTER TABLE `vn`.`claimConfig`
+ ADD COLUMN `pickupDeliveryFk` INT(11)
+ COMMENT 'Agencia utilizada para las recogidas mediante reparto',
+ ADD COLUMN `warehouseFk` smallint(6) unsigned
+ COMMENT 'Almacén usado para los tickets de reclamaciones',
+
+ ADD CONSTRAINT `fk_claimConfig_pickupdeliveryFk`
+ FOREIGN KEY (`pickupdeliveryFk`)
+ REFERENCES `agencyMode` (`id`),
+
+ ADD CONSTRAINT `fk_claimConfig_warehouseFk`
+ FOREIGN KEY (`warehouseFk`)
+ REFERENCES `warehouse` (`id`);
+
diff --git a/db/versions/11401-azureMoss/01-createState.sql b/db/versions/11401-azureMoss/01-createState.sql
new file mode 100644
index 0000000000..8162e45a9d
--- /dev/null
+++ b/db/versions/11401-azureMoss/01-createState.sql
@@ -0,0 +1,2 @@
+INSERT IGNORE INTO vn.state (name,`order`,alertLevel,code,isPreviousPreparable,isPicked)
+ VALUES ('Recogido',3,4,'PICKED_UP',0,1)
diff --git a/db/versions/11401-azureMoss/02-claimEnd.sql b/db/versions/11401-azureMoss/02-claimEnd.sql
new file mode 100644
index 0000000000..8cc03279d2
--- /dev/null
+++ b/db/versions/11401-azureMoss/02-claimEnd.sql
@@ -0,0 +1,5 @@
+ALTER TABLE `vn`.`claimEnd`
+ ADD COLUMN `shelvingFk` INT(11) DEFAULT NULL AFTER `editorFk`,
+ ADD INDEX `claimEnd_fk_shelving` (`shelvingFk`),
+ ADD CONSTRAINT `claimEnd_fk_shelving` FOREIGN KEY (`shelvingFk`)
+ REFERENCES `shelving` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;
diff --git a/db/versions/11401-azureMoss/03-claimDestination.sql b/db/versions/11401-azureMoss/03-claimDestination.sql
new file mode 100644
index 0000000000..09da25a88e
--- /dev/null
+++ b/db/versions/11401-azureMoss/03-claimDestination.sql
@@ -0,0 +1,8 @@
+UPDATE vn.claimDestination cd
+ SET cd.addressFk = NULL
+ WHERE code IN ('garbage/loss','manufacturing','supplierClaim','corrected');
+
+UPDATE vn.claimDestination cd
+ JOIN vn.addressWaste aw ON aw.`type` = 'fault'
+ SET cd.addressFk = aw.addressFk
+ WHERE code IN ('good');
diff --git a/db/versions/11442-blackBirch/00-firstScript.sql b/db/versions/11442-blackBirch/00-firstScript.sql
new file mode 100644
index 0000000000..2379b13535
--- /dev/null
+++ b/db/versions/11442-blackBirch/00-firstScript.sql
@@ -0,0 +1,11 @@
+CREATE TABLE `edi`.`floricodeConfig` (
+ `id` int(10) unsigned NOT NULL,
+ `url` varchar(100) NOT NULL,
+ `user` varchar(50) NOT NULL,
+ `password` varchar(100) NOT NULL,
+ PRIMARY KEY (`id`),
+ CONSTRAINT `floricodeConfig_check` CHECK (`id` = 1)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+
+INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
+ VALUES ('Edi','syncData','WRITE','ALLOW','ROLE','system');
diff --git a/db/versions/11442-blackBirch/01-firstScript.sql b/db/versions/11442-blackBirch/01-firstScript.sql
new file mode 100644
index 0000000000..18aee4ec2f
--- /dev/null
+++ b/db/versions/11442-blackBirch/01-firstScript.sql
@@ -0,0 +1,65 @@
+ALTER TABLE edi.tableMultiConfig
+ ADD `method` varchar(100) DEFAULT NULL NULL AFTER file,
+ DROP PRIMARY KEY,
+ DROP KEY to_table,
+ ADD id int(10) unsigned NULL FIRST;
+
+UPDATE edi.tableMultiConfig
+ SET id = 1, method = 'VBN/Packaging'
+ WHERE id IS NULL
+ AND fileName='CK';
+
+UPDATE edi.tableMultiConfig
+ SET id = 2, method = 'VBN/PackagingType'
+ WHERE id IS NULL
+ AND fileName='FB';
+
+UPDATE edi.tableMultiConfig
+ SET id = 3, method = 'VBN/ProductFeature'
+ WHERE id IS NULL
+ AND fileName='FF';
+
+UPDATE edi.tableMultiConfig
+ SET id = 4, method = 'VBN/Genus'
+ WHERE id IS NULL
+ AND fileName='FG';
+
+UPDATE edi.tableMultiConfig
+ SET id = 5, method = 'VBN/Product'
+ WHERE id IS NULL
+ AND fileName='FP';
+
+UPDATE edi.tableMultiConfig
+ SET id = 6, method = 'VBN/RegulatoryFeatureType'
+ WHERE id IS NULL
+ AND fileName='FY';
+
+UPDATE edi.tableMultiConfig
+ SET id = 7, method = 'VBN/ProductGroup'
+ WHERE id IS NULL
+ AND fileName='FO';
+
+UPDATE edi.tableMultiConfig
+ SET id = 8, method = 'VBN/Plant'
+ WHERE id IS NULL
+ AND fileName='FT';
+
+UPDATE edi.tableMultiConfig
+ SET id = 9, method = 'VBN/Species'
+ WHERE id IS NULL
+ AND fileName='FS';
+
+UPDATE edi.tableMultiConfig
+ SET id = 10, method = 'FEC/Company'
+ WHERE id IS NULL
+ AND fileName='CC';
+
+UPDATE edi.tableMultiConfig
+ SET id = 11, method = 'VBN/FeatureType'
+ WHERE id IS NULL
+ AND fileName='FE';
+
+UPDATE edi.tableMultiConfig
+ SET id = 12, method = 'VBN/FeatureValue'
+ WHERE id IS NULL
+ AND fileName='FV';
diff --git a/db/versions/11442-blackBirch/02-firstScript.sql b/db/versions/11442-blackBirch/02-firstScript.sql
new file mode 100644
index 0000000000..609940cf1d
--- /dev/null
+++ b/db/versions/11442-blackBirch/02-firstScript.sql
@@ -0,0 +1,4 @@
+ALTER TABLE edi.tableMultiConfig
+ ADD CONSTRAINT tableMultiConfig_pk PRIMARY KEY (id),
+ MODIFY COLUMN id int(10) unsigned auto_increment NOT NULL,
+ ADD CONSTRAINT tableMultiConfig_unique UNIQUE KEY (toTable);
diff --git a/db/versions/11444-orangeMastic/00-firstScript.sql b/db/versions/11444-orangeMastic/00-firstScript.sql
new file mode 100644
index 0000000000..2476ea6f2c
--- /dev/null
+++ b/db/versions/11444-orangeMastic/00-firstScript.sql
@@ -0,0 +1,8 @@
+UPDATE vn.claimEnd ce
+ JOIN(
+ SELECT id
+ FROM vn.claimEnd
+ WHERE claimDestinationFk NOT IN
+ (SELECT id FROM vn.claimDestination WHERE id IS NOT NULL)
+ ) s ON ce.id = s.id
+ SET ce.claimDestinationFk = 1;
\ No newline at end of file
diff --git a/db/versions/11444-orangeMastic/01-firstScript.sql b/db/versions/11444-orangeMastic/01-firstScript.sql
new file mode 100644
index 0000000000..38cd7c0914
--- /dev/null
+++ b/db/versions/11444-orangeMastic/01-firstScript.sql
@@ -0,0 +1,9 @@
+ALTER TABLE vn.claimEnd
+ MODIFY COLUMN claimDestinationFk tinyint(3) unsigned NOT NULL DEFAULT 1;
+
+ALTER TABLE vn.claimEnd
+ ADD CONSTRAINT fk_claimEnd_claimDestination
+ FOREIGN KEY (claimDestinationFk)
+ REFERENCES claimDestination(id)
+ ON UPDATE CASCADE
+ ON DELETE RESTRICT;
\ No newline at end of file
diff --git a/db/versions/11449-limeDracena/00-deprecate.sql b/db/versions/11449-limeDracena/00-deprecate.sql
new file mode 100644
index 0000000000..2ade5cb8bd
--- /dev/null
+++ b/db/versions/11449-limeDracena/00-deprecate.sql
@@ -0,0 +1,10 @@
+ALTER TABLE `account`.`user` DROP COLUMN `recoverPass__`;
+ALTER TABLE `account`.`user` DROP COLUMN `sync__`;
+ALTER TABLE `vn`.`client` DROP COLUMN `gestdocFk__`;
+DROP TABLE `vn`.`itemShelvingLog__`;
+DROP TABLE `vn`.`inventoryFailure__`;
+DROP TABLE `vn`.`entryVirtual__`;
+DROP TABLE `vn`.`machineWorkerConfig__`;
+DROP TABLE `vn`.`machineWorker__`;
+DROP TABLE `vn`.`inventoryFailureCause__`;
+DROP TABLE `vn`.`workerTimeControlParams__`;
diff --git a/db/versions/11453-pinkTulip/00-firstScript.sql b/db/versions/11453-pinkTulip/00-firstScript.sql
new file mode 100644
index 0000000000..351fd8396d
--- /dev/null
+++ b/db/versions/11453-pinkTulip/00-firstScript.sql
@@ -0,0 +1,8 @@
+ALTER TABLE vn.workerTimeControlConfig
+ ADD COLUMN `mandatoryBreakFrom` time DEFAULT '12:00:00'
+ COMMENT 'Tiempo desde el que se obligará a realizar un descanso para jornada partida';
+ALTER TABLE vn.workerTimeControlConfig
+ ADD COLUMN `mandatoryBreakTo` time DEFAULT '15:00:00';
+
+INSERT INTO vn.workerTimeControlError (`code`, `description`)
+ VALUES ('WAIT_TIME', 'El descanso terminará en ');
diff --git a/db/versions/11455-orangeTulip/00-firstScript.sql b/db/versions/11455-orangeTulip/00-firstScript.sql
new file mode 100644
index 0000000000..d64c8e324e
--- /dev/null
+++ b/db/versions/11455-orangeTulip/00-firstScript.sql
@@ -0,0 +1,9 @@
+
+
+USE vn;
+
+INSERT INTO vn.workerActivityType (code, description)
+VALUES('SHELVING_CLEAN_START', 'SE INICIA LIMPIEZA CARRO'),
+ ('SHELVING_CLEAN_STOP', 'SE FINALIZA LIMPIEZA CARRO');
+
+
diff --git a/db/versions/11456-goldenDracena/00-firstScript.sql b/db/versions/11456-goldenDracena/00-firstScript.sql
new file mode 100644
index 0000000000..fba3ba8088
--- /dev/null
+++ b/db/versions/11456-goldenDracena/00-firstScript.sql
@@ -0,0 +1,3 @@
+ALTER TABLE vn.priceDelta ADD IF NOT EXISTS isHidden BOOL
+ DEFAULT FALSE NOT NULL
+ COMMENT 'Hides the itemType when building de catalog recordset';
diff --git a/db/versions/11461-chocolateChrysanthemum/00-firstScript.sql b/db/versions/11461-chocolateChrysanthemum/00-firstScript.sql
new file mode 100644
index 0000000000..76985d3dbf
--- /dev/null
+++ b/db/versions/11461-chocolateChrysanthemum/00-firstScript.sql
@@ -0,0 +1,3 @@
+-- Place your SQL code here
+INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
+ VALUES ('SaleGroupDetail','find','READ','ALLOW','ROLE','employee');
diff --git a/db/versions/11464-greenRaphis/00-firstScript.sql b/db/versions/11464-greenRaphis/00-firstScript.sql
new file mode 100644
index 0000000000..a8937a3c9a
--- /dev/null
+++ b/db/versions/11464-greenRaphis/00-firstScript.sql
@@ -0,0 +1,6 @@
+-- Place your SQL code here
+UPDATE vn.travel
+ SET availabled = landed
+ WHERE availabled IS NULL;
+
+
diff --git a/db/versions/11467-blackFern/00-stockPrivs.sql b/db/versions/11467-blackFern/00-stockPrivs.sql
new file mode 100644
index 0000000000..f776bca5e9
--- /dev/null
+++ b/db/versions/11467-blackFern/00-stockPrivs.sql
@@ -0,0 +1,8 @@
+
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `stock`.`buyOut_refreshBuy`() BEGIN END;
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `stock`.`buyOut_refreshOrder`() BEGIN END;
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `stock`.`buyOut_refreshSale`() BEGIN END;
+
+GRANT EXECUTE ON PROCEDURE stock.buyOut_refreshBuy TO 'mycdc-consumer'@'10.0.%.%';
+GRANT EXECUTE ON PROCEDURE stock.buyOut_refreshOrder TO 'mycdc-consumer'@'10.0.%.%';
+GRANT EXECUTE ON PROCEDURE stock.buyOut_refreshSale TO 'mycdc-consumer'@'10.0.%.%';
diff --git a/db/versions/11469-wheatRuscus/00-firstScript.sql b/db/versions/11469-wheatRuscus/00-firstScript.sql
new file mode 100644
index 0000000000..f33cfe1194
--- /dev/null
+++ b/db/versions/11469-wheatRuscus/00-firstScript.sql
@@ -0,0 +1,4 @@
+-- Place your SQL code here
+UPDATE vn.travel
+ SET availabled = landed
+ WHERE availabled IS NULL;
\ No newline at end of file
diff --git a/db/versions/11469-wheatRuscus/01-alter table.sql b/db/versions/11469-wheatRuscus/01-alter table.sql
new file mode 100644
index 0000000000..c1d19ee664
--- /dev/null
+++ b/db/versions/11469-wheatRuscus/01-alter table.sql
@@ -0,0 +1,2 @@
+ALTER TABLE vn.travel MODIFY COLUMN availabled datetime NOT NULL
+COMMENT 'Indicates the moment in time when the goods become available for picking';
diff --git a/db/versions/11471-blueOak/00-firstScript.sql b/db/versions/11471-blueOak/00-firstScript.sql
new file mode 100644
index 0000000000..fec51f2366
--- /dev/null
+++ b/db/versions/11471-blueOak/00-firstScript.sql
@@ -0,0 +1,3 @@
+INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
+ VALUES
+ ('TicketRefund', 'find', 'READ', 'ALLOW', 'ROLE', 'employee');
\ No newline at end of file
diff --git a/db/versions/11476-chocolateEucalyptus/00-firstScript.sql b/db/versions/11476-chocolateEucalyptus/00-firstScript.sql
new file mode 100644
index 0000000000..40ed052e75
--- /dev/null
+++ b/db/versions/11476-chocolateEucalyptus/00-firstScript.sql
@@ -0,0 +1,19 @@
+UPDATE vn.town
+ SET name = CONCAT(UPPER(SUBSTRING(name, 1, 1)), LOWER(SUBSTRING(name, 2)))
+ WHERE name IS NOT NULL
+ AND BINARY name = UPPER(name);
+
+UPDATE vn.province
+ SET name = CONCAT(UPPER(SUBSTRING(name, 1, 1)), LOWER(SUBSTRING(name, 2)))
+ WHERE name IS NOT NULL
+ AND BINARY name = UPPER(name);
+
+UPDATE vn.autonomy
+ SET name = CONCAT(UPPER(SUBSTRING(name, 1, 1)), LOWER(SUBSTRING(name, 2)))
+ WHERE name IS NOT NULL
+ AND BINARY name = UPPER(name);
+
+UPDATE vn.country
+ SET name = CONCAT(UPPER(SUBSTRING(name, 1, 1)), LOWER(SUBSTRING(name, 2)))
+ WHERE name IS NOT NULL
+ AND BINARY name = UPPER(name);
\ No newline at end of file
diff --git a/loopback/locale/en.json b/loopback/locale/en.json
index b9add02a8c..d9cb3ed476 100644
--- a/loopback/locale/en.json
+++ b/loopback/locale/en.json
@@ -257,5 +257,7 @@
"Ticket has been delivered out of order": "The ticket {{ticket}} of route {{{fullUrl}}} has been delivered out of order.",
"clonedFromTicketWeekly": ", that is a cloned sale from ticket {{ ticketWeekly }}",
"negativeReplaced": "Replaced item [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} with [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} from ticket [{{ticketId}}]({{{ticketUrl}}})",
- "The tag and priority can't be repeated": "The tag and priority can't be repeated"
+ "The tag and priority can't be repeated": "The tag and priority can't be repeated",
+ "The introduced warehouse already exists": "The introduced warehouse already exists",
+ "The code already exists": "The code already exists"
}
diff --git a/loopback/locale/es.json b/loopback/locale/es.json
index 61e05f7367..7783182c01 100644
--- a/loopback/locale/es.json
+++ b/loopback/locale/es.json
@@ -1,402 +1,404 @@
{
- "Phone format is invalid": "El formato del teléfono no es correcto",
- "You are not allowed to change the credit": "No tienes privilegios para modificar el crédito",
- "Unable to mark the equivalence surcharge": "No se puede marcar el recargo de equivalencia",
- "The default consignee can not be unchecked": "No se puede desmarcar el consignatario predeterminado",
- "Unable to default a disabled consignee": "No se puede poner predeterminado un consignatario desactivado",
- "Can't be blank": "No puede estar en blanco",
- "Invalid TIN": "NIF/CIF inválido",
- "TIN must be unique": "El NIF/CIF debe ser único",
- "A client with that Web User name already exists": "Ya existe un cliente con ese Usuario Web",
- "Is invalid": "Es inválido",
- "Quantity cannot be zero": "La cantidad no puede ser cero",
- "Enter an integer different to zero": "Introduce un entero distinto de cero",
- "Package cannot be blank": "El embalaje no puede estar en blanco",
- "The company name must be unique": "La razón social debe ser única",
- "Invalid email": "Correo electrónico inválido",
- "The IBAN does not have the correct format": "El IBAN no tiene el formato correcto",
- "That payment method requires an IBAN": "El método de pago seleccionado requiere un IBAN",
- "That payment method requires a BIC": "El método de pago seleccionado requiere un BIC",
- "State cannot be blank": "El estado no puede estar en blanco",
- "Worker cannot be blank": "El trabajador no puede estar en blanco",
- "Cannot change the payment method if no salesperson": "No se puede cambiar la forma de pago si no hay comercial asignado",
- "can't be blank": "El campo no puede estar vacío",
- "Observation type must be unique": "El tipo de observación no puede repetirse",
+ "Phone format is invalid": "El formato del teléfono no es correcto",
+ "You are not allowed to change the credit": "No tienes privilegios para modificar el crédito",
+ "Unable to mark the equivalence surcharge": "No se puede marcar el recargo de equivalencia",
+ "The default consignee can not be unchecked": "No se puede desmarcar el consignatario predeterminado",
+ "Unable to default a disabled consignee": "No se puede poner predeterminado un consignatario desactivado",
+ "Can't be blank": "No puede estar en blanco",
+ "Invalid TIN": "NIF/CIF inválido",
+ "TIN must be unique": "El NIF/CIF debe ser único",
+ "A client with that Web User name already exists": "Ya existe un cliente con ese Usuario Web",
+ "Is invalid": "Es inválido",
+ "Quantity cannot be zero": "La cantidad no puede ser cero",
+ "Enter an integer different to zero": "Introduce un entero distinto de cero",
+ "Package cannot be blank": "El embalaje no puede estar en blanco",
+ "The company name must be unique": "La razón social debe ser única",
+ "Invalid email": "Correo electrónico inválido",
+ "The IBAN does not have the correct format": "El IBAN no tiene el formato correcto",
+ "That payment method requires an IBAN": "El método de pago seleccionado requiere un IBAN",
+ "That payment method requires a BIC": "El método de pago seleccionado requiere un BIC",
+ "State cannot be blank": "El estado no puede estar en blanco",
+ "Worker cannot be blank": "El trabajador no puede estar en blanco",
+ "Cannot change the payment method if no salesperson": "No se puede cambiar la forma de pago si no hay comercial asignado",
+ "can't be blank": "El campo no puede estar vacío",
+ "Observation type must be unique": "El tipo de observación no puede repetirse",
"The credit must be an integer greater than or equal to zero": "The credit must be an integer greater than or equal to zero",
- "The grade must be similar to the last one": "El grade debe ser similar al último",
- "Only manager can change the credit": "Solo el gerente puede cambiar el credito de este cliente",
- "Name cannot be blank": "El nombre no puede estar en blanco",
- "Phone cannot be blank": "El teléfono no puede estar en blanco",
- "Period cannot be blank": "El periodo no puede estar en blanco",
- "Choose a company": "Selecciona una empresa",
- "Se debe rellenar el campo de texto": "Se debe rellenar el campo de texto",
- "Description should have maximum of 45 characters": "La descripción debe tener maximo 45 caracteres",
- "Cannot be blank": "El campo no puede estar en blanco",
- "The grade must be an integer greater than or equal to zero": "El grade debe ser un entero mayor o igual a cero",
- "Sample type cannot be blank": "El tipo de plantilla no puede quedar en blanco",
- "Description cannot be blank": "Se debe rellenar el campo de texto",
- "The price of the item changed": "El precio del artículo cambió",
- "The value should not be greater than 100%": "El valor no debe de ser mayor de 100%",
- "The value should be a number": "El valor debe ser un numero",
- "This order is not editable": "Esta orden no se puede modificar",
- "You can't create an order for a frozen client": "No puedes crear una orden para un cliente congelado",
- "You can't create an order for a client that has a debt": "No puedes crear una orden para un cliente con deuda",
- "is not a valid date": "No es una fecha valida",
- "Barcode must be unique": "El código de barras debe ser único",
- "The warehouse can't be repeated": "El almacén no puede repetirse",
- "The tag or priority can't be repeated for an item": "El tag o prioridad no puede repetirse para un item",
- "The observation type can't be repeated": "El tipo de observación no puede repetirse",
- "A claim with that sale already exists": "Ya existe una reclamación para esta línea",
- "You don't have enough privileges to change that field": "No tienes permisos para cambiar ese campo",
- "Warehouse cannot be blank": "El almacén no puede quedar en blanco",
- "Agency cannot be blank": "La agencia no puede quedar en blanco",
- "Not enough privileges to edit a client with verified data": "No tienes permisos para hacer cambios en un cliente con datos comprobados",
- "This address doesn't exist": "Este consignatario no existe",
- "You must delete the claim id %d first": "Antes debes borrar la reclamación %d",
- "You don't have enough privileges": "No tienes suficientes permisos",
- "Cannot check Equalization Tax in this NIF/CIF": "No se puede marcar RE en este NIF/CIF",
- "You can't make changes on the basic data of an confirmed order or with rows": "No puedes cambiar los datos básicos de una orden con artículos",
- "INVALID_USER_NAME": "El nombre de usuario solo debe contener letras minúsculas o, a partir del segundo carácter, números o subguiones, no está permitido el uso de la letra ñ",
- "You can't create a ticket for a frozen client": "No puedes crear un ticket para un cliente congelado",
- "You can't create a ticket for an inactive client": "No puedes crear un ticket para un cliente inactivo",
- "Tag value cannot be blank": "El valor del tag no puede quedar en blanco",
- "ORDER_EMPTY": "Cesta vacía",
- "You don't have enough privileges to do that": "No tienes permisos para cambiar esto",
- "NO SE PUEDE DESACTIVAR EL CONSIGNAT": "NO SE PUEDE DESACTIVAR EL CONSIGNAT",
- "Error. El NIF/CIF está repetido": "Error. El NIF/CIF está repetido",
- "Street cannot be empty": "Dirección no puede estar en blanco",
- "City cannot be empty": "Ciudad no puede estar en blanco",
- "Code cannot be blank": "Código no puede estar en blanco",
- "You cannot remove this department": "No puedes eliminar este departamento",
- "The extension must be unique": "La extensión debe ser unica",
- "The secret can't be blank": "La contraseña no puede estar en blanco",
- "We weren't able to send this SMS": "No hemos podido enviar el SMS",
- "This client can't be invoiced": "Este cliente no puede ser facturado",
- "You must provide the correction information to generate a corrective invoice": "Debes informar la información de corrección para generar una factura rectificativa",
- "This ticket can't be invoiced": "Este ticket no puede ser facturado",
- "You cannot add or modify services to an invoiced ticket": "No puedes añadir o modificar servicios a un ticket facturado",
- "This ticket can not be modified": "Este ticket no puede ser modificado",
- "The introduced hour already exists": "Esta hora ya ha sido introducida",
- "INFINITE_LOOP": "Existe una dependencia entre dos Jefes",
- "The sales of the receiver ticket can't be modified": "Las lineas del ticket al que envias no pueden ser modificadas",
- "NO_AGENCY_AVAILABLE": "No hay una zona de reparto disponible con estos parámetros",
- "ERROR_PAST_SHIPMENT": "No puedes seleccionar una fecha de envío en pasado",
- "The current ticket can't be modified": "El ticket actual no puede ser modificado",
- "The current claim can't be modified": "La reclamación actual no puede ser modificada",
- "The sales of this ticket can't be modified": "Las lineas de este ticket no pueden ser modificadas",
- "The sales do not exists": "La(s) línea(s) seleccionada(s) no existe(n)",
- "Please select at least one sale": "Por favor selecciona al menos una linea",
- "All sales must belong to the same ticket": "Todas las lineas deben pertenecer al mismo ticket",
- "NO_ZONE_FOR_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada",
- "This item doesn't exists": "El artículo no existe",
- "NOT_ZONE_WITH_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada",
- "Extension format is invalid": "El formato de la extensión es inválido",
- "Invalid parameters to create a new ticket": "Parámetros inválidos para crear un nuevo ticket",
- "This item is not available": "Este artículo no está disponible",
- "This postcode already exists": "Este código postal ya existe",
- "Concept cannot be blank": "El concepto no puede quedar en blanco",
- "File doesn't exists": "El archivo no existe",
- "You don't have privileges to change the zone": "No tienes permisos para cambiar la zona o para esos parámetros hay más de una opción de envío, hable con las agencias",
- "This ticket is already on weekly tickets": "Este ticket ya está en tickets programados",
- "Ticket id cannot be blank": "El id de ticket no puede quedar en blanco",
- "Weekday cannot be blank": "El día de la semana no puede quedar en blanco",
- "You can't delete a confirmed order": "No puedes borrar un pedido confirmado",
- "The social name has an invalid format": "El nombre fiscal tiene un formato incorrecto",
- "Invalid quantity": "Cantidad invalida",
- "This postal code is not valid": "Este código postal no es válido",
- "is invalid": "es inválido",
- "The postcode doesn't exist. Please enter a correct one": "El código postal no existe. Por favor, introduce uno correcto",
- "The department name can't be repeated": "El nombre del departamento no puede repetirse",
- "This phone already exists": "Este teléfono ya existe",
- "You cannot move a parent to its own sons": "No puedes mover un elemento padre a uno de sus hijos",
- "You can't create a claim for a removed ticket": "No puedes crear una reclamación para un ticket eliminado",
- "You cannot delete a ticket that part of it is being prepared": "No puedes eliminar un ticket en el que una parte que está siendo preparada",
- "You must delete all the buy requests first": "Debes eliminar todas las peticiones de compra primero",
- "You should specify a date": "Debes especificar una fecha",
- "You should specify at least a start or end date": "Debes especificar al menos una fecha de inicio o de fin",
- "Start date should be lower than end date": "La fecha de inicio debe ser menor que la fecha de fin",
- "You should mark at least one week day": "Debes marcar al menos un día de la semana",
- "Swift / BIC can't be empty": "Swift / BIC no puede estar vacío",
- "Customs agent is required for a non UEE member": "El agente de aduanas es requerido para los clientes extracomunitarios",
- "Incoterms is required for a non UEE member": "El incoterms es requerido para los clientes extracomunitarios",
- "Deleted sales from ticket": "He eliminado las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{deletions}}}",
- "Added sale to ticket": "He añadido la siguiente linea al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}",
- "Changed sale discount": "He cambiado el descuento de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}} {{ticketWeekly}}",
- "Created claim": "He creado la reclamación [{{claimId}}]({{{claimUrl}}}) de las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
- "Changed sale price": "He cambiado el precio de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* del ticket [{{ticketId}}]({{{ticketUrl}}}) {{ticketWeekly}} ",
- "Changed sale quantity": "He cambiado {{changes}} del ticket [{{ticketId}}]({{{ticketUrl}}}) {{ticketWeekly}}",
- "Changes in sales": "la cantidad de [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}*",
- "State": "Estado",
- "regular": "normal",
- "reserved": "reservado",
- "Changed sale reserved state": "He cambiado el estado reservado de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
- "Bought units from buy request": "Se ha comprado {{quantity}} unidades de [{{itemId}} {{concept}}]({{{urlItem}}}) para el ticket id [{{ticketId}}]({{{url}}})",
- "Deny buy request": "Se ha rechazado la petición de compra para el ticket id [{{ticketId}}]({{{url}}}). Motivo: {{observation}}",
- "MESSAGE_INSURANCE_CHANGE": "He cambiado el crédito asegurado del cliente [{{clientName}} ({{clientId}})]({{{url}}}) a *{{credit}} €*",
- "Changed client paymethod": "He cambiado la forma de pago del cliente [{{clientName}} ({{clientId}})]({{{url}}})",
- "Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} ({{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [{{ticketId}}]({{{ticketUrl}}})",
- "Change quantity": "{{concept}} cambia de {{oldQuantity}} a {{newQuantity}}",
- "Claim will be picked": "Se recogerá el género de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}*, con el tipo de recogida *{{claimPickup}}*",
- "Claim state has changed to": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *{{newState}}*",
- "Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}",
- "ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto",
- "Distance must be lesser than 4000": "La distancia debe ser inferior a 4000",
- "This ticket is deleted": "Este ticket está eliminado",
- "Unable to clone this travel": "No ha sido posible clonar este travel",
- "This thermograph id already exists": "La id del termógrafo ya existe",
- "Choose a date range or days forward": "Selecciona un rango de fechas o días en adelante",
- "ORDER_ALREADY_CONFIRMED": "ORDEN YA CONFIRMADA",
- "Invalid password": "Invalid password",
- "Password does not meet requirements": "La contraseña no cumple los requisitos",
- "Role already assigned": "Rol ya asignado",
- "Invalid role name": "Nombre de rol no válido",
- "Role name must be written in camelCase": "El nombre del rol debe escribirse en camelCase",
- "Email already exists": "El correo ya existe",
- "User already exists": "El/La usuario/a ya existe",
- "Absence change notification on the labour calendar": "Notificación de cambio de ausencia en el calendario laboral",
- "Record of hours week": "Registro de horas semana {{week}} año {{year}} ",
- "Created absence": "El empleado {{author}} ha añadido una ausencia de tipo '{{absenceType}}' a {{employee}} para el día {{dated}}.",
- "Deleted absence": "El empleado {{author}} ha eliminado una ausencia de tipo '{{absenceType}}' a {{employee}} del día {{dated}}.",
- "I have deleted the ticket id": "He eliminado el ticket id [{{id}}]({{{url}}})",
- "I have restored the ticket id": "He restaurado el ticket id [{{id}}]({{{url}}})",
- "You can only restore a ticket within the first hour after deletion": "Únicamente puedes restaurar el ticket dentro de la primera hora después de su eliminación",
- "Changed this data from the ticket": "He cambiado estos datos del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
- "agencyModeFk": "Agencia",
- "clientFk": "Cliente",
- "zoneFk": "Zona",
- "warehouseFk": "Almacén",
- "shipped": "F. envío",
- "landed": "F. entrega",
- "addressFk": "Consignatario",
- "companyFk": "Empresa",
- "agency": "Agencia",
- "delivery": "Reparto",
- "The social name cannot be empty": "La razón social no puede quedar en blanco",
- "The nif cannot be empty": "El NIF no puede quedar en blanco",
- "You need to fill sage information before you check verified data": "Debes rellenar la información de sage antes de marcar datos comprobados",
- "ASSIGN_ZONE_FIRST": "Asigna una zona primero",
- "Amount cannot be zero": "El importe no puede ser cero",
- "Company has to be official": "Empresa inválida",
- "You can not select this payment method without a registered bankery account": "No se puede utilizar este método de pago si no has registrado una cuenta bancaria",
- "Action not allowed on the test environment": "Esta acción no está permitida en el entorno de pruebas",
- "The selected ticket is not suitable for this route": "El ticket seleccionado no es apto para esta ruta",
- "New ticket request has been created with price": "Se ha creado una nueva petición de compra '{{description}}' para el día *{{shipped}}*, con una cantidad de *{{quantity}}* y un precio de *{{price}} €*",
- "New ticket request has been created": "Se ha creado una nueva petición de compra '{{description}}' para el día *{{shipped}}*, con una cantidad de *{{quantity}}*",
- "Swift / BIC cannot be empty": "Swift / BIC no puede estar vacío",
- "This BIC already exist.": "Este BIC ya existe.",
- "That item doesn't exists": "Ese artículo no existe",
- "There's a new urgent ticket:": "Hay un nuevo ticket urgente:",
- "Invalid account": "Cuenta inválida",
- "Compensation account is empty": "La cuenta para compensar está vacia",
- "This genus already exist": "Este genus ya existe",
- "This specie already exist": "Esta especie ya existe",
- "Client assignment has changed": "He cambiado el comercial ~*\"<{{previousWorkerName}}>\"*~ por *\"<{{currentWorkerName}}>\"* del cliente [{{clientName}} ({{clientId}})]({{{url}}})",
- "None": "Ninguno",
- "The contract was not active during the selected date": "El contrato no estaba activo durante la fecha seleccionada",
- "Cannot add more than one '1/2 day vacation'": "No puedes añadir más de un 'Vacaciones 1/2 dia'",
- "This document already exists on this ticket": "Este documento ya existe en el ticket",
- "Some of the selected tickets are not billable": "Algunos de los tickets seleccionados no son facturables",
- "You can't invoice tickets from multiple clients": "No puedes facturar tickets de multiples clientes",
- "nickname": "nickname",
- "INACTIVE_PROVIDER": "Proveedor inactivo",
- "This client is not invoiceable": "Este cliente no es facturable",
- "serial non editable": "Esta serie no permite asignar la referencia",
- "Max shipped required": "La fecha límite es requerida",
- "Can't invoice to future": "No se puede facturar a futuro",
- "Can't invoice to past": "No se puede facturar a pasado",
- "This ticket is already invoiced": "Este ticket ya está facturado",
- "A ticket with an amount of zero can't be invoiced": "No se puede facturar un ticket con importe cero",
- "A ticket with a negative base can't be invoiced": "No se puede facturar un ticket con una base negativa",
- "Global invoicing failed": "[Facturación global] No se han podido facturar algunos clientes",
- "Wasn't able to invoice the following clients": "No se han podido facturar los siguientes clientes",
- "Can't verify data unless the client has a business type": "No se puede verificar datos de un cliente que no tiene tipo de negocio",
- "You don't have enough privileges to set this credit amount": "No tienes suficientes privilegios para establecer esta cantidad de crédito",
- "You can't change the credit set to zero from a financialBoss": "No puedes cambiar el cŕedito establecido a cero por un jefe de finanzas",
- "Amounts do not match": "Las cantidades no coinciden",
- "The PDF document does not exist": "El documento PDF no existe. Prueba a regenerarlo desde la opción 'Regenerar PDF factura'",
- "The type of business must be filled in basic data": "El tipo de negocio debe estar rellenado en datos básicos",
- "You can't create a claim from a ticket delivered more than seven days ago": "No puedes crear una reclamación de un ticket entregado hace más de siete días",
- "The worker has hours recorded that day": "El trabajador tiene horas fichadas ese día",
- "The worker has a marked absence that day": "El trabajador tiene marcada una ausencia ese día",
- "You can not modify is pay method checked": "No se puede modificar el campo método de pago validado",
- "The account size must be exactly 10 characters": "El tamaño de la cuenta debe ser exactamente de 10 caracteres",
- "Can't transfer claimed sales": "No puedes transferir lineas reclamadas",
- "You don't have privileges to create refund": "No tienes permisos para crear un abono",
- "The item is required": "El artículo es requerido",
- "The agency is already assigned to another autonomous": "La agencia ya está asignada a otro autónomo",
- "date in the future": "Fecha en el futuro",
- "reference duplicated": "Referencia duplicada",
- "This ticket is already a refund": "Este ticket ya es un abono",
- "isWithoutNegatives": "Sin negativos",
- "routeFk": "routeFk",
- "Can't change the password of another worker": "No se puede cambiar la contraseña de otro trabajador",
- "No hay un contrato en vigor": "No hay un contrato en vigor",
- "No se permite fichar a futuro": "No se permite fichar a futuro",
- "No está permitido trabajar": "No está permitido trabajar",
- "Fichadas impares": "Fichadas impares",
- "Descanso diario 12h.": "Descanso diario 12h.",
- "Descanso semanal 36h. / 72h.": "Descanso semanal 36h. / 72h.",
- "Dirección incorrecta": "Dirección incorrecta",
- "Modifiable user details only by an administrator": "Detalles de usuario modificables solo por un administrador",
- "Modifiable password only via recovery or by an administrator": "Contraseña modificable solo a través de la recuperación o por un administrador",
- "Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente",
- "This route does not exists": "Esta ruta no existe",
- "Claim pickup order sent": "Reclamación Orden de recogida enviada [{{claimId}}]({{{claimUrl}}}) al cliente *{{clientName}}*",
- "You don't have grant privilege": "No tienes privilegios para dar privilegios",
- "You don't own the role and you can't assign it to another user": "No eres el propietario del rol y no puedes asignarlo a otro usuario",
- "Ticket merged": "Ticket [{{originId}}]({{{originFullPath}}}) ({{{originDated}}}) fusionado con [{{destinationId}}]({{{destinationFullPath}}}) ({{{destinationDated}}})",
- "Already has this status": "Ya tiene este estado",
- "There aren't records for this week": "No existen registros para esta semana",
- "Empty data source": "Origen de datos vacio",
- "App locked": "Aplicación bloqueada por el usuario {{userId}}",
- "Email verify": "Correo de verificación",
- "Landing cannot be lesser than shipment": "Landing cannot be lesser than shipment",
- "Receipt's bank was not found": "No se encontró el banco del recibo",
- "This receipt was not compensated": "Este recibo no ha sido compensado",
- "Client's email was not found": "No se encontró el email del cliente",
- "Negative basis": "Base negativa",
- "This worker code already exists": "Este codigo de trabajador ya existe",
- "This personal mail already exists": "Este correo personal ya existe",
- "This worker already exists": "Este trabajador ya existe",
- "App name does not exist": "El nombre de aplicación no es válido",
- "Try again": "Vuelve a intentarlo",
- "Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9",
- "Failed to upload delivery note": "Error al subir albarán {{id}}",
- "The DOCUWARE PDF document does not exists": "El documento PDF Docuware no existe",
- "It is not possible to modify tracked sales": "No es posible modificar líneas de pedido que se hayan empezado a preparar",
- "It is not possible to modify sales that their articles are from Floramondo": "No es posible modificar líneas de pedido cuyos artículos sean de Floramondo",
- "It is not possible to modify cloned sales": "No es posible modificar líneas de pedido clonadas",
- "A supplier with the same name already exists. Change the country.": "Un proveedor con el mismo nombre ya existe. Cambie el país.",
- "There is no assigned email for this client": "No hay correo asignado para este cliente",
- "Exists an invoice with a future date": "Existe una factura con fecha posterior",
- "Invoice date can't be less than max date": "La fecha de factura no puede ser inferior a la fecha límite",
- "Warehouse inventory not set": "El almacén inventario no está establecido",
- "This locker has already been assigned": "Esta taquilla ya ha sido asignada",
- "Tickets with associated refunds": "No se pueden borrar tickets con abonos asociados. Este ticket está asociado al abono Nº %s",
- "Not exist this branch": "La rama no existe",
- "This ticket cannot be signed because it has not been boxed": "Este ticket no puede firmarse porque no ha sido encajado",
- "Collection does not exist": "La colección no existe",
- "Cannot obtain exclusive lock": "No se puede obtener un bloqueo exclusivo",
- "Insert a date range": "Inserte un rango de fechas",
- "Added observation": "{{user}} añadió esta observacion: {{text}} {{defaulterId}} ({{{defaulterUrl}}})",
- "Comment added to client": "Observación añadida al cliente {{clientFk}}",
- "Invalid auth code": "Código de verificación incorrecto",
- "Invalid or expired verification code": "Código de verificación incorrecto o expirado",
- "Cannot create a new claimBeginning from a different ticket": "No se puede crear una línea de reclamación de un ticket diferente al origen",
- "company": "Compañía",
- "country": "País",
- "clientId": "Id cliente",
- "clientSocialName": "Cliente",
- "amount": "Importe",
- "taxableBase": "Base",
- "ticketFk": "Id ticket",
- "isActive": "Activo",
- "hasToInvoice": "Facturar",
- "isTaxDataChecked": "Datos comprobados",
- "comercialId": "Id comercial",
- "comercialName": "Comercial",
- "Pass expired": "La contraseña ha caducado, cambiela desde Salix",
- "Invalid NIF for VIES": "Invalid NIF for VIES",
- "Ticket does not exist": "Este ticket no existe",
- "Ticket is already signed": "Este ticket ya ha sido firmado",
- "Authentication failed": "Autenticación fallida",
- "You can't use the same password": "No puedes usar la misma contraseña",
- "You can only add negative amounts in refund tickets": "Solo se puede añadir cantidades negativas en tickets abono",
- "Fecha fuera de rango": "Fecha fuera de rango",
- "Error while generating PDF": "Error al generar PDF",
- "Error when sending mail to client": "Error al enviar el correo al cliente",
- "Mail not sent": "Se ha producido un fallo al enviar la factura al cliente [{{clientId}}]({{{clientUrl}}}), por favor revisa la dirección de correo electrónico",
- "The renew period has not been exceeded": "El periodo de renovación no ha sido superado",
- "Valid priorities": "Prioridades válidas: %d",
- "hasAnyNegativeBase": "Base negativa para los tickets: {{ticketsIds}}",
- "hasAnyPositiveBase": "Base positivas para los tickets: {{ticketsIds}}",
- "You cannot assign an alias that you are not assigned to": "No puede asignar un alias que no tenga asignado",
- "This ticket cannot be left empty.": "Este ticket no se puede dejar vacío. %s",
- "The company has not informed the supplier account for bank transfers": "La empresa no tiene informado la cuenta de proveedor para transferencias bancarias",
- "You cannot assign/remove an alias that you are not assigned to": "No puede asignar/eliminar un alias que no tenga asignado",
- "This invoice has a linked vehicle.": "Esta factura tiene un vehiculo vinculado",
- "You don't have enough privileges.": "No tienes suficientes permisos.",
- "This ticket is locked": "Este ticket está bloqueado.",
- "This ticket is not editable.": "Este ticket no es editable.",
- "The ticket doesn't exist.": "No existe el ticket.",
- "Social name should be uppercase": "La razón social debe ir en mayúscula",
- "Street should be uppercase": "La dirección fiscal debe ir en mayúscula",
- "Ticket without Route": "Ticket sin ruta",
- "Select a different client": "Seleccione un cliente distinto",
- "Fill all the fields": "Rellene todos los campos",
- "The response is not a PDF": "La respuesta no es un PDF",
- "Booking completed": "Reserva completada",
- "The ticket is in preparation": "El ticket [{{ticketId}}]({{{ticketUrl}}}) del comercial {{salesPersonId}} está en preparación",
- "The notification subscription of this worker cant be modified": "La subscripción a la notificación de este trabajador no puede ser modificada",
- "User disabled": "Usuario desactivado",
- "The amount cannot be less than the minimum": "La cantidad no puede ser menor que la cantidad mínima",
- "quantityLessThanMin": "La cantidad no puede ser menor que la cantidad mínima",
- "Cannot past travels with entries": "No se pueden pasar envíos con entradas",
- "It was not able to remove the next expeditions:": "No se pudo eliminar las siguientes expediciones: {{expeditions}}",
- "This claim has been updated": "La reclamación con Id: {{claimId}}, ha sido actualizada",
- "This user does not have an assigned tablet": "Este usuario no tiene tablet asignada",
- "Field are invalid": "El campo '{{tag}}' no es válido",
- "Incorrect pin": "Pin incorrecto.",
- "You already have the mailAlias": "Ya tienes este alias de correo",
- "The alias cant be modified": "Este alias de correo no puede ser modificado",
- "No tickets to invoice": "No hay tickets para facturar que cumplan los requisitos de facturación",
- "this warehouse has not dms": "El Almacén no acepta documentos",
- "This ticket already has a cmr saved": "Este ticket ya tiene un cmr guardado",
- "Name should be uppercase": "El nombre debe ir en mayúscula",
- "Bank entity must be specified": "La entidad bancaria es obligatoria",
- "An email is necessary": "Es necesario un email",
- "You cannot update these fields": "No puedes actualizar estos campos",
- "CountryFK cannot be empty": "El país no puede estar vacío",
- "Cmr file does not exist": "El archivo del cmr no existe",
- "You are not allowed to modify the alias": "No estás autorizado a modificar el alias",
- "The address of the customer must have information about Incoterms and Customs Agent": "El consignatario del cliente debe tener informado Incoterms y Agente de aduanas",
- "No invoice series found for these parameters": "No se encontró una serie para estos parámetros",
- "The line could not be marked": "La linea no puede ser marcada",
- "Through this procedure, it is not possible to modify the password of users with verified email": "Mediante este procedimiento, no es posible modificar la contraseña de usuarios con correo verificado",
- "They're not your subordinate": "No es tu subordinado/a.",
- "No results found": "No se han encontrado resultados",
- "InvoiceIn is already booked": "La factura recibida está contabilizada",
- "This workCenter is already assigned to this agency": "Este centro de trabajo ya está asignado a esta agencia",
- "Select ticket or client": "Elija un ticket o un client",
- "It was not able to create the invoice": "No se pudo crear la factura",
- "Incoterms and Customs agent are required for a non UEE member": "Se requieren Incoterms y agente de aduanas para un no miembro de la UEE",
- "You can not use the same password": "No puedes usar la misma contraseña",
- "This PDA is already assigned to another user": "Este PDA ya está asignado a otro usuario",
- "You can only have one PDA": "Solo puedes tener un PDA",
- "The invoices have been created but the PDFs could not be generated": "Se ha facturado pero no se ha podido generar el PDF",
- "It has been invoiced but the PDF of refund not be generated": "Se ha facturado pero no se ha podido generar el PDF del abono",
- "Payment method is required": "El método de pago es obligatorio",
- "Cannot send mail": "Não é possível enviar o email",
- "CONSTRAINT `supplierAccountTooShort` failed for `vn`.`supplier`": "La cuenta debe tener exactamente 10 dígitos",
- "The sale not exists in the item shelving": "La venta no existe en la estantería del artículo",
- "The entry not have stickers": "La entrada no tiene etiquetas",
- "Too many records": "Demasiados registros",
- "Original invoice not found": "Factura original no encontrada",
- "The entry has no lines or does not exist": "La entrada no tiene lineas o no existe",
- "Weight already set": "El peso ya está establecido",
- "This ticket is not allocated to your department": "Este ticket no está asignado a tu departamento",
- "There is already a tray with the same height": "Ya existe una bandeja con la misma altura",
- "The height must be greater than 50cm": "La altura debe ser superior a 50cm",
- "The maximum height of the wagon is 200cm": "La altura máxima es 200cm",
- "The entry does not have stickers": "La entrada no tiene etiquetas",
- "This buyer has already made a reservation for this date": "Este comprador ya ha hecho una reserva para esta fecha",
- "No valid travel thermograph found": "No se encontró un termógrafo válido",
- "The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea",
- "type cannot be blank": "Se debe rellenar el tipo",
- "There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero",
- "There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén",
- "You do not have permission to modify the booked field": "No tienes permisos para modificar el campo contabilizada",
- "ticketLostExpedition": "El ticket [{{ticketId}}]({{{ticketUrl}}}) tiene la siguiente expedición perdida:{{ expeditionId }}",
- "The web user's email already exists": "El correo del usuario web ya existe",
- "Sales already moved": "Ya han sido transferidas",
- "The raid information is not correct": "La información de la redada no es correcta",
- "An item type with the same code already exists": "Un tipo con el mismo código ya existe",
- "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles",
- "All tickets have a route order": "Todos los tickets tienen orden de ruta",
- "There are tickets to be invoiced": "La zona tiene tickets por facturar",
- "Incorrect delivery order alert on route": "Alerta de orden de entrega incorrecta en ruta: {{ route }} zona: {{ zone }}",
- "Ticket has been delivered out of order": "El ticket {{ticket}} {{{fullUrl}}} no ha sido entregado en su orden.",
- "Price cannot be blank": "El precio no puede estar en blanco",
- "clonedFromTicketWeekly": ", que es una linea clonada del ticket {{ticketWeekly}}",
- "negativeReplaced": "Sustituido el articulo [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} por [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} del ticket [{{ticketId}}]({{{ticketUrl}}})"
-}
+ "The grade must be similar to the last one": "El grade debe ser similar al último",
+ "Only manager can change the credit": "Solo el gerente puede cambiar el credito de este cliente",
+ "Name cannot be blank": "El nombre no puede estar en blanco",
+ "Phone cannot be blank": "El teléfono no puede estar en blanco",
+ "Period cannot be blank": "El periodo no puede estar en blanco",
+ "Choose a company": "Selecciona una empresa",
+ "Se debe rellenar el campo de texto": "Se debe rellenar el campo de texto",
+ "Description should have maximum of 45 characters": "La descripción debe tener maximo 45 caracteres",
+ "Cannot be blank": "El campo no puede estar en blanco",
+ "The grade must be an integer greater than or equal to zero": "El grade debe ser un entero mayor o igual a cero",
+ "Sample type cannot be blank": "El tipo de plantilla no puede quedar en blanco",
+ "Description cannot be blank": "Se debe rellenar el campo de texto",
+ "The price of the item changed": "El precio del artículo cambió",
+ "The value should not be greater than 100%": "El valor no debe de ser mayor de 100%",
+ "The value should be a number": "El valor debe ser un numero",
+ "This order is not editable": "Esta orden no se puede modificar",
+ "You can't create an order for a frozen client": "No puedes crear una orden para un cliente congelado",
+ "You can't create an order for a client that has a debt": "No puedes crear una orden para un cliente con deuda",
+ "is not a valid date": "No es una fecha valida",
+ "Barcode must be unique": "El código de barras debe ser único",
+ "The warehouse can't be repeated": "El almacén no puede repetirse",
+ "The tag or priority can't be repeated for an item": "El tag o prioridad no puede repetirse para un item",
+ "The observation type can't be repeated": "El tipo de observación no puede repetirse",
+ "A claim with that sale already exists": "Ya existe una reclamación para esta línea",
+ "You don't have enough privileges to change that field": "No tienes permisos para cambiar ese campo",
+ "Warehouse cannot be blank": "El almacén no puede quedar en blanco",
+ "Agency cannot be blank": "La agencia no puede quedar en blanco",
+ "Not enough privileges to edit a client with verified data": "No tienes permisos para hacer cambios en un cliente con datos comprobados",
+ "This address doesn't exist": "Este consignatario no existe",
+ "You must delete the claim id %d first": "Antes debes borrar la reclamación %d",
+ "You don't have enough privileges": "No tienes suficientes permisos",
+ "Cannot check Equalization Tax in this NIF/CIF": "No se puede marcar RE en este NIF/CIF",
+ "You can't make changes on the basic data of an confirmed order or with rows": "No puedes cambiar los datos básicos de una orden con artículos",
+ "INVALID_USER_NAME": "El nombre de usuario solo debe contener letras minúsculas o, a partir del segundo carácter, números o subguiones, no está permitido el uso de la letra ñ",
+ "You can't create a ticket for a frozen client": "No puedes crear un ticket para un cliente congelado",
+ "You can't create a ticket for an inactive client": "No puedes crear un ticket para un cliente inactivo",
+ "Tag value cannot be blank": "El valor del tag no puede quedar en blanco",
+ "ORDER_EMPTY": "Cesta vacía",
+ "You don't have enough privileges to do that": "No tienes permisos para cambiar esto",
+ "NO SE PUEDE DESACTIVAR EL CONSIGNAT": "NO SE PUEDE DESACTIVAR EL CONSIGNAT",
+ "Error. El NIF/CIF está repetido": "Error. El NIF/CIF está repetido",
+ "Street cannot be empty": "Dirección no puede estar en blanco",
+ "City cannot be empty": "Ciudad no puede estar en blanco",
+ "Code cannot be blank": "Código no puede estar en blanco",
+ "You cannot remove this department": "No puedes eliminar este departamento",
+ "The extension must be unique": "La extensión debe ser unica",
+ "The secret can't be blank": "La contraseña no puede estar en blanco",
+ "We weren't able to send this SMS": "No hemos podido enviar el SMS",
+ "This client can't be invoiced": "Este cliente no puede ser facturado",
+ "You must provide the correction information to generate a corrective invoice": "Debes informar la información de corrección para generar una factura rectificativa",
+ "This ticket can't be invoiced": "Este ticket no puede ser facturado",
+ "You cannot add or modify services to an invoiced ticket": "No puedes añadir o modificar servicios a un ticket facturado",
+ "This ticket can not be modified": "Este ticket no puede ser modificado",
+ "The introduced hour already exists": "Esta hora ya ha sido introducida",
+ "INFINITE_LOOP": "Existe una dependencia entre dos Jefes",
+ "The sales of the receiver ticket can't be modified": "Las lineas del ticket al que envias no pueden ser modificadas",
+ "NO_AGENCY_AVAILABLE": "No hay una zona de reparto disponible con estos parámetros",
+ "ERROR_PAST_SHIPMENT": "No puedes seleccionar una fecha de envío en pasado",
+ "The current ticket can't be modified": "El ticket actual no puede ser modificado",
+ "The current claim can't be modified": "La reclamación actual no puede ser modificada",
+ "The sales of this ticket can't be modified": "Las lineas de este ticket no pueden ser modificadas",
+ "The sales do not exists": "La(s) línea(s) seleccionada(s) no existe(n)",
+ "Please select at least one sale": "Por favor selecciona al menos una linea",
+ "All sales must belong to the same ticket": "Todas las lineas deben pertenecer al mismo ticket",
+ "NO_ZONE_FOR_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada",
+ "This item doesn't exists": "El artículo no existe",
+ "NOT_ZONE_WITH_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada",
+ "Extension format is invalid": "El formato de la extensión es inválido",
+ "Invalid parameters to create a new ticket": "Parámetros inválidos para crear un nuevo ticket",
+ "This item is not available": "Este artículo no está disponible",
+ "This postcode already exists": "Este código postal ya existe",
+ "Concept cannot be blank": "El concepto no puede quedar en blanco",
+ "File doesn't exists": "El archivo no existe",
+ "You don't have privileges to change the zone": "No tienes permisos para cambiar la zona o para esos parámetros hay más de una opción de envío, hable con las agencias",
+ "This ticket is already on weekly tickets": "Este ticket ya está en tickets programados",
+ "Ticket id cannot be blank": "El id de ticket no puede quedar en blanco",
+ "Weekday cannot be blank": "El día de la semana no puede quedar en blanco",
+ "You can't delete a confirmed order": "No puedes borrar un pedido confirmado",
+ "The social name has an invalid format": "El nombre fiscal tiene un formato incorrecto",
+ "Invalid quantity": "Cantidad invalida",
+ "This postal code is not valid": "Este código postal no es válido",
+ "is invalid": "es inválido",
+ "The postcode doesn't exist. Please enter a correct one": "El código postal no existe. Por favor, introduce uno correcto",
+ "The department name can't be repeated": "El nombre del departamento no puede repetirse",
+ "This phone already exists": "Este teléfono ya existe",
+ "You cannot move a parent to its own sons": "No puedes mover un elemento padre a uno de sus hijos",
+ "You can't create a claim for a removed ticket": "No puedes crear una reclamación para un ticket eliminado",
+ "You cannot delete a ticket that part of it is being prepared": "No puedes eliminar un ticket en el que una parte que está siendo preparada",
+ "You must delete all the buy requests first": "Debes eliminar todas las peticiones de compra primero",
+ "You should specify a date": "Debes especificar una fecha",
+ "You should specify at least a start or end date": "Debes especificar al menos una fecha de inicio o de fin",
+ "Start date should be lower than end date": "La fecha de inicio debe ser menor que la fecha de fin",
+ "You should mark at least one week day": "Debes marcar al menos un día de la semana",
+ "Swift / BIC can't be empty": "Swift / BIC no puede estar vacío",
+ "Customs agent is required for a non UEE member": "El agente de aduanas es requerido para los clientes extracomunitarios",
+ "Incoterms is required for a non UEE member": "El incoterms es requerido para los clientes extracomunitarios",
+ "Deleted sales from ticket": "He eliminado las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{deletions}}}",
+ "Added sale to ticket": "He añadido la siguiente linea al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}",
+ "Changed sale discount": "He cambiado el descuento de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}} {{ticketWeekly}}",
+ "Created claim": "He creado la reclamación [{{claimId}}]({{{claimUrl}}}) de las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
+ "Changed sale price": "He cambiado el precio de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* del ticket [{{ticketId}}]({{{ticketUrl}}}) {{ticketWeekly}} ",
+ "Changed sale quantity": "He cambiado {{changes}} del ticket [{{ticketId}}]({{{ticketUrl}}}) {{ticketWeekly}}",
+ "Changes in sales": "la cantidad de [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}*",
+ "State": "Estado",
+ "regular": "normal",
+ "reserved": "reservado",
+ "Changed sale reserved state": "He cambiado el estado reservado de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
+ "Bought units from buy request": "Se ha comprado {{quantity}} unidades de [{{itemId}} {{concept}}]({{{urlItem}}}) para el ticket id [{{ticketId}}]({{{url}}})",
+ "Deny buy request": "Se ha rechazado la petición de compra para el ticket id [{{ticketId}}]({{{url}}}). Motivo: {{observation}}",
+ "MESSAGE_INSURANCE_CHANGE": "He cambiado el crédito asegurado del cliente [{{clientName}} ({{clientId}})]({{{url}}}) a *{{credit}} €*",
+ "Changed client paymethod": "He cambiado la forma de pago del cliente [{{clientName}} ({{clientId}})]({{{url}}})",
+ "Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} ({{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [{{ticketId}}]({{{ticketUrl}}})",
+ "Change quantity": "{{concept}} cambia de {{oldQuantity}} a {{newQuantity}}",
+ "Claim will be picked": "Se recogerá el género de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}*, con el tipo de recogida *{{claimPickup}}*",
+ "Claim state has changed to": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *{{newState}}*",
+ "Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}",
+ "ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto",
+ "Distance must be lesser than 4000": "La distancia debe ser inferior a 4000",
+ "This ticket is deleted": "Este ticket está eliminado",
+ "Unable to clone this travel": "No ha sido posible clonar este travel",
+ "This thermograph id already exists": "La id del termógrafo ya existe",
+ "Choose a date range or days forward": "Selecciona un rango de fechas o días en adelante",
+ "ORDER_ALREADY_CONFIRMED": "ORDEN YA CONFIRMADA",
+ "Invalid password": "Invalid password",
+ "Password does not meet requirements": "La contraseña no cumple los requisitos",
+ "Role already assigned": "Rol ya asignado",
+ "Invalid role name": "Nombre de rol no válido",
+ "Role name must be written in camelCase": "El nombre del rol debe escribirse en camelCase",
+ "Email already exists": "El correo ya existe",
+ "User already exists": "El/La usuario/a ya existe",
+ "Absence change notification on the labour calendar": "Notificación de cambio de ausencia en el calendario laboral",
+ "Record of hours week": "Registro de horas semana {{week}} año {{year}} ",
+ "Created absence": "El empleado {{author}} ha añadido una ausencia de tipo '{{absenceType}}' a {{employee}} para el día {{dated}}.",
+ "Deleted absence": "El empleado {{author}} ha eliminado una ausencia de tipo '{{absenceType}}' a {{employee}} del día {{dated}}.",
+ "I have deleted the ticket id": "He eliminado el ticket id [{{id}}]({{{url}}})",
+ "I have restored the ticket id": "He restaurado el ticket id [{{id}}]({{{url}}})",
+ "You can only restore a ticket within the first hour after deletion": "Únicamente puedes restaurar el ticket dentro de la primera hora después de su eliminación",
+ "Changed this data from the ticket": "He cambiado estos datos del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
+ "agencyModeFk": "Agencia",
+ "clientFk": "Cliente",
+ "zoneFk": "Zona",
+ "warehouseFk": "Almacén",
+ "shipped": "F. envío",
+ "landed": "F. entrega",
+ "addressFk": "Consignatario",
+ "companyFk": "Empresa",
+ "agency": "Agencia",
+ "delivery": "Reparto",
+ "The social name cannot be empty": "La razón social no puede quedar en blanco",
+ "The nif cannot be empty": "El NIF no puede quedar en blanco",
+ "You need to fill sage information before you check verified data": "Debes rellenar la información de sage antes de marcar datos comprobados",
+ "ASSIGN_ZONE_FIRST": "Asigna una zona primero",
+ "Amount cannot be zero": "El importe no puede ser cero",
+ "Company has to be official": "Empresa inválida",
+ "You can not select this payment method without a registered bankery account": "No se puede utilizar este método de pago si no has registrado una cuenta bancaria",
+ "Action not allowed on the test environment": "Esta acción no está permitida en el entorno de pruebas",
+ "The selected ticket is not suitable for this route": "El ticket seleccionado no es apto para esta ruta",
+ "New ticket request has been created with price": "Se ha creado una nueva petición de compra '{{description}}' para el día *{{shipped}}*, con una cantidad de *{{quantity}}* y un precio de *{{price}} €*",
+ "New ticket request has been created": "Se ha creado una nueva petición de compra '{{description}}' para el día *{{shipped}}*, con una cantidad de *{{quantity}}*",
+ "Swift / BIC cannot be empty": "Swift / BIC no puede estar vacío",
+ "This BIC already exist.": "Este BIC ya existe.",
+ "That item doesn't exists": "Ese artículo no existe",
+ "There's a new urgent ticket:": "Hay un nuevo ticket urgente:",
+ "Invalid account": "Cuenta inválida",
+ "Compensation account is empty": "La cuenta para compensar está vacia",
+ "This genus already exist": "Este genus ya existe",
+ "This specie already exist": "Esta especie ya existe",
+ "Client assignment has changed": "He cambiado el comercial ~*\"<{{previousWorkerName}}>\"*~ por *\"<{{currentWorkerName}}>\"* del cliente [{{clientName}} ({{clientId}})]({{{url}}})",
+ "None": "Ninguno",
+ "The contract was not active during the selected date": "El contrato no estaba activo durante la fecha seleccionada",
+ "Cannot add more than one '1/2 day vacation'": "No puedes añadir más de un 'Vacaciones 1/2 dia'",
+ "This document already exists on this ticket": "Este documento ya existe en el ticket",
+ "Some of the selected tickets are not billable": "Algunos de los tickets seleccionados no son facturables",
+ "You can't invoice tickets from multiple clients": "No puedes facturar tickets de multiples clientes",
+ "nickname": "nickname",
+ "INACTIVE_PROVIDER": "Proveedor inactivo",
+ "This client is not invoiceable": "Este cliente no es facturable",
+ "serial non editable": "Esta serie no permite asignar la referencia",
+ "Max shipped required": "La fecha límite es requerida",
+ "Can't invoice to future": "No se puede facturar a futuro",
+ "Can't invoice to past": "No se puede facturar a pasado",
+ "This ticket is already invoiced": "Este ticket ya está facturado",
+ "A ticket with an amount of zero can't be invoiced": "No se puede facturar un ticket con importe cero",
+ "A ticket with a negative base can't be invoiced": "No se puede facturar un ticket con una base negativa",
+ "Global invoicing failed": "[Facturación global] No se han podido facturar algunos clientes",
+ "Wasn't able to invoice the following clients": "No se han podido facturar los siguientes clientes",
+ "Can't verify data unless the client has a business type": "No se puede verificar datos de un cliente que no tiene tipo de negocio",
+ "You don't have enough privileges to set this credit amount": "No tienes suficientes privilegios para establecer esta cantidad de crédito",
+ "You can't change the credit set to zero from a financialBoss": "No puedes cambiar el cŕedito establecido a cero por un jefe de finanzas",
+ "Amounts do not match": "Las cantidades no coinciden",
+ "The PDF document does not exist": "El documento PDF no existe. Prueba a regenerarlo desde la opción 'Regenerar PDF factura'",
+ "The type of business must be filled in basic data": "El tipo de negocio debe estar rellenado en datos básicos",
+ "You can't create a claim from a ticket delivered more than seven days ago": "No puedes crear una reclamación de un ticket entregado hace más de siete días",
+ "The worker has hours recorded that day": "El trabajador tiene horas fichadas ese día",
+ "The worker has a marked absence that day": "El trabajador tiene marcada una ausencia ese día",
+ "You can not modify is pay method checked": "No se puede modificar el campo método de pago validado",
+ "The account size must be exactly 10 characters": "El tamaño de la cuenta debe ser exactamente de 10 caracteres",
+ "Can't transfer claimed sales": "No puedes transferir lineas reclamadas",
+ "You don't have privileges to create refund": "No tienes permisos para crear un abono",
+ "The item is required": "El artículo es requerido",
+ "The agency is already assigned to another autonomous": "La agencia ya está asignada a otro autónomo",
+ "date in the future": "Fecha en el futuro",
+ "reference duplicated": "Referencia duplicada",
+ "This ticket is already a refund": "Este ticket ya es un abono",
+ "isWithoutNegatives": "Sin negativos",
+ "routeFk": "routeFk",
+ "Can't change the password of another worker": "No se puede cambiar la contraseña de otro trabajador",
+ "No hay un contrato en vigor": "No hay un contrato en vigor",
+ "No se permite fichar a futuro": "No se permite fichar a futuro",
+ "No está permitido trabajar": "No está permitido trabajar",
+ "Fichadas impares": "Fichadas impares",
+ "Descanso diario 12h.": "Descanso diario 12h.",
+ "Descanso semanal 36h. / 72h.": "Descanso semanal 36h. / 72h.",
+ "Dirección incorrecta": "Dirección incorrecta",
+ "Modifiable user details only by an administrator": "Detalles de usuario modificables solo por un administrador",
+ "Modifiable password only via recovery or by an administrator": "Contraseña modificable solo a través de la recuperación o por un administrador",
+ "Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente",
+ "This route does not exists": "Esta ruta no existe",
+ "Claim pickup order sent": "Reclamación Orden de recogida enviada [{{claimId}}]({{{claimUrl}}}) al cliente *{{clientName}}*",
+ "You don't have grant privilege": "No tienes privilegios para dar privilegios",
+ "You don't own the role and you can't assign it to another user": "No eres el propietario del rol y no puedes asignarlo a otro usuario",
+ "Ticket merged": "Ticket [{{originId}}]({{{originFullPath}}}) ({{{originDated}}}) fusionado con [{{destinationId}}]({{{destinationFullPath}}}) ({{{destinationDated}}})",
+ "Already has this status": "Ya tiene este estado",
+ "There aren't records for this week": "No existen registros para esta semana",
+ "Empty data source": "Origen de datos vacio",
+ "App locked": "Aplicación bloqueada por el usuario {{userId}}",
+ "Email verify": "Correo de verificación",
+ "Landing cannot be lesser than shipment": "Landing cannot be lesser than shipment",
+ "Receipt's bank was not found": "No se encontró el banco del recibo",
+ "This receipt was not compensated": "Este recibo no ha sido compensado",
+ "Client's email was not found": "No se encontró el email del cliente",
+ "Negative basis": "Base negativa",
+ "This worker code already exists": "Este codigo de trabajador ya existe",
+ "This personal mail already exists": "Este correo personal ya existe",
+ "This worker already exists": "Este trabajador ya existe",
+ "App name does not exist": "El nombre de aplicación no es válido",
+ "Try again": "Vuelve a intentarlo",
+ "Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9",
+ "Failed to upload delivery note": "Error al subir albarán {{id}}",
+ "The DOCUWARE PDF document does not exists": "El documento PDF Docuware no existe",
+ "It is not possible to modify tracked sales": "No es posible modificar líneas de pedido que se hayan empezado a preparar",
+ "It is not possible to modify sales that their articles are from Floramondo": "No es posible modificar líneas de pedido cuyos artículos sean de Floramondo",
+ "It is not possible to modify cloned sales": "No es posible modificar líneas de pedido clonadas",
+ "A supplier with the same name already exists. Change the country.": "Un proveedor con el mismo nombre ya existe. Cambie el país.",
+ "There is no assigned email for this client": "No hay correo asignado para este cliente",
+ "Exists an invoice with a future date": "Existe una factura con fecha posterior",
+ "Invoice date can't be less than max date": "La fecha de factura no puede ser inferior a la fecha límite",
+ "Warehouse inventory not set": "El almacén inventario no está establecido",
+ "This locker has already been assigned": "Esta taquilla ya ha sido asignada",
+ "Tickets with associated refunds": "No se pueden borrar tickets con abonos asociados. Este ticket está asociado al abono Nº %s",
+ "Not exist this branch": "La rama no existe",
+ "This ticket cannot be signed because it has not been boxed": "Este ticket no puede firmarse porque no ha sido encajado",
+ "Collection does not exist": "La colección no existe",
+ "Cannot obtain exclusive lock": "No se puede obtener un bloqueo exclusivo",
+ "Insert a date range": "Inserte un rango de fechas",
+ "Added observation": "{{user}} añadió esta observacion: {{text}} {{defaulterId}} ({{{defaulterUrl}}})",
+ "Comment added to client": "Observación añadida al cliente {{clientFk}}",
+ "Invalid auth code": "Código de verificación incorrecto",
+ "Invalid or expired verification code": "Código de verificación incorrecto o expirado",
+ "Cannot create a new claimBeginning from a different ticket": "No se puede crear una línea de reclamación de un ticket diferente al origen",
+ "company": "Compañía",
+ "country": "País",
+ "clientId": "Id cliente",
+ "clientSocialName": "Cliente",
+ "amount": "Importe",
+ "taxableBase": "Base",
+ "ticketFk": "Id ticket",
+ "isActive": "Activo",
+ "hasToInvoice": "Facturar",
+ "isTaxDataChecked": "Datos comprobados",
+ "comercialId": "Id comercial",
+ "comercialName": "Comercial",
+ "Pass expired": "La contraseña ha caducado, cambiela desde Salix",
+ "Invalid NIF for VIES": "Invalid NIF for VIES",
+ "Ticket does not exist": "Este ticket no existe",
+ "Ticket is already signed": "Este ticket ya ha sido firmado",
+ "Authentication failed": "Autenticación fallida",
+ "You can't use the same password": "No puedes usar la misma contraseña",
+ "You can only add negative amounts in refund tickets": "Solo se puede añadir cantidades negativas en tickets abono",
+ "Fecha fuera de rango": "Fecha fuera de rango",
+ "Error while generating PDF": "Error al generar PDF",
+ "Error when sending mail to client": "Error al enviar el correo al cliente",
+ "Mail not sent": "Se ha producido un fallo al enviar la factura al cliente [{{clientId}}]({{{clientUrl}}}), por favor revisa la dirección de correo electrónico",
+ "The renew period has not been exceeded": "El periodo de renovación no ha sido superado",
+ "Valid priorities": "Prioridades válidas: %d",
+ "hasAnyNegativeBase": "Base negativa para los tickets: {{ticketsIds}}",
+ "hasAnyPositiveBase": "Base positivas para los tickets: {{ticketsIds}}",
+ "You cannot assign an alias that you are not assigned to": "No puede asignar un alias que no tenga asignado",
+ "This ticket cannot be left empty.": "Este ticket no se puede dejar vacío. %s",
+ "The company has not informed the supplier account for bank transfers": "La empresa no tiene informado la cuenta de proveedor para transferencias bancarias",
+ "You cannot assign/remove an alias that you are not assigned to": "No puede asignar/eliminar un alias que no tenga asignado",
+ "This invoice has a linked vehicle.": "Esta factura tiene un vehiculo vinculado",
+ "You don't have enough privileges.": "No tienes suficientes permisos.",
+ "This ticket is locked": "Este ticket está bloqueado.",
+ "This ticket is not editable.": "Este ticket no es editable.",
+ "The ticket doesn't exist.": "No existe el ticket.",
+ "Social name should be uppercase": "La razón social debe ir en mayúscula",
+ "Street should be uppercase": "La dirección fiscal debe ir en mayúscula",
+ "Ticket without Route": "Ticket sin ruta",
+ "Select a different client": "Seleccione un cliente distinto",
+ "Fill all the fields": "Rellene todos los campos",
+ "The response is not a PDF": "La respuesta no es un PDF",
+ "Booking completed": "Reserva completada",
+ "The ticket is in preparation": "El ticket [{{ticketId}}]({{{ticketUrl}}}) del comercial {{salesPersonId}} está en preparación",
+ "The notification subscription of this worker cant be modified": "La subscripción a la notificación de este trabajador no puede ser modificada",
+ "User disabled": "Usuario desactivado",
+ "The amount cannot be less than the minimum": "La cantidad no puede ser menor que la cantidad mínima",
+ "quantityLessThanMin": "La cantidad no puede ser menor que la cantidad mínima",
+ "Cannot past travels with entries": "No se pueden pasar envíos con entradas",
+ "It was not able to remove the next expeditions:": "No se pudo eliminar las siguientes expediciones: {{expeditions}}",
+ "This claim has been updated": "La reclamación con Id: {{claimId}}, ha sido actualizada",
+ "This user does not have an assigned tablet": "Este usuario no tiene tablet asignada",
+ "Field are invalid": "El campo '{{tag}}' no es válido",
+ "Incorrect pin": "Pin incorrecto.",
+ "You already have the mailAlias": "Ya tienes este alias de correo",
+ "The alias cant be modified": "Este alias de correo no puede ser modificado",
+ "No tickets to invoice": "No hay tickets para facturar que cumplan los requisitos de facturación",
+ "this warehouse has not dms": "El Almacén no acepta documentos",
+ "This ticket already has a cmr saved": "Este ticket ya tiene un cmr guardado",
+ "Name should be uppercase": "El nombre debe ir en mayúscula",
+ "Bank entity must be specified": "La entidad bancaria es obligatoria",
+ "An email is necessary": "Es necesario un email",
+ "You cannot update these fields": "No puedes actualizar estos campos",
+ "CountryFK cannot be empty": "El país no puede estar vacío",
+ "Cmr file does not exist": "El archivo del cmr no existe",
+ "You are not allowed to modify the alias": "No estás autorizado a modificar el alias",
+ "The address of the customer must have information about Incoterms and Customs Agent": "El consignatario del cliente debe tener informado Incoterms y Agente de aduanas",
+ "No invoice series found for these parameters": "No se encontró una serie para estos parámetros",
+ "The line could not be marked": "La linea no puede ser marcada",
+ "Through this procedure, it is not possible to modify the password of users with verified email": "Mediante este procedimiento, no es posible modificar la contraseña de usuarios con correo verificado",
+ "They're not your subordinate": "No es tu subordinado/a.",
+ "No results found": "No se han encontrado resultados",
+ "InvoiceIn is already booked": "La factura recibida está contabilizada",
+ "This workCenter is already assigned to this agency": "Este centro de trabajo ya está asignado a esta agencia",
+ "Select ticket or client": "Elija un ticket o un client",
+ "It was not able to create the invoice": "No se pudo crear la factura",
+ "Incoterms and Customs agent are required for a non UEE member": "Se requieren Incoterms y agente de aduanas para un no miembro de la UEE",
+ "You can not use the same password": "No puedes usar la misma contraseña",
+ "This PDA is already assigned to another user": "Este PDA ya está asignado a otro usuario",
+ "You can only have one PDA": "Solo puedes tener un PDA",
+ "The invoices have been created but the PDFs could not be generated": "Se ha facturado pero no se ha podido generar el PDF",
+ "It has been invoiced but the PDF of refund not be generated": "Se ha facturado pero no se ha podido generar el PDF del abono",
+ "Payment method is required": "El método de pago es obligatorio",
+ "Cannot send mail": "Não é possível enviar o email",
+ "CONSTRAINT `supplierAccountTooShort` failed for `vn`.`supplier`": "La cuenta debe tener exactamente 10 dígitos",
+ "The sale not exists in the item shelving": "La venta no existe en la estantería del artículo",
+ "The entry not have stickers": "La entrada no tiene etiquetas",
+ "Too many records": "Demasiados registros",
+ "Original invoice not found": "Factura original no encontrada",
+ "The entry has no lines or does not exist": "La entrada no tiene lineas o no existe",
+ "Weight already set": "El peso ya está establecido",
+ "This ticket is not allocated to your department": "Este ticket no está asignado a tu departamento",
+ "There is already a tray with the same height": "Ya existe una bandeja con la misma altura",
+ "The height must be greater than 50cm": "La altura debe ser superior a 50cm",
+ "The maximum height of the wagon is 200cm": "La altura máxima es 200cm",
+ "The entry does not have stickers": "La entrada no tiene etiquetas",
+ "This buyer has already made a reservation for this date": "Este comprador ya ha hecho una reserva para esta fecha",
+ "No valid travel thermograph found": "No se encontró un termógrafo válido",
+ "The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea",
+ "type cannot be blank": "Se debe rellenar el tipo",
+ "There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero",
+ "There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén",
+ "You do not have permission to modify the booked field": "No tienes permisos para modificar el campo contabilizada",
+ "ticketLostExpedition": "El ticket [{{ticketId}}]({{{ticketUrl}}}) tiene la siguiente expedición perdida:{{ expeditionId }}",
+ "The web user's email already exists": "El correo del usuario web ya existe",
+ "Sales already moved": "Ya han sido transferidas",
+ "The raid information is not correct": "La información de la redada no es correcta",
+ "An item type with the same code already exists": "Un tipo con el mismo código ya existe",
+ "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles",
+ "All tickets have a route order": "Todos los tickets tienen orden de ruta",
+ "There are tickets to be invoiced": "La zona tiene tickets por facturar",
+ "Incorrect delivery order alert on route": "Alerta de orden de entrega incorrecta en ruta: {{ route }} zona: {{ zone }}",
+ "Ticket has been delivered out of order": "El ticket {{ticket}} {{{fullUrl}}} no ha sido entregado en su orden.",
+ "Price cannot be blank": "El precio no puede estar en blanco",
+ "clonedFromTicketWeekly": ", que es una linea clonada del ticket {{ticketWeekly}}",
+ "negativeReplaced": "Sustituido el articulo [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} por [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} del ticket [{{ticketId}}]({{{ticketUrl}}})",
+ "The introduced warehouse already exists": "El almacén seleccionado ya existe en la zona",
+ "The code already exists": "El código ya existe"
+}
\ No newline at end of file
diff --git a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js
index a0dc2248c4..74ae102d0c 100644
--- a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js
+++ b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js
@@ -74,66 +74,77 @@ module.exports = Self => {
}
try {
- const worker = await models.Worker.findOne({
- where: {id: userId}
- }, myOptions);
-
- const obsevationType = await models.ObservationType.findOne({
- where: {code: 'salesPerson'}
- }, myOptions);
-
- const agencyMode = await models.AgencyMode.findOne({
- where: {code: 'refund'}
- }, myOptions);
-
- const state = await models.State.findOne({
- where: {code: 'DELIVERED'}
- }, myOptions);
-
- const zone = await models.Zone.findOne({
- where: {agencyModeFk: agencyMode.id}
- }, myOptions);
-
const claim = await models.Claim.findOne(filter, myOptions);
const today = Date.vnNew();
+ let agencyModeFk;
+ let nickname;
+ let state;
+ let discountValue = null;
+ let packages = 0;
+ const claimConfig = await models.ClaimConfig.findOne();
+ const warehouseFk = claimConfig.warehouseFk;
+ if (claim.pickup === null || claim.pickup == 'agency') {
+ state = await models.State.findOne({
+ where: {code: 'DELIVERED'}
+ }, myOptions);
+ const agencyMode = await models.AgencyMode.findOne({
+ where: {code: 'refund'}
+ }, myOptions);
+ agencyModeFk = agencyMode.id;
+ nickname = `Abono del: ${claim.ticketFk}`;
+ } else {
+ discountValue = 100;
+ packages = 1;
+ state = await models.State.findOne({
+ where: {code: 'WAITING_FOR_PICKUP'}
+ }, myOptions);
+
+ nickname = `Recogida pendiente del: ${claim.ticketFk}`;
+
+ agencyModeFk = claimConfig.pickupDeliveryFk;
+ }
+ const nextShipped = await models.Agency.getShipped(
+ ctx, today, claim.ticket().addressFk, agencyModeFk, warehouseFk, myOptions
+ );
const newRefundTicket = await models.Ticket.create({
clientFk: claim.ticket().clientFk,
- shipped: today,
- landed: today,
- nickname: `Abono del: ${claim.ticketFk}`,
- warehouseFk: claim.ticket().warehouseFk,
+ shipped: nextShipped.shipped,
+ landed: null,
+ nickname,
+ warehouseFk,
companyFk: claim.ticket().companyFk,
addressFk: claim.ticket().addressFk,
- agencyModeFk: agencyMode.id,
- zoneFk: zone.id
+ agencyModeFk,
+ zoneFk: claim.ticket().zoneFk,
+ packages
}, myOptions);
+ if (claim.pickup == 'pickup') {
+ const observationDelivery =
+ await models.ObservationType.findOne({where: {code: 'delivery'}}, myOptions);
+
+ await saveObservation({
+ description: `recoger reclamación: ${claim.id}`,
+ ticketFk: newRefundTicket.id,
+ observationTypeFk: observationDelivery.id
+ }, myOptions);
+ }
await models.TicketRefund.create({
refundTicketFk: newRefundTicket.id,
originalTicketFk: claim.ticket().id
}, myOptions);
- await saveObservation({
- description: `Reclama ticket: ${claim.ticketFk}`,
- ticketFk: newRefundTicket.id,
- observationTypeFk: obsevationType.id
- }, myOptions);
+ const salesToRefund = await models.ClaimBeginning.find(salesFilter, myOptions);
+ const createdSales = await addSalesToTicket(salesToRefund, newRefundTicket.id, discountValue, myOptions);
+ await insertIntoClaimEnd(createdSales, id, userId, myOptions);
await models.Ticket.state(ctx, {
ticketFk: newRefundTicket.id,
stateFk: state.id,
- userFk: worker.id
+ userFk: userId
}, myOptions);
- const salesToRefund = await models.ClaimBeginning.find(salesFilter, myOptions);
- const createdSales = await addSalesToTicket(salesToRefund, newRefundTicket.id, myOptions);
- await insertIntoClaimEnd(createdSales, id, worker.id, myOptions);
-
- await Self.rawSql('CALL vn.ticketCalculateClon(?, ?)', [
- newRefundTicket.id, claim.ticketFk
- ], myOptions);
-
if (tx) await tx.commit();
return newRefundTicket;
@@ -143,23 +154,36 @@ module.exports = Self => {
}
};
- async function addSalesToTicket(salesToRefund, ticketId, options) {
- let formatedSales = [];
- salesToRefund.forEach(sale => {
- let formatedSale = {
- itemFk: sale.sale().itemFk,
- ticketFk: ticketId,
- concept: sale.sale().concept,
- quantity: -Math.abs(sale.quantity),
- price: sale.sale().price,
- discount: sale.sale().discount,
- reserved: sale.sale().reserved,
- isPicked: sale.sale().isPicked,
- created: sale.sale().created
+ async function addSalesToTicket(salesToRefund, newTicketId, discountValue, options) {
+ const createdSales = [];
+ const models = Self.app.models;
+ for (const saleToRefund of salesToRefund) {
+ const oldSale = saleToRefund.sale();
+ const newSaleData = {
+ itemFk: oldSale.itemFk,
+ ticketFk: newTicketId,
+ concept: oldSale.concept,
+ quantity: -Math.abs(saleToRefund.quantity),
+ price: oldSale.price,
+ discount: discountValue ?? oldSale.discount,
+ reserved: oldSale.reserved,
+ isPicked: oldSale.isPicked,
+ created: oldSale.created
};
- formatedSales.push(formatedSale);
- });
- return await Self.app.models.Sale.create(formatedSales, options);
+ const newSale = await models.Sale.create(newSaleData, options);
+ const oldSaleComponents = await models.SaleComponent.find({
+ where: {saleFk: oldSale.id}
+ }, options);
+ const newComponents = oldSaleComponents.map(component => {
+ const data = component.toJSON ? component.toJSON() : {...component};
+ delete data.id;
+ data.saleFk = newSale.id;
+ return data;
+ });
+ await models.SaleComponent.create(newComponents, options);
+ createdSales.push(newSale);
+ }
+ return createdSales;
}
async function insertIntoClaimEnd(createdSales, claimId, workerId, options) {
diff --git a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js
deleted file mode 100644
index 156caaeec6..0000000000
--- a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js
+++ /dev/null
@@ -1,44 +0,0 @@
-const app = require('vn-loopback/server/server');
-const LoopBackContext = require('loopback-context');
-const models = app.models;
-
-describe('claimBeginning', () => {
- const claimManagerId = 72;
- const activeCtx = {
- accessToken: {userId: claimManagerId},
- __: value => value
- };
- const ctx = {req: activeCtx};
-
- describe('importToNewRefundTicket()', () => {
- it('should create a new ticket with negative sales and insert the negative sales into claimEnd', async() => {
- spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
- active: activeCtx
- });
- let claimId = 1;
-
- const tx = await models.Entry.beginTransaction({});
- try {
- const options = {transaction: tx};
-
- const ticket = await models.ClaimBeginning.importToNewRefundTicket(ctx, claimId, options);
-
- const refundTicketSales = await models.Sale.find({
- where: {ticketFk: ticket.id}
- }, options);
- const salesInsertedInClaimEnd = await models.ClaimEnd.find({
- where: {claimFk: claimId}
- }, options);
-
- expect(refundTicketSales.length).toEqual(1);
- expect(refundTicketSales[0].quantity).toEqual(-5);
- expect(salesInsertedInClaimEnd[0].saleFk).toEqual(refundTicketSales[0].id);
-
- await tx.rollback();
- } catch (e) {
- await tx.rollback();
- throw e;
- }
- });
- });
-});
diff --git a/modules/claim/back/methods/claim-beginning/specs/importToNewRefundTicket.spec.js b/modules/claim/back/methods/claim-beginning/specs/importToNewRefundTicket.spec.js
new file mode 100644
index 0000000000..d305ca1f56
--- /dev/null
+++ b/modules/claim/back/methods/claim-beginning/specs/importToNewRefundTicket.spec.js
@@ -0,0 +1,99 @@
+const app = require('vn-loopback/server/server');
+const LoopBackContext = require('loopback-context');
+const models = app.models;
+
+describe('importToNewRefundTicket()', () => {
+ let tx;
+ const claimManagerId = 72;
+ const activeCtx = {
+ accessToken: {userId: claimManagerId},
+ };
+ let ctx = {req: activeCtx};
+ let options;
+ const claimId = 1;
+ const expectedDate = Date.vnNew();
+
+ beforeEach(async() => {
+ LoopBackContext.getCurrentContext = () => ({
+ active: activeCtx,
+ });
+ tx = await models.Entry.beginTransaction({});
+ options = {transaction: tx};
+ spyOn(models.Agency, 'getShipped').and.returnValue(Promise.resolve({shipped: expectedDate}));
+ });
+
+ afterEach(async() => {
+ await tx.rollback();
+ });
+
+ it('should create a new ticket with negative sales and insert the negative sales into claimEnd', async() => {
+ const ticket = await models.ClaimBeginning.importToNewRefundTicket(ctx, claimId, options);
+
+ const refundTicketSales = await models.Sale.find({
+ where: {ticketFk: ticket.id}
+ }, options);
+ const salesInsertedInClaimEnd = await models.ClaimEnd.find({
+ where: {claimFk: claimId}
+ }, options);
+
+ expect(refundTicketSales.length).toEqual(1);
+ expect(refundTicketSales[0].quantity).toEqual(-5);
+ expect(salesInsertedInClaimEnd[0].saleFk).toEqual(refundTicketSales[0].id);
+ });
+
+ it('should set DELIVERED state and refund agency mode', async() => {
+ const state = await models.State.findOne({
+ where: {code: 'DELIVERED'}
+ }, options);
+ const ticket = await models.ClaimBeginning.importToNewRefundTicket(ctx, claimId, options);
+ const ticketTracking = await models.TicketTracking.findOne({
+ where: {ticketFk: ticket.id},
+ order: 'id DESC'
+ }, options);
+
+ const newSales = await models.Sale.find({
+ where: {ticketFk: ticket.id}
+ }, options);
+
+ newSales.forEach(sale => {
+ expect(sale.discount).toEqual(0);
+ });
+
+ expect(ticketTracking.stateFk).toEqual(state.id);
+ });
+
+ it('should set WAITING_FOR_PICKUP state for delivery pickups', async() => {
+ const state = await models.State.findOne({
+ where: {code: 'WAITING_FOR_PICKUP'}
+ }, options);
+ await models.Claim.updateAll({id: claimId}, {pickup: 'delivery'}, options);
+ const ticket = await models.ClaimBeginning.importToNewRefundTicket(ctx, claimId, options);
+ const ticketTracking = await models.TicketTracking.findOne({
+ where: {ticketFk: ticket.id},
+ order: 'id DESC'
+ }, options);
+ const newSales = await models.Sale.find({
+ where: {ticketFk: ticket.id}
+ }, options);
+
+ newSales.forEach(sale => {
+ expect(sale.discount).toEqual(100);
+ });
+
+ expect(ticketTracking.stateFk).toEqual(state.id);
+ });
+
+ it('should set DELIVERED state for agency pickups', async() => {
+ const state = await models.State.findOne({
+ where: {code: 'DELIVERED'}
+ }, options);
+ await models.Claim.updateAll({id: claimId}, {pickup: 'agency'}, options);
+ const ticket = await models.ClaimBeginning.importToNewRefundTicket(ctx, claimId, options);
+ const ticketTracking = await models.TicketTracking.findOne({
+ where: {ticketFk: ticket.id},
+ order: 'id DESC'
+ }, options);
+
+ expect(ticketTracking.stateFk).toEqual(state.id);
+ });
+});
diff --git a/modules/claim/back/methods/claim-end/filter.js b/modules/claim/back/methods/claim-end/filter.js
index 0dda16a3a7..c4f4879969 100644
--- a/modules/claim/back/methods/claim-end/filter.js
+++ b/modules/claim/back/methods/claim-end/filter.js
@@ -40,21 +40,24 @@ module.exports = Self => {
const stmt = new ParameterizedSQL(
`SELECT *
FROM (
- SELECT
+ SELECT
ce.id,
ce.claimFk,
- s.itemFk,
- s.ticketFk,
- ce.claimDestinationFk,
- t.landed,
- s.quantity,
- s.concept,
- s.price,
+ s.itemFk,
+ s.ticketFk,
+ ce.claimDestinationFk,
+ t.landed,
+ s.quantity,
+ s.concept,
+ s.price,
s.discount,
- s.quantity * s.price * ((100 - s.discount) / 100) total
+ s.quantity * s.price * ((100 - s.discount) / 100) total,
+ ce.shelvingFk,
+ sh.code shelvingCode
FROM vn.claimEnd ce
- LEFT JOIN vn.sale s ON s.id = ce.saleFk
+ LEFT JOIN vn.sale s ON s.id = ce.saleFk
LEFT JOIN vn.ticket t ON t.id = s.ticketFk
+ LEFT JOIN vn.shelving sh ON sh.id = ce.shelvingFk
) ce`
);
diff --git a/modules/claim/back/methods/claim/regularizeClaim.js b/modules/claim/back/methods/claim/regularizeClaim.js
index a51b114ef2..b1c34d2f40 100644
--- a/modules/claim/back/methods/claim/regularizeClaim.js
+++ b/modules/claim/back/methods/claim/regularizeClaim.js
@@ -3,12 +3,14 @@ module.exports = Self => {
description: `Imports lines from claimBeginning to a new ticket
with specific shipped, landed dates, agency and company`,
accessType: 'WRITE',
- accepts: [{
- arg: 'id',
- type: 'number',
- description: 'The claim id',
- http: {source: 'path'}
- }],
+ accepts: [
+ {
+ arg: 'id',
+ type: 'number',
+ description: 'The claim id',
+ http: {source: 'path'}
+ }
+ ],
returns: {
type: ['Object'],
root: true
@@ -22,8 +24,6 @@ module.exports = Self => {
Self.regularizeClaim = async(ctx, claimFk, options) => {
const models = Self.app.models;
const $t = ctx.req.__; // $translate
- const resolvedState = 3;
-
let tx;
const myOptions = {};
@@ -37,25 +37,39 @@ module.exports = Self => {
try {
const claimEnds = await models.ClaimEnd.find({
- include: {
- relation: 'claimDestination',
- fields: ['addressFk']
- },
- where: {claimFk: claimFk}
+ where: {claimFk: claimFk},
+ include: [
+ {
+ relation: 'claimDestination',
+ scope: {fields: ['addressFk']}
+ },
+ {
+ relation: 'shelving',
+ scope: {
+ fields: ['code', 'parkingFk'],
+ include: {
+ relation: 'parking',
+ scope: {
+ fields: ['sectorFk'],
+ include: {
+ relation: 'sector',
+ scope: {fields: ['warehouseFk']}
+ }
+ }
+ }
+ }
+ }
+ ]
}, myOptions);
for (let claimEnd of claimEnds) {
const destination = claimEnd.claimDestination();
const sale = await getSale(claimEnd.saleFk, myOptions);
- const addressId = destination && destination.addressFk;
-
- let address;
- if (addressId)
- address = await models.Address.findById(addressId, null, myOptions);
+ const addressId = destination?.addressFk;
const salesPerson = sale.ticket().client().salesPersonUser();
if (salesPerson) {
- const nickname = address && address.nickname || destination.description;
+ const nickname = destination.description;
const url = await Self.app.models.Url.getUrl();
const message = $t('Sent units from ticket', {
quantity: sale.quantity,
@@ -69,18 +83,21 @@ module.exports = Self => {
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message);
}
- if (!address) continue;
+ if (!addressId) continue;
+
+ const warehouseFk = claimEnd.shelving().parking().sector().warehouseFk;
+ const address = await models.Address.findById(addressId, null, myOptions);
let ticketFk = await getTicketId({
addressFk: addressId,
companyFk: sale.ticket().companyFk,
- warehouseFk: sale.ticket().warehouseFk
+ warehouseFk: warehouseFk
}, myOptions);
if (!ticketFk) {
ctx.args = {
clientId: address.clientFk,
- warehouseId: sale.ticket().warehouseFk,
+ warehouseId: warehouseFk,
companyId: sale.ticket().companyFk,
addressId: addressId
};
@@ -90,15 +107,43 @@ module.exports = Self => {
ticketFk: ticketFk,
itemFk: sale.itemFk,
concept: sale.concept,
- quantity: -sale.quantity,
+ quantity: sale.quantity,
price: sale.price,
discount: 100
}, myOptions);
+
+ const [buyFk] = await Self.rawSql('SELECT vn.buy_getLastWithoutInventory(?, ?) buyFk',
+ [sale.itemFk, warehouseFk], myOptions
+ );
+ await Self.rawSql('CALL vn.itemShelving_add(?, ?, ?, NULL, NULL, NULL, ?)',
+ [claimEnd.shelving().code, buyFk.buyFk, -sale.quantity, warehouseFk],
+ myOptions
+ );
+ const operator = await models.Operator.findById(
+ ctx.req.accessToken.userId, {fields: ['labelerFk']}, myOptions);
+
+ const params = JSON.stringify({
+ copies: 1,
+ id: buyFk.buyFk,
+ labelType: 'qr'
+ });
+
+ await Self.rawSql(`CALL vn.report_print( ?, ?, ?, ?, ?)`,
+ ['LabelBuy',
+ operator?.labelerFk,
+ ctx.req.accessToken.userId,
+ params,
+ 'normal'
+ ],
+ myOptions);
}
+ const resolvedState = await models.ClaimState.findOne({
+ where: {code: 'resolved'}
+ }, myOptions);
let claim = await Self.findById(claimFk, null, myOptions);
claim = await claim.updateAttributes({
- claimStateFk: resolvedState
+ claimStateFk: resolvedState.id
}, myOptions);
if (tx) await tx.commit();
@@ -151,7 +196,7 @@ module.exports = Self => {
}
}, options);
- return ticket && ticket.id;
+ return ticket?.id;
}
async function createTicket(ctx, options) {
diff --git a/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js b/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js
index 55d76ed7a7..f0ad1ce470 100644
--- a/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js
+++ b/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js
@@ -1,11 +1,8 @@
const models = require('vn-loopback/server/server').models;
+const LoopBackContext = require('loopback-context');
describe('claim regularizeClaim()', () => {
- const userId = 18;
- const ctx = beforeAll.mockLoopBackContext(userId);
- ctx.req.__ = (value, params) => {
- return params.nickname;
- };
+ const userId = 72;
const chatModel = models.Chat;
const claimId = 1;
const ticketId = 1;
@@ -13,9 +10,27 @@ describe('claim regularizeClaim()', () => {
const resolvedState = 3;
const trashDestination = 2;
const okDestination = 1;
- const trashAddress = 12;
let claimEnds = [];
- let trashTicket;
+ const activeCtx = {accessToken: {userId}};
+ let ctx = {req: activeCtx};
+ let tx;
+ let options;
+
+ beforeEach(async() => {
+ LoopBackContext.getCurrentContext = () => ({
+ active: activeCtx,
+ });
+
+ ctx.req.__ = (_value, params) => {
+ return params.nickname;
+ };
+ tx = await models.Claim.beginTransaction({});
+ options = {transaction: tx};
+ });
+
+ afterEach(async() => {
+ await tx.rollback();
+ });
async function importTicket(ticketId, claimId, userId, options) {
const ticketSales = await models.Sale.find({
@@ -34,84 +49,73 @@ describe('claim regularizeClaim()', () => {
}
it('should send a chat message with value "Trash" and then change claim state to resolved', async() => {
- const tx = await models.Claim.beginTransaction({});
+ spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
- try {
- const options = {transaction: tx};
+ claimEnds = await importTicket(ticketId, claimId, userId, options);
- spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
+ for (const claimEnd of claimEnds)
+ await claimEnd.updateAttributes({claimDestinationFk: trashDestination}, options);
- claimEnds = await importTicket(ticketId, claimId, userId, options);
+ let claimBefore = await models.Claim.findById(claimId, null, options);
+ await models.Claim.regularizeClaim(ctx, claimId, options);
+ let claimAfter = await models.Claim.findById(claimId, null, options);
- for (const claimEnd of claimEnds)
- await claimEnd.updateAttributes({claimDestinationFk: trashDestination}, options);
-
- let claimBefore = await models.Claim.findById(claimId, null, options);
- await models.Claim.regularizeClaim(ctx, claimId, options);
- let claimAfter = await models.Claim.findById(claimId, null, options);
-
- trashTicket = await models.Ticket.findOne({where: {addressFk: 12}}, options);
-
- expect(trashTicket.addressFk).toEqual(trashAddress);
- expect(claimBefore.claimStateFk).toEqual(pendentState);
- expect(claimAfter.claimStateFk).toEqual(resolvedState);
- expect(chatModel.sendCheckingPresence).toHaveBeenCalledWith(ctx, 18, 'Trash');
- expect(chatModel.sendCheckingPresence).toHaveBeenCalledTimes(4);
-
- await tx.rollback();
- } catch (e) {
- await tx.rollback();
- throw e;
- }
+ expect(claimBefore.claimStateFk).toEqual(pendentState);
+ expect(claimAfter.claimStateFk).toEqual(resolvedState);
});
- it('should send a chat message with value "Bueno" and then change claim state to resolved', async() => {
- const tx = await models.Claim.beginTransaction({});
+ it('should change claim state to resolved', async() => {
+ const addressMissingFk = 11;
+ const shelvingFk = 1;
+ const warehouseFk = 6;
+ const minDate = Date.vnNew();
+ minDate.setHours(0, 0, 0, 0);
- try {
- const options = {transaction: tx};
+ const maxDate = Date.vnNew();
+ maxDate.setHours(23, 59, 59, 59);
- spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
+ spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
- claimEnds = await importTicket(ticketId, claimId, userId, options);
+ claimEnds = await importTicket(ticketId, claimId, userId, options);
- for (claimEnd of claimEnds)
- await claimEnd.updateAttributes({claimDestinationFk: okDestination}, options);
+ for (let claimEnd of claimEnds)
+ await claimEnd.updateAttributes({claimDestinationFk: okDestination, shelvingFk}, options);
- await models.Claim.regularizeClaim(ctx, claimId, options);
+ const sale = await models.Sale.findOne({
+ include: [
+ {
+ relation: 'ticket',
+ scope: {
+ fields: ['clientFk', 'companyFk']
+ }
+ }],
+ where: {id: claimEnds[0].saleFk}
+ }, options);
- expect(chatModel.sendCheckingPresence).toHaveBeenCalledWith(ctx, 18, 'Bueno');
- expect(chatModel.sendCheckingPresence).toHaveBeenCalledTimes(4);
+ await models.Claim.regularizeClaim(ctx, claimId, options);
- await tx.rollback();
- } catch (e) {
- await tx.rollback();
- throw e;
- }
- });
+ const ticket = await models.Ticket.findOne({
+ where: {
+ addressFk: addressMissingFk,
+ companyFk: sale.ticket().companyFk,
+ warehouseFk: warehouseFk,
+ shipped: {between: [minDate, maxDate]},
+ landed: {between: [minDate, maxDate]}
+ }
+ }, options);
- it('should send a chat message to the salesPerson when claim isPickUp is enabled', async() => {
- const tx = await models.Claim.beginTransaction({});
+ const missingSale = await models.Sale.findOne({
+ where: {
+ ticketFk: ticket.id
+ }
+ }, options);
- try {
- const options = {transaction: tx};
+ const claimBeginning = await models.ClaimBeginning.findOne({
+ where: {
+ claimFk: claimId
+ }
+ }, options);
- spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
-
- claimEnds = await importTicket(ticketId, claimId, userId, options);
-
- for (claimEnd of claimEnds)
- await claimEnd.updateAttributes({claimDestinationFk: okDestination}, options);
-
- await models.Claim.regularizeClaim(ctx, claimId, options);
-
- expect(chatModel.sendCheckingPresence).toHaveBeenCalledWith(ctx, 18, 'Bueno');
- expect(chatModel.sendCheckingPresence).toHaveBeenCalledTimes(4);
-
- await tx.rollback();
- } catch (e) {
- await tx.rollback();
- throw e;
- }
+ expect(missingSale.quantity).toBe(claimBeginning.quantity);
});
});
diff --git a/modules/claim/back/model-config.json b/modules/claim/back/model-config.json
index d90ed4c1e8..6183a31423 100644
--- a/modules/claim/back/model-config.json
+++ b/modules/claim/back/model-config.json
@@ -2,6 +2,9 @@
"Claim": {
"dataSource": "vn"
},
+ "ClaimConfig": {
+ "dataSource": "vn"
+ },
"ClaimContainer": {
"dataSource": "claimStorage"
},
@@ -43,5 +46,5 @@
},
"ClaimObservation": {
"dataSource": "vn"
- }
+ }
}
diff --git a/modules/claim/back/models/claim-config.json b/modules/claim/back/models/claim-config.json
new file mode 100644
index 0000000000..6b90909953
--- /dev/null
+++ b/modules/claim/back/models/claim-config.json
@@ -0,0 +1,42 @@
+
+{
+ "name": "ClaimConfig",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
+ "options": {
+ "mysql": {
+ "table": "claimConfig"
+ }
+ },
+ "properties": {
+ "id": {
+ "type": "number",
+ "id": true,
+ "description": "Identifier"
+ },
+ "maxResponsibility": {
+ "type": "number"
+ },
+ "monthsToRefund": {
+ "type": "number"
+ },
+ "minShipped": {
+ "type": "date"
+ },
+ "pickupdeliveryFk": {
+ "type": "number"
+ },
+ "warehouseFk": {
+ "type": "number"
+ }
+ },
+ "relations": {
+ "pickupDelivery": {
+ "type": "belongsTo",
+ "model": "AgencyMode",
+ "foreignKey": "pickupdeliveryFk"
+ }
+ }
+}
diff --git a/modules/claim/back/models/claim-end.json b/modules/claim/back/models/claim-end.json
index ef5477f50e..aa66824f71 100644
--- a/modules/claim/back/models/claim-end.json
+++ b/modules/claim/back/models/claim-end.json
@@ -41,6 +41,11 @@
"type": "belongsTo",
"model": "ClaimDestination",
"foreignKey": "claimDestinationFk"
+ },
+ "shelving": {
+ "type": "belongsTo",
+ "model": "Shelving",
+ "foreignKey": "shelvingFk"
}
}
}
diff --git a/modules/client/back/methods/client/createWithUser.js b/modules/client/back/methods/client/createWithUser.js
index 1d5e71fcae..ad20171dc9 100644
--- a/modules/client/back/methods/client/createWithUser.js
+++ b/modules/client/back/methods/client/createWithUser.js
@@ -43,6 +43,17 @@ module.exports = function(Self) {
password: String(Math.random() * 100000000000000)
};
+ const supplier = await models.Supplier.findOne({
+ where: {nif: data.fi}
+ });
+
+ const role = supplier ? await models.VnRole.findOne({
+ where: {name: 'supplier'}
+ }) : null;
+
+ if (role)
+ user.roleFk = role.id;
+
try {
const province = await models.Province.findOne({
where: {id: data.provinceFk},
diff --git a/modules/client/back/methods/client/specs/createWithUser.spec.js b/modules/client/back/methods/client/specs/createWithUser.spec.js
index 8cff96ac54..fdc0797958 100644
--- a/modules/client/back/methods/client/specs/createWithUser.spec.js
+++ b/modules/client/back/methods/client/specs/createWithUser.spec.js
@@ -48,11 +48,11 @@ describe('Client Create', () => {
expect(error.message).toEqual('An email is necessary');
});
- it('should create a new account with dailyInvoice', async() => {
+ it('should create a new account with dailyInvoice and role supplier', async() => {
const newAccount = {
userName: 'deadpool',
email: 'deadpool@marvel.com',
- fi: '16195279J',
+ fi: '07972486L',
name: 'Wade',
socialName: 'DEADPOOL MARVEL',
street: 'WALL STREET',
@@ -61,33 +61,30 @@ describe('Client Create', () => {
provinceFk: 1
};
- try {
- const province = await models.Province.findById(newAccount.provinceFk, {
- fields: ['id', 'name', 'autonomyFk'],
- include: {
- relation: 'autonomy'
- }
- }, options);
+ const province = await models.Province.findById(newAccount.provinceFk, {
+ fields: ['id', 'name', 'autonomyFk'],
+ include: {
+ relation: 'autonomy'
+ }
+ }, options);
- const client = await models.Client.createWithUser(newAccount, options);
- const account = await models.VnUser.findOne({where: {name: newAccount.userName}}, options);
+ const client = await models.Client.createWithUser(newAccount, options);
+ const account = await models.VnUser.findOne({where: {name: newAccount.userName}}, options);
+ const supplierRole = await models.VnRole.findOne({where: {name: 'supplier'}}, options);
- expect(province.autonomy().hasDailyInvoice).toBeTruthy();
- expect(account.name).toEqual(newAccount.userName);
- expect(client.id).toEqual(account.id);
- expect(client.name).toEqual(newAccount.name);
- expect(client.email).toEqual(newAccount.email);
- expect(client.fi).toEqual(newAccount.fi);
- expect(client.socialName).toEqual(newAccount.socialName);
- expect(client.businessTypeFk).toEqual(newAccount.businessTypeFk);
- expect(client.hasDailyInvoice).toBeTruthy();
- } catch (e) {
- await tx.rollback();
- throw e;
- }
+ expect(account.roleFk).toEqual(supplierRole.id);
+ expect(province.autonomy().hasDailyInvoice).toBeTruthy();
+ expect(account.name).toEqual(newAccount.userName);
+ expect(client.id).toEqual(account.id);
+ expect(client.name).toEqual(newAccount.name);
+ expect(client.email).toEqual(newAccount.email);
+ expect(client.fi).toEqual(newAccount.fi);
+ expect(client.socialName).toEqual(newAccount.socialName);
+ expect(client.businessTypeFk).toEqual(newAccount.businessTypeFk);
+ expect(client.hasDailyInvoice).toBeTruthy();
});
- it('should create a new account without dailyInvoice', async() => {
+ it('should create a new account without dailyInvoice and role customer', async() => {
const newAccount = {
userName: 'deadpool',
email: 'deadpool@marvel.com',
@@ -100,22 +97,20 @@ describe('Client Create', () => {
provinceFk: 3
};
- try {
- const province = await models.Province.findById(newAccount.provinceFk, {
- fields: ['id', 'name', 'autonomyFk'],
- include: {
- relation: 'autonomy'
- }
- }, options);
+ const province = await models.Province.findById(newAccount.provinceFk, {
+ fields: ['id', 'name', 'autonomyFk'],
+ include: {
+ relation: 'autonomy'
+ }
+ }, options);
- const client = await models.Client.createWithUser(newAccount, options);
+ const client = await models.Client.createWithUser(newAccount, options);
+ const vnUser = await models.VnUser.findOne({where: {name: newAccount.userName}}, options);
+ const customerRole = await models.VnRole.findOne({where: {name: 'customer'}}, options);
- expect(province.autonomy.hasDailyInvoice).toBeFalsy();
- expect(client.hasDailyInvoice).toBeFalsy();
- } catch (e) {
- await tx.rollback();
- throw e;
- }
+ expect(vnUser.roleFk).toEqual(customerRole.id);
+ expect(province.autonomy.hasDailyInvoice).toBeFalsy();
+ expect(client.hasDailyInvoice).toBeFalsy();
});
it('should not be able to create a user if exists', async() => {
diff --git a/modules/item/back/methods/item/regularize.js b/modules/item/back/methods/item/regularize.js
index dfbcaa69f6..546515093d 100644
--- a/modules/item/back/methods/item/regularize.js
+++ b/modules/item/back/methods/item/regularize.js
@@ -46,29 +46,24 @@ module.exports = Self => {
}
try {
- const itemDestination = await models.ClaimDestination.findOne({
- include: {
- relation: 'address',
- scope: {
- fields: ['clientFk']
- }
- },
- where: {description: 'Corregido'}
+ const addressWaste = await models.AddressWaste.findOne({
+ where: {type: 'fault'},
+ include: 'address'
}, myOptions);
const item = await models.Item.findById(itemFk, null, myOptions);
let ticketId = await getTicketId({
- clientFk: itemDestination.address.clientFk,
- addressFk: itemDestination.addressFk,
+ clientFk: addressWaste.address().clientFk,
+ addressFk: addressWaste.addressFk,
warehouseFk: warehouseFk
}, myOptions);
if (!ticketId) {
ctx.args = {
- clientId: itemDestination.address().clientFk,
+ clientId: addressWaste.address().clientFk,
warehouseId: warehouseFk,
- addressId: itemDestination.addressFk
+ addressId: addressWaste.addressFk
};
ticketId = await createTicket(ctx, myOptions);
}
@@ -121,7 +116,7 @@ module.exports = Self => {
}
}, options);
- return ticket && ticket.id;
+ return ticket?.id;
}
};
};
diff --git a/modules/item/front/last-entries/index.html b/modules/item/front/last-entries/index.html
index e3b84655c8..e8fedab85e 100644
--- a/modules/item/front/last-entries/index.html
+++ b/modules/item/front/last-entries/index.html
@@ -95,7 +95,13 @@
{{::entry.weight | dashIfEmpty}}{{::entry.packagingFk | dashIfEmpty}}
- {{::entry.supplier | dashIfEmpty}}
+
+
+ {{::entry.supplier | dashIfEmpty}}
+
+
@@ -107,6 +113,10 @@
vn-id="entryDescriptor">
+
+
+
diff --git a/modules/route/back/methods/agency-term/filter.js b/modules/route/back/methods/agency-term/filter.js
index d52d93e952..1b2b5caab9 100644
--- a/modules/route/back/methods/agency-term/filter.js
+++ b/modules/route/back/methods/agency-term/filter.js
@@ -95,6 +95,7 @@ module.exports = Self => {
+ sat.packagePrice * SUM(t.packages) )
AS DECIMAL(10,2)) price,
r.invoiceInFk,
+ i.supplierRef,
sat.supplierFk,
s.name supplierName
FROM vn.route r
@@ -103,6 +104,7 @@ module.exports = Self => {
LEFT JOIN vn.ticket t ON t.routeFk = r.id
LEFT JOIN vn.supplierAgencyTerm sat ON sat.agencyFk = a.id
LEFT JOIN vn.supplier s ON s.id = sat.supplierFk
+ LEFT JOIN vn.invoiceIn i ON i.id = r.invoiceInFk
WHERE r.dated > DATE_ADD(?, INTERVAL -2 MONTH) AND sat.supplierFk IS NOT NULL
GROUP BY r.id
) a`
diff --git a/modules/route/back/methods/cmr/filter.js b/modules/route/back/methods/cmr/filter.js
index d5a217b1cf..a8919abc7a 100644
--- a/modules/route/back/methods/cmr/filter.js
+++ b/modules/route/back/methods/cmr/filter.js
@@ -12,10 +12,15 @@ module.exports = Self => {
type: 'object',
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
},
+ {
+ arg: 'search',
+ type: 'string',
+ description: 'Searchs cmr by id',
+ },
{
arg: 'cmrFk',
type: 'integer',
- description: 'Searchs the route by id',
+ description: 'Searchs cmr by id',
},
{
arg: 'ticketFk',
@@ -28,7 +33,7 @@ module.exports = Self => {
description: 'The route id',
},
{
- arg: 'country',
+ arg: 'countryFk',
type: 'string',
description: 'The agencyMode id',
},
@@ -63,22 +68,17 @@ module.exports = Self => {
});
Self.filter = async(
- filter, cmrFk, ticketFk, routeFk, country, clientFk, hasCmrDms, shipped, warehouseFk, options
+ filter, search, cmrFk, ticketFk, routeFk, countryFk, clientFk, hasCmrDms, shipped, warehouseFk, options
) => {
- const params = {cmrFk, ticketFk, routeFk, country, clientFk, hasCmrDms, warehouseFk, shipped};
+ const params = {search, cmrFk, ticketFk, routeFk, countryFk, clientFk, hasCmrDms, warehouseFk, shipped};
const conn = Self.dataSource.connector;
let where = buildFilter(params, (param, value) => {
+ if (param === 'search') return {'cmrFk': value};
return {[param]: value};
});
filter = mergeFilters(filter, {where});
- if (!filter.where) {
- const yesterday = new Date();
- yesterday.setDate(yesterday.getDate() - 1);
- filter.where = {'shipped': yesterday.toISOString().split('T')[0]};
- }
-
const myOptions = {};
if (typeof options == 'object')
diff --git a/modules/shelving/back/models/parking.js b/modules/shelving/back/models/parking.js
new file mode 100644
index 0000000000..027f1e8ae6
--- /dev/null
+++ b/modules/shelving/back/models/parking.js
@@ -0,0 +1,5 @@
+module.exports = Self => {
+ Self.validatesUniquenessOf('code', {
+ message: `The code already exists`
+ });
+};
diff --git a/modules/shelving/back/models/shelving.js b/modules/shelving/back/models/shelving.js
index bf611d2ba1..207224266e 100644
--- a/modules/shelving/back/models/shelving.js
+++ b/modules/shelving/back/models/shelving.js
@@ -1,4 +1,8 @@
module.exports = Self => {
require('../methods/shelving/getSummary')(Self);
require('../methods/shelving/addLog')(Self);
+
+ Self.validatesUniquenessOf('code', {
+ message: `The code already exists`
+ });
};
diff --git a/modules/supplier/front/descriptor-popover/index.html b/modules/supplier/front/descriptor-popover/index.html
new file mode 100644
index 0000000000..610bd128c6
--- /dev/null
+++ b/modules/supplier/front/descriptor-popover/index.html
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/modules/supplier/front/descriptor-popover/index.js b/modules/supplier/front/descriptor-popover/index.js
new file mode 100644
index 0000000000..a30aa4829b
--- /dev/null
+++ b/modules/supplier/front/descriptor-popover/index.js
@@ -0,0 +1,9 @@
+import ngModule from '../module';
+import DescriptorPopover from 'salix/components/descriptor-popover';
+
+class Controller extends DescriptorPopover {}
+
+ngModule.vnComponent('vnSupplierDescriptorPopover', {
+ slotTemplate: require('./index.html'),
+ controller: Controller
+});
diff --git a/modules/supplier/front/descriptor/index.html b/modules/supplier/front/descriptor/index.html
new file mode 100644
index 0000000000..b3ba595ab4
--- /dev/null
+++ b/modules/supplier/front/descriptor/index.html
@@ -0,0 +1,66 @@
+
+
+