Merge branch 'dev' into 7126-improvedWaste
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
commit
b9d04e9557
|
@ -1,3 +1,4 @@
|
|||
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
@ -12,6 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- (InvoiceOut -> Crear factura) Cuando falla al crear una factura, se devuelve un error
|
||||
- (Worker -> Ver albarán) Ya no aparece la página en blanco
|
||||
|
||||
### Changed
|
||||
- (InvoiceOut) Las facturas ahora muestran el ticket del cual proviene el abono
|
||||
|
||||
## [24.18.01] - 2024-05-07
|
||||
|
||||
## [24.16.01] - 2024-04-18
|
||||
|
|
|
@ -24,7 +24,7 @@ node {
|
|||
FROM_GIT = env.JOB_NAME.startsWith('gitea/')
|
||||
RUN_TESTS = !PROTECTED_BRANCH && FROM_GIT
|
||||
RUN_BUILD = PROTECTED_BRANCH && FROM_GIT
|
||||
// env.DEBUG = 'strong-remoting:shared-method'
|
||||
|
||||
// https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables
|
||||
echo "NODE_NAME: ${env.NODE_NAME}"
|
||||
echo "WORKSPACE: ${env.WORKSPACE}"
|
||||
|
@ -60,7 +60,6 @@ pipeline {
|
|||
}
|
||||
environment {
|
||||
PROJECT_NAME = 'salix'
|
||||
STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
|
||||
}
|
||||
stages {
|
||||
stage('Install') {
|
||||
|
@ -204,19 +203,23 @@ pipeline {
|
|||
sh 'npx myt push $NODE_ENV --force --commit'
|
||||
}
|
||||
}
|
||||
stage('Docker') {
|
||||
stage('Kubernetes') {
|
||||
when {
|
||||
expression { FROM_GIT }
|
||||
}
|
||||
environment {
|
||||
DOCKER_HOST = "${env.SWARM_HOST}"
|
||||
}
|
||||
steps {
|
||||
script {
|
||||
def packageJson = readJSON file: 'package.json'
|
||||
env.VERSION = packageJson.version
|
||||
}
|
||||
sh "docker stack deploy --with-registry-auth --compose-file docker-compose.yml ${env.STACK_NAME}"
|
||||
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'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
11
README.md
11
README.md
|
@ -11,11 +11,16 @@ Required applications.
|
|||
* Node.js
|
||||
* Docker
|
||||
* Git
|
||||
* MYT
|
||||
|
||||
You will need to install globally the following items.
|
||||
```
|
||||
$ 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
|
||||
|
||||
|
@ -54,6 +59,12 @@ For end-to-end tests run from project's root.
|
|||
$ npm run test:e2e
|
||||
```
|
||||
|
||||
## Generate changeLog test → master
|
||||
```
|
||||
$ bash changelog.sh
|
||||
```
|
||||
|
||||
|
||||
## Visual Studio Code extensions
|
||||
|
||||
Open Visual Studio Code, press Ctrl+P and paste the following commands.
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('sendCheckingPresence', {
|
||||
description: 'Creates a message in the chat model checking the user status',
|
||||
|
@ -37,7 +39,7 @@ module.exports = Self => {
|
|||
if (!recipient)
|
||||
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;
|
||||
|
||||
const chat = await models.Chat.create({
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
const axios = require('axios');
|
||||
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('sendQueued', {
|
||||
description: 'Send a RocketChat message',
|
||||
|
@ -94,7 +96,7 @@ module.exports = Self => {
|
|||
* @return {Promise} - The request promise
|
||||
*/
|
||||
Self.sendMessage = async function sendMessage(senderFk, recipient, message) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (!isProduction(false)) {
|
||||
return new Promise(resolve => {
|
||||
return resolve({
|
||||
statusCode: 200,
|
||||
|
@ -149,7 +151,7 @@ module.exports = Self => {
|
|||
* @return {Promise} - The request promise
|
||||
*/
|
||||
Self.getUserStatus = async function getUserStatus(username) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (!isProduction(false)) {
|
||||
return new Promise(resolve => {
|
||||
return resolve({
|
||||
data: {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('deleteTrashFiles', {
|
||||
|
@ -22,7 +23,7 @@ module.exports = Self => {
|
|||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (process.env.NODE_ENV == 'test')
|
||||
if (!isProduction())
|
||||
throw new UserError(`Action not allowed on the test environment`);
|
||||
|
||||
const models = Self.app.models;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
const axios = require('axios');
|
||||
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||
|
||||
module.exports = Self => {
|
||||
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');
|
||||
|
||||
// delete old
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const UserError = require('vn-loopback/util/user-error');
|
||||
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('scrub', {
|
||||
|
@ -43,8 +44,7 @@ module.exports = Self => {
|
|||
Self.scrub = async function(collection, remove, limit, dryRun, skipLock) {
|
||||
const $ = Self.app.models;
|
||||
|
||||
const env = process.env.NODE_ENV;
|
||||
dryRun = dryRun || (env && env !== 'production');
|
||||
dryRun = dryRun || !isProduction(false);
|
||||
|
||||
const instance = await $.ImageCollection.findOne({
|
||||
fields: ['id'],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
const fs = require('fs/promises');
|
||||
const path = require('path');
|
||||
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('upload', {
|
||||
|
@ -41,7 +42,7 @@ module.exports = Self => {
|
|||
if (!hasWriteRole)
|
||||
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`);
|
||||
|
||||
// Upload file to temporary path
|
||||
|
|
|
@ -39,8 +39,6 @@ module.exports = Self => {
|
|||
const xmlString = response.data;
|
||||
const parser = new DOMParser();
|
||||
const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
|
||||
const [resultElement] = xmlDoc.getElementsByTagName('Mensaje');
|
||||
|
||||
return resultElement.textContent;
|
||||
return xmlDoc.getElementsByTagName('Mensaje')[0].textContent;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -26,16 +26,24 @@
|
|||
<mrw:Nif><%= expeditionData.fi %></mrw:Nif>
|
||||
<mrw:Nombre><%= expeditionData.clientName %></mrw:Nombre>
|
||||
<mrw:Telefono><%= expeditionData.phone %></mrw:Telefono>
|
||||
<mrw:Observaciones><%= expeditionData.deliveryObservation %></mrw:Observaciones>
|
||||
</mrw:DatosEntrega>
|
||||
<mrw:DatosServicio>
|
||||
<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:NumeroBultos>1</mrw:NumeroBultos>
|
||||
<mrw:EntregaSabado><%= expeditionData.weekDays %></mrw:EntregaSabado>
|
||||
<mrw:Peso><%= expeditionData.kg %></mrw:Peso>
|
||||
<mrw:Reembolso/>
|
||||
<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:request>
|
||||
</mrw:TransmEnvio>
|
||||
|
|
|
@ -42,9 +42,10 @@ module.exports = Self => {
|
|||
throw new UserError(`Some mrwConfig parameters are not set`);
|
||||
|
||||
const query =
|
||||
`SELECT CASE co.code
|
||||
`SELECT
|
||||
CASE co.code
|
||||
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')
|
||||
END postalCode,
|
||||
a.city,
|
||||
|
@ -55,9 +56,10 @@ module.exports = Self => {
|
|||
c.phone,
|
||||
DATE_FORMAT(t.shipped, '%d/%m/%Y') created,
|
||||
t.shipped,
|
||||
e.id expeditionId,
|
||||
LPAD(IF(mw.params IS NULL, ms.serviceType, mw.serviceType), 4 ,'0') serviceType,
|
||||
IF(mw.weekdays, 'S', 'N') weekDays
|
||||
CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference,
|
||||
LPAD(IF(mw.params IS NULL, ms.serviceType, mw.serviceType), mc.serviceTypeWidth,'0') serviceType,
|
||||
IF(mw.weekdays, 'S', 'N') weekDays,
|
||||
oa.description deliveryObservation
|
||||
FROM expedition e
|
||||
JOIN ticket t ON e.ticketFk = t.id
|
||||
JOIN agencyMode am ON am.id = t.agencyModeFk
|
||||
|
@ -65,8 +67,12 @@ module.exports = Self => {
|
|||
LEFT JOIN mrwServiceWeekday mw ON mw.weekdays = DATE_FORMAT(t.shipped, '%a')
|
||||
JOIN client c ON t.clientFk = c.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 country co ON co.id = p.countryFk
|
||||
JOIN mrwConfig mc
|
||||
WHERE e.id = ?
|
||||
LIMIT 1`;
|
||||
|
||||
|
@ -89,14 +95,9 @@ module.exports = Self => {
|
|||
const getLabelResponse = await sendXmlDoc('getLabel', {mrw, shipmentId}, 'text/xml');
|
||||
const file = getTextByTag(getLabelResponse, 'EtiquetaFile');
|
||||
|
||||
try {
|
||||
await models.Expedition.updateAll({id: expeditionFk}, {externalId: shipmentId}, myOptions);
|
||||
if (tx) await tx.commit();
|
||||
} catch (error) {
|
||||
if (tx) await tx.rollback();
|
||||
throw error;
|
||||
}
|
||||
return file;
|
||||
if (tx) await tx.commit();
|
||||
|
||||
return {shipmentId, file};
|
||||
};
|
||||
|
||||
function getTextByTag(xmlDoc, tag) {
|
||||
|
|
|
@ -81,9 +81,9 @@ describe('MRWConfig createShipment()', () => {
|
|||
|
||||
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() => {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
const {Email} = require('vn-print');
|
||||
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('send', {
|
||||
|
@ -70,7 +71,7 @@ module.exports = Self => {
|
|||
const newParams = Object.assign({}, queueParams, sendParams);
|
||||
const email = new Email(queueName, newParams);
|
||||
|
||||
if (process.env.NODE_ENV != 'test')
|
||||
if (isProduction())
|
||||
await email.send();
|
||||
|
||||
await queue.updateAttribute('status', statusSent);
|
||||
|
|
|
@ -45,7 +45,7 @@ module.exports = Self => {
|
|||
{'pc.code': {like: `%${value}%`}},
|
||||
{'t.name': {like: `%${value}%`}},
|
||||
{'p.name': {like: `%${value}%`}},
|
||||
{'c.country': {like: `%${value}%`}}
|
||||
{'c.name': {like: `%${value}%`}}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ module.exports = Self => {
|
|||
pc.code,
|
||||
t.name as town,
|
||||
p.name as province,
|
||||
c.country
|
||||
c.name country
|
||||
FROM
|
||||
postCode pc
|
||||
JOIN town t on t.id = pc.townFk
|
||||
|
|
|
@ -18,15 +18,10 @@ module.exports = Self => {
|
|||
Self.renewToken = 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 {courtesyTime} = await models.AccessTokenConfig.findOne({
|
||||
fields: ['courtesyTime']
|
||||
});
|
||||
const now = Date.now();
|
||||
const differenceMilliseconds = now - token.created;
|
||||
const differenceSeconds = Math.floor(differenceMilliseconds / 1000);
|
||||
const isNotExceeded = differenceSeconds < renewPeriod - courtesyTime;
|
||||
const isNotExceeded = await Self.validateToken(ctx);
|
||||
if (isNotExceeded)
|
||||
return token;
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
};
|
|
@ -186,5 +186,8 @@
|
|||
},
|
||||
"AgencyWorkCenter": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"RouteConfig": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"country": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
|
|
|
@ -27,6 +27,18 @@
|
|||
},
|
||||
"subscriberCode": {
|
||||
"type": "string"
|
||||
},
|
||||
"defaultHeight": {
|
||||
"type": "number"
|
||||
},
|
||||
"defaultLength": {
|
||||
"type": "number"
|
||||
},
|
||||
"defaultWidth": {
|
||||
"type": "number"
|
||||
},
|
||||
"defaultWeight": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "RouteConfig",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "routeConfig"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"description": "Identifier"
|
||||
},
|
||||
"kmMax": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,6 +15,7 @@ module.exports = function(Self) {
|
|||
require('../methods/vn-user/renew-token')(Self);
|
||||
require('../methods/vn-user/share-token')(Self);
|
||||
require('../methods/vn-user/update-user')(Self);
|
||||
require('../methods/vn-user/validate-token')(Self);
|
||||
|
||||
Self.definition.settings.acls = Self.definition.settings.acls.filter(acl => acl.property !== 'create');
|
||||
|
||||
|
|
|
@ -113,6 +113,13 @@
|
|||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
},
|
||||
{
|
||||
"property": "validateToken",
|
||||
"accessType": "EXECUTE",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$authenticated",
|
||||
"permission": "ALLOW"
|
||||
},
|
||||
{
|
||||
"property": "privileges",
|
||||
"accessType": "*",
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
},
|
||||
"vn": {
|
||||
"view": {
|
||||
"expeditionPallet_Print": "288cbd6e8289df083ed5eb1a2c808f7a82ba4c90c8ad9781104808a7a54471fb"
|
||||
"expeditionPallet_Print": "06613719475fcdba8309607c38cc78efc2e348cca7bc96b48dc3ae3c12426f54"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ USE `util`;
|
|||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||
|
||||
INSERT INTO `version` VALUES ('vn-database','11018','878ee9e3039dd06ad456fa475f0d646d8bae3d4b','2024-05-07 07:34:42','11032');
|
||||
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','10112','00-firstScript.sql','jenkins@10.0.2.69','2022-05-09 09:14:53',NULL,NULL);
|
||||
|
@ -651,6 +651,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','10855','00-firstScript.sql','jen
|
|||
INSERT INTO `versionLog` VALUES ('vn-database','10856','00-cloneAcl.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:57',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','10857','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:57',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','10858','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:46:06',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','10859','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:25',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','10861','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:46:06',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','10862','00-alterAgencyTermConfig.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:12:55',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','10862','00-alterGastosResumen.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:12:55',NULL,NULL);
|
||||
|
@ -758,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','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','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','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);
|
||||
|
@ -776,16 +778,57 @@ INSERT INTO `versionLog` VALUES ('vn-database','10977','00-firstScript.sql','jen
|
|||
INSERT INTO `versionLog` VALUES ('vn-database','10984','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:59',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','10988','00-pbx_prefix.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-04-11 17:00:16',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','10990','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:59',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','10991','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:26',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','10992','00-acl.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:26',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','10992','00-referenceRate.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:26',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','10994','00-modifyAcls.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:59',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','10995','01-agencyLogCreate.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:26',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','10995','02-agencyWorkCenterCreate.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:26',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','10995','03-tableAcl.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:26',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','10996','00-dropOrderRecalc.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','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','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','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','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','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','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','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','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','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','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','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','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 */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
|
@ -1072,7 +1115,6 @@ INSERT INTO `roleInherit` VALUES (249,109,18,NULL);
|
|||
INSERT INTO `roleInherit` VALUES (250,109,13,NULL);
|
||||
INSERT INTO `roleInherit` VALUES (251,51,21,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 (256,48,69,NULL);
|
||||
INSERT INTO `roleInherit` VALUES (257,47,111,NULL);
|
||||
|
@ -1147,6 +1189,7 @@ INSERT INTO `roleInherit` VALUES (360,101,129,NULL);
|
|||
INSERT INTO `roleInherit` VALUES (361,50,112,NULL);
|
||||
INSERT INTO `roleInherit` VALUES (362,122,15,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);
|
||||
|
||||
|
@ -1683,9 +1726,9 @@ INSERT INTO `ACL` VALUES (610,'Ticket','deliveryNoteCsv','READ','ALLOW','ROLE','
|
|||
INSERT INTO `ACL` VALUES (611,'State','find','READ','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (612,'State','findById','READ','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (613,'State','findOne','READ','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (614,'Worker','find','READ','ALLOW','ROLE','hr');
|
||||
INSERT INTO `ACL` VALUES (615,'Worker','findById','READ','ALLOW','ROLE','hr');
|
||||
INSERT INTO `ACL` VALUES (616,'Worker','findOne','READ','ALLOW','ROLE','hr');
|
||||
INSERT INTO `ACL` VALUES (614,'Worker','find','READ','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (615,'Worker','findById','READ','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (616,'Worker','findOne','READ','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (617,'Worker','filter','READ','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (618,'Worker','getWorkedHours','READ','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (619,'Worker','active','READ','ALLOW','ROLE','employee');
|
||||
|
@ -1861,7 +1904,22 @@ INSERT INTO `ACL` VALUES (825,'Application','getEnumValues','*','ALLOW','ROLE','
|
|||
INSERT INTO `ACL` VALUES (826,'Ticket','editZone','WRITE','ALLOW','ROLE','salesAssistant');
|
||||
INSERT INTO `ACL` VALUES (827,'TicketWeekly','deleteById','WRITE','ALLOW','ROLE','buyerBoss');
|
||||
INSERT INTO `ACL` VALUES (828,'TicketWeekly','upsert','WRITE','ALLOW','ROLE','buyer');
|
||||
INSERT INTO `ACL` VALUES (829,'Worker','__get__summary','READ','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (830,'InvoiceIn','*','READ','ALLOW','ROLE','deliveryBoss');
|
||||
INSERT INTO `ACL` VALUES (831,'InvoiceIn','exchangeRateUpdate','*','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (832,'AgencyLog','*','READ','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (833,'AgencyWorkCenter','*','READ','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (834,'AgencyMode','*','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 (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 (2,'Client','contact','update','employee');
|
||||
|
@ -2007,6 +2065,7 @@ INSERT INTO `businessType` VALUES ('others','Otros');
|
|||
INSERT INTO `businessType` VALUES ('otherSector','Profesional de otro sector');
|
||||
INSERT INTO `businessType` VALUES ('restoration','Restauración');
|
||||
INSERT INTO `businessType` VALUES ('trainingCentre','Centro de formación');
|
||||
INSERT INTO `businessType` VALUES ('VIP','Very important person');
|
||||
INSERT INTO `businessType` VALUES ('wholesaler','Mayorista');
|
||||
INSERT INTO `businessType` VALUES ('worker','Trabajador');
|
||||
|
||||
|
@ -2180,8 +2239,8 @@ INSERT INTO `continent` VALUES (3,'África','AF');
|
|||
INSERT INTO `continent` VALUES (4,'Europa','EU');
|
||||
INSERT INTO `continent` VALUES (5,'Oceanía','OC');
|
||||
|
||||
INSERT INTO `department` VALUES (1,'VN','VERDNATURA',1,118,763,0,0,0,0,26,NULL,'/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (22,'shopping','COMPRAS',2,3,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,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,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 (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);
|
||||
|
@ -2191,54 +2250,50 @@ 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 (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 (43,'VT','VENTAS',38,77,NULL,0,0,0,1,19,1,'/1/',NULL,1,'',1,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (44,'management','GERENCIA',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 (45,'logistic','LOGISTICA',80,81,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (46,'delivery','REPARTO',82,83,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',84,85,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',86,87,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',88,89,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,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',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',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',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',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',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 (54,NULL,'ORNAMENTALES',90,91,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (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 (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',92,95,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',96,97,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,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',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 (61,NULL,'VNH',98,101,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',102,103,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (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',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 (69,NULL,'VERDNABARNA',104,105,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 J VALLES',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 (86,NULL,'LIMPIEZA',106,107,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',108,109,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',99,100,NULL,0,0,0,2,0,61,'/1/61/',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,'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',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',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',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 (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,'brocalTeam','EQUIPO J BROCAL',47,48,3797,0,0,0,2,0,43,'/1/43/','jes_equipo',0,'equipojbrocal@verdnatura.es',0,0,0,0,NULL,NULL,'5100',NULL);
|
||||
INSERT INTO `department` VALUES (95,'spainTeam1','EQUIPO ESPAÑA 1',49,50,24065,0,0,0,2,0,43,'/1/43/','es1_equipo',0,'españa1@verdnatura.es',0,0,0,0,NULL,NULL,'5000',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 (95,'spainTeam1','EQUIPO ESPAÑA 1',49,50,24065,0,0,0,2,0,43,'/1/43/','es1_equipo',0,'es1@verdnatura.es',0,0,0,0,NULL,NULL,'5000',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 (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',110,111,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (125,'miriamMarTeam','EQUIPO MIRIAM MAR',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 (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,'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 (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 (131,'greenhouse','INVERNADERO',93,94,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 (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 (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 (135,'routers','ENRUTADORES',112,113,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',114,115,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',116,117,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 J SORIA ',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 (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 (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',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',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',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 (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 (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',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 (142,NULL,'EQUIPO ESPAÑA 2',69,70,3797,0,0,0,2,0,43,'/1/43/','jes_equipo',0,'equipojbrocal@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (143,NULL,'EQUIPO ESPAÑA 3',71,72,4379,0,0,0,2,0,43,'/1/43/','mir_equipo',0,'equipomirgir@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (144,NULL,'EQUIPO ESPAÑA 4',73,74,3803,0,0,0,2,0,43,'/1/43/','jss_equipo',0,'equipojsoria@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (145,NULL,'EQUIPO ESPAÑA 5',75,76,4250,0,0,0,2,0,43,'/1/43/','jvp_equipo',0,'equipojvalles@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
|
||||
INSERT INTO `docuware` VALUES (1,'deliveryNote','Albaranes cliente','find','find','N__ALBAR_N',NULL);
|
||||
INSERT INTO `docuware` VALUES (2,'deliveryNote','Albaranes cliente','store','Archivar','N__ALBAR_N',NULL);
|
||||
|
@ -2541,7 +2596,7 @@ INSERT INTO `volumeConfig` VALUES (2.67,1.60,0.8,150,0.30,120,57,2.0,50,200,10,1
|
|||
INSERT INTO `workCenter` VALUES (1,'Silla',20,859,1,'Av espioca 100',552703,NULL);
|
||||
INSERT INTO `workCenter` VALUES (2,'Mercaflor',19,NULL,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `workCenter` VALUES (3,'Marjales',26,20008,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `workCenter` VALUES (4,'VNH',NULL,NULL,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `workCenter` VALUES (4,'VNH',NULL,NULL,7,NULL,NULL,NULL);
|
||||
INSERT INTO `workCenter` VALUES (5,'Madrid',28,2869,5,'Av constitución 3',554145,2.00);
|
||||
INSERT INTO `workCenter` VALUES (6,'Vilassar',88,88038,NULL,'Cami del Crist, 33',556412,NULL);
|
||||
INSERT INTO `workCenter` VALUES (7,'Tenerife',NULL,NULL,NULL,NULL,NULL,NULL);
|
||||
|
|
|
@ -327,20 +327,16 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','price_fixed','
|
|||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','printQueue','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','preservedBoss','travel','alexm@%','0000-00-00 00:00:00','Insert,Delete','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','travel','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','Cubos_Retorno','alexm@%','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','Cubos','alexm@%','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyerAssistant','itemType','jgallego@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Cubos','alexm@%','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesPerson','Cubos','alexm@%','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerBoss','Cubos_Retorno','alexm@%','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','artificialBoss','state','alexm@%','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','travel','alexm@%','0000-00-00 00:00:00','Delete','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Bancos_poliza','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','cmr','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','duaDismissed','alexm@%','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','edi_article','alexm@%','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','edi_bucket','alexm@%','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','edi_bucket_type','alexm@%','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','time','alexm@%','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','operator','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','payment','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert','');
|
||||
|
@ -553,7 +549,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','client','alexm@%',
|
|||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','saleVolume','alexm@%','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','Proveedores_gestdoc','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','awb_gestdoc','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerBoss','Cubos','alexm@%','0000-00-00 00:00:00','Insert,Update','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerAssistant','Cubos','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','routesMonitor','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','Update');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminBoss','sale','alexm@%','0000-00-00 00:00:00','Insert','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','sale','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Delete','Update');
|
||||
|
@ -1304,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 ('','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','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','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','');
|
||||
|
@ -1379,9 +1375,9 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','zoneIncluded','guil
|
|||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','zoneGeo','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','quality','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','category','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerAssistant','edi_bucket_type','carlosap@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','edi_bucket','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','ektEntryAssign','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Delete','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerAssistant','edi_bucket','carlosap@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','edi_bucket_type','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','calendarType','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','timeSlots','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','supplierFreight','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
|
@ -1395,6 +1391,21 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','deliveryNote','guil
|
|||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','invoiceOutExpense','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','delivery','carlosap@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','entry','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Cubos_Retorno','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimDestination','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','entryConfig','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','farmingDeliveryNote','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','sage','grafana','TiposIva','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','bs','buyer','waste','alexm@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','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 `columns_priv` DISABLE KEYS */;
|
||||
|
@ -1590,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','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','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','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','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');
|
||||
|
@ -1719,18 +1727,13 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_afterUpsert','PROC
|
|||
INSERT IGNORE INTO `procs_priv` VALUES ('','util','grafana','dayend','FUNCTION','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','srt','production','buffer_settypebyname','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buyUltimate','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn2008','financialBoss','balance_create','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','buyUltimate','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','barcodeToItem','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','ticket_splititempackingtype','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','entry_getCommission','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','deliveryAssistant','expeditionstate_addbypallet','PROCEDURE','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn2008','buyer','buy_tarifas_entry','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn2008','entryEditor','buy_tarifas','PROCEDURE','guillermo@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn2008','claimManager','buy_tarifas_entry','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','mail_insert','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','entry_fixMisfit','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn2008','employee','buy_tarifas_entry','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','VN_CURDATE','FUNCTION','juan@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','marketingBoss','clientTaxArea','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','clientTaxArea','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00');
|
||||
|
@ -1766,7 +1769,6 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','productionBoss','saleSplit','P
|
|||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','grafana','client_getDebt','FUNCTION','guillermo@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','client_getDebt','PROCEDURE','guillermo@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','tx_commit','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn2008','hrBoss','balance_create','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','cooler','buyultimate','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','util','grafana','firstdayofyear','FUNCTION','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','util','claimManager','dayend','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00');
|
||||
|
@ -1874,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','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','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','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');
|
||||
|
@ -1913,7 +1914,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','account','guest','myuser_hasroutine
|
|||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','productionAssi','timebusiness_calculateall','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','timecontrol_geterror','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','logistic','travel_weeklyclone','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_recalcPricesByBuy','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_recalcPricesByBuy','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','handmadeBoss','confection_controlSource','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','bi','productionAssi','rutasanalyze','PROCEDURE','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','productionPlus','workerCreateExternal','PROCEDURE','juan@10.5.1.2','Execute','0000-00-00 00:00:00');
|
||||
|
@ -1977,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_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','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','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');
|
||||
|
@ -2030,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_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','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','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');
|
||||
|
@ -2044,7 +2043,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','tx_rollback','PROCED
|
|||
INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','tx_start','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_recalcPrices','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_recalcPricesByAwb','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_recalcPricesByEntry','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_recalcPricesByEntry','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','util','hr','accountNumberToIban','FUNCTION','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','util','financial','accountNumberToIban','FUNCTION','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','supplier_statement','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
|
@ -2059,6 +2058,14 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','artificialBoss','confection_co
|
|||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financial','remittance_calc','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','util','developer','connection_kill','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financial','client_getRisk','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','grafana','item_ValuateInventory','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financialBoss','balance_create','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hrBoss','balance_create','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','buy_recalcPricesByEntry','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','buy_recalcPricesByEntry','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','entryEditor','buy_recalcPricesByBuy','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','buy_recalcPricesByBuy','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','buy_recalcPricesByBuy','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
/*!40000 ALTER TABLE `procs_priv` ENABLE KEYS */;
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1855,6 +1855,26 @@ DELIMITER ;
|
|||
/*!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`.`agency_beforeInsert`
|
||||
BEFORE INSERT ON `agency`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
END */;;
|
||||
DELIMITER ;
|
||||
/*!50003 SET sql_mode = @saved_sql_mode */ ;
|
||||
/*!50003 SET character_set_client = @saved_cs_client */ ;
|
||||
/*!50003 SET character_set_results = @saved_cs_results */ ;
|
||||
/*!50003 SET collation_connection = @saved_col_connection */ ;
|
||||
/*!50003 SET @saved_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`.`agency_afterInsert`
|
||||
AFTER INSERT ON `agency`
|
||||
FOR EACH ROW
|
||||
|
@ -3211,12 +3231,6 @@ BEGIN
|
|||
UPDATE `address` SET isDefaultAddress = TRUE
|
||||
WHERE id = NEW.defaultAddressFk;
|
||||
END IF;
|
||||
|
||||
IF NOT NEW.isActive THEN
|
||||
UPDATE account.`user`
|
||||
SET active = FALSE
|
||||
WHERE id = NEW.id;
|
||||
END IF;
|
||||
END */;;
|
||||
DELIMITER ;
|
||||
/*!50003 SET sql_mode = @saved_sql_mode */ ;
|
||||
|
@ -3775,7 +3789,7 @@ DELIMITER ;;
|
|||
BEFORE INSERT ON `country`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.geoFk = zoneGeo_new('country', NEW.country, NULL);
|
||||
SET NEW.geoFk = zoneGeo_new('country', NEW.name, NULL);
|
||||
END */;;
|
||||
DELIMITER ;
|
||||
/*!50003 SET sql_mode = @saved_sql_mode */ ;
|
||||
|
@ -3797,14 +3811,17 @@ DELIMITER ;;
|
|||
BEGIN
|
||||
UPDATE sage.Naciones
|
||||
SET countryFk = NEW.id
|
||||
WHERE Nacion = NEW.country;
|
||||
WHERE Nacion = NEW.name;
|
||||
|
||||
IF ROW_COUNT() = 0 THEN
|
||||
CALL mail_insert(
|
||||
'cau@verdnatura.es',
|
||||
NULL,
|
||||
'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 */;;
|
||||
|
@ -3848,8 +3865,8 @@ DELIMITER ;;
|
|||
AFTER UPDATE ON `country`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF !(OLD.country <=> NEW.country) THEN
|
||||
UPDATE zoneGeo SET `name` = NEW.country
|
||||
IF !(OLD.name <=> NEW.name) THEN
|
||||
UPDATE zoneGeo SET `name` = NEW.name
|
||||
WHERE id = NEW.geoFk;
|
||||
END IF;
|
||||
END */;;
|
||||
|
@ -4311,10 +4328,32 @@ DELIMITER ;
|
|||
/*!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_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`
|
||||
BEFORE UPDATE ON `deviceProductionUser`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
|
||||
CALL worker_checkMultipleDevice(NEW.userFk);
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
END */;;
|
||||
DELIMITER ;
|
||||
|
@ -4577,9 +4616,19 @@ BEGIN
|
|||
DECLARE vIsVirtual BOOL;
|
||||
DECLARE vPrintedCount INT;
|
||||
DECLARE vHasDistinctWarehouses BOOL;
|
||||
DECLARE vTotalBuy INT;
|
||||
|
||||
IF NEW.isBooked = OLD.isBooked THEN
|
||||
CALL entry_checkBooked(OLD.id);
|
||||
ELSE
|
||||
IF NEW.isBooked THEN
|
||||
SELECT COUNT(*) INTO vTotalBuy
|
||||
FROM buy
|
||||
WHERE entryFk = NEW.id;
|
||||
IF NOT vTotalBuy THEN
|
||||
CALL util.throw('Entry must have lines to be marked booked');
|
||||
END IF;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
|
@ -4587,7 +4636,7 @@ BEGIN
|
|||
IF NOT (NEW.travelFk <=> OLD.travelFk) THEN
|
||||
|
||||
IF NEW.travelFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.travelFk) THEN
|
||||
CALL util.throw('The travel is incorrect, there is a different AWB in the associated entries');
|
||||
CALL util.throw('The travel is incorrect, there is a different AWB in the associated entries');
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) > 0 INTO vIsVirtual
|
||||
|
@ -5036,50 +5085,6 @@ BEGIN
|
|||
SET e.stateTypeFk = NEW.typeFk
|
||||
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 */;;
|
||||
DELIMITER ;
|
||||
/*!50003 SET sql_mode = @saved_sql_mode */ ;
|
||||
|
@ -5295,10 +5300,6 @@ DELIMITER ;;
|
|||
BEGIN
|
||||
DECLARE vWithholdingSageFk INT;
|
||||
|
||||
IF NEW.isBooked = OLD.isBooked THEN
|
||||
CALL invoiceIn_checkBooked(OLD.id);
|
||||
END IF;
|
||||
|
||||
IF NOT (NEW.supplierRef <=> OLD.supplierRef) AND NOT util.checkPrintableChars(NEW.supplierRef) THEN
|
||||
CALL util.throw('The invoiceIn reference contains invalid characters');
|
||||
END IF;
|
||||
|
@ -5419,74 +5420,12 @@ DELIMITER ;
|
|||
/*!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`.`invoiceInCorrection_beforeInsert`
|
||||
BEFORE INSERT ON `invoiceInCorrection`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL invoiceIn_checkBooked(NEW.correctingFk);
|
||||
END */;;
|
||||
DELIMITER ;
|
||||
/*!50003 SET sql_mode = @saved_sql_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`.`invoiceInCorrection_beforeUpdate`
|
||||
BEFORE UPDATE ON `invoiceInCorrection`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL invoiceIn_checkBooked(OLD.correctingFk);
|
||||
END */;;
|
||||
DELIMITER ;
|
||||
/*!50003 SET sql_mode = @saved_sql_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`.`invoiceInCorrection_beforeDelete`
|
||||
BEFORE DELETE ON `invoiceInCorrection`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL invoiceIn_checkBooked(OLD.correctingFk);
|
||||
END */;;
|
||||
DELIMITER ;
|
||||
/*!50003 SET sql_mode = @saved_sql_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`.`invoiceInDueDay_beforeInsert`
|
||||
BEFORE INSERT ON `invoiceInDueDay`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
DECLARE vIsNotified BOOLEAN;
|
||||
|
||||
CALL invoiceIn_checkBooked(NEW.invoiceInFk);
|
||||
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
|
||||
SELECT isNotified INTO vIsNotified
|
||||
|
@ -5529,7 +5468,6 @@ DELIMITER ;;
|
|||
BEGIN
|
||||
DECLARE vIsNotified BOOLEAN;
|
||||
|
||||
CALL invoiceIn_checkBooked(OLD.invoiceInFk);
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
|
||||
SELECT isNotified INTO vIsNotified
|
||||
|
@ -5566,26 +5504,6 @@ DELIMITER ;
|
|||
/*!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`.`invoiceInDueDay_beforeDelete`
|
||||
BEFORE DELETE ON `invoiceInDueDay`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL invoiceIn_checkBooked(OLD.invoiceInFk);
|
||||
END */;;
|
||||
DELIMITER ;
|
||||
/*!50003 SET sql_mode = @saved_sql_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`.`invoiceInDueDay_afterDelete`
|
||||
AFTER DELETE ON `invoiceInDueDay`
|
||||
FOR EACH ROW
|
||||
|
@ -5610,66 +5528,6 @@ DELIMITER ;
|
|||
/*!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`.`invoiceInIntrastat_beforeInsert`
|
||||
BEFORE INSERT ON `invoiceInIntrastat`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL invoiceIn_checkBooked(NEW.invoiceInFk);
|
||||
END */;;
|
||||
DELIMITER ;
|
||||
/*!50003 SET sql_mode = @saved_sql_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`.`invoiceInIntrastat_beforeUpdate`
|
||||
BEFORE UPDATE ON `invoiceInIntrastat`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL invoiceIn_checkBooked(OLD.invoiceInFk);
|
||||
END */;;
|
||||
DELIMITER ;
|
||||
/*!50003 SET sql_mode = @saved_sql_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`.`invoiceInIntrastat_beforeDelete`
|
||||
BEFORE DELETE ON `invoiceInIntrastat`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL invoiceIn_checkBooked(OLD.invoiceInFk);
|
||||
END */;;
|
||||
DELIMITER ;
|
||||
/*!50003 SET sql_mode = @saved_sql_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`.`invoiceInTax_beforeInsert`
|
||||
BEFORE INSERT ON `invoiceInTax`
|
||||
FOR EACH ROW
|
||||
|
@ -5695,8 +5553,6 @@ DELIMITER ;;
|
|||
BEFORE UPDATE ON `invoiceInTax`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL invoiceIn_checkBooked(OLD.invoiceInFk);
|
||||
|
||||
IF NOT (NEW.invoiceInFk <=> OLD.invoiceInFk) THEN
|
||||
CALL invoiceInTax_afterUpsert(NEW.invoiceInFk);
|
||||
END IF;
|
||||
|
@ -5717,26 +5573,6 @@ DELIMITER ;
|
|||
/*!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`.`invoiceInTax_beforeDelete`
|
||||
BEFORE DELETE ON `invoiceInTax`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL invoiceIn_checkBooked(OLD.invoiceInFk);
|
||||
END */;;
|
||||
DELIMITER ;
|
||||
/*!50003 SET sql_mode = @saved_sql_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`.`invoiceInTax_afterDelete`
|
||||
AFTER DELETE ON `invoiceInTax`
|
||||
FOR EACH ROW
|
||||
|
@ -6941,94 +6777,95 @@ DELIMITER ;;
|
|||
BEFORE INSERT ON `payment`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
DECLARE cuenta_banco,cuenta_proveedor DOUBLE;
|
||||
DECLARE vNewBookEntry INT;
|
||||
DECLARE bolCASH BOOLEAN;
|
||||
DECLARE isSupplierActive BOOLEAN;
|
||||
DECLARE vBankAccount DOUBLE;
|
||||
DECLARE vSupplierAccount DOUBLE;
|
||||
DECLARE vNewBookEntry INT;
|
||||
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
|
||||
SELECT (at2.code = 'cash') INTO bolCASH
|
||||
FROM accounting a
|
||||
JOIN accountingType at2 ON at2.id = a.accountingTypeFk
|
||||
WHERE a.id = NEW.bankFk;
|
||||
-- PAK 10/02/15 No se asientan los pagos directamente, salvo en el caso de las cajas de CASH
|
||||
SELECT (at2.code = 'cash') INTO vIsCash
|
||||
FROM accounting a
|
||||
JOIN accountingType at2 ON at2.id = a.accountingTypeFk
|
||||
WHERE a.id = NEW.bankFk;
|
||||
|
||||
IF bolCASH THEN
|
||||
|
||||
SELECT account INTO cuenta_banco
|
||||
FROM accounting
|
||||
WHERE id = NEW.bankFk;
|
||||
|
||||
SELECT account INTO cuenta_proveedor
|
||||
FROM supplier
|
||||
WHERE id = NEW.supplierFk;
|
||||
IF vIsCash THEN
|
||||
SELECT account INTO vBankAccount
|
||||
FROM accounting
|
||||
WHERE id = NEW.bankFk;
|
||||
|
||||
CALL ledger_next(vNewBookEntry);
|
||||
|
||||
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
|
||||
SELECT account INTO vSupplierAccount
|
||||
FROM supplier
|
||||
WHERE id = NEW.supplierFk;
|
||||
|
||||
IF isSupplierActive = FALSE THEN
|
||||
CALL util.throw('SUPPLIER_INACTIVE');
|
||||
END IF;
|
||||
|
||||
IF ISNULL(NEW.workerFk) THEN
|
||||
SET NEW.workerFk = account.myUser_getId();
|
||||
END IF;
|
||||
|
||||
END */;;
|
||||
|
||||
CALL ledger_next(YEAR(NEW.received), NEW.companyFk, vNewBookEntry);
|
||||
|
||||
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 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 ;
|
||||
/*!50003 SET sql_mode = @saved_sql_mode */ ;
|
||||
/*!50003 SET character_set_client = @saved_cs_client */ ;
|
||||
|
@ -7617,6 +7454,48 @@ DELIMITER ;
|
|||
/*!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 `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`
|
||||
BEFORE INSERT ON `route`
|
||||
FOR EACH ROW
|
||||
|
@ -8459,8 +8338,8 @@ DELIMITER ;;
|
|||
AFTER INSERT ON `solunionCAP`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
UPDATE vn2008.Clientes c
|
||||
JOIN creditClassification cc ON c.Id_Cliente = cc.client
|
||||
UPDATE client c
|
||||
JOIN creditClassification cc ON cc.client = c.id
|
||||
JOIN creditInsurance ci ON ci.creditClassification = cc.id
|
||||
SET creditInsurance = ci.credit * 2 WHERE ci.id = NEW.creditInsurance;
|
||||
END */;;
|
||||
|
@ -8483,13 +8362,13 @@ DELIMITER ;;
|
|||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF NEW.dateLeaving IS NOT NULL THEN
|
||||
UPDATE vn2008.Clientes c
|
||||
JOIN creditClassification cc ON c.Id_Cliente = cc.client
|
||||
UPDATE client c
|
||||
JOIN creditClassification cc ON cc.client = c.id
|
||||
JOIN creditInsurance ci ON ci.creditClassification = cc.id
|
||||
SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance;
|
||||
ELSE
|
||||
UPDATE vn2008.Clientes c
|
||||
JOIN creditClassification cc ON c.Id_Cliente = cc.client
|
||||
UPDATE client c
|
||||
JOIN creditClassification cc ON cc.client = c.id
|
||||
JOIN creditInsurance ci ON ci.creditClassification = cc.id
|
||||
SET creditInsurance = ci.credit * 2 WHERE ci.id = OLD.creditInsurance;
|
||||
END IF;
|
||||
|
@ -8512,8 +8391,8 @@ DELIMITER ;;
|
|||
BEFORE DELETE ON `solunionCAP`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
UPDATE vn2008.Clientes c
|
||||
JOIN creditClassification cc ON c.Id_Cliente = cc.client
|
||||
UPDATE client c
|
||||
JOIN creditClassification cc ON cc.client = c.id
|
||||
JOIN creditInsurance ci ON ci.creditClassification = cc.id
|
||||
SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance;
|
||||
END */;;
|
||||
|
@ -9106,6 +8985,8 @@ BEGIN
|
|||
UPDATE expedition
|
||||
SET hasNewRoute = TRUE
|
||||
WHERE ticketFk = NEW.id;
|
||||
|
||||
CALL ticket_doCmr(NEW.id);
|
||||
END IF;
|
||||
END */;;
|
||||
DELIMITER ;
|
||||
|
@ -9463,7 +9344,6 @@ DELIMITER ;;
|
|||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
CALL ticketRefund_beforeUpsert(NEW.refundTicketFk, NEW.originalTicketFk);
|
||||
END */;;
|
||||
DELIMITER ;
|
||||
/*!50003 SET sql_mode = @saved_sql_mode */ ;
|
||||
|
@ -9484,7 +9364,6 @@ DELIMITER ;;
|
|||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
CALL ticketRefund_beforeUpsert(NEW.refundTicketFk, NEW.originalTicketFk);
|
||||
END */;;
|
||||
DELIMITER ;
|
||||
/*!50003 SET sql_mode = @saved_sql_mode */ ;
|
||||
|
@ -9539,7 +9418,7 @@ BEGIN
|
|||
END IF;
|
||||
|
||||
IF NEW.attenderFk IS NULL THEN
|
||||
SET NEW.attenderFk = (SELECT w.id FROM worker w WHERE w.code = NEW.buyerCode);
|
||||
SET NEW.attenderFk = (SELECT defaultAttenderFk FROM ticketConfig LIMIT 1);
|
||||
END IF;
|
||||
END */;;
|
||||
DELIMITER ;
|
||||
|
@ -9569,10 +9448,6 @@ BEGIN
|
|||
IF NEW.salesPersonCode <> OLD.salesPersonCode THEN
|
||||
SET NEW.requesterFk = (SELECT w.id FROM worker w WHERE w.code = NEW.salesPersonCode);
|
||||
END IF;
|
||||
|
||||
IF NEW.buyerCode <> OLD.buyerCode THEN
|
||||
SET NEW.attenderFk = (SELECT w.id FROM worker w WHERE w.code = NEW.buyerCode);
|
||||
END IF;
|
||||
END */;;
|
||||
DELIMITER ;
|
||||
/*!50003 SET sql_mode = @saved_sql_mode */ ;
|
||||
|
@ -9804,11 +9679,6 @@ BEGIN
|
|||
`changedModel` = 'TicketTracking',
|
||||
`changedModelId` = OLD.id,
|
||||
`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`
|
||||
INTO vTicketFk, vTicketTrackingFk, vStateName
|
||||
|
@ -10954,4 +10824,4 @@ USE `vn2008`;
|
|||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2024-05-07 5:48:41
|
||||
-- Dump completed on 2024-05-28 6:58:42
|
||||
|
|
|
@ -162,7 +162,7 @@ INSERT INTO `vn`.`currency`(`id`, `code`, `name`, `ratio`)
|
|||
(4, 'JPY', 'Yen Japones', 1),
|
||||
(5, 'CNY', 'Yuan Chino', 1.2);
|
||||
|
||||
INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, `ibanLength`, `continentFk`, `hasDailyInvoice`, `CEE`)
|
||||
INSERT INTO `vn`.`country`(`id`, `name`, `isUeeMember`, `code`, `currencyFk`, `ibanLength`, `continentFk`, `hasDailyInvoice`, `CEE`)
|
||||
VALUES
|
||||
(1, 'España', 1, 'ES', 1, 24, 4, 0, 1),
|
||||
(2, 'Italia', 1, 'IT', 1, 27, 4, 0, 1),
|
||||
|
@ -1205,11 +1205,11 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`)
|
|||
(32, 36, -92.324),
|
||||
(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
|
||||
(2, 'GVC', 1, 1, 1, 1106),
|
||||
(4, 'HEJ', 1, 1, 1, 1106),
|
||||
(1, 'UXN', 2, 12, 12, 1106);
|
||||
(2, 'GVC', 1, 1, 1, 2,1106),
|
||||
(4, 'HEJ', 1, 1, 1, NULL,1106),
|
||||
(1, 'UXN', 2, 12, 12, NULL,1106);
|
||||
|
||||
INSERT INTO `vn`.`itemShelvingSale` (`itemShelvingFk`, `saleFk`, `quantity`, `created`, `userFk`)
|
||||
VALUES
|
||||
|
@ -2549,18 +2549,18 @@ INSERT INTO `vn`.`duaEntry` (`duaFk`, `entryFk`, `value`, `customsValue`, `euroV
|
|||
(7, 7, 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
|
||||
(1, 1001, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1234, 0, 442, 1),
|
||||
(2, 1002, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1235, 0, 442, 1),
|
||||
(3, 1003, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1236, 0, 442, 1),
|
||||
(4, 1004, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1237, 0, 442, 1),
|
||||
(5, 1005, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1238, 0, 442, 1),
|
||||
(6, 1006, 'R', 2, util.VN_CURDATE(), util.VN_CURDATE(), 1239, 0, 442, 1),
|
||||
(7, 1007, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1240, 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),
|
||||
(9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 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);
|
||||
(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,util.VN_CURDATE()),
|
||||
(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,util.VN_CURDATE()),
|
||||
(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,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,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,util.VN_CURDATE()),
|
||||
(9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 0, 442, 1,util.VN_CURDATE()),
|
||||
(10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 0, 442, 1,util.VN_CURDATE());
|
||||
|
||||
INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageFarmerWithholdingFk`, `daysAgo`)
|
||||
VALUES
|
||||
|
@ -3788,5 +3788,22 @@ INSERT INTO vn.workerTeam(id, team, workerFk)
|
|||
VALUES
|
||||
(8, 1, 19);
|
||||
|
||||
INSERT INTO vn.workCenter (id, name, payrollCenterFk, counter, warehouseFk, street, geoFk, deliveryManAdjustment)
|
||||
VALUES(100, 'workCenterOne', 1, NULL, 1, 'gotham', NULL, NULL);
|
||||
INSERT INTO vn.workCenter (id, name, payrollCenterFk, counter, warehouseFk, street, geoFk, deliveryManAdjustment)
|
||||
VALUES(100, 'workCenterOne', 1, NULL, 1, 'gotham', NULL, NULL);
|
||||
|
||||
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;
|
||||
|
|
|
@ -48,7 +48,7 @@ BEGIN
|
|||
-- Marcamos para no repetir
|
||||
UPDATE vn.claimEnd ce
|
||||
JOIN vn.claim c ON c.id = ce.claimFk
|
||||
SET c.isChargedToMana = TRUE
|
||||
SET ce.isGreuge = TRUE
|
||||
WHERE ce.claimDestinationFk NOT IN (1,5)
|
||||
AND NOT ce.isGreuge
|
||||
AND c.claimStateFk = 3;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`sale_add`(
|
||||
IN vStarted DATE,
|
||||
IN vEnded DATE)
|
||||
IN vEnded DATE
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Añade las ventas que se realizaron entre 2 fechas a la tabla bs.sale
|
||||
|
@ -10,63 +11,54 @@ BEGIN
|
|||
* @param vEnded Fecha de fin
|
||||
*
|
||||
*/
|
||||
DECLARE vLoopDate DATE;
|
||||
DECLARE vLoopDateTime DATETIME;
|
||||
|
||||
IF vStarted < (util.VN_CURDATE() - INTERVAL 5 YEAR) OR vStarted > vEnded THEN
|
||||
CALL util.throw('Wrong date');
|
||||
END IF;
|
||||
|
||||
SET vLoopDate = vStarted;
|
||||
|
||||
DELETE FROM sale
|
||||
WHERE dated BETWEEN vStarted AND vEnded;
|
||||
|
||||
WHILE vLoopDate <= vEnded DO
|
||||
SET vLoopDateTime = util.dayEnd(vLoopDate);
|
||||
|
||||
REPLACE sale(
|
||||
saleFk,
|
||||
amount,
|
||||
surcharge,
|
||||
dated,
|
||||
typeFk,
|
||||
clientFk,
|
||||
companyFk,
|
||||
margin
|
||||
)WITH calculatedSales AS(
|
||||
SELECT s.id saleFk,
|
||||
SUM(IF(ct.isBase, s.quantity * sc.value, 0)) amount,
|
||||
SUM(IF(ct.isBase, 0, s.quantity * sc.value)) surcharge,
|
||||
s.total pvp,
|
||||
DATE(t.shipped) dated,
|
||||
i.typeFk,
|
||||
t.clientFk,
|
||||
t.companyFk,
|
||||
SUM(IF(ct.isMargin, s.quantity * sc.value, 0 )) marginComponents
|
||||
FROM vn.ticket t
|
||||
STRAIGHT_JOIN vn.sale s ON s.ticketFk = t.id
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
JOIN vn.itemType it ON it.id = i.typeFk
|
||||
JOIN vn.itemCategory ic ON ic.id = it.categoryFk
|
||||
JOIN vn.saleComponent sc ON sc.saleFk = s.id
|
||||
JOIN vn.component c ON c.id = sc.componentFk
|
||||
JOIN vn.componentType ct ON ct.id = c.typeFk
|
||||
WHERE t.shipped BETWEEN vLoopDate AND vLoopDateTime
|
||||
AND s.quantity <> 0
|
||||
AND ic.merchandise
|
||||
GROUP BY s.id
|
||||
)SELECT saleFk,
|
||||
amount,
|
||||
surcharge,
|
||||
dated,
|
||||
typeFk,
|
||||
clientFk,
|
||||
companyFk,
|
||||
marginComponents + amount + surcharge - pvp
|
||||
FROM calculatedSales;
|
||||
|
||||
SET vLoopDate = vLoopDate + INTERVAL 1 DAY;
|
||||
END WHILE;
|
||||
REPLACE sale(
|
||||
saleFk,
|
||||
amount,
|
||||
surcharge,
|
||||
dated,
|
||||
typeFk,
|
||||
clientFk,
|
||||
companyFk,
|
||||
margin
|
||||
)WITH calculatedSales AS(
|
||||
SELECT s.id saleFk,
|
||||
CAST(SUM(IF(ct.isBase, s.quantity * sc.value, 0)) AS DECIMAL(10, 3)) amount,
|
||||
CAST(SUM(IF(ct.isBase, 0, s.quantity * sc.value)) AS DECIMAL(10, 3)) surcharge,
|
||||
s.total,
|
||||
DATE(t.shipped) dated,
|
||||
i.typeFk,
|
||||
t.clientFk,
|
||||
t.companyFk,
|
||||
CAST(SUM(IF(ct.isMargin, s.quantity * sc.value, 0 )) AS DECIMAL(10, 3)) marginComponents
|
||||
FROM vn.ticket t
|
||||
STRAIGHT_JOIN vn.sale s ON s.ticketFk = t.id
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
JOIN vn.itemType it ON it.id = i.typeFk
|
||||
JOIN vn.itemCategory ic ON ic.id = it.categoryFk
|
||||
JOIN vn.saleComponent sc ON sc.saleFk = s.id
|
||||
JOIN vn.component c ON c.id = sc.componentFk
|
||||
JOIN vn.componentType ct ON ct.id = c.typeFk
|
||||
WHERE t.shipped BETWEEN vStarted AND vEnded
|
||||
AND s.quantity <> 0
|
||||
AND ic.merchandise
|
||||
GROUP BY s.id
|
||||
)SELECT saleFk,
|
||||
amount,
|
||||
surcharge,
|
||||
dated,
|
||||
typeFk,
|
||||
clientFk,
|
||||
companyFk,
|
||||
IF (marginComponents IS NULL,
|
||||
0,
|
||||
CAST(marginComponents + amount + surcharge - total AS DECIMAL(10, 3)))
|
||||
FROM calculatedSales;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -34,7 +34,7 @@ BEGIN
|
|||
vPrinterFk,
|
||||
IFNULL(right(`t`.`routeFk`, 3),0),
|
||||
if (@vVolume := vn.ticketTotalVolume(t.id) > 1.5, @vVolume, IFNULL( rm.beachFk, 0)),
|
||||
LEFT(IFNULL(et.description ,replace(`z`.`name`, 'ZONA ', 'Z')),14) truckName,
|
||||
LEFT(IFNULL(rs.description ,replace(`z`.`name`, 'ZONA ', 'Z')),14) truckName,
|
||||
t.clientFk ,
|
||||
ifnull(c.mobile, ifnull(a.mobile, ifnull(c.phone, a.phone))),
|
||||
LEFT(p.name, 20),
|
||||
|
@ -46,7 +46,7 @@ BEGIN
|
|||
JOIN vn.address a ON a.id = t.addressFk
|
||||
JOIN vn.province p ON p.id = a.provinceFk
|
||||
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk
|
||||
LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk
|
||||
LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk
|
||||
LEFT JOIN vn.beach b ON b.code = rm.beachFk
|
||||
LEFT JOIN vn.`zone`z ON z.id = t.zoneFk
|
||||
JOIN vn.agencyMode am ON t.agencyModeFk = am.id
|
||||
|
|
|
@ -23,42 +23,39 @@ BEGIN
|
|||
DECLARE vXtraLongAgj INT;
|
||||
DECLARE vDefaultKlo INT;
|
||||
|
||||
SELECT
|
||||
ec.usefulAuctionLeftSegmentLength,
|
||||
ec.standardBarcodeLength,
|
||||
ec.floridayBarcodeLength,
|
||||
ec.floramondoBarcodeLength,
|
||||
ec.defaultKlo
|
||||
INTO
|
||||
vUsefulAuctionLeftSegmentLength,
|
||||
SELECT usefulAuctionLeftSegmentLength,
|
||||
standardBarcodeLength,
|
||||
floridayBarcodeLength,
|
||||
floramondoBarcodeLength,
|
||||
defaultKlo
|
||||
INTO vUsefulAuctionLeftSegmentLength,
|
||||
vStandardBarcodeLength,
|
||||
vFloridayBarcodeLength,
|
||||
vFloramondoBarcodeLength,
|
||||
vDefaultKlo
|
||||
FROM edi.ektConfig ec;
|
||||
FROM ektConfig;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.ekt;
|
||||
CREATE TEMPORARY TABLE tmp.ekt
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ekt
|
||||
ENGINE = MEMORY
|
||||
SELECT id ektFk FROM ekt LIMIT 0;
|
||||
|
||||
CASE
|
||||
CASE
|
||||
WHEN LENGTH(vBarcode) <= vFloridayBarcodeLength THEN
|
||||
INSERT INTO tmp.ekt
|
||||
SELECT id
|
||||
FROM edi.ektRecent e
|
||||
FROM ektRecent e
|
||||
WHERE e.cps = vBarcode
|
||||
OR e.batchNumber = vBarcode;
|
||||
|
||||
WHEN LENGTH(vBarcode) = vFloramondoBarcodeLength THEN
|
||||
INSERT INTO tmp.ekt
|
||||
SELECT e.id
|
||||
FROM edi.ektRecent e
|
||||
FROM ektRecent e
|
||||
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
|
||||
SET vBarcode = LPAD(vBarcode,vStandardBarcodeLength,'0');
|
||||
SET vBarcode = LPAD(vBarcode, vStandardBarcodeLength, '0');
|
||||
SET vAuction = MID(vBarcode, 1, 3);
|
||||
SET vKlo = MID(vBarcode, 4, 2);
|
||||
SET vFec = MAKEDATE(YEAR(util.VN_CURDATE()), MID(vBarcode, 6, 3));
|
||||
|
@ -69,21 +66,23 @@ BEGIN
|
|||
-- Clásico de subasta
|
||||
-- Trade standard
|
||||
-- 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
|
||||
SELECT id
|
||||
FROM ekt
|
||||
WHERE fec >= vFec - INTERVAL 1 DAY
|
||||
AND ((
|
||||
vKlo = vDefaultKlo
|
||||
AND (
|
||||
(vKlo = vDefaultKlo
|
||||
AND (klo = vKlo OR klo IS NULL OR klo = 0)
|
||||
AND agj IN (vShortAgj, vLongAgj, vXtraLongAgj))
|
||||
OR (klo = vKlo
|
||||
AND agj IN (vShortAgj, vLongAgj, vXtraLongAgj)
|
||||
) OR (
|
||||
klo = vKlo
|
||||
AND auction = vAuction
|
||||
AND agj = vShortAgj)
|
||||
AND agj = vShortAgj
|
||||
)
|
||||
)
|
||||
ORDER BY agj DESC, fec DESC
|
||||
LIMIT 1;
|
||||
ORDER BY agj DESC, fec DESC
|
||||
LIMIT 1;
|
||||
|
||||
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
|
||||
|
||||
|
@ -91,9 +90,11 @@ BEGIN
|
|||
IF NOT vIsFound THEN
|
||||
INSERT INTO tmp.ekt
|
||||
SELECT id
|
||||
FROM edi.ektRecent e
|
||||
WHERE e.batchNumber
|
||||
= LEFT(vBarcode,vUsefulAuctionLeftSegmentLength)
|
||||
FROM ektRecent e
|
||||
WHERE e.batchNumber = LEFT(
|
||||
vBarcode,
|
||||
vUsefulAuctionLeftSegmentLength
|
||||
)
|
||||
AND e.batchNumber > 0;
|
||||
|
||||
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
|
||||
|
@ -103,7 +104,7 @@ BEGIN
|
|||
IF NOT vIsFound THEN
|
||||
INSERT INTO tmp.ekt
|
||||
SELECT id
|
||||
FROM edi.ektRecent e
|
||||
FROM ektRecent e
|
||||
WHERE e.putOrderFk = vBarcode;
|
||||
|
||||
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
|
||||
|
@ -113,18 +114,28 @@ BEGIN
|
|||
IF NOT vIsFound THEN
|
||||
INSERT INTO tmp.ekt
|
||||
SELECT id
|
||||
FROM edi.ektRecent e
|
||||
WHERE e.deliveryNumber
|
||||
= MID(vBarcode, 4, 13)
|
||||
FROM ektRecent e
|
||||
WHERE e.deliveryNumber = MID(vBarcode, 4, 13)
|
||||
AND e.deliveryNumber > 0;
|
||||
|
||||
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
|
||||
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;
|
||||
|
||||
IF vIsFound THEN
|
||||
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;
|
||||
END IF;
|
||||
END$$
|
||||
|
|
|
@ -40,19 +40,28 @@ proc:BEGIN
|
|||
postalCode,
|
||||
`type`,
|
||||
image,
|
||||
description
|
||||
description,
|
||||
addressFk
|
||||
)
|
||||
SELECT i.name,
|
||||
i.`size`,
|
||||
i.id,
|
||||
SELECT CONCAT(i.name, ' by ',a.nickname),
|
||||
r.price + apc.deliveryCost,
|
||||
r.itemFk,
|
||||
vLanded,
|
||||
vPostalCode,
|
||||
it.name,
|
||||
CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image),
|
||||
i.description
|
||||
i.description,
|
||||
apc.addressFk
|
||||
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
|
||||
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 *
|
||||
FROM catalogue
|
||||
|
|
|
@ -13,8 +13,17 @@ BEGIN
|
|||
/**
|
||||
* 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$$
|
||||
DELIMITER ;
|
|
@ -21,7 +21,7 @@ BEGIN
|
|||
apc.dayOfWeek - vCurrentDayOfWeek,
|
||||
7 - apc.dayOfWeek
|
||||
) DAY nextDay,
|
||||
NOW() + INTERVAL apc.hoursInAdvance - 12 HOUR minDeliveryTime
|
||||
NOW() + INTERVAL apc.hoursInAdvance HOUR minDeliveryTime
|
||||
FROM addressPostCode apc
|
||||
WHERE apc.postCode = vPostalCode
|
||||
HAVING nextDay > minDeliveryTime) sub;
|
||||
|
|
|
@ -1,25 +1,167 @@
|
|||
DROP PROCEDURE IF EXISTS floranet.order_confirm;
|
||||
|
||||
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
|
||||
|
||||
BEGIN
|
||||
/** Update order.isPaid field.
|
||||
proc:BEGIN
|
||||
/** Update order.isPaid field, and makes the ticket
|
||||
*
|
||||
* @param vCatalogueFk floranet.catalogue.id
|
||||
*
|
||||
* @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`
|
||||
SET isPaid = TRUE,
|
||||
payed = NOW()
|
||||
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`
|
||||
WHERE catalogueFk = vCatalogueFk;
|
||||
|
||||
COMMIT;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -7,7 +7,7 @@ BEGIN
|
|||
*
|
||||
* @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')),
|
||||
customerName = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.customerName')),
|
||||
email = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.email')),
|
||||
|
@ -15,7 +15,8 @@ BEGIN
|
|||
message= JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.message')),
|
||||
deliveryName = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryName')),
|
||||
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;
|
||||
END$$
|
||||
|
|
|
@ -9,12 +9,11 @@ BEGIN
|
|||
* Returns list of url for sliders.
|
||||
*/
|
||||
SELECT
|
||||
CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image) url,
|
||||
i.longName
|
||||
FROM vn.item i
|
||||
JOIN vn.itemType it ON it.id = i.typeFk
|
||||
WHERE it.code IN ('FNR','FNP')
|
||||
LIMIT 3;
|
||||
|
||||
CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image) url,
|
||||
i.longName
|
||||
FROM vn.item i
|
||||
JOIN vn.itemType it ON it.id = i.typeFk
|
||||
WHERE it.code IN ('FNR','FNP')
|
||||
LIMIT 3;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -81,7 +81,7 @@ BEGIN
|
|||
|
||||
-- Código redundante
|
||||
|
||||
DO vn.till_new(
|
||||
CALL vn.till_new(
|
||||
vCustomer
|
||||
,vBank
|
||||
,vAmount / 100
|
||||
|
|
|
@ -12,7 +12,7 @@ AS SELECT `s`.`user_id` AS `id`,
|
|||
`c`.`permit` AS `permit`,
|
||||
`c`.`type` AS `type`,
|
||||
`c`.`context` AS `context`,
|
||||
`c`.`incomingLimit` AS `incominglimit`,
|
||||
`c`.`call-limit` AS `call-limit`,
|
||||
`c`.`pickupGroup` AS `pickupgroup`,
|
||||
`c`.`directMedia` AS `directmedia`,
|
||||
`c`.`insecure` AS `insecure`,
|
||||
|
|
|
@ -15,14 +15,14 @@ BEGIN
|
|||
|
||||
DECLARE vDayMinute INT;
|
||||
|
||||
SELECT HOUR(IFNULL(et.ETD, z.`hour`)) * 60 + MINUTE(IFNULL(et.ETD, z.`hour`)) INTO vDayMinute
|
||||
SELECT HOUR(IFNULL(rs.ETD, z.`hour`)) * 60 + MINUTE(IFNULL(rs.ETD, z.`hour`)) INTO vDayMinute
|
||||
FROM vn.expedition e
|
||||
JOIN vn.ticket t ON e.ticketFk = t.id
|
||||
JOIN vn.`zone` z ON z.id = t.zoneFk
|
||||
LEFT JOIN vn.route r ON r.id = t.routeFk
|
||||
LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk
|
||||
LEFT JOIN vn.routesMonitor rm ON t.routeFk = rm.routeFk
|
||||
LEFT JOIN vn.expeditionTruck et ON rm.expeditionTruckFk = et.id
|
||||
LEFT JOIN vn.roadmapStop rs ON rm.expeditionTruckFk = rs.id
|
||||
WHERE e.id = vExpeditionFk;
|
||||
|
||||
RETURN vDayMinute;
|
||||
|
|
|
@ -296,8 +296,8 @@ BEGIN
|
|||
|
||||
SET @dm := (24 * 60) - 10;
|
||||
|
||||
UPDATE vn.expeditionTruck et
|
||||
SET et.eta = timestampadd(MINUTE ,@dm := 1 + @dm,util.VN_CURDATE())
|
||||
UPDATE vn.roadmapStop rs
|
||||
SET rs.eta = timestampadd(MINUTE ,@dm := 1 + @dm,util.VN_CURDATE())
|
||||
WHERE description LIKE 'PRU%' ;
|
||||
|
||||
DELETE FROM srt.movingLog ;
|
||||
|
|
|
@ -3,10 +3,10 @@ CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|||
VIEW `srt`.`bufferDayMinute`
|
||||
AS SELECT `b`.`id` AS `bufferFk`,
|
||||
`e`.`id` AS `expeditionFk`,
|
||||
`srt`.`dayMinute`(IFNULL(`et`.`eta`, `z`.`hour`)) AS `dayMinute`,
|
||||
`srt`.`dayMinute`(IFNULL(`rs`.`eta`, `z`.`hour`)) AS `dayMinute`,
|
||||
`e`.`position` AS `position`,
|
||||
IFNULL(
|
||||
`et`.`eta`,
|
||||
`rs`.`eta`,
|
||||
`util`.`VN_CURDATE`() + INTERVAL `srt`.`dayMinute`(`z`.`hour`) MINUTE
|
||||
) AS `ETD`,
|
||||
`e2`.`ticketFk` AS `ticketFk`,
|
||||
|
@ -34,7 +34,7 @@ FROM (
|
|||
)
|
||||
LEFT JOIN `vn`.`routesMonitor` `rm` ON(`t`.`routeFk` = `rm`.`routeFk`)
|
||||
)
|
||||
LEFT JOIN `vn`.`expeditionTruck` `et` ON(`rm`.`expeditionTruckFk` = `et`.`id`)
|
||||
LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`expeditionTruckFk` = `rs`.`id`)
|
||||
)
|
||||
LEFT JOIN `vn`.`zone` `z` ON(`z`.`id` = `t`.`zoneFk`)
|
||||
)
|
||||
|
|
|
@ -4,22 +4,22 @@ CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|||
AS SELECT `e`.`id` AS `expeditionFk`,
|
||||
`e`.`bufferFk` AS `bufferFk`,
|
||||
`e`.`position` AS `position`,
|
||||
`srt`.`dayMinute`(IFNULL(`et`.`eta`, `z`.`hour`)) AS `dayMinute`,
|
||||
`srt`.`dayMinute`(IFNULL(`rs`.`eta`, `z`.`hour`)) AS `dayMinute`,
|
||||
IFNULL(
|
||||
`et`.`eta`,
|
||||
`rs`.`eta`,
|
||||
`util`.`VN_CURDATE`() + INTERVAL `srt`.`dayMinute`(`z`.`hour`) + 120 MINUTE
|
||||
) AS `eta`,
|
||||
`ve`.`ticketFk` AS `ticketFk`,
|
||||
IFNULL(`t`.`routeFk`, `t`.`agencyModeFk`) AS `routeFk`,
|
||||
`z`.`name` AS `zonaTicket`,
|
||||
`et`.`description` AS `truck`,
|
||||
`rs`.`description` AS `truck`,
|
||||
`es`.`description` AS `expeditionState`,
|
||||
`b`.`hasWorkerWaiting` AS `hasWorkerWaiting`,
|
||||
`b`.`isActive` AS `isActive`,
|
||||
IF(
|
||||
`et`.`id` IS NULL,
|
||||
`rs`.`id` IS NULL,
|
||||
`c`.`bufferDefault`,
|
||||
`et`.`bufferFk`
|
||||
`rs`.`bufferFk`
|
||||
) AS `bufferTruck`,
|
||||
`bt`.`typeName` AS `typeName`,
|
||||
`rm`.`bufferFk` AS `routeBuffer`
|
||||
|
@ -45,7 +45,7 @@ FROM (
|
|||
)
|
||||
LEFT JOIN `vn`.`routesMonitor` `rm` ON(`t`.`routeFk` = `rm`.`routeFk`)
|
||||
)
|
||||
LEFT JOIN `vn`.`expeditionTruck` `et` ON(`rm`.`expeditionTruckFk` = `et`.`id`)
|
||||
LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`expeditionTruckFk` = `rs`.`id`)
|
||||
)
|
||||
JOIN `srt`.`config` `c`
|
||||
)
|
||||
|
|
|
@ -4,13 +4,13 @@ CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|||
AS SELECT `e`.`id` AS `expeditionFk`,
|
||||
`e`.`id` MOD 10000 AS `expedition`,
|
||||
IFNULL(
|
||||
`et`.`eta`,
|
||||
`rs`.`eta`,
|
||||
`util`.`VN_CURDATE`() + INTERVAL `srt`.`dayMinute`(`z`.`hour`) + 120 MINUTE
|
||||
) AS `ETD`,
|
||||
`ve`.`ticketFk` AS `ticketFk`,
|
||||
right(IFNULL(`t`.`routeFk`, `t`.`agencyModeFk`), 3) AS `routeFk`,
|
||||
`z`.`name` AS `zonaTicket`,
|
||||
`et`.`description` AS `truck`,
|
||||
`rs`.`description` AS `truck`,
|
||||
`epo`.`workerCode` AS `worker`,
|
||||
`p`.`name` AS `labeler`,
|
||||
`ve`.`counter` AS `expeditionCounter`,
|
||||
|
@ -32,7 +32,7 @@ FROM (
|
|||
)
|
||||
LEFT JOIN `vn`.`routesMonitor` `rm` ON(`t`.`routeFk` = `rm`.`routeFk`)
|
||||
)
|
||||
LEFT JOIN `vn`.`expeditionTruck` `et` ON(`rm`.`expeditionTruckFk` = `et`.`id`)
|
||||
LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`expeditionTruckFk` = `rs`.`id`)
|
||||
)
|
||||
JOIN `dipole`.`expedition_PrintOut` `epo` ON(`epo`.`expeditionFk` = `e`.`id`)
|
||||
)
|
||||
|
|
|
@ -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 ;
|
|
@ -1,21 +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
|
||||
SET u.active = FALSE
|
||||
WHERE c.typeFk = 'normal'
|
||||
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 2 MONTH
|
||||
OR shipped > util.VN_CURDATE() - INTERVAL 2 MONTH
|
||||
);
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -11,10 +11,7 @@ BEGIN
|
|||
*/
|
||||
DECLARE vClient INT DEFAULT NULL;
|
||||
|
||||
-- SET vPhone = vPhone COLLATE 'utf8_unicode_ci';
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tClient;
|
||||
CREATE TEMPORARY TABLE tClient
|
||||
CREATE OR REPLACE TEMPORARY TABLE tClient
|
||||
ENGINE = MEMORY
|
||||
SELECT id clientFk
|
||||
FROM `client`
|
||||
|
@ -27,13 +24,14 @@ BEGIN
|
|||
OR mobile = vPhone
|
||||
UNION
|
||||
SELECT clientFk
|
||||
FROM vn.clientContact
|
||||
FROM clientContact
|
||||
WHERE phone = vPhone;
|
||||
|
||||
SELECT t.clientFk INTO vClient
|
||||
FROM tClient t
|
||||
JOIN `client` c ON c.id = t.clientFk
|
||||
WHERE c.isActive
|
||||
AND c.salesPersonFk
|
||||
LIMIT 1;
|
||||
|
||||
DROP TEMPORARY TABLE tClient;
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`sale_hasComponentLack`(
|
||||
vSelf INT
|
||||
)RETURNS tinyint(1)
|
||||
READS SQL DATA
|
||||
BEGIN
|
||||
/**
|
||||
* Check if a sales line has all the required components.
|
||||
*
|
||||
* @param vSelf Id de sale
|
||||
* @return BOOL
|
||||
*/
|
||||
DECLARE vHasComponentLack TINYINT(1);
|
||||
|
||||
WITH componentRequired AS(
|
||||
SELECT COUNT(*) total
|
||||
FROM vn.component
|
||||
WHERE isRequired
|
||||
)SELECT SUM(IF(c.isRequired, TRUE, FALSE)) <> cr.total INTO vHasComponentLack
|
||||
FROM vn.sale s
|
||||
JOIN componentRequired cr
|
||||
LEFT JOIN vn.saleComponent sc ON sc.saleFk = s.id
|
||||
LEFT JOIN vn.component c ON c.id = sc.componentFk
|
||||
WHERE s.id = vSelf;
|
||||
|
||||
RETURN vHasComponentLack;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,25 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ticket_isTooLittle`(
|
||||
vSelf INT
|
||||
)
|
||||
RETURNS tinyint(1)
|
||||
READS SQL DATA
|
||||
BEGIN
|
||||
/**
|
||||
* Check if the ticket is small based on the volume and amount parameters.
|
||||
*
|
||||
* @param vSelf Id ticket
|
||||
* @return BOOL
|
||||
*/
|
||||
DECLARE vIsTooLittle TINYINT(1);
|
||||
|
||||
SELECT (SUM(IFNULL(sv.litros, 0)) < vc.minTicketVolume
|
||||
OR IFNULL(t.totalWithoutVat, 0) < vc.minTicketValue) INTO vIsTooLittle
|
||||
FROM ticket t
|
||||
LEFT JOIN saleVolume sv ON sv.ticketFk = t.id
|
||||
JOIN volumeConfig vc
|
||||
WHERE t.id = vSelf;
|
||||
|
||||
RETURN vIsTooLittle;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,79 +1,73 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`till_new`(vClient INT
|
||||
,vBank INT
|
||||
,vAmount DOUBLE
|
||||
,vConcept VARCHAR(25)
|
||||
,vDated DATE
|
||||
,vSerie CHAR(1)
|
||||
,vBatch TINYINT
|
||||
,vNumber INT
|
||||
,vCompany SMALLINT
|
||||
,vWorker INT
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`till_new`(
|
||||
vClient INT,
|
||||
vBank INT,
|
||||
vAmount DOUBLE,
|
||||
vConcept VARCHAR(25),
|
||||
vDated DATE,
|
||||
vSerie CHAR(1),
|
||||
vBatch TINYINT,
|
||||
vNumber INT,
|
||||
vCompany SMALLINT,
|
||||
vWorker INT
|
||||
)
|
||||
RETURNS int(11)
|
||||
DETERMINISTIC
|
||||
BEGIN
|
||||
DECLARE vAccount VARCHAR(12);
|
||||
DECLARE vSubaccount VARCHAR(12);
|
||||
DECLARE vAsiento INT DEFAULT NULL;
|
||||
|
||||
-- Inserta el registro en cajas
|
||||
|
||||
INSERT INTO till
|
||||
SET
|
||||
workerFk = vWorker
|
||||
,bankFk = vBank
|
||||
,`in` = vAmount
|
||||
,concept = vConcept
|
||||
,dated = vDated
|
||||
,serie = vSerie
|
||||
,isAccountable = vBatch
|
||||
,`number` = vNumber
|
||||
,companyFk = vCompany;
|
||||
workerFk = vWorker,
|
||||
bankFk = vBank,
|
||||
`in` = vAmount,
|
||||
concept = vConcept,
|
||||
dated = vDated,
|
||||
serie = vSerie,
|
||||
isAccountable = vBatch,
|
||||
`number` = vNumber,
|
||||
companyFk = vCompany;
|
||||
|
||||
-- Inserta los asientos contables
|
||||
|
||||
SELECT account INTO vAccount
|
||||
FROM accounting WHERE id = vBank;
|
||||
|
||||
SELECT accountingAccount INTO vSubaccount
|
||||
FROM `client` WHERE id = vClient;
|
||||
|
||||
SET vAsiento = xdiario_new
|
||||
(
|
||||
vAsiento
|
||||
,vDated
|
||||
,vAccount
|
||||
,vSubaccount
|
||||
,vConcept
|
||||
,vAmount
|
||||
,0
|
||||
,0
|
||||
,NULL -- Serie
|
||||
,NULL -- Factura
|
||||
,NULL -- IVA
|
||||
,NULL -- Recargo
|
||||
,FALSE -- Auxiliar
|
||||
,vCompany
|
||||
);
|
||||
DO xdiario_new
|
||||
(
|
||||
vAsiento
|
||||
,vDated
|
||||
,vSubaccount
|
||||
,vAccount
|
||||
,vConcept
|
||||
,0
|
||||
,vAmount
|
||||
,0
|
||||
,NULL -- Serie
|
||||
,NULL -- Factura
|
||||
,NULL -- IVA
|
||||
,NULL -- Recargo
|
||||
,FALSE -- Auxiliar
|
||||
,vCompany
|
||||
);
|
||||
CALL xdiario_new(
|
||||
vAsiento,
|
||||
vDated,
|
||||
vAccount,
|
||||
vSubaccount,
|
||||
vConcept,
|
||||
vAmount,
|
||||
0,
|
||||
0,
|
||||
NULL, -- Serie
|
||||
NULL, -- Factura
|
||||
NULL, -- IVA
|
||||
NULL, -- Recargo
|
||||
FALSE, -- Auxiliar
|
||||
vCompany,
|
||||
vAsiento);
|
||||
|
||||
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$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`xdiario_new`(vAsiento 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,
|
||||
vCompany INT
|
||||
)
|
||||
RETURNS int(11)
|
||||
NOT DETERMINISTIC
|
||||
NO SQL
|
||||
BEGIN
|
||||
IF vAsiento IS NULL THEN
|
||||
CALL vn.ledger_next(vAsiento);
|
||||
END IF;
|
||||
|
||||
INSERT INTO XDiario
|
||||
SET ASIEN = vAsiento,
|
||||
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 = vCompany;
|
||||
|
||||
RETURN vAsiento;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -9,7 +9,7 @@ BEGIN
|
|||
DECLARE vEnded DATETIME DEFAULT util.dayEnd(util.VN_CURDATE());
|
||||
|
||||
SELECT ag.id agency_id,
|
||||
CONCAT(RPAD(c.country, 16,' _') ,' ',ag.name) Agencia,
|
||||
CONCAT(RPAD(c.name, 16,' _') ,' ',ag.name) Agencia,
|
||||
COUNT(*) expediciones,
|
||||
SUM(t.packages) Bultos,
|
||||
SUM(tpe.boxes) Faltan
|
||||
|
|
|
@ -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 ;
|
|
@ -10,7 +10,7 @@ BEGIN
|
|||
*/
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc;
|
||||
|
||||
CREATE TEMPORARY TABLE tmp.buyRecalc
|
||||
CREATE TEMPORARY TABLE tmp.buyRecalc
|
||||
SELECT vBuyFk id;
|
||||
|
||||
CALL buy_recalcPrices();
|
||||
|
|
|
@ -86,7 +86,7 @@ BEGIN
|
|||
WHERE cs.description = 'Anulado'
|
||||
AND c.created < v2Months;
|
||||
|
||||
DELETE FROM expeditionTruck WHERE eta < v3Months;
|
||||
DELETE FROM roadmapStop WHERE eta < v3Months;
|
||||
DELETE FROM XDiario WHERE FECHA < v3Months OR FECHA IS NULL;
|
||||
|
||||
-- Borrar travels sin entradas
|
||||
|
|
|
@ -22,7 +22,7 @@ BEGIN
|
|||
c.credit,
|
||||
CAST(r.risk AS DECIMAL (10,2)) risk,
|
||||
CAST(c.credit - r.risk AS DECIMAL (10,2)) difference,
|
||||
co.country
|
||||
co.name country
|
||||
FROM client c
|
||||
JOIN tmp.risk r ON r.clientFk = c.id
|
||||
JOIN country co ON co.id = c.countryFk
|
||||
|
|
|
@ -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 ;
|
|
@ -13,24 +13,12 @@ BEGIN
|
|||
* @param vCollectionFk Id de colección
|
||||
*/
|
||||
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
|
||||
CALL collection_get(vUserFk);
|
||||
|
||||
SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0 INTO vHasTooMuchCollections
|
||||
SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0
|
||||
INTO vHasTooMuchCollections
|
||||
FROM productionConfig pc
|
||||
LEFT JOIN tCollection ON TRUE;
|
||||
|
||||
|
@ -40,21 +28,6 @@ BEGIN
|
|||
CALL util.throw('Hay colecciones pendientes');
|
||||
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
|
||||
INSERT INTO ticketTracking(stateFk, ticketFk)
|
||||
SELECT s.id, tc.ticketFk
|
||||
|
@ -62,7 +35,7 @@ BEGIN
|
|||
JOIN ticketCollection tc ON tc.collectionFk = c.id
|
||||
JOIN `state` s ON s.code = 'PRINTED_AUTO'
|
||||
JOIN productionConfig pc
|
||||
WHERE c.workerFk IS NULL
|
||||
WHERE c.workerFk IS NULL
|
||||
AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime;
|
||||
|
||||
DELETE c.*
|
||||
|
@ -76,8 +49,7 @@ BEGIN
|
|||
VALUES(vUserFk);
|
||||
|
||||
-- Comprueba si hay colecciones disponibles que se ajustan a su configuracion
|
||||
SELECT MIN(c.id)
|
||||
INTO vCollectionFk
|
||||
SELECT MIN(c.id) INTO vCollectionFk
|
||||
FROM `collection` c
|
||||
JOIN operator o
|
||||
ON (o.itemPackingTypeFk = c.itemPackingTypeFk OR c.itemPackingTypeFk IS NULL)
|
||||
|
@ -103,7 +75,5 @@ BEGIN
|
|||
UPDATE `collection`
|
||||
SET workerFk = vUserFk
|
||||
WHERE id = vCollectionFk;
|
||||
|
||||
DO RELEASE_LOCK(vLockName);
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -49,6 +49,7 @@ BEGIN
|
|||
BEGIN
|
||||
IF vLockName IS NOT NULL THEN
|
||||
DO RELEASE_LOCK(vLockName);
|
||||
CALL util.debugAdd('releaseLock', vLockName); -- Tmp
|
||||
END IF;
|
||||
|
||||
RESIGNAL;
|
||||
|
|
|
@ -24,7 +24,7 @@ BEGIN
|
|||
10 * p.height as height,
|
||||
IFNULL(t.routeFk,am.agencyFk) routeFk,
|
||||
hour(e.created) * 60 + minute(e.created),
|
||||
IFNULL(et.description , a.name),
|
||||
IFNULL(rs.description , a.name),
|
||||
IFNULL(t.routeFk,am.agencyFk) criterion,
|
||||
IFNULL(p.conveyorBuildingClassFk , pc.defaultConveyorBuildingClass)
|
||||
FROM vn.expedition e
|
||||
|
@ -34,7 +34,7 @@ BEGIN
|
|||
LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
|
||||
LEFT JOIN vn.agency a ON a.id = am.agencyFk
|
||||
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk
|
||||
LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk
|
||||
LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk
|
||||
JOIN vn.packagingConfig pc
|
||||
WHERE t.warehouseFk IN (60,1,44)
|
||||
AND e.created BETWEEN vStarted AND vEnded
|
||||
|
|
|
@ -27,7 +27,7 @@ BEGIN
|
|||
cac.invoiced billedAnnually,
|
||||
c.dueDay,
|
||||
cgd.grade,
|
||||
c2.country
|
||||
c2.name country
|
||||
FROM tmp.clientGetDebt cgd
|
||||
LEFT JOIN tmp.risk r ON r.clientFk = cgd.clientFk
|
||||
JOIN client c ON c.id = cgd.clientFk
|
||||
|
|
|
@ -6,12 +6,12 @@ BEGIN
|
|||
*
|
||||
* @param vDuaFk Id del dua a recalcular
|
||||
*/
|
||||
DECLARE done BOOL DEFAULT FALSE;
|
||||
DECLARE vDone BOOL DEFAULT FALSE;
|
||||
DECLARE vInvoiceFk INT;
|
||||
DECLARE vASIEN BIGINT DEFAULT 0;
|
||||
DECLARE vCounter INT DEFAULT 0;
|
||||
DECLARE vBookEntry INT;
|
||||
DECLARE vFiscalYear INT;
|
||||
|
||||
DECLARE rs CURSOR FOR
|
||||
DECLARE vInvoicesIn CURSOR FOR
|
||||
SELECT DISTINCT e.invoiceInFk
|
||||
FROM entry e
|
||||
JOIN duaEntry de ON de.entryFk = e.id
|
||||
|
@ -20,9 +20,7 @@ BEGIN
|
|||
AND de.customsValue
|
||||
AND ii.isBooked = FALSE;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
|
||||
|
||||
OPEN rs;
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
UPDATE invoiceIn ii
|
||||
JOIN entry e ON e.invoiceInFk = ii.id
|
||||
|
@ -36,38 +34,36 @@ BEGIN
|
|||
e.isConfirmed = TRUE
|
||||
WHERE d.id = vDuaFk;
|
||||
|
||||
SELECT IFNULL(ASIEN,0) INTO vASIEN
|
||||
FROM dua
|
||||
WHERE id = vDuaFk;
|
||||
SELECT ASIEN INTO vBookEntry 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_next(vFiscalYear, FALSE, vBookEntry);
|
||||
END IF;
|
||||
|
||||
WHILE NOT done DO
|
||||
OPEN vInvoicesIn;
|
||||
|
||||
CALL invoiceIn_booking(vInvoiceFk);
|
||||
|
||||
IF vCounter > 0 OR vASIEN > 0 THEN
|
||||
|
||||
UPDATE XDiario x
|
||||
JOIN ledgerConfig lc ON lc.lastBookEntry = x.ASIEN
|
||||
SET x.ASIEN = vASIEN;
|
||||
|
||||
ELSE
|
||||
|
||||
SELECT lastBookEntry INTO vASIEN FROM ledgerConfig;
|
||||
l: LOOP
|
||||
SET vDone = FALSE;
|
||||
FETCH vInvoicesIn INTO vInvoiceFk;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE l;
|
||||
END IF;
|
||||
|
||||
SET vCounter = vCounter + 1;
|
||||
CALL invoiceIn_booking(vInvoiceFk, vBookEntry);
|
||||
END LOOP;
|
||||
|
||||
FETCH rs INTO vInvoiceFk;
|
||||
|
||||
END WHILE;
|
||||
|
||||
CLOSE rs;
|
||||
CLOSE vInvoicesIn;
|
||||
|
||||
UPDATE dua
|
||||
SET ASIEN = vASIEN
|
||||
SET ASIEN = vBookEntry
|
||||
WHERE id = vDuaFk;
|
||||
|
||||
UPDATE invoiceIn ii
|
||||
|
|
|
@ -2,127 +2,121 @@ DELIMITER $$
|
|||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`duaTaxBooking`(vDuaFk INT)
|
||||
BEGIN
|
||||
DECLARE vBookNumber INT;
|
||||
DECLARE vBookDated DATE;
|
||||
DECLARE vDiff DECIMAL(10,2);
|
||||
DECLARE vApunte BIGINT;
|
||||
|
||||
SELECT ASIEN, IFNULL(bookEntried, util.VN_CURDATE()) INTO vBookNumber, vBookDated
|
||||
FROM dua
|
||||
DECLARE vBookDated DATE;
|
||||
DECLARE vDiff DECIMAL(10,2);
|
||||
DECLARE vApunte BIGINT;
|
||||
|
||||
SELECT ASIEN, IFNULL(bookEntried, util.VN_CURDATE())
|
||||
INTO vBookNumber, vBookDated
|
||||
FROM dua
|
||||
WHERE id = vDuaFk;
|
||||
|
||||
|
||||
IF vBookNumber IS NULL OR NOT vBookNumber THEN
|
||||
CALL ledger_next(vBookNumber);
|
||||
CALL ledger_next(YEAR(vBookDated), FALSE, vBookNumber);
|
||||
END IF;
|
||||
|
||||
-- Apunte de la aduana
|
||||
|
||||
INSERT INTO XDiario(
|
||||
ASIEN,
|
||||
FECHA,
|
||||
SUBCTA,
|
||||
CONCEPTO,
|
||||
EUROHABER,
|
||||
SERIE,
|
||||
empresa_id,
|
||||
CLAVE,
|
||||
FACTURA)
|
||||
ASIEN,
|
||||
FECHA,
|
||||
SUBCTA,
|
||||
CONCEPTO,
|
||||
EUROHABER,
|
||||
SERIE,
|
||||
empresa_id,
|
||||
CLAVE,
|
||||
FACTURA)
|
||||
SELECT vBookNumber,
|
||||
d.bookEntried,
|
||||
'4700000999',
|
||||
CONCAT('DUA ',d.`code`),
|
||||
sum(dt.base * dt.rate / 100) EUROHABER,
|
||||
'R',
|
||||
d.companyFk,
|
||||
vDuaFk,
|
||||
vDuaFk
|
||||
FROM duaTax dt
|
||||
JOIN dua d ON d.id = dt.duaFk
|
||||
WHERE dt.duaFk = vDuaFk;
|
||||
|
||||
SELECT
|
||||
vBookNumber,
|
||||
d.bookEntried,
|
||||
'4700000999',
|
||||
CONCAT('DUA ',d.`code`),
|
||||
sum(dt.base * dt.rate / 100) EUROHABER,
|
||||
'R',
|
||||
d.companyFk,
|
||||
vDuaFk,
|
||||
vDuaFk
|
||||
FROM duaTax dt
|
||||
JOIN dua d ON d.id = dt.duaFk
|
||||
WHERE dt.duaFk = vDuaFk;
|
||||
|
||||
-- Apuntes por tipo de IVA y proveedor
|
||||
|
||||
INSERT INTO XDiario(
|
||||
ASIEN,
|
||||
FECHA,
|
||||
SUBCTA,
|
||||
CONTRA,
|
||||
EURODEBE,
|
||||
BASEEURO,
|
||||
CONCEPTO,
|
||||
FACTURA,
|
||||
IVA,
|
||||
AUXILIAR,
|
||||
SERIE,
|
||||
FECHA_EX,
|
||||
FECHA_OP,
|
||||
FACTURAEX,
|
||||
NFACTICK,
|
||||
L340,
|
||||
LDIFADUAN,
|
||||
TIPOCLAVE,
|
||||
TIPOEXENCI,
|
||||
TIPONOSUJE,
|
||||
TIPOFACT,
|
||||
TIPORECTIF,
|
||||
TERIDNIF,
|
||||
TERNIF,
|
||||
TERNOM,
|
||||
empresa_id,
|
||||
FECREGCON
|
||||
)
|
||||
|
||||
SELECT
|
||||
vBookNumber ASIEN,
|
||||
vBookDated FECHA,
|
||||
tr.account SUBCTA,
|
||||
'4330002067' CONTRA,
|
||||
sum(dt.tax) EURODEBE,
|
||||
sum(dt.base) BASEEURO,
|
||||
CONCAT('DUA nº',d.code) CONCEPTO,
|
||||
d.id FACTURA,
|
||||
dt.rate IVA,
|
||||
'*' AUXILIAR,
|
||||
'D' SERIE,
|
||||
d.issued FECHA_EX,
|
||||
d.operated FECHA_OP,
|
||||
d.code FACTURAEX,
|
||||
1 NFACTICK,
|
||||
1 L340,
|
||||
TRUE LDIFADUAN,
|
||||
1 TIPOCLAVE,
|
||||
1 TIPOEXENCI,
|
||||
1 TIPONOSUJE,
|
||||
5 TIPOFACT,
|
||||
1 TIPORECTIF,
|
||||
IF(c.code = 'ES', 1, 4) TERIDNIF,
|
||||
s.nif TERNIF,
|
||||
s.name TERNOM,
|
||||
d.companyFk,
|
||||
d.booked FECREGCON
|
||||
FROM duaTax dt
|
||||
JOIN dua d ON dt.duaFk = d.id
|
||||
JOIN (SELECT account, rate
|
||||
FROM
|
||||
(SELECT rate, account
|
||||
FROM invoiceInTaxBookingAccount ta
|
||||
WHERE ta.effectived <= vBookDated
|
||||
AND taxAreaFk = 'WORLD'
|
||||
ORDER BY ta.effectived DESC
|
||||
LIMIT 10000000000000000000
|
||||
) tba
|
||||
GROUP BY rate
|
||||
-- Apuntes por tipo de IVA y proveedor
|
||||
INSERT INTO XDiario(
|
||||
ASIEN,
|
||||
FECHA,
|
||||
SUBCTA,
|
||||
CONTRA,
|
||||
EURODEBE,
|
||||
BASEEURO,
|
||||
CONCEPTO,
|
||||
FACTURA,
|
||||
IVA,
|
||||
AUXILIAR,
|
||||
SERIE,
|
||||
FECHA_EX,
|
||||
FECHA_OP,
|
||||
FACTURAEX,
|
||||
NFACTICK,
|
||||
L340,
|
||||
LDIFADUAN,
|
||||
TIPOCLAVE,
|
||||
TIPOEXENCI,
|
||||
TIPONOSUJE,
|
||||
TIPOFACT,
|
||||
TIPORECTIF,
|
||||
TERIDNIF,
|
||||
TERNIF,
|
||||
TERNOM,
|
||||
empresa_id,
|
||||
FECREGCON)
|
||||
SELECT vBookNumber ASIEN,
|
||||
vBookDated FECHA,
|
||||
tr.account SUBCTA,
|
||||
'4330002067' CONTRA,
|
||||
SUM(dt.tax) EURODEBE,
|
||||
SUM(dt.base) BASEEURO,
|
||||
CONCAT('DUA nº',d.code) CONCEPTO,
|
||||
d.id FACTURA,
|
||||
dt.rate IVA,
|
||||
'*' AUXILIAR,
|
||||
'D' SERIE,
|
||||
d.issued FECHA_EX,
|
||||
d.operated FECHA_OP,
|
||||
d.code FACTURAEX,
|
||||
1 NFACTICK,
|
||||
1 L340,
|
||||
TRUE LDIFADUAN,
|
||||
1 TIPOCLAVE,
|
||||
1 TIPOEXENCI,
|
||||
1 TIPONOSUJE,
|
||||
5 TIPOFACT,
|
||||
1 TIPORECTIF,
|
||||
IF(c.code = 'ES', 1, 4) TERIDNIF,
|
||||
s.nif TERNIF,
|
||||
s.name TERNOM,
|
||||
d.companyFk,
|
||||
d.booked FECREGCON
|
||||
FROM duaTax dt
|
||||
JOIN dua d ON dt.duaFk = d.id
|
||||
JOIN (SELECT account, rate
|
||||
FROM
|
||||
(SELECT rate, account
|
||||
FROM invoiceInTaxBookingAccount ta
|
||||
WHERE ta.effectived <= vBookDated
|
||||
AND taxAreaFk = 'WORLD'
|
||||
ORDER BY ta.effectived DESC
|
||||
LIMIT 10000000000000000000
|
||||
) tba
|
||||
GROUP BY rate
|
||||
) tr ON tr.rate = dt.rate
|
||||
JOIN supplier s ON s.id = d.companyFk
|
||||
JOIN country c ON c.id = s.countryFk
|
||||
WHERE d.id = vDuaFk
|
||||
GROUP BY dt.rate;
|
||||
JOIN supplier s ON s.id = d.companyFk
|
||||
JOIN country c ON c.id = s.countryFk
|
||||
WHERE d.id = vDuaFk
|
||||
GROUP BY dt.rate;
|
||||
|
||||
SELECT SUM(EURODEBE) -SUM(EUROHABER), MAX(id) INTO vDiff, vApunte
|
||||
FROM XDiario
|
||||
WHERE ASIEN = vBookNumber;
|
||||
|
||||
|
||||
UPDATE XDiario
|
||||
SET BASEEURO = 100 * (EURODEBE - vDiff) / IVA,
|
||||
EURODEBE = EURODEBE - vDiff
|
||||
|
@ -131,6 +125,5 @@ BEGIN
|
|||
UPDATE dua
|
||||
SET ASIEN = vBookNumber
|
||||
WHERE id = vDuaFk;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -9,8 +9,8 @@ BEGIN
|
|||
* Clones an entry header.
|
||||
*
|
||||
* @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 vNewEntryFk The new entry id
|
||||
*/
|
||||
INSERT INTO entry(
|
||||
travelFk,
|
||||
|
|
|
@ -1,59 +1,18 @@
|
|||
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
|
||||
/**
|
||||
* Copies an entry buys to another buy.
|
||||
* Copies all buys from an entry to an entry.
|
||||
*
|
||||
* @param vSelf The entry id
|
||||
* @param vCopyTo The destination entry id
|
||||
* @param vDestinationEntryFk The destination entry id
|
||||
*/
|
||||
INSERT INTO buy(
|
||||
entryFk,
|
||||
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
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.buy
|
||||
SELECT id
|
||||
FROM buy
|
||||
WHERE entryFk = vSelf;
|
||||
|
||||
CALL buy_clone(vDestinationEntryFk);
|
||||
DROP TEMPORARY TABLE tmp.buy;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -26,7 +26,6 @@ BEGIN
|
|||
packing,
|
||||
`grouping`,
|
||||
groupingMode,
|
||||
containerFk,
|
||||
comissionValue,
|
||||
packageValue,
|
||||
location,
|
||||
|
@ -46,7 +45,6 @@ BEGIN
|
|||
packing,
|
||||
`grouping`,
|
||||
groupingMode,
|
||||
containerFk,
|
||||
comissionValue,
|
||||
packageValue,
|
||||
location,
|
||||
|
|
|
@ -56,7 +56,6 @@ BEGIN
|
|||
packing,
|
||||
`grouping`,
|
||||
groupingMode,
|
||||
containerFk,
|
||||
comissionValue,
|
||||
packageValue,
|
||||
packagingFk,
|
||||
|
@ -77,7 +76,6 @@ BEGIN
|
|||
packing,
|
||||
`grouping`,
|
||||
groupingMode,
|
||||
containerFk,
|
||||
comissionValue,
|
||||
packageValue,
|
||||
packagingFk,
|
||||
|
@ -114,7 +112,6 @@ BEGIN
|
|||
packing,
|
||||
`grouping`,
|
||||
groupingMode,
|
||||
containerFk,
|
||||
comissionValue,
|
||||
packageValue,
|
||||
location,
|
||||
|
@ -133,7 +130,6 @@ BEGIN
|
|||
packing,
|
||||
`grouping`,
|
||||
groupingMode,
|
||||
containerFk,
|
||||
comissionValue,
|
||||
packageValue,
|
||||
location,
|
||||
|
|
|
@ -76,7 +76,6 @@ BEGIN
|
|||
packing,
|
||||
`grouping`,
|
||||
groupingMode,
|
||||
containerFk,
|
||||
comissionValue,
|
||||
packageValue,
|
||||
location,
|
||||
|
@ -103,7 +102,6 @@ BEGIN
|
|||
packing,
|
||||
`grouping`,
|
||||
groupingMode,
|
||||
containerFk,
|
||||
comissionValue,
|
||||
packageValue,
|
||||
location,
|
||||
|
|
|
@ -2,7 +2,7 @@ DELIMITER $$
|
|||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionTruck_Add`(vHour VARCHAR(5), vDescription VARCHAR(45))
|
||||
BEGIN
|
||||
|
||||
INSERT INTO vn.expeditionTruck(eta,description)
|
||||
INSERT INTO vn.roadmapStop(eta,description)
|
||||
VALUES(CONCAT(util.VN_CURDATE(), ' ', vHour), vDescription);
|
||||
|
||||
END$$
|
||||
|
|
|
@ -4,9 +4,9 @@ BEGIN
|
|||
|
||||
SELECT id truckFk,
|
||||
eta,
|
||||
description Destino
|
||||
FROM expeditionTruck
|
||||
WHERE eta BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
|
||||
ORDER BY eta;
|
||||
description Destino
|
||||
FROM roadmapStop
|
||||
WHERE eta BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
|
||||
ORDER BY eta;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -53,8 +53,8 @@ BEGIN
|
|||
am.name zonaRuta,
|
||||
t.routeFk ruta,
|
||||
rm.beachFk ubicacion,
|
||||
et.eta ,
|
||||
et.description camion,
|
||||
rs.eta ,
|
||||
rs.description camion,
|
||||
vTicketsPendientes AS ticketsPendientes,
|
||||
vEtiquetasTotales AS etiquetasTotales,
|
||||
vEtiquetasEscaneadas AS etiquetasEscaneadas,
|
||||
|
@ -67,7 +67,7 @@ BEGIN
|
|||
LEFT JOIN vn.route r ON r.id = t.routeFk
|
||||
LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk
|
||||
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id
|
||||
LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk
|
||||
LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk
|
||||
WHERE e.id = vExpeditionFk;
|
||||
|
||||
END$$
|
||||
|
|
|
@ -37,8 +37,8 @@ BEGIN
|
|||
am.name zonaRuta,
|
||||
t.routeFk ruta,
|
||||
rm.beachFk ubicacion,
|
||||
et.eta ,
|
||||
et.description camion,
|
||||
rs.eta ,
|
||||
rs.description camion,
|
||||
vTicketsPendientes AS ticketsPendientes,
|
||||
vEtiquetasTotales AS etiquetasTotales,
|
||||
vEtiquetasEscaneadas AS etiquetasEscaneadas
|
||||
|
@ -50,7 +50,7 @@ BEGIN
|
|||
LEFT JOIN vn.route r ON r.id = t.routeFk
|
||||
LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk
|
||||
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id
|
||||
LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk
|
||||
LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk
|
||||
WHERE e.id = vExpeditionFk;
|
||||
|
||||
END$$
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInTax_getFromEntries`(IN vInvoiceInFk INT)
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInTax_getFromEntries`(
|
||||
IN vInvoiceInFk INT
|
||||
)
|
||||
BEGIN
|
||||
DECLARE vRate DOUBLE DEFAULT 1;
|
||||
DECLARE vDated DATE;
|
||||
DECLARE vExpenseFk VARCHAR(10);
|
||||
|
||||
SELECT MAX(rr.dated) INTO vDated
|
||||
FROM referenceRate rr
|
||||
JOIN invoiceIn ii ON ii.id = vInvoiceInFk
|
||||
WHERE rr.dated <= ii.issued
|
||||
AND rr.currencyFk = ii.currencyFk ;
|
||||
|
||||
IF vDated THEN
|
||||
SELECT `value` INTO vRate
|
||||
FROM referenceRate
|
||||
WHERE dated = vDated;
|
||||
END IF;
|
||||
WITH rate AS(
|
||||
SELECT MAX(rr.dated) dated, ii.currencyFk
|
||||
FROM vn.invoiceIn ii
|
||||
JOIN vn.referenceRate rr ON rr.currencyFk = ii.currencyFk
|
||||
WHERE ii.id = vInvoiceInFk
|
||||
AND rr.dated <= ii.issued
|
||||
) SELECT `value` INTO vRate
|
||||
FROM vn.referenceRate rr
|
||||
JOIN rate r ON r.dated = rr.dated
|
||||
AND r.currencyFk = rr.currencyFk;
|
||||
|
||||
SELECT id INTO vExpenseFk
|
||||
FROM vn.expense
|
||||
FROM expense
|
||||
WHERE `name` = 'Adquisición mercancia Extracomunitaria'
|
||||
GROUP BY id
|
||||
LIMIT 1;
|
||||
|
@ -26,19 +26,25 @@ BEGIN
|
|||
DELETE FROM invoiceInTax
|
||||
WHERE invoiceInFk = vInvoiceInFk;
|
||||
|
||||
INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenseFk, foreignValue, taxTypeSageFk, transactionTypeSageFk)
|
||||
SELECT ii.id,
|
||||
SUM(b.buyingValue * b.quantity) / IFNULL(vRate,1) taxableBase,
|
||||
vExpenseFk,
|
||||
IF(ii.currencyFk = 1,NULL,SUM(b.buyingValue * b.quantity )) divisa,
|
||||
taxTypeSageFk,
|
||||
INSERT INTO invoiceInTax(
|
||||
invoiceInFk,
|
||||
taxableBase,
|
||||
expenseFk,
|
||||
foreignValue,
|
||||
taxTypeSageFk,
|
||||
transactionTypeSageFk
|
||||
)SELECT ii.id,
|
||||
SUM(b.buyingValue * b.quantity) / vRate taxableBase,
|
||||
vExpenseFk,
|
||||
IF(ii.currencyFk = 1,
|
||||
NULL,
|
||||
SUM(b.buyingValue * b.quantity )),
|
||||
taxTypeSageFk,
|
||||
transactionTypeSageFk
|
||||
FROM invoiceIn ii
|
||||
JOIN entry e ON e.invoiceInFk = ii.id
|
||||
JOIN supplier s ON s.id = e.supplierFk
|
||||
JOIN buy b ON b.entryFk = e.id
|
||||
LEFT JOIN referenceRate rr ON rr.currencyFk = ii.currencyFk
|
||||
AND rr.dated = ii.issued
|
||||
WHERE ii.id = vInvoiceInFk
|
||||
HAVING taxableBase IS NOT NULL;
|
||||
END$$
|
||||
|
|
|
@ -1,7 +1,18 @@
|
|||
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
|
||||
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;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tInvoiceIn
|
||||
ENGINE = MEMORY
|
||||
|
@ -56,7 +67,11 @@ BEGIN
|
|||
LEFT JOIN sage.taxType tt ON tt.id = ti.CodigoIva
|
||||
WHERE ii.id = vSelf;
|
||||
|
||||
CALL vn.ledger_next(vBookNumber);
|
||||
SELECT YEAR(bookEntried) INTO vFiscalYear FROM tInvoiceIn LIMIT 1;
|
||||
|
||||
IF vBookNumber IS NULL THEN
|
||||
CALL ledger_next(vFiscalYear, FALSE, vBookNumber);
|
||||
END IF;
|
||||
|
||||
-- Apunte del proveedor
|
||||
INSERT INTO XDiario(
|
||||
|
@ -185,7 +200,7 @@ BEGIN
|
|||
LEFT JOIN (
|
||||
SELECT e.id
|
||||
FROM tInvoiceIn tii
|
||||
JOIN expense e ON e.id = tii.expenseFk
|
||||
JOIN expense e ON e.id = tii.expenseFk
|
||||
WHERE e.isWithheld
|
||||
LIMIT 1
|
||||
) eWithheld ON TRUE
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceOutBooking`(IN vInvoice INT)
|
||||
BEGIN
|
||||
/* Asienta la factura emitida
|
||||
*
|
||||
* param vInvoice factura_id
|
||||
*/
|
||||
/**
|
||||
* Asienta una factura emitida
|
||||
*
|
||||
* @param vInvoice Id invoiceOut
|
||||
*/
|
||||
DECLARE vBookNumber INT;
|
||||
DECLARE vExpenseConcept VARCHAR(50);
|
||||
DECLARE vSpainCountryFk INT;
|
||||
DECLARE vOldBookNumber INT;
|
||||
DECLARE vExpenseConcept VARCHAR(50);
|
||||
DECLARE vSpainCountryFk INT;
|
||||
DECLARE vOldBookNumber INT;
|
||||
DECLARE vFiscalYear INT;
|
||||
|
||||
SELECT id INTO vSpainCountryFk FROM country WHERE code = 'ES';
|
||||
SELECT id INTO vSpainCountryFk FROM country WHERE `code` = 'ES';
|
||||
|
||||
SELECT ASIEN
|
||||
SELECT ASIEN
|
||||
INTO vOldBookNumber
|
||||
FROM XDiario x
|
||||
JOIN invoiceOut io ON io.id = vInvoice
|
||||
WHERE x.SERIE = io.serial
|
||||
WHERE x.SERIE = io.serial
|
||||
AND x.FACTURA = RIGHT(io.ref, LENGTH(io.ref) - 1)
|
||||
LIMIT 1;
|
||||
|
||||
|
@ -26,140 +28,133 @@ BEGIN
|
|||
|
||||
DROP TEMPORARY TABLE IF EXISTS rs;
|
||||
CREATE TEMPORARY TABLE rs
|
||||
SELECT
|
||||
c.accountingAccount AS clientBookingAccount,
|
||||
io.amount as totalAmount,
|
||||
CONCAT('n/fra ', io.ref) as simpleConcept,
|
||||
CONCAT('n/fra ', io.ref, ' ', c.name) as Concept,
|
||||
io.serial AS SERIE,
|
||||
io.issued AS FECHA_EX,
|
||||
io.issued AS FECHA_OP,
|
||||
io.issued AS FECHA,
|
||||
1 AS NFACTICK,
|
||||
IF(ic.correctingFk,'D','') AS TIPOOPE,
|
||||
io.siiTrascendencyInvoiceOutFk AS TIPOCLAVE,
|
||||
io.cplusTaxBreakFk AS TIPOEXENCI,
|
||||
io.cplusSubjectOpFk AS TIPONOSUJE,
|
||||
io.siiTypeInvoiceOutFk AS TIPOFACT,
|
||||
ic.cplusRectificationTypeFk AS TIPORECTIF,
|
||||
SELECT c.accountingAccount clientBookingAccount,
|
||||
io.amount totalAmount,
|
||||
CONCAT('n/fra ', io.ref) simpleConcept,
|
||||
CONCAT('n/fra ', io.ref, ' ', c.name) Concept,
|
||||
io.serial SERIE,
|
||||
io.issued FECHA_EX,
|
||||
io.issued FECHA_OP,
|
||||
io.issued FECHA,
|
||||
1 NFACTICK,
|
||||
IF(ic.correctingFk,'D','') TIPOOPE,
|
||||
io.siiTrascendencyInvoiceOutFk TIPOCLAVE,
|
||||
io.cplusTaxBreakFk TIPOEXENCI,
|
||||
io.cplusSubjectOpFk TIPONOSUJE,
|
||||
io.siiTypeInvoiceOutFk TIPOFACT,
|
||||
ic.cplusRectificationTypeFk TIPORECTIF,
|
||||
io.companyFk,
|
||||
RIGHT(io.ref, LENGTH(io.ref) - 1) AS invoiceNum,
|
||||
IF(c.countryFk = vSpainCountryFk, vSpainCountryFk, IF(ct.isUeeMember,2,4)) AS TERIDNIF,
|
||||
CONCAT(IF(ct.isUeeMember AND c.countryFk <> vSpainCountryFk,ct.code,''),c.fi) AS TERNIF,
|
||||
c.socialName AS TERNOM,
|
||||
ior.serial AS SERIE_RT,
|
||||
RIGHT(ior.ref, LENGTH(ior.ref) - 1) AS FACTU_RT,
|
||||
ior.issued AS FECHA_RT,
|
||||
IF(ior.id,TRUE,FALSE) AS RECTIFICA
|
||||
RIGHT(io.ref, LENGTH(io.ref) - 1) invoiceNum,
|
||||
IF(c.countryFk = vSpainCountryFk, vSpainCountryFk, IF(ct.isUeeMember,2,4)) TERIDNIF,
|
||||
CONCAT(IF(ct.isUeeMember AND c.countryFk <> vSpainCountryFk,ct.code,''),c.fi) TERNIF,
|
||||
c.socialName TERNOM,
|
||||
ior.serial SERIE_RT,
|
||||
RIGHT(ior.ref, LENGTH(ior.ref) - 1) FACTU_RT,
|
||||
ior.issued FECHA_RT,
|
||||
IF(ior.id,TRUE,FALSE) RECTIFICA
|
||||
FROM invoiceOut io
|
||||
JOIN invoiceOutSerial ios ON ios.code = io.serial
|
||||
JOIN client c ON c.id = io.clientFk
|
||||
JOIN country ct ON ct.id = c.countryFk
|
||||
LEFT JOIN invoiceCorrection ic ON ic.correctingFk = io.id
|
||||
LEFT JOIN invoiceOut ior ON ior.id = ic.correctedFk
|
||||
LEFT JOIN invoiceOut ior ON ior.id = ic.correctedFk
|
||||
WHERE io.id = vInvoice;
|
||||
|
||||
CALL vn.ledger_next(vBookNumber);
|
||||
|
||||
SELECT YEAR(FECHA) INTO vFiscalYear FROM rs LIMIT 1;
|
||||
CALL ledger_next(vFiscalYear, FALSE, vBookNumber);
|
||||
-- Linea del cliente
|
||||
INSERT INTO XDiario(
|
||||
ASIEN,
|
||||
FECHA,
|
||||
SUBCTA,
|
||||
EURODEBE,
|
||||
CONCEPTO,
|
||||
FECHA_EX,
|
||||
FECHA_OP,
|
||||
empresa_id
|
||||
)
|
||||
SELECT
|
||||
vBookNumber AS ASIEN,
|
||||
ASIEN,
|
||||
FECHA,
|
||||
SUBCTA,
|
||||
EURODEBE,
|
||||
CONCEPTO,
|
||||
FECHA_EX,
|
||||
FECHA_OP,
|
||||
empresa_id)
|
||||
SELECT vBookNumber,
|
||||
rs.FECHA,
|
||||
rs.clientBookingAccount AS SUBCTA,
|
||||
rs.totalAmount AS EURODEBE,
|
||||
rs.simpleConcept AS CONCEPTO,
|
||||
rs.clientBookingAccount,
|
||||
rs.totalAmount,
|
||||
rs.simpleConcept,
|
||||
rs.FECHA_EX,
|
||||
rs.FECHA_OP,
|
||||
rs.companyFk AS empresa_id
|
||||
rs.companyFk
|
||||
FROM rs;
|
||||
|
||||
-- Lineas de gasto
|
||||
INSERT INTO XDiario(
|
||||
ASIEN,
|
||||
FECHA,
|
||||
SUBCTA,
|
||||
CONTRA,
|
||||
EUROHABER,
|
||||
CONCEPTO,
|
||||
FECHA_EX,
|
||||
FECHA_OP,
|
||||
empresa_id
|
||||
)
|
||||
SELECT
|
||||
vBookNumber AS ASIEN,
|
||||
rs.FECHA,
|
||||
ioe.expenseFk AS SUBCTA,
|
||||
rs.clientBookingAccount AS CONTRA,
|
||||
ioe.amount AS EUROHABER,
|
||||
rs.Concept AS CONCEPTO,
|
||||
rs.FECHA_EX,
|
||||
rs.FECHA_OP,
|
||||
rs.companyFk AS empresa_id
|
||||
FROM rs
|
||||
JOIN invoiceOutExpense ioe
|
||||
WHERE ioe.invoiceOutFk = vInvoice;
|
||||
ASIEN,
|
||||
FECHA,
|
||||
SUBCTA,
|
||||
CONTRA,
|
||||
EUROHABER,
|
||||
CONCEPTO,
|
||||
FECHA_EX,
|
||||
FECHA_OP,
|
||||
empresa_id)
|
||||
SELECT vBookNumber,
|
||||
rs.FECHA,
|
||||
ioe.expenseFk,
|
||||
rs.clientBookingAccount,
|
||||
ioe.amount,
|
||||
rs.Concept,
|
||||
rs.FECHA_EX,
|
||||
rs.FECHA_OP,
|
||||
rs.companyFk
|
||||
FROM rs
|
||||
JOIN invoiceOutExpense ioe
|
||||
WHERE ioe.invoiceOutFk = vInvoice;
|
||||
|
||||
SELECT GROUP_CONCAT(`name` SEPARATOR ',')
|
||||
INTO vExpenseConcept
|
||||
FROM expense e
|
||||
JOIN invoiceOutExpense ioe ON ioe.expenseFk = e.id
|
||||
WHERE ioe.invoiceOutFk = vInvoice;
|
||||
SELECT GROUP_CONCAT(`name` SEPARATOR ',')
|
||||
INTO vExpenseConcept
|
||||
FROM expense e
|
||||
JOIN invoiceOutExpense ioe ON ioe.expenseFk = e.id
|
||||
WHERE ioe.invoiceOutFk = vInvoice;
|
||||
|
||||
-- Lineas de IVA
|
||||
-- Lineas de IVA
|
||||
INSERT INTO XDiario(
|
||||
ASIEN,
|
||||
FECHA,
|
||||
SUBCTA,
|
||||
CONTRA,
|
||||
EUROHABER,
|
||||
BASEEURO,
|
||||
CONCEPTO,
|
||||
FACTURA,
|
||||
IVA,
|
||||
RECEQUIV,
|
||||
AUXILIAR,
|
||||
SERIE,
|
||||
SERIE_RT,
|
||||
FACTU_RT,
|
||||
RECTIFICA,
|
||||
FECHA_RT,
|
||||
FECHA_OP,
|
||||
FECHA_EX,
|
||||
TIPOOPE,
|
||||
NFACTICK,
|
||||
TERIDNIF,
|
||||
TERNIF,
|
||||
TERNOM,
|
||||
L340,
|
||||
TIPOCLAVE,
|
||||
TIPOEXENCI,
|
||||
TIPONOSUJE,
|
||||
TIPOFACT,
|
||||
TIPORECTIF,
|
||||
empresa_id
|
||||
)
|
||||
SELECT
|
||||
vBookNumber AS ASIEN,
|
||||
ASIEN,
|
||||
FECHA,
|
||||
SUBCTA,
|
||||
CONTRA,
|
||||
EUROHABER,
|
||||
BASEEURO,
|
||||
CONCEPTO,
|
||||
FACTURA,
|
||||
IVA,
|
||||
RECEQUIV,
|
||||
AUXILIAR,
|
||||
SERIE,
|
||||
SERIE_RT,
|
||||
FACTU_RT,
|
||||
RECTIFICA,
|
||||
FECHA_RT,
|
||||
FECHA_OP,
|
||||
FECHA_EX,
|
||||
TIPOOPE,
|
||||
NFACTICK,
|
||||
TERIDNIF,
|
||||
TERNIF,
|
||||
TERNOM,
|
||||
L340,
|
||||
TIPOCLAVE,
|
||||
TIPOEXENCI,
|
||||
TIPONOSUJE,
|
||||
TIPOFACT,
|
||||
TIPORECTIF,
|
||||
empresa_id)
|
||||
SELECT vBookNumber ASIEN,
|
||||
rs.FECHA,
|
||||
iot.pgcFk AS SUBCTA,
|
||||
rs.clientBookingAccount AS CONTRA,
|
||||
iot.vat AS EUROHABER,
|
||||
iot.taxableBase AS BASEEURO,
|
||||
CONCAT(vExpenseConcept,' : ',rs.Concept) AS CONCEPTO,
|
||||
rs.invoiceNum AS FACTURA,
|
||||
IF(pe2.equFk,0,pgc.rate) AS IVA,
|
||||
IF(pe2.equFk,0,pgce.rate) AS RECEQUIV,
|
||||
IF(pgc.mod347,'','*') AS AUXILIAR,
|
||||
iot.pgcFk SUBCTA,
|
||||
rs.clientBookingAccount CONTRA,
|
||||
iot.vat EUROHABER,
|
||||
iot.taxableBase BASEEURO,
|
||||
CONCAT(vExpenseConcept,' : ',rs.Concept) CONCEPTO,
|
||||
rs.invoiceNum FACTURA,
|
||||
IF(pe2.equFk,0,pgc.rate) IVA,
|
||||
IF(pe2.equFk,0,pgce.rate) RECEQUIV,
|
||||
IF(pgc.mod347,'','*') AUXILIAR,
|
||||
rs.SERIE,
|
||||
rs.SERIE_RT,
|
||||
rs.FACTU_RT,
|
||||
|
@ -168,27 +163,27 @@ BEGIN
|
|||
rs.FECHA_OP,
|
||||
rs.FECHA_EX,
|
||||
rs.TIPOOPE,
|
||||
rs.NFACTICK,
|
||||
rs.NFACTICK,
|
||||
rs.TERIDNIF,
|
||||
rs.TERNIF,
|
||||
rs.TERNOM,
|
||||
pgc.mod340 AS L340,
|
||||
pgc.siiTrascendencyInvoiceOutFk AS TIPOCLAVE,
|
||||
pgc.cplusTaxBreakFk as TIPOEXENCI,
|
||||
pgc.mod340 L340,
|
||||
pgc.siiTrascendencyInvoiceOutFk TIPOCLAVE,
|
||||
pgc.cplusTaxBreakFk TIPOEXENCI,
|
||||
rs.TIPONOSUJE,
|
||||
rs.TIPOFACT,
|
||||
rs.TIPORECTIF,
|
||||
rs.companyFk AS empresa_id
|
||||
rs.companyFk
|
||||
FROM rs
|
||||
JOIN invoiceOutTax iot
|
||||
JOIN pgc ON pgc.code = iot.pgcFk
|
||||
LEFT JOIN pgcEqu pe ON pe.vatFk = iot.pgcFk -- --------------- Comprueba si la linea es de iva con rec.equiv. asociado
|
||||
LEFT JOIN pgc pgce ON pgce.code = pe.equFk
|
||||
LEFT JOIN pgcEqu pe2 ON pe2.equFk = iot.pgcFk -- --------------- Comprueba si la linea es de rec.equiv.
|
||||
LEFT JOIN pgcEqu pe2 ON pe2.equFk = iot.pgcFk -- --------------- Comprueba si la linea es de rec.equiv.
|
||||
WHERE iot.invoiceOutFk = vInvoice;
|
||||
|
||||
UPDATE invoiceOut
|
||||
SET booked = util.VN_CURDATE()
|
||||
WHERE id = vInvoice;
|
||||
|
||||
UPDATE invoiceOut
|
||||
SET booked = util.VN_CURDATE()
|
||||
WHERE id = vInvoice;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -18,11 +18,12 @@ BEGIN
|
|||
JOIN vn.parking p ON p.id = sh.parkingFk
|
||||
JOIN vn.sector sc ON sc.id = p.sectorFk
|
||||
JOIN vn.warehouse w ON w.id = sc.warehouseFk
|
||||
WHERE sc.id = vSectorFk
|
||||
AND ish.visible > 0
|
||||
WHERE ish.visible > 0
|
||||
AND ish.itemFk = vItemFk
|
||||
GROUP BY ish.id
|
||||
ORDER BY sh.priority DESC,
|
||||
ORDER BY
|
||||
(sc.id = vSectorFk) DESC,
|
||||
sh.priority DESC,
|
||||
ish.created,
|
||||
p.pickingOrder;
|
||||
END$$
|
||||
|
|
|
@ -2,7 +2,7 @@ DELIMITER $$
|
|||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingRadar`(
|
||||
vSectorFk INT
|
||||
)
|
||||
proc:BEGIN
|
||||
BEGIN
|
||||
/**
|
||||
* Calcula la información detallada respecto un sector.
|
||||
*
|
||||
|
@ -15,37 +15,24 @@ proc:BEGIN
|
|||
DECLARE vWarehouseFk INT DEFAULT 0;
|
||||
DECLARE vSonSectorFk INT;
|
||||
DECLARE vWorkerFk INT;
|
||||
|
||||
SELECT s.workerFk
|
||||
INTO vWorkerFk
|
||||
FROM vn.sector s
|
||||
|
||||
SELECT s.workerFk INTO vWorkerFk
|
||||
FROM sector s
|
||||
WHERE s.id = vSectorFk;
|
||||
|
||||
SELECT w.id, s.warehouseFk INTO vBuyerFk, vWarehouseFk
|
||||
FROM vn.worker w
|
||||
JOIN vn.sector s ON s.code = w.code
|
||||
WHERE s.id = vSectorFk;
|
||||
|
||||
SELECT s.id INTO vSectorFk
|
||||
FROM vn.sector s
|
||||
WHERE s.warehouseFk = vWarehouseFk
|
||||
AND s.isMain;
|
||||
|
||||
SELECT COUNT(*) INTO hasFatherSector
|
||||
FROM vn.sector
|
||||
FROM sector
|
||||
WHERE sonFk = vSectorFk;
|
||||
|
||||
|
||||
SELECT warehouseFk, sonFk INTO vWarehouseFk, vSonSectorFk
|
||||
FROM vn.sector
|
||||
FROM sector
|
||||
WHERE id = vSectorFk;
|
||||
|
||||
|
||||
CALL cache.visible_refresh(vCalcVisibleFk, TRUE, vWarehouseFk);
|
||||
CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, util.VN_CURDATE());
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.itemShelvingRadar;
|
||||
|
||||
|
||||
IF hasFatherSector THEN
|
||||
CREATE TEMPORARY TABLE tmp.itemShelvingRadar
|
||||
CREATE OR REPLACE TEMPORARY TABLE tItemShelvingRadar
|
||||
(PRIMARY KEY (itemFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT *
|
||||
|
@ -54,57 +41,77 @@ proc:BEGIN
|
|||
i.longName,
|
||||
i.size,
|
||||
i.subName producer,
|
||||
IFNULL(a.available,0) available,
|
||||
SUM(IF(s.sonFk = vSectorFk, IFNULL(iss.visible,0), 0)) upstairs,
|
||||
SUM(IF(iss.sectorFk = vSectorFk, IFNULL(iss.visible,0), 0)) downstairs,
|
||||
IF(it.isPackaging, NULL, IFNULL(v.visible,0)) as visible,
|
||||
vSectorFk sectorFk
|
||||
FROM vn.itemShelvingStock iss
|
||||
JOIN vn.sector s ON s.id = iss.sectorFk
|
||||
JOIN vn.item i on i.id = iss.itemFk
|
||||
JOIN vn.itemType it ON it.id = i.typeFk AND vBuyerFk IN (0,it.workerFk)
|
||||
LEFT JOIN cache.available a ON a.item_id = iss.itemFk AND a.calc_id = vCalcAvailableFk
|
||||
LEFT JOIN cache.visible v ON v.item_id = iss.itemFk AND v.calc_id = vCalcVisibleFk
|
||||
IFNULL(a.available, 0) available,
|
||||
SUM(IF(s.sonFk = vSectorFk, IFNULL(iss.visible, 0), 0)) upstairs,
|
||||
SUM(IF(iss.sectorFk = vSectorFk, IFNULL(iss.visible, 0), 0)) downstairs,
|
||||
IF(it.isPackaging, NULL, IFNULL(v.visible, 0)) visible,
|
||||
vSectorFk sectorFk,
|
||||
ish.isChecked,
|
||||
sub.isAllChecked
|
||||
FROM itemShelvingStock iss
|
||||
JOIN itemShelving ish ON ish.shelvingFk = iss.shelvingFk
|
||||
LEFT JOIN (
|
||||
SELECT itemFk,
|
||||
IF(
|
||||
COUNT(*) = SUM(IF(isChecked >= 0, 1, 0)),
|
||||
TRUE,
|
||||
FALSE
|
||||
) isAllChecked
|
||||
FROM itemShelving is2
|
||||
GROUP BY itemFk
|
||||
) sub ON sub.itemFk = ish.itemFk
|
||||
JOIN sector s ON s.id = iss.sectorFk
|
||||
JOIN item i ON i.id = iss.itemFk
|
||||
JOIN itemType it ON it.id = i.typeFk
|
||||
LEFT JOIN cache.available a ON a.item_id = iss.itemFk
|
||||
AND a.calc_id = vCalcAvailableFk
|
||||
LEFT JOIN cache.visible v ON v.item_id = iss.itemFk
|
||||
AND v.calc_id = vCalcVisibleFk
|
||||
WHERE vSectorFk IN (iss.sectorFk, s.sonFk)
|
||||
GROUP BY iss.itemFk
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT v.item_id,
|
||||
SELECT v.item_id,
|
||||
i.longName,
|
||||
i.size,
|
||||
i.subName producer,
|
||||
IFNULL(a.available,0) as available,
|
||||
0 upstairs,
|
||||
0 downstairs,
|
||||
IF(it.isPackaging, NULL, v.visible) visible,
|
||||
vSectorFk as sectorFk
|
||||
i.subName,
|
||||
IFNULL(a.available, 0),
|
||||
0,
|
||||
0,
|
||||
IF(it.isPackaging, NULL, v.visible),
|
||||
vSectorFk,
|
||||
NULL,
|
||||
NULL
|
||||
FROM cache.visible v
|
||||
JOIN vn.item i on i.id = v.item_id
|
||||
JOIN vn.itemType it ON it.id = i.typeFk AND vBuyerFk IN (0,it.workerFk)
|
||||
LEFT JOIN vn.itemShelvingStock iss ON iss.itemFk = v.item_id AND iss.warehouseFk = vWarehouseFk
|
||||
LEFT JOIN cache.available a ON a.item_id = v.item_id AND a.calc_id = vCalcAvailableFk
|
||||
JOIN item i ON i.id = v.item_id
|
||||
JOIN itemType it ON it.id = i.typeFk
|
||||
LEFT JOIN itemShelvingStock iss ON iss.itemFk = v.item_id
|
||||
AND iss.warehouseFk = vWarehouseFk
|
||||
LEFT JOIN cache.available a ON a.item_id = v.item_id
|
||||
AND a.calc_id = vCalcAvailableFk
|
||||
WHERE v.calc_id = vCalcVisibleFk
|
||||
AND iss.itemFk IS NULL
|
||||
AND it.isInventory
|
||||
) sub GROUP BY itemFk;
|
||||
) sub
|
||||
GROUP BY itemFk;
|
||||
|
||||
SELECT ishr.*,
|
||||
CAST(visible - upstairs - downstairs AS DECIMAL(10,0)) AS nicho,
|
||||
CAST(downstairs - IFNULL(notPickedYed,0) AS DECIMAL(10,0)) as pendiente
|
||||
FROM tmp.itemShelvingRadar ishr
|
||||
JOIN vn.item i ON i.id = ishr.itemFk
|
||||
LEFT JOIN (SELECT s.itemFk, sum(s.quantity) as notPickedYed
|
||||
FROM vn.ticket t
|
||||
JOIN vn.ticketStateToday tst ON tst.ticketFk = t.id
|
||||
JOIN vn.sale s ON s.ticketFk = t.id
|
||||
WHERE t.warehouseFk = vWarehouseFk
|
||||
AND tst.alertLevel = 0
|
||||
GROUP BY s.itemFk
|
||||
) sub ON sub.itemFk = ishr.itemFk
|
||||
ORDER BY i.typeFk, i.longName;
|
||||
CAST(visible - upstairs - downstairs AS DECIMAL(10, 0)) nicho,
|
||||
CAST(downstairs - IFNULL(notPickedYed, 0) AS DECIMAL(10, 0)) pendiente
|
||||
FROM tItemShelvingRadar ishr
|
||||
JOIN item i ON i.id = ishr.itemFk
|
||||
LEFT JOIN (
|
||||
SELECT s.itemFk, SUM(s.quantity) notPickedYed
|
||||
FROM ticket t
|
||||
JOIN ticketStateToday tst ON tst.ticketFk = t.id
|
||||
JOIN alertLevel al ON al.id = tst.alertLevel
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
WHERE t.warehouseFk = vWarehouseFk
|
||||
AND al.code = 'FREE'
|
||||
GROUP BY s.itemFk
|
||||
) sub ON sub.itemFk = ishr.itemFk
|
||||
ORDER BY i.typeFk, i.longName;
|
||||
ELSE
|
||||
CREATE TEMPORARY TABLE tmp.itemShelvingRadar
|
||||
CREATE OR REPLACE TEMPORARY TABLE tItemShelvingRadar
|
||||
(PRIMARY KEY (itemFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT iss.itemFk,
|
||||
|
@ -115,80 +122,86 @@ proc:BEGIN
|
|||
i.size,
|
||||
i.subName producer,
|
||||
i.upToDown,
|
||||
IFNULL(a.available,0) available,
|
||||
IFNULL(v.visible - iss.visible,0) dayEndVisible,
|
||||
IFNULL(v.visible - iss.visible,0) firstNegative,
|
||||
IFNULL(v.visible - iss.visible,0) itemPlacementVisible,
|
||||
IFNULL(i.minimum * b.packing,0) itemPlacementSize,
|
||||
IFNULL(a.available, 0) available,
|
||||
IFNULL(v.visible - iss.visible, 0) dayEndVisible,
|
||||
IFNULL(v.visible - iss.visible, 0) firstNegative,
|
||||
IFNULL(v.visible - iss.visible, 0) itemPlacementVisible,
|
||||
IFNULL(i.minimum * b.packing, 0) itemPlacementSize,
|
||||
ips.onTheWay,
|
||||
iss.visible itemShelvingStock,
|
||||
IFNULL(v.visible,0) visible,
|
||||
IFNULL(v.visible, 0) visible,
|
||||
b.isPickedOff,
|
||||
iss.sectorFk
|
||||
FROM vn.itemShelvingStock iss
|
||||
JOIN vn.item i on i.id = iss.itemFk
|
||||
LEFT JOIN cache.last_buy lb ON lb.item_id = iss.itemFk AND lb.warehouse_id = vWarehouseFk
|
||||
LEFT JOIN vn.buy b ON b.id = lb.buy_id
|
||||
LEFT JOIN cache.available a ON a.item_id = iss.itemFk AND a.calc_id = vCalcAvailableFk
|
||||
LEFT JOIN cache.visible v ON v.item_id = iss.itemFk AND v.calc_id = vCalcVisibleFk
|
||||
LEFT JOIN (SELECT itemFk, sum(saldo) as onTheWay
|
||||
FROM vn.itemPlacementSupplyList
|
||||
WHERE saldo > 0
|
||||
GROUP BY itemFk
|
||||
) ips ON ips.itemFk = i.id
|
||||
WHERE IFNULL(iss.sectorFk,0) IN (0, vSectorFk)
|
||||
OR iss.sectorFk = vSectorFk;
|
||||
FROM itemShelvingStock iss
|
||||
JOIN item i ON i.id = iss.itemFk
|
||||
LEFT JOIN cache.last_buy lb ON lb.item_id = iss.itemFk
|
||||
AND lb.warehouse_id = vWarehouseFk
|
||||
LEFT JOIN buy b ON b.id = lb.buy_id
|
||||
LEFT JOIN cache.available a ON a.item_id = iss.itemFk
|
||||
AND a.calc_id = vCalcAvailableFk
|
||||
LEFT JOIN cache.visible v ON v.item_id = iss.itemFk
|
||||
AND v.calc_id = vCalcVisibleFk
|
||||
LEFT JOIN (
|
||||
SELECT itemFk, SUM(saldo) onTheWay
|
||||
FROM itemPlacementSupplyList
|
||||
WHERE saldo > 0
|
||||
GROUP BY itemFk
|
||||
) ips ON ips.itemFk = i.id
|
||||
WHERE iss.sectorFk = vSectorFk
|
||||
OR iss.sectorFk IS NULL;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.itemOutTime;
|
||||
CREATE TEMPORARY TABLE tmp.itemOutTime
|
||||
SELECT *,SUM(amount) quantity
|
||||
FROM
|
||||
(SELECT io.itemFk,
|
||||
io.quantity amount,
|
||||
IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) as hours,
|
||||
IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) as minutes
|
||||
FROM itemTicketOut io
|
||||
JOIN tmp.itemShelvingRadar isr ON isr.itemFk = io.itemFk
|
||||
JOIN vn.ticket t on t.id= io.ticketFk
|
||||
JOIN vn.ticketState ts on ts.ticketFk = io.ticketFk
|
||||
JOIN vn.state s ON s.id = ts.stateFk
|
||||
LEFT JOIN vn.zone z ON z.id = t.zoneFk
|
||||
LEFT JOIN (SELECT DISTINCT saleFk
|
||||
FROM vn.saleTracking st
|
||||
WHERE st.created > util.VN_CURDATE()
|
||||
AND st.isChecked
|
||||
) stPrevious ON `stPrevious`.`saleFk` = io.saleFk
|
||||
WHERE t.warehouseFk = vWarehouseFk
|
||||
AND s.isPicked = 0
|
||||
AND NOT io.reserved
|
||||
AND stPrevious.saleFk IS NULL
|
||||
AND io.shipped >= util.VN_CURDATE()
|
||||
AND io.shipped < util.VN_CURDATE() + INTERVAL 1 DAY
|
||||
) sub
|
||||
GROUP BY itemFk, hours, minutes;
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.itemOutTime
|
||||
SELECT *, SUM(amount) quantity
|
||||
FROM (
|
||||
SELECT io.itemFk,
|
||||
io.quantity amount,
|
||||
IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) `hours`,
|
||||
IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) `minutes`
|
||||
FROM itemTicketOut `io`
|
||||
JOIN tItemShelvingRadar isr ON isr.itemFk = io.itemFk
|
||||
JOIN ticket t ON t.id= io.ticketFk
|
||||
JOIN ticketState ts ON ts.ticketFk = io.ticketFk
|
||||
JOIN `state` s ON s.id = ts.stateFk
|
||||
LEFT JOIN `zone` z ON z.id = t.zoneFk
|
||||
LEFT JOIN (
|
||||
SELECT DISTINCT saleFk
|
||||
FROM saleTracking st
|
||||
WHERE st.created > util.VN_CURDATE()
|
||||
AND st.isChecked
|
||||
) stPrevious ON stPrevious.saleFk = io.saleFk
|
||||
WHERE t.warehouseFk = vWarehouseFk
|
||||
AND NOT s.isPicked
|
||||
AND NOT io.reserved
|
||||
AND stPrevious.saleFk IS NULL
|
||||
AND io.shipped >= util.VN_CURDATE()
|
||||
AND io.shipped < util.VN_CURDATE() + INTERVAL 1 DAY
|
||||
) sub
|
||||
GROUP BY itemFk, `hours`, `minutes`;
|
||||
|
||||
INSERT INTO tmp.itemShelvingRadar (itemFk)
|
||||
INSERT INTO tItemShelvingRadar (itemFk)
|
||||
SELECT itemFk FROM tmp.itemOutTime
|
||||
ON DUPLICATE KEY UPDATE dayEndVisible = dayEndVisible + quantity,
|
||||
firstNegative = if (firstNegative < 0, firstNegative, firstNegative + quantity),
|
||||
`hour` = ifnull(if (firstNegative > 0 , `hour`, hours),0),
|
||||
`minute` = ifnull(if (firstNegative > 0, `minute`, minutes),0);
|
||||
ON DUPLICATE KEY UPDATE dayEndVisible = dayEndVisible + quantity,
|
||||
firstNegative = IF(firstNegative < 0, firstNegative, firstNegative + quantity),
|
||||
`hour` = IFNULL(IF(firstNegative > 0 , `hour`, `hours`), 0),
|
||||
`minute` = IFNULL(IF(firstNegative > 0, `minute`, `minutes`), 0);
|
||||
|
||||
UPDATE tmp.itemShelvingRadar isr
|
||||
JOIN (SELECT s.itemFk, sum(s.quantity) amount
|
||||
FROM sale s
|
||||
JOIN ticket t ON t.id = s.ticketFk
|
||||
JOIN ticketLastState tls ON tls.ticketFk = t.id
|
||||
WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
|
||||
AND tls.name = 'Prep Camara'
|
||||
GROUP BY s.itemFk) sub ON sub.itemFk = isr.itemFk
|
||||
UPDATE tItemShelvingRadar isr
|
||||
JOIN (
|
||||
SELECT s.itemFk, SUM(s.quantity) amount
|
||||
FROM sale s
|
||||
JOIN ticket t ON t.id = s.ticketFk
|
||||
JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
|
||||
AND ts.code = 'COOLER_PREPARATION'
|
||||
GROUP BY s.itemFk
|
||||
) sub ON sub.itemFk = isr.itemFk
|
||||
SET isr.dayEndVisible = dayEndVisible + sub.amount,
|
||||
firstNegative = firstNegative + sub.amount;
|
||||
|
||||
SELECT * FROM tmp.itemShelvingRadar;
|
||||
SELECT * FROM tItemShelvingRadar;
|
||||
END IF;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.itemShelvingRadar;
|
||||
DROP TEMPORARY TABLE tItemShelvingRadar;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -17,13 +17,15 @@ BEGIN
|
|||
SELECT
|
||||
itemFk,
|
||||
packing,
|
||||
created
|
||||
created,
|
||||
buyFk
|
||||
FROM itemShelving
|
||||
WHERE id = vItemShelvingFk
|
||||
) ish2
|
||||
ON ish2.itemFk = ish.itemFk
|
||||
AND ish2.packing = ish.packing
|
||||
AND date(ish2.created) = date(ish.created)
|
||||
AND ish2.buyFk = ish.buyFk
|
||||
WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci;
|
||||
|
||||
IF vNewItemShelvingFk THEN
|
||||
|
|
|
@ -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)
|
||||
BEGIN
|
||||
|
||||
|
||||
/**
|
||||
* Añade registro o lo actualiza si ya existe.
|
||||
*
|
||||
|
@ -15,42 +14,58 @@ BEGIN
|
|||
* @param vWarehouseFk indica el sector
|
||||
*
|
||||
**/
|
||||
|
||||
DECLARE vItemFk INT;
|
||||
DECLARE vBuyFk INT;
|
||||
|
||||
SELECT id INTO vBuyFk
|
||||
FROM buy WHERE id = vBarcode;
|
||||
|
||||
SELECT barcodeToItem(vBarcode) INTO vItemFk;
|
||||
|
||||
SET vPacking = COALESCE(vPacking, GREATEST(vn.itemPacking(vBarcode,vWarehouseFk), 1));
|
||||
SET vQuantity = vQuantity * vPacking;
|
||||
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
|
||||
THEN
|
||||
SET vPacking = itemPacking(vBarcode, vWarehouseFk);
|
||||
SET vQuantity = vQuantity * vPacking;
|
||||
END IF;
|
||||
|
||||
IF (SELECT COUNT(*) FROM itemShelving
|
||||
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
|
||||
AND itemFk = vItemFk
|
||||
AND packing = vPacking) = 1 THEN
|
||||
AND packing = vPacking
|
||||
AND buyFk = vBuyFk) THEN
|
||||
|
||||
UPDATE itemShelving
|
||||
SET visible = visible+vQuantity
|
||||
SET visible = visible + vQuantity
|
||||
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking;
|
||||
|
||||
ELSE
|
||||
CALL cache.last_buy_refresh(FALSE);
|
||||
INSERT INTO itemShelving( itemFk,
|
||||
shelvingFk,
|
||||
visible,
|
||||
grouping,
|
||||
packing,
|
||||
packagingFk)
|
||||
|
||||
SELECT vItemFk,
|
||||
vShelvingFk,
|
||||
vQuantity,
|
||||
IFNULL(vGrouping, b.grouping),
|
||||
IFNULL(vPacking, b.packing),
|
||||
IFNULL(vPackagingFk, b.packagingFk)
|
||||
FROM item i
|
||||
LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk
|
||||
LEFT JOIN buy b ON b.id = lb.buy_id
|
||||
WHERE i.id = vItemFk;
|
||||
INSERT INTO itemShelving(
|
||||
itemFk,
|
||||
shelvingFk,
|
||||
visible,
|
||||
grouping,
|
||||
packing,
|
||||
packagingFk,
|
||||
buyFk)
|
||||
SELECT 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$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -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 ;
|
|
@ -6,7 +6,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_comparative`(
|
|||
vAvailableSince DATE,
|
||||
vBuyerFk INT,
|
||||
vIsFloramondo BOOL,
|
||||
vCountryFk INT
|
||||
vCountryFk INT
|
||||
)
|
||||
proc: BEGIN
|
||||
/**
|
||||
|
@ -23,7 +23,6 @@ proc: BEGIN
|
|||
* @param tmp.comparativeFilterType(filterFk INT ,itemTypeFk INT)
|
||||
* @return tmp.comparative
|
||||
*/
|
||||
|
||||
DECLARE vDayRangeStart DATE;
|
||||
DECLARE vDayRangeEnd DATE;
|
||||
DECLARE w1, w2, w3, w4, w5, w6, w7 INT;
|
||||
|
@ -59,14 +58,14 @@ proc: BEGIN
|
|||
END IF;
|
||||
|
||||
SELECT MIN(dated) INTO vDayRangeStart
|
||||
FROM vn.time
|
||||
FROM `time`
|
||||
WHERE dated <= vDate
|
||||
GROUP BY period
|
||||
ORDER BY dated desc
|
||||
LIMIT 1 OFFSET vWeekRange;
|
||||
|
||||
SELECT MAX(dated) INTO vDayRangeEnd
|
||||
FROM vn.time
|
||||
FROM `time`
|
||||
WHERE dated >= vDate
|
||||
GROUP BY period
|
||||
ORDER BY dated ASC
|
||||
|
@ -83,12 +82,11 @@ proc: BEGIN
|
|||
JOIN itemType t ON t.id = i.typeFk
|
||||
JOIN itemCategory c ON c.id = t.categoryFk
|
||||
LEFT JOIN worker w ON w.id = t.workerFk
|
||||
WHERE (NOT vHasTypeFilter
|
||||
OR t.id IN (SELECT itemTypeFk FROM tmp.comparativeFilterType))
|
||||
AND (vBuyerFk IS NULL
|
||||
OR t.workerFk = vBuyerFk)
|
||||
AND (vIsFloramondo IS NULL
|
||||
OR i.isFloramondo = vIsFloramondo);
|
||||
WHERE (NOT vHasTypeFilter OR t.id IN (
|
||||
SELECT itemTypeFk FROM tmp.comparativeFilterType
|
||||
))
|
||||
AND (vBuyerFk IS NULL OR t.workerFk = vBuyerFk)
|
||||
AND (vIsFloramondo IS NULL OR i.isFloramondo = vIsFloramondo);
|
||||
|
||||
IF vDate < util.VN_CURDATE() THEN
|
||||
ALTER TABLE tmp.itemInventory
|
||||
|
@ -115,10 +113,11 @@ proc: BEGIN
|
|||
SET i = i + 1;
|
||||
|
||||
SELECT t.period INTO vPeriod
|
||||
FROM vn.`time` t
|
||||
FROM `time` t
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
-- Genera una tabla con los datos del año pasado.
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tLastYear
|
||||
(KEY (lItemFk))
|
||||
ENGINE = MEMORY
|
||||
|
@ -151,15 +149,14 @@ proc: BEGIN
|
|||
SUM(IF(c.timePeriod = y7, c.price, 0)) lprice7
|
||||
FROM tmp.itemInventory ai
|
||||
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
|
||||
WHERE IFNULL(vWarehouseFk, c.warehouseFk) = c.warehouseFk
|
||||
WHERE (vWarehouseFk IS NULL OR vWarehouseFk = c.warehouseFk)
|
||||
AND w.isComparative
|
||||
AND (vCountryFk IS NULL OR c.countryFk = vCountryFk)
|
||||
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
|
||||
(KEY (tItemFk))
|
||||
ENGINE = MEMORY
|
||||
|
@ -180,73 +177,72 @@ proc: BEGIN
|
|||
SUM(IF(c.timePeriod = z7, c.price, 0)) vlprice7
|
||||
FROM tmp.itemInventory ai
|
||||
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
|
||||
WHERE IFNULL(vWarehouseFk, c.warehouseFk) = c.warehouseFk
|
||||
WHERE (vWarehouseFk IS NULL OR vWarehouseFk = c.warehouseFk)
|
||||
AND w.isComparative
|
||||
AND (vCountryFk IS NULL OR c.countryFk = vCountryFk)
|
||||
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
|
||||
(KEY (cItemFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT t.itemFk cItemFk,
|
||||
SUM(IF(week = w1, total, 0)) cweek1,
|
||||
SUM(IF(week = w2, total, 0)) cweek2,
|
||||
SUM(IF(week = w3, total, 0)) cweek3,
|
||||
SUM(IF(week = w4, total, 0)) cweek4,
|
||||
SUM(IF(week = w5, total, 0)) cweek5,
|
||||
SUM(IF(week = w6, total, 0)) cweek6,
|
||||
SUM(IF(week = w7, total, 0)) cweek7,
|
||||
SUM(IF(week = w1, price, 0)) cprice1,
|
||||
SUM(IF(week = w2, price, 0)) cprice2,
|
||||
SUM(IF(week = w3, price, 0)) cprice3,
|
||||
SUM(IF(week = w4, price, 0)) cprice4,
|
||||
SUM(IF(week = w5, price, 0)) cprice5,
|
||||
SUM(IF(week = w6, price, 0)) cprice6,
|
||||
SUM(IF(week = w7, price, 0)) cprice7
|
||||
SUM(IF(`week` = w1, total, 0)) cweek1,
|
||||
SUM(IF(`week` = w2, total, 0)) cweek2,
|
||||
SUM(IF(`week` = w3, total, 0)) cweek3,
|
||||
SUM(IF(`week` = w4, total, 0)) cweek4,
|
||||
SUM(IF(`week` = w5, total, 0)) cweek5,
|
||||
SUM(IF(`week` = w6, total, 0)) cweek6,
|
||||
SUM(IF(`week` = w7, total, 0)) cweek7,
|
||||
SUM(IF(`week` = w1, price, 0)) cprice1,
|
||||
SUM(IF(`week` = w2, price, 0)) cprice2,
|
||||
SUM(IF(`week` = w3, price, 0)) cprice3,
|
||||
SUM(IF(`week` = w4, price, 0)) cprice4,
|
||||
SUM(IF(`week` = w5, price, 0)) cprice5,
|
||||
SUM(IF(`week` = w6, price, 0)) cprice6,
|
||||
SUM(IF(`week` = w7, price, 0)) cprice7
|
||||
FROM (
|
||||
SELECT s.itemFk,
|
||||
ti.period `week`,
|
||||
SUM(s.quantity) total,
|
||||
TRUNCATE(SUM(s.quantity * s.priceFixed),0) price
|
||||
FROM ticket t
|
||||
TRUNCATE(SUM(s.quantity * s.priceFixed), 0) price
|
||||
FROM ticket t FORCE INDEX (Fecha)
|
||||
JOIN sale s ON t.id = s.ticketFk
|
||||
JOIN tmp.itemInventory it ON it.id = s.itemFk
|
||||
JOIN time ti ON ti.dated = DATE(t.shipped)
|
||||
JOIN tmp.itemInventory it ON it.id = s.itemFk
|
||||
JOIN `time` ti ON ti.dated = DATE(t.shipped)
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN itemType tp ON tp.id = i.typeFk
|
||||
JOIN itemCategory ic ON ic.id = tp.categoryFk
|
||||
JOIN warehouse w ON w.id = t.warehouseFk
|
||||
STRAIGHT_JOIN address ad ON ad.id = t.addressFk
|
||||
JOIN province p ON p.id = ad.provinceFk
|
||||
JOIN `address` ad ON ad.id = t.addressFk
|
||||
JOIN province p ON p.id = ad.provinceFk
|
||||
JOIN `client` c ON c.id = ad.clientFk
|
||||
WHERE t.shipped BETWEEN vDayRangeStart AND util.dayEnd(vDayRangeEnd)
|
||||
AND c.typeFk IN ('Normal','handMaking')
|
||||
AND w.id = COALESCE(vWarehouseFk, w.id)
|
||||
AND c.typeFk IN ('normal', 'handMaking')
|
||||
AND (vWarehouseFk IS NULL OR vWarehouseFk = w.id)
|
||||
AND (vCountryFk IS NULL OR p.countryFk = vCountryFk)
|
||||
AND w.isComparative
|
||||
AND (vCountryFk IS NULL OR p.countryFk = vCountryFk)
|
||||
GROUP BY i.id, week
|
||||
GROUP BY i.id, `week`
|
||||
) t
|
||||
GROUP BY t.itemFk;
|
||||
|
||||
-- Genera la tabla con la comparativa.
|
||||
-- Genera la tabla con la comparativa
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.comparative
|
||||
ENGINE = MEMORY
|
||||
SELECT it.subName productor,
|
||||
b.packing,
|
||||
SELECT it.subName productor,
|
||||
b.packing,
|
||||
b.buyingValue costefijo,
|
||||
b.groupingMode caja,
|
||||
it.image ArticleImage,
|
||||
IFNULL(it.inkFk,"?") color,
|
||||
IFNULL(it.inkFk, '?') color,
|
||||
tp.code tipo,
|
||||
it.typeFk tipo_id,
|
||||
o.code origen,
|
||||
it.category categoria,
|
||||
it.stems tallos,
|
||||
it.size medida,
|
||||
it.`size` medida,
|
||||
it.name article,
|
||||
w.code codigoTrabajador,
|
||||
tp.categoryFk reino_id,
|
||||
|
@ -257,24 +253,27 @@ proc: BEGIN
|
|||
it.id Id_Article,
|
||||
i.buy_id,
|
||||
tp.life,
|
||||
IFNULL(i.sd,0) sd,
|
||||
IFNULL(i.sd, 0) sd,
|
||||
i.avalaible,
|
||||
i.visible,
|
||||
i.buy_date,
|
||||
e.id provider_id,
|
||||
it.comment comments,
|
||||
it.description itemDescription,
|
||||
IF(cy.cItemFk IS NULL AND i.visible = 0 AND i.avalaible = 0
|
||||
AND IFNULL(i.sd, 0) = 0, FALSE, TRUE) filtret,
|
||||
IF(cy.cItemFk IS NULL AND i.visible = 0
|
||||
AND i.avalaible = 0 AND (i.sd IS NULL OR i.sd = 0),
|
||||
FALSE,
|
||||
TRUE
|
||||
) filtret,
|
||||
IF(it.hasMinPrice, FORMAT(it.minPrice, 2), "") pvp,
|
||||
s.company_name
|
||||
FROM tmp.itemInventory i
|
||||
JOIN item it ON it.id = i.id
|
||||
LEFT JOIN itemType tp ON tp.id = it.typeFk
|
||||
LEFT JOIN worker w ON w.id = tp.workerFk
|
||||
JOIN itemType tp ON tp.id = it.typeFk
|
||||
JOIN worker w ON w.id = tp.workerFk
|
||||
LEFT JOIN buy b ON b.id = i.buy_id
|
||||
LEFT JOIN entry e ON e.id = b.entryFk
|
||||
LEFT JOIN origin o ON o.id = it.originFk
|
||||
LEFT JOIN `entry` e ON e.id = b.entryFk
|
||||
JOIN origin o ON o.id = it.originFk
|
||||
LEFT JOIN tLastYear ly ON ly.lItemFk = it.id
|
||||
LEFT JOIN tCurrentYear cy ON cy.cItemFk = 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 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 tmp.itemInventory,
|
||||
DROP TEMPORARY TABLE IF EXISTS
|
||||
tmp.itemInventory,
|
||||
tTwoYearsAgo,
|
||||
tLastYear,
|
||||
tCurrentYear,
|
||||
|
|
|
@ -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 ;
|
|
@ -9,7 +9,7 @@ BEGIN
|
|||
* @vItemFk item a buscar
|
||||
* @vWarehouseFk almacen donde buscar
|
||||
* @vDate Si la fecha es null, muestra el histórico desde el inventario.
|
||||
* Si la fecha no es null, muestra histórico desde la fecha pasada.
|
||||
* Si la fecha no es null, muestra histórico desde la fecha de vDate.
|
||||
*/
|
||||
DECLARE vDateInventory DATETIME;
|
||||
|
||||
|
@ -40,117 +40,154 @@ BEGIN
|
|||
inventorySupplierFk INT(10)
|
||||
);
|
||||
|
||||
INSERT INTO tItemDiary
|
||||
SELECT tr.landed shipped,
|
||||
b.quantity `in`,
|
||||
NULL `out`,
|
||||
st.alertLevel ,
|
||||
st.name stateName,
|
||||
s.name `name`,
|
||||
e.invoiceNumber reference,
|
||||
e.id origin,
|
||||
s.id clientFk,
|
||||
IF(st.`code` = 'DELIVERED', TRUE, FALSE) isPicked,
|
||||
FALSE isTicket,
|
||||
b.id lineFk,
|
||||
NULL `order`,
|
||||
NULL clientType,
|
||||
NULL claimFk,
|
||||
ec.inventorySupplierFk
|
||||
FROM buy b
|
||||
JOIN entry e ON e.id = b.entryFk
|
||||
JOIN travel tr ON tr.id = e.travelFk
|
||||
JOIN supplier s ON s.id = e.supplierFk
|
||||
JOIN state st ON st.`code` = IF( tr.landed < util.VN_CURDATE()
|
||||
OR (util.VN_CURDATE() AND tr.isReceived),
|
||||
'DELIVERED',
|
||||
'FREE')
|
||||
JOIN entryConfig ec
|
||||
WHERE tr.landed >= vDateInventory
|
||||
AND vWarehouseFk = tr.warehouseInFk
|
||||
AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL)
|
||||
AND b.itemFk = vItemFk
|
||||
AND e.isExcludedFromAvailable = FALSE
|
||||
AND e.isRaid = FALSE
|
||||
UNION ALL
|
||||
SELECT tr.shipped,
|
||||
NULL,
|
||||
b.quantity,
|
||||
st.alertLevel,
|
||||
st.name,
|
||||
s.name,
|
||||
e.invoiceNumber,
|
||||
e.id,
|
||||
s.id,
|
||||
IF(st.`code` = 'DELIVERED' , TRUE, FALSE),
|
||||
FALSE,
|
||||
b.id,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
ec.inventorySupplierFk
|
||||
FROM buy b
|
||||
JOIN entry e ON e.id = b.entryFk
|
||||
JOIN travel tr ON tr.id = e.travelFk
|
||||
JOIN warehouse w ON w.id = tr.warehouseOutFk
|
||||
JOIN supplier s ON s.id = e.supplierFk
|
||||
JOIN state st ON st.`code` = IF(tr.shipped < util.VN_CURDATE()
|
||||
INSERT INTO tItemDiary
|
||||
WITH entriesIn AS (
|
||||
SELECT tr.landed shipped,
|
||||
b.quantity `in`,
|
||||
NULL `out`,
|
||||
st.alertLevel ,
|
||||
st.name stateName,
|
||||
s.name `name`,
|
||||
e.invoiceNumber reference,
|
||||
e.id origin,
|
||||
s.id clientFk,
|
||||
IF(st.`code` = 'DELIVERED', TRUE, FALSE) isPicked,
|
||||
FALSE isTicket,
|
||||
b.id lineFk,
|
||||
NULL `order`,
|
||||
NULL clientType,
|
||||
NULL claimFk,
|
||||
ec.inventorySupplierFk
|
||||
FROM vn.buy b
|
||||
JOIN vn.entry e ON e.id = b.entryFk
|
||||
JOIN vn.travel tr ON tr.id = e.travelFk
|
||||
JOIN vn.supplier s ON s.id = e.supplierFk
|
||||
JOIN vn.state st ON st.`code` = IF( tr.landed < util.VN_CURDATE()
|
||||
OR (util.VN_CURDATE() AND tr.isReceived),
|
||||
'DELIVERED',
|
||||
'FREE')
|
||||
JOIN vn.entryConfig ec
|
||||
WHERE tr.landed >= vDateInventory
|
||||
AND vWarehouseFk = tr.warehouseInFk
|
||||
AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL)
|
||||
AND b.itemFk = vItemFk
|
||||
AND NOT e.isExcludedFromAvailable
|
||||
AND NOT e.isRaid
|
||||
), entriesOut AS (
|
||||
SELECT tr.shipped,
|
||||
NULL,
|
||||
b.quantity,
|
||||
st.alertLevel,
|
||||
st.name stateName,
|
||||
s.name ,
|
||||
e.invoiceNumber,
|
||||
e.id entryFk,
|
||||
s.id supplierFk,
|
||||
IF(st.`code` = 'DELIVERED' , TRUE, FALSE),
|
||||
FALSE isTicket,
|
||||
b.id,
|
||||
NULL `order`,
|
||||
NULL clientType,
|
||||
NULL claimFk,
|
||||
ec.inventorySupplierFk
|
||||
FROM vn.buy b
|
||||
JOIN vn.entry e ON e.id = b.entryFk
|
||||
JOIN vn.travel tr ON tr.id = e.travelFk
|
||||
JOIN vn.warehouse w ON w.id = tr.warehouseOutFk
|
||||
JOIN vn.supplier s ON s.id = e.supplierFk
|
||||
JOIN vn.state st ON st.`code` = IF(tr.shipped < util.VN_CURDATE()
|
||||
OR (tr.shipped = util.VN_CURDATE() AND tr.isReceived),
|
||||
'DELIVERED',
|
||||
'FREE')
|
||||
JOIN entryConfig ec
|
||||
WHERE tr.shipped >= vDateInventory
|
||||
AND vWarehouseFk = tr.warehouseOutFk
|
||||
AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL)
|
||||
AND b.itemFk = vItemFk
|
||||
AND e.isExcludedFromAvailable = FALSE
|
||||
AND w.isFeedStock = FALSE
|
||||
AND e.isRaid = FALSE
|
||||
UNION ALL
|
||||
SELECT DATE(t.shipped),
|
||||
NULL,
|
||||
s.quantity,
|
||||
st2.alertLevel,
|
||||
st2.name,
|
||||
t.nickname,
|
||||
t.refFk,
|
||||
t.id,
|
||||
t.clientFk,
|
||||
stk.id,
|
||||
TRUE,
|
||||
s.id,
|
||||
st.`order`,
|
||||
c.typeFk,
|
||||
cb.claimFk,
|
||||
NULL
|
||||
FROM sale s
|
||||
JOIN ticket t ON t.id = s.ticketFk
|
||||
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
LEFT JOIN state st ON st.`code` = ts.`code`
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
JOIN state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(),
|
||||
'DELIVERED',
|
||||
IF (t.shipped > util.dayEnd(util.VN_CURDATE()),
|
||||
'FREE',
|
||||
IFNULL(ts.code, 'FREE')))
|
||||
LEFT JOIN state stPrep ON stPrep.`code` = 'PREPARED'
|
||||
LEFT JOIN saleTracking stk ON stk.saleFk = s.id
|
||||
AND stk.stateFk = stPrep.id
|
||||
LEFT JOIN claimBeginning cb ON s.id = cb.saleFk
|
||||
WHERE t.shipped >= vDateInventory
|
||||
AND s.itemFk = vItemFk
|
||||
AND vWarehouseFk =t.warehouseFk
|
||||
ORDER BY shipped,
|
||||
(inventorySupplierFk = clientFk) DESC,
|
||||
alertLevel DESC,
|
||||
isTicket,
|
||||
`order` DESC,
|
||||
isPicked DESC,
|
||||
`in` DESC,
|
||||
`out` DESC;
|
||||
'DELIVERED',
|
||||
'FREE')
|
||||
JOIN vn.entryConfig ec
|
||||
WHERE tr.shipped >= vDateInventory
|
||||
AND vWarehouseFk = tr.warehouseOutFk
|
||||
AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL)
|
||||
AND b.itemFk = vItemFk
|
||||
AND NOT e.isExcludedFromAvailable
|
||||
AND NOT w.isFeedStock
|
||||
AND NOT e.isRaid
|
||||
), sales AS (
|
||||
SELECT DATE(t.shipped) shipped,
|
||||
s.quantity,
|
||||
st2.alertLevel,
|
||||
st2.name,
|
||||
t.nickname,
|
||||
t.refFk,
|
||||
t.id ticketFk,
|
||||
t.clientFk,
|
||||
s.id saleFk,
|
||||
st.`order`,
|
||||
c.typeFk,
|
||||
cb.claimFk
|
||||
FROM vn.sale s
|
||||
JOIN vn.ticket t ON t.id = s.ticketFk
|
||||
LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id
|
||||
LEFT JOIN vn.state st ON st.`code` = ts.`code`
|
||||
JOIN vn.client c ON c.id = t.clientFk
|
||||
JOIN vn.state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(),
|
||||
'DELIVERED',
|
||||
IF (t.shipped > util.dayEnd(util.VN_CURDATE()),
|
||||
'FREE',
|
||||
IFNULL(ts.code, 'FREE')))
|
||||
LEFT JOIN vn.claimBeginning cb ON s.id = cb.saleFk
|
||||
WHERE t.shipped >= vDateInventory
|
||||
AND s.itemFk = vItemFk
|
||||
AND vWarehouseFk = t.warehouseFk
|
||||
),sale AS (
|
||||
SELECT s.shipped,
|
||||
NULL `in`,
|
||||
s.quantity,
|
||||
s.alertLevel,
|
||||
s.name,
|
||||
s.nickname,
|
||||
s.refFk,
|
||||
s.ticketFk,
|
||||
s.clientFk,
|
||||
IF(stk.saleFk, TRUE, NULL),
|
||||
TRUE,
|
||||
s.saleFk,
|
||||
s.`order`,
|
||||
s.typeFk,
|
||||
s.claimFk,
|
||||
NULL
|
||||
FROM sales s
|
||||
LEFT JOIN vn.state stPrep ON stPrep.`code` = 'PREPARED'
|
||||
LEFT JOIN vn.saleTracking stk ON stk.saleFk = s.saleFk
|
||||
AND stk.stateFk = stPrep.id
|
||||
GROUP BY s.saleFk
|
||||
) SELECT shipped,
|
||||
`in`,
|
||||
`out`,
|
||||
alertLevel,
|
||||
stateName,
|
||||
`name`,
|
||||
reference,
|
||||
origin,
|
||||
clientFk,
|
||||
isPicked,
|
||||
isTicket,
|
||||
lineFk,
|
||||
`order`,
|
||||
clientType,
|
||||
claimFk,
|
||||
inventorySupplierFk
|
||||
FROM entriesIn
|
||||
UNION ALL
|
||||
SELECT * FROM entriesOut
|
||||
UNION ALL
|
||||
SELECT * FROM sale
|
||||
ORDER BY shipped,
|
||||
(inventorySupplierFk = clientFk) DESC,
|
||||
alertLevel DESC,
|
||||
isTicket,
|
||||
`order` DESC,
|
||||
isPicked DESC,
|
||||
`in` DESC,
|
||||
`out` DESC;
|
||||
|
||||
IF vDate IS NULL THEN
|
||||
|
||||
|
||||
SET @a := 0;
|
||||
SET @currentLineFk := 0;
|
||||
SET @shipped := '';
|
||||
|
@ -220,7 +257,7 @@ BEGIN
|
|||
FROM tItemDiary
|
||||
WHERE shipped >= vDate;
|
||||
END IF;
|
||||
|
||||
|
||||
DROP TEMPORARY TABLE tItemDiary;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -21,6 +21,9 @@ BEGIN
|
|||
|
||||
CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vDated);
|
||||
|
||||
-- Añadido temporalmente para que no se cuelgue la db
|
||||
SET vShowType = TRUE;
|
||||
|
||||
WITH itemTags AS (
|
||||
SELECT i.id,
|
||||
typeFk,
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
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
|
||||
DECLARE vInventoried DATE;
|
||||
DECLARE vHasNotInventory BOOLEAN DEFAULT FALSE;
|
||||
|
@ -15,8 +17,7 @@ BEGIN
|
|||
SELECT tr.landed INTO vInventoried
|
||||
FROM travel tr
|
||||
JOIN `entry` e ON e.travelFk = tr.id
|
||||
JOIN entryConfig ec
|
||||
WHERE landed <= vDateDayEnd
|
||||
WHERE tr.landed <= vDateDayEnd
|
||||
AND e.supplierFk = vInventorySupplierFk
|
||||
ORDER BY tr.landed DESC
|
||||
LIMIT 1;
|
||||
|
@ -27,8 +28,7 @@ BEGIN
|
|||
SELECT landed INTO vInventoryClone
|
||||
FROM travel tr
|
||||
JOIN `entry` e ON e.travelFk = tr.id
|
||||
JOIN entryConfig ec
|
||||
WHERE landed >= vDated
|
||||
WHERE tr.landed >= vDated
|
||||
AND e.supplierFk = vInventorySupplierFk
|
||||
ORDER BY landed ASC
|
||||
LIMIT 1;
|
||||
|
@ -38,13 +38,14 @@ BEGIN
|
|||
END IF;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tInventory(
|
||||
warehouseFk SMALLINT,
|
||||
itemFk BIGINT,
|
||||
quantity INT,
|
||||
cost DOUBLE DEFAULT 0,
|
||||
total DOUBLE DEFAULT 0,
|
||||
warehouseInventory VARCHAR(20),
|
||||
PRIMARY KEY (warehouseInventory, itemFk) USING HASH
|
||||
warehouseFk SMALLINT,
|
||||
itemFk BIGINT,
|
||||
quantity INT,
|
||||
volume DECIMAL(10,2),
|
||||
cost DOUBLE DEFAULT 0,
|
||||
total DOUBLE DEFAULT 0,
|
||||
warehouseInventory VARCHAR(20),
|
||||
PRIMARY KEY (warehouseInventory, itemFk) USING HASH
|
||||
)
|
||||
ENGINE = MEMORY;
|
||||
|
||||
|
@ -60,9 +61,8 @@ BEGIN
|
|||
JOIN `entry` e ON e.id = b.entryFk
|
||||
JOIN travel tr ON tr.id = e.travelFk
|
||||
JOIN itemType t ON t.id = i.typeFk
|
||||
JOIN warehouse w ON w.id = warehouseInFk
|
||||
JOIN entryConfig ec
|
||||
WHERE landed = vDateDayEnd
|
||||
JOIN warehouse w ON w.id = tr.warehouseInFk
|
||||
WHERE tr.landed = vDateDayEnd
|
||||
AND e.supplierFk = vInventorySupplierFk
|
||||
AND w.valuatedInventory
|
||||
AND t.isInventory
|
||||
|
@ -78,9 +78,8 @@ BEGIN
|
|||
JOIN `entry` e ON e.id = b.entryFk
|
||||
JOIN travel tr ON tr.id = e.travelFk
|
||||
JOIN itemType t ON t.id = i.typeFk
|
||||
JOIN warehouse w ON w.id = warehouseInFk
|
||||
JOIN entryConfig ec
|
||||
WHERE landed = vInventoried
|
||||
JOIN warehouse w ON w.id = tr.warehouseInFk
|
||||
WHERE tr.landed = vInventoried
|
||||
AND e.supplierFk = vInventorySupplierFk
|
||||
AND w.valuatedInventory
|
||||
AND t.isInventory
|
||||
|
@ -99,7 +98,6 @@ BEGIN
|
|||
JOIN travel tr ON tr.id = e.travelFk
|
||||
JOIN itemType t ON t.id = i.typeFk
|
||||
JOIN warehouse w ON w.id = tr.warehouseInFk
|
||||
JOIN entryConfig ec
|
||||
WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd
|
||||
AND IF(tr.landed = util.VN_CURDATE(), tr.isReceived, TRUE)
|
||||
AND NOT e.isRaid
|
||||
|
@ -183,52 +181,37 @@ BEGIN
|
|||
AND e.isConfirmed
|
||||
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
|
||||
JOIN tmp.buyUltimate bu ON i.warehouseFk = bu.warehouseFk AND i.itemFk = bu.itemFk
|
||||
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)),
|
||||
cost = IFNULL(b.buyingValue, 0) + IFNULL(b.packageValue, 0) + IFNULL(b.freightValue, 0) + IFNULL(b.comissionValue, 0)
|
||||
WHERE i.quantity;
|
||||
LEFT JOIN itemCost ic ON ic.itemFk = i.itemFk
|
||||
AND ic.warehouseFk = i.warehouseFk
|
||||
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
|
||||
WHERE quantity IS NULL OR NOT quantity;
|
||||
|
||||
IF vIsDetailed THEN
|
||||
SELECT ti.warehouseFk,
|
||||
i.id itemFk,
|
||||
i.longName,
|
||||
i.size,
|
||||
ti.quantity,
|
||||
tp.name Tipo,
|
||||
ic.name Reino,
|
||||
ti.cost,
|
||||
CAST(ti.total AS DECIMAL(10, 2)) total,
|
||||
ti.warehouseInventory almacen
|
||||
FROM tInventory ti
|
||||
JOIN warehouse w ON w.id = warehouseFk
|
||||
JOIN item i ON i.id = ti.itemFk
|
||||
JOIN itemType tp ON tp.id = i.typeFk
|
||||
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;
|
||||
SELECT ti.warehouseFk,
|
||||
i.id,
|
||||
i.longName,
|
||||
i.size,
|
||||
ti.quantity,
|
||||
ti.volume,
|
||||
tp.name itemTypeName,
|
||||
ic.name itemCategoryName,
|
||||
ti.cost,
|
||||
ti.total,
|
||||
ti.warehouseInventory
|
||||
FROM tInventory ti
|
||||
JOIN warehouse w ON w.id = warehouseFk
|
||||
JOIN item i ON i.id = ti.itemFk
|
||||
JOIN itemType tp ON tp.id = i.typeFk
|
||||
JOIN itemCategory ic ON ic.id = tp.categoryFk
|
||||
WHERE w.valuatedInventory
|
||||
AND ti.total > 0;
|
||||
|
||||
DROP TEMPORARY TABLE
|
||||
tmp.buyUltimate,
|
|
@ -1,5 +1,13 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_doCompensation`(vDated DATE, vCompensationAccount VARCHAR(10) , vBankFk VARCHAR(10), vConcept VARCHAR(255), vAmount DECIMAL(10,2), vCompanyFk INT, vOriginalAccount VARCHAR(10))
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_doCompensation`(
|
||||
vDated DATE,
|
||||
vCompensationAccount VARCHAR(10),
|
||||
vBankFk VARCHAR(10),
|
||||
vConcept VARCHAR(255),
|
||||
vAmount DECIMAL(10,2),
|
||||
vCompanyFk INT,
|
||||
vOriginalAccount VARCHAR(10)
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Compensa un pago o un recibo insertando en contabilidad
|
||||
|
@ -9,29 +17,31 @@ BEGIN
|
|||
* @param vBankFk banco de la compensacion
|
||||
* @param vConcept descripcion
|
||||
* @param vAmount cantidad que se compensa
|
||||
* @param vCompany empresa
|
||||
* @param vCompanyFk empresa
|
||||
* @param vOriginalAccount cuenta contable desde la cual se compensa
|
||||
*
|
||||
*/
|
||||
*/
|
||||
DECLARE vNewBookEntry INT;
|
||||
DECLARE vIsClientCompensation INT;
|
||||
DECLARE vIsClientCompensation INT;
|
||||
DECLARE vClientFk INT;
|
||||
DECLARE vSupplierFk INT;
|
||||
DECLARE vIsOriginalAClient BOOL;
|
||||
DECLARE vPayMethodCompensation INT;
|
||||
|
||||
CALL ledger_next(vNewBookEntry);
|
||||
DECLARE vSupplierFk INT;
|
||||
DECLARE vIsOriginalAClient BOOL;
|
||||
DECLARE vPayMethodCompensation INT;
|
||||
|
||||
SELECT COUNT(id) INTO vIsOriginalAClient FROM client WHERE accountingAccount LIKE vOriginalAccount COLLATE utf8_general_ci;
|
||||
CALL ledger_next(YEAR(vDated), FALSE, vNewBookEntry);
|
||||
|
||||
SELECT COUNT(id) INTO vIsOriginalAClient
|
||||
FROM client
|
||||
WHERE accountingAccount LIKE vOriginalAccount COLLATE utf8_general_ci;
|
||||
|
||||
SELECT id, COUNT(id) INTO vClientFk, vIsClientCompensation
|
||||
FROM client
|
||||
WHERE accountingAccount LIKE vCompensationAccount COLLATE utf8_general_ci;
|
||||
|
||||
|
||||
SET @vAmount1:= 0.0;
|
||||
SET @vAmount2:= 0.0;
|
||||
|
||||
INSERT INTO XDiario (ASIEN, FECHA, SUBCTA, CONTRA, CONCEPTO, EURODEBE, EUROHABER, empresa_id)
|
||||
INSERT INTO XDiario (ASIEN, FECHA, SUBCTA, CONTRA, CONCEPTO, EURODEBE, EUROHABER, empresa_id)
|
||||
VALUES ( vNewBookEntry,
|
||||
vDated,
|
||||
vOriginalAccount,
|
||||
|
@ -49,30 +59,51 @@ BEGIN
|
|||
),
|
||||
vCompanyFk
|
||||
),
|
||||
( vNewBookEntry,
|
||||
vDated,
|
||||
vCompensationAccount,
|
||||
vOriginalAccount,
|
||||
vConcept,
|
||||
@vAmount2,
|
||||
( vNewBookEntry,
|
||||
vDated,
|
||||
vCompensationAccount,
|
||||
vOriginalAccount,
|
||||
vConcept,
|
||||
@vAmount2,
|
||||
@vAmount1,
|
||||
vCompanyFk);
|
||||
|
||||
IF vIsClientCompensation THEN
|
||||
IF vIsOriginalAClient THEN
|
||||
SET vAmount = -vAmount;
|
||||
END IF;
|
||||
INSERT INTO receipt(invoiceFk, amountPaid, payed, bankFk, companyFk, clientFk, isConciliate)
|
||||
VALUES (vConcept, vAmount, vDated, vBankFk, vCompanyFk, vClientFk, TRUE);
|
||||
ELSE
|
||||
IF NOT vIsOriginalAClient THEN
|
||||
SET vAmount = -vAmount;
|
||||
END IF;
|
||||
SELECT id INTO vSupplierFk FROM supplier WHERE `account` LIKE vCompensationAccount COLLATE utf8_general_ci;
|
||||
SELECT id INTO vPayMethodCompensation FROM payMethod WHERE `code` = 'compensation';
|
||||
|
||||
INSERT INTO payment (received, dueDated, supplierFk, amount, bankFk, payMethodFk, concept, companyFk, isConciliated)
|
||||
VALUES(vDated, vDated, vSupplierFk, vAmount, vBankFk, vPayMethodCompensation, vConcept, vCompanyFk, TRUE);
|
||||
END IF;
|
||||
vCompanyFk);
|
||||
|
||||
IF vIsClientCompensation THEN
|
||||
IF vIsOriginalAClient THEN
|
||||
SET vAmount = -vAmount;
|
||||
END IF;
|
||||
|
||||
INSERT INTO receipt
|
||||
SET invoiceFk = vConcept,
|
||||
amountPaid = vAmount,
|
||||
payed = vDated,
|
||||
bankFk = vBankFk,
|
||||
companyFk = vCompanyFk,
|
||||
clientFk = vClientFk,
|
||||
isConciliate = TRUE;
|
||||
ELSE
|
||||
IF NOT vIsOriginalAClient THEN
|
||||
SET vAmount = -vAmount;
|
||||
END IF;
|
||||
|
||||
SELECT id INTO vSupplierFk
|
||||
FROM supplier
|
||||
WHERE `account` LIKE vCompensationAccount COLLATE utf8_general_ci;
|
||||
|
||||
SELECT id INTO vPayMethodCompensation
|
||||
FROM payMethod
|
||||
WHERE `code` = 'compensation';
|
||||
|
||||
INSERT INTO payment
|
||||
SET received = vDated,
|
||||
dueDated = vDated,
|
||||
supplierFk = vSupplierFk,
|
||||
amount = vAmount,
|
||||
bankFk = vBankFk,
|
||||
payMethodFk = vPayMethodCompensation,
|
||||
concept = vConcept,
|
||||
companyFk = vCompanyFk,
|
||||
isConciliated = TRUE;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -1,9 +1,60 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_next`(OUT vNewBookEntry INT)
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_next`(
|
||||
IN vFiscalYear INT,
|
||||
IN vIsManageTransaction BOOLEAN,
|
||||
OUT vLastBookEntry INT
|
||||
)
|
||||
BEGIN
|
||||
|
||||
UPDATE vn.ledgerConfig SET lastBookEntry = LAST_INSERT_ID(lastBookEntry + 1);
|
||||
SET vNewBookEntry = LAST_INSERT_ID();
|
||||
|
||||
DECLARE vHasStartTransaction BOOLEAN;
|
||||
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
|
||||
IF vHasStartTransaction THEN
|
||||
ROLLBACK TO sp;
|
||||
RESIGNAL;
|
||||
ELSE
|
||||
ROLLBACK;
|
||||
CALL util.throw ('It has not been possible to generate a new ledger');
|
||||
END IF;
|
||||
END;
|
||||
|
||||
IF vFiscalYear IS NULL THEN
|
||||
CALL util.throw('Fiscal year is required');
|
||||
END IF;
|
||||
|
||||
IF NOT vIsManageTransaction THEN
|
||||
SELECT @@in_transaction INTO vHasStartTransaction;
|
||||
|
||||
IF NOT vHasStartTransaction THEN
|
||||
START TRANSACTION;
|
||||
ELSE
|
||||
SAVEPOINT sp;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
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;
|
||||
|
||||
IF NOT vIsManageTransaction THEN
|
||||
IF vHasStartTransaction THEN
|
||||
RELEASE SAVEPOINT sp;
|
||||
ELSE
|
||||
COMMIT;
|
||||
END IF;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
DELIMITER ;
|
|
@ -1,121 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`packageInvoicing`(
|
||||
IN vClient INT,
|
||||
IN vDate DATE,
|
||||
IN vCompany INT,
|
||||
IN vIsAllInvoiceable BOOLEAN,
|
||||
OUT vNewTicket INT(11)
|
||||
)
|
||||
BEGIN
|
||||
|
||||
DECLARE vGraceDays INT;
|
||||
DECLARE vDateStart DATE DEFAULT '2017-11-21';
|
||||
DECLARE vIsInvoiceable BOOLEAN;
|
||||
DECLARE vWarehouse INT DEFAULT 13;
|
||||
DECLARE vComponentCost INT DEFAULT 28;
|
||||
DECLARE vGraceDate DATE;
|
||||
DECLARE vDateEnd DATE;
|
||||
|
||||
SET vGraceDays = IF(vIsAllInvoiceable ,0, 30);
|
||||
SET vGraceDate = TIMESTAMPADD(DAY, - vGraceDays, vDate);
|
||||
|
||||
/* Clientes especiales:
|
||||
3240 MADEFLOR
|
||||
992 JAVIER FELIU
|
||||
4 TONI VENDRELL
|
||||
*/
|
||||
|
||||
IF vClient IN (992, 3240, 4) THEN
|
||||
|
||||
SET vGraceDays = 365;
|
||||
|
||||
END IF;
|
||||
/* Fin clientes especiales */
|
||||
|
||||
SET vDateEnd = DATE_ADD(vDate, INTERVAL 1 DAY);
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.packageToInvoice;
|
||||
|
||||
CREATE TEMPORARY TABLE tmp.packageToInvoice
|
||||
SELECT p.itemFk,
|
||||
tp.packagingFk,
|
||||
IF(tp.quantity < 0 OR t.shipped < vGraceDate, tp.quantity, 0) quantity,
|
||||
tp.ticketFk,
|
||||
p.price
|
||||
FROM ticketPackaging tp
|
||||
JOIN packaging p ON p.id = tp.packagingFk
|
||||
JOIN ticket t ON t.id = tp.ticketFk
|
||||
WHERE t.shipped BETWEEN vDateStart AND vDateEnd
|
||||
AND t.clientFk = vClient;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.packageToInvoicePositives;
|
||||
|
||||
CREATE TEMPORARY TABLE tmp.packageToInvoicePositives
|
||||
SELECT itemFk, sum(quantity) as totalQuantity
|
||||
FROM tmp.packageToInvoice
|
||||
GROUP BY itemFk
|
||||
HAVING totalQuantity > 0;
|
||||
|
||||
SELECT COUNT(*)
|
||||
INTO vIsInvoiceable
|
||||
FROM tmp.packageToInvoicePositives;
|
||||
|
||||
IF vIsInvoiceable THEN
|
||||
|
||||
CALL ticket_add(vClient,
|
||||
vDateEnd,
|
||||
vWarehouse,
|
||||
vCompany,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
vDateEnd,
|
||||
account.myUser_getId(),
|
||||
TRUE,
|
||||
vNewTicket);
|
||||
|
||||
INSERT INTO ticketPackaging(
|
||||
ticketFk,
|
||||
packagingFk,
|
||||
quantity,
|
||||
pvp)
|
||||
SELECT vNewTicket,
|
||||
pti.packagingFk,
|
||||
- SUM(pti.quantity) AS totalQuantity,
|
||||
pti.price
|
||||
FROM tmp.packageToInvoice pti
|
||||
LEFT JOIN tmp.packageToInvoicePositives ptip ON pti.itemFk = ptip.itemFk
|
||||
WHERE ptip.itemFK IS NOT NULL
|
||||
OR vIsAllInvoiceable
|
||||
GROUP BY packagingFk
|
||||
HAVING totalQuantity;
|
||||
|
||||
INSERT INTO sale(
|
||||
ticketFk,
|
||||
itemFk,
|
||||
concept,
|
||||
quantity,
|
||||
price
|
||||
)
|
||||
SELECT vNewTicket,
|
||||
pti.itemFk,
|
||||
i.name as concept,
|
||||
sum(pti.quantity) as totalQuantity,
|
||||
pti.price
|
||||
FROM tmp.packageToInvoice pti
|
||||
JOIN item i ON i.id = pti.itemFk
|
||||
LEFT JOIN tmp.packageToInvoicePositives ptip ON pti.itemFk = ptip.itemFk
|
||||
WHERE ptip.itemFK IS NOT NULL
|
||||
OR vIsAllInvoiceable
|
||||
GROUP BY pti.itemFk
|
||||
HAVING totalQuantity;
|
||||
|
||||
INSERT INTO saleComponent(saleFk, componentFk, value)
|
||||
SELECT id, vComponentCost, price
|
||||
FROM sale
|
||||
WHERE ticketFk = vNewTicket;
|
||||
|
||||
END IF;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -20,7 +20,7 @@ BEGIN
|
|||
CONCAT(tc.collectionFk, ' ', LEFT(cc.code, 4)) color,
|
||||
CONCAT(tc.collectionFk, ' ', SUBSTRING('ABCDEFGH',tc.wagon, 1), '-', tc.level) levelV,
|
||||
tc.ticketFk,
|
||||
LEFT(COALESCE(et.description, zo.name, am.name),12) agencyDescription,
|
||||
LEFT(COALESCE(rs.description, zo.name, am.name),12) agencyDescription,
|
||||
am.name,
|
||||
t.clientFk,
|
||||
CONCAT(CAST(SUM(sv.volume) AS DECIMAL(5, 2)), 'm³') m3 ,
|
||||
|
@ -47,7 +47,7 @@ BEGIN
|
|||
LEFT JOIN ticketTrolley tt ON tt.ticket = t.id
|
||||
LEFT JOIN zone zo ON t.zoneFk = zo.id
|
||||
LEFT JOIN routesMonitor rm ON rm.routeFk = t.routeFk
|
||||
LEFT JOIN expeditionTruck et ON et.id = rm.expeditionTruckFk
|
||||
LEFT JOIN roadmapStop rs ON rs.id = rm.expeditionTruckFk
|
||||
WHERE IF(vIsCollection, tc.collectionFk = vParam, tc.ticketFk = vParam)
|
||||
GROUP BY t.id
|
||||
ORDER BY cc.code;
|
||||
|
|
|
@ -106,8 +106,8 @@ BEGIN
|
|||
SET rm.m3boxes = sub.m3boxes;
|
||||
|
||||
UPDATE routesMonitor rm
|
||||
JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk
|
||||
SET rm.etd = et.eta;
|
||||
JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk
|
||||
SET rm.etd = rs.eta;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.routesMonitor;
|
||||
END$$
|
||||
|
|
|
@ -44,6 +44,7 @@ BEGIN
|
|||
hasComponentLack INTEGER(1),
|
||||
hasRounding VARCHAR(255),
|
||||
isTooLittle BOOL DEFAULT FALSE,
|
||||
isVip BOOL DEFAULT FALSE,
|
||||
PRIMARY KEY (ticketFk, saleFk)
|
||||
) ENGINE = MEMORY;
|
||||
|
||||
|
@ -79,6 +80,14 @@ BEGIN
|
|||
JOIN volumeConfig vc
|
||||
WHERE sub.litros < vc.minTicketVolume
|
||||
AND sub.totalWithoutVat < vc.minTicketValue;
|
||||
|
||||
-- VIP
|
||||
INSERT INTO tmp.sale_problems(ticketFk, isVip)
|
||||
SELECT DISTINCT tl.ticketFk, TRUE
|
||||
FROM tmp.ticket_list tl
|
||||
JOIN client c ON c.id = tl.clientFk
|
||||
WHERE c.businessTypeFk = 'VIP'
|
||||
ON DUPLICATE KEY UPDATE isVip = TRUE;
|
||||
|
||||
-- Faltan componentes
|
||||
INSERT INTO tmp.sale_problems(ticketFk, hasComponentLack, saleFk)
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_setProblem`(
|
||||
vProblemCode VARCHAR(25)
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Update column sale.problem with a problem code
|
||||
* @param vProblemCode Code to set or unset
|
||||
* @table tmp.sale(saleFk, hasProblem)
|
||||
*/
|
||||
UPDATE sale s
|
||||
JOIN tmp.sale ts ON ts.saleFk = s.id
|
||||
SET s.problem = CONCAT(
|
||||
IF(ts.hasProblem,
|
||||
CONCAT(s.problem, ',', vProblemCode),
|
||||
REPLACE(s.problem, vProblemCode , '')));
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,21 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_setProblemComponentLack`(
|
||||
vSelf INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Update the problems for sales lines that have or no longer have problems with components,
|
||||
* verify whether all mandatory components are present or not
|
||||
*
|
||||
* @param vSelf Id del sale
|
||||
*/
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
||||
(INDEX(saleFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT vSelf saleFk, sale_hasComponentLack(vSelf) hasProblem;
|
||||
|
||||
CALL sale_setProblem('hasComponentLack');
|
||||
|
||||
DROP TEMPORARY TABLE tmp.sale;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,29 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_setProblemComponentLackByComponent`(
|
||||
vComponentFk INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Update the issues for sales lines that have or no longer have problems with components, verify
|
||||
* whether all mandatory components are present or not resulting from changes in the table vn.component
|
||||
*
|
||||
* @param vComponentFk Id component
|
||||
*/
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
||||
(INDEX(saleFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT saleFk, sale_hasComponentLack(saleFk)hasProblem
|
||||
FROM (
|
||||
SELECT s.id saleFk
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
|
||||
WHERE t.shipped >= util.midnight()
|
||||
AND (vComponentFk IS NULL OR sc.componentFk = vComponentFk)
|
||||
GROUP BY s.id) sub;
|
||||
|
||||
CALL sale_setProblem('hasComponentLack');
|
||||
|
||||
DROP TEMPORARY TABLE tmp.sale;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,34 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_setProblemRounding`(
|
||||
vSelf INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Update the rounding problem for a sales line
|
||||
* @param vSelf Id sale
|
||||
*/
|
||||
DECLARE vItemFk INT;
|
||||
DECLARE vWarehouseFk INT;
|
||||
DECLARE vShipped DATE;
|
||||
DECLARE vQuantity INT;
|
||||
|
||||
SELECT s.itemFk, t.warehouseFk, t.shipped, s.quantity
|
||||
INTO vItemFk, vWarehouseFk, vShipped, vQuantity
|
||||
FROM sale s
|
||||
JOIN ticket t ON t.id = s.ticketFk
|
||||
WHERE s.id = vSelf;
|
||||
|
||||
CALL buyUltimate(vWarehouseFk, vShipped);
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
||||
SELECT vSelf saleFk, MOD(vQuantity, b.`grouping`) hasProblem
|
||||
FROM tmp.buyUltimate bu
|
||||
JOIN buy b ON b.id = bu.buyFk
|
||||
WHERE bu.itemFk = vItemFk;
|
||||
|
||||
CALL sale_setProblem('hasRounding');
|
||||
|
||||
DROP TEMPORARY TABLE tmp.sale;
|
||||
DROP TEMPORARY TABLE tmp.buyUltimate;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -43,7 +43,7 @@ BEGIN
|
|||
INSERT INTO stockBuyed(buyed, dated, description)
|
||||
SELECT SUM(ic.cm3 * ito.quantity / vc.palletM3 / 1000000),
|
||||
vDated,
|
||||
IF(c.code = 'ES', p.name, c.country) destiny
|
||||
IF(c.code = 'ES', p.name, c.name) destiny
|
||||
FROM itemTicketOut ito
|
||||
JOIN ticket t ON t.id = ito.ticketFk
|
||||
JOIN `address` a ON a.id = t.addressFk
|
||||
|
|
|
@ -35,7 +35,7 @@ BEGIN
|
|||
itemFk,
|
||||
longName,
|
||||
supplier,
|
||||
entryFk,
|
||||
CONCAT('E',entryFk) entryFk,
|
||||
landed,
|
||||
`in`,
|
||||
`out`,
|
||||
|
@ -49,16 +49,98 @@ BEGIN
|
|||
itemFk,
|
||||
longName,
|
||||
supplier,
|
||||
'previous',
|
||||
'E previous',
|
||||
vFromDated,
|
||||
SUM(`in`),
|
||||
SUM(`out`),
|
||||
NULL,
|
||||
buyingValue
|
||||
AVG(buyingValue)
|
||||
FROM supplierPackaging
|
||||
WHERE supplierFk = vSupplierFk
|
||||
AND landed < vFromDated
|
||||
GROUP BY itemFk
|
||||
UNION ALL
|
||||
SELECT vSupplierFk,
|
||||
s.itemFk,
|
||||
i.longName,
|
||||
c.name,
|
||||
CONCAT('T',s.ticketFk),
|
||||
DATE(t.shipped),
|
||||
-LEAST(s.quantity,0) `in`,
|
||||
GREATEST(s.quantity,0) `out`,
|
||||
t.warehouseFk,
|
||||
s.price * (100 - s.discount) / 100
|
||||
FROM sale s
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN packaging p ON p.itemFk = i.id
|
||||
JOIN ticket t ON t.id = s.ticketFk
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
JOIN supplier su ON su.nif = c.fi
|
||||
WHERE su.id = vSupplierFk
|
||||
AND t.shipped >= vFromDated
|
||||
AND p.isPackageReturnable
|
||||
UNION ALL
|
||||
SELECT vSupplierFk,
|
||||
s.itemFk,
|
||||
i.longName,
|
||||
c.name,
|
||||
'T previous',
|
||||
vFromDated,
|
||||
SUM(-LEAST(s.quantity,0)) `in`,
|
||||
SUM(GREATEST(s.quantity,0)) `out`,
|
||||
NULL,
|
||||
AVG(s.price * (100 - s.discount) / 100)
|
||||
FROM sale s
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN packaging p ON p.itemFk = i.id
|
||||
JOIN ticket t ON t.id = s.ticketFk
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
JOIN supplier su ON su.nif = c.fi
|
||||
WHERE su.id = vSupplierFk
|
||||
AND t.shipped < vFromDated
|
||||
AND p.isPackageReturnable
|
||||
GROUP BY s.itemFk
|
||||
UNION ALL
|
||||
SELECT vSupplierFk,
|
||||
p.itemFk,
|
||||
i.longName,
|
||||
c.name,
|
||||
CONCAT('TP',tp.ticketFk),
|
||||
DATE(t.shipped),
|
||||
-LEAST(tp.quantity,0) `in`,
|
||||
GREATEST(tp.quantity,0) `out`,
|
||||
t.warehouseFk,
|
||||
0
|
||||
FROM ticketPackaging tp
|
||||
JOIN packaging p ON p.id = tp.packagingFk
|
||||
JOIN item i ON i.id = p.itemFk
|
||||
JOIN ticket t ON t.id = tp.ticketFk
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
JOIN supplier su ON su.nif = c.fi
|
||||
WHERE su.id = vSupplierFk
|
||||
AND t.shipped >= vFromDated
|
||||
AND p.isPackageReturnable
|
||||
UNION ALL
|
||||
SELECT vSupplierFk,
|
||||
p.itemFk,
|
||||
i.longName,
|
||||
c.name,
|
||||
'TP previous',
|
||||
vFromDated,
|
||||
SUM(-LEAST(tp.quantity,0)) `in`,
|
||||
SUM(GREATEST(tp.quantity,0)) `out`,
|
||||
NULL,
|
||||
0
|
||||
FROM ticketPackaging tp
|
||||
JOIN packaging p ON p.id = tp.packagingFk
|
||||
JOIN item i ON i.id = p.itemFk
|
||||
JOIN ticket t ON t.id = tp.ticketFk
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
JOIN supplier su ON su.nif = c.fi
|
||||
WHERE su.id = vSupplierFk
|
||||
AND t.shipped >= vFromDated
|
||||
AND p.isPackageReturnable
|
||||
GROUP BY p.itemFk
|
||||
ORDER BY itemFk, landed, entryFk
|
||||
) sub
|
||||
WHERE `out` OR `in`;
|
||||
|
@ -69,8 +151,8 @@ BEGIN
|
|||
supplier,
|
||||
entryFk,
|
||||
landed,
|
||||
`in`,
|
||||
`out`,
|
||||
CAST(`in` AS DECIMAL(10,0)) `in`,
|
||||
CAST(`out` AS DECIMAL(10,0)) `out`,
|
||||
warehouse,
|
||||
buyingValue,
|
||||
balance
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue