Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 6598-getUserAcls
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-06-11 09:11:56 +02:00
commit d30cd68417
298 changed files with 6414 additions and 5566 deletions

View File

@ -1,3 +1,4 @@
# Changelog # Changelog
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.

26
Jenkinsfile vendored
View File

@ -24,6 +24,7 @@ node {
FROM_GIT = env.JOB_NAME.startsWith('gitea/') FROM_GIT = env.JOB_NAME.startsWith('gitea/')
RUN_TESTS = !PROTECTED_BRANCH && FROM_GIT RUN_TESTS = !PROTECTED_BRANCH && FROM_GIT
RUN_BUILD = PROTECTED_BRANCH && FROM_GIT RUN_BUILD = PROTECTED_BRANCH && FROM_GIT
// https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables // https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables
echo "NODE_NAME: ${env.NODE_NAME}" echo "NODE_NAME: ${env.NODE_NAME}"
echo "WORKSPACE: ${env.WORKSPACE}" echo "WORKSPACE: ${env.WORKSPACE}"
@ -59,7 +60,6 @@ pipeline {
} }
environment { environment {
PROJECT_NAME = 'salix' PROJECT_NAME = 'salix'
STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
} }
stages { stages {
stage('Install') { stage('Install') {
@ -103,7 +103,7 @@ pipeline {
NODE_ENV = '' NODE_ENV = ''
} }
steps { steps {
sh 'node back/tests.js --ci --junit --network jenkins' sh 'node back/tests.js --junit'
} }
post { post {
always { always {
@ -121,7 +121,7 @@ pipeline {
steps { steps {
script { script {
def packageJson = readJSON file: 'package.json' def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version env.VERSION = "${packageJson.version}-vn${env.BUILD_ID}"
} }
sh 'docker-compose build back' sh 'docker-compose build back'
} }
@ -159,7 +159,7 @@ pipeline {
steps { steps {
script { script {
def packageJson = readJSON file: 'package.json' def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version env.VERSION = "${packageJson.version}-vn${env.BUILD_ID}"
} }
sh 'gulp build' sh 'gulp build'
sh 'docker-compose build front' sh 'docker-compose build front'
@ -179,7 +179,7 @@ pipeline {
steps { steps {
script { script {
def packageJson = readJSON file: 'package.json' def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version env.VERSION = "${packageJson.version}-vn${env.BUILD_ID}"
} }
sh 'docker login --username $CREDENTIALS_USR --password $CREDENTIALS_PSW $REGISTRY' sh 'docker login --username $CREDENTIALS_USR --password $CREDENTIALS_PSW $REGISTRY'
sh 'docker-compose push' sh 'docker-compose push'
@ -203,19 +203,23 @@ pipeline {
sh 'npx myt push $NODE_ENV --force --commit' sh 'npx myt push $NODE_ENV --force --commit'
} }
} }
stage('Docker') { stage('Kubernetes') {
when { when {
expression { FROM_GIT } expression { FROM_GIT }
} }
environment {
DOCKER_HOST = "${env.SWARM_HOST}"
}
steps { steps {
script { script {
def packageJson = readJSON file: 'package.json' def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version env.VERSION = "${packageJson.version}-vn${env.BUILD_ID}"
}
withKubeConfig([
serverUrl: "$KUBERNETES_API",
credentialsId: 'kubernetes',
namespace: 'salix'
]) {
sh 'kubectl set image deployment/salix-back-$BRANCH_NAME salix-back-$BRANCH_NAME=$REGISTRY/salix-back:$VERSION'
sh 'kubectl set image deployment/salix-front-$BRANCH_NAME salix-front-$BRANCH_NAME=$REGISTRY/salix-front:$VERSION'
} }
sh "docker stack deploy --with-registry-auth --compose-file docker-compose.yml ${env.STACK_NAME}"
} }
} }
} }

View File

@ -11,11 +11,16 @@ Required applications.
* Node.js * Node.js
* Docker * Docker
* Git * Git
* MYT
You will need to install globally the following items. You will need to install globally the following items.
``` ```
$ sudo npm install -g jest gulp-cli $ sudo npm install -g jest gulp-cli
``` ```
After installing MYT you will need the following item.
```
$ apt install libkrb5-dev libssl-dev
```
## Installing dependencies and launching ## Installing dependencies and launching
@ -54,6 +59,12 @@ For end-to-end tests run from project's root.
$ npm run test:e2e $ npm run test:e2e
``` ```
## Generate changeLog test → master
```
$ bash changelog.sh
```
## Visual Studio Code extensions ## Visual Studio Code extensions
Open Visual Studio Code, press Ctrl+P and paste the following commands. Open Visual Studio Code, press Ctrl+P and paste the following commands.

View File

@ -1,3 +1,5 @@
const isProduction = require('vn-loopback/server/boot/isProduction');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('sendCheckingPresence', { Self.remoteMethodCtx('sendCheckingPresence', {
description: 'Creates a message in the chat model checking the user status', description: 'Creates a message in the chat model checking the user status',
@ -37,7 +39,7 @@ module.exports = Self => {
if (!recipient) if (!recipient)
throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`); throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`);
if (process.env.NODE_ENV == 'test') if (!isProduction())
message = `[Test:Environment to user ${userId}] ` + message; message = `[Test:Environment to user ${userId}] ` + message;
const chat = await models.Chat.create({ const chat = await models.Chat.create({

View File

@ -1,4 +1,6 @@
const axios = require('axios'); const axios = require('axios');
const isProduction = require('vn-loopback/server/boot/isProduction');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('sendQueued', { Self.remoteMethodCtx('sendQueued', {
description: 'Send a RocketChat message', description: 'Send a RocketChat message',
@ -94,7 +96,7 @@ module.exports = Self => {
* @return {Promise} - The request promise * @return {Promise} - The request promise
*/ */
Self.sendMessage = async function sendMessage(senderFk, recipient, message) { Self.sendMessage = async function sendMessage(senderFk, recipient, message) {
if (process.env.NODE_ENV !== 'production') { if (!isProduction(false)) {
return new Promise(resolve => { return new Promise(resolve => {
return resolve({ return resolve({
statusCode: 200, statusCode: 200,
@ -149,7 +151,7 @@ module.exports = Self => {
* @return {Promise} - The request promise * @return {Promise} - The request promise
*/ */
Self.getUserStatus = async function getUserStatus(username) { Self.getUserStatus = async function getUserStatus(username) {
if (process.env.NODE_ENV !== 'production') { if (!isProduction(false)) {
return new Promise(resolve => { return new Promise(resolve => {
return resolve({ return resolve({
data: { data: {

View File

@ -1,6 +1,7 @@
const UserError = require('vn-loopback/util/user-error'); const UserError = require('vn-loopback/util/user-error');
const fs = require('fs-extra'); const fs = require('fs-extra');
const path = require('path'); const path = require('path');
const isProduction = require('vn-loopback/server/boot/isProduction');
module.exports = Self => { module.exports = Self => {
Self.remoteMethod('deleteTrashFiles', { Self.remoteMethod('deleteTrashFiles', {
@ -22,7 +23,7 @@ module.exports = Self => {
if (typeof options == 'object') if (typeof options == 'object')
Object.assign(myOptions, options); Object.assign(myOptions, options);
if (process.env.NODE_ENV == 'test') if (!isProduction())
throw new UserError(`Action not allowed on the test environment`); throw new UserError(`Action not allowed on the test environment`);
const models = Self.app.models; const models = Self.app.models;

View File

@ -1,5 +1,6 @@
const UserError = require('vn-loopback/util/user-error'); const UserError = require('vn-loopback/util/user-error');
const axios = require('axios'); const axios = require('axios');
const isProduction = require('vn-loopback/server/boot/isProduction');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('upload', { Self.remoteMethodCtx('upload', {
@ -119,7 +120,7 @@ module.exports = Self => {
] ]
}; };
if (process.env.NODE_ENV != 'production') if (!isProduction(false))
throw new UserError('Action not allowed on the test environment'); throw new UserError('Action not allowed on the test environment');
// delete old // delete old

View File

@ -1,6 +1,7 @@
const fs = require('fs-extra'); const fs = require('fs-extra');
const path = require('path'); const path = require('path');
const UserError = require('vn-loopback/util/user-error'); const UserError = require('vn-loopback/util/user-error');
const isProduction = require('vn-loopback/server/boot/isProduction');
module.exports = Self => { module.exports = Self => {
Self.remoteMethod('scrub', { Self.remoteMethod('scrub', {
@ -43,8 +44,7 @@ module.exports = Self => {
Self.scrub = async function(collection, remove, limit, dryRun, skipLock) { Self.scrub = async function(collection, remove, limit, dryRun, skipLock) {
const $ = Self.app.models; const $ = Self.app.models;
const env = process.env.NODE_ENV; dryRun = dryRun || !isProduction(false);
dryRun = dryRun || (env && env !== 'production');
const instance = await $.ImageCollection.findOne({ const instance = await $.ImageCollection.findOne({
fields: ['id'], fields: ['id'],

View File

@ -1,6 +1,7 @@
const UserError = require('vn-loopback/util/user-error'); const UserError = require('vn-loopback/util/user-error');
const fs = require('fs/promises'); const fs = require('fs/promises');
const path = require('path'); const path = require('path');
const isProduction = require('vn-loopback/server/boot/isProduction');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('upload', { Self.remoteMethodCtx('upload', {
@ -41,7 +42,7 @@ module.exports = Self => {
if (!hasWriteRole) if (!hasWriteRole)
throw new UserError(`You don't have enough privileges`); throw new UserError(`You don't have enough privileges`);
if (process.env.NODE_ENV == 'test') if (!isProduction())
throw new UserError(`Action not allowed on the test environment`); throw new UserError(`Action not allowed on the test environment`);
// Upload file to temporary path // Upload file to temporary path

View File

@ -39,8 +39,6 @@ module.exports = Self => {
const xmlString = response.data; const xmlString = response.data;
const parser = new DOMParser(); const parser = new DOMParser();
const xmlDoc = parser.parseFromString(xmlString, 'text/xml'); const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
const [resultElement] = xmlDoc.getElementsByTagName('Mensaje'); return xmlDoc.getElementsByTagName('Mensaje')[0].textContent;
return resultElement.textContent;
}; };
}; };

View File

@ -26,16 +26,24 @@
<mrw:Nif><%= expeditionData.fi %></mrw:Nif> <mrw:Nif><%= expeditionData.fi %></mrw:Nif>
<mrw:Nombre><%= expeditionData.clientName %></mrw:Nombre> <mrw:Nombre><%= expeditionData.clientName %></mrw:Nombre>
<mrw:Telefono><%= expeditionData.phone %></mrw:Telefono> <mrw:Telefono><%= expeditionData.phone %></mrw:Telefono>
<mrw:Observaciones><%= expeditionData.deliveryObservation %></mrw:Observaciones>
</mrw:DatosEntrega> </mrw:DatosEntrega>
<mrw:DatosServicio> <mrw:DatosServicio>
<mrw:Fecha><%= expeditionData.created %></mrw:Fecha> <mrw:Fecha><%= expeditionData.created %></mrw:Fecha>
<mrw:Referencia><%= expeditionData.expeditionDataId %></mrw:Referencia> <mrw:Referencia><%= expeditionData.reference %></mrw:Referencia>
<mrw:CodigoServicio><%= expeditionData.serviceType %></mrw:CodigoServicio> <mrw:CodigoServicio><%= expeditionData.serviceType %></mrw:CodigoServicio>
<mrw:NumeroBultos>1</mrw:NumeroBultos> <mrw:NumeroBultos>1</mrw:NumeroBultos>
<mrw:EntregaSabado><%= expeditionData.weekDays %></mrw:EntregaSabado> <mrw:EntregaSabado><%= expeditionData.weekDays %></mrw:EntregaSabado>
<mrw:Peso><%= expeditionData.kg %></mrw:Peso>
<mrw:Reembolso/> <mrw:Reembolso/>
<mrw:ImporteReembolso/> <mrw:ImporteReembolso/>
<mrw:Bultos>
<mrw:BultoRequest>
<mrw:Alto><%= mrw.defaultHeight %></mrw:Alto>
<mrw:Largo><%= mrw.defaultLength %></mrw:Largo>
<mrw:Ancho><%= mrw.defaultWidth %></mrw:Ancho>
<mrw:Peso><%= mrw.defaultWeight %></mrw:Peso>
</mrw:BultoRequest>
</mrw:Bultos>
</mrw:DatosServicio> </mrw:DatosServicio>
</mrw:request> </mrw:request>
</mrw:TransmEnvio> </mrw:TransmEnvio>

View File

@ -42,9 +42,10 @@ module.exports = Self => {
throw new UserError(`Some mrwConfig parameters are not set`); throw new UserError(`Some mrwConfig parameters are not set`);
const query = const query =
`SELECT CASE co.code `SELECT
CASE co.code
WHEN 'ES' THEN a.postalCode WHEN 'ES' THEN a.postalCode
WHEN 'PT' THEN LEFT(a.postalCode, 4) WHEN 'PT' THEN LEFT(a.postalCode, mc.portugalPostCodeTrim)
WHEN 'AD' THEN REPLACE(a.postalCode, 'AD', '00') WHEN 'AD' THEN REPLACE(a.postalCode, 'AD', '00')
END postalCode, END postalCode,
a.city, a.city,
@ -55,18 +56,23 @@ module.exports = Self => {
c.phone, c.phone,
DATE_FORMAT(t.shipped, '%d/%m/%Y') created, DATE_FORMAT(t.shipped, '%d/%m/%Y') created,
t.shipped, t.shipped,
e.id expeditionId, CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference,
LPAD(IF(mw.params IS NULL, ms.serviceType, mw.serviceType), 4 ,'0') serviceType, LPAD(IF(mw.serviceType IS NULL, ms.serviceType, mw.serviceType), mc.serviceTypeWidth,'0') serviceType,
IF(mw.weekdays, 'S', 'N') weekDays IF(mw.weekdays, 'S', 'N') weekDays,
oa.description deliveryObservation
FROM expedition e FROM expedition e
JOIN ticket t ON e.ticketFk = t.id JOIN ticket t ON e.ticketFk = t.id
JOIN agencyMode am ON am.id = t.agencyModeFk JOIN agencyMode am ON am.id = t.agencyModeFk
JOIN mrwService ms ON ms.agencyModeCodeFk = am.code JOIN mrwService ms ON ms.agencyModeCodeFk = am.code
LEFT JOIN mrwServiceWeekday mw ON mw.weekdays = DATE_FORMAT(t.shipped, '%a') LEFT JOIN mrwServiceWeekday mw ON mw.weekdays | 1 << WEEKDAY(t.landed)
JOIN client c ON t.clientFk = c.id JOIN client c ON t.clientFk = c.id
JOIN address a ON t.addressFk = a.id JOIN address a ON t.addressFk = a.id
LEFT JOIN addressObservation oa ON oa.addressFk = a.id
LEFT JOIN observationType ot ON ot.id = oa.observationTypeFk
AND ot.code = 'delivery'
JOIN province p ON a.provinceFk = p.id JOIN province p ON a.provinceFk = p.id
JOIN country co ON co.id = p.countryFk JOIN country co ON co.id = p.countryFk
JOIN mrwConfig mc
WHERE e.id = ? WHERE e.id = ?
LIMIT 1`; LIMIT 1`;
@ -89,14 +95,9 @@ module.exports = Self => {
const getLabelResponse = await sendXmlDoc('getLabel', {mrw, shipmentId}, 'text/xml'); const getLabelResponse = await sendXmlDoc('getLabel', {mrw, shipmentId}, 'text/xml');
const file = getTextByTag(getLabelResponse, 'EtiquetaFile'); const file = getTextByTag(getLabelResponse, 'EtiquetaFile');
try { if (tx) await tx.commit();
await models.Expedition.updateAll({id: expeditionFk}, {externalId: shipmentId}, myOptions);
if (tx) await tx.commit(); return {shipmentId, file};
} catch (error) {
if (tx) await tx.rollback();
throw error;
}
return file;
}; };
function getTextByTag(xmlDoc, tag) { function getTextByTag(xmlDoc, tag) {

View File

@ -81,9 +81,9 @@ describe('MRWConfig createShipment()', () => {
spyOn(axios, 'post').and.callFake(() => Promise.resolve(mockPostResponses.pop())); spyOn(axios, 'post').and.callFake(() => Promise.resolve(mockPostResponses.pop()));
const base64Binary = await models.MrwConfig.createShipment(expedition1.id, options); const {file} = await models.MrwConfig.createShipment(expedition1.id, options);
expect(base64Binary).toEqual(mockBase64Binary); expect(file).toEqual(mockBase64Binary);
}); });
it('should fail if mrwConfig has no data', async() => { it('should fail if mrwConfig has no data', async() => {

View File

@ -1,4 +1,5 @@
const {Email} = require('vn-print'); const {Email} = require('vn-print');
const isProduction = require('vn-loopback/server/boot/isProduction');
module.exports = Self => { module.exports = Self => {
Self.remoteMethod('send', { Self.remoteMethod('send', {
@ -70,7 +71,7 @@ module.exports = Self => {
const newParams = Object.assign({}, queueParams, sendParams); const newParams = Object.assign({}, queueParams, sendParams);
const email = new Email(queueName, newParams); const email = new Email(queueName, newParams);
if (process.env.NODE_ENV != 'test') if (isProduction())
await email.send(); await email.send();
await queue.updateAttribute('status', statusSent); await queue.updateAttribute('status', statusSent);

View File

@ -18,15 +18,10 @@ module.exports = Self => {
Self.renewToken = async function(ctx) { Self.renewToken = async function(ctx) {
const {accessToken: token} = ctx.req; const {accessToken: token} = ctx.req;
// Check if current token is valid const {courtesyTime} = await models.AccessTokenConfig.findOne({
fields: ['courtesyTime']
const {renewPeriod, courtesyTime} = await models.AccessTokenConfig.findOne({
fields: ['renewPeriod', 'courtesyTime']
}); });
const now = Date.now(); const isNotExceeded = await Self.validateToken(ctx);
const differenceMilliseconds = now - token.created;
const differenceSeconds = Math.floor(differenceMilliseconds / 1000);
const isNotExceeded = differenceSeconds < renewPeriod - courtesyTime;
if (isNotExceeded) if (isNotExceeded)
return token; return token;

View File

@ -0,0 +1,30 @@
const {models} = require('vn-loopback/server/server');
module.exports = Self => {
Self.remoteMethodCtx('validateToken', {
description: 'Validates the current logged user token',
accepts: [],
accessType: 'READ',
returns: {
type: 'Boolean',
root: true
},
http: {
path: `/validateToken`,
verb: 'GET'
}
});
Self.validateToken = async function(ctx) {
const {accessToken: token} = ctx.req;
// Check if current token is valid
const {renewPeriod, courtesyTime} = await models.AccessTokenConfig.findOne({
fields: ['renewPeriod', 'courtesyTime']
});
const now = Date.now();
const differenceMilliseconds = now - token.created;
const differenceSeconds = Math.floor(differenceMilliseconds / 1000);
const isNotExceeded = differenceSeconds < renewPeriod - courtesyTime;
return isNotExceeded;
};
};

View File

@ -186,5 +186,8 @@
}, },
"AgencyWorkCenter": { "AgencyWorkCenter": {
"dataSource": "vn" "dataSource": "vn"
},
"RouteConfig": {
"dataSource": "vn"
} }
} }

View File

@ -1,6 +1,16 @@
{ {
"name": "Collection", "name": "Collection",
"base": "VnModel", "base": "VnModel",
"properties": {
"id": {
"id": true,
"type": "number",
"required": true
},
"workerFk": {
"type": "number"
}
},
"options": { "options": {
"mysql": { "mysql": {
"table": "collection" "table": "collection"

View File

@ -27,6 +27,18 @@
}, },
"subscriberCode": { "subscriberCode": {
"type": "string" "type": "string"
},
"defaultHeight": {
"type": "number"
},
"defaultLength": {
"type": "number"
},
"defaultWidth": {
"type": "number"
},
"defaultWeight": {
"type": "number"
} }
} }
} }

View File

@ -0,0 +1,18 @@
{
"name": "RouteConfig",
"base": "VnModel",
"options": {
"mysql": {
"table": "routeConfig"
}
},
"properties": {
"id": {
"type": "number",
"description": "Identifier"
},
"kmMax": {
"type": "number"
}
}
}

View File

@ -15,6 +15,7 @@ module.exports = function(Self) {
require('../methods/vn-user/renew-token')(Self); require('../methods/vn-user/renew-token')(Self);
require('../methods/vn-user/share-token')(Self); require('../methods/vn-user/share-token')(Self);
require('../methods/vn-user/update-user')(Self); require('../methods/vn-user/update-user')(Self);
require('../methods/vn-user/validate-token')(Self);
require('../methods/vn-user/acls')(Self); require('../methods/vn-user/acls')(Self);
Self.definition.settings.acls = Self.definition.settings.acls.filter(acl => acl.property !== 'create'); Self.definition.settings.acls = Self.definition.settings.acls.filter(acl => acl.property !== 'create');

View File

@ -113,6 +113,13 @@
"principalId": "$everyone", "principalId": "$everyone",
"permission": "ALLOW" "permission": "ALLOW"
}, },
{
"property": "validateToken",
"accessType": "EXECUTE",
"principalType": "ROLE",
"principalId": "$authenticated",
"permission": "ALLOW"
},
{ {
"property": "privileges", "property": "privileges",
"accessType": "*", "accessType": "*",

34
changelog.sh Normal file
View File

@ -0,0 +1,34 @@
features_types=(chore feat style)
changes_types=(refactor perf)
fix_types=(fix revert)
file="CHANGELOG.md"
file_tmp="temp_log.txt"
file_current_tmp="temp_current_log.txt"
setType(){
echo "### $1" >> $file_tmp
arr=("$@")
echo "" > $file_current_tmp
for i in "${arr[@]}"
do
git log --grep="$i" --oneline --no-merges --format="- %s %d by:%an" master..test >> $file_current_tmp
done
# remove duplicates
sort -o $file_current_tmp -u $file_current_tmp
cat $file_current_tmp >> $file_tmp
echo "" >> $file_tmp
# remove tmp current file
[ -e $file_current_tmp ] && rm $file_current_tmp
}
echo "# Version XX.XX - XXXX-XX-XX" >> $file_tmp
echo "" >> $file_tmp
setType "Added 🆕" "${features_types[@]}"
setType "Changed 📦" "${changes_types[@]}"
setType "Fixed 🛠️" "${fix_types[@]}"
cat $file >> $file_tmp
mv $file_tmp $file

View File

@ -9,7 +9,7 @@
}, },
"vn": { "vn": {
"view": { "view": {
"expeditionPallet_Print": "288cbd6e8289df083ed5eb1a2c808f7a82ba4c90c8ad9781104808a7a54471fb" "expeditionPallet_Print": "ced2b84a114fcb99fce05f0c34f4fc03f3fa387bef92621be1bc306608a84345"
} }
} }
} }

View File

@ -3,7 +3,7 @@ USE `util`;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
INSERT INTO `version` VALUES ('vn-database','11031','12f36dc825b6660062e2c86fde9c6b451cb58f0d','2024-05-14 08:25:58','11048'); INSERT INTO `version` VALUES ('vn-database','11071','60ac8cf6fc77b99b199b27866011b1efe8c961e8','2024-05-28 07:32:50','11074');
INSERT INTO `versionLog` VALUES ('vn-database','10107','00-firstScript.sql','jenkins@10.0.2.69','2022-04-23 10:53:53',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10107','00-firstScript.sql','jenkins@10.0.2.69','2022-04-23 10:53:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10112','00-firstScript.sql','jenkins@10.0.2.69','2022-05-09 09:14:53',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10112','00-firstScript.sql','jenkins@10.0.2.69','2022-05-09 09:14:53',NULL,NULL);
@ -759,6 +759,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','10953','06-srt.sql','jenkins@db-
INSERT INTO `versionLog` VALUES ('vn-database','10953','07-util.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:55',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10953','07-util.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10953','08-vn.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:56',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10953','08-vn.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:56',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10953','08-vn2.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:58',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10953','08-vn2.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:58',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10955','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:16',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10956','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:58',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10956','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:58',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10957','00-aclTicketClone.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:58',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10957','00-aclTicketClone.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:58',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10959','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-18 13:32:25',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10959','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-18 13:32:25',NULL,NULL);
@ -788,22 +789,46 @@ INSERT INTO `versionLog` VALUES ('vn-database','10996','00-dropOrderRecalc.sql',
INSERT INTO `versionLog` VALUES ('vn-database','10996','01-dropTicketRecalc.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:59',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10996','01-dropTicketRecalc.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:59',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10996','02-dropTravelRecalc.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:59',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10996','02-dropTravelRecalc.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:59',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10997','00-groupingMode.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:34:21',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10997','00-groupingMode.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:34:21',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11000','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:16',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11001','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:26',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11001','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:26',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11002','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:26',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11002','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:26',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11003','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:34:21',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11003','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:34:21',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11006','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:16',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11007','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:34:21',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11007','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:34:21',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11008','00-alter.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11008','00-alter.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11010','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11012','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11012','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11013','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11014','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11014','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11016','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-27 13:16:09',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11016','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-27 13:16:09',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11018','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:34:21',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11018','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:34:21',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11019','00-locker.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11019','01-aclLocker.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11021','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-30 09:07:56',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11021','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-30 09:07:56',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11022','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11026','00-entryAlter.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11026','00-entryAlter.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11026','01-entryUpdate.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11026','01-entryUpdate.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11026','02-entryInternal.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11026','02-entryInternal.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11030','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11031','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11031','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11033','00-rollbackAcls.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-07 12:45:45',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11033','00-rollbackAcls.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-07 12:45:45',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11034','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11037','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11038','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11040','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:31',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11044','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:31',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11045','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-10 14:53:29',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11045','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-10 14:53:29',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11046','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:46',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11051','00-sipConfig_callLimit.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-14 14:31:10',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11054','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:46',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11055','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:46',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11057','00-part.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:46',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11057','01-part.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:47',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11057','02-part.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:47',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11057','03-part.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:48',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11058','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:48',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11061','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:48',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11071','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:48',NULL,NULL);
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
@ -1090,7 +1115,6 @@ INSERT INTO `roleInherit` VALUES (249,109,18,NULL);
INSERT INTO `roleInherit` VALUES (250,109,13,NULL); INSERT INTO `roleInherit` VALUES (250,109,13,NULL);
INSERT INTO `roleInherit` VALUES (251,51,21,NULL); INSERT INTO `roleInherit` VALUES (251,51,21,NULL);
INSERT INTO `roleInherit` VALUES (253,48,49,NULL); INSERT INTO `roleInherit` VALUES (253,48,49,NULL);
INSERT INTO `roleInherit` VALUES (254,110,1,NULL);
INSERT INTO `roleInherit` VALUES (255,110,76,NULL); INSERT INTO `roleInherit` VALUES (255,110,76,NULL);
INSERT INTO `roleInherit` VALUES (256,48,69,NULL); INSERT INTO `roleInherit` VALUES (256,48,69,NULL);
INSERT INTO `roleInherit` VALUES (257,47,111,NULL); INSERT INTO `roleInherit` VALUES (257,47,111,NULL);
@ -1165,6 +1189,7 @@ INSERT INTO `roleInherit` VALUES (360,101,129,NULL);
INSERT INTO `roleInherit` VALUES (361,50,112,NULL); INSERT INTO `roleInherit` VALUES (361,50,112,NULL);
INSERT INTO `roleInherit` VALUES (362,122,15,NULL); INSERT INTO `roleInherit` VALUES (362,122,15,NULL);
INSERT INTO `roleInherit` VALUES (364,35,18,NULL); INSERT INTO `roleInherit` VALUES (364,35,18,NULL);
INSERT INTO `roleInherit` VALUES (365,123,119,NULL);
INSERT INTO `userPassword` VALUES (1,7,1,0,2,1); INSERT INTO `userPassword` VALUES (1,7,1,0,2,1);
@ -1747,8 +1772,8 @@ INSERT INTO `ACL` VALUES (688,'ClientSms','create','WRITE','ALLOW','ROLE','emplo
INSERT INTO `ACL` VALUES (689,'Vehicle','sorted','WRITE','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (689,'Vehicle','sorted','WRITE','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (690,'Roadmap','*','*','ALLOW','ROLE','palletizerBoss'); INSERT INTO `ACL` VALUES (690,'Roadmap','*','*','ALLOW','ROLE','palletizerBoss');
INSERT INTO `ACL` VALUES (691,'Roadmap','*','*','ALLOW','ROLE','productionBoss'); INSERT INTO `ACL` VALUES (691,'Roadmap','*','*','ALLOW','ROLE','productionBoss');
INSERT INTO `ACL` VALUES (692,'ExpeditionTruck','*','*','ALLOW','ROLE','production'); INSERT INTO `ACL` VALUES (692,'RoadmapStop','*','*','ALLOW','ROLE','production');
INSERT INTO `ACL` VALUES (693,'ExpeditionTruck','*','*','ALLOW','ROLE','productionBoss'); INSERT INTO `ACL` VALUES (693,'RoadmapStop','*','*','ALLOW','ROLE','productionBoss');
INSERT INTO `ACL` VALUES (695,'ViaexpressConfig','internationalExpedition','WRITE','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (695,'ViaexpressConfig','internationalExpedition','WRITE','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (696,'ViaexpressConfig','renderer','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (696,'ViaexpressConfig','renderer','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (697,'Ticket','transferClient','WRITE','ALLOW','ROLE','administrative'); INSERT INTO `ACL` VALUES (697,'Ticket','transferClient','WRITE','ALLOW','ROLE','administrative');
@ -1887,6 +1912,14 @@ INSERT INTO `ACL` VALUES (834,'AgencyMode','*','READ','ALLOW','ROLE','employee')
INSERT INTO `ACL` VALUES (835,'Agency','*','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (835,'Agency','*','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (836,'Agency','*','WRITE','ALLOW','ROLE','deliveryAssistant'); INSERT INTO `ACL` VALUES (836,'Agency','*','WRITE','ALLOW','ROLE','deliveryAssistant');
INSERT INTO `ACL` VALUES (837,'AgencyWorkCenter','*','WRITE','ALLOW','ROLE','deliveryAssistant'); INSERT INTO `ACL` VALUES (837,'AgencyWorkCenter','*','WRITE','ALLOW','ROLE','deliveryAssistant');
INSERT INTO `ACL` VALUES (838,'Worker','getAvailablePda','READ','ALLOW','ROLE','hr');
INSERT INTO `ACL` VALUES (839,'Locker','__get__codes','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (840,'Locker','*','*','ALLOW','ROLE','hr');
INSERT INTO `ACL` VALUES (841,'Locker','*','*','ALLOW','ROLE','productionBoss');
INSERT INTO `ACL` VALUES (842,'Worker','__get__locker','READ','ALLOW','ROLE','hr');
INSERT INTO `ACL` VALUES (843,'Worker','__get__locker','READ','ALLOW','ROLE','productionBoss');
INSERT INTO `ACL` VALUES (844,'RoadmapStop','*','*','ALLOW','ROLE','production');
INSERT INTO `ACL` VALUES (845,'RoadmapStop','*','*','ALLOW','ROLE','productionBoss');
INSERT INTO `fieldAcl` VALUES (1,'Client','name','update','employee'); INSERT INTO `fieldAcl` VALUES (1,'Client','name','update','employee');
INSERT INTO `fieldAcl` VALUES (2,'Client','contact','update','employee'); INSERT INTO `fieldAcl` VALUES (2,'Client','contact','update','employee');
@ -2206,8 +2239,8 @@ INSERT INTO `continent` VALUES (3,'África','AF');
INSERT INTO `continent` VALUES (4,'Europa','EU'); INSERT INTO `continent` VALUES (4,'Europa','EU');
INSERT INTO `continent` VALUES (5,'Oceanía','OC'); INSERT INTO `continent` VALUES (5,'Oceanía','OC');
INSERT INTO `department` VALUES (1,'VN','VERDNATURA',1,110,763,0,0,0,0,26,NULL,'/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (1,'VN','VERDNATURA',1,110,763,0,0,0,0,25,NULL,'/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (22,'shopping','COMPRAS',2,3,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (22,'shopping','COMPRAS',2,3,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (23,'CMA','CAMARA',13,14,NULL,72,1,1,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,1,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (23,'CMA','CAMARA',13,14,NULL,72,1,1,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,1,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (31,'it','INFORMATICA',4,5,NULL,72,0,0,1,0,1,'/1/','informatica-cau',1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (31,'it','INFORMATICA',4,5,NULL,72,0,0,1,0,1,'/1/','informatica-cau',1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (34,'accounting','CONTABILIDAD',6,7,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (34,'accounting','CONTABILIDAD',6,7,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
@ -2217,28 +2250,28 @@ INSERT INTO `department` VALUES (37,'PROD','PRODUCCION',12,35,NULL,72,1,1,1,11,1
INSERT INTO `department` VALUES (38,'picking','SACADO',15,16,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (38,'picking','SACADO',15,16,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (39,'packing','ENCAJADO',17,18,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (39,'packing','ENCAJADO',17,18,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (41,'administration','ADMINISTRACION',36,37,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (41,'administration','ADMINISTRACION',36,37,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (43,'VT','VENTAS',38,69,NULL,0,0,0,1,15,1,'/1/',NULL,1,'',1,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (43,'VT','VENTAS',38,71,NULL,0,0,0,1,16,1,'/1/',NULL,1,'',1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (44,'management','GERENCIA',70,71,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (44,'management','GERENCIA',72,73,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (45,'logistic','LOGISTICA',72,73,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (45,'logistic','LOGISTICA',74,75,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (46,'delivery','REPARTO',74,75,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (46,'delivery','REPARTO',76,77,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (48,'storage','ALMACENAJE',76,77,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (48,'storage','ALMACENAJE',78,79,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (49,NULL,'PROPIEDAD',78,79,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (49,NULL,'PROPIEDAD',80,81,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (52,NULL,'CARGA AEREA',80,81,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (52,NULL,'CARGA AEREA',82,83,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (53,'marketing','MARKETING Y COMUNICACIÓN',39,40,NULL,72,0,0,2,0,43,'/1/43/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (53,'marketing','MARKETING Y COMUNICACIÓN',39,40,NULL,72,0,0,2,0,43,'/1/43/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (54,NULL,'ORNAMENTALES',82,83,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (54,NULL,'ORNAMENTALES',84,85,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (55,NULL,'TALLER NATURAL',19,20,14548,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1118,NULL,NULL,NULL); INSERT INTO `department` VALUES (55,NULL,'TALLER NATURAL',19,20,14548,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1118,NULL,NULL,NULL);
INSERT INTO `department` VALUES (56,NULL,'TALLER ARTIFICIAL',21,22,8470,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1927,NULL,NULL,NULL); INSERT INTO `department` VALUES (56,NULL,'TALLER ARTIFICIAL',21,22,8470,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1927,NULL,NULL,NULL);
INSERT INTO `department` VALUES (58,'CMP','CAMPOS',84,87,NULL,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (58,'CMP','CAMPOS',86,89,NULL,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (59,'maintenance','MANTENIMIENTO',88,89,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (59,'maintenance','MANTENIMIENTO',90,91,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (60,'claims','RECLAMACIONES',41,42,NULL,72,0,0,2,0,43,'/1/43/',NULL,1,NULL,1,1,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (60,'claims','RECLAMACIONES',41,42,NULL,72,0,0,2,0,43,'/1/43/',NULL,1,NULL,1,1,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (61,NULL,'VNH',90,93,NULL,73,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (61,NULL,'VNH',92,95,NULL,73,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (66,NULL,'VERDNAMADRID',94,95,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (66,NULL,'VERDNAMADRID',96,97,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (68,NULL,'COMPLEMENTOS',23,24,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (68,NULL,'COMPLEMENTOS',23,24,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (69,NULL,'VERDNABARNA',96,97,NULL,74,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (69,NULL,'VERDNABARNA',98,99,NULL,74,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (80,'vallesTeam','EQUIPO ESPAÑA 5',43,44,4250,72,0,0,2,0,43,'/1/43/','jvp_equipo',1,'equipojvalles@verdnatura.es',0,0,0,0,NULL,NULL,'5300',NULL); INSERT INTO `department` VALUES (80,'spainTeam5','EQUIPO ESPAÑA 5',43,44,4250,0,0,0,2,0,43,'/1/43/','es5_equipo',1,'es5@verdnatura.es',0,0,0,0,NULL,NULL,'5300',NULL);
INSERT INTO `department` VALUES (86,NULL,'LIMPIEZA',98,99,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (86,NULL,'LIMPIEZA',100,101,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (89,NULL,'COORDINACION',100,101,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (89,NULL,'COORDINACION',102,103,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (90,NULL,'TRAILER',91,92,NULL,0,0,0,2,0,61,'/1/61/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (90,NULL,'TRAILER',93,94,NULL,0,0,0,2,0,61,'/1/61/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (91,'artificial','ARTIFICIAL',25,26,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (91,'artificial','ARTIFICIAL',25,26,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (92,NULL,'EQUIPO SILVERIO',45,46,1203,0,0,0,2,0,43,'/1/43/','sdc_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (92,NULL,'EQUIPO SILVERIO',45,46,1203,0,0,0,2,0,43,'/1/43/','sdc_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (94,'spainTeam2','EQUIPO ESPAÑA 2',47,48,3797,0,0,0,2,0,43,'/1/43/','es2_equipo',0,'es2@verdnatura.es',0,0,0,0,NULL,NULL,'5100',NULL); INSERT INTO `department` VALUES (94,'spainTeam2','EQUIPO ESPAÑA 2',47,48,3797,0,0,0,2,0,43,'/1/43/','es2_equipo',0,'es2@verdnatura.es',0,0,0,0,NULL,NULL,'5100',NULL);
@ -2246,20 +2279,20 @@ INSERT INTO `department` VALUES (95,'spainTeam1','EQUIPO ESPAÑA 1',49,50,24065,
INSERT INTO `department` VALUES (96,NULL,'EQUIPO C LOPEZ',51,52,4661,0,0,0,2,0,43,'/1/43/','cla_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (96,NULL,'EQUIPO C LOPEZ',51,52,4661,0,0,0,2,0,43,'/1/43/','cla_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (115,NULL,'EQUIPO CLAUDI',53,54,3810,0,0,0,2,0,43,'/1/43/','csr_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (115,NULL,'EQUIPO CLAUDI',53,54,3810,0,0,0,2,0,43,'/1/43/','csr_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (123,NULL,'EQUIPO ELENA BASCUÑANA',55,56,7102,0,0,0,2,0,43,'/1/43/','ebt_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (123,NULL,'EQUIPO ELENA BASCUÑANA',55,56,7102,0,0,0,2,0,43,'/1/43/','ebt_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (124,NULL,'CONTROL INTERNO',102,103,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,1,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (124,NULL,'CONTROL INTERNO',57,58,NULL,72,0,0,2,0,43,'/1/43/',NULL,0,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (125,'miriamMarTeam','EQUIPO ESPAÑA 3',57,58,1118,0,0,0,2,0,43,'/1/43/','mir_equipo',0,'equipomirgir@verdnatura.es',0,0,0,0,NULL,NULL,'5200',NULL); INSERT INTO `department` VALUES (125,'spainTeam3','EQUIPO ESPAÑA 3',59,60,1118,0,0,0,2,0,43,'/1/43/','es3_equipo',0,'es3@verdnatura.es',0,0,0,0,NULL,NULL,'5200',NULL);
INSERT INTO `department` VALUES (126,NULL,'PRESERVADO',27,28,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (126,NULL,'PRESERVADO',27,28,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (128,NULL,'PALETIZADO',29,30,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (128,NULL,'PALETIZADO',29,30,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (130,NULL,'REVISION',31,32,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (130,NULL,'REVISION',31,32,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (131,'greenhouse','INVERNADERO',85,86,NULL,0,0,0,2,0,58,'/1/58/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (131,'greenhouse','INVERNADERO',87,88,NULL,0,0,0,2,0,58,'/1/58/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (132,NULL,'EQUIPO DC',59,60,1731,0,0,0,2,0,43,'/1/43/','dc_equipo',1,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (132,NULL,'EQUIPO DC',61,62,1731,0,0,0,2,0,43,'/1/43/','dc_equipo',1,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (133,'franceTeam','EQUIPO FRANCIA',61,62,1731,72,0,0,2,0,43,'/1/43/','fr_equipo',1,'gestionfrancia@verdnatura.es',0,0,0,0,NULL,NULL,'3300',NULL); INSERT INTO `department` VALUES (133,'franceTeam','EQUIPO FRANCIA',63,64,1731,72,0,0,2,0,43,'/1/43/','fr_equipo',1,'gestionfrancia@verdnatura.es',0,0,0,0,NULL,NULL,'3300',NULL);
INSERT INTO `department` VALUES (134,'portugalTeam','EQUIPO PORTUGAL',63,64,6264,0,0,0,2,0,43,'/1/43/','pt_equipo',1,'portugal@verdnatura.es',0,0,0,0,NULL,NULL,'3500',NULL); INSERT INTO `department` VALUES (134,'portugalTeam','EQUIPO PORTUGAL',65,66,6264,0,0,0,2,0,43,'/1/43/','pt_equipo',1,'portugal@verdnatura.es',0,0,0,0,NULL,NULL,'3500',NULL);
INSERT INTO `department` VALUES (135,'routers','ENRUTADORES',104,105,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (135,'routers','ENRUTADORES',104,105,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (136,'heavyVehicles','VEHICULOS PESADOS',106,107,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (136,'heavyVehicles','VEHICULOS PESADOS',106,107,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (137,'sorter','SORTER',108,109,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (137,'sorter','SORTER',108,109,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (139,'soriaTeam','EQUIPO ESPAÑA 4',65,66,3803,0,0,0,2,0,43,'/1/43/','jss_equipo',1,'equipojsoria@verdnatura.es',0,0,0,0,NULL,NULL,'5400',NULL); INSERT INTO `department` VALUES (139,'spainTeam4','EQUIPO ESPAÑA 4',67,68,3803,0,0,0,2,0,43,'/1/43/','es4_equipo',1,'es4@verdnatura.es',0,0,0,0,NULL,NULL,'5400',NULL);
INSERT INTO `department` VALUES (140,'hollandTeam','EQUIPO HOLANDA',67,68,NULL,0,0,0,2,0,43,'/1/43/','nl_equipo',1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (140,'hollandTeam','EQUIPO HOLANDA',69,70,NULL,0,0,0,2,0,43,'/1/43/','nl_equipo',1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (141,NULL,'PREVIA',33,34,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (141,NULL,'PREVIA',33,34,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL);
INSERT INTO `docuware` VALUES (1,'deliveryNote','Albaranes cliente','find','find','N__ALBAR_N',NULL); INSERT INTO `docuware` VALUES (1,'deliveryNote','Albaranes cliente','find','find','N__ALBAR_N',NULL);

View File

@ -1300,7 +1300,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimState','juan@d
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','company','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','company','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','buffer','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','buffer','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','greuge','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','greuge','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','item','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','','Select,Update'); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','item','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','','Select,Update');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','itemShelving','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','itemShelving','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','negativeOrigin','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','negativeOrigin','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryBoss','Vehiculos_consumo','carlosap@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryBoss','Vehiculos_consumo','carlosap@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
@ -1400,6 +1400,12 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','bs','buyer','waste','alexm@db-prox
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientObservation','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientObservation','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceInConfig','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceInConfig','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerActivity','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerActivity','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','bankPolicy','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','bankPolicyDetail','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','bankPolicyReview','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','chat','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','roadmapStop','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','agencyWorkCenter','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
/*!40000 ALTER TABLE `tables_priv` ENABLE KEYS */; /*!40000 ALTER TABLE `tables_priv` ENABLE KEYS */;
/*!40000 ALTER TABLE `columns_priv` DISABLE KEYS */; /*!40000 ALTER TABLE `columns_priv` DISABLE KEYS */;
@ -1595,10 +1601,7 @@ INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','editorFk',
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','recycledPlastic','0000-00-00 00:00:00','Update'); INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','recycledPlastic','0000-00-00 00:00:00','Update');
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','nonRecycledPlastic','0000-00-00 00:00:00','Update'); INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','nonRecycledPlastic','0000-00-00 00:00:00','Update');
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','minQuantity','0000-00-00 00:00:00','Update'); INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','minQuantity','0000-00-00 00:00:00','Update');
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','item','size','0000-00-00 00:00:00','Update');
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','item','originFk','0000-00-00 00:00:00','Select,Update'); INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','item','originFk','0000-00-00 00:00:00','Select,Update');
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','item','longName','0000-00-00 00:00:00','Update');
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','item','name','0000-00-00 00:00:00','Update');
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','id','0000-00-00 00:00:00','Update'); INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','id','0000-00-00 00:00:00','Update');
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','warehouseFk','0000-00-00 00:00:00','Update'); INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','warehouseFk','0000-00-00 00:00:00','Update');
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','shipped','0000-00-00 00:00:00','Update'); INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','shipped','0000-00-00 00:00:00','Update');
@ -1873,7 +1876,6 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','duaParcialMak
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','palletizerBoss','packingsite_startcollection','PROCEDURE','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','palletizerBoss','packingsite_startcollection','PROCEDURE','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','sale_calculatecomponent','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','sale_calculatecomponent','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesPerson','manaspellersrequery','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesPerson','manaspellersrequery','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','adminBoss','packageinvoicing','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','packinglistswitch','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','packinglistswitch','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','previoussticker_get','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','previoussticker_get','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','productioncontrol','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','productioncontrol','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
@ -1976,7 +1978,6 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expeditionscan_ad
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expeditionscan_list','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expeditionscan_list','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expeditionscan_put','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expeditionscan_put','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','cmrpallet_add','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','cmrpallet_add','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemtrash','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','item_getbalance','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','item_getbalance','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expedition_checkroute','FUNCTION','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expedition_checkroute','FUNCTION','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','addnotefromdelivery','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','addnotefromdelivery','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
@ -2029,7 +2030,6 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expeditionscan_add'
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expeditionscan_list','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expeditionscan_list','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expeditionscan_put','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expeditionscan_put','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','cmrpallet_add','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','cmrpallet_add','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemtrash','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','item_getbalance','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','item_getbalance','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expedition_checkroute','FUNCTION','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expedition_checkroute','FUNCTION','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','addnotefromdelivery','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','addnotefromdelivery','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');

File diff suppressed because it is too large Load Diff

View File

@ -3789,7 +3789,7 @@ DELIMITER ;;
BEFORE INSERT ON `country` BEFORE INSERT ON `country`
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
SET NEW.geoFk = zoneGeo_new('country', NEW.country, NULL); SET NEW.geoFk = zoneGeo_new('country', NEW.name, NULL);
END */;; END */;;
DELIMITER ; DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET sql_mode = @saved_sql_mode */ ;
@ -3811,14 +3811,17 @@ DELIMITER ;;
BEGIN BEGIN
UPDATE sage.Naciones UPDATE sage.Naciones
SET countryFk = NEW.id SET countryFk = NEW.id
WHERE Nacion = NEW.country; WHERE Nacion = NEW.name;
IF ROW_COUNT() = 0 THEN IF ROW_COUNT() = 0 THEN
CALL mail_insert( CALL mail_insert(
'cau@verdnatura.es', 'cau@verdnatura.es',
NULL, NULL,
'Actualizar tabla sage.Naciones', 'Actualizar tabla sage.Naciones',
CONCAT('Se ha insertado un nuevo país en la tabla vn.conuntry. Para el correcto funcionamiento del sistema \n\t\t\t\tde contabilidad es necesario actualizar la columna sage.Naciones.countryFk con el valor del nuevo país. \n\t\t\t Hay que buscar el nuevo país: ', NEW.country, ' en la tabla sage.Naciones y actualizar el campo sage.Naciones.countryFk con el valor ', NEW.id) CONCAT('Se ha insertado un nuevo país en la tabla vn.conuntry.
Para el correcto funcionamiento del sistema \n\t\t\t\tde contabilidad es necesario actualizar la columna
sage.Naciones.countryFk con el valor del nuevo país. \n\t\t\t Hay que buscar el nuevo país: ', NEW.name,
' en la tabla sage.Naciones y actualizar el campo sage.Naciones.countryFk con el valor ', NEW.id)
); );
END IF; END IF;
END */;; END */;;
@ -3862,8 +3865,8 @@ DELIMITER ;;
AFTER UPDATE ON `country` AFTER UPDATE ON `country`
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
IF !(OLD.country <=> NEW.country) THEN IF !(OLD.name <=> NEW.name) THEN
UPDATE zoneGeo SET `name` = NEW.country UPDATE zoneGeo SET `name` = NEW.name
WHERE id = NEW.geoFk; WHERE id = NEW.geoFk;
END IF; END IF;
END */;; END */;;
@ -4325,10 +4328,32 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;; DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionUser_afterInsert`
AFTER INSERT ON `deviceProductionUser`
FOR EACH ROW
BEGIN
CALL worker_checkMultipleDevice(NEW.userFk);
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionUser_beforeUpdate` /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionUser_beforeUpdate`
BEFORE UPDATE ON `deviceProductionUser` BEFORE UPDATE ON `deviceProductionUser`
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
CALL worker_checkMultipleDevice(NEW.userFk);
SET NEW.editorFk = account.myUser_getId(); SET NEW.editorFk = account.myUser_getId();
END */;; END */;;
DELIMITER ; DELIMITER ;
@ -5060,50 +5085,6 @@ BEGIN
SET e.stateTypeFk = NEW.typeFk SET e.stateTypeFk = NEW.typeFk
WHERE e.id = NEW.expeditionFk; WHERE e.id = NEW.expeditionFk;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expeditionTruck_beforeInsert`
BEFORE INSERT ON `expeditionTruck`
FOR EACH ROW
BEGIN
SET NEW.description = UCASE(NEW.description);
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expeditionTruck_beforeUpdate`
BEFORE UPDATE ON `expeditionTruck`
FOR EACH ROW
BEGIN
SET NEW.description = UCASE(NEW.description);
END */;; END */;;
DELIMITER ; DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET sql_mode = @saved_sql_mode */ ;
@ -6796,94 +6777,95 @@ DELIMITER ;;
BEFORE INSERT ON `payment` BEFORE INSERT ON `payment`
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
DECLARE cuenta_banco,cuenta_proveedor DOUBLE; DECLARE vBankAccount DOUBLE;
DECLARE vNewBookEntry INT; DECLARE vSupplierAccount DOUBLE;
DECLARE bolCASH BOOLEAN; DECLARE vNewBookEntry INT;
DECLARE isSupplierActive BOOLEAN; DECLARE vIsCash BOOLEAN;
DECLARE vIsSupplierActive BOOLEAN;
-- PAK 10/02/15 No se asientan los pagos directamente, salvo en el caso de las cajas de CASH -- PAK 10/02/15 No se asientan los pagos directamente, salvo en el caso de las cajas de CASH
SELECT (at2.code = 'cash') INTO bolCASH SELECT (at2.code = 'cash') INTO vIsCash
FROM accounting a FROM accounting a
JOIN accountingType at2 ON at2.id = a.accountingTypeFk JOIN accountingType at2 ON at2.id = a.accountingTypeFk
WHERE a.id = NEW.bankFk; WHERE a.id = NEW.bankFk;
IF bolCASH THEN IF vIsCash THEN
SELECT account INTO vBankAccount
SELECT account INTO cuenta_banco FROM accounting
FROM accounting WHERE id = NEW.bankFk;
WHERE id = NEW.bankFk;
SELECT account INTO cuenta_proveedor
FROM supplier
WHERE id = NEW.supplierFk;
CALL ledger_next(vNewBookEntry); SELECT account INTO vSupplierAccount
INSERT INTO XDiario ( ASIEN,
FECHA,
SUBCTA,
CONTRA,
CONCEPTO,
EURODEBE,
EUROHABER,
empresa_id)
SELECT vNewBookEntry,
NEW.received,
SUBCTA,
CONTRA,
NEW.concept,
EURODEBE,
EUROHABER,
NEW.companyFk
FROM ( SELECT cuenta_banco SUBCTA,
cuenta_proveedor CONTRA,
0 EURODEBE,
NEW.amount + NEW.bankingFees EUROHABER
UNION ALL
SELECT cuenta_proveedor SUBCTA,
cuenta_banco CONTRA,
NEW.amount EURODEBE,
0 EUROHABER) gf;
IF NEW.bankingFees <> 0 THEN
INSERT INTO XDiario ( ASIEN,
FECHA,
SUBCTA,
CONTRA,
CONCEPTO,
EURODEBE,
EUROHABER,
empresa_id)
SELECT vNewBookEntry,
NEW.received,
IF(c.id = 1,6260000002,
IF(CEE = 1,6260000003,6260000004)),
cuenta_banco,
NEW.concept,
NEW.bankingFees,
0,
NEW.companyFk
FROM supplier s
JOIN country c ON s.countryFk = c.id
WHERE s.id = NEW.supplierFk;
END IF;
END IF;
SET NEW.dueDated = IFNULL(NEW.dueDated, NEW.received);
SELECT isActive INTO isSupplierActive
FROM supplier FROM supplier
WHERE id = NEW.supplierFk; WHERE id = NEW.supplierFk;
IF isSupplierActive = FALSE THEN CALL ledger_next(YEAR(NEW.received), NEW.companyFk, vNewBookEntry);
CALL util.throw('SUPPLIER_INACTIVE');
END IF; INSERT INTO XDiario (
ASIEN,
IF ISNULL(NEW.workerFk) THEN FECHA,
SET NEW.workerFk = account.myUser_getId(); SUBCTA,
END IF; CONTRA,
CONCEPTO,
END */;; EURODEBE,
EUROHABER,
empresa_id)
SELECT vNewBookEntry,
NEW.received,
SUBCTA,
CONTRA,
NEW.concept,
EURODEBE,
EUROHABER,
NEW.companyFk
FROM (SELECT vBankAccount SUBCTA,
vSupplierAccount CONTRA,
0 EURODEBE,
NEW.amount + NEW.bankingFees EUROHABER
UNION ALL
SELECT vSupplierAccount SUBCTA,
vBankAccount CONTRA,
NEW.amount EURODEBE,
0 EUROHABER) gf;
IF NEW.bankingFees <> 0 THEN
INSERT INTO XDiario (
ASIEN,
FECHA,
SUBCTA,
CONTRA,
CONCEPTO,
EURODEBE,
EUROHABER,
empresa_id)
SELECT vNewBookEntry,
NEW.received,
IF(c.id = 1,6260000002,
IF(CEE = 1,6260000003,6260000004)),
vBankAccount,
NEW.concept,
NEW.bankingFees,
0,
NEW.companyFk
FROM supplier s
JOIN country c ON s.countryFk = c.id
WHERE s.id = NEW.supplierFk;
END IF;
END IF;
SET NEW.dueDated = IFNULL(NEW.dueDated, NEW.received);
SELECT isActive INTO vIsSupplierActive
FROM supplier
WHERE id = NEW.supplierFk;
IF vIsSupplierActive = FALSE THEN
CALL util.throw('SUPPLIER_INACTIVE');
END IF;
IF ISNULL(NEW.workerFk) THEN
SET NEW.workerFk = account.myUser_getId();
END IF;
END */;;
DELIMITER ; DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_client = @saved_cs_client */ ;
@ -7472,6 +7454,48 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;; DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expeditionTruck_beforeInsert`
BEFORE INSERT ON `roadmapStop` FOR EACH ROW
BEGIN
SET NEW.description = UCASE(NEW.description);
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expeditionTruck_beforeUpdate`
BEFORE UPDATE ON `roadmapStop` FOR EACH ROW
BEGIN
SET NEW.description = UCASE(NEW.description);
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`route_beforeInsert` /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`route_beforeInsert`
BEFORE INSERT ON `route` BEFORE INSERT ON `route`
FOR EACH ROW FOR EACH ROW
@ -8961,6 +8985,8 @@ BEGIN
UPDATE expedition UPDATE expedition
SET hasNewRoute = TRUE SET hasNewRoute = TRUE
WHERE ticketFk = NEW.id; WHERE ticketFk = NEW.id;
CALL ticket_doCmr(NEW.id);
END IF; END IF;
END */;; END */;;
DELIMITER ; DELIMITER ;
@ -9318,7 +9344,6 @@ DELIMITER ;;
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
SET NEW.editorFk = account.myUser_getId(); SET NEW.editorFk = account.myUser_getId();
CALL ticketRefund_beforeUpsert(NEW.refundTicketFk, NEW.originalTicketFk);
END */;; END */;;
DELIMITER ; DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET sql_mode = @saved_sql_mode */ ;
@ -9339,7 +9364,6 @@ DELIMITER ;;
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
SET NEW.editorFk = account.myUser_getId(); SET NEW.editorFk = account.myUser_getId();
CALL ticketRefund_beforeUpsert(NEW.refundTicketFk, NEW.originalTicketFk);
END */;; END */;;
DELIMITER ; DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET sql_mode = @saved_sql_mode */ ;
@ -9655,11 +9679,6 @@ BEGIN
`changedModel` = 'TicketTracking', `changedModel` = 'TicketTracking',
`changedModelId` = OLD.id, `changedModelId` = OLD.id,
`userFk` = account.myUser_getId(); `userFk` = account.myUser_getId();
CALL util.debugAdd('deletedState',
CONCAT('interFk: ', OLD.id,
' ticketFk: ', OLD.ticketFk,
' stateFk: ', OLD.stateFk));
SELECT i.ticketFk, i.id, s.`name` SELECT i.ticketFk, i.id, s.`name`
INTO vTicketFk, vTicketTrackingFk, vStateName INTO vTicketFk, vTicketTrackingFk, vStateName
@ -10805,4 +10824,4 @@ USE `vn2008`;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2024-05-14 6:26:46 -- Dump completed on 2024-05-28 6:58:42

View File

@ -129,7 +129,7 @@ INSERT INTO vn.itemShelving (id,itemFk,visible,shelvingFk,`grouping`,packing,pac
INSERT INTO vn.beach (code,warehouseFk) VALUES INSERT INTO vn.beach (code,warehouseFk) VALUES
('TEST',1); ('TEST',1);
INSERT INTO vn.routesMonitor (routeFk,name,beachFk,m3,expeditionTruckFk) VALUES INSERT INTO vn.routesMonitor (routeFk,name,beachFk,m3,roadmapStopFk) VALUES
(1,'TEST','TEST',1.0,1); (1,'TEST','TEST',1.0,1);
/* #5483 /* #5483
INSERT INTO vn.ticket (clientFk, warehouseFk, shipped, nickname, refFk, addressFk, workerFk, observations, isSigned, isLabeled, isPrinted, packages, location, `hour`, created, isBlocked, solution, routeFk, priority, hasPriority, companyFk, agencyModeFk, landed, isBoxed, isDeleted, zoneFk, zonePrice, zoneBonus, totalWithVat, totalWithoutVat, weight) INSERT INTO vn.ticket (clientFk, warehouseFk, shipped, nickname, refFk, addressFk, workerFk, observations, isSigned, isLabeled, isPrinted, packages, location, `hour`, created, isBlocked, solution, routeFk, priority, hasPriority, companyFk, agencyModeFk, landed, isBoxed, isDeleted, zoneFk, zonePrice, zoneBonus, totalWithVat, totalWithoutVat, weight)

View File

@ -762,7 +762,12 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF
(30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), (30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL),
(31, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), (31, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL),
(32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), (32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL),
(33, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL); (33, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL),
(34, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1103, 'BEJAR', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL),
(35, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Somewhere in Philippines', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL),
(36, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Ant-Man Adventure', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL),
(37, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1110, 'Deadpool swords', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL);
INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`) INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`)
VALUES VALUES
(1, 11, 1, 'ready'), (1, 11, 1, 'ready'),
@ -808,7 +813,10 @@ INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `userFk`, `created`)
(21, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)), (21, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)),
(22, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)), (22, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)),
(23, 16, 21, util.VN_NOW()), (23, 16, 21, util.VN_NOW()),
(24, 16, 21, util.VN_NOW()); (24, 16, 21, util.VN_NOW()),
(34, 14, 49, util.VN_NOW()),
(35, 14, 18, util.VN_NOW()),
(36, 14, 18, util.VN_NOW());
INSERT INTO `vn`.`deliveryPoint` (`id`, `name`, `ubication`) INSERT INTO `vn`.`deliveryPoint` (`id`, `name`, `ubication`)
VALUES VALUES
@ -1068,7 +1076,10 @@ INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `pric
(37, 4, 31, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), (37, 4, 31, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
(36, 4, 30, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), (36, 4, 30, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
(38, 2, 32, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)), (38, 2, 32, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)),
(39, 1, 32, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE()); (39, 1, 32, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE()),
(40, 2, 34, 'Melee weapon combat fist 15cm', 10.00, 3.91, 0, 0, 0, util.VN_CURDATE()),
(41, 2, 35, 'Melee weapon combat fist 15cm', 8.00, 3.01, 0, 0, 0, util.VN_CURDATE()),
(42, 2, 36, 'Melee weapon combat fist 15cm', 6.00, 2.50, 0, 0, 0, util.VN_CURDATE());
INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`)
VALUES VALUES
@ -1205,11 +1216,11 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`)
(32, 36, -92.324), (32, 36, -92.324),
(32, 39, 0.994); (32, 39, 0.994);
INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `visible`, `grouping`, `packing`, `userFk`) INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `visible`, `grouping`, `packing`,`buyFk`, `userFk`)
VALUES VALUES
(2, 'GVC', 1, 1, 1, 1106), (2, 'GVC', 1, 1, 1, 2,1106),
(4, 'HEJ', 1, 1, 1, 1106), (4, 'HEJ', 1, 1, 1, NULL,1106),
(1, 'UXN', 2, 12, 12, 1106); (1, 'UXN', 2, 12, 12, NULL,1106);
INSERT INTO `vn`.`itemShelvingSale` (`itemShelvingFk`, `saleFk`, `quantity`, `created`, `userFk`) INSERT INTO `vn`.`itemShelvingSale` (`itemShelvingFk`, `saleFk`, `quantity`, `created`, `userFk`)
VALUES VALUES
@ -1247,14 +1258,20 @@ INSERT INTO `vn`.`operator` (`workerFk`, `numberOfWagons`, `trainFk`, `itemPacki
INSERT INTO `vn`.`collection`(`id`, `workerFk`, `stateFk`, `created`, `trainFk`) INSERT INTO `vn`.`collection`(`id`, `workerFk`, `stateFk`, `created`, `trainFk`)
VALUES VALUES
(1, 1106, 5, DATE_ADD(util.VN_CURDATE(),INTERVAL +1 DAY), 1), (1, 1106, 5, DATE_ADD(util.VN_CURDATE(),INTERVAL +1 DAY), 1),
(2, 1106, 14, util.VN_CURDATE(), 1); (2, 1106, 14, util.VN_CURDATE(), 1),
(4, 49, 5, util.VN_CURDATE(), 1),
(5, 18, 5, util.VN_CURDATE(), 1),
(6, 18, 5, util.VN_CURDATE(), 1);
INSERT INTO `vn`.`ticketCollection`(`ticketFk`, `collectionFk`, `level`) INSERT INTO `vn`.`ticketCollection`(`ticketFk`, `collectionFk`, `level`)
VALUES VALUES
(1, 1, 1), (1, 1, 1),
(2, 1, NULL), (2, 1, NULL),
(3, 2, NULL), (3, 2, NULL),
(23, 1, NULL); (23, 1, NULL),
(34, 4, 1),
(35, 5, 1),
(8, 6, 1);
INSERT INTO `vn`.`genus`(`id`, `name`) INSERT INTO `vn`.`genus`(`id`, `name`)
VALUES VALUES
@ -2549,18 +2566,18 @@ INSERT INTO `vn`.`duaEntry` (`duaFk`, `entryFk`, `value`, `customsValue`, `euroV
(7, 7, 1.00, 1.00, 1.00), (7, 7, 1.00, 1.00, 1.00),
(8, 8, 1.00, 1.00, 1.00); (8, 8, 1.00, 1.00, 1.00);
REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issued`, `created`, `supplierRef`, `isBooked`, `companyFk`, `docFk`) REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issued`, `created`, `supplierRef`, `isBooked`, `companyFk`, `docFk`, `bookEntried`)
VALUES VALUES
(1, 1001, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1234, 0, 442, 1), (1, 1001, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1234, 0, 442, 1,util.VN_CURDATE()),
(2, 1002, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1235, 0, 442, 1), (2, 1002, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1235, 0, 442, 1,util.VN_CURDATE()),
(3, 1003, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1236, 0, 442, 1), (3, 1003, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1236, 0, 442, 1,util.VN_CURDATE()),
(4, 1004, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1237, 0, 442, 1), (4, 1004, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1237, 0, 442, 1,util.VN_CURDATE()),
(5, 1005, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1238, 0, 442, 1), (5, 1005, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1238, 0, 442, 1,util.VN_CURDATE()),
(6, 1006, 'R', 2, util.VN_CURDATE(), util.VN_CURDATE(), 1239, 0, 442, 1), (6, 1006, 'R', 2, util.VN_CURDATE(), util.VN_CURDATE(), 1239, 0, 442, 1,util.VN_CURDATE()),
(7, 1007, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1240, 0, 442, 1), (7, 1007, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1240, 0, 442, 1,util.VN_CURDATE()),
(8, 1008, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1241, 0, 442, 1), (8, 1008, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1241, 0, 442, 1,util.VN_CURDATE()),
(9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 0, 442, 1), (9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 0, 442, 1,util.VN_CURDATE()),
(10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 0, 442, 1); (10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 0, 442, 1,util.VN_CURDATE());
INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageFarmerWithholdingFk`, `daysAgo`) INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageFarmerWithholdingFk`, `daysAgo`)
VALUES VALUES
@ -2670,13 +2687,20 @@ INSERT INTO `vn`.`zoneAgencyMode`(`id`, `agencyModeFk`, `zoneFk`)
(3, 6, 5), (3, 6, 5),
(4, 7, 1); (4, 7, 1);
INSERT INTO `vn`.`roadmapAddress` (`addressFk`)
VALUES
(1),
(2),
(3),
(4);
INSERT INTO `vn`.`roadmap` (`id`, `name`, `tractorPlate`, `trailerPlate`, `phone`, `supplierFk`, `etd`, `observations`, `userFk`, `price`, `driverName`) INSERT INTO `vn`.`roadmap` (`id`, `name`, `tractorPlate`, `trailerPlate`, `phone`, `supplierFk`, `etd`, `observations`, `userFk`, `price`, `driverName`)
VALUES VALUES
(1, 'val-algemesi', 'RE-001', 'PO-001', '111111111', 1, util.VN_NOW(), 'this is test observation', 1, 15, 'Batman'), (1, 'val-algemesi', '1234-BCD', '9876-BCD', '111111111', 1, util.VN_NOW(), 'this is test observation', 1, 15, 'Batman'),
(2, 'alg-valencia', 'RE-002', 'PO-002', '111111111', 1, util.VN_NOW(), 'test observation', 1, 20, 'Robin'), (2, 'alg-valencia', '2345-CDF', '8765-BCD', '111111111', 1, util.VN_NOW(), 'test observation', 1, 20, 'Robin'),
(3, 'alz-algemesi', 'RE-003', 'PO-003', '222222222', 2, DATE_ADD(util.VN_NOW(), INTERVAL 2 DAY), 'observations...', 2, 25, 'Driverman'); (3, 'alz-algemesi', '3456-DFG', '7654-BCD', '222222222', 2, DATE_ADD(util.VN_NOW(), INTERVAL 2 DAY), 'observations...', 2, 25, 'Driverman');
INSERT INTO `vn`.`expeditionTruck` (`id`, `roadmapFk`, `warehouseFk`, `eta`, `description`, `userFk`) INSERT INTO `vn`.`roadmapStop` (`id`, `roadmapFk`, `addressFk`, `eta`, `description`, `userFk`)
VALUES VALUES
(1, 1, 1, DATE_ADD(util.VN_NOW(), INTERVAL 1 DAY), 'Best truck in fleet', 1), (1, 1, 1, DATE_ADD(util.VN_NOW(), INTERVAL 1 DAY), 'Best truck in fleet', 1),
(2, 1, 2, DATE_ADD(util.VN_NOW(), INTERVAL '1 2' DAY_HOUR), 'Second truck in fleet', 1), (2, 1, 2, DATE_ADD(util.VN_NOW(), INTERVAL '1 2' DAY_HOUR), 'Second truck in fleet', 1),
@ -3705,7 +3729,8 @@ INSERT IGNORE INTO vn.saleGroup
SET id = 4, SET id = 4,
userFk = 1, userFk = 1,
parkingFk = 9, parkingFk = 9,
sectorFk = 9992; sectorFk = 9992,
ticketFk = 36;
INSERT IGNORE INTO vn.sectorCollectionSaleGroup INSERT IGNORE INTO vn.sectorCollectionSaleGroup
SET id = 9999, SET id = 9999,
@ -3788,7 +3813,46 @@ INSERT INTO vn.workerTeam(id, team, workerFk)
VALUES VALUES
(8, 1, 19); (8, 1, 19);
INSERT INTO vn.workCenter (id, name, payrollCenterFk, counter, warehouseFk, street, geoFk, deliveryManAdjustment) INSERT INTO vn.workCenter (id, name, payrollCenterFk, counter, warehouseFk, street, geoFk, deliveryManAdjustment)
VALUES(100, 'workCenterOne', 1, NULL, 1, 'gotham', NULL, NULL); VALUES(100, 'workCenterOne', 1, NULL, 1, 'gotham', NULL, NULL);
UPDATE vn.locker SET workerFk = 1110 WHERE id = 147; INSERT INTO `vn`.`locker` (code, gender, workerFk) VALUES
('1M', 'M', 1),
('2M', 'M', 9),
('3M', 'M', NULL),
('4M', 'M', NULL),
('1F', 'F', 1110),
('2F', 'F', NULL),
('3F', 'F', NULL),
('4F', 'F', NULL);
INSERT INTO `vn`.`ledgerCompany` SET
fiscalYear = YEAR(util.VN_CURDATE()),
bookEntry = 2;
INSERT INTO `vn`.`ledgerConfig` SET
maxTolerance = 0.01;
INSERT INTO vn.sectorCollection
SET id = 2,
userFk = 18,
sectorFk = 1;
INSERT INTO vn.sectorCollectionSaleGroup
SET id = 8,
sectorCollectionFk = 2,
saleGroupFk = 4;
INSERT INTO vn.saleGroup (userFk, parkingFk, sectorFk, ticketFk)
VALUES
(1, 1, 1, 37);
INSERT INTO vn.sectorCollection
SET id = 3,
userFk = 18,
sectorFk = 1;
INSERT INTO vn.sectorCollectionSaleGroup
SET id = 9,
sectorCollectionFk = 3,
saleGroupFk = 6;

View File

@ -48,7 +48,7 @@ BEGIN
-- Marcamos para no repetir -- Marcamos para no repetir
UPDATE vn.claimEnd ce UPDATE vn.claimEnd ce
JOIN vn.claim c ON c.id = ce.claimFk JOIN vn.claim c ON c.id = ce.claimFk
SET c.isChargedToMana = TRUE SET ce.isGreuge = TRUE
WHERE ce.claimDestinationFk NOT IN (1,5) WHERE ce.claimDestinationFk NOT IN (1,5)
AND NOT ce.isGreuge AND NOT ce.isGreuge
AND c.claimStateFk = 3; AND c.claimStateFk = 3;
@ -65,11 +65,12 @@ BEGIN
JOIN vn.ticketLastState ts ON ts.ticketFk = t.id JOIN vn.ticketLastState ts ON ts.ticketFk = t.id
JOIN vn.ticketTracking tt ON tt.id = ts.ticketTrackingFk JOIN vn.ticketTracking tt ON tt.id = ts.ticketTrackingFk
JOIN vn.state st ON st.id = tt.stateFk JOIN vn.state st ON st.id = tt.stateFk
JOIN vn.alertLevel al ON al.code = 'DELIVERED'
WHERE sc.componentFk = 17 WHERE sc.componentFk = 17
AND sc.isGreuge = 0 AND sc.isGreuge = 0
AND t.shipped >= '2016-10-01' AND t.shipped >= '2016-10-01'
AND t.shipped < util.VN_CURDATE() AND t.shipped < util.VN_CURDATE()
AND st.alertLevel >= 3; AND st.alertLevel >= al.id;
DELETE g.* DELETE g.*
FROM vn.greuge g FROM vn.greuge g

View File

@ -46,7 +46,7 @@ BEGIN
JOIN vn.address a ON a.id = t.addressFk JOIN vn.address a ON a.id = t.addressFk
JOIN vn.province p ON p.id = a.provinceFk JOIN vn.province p ON p.id = a.provinceFk
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk
LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk
LEFT JOIN vn.beach b ON b.code = rm.beachFk LEFT JOIN vn.beach b ON b.code = rm.beachFk
LEFT JOIN vn.`zone`z ON z.id = t.zoneFk LEFT JOIN vn.`zone`z ON z.id = t.zoneFk
JOIN vn.agencyMode am ON t.agencyModeFk = am.id JOIN vn.agencyMode am ON t.agencyModeFk = am.id

View File

@ -23,42 +23,39 @@ BEGIN
DECLARE vXtraLongAgj INT; DECLARE vXtraLongAgj INT;
DECLARE vDefaultKlo INT; DECLARE vDefaultKlo INT;
SELECT SELECT usefulAuctionLeftSegmentLength,
ec.usefulAuctionLeftSegmentLength, standardBarcodeLength,
ec.standardBarcodeLength, floridayBarcodeLength,
ec.floridayBarcodeLength, floramondoBarcodeLength,
ec.floramondoBarcodeLength, defaultKlo
ec.defaultKlo INTO vUsefulAuctionLeftSegmentLength,
INTO
vUsefulAuctionLeftSegmentLength,
vStandardBarcodeLength, vStandardBarcodeLength,
vFloridayBarcodeLength, vFloridayBarcodeLength,
vFloramondoBarcodeLength, vFloramondoBarcodeLength,
vDefaultKlo vDefaultKlo
FROM edi.ektConfig ec; FROM ektConfig;
DROP TEMPORARY TABLE IF EXISTS tmp.ekt; CREATE OR REPLACE TEMPORARY TABLE tmp.ekt
CREATE TEMPORARY TABLE tmp.ekt
ENGINE = MEMORY ENGINE = MEMORY
SELECT id ektFk FROM ekt LIMIT 0; SELECT id ektFk FROM ekt LIMIT 0;
CASE CASE
WHEN LENGTH(vBarcode) <= vFloridayBarcodeLength THEN WHEN LENGTH(vBarcode) <= vFloridayBarcodeLength THEN
INSERT INTO tmp.ekt INSERT INTO tmp.ekt
SELECT id SELECT id
FROM edi.ektRecent e FROM ektRecent e
WHERE e.cps = vBarcode WHERE e.cps = vBarcode
OR e.batchNumber = vBarcode; OR e.batchNumber = vBarcode;
WHEN LENGTH(vBarcode) = vFloramondoBarcodeLength THEN WHEN LENGTH(vBarcode) = vFloramondoBarcodeLength THEN
INSERT INTO tmp.ekt INSERT INTO tmp.ekt
SELECT e.id SELECT e.id
FROM edi.ektRecent e FROM ektRecent e
WHERE e.pro = MID(vBarcode,2,6) WHERE e.pro = MID(vBarcode,2,6)
AND CAST(e.ptd AS SIGNED) = MID(vBarcode,8,5); AND CAST(e.ptd AS SIGNED) = MID(vBarcode, 8, 5);
ELSE ELSE
SET vBarcode = LPAD(vBarcode,vStandardBarcodeLength,'0'); SET vBarcode = LPAD(vBarcode, vStandardBarcodeLength, '0');
SET vAuction = MID(vBarcode, 1, 3); SET vAuction = MID(vBarcode, 1, 3);
SET vKlo = MID(vBarcode, 4, 2); SET vKlo = MID(vBarcode, 4, 2);
SET vFec = MAKEDATE(YEAR(util.VN_CURDATE()), MID(vBarcode, 6, 3)); SET vFec = MAKEDATE(YEAR(util.VN_CURDATE()), MID(vBarcode, 6, 3));
@ -69,21 +66,23 @@ BEGIN
-- Clásico de subasta -- Clásico de subasta
-- Trade standard -- Trade standard
-- Trade que construye como la subasta -- Trade que construye como la subasta
-- Trade como el anterior pero sin trade code -- Trade como el anterior pero sin trade code
INSERT INTO tmp.ekt INSERT INTO tmp.ekt
SELECT id SELECT id
FROM ekt FROM ekt
WHERE fec >= vFec - INTERVAL 1 DAY WHERE fec >= vFec - INTERVAL 1 DAY
AND (( AND (
vKlo = vDefaultKlo (vKlo = vDefaultKlo
AND (klo = vKlo OR klo IS NULL OR klo = 0) AND (klo = vKlo OR klo IS NULL OR klo = 0)
AND agj IN (vShortAgj, vLongAgj, vXtraLongAgj)) AND agj IN (vShortAgj, vLongAgj, vXtraLongAgj)
OR (klo = vKlo ) OR (
klo = vKlo
AND auction = vAuction AND auction = vAuction
AND agj = vShortAgj) AND agj = vShortAgj
)
) )
ORDER BY agj DESC, fec DESC ORDER BY agj DESC, fec DESC
LIMIT 1; LIMIT 1;
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound; SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
@ -91,9 +90,11 @@ BEGIN
IF NOT vIsFound THEN IF NOT vIsFound THEN
INSERT INTO tmp.ekt INSERT INTO tmp.ekt
SELECT id SELECT id
FROM edi.ektRecent e FROM ektRecent e
WHERE e.batchNumber WHERE e.batchNumber = LEFT(
= LEFT(vBarcode,vUsefulAuctionLeftSegmentLength) vBarcode,
vUsefulAuctionLeftSegmentLength
)
AND e.batchNumber > 0; AND e.batchNumber > 0;
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound; SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
@ -103,7 +104,7 @@ BEGIN
IF NOT vIsFound THEN IF NOT vIsFound THEN
INSERT INTO tmp.ekt INSERT INTO tmp.ekt
SELECT id SELECT id
FROM edi.ektRecent e FROM ektRecent e
WHERE e.putOrderFk = vBarcode; WHERE e.putOrderFk = vBarcode;
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound; SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
@ -113,18 +114,28 @@ BEGIN
IF NOT vIsFound THEN IF NOT vIsFound THEN
INSERT INTO tmp.ekt INSERT INTO tmp.ekt
SELECT id SELECT id
FROM edi.ektRecent e FROM ektRecent e
WHERE e.deliveryNumber WHERE e.deliveryNumber = MID(vBarcode, 4, 13)
= MID(vBarcode, 4, 13)
AND e.deliveryNumber > 0; AND e.deliveryNumber > 0;
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound; SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
END IF; END IF;
-- Solo campo agj
IF NOT vIsFound THEN
INSERT INTO tmp.ekt
SELECT id
FROM ektRecent
WHERE agj = vShortAgj;
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
END IF;
END CASE; END CASE;
IF vIsFound THEN IF vIsFound THEN
UPDATE ekt e UPDATE ekt e
JOIN tmp.ekt t ON t.ektFk = e.id JOIN tmp.ekt t ON t.ektFk = e.id
SET e.scanned = TRUE; SET e.scanned = TRUE;
END IF; END IF;
END$$ END$$

View File

@ -40,19 +40,28 @@ proc:BEGIN
postalCode, postalCode,
`type`, `type`,
image, image,
description description,
addressFk
) )
SELECT i.name, SELECT CONCAT(i.name, ' by ',a.nickname),
i.`size`, r.price + apc.deliveryCost,
i.id, r.itemFk,
vLanded, vLanded,
vPostalCode, vPostalCode,
it.name, it.name,
CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image), CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image),
i.description i.description,
apc.addressFk
FROM vn.item i FROM vn.item i
JOIN (SELECT itemFk, SUM(quantity * cost) price
FROM recipe
GROUP BY itemFk) r ON r.itemFk = i.id
JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.itemType it ON it.id = i.typeFk
WHERE it.code IN ('FNR','FNP'); JOIN addressPostCode apc
ON apc.dayOfWeek = dayOfWeek(vLanded)
AND NOW() < vLanded - INTERVAL apc.hoursInAdvance HOUR
AND apc.postCode = vPostalCode
JOIN vn.address a ON a.id = apc.addressFk;
SELECT * SELECT *
FROM catalogue FROM catalogue

View File

@ -13,8 +13,17 @@ BEGIN
/** /**
* Set actions for contact request * Set actions for contact request
* *
* @param vPostalCode Delivery address postal code * @param vName Name
* @param vPhone Phone number
* @param vEmail e-mail
* @param vMessage text of the message
*/ */
CALL vn.mail_insert(
'floranet@verdnatura.es',
vEmail,
'Contact request',
CONCAT('Phone: ',vPhone, ' Message: ', vMessage)
);
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -21,7 +21,7 @@ BEGIN
apc.dayOfWeek - vCurrentDayOfWeek, apc.dayOfWeek - vCurrentDayOfWeek,
7 - apc.dayOfWeek 7 - apc.dayOfWeek
) DAY nextDay, ) DAY nextDay,
NOW() + INTERVAL apc.hoursInAdvance - 12 HOUR minDeliveryTime NOW() + INTERVAL apc.hoursInAdvance HOUR minDeliveryTime
FROM addressPostCode apc FROM addressPostCode apc
WHERE apc.postCode = vPostalCode WHERE apc.postCode = vPostalCode
HAVING nextDay > minDeliveryTime) sub; HAVING nextDay > minDeliveryTime) sub;

View File

@ -1,25 +1,167 @@
DROP PROCEDURE IF EXISTS floranet.order_confirm;
DELIMITER $$ DELIMITER $$
$$ $$
CREATE DEFINER=`root`@`localhost`PROCEDURE floranet.order_confirm(vCatalogueFk INT) CREATE OR REPLACE DEFINER=`root`@`localhost`PROCEDURE floranet.order_confirm(vCatalogueFk INT)
READS SQL DATA READS SQL DATA
BEGIN proc:BEGIN
/** Update order.isPaid field. /** Update order.isPaid field, and makes the ticket
* *
* @param vCatalogueFk floranet.catalogue.id * @param vCatalogueFk floranet.catalogue.id
* *
* @returns floranet.order.isPaid * @returns floranet.order.isPaid
*/ */
DECLARE vNewTicketFk INT;
DECLARE vCustomerEmail VARCHAR(255);
DECLARE vFloranetEmail VARCHAR(255);
DECLARE vSubjectEmail VARCHAR(100);
DECLARE vBodyEmail TEXT;
DECLARE vZoneFk INT;
DECLARE exit handler FOR SQLEXCEPTION
BEGIN
ROLLBACK;
GET DIAGNOSTICS CONDITION 2 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
SELECT CONCAT('ERROR ', IFNULL(@errno,0), ': ', ifnull(@text,'texto')) AS `SQLEXCEPTION`;
CALL vn.mail_insert(
'floranet@verdnatura.es,pako@verdnatura.es',
'noreply@verdnatura.es',
'Floranet.order_confirm failure',
CONCAT('CatalogueFk: ', vCatalogueFk, '\n','ERROR ', IFNULL(@errno, 0), ': ', ifnull(@text, 'texto'))
);
END;
IF (SELECT isPaid FROM `order` WHERE catalogueFk = vCatalogueFk) THEN
SELECT CONCAT('CatalogueFk: ', vCatalogueFk, ' Esta orden ya está confirmada') AS `ERROR`;
LEAVE proc;
END IF;
START TRANSACTION;
UPDATE `order` UPDATE `order`
SET isPaid = TRUE, SET isPaid = TRUE,
payed = NOW() payed = NOW()
WHERE catalogueFk = vCatalogueFk; WHERE catalogueFk = vCatalogueFk;
SELECT isPaid SELECT zoneFk
INTO vZoneFk
FROM (
SELECT zoneFk, COUNT(*) totalCount
FROM vn.ticket t
JOIN catalogue c ON c.id = vCatalogueFk
WHERE t.shipped > util.VN_CURDATE() - INTERVAL 1 YEAR
AND t.addressFk = c.addressFk
GROUP BY zoneFk
ORDER BY totalCount DESC
LIMIT 10000000000000000000
) sub
LIMIT 1;
INSERT INTO vn.ticket (
clientFk,
shipped,
addressFk,
agencyModeFk,
nickname,
warehouseFk,
routeFk,
companyFk,
landed,
zoneFk
)
SELECT a.clientFk,
c.dated - INTERVAL 1 DAY,
c.addressFk,
a.agencyModeFk,
a.nickname,
ag.warehouseFk,
NULL,
co.id,
c.dated,
vZoneFk
FROM vn.address a
JOIN vn.agencyMode am ON am.id = a.agencyModeFk
JOIN vn.agency ag ON ag.id = am.agencyFk
JOIN catalogue c ON c.addressFk = a.id
JOIN vn.company co ON co.code = 'VNL'
WHERE c.id = vCatalogueFk;
SET vNewTicketFk = LAST_INSERT_ID();
INSERT INTO vn.sale(
ticketFk,
itemFk,
concept,
price,
quantity)
SELECT
vNewTicketFk,
c.itemFk,
CONCAT('Entrega: ',c.name),
- c.price,
1
FROM catalogue c
JOIN addressPostCode apc
ON apc.addressFk = c.addressFk
AND apc.dayOfWeek = dayOfWeek(c.dated)
WHERE c.id = vCatalogueFk;
INSERT INTO vn.sale(
ticketFk,
itemFk,
concept,
price,
quantity)
SELECT
vNewTicketFk,
r.elementFk,
i.longName,
r.cost,
r.quantity
FROM catalogue c
JOIN recipe r ON r.itemFk = c.itemFk
JOIN vn.item i ON i.id = r.elementFk
WHERE c.id = vCatalogueFk;
SELECT cl.email,
cf.email,
CONCAT('Nuevo pedido FLORANET para entrega el ',c.dated),
CONCAT_WS('\n',
CONCAT('Producto: ', c.name),
CONCAT('Fecha de entrega: ',c.dated),
CONCAT('Destinatario: ', o.deliveryName),
CONCAT('Dirección: ', o.address),
CONCAT('CP: ', c.postalCode),
CONCAT('Foto: ', c.image),
CONCAT('Mensaje: ', IFNULL(o.message,"Ninguno.")),
CONCAT('Teléfono: ',IFNULL(o.deliveryPhone,"--")),
CONCAT('Observaciones: ', IFNULL(o.observations,"No hay."))
)
INTO vCustomerEmail,
vFloranetEmail,
vSubjectEmail,
vBodyEmail
FROM vn.client cl
JOIN vn.address a ON a.clientFk = cl.id
JOIN catalogue c ON c.addressFk = a.id
JOIN `order` o ON o.catalogueFk = c.id
JOIN config cf
WHERE c.id = vCatalogueFk;
CALL vn.mail_insert(
vCustomerEmail,
vFloranetEmail,
vSubjectEmail,
vBodyEmail);
SELECT isPaid, vNewTicketFk
FROM `order` FROM `order`
WHERE catalogueFk = vCatalogueFk; WHERE catalogueFk = vCatalogueFk;
COMMIT;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -7,7 +7,7 @@ BEGIN
* *
* @param vJsonData The order data in json format * @param vJsonData The order data in json format
*/ */
INSERT INTO `order` REPLACE `order`
SET catalogueFk = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.products[0].id')), SET catalogueFk = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.products[0].id')),
customerName = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.customerName')), customerName = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.customerName')),
email = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.email')), email = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.email')),
@ -15,7 +15,8 @@ BEGIN
message= JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.message')), message= JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.message')),
deliveryName = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryName')), deliveryName = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryName')),
address = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.address')), address = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.address')),
deliveryPhone = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryPhone')); deliveryPhone = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryPhone')),
observations = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.observations'));
SELECT LAST_INSERT_ID() orderFk; SELECT LAST_INSERT_ID() orderFk;
END$$ END$$

View File

@ -9,12 +9,11 @@ BEGIN
* Returns list of url for sliders. * Returns list of url for sliders.
*/ */
SELECT SELECT
CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image) url, CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image) url,
i.longName i.longName
FROM vn.item i FROM vn.item i
JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.itemType it ON it.id = i.typeFk
WHERE it.code IN ('FNR','FNP') WHERE it.code IN ('FNR','FNP')
LIMIT 3; LIMIT 3;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`item_getVisible
vType INT, vType INT,
vPrefix VARCHAR(255)) vPrefix VARCHAR(255))
BEGIN BEGIN
/** /**
* Gets visible items of the specified type at specified date. * Gets visible items of the specified type at specified date.
* *
@ -14,7 +14,7 @@ BEGIN
* @param vType The type id * @param vType The type id
* @param vPrefix The article prefix to filter or %NULL for all * @param vPrefix The article prefix to filter or %NULL for all
* @return tmp.itemVisible Visible items * @return tmp.itemVisible Visible items
*/ */
DECLARE vPrefixLen SMALLINT; DECLARE vPrefixLen SMALLINT;
DECLARE vFilter VARCHAR(255) DEFAULT NULL; DECLARE vFilter VARCHAR(255) DEFAULT NULL;
DECLARE vDateInv DATE DEFAULT vn.getInventoryDate(); DECLARE vDateInv DATE DEFAULT vn.getInventoryDate();
@ -23,13 +23,13 @@ BEGIN
GET DIAGNOSTICS CONDITION 1 GET DIAGNOSTICS CONDITION 1
@message = MESSAGE_TEXT; @message = MESSAGE_TEXT;
CALL vn.mail_insert( CALL vn.mail_insert(
'cau@verdnatura.es', 'cau@verdnatura.es',
NULL, NULL,
CONCAT('hedera.item_getVisible error: ', @message), CONCAT('hedera.item_getVisible error: ', @message),
CONCAT( CONCAT(
'warehouse: ', IFNULL(vWarehouse, ''), 'warehouse: ', IFNULL(vWarehouse, ''),
', Fecha:', IFNULL(vDate, ''), ', Fecha:', IFNULL(vDate, ''),
', tipo: ', IFNULL(vType,''), ', tipo: ', IFNULL(vType,''),
', prefijo: ', IFNULL(vPrefix,''))); ', prefijo: ', IFNULL(vPrefix,'')));
RESIGNAL; RESIGNAL;
END; END;
@ -74,9 +74,10 @@ BEGIN
FROM vn.sale m FROM vn.sale m
JOIN vn.ticket t ON t.id = m.ticketFk JOIN vn.ticket t ON t.id = m.ticketFk
JOIN vn.ticketState s ON s.ticketFk = t.id JOIN vn.ticketState s ON s.ticketFk = t.id
JOIN vn.alertLevel al ON al.code = 'DELIVERED'
WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE() WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE()
AND t.warehouseFk = vWarehouse AND t.warehouseFk = vWarehouse
AND s.alertLevel = 3 AND s.alertLevel = al.id
) t ) t
GROUP BY itemFk GROUP BY itemFk
HAVING quantity > 0; HAVING quantity > 0;
@ -108,7 +109,7 @@ BEGIN
IF(p.depth > 0, p.depth, 0) depth, p.width, p.height, IF(p.depth > 0, p.depth, 0) depth, p.width, p.height,
CEIL(s.quantity / t.packing) etiquetas CEIL(s.quantity / t.packing) etiquetas
FROM vn.item i FROM vn.item i
JOIN `filter` f ON f.itemFk = i.id JOIN `filter` f ON f.itemFk = i.id
JOIN currentStock s ON s.itemFk = i.id JOIN currentStock s ON s.itemFk = i.id
LEFT JOIN tmp t ON t.itemFk = i.id LEFT JOIN tmp t ON t.itemFk = i.id
LEFT JOIN vn.packaging p ON p.id = t.packagingFk LEFT JOIN vn.packaging p ON p.id = t.packagingFk

View File

@ -62,7 +62,7 @@ BEGIN
END; END;
-- Carga los datos del pedido -- Carga los datos del pedido
SELECT o.date_send, o.address_id, o.note, a.clientFk, SELECT o.date_send, o.address_id, o.note, a.clientFk,
o.company_id, o.agency_id, c.isTaxDataChecked o.company_id, o.agency_id, c.isTaxDataChecked
INTO vDelivery, vAddress, vNotes, vClientId, INTO vDelivery, vAddress, vNotes, vClientId,
vCompanyId, vAgencyModeId, vIsTaxDataChecked vCompanyId, vAgencyModeId, vIsTaxDataChecked
@ -121,6 +121,7 @@ BEGIN
) )
SELECT t.id INTO vTicket SELECT t.id INTO vTicket
FROM vn.ticket t FROM vn.ticket t
JOIN vn.alertLevel al ON al.code = 'FREE'
LEFT JOIN tPrevia tp ON tp.ticketFk = t.id LEFT JOIN tPrevia tp ON tp.ticketFk = t.id
LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id
JOIN hedera.`order` o JOIN hedera.`order` o
@ -131,7 +132,7 @@ BEGIN
WHERE o.id = vSelf WHERE o.id = vSelf
AND t.refFk IS NULL AND t.refFk IS NULL
AND tp.ticketFk IS NULL AND tp.ticketFk IS NULL
AND IFNULL(tls.alertLevel,0) = 0 AND (tls.alertLevel IS NULL OR tls.alertLevel = al.id)
LIMIT 1; LIMIT 1;
-- Crea el ticket en el caso de no existir uno adecuado -- Crea el ticket en el caso de no existir uno adecuado

View File

@ -81,7 +81,7 @@ BEGIN
-- Código redundante -- Código redundante
DO vn.till_new( CALL vn.till_new(
vCustomer vCustomer
,vBank ,vBank
,vAmount / 100 ,vAmount / 100

View File

@ -22,7 +22,7 @@ BEGIN
LEFT JOIN vn.route r ON r.id = t.routeFk LEFT JOIN vn.route r ON r.id = t.routeFk
LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk
LEFT JOIN vn.routesMonitor rm ON t.routeFk = rm.routeFk LEFT JOIN vn.routesMonitor rm ON t.routeFk = rm.routeFk
LEFT JOIN vn.roadmapStop rs ON rm.expeditionTruckFk = rs.id LEFT JOIN vn.roadmapStop rs ON rm.roadmapStopFk = rs.id
WHERE e.id = vExpeditionFk; WHERE e.id = vExpeditionFk;
RETURN vDayMinute; RETURN vDayMinute;

View File

@ -34,7 +34,7 @@ FROM (
) )
LEFT JOIN `vn`.`routesMonitor` `rm` ON(`t`.`routeFk` = `rm`.`routeFk`) LEFT JOIN `vn`.`routesMonitor` `rm` ON(`t`.`routeFk` = `rm`.`routeFk`)
) )
LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`expeditionTruckFk` = `rs`.`id`) LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`roadmapStopFk` = `rs`.`id`)
) )
LEFT JOIN `vn`.`zone` `z` ON(`z`.`id` = `t`.`zoneFk`) LEFT JOIN `vn`.`zone` `z` ON(`z`.`id` = `t`.`zoneFk`)
) )

View File

@ -45,7 +45,7 @@ FROM (
) )
LEFT JOIN `vn`.`routesMonitor` `rm` ON(`t`.`routeFk` = `rm`.`routeFk`) LEFT JOIN `vn`.`routesMonitor` `rm` ON(`t`.`routeFk` = `rm`.`routeFk`)
) )
LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`expeditionTruckFk` = `rs`.`id`) LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`roadmapStopFk` = `rs`.`id`)
) )
JOIN `srt`.`config` `c` JOIN `srt`.`config` `c`
) )

View File

@ -32,7 +32,7 @@ FROM (
) )
LEFT JOIN `vn`.`routesMonitor` `rm` ON(`t`.`routeFk` = `rm`.`routeFk`) LEFT JOIN `vn`.`routesMonitor` `rm` ON(`t`.`routeFk` = `rm`.`routeFk`)
) )
LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`expeditionTruckFk` = `rs`.`id`) LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`roadmapStopFk` = `rs`.`id`)
) )
JOIN `dipole`.`expedition_PrintOut` `epo` ON(`epo`.`expeditionFk` = `e`.`id`) JOIN `dipole`.`expedition_PrintOut` `epo` ON(`epo`.`expeditionFk` = `e`.`id`)
) )

View File

@ -16,12 +16,13 @@ BEGIN
m.created, m.created,
TIMESTAMPADD(DAY, tp.life, t.shipped) expired, TIMESTAMPADD(DAY, tp.life, t.shipped) expired,
m.quantity < 0 isIn, m.quantity < 0 isIn,
m.isPicked OR s.alertLevel > 1 isPicked m.isPicked OR s.alertLevel > al.id isPicked
FROM vn.sale m FROM vn.sale m
JOIN vn.ticket t ON t.id = m.ticketFk JOIN vn.ticket t ON t.id = m.ticketFk
JOIN vn.ticketState s ON s.ticketFk = t.id JOIN vn.ticketState s ON s.ticketFk = t.id
JOIN vn.item i ON i.id = m.itemFk JOIN vn.item i ON i.id = m.itemFk
JOIN vn.itemType tp ON tp.id = i.typeFk JOIN vn.itemType tp ON tp.id = i.typeFk
JOIN vn.alertLevel al ON al.code = 'ON_PREPARATION'
WHERE ( WHERE (
vTableId IS NULL vTableId IS NULL
OR (vTableName = 'ticket' AND t.id = vTableId) OR (vTableName = 'ticket' AND t.id = vTableId)

View File

@ -1,7 +1,7 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`midnight`() CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`midnight`()
RETURNS datetime RETURNS datetime
NOT DETERMINISTIC DETERMINISTIC
READS SQL DATA READS SQL DATA
BEGIN BEGIN

View File

@ -1,12 +1,12 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_commit`(isTx BOOL) CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_commit`(vIsTx BOOL)
BEGIN BEGIN
/** /**
* Confirma los cambios asociados a una transacción. * Confirma los cambios asociados a una transacción.
* *
* @param isTx es true si existe transacción asociada * @param vIsTx es true si existe transacción asociada
*/ */
IF isTx THEN IF vIsTx THEN
COMMIT; COMMIT;
END IF; END IF;
END$$ END$$

View File

@ -1,12 +1,12 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_rollback`(isTx BOOL) CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_rollback`(vIsTx BOOL)
BEGIN BEGIN
/** /**
* Deshace los cambios asociados a una transacción. * Deshace los cambios asociados a una transacción.
* *
* @param isTx es true si existe transacción asociada * @param vIsTx es true si existe transacción asociada
*/ */
IF isTx THEN IF vIsTx THEN
ROLLBACK; ROLLBACK;
END IF; END IF;
END$$ END$$

View File

@ -1,12 +1,12 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_start`(isTx BOOL) CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_start`(vIsTx BOOL)
BEGIN BEGIN
/** /**
* Inicia una transacción. * Inicia una transacción.
* *
* @param isTx es true si existe transacción asociada * @param vIsTx es true si existe transacción asociada
*/ */
IF isTx THEN IF vIsTx THEN
START TRANSACTION; START TRANSACTION;
END IF; END IF;
END$$ END$$

View File

@ -0,0 +1,8 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`client_userDisable`
ON SCHEDULE EVERY 1 MONTH
STARTS '2023-06-01 00:00:00.000'
ON COMPLETION PRESERVE
ENABLE
DO CALL client_userDisable()$$
DELIMITER ;

View File

@ -1,25 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`clientsDisable`
ON SCHEDULE EVERY 1 MONTH
STARTS '2023-06-01 00:00:00.000'
ON COMPLETION PRESERVE
ENABLE
DO BEGIN
UPDATE account.user u
JOIN client c ON c.id = u.id
LEFT JOIN account.account a ON a.id = u.id
SET u.active = FALSE
WHERE c.typeFk = 'normal'
AND a.id IS NULL
AND u.active
AND c.created < util.VN_CURDATE() - INTERVAL 12 MONTH
AND u.id NOT IN (
SELECT DISTINCT c.id
FROM client c
LEFT JOIN ticket t ON t.clientFk = c.id
WHERE c.salesPersonFk IS NOT NULL
OR t.created > util.VN_CURDATE() - INTERVAL 12 MONTH
OR shipped > util.VN_CURDATE() - INTERVAL 12 MONTH
);
END$$
DELIMITER ;

View File

@ -11,10 +11,7 @@ BEGIN
*/ */
DECLARE vClient INT DEFAULT NULL; DECLARE vClient INT DEFAULT NULL;
-- SET vPhone = vPhone COLLATE 'utf8_unicode_ci'; CREATE OR REPLACE TEMPORARY TABLE tClient
DROP TEMPORARY TABLE IF EXISTS tClient;
CREATE TEMPORARY TABLE tClient
ENGINE = MEMORY ENGINE = MEMORY
SELECT id clientFk SELECT id clientFk
FROM `client` FROM `client`
@ -27,13 +24,14 @@ BEGIN
OR mobile = vPhone OR mobile = vPhone
UNION UNION
SELECT clientFk SELECT clientFk
FROM vn.clientContact FROM clientContact
WHERE phone = vPhone; WHERE phone = vPhone;
SELECT t.clientFk INTO vClient SELECT t.clientFk INTO vClient
FROM tClient t FROM tClient t
JOIN `client` c ON c.id = t.clientFk JOIN `client` c ON c.id = t.clientFk
WHERE c.isActive WHERE c.isActive
AND c.salesPersonFk
LIMIT 1; LIMIT 1;
DROP TEMPORARY TABLE tClient; DROP TEMPORARY TABLE tClient;

View File

@ -14,7 +14,7 @@ BEGIN
DECLARE vIsTooLittle TINYINT(1); DECLARE vIsTooLittle TINYINT(1);
SELECT (SUM(IFNULL(sv.litros, 0)) < vc.minTicketVolume SELECT (SUM(IFNULL(sv.litros, 0)) < vc.minTicketVolume
OR IFNULL(t.totalWithoutVat, 0) < vc.minTicketValue) INTO vIsTooLittle AND IFNULL(t.totalWithoutVat, 0) < vc.minTicketValue) INTO vIsTooLittle
FROM ticket t FROM ticket t
LEFT JOIN saleVolume sv ON sv.ticketFk = t.id LEFT JOIN saleVolume sv ON sv.ticketFk = t.id
JOIN volumeConfig vc JOIN volumeConfig vc

View File

@ -1,79 +1,73 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`till_new`(vClient INT CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`till_new`(
,vBank INT vClient INT,
,vAmount DOUBLE vBank INT,
,vConcept VARCHAR(25) vAmount DOUBLE,
,vDated DATE vConcept VARCHAR(25),
,vSerie CHAR(1) vDated DATE,
,vBatch TINYINT vSerie CHAR(1),
,vNumber INT vBatch TINYINT,
,vCompany SMALLINT vNumber INT,
,vWorker INT vCompany SMALLINT,
vWorker INT
) )
RETURNS int(11)
DETERMINISTIC
BEGIN BEGIN
DECLARE vAccount VARCHAR(12); DECLARE vAccount VARCHAR(12);
DECLARE vSubaccount VARCHAR(12); DECLARE vSubaccount VARCHAR(12);
DECLARE vAsiento INT DEFAULT NULL; DECLARE vAsiento INT DEFAULT NULL;
-- Inserta el registro en cajas -- Inserta el registro en cajas
INSERT INTO till INSERT INTO till
SET SET
workerFk = vWorker workerFk = vWorker,
,bankFk = vBank bankFk = vBank,
,`in` = vAmount `in` = vAmount,
,concept = vConcept concept = vConcept,
,dated = vDated dated = vDated,
,serie = vSerie serie = vSerie,
,isAccountable = vBatch isAccountable = vBatch,
,`number` = vNumber `number` = vNumber,
,companyFk = vCompany; companyFk = vCompany;
-- Inserta los asientos contables -- Inserta los asientos contables
SELECT account INTO vAccount SELECT account INTO vAccount
FROM accounting WHERE id = vBank; FROM accounting WHERE id = vBank;
SELECT accountingAccount INTO vSubaccount SELECT accountingAccount INTO vSubaccount
FROM `client` WHERE id = vClient; FROM `client` WHERE id = vClient;
SET vAsiento = xdiario_new CALL xdiario_new(
( vAsiento,
vAsiento vDated,
,vDated vAccount,
,vAccount vSubaccount,
,vSubaccount vConcept,
,vConcept vAmount,
,vAmount 0,
,0 0,
,0 NULL, -- Serie
,NULL -- Serie NULL, -- Factura
,NULL -- Factura NULL, -- IVA
,NULL -- IVA NULL, -- Recargo
,NULL -- Recargo FALSE, -- Auxiliar
,FALSE -- Auxiliar vCompany,
,vCompany vAsiento);
);
DO xdiario_new
(
vAsiento
,vDated
,vSubaccount
,vAccount
,vConcept
,0
,vAmount
,0
,NULL -- Serie
,NULL -- Factura
,NULL -- IVA
,NULL -- Recargo
,FALSE -- Auxiliar
,vCompany
);
RETURN NULL; CALL xdiario_new(
vAsiento,
vDated,
vSubaccount,
vAccount,
vConcept,
0,
vAmount,
0,
NULL, -- Serie
NULL, -- Factura
NULL, -- IVA
NULL, -- Recargo
FALSE, -- Auxiliar
vCompany,
vAsiento);
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -1,45 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`xdiario_new`(
vBookNumber INT,
vDated DATE,
vSubaccount VARCHAR(12),
vAccount VARCHAR(12),
vConcept VARCHAR(25),
vDebit DOUBLE,
vCredit DOUBLE,
vEuro DOUBLE,
vSerie CHAR(1),
vInvoice VARCHAR(8),
vVat DOUBLE,
vRe DOUBLE,
vAux TINYINT,
vCompanyFk INT
)
RETURNS int(11)
NOT DETERMINISTIC
NO SQL
BEGIN
IF vBookNumber IS NULL THEN
CALL ledger_next(YEAR(vDated), vBookNumber);
END IF;
INSERT INTO XDiario
SET ASIEN = vBookNumber,
FECHA = vDated,
SUBCTA = vSubaccount,
CONTRA = vAccount,
CONCEPTO = vConcept,
EURODEBE = vDebit,
EUROHABER = vCredit,
BASEEURO = vEuro,
SERIE = vSerie,
FACTURA = vInvoice,
IVA = vVat,
RECEQUIV = vRe,
AUXILIAR = IF(vAux = FALSE, NULL, '*'),
MONEDAUSO = 2,
empresa_id = vCompanyFk;
RETURN vBookNumber;
END$$
DELIMITER ;

View File

@ -1,5 +1,7 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_afterUpsert`(vSelf INT) CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_afterUpsert`(
vSelf INT
)
BEGIN BEGIN
/** /**
* Triggered actions when a buy is updated or inserted. * Triggered actions when a buy is updated or inserted.
@ -16,7 +18,7 @@ BEGIN
DECLARE vIsFeedStock BOOL; DECLARE vIsFeedStock BOOL;
DECLARE vWeight DECIMAL(10,2); DECLARE vWeight DECIMAL(10,2);
DECLARE vPacking INT; DECLARE vPacking INT;
SELECT b.entryFk, SELECT b.entryFk,
b.itemFk, b.itemFk,
i.packingOut, i.packingOut,
@ -47,8 +49,11 @@ BEGIN
WHERE e.id = vEntryFk; WHERE e.id = vEntryFk;
IF vIsMerchandise THEN IF vIsMerchandise THEN
IF vWarehouse IS NULL THEN
CALL util.throw('The entry does not have travel');
END IF;
REPLACE itemCost SET REPLACE itemCost SET
itemFk = vItemFk, itemFk = vItemFk,
warehouseFk = vWarehouse, warehouseFk = vWarehouse,
cm3 = buy_getUnitVolume(vSelf), cm3 = buy_getUnitVolume(vSelf),
@ -74,7 +79,7 @@ BEGIN
WHERE b.id = vSelf; WHERE b.id = vSelf;
END IF; END IF;
CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck
SELECT vSelf id; SELECT vSelf id;
CALL buy_checkItem(); CALL buy_checkItem();
END$$ END$$

View File

@ -0,0 +1,57 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_clone`(vEntryFk INT)
BEGIN
/**
* Clone buys to an entry
*
* @param vEntryFk The entry id
* @table tmp.buy(id)
*/
INSERT INTO buy(
entryFk,
itemFk,
quantity,
buyingValue,
freightValue,
isIgnored,
stickers,
packagingFk,
packing,
`grouping`,
groupingMode,
comissionValue,
packageValue,
price1,
price2,
price3,
minPrice,
isChecked,
location,
weight,
itemOriginalFk)
SELECT vEntryFk,
b.itemFk,
b.quantity,
b.buyingValue,
b.freightValue,
b.isIgnored,
b.stickers,
b.packagingFk,
b.packing,
b.`grouping`,
b.groupingMode,
b.comissionValue,
b.packageValue,
b.price1,
b.price2,
b.price3,
b.minPrice,
b.isChecked,
b.location,
b.weight,
b.itemOriginalFk
FROM tmp.buy tb
JOIN vn.buy b ON b.id = tb.id;
END$$
DELIMITER ;

View File

@ -10,7 +10,7 @@ BEGIN
*/ */
DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc; DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc;
CREATE TEMPORARY TABLE tmp.buyRecalc CREATE TEMPORARY TABLE tmp.buyRecalc
SELECT vBuyFk id; SELECT vBuyFk id;
CALL buy_recalcPrices(); CALL buy_recalcPrices();

View File

@ -0,0 +1,33 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_userDisable`()
BEGIN
/**
* Desactiva los clientes inactivos en los últimos X meses.
*/
DECLARE vMonths INT;
SELECT monthsToDisableUser INTO vMonths
FROM clientConfig;
IF vMonths IS NULL THEN
CALL util.throw('Config parameter not set');
END IF;
UPDATE account.user u
JOIN client c ON c.id = u.id
LEFT JOIN account.account a ON a.id = u.id
SET u.active = FALSE
WHERE c.typeFk = 'normal'
AND a.id IS NULL
AND u.active
AND c.created < util.VN_CURDATE() - INTERVAL vMonths MONTH
AND u.id NOT IN (
SELECT DISTINCT c.id
FROM client c
LEFT JOIN ticket t ON t.clientFk = c.id
WHERE c.salesPersonFk IS NOT NULL
OR t.created > util.VN_CURDATE() - INTERVAL vMonths MONTH
OR shipped > util.VN_CURDATE() - INTERVAL vMonths MONTH
);
END$$
DELIMITER ;

View File

@ -13,27 +13,12 @@ BEGIN
* @param vCollectionFk Id de colección * @param vCollectionFk Id de colección
*/ */
DECLARE vHasTooMuchCollections BOOL; DECLARE vHasTooMuchCollections BOOL;
DECLARE vItemPackingTypeFk VARCHAR(1);
DECLARE vWarehouseFk INT;
DECLARE vLockName VARCHAR(215);
DECLARE vLockTime INT DEFAULT 30;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
IF vLockName IS NOT NULL THEN
DO RELEASE_LOCK(vLockName);
END IF;
RESIGNAL;
END;
-- Si hay colecciones sin terminar, sale del proceso -- Si hay colecciones sin terminar, sale del proceso
CALL collection_get(vUserFk); CALL collection_get(vUserFk);
SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0
collection_assign_lockname INTO vHasTooMuchCollections
INTO vHasTooMuchCollections,
vLockName
FROM productionConfig pc FROM productionConfig pc
LEFT JOIN tCollection ON TRUE; LEFT JOIN tCollection ON TRUE;
@ -43,21 +28,6 @@ BEGIN
CALL util.throw('Hay colecciones pendientes'); CALL util.throw('Hay colecciones pendientes');
END IF; END IF;
SELECT warehouseFk, itemPackingTypeFk
INTO vWarehouseFk, vItemPackingTypeFk
FROM operator
WHERE workerFk = vUserFk;
SET vLockName = CONCAT_WS('/',
vLockName,
vWarehouseFk,
vItemPackingTypeFk
);
IF NOT GET_LOCK(vLockName, vLockTime) THEN
CALL util.throw(CONCAT('Cannot get lock: ', vLockName));
END IF;
-- Se eliminan las colecciones sin asignar que estan obsoletas -- Se eliminan las colecciones sin asignar que estan obsoletas
INSERT INTO ticketTracking(stateFk, ticketFk) INSERT INTO ticketTracking(stateFk, ticketFk)
SELECT s.id, tc.ticketFk SELECT s.id, tc.ticketFk
@ -65,7 +35,7 @@ BEGIN
JOIN ticketCollection tc ON tc.collectionFk = c.id JOIN ticketCollection tc ON tc.collectionFk = c.id
JOIN `state` s ON s.code = 'PRINTED_AUTO' JOIN `state` s ON s.code = 'PRINTED_AUTO'
JOIN productionConfig pc JOIN productionConfig pc
WHERE c.workerFk IS NULL WHERE c.workerFk IS NULL
AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime; AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime;
DELETE c.* DELETE c.*
@ -79,8 +49,7 @@ BEGIN
VALUES(vUserFk); VALUES(vUserFk);
-- Comprueba si hay colecciones disponibles que se ajustan a su configuracion -- Comprueba si hay colecciones disponibles que se ajustan a su configuracion
SELECT MIN(c.id) SELECT MIN(c.id) INTO vCollectionFk
INTO vCollectionFk
FROM `collection` c FROM `collection` c
JOIN operator o JOIN operator o
ON (o.itemPackingTypeFk = c.itemPackingTypeFk OR c.itemPackingTypeFk IS NULL) ON (o.itemPackingTypeFk = c.itemPackingTypeFk OR c.itemPackingTypeFk IS NULL)
@ -106,7 +75,5 @@ BEGIN
UPDATE `collection` UPDATE `collection`
SET workerFk = vUserFk SET workerFk = vUserFk
WHERE id = vCollectionFk; WHERE id = vCollectionFk;
DO RELEASE_LOCK(vLockName);
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -49,6 +49,10 @@ BEGIN
BEGIN BEGIN
IF vLockName IS NOT NULL THEN IF vLockName IS NOT NULL THEN
DO RELEASE_LOCK(vLockName); DO RELEASE_LOCK(vLockName);
CALL util.debugAdd(JSON_OBJECT(
'type', 'releaseLock',
'userFk', vUserFk
), vLockName); -- Tmp
END IF; END IF;
RESIGNAL; RESIGNAL;

View File

@ -34,7 +34,7 @@ BEGIN
LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
LEFT JOIN vn.agency a ON a.id = am.agencyFk LEFT JOIN vn.agency a ON a.id = am.agencyFk
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk
LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk
JOIN vn.packagingConfig pc JOIN vn.packagingConfig pc
WHERE t.warehouseFk IN (60,1,44) WHERE t.warehouseFk IN (60,1,44)
AND e.created BETWEEN vStarted AND vEnded AND e.created BETWEEN vStarted AND vEnded

View File

@ -6,12 +6,12 @@ BEGIN
* *
* @param vDuaFk Id del dua a recalcular * @param vDuaFk Id del dua a recalcular
*/ */
DECLARE done BOOL DEFAULT FALSE; DECLARE vDone BOOL DEFAULT FALSE;
DECLARE vInvoiceFk INT; DECLARE vInvoiceFk INT;
DECLARE vASIEN BIGINT DEFAULT 0; DECLARE vBookEntry INT;
DECLARE vCounter INT DEFAULT 0; DECLARE vFiscalYear INT;
DECLARE rs CURSOR FOR DECLARE vInvoicesIn CURSOR FOR
SELECT DISTINCT e.invoiceInFk SELECT DISTINCT e.invoiceInFk
FROM entry e FROM entry e
JOIN duaEntry de ON de.entryFk = e.id JOIN duaEntry de ON de.entryFk = e.id
@ -20,9 +20,7 @@ BEGIN
AND de.customsValue AND de.customsValue
AND ii.isBooked = FALSE; AND ii.isBooked = FALSE;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
OPEN rs;
UPDATE invoiceIn ii UPDATE invoiceIn ii
JOIN entry e ON e.invoiceInFk = ii.id JOIN entry e ON e.invoiceInFk = ii.id
@ -36,38 +34,36 @@ BEGIN
e.isConfirmed = TRUE e.isConfirmed = TRUE
WHERE d.id = vDuaFk; WHERE d.id = vDuaFk;
SELECT IFNULL(ASIEN,0) INTO vASIEN SELECT ASIEN INTO vBookEntry FROM dua WHERE id = vDuaFk;
FROM dua
WHERE id = vDuaFk;
FETCH rs INTO vInvoiceFk; IF vBookEntry IS NULL THEN
SELECT YEAR(IFNULL(ii.bookEntried, d.bookEntried)) INTO vFiscalYear
FROM invoiceIn ii
JOIN entry e ON e.invoiceInFk = ii.id
JOIN duaEntry de ON de.entryFk = e.id
JOIN dua d ON d.id = de.duaFk
WHERE d.id = vDuaFk
LIMIT 1;
CALL ledger_nextTx(vFiscalYear, vBookEntry);
END IF;
WHILE NOT done DO OPEN vInvoicesIn;
CALL invoiceIn_booking(vInvoiceFk); l: LOOP
SET vDone = FALSE;
IF vCounter > 0 OR vASIEN > 0 THEN FETCH vInvoicesIn INTO vInvoiceFk;
UPDATE XDiario x
JOIN ledgerConfig lc ON lc.lastBookEntry = x.ASIEN
SET x.ASIEN = vASIEN;
ELSE
SELECT lastBookEntry INTO vASIEN FROM ledgerConfig;
IF vDone THEN
LEAVE l;
END IF; END IF;
SET vCounter = vCounter + 1; CALL invoiceIn_booking(vInvoiceFk, vBookEntry);
END LOOP;
FETCH rs INTO vInvoiceFk; CLOSE vInvoicesIn;
END WHILE;
CLOSE rs;
UPDATE dua UPDATE dua
SET ASIEN = vASIEN SET ASIEN = vBookEntry
WHERE id = vDuaFk; WHERE id = vDuaFk;
UPDATE invoiceIn ii UPDATE invoiceIn ii

View File

@ -12,7 +12,7 @@ BEGIN
WHERE id = vDuaFk; WHERE id = vDuaFk;
IF vBookNumber IS NULL OR NOT vBookNumber THEN IF vBookNumber IS NULL OR NOT vBookNumber THEN
CALL ledger_next(YEAR(vBookDated), vBookNumber); CALL ledger_nextTx(YEAR(vBookDated), vBookNumber);
END IF; END IF;
-- Apunte de la aduana -- Apunte de la aduana

View File

@ -1,22 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_checkBooked`(
vSelf INT
)
BEGIN
/**
* Comprueba si una entrada está contabilizada,
* y si lo está retorna un throw.
*
* @param vSelf Id de entrada
*/
DECLARE vIsBooked BOOL;
SELECT isBooked INTO vIsBooked
FROM `entry`
WHERE id = vSelf;
IF vIsBooked AND NOT IFNULL(@isModeInventory, FALSE) THEN
CALL util.throw('Entry is already booked');
END IF;
END$$
DELIMITER ;

View File

@ -9,8 +9,8 @@ BEGIN
* Clones an entry header. * Clones an entry header.
* *
* @param vSelf The entry id * @param vSelf The entry id
* @param OUT vNewEntryFk The new entry id
* @param vTravelFk Travel for the new entry or %NULL to use the source entry travel * @param vTravelFk Travel for the new entry or %NULL to use the source entry travel
* @param vNewEntryFk The new entry id
*/ */
INSERT INTO entry( INSERT INTO entry(
travelFk, travelFk,

View File

@ -1,59 +1,18 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_copyBuys`(vSelf INT, vCopyTo INT) CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_copyBuys`(vSelf INT, vDestinationEntryFk INT)
BEGIN BEGIN
/** /**
* Copies an entry buys to another buy. * Copies all buys from an entry to an entry.
* *
* @param vSelf The entry id * @param vSelf The entry id
* @param vCopyTo The destination entry id * @param vDestinationEntryFk The destination entry id
*/ */
INSERT INTO buy( CREATE OR REPLACE TEMPORARY TABLE tmp.buy
entryFk, SELECT id
itemFk,
quantity,
buyingValue,
freightValue,
isIgnored,
stickers,
packing,
`grouping`,
groupingMode,
containerFk,
comissionValue,
packageValue,
packagingFk,
price1,
price2,
price3,
minPrice,
isChecked,
location,
weight,
itemOriginalFk
)
SELECT vCopyTo,
itemFk,
quantity,
buyingValue,
freightValue,
isIgnored,
stickers,
packing,
`grouping`,
groupingMode,
containerFk,
comissionValue,
packageValue,
packagingFk,
price1,
price2,
price3,
minPrice,
isChecked,
location,
weight,
itemOriginalFk
FROM buy FROM buy
WHERE entryFk = vSelf; WHERE entryFk = vSelf;
CALL buy_clone(vDestinationEntryFk);
DROP TEMPORARY TABLE tmp.buy;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -26,7 +26,6 @@ BEGIN
packing, packing,
`grouping`, `grouping`,
groupingMode, groupingMode,
containerFk,
comissionValue, comissionValue,
packageValue, packageValue,
location, location,
@ -46,7 +45,6 @@ BEGIN
packing, packing,
`grouping`, `grouping`,
groupingMode, groupingMode,
containerFk,
comissionValue, comissionValue,
packageValue, packageValue,
location, location,

View File

@ -0,0 +1,24 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_isEditable`(
vSelf INT
)
BEGIN
/**
* Comprueba si una entrada se puede actualizar
* si no se puede retorna un throw.
*
* @param vSelf Id de entrada
*/
DECLARE vIsEditable BOOL;
SELECT e.isBooked INTO vIsEditable
FROM `entry` e
JOIN entryType et ON et.code = e.typeFk
WHERE NOT et.isInformal
AND e.id = vSelf;
IF vIsEditable AND NOT IFNULL(@isModeInventory, FALSE) THEN
CALL util.throw('Entry is not editable');
END IF;
END$$
DELIMITER ;

View File

@ -56,7 +56,6 @@ BEGIN
packing, packing,
`grouping`, `grouping`,
groupingMode, groupingMode,
containerFk,
comissionValue, comissionValue,
packageValue, packageValue,
packagingFk, packagingFk,
@ -77,7 +76,6 @@ BEGIN
packing, packing,
`grouping`, `grouping`,
groupingMode, groupingMode,
containerFk,
comissionValue, comissionValue,
packageValue, packageValue,
packagingFk, packagingFk,
@ -114,7 +112,6 @@ BEGIN
packing, packing,
`grouping`, `grouping`,
groupingMode, groupingMode,
containerFk,
comissionValue, comissionValue,
packageValue, packageValue,
location, location,
@ -133,7 +130,6 @@ BEGIN
packing, packing,
`grouping`, `grouping`,
groupingMode, groupingMode,
containerFk,
comissionValue, comissionValue,
packageValue, packageValue,
location, location,

View File

@ -76,7 +76,6 @@ BEGIN
packing, packing,
`grouping`, `grouping`,
groupingMode, groupingMode,
containerFk,
comissionValue, comissionValue,
packageValue, packageValue,
location, location,
@ -103,7 +102,6 @@ BEGIN
packing, packing,
`grouping`, `grouping`,
groupingMode, groupingMode,
containerFk,
comissionValue, comissionValue,
packageValue, packageValue,
location, location,

View File

@ -23,7 +23,8 @@ BEGIN
JOIN vn.travel t ON t.id = e.travelFk JOIN vn.travel t ON t.id = e.travelFk
JOIN vn.warehouse w ON w.id = t.warehouseInFk JOIN vn.warehouse w ON w.id = t.warehouseInFk
WHERE t.shipped >= util.VN_CURDATE() WHERE t.shipped >= util.VN_CURDATE()
AND e.currencyFk = vCurrency; AND e.currencyFk = vCurrency
AND NOT e.isBooked;
SET vComission = currency_getCommission(vCurrency); SET vComission = currency_getCommission(vCurrency);

View File

@ -56,13 +56,13 @@ BEGIN
LIMIT 1; LIMIT 1;
IF vPalletFk IS NULL THEN IF vPalletFk IS NULL THEN
SELECT expeditionTruckFk SELECT roadmapStopFk
INTO vTruckFk INTO vTruckFk
FROM ( FROM (
SELECT rm.expeditionTruckFk, count(*) n SELECT rm.roadmapStopFk, count(*) n
FROM vn.routesMonitor rm FROM vn.routesMonitor rm
JOIN tExpedition e ON e.routeFk = rm.routeFk JOIN tExpedition e ON e.routeFk = rm.routeFk
GROUP BY expeditionTruckFk GROUP BY roadmapStopFk
ORDER BY n DESC ORDER BY n DESC
LIMIT 1) sub; LIMIT 1) sub;

View File

@ -1,9 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionTruck_Add`(vHour VARCHAR(5), vDescription VARCHAR(45))
BEGIN
INSERT INTO vn.roadmapStop(eta,description)
VALUES(CONCAT(util.VN_CURDATE(), ' ', vHour), vDescription);
END$$
DELIMITER ;

View File

@ -1,12 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionTruck_List`()
BEGIN
SELECT id truckFk,
eta,
description Destino
FROM roadmapStop
WHERE eta BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
ORDER BY eta;
END$$
DELIMITER ;

View File

@ -67,7 +67,7 @@ BEGIN
LEFT JOIN vn.route r ON r.id = t.routeFk LEFT JOIN vn.route r ON r.id = t.routeFk
LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id
LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk
WHERE e.id = vExpeditionFk; WHERE e.id = vExpeditionFk;
END$$ END$$

View File

@ -15,7 +15,8 @@ BEGIN
t.addressFk, t.addressFk,
a.nickname, a.nickname,
sub2.itemPackingTypeConcat, sub2.itemPackingTypeConcat,
est.code est.code,
es.isScanned
FROM expedition e FROM expedition e
JOIN ticket t ON t.id = e.ticketFk JOIN ticket t ON t.id = e.ticketFk
JOIN ticketState ts ON ts.ticketFk = e.ticketFk JOIN ticketState ts ON ts.ticketFk = e.ticketFk
@ -33,6 +34,10 @@ BEGIN
GROUP BY sub.ticketFk GROUP BY sub.ticketFk
) sub2 ON sub2.ticketFk = t.id ) sub2 ON sub2.ticketFk = t.id
LEFT JOIN expeditionStateType est ON est.id = e.stateTypeFk LEFT JOIN expeditionStateType est ON est.id = e.stateTypeFk
LEFT JOIN expeditionState es ON es.id = (
SELECT MAX(id)
FROM expeditionState es
WHERE expeditionFk = e.id)
WHERE t.routeFk = vRouteFk AND e.freightItemFk <> FALSE WHERE t.routeFk = vRouteFk AND e.freightItemFk <> FALSE
ORDER BY r.created, t.priority DESC; ORDER BY r.created, t.priority DESC;
END$$ END$$

View File

@ -50,7 +50,7 @@ BEGIN
LEFT JOIN vn.route r ON r.id = t.routeFk LEFT JOIN vn.route r ON r.id = t.routeFk
LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id
LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk
WHERE e.id = vExpeditionFk; WHERE e.id = vExpeditionFk;
END$$ END$$

View File

@ -1,7 +1,17 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_booking`(vSelf INT) CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_booking`(
vSelf INT,
vBookNumber INT
)
BEGIN BEGIN
DECLARE vBookNumber INT; /**
* Genera la contabilidad para una factura y la marca como contabilizada
* Cuadra el asiento generado en si encuentra problemas derivados
* de los calculos con decimales
*
* @param vSelf Id invoiceIn
* @param vBookEntry Id de asiento, si es NULL se genera uno nuevo
*/
DECLARE vFiscalYear INT; DECLARE vFiscalYear INT;
CREATE OR REPLACE TEMPORARY TABLE tInvoiceIn CREATE OR REPLACE TEMPORARY TABLE tInvoiceIn
@ -58,7 +68,10 @@ BEGIN
WHERE ii.id = vSelf; WHERE ii.id = vSelf;
SELECT YEAR(bookEntried) INTO vFiscalYear FROM tInvoiceIn LIMIT 1; SELECT YEAR(bookEntried) INTO vFiscalYear FROM tInvoiceIn LIMIT 1;
CALL ledger_next(vFiscalYear, vBookNumber);
IF vBookNumber IS NULL THEN
CALL ledger_nextTx(vFiscalYear, vBookNumber);
END IF;
-- Apunte del proveedor -- Apunte del proveedor
INSERT INTO XDiario( INSERT INTO XDiario(
@ -187,7 +200,7 @@ BEGIN
LEFT JOIN ( LEFT JOIN (
SELECT e.id SELECT e.id
FROM tInvoiceIn tii FROM tInvoiceIn tii
JOIN expense e ON e.id = tii.expenseFk JOIN expense e ON e.id = tii.expenseFk
WHERE e.isWithheld WHERE e.isWithheld
LIMIT 1 LIMIT 1
) eWithheld ON TRUE ) eWithheld ON TRUE

View File

@ -61,7 +61,7 @@ BEGIN
WHERE io.id = vInvoice; WHERE io.id = vInvoice;
SELECT YEAR(FECHA) INTO vFiscalYear FROM rs LIMIT 1; SELECT YEAR(FECHA) INTO vFiscalYear FROM rs LIMIT 1;
CALL ledger_next(vFiscalYear, vBookNumber); CALL ledger_nextTx(vFiscalYear, vBookNumber);
-- Linea del cliente -- Linea del cliente
INSERT INTO XDiario( INSERT INTO XDiario(
ASIEN, ASIEN,

View File

@ -80,8 +80,8 @@ BEGIN
OR t.isDeleted OR t.isDeleted
OR c.hasToInvoice = FALSE OR c.hasToInvoice = FALSE
OR itc.id IS NULL OR itc.id IS NULL
OR a.id IS NULL OR a.id IS NULL
OR (vTaxArea = 'WORLD' OR (vTaxArea = 'WORLD'
AND (a.customsAgentFk IS NULL OR a.incotermsFk IS NULL)); AND (a.customsAgentFk IS NULL OR a.incotermsFk IS NULL));
SELECT SUM(s.quantity * s.price * (100 - s.discount)/100) <> 0 SELECT SUM(s.quantity * s.price * (100 - s.discount)/100) <> 0
@ -153,7 +153,9 @@ BEGIN
FROM tmp.ticketToInvoice ti FROM tmp.ticketToInvoice ti
LEFT JOIN ticketState ts ON ti.id = ts.ticketFk LEFT JOIN ticketState ts ON ti.id = ts.ticketFk
JOIN state s JOIN state s
WHERE IFNULL(ts.alertLevel, 0) < 3 and s.`code` = getAlert3State(ti.id); JOIN alertLevel al ON al.code = 'DELIVERED'
WHERE (ts.alertLevel IS NULL OR ts.alertLevel < al.id)
AND s.`code` = getAlert3State(ti.id);
INSERT INTO ticketTracking(stateFk, ticketFk, userFk) INSERT INTO ticketTracking(stateFk, ticketFk, userFk)
SELECT * FROM tmp.updateInter; SELECT * FROM tmp.updateInter;

View File

@ -18,11 +18,12 @@ BEGIN
JOIN vn.parking p ON p.id = sh.parkingFk JOIN vn.parking p ON p.id = sh.parkingFk
JOIN vn.sector sc ON sc.id = p.sectorFk JOIN vn.sector sc ON sc.id = p.sectorFk
JOIN vn.warehouse w ON w.id = sc.warehouseFk JOIN vn.warehouse w ON w.id = sc.warehouseFk
WHERE sc.id = vSectorFk WHERE ish.visible > 0
AND ish.visible > 0
AND ish.itemFk = vItemFk AND ish.itemFk = vItemFk
GROUP BY ish.id GROUP BY ish.id
ORDER BY sh.priority DESC, ORDER BY
(sc.id = vSectorFk) DESC,
sh.priority DESC,
ish.created, ish.created,
p.pickingOrder; p.pickingOrder;
END$$ END$$

View File

@ -49,7 +49,7 @@ BEGIN
ish.isChecked, ish.isChecked,
sub.isAllChecked sub.isAllChecked
FROM itemShelvingStock iss FROM itemShelvingStock iss
JOIN itemShelving ish ON ish.shelvingFk = iss.shelvingFk JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
LEFT JOIN ( LEFT JOIN (
SELECT itemFk, SELECT itemFk,
IF( IF(

View File

@ -17,13 +17,15 @@ BEGIN
SELECT SELECT
itemFk, itemFk,
packing, packing,
created created,
buyFk
FROM itemShelving FROM itemShelving
WHERE id = vItemShelvingFk WHERE id = vItemShelvingFk
) ish2 ) ish2
ON ish2.itemFk = ish.itemFk ON ish2.itemFk = ish.itemFk
AND ish2.packing = ish.packing AND ish2.packing = ish.packing
AND date(ish2.created) = date(ish.created) AND date(ish2.created) = date(ish.created)
AND ish2.buyFk = ish.buyFk
WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci; WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci;
IF vNewItemShelvingFk THEN IF vNewItemShelvingFk THEN

View File

@ -2,7 +2,6 @@ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT) CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT)
BEGIN BEGIN
/** /**
* Añade registro o lo actualiza si ya existe. * Añade registro o lo actualiza si ya existe.
* *
@ -15,11 +14,23 @@ BEGIN
* @param vWarehouseFk indica el sector * @param vWarehouseFk indica el sector
* *
**/ **/
DECLARE vItemFk INT; DECLARE vItemFk INT;
DECLARE vBuyFk INT;
SELECT id INTO vBuyFk
FROM buy WHERE id = vBarcode;
SELECT barcodeToItem(vBarcode) INTO vItemFk; SELECT barcodeToItem(vBarcode) INTO vItemFk;
IF vBuyFk IS NULL THEN
CALL cache.last_buy_refresh(FALSE);
SELECT buy_id INTO vBuyFk
FROM cache.last_buy
WHERE item_id = vItemFk
AND warehouse_id = vWarehouseFk;
END IF;
IF vPacking IS NULL IF vPacking IS NULL
THEN THEN
SET vPacking = itemPacking(vBarcode, vWarehouseFk); SET vPacking = itemPacking(vBarcode, vWarehouseFk);
@ -29,31 +40,32 @@ BEGIN
IF (SELECT COUNT(*) FROM itemShelving IF (SELECT COUNT(*) FROM itemShelving
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
AND itemFk = vItemFk AND itemFk = vItemFk
AND packing = vPacking) = 1 THEN AND packing = vPacking
AND buyFk = vBuyFk) THEN
UPDATE itemShelving UPDATE itemShelving
SET visible = visible+vQuantity SET visible = visible + vQuantity
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking; WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking;
ELSE ELSE
CALL cache.last_buy_refresh(FALSE);
INSERT INTO itemShelving( itemFk,
shelvingFk,
visible,
grouping,
packing,
packagingFk)
SELECT vItemFk, INSERT INTO itemShelving(
vShelvingFk, itemFk,
vQuantity, shelvingFk,
IFNULL(vGrouping, b.grouping), visible,
IFNULL(vPacking, b.packing), grouping,
IFNULL(vPackagingFk, b.packagingFk) packing,
FROM item i packagingFk,
LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk buyFk)
LEFT JOIN buy b ON b.id = lb.buy_id SELECT vItemFk,
WHERE i.id = vItemFk; vShelvingFk,
vQuantity,
IFNULL(vGrouping, b.grouping),
IFNULL(vPacking, b.packing),
IFNULL(vPackagingFk, b.packagingFk),
id
FROM buy b
WHERE id = vBuyFk;
END IF; END IF;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -0,0 +1,55 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_getItemDetails`(
vBarcodeItem INT,
vShelvingFK VARCHAR(10)
)
BEGIN
/**
* Obtiene el precio y visible de un item
*
* @param vBarcodeItem barcode de artículo
* @param vShelvingFK Ubicación actual del artículo
*/
DECLARE vIsItem BOOL;
DECLARE vBuyFk INT;
DECLARE vWarehouseFk INT;
SELECT COUNT(*) > 0 INTO vIsItem
FROM item
WHERE id = vBarcodeItem;
IF vIsItem THEN
SELECT warehouseFk INTO vWarehouseFk
FROM operator
WHERE workerFk = account.myUser_getId();
CALL buyUltimate(vWarehouseFk, util.VN_CURDATE());
SELECT buyFk INTO vBuyFk
FROM tmp.buyUltimate
WHERE itemFk = vBarcodeItem
AND warehouseFk = vWarehouseFk;
DELETE FROM tmp.buyUltimate;
ELSE
SELECT vBarcodeItem INTO vBuyFk;
END IF;
WITH visible AS(
SELECT itemFk,
IFNULL(buyingValue, 0) +
IFNULL(freightValue, 0) +
IFNULL(comissionValue, 0) +
IFNULL(packageValue, 0) itemCost
FROM vn.buy b
WHERE b.id = vBuyFk
) SELECT v.itemFk,
vShelvingFK,
v.itemCost,
SUM(ish.visible) visible
FROM vn.itemShelving ish
JOIN visible v
WHERE ish.shelvingFK = vShelvingFK COLLATE utf8mb3_general_ci
AND ish.itemFk = v.itemFk;
END$$
DELIMITER ;

View File

@ -6,7 +6,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_comparative`(
vAvailableSince DATE, vAvailableSince DATE,
vBuyerFk INT, vBuyerFk INT,
vIsFloramondo BOOL, vIsFloramondo BOOL,
vCountryFk INT vCountryFk INT
) )
proc: BEGIN proc: BEGIN
/** /**
@ -23,7 +23,6 @@ proc: BEGIN
* @param tmp.comparativeFilterType(filterFk INT ,itemTypeFk INT) * @param tmp.comparativeFilterType(filterFk INT ,itemTypeFk INT)
* @return tmp.comparative * @return tmp.comparative
*/ */
DECLARE vDayRangeStart DATE; DECLARE vDayRangeStart DATE;
DECLARE vDayRangeEnd DATE; DECLARE vDayRangeEnd DATE;
DECLARE w1, w2, w3, w4, w5, w6, w7 INT; DECLARE w1, w2, w3, w4, w5, w6, w7 INT;
@ -59,14 +58,14 @@ proc: BEGIN
END IF; END IF;
SELECT MIN(dated) INTO vDayRangeStart SELECT MIN(dated) INTO vDayRangeStart
FROM vn.time FROM `time`
WHERE dated <= vDate WHERE dated <= vDate
GROUP BY period GROUP BY period
ORDER BY dated desc ORDER BY dated desc
LIMIT 1 OFFSET vWeekRange; LIMIT 1 OFFSET vWeekRange;
SELECT MAX(dated) INTO vDayRangeEnd SELECT MAX(dated) INTO vDayRangeEnd
FROM vn.time FROM `time`
WHERE dated >= vDate WHERE dated >= vDate
GROUP BY period GROUP BY period
ORDER BY dated ASC ORDER BY dated ASC
@ -83,12 +82,11 @@ proc: BEGIN
JOIN itemType t ON t.id = i.typeFk JOIN itemType t ON t.id = i.typeFk
JOIN itemCategory c ON c.id = t.categoryFk JOIN itemCategory c ON c.id = t.categoryFk
LEFT JOIN worker w ON w.id = t.workerFk LEFT JOIN worker w ON w.id = t.workerFk
WHERE (NOT vHasTypeFilter WHERE (NOT vHasTypeFilter OR t.id IN (
OR t.id IN (SELECT itemTypeFk FROM tmp.comparativeFilterType)) SELECT itemTypeFk FROM tmp.comparativeFilterType
AND (vBuyerFk IS NULL ))
OR t.workerFk = vBuyerFk) AND (vBuyerFk IS NULL OR t.workerFk = vBuyerFk)
AND (vIsFloramondo IS NULL AND (vIsFloramondo IS NULL OR i.isFloramondo = vIsFloramondo);
OR i.isFloramondo = vIsFloramondo);
IF vDate < util.VN_CURDATE() THEN IF vDate < util.VN_CURDATE() THEN
ALTER TABLE tmp.itemInventory ALTER TABLE tmp.itemInventory
@ -115,10 +113,11 @@ proc: BEGIN
SET i = i + 1; SET i = i + 1;
SELECT t.period INTO vPeriod SELECT t.period INTO vPeriod
FROM vn.`time` t FROM `time` t
WHERE t.dated = vDayRangeStart + INTERVAL (vWeekCount * (i - 1)) DAY; WHERE t.dated = vDayRangeStart + INTERVAL (vWeekCount * (i - 1)) DAY;
INSERT IGNORE INTO tTable(cy, ly, zy) VALUES(vPeriod, vPeriod - 100, vPeriod - 200); INSERT IGNORE INTO tTable(cy, ly, zy)
VALUES(vPeriod, vPeriod - 100, vPeriod - 200);
UNTIL i = vWeekCount END REPEAT; UNTIL i = vWeekCount END REPEAT;
SELECT cy, ly, zy INTO w1, y1, z1 FROM tTable LIMIT 1; SELECT cy, ly, zy INTO w1, y1, z1 FROM tTable LIMIT 1;
@ -130,7 +129,6 @@ proc: BEGIN
SELECT cy, ly, zy INTO w7, y7, z7 FROM tTable WHERE cy > w6 LIMIT 1; SELECT cy, ly, zy INTO w7, y7, z7 FROM tTable WHERE cy > w6 LIMIT 1;
-- Genera una tabla con los datos del año pasado. -- Genera una tabla con los datos del año pasado.
CREATE OR REPLACE TEMPORARY TABLE tLastYear CREATE OR REPLACE TEMPORARY TABLE tLastYear
(KEY (lItemFk)) (KEY (lItemFk))
ENGINE = MEMORY ENGINE = MEMORY
@ -151,15 +149,14 @@ proc: BEGIN
SUM(IF(c.timePeriod = y7, c.price, 0)) lprice7 SUM(IF(c.timePeriod = y7, c.price, 0)) lprice7
FROM tmp.itemInventory ai FROM tmp.itemInventory ai
JOIN comparative c ON c.itemFk = ai.id JOIN comparative c ON c.itemFk = ai.id
JOIN warehouse w on w.id = c.warehouseFk JOIN warehouse w ON w.id = c.warehouseFk
JOIN tTable wt ON c.timePeriod = wt.ly JOIN tTable wt ON c.timePeriod = wt.ly
WHERE IFNULL(vWarehouseFk, c.warehouseFk) = c.warehouseFk WHERE (vWarehouseFk IS NULL OR vWarehouseFk = c.warehouseFk)
AND w.isComparative AND w.isComparative
AND (vCountryFk IS NULL OR c.countryFk = vCountryFk) AND (vCountryFk IS NULL OR c.countryFk = vCountryFk)
GROUP BY ai.id; GROUP BY ai.id;
-- Genera una tabla con los datos de hace DOS años. -- Genera una tabla con los datos de hace 2 años
CREATE OR REPLACE TEMPORARY TABLE tTwoYearsAgo CREATE OR REPLACE TEMPORARY TABLE tTwoYearsAgo
(KEY (tItemFk)) (KEY (tItemFk))
ENGINE = MEMORY ENGINE = MEMORY
@ -180,73 +177,72 @@ proc: BEGIN
SUM(IF(c.timePeriod = z7, c.price, 0)) vlprice7 SUM(IF(c.timePeriod = z7, c.price, 0)) vlprice7
FROM tmp.itemInventory ai FROM tmp.itemInventory ai
JOIN comparative c ON c.itemFk = ai.id JOIN comparative c ON c.itemFk = ai.id
JOIN warehouse w on w.id = c.warehouseFk JOIN warehouse w ON w.id = c.warehouseFk
JOIN tTable wt ON c.timePeriod = wt.zy JOIN tTable wt ON c.timePeriod = wt.zy
WHERE IFNULL(vWarehouseFk, c.warehouseFk) = c.warehouseFk WHERE (vWarehouseFk IS NULL OR vWarehouseFk = c.warehouseFk)
AND w.isComparative AND w.isComparative
AND (vCountryFk IS NULL OR c.countryFk = vCountryFk) AND (vCountryFk IS NULL OR c.countryFk = vCountryFk)
GROUP BY ai.id; GROUP BY ai.id;
-- Genera una tabla con los datos de este año.ss -- Genera una tabla con los datos de este año
CREATE OR REPLACE TEMPORARY TABLE tCurrentYear CREATE OR REPLACE TEMPORARY TABLE tCurrentYear
(KEY (cItemFk)) (KEY (cItemFk))
ENGINE = MEMORY ENGINE = MEMORY
SELECT t.itemFk cItemFk, SELECT t.itemFk cItemFk,
SUM(IF(week = w1, total, 0)) cweek1, SUM(IF(`week` = w1, total, 0)) cweek1,
SUM(IF(week = w2, total, 0)) cweek2, SUM(IF(`week` = w2, total, 0)) cweek2,
SUM(IF(week = w3, total, 0)) cweek3, SUM(IF(`week` = w3, total, 0)) cweek3,
SUM(IF(week = w4, total, 0)) cweek4, SUM(IF(`week` = w4, total, 0)) cweek4,
SUM(IF(week = w5, total, 0)) cweek5, SUM(IF(`week` = w5, total, 0)) cweek5,
SUM(IF(week = w6, total, 0)) cweek6, SUM(IF(`week` = w6, total, 0)) cweek6,
SUM(IF(week = w7, total, 0)) cweek7, SUM(IF(`week` = w7, total, 0)) cweek7,
SUM(IF(week = w1, price, 0)) cprice1, SUM(IF(`week` = w1, price, 0)) cprice1,
SUM(IF(week = w2, price, 0)) cprice2, SUM(IF(`week` = w2, price, 0)) cprice2,
SUM(IF(week = w3, price, 0)) cprice3, SUM(IF(`week` = w3, price, 0)) cprice3,
SUM(IF(week = w4, price, 0)) cprice4, SUM(IF(`week` = w4, price, 0)) cprice4,
SUM(IF(week = w5, price, 0)) cprice5, SUM(IF(`week` = w5, price, 0)) cprice5,
SUM(IF(week = w6, price, 0)) cprice6, SUM(IF(`week` = w6, price, 0)) cprice6,
SUM(IF(week = w7, price, 0)) cprice7 SUM(IF(`week` = w7, price, 0)) cprice7
FROM ( FROM (
SELECT s.itemFk, SELECT s.itemFk,
ti.period `week`, ti.period `week`,
SUM(s.quantity) total, SUM(s.quantity) total,
TRUNCATE(SUM(s.quantity * s.priceFixed),0) price TRUNCATE(SUM(s.quantity * s.priceFixed), 0) price
FROM ticket t FROM ticket t FORCE INDEX (Fecha)
JOIN sale s ON t.id = s.ticketFk JOIN sale s ON t.id = s.ticketFk
JOIN tmp.itemInventory it ON it.id = s.itemFk JOIN tmp.itemInventory it ON it.id = s.itemFk
JOIN time ti ON ti.dated = DATE(t.shipped) JOIN `time` ti ON ti.dated = DATE(t.shipped)
JOIN item i ON i.id = s.itemFk JOIN item i ON i.id = s.itemFk
JOIN itemType tp ON tp.id = i.typeFk JOIN itemType tp ON tp.id = i.typeFk
JOIN itemCategory ic ON ic.id = tp.categoryFk JOIN itemCategory ic ON ic.id = tp.categoryFk
JOIN warehouse w ON w.id = t.warehouseFk JOIN warehouse w ON w.id = t.warehouseFk
STRAIGHT_JOIN address ad ON ad.id = t.addressFk JOIN `address` ad ON ad.id = t.addressFk
JOIN province p ON p.id = ad.provinceFk JOIN province p ON p.id = ad.provinceFk
JOIN `client` c ON c.id = ad.clientFk JOIN `client` c ON c.id = ad.clientFk
WHERE t.shipped BETWEEN vDayRangeStart AND util.dayEnd(vDayRangeEnd) WHERE t.shipped BETWEEN vDayRangeStart AND util.dayEnd(vDayRangeEnd)
AND c.typeFk IN ('Normal','handMaking') AND c.typeFk IN ('normal', 'handMaking')
AND w.id = COALESCE(vWarehouseFk, w.id) AND (vWarehouseFk IS NULL OR vWarehouseFk = w.id)
AND (vCountryFk IS NULL OR p.countryFk = vCountryFk)
AND w.isComparative AND w.isComparative
AND (vCountryFk IS NULL OR p.countryFk = vCountryFk) GROUP BY i.id, `week`
GROUP BY i.id, week
) t ) t
GROUP BY t.itemFk; GROUP BY t.itemFk;
-- Genera la tabla con la comparativa. -- Genera la tabla con la comparativa
CREATE OR REPLACE TEMPORARY TABLE tmp.comparative CREATE OR REPLACE TEMPORARY TABLE tmp.comparative
ENGINE = MEMORY ENGINE = MEMORY
SELECT it.subName productor, SELECT it.subName productor,
b.packing, b.packing,
b.buyingValue costefijo, b.buyingValue costefijo,
b.groupingMode caja, b.groupingMode caja,
it.image ArticleImage, it.image ArticleImage,
IFNULL(it.inkFk,"?") color, IFNULL(it.inkFk, '?') color,
tp.code tipo, tp.code tipo,
it.typeFk tipo_id, it.typeFk tipo_id,
o.code origen, o.code origen,
it.category categoria, it.category categoria,
it.stems tallos, it.stems tallos,
it.size medida, it.`size` medida,
it.name article, it.name article,
w.code codigoTrabajador, w.code codigoTrabajador,
tp.categoryFk reino_id, tp.categoryFk reino_id,
@ -257,24 +253,27 @@ proc: BEGIN
it.id Id_Article, it.id Id_Article,
i.buy_id, i.buy_id,
tp.life, tp.life,
IFNULL(i.sd,0) sd, IFNULL(i.sd, 0) sd,
i.avalaible, i.avalaible,
i.visible, i.visible,
i.buy_date, i.buy_date,
e.id provider_id, e.id provider_id,
it.comment comments, it.comment comments,
it.description itemDescription, it.description itemDescription,
IF(cy.cItemFk IS NULL AND i.visible = 0 AND i.avalaible = 0 IF(cy.cItemFk IS NULL AND i.visible = 0
AND IFNULL(i.sd, 0) = 0, FALSE, TRUE) filtret, AND i.avalaible = 0 AND (i.sd IS NULL OR i.sd = 0),
FALSE,
TRUE
) filtret,
IF(it.hasMinPrice, FORMAT(it.minPrice, 2), "") pvp, IF(it.hasMinPrice, FORMAT(it.minPrice, 2), "") pvp,
s.company_name s.company_name
FROM tmp.itemInventory i FROM tmp.itemInventory i
JOIN item it ON it.id = i.id JOIN item it ON it.id = i.id
LEFT JOIN itemType tp ON tp.id = it.typeFk JOIN itemType tp ON tp.id = it.typeFk
LEFT JOIN worker w ON w.id = tp.workerFk JOIN worker w ON w.id = tp.workerFk
LEFT JOIN buy b ON b.id = i.buy_id LEFT JOIN buy b ON b.id = i.buy_id
LEFT JOIN entry e ON e.id = b.entryFk LEFT JOIN `entry` e ON e.id = b.entryFk
LEFT JOIN origin o ON o.id = it.originFk JOIN origin o ON o.id = it.originFk
LEFT JOIN tLastYear ly ON ly.lItemFk = it.id LEFT JOIN tLastYear ly ON ly.lItemFk = it.id
LEFT JOIN tCurrentYear cy ON cy.cItemFk = it.id LEFT JOIN tCurrentYear cy ON cy.cItemFk = it.id
LEFT JOIN tTwoYearsAgo zy ON zy.tItemFk = it.id LEFT JOIN tTwoYearsAgo zy ON zy.tItemFk = it.id
@ -287,8 +286,8 @@ proc: BEGIN
OR ly.lweek1 OR ly.lweek2 OR ly.lweek3 OR ly.lweek4 OR ly.lweek5 OR ly.lweek6 OR ly.lweek7 OR ly.lweek1 OR ly.lweek2 OR ly.lweek3 OR ly.lweek4 OR ly.lweek5 OR ly.lweek6 OR ly.lweek7
OR zy.vlweek1 OR zy.vlweek2 OR zy.vlweek3 OR zy.vlweek4 OR zy.vlweek5 OR zy.vlweek6 OR zy.vlweek7; OR zy.vlweek1 OR zy.vlweek2 OR zy.vlweek3 OR zy.vlweek4 OR zy.vlweek5 OR zy.vlweek6 OR zy.vlweek7;
-- Elimina las tablas temporales creadas... DROP TEMPORARY TABLE IF EXISTS
DROP TEMPORARY TABLE IF EXISTS tmp.itemInventory, tmp.itemInventory,
tTwoYearsAgo, tTwoYearsAgo,
tLastYear, tLastYear,
tCurrentYear, tCurrentYear,

View File

@ -0,0 +1,408 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_devalueA2`(
vSelf INT,
vShelvingFK VARCHAR(10),
vBuyingValue DECIMAL(10,4),
vQuantity INT
)
BEGIN
/**
* Devalua un item modificando su calidad de A1 a A2.
* Si no existe el item A2 lo crea y genera los movimientos de las entradas
* de almacén y shelvings correspondientes
*
* @param vSelf Id de artículo a devaluar
* @param vShelvingFK Ubicación actual del artículo
* @param vBuyingValue Nuevo precio de coste
* @param vQuantity Cantidad del ítem a pasar a A2
*/
DECLARE vItemA2Fk INT;
DECLARE vLastBuyFk BIGINT;
DECLARE vA1BuyFk INT;
DECLARE vA2BuyFk INT;
DECLARE vTargetEntryFk INT;
DECLARE vTargetEntryDate DATE;
DECLARE vTargetItemShelvingFk BIGINT;
DECLARE vWarehouseFk INT;
DECLARE vCacheFk INT;
DECLARE vLastEntryFk INT;
DECLARE vCurrentVisible INT;
DECLARE vDevalueTravelFk INT;
DECLARE vCurdate DATE;
DECLARE vBuyingValueOriginal DECIMAL(10,4);
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
RESIGNAL;
END;
IF (SELECT TRUE FROM item WHERE id = vSelf AND (category <> 'A1' OR category IS NULL)) THEN
CALL util.throw('Item has not category A1');
END IF;
SELECT warehouseFk INTO vWarehouseFk
FROM userConfig
WHERE userFk = account.myUser_getId();
IF NOT vWarehouseFk OR vWarehouseFk IS NULL THEN
CALL util.throw ('Operator has not a valid warehouse');
END IF;
IF vQuantity <= 0 OR vQuantity IS NULL THEN
CALL util.throw ('The quantity is incorrect');
END IF;
SELECT util.VN_CURDATE() INTO vCurdate;
SELECT t.id INTO vDevalueTravelFk
FROM travel t
JOIN travelConfig tc
WHERE t.shipped = vCurdate
AND t.landed = vCurdate
AND t.warehouseInFk = vWarehouseFk
AND t.warehouseOutFk = tc.devalueWarehouseOutFk
AND t.agencyModeFk = tc.devalueAgencyModeFk
LIMIT 1;
IF NOT vDevalueTravelFk OR vDevalueTravelFk IS NULL THEN
INSERT INTO travel (
shipped,
landed,
warehouseInFk,
warehouseOutFk,
`ref`,
isReceived,
agencyModeFk)
SELECT vCurdate,
vCurdate,
vWarehouseFk,
tc.devalueWarehouseOutFk,
tc.devalueRef,
TRUE,
tc.devalueAgencyModeFk
FROM travelConfig tc;
SET vDevalueTravelFk = LAST_INSERT_ID();
END IF;
SELECT id, DATE(dated) INTO vTargetEntryFk, vTargetEntryDate
FROM `entry` e
WHERE DATE(dated) = vCurdate
AND typeFk = 'devaluation'
AND travelFk = vDevalueTravelFk
ORDER BY created DESC
LIMIT 1;
CALL buyUltimate(vWarehouseFk, vCurdate);
SELECT b.entryFk, bu.buyFk,IFNULL(b.buyingValue, 0) INTO vLastEntryFk, vLastBuyFk, vBuyingValueOriginal
FROM tmp.buyUltimate bu
JOIN vn.buy b ON b.id = bu.buyFk
WHERE bu.itemFk = vSelf
AND bu.warehouseFk = vWarehouseFk;
IF vBuyingValue > vBuyingValueOriginal THEN
CALL util.throw ('Price not valid');
END IF;
IF vLastEntryFk IS NULL OR vLastBuyFk IS NULL THEN
CALL util.throw ('The item has not a buy');
END IF;
SELECT id,visible INTO vTargetItemShelvingFk, vCurrentVisible
FROM itemShelving
WHERE shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci
AND itemFk = vSelf
LIMIT 1;
IF vCurrentVisible IS NULL THEN
CALL util.throw ('The shelving has not a visible for this item');
END IF;
IF vQuantity > vCurrentVisible THEN
CALL util.throw('Quantity is greater than visible');
END IF;
START TRANSACTION;
IF NOT vTargetEntryFk OR vTargetEntryFk IS NULL
OR NOT vTargetEntryDate <=> vCurdate THEN
INSERT INTO entry(
travelFk,
supplierFk,
dated,
commission,
currencyFk,
companyFk,
clonedFrom,
typeFk
)
SELECT vDevalueTravelFk,
supplierFk,
vCurdate,
commission,
currencyFk,
companyFk,
vLastEntryFk,
'devaluation'
FROM entry
WHERE id = vLastEntryFk;
SET vTargetEntryFk = LAST_INSERT_ID();
END IF;
SELECT i.id INTO vItemA2Fk
FROM item i
JOIN (
SELECT i.id,
i.name,
i.subname,
i.value5,
i.value6,
i.value7,
i.value8,
i.value9,
i.value10,
i.NumberOfItemsPerCask,
i.EmbalageCode,
i.quality
FROM item i
WHERE i.id = vSelf
)i2 ON i2.name <=> i.name
AND i2.subname <=> i.subname
AND i2.value5 <=> i.value5
AND i2.value6 <=> i.value6
AND i2.value8 <=> i.value8
AND i2.value9 <=> i.value9
AND i2.value10 <=> i.value10
AND i2.NumberOfItemsPerCask <=> i.NumberOfItemsPerCask
AND i2.EmbalageCode <=> i.EmbalageCode
AND i2.quality <=> i.quality
WHERE i.id <> i2.id
AND i.category = 'A2'
LIMIT 1;
IF vItemA2Fk IS NULL THEN
INSERT INTO item (
equivalent,
name,
`size`,
stems,
minPrice,
isToPrint,
family,
box,
category,
originFk,
doPhoto,
image,
inkFk,
intrastatFk,
hasMinPrice,
created,
comment,
typeFk,
generic,
producerFk,
description,
density,
relevancy,
expenseFk,
isActive,
longName,
subName,
minimum,
upToDown,
supplyResponseFk,
hasKgPrice,
isFloramondo,
isFragile,
numberOfItemsPerCask,
embalageCode,
quality,
stemMultiplier,
itemPackingTypeFk,
packingOut,
genericFk,
isLaid,
lastUsed,
weightByPiece,
editorFk,
recycledPlastic,
nonRecycledPlastic)
SELECT equivalent,
name,
`size`,
stems,
minPrice,
isToPrint,
family,
box,
'A2',
originFk,
doPhoto,
image,
inkFk,
intrastatFk,
hasMinPrice,
created,
comment,
typeFk,
generic,
producerFk,
description,
density,
relevancy,
expenseFk,
isActive,
longName,
subName,
minimum,
upToDown,
supplyResponseFk,
hasKgPrice,
isFloramondo,
isFragile,
numberOfItemsPerCask,
embalageCode,
quality,
stemMultiplier,
itemPackingTypeFk,
packingOut,
genericFk,
isLaid,
lastUsed,
weightByPiece,
editorFk,
recycledPlastic,
nonRecycledPlastic
FROM item
WHERE id = vSelf;
SET vItemA2Fk = LAST_INSERT_ID();
INSERT INTO itemTag (itemFk, tagFk, `value`, intValue, priority, editorFk)
SELECT vItemA2Fk, tagFk, `value`, intValue, priority, editorFk
FROM itemTag
WHERE id = vSelf;
UPDATE itemTaxCountry itc
JOIN itemTaxCountry itc2 ON itc2.itemFk = vSelf
AND itc2.countryFk = itc.countryFk
SET itc2.taxClassFk = itc.taxClassFk
WHERE itc.id = vItemA2Fk;
INSERT INTO itemBotanical (itemFk, genusFk, specieFk)
SELECT vItemA2Fk, genusFk, specieFk
FROM itemBotanical
WHERE itemFk = vSelf;
END IF;
IF vQuantity = vCurrentVisible THEN
DELETE FROM itemShelving
WHERE id = vTargetItemShelvingFk;
ELSE
UPDATE itemShelving
SET visible = vCurrentVisible - vQuantity
WHERE id = vTargetItemShelvingFk;
END IF;
INSERT INTO buy(
entryFk,
itemFk,
quantity,
buyingValue,
freightValue,
isIgnored,
stickers,
packagingFk,
packing,
`grouping`,
groupingMode,
comissionValue,
packageValue,
price1,
price2,
price3,
minPrice,
isChecked,
location,
weight,
itemOriginalFk)
SELECT vTargetEntryFk,
itemFk,
- LEAST(vQuantity, vCurrentVisible),
buyingValue,
freightValue,
TRUE,
stickers,
packagingFk,
packing,
`grouping`,
groupingMode,
comissionValue,
packageValue,
price1,
price2,
price3,
minPrice,
isChecked,
location,
weight,
itemOriginalFk
FROM vn.buy
WHERE id = vLastBuyFk
UNION
SELECT vTargetEntryFk,
vItemA2Fk,
vQuantity,
vBuyingValue,
freightValue,
TRUE,
stickers,
packagingFk,
packing,
`grouping`,
groupingMode,
comissionValue,
packageValue,
price1,
price2,
price3,
minPrice,
isChecked,
location,
weight,
itemOriginalFk
FROM vn.buy
WHERE id = vLastBuyFk;
INSERT IGNORE INTO itemShelving (
itemFk,
shelvingFk,
visible,
`grouping`,
packing,
packagingFk,
userFk,
isChecked)
SELECT vItemA2Fk,
shelvingFk,
vQuantity ,
`grouping`,
packing,
packagingFk,
account.myUser_getId(),
isChecked
FROM itemShelving
WHERE itemFK = vSelf
AND shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci
ON DUPLICATE KEY UPDATE
visible = vQuantity + VALUES(visible);
COMMIT;
CALL cache.visible_refresh(vCacheFk, TRUE, vWarehouseFk);
CALL cache.available_refresh(vCacheFk, TRUE, vWarehouseFk, vCurdate);
CALL buy_recalcPricesByBuy(vA2BuyFk);
END$$
DELIMITER ;

View File

@ -1,5 +1,7 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_ValuateInventory`(vDated DATE, vIsDetailed BOOLEAN) CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_valuateInventory`(
vDated DATE
)
BEGIN BEGIN
DECLARE vInventoried DATE; DECLARE vInventoried DATE;
DECLARE vHasNotInventory BOOLEAN DEFAULT FALSE; DECLARE vHasNotInventory BOOLEAN DEFAULT FALSE;
@ -15,8 +17,7 @@ BEGIN
SELECT tr.landed INTO vInventoried SELECT tr.landed INTO vInventoried
FROM travel tr FROM travel tr
JOIN `entry` e ON e.travelFk = tr.id JOIN `entry` e ON e.travelFk = tr.id
JOIN entryConfig ec WHERE tr.landed <= vDateDayEnd
WHERE landed <= vDateDayEnd
AND e.supplierFk = vInventorySupplierFk AND e.supplierFk = vInventorySupplierFk
ORDER BY tr.landed DESC ORDER BY tr.landed DESC
LIMIT 1; LIMIT 1;
@ -27,8 +28,7 @@ BEGIN
SELECT landed INTO vInventoryClone SELECT landed INTO vInventoryClone
FROM travel tr FROM travel tr
JOIN `entry` e ON e.travelFk = tr.id JOIN `entry` e ON e.travelFk = tr.id
JOIN entryConfig ec WHERE tr.landed >= vDated
WHERE landed >= vDated
AND e.supplierFk = vInventorySupplierFk AND e.supplierFk = vInventorySupplierFk
ORDER BY landed ASC ORDER BY landed ASC
LIMIT 1; LIMIT 1;
@ -38,13 +38,14 @@ BEGIN
END IF; END IF;
CREATE OR REPLACE TEMPORARY TABLE tInventory( CREATE OR REPLACE TEMPORARY TABLE tInventory(
warehouseFk SMALLINT, warehouseFk SMALLINT,
itemFk BIGINT, itemFk BIGINT,
quantity INT, quantity INT,
cost DOUBLE DEFAULT 0, volume DECIMAL(10,2),
total DOUBLE DEFAULT 0, cost DOUBLE DEFAULT 0,
warehouseInventory VARCHAR(20), total DOUBLE DEFAULT 0,
PRIMARY KEY (warehouseInventory, itemFk) USING HASH warehouseInventory VARCHAR(20),
PRIMARY KEY (warehouseInventory, itemFk) USING HASH
) )
ENGINE = MEMORY; ENGINE = MEMORY;
@ -60,9 +61,8 @@ BEGIN
JOIN `entry` e ON e.id = b.entryFk JOIN `entry` e ON e.id = b.entryFk
JOIN travel tr ON tr.id = e.travelFk JOIN travel tr ON tr.id = e.travelFk
JOIN itemType t ON t.id = i.typeFk JOIN itemType t ON t.id = i.typeFk
JOIN warehouse w ON w.id = warehouseInFk JOIN warehouse w ON w.id = tr.warehouseInFk
JOIN entryConfig ec WHERE tr.landed = vDateDayEnd
WHERE landed = vDateDayEnd
AND e.supplierFk = vInventorySupplierFk AND e.supplierFk = vInventorySupplierFk
AND w.valuatedInventory AND w.valuatedInventory
AND t.isInventory AND t.isInventory
@ -78,9 +78,8 @@ BEGIN
JOIN `entry` e ON e.id = b.entryFk JOIN `entry` e ON e.id = b.entryFk
JOIN travel tr ON tr.id = e.travelFk JOIN travel tr ON tr.id = e.travelFk
JOIN itemType t ON t.id = i.typeFk JOIN itemType t ON t.id = i.typeFk
JOIN warehouse w ON w.id = warehouseInFk JOIN warehouse w ON w.id = tr.warehouseInFk
JOIN entryConfig ec WHERE tr.landed = vInventoried
WHERE landed = vInventoried
AND e.supplierFk = vInventorySupplierFk AND e.supplierFk = vInventorySupplierFk
AND w.valuatedInventory AND w.valuatedInventory
AND t.isInventory AND t.isInventory
@ -99,7 +98,6 @@ BEGIN
JOIN travel tr ON tr.id = e.travelFk JOIN travel tr ON tr.id = e.travelFk
JOIN itemType t ON t.id = i.typeFk JOIN itemType t ON t.id = i.typeFk
JOIN warehouse w ON w.id = tr.warehouseInFk JOIN warehouse w ON w.id = tr.warehouseInFk
JOIN entryConfig ec
WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd
AND IF(tr.landed = util.VN_CURDATE(), tr.isReceived, TRUE) AND IF(tr.landed = util.VN_CURDATE(), tr.isReceived, TRUE)
AND NOT e.isRaid AND NOT e.isRaid
@ -183,52 +181,37 @@ BEGIN
AND e.isConfirmed AND e.isConfirmed
ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity); ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity);
CALL vn.buyUltimate(NULL, vDateDayEnd); CALL buyUltimate(NULL, vDateDayEnd);
DELETE FROM tInventory WHERE quantity IS NULL OR NOT quantity;
UPDATE tInventory i UPDATE tInventory i
JOIN tmp.buyUltimate bu ON i.warehouseFk = bu.warehouseFk AND i.itemFk = bu.itemFk JOIN tmp.buyUltimate bu ON i.warehouseFk = bu.warehouseFk AND i.itemFk = bu.itemFk
JOIN buy b ON b.id = bu.buyFk JOIN buy b ON b.id = bu.buyFk
SET total = i.quantity * (IFNULL(b.buyingValue, 0) + IFNULL(b.packageValue, 0) + IFNULL(b.freightValue, 0) + IFNULL(b.comissionValue, 0)), LEFT JOIN itemCost ic ON ic.itemFk = i.itemFk
cost = IFNULL(b.buyingValue, 0) + IFNULL(b.packageValue, 0) + IFNULL(b.freightValue, 0) + IFNULL(b.comissionValue, 0) AND ic.warehouseFk = i.warehouseFk
WHERE i.quantity; SET i.total = i.quantity * (IFNULL(b.buyingValue, 0) + IFNULL(b.packageValue, 0) + IFNULL(b.freightValue, 0) + IFNULL(b.comissionValue, 0)),
i.cost = IFNULL(b.buyingValue, 0) + IFNULL(b.packageValue, 0) + IFNULL(b.freightValue, 0) + IFNULL(b.comissionValue, 0),
i.volume = i.quantity * ic.cm3delivery / 1000000;
DELETE FROM tInventory SELECT ti.warehouseFk,
WHERE quantity IS NULL OR NOT quantity; i.id,
i.longName,
IF vIsDetailed THEN i.size,
SELECT ti.warehouseFk, ti.quantity,
i.id itemFk, ti.volume,
i.longName, tp.name itemTypeName,
i.size, ic.name itemCategoryName,
ti.quantity, ti.cost,
tp.name Tipo, ti.total,
ic.name Reino, ti.warehouseInventory
ti.cost, FROM tInventory ti
CAST(ti.total AS DECIMAL(10, 2)) total, JOIN warehouse w ON w.id = warehouseFk
ti.warehouseInventory almacen JOIN item i ON i.id = ti.itemFk
FROM tInventory ti JOIN itemType tp ON tp.id = i.typeFk
JOIN warehouse w ON w.id = warehouseFk JOIN itemCategory ic ON ic.id = tp.categoryFk
JOIN item i ON i.id = ti.itemFk WHERE w.valuatedInventory
JOIN itemType tp ON tp.id = i.typeFk AND ti.total > 0;
JOIN itemCategory ic ON ic.id = tp.categoryFk
WHERE w.valuatedInventory
AND ti.total > 0
ORDER BY ti.total DESC;
ELSE
SELECT i.warehouseInventory Almacen,
ic.name Reino,
CAST(i.total AS DECIMAL(10, 2)) Euros,
w.code Comprador,
it.id
FROM tInventory i
JOIN warehouse wh ON wh.id = warehouseFk
JOIN item it ON it.id = i.itemFk
JOIN itemType itp ON itp.id = it.typeFk
LEFT JOIN worker w ON w.id = itp.workerFk
JOIN itemCategory ic ON ic.id = itp.categoryFk
WHERE wh.valuatedInventory
AND i.total > 0;
END IF;
DROP TEMPORARY TABLE DROP TEMPORARY TABLE
tmp.buyUltimate, tmp.buyUltimate,

View File

@ -28,7 +28,7 @@ BEGIN
DECLARE vIsOriginalAClient BOOL; DECLARE vIsOriginalAClient BOOL;
DECLARE vPayMethodCompensation INT; DECLARE vPayMethodCompensation INT;
CALL ledger_next(YEAR(vDated), vNewBookEntry); CALL ledger_nextTx(YEAR(vDated), vNewBookEntry);
SELECT COUNT(id) INTO vIsOriginalAClient SELECT COUNT(id) INTO vIsOriginalAClient
FROM client FROM client

View File

@ -1,13 +1,35 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_next`( CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_next`(
IN vFiscalYear INT, IN vFiscalYear INT,
OUT vNewBookEntry INT OUT vLastBookEntry INT
) )
/**
* Devuelve un número de asiento válido, según el contador de asientos
* tabla vn.ledgerConfig, si no existe lo inicializa a 1
* No inicia transacción, para transaccionar usar vn.ledger_nextTx
*
* @param vFiscalYear Id del año contable
* @return vLastBookEntry Id del asiento
*/
BEGIN BEGIN
UPDATE ledgerCompany IF vFiscalYear IS NULL THEN
SET bookEntry = LAST_INSERT_ID(bookEntry + 1) CALL util.throw('Fiscal year is required');
WHERE fiscalYear = vFiscalYear; END IF;
SET vNewBookEntry = LAST_INSERT_ID(); SELECT bookEntry + 1 INTO vLastBookEntry
FROM ledgerCompany
WHERE fiscalYear = vFiscalYear
FOR UPDATE;
IF vLastBookEntry IS NULL THEN
INSERT INTO ledgerCompany
SET fiscalYear = vFiscalYear,
bookEntry = 1;
SET vLastBookEntry = 1;
END IF;
UPDATE ledgerCompany
SET bookEntry = vLastBookEntry
WHERE fiscalYear = vFiscalYear;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -0,0 +1,30 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_nextTx`(
IN vFiscalYear INT,
OUT vLastBookEntry INT
)
/**
* Devuelve un número de asiento válido, según el contador de asientos
* tabla vn.ledgerConfig, si no existe lo inicializa a 1
* Lo hace transaccionando el proceso
*
* @param vFiscalYear Id del año contable
* @return vLastBookEntry Id del asiento
*/
BEGIN
DECLARE vIsRequiredTx BOOL DEFAULT NOT @@in_transaction;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
CALL util.tx_rollback(vIsRequiredTx);
RESIGNAL;
END;
IF vFiscalYear IS NULL THEN
CALL util.throw('Fiscal year is required');
END IF;
CALL util.tx_start(vIsRequiredTx);
CALL ledger_next(vFiscalYear, vLastBookEntry);
CALL util.tx_commit(vIsRequiredTx);
END$$
DELIMITER ;

View File

@ -6,14 +6,16 @@ BEGIN
(PRIMARY KEY (ticketFk)) (PRIMARY KEY (ticketFk))
ENGINE = MEMORY ENGINE = MEMORY
SELECT t.id ticketFk, t.clientFk SELECT t.id ticketFk, t.clientFk
FROM vn.ticket t FROM ticket t
LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id JOIN alertLevel al ON al.code = 'DELIVERED'
JOIN vn.client c ON c.id = t.clientFk LEFT JOIN ticketState ts ON ts.ticketFk = t.id
JOIN client c ON c.id = t.clientFk
WHERE c.typeFk IN ('normal','handMaking','internalUse') WHERE c.typeFk IN ('normal','handMaking','internalUse')
AND ( AND (
t.shipped BETWEEN util.VN_CURDATE() AND vEndingDate t.shipped BETWEEN util.VN_CURDATE() AND vEndingDate
OR ( OR (
ts.alertLevel < 3 ts.alertLevel < al.id
AND t.shipped >= vStartingDate AND t.shipped >= vStartingDate
AND t.shipped < util.VN_CURDATE() AND t.shipped < util.VN_CURDATE()
) )

View File

@ -1,6 +1,6 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`productionControl`( CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`productionControl`(
vWarehouseFk INT, vWarehouseFk INT,
vScopeDays INT vScopeDays INT
) )
proc: BEGIN proc: BEGIN
@ -67,7 +67,7 @@ proc: BEGIN
wk.code salesPersonCode, wk.code salesPersonCode,
p.id provinceFk, p.id provinceFk,
tls.productionOrder, tls.productionOrder,
IFNULL(tls.alertLevel, 0) alertLevel, IFNULL(tls.alertLevel, al.id) alertLevel,
t.isBoxed palletized, t.isBoxed palletized,
IF(rm.isPickingAllowed, rm.bufferFk, NULL) ubicacion, IF(rm.isPickingAllowed, rm.bufferFk, NULL) ubicacion,
tlu.lastUpdated, tlu.lastUpdated,
@ -81,6 +81,7 @@ proc: BEGIN
rm.bufferFk rm.bufferFk
FROM tmp.productionTicket tt FROM tmp.productionTicket tt
JOIN ticket t ON tt.ticketFk = t.id JOIN ticket t ON tt.ticketFk = t.id
JOIN alertLevel al ON al.code = 'FREE'
LEFT JOIN ticketStateToday tst ON tst.ticketFk = t.id LEFT JOIN ticketStateToday tst ON tst.ticketFk = t.id
LEFT JOIN `state` st ON st.id = tst.state LEFT JOIN `state` st ON st.id = tst.state
LEFT JOIN client c ON c.id = t.clientFk LEFT JOIN client c ON c.id = t.clientFk
@ -101,7 +102,7 @@ proc: BEGIN
LEFT JOIN parking pk ON pk.id = tp.parkingFk LEFT JOIN parking pk ON pk.id = tp.parkingFk
WHERE t.warehouseFk = vWarehouseFk WHERE t.warehouseFk = vWarehouseFk
AND dm.code IN ('AGENCY', 'DELIVERY', 'PICKUP'); AND dm.code IN ('AGENCY', 'DELIVERY', 'PICKUP');
UPDATE tmp.productionBuffer pb UPDATE tmp.productionBuffer pb
JOIN ( JOIN (
SELECT pb.ticketFk, GROUP_CONCAT(p.code) previaParking SELECT pb.ticketFk, GROUP_CONCAT(p.code) previaParking
@ -109,12 +110,12 @@ proc: BEGIN
JOIN sale s ON s.ticketFk = pb.ticketFk JOIN sale s ON s.ticketFk = pb.ticketFk
JOIN saleGroupDetail sgd ON sgd.saleFk = s.id JOIN saleGroupDetail sgd ON sgd.saleFk = s.id
JOIN saleGroup sg ON sg.id = sgd.saleGroupFk JOIN saleGroup sg ON sg.id = sgd.saleGroupFk
JOIN parking p ON p.id = sg.parkingFk JOIN parking p ON p.id = sg.parkingFk
GROUP BY pb.ticketFk GROUP BY pb.ticketFk
) t ON t.ticketFk = pb.ticketFk ) t ON t.ticketFk = pb.ticketFk
SET pb.previaParking = t.previaParking; SET pb.previaParking = t.previaParking;
-- Problemas por ticket -- Problemas por ticket
ALTER TABLE tmp.productionBuffer ALTER TABLE tmp.productionBuffer
CHANGE COLUMN `problem` `problem` VARCHAR(255), CHANGE COLUMN `problem` `problem` VARCHAR(255),
ADD COLUMN `collectionH` INT, ADD COLUMN `collectionH` INT,
@ -145,13 +146,19 @@ proc: BEGIN
-- Líneas y volumen por ticket -- Líneas y volumen por ticket
UPDATE tmp.productionBuffer pb UPDATE tmp.productionBuffer pb
JOIN ( JOIN (
SELECT tt.ticketFk, SELECT tt.ticketFk,
COUNT(*) `lines`, COUNT(*) `lines`,
SUM(sv.volume) m3, SUM(s.quantity * ic.cm3delivery / 1000000) m3,
IFNULL(SUM(IF(sv.isPicked, sv.volume, 0)) / SUM(sv.volume), 0) rate IFNULL(SUM(IF(s.isPicked,
FROM tmp.productionTicket tt (s.quantity * ic.cm3delivery / 1000000),
JOIN saleVolume sv ON sv.ticketFk = tt.ticketFk 0)) / SUM(s.quantity * ic.cm3delivery / 1000000),
GROUP BY tt.ticketFk 0) rate
FROM tmp.productionTicket tt
JOIN sale s ON s.ticketFk = tt.ticketFk
AND s.quantity > 0
JOIN itemCost ic ON ic.itemFk = s.itemFk
AND ic.warehouseFk = vWarehouseFk
GROUP BY tt.ticketFk
) m ON m.ticketFk = pb.ticketFk ) m ON m.ticketFk = pb.ticketFk
SET pb.`lines` = m.`lines`, SET pb.`lines` = m.`lines`,
pb.m3 = m.m3, pb.m3 = m.m3,
@ -218,6 +225,8 @@ proc: BEGIN
AND ish.visible AND ish.visible
GROUP BY ish.itemFk, p.sectorFk; GROUP BY ish.itemFk, p.sectorFk;
CREATE INDEX idxItem ON tItemShelvingStock (itemFk);
INSERT INTO tmp.ticketWithPrevia(ticketFk, salesCount) INSERT INTO tmp.ticketWithPrevia(ticketFk, salesCount)
SELECT pb.ticketFk, COUNT(DISTINCT s.id) SELECT pb.ticketFk, COUNT(DISTINCT s.id)
FROM tmp.productionBuffer pb FROM tmp.productionBuffer pb

View File

@ -47,7 +47,7 @@ BEGIN
LEFT JOIN ticketTrolley tt ON tt.ticket = t.id LEFT JOIN ticketTrolley tt ON tt.ticket = t.id
LEFT JOIN zone zo ON t.zoneFk = zo.id LEFT JOIN zone zo ON t.zoneFk = zo.id
LEFT JOIN routesMonitor rm ON rm.routeFk = t.routeFk LEFT JOIN routesMonitor rm ON rm.routeFk = t.routeFk
LEFT JOIN roadmapStop rs ON rs.id = rm.expeditionTruckFk LEFT JOIN roadmapStop rs ON rs.id = rm.roadmapStopFk
WHERE IF(vIsCollection, tc.collectionFk = vParam, tc.ticketFk = vParam) WHERE IF(vIsCollection, tc.collectionFk = vParam, tc.ticketFk = vParam)
GROUP BY t.id GROUP BY t.id
ORDER BY cc.code; ORDER BY cc.code;

View File

@ -106,7 +106,7 @@ BEGIN
SET rm.m3boxes = sub.m3boxes; SET rm.m3boxes = sub.m3boxes;
UPDATE routesMonitor rm UPDATE routesMonitor rm
JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk
SET rm.etd = rs.eta; SET rm.etd = rs.eta;
DROP TEMPORARY TABLE tmp.routesMonitor; DROP TEMPORARY TABLE tmp.routesMonitor;

View File

@ -64,10 +64,15 @@ BEGIN
FROM tmp.sale_getProblems tp FROM tmp.sale_getProblems tp
JOIN ticket t ON t.id = tp.ticketFk JOIN ticket t ON t.id = tp.ticketFk
JOIN ( JOIN (
SELECT t.addressFk, SUM(sv.litros) litros, t.totalWithoutVat SELECT t.addressFk,
SUM(ROUND(`ic`.`cm3delivery` * `s`.`quantity` / 1000, 0)) litros,
t.totalWithoutVat
FROM tmp.ticket_list tl FROM tmp.ticket_list tl
JOIN saleVolume sv ON sv.ticketFk = tl.ticketFk
JOIN ticket t ON t.id = tl.ticketFk JOIN ticket t ON t.id = tl.ticketFk
JOIN sale s ON s.ticketFk = t.id
AND s.quantity > 0
JOIN itemCost ic ON ic.itemFk = s.itemFk
AND ic.warehouseFk = t.warehouseFk
JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk
AND zc.dated = util.VN_CURDATE() AND zc.dated = util.VN_CURDATE()
JOIN agencyMode am ON am.id = t.agencyModeFk JOIN agencyMode am ON am.id = t.agencyModeFk
@ -95,12 +100,12 @@ BEGIN
FROM ( FROM (
SELECT COUNT(s.id) nComp, tl.ticketFk, s.id saleFk SELECT COUNT(s.id) nComp, tl.ticketFk, s.id saleFk
FROM tmp.ticket_list tl FROM tmp.ticket_list tl
JOIN vn.sale s ON s.ticketFk = tl.ticketFk JOIN sale s ON s.ticketFk = tl.ticketFk
LEFT JOIN vn.saleComponent sc ON sc.saleFk = s.id LEFT JOIN saleComponent sc ON sc.saleFk = s.id
LEFT JOIN vn.component c ON c.id = sc.componentFk AND c.isRequired LEFT JOIN component c ON c.id = sc.componentFk AND c.isRequired
JOIN vn.ticket t ON t.id = tl.ticketFk JOIN ticket t ON t.id = tl.ticketFk
JOIN vn.agencyMode am ON am.id = t.agencyModeFk JOIN agencyMode am ON am.id = t.agencyModeFk
JOIN vn.deliveryMethod dm ON dm.id = am.deliveryMethodFk JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
WHERE dm.code IN ('AGENCY','DELIVERY','PICKUP') WHERE dm.code IN ('AGENCY','DELIVERY','PICKUP')
AND s.quantity > 0 AND s.quantity > 0
GROUP BY s.id GROUP BY s.id

View File

@ -12,12 +12,15 @@ BEGIN
CREATE OR REPLACE TEMPORARY TABLE tmp.sale CREATE OR REPLACE TEMPORARY TABLE tmp.sale
(INDEX(saleFk)) (INDEX(saleFk))
ENGINE = MEMORY ENGINE = MEMORY
SELECT s.id saleFk, sale_hasComponentLack(s.id) hasProblem SELECT saleFk, sale_hasComponentLack(saleFk)hasProblem
FROM ticket t FROM (
JOIN sale s ON s.ticketFk = t.id SELECT s.id saleFk
LEFT JOIN saleComponent sc ON sc.saleFk = s.id FROM ticket t
WHERE t.shipped >= util.midnight() JOIN sale s ON s.ticketFk = t.id
AND (vComponentFk IS NULL OR sc.componentFk = vComponentFk); LEFT JOIN saleComponent sc ON sc.saleFk = s.id
WHERE t.shipped >= util.VN_CURDATE()
AND (vComponentFk IS NULL OR sc.componentFk = vComponentFk)
GROUP BY s.id) sub;
CALL sale_setProblem('hasComponentLack'); CALL sale_setProblem('hasComponentLack');

Some files were not shown because too many files have changed in this diff Show More