diff --git a/.eslintrc.yml b/.eslintrc.yml
index edbc47195..0d74348f2 100644
--- a/.eslintrc.yml
+++ b/.eslintrc.yml
@@ -36,3 +36,7 @@ rules:
jasmine/no-focused-tests: 0
jasmine/prefer-toHaveBeenCalledWith: 0
arrow-spacing: ["error", { "before": true, "after": true }]
+ no-restricted-syntax:
+ - "error"
+ - selector: "NewExpression[callee.name='Date']"
+ message: "Use Date.vnNew() instead of new Date()."
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 57848aa7f..73ebecabc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,117 @@
+# Version 24.48 - 2024-11-25
+
+### Added 🆕
+
+- feat: refs #4948 Added ticket_selfConsumptionPackaging by:guillermo
+- feat: refs #6818 add config table by:jorgep
+- feat: refs #6818 add records by:jorgep
+- feat: refs #6818 saysimple integration by:jorgep
+- feat: refs #6845 userInterface by:sergiodt
+- feat: refs #6869 add back by:jorgep
+- feat: refs #6869 define model by:jorgep
+- feat: refs #6869 refs#6869 itemShelving_get (origin/6869-createGetDetails) by:sergiodt
+- feat: refs #7006 itemTypeLog by:guillermo
+- feat: refs #7006 itemTypeLog created by:guillermo
+- feat: refs #7006 Requested changes by:guillermo
+- feat: refs #7193 added scope in parking model by:Jon
+- feat: refs #7244 Requested changes by:guillermo
+- feat: refs #7266 Added details and improvements in item label reports by:guillermo
+- feat: refs #7266 buyFkForPrint by:sergiodt
+- feat: refs #7266 First commit by:guillermo
+- feat: refs #7266 Item label barcode by:guillermo
+- feat: refs #7266 Item label QR by:guillermo
+- feat: refs #7266 Item label QR finished by:guillermo
+- feat: refs #7266 Minor change by:guillermo
+- feat: refs #7266 Print corrections by:guillermo
+- feat: refs #7266 Requested changes and improvements by:guillermo
+- feat: refs #7266 Requested changes and query optimization by:guillermo
+- feat: refs #7266 Version by:guillermo
+- feat: refs #7289 #7289 apply option 1 by:Javier Segarra
+- feat: refs #7289 #7289 remove bad translation by:Javier Segarra
+- feat: refs #7524 restrict fields by:jorgep
+- feat: refs #7641 fine tunning by:jorgep
+- feat: refs #7641 improve style by:jorgep
+- feat: refs #7743 add simple spec for sendMail by:pablone
+- feat: refs #7743 add try catch stmt to the test by:pablone
+- feat: refs #7874 add default type by:jorgep
+- feat: refs #7874 use name by:jorgep
+- feat: refs #7920 Added ItemShelving in shelvingLog by:guillermo
+- feat: refs #7921 refs#7921 sendLostExpedition by:sergiodt
+- feat: refs #7922 refs #792 scanOrder by:sergiodt
+- feat: refs #7943 quitar lectura en metodos comunes by:jgallego
+- feat: refs #7943 return just the required content by:jorgep
+- feat: refs #7943 usa back con permisos by:jgallego
+- feat: refs #8020 machineWorkerDeprecated by:sergiodt
+- feat: refs #8057 Added data updates by:guillermo
+- feat: refs #8057 Added data updates (origin/8057-geoFk) by:guillermo
+- feat: refs #8057 Added geoFk columns by:guillermo
+- feat: refs #8057 Fix version by:guillermo
+- feat: refs #8057 More precision in getGeo by:guillermo
+- feat: refs #8057 Requested changes by:guillermo
+- feat: refs #8071 quitar esquema by:robert
+- feat: refs #8071 travel_weeklyClone by:robert
+- feat: refs #8080 Added column comment by:guillermo
+- feat: refs #8083 add prop by:jorgep
+- feat: refs #8087 Traspasar redadas a travels by:Carlos Andrés
+- feat: refs #8099 refs#8099 addComplmentSalary by:sergiodt
+- feat: refs #8124 Enrutadores nuevos requerimientos by:Carlos Andrés
+- feat: refs #8124 Enrutadores nuevos requerimientos (origin/8124-enrutadoresNuevosRequerimientos) by:Carlos Andrés
+- feat: refs #8127 entry_getCommission by:robert
+- feat: refs #8127 quitar esquemas by:robert
+- feat: refs #8135 refs#8135 updateTicketACL (origin/8135-ticketACL) by:sergiodt
+- feat: refs #8143 deprecate recoverPass and sync from account.user by:ivanm
+- feat: refs #8150 movExpeditions by:sergiodt
+- feat: refs #8151 Added test by:guillermo
+- feat: refs #8151 moveExpeditions by:guillermo
+- feat: refs #8151 Requested changes by:guillermo
+- feat(Supplier): refs #6828 add companySize by:alexm
+- refactor: refs #7641 entry report style by:jorgep
+
+### Changed 📦
+
+- refactor: refs #6920 add correct role by:alexm
+- refactor: refs #7242 Deleted select column by:guillermo
+- refactor: refs #7457 Added from param if not exists by:guillermo
+- refactor: refs #7641 entry report style by:jorgep
+- refactor: refs #7715 Deleted hasNewLabelMrwMethod column by:guillermo
+- refactor: refs #7920 Fix tests by:guillermo
+- refactor: refs #7920 Fix version by:guillermo
+- refactor: refs #7920 itemShelvingLog by:guillermo
+- refactor: refs #7920 Main change by:guillermo
+- refactor: refs #7920 Major changes by:guillermo
+- refactor: refs #7920 No changes in itemShelvingLog table by:guillermo
+- refactor: refs #7920 Requested changes by:guillermo
+- refactor: refs #7950 Created cmr model (7950-cmrModelUnify) by:guillermo
+- refactor: refs #7950 Requested changes by:guillermo
+- refactor: refs #8153 Optimized order_getTax by:guillermo
+
+### Fixed 🛠️
+
+- fix: clean deletes also zoneEvent range records by:jgallego
+- fix: more data for fixture.before by:Pako
+- fix: refs #4948 Tests by:guillermo
+- fix: refs #6644 email and translations by:carlossa
+- fix: refs #6818 add config by:jorgep
+- fix: refs #6818 add defaultChannel by:jorgep
+- fix: refs #6818 use right col type by:jorgep
+- fix: refs #6869 use id as primaryKey by:jorgep
+- fix: refs #7244 Added collection ACL by:guillermo
+- fix: refs #7283 item filters by:carlossa
+- fix: refs #7283 remove by:carlossa
+- fix: refs #7283 remove tests by:carlossa
+- fix: refs #7283 tback by:carlossa
+- fix: refs #7323 add remaining fields (origin/7323-warfix-addRemainingFields) by:jorgep
+- fix: refs #7457 add with on select to reduce by:pablone
+- fix: refs #7457 empty commit for gitea by:pablone
+- fix: refs #7457 error on empty from param and add translate by:pablone
+- fix: refs #7457 remove group by calc time reduce bellow 1s by:pablone
+- fix: refs #7457 remove translate and use param definition for restriction by:pablone
+- fix: refs #7641 align columns by:jorgep
+- fix: refs #7641 drop boilerplate code by:jorgep
+- fix: refs #7920 refs#7920 itemShelvingLog by:sergiodt
+- fix: refs #8153 Version by:guillermo
+- revert cd7ed6987a88e00275b562d3248f368b6333620c by:Javier Segarra
+
# Version 24.38 - 2024-09-17
### Added 🆕
diff --git a/Jenkinsfile b/Jenkinsfile
index 19f47c5b0..06addc940 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -7,7 +7,8 @@ def RUN_BUILD
def BRANCH_ENV = [
test: 'test',
- master: 'production'
+ master: 'production',
+ beta: 'production'
]
node {
@@ -18,7 +19,8 @@ node {
PROTECTED_BRANCH = [
'dev',
'test',
- 'master'
+ 'master',
+ 'beta'
].contains(env.BRANCH_NAME)
FROM_GIT = env.JOB_NAME.startsWith('gitea/')
@@ -62,6 +64,18 @@ pipeline {
PROJECT_NAME = 'salix'
}
stages {
+ stage('Version') {
+ when {
+ expression { RUN_BUILD }
+ }
+ steps {
+ script {
+ def packageJson = readJSON file: 'package.json'
+ def version = "${packageJson.version}-build${env.BUILD_ID}"
+ writeFile(file: 'VERSION.txt', text: version)
+ }
+ }
+ }
stage('Install') {
environment {
NODE_ENV = ''
@@ -118,11 +132,10 @@ pipeline {
when {
expression { RUN_BUILD }
}
+ environment {
+ VERSION = readFile 'VERSION.txt'
+ }
steps {
- script {
- def packageJson = readJSON file: 'package.json'
- env.VERSION = "${packageJson.version}-build${env.BUILD_ID}"
- }
sh 'docker-compose build back'
}
}
@@ -156,11 +169,10 @@ pipeline {
when {
expression { RUN_BUILD }
}
+ environment {
+ VERSION = readFile 'VERSION.txt'
+ }
steps {
- script {
- def packageJson = readJSON file: 'package.json'
- env.VERSION = "${packageJson.version}-build${env.BUILD_ID}"
- }
sh 'gulp build'
sh 'docker-compose build front'
}
@@ -175,12 +187,9 @@ pipeline {
}
environment {
CREDENTIALS = credentials('docker-registry')
+ VERSION = readFile 'VERSION.txt'
}
steps {
- script {
- def packageJson = readJSON file: 'package.json'
- env.VERSION = "${packageJson.version}-build${env.BUILD_ID}"
- }
sh 'docker login --username $CREDENTIALS_USR --password $CREDENTIALS_PSW $REGISTRY'
sh 'docker-compose push'
}
@@ -207,11 +216,10 @@ pipeline {
when {
expression { FROM_GIT }
}
+ environment {
+ VERSION = readFile 'VERSION.txt'
+ }
steps {
- script {
- def packageJson = readJSON file: 'package.json'
- env.VERSION = "${packageJson.version}-build${env.BUILD_ID}"
- }
withKubeConfig([
serverUrl: "$KUBERNETES_API",
credentialsId: 'kubernetes',
diff --git a/back/methods/collection/getSales.js b/back/methods/collection/getSales.js
index a9e5f2e60..f3575672f 100644
--- a/back/methods/collection/getSales.js
+++ b/back/methods/collection/getSales.js
@@ -29,10 +29,8 @@ module.exports = Self => {
});
Self.getSales = async(ctx, collectionOrTicketFk, print, source, options) => {
- const models = Self.app.models;
const userId = ctx.req.accessToken.userId;
const myOptions = {userId};
- const $t = ctx.req.__;
if (typeof options == 'object')
Object.assign(myOptions, options);
@@ -59,22 +57,6 @@ module.exports = Self => {
if (print) await Self.rawSql('CALL vn.collection_printSticker(?,NULL)', [id], myOptions);
- for (let ticket of tickets) {
- if (ticket.observaciones) {
- let observations = ticket.observaciones.split(' ');
-
- for (let observation of observations) {
- const salesPerson = ticket.salesPersonFk;
- if (observation.startsWith('#') || observation.startsWith('@')) {
- await models.Chat.send(ctx,
- observation,
- $t('ticketCommercial', {ticket: ticket.ticketFk, salesPerson})
- );
- }
- }
- }
- }
-
return getCollection(id, tickets, sales, placements, myOptions);
};
diff --git a/back/methods/collection/getTickets.js b/back/methods/collection/getTickets.js
index 48301a366..677c9e444 100644
--- a/back/methods/collection/getTickets.js
+++ b/back/methods/collection/getTickets.js
@@ -57,13 +57,14 @@ module.exports = Self => {
ROW_NUMBER () OVER (PARTITION BY s.id ORDER BY pickingOrder) currentItemShelving,
COUNT(*) OVER (PARTITION BY s.id ORDER BY s.id) totalItemShelving,
sh.code,
- p2.code parkingCode,
- p2.pickingOrder pickingOrder,
- p.code parkingCodePrevia,
- p.pickingOrder pickingOrderPrevia,
+ p2.code parkingCodePrevia,
+ p2.pickingOrder pickingOrderPrevia,
+ p.code parkingCode,
+ p.pickingOrder pickingOrder,
iss.id itemShelvingSaleFk,
iss.isPicked,
- iss.itemShelvingFk
+ iss.itemShelvingFk,
+ st.code stateCode
FROM ticketCollection tc
LEFT JOIN collection c ON c.id = tc.collectionFk
JOIN sale s ON s.ticketFk = tc.ticketFk
@@ -73,10 +74,11 @@ module.exports = Self => {
JOIN item i ON i.id = s.itemFk
JOIN itemShelvingSale iss ON iss.saleFk = s.id
LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
- LEFT JOIN shelving sh ON sh.code = ish.shelvingFk
+ LEFT JOIN shelving sh ON sh.id = ish.shelvingFk
LEFT JOIN parking p ON p.id = sh.parkingFk
LEFT JOIN itemColor ic ON ic.itemFk = s.itemFk
LEFT JOIN origin o ON o.id = i.originFk
+ LEFT JOIN state st ON st.id = sg.stateFk
WHERE tc.collectionFk = ?
GROUP BY s.id, ish.id, p.code, p2.code
UNION ALL
@@ -104,7 +106,8 @@ module.exports = Self => {
p.pickingOrder,
iss.id itemShelvingSaleFk,
iss.isPicked,
- iss.itemShelvingFk
+ iss.itemShelvingFk,
+ st.code stateCode
FROM sectorCollection sc
JOIN sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id
JOIN saleGroup sg ON sg.id = ss.saleGroupFk
@@ -114,10 +117,11 @@ module.exports = Self => {
JOIN item i ON i.id = s.itemFk
JOIN itemShelvingSale iss ON iss.saleFk = s.id
LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
- LEFT JOIN shelving sh ON sh.code = ish.shelvingFk
+ LEFT JOIN shelving sh ON sh.id = ish.shelvingFk
LEFT JOIN parking p ON p.id = sh.parkingFk
LEFT JOIN itemColor ic ON ic.itemFk = s.itemFk
LEFT JOIN origin o ON o.id = i.originFk
+ LEFT JOIN state st ON st.id = sg.stateFk
WHERE sc.id = ?
AND sgd.saleGroupFk
GROUP BY s.id, ish.id, p.code, p2.code`, [id, id], myOptions);
diff --git a/back/methods/collection/spec/assign.spec.js b/back/methods/collection/spec/assign.spec.js
index 745343819..b00631d22 100644
--- a/back/methods/collection/spec/assign.spec.js
+++ b/back/methods/collection/spec/assign.spec.js
@@ -28,9 +28,10 @@ describe('ticket assign()', () => {
await tx.rollback();
});
- it('should throw an error when there is not picking tickets', async() => {
+ it('should throw an error when there are no picking tickets', async() => {
try {
await models.Collection.assign(ctx, options);
+ fail('Expected an error to be thrown, but none was thrown.');
} catch (e) {
expect(e.message).toEqual('There are not picking tickets');
}
diff --git a/back/methods/mrw-config/cancelShipment.js b/back/methods/mrw-config/cancelShipment.js
index 56d206529..e96d6d694 100644
--- a/back/methods/mrw-config/cancelShipment.js
+++ b/back/methods/mrw-config/cancelShipment.js
@@ -24,12 +24,13 @@ module.exports = Self => {
Self.cancelShipment = async expeditionFk => {
const models = Self.app.models;
-
const mrw = await models.MrwConfig.findOne();
const {externalId} = await models.Expedition.findById(expeditionFk);
const clientType = await models.MrwConfig.getClientType(expeditionFk);
const template = fs.readFileSync(__dirname + '/cancelShipment.ejs', 'utf-8');
const renderedXml = ejs.render(template, {mrw, externalId, clientType});
+
+ await Self.rawSql('CALL util.debugAdd(?,?);', ['cancelShipment', renderedXml]);
const response = await axios.post(mrw.url, renderedXml, {
headers: {
'Content-Type': 'application/soap+xml; charset=utf-8'
@@ -37,9 +38,11 @@ module.exports = Self => {
});
const xmlString = response.data;
+ await Self.rawSql('CALL util.debugAdd(?,?);', ['cancelShipmentResponse', xmlString]);
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
+
const result = xmlDoc.getElementsByTagName('Mensaje')[0].textContent;
- return result.toLowerCase().includes('se ha cancelado correctamente');
+ return ['no se ha encontrado', 'se ha cancelado correctamente'].some(res => result.toLowerCase().includes(res));
};
};
diff --git a/back/methods/osticket/sendToSupport.js b/back/methods/osticket/sendToSupport.js
index e17093839..dabd35f80 100644
--- a/back/methods/osticket/sendToSupport.js
+++ b/back/methods/osticket/sendToSupport.js
@@ -29,35 +29,34 @@ module.exports = Self => {
});
Self.sendToSupport = async(ctx, reason, additionalData) => {
+ const userId = ctx.req.accessToken.userId;
const emailUser =
- await Self.app.models.EmailUser.findById(ctx.req.accessToken.userId, {fields: ['email']});
+ await Self.app.models.EmailUser.findById(userId, {fields: ['email']});
- let html = `Motivo:
${reason}
`;
- html += `Usuario:
${ctx.req.accessToken.userId} ${emailUser.email}
`;
+ let html = `
Motivo: ${reason}
`;
+ html += `Usuario: ${userId} ${emailUser.email}
`;
+ html += `Additional Data:
`;
+ html += '';
+ for (const [key, val] of Object.entries(additionalData)) {
+ if (key !== 'config') html += `- ${key}: ${parse(val)}
`;
+ else {
+ html += `- ${key}:
`;
+ for (const [confKey, confVal] of Object.entries(val))
+ html += `- ${confKey}: ${parse(confVal)}
`;
+ html += '
';
+ }
+ }
+ html += '
';
- delete additionalData.backError.config.headers.Authorization;
- const httpRequest = JSON.parse(additionalData?.httpRequest);
-
- if (httpRequest)
- delete httpRequest.config.headers.Authorization;
- additionalData.httpRequest = httpRequest;
-
- for (const data in additionalData)
- html += `${data}:
${tryParse(additionalData[data])}
`;
-
- const subjectReason = httpRequest?.data?.error;
+ const {message, path, name} = additionalData;
await smtp.send({
to: `${config.app.reportEmail}, ${emailUser.email}`,
- subject:
- '[Support-Salix] ' +
- additionalData?.frontPath + ' ' +
- subjectReason?.name + ':' +
- subjectReason?.message,
+ subject: `[Support-Salix] ${path} ${name}: ${message}`,
html
});
};
- function tryParse(value) {
+ function parse(value) {
try {
try {
value = JSON.parse(value);
diff --git a/back/methods/quadminds-api-config/sendOrders.js b/back/methods/quadminds-api-config/sendOrders.js
deleted file mode 100644
index 760d622b6..000000000
--- a/back/methods/quadminds-api-config/sendOrders.js
+++ /dev/null
@@ -1,88 +0,0 @@
-const axios = require('axios');
-const UserError = require('vn-loopback/util/user-error');
-const moment = require('moment');
-
-module.exports = Self => {
- Self.remoteMethod('sendOrders', {
- description: 'Sends a set of orders',
- accessType: 'WRITE',
- accepts: [{
- arg: 'tickets',
- type: ['number'],
- required: true
- }
- ],
- returns: {
- type: 'string',
- root: true
- },
- http: {
- path: `/sendOrders`,
- verb: 'POST'
- }
- });
- Self.sendOrders = async tickets => {
- const config = await Self.app.models.QuadmindsApiConfig.findOne();
- if (!config) throw new UserError('Config params not set');
-
- if (tickets.length > config.maxObjects)
- throw new UserError(`Quadminds does not support more than ${config.maxObjects} tickets`);
-
- let poisData = [];
- let isOk;
- for (let offset = 0; !isOk; offset = offset + config.limit) {
- const pois = await axios.get(`${config.url}pois/search?limit=${config.limit}&offset=${offset}`, {
- headers: {
- 'Accept': 'application/json',
- 'X-Saas-Apikey': config.key
- }
- });
- pois.data.data.length ? poisData.push(...pois.data.data) : isOk = true;
- }
-
- const poiMap = new Map(poisData.map(poi => [poi.code, poi._id]));
-
- let orders = await Self.rawSql(`
- SELECT a.id poiCode,
- t.id code,
- t.shipped date,
- 'PEDIDO' operation,
- t.totalWithVat totalAmount,
- t.totalWithoutVat totalAmountWithoutTaxes,
- SUM(sv.volume) volume
- FROM ticket t
- JOIN address a ON a.id = t.addressFk
- JOIN saleVolume sv ON sv.ticketFk = t.id
- WHERE t.id IN (?)
- GROUP BY t.id
- `, [tickets]);
-
- // Transformo code en string ya que lo obtenermos como integer
- orders = orders.map(order => {
- return {
- ...order,
- poiId: poiMap.get(order.poiCode.toString()) || undefined,
- code: order.code.toString(),
- date: moment(order.date).format('YYYY-MM-DD'),
- totalAmount: order.totalAmount || undefined,
- totalAmountWithoutTaxes: order.totalAmountWithoutTaxes || undefined,
- timeWindow: [{
- from: config.orderTimeFrom,
- to: config.orderTimeTo
- }],
- orderMeasures: [{
- constraintId: 3, // Volumen
- value: order.volume
- }]
- };
- });
-
- await axios.post(`${config.url}orders`, orders, {
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json',
- 'X-Saas-Apikey': config.key
- }
- });
- };
-};
diff --git a/back/methods/quadminds-api-config/sendPois.js b/back/methods/quadminds-api-config/sendPois.js
deleted file mode 100644
index cb5eef93e..000000000
--- a/back/methods/quadminds-api-config/sendPois.js
+++ /dev/null
@@ -1,87 +0,0 @@
-const axios = require('axios');
-const UserError = require('vn-loopback/util/user-error');
-
-module.exports = Self => {
- Self.remoteMethod('sendPois', {
- description: 'Sends a set of pois',
- accessType: 'WRITE',
- accepts: [{
- arg: 'tickets',
- type: ['number'],
- required: true
- }
- ],
- returns: {
- type: 'string',
- root: true
- },
- http: {
- path: `/sendPois`,
- verb: 'POST'
- }
- });
- Self.sendPois = async tickets => {
- const config = await Self.app.models.QuadmindsApiConfig.findOne();
- if (!config) throw new UserError('Config params not set');
-
- if (tickets.length > config.maxObjects)
- throw new UserError(`Quadminds does not support more than ${config.maxObjects} tickets`);
-
- let pois = await Self.rawSql(`
- WITH deliveryNotes AS (
- SELECT t.id, t.routeFk, tn.description
- FROM ticket t
- JOIN ticketObservation tn ON tn.ticketFk = t.id
- JOIN observationType ot ON ot.id = tn.observationTypeFk
- WHERE ot.code = 'delivery'
- )
- SELECT a.id code,
- c.socialName name,
- IF(ABS(a.latitude - ROUND(a.latitude)) < 0.000001, NULL, a.latitude) latitude,
- IF(ABS(a.longitude - ROUND(a.longitude)) < 0.000001, NULL, a.longitude) longitude,
- a.street,
- a.city locality,
- p.name state,
- co.name country,
- CONCAT_WS(', ', IFNULL(a.street, ''), IFNULL(a.city, ''), IFNULL(p.name, '')) longAddress,
- CONCAT(IFNULL(a.mobile, c.mobile)) phoneNumber,
- dn.description poiDeliveryComments,
- c.email email
- FROM ticket t
- JOIN address a ON a.id = t.addressFk
- JOIN province p ON p.id = a.provinceFk
- JOIN country co ON co.id = p.countryFk
- JOIN client c ON c.id = t.clientFk
- LEFT JOIN deliveryNotes dn ON dn.id = t.id
- WHERE t.id IN (?)
- GROUP BY t.id
- `, [tickets]);
-
- // Transformo code en string ya que lo obtenermos como integer
- pois = pois.map(poi => {
- return {
- ...poi,
- code: poi.code.toString(),
- latitude: poi.latitude || undefined,
- longitude: poi.longitude || undefined,
- address: {
- street: poi.street || undefined,
- locality: poi.locality || undefined,
- state: poi.state || undefined,
- country: poi.country || undefined
- },
- poiDeliveryComments: poi.poiDeliveryComments || undefined,
- phoneNumber: poi.phoneNumber || undefined,
- email: poi.email || undefined
- };
- });
-
- await axios.post(`${config.url}pois`, pois, {
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json',
- 'X-Saas-Apikey': config.key
- }
- });
- };
-};
diff --git a/back/methods/url/getUrl.js b/back/methods/url/getUrl.js
index 5c6e5655f..fa3f7fdad 100644
--- a/back/methods/url/getUrl.js
+++ b/back/methods/url/getUrl.js
@@ -22,7 +22,7 @@ module.exports = Self => {
const url = await Self.app.models.Url.findOne({
where: {
appName,
- environment: process.env.NODE_ENV || 'dev'
+ environment: process.env.NODE_ENV || 'development'
}
});
return url?.url;
diff --git a/back/methods/workerActivity/add.js b/back/methods/workerActivity/add.js
index 4592a0797..89131491d 100644
--- a/back/methods/workerActivity/add.js
+++ b/back/methods/workerActivity/add.js
@@ -31,7 +31,7 @@ module.exports = Self => {
return await Self.rawSql(`
INSERT INTO workerActivity (workerFk, workerActivityTypeFk, model)
SELECT ?, ?, ?
- FROM workerTimeControlParams wtcp
+ FROM workerTimeControlConfig wtcc
LEFT JOIN (
SELECT wa.workerFk,
wa.created,
@@ -44,7 +44,7 @@ module.exports = Self => {
) sub ON TRUE
WHERE sub.workerFk IS NULL
OR sub.code <> ?
- OR TIMESTAMPDIFF(SECOND, sub.created, util.VN_NOW()) > wtcp.dayBreak;`
+ OR TIMESTAMPDIFF(SECOND, sub.created, util.VN_NOW()) > wtcc.dayBreak;`
, [userId, code, model, userId, code], myOptions);
};
};
diff --git a/back/methods/workerActivity/specs/add.spec.js b/back/methods/workerActivity/specs/add.spec.js
index 352d67723..751cce009 100644
--- a/back/methods/workerActivity/specs/add.spec.js
+++ b/back/methods/workerActivity/specs/add.spec.js
@@ -10,10 +10,10 @@ describe('workerActivity insert()', () => {
try {
await models.WorkerActivityType.create(
- {'code': 'STOP', 'description': 'STOP'}, options
+ {'code': 'TEST', 'description': 'TEST'}, options
);
- await models.WorkerActivity.add(ctx, 'STOP', 'APP', options);
+ await models.WorkerActivity.add(ctx, 'TEST', 'APP', options);
count = await models.WorkerActivity.count(
{'workerFK': 1106}, options
diff --git a/back/model-config.json b/back/model-config.json
index 5368769fd..c1682f29a 100644
--- a/back/model-config.json
+++ b/back/model-config.json
@@ -79,6 +79,9 @@
"ImageCollectionSize": {
"dataSource": "vn"
},
+ "ImageConfig": {
+ "dataSource": "vn"
+ },
"ImageContainer": {
"dataSource": "imageStorage"
},
@@ -118,18 +121,21 @@
"Province": {
"dataSource": "vn"
},
- "QuadmindsApiConfig": {
- "dataSource": "vn"
- },
"Autonomy": {
"dataSource": "vn"
},
"Payment": {
"dataSource": "vn"
},
+ "PbxConfig": {
+ "dataSource": "vn"
+ },
"Postcode": {
"dataSource": "vn"
},
+ "Prefix": {
+ "dataSource": "vn"
+ },
"ReferenceRate": {
"dataSource": "vn"
},
@@ -139,6 +145,12 @@
"StarredModule": {
"dataSource": "vn"
},
+ "SaySimpleCountry": {
+ "dataSource": "vn"
+ },
+ "SaySimpleConfig": {
+ "dataSource": "vn"
+ },
"TempContainer": {
"dataSource": "tempStorage"
},
diff --git a/back/models/country.json b/back/models/country.json
index 80d456702..ee72ae49d 100644
--- a/back/models/country.json
+++ b/back/models/country.json
@@ -44,6 +44,11 @@
"type": "belongsTo",
"model": "Continent",
"foreignKey": "continentFk"
+ },
+ "saySimpleCountry": {
+ "type": "hasOne",
+ "model": "SaySimpleCountry",
+ "foreignKey": "countryFk"
}
},
"acls": [
@@ -54,4 +59,4 @@
"permission": "ALLOW"
}
]
-}
+}
\ No newline at end of file
diff --git a/back/models/expedition_PrintOut.json b/back/models/expedition_PrintOut.json
index dd49b0234..23a2fdbc4 100644
--- a/back/models/expedition_PrintOut.json
+++ b/back/models/expedition_PrintOut.json
@@ -14,9 +14,6 @@
},
"itemFk": {
"type": "number"
- },
- "isChecked": {
- "type": "boolean"
}
}
}
\ No newline at end of file
diff --git a/back/models/image-config.json b/back/models/image-config.json
new file mode 100644
index 000000000..11f4c2284
--- /dev/null
+++ b/back/models/image-config.json
@@ -0,0 +1,22 @@
+{
+ "name": "ImageConfig",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "hedera.imageConfig"
+ }
+ },
+ "properties": {
+ "url": {
+ "type": "string"
+ }
+ },
+ "acls": [
+ {
+ "accessType": "READ",
+ "principalType": "ROLE",
+ "principalId": "$authenticated",
+ "permission": "ALLOW"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/back/models/pbx-config.json b/back/models/pbx-config.json
new file mode 100644
index 000000000..44137b55d
--- /dev/null
+++ b/back/models/pbx-config.json
@@ -0,0 +1,27 @@
+{
+ "name": "PbxConfig",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "pbx.config"
+ }
+ },
+ "properties": {
+ "id": {
+ "type": "number",
+ "id": true
+ },
+ "defaultPrefix": {
+ "type": "string"
+ }
+ },
+ "acls": [
+ {
+ "property": "*",
+ "accessType": "READ",
+ "principalType": "ROLE",
+ "principalId": "employee",
+ "permission": "ALLOW"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/back/models/prefix.json b/back/models/prefix.json
new file mode 100644
index 000000000..762354caa
--- /dev/null
+++ b/back/models/prefix.json
@@ -0,0 +1,27 @@
+{
+ "name": "Prefix",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "pbx.prefix"
+ }
+ },
+ "properties": {
+ "country": {
+ "type": "string",
+ "id": true
+ },
+ "prefix": {
+ "type": "string"
+ }
+ },
+ "acls": [
+ {
+ "property": "*",
+ "accessType": "READ",
+ "principalType": "ROLE",
+ "principalId": "employee",
+ "permission": "ALLOW"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/back/models/production-config.json b/back/models/production-config.json
index 2fc6d71ff..048264e8c 100644
--- a/back/models/production-config.json
+++ b/back/models/production-config.json
@@ -20,6 +20,9 @@
},
"backupPrinterNotificationDelay": {
"type": "string"
+ },
+ "itemOrderReviewHours": {
+ "type": "number"
}
}
}
\ No newline at end of file
diff --git a/back/models/quadminds-api-config.js b/back/models/quadminds-api-config.js
deleted file mode 100644
index c2773fa0b..000000000
--- a/back/models/quadminds-api-config.js
+++ /dev/null
@@ -1,4 +0,0 @@
-module.exports = Self => {
- require('../methods/quadminds-api-config/sendPois')(Self);
- require('../methods/quadminds-api-config/sendOrders')(Self);
-};
diff --git a/back/models/quadminds-api-config.json b/back/models/quadminds-api-config.json
deleted file mode 100644
index 4001badf3..000000000
--- a/back/models/quadminds-api-config.json
+++ /dev/null
@@ -1,34 +0,0 @@
-{
- "name": "QuadmindsApiConfig",
- "base": "VnModel",
- "options": {
- "mysql": {
- "table": "quadmindsApiConfig"
- }
- },
- "properties": {
- "id": {
- "type": "number",
- "id": true,
- "required": true
- },
- "url": {
- "type": "string"
- },
- "key": {
- "type": "string"
- },
- "maxObjects": {
- "type": "number"
- },
- "limit": {
- "type": "number"
- },
- "orderTimeFrom": {
- "type": "string"
- },
- "orderTimeTo": {
- "type": "string"
- }
- }
-}
diff --git a/back/models/say-simple-config.json b/back/models/say-simple-config.json
new file mode 100644
index 000000000..d5d4f8a6f
--- /dev/null
+++ b/back/models/say-simple-config.json
@@ -0,0 +1,29 @@
+{
+ "name": "SaySimpleConfig",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "saySimpleConfig"
+ }
+ },
+ "properties": {
+ "id": {
+ "type": "number",
+ "id": true
+ },
+ "url": {
+ "type": "string"
+ },
+ "defaultChannel": {
+ "type": "number"
+ }
+ },
+ "acls": [
+ {
+ "accessType": "READ",
+ "principalType": "ROLE",
+ "principalId": "$authenticated",
+ "permission": "ALLOW"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/back/models/say-simple-country.json b/back/models/say-simple-country.json
new file mode 100644
index 000000000..adddddc02
--- /dev/null
+++ b/back/models/say-simple-country.json
@@ -0,0 +1,26 @@
+{
+ "name": "SaySimpleCountry",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "saySimpleCountry"
+ }
+ },
+ "properties": {
+ "countryFk": {
+ "type": "number",
+ "id": true
+ },
+ "channel": {
+ "type": "number"
+ }
+ },
+ "acls": [
+ {
+ "accessType": "READ",
+ "principalType": "ROLE",
+ "principalId": "$authenticated",
+ "permission": "ALLOW"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/db/.pullinfo.json b/db/.pullinfo.json
index 5b75584d1..b890ffc31 100644
--- a/db/.pullinfo.json
+++ b/db/.pullinfo.json
@@ -9,7 +9,7 @@
},
"vn": {
"view": {
- "expeditionPallet_Print": "99f75145ac2e7b612a6d71e74b6e55f194a465780fd9875a15eb01e6596b447e"
+ "expeditionPallet_Print": "04fc5f2967ce53bfbb85f7f48b9a3dca4a4f7111ac41e1775f4cc7d6538774b2"
}
}
}
diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql
index 5f464c5e2..cd978e4a8 100644
--- a/db/dump/.dump/data.sql
+++ b/db/dump/.dump/data.sql
@@ -4,7 +4,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','11278','fe10f03459a153fc213bf64e352804c043f94590','2024-10-03 07:47:47','11281');
+INSERT INTO `version` VALUES ('vn-database','11377','d3fe5098277c3935c434838b53facb271f84ebec','2024-12-10 07:22:33','11379');
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);
@@ -988,6 +988,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','11194','00-firstScript.sql','jen
INSERT INTO `versionLog` VALUES ('vn-database','11195','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:01',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11196','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-18 07:28:14',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11197','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:01',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11198','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 07:42:49',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11201','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-27 13:04:26',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11204','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:01',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11205','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-04 13:54:55',NULL,NULL);
@@ -1013,6 +1014,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','11225','01-firstScript.sql','jen
INSERT INTO `versionLog` VALUES ('vn-database','11225','02-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:41',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11227','00-addWorkerTimeControlMailAcl.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:41',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11229','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-16 08:24:17',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11230','00-addClientObservationType.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 07:42:52',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11234','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:42',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11235','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:43',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11236','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:43',NULL,NULL);
@@ -1021,18 +1023,112 @@ INSERT INTO `versionLog` VALUES ('vn-database','11237','00-firstScript.sql','jen
INSERT INTO `versionLog` VALUES ('vn-database','11239','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-17 12:57:06',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11240','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:43',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11241','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-20 09:08:25',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11242','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 07:42:52',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11246','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-18 12:39:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11247','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-19 12:10:08',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11248','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-23 11:12:17',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11249','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:43',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11251','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 07:43:38',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11251','01-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 07:57:30',NULL,'Connection lost: The server closed the connection.');
INSERT INTO `versionLog` VALUES ('vn-database','11253','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-20 14:41:27',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11254','00-thermographTemperature.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:13',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11254','01-thermographFk.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:15',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11255','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:43',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11256','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-23 12:18:24',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11258','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:15',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11260','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:15',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11261','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:15',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11262','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:43',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11263','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-27 12:05:32',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11264','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:15',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11271','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:15',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11272','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:15',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11273','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 10:50:51',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11274','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:16',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11274','00-firstScript2.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:29',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11274','00-firstScript3.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:30',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11274','00-firstScript5.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:35',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11274','00-firstScript6.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:35',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11274','00-firstScript7.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:36',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11277','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:36',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11278','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:43',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11279','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-10-02 08:05:24',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11280','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-02 08:46:50',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11281','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:36',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11283','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:36',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11284','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:36',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11285','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:37',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11287','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:37',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11288','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-10 08:26:34',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11289','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-15 07:01:33',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11290','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:37',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11291','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-17 09:10:30',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11294','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:37',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11295','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-10 08:45:13',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11297','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:29',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11297','01-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11298','00-closure.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:37',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11300','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-18 08:27:05',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11302','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:57',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11308','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-23 12:41:55',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11311','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:57',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11312','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11314','00-restrictedAsterisk.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11315','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11316','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11317','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11319','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11321','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11322','00-entryAcl.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11324','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-13 10:49:47',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11325','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11326','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11330','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11331','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11332','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11336','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11337','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11338','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 09:14:12',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11339','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11341','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11342','00-itemShelving.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:06:34',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11342','01-itemShelving.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:06:35',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11342','02-itemShelving.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:06:37',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11342','03-itemShelving.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:11:07',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11342','04-itemShelvingLog.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:11:07',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11342','05-itemShelvingLog.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:11:07',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11342','06-itemShelvingLog.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:11:07',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11343','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:11:07',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11344','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-13 17:36:45',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11344','01-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-13 17:46:26',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11345','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:11:08',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11346','00-address.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:15:02',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11346','01-client.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:16:29',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11346','02-supplier.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:27:57',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11347','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:27:57',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11348','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:28:14',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11349','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:28:14',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11350','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:28:14',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11351','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11353','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:28:14',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11354','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11355','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:28:14',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11357','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:28:16',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11358','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:28:21',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11359','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11362','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-28 08:52:33',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11363','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11366','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11367','00-deprecate.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11369','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:05',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11371','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:05',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11371','01-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:47',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11371','02-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:22:29',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11371','03-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:22:31',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11372','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-09 13:30:30',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11373','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-02 16:09:01',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11375','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-03 08:58:20',NULL,NULL);
+INSERT INTO `versionLog` VALUES ('vn-database','11377','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:22:31',NULL,NULL);
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
@@ -1407,6 +1503,8 @@ INSERT INTO `roleInherit` VALUES (376,124,21,19336);
INSERT INTO `roleInherit` VALUES (377,47,49,19295);
INSERT INTO `roleInherit` VALUES (378,101,15,19294);
INSERT INTO `roleInherit` VALUES (379,103,121,19294);
+INSERT INTO `roleInherit` VALUES (381,119,123,19295);
+INSERT INTO `roleInherit` VALUES (382,48,72,783);
INSERT INTO `userPassword` VALUES (1,7,1,0,2,1);
@@ -1588,7 +1686,6 @@ INSERT INTO `ACL` VALUES (209,'Ticket','recalculateComponents','WRITE','ALLOW','
INSERT INTO `ACL` VALUES (211,'TravelLog','*','READ','ALLOW','ROLE','buyer',NULL);
INSERT INTO `ACL` VALUES (212,'Thermograph','*','*','ALLOW','ROLE','buyer',NULL);
INSERT INTO `ACL` VALUES (213,'TravelThermograph','*','WRITE','ALLOW','ROLE','buyer',NULL);
-INSERT INTO `ACL` VALUES (214,'Entry','*','*','ALLOW','ROLE','buyer',NULL);
INSERT INTO `ACL` VALUES (216,'TravelThermograph','*','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (218,'Intrastat','*','*','ALLOW','ROLE','buyer',NULL);
INSERT INTO `ACL` VALUES (221,'UserConfig','getUserConfig','READ','ALLOW','ROLE','guest',NULL);
@@ -1617,7 +1714,6 @@ INSERT INTO `ACL` VALUES (258,'PayDem','*','READ','ALLOW','ROLE','employee',NULL
INSERT INTO `ACL` VALUES (259,'Client','createReceipt','*','ALLOW','ROLE','salesAssistant',NULL);
INSERT INTO `ACL` VALUES (260,'PrintServerQueue','*','WRITE','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (261,'SupplierAccount','*','WRITE','ALLOW','ROLE','administrative',783);
-INSERT INTO `ACL` VALUES (262,'Entry','*','*','ALLOW','ROLE','administrative',NULL);
INSERT INTO `ACL` VALUES (263,'InvoiceIn','*','READ','ALLOW','ROLE','administrative',NULL);
INSERT INTO `ACL` VALUES (264,'StarredModule','*','*','ALLOW','ROLE','$authenticated',NULL);
INSERT INTO `ACL` VALUES (265,'ItemBotanical','*','WRITE','ALLOW','ROLE','logisticBoss',NULL);
@@ -1934,13 +2030,11 @@ INSERT INTO `ACL` VALUES (605,'Ticket','sendSms','WRITE','ALLOW','ROLE','employe
INSERT INTO `ACL` VALUES (606,'Ticket','isLocked','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (607,'Ticket','freightCost','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (608,'Ticket','getComponentsSum','READ','ALLOW','ROLE','employee',NULL);
-INSERT INTO `ACL` VALUES (609,'Ticket','updateAttributes','WRITE','ALLOW','ROLE','delivery',NULL);
+INSERT INTO `ACL` VALUES (609,'Ticket','updateAttributes','WRITE','ALLOW','ROLE','delivery',19295);
INSERT INTO `ACL` VALUES (610,'Ticket','deliveryNoteCsv','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (611,'State','find','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (612,'State','findById','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (613,'State','findOne','READ','ALLOW','ROLE','employee',NULL);
-INSERT INTO `ACL` VALUES (614,'Worker','find','READ','ALLOW','ROLE','employee',NULL);
-INSERT INTO `ACL` VALUES (616,'Worker','findOne','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (617,'Worker','filter','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (618,'Worker','getWorkedHours','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (619,'Worker','active','READ','ALLOW','ROLE','employee',NULL);
@@ -2006,7 +2100,6 @@ INSERT INTO `ACL` VALUES (716,'ExpeditionMistake','*','WRITE','ALLOW','ROLE','em
INSERT INTO `ACL` VALUES (717,'WorkerMistake','*','WRITE','ALLOW','ROLE','coolerAssist',NULL);
INSERT INTO `ACL` VALUES (718,'MistakesTypes','*','WRITE','ALLOW','ROLE','coolerAssist',NULL);
INSERT INTO `ACL` VALUES (719,'MistakeType','*','READ','ALLOW','ROLE','employee',NULL);
-INSERT INTO `ACL` VALUES (720,'MachineWorker','*','READ','ALLOW','ROLE','coolerAssist',NULL);
INSERT INTO `ACL` VALUES (721,'Printer','*','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (722,'SaleMistake','*','WRITE','ALLOW','ROLE','production',NULL);
INSERT INTO `ACL` VALUES (723,'Item','setVisibleDiscard','WRITE','ALLOW','ROLE','employee',NULL);
@@ -2035,7 +2128,7 @@ INSERT INTO `ACL` VALUES (746,'Claim','getSummary','READ','ALLOW','ROLE','claimV
INSERT INTO `ACL` VALUES (747,'CplusRectificationType','*','READ','ALLOW','ROLE','administrative',NULL);
INSERT INTO `ACL` VALUES (748,'SiiTypeInvoiceOut','*','READ','ALLOW','ROLE','salesPerson',NULL);
INSERT INTO `ACL` VALUES (749,'InvoiceCorrectionType','*','READ','ALLOW','ROLE','salesPerson',NULL);
-INSERT INTO `ACL` VALUES (750,'InvoiceOut','transferInvoice','WRITE','ALLOW','ROLE','administrative',NULL);
+INSERT INTO `ACL` VALUES (750,'InvoiceOut','transfer','WRITE','ALLOW','ROLE','administrative',NULL);
INSERT INTO `ACL` VALUES (751,'Application','executeProc','*','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (752,'Application','executeFunc','*','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (753,'NotificationSubscription','getList','READ','ALLOW','ROLE','employee',NULL);
@@ -2044,13 +2137,10 @@ INSERT INTO `ACL` VALUES (755,'Route','findById','READ','ALLOW','ROLE','employee
INSERT INTO `ACL` VALUES (756,'Route','findOne','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (757,'Route','getRoutesByWorker','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (758,'Route','canViewAllRoute','READ','ALLOW','ROLE','deliveryAssistant',NULL);
-INSERT INTO `ACL` VALUES (759,'Route','cmr','READ','ALLOW','ROLE','employee',NULL);
-INSERT INTO `ACL` VALUES (760,'Route','downloadCmrsZip','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (761,'Route','downloadZip','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (762,'Route','filter','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (763,'Route','getByWorker','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (764,'Route','getDeliveryPoint','READ','ALLOW','ROLE','employee',NULL);
-INSERT INTO `ACL` VALUES (765,'Route','cmrs','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (766,'Route','getSuggestedTickets','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (767,'Route','getTickets','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (768,'Route','guessPriority','WRITE','ALLOW','ROLE','employee',NULL);
@@ -2091,7 +2181,6 @@ INSERT INTO `ACL` VALUES (802,'MailAliasAccount','deleteById','WRITE','ALLOW','R
INSERT INTO `ACL` VALUES (804,'DeviceProduction','*','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (805,'Collection','assign','WRITE','ALLOW','ROLE','production',NULL);
INSERT INTO `ACL` VALUES (806,'ExpeditionPallet','getPallet','READ','ALLOW','ROLE','production',NULL);
-INSERT INTO `ACL` VALUES (807,'MachineWorker','updateInTime','WRITE','ALLOW','ROLE','production',NULL);
INSERT INTO `ACL` VALUES (808,'MobileAppVersionControl','getVersion','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (809,'SaleTracking','delete','WRITE','ALLOW','ROLE','production',NULL);
INSERT INTO `ACL` VALUES (810,'SaleTracking','updateTracking','WRITE','ALLOW','ROLE','production',NULL);
@@ -2174,13 +2263,12 @@ INSERT INTO `ACL` VALUES (892,'WorkerIncome','*','*','ALLOW','ROLE','hr',NULL);
INSERT INTO `ACL` VALUES (893,'PayrollComponent','*','*','ALLOW','ROLE','hr',NULL);
INSERT INTO `ACL` VALUES (894,'Worker','__get__incomes','*','ALLOW','ROLE','hr',NULL);
INSERT INTO `ACL` VALUES (895,'ItemShelvingLog','*','READ','ALLOW','ROLE','production',NULL);
-INSERT INTO `ACL` VALUES (897,'WorkerLog','*','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (901,'WorkerTimeControl','sendMail','WRITE','ALLOW','ROLE','system',NULL);
INSERT INTO `ACL` VALUES (902,'Entry','filter','READ','ALLOW','ROLE','supplier',NULL);
INSERT INTO `ACL` VALUES (903,'Entry','getBuys','READ','ALLOW','ROLE','supplier',NULL);
-INSERT INTO `ACL` VALUES (904,'Entry','buyLabel','READ','ALLOW','ROLE','supplier',NULL);
+INSERT INTO `ACL` VALUES (904,'Entry','buyLabelSupplier','READ','ALLOW','ROLE','supplier',19295);
INSERT INTO `ACL` VALUES (905,'AddressWaste','*','READ','ALLOW','ROLE','production',NULL);
-INSERT INTO `ACL` VALUES (906,'Entry','print','READ','ALLOW','ROLE','supplier',NULL);
+INSERT INTO `ACL` VALUES (906,'Entry','labelSupplier','READ','ALLOW','ROLE','supplier',19295);
INSERT INTO `ACL` VALUES (907,'Expedition_PrintOut','*','*','ALLOW','ROLE','production',NULL);
INSERT INTO `ACL` VALUES (908,'Docuware','upload','WRITE','ALLOW','ROLE','hrBuyer',13657);
INSERT INTO `ACL` VALUES (909,'Entry','getBuysCsv','READ','ALLOW','ROLE','supplier',19295);
@@ -2190,10 +2278,8 @@ INSERT INTO `ACL` VALUES (912,'Worker','__get__medicalReview','*','ALLOW','ROLE'
INSERT INTO `ACL` VALUES (913,'VnToken','*','READ','ALLOW','ROLE','developer',10578);
INSERT INTO `ACL` VALUES (914,'VnToken','killSession','*','ALLOW','ROLE','developer',10578);
INSERT INTO `ACL` VALUES (915,'ACL','*','WRITE','ALLOW','ROLE','developerBoss',10578);
-INSERT INTO `ACL` VALUES (916,'Entry','getBuysCsv','READ','ALLOW','ROLE','supplier',10578);
INSERT INTO `ACL` VALUES (917,'InvoiceOut','refundAndInvoice','WRITE','ALLOW','ROLE','administrative',10578);
INSERT INTO `ACL` VALUES (918,'Worker','__get__descriptor','READ','ALLOW','ROLE','employee',10578);
-INSERT INTO `ACL` VALUES (919,'Worker','findById','READ','ALLOW','ROLE','employee',10578);
INSERT INTO `ACL` VALUES (920,'QuadmindsApiConfig','*','*','ALLOW','ROLE','delivery',19295);
INSERT INTO `ACL` VALUES (922,'SaleGroup','*','WRITE','ALLOW','ROLE','production',19294);
INSERT INTO `ACL` VALUES (923,'Worker','__get__advancedSummary','READ','ALLOW','ROLE','hr',10578);
@@ -2212,6 +2298,77 @@ INSERT INTO `ACL` VALUES (935,'BankEntity','*','WRITE','ALLOW','ROLE','financial
INSERT INTO `ACL` VALUES (936,'Device','handleUser','*','ALLOW','ROLE','employee',10578);
INSERT INTO `ACL` VALUES (937,'WorkerTimeControlMail','count','READ','ALLOW','ROLE','employee',10578);
INSERT INTO `ACL` VALUES (938,'Worker','__get__mail','READ','ALLOW','ROLE','hr',10578);
+INSERT INTO `ACL` VALUES (939,'Machine','*','*','ALLOW','ROLE','productionBoss',10578);
+INSERT INTO `ACL` VALUES (940,'ItemTypeLog','find','READ','ALLOW','ROLE','employee',10578);
+INSERT INTO `ACL` VALUES (941,'Entry','buyLabel','READ','ALLOW','ROLE','employee',10578);
+INSERT INTO `ACL` VALUES (942,'Cmr','filter','READ','ALLOW','ROLE','production',10578);
+INSERT INTO `ACL` VALUES (943,'Cmr','downloadZip','READ','ALLOW','ROLE','production',10578);
+INSERT INTO `ACL` VALUES (944,'Cmr','print','READ','ALLOW','ROLE','production',10578);
+INSERT INTO `ACL` VALUES (945,'Collection','create','WRITE','ALLOW','ROLE','productionBoss',10578);
+INSERT INTO `ACL` VALUES (946,'Collection','upsert','WRITE','ALLOW','ROLE','productionBoss',10578);
+INSERT INTO `ACL` VALUES (947,'Collection','replaceById','WRITE','ALLOW','ROLE','productionBoss',10578);
+INSERT INTO `ACL` VALUES (948,'Collection','updateAll','WRITE','ALLOW','ROLE','productionBoss',10578);
+INSERT INTO `ACL` VALUES (949,'Collection','updateAttributes','WRITE','ALLOW','ROLE','productionBoss',10578);
+INSERT INTO `ACL` VALUES (950,'Collection','deleteById','WRITE','ALLOW','ROLE','productionBoss',10578);
+INSERT INTO `ACL` VALUES (951,'Collection','destroyAll','WRITE','ALLOW','ROLE','productionBoss',10578);
+INSERT INTO `ACL` VALUES (952,'Collection','destroyById','WRITE','ALLOW','ROLE','productionBoss',10578);
+INSERT INTO `ACL` VALUES (953,'RouteAction','find','READ','ALLOW','ROLE','delivery',10578);
+INSERT INTO `ACL` VALUES (954,'RouteComplement','find','READ','ALLOW','ROLE','delivery',10578);
+INSERT INTO `ACL` VALUES (955,'RouteComplement','create','WRITE','ALLOW','ROLE','delivery',10578);
+INSERT INTO `ACL` VALUES (956,'RouteComplement','deleteById','WRITE','ALLOW','ROLE','delivery',10578);
+INSERT INTO `ACL` VALUES (957,'SaleGroup','find','READ','ALLOW','ROLE','production',10578);
+INSERT INTO `ACL` VALUES (958,'Worker','canCreateAbsenceInPast','WRITE','ALLOW','ROLE','hr',10578);
+INSERT INTO `ACL` VALUES (959,'WorkerRelative','updateAttributes','*','ALLOW','ROLE','hr',10578);
+INSERT INTO `ACL` VALUES (960,'WorkerRelative','crud','WRITE','ALLOW','ROLE','hr',10578);
+INSERT INTO `ACL` VALUES (961,'WorkerRelative','findById','*','ALLOW','ROLE','hr',10578);
+INSERT INTO `ACL` VALUES (962,'WorkerRelative','find','*','ALLOW','ROLE','hr',10578);
+INSERT INTO `ACL` VALUES (963,'WorkerRelative','upsert','*','ALLOW','ROLE','hr',10578);
+INSERT INTO `ACL` VALUES (964,'WorkerRelative','filter','*','ALLOW','ROLE','hr',10578);
+INSERT INTO `ACL` VALUES (965,'WorkerIrpf','updateAttributes','*','ALLOW','ROLE','hr',10578);
+INSERT INTO `ACL` VALUES (966,'WorkerIrpf','crud','*','ALLOW','ROLE','hr',10578);
+INSERT INTO `ACL` VALUES (967,'WorkerIrpf','findById','*','ALLOW','ROLE','hr',10578);
+INSERT INTO `ACL` VALUES (968,'WorkerIrpf','find','*','ALLOW','ROLE','hr',10578);
+INSERT INTO `ACL` VALUES (969,'WorkerIrpf','upsert','*','ALLOW','ROLE','hr',10578);
+INSERT INTO `ACL` VALUES (970,'WorkerIrpf','filter','*','ALLOW','ROLE','hr',10578);
+INSERT INTO `ACL` VALUES (971,'DisabilityGrade','updateAttributes','*','ALLOW','ROLE','hr',10578);
+INSERT INTO `ACL` VALUES (972,'DisabilityGrade','crud','*','ALLOW','ROLE','hr',10578);
+INSERT INTO `ACL` VALUES (973,'DisabilityGrade','findById','*','ALLOW','ROLE','hr',10578);
+INSERT INTO `ACL` VALUES (974,'DisabilityGrade','find','*','ALLOW','ROLE','hr',10578);
+INSERT INTO `ACL` VALUES (975,'DisabilityGrade','upsert','*','ALLOW','ROLE','hr',10578);
+INSERT INTO `ACL` VALUES (976,'Entry','upsert','WRITE','ALLOW','ROLE','administrative',10578);
+INSERT INTO `ACL` VALUES (977,'Entry','updateAttributes','WRITE','ALLOW','ROLE','administrative',10578);
+INSERT INTO `ACL` VALUES (978,'Entry','isBooked','READ','ALLOW','ROLE','administrative',10578);
+INSERT INTO `ACL` VALUES (979,'Entry','findById','READ','ALLOW','ROLE','administrative',10578);
+INSERT INTO `ACL` VALUES (980,'Entry','find','READ','ALLOW','ROLE','administrative',10578);
+INSERT INTO `ACL` VALUES (981,'Entry','filter','READ','ALLOW','ROLE','administrative',10578);
+INSERT INTO `ACL` VALUES (982,'Entry','count','READ','ALLOW','ROLE','administrative',10578);
+INSERT INTO `ACL` VALUES (983,'Entry','getEntry','READ','ALLOW','ROLE','administrative',10578);
+INSERT INTO `ACL` VALUES (984,'Entry','getBuys','READ','ALLOW','ROLE','administrative',10578);
+INSERT INTO `ACL` VALUES (985,'Entry','findOne','READ','ALLOW','ROLE','administrative',10578);
+INSERT INTO `ACL` VALUES (986,'Entry','deleteBuys','WRITE','ALLOW','ROLE','administrative',10578);
+INSERT INTO `ACL` VALUES (987,'Entry','editLatestBuys','WRITE','ALLOW','ROLE','administrative',10578);
+INSERT INTO `ACL` VALUES (988,'Entry','importBuys','WRITE','ALLOW','ROLE','administrative',10578);
+INSERT INTO `ACL` VALUES (989,'Entry','importBuysPreview','READ','ALLOW','ROLE','administrative',10578);
+INSERT INTO `ACL` VALUES (990,'Entry','lastItemBuys','READ','ALLOW','ROLE','administrative',10578);
+INSERT INTO `ACL` VALUES (991,'Entry','latestBuysFilter','READ','ALLOW','ROLE','administrative',10578);
+INSERT INTO `ACL` VALUES (992,'Entry','upsert','WRITE','ALLOW','ROLE','buyer',10578);
+INSERT INTO `ACL` VALUES (993,'Entry','updateAttributes','WRITE','ALLOW','ROLE','buyer',10578);
+INSERT INTO `ACL` VALUES (994,'Entry','findById','READ','ALLOW','ROLE','buyer',10578);
+INSERT INTO `ACL` VALUES (995,'Entry','find','READ','ALLOW','ROLE','buyer',10578);
+INSERT INTO `ACL` VALUES (996,'Entry','filter','READ','ALLOW','ROLE','buyer',10578);
+INSERT INTO `ACL` VALUES (997,'Entry','count','READ','ALLOW','ROLE','buyer',10578);
+INSERT INTO `ACL` VALUES (998,'Entry','getEntry','READ','ALLOW','ROLE','buyer',10578);
+INSERT INTO `ACL` VALUES (999,'Entry','getBuys','READ','ALLOW','ROLE','buyer',10578);
+INSERT INTO `ACL` VALUES (1000,'Entry','findOne','READ','ALLOW','ROLE','buyer',10578);
+INSERT INTO `ACL` VALUES (1001,'Entry','deleteBuys','WRITE','ALLOW','ROLE','buyer',10578);
+INSERT INTO `ACL` VALUES (1002,'Entry','editLatestBuys','WRITE','ALLOW','ROLE','buyer',10578);
+INSERT INTO `ACL` VALUES (1003,'Entry','importBuys','WRITE','ALLOW','ROLE','buyer',10578);
+INSERT INTO `ACL` VALUES (1004,'Entry','importBuysPreview','READ','ALLOW','ROLE','buyer',10578);
+INSERT INTO `ACL` VALUES (1005,'Entry','lastItemBuys','READ','ALLOW','ROLE','buyer',10578);
+INSERT INTO `ACL` VALUES (1006,'Entry','latestBuysFilter','READ','ALLOW','ROLE','buyer',10578);
+INSERT INTO `ACL` VALUES (1007,'ItemShelving','getItemsByReviewOrder','READ','ALLOW','ROLE','production',19294);
+INSERT INTO `ACL` VALUES (1008,'Entry','buyLabelSupplier','READ','ALLOW','ROLE','employee',19295);
+INSERT INTO `ACL` VALUES (1009,'Entry','buyLabel','READ','ALLOW','ROLE','supplier',19295);
INSERT INTO `fieldAcl` VALUES (1,'Client','name','update','employee');
INSERT INTO `fieldAcl` VALUES (2,'Client','contact','update','employee');
@@ -2386,69 +2543,51 @@ INSERT INTO `cplusTaxBreak` VALUES (7,'E6 - Exenta por otros');
INSERT INTO `claimResponsible` VALUES (1,'Compradores',0,'buy');
INSERT INTO `claimResponsible` VALUES (2,'Proveedor',0,'sup');
-INSERT INTO `claimResponsible` VALUES (3,'Entradores',0,'ent');
INSERT INTO `claimResponsible` VALUES (4,'Camareros',0,'bar');
INSERT INTO `claimResponsible` VALUES (6,'Sacadores',0,'pic');
INSERT INTO `claimResponsible` VALUES (7,'Revisadores',0,'chk');
-INSERT INTO `claimResponsible` VALUES (8,'Calidad general',0,'qas');
INSERT INTO `claimResponsible` VALUES (9,'Encajadores',0,'pck');
INSERT INTO `claimResponsible` VALUES (10,'Clima',0,'wea');
INSERT INTO `claimResponsible` VALUES (11,'Comerciales',1,'com');
INSERT INTO `claimResponsible` VALUES (12,'Clientes',1,'cli');
-INSERT INTO `claimResponsible` VALUES (13,'Administración',0,'adm');
INSERT INTO `claimResponsible` VALUES (14,'Agencia',0,'age');
INSERT INTO `claimResponsible` VALUES (15,'Repartidores',0,'del');
INSERT INTO `claimResponsible` VALUES (16,'Informatica',0,'ite');
INSERT INTO `claimResponsible` VALUES (17,'Transp.origen',0,'tra');
INSERT INTO `claimResponsible` VALUES (18,'Confeccion',0,'con');
INSERT INTO `claimResponsible` VALUES (19,'OTROS',0,'oth');
-INSERT INTO `claimResponsible` VALUES (21,'Gerencia',0,'man');
INSERT INTO `claimResponsible` VALUES (22,'Paletizadores',0,'pal');
INSERT INTO `claimResponsible` VALUES (23,'Preparación Previa',0,'pre');
-INSERT INTO `claimResponsible` VALUES (24,'Almacén PCA',0,'war');
INSERT INTO `claimResponsible` VALUES (25,'Huelga',0,'str');
+INSERT INTO `claimResponsible` VALUES (27,'Prep. por caja',0,'pbb');
+INSERT INTO `claimResponsible` VALUES (45,'Negativo',0,'neg');
-INSERT INTO `claimReason` VALUES (1,'Prisas',0);
-INSERT INTO `claimReason` VALUES (2,'Novato',0);
INSERT INTO `claimReason` VALUES (3,'Exceso de confianza',0);
-INSERT INTO `claimReason` VALUES (4,'Exceso de celo',0);
-INSERT INTO `claimReason` VALUES (5,'Indiferencia',0);
INSERT INTO `claimReason` VALUES (6,'Extraviado o Hurto',0);
INSERT INTO `claimReason` VALUES (7,'Incompetencia',0);
-INSERT INTO `claimReason` VALUES (8,'Ubicación erronea',0);
-INSERT INTO `claimReason` VALUES (9,'Dat.Inctos/Pak.conf',0);
-INSERT INTO `claimReason` VALUES (10,'Datos duplicados',0);
-INSERT INTO `claimReason` VALUES (11,'Fallo stock',0);
-INSERT INTO `claimReason` VALUES (12,'Innovación',0);
INSERT INTO `claimReason` VALUES (13,'Distracción',1);
-INSERT INTO `claimReason` VALUES (15,'Portes indebidos',0);
INSERT INTO `claimReason` VALUES (16,'Baja calidad',0);
INSERT INTO `claimReason` VALUES (17,'Defectuoso',0);
-INSERT INTO `claimReason` VALUES (19,'Endiñado',0);
INSERT INTO `claimReason` VALUES (20,'Calor',0);
INSERT INTO `claimReason` VALUES (21,'Frio',0);
INSERT INTO `claimReason` VALUES (22,'Cambiado',0);
-INSERT INTO `claimReason` VALUES (24,'Cansancio',1);
INSERT INTO `claimReason` VALUES (25,'Mal etiquetado',1);
-INSERT INTO `claimReason` VALUES (26,'Cantidad malentendido',0);
-INSERT INTO `claimReason` VALUES (30,'No revisado',1);
INSERT INTO `claimReason` VALUES (34,'Error fotografia',0);
INSERT INTO `claimReason` VALUES (40,'Fallo Personal VN',0);
-INSERT INTO `claimReason` VALUES (41,'Fallo Personal Cliente',0);
INSERT INTO `claimReason` VALUES (42,'Otros',0);
INSERT INTO `claimReason` VALUES (43,'Precio alto',0);
-INSERT INTO `claimReason` VALUES (44,'Abuso de confianza',0);
INSERT INTO `claimReason` VALUES (45,'Retraso Agencia',0);
INSERT INTO `claimReason` VALUES (46,'Delicado',0);
-INSERT INTO `claimReason` VALUES (47,'Seco',0);
INSERT INTO `claimReason` VALUES (48,'Retraso Reparto',0);
INSERT INTO `claimReason` VALUES (49,'Mal Embalado',0);
INSERT INTO `claimReason` VALUES (50,'Tumbado',0);
INSERT INTO `claimReason` VALUES (51,'Enfermo/Plaga',0);
INSERT INTO `claimReason` VALUES (52,'Mala gestión comercial',0);
INSERT INTO `claimReason` VALUES (53,'Mala gestión comprador',0);
-INSERT INTO `claimReason` VALUES (54,'A2',0);
INSERT INTO `claimReason` VALUES (55,'Entrega 48h o más',0);
+INSERT INTO `claimReason` VALUES (56,'Error cliente',0);
+INSERT INTO `claimReason` VALUES (57,'A2/B1',0);
+INSERT INTO `claimReason` VALUES (58,'Seguro',0);
INSERT INTO `claimRedelivery` VALUES (1,'Cliente');
INSERT INTO `claimRedelivery` VALUES (2,'No dev./No especif.');
@@ -2456,8 +2595,8 @@ INSERT INTO `claimRedelivery` VALUES (3,'Reparto');
INSERT INTO `claimRedelivery` VALUES (4,'Agencia');
INSERT INTO `claimRedelivery` VALUES (5,'Tour');
INSERT INTO `claimRedelivery` VALUES (6,'Fuera Peninsula');
+INSERT INTO `claimRedelivery` VALUES (7,'Francia');
-INSERT INTO `claimResult` VALUES (1,'Otros daños');
INSERT INTO `claimResult` VALUES (2,'Roces');
INSERT INTO `claimResult` VALUES (3,'Humedad');
INSERT INTO `claimResult` VALUES (4,'Deshidratacion');
@@ -2466,26 +2605,20 @@ INSERT INTO `claimResult` VALUES (6,'Incompleto (Faltas)');
INSERT INTO `claimResult` VALUES (7,'Error packing');
INSERT INTO `claimResult` VALUES (8,'Error color');
INSERT INTO `claimResult` VALUES (9,'Error medida');
-INSERT INTO `claimResult` VALUES (10,'Error origen');
INSERT INTO `claimResult` VALUES (11,'Envejecido');
-INSERT INTO `claimResult` VALUES (12,'Venta Perdida');
INSERT INTO `claimResult` VALUES (13,'Duplicacion');
INSERT INTO `claimResult` VALUES (14,'Rechazado');
INSERT INTO `claimResult` VALUES (15,'Rotura');
INSERT INTO `claimResult` VALUES (16,'Deterioro/Estropeado');
INSERT INTO `claimResult` VALUES (17,'Podrido');
-INSERT INTO `claimResult` VALUES (18,'Baboso');
-INSERT INTO `claimResult` VALUES (19,'Cocido');
INSERT INTO `claimResult` VALUES (20,'Congelado');
INSERT INTO `claimResult` VALUES (21,'Machacado');
-INSERT INTO `claimResult` VALUES (22,'Error precio');
INSERT INTO `claimResult` VALUES (23,'Manchado');
INSERT INTO `claimResult` VALUES (24,'No entregado');
-INSERT INTO `claimResult` VALUES (25,'Cobro indebido');
INSERT INTO `claimResult` VALUES (26,'Decepcion/Esperaba mas');
INSERT INTO `claimResult` VALUES (27,'Otros');
INSERT INTO `claimResult` VALUES (28,'Baboso/Cocido');
-INSERT INTO `claimResult` VALUES (29,'Video Camara');
+INSERT INTO `claimResult` VALUES (29,'Videocámaras');
INSERT INTO `component` VALUES (10,'Precios Especiales',4,NULL,NULL,1,'specialPrices',0);
INSERT INTO `component` VALUES (14,'porte extra por dia semana',6,NULL,NULL,1,'extraCostPerWeekDay',0);
@@ -2533,63 +2666,71 @@ 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,114,763,0,0,0,0,26,NULL,'/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
+INSERT INTO `department` VALUES (1,'VN','VERDNATURA',1,130,763,0,0,0,0,26,NULL,'/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (22,'shopping','COMPRAS',2,5,NULL,72,0,0,1,1,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (23,'CMA','CAMARA',15,16,NULL,72,1,1,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,1,NULL,NULL,NULL,'PREVIOUS');
-INSERT INTO `department` VALUES (31,'it','INFORMATICA',6,7,NULL,72,0,0,1,0,1,'/1/','informatica-cau',1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
+INSERT INTO `department` VALUES (31,'it','INFORMATICA',6,7,NULL,72,0,0,1,0,1,'/1/','informatica-cau',1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (34,'accounting','CONTABILIDAD',8,9,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
-INSERT INTO `department` VALUES (35,'finance','FINANZAS',10,11,NULL,0,0,0,1,0,1,'/1/',NULL,1,'begonya@verdnatura.es',1,0,0,0,NULL,NULL,NULL,NULL);
+INSERT INTO `department` VALUES (35,'finance','FINANZAS',10,11,NULL,0,0,0,1,0,1,'/1/',NULL,1,'begonya@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (36,'labor','LABORAL',12,13,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (37,'PROD','PRODUCCION',14,37,NULL,72,1,1,1,11,1,'/1/',NULL,0,NULL,0,1,1,1,NULL,NULL,NULL,NULL);
-INSERT INTO `department` VALUES (38,'picking','SACADO',17,18,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,'ON_PREPARATION');
+INSERT INTO `department` VALUES (38,'picking','SACADO',17,18,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,0,1,NULL,NULL,NULL,'ON_PREPARATION');
INSERT INTO `department` VALUES (39,'packing','ENCAJADO',19,20,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,'PACKING');
INSERT INTO `department` VALUES (41,'administration','ADMINISTRACION',38,39,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
-INSERT INTO `department` VALUES (43,'VT','VENTAS',40,73,NULL,0,0,0,1,16,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
-INSERT INTO `department` VALUES (44,'management','GERENCIA',74,75,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',76,77,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',78,79,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,'DELIVERY');
-INSERT INTO `department` VALUES (48,'storage','ALMACENAJE',80,81,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'STORAGE');
-INSERT INTO `department` VALUES (49,NULL,'PROPIEDAD',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 (52,NULL,'CARGA AEREA',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 (53,'marketing','MARKETING Y COMUNICACIÓN',41,42,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',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 (43,'VT','VENTAS',40,89,NULL,0,0,0,1,24,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
+INSERT INTO `department` VALUES (44,'management','GERENCIA',90,91,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
+INSERT INTO `department` VALUES (45,'logistic','LOGISTICA',92,93,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
+INSERT INTO `department` VALUES (46,'delivery','REPARTO',94,95,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,'DELIVERY');
+INSERT INTO `department` VALUES (48,'storage','ALMACENAJE',96,97,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'STORAGE');
+INSERT INTO `department` VALUES (49,NULL,'PROPIEDAD',98,99,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
+INSERT INTO `department` VALUES (52,NULL,'CARGA AEREA',100,101,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
+INSERT INTO `department` VALUES (53,'marketing','MARKETING Y COMUNICACIÓN',41,42,NULL,72,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
+INSERT INTO `department` VALUES (54,NULL,'ORNAMENTALES',102,103,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (55,NULL,'TALLER NATURAL',21,22,14548,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1118,NULL,NULL,NULL);
INSERT INTO `department` VALUES (56,NULL,'TALLER ARTIFICIAL',23,24,8470,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1927,NULL,NULL,NULL);
-INSERT INTO `department` VALUES (58,'CMP','CAMPOS',88,91,NULL,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'FIELD');
-INSERT INTO `department` VALUES (59,'maintenance','MANTENIMIENTO',92,93,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',43,44,NULL,72,0,0,2,0,43,'/1/43/',NULL,0,NULL,1,1,0,0,NULL,NULL,NULL,'CLAIM');
-INSERT INTO `department` VALUES (61,NULL,'VNH',94,97,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',98,99,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
+INSERT INTO `department` VALUES (58,'CMP','CAMPOS',104,107,NULL,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'FIELD');
+INSERT INTO `department` VALUES (59,'maintenance','MANTENIMIENTO',108,109,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL);
+INSERT INTO `department` VALUES (60,'claims','RECLAMACIONES',43,44,NULL,72,0,0,2,0,43,'/1/43/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,'CLAIM');
+INSERT INTO `department` VALUES (61,NULL,'VNH',110,113,NULL,73,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
+INSERT INTO `department` VALUES (66,NULL,'VERDNAMADRID',114,115,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (68,NULL,'COMPLEMENTOS',25,26,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL);
-INSERT INTO `department` VALUES (69,NULL,'VERDNABARNA',100,101,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',45,46,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',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 (89,NULL,'COORDINACION',104,105,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',95,96,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',116,117,NULL,74,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
+INSERT INTO `department` VALUES (80,'spainTeam5','EQUIPO ESPAÑA 5',45,46,4250,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
+INSERT INTO `department` VALUES (86,NULL,'LIMPIEZA',118,119,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
+INSERT INTO `department` VALUES (89,NULL,'COORDINACION',120,121,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
+INSERT INTO `department` VALUES (90,NULL,'TRAILER',111,112,NULL,0,0,0,2,0,61,'/1/61/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (91,'artificial','ARTIFICIAL',27,28,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'PREVIOUS');
INSERT INTO `department` VALUES (92,NULL,'EQUIPO SILVERIO',47,48,1203,0,0,0,2,0,43,'/1/43/','sdc_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
-INSERT INTO `department` VALUES (94,'spainTeam2','EQUIPO ESPAÑA 2',49,50,3797,0,0,0,2,0,43,'/1/43/','es2_equipo',1,'es2@verdnatura.es',0,0,0,0,NULL,NULL,'5100',NULL);
-INSERT INTO `department` VALUES (95,'spainTeam1','EQUIPO ESPAÑA 1',51,52,24065,0,0,0,2,0,43,'/1/43/','es1_equipo',1,'es1@verdnatura.es',0,0,0,0,NULL,NULL,'5000',NULL);
+INSERT INTO `department` VALUES (94,'spainTeam2','EQUIPO ESPAÑA 2',49,50,3797,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
+INSERT INTO `department` VALUES (95,'spainTeam1','EQUIPO ESPAÑA 1',51,52,24065,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (96,NULL,'EQUIPO C LOPEZ',53,54,4661,0,0,0,2,0,43,'/1/43/','cla_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (115,NULL,'EQUIPO CLAUDI',55,56,3810,0,0,0,2,0,43,'/1/43/','csr_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (123,NULL,'EQUIPO ELENA BASCUÑANA',57,58,7102,0,0,0,2,0,43,'/1/43/','ebt_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
-INSERT INTO `department` VALUES (124,NULL,'CONTROL INTERNO',106,107,NULL,72,0,0,1,0,1,'/1/',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',1,'es3@verdnatura.es',0,0,0,0,NULL,NULL,'5200',NULL);
+INSERT INTO `department` VALUES (124,NULL,'CONTROL INTERNO',122,123,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
+INSERT INTO `department` VALUES (125,'spainTeam3','EQUIPO ESPAÑA 3',59,60,1118,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (126,NULL,'PRESERVADO',29,30,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (128,NULL,'PALETIZADO',31,32,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'PALLETIZING');
INSERT INTO `department` VALUES (130,NULL,'REVISION',33,34,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,'ON_CHECKING');
-INSERT INTO `department` VALUES (131,'greenhouse','INVERNADERO',89,90,NULL,0,0,0,2,0,58,'/1/58/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL);
+INSERT INTO `department` VALUES (131,'greenhouse','INVERNADERO',105,106,NULL,0,0,0,2,0,58,'/1/58/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (132,NULL,'EQUIPO DC',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',108,109,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',110,111,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',112,113,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 (133,'franceTeamManagement','EQUIPO GESTIÓN FRANCIA',63,64,9751,72,0,0,2,0,43,'/1/43/','fr_equipo',1,'gestionfrancia@verdnatura.es',0,0,0,0,NULL,NULL,'3300',NULL);
+INSERT INTO `department` VALUES (134,'portugalTeam','EQUIPO PORTUGAL',65,66,8964,0,0,0,2,0,43,'/1/43/','pt_equipo',1,'portugal@verdnatura.es',0,0,0,0,NULL,NULL,'3500',NULL);
+INSERT INTO `department` VALUES (135,'routers','ENRUTADORES',124,125,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
+INSERT INTO `department` VALUES (136,'heavyVehicles','VEHICULOS PESADOS',126,127,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
+INSERT INTO `department` VALUES (137,'sorter','SORTER',128,129,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
+INSERT INTO `department` VALUES (139,'spainTeam4','EQUIPO ESPAÑA 4',67,68,3803,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
+INSERT INTO `department` VALUES (140,'internationalTeam','EQUIPO INTERNACIONAL',69,70,24065,0,0,0,2,0,43,'/1/43/','int_equipo',1,'international@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (141,NULL,'PREVIA',35,36,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,'PREVIOUS');
INSERT INTO `department` VALUES (146,NULL,'VERDNACOLOMBIA',3,4,NULL,72,0,0,2,0,22,'/1/22/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
-INSERT INTO `department` VALUES (147,'spainTeamAsia','EQUIPO ESPAÑA ASIA',71,72,40214,0,0,0,2,0,43,'/1/43/','esA_equipo',0,'esA@verdnatura.es',0,0,0,0,NULL,NULL,'5500',NULL);
+INSERT INTO `department` VALUES (147,'spainTeamAsia','EQUIPO ESPAÑA ASIA',71,72,40214,0,0,0,2,0,43,'/1/43/','esA_equipo',1,'esA@verdnatura.es',0,0,0,0,NULL,NULL,'5500',NULL);
+INSERT INTO `department` VALUES (148,'franceTeamCatchment','EQUIPO CAPTACIÓN FRANCIA',73,74,25178,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,'6000',NULL);
+INSERT INTO `department` VALUES (149,'spainTeamCatchment','EQUIPO ESPAÑA CAPTACIÓN',75,76,1203,0,0,0,2,0,43,'/1/43/','es_captacion_equipo',1,'es_captacion@verdnatura.es',0,0,0,0,NULL,NULL,'5700',NULL);
+INSERT INTO `department` VALUES (150,'spainTeamLevanteIslands','EQUIPO ESPAÑA LEVANTE/ISLAS',77,78,1118,0,0,0,2,0,43,'/1/43/','es_levanteislas_equipo',1,'levanteislas.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5000',NULL);
+INSERT INTO `department` VALUES (151,'spainTeamNorthwest','EQUIPO ESPAÑA NOROESTE',79,80,7102,0,0,0,2,0,43,'/1/43/','es_noroeste_equipo',1,'noroeste.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5300',NULL);
+INSERT INTO `department` VALUES (152,'spainTeamNortheast','EQUIPO ESPAÑA NORESTE',81,82,1118,0,0,0,2,0,43,'/1/43/','es_noreste_equipo',1,'noreste.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5200',NULL);
+INSERT INTO `department` VALUES (153,'spainTeamSouth','EQUIPO ESPAÑA SUR',83,84,36578,0,0,0,2,0,43,'/1/43/','es_sur_equipo',1,'sur.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5400',NULL);
+INSERT INTO `department` VALUES (154,'spainTeamCenter','EQUIPO ESPAÑA CENTRO',85,86,4661,0,0,0,2,0,43,'/1/43/','es_centro_equipo',1,'centro.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5100',NULL);
+INSERT INTO `department` VALUES (155,'spainTeamVip','EQUIPO ESPAÑA VIP',87,88,5432,0,0,0,2,0,43,'/1/43/','es_vip_equipo',1,'vip.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5600',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);
@@ -2691,7 +2832,6 @@ INSERT INTO `state` VALUES (7,'Sin Acabar',1,0,'NOT_READY',7,0,0,0,0,0,0,4,1,'al
INSERT INTO `state` VALUES (8,'Revisado',8,2,'CHECKED',8,0,1,0,3,0,0,1,0,'warning');
INSERT INTO `state` VALUES (9,'Encajando',9,3,'PACKING',9,0,1,0,0,0,0,1,0,NULL);
INSERT INTO `state` VALUES (10,'Encajado',10,3,'PACKED',10,0,1,0,0,0,0,0,0,NULL);
-INSERT INTO `state` VALUES (11,'Facturado',0,4,'INVOICED',11,0,1,0,0,0,0,0,0,NULL);
INSERT INTO `state` VALUES (12,'Bloqueado',0,0,'BLOCKED',12,0,0,0,0,0,0,4,1,'alert');
INSERT INTO `state` VALUES (13,'En Reparto',11,4,'ON_DELIVERY',13,0,1,0,0,0,0,0,0,NULL);
INSERT INTO `state` VALUES (14,'Preparado',6,2,'PREPARED',14,0,1,0,2,0,0,1,0,'warning');
@@ -2704,19 +2844,15 @@ INSERT INTO `state` VALUES (23,'URGENTE',5,2,'LAST_CALL',23,1,0,1,0,0,0,4,1,'suc
INSERT INTO `state` VALUES (24,'Encadenado',4,0,'CHAINED',24,0,0,0,0,0,0,3,1,'success');
INSERT INTO `state` VALUES (25,'Embarcando',3,0,'BOARDING',25,1,0,0,0,0,0,3,0,'alert');
INSERT INTO `state` VALUES (26,'Prep Previa',5,0,'PREVIOUS_PREPARATION',28,1,0,0,1,0,0,2,0,'warning');
-INSERT INTO `state` VALUES (27,'Prep Asistida',5,2,'ASSISTED_PREPARATION',27,0,0,0,0,0,0,2,0,'success');
INSERT INTO `state` VALUES (28,'Previa OK',3,0,'OK PREVIOUS',28,1,0,1,1,1,1,3,0,'warning');
INSERT INTO `state` VALUES (29,'Previa Impreso',4,0,'PRINTED PREVIOUS',29,1,0,1,0,0,1,2,0,'success');
-INSERT INTO `state` VALUES (30,'Embarcado',4,2,'BOARD',30,0,0,0,2,0,0,3,0,'success');
INSERT INTO `state` VALUES (31,'Polizon Impreso',4,2,'PRINTED STOWAWAY',29,1,0,1,0,0,1,2,0,'success');
-INSERT INTO `state` VALUES (32,'Polizon OK',3,2,'OK STOWAWAY',31,1,0,0,1,1,1,3,0,'warning');
INSERT INTO `state` VALUES (33,'Auto_Impreso',4,0,'PRINTED_AUTO',29,1,0,1,0,0,1,2,0,'success');
INSERT INTO `state` VALUES (34,'Pte Pago',3,0,'WAITING_FOR_PAYMENT',34,0,0,0,0,0,0,4,1,'alert');
INSERT INTO `state` VALUES (35,'Semi-Encajado',9,3,'HALF_PACKED',10,0,1,0,0,0,0,1,0,NULL);
INSERT INTO `state` VALUES (36,'Previa Revisando',3,0,'PREVIOUS_CONTROL',37,1,0,0,4,0,1,2,0,'warning');
INSERT INTO `state` VALUES (37,'Previa Revisado',3,0,'PREVIOUS_CONTROLLED',29,1,0,1,0,0,1,2,0,'warning');
INSERT INTO `state` VALUES (38,'Prep Cámara',6,2,'COOLER_PREPARATION',14,0,0,0,2,0,0,2,0,'warning');
-INSERT INTO `state` VALUES (41,'Prep Parcial',6,2,'PARTIAL_PREPARATION',14,0,0,0,2,0,0,2,0,'warning');
INSERT INTO `state` VALUES (42,'Entregado en parte',13,3,'PARTIAL_DELIVERED',16,0,1,0,0,0,0,0,0,NULL);
INSERT INTO `state` VALUES (43,'Preparación por caja',6,2,'BOX_PICKING',42,0,0,0,2,0,0,2,0,'warning');
@@ -2727,6 +2863,17 @@ INSERT INTO `ticketCanAdvanceConfig` VALUES (1,5);
INSERT INTO `volumeConfig` VALUES (2.67,1.60,0.8,150,0.30,120,57,2.0,50,200,10,167.0);
+INSERT INTO `workerActivityType` VALUES ('CLAIM','RECLAMACIONES');
+INSERT INTO `workerActivityType` VALUES ('DELIVERY','REPARTO');
+INSERT INTO `workerActivityType` VALUES ('FIELD','CAMPOS');
+INSERT INTO `workerActivityType` VALUES ('ON_CHECKING','REVISION');
+INSERT INTO `workerActivityType` VALUES ('ON_PREPARATION','SACADO');
+INSERT INTO `workerActivityType` VALUES ('PACKING','ENCAJADO');
+INSERT INTO `workerActivityType` VALUES ('PALLETIZING','PALETIZADO');
+INSERT INTO `workerActivityType` VALUES ('PREVIOUS','ARTIFICIAL-CÁMARA');
+INSERT INTO `workerActivityType` VALUES ('STOP','PARADA');
+INSERT INTO `workerActivityType` VALUES ('STORAGE','ALMACENAJE');
+
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);
@@ -3056,6 +3203,7 @@ USE `sage`;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
INSERT INTO `TiposIva` VALUES (2,0,'Operaciones no sujetas',0.0000000000,0.0000000000,0.0000000000,'','4770000020','','','','','','','95B21A93-5910-489D-83BB-C32788C9B19D','','','','','','','','','',0);
+INSERT INTO `TiposIva` VALUES (3,0,'IVA ESPECIAL 2%',0.0000000000,2.0000000000,0.0000000000,'4720000002','4770000012','','','','','','','9E6160D5-984E-4643-ACBC-1EBC3BF73360','','','','','','','','','',0);
INSERT INTO `TiposIva` VALUES (4,0,'I.V.A. 4%',0.0000000000,4.0000000000,0.0000000000,'4720000004','4770000004','','6310000000','','','','','9E6160D5-984E-4643-ACBC-1EBC3BF73360','','','','','','','','','',0);
INSERT INTO `TiposIva` VALUES (5,0,'I.V.A. 4% y R.E. 0.5%',0.0000000000,4.0000000000,0.5000000000,'','4770000504','4770000405','','','','','','DBEFA562-63FB-4FFC-8171-64F0C6F065FF','','','','','','','','','',0);
INSERT INTO `TiposIva` VALUES (6,0,'H.P. IVA 4% CEE',0.0000000000,4.0000000000,0.0000000000,'4721000004','4771000004','','','','','','','DD0ECBA8-2EF5-425E-911B-623580BADA77','','','','','','','','','',0);
diff --git a/db/dump/.dump/privileges.sql b/db/dump/.dump/privileges.sql
index 66e553763..f608d0e8a 100644
--- a/db/dump/.dump/privileges.sql
+++ b/db/dump/.dump/privileges.sql
@@ -49,6 +49,7 @@ INSERT IGNORE INTO `db` VALUES ('','geo','developerBoss','Y','Y','Y','Y','N','N'
INSERT IGNORE INTO `db` VALUES ('','floranet','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N');
INSERT IGNORE INTO `db` VALUES ('','tmp','guest','Y','Y','Y','Y','N','Y','N','N','N','N','Y','N','N','N','N','N','N','N','N','N');
INSERT IGNORE INTO `db` VALUES ('','util','salix','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N');
+INSERT IGNORE INTO `db` VALUES ('','srt','maintenanceBoss','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N');
INSERT IGNORE INTO `db` VALUES ('','dipole','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N');
INSERT IGNORE INTO `db` VALUES ('','bi','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N');
INSERT IGNORE INTO `db` VALUES ('','sage','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N');
@@ -502,7 +503,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','receipt','alexm@%','0000-
INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','grafana','visitUser','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','referenceRate','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','report','alexm@%','0000-00-00 00:00:00','Select','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','cache','productionBoss','available','guillermo@10.5.1.2','0000-00-00 00:00:00','Select','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyerAssistant','producer','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','time','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','role','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','config__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
@@ -605,7 +606,6 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','project','jua
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','productionConfig','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','manager','productionConfig','alexm@%','0000-00-00 00:00:00','Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','creditInsurance','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','cache','productionBoss','visible','guillermo@10.5.1.2','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','errorProduction__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','invoiceOut','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','coolerAssist','Tickets','alexm@%','0000-00-00 00:00:00','Update','');
@@ -792,7 +792,6 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','Movimientos','alexm@%
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','buy','alexm@%','0000-00-00 00:00:00','Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','itemMinimumQuantity','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','receipt','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerBoss','producer','alexm@%','0000-00-00 00:00:00','Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','link','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','link','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','delivery','vehicle','alexm@%','0000-00-00 00:00:00','Select','');
@@ -806,7 +805,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','edi','grafana','supplyResponse','ju
INSERT IGNORE INTO `tables_priv` VALUES ('','cache','customer','last_buy','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','client','carlosap@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','invoiceInTax','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','workerTeam','juan@10.5.1.2','0000-00-00 00:00:00','Select,Insert,Update','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','workerTeam','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','profile_type','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','profile_media','alexm@%','0000-00-00 00:00:00','Select,Insert','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','recovery','alexm@%','0000-00-00 00:00:00','Select','');
@@ -836,7 +835,6 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','bi','salesPerson','tarifa_component
INSERT IGNORE INTO `tables_priv` VALUES ('','srt','employee','expeditionLog','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','bs','salesPerson','clientNewBorn','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','saleItemShelving__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesBoss','workerTeam','juan@10.5.1.2','0000-00-00 00:00:00','Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','srt','employee','expedition','alexm@%','0000-00-00 00:00:00','Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemShelvingStock','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','saleParking__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
@@ -888,7 +886,6 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketDms','alexm@%
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','ektEntryAssign','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','intrastat','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','supplierAgencyTerm','alexm@%','0000-00-00 00:00:00','Update','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','entryConfig','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','franceExpressConfig','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','manager','ticketLog','juan@10.5.1.2','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','ticketCollection','alexm@%','0000-00-00 00:00:00','Delete','');
@@ -943,11 +940,10 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','volumeConfig','alex
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','ticketTrackingState','alexm@%','0000-00-00 00:00:00','Select,Insert,Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','warehouse','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','role','alexm@%','0000-00-00 00:00:00','Select','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workCenter','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientCredit','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','worker','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','workerAppTester','alexm@%','0000-00-00 00:00:00','Select','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','propertyGroup','alexm@%','0000-00-00 00:00:00','Select','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','propertyGroup','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','worker','alexm@%','0000-00-00 00:00:00','Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerBusinessType','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','workerDepartment','alexm@%','0000-00-00 00:00:00','Select','');
@@ -966,12 +962,11 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','workerMana','alexm@%',
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','workerMana','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','ticketPackaging','alexm@%','0000-00-00 00:00:00','Insert','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','ticketPackagingStartingStock','alexm@%','0000-00-00 00:00:00','Select','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','entryConfig','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','officeBoss','ticketPackagingStartingStock','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerRelatives','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','ticketPackagingStartingStock','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','supplierPackaging','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerDocument','alexm@%','0000-00-00 00:00:00','Select,Insert','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','supplierContact','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceCorrection','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ink','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','zone','alexm@%','0000-00-00 00:00:00','Select','');
@@ -1248,7 +1243,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','bs','deliveryAssistant','m3','alexm
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','ticketDms','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','time','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','v_Articles_botanical','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','workCenter','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','inventoryConfig','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','workerDepartment','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','zoneEvent','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','bi','deliveryAssistant','rotacion','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
@@ -1390,7 +1385,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','entry','jenki
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 ('','vn','administrative','farmingDeliveryNote','carlosap@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
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','');
@@ -1421,13 +1416,10 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financialBoss','accountDetail'
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','accountDetail','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','maintenanceBoss','project','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','maintenanceBoss','machineDetail','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','antenna','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','bufferPool','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','enteringLog','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','expeditionLoading','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','failureLog','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','movingLog','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','sorterLog','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','workerActivityType','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyerSalesAssistant','route','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','workCenter','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerSalesAssistant','Rutas','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','genericAllocation','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','businessReasonEnd','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','buy_edi','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
@@ -1465,15 +1457,37 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryBoss','vehicleDms','gu
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryBoss','vehicleInvoiceIn','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryBoss','vehicleNotes','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','saleGroup','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','bufferLog','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','shelvingLog','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financialBoss','supplierAccount','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','tillSerial','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','stockBuyed','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','alertLevel','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerActivityType','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
-INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','priceDelta','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','priceDelta','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','parkingLog','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','travelLog','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','supplierContact','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerDms','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemLog','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','account','developer','user','juan@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','claimReason','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','claimResponsible','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','claimResult','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','claimRedelivery','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','producer','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','itemStateTag','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','material','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','saleUnit','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','origin','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','delivery','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','itemFarmingTag','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','itemWrappingTag','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','itemLanguageTag','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','itemStemTag','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','itemBaseTag','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','itemBreederTag','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemShelvingLog','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
+INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','itemTextureTag','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
/*!40000 ALTER TABLE `tables_priv` ENABLE KEYS */;
/*!40000 ALTER TABLE `columns_priv` DISABLE KEYS */;
@@ -1853,7 +1867,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','buy_getVolumeByE
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_getVolumeByEntry','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','entry_moveNotPrinted','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','buy_getVolume','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00');
-INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','stockbuyedbyworker','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
+INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','stockBuyedByWorker','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','buy_getsplit','PROCEDURE','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','subordinategetlist','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_afterUpsert','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
@@ -1895,7 +1909,6 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','util','android','debugadd','PROCEDUR
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','copyComponentsFromSaleList','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','duaEntryValueUpdate','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','duaInvoiceInBooking','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
-INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelvinglog_get','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expedition_getstate','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','srt','production','expedition_scan','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','productionBoss','saleSplit','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
@@ -1906,7 +1919,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','util','grafana','firstdayofyear','FU
INSERT IGNORE INTO `procs_priv` VALUES ('','util','claimManager','dayend','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','util','employee','log_add','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','srt','employee','moving_between','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
-INSERT IGNORE INTO `procs_priv` VALUES ('','bi','financial','defaultersfromdate','PROCEDURE','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00');
+INSERT IGNORE INTO `procs_priv` VALUES ('','bi','financial','defaultersfromdate','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','getuser','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','hasanynegativebase','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','marketingBoss','hasanynegativebase','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00');
@@ -2001,7 +2014,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','logshow','PROCEDURE','alex
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyerBoss','supplierpackaging_reportsource','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financialBoss','supplierexpenses','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','grafana','firstdayofweek','FUNCTION','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00');
-INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','stockbuyed_add','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
+INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','stockBuyed_add','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','mail_insert','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','duaParcialMake','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','palletizerBoss','packingsite_startcollection','PROCEDURE','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00');
@@ -2081,7 +2094,6 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','collection_printst
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','deviceproductionuser_getworker','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','ticket_printlabelprevious','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','ticket_isoutclosurezone','FUNCTION','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
-INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','workermachinery_isregistered','FUNCTION','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','ticketstatetoday_setstate','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','device_checklogin','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','worker_getfromhasmistake','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
@@ -2089,7 +2101,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','sectorcollection_n
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','sectorcollection_get','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','setparking','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','shelvingparking_get','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
-INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','machine_getworkerplate','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
+INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','report_print','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','saletracking_addprevok','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','sectorcollectionsalegroup_add','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','saletracking_updateischecked','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
@@ -2098,7 +2110,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','travel_updatepacki
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','freelance_getinfo','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','company_getfiscaldata','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expedition_getfromroute','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
-INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','machineworker_gethistorical','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
+INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','buy_getUltimate','FUNCTION','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemplacementsupplyaiming','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expeditionstate_addbypallet','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','srt','production','expeditionloading_add','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
@@ -2119,7 +2131,6 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','srt','delivery','buffer_settypebynam
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expedition_getstate','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','srt','delivery','expedition_scan','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_get','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
-INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelvinglog_get','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_add','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_getsaledate','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_filterbuyer','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
@@ -2132,7 +2143,6 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','collection_printstic
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','deviceproductionuser_getworker','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','ticket_printlabelprevious','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','ticket_isoutclosurezone','FUNCTION','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
-INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','workermachinery_isregistered','FUNCTION','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','ticketstatetoday_setstate','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','device_checklogin','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','worker_getfromhasmistake','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
@@ -2140,7 +2150,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','sectorcollection_new
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','sectorcollection_get','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','setparking','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','shelvingparking_get','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
-INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','machine_getworkerplate','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
+INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','buy_getLastWithoutInventory','FUNCTION','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','saletracking_addprevok','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','sectorcollectionsalegroup_add','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','saletracking_updateischecked','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
@@ -2149,7 +2159,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','travel_updatepacking
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','freelance_getinfo','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','company_getfiscaldata','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expedition_getfromroute','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
-INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','machineworker_gethistorical','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
+INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','zone_getPostalCode','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemplacementsupplyaiming','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expeditionstate_addbypallet','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','srt','delivery','expeditionloading_add','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
@@ -2211,7 +2221,10 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','guest','ticketCalculatePurge','
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_getUltimate','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','cooler','buy_getUltimate','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','bs','buyerBoss','waste_addSales','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
-INSERT IGNORE INTO `procs_priv` VALUES ('','bs','grafana','waste_addSales','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
+INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','saletracking_sectorcollectionaddprevok','PROCEDURE','alexm@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
+INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','saleSplit','PROCEDURE','carlosap@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
+INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemShelvingSale_deleteAdded','PROCEDURE','guillermo@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
+INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','buy_getUltimate','PROCEDURE','guillermo@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 */;
@@ -2236,9 +2249,10 @@ INSERT IGNORE INTO `global_priv` VALUES ('','assetManager','{\"access\":0,\"vers
INSERT IGNORE INTO `global_priv` VALUES ('','buyer','{\"access\": 0, \"version_id\": 101106, \"is_role\": true}');
INSERT IGNORE INTO `global_priv` VALUES ('','buyerAssistant','{\"access\":0,\"version_id\":101106,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','buyerBoss','{\"access\": 0, \"version_id\": 101106, \"is_role\": true}');
+INSERT IGNORE INTO `global_priv` VALUES ('','buyerSalesAssistant','{\"access\":0,\"version_id\":101106,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','claimManager','{\"access\":0,\"version_id\":101106,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','cooler','{\"access\":0,\"version_id\":101106,\"is_role\":true}');
-INSERT IGNORE INTO `global_priv` VALUES ('','coolerAssist','{\"access\":0,\"version_id\":100707,\"is_role\":true}');
+INSERT IGNORE INTO `global_priv` VALUES ('','coolerAssist','{\"access\":0,\"version_id\":101106,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','coolerBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','customer','{\"access\": 0, \"max_questions\": 0, \"max_updates\": 30000, \"max_connections\": 300000, \"max_user_connections\": 400, \"max_statement_time\": 0.000000, \"is_role\": true,\"version_id\":100707}');
INSERT IGNORE INTO `global_priv` VALUES ('','delivery','{\"access\":0,\"version_id\":101106,\"is_role\":true}');
diff --git a/db/dump/.dump/structure.sql b/db/dump/.dump/structure.sql
index 0bd03ac32..a4ae460b1 100644
--- a/db/dump/.dump/structure.sql
+++ b/db/dump/.dump/structure.sql
@@ -75,26 +75,6 @@ SET character_set_client = utf8;
1 AS `password` */;
SET character_set_client = @saved_cs_client;
---
--- Table structure for table `accountLog__`
---
-
-DROP TABLE IF EXISTS `accountLog__`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `accountLog__` (
- `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
- `msg` varchar(255) NOT NULL,
- `pid` varchar(255) NOT NULL,
- `user` varchar(255) NOT NULL,
- `host` varchar(255) NOT NULL,
- `rhost` varchar(255) NOT NULL,
- `time` varchar(255) NOT NULL,
- `summaryId` varchar(30) DEFAULT NULL,
- PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='@deprecated 2024-09-02 refs #7819';
-/*!40101 SET character_set_client = @saved_cs_client */;
-
--
-- Temporary table structure for view `emailUser`
--
@@ -246,8 +226,7 @@ SET character_set_client = utf8;
1 AS `email`,
1 AS `nickname`,
1 AS `lang`,
- 1 AS `role`,
- 1 AS `recoverPass` */;
+ 1 AS `role` */;
SET character_set_client = @saved_cs_client;
--
@@ -416,15 +395,15 @@ CREATE TABLE `user` (
`role` int(10) unsigned NOT NULL DEFAULT 2,
`active` tinyint(1) NOT NULL DEFAULT 1,
`email` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
- `emailVerified` tinyint(1) DEFAULT NULL,
+ `emailVerified` tinyint(1) NOT NULL DEFAULT 0,
`verificationToken` varchar(512) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
`lang` char(2) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
`lastPassChange` datetime DEFAULT NULL,
`created` timestamp NOT NULL DEFAULT current_timestamp(),
`updated` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`image` varchar(255) DEFAULT NULL,
- `recoverPass` tinyint(3) unsigned NOT NULL DEFAULT 1 COMMENT 'Deprecated',
- `sync` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'Deprecated',
+ `recoverPass__` tinyint(3) unsigned NOT NULL DEFAULT 1 COMMENT '@deprecated 2024-11-13',
+ `sync__` tinyint(4) NOT NULL DEFAULT 0 COMMENT '@deprecated 2024-11-13',
`hasGrant` tinyint(1) NOT NULL,
`editorFk` int(10) unsigned DEFAULT NULL,
`passExpired` date DEFAULT NULL,
@@ -3539,14 +3518,14 @@ BEGIN
bultos)
SELECT r.id,
r.agencyModeFk,
- r.created,
+ r.dated,
SUM(sv.volume / ebv.m3)
FROM vn.route r
JOIN vn.ticket t ON t.routeFk = r.id
LEFT JOIN vn.`zone` z ON z.id = t.zoneFk
JOIN vn.saleVolume sv ON sv.ticketFk = t.id
JOIN vn.expeditionBoxVol ebv ON ebv.code = 'transportBox'
- WHERE r.created BETWEEN vDatedFrom AND vDatedTo
+ WHERE r.dated BETWEEN vDatedFrom AND vDatedTo
AND z.isVolumetric
GROUP BY r.id;
@@ -3558,12 +3537,12 @@ BEGIN
Bultos)
SELECT r.id,
r.agencyModeFk,
- r.created,
+ r.dated,
SUM(t.packages)
FROM vn.route r
JOIN vn.ticket t ON t.routeFk = r.id
LEFT JOIN vn.`zone` z ON z.id = t.zoneFk
- WHERE r.created BETWEEN vDatedFrom AND vDatedTo
+ WHERE r.dated BETWEEN vDatedFrom AND vDatedTo
AND NOT z.isVolumetric
GROUP BY r.id
ON DUPLICATE KEY UPDATE Bultos = Bultos + VALUES(Bultos);
@@ -3580,7 +3559,7 @@ BEGIN
JOIN vn.component c ON c.id = sc.componentFk
JOIN vn.componentType ct ON ct.id = c.typeFk
WHERE ct.code = 'freight'
- AND r.created BETWEEN vDatedFrom AND vDatedTo
+ AND r.dated BETWEEN vDatedFrom AND vDatedTo
GROUP BY r.id
) sub ON sub.routeFk = r.Id_Ruta
SET r.practico = IFNULL(sub.totalPractice / r.Bultos, 0);
@@ -3597,7 +3576,7 @@ BEGIN
JOIN vn.address ad ON ad.id = t.addressFk
JOIN vn.client c ON c.id = ad.clientFk
LEFT JOIN vn.`zone` z ON z.id = t.zoneFk
- WHERE r.created BETWEEN vDatedFrom AND vDatedTo
+ WHERE r.dated BETWEEN vDatedFrom AND vDatedTo
AND NOT z.isVolumetric
GROUP BY t.routeFk
) sub ON r.Id_Ruta = sub.routeFk
@@ -3613,7 +3592,7 @@ BEGIN
JOIN vn.saleVolume sf ON sf.ticketFk = t.id
JOIN vn.client c ON c.id = t.clientFk
JOIN vn.`zone` z ON z.id = t.zoneFk
- WHERE r.created BETWEEN vDatedFrom AND vDatedTo
+ WHERE r.dated BETWEEN vDatedFrom AND vDatedTo
AND z.isVolumetric
GROUP BY t.routeFk
) sub ON r.Id_Ruta = sub.routeFk
@@ -3628,7 +3607,7 @@ BEGIN
JOIN vn.route r ON r.id = t.routeFk
JOIN vn.greuge g ON g.ticketFk = t.id
JOIN vn.greugeType gt ON gt.id = g.greugeTypeFk
- WHERE r.created BETWEEN vDatedFrom AND vDatedTo
+ WHERE r.dated BETWEEN vDatedFrom AND vDatedTo
AND gt.code = 'freightDifference'
GROUP BY t.routeFk
) sub ON r.Id_Ruta = sub.routeFk
@@ -3815,7 +3794,7 @@ CREATE TABLE `defaulter` (
`created` date NOT NULL,
`amount` double NOT NULL DEFAULT 0,
`defaulterSinced` date DEFAULT NULL,
- `hasChanged` tinyint(1) DEFAULT NULL,
+ `hasChanged` tinyint(1) NOT NULL DEFAULT 0,
`frozened` date DEFAULT NULL,
PRIMARY KEY (`clientFk`,`created`),
KEY `client` (`clientFk`),
@@ -4685,25 +4664,27 @@ BLOCK1: BEGIN
DECLARE vShipped DATE;
DECLARE vPreviousShipped DATE;
DECLARE vDone boolean;
- DECLARE cur cursor for
-
- SELECT clientFk, firstShipped
- FROM bs.clientNewBorn;
+
+ DECLARE cur CURSOR FOR
+ SELECT clientFk, firstShipped
+ FROM bs.clientNewBorn;
DECLARE continue HANDLER FOR NOT FOUND SET vDone = TRUE;
SET vDone := FALSE;
DELETE FROM bs.clientNewBorn WHERE isModified = FALSE;
- INSERT INTO clientNewBorn(clientFk, firstShipped, lastShipped)
- SELECT c.id, MAX(t.shipped), MAX(t.shipped)
- FROM vn.client c
- JOIN vn.ticket t on t.clientFk = c.id
- LEFT JOIN clientNewBorn cb on cb.clientFk = c.id
- WHERE t.shipped BETWEEN TIMESTAMPADD(YEAR, -1, util.VN_CURDATE()) AND util.VN_CURDATE() AND cb.isModified is null
- GROUP BY c.id;
+ INSERT INTO clientNewBorn(clientFk, firstShipped, lastShipped)
+ SELECT c.id, DATE(MAX(t.shipped)), DATE(MAX(t.shipped))
+ FROM vn.client c
+ JOIN vn.ticket t ON t.clientFk = c.id
+ LEFT JOIN clientNewBorn cb ON cb.clientFk = c.id
+ WHERE t.shipped BETWEEN util.VN_CURDATE() - INTERVAL 1 YEAR
+ AND util.VN_CURDATE()
+ AND cb.isModified IS NULL
+ GROUP BY c.id;
+
OPEN cur;
-
LOOP1: LOOP
SET vDone := FALSE;
FETCH cur INTO vClientFk, vShipped;
@@ -5196,7 +5177,7 @@ BEGIN
CREATE OR REPLACE TEMPORARY TABLE tVisible
SELECT itemFk, SUM(visible) totalVisible
FROM vn.itemShelving ish
- JOIN vn.shelving sh ON sh.code = ish.shelvingFk
+ JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
JOIN vn.sector sc ON sc.id = p.sectorFk
WHERE sc.warehouseFk = vWarehouseFk
@@ -6956,7 +6937,7 @@ proc: BEGIN
WHERE t.landed BETWEEN vInventoryDate AND vStartDate
AND t.warehouseInFk = vWarehouse
AND s.name != 'INVENTARIO'
- AND NOT e.isRaid
+ AND NOT t.isRaid
GROUP BY b.itemFk
) c
JOIN vn.item i ON i.id = c.itemFk
@@ -7835,7 +7816,6 @@ CREATE TABLE `expedition_PrintOut` (
`longName` varchar(30) DEFAULT NULL,
`shelvingFk` varchar(5) DEFAULT NULL,
`comments` varchar(100) DEFAULT NULL,
- `isChecked` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Indica si la expedición ha sido revisada por un revisor',
PRIMARY KEY (`expeditionFk`),
KEY `expedition_PrintOut_FK` (`printerFk`),
CONSTRAINT `expedition_PrintOut_FK` FOREIGN KEY (`printerFk`) REFERENCES `printer` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
@@ -11396,6 +11376,7 @@ CREATE TABLE `order` (
`tax` decimal(10,2) NOT NULL,
`total` decimal(10,2) NOT NULL,
`configured` datetime DEFAULT NULL,
+ `rowUpdated` datetime DEFAULT NULL COMMENT 'Timestamp for last updated record in orderRow table',
PRIMARY KEY (`id`),
KEY `address` (`address_id`),
KEY `delivery_method` (`delivery_method_id`),
@@ -12261,7 +12242,7 @@ BEGIN
JOIN vn.travel t ON t.id = e.travelFk
WHERE t.landed BETWEEN vDateInv AND vDate
AND t.warehouseInFk = vWarehouse
- AND NOT e.isRaid
+ AND NOT t.isRaid
UNION ALL
SELECT b.itemFk, -b.quantity
FROM vn.buy b
@@ -12269,7 +12250,7 @@ BEGIN
JOIN vn.travel t ON t.id = e.travelFk
WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE()
AND t.warehouseOutFk = vWarehouse
- AND NOT e.isRaid
+ AND NOT t.isRaid
AND t.isDelivered
UNION ALL
SELECT m.itemFk, -m.quantity
@@ -13184,6 +13165,70 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `orderRow_updateOverstocking` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `orderRow_updateOverstocking`(vOrderFk INT)
+BEGIN
+/**
+* Set amount = 0 to avoid overbooking sales
+*
+* @param vOrderFk hedera.order.id
+*/
+ DECLARE vCalcFk INT;
+ DECLARE vDone BOOL;
+ DECLARE vWarehouseFk INT;
+
+ DECLARE cWarehouses CURSOR FOR
+ SELECT DISTINCT warehouseFk
+ FROM orderRow
+ WHERE orderFk = vOrderFk
+ AND shipment = util.VN_CURDATE();
+
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
+
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ ROLLBACK;
+ RESIGNAL;
+ END;
+
+ OPEN cWarehouses;
+ checking: LOOP
+ SET vDone = FALSE;
+
+ FETCH cWarehouses INTO vWarehouseFk;
+
+ IF vDone THEN
+ LEAVE checking;
+ END IF;
+
+ CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, util.VN_CURDATE());
+
+ UPDATE orderRow r
+ JOIN `order` o ON o.id = r.orderFk
+ JOIN orderConfig oc
+ JOIN cache.available a ON a.calc_id = vCalcFk AND a.item_id = r.itemFk
+ SET r.amount = 0
+ WHERE ADDTIME(o.rowUpdated, oc.reserveTime) < util.VN_NOW()
+ AND a.available <= 0
+ AND r.warehouseFk = vWarehouseFk
+ AND r.orderFk = vOrderFk;
+ END LOOP;
+ CLOSE cWarehouses;
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `order_addItem` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -13689,6 +13734,7 @@ BEGIN
* @param vUser The user identifier
*/
DECLARE vHasRows BOOL;
+ DECLARE vHas0Amount BOOL;
DECLARE vDone BOOL;
DECLARE vWarehouseFk INT;
DECLARE vShipment DATE;
@@ -13698,7 +13744,6 @@ BEGIN
DECLARE vItemFk INT;
DECLARE vConcept VARCHAR(30);
DECLARE vAmount INT;
- DECLARE vAvailable INT;
DECLARE vPrice DECIMAL(10,2);
DECLARE vSaleFk INT;
DECLARE vRowFk INT;
@@ -13708,7 +13753,6 @@ BEGIN
DECLARE vClientFk INT;
DECLARE vCompanyFk INT;
DECLARE vAgencyModeFk INT;
- DECLARE vCalcFk INT;
DECLARE vIsTaxDataChecked BOOL;
DECLARE vDates CURSOR FOR
@@ -13774,6 +13818,20 @@ BEGIN
SELECT employeeFk INTO vUserFk FROM orderConfig;
END IF;
+ CALL orderRow_updateOverstocking(vSelf);
+
+ -- Check if any product has a quantity of 0
+ SELECT EXISTS (
+ SELECT id
+ FROM orderRow
+ WHERE orderFk = vSelf
+ AND amount = 0
+ ) INTO vHas0Amount;
+
+ IF vHas0Amount THEN
+ CALL util.throw('Hay líneas vacías. Por favor, elimínelas');
+ END IF;
+
START TRANSACTION;
CALL order_checkEditable(vSelf);
@@ -14035,45 +14093,54 @@ BEGIN
* @param vOrder El identificador del pedido
* @return tmp.orderTax Bases imponibles, IVA y recargo de equivalencia
*/
+ -- No poner create or replace, ya que da problemas
DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany;
CREATE TEMPORARY TABLE tmp.addressCompany
(INDEX (addressFk, companyFk))
ENGINE = MEMORY
SELECT DISTINCT o.address_id addressFk, o.company_id companyFk
FROM tmp.`order` tmpOrder
- JOIN hedera.`order` o ON o.id = tmpOrder.orderFk;
+ JOIN `order` o ON o.id = tmpOrder.orderFk;
- CALL vn.addressTaxArea;
+ CALL vn.addressTaxArea();
-- Calcula el IVA y el recargo desglosado.
-
- DROP TEMPORARY TABLE IF EXISTS tmp.orderTax;
- CREATE TEMPORARY TABLE tmp.orderTax
- (INDEX (orderFk))
+ CREATE OR REPLACE TEMPORARY TABLE tmp.orderTax
+ (PRIMARY KEY (orderFk, code, rate))
ENGINE = MEMORY
- SELECT o.id orderFk,
+ WITH orders AS (
+ SELECT tor.orderFk,
+ oro.amount * oro.price total,
+ s.countryFk,
+ ata.areaFk,
+ itc.taxClassFk
+ FROM hedera.orderRow oro
+ JOIN tmp.order tor ON tor.orderFk = oro.orderFk
+ JOIN hedera.`order` o ON o.id = tor.orderFk
+ JOIN vn.item i ON i.id = oro.itemFk
+ JOIN vn.`client` c ON c.id = o.customer_id
+ JOIN vn.supplier s ON s.id = o.company_id
+ JOIN tmp.addressTaxArea ata ON ata.addressFk = o.address_id
+ AND ata.companyFk = o.company_id
+ JOIN vn.itemTaxCountry itc ON itc.itemFk = i.id
+ AND itc.countryFk = s.countryFk
+ HAVING total
+ )
+ SELECT o.orderFk,
tc.code,
- SUM(m.amount * m.price) taxableBase,
+ SUM(o.total) taxableBase,
pgc.rate
- FROM tmp.`order` tmpOrder
- JOIN `order` o ON o.id = tmpOrder.orderFk
- JOIN orderRow m ON m.orderFk = o.id
- JOIN vn.item i ON i.id = m.itemFk
- JOIN vn.`client` c ON c.id = o.customer_id
- JOIN vn.supplier s ON s.id = o.company_id
- JOIN tmp.addressTaxArea ata
- ON ata.addressFk = o.address_id AND ata.companyFk = o.company_id
- JOIN vn.itemTaxCountry itc
- ON itc.itemFk = i.id AND itc.countryFk = s.countryFk
- JOIN vn.bookingPlanner bp
- ON bp.countryFk = s.countryFk
- AND bp.taxAreaFk = ata.areaFk
- AND bp.taxClassFk = itc.taxClassFk
- JOIN vn.pgc ON pgc.`code` = bp.pgcFk
+ FROM orders o
+ JOIN vn.bookingPlanner bp ON bp.countryFk = o.countryFk
+ AND bp.taxAreaFk = o.areaFk
+ AND bp.taxClassFk = o.taxClassFk
+ JOIN vn.pgc ON pgc.code = bp.pgcFk
JOIN vn.taxClass tc ON tc.id = bp.taxClassFk
- GROUP BY tmpOrder.orderFk, pgc.`code`, pgc.rate
- HAVING taxableBase != 0;
+ GROUP BY o.orderFk, pgc.code, pgc.rate
+ HAVING taxableBase
+ ORDER BY bp.priority;
+ -- No poner create or replace, ya que da problemas
DROP TEMPORARY TABLE IF EXISTS tmp.orderAmount;
CREATE TEMPORARY TABLE tmp.orderAmount
(INDEX (orderFk))
@@ -17436,7 +17503,7 @@ BEGIN
DECLARE vCursor CURSOR FOR
SELECT it.taxableBase,
- CAST((( it.taxableBase / 100) * t.PorcentajeIva) AS DECIMAL (10,2)),
+ CAST(SUM((( it.taxableBase / 100) * t.PorcentajeIva)) AS DECIMAL (10,2)),
t.PorcentajeIva,
it.transactionTypeSageFk,
it.taxTypeSageFk,
@@ -17449,7 +17516,8 @@ BEGIN
JOIN TiposTransacciones tt ON tt.CodigoTransaccion = it.transactionTypeSageFk
LEFT JOIN vn.dua d ON d.id = vInvoiceInFk
WHERE i.id = vInvoiceInFk
- AND d.id IS NULL;
+ AND d.id IS NULL
+ GROUP BY it.taxTypeSageFk;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
@@ -22669,12 +22737,11 @@ BEGIN
DROP TEMPORARY TABLE IF EXISTS tValues;
CREATE TEMPORARY TABLE tValues
ENGINE = MEMORY
- SELECT
- b.id buyFk,
+ SELECT b.id buyFk,
e.id entryFk,
t.id travelFk,
b.itemFk,
- e.isRaid,
+ t.isRaid,
ADDTIME(t.shipped,
IFNULL(t.shipmentHour, '00:00:00')) shipped,
t.warehouseOutFk,
@@ -22713,7 +22780,7 @@ BEGIN
itemFk,
TIMESTAMPADD(DAY, life, @dated),
quantity,
- IF(isIn, isReceived, isDelivered) AND !isRaid
+ IF(isIn, isReceived, isDelivered) AND NOT isRaid
FROM tValues
WHERE isIn OR !lessThanInventory;
@@ -22728,7 +22795,7 @@ BEGIN
itemFk,
created,
quantity,
- IF(isIn, isDelivered, isReceived) AND !isRaid
+ IF(isIn, isDelivered, isReceived) AND NOT isRaid
FROM tValues
WHERE !isIn OR !lessThanInventory;
@@ -23352,8 +23419,6 @@ DROP TABLE IF EXISTS `config`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `config` (
`id` int(10) unsigned NOT NULL,
- `dbVersion__` char(11) DEFAULT NULL COMMENT '@deprecated 2024-09-02 refs #7819',
- `hasTriggersDisabled__` tinyint(1) NOT NULL DEFAULT 0 COMMENT '@deprecated 2024-09-02 refs #7819',
`environment` varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT 'The current Database environment',
`lastDump` datetime DEFAULT NULL COMMENT 'Timestamp of the last data dump',
`mockUtcTime` datetime DEFAULT NULL,
@@ -25827,10 +25892,11 @@ CREATE TABLE `address` (
`isActive` tinyint(4) NOT NULL DEFAULT 1,
`longitude` decimal(11,7) DEFAULT NULL COMMENT 'Indica la última longitud proporcionada por tabla delivery',
`latitude` decimal(11,7) DEFAULT NULL COMMENT 'Indica la última latitud proporcionada por tabla delivery',
- `isEqualizated` tinyint(1) DEFAULT NULL,
+ `isEqualizated` tinyint(1) NOT NULL DEFAULT 0,
`customsAgentFk` int(11) DEFAULT NULL,
`incotermsFk` varchar(3) DEFAULT NULL,
`isLogifloraAllowed` tinyint(4) NOT NULL DEFAULT 0,
+ `geoFk` int(11) DEFAULT NULL,
`editorFk` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `Id_Agencia` (`agencyModeFk`),
@@ -25842,12 +25908,14 @@ CREATE TABLE `address` (
KEY `address_customsAgentFk_idx` (`customsAgentFk`),
KEY `address_incotermsFk_idx` (`incotermsFk`),
KEY `address_fk_editor` (`editorFk`),
+ KEY `address_zoneGeo_FK` (`geoFk`),
CONSTRAINT `address_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE,
CONSTRAINT `address_customsAgentFk` FOREIGN KEY (`customsAgentFk`) REFERENCES `customsAgent` (`id`) ON UPDATE CASCADE,
CONSTRAINT `address_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`),
CONSTRAINT `address_ibfk_3` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON UPDATE CASCADE,
CONSTRAINT `address_ibfk_4` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `address_incotermsFk` FOREIGN KEY (`incotermsFk`) REFERENCES `incoterms` (`code`) ON UPDATE CASCADE
+ CONSTRAINT `address_incotermsFk` FOREIGN KEY (`incotermsFk`) REFERENCES `incoterms` (`code`) ON UPDATE CASCADE,
+ CONSTRAINT `address_zoneGeo_FK` FOREIGN KEY (`geoFk`) REFERENCES `zoneGeo` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -26035,7 +26103,6 @@ CREATE TABLE `agencyMode` (
`inflation` decimal(5,2) NOT NULL DEFAULT 0.00 COMMENT 'Este valor se utiliza para aumentar el valor del componente porte.',
`isVolumetric` tinyint(1) NOT NULL DEFAULT 0,
`reportMail` varchar(100) DEFAULT NULL,
- `showAgencyName` tinyint(1) DEFAULT 1 COMMENT 'obsoleta',
`isActive` tinyint(1) NOT NULL DEFAULT 1,
`isExternalAgency` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'obsoleta',
`flag` blob DEFAULT NULL COMMENT 'obsoleta',
@@ -27058,23 +27125,6 @@ CREATE TABLE `buyConfig` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Table structure for table `buyMark`
---
-
-DROP TABLE IF EXISTS `buyMark`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `buyMark` (
- `id` int(11) NOT NULL,
- `comment` varchar(255) DEFAULT NULL,
- `mark` tinyint(1) DEFAULT NULL,
- `odbcDate` timestamp NULL DEFAULT current_timestamp(),
- PRIMARY KEY (`id`),
- CONSTRAINT `Compres_mark_ibfk_1` FOREIGN KEY (`id`) REFERENCES `buy` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
--
-- Temporary table structure for view `buyer`
--
@@ -27208,9 +27258,10 @@ DROP TABLE IF EXISTS `campaign`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `campaign` (
`id` int(11) NOT NULL AUTO_INCREMENT,
- `code` enum('mothersDay','allSaints','valentinesDay') NOT NULL,
+ `code` enum('mothersDay','allSaints','valentinesDay','frenchMothersDay') NOT NULL,
`dated` datetime NOT NULL DEFAULT current_timestamp(),
`scopeDays` int(11) NOT NULL DEFAULT 15,
+ `previousDays` int(10) unsigned NOT NULL DEFAULT 30 COMMENT 'Días previos para calcular e insertar en la tabla itemCampaign',
PRIMARY KEY (`id`),
UNIQUE KEY `campaign_dated_uindex` (`dated`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
@@ -27262,7 +27313,7 @@ CREATE TABLE `chat` (
`senderFk` int(10) unsigned DEFAULT NULL,
`recipient` varchar(50) DEFAULT NULL,
`dated` datetime DEFAULT NULL,
- `checkUserStatus` tinyint(1) DEFAULT NULL,
+ `checkUserStatus` tinyint(1) NOT NULL DEFAULT 0,
`message` text DEFAULT NULL,
`attempts` int(1) DEFAULT NULL,
`error` text DEFAULT NULL,
@@ -27656,7 +27707,7 @@ CREATE TABLE `client` (
`credit` decimal(10,2) unsigned NOT NULL DEFAULT 0.00,
`countryFk` mediumint(8) unsigned NOT NULL DEFAULT 1,
`isActive` tinyint(1) NOT NULL DEFAULT 1,
- `gestdocFk` int(11) DEFAULT NULL,
+ `gestdocFk__` int(11) DEFAULT NULL COMMENT '@deprecated 2024-10-17',
`quality` int(2) DEFAULT 11,
`payMethodFk` tinyint(3) unsigned NOT NULL DEFAULT 5,
`created` timestamp NULL DEFAULT current_timestamp(),
@@ -27685,8 +27736,9 @@ CREATE TABLE `client` (
`businessTypeFk` varchar(20) NOT NULL DEFAULT 'florist',
`rating` int(10) unsigned DEFAULT NULL COMMENT 'información proporcionada por Informa',
`recommendedCredit` int(10) unsigned DEFAULT NULL COMMENT 'información proporcionada por Informa',
- `editorFk` int(10) unsigned DEFAULT NULL,
`hasDailyInvoice` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Indica si el cliente requiere facturación diaria por defecto se copiará lo que tenga country.hasDailyInvoice',
+ `geoFk` int(11) DEFAULT NULL,
+ `editorFk` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `IF` (`fi`),
KEY `Id_Trabajador` (`salesPersonFk`),
@@ -27708,6 +27760,7 @@ CREATE TABLE `client` (
KEY `codpos` (`postcode`),
KEY `client_fk_editor` (`editorFk`),
KEY `client_isTaxDataChecked_IDX` (`isTaxDataChecked`) USING BTREE,
+ KEY `client_zoneGeo_FK` (`geoFk`),
CONSTRAINT `canal_nuevo_cliente` FOREIGN KEY (`contactChannelFk`) REFERENCES `contactChannel` (`id`) ON UPDATE CASCADE,
CONSTRAINT `client_FK` FOREIGN KEY (`businessTypeFk`) REFERENCES `businessType` (`code`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `client_FK_1` FOREIGN KEY (`bankEntityFk`) REFERENCES `bankEntity` (`id`) ON UPDATE CASCADE,
@@ -27721,6 +27774,7 @@ CREATE TABLE `client` (
CONSTRAINT `client_ibfk_5` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON UPDATE CASCADE,
CONSTRAINT `client_taxTypeSageFk` FOREIGN KEY (`taxTypeSageFk`) REFERENCES `sage`.`TiposIva` (`CodigoIva`) ON UPDATE CASCADE,
CONSTRAINT `client_transactionTypeSageFk` FOREIGN KEY (`transactionTypeSageFk`) REFERENCES `sage`.`TiposTransacciones` (`CodigoTransaccion`) ON UPDATE CASCADE,
+ CONSTRAINT `client_zoneGeo_FK` FOREIGN KEY (`geoFk`) REFERENCES `zoneGeo` (`id`) ON UPDATE CASCADE,
CONSTRAINT `typeFk` FOREIGN KEY (`typeFk`) REFERENCES `clientType` (`code`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -27969,11 +28023,14 @@ CREATE TABLE `clientObservation` (
`text` text NOT NULL,
`created` timestamp NOT NULL DEFAULT current_timestamp(),
`editorFk` int(10) unsigned DEFAULT NULL,
+ `observationTypeFk` tinyint(3) unsigned NOT NULL DEFAULT 4,
PRIMARY KEY (`id`),
KEY `Id_Trabajador` (`workerFk`),
KEY `Id_Cliente` (`clientFk`),
KEY `clientObservation_created_IDX` (`created`) USING BTREE,
KEY `clientObservation_fk_editor` (`editorFk`),
+ KEY `clientObservationTypeFk` (`observationTypeFk`),
+ CONSTRAINT `clientObservationTypeFk` FOREIGN KEY (`observationTypeFk`) REFERENCES `observationType` (`id`),
CONSTRAINT `clientObservation_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`),
CONSTRAINT `clientObservation_ibfk_1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `clientObservation_ibfk_2` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE
@@ -28995,13 +29052,11 @@ DROP TABLE IF EXISTS `creditInsurance`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `creditInsurance` (
`id` int(11) NOT NULL AUTO_INCREMENT,
- `creditClassification__` int(11) DEFAULT NULL COMMENT '@deprecated 2024-09-11',
`credit` int(11) DEFAULT NULL,
`creationDate` timestamp NOT NULL DEFAULT current_timestamp(),
`grade` tinyint(1) DEFAULT NULL,
`creditClassificationFk` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
- KEY `CreditInsurance_Fk1_idx` (`creditClassification__`),
KEY `creditInsurance_creditClassificationFk` (`creditClassificationFk`),
CONSTRAINT `creditInsurance_creditClassificationFk` FOREIGN KEY (`creditClassificationFk`) REFERENCES `creditClassification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Detalla los clientes que tienen seguro de credito';
@@ -29619,6 +29674,10 @@ CREATE TABLE `docuwareConfig` (
`id` int(10) unsigned NOT NULL,
`url` varchar(75) DEFAULT NULL,
`cookie` varchar(1000) DEFAULT NULL,
+ `username` varchar(100) DEFAULT NULL,
+ `password` varchar(100) DEFAULT NULL,
+ `token` text DEFAULT NULL,
+ `expired` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `docuwareConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
@@ -29656,6 +29715,7 @@ CREATE TABLE `dua` (
`customsValue` decimal(10,2) DEFAULT NULL,
`companyFk` int(10) unsigned NOT NULL DEFAULT 442,
`ASIEN` double DEFAULT NULL,
+ `comment` text DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `code_UNIQUE` (`code`),
KEY `fk_dua_gestdoc1_idx` (`gestdocFk`),
@@ -29718,7 +29778,7 @@ CREATE TABLE `duaInvoiceIn` (
`duaFk` int(11) NOT NULL,
`invoiceInFk` mediumint(8) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
- UNIQUE KEY `duaFk_UNIQUE` (`duaFk`,`invoiceInFk`),
+ UNIQUE KEY `duaInvoiceIn_unique` (`invoiceInFk`),
KEY `duaInvoiceIn_fk1_idx` (`duaFk`),
KEY `duaInvoiceIn_fk2_idx` (`invoiceInFk`),
CONSTRAINT `duaInvoiceIn_fk1` FOREIGN KEY (`duaFk`) REFERENCES `dua` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
@@ -29900,7 +29960,7 @@ CREATE TABLE `entry` (
`isExcludedFromAvailable` tinyint(1) NOT NULL DEFAULT 0,
`isConfirmed` tinyint(1) NOT NULL DEFAULT 0,
`isOrdered` tinyint(1) NOT NULL DEFAULT 0,
- `isRaid` tinyint(1) NOT NULL DEFAULT 0,
+ `isRaid_` tinyint(1) NOT NULL DEFAULT 0 COMMENT '@deprecated 2024-11-05',
`commission` float DEFAULT 0,
`created` timestamp NOT NULL DEFAULT current_timestamp(),
`evaNotes` varchar(45) DEFAULT NULL,
@@ -30067,17 +30127,17 @@ CREATE TABLE `entryType` (
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `entryVirtual`
+-- Table structure for table `entryVirtual__`
--
-DROP TABLE IF EXISTS `entryVirtual`;
+DROP TABLE IF EXISTS `entryVirtual__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `entryVirtual` (
+CREATE TABLE `entryVirtual__` (
`entryFk` int(11) NOT NULL,
PRIMARY KEY (`entryFk`),
- CONSTRAINT `entryVirtual_ibfk_1` FOREIGN KEY (`entryFk`) REFERENCES `entry` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='entradas que se van moviendo automaticamente al futuro';
+ CONSTRAINT `entryVirtual___ibfk_1` FOREIGN KEY (`entryFk`) REFERENCES `entry` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='@deprecated 2024-11-05';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -30544,6 +30604,7 @@ CREATE TABLE `expeditionState` (
`typeFk` int(11) NOT NULL,
`userFk` int(10) unsigned DEFAULT NULL,
`isScanned` tinyint(1) NOT NULL DEFAULT 0,
+ `scanOrder` int(11) DEFAULT NULL COMMENT 'Indica la posición al cargar la furgoneta',
PRIMARY KEY (`id`),
KEY `expeditionState_FK` (`expeditionFk`),
KEY `expeditionState_FK_1` (`typeFk`),
@@ -31985,6 +32046,21 @@ CREATE TABLE `itemBarcode` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `itemBaseTag`
+--
+
+DROP TABLE IF EXISTS `itemBaseTag`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `itemBaseTag` (
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `name` varchar(50) DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `name_UNIQUE` (`name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `itemBotanical`
--
@@ -32021,6 +32097,42 @@ SET character_set_client = utf8;
1 AS `ediBotanic` */;
SET character_set_client = @saved_cs_client;
+--
+-- Table structure for table `itemBreederTag`
+--
+
+DROP TABLE IF EXISTS `itemBreederTag`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `itemBreederTag` (
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `name` varchar(50) DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `name_UNIQUE` (`name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `itemCampaign`
+--
+
+DROP TABLE IF EXISTS `itemCampaign`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `itemCampaign` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `dated` date NOT NULL,
+ `itemFk` int(11) NOT NULL,
+ `quantity` decimal(10,2) NOT NULL,
+ `total` decimal(10,2) NOT NULL,
+ `campaign` varchar(100) NOT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `itemCampaign_UNIQUE` (`dated`,`itemFk`),
+ KEY `itemCampaign_item_FK` (`itemFk`),
+ CONSTRAINT `itemCampaign_item_FK` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tallos confirmados por día en los días de más producción de una campaña. La tabla está pensada para que sea una foto.';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `itemCategory`
--
@@ -32122,6 +32234,7 @@ CREATE TABLE `itemConfig` (
`defaultPriority` int(11) NOT NULL DEFAULT 2,
`warehouseFk` smallint(6) unsigned DEFAULT NULL,
`downloadMaxAttempts` tinyint(3) DEFAULT NULL COMMENT 'Intentos máximos para que se borre',
+ `defaultPackingTypeFk` varchar(1) DEFAULT 'H',
PRIMARY KEY (`id`),
KEY `itemConfig_FK` (`defaultTag`),
CONSTRAINT `itemConfig_FK` FOREIGN KEY (`defaultTag`) REFERENCES `tag` (`id`),
@@ -32205,6 +32318,21 @@ CREATE TABLE `itemFamily` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `itemFarmingTag`
+--
+
+DROP TABLE IF EXISTS `itemFarmingTag`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `itemFarmingTag` (
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `name` varchar(50) DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `name_UNIQUE` (`name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `itemImageQueue`
--
@@ -32256,6 +32384,21 @@ CREATE TABLE `itemLabel` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `itemLanguageTag`
+--
+
+DROP TABLE IF EXISTS `itemLanguageTag`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `itemLanguageTag` (
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `name` varchar(50) DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `name_UNIQUE` (`name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `itemLog`
--
@@ -32458,7 +32601,7 @@ DROP TABLE IF EXISTS `itemShelving`;
CREATE TABLE `itemShelving` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`itemFk` int(11) NOT NULL,
- `shelvingFk` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
+ `shelvingFk` int(11) NOT NULL,
`visible` int(11) NOT NULL DEFAULT 0,
`created` timestamp NOT NULL DEFAULT current_timestamp(),
`grouping` smallint(5) unsigned DEFAULT NULL,
@@ -32470,6 +32613,7 @@ CREATE TABLE `itemShelving` (
`editorFk` int(10) unsigned DEFAULT NULL,
`available` int(11) DEFAULT NULL,
`isSplit` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Este valor cambia al splitar un carro que se ha quedado en holanda',
+ `movingState` enum('selected','printed') DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `itemShelving_fk1_idx` (`itemFk`),
KEY `itemShelving_fk2_idx` (`shelvingFk`),
@@ -32478,8 +32622,8 @@ CREATE TABLE `itemShelving` (
KEY `itemShelvingBuy_FK` (`buyFk`),
CONSTRAINT `itemShelvingBuy_FK` FOREIGN KEY (`buyFk`) REFERENCES `buy` (`id`),
CONSTRAINT `itemShelving_fk1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `itemShelving_fk2` FOREIGN KEY (`shelvingFk`) REFERENCES `shelving` (`code`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `itemShelving_fk3` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE
+ CONSTRAINT `itemShelving_fk3` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `itemShelving_shelving_FK` FOREIGN KEY (`shelvingFk`) REFERENCES `shelving` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tabla utilizada para localizar los artículos dentro de los carros. Usado para la gestión del almacén en el altillo ';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -32538,13 +32682,13 @@ SET character_set_client = utf8;
SET character_set_client = @saved_cs_client;
--
--- Table structure for table `itemShelvingLog`
+-- Table structure for table `itemShelvingLog__`
--
-DROP TABLE IF EXISTS `itemShelvingLog`;
+DROP TABLE IF EXISTS `itemShelvingLog__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `itemShelvingLog` (
+CREATE TABLE `itemShelvingLog__` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`itemShelvingFk` int(10) unsigned DEFAULT NULL,
`workerFk` int(11) DEFAULT NULL,
@@ -32562,7 +32706,7 @@ CREATE TABLE `itemShelvingLog` (
KEY `itemShelving_Log_FK` (`itemShelvingFk`),
KEY `itemShelvingLog_itemFk_IDX` (`itemFk`) USING BTREE,
KEY `itemShelvingLog_shelvingFk_IDX` (`shelvingFk`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='@deprecated 2024-11-26';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -32737,6 +32881,36 @@ SET character_set_client = utf8;
1 AS `removed` */;
SET character_set_client = @saved_cs_client;
+--
+-- Table structure for table `itemStateTag`
+--
+
+DROP TABLE IF EXISTS `itemStateTag`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `itemStateTag` (
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `name` varchar(50) DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `name_UNIQUE` (`name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `itemStemTag`
+--
+
+DROP TABLE IF EXISTS `itemStemTag`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `itemStemTag` (
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `name` varchar(50) DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `name_UNIQUE` (`name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `itemTag`
--
@@ -32827,6 +33001,21 @@ SET character_set_client = utf8;
1 AS `taxClassFk` */;
SET character_set_client = @saved_cs_client;
+--
+-- Table structure for table `itemTextureTag`
+--
+
+DROP TABLE IF EXISTS `itemTextureTag`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `itemTextureTag` (
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `name` varchar(50) DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `name_UNIQUE` (`name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Temporary table structure for view `itemTicketOut`
--
@@ -32875,6 +33064,7 @@ CREATE TABLE `itemType` (
`maxRefs` int(10) unsigned DEFAULT NULL COMMENT 'Indica el número máximo de referencias',
`isMergeable` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Articulos que al mergear los tickets se fusionara la linea',
`isFragile` tinyint(1) NOT NULL DEFAULT 0,
+ `editorFk` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `Tipo_UNIQUE` (`name`,`categoryFk`),
UNIQUE KEY `itemType_UN` (`code`),
@@ -32882,9 +33072,13 @@ CREATE TABLE `itemType` (
KEY `reino_id` (`categoryFk`),
KEY `Tipos_fk3_idx` (`making`),
KEY `temperatureFk` (`temperatureFk`),
+ KEY `itemType_user_FK` (`editorFk`),
+ KEY `itemType_itemPackingType_FK` (`itemPackingTypeFk`),
CONSTRAINT `Tipos_fk3` FOREIGN KEY (`making`) REFERENCES `confectionType` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `Trabajador` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE,
CONSTRAINT `itemType_ibfk_1` FOREIGN KEY (`categoryFk`) REFERENCES `itemCategory` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `itemType_itemPackingType_FK` FOREIGN KEY (`itemPackingTypeFk`) REFERENCES `itemPackingType` (`code`) ON UPDATE CASCADE,
+ CONSTRAINT `itemType_user_FK` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`),
CONSTRAINT `temperatureFk` FOREIGN KEY (`temperatureFk`) REFERENCES `temperature` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Protege la tabla tipos de updates para los 4 parámetros de los compradores, en funcion del valor del campo CodigoRojo de tblContadores.';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -32917,6 +33111,35 @@ SET character_set_client = utf8;
1 AS `name` */;
SET character_set_client = @saved_cs_client;
+--
+-- Table structure for table `itemTypeLog`
+--
+
+DROP TABLE IF EXISTS `itemTypeLog`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `itemTypeLog` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `originFk` int(11) DEFAULT NULL,
+ `userFk` int(10) unsigned DEFAULT NULL,
+ `action` set('insert','update','delete') NOT NULL,
+ `creationDate` timestamp NULL DEFAULT current_timestamp(),
+ `description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
+ `changedModel` enum('ItemType') NOT NULL DEFAULT 'ItemType',
+ `oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)),
+ `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)),
+ `changedModelId` int(11) NOT NULL,
+ `changedModelValue` varchar(45) DEFAULT NULL,
+ `summaryId` varchar(30) DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ KEY `itemTypeLogUserFk_idx` (`userFk`),
+ KEY `itemTypeLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`),
+ KEY `itemTypeLog_originFk` (`originFk`,`creationDate`),
+ KEY `itemTypeLog_creationDate_IDX` (`creationDate` DESC) USING BTREE,
+ CONSTRAINT `itemTypeLogUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `itemTypeRestriction`
--
@@ -32957,6 +33180,36 @@ CREATE TABLE `itemTypeTag` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `itemVatRateTag`
+--
+
+DROP TABLE IF EXISTS `itemVatRateTag`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `itemVatRateTag` (
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `name` varchar(50) DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `name_UNIQUE` (`name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `itemWrappingTag`
+--
+
+DROP TABLE IF EXISTS `itemWrappingTag`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `itemWrappingTag` (
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `name` varchar(50) DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `name_UNIQUE` (`name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Temporary table structure for view `item_Free_Id`
--
@@ -33211,13 +33464,28 @@ CREATE TABLE `machineDms` (
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `machineWorker`
+-- Table structure for table `machineWorkerConfig__`
--
-DROP TABLE IF EXISTS `machineWorker`;
+DROP TABLE IF EXISTS `machineWorkerConfig__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `machineWorker` (
+CREATE TABLE `machineWorkerConfig__` (
+ `id` int(10) unsigned NOT NULL,
+ `maxHours` smallint(5) unsigned NOT NULL COMMENT 'Indicates how many hours a user record is reviewed to update or insert',
+ PRIMARY KEY (`id`),
+ CONSTRAINT `machineWorkerConfig_check` CHECK (`id` = 1)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='@deprecated 2024-10-23 not used';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `machineWorker__`
+--
+
+DROP TABLE IF EXISTS `machineWorker__`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `machineWorker__` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`workerFk` int(10) unsigned NOT NULL,
`machineFk` int(11) NOT NULL,
@@ -33228,22 +33496,7 @@ CREATE TABLE `machineWorker` (
KEY `machineWorker_FK` (`workerFk`),
CONSTRAINT `machineWorker_FK` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE,
CONSTRAINT `machineWorker_FK_1` FOREIGN KEY (`machineFk`) REFERENCES `machine` (`id`) ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Registros horarios de vehículos de almacén por empleado';
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Table structure for table `machineWorkerConfig`
---
-
-DROP TABLE IF EXISTS `machineWorkerConfig`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `machineWorkerConfig` (
- `id` int(10) unsigned NOT NULL,
- `maxHours` smallint(5) unsigned NOT NULL COMMENT 'Indicates how many hours a user record is reviewed to update or insert',
- PRIMARY KEY (`id`),
- CONSTRAINT `machineWorkerConfig_check` CHECK (`id` = 1)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='@deprecated 2024-10-23 not used';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -33809,6 +34062,7 @@ CREATE TABLE `operator` (
`volumeLimit` decimal(10,6) DEFAULT 0.500000 COMMENT 'Límite de volumen en una colección para la asignación de pedidos',
`sizeLimit` int(10) unsigned DEFAULT NULL COMMENT 'Límite de altura en una colección para la asignación de pedidos',
`isOnReservationMode` tinyint(1) NOT NULL DEFAULT 0,
+ `machineFk` int(11) DEFAULT NULL,
PRIMARY KEY (`workerFk`),
KEY `operator_FK` (`workerFk`),
KEY `operator_FK_1` (`trainFk`),
@@ -33816,11 +34070,13 @@ CREATE TABLE `operator` (
KEY `operator_FK_3` (`warehouseFk`),
KEY `operator_FK_5` (`labelerFk`),
KEY `operator_FK_4` (`sectorFk`),
+ KEY `operator_machine_FK` (`machineFk`),
CONSTRAINT `operator_FK` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `operator_FK_1` FOREIGN KEY (`trainFk`) REFERENCES `train` (`id`) ON UPDATE CASCADE,
CONSTRAINT `operator_FK_2` FOREIGN KEY (`itemPackingTypeFk`) REFERENCES `itemPackingType` (`code`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `operator_FK_3` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `operator_FK_4` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON UPDATE CASCADE
+ CONSTRAINT `operator_FK_4` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `operator_machine_FK` FOREIGN KEY (`machineFk`) REFERENCES `machine` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -34916,7 +35172,7 @@ CREATE TABLE `priceDelta` (
`warehouseFk` smallint(6) unsigned NOT NULL,
`created` timestamp NOT NULL DEFAULT current_timestamp(),
`editorFk` int(10) unsigned DEFAULT NULL,
- `zoneGeoFk` int(11) DEFAULT NULL,
+ `zoneGeoFk` int(11) DEFAULT NULL COMMENT 'Application area for the bonus component',
PRIMARY KEY (`id`),
KEY `priceDelta_itemType_FK` (`itemTypeFk`),
KEY `priceDelta_ink_FK` (`inkFk`),
@@ -35148,8 +35404,8 @@ CREATE TABLE `productionConfig` (
`sectorToCode` varchar(15) DEFAULT NULL COMMENT 'Sector destino que se revisa ítems más nuevos al parkinear',
`orderMode` enum('Location','Age') NOT NULL DEFAULT 'Location',
`editorFk` int(10) unsigned DEFAULT NULL,
- `hasNewLabelMrwMethod` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'column to activate the new mrw integration',
`minPlantTrayLength` int(11) NOT NULL DEFAULT 53 COMMENT 'minimum length for plant tray restriction. Avoid to make collection of the ticket with this kind of item',
+ `itemOrderReviewHours` int(11) DEFAULT 24 COMMENT 'Horas que no se tienen en cuenta para comprobar orden en el almacén, null para desactivar revisión',
PRIMARY KEY (`id`),
KEY `productionConfig_FK` (`shortageAddressFk`),
KEY `productionConfig_FK_1` (`clientSelfConsumptionFk`),
@@ -35974,7 +36230,7 @@ CREATE TABLE `route` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`workerFk` int(10) unsigned DEFAULT NULL,
`firstEditorFk` int(10) unsigned DEFAULT NULL,
- `created` date NOT NULL,
+ `created` timestamp NOT NULL DEFAULT current_timestamp(),
`vehicleFk` int(10) unsigned DEFAULT NULL,
`agencyModeFk` int(11) DEFAULT NULL,
`time` datetime DEFAULT NULL,
@@ -35993,6 +36249,7 @@ CREATE TABLE `route` (
`beachFk` int(11) DEFAULT NULL,
`commissionWorkCenterFk` int(11) DEFAULT NULL COMMENT 'WorkerCenter que gestiona la ruta',
`editorFk` int(10) unsigned DEFAULT NULL,
+ `dated` date NOT NULL,
PRIMARY KEY (`id`),
KEY `Id_Agencia` (`agencyModeFk`),
KEY `Fecha` (`created`),
@@ -36052,10 +36309,14 @@ CREATE TABLE `routeCommission` (
`cat4m3` decimal(5,2) DEFAULT NULL,
`cat5m3` decimal(5,2) DEFAULT NULL,
`freelanceYearlyM3` decimal(5,2) DEFAULT NULL,
+ `countryFk` mediumint(8) unsigned DEFAULT NULL,
+ `isKmTruckRate` tinyint(1) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `routeCommission_routeFk_idx` (`routeFk`),
KEY `routeCommission_workCenterFk_idx` (`workCenterFk`),
KEY `routeCommission_firstEditorFk` (`firstEditorFk`),
+ KEY `routeCommission_country_FK` (`countryFk`),
+ CONSTRAINT `routeCommission_country_FK` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE,
CONSTRAINT `routeCommission_routeFk` FOREIGN KEY (`routeFk`) REFERENCES `route` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `routeCommission_workCenterFk` FOREIGN KEY (`workCenterFk`) REFERENCES `workCenter` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
@@ -36302,7 +36563,7 @@ CREATE TABLE `sale` (
`ticketFk` int(11) NOT NULL,
`concept` varchar(50) DEFAULT NULL,
`quantity` decimal(10,2) NOT NULL DEFAULT 0.00,
- `originalQuantity` double(9,1) DEFAULT NULL COMMENT 'Se utiliza para notificar a través de rocket los cambios de quantity',
+ `originalQuantity` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT 'Se utiliza para notificar a través de rocket los cambios de quantity',
`price` decimal(10,2) NOT NULL DEFAULT 0.00,
`discount` tinyint(2) unsigned NOT NULL DEFAULT 0,
`priceFixed` decimal(10,2) NOT NULL DEFAULT 0.00,
@@ -36847,6 +37108,36 @@ CREATE TABLE `sample` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `saySimpleConfig`
+--
+
+DROP TABLE IF EXISTS `saySimpleConfig`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `saySimpleConfig` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `url` varchar(255) NOT NULL,
+ `defaultChannel` varchar(128) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `saySimpleCountry`
+--
+
+DROP TABLE IF EXISTS `saySimpleCountry`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `saySimpleCountry` (
+ `countryFk` mediumint(8) unsigned NOT NULL,
+ `channel` varchar(128) DEFAULT NULL,
+ PRIMARY KEY (`countryFk`),
+ CONSTRAINT `saySimpleCountry_FK` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `scanner`
--
@@ -36929,6 +37220,7 @@ CREATE TABLE `sector` (
`isReserve` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Sectores de reserva, como Albenfruit o Fuentes',
`backupPrinterFk` int(10) unsigned DEFAULT NULL,
`typeFk` int(10) unsigned NOT NULL DEFAULT 1,
+ `isOnReservationMode` tinyint(1) DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `code_UNIQUE` (`code`),
KEY `sector_fk1_idx` (`warehouseFk`),
@@ -37175,7 +37467,7 @@ CREATE TABLE `shelvingLog` (
`action` set('insert','update','delete','select') NOT NULL,
`creationDate` timestamp NULL DEFAULT current_timestamp(),
`description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
- `changedModel` enum('Shelving') NOT NULL DEFAULT 'Shelving',
+ `changedModel` enum('Shelving','ItemShelving') NOT NULL DEFAULT 'Shelving',
`oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)),
`newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)),
`changedModelId` int(11) NOT NULL,
@@ -37250,23 +37542,6 @@ CREATE TABLE `siiTypeInvoiceOut` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tipo de Factura Emitidas en el suministro de inmediato';
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Table structure for table `silexACL__`
---
-
-DROP TABLE IF EXISTS `silexACL__`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `silexACL__` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `module` varchar(50) NOT NULL,
- `method` varchar(50) NOT NULL,
- `role` varchar(20) NOT NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY `module_UNIQUE` (`module`,`method`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='@deprecated 2024-08-05 refs #7820';
-/*!40101 SET character_set_client = @saved_cs_client */;
-
--
-- Table structure for table `sinister`
--
@@ -37669,7 +37944,7 @@ CREATE TABLE `stockBuyed` (
PRIMARY KEY (`id`),
KEY `stockBuyed_user_idx` (`userFk`),
CONSTRAINT `stockBuyedUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='@deprecated 2024-10-01 rename and refactor to stockBought';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -37727,6 +38002,8 @@ CREATE TABLE `supplier` (
`isPayMethodChecked` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'Se ha validado la forma de pago',
`isVies` tinyint(4) NOT NULL DEFAULT 0,
`stamp` longblob DEFAULT NULL,
+ `companySize` enum('small','medium','big') DEFAULT NULL,
+ `geoFk` int(11) DEFAULT NULL,
`editorFk` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `cuenta` (`account`),
@@ -37742,6 +38019,7 @@ CREATE TABLE `supplier` (
KEY `suppplier_supplierActivityFk` (`supplierActivityFk`),
KEY `supplier_workerFk` (`workerFk`),
KEY `supplier_fk_editor` (`editorFk`),
+ KEY `supplier_zoneGeo_FK` (`geoFk`),
CONSTRAINT `Id_Pais` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE,
CONSTRAINT `pay_dem_id` FOREIGN KEY (`payDemFk`) REFERENCES `payDem` (`id`) ON UPDATE CASCADE,
CONSTRAINT `pay_met_id` FOREIGN KEY (`payMethodFk`) REFERENCES `payMethod` (`id`) ON UPDATE CASCADE,
@@ -37751,6 +38029,7 @@ CREATE TABLE `supplier` (
CONSTRAINT `supplier_transactionFk` FOREIGN KEY (`transactionTypeSageFk`) REFERENCES `sage`.`TiposTransacciones` (`CodigoTransaccion`) ON UPDATE CASCADE,
CONSTRAINT `supplier_withholdingFk` FOREIGN KEY (`withholdingSageFk`) REFERENCES `sage`.`TiposRetencion` (`CodigoRetencion`) ON UPDATE CASCADE,
CONSTRAINT `supplier_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `supplier_zoneGeo_FK` FOREIGN KEY (`geoFk`) REFERENCES `zoneGeo` (`id`) ON UPDATE CASCADE,
CONSTRAINT `suppplier_supplierActivityFk` FOREIGN KEY (`supplierActivityFk`) REFERENCES `supplierActivity` (`code`) ON UPDATE CASCADE,
CONSTRAINT `supplierAccountTooShort` CHECK (octet_length(`account`) = 10)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
@@ -38310,7 +38589,7 @@ CREATE TABLE `ticket` (
CONSTRAINT `ticket_ibfk_8` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`),
CONSTRAINT `ticket_ibfk_9` FOREIGN KEY (`routeFk`) REFERENCES `route` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `ticket_invoiceOut_FK` FOREIGN KEY (`refFk`) REFERENCES `invoiceOut` (`ref`) ON UPDATE CASCADE,
- CONSTRAINT `tickets_zone_fk` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON UPDATE CASCADE
+ CONSTRAINT `tickets_zone_fk` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -38374,10 +38653,12 @@ CREATE TABLE `ticketConfig` (
`packingDelay` int(11) DEFAULT 1 COMMENT 'Horas que marcará el retraso respecto hora de cierre web del ticket',
`daysForWarningClaim` int(11) NOT NULL DEFAULT 2 COMMENT 'dias restantes hasta que salte el aviso de reclamación fuera de plazo',
`defaultAttenderFk` int(10) unsigned DEFAULT NULL,
+ `closureDaysAgo` int(11) NOT NULL DEFAULT 2 COMMENT 'Number of days to look back for ticket closure',
PRIMARY KEY (`id`),
KEY `ticketConfig_worker_FK` (`defaultAttenderFk`),
CONSTRAINT `ticketConfig_worker_FK` FOREIGN KEY (`defaultAttenderFk`) REFERENCES `worker` (`id`),
- CONSTRAINT `ticketConfig_check` CHECK (`id` = 1)
+ CONSTRAINT `ticketConfig_check` CHECK (`id` = 1),
+ CONSTRAINT `closureDaysAgo_check` CHECK (`closureDaysAgo` > 0)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -39252,6 +39533,8 @@ CREATE TABLE `travel` (
`clonedFrom` int(11) DEFAULT NULL,
`editorFk` int(10) unsigned DEFAULT NULL,
`awbFk` smallint(11) unsigned DEFAULT NULL,
+ `daysInForward` int(10) unsigned DEFAULT NULL COMMENT 'Cuando es una redada, indica el número de días que se añadirán a la fecha de hoy para establecer el landed. NULL si no es una redada',
+ `isRaid` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Redada',
PRIMARY KEY (`id`),
UNIQUE KEY `shipment_1` (`shipped`,`landed`,`warehouseInFk`,`warehouseOutFk`,`agencyModeFk`,`ref`),
KEY `shipment` (`shipped`),
@@ -39414,6 +39697,8 @@ CREATE TABLE `travelThermograph` (
`result` varchar(45) DEFAULT NULL,
`dmsFk` int(11) DEFAULT NULL,
`temperatureFk` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT 'cool' COMMENT 'En la versión de Agosto de Salix se empezará a usar este campo y se actualizaran los anteriores mirando temperature.',
+ `maxTemperature` decimal(5,2) DEFAULT NULL,
+ `minTemperature` decimal(5,2) DEFAULT NULL,
`editorFk` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `thermograph_fk_idx` (`thermographFk`),
@@ -39422,7 +39707,7 @@ CREATE TABLE `travelThermograph` (
KEY `warehouse_id` (`warehouseFk`),
KEY `travelThermographTemperatureFgn` (`temperatureFk`),
KEY `travelThermograph_fk_editor` (`editorFk`),
- CONSTRAINT `travelThermographDmsFgn` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `travelThermographDmsFgn` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `travelThermographTemperatureFgn` FOREIGN KEY (`temperatureFk`) REFERENCES `temperature` (`code`),
CONSTRAINT `travelThermographThermographFgn` FOREIGN KEY (`thermographFk`) REFERENCES `thermograph` (`id`) ON UPDATE CASCADE,
CONSTRAINT `travelThermographTravelFgn` FOREIGN KEY (`travelFk`) REFERENCES `travel` (`id`),
@@ -39938,8 +40223,8 @@ CREATE TABLE `warehouse` (
`isLogiflora` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Este almacén acepta productos de Logiflora',
`isBionic` tinyint(1) NOT NULL DEFAULT 1,
`isHalt` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Almacén en el que descargan nuestros troncales',
- `isOrigin` tinyint(1) DEFAULT NULL,
- `isDestiny` tinyint(1) DEFAULT NULL,
+ `isOrigin` tinyint(1) NOT NULL DEFAULT 0,
+ `isDestiny` tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `name_UNIQUE` (`name`),
KEY `Id_Paises` (`countryFk`),
@@ -39991,6 +40276,27 @@ CREATE TABLE `workCenter` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `workCenterCommission`
+--
+
+DROP TABLE IF EXISTS `workCenterCommission`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `workCenterCommission` (
+ `workCenterFk` int(11) NOT NULL,
+ `deliveryManAdjustment` decimal(4,2) DEFAULT NULL COMMENT 'Número de trabajadores para equilibrar los repartidores de diferentes centros.\n Utilizado en repartidores de grafana',
+ `distributionM3Category1` decimal(5,2) DEFAULT NULL,
+ `distributionM3Category2` decimal(5,2) DEFAULT NULL,
+ `distributionCat4M3` decimal(5,2) DEFAULT NULL COMMENT 'Comisión por gestión de la distribución Cat IV',
+ `distributionCat5M3` decimal(5,2) DEFAULT NULL COMMENT 'Comisión por gestión de la distribución Cat V',
+ `deliveryM3Cat4` decimal(5,2) DEFAULT NULL,
+ `deliveryM3Cat5` decimal(5,2) DEFAULT NULL,
+ PRIMARY KEY (`workCenterFk`),
+ CONSTRAINT `workCenterCommission_workCenterFk` FOREIGN KEY (`workCenterFk`) REFERENCES `workCenter` (`id`) ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `workCenterHoliday`
--
@@ -40027,7 +40333,6 @@ CREATE TABLE `worker` (
`hasMachineryAuthorized` tinyint(2) DEFAULT 0,
`seniority` date DEFAULT NULL,
`isTodayRelative` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Para el F11. Calcula los problemas de visiblidad en funcion del dia actual',
- `isF11Allowed__` tinyint(1) NOT NULL DEFAULT 0 COMMENT '@deprecated 2024-09-22',
`maritalStatus` enum('S','M') NOT NULL,
`originCountryFk` mediumint(8) unsigned DEFAULT NULL COMMENT 'País de origen',
`educationLevelFk` smallint(6) DEFAULT NULL,
@@ -40260,8 +40565,13 @@ CREATE TABLE `workerDistributionCategory` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`workerFk` int(10) unsigned NOT NULL,
`category` int(11) NOT NULL,
+ `countryFk` mediumint(8) unsigned DEFAULT NULL,
+ `isKmTruckRate` tinyint(1) DEFAULT NULL,
+ `commissionSplitWorkers` int(10) unsigned NOT NULL DEFAULT 1 COMMENT 'Número de enrutadores entr los que se reparte la comsión',
PRIMARY KEY (`id`),
KEY `workerDistributionCategory_workerFk_idx` (`workerFk`),
+ KEY `workerDistributionCategory_country_FK` (`countryFk`),
+ CONSTRAINT `workerDistributionCategory_country_FK` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE,
CONSTRAINT `workerDistributionCategory_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -40574,9 +40884,7 @@ CREATE TABLE `workerRelatives` (
`updated` timestamp NULL DEFAULT current_timestamp(),
PRIMARY KEY (`id`),
KEY `workerRelatives_disabilityGradeFk` (`disabilityGradeFk`),
- KEY `workerRelatives_workerFk` (`workerFk`),
- CONSTRAINT `workerRelatives_disabilityGradeFk` FOREIGN KEY (`disabilityGradeFk`) REFERENCES `disabilityGrade` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `workerRelatives_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `workerIrpf` (`workerFk`) ON DELETE CASCADE ON UPDATE CASCADE
+ KEY `workerRelatives_workerFk` (`workerFk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Modelo 145 IRPF apartado 2 y 3';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -40796,13 +41104,13 @@ CREATE TABLE `workerTimeControlMail` (
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `workerTimeControlParams`
+-- Table structure for table `workerTimeControlParams__`
--
-DROP TABLE IF EXISTS `workerTimeControlParams`;
+DROP TABLE IF EXISTS `workerTimeControlParams__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `workerTimeControlParams` (
+CREATE TABLE `workerTimeControlParams__` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`dayBreak` int(11) NOT NULL,
`weekBreak` int(11) NOT NULL,
@@ -40818,7 +41126,7 @@ CREATE TABLE `workerTimeControlParams` (
`mailErrorFolder` varchar(45) NOT NULL,
`mailUser` varchar(45) NOT NULL,
PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin COMMENT='All values in seconds';
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin COMMENT='@deprecated 2024-11-19';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -41174,7 +41482,7 @@ CREATE TABLE `zoneIncluded` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`zoneFk` int(11) NOT NULL,
`geoFk` int(11) NOT NULL,
- `isIncluded` tinyint(1) DEFAULT NULL,
+ `isIncluded` tinyint(1) NOT NULL DEFAULT 0,
`editorFk` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `unique_zone_geo` (`zoneFk`,`geoFk`),
@@ -41428,6 +41736,24 @@ DELIMITER ;;
/*!50003 SET character_set_client = @saved_cs_client */ ;;
/*!50003 SET character_set_results = @saved_cs_results */ ;;
/*!50003 SET collation_connection = @saved_col_connection */ ;;
+/*!50106 DROP EVENT IF EXISTS `itemCampaig_add` */;;
+DELIMITER ;;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;;
+/*!50003 SET character_set_client = utf8mb4 */ ;;
+/*!50003 SET character_set_results = utf8mb4 */ ;;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;;
+/*!50003 SET @saved_time_zone = @@time_zone */ ;;
+/*!50003 SET time_zone = 'SYSTEM' */ ;;
+/*!50106 CREATE*/ /*!50117 DEFINER=`vn`@`localhost`*/ /*!50106 EVENT `itemCampaig_add` ON SCHEDULE EVERY 1 DAY STARTS '2024-10-18 03:00:00' ON COMPLETION PRESERVE ENABLE DO CALL itemCampaign_add() */ ;;
+/*!50003 SET time_zone = @saved_time_zone */ ;;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;;
+/*!50003 SET character_set_client = @saved_cs_client */ ;;
+/*!50003 SET character_set_results = @saved_cs_results */ ;;
+/*!50003 SET collation_connection = @saved_col_connection */ ;;
/*!50106 DROP EVENT IF EXISTS `itemImageQueue_check` */;;
DELIMITER ;;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;;
@@ -41579,24 +41905,6 @@ END */ ;;
/*!50003 SET character_set_client = @saved_cs_client */ ;;
/*!50003 SET character_set_results = @saved_cs_results */ ;;
/*!50003 SET collation_connection = @saved_col_connection */ ;;
-/*!50106 DROP EVENT IF EXISTS `raidUpdate` */;;
-DELIMITER ;;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;;
-/*!50003 SET character_set_client = utf8mb4 */ ;;
-/*!50003 SET character_set_results = utf8mb4 */ ;;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;;
-/*!50003 SET @saved_time_zone = @@time_zone */ ;;
-/*!50003 SET time_zone = 'SYSTEM' */ ;;
-/*!50106 CREATE*/ /*!50117 DEFINER=`vn`@`localhost`*/ /*!50106 EVENT `raidUpdate` ON SCHEDULE EVERY 1 DAY STARTS '2017-12-29 00:05:00' ON COMPLETION PRESERVE ENABLE DO CALL raidUpdate */ ;;
-/*!50003 SET time_zone = @saved_time_zone */ ;;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;;
-/*!50003 SET character_set_client = @saved_cs_client */ ;;
-/*!50003 SET character_set_results = @saved_cs_results */ ;;
-/*!50003 SET collation_connection = @saved_col_connection */ ;;
/*!50106 DROP EVENT IF EXISTS `route_doRecalc` */;;
DELIMITER ;;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;;
@@ -41799,9 +42107,12 @@ BEGIN
SELECT p.geoFk INTO vGeoFk
FROM address a
JOIN town t ON t.provinceFk = a.provinceFk
- JOIN postCode p ON p.townFk = t.id AND p.`code` = a.postalCode
+ JOIN postCode p ON p.townFk = t.id
+ AND (p.code = a.postalCode OR a.postalCode IS NULL)
+ JOIN zoneGeo zg ON zg.id = p.geoFk
WHERE a.id = vSelf
- ORDER BY (a.city SOUNDS LIKE t.`name`) DESC
+ ORDER BY (a.city SOUNDS LIKE t.name) DESC,
+ (p.code = a.postalCode) DESC
LIMIT 1;
RETURN vGeoFk;
@@ -41876,6 +42187,91 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP FUNCTION IF EXISTS `buy_getLastWithoutInventory` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`vn`@`localhost` FUNCTION `buy_getLastWithoutInventory`(vItemFk INT,
+ vWarehouseFk INT
+) RETURNS int(11)
+ DETERMINISTIC
+BEGIN
+/**
+ * Retorna la última compra que no sea inventario.
+ *
+ * @param vItemFk Id del artículo
+ * @param vWarehouseFk Id del almacén
+ * @return Id de compra
+ */
+ DECLARE vBuyFk INT;
+
+ SELECT b.id INTO vBuyFk
+ FROM buy b
+ JOIN entry e ON e.id = b.entryFk
+ JOIN travel t ON t.id = e.travelFk
+ WHERE e.id <> (SELECT defaultEntry FROM entryConfig)
+ AND e.supplierFk <> (SELECT supplierFk FROM inventoryConfig)
+ AND e.typeFk <> 'inventory'
+ AND b.itemFk = vItemFk
+ AND (t.warehouseInFk = vWarehouseFk OR t.warehouseInFk IS NULL)
+ ORDER BY ABS(DATEDIFF(util.VN_CURDATE(), t.landed)), e.created DESC
+ LIMIT 1;
+
+ RETURN vBuyFk;
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP FUNCTION IF EXISTS `buy_getUltimate` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`vn`@`localhost` FUNCTION `buy_getUltimate`(vItemFk INT,
+ vWarehouseFk INT,
+ vDated DATE
+) RETURNS int(11)
+ DETERMINISTIC
+BEGIN
+/**
+ * Calcula las últimas compras realizadas hasta una fecha.
+ *
+ * @param vItemFk Id del artículo
+ * @param vWarehouseFk Id del almacén
+ * @param vDated Compras hasta fecha
+ * @return Id de compra
+ */
+ DECLARE vBuyFk INT;
+
+ CALL buy_getUltimate(vItemFk, vWarehouseFk, vDated);
+
+ SELECT buyFk INTO vBuyFk
+ FROM tmp.buyUltimate;
+
+ DROP TEMPORARY TABLE IF EXISTS
+ tmp.buyUltimate,
+ tmp.buyUltimateFromInterval;
+
+ RETURN vBuyFk;
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP FUNCTION IF EXISTS `buy_getUnitVolume` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -42251,6 +42647,45 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP FUNCTION IF EXISTS `client_getGeo` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`vn`@`localhost` FUNCTION `client_getGeo`(vSelf INT) RETURNS int(11)
+ DETERMINISTIC
+BEGIN
+/**
+ * Returns the geo for the passed client.
+ *
+ * @param vSelf The address id
+ * @return The geo id
+ */
+ DECLARE vGeoFk INT;
+
+ SELECT p.geoFk INTO vGeoFk
+ FROM client c
+ JOIN town t ON t.provinceFk = c.provinceFk
+ JOIN postCode p ON p.townFk = t.id
+ AND (p.code = c.postcode OR c.postcode IS NULL)
+ JOIN zoneGeo zg ON zg.id = p.geoFk
+ WHERE c.id = vSelf
+ ORDER BY (c.city SOUNDS LIKE t.name) DESC,
+ (p.code = c.postcode) DESC
+ LIMIT 1;
+
+ RETURN vGeoFk;
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP FUNCTION IF EXISTS `client_getSalesPerson` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -42800,58 +43235,51 @@ DELIMITER ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
CREATE DEFINER=`vn`@`localhost` FUNCTION `entry_getCommission`(vTravelFk INT,
- vCurrencyFk INT,
- vSupplierFk INT
+ vCurrencyFk INT,
+ vSupplierFk INT
) RETURNS int(11)
READS SQL DATA
BEGIN
- DECLARE vCommission INT;
- DECLARE vCurrentCommission INT;
- DECLARE vIsCurrencyUsd INT;
- DECLARE vLastEntryFk INT;
-
- SELECT count(*) INTO vIsCurrencyUsd
- FROM currency c
- WHERE c.code = 'USD' AND id = vCurrencyFk;
-
- IF NOT vIsCurrencyUsd THEN
-
- SELECT e.id INTO vLastEntryFk
- FROM vn.entry e
- JOIN vn.travel tr ON tr.id = e.travelFk
- WHERE e.supplierFk = vSupplierFk
- ORDER BY tr.landed DESC
- LIMIT 1;
-
- IF vLastEntryFk THEN
-
- SELECT commission INTO vCurrentCommission
- FROM vn.entry
- WHERE id = vLastEntryFk;
-
- ELSE
-
- SELECT commission INTO vCurrentCommission
- FROM supplier s
- WHERE s.id = vSupplierFk;
-
- END IF;
-
- RETURN vCurrentCommission;
-
- ELSE
+ DECLARE vCommission INT;
+ DECLARE vCurrentCommission INT;
+ DECLARE vIsNotEUR INT;
+ DECLARE vLastEntryFk INT;
+ SELECT count(*) INTO vIsNotEUR
+ FROM currency c
+ WHERE c.code <> 'EUR' AND id = vCurrencyFk;
+
+ IF vIsNotEUR THEN
SELECT ROUND(-100 * (1 - (1 / r.value))) INTO vCommission
FROM travel t
LEFT JOIN referenceCurrent r ON r.currencyFk = vCurrencyFk AND r.`dated` <= t.shipped
WHERE t.id = vTravelFk
ORDER BY r.`dated` DESC
LIMIT 1;
-
+
RETURN IFNULL(vCommission, 0);
-
- END IF;
-
+ ELSE
+ SELECT e.id INTO vLastEntryFk
+ FROM `entry` e
+ JOIN travel tr ON tr.id = e.travelFk
+ WHERE e.supplierFk = vSupplierFk
+ ORDER BY tr.landed DESC
+ LIMIT 1;
+
+ IF vLastEntryFk THEN
+ SELECT commission INTO vCurrentCommission
+ FROM `entry`
+ WHERE id = vLastEntryFk;
+
+ ELSE
+ SELECT commission INTO vCurrentCommission
+ FROM supplier s
+ WHERE s.id = vSupplierFk;
+
+ END IF;
+
+ RETURN vCurrentCommission;
+ END IF;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -43481,7 +43909,7 @@ BEGIN
SELECT count(*) INTO vItemCount
FROM vn.sale s
JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk
- JOIN vn.shelving sh ON sh.code = ish.shelvingFk
+ JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
WHERE s.ticketFk = vTicketFk
AND p.sectorFk = vSectorFk;
@@ -43931,7 +44359,7 @@ BEGIN
SELECT count(*) INTO vItemCount
FROM vn.sale s
JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk
- JOIN vn.shelving sh ON sh.code = ish.shelvingFk
+ JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
WHERE s.ticketFk = vTicketFk
AND p.sectorFk = vSectorFk;
@@ -44413,7 +44841,7 @@ BEGIN
JOIN cache.zoneAgencyFriendship zf ON zf.agencyModeFk = r.agencyModeFk
WHERE friendship >= vSignificativeFriendship
AND zf.zoneFk = vZoneFk
- AND r.created = vLanded
+ AND r.dated = vLanded
ORDER BY friendship;
-- Se eliminan aquellas que superan el volumen máximo
@@ -44479,7 +44907,7 @@ BEGIN
JOIN cache.zoneAgencyFriendship zf ON zf.agencyModeFk = r.agencyModeFk
WHERE friendship >= vSignificativeFriendship
AND zf.zoneFk = vZoneFk
- AND r.created = vLanded
+ AND r.dated = vLanded
ORDER BY friendship;
-- Se eliminan aquellas que superan el volumen máximo
@@ -44629,6 +45057,47 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP FUNCTION IF EXISTS `supplier_getGeo` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`vn`@`localhost` FUNCTION `supplier_getGeo`(vSelf INT) RETURNS int(11)
+ DETERMINISTIC
+BEGIN
+/**
+ * Returns the geo for the passed supplier.
+ *
+ * @param vSelf The address id
+ * @return The geo id
+ */
+ DECLARE vGeoFk INT;
+
+ SELECT p.geoFk INTO vGeoFk
+ FROM supplier s
+ JOIN town t ON t.provinceFk = s.provinceFk
+ JOIN postCode p ON p.townFk = t.id
+ AND (p.code = s.postCode OR s.postCode IS NULL)
+ LEFT JOIN supplierAddress sad ON sad.supplierFk = s.id
+ JOIN zoneGeo zg ON zg.id = p.geoFk
+ WHERE s.id = vSelf
+ ORDER BY (s.city SOUNDS LIKE t.name) DESC,
+ (p.code = s.postCode) DESC,
+ (p.code = sad.postalCode) DESC
+ LIMIT 1;
+
+ RETURN vGeoFk;
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP FUNCTION IF EXISTS `testCIF` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -45516,82 +45985,6 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP FUNCTION IF EXISTS `timeWorkerControl_getDirection` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`vn`@`localhost` FUNCTION `timeWorkerControl_getDirection`(vUserFk INT, vTimed DATETIME) RETURNS varchar(6) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci
- READS SQL DATA
-BEGIN
-/**
- * Verifica la dirección de la fichada
- * @param vUserFk Identificador del trabajador
- * @param vTimed Hora de la fichada
- * @return Retorna sentido de la fichada 'in, out, middle'
- */
-
- DECLARE vPrevious DATETIME ;
- DECLARE vNext DATETIME ;
- DECLARE vPreviousDirection VARCHAR(3) ;
- DECLARE vNextDirection VARCHAR(3) ;
- DECLARE vDayStayMax INT;
- DECLARE vTimedSeconds INT;
- DECLARE vLastTimeIn INT;
-
- SELECT UNIX_TIMESTAMP(vTimed) INTO vTimedSeconds;
-
- SELECT dayStayMax INTO vDayStayMax
- FROM vn.workerTimeControlParams;
-
- SELECT timed, direction INTO vNext,vNextDirection
- FROM vn.workerTimeControl
- WHERE userFk = vUserFk
- AND direction IN ('in','out')
- AND timed > vTimed
- ORDER BY timed ASC
- LIMIT 1;
-
- SELECT timed, direction INTO vPrevious, vPreviousDirection
- FROM vn.workerTimeControl
- WHERE userFk = vUserFk
- AND direction IN ('in','out')
- AND timed < vTimed
- ORDER BY timed DESC
- LIMIT 1;
-
- IF (vTimedSeconds - UNIX_TIMESTAMP(vPrevious) + UNIX_TIMESTAMP(vNext) - vTimedSeconds)<= vDayStayMax AND vPreviousDirection = 'in' AND vNextDirection = 'out' THEN
- RETURN 'middle';
- END IF;
-
-
- IF (vTimedSeconds> UNIX_TIMESTAMP(vPrevious)) THEN
- IF vPreviousDirection = 'in' THEN
- RETURN 'out';
- ELSE
- SELECT UNIX_TIMESTAMP(MAX(timed)) INTO vLastTimeIn
- FROM vn.workerTimeControl
- WHERE userFk = vUserFk
- AND direction ='in'
- AND timed < vPrevious;
- IF vTimedSeconds - vLastTimeIn <= vDayStayMax THEN
- RETURN 'out';
- END IF;
- END IF;
- END IF;
-
- RETURN 'in';
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP FUNCTION IF EXISTS `time_getSalesYear` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -45738,40 +46131,6 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP FUNCTION IF EXISTS `workerMachinery_isRegistered` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`vn`@`localhost` FUNCTION `workerMachinery_isRegistered`(vWorkerFk VARCHAR(10)) RETURNS tinyint(1)
- READS SQL DATA
-BEGIN
-/**
- * Comprueba si existen registros en las últimas horas (maxHours de machineWorkerConfig) del trabajador vWorkerFk y si tiene a nulo la hora outTimed (indica la hora que deja el vehículo)
- *
- * @param vWorkerFk id del trabajador
- * @return Devuelve TRUE/FALSE en caso de que haya o no registros
- */
- IF (SELECT COUNT(*)
- FROM machineWorker m
- WHERE m.workerFk = vWorkerFk
- AND m.inTimed >= TIMESTAMPADD(HOUR , -(SELECT maxHours from machineWorkerConfig), util.VN_NOW()) AND ISNULL(m.outTimed))
- THEN
- RETURN TRUE;
- ELSE
- RETURN FALSE;
- END IF;
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP FUNCTION IF EXISTS `workerNigthlyHours_calculate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -46062,7 +46421,7 @@ BEGIN
AND vWarehouseFk IN (tr.warehouseInFk, 0)
AND b.itemFk = vItemFk
AND NOT e.isExcludedFromAvailable
- AND NOT e.isRaid
+ AND NOT tr.isRaid
UNION ALL
SELECT tr.shipped,
NULL,
@@ -46081,7 +46440,7 @@ BEGIN
AND s.id <> (SELECT supplierFk FROM inventoryConfig)
AND b.itemFk = vItemFk
AND NOT e.isExcludedFromAvailable
- AND NOT e.isRaid
+ AND NOT tr.isRaid
UNION ALL
SELECT t.shipped,
NULL,
@@ -46104,7 +46463,7 @@ BEGIN
FROM tHistoricalPast
WHERE `date` < vDate;
- SELECT p1.*, NULL v_virtual
+ SELECT p1.*, NULL v_virtual
FROM (
SELECT vDate `date`,
vCalculatedInventory input,
@@ -46119,7 +46478,7 @@ BEGIN
FROM tHistoricalPast
WHERE `date` >= vDate
) p1;
-
+
DROP TEMPORARY TABLE tHistoricalPast;
END ;;
DELIMITER ;
@@ -46673,7 +47032,7 @@ CREATE DEFINER=`vn`@`localhost` PROCEDURE `available_traslate`(
vWarehouseShipment INT)
proc: BEGIN
/**
- * Calcular la disponibilidad dependiendo del almacen
+ * Calcular la disponibilidad dependiendo del almacen
* de origen y destino según la fecha.
*
* @param vWarehouseLanding Almacén de llegada
@@ -46710,10 +47069,10 @@ proc: BEGIN
WHERE t.landed BETWEEN vDatedInventory AND vDatedFrom
AND t.warehouseInFk = vWarehouseLanding
AND NOT e.isExcludedFromAvailable
- AND NOT e.isRaid
+ AND NOT t.isRaid
GROUP BY c.itemFk;
- -- Tabla con el ultimo dia de last_buy para cada producto
+ -- Tabla con el ultimo dia de last_buy para cada producto
-- que hace un replace de la anterior.
CALL buy_getUltimate (NULL, vWarehouseShipment, util.VN_CURDATE());
@@ -46725,7 +47084,7 @@ proc: BEGIN
JOIN travel tr ON tr.id = e.travelFk
LEFT JOIN tItemRange i ON t.itemFk = i.itemFk
WHERE t.warehouseFk = vWarehouseShipment
- AND NOT e.isRaid
+ AND NOT tr.isRaid
ON DUPLICATE KEY UPDATE tItemRange.dated = GREATEST(tItemRange.dated,
tr.landed);
@@ -46762,7 +47121,7 @@ proc: BEGIN
JOIN tItemRangeLive ir ON ir.itemFk = b.itemFk
WHERE NOT e.isExcludedFromAvailable
AND b.quantity <> 0
- AND NOT e.isRaid
+ AND NOT t.isRaid
AND t.warehouseInFk = vWarehouseLanding
AND t.landed >= vDatedFrom
AND (ir.dated IS NULL OR t.landed <= ir.dated)
@@ -47756,7 +48115,7 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`vn`@`localhost` PROCEDURE `buy_getUltimate`(
vItemFk INT,
- vWarehouseFk SMALLINT,
+ vWarehouseFk INT,
vDated DATE
)
BEGIN
@@ -48028,39 +48387,6 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `buy_getVolumeByAgency` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`vn`@`localhost` PROCEDURE `buy_getVolumeByAgency`(vDated DATE, vAgencyFk INT)
-BEGIN
-
- DROP TEMPORARY TABLE IF EXISTS tmp.buy;
- CREATE TEMPORARY TABLE tmp.buy (buyFk INT NOT NULL, PRIMARY KEY (buyFk)) ENGINE = MEMORY;
-
- INSERT INTO tmp.buy
- SELECT b.id
- FROM buy b
- JOIN entry e ON e.id = b.entryFk
- JOIN travel t ON t.id = e.travelFk
- WHERE t.landed = vDated
- AND t.agencyModeFk IN (0, vAgencyFk);
-
- CALL buy_getVolume();
- DROP TEMPORARY TABLE tmp.buy;
-
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `buy_getVolumeByEntry` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -49309,6 +49635,13 @@ BEGIN
DELETE FROM messageInbox WHERE sendDate < v2Months;
DELETE FROM messageInbox WHERE sendDate < v2Months;
DELETE FROM workerTimeControl WHERE timed < v4Years;
+ DELETE FROM itemShelvingSale
+ WHERE itemShelvingFk IN (
+ SELECT id
+ FROM itemShelving
+ WHERE created < util.VN_CURDATE()
+ AND visible = 0
+ );
DELETE FROM itemShelving WHERE created < util.VN_CURDATE() AND visible = 0;
DELETE FROM ticketDown WHERE created < util.yesterday();
DELETE IGNORE FROM expedition WHERE created < v26Months;
@@ -49335,17 +49668,11 @@ BEGIN
AND ts.id IS NULL;
DELETE FROM claim WHERE ticketCreated < v4Years;
-- Robert ubicacion anterior de travelLog comentario para debug
- DELETE FROM zoneEvent WHERE `type` = 'day' AND dated < v3Months;
- DELETE bm
- FROM buyMark bm
- JOIN buy b ON b.id = bm.id
- JOIN entry e ON e.id = b.entryFk
- JOIN travel t ON t.id = e.travelFk
- WHERE t.landed <= v2Months;
+ DELETE FROM zoneEvent WHERE dated < v2Months OR ended < v2Months;
DELETE b FROM buy b
JOIN entryConfig e ON e.defaultEntry = b.entryFk
WHERE b.created < v2Months;
- DELETE FROM stockBuyed WHERE creationDate < v2Months;
+ DELETE FROM stockBought WHERE dated < v2Months;
DELETE FROM printQueue WHERE statusCode = 'printed' AND created < v2Months;
-- Equipos duplicados
DELETE w.*
@@ -49552,7 +49879,7 @@ BEGIN
JOIN agencyMode am ON am.id = tr.agencyModeFk
WHERE NOT b.quantity
AND am.code = 'logiflora'
- AND e.isRaid;
+ AND tr.daysInForward;
START TRANSACTION;
@@ -50287,22 +50614,19 @@ BEGIN
DECLARE vIsTaxDataChecked TINYINT(1);
DECLARE vHasCoreVnl BOOLEAN;
DECLARE vMandateTypeFk INT;
- DECLARE vHasDailyInvoice BOOLEAN;
SELECT cc.defaultPayMethodFk,
cc.defaultDueDay,
cc.defaultCredit,
cc.defaultIsTaxDataChecked,
cc.defaultHasCoreVnl,
- cc.defaultMandateTypeFk,
- c.hasDailyInvoice
+ cc.defaultMandateTypeFk
INTO vPayMethodFk,
vDueDay,
vDefaultCredit,
vIsTaxDataChecked,
vHasCoreVnl,
- vMandateTypeFk,
- vHasDailyInvoice
+ vMandateTypeFk
FROM clientConfig cc
LEFT JOIN province p ON p.id = vProvinceFk
LEFT JOIN country c ON c.id = p.countryFk;
@@ -50323,8 +50647,7 @@ BEGIN
credit = vDefaultCredit,
isTaxDataChecked = vIsTaxDataChecked,
hasCoreVnl = vHasCoreVnl,
- isEqualizated = FALSE,
- hasDailyInvoice = vHasDailyInvoice
+ isEqualizated = FALSE
ON duplicate KEY UPDATE
payMethodFk = vPayMethodFk,
dueDay = vDueDay,
@@ -50869,7 +51192,7 @@ BEGIN
AND s.semaphore = 1
GROUP BY st.saleFk) st ON st.saleFk = ts.saleFk
JOIN itemShelving ish ON ish.itemFk = ts.itemFk
- JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector sc ON sc.id = p.sectorFk
JOIN sectorType st ON st.id = sc.typeFk
@@ -51057,23 +51380,23 @@ BEGIN
WHERE t.id = vTicketFk;
CALL cache.available_refresh(
- vCacheAvailableFk,
+ vCacheAvailableFk,
FALSE,
- vWarehouseFk,
+ vWarehouseFk,
util.VN_CURDATE());
SELECT available INTO vAvailable
FROM cache.available
- WHERE calc_id = vCacheAvailableFk
+ WHERE calc_id = vCacheAvailableFk
AND item_id = vItemFk;
-
+
IF vAvailable < vQuantity THEN
SET vHasThrow = TRUE;
ELSE
SELECT `name`,
- CONCAT(getUser(), ' ', DATE_FORMAT(util.VN_NOW(), '%H:%i'), ' ', name)
+ CONCAT(getUser(), ' ', DATE_FORMAT(util.VN_NOW(), '%H:%i'), ' ', name)
INTO vItemName, vConcept
- FROM item
+ FROM item
WHERE id = vItemFk;
START TRANSACTION;
@@ -51089,7 +51412,7 @@ BEGIN
CALL sale_calculateComponent(vSaleFk, NULL);
CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk);
-
+
IF NOT EXISTS (SELECT TRUE FROM itemShelvingSale WHERE saleFk = vSaleFk LIMIT 1) THEN
SET vHasThrow = TRUE;
END IF;
@@ -51098,13 +51421,13 @@ BEGIN
IF vHasThrow THEN
CALL util.throw("There is no available for the selected item");
END IF;
-
+
IF vSaleGroupFk THEN
INSERT INTO saleGroupDetail
SET saleFk = vSaleFk,
saleGroupFk = vSaleGroupFk;
END IF;
-
+
COMMIT;
END ;;
DELIMITER ;
@@ -51126,7 +51449,7 @@ CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_assign`(
vUserFk INT,
OUT vCollectionFk INT
)
-BEGIN
+BEGIN
/**
* Comprueba si existen colecciones libres que se ajustan
* al perfil del usuario y le asigna la más antigua.
@@ -51168,6 +51491,12 @@ BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
-- Si hay colecciones sin terminar, sale del proceso
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ ROLLBACK;
+ RESIGNAL;
+ END;
+
CALL collection_get(vUserFk);
SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, pc.maxNotAssignedCollectionLifeTime
@@ -51241,9 +51570,19 @@ BEGIN
IF vCollectionFk IS NULL THEN
CALL collection_new(vUserFk, vCollectionFk);
- UPDATE `collection`
- SET workerFk = vUserFk
- WHERE id = vCollectionFk;
+ START TRANSACTION;
+
+ SELECT workerFk INTO vCollectionWorker
+ FROM `collection`
+ WHERE id = vCollectionFk FOR UPDATE;
+
+ IF vCollectionWorker IS NULL THEN
+ UPDATE `collection`
+ SET workerFk = vUserFk
+ WHERE id = vCollectionFk;
+ END IF;
+
+ COMMIT;
END IF;
END ;;
DELIMITER ;
@@ -51318,101 +51657,140 @@ CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_getAssigned`(
)
BEGIN
/**
- * Comprueba si existen colecciones libres que se ajustan al perfil del usuario
- * y le asigna la más antigua.
- * Añade un registro al semillero de colecciones y hace la reserva para la colección
- *
+ * Comprueba si existen colecciones libres que se ajustan
+ * al perfil del usuario y le asigna la más antigua.
+ * Añade un registro al semillero de colecciones.
+ *
* @param vUserFk Id de usuario
* @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 vDone BOOL DEFAULT FALSE;
+ DECLARE vCollectionWorker INT;
+ DECLARE vMaxNotAssignedCollectionLifeTime TIME;
+
+ DECLARE vCollections CURSOR FOR
+ WITH collections AS (
+ SELECT tc.collectionFk,
+ SUM(sv.volume) volume,
+ c.saleTotalCount,
+ c.itemPackingTypeFk,
+ c.trainFk,
+ c.warehouseFk,
+ c.wagons
+ FROM vn.ticketCollection tc
+ JOIN vn.collection c ON c.id = tc.collectionFk
+ JOIN vn.saleVolume sv ON sv.ticketFk = tc.ticketFk
+ WHERE c.workerFk IS NULL
+ AND sv.shipped >= util.VN_CURDATE()
+ GROUP BY tc.collectionFk
+ ) SELECT c.collectionFk
+ FROM collections c
+ JOIN vn.operator o
+ WHERE o.workerFk = vUserFk
+ AND (c.saleTotalCount <= o.linesLimit OR o.linesLimit IS NULL)
+ AND (c.itemPackingTypeFk = o.itemPackingTypeFk OR o.itemPackingTypeFk IS NULL)
+ AND o.numberOfWagons = c.wagons
+ AND o.trainFk = c.trainFk
+ AND o.warehouseFk = c.warehouseFk;
+
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
+ -- Si hay colecciones sin terminar, sale del proceso
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
- IF vLockName IS NOT NULL THEN
- DO RELEASE_LOCK(vLockName);
- END IF;
-
+ ROLLBACK;
RESIGNAL;
END;
- -- Si hay colecciones sin terminar, sale del proceso
CALL collection_get(vUserFk);
- SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0,
- pc.collection_assign_lockname
- INTO vHasTooMuchCollections,
- vLockName
- FROM tmp.collection c
- JOIN productionConfig pc;
+ SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, pc.maxNotAssignedCollectionLifeTime
+ INTO vHasTooMuchCollections, vMaxNotAssignedCollectionLifeTime
+ FROM productionConfig pc
+ LEFT JOIN tmp.collection ON TRUE;
DROP TEMPORARY TABLE tmp.collection;
IF vHasTooMuchCollections THEN
- CALL util.throw('There are pending collections');
- 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));
+ CALL util.throw('Hay colecciones pendientes');
END IF;
-- Se eliminan las colecciones sin asignar que estan obsoletas
- INSERT INTO ticketTracking(stateFk, ticketFk)
- SELECT s.id, tc.ticketFk
- FROM collection c
- JOIN ticketCollection tc ON tc.collectionFk = c.id
- JOIN state s ON s.code = 'PRINTED_AUTO'
- JOIN productionConfig pc
- WHERE c.workerFk IS NULL
- AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime;
- DELETE c
- FROM collection c
- JOIN productionConfig pc
- WHERE c.workerFk IS NULL
- AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime;
+ INSERT INTO ticketTracking(stateFk, ticketFk)
+ SELECT s.id, tc.ticketFk
+ FROM `collection` c
+ JOIN ticketCollection tc ON tc.collectionFk = c.id
+ JOIN `state` s ON s.code = 'PRINTED_AUTO'
+ WHERE c.workerFk IS NULL
+ AND TIMEDIFF(util.VN_NOW(), c.created) > vMaxNotAssignedCollectionLifeTime;
+
+ DELETE FROM `collection`
+ WHERE workerFk IS NULL
+ AND TIMEDIFF(util.VN_NOW(), created) > vMaxNotAssignedCollectionLifeTime;
-- Se añade registro al semillero
- INSERT INTO collectionHotbed
- SET userFk = vUserFk;
+
+ INSERT INTO collectionHotbed(userFk) VALUES(vUserFk);
-- Comprueba si hay colecciones disponibles que se ajustan a su configuracion
- SELECT MIN(c.id) INTO vCollectionFk
- FROM collection c
- JOIN operator o ON (o.itemPackingTypeFk = c.itemPackingTypeFk
- OR c.itemPackingTypeFk IS NULL)
- AND o.numberOfWagons = c.wagons
- AND o.trainFk = c.trainFk
- AND o.warehouseFk = c.warehouseFk
- AND c.workerFk IS NULL
- WHERE o.workerFk = vUserFk;
+
+ OPEN vCollections;
+ l: LOOP
+ SET vDone = FALSE;
+ FETCH vCollections INTO vCollectionFk;
+
+ IF vDone THEN
+ LEAVE l;
+ END IF;
+
+ BEGIN
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ ROLLBACK;
+ SET vCollectionFk = NULL;
+ RESIGNAL;
+ END;
+
+ START TRANSACTION;
+
+ SELECT workerFk INTO vCollectionWorker
+ FROM `collection`
+ WHERE id = vCollectionFk FOR UPDATE;
+
+ IF vCollectionWorker IS NULL THEN
+ UPDATE `collection`
+ SET workerFk = vUserFk
+ WHERE id = vCollectionFk;
+
+ COMMIT;
+ LEAVE l;
+ END IF;
+
+ ROLLBACK;
+ END;
+ END LOOP;
+ CLOSE vCollections;
IF vCollectionFk IS NULL THEN
CALL collection_new(vUserFk, vCollectionFk);
+
+ START TRANSACTION;
+
+ SELECT workerFk INTO vCollectionWorker
+ FROM `collection`
+ WHERE id = vCollectionFk FOR UPDATE;
+
+ IF vCollectionWorker IS NULL THEN
+ UPDATE `collection`
+ SET workerFk = vUserFk
+ WHERE id = vCollectionFk;
+ END IF;
+
+ COMMIT;
END IF;
-
- UPDATE collection
- SET workerFk = vUserFk
- WHERE id = vCollectionFk;
-
CALL itemShelvingSale_addByCollection(vCollectionFk);
-
- DO RELEASE_LOCK(vLockName);
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -51451,9 +51829,8 @@ BEGIN
SELECT tob.ticketFk, tob.description
FROM vn.ticketObservation tob
JOIN vn.ticketCollection tc ON tc.ticketFk = tob.ticketFk
- LEFT JOIN vn.observationType ot ON ot.id = tob.observationTypeFk
- WHERE ot.`code` = 'itemPicker'
- AND tc.collectionFk = vParamFk OR tc.ticketFk = vParamFk
+ JOIN vn.observationType ot ON ot.id = tob.observationTypeFk AND ot.`code` = 'itemPicker'
+ WHERE tc.collectionFk = vParamFk OR tc.ticketFk = vParamFk
)
SELECT t.id ticketFk,
IF(!(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`,
@@ -51461,7 +51838,9 @@ BEGIN
t.warehouseFk,
w.id salesPersonFk,
IFNULL(ob.description,'') observaciones,
- cc.rgb
+ cc.rgb,
+ p.code parkingCode,
+ IF (ps.ticketFk, TRUE, FALSE) isAdvanced
FROM vn.ticket t
LEFT JOIN vn.ticketCollection tc ON t.id = tc.ticketFk
LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk
@@ -51473,17 +51852,22 @@ BEGIN
LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
LEFT JOIN vn.client c ON c.id = t.clientFk
LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
- LEFT JOIN observation ob ON ob.ticketFk = t.id
+ LEFT JOIN observation ob ON ob.ticketFk = t.id
+ LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id
+ LEFT JOIN vn.parking p ON tp.parkingFk = p.id
+ LEFT JOIN vn.packingSiteAdvanced ps ON ps.ticketFk = t.id
WHERE t.id = vParamFk
AND t.shipped >= vYesterday
- UNION ALL
+ UNION
SELECT t.id ticketFk,
IF(NOT(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`,
am.name agencyName,
t.warehouseFk,
w.id salesPersonFk,
ob.description,
- IF(NOT (vItemPackingTypeFk <=> 'V'), cc.rgb, NULL) `rgb`
+ IF(NOT (vItemPackingTypeFk <=> 'V'), cc.rgb, NULL) `rgb`,
+ p.code parkingCode,
+ IF (ps.ticketFk, TRUE, FALSE) isAdvanced
FROM vn.ticket t
JOIN vn.ticketCollection tc ON t.id = tc.ticketFk
LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk
@@ -51495,16 +51879,21 @@ BEGIN
LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
LEFT JOIN vn.client c ON c.id = t.clientFk
LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
- LEFT JOIN observation ob ON ob.ticketFk = t.id
+ LEFT JOIN observation ob ON ob.ticketFk = t.id
+ LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id
+ LEFT JOIN vn.parking p ON tp.parkingFk = p.id
+ LEFT JOIN vn.packingSiteAdvanced ps ON ps.ticketFk = t.id
WHERE tc.collectionFk = vParamFk
- UNION ALL
+ UNION
SELECT sg.ticketFk,
NULL `level`,
am.name agencyName,
t.warehouseFk,
c.salesPersonFk,
ob.description,
- NULL `rgb`
+ NULL `rgb`,
+ p.code parkingCode,
+ IF (ps.ticketFk, TRUE, FALSE) isAdvanced
FROM vn.sectorCollection sc
JOIN vn.sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id
JOIN vn.saleGroup sg ON sg.id = ss.saleGroupFk
@@ -51512,9 +51901,13 @@ BEGIN
LEFT JOIN vn.zone z ON z.id = t.zoneFk
LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
LEFT JOIN observation ob ON ob.ticketFk = t.id
- LEFT JOIN vn.client c ON c.id = t.clientFk
+ LEFT JOIN vn.client c ON c.id = t.clientFk
+ LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id
+ LEFT JOIN vn.parking p ON tp.parkingFk = p.id
+ LEFT JOIN vn.packingSiteAdvanced ps ON ps.ticketFk = t.id
WHERE sc.id = vParamFk
- AND t.shipped >= vYesterday;
+ AND t.shipped >= vYesterday
+ GROUP BY ticketFk;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -51683,7 +52076,10 @@ DELIMITER ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
-CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_new`(vUserFk INT, OUT vCollectionFk INT)
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_new`(
+ vUserFk INT,
+ OUT vCollectionFk INT
+)
BEGIN
/**
* Genera colecciones de tickets sin asignar trabajador.
@@ -51696,30 +52092,29 @@ BEGIN
DECLARE vLinesLimit INT;
DECLARE vTicketLines INT;
DECLARE vVolumeLimit DECIMAL;
- DECLARE vTicketVolume DECIMAL;
DECLARE vSizeLimit INT;
+ DECLARE vTicketVolume DECIMAL;
DECLARE vMaxTickets INT;
- DECLARE vStateFk VARCHAR(45);
+ DECLARE vStateCode VARCHAR(45);
DECLARE vFirstTicketFk INT;
- DECLARE vHour INT;
- DECLARE vMinute INT;
DECLARE vWorkerCode VARCHAR(3);
- DECLARE vWagonCounter INT DEFAULT 0;
+ DECLARE vWagonCounter INT DEFAULT 1;
DECLARE vTicketFk INT;
DECLARE vItemPackingTypeFk VARCHAR(1);
- DECLARE vHasAssignedTickets BOOLEAN;
+ DECLARE vHasAssignedTickets BOOL;
DECLARE vHasUniqueCollectionTime BOOL;
- DECLARE vDone INT DEFAULT FALSE;
- DECLARE vLockName VARCHAR(215);
- DECLARE vLockTime INT DEFAULT 30;
+ DECLARE vHeight INT;
+ DECLARE vVolume INT;
+ DECLARE vLiters INT;
+ DECLARE vLines INT;
+ DECLARE vTotalLines INT DEFAULT 0;
+ DECLARE vTotalVolume INT DEFAULT 0;
DECLARE vFreeWagonFk INT;
- DECLARE vErrorNumber INT;
- DECLARE vErrorMsg TEXT;
+ DECLARE vDone INT DEFAULT FALSE;
- DECLARE c1 CURSOR FOR
+ DECLARE vTickets CURSOR FOR
SELECT ticketFk, `lines`, m3
FROM tmp.productionBuffer
- WHERE ticketFk <> vFirstTicketFk
ORDER BY HH,
mm,
productionOrder DESC,
@@ -51732,26 +52127,6 @@ BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
- DECLARE EXIT HANDLER FOR SQLEXCEPTION
- BEGIN
- GET DIAGNOSTICS CONDITION 1
- vErrorNumber = MYSQL_ERRNO,
- vErrorMsg = MESSAGE_TEXT;
-
- CALL util.debugAdd('collection_new', JSON_OBJECT(
- 'errorNumber', vErrorNumber,
- 'errorMsg', vErrorMsg,
- 'lockName', vLockName,
- 'userFk', vUserFk,
- 'ticketFk', vTicketFk
- )); -- Tmp
-
- IF vLockName IS NOT NULL THEN
- DO RELEASE_LOCK(vLockName);
- END IF;
- RESIGNAL;
- END;
-
SELECT pc.ticketTrolleyMax * o.numberOfWagons,
pc.hasUniqueCollectionTime,
w.code,
@@ -51762,36 +52137,26 @@ BEGIN
o.trainFk,
o.linesLimit,
o.volumeLimit,
- o.sizeLimit,
- pc.collection_new_lockname
+ o.sizeLimit
INTO vMaxTickets,
- vHasUniqueCollectionTime,
- vWorkerCode,
- vWarehouseFk,
- vItemPackingTypeFk,
- vStateFk,
- vWagons,
- vTrainFk,
- vLinesLimit,
- vVolumeLimit,
- vSizeLimit,
- vLockName
- FROM productionConfig pc
- JOIN worker w ON w.id = vUserFk
+ vHasUniqueCollectionTime,
+ vWorkerCode,
+ vWarehouseFk,
+ vItemPackingTypeFk,
+ vStateCode,
+ vWagons,
+ vTrainFk,
+ vLinesLimit,
+ vVolumeLimit,
+ vSizeLimit
+ FROM worker w
+ JOIN operator o ON o.workerFk = w.id
JOIN state st ON st.`code` = 'ON_PREPARATION'
- JOIN operator o ON o.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;
+ JOIN productionConfig pc
+ WHERE w.id = vUserFk;
-- Se prepara el tren, con tantos vagones como sea necesario.
+
CREATE OR REPLACE TEMPORARY TABLE tTrain
(wagon INT,
shelve INT,
@@ -51802,63 +52167,62 @@ BEGIN
PRIMARY KEY(wagon, shelve))
ENGINE = MEMORY;
- WHILE vWagons > vWagonCounter DO
- SET vWagonCounter = vWagonCounter + 1;
-
- INSERT INTO tTrain(wagon, shelve, liters, `lines`, height)
- SELECT vWagonCounter, cv.`level` , cv.liters , cv.`lines` , cv.height
- FROM collectionVolumetry cv
- WHERE cv.trainFk = vTrainFk
+ INSERT INTO tTrain (wagon, shelve, liters, `lines`, height)
+ WITH RECURSIVE wagonSequence AS (
+ SELECT vWagonCounter wagon
+ UNION ALL
+ SELECT wagon + 1 wagon
+ FROM wagonSequence
+ WHERE wagon < vWagonCounter + vWagons -1
+ )
+ SELECT ws.wagon, cv.`level`, cv.liters, cv.`lines`, cv.height
+ FROM wagonSequence ws
+ JOIN vn.collectionVolumetry cv ON cv.trainFk = vTrainFk
AND cv.itemPackingTypeFk = vItemPackingTypeFk;
- END WHILE;
-- Esto desaparecerá cuando tengamos la table cache.ticket
+
CALL productionControl(vWarehouseFk, 0);
ALTER TABLE tmp.productionBuffer
ADD COLUMN liters INT,
ADD COLUMN height INT;
- -- Se obtiene nº de colección.
- INSERT INTO collection
- SET itemPackingTypeFk = vItemPackingTypeFk,
- trainFk = vTrainFk,
- wagons = vWagons,
- warehouseFk = vWarehouseFk;
-
- SELECT LAST_INSERT_ID() INTO vCollectionFk;
-
-- Los tickets de recogida en Algemesí sólo se sacan si están asignados.
-- Los pedidos con riesgo no se sacan aunque se asignen.
- DELETE pb.*
+
+ DELETE pb
FROM tmp.productionBuffer pb
JOIN state s ON s.id = pb.state
WHERE (pb.agency = 'REC_ALGEMESI'
AND s.code <> 'PICKER_DESIGNED')
OR pb.problem LIKE '%RIESGO%';
- -- Comprobamos si hay tickets asignados. En ese caso, nos centramos
- -- exclusivamente en esos tickets y los sacamos independientemente
- -- de problemas o tamaños
- SELECT COUNT(*) INTO vHasAssignedTickets
- FROM tmp.productionBuffer pb
- JOIN state s ON s.id = pb.state
- WHERE s.code = 'PICKER_DESIGNED'
- AND pb.workerCode = vWorkerCode;
+ -- Si hay tickets asignados, nos centramos exclusivamente en esos tickets
+ -- y los sacamos independientemente de problemas o tamaños
+
+ SELECT EXISTS (
+ SELECT TRUE
+ FROM tmp.productionBuffer pb
+ JOIN state s ON s.id = pb.state
+ WHERE (s.code = 'PICKER_DESIGNED'
+ AND pb.workerCode = vWorkerCode)
+ OR s.code = 'LAST_CALL'
+ ) INTO vHasAssignedTickets;
-- Se dejan en la tabla tmp.productionBuffer sólo aquellos tickets adecuados
+
IF vHasAssignedTickets THEN
- DELETE pb.*
+ DELETE pb
FROM tmp.productionBuffer pb
JOIN state s ON s.id = pb.state
- WHERE s.code <> 'PICKER_DESIGNED'
- OR pb.workerCode <> vWorkerCode;
+ WHERE (s.code <> 'PICKER_DESIGNED'
+ OR pb.workerCode <> vWorkerCode)
+ AND s.code <> 'LAST_CALL';
ELSE
- DELETE pb.*
+ DELETE pb
FROM tmp.productionBuffer pb
JOIN state s ON s.id = pb.state
- JOIN agencyMode am ON am.id = pb.agencyModeFk
- JOIN agency a ON a.id = am.agencyFk
LEFT JOIN (
SELECT pb.ticketFk, MAX(i.`size`) maxSize
FROM tmp.productionBuffer pb
@@ -51869,7 +52233,7 @@ BEGIN
) sub ON sub.ticketFk = pb.ticketFk
JOIN productionConfig pc
WHERE pb.shipped <> util.VN_CURDATE()
- OR (pb.ubicacion IS NULL AND a.isOwn)
+ OR pb.ubicacion IS NULL
OR (NOT s.isPreparable AND NOT s.isPrintable)
OR pb.collectionH IS NOT NULL
OR pb.collectionV IS NOT NULL
@@ -51877,26 +52241,25 @@ BEGIN
OR (NOT pb.H AND pb.V > 0 AND vItemPackingTypeFk = 'H')
OR (NOT pb.V AND vItemPackingTypeFk = 'V')
OR (pc.isPreviousPreparationRequired AND pb.previousWithoutParking)
- OR LENGTH(pb.problem) > 0
+ OR LENGTH(pb.problem)
OR pb.lines > vLinesLimit
OR pb.m3 > vVolumeLimit
OR sub.maxSize > vSizeLimit
OR pb.hasPlantTray;
END IF;
- -- Es importante que el primer ticket se coja en todos los casos
- SELECT ticketFk,
- HH,
- mm,
- `lines`,
- m3
- INTO vFirstTicketFk,
- vHour,
- vMinute,
- vTicketLines,
- vTicketVolume
+ -- Hay que excluir aquellos que no tengan la misma hora de preparacion, si procede
+
+ IF vHasUniqueCollectionTime THEN
+ DELETE pb
+ FROM tmp.productionBuffer pb
+ JOIN tmp.productionBuffer pb2 ON pb2.ticketFk = vFirstTicketFk
+ AND (pb.HH <> pb2.HH OR pb.mm <> pb2.mm);
+ END IF;
+
+ SELECT ticketFk INTO vFirstTicketFk
FROM tmp.productionBuffer
- ORDER BY HH,
+ ORDER BY HH,
mm,
productionOrder DESC,
m3 DESC,
@@ -51906,44 +52269,37 @@ BEGIN
ticketFk
LIMIT 1;
- -- Hay que excluir aquellos que no tengan la misma hora de preparacion, si procede
- IF vHasUniqueCollectionTime THEN
- DELETE FROM tmp.productionBuffer
- WHERE HH <> vHour
- OR mm <> vMinute;
- END IF;
-
- SET vTicketFk = vFirstTicketFk;
- SET @lines = 0;
- SET @volume = 0;
-
- OPEN c1;
- read_loop: LOOP
+ OPEN vTickets;
+ l: LOOP
SET vDone = FALSE;
+ FETCH vTickets INTO vTicketFk, vTicketLines, vTicketVolume;
+
+ IF vDone THEN
+ LEAVE l;
+ END IF;
-- Buscamos un ticket que cumpla con los requisitos en el listado
- IF ((vTicketLines + @lines) <= vLinesLimit OR vLinesLimit IS NULL)
- AND ((vTicketVolume + @volume) <= vVolumeLimit OR vVolumeLimit IS NULL) THEN
+
+ IF (vLinesLimit IS NULL OR (vTotalLines + vTicketLines) <= vLinesLimit)
+ AND (vVolumeLimit IS NULL OR (vTotalVolume + vTicketVolume) <= vVolumeLimit) THEN
CALL ticket_splitItemPackingType(vTicketFk, vItemPackingTypeFk);
DROP TEMPORARY TABLE tmp.ticketIPT;
+ SELECT COUNT(*), SUM(litros), MAX(i.`size`), SUM(sv.volume)
+ INTO vLines, vLiters, vHeight, vVolume
+ FROM saleVolume sv
+ JOIN sale s ON s.id = sv.saleFk
+ JOIN item i ON i.id = s.itemFk
+ WHERE sv.ticketFk = vTicketFk;
+
+ SET vTotalVolume = vTotalVolume + vVolume,
+ vTotalLines = vTotalLines + vLines;
+
UPDATE tmp.productionBuffer pb
- JOIN (
- SELECT SUM(litros) liters,
- @lines:= COUNT(*) + @lines,
- COUNT(*) `lines`,
- MAX(i.`size`) height,
- @volume := SUM(sv.volume) + @volume,
- SUM(sv.volume) volume
- FROM saleVolume sv
- JOIN sale s ON s.id = sv.saleFk
- JOIN item i ON i.id = s.itemFk
- WHERE sv.ticketFk = vTicketFk
- ) sub
- SET pb.liters = sub.liters,
- pb.`lines` = sub.`lines`,
- pb.height = sub.height
+ SET pb.liters = vLiters,
+ pb.`lines` = vLines,
+ pb.height = vHeight
WHERE pb.ticketFk = vTicketFk;
UPDATE tTrain tt
@@ -51960,17 +52316,13 @@ BEGIN
tt.height
LIMIT 1;
- -- Si no le encuentra una balda adecuada, intentamos darle un carro entero si queda alguno libre
+ -- Si no le encuentra una balda, intentamos darle un carro entero libre
+
IF NOT (SELECT COUNT(*) FROM tTrain WHERE ticketFk) THEN
- SELECT tt.wagon
- INTO vFreeWagonFk
- FROM tTrain tt
- LEFT JOIN (
- SELECT DISTINCT wagon
- FROM tTrain
- WHERE ticketFk IS NOT NULL
- ) nn ON nn.wagon = tt.wagon
- WHERE nn.wagon IS NULL
+ SELECT wagon INTO vFreeWagonFk
+ FROM tTrain
+ GROUP BY wagon
+ HAVING COUNT(ticketFk) = 0
ORDER BY wagon
LIMIT 1;
@@ -51979,38 +52331,35 @@ BEGIN
SET ticketFk = vFirstTicketFk
WHERE wagon = vFreeWagonFk;
- -- Se anulan el resto de carros libres para que sólo uno lleve un pedido excesivo
- DELETE tt.*
- FROM tTrain tt
- LEFT JOIN (
- SELECT DISTINCT wagon
- FROM tTrain
- WHERE ticketFk IS NOT NULL
- ) nn ON nn.wagon = tt.wagon
- WHERE nn.wagon IS NULL;
- END IF;
- END IF;
+ -- Se anulan el resto de carros libres,
+ -- máximo un carro con pedido excesivo
- FETCH c1 INTO vTicketFk, vTicketLines, vTicketVolume;
- IF vDone OR NOT (SELECT COUNT(*) FROM tTrain WHERE ticketFk IS NULL) THEN
- LEAVE read_loop;
- END IF;
- ELSE
- FETCH c1 INTO vTicketFk, vTicketLines, vTicketVolume;
- IF vDone THEN
- LEAVE read_loop;
- END IF;
+ DELETE tt
+ FROM tTrain tt
+ JOIN (SELECT wagon
+ FROM tTrain
+ GROUP BY wagon
+ HAVING COUNT(ticketFk) = 0
+ ) sub ON sub.wagon = tt.wagon;
+ END IF;
+ END IF;
END IF;
END LOOP;
- CLOSE c1;
+ CLOSE vTickets;
IF (SELECT COUNT(*) FROM tTrain WHERE ticketFk) THEN
- UPDATE collection c
- JOIN state st ON st.code = 'ON_PREPARATION'
- SET c.stateFk = st.id
- WHERE c.id = vCollectionFk;
+ -- Se obtiene nº de colección
+
+ INSERT INTO collection
+ SET itemPackingTypeFk = vItemPackingTypeFk,
+ trainFk = vTrainFk,
+ wagons = vWagons,
+ warehouseFk = vWarehouseFk;
+
+ SELECT LAST_INSERT_ID() INTO vCollectionFk;
-- Asigna las bandejas
+
INSERT IGNORE INTO ticketCollection(ticketFk, collectionFk, `level`, wagon, liters)
SELECT tt.ticketFk, vCollectionFk, tt.shelve, tt.wagon, tt.liters
FROM tTrain tt
@@ -52018,37 +52367,34 @@ BEGIN
ORDER BY tt.wagon, tt.shelve;
-- Actualiza el estado de los tickets
- CALL collection_setState(vCollectionFk, vStateFk);
+
+ CALL collection_setState(vCollectionFk, vStateCode);
-- Aviso para la preparacion previa
+
INSERT INTO ticketDown(ticketFk, collectionFk)
SELECT tc.ticketFk, tc.collectionFk
FROM ticketCollection tc
WHERE tc.collectionFk = vCollectionFk;
- CALL sales_mergeByCollection(vCollectionFk);
+ CALL collection_mergeSales(vCollectionFk);
UPDATE `collection` c
- JOIN (
+ JOIN(
SELECT COUNT(*) saleTotalCount,
SUM(s.isPicked <> 0) salePickedCount
FROM ticketCollection tc
JOIN sale s ON s.ticketFk = tc.ticketFk
- WHERE tc.collectionFk = vCollectionFk
- AND s.quantity > 0
- ) sub
+ WHERE tc.collectionFk = vCollectionFk
+ AND s.quantity > 0
+ )sub
SET c.saleTotalCount = sub.saleTotalCount,
c.salePickedCount = sub.salePickedCount
WHERE c.id = vCollectionFk;
-
ELSE
- DELETE FROM `collection`
- WHERE id = vCollectionFk;
- SET vCollectionFk = NULL;
+ SET vCollectionFk = NULL;
END IF;
- DO RELEASE_LOCK(vLockName);
-
DROP TEMPORARY TABLE
tTrain,
tmp.productionBuffer;
@@ -54273,7 +54619,6 @@ BEGIN
supplierFk,
dated,
isExcludedFromAvailable,
- isRaid,
commission,
currencyFk,
companyFk,
@@ -54284,7 +54629,6 @@ BEGIN
supplierFk,
dated,
isExcludedFromAvailable,
- isRaid,
commission,
currencyFk,
companyFk,
@@ -54491,7 +54835,7 @@ CREATE DEFINER=`vn`@`localhost` PROCEDURE `entry_getTransfer`(
BEGIN
/**
* Retorna los artículos trasladables a partir de una entrada.
- *
+ *
* @param vSelf Id de entrada
*/
DECLARE vDateShipped DATE;
@@ -54652,7 +54996,7 @@ BEGIN
LEFT JOIN tmp.buyUltimateFromInterval bufi ON bufi.itemFk = i.id
LEFT JOIN buy b3 ON b3.id = bufi.buyFk
WHERE ic.display
- AND NOT e.isRaid
+ AND NOT tr.isRaid
AND (ti.visible OR ti.available)
ORDER BY i.typeFk, i.name, i.id, i.size, i.category, o.name;
@@ -54714,17 +55058,19 @@ BEGIN
*
* @param vSelf Id de entrada
*/
- DECLARE vIsEditable BOOL;
+ DECLARE vIsNotEditable BOOL DEFAULT FALSE;
- SELECT e.isBooked INTO vIsEditable
+ SELECT TRUE INTO vIsNotEditable
FROM `entry` e
- JOIN entryType et ON et.code = e.typeFk
- WHERE NOT et.isInformal
- AND e.id = vSelf;
+ LEFT JOIN entryType et ON et.code = e.typeFk
+ WHERE e.id = vSelf
+ AND e.isBooked
+ AND (e.typeFk IS NULL OR NOT et.isInformal);
- IF vIsEditable AND NOT IFNULL(@isModeInventory, FALSE) THEN
+ IF vIsNotEditable AND NOT IFNULL(@isModeInventory, FALSE) THEN
CALL util.throw(CONCAT('Entry ', vSelf, ' is not editable'));
END IF;
+
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -55045,12 +55391,17 @@ DELIMITER ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
-CREATE DEFINER=`vn`@`localhost` PROCEDURE `entry_splitByShelving`(vShelvingFk VARCHAR(3), vFromEntryFk INT, vToEntryFk INT)
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `entry_splitByShelving`(
+ vShelvingCode VARCHAR(10),
+ vFromEntryFk INT,
+ vToEntryFk INT
+)
BEGIN
/**
- * Divide las compras entre dos entradas de acuerdo con lo ubicado en una matr�cula
+ * Divide las compras entre dos entradas de
+ * acuerdo con lo ubicado en una matricula.
*
- * @param vShelvingFk Identificador de vn.shelving
+ * @param vShelvingCode Código de vn.shelving
* @param vFromEntryFk Entrada origen
* @param vToEntryFk Entrada destino
*/
@@ -55060,16 +55411,17 @@ BEGIN
DECLARE vDone BOOLEAN DEFAULT FALSE;
DECLARE cur CURSOR FOR
- SELECT bb.id buyFk,
+ SELECT bb.id buyFk,
LEAST(bb.stickers, FLOOR(ish.visible / ish.packing)) ishStickers,
bb.stickers buyStickers
FROM itemShelving ish
+ JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN (SELECT b.id, b.itemFk, b.stickers
FROM buy b
WHERE b.entryFk = vFromEntryFk
ORDER BY b.stickers DESC
LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk
- WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_general_ci
+ WHERE sh.code = vShelvingCode COLLATE utf8_general_ci
AND NOT ish.isSplit
GROUP BY ish.id;
@@ -55153,9 +55505,10 @@ BEGIN
UPDATE buy SET printedStickers = vIshStickers WHERE id = LAST_INSERT_ID();
END IF;
- UPDATE itemShelving
- SET isSplit = TRUE
- WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci;
+ UPDATE itemShelving ish
+ JOIN shelving sh ON sh.id = ish.shelvingFk
+ SET ish.isSplit = TRUE
+ WHERE sh.code = vShelvingCode COLLATE utf8_general_ci;
END LOOP;
CLOSE cur;
END ;;
@@ -55270,7 +55623,7 @@ BEGIN
FROM vn.entry e
JOIN vn.travel t ON t.id = e.travelFk
JOIN vn.warehouse w ON w.id = t.warehouseInFk
- WHERE t.shipped >= util.VN_CURDATE()
+ WHERE t.landed >= util.VN_CURDATE()
AND e.currencyFk = vCurrency
AND NOT e.isBooked;
@@ -55281,7 +55634,7 @@ BEGIN
SET e.commission = vComission;
SELECT `name` INTO vCurrencyName
- FROM currency
+ FROM currency
WHERE id = vCurrency;
CALL entry_recalc();
@@ -55362,22 +55715,26 @@ CREATE DEFINER=`vn`@`localhost` PROCEDURE `expeditionPallet_build`(
vWorkerFk INT,
OUT vPalletFk INT
)
-BEGIN
-/** Construye un pallet de expediciones.
+proc: BEGIN
+/**
+ * Builds an expedition pallet.
*
- * Primero comprueba si esas expediciones ya pertenecen a otro pallet,
- * en cuyo caso actualiza ese pallet.
+ * First, it checks if these expeditions already belong to another pallet,
+ * in which case it returns an error.
*
- * @param vExpeditions JSON_ARRAY con esta estructura [exp1, exp2, exp3, ...]
- * @param vArcId INT Identificador de arcRead
- * @param vWorkerFk INT Identificador de worker
- * @param out vPalletFk Identificador de expeditionPallet
+ * @param vExpeditions JSON_ARRAY with this structure [exp1, exp2, exp3, ...]
+ * @param vArcId INT Identifier of arcRead
+ * @param vWorkerFk INT Identifier of worker
+ * @param out vPalletFk Identifier of expeditionPallet
*/
+
DECLARE vCounter INT;
DECLARE vExpeditionFk INT;
DECLARE vTruckFk INT;
DECLARE vPrinterFk INT;
DECLARE vExpeditionStateTypeFk INT;
+ DECLARE vFreeExpeditionCount INT;
+ DECLARE vExpeditionWithPallet INT;
CREATE OR REPLACE TEMPORARY TABLE tExpedition (
expeditionFk INT,
@@ -55401,48 +55758,63 @@ BEGIN
WHERE e.id = vExpeditionFk;
END WHILE;
- SELECT palletFk INTO vPalletFk
- FROM (
- SELECT palletFk, count(*) n
- FROM tExpedition
- WHERE palletFk > 0
- GROUP BY palletFk
- ORDER BY n DESC
- LIMIT 100
- ) sub
- LIMIT 1;
+ SELECT COUNT(expeditionFk) INTO vFreeExpeditionCount
+ FROM tExpedition
+ WHERE palletFk IS NULL;
- IF vPalletFk IS NULL THEN
- SELECT roadmapStopFk INTO vTruckFk
- FROM (
- SELECT rm.roadmapStopFk, count(*) n
- FROM routesMonitor rm
- JOIN tExpedition e ON e.routeFk = rm.routeFk
- GROUP BY roadmapStopFk
- ORDER BY n DESC
- LIMIT 1
- ) sub;
+ SELECT COUNT(expeditionFk) INTO vExpeditionWithPallet
+ FROM tExpedition
+ WHERE palletFk;
- IF vTruckFk IS NULL THEN
- CALL util.throw ('TRUCK_NOT_AVAILABLE');
- END IF;
-
- INSERT INTO expeditionPallet SET truckFk = vTruckFk;
-
- SET vPalletFk = LAST_INSERT_ID();
+ IF vExpeditionWithPallet THEN
+ UPDATE arcRead
+ SET error = (
+ SELECT GROUP_CONCAT(expeditionFk SEPARATOR ', ')
+ FROM tExpedition
+ WHERE palletFk
+ )
+ WHERE id = vArcId;
+ LEAVE proc;
END IF;
+ IF NOT vFreeExpeditionCount THEN
+ CALL util.throw ('NO_FREE_EXPEDITIONS');
+ END IF;
+
+ SELECT roadmapStopFk INTO vTruckFk
+ FROM (
+ SELECT rm.roadmapStopFk, count(*) n
+ FROM routesMonitor rm
+ JOIN tExpedition e ON e.routeFk = rm.routeFk
+ WHERE e.palletFk IS NULL
+ GROUP BY roadmapStopFk
+ ORDER BY n DESC
+ LIMIT 1
+ ) sub;
+
+ IF vTruckFk IS NULL THEN
+ CALL util.throw ('TRUCK_NOT_AVAILABLE');
+ END IF;
+
+ INSERT INTO expeditionPallet SET truckFk = vTruckFk;
+
+ SET vPalletFk = LAST_INSERT_ID();
+
INSERT INTO expeditionScan(expeditionFk, palletFk, workerFk)
SELECT expeditionFk, vPalletFk, vWorkerFk
FROM tExpedition
- ON DUPLICATE KEY UPDATE palletFk = vPalletFk, workerFk = vWorkerFk;
+ WHERE palletFk IS NULL;
SELECT id INTO vExpeditionStateTypeFk
FROM expeditionStateType
WHERE code = 'PALLETIZED';
-
+
INSERT INTO expeditionState(expeditionFk, typeFk)
- SELECT expeditionFk, vExpeditionStateTypeFk FROM tExpedition;
+ SELECT expeditionFk, vExpeditionStateTypeFk
+ FROM tExpedition
+ WHERE palletFk IS NULL;
+
+ UPDATE arcRead SET error = NULL WHERE id = vArcId;
SELECT printerFk INTO vPrinterFk FROM arcRead WHERE id = vArcId;
@@ -55701,12 +56073,12 @@ CREATE DEFINER=`vn`@`localhost` PROCEDURE `expeditionScan_Put`(
vExpeditionFk INT
)
BEGIN
- IF NOT (SELECT TRUE FROM expedition WHERE id = vExpeditionFk LIMIT 1) THEN
- CALL util.throw('Expedition not exists');
+ IF NOT EXISTS (SELECT id FROM expeditionPallet WHERE id = vPalletFk) THEN
+ CALL util.throw('Pallet not exists');
END IF;
- IF NOT (SELECT TRUE FROM expeditionPallet WHERE id = vPalletFk LIMIT 1) THEN
- CALL util.throw('Pallet not exists');
+ IF NOT EXISTS (SELECT id FROM expedition WHERE id = vExpeditionFk) THEN
+ CALL util.throw('Expedition not exists');
END IF;
REPLACE expeditionScan(expeditionFk, palletFk)
@@ -55930,7 +56302,8 @@ BEGIN
a.nickname,
sub2.itemPackingTypeConcat,
est.code,
- es.isScanned
+ es2.isScanned,
+ es2.scanOrder
FROM expedition e
JOIN ticket t ON t.id = e.ticketFk
JOIN ticketState ts ON ts.ticketFk = e.ticketFk
@@ -55952,8 +56325,9 @@ BEGIN
SELECT MAX(id)
FROM expeditionState es
WHERE expeditionFk = e.id)
+ LEFT JOIN expeditionState es2 ON es2.id = es.id
WHERE t.routeFk = vRouteFk AND e.freightItemFk <> FALSE
- ORDER BY r.created, t.priority DESC;
+ ORDER BY r.dated, t.priority DESC;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -56032,6 +56406,114 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `expedition_selfConsumptionPackaging` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `expedition_selfConsumptionPackaging`(
+ vSelf INT,
+ vAction ENUM('add', 'remove')
+)
+proc:BEGIN
+/**
+ * Maneja el consumo de cajas para autoconsumo, permitiendo
+ * añadir o quitar cajas utilizadas según la acción indicada.
+ *
+ * @param vSelf Id de expedición
+ */
+ DECLARE vClientFk INT;
+ DECLARE vAddressFk INT;
+ DECLARE vItemFk INT;
+ DECLARE vItemName VARCHAR(50);
+ DECLARE vWarehouseFk INT;
+ DECLARE vCreated DATE;
+ DECLARE vTicketFk INT;
+ DECLARE vSaleFk INT;
+ DECLARE vQuantity INT;
+
+ IF vAction NOT IN ('add', 'remove') THEN
+ CALL util.throw('Action not supported');
+ END IF;
+
+ SELECT pc.clientSelfConsumptionFk,
+ pc.addressSelfConsumptionFk,
+ i.id,
+ i.name,
+ t.warehouseFk,
+ e.created
+ INTO vClientFk,
+ vAddressFk,
+ vItemFk,
+ vItemName,
+ vWarehouseFk,
+ vCreated
+ FROM expedition e
+ LEFT JOIN packaging p ON p.id = e.packagingFk
+ LEFT JOIN item i ON i.id = p.itemFk
+ JOIN ticket t ON t.id = e.ticketFk
+ JOIN productionConfig pc
+ WHERE e.id = vSelf;
+
+ IF vClientFk IS NULL OR vItemFk IS NULL THEN
+ LEAVE proc;
+ END IF;
+
+ SET vCreated = DATE(vCreated);
+
+ SELECT id INTO vTicketFk
+ FROM ticket
+ WHERE shipped BETWEEN vCreated AND util.dayEnd(vCreated)
+ AND clientFk = vClientFk
+ AND addressFk = vAddressFk
+ AND warehouseFk = vWarehouseFk
+ AND nickname = 'CAJAS AUTOCONSUMO'
+ LIMIT 1;
+
+ IF vTicketFk IS NULL AND vAction = 'add' THEN
+ INSERT INTO ticket(clientFk, warehouseFk, shipped, nickname, addressFk)
+ VALUES (vClientFk, vWarehouseFk, vCreated, 'CAJAS AUTOCONSUMO', vAddressFk);
+
+ SET vTicketFk = LAST_INSERT_ID();
+ END IF;
+
+ SELECT id, quantity INTO vSaleFk, vQuantity
+ FROM sale
+ WHERE itemFk = vItemFk
+ AND ticketFk = vTicketFk
+ LIMIT 1;
+
+ IF vAction = 'add' THEN
+ IF vSaleFk IS NOT NULL THEN
+ UPDATE sale
+ SET quantity = quantity + 1
+ WHERE id = vSaleFk;
+ ELSE
+ INSERT INTO sale(itemFk, ticketFk, concept, quantity)
+ VALUES (vItemFk, vTicketFk, vItemName, 1);
+ END IF;
+ ELSE
+ IF vSaleFk IS NOT NULL THEN
+ IF vQuantity > 1 THEN
+ UPDATE sale
+ SET quantity = quantity - 1
+ WHERE id = vSaleFk;
+ ELSE
+ DELETE FROM sale WHERE id = vSaleFk;
+ END IF;
+ END IF;
+ END IF;
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `expedition_StateGet` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -56590,7 +57072,7 @@ BEGIN
JOIN travel tr ON tr.id = e.travelFk
WHERE tr.warehouseInFk = vWarehouseFk
AND tr.landed BETWEEN vDateLastInventory AND vDateYesterday
- AND NOT isRaid
+ AND NOT tr.isRaid
GROUP BY b.itemFk;
-- Transfers
@@ -56603,7 +57085,7 @@ BEGIN
JOIN travel tr ON tr.id = e.travelFk
WHERE tr.warehouseOutFk = vWarehouseFk
AND tr.shipped BETWEEN vDateLastInventory AND vDateYesterday
- AND NOT isRaid
+ AND NOT tr.isRaid
GROUP BY b.itemFk
) sub
ON DUPLICATE KEY UPDATE quantity = IFNULL(quantity, 0) + sub.quantityOut;
@@ -57621,7 +58103,7 @@ BEGIN
) eWithheld ON TRUE
WHERE tii.taxTypeSageFk IS NOT NULL
AND (tii.taxCode IS NULL OR tii.taxCode NOT IN ('import10', 'import21'))
- GROUP BY tii.PorcentajeIva, tii.expenseFk;
+ GROUP BY tii.CuentaIvaRepercutido;
-- Línea iva inversor sujeto pasivo
INSERT INTO XDiario(
@@ -57686,7 +58168,7 @@ BEGIN
AND NOT(tii.isVies
AND c.nontaxableTransactionTypeFk = tii.transactionTypeSageFk
AND tii.taxCode = 'nonTaxable')
- GROUP BY tii.PorcentajeIva, tii.expenseFk;
+ GROUP BY tii.CuentaIvaRepercutido;
-- Actualización del registro original
UPDATE invoiceIn ii
@@ -58550,6 +59032,75 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `invoiceOut_newFromAddress` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `invoiceOut_newFromAddress`(
+ IN vAddressFk INT,
+ IN vSerial CHAR(2),
+ IN vMaxShipped DATE,
+ IN vCompanyFk INT,
+ IN vTaxArea VARCHAR(25),
+ IN vRef VARCHAR(25),
+ OUT vInvoiceId INT)
+BEGIN
+/**
+ * Factura los tickets de un consignatario hasta una fecha dada
+ * @param vAddressFk Id del consignatario a facturar
+ * @param vSerial Serie de factura
+ * @param vMaxShipped Fecha hasta la cual cogerá tickets para facturar
+ * @param vCompanyFk Id de la empresa desde la que se factura
+ * @param vTaxArea Tipo de iva en relacion a la empresa y al cliente, NULL por defecto
+ * @param vRef Referencia de la factura en caso que se quiera forzar, NULL por defecto
+ * @return vInvoiceId factura
+ */
+ DECLARE vIsRefEditable BOOLEAN;
+
+ IF vRef IS NOT NULL AND vSerial IS NOT NULL THEN
+ SELECT isRefEditable INTO vIsRefEditable
+ FROM invoiceOutSerial
+ WHERE code = vSerial;
+
+ IF NOT vIsRefEditable THEN
+ CALL util.throw('serial non editable');
+ END IF;
+ END IF;
+
+ DROP TEMPORARY TABLE IF EXISTS `tmp`.`ticketToInvoice`;
+ CREATE TEMPORARY TABLE `tmp`.`ticketToInvoice`
+ (PRIMARY KEY (`id`))
+ ENGINE = MEMORY
+ SELECT id FROM ticket t
+ WHERE t.addressFk = vAddressFk
+ AND t.refFk IS NULL
+ AND t.companyFk = vCompanyFk
+ AND t.shipped BETWEEN
+ util.firstDayOfYear(vMaxShipped - INTERVAL 1 YEAR)
+ AND util.dayend(vMaxShipped);
+
+ CALL invoiceOut_new(vSerial, util.VN_CURDATE(), vTaxArea, vInvoiceId);
+
+ UPDATE invoiceOut
+ SET `ref` = vRef
+ WHERE id = vInvoiceId
+ AND vRef IS NOT NULL;
+
+ IF vSerial <> 'R' AND NOT ISNULL(vInvoiceId) AND vInvoiceId <> 0 THEN
+ CALL invoiceOutBooking(vInvoiceId);
+ END IF;
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `invoiceOut_newFromClient` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -58739,6 +59290,73 @@ ELSE
INSERT INTO vn.itemBarcode(itemFk,code) VALUES (vItemFk,vCode);
END IF;
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `itemCampaign_add` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemCampaign_add`()
+proc: BEGIN
+/**
+ * Añade registros a tabla itemCampaign.
+ *
+ * @param vDateFrom Fecha desde
+ * @param vDateTo Fecha hasta
+ * @param vCampaign Código de la campaña
+ */
+ DECLARE vYesterday DATE;
+ DECLARE vCampaign VARCHAR(100);
+ DECLARE vScopeDays INT;
+ DECLARE vPreviousDays INT;
+ DECLARE vDateSumFrom DATE;
+ DECLARE vDateSumTo DATE;
+
+ SET vYesterday = util.yesterday();
+
+ SELECT dated, code, scopeDays, previousDays
+ INTO vDateSumTo, vCampaign, vScopeDays, vPreviousDays
+ FROM campaign
+ WHERE dated >= vYesterday
+ ORDER BY dated
+ LIMIT 1;
+
+ IF vCampaign IS NULL THEN
+ CALL util.throw('Missing data in campaign table');
+ END IF;
+
+ IF NOT vYesterday BETWEEN vDateSumTo - INTERVAL vPreviousDays DAY
+ AND vDateSumTo THEN
+ LEAVE proc;
+ END IF;
+
+ SET vDateSumFrom = vDateSumTo - INTERVAL vScopeDays DAY;
+ SET vDateSumTo = vDateSumTo - INTERVAL 1 DAY;
+
+ INSERT INTO itemCampaign(dated, itemFk, quantity, total, campaign)
+ SELECT vYesterday,
+ s.itemFk,
+ SUM(s.quantity) quantity,
+ SUM((s.quantity * s.price) * (100 - s.discount) / 100) total,
+ vCampaign
+ FROM sale s
+ JOIN ticket t ON t.id = s.ticketFk
+ JOIN client c ON c.id = t.clientFk
+ WHERE t.shipped BETWEEN vDateSumFrom AND util.dayEnd(vDateSumTo)
+ AND c.typeFk = 'normal'
+ AND NOT t.isDeleted
+ GROUP BY s.itemFk
+ HAVING quantity;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -58833,7 +59451,11 @@ DELIMITER ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
-CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemPlacementSupplyAiming`(vShelvingFk VARCHAR(10), quantity INT, vItemFk INT)
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemPlacementSupplyAiming`(
+ vShelvingCode VARCHAR(10),
+ vQuantity INT,
+ vItemFk INT
+)
BEGIN
SELECT ish.itemFk,
@@ -58843,21 +59465,21 @@ BEGIN
ish.itemShelvingFk,
ish.shelving,
ish.stock,
- LEAST(ish.stock,quantity) as total,
+ LEAST(ish.stock,vQuantity) total,
CONCAT(
- CAST(FLOOR(LEAST(ish.stock,quantity) / ish.packing) AS DECIMAL(10,0)),
+ CAST(FLOOR(LEAST(ish.stock, vQuantity) / ish.packing) AS DECIMAL(10,0)),
' x ',
ish.packing,
IF (
- LEAST(ish.stock,quantity) MOD ish.packing,
- CONCAT(' + ',CAST(LEAST(ish.stock,quantity) MOD ish.packing AS DECIMAL(10,0))),
+ LEAST(ish.stock, vQuantity) MOD ish.packing,
+ CONCAT(' + ',CAST(LEAST(ish.stock, vQuantity) MOD ish.packing AS DECIMAL(10,0))),
''
),
' = ',
- LEAST(ish.stock,quantity)
- ) as proposal
- FROM vn.itemShelvingPlacementSupplyStock ish
- WHERE ish.shelving = vShelvingFk COLLATE utf8_general_ci
+ LEAST(ish.stock, vQuantity)
+ ) proposal
+ FROM itemShelvingPlacementSupplyStock ish
+ WHERE ish.shelving = vShelvingCode COLLATE utf8_general_ci
AND ish.itemFk = vItemFk;
END ;;
@@ -58899,7 +59521,9 @@ DELIMITER ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
-CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemPlacementSupplyGetOrder`(vSector INT )
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemPlacementSupplyGetOrder`(
+ vSectorFk INT
+)
BEGIN
DECLARE vId INT;
@@ -58907,31 +59531,35 @@ BEGIN
DECLARE vNextParkingFk INT;
SELECT sh.parkingFk INTO vLastParkingFk
- FROM vn.itemShelvingPlacementSupply isps
- JOIN vn.itemShelving ish ON ish.id = isps.itemShelvingFk
- JOIN vn.shelving sh ON sh.code = ish.shelvingFk
+ FROM itemShelvingPlacementSupply isps
+ JOIN itemShelving ish ON ish.id = isps.itemShelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
WHERE isps.userFk = getUser()
ORDER BY isps.created DESC
LIMIT 1;
- SET vNextParkingFk = vn.itemShelvingPlacementSupply_ClosestGet(vLastParkingFk);
+ SET vNextParkingFk = itemShelvingPlacementSupply_ClosestGet(vLastParkingFk);
SELECT ipsl.id INTO vId
- FROM vn.itemPlacementSupplyList ipsl
- JOIN vn.itemShelvingPlacementSupplyStock ispss ON ispss.itemFk = ipsl.itemFk
+ FROM itemPlacementSupplyList ipsl
+ JOIN itemShelvingPlacementSupplyStock ispss ON ispss.itemFk = ipsl.itemFk
WHERE ipsl.saldo > 0
AND (ipsl.repoUserFk is NULL OR ipsl.repoUserFk = getUser())
- AND ipsl.sectorFk = vSector
- ORDER BY ipsl.repoUserFk DESC, ipsl.priority DESC, (ispss.parkingFk = vNextParkingFk) DESC, ispss.parking DESC, ipsl.created
+ AND ipsl.sectorFk = vSectorFk
+ ORDER BY ipsl.repoUserFk DESC,
+ ipsl.priority DESC,
+ (ispss.parkingFk = vNextParkingFk) DESC,
+ ispss.parking DESC,
+ ipsl.created
LIMIT 1;
- UPDATE vn.itemPlacementSupply
+ UPDATE itemPlacementSupply
SET repoUserFk = getUser()
WHERE id = vId;
- SELECT * FROM vn.itemPlacementSupplyList
+ SELECT * FROM itemPlacementSupplyList
WHERE id = vId
- AND sectorFk = vSector;
+ AND sectorFk = vSectorFk;
END ;;
DELIMITER ;
@@ -58949,7 +59577,10 @@ DELIMITER ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
-CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemPlacementSupplyStockGetTargetList`(vItemFk INT,vSectorFk INT)
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemPlacementSupplyStockGetTargetList`(
+ vItemFk INT,
+ vSectorFk INT
+)
BEGIN
/**
* Devuelve la lista de ubicaciones para itemFk en ese sector. Se utiliza en la preparación previa.
@@ -58963,11 +59594,11 @@ BEGIN
SUM(ish.visible) stockTotal,
ish.created,
p.pickingOrder
- FROM vn.itemShelving ish
- JOIN vn.shelving sh ON sh.code = ish.shelvingFk
- JOIN vn.parking p ON p.id = sh.parkingFk
- JOIN vn.sector sc ON sc.id = p.sectorFk
- JOIN vn.warehouse w ON w.id = sc.warehouseFk
+ FROM itemShelving ish
+ JOIN shelving sh ON sh.id = ish.shelvingFk
+ JOIN parking p ON p.id = sh.parkingFk
+ JOIN sector sc ON sc.id = p.sectorFk
+ JOIN warehouse w ON w.id = sc.warehouseFk
WHERE ish.visible > 0
AND ish.itemFk = vItemFk
GROUP BY ish.id
@@ -59136,54 +59767,6 @@ BEGIN
DELETE FROM vn.itemShelving WHERE id = vId;
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingLog_get` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingLog_get`(vShelvingFk VARCHAR(10) )
-BEGIN
-
-/**
- * Devuelve el log de los item en cada carro
- *
- * @param vShelvingFk Matrícula del carro
- *
- */
-
- SELECT isl.itemShelvingFk,
- isl.created,
- isl.accion,
- isl.itemFk,
- isl.shelvingFk,
- isl.quantity,
- isl.visible,
- isl.available,
- isl.grouping,
- isl.packing,
- isl.stars,
- item.longName,
- item.size,
- item.subName,
- worker.code,
- isl.accion
- FROM item
- JOIN itemShelvingLog isl ON item.id = isl.itemFk
- JOIN worker ON isl.workerFk = worker.id
- WHERE shelvingFk = vShelvingFk OR isl.itemFk = vShelvingFk
- ORDER BY isl.created DESC;
-
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -59221,7 +59804,7 @@ BEGIN
LEFT JOIN (
SELECT itemFk, sum(cast(visible / packing AS DECIMAL(10,0))) AS etiquetas
FROM itemShelving ish
- JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
LEFT JOIN parking pk ON pk.id = sh.parkingFk
WHERE ish.created BETWEEN vFromTimed AND vToTimed
GROUP BY itemFk
@@ -59767,18 +60350,19 @@ proc: BEGIN
DECLARE vReservedQuantity INT;
DECLARE vOutStanding INT;
DECLARE vUserFk INT;
- DECLARE vTotalReservedQuantity INT;
+ DECLARE vTotalReservedQuantity INT;
DECLARE vSaleQuantity INT;
+ DECLARE vIsRequiredTx BOOL DEFAULT NOT @@in_transaction;
DECLARE vItemShelvingAvailable CURSOR FOR
SELECT ish.id itemShelvingFk,
ish.available
FROM sale s
JOIN itemShelving ish ON ish.itemFk = s.itemFk
- JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector sc ON sc.id = p.sectorFk
- JOIN productionConfig pc
+ JOIN productionConfig pc
WHERE s.id = vSaleFk
AND NOT sc.isHideForPickers
AND (sc.id = vSectorFk OR vSectorFk IS NULL)
@@ -59793,15 +60377,15 @@ proc: BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
- ROLLBACK;
+ CALL util.tx_rollback(vIsRequiredTx);
RESIGNAL;
END;
-
- START TRANSACTION;
-
+
+ CALL util.tx_start(vIsRequiredTx);
+
SELECT id INTO vSaleFk
FROM sale
- WHERE id = vSaleFk
+ WHERE id = vSaleFk
FOR UPDATE;
SELECT MAX(p.pickingOrder), s.quantity - SUM(IFNULL(iss.quantity, 0)), s.quantity
@@ -59809,12 +60393,12 @@ proc: BEGIN
FROM sale s
LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id
LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
- LEFT JOIN shelving sh ON sh.code = ish.shelvingFk
+ LEFT JOIN shelving sh ON sh.id = ish.shelvingFk
LEFT JOIN parking p ON p.id = sh.parkingFk
WHERE s.id = vSaleFk;
IF vOutStanding <= 0 THEN
- COMMIT;
+ CALL util.tx_commit(vIsRequiredTx);
LEAVE proc;
END IF;
@@ -59834,7 +60418,7 @@ proc: BEGIN
IF vTotalReservedQuantity <> vSaleQuantity THEN
CALL util.debugAdd('itemShelvingSale_addBySale',
CONCAT(vSaleFk, ' - ', vSaleQuantity,' - ', vTotalReservedQuantity,'-', vOutStanding,'-', account.myUser_getId()));
-
+
UPDATE sale
SET quantity = vTotalReservedQuantity
WHERE id = vSaleFk;
@@ -59842,7 +60426,7 @@ proc: BEGIN
LEAVE l;
END IF;
- SELECT id INTO vItemShelvingFk
+ SELECT id INTO vItemShelvingFk
FROM itemShelving
WHERE id = vItemShelvingFk
FOR UPDATE;
@@ -59851,19 +60435,19 @@ proc: BEGIN
SET vOutStanding = vOutStanding - vReservedQuantity;
IF vReservedQuantity > 0 THEN
- CALL util.debugAdd('itemShelvingSale_addBySale_reservedQuantity',
- CONCAT(vSaleFk, ' - ', vReservedQuantity, ' - ', vOutStanding, account.myUser_getId()));
- INSERT INTO itemShelvingSale(
- itemShelvingFk,
- saleFk,
- quantity,
- userFk,
- isPicked)
- SELECT vItemShelvingFk,
- vSaleFk,
- vReservedQuantity,
- vUserFk,
- FALSE;
+ CALL util.debugAdd('itemShelvingSale_addBySale_reservedQuantity',
+ CONCAT(vSaleFk, ' - ', vReservedQuantity, ' - ', vOutStanding, account.myUser_getId()));
+ INSERT INTO itemShelvingSale(
+ itemShelvingFk,
+ saleFk,
+ quantity,
+ userFk,
+ isPicked)
+ SELECT vItemShelvingFk,
+ vSaleFk,
+ vReservedQuantity,
+ vUserFk,
+ FALSE;
UPDATE itemShelving
SET available = available - vReservedQuantity
@@ -59872,7 +60456,7 @@ proc: BEGIN
END IF;
END LOOP;
CLOSE vItemShelvingAvailable;
- COMMIT;
+ CALL util.tx_commit(vIsRequiredTx);
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -60000,6 +60584,68 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingSale_deleteAdded` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingSale_deleteAdded`(
+ vSelf INT(11)
+)
+proc: BEGIN
+/**
+ * Borra una reservea devolviendo la cantidad al itemShelving
+ *
+ * @param vSelf Identificador del itemShelvingSale
+ */
+ DECLARE vSaleFk INT;
+ DECLARE vHasSalesPicked BOOL;
+
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ ROLLBACK;
+ RESIGNAL;
+ END;
+
+ START TRANSACTION;
+
+ SELECT iss.saleFk INTO vSaleFk
+ FROM itemShelvingSale iss
+ JOIN sale s ON s.id = iss.saleFk
+ WHERE iss.id = vSelf AND s.isAdded
+ FOR UPDATE;
+
+ IF vSaleFk IS NULL THEN
+ CALL util.throw('The sale can not be deleted');
+ END IF;
+
+ SELECT COUNT(*) INTO vHasSalesPicked
+ FROM itemShelvingSale
+ WHERE saleFk = vSaleFk AND isPicked;
+
+ IF vHasSalesPicked THEN
+ CALL util.throw('A sale with picked sales cannot be deleted');
+ END IF;
+
+ UPDATE itemShelvingSale iss
+ JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
+ SET ish.available = ish.available + iss.quantity
+ WHERE iss.saleFk = vSaleFk;
+
+ DELETE FROM sale WHERE id = vSaleFk;
+
+ COMMIT;
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingSale_doReserve` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60194,7 +60840,8 @@ CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingSale_setQuantity`(
vItemShelvingSaleFk INT(10),
vQuantity DECIMAL(10,0),
vIsItemShelvingSaleEmpty BOOLEAN,
- vSectorFk INT
+ vSectorFk INT,
+ vShelvingFk VARCHAR(10)
)
BEGIN
/**
@@ -60215,6 +60862,7 @@ BEGIN
DECLARE vItemFk INT;
DECLARE vTotalQuantity INT;
DECLARE vStateCode VARCHAR(45);
+ DECLARE vCurrentShelvingFk VARCHAR(10);
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
@@ -60236,18 +60884,26 @@ BEGIN
iss.saleFk,
iss.itemShelvingFk,
SUM(IFNULL(iss.quantity,0)),
- IF(sgd.id, 'PREVIOUS_PREPARATION', 'PREPARED')
+ IF(sgd.id, 'PREVIOUS_PREPARATION', 'PREPARED'),
+ sh.code
INTO vItemFk,
vSaleFk,
vItemShelvingFk,
vReservedQuantity,
- vStateCode
+ vStateCode,
+ vCurrentShelvingFk
FROM itemShelvingSale iss
JOIN sale s ON s.id = iss.saleFk
- LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = iss.saleFk
+ JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
+ LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = iss.saleFk
+ LEFT JOIN shelving sh ON sh.id = ish.shelvingFk
WHERE iss.id = vItemShelvingSaleFk
AND NOT iss.isPicked;
+ IF NOT (vCurrentShelvingFk <=> vShelvingFk) THEN
+ CALL util.throw('The shelving can not be different from the shelving reserved');
+ END IF;
+
IF vQuantity > vReservedQuantity
OR (vQuantity < vReservedQuantity AND NOT vIsItemShelvingSaleEmpty)
OR (vQuantity = vReservedQuantity AND vIsItemShelvingSaleEmpty) THEN
@@ -60388,7 +61044,7 @@ DELIMITER ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_add`(
- vShelvingFk VARCHAR(8),
+ vShelvingCode VARCHAR(10),
vBarcode VARCHAR(22),
vQuantity INT,
vPackagingFk VARCHAR(10),
@@ -60400,7 +61056,7 @@ BEGIN
/**
* Añade registro o lo actualiza si ya existe.
*
- * @param vShelvingFk matrícula del carro
+ * @param vShelvingCode matrícula del carro
* @param vBarcode el id del registro
* @param vQuantity indica la cantidad del producto
* @param vPackagingFk el packaging del producto en itemShelving, NULL para coger el de la ultima compra
@@ -60411,10 +61067,15 @@ BEGIN
**/
DECLARE vItemFk INT;
DECLARE vBuyFk INT;
+ DECLARE vShelvingFk INT;
SELECT id INTO vBuyFk
FROM buy WHERE id = vBarcode;
+ SELECT id INTO vShelvingFk
+ FROM shelving
+ WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
+
SELECT barcodeToItem(vBarcode) INTO vItemFk;
IF vBuyFk IS NULL THEN
@@ -60428,7 +61089,7 @@ BEGIN
END IF;
IF (SELECT COUNT(*) FROM itemShelving
- WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
+ WHERE shelvingFk = vShelvingFk
AND itemFk = vItemFk
AND packing = vPacking
AND buyFk = vBuyFk) THEN
@@ -60436,7 +61097,9 @@ BEGIN
UPDATE itemShelving
SET visible = visible + vQuantity,
available = available + vQuantity
- WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking;
+ WHERE shelvingFk = vShelvingFk
+ AND itemFk = vItemFk
+ AND packing = vPacking;
ELSE
@@ -60474,31 +61137,40 @@ DELIMITER ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
-CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_addByClaim`(vClaimFk INT, vShelvingFk VARCHAR(3))
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_addByClaim`(
+ vClaimFk INT,
+ vShelvingCode VARCHAR(10)
+)
BEGIN
/**
* Insert items of claim into itemShelving.
*
* @param vClaimFk The claim
- * @param vShelvingFk The shelving
+ * @param vShelvingCode The shelving code
* @table tmp.buyUltimate
*/
DECLARE vWarehouseFk INT;
+ DECLARE vShelvingFk INT;
SELECT t.warehouseFk INTO vWarehouseFk
FROM claim c
JOIN ticket t ON t.id = c.ticketFk
WHERE c.id = vClaimFk;
+ SELECT id INTO vShelvingFk
+ FROM shelving
+ WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
+
CALL buy_getUltimate(NULL, vWarehouseFk, util.VN_CURDATE());
INSERT INTO itemShelving (itemFk, shelvingFk, packing, `grouping`, visible)
- SELECT s.itemFk, vShelvingFk, b.packing, b.`grouping`, cb.quantity AS visible
+ SELECT s.itemFk, vShelvingFk, b.packing, b.`grouping`, cb.quantity visible
FROM claim c
JOIN claimBeginning cb ON c.id = cb.claimFk
JOIN sale s ON s.id = cb.saleFk
JOIN ticket t ON t.id = s.ticketFk
- JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk AND bu.warehouseFk = t.warehouseFk
+ JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
+ AND bu.warehouseFk = t.warehouseFk
JOIN buy b ON b.id = bu.buyFk
WHERE c.id = vClaimFk;
END ;;
@@ -60517,18 +61189,24 @@ DELIMITER ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
-CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_addList`(vShelvingFk VARCHAR(3), vList TEXT, vIsChecking BOOL, vWarehouseFk INT)
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_addList`(
+ vShelvingCode VARCHAR(10),
+ vList TEXT,
+ vIsChecking BOOL,
+ vWarehouseFk INT
+)
BEGIN
-/* Recorre cada elemento en la colección vList.
+/**
+ * Recorre cada elemento en la colección vList.
* Si el parámetro isChecking = FALSE, llama a itemShelving_add.
*
* Cuando es TRUE sólo inserta los elementos de la colección que no están ya en
- * ese shelving, actualizando los valores del campo vn.itemShelving.isChecked
+ * ese shelving, actualizando los valores del campo itemShelving.isChecked
*
- * param vShelvingFk Identificador de vn.shelving
- * param vList JSON array con esta estructura: '[value1, value2, ...]'
- * param vIsChecking Define si hay que añadir o comprobar los items
- * param vWarehouseFk Identificador de vn.warehouse
+ * @param vShelvingCode Código de shelving
+ * @param vList JSON array con esta estructura: '[value1, value2, ...]'
+ * @param vIsChecking Define si hay que añadir o comprobar los items
+ * @param vWarehouseFk Identificador de warehouse
*/
DECLARE vListLength INT DEFAULT JSON_LENGTH(vList);
DECLARE vCounter INT DEFAULT 0;
@@ -60536,28 +61214,34 @@ BEGIN
DECLARE vPath VARCHAR(6);
DECLARE vItemFk INT;
DECLARE vIsChecked BOOL;
+ DECLARE vShelvingFk INT;
+
+ SELECT id INTO vShelvingFk
+ FROM shelving
+ WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
WHILE vCounter < vListLength DO
- SET vPath = CONCAT('$[',vCounter,']');
- SET vBarcode = JSON_EXTRACT(vList,vPath);
+ SET vPath = CONCAT('$[', vCounter, ']');
+ SET vBarcode = JSON_EXTRACT(vList, vPath);
SET vIsChecked = NULL;
IF vIsChecking THEN
SELECT barcodeToItem(vBarcode) INTO vItemFk;
- SELECT COUNT(*) INTO vIsChecked
- FROM vn.itemShelving
- WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
+ SELECT IF(COUNT(*), TRUE, FALSE) INTO vIsChecked
+ FROM itemShelving
+ WHERE shelvingFk = vShelvingFk
AND itemFk = vItemFk;
END IF;
- IF NOT (vIsChecking AND vIsChecked) THEN
- CALL vn.itemShelving_add(vShelvingFk, vBarcode, 1, NULL, NULL, NULL, vWarehouseFk);
+ IF NOT vIsChecking OR NOT vIsChecked THEN
+ CALL itemShelving_add(vShelvingCode, vBarcode, 1, NULL, NULL, NULL, vWarehouseFk);
END IF;
- UPDATE vn.itemShelving
+ UPDATE itemShelving
SET isChecked = vIsChecked
- WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
- AND itemFk = vItemFk AND isChecked IS NULL;
+ WHERE shelvingFk = vShelvingFk
+ AND itemFk = vItemFk
+ AND isChecked IS NULL;
SET vCounter = vCounter + 1;
END WHILE;
@@ -60676,17 +61360,20 @@ DELIMITER ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
-CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_get`(IN vSelf VARCHAR(8))
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_get`(
+ vShelvingCode VARCHAR(10)
+)
BEGIN
/**
-* Lista artículos de itemshelving
+* Lista artículos de itemShelving.
*
-* @param vSelf matrícula del carro
+* @param vShelvingCode Matrícula del carro
**/
SELECT ish.itemFk item,
- IFNULL(i.longName, CONCAT(i.name, ' ', i.size)) description,
+ i.name,
+ i.longName,
+ i.size,
ish.visible,
- CEIL(ish.visible/ish.packing) stickers,
ish.packing,
ish.grouping,
p.code,
@@ -60694,13 +61381,15 @@ BEGIN
s.priority,
ish.isChecked,
ic.url,
- ish.available
+ ish.available,
+ ish.buyFk,
+ ish.shelvingFk
FROM itemShelving ish
JOIN item i ON i.id = ish.itemFk
- JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci
- LEFT JOIN parking p ON s.parkingFk = p.id
+ JOIN shelving s ON s.id = ish.shelvingFk
+ LEFT JOIN parking p ON p.id = s.parkingFk
JOIN hedera.imageConfig ic
- WHERE ish.shelvingFk COLLATE utf8_unicode_ci = vSelf;
+ WHERE s.code COLLATE utf8_unicode_ci = vShelvingCode;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -60717,23 +61406,33 @@ DELIMITER ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
-CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_getAlternatives`(vShelvingFk VARCHAR(10))
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_getAlternatives`(
+ vShelvingCode VARCHAR(10)
+)
BEGIN
/**
- * Devuelve un listado de posibles ubicaciones alternativas a ubicar los item de la matricula
- * del carro que se le ha pasado.
+ * Devuelve un listado de posibles ubicaciones alternativas a ubicar
+ * los item de la matricula del carro que se le ha pasado.
*
- * @param vShelvingFk matricula del carro
+ * @param vShelvingCode Matricula del carro
*/
- SELECT is2.id,is2.shelvingFk , p.code, is2.itemFk , is2.visible, p.pickingOrder
+ DECLARE vShelvingFk INT;
+
+ SELECT id INTO vShelvingFk
+ FROM shelving
+ WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
+
+ SELECT is2.id,is2.shelvingFk, p.code, is2.itemFk , is2.visible, p.pickingOrder
FROM itemShelving is2
- JOIN shelving sh ON sh.code = is2.shelvingFk
+ JOIN shelving sh ON sh.id = is2.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector s ON s.id = p.sectorFk
- LEFT JOIN operator o ON o.sectorFk = s.id AND o.workerFk = account.myUser_getId()
+ LEFT JOIN operator o ON o.sectorFk = s.id
+ AND o.workerFk = account.myUser_getId()
JOIN warehouse wh ON wh.id = s.warehouseFk
- JOIN itemShelving is3 ON is3.itemFk = is2.itemFk AND is3.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci
- WHERE is2.shelvingFk <> vShelvingFk COLLATE utf8_unicode_ci
+ JOIN itemShelving is3 ON is3.itemFk = is2.itemFk
+ AND is3.shelvingFk = vShelvingFk
+ WHERE is2.shelvingFk <> vShelvingFk
GROUP BY is2.id
ORDER BY p.pickingOrder DESC;
END ;;
@@ -60769,7 +61468,7 @@ BEGIN
ish.itemFk itemFk,
sh.priority
FROM vn.itemShelving ish
- JOIN vn.shelving sh ON sh.`code` = ish.shelvingFk
+ JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking pk ON pk.id = sh.parkingFk
WHERE ish.itemFk = vItemFk
ORDER BY sh.priority DESC, created ASC;
@@ -60791,14 +61490,14 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_getItemDetails`(
vBarcodeItem INT,
- vShelvingFK VARCHAR(10)
+ vShelvingCode 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
+ * @param vShelvingCode Ubicación actual del artículo
*/
DECLARE vIsItem BOOL;
DECLARE vBuyFk INT;
@@ -60828,19 +61527,20 @@ BEGIN
WITH visible AS(
SELECT itemFk,
IFNULL(buyingValue, 0) +
- IFNULL(freightValue, 0) +
- IFNULL(comissionValue, 0) +
- IFNULL(packageValue, 0) itemCost
- FROM vn.buy b
+ IFNULL(freightValue, 0) +
+ IFNULL(comissionValue, 0) +
+ IFNULL(packageValue, 0) itemCost
+ FROM vn.buy b
WHERE b.id = vBuyFk
) SELECT v.itemFk,
- vShelvingFK,
+ vShelvingCode,
v.itemCost,
SUM(ish.visible) visible
FROM vn.itemShelving ish
+ JOIN vn.shelving sh ON sh.id = ish.shelvingFK
JOIN visible v
- WHERE ish.shelvingFK = vShelvingFK COLLATE utf8mb3_general_ci
- AND ish.itemFk = v.itemFk;
+ WHERE sh.code = vShelvingCode COLLATE utf8mb3_general_ci
+ AND ish.itemFk = v.itemFk;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -60857,16 +61557,22 @@ DELIMITER ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
-CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_getSaleDate`(vShelvingFk VARCHAR(3))
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_getSaleDate`(
+ vShelvingCode VARCHAR(10)
+)
BEGIN
-
- /* Devuelve la mínima fecha en que se necesita cada producto en esa matrícula.
- *
- * @param vShelvingFk Matrícula del carro o pallet
- */
-
+/**
+ * Devuelve la mínima fecha en que se necesita cada producto en esa matrícula.
+ *
+ * @param vShelvingCode Matrícula del carro o pallet
+ */
DECLARE vWarehouseFk INT;
DECLARE vStockScopeDays INT;
+ DECLARE vShelvingFk INT;
+
+ SELECT id INTO vShelvingFk
+ FROM shelving
+ WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
SELECT s.warehouseFk, stockScopeDays
INTO vWarehouseFk, vStockScopeDays
@@ -60888,7 +61594,7 @@ BEGIN
ENGINE = MEMORY
SELECT itemFk, SUM(visible) visible
FROM itemShelving
- WHERE shelvingFk = vShelvingFk COLLATE utf8_unicode_ci
+ WHERE shelvingFk = vShelvingFk
GROUP BY itemFk;
CREATE OR REPLACE TEMPORARY TABLE tmp.tStockByDay
@@ -60910,7 +61616,7 @@ BEGIN
SELECT ish.itemFk, - SUM(ish.visible), util.VN_CURDATE()
FROM itemShelving ish
JOIN tmp.tItems i ON i.itemFk = ish.itemFk
- JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON sh.parkingFk = p.id
JOIN sector s ON s.id = p.sectorFk
WHERE s.isReserve
@@ -60968,7 +61674,7 @@ BEGIN
UPDATE tmp.tStockByDay sbd
JOIN (SELECT ish.itemFK, SUM(ish.visible) amount
FROM itemShelving ish
- JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector s ON s.id = p.sectorFk
WHERE s.warehouseFk = vWarehouseFk
@@ -61008,10 +61714,10 @@ BEGIN
p.sectorFk,
ish.shelvingFk
FROM itemShelving ish
- JOIN vn.shelving sh ON sh.code = ish.shelvingFk
+ JOIN vn.shelving sh ON sh.id = ish.shelvingFk
LEFT JOIN parking p ON p.id = parkingFk
LEFT JOIN vn.sector s ON s.id = p.sectorFk
- WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci
+ WHERE ish.shelvingFk = vShelvingFk
) sub4 ON sub4.itemFk = ts.itemFk
LEFT JOIN sector s ON s.id = sub4.sectorFk
LEFT JOIN item i ON i.id = ts.itemFk
@@ -61078,7 +61784,7 @@ BEGIN
JOIN item i ON i.id = ish.itemFk
JOIN itemType it ON it.id = i.typeFk
JOIN tmp.stockMisfit sm ON sm.itemFk = ish.itemFk
- JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
LEFT JOIN (
SELECT s.itemFk, sum(s.quantity) notPrepared
@@ -61114,7 +61820,7 @@ DELIMITER ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_selfConsumption`(
- vShelvingFk VARCHAR(10) COLLATE utf8_general_ci,
+ vShelvingCode VARCHAR(10) COLLATE utf8_general_ci,
vItemFk INT,
vQuantity INT
)
@@ -61123,9 +61829,9 @@ BEGIN
* Leave the indicated amount on the shelve
* and create a ticket with the difference.
*
- * @param vShelvingFk id of the shelve where the item is located.
- * @param vItemFk article of which the self-consumption ticket is to be created.
- * @param vQuantity amount that will stay on the shelve
+ * @param vShelvingCode Code of the shelve where the item is located
+ * @param vItemFk Item of which the self-consumption ticket is to be created
+ * @param vQuantity Amount that will stay on the shelve
*/
DECLARE vVisible INT;
DECLARE vClientFk INT;
@@ -61135,6 +61841,11 @@ BEGIN
DECLARE vAgencyModeFk INT;
DECLARE vItemShelvingFk INT;
DECLARE vAddressFk INT;
+ DECLARE vShelvingFk INT;
+
+ SELECT id INTO vShelvingFk
+ FROM shelving
+ WHERE code = vShelvingCode;
SELECT c.id,
pc.clientSelfConsumptionFk,
@@ -61151,7 +61862,7 @@ BEGIN
JOIN parking p ON p.sectorFk = s.id
JOIN shelving s2 ON s2.parkingFk = p.id
JOIN productionConfig pc
- WHERE s2.code = vShelvingFk;
+ WHERE s2.id = vShelvingFk;
IF vClientFk IS NULL THEN
CALL util.throw('The company does not have a customer assigned');
@@ -61161,7 +61872,7 @@ BEGIN
CALL util.throw('The shelf cannot have NULL or negative quantities');
END IF;
- IF vShelvingFk IS NULL THEN
+ IF vShelvingCode IS NULL THEN
CALL util.throw('The shelf is necessary');
END IF;
@@ -61218,7 +61929,7 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_transfer`(
vItemShelvingFk INT,
- vShelvingFk VARCHAR(10)
+ vShelvingCode VARCHAR(10)
)
BEGIN
/**
@@ -61226,9 +61937,14 @@ BEGIN
* fusionando si coincide el packing y la fecha.
*
* @param vItemShelvingFk Identificador de itemShelving
- * @param vShelvingFk Identificador de shelving
+ * @param vShelvingCode Código de shelving
*/
DECLARE vNewItemShelvingFk INT;
+ DECLARE vShelvingFk INT;
+
+ SELECT id INTO vShelvingFk
+ FROM shelving
+ WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
SELECT MAX(ish.id) INTO vNewItemShelvingFk
FROM itemShelving ish
@@ -61243,7 +61959,7 @@ BEGIN
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;
+ WHERE ish.shelvingFk = vShelvingFk;
IF vNewItemShelvingFk THEN
UPDATE itemShelving ish
@@ -61255,9 +61971,7 @@ BEGIN
DELETE FROM itemShelving
WHERE id = vItemShelvingFk;
ELSE
- IF (SELECT EXISTS(SELECT id FROM shelving
- WHERE code = vShelvingFk COLLATE utf8_unicode_ci)) THEN
-
+ IF (SELECT EXISTS(SELECT id FROM shelving WHERE id = vShelvingFk)) THEN
UPDATE itemShelving
SET shelvingFk = vShelvingFk
WHERE id = vItemShelvingFk;
@@ -61625,6 +62339,58 @@ SET tag8 = t.name, value8 = it.value
WHERE it.priority = 4
AND (vItem IS NULL OR vItem = it.itemFk);
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `item_calculateStock` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_calculateStock`(
+ vDated DATE
+)
+BEGIN
+/**
+ * Calculate the stock of the auction warehouse from the inventory date to vDated
+ *
+ * @param vDated Date to calculate the stock.
+ * @return tmp.item, tmp.buyUltimate
+ */
+ DECLARE vAuctionWarehouseFk INT;
+
+ SELECT warehouseFk INTO vAuctionWarehouseFk
+ FROM auctionConfig;
+
+ CREATE OR REPLACE TEMPORARY TABLE tmp.item
+ (UNIQUE INDEX i USING HASH (itemFk))
+ ENGINE = MEMORY
+ SELECT itemFk, SUM(quantity) quantity
+ FROM itemEntryIn
+ WHERE landed = vDated
+ AND vDated >= util.VN_CURDATE()
+ AND warehouseInFk = vAuctionWarehouseFk
+ AND NOT isVirtualStock
+ GROUP BY itemFk
+ HAVING quantity;
+
+ CALL `cache`.stock_refresh(FALSE);
+
+ INSERT INTO tmp.item (itemFk, quantity)
+ SELECT item_id, amount
+ FROM `cache`.stock
+ WHERE warehouse_id = vAuctionWarehouseFk
+ ON DUPLICATE KEY UPDATE quantity = tmp.item.quantity + VALUES(quantity);
+
+ CALL buy_getUltimate(NULL, vAuctionWarehouseFk, vDated);
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -62285,7 +63051,7 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_devalueA2`(
vSelf INT,
- vShelvingFK VARCHAR(10),
+ vShelvingCode VARCHAR(10) COLLATE utf8mb3_general_ci,
vBuyingValue DECIMAL(10,4),
vQuantity INT
)
@@ -62296,7 +63062,7 @@ BEGIN
* de almacén y shelvings correspondientes
*
* @param vSelf Id de artículo a devaluar
- * @param vShelvingFK Ubicación actual del artículo
+ * @param vShelvingCode Código de shelving / ubicación
* @param vBuyingValue Nuevo precio de coste
* @param vQuantity Cantidad del ítem a pasar a A2
*/
@@ -62393,10 +63159,11 @@ BEGIN
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
+ SELECT ish.id, ish.visible INTO vTargetItemShelvingFk, vCurrentVisible
+ FROM itemShelving ish
+ JOIN shelving sh ON sh.id = ish.shelvingFk
+ WHERE sh.code = vShelvingCode
+ AND ish.itemFk = vSelf
LIMIT 1;
IF vCurrentVisible IS NULL THEN
@@ -62672,16 +63439,17 @@ BEGIN
userFk,
isChecked)
SELECT vItemA2Fk,
- shelvingFk,
+ ish.shelvingFk,
vQuantity ,
- `grouping`,
- packing,
- packagingFk,
+ ish.`grouping`,
+ ish.packing,
+ ish.packagingFk,
account.myUser_getId(),
- isChecked
- FROM itemShelving
- WHERE itemFK = vSelf
- AND shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci
+ ish.isChecked
+ FROM itemShelving ish
+ JOIN shelving sh ON sh.id = ish.shelvingFk
+ WHERE ish.itemFK = vSelf
+ AND sh.code = vShelvingCode
ON DUPLICATE KEY UPDATE
visible = vQuantity + VALUES(visible);
@@ -62817,16 +63585,16 @@ BEGIN
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()
+ JOIN vn.state st ON st.`code` = IF(tr.landed < util.VN_CURDATE()
OR (util.VN_CURDATE() AND tr.isReceived),
'DELIVERED',
'FREE')
WHERE tr.landed >= vDateInventory
AND tr.warehouseInFk = vWarehouseFk
- AND (s.id <> vSupplierInventoryFk OR vDated IS NULL)
+ AND (s.id <> vSupplierInventoryFk OR vDated IS NULL)
AND b.itemFk = vItemFk
AND NOT e.isExcludedFromAvailable
- AND NOT e.isRaid
+ AND NOT tr.isRaid
),
entriesOut AS (
SELECT 'entry',
@@ -62862,7 +63630,7 @@ BEGIN
AND b.itemFk = vItemFk
AND NOT e.isExcludedFromAvailable
AND NOT w.isFeedStock
- AND NOT e.isRaid
+ AND NOT tr.isRaid
),
sales AS (
WITH itemSales AS (
@@ -62914,10 +63682,10 @@ BEGIN
NULL
FROM itemSales s
LEFT JOIN vn.state stPrep ON stPrep.`code` = 'PREPARED'
- LEFT JOIN vn.saleTracking stk ON stk.saleFk = s.saleFk
+ LEFT JOIN vn.saleTracking stk ON stk.saleFk = s.saleFk
AND stk.stateFk = stPrep.id
GROUP BY s.saleFk
- ),
+ ),
orders AS (
SELECT 'order' originType,
o.id originId,
@@ -62982,9 +63750,9 @@ BEGIN
t.`in` invalue,
t.`out`,
@a := @a + IFNULL(t.`in`, 0) - IFNULL(t.`out`, 0) balance,
- @currentLineFk := IF (@shipped < util.VN_CURDATE()
+ @currentLineFk := IF (@shipped < util.VN_CURDATE()
OR (@shipped = util.VN_CURDATE() AND (t.isPicked OR a.`code` >= 'ON_PREPARATION')),
- t.lineFk,
+ t.lineFk,
@currentLineFk) lastPreparedLineFk,
t.isTicket,
t.lineFk,
@@ -63021,21 +63789,21 @@ BEGIN
UNION ALL
SELECT originType,
originId,
- shipped,
- alertlevel,
- stateName,
+ shipped,
+ alertlevel,
+ stateName,
reference,
entityType,
- entityId,
+ entityId,
entityName,
- `in`,
- `out`,
- @a := @a + IFNULL(`in`, 0) - IFNULL(`out`, 0),
- 0,
- isTicket,
- lineFk,
- isPicked,
- clientType,
+ `in`,
+ `out`,
+ @a := @a + IFNULL(`in`, 0) - IFNULL(`out`, 0),
+ 0,
+ isTicket,
+ lineFk,
+ isPicked,
+ clientType,
claimFk,
`order`
FROM tItemDiary
@@ -63102,7 +63870,6 @@ BEGIN
i.minimum `min`,
p.name producer,
o.code origin,
- v.visible - IFNULL(vVisibleItemShelving, 0) unlocated,
a.available,
vVisibleItemShelving,
v.visible,
@@ -63283,7 +64050,7 @@ BEGIN
AND NOT e.isExcludedFromAvailable
AND b.quantity <> 0
AND (vItemFk IS NULL OR b.itemFk = vItemFk)
- AND NOT e.isRaid
+ AND NOT t.isRaid
UNION ALL
SELECT r.itemFk,
r.shipment,
@@ -63380,19 +64147,23 @@ CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_getSimilar`(
)
BEGIN
/**
-* Propone articulos ordenados, con la cantidad
-* de veces usado y segun sus caracteristicas.
-*
-* @param vSelf Id de artículo
-* @param vWarehouseFk Id de almacen
-* @param vDated Fecha
-* @param vShowType Mostrar tipos
-* @param vDaysInForward Días de alcance para las ventas
-*/
+ * Propone articulos ordenados, con la cantidad
+ * de veces usado y segun sus caracteristicas.
+ *
+ * @param vSelf Id de artículo
+ * @param vWarehouseFk Id de almacen
+ * @param vDated Fecha
+ * @param vShowType Mostrar tipos
+ * @param vDaysInForward Días de alcance para las ventas (https://redmine.verdnatura.es/issues/7956#note-4)
+ */
DECLARE vAvailableCalcFk INT;
+ DECLARE vVisibleCalcFk INT;
+ DECLARE vTypeFk INT;
DECLARE vPriority INT DEFAULT 1;
CALL cache.available_refresh(vAvailableCalcFk, FALSE, vWarehouseFk, vDated);
+ CALL cache.visible_refresh(vVisibleCalcFk, FALSE, vWarehouseFk);
+ CALL buy_getUltimate(NULL, vWarehouseFk, vDated);
WITH itemTags AS (
SELECT i.id,
@@ -63412,25 +64183,9 @@ BEGIN
AND it.priority = vPriority
LEFT JOIN vn.tag t ON t.id = it.tagFk
WHERE i.id = vSelf
- ),
- stock AS (
- SELECT itemFk, SUM(visible) stock
- FROM vn.itemShelvingStock
- WHERE warehouseFk = vWarehouseFk
- GROUP BY itemFk
- ),
- sold AS (
- SELECT SUM(s.quantity) quantity, s.itemFk
- FROM vn.sale s
- JOIN vn.ticket t ON t.id = s.ticketFk
- LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id
- WHERE t.shipped >= CURDATE() + INTERVAL vDaysInForward DAY
- AND iss.saleFk IS NULL
- AND t.warehouseFk = vWarehouseFk
- GROUP BY s.itemFk
)
SELECT i.id itemFk,
- LEAST(CAST(sd.quantity AS INT), sk.stock) advanceable,
+ NULL advanceable, -- https://redmine.verdnatura.es/issues/7956#note-4
i.longName,
i.subName,
i.tag5,
@@ -63452,38 +64207,38 @@ BEGIN
WHEN b.groupingMode = 'packing' THEN b.packing
ELSE 1
END minQuantity,
- sk.stock located,
+ v.visible located,
b.price2
FROM vn.item i
- LEFT JOIN sold sd ON sd.itemFk = i.id
JOIN cache.available a ON a.item_id = i.id
AND a.calc_id = vAvailableCalcFk
- LEFT JOIN stock sk ON sk.itemFk = i.id
- LEFT JOIN cache.last_buy lb ON lb.item_id = i.id
- AND lb.warehouse_id = vWarehouseFk
+ LEFT JOIN cache.visible v ON v.item_id = i.id
+ AND v.calc_id = vVisibleCalcFk
+ LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = i.id
LEFT JOIN vn.itemProposal ip ON ip.mateFk = i.id
AND ip.itemFk = vSelf
LEFT JOIN vn.itemTag it ON it.itemFk = i.id
AND it.priority = vPriority
LEFT JOIN vn.tag t ON t.id = it.tagFk
- LEFT JOIN vn.buy b ON b.id = lb.buy_id
+ LEFT JOIN vn.buy b ON b.id = bu.buyFk
JOIN itemTags its
- WHERE (a.available > 0 OR sd.quantity < sk.stock)
+ WHERE a.available > 0
AND (i.typeFk = its.typeFk OR NOT vShowType)
AND i.id <> vSelf
- ORDER BY (a.available > 0) DESC,
- `counter` DESC,
- (t.name = its.name) DESC,
- (it.value = its.value) DESC,
- (i.tag5 = its.tag5) DESC,
- match5 DESC,
- (i.tag6 = its.tag6) DESC,
- match6 DESC,
- (i.tag7 = its.tag7) DESC,
- match7 DESC,
- (i.tag8 = its.tag8) DESC,
- match8 DESC
+ ORDER BY `counter` DESC,
+ (t.name = its.name) DESC,
+ (it.value = its.value) DESC,
+ (i.tag5 = its.tag5) DESC,
+ match5 DESC,
+ (i.tag6 = its.tag6) DESC,
+ match6 DESC,
+ (i.tag7 = its.tag7) DESC,
+ match7 DESC,
+ (i.tag8 = its.tag8) DESC,
+ match8 DESC
LIMIT 100;
+
+ DROP TEMPORARY TABLE tmp.buyUltimate;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -63652,22 +64407,22 @@ BEGIN
ALTER TABLE tmp.itemInventory
ADD `buy_date` datetime NOT NULL;
-
+
CREATE OR REPLACE TEMPORARY TABLE lastBuyScope
SELECT i.id, MAX(t.landed) lastLanded
- FROM item i
- JOIN buy b ON b.itemFk = i.id
+ FROM item i
+ JOIN buy b ON b.itemFk = i.id
JOIN entry e ON e.id = b.entryFk
- JOIN travel t ON t.id = e.travelFk
+ JOIN travel t ON t.id = e.travelFk
JOIN supplier s ON s.id = e.supplierFk
JOIN warehouse w ON w.id = t.warehouseInFk
WHERE t.landed BETWEEN (vDated + INTERVAL - vLastBuyScope DAY) AND vDated
AND NOT s.name = 'INVENTARIO'
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
AND w.isComparative
- AND NOT e.isRaid
+ AND NOT t.isRaid
GROUP BY i.id;
-
+
UPDATE tmp.itemInventory y
JOIN lastBuyScope lbs ON lbs.id = y.id
SET y.buy_date = lbs.lastLanded;
@@ -64056,7 +64811,7 @@ BEGIN
LIMIT 1;
SET vHasNotInventory = (vInventoried IS NULL);
-
+
IF vHasNotInventory THEN
SELECT landed INTO vInventoryClone
FROM travel tr
@@ -64081,7 +64836,7 @@ BEGIN
PRIMARY KEY (warehouseInventory, itemFk) USING HASH
)
ENGINE = MEMORY;
-
+
-- Inventario inicial
IF vHasNotInventory THEN
INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory)
@@ -64140,7 +64895,7 @@ BEGIN
JOIN warehouse w ON w.id = tr.warehouseInFk
WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd
AND IF(tr.landed = util.VN_CURDATE(), tr.isReceived, TRUE)
- AND NOT e.isRaid
+ AND NOT tr.isRaid
AND w.valuatedInventory
AND t.isInventory
AND e.supplierFk <> vInventorySupplierFk
@@ -64162,7 +64917,7 @@ BEGIN
JOIN itemCategory ic ON ic.id = t.categoryFk
JOIN warehouse w ON w.id = tr.warehouseOutFk
WHERE tr.shipped BETWEEN vInventoried AND vDateDayEnd
- AND NOT e.isRaid
+ AND NOT tr.isRaid
AND w.valuatedInventory
AND t.isInventory
AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL)
@@ -64190,7 +64945,7 @@ BEGIN
ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + s.quantity * IF(vHasNotInventory, 1, -1);
-- Volver a poner lo que esta aun en las estanterias
- IF vDated = util.VN_CURDATE() THEN
+ IF vDated = util.VN_CURDATE() THEN
INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory)
SELECT w.id,
s.itemFk,
@@ -64227,14 +64982,14 @@ BEGIN
JOIN warehouse wIn ON wIn.id = tr.warehouseInFk
JOIN warehouse wOut ON wOut.id = tr.warehouseOutFk
WHERE vDated >= tr.shipped AND vDated < tr.landed
- AND NOT isRaid
+ AND NOT tr.isRaid
AND wIn.valuatedInventory
AND t.isInventory
AND e.isConfirmed
AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL)
AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL)
ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity);
-
+
CALL buy_getUltimate (NULL, NULL, vDateDayEnd);
DELETE FROM tInventory WHERE quantity IS NULL OR NOT quantity;
@@ -64264,7 +65019,7 @@ BEGIN
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
+ JOIN itemCategory ic ON ic.id = tp.categoryFk
WHERE w.valuatedInventory
AND ti.total > 0;
@@ -64603,155 +65358,6 @@ set @cajas := 0;
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `machineWorker_add` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`vn`@`localhost` PROCEDURE `machineWorker_add`(vPlate VARCHAR(10), vWorkerFk INT)
-BEGIN
-
-/**
- * Inserta registro si el vWorkerFk no ha registrado nada en las últimas 12 horas
- * @param vPlate número de matrícula
- * @param vWorkerFk id del worker
- *
-*/
- UPDATE vn.machineWorker mw
- JOIN vn.machine m ON m.id = mw.machineFk
- SET mw.outTimed = util.VN_NOW()
- WHERE (mw.workerFk = vWorkerFk OR m.plate = vPlate)
- AND ISNULL(mw.outTimed);
-
- INSERT INTO machineWorker (machineFk, workerFk)
- SELECT m.id, vWorkerFk
- FROM machine m
- WHERE m.plate= vPlate;
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `machineWorker_getHistorical` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`vn`@`localhost` PROCEDURE `machineWorker_getHistorical`(vPlate VARCHAR(20), vWorkerFk INT)
-BEGIN
-/**
- * Obtiene historial de la matrícula vPlate que el trabajador vWorkerFk escanea,
- * si es jefe de producción muestra el historial completo.
- *
- * @param vPlate número de matrícula
- * @param vWorkerFk id del trabajador
- *
-*/
- DECLARE vWorkerName VARCHAR(255) DEFAULT account.user_getNameFromId(vWorkerFk);
-
- SELECT mw.inTimed,account.user_getNameFromId(mw.workerFk) as workerName, mw.outTimed
- FROM machineWorker mw
- JOIN machine m ON m.plate = vPlate
- WHERE mw.machineFk = m.id
- AND mw.workerFk = IF(account.user_hasRole(vWorkerName, 'coolerAssist'), mw.workerFk, vWorkerFk)
- ORDER BY mw.inTimed DESC;
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `machineWorker_update` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`vn`@`localhost` PROCEDURE `machineWorker_update`(vPlate VARCHAR(10), vWorkerFk INT)
-BEGIN
-
-/**
- * Actualiza el registro correspondiente si el vWorkerFk se ha registrado en las últimas horas (campo maxHours de machineWorkerConfig) con vPlate,
- *
- * @param vPlate número de matrícula
- * @param vWorkerFk id del trabajador
- *
-*/
-
- DECLARE vMachineFk INT(10);
- DECLARE vMaxHours INT(10);
-
- SELECT m.id INTO vMachineFk
- FROM machine m
- WHERE m.plate = vPlate;
-
- SELECT maxHours INTO vMaxHours
- FROM machineWorkerConfig;
-
- IF (SELECT COUNT(*)
- FROM machineWorker m
- WHERE m.workerFk = vWorkerFk
- AND m.inTimed >= TIMESTAMPADD(HOUR , -vMaxHours, util.VN_NOW()) AND ISNULL(m.outTimed)) THEN
-
- UPDATE machineWorker m
- SET m.outTimed = CURRENT_TIMESTAMP()
- WHERE m.workerFk = vWorkerFk
- AND m.inTimed >= TIMESTAMPADD(HOUR , -vMaxHours, util.VN_NOW())
- AND ISNULL(m.outTimed)
- AND m.machineFk = vMachineFk;
-
- END IF;
-
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `machine_getWorkerPlate` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`vn`@`localhost` PROCEDURE `machine_getWorkerPlate`(vWorkerFk INT)
-BEGIN
-/**
- * Selecciona la matrícula del vehículo del workerfk
- *
- * @param vWorkerFk el id del trabajador
- */
- SELECT m.plate
- FROM machine m
- JOIN machineWorker mw ON mw.machineFk = m.id
- WHERE mw.inTimed >= TIMESTAMPADD(HOUR , -12,util.VN_NOW())
- AND ISNULL(mw.outTimed)
- AND mw.workerFk = vWorkerFk;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -64949,176 +65555,176 @@ DELIMITER ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
-CREATE DEFINER=`vn`@`localhost` PROCEDURE `multipleInventory`(
- vDate DATE,
- vWarehouseFk TINYINT,
- vMaxDays TINYINT
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `multipleInventory`(
+ vDate DATE,
+ vWarehouseFk TINYINT,
+ vMaxDays TINYINT
)
-proc: BEGIN
- DECLARE vDateTomorrow DATE DEFAULT vDate + INTERVAL 1 DAY;
- DECLARE vDateFrom DATE DEFAULT vDate;
- DECLARE vDateTo DATETIME;
- DECLARE vDateToTomorrow DATETIME;
- DECLARE vDefaultDayRange INT;
- DECLARE vCalcFk INT;
-
- IF vDate < util.VN_CURDATE() THEN
- LEAVE proc;
- END IF;
-
- IF vDate = util.VN_CURDATE() THEN
- SELECT inventoried INTO vDateFrom
- FROM config;
- END IF;
-
- SELECT defaultDayRange INTO vDefaultDayRange
- FROM comparativeConfig;
-
- SET vDateTo = vDate + INTERVAL IFNULL(vMaxDays, vDefaultDayRange) DAY;
- SET vDateToTomorrow = vDateTo + INTERVAL 1 DAY;
-
- ALTER TABLE tmp.itemInventory
- ADD `avalaible` INT NOT NULL,
- ADD `sd` INT NOT NULL,
- ADD `rest` INT NOT NULL,
- ADD `expected` INT NOT NULL,
- ADD `inventory` INT NOT NULL,
- ADD `visible` INT NOT NULL,
- ADD `life` TINYINT NOT NULL DEFAULT '0';
-
- -- Calculo del inventario
- CREATE OR REPLACE TEMPORARY TABLE tItemInventoryCalc
- (PRIMARY KEY (itemFk))
- ENGINE = MEMORY
- SELECT itemFk,
- SUM(quantity) quantity
- FROM (
- SELECT s.itemFk, - s.quantity quantity
- FROM sale s
- JOIN ticket t ON t.id = s.ticketFk
- JOIN warehouse w ON w.id = t.warehouseFk
- WHERE t.shipped BETWEEN vDateFrom AND util.dayEnd(vDate)
- AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk
- AND w.isComparative
- UNION ALL
- SELECT b.itemFk, b.quantity
- FROM buy b
- JOIN entry e ON e.id = b.entryFk
- JOIN travel t ON t.id = e.travelFk
- JOIN warehouse w ON w.id = t.warehouseInFk
- WHERE t.landed BETWEEN vDateFrom AND util.dayEnd(vDate)
- AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk
- AND w.isComparative
- AND NOT e.isExcludedFromAvailable
- AND NOT e.isRaid
- UNION ALL
- SELECT b.itemFk, - b.quantity
- FROM buy b
- JOIN entry e ON e.id = b.entryFk
- JOIN travel t ON t.id = e.travelFk
- JOIN warehouse w ON w.id = t.warehouseOutFk
- WHERE t.shipped BETWEEN vDateFrom AND util.dayEnd(vDate)
- AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk
- AND w.isComparative
- AND NOT e.isExcludedFromAvailable
- AND NOT e.isRaid
- ) sub
- GROUP BY itemFk;
-
- -- Cálculo del visible
- CALL cache.visible_refresh(vCalcFk, FALSE, vWarehouseFk);
-
- CREATE OR REPLACE TEMPORARY TABLE tItemVisibleCalc
- (PRIMARY KEY (item_id))
- ENGINE = MEMORY
- SELECT item_id, visible
- FROM cache.visible
- WHERE calc_id = vCalcFk;
-
- UPDATE tmp.itemInventory it
- LEFT JOIN tItemInventoryCalc iic ON iic.itemFk = it.id
- LEFT JOIN tItemVisibleCalc ivc ON ivc.item_id = it.id
- SET it.inventory = iic.quantity,
- it.visible = ivc.visible,
- it.avalaible = iic.quantity,
- it.sd = iic.quantity;
-
- -- Calculo del disponible
- CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc
- (INDEX (itemFk, warehouseFk))
- ENGINE = MEMORY
- SELECT sub.itemFk,
- vWarehouseFk warehouseFk,
- sub.dated,
- SUM(sub.quantity) quantity
- FROM (
- SELECT s.itemFk,
- DATE(t.shipped) dated,
- - s.quantity quantity
- FROM sale s
- JOIN ticket t ON t.id = s.ticketFk
- JOIN warehouse w ON w.id = t.warehouseFk
- WHERE t.shipped BETWEEN vDateTomorrow AND vDateTo
- AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk
- AND w.isComparative
- UNION ALL
- SELECT b.itemFk, t.landed, b.quantity
- FROM buy b
- JOIN entry e ON e.id = b.entryFk
- JOIN travel t ON t.id = e.travelFk
- JOIN warehouse w ON w.id = t.warehouseInFk
- WHERE t.landed BETWEEN vDateTomorrow AND vDateTo
- AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk
- AND w.isComparative
- AND NOT e.isExcludedFromAvailable
- AND NOT e.isRaid
- UNION ALL
- SELECT b.itemFk, t.shipped, - b.quantity
- FROM buy b
- JOIN entry e ON e.id = b.entryFk
- JOIN travel t ON t.id = e.travelFk
- JOIN warehouse w ON w.id = t.warehouseOutFk
- WHERE t.shipped BETWEEN vDateTomorrow AND vDateTo
- AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk
- AND w.isComparative
- AND NOT e.isExcludedFromAvailable
- AND NOT e.isRaid
- ) sub
- GROUP BY sub.itemFk, sub.dated;
-
- CALL item_getAtp(vDate);
- CALL travel_upcomingArrivals(vWarehouseFk, vDate);
-
- CREATE OR REPLACE TEMPORARY TABLE tItemAvailableCalc
- (PRIMARY KEY (itemFk))
- ENGINE = MEMORY
- SELECT it.itemFk,
- SUM(it.quantity) quantity,
- im.quantity minQuantity
- FROM tmp.itemCalc it
- JOIN tmp.itemAtp im ON im.itemFk = it.itemFk
- JOIN item i ON i.id = it.itemFk
- LEFT JOIN origin o ON o.id = i.originFk
- LEFT JOIN tmp.itemTravel t ON t.wh = o.warehouseFk
- WHERE it.dated < IF(vMaxDays < 0 AND t.landing IS NOT NULL,
- t.landing,
- vDateToTomorrow)
- GROUP BY it.itemFk;
-
- UPDATE tmp.itemInventory it
- JOIN tItemAvailableCalc iac ON iac.itemFk = it.id
- SET it.avalaible = IF(iac.minQuantity > 0,
- it.avalaible,
- it.avalaible + iac.minQuantity),
- it.sd = it.inventory + iac.quantity;
-
- DROP TEMPORARY TABLE
- tmp.itemTravel,
- tmp.itemCalc,
- tmp.itemAtp,
- tItemInventoryCalc,
- tItemVisibleCalc,
- tItemAvailableCalc;
+proc: BEGIN
+ DECLARE vDateTomorrow DATE DEFAULT vDate + INTERVAL 1 DAY;
+ DECLARE vDateFrom DATE DEFAULT vDate;
+ DECLARE vDateTo DATETIME;
+ DECLARE vDateToTomorrow DATETIME;
+ DECLARE vDefaultDayRange INT;
+ DECLARE vCalcFk INT;
+
+ IF vDate < util.VN_CURDATE() THEN
+ LEAVE proc;
+ END IF;
+
+ IF vDate = util.VN_CURDATE() THEN
+ SELECT inventoried INTO vDateFrom
+ FROM config;
+ END IF;
+
+ SELECT defaultDayRange INTO vDefaultDayRange
+ FROM comparativeConfig;
+
+ SET vDateTo = vDate + INTERVAL IFNULL(vMaxDays, vDefaultDayRange) DAY;
+ SET vDateToTomorrow = vDateTo + INTERVAL 1 DAY;
+
+ ALTER TABLE tmp.itemInventory
+ ADD `avalaible` INT NOT NULL,
+ ADD `sd` INT NOT NULL,
+ ADD `rest` INT NOT NULL,
+ ADD `expected` INT NOT NULL,
+ ADD `inventory` INT NOT NULL,
+ ADD `visible` INT NOT NULL,
+ ADD `life` TINYINT NOT NULL DEFAULT '0';
+
+ -- Calculo del inventario
+ CREATE OR REPLACE TEMPORARY TABLE tItemInventoryCalc
+ (PRIMARY KEY (itemFk))
+ ENGINE = MEMORY
+ SELECT itemFk,
+ SUM(quantity) quantity
+ FROM (
+ SELECT s.itemFk, - s.quantity quantity
+ FROM sale s
+ JOIN ticket t ON t.id = s.ticketFk
+ JOIN warehouse w ON w.id = t.warehouseFk
+ WHERE t.shipped BETWEEN vDateFrom AND util.dayEnd(vDate)
+ AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk
+ AND w.isComparative
+ UNION ALL
+ SELECT b.itemFk, b.quantity
+ FROM buy b
+ JOIN entry e ON e.id = b.entryFk
+ JOIN travel t ON t.id = e.travelFk
+ JOIN warehouse w ON w.id = t.warehouseInFk
+ WHERE t.landed BETWEEN vDateFrom AND util.dayEnd(vDate)
+ AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk
+ AND w.isComparative
+ AND NOT e.isExcludedFromAvailable
+ AND NOT t.isRaid
+ UNION ALL
+ SELECT b.itemFk, - b.quantity
+ FROM buy b
+ JOIN entry e ON e.id = b.entryFk
+ JOIN travel t ON t.id = e.travelFk
+ JOIN warehouse w ON w.id = t.warehouseOutFk
+ WHERE t.shipped BETWEEN vDateFrom AND util.dayEnd(vDate)
+ AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk
+ AND w.isComparative
+ AND NOT e.isExcludedFromAvailable
+ AND NOT t.isRaid
+ ) sub
+ GROUP BY itemFk;
+
+ -- Cálculo del visible
+ CALL cache.visible_refresh(vCalcFk, FALSE, vWarehouseFk);
+
+ CREATE OR REPLACE TEMPORARY TABLE tItemVisibleCalc
+ (PRIMARY KEY (item_id))
+ ENGINE = MEMORY
+ SELECT item_id, visible
+ FROM cache.visible
+ WHERE calc_id = vCalcFk;
+
+ UPDATE tmp.itemInventory it
+ LEFT JOIN tItemInventoryCalc iic ON iic.itemFk = it.id
+ LEFT JOIN tItemVisibleCalc ivc ON ivc.item_id = it.id
+ SET it.inventory = iic.quantity,
+ it.visible = ivc.visible,
+ it.avalaible = iic.quantity,
+ it.sd = iic.quantity;
+
+ -- Calculo del disponible
+ CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc
+ (INDEX (itemFk, warehouseFk))
+ ENGINE = MEMORY
+ SELECT sub.itemFk,
+ vWarehouseFk warehouseFk,
+ sub.dated,
+ SUM(sub.quantity) quantity
+ FROM (
+ SELECT s.itemFk,
+ DATE(t.shipped) dated,
+ - s.quantity quantity
+ FROM sale s
+ JOIN ticket t ON t.id = s.ticketFk
+ JOIN warehouse w ON w.id = t.warehouseFk
+ WHERE t.shipped BETWEEN vDateTomorrow AND vDateTo
+ AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk
+ AND w.isComparative
+ UNION ALL
+ SELECT b.itemFk, t.landed, b.quantity
+ FROM buy b
+ JOIN entry e ON e.id = b.entryFk
+ JOIN travel t ON t.id = e.travelFk
+ JOIN warehouse w ON w.id = t.warehouseInFk
+ WHERE t.landed BETWEEN vDateTomorrow AND vDateTo
+ AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk
+ AND w.isComparative
+ AND NOT e.isExcludedFromAvailable
+ AND NOT t.isRaid
+ UNION ALL
+ SELECT b.itemFk, t.shipped, - b.quantity
+ FROM buy b
+ JOIN entry e ON e.id = b.entryFk
+ JOIN travel t ON t.id = e.travelFk
+ JOIN warehouse w ON w.id = t.warehouseOutFk
+ WHERE t.shipped BETWEEN vDateTomorrow AND vDateTo
+ AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk
+ AND w.isComparative
+ AND NOT e.isExcludedFromAvailable
+ AND NOT t.isRaid
+ ) sub
+ GROUP BY sub.itemFk, sub.dated;
+
+ CALL item_getAtp(vDate);
+ CALL travel_upcomingArrivals(vWarehouseFk, vDate);
+
+ CREATE OR REPLACE TEMPORARY TABLE tItemAvailableCalc
+ (PRIMARY KEY (itemFk))
+ ENGINE = MEMORY
+ SELECT it.itemFk,
+ SUM(it.quantity) quantity,
+ im.quantity minQuantity
+ FROM tmp.itemCalc it
+ JOIN tmp.itemAtp im ON im.itemFk = it.itemFk
+ JOIN item i ON i.id = it.itemFk
+ LEFT JOIN origin o ON o.id = i.originFk
+ LEFT JOIN tmp.itemTravel t ON t.wh = o.warehouseFk
+ WHERE it.dated < IF(vMaxDays < 0 AND t.landing IS NOT NULL,
+ t.landing,
+ vDateToTomorrow)
+ GROUP BY it.itemFk;
+
+ UPDATE tmp.itemInventory it
+ JOIN tItemAvailableCalc iac ON iac.itemFk = it.id
+ SET it.avalaible = IF(iac.minQuantity > 0,
+ it.avalaible,
+ it.avalaible + iac.minQuantity),
+ it.sd = it.inventory + iac.quantity;
+
+ DROP TEMPORARY TABLE
+ tmp.itemTravel,
+ tmp.itemCalc,
+ tmp.itemAtp,
+ tItemInventoryCalc,
+ tItemVisibleCalc,
+ tItemAvailableCalc;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -66055,13 +66661,11 @@ proc: BEGIN
DECLARE vEndingDate DATETIME;
DECLARE vIsTodayRelative BOOLEAN;
- SELECT util.dayEnd(util.VN_CURDATE()) + INTERVAL LEAST(vScopeDays, maxProductionScopeDays) DAY
- INTO vEndingDate
- FROM productionConfig;
-
- SELECT isTodayRelative INTO vIsTodayRelative
- FROM worker
- WHERE id = getUser(); -- Cambiar por account.myUser_getId(), falta dar permisos
+ SELECT w.isTodayRelative, util.dayEnd(util.VN_CURDATE()) + INTERVAL LEAST(vScopeDays, pc.maxProductionScopeDays) DAY
+ INTO vIsTodayRelative,vEndingDate
+ FROM worker w
+ JOIN productionConfig pc
+ WHERE w.id = account.myUser_getId();
CALL prepareTicketList(util.yesterday(), vEndingDate);
@@ -66259,7 +66863,7 @@ proc: BEGIN
st.code = 'previousPrepared' isPreviousPrepared,
sc.itemPackingTypeFk
FROM itemShelving ish
- JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector sc ON sc.id = p.sectorFk
JOIN sectorType st ON st.id = sc.typeFk
@@ -66308,15 +66912,14 @@ proc: BEGIN
UPDATE tmp.productionBuffer pb
JOIN sale s ON s.ticketFk = pb.ticketFk
JOIN item i ON i.id = s.itemFk
- JOIN cache.last_buy lb ON lb.warehouse_id = vWarehouseFk
+ JOIN cache.last_buy lb ON lb.warehouse_id = vWarehouseFk
AND lb.item_id = s.itemFk
JOIN buy b ON b.id = lb.buy_id
JOIN packaging p ON p.id = b.packagingFk
- JOIN productionConfig pc
SET pb.hasPlantTray = TRUE
WHERE p.isPlantTray
AND s.quantity >= b.packing
- AND pb.isOwn;
+ AND pb.isOwn;
DROP TEMPORARY TABLE
tmp.productionTicket,
@@ -66691,7 +67294,7 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `raidUpdate` */;
+/*!50003 DROP PROCEDURE IF EXISTS `queueMember_updateQueue` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -66699,34 +67302,31 @@ DELIMITER ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
-CREATE DEFINER=`vn`@`localhost` PROCEDURE `raidUpdate`()
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `queueMember_updateQueue`(
+ vBusinessFk INT
+)
BEGIN
-/**
- * Actualiza el travel de las entradas de redadas
- */
- UPDATE entry e
- JOIN entryVirtual ev ON ev.entryFk = e.id
- JOIN travel t ON t.id = e.travelFk
- JOIN (
- SELECT *
- FROM (
- SELECT t.id, t.landed, tt.warehouseInFk, tt.warehouseOutFk
- FROM travel t
- JOIN (
- SELECT t.warehouseInFk, t.warehouseOutFk
- FROM entryVirtual ev
- JOIN entry e ON e.id = ev.entryFk
- JOIN travel t ON t.id = e.travelFk
- GROUP BY t.warehouseInFk, t.warehouseOutFk
- ) tt ON t.warehouseInFk = tt.warehouseInFk AND t.warehouseOutFk = tt.warehouseOutFk
- WHERE shipped > util.VN_CURDATE() AND NOT isDelivered
- ORDER BY t.landed
- LIMIT 10000000000000000000
- ) t
- GROUP BY t.warehouseInFk, t.warehouseOutFk
- ) tt ON t.warehouseInFk = tt.warehouseInFk AND t.warehouseOutFk = tt.warehouseOutFk
- SET e.travelFk = t.id;
+ /**
+ * Elimina la entrada de la cola anterior y luego inserta la nueva para un trabajador.
+ *
+ * @param vBusinessFk ID del negocio
+ */
+ DECLARE vNewQueue VARCHAR(10);
+ DECLARE vExtension VARCHAR(10);
+ DECLARE exit handler FOR SQLEXCEPTION
+ SELECT d.pbxQueue, s.extension
+ INTO vNewQueue, vExtension
+ FROM business b
+ JOIN department d ON d.id = b.departmentFk
+ JOIN pbx.sip s ON s.user_id = b.workerFk
+ WHERE b.id = vBusinessFk;
+
+ DELETE FROM pbx.queueMember
+ WHERE extension = vExtension COLLATE utf8_general_ci;
+
+ INSERT IGNORE INTO pbx.queueMember (queue, extension)
+ VALUES (vNewQueue, vExtension);
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -67304,7 +67904,7 @@ BEGIN
rm.ticketFree = 0,
rm.ticketProduction = 0,
rm.ticketPacked = 0,
- rm.dated = r.created;
+ rm.dated = r.dated;
UPDATE routesMonitor rm
JOIN (
@@ -67461,8 +68061,10 @@ BEGIN
*/
DECLARE vIsUpdatable, vIsFreelance BOOL DEFAULT 0;
DECLARE vAgencyModePricePercentage DOUBLE;
+ DECLARE vIsKmTruckRate BOOL;
+ DECLARE vCountryFk INT;
- SELECT r.created >= rc.cutoffDated INTO vIsUpdatable
+ SELECT r.dated >= rc.cutoffDated INTO vIsUpdatable
FROM route r
JOIN routeConfig rc
WHERE r.id = vSelf;
@@ -67471,10 +68073,17 @@ BEGIN
DELETE FROM routeCommission
WHERE routeFk = vSelf;
- SELECT w.isFreelance INTO vIsFreelance
+ SELECT w.isFreelance, v.isKmTruckRate, p.countryFk INTO vIsFreelance, vIsKmTruckRate, vCountryFk
FROM route r
JOIN worker w ON w.id = r.workerFk
- WHERE r.id = vSelf;
+ JOIN vehicle v ON v.id = r.vehicleFk
+ LEFT JOIN ticket t ON t.routeFk = r.id
+ LEFT JOIN address a ON a.id = t.addressFk
+ LEFT JOIN province p ON p.id = a.provinceFk
+ WHERE r.id = vSelf
+ GROUP BY p.countryFk
+ ORDER BY COUNT(*) DESC
+ LIMIT 1;
SELECT ampp.percentage INTO vAgencyModePricePercentage
FROM route r
@@ -67489,7 +68098,9 @@ BEGIN
workCenterFk,
freelanceYearlyM3,
cat4m3,
- cat5m3
+ cat5m3,
+ isKmTruckRate,
+ countryFk
)
SELECT vSelf,
r.commissionWorkCenterFk,
@@ -67501,11 +68112,14 @@ BEGIN
IFNULL(r.m3, 0),
0
),
- rc.distributionCat4M3 * IFNULL(r.m3, 0),
- rc.distributionCat5M3 * IFNULL(r.m3, 0)
+ IFNULL(wc.distributionCat4M3, rc.distributionCat4M3) * IFNULL(r.m3, 0),
+ IFNULL(wc.distributionCat5M3, rc.distributionCat5M3) * IFNULL(r.m3, 0),
+ vIsKmTruckRate,
+ vCountryFk
FROM route r
JOIN vehicle v ON v.id = r.vehicleFk
JOIN routeConfig rc
+ LEFT JOIN workCenterCommission wc ON wc.workCenterFk = r.commissionWorkCenterFk
WHERE r.id = vSelf
AND r.workerFk
AND r.commissionWorkCenterFk;
@@ -67518,21 +68132,28 @@ BEGIN
yearlyKm,
yearlyM3,
cat4m3,
- cat5m3
+ cat5m3,
+ isKmTruckRate,
+ countryFk
)
SELECT vSelf,
r.commissionWorkCenterFk,
(r.kmEnd - r.kmStart) *
IF(v.isKmTruckRate, rc.kmHeavy, rc.kmLight),
IFNULL(r.m3, 0) *
- IF(v.isKmTruckRate, rc.deliveryM3Cat5, rc.deliveryM3Cat4),
+ IF(v.isKmTruckRate,
+ IFNULL(wc.deliveryM3Cat5, rc.deliveryM3Cat5),
+ IFNULL(wc.deliveryM3Cat4, rc.deliveryM3Cat4)),
(r.kmEnd - r.kmStart) * rc.kmYearly,
IFNULL(r.m3, 0) * rc.m3Yearly,
- rc.distributionCat4M3 * IFNULL(r.m3, 0),
- rc.distributionCat5M3 * IFNULL(r.m3, 0)
+ IFNULL(wc.distributionCat4M3, rc.distributionCat4M3) * IFNULL(r.m3, 0),
+ IFNULL(wc.distributionCat5M3, rc.distributionCat5M3) * IFNULL(r.m3, 0),
+ vIsKmTruckRate,
+ vCountryFk
FROM route r
JOIN vehicle v ON v.id = r.vehicleFk
JOIN routeConfig rc
+ LEFT JOIN workCenterCommission wc ON wc.workCenterFk = r.commissionWorkCenterFk
WHERE r.id = vSelf
AND r.kmStart
AND r.kmEnd
@@ -68192,6 +68813,39 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `saleTracking_sectorCollectionAddPrevOK` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `saleTracking_sectorCollectionAddPrevOK`(
+ vSectorCollectionFk INT
+)
+BEGIN
+/**
+ * Inserta los registros de sectorCollection con el estado PREVIA OK si la reserva está picked
+ *
+ * @param vSectorCollectionFk Identificador de vn.sectorCollection
+ */
+ REPLACE saleTracking(saleFk, isChecked, workerFk, stateFk)
+ SELECT sgd.saleFk, TRUE, sc.userFk, s.id
+ FROM sectorCollection sc
+ JOIN sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id
+ JOIN saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk
+ JOIN state s ON s.code = 'OK PREVIOUS'
+ JOIN itemShelvingSale iss ON iss.saleFk = sgd.saleFk
+ WHERE sc.id = vSectorCollectionFk AND iss.isPicked;
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `saleTracking_updateIsChecked` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -68268,7 +68922,7 @@ BEGIN
DECLARE vQuantity INT;
DECLARE vRemainder INT DEFAULT 0;
DECLARE vRemainderSaleFk INT;
- DECLARE vShelving VARCHAR(10);
+ DECLARE vShelvingFk VARCHAR(10);
DECLARE vTicketFk INT;
SELECT s.quantity,
@@ -68315,7 +68969,7 @@ w1: WHILE vQuantity >= vPacking DO
p.pickingOrder,
ish.created
FROM itemShelving ish
- JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
LEFT JOIN itemShelvingSale iss
ON iss.itemShelvingFk = ish.id
@@ -68503,9 +69157,9 @@ w1: WHILE vQuantity >= vPacking DO
CALL dipole.expedition_Add(vExpeditionFk,vPrinterFk, TRUE);
SELECT shelvingFk, p.code
- INTO vShelving, vParkingCode
+ INTO vShelvingFk, vParkingCode
FROM itemShelving ish
- JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
WHERE ish.id = vItemShelvingFk;
@@ -68514,7 +69168,7 @@ w1: WHILE vQuantity >= vPacking DO
itemFk = vItemFk,
quantity = vPacking,
longName = vConcept,
- shelvingFk = vShelving,
+ shelvingFk = vShelvingFk,
parkingCode = vParkingCode,
phone = RIGHT(phone,vMaxPhoneLength),
street = RIGHT(street, vMAxStreetLength)
@@ -68616,7 +69270,7 @@ BEGIN
AND iss.created >= vDated
GROUP BY iss.itemShelvingFk, s.itemFk) tISS
ON tISS.itemFk = ish.itemFk AND tISS.itemShelvingFk = ish.id
- JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN tmp.productionBuffer pb ON pb.ticketFk = s.ticketFk
JOIN agencyMode am ON am.id = pb.agencyModeFk
@@ -68834,7 +69488,7 @@ BEGIN
isTooLittle BOOL DEFAULT FALSE,
isVip BOOL DEFAULT FALSE,
PRIMARY KEY (ticketFk, saleFk)
- ) ENGINE = MEMORY;
+ ); -- No memory
INSERT INTO tmp.sale_problems(ticketFk,
saleFk,
@@ -68881,7 +69535,7 @@ BEGIN
SUM(ish.visible) visible,
s.warehouseFk warehouseFk
FROM itemShelving ish
- JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector s ON s.id = p.sectorFk
GROUP BY ish.itemFk, s.warehouseFk;
@@ -68921,7 +69575,7 @@ BEGIN
LEFT JOIN tItemShelvingStock_byWarehouse issw ON issw.itemFk = i.id
AND issw.warehouseFk = t.warehouseFk
WHERE IFNULL(v.visible, 0) < s.quantity
- AND IFNULL(av.available, 0) < s.quantity
+ AND IFNULL(av.available, 0) < 0
AND IFNULL(issw.visible, 0) < s.quantity
AND NOT s.isPicked
AND NOT s.reserved
@@ -68984,7 +69638,7 @@ BEGIN
LEFT JOIN tItemShelvingStock_byWarehouse issw ON issw.itemFk = i.id
AND issw.warehouseFk = t.warehouseFk
WHERE IFNULL(v.visible, 0) < s.quantity
- AND IFNULL(av.available, 0) >= s.quantity
+ AND IFNULL(av.available, 0) >= 0
AND IFNULL(issw.visible, 0) < s.quantity
AND s.quantity > 0
AND NOT s.isPicked
@@ -69909,14 +70563,16 @@ DELIMITER ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
-CREATE DEFINER=`vn`@`localhost` PROCEDURE `shelvingChange`(IN `vShelvingO` VARCHAR(8), IN `vShelvingD` VARCHAR(8))
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `shelvingChange`(
+ `vShelvingO` VARCHAR(10),
+ `vShelvingD` VARCHAR(10)
+)
BEGIN
-
- UPDATE vn.itemShelving
- SET shelvingFk = vShelvingD COLLATE utf8_unicode_ci
- WHERE shelvingFk = vShelvingO COLLATE utf8_unicode_ci;
-
-
+ UPDATE itemShelving ish
+ JOIN shelving sh1 ON sh1.code = vShelvingD COLLATE utf8_unicode_ci
+ JOIN shelving sh2 ON sh2.code = vShelvingO COLLATE utf8_unicode_ci
+ SET ish.shelvingFk = sh1.id
+ WHERE ish.shelvingFk = sh2.id;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -69964,10 +70620,12 @@ DELIMITER ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
-CREATE DEFINER=`vn`@`localhost` PROCEDURE `shelvingParking_get`(vShelvingFk VARCHAR(10), vWarehouseFk INT, vDayRange INT)
-BEGIN
-
-
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `shelvingParking_get`(
+ vShelvingCode VARCHAR(10),
+ vWarehouseFk INT,
+ vDayRange INT
+)
+BEGIN
SELECT s.itemFk,
s.concept,
CAST(SUM(s.quantity) AS DECIMAL(10,0)) as sinServir,
@@ -69975,15 +70633,16 @@ SELECT s.itemFk,
FROM vn.sale s
LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id
JOIN vn.ticket t ON t.id = s.ticketFk
- LEFT JOIN vn.itemShelvingStock ist ON ist.itemFk = s.itemFk AND ist.warehouseFk = vWarehouseFk
- JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk AND ish.shelvingFk = vShelvingFk COLLATE utf8_general_ci
+ LEFT JOIN vn.itemShelvingStock ist ON ist.itemFk = s.itemFk
+ AND ist.warehouseFk = vWarehouseFk
+ JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
+ AND sh.code = vShelvingCode COLLATE utf8_general_ci
WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(TIMESTAMPADD(DAY, GREATEST(0,vDayRange), util.VN_CURDATE()))
AND iss.saleFk IS NULL
AND t.warehouseFk = vWarehouseFk
GROUP BY s.itemFk
HAVING sinServir > aparcado;
-
-
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -70034,12 +70693,12 @@ BEGIN
DELETE ish.*
FROM itemShelving ish
- JOIN vn.shelving sh ON sh.code = ish.shelvingFk
+ JOIN vn.shelving sh ON sh.id = ish.shelvingFk
WHERE sh.parkingFk IS NULL
AND ish.created < TIMESTAMPADD(WEEK,-1,util.VN_CURDATE());
UPDATE shelving sh
- LEFT JOIN itemShelving its ON its.shelvingFk = sh.`code`
+ LEFT JOIN itemShelving its ON its.shelvingFk = sh.id
SET isPrinted = 0,
parkingFk = NULL
WHERE its.id IS NULL
@@ -70049,11 +70708,11 @@ UPDATE shelving sh
OR
sh.parked < util.VN_CURDATE() - INTERVAL 2 WEEK
)
-
AND IF(code REGEXP '^[A-Za-z]{2}[0-9]', LEFT (code, 2) NOT IN (
- SELECT DISTINCT LEFT(its.shelvingFk, 2)
+ SELECT DISTINCT LEFT(sh.code, 2)
FROM itemShelving its
- WHERE its.shelvingFk REGEXP '^[A-Za-z]{2}[0-9]'
+ JOIN shelving sh ON sh.id = its.shelvingFk
+ WHERE sh.code REGEXP '^[A-Za-z]{2}[0-9]'
), TRUE);
END ;;
@@ -70098,7 +70757,7 @@ BEGIN
LEFT JOIN (
SELECT ish.itemFk, CAST(SUM(ish.visible) AS DECIMAL(10,0)) AS reserva
FROM vn.itemShelving ish
- JOIN vn.shelving sh ON sh.code = ish.shelvingFk
+ JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
JOIN vn.sector s ON s.id = p.sectorFk
WHERE s.code = 'FUENTES_PICASSE'
@@ -70141,7 +70800,7 @@ BEGIN
sh.isSpam
FROM vn.itemShelving ish
JOIN vn.item i ON i.id = ish.itemFk
- JOIN vn.shelving sh ON sh.code = ish.shelvingFk
+ JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
JOIN vn.sector s ON s.id = p.sectorFk
JOIN vn.warehouse w ON w.id = s.warehouseFk
@@ -70238,13 +70897,13 @@ proc: BEGIN
* Calculate the stock of the auction warehouse from the inventory date to vDated
* without taking into account the outputs of the same day vDated
*
- * @param vDated Date to calculate the stock.
+ * @param vDated Date to calculate the stock
*/
IF vDated < util.VN_CURDATE() THEN
LEAVE proc;
END IF;
- CREATE OR REPLACE TEMPORARY TABLE tStockBought
+ CREATE OR REPLACE TEMPORARY TABLE tCurrentData
SELECT workerFk, reserve
FROM stockBought
WHERE dated = vDated
@@ -70252,15 +70911,28 @@ proc: BEGIN
DELETE FROM stockBought WHERE dated = vDated;
+ CREATE OR REPLACE TEMPORARY TABLE tStockSold
+ SELECT it.workerFk,
+ SUM(ic.cm3 * ito.quantity / vc.palletM3 / 1000000) sold
+ FROM itemTicketOut ito
+ JOIN item i ON i.id = ito.itemFk
+ JOIN itemType it ON it.id = i.typeFk
+ JOIN ticket t ON t.id = ito.ticketFk
+ JOIN warehouse wh ON wh.id = t.warehouseFk
+ JOIN itemCost ic ON ic.itemFk = ito.itemFk
+ AND ic.warehouseFk = t.warehouseFk
+ JOIN volumeConfig vc
+ WHERE ito.shipped BETWEEN vDated AND util.dayEnd(vDated)
+ AND wh.code = 'VNH'
+ GROUP BY it.workerFk;
+
CALL item_calculateStock(vDated);
- INSERT INTO stockBought(workerFk, bought, dated)
+ CREATE OR REPLACE TEMPORARY TABLE tStockBought
SELECT it.workerFk,
- ROUND(SUM(
- (ti.quantity / b.packing) *
- buy_getVolume(b.id)
- ) / vc.palletM3 / 1000000, 1) bought,
- vDated
+ SUM((ti.quantity / b.packing) *
+ buy_getVolume(b.id)
+ ) / vc.palletM3 / 1000000 bought
FROM itemType it
JOIN item i ON i.typeFk = it.id
LEFT JOIN tmp.item ti ON ti.itemFk = i.id
@@ -70274,21 +70946,34 @@ proc: BEGIN
GROUP BY it.workerFk
HAVING bought;
+
+ INSERT INTO stockBought(workerFk, bought, dated)
+ SELECT tb.workerFk,
+ ROUND(GREATEST(tb.bought - IFNULL(ts.sold, 0), 0), 2),
+ vDated
+ FROM tStockBought tb
+ LEFT JOIN tStockSold ts ON ts.workerFk = tb.workerFk;
+
UPDATE stockBought s
- JOIN tStockBought ts ON ts.workerFk = s.workerFk
+ JOIN tCurrentData ts ON ts.workerFk = s.workerFk
SET s.reserve = ts.reserve
WHERE s.dated = vDated;
INSERT INTO stockBought (workerFk, reserve, dated)
SELECT ts.workerFk, ts.reserve, vDated
- FROM tStockBought ts
+ FROM tCurrentData ts
WHERE ts.workerFk NOT IN (
SELECT workerFk
FROM stockBought
WHERE dated = vDated
);
- DROP TEMPORARY TABLE tStockBought, tmp.item, tmp.buyUltimate;
+ UPDATE stockBought s
+ JOIN tStockSold ts ON ts.workerFk = s.workerFk
+ SET s.bought = IF(s.bought < ABS(ts.sold), 0, ROUND(s.bought - ABS(ts.sold), 1))
+ WHERE s.dated = vDated;
+
+ DROP TEMPORARY TABLE tCurrentData, tmp.item, tmp.buyUltimate, tStockSold;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -70329,7 +71014,7 @@ BEGIN
WHERE dated = vDated
AND userFk = vWorker;
- CALL stockTraslation(vDated);
+ CALL item_calculateStock(vDated);
INSERT INTO stockBuyed(userFk, buyed, `dated`, reserved, requested, description)
SELECT it.workerFk,
@@ -70411,7 +71096,7 @@ BEGIN
DELETE FROM stockBuyed WHERE dated = vDated;
- CALL stockTraslation(vDated);
+ CALL item_calculateStock(vDated);
INSERT INTO stockBuyed(userFk, buyed, `dated`, description)
SELECT it.workerFk,
@@ -70467,60 +71152,6 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `stockTraslation` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`vn`@`localhost` PROCEDURE `stockTraslation`(
- vDated DATE
-)
-BEGIN
-/**
- * Calcula el stock del almacén de subasta desde FechaInventario hasta vDated
- * sin tener en cuenta las salidas del mismo dia vDated
- * para ver el transporte a reservar
- *
- * @param vDated Fecha hasta la cual calcula el stock
- * @return tmp.item
- */
- DECLARE vAuctionWarehouseFk INT;
-
- SELECT warehouseFk INTO vAuctionWarehouseFk
- FROM auctionConfig;
-
- CREATE OR REPLACE TEMPORARY TABLE tmp.item
- (UNIQUE INDEX i USING HASH (itemFk))
- ENGINE = MEMORY
- SELECT itemFk, SUM(quantity) quantity
- FROM itemEntryIn
- WHERE landed = vDated
- AND vDated >= util.VN_CURDATE()
- AND warehouseInFk = vAuctionWarehouseFk
- AND NOT isVirtualStock
- GROUP BY itemFk
- HAVING quantity;
-
- CALL `cache`.stock_refresh(FALSE);
-
- INSERT INTO tmp.item (itemFk, quantity)
- SELECT item_id, amount
- FROM `cache`.stock
- WHERE warehouse_id = vAuctionWarehouseFk
- ON DUPLICATE KEY UPDATE quantity = tmp.item.quantity + VALUES(quantity);
-
- CALL buy_getUltimate(NULL, vAuctionWarehouseFk, vDated);
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `subordinateGetList` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71712,7 +72343,7 @@ BEGIN
JOIN vn.sale s ON s.ticketFk = t.id
JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id
JOIN vn.itemShelving ish ON ish.id = iss.itemShelvingFk
- JOIN vn.shelving sh ON sh.code = ish.shelvingFk
+ JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
WHERE p.sectorFk = vSectorFk
) sub ON sub.id = td.ticketFk
@@ -72250,6 +72881,44 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `ticketRefund_upsert` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticketRefund_upsert`(
+ vRefundTicketFk INT,
+ vOriginalTicketFk INT
+)
+ READS SQL DATA
+BEGIN
+/**
+ * Common code for ticketRefund triggers
+ *
+ * @param vRefundTicketFk
+ * @param vOriginalTicketFk
+ */
+ DECLARE vIsDeleted BOOL;
+
+ SELECT COUNT(*) INTO vIsDeleted
+ FROM ticket
+ WHERE id IN (vRefundTicketFk, vOriginalTicketFk)
+ AND isDeleted;
+
+ IF vIsDeleted THEN
+ CALL util.throw('The refund ticket cannot be deleted tickets');
+ END IF;
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticketStateToday_setState` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -72655,7 +73324,8 @@ BEGIN
origin.companyFk futureCompanyFk,
IFNULL(dest.nickname, origin.nickname) nickname,
dest.landed,
- dest.preparation
+ dest.preparation,
+ origin.departmentFk
FROM (
SELECT s.ticketFk,
c.salesPersonFk workerFk,
@@ -72675,9 +73345,11 @@ BEGIN
t.addressFk,
t.warehouseFk,
t.companyFk,
- t.agencyModeFk
+ t.agencyModeFk,
+ wd.departmentFk
FROM ticket t
JOIN client c ON c.id = t.clientFk
+ JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk
JOIN sale s ON s.ticketFk = t.id
JOIN saleVolume sv ON sv.saleFk = s.id
JOIN item i ON i.id = s.itemFk
@@ -73394,7 +74066,7 @@ BEGIN
c.isTaxDataChecked,
t.companyFk,
t.shipped,
- IFNULL(a.hasDailyInvoice, co.hasDailyInvoice),
+ c.hasDailyInvoice,
w.isManaged,
c.hasToInvoice
INTO vClientFk,
@@ -73406,9 +74078,6 @@ BEGIN
vHasToInvoice
FROM ticket t
JOIN `client` c ON c.id = t.clientFk
- JOIN province p ON p.id = c.provinceFk
- LEFT JOIN autonomy a ON a.id = p.autonomyFk
- JOIN country co ON co.id = p.countryFk
JOIN warehouse w ON w.id = t.warehouseFk
WHERE t.id = vCurTicketFk;
@@ -73436,7 +74105,7 @@ BEGIN
IF(vHasDailyInvoice) AND vHasToInvoice THEN
SELECT invoiceSerial(vClientFk, vCompanyFk, 'quick') INTO vSerial;
- IF vSerial IS NULL THEN
+ IF vSerial IS NULL THEN
CALL util.throw('Cannot booking without a serial');
END IF;
@@ -73815,7 +74484,7 @@ BEGIN
SUM(ish.visible) visible,
s.warehouseFk warehouseFk
FROM itemShelving ish
- JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector s ON s.id = p.sectorFk
GROUP BY ish.itemFk,
@@ -74257,7 +74926,7 @@ BEGIN
SUM(ish.visible) visible,
s.warehouseFk warehouseFk
FROM itemShelving ish
- JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector s ON s.id = p.sectorFk
GROUP BY ish.itemFk,
@@ -74401,7 +75070,9 @@ DELIMITER ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
-CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_getTax`(IN vTaxArea VARCHAR(25))
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_getTax`(
+ vTaxArea VARCHAR(25)
+)
BEGIN
/**
* Calcula la base imponible, el IVA y el recargo de equivalencia para
@@ -74435,30 +75106,39 @@ BEGIN
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketTax
(PRIMARY KEY (ticketFk, code, rate))
ENGINE = MEMORY
- SELECT * FROM (
- SELECT tmpTicket.ticketFk,
- bp.pgcFk,
- SUM(s.quantity * s.price * (100 - s.discount) / 100 ) taxableBase,
- pgc.rate,
- tc.code,
- bp.priority
- FROM tmp.ticket tmpTicket
- JOIN sale s ON s.ticketFk = tmpTicket.ticketFk
- JOIN item i ON i.id = s.itemFk
- JOIN ticket t ON t.id = tmpTicket.ticketFk
- JOIN supplier su ON su.id = t.companyFk
+ WITH sales AS (
+ SELECT s.ticketFk,
+ s.itemFk,
+ s.quantity * s.price * (100 - s.discount) / 100 total,
+ t.companyFk,
+ t.addressFk,
+ su.countryFk,
+ ata.areaFk,
+ itc.taxClassFk
+ FROM vn.sale s
+ JOIN tmp.ticket tmp ON tmp.ticketFk = s.ticketFk
+ JOIN vn.ticket t ON t.id = s.ticketFk
+ JOIN vn.supplier su ON su.id = t.companyFk
JOIN tmp.addressTaxArea ata ON ata.addressFk = t.addressFk
AND ata.companyFk = t.companyFk
- JOIN itemTaxCountry itc ON itc.itemFk = i.id
+ JOIN vn.itemTaxCountry itc ON itc.itemFk = s.itemFk
AND itc.countryFk = su.countryFk
- JOIN bookingPlanner bp ON bp.countryFk = su.countryFk
- AND bp.taxAreaFk = ata.areaFk
- AND bp.taxClassFk = itc.taxClassFk
- JOIN pgc ON pgc.code = bp.pgcFk
- JOIN taxClass tc ON tc.id = bp.taxClassFk
- GROUP BY tmpTicket.ticketFk, pgc.code, pgc.rate
- HAVING taxableBase
- ) t3
+ HAVING total
+ )
+ SELECT s.ticketFk,
+ bp.pgcFk,
+ SUM(s.total) taxableBase,
+ pgc.rate,
+ tc.code,
+ bp.priority
+ FROM sales s
+ JOIN vn.bookingPlanner bp ON bp.countryFk = s.countryFk
+ AND bp.taxAreaFk = s.areaFk
+ AND bp.taxClassFk = s.taxClassFk
+ JOIN vn.pgc ON pgc.code = bp.pgcFk
+ JOIN vn.taxClass tc ON tc.id = bp.taxClassFk
+ GROUP BY s.ticketFk, pgc.code, pgc.rate
+ HAVING taxableBase
ORDER BY priority;
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketServiceTax
@@ -74681,12 +75361,25 @@ CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_mergeSales`(
vSelf INT
)
BEGIN
+/**
+ * Para un ticket se agrupa las diferentes líneas de venta de un mismo artículo en una sola
+ * siempre y cuando tengan el mismo precio y dto.
+ *
+ * @param vSelf Id de ticket
+ */
+ DECLARE vHasSalesToMerge BOOL;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
RESIGNAL;
END;
+ START TRANSACTION;
+
+ SELECT id INTO vSelf
+ FROM ticket
+ WHERE id = vSelf FOR UPDATE;
+
CREATE OR REPLACE TEMPORARY TABLE tSalesToPreserve
(PRIMARY KEY (id))
ENGINE = MEMORY
@@ -74696,26 +75389,24 @@ BEGIN
JOIN itemType it ON it.id = i.typeFk
WHERE s.ticketFk = vSelf
AND it.isMergeable
- GROUP BY s.itemFk, s.price, s.discount;
+ GROUP BY s.itemFk, s.price, s.discount
+ HAVING COUNT(*) > 1;
- START TRANSACTION;
+ SELECT COUNT(*) INTO vHasSalesToMerge FROM tSalesToPreserve;
- UPDATE sale s
- JOIN tSalesToPreserve stp ON stp.id = s.id
- SET s.quantity = newQuantity
- WHERE s.ticketFk = vSelf;
+ IF vHasSalesToMerge THEN
+ UPDATE sale s
+ JOIN tSalesToPreserve stp ON stp.id = s.id
+ SET s.quantity = newQuantity;
- DELETE s.*
- FROM sale s
- LEFT JOIN tSalesToPreserve stp ON stp.id = s.id
- JOIN item i ON i.id = s.itemFk
- JOIN itemType it ON it.id = i.typeFk
- WHERE s.ticketFk = vSelf
- AND stp.id IS NULL
- AND it.isMergeable;
+ DELETE s
+ FROM sale s
+ JOIN tSalesToPreserve stp ON stp.itemFk = s.itemFk
+ WHERE s.ticketFk = vSelf
+ AND s.id <> stp.id;
+ END IF;
COMMIT;
-
DROP TEMPORARY TABLE tSalesToPreserve;
END ;;
DELIMITER ;
@@ -75858,123 +76549,123 @@ CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_splitItemPackingType`(
)
BEGIN
/**
- * Clona y reparte las ventas de un ticket en funcion del tipo de empaquetado.
- * Respeta el id inicial para el tipo propuesto.
+ * Separa en diferentes tickets según el tipo de empaquetado
+ * El ticket original conserva las líneas del tipo de empaquetado especificado
+ * Las líneas sin tipo de empaquetado se asignan al ticket del tipo por defecto.
*
- * @param vSelf Id ticket
- * @param vOriginalItemPackingTypeFk Tipo para el que se reserva el número de ticket original
+ * @param vSelf Id del ticket original
+ * @param vOriginalItemPackingTypeFk Tipo de empaquetado a mantener en el ticket original
* @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk)
*/
- DECLARE vItemPackingTypeFk VARCHAR(1) DEFAULT 'H';
+ DECLARE vIsDone BOOLEAN DEFAULT FALSE;
+ DECLARE vCurrentPackingType VARCHAR(1);
+ DECLARE vDefaultPackingType VARCHAR(1);
+ DECLARE vHasOriginalPackingType BOOLEAN;
DECLARE vNewTicketFk INT;
- DECLARE vPackingTypesToSplit INT;
- DECLARE vDone INT DEFAULT FALSE;
+ DECLARE vTicketFk INT;
- DECLARE vSaleGroup CURSOR FOR
- SELECT itemPackingTypeFk
- FROM tSaleGroup
- WHERE itemPackingTypeFk IS NOT NULL
- ORDER BY (itemPackingTypeFk = vOriginalItemPackingTypeFk) DESC;
+ DECLARE vItemPackingTypes CURSOR FOR
+ SELECT DISTINCT itemPackingTypeFk FROM tSalesToMove;
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE;
+
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ ROLLBACK;
+ RESIGNAL;
+ END;
+
+ CREATE OR REPLACE TEMPORARY TABLE tSalesToMove (
+ ticketFk INT,
+ saleFk INT,
+ itemPackingTypeFk VARCHAR(1)
+ ) ENGINE=MEMORY;
+
+ SELECT COALESCE(MAX(ic.defaultPackingTypeFk), MAX(i.itemPackingTypeFk)) INTO vDefaultPackingType
+ FROM vn.sale s
+ JOIN item i ON i.id = s.itemFk
+ LEFT JOIN itemConfig ic ON ic.defaultPackingTypeFk = i.itemPackingTypeFk
+ WHERE s.ticketFk = vSelf
+ GROUP BY s.ticketFk;
+
+ SELECT EXISTS (
+ SELECT TRUE
+ FROM sale s
+ JOIN item i ON i.id = s.itemFk
+ WHERE s.ticketFk = vSelf
+ AND i.itemPackingTypeFk = vOriginalItemPackingTypeFk
+ ) INTO vHasOriginalPackingType;
+
+ IF vOriginalItemPackingTypeFk IS NULL OR NOT vHasOriginalPackingType THEN
+ SET vOriginalItemPackingTypeFk = vDefaultPackingType;
+ END IF;
START TRANSACTION;
- SELECT id
- FROM sale
- WHERE ticketFk = vSelf
- AND NOT quantity
+ SELECT t.id INTO vTicketFk
+ FROM ticket t
+ JOIN sale s ON s.id = t.id
+ WHERE t.id = vSelf
FOR UPDATE;
- DELETE FROM sale
- WHERE NOT quantity
- AND ticketFk = vSelf;
-
- CREATE OR REPLACE TEMPORARY TABLE tSale
- (PRIMARY KEY (id))
- ENGINE = MEMORY
- SELECT s.id, i.itemPackingTypeFk, IFNULL(sv.litros, 0) litros
+ INSERT INTO tSalesToMove (saleFk, itemPackingTypeFk)
+ SELECT s.id, i.itemPackingTypeFk
FROM sale s
JOIN item i ON i.id = s.itemFk
- LEFT JOIN saleVolume sv ON sv.saleFk = s.id
- WHERE s.ticketFk = vSelf;
+ WHERE s.ticketFk = vSelf
+ AND i.itemPackingTypeFk <> vOriginalItemPackingTypeFk;
- CREATE OR REPLACE TEMPORARY TABLE tSaleGroup
- ENGINE = MEMORY
- SELECT itemPackingTypeFk, SUM(litros) totalLitros
- FROM tSale
- GROUP BY itemPackingTypeFk;
+ OPEN vItemPackingTypes;
+ l: LOOP
+ SET vIsDone = FALSE;
+ FETCH vItemPackingTypes INTO vCurrentPackingType;
- SELECT COUNT(*) INTO vPackingTypesToSplit
- FROM tSaleGroup
- WHERE itemPackingTypeFk IS NOT NULL;
+ IF vIsDone THEN
+ LEAVE l;
+ END IF;
- CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT(
- ticketFk INT,
- itemPackingTypeFk VARCHAR(1)
- ) ENGINE = MEMORY;
+ CALL ticket_Clone(vSelf, vNewTicketFk);
- CASE vPackingTypesToSplit
- WHEN 0 THEN
- INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk)
- VALUES(vSelf, vItemPackingTypeFk);
- WHEN 1 THEN
- INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk)
- SELECT vSelf, itemPackingTypeFk
- FROM tSaleGroup
- WHERE itemPackingTypeFk IS NOT NULL;
- ELSE
- OPEN vSaleGroup;
- FETCH vSaleGroup INTO vItemPackingTypeFk;
+ SELECT id INTO vTicketFk
+ FROM ticket t
+ WHERE t.id = vNewTicketFk
+ FOR UPDATE;
- INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk)
- VALUES(vSelf, vItemPackingTypeFk);
+ UPDATE tSalesToMove
+ SET ticketFk = vNewTicketFk
+ WHERE itemPackingTypeFk = vCurrentPackingType;
- l: LOOP
- SET vDone = FALSE;
- FETCH vSaleGroup INTO vItemPackingTypeFk;
+ IF vCurrentPackingType = vDefaultPackingType THEN
+ INSERT INTO tSalesToMove (ticketFk, saleFk, itemPackingTypeFk)
+ SELECT vNewTicketFk, s.id, i.itemPackingTypeFk
+ FROM sale s
+ JOIN item i ON i.id = s.itemFk
+ WHERE s.ticketFk = vSelf
+ AND i.itemPackingTypeFk IS NULL;
+ END IF;
- IF vDone THEN
- LEAVE l;
- END IF;
+ END LOOP;
+ CLOSE vItemPackingTypes;
- CALL ticket_Clone(vSelf, vNewTicketFk);
+ UPDATE sale s
+ JOIN tSalesToMove t ON t.saleFk = s.id
+ SET s.ticketFk = t.ticketFk;
- INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk)
- VALUES(vNewTicketFk, vItemPackingTypeFk);
- END LOOP;
-
- CLOSE vSaleGroup;
-
- SELECT s.id
- FROM sale s
- JOIN tSale ts ON ts.id = s.id
- JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk
- FOR UPDATE;
-
- UPDATE sale s
- JOIN tSale ts ON ts.id = s.id
- JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk
- SET s.ticketFk = t.ticketFk;
-
- SELECT itemPackingTypeFk INTO vItemPackingTypeFk
- FROM tSaleGroup sg
- WHERE sg.itemPackingTypeFk IS NOT NULL
- ORDER BY sg.itemPackingTypeFk
- LIMIT 1;
-
- UPDATE sale s
- JOIN tSale ts ON ts.id = s.id
- JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = vItemPackingTypeFk
- SET s.ticketFk = t.ticketFk
- WHERE ts.itemPackingTypeFk IS NULL;
- END CASE;
+ CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT
+ ENGINE=MEMORY
+ SELECT s.ticketFk, MAX(i.itemPackingTypeFk) itemPackingTypeFk
+ FROM sale s
+ JOIN item i ON i.id = s.itemFk
+ WHERE s.ticketFk = vSelf
+ GROUP BY s.ticketFk
+ UNION
+ SELECT ticketFk, MAX(itemPackingTypeFk)
+ FROM tSalesToMove
+ GROUP BY ticketFk;
COMMIT;
- DROP TEMPORARY TABLE
- tSale,
- tSaleGroup;
+ DROP TEMPORARY TABLE tSalesToMove;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -76953,7 +77644,7 @@ BEGIN
JOIN vn.entry e ON e.travelFk = tr.id
JOIN vn.buy b ON b.entryFk = e.id
WHERE tr.landed BETWEEN vFromDated AND vToDated
- AND e.isRaid = FALSE
+ AND NOT tr.isRaid
AND tr.warehouseInFk = vWarehouseFk
GROUP BY tr.landed , a.name ;
END ;;
@@ -77037,6 +77728,36 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `travel_checkRaid` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`vn`@`localhost` PROCEDURE `travel_checkRaid`(
+ vIsRaid BOOL,
+ vDaysInForward INT
+)
+BEGIN
+/**
+ * Check if the values of isRaid and daysInforward are correct
+ *
+ * @param vIsRaid idRaid value
+ * @param vDaysInForward daysInForward value
+ */
+ IF (NOT vIsRaid AND vDaysInForward IS NOT NULL) OR (vIsRaid AND vDaysInForward IS NULL) THEN
+ CALL util.throw('The raid information is not correct');
+ END IF;
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `travel_checkWarehouseIsFeedStock` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -77199,7 +77920,7 @@ BEGIN
END IF;
CALL entry_cloneHeader(vAuxEntryFk, vNewEntryFk, vNewTravelFk);
- CALL entry_copyBuys(vAuxEntryFk, vNewEntryFk);
+ CALL entry_copyBuys(vAuxEntryFk, vNewEntryFk);
SELECT evaNotes INTO vEvaNotes
FROM entry
@@ -77208,6 +77929,8 @@ BEGIN
UPDATE entry
SET evaNotes = vEvaNotes
WHERE id = vNewEntryFk;
+
+ CALL buy_recalcPricesByEntry(vNewEntryFk);
END LOOP;
SET @isModeInventory = FALSE;
@@ -77385,73 +78108,70 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`vn`@`localhost` PROCEDURE `travel_moveRaids`()
BEGIN
-
-/*
- * Desplaza al dia siguiente los travels que contengan redadas y avisa a los compradores
- *
+/**
+ * Desplaza los travels en el futuro y avisa a los compradores
+ *
*/
DECLARE vDone BOOL DEFAULT FALSE;
- DECLARE vWorkerName VARCHAR(50);
- DECLARE vRaid TEXT;
- DECLARE vWorker VARCHAR(50) DEFAULT '';
+ DECLARE vBuyerEmail VARCHAR(40);
+ DECLARE vTravelLink TEXT;
DECLARE vMailBody TEXT DEFAULT '';
DECLARE vCur CURSOR FOR
- SELECT GROUP_CONCAT( DISTINCT CONCAT('https://salix.verdnatura.es/#!/travel/', ttr.id, '/summary ') ORDER BY ttr.id SEPARATOR '\n\r'),
- u.name
- FROM tmp.travel ttr
- JOIN entry e ON e.travelFk = ttr.id
+ SELECT GROUP_CONCAT(DISTINCT
+ CONCAT('https://salix.verdnatura.es/#!/travel/',
+ ttm.travelFk,
+ '/summary ')
+ ORDER BY ttm.travelFk SEPARATOR '\n\r') travelLink,
+ CONCAT(u.name, '@verdnatura.es') buyerEmail
+ FROM tTravelToMove ttm
+ JOIN entry e ON e.travelFk = ttm.travelFk
JOIN buy b ON b.entryFk = e.id
JOIN item i ON i.id = b.itemFk
JOIN itemType it ON it.id = i.typeFk
JOIN account.user u ON u.id = it.workerFk
GROUP BY u.name;
- DECLARE CONTINUE HANDLER FOR NOT FOUND
- SET vDone = TRUE;
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
RESIGNAL;
END;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.travel;
- CREATE TEMPORARY TABLE tmp.travel
- SELECT tr.id,tr.landed
- FROM travel tr
- JOIN entry e ON e.travelFk = tr.id
- WHERE tr.landed = util.tomorrow()
- AND e.isRaid
- GROUP BY tr.id;
+
+ CREATE OR REPLACE TEMPORARY TABLE tTravelToMove
+ SELECT id travelFk,
+ util.VN_CURDATE() + INTERVAL daysInForward DAY newLanded
+ FROM travel
+ WHERE isRaid
+ AND daysInForward;
START TRANSACTION;
UPDATE travel tr
- JOIN tmp.travel ttr ON ttr.id = tr.id
- SET tr.landed = TIMESTAMPADD(DAY, 1, tr.landed);
+ JOIN tTravelToMove ttm ON ttm.travelFk = tr.id
+ SET tr.landed = ttm.newLanded;
OPEN vCur;
l: LOOP
SET vDone = FALSE;
- FETCH vCur INTO vRaid, vWorkerName;
+ FETCH vCur INTO vTravelLink, vBuyerEmail;
IF vDone THEN
LEAVE l;
END IF;
- CALL `vn`.`mail_insert`(CONCAT(vWorkerName, '@verdnatura.es'),
- 'noreply@verdnatura.es',
- 'Cambio de fecha en Redadas',
- CONCAT('Se ha movido las siguientes redadas: \n\r ', vRaid)
- );
-
+ CALL `vn`.`mail_insert`(
+ vBuyerEmail,
+ 'noreply@verdnatura.es',
+ 'Cambio de fecha en Redadas',
+ CONCAT('Se ha movido los siguientes travels: \n\r ', vTravelLink));
END LOOP;
CLOSE vCur;
COMMIT;
- DROP TEMPORARY TABLE tmp.travel;
-
+ DROP TEMPORARY TABLE tTravelToMove;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -78910,187 +79630,6 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_check` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`vn`@`localhost` PROCEDURE `workerTimeControl_check`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100))
-proc: BEGIN
-/**
- * Verifica si el empleado puede fichar en el momento actual, si puede fichar llama a workerTimeControlAdd
- *
- * @param vUserFk Identificador del trabajador
- * @return Retorna si encuentra un problema 'odd','maxTimeWork','breakDay','breakWeek' ;
- * En caso de tener algun problema retorna el primero que encuentra
- */
- DECLARE vLastIn DATETIME ;
- DECLARE vLastOut DATETIME ;
- DECLARE vDayWorkMax INT;
- DECLARE vDayBreak INT;
- DECLARE vWeekBreak INT ;
- DECLARE vWeekScope INT;
- DECLARE vDayStayMax INT;
- DECLARE vProblem VARCHAR(20) DEFAULT NULL;
- DECLARE vTimedWorked INT;
- DECLARE vCalendarStateType VARCHAR(20) DEFAULT NULL;
- DECLARE vDepartmentFk INT;
- DECLARE vTo VARCHAR(50) DEFAULT NULL;
- DECLARE vUserName VARCHAR(50) DEFAULT NULL;
- DECLARE vBody VARCHAR(255) DEFAULT NULL;
-
- SELECT dayBreak, weekBreak, weekScope, dayWorkMax, dayStayMax
- INTO vDayBreak, vWeekBreak, vWeekScope, vDayWorkMax, vDayStayMax
- FROM workerTimeControlParams;
-
- SELECT MAX(timed) INTO vLastIn
- FROM workerTimeControl
- WHERE userFk = vUserFk
- AND direction = 'in';
-
- SELECT MAX(timed) INTO vLastOut
- FROM workerTimeControl
- WHERE userFk = vUserFk
- AND direction = 'out';
-
- SELECT CONCAT(u.name,'@verdnatura.es') INTO vTo
- FROM account.user u
- WHERE u.id = (SELECT bossFk FROM worker WHERE id = vUserFk);
-
- SELECT CONCAT(firstName,' ',lastName) INTO vUserName
- FROM worker w
- WHERE w.id = vUserFk;
-
-
- IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastIn) > vDayStayMax THEN -- NUEVA JORNADA
-
- -- VERIFICAR DESCANSO DIARIO
- IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastOut) < vDayBreak THEN
- SELECT "Descansos 12 h" AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos 12 h") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
- END IF;
-
- -- VERIFICAR FICHADAS IMPARES DEL ÚLTIMO DÍA QUE SE FICHÓ
- IF (SELECT MOD(COUNT(*),2) -- <>0
- FROM workerTimeControl
- WHERE userFk = vUserFk
- AND timed >= vLastIn
- ) THEN
- SELECT "Dias con fichadas impares" AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Dias con fichadas impares") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
- END IF;
-
- -- VERIFICAR VACACIONES
- SELECT at2.name INTO vCalendarStateType
- FROM calendar c
- JOIN business b ON b.id = c.businessFk
- JOIN absenceType at2 ON at2.id = c.dayOffTypeFk
- WHERE c.dated = util.VN_CURDATE()
- AND at2.isAllowedToWork = FALSE
- AND b.workerFk = vUserFk
- LIMIT 1;
-
- IF(LENGTH(vCalendarStateType)) THEN
- SELECT vCalendarStateType AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Vacaciones") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
-
- END IF;
-
- -- VERIFICAR CONTRATO EN VIGOR
- IF (SELECT COUNT(*)
- FROM business b
- WHERE b.workerFk = vUserFk
- AND b.started <= vDated
- AND IFNULL(b.ended, vDated) >= vDated
- ) = 0 THEN
- SELECT "No hay un contrato en vigor" AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"No hay un contrato en vigor") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
-
- END IF;
-
- -- VERIFICAR DESCANSO SEMANAL
- SET @vHasBreakWeek:= FALSE;
- SET @vLastTimed:= UNIX_TIMESTAMP((util.VN_NOW() - INTERVAL vWeekScope SECOND));
-
- DROP TEMPORARY TABLE IF EXISTS tmp.trash;
- CREATE TEMPORARY TABLE tmp.trash
- SELECT IF(vWeekBreak-(UNIX_TIMESTAMP(timed)-@vLastTimed) <= 0, @vHasBreakWeek:=TRUE, TRUE) alias,
- @vLastTimed:= UNIX_TIMESTAMP(timed)
- FROM workerTimeControl
- WHERE timed>= (util.VN_NOW() - INTERVAL vWeekScope SECOND)
- AND userFk= vUserFk
- AND direction IN ('in','out')
- ORDER BY timed ASC;
-
- IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastOut) < vWeekBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA
- SELECT "Descansos 36 h" AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos 36 h") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
- END IF;
-
- DROP TEMPORARY TABLE tmp.trash;
-
- ELSE -- DIA ACTUAL
-
- -- VERIFICA QUE EL TIEMPO EFECTIVO NO SUPERE EL MÁXIMO
- SELECT IFNULL(SUM(if( mod(wtc.order,2)=1, -UNIX_TIMESTAMP(timed), UNIX_TIMESTAMP(timed))),0) - IF( MOD(COUNT(*),2), UNIX_TIMESTAMP(util.VN_NOW()), 0) INTO vTimedWorked
- FROM workerTimeControl wtc
- WHERE userFk = vUserFk
- AND timed >= vLastIn
- ORDER BY timed;
-
- IF vTimedWorked > vDayWorkMax THEN
- SELECT "Jornadas" AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Jornadas") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
- END IF;
-
- END IF;
-
- -- VERIFICAR DEPARTAMENTO
- /* IF vTabletFk IS NOT NULL THEN
- SELECT wtcu.departmentFk INTO vDepartmentFk
- FROM workerTimeControlUserInfo wtcu
- WHERE wtcu.userFk = vUserFk;
- IF (SELECT COUNT(td.tabletFk)
- FROM tabletDepartment td
- WHERE td.tabletFk = vTabletFk AND td.departmentFk = vDepartmentFk
- ) = 0 THEN
- SELECT "No perteneces a este departamento." AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"No perteneces a este departamento.") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
- END IF;
- END IF;*/
-
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_checkBreak` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -80405,6 +80944,8 @@ BEGIN
SET businessFk = vNewBusinessFk
WHERE id = vSelf;
+ CALL queueMember_updateQueue(vNewBusinessFk);
+
IF vOldBusinessFk IS NULL THEN
CALL account.account_enable(vSelf);
@@ -82245,7 +82786,6 @@ SET character_set_client = utf8;
1 AS `send_mail`,
1 AS `tpv`,
1 AS `code`,
- 1 AS `show_AgencyName`,
1 AS `isRiskFree` */;
SET character_set_client = @saved_cs_client;
@@ -82416,7 +82956,6 @@ SET character_set_client = utf8;
1 AS `credito`,
1 AS `Id_Pais`,
1 AS `activo`,
- 1 AS `gestdoc_id`,
1 AS `calidad`,
1 AS `pay_met_id`,
1 AS `created`,
@@ -82496,21 +83035,6 @@ SET character_set_client = utf8;
1 AS `itemOriginalFk` */;
SET character_set_client = @saved_cs_client;
---
--- Temporary table structure for view `Compres_mark`
---
-
-DROP TABLE IF EXISTS `Compres_mark`;
-/*!50001 DROP VIEW IF EXISTS `Compres_mark`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE VIEW `Compres_mark` AS SELECT
- 1 AS `Id_Compra`,
- 1 AS `comment`,
- 1 AS `mark`,
- 1 AS `odbc_date` */;
-SET character_set_client = @saved_cs_client;
-
--
-- Temporary table structure for view `Consignatarios`
--
@@ -82597,7 +83121,6 @@ SET character_set_client = utf8;
1 AS `Inventario`,
1 AS `Confirmada`,
1 AS `Pedida`,
- 1 AS `Redada`,
1 AS `comision`,
1 AS `odbc_date`,
1 AS `Notas_Eva`,
@@ -82617,18 +83140,6 @@ SET character_set_client = utf8;
1 AS `typeFk` */;
SET character_set_client = @saved_cs_client;
---
--- Temporary table structure for view `Entradas_Auto`
---
-
-DROP TABLE IF EXISTS `Entradas_Auto`;
-/*!50001 DROP VIEW IF EXISTS `Entradas_Auto`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE VIEW `Entradas_Auto` AS SELECT
- 1 AS `Id_Entrada` */;
-SET character_set_client = @saved_cs_client;
-
--
-- Temporary table structure for view `Entradas_orden`
--
@@ -84034,7 +84545,8 @@ SET character_set_client = utf8;
1 AS `Inventario`,
1 AS `Confirmada`,
1 AS `Pedida`,
- 1 AS `Redada`,
+ 1 AS `isRaid`,
+ 1 AS `daysInForward`,
1 AS `notas`,
1 AS `Id_Proveedor`,
1 AS `shipment`,
@@ -84769,7 +85281,9 @@ SET character_set_client = utf8;
1 AS `cargoSupplierFk`,
1 AS `totalEntries`,
1 AS `appointment`,
- 1 AS `awbFk` */;
+ 1 AS `awbFk`,
+ 1 AS `isRaid`,
+ 1 AS `daysInForward` */;
SET character_set_client = @saved_cs_client;
--
@@ -84821,7 +85335,6 @@ SET character_set_client = utf8;
1 AS `Id_Proveedor`,
1 AS `Fecha`,
1 AS `Confirmada`,
- 1 AS `Redada`,
1 AS `empresa_id`,
1 AS `travel_id`,
1 AS `Pedida`,
@@ -84985,7 +85498,7 @@ USE `account`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `myUser` AS select `u`.`id` AS `id`,`u`.`name` AS `name`,`u`.`active` AS `active`,`u`.`email` AS `email`,`u`.`nickname` AS `nickname`,`u`.`lang` AS `lang`,`u`.`role` AS `role`,`u`.`recoverPass` AS `recoverPass` from `user` `u` where `u`.`name` = `myUser_getName`() */
+/*!50001 VIEW `myUser` AS select `u`.`id` AS `id`,`u`.`name` AS `name`,`u`.`active` AS `active`,`u`.`email` AS `email`,`u`.`nickname` AS `nickname`,`u`.`lang` AS `lang`,`u`.`role` AS `role` from `user` `u` where `u`.`name` = `myUser_getName`() */
/*!50002 WITH CASCADED CHECK OPTION */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
@@ -86528,7 +87041,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `expeditionPallet_Print` AS select `rs2`.`description` AS `truck`,`t`.`routeFk` AS `routeFk`,`r`.`description` AS `zone`,count(`es`.`id`) AS `eti`,`ep`.`id` AS `palletFk`,`rs`.`id` <=> `rm`.`roadmapStopFk` AS `isMatch`,`t`.`warehouseFk` AS `warehouseFk`,if(`r`.`created` > `util`.`VN_CURDATE`() + interval 1 day,ucase(dayname(`r`.`created`)),NULL) AS `nombreDia` from (((((((`roadmapStop` `rs` join `expeditionPallet` `ep` on(`ep`.`truckFk` = `rs`.`id`)) join `expeditionScan` `es` on(`es`.`palletFk` = `ep`.`id`)) join `expedition` `e` on(`e`.`id` = `es`.`expeditionFk`)) join `ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) join `route` `r` on(`r`.`id` = `t`.`routeFk`)) left join `routesMonitor` `rm` on(`rm`.`routeFk` = `r`.`id`)) left join `roadmapStop` `rs2` on(`rs2`.`id` = `rm`.`roadmapStopFk`)) group by `ep`.`id`,`t`.`routeFk` */;
+/*!50001 VIEW `expeditionPallet_Print` AS select `rs2`.`description` AS `truck`,`t`.`routeFk` AS `routeFk`,`r`.`description` AS `zone`,count(`es`.`id`) AS `eti`,`ep`.`id` AS `palletFk`,`rs`.`id` <=> `rm`.`roadmapStopFk` AS `isMatch`,`t`.`warehouseFk` AS `warehouseFk`,if(`r`.`dated` > `util`.`VN_CURDATE`() + interval 1 day,ucase(dayname(`r`.`dated`)),NULL) AS `nombreDia` from (((((((`roadmapStop` `rs` join `expeditionPallet` `ep` on(`ep`.`truckFk` = `rs`.`id`)) join `expeditionScan` `es` on(`es`.`palletFk` = `ep`.`id`)) join `expedition` `e` on(`e`.`id` = `es`.`expeditionFk`)) join `ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) join `route` `r` on(`r`.`id` = `t`.`routeFk`)) left join `routesMonitor` `rm` on(`rm`.`routeFk` = `r`.`id`)) left join `roadmapStop` `rs2` on(`rs2`.`id` = `rm`.`roadmapStopFk`)) group by `ep`.`id`,`t`.`routeFk` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -86546,7 +87059,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `expeditionRoute_Monitor` AS select `r`.`id` AS `routeFk`,count(distinct if(`e`.`id` is null,`t`.`id`,NULL)) AS `tickets`,count(distinct `e`.`id`) AS `expeditions`,count(distinct `es`.`id`) AS `scanned`,max(`e`.`created`) AS `lastPacked`,`r`.`created` AS `created` from (((((`route` `r` left join `routesMonitor` `rm` on(`r`.`id` = `rm`.`routeFk`)) left join `roadmapStop` `rs` on(`rs`.`id` = `rm`.`roadmapStopFk`)) join `ticket` `t` on(`t`.`routeFk` = `r`.`id`)) left join `expedition` `e` on(`e`.`ticketFk` = `t`.`id`)) left join `expeditionScan` `es` on(`es`.`expeditionFk` = `e`.`id`)) where `r`.`created` >= `util`.`yesterday`() group by `r`.`id` */;
+/*!50001 VIEW `expeditionRoute_Monitor` AS select `r`.`id` AS `routeFk`,count(distinct if(`e`.`id` is null,`t`.`id`,NULL)) AS `tickets`,count(distinct `e`.`id`) AS `expeditions`,count(distinct `es`.`id`) AS `scanned`,max(`e`.`created`) AS `lastPacked`,`r`.`dated` AS `created` from (((((`route` `r` left join `routesMonitor` `rm` on(`r`.`id` = `rm`.`routeFk`)) left join `roadmapStop` `rs` on(`rs`.`id` = `rm`.`roadmapStopFk`)) join `ticket` `t` on(`t`.`routeFk` = `r`.`id`)) left join `expedition` `e` on(`e`.`ticketFk` = `t`.`id`)) left join `expeditionScan` `es` on(`es`.`expeditionFk` = `e`.`id`)) where `r`.`dated` >= `util`.`yesterday`() group by `r`.`id` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -86798,7 +87311,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `itemEntryIn` AS select `t`.`warehouseInFk` AS `warehouseInFk`,`t`.`landed` AS `landed`,`b`.`itemFk` AS `itemFk`,`b`.`quantity` AS `quantity`,`t`.`isReceived` AS `isReceived`,`e`.`isRaid` AS `isVirtualStock`,`e`.`id` AS `entryFk` from ((`buy` `b` join `entry` `e` on(`b`.`entryFk` = `e`.`id`)) join `travel` `t` on(`e`.`travelFk` = `t`.`id`)) where `e`.`isExcludedFromAvailable` = 0 and `b`.`quantity` <> 0 */;
+/*!50001 VIEW `itemEntryIn` AS select `t`.`warehouseInFk` AS `warehouseInFk`,`t`.`landed` AS `landed`,`b`.`itemFk` AS `itemFk`,`b`.`quantity` AS `quantity`,`t`.`isReceived` AS `isReceived`,`t`.`isRaid` AS `isVirtualStock`,`e`.`id` AS `entryFk` from ((`buy` `b` join `entry` `e` on(`b`.`entryFk` = `e`.`id`)) join `travel` `t` on(`e`.`travelFk` = `t`.`id`)) where `e`.`isExcludedFromAvailable` = 0 and `b`.`quantity` <> 0 */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -86816,7 +87329,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `itemEntryOut` AS select `t`.`warehouseOutFk` AS `warehouseOutFk`,`t`.`shipped` AS `shipped`,`b`.`itemFk` AS `itemFk`,-`b`.`quantity` AS `quantity`,`t`.`isDelivered` AS `isDelivered`,`e`.`id` AS `entryFk` from ((`buy` `b` join `entry` `e` on(`b`.`entryFk` = `e`.`id`)) join `travel` `t` on(`e`.`travelFk` = `t`.`id`)) where `e`.`isExcludedFromAvailable` = 0 and `e`.`isRaid` = 0 and `b`.`quantity` <> 0 */;
+/*!50001 VIEW `itemEntryOut` AS select `t`.`warehouseOutFk` AS `warehouseOutFk`,`t`.`shipped` AS `shipped`,`b`.`itemFk` AS `itemFk`,-`b`.`quantity` AS `quantity`,`t`.`isDelivered` AS `isDelivered`,`e`.`id` AS `entryFk` from ((`buy` `b` join `entry` `e` on(`b`.`entryFk` = `e`.`id`)) join `travel` `t` on(`e`.`travelFk` = `t`.`id`)) where `e`.`isExcludedFromAvailable` = 0 and `t`.`isRaid` = 0 and `b`.`quantity` <> 0 */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -86924,7 +87437,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `itemShelvingList` AS select `ish`.`shelvingFk` AS `shelvingFk`,`ish`.`visible` AS `visible`,`ish`.`created` AS `created`,`pk`.`code` AS `parking`,`ish`.`itemFk` AS `itemFk`,`i`.`longName` AS `longName`,`i`.`size` AS `size`,`i`.`subName` AS `subName`,`sh`.`parked` AS `parked`,`pk`.`sectorFk` AS `sectorFk` from (((`itemShelving` `ish` join `shelving` `sh` on(`sh`.`code` = `ish`.`shelvingFk`)) join `item` `i` on(`i`.`id` = `ish`.`itemFk`)) left join `parking` `pk` on(`pk`.`id` = `sh`.`parkingFk`)) order by `ish`.`created` */;
+/*!50001 VIEW `itemShelvingList` AS select `ish`.`shelvingFk` AS `shelvingFk`,`ish`.`visible` AS `visible`,`ish`.`created` AS `created`,`pk`.`code` AS `parking`,`ish`.`itemFk` AS `itemFk`,`i`.`longName` AS `longName`,`i`.`size` AS `size`,`i`.`subName` AS `subName`,`sh`.`parked` AS `parked`,`pk`.`sectorFk` AS `sectorFk` from (((`itemShelving` `ish` join `shelving` `sh` on(`sh`.`id` = `ish`.`shelvingFk`)) join `item` `i` on(`i`.`id` = `ish`.`itemFk`)) left join `parking` `pk` on(`pk`.`id` = `sh`.`parkingFk`)) order by `ish`.`created` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -86942,7 +87455,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `itemShelvingPlacementSupplyStock` AS select `ish`.`id` AS `itemShelvingFk`,`ish`.`itemFk` AS `itemFk`,`ish`.`packing` AS `packing`,`ish`.`visible` AS `stock`,`i`.`longName` AS `longName`,`i`.`size` AS `size`,`i`.`subName` AS `subName`,`sh`.`code` AS `shelving`,`p`.`code` AS `parking`,`ish`.`created` AS `created`,ifnull(`sh`.`priority`,1) AS `priority`,`p`.`id` AS `parkingFk`,`p`.`sectorFk` AS `sectorFk` from (((`itemShelving` `ish` join `shelving` `sh` on(`sh`.`code` = `ish`.`shelvingFk`)) left join `parking` `p` on(`p`.`id` = `sh`.`parkingFk`)) join `item` `i` on(`i`.`id` = `ish`.`itemFk`)) group by `ish`.`id` */;
+/*!50001 VIEW `itemShelvingPlacementSupplyStock` AS select `ish`.`id` AS `itemShelvingFk`,`ish`.`itemFk` AS `itemFk`,`ish`.`packing` AS `packing`,`ish`.`visible` AS `stock`,`i`.`longName` AS `longName`,`i`.`size` AS `size`,`i`.`subName` AS `subName`,`sh`.`code` AS `shelving`,`p`.`code` AS `parking`,`ish`.`created` AS `created`,ifnull(`sh`.`priority`,1) AS `priority`,`p`.`id` AS `parkingFk`,`p`.`sectorFk` AS `sectorFk` from (((`itemShelving` `ish` join `shelving` `sh` on(`sh`.`id` = `ish`.`shelvingFk`)) left join `parking` `p` on(`p`.`id` = `sh`.`parkingFk`)) join `item` `i` on(`i`.`id` = `ish`.`itemFk`)) group by `ish`.`id` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -86960,7 +87473,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `itemShelvingSaleSum` AS select `iss`.`id` AS `id`,`iss`.`itemShelvingFk` AS `itemShelvingFk`,`iss`.`saleFk` AS `saleFk`,sum(`iss`.`quantity`) AS `quantity`,`iss`.`created` AS `created`,`p`.`sectorFk` AS `sectorFk` from (((`itemShelvingSale` `iss` join `itemShelving` `ish` on(`ish`.`id` = `iss`.`itemShelvingFk`)) join `shelving` `sh` on(`sh`.`code` = `ish`.`shelvingFk`)) join `parking` `p` on(`p`.`id` = `sh`.`parkingFk`)) group by `iss`.`saleFk` */;
+/*!50001 VIEW `itemShelvingSaleSum` AS select `iss`.`id` AS `id`,`iss`.`itemShelvingFk` AS `itemShelvingFk`,`iss`.`saleFk` AS `saleFk`,sum(`iss`.`quantity`) AS `quantity`,`iss`.`created` AS `created`,`p`.`sectorFk` AS `sectorFk` from (((`itemShelvingSale` `iss` join `itemShelving` `ish` on(`ish`.`id` = `iss`.`itemShelvingFk`)) join `shelving` `sh` on(`sh`.`id` = `ish`.`shelvingFk`)) join `parking` `p` on(`p`.`id` = `sh`.`parkingFk`)) group by `iss`.`saleFk` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -86978,7 +87491,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `itemShelvingStock` AS select `ish`.`itemFk` AS `itemFk`,sum(`ish`.`visible`) AS `visible`,min(`ish`.`packing`) AS `packing`,min(`ish`.`grouping`) AS `grouping`,`s`.`description` AS `sector`,sum(`ish`.`visible`) AS `visibleOriginal`,0 AS `removed`,`p`.`sectorFk` AS `sectorFk`,`s`.`warehouseFk` AS `warehouseFk`,`ish`.`shelvingFk` AS `shelvingFk`,`p`.`code` AS `parkingCode`,`sh`.`parkingFk` AS `parkingFk`,`ish`.`id` AS `itemShelvingFk`,`ish`.`created` AS `created`,`st`.`code` = 'previousPrepared' AS `isPreviousPrepared` from ((((`itemShelving` `ish` left join `shelving` `sh` on(`sh`.`code` = `ish`.`shelvingFk`)) left join `parking` `p` on(`p`.`id` = `sh`.`parkingFk`)) left join `sector` `s` on(`s`.`id` = `p`.`sectorFk`)) left join `sectorType` `st` on(`st`.`id` = `s`.`typeFk`)) where `ish`.`visible` <> 0 and `p`.`sectorFk` <> 0 group by `ish`.`itemFk`,`p`.`sectorFk` */;
+/*!50001 VIEW `itemShelvingStock` AS select `ish`.`itemFk` AS `itemFk`,sum(`ish`.`visible`) AS `visible`,min(`ish`.`packing`) AS `packing`,min(`ish`.`grouping`) AS `grouping`,`s`.`description` AS `sector`,sum(`ish`.`visible`) AS `visibleOriginal`,0 AS `removed`,`p`.`sectorFk` AS `sectorFk`,`s`.`warehouseFk` AS `warehouseFk`,`ish`.`shelvingFk` AS `shelvingFk`,`p`.`code` AS `parkingCode`,`sh`.`parkingFk` AS `parkingFk`,`ish`.`id` AS `itemShelvingFk`,`ish`.`created` AS `created`,`st`.`code` = 'previousPrepared' AS `isPreviousPrepared` from ((((`itemShelving` `ish` left join `shelving` `sh` on(`sh`.`id` = `ish`.`shelvingFk`)) left join `parking` `p` on(`p`.`id` = `sh`.`parkingFk`)) left join `sector` `s` on(`s`.`id` = `p`.`sectorFk`)) left join `sectorType` `st` on(`st`.`id` = `s`.`typeFk`)) where `ish`.`visible` <> 0 and `p`.`sectorFk` <> 0 group by `ish`.`itemFk`,`p`.`sectorFk` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -86996,7 +87509,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `itemShelvingStockFull` AS select `ish`.`itemFk` AS `itemFk`,`ish`.`visible` AS `quantity`,`ish`.`packing` AS `packing`,`ish`.`grouping` AS `grouping`,`s`.`description` AS `sector`,`issr`.`removed` AS `removed`,`p`.`sectorFk` AS `sectorFk`,`s`.`warehouseFk` AS `warehouseFk`,`ish`.`shelvingFk` AS `shelvingFk`,`p`.`code` AS `parkingCode`,`sh`.`parkingFk` AS `parkingFk`,`ish`.`id` AS `itemShelvingFk`,`ish`.`created` AS `created` from ((((`itemShelving` `ish` join `shelving` `sh` on(`sh`.`code` = `ish`.`shelvingFk`)) join `parking` `p` on(`p`.`id` = `sh`.`parkingFk`)) join `sector` `s` on(`s`.`id` = `p`.`sectorFk`)) left join `itemShelvingStockRemoved` `issr` on(`issr`.`itemShelvingFk` = `ish`.`id`)) */;
+/*!50001 VIEW `itemShelvingStockFull` AS select `ish`.`itemFk` AS `itemFk`,`ish`.`visible` AS `quantity`,`ish`.`packing` AS `packing`,`ish`.`grouping` AS `grouping`,`s`.`description` AS `sector`,`issr`.`removed` AS `removed`,`p`.`sectorFk` AS `sectorFk`,`s`.`warehouseFk` AS `warehouseFk`,`ish`.`shelvingFk` AS `shelvingFk`,`p`.`code` AS `parkingCode`,`sh`.`parkingFk` AS `parkingFk`,`ish`.`id` AS `itemShelvingFk`,`ish`.`created` AS `created` from ((((`itemShelving` `ish` join `shelving` `sh` on(`sh`.`id` = `ish`.`shelvingFk`)) join `parking` `p` on(`p`.`id` = `sh`.`parkingFk`)) join `sector` `s` on(`s`.`id` = `p`.`sectorFk`)) left join `itemShelvingStockRemoved` `issr` on(`issr`.`itemShelvingFk` = `ish`.`id`)) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -87158,7 +87671,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `lastPurchases` AS select `tr`.`landed` AS `landed`,`w`.`id` AS `warehouseFk`,`w`.`name` AS `warehouse`,`i`.`longName` AS `longName`,`i`.`subName` AS `subName`,`e`.`id` AS `entryFk`,`b`.`stickers` AS `stickers`,`b`.`packing` AS `packing`,`e`.`invoiceNumber` AS `ref`,`b`.`itemFk` AS `itemFk`,`ek`.`pro` AS `pro`,`ek`.`ref` AS `ektRef`,`ek`.`agj` AS `agj` from (((((`vn`.`buy` `b` join `vn`.`entry` `e` on(`e`.`id` = `b`.`entryFk`)) join `vn`.`item` `i` on(`i`.`id` = `b`.`itemFk`)) join `vn`.`travel` `tr` on(`tr`.`id` = `e`.`travelFk`)) join `vn`.`warehouse` `w` on(`w`.`id` = `tr`.`warehouseInFk`)) left join `edi`.`ekt` `ek` on(`ek`.`id` = `b`.`ektFk`)) where `tr`.`landed` between `util`.`yesterday`() and `util`.`tomorrow`() and `e`.`isRaid` = 0 and `b`.`stickers` > 0 */;
+/*!50001 VIEW `lastPurchases` AS select `tr`.`landed` AS `landed`,`w`.`id` AS `warehouseFk`,`w`.`name` AS `warehouse`,`i`.`longName` AS `longName`,`i`.`subName` AS `subName`,`e`.`id` AS `entryFk`,`b`.`stickers` AS `stickers`,`b`.`packing` AS `packing`,`e`.`invoiceNumber` AS `ref`,`b`.`itemFk` AS `itemFk`,`ek`.`pro` AS `pro`,`ek`.`ref` AS `ektRef`,`ek`.`agj` AS `agj` from (((((`vn`.`buy` `b` join `vn`.`entry` `e` on(`e`.`id` = `b`.`entryFk`)) join `vn`.`item` `i` on(`i`.`id` = `b`.`itemFk`)) join `vn`.`travel` `tr` on(`tr`.`id` = `e`.`travelFk`)) join `vn`.`warehouse` `w` on(`w`.`id` = `tr`.`warehouseInFk`)) left join `edi`.`ekt` `ek` on(`ek`.`id` = `b`.`ektFk`)) where `tr`.`landed` between `util`.`yesterday`() and `util`.`tomorrow`() and `tr`.`isRaid` = 0 and `b`.`stickers` > 0 */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -88040,7 +88553,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `workerWithoutTractor` AS select `c`.`workerFk` AS `workerFk`,`cl`.`name` AS `Trabajador`,count(distinct `c`.`id`) AS `Colecciones`,max(`c`.`created`) AS `created` from ((`collection` `c` join `client` `cl` on(`cl`.`id` = `c`.`workerFk`)) left join `machineWorker` `mw` on(`mw`.`workerFk` = `c`.`workerFk` and `mw`.`inTimed` > `util`.`VN_CURDATE`())) where `c`.`created` > `util`.`VN_CURDATE`() and `mw`.`workerFk` is null group by `c`.`workerFk` */;
+/*!50001 VIEW `workerWithoutTractor` AS select `c`.`workerFk` AS `workerFk`,`cl`.`name` AS `Trabajador`,count(distinct `c`.`id`) AS `Colecciones`,max(`c`.`created`) AS `created` from ((`collection` `c` join `client` `cl` on(`cl`.`id` = `c`.`workerFk`)) join `operator` `o` on(`o`.`workerFk` = `c`.`workerFk`)) where `c`.`created` > `util`.`VN_CURDATE`() and `o`.`machineFk` is null group by `c`.`workerFk` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -88082,7 +88595,7 @@ USE `vn2008`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `Agencias` AS select `am`.`id` AS `Id_Agencia`,`am`.`name` AS `Agencia`,`am`.`description` AS `description`,`am`.`deliveryMethodFk` AS `Vista`,`am`.`m3` AS `m3`,`am`.`web` AS `web`,`am`.`agencyFk` AS `agency_id`,`am`.`inflation` AS `inflacion`,`am`.`isVolumetric` AS `is_volumetric`,`am`.`reportMail` AS `send_mail`,`am`.`isActive` AS `tpv`,`am`.`code` AS `code`,`am`.`showAgencyName` AS `show_AgencyName`,`am`.`isRiskFree` AS `isRiskFree` from `vn`.`agencyMode` `am` */;
+/*!50001 VIEW `Agencias` AS select `am`.`id` AS `Id_Agencia`,`am`.`name` AS `Agencia`,`am`.`description` AS `description`,`am`.`deliveryMethodFk` AS `Vista`,`am`.`m3` AS `m3`,`am`.`web` AS `web`,`am`.`agencyFk` AS `agency_id`,`am`.`inflation` AS `inflacion`,`am`.`isVolumetric` AS `is_volumetric`,`am`.`reportMail` AS `send_mail`,`am`.`isActive` AS `tpv`,`am`.`code` AS `code`,`am`.`isRiskFree` AS `isRiskFree` from `vn`.`agencyMode` `am` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -88172,7 +88685,7 @@ USE `vn2008`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `Clientes` AS select `c`.`id` AS `id_cliente`,`c`.`name` AS `cliente`,`c`.`fi` AS `if`,`c`.`socialName` AS `razonSocial`,`c`.`contact` AS `contacto`,`c`.`street` AS `domicilio`,`c`.`city` AS `poblacion`,`c`.`postcode` AS `codPostal`,`c`.`phone` AS `telefono`,`c`.`mobile` AS `movil`,`c`.`isRelevant` AS `real`,`c`.`email` AS `e-mail`,`c`.`iban` AS `iban`,`c`.`dueDay` AS `vencimiento`,`c`.`accountingAccount` AS `Cuenta`,`c`.`isEqualizated` AS `RE`,`c`.`provinceFk` AS `province_id`,`c`.`hasToInvoice` AS `invoice`,`c`.`credit` AS `credito`,`c`.`countryFk` AS `Id_Pais`,`c`.`isActive` AS `activo`,`c`.`gestdocFk` AS `gestdoc_id`,`c`.`quality` AS `calidad`,`c`.`payMethodFk` AS `pay_met_id`,`c`.`created` AS `created`,`c`.`isToBeMailed` AS `mail`,`c`.`contactChannelFk` AS `chanel_id`,`c`.`hasSepaVnl` AS `sepaVnl`,`c`.`hasCoreVnl` AS `coreVnl`,`c`.`hasCoreVnh` AS `coreVnh`,`c`.`hasLcr` AS `hasLcr`,`c`.`defaultAddressFk` AS `default_address`,`c`.`riskCalculated` AS `risk_calculated`,`c`.`hasToInvoiceByAddress` AS `invoiceByAddress`,`c`.`isTaxDataChecked` AS `contabilizado`,`c`.`isFreezed` AS `congelado`,`c`.`creditInsurance` AS `creditInsurance`,`c`.`isCreatedAsServed` AS `isCreatedAsServed`,`c`.`hasInvoiceSimplified` AS `hasInvoiceSimplified`,`c`.`salesPersonFk` AS `Id_Trabajador`,`c`.`isVies` AS `vies`,`c`.`bankEntityFk` AS `bankEntityFk`,`c`.`typeFk` AS `typeFk` from `vn`.`client` `c` */;
+/*!50001 VIEW `Clientes` AS select `c`.`id` AS `id_cliente`,`c`.`name` AS `cliente`,`c`.`fi` AS `if`,`c`.`socialName` AS `razonSocial`,`c`.`contact` AS `contacto`,`c`.`street` AS `domicilio`,`c`.`city` AS `poblacion`,`c`.`postcode` AS `codPostal`,`c`.`phone` AS `telefono`,`c`.`mobile` AS `movil`,`c`.`isRelevant` AS `real`,`c`.`email` AS `e-mail`,`c`.`iban` AS `iban`,`c`.`dueDay` AS `vencimiento`,`c`.`accountingAccount` AS `Cuenta`,`c`.`isEqualizated` AS `RE`,`c`.`provinceFk` AS `province_id`,`c`.`hasToInvoice` AS `invoice`,`c`.`credit` AS `credito`,`c`.`countryFk` AS `Id_Pais`,`c`.`isActive` AS `activo`,`c`.`quality` AS `calidad`,`c`.`payMethodFk` AS `pay_met_id`,`c`.`created` AS `created`,`c`.`isToBeMailed` AS `mail`,`c`.`contactChannelFk` AS `chanel_id`,`c`.`hasSepaVnl` AS `sepaVnl`,`c`.`hasCoreVnl` AS `coreVnl`,`c`.`hasCoreVnh` AS `coreVnh`,`c`.`hasLcr` AS `hasLcr`,`c`.`defaultAddressFk` AS `default_address`,`c`.`riskCalculated` AS `risk_calculated`,`c`.`hasToInvoiceByAddress` AS `invoiceByAddress`,`c`.`isTaxDataChecked` AS `contabilizado`,`c`.`isFreezed` AS `congelado`,`c`.`creditInsurance` AS `creditInsurance`,`c`.`isCreatedAsServed` AS `isCreatedAsServed`,`c`.`hasInvoiceSimplified` AS `hasInvoiceSimplified`,`c`.`salesPersonFk` AS `Id_Trabajador`,`c`.`isVies` AS `vies`,`c`.`bankEntityFk` AS `bankEntityFk`,`c`.`typeFk` AS `typeFk` from `vn`.`client` `c` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -88213,24 +88726,6 @@ USE `vn2008`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
---
--- Final view structure for view `Compres_mark`
---
-
-/*!50001 DROP VIEW IF EXISTS `Compres_mark`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `Compres_mark` AS select `bm`.`id` AS `Id_Compra`,`bm`.`comment` AS `comment`,`bm`.`mark` AS `mark`,`bm`.`odbcDate` AS `odbc_date` from `vn`.`buyMark` `bm` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
--
-- Final view structure for view `Consignatarios`
--
@@ -88298,25 +88793,7 @@ USE `vn2008`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `Entradas` AS select `e`.`id` AS `Id_Entrada`,`e`.`supplierFk` AS `Id_Proveedor`,`e`.`invoiceNumber` AS `Referencia`,`e`.`reference` AS `reference`,`e`.`isExcludedFromAvailable` AS `Inventario`,`e`.`isConfirmed` AS `Confirmada`,`e`.`isOrdered` AS `Pedida`,`e`.`isRaid` AS `Redada`,`e`.`commission` AS `comision`,`e`.`created` AS `odbc_date`,`e`.`evaNotes` AS `Notas_Eva`,`e`.`travelFk` AS `travel_id`,`e`.`currencyFk` AS `Id_Moneda`,`e`.`companyFk` AS `empresa_id`,`e`.`gestDocFk` AS `gestdoc_id`,`e`.`invoiceInFk` AS `recibida_id`,`e`.`dated` AS `Fecha`,`e`.`isBooked` AS `Anotadoencaja`,`e`.`loadPriority` AS `loadPriority`,`e`.`sub` AS `sub`,`e`.`kop` AS `kop`,`e`.`pro` AS `pro`,`e`.`invoiceAmount` AS `invoiceAmount`,`e`.`buyerFk` AS `buyerFk`,`e`.`typeFk` AS `typeFk` from `vn`.`entry` `e` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `Entradas_Auto`
---
-
-/*!50001 DROP VIEW IF EXISTS `Entradas_Auto`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `Entradas_Auto` AS select `ev`.`entryFk` AS `Id_Entrada` from `vn`.`entryVirtual` `ev` */;
+/*!50001 VIEW `Entradas` AS select `e`.`id` AS `Id_Entrada`,`e`.`supplierFk` AS `Id_Proveedor`,`e`.`invoiceNumber` AS `Referencia`,`e`.`reference` AS `reference`,`e`.`isExcludedFromAvailable` AS `Inventario`,`e`.`isConfirmed` AS `Confirmada`,`e`.`isOrdered` AS `Pedida`,`e`.`commission` AS `comision`,`e`.`created` AS `odbc_date`,`e`.`evaNotes` AS `Notas_Eva`,`e`.`travelFk` AS `travel_id`,`e`.`currencyFk` AS `Id_Moneda`,`e`.`companyFk` AS `empresa_id`,`e`.`gestDocFk` AS `gestdoc_id`,`e`.`invoiceInFk` AS `recibida_id`,`e`.`dated` AS `Fecha`,`e`.`isBooked` AS `Anotadoencaja`,`e`.`loadPriority` AS `loadPriority`,`e`.`sub` AS `sub`,`e`.`kop` AS `kop`,`e`.`pro` AS `pro`,`e`.`invoiceAmount` AS `invoiceAmount`,`e`.`buyerFk` AS `buyerFk`,`e`.`typeFk` AS `typeFk` from `vn`.`entry` `e` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -88622,7 +89099,7 @@ USE `vn2008`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `Rutas` AS select `r`.`id` AS `Id_Ruta`,`r`.`workerFk` AS `Id_Trabajador`,`r`.`created` AS `Fecha`,`r`.`vehicleFk` AS `Id_Vehiculo`,`r`.`agencyModeFk` AS `Id_Agencia`,`r`.`time` AS `Hora`,`r`.`isOk` AS `ok`,`r`.`kmStart` AS `km_start`,`r`.`kmEnd` AS `km_end`,`r`.`started` AS `date_start`,`r`.`finished` AS `date_end`,`r`.`gestdocFk` AS `gestdoc_id`,`r`.`cost` AS `cost`,`r`.`m3` AS `m3`,`r`.`description` AS `description` from `vn`.`route` `r` */;
+/*!50001 VIEW `Rutas` AS select `r`.`id` AS `Id_Ruta`,`r`.`workerFk` AS `Id_Trabajador`,`r`.`dated` AS `Fecha`,`r`.`vehicleFk` AS `Id_Vehiculo`,`r`.`agencyModeFk` AS `Id_Agencia`,`r`.`time` AS `Hora`,`r`.`isOk` AS `ok`,`r`.`kmStart` AS `km_start`,`r`.`kmEnd` AS `km_end`,`r`.`started` AS `date_start`,`r`.`finished` AS `date_end`,`r`.`gestdocFk` AS `gestdoc_id`,`r`.`cost` AS `cost`,`r`.`m3` AS `m3`,`r`.`description` AS `description` from `vn`.`route` `r` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -89648,7 +90125,7 @@ USE `vn2008`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `entrySource` AS select `e`.`gestDocFk` AS `gestdoc_id`,`e`.`id` AS `Id_Entrada`,`e`.`invoiceNumber` AS `invoiceNumber`,`e`.`reference` AS `reference`,`e`.`isExcludedFromAvailable` AS `Inventario`,`e`.`isConfirmed` AS `Confirmada`,`e`.`isOrdered` AS `Pedida`,`e`.`isRaid` AS `Redada`,`e`.`evaNotes` AS `notas`,`e`.`supplierFk` AS `Id_Proveedor`,`tr`.`shipped` AS `shipment`,`tr`.`landed` AS `landing`,`w2`.`name` AS `wh_in`,`w1`.`name` AS `wh_out`,`am`.`name` AS `Agencia`,`e`.`commission` AS `comision`,`tr`.`warehouseInFk` AS `warehouse_id`,`w1`.`id` AS `warehouse_id_out`,`e`.`isBooked` AS `anotadoencaja`,`e`.`invoiceInFk` AS `invoiceInFk`,`e`.`companyFk` AS `empresa_id`,`e`.`currencyFk` AS `Id_Moneda`,`tr`.`id` AS `TravelFk`,`e`.`sub` AS `sub`,`e`.`kop` AS `kop`,`e`.`pro` AS `pro`,`e`.`invoiceAmount` AS `invoiceAmount`,`w`.`code` AS `buyerCode`,`e`.`typeFk` AS `typeFk`,`w3`.`code` AS `observationWorkerCode` from (((((((`vn`.`entry` `e` left join `vn`.`travel` `tr` on(`e`.`travelFk` = `tr`.`id`)) left join `vn`.`agencyMode` `am` on(`am`.`id` = `tr`.`agencyModeFk`)) left join `vn`.`warehouse` `w1` on(`tr`.`warehouseOutFk` = `w1`.`id`)) left join `vn`.`warehouse` `w2` on(`tr`.`warehouseInFk` = `w2`.`id`)) left join `vn`.`supplier` `s` on(`e`.`supplierFk` = `s`.`id`)) left join `vn`.`worker` `w` on(`w`.`id` = `e`.`buyerFk`)) left join `vn`.`worker` `w3` on(`w3`.`id` = `e`.`observationEditorFk`)) */;
+/*!50001 VIEW `entrySource` AS select `e`.`gestDocFk` AS `gestdoc_id`,`e`.`id` AS `Id_Entrada`,`e`.`invoiceNumber` AS `invoiceNumber`,`e`.`reference` AS `reference`,`e`.`isExcludedFromAvailable` AS `Inventario`,`e`.`isConfirmed` AS `Confirmada`,`e`.`isOrdered` AS `Pedida`,`tr`.`isRaid` AS `isRaid`,`tr`.`daysInForward` AS `daysInForward`,`e`.`evaNotes` AS `notas`,`e`.`supplierFk` AS `Id_Proveedor`,`tr`.`shipped` AS `shipment`,`tr`.`landed` AS `landing`,`w2`.`name` AS `wh_in`,`w1`.`name` AS `wh_out`,`am`.`name` AS `Agencia`,`e`.`commission` AS `comision`,`tr`.`warehouseInFk` AS `warehouse_id`,`w1`.`id` AS `warehouse_id_out`,`e`.`isBooked` AS `anotadoencaja`,`e`.`invoiceInFk` AS `invoiceInFk`,`e`.`companyFk` AS `empresa_id`,`e`.`currencyFk` AS `Id_Moneda`,`tr`.`id` AS `TravelFk`,`e`.`sub` AS `sub`,`e`.`kop` AS `kop`,`e`.`pro` AS `pro`,`e`.`invoiceAmount` AS `invoiceAmount`,`w`.`code` AS `buyerCode`,`e`.`typeFk` AS `typeFk`,`w3`.`code` AS `observationWorkerCode` from (((((((`vn`.`entry` `e` left join `vn`.`travel` `tr` on(`e`.`travelFk` = `tr`.`id`)) left join `vn`.`agencyMode` `am` on(`am`.`id` = `tr`.`agencyModeFk`)) left join `vn`.`warehouse` `w1` on(`tr`.`warehouseOutFk` = `w1`.`id`)) left join `vn`.`warehouse` `w2` on(`tr`.`warehouseInFk` = `w2`.`id`)) left join `vn`.`supplier` `s` on(`e`.`supplierFk` = `s`.`id`)) left join `vn`.`worker` `w` on(`w`.`id` = `e`.`buyerFk`)) left join `vn`.`worker` `w3` on(`w3`.`id` = `e`.`observationEditorFk`)) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -90368,7 +90845,7 @@ USE `vn2008`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `travel` AS select `t`.`id` AS `id`,`t`.`shipped` AS `shipment`,`t`.`shipmentHour` AS `shipment_hour`,`t`.`landed` AS `landing`,`t`.`landingHour` AS `landing_hour`,`t`.`warehouseInFk` AS `warehouse_id`,`t`.`warehouseOutFk` AS `warehouse_id_out`,`t`.`agencyModeFk` AS `agency_id`,`t`.`ref` AS `ref`,`t`.`isDelivered` AS `delivered`,`t`.`isReceived` AS `received`,`t`.`m3` AS `m3`,`t`.`kg` AS `kg`,`t`.`cargoSupplierFk` AS `cargoSupplierFk`,`t`.`totalEntries` AS `totalEntries`,`t`.`appointment` AS `appointment`,`t`.`awbFk` AS `awbFk` from `vn`.`travel` `t` */;
+/*!50001 VIEW `travel` AS select `t`.`id` AS `id`,`t`.`shipped` AS `shipment`,`t`.`shipmentHour` AS `shipment_hour`,`t`.`landed` AS `landing`,`t`.`landingHour` AS `landing_hour`,`t`.`warehouseInFk` AS `warehouse_id`,`t`.`warehouseOutFk` AS `warehouse_id_out`,`t`.`agencyModeFk` AS `agency_id`,`t`.`ref` AS `ref`,`t`.`isDelivered` AS `delivered`,`t`.`isReceived` AS `received`,`t`.`m3` AS `m3`,`t`.`kg` AS `kg`,`t`.`cargoSupplierFk` AS `cargoSupplierFk`,`t`.`totalEntries` AS `totalEntries`,`t`.`appointment` AS `appointment`,`t`.`awbFk` AS `awbFk`,`t`.`isRaid` AS `isRaid`,`t`.`daysInForward` AS `daysInForward` from `vn`.`travel` `t` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -90404,7 +90881,7 @@ USE `vn2008`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `v_compres` AS select `TP`.`Id_Tipo` AS `Familia`,`RN`.`id` AS `reino_id`,`C`.`Id_Compra` AS `Id_Compra`,`C`.`Id_Entrada` AS `Id_Entrada`,`C`.`Id_Article` AS `Id_Article`,`C`.`Cantidad` AS `Cantidad`,`C`.`Costefijo` AS `Costefijo`,`C`.`Portefijo` AS `Portefijo`,`C`.`Novincular` AS `Novincular`,`C`.`Etiquetas` AS `Etiquetas`,`C`.`Packing` AS `Packing`,`C`.`grouping` AS `grouping`,`C`.`Comisionfija` AS `Comisionfija`,`C`.`Embalajefijo` AS `Embalajefijo`,`C`.`Id_Cubo` AS `Id_Cubo`,`C`.`Tarifa1` AS `Tarifa1`,`C`.`Tarifa2` AS `Tarifa2`,`C`.`Tarifa3` AS `Tarifa3`,`C`.`PVP` AS `PVP`,`C`.`Vida` AS `Vida`,`C`.`Id_Trabajador` AS `Id_Trabajador`,`C`.`punteo` AS `punteo`,`C`.`odbc_date` AS `odbc_date`,`E`.`Inventario` AS `Inventario`,`E`.`Id_Proveedor` AS `Id_Proveedor`,`E`.`Fecha` AS `Fecha`,`E`.`Confirmada` AS `Confirmada`,`E`.`Redada` AS `Redada`,`E`.`empresa_id` AS `empresa_id`,`E`.`travel_id` AS `travel_id`,`E`.`Pedida` AS `Pedida`,`E`.`recibida_id` AS `recibida_id`,`TR`.`id` AS `id`,`TR`.`shipment` AS `shipment`,`TR`.`landing` AS `landing`,`TR`.`warehouse_id` AS `warehouse_id`,`TR`.`warehouse_id_out` AS `warehouse_id_out`,`TR`.`agency_id` AS `agency_id`,`TR`.`ref` AS `ref`,`TR`.`delivered` AS `delivered`,`TR`.`received` AS `received`,`A`.`Article` AS `Article`,`A`.`Medida` AS `Medida`,`A`.`Tallos` AS `Tallos`,`C`.`caja` AS `caja`,`A`.`Categoria` AS `Categoria`,`A`.`id_origen` AS `id_origen`,`TP`.`Id_Tipo` AS `Tipo`,`A`.`tipo_id` AS `tipo_id`,`A`.`Color` AS `Color`,`A`.`Min` AS `Min`,`C`.`Costefijo` + `C`.`Embalajefijo` + `C`.`Comisionfija` + `C`.`Portefijo` AS `Coste`,`W_OUT`.`isFeedStock` AS `fuente`,if(`cb`.`Volumen` > 0,`cb`.`Volumen`,`cb`.`X` * `cb`.`Y` * if(`cb`.`Z` = 0,`A`.`Medida` + 10,`cb`.`Z`)) * `C`.`Etiquetas` AS `cm3`,`A`.`producer_id` AS `producer_id` from ((((((((`vn2008`.`Compres` `C` join `vn2008`.`Entradas` `E` on(`C`.`Id_Entrada` = `E`.`Id_Entrada`)) join `vn2008`.`travel` `TR` on(`TR`.`id` = `E`.`travel_id`)) join `vn`.`warehouse` `W_IN` on(`W_IN`.`id` = `TR`.`warehouse_id`)) join `vn`.`warehouse` `W_OUT` on(`W_OUT`.`id` = `TR`.`warehouse_id_out`)) join `vn2008`.`Articles` `A` on(`C`.`Id_Article` = `A`.`Id_Article`)) join `vn2008`.`Tipos` `TP` on(`A`.`tipo_id` = `TP`.`tipo_id`)) join `vn2008`.`reinos` `RN` on(`RN`.`id` = `TP`.`reino_id`)) join `vn2008`.`Cubos` `cb` on(`cb`.`Id_Cubo` = `C`.`Id_Cubo`)) where `W_IN`.`isFeedStock` = 0 and `E`.`Inventario` = 0 and `E`.`Redada` = 0 */;
+/*!50001 VIEW `v_compres` AS select `TP`.`Id_Tipo` AS `Familia`,`RN`.`id` AS `reino_id`,`C`.`Id_Compra` AS `Id_Compra`,`C`.`Id_Entrada` AS `Id_Entrada`,`C`.`Id_Article` AS `Id_Article`,`C`.`Cantidad` AS `Cantidad`,`C`.`Costefijo` AS `Costefijo`,`C`.`Portefijo` AS `Portefijo`,`C`.`Novincular` AS `Novincular`,`C`.`Etiquetas` AS `Etiquetas`,`C`.`Packing` AS `Packing`,`C`.`grouping` AS `grouping`,`C`.`Comisionfija` AS `Comisionfija`,`C`.`Embalajefijo` AS `Embalajefijo`,`C`.`Id_Cubo` AS `Id_Cubo`,`C`.`Tarifa1` AS `Tarifa1`,`C`.`Tarifa2` AS `Tarifa2`,`C`.`Tarifa3` AS `Tarifa3`,`C`.`PVP` AS `PVP`,`C`.`Vida` AS `Vida`,`C`.`Id_Trabajador` AS `Id_Trabajador`,`C`.`punteo` AS `punteo`,`C`.`odbc_date` AS `odbc_date`,`E`.`Inventario` AS `Inventario`,`E`.`Id_Proveedor` AS `Id_Proveedor`,`E`.`Fecha` AS `Fecha`,`E`.`Confirmada` AS `Confirmada`,`E`.`empresa_id` AS `empresa_id`,`E`.`travel_id` AS `travel_id`,`E`.`Pedida` AS `Pedida`,`E`.`recibida_id` AS `recibida_id`,`TR`.`id` AS `id`,`TR`.`shipment` AS `shipment`,`TR`.`landing` AS `landing`,`TR`.`warehouse_id` AS `warehouse_id`,`TR`.`warehouse_id_out` AS `warehouse_id_out`,`TR`.`agency_id` AS `agency_id`,`TR`.`ref` AS `ref`,`TR`.`delivered` AS `delivered`,`TR`.`received` AS `received`,`A`.`Article` AS `Article`,`A`.`Medida` AS `Medida`,`A`.`Tallos` AS `Tallos`,`C`.`caja` AS `caja`,`A`.`Categoria` AS `Categoria`,`A`.`id_origen` AS `id_origen`,`TP`.`Id_Tipo` AS `Tipo`,`A`.`tipo_id` AS `tipo_id`,`A`.`Color` AS `Color`,`A`.`Min` AS `Min`,`C`.`Costefijo` + `C`.`Embalajefijo` + `C`.`Comisionfija` + `C`.`Portefijo` AS `Coste`,`W_OUT`.`isFeedStock` AS `fuente`,if(`cb`.`Volumen` > 0,`cb`.`Volumen`,`cb`.`X` * `cb`.`Y` * if(`cb`.`Z` = 0,`A`.`Medida` + 10,`cb`.`Z`)) * `C`.`Etiquetas` AS `cm3`,`A`.`producer_id` AS `producer_id` from ((((((((`vn2008`.`Compres` `C` join `vn2008`.`Entradas` `E` on(`C`.`Id_Entrada` = `E`.`Id_Entrada`)) join `vn2008`.`travel` `TR` on(`TR`.`id` = `E`.`travel_id`)) join `vn`.`warehouse` `W_IN` on(`W_IN`.`id` = `TR`.`warehouse_id`)) join `vn`.`warehouse` `W_OUT` on(`W_OUT`.`id` = `TR`.`warehouse_id_out`)) join `vn2008`.`Articles` `A` on(`C`.`Id_Article` = `A`.`Id_Article`)) join `vn2008`.`Tipos` `TP` on(`A`.`tipo_id` = `TP`.`tipo_id`)) join `vn2008`.`reinos` `RN` on(`RN`.`id` = `TP`.`reino_id`)) join `vn2008`.`Cubos` `cb` on(`cb`.`Id_Cubo` = `C`.`Id_Cubo`)) where `W_IN`.`isFeedStock` = 0 and `E`.`Inventario` = 0 and `TR`.`isRaid` = 0 */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -90472,4 +90949,4 @@ USE `vn2008`;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2024-10-03 7:42:53
+-- Dump completed on 2024-12-10 8:17:51
diff --git a/db/dump/.dump/triggers.sql b/db/dump/.dump/triggers.sql
index 74190df36..3299aea37 100644
--- a/db/dump/.dump/triggers.sql
+++ b/db/dump/.dump/triggers.sql
@@ -867,17 +867,17 @@ BEGIN
UPDATE vn.buy b
JOIN vn.entry e ON e.id = b.entryFk
- JOIN vn.travel tr ON tr.id = e.travelFk
- JOIN vn.agencyMode am ON am.id = tr.agencyModeFk
+ JOIN vn.travel tr ON tr.id = e.travelFk
+ JOIN vn.agencyMode am ON am.id = tr.agencyModeFk
JOIN vn.item i ON i.id = b.itemFk
JOIN edi.supplyResponse sr ON i.supplyResponseFk = sr.ID
SET b.quantity = NEW.NumberOfItemsPerCask * NEW.NumberOfUnits,
b.stickers = NEW.NumberOfUnits
WHERE i.supplyResponseFk = NEW.ID
AND am.name = 'LOGIFLORA'
- AND e.isRaid
+ AND tr.isRaid
AND tr.landed >= util.VN_CURDATE();
-
+
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -1128,6 +1128,28 @@ DELIMITER ;
/*!50003 SET 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 `hedera`.`orderRow_afterInsert`
+ AFTER INSERT ON `orderRow`
+ FOR EACH ROW
+BEGIN
+ UPDATE `order`
+ SET rowUpdated = util.VN_NOW()
+ WHERE id = NEW.orderFk;
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
--
-- Current Database: `pbx`
@@ -1438,6 +1460,9 @@ DELIMITER ;;
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
+ IF NEW.`property` = '*' THEN
+ CALL util.throw('The property field cannot be *');
+ END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -1978,6 +2003,7 @@ BEGIN
DECLARE vIsEqualizated BOOL;
SET NEW.editorFk = account.myUser_getId();
+ SET NEW.geoFk = address_getGeo(NEW.id);
IF (NEW.phone <> '') THEN
CALL pbx.phone_isValid(NEW.phone);
@@ -2014,7 +2040,6 @@ DELIMITER ;;
BEFORE UPDATE ON `address`
FOR EACH ROW
BEGIN
-
SET NEW.editorFk = account.myUser_getId();
IF !(NEW.phone <=> OLD.phone) AND (NEW.phone <> '') THEN
@@ -2025,6 +2050,11 @@ BEGIN
CALL pbx.phone_isValid(NEW.mobile);
END IF;
+ IF NOT (NEW.provinceFk <=> OLD.provinceFk)
+ OR (NEW.postalCode <=> OLD.postalCode) THEN
+
+ SET NEW.geoFk = address_getGeo(NEW.id);
+ END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -2432,11 +2462,21 @@ DELIMITER ;;
AFTER UPDATE ON `business`
FOR EACH ROW
BEGIN
+ DECLARE vIsActive BOOL;
+ DECLARE vExtension VARCHAR(10);
+
CALL worker_updateBusiness(NEW.workerFk);
IF NOT (OLD.workerFk <=> NEW.workerFk) THEN
CALL worker_updateBusiness(OLD.workerFk);
END IF;
+
+ IF NOT (OLD.departmentFk <=> NEW.departmentFk) THEN
+ SELECT COUNT(*) INTO vIsActive FROM worker WHERE businessFk = NEW.id;
+ IF vIsActive THEN
+ CALL queueMember_updateQueue(NEW.id);
+ END IF;
+ END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -3391,8 +3431,10 @@ DELIMITER ;;
BEFORE INSERT ON `client`
FOR EACH ROW
BEGIN
-
SET NEW.editorFk = account.myUser_getId();
+ SET NEW.accountingAccount = 4300000000 + NEW.id;
+ SET NEW.lastSalesPersonFk = NEW.salesPersonFk;
+ SET NEW.geoFk = client_getGeo(NEW.id);
IF (NEW.phone <> '') THEN
CALL pbx.phone_isValid(NEW.phone);
@@ -3401,10 +3443,6 @@ BEGIN
IF (NEW.mobile <> '') THEN
CALL pbx.phone_isValid(NEW.mobile);
END IF;
-
- SET NEW.accountingAccount = 4300000000 + NEW.id;
-
- SET NEW.lastSalesPersonFk = NEW.salesPersonFk;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -3518,6 +3556,12 @@ BEGIN
IF NOT (NEW.businessTypeFk <=> OLD.businessTypeFk) AND (NEW.businessTypeFk = 'individual' OR OLD.businessTypeFk = 'individual') THEN
SET NEW.isTaxDataChecked = 0;
END IF;
+
+ IF NOT (NEW.provinceFk <=> OLD.provinceFk)
+ OR (NEW.postcode <=> OLD.postcode) THEN
+
+ SET NEW.geoFk = client_getGeo(NEW.id);
+ END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -4928,7 +4972,7 @@ DELIMITER ;;
BEFORE UPDATE ON `entry`
FOR EACH ROW
BEGIN
- DECLARE vIsVirtual BOOL;
+ DECLARE vIsRaid BOOL;
DECLARE vPrintedCount INT;
DECLARE vHasDistinctWarehouses BOOL;
DECLARE vTotalBuy INT;
@@ -4962,18 +5006,20 @@ BEGIN
IF NEW.travelFk IS NOT NULL THEN
CALL travel_throwAwb(NEW.travelFk);
END IF;
-
- SELECT COUNT(*) > 0 INTO vIsVirtual
- FROM entryVirtual WHERE entryFk = NEW.id;
+
+ SELECT t.isRaid INTO vIsRaid
+ FROM travel t
+ JOIN entry e ON e.travelFk = t.id
+ WHERE e.id = NEW.id;
SELECT NOT (o.warehouseInFk <=> n.warehouseInFk)
- OR NOT (o.warehouseOutFk <=> n.warehouseOutFk)
+ OR NOT (o.warehouseOutFk <=> n.warehouseOutFk)
INTO vHasDistinctWarehouses
FROM travel o, travel n
WHERE o.id = OLD.travelFk
AND n.id = NEW.travelFk;
- IF vIsVirtual AND vHasDistinctWarehouses THEN
+ IF vIsRaid AND vHasDistinctWarehouses THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'A cloned entry cannot be moved to a travel with different warehouses';
END IF;
@@ -4996,7 +5042,7 @@ BEGIN
SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk);
END IF;
- IF NOT (NEW.travelFk <=> OLD.travelFk)
+ IF NOT (NEW.travelFk <=> OLD.travelFk)
OR NOT (NEW.currencyFk <=> OLD.currencyFk)
OR NOT (NEW.supplierFk <=> OLD.supplierFk) THEN
@@ -5293,7 +5339,8 @@ BEGIN
SET packages = (SELECT COUNT(counter)-1
FROM expedition e WHERE e.ticketFk = OLD.ticketFk and e.freightItemFk)
WHERE t.id = OLD.ticketFk;
-
+
+ CALL expedition_selfConsumptionPackaging(OLD.id, 'remove');
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -6400,7 +6447,7 @@ BEGIN
JOIN vn.route r ON r.id = t.routeFk
WHERE r.isOk = FALSE
AND ic.itemFk = NEW.itemFk
- AND r.created >= util.VN_CURDATE()
+ AND r.dated >= util.VN_CURDATE()
GROUP BY r.id;
IF NEW.cm3Delivery = 0 AND NEW.warehouseFk = 60 THEN
CALL mail_insert(
@@ -6499,36 +6546,6 @@ BEGIN
SET NEW.userFk = account.myUser_getId();
SET NEW.available = NEW.visible;
-END */;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_afterInsert`
- AFTER INSERT ON `itemShelving`
- FOR EACH ROW
-BEGIN
- INSERT INTO itemShelvingLog
- SET itemShelvingFk = NEW.id,
- workerFk = account.myUser_getId(),
- accion = 'CREA REGISTRO',
- itemFk = NEW.itemFk,
- shelvingFk = NEW.shelvingFk,
- visible = NEW.visible,
- `grouping` = NEW.`grouping`,
- packing = NEW.packing,
- available = NEW.available;
-
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -6554,6 +6571,9 @@ BEGIN
SET NEW.userFk = account.myUser_getId();
END IF;
+ IF NEW.shelvingFk <> OLD.shelvingFk THEN
+ SET NEW.movingState = NULL;
+ END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -6569,63 +6589,6 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_afterUpdate`
- AFTER UPDATE ON `itemShelving`
- FOR EACH ROW
-BEGIN
- INSERT INTO itemShelvingLog
- SET itemShelvingFk = NEW.id,
- workerFk = account.myUser_getId(),
- accion = 'CAMBIO',
- itemFk = NEW.itemFk,
- shelvingFk = NEW.shelvingFk,
- visible = NEW.visible,
- `grouping` = NEW.`grouping`,
- packing = NEW.packing,
- available = NEW.available;
-
-END */;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_beforeDelete`
- BEFORE DELETE ON `itemShelving`
- FOR EACH ROW
-INSERT INTO vn.itemShelvingLog(itemShelvingFk,
- workerFk,
- accion,
- shelvingFk,
- itemFk)
- VALUES( OLD.id,
- account.myUser_getId(),
- 'ELIMINADO',
- OLD.shelvingFk,
- OLD.itemFk) */;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_afterDelete`
AFTER DELETE ON `itemShelving`
FOR EACH ROW
@@ -6654,11 +6617,11 @@ DELIMITER ;;
AFTER INSERT ON `itemShelvingSale`
FOR EACH ROW
BEGIN
-
UPDATE sale s
JOIN operator o ON o.workerFk = account.myUser_getId()
- SET s.isPicked = IF(o.isOnReservationMode, s.isPicked, TRUE)
- WHERE id = NEW.saleFk;
+ JOIN sector se ON se.id = o.sectorFk
+ SET s.isPicked = IF(IFNULL(se.isOnReservationMode, o.isOnReservationMode), s.isPicked, TRUE)
+ WHERE s.id = NEW.saleFk;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -6874,10 +6837,31 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemType_beforeInsert`
+ BEFORE INSERT ON `itemType`
+ 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=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemType_beforeUpdate`
BEFORE UPDATE ON `itemType`
FOR EACH ROW
BEGIN
+ SET NEW.editorFk = account.myUser_getId();
IF NEW.itemPackingTypeFk = '' THEN
SET NEW.itemPackingTypeFk = NULL;
@@ -6904,6 +6888,30 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemType_afterDelete`
+ AFTER DELETE ON `itemType`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO itemTypeLog
+ SET `action` = 'delete',
+ `changedModel` = 'ItemType',
+ `changedModelId` = OLD.id,
+ `userFk` = 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=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`machine_beforeInsert`
BEFORE INSERT ON `machine`
FOR EACH ROW
@@ -7549,7 +7557,7 @@ DELIMITER ;;
AFTER DELETE ON `productionConfig`
FOR EACH ROW
BEGIN
- INSERT INTO productionConfig
+ INSERT INTO productionConfigLog
SET `action` = 'delete',
`changedModel` = 'ProductionConfig',
`changedModelId` = OLD.id,
@@ -8043,7 +8051,7 @@ BEGIN
SELECT IFNULL(b.workCenterFK, r.defaultWorkCenterFk)
FROM vn.routeConfig r
LEFT JOIN vn.business b ON b.workerFk = vUserFk
- AND NEW.created BETWEEN b.started AND IFNULL(b.ended, NEW.created));
+ AND NEW.dated BETWEEN b.started AND IFNULL(b.ended, NEW.dated));
IF ISNULL(NEW.agencyModeFk) THEN
SELECT r.agencyModeFk INTO vDefaultAgencyModeFk
@@ -8133,18 +8141,18 @@ DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`route_afterUpdate`
AFTER UPDATE ON `route`
FOR EACH ROW
-BEGIN
+BEGIN
IF IFNULL(NEW.gestdocFk,0) <> IFNULL(OLD.gestdocFk,0) AND NEW.gestdocFk > 0 THEN
-- JGF 09/09/14 cuando se añade un gestdoc a una ruta, se le asigna automagicamente a todos sus Tickets
-
+
-- Inserta el gestdoc en todos los tickets de la ruta
INSERT INTO ticketDms(ticketFk,dmsFk)
SELECT id, NEW.gestdocFk FROM ticket WHERE routeFk = NEW.id
ON DUPLICATE KEY UPDATE dmsFk = NEW.gestdocFk;
- -- Update del firmado
- UPDATE ticket t
- JOIN ticketDms tg ON t.id = tg.ticketFk
+ -- Update del firmado
+ UPDATE ticket t
+ JOIN ticketDms tg ON t.id = tg.ticketFk
SET isSigned = 1 WHERE t.routeFk = NEW.id;
END IF;
@@ -8152,7 +8160,8 @@ BEGIN
OR !(NEW.kmEnd <=> OLD.kmEnd)
OR !(NEW.workerFk <=> OLD.workerFk)
OR !(NEW.m3 <=> OLD.m3)
- OR !(NEW.agencyModeFk <=> OLD.agencyModeFk)THEN
+ OR !(NEW.agencyModeFk <=> OLD.agencyModeFk)
+ OR !(NEW.vehicleFk <=> OLD.vehicleFk)THEN
CALL route_calcCommission(NEW.id);
END IF;
@@ -8304,7 +8313,7 @@ BEGIN
JOIN vn.route r ON r.id = t.routeFk
WHERE r.isOk = FALSE
AND s.id = NEW.id
- AND r.created >= util.VN_CURDATE()
+ AND r.dated >= util.VN_CURDATE()
GROUP BY r.id;
END IF;
END */;;
@@ -8412,7 +8421,7 @@ BEGIN
JOIN vn.route r ON r.id = t.routeFk
WHERE r.isOk = FALSE
AND s.id = NEW.id
- AND r.created >= util.VN_CURDATE()
+ AND r.dated >= util.VN_CURDATE()
GROUP BY r.id;
END IF;
@@ -8454,7 +8463,7 @@ BEGIN
JOIN vn.route r ON r.id = t.routeFk
WHERE r.isOk = FALSE
AND s.id = OLD.id
- AND r.created >= util.VN_CURDATE()
+ AND r.dated >= util.VN_CURDATE()
GROUP BY r.id;
END IF;
END */;;
@@ -9051,6 +9060,7 @@ DELIMITER ;;
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
+ SET NEW.geoFk = supplier_getGeo(NEW.id);
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -9145,6 +9155,11 @@ BEGIN
SET NEW.isPayMethodChecked = FALSE;
END IF;
+ IF NOT (NEW.provinceFk <=> OLD.provinceFk)
+ OR (NEW.postCode <=> OLD.postCode) THEN
+
+ SET NEW.geoFk = supplier_getGeo(NEW.id);
+ END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -9555,7 +9570,7 @@ BEGIN
FROM `route`
WHERE NOT isOk
AND id IN (OLD.routeFk, NEW.routeFk)
- AND created >= util.VN_CURDATE()
+ AND dated >= util.VN_CURDATE()
GROUP BY id;
END IF;
@@ -9578,7 +9593,7 @@ BEGIN
JOIN vn.route r ON r.id = t.routeFk
WHERE r.isOk = FALSE
AND t.id = NEW.id
- AND r.created >= util.VN_CURDATE()
+ AND r.dated >= util.VN_CURDATE()
GROUP BY r.id;
SET NEW.shipped = DATE_FORMAT(NEW.shipped, '2000-%m-%d %T');
SET NEW.landed = DATE_FORMAT(NEW.landed, '2000-%m-%d %T');
@@ -9657,7 +9672,7 @@ BEGIN
FROM vn.route r
WHERE r.isOk = FALSE
AND r.id = OLD.routeFk
- AND r.created >= util.VN_CURDATE()
+ AND r.dated >= util.VN_CURDATE()
GROUP BY r.id;
DELETE FROM sale WHERE ticketFk = OLD.id;
@@ -9988,6 +10003,8 @@ DELIMITER ;;
BEFORE INSERT ON `ticketRefund`
FOR EACH ROW
BEGIN
+ CALL ticketRefund_upsert(NEW.refundTicketFk, NEW.originalTicketFk);
+
SET NEW.editorFk = account.myUser_getId();
END */;;
DELIMITER ;
@@ -10008,6 +10025,8 @@ DELIMITER ;;
BEFORE UPDATE ON `ticketRefund`
FOR EACH ROW
BEGIN
+ CALL ticketRefund_upsert(NEW.refundTicketFk, NEW.originalTicketFk);
+
SET NEW.editorFk = account.myUser_getId();
END */;;
DELIMITER ;
@@ -10462,28 +10481,6 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`town_beforeUpdate`
- BEFORE UPDATE ON `town`
- FOR EACH ROW
-BEGIN
- -- IF !(OLD.geoFk <=> NEW.geoFk) THEN
- -- CALL zoneGeo_throwNotEditable;
- -- END IF;
-END */;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`town_afterUpdate`
AFTER UPDATE ON `town`
FOR EACH ROW
@@ -10541,7 +10538,11 @@ BEGIN
CALL travel_checkDates(NEW.shipped, NEW.landed);
CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
-
+
+ IF NEW.isRaid IS NOT NULL OR NEW.daysInForward IS NOT NULL THEN
+ CALL travel_checkRaid(NEW.isRaid, NEW.daysInForward);
+ END IF;
+
IF NEW.awbFk IS NOT NULL THEN
CALL travel_throwAwb(NEW.id);
END IF;
@@ -10568,7 +10569,7 @@ BEGIN
SET NEW.editorFk = account.myUser_getId();
- IF NOT (NEW.landed <=> OLD.landed)
+ IF NOT (NEW.landed <=> OLD.landed)
OR NOT (NEW.shipped <=> OLD.shipped) THEN
CALL travel_checkDates(NEW.shipped, NEW.landed);
END IF;
@@ -10582,18 +10583,18 @@ BEGIN
END IF;
IF NOT (NEW.awbFk <=> OLD.awbFk)THEN
- SELECT COUNT(*) INTO vHasAnyInvoiceBooked
+ SELECT COUNT(*) INTO vHasAnyInvoiceBooked
FROM travel t
- JOIN entry e ON e.travelFk = t.id
- JOIN invoiceIn ii ON ii.id = e.invoiceInFk
+ JOIN entry e ON e.travelFk = t.id
+ JOIN invoiceIn ii ON ii.id = e.invoiceInFk
WHERE t.id = NEW.id
- AND ii.isBooked;
-
+ AND ii.isBooked;
+
IF vHasAnyInvoiceBooked THEN
CALL util.throw('The travel has entries with booked invoices');
END IF;
- END IF;
-
+ END IF;
+
IF (NOT(NEW.awbFk <=> OLD.awbFk)) AND NEW.awbFk IS NOT NULL THEN
CALL travel_throwAwb(NEW.id);
END IF;
@@ -10678,6 +10679,15 @@ DELIMITER ;;
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
+
+ IF NEW.travelFk IS NULL AND
+ (SELECT COUNT(*) FROM travelThermograph
+ WHERE thermographFk = NEW.thermographFk
+ AND travelFk IS NULL
+ AND id <> NEW.id) > 0
+ THEN
+ CALL util.throw('Duplicate thermographFk without travelFk not allowed.');
+ END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -10698,6 +10708,15 @@ DELIMITER ;;
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
+
+ IF NEW.travelFk IS NULL AND
+ (SELECT COUNT(*) FROM travelThermograph
+ WHERE thermographFk = NEW.thermographFk
+ AND travelFk IS NULL
+ AND id <> NEW.id) > 0
+ THEN
+ CALL util.throw('Duplicate thermographFk without travelFk not allowed.');
+ END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -11469,4 +11488,4 @@ USE `vn2008`;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2024-10-03 7:43:14
+-- Dump completed on 2024-12-10 8:18:11
diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql
index de1043b4f..5dde66f6e 100644
--- a/db/dump/fixtures.before.sql
+++ b/db/dump/fixtures.before.sql
@@ -400,11 +400,11 @@ INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city
(1108, 'Charles Xavier', '22641921P', 'PROFESSOR X', 'Beast', '3800 VICTORY PKWY, CINCINNATI, OH 45207, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 5, 1, 300, 13, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, NULL, 0, 0, 19, 0, 'florist','normal'),
(1109, 'Bruce Banner', '16104829E', 'HULK', 'Black widow', 'SOMEWHERE IN NEW YORK', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, 9, 0, 'florist','normal'),
(1110, 'Jessica Jones', '58282869H', 'JESSICA JONES', 'Luke Cage', 'NYCC 2015 POSTER', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, NULL, 1, 'florist','normal'),
- (1111, 'Missing', NULL, 'MISSING MAN', 'Anton', 'THE SPACE, UNIVERSE FAR AWAY', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses'),
- (1112, 'Trash', NULL, 'GARBAGE MAN', 'Unknown name', 'NEW YORK CITY, UNDERGROUND', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses');
+ (1111, 'Missing', NULL, 'MISSING MAN', 'Anton', 'THE SPACE, UNIVERSE FAR AWAY', 'Gotham', 46460, 1111111111, 222222222, 0, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses'),
+ (1112, 'Trash', NULL, 'GARBAGE MAN', 'Unknown name', 'NEW YORK CITY, UNDERGROUND', 'Gotham', 46460, 1111111111, 222222222, 0, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses');
INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`)
- SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), UPPER(CONCAT(name, 'Social')), CONCAT(name, 'Contact'), UPPER(CONCAT(name, 'Street')), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1
+ SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), UPPER(CONCAT(name, 'Social')), CONCAT(name, 'Contact'), UPPER(CONCAT(name, 'Street')), 'GOTHAM', 46460, 0, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1
FROM `account`.`role` `r`
WHERE `r`.`hasLogin` = 1;
@@ -745,15 +745,15 @@ INSERT INTO `vn`.`zoneClosure` (`zoneFk`, `dated`, `hour`)
INSERT INTO `vn`.`zoneConfig` (`id`, `scope`) VALUES (1, '1');
-INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agencyModeFk`, `description`, `m3`, `cost`, `started`, `finished`, `zoneFk`)
+INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agencyModeFk`, `description`, `m3`, `cost`, `started`, `finished`, `zoneFk`, `dated`)
VALUES
- (1, '1899-12-30 12:15:00', 56, util.VN_CURDATE(), 1, 1, 'first route', 1.8, 10, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1),
- (2, '1899-12-30 13:20:00', 56, util.VN_CURDATE(), 1, 2, 'second route', 0.2, 20, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 9),
- (3, '1899-12-30 14:30:00', 56, util.VN_CURDATE(), 2, 3, 'third route', 0.5, 30, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 10),
- (4, '1899-12-30 15:45:00', 56, util.VN_CURDATE(), 3, 4, 'fourth route', 0, 40, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 12),
- (5, '1899-12-30 16:00:00', 56, util.VN_CURDATE(), 4, 5, 'fifth route', 0.1, 50, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 13),
- (6, NULL, 57, util.VN_CURDATE(), 5, 7, 'sixth route', 1.7, 60, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 3),
- (7, NULL, 57, util.VN_CURDATE(), 6, 8, 'seventh route', 0, 70, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 5);
+ (1, '1899-12-30 12:15:00', 56, util.VN_CURDATE(), 1, 1, 'first route', 1.8, 10, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1, util.VN_CURDATE()),
+ (2, '1899-12-30 13:20:00', 56, util.VN_CURDATE(), 1, 2, 'second route', 0.2, 20, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 9, util.VN_CURDATE()),
+ (3, '1899-12-30 14:30:00', 56, util.VN_CURDATE(), 2, 3, 'third route', 0.5, 30, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 10, util.VN_CURDATE()),
+ (4, '1899-12-30 15:45:00', 56, util.VN_CURDATE(), 3, 4, 'fourth route', 0, 40, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 12, util.VN_CURDATE()),
+ (5, '1899-12-30 16:00:00', 56, util.VN_CURDATE(), 4, 5, 'fifth route', 0.1, 50, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 13, util.VN_CURDATE()),
+ (6, NULL, 57, util.VN_CURDATE(), 5, 7, 'sixth route', 1.7, 60, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 3, util.VN_CURDATE()),
+ (7, NULL, 57, util.VN_CURDATE(), 6, 8, 'seventh route', 0, 70, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 5, util.VN_CURDATE());
INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`, `weight`, `cmrFk`, `problem`, `risk`)
VALUES
@@ -1254,9 +1254,9 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`)
INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `visible`, `grouping`, `packing`,`buyFk`, `userFk`)
VALUES
- (2, 'GVC', 1, 1, 1, 2,1106),
- (4, 'HEJ', 1, 1, 1, NULL,1106),
- (1, 'UXN', 2, 12, 12, NULL,1106);
+ (2, 11, 1, 1, 1, 2,1106),
+ (4, 12, 1, 1, 1, NULL,1106),
+ (1, 13, 2, 12, 12, NULL,1106);
INSERT INTO `vn`.`itemShelvingSale` (`itemShelvingFk`, `saleFk`, `quantity`, `created`, `userFk`)
VALUES
@@ -1505,32 +1505,33 @@ INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk
(9, '99610289193', 302, 2972, util.VN_CURDATE(), 3871, 442, 1),
(10, '07546500856', 185, 2364, util.VN_CURDATE(), 5321, 442, 1);
-INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`, `awbFK`, `daysInForward`)
- VALUES (1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1, 1, NULL),
- (2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150.00, 2000, 'second travel', 2, 2, 2, NULL),
- (3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1, 3, NULL),
- (4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 3, 1, 50.00, 500, 'fourth travel', 0, 2, 4, NULL),
- (5, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1, 5, NULL),
- (6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2, 6, NULL),
- (7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1, 7, 2),
- (8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10, NULL),
- (10, DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10, 2),
- (11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, NULL),
- (12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, NULL);
+INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`, `awbFK`, `isRaid`, `daysInForward`)
+ VALUES (1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1, 1, FALSE, NULL),
+ (2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150.00, 2000, 'second travel', 2, 2, 2, FALSE, NULL),
+ (3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1, 3, FALSE, NULL),
+ (4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 3, 1, 50.00, 500, 'fourth travel', 0, 2, 4, FALSE, NULL),
+ (5, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1, 5, FALSE, NULL),
+ (6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2, 6, FALSE,NULL),
+ (7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1, 7, TRUE, 2),
+ (8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10, FALSE, NULL),
+ (10, DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10, TRUE, 2),
+ (11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL),
+ (12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL);
-INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `evaNotes`)
- VALUES
- (1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'IN2001', 'Movement 1', 0, ''),
- (2, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 442, 'IN2002', 'Movement 2', 0, 'observation two'),
- (3, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 0, 442, 'IN2003', 'Movement 3', 0, 'observation three'),
- (4, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 69, 'IN2004', 'Movement 4', 0, 'observation four'),
- (5, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 0, 442, 'IN2005', 'Movement 5', 0, 'observation five'),
- (6, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 6, 0, 442, 'IN2006', 'Movement 6', 0, 'observation six'),
- (7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 'observation seven'),
- (8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1,''),
- (9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, ''),
- (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 10', 1, ''),
- (99, 69, '2000-12-01 00:00:00.000', 11, 0, 442, 'IN2009', 'Movement 99', 0, '');
+INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `evaNotes`, `typeFk`)
+ VALUES
+ (1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'IN2001', 'Movement 1', 0, '', 'packaging'),
+ (2, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 442, 'IN2002', 'Movement 2', 0, 'observation two' , 'product'),
+ (3, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 0, 442, 'IN2003', 'Movement 3', 0, 'observation three', 'product'),
+ (4, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 69, 'IN2004', 'Movement 4', 0, 'observation four' , 'product'),
+ (5, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 0, 442, 'IN2005', 'Movement 5', 0, 'observation five' , 'product'),
+ (6, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 6, 0, 442, 'IN2006', 'Movement 6', 0, 'observation six' , 'product'),
+ (7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 'observation seven', 'product'),
+ (8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, '', 'product'),
+ (9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, '', 'product'),
+ (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 10',1, '', 'product'),
+ (11, 4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'IN2001', 'Movement 11',0, '', 'product'),
+ (99, 69, util.VN_CURDATE() - INTERVAL 1 MONTH, 11, 0, 442, 'IN2009', 'Movement 99',0, '', 'product');
INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`)
VALUES (2, 4, 1);
@@ -1570,7 +1571,8 @@ INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `sal
(13, 7, 1, 50, 0, 3, 1, 2.000, 2.000, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()),
(14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 7.30, 7.00, 0, 1, 0, 4, util.VN_CURDATE()),
(15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()),
- (16, 99,1,50.0000, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.60, 99.40, 0, 1, 0, 1.00, '2024-07-30 08:13:51.000');
+ (16, 99,1,50.0000, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.60, 99.40, 0, 1, 0, 1.00, '2024-07-30 08:13:51.000'),
+ (17, 11, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH);
INSERT INTO `hedera`.`order`(`id`, `date_send`, `customer_id`, `delivery_method_id`, `agency_id`, `address_id`, `company_id`, `note`, `source_app`, `confirmed`,`total`, `date_make`, `first_row_stamp`, `confirm_date`)
VALUES
@@ -2040,7 +2042,7 @@ INSERT INTO `vn`.`ticketService`(`id`, `description`, `quantity`, `price`, `taxC
INSERT INTO `pbx`.`config` (id,defaultPrefix)
VALUES (1,'0034');
-INSERT INTO `pbx`.`prefix` (country, prefix)
+INSERT IGNORE INTO `pbx`.`prefix` (country, prefix)
VALUES
('es', '0034'),
('fr', '0033'),
@@ -2469,7 +2471,8 @@ INSERT INTO `vn`.`dmsType`
(20, 'Reclamación', 1, 1, 'claim'),
(21, 'Entrada', 1, 1, 'entry'),
(22, 'Proveedor', 1, 1, 'supplier'),
- (23, 'Termografos', 35, 35, 'thermograph');
+ (23, 'Termografos', 35, 35, 'thermograph'),
+ (24, 'Sello de calidad', 1, 1, 'qualitySeal');
INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `contentType`, `workerFk`, `warehouseFk`, `companyFk`, `hardCopyNumber`, `hasFile`, `reference`, `description`, `created`)
VALUES
@@ -2513,10 +2516,6 @@ INSERT INTO `vn`.`queuePriority`(`id`, `priority`, `code`)
(2, 'Normal', 'normal'),
(3, 'Baja', 'low');
-INSERT INTO `vn`.`workerTimeControlParams` (`id`, `dayBreak`, `weekBreak`, `weekScope`, `dayWorkMax`, `dayStayMax`, `weekMaxBreak`, `weekMaxScope`, `askInOut`)
- VALUES
- (1, 43200, 129600, 734400, 43200, 50400, 259200, 1296000, 36000);
-
INSERT IGNORE INTO `vn`.`greugeConfig` (`id`, `freightPickUpPrice`) VALUES ('1', '11');
INSERT INTO `vn`.`thermograph`(`id`, `model`)
@@ -2947,9 +2946,9 @@ INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`)
VALUES
(1, 9);
-INSERT INTO `vn`.`productionConfig` (`isPreviousPreparationRequired`, `ticketPrintedMax`, `ticketTrolleyMax`, `rookieDays`, `notBuyingMonths`, `id`, `isZoneClosedByExpeditionActivated`, `maxNotReadyCollections`, `minTicketsToCloseZone`, `movingTicketDelRoute`, `defaultZone`, `defautlAgencyMode`, `hasUniqueCollectionTime`, `maxCollectionWithoutUser`, `pendingCollectionsOrder`, `pendingCollectionsAge`, `backupPrinterNotificationDelay`)
+INSERT INTO `vn`.`productionConfig` (`isPreviousPreparationRequired`, `ticketPrintedMax`, `ticketTrolleyMax`, `rookieDays`, `notBuyingMonths`, `id`, `isZoneClosedByExpeditionActivated`, `maxNotReadyCollections`, `minTicketsToCloseZone`, `movingTicketDelRoute`, `defaultZone`, `defautlAgencyMode`, `hasUniqueCollectionTime`, `maxCollectionWithoutUser`, `pendingCollectionsOrder`, `pendingCollectionsAge`, `backupPrinterNotificationDelay`, `clientSelfConsumptionFk`, `addressSelfConsumptionFk`)
VALUES
- (0, 8, 80, 0, 0, 1, 0, 15, 25, -1, 697, 1328, 0, 1, 8, 6, 3600);
+ (0, 8, 80, 0, 0, 1, 0, 15, 25, -1, 697, 1328, 0, 1, 8, 6, 3600, 1112, 12);
INSERT INTO `vn`.`collection` (`id`, `created`, `workerFk`, `stateFk`, `itemPackingTypeFk`, `saleTotalCount`, `salePickedCount`, `trainFk`, `sectorFk`, `wagons`)
VALUES
@@ -3417,7 +3416,7 @@ INSERT INTO vn.buy
INSERT INTO vn.itemShelving
SET id = 9931,
itemFk = 999993,
- shelvingFk = 'NCC',
+ shelvingFk = 16,
visible = 10,
`grouping` = 5,
packing = 10;
@@ -3744,7 +3743,7 @@ INSERT vn.sale
USE vn;
DELETE ish.* FROM vn.itemShelving ish
- JOIN vn.shelving sh ON sh.code = ish.shelvingFk
+ JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
JOIN vn.sector s ON s.id = p.sectorFk
JOIN vn.warehouse w ON w.id = s.warehouseFk
@@ -3753,22 +3752,23 @@ DELETE ish.* FROM vn.itemShelving ish
INSERT INTO vn.itemShelving
(itemFk, shelvingFk, visible, created, `grouping`, packing, packagingFk, userFk, isChecked)
VALUES
- (999991, 'NAA', 8, '2023-09-20', 1, 20, NULL, 103, NULL),
- (999998, 'NAA', 80, '2023-09-20', 10, 30, NULL, 103, NULL),
- (1000001, 'NAA', 6, '2023-09-20', 3, 50, NULL, 103, NULL),
- (1000000, 'NBB', 50, '2023-09-18', 25, 500, NULL, 103, NULL),
- (999993, 'NBB', 25, '2023-09-18', NULL, 10, NULL, 103, NULL),
- (999999, 'NBB', 30, '2023-09-18', 10, 500, NULL, 103, NULL),
- (999993, 'NCC', 25, '2023-09-20', 5, 10, NULL, 103, NULL),
- (999997, 'NCC', 10, '2023-09-20', NULL, 100, NULL, 103, NULL),
- (999999, 'NCC', 40, '2023-09-20', 10, 500, NULL, 103, NULL),
- (999995, 'NDD', 10, '2023-09-19', NULL, 20, NULL, 103, NULL),
- (999994, 'NDD', 48, '2023-09-19', 4, 20, NULL, 103, NULL),
- (1000001, 'NEE', 6, '2023-09-21', 3, 50, NULL, 103, NULL),
- (999992, 'NEE', 50, '2023-09-21', NULL, 1, NULL, 103, NULL),
- (1000000, 'NEE', 25, '2023-09-21', 25, 500, NULL, 103, NULL),
- (999996, 'PAA', 5, '2023-09-27', 1, 5, NULL, 103, NULL),
- (999997, 'PCC', 10, '2023-09-27', 5, 100, NULL, 103, NULL);
+ (999991, 14, 8, '2023-09-20', 1, 20, NULL, 103, NULL),
+ (999998, 14, 80, '2023-09-20', 10, 30, NULL, 103, NULL),
+ (1000001, 14, 6, '2023-09-20', 3, 50, NULL, 103, NULL),
+ (1000000, 15, 50, '2023-09-18', 25, 500, NULL, 103, NULL),
+ (999993, 15, 25, '2023-09-18', NULL, 10, NULL, 103, NULL),
+ (999999, 15, 30, '2023-09-18', 10, 500, NULL, 103, NULL),
+ (999993, 16, 25, '2023-09-20', 5, 10, NULL, 103, NULL),
+ (999997, 16, 10, '2023-09-20', NULL, 100, NULL, 103, NULL),
+ (999999, 16, 40, '2023-09-20', 10, 500, NULL, 103, NULL),
+ (999995, 17, 10, '2023-09-19', NULL, 20, NULL, 103, NULL),
+ (999994, 17, 48, '2023-09-19', 4, 20, NULL, 103, NULL),
+ (1000001, 18, 6, '2023-09-21', 3, 50, NULL, 103, NULL),
+ (999992, 18, 50, '2023-09-21', NULL, 1, NULL, 103, NULL),
+ (1000000, 18, 25, '2023-09-21', 25, 500, NULL, 103, NULL),
+ (999996, 19, 5, '2023-09-27', 1, 5, NULL, 103, NULL),
+ (999997, 21, 10, '2023-09-27', 5, 100, NULL, 103, NULL),
+ (1000000, 16, 25, '2023-08-21',25, 500, NULL, NULL, NULL);
-- Previous for Bolas de madera
INSERT IGNORE INTO vn.sectorCollection
@@ -3998,4 +3998,41 @@ INSERT IGNORE INTO pbx.queueMember
extension = '1111';
UPDATE vn.department SET pbxQueue = '1000' WHERE name = "CAMARA";
-UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS";
\ No newline at end of file
+UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS";
+UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS";
+
+INSERT INTO vn.workerRelatives (workerFk, isDescendant, disabilityGradeFk, birthed, adoptionYear, isDependend, isJointCustody, updated)
+ VALUES
+ (1106, 1, NULL, 0, NULL, 0, 0, '2024-10-29 08:42:44.000');
+INSERT INTO vn.routeAction (id, name, price, isMainlineDelivered) VALUES(1, 'Pintar traje', 50.00, 0);
+INSERT INTO vn.routeComplement (id, dated, workerFk, price, routeActionFk) VALUES(1, util.VN_CURDATE(), 9, 50.00, 1);
+
+
+INSERT INTO srt.buffer (id, x, y, `size`, `length`, stateFk, typeFk, isActive, code, stratus, hasWorkerWaiting, reserve, routeFk, dayMinute, lastUnloaded, hasStrapper, typeDefaultFk, motors, editorFk)
+ VALUES (0, 0, 0, 0, NULL, 3, 1, 0, 'ENT', 0, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL),
+ (1, 0, 9900, 0, NULL, 1, 0, 0, 'NOK', 0, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL),
+ (2, 0, 0, 450, 13000, 1, 0, 1, '01A', 1, 1, NULL, NULL, NULL, NULL, 0, 1, 1, NULL),
+ (3, 1400, 0, 450, 13000, 1, 0, 1, '01B', 1, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL),
+ (4, 0, 500, 500, 13000, 1, 4, 1, '02A', 2, 1, NULL, NULL, NULL, NULL, 1, 4, 13, NULL),
+ (5, 1400, 500, 500, 13000, 1, 4, 1, '02B', 2, 1, NULL, NULL, NULL, NULL, 1, 4, 13, NULL),
+ (6, 0, 1000, 500, 13000, 1, 1, 1, '03A', 3, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL),
+ (7, 1400, 1000, 500, 13000, 1, 1, 1, '03B', 3, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL),
+ (8, 0, 1500, 500, 13000, 1, 0, 1, '04A', 4, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL),
+ (9, 1400, 1500, 500, 13000, 1, 1, 1, '04B', 4, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL),
+ (10, 0, 2000, 500, 13000, 1, 1, 1, '05A', 5, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL);
+
+INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel)
+ VALUES (19, '1169'),
+ (8, '1183'),
+ (1, '1320');
+
+INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel)
+ VALUES ('saysimle-url-mock', '1819');
+
+INSERT INTO vn.workerIrpf (workerFk,spouseNif, geographicMobilityDate)
+ VALUES (1106,'26493101E','2019-09-20');
+
+
+INSERT IGNORE INTO vn.inventoryConfig
+ SET id = 1,
+ supplierFk = 4;
diff --git a/db/routines/account/views/myUser.sql b/db/routines/account/views/myUser.sql
index f520d893b..8d927dc0f 100644
--- a/db/routines/account/views/myUser.sql
+++ b/db/routines/account/views/myUser.sql
@@ -7,8 +7,7 @@ AS SELECT `u`.`id` AS `id`,
`u`.`email` AS `email`,
`u`.`nickname` AS `nickname`,
`u`.`lang` AS `lang`,
- `u`.`role` AS `role`,
- `u`.`recoverPass` AS `recoverPass`
+ `u`.`role` AS `role`
FROM `account`.`user` `u`
WHERE `u`.`name` = `myUser_getName`()
WITH CASCADED CHECK OPTION
diff --git a/db/routines/bi/procedures/rutasAnalyze.sql b/db/routines/bi/procedures/rutasAnalyze.sql
index e277968bf..1f103bde0 100644
--- a/db/routines/bi/procedures/rutasAnalyze.sql
+++ b/db/routines/bi/procedures/rutasAnalyze.sql
@@ -19,14 +19,14 @@ BEGIN
bultos)
SELECT r.id,
r.agencyModeFk,
- r.created,
+ r.dated,
SUM(sv.volume / ebv.m3)
FROM vn.route r
JOIN vn.ticket t ON t.routeFk = r.id
LEFT JOIN vn.`zone` z ON z.id = t.zoneFk
JOIN vn.saleVolume sv ON sv.ticketFk = t.id
JOIN vn.expeditionBoxVol ebv ON ebv.code = 'transportBox'
- WHERE r.created BETWEEN vDatedFrom AND vDatedTo
+ WHERE r.dated BETWEEN vDatedFrom AND vDatedTo
AND z.isVolumetric
GROUP BY r.id;
@@ -38,12 +38,12 @@ BEGIN
Bultos)
SELECT r.id,
r.agencyModeFk,
- r.created,
+ r.dated,
SUM(t.packages)
FROM vn.route r
JOIN vn.ticket t ON t.routeFk = r.id
LEFT JOIN vn.`zone` z ON z.id = t.zoneFk
- WHERE r.created BETWEEN vDatedFrom AND vDatedTo
+ WHERE r.dated BETWEEN vDatedFrom AND vDatedTo
AND NOT z.isVolumetric
GROUP BY r.id
ON DUPLICATE KEY UPDATE Bultos = Bultos + VALUES(Bultos);
@@ -60,7 +60,7 @@ BEGIN
JOIN vn.component c ON c.id = sc.componentFk
JOIN vn.componentType ct ON ct.id = c.typeFk
WHERE ct.code = 'freight'
- AND r.created BETWEEN vDatedFrom AND vDatedTo
+ AND r.dated BETWEEN vDatedFrom AND vDatedTo
GROUP BY r.id
) sub ON sub.routeFk = r.Id_Ruta
SET r.practico = IFNULL(sub.totalPractice / r.Bultos, 0);
@@ -77,7 +77,7 @@ BEGIN
JOIN vn.address ad ON ad.id = t.addressFk
JOIN vn.client c ON c.id = ad.clientFk
LEFT JOIN vn.`zone` z ON z.id = t.zoneFk
- WHERE r.created BETWEEN vDatedFrom AND vDatedTo
+ WHERE r.dated BETWEEN vDatedFrom AND vDatedTo
AND NOT z.isVolumetric
GROUP BY t.routeFk
) sub ON r.Id_Ruta = sub.routeFk
@@ -93,7 +93,7 @@ BEGIN
JOIN vn.saleVolume sf ON sf.ticketFk = t.id
JOIN vn.client c ON c.id = t.clientFk
JOIN vn.`zone` z ON z.id = t.zoneFk
- WHERE r.created BETWEEN vDatedFrom AND vDatedTo
+ WHERE r.dated BETWEEN vDatedFrom AND vDatedTo
AND z.isVolumetric
GROUP BY t.routeFk
) sub ON r.Id_Ruta = sub.routeFk
@@ -108,7 +108,7 @@ BEGIN
JOIN vn.route r ON r.id = t.routeFk
JOIN vn.greuge g ON g.ticketFk = t.id
JOIN vn.greugeType gt ON gt.id = g.greugeTypeFk
- WHERE r.created BETWEEN vDatedFrom AND vDatedTo
+ WHERE r.dated BETWEEN vDatedFrom AND vDatedTo
AND gt.code = 'freightDifference'
GROUP BY t.routeFk
) sub ON r.Id_Ruta = sub.routeFk
diff --git a/db/routines/bi/views/rotacion.sql b/db/routines/bi/views/rotacion.sql
deleted file mode 100644
index 65a5db923..000000000
--- a/db/routines/bi/views/rotacion.sql
+++ /dev/null
@@ -1,15 +0,0 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
- SQL SECURITY DEFINER
- VIEW `bi`.`rotacion`
-AS SELECT `ic`.`itemFk` AS `Id_Article`,
- `ic`.`warehouseFk` AS `warehouse_id`,
- `ic`.`quantity` AS `total`,
- `ic`.`rotation` AS `rotacion`,
- `ic`.`cm3` AS `cm3`,
- `ic`.`storage` AS `almacenaje`,
- `ic`.`handling` AS `manipulacion`,
- `ic`.`extraCharge` AS `auxiliar`,
- `ic`.`wasted` AS `mermas`,
- `ic`.`cm3delivery` AS `cm3reparto`,
- `ic`.`grams` AS `grams`
-FROM `vn`.`itemCost` `ic`
diff --git a/db/routines/bs/procedures/inventoryDiscrepancyDetail_replace.sql b/db/routines/bs/procedures/inventoryDiscrepancyDetail_replace.sql
index 863005373..b698f0e3e 100644
--- a/db/routines/bs/procedures/inventoryDiscrepancyDetail_replace.sql
+++ b/db/routines/bs/procedures/inventoryDiscrepancyDetail_replace.sql
@@ -32,7 +32,7 @@ BEGIN
CREATE OR REPLACE TEMPORARY TABLE tVisible
SELECT itemFk, SUM(visible) totalVisible
FROM vn.itemShelving ish
- JOIN vn.shelving sh ON sh.code = ish.shelvingFk
+ JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
JOIN vn.sector sc ON sc.id = p.sectorFk
WHERE sc.warehouseFk = vWarehouseFk
diff --git a/db/routines/cache/procedures/availableNoRaids_refresh.sql b/db/routines/cache/procedures/availableNoRaids_refresh.sql
index efbbf6a13..447300305 100644
--- a/db/routines/cache/procedures/availableNoRaids_refresh.sql
+++ b/db/routines/cache/procedures/availableNoRaids_refresh.sql
@@ -53,7 +53,7 @@ proc: BEGIN
WHERE t.landed BETWEEN vInventoryDate AND vStartDate
AND t.warehouseInFk = vWarehouse
AND s.name != 'INVENTARIO'
- AND NOT t.daysInForward
+ AND NOT t.isRaid
GROUP BY b.itemFk
) c
JOIN vn.item i ON i.id = c.itemFk
diff --git a/db/routines/edi/triggers/supplyResponse_afterUpdate.sql b/db/routines/edi/triggers/supplyResponse_afterUpdate.sql
index 28a8c9466..f3e5aaefd 100644
--- a/db/routines/edi/triggers/supplyResponse_afterUpdate.sql
+++ b/db/routines/edi/triggers/supplyResponse_afterUpdate.sql
@@ -14,7 +14,7 @@ BEGIN
b.stickers = NEW.NumberOfUnits
WHERE i.supplyResponseFk = NEW.ID
AND am.name = 'LOGIFLORA'
- AND tr.daysInForward
+ AND tr.isRaid
AND tr.landed >= util.VN_CURDATE();
END$$
diff --git a/db/routines/hedera/procedures/item_getVisible.sql b/db/routines/hedera/procedures/item_getVisible.sql
index 365161bdf..d5bbe9d76 100644
--- a/db/routines/hedera/procedures/item_getVisible.sql
+++ b/db/routines/hedera/procedures/item_getVisible.sql
@@ -59,7 +59,7 @@ BEGIN
JOIN vn.travel t ON t.id = e.travelFk
WHERE t.landed BETWEEN vDateInv AND vDate
AND t.warehouseInFk = vWarehouse
- AND NOT t.daysInForward
+ AND NOT t.isRaid
UNION ALL
SELECT b.itemFk, -b.quantity
FROM vn.buy b
@@ -67,7 +67,7 @@ BEGIN
JOIN vn.travel t ON t.id = e.travelFk
WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE()
AND t.warehouseOutFk = vWarehouse
- AND NOT t.daysInForward
+ AND NOT t.isRaid
AND t.isDelivered
UNION ALL
SELECT m.itemFk, -m.quantity
diff --git a/db/routines/hedera/procedures/order_getTax.sql b/db/routines/hedera/procedures/order_getTax.sql
index d24ffe7ef..371416c29 100644
--- a/db/routines/hedera/procedures/order_getTax.sql
+++ b/db/routines/hedera/procedures/order_getTax.sql
@@ -9,45 +9,54 @@ BEGIN
* @param vOrder El identificador del pedido
* @return tmp.orderTax Bases imponibles, IVA y recargo de equivalencia
*/
+ -- No poner create or replace, ya que da problemas
DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany;
CREATE TEMPORARY TABLE tmp.addressCompany
(INDEX (addressFk, companyFk))
ENGINE = MEMORY
SELECT DISTINCT o.address_id addressFk, o.company_id companyFk
FROM tmp.`order` tmpOrder
- JOIN hedera.`order` o ON o.id = tmpOrder.orderFk;
+ JOIN `order` o ON o.id = tmpOrder.orderFk;
- CALL vn.addressTaxArea;
+ CALL vn.addressTaxArea();
-- Calcula el IVA y el recargo desglosado.
-
- DROP TEMPORARY TABLE IF EXISTS tmp.orderTax;
- CREATE TEMPORARY TABLE tmp.orderTax
- (INDEX (orderFk))
+ CREATE OR REPLACE TEMPORARY TABLE tmp.orderTax
+ (PRIMARY KEY (orderFk, code, rate))
ENGINE = MEMORY
- SELECT o.id orderFk,
+ WITH orders AS (
+ SELECT tor.orderFk,
+ oro.amount * oro.price total,
+ s.countryFk,
+ ata.areaFk,
+ itc.taxClassFk
+ FROM hedera.orderRow oro
+ JOIN tmp.order tor ON tor.orderFk = oro.orderFk
+ JOIN hedera.`order` o ON o.id = tor.orderFk
+ JOIN vn.item i ON i.id = oro.itemFk
+ JOIN vn.`client` c ON c.id = o.customer_id
+ JOIN vn.supplier s ON s.id = o.company_id
+ JOIN tmp.addressTaxArea ata ON ata.addressFk = o.address_id
+ AND ata.companyFk = o.company_id
+ JOIN vn.itemTaxCountry itc ON itc.itemFk = i.id
+ AND itc.countryFk = s.countryFk
+ HAVING total
+ )
+ SELECT o.orderFk,
tc.code,
- SUM(m.amount * m.price) taxableBase,
+ SUM(o.total) taxableBase,
pgc.rate
- FROM tmp.`order` tmpOrder
- JOIN `order` o ON o.id = tmpOrder.orderFk
- JOIN orderRow m ON m.orderFk = o.id
- JOIN vn.item i ON i.id = m.itemFk
- JOIN vn.`client` c ON c.id = o.customer_id
- JOIN vn.supplier s ON s.id = o.company_id
- JOIN tmp.addressTaxArea ata
- ON ata.addressFk = o.address_id AND ata.companyFk = o.company_id
- JOIN vn.itemTaxCountry itc
- ON itc.itemFk = i.id AND itc.countryFk = s.countryFk
- JOIN vn.bookingPlanner bp
- ON bp.countryFk = s.countryFk
- AND bp.taxAreaFk = ata.areaFk
- AND bp.taxClassFk = itc.taxClassFk
- JOIN vn.pgc ON pgc.`code` = bp.pgcFk
+ FROM orders o
+ JOIN vn.bookingPlanner bp ON bp.countryFk = o.countryFk
+ AND bp.taxAreaFk = o.areaFk
+ AND bp.taxClassFk = o.taxClassFk
+ JOIN vn.pgc ON pgc.code = bp.pgcFk
JOIN vn.taxClass tc ON tc.id = bp.taxClassFk
- GROUP BY tmpOrder.orderFk, pgc.`code`, pgc.rate
- HAVING taxableBase != 0;
+ GROUP BY o.orderFk, pgc.code, pgc.rate
+ HAVING taxableBase
+ ORDER BY bp.priority;
+ -- No poner create or replace, ya que da problemas
DROP TEMPORARY TABLE IF EXISTS tmp.orderAmount;
CREATE TEMPORARY TABLE tmp.orderAmount
(INDEX (orderFk))
diff --git a/db/routines/sage/procedures/invoiceIn_add.sql b/db/routines/sage/procedures/invoiceIn_add.sql
index 0898d6810..1d411cfd0 100644
--- a/db/routines/sage/procedures/invoiceIn_add.sql
+++ b/db/routines/sage/procedures/invoiceIn_add.sql
@@ -26,7 +26,7 @@ BEGIN
DECLARE vCursor CURSOR FOR
SELECT it.taxableBase,
- CAST((( it.taxableBase / 100) * t.PorcentajeIva) AS DECIMAL (10,2)),
+ CAST(SUM((( it.taxableBase / 100) * t.PorcentajeIva)) AS DECIMAL (10,2)),
t.PorcentajeIva,
it.transactionTypeSageFk,
it.taxTypeSageFk,
@@ -39,7 +39,8 @@ BEGIN
JOIN TiposTransacciones tt ON tt.CodigoTransaccion = it.transactionTypeSageFk
LEFT JOIN vn.dua d ON d.id = vInvoiceInFk
WHERE i.id = vInvoiceInFk
- AND d.id IS NULL;
+ AND d.id IS NULL
+ GROUP BY it.taxTypeSageFk;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
diff --git a/db/routines/stock/procedures/log_refreshBuy.sql b/db/routines/stock/procedures/log_refreshBuy.sql
index d8e727f17..874e14072 100644
--- a/db/routines/stock/procedures/log_refreshBuy.sql
+++ b/db/routines/stock/procedures/log_refreshBuy.sql
@@ -6,12 +6,11 @@ BEGIN
DROP TEMPORARY TABLE IF EXISTS tValues;
CREATE TEMPORARY TABLE tValues
ENGINE = MEMORY
- SELECT
- b.id buyFk,
+ SELECT b.id buyFk,
e.id entryFk,
t.id travelFk,
b.itemFk,
- t.daysInForward,
+ t.isRaid,
ADDTIME(t.shipped,
IFNULL(t.shipmentHour, '00:00:00')) shipped,
t.warehouseOutFk,
@@ -50,7 +49,7 @@ BEGIN
itemFk,
TIMESTAMPADD(DAY, life, @dated),
quantity,
- IF(isIn, isReceived, isDelivered) AND NOT daysInForward
+ IF(isIn, isReceived, isDelivered) AND NOT isRaid
FROM tValues
WHERE isIn OR !lessThanInventory;
@@ -65,7 +64,7 @@ BEGIN
itemFk,
created,
quantity,
- IF(isIn, isDelivered, isReceived) AND NOT daysInForward
+ IF(isIn, isDelivered, isReceived) AND NOT isRaid
FROM tValues
WHERE !isIn OR !lessThanInventory;
diff --git a/db/routines/vn/functions/address_getGeo.sql b/db/routines/vn/functions/address_getGeo.sql
index 04155c30c..213eb91c3 100644
--- a/db/routines/vn/functions/address_getGeo.sql
+++ b/db/routines/vn/functions/address_getGeo.sql
@@ -14,9 +14,12 @@ BEGIN
SELECT p.geoFk INTO vGeoFk
FROM address a
JOIN town t ON t.provinceFk = a.provinceFk
- JOIN postCode p ON p.townFk = t.id AND p.`code` = a.postalCode
+ JOIN postCode p ON p.townFk = t.id
+ AND (p.code = a.postalCode OR a.postalCode IS NULL)
+ JOIN zoneGeo zg ON zg.id = p.geoFk
WHERE a.id = vSelf
- ORDER BY (a.city SOUNDS LIKE t.`name`) DESC
+ ORDER BY (a.city SOUNDS LIKE t.name) DESC,
+ (p.code = a.postalCode) DESC
LIMIT 1;
RETURN vGeoFk;
diff --git a/db/routines/vn/functions/buy_getLastWithoutInventory.sql b/db/routines/vn/functions/buy_getLastWithoutInventory.sql
new file mode 100644
index 000000000..ac19fe416
--- /dev/null
+++ b/db/routines/vn/functions/buy_getLastWithoutInventory.sql
@@ -0,0 +1,32 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`buy_getLastWithoutInventory`(
+ vItemFk INT,
+ vWarehouseFk INT
+)
+ RETURNS int(11)
+ DETERMINISTIC
+BEGIN
+/**
+ * Retorna la última compra que no sea inventario.
+ *
+ * @param vItemFk Id del artículo
+ * @param vWarehouseFk Id del almacén
+ * @return Id de compra
+ */
+ DECLARE vBuyFk INT;
+
+ SELECT b.id INTO vBuyFk
+ FROM buy b
+ JOIN entry e ON e.id = b.entryFk
+ JOIN travel t ON t.id = e.travelFk
+ WHERE e.id <> (SELECT defaultEntry FROM entryConfig)
+ AND e.supplierFk <> (SELECT supplierFk FROM inventoryConfig)
+ AND e.typeFk <> 'inventory'
+ AND b.itemFk = vItemFk
+ AND (t.warehouseInFk = vWarehouseFk OR t.warehouseInFk IS NULL)
+ ORDER BY ABS(DATEDIFF(util.VN_CURDATE(), t.landed)), e.created DESC
+ LIMIT 1;
+
+ RETURN vBuyFk;
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/functions/client_getGeo.sql b/db/routines/vn/functions/client_getGeo.sql
new file mode 100644
index 000000000..9c2e3212e
--- /dev/null
+++ b/db/routines/vn/functions/client_getGeo.sql
@@ -0,0 +1,27 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`client_getGeo`(vSelf INT)
+ RETURNS int(11)
+ DETERMINISTIC
+BEGIN
+/**
+ * Returns the geo for the passed client.
+ *
+ * @param vSelf The address id
+ * @return The geo id
+ */
+ DECLARE vGeoFk INT;
+
+ SELECT p.geoFk INTO vGeoFk
+ FROM client c
+ JOIN town t ON t.provinceFk = c.provinceFk
+ JOIN postCode p ON p.townFk = t.id
+ AND (p.code = c.postcode OR c.postcode IS NULL)
+ JOIN zoneGeo zg ON zg.id = p.geoFk
+ WHERE c.id = vSelf
+ ORDER BY (c.city SOUNDS LIKE t.name) DESC,
+ (p.code = c.postcode) DESC
+ LIMIT 1;
+
+ RETURN vGeoFk;
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/functions/entry_getCommission.sql b/db/routines/vn/functions/entry_getCommission.sql
index 4a19f4e63..a4afdabd4 100644
--- a/db/routines/vn/functions/entry_getCommission.sql
+++ b/db/routines/vn/functions/entry_getCommission.sql
@@ -1,58 +1,51 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`entry_getCommission`(vTravelFk INT,
- vCurrencyFk INT,
- vSupplierFk INT
+ vCurrencyFk INT,
+ vSupplierFk INT
)
RETURNS int(11)
NOT DETERMINISTIC
READS SQL DATA
BEGIN
- DECLARE vCommission INT;
- DECLARE vCurrentCommission INT;
- DECLARE vIsCurrencyUsd INT;
- DECLARE vLastEntryFk INT;
-
- SELECT count(*) INTO vIsCurrencyUsd
- FROM currency c
- WHERE c.code = 'USD' AND id = vCurrencyFk;
-
- IF NOT vIsCurrencyUsd THEN
-
- SELECT e.id INTO vLastEntryFk
- FROM vn.entry e
- JOIN vn.travel tr ON tr.id = e.travelFk
- WHERE e.supplierFk = vSupplierFk
- ORDER BY tr.landed DESC
- LIMIT 1;
-
- IF vLastEntryFk THEN
-
- SELECT commission INTO vCurrentCommission
- FROM vn.entry
- WHERE id = vLastEntryFk;
-
- ELSE
-
- SELECT commission INTO vCurrentCommission
- FROM supplier s
- WHERE s.id = vSupplierFk;
-
- END IF;
-
- RETURN vCurrentCommission;
-
- ELSE
+ DECLARE vCommission INT;
+ DECLARE vCurrentCommission INT;
+ DECLARE vIsNotEUR INT;
+ DECLARE vLastEntryFk INT;
+ SELECT count(*) INTO vIsNotEUR
+ FROM currency c
+ WHERE c.code <> 'EUR' AND id = vCurrencyFk;
+
+ IF vIsNotEUR THEN
SELECT ROUND(-100 * (1 - (1 / r.value))) INTO vCommission
FROM travel t
LEFT JOIN referenceCurrent r ON r.currencyFk = vCurrencyFk AND r.`dated` <= t.shipped
WHERE t.id = vTravelFk
ORDER BY r.`dated` DESC
LIMIT 1;
-
+
RETURN IFNULL(vCommission, 0);
-
- END IF;
-
+ ELSE
+ SELECT e.id INTO vLastEntryFk
+ FROM `entry` e
+ JOIN travel tr ON tr.id = e.travelFk
+ WHERE e.supplierFk = vSupplierFk
+ ORDER BY tr.landed DESC
+ LIMIT 1;
+
+ IF vLastEntryFk THEN
+ SELECT commission INTO vCurrentCommission
+ FROM `entry`
+ WHERE id = vLastEntryFk;
+
+ ELSE
+ SELECT commission INTO vCurrentCommission
+ FROM supplier s
+ WHERE s.id = vSupplierFk;
+
+ END IF;
+
+ RETURN vCurrentCommission;
+ END IF;
END$$
DELIMITER ;
diff --git a/db/routines/vn/functions/hasItemsInSector.sql b/db/routines/vn/functions/hasItemsInSector.sql
index 7a5c4cf60..faf9e8a90 100644
--- a/db/routines/vn/functions/hasItemsInSector.sql
+++ b/db/routines/vn/functions/hasItemsInSector.sql
@@ -9,7 +9,7 @@ BEGIN
SELECT count(*) INTO vItemCount
FROM vn.sale s
JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk
- JOIN vn.shelving sh ON sh.code = ish.shelvingFk
+ JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
WHERE s.ticketFk = vTicketFk
AND p.sectorFk = vSectorFk;
diff --git a/db/routines/vn/functions/itemsInSector_get.sql b/db/routines/vn/functions/itemsInSector_get.sql
index 254ebe1b5..9043e55cb 100644
--- a/db/routines/vn/functions/itemsInSector_get.sql
+++ b/db/routines/vn/functions/itemsInSector_get.sql
@@ -10,7 +10,7 @@ BEGIN
SELECT count(*) INTO vItemCount
FROM vn.sale s
JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk
- JOIN vn.shelving sh ON sh.code = ish.shelvingFk
+ JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
WHERE s.ticketFk = vTicketFk
AND p.sectorFk = vSectorFk;
diff --git a/db/routines/vn/functions/routeProposal.sql b/db/routines/vn/functions/routeProposal.sql
index 14b626a39..70a1eaae4 100644
--- a/db/routines/vn/functions/routeProposal.sql
+++ b/db/routines/vn/functions/routeProposal.sql
@@ -26,7 +26,7 @@ BEGIN
JOIN cache.zoneAgencyFriendship zf ON zf.agencyModeFk = r.agencyModeFk
WHERE friendship >= vSignificativeFriendship
AND zf.zoneFk = vZoneFk
- AND r.created = vLanded
+ AND r.dated = vLanded
ORDER BY friendship;
-- Se eliminan aquellas que superan el volumen máximo
diff --git a/db/routines/vn/functions/routeProposal_beta.sql b/db/routines/vn/functions/routeProposal_beta.sql
index d6db4d361..f5c347a5b 100644
--- a/db/routines/vn/functions/routeProposal_beta.sql
+++ b/db/routines/vn/functions/routeProposal_beta.sql
@@ -26,7 +26,7 @@ BEGIN
JOIN cache.zoneAgencyFriendship zf ON zf.agencyModeFk = r.agencyModeFk
WHERE friendship >= vSignificativeFriendship
AND zf.zoneFk = vZoneFk
- AND r.created = vLanded
+ AND r.dated = vLanded
ORDER BY friendship;
-- Se eliminan aquellas que superan el volumen máximo
diff --git a/db/routines/vn/functions/supplier_getGeo.sql b/db/routines/vn/functions/supplier_getGeo.sql
new file mode 100644
index 000000000..86984272c
--- /dev/null
+++ b/db/routines/vn/functions/supplier_getGeo.sql
@@ -0,0 +1,29 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`supplier_getGeo`(vSelf INT)
+ RETURNS int(11)
+ DETERMINISTIC
+BEGIN
+/**
+ * Returns the geo for the passed supplier.
+ *
+ * @param vSelf The address id
+ * @return The geo id
+ */
+ DECLARE vGeoFk INT;
+
+ SELECT p.geoFk INTO vGeoFk
+ FROM supplier s
+ JOIN town t ON t.provinceFk = s.provinceFk
+ JOIN postCode p ON p.townFk = t.id
+ AND (p.code = s.postCode OR s.postCode IS NULL)
+ LEFT JOIN supplierAddress sad ON sad.supplierFk = s.id
+ JOIN zoneGeo zg ON zg.id = p.geoFk
+ WHERE s.id = vSelf
+ ORDER BY (s.city SOUNDS LIKE t.name) DESC,
+ (p.code = s.postCode) DESC,
+ (p.code = sad.postalCode) DESC
+ LIMIT 1;
+
+ RETURN vGeoFk;
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/functions/timeWorkerControl_getDirection.sql b/db/routines/vn/functions/timeWorkerControl_getDirection.sql
deleted file mode 100644
index c0f1e67ea..000000000
--- a/db/routines/vn/functions/timeWorkerControl_getDirection.sql
+++ /dev/null
@@ -1,65 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`timeWorkerControl_getDirection`(vUserFk INT, vTimed DATETIME)
- RETURNS varchar(6) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci
- NOT DETERMINISTIC
- READS SQL DATA
-BEGIN
-/**
- * Verifica la dirección de la fichada
- * @param vUserFk Identificador del trabajador
- * @param vTimed Hora de la fichada
- * @return Retorna sentido de la fichada 'in, out, middle'
- */
-
- DECLARE vPrevious DATETIME ;
- DECLARE vNext DATETIME ;
- DECLARE vPreviousDirection VARCHAR(3) ;
- DECLARE vNextDirection VARCHAR(3) ;
- DECLARE vDayStayMax INT;
- DECLARE vTimedSeconds INT;
- DECLARE vLastTimeIn INT;
-
- SELECT UNIX_TIMESTAMP(vTimed) INTO vTimedSeconds;
-
- SELECT dayStayMax INTO vDayStayMax
- FROM vn.workerTimeControlParams;
-
- SELECT timed, direction INTO vNext,vNextDirection
- FROM vn.workerTimeControl
- WHERE userFk = vUserFk
- AND direction IN ('in','out')
- AND timed > vTimed
- ORDER BY timed ASC
- LIMIT 1;
-
- SELECT timed, direction INTO vPrevious, vPreviousDirection
- FROM vn.workerTimeControl
- WHERE userFk = vUserFk
- AND direction IN ('in','out')
- AND timed < vTimed
- ORDER BY timed DESC
- LIMIT 1;
-
- IF (vTimedSeconds - UNIX_TIMESTAMP(vPrevious) + UNIX_TIMESTAMP(vNext) - vTimedSeconds)<= vDayStayMax AND vPreviousDirection = 'in' AND vNextDirection = 'out' THEN
- RETURN 'middle';
- END IF;
-
-
- IF (vTimedSeconds> UNIX_TIMESTAMP(vPrevious)) THEN
- IF vPreviousDirection = 'in' THEN
- RETURN 'out';
- ELSE
- SELECT UNIX_TIMESTAMP(MAX(timed)) INTO vLastTimeIn
- FROM vn.workerTimeControl
- WHERE userFk = vUserFk
- AND direction ='in'
- AND timed < vPrevious;
- IF vTimedSeconds - vLastTimeIn <= vDayStayMax THEN
- RETURN 'out';
- END IF;
- END IF;
- END IF;
-
- RETURN 'in';
-END$$
-DELIMITER ;
diff --git a/db/routines/vn/procedures/absoluteInventoryHistory.sql b/db/routines/vn/procedures/absoluteInventoryHistory.sql
index 3ea8cf4de..d0d9ffac2 100644
--- a/db/routines/vn/procedures/absoluteInventoryHistory.sql
+++ b/db/routines/vn/procedures/absoluteInventoryHistory.sql
@@ -39,7 +39,7 @@ BEGIN
AND vWarehouseFk IN (tr.warehouseInFk, 0)
AND b.itemFk = vItemFk
AND NOT e.isExcludedFromAvailable
- AND NOT tr.daysInForward
+ AND NOT tr.isRaid
UNION ALL
SELECT tr.shipped,
NULL,
@@ -58,7 +58,7 @@ BEGIN
AND s.id <> (SELECT supplierFk FROM inventoryConfig)
AND b.itemFk = vItemFk
AND NOT e.isExcludedFromAvailable
- AND NOT tr.daysInForward
+ AND NOT tr.isRaid
UNION ALL
SELECT t.shipped,
NULL,
diff --git a/db/routines/vn/procedures/available_traslate.sql b/db/routines/vn/procedures/available_traslate.sql
index 513f58e36..bfd5b34c8 100644
--- a/db/routines/vn/procedures/available_traslate.sql
+++ b/db/routines/vn/procedures/available_traslate.sql
@@ -42,7 +42,7 @@ proc: BEGIN
WHERE t.landed BETWEEN vDatedInventory AND vDatedFrom
AND t.warehouseInFk = vWarehouseLanding
AND NOT e.isExcludedFromAvailable
- AND NOT t.daysInForward
+ AND NOT t.isRaid
GROUP BY c.itemFk;
-- Tabla con el ultimo dia de last_buy para cada producto
@@ -57,7 +57,7 @@ proc: BEGIN
JOIN travel tr ON tr.id = e.travelFk
LEFT JOIN tItemRange i ON t.itemFk = i.itemFk
WHERE t.warehouseFk = vWarehouseShipment
- AND NOT tr.daysInForward
+ AND NOT tr.isRaid
ON DUPLICATE KEY UPDATE tItemRange.dated = GREATEST(tItemRange.dated,
tr.landed);
@@ -94,7 +94,7 @@ proc: BEGIN
JOIN tItemRangeLive ir ON ir.itemFk = b.itemFk
WHERE NOT e.isExcludedFromAvailable
AND b.quantity <> 0
- AND NOT t.daysInForward
+ AND NOT t.isRaid
AND t.warehouseInFk = vWarehouseLanding
AND t.landed >= vDatedFrom
AND (ir.dated IS NULL OR t.landed <= ir.dated)
diff --git a/db/routines/vn/procedures/clean.sql b/db/routines/vn/procedures/clean.sql
index d3fed0242..fcee33c97 100644
--- a/db/routines/vn/procedures/clean.sql
+++ b/db/routines/vn/procedures/clean.sql
@@ -56,7 +56,7 @@ BEGIN
AND ts.id IS NULL;
DELETE FROM claim WHERE ticketCreated < v4Years;
-- Robert ubicacion anterior de travelLog comentario para debug
- DELETE FROM zoneEvent WHERE `type` = 'day' AND dated < v3Months;
+ DELETE FROM zoneEvent WHERE dated < v2Months OR ended < v2Months;
DELETE b FROM buy b
JOIN entryConfig e ON e.defaultEntry = b.entryFk
WHERE b.created < v2Months;
diff --git a/db/routines/vn/procedures/collectionPlacement_get.sql b/db/routines/vn/procedures/collectionPlacement_get.sql
index 239dbd3a2..8d2301e1e 100644
--- a/db/routines/vn/procedures/collectionPlacement_get.sql
+++ b/db/routines/vn/procedures/collectionPlacement_get.sql
@@ -83,7 +83,7 @@ BEGIN
AND s.semaphore = 1
GROUP BY st.saleFk) st ON st.saleFk = ts.saleFk
JOIN itemShelving ish ON ish.itemFk = ts.itemFk
- JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector sc ON sc.id = p.sectorFk
JOIN sectorType st ON st.id = sc.typeFk
diff --git a/db/routines/vn/procedures/collection_getTickets.sql b/db/routines/vn/procedures/collection_getTickets.sql
index fed7a3eb6..a468d7582 100644
--- a/db/routines/vn/procedures/collection_getTickets.sql
+++ b/db/routines/vn/procedures/collection_getTickets.sql
@@ -30,7 +30,9 @@ BEGIN
t.warehouseFk,
w.id salesPersonFk,
IFNULL(ob.description,'') observaciones,
- cc.rgb
+ cc.rgb,
+ p.code parkingCode,
+ IF (ps.ticketFk, TRUE, FALSE) isAdvanced
FROM vn.ticket t
LEFT JOIN vn.ticketCollection tc ON t.id = tc.ticketFk
LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk
@@ -42,7 +44,10 @@ BEGIN
LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
LEFT JOIN vn.client c ON c.id = t.clientFk
LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
- LEFT JOIN observation ob ON ob.ticketFk = t.id
+ LEFT JOIN observation ob ON ob.ticketFk = t.id
+ LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id
+ LEFT JOIN vn.parking p ON tp.parkingFk = p.id
+ LEFT JOIN vn.packingSiteAdvanced ps ON ps.ticketFk = t.id
WHERE t.id = vParamFk
AND t.shipped >= vYesterday
UNION
@@ -52,7 +57,9 @@ BEGIN
t.warehouseFk,
w.id salesPersonFk,
ob.description,
- IF(NOT (vItemPackingTypeFk <=> 'V'), cc.rgb, NULL) `rgb`
+ IF(NOT (vItemPackingTypeFk <=> 'V'), cc.rgb, NULL) `rgb`,
+ p.code parkingCode,
+ IF (ps.ticketFk, TRUE, FALSE) isAdvanced
FROM vn.ticket t
JOIN vn.ticketCollection tc ON t.id = tc.ticketFk
LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk
@@ -64,7 +71,10 @@ BEGIN
LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
LEFT JOIN vn.client c ON c.id = t.clientFk
LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
- LEFT JOIN observation ob ON ob.ticketFk = t.id
+ LEFT JOIN observation ob ON ob.ticketFk = t.id
+ LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id
+ LEFT JOIN vn.parking p ON tp.parkingFk = p.id
+ LEFT JOIN vn.packingSiteAdvanced ps ON ps.ticketFk = t.id
WHERE tc.collectionFk = vParamFk
UNION
SELECT sg.ticketFk,
@@ -73,7 +83,9 @@ BEGIN
t.warehouseFk,
c.salesPersonFk,
ob.description,
- NULL `rgb`
+ NULL `rgb`,
+ p.code parkingCode,
+ IF (ps.ticketFk, TRUE, FALSE) isAdvanced
FROM vn.sectorCollection sc
JOIN vn.sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id
JOIN vn.saleGroup sg ON sg.id = ss.saleGroupFk
@@ -81,7 +93,10 @@ BEGIN
LEFT JOIN vn.zone z ON z.id = t.zoneFk
LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
LEFT JOIN observation ob ON ob.ticketFk = t.id
- LEFT JOIN vn.client c ON c.id = t.clientFk
+ LEFT JOIN vn.client c ON c.id = t.clientFk
+ LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id
+ LEFT JOIN vn.parking p ON tp.parkingFk = p.id
+ LEFT JOIN vn.packingSiteAdvanced ps ON ps.ticketFk = t.id
WHERE sc.id = vParamFk
AND t.shipped >= vYesterday
GROUP BY ticketFk;
diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql
index 480a88f35..84133d36e 100644
--- a/db/routines/vn/procedures/collection_new.sql
+++ b/db/routines/vn/procedures/collection_new.sql
@@ -146,8 +146,6 @@ BEGIN
DELETE pb
FROM tmp.productionBuffer pb
JOIN state s ON s.id = pb.state
- JOIN agencyMode am ON am.id = pb.agencyModeFk
- JOIN agency a ON a.id = am.agencyFk
LEFT JOIN (
SELECT pb.ticketFk, MAX(i.`size`) maxSize
FROM tmp.productionBuffer pb
@@ -158,7 +156,7 @@ BEGIN
) sub ON sub.ticketFk = pb.ticketFk
JOIN productionConfig pc
WHERE pb.shipped <> util.VN_CURDATE()
- OR (pb.ubicacion IS NULL AND a.isOwn)
+ OR pb.ubicacion IS NULL
OR (NOT s.isPreparable AND NOT s.isPrintable)
OR pb.collectionH IS NOT NULL
OR pb.collectionV IS NOT NULL
diff --git a/db/routines/vn/procedures/entry_getTransfer.sql b/db/routines/vn/procedures/entry_getTransfer.sql
index 9527e0bf2..873827db2 100644
--- a/db/routines/vn/procedures/entry_getTransfer.sql
+++ b/db/routines/vn/procedures/entry_getTransfer.sql
@@ -166,7 +166,7 @@ BEGIN
LEFT JOIN tmp.buyUltimateFromInterval bufi ON bufi.itemFk = i.id
LEFT JOIN buy b3 ON b3.id = bufi.buyFk
WHERE ic.display
- AND NOT tr.daysInForward
+ AND NOT tr.isRaid
AND (ti.visible OR ti.available)
ORDER BY i.typeFk, i.name, i.id, i.size, i.category, o.name;
diff --git a/db/routines/vn/procedures/entry_isEditable.sql b/db/routines/vn/procedures/entry_isEditable.sql
index 12b6d0ef6..c417f6789 100644
--- a/db/routines/vn/procedures/entry_isEditable.sql
+++ b/db/routines/vn/procedures/entry_isEditable.sql
@@ -9,16 +9,18 @@ BEGIN
*
* @param vSelf Id de entrada
*/
- DECLARE vIsEditable BOOL;
+ DECLARE vIsNotEditable BOOL DEFAULT FALSE;
- SELECT e.isBooked INTO vIsEditable
+ SELECT TRUE INTO vIsNotEditable
FROM `entry` e
- JOIN entryType et ON et.code = e.typeFk
- WHERE NOT et.isInformal
- AND e.id = vSelf;
+ LEFT JOIN entryType et ON et.code = e.typeFk
+ WHERE e.id = vSelf
+ AND e.isBooked
+ AND (e.typeFk IS NULL OR NOT et.isInformal);
- IF vIsEditable AND NOT IFNULL(@isModeInventory, FALSE) THEN
+ IF vIsNotEditable AND NOT IFNULL(@isModeInventory, FALSE) THEN
CALL util.throw(CONCAT('Entry ', vSelf, ' is not editable'));
END IF;
+
END$$
DELIMITER ;
diff --git a/db/routines/vn/procedures/entry_splitByShelving.sql b/db/routines/vn/procedures/entry_splitByShelving.sql
index fbf0cef90..f5de36098 100644
--- a/db/routines/vn/procedures/entry_splitByShelving.sql
+++ b/db/routines/vn/procedures/entry_splitByShelving.sql
@@ -1,10 +1,15 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_splitByShelving`(vShelvingFk VARCHAR(3), vFromEntryFk INT, vToEntryFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_splitByShelving`(
+ vShelvingCode VARCHAR(10),
+ vFromEntryFk INT,
+ vToEntryFk INT
+)
BEGIN
/**
- * Divide las compras entre dos entradas de acuerdo con lo ubicado en una matr�cula
+ * Divide las compras entre dos entradas de
+ * acuerdo con lo ubicado en una matricula.
*
- * @param vShelvingFk Identificador de vn.shelving
+ * @param vShelvingCode Código de vn.shelving
* @param vFromEntryFk Entrada origen
* @param vToEntryFk Entrada destino
*/
@@ -14,16 +19,17 @@ BEGIN
DECLARE vDone BOOLEAN DEFAULT FALSE;
DECLARE cur CURSOR FOR
- SELECT bb.id buyFk,
+ SELECT bb.id buyFk,
LEAST(bb.stickers, FLOOR(ish.visible / ish.packing)) ishStickers,
bb.stickers buyStickers
FROM itemShelving ish
+ JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN (SELECT b.id, b.itemFk, b.stickers
FROM buy b
WHERE b.entryFk = vFromEntryFk
ORDER BY b.stickers DESC
LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk
- WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_general_ci
+ WHERE sh.code = vShelvingCode COLLATE utf8_general_ci
AND NOT ish.isSplit
GROUP BY ish.id;
@@ -107,9 +113,10 @@ BEGIN
UPDATE buy SET printedStickers = vIshStickers WHERE id = LAST_INSERT_ID();
END IF;
- UPDATE itemShelving
- SET isSplit = TRUE
- WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci;
+ UPDATE itemShelving ish
+ JOIN shelving sh ON sh.id = ish.shelvingFk
+ SET ish.isSplit = TRUE
+ WHERE sh.code = vShelvingCode COLLATE utf8_general_ci;
END LOOP;
CLOSE cur;
END$$
diff --git a/db/routines/vn/procedures/entry_updateComission.sql b/db/routines/vn/procedures/entry_updateComission.sql
index e2de2a4a5..8db28f97d 100644
--- a/db/routines/vn/procedures/entry_updateComission.sql
+++ b/db/routines/vn/procedures/entry_updateComission.sql
@@ -22,7 +22,7 @@ BEGIN
FROM vn.entry e
JOIN vn.travel t ON t.id = e.travelFk
JOIN vn.warehouse w ON w.id = t.warehouseInFk
- WHERE t.shipped >= util.VN_CURDATE()
+ WHERE t.landed >= util.VN_CURDATE()
AND e.currencyFk = vCurrency
AND NOT e.isBooked;
@@ -33,7 +33,7 @@ BEGIN
SET e.commission = vComission;
SELECT `name` INTO vCurrencyName
- FROM currency
+ FROM currency
WHERE id = vCurrency;
CALL entry_recalc();
diff --git a/db/routines/vn/procedures/expeditionScan_Put.sql b/db/routines/vn/procedures/expeditionScan_Put.sql
index fc7d4da23..999b9af10 100644
--- a/db/routines/vn/procedures/expeditionScan_Put.sql
+++ b/db/routines/vn/procedures/expeditionScan_Put.sql
@@ -4,12 +4,12 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expeditionScan_Put`(
vExpeditionFk INT
)
BEGIN
- IF NOT (SELECT TRUE FROM expedition WHERE id = vExpeditionFk LIMIT 1) THEN
- CALL util.throw('Expedition not exists');
+ IF NOT EXISTS (SELECT id FROM expeditionPallet WHERE id = vPalletFk) THEN
+ CALL util.throw('Pallet not exists');
END IF;
- IF NOT (SELECT TRUE FROM expeditionPallet WHERE id = vPalletFk LIMIT 1) THEN
- CALL util.throw('Pallet not exists');
+ IF NOT EXISTS (SELECT id FROM expedition WHERE id = vExpeditionFk) THEN
+ CALL util.throw('Expedition not exists');
END IF;
REPLACE expeditionScan(expeditionFk, palletFk)
diff --git a/db/routines/vn/procedures/expedition_getFromRoute.sql b/db/routines/vn/procedures/expedition_getFromRoute.sql
index 8c2ab057d..932f614b6 100644
--- a/db/routines/vn/procedures/expedition_getFromRoute.sql
+++ b/db/routines/vn/procedures/expedition_getFromRoute.sql
@@ -41,6 +41,6 @@ BEGIN
WHERE expeditionFk = e.id)
LEFT JOIN expeditionState es2 ON es2.id = es.id
WHERE t.routeFk = vRouteFk AND e.freightItemFk <> FALSE
- ORDER BY r.created, t.priority DESC;
+ ORDER BY r.dated, t.priority DESC;
END$$
DELIMITER ;
diff --git a/db/routines/vn/procedures/expedition_selfConsumptionPackaging.sql b/db/routines/vn/procedures/expedition_selfConsumptionPackaging.sql
new file mode 100644
index 000000000..166ec476c
--- /dev/null
+++ b/db/routines/vn/procedures/expedition_selfConsumptionPackaging.sql
@@ -0,0 +1,95 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expedition_selfConsumptionPackaging`(
+ vSelf INT,
+ vAction ENUM('add', 'remove')
+)
+proc:BEGIN
+/**
+ * Maneja el consumo de cajas para autoconsumo, permitiendo
+ * añadir o quitar cajas utilizadas según la acción indicada.
+ *
+ * @param vSelf Id de expedición
+ */
+ DECLARE vClientFk INT;
+ DECLARE vAddressFk INT;
+ DECLARE vItemFk INT;
+ DECLARE vItemName VARCHAR(50);
+ DECLARE vWarehouseFk INT;
+ DECLARE vCreated DATE;
+ DECLARE vTicketFk INT;
+ DECLARE vSaleFk INT;
+ DECLARE vQuantity INT;
+
+ IF vAction NOT IN ('add', 'remove') THEN
+ CALL util.throw('Action not supported');
+ END IF;
+
+ SELECT pc.clientSelfConsumptionFk,
+ pc.addressSelfConsumptionFk,
+ i.id,
+ i.name,
+ t.warehouseFk,
+ e.created
+ INTO vClientFk,
+ vAddressFk,
+ vItemFk,
+ vItemName,
+ vWarehouseFk,
+ vCreated
+ FROM expedition e
+ LEFT JOIN packaging p ON p.id = e.packagingFk
+ LEFT JOIN item i ON i.id = p.itemFk
+ JOIN ticket t ON t.id = e.ticketFk
+ JOIN productionConfig pc
+ WHERE e.id = vSelf;
+
+ IF vClientFk IS NULL OR vItemFk IS NULL THEN
+ LEAVE proc;
+ END IF;
+
+ SET vCreated = DATE(vCreated);
+
+ SELECT id INTO vTicketFk
+ FROM ticket
+ WHERE shipped BETWEEN vCreated AND util.dayEnd(vCreated)
+ AND clientFk = vClientFk
+ AND addressFk = vAddressFk
+ AND warehouseFk = vWarehouseFk
+ AND nickname = 'CAJAS AUTOCONSUMO'
+ LIMIT 1;
+
+ IF vTicketFk IS NULL AND vAction = 'add' THEN
+ INSERT INTO ticket(clientFk, warehouseFk, shipped, nickname, addressFk)
+ VALUES (vClientFk, vWarehouseFk, vCreated, 'CAJAS AUTOCONSUMO', vAddressFk);
+
+ SET vTicketFk = LAST_INSERT_ID();
+ END IF;
+
+ SELECT id, quantity INTO vSaleFk, vQuantity
+ FROM sale
+ WHERE itemFk = vItemFk
+ AND ticketFk = vTicketFk
+ LIMIT 1;
+
+ IF vAction = 'add' THEN
+ IF vSaleFk IS NOT NULL THEN
+ UPDATE sale
+ SET quantity = quantity + 1
+ WHERE id = vSaleFk;
+ ELSE
+ INSERT INTO sale(itemFk, ticketFk, concept, quantity)
+ VALUES (vItemFk, vTicketFk, vItemName, 1);
+ END IF;
+ ELSE
+ IF vSaleFk IS NOT NULL THEN
+ IF vQuantity > 1 THEN
+ UPDATE sale
+ SET quantity = quantity - 1
+ WHERE id = vSaleFk;
+ ELSE
+ DELETE FROM sale WHERE id = vSaleFk;
+ END IF;
+ END IF;
+ END IF;
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/procedures/inventoryMake.sql b/db/routines/vn/procedures/inventoryMake.sql
index 65dceef3d..316083db0 100644
--- a/db/routines/vn/procedures/inventoryMake.sql
+++ b/db/routines/vn/procedures/inventoryMake.sql
@@ -137,7 +137,7 @@ BEGIN
JOIN travel tr ON tr.id = e.travelFk
WHERE tr.warehouseInFk = vWarehouseFk
AND tr.landed BETWEEN vDateLastInventory AND vDateYesterday
- AND NOT tr.daysInForward
+ AND NOT tr.isRaid
GROUP BY b.itemFk;
-- Transfers
@@ -150,7 +150,7 @@ BEGIN
JOIN travel tr ON tr.id = e.travelFk
WHERE tr.warehouseOutFk = vWarehouseFk
AND tr.shipped BETWEEN vDateLastInventory AND vDateYesterday
- AND NOT tr.daysInForward
+ AND NOT tr.isRaid
GROUP BY b.itemFk
) sub
ON DUPLICATE KEY UPDATE quantity = IFNULL(quantity, 0) + sub.quantityOut;
diff --git a/db/routines/vn/procedures/invoiceIn_booking.sql b/db/routines/vn/procedures/invoiceIn_booking.sql
index 36189afcc..cfe3adb0b 100644
--- a/db/routines/vn/procedures/invoiceIn_booking.sql
+++ b/db/routines/vn/procedures/invoiceIn_booking.sql
@@ -219,7 +219,7 @@ BEGIN
) eWithheld ON TRUE
WHERE tii.taxTypeSageFk IS NOT NULL
AND (tii.taxCode IS NULL OR tii.taxCode NOT IN ('import10', 'import21'))
- GROUP BY tii.PorcentajeIva, tii.expenseFk;
+ GROUP BY tii.CuentaIvaRepercutido;
-- Línea iva inversor sujeto pasivo
INSERT INTO XDiario(
@@ -284,7 +284,7 @@ BEGIN
AND NOT(tii.isVies
AND c.nontaxableTransactionTypeFk = tii.transactionTypeSageFk
AND tii.taxCode = 'nonTaxable')
- GROUP BY tii.PorcentajeIva, tii.expenseFk;
+ GROUP BY tii.CuentaIvaRepercutido;
-- Actualización del registro original
UPDATE invoiceIn ii
diff --git a/db/routines/vn/procedures/itemPlacementSupplyAiming.sql b/db/routines/vn/procedures/itemPlacementSupplyAiming.sql
index b96860623..ae0890564 100644
--- a/db/routines/vn/procedures/itemPlacementSupplyAiming.sql
+++ b/db/routines/vn/procedures/itemPlacementSupplyAiming.sql
@@ -1,5 +1,9 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyAiming`(vShelvingFk VARCHAR(10), quantity INT, vItemFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyAiming`(
+ vShelvingCode VARCHAR(10),
+ vQuantity INT,
+ vItemFk INT
+)
BEGIN
SELECT ish.itemFk,
@@ -9,21 +13,21 @@ BEGIN
ish.itemShelvingFk,
ish.shelving,
ish.stock,
- LEAST(ish.stock,quantity) as total,
+ LEAST(ish.stock,vQuantity) total,
CONCAT(
- CAST(FLOOR(LEAST(ish.stock,quantity) / ish.packing) AS DECIMAL(10,0)),
+ CAST(FLOOR(LEAST(ish.stock, vQuantity) / ish.packing) AS DECIMAL(10,0)),
' x ',
ish.packing,
IF (
- LEAST(ish.stock,quantity) MOD ish.packing,
- CONCAT(' + ',CAST(LEAST(ish.stock,quantity) MOD ish.packing AS DECIMAL(10,0))),
+ LEAST(ish.stock, vQuantity) MOD ish.packing,
+ CONCAT(' + ',CAST(LEAST(ish.stock, vQuantity) MOD ish.packing AS DECIMAL(10,0))),
''
),
' = ',
- LEAST(ish.stock,quantity)
- ) as proposal
- FROM vn.itemShelvingPlacementSupplyStock ish
- WHERE ish.shelving = vShelvingFk COLLATE utf8_general_ci
+ LEAST(ish.stock, vQuantity)
+ ) proposal
+ FROM itemShelvingPlacementSupplyStock ish
+ WHERE ish.shelving = vShelvingCode COLLATE utf8_general_ci
AND ish.itemFk = vItemFk;
END$$
diff --git a/db/routines/vn/procedures/itemPlacementSupplyGetOrder.sql b/db/routines/vn/procedures/itemPlacementSupplyGetOrder.sql
index 958dc7e78..d2648ca6c 100644
--- a/db/routines/vn/procedures/itemPlacementSupplyGetOrder.sql
+++ b/db/routines/vn/procedures/itemPlacementSupplyGetOrder.sql
@@ -1,5 +1,7 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyGetOrder`(vSector INT )
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyGetOrder`(
+ vSectorFk INT
+)
BEGIN
DECLARE vId INT;
@@ -7,31 +9,35 @@ BEGIN
DECLARE vNextParkingFk INT;
SELECT sh.parkingFk INTO vLastParkingFk
- FROM vn.itemShelvingPlacementSupply isps
- JOIN vn.itemShelving ish ON ish.id = isps.itemShelvingFk
- JOIN vn.shelving sh ON sh.code = ish.shelvingFk
+ FROM itemShelvingPlacementSupply isps
+ JOIN itemShelving ish ON ish.id = isps.itemShelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
WHERE isps.userFk = getUser()
ORDER BY isps.created DESC
LIMIT 1;
- SET vNextParkingFk = vn.itemShelvingPlacementSupply_ClosestGet(vLastParkingFk);
+ SET vNextParkingFk = itemShelvingPlacementSupply_ClosestGet(vLastParkingFk);
SELECT ipsl.id INTO vId
- FROM vn.itemPlacementSupplyList ipsl
- JOIN vn.itemShelvingPlacementSupplyStock ispss ON ispss.itemFk = ipsl.itemFk
+ FROM itemPlacementSupplyList ipsl
+ JOIN itemShelvingPlacementSupplyStock ispss ON ispss.itemFk = ipsl.itemFk
WHERE ipsl.saldo > 0
AND (ipsl.repoUserFk is NULL OR ipsl.repoUserFk = getUser())
- AND ipsl.sectorFk = vSector
- ORDER BY ipsl.repoUserFk DESC, ipsl.priority DESC, (ispss.parkingFk = vNextParkingFk) DESC, ispss.parking DESC, ipsl.created
+ AND ipsl.sectorFk = vSectorFk
+ ORDER BY ipsl.repoUserFk DESC,
+ ipsl.priority DESC,
+ (ispss.parkingFk = vNextParkingFk) DESC,
+ ispss.parking DESC,
+ ipsl.created
LIMIT 1;
- UPDATE vn.itemPlacementSupply
+ UPDATE itemPlacementSupply
SET repoUserFk = getUser()
WHERE id = vId;
- SELECT * FROM vn.itemPlacementSupplyList
+ SELECT * FROM itemPlacementSupplyList
WHERE id = vId
- AND sectorFk = vSector;
+ AND sectorFk = vSectorFk;
END$$
DELIMITER ;
diff --git a/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql b/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql
index cefa64d13..92c17b82f 100644
--- a/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql
+++ b/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql
@@ -1,5 +1,8 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyStockGetTargetList`(vItemFk INT,vSectorFk INT)
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyStockGetTargetList`(
+ vItemFk INT,
+ vSectorFk INT
+)
BEGIN
/**
* Devuelve la lista de ubicaciones para itemFk en ese sector. Se utiliza en la preparación previa.
@@ -13,11 +16,11 @@ BEGIN
SUM(ish.visible) stockTotal,
ish.created,
p.pickingOrder
- FROM vn.itemShelving ish
- JOIN vn.shelving sh ON sh.code = ish.shelvingFk
- JOIN vn.parking p ON p.id = sh.parkingFk
- JOIN vn.sector sc ON sc.id = p.sectorFk
- JOIN vn.warehouse w ON w.id = sc.warehouseFk
+ FROM itemShelving ish
+ JOIN shelving sh ON sh.id = ish.shelvingFk
+ JOIN parking p ON p.id = sh.parkingFk
+ JOIN sector sc ON sc.id = p.sectorFk
+ JOIN warehouse w ON w.id = sc.warehouseFk
WHERE ish.visible > 0
AND ish.itemFk = vItemFk
GROUP BY ish.id
diff --git a/db/routines/vn/procedures/itemShelvingLog_get.sql b/db/routines/vn/procedures/itemShelvingLog_get.sql
deleted file mode 100644
index 52e7a273f..000000000
--- a/db/routines/vn/procedures/itemShelvingLog_get.sql
+++ /dev/null
@@ -1,35 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingLog_get`(vShelvingFk VARCHAR(10) )
-BEGIN
-
-/**
- * Devuelve el log de los item en cada carro
- *
- * @param vShelvingFk Matrícula del carro
- *
- */
-
- SELECT isl.itemShelvingFk,
- isl.created,
- isl.accion,
- isl.itemFk,
- isl.shelvingFk,
- isl.quantity,
- isl.visible,
- isl.available,
- isl.grouping,
- isl.packing,
- isl.stars,
- item.longName,
- item.size,
- item.subName,
- worker.code,
- isl.accion
- FROM item
- JOIN itemShelvingLog isl ON item.id = isl.itemFk
- JOIN worker ON isl.workerFk = worker.id
- WHERE shelvingFk = vShelvingFk OR isl.itemFk = vShelvingFk
- ORDER BY isl.created DESC;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn/procedures/itemShelvingMatch.sql b/db/routines/vn/procedures/itemShelvingMatch.sql
index 850c7907b..4ffa66fcb 100644
--- a/db/routines/vn/procedures/itemShelvingMatch.sql
+++ b/db/routines/vn/procedures/itemShelvingMatch.sql
@@ -20,7 +20,7 @@ BEGIN
LEFT JOIN (
SELECT itemFk, sum(cast(visible / packing AS DECIMAL(10,0))) AS etiquetas
FROM itemShelving ish
- JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
LEFT JOIN parking pk ON pk.id = sh.parkingFk
WHERE ish.created BETWEEN vFromTimed AND vToTimed
GROUP BY itemFk
diff --git a/db/routines/vn/procedures/itemShelvingSale_addBySale.sql b/db/routines/vn/procedures/itemShelvingSale_addBySale.sql
index 06736732a..eeec60248 100644
--- a/db/routines/vn/procedures/itemShelvingSale_addBySale.sql
+++ b/db/routines/vn/procedures/itemShelvingSale_addBySale.sql
@@ -27,7 +27,7 @@ proc: BEGIN
ish.available
FROM sale s
JOIN itemShelving ish ON ish.itemFk = s.itemFk
- JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector sc ON sc.id = p.sectorFk
JOIN productionConfig pc
@@ -61,7 +61,7 @@ proc: BEGIN
FROM sale s
LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id
LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
- LEFT JOIN shelving sh ON sh.code = ish.shelvingFk
+ LEFT JOIN shelving sh ON sh.id = ish.shelvingFk
LEFT JOIN parking p ON p.id = sh.parkingFk
WHERE s.id = vSaleFk;
diff --git a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql
index cde1b6872..1975180d1 100644
--- a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql
+++ b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql
@@ -3,7 +3,8 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setQ
vItemShelvingSaleFk INT(10),
vQuantity DECIMAL(10,0),
vIsItemShelvingSaleEmpty BOOLEAN,
- vSectorFk INT
+ vSectorFk INT,
+ vShelvingFk VARCHAR(10)
)
BEGIN
/**
@@ -24,6 +25,7 @@ BEGIN
DECLARE vItemFk INT;
DECLARE vTotalQuantity INT;
DECLARE vStateCode VARCHAR(45);
+ DECLARE vCurrentShelvingFk VARCHAR(10);
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
@@ -45,18 +47,26 @@ BEGIN
iss.saleFk,
iss.itemShelvingFk,
SUM(IFNULL(iss.quantity,0)),
- IF(sgd.id, 'PREVIOUS_PREPARATION', 'PREPARED')
+ IF(sgd.id, 'PREVIOUS_PREPARATION', 'PREPARED'),
+ sh.code
INTO vItemFk,
vSaleFk,
vItemShelvingFk,
vReservedQuantity,
- vStateCode
+ vStateCode,
+ vCurrentShelvingFk
FROM itemShelvingSale iss
JOIN sale s ON s.id = iss.saleFk
- LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = iss.saleFk
+ JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
+ LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = iss.saleFk
+ LEFT JOIN shelving sh ON sh.id = ish.shelvingFk
WHERE iss.id = vItemShelvingSaleFk
AND NOT iss.isPicked;
+ IF NOT (vCurrentShelvingFk <=> vShelvingFk) THEN
+ CALL util.throw('The shelving can not be different from the shelving reserved');
+ END IF;
+
IF vQuantity > vReservedQuantity
OR (vQuantity < vReservedQuantity AND NOT vIsItemShelvingSaleEmpty)
OR (vQuantity = vReservedQuantity AND vIsItemShelvingSaleEmpty) THEN
diff --git a/db/routines/vn/procedures/itemShelving_add.sql b/db/routines/vn/procedures/itemShelving_add.sql
index 92d1609e4..a8f0b5250 100644
--- a/db/routines/vn/procedures/itemShelving_add.sql
+++ b/db/routines/vn/procedures/itemShelving_add.sql
@@ -1,6 +1,6 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_add`(
- vShelvingFk VARCHAR(8),
+ vShelvingCode VARCHAR(10),
vBarcode VARCHAR(22),
vQuantity INT,
vPackagingFk VARCHAR(10),
@@ -12,7 +12,7 @@ BEGIN
/**
* Añade registro o lo actualiza si ya existe.
*
- * @param vShelvingFk matrícula del carro
+ * @param vShelvingCode matrícula del carro
* @param vBarcode el id del registro
* @param vQuantity indica la cantidad del producto
* @param vPackagingFk el packaging del producto en itemShelving, NULL para coger el de la ultima compra
@@ -23,10 +23,15 @@ BEGIN
**/
DECLARE vItemFk INT;
DECLARE vBuyFk INT;
+ DECLARE vShelvingFk INT;
SELECT id INTO vBuyFk
FROM buy WHERE id = vBarcode;
+ SELECT id INTO vShelvingFk
+ FROM shelving
+ WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
+
SELECT barcodeToItem(vBarcode) INTO vItemFk;
IF vBuyFk IS NULL THEN
@@ -40,7 +45,7 @@ BEGIN
END IF;
IF (SELECT COUNT(*) FROM itemShelving
- WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
+ WHERE shelvingFk = vShelvingFk
AND itemFk = vItemFk
AND packing = vPacking
AND buyFk = vBuyFk) THEN
@@ -48,7 +53,9 @@ BEGIN
UPDATE itemShelving
SET visible = visible + vQuantity,
available = available + vQuantity
- WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking;
+ WHERE shelvingFk = vShelvingFk
+ AND itemFk = vItemFk
+ AND packing = vPacking;
ELSE
diff --git a/db/routines/vn/procedures/itemShelving_addByClaim.sql b/db/routines/vn/procedures/itemShelving_addByClaim.sql
index 5e7cdf3fc..55ac3e337 100644
--- a/db/routines/vn/procedures/itemShelving_addByClaim.sql
+++ b/db/routines/vn/procedures/itemShelving_addByClaim.sql
@@ -1,29 +1,38 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_addByClaim`(vClaimFk INT, vShelvingFk VARCHAR(3))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_addByClaim`(
+ vClaimFk INT,
+ vShelvingCode VARCHAR(10)
+)
BEGIN
/**
* Insert items of claim into itemShelving.
*
* @param vClaimFk The claim
- * @param vShelvingFk The shelving
+ * @param vShelvingCode The shelving code
* @table tmp.buyUltimate
*/
DECLARE vWarehouseFk INT;
+ DECLARE vShelvingFk INT;
SELECT t.warehouseFk INTO vWarehouseFk
FROM claim c
JOIN ticket t ON t.id = c.ticketFk
WHERE c.id = vClaimFk;
+ SELECT id INTO vShelvingFk
+ FROM shelving
+ WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
+
CALL buy_getUltimate(NULL, vWarehouseFk, util.VN_CURDATE());
INSERT INTO itemShelving (itemFk, shelvingFk, packing, `grouping`, visible)
- SELECT s.itemFk, vShelvingFk, b.packing, b.`grouping`, cb.quantity AS visible
+ SELECT s.itemFk, vShelvingFk, b.packing, b.`grouping`, cb.quantity visible
FROM claim c
JOIN claimBeginning cb ON c.id = cb.claimFk
JOIN sale s ON s.id = cb.saleFk
JOIN ticket t ON t.id = s.ticketFk
- JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk AND bu.warehouseFk = t.warehouseFk
+ JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
+ AND bu.warehouseFk = t.warehouseFk
JOIN buy b ON b.id = bu.buyFk
WHERE c.id = vClaimFk;
END$$
diff --git a/db/routines/vn/procedures/itemShelving_addList.sql b/db/routines/vn/procedures/itemShelving_addList.sql
index ade92b9fd..04fa1e10c 100644
--- a/db/routines/vn/procedures/itemShelving_addList.sql
+++ b/db/routines/vn/procedures/itemShelving_addList.sql
@@ -1,6 +1,6 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_addList`(
- vShelvingFk VARCHAR(3),
+ vShelvingCode VARCHAR(10),
vList TEXT,
vIsChecking BOOL,
vWarehouseFk INT
@@ -13,7 +13,7 @@ BEGIN
* Cuando es TRUE sólo inserta los elementos de la colección que no están ya en
* ese shelving, actualizando los valores del campo itemShelving.isChecked
*
- * @param vShelvingFk Identificador de shelving
+ * @param vShelvingCode Código de shelving
* @param vList JSON array con esta estructura: '[value1, value2, ...]'
* @param vIsChecking Define si hay que añadir o comprobar los items
* @param vWarehouseFk Identificador de warehouse
@@ -24,6 +24,11 @@ BEGIN
DECLARE vPath VARCHAR(6);
DECLARE vItemFk INT;
DECLARE vIsChecked BOOL;
+ DECLARE vShelvingFk INT;
+
+ SELECT id INTO vShelvingFk
+ FROM shelving
+ WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
WHILE vCounter < vListLength DO
SET vPath = CONCAT('$[', vCounter, ']');
@@ -34,17 +39,17 @@ BEGIN
SELECT IF(COUNT(*), TRUE, FALSE) INTO vIsChecked
FROM itemShelving
- WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
+ WHERE shelvingFk = vShelvingFk
AND itemFk = vItemFk;
END IF;
IF NOT vIsChecking OR NOT vIsChecked THEN
- CALL itemShelving_add(vShelvingFk, vBarcode, 1, NULL, NULL, NULL, vWarehouseFk);
+ CALL itemShelving_add(vShelvingCode, vBarcode, 1, NULL, NULL, NULL, vWarehouseFk);
END IF;
UPDATE itemShelving
SET isChecked = vIsChecked
- WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
+ WHERE shelvingFk = vShelvingFk
AND itemFk = vItemFk
AND isChecked IS NULL;
diff --git a/db/routines/vn/procedures/itemShelving_get.sql b/db/routines/vn/procedures/itemShelving_get.sql
index 606bb8bd9..0038257c2 100644
--- a/db/routines/vn/procedures/itemShelving_get.sql
+++ b/db/routines/vn/procedures/itemShelving_get.sql
@@ -1,15 +1,18 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_get`(IN vSelf VARCHAR(8))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_get`(
+ vShelvingCode VARCHAR(10)
+)
BEGIN
/**
-* Lista artículos de itemshelving
+* Lista artículos de itemShelving.
*
-* @param vSelf matrícula del carro
+* @param vShelvingCode Matrícula del carro
**/
SELECT ish.itemFk item,
- IFNULL(i.longName, CONCAT(i.name, ' ', i.size)) description,
+ i.name,
+ i.longName,
+ i.size,
ish.visible,
- CEIL(ish.visible/ish.packing) stickers,
ish.packing,
ish.grouping,
p.code,
@@ -17,12 +20,14 @@ BEGIN
s.priority,
ish.isChecked,
ic.url,
- ish.available
+ ish.available,
+ ish.buyFk,
+ ish.shelvingFk
FROM itemShelving ish
JOIN item i ON i.id = ish.itemFk
- JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci
- LEFT JOIN parking p ON s.parkingFk = p.id
+ JOIN shelving s ON s.id = ish.shelvingFk
+ LEFT JOIN parking p ON p.id = s.parkingFk
JOIN hedera.imageConfig ic
- WHERE ish.shelvingFk COLLATE utf8_unicode_ci = vSelf;
+ WHERE s.code COLLATE utf8_unicode_ci = vShelvingCode;
END$$
DELIMITER ;
diff --git a/db/routines/vn/procedures/itemShelving_getAlternatives.sql b/db/routines/vn/procedures/itemShelving_getAlternatives.sql
index 89176c4f5..3eff3254b 100644
--- a/db/routines/vn/procedures/itemShelving_getAlternatives.sql
+++ b/db/routines/vn/procedures/itemShelving_getAlternatives.sql
@@ -1,21 +1,31 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getAlternatives`(vShelvingFk VARCHAR(10))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getAlternatives`(
+ vShelvingCode VARCHAR(10)
+)
BEGIN
/**
- * Devuelve un listado de posibles ubicaciones alternativas a ubicar los item de la matricula
- * del carro que se le ha pasado.
+ * Devuelve un listado de posibles ubicaciones alternativas a ubicar
+ * los item de la matricula del carro que se le ha pasado.
*
- * @param vShelvingFk matricula del carro
+ * @param vShelvingCode Matricula del carro
*/
- SELECT is2.id,is2.shelvingFk , p.code, is2.itemFk , is2.visible, p.pickingOrder
+ DECLARE vShelvingFk INT;
+
+ SELECT id INTO vShelvingFk
+ FROM shelving
+ WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
+
+ SELECT is2.id,is2.shelvingFk, p.code, is2.itemFk , is2.visible, p.pickingOrder
FROM itemShelving is2
- JOIN shelving sh ON sh.code = is2.shelvingFk
+ JOIN shelving sh ON sh.id = is2.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector s ON s.id = p.sectorFk
- LEFT JOIN operator o ON o.sectorFk = s.id AND o.workerFk = account.myUser_getId()
+ LEFT JOIN operator o ON o.sectorFk = s.id
+ AND o.workerFk = account.myUser_getId()
JOIN warehouse wh ON wh.id = s.warehouseFk
- JOIN itemShelving is3 ON is3.itemFk = is2.itemFk AND is3.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci
- WHERE is2.shelvingFk <> vShelvingFk COLLATE utf8_unicode_ci
+ JOIN itemShelving is3 ON is3.itemFk = is2.itemFk
+ AND is3.shelvingFk = vShelvingFk
+ WHERE is2.shelvingFk <> vShelvingFk
GROUP BY is2.id
ORDER BY p.pickingOrder DESC;
END$$
diff --git a/db/routines/vn/procedures/itemShelving_getInfo.sql b/db/routines/vn/procedures/itemShelving_getInfo.sql
index f02100e8b..f4c8c5b35 100644
--- a/db/routines/vn/procedures/itemShelving_getInfo.sql
+++ b/db/routines/vn/procedures/itemShelving_getInfo.sql
@@ -16,7 +16,7 @@ BEGIN
ish.itemFk itemFk,
sh.priority
FROM vn.itemShelving ish
- JOIN vn.shelving sh ON sh.`code` = ish.shelvingFk
+ JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking pk ON pk.id = sh.parkingFk
WHERE ish.itemFk = vItemFk
ORDER BY sh.priority DESC, created ASC;
diff --git a/db/routines/vn/procedures/itemShelving_getItemDetails.sql b/db/routines/vn/procedures/itemShelving_getItemDetails.sql
index 4e641ca72..36f9830f0 100644
--- a/db/routines/vn/procedures/itemShelving_getItemDetails.sql
+++ b/db/routines/vn/procedures/itemShelving_getItemDetails.sql
@@ -1,14 +1,14 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getItemDetails`(
vBarcodeItem INT,
- vShelvingFK VARCHAR(10)
+ vShelvingCode 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
+ * @param vShelvingCode Ubicación actual del artículo
*/
DECLARE vIsItem BOOL;
DECLARE vBuyFk INT;
@@ -38,18 +38,19 @@ BEGIN
WITH visible AS(
SELECT itemFk,
IFNULL(buyingValue, 0) +
- IFNULL(freightValue, 0) +
- IFNULL(comissionValue, 0) +
- IFNULL(packageValue, 0) itemCost
- FROM vn.buy b
+ IFNULL(freightValue, 0) +
+ IFNULL(comissionValue, 0) +
+ IFNULL(packageValue, 0) itemCost
+ FROM vn.buy b
WHERE b.id = vBuyFk
) SELECT v.itemFk,
- vShelvingFK,
+ vShelvingCode,
v.itemCost,
SUM(ish.visible) visible
FROM vn.itemShelving ish
+ JOIN vn.shelving sh ON sh.id = ish.shelvingFK
JOIN visible v
- WHERE ish.shelvingFK = vShelvingFK COLLATE utf8mb3_general_ci
- AND ish.itemFk = v.itemFk;
+ WHERE sh.code = vShelvingCode COLLATE utf8mb3_general_ci
+ AND ish.itemFk = v.itemFk;
END$$
DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/vn/procedures/itemShelving_getSaleDate.sql b/db/routines/vn/procedures/itemShelving_getSaleDate.sql
index d8ab6ed0c..fad4d5abc 100644
--- a/db/routines/vn/procedures/itemShelving_getSaleDate.sql
+++ b/db/routines/vn/procedures/itemShelving_getSaleDate.sql
@@ -1,14 +1,20 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getSaleDate`(vShelvingFk VARCHAR(3))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getSaleDate`(
+ vShelvingCode VARCHAR(10)
+)
BEGIN
-
- /* Devuelve la mínima fecha en que se necesita cada producto en esa matrícula.
- *
- * @param vShelvingFk Matrícula del carro o pallet
- */
-
+/**
+ * Devuelve la mínima fecha en que se necesita cada producto en esa matrícula.
+ *
+ * @param vShelvingCode Matrícula del carro o pallet
+ */
DECLARE vWarehouseFk INT;
DECLARE vStockScopeDays INT;
+ DECLARE vShelvingFk INT;
+
+ SELECT id INTO vShelvingFk
+ FROM shelving
+ WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
SELECT s.warehouseFk, stockScopeDays
INTO vWarehouseFk, vStockScopeDays
@@ -30,7 +36,7 @@ BEGIN
ENGINE = MEMORY
SELECT itemFk, SUM(visible) visible
FROM itemShelving
- WHERE shelvingFk = vShelvingFk COLLATE utf8_unicode_ci
+ WHERE shelvingFk = vShelvingFk
GROUP BY itemFk;
CREATE OR REPLACE TEMPORARY TABLE tmp.tStockByDay
@@ -52,7 +58,7 @@ BEGIN
SELECT ish.itemFk, - SUM(ish.visible), util.VN_CURDATE()
FROM itemShelving ish
JOIN tmp.tItems i ON i.itemFk = ish.itemFk
- JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON sh.parkingFk = p.id
JOIN sector s ON s.id = p.sectorFk
WHERE s.isReserve
@@ -110,7 +116,7 @@ BEGIN
UPDATE tmp.tStockByDay sbd
JOIN (SELECT ish.itemFK, SUM(ish.visible) amount
FROM itemShelving ish
- JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector s ON s.id = p.sectorFk
WHERE s.warehouseFk = vWarehouseFk
@@ -150,10 +156,10 @@ BEGIN
p.sectorFk,
ish.shelvingFk
FROM itemShelving ish
- JOIN vn.shelving sh ON sh.code = ish.shelvingFk
+ JOIN vn.shelving sh ON sh.id = ish.shelvingFk
LEFT JOIN parking p ON p.id = parkingFk
LEFT JOIN vn.sector s ON s.id = p.sectorFk
- WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci
+ WHERE ish.shelvingFk = vShelvingFk
) sub4 ON sub4.itemFk = ts.itemFk
LEFT JOIN sector s ON s.id = sub4.sectorFk
LEFT JOIN item i ON i.id = ts.itemFk
diff --git a/db/routines/vn/procedures/itemShelving_inventory.sql b/db/routines/vn/procedures/itemShelving_inventory.sql
index b57df02e0..9ae96c7a8 100644
--- a/db/routines/vn/procedures/itemShelving_inventory.sql
+++ b/db/routines/vn/procedures/itemShelving_inventory.sql
@@ -42,7 +42,7 @@ BEGIN
JOIN item i ON i.id = ish.itemFk
JOIN itemType it ON it.id = i.typeFk
JOIN tmp.stockMisfit sm ON sm.itemFk = ish.itemFk
- JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
LEFT JOIN (
SELECT s.itemFk, sum(s.quantity) notPrepared
diff --git a/db/routines/vn/procedures/itemShelving_selfConsumption.sql b/db/routines/vn/procedures/itemShelving_selfConsumption.sql
index 083d8d74c..5820b9d28 100644
--- a/db/routines/vn/procedures/itemShelving_selfConsumption.sql
+++ b/db/routines/vn/procedures/itemShelving_selfConsumption.sql
@@ -1,6 +1,6 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_selfConsumption`(
- vShelvingFk VARCHAR(10) COLLATE utf8_general_ci,
+ vShelvingCode VARCHAR(10) COLLATE utf8_general_ci,
vItemFk INT,
vQuantity INT
)
@@ -9,9 +9,9 @@ BEGIN
* Leave the indicated amount on the shelve
* and create a ticket with the difference.
*
- * @param vShelvingFk id of the shelve where the item is located.
- * @param vItemFk article of which the self-consumption ticket is to be created.
- * @param vQuantity amount that will stay on the shelve
+ * @param vShelvingCode Code of the shelve where the item is located
+ * @param vItemFk Item of which the self-consumption ticket is to be created
+ * @param vQuantity Amount that will stay on the shelve
*/
DECLARE vVisible INT;
DECLARE vClientFk INT;
@@ -21,6 +21,11 @@ BEGIN
DECLARE vAgencyModeFk INT;
DECLARE vItemShelvingFk INT;
DECLARE vAddressFk INT;
+ DECLARE vShelvingFk INT;
+
+ SELECT id INTO vShelvingFk
+ FROM shelving
+ WHERE code = vShelvingCode;
SELECT c.id,
pc.clientSelfConsumptionFk,
@@ -37,7 +42,7 @@ BEGIN
JOIN parking p ON p.sectorFk = s.id
JOIN shelving s2 ON s2.parkingFk = p.id
JOIN productionConfig pc
- WHERE s2.code = vShelvingFk;
+ WHERE s2.id = vShelvingFk;
IF vClientFk IS NULL THEN
CALL util.throw('The company does not have a customer assigned');
@@ -47,7 +52,7 @@ BEGIN
CALL util.throw('The shelf cannot have NULL or negative quantities');
END IF;
- IF vShelvingFk IS NULL THEN
+ IF vShelvingCode IS NULL THEN
CALL util.throw('The shelf is necessary');
END IF;
diff --git a/db/routines/vn/procedures/itemShelving_transfer.sql b/db/routines/vn/procedures/itemShelving_transfer.sql
index 95d70227f..e0e6af110 100644
--- a/db/routines/vn/procedures/itemShelving_transfer.sql
+++ b/db/routines/vn/procedures/itemShelving_transfer.sql
@@ -1,7 +1,7 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_transfer`(
vItemShelvingFk INT,
- vShelvingFk VARCHAR(10)
+ vShelvingCode VARCHAR(10)
)
BEGIN
/**
@@ -9,9 +9,14 @@ BEGIN
* fusionando si coincide el packing y la fecha.
*
* @param vItemShelvingFk Identificador de itemShelving
- * @param vShelvingFk Identificador de shelving
+ * @param vShelvingCode Código de shelving
*/
DECLARE vNewItemShelvingFk INT;
+ DECLARE vShelvingFk INT;
+
+ SELECT id INTO vShelvingFk
+ FROM shelving
+ WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
SELECT MAX(ish.id) INTO vNewItemShelvingFk
FROM itemShelving ish
@@ -26,7 +31,7 @@ BEGIN
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;
+ WHERE ish.shelvingFk = vShelvingFk;
IF vNewItemShelvingFk THEN
UPDATE itemShelving ish
@@ -38,9 +43,7 @@ BEGIN
DELETE FROM itemShelving
WHERE id = vItemShelvingFk;
ELSE
- IF (SELECT EXISTS(SELECT id FROM shelving
- WHERE code = vShelvingFk COLLATE utf8_unicode_ci)) THEN
-
+ IF (SELECT EXISTS(SELECT id FROM shelving WHERE id = vShelvingFk)) THEN
UPDATE itemShelving
SET shelvingFk = vShelvingFk
WHERE id = vItemShelvingFk;
diff --git a/db/routines/vn/procedures/item_devalueA2.sql b/db/routines/vn/procedures/item_devalueA2.sql
index d0178f6a7..3264165a6 100644
--- a/db/routines/vn/procedures/item_devalueA2.sql
+++ b/db/routines/vn/procedures/item_devalueA2.sql
@@ -1,7 +1,7 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_devalueA2`(
vSelf INT,
- vShelvingFK VARCHAR(10),
+ vShelvingCode VARCHAR(10) COLLATE utf8mb3_general_ci,
vBuyingValue DECIMAL(10,4),
vQuantity INT
)
@@ -12,7 +12,7 @@ BEGIN
* de almacén y shelvings correspondientes
*
* @param vSelf Id de artículo a devaluar
- * @param vShelvingFK Ubicación actual del artículo
+ * @param vShelvingCode Código de shelving / ubicación
* @param vBuyingValue Nuevo precio de coste
* @param vQuantity Cantidad del ítem a pasar a A2
*/
@@ -109,10 +109,11 @@ BEGIN
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
+ SELECT ish.id, ish.visible INTO vTargetItemShelvingFk, vCurrentVisible
+ FROM itemShelving ish
+ JOIN shelving sh ON sh.id = ish.shelvingFk
+ WHERE sh.code = vShelvingCode
+ AND ish.itemFk = vSelf
LIMIT 1;
IF vCurrentVisible IS NULL THEN
@@ -388,16 +389,17 @@ BEGIN
userFk,
isChecked)
SELECT vItemA2Fk,
- shelvingFk,
+ ish.shelvingFk,
vQuantity ,
- `grouping`,
- packing,
- packagingFk,
+ ish.`grouping`,
+ ish.packing,
+ ish.packagingFk,
account.myUser_getId(),
- isChecked
- FROM itemShelving
- WHERE itemFK = vSelf
- AND shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci
+ ish.isChecked
+ FROM itemShelving ish
+ JOIN shelving sh ON sh.id = ish.shelvingFk
+ WHERE ish.itemFK = vSelf
+ AND sh.code = vShelvingCode
ON DUPLICATE KEY UPDATE
visible = vQuantity + VALUES(visible);
diff --git a/db/routines/vn/procedures/item_getBalance.sql b/db/routines/vn/procedures/item_getBalance.sql
index 260f0a527..c4974491c 100644
--- a/db/routines/vn/procedures/item_getBalance.sql
+++ b/db/routines/vn/procedures/item_getBalance.sql
@@ -59,7 +59,7 @@ BEGIN
AND (s.id <> vSupplierInventoryFk OR vDated IS NULL)
AND b.itemFk = vItemFk
AND NOT e.isExcludedFromAvailable
- AND NOT tr.daysInForward
+ AND NOT tr.isRaid
),
entriesOut AS (
SELECT 'entry',
@@ -95,7 +95,7 @@ BEGIN
AND b.itemFk = vItemFk
AND NOT e.isExcludedFromAvailable
AND NOT w.isFeedStock
- AND NOT tr.daysInForward
+ AND NOT tr.isRaid
),
sales AS (
WITH itemSales AS (
diff --git a/db/routines/vn/procedures/item_getInfo.sql b/db/routines/vn/procedures/item_getInfo.sql
index 341142892..bd59728f7 100644
--- a/db/routines/vn/procedures/item_getInfo.sql
+++ b/db/routines/vn/procedures/item_getInfo.sql
@@ -42,7 +42,6 @@ BEGIN
i.minimum `min`,
p.name producer,
o.code origin,
- v.visible - IFNULL(vVisibleItemShelving, 0) unlocated,
a.available,
vVisibleItemShelving,
v.visible,
diff --git a/db/routines/vn/procedures/item_getMinacum.sql b/db/routines/vn/procedures/item_getMinacum.sql
index 8a42bd737..e3c915820 100644
--- a/db/routines/vn/procedures/item_getMinacum.sql
+++ b/db/routines/vn/procedures/item_getMinacum.sql
@@ -63,7 +63,7 @@ BEGIN
AND NOT e.isExcludedFromAvailable
AND b.quantity <> 0
AND (vItemFk IS NULL OR b.itemFk = vItemFk)
- AND NOT t.daysInForward
+ AND NOT t.isRaid
UNION ALL
SELECT r.itemFk,
r.shipment,
diff --git a/db/routines/vn/procedures/item_multipleBuyByDate.sql b/db/routines/vn/procedures/item_multipleBuyByDate.sql
index 7bd809312..04d3f1855 100644
--- a/db/routines/vn/procedures/item_multipleBuyByDate.sql
+++ b/db/routines/vn/procedures/item_multipleBuyByDate.sql
@@ -30,7 +30,7 @@ BEGIN
AND NOT s.name = 'INVENTARIO'
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
AND w.isComparative
- AND NOT t.daysInForward
+ AND NOT t.isRaid
GROUP BY i.id;
UPDATE tmp.itemInventory y
diff --git a/db/routines/vn/procedures/item_valuateInventory.sql b/db/routines/vn/procedures/item_valuateInventory.sql
index b6d687960..7e420be27 100644
--- a/db/routines/vn/procedures/item_valuateInventory.sql
+++ b/db/routines/vn/procedures/item_valuateInventory.sql
@@ -109,7 +109,7 @@ BEGIN
JOIN warehouse w ON w.id = tr.warehouseInFk
WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd
AND IF(tr.landed = util.VN_CURDATE(), tr.isReceived, TRUE)
- AND NOT tr.daysInForward
+ AND NOT tr.isRaid
AND w.valuatedInventory
AND t.isInventory
AND e.supplierFk <> vInventorySupplierFk
@@ -131,7 +131,7 @@ BEGIN
JOIN itemCategory ic ON ic.id = t.categoryFk
JOIN warehouse w ON w.id = tr.warehouseOutFk
WHERE tr.shipped BETWEEN vInventoried AND vDateDayEnd
- AND NOT tr.daysInForward
+ AND NOT tr.isRaid
AND w.valuatedInventory
AND t.isInventory
AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL)
@@ -196,7 +196,7 @@ BEGIN
JOIN warehouse wIn ON wIn.id = tr.warehouseInFk
JOIN warehouse wOut ON wOut.id = tr.warehouseOutFk
WHERE vDated >= tr.shipped AND vDated < tr.landed
- AND NOT tr.daysInForward
+ AND NOT tr.isRaid
AND wIn.valuatedInventory
AND t.isInventory
AND e.isConfirmed
diff --git a/db/routines/vn/procedures/multipleInventory.sql b/db/routines/vn/procedures/multipleInventory.sql
index 6b26e456f..ee18bbe96 100644
--- a/db/routines/vn/procedures/multipleInventory.sql
+++ b/db/routines/vn/procedures/multipleInventory.sql
@@ -60,7 +60,7 @@ proc: BEGIN
AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk
AND w.isComparative
AND NOT e.isExcludedFromAvailable
- AND NOT t.daysInForward
+ AND NOT t.isRaid
UNION ALL
SELECT b.itemFk, - b.quantity
FROM buy b
@@ -71,7 +71,7 @@ proc: BEGIN
AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk
AND w.isComparative
AND NOT e.isExcludedFromAvailable
- AND NOT t.daysInForward
+ AND NOT t.isRaid
) sub
GROUP BY itemFk;
@@ -121,7 +121,7 @@ proc: BEGIN
AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk
AND w.isComparative
AND NOT e.isExcludedFromAvailable
- AND NOT t.daysInForward
+ AND NOT t.isRaid
UNION ALL
SELECT b.itemFk, t.shipped, - b.quantity
FROM buy b
@@ -132,7 +132,7 @@ proc: BEGIN
AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk
AND w.isComparative
AND NOT e.isExcludedFromAvailable
- AND NOT t.daysInForward
+ AND NOT t.isRaid
) sub
GROUP BY sub.itemFk, sub.dated;
diff --git a/db/routines/vn/procedures/productionControl.sql b/db/routines/vn/procedures/productionControl.sql
index 1d206e20d..813c65ab2 100644
--- a/db/routines/vn/procedures/productionControl.sql
+++ b/db/routines/vn/procedures/productionControl.sql
@@ -217,7 +217,7 @@ proc: BEGIN
st.code = 'previousPrepared' isPreviousPrepared,
sc.itemPackingTypeFk
FROM itemShelving ish
- JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector sc ON sc.id = p.sectorFk
JOIN sectorType st ON st.id = sc.typeFk
diff --git a/db/routines/vn/procedures/routeMonitor_calculate.sql b/db/routines/vn/procedures/routeMonitor_calculate.sql
index c9a7a9ccf..31667f211 100644
--- a/db/routines/vn/procedures/routeMonitor_calculate.sql
+++ b/db/routines/vn/procedures/routeMonitor_calculate.sql
@@ -27,7 +27,7 @@ BEGIN
rm.ticketFree = 0,
rm.ticketProduction = 0,
rm.ticketPacked = 0,
- rm.dated = r.created;
+ rm.dated = r.dated;
UPDATE routesMonitor rm
JOIN (
diff --git a/db/routines/vn/procedures/route_calcCommission.sql b/db/routines/vn/procedures/route_calcCommission.sql
index 7c911a5e2..dc44adb9b 100644
--- a/db/routines/vn/procedures/route_calcCommission.sql
+++ b/db/routines/vn/procedures/route_calcCommission.sql
@@ -11,8 +11,10 @@ BEGIN
*/
DECLARE vIsUpdatable, vIsFreelance BOOL DEFAULT 0;
DECLARE vAgencyModePricePercentage DOUBLE;
+ DECLARE vIsKmTruckRate BOOL;
+ DECLARE vCountryFk INT;
- SELECT r.created >= rc.cutoffDated INTO vIsUpdatable
+ SELECT r.dated >= rc.cutoffDated INTO vIsUpdatable
FROM route r
JOIN routeConfig rc
WHERE r.id = vSelf;
@@ -21,10 +23,17 @@ BEGIN
DELETE FROM routeCommission
WHERE routeFk = vSelf;
- SELECT w.isFreelance INTO vIsFreelance
+ SELECT w.isFreelance, v.isKmTruckRate, p.countryFk INTO vIsFreelance, vIsKmTruckRate, vCountryFk
FROM route r
JOIN worker w ON w.id = r.workerFk
- WHERE r.id = vSelf;
+ JOIN vehicle v ON v.id = r.vehicleFk
+ LEFT JOIN ticket t ON t.routeFk = r.id
+ LEFT JOIN address a ON a.id = t.addressFk
+ LEFT JOIN province p ON p.id = a.provinceFk
+ WHERE r.id = vSelf
+ GROUP BY p.countryFk
+ ORDER BY COUNT(*) DESC
+ LIMIT 1;
SELECT ampp.percentage INTO vAgencyModePricePercentage
FROM route r
@@ -39,7 +48,9 @@ BEGIN
workCenterFk,
freelanceYearlyM3,
cat4m3,
- cat5m3
+ cat5m3,
+ isKmTruckRate,
+ countryFk
)
SELECT vSelf,
r.commissionWorkCenterFk,
@@ -51,11 +62,14 @@ BEGIN
IFNULL(r.m3, 0),
0
),
- rc.distributionCat4M3 * IFNULL(r.m3, 0),
- rc.distributionCat5M3 * IFNULL(r.m3, 0)
+ IFNULL(wc.distributionCat4M3, rc.distributionCat4M3) * IFNULL(r.m3, 0),
+ IFNULL(wc.distributionCat5M3, rc.distributionCat5M3) * IFNULL(r.m3, 0),
+ vIsKmTruckRate,
+ vCountryFk
FROM route r
JOIN vehicle v ON v.id = r.vehicleFk
JOIN routeConfig rc
+ LEFT JOIN workCenterCommission wc ON wc.workCenterFk = r.commissionWorkCenterFk
WHERE r.id = vSelf
AND r.workerFk
AND r.commissionWorkCenterFk;
@@ -68,21 +82,28 @@ BEGIN
yearlyKm,
yearlyM3,
cat4m3,
- cat5m3
+ cat5m3,
+ isKmTruckRate,
+ countryFk
)
SELECT vSelf,
r.commissionWorkCenterFk,
(r.kmEnd - r.kmStart) *
IF(v.isKmTruckRate, rc.kmHeavy, rc.kmLight),
IFNULL(r.m3, 0) *
- IF(v.isKmTruckRate, rc.deliveryM3Cat5, rc.deliveryM3Cat4),
+ IF(v.isKmTruckRate,
+ IFNULL(wc.deliveryM3Cat5, rc.deliveryM3Cat5),
+ IFNULL(wc.deliveryM3Cat4, rc.deliveryM3Cat4)),
(r.kmEnd - r.kmStart) * rc.kmYearly,
IFNULL(r.m3, 0) * rc.m3Yearly,
- rc.distributionCat4M3 * IFNULL(r.m3, 0),
- rc.distributionCat5M3 * IFNULL(r.m3, 0)
+ IFNULL(wc.distributionCat4M3, rc.distributionCat4M3) * IFNULL(r.m3, 0),
+ IFNULL(wc.distributionCat5M3, rc.distributionCat5M3) * IFNULL(r.m3, 0),
+ vIsKmTruckRate,
+ vCountryFk
FROM route r
JOIN vehicle v ON v.id = r.vehicleFk
JOIN routeConfig rc
+ LEFT JOIN workCenterCommission wc ON wc.workCenterFk = r.commissionWorkCenterFk
WHERE r.id = vSelf
AND r.kmStart
AND r.kmEnd
diff --git a/db/routines/vn/procedures/sale_boxPickingPrint.sql b/db/routines/vn/procedures/sale_boxPickingPrint.sql
index 6bb954a78..f156ff8f8 100644
--- a/db/routines/vn/procedures/sale_boxPickingPrint.sql
+++ b/db/routines/vn/procedures/sale_boxPickingPrint.sql
@@ -27,7 +27,7 @@ BEGIN
DECLARE vQuantity INT;
DECLARE vRemainder INT DEFAULT 0;
DECLARE vRemainderSaleFk INT;
- DECLARE vShelving VARCHAR(10);
+ DECLARE vShelvingFk VARCHAR(10);
DECLARE vTicketFk INT;
SELECT s.quantity,
@@ -74,7 +74,7 @@ w1: WHILE vQuantity >= vPacking DO
p.pickingOrder,
ish.created
FROM itemShelving ish
- JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
LEFT JOIN itemShelvingSale iss
ON iss.itemShelvingFk = ish.id
@@ -262,9 +262,9 @@ w1: WHILE vQuantity >= vPacking DO
CALL dipole.expedition_Add(vExpeditionFk,vPrinterFk, TRUE);
SELECT shelvingFk, p.code
- INTO vShelving, vParkingCode
+ INTO vShelvingFk, vParkingCode
FROM itemShelving ish
- JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
WHERE ish.id = vItemShelvingFk;
@@ -273,7 +273,7 @@ w1: WHILE vQuantity >= vPacking DO
itemFk = vItemFk,
quantity = vPacking,
longName = vConcept,
- shelvingFk = vShelving,
+ shelvingFk = vShelvingFk,
parkingCode = vParkingCode,
phone = RIGHT(phone,vMaxPhoneLength),
street = RIGHT(street, vMAxStreetLength)
diff --git a/db/routines/vn/procedures/sale_getBoxPickingList.sql b/db/routines/vn/procedures/sale_getBoxPickingList.sql
index f343ab375..4f6a08083 100644
--- a/db/routines/vn/procedures/sale_getBoxPickingList.sql
+++ b/db/routines/vn/procedures/sale_getBoxPickingList.sql
@@ -41,7 +41,7 @@ BEGIN
AND iss.created >= vDated
GROUP BY iss.itemShelvingFk, s.itemFk) tISS
ON tISS.itemFk = ish.itemFk AND tISS.itemShelvingFk = ish.id
- JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN tmp.productionBuffer pb ON pb.ticketFk = s.ticketFk
JOIN agencyMode am ON am.id = pb.agencyModeFk
diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql
index b50b4784d..e016f3ab4 100644
--- a/db/routines/vn/procedures/sale_getProblems.sql
+++ b/db/routines/vn/procedures/sale_getProblems.sql
@@ -87,7 +87,7 @@ BEGIN
SUM(ish.visible) visible,
s.warehouseFk warehouseFk
FROM itemShelving ish
- JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector s ON s.id = p.sectorFk
GROUP BY ish.itemFk, s.warehouseFk;
@@ -127,7 +127,7 @@ BEGIN
LEFT JOIN tItemShelvingStock_byWarehouse issw ON issw.itemFk = i.id
AND issw.warehouseFk = t.warehouseFk
WHERE IFNULL(v.visible, 0) < s.quantity
- AND IFNULL(av.available, 0) < s.quantity
+ AND IFNULL(av.available, 0) < 0
AND IFNULL(issw.visible, 0) < s.quantity
AND NOT s.isPicked
AND NOT s.reserved
@@ -190,7 +190,7 @@ BEGIN
LEFT JOIN tItemShelvingStock_byWarehouse issw ON issw.itemFk = i.id
AND issw.warehouseFk = t.warehouseFk
WHERE IFNULL(v.visible, 0) < s.quantity
- AND IFNULL(av.available, 0) >= s.quantity
+ AND IFNULL(av.available, 0) >= 0
AND IFNULL(issw.visible, 0) < s.quantity
AND s.quantity > 0
AND NOT s.isPicked
diff --git a/db/routines/vn/procedures/shelvingChange.sql b/db/routines/vn/procedures/shelvingChange.sql
index 2e7e92082..901b1cf95 100644
--- a/db/routines/vn/procedures/shelvingChange.sql
+++ b/db/routines/vn/procedures/shelvingChange.sql
@@ -1,11 +1,13 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelvingChange`(IN `vShelvingO` VARCHAR(8), IN `vShelvingD` VARCHAR(8))
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelvingChange`(
+ `vShelvingO` VARCHAR(10),
+ `vShelvingD` VARCHAR(10)
+)
BEGIN
-
- UPDATE vn.itemShelving
- SET shelvingFk = vShelvingD COLLATE utf8_unicode_ci
- WHERE shelvingFk = vShelvingO COLLATE utf8_unicode_ci;
-
-
+ UPDATE itemShelving ish
+ JOIN shelving sh1 ON sh1.code = vShelvingD COLLATE utf8_unicode_ci
+ JOIN shelving sh2 ON sh2.code = vShelvingO COLLATE utf8_unicode_ci
+ SET ish.shelvingFk = sh1.id
+ WHERE ish.shelvingFk = sh2.id;
END$$
DELIMITER ;
diff --git a/db/routines/vn/procedures/shelvingParking_get.sql b/db/routines/vn/procedures/shelvingParking_get.sql
index a9ed9f74a..c05e8afc3 100644
--- a/db/routines/vn/procedures/shelvingParking_get.sql
+++ b/db/routines/vn/procedures/shelvingParking_get.sql
@@ -1,8 +1,10 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelvingParking_get`(vShelvingFk VARCHAR(10), vWarehouseFk INT, vDayRange INT)
-BEGIN
-
-
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelvingParking_get`(
+ vShelvingCode VARCHAR(10),
+ vWarehouseFk INT,
+ vDayRange INT
+)
+BEGIN
SELECT s.itemFk,
s.concept,
CAST(SUM(s.quantity) AS DECIMAL(10,0)) as sinServir,
@@ -10,14 +12,15 @@ SELECT s.itemFk,
FROM vn.sale s
LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id
JOIN vn.ticket t ON t.id = s.ticketFk
- LEFT JOIN vn.itemShelvingStock ist ON ist.itemFk = s.itemFk AND ist.warehouseFk = vWarehouseFk
- JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk AND ish.shelvingFk = vShelvingFk COLLATE utf8_general_ci
+ LEFT JOIN vn.itemShelvingStock ist ON ist.itemFk = s.itemFk
+ AND ist.warehouseFk = vWarehouseFk
+ JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
+ AND sh.code = vShelvingCode COLLATE utf8_general_ci
WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(TIMESTAMPADD(DAY, GREATEST(0,vDayRange), util.VN_CURDATE()))
AND iss.saleFk IS NULL
AND t.warehouseFk = vWarehouseFk
GROUP BY s.itemFk
HAVING sinServir > aparcado;
-
-
END$$
DELIMITER ;
diff --git a/db/routines/vn/procedures/shelving_clean.sql b/db/routines/vn/procedures/shelving_clean.sql
index 0b29968bc..155338827 100644
--- a/db/routines/vn/procedures/shelving_clean.sql
+++ b/db/routines/vn/procedures/shelving_clean.sql
@@ -12,12 +12,12 @@ BEGIN
DELETE ish.*
FROM itemShelving ish
- JOIN vn.shelving sh ON sh.code = ish.shelvingFk
+ JOIN vn.shelving sh ON sh.id = ish.shelvingFk
WHERE sh.parkingFk IS NULL
AND ish.created < TIMESTAMPADD(WEEK,-1,util.VN_CURDATE());
UPDATE shelving sh
- LEFT JOIN itemShelving its ON its.shelvingFk = sh.`code`
+ LEFT JOIN itemShelving its ON its.shelvingFk = sh.id
SET isPrinted = 0,
parkingFk = NULL
WHERE its.id IS NULL
@@ -27,11 +27,11 @@ UPDATE shelving sh
OR
sh.parked < util.VN_CURDATE() - INTERVAL 2 WEEK
)
-
AND IF(code REGEXP '^[A-Za-z]{2}[0-9]', LEFT (code, 2) NOT IN (
- SELECT DISTINCT LEFT(its.shelvingFk, 2)
+ SELECT DISTINCT LEFT(sh.code, 2)
FROM itemShelving its
- WHERE its.shelvingFk REGEXP '^[A-Za-z]{2}[0-9]'
+ JOIN shelving sh ON sh.id = its.shelvingFk
+ WHERE sh.code REGEXP '^[A-Za-z]{2}[0-9]'
), TRUE);
END$$
diff --git a/db/routines/vn/procedures/shelving_getSpam.sql b/db/routines/vn/procedures/shelving_getSpam.sql
index cef407285..a80021cdf 100644
--- a/db/routines/vn/procedures/shelving_getSpam.sql
+++ b/db/routines/vn/procedures/shelving_getSpam.sql
@@ -25,7 +25,7 @@ BEGIN
LEFT JOIN (
SELECT ish.itemFk, CAST(SUM(ish.visible) AS DECIMAL(10,0)) AS reserva
FROM vn.itemShelving ish
- JOIN vn.shelving sh ON sh.code = ish.shelvingFk
+ JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
JOIN vn.sector s ON s.id = p.sectorFk
WHERE s.code = 'FUENTES_PICASSE'
@@ -68,7 +68,7 @@ BEGIN
sh.isSpam
FROM vn.itemShelving ish
JOIN vn.item i ON i.id = ish.itemFk
- JOIN vn.shelving sh ON sh.code = ish.shelvingFk
+ JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
JOIN vn.sector s ON s.id = p.sectorFk
JOIN vn.warehouse w ON w.id = s.warehouseFk
diff --git a/db/routines/vn/procedures/stockBought_calculate.sql b/db/routines/vn/procedures/stockBought_calculate.sql
index 8b2a32e5d..c248d0deb 100644
--- a/db/routines/vn/procedures/stockBought_calculate.sql
+++ b/db/routines/vn/procedures/stockBought_calculate.sql
@@ -7,13 +7,13 @@ proc: BEGIN
* Calculate the stock of the auction warehouse from the inventory date to vDated
* without taking into account the outputs of the same day vDated
*
- * @param vDated Date to calculate the stock.
+ * @param vDated Date to calculate the stock
*/
IF vDated < util.VN_CURDATE() THEN
LEAVE proc;
END IF;
- CREATE OR REPLACE TEMPORARY TABLE tStockBought
+ CREATE OR REPLACE TEMPORARY TABLE tCurrentData
SELECT workerFk, reserve
FROM stockBought
WHERE dated = vDated
@@ -21,15 +21,28 @@ proc: BEGIN
DELETE FROM stockBought WHERE dated = vDated;
+ CREATE OR REPLACE TEMPORARY TABLE tStockSold
+ SELECT it.workerFk,
+ SUM(ic.cm3 * ito.quantity / vc.palletM3 / 1000000) sold
+ FROM itemTicketOut ito
+ JOIN item i ON i.id = ito.itemFk
+ JOIN itemType it ON it.id = i.typeFk
+ JOIN ticket t ON t.id = ito.ticketFk
+ JOIN warehouse wh ON wh.id = t.warehouseFk
+ JOIN itemCost ic ON ic.itemFk = ito.itemFk
+ AND ic.warehouseFk = t.warehouseFk
+ JOIN volumeConfig vc
+ WHERE ito.shipped BETWEEN vDated AND util.dayEnd(vDated)
+ AND wh.code = 'VNH'
+ GROUP BY it.workerFk;
+
CALL item_calculateStock(vDated);
- INSERT INTO stockBought(workerFk, bought, dated)
+ CREATE OR REPLACE TEMPORARY TABLE tStockBought
SELECT it.workerFk,
- ROUND(SUM(
- (ti.quantity / b.packing) *
- buy_getVolume(b.id)
- ) / vc.palletM3 / 1000000, 1) bought,
- vDated
+ SUM((ti.quantity / b.packing) *
+ buy_getVolume(b.id)
+ ) / vc.palletM3 / 1000000 bought
FROM itemType it
JOIN item i ON i.typeFk = it.id
LEFT JOIN tmp.item ti ON ti.itemFk = i.id
@@ -43,20 +56,33 @@ proc: BEGIN
GROUP BY it.workerFk
HAVING bought;
+
+ INSERT INTO stockBought(workerFk, bought, dated)
+ SELECT tb.workerFk,
+ ROUND(GREATEST(tb.bought - IFNULL(ts.sold, 0), 0), 2),
+ vDated
+ FROM tStockBought tb
+ LEFT JOIN tStockSold ts ON ts.workerFk = tb.workerFk;
+
UPDATE stockBought s
- JOIN tStockBought ts ON ts.workerFk = s.workerFk
+ JOIN tCurrentData ts ON ts.workerFk = s.workerFk
SET s.reserve = ts.reserve
WHERE s.dated = vDated;
INSERT INTO stockBought (workerFk, reserve, dated)
SELECT ts.workerFk, ts.reserve, vDated
- FROM tStockBought ts
+ FROM tCurrentData ts
WHERE ts.workerFk NOT IN (
SELECT workerFk
FROM stockBought
WHERE dated = vDated
);
- DROP TEMPORARY TABLE tStockBought, tmp.item, tmp.buyUltimate;
+ UPDATE stockBought s
+ JOIN tStockSold ts ON ts.workerFk = s.workerFk
+ SET s.bought = IF(s.bought < ABS(ts.sold), 0, ROUND(s.bought - ABS(ts.sold), 1))
+ WHERE s.dated = vDated;
+
+ DROP TEMPORARY TABLE tCurrentData, tmp.item, tmp.buyUltimate, tStockSold;
END$$
DELIMITER ;
diff --git a/db/routines/vn/procedures/stockBuyedByWorker.sql b/db/routines/vn/procedures/stockBuyedByWorker.sql
new file mode 100644
index 000000000..536638770
--- /dev/null
+++ b/db/routines/vn/procedures/stockBuyedByWorker.sql
@@ -0,0 +1,74 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`stockBuyedByWorker`(
+ vDated DATE,
+ vWorker INT
+)
+BEGIN
+/**
+ * Inserta el volumen de compra de un comprador
+ * en stockBuyed de acuerdo con la fecha.
+ *
+ * @param vDated Fecha de compra
+ * @param vWorker Id de trabajador
+ */
+ CREATE OR REPLACE TEMPORARY TABLE tStockBuyed
+ (INDEX (userFk))
+ ENGINE = MEMORY
+ SELECT requested, reserved, userFk
+ FROM stockBuyed
+ WHERE dated = vDated
+ AND userFk = vWorker;
+
+ DELETE FROM stockBuyed
+ WHERE dated = vDated
+ AND userFk = vWorker;
+
+ CALL item_calculateStock(vDated);
+
+ INSERT INTO stockBuyed(userFk, buyed, `dated`, reserved, requested, description)
+ SELECT it.workerFk,
+ SUM((ti.quantity / b.packing) * buy_getVolume(b.id)) / vc.palletM3 / 1000000,
+ vDated,
+ sb.reserved,
+ sb.requested,
+ u.name
+ FROM itemType it
+ JOIN item i ON i.typeFk = it.id
+ LEFT JOIN tmp.item ti ON ti.itemFk = i.id
+ JOIN itemCategory ic ON ic.id = it.categoryFk
+ JOIN warehouse wh ON wh.code = 'VNH'
+ JOIN tmp.buyUltimate bu ON bu.itemFk = i.id
+ AND bu.warehouseFk = wh.id
+ JOIN buy b ON b.id = bu.buyFk
+ JOIN volumeConfig vc
+ JOIN account.`user` u ON u.id = it.workerFk
+ LEFT JOIN tStockBuyed sb ON sb.userFk = it.workerFk
+ WHERE ic.display
+ AND it.workerFk = vWorker;
+
+ SELECT b.entryFk Id_Entrada,
+ i.id Id_Article,
+ i.name Article,
+ ti.quantity Cantidad,
+ (ac.conversionCoefficient * (ti.quantity / b.packing) * buy_getVolume(b.id))
+ / (vc.trolleyM3 * 1000000) buyed,
+ b.packagingFk id_cubo,
+ b.packing
+ FROM tmp.item ti
+ JOIN item i ON i.id = ti.itemFk
+ JOIN itemType it ON i.typeFk = it.id
+ JOIN itemCategory ic ON ic.id = it.categoryFk
+ JOIN worker w ON w.id = it.workerFk
+ JOIN auctionConfig ac
+ JOIN tmp.buyUltimate bu ON bu.itemFk = i.id
+ AND bu.warehouseFk = ac.warehouseFk
+ JOIN buy b ON b.id = bu.buyFk
+ JOIN volumeConfig vc
+ WHERE ic.display
+ AND w.id = vWorker;
+
+ DROP TEMPORARY TABLE tmp.buyUltimate,
+ tmp.item,
+ tStockBuyed;
+END$$
+DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/vn/procedures/stockBuyed_add.sql b/db/routines/vn/procedures/stockBuyed_add.sql
new file mode 100644
index 000000000..0491c2424
--- /dev/null
+++ b/db/routines/vn/procedures/stockBuyed_add.sql
@@ -0,0 +1,70 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`stockBuyed_add`(
+ vDated DATE
+)
+BEGIN
+/**
+ * Inserta el volumen de compra por comprador
+ * en stockBuyed de acuerdo con la fecha.
+ *
+ * @param vDated Fecha de compra
+ */
+ CREATE OR REPLACE TEMPORARY TABLE tStockBuyed
+ (INDEX (userFk))
+ ENGINE = MEMORY
+ SELECT requested, reserved, userFk
+ FROM stockBuyed
+ WHERE dated = vDated;
+
+ DELETE FROM stockBuyed WHERE dated = vDated;
+
+ CALL item_calculateStock(vDated);
+
+ INSERT INTO stockBuyed(userFk, buyed, `dated`, description)
+ SELECT it.workerFk,
+ SUM((ti.quantity / b.packing) * buy_getVolume(b.id)) / vc.palletM3 / 1000000,
+ vDated,
+ u.name
+ FROM itemType it
+ JOIN item i ON i.typeFk = it.id
+ LEFT JOIN tmp.item ti ON ti.itemFk = i.id
+ JOIN itemCategory ic ON ic.id = it.categoryFk
+ JOIN warehouse wh ON wh.code = 'VNH'
+ JOIN tmp.buyUltimate bu ON bu.itemFk = i.id AND bu.warehouseFk = wh.id
+ JOIN buy b ON b.id = bu.buyFk
+ JOIN volumeConfig vc
+ JOIN account.`user` u ON u.id = it.workerFk
+ JOIN workerDepartment wd ON wd.workerFk = u.id
+ JOIN department d ON d.id = wd.departmentFk
+ WHERE ic.display
+ AND d.code IN ('shopping', 'logistic', 'franceTeam')
+ GROUP BY it.workerFk;
+
+ INSERT INTO stockBuyed(buyed, dated, description)
+ SELECT SUM(ic.cm3 * ito.quantity / vc.palletM3 / 1000000),
+ vDated,
+ 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
+ JOIN province p ON p.id = a.provinceFk
+ JOIN country c ON c.id = p.countryFk
+ JOIN warehouse wh ON wh.id = t.warehouseFk
+ JOIN itemCost ic ON ic.itemFk = ito.itemFk
+ AND ic.warehouseFk = t.warehouseFk
+ JOIN volumeConfig vc
+ WHERE ito.shipped BETWEEN vDated AND util.dayend(vDated)
+ AND wh.code = 'VNH'
+ GROUP BY destiny;
+
+ UPDATE stockBuyed s
+ JOIN tStockBuyed ts ON ts.userFk = s.userFk
+ SET s.requested = ts.requested,
+ s.reserved = ts.reserved
+ WHERE s.dated = vDated;
+
+ DROP TEMPORARY TABLE tmp.buyUltimate,
+ tmp.item,
+ tStockBuyed;
+END$$
+DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/vn/procedures/ticketDown_PrintableSelection.sql b/db/routines/vn/procedures/ticketDown_PrintableSelection.sql
index 082a890a6..8f448d647 100644
--- a/db/routines/vn/procedures/ticketDown_PrintableSelection.sql
+++ b/db/routines/vn/procedures/ticketDown_PrintableSelection.sql
@@ -9,7 +9,7 @@ BEGIN
JOIN vn.sale s ON s.ticketFk = t.id
JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id
JOIN vn.itemShelving ish ON ish.id = iss.itemShelvingFk
- JOIN vn.shelving sh ON sh.code = ish.shelvingFk
+ JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
WHERE p.sectorFk = vSectorFk
) sub ON sub.id = td.ticketFk
diff --git a/db/routines/vn/procedures/ticket_DelayTruckSplit.sql b/db/routines/vn/procedures/ticket_DelayTruckSplit.sql
index 1dc45d065..3d22207f3 100644
--- a/db/routines/vn/procedures/ticket_DelayTruckSplit.sql
+++ b/db/routines/vn/procedures/ticket_DelayTruckSplit.sql
@@ -27,7 +27,7 @@ BEGIN
SUM(ish.visible) visible,
s.warehouseFk warehouseFk
FROM itemShelving ish
- JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector s ON s.id = p.sectorFk
GROUP BY ish.itemFk,
diff --git a/db/routines/vn/procedures/ticket_getSplitList.sql b/db/routines/vn/procedures/ticket_getSplitList.sql
index 988bc2931..66e9bdb57 100644
--- a/db/routines/vn/procedures/ticket_getSplitList.sql
+++ b/db/routines/vn/procedures/ticket_getSplitList.sql
@@ -28,7 +28,7 @@ BEGIN
SUM(ish.visible) visible,
s.warehouseFk warehouseFk
FROM itemShelving ish
- JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector s ON s.id = p.sectorFk
GROUP BY ish.itemFk,
diff --git a/db/routines/vn/procedures/ticket_splitItemPackingType.sql b/db/routines/vn/procedures/ticket_splitItemPackingType.sql
index 9a4bc01eb..31e0c24e7 100644
--- a/db/routines/vn/procedures/ticket_splitItemPackingType.sql
+++ b/db/routines/vn/procedures/ticket_splitItemPackingType.sql
@@ -3,87 +3,124 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_splitItemPacki
vSelf INT,
vOriginalItemPackingTypeFk VARCHAR(1)
)
-proc:BEGIN
+BEGIN
/**
- * Clona y reparte las líneas de ventas de un ticket en funcion del tipo de empaquetado.
- * Respeta el id de ticket original para el tipo de empaquetado propuesto.
+ * Separa en diferentes tickets según el tipo de empaquetado
+ * El ticket original conserva las líneas del tipo de empaquetado especificado
+ * Las líneas sin tipo de empaquetado se asignan al ticket del tipo por defecto.
*
- * @param vSelf Id ticket
- * @param vOriginalItemPackingTypeFk Tipo empaquetado que se mantiene el ticket original
+ * @param vSelf Id del ticket original
+ * @param vOriginalItemPackingTypeFk Tipo de empaquetado a mantener en el ticket original
* @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk)
*/
- DECLARE vDone INT DEFAULT FALSE;
- DECLARE vHasItemPackingType BOOL;
- DECLARE vItemPackingTypeFk INT;
+ DECLARE vIsDone BOOLEAN DEFAULT FALSE;
+ DECLARE vCurrentPackingType VARCHAR(1);
+ DECLARE vDefaultPackingType VARCHAR(1);
+ DECLARE vHasOriginalPackingType BOOLEAN;
DECLARE vNewTicketFk INT;
+ DECLARE vTicketFk INT;
- DECLARE vItemPackingTypes CURSOR FOR
- SELECT DISTINCT itemPackingTypeFk
- FROM tSalesToMove;
+ DECLARE vItemPackingTypes CURSOR FOR
+ SELECT DISTINCT itemPackingTypeFk FROM tSalesToMove;
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE;
- SELECT COUNT(*) INTO vHasItemPackingType
- FROM ticket t
- JOIN sale s ON s.ticketFk = t.id
- JOIN item i ON i.id = s.itemFk
- WHERE t.id = vSelf
- AND i.itemPackingTypeFk = vOriginalItemPackingTypeFk;
-
- CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT(
- ticketFk INT,
- itemPackingTypeFk VARCHAR(1)
- ) ENGINE=MEMORY
- SELECT vSelf ticketFk, vOriginalItemPackingTypeFk itemPackingTypeFk;
-
- IF NOT vHasItemPackingType THEN
- LEAVE proc;
- END IF;
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ ROLLBACK;
+ RESIGNAL;
+ END;
CREATE OR REPLACE TEMPORARY TABLE tSalesToMove (
ticketFk INT,
saleFk INT,
- itemPackingTypeFk INT
+ itemPackingTypeFk VARCHAR(1)
) ENGINE=MEMORY;
+ SELECT COALESCE(MAX(ic.defaultPackingTypeFk), MAX(i.itemPackingTypeFk)) INTO vDefaultPackingType
+ FROM vn.sale s
+ JOIN item i ON i.id = s.itemFk
+ LEFT JOIN itemConfig ic ON ic.defaultPackingTypeFk = i.itemPackingTypeFk
+ WHERE s.ticketFk = vSelf
+ GROUP BY s.ticketFk;
+
+ SELECT EXISTS (
+ SELECT TRUE
+ FROM sale s
+ JOIN item i ON i.id = s.itemFk
+ WHERE s.ticketFk = vSelf
+ AND i.itemPackingTypeFk = vOriginalItemPackingTypeFk
+ ) INTO vHasOriginalPackingType;
+
+ IF vOriginalItemPackingTypeFk IS NULL OR NOT vHasOriginalPackingType THEN
+ SET vOriginalItemPackingTypeFk = vDefaultPackingType;
+ END IF;
+
+ START TRANSACTION;
+
+ SELECT t.id INTO vTicketFk
+ FROM ticket t
+ JOIN sale s ON s.id = t.id
+ WHERE t.id = vSelf
+ FOR UPDATE;
+
INSERT INTO tSalesToMove (saleFk, itemPackingTypeFk)
- SELECT s.id, i.itemPackingTypeFk
- FROM ticket t
- JOIN sale s ON s.ticketFk = t.id
- JOIN item i ON i.id = s.itemFk
- WHERE t.id = vSelf
+ SELECT s.id, i.itemPackingTypeFk
+ FROM sale s
+ JOIN item i ON i.id = s.itemFk
+ WHERE s.ticketFk = vSelf
AND i.itemPackingTypeFk <> vOriginalItemPackingTypeFk;
OPEN vItemPackingTypes;
-
l: LOOP
- SET vDone = FALSE;
- FETCH vItemPackingTypes INTO vItemPackingTypeFk;
+ SET vIsDone = FALSE;
+ FETCH vItemPackingTypes INTO vCurrentPackingType;
- IF vDone THEN
+ IF vIsDone THEN
LEAVE l;
END IF;
CALL ticket_Clone(vSelf, vNewTicketFk);
+ SELECT id INTO vTicketFk
+ FROM ticket t
+ WHERE t.id = vNewTicketFk
+ FOR UPDATE;
+
UPDATE tSalesToMove
SET ticketFk = vNewTicketFk
- WHERE itemPackingTypeFk = vItemPackingTypeFk;
+ WHERE itemPackingTypeFk = vCurrentPackingType;
+
+ IF vCurrentPackingType = vDefaultPackingType THEN
+ INSERT INTO tSalesToMove (ticketFk, saleFk, itemPackingTypeFk)
+ SELECT vNewTicketFk, s.id, i.itemPackingTypeFk
+ FROM sale s
+ JOIN item i ON i.id = s.itemFk
+ WHERE s.ticketFk = vSelf
+ AND i.itemPackingTypeFk IS NULL;
+ END IF;
END LOOP;
-
CLOSE vItemPackingTypes;
UPDATE sale s
- JOIN tSalesToMove stm ON stm.saleFk = s.id
- SET s.ticketFk = stm.ticketFk
- WHERE stm.ticketFk;
+ JOIN tSalesToMove t ON t.saleFk = s.id
+ SET s.ticketFk = t.ticketFk;
- INSERT INTO tmp.ticketIPT (ticketFk, itemPackingTypeFk)
- SELECT ticketFk, itemPackingTypeFk
+ CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT
+ ENGINE=MEMORY
+ SELECT s.ticketFk, MAX(i.itemPackingTypeFk) itemPackingTypeFk
+ FROM sale s
+ JOIN item i ON i.id = s.itemFk
+ WHERE s.ticketFk = vSelf
+ GROUP BY s.ticketFk
+ UNION
+ SELECT ticketFk, MAX(itemPackingTypeFk)
FROM tSalesToMove
GROUP BY ticketFk;
+ COMMIT;
+
DROP TEMPORARY TABLE tSalesToMove;
END$$
DELIMITER ;
diff --git a/db/routines/vn/procedures/travelVolume_get.sql b/db/routines/vn/procedures/travelVolume_get.sql
index bb98cacdf..ab24a6395 100644
--- a/db/routines/vn/procedures/travelVolume_get.sql
+++ b/db/routines/vn/procedures/travelVolume_get.sql
@@ -10,7 +10,7 @@ BEGIN
JOIN vn.entry e ON e.travelFk = tr.id
JOIN vn.buy b ON b.entryFk = e.id
WHERE tr.landed BETWEEN vFromDated AND vToDated
- AND NOT tr.daysInForward
+ AND NOT tr.isRaid
AND tr.warehouseInFk = vWarehouseFk
GROUP BY tr.landed , a.name ;
END$$
diff --git a/db/routines/vn/procedures/travel_checkRaid.sql b/db/routines/vn/procedures/travel_checkRaid.sql
new file mode 100644
index 000000000..64f3355e2
--- /dev/null
+++ b/db/routines/vn/procedures/travel_checkRaid.sql
@@ -0,0 +1,17 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_checkRaid`(
+ vIsRaid BOOL,
+ vDaysInForward INT
+)
+BEGIN
+/**
+ * Check if the values of isRaid and daysInforward are correct
+ *
+ * @param vIsRaid idRaid value
+ * @param vDaysInForward daysInForward value
+ */
+ IF (NOT vIsRaid AND vDaysInForward IS NOT NULL) OR (vIsRaid AND vDaysInForward IS NULL) THEN
+ CALL util.throw('The raid information is not correct');
+ END IF;
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/procedures/travel_moveRaids.sql b/db/routines/vn/procedures/travel_moveRaids.sql
index aa554a1a0..cf0fce23c 100644
--- a/db/routines/vn/procedures/travel_moveRaids.sql
+++ b/db/routines/vn/procedures/travel_moveRaids.sql
@@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_moveRaids`()
BEGIN
/**
* Desplaza los travels en el futuro y avisa a los compradores
- *
+ *
*/
DECLARE vDone BOOL DEFAULT FALSE;
DECLARE vBuyerEmail VARCHAR(40);
@@ -11,21 +11,21 @@ BEGIN
DECLARE vMailBody TEXT DEFAULT '';
DECLARE vCur CURSOR FOR
- SELECT GROUP_CONCAT(DISTINCT
- CONCAT('https://salix.verdnatura.es/#!/travel/',
- ttm.travelFk,
+ SELECT GROUP_CONCAT(DISTINCT
+ CONCAT('https://salix.verdnatura.es/#!/travel/',
+ ttm.travelFk,
'/summary ')
ORDER BY ttm.travelFk SEPARATOR '\n\r') travelLink,
CONCAT(u.name, '@verdnatura.es') buyerEmail
FROM tTravelToMove ttm
- JOIN entry e ON e.travelFk = ttm.travelFk
+ JOIN entry e ON e.travelFk = ttm.travelFk
JOIN buy b ON b.entryFk = e.id
JOIN item i ON i.id = b.itemFk
JOIN itemType it ON it.id = i.typeFk
JOIN account.user u ON u.id = it.workerFk
GROUP BY u.name;
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
@@ -34,10 +34,11 @@ BEGIN
END;
CREATE OR REPLACE TEMPORARY TABLE tTravelToMove
- SELECT id travelFk,
+ SELECT id travelFk,
util.VN_CURDATE() + INTERVAL daysInForward DAY newLanded
FROM travel
- WHERE daysInForward;
+ WHERE isRaid
+ AND daysInForward;
START TRANSACTION;
diff --git a/db/routines/vn/procedures/workerTimeControl_check.sql b/db/routines/vn/procedures/workerTimeControl_check.sql
deleted file mode 100644
index 30cf5c639..000000000
--- a/db/routines/vn/procedures/workerTimeControl_check.sql
+++ /dev/null
@@ -1,168 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerTimeControl_check`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100))
-proc: BEGIN
-/**
- * Verifica si el empleado puede fichar en el momento actual, si puede fichar llama a workerTimeControlAdd
- *
- * @param vUserFk Identificador del trabajador
- * @return Retorna si encuentra un problema 'odd','maxTimeWork','breakDay','breakWeek' ;
- * En caso de tener algun problema retorna el primero que encuentra
- */
- DECLARE vLastIn DATETIME ;
- DECLARE vLastOut DATETIME ;
- DECLARE vDayWorkMax INT;
- DECLARE vDayBreak INT;
- DECLARE vWeekBreak INT ;
- DECLARE vWeekScope INT;
- DECLARE vDayStayMax INT;
- DECLARE vProblem VARCHAR(20) DEFAULT NULL;
- DECLARE vTimedWorked INT;
- DECLARE vCalendarStateType VARCHAR(20) DEFAULT NULL;
- DECLARE vDepartmentFk INT;
- DECLARE vTo VARCHAR(50) DEFAULT NULL;
- DECLARE vUserName VARCHAR(50) DEFAULT NULL;
- DECLARE vBody VARCHAR(255) DEFAULT NULL;
-
- SELECT dayBreak, weekBreak, weekScope, dayWorkMax, dayStayMax
- INTO vDayBreak, vWeekBreak, vWeekScope, vDayWorkMax, vDayStayMax
- FROM workerTimeControlParams;
-
- SELECT MAX(timed) INTO vLastIn
- FROM workerTimeControl
- WHERE userFk = vUserFk
- AND direction = 'in';
-
- SELECT MAX(timed) INTO vLastOut
- FROM workerTimeControl
- WHERE userFk = vUserFk
- AND direction = 'out';
-
- SELECT CONCAT(u.name,'@verdnatura.es') INTO vTo
- FROM account.user u
- WHERE u.id = (SELECT bossFk FROM worker WHERE id = vUserFk);
-
- SELECT CONCAT(firstName,' ',lastName) INTO vUserName
- FROM worker w
- WHERE w.id = vUserFk;
-
-
- IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastIn) > vDayStayMax THEN -- NUEVA JORNADA
-
- -- VERIFICAR DESCANSO DIARIO
- IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastOut) < vDayBreak THEN
- SELECT "Descansos 12 h" AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos 12 h") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
- END IF;
-
- -- VERIFICAR FICHADAS IMPARES DEL ÚLTIMO DÍA QUE SE FICHÓ
- IF (SELECT MOD(COUNT(*),2) -- <>0
- FROM workerTimeControl
- WHERE userFk = vUserFk
- AND timed >= vLastIn
- ) THEN
- SELECT "Dias con fichadas impares" AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Dias con fichadas impares") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
- END IF;
-
- -- VERIFICAR VACACIONES
- SELECT at2.name INTO vCalendarStateType
- FROM calendar c
- JOIN business b ON b.id = c.businessFk
- JOIN absenceType at2 ON at2.id = c.dayOffTypeFk
- WHERE c.dated = util.VN_CURDATE()
- AND at2.isAllowedToWork = FALSE
- AND b.workerFk = vUserFk
- LIMIT 1;
-
- IF(LENGTH(vCalendarStateType)) THEN
- SELECT vCalendarStateType AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Vacaciones") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
-
- END IF;
-
- -- VERIFICAR CONTRATO EN VIGOR
- IF (SELECT COUNT(*)
- FROM business b
- WHERE b.workerFk = vUserFk
- AND b.started <= vDated
- AND IFNULL(b.ended, vDated) >= vDated
- ) = 0 THEN
- SELECT "No hay un contrato en vigor" AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"No hay un contrato en vigor") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
-
- END IF;
-
- -- VERIFICAR DESCANSO SEMANAL
- SET @vHasBreakWeek:= FALSE;
- SET @vLastTimed:= UNIX_TIMESTAMP((util.VN_NOW() - INTERVAL vWeekScope SECOND));
-
- DROP TEMPORARY TABLE IF EXISTS tmp.trash;
- CREATE TEMPORARY TABLE tmp.trash
- SELECT IF(vWeekBreak-(UNIX_TIMESTAMP(timed)-@vLastTimed) <= 0, @vHasBreakWeek:=TRUE, TRUE) alias,
- @vLastTimed:= UNIX_TIMESTAMP(timed)
- FROM workerTimeControl
- WHERE timed>= (util.VN_NOW() - INTERVAL vWeekScope SECOND)
- AND userFk= vUserFk
- AND direction IN ('in','out')
- ORDER BY timed ASC;
-
- IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastOut) < vWeekBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA
- SELECT "Descansos 36 h" AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos 36 h") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
- END IF;
-
- DROP TEMPORARY TABLE tmp.trash;
-
- ELSE -- DIA ACTUAL
-
- -- VERIFICA QUE EL TIEMPO EFECTIVO NO SUPERE EL MÁXIMO
- SELECT IFNULL(SUM(if( mod(wtc.order,2)=1, -UNIX_TIMESTAMP(timed), UNIX_TIMESTAMP(timed))),0) - IF( MOD(COUNT(*),2), UNIX_TIMESTAMP(util.VN_NOW()), 0) INTO vTimedWorked
- FROM workerTimeControl wtc
- WHERE userFk = vUserFk
- AND timed >= vLastIn
- ORDER BY timed;
-
- IF vTimedWorked > vDayWorkMax THEN
- SELECT "Jornadas" AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Jornadas") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
- END IF;
-
- END IF;
-
- -- VERIFICAR DEPARTAMENTO
- /* IF vTabletFk IS NOT NULL THEN
- SELECT wtcu.departmentFk INTO vDepartmentFk
- FROM workerTimeControlUserInfo wtcu
- WHERE wtcu.userFk = vUserFk;
- IF (SELECT COUNT(td.tabletFk)
- FROM tabletDepartment td
- WHERE td.tabletFk = vTabletFk AND td.departmentFk = vDepartmentFk
- ) = 0 THEN
- SELECT "No perteneces a este departamento." AS problem;
- -- ENVIAMOS CORREO AL BOSSFK
- SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"No perteneces a este departamento.") INTO vBody;
- CALL mail_insert(vTo,vTo,'error al fichar',vBody);
- LEAVE proc;
- END IF;
- END IF;*/
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn/triggers/address_beforeInsert.sql b/db/routines/vn/triggers/address_beforeInsert.sql
index 56ef7aa51..a4f384f14 100644
--- a/db/routines/vn/triggers/address_beforeInsert.sql
+++ b/db/routines/vn/triggers/address_beforeInsert.sql
@@ -6,6 +6,7 @@ BEGIN
DECLARE vIsEqualizated BOOL;
SET NEW.editorFk = account.myUser_getId();
+ SET NEW.geoFk = address_getGeo(NEW.id);
IF (NEW.phone <> '') THEN
CALL pbx.phone_isValid(NEW.phone);
diff --git a/db/routines/vn/triggers/address_beforeUpdate.sql b/db/routines/vn/triggers/address_beforeUpdate.sql
index 35887912c..0b19a6266 100644
--- a/db/routines/vn/triggers/address_beforeUpdate.sql
+++ b/db/routines/vn/triggers/address_beforeUpdate.sql
@@ -3,7 +3,6 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`address_beforeUpdate`
BEFORE UPDATE ON `address`
FOR EACH ROW
BEGIN
-
SET NEW.editorFk = account.myUser_getId();
IF !(NEW.phone <=> OLD.phone) AND (NEW.phone <> '') THEN
@@ -14,5 +13,10 @@ BEGIN
CALL pbx.phone_isValid(NEW.mobile);
END IF;
+ IF NOT (NEW.provinceFk <=> OLD.provinceFk)
+ OR (NEW.postalCode <=> OLD.postalCode) THEN
+
+ SET NEW.geoFk = address_getGeo(NEW.id);
+ END IF;
END$$
DELIMITER ;
diff --git a/db/routines/vn/triggers/client_beforeInsert.sql b/db/routines/vn/triggers/client_beforeInsert.sql
index 45de107f1..b4038a2ba 100644
--- a/db/routines/vn/triggers/client_beforeInsert.sql
+++ b/db/routines/vn/triggers/client_beforeInsert.sql
@@ -3,8 +3,10 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`client_beforeInsert`
BEFORE INSERT ON `client`
FOR EACH ROW
BEGIN
-
SET NEW.editorFk = account.myUser_getId();
+ SET NEW.accountingAccount = 4300000000 + NEW.id;
+ SET NEW.lastSalesPersonFk = NEW.salesPersonFk;
+ SET NEW.geoFk = client_getGeo(NEW.id);
IF (NEW.phone <> '') THEN
CALL pbx.phone_isValid(NEW.phone);
@@ -13,9 +15,5 @@ BEGIN
IF (NEW.mobile <> '') THEN
CALL pbx.phone_isValid(NEW.mobile);
END IF;
-
- SET NEW.accountingAccount = 4300000000 + NEW.id;
-
- SET NEW.lastSalesPersonFk = NEW.salesPersonFk;
END$$
DELIMITER ;
diff --git a/db/routines/vn/triggers/client_beforeUpdate.sql b/db/routines/vn/triggers/client_beforeUpdate.sql
index 7142d6604..00418a9e7 100644
--- a/db/routines/vn/triggers/client_beforeUpdate.sql
+++ b/db/routines/vn/triggers/client_beforeUpdate.sql
@@ -72,5 +72,11 @@ BEGIN
IF NOT (NEW.businessTypeFk <=> OLD.businessTypeFk) AND (NEW.businessTypeFk = 'individual' OR OLD.businessTypeFk = 'individual') THEN
SET NEW.isTaxDataChecked = 0;
END IF;
+
+ IF NOT (NEW.provinceFk <=> OLD.provinceFk)
+ OR (NEW.postcode <=> OLD.postcode) THEN
+
+ SET NEW.geoFk = client_getGeo(NEW.id);
+ END IF;
END$$
DELIMITER ;
diff --git a/db/routines/vn/triggers/entry_beforeUpdate.sql b/db/routines/vn/triggers/entry_beforeUpdate.sql
index 3b999012f..4f2c5ed4a 100644
--- a/db/routines/vn/triggers/entry_beforeUpdate.sql
+++ b/db/routines/vn/triggers/entry_beforeUpdate.sql
@@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`entry_beforeUpdate`
BEFORE UPDATE ON `entry`
FOR EACH ROW
BEGIN
- DECLARE vDaysInForward INT;
+ DECLARE vIsRaid BOOL;
DECLARE vPrintedCount INT;
DECLARE vHasDistinctWarehouses BOOL;
DECLARE vTotalBuy INT;
@@ -38,10 +38,10 @@ BEGIN
CALL travel_throwAwb(NEW.travelFk);
END IF;
- SELECT daysInForward INTO vDaysInForward
+ SELECT t.isRaid INTO vIsRaid
FROM travel t
JOIN entry e ON e.travelFk = t.id
- WHERE entryFk = NEW.id;
+ WHERE e.id = NEW.id;
SELECT NOT (o.warehouseInFk <=> n.warehouseInFk)
OR NOT (o.warehouseOutFk <=> n.warehouseOutFk)
@@ -50,7 +50,7 @@ BEGIN
WHERE o.id = OLD.travelFk
AND n.id = NEW.travelFk;
- IF vDaysInForward AND vHasDistinctWarehouses THEN
+ IF vIsRaid AND vHasDistinctWarehouses THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'A cloned entry cannot be moved to a travel with different warehouses';
END IF;
diff --git a/db/routines/vn/triggers/expedition_beforeDelete.sql b/db/routines/vn/triggers/expedition_beforeDelete.sql
index 13ba19631..60d3a6ca1 100644
--- a/db/routines/vn/triggers/expedition_beforeDelete.sql
+++ b/db/routines/vn/triggers/expedition_beforeDelete.sql
@@ -7,6 +7,7 @@ BEGIN
SET packages = (SELECT COUNT(counter)-1
FROM expedition e WHERE e.ticketFk = OLD.ticketFk and e.freightItemFk)
WHERE t.id = OLD.ticketFk;
-
+
+ CALL expedition_selfConsumptionPackaging(OLD.id, 'remove');
END$$
DELIMITER ;
diff --git a/db/routines/vn/triggers/itemCost_beforeUpdate.sql b/db/routines/vn/triggers/itemCost_beforeUpdate.sql
index bd5fde85a..8de288a92 100644
--- a/db/routines/vn/triggers/itemCost_beforeUpdate.sql
+++ b/db/routines/vn/triggers/itemCost_beforeUpdate.sql
@@ -16,7 +16,7 @@ BEGIN
JOIN vn.route r ON r.id = t.routeFk
WHERE r.isOk = FALSE
AND ic.itemFk = NEW.itemFk
- AND r.created >= util.VN_CURDATE()
+ AND r.dated >= util.VN_CURDATE()
GROUP BY r.id;
IF NEW.cm3Delivery = 0 AND NEW.warehouseFk = 60 THEN
CALL mail_insert(
diff --git a/db/routines/vn/triggers/itemShelving_afterInsert.sql b/db/routines/vn/triggers/itemShelving_afterInsert.sql
deleted file mode 100644
index 92243ca03..000000000
--- a/db/routines/vn/triggers/itemShelving_afterInsert.sql
+++ /dev/null
@@ -1,18 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemShelving_afterInsert`
- AFTER INSERT ON `itemShelving`
- FOR EACH ROW
-BEGIN
- INSERT INTO itemShelvingLog
- SET itemShelvingFk = NEW.id,
- workerFk = account.myUser_getId(),
- accion = 'CREA REGISTRO',
- itemFk = NEW.itemFk,
- shelvingFk = NEW.shelvingFk,
- visible = NEW.visible,
- `grouping` = NEW.`grouping`,
- packing = NEW.packing,
- available = NEW.available;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn/triggers/itemShelving_afterUpdate.sql b/db/routines/vn/triggers/itemShelving_afterUpdate.sql
deleted file mode 100644
index e5e63db43..000000000
--- a/db/routines/vn/triggers/itemShelving_afterUpdate.sql
+++ /dev/null
@@ -1,18 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemShelving_afterUpdate`
- AFTER UPDATE ON `itemShelving`
- FOR EACH ROW
-BEGIN
- INSERT INTO itemShelvingLog
- SET itemShelvingFk = NEW.id,
- workerFk = account.myUser_getId(),
- accion = 'CAMBIO',
- itemFk = NEW.itemFk,
- shelvingFk = NEW.shelvingFk,
- visible = NEW.visible,
- `grouping` = NEW.`grouping`,
- packing = NEW.packing,
- available = NEW.available;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn/triggers/itemShelving_beforeDelete.sql b/db/routines/vn/triggers/itemShelving_beforeDelete.sql
deleted file mode 100644
index 89737a841..000000000
--- a/db/routines/vn/triggers/itemShelving_beforeDelete.sql
+++ /dev/null
@@ -1,15 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemShelving_beforeDelete`
- BEFORE DELETE ON `itemShelving`
- FOR EACH ROW
-INSERT INTO vn.itemShelvingLog(itemShelvingFk,
- workerFk,
- accion,
- shelvingFk,
- itemFk)
- VALUES( OLD.id,
- account.myUser_getId(),
- 'ELIMINADO',
- OLD.shelvingFk,
- OLD.itemFk)$$
-DELIMITER ;
diff --git a/db/routines/vn/triggers/route_afterUpdate.sql b/db/routines/vn/triggers/route_afterUpdate.sql
index ec205090e..447608acc 100644
--- a/db/routines/vn/triggers/route_afterUpdate.sql
+++ b/db/routines/vn/triggers/route_afterUpdate.sql
@@ -2,18 +2,18 @@ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`route_afterUpdate`
AFTER UPDATE ON `route`
FOR EACH ROW
-BEGIN
+BEGIN
IF IFNULL(NEW.gestdocFk,0) <> IFNULL(OLD.gestdocFk,0) AND NEW.gestdocFk > 0 THEN
-- JGF 09/09/14 cuando se añade un gestdoc a una ruta, se le asigna automagicamente a todos sus Tickets
-
+
-- Inserta el gestdoc en todos los tickets de la ruta
INSERT INTO ticketDms(ticketFk,dmsFk)
SELECT id, NEW.gestdocFk FROM ticket WHERE routeFk = NEW.id
ON DUPLICATE KEY UPDATE dmsFk = NEW.gestdocFk;
- -- Update del firmado
- UPDATE ticket t
- JOIN ticketDms tg ON t.id = tg.ticketFk
+ -- Update del firmado
+ UPDATE ticket t
+ JOIN ticketDms tg ON t.id = tg.ticketFk
SET isSigned = 1 WHERE t.routeFk = NEW.id;
END IF;
@@ -21,7 +21,8 @@ BEGIN
OR !(NEW.kmEnd <=> OLD.kmEnd)
OR !(NEW.workerFk <=> OLD.workerFk)
OR !(NEW.m3 <=> OLD.m3)
- OR !(NEW.agencyModeFk <=> OLD.agencyModeFk)THEN
+ OR !(NEW.agencyModeFk <=> OLD.agencyModeFk)
+ OR !(NEW.vehicleFk <=> OLD.vehicleFk)THEN
CALL route_calcCommission(NEW.id);
END IF;
diff --git a/db/routines/vn/triggers/route_beforeInsert.sql b/db/routines/vn/triggers/route_beforeInsert.sql
index 788efe662..0afc9617e 100644
--- a/db/routines/vn/triggers/route_beforeInsert.sql
+++ b/db/routines/vn/triggers/route_beforeInsert.sql
@@ -14,7 +14,7 @@ BEGIN
SELECT IFNULL(b.workCenterFK, r.defaultWorkCenterFk)
FROM vn.routeConfig r
LEFT JOIN vn.business b ON b.workerFk = vUserFk
- AND NEW.created BETWEEN b.started AND IFNULL(b.ended, NEW.created));
+ AND NEW.dated BETWEEN b.started AND IFNULL(b.ended, NEW.dated));
IF ISNULL(NEW.agencyModeFk) THEN
SELECT r.agencyModeFk INTO vDefaultAgencyModeFk
diff --git a/db/routines/vn/triggers/sale_afterInsert.sql b/db/routines/vn/triggers/sale_afterInsert.sql
index f15b17722..1a9ef240a 100644
--- a/db/routines/vn/triggers/sale_afterInsert.sql
+++ b/db/routines/vn/triggers/sale_afterInsert.sql
@@ -23,7 +23,7 @@ BEGIN
JOIN vn.route r ON r.id = t.routeFk
WHERE r.isOk = FALSE
AND s.id = NEW.id
- AND r.created >= util.VN_CURDATE()
+ AND r.dated >= util.VN_CURDATE()
GROUP BY r.id;
END IF;
END$$
diff --git a/db/routines/vn/triggers/sale_afterUpdate.sql b/db/routines/vn/triggers/sale_afterUpdate.sql
index 82da55486..49e5383d0 100644
--- a/db/routines/vn/triggers/sale_afterUpdate.sql
+++ b/db/routines/vn/triggers/sale_afterUpdate.sql
@@ -54,7 +54,7 @@ BEGIN
JOIN vn.route r ON r.id = t.routeFk
WHERE r.isOk = FALSE
AND s.id = NEW.id
- AND r.created >= util.VN_CURDATE()
+ AND r.dated >= util.VN_CURDATE()
GROUP BY r.id;
END IF;
diff --git a/db/routines/vn/triggers/sale_beforeDelete.sql b/db/routines/vn/triggers/sale_beforeDelete.sql
index ad97f8b55..0f72d788b 100644
--- a/db/routines/vn/triggers/sale_beforeDelete.sql
+++ b/db/routines/vn/triggers/sale_beforeDelete.sql
@@ -11,7 +11,7 @@ BEGIN
JOIN vn.route r ON r.id = t.routeFk
WHERE r.isOk = FALSE
AND s.id = OLD.id
- AND r.created >= util.VN_CURDATE()
+ AND r.dated >= util.VN_CURDATE()
GROUP BY r.id;
END IF;
END$$
diff --git a/db/routines/vn/triggers/supplier_beforeInsert.sql b/db/routines/vn/triggers/supplier_beforeInsert.sql
index b141ec8fb..5bbfc79a1 100644
--- a/db/routines/vn/triggers/supplier_beforeInsert.sql
+++ b/db/routines/vn/triggers/supplier_beforeInsert.sql
@@ -4,5 +4,6 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`supplier_beforeInsert`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
+ SET NEW.geoFk = supplier_getGeo(NEW.id);
END$$
DELIMITER ;
diff --git a/db/routines/vn/triggers/supplier_beforeUpdate.sql b/db/routines/vn/triggers/supplier_beforeUpdate.sql
index af730b49d..b502340a3 100644
--- a/db/routines/vn/triggers/supplier_beforeUpdate.sql
+++ b/db/routines/vn/triggers/supplier_beforeUpdate.sql
@@ -40,5 +40,10 @@ BEGIN
SET NEW.isPayMethodChecked = FALSE;
END IF;
+ IF NOT (NEW.provinceFk <=> OLD.provinceFk)
+ OR (NEW.postCode <=> OLD.postCode) THEN
+
+ SET NEW.geoFk = supplier_getGeo(NEW.id);
+ END IF;
END$$
DELIMITER ;
diff --git a/db/routines/vn/triggers/ticket_beforeDelete.sql b/db/routines/vn/triggers/ticket_beforeDelete.sql
index 953fa509a..2115175b5 100644
--- a/db/routines/vn/triggers/ticket_beforeDelete.sql
+++ b/db/routines/vn/triggers/ticket_beforeDelete.sql
@@ -8,7 +8,7 @@ BEGIN
FROM vn.route r
WHERE r.isOk = FALSE
AND r.id = OLD.routeFk
- AND r.created >= util.VN_CURDATE()
+ AND r.dated >= util.VN_CURDATE()
GROUP BY r.id;
DELETE FROM sale WHERE ticketFk = OLD.id;
diff --git a/db/routines/vn/triggers/ticket_beforeUpdate.sql b/db/routines/vn/triggers/ticket_beforeUpdate.sql
index 3208a93d0..f86f50485 100644
--- a/db/routines/vn/triggers/ticket_beforeUpdate.sql
+++ b/db/routines/vn/triggers/ticket_beforeUpdate.sql
@@ -22,7 +22,7 @@ BEGIN
FROM `route`
WHERE NOT isOk
AND id IN (OLD.routeFk, NEW.routeFk)
- AND created >= util.VN_CURDATE()
+ AND dated >= util.VN_CURDATE()
GROUP BY id;
END IF;
@@ -45,7 +45,7 @@ BEGIN
JOIN vn.route r ON r.id = t.routeFk
WHERE r.isOk = FALSE
AND t.id = NEW.id
- AND r.created >= util.VN_CURDATE()
+ AND r.dated >= util.VN_CURDATE()
GROUP BY r.id;
SET NEW.shipped = DATE_FORMAT(NEW.shipped, '2000-%m-%d %T');
SET NEW.landed = DATE_FORMAT(NEW.landed, '2000-%m-%d %T');
diff --git a/db/routines/vn/triggers/town_beforeUpdate.sql b/db/routines/vn/triggers/town_beforeUpdate.sql
deleted file mode 100644
index fc1410d5c..000000000
--- a/db/routines/vn/triggers/town_beforeUpdate.sql
+++ /dev/null
@@ -1,10 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`town_beforeUpdate`
- BEFORE UPDATE ON `town`
- FOR EACH ROW
-BEGIN
- -- IF !(OLD.geoFk <=> NEW.geoFk) THEN
- -- CALL zoneGeo_throwNotEditable;
- -- END IF;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn/triggers/travel_beforeInsert.sql b/db/routines/vn/triggers/travel_beforeInsert.sql
index 4563c9a81..5356ed537 100644
--- a/db/routines/vn/triggers/travel_beforeInsert.sql
+++ b/db/routines/vn/triggers/travel_beforeInsert.sql
@@ -8,7 +8,11 @@ BEGIN
CALL travel_checkDates(NEW.shipped, NEW.landed);
CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
-
+
+ IF NEW.isRaid IS NOT NULL OR NEW.daysInForward IS NOT NULL THEN
+ CALL travel_checkRaid(NEW.isRaid, NEW.daysInForward);
+ END IF;
+
IF NEW.awbFk IS NOT NULL THEN
CALL travel_throwAwb(NEW.id);
END IF;
diff --git a/db/routines/vn/triggers/travel_beforeUpdate.sql b/db/routines/vn/triggers/travel_beforeUpdate.sql
index 33578fea1..256dd35f8 100644
--- a/db/routines/vn/triggers/travel_beforeUpdate.sql
+++ b/db/routines/vn/triggers/travel_beforeUpdate.sql
@@ -7,7 +7,7 @@ BEGIN
SET NEW.editorFk = account.myUser_getId();
- IF NOT (NEW.landed <=> OLD.landed)
+ IF NOT (NEW.landed <=> OLD.landed)
OR NOT (NEW.shipped <=> OLD.shipped) THEN
CALL travel_checkDates(NEW.shipped, NEW.landed);
END IF;
@@ -21,18 +21,18 @@ BEGIN
END IF;
IF NOT (NEW.awbFk <=> OLD.awbFk)THEN
- SELECT COUNT(*) INTO vHasAnyInvoiceBooked
+ SELECT COUNT(*) INTO vHasAnyInvoiceBooked
FROM travel t
- JOIN entry e ON e.travelFk = t.id
- JOIN invoiceIn ii ON ii.id = e.invoiceInFk
+ JOIN entry e ON e.travelFk = t.id
+ JOIN invoiceIn ii ON ii.id = e.invoiceInFk
WHERE t.id = NEW.id
- AND ii.isBooked;
-
+ AND ii.isBooked;
+
IF vHasAnyInvoiceBooked THEN
CALL util.throw('The travel has entries with booked invoices');
END IF;
- END IF;
-
+ END IF;
+
IF (NOT(NEW.awbFk <=> OLD.awbFk)) AND NEW.awbFk IS NOT NULL THEN
CALL travel_throwAwb(NEW.id);
END IF;
diff --git a/db/routines/vn/views/expeditionPallet_Print.sql b/db/routines/vn/views/expeditionPallet_Print.sql
index 7b933a0a1..0a445a4a6 100644
--- a/db/routines/vn/views/expeditionPallet_Print.sql
+++ b/db/routines/vn/views/expeditionPallet_Print.sql
@@ -9,8 +9,8 @@ AS SELECT `rs2`.`description` AS `truck`,
`rs`.`id` <=> `rm`.`roadmapStopFk` AS `isMatch`,
`t`.`warehouseFk` AS `warehouseFk`,
IF(
- `r`.`created` > `util`.`VN_CURDATE`() + INTERVAL 1 DAY,
- ucase(dayname(`r`.`created`)),
+ `r`.`dated` > `util`.`VN_CURDATE`() + INTERVAL 1 DAY,
+ ucase(dayname(`r`.`dated`)),
NULL
) AS `nombreDia`
FROM (
diff --git a/db/routines/vn/views/expeditionRoute_Monitor.sql b/db/routines/vn/views/expeditionRoute_Monitor.sql
index 9b46c8237..716702753 100644
--- a/db/routines/vn/views/expeditionRoute_Monitor.sql
+++ b/db/routines/vn/views/expeditionRoute_Monitor.sql
@@ -6,7 +6,7 @@ AS SELECT `r`.`id` AS `routeFk`,
COUNT(DISTINCT `e`.`id`) AS `expeditions`,
COUNT(DISTINCT `es`.`id`) AS `scanned`,
max(`e`.`created`) AS `lastPacked`,
- `r`.`created` AS `created`
+ `r`.`dated` AS `created`
FROM (
(
(
@@ -23,5 +23,5 @@ FROM (
)
LEFT JOIN `vn`.`expeditionScan` `es` ON(`es`.`expeditionFk` = `e`.`id`)
)
-WHERE `r`.`created` >= `util`.`yesterday`()
+WHERE `r`.`dated` >= `util`.`yesterday`()
GROUP BY `r`.`id`
diff --git a/db/routines/vn/views/itemEntryIn.sql b/db/routines/vn/views/itemEntryIn.sql
index 6196e9396..60af585f2 100644
--- a/db/routines/vn/views/itemEntryIn.sql
+++ b/db/routines/vn/views/itemEntryIn.sql
@@ -6,7 +6,7 @@ AS SELECT `t`.`warehouseInFk` AS `warehouseInFk`,
`b`.`itemFk` AS `itemFk`,
`b`.`quantity` AS `quantity`,
`t`.`isReceived` AS `isReceived`,
- `t`.`daysInForward` AS `isVirtualStock`,
+ `t`.`isRaid` AS `isVirtualStock`,
`e`.`id` AS `entryFk`
FROM (
(
diff --git a/db/routines/vn/views/itemEntryOut.sql b/db/routines/vn/views/itemEntryOut.sql
index f18116e61..4793ddbb8 100644
--- a/db/routines/vn/views/itemEntryOut.sql
+++ b/db/routines/vn/views/itemEntryOut.sql
@@ -15,5 +15,5 @@ FROM (
JOIN `vn`.`travel` `t` ON(`e`.`travelFk` = `t`.`id`)
)
WHERE `e`.`isExcludedFromAvailable` = 0
- AND NOT `t`.`daysInForward`
+ AND NOT `t`.`isRaid`
AND `b`.`quantity` <> 0
diff --git a/db/routines/vn/views/itemShelvingList.sql b/db/routines/vn/views/itemShelvingList.sql
index 457d6f28a..f2cfeda58 100644
--- a/db/routines/vn/views/itemShelvingList.sql
+++ b/db/routines/vn/views/itemShelvingList.sql
@@ -15,7 +15,7 @@ FROM (
(
(
`vn`.`itemShelving` `ish`
- JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`)
+ JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`)
)
JOIN `vn`.`item` `i` ON(`i`.`id` = `ish`.`itemFk`)
)
diff --git a/db/routines/vn/views/itemShelvingPlacementSupplyStock.sql b/db/routines/vn/views/itemShelvingPlacementSupplyStock.sql
index fa1c11314..1ebb6410c 100644
--- a/db/routines/vn/views/itemShelvingPlacementSupplyStock.sql
+++ b/db/routines/vn/views/itemShelvingPlacementSupplyStock.sql
@@ -18,7 +18,7 @@ FROM (
(
(
`vn`.`itemShelving` `ish`
- JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`)
+ JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`)
)
LEFT JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`)
)
diff --git a/db/routines/vn/views/itemShelvingSaleSum.sql b/db/routines/vn/views/itemShelvingSaleSum.sql
index 9a402d6f4..60581faa9 100644
--- a/db/routines/vn/views/itemShelvingSaleSum.sql
+++ b/db/routines/vn/views/itemShelvingSaleSum.sql
@@ -13,7 +13,7 @@ FROM (
`vn`.`itemShelvingSale` `iss`
JOIN `vn`.`itemShelving` `ish` ON(`ish`.`id` = `iss`.`itemShelvingFk`)
)
- JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`)
+ JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`)
)
JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`)
)
diff --git a/db/routines/vn/views/itemShelvingStock.sql b/db/routines/vn/views/itemShelvingStock.sql
index 41777eaec..725a06f88 100644
--- a/db/routines/vn/views/itemShelvingStock.sql
+++ b/db/routines/vn/views/itemShelvingStock.sql
@@ -21,7 +21,7 @@ FROM (
(
(
`vn`.`itemShelving` `ish`
- LEFT JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`)
+ LEFT JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`)
)
LEFT JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`)
)
diff --git a/db/routines/vn/views/itemShelvingStockFull.sql b/db/routines/vn/views/itemShelvingStockFull.sql
index c767823d6..c8a82685c 100644
--- a/db/routines/vn/views/itemShelvingStockFull.sql
+++ b/db/routines/vn/views/itemShelvingStockFull.sql
@@ -19,7 +19,7 @@ FROM (
(
(
`vn`.`itemShelving` `ish`
- JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`)
+ JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`)
)
JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`)
)
diff --git a/db/routines/vn/views/lastPurchases.sql b/db/routines/vn/views/lastPurchases.sql
index 9dc5ec898..3dcaf8c1d 100644
--- a/db/routines/vn/views/lastPurchases.sql
+++ b/db/routines/vn/views/lastPurchases.sql
@@ -31,5 +31,5 @@ FROM (
LEFT JOIN `edi`.`ekt` `ek` ON(`ek`.`id` = `b`.`ektFk`)
)
WHERE `tr`.`landed` BETWEEN `util`.`yesterday`() AND `util`.`tomorrow`()
- AND NOT `tr`.`daysInForward`
+ AND NOT `tr`.`isRaid`
AND `b`.`stickers` > 0
diff --git a/db/routines/vn2008/views/Rutas.sql b/db/routines/vn2008/views/Rutas.sql
index 78b3bb471..c8ade24e9 100644
--- a/db/routines/vn2008/views/Rutas.sql
+++ b/db/routines/vn2008/views/Rutas.sql
@@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost`
VIEW `vn2008`.`Rutas`
AS SELECT `r`.`id` AS `Id_Ruta`,
`r`.`workerFk` AS `Id_Trabajador`,
- `r`.`created` AS `Fecha`,
+ `r`.`dated` AS `Fecha`,
`r`.`vehicleFk` AS `Id_Vehiculo`,
`r`.`agencyModeFk` AS `Id_Agencia`,
`r`.`time` AS `Hora`,
diff --git a/db/routines/vn2008/views/entrySource.sql b/db/routines/vn2008/views/entrySource.sql
index 9c0c0f6ed..732603617 100644
--- a/db/routines/vn2008/views/entrySource.sql
+++ b/db/routines/vn2008/views/entrySource.sql
@@ -8,6 +8,7 @@ AS SELECT `e`.`gestDocFk` AS `gestdoc_id`,
`e`.`isExcludedFromAvailable` AS `Inventario`,
`e`.`isConfirmed` AS `Confirmada`,
`e`.`isOrdered` AS `Pedida`,
+ `tr`.`isRaid` AS `isRaid`,
`tr`.`daysInForward` AS `daysInForward`,
`e`.`evaNotes` AS `notas`,
`e`.`supplierFk` AS `Id_Proveedor`,
diff --git a/db/routines/vn2008/views/travel.sql b/db/routines/vn2008/views/travel.sql
index 0e1f5acb2..38dfd40ea 100644
--- a/db/routines/vn2008/views/travel.sql
+++ b/db/routines/vn2008/views/travel.sql
@@ -18,5 +18,6 @@ AS SELECT `t`.`id` AS `id`,
`t`.`totalEntries` AS `totalEntries`,
`t`.`appointment` AS `appointment`,
`t`.`awbFk` AS `awbFk`,
+ `t`.`isRaid` AS `isRaid`,
`t`.`daysInForward` AS `daysInForward`
FROM `vn`.`travel` `t`
diff --git a/db/routines/vn2008/views/v_compres.sql b/db/routines/vn2008/views/v_compres.sql
index 324e459f6..633feb471 100644
--- a/db/routines/vn2008/views/v_compres.sql
+++ b/db/routines/vn2008/views/v_compres.sql
@@ -86,4 +86,4 @@ FROM (
)
WHERE NOT `W_IN`.`isFeedStock`
AND NOT `E`.`Inventario`
- AND NOT `TR`.`daysInForward`
+ AND NOT `TR`.`isRaid`
diff --git a/db/versions/11251-navyChrysanthemum/00-firstScript.sql b/db/versions/11251-navyChrysanthemum/00-firstScript.sql
index 801405e59..7c2c69839 100644
--- a/db/versions/11251-navyChrysanthemum/00-firstScript.sql
+++ b/db/versions/11251-navyChrysanthemum/00-firstScript.sql
@@ -1,3 +1,2 @@
-UPDATE vn.sale
- SET originalQuantity = quantity
- WHERE originalQuantity IS NULL
+-- Debido a que tardaba mucho en la subida a master, se ha creado una nueva versión para que el proceso no se vea afectado y se ejecute por la noche.
+-- Se crea de nuevo en la versión 11344-grayBamboo
diff --git a/db/versions/11274-redGerbera/00-firstScript4.sql b/db/versions/11274-redGerbera/00-firstScript4.sql
deleted file mode 100644
index c1f574379..000000000
--- a/db/versions/11274-redGerbera/00-firstScript4.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE vn.autonomy MODIFY COLUMN isUeeMember tinyint(1) DEFAULT FALSE NOT NULL;
\ No newline at end of file
diff --git a/db/versions/11312-navyAralia/00-firstScript.sql b/db/versions/11312-navyAralia/00-firstScript.sql
new file mode 100644
index 000000000..452b1feed
--- /dev/null
+++ b/db/versions/11312-navyAralia/00-firstScript.sql
@@ -0,0 +1,23 @@
+ALTER TABLE vn.workerRelatives DROP FOREIGN KEY workerRelatives_disabilityGradeFk;
+ALTER TABLE vn.workerRelatives DROP FOREIGN KEY workerRelatives_workerFk;
+
+INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
+ VALUES
+ ('WorkerRelative','updateAttributes','*','ALLOW','ROLE','hr'),
+ ('WorkerRelative','crud','WRITE','ALLOW','ROLE','hr'),
+ ('WorkerRelative','findById','*','ALLOW','ROLE','hr'),
+ ('WorkerRelative','find','*','ALLOW','ROLE','hr'),
+ ('WorkerRelative','upsert','*','ALLOW','ROLE','hr'),
+ ('WorkerRelative','filter','*','ALLOW','ROLE','hr'),
+ ('WorkerIrpf','updateAttributes','*','ALLOW','ROLE','hr'),
+ ('WorkerIrpf','crud','*','ALLOW','ROLE','hr'),
+ ('WorkerIrpf','findById','*','ALLOW','ROLE','hr'),
+ ('WorkerIrpf','find','*','ALLOW','ROLE','hr'),
+ ('WorkerIrpf','upsert','*','ALLOW','ROLE','hr'),
+ ('WorkerIrpf','filter','*','ALLOW','ROLE','hr'),
+ ('DisabilityGrade','updateAttributes','*','ALLOW','ROLE','hr'),
+ ('DisabilityGrade','crud','*','ALLOW','ROLE','hr'),
+ ('DisabilityGrade','findById','*','ALLOW','ROLE','hr'),
+ ('DisabilityGrade','find','*','ALLOW','ROLE','hr'),
+ ('DisabilityGrade','upsert','*','ALLOW','ROLE','hr');
+
diff --git a/db/versions/11322-azureAspidistra/00-entryAcl.sql b/db/versions/11322-azureAspidistra/00-entryAcl.sql
new file mode 100644
index 000000000..836737d4b
--- /dev/null
+++ b/db/versions/11322-azureAspidistra/00-entryAcl.sql
@@ -0,0 +1,40 @@
+-- Eliminar registros existentes donde property = '*'
+DELETE FROM `salix`.ACL WHERE model = 'entry' AND property = '*';
+
+-- Insertar permisos para los métodos solicitados en el modelo Entry
+INSERT INTO `salix`.ACL (model, property, accessType, permission, principalType, principalId)
+VALUES
+ -- Permisos para administrative
+ ('Entry', 'upsert', 'WRITE', 'ALLOW', 'ROLE', 'administrative'),
+ ('Entry', 'updateAttributes', 'WRITE', 'ALLOW', 'ROLE', 'administrative'),
+ ('Entry', 'isBooked', 'READ', 'ALLOW', 'ROLE', 'administrative'),
+ ('Entry', 'findById', 'READ', 'ALLOW', 'ROLE', 'administrative'),
+ ('Entry', 'find', 'READ', 'ALLOW', 'ROLE', 'administrative'),
+ ('Entry', 'filter', 'READ', 'ALLOW', 'ROLE', 'administrative'),
+ ('Entry', 'count', 'READ', 'ALLOW', 'ROLE', 'administrative'),
+ ('Entry', 'getEntry', 'READ', 'ALLOW', 'ROLE', 'administrative'),
+ ('Entry', 'getBuys', 'READ', 'ALLOW', 'ROLE', 'administrative'),
+ ('Entry', 'findOne', 'READ', 'ALLOW', 'ROLE', 'administrative'),
+ ('Entry', 'deleteBuys', 'WRITE', 'ALLOW', 'ROLE', 'administrative'),
+ ('Entry', 'editLatestBuys', 'WRITE', 'ALLOW', 'ROLE', 'administrative'),
+ ('Entry', 'importBuys', 'WRITE', 'ALLOW', 'ROLE', 'administrative'),
+ ('Entry', 'importBuysPreview', 'READ', 'ALLOW', 'ROLE', 'administrative'),
+ ('Entry', 'lastItemBuys', 'READ', 'ALLOW', 'ROLE', 'administrative'),
+ ('Entry', 'latestBuysFilter', 'READ', 'ALLOW', 'ROLE', 'administrative'),
+
+ -- Permisos para buyer (excluyendo isBooked)
+ ('Entry', 'upsert', 'WRITE', 'ALLOW', 'ROLE', 'buyer'),
+ ('Entry', 'updateAttributes', 'WRITE', 'ALLOW', 'ROLE', 'buyer'),
+ ('Entry', 'findById', 'READ', 'ALLOW', 'ROLE', 'buyer'),
+ ('Entry', 'find', 'READ', 'ALLOW', 'ROLE', 'buyer'),
+ ('Entry', 'filter', 'READ', 'ALLOW', 'ROLE', 'buyer'),
+ ('Entry', 'count', 'READ', 'ALLOW', 'ROLE', 'buyer'),
+ ('Entry', 'getEntry', 'READ', 'ALLOW', 'ROLE', 'buyer'),
+ ('Entry', 'getBuys', 'READ', 'ALLOW', 'ROLE', 'buyer'),
+ ('Entry', 'findOne', 'READ', 'ALLOW', 'ROLE', 'buyer'),
+ ('Entry', 'deleteBuys', 'WRITE', 'ALLOW', 'ROLE', 'buyer'),
+ ('Entry', 'editLatestBuys', 'WRITE', 'ALLOW', 'ROLE', 'buyer'),
+ ('Entry', 'importBuys', 'WRITE', 'ALLOW', 'ROLE', 'buyer'),
+ ('Entry', 'importBuysPreview', 'READ', 'ALLOW', 'ROLE', 'buyer'),
+ ('Entry', 'lastItemBuys', 'READ', 'ALLOW', 'ROLE', 'buyer'),
+ ('Entry', 'latestBuysFilter', 'READ', 'ALLOW', 'ROLE', 'buyer');
diff --git a/db/versions/11324-salmonCataractarum/00-firstScript.sql b/db/versions/11324-salmonCataractarum/00-firstScript.sql
new file mode 100644
index 000000000..5c17ed549
--- /dev/null
+++ b/db/versions/11324-salmonCataractarum/00-firstScript.sql
@@ -0,0 +1,71 @@
+CREATE TABLE IF NOT EXISTS `vn`.`itemTextureTag` (
+ `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `name` varchar(50) DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `name_UNIQUE` (`name`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT
+ CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural y encerado');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural y esponjoso');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural y foam');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural y látex');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Arenosa');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Aterciopelado');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Engomado');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Flocado');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Foam');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Gasa');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Goma');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Látex');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Latón');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Mate');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Metálico');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural y engomado');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Plastificado');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Plastificado y engomado');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Plastificado y rugoso');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Pluma');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Plástico');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Plástico engomado');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Poliéster');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Poliéster texturizado');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Rugoso');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Rígido');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Seminatural');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Silicona');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Suave');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela con brillo');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela con texturas');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela dura');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela engomada');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela escarchada');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela flocada');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela flocada engomada');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela foam');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela micro peach');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela plastificada');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela plástico engomado');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela poliéster');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela PVC');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela ratan');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela rigida');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela rugosa');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela rústica');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela sintética');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y cristal');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y foam');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y goma');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y látex');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y madera');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y plástico');
+INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y seco');
+
+UPDATE vn.tag
+ SET isFree=0,
+ sourceTable='itemTextureTag'
+ WHERE name= 'Textura';
+
+GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemTextureTag TO logisticAssist;
diff --git a/db/versions/11330-greenMoss/00-firstScript.sql b/db/versions/11330-greenMoss/00-firstScript.sql
new file mode 100644
index 000000000..127c8e40e
--- /dev/null
+++ b/db/versions/11330-greenMoss/00-firstScript.sql
@@ -0,0 +1,16 @@
+CREATE TABLE IF NOT EXISTS vn.saySimpleCountry(
+ countryFk MEDIUMINT(8) UNSIGNED,
+ channel INT(4) COMMENT 'channel de whatsapp de saySimple',
+ PRIMARY KEY (countryFk),
+ CONSTRAINT `saySimpleCountry_FK` FOREIGN KEY (`countryFk`) REFERENCES vn.country (`id`) ON UPDATE CASCADE
+);
+
+CREATE TABLE IF NOT EXISTS vn.saySimpleConfig(
+ id INT AUTO_INCREMENT PRIMARY KEY,
+ url VARCHAR(255) NOT NULL
+);
+
+INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel)
+ VALUES (19, 1169),
+ (8, 1183),
+ (NULL, 1320);
\ No newline at end of file
diff --git a/db/versions/11331-bronzeBirch/00-firstScript.sql b/db/versions/11331-bronzeBirch/00-firstScript.sql
new file mode 100644
index 000000000..ada374182
--- /dev/null
+++ b/db/versions/11331-bronzeBirch/00-firstScript.sql
@@ -0,0 +1,2 @@
+ALTER TABLE vn.supplier ADD companySize ENUM('small', 'medium', 'big') NULL;
+
diff --git a/db/versions/11332-tealErica/00-firstScript.sql b/db/versions/11332-tealErica/00-firstScript.sql
new file mode 100644
index 000000000..a7870632f
--- /dev/null
+++ b/db/versions/11332-tealErica/00-firstScript.sql
@@ -0,0 +1,4 @@
+ALTER TABLE vn.travel ADD IF NOT EXISTS isRaid tinyint(1) DEFAULT 0 NOT NULL COMMENT 'Redada';
+
+ALTER TABLE vn.travel MODIFY COLUMN daysInForward int(10) unsigned DEFAULT NULL
+ COMMENT 'Cuando es una redada, indica el número de días que se añadirán a la fecha de hoy para establecer el landed. NULL si no es una redada';
\ No newline at end of file
diff --git a/db/versions/11336-chocolateRaphis/00-firstScript.sql b/db/versions/11336-chocolateRaphis/00-firstScript.sql
new file mode 100644
index 000000000..c86dc39e9
--- /dev/null
+++ b/db/versions/11336-chocolateRaphis/00-firstScript.sql
@@ -0,0 +1,8 @@
+DELETE FROM salix.ACL
+ WHERE property IN ('cmrs', 'cmr', 'downloadCmrsZip')
+ AND model = 'Route';
+
+INSERT INTO salix.ACL (model,property,principalId)
+ VALUES ('Cmr','filter','production'),
+ ('Cmr','downloadZip','production'),
+ ('Cmr','print','production')
\ No newline at end of file
diff --git a/db/versions/11337-limeAsparagus/00-firstScript.sql b/db/versions/11337-limeAsparagus/00-firstScript.sql
new file mode 100644
index 000000000..4cfedc8a8
--- /dev/null
+++ b/db/versions/11337-limeAsparagus/00-firstScript.sql
@@ -0,0 +1 @@
+ALTER TABLE vn.productionConfig DROP COLUMN hasNewLabelMrwMethod;
diff --git a/db/versions/11338-brownMonstera/00-firstScript.sql b/db/versions/11338-brownMonstera/00-firstScript.sql
new file mode 100644
index 000000000..9752bb90d
--- /dev/null
+++ b/db/versions/11338-brownMonstera/00-firstScript.sql
@@ -0,0 +1,2 @@
+-- Place your SQL code here
+RENAME TABLE vn.stockBuyed__ TO vn.stockBuyed;
diff --git a/db/versions/11339-goldenMastic/00-firstScript.sql b/db/versions/11339-goldenMastic/00-firstScript.sql
new file mode 100644
index 000000000..f1da5798a
--- /dev/null
+++ b/db/versions/11339-goldenMastic/00-firstScript.sql
@@ -0,0 +1 @@
+ALTER TABLE vn.dua ADD comment TEXT DEFAULT NULL NULL;
diff --git a/db/versions/11341-pinkSalal/00-firstScript.sql b/db/versions/11341-pinkSalal/00-firstScript.sql
new file mode 100644
index 000000000..2c9e912d9
--- /dev/null
+++ b/db/versions/11341-pinkSalal/00-firstScript.sql
@@ -0,0 +1,5 @@
+
+ALTER TABLE vn.travel ADD IF NOT EXISTS isRaid tinyint(1) DEFAULT 0 NOT NULL COMMENT 'Redada';
+
+ALTER TABLE vn.travel MODIFY COLUMN daysInForward int(10) unsigned DEFAULT NULL
+ COMMENT 'Cuando es una redada, indica el número de días que se añadirán a la fecha de hoy para establecer el landed. NULL si no es una redada';
diff --git a/db/versions/11342-crimsonDendro/00-itemShelving.sql b/db/versions/11342-crimsonDendro/00-itemShelving.sql
new file mode 100644
index 000000000..4d083bf97
--- /dev/null
+++ b/db/versions/11342-crimsonDendro/00-itemShelving.sql
@@ -0,0 +1,6 @@
+CREATE OR REPLACE TEMPORARY TABLE tmp.tItemShelving
+ (PRIMARY KEY (id))
+ ENGINE = MEMORY
+ SELECT ish.id, s.id shelvingFk
+ FROM vn.itemShelving ish
+ JOIN vn.shelving s ON s.code = ish.shelvingFk COLLATE utf8mb3_unicode_ci;
diff --git a/db/versions/11342-crimsonDendro/01-itemShelving.sql b/db/versions/11342-crimsonDendro/01-itemShelving.sql
new file mode 100644
index 000000000..23099ac6b
--- /dev/null
+++ b/db/versions/11342-crimsonDendro/01-itemShelving.sql
@@ -0,0 +1,2 @@
+ALTER TABLE vn.itemShelving DROP FOREIGN KEY itemShelving_fk2,
+ MODIFY COLUMN shelvingFk int(11) NOT NULL;
diff --git a/db/versions/11342-crimsonDendro/02-itemShelving.sql b/db/versions/11342-crimsonDendro/02-itemShelving.sql
new file mode 100644
index 000000000..9d0e65d0b
--- /dev/null
+++ b/db/versions/11342-crimsonDendro/02-itemShelving.sql
@@ -0,0 +1,3 @@
+UPDATE vn.itemShelving ish
+ JOIN tmp.tItemShelving tish ON tish.id = ish.id
+ SET ish.shelvingFk = tish.shelvingFk;
\ No newline at end of file
diff --git a/db/versions/11342-crimsonDendro/03-itemShelving.sql b/db/versions/11342-crimsonDendro/03-itemShelving.sql
new file mode 100644
index 000000000..cb9825bfc
--- /dev/null
+++ b/db/versions/11342-crimsonDendro/03-itemShelving.sql
@@ -0,0 +1,4 @@
+ALTER TABLE vn.itemShelving
+ ADD CONSTRAINT itemShelving_shelving_FK FOREIGN KEY (shelvingFk) REFERENCES vn.shelving(id)
+ ON DELETE RESTRICT
+ ON UPDATE CASCADE;
diff --git a/db/versions/11342-crimsonDendro/04-itemShelvingLog.sql b/db/versions/11342-crimsonDendro/04-itemShelvingLog.sql
new file mode 100644
index 000000000..1135b9d09
--- /dev/null
+++ b/db/versions/11342-crimsonDendro/04-itemShelvingLog.sql
@@ -0,0 +1,8 @@
+/*
+CREATE OR REPLACE TEMPORARY TABLE tmp.tItemShelvingLog
+ (PRIMARY KEY (id))
+ ENGINE = MEMORY
+ SELECT ishl.id, s.id shelvingFk
+ FROM vn.itemShelvingLog ishl
+ JOIN vn.shelving s ON s.code = ishl.shelvingFk COLLATE utf8mb3_unicode_ci;
+*/
diff --git a/db/versions/11342-crimsonDendro/05-itemShelvingLog.sql b/db/versions/11342-crimsonDendro/05-itemShelvingLog.sql
new file mode 100644
index 000000000..b0e3b55cc
--- /dev/null
+++ b/db/versions/11342-crimsonDendro/05-itemShelvingLog.sql
@@ -0,0 +1 @@
+-- ALTER TABLE vn.itemShelvingLog MODIFY COLUMN shelvingFk int(11) NOT NULL;
diff --git a/db/versions/11342-crimsonDendro/06-itemShelvingLog.sql b/db/versions/11342-crimsonDendro/06-itemShelvingLog.sql
new file mode 100644
index 000000000..f97f61e42
--- /dev/null
+++ b/db/versions/11342-crimsonDendro/06-itemShelvingLog.sql
@@ -0,0 +1,7 @@
+/*
+UPDATE vn.itemShelvingLog ishl
+ JOIN tmp.tItemShelvingLog tishl ON tishl.id = ishl.id
+ SET ishl.shelvingFk = tishl.shelvingFk;
+
+DROP TEMPORARY TABLE tmp.tItemShelvingLog;
+*/
\ No newline at end of file
diff --git a/db/versions/11343-silverAsparagus/00-firstScript.sql b/db/versions/11343-silverAsparagus/00-firstScript.sql
new file mode 100644
index 000000000..bcee42eea
--- /dev/null
+++ b/db/versions/11343-silverAsparagus/00-firstScript.sql
@@ -0,0 +1,9 @@
+INSERT INTO salix.ACL (model, property, accessType, principalId)
+ VALUES ('Collection', 'create', 'WRITE', 'productionBoss'),
+ ('Collection', 'upsert', 'WRITE', 'productionBoss'),
+ ('Collection', 'replaceById', 'WRITE', 'productionBoss'),
+ ('Collection', 'updateAll', 'WRITE', 'productionBoss'),
+ ('Collection', 'updateAttributes', 'WRITE', 'productionBoss'),
+ ('Collection', 'deleteById', 'WRITE', 'productionBoss'),
+ ('Collection', 'destroyAll', 'WRITE', 'productionBoss'),
+ ('Collection', 'destroyById', 'WRITE', 'productionBoss');
diff --git a/db/versions/11344-grayBamboo/00-firstScript.sql b/db/versions/11344-grayBamboo/00-firstScript.sql
new file mode 100644
index 000000000..1fbd2a0d8
--- /dev/null
+++ b/db/versions/11344-grayBamboo/00-firstScript.sql
@@ -0,0 +1,3 @@
+UPDATE vn.sale
+ SET originalQuantity = quantity
+ WHERE originalQuantity IS NULL
\ No newline at end of file
diff --git a/db/versions/11251-navyChrysanthemum/01-firstScript.sql b/db/versions/11344-grayBamboo/01-firstScript.sql
similarity index 100%
rename from db/versions/11251-navyChrysanthemum/01-firstScript.sql
rename to db/versions/11344-grayBamboo/01-firstScript.sql
diff --git a/db/versions/11345-salmonEucalyptus/00-firstScript.sql b/db/versions/11345-salmonEucalyptus/00-firstScript.sql
new file mode 100644
index 000000000..ecbc36c40
--- /dev/null
+++ b/db/versions/11345-salmonEucalyptus/00-firstScript.sql
@@ -0,0 +1,2 @@
+ALTER TABLE account.user CHANGE recoverPass recoverPass__ tinyint(3) unsigned NOT NULL DEFAULT 1 COMMENT '@deprecated 2024-11-13';
+ALTER TABLE account.user CHANGE sync sync__ tinyint(4) NOT NULL DEFAULT 0 COMMENT '@deprecated 2024-11-13';
\ No newline at end of file
diff --git a/db/versions/11346-yellowPhormium/00-address.sql b/db/versions/11346-yellowPhormium/00-address.sql
new file mode 100644
index 000000000..f91d0ae9f
--- /dev/null
+++ b/db/versions/11346-yellowPhormium/00-address.sql
@@ -0,0 +1,23 @@
+ALTER TABLE vn.address
+ ADD geoFk int(11) DEFAULT NULL NULL AFTER isLogifloraAllowed,
+ ADD CONSTRAINT address_zoneGeo_FK FOREIGN KEY (geoFk)
+ REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE;
+
+CREATE OR REPLACE TEMPORARY TABLE tmp.tAddressGeo
+ (PRIMARY KEY (id))
+ ENGINE = MEMORY
+ SELECT a.id, p.geoFk
+ FROM vn.address a
+ JOIN vn.town t ON t.provinceFk = a.provinceFk
+ JOIN vn.postCode p ON p.townFk = t.id
+ AND (p.code = a.postalCode OR a.postalCode IS NULL)
+ JOIN vn.zoneGeo zg ON zg.id = p.geoFk
+ GROUP BY a.id
+ ORDER BY (a.city SOUNDS LIKE t.`name`) DESC,
+ (p.code = a.postalCode) DESC;
+
+UPDATE vn.address a
+ JOIN tmp.tAddressGeo tag ON tag.id = a.id
+ SET a.geoFk = tag.geoFk;
+
+DROP TEMPORARY TABLE tmp.tAddressGeo;
diff --git a/db/versions/11346-yellowPhormium/01-client.sql b/db/versions/11346-yellowPhormium/01-client.sql
new file mode 100644
index 000000000..cb6fe41e8
--- /dev/null
+++ b/db/versions/11346-yellowPhormium/01-client.sql
@@ -0,0 +1,26 @@
+ALTER TABLE vn.client
+ CHANGE hasDailyInvoice hasDailyInvoice tinyint(1) DEFAULT 0 NOT NULL
+ COMMENT 'Indica si el cliente requiere facturación diaria por defecto se copiará lo que tenga country.hasDailyInvoice'
+ AFTER recommendedCredit,
+ ADD geoFk int(11) DEFAULT NULL NULL AFTER hasDailyInvoice,
+ ADD CONSTRAINT client_zoneGeo_FK FOREIGN KEY (geoFk)
+ REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE;
+
+CREATE OR REPLACE TEMPORARY TABLE tmp.tClientGeo
+ (PRIMARY KEY (id))
+ ENGINE = MEMORY
+ SELECT c.id, p.geoFk
+ FROM vn.client c
+ JOIN vn.town t ON t.provinceFk = c.provinceFk
+ JOIN vn.postCode p ON p.townFk = t.id
+ AND (p.code = c.postcode OR c.postcode IS NULL)
+ JOIN vn.zoneGeo zg ON zg.id = p.geoFk
+ GROUP BY c.id
+ ORDER BY (c.city SOUNDS LIKE t.`name`) DESC,
+ (p.code = c.postcode) DESC;
+
+UPDATE vn.client c
+ JOIN tmp.tClientGeo tcg ON tcg.id = c.id
+ SET c.geoFk = tcg.geoFk;
+
+DROP TEMPORARY TABLE tmp.tClientGeo;
diff --git a/db/versions/11346-yellowPhormium/02-supplier.sql b/db/versions/11346-yellowPhormium/02-supplier.sql
new file mode 100644
index 000000000..4e866525e
--- /dev/null
+++ b/db/versions/11346-yellowPhormium/02-supplier.sql
@@ -0,0 +1,27 @@
+ALTER TABLE vn.supplier
+ CHANGE companySize companySize enum('small','medium','big') CHARACTER SET utf8mb3
+ COLLATE utf8mb3_general_ci DEFAULT NULL NULL AFTER stamp,
+ ADD geoFk int(11) DEFAULT NULL NULL AFTER companySize,
+ ADD CONSTRAINT supplier_zoneGeo_FK FOREIGN KEY (geoFk)
+ REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE;
+
+CREATE OR REPLACE TEMPORARY TABLE tmp.tSupplierGeo
+ (PRIMARY KEY (id))
+ ENGINE = MEMORY
+ SELECT s.id, p.geoFk
+ FROM vn.supplier s
+ JOIN vn.town t ON t.provinceFk = s.provinceFk
+ JOIN vn.postCode p ON p.townFk = t.id
+ AND (p.code = s.postCode OR s.postCode IS NULL)
+ LEFT JOIN vn.supplierAddress sad ON sad.supplierFk = s.id
+ JOIN vn.zoneGeo zg ON zg.id = p.geoFk
+ GROUP BY s.id
+ ORDER BY (s.city SOUNDS LIKE t.`name`) DESC,
+ (p.code = s.postCode) DESC,
+ (p.code = sad.postalCode) DESC;
+
+UPDATE vn.supplier s
+ JOIN tmp.tSupplierGeo tsg ON tsg.id = s.id
+ SET s.geoFk = tsg.geoFk;
+
+DROP TEMPORARY TABLE tmp.tSupplierGeo;
diff --git a/db/versions/11347-redErica/00-firstScript.sql b/db/versions/11347-redErica/00-firstScript.sql
new file mode 100644
index 000000000..5da1d6096
--- /dev/null
+++ b/db/versions/11347-redErica/00-firstScript.sql
@@ -0,0 +1,9 @@
+DROP TABLE IF EXISTS vn.saySimpleConfig;
+
+CREATE TABLE vn.saySimpleConfig(
+ id INT AUTO_INCREMENT PRIMARY KEY,
+ url VARCHAR(255) NOT NULL,
+ defaultChannel VARCHAR(128)
+);
+
+ALTER TABLE vn.saySimpleCountry MODIFY COLUMN channel VARCHAR(128);
\ No newline at end of file
diff --git a/db/versions/11348-bronzeCamellia/00-firstScript.sql b/db/versions/11348-bronzeCamellia/00-firstScript.sql
new file mode 100644
index 000000000..fa466f1a4
--- /dev/null
+++ b/db/versions/11348-bronzeCamellia/00-firstScript.sql
@@ -0,0 +1,2 @@
+ALTER TABLE vn.clientObservation MODIFY COLUMN observationTypeFk tinyint(3) unsigned DEFAULT 4 NOT NULL;
+UPDATE vn.clientObservation SET observationTypeFk=4 WHERE observationTypeFk=0;
diff --git a/db/versions/11349-azureBamboo/00-firstScript.sql b/db/versions/11349-azureBamboo/00-firstScript.sql
new file mode 100644
index 000000000..09c919b79
--- /dev/null
+++ b/db/versions/11349-azureBamboo/00-firstScript.sql
@@ -0,0 +1,7 @@
+
+
+UPDATE salix.ACL
+ SET principalId = 'deliveryAssistant'
+WHERE model = 'Ticket'
+ AND property = 'updateAttributes'
+ AND principalId = "delivery";
diff --git a/db/versions/11350-silverArborvitae/00-firstScript.sql b/db/versions/11350-silverArborvitae/00-firstScript.sql
new file mode 100644
index 000000000..b5e87133e
--- /dev/null
+++ b/db/versions/11350-silverArborvitae/00-firstScript.sql
@@ -0,0 +1,2 @@
+ALTER TABLE vn.shelvingLog
+ MODIFY COLUMN changedModel enum('Shelving', 'ItemShelving') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT 'Shelving' NOT NULL;
diff --git a/db/versions/11351-bronzeMedeola/00-firstScript.sql b/db/versions/11351-bronzeMedeola/00-firstScript.sql
new file mode 100644
index 000000000..c94447a89
--- /dev/null
+++ b/db/versions/11351-bronzeMedeola/00-firstScript.sql
@@ -0,0 +1,2 @@
+
+ALTER TABLE vn.itemConfig ADD defaultPackingTypeFk VARCHAR(1) DEFAULT 'H' NULL;
diff --git a/db/versions/11352-blackErica/00-firstScript.sql b/db/versions/11352-blackErica/00-firstScript.sql
new file mode 100644
index 000000000..659f50161
--- /dev/null
+++ b/db/versions/11352-blackErica/00-firstScript.sql
@@ -0,0 +1,3 @@
+-- Place your SQL code here
+INSERT IGNORE INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
+ VALUES('InventoryConfig', 'find', 'READ', 'ALLOW', 'ROLE', 'buyer');
\ No newline at end of file
diff --git a/db/versions/11353-wheatCymbidium/00-firstScript.sql b/db/versions/11353-wheatCymbidium/00-firstScript.sql
new file mode 100644
index 000000000..557ffab9e
--- /dev/null
+++ b/db/versions/11353-wheatCymbidium/00-firstScript.sql
@@ -0,0 +1,15 @@
+
+
+USE vn;
+
+INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
+VALUES('RouteAction', 'find', 'READ', 'ALLOW', 'ROLE', 'delivery');
+
+INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
+VALUES('RouteComplement', 'find', 'READ', 'ALLOW', 'ROLE', 'delivery');
+
+INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
+VALUES('RouteComplement', 'create', 'WRITE', 'ALLOW', 'ROLE', 'delivery');
+
+INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
+VALUES('RouteComplement', 'deleteById', 'WRITE', 'ALLOW', 'ROLE', 'delivery');
\ No newline at end of file
diff --git a/db/versions/11354-aquaMastic/00-firstScript.sql b/db/versions/11354-aquaMastic/00-firstScript.sql
new file mode 100644
index 000000000..dda3f4752
--- /dev/null
+++ b/db/versions/11354-aquaMastic/00-firstScript.sql
@@ -0,0 +1,2 @@
+RENAME TABLE vn.workerTimeControlParams TO vn.workerTimeControlParams__;
+ALTER TABLE vn.workerTimeControlParams__ COMMENT='@deprecated 2024-11-19';
\ No newline at end of file
diff --git a/db/versions/11355-pinkMedeola/00-firstScript.sql b/db/versions/11355-pinkMedeola/00-firstScript.sql
new file mode 100644
index 000000000..fc89b386c
--- /dev/null
+++ b/db/versions/11355-pinkMedeola/00-firstScript.sql
@@ -0,0 +1,3 @@
+-- Place your SQL code here
+INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel)
+ VALUES ('https://verdnatura.saysimple.io/start-conversation', 1320);
\ No newline at end of file
diff --git a/db/versions/11357-whiteGerbera/00-firstScript.sql b/db/versions/11357-whiteGerbera/00-firstScript.sql
new file mode 100644
index 000000000..c10ec4d26
--- /dev/null
+++ b/db/versions/11357-whiteGerbera/00-firstScript.sql
@@ -0,0 +1,4 @@
+ALTER TABLE vn.travel ADD IF NOT EXISTS isRaid tinyint(1) DEFAULT 0 NOT NULL COMMENT 'Redada';
+
+ALTER TABLE vn.travel MODIFY COLUMN daysInForward int(10) unsigned DEFAULT NULL
+ COMMENT 'Cuando es una redada, indica el número de días que se añadirán a la fecha de hoy para establecer el landed. NULL si no es una redada';
diff --git a/db/versions/11358-maroonPhormium/00-firstScript.sql b/db/versions/11358-maroonPhormium/00-firstScript.sql
new file mode 100644
index 000000000..88762e5aa
--- /dev/null
+++ b/db/versions/11358-maroonPhormium/00-firstScript.sql
@@ -0,0 +1,51 @@
+
+ ALTER TABLE vn.routeCommission ADD IF NOT EXISTS countryFk mediumint(8) unsigned DEFAULT NULL NULL;
+ ALTER TABLE vn.routeCommission ADD IF NOT EXISTS isKmTruckRate TINYINT(1) DEFAULT NULL NULL;
+
+ ALTER TABLE vn.routeCommission DROP FOREIGN KEY IF EXISTS routeCommission_country_FK;
+ ALTER TABLE vn.routeCommission ADD CONSTRAINT routeCommission_country_FK FOREIGN KEY (countryFk)
+ REFERENCES vn.country(id) ON DELETE RESTRICT ON UPDATE CASCADE;
+
+ CREATE TABLE IF NOT EXISTS vn.workCenterCommission (
+ `workCenterFk` INT(11) NOT NULL,
+ `deliveryManAdjustment` DECIMAL(4,2) DEFAULT NULL
+ COMMENT 'Número de trabajadores para equilibrar los repartidores de diferentes centros.
+ Utilizado en repartidores de grafana',
+ `distributionM3Category1` decimal(5,2) DEFAULT NULL,
+ `distributionM3Category2` decimal(5,2) DEFAULT NULL,
+ `distributionCat4M3` DECIMAL(5,2) DEFAULT NULL
+ COMMENT 'Comisión por gestión de la distribución Cat IV',
+ `distributionCat5M3` DECIMAL(5,2) DEFAULT NULL
+ COMMENT 'Comisión por gestión de la distribución Cat V',
+ PRIMARY KEY (`workCenterFk`),
+ CONSTRAINT `workCenterCommission_workCenterFk` FOREIGN KEY (`workCenterFk`)
+ REFERENCES `workCenter` (`id`) ON UPDATE CASCADE ON DELETE RESTRICT
+ );
+
+ UPDATE vn.routeCommission rc
+ JOIN (SELECT id, countryFk, isKmTruckRate
+ FROM (SELECT r.id, c.countryFk, v.isKmTruckRate
+ FROM vn.route r
+ JOIN vn.routeCommission rc ON rc.routeFk = r.id
+ LEFT JOIN vn.ticket t ON t.routeFk = r.id
+ LEFT JOIN vn.client c ON c.id = t.clientFk
+ LEFT JOIN vn.vehicle v ON v.id = r.vehicleFk
+ WHERE r.created >= '2023-12-01'
+ GROUP BY r.id, c.countryFk
+ ORDER BY r.id, COUNT(*) DESC
+ LIMIT 100000000000
+ )sub
+ GROUP BY id
+ )sub ON sub.id = rc.routeFk
+ SET rc.isKmTruckRate = sub.isKmTruckRate,
+ rc.countryFk = sub.countryFk;
+
+ ALTER TABLE vn.workerDistributionCategory ADD IF NOT EXISTS countryFk mediumint(8) unsigned DEFAULT NULL NULL;
+ ALTER TABLE vn.workerDistributionCategory ADD IF NOT EXISTS isKmTruckRate TINYINT(1) DEFAULT NULL NULL;
+
+ ALTER TABLE vn.workerDistributionCategory DROP FOREIGN KEY IF EXISTS workerDistributionCategory_country_FK;
+ ALTER TABLE vn.workerDistributionCategory ADD CONSTRAINT workerDistributionCategory_country_FK FOREIGN KEY (countryFk)
+ REFERENCES vn.country(id) ON DELETE RESTRICT ON UPDATE CASCADE;
+
+ ALTER TABLE vn.workerDistributionCategory ADD IF NOT EXISTS commissionSplitWorkers INT UNSIGNED NOT NULL DEFAULT 1
+ COMMENT 'Número de enrutadores entr los que se reparte la comsión';
diff --git a/db/versions/11359-navyPaniculata/00-firstScript.sql b/db/versions/11359-navyPaniculata/00-firstScript.sql
new file mode 100644
index 000000000..de057b540
--- /dev/null
+++ b/db/versions/11359-navyPaniculata/00-firstScript.sql
@@ -0,0 +1,8 @@
+DELETE FROM vn.stateI18n
+ WHERE `name` IN ('Billed', 'Facturado', 'Assisted preparation', 'Preparación asistida', 'Shipped', 'Embarcado', 'Stowaway OK', 'Polizón OK');
+
+UPDATE vn.`state` SET nextStateFk = 43
+ WHERE nextStateFk IN (11, 27, 30, 32, 41);
+
+DELETE FROM vn.`state`
+ WHERE code IN ('INVOICED', 'ASSISTED_PREPARATION', 'BOARD', 'OK STOWAWAY', 'PARTIAL_PREPARATION');
\ No newline at end of file
diff --git a/db/versions/11362-limeLilium/00-firstScript.sql b/db/versions/11362-limeLilium/00-firstScript.sql
new file mode 100644
index 000000000..4a7c5b742
--- /dev/null
+++ b/db/versions/11362-limeLilium/00-firstScript.sql
@@ -0,0 +1,4 @@
+
+
+INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
+VALUES('SaleGroup', 'find', 'READ', 'ALLOW', 'ROLE', 'production');
\ No newline at end of file
diff --git a/db/versions/11363-silverCarnation/00-firstScript.sql b/db/versions/11363-silverCarnation/00-firstScript.sql
new file mode 100644
index 000000000..8c2e68ff4
--- /dev/null
+++ b/db/versions/11363-silverCarnation/00-firstScript.sql
@@ -0,0 +1,7 @@
+ALTER TABLE vn.workCenterCommission ADD IF NOT EXISTS deliveryM3Cat4 DECIMAL(5,2) DEFAULT NULL NULL;
+ALTER TABLE vn.workCenterCommission ADD IF NOT EXISTS deliveryM3Cat5 DECIMAL(5,2) DEFAULT NULL NULL;
+
+INSERT IGNORE INTO vn.workCenterCommission (workCenterFk, deliveryM3Cat4, deliveryM3Cat5)
+ VALUES (5,8.0,8.0);
+
+
diff --git a/db/versions/11366-navyBirch/00-firstScript.sql b/db/versions/11366-navyBirch/00-firstScript.sql
new file mode 100644
index 000000000..4d56c13b8
--- /dev/null
+++ b/db/versions/11366-navyBirch/00-firstScript.sql
@@ -0,0 +1,2 @@
+RENAME TABLE vn.itemShelvingLog TO vn.itemShelvingLog__;
+ALTER TABLE vn.itemShelvingLog__ COMMENT='@deprecated 2024-11-26';
diff --git a/db/versions/11367-grayOrchid/00-deprecate.sql b/db/versions/11367-grayOrchid/00-deprecate.sql
new file mode 100644
index 000000000..19e82419e
--- /dev/null
+++ b/db/versions/11367-grayOrchid/00-deprecate.sql
@@ -0,0 +1,7 @@
+ALTER TABLE `vn`.`creditInsurance` DROP COLUMN `creditClassification__`;
+ALTER TABLE `vn`.`worker` DROP COLUMN `isF11Allowed__`;
+ALTER TABLE `util`.`config` DROP COLUMN `dbVersion__`;
+ALTER TABLE `util`.`config` DROP COLUMN `hasTriggersDisabled__`;
+ALTER TABLE `vn`.`agencyMode` DROP COLUMN `showAgencyName__`;
+DROP TABLE `account`.`accountLog__`;
+DROP TABLE `vn`.`silexACL__`;
diff --git a/db/versions/11369-azureChrysanthemum/00-firstScript.sql b/db/versions/11369-azureChrysanthemum/00-firstScript.sql
new file mode 100644
index 000000000..3a86c0c59
--- /dev/null
+++ b/db/versions/11369-azureChrysanthemum/00-firstScript.sql
@@ -0,0 +1,5 @@
+ALTER TABLE vn.duaInvoiceIn DROP KEY IF EXISTS duaFk_UNIQUE;
+ALTER TABLE vn.duaInvoiceIn DROP KEY IF EXISTS duaInvoiceIn_unique;
+ALTER TABLE vn.duaInvoiceIn ADD CONSTRAINT duaInvoiceIn_unique
+ UNIQUE KEY (invoiceInFk);
+
diff --git a/db/versions/11371-salmonRuscus/00-firstScript.sql b/db/versions/11371-salmonRuscus/00-firstScript.sql
new file mode 100644
index 000000000..306ec451e
--- /dev/null
+++ b/db/versions/11371-salmonRuscus/00-firstScript.sql
@@ -0,0 +1 @@
+ALTER TABLE vn.route ADD dated DATE;
\ No newline at end of file
diff --git a/db/versions/11371-salmonRuscus/01-firstScript.sql b/db/versions/11371-salmonRuscus/01-firstScript.sql
new file mode 100644
index 000000000..14c8989d8
--- /dev/null
+++ b/db/versions/11371-salmonRuscus/01-firstScript.sql
@@ -0,0 +1 @@
+UPDATE vn.route SET dated = created;
\ No newline at end of file
diff --git a/db/versions/11371-salmonRuscus/02-firstScript.sql b/db/versions/11371-salmonRuscus/02-firstScript.sql
new file mode 100644
index 000000000..42666b89c
--- /dev/null
+++ b/db/versions/11371-salmonRuscus/02-firstScript.sql
@@ -0,0 +1,2 @@
+ALTER TABLE vn.route
+MODIFY COLUMN dated DATE NOT NULL;
\ No newline at end of file
diff --git a/db/versions/11371-salmonRuscus/03-firstScript.sql b/db/versions/11371-salmonRuscus/03-firstScript.sql
new file mode 100644
index 000000000..b7776d31d
--- /dev/null
+++ b/db/versions/11371-salmonRuscus/03-firstScript.sql
@@ -0,0 +1,2 @@
+ALTER TABLE vn.route
+MODIFY COLUMN created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
\ No newline at end of file
diff --git a/db/versions/11372-azureMedeola/00-firstScript.sql b/db/versions/11372-azureMedeola/00-firstScript.sql
new file mode 100644
index 000000000..53295e9f8
--- /dev/null
+++ b/db/versions/11372-azureMedeola/00-firstScript.sql
@@ -0,0 +1,2 @@
+INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
+ VALUES ('Worker','canCreateAbsenceInPast','WRITE','ALLOW','ROLE','hr');
diff --git a/db/versions/11373-pinkMastic/00-firstScript.sql b/db/versions/11373-pinkMastic/00-firstScript.sql
new file mode 100644
index 000000000..2d7cd4dc7
--- /dev/null
+++ b/db/versions/11373-pinkMastic/00-firstScript.sql
@@ -0,0 +1,107 @@
+INSERT IGNORE INTO vn.saySimpleCountry
+ SET countryFk = 1,
+ channel = '1320';
+
+UPDATE vn.saySimpleConfig
+ SET defaultChannel = '1819';
+
+INSERT IGNORE INTO pbx.prefix (country, prefix) VALUES
+ ('ES', '0034'),
+ ('IT', '0039'),
+ ('DE', '0049'),
+ ('RO', '0040'),
+ ('NL', '0031'),
+ ('BE', '0032'),
+ ('RU', '007'),
+ ('PT', '00351'),
+ ('LT', '00370'),
+ ('UA', '00380'),
+ ('CO', '0057'),
+ ('FI', '00358'),
+ ('EC', '00593'),
+ ('LB', '00961'),
+ ('IL', '00972'),
+ ('TH', '0066'),
+ ('PA', '00507'),
+ ('GB', '0044'),
+ ('FR', '0033'),
+ ('PL', '0048'),
+ ('MX', '0052'),
+ ('MA', '00212'),
+ ('AI', '001268'),
+ ('GH', '00233'),
+ ('SE', '0046'),
+ ('AE', '00971'),
+ ('KE', '00254'),
+ ('AD', '00376'),
+ ('AO', '00244'),
+ ('LU', '00352'),
+ ('BY', '00375'),
+ ('MD', '00373'),
+ ('DK', '0045'),
+ ('ET', '00251'),
+ ('AU', '0061'),
+ ('CA', '0001'),
+ ('CL', '0056'),
+ ('CN', '0086'),
+ ('CR', '00506'),
+ ('GT', '00502'),
+ ('CI', '00225'),
+ ('PE', '0051'),
+ ('LK', '0094'),
+ ('ZA', '0027'),
+ ('TR', '0090'),
+ ('ZW', '00263'),
+ ('MY', '0060'),
+ ('NZ', '0064'),
+ ('IE', '00353'),
+ ('MN', '00976'),
+ ('SV', '00503'),
+ ('ZM', '00260'),
+ ('JP', '0081'),
+ ('RW', '00250'),
+ ('AL', '00355'),
+ ('KW', '00965'),
+ ('SG', '0065'),
+ ('SR', '00597'),
+ ('KR', '0082'),
+ ('US', '0001'),
+ ('RS', '00381'),
+ ('AT', '0043'),
+ ('EG', '0020'),
+ ('LV', '00371'),
+ ('CY', '00357'),
+ ('CZ', '00420'),
+ ('BB', '001246'),
+ ('SK', '00421'),
+ ('IN', '0091'),
+ ('DZ', '00213'),
+ ('BR', '0055'),
+ ('GR', '0030'),
+ ('MC', '00377'),
+ ('SI', '00386'),
+ ('GP', '00590'),
+ ('NO', '0047'),
+ ('CH', '0041'),
+ ('AR', '0054'),
+ ('CU', '0053'),
+ ('GQ', '00240'),
+ ('GN', '00224'),
+ ('HN', '00504'),
+ ('ML', '00223'),
+ ('NI', '00505'),
+ ('PK', '0092'),
+ ('PY', '00595'),
+ ('SN', '00221'),
+ ('UY', '00598'),
+ ('VE', '0058'),
+ ('BG', '00359'),
+ ('GE', '00995'),
+ ('EE', '00372'),
+ ('SA', '00966'),
+ ('RN', '00234'),
+ ('HK', '00852'),
+ ('GI', '00350'),
+ ('CM', '00237'),
+ ('HU', '0036'),
+ ('AM', '00374');
\ No newline at end of file
diff --git a/db/versions/11375-navyIvy/00-firstScript.sql b/db/versions/11375-navyIvy/00-firstScript.sql
new file mode 100644
index 000000000..a90aaf519
--- /dev/null
+++ b/db/versions/11375-navyIvy/00-firstScript.sql
@@ -0,0 +1,2 @@
+ALTER TABLE vn.ticket DROP FOREIGN KEY tickets_zone_fk;
+ALTER TABLE vn.ticket ADD CONSTRAINT tickets_zone_fk FOREIGN KEY (zoneFk) REFERENCES vn.`zone`(id) ON DELETE SET NULL ON UPDATE CASCADE;
diff --git a/db/versions/11376-pinkBamboo/00-firstScript.sql b/db/versions/11376-pinkBamboo/00-firstScript.sql
new file mode 100644
index 000000000..0c1e71a2f
--- /dev/null
+++ b/db/versions/11376-pinkBamboo/00-firstScript.sql
@@ -0,0 +1,2 @@
+ALTER TABLE vn.`zone` MODIFY COLUMN `price` DECIMAL(10,2);
+
diff --git a/db/versions/11377-pinkCarnation/00-firstScript.sql b/db/versions/11377-pinkCarnation/00-firstScript.sql
new file mode 100644
index 000000000..fdbd7e836
--- /dev/null
+++ b/db/versions/11377-pinkCarnation/00-firstScript.sql
@@ -0,0 +1,5 @@
+-- Place your SQL code here
+
+
+ALTER TABLE vn.productionConfig ADD IF NOT EXISTS itemOrderReviewHours int(11) DEFAULT 24 NULL
+COMMENT 'Horas que no se tienen en cuenta para comprobar orden en el almacén, null para desactivar revisión';
diff --git a/db/versions/11378-orangeAsparagus/00-firstScript.sql b/db/versions/11378-orangeAsparagus/00-firstScript.sql
new file mode 100644
index 000000000..a030b7e05
--- /dev/null
+++ b/db/versions/11378-orangeAsparagus/00-firstScript.sql
@@ -0,0 +1 @@
+DROP TABLE vn.quadmindsApiConfig;
diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js
index 0a3892c86..52177b231 100644
--- a/e2e/helpers/selectors.js
+++ b/e2e/helpers/selectors.js
@@ -791,7 +791,7 @@ export default {
},
createRouteView: {
worker: 'vn-route-create vn-worker-autocomplete[ng-model="$ctrl.route.workerFk"]',
- createdDatePicker: 'vn-route-create vn-date-picker[ng-model="$ctrl.route.created"]',
+ createdDatePicker: 'vn-route-create vn-date-picker[ng-model="$ctrl.route.dated"]',
vehicleAuto: 'vn-route-create vn-autocomplete[ng-model="$ctrl.route.vehicleFk"]',
agency: 'vn-route-create vn-autocomplete[ng-model="$ctrl.route.agencyModeFk"]',
description: 'vn-route-create [ng-model="$ctrl.route.description"]',
diff --git a/front/core/components/snackbar/snackbar.js b/front/core/components/snackbar/snackbar.js
index b380c47c3..cce285d14 100644
--- a/front/core/components/snackbar/snackbar.js
+++ b/front/core/components/snackbar/snackbar.js
@@ -27,18 +27,6 @@ export default class Controller extends Component {
setTimeout(() => element.classList.add('shown'), 30);
shape.element = element;
- if (data.additionalData && this.vnToken.token) {
- this.additionalData = data.additionalData;
- let supportButton = document.createElement('i');
- supportButton.setAttribute('class', 'material-icons clickable');
- supportButton.addEventListener('click', () => this.$.supportDialog.show());
- element.appendChild(supportButton);
-
- let buttonIcon = 'support_agent';
- buttonIcon = document.createTextNode(buttonIcon);
- supportButton.appendChild(buttonIcon);
- }
-
if (shape.type)
element.classList.add(shape.type);
diff --git a/front/core/components/support-dialog/index.js b/front/core/components/support-dialog/index.js
index d15c14b4a..82f086184 100644
--- a/front/core/components/support-dialog/index.js
+++ b/front/core/components/support-dialog/index.js
@@ -9,13 +9,6 @@ export default class Controller extends Dialog {
responseHandler(response) {
if (response !== 'accept')
return super.responseHandler(response);
-
- this.$http.post('Ostickets/send-to-support', {
- reason: this.reason,
- additionalData: this.additionalData
- })
- .then(() => super.responseHandler(response))
- .then(() => this.vnApp.showSuccess(this.$t('Email sended!')));
}
}
diff --git a/front/core/services/app.js b/front/core/services/app.js
index dba6e70bf..816167835 100644
--- a/front/core/services/app.js
+++ b/front/core/services/app.js
@@ -70,10 +70,18 @@ export default class App {
if (this.logger.$params.q) {
let tableValue = this.logger.$params.q;
- const q = JSON.parse(tableValue);
- if (typeof q === 'number')
- tableValue = JSON.stringify({id: tableValue});
- newRoute = newRoute.concat(`?table=${tableValue}`);
+ if (Array.isArray(tableValue)) {
+ const [key, param1, param2] = tableValue;
+ const payload = key === 'createForm'
+ ? {[param1]: param2}
+ : {[key]: param1};
+ newRoute += `?${key}=${JSON.stringify(payload)}`;
+ } else {
+ const q = JSON.parse(tableValue);
+ if (typeof q === 'number')
+ tableValue = JSON.stringify({id: tableValue});
+ newRoute = newRoute.concat(`?table=${tableValue}`);
+ }
} else if (!hasId && this.logger.$params.id && newRoute.indexOf(this.logger.$params.id) < 0)
newRoute = newRoute.concat(`${this.logger.$params.id}`);
diff --git a/loopback/common/methods/vn-model/printService.js b/loopback/common/methods/vn-model/printService.js
index 12a6a67cc..ed784229b 100644
--- a/loopback/common/methods/vn-model/printService.js
+++ b/loopback/common/methods/vn-model/printService.js
@@ -2,7 +2,7 @@ const {Report, Email} = require('vn-print');
module.exports = Self => {
Self.printReport = async function(ctx, id, reportName) {
- const args = Object.assign({}, ctx.args);
+ const args = Object.assign({id}, ctx.args);
const params = {lang: ctx.req.getLocale()};
delete args.ctx;
diff --git a/loopback/locale/en.json b/loopback/locale/en.json
index 4ad3f76e2..002a3307e 100644
--- a/loopback/locale/en.json
+++ b/loopback/locale/en.json
@@ -223,7 +223,6 @@
"Shelving not valid": "Shelving not valid",
"printerNotExists": "The printer does not exist",
"There are not picking tickets": "There are not picking tickets",
- "ticketCommercial": "The ticket {{ ticket }} for the salesperson {{ salesMan }} is in preparation. (automatically generated message)",
"This password can only be changed by the user themselves": "This password can only be changed by the user themselves",
"They're not your subordinate": "They're not your subordinate",
"InvoiceIn is already booked": "InvoiceIn is already booked",
@@ -242,8 +241,13 @@
"The maximum height of the wagon is 200cm": "The maximum height of the wagon is 200cm",
"The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line",
"There are tickets for this area, delete them first": "There are tickets for this area, delete them first",
- "ticketLostExpedition": "The ticket [{{ticketId}}]({{{ticketUrl}}}) has the following lost expedition:{{ expeditionId }}",
- "null": "null",
+ "You do not have permission to modify the booked field": "You do not have permission to modify the booked field",
"Invalid or expired verification code": "Invalid or expired verification code",
- "Payment method is required": "Payment method is required"
-}
\ No newline at end of file
+ "ticketLostExpedition": "The ticket [{{ticketId}}]({{{ticketUrl}}}) has the following lost expedition:{{ expeditionId }}",
+ "The raid information is not correct": "The raid information is not correct",
+ "Payment method is required": "Payment method is required",
+ "Sales already moved": "Sales already moved",
+ "Holidays to past days not available": "Holidays to past days not available",
+ "There are tickets to be invoiced": "There are tickets to be invoiced for this zone, please delete them first",
+ "Price cannot be blank": "Price cannot be blank"
+}
diff --git a/loopback/locale/es.json b/loopback/locale/es.json
index 37976c0ea..a81f2574f 100644
--- a/loopback/locale/es.json
+++ b/loopback/locale/es.json
@@ -359,7 +359,6 @@
"This workCenter is already assigned to this agency": "Este centro de trabajo ya está asignado a esta agencia",
"Select ticket or client": "Elija un ticket o un client",
"It was not able to create the invoice": "No se pudo crear la factura",
- "ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)",
"Incoterms and Customs agent are required for a non UEE member": "Se requieren Incoterms y agente de aduanas para un no miembro de la UEE",
"You can not use the same password": "No puedes usar la misma contraseña",
"This PDA is already assigned to another user": "Este PDA ya está asignado a otro usuario",
@@ -386,6 +385,13 @@
"type cannot be blank": "Se debe rellenar el tipo",
"There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero",
"There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén",
+ "You do not have permission to modify the booked field": "No tienes permisos para modificar el campo contabilizada",
"ticketLostExpedition": "El ticket [{{ticketId}}]({{{ticketUrl}}}) tiene la siguiente expedición perdida:{{ expeditionId }}",
- "The web user's email already exists": "El correo del usuario web ya existe"
-}
\ No newline at end of file
+ "The web user's email already exists": "El correo del usuario web ya existe",
+ "Sales already moved": "Ya han sido transferidas",
+ "The raid information is not correct": "La información de la redada no es correcta",
+ "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero",
+ "Price cannot be blank": "Price cannot be blank",
+ "An item type with the same code already exists": "Un tipo con el mismo código ya existe",
+ "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles"
+}
diff --git a/loopback/locale/fr.json b/loopback/locale/fr.json
index 0e876f89c..9941358be 100644
--- a/loopback/locale/fr.json
+++ b/loopback/locale/fr.json
@@ -362,8 +362,9 @@
"The invoices have been created but the PDFs could not be generated": "La facture a été émise mais le PDF n'a pas pu être généré",
"It has been invoiced but the PDF of refund not be generated": "Il a été facturé mais le PDF de remboursement n'a pas été généré",
"Cannot send mail": "Impossible d'envoyer le mail",
- "Original invoice not found": "Facture originale introuvable",
- "The quantity claimed cannot be greater than the quantity of the line": "Le montant réclamé ne peut pas être supérieur au montant de la ligne",
+ "Original invoice not found": "Facture originale introuvable",
+ "The quantity claimed cannot be greater than the quantity of the line": "Le montant réclamé ne peut pas être supérieur au montant de la ligne",
+ "You do not have permission to modify the booked field": "Vous n'avez pas la permission de modifier le champ comptabilisé",
"ticketLostExpedition": "Le ticket [{{ticketId}}]({{{ticketUrl}}}) a l'expédition perdue suivante : {{expeditionId}}",
"The web user's email already exists": "L'email de l'internaute existe déjà"
-}
\ No newline at end of file
+}
diff --git a/loopback/locale/pt.json b/loopback/locale/pt.json
index e08336273..e84b30f3d 100644
--- a/loopback/locale/pt.json
+++ b/loopback/locale/pt.json
@@ -366,4 +366,4 @@
"The quantity claimed cannot be greater than the quantity of the line": "O valor reclamado não pode ser superior ao valor da linha",
"ticketLostExpedition": "O ticket [{{ticketId}}]({{{ticketUrl}}}) tem a seguinte expedição perdida: {{expeditionId}}",
"The web user's email already exists": "O e-mail do utilizador da web já existe."
-}
\ No newline at end of file
+}
diff --git a/modules/account/back/locale/vn-user/en.yml b/modules/account/back/locale/vn-user/en.yml
index 51de7c40d..f911ee1eb 100644
--- a/modules/account/back/locale/vn-user/en.yml
+++ b/modules/account/back/locale/vn-user/en.yml
@@ -15,7 +15,5 @@ columns:
image: image
hasGrant: has grant
userFk: user
- recoverPass: recover password
role: role
- sync: pending sync
lastPassChange: password changed
diff --git a/modules/account/back/locale/vn-user/es.yml b/modules/account/back/locale/vn-user/es.yml
index 85e8bc0dc..c05dd872c 100644
--- a/modules/account/back/locale/vn-user/es.yml
+++ b/modules/account/back/locale/vn-user/es.yml
@@ -15,7 +15,5 @@ columns:
image: imagen
hasGrant: puede delegar
userFk: usuario
- recoverPass: recuperar contraseña
role: rol
- sync: Pendiente de sincronizar
lastPassChange: contraseña modificada
diff --git a/modules/client/back/methods/client/filter.js b/modules/client/back/methods/client/filter.js
index f805c4be9..7df973f19 100644
--- a/modules/client/back/methods/client/filter.js
+++ b/modules/client/back/methods/client/filter.js
@@ -1,4 +1,3 @@
-
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
const buildFilter = require('vn-loopback/util/filter').buildFilter;
const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
diff --git a/modules/client/back/methods/client/summary.js b/modules/client/back/methods/client/summary.js
index 8162096f0..9c1420b61 100644
--- a/modules/client/back/methods/client/summary.js
+++ b/modules/client/back/methods/client/summary.js
@@ -54,7 +54,10 @@ module.exports = Self => {
{
relation: 'country',
scope: {
- fields: ['name']
+ fields: ['id', 'name', 'code'],
+ include: {
+ relation: 'saySimpleCountry',
+ }
}
},
{
diff --git a/modules/client/back/models/client-observation.json b/modules/client/back/models/client-observation.json
index 86351862d..1d906420a 100644
--- a/modules/client/back/models/client-observation.json
+++ b/modules/client/back/models/client-observation.json
@@ -55,7 +55,7 @@
"relation": "user",
"scope": {
"fields": [
- "nickname"
+ "name"
]
}
}
diff --git a/modules/client/front/descriptor/index.html b/modules/client/front/descriptor/index.html
index f2dbd64b6..cecd7ee62 100644
--- a/modules/client/front/descriptor/index.html
+++ b/modules/client/front/descriptor/index.html
@@ -99,7 +99,7 @@
diff --git a/modules/entry/back/locale/entry/en.yml b/modules/entry/back/locale/entry/en.yml
index ab8c0fd1c..6bc2333e6 100644
--- a/modules/entry/back/locale/entry/en.yml
+++ b/modules/entry/back/locale/entry/en.yml
@@ -9,6 +9,7 @@ columns:
notes: notes
isConfirmed: confirmed
isVirtual: virtual
+ isRaid: raid
commission: commission
isOrdered: price3
created: created
diff --git a/modules/entry/back/locale/entry/es.yml b/modules/entry/back/locale/entry/es.yml
index 18bf1ca33..a892b05d2 100644
--- a/modules/entry/back/locale/entry/es.yml
+++ b/modules/entry/back/locale/entry/es.yml
@@ -9,6 +9,7 @@ columns:
notes: notas
isConfirmed: confirmado
isVirtual: virtual
+ isRaid: redada
commission: comisión
isOrdered: pedida
created: creado
diff --git a/modules/entry/back/methods/entry/buyLabelSupplier.js b/modules/entry/back/methods/entry/buyLabelSupplier.js
index 61938f2f8..23806f561 100644
--- a/modules/entry/back/methods/entry/buyLabelSupplier.js
+++ b/modules/entry/back/methods/entry/buyLabelSupplier.js
@@ -9,6 +9,10 @@ module.exports = Self => {
required: true,
description: 'The entry id',
http: {source: 'path'}
+ }, {
+ arg: 'showEntryLines',
+ type: 'boolean',
+ required: false
}
],
returns: [
diff --git a/modules/entry/back/methods/entry/filter.js b/modules/entry/back/methods/entry/filter.js
index a5c236fe4..d7740dd4e 100644
--- a/modules/entry/back/methods/entry/filter.js
+++ b/modules/entry/back/methods/entry/filter.js
@@ -194,6 +194,7 @@ module.exports = Self => {
e.evaNotes observation,
e.isConfirmed,
e.isOrdered,
+ t.isRaid,
t.daysInForward,
e.commission,
e.created,
diff --git a/modules/entry/back/methods/entry/getEntry.js b/modules/entry/back/methods/entry/getEntry.js
index 4612de9a5..92be9a9dd 100644
--- a/modules/entry/back/methods/entry/getEntry.js
+++ b/modules/entry/back/methods/entry/getEntry.js
@@ -49,8 +49,8 @@ module.exports = Self => {
'isReceived',
'isDelivered',
'ref',
- 'daysInForward',
- ],
+ 'isRaid',
+ 'daysInForward'],
include: [
{
relation: 'agency',
diff --git a/modules/entry/back/methods/entry/print.js b/modules/entry/back/methods/entry/labelSupplier.js
similarity index 85%
rename from modules/entry/back/methods/entry/print.js
rename to modules/entry/back/methods/entry/labelSupplier.js
index 5b9de9a69..07107d032 100644
--- a/modules/entry/back/methods/entry/print.js
+++ b/modules/entry/back/methods/entry/labelSupplier.js
@@ -1,6 +1,6 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
- Self.remoteMethodCtx('print', {
+ Self.remoteMethodCtx('labelSupplier', {
description: 'Print stickers of all entries',
accessType: 'READ',
accepts: [
@@ -28,13 +28,13 @@ module.exports = Self => {
}
],
http: {
- path: '/:id/print',
+ path: '/:id/labelSupplier',
verb: 'GET'
},
accessScopes: ['DEFAULT', 'read:multimedia']
});
- Self.print = async function(ctx, id, options) {
+ Self.labelSupplier = async function(ctx, id, options) {
const models = Self.app.models;
const myOptions = {};
if (typeof options == 'object')
@@ -47,8 +47,8 @@ module.exports = Self => {
for (const buy of buys) {
if (buy.stickers < 1) continue;
- ctx.args.id = buy.id;
- const pdfBuffer = await models.Entry.buyLabel(ctx, myOptions);
+ ctx.args = {...ctx.args, id: buy.id, showEntryLines: true};
+ const pdfBuffer = await models.Entry.buyLabelSupplier(ctx, myOptions);
await merger.add(new Uint8Array(pdfBuffer[0]));
}
diff --git a/modules/entry/back/methods/entry/specs/filter.spec.js b/modules/entry/back/methods/entry/specs/filter.spec.js
index 4bf5127b0..b139b00b6 100644
--- a/modules/entry/back/methods/entry/specs/filter.spec.js
+++ b/modules/entry/back/methods/entry/specs/filter.spec.js
@@ -38,8 +38,9 @@ describe('Entry filter()', () => {
};
const result = await models.Entry.filter(ctx, options);
+ const resultWithCurrency = result.filter(entry => entry.currencyFk === 1);
- expect(result.length).toEqual(12);
+ expect(result.length).toEqual(resultWithCurrency.length);
await tx.rollback();
} catch (e) {
@@ -141,18 +142,21 @@ describe('Entry filter()', () => {
it('should return the entry matching the company', async() => {
const tx = await models.Entry.beginTransaction({});
const options = {transaction: tx};
+ const companyFk = 442;
try {
const ctx = {
args: {
- companyFk: 442
+ companyFk
},
req: {accessToken: {userId: 9}}
};
const result = await models.Entry.filter(ctx, options);
- expect(result.length).toEqual(11);
+ const resultWithCurrency = result.filter(entry => entry.companyFk === companyFk);
+
+ expect(result.length).toEqual(resultWithCurrency.length);
await tx.rollback();
} catch (e) {
diff --git a/modules/entry/back/methods/stock-bought/getStockBought.js b/modules/entry/back/methods/stock-bought/getStockBought.js
index c1f99c496..9768b58e7 100644
--- a/modules/entry/back/methods/stock-bought/getStockBought.js
+++ b/modules/entry/back/methods/stock-bought/getStockBought.js
@@ -6,6 +6,9 @@ module.exports = Self => {
arg: 'workerFk',
type: 'number',
description: 'The id for a buyer',
+ }, {
+ arg: 'filter',
+ type: 'object',
},
{
arg: 'dated',
@@ -23,7 +26,7 @@ module.exports = Self => {
}
});
- Self.getStockBought = async(workerFk, dated = Date.vnNew()) => {
+ Self.getStockBought = async(workerFk, filter, dated = Date.vnNew()) => {
const models = Self.app.models;
const today = Date.vnNew();
dated.setHours(0, 0, 0, 0);
@@ -31,7 +34,7 @@ module.exports = Self => {
await models.StockBought.rawSql(`CALL vn.stockBought_calculate(?)`, [dated]);
- const filter = {
+ const defaultFilter = {
where: {dated},
include: [
{
@@ -53,6 +56,6 @@ module.exports = Self => {
if (workerFk) filter.where.workerFk = workerFk;
- return models.StockBought.find(filter);
+ return models.StockBought.find({...filter, ...defaultFilter});
};
};
diff --git a/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js b/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js
index d5f712edf..723e04cb9 100644
--- a/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js
+++ b/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js
@@ -1,3 +1,4 @@
+const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
module.exports = Self => {
Self.remoteMethod('getStockBoughtDetail', {
description: 'Returns the detail of stock bought for a given date and a worker',
@@ -12,6 +13,9 @@ module.exports = Self => {
type: 'string',
description: 'The date to filter',
required: true,
+ }, {
+ arg: 'filter',
+ type: 'object',
}
],
returns: {
@@ -24,11 +28,10 @@ module.exports = Self => {
}
});
- Self.getStockBoughtDetail = async(workerFk, dated) => {
- const models = Self.app.models;
+ Self.getStockBoughtDetail = async(workerFk, dated, filter, options) => {
+ const conn = Self.dataSource.connector;
const myOptions = {};
let tx;
- let result;
if (typeof options == 'object')
Object.assign(myOptions, options);
@@ -39,14 +42,19 @@ module.exports = Self => {
}
try {
- await models.StockBought.rawSql(`CALL vn.item_calculateStock(?)`, [dated], myOptions);
- result = await Self.rawSql(
+ const stmts = [];
+ stmts.push(new ParameterizedSQL(`CALL vn.item_calculateStock(?)`, [dated]));
+
+ const query = new ParameterizedSQL(
`SELECT b.entryFk entryFk,
i.id itemFk,
i.name itemName,
ti.quantity,
- ROUND((ac.conversionCoefficient * (ti.quantity / b.packing) * buy_getVolume(b.id))
- / (vc.trolleyM3 * 1000000),1) volume,
+ ROUND((ac.conversionCoefficient *
+ (ti.quantity / b.packing) *
+ buy_getVolume(b.id)
+ ) / (vc.trolleyM3 * 1000000),
+ 2) volume,
b.packagingFk packagingFk,
b.packing
FROM tmp.item ti
@@ -61,11 +69,17 @@ module.exports = Self => {
JOIN volumeConfig vc
WHERE ic.display
AND w.id = ?`,
- [workerFk], myOptions
+ [workerFk]
);
- await Self.rawSql(`DROP TEMPORARY TABLE tmp.item, tmp.buyUltimate;`, [], myOptions);
+
+ stmts.push(query.merge(conn.makeSuffix(filter)));
+
+ stmts.push(new ParameterizedSQL(`DROP TEMPORARY TABLE tmp.item, tmp.buyUltimate`));
+
+ const sql = ParameterizedSQL.join(stmts, ';');
+ const result = await conn.executeStmt(sql, myOptions);
if (tx) await tx.commit();
- return result;
+ return result[1];
} catch (e) {
await tx.rollback();
throw e;
diff --git a/modules/entry/back/model-config.json b/modules/entry/back/model-config.json
index 5c45b6e07..49c2df2db 100644
--- a/modules/entry/back/model-config.json
+++ b/modules/entry/back/model-config.json
@@ -28,5 +28,8 @@
},
"StockBought": {
"dataSource": "vn"
+ },
+ "InventoryConfig": {
+ "dataSource": "vn"
}
}
diff --git a/modules/entry/back/models/entry.js b/modules/entry/back/models/entry.js
index 8ca79f531..55a23bb0a 100644
--- a/modules/entry/back/models/entry.js
+++ b/modules/entry/back/models/entry.js
@@ -1,3 +1,4 @@
+const UserError = require('vn-loopback/util/user-error');
const LoopBackContext = require('loopback-context');
module.exports = Self => {
require('../methods/entry/filter')(Self);
@@ -11,18 +12,28 @@ module.exports = Self => {
require('../methods/entry/addFromPackaging')(Self);
require('../methods/entry/addFromBuy')(Self);
require('../methods/entry/buyLabel')(Self);
- require('../methods/entry/print')(Self);
+ require('../methods/entry/labelSupplier')(Self);
+ require('../methods/entry/buyLabelSupplier')(Self);
Self.observe('before save', async function(ctx, options) {
if (ctx.isNewInstance) return;
const changes = ctx.data || ctx.instance;
const orgData = ctx.currentInstance;
+ const loopBackContext = LoopBackContext.getCurrentContext();
+ const accessToken = {req: loopBackContext.active};
+ const hasChanges = orgData && changes;
+
+ const isBookedChanged = changes.isBooked !== undefined && orgData.isBooked !== changes.isBooked;
+
+ if (isBookedChanged) {
+ const canEditIsBooked = await Self.app.models.ACL.checkAccessAcl(accessToken, 'Entry', 'isBooked', 'READ');
+ if (!canEditIsBooked)
+ throw new UserError('You do not have permission to modify the booked field');
+ }
const observation = changes.observation || orgData.observation;
- const hasChanges = orgData && changes;
- const observationChanged = hasChanges
- && orgData.observation != observation;
+ const observationChanged = hasChanges && orgData.observation != observation;
if (observationChanged) {
let tx;
@@ -37,8 +48,7 @@ module.exports = Self => {
}
try {
- const loopbackContext = LoopBackContext.getCurrentContext();
- const userId = loopbackContext.active.accessToken.userId;
+ const userId = loopBackContext.active.accessToken.userId;
const id = changes.id || orgData.id;
const entry = await Self.app.models.Entry.findById(id, null, myOptions);
await entry.updateAttribute('observationEditorFk', userId, myOptions);
diff --git a/modules/entry/back/models/inventory-config.json b/modules/entry/back/models/inventory-config.json
new file mode 100644
index 000000000..caa39db88
--- /dev/null
+++ b/modules/entry/back/models/inventory-config.json
@@ -0,0 +1,18 @@
+{
+ "name": "InventoryConfig",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "inventoryConfig"
+ }
+ },
+ "properties": {
+ "id": {
+ "type": "number",
+ "id": true
+ },
+ "supplierFk": {
+ "type": "number"
+ }
+ }
+}
diff --git a/modules/entry/back/models/specs/entry.spec.js b/modules/entry/back/models/specs/entry.spec.js
new file mode 100644
index 000000000..15a8202c4
--- /dev/null
+++ b/modules/entry/back/models/specs/entry.spec.js
@@ -0,0 +1,97 @@
+const {models} = require('vn-loopback/server/server');
+const LoopBackContext = require('loopback-context');
+
+describe('entry_isEditable trigger', () => {
+ const activeCtx = {
+ accessToken: {userId: 5},
+ http: {
+ req: {
+ headers: {origin: 'http://localhost'}
+ }
+ }
+ };
+ const ctx = {req: activeCtx};
+ const entryId = 1;
+ let tx;
+ let options;
+ let entry;
+
+ beforeEach(async() => {
+ spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({active: ctx.req});
+ tx = await models.Entry.beginTransaction({});
+ options = {transaction: tx};
+
+ entry = await models.Entry.findById(entryId, null, options);
+ });
+
+ afterEach(async() => {
+ await tx.rollback();
+ });
+
+ async function prepareEntry(isBooked, typeFk) {
+ let newCreated = Date.vnNew();
+ await entry.updateAttributes({isBooked, typeFk}, options);
+ await entry.updateAttributes({dated: newCreated}, options);
+ }
+
+ it('should throw an error when entry is booked and typeFk is null', async() => {
+ let error;
+ try {
+ await prepareEntry(true, null);
+ } catch (e) {
+ error = e;
+ }
+
+ expect(error.message).toContain(`Entry ${entryId} is not editable`);
+ });
+
+ it('should throw an error when entry is booked and typeFk is not informal', async() => {
+ let error;
+ try {
+ const type = await models.EntryType.findOne({where: {isInformal: false}}, options);
+ await prepareEntry(true, type.code);
+ } catch (e) {
+ error = e;
+ }
+
+ expect(error.message).toContain(`Entry ${entryId} is not editable`);
+ });
+
+ it('should not throw an error when entry is booked and typeFk is informal', async() => {
+ let error;
+ try {
+ const type = await models.EntryType.findOne({where: {isInformal: true}}, options);
+ await prepareEntry(true, type.code);
+ } catch (e) {
+ error = e;
+ }
+
+ expect(error).toBeUndefined();
+ });
+
+ it('should not throw an error when entry is not booked', async() => {
+ let error;
+ try {
+ const type = await models.EntryType.findOne({}, options);
+ await prepareEntry(false, type.code);
+ } catch (e) {
+ error = e;
+ }
+
+ expect(error).toBeUndefined();
+ });
+
+ it('should not throw an error when @isModeInventory is true', async() => {
+ let error;
+ try {
+ await models.Application.rawSql('SET @isModeInventory = TRUE;', null, options);
+ await prepareEntry(true, null);
+ } catch (e) {
+ error = e;
+ } finally {
+ await models.Application.rawSql('SET @isModeInventory = FALSE;', null, options);
+ }
+
+ expect(error).toBeUndefined();
+ });
+});
diff --git a/modules/entry/front/descriptor/index.html b/modules/entry/front/descriptor/index.html
index 40625a4d5..957bcafb5 100644
--- a/modules/entry/front/descriptor/index.html
+++ b/modules/entry/front/descriptor/index.html
@@ -30,7 +30,7 @@
+ ng-if="$ctrl.entryData.travel.isRaid">
diff --git a/modules/entry/front/summary/index.html b/modules/entry/front/summary/index.html
index e58169fa5..db4b034f7 100644
--- a/modules/entry/front/summary/index.html
+++ b/modules/entry/front/summary/index.html
@@ -86,7 +86,7 @@ auto-load="true">
{
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
http: {source: 'query'}
},
+ {
+ arg: 'id',
+ type: 'number',
+ description: 'The invoiceOut id',
+ http: {source: 'query'}
+ },
{
arg: 'search',
type: 'string',
@@ -106,6 +112,8 @@ module.exports = Self => {
return {'i.created': value};
case 'clientFk':
return {'i.clientFk': value};
+ case 'id':
+ return {'i.id': value};
case 'fi':
return {'c.fi': value};
case 'amount':
diff --git a/modules/invoiceOut/front/index.js b/modules/invoiceOut/front/index.js
index a5e51d439..6d58a0a45 100644
--- a/modules/invoiceOut/front/index.js
+++ b/modules/invoiceOut/front/index.js
@@ -1,7 +1,7 @@
export * from './module';
import './main';
-import './summary';
import './descriptor';
import './descriptor-popover';
import './descriptor-menu';
+import './summary';
diff --git a/modules/invoiceOut/front/routes.json b/modules/invoiceOut/front/routes.json
index 7c7495cb9..908df3972 100644
--- a/modules/invoiceOut/front/routes.json
+++ b/modules/invoiceOut/front/routes.json
@@ -34,6 +34,12 @@
"params": {
"invoice-out": "$ctrl.invoiceOut"
}
+ },
+ {
+ "url": "/:id",
+ "state": "invoiceOut.card",
+ "abstract": true,
+ "component": "vn-invoice-out-card"
}
]
}
diff --git a/modules/item/back/locale/item-minimum-quantity/en.yml b/modules/item/back/locale/item-minimum-quantity/en.yml
new file mode 100644
index 000000000..206b1d96b
--- /dev/null
+++ b/modules/item/back/locale/item-minimum-quantity/en.yml
@@ -0,0 +1,5 @@
+name: Minimum Quantity
+columns:
+ ended: Ended
+ code: Code
+ started: Started
\ No newline at end of file
diff --git a/modules/item/back/locale/item-minimum-quantity/es.yml b/modules/item/back/locale/item-minimum-quantity/es.yml
new file mode 100644
index 000000000..68c67eeff
--- /dev/null
+++ b/modules/item/back/locale/item-minimum-quantity/es.yml
@@ -0,0 +1,5 @@
+name: Cantidad Mínima
+columns:
+ ended: Finaliza
+ quantity: Cantidad
+ started: Comienza
diff --git a/modules/item/back/locale/item/en.yml b/modules/item/back/locale/item/en.yml
index ea40fd34b..f5e6fcf9a 100644
--- a/modules/item/back/locale/item/en.yml
+++ b/modules/item/back/locale/item/en.yml
@@ -46,4 +46,4 @@ columns:
itemFk: item
density: density
compression: compression
-
+ minQuantity: min quantity
diff --git a/modules/item/back/locale/item/es.yml b/modules/item/back/locale/item/es.yml
index 973f5e94f..68020d452 100644
--- a/modules/item/back/locale/item/es.yml
+++ b/modules/item/back/locale/item/es.yml
@@ -46,4 +46,4 @@ columns:
itemFk: artículo
density: densidad
compression: compresión
-
+ minQuantity: Cantidad mínima
diff --git a/modules/item/back/methods/item-shelving-sale/filter.js b/modules/item/back/methods/item-shelving-sale/filter.js
index 01a9f1856..edd04b61f 100644
--- a/modules/item/back/methods/item-shelving-sale/filter.js
+++ b/modules/item/back/methods/item-shelving-sale/filter.js
@@ -41,7 +41,7 @@ module.exports = Self => {
u.name
FROM itemShelvingSale iss
LEFT JOIN itemShelving ish ON iss.itemShelvingFk = ish.id
- LEFT JOIN shelving s ON ish.shelvingFk = s.code
+ LEFT JOIN shelving s ON ish.shelvingFk = s.id
LEFT JOIN parking p ON s.parkingFk = p.id
LEFT JOIN account.user u ON u.id = iss.userFk`
);
diff --git a/modules/item/back/methods/item-shelving/getAlternative.js b/modules/item/back/methods/item-shelving/getAlternative.js
index 8108bfa6e..de34739bc 100644
--- a/modules/item/back/methods/item-shelving/getAlternative.js
+++ b/modules/item/back/methods/item-shelving/getAlternative.js
@@ -3,7 +3,7 @@ module.exports = Self => {
description: 'Returns a list of items and possible alternative locations',
accessType: 'READ',
accepts: [{
- arg: 'shelvingFk',
+ arg: 'shelvingCode',
type: 'string',
required: true,
}],
@@ -17,13 +17,21 @@ module.exports = Self => {
}
});
- Self.getAlternative = async(shelvingFk, options) => {
+ Self.getAlternative = async(shelvingCode, options) => {
const models = Self.app.models;
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
+ const shelving = await models.Shelving.findOne({
+ where: {
+ code: shelvingCode
+ }
+ });
+
+ if (!shelving) return [];
+ const {id: shelvingFk} = shelving;
const filterItemShelvings = {
fields: ['id', 'visible', 'itemFk', 'shelvingFk'],
where: {shelvingFk},
@@ -42,7 +50,7 @@ module.exports = Self => {
if (itemShelvings) {
const [alternatives] = await models.ItemShelving.rawSql('CALL vn.itemShelving_getAlternatives(?)',
- [shelvingFk], myOptions
+ [shelvingCode], myOptions
);
return itemShelvings.map(itemShelving => {
const item = itemShelving.item();
diff --git a/modules/item/back/methods/item-shelving/getItemsByReviewOrder.js b/modules/item/back/methods/item-shelving/getItemsByReviewOrder.js
new file mode 100644
index 000000000..7a960a8c8
--- /dev/null
+++ b/modules/item/back/methods/item-shelving/getItemsByReviewOrder.js
@@ -0,0 +1,89 @@
+module.exports = Self => {
+ const models = require('vn-loopback/server/server').models;
+ Self.remoteMethod('getItemsByReviewOrder', {
+ description:
+ 'Get list items if they are ordered by pickingOrder and their created regarding where they will be parked',
+ accessType: 'READ',
+ accepts: [{
+ arg: 'shelving',
+ type: 'string',
+ required: true,
+ description: 'Shelving code'
+ },
+ {
+ arg: 'parking',
+ type: 'string',
+ required: true,
+ description: 'Parking code'
+ },
+ {
+ arg: 'itemFk',
+ type: 'number',
+ description: 'Item id'
+ },
+ ],
+ returns: {
+ type: 'Array',
+ root: true
+ },
+ http: {
+ path: `/getItemsByReviewOrder`,
+ verb: 'GET'
+ }
+ });
+
+ Self.getItemsByReviewOrder = async(shelving, parking, itemFk, options) => {
+ const myOptions = {};
+ if (typeof options == 'object')
+ Object.assign(myOptions, options);
+
+ const config = await models.ProductionConfig.findOne();
+ const hoursToCompare = config['itemOrderReviewHours'];
+ if (!hoursToCompare) return [];
+
+ const parkingItem = await models.Parking.findOne({where: {code: parking}}, myOptions);
+ if (!parkingItem) return [];
+ const pickingOrderToCompare = parkingItem['pickingOrder'];
+
+ const result = await Self.rawSql(`
+ WITH currentItemShelving AS (
+ SELECT is2.created, is2.itemFk, sh.code
+ FROM vn.itemShelving is2
+ JOIN vn.shelving sh ON sh.id = is2.shelvingFk
+ LEFT JOIN vn.parking p ON p.id = sh.parkingFk
+ LEFT JOIN vn.sector s ON s.id = p.sectorFk
+ WHERE sh.code = ? AND (? IS NULL OR is2.itemFk = ?)
+ ),
+ itemShelvings AS (
+ SELECT is2.itemFk, is2.created, sh.code, p.pickingOrder, p.code AS parkingFk
+ FROM vn.itemShelving is2
+ JOIN currentItemShelving ai ON is2.itemFk = ai.itemFk
+ JOIN vn.shelving sh ON sh.id = is2.shelvingFk AND ai.code <> sh.code
+ JOIN vn.parking p ON p.id = sh.parkingFk
+ JOIN vn.sector s ON s.id = p.sectorFk
+ ),
+ parkingDestiny AS (
+ SELECT ? AS pickingOrder
+ )
+ SELECT ish.*,
+ CASE
+ WHEN ish.pickingOrder < d.pickingOrder AND aish.created < ish.created
+ AND ABS(TIMESTAMPDIFF(HOUR, aish.created, ish.created)) > ? THEN "old"
+ WHEN ish.pickingOrder > d.pickingOrder AND aish.created > ish.created
+ AND ABS(TIMESTAMPDIFF(HOUR, aish.created, ish.created)) > ? THEN "new"
+ END AS itemCreated
+ FROM itemShelvings ish
+ JOIN parkingDestiny d ON d.pickingOrder IS NOT NULL
+ JOIN currentItemShelving aish ON ish.itemFk = aish.itemFk
+ WHERE ABS(TIMESTAMPDIFF(HOUR, aish.created, ish.created)) > ?
+ AND (
+ (ish.pickingOrder < d.pickingOrder AND aish.created < ish.created)
+ OR
+ (ish.pickingOrder > d.pickingOrder AND aish.created > ish.created)
+ );
+ `,
+ [shelving, itemFk, itemFk, pickingOrderToCompare,
+ hoursToCompare, hoursToCompare, hoursToCompare, hoursToCompare], myOptions);
+ return result;
+ };
+};
diff --git a/modules/item/back/methods/item-shelving/getListItemNewer.js b/modules/item/back/methods/item-shelving/getListItemNewer.js
index 74c73532a..c806c0a7e 100644
--- a/modules/item/back/methods/item-shelving/getListItemNewer.js
+++ b/modules/item/back/methods/item-shelving/getListItemNewer.js
@@ -45,21 +45,21 @@ module.exports = Self => {
WITH tItemShelving AS(
SELECT is2.itemFk, is2.created, p.sectorFK, is2.id
FROM vn.itemShelving is2
- JOIN vn.shelving sh ON sh.code = is2.shelvingFk
+ JOIN vn.shelving sh ON sh.id = is2.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
JOIN vn.sector s ON s.id = p.sectorFk
JOIN vn.productionConfig pc
- WHERE is2.shelvingFk = ? AND s.code = pc.sectorFromCode
+ WHERE sh.code = ? AND s.code = pc.sectorFromCode
), tItemInSector AS (
- SELECT is2.itemFk, is2.created, is2.shelvingFk
+ SELECT is2.itemFk, is2.created, sh.code
FROM vn.itemShelving is2
- JOIN vn.shelving sh ON sh.code = is2.shelvingFk
+ JOIN vn.shelving sh ON sh.id = is2.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
JOIN vn.sector s ON s.id = p.sectorFk
JOIN vn.productionConfig pc
- WHERE is2.shelvingFk <> ?
+ WHERE sh.code <> ?
AND s.code = pc.sectorFromCode)
- SELECT ti.itemFK, tis.shelvingFk
+ SELECT ti.itemFK, tis.code shelvingFk
FROM tItemShelving ti
JOIN tItemInSector tis ON tis.itemFk = ti.itemFk
JOIN vn.productionConfig pc
diff --git a/modules/item/back/methods/item-shelving/specs/getItemsByReviewOrder.spec.js b/modules/item/back/methods/item-shelving/specs/getItemsByReviewOrder.spec.js
new file mode 100644
index 000000000..8f368b57c
--- /dev/null
+++ b/modules/item/back/methods/item-shelving/specs/getItemsByReviewOrder.spec.js
@@ -0,0 +1,123 @@
+
+const {models} = require('vn-loopback/server/server');
+
+describe('itemShelving getItemsByReviewOrder()', () => {
+ it('should return empty because hoursToReview = 0', async() => {
+ const shelving = 'NBB';
+ const parking = '700-01';
+
+ const tx = await models.Sector.beginTransaction({});
+ const myOptions = {transaction: tx};
+
+ try {
+ const config = await models.ProductionConfig.findOne();
+ await config.updateAttributes({
+ itemOrderReviewHours: null,
+ });
+
+ const result = await models.ItemShelving.getItemsByReviewOrder(shelving, parking, myOptions);
+
+ expect(result.length).toEqual(0);
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+ });
+
+ it('should return an item because you are trying parking a shelving and there is an older item', async() => {
+ const shelving = 'NBB';
+ const parking = 'K-26-2';
+ const itemFk = 1000000;
+
+ const tx = await models.Sector.beginTransaction({});
+ const myOptions = {transaction: tx};
+
+ try {
+ const config = await models.ProductionConfig.findOne();
+ await config.updateAttributes({
+ itemOrderReviewHours: 24,
+ });
+
+ const result = await models.ItemShelving.getItemsByReviewOrder(shelving, parking, itemFk, myOptions);
+
+ expect(result.length).toEqual(1);
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+ });
+
+ it('should return an item because you are trying parking a shelving and there is an newer item', async() => {
+ const shelving = 'NBB';
+ const parking = 'K-26-2';
+ const itemFk = 1000000;
+
+ const tx = await models.Sector.beginTransaction({});
+ const myOptions = {transaction: tx};
+
+ try {
+ const config = await models.ProductionConfig.findOne();
+ await config.updateAttributes({
+ itemOrderReviewHours: 24,
+ });
+
+ const result = await models.ItemShelving.getItemsByReviewOrder(shelving, parking, itemFk, myOptions);
+
+ expect(result.length).toEqual(1);
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+ });
+
+ it('should return a item list because you are trying parking a shelving and there is an newer item', async() => {
+ const shelving = 'NCC';
+ const parking = 'K-26-2';
+ const itemFk = 1000000;
+
+ const tx = await models.Sector.beginTransaction({});
+ const myOptions = {transaction: tx};
+
+ try {
+ const config = await models.ProductionConfig.findOne();
+ await config.updateAttributes({
+ itemOrderReviewHours: 24,
+ });
+
+ const result = await models.ItemShelving.getItemsByReviewOrder(shelving, parking, itemFk, myOptions);
+
+ expect(result.length).toEqual(2);
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+ });
+
+ it('should return empty list because all order is correct', async() => {
+ const shelving = 'NCC';
+ const parking = 'A-01-1';
+ const itemFk = 1000000;
+
+ const tx = await models.Sector.beginTransaction({});
+ const myOptions = {transaction: tx};
+
+ try {
+ const config = await models.ProductionConfig.findOne();
+ await config.updateAttributes({
+ itemOrderReviewHours: 24,
+ });
+
+ const result = await models.ItemShelving.getItemsByReviewOrder(shelving, parking, itemFk, myOptions);
+
+ expect(result.length).toEqual(0);
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+ });
+});
diff --git a/modules/item/back/methods/item-shelving/specs/updateFromSale.spec.js b/modules/item/back/methods/item-shelving/specs/updateFromSale.spec.js
index dfa294000..2cdb5994b 100644
--- a/modules/item/back/methods/item-shelving/specs/updateFromSale.spec.js
+++ b/modules/item/back/methods/item-shelving/specs/updateFromSale.spec.js
@@ -5,7 +5,7 @@ describe('itemShelving updateFromSale()', () => {
const tx = await models.ItemBarcode.beginTransaction({});
const options = {transaction: tx};
const saleFk = 2;
- const filter = {where: {itemFk: 4, shelvingFk: 'HEJ'}
+ const filter = {where: {itemFk: 4, shelvingFk: 12}
};
try {
const {visible: visibleBefore} = await models.ItemShelving.findOne(filter, options);
diff --git a/modules/item/back/methods/item-shelving/specs/upsertItem.spec.js b/modules/item/back/methods/item-shelving/specs/upsertItem.spec.js
index f01cb985d..edc850211 100644
--- a/modules/item/back/methods/item-shelving/specs/upsertItem.spec.js
+++ b/modules/item/back/methods/item-shelving/specs/upsertItem.spec.js
@@ -18,22 +18,31 @@ describe('ItemShelving upsertItem()', () => {
});
it('should add two new records', async() => {
- const shelvingFk = 'GVC';
+ const shelvingCode = 'GVC';
const items = [1, 1, 1, 2];
-
- await models.ItemShelving.upsertItem(ctx, shelvingFk, items, warehouseFk, options);
+ const {id: shelvingFk} = await models.Shelving.findOne({
+ where: {
+ code: shelvingCode
+ }
+ });
+ await models.ItemShelving.upsertItem(ctx, shelvingCode, items, warehouseFk, options);
const itemShelvings = await models.ItemShelving.find({where: {shelvingFk}}, options);
expect(itemShelvings.length).toEqual(2);
});
it('should update the visible items', async() => {
- const shelvingFk = 'GVC';
+ const shelvingCode = 'GVC';
const items = [2, 2];
+ const {id: shelvingFk} = await models.Shelving.findOne({
+ where: {
+ code: shelvingCode
+ }
+ });
const {visible: visibleItemsBefore} = await models.ItemShelving.findOne({
where: {shelvingFk, itemFk: items[0]}
}, options);
- await models.ItemShelving.upsertItem(ctx, shelvingFk, items, warehouseFk, options);
+ await models.ItemShelving.upsertItem(ctx, shelvingCode, items, warehouseFk, options);
const {visible: visibleItemsAfter} = await models.ItemShelving.findOne({
where: {shelvingFk, itemFk: items[0]}
diff --git a/modules/item/back/methods/item/filter.js b/modules/item/back/methods/item/filter.js
index 54dd975a4..a7fde1e6c 100644
--- a/modules/item/back/methods/item/filter.js
+++ b/modules/item/back/methods/item/filter.js
@@ -178,17 +178,18 @@ module.exports = Self => {
i.isFloramondo,
i.recycledPlastic,
i.nonRecycledPlastic,
- pr.name AS producer,
- it.name AS typeName,
- it.workerFk AS buyerFk,
- u.name AS userName,
- ori.code AS origin,
- ic.name AS category,
+ pr.name producer,
+ it.name typeName,
+ it.workerFk buyerFk,
+ u.name userName,
+ ori.code origin,
+ ic.name category,
i.intrastatFk,
- intr.description AS intrastat,
+ intr.description intrastat,
b.grouping,
b.packing,
- lb.landing AS landed
+ lb.landing landed,
+ it.name typeName
FROM item i
LEFT JOIN itemType it ON it.id = i.typeFk
LEFT JOIN itemCategory ic ON ic.id = it.categoryFk
diff --git a/modules/item/back/methods/item/lastEntriesFilter.js b/modules/item/back/methods/item/lastEntriesFilter.js
index 5aafbb4f6..06c60162f 100644
--- a/modules/item/back/methods/item/lastEntriesFilter.js
+++ b/modules/item/back/methods/item/lastEntriesFilter.js
@@ -54,7 +54,8 @@ module.exports = Self => {
b.packageValue,
b.packagingFk ,
s.id AS supplierFk,
- s.name AS supplier
+ s.name AS supplier,
+ b.printedStickers
FROM itemType it
RIGHT JOIN (entry e
LEFT JOIN supplier s ON s.id = e.supplierFk
diff --git a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js
index 2fd30c2ca..d4429e158 100644
--- a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js
+++ b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js
@@ -34,10 +34,31 @@ describe('item lastEntriesFilter()', () => {
const options = {transaction: tx};
try {
- const filter = {where: {itemFk: 1, landed: {between: [minDate, maxDate]}}};
+ const itemFk = 1;
+ const filter = {where: {itemFk, landed: {between: [minDate, maxDate]}}};
const result = await models.Item.lastEntriesFilter(filter, options);
+ const minDateUtc = new Date(minDate).getTime();
+ const maxDateUtc = new Date(maxDate).getTime();
- expect(result.length).toEqual(6);
+ const resultMatch = (
+ await Promise.all(
+ result.map(async item => {
+ const itemRecord = await models.Buy.findOne({
+ fields: ['id'],
+ where: {id: item.id},
+ options,
+ });
+
+ const isItemFkValid = itemRecord?.id === itemFk;
+ const landedDate = new Date(item.landed).getTime();
+ const isLandedValid = landedDate >= minDateUtc && landedDate <= maxDateUtc;
+
+ return isItemFkValid && isLandedValid;
+ })
+ )
+ ).filter(Boolean).length;
+
+ expect(result.length).toEqual(resultMatch);
await tx.rollback();
} catch (e) {
diff --git a/modules/item/back/model-config.json b/modules/item/back/model-config.json
index dcd973524..c386a8eaa 100644
--- a/modules/item/back/model-config.json
+++ b/modules/item/back/model-config.json
@@ -56,9 +56,6 @@
"ItemShelving": {
"dataSource": "vn"
},
- "ItemShelvingLog": {
- "dataSource": "vn"
- },
"ItemShelvingSale": {
"dataSource": "vn"
},
diff --git a/modules/item/back/models/item-shelving-log.json b/modules/item/back/models/item-shelving-log.json
deleted file mode 100644
index f976008f1..000000000
--- a/modules/item/back/models/item-shelving-log.json
+++ /dev/null
@@ -1,52 +0,0 @@
-{
- "name": "ItemShelvingLog",
- "base": "VnModel",
- "mixins": {
- "Loggable": true
- },
- "options": {
- "mysql": {
- "table": "itemShelvingLog"
- }
- },
- "properties": {
- "id": {
- "type": "number",
- "id": true,
- "description": "Identifier"
- },
- "created": {
- "type": "date"
- },
- "shelvingFk": {
- "type": "string"
- },
- "itemFk": {
- "type": "number"
- },
- "visible": {
- "type": "number"
- },
- "accion": {
- "type": "string"
- }
- },
- "relations": {
- "item": {
- "type": "belongsTo",
- "model": "Item",
- "foreignKey": "itemFk"
- },
- "worker": {
- "type": "belongsTo",
- "model": "Worker",
- "foreignKey": "workerFk"
- },
- "shelving": {
- "type": "belongsTo",
- "model": "Shelving",
- "foreignKey": "shelvingFk",
- "primaryKey": "code"
- }
- }
-}
\ No newline at end of file
diff --git a/modules/item/back/models/item-shelving.js b/modules/item/back/models/item-shelving.js
index be72dac37..34e18f23f 100644
--- a/modules/item/back/models/item-shelving.js
+++ b/modules/item/back/models/item-shelving.js
@@ -5,4 +5,5 @@ module.exports = Self => {
require('../methods/item-shelving/getAlternative')(Self);
require('../methods/item-shelving/updateFromSale')(Self);
require('../methods/item-shelving/getListItemNewer')(Self);
+ require('../methods/item-shelving/getItemsByReviewOrder')(Self);
};
diff --git a/modules/item/back/models/item-shelving.json b/modules/item/back/models/item-shelving.json
index 5df3b0703..483d6bf3d 100644
--- a/modules/item/back/models/item-shelving.json
+++ b/modules/item/back/models/item-shelving.json
@@ -41,6 +41,9 @@
},
"available": {
"type": "number"
+ },
+ "buyFk": {
+ "type": "number"
}
},
"relations": {
@@ -57,8 +60,7 @@
"shelving": {
"type": "belongsTo",
"model": "Shelving",
- "foreignKey": "shelvingFk",
- "primaryKey": "code"
+ "foreignKey": "shelvingFk"
}
}
}
\ No newline at end of file
diff --git a/modules/item/back/models/item-type.js b/modules/item/back/models/item-type.js
new file mode 100644
index 000000000..4dc8adfc9
--- /dev/null
+++ b/modules/item/back/models/item-type.js
@@ -0,0 +1,9 @@
+let UserError = require('vn-loopback/util/user-error');
+
+module.exports = Self => {
+ Self.rewriteDbError(function(err) {
+ if (err.code === 'ER_DUP_ENTRY')
+ return new UserError(`An item type with the same code already exists`);
+ return err;
+ });
+};
diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js
index 927f49999..95713f9fb 100644
--- a/modules/monitor/back/methods/sales-monitor/salesFilter.js
+++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js
@@ -88,6 +88,16 @@ module.exports = Self => {
arg: 'alertLevel',
type: 'number',
description: `The alert level of the tickets`
+ },
+ {
+ arg: 'packing',
+ type: 'string',
+ description: `The packing of the items`
+ },
+ {
+ arg: 'countryFk',
+ type: 'number',
+ description: 'The country id filter'
}
],
returns: {
@@ -169,7 +179,7 @@ module.exports = Self => {
stmt = new ParameterizedSQL(`
CREATE OR REPLACE TEMPORARY TABLE tmp.filter
(PRIMARY KEY (id))
- ENGINE = MEMORY
+ ENGINE = InnoDB
SELECT t.id,
t.shipped,
CAST(DATE(t.shipped) AS CHAR) shippedDate,
@@ -182,6 +192,7 @@ module.exports = Self => {
t.totalWithVat,
io.id invoiceOutId,
a.provinceFk,
+ p.countryFk,
p.name province,
w.name warehouse,
am.name agencyMode,
@@ -194,10 +205,18 @@ module.exports = Self => {
u.name userName,
c.salesPersonFk,
c.credit,
+ pm.name payMethod,
z.hour zoneLanding,
z.name zoneName,
z.id zoneFk,
st.classColor,
+ d.id departmentFk,
+ d.name department,
+ (SELECT GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk SEPARATOR ',')
+ FROM sale s
+ JOIN item i ON i.id = s.itemFk
+ WHERE s.ticketFk = t.id
+ ) AS packing,
TIME_FORMAT(t.shipped, '%H:%i') preparationHour,
TIME_FORMAT(z.hour, '%H:%i') theoreticalhour,
TIME_FORMAT(zed.etc, '%H:%i') practicalHour
@@ -211,7 +230,10 @@ module.exports = Self => {
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
LEFT JOIN state st ON st.id = ts.stateFk
LEFT JOIN client c ON c.id = t.clientFk
+ LEFT JOIN payMethod pm ON pm.id = c.payMethodFk
LEFT JOIN worker wk ON wk.id = c.salesPersonFk
+ LEFT JOIN workerDepartment wd ON wd.workerFk = wk.id
+ LEFT JOIN department d ON d.id = wd.departmentFk
LEFT JOIN account.user u ON u.id = wk.id
LEFT JOIN (
SELECT zoneFk,
@@ -342,7 +364,6 @@ module.exports = Self => {
'CHECKED',
'PACKING',
'PACKED',
- 'INVOICED',
'ON_DELIVERY',
'PREPARED',
'WAITING_FOR_PICKUP',
@@ -350,16 +371,15 @@ module.exports = Self => {
'PRINTED_BACK',
'LAST_CALL',
'PREVIOUS_PREPARATION',
- 'ASSISTED_PREPARATION',
- 'BOARD',
'PRINTED STOWAWAY',
- 'OK STOWAWAY',
'HALF_PACKED',
'COOLER_PREPARATION'
]}};
}
case 'agencyModeFk':
case 'warehouseFk':
+ case 'packing':
+ case 'countryFk':
param = `f.${param}`;
return {[param]: value};
}
diff --git a/modules/order/back/methods/order/filter.js b/modules/order/back/methods/order/filter.js
index 758e8065c..2aeb1aac5 100644
--- a/modules/order/back/methods/order/filter.js
+++ b/modules/order/back/methods/order/filter.js
@@ -22,7 +22,7 @@ module.exports = Self => {
}, {
arg: 'from',
type: 'date',
- description: 'The from date'
+ description: 'The from date',
}, {
arg: 'to',
type: 'date',
@@ -76,14 +76,15 @@ module.exports = Self => {
});
Self.filter = async(ctx, filter, options) => {
+ const models = Self.app.models;
const conn = Self.dataSource.connector;
const myOptions = {};
+ const userId = ctx.req.accessToken.userId;
if (typeof options == 'object')
Object.assign(myOptions, options);
const args = ctx.args;
-
// Apply filter by team
const teamMembersId = [];
if (args.myTeam != null) {
@@ -100,9 +101,12 @@ module.exports = Self => {
teamMembersId.push(userId);
}
- if (args && args.myTeam)
+ if (args?.myTeam)
args.teamIds = teamIds;
+ if (args?.to)
+ args.to.setHours(23, 59, 0, 0);
+
const where = buildFilter(args, (param, value) => {
switch (param) {
case 'search':
@@ -150,7 +154,12 @@ module.exports = Self => {
CREATE OR REPLACE TEMPORARY TABLE tmp.filter
(INDEX (id))
ENGINE = MEMORY
- SELECT o.id,
+ WITH wOrderTicket AS(
+ SELECT orderFk,
+ ticketFk
+ FROM orderTicket
+ GROUP BY orderFk
+ )SELECT o.id,
o.total,
o.date_send landed,
o.date_make created,
@@ -198,7 +207,6 @@ module.exports = Self => {
`);
stmt.merge(conn.makeWhere(filter.where));
- stmt.merge(`GROUP BY id`);
stmt.merge(conn.makePagination(filter));
stmts.push(stmt);
stmts.push(`SET SESSION optimizer_search_depth = @_optimizer_search_depth`);
@@ -211,7 +219,6 @@ module.exports = Self => {
const sql = ParameterizedSQL.join(stmts, ';');
const result = await conn.executeStmt(sql, myOptions);
-
return result[ordersIndex];
};
};
diff --git a/modules/route/back/methods/agency-term/filter.js b/modules/route/back/methods/agency-term/filter.js
index 9d1268958..d52d93e95 100644
--- a/modules/route/back/methods/agency-term/filter.js
+++ b/modules/route/back/methods/agency-term/filter.js
@@ -66,9 +66,9 @@ module.exports = Self => {
case 'agencyFk':
return {'agencyFk': value};
case 'from':
- return {'created': {gte: value}};
+ return {'dated': {gte: value}};
case 'to':
- return {'created': {lte: value}};
+ return {'dated': {lte: value}};
}
});
@@ -81,7 +81,7 @@ module.exports = Self => {
`SELECT *
FROM (
SELECT r.id routeFk,
- r.created,
+ r.dated,
r.agencyModeFk,
am.name agencyModeName,
am.agencyFk,
@@ -103,7 +103,7 @@ module.exports = Self => {
LEFT JOIN vn.ticket t ON t.routeFk = r.id
LEFT JOIN vn.supplierAgencyTerm sat ON sat.agencyFk = a.id
LEFT JOIN vn.supplier s ON s.id = sat.supplierFk
- WHERE r.created > DATE_ADD(?, INTERVAL -2 MONTH) AND sat.supplierFk IS NOT NULL
+ WHERE r.dated > DATE_ADD(?, INTERVAL -2 MONTH) AND sat.supplierFk IS NOT NULL
GROUP BY r.id
) a`
, [date]);
diff --git a/modules/route/back/methods/route/downloadCmrsZip.js b/modules/route/back/methods/cmr/downloadZip.js
similarity index 87%
rename from modules/route/back/methods/route/downloadCmrsZip.js
rename to modules/route/back/methods/cmr/downloadZip.js
index 895ff7a16..fcf4ce61c 100644
--- a/modules/route/back/methods/route/downloadCmrsZip.js
+++ b/modules/route/back/methods/cmr/downloadZip.js
@@ -1,7 +1,7 @@
const JSZip = require('jszip');
module.exports = Self => {
- Self.remoteMethodCtx('downloadCmrsZip', {
+ Self.remoteMethodCtx('downloadZip', {
description: 'Download a zip file with multiple cmrs pdfs',
accessType: 'READ',
accepts: [
@@ -27,13 +27,13 @@ module.exports = Self => {
}
],
http: {
- path: '/downloadCmrsZip',
+ path: '/downloadZip',
verb: 'GET'
},
accessScopes: ['DEFAULT', 'read:multimedia']
});
- Self.downloadCmrsZip = async function(ctx, ids, options) {
+ Self.downloadZip = async function(ctx, ids, options) {
const models = Self.app.models;
const myOptions = {};
const zip = new JSZip();
@@ -44,7 +44,7 @@ module.exports = Self => {
const downloadAddZip = async id => {
ctx.args = ctx.args || {};
ctx.args.id = Number(id);
- const [data] = await models.Route.cmr(ctx, myOptions);
+ const [data] = await models.Cmr.print(ctx, myOptions);
zip.file(`${id}.pdf`, data, {binary: true});
};
diff --git a/modules/route/back/methods/route/cmrs.js b/modules/route/back/methods/cmr/filter.js
similarity index 98%
rename from modules/route/back/methods/route/cmrs.js
rename to modules/route/back/methods/cmr/filter.js
index 6f271a4cf..d5a217b1c 100644
--- a/modules/route/back/methods/route/cmrs.js
+++ b/modules/route/back/methods/cmr/filter.js
@@ -3,7 +3,7 @@ const buildFilter = require('vn-loopback/util/filter').buildFilter;
const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
module.exports = Self => {
- Self.remoteMethod('cmrs', {
+ Self.remoteMethod('filter', {
description: 'Returns an array of cmrs',
accessType: 'READ',
accepts: [
@@ -57,12 +57,12 @@ module.exports = Self => {
root: true
},
http: {
- path: `/cmrs`,
+ path: `/filter`,
verb: 'GET'
}
});
- Self.cmrs = async(
+ Self.filter = async(
filter, cmrFk, ticketFk, routeFk, country, clientFk, hasCmrDms, shipped, warehouseFk, options
) => {
const params = {cmrFk, ticketFk, routeFk, country, clientFk, hasCmrDms, warehouseFk, shipped};
diff --git a/modules/route/back/methods/route/cmr.js b/modules/route/back/methods/cmr/print.js
similarity index 82%
rename from modules/route/back/methods/route/cmr.js
rename to modules/route/back/methods/cmr/print.js
index 5033dee2f..2fe807829 100644
--- a/modules/route/back/methods/route/cmr.js
+++ b/modules/route/back/methods/cmr/print.js
@@ -1,6 +1,6 @@
module.exports = Self => {
- Self.remoteMethodCtx('cmr', {
- description: 'Returns the cmr',
+ Self.remoteMethodCtx('print', {
+ description: 'Returns the cmr pdf',
accessType: 'READ',
accepts: [
{
@@ -27,11 +27,11 @@ module.exports = Self => {
}
],
http: {
- path: '/:id/cmr',
+ path: '/:id/print',
verb: 'GET'
},
accessScopes: ['DEFAULT', 'read:multimedia']
});
- Self.cmr = (ctx, id) => Self.printReport(ctx, id, 'cmr');
+ Self.print = (ctx, id) => Self.printReport(ctx, id, 'cmr');
};
diff --git a/modules/route/back/methods/route/specs/downloadCmrsZip.spec.js b/modules/route/back/methods/cmr/specs/downloadZip.spec.js
similarity index 83%
rename from modules/route/back/methods/route/specs/downloadCmrsZip.spec.js
rename to modules/route/back/methods/cmr/specs/downloadZip.spec.js
index 7312a5d44..74870038f 100644
--- a/modules/route/back/methods/route/specs/downloadCmrsZip.spec.js
+++ b/modules/route/back/methods/cmr/specs/downloadZip.spec.js
@@ -1,6 +1,6 @@
const models = require('vn-loopback/server/server').models;
-describe('route downloadCmrsZip()', () => {
+describe('route downloadZip()', () => {
it('should create a zip file with the given cmr ids', async() => {
const tx = await models.Route.beginTransaction({});
const ctx = {
@@ -13,7 +13,7 @@ describe('route downloadCmrsZip()', () => {
};
let cmrs = '1,2';
try {
- const stream = await models.Route.downloadCmrsZip(ctx, cmrs);
+ const stream = await models.Cmr.downloadZip(ctx, cmrs);
expect(stream[0]).toBeDefined();
await tx.rollback();
diff --git a/modules/route/back/methods/route/clone.js b/modules/route/back/methods/route/clone.js
index d56118e08..c5c4d846a 100644
--- a/modules/route/back/methods/route/clone.js
+++ b/modules/route/back/methods/route/clone.js
@@ -10,10 +10,10 @@ module.exports = Self => {
description: 'The routes ids to clone'
},
{
- arg: 'created',
+ arg: 'dated',
type: 'date',
required: true,
- description: 'The created date for all routes'
+ description: 'The date for all routes'
}
],
returns: {
@@ -26,7 +26,7 @@ module.exports = Self => {
}
});
- Self.clone = async(ids, created) => {
+ Self.clone = async(ids, dated) => {
const tx = await Self.beginTransaction({});
try {
const options = {transaction: tx};
@@ -39,7 +39,7 @@ module.exports = Self => {
throw new Error(`The amount of routes found don't match`);
const routes = originalRoutes.map(route => {
- route.created = created;
+ route.dated = dated;
return route;
});
diff --git a/modules/route/back/methods/route/filter.js b/modules/route/back/methods/route/filter.js
index 925927cc8..70bf7ba67 100644
--- a/modules/route/back/methods/route/filter.js
+++ b/modules/route/back/methods/route/filter.js
@@ -93,9 +93,9 @@ module.exports = Self => {
case 'search':
return {'id': value};
case 'from':
- return {'created': {gte: value}};
+ return {'dated': {gte: value}};
case 'to':
- return {'created': {lte: value}};
+ return {'dated': {lte: value}};
case 'description':
return {'description': {like: `%${value}%`}};
case 'isOk':
@@ -119,7 +119,7 @@ module.exports = Self => {
SELECT
r.id,
r.workerFk,
- r.created,
+ r.dated,
r.vehicleFk,
r.agencyModeFk,
r.time,
diff --git a/modules/route/back/methods/route/getByWorker.js b/modules/route/back/methods/route/getByWorker.js
index 5d1881c20..92086bba0 100644
--- a/modules/route/back/methods/route/getByWorker.js
+++ b/modules/route/back/methods/route/getByWorker.js
@@ -46,14 +46,14 @@ module.exports = Self => {
and: [
{
or: [
- {'created': currentDate},
- {'created': nextDay}
+ {'dated': currentDate},
+ {'dated': nextDay}
]
}
]
},
order: [
- 'created ASC',
+ 'dated ASC',
'time ASC',
'agencyName ASC'
]
diff --git a/modules/route/back/methods/route/getSuggestedTickets.js b/modules/route/back/methods/route/getSuggestedTickets.js
index e1b90d359..daaff2bc8 100644
--- a/modules/route/back/methods/route/getSuggestedTickets.js
+++ b/modules/route/back/methods/route/getSuggestedTickets.js
@@ -43,10 +43,10 @@ module.exports = Self => {
for (let zoneAgencyMode of zoneAgencyModes)
zoneIds.push(zoneAgencyMode.zoneFk);
- const minDate = new Date(route.created);
+ const minDate = new Date(route.dated);
minDate.setHours(0, 0, 0, 0);
- const maxDate = new Date(route.created);
+ const maxDate = new Date(route.dated);
maxDate.setHours(23, 59, 59, 59);
let tickets = await Self.app.models.Ticket.find({
diff --git a/modules/route/back/methods/route/insertTicket.js b/modules/route/back/methods/route/insertTicket.js
index 4ac8bad1a..41c910116 100644
--- a/modules/route/back/methods/route/insertTicket.js
+++ b/modules/route/back/methods/route/insertTicket.js
@@ -42,10 +42,10 @@ module.exports = Self => {
try {
const route = await models.Route.findById(routeId, null, myOptions);
- const minDate = new Date(route.created);
+ const minDate = new Date(route.dated);
minDate.setHours(0, 0, 0, 0);
- const maxDate = new Date(route.created);
+ const maxDate = new Date(route.dated);
maxDate.setHours(23, 59, 59, 59);
const ticket = await models.Ticket.findOne({
where: {
diff --git a/modules/route/back/model-config.json b/modules/route/back/model-config.json
index ccae87bd9..fb1c5d7fd 100644
--- a/modules/route/back/model-config.json
+++ b/modules/route/back/model-config.json
@@ -5,6 +5,9 @@
"AgencyTermConfig": {
"dataSource": "vn"
},
+ "Cmr": {
+ "dataSource": "vn"
+ },
"DeliveryPoint": {
"dataSource": "vn"
},
@@ -20,6 +23,12 @@
"Route": {
"dataSource": "vn"
},
+ "RouteAction": {
+ "dataSource": "vn"
+ },
+ "RouteComplement": {
+ "dataSource": "vn"
+ },
"RouteLog": {
"dataSource": "vn"
},
@@ -29,4 +38,4 @@
"RoutesMonitor": {
"dataSource": "vn"
}
-}
+}
\ No newline at end of file
diff --git a/modules/route/back/models/cmr.js b/modules/route/back/models/cmr.js
new file mode 100644
index 000000000..f9a153d52
--- /dev/null
+++ b/modules/route/back/models/cmr.js
@@ -0,0 +1,5 @@
+module.exports = Self => {
+ require('../methods/cmr/print')(Self);
+ require('../methods/cmr/filter')(Self);
+ require('../methods/cmr/downloadZip')(Self);
+};
diff --git a/modules/route/back/models/route.js b/modules/route/back/models/route.js
index 242623d6e..cd8685cec 100644
--- a/modules/route/back/models/route.js
+++ b/modules/route/back/models/route.js
@@ -14,10 +14,6 @@ module.exports = Self => {
require('../methods/route/driverRouteEmail')(Self);
require('../methods/route/sendSms')(Self);
require('../methods/route/downloadZip')(Self);
- require('../methods/route/cmr')(Self);
- require('../methods/route/cmrs')(Self);
- require('../methods/route/downloadCmrsZip')(Self);
- require('../methods/route/cmrEmail')(Self);
require('../methods/route/getExpeditionSummary')(Self);
require('../methods/route/getByWorker')(Self);
};
diff --git a/modules/route/back/models/route.json b/modules/route/back/models/route.json
index f8be9023c..8f4eab761 100644
--- a/modules/route/back/models/route.json
+++ b/modules/route/back/models/route.json
@@ -15,7 +15,7 @@
"id": true,
"description": "Identifier"
},
- "created": {
+ "dated": {
"type": "date"
},
"time": {
diff --git a/modules/route/back/models/routeAction.json b/modules/route/back/models/routeAction.json
new file mode 100644
index 000000000..88f7a8226
--- /dev/null
+++ b/modules/route/back/models/routeAction.json
@@ -0,0 +1,30 @@
+{
+ "name": "RouteAction",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
+ "options": {
+ "mysql": {
+ "table": "routeAction"
+ }
+ },
+ "properties": {
+ "id": {
+ "type": "number",
+ "id": true,
+ "description": "Identifier"
+ },
+ "name": {
+ "type": "string",
+ "required": true
+ },
+ "price": {
+ "type": "number"
+ },
+ "isMainlineDelivered": {
+ "type": "boolean",
+ "required": true
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/route/back/models/routeComplement.json b/modules/route/back/models/routeComplement.json
new file mode 100644
index 000000000..e2086f78d
--- /dev/null
+++ b/modules/route/back/models/routeComplement.json
@@ -0,0 +1,37 @@
+{
+ "name": "RouteComplement",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
+ "options": {
+ "mysql": {
+ "table": "routeComplement"
+ }
+ },
+ "properties": {
+ "id": {
+ "type": "number",
+ "id": true,
+ "description": "Identifier"
+ },
+ "dated": {
+ "type": "date"
+ },
+ "price": {
+ "type": "number"
+ }
+ },
+ "relations": {
+ "worker": {
+ "type": "belongsTo",
+ "model": "Worker",
+ "foreignKey": "workerFk"
+ },
+ "routeAction": {
+ "type": "belongsTo",
+ "model": "RouteAction",
+ "foreignKey": "routeActionFk"
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/route/front/descriptor/index.html b/modules/route/front/descriptor/index.html
index 4e7e99f1a..0079168a6 100644
--- a/modules/route/front/descriptor/index.html
+++ b/modules/route/front/descriptor/index.html
@@ -32,7 +32,7 @@
+ value="{{$ctrl.route.dated | date: 'dd/MM/yyyy'}}">
+ value="{{$ctrl.summary.route.dated | date: 'dd/MM/yyyy'}}">
diff --git a/modules/shelving/back/models/shelving.json b/modules/shelving/back/models/shelving.json
index 46fce31e8..84e260b9e 100644
--- a/modules/shelving/back/models/shelving.json
+++ b/modules/shelving/back/models/shelving.json
@@ -1,6 +1,6 @@
{
"name": "Shelving",
- "base": "VnModel",
+ "base": "VnModel",
"mixins": {
"Loggable": true
},
@@ -44,6 +44,11 @@
"type": "belongsTo",
"model": "Worker",
"foreignKey": "id"
+ },
+ "itemShelving": {
+ "type": "hasMany",
+ "model": "ItemShelving",
+ "foreignKey": "shelvingFk"
}
}
-}
+}
\ No newline at end of file
diff --git a/modules/supplier/back/methods/supplier/getSummary.js b/modules/supplier/back/methods/supplier/getSummary.js
index 67767e7b4..8fcaaa53f 100644
--- a/modules/supplier/back/methods/supplier/getSummary.js
+++ b/modules/supplier/back/methods/supplier/getSummary.js
@@ -43,7 +43,8 @@ module.exports = Self => {
'sageWithholdingFk',
'workerFk',
'supplierActivityFk',
- 'healthRegister'
+ 'healthRegister',
+ 'companySize'
],
include: [
{
diff --git a/modules/supplier/back/methods/supplier/getWithPackaging.js b/modules/supplier/back/methods/supplier/getWithPackaging.js
index 07e563412..41b080964 100644
--- a/modules/supplier/back/methods/supplier/getWithPackaging.js
+++ b/modules/supplier/back/methods/supplier/getWithPackaging.js
@@ -15,7 +15,7 @@ module.exports = Self => {
Self.getWithPackaging = async options => {
const models = Self.app.models;
const myOptions = {};
- const oneYearAgo = new Date();
+ const oneYearAgo = Date.vnNew();
oneYearAgo.setFullYear(oneYearAgo.getFullYear() - 1);
if (typeof options == 'object')
diff --git a/modules/supplier/back/methods/supplier/specs/getWithPackaging.spec.js b/modules/supplier/back/methods/supplier/specs/getWithPackaging.spec.js
index bd30d7437..b6a780a10 100644
--- a/modules/supplier/back/methods/supplier/specs/getWithPackaging.spec.js
+++ b/modules/supplier/back/methods/supplier/specs/getWithPackaging.spec.js
@@ -1,26 +1,12 @@
const {models} = require('vn-loopback/server/server');
describe('Supplier getWithPackaging()', () => {
+ beforeAll.mockLoopBackContext();
it('should return a list of suppliers with an entry of type packaging', async() => {
- const typeFk = 'packaging';
-
const tx = await models.Supplier.beginTransaction({});
const myOptions = {transaction: tx};
try {
- const entry = await models.Entry.findOne(
- {
- where: {
- id: 1
- },
- myOptions
- });
-
- await entry.updateAttributes({
- typeFk: typeFk,
- created: new Date()
- });
-
const result = await models.Supplier.getWithPackaging(myOptions);
expect(result.length).toEqual(1);
diff --git a/modules/supplier/back/models/supplier.json b/modules/supplier/back/models/supplier.json
index 90b266ba9..b79a6b80d 100644
--- a/modules/supplier/back/models/supplier.json
+++ b/modules/supplier/back/models/supplier.json
@@ -113,6 +113,9 @@
},
"isVies": {
"type": "boolean"
+ },
+ "companySize": {
+ "type": "string"
}
},
"relations": {
diff --git a/modules/ticket/back/methods/expedition/deleteExpeditions.js b/modules/ticket/back/methods/expedition/deleteExpeditions.js
index 75993a485..267811d25 100644
--- a/modules/ticket/back/methods/expedition/deleteExpeditions.js
+++ b/modules/ticket/back/methods/expedition/deleteExpeditions.js
@@ -52,7 +52,8 @@ module.exports = Self => {
const deletedExpedition = await models.Expedition.destroyById(expeditionId);
deletedExpeditions.push(deletedExpedition);
- } catch (e) {
+ } catch (error) {
+ console.error('error: ', error);
notDeletedExpeditions.push(expeditionId);
}
}
diff --git a/modules/ticket/back/methods/expedition/filter.js b/modules/ticket/back/methods/expedition/filter.js
index 43be14349..bd2012668 100644
--- a/modules/ticket/back/methods/expedition/filter.js
+++ b/modules/ticket/back/methods/expedition/filter.js
@@ -49,7 +49,8 @@ module.exports = Self => {
es.workerFk expeditionScanWorkerFk,
su.name scannerUserName,
es.scanned,
- est.description state
+ est.description state,
+ de.longName
FROM vn.expedition e
LEFT JOIN vn.expeditionStateType est ON est.id = e.stateTypeFk
INNER JOIN vn.item i1 ON i1.id = e.freightItemFk
@@ -59,6 +60,7 @@ module.exports = Self => {
LEFT JOIN account.user u ON u.id = e.workerFk
LEFT JOIN vn.expeditionScan es ON es.expeditionFk = e.id
LEFT JOIN account.user su ON su.id = es.workerFk
+ LEFT JOIN dipole.expedition_PrintOut de ON de.expeditionFk = e.id
) e
`);
stmt.merge(conn.makeWhere(filter.where));
diff --git a/modules/ticket/back/methods/expedition/moveExpeditions.js b/modules/ticket/back/methods/expedition/moveExpeditions.js
index cef35ab86..3ad41897f 100644
--- a/modules/ticket/back/methods/expedition/moveExpeditions.js
+++ b/modules/ticket/back/methods/expedition/moveExpeditions.js
@@ -13,7 +13,8 @@ module.exports = Self => {
{
arg: 'landed',
type: 'date',
- description: `The landing date`
+ description: `The landing date`,
+ required: true
},
{
arg: 'warehouseId',
@@ -79,11 +80,17 @@ module.exports = Self => {
const expeditionUpdated = expeditionToUpdate.updateAttribute('ticketFk', ticket.id, myOptions);
promises.push(expeditionUpdated);
}
-
await Promise.all(promises);
+ await models.Ticket.updateAll({id: ticket.id}, {packages: promises.length}, myOptions);
+ const state = await models.State.findOne({where: {code: 'PACKED'}});
+
+ await models.Ticket.state(ctx, {
+ ticketFk: ticket.id,
+ stateFk: state.id,
+ userFk: ctx.req.accessToken.userId
+ }, myOptions);
if (tx) await tx.commit();
-
return ticket;
} catch (e) {
if (tx) await tx.rollback();
diff --git a/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js b/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js
index c1c7c2c12..0edae9c6a 100644
--- a/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js
+++ b/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js
@@ -17,14 +17,55 @@ describe('ticket moveExpeditions()', () => {
agencyModeId: 1,
routeId: null,
expeditionIds: [1, 2]
-
};
-
+ const newestTicketIdInFixtures = await models.Ticket.findOne({
+ order: 'id DESC'
+ }, options);
const ticket = await models.Expedition.moveExpeditions(ctx, options);
- const newestTicketIdInFixtures = 27;
+ expect(ticket.id).toBeGreaterThan(newestTicketIdInFixtures.id);
- expect(ticket.id).toBeGreaterThan(newestTicketIdInFixtures);
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+ });
+
+ it('should move expeditions to a new ticket, set state to PACKED, and update packages count correctly', async() => {
+ const tx = await models.Expedition.beginTransaction({});
+ const myCtx = ctx;
+
+ try {
+ const options = {transaction: tx};
+ myCtx.args = {
+ clientId: 1101,
+ landed: Date.vnNew(),
+ warehouseId: 1,
+ addressId: 121,
+ agencyModeId: 1,
+ routeId: null,
+ expeditionIds: [1, 2]
+ };
+
+ const newestTicketIdInFixtures = await models.Ticket.findOne({
+ order: 'id DESC'
+ }, options);
+ const ticket = await models.Expedition.moveExpeditions(myCtx, options);
+
+ expect(ticket.id).toBeGreaterThan(newestTicketIdInFixtures.id);
+
+ const updatedTicket = await models.Ticket.findById(ticket.id, null, options);
+ const packedState = await models.State.findOne({where: {code: 'PACKED'}}, options);
+
+ const state = await models.TicketState.findOne({where: {ticketFk: ticket.id}}, options);
+
+ expect(state.stateFk).toBe(packedState.id);
+ expect(state.userFk).toBe(myCtx.req.accessToken.userId);
+
+ const expectedPackagesCount = myCtx.args.expeditionIds.length;
+
+ expect(updatedTicket.$packages).toBe(expectedPackagesCount);
await tx.rollback();
} catch (e) {
@@ -33,4 +74,3 @@ describe('ticket moveExpeditions()', () => {
}
});
});
-
diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js
index d3e53c702..c61223470 100644
--- a/modules/ticket/back/methods/ticket/filter.js
+++ b/modules/ticket/back/methods/ticket/filter.js
@@ -265,7 +265,8 @@ module.exports = Self => {
FROM sale s2
JOIN item i2 ON i2.id = s2.itemFk
WHERE s2.ticketFk = t.id
- ) AS packing
+ ) AS packing,
+ c.credit
FROM ticket t
LEFT JOIN invoiceOut io ON t.refFk = io.ref
LEFT JOIN zone z ON z.id = t.zoneFk
diff --git a/modules/ticket/back/methods/ticket/getSales.js b/modules/ticket/back/methods/ticket/getSales.js
index e721d90ae..5b2288d31 100644
--- a/modules/ticket/back/methods/ticket/getSales.js
+++ b/modules/ticket/back/methods/ticket/getSales.js
@@ -37,6 +37,7 @@ module.exports = Self => {
'name',
'subName',
'itemPackingTypeFk',
+ 'size',
'tag5',
'value5',
'tag6',
diff --git a/modules/ticket/back/methods/ticket/saveCmr.js b/modules/ticket/back/methods/ticket/saveCmr.js
index 339ac1e38..5ac748751 100644
--- a/modules/ticket/back/methods/ticket/saveCmr.js
+++ b/modules/ticket/back/methods/ticket/saveCmr.js
@@ -41,7 +41,7 @@ module.exports = Self => {
for (const ticketId of tickets) {
const ticket = await models.Ticket.findById(ticketId, null, myOptions);
- if (ticket.cmrFk) {
+ if (ticket.$cmrFk) {
const hasDmsCmr = await Self.rawSql(`
SELECT d.id
FROM ticketDms td
@@ -53,8 +53,7 @@ module.exports = Self => {
if (hasDmsCmr.length)
throw new UserError('This ticket already has a cmr saved');
- ctx.args.id = ticket.cmrFk;
- const response = await models.Route.cmr(ctx, myOptions);
+ const response = await models.Cmr.print(ctx, ticket.$cmrFk, myOptions);
const pdfStream = Readable.from(Buffer.from(response[0]));
const data = {
workerFk: ctx.req.accessToken.userId,
diff --git a/modules/ticket/back/methods/ticket/saveSign.js b/modules/ticket/back/methods/ticket/saveSign.js
index bc0da686c..ac2a7bc66 100644
--- a/modules/ticket/back/methods/ticket/saveSign.js
+++ b/modules/ticket/back/methods/ticket/saveSign.js
@@ -151,7 +151,7 @@ module.exports = Self => {
await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [ticketId, stateCode], myOptions);
- if (ticket?.address()?.province()?.country()?.code != 'ES' && ticket.cmrFk) {
+ if (ticket?.address()?.province()?.country()?.code != 'ES' && ticket.$cmrFk) {
await models.Ticket.saveCmr(ctx, [ticketId], myOptions);
externalTickets.push(ticketId);
}
@@ -161,6 +161,6 @@ module.exports = Self => {
if (tx) await tx.rollback();
throw e;
}
- await models.Route.cmrEmail(ctx, externalTickets);
+ await models.Ticket.sendCmrEmail(ctx, externalTickets);
};
};
diff --git a/modules/route/back/methods/route/cmrEmail.js b/modules/ticket/back/methods/ticket/sendCmrEmail.js
similarity index 92%
rename from modules/route/back/methods/route/cmrEmail.js
rename to modules/ticket/back/methods/ticket/sendCmrEmail.js
index 0c4cc5061..27f22ca14 100644
--- a/modules/route/back/methods/route/cmrEmail.js
+++ b/modules/ticket/back/methods/ticket/sendCmrEmail.js
@@ -2,7 +2,7 @@ const {Email} = require('vn-print');
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
- Self.remoteMethodCtx('cmrEmail', {
+ Self.remoteMethodCtx('sendCmrEmail', {
description: 'Sends the email with an cmr attached PDF',
accessType: 'WRITE',
accepts: [
@@ -14,12 +14,12 @@ module.exports = Self => {
}
],
http: {
- path: '/cmrEmail',
+ path: '/sendCmrEmail',
verb: 'POST'
}
});
- Self.cmrEmail = async function(ctx, tickets, options) {
+ Self.sendCmrEmail = async function(ctx, tickets, options) {
const models = Self.app.models;
const myOptions = {};
let tx;
@@ -70,7 +70,7 @@ module.exports = Self => {
await email.send({
overrideAttachments: true,
attachments: [{
- filename: `${ticket.cmrFk}.pdf`,
+ filename: `${ticket.$cmrFk}.pdf`,
content: response[0]
}]
});
diff --git a/modules/ticket/back/methods/ticket/transferSales.js b/modules/ticket/back/methods/ticket/transferSales.js
index 5f5fdde67..580a8e1f7 100644
--- a/modules/ticket/back/methods/ticket/transferSales.js
+++ b/modules/ticket/back/methods/ticket/transferSales.js
@@ -81,6 +81,10 @@ module.exports = Self => {
if (ticketId != id && hasClaimedSales)
throw new UserError(`Can't transfer claimed sales`);
+ const missingSales = sales.some(({id}) => !map.has(id));
+ if (missingSales)
+ throw new UserError($t('Sales already moved'));
+
for (const sale of sales) {
const originalSale = map.get(sale.id);
if (sale.quantity == originalSale?.quantity) {
diff --git a/modules/ticket/back/models/saleGroup.json b/modules/ticket/back/models/saleGroup.json
index aa78b4167..5f432b514 100644
--- a/modules/ticket/back/models/saleGroup.json
+++ b/modules/ticket/back/models/saleGroup.json
@@ -29,6 +29,11 @@
"type": "belongsTo",
"model": "Parking",
"foreignKey": "parkingFk"
+ },
+ "state": {
+ "type": "belongsTo",
+ "model": "State",
+ "foreignKey": "stateFk"
}
}
-}
+}
\ No newline at end of file
diff --git a/modules/ticket/back/models/ticket-methods.js b/modules/ticket/back/models/ticket-methods.js
index 7fe968b26..620b3e184 100644
--- a/modules/ticket/back/models/ticket-methods.js
+++ b/modules/ticket/back/models/ticket-methods.js
@@ -40,6 +40,7 @@ module.exports = function(Self) {
require('../methods/ticket/expeditionPalletLabel')(Self);
require('../methods/ticket/saveSign')(Self);
require('../methods/ticket/saveCmr')(Self);
+ require('../methods/ticket/sendCmrEmail')(Self);
require('../methods/ticket/invoiceTickets')(Self);
require('../methods/ticket/invoiceTicketsAndPdf')(Self);
require('../methods/ticket/docuwareDownload')(Self);
diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js
index 4f8494ed0..3672c467d 100644
--- a/modules/ticket/front/sale/index.js
+++ b/modules/ticket/front/sale/index.js
@@ -387,10 +387,10 @@ class Controller extends Section {
}
newOrderFromTicket() {
- this.$http.post(`Orders/newFromTicket`, {ticketFk: this.ticket.id}).then(res => {
- const path = this.$state.href('order.card.catalog', {id: res.data});
- window.open(path, '_blank');
+ this.$http.post(`Orders/newFromTicket`, {ticketFk: this.ticket.id}).then(async res => {
+ const path = await this.vnApp.getUrl(`order/${res.data}/catalog`);
+ window.open(path, '_blank');
this.vnApp.showSuccess(this.$t('Order created'));
});
}
diff --git a/modules/ticket/front/sale/index.spec.js b/modules/ticket/front/sale/index.spec.js
index 931776619..8ff9aa624 100644
--- a/modules/ticket/front/sale/index.spec.js
+++ b/modules/ticket/front/sale/index.spec.js
@@ -567,14 +567,10 @@ describe('Ticket', () => {
const expectedResponse = {id: 123};
window.open = jasmine.createSpy('open');
- controller.$state.href = jasmine.createSpy('href')
- .and.returnValue('/somePath');
$httpBackend.expect('POST', `Orders/newFromTicket`, expectedParams).respond(expectedResponse);
controller.newOrderFromTicket();
$httpBackend.flush();
-
- expect(window.open).toHaveBeenCalledWith('/somePath', '_blank');
});
});
diff --git a/modules/travel/back/methods/travel/extraCommunityFilter.js b/modules/travel/back/methods/travel/extraCommunityFilter.js
index dcb704ff5..f1586f804 100644
--- a/modules/travel/back/methods/travel/extraCommunityFilter.js
+++ b/modules/travel/back/methods/travel/extraCommunityFilter.js
@@ -1,4 +1,3 @@
-
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
const buildFilter = require('vn-loopback/util/filter').buildFilter;
const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
@@ -87,7 +86,7 @@ module.exports = Self => {
return /^\d+$/.test(value)
? {'t.id': value}
: {'t.ref': {like: `%${value}%`}};
- case 'ref':
+ case 'reference':
return {'t.ref': {like: `%${value}%`}};
case 'shippedFrom':
return {'t.shipped': {gte: value}};
@@ -115,42 +114,39 @@ module.exports = Self => {
`CREATE TEMPORARY TABLE tmp.travel
(INDEX (id))
ENGINE = MEMORY
- SELECT
- t.id,
+ SELECT t.id,
t.ref,
t.shipped,
t.landed,
t.kg,
- am.id AS agencyModeFk,
- am.name AS agencyModeName,
- wo.id AS warehouseOutFk,
- wo.name AS warehouseOutName,
- w.name AS warehouseInFk,
- w.name AS warehouseInName,
- SUM(b.stickers) AS stickers,
- s.id AS cargoSupplierFk,
- s.nickname AS cargoSupplierNickname,
- s.name AS supplierName,
- CAST(SUM(b.weight * b.stickers) as DECIMAL(10,0)) as loadedKg,
+ am.id agencyModeFk,
+ am.name agencyModeName,
+ wo.id warehouseOutFk,
+ wo.name warehouseOutName,
+ w.name warehouseInFk,
+ w.name warehouseInName,
+ SUM(b.stickers) stickers,
+ s.id cargoSupplierFk,
+ s.nickname cargoSupplierNickname,
+ s.name supplierName,
+ CAST(SUM(b.weight * b.stickers) AS DECIMAL(10,0)) loadedKg,
CAST(
SUM(
vc.aerealVolumetricDensity *
b.stickers *
IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000
- ) as DECIMAL(10,0)
- ) as volumeKg,
- GREATEST(
- CAST(SUM(b.weight * b.stickers) AS INT),
- CAST(
+ ) AS DECIMAL(10,0)
+ ) volumeKg,
+ CAST(
+ GREATEST(
+ SUM(b.weight * b.stickers) ,
SUM(vc.aerealVolumetricDensity *
b.stickers *
- IF(pkg.volume,
- pkg.volume,
- pkg.width * pkg.depth * pkg.height
- ) / 1000000
- ) AS INT
- )
- / t.kg * 100, 0) percentageKg
+ IF(pkg.volume,
+ pkg.volume,
+ pkg.width * pkg.depth * pkg.height) / 1000000)
+ ) / t.kg * 100 AS INT
+ ) percentageKg
FROM travel t
LEFT JOIN supplier s ON s.id = t.cargoSupplierFk
LEFT JOIN entry e ON e.travelFk = t.id
diff --git a/modules/travel/back/methods/travel/filter.js b/modules/travel/back/methods/travel/filter.js
index 30910fa46..b96873925 100644
--- a/modules/travel/back/methods/travel/filter.js
+++ b/modules/travel/back/methods/travel/filter.js
@@ -117,7 +117,6 @@ module.exports = Self => {
case 'landedTo':
return {'t.landed': {lte: value}};
case 'daysOnward':
-
today.setHours(0, 0, 0, 0);
future.setDate(today.getDate() + value);
future.setHours(23, 59, 59, 999);
@@ -155,6 +154,7 @@ module.exports = Self => {
t.landingHour,
t.cargoSupplierFk,
t.totalEntries,
+ t.isRaid,
t.daysInForward,
am.name agencyModeName,
win.name warehouseInName,
diff --git a/modules/travel/back/methods/travel/specs/getEntries.spec.js b/modules/travel/back/methods/travel/specs/getEntries.spec.js
index fcaa80d02..9286a9d55 100644
--- a/modules/travel/back/methods/travel/specs/getEntries.spec.js
+++ b/modules/travel/back/methods/travel/specs/getEntries.spec.js
@@ -3,9 +3,10 @@ const models = require('vn-loopback/server/server').models;
describe('travel getEntries()', () => {
const travelId = 1;
it('should check the response contains the id', async() => {
- const entries = await models.Travel.getEntries(travelId);
+ const result = await models.Travel.getEntries(travelId);
+ const entries = await models.Entry.find({where: {travelFk: travelId}});
- expect(entries.length).toEqual(1);
+ expect(entries.length).toEqual(result.length);
expect(entries[0].id).toEqual(1);
});
diff --git a/modules/travel/back/models/travel.json b/modules/travel/back/models/travel.json
index 04f53f1c8..a2a9e478e 100644
--- a/modules/travel/back/models/travel.json
+++ b/modules/travel/back/models/travel.json
@@ -51,6 +51,9 @@
"landingHour": {
"type": "string"
},
+ "isRaid": {
+ "type": "boolean"
+ },
"daysInForward": {
"type": "number"
}
diff --git a/modules/worker/back/methods/worker-dms/filter.js b/modules/worker/back/methods/worker-dms/filter.js
index 597084e60..240a905d2 100644
--- a/modules/worker/back/methods/worker-dms/filter.js
+++ b/modules/worker/back/methods/worker-dms/filter.js
@@ -86,30 +86,30 @@ module.exports = Self => {
'Tipo Documento': 'description',
'Stored on': 'created',
'Document ID': 'id',
- 'URL': 'download',
+ 'URL': 'url',
'Stored by': 'name',
'Estado': 'state'
};
workerDocuware =
- await models.Docuware.getById('hr', worker.lastName + ' ' + worker.firstName, docuwareParse) ?? [];
- const url = (await Self.app.models.Url.getUrl('docuware')) + 'WebClient';
+ await models.Docuware.getById('hr', worker?.lastName + ' ' + worker?.firstName, docuwareParse) ?? [];
+
for (document of workerDocuware) {
- const docuwareId = document.id;
+ const {id: documentId, dmsFk} = document;
const defaultData = {
- id: docuwareId,
+ id: documentId,
workerFk: id,
- dmsFk: docuwareId,
+ dmsFk: dmsFk,
dms: {
- id: docuwareId,
- file: docuwareId + '.pdf',
+ id: documentId,
+ file: dmsFk + '.pdf',
isDocuware: true,
hasFile: false,
- reference: worker.fi,
- dmsFk: docuwareId,
- url,
+ reference: worker?.fi,
+ dmsFk: dmsFk,
+ url: document.url,
+ download: `WorkerDms/${document.dmsFk}/docuwareDownload`,
description: document.description + ' - ' + document.state,
- download: document.download,
created: document.created,
dmsType: {name: 'Docuware'},
worker: {id: null, user: {name: document.name}},
diff --git a/modules/worker/back/methods/worker-time-control-mail/checkInbox.js b/modules/worker/back/methods/worker-time-control-mail/checkInbox.js
index 4d9f98cc3..688cbb634 100644
--- a/modules/worker/back/methods/worker-time-control-mail/checkInbox.js
+++ b/modules/worker/back/methods/worker-time-control-mail/checkInbox.js
@@ -16,7 +16,7 @@ module.exports = Self => {
});
Self.checkInbox = async() => {
- let imapConfig = await Self.app.models.WorkerTimeControlParams.findOne();
+ let imapConfig = await Self.app.models.WorkerTimeControlConfig.findOne();
let imap = new Imap({
user: imapConfig.mailUser,
password: imapConfig.mailPass,
diff --git a/modules/worker/back/methods/worker-time-control/specs/login.spec.js b/modules/worker/back/methods/worker-time-control/specs/login.spec.js
index e125a876d..eff0edaa7 100644
--- a/modules/worker/back/methods/worker-time-control/specs/login.spec.js
+++ b/modules/worker/back/methods/worker-time-control/specs/login.spec.js
@@ -1,5 +1,4 @@
const models = require('vn-loopback/server/server').models;
-const LoopBackContext = require('loopback-context');
const UserError = require('vn-loopback/util/user-error');
describe('workerTimeControl login()', () => {
diff --git a/modules/worker/back/methods/worker-time-control/specs/sendMail.spec.js b/modules/worker/back/methods/worker-time-control/specs/sendMail.spec.js
new file mode 100644
index 000000000..1395c7a46
--- /dev/null
+++ b/modules/worker/back/methods/worker-time-control/specs/sendMail.spec.js
@@ -0,0 +1,27 @@
+const models = require('vn-loopback/server/server').models;
+
+describe('sendMail', () => {
+ it('should insert in mail', async() => {
+ const tx = await models.Sale.beginTransaction({});
+ const options = {transaction: tx};
+ options.transaction = tx;
+ let mailCountBefore;
+ let mailCountAfter;
+ const ctx = {
+ req: {accessToken: {userId: 50}},
+ args: {workerFk: 1106, year: 2001, week: 1}
+ };
+
+ try {
+ mailCountBefore = await models.Mail.count(options);
+ await models.WorkerTimeControl.sendMail(ctx, options);
+ mailCountAfter = await models.Mail.count(options);
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+
+ expect(mailCountAfter).toBeGreaterThan(mailCountBefore);
+ await tx.rollback();
+ });
+});
diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js
index 0397886cf..e46ce9577 100644
--- a/modules/worker/back/methods/worker/createAbsence.js
+++ b/modules/worker/back/methods/worker/createAbsence.js
@@ -58,18 +58,24 @@ module.exports = Self => {
if (!isSubordinate || (isSubordinate && userId == id && !isTeamBoss))
throw new UserError(`You don't have enough privileges`);
- const labour = await models.WorkerLabour.findById(args.businessFk, {
- include: {relation: 'department'}
- }, myOptions);
+ const canCreateAbsenceInPast =
+ await models.ACL.checkAccessAcl(ctx, 'Worker', 'canCreateAbsenceInPast', 'WRITE');
+ const now = Date.vnNew();
+ const newDate = new Date(args.dated).getTime();
+
+ if ((now.getTime() > newDate) && !canCreateAbsenceInPast)
+ throw new UserError(`Holidays to past days not available`);
+
+ const labour = await models.WorkerLabour.findById(args.businessFk,
+ {fields: ['started', 'ended', 'businessFk']}, myOptions);
if (args.dated < labour.started || (labour.ended != null && args.dated > labour.ended))
throw new UserError(`The contract was not active during the selected date`);
- query = `SELECT *
- FROM vn.workerTimeControl
- WHERE userFk = ? AND timed BETWEEN DATE(?) AND CONCAT(DATE(?), ' 23:59:59')
- LIMIT 1;`;
- const [hasHoursRecorded] = await Self.rawSql(query, [id, args.dated, args.dated]);
+ const [hasHoursRecorded] = await Self.rawSql(`SELECT *
+ FROM vn.workerTimeControl
+ WHERE userFk = ? AND timed BETWEEN DATE(?) AND CONCAT(DATE(?), ' 23:59:59')
+ LIMIT 1;`, [id, args.dated, args.dated]);
const absenceType = await models.AbsenceType.findById(args.absenceTypeId, null, myOptions);
@@ -81,13 +87,13 @@ module.exports = Self => {
throw new UserError(`The worker has hours recorded that day`);
const date = Date.vnNew();
- const now = Date.vnNew();
date.setHours(0, 0, 0, 0);
const [result] = await Self.rawSql(
`SELECT COUNT(*) halfHolidayCounter
FROM vn.calendar c
JOIN vn.business b ON b.id = c.businessFk
- WHERE c.dayOffTypeFk = 6
+ JOIN vn.absenceType at ON at.id = c.dayOffTypeFk
+ WHERE at.code = 'halfHoliday'
AND b.workerFk = ?
AND c.dated BETWEEN util.firstDayOfYear(?)
AND LAST_DAY(DATE_ADD(?, INTERVAL 12 - MONTH(?) MONTH))`, [id, date, now, now]);
@@ -119,25 +125,23 @@ module.exports = Self => {
dated: args.dated
}, myOptions);
- const department = labour.department();
- if (department && department.notificationEmail) {
- const absenceType = await models.AbsenceType.findById(args.absenceTypeId, null, myOptions);
- const account = await models.VnUser.findById(userId, null, myOptions);
- const subordinated = await models.VnUser.findById(id, null, myOptions);
- const url = await Self.app.models.Url.getUrl();
- const body = $t('Created absence', {
- author: account.nickname,
- employee: subordinated.nickname,
- absenceType: absenceType.name,
- dated: formatDate(args.dated),
- workerUrl: `${url}worker/${id}/calendar`
- });
- await models.Mail.create({
- subject: $t('Absence change notification on the labour calendar'),
- body: body,
- receiver: department.notificationEmail
- }, myOptions);
- }
+ const account = await models.VnUser.findById(userId, null, myOptions);
+ const subordinated = await models.VnUser.findById(id, null, myOptions);
+ const worker = await models.Worker.findById(subordinated.id, null, myOptions);
+ const departmentBoss = await models.VnUser.findById(worker.bossFk, null, myOptions);
+ const url = await Self.app.models.Url.getUrl();
+ const body = $t('Created absence', {
+ author: account.nickname,
+ employee: subordinated.nickname,
+ absenceType: absenceType.name,
+ dated: formatDate(args.dated),
+ workerUrl: `${url}worker/${id}/calendar`
+ });
+ await models.Mail.create({
+ subject: $t('Absence change notification on the labour calendar'),
+ body: body,
+ receiver: departmentBoss.email
+ }, myOptions);
if (tx) await tx.commit();
diff --git a/modules/worker/back/methods/worker/specs/createAbsence.spec.js b/modules/worker/back/methods/worker/specs/createAbsence.spec.js
index fcb1c1633..1c7efcd28 100644
--- a/modules/worker/back/methods/worker/specs/createAbsence.spec.js
+++ b/modules/worker/back/methods/worker/specs/createAbsence.spec.js
@@ -162,4 +162,33 @@ describe('Worker createAbsence()', () => {
expect(error.message).toEqual(`The worker has hours recorded that day`);
});
+
+ it(`Should throw an error when adding a "Vacation" absence on a past day`, async() => {
+ const ctx = {
+ req: {accessToken: {userId: 19}},
+ args: {
+ id: 1110,
+ businessFk: 1110,
+ absenceTypeId: 1,
+ dated: '2000-12-27T23:00:00.000Z',
+ }
+ };
+ const workerId = 19;
+
+ const tx = await app.models.Calendar.beginTransaction({});
+
+ let error;
+ try {
+ const options = {transaction: tx};
+
+ await app.models.Worker.createAbsence(ctx, workerId, options);
+
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ error = e;
+ }
+
+ expect(error.message).toEqual(`Holidays to past days not available`);
+ });
});
diff --git a/modules/worker/back/model-config.json b/modules/worker/back/model-config.json
index 7bfc667ac..10e55d956 100644
--- a/modules/worker/back/model-config.json
+++ b/modules/worker/back/model-config.json
@@ -113,9 +113,6 @@
"WorkerTimeControlConfig": {
"dataSource": "vn"
},
- "WorkerTimeControlParams": {
- "dataSource": "vn"
- },
"WorkerTimeControlMail": {
"dataSource": "vn"
},
@@ -125,6 +122,15 @@
"Locker": {
"dataSource": "vn"
},
+ "WorkerIrpf": {
+ "dataSource": "vn"
+ },
+ "DisabilityGrade": {
+ "dataSource": "vn"
+ },
+ "WorkerRelative": {
+ "dataSource": "vn"
+ },
"MedicalReview": {
"dataSource": "vn"
},
diff --git a/modules/worker/back/models/disability-grade.json b/modules/worker/back/models/disability-grade.json
new file mode 100644
index 000000000..506138225
--- /dev/null
+++ b/modules/worker/back/models/disability-grade.json
@@ -0,0 +1,18 @@
+{
+ "name": "DisabilityGrade",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "disabilityGrade"
+ }
+ },
+ "properties": {
+ "id": {
+ "id": true,
+ "type": "number"
+ },
+ "description": {
+ "type": "string"
+ }
+ }
+}
diff --git a/modules/worker/back/models/worker-irpf.json b/modules/worker/back/models/worker-irpf.json
new file mode 100644
index 000000000..65f72a1fd
--- /dev/null
+++ b/modules/worker/back/models/worker-irpf.json
@@ -0,0 +1,55 @@
+{
+ "name": "WorkerIrpf",
+ "description": "Model 145 IRPF",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "workerIrpf"
+ }
+ },
+ "properties": {
+ "workerFk": {
+ "type": "number",
+ "id": 1,
+ "description": "Identifier"
+ },
+ "spouseNif": {
+ "type": "string"
+ },
+ "geographicMobilityDate": {
+ "type": "date"
+ },
+ "disabilityGradeFk": {
+ "type" : "number"
+ },
+ "isDependend": {
+ "type" : "number"
+ },
+ "familySituation": {
+ "type" : "number"
+ },
+ "spousePension": {
+ "type" : "number"
+ },
+ "childPension": {
+ "type" : "number"
+ },
+ "hasHousingPaymentBefore": {
+ "type" : "number"
+ },
+ "hasHousingPaymentAfter": {
+ "type" : "number"
+ },
+ "updated": {
+ "type" : "date"
+ }
+
+ },
+ "relations": {
+ "disabilityGrade": {
+ "type": "belongsTo",
+ "model": "disabilityGrade",
+ "foreignKey": "disabilityGradeFk"
+ }
+ }
+}
diff --git a/modules/worker/back/models/worker-relatives.json b/modules/worker/back/models/worker-relatives.json
new file mode 100644
index 000000000..532a9446c
--- /dev/null
+++ b/modules/worker/back/models/worker-relatives.json
@@ -0,0 +1,53 @@
+{
+ "name": "WorkerRelative",
+ "description": "Model 145 IRPF",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "workerRelatives"
+ }
+ },
+ "properties": {
+ "id": {
+ "type": "number",
+ "id": true,
+ "description": "Identifier"
+ },
+ "workerFk": {
+ "type": "number"
+ },
+ "isDescendant": {
+ "type": "number"
+ },
+ "disabilityGradeFk": {
+ "type" : "number"
+ },
+ "birthed": {
+ "type" : "number"
+ },
+ "adoptionYear": {
+ "type" : "number"
+ },
+ "isDependend": {
+ "type" : "boolean"
+ },
+ "isJointCustody": {
+ "type" : "boolean"
+ },
+ "updated": {
+ "type" : "date"
+ }
+ },
+ "relations": {
+ "disabilityGrade": {
+ "type": "belongsTo",
+ "model": "disabilityGrade",
+ "foreignKey": "disabilityGradeFk"
+ },
+ "worker": {
+ "type": "belongsTo",
+ "model": "VnUser",
+ "foreignKey": "workerFK"
+ }
+ }
+}
diff --git a/modules/worker/back/models/worker-time-control-config.json b/modules/worker/back/models/worker-time-control-config.json
index b96e2ae3b..53f1a14ea 100644
--- a/modules/worker/back/models/worker-time-control-config.json
+++ b/modules/worker/back/models/worker-time-control-config.json
@@ -11,6 +11,15 @@
"id": true,
"type": "number"
},
+ "mailPass": {
+ "type": "string"
+ },
+ "mailHost": {
+ "type": "string"
+ },
+ "mailUser": {
+ "type": "string"
+ },
"breakTime": {
"type": "number"
},
@@ -23,5 +32,13 @@
"teleworkingStartBreakTime": {
"type": "number"
}
- }
+ },
+ "acls": [
+ {
+ "accessType": "READ",
+ "principalType": "ROLE",
+ "principalId": "$everyone",
+ "permission": "ALLOW"
+ }
+ ]
}
diff --git a/modules/worker/back/models/worker-time-control-params.json b/modules/worker/back/models/worker-time-control-params.json
deleted file mode 100644
index 14cabbfb0..000000000
--- a/modules/worker/back/models/worker-time-control-params.json
+++ /dev/null
@@ -1,35 +0,0 @@
-{
- "name": "WorkerTimeControlParams",
- "description": "imap config",
- "base": "VnModel",
- "options": {
- "mysql": {
- "table": "workerTimeControlParams"
- }
- },
- "properties": {
- "mailHost": {
- "type": "string"
- },
- "mailUser": {
- "type": "string"
- },
- "mailPass": {
- "type": "string"
- },
- "mailSuccessFolder": {
- "type": "string"
- },
- "mailErrorFolder": {
- "type": "string"
- }
- },
- "acls": [
- {
- "accessType": "READ",
- "principalType": "ROLE",
- "principalId": "$everyone",
- "permission": "ALLOW"
- }
- ]
-}
diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json
index 937df98c0..705851963 100644
--- a/modules/worker/back/models/worker.json
+++ b/modules/worker/back/models/worker.json
@@ -132,6 +132,16 @@
"type": "hasMany",
"model": "WorkerTimeControlMail",
"foreignKey": "workerFk"
+ },
+ "irpf": {
+ "type": "hasMany",
+ "model": "WorkerIrpf",
+ "foreignKey": "workerFk"
+ },
+ "workerRelative": {
+ "type": "hasMany",
+ "model": "WorkerRelative",
+ "foreignKey": "workerFK"
}
},
"acls": [
@@ -301,8 +311,20 @@
"birth",
"educationLevelFk",
"originCountryFk",
- "maritalStatus"
+ "maritalStatus",
+ "SSN"
+ ],
+ "include": [
+ {
+ "relation": "client",
+ "scope": {
+ "fields": [
+ "id",
+ "phone"
+ ]
+ }
+ }
]
}
}
-}
\ No newline at end of file
+}
diff --git a/modules/zone/back/methods/zone/deleteZone.js b/modules/zone/back/methods/zone/deleteZone.js
index ffe23c9b9..e2e01a949 100644
--- a/modules/zone/back/methods/zone/deleteZone.js
+++ b/modules/zone/back/methods/zone/deleteZone.js
@@ -40,8 +40,7 @@ module.exports = Self => {
try {
const filter = {
where: {
- zoneFk: id,
- shipped: {gte: today}
+ zoneFk: id
},
include: {
relation: 'ticketState',
@@ -52,9 +51,9 @@ module.exports = Self => {
};
const ticketList = await models.Ticket.find(filter, myOptions);
-
- if (ticketList.length > 0)
- throw new UserError('There are tickets for this area, delete them first');
+ const hasRefFk = ticketList.some(ticket => ticket.refFk);
+ if (hasRefFk)
+ throw new UserError('There are tickets to be invoiced');
await models.Zone.destroyById(id, myOptions);
diff --git a/modules/zone/back/methods/zone/specs/deleteZone.spec.js b/modules/zone/back/methods/zone/specs/deleteZone.spec.js
index aef7fd290..510713f9e 100644
--- a/modules/zone/back/methods/zone/specs/deleteZone.spec.js
+++ b/modules/zone/back/methods/zone/specs/deleteZone.spec.js
@@ -8,14 +8,14 @@ describe('zone deletezone()', () => {
__: value => value
};
const ctx = {req: activeCtx};
- const zoneId = 4;
- const zoneId2 = 3;
let ticketIDs;
beforeAll(async() => {
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
+
+ const zoneId = 4;
const originalTickets = await models.Ticket.find({
where: {
zoneFk: zoneId
@@ -29,7 +29,7 @@ describe('zone deletezone()', () => {
it('should delete a zone and update their tickets', async() => {
const tx = await models.Zone.beginTransaction({});
-
+ const zoneId = 4;
try {
const options = {transaction: tx};
await models.Zone.deleteZone(ctx, zoneId, options);
@@ -47,17 +47,18 @@ describe('zone deletezone()', () => {
it('should not delete the zone if it has tickets', async() => {
const tx = await models.Zone.beginTransaction({});
+ const zoneId = 1;
let error;
try {
const options = {transaction: tx};
- await models.Zone.deleteZone(ctx, zoneId2, options);
+ await models.Zone.deleteZone(ctx, zoneId, options);
await tx.rollback();
} catch (e) {
error = e.message;
await tx.rollback();
}
- expect(error).toEqual('There are tickets for this area, delete them first');
+ expect(error).toEqual('There are tickets to be invoiced');
});
});
diff --git a/modules/zone/back/models/zone.js b/modules/zone/back/models/zone.js
index 6d5a6cdca..7b5cb4301 100644
--- a/modules/zone/back/models/zone.js
+++ b/modules/zone/back/models/zone.js
@@ -14,4 +14,18 @@ module.exports = Self => {
Self.validatesPresenceOf('agencyModeFk', {
message: `Agency cannot be blank`
});
+
+ Self.validatesPresenceOf('price', {
+ message: 'Price cannot be blank'
+ });
+ Self.validateAsync('price', priceIsValid, {
+ message: 'Price must be greater than 0'
+ });
+
+ async function priceIsValid(err, done) {
+ if (this.price <= 0)
+ err();
+
+ done();
+ }
};
diff --git a/myt.config.yml b/myt.config.yml
index 25f94f1bd..a947405b3 100755
--- a/myt.config.yml
+++ b/myt.config.yml
@@ -71,6 +71,7 @@ fixtures:
- ticketUpdateAction
- ticketCanAdvanceConfig
- volumeConfig
+ - workerActivityType
- workCenter
- workerTimeControlError
cache:
@@ -258,7 +259,6 @@ localFixtures:
- itemFamily
- itemLog
- itemShelving
- - itemShelvingLog
- itemShelvingSale
- itemTag
- itemTaxCountry
@@ -385,7 +385,6 @@ localFixtures:
- workerTimeControl
- workerTimeControlConfig
- workerTimeControlMail
- - workerTimeControlParams
- zone
- zoneAgencyMode
- zoneClosure
diff --git a/package.json b/package.json
index 767ec231e..4e823eaad 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "salix-back",
- "version": "24.44.0",
+ "version": "24.52.0",
"author": "Verdnatura Levante SL",
"description": "Salix backend",
"license": "GPL-3.0",
diff --git a/print/templates/email/incoterms-authorization/locale/en.yml b/print/templates/email/incoterms-authorization/locale/en.yml
new file mode 100644
index 000000000..7e1402575
--- /dev/null
+++ b/print/templates/email/incoterms-authorization/locale/en.yml
@@ -0,0 +1,6 @@
+subject: Incoterms Authorization
+title: Incoterms Authorization
+description:
+ dear: Dear customer
+ instructions: Please find attached the Incoterms authorization form, which you must complete and sign.
+ conclusion: Thank you for your attention!
diff --git a/print/templates/reports/balance-compensation/locale/en.yml b/print/templates/reports/balance-compensation/locale/en.yml
new file mode 100644
index 000000000..824127482
--- /dev/null
+++ b/print/templates/reports/balance-compensation/locale/en.yml
@@ -0,0 +1,16 @@
+reportName: balance-compensation
+Place: Algemesí, on
+Compensation: Compensation of debtor and creditor balances
+In one hand: On one hand
+CIF: with CIF
+NIF: with NIF
+Home: and address located at
+In other hand: On the other hand
+Sr: Mr./Ms.
+Agree: Agree
+Date: On the date of
+Compensate: the balance of has been compensated
+From client: from the client/supplier
+Against the balance of: against the balance of
+Reception: Please confirm receipt of this compensation at the email
+Greetings: Best regards,
diff --git a/print/templates/reports/buy-label-barcode/assets/css/style.css b/print/templates/reports/buy-label-barcode/assets/css/style.css
index fabecd28e..ce1924878 100644
--- a/print/templates/reports/buy-label-barcode/assets/css/style.css
+++ b/print/templates/reports/buy-label-barcode/assets/css/style.css
@@ -32,6 +32,11 @@ td {
.md-txt {
font-size: 26px;
}
+.lg-txt {
+ font-size: 40px;
+ padding: 0px;
+ line-height: 1;
+}
.xl-txt {
font-size: 50px;
}
diff --git a/print/templates/reports/buy-label-barcode/buy-label-barcode.html b/print/templates/reports/buy-label-barcode/buy-label-barcode.html
index f14f0b70b..ebddb60ec 100644
--- a/print/templates/reports/buy-label-barcode/buy-label-barcode.html
+++ b/print/templates/reports/buy-label-barcode/buy-label-barcode.html
@@ -36,12 +36,12 @@
-
+ |
- {{buy.itemFk}}
+ {{formatNumber(buy.itemFk)}}
|
-
+ |
{{`${(packing || buy.packing)} x ${buy.stems || ''}`}}
@@ -56,7 +56,7 @@
{{'LAID'}}
- {{buy.entryFk}}
+ {{formatNumber(buy.entryFk)}}
|
@@ -73,17 +73,17 @@
-
+ |
- {{buy.buyFk}}
+ {{formatNumber(buy.buyFk)}}
|
-
+ |
{{date}}
|
-
+ |
{{`${buy.labelNum}/${buy.quantity / (packing || buy.packing)}`}}
diff --git a/print/templates/reports/buy-label-barcode/buy-label-barcode.js b/print/templates/reports/buy-label-barcode/buy-label-barcode.js
index 8c39a7046..37b618f09 100755
--- a/print/templates/reports/buy-label-barcode/buy-label-barcode.js
+++ b/print/templates/reports/buy-label-barcode/buy-label-barcode.js
@@ -9,7 +9,7 @@ module.exports = {
this.date = Date.vnNew();
this.buys = await this.rawSqlFromDef('buy', [this.copies || 1, this.id]);
if (!this.buys.length) throw new UserError(`Empty data source`);
- this.date = moment(this.date).format('WW/E');
+ this.date = moment(this.date).format('WW/DD');
},
methods: {
getBarcode(data) {
@@ -20,11 +20,14 @@ module.exports = {
xmlDocument: document,
format: 'code128',
displayValue: false,
- width: 3.8,
- height: 85,
+ width: 3.5,
+ height: 75,
margin: 0
});
return new XMLSerializer().serializeToString(svgNode);
+ },
+ formatNumber(number) {
+ return new Intl.NumberFormat('es-ES', {maximumFractionDigits: 0}).format(number);
}
},
props: {
diff --git a/print/templates/reports/buy-label-qr/assets/css/style.css b/print/templates/reports/buy-label-qr/assets/css/style.css
index 0e288704b..36db0fdef 100644
--- a/print/templates/reports/buy-label-qr/assets/css/style.css
+++ b/print/templates/reports/buy-label-qr/assets/css/style.css
@@ -34,6 +34,9 @@ html {
background-color: black;
color: white;
}
+.sm-txt {
+ font-size: 18px;
+}
.md-txt {
font-size: 20px;
}
diff --git a/print/templates/reports/buy-label-qr/buy-label-qr.html b/print/templates/reports/buy-label-qr/buy-label-qr.html
index 00e64b57d..00ede5488 100644
--- a/print/templates/reports/buy-label-qr/buy-label-qr.html
+++ b/print/templates/reports/buy-label-qr/buy-label-qr.html
@@ -11,8 +11,8 @@
|
-
- {{buy.buyFk}}
+ |
+ {{formatNumber(buy.buyFk)}}
|
@@ -28,7 +28,7 @@
- {{buy.itemFk}}
+ {{formatNumber(buy.itemFk)}}
|
@@ -78,8 +78,7 @@
{{'LAID'}}
-
- {{buy.entryFk}}
+
@@ -103,7 +102,7 @@
- Entrada: {{buy.entryFk}}
+ Entrada: {{formatNumber(buy.entryFk)}}
|
diff --git a/print/templates/reports/buy-label-qr/buy-label-qr.js b/print/templates/reports/buy-label-qr/buy-label-qr.js
index 74470ad6d..614e40816 100755
--- a/print/templates/reports/buy-label-qr/buy-label-qr.js
+++ b/print/templates/reports/buy-label-qr/buy-label-qr.js
@@ -9,7 +9,7 @@ module.exports = {
this.buys = await this.rawSqlFromDef('buy', [this.copies || 1, this.id]);
if (!this.buys.length) throw new UserError(`Empty data source`);
this.qr = await this.getQr(this.buys[0].buyFk);
- this.date = moment(this.date).format('WW/E');
+ this.date = moment(this.date).format('WW/DD');
},
methods: {
getQr(data) {
@@ -24,6 +24,9 @@ module.exports = {
margin: 0,
errorCorrectionLevel: 'L'
});
+ },
+ formatNumber(number) {
+ return new Intl.NumberFormat('es-ES', {maximumFractionDigits: 0}).format(number);
}
},
props: {
diff --git a/print/templates/reports/buy-label-supplier/buy-label-supplier.html b/print/templates/reports/buy-label-supplier/buy-label-supplier.html
index 5777d34de..31fef38f7 100644
--- a/print/templates/reports/buy-label-supplier/buy-label-supplier.html
+++ b/print/templates/reports/buy-label-supplier/buy-label-supplier.html
@@ -86,7 +86,7 @@
{{$t('boxNum')}}
- {{`${buy.labelNum} / ${buy.maxLabelNum}`}}
+ {{getTotal(buy)}}
|
diff --git a/print/templates/reports/buy-label-supplier/buy-label-supplier.js b/print/templates/reports/buy-label-supplier/buy-label-supplier.js
index 3cef5f295..5e59472eb 100755
--- a/print/templates/reports/buy-label-supplier/buy-label-supplier.js
+++ b/print/templates/reports/buy-label-supplier/buy-label-supplier.js
@@ -9,7 +9,7 @@ module.exports = {
mixins: [vnReport],
async serverPrefetch() {
const buy = await models.Buy.findById(this.id, null);
- this.buys = await this.rawSqlFromDef('buy', [buy.entryFk, buy.entryFk, buy.entryFk, this.id]);
+ this.buys = await this.rawSqlFromDef('buy', [buy.entryFk, buy.entryFk, buy.entryFk, this.id, this.id]);
const date = new Date();
this.weekNum = moment(date).isoWeek();
this.dayNum = moment(date).day();
@@ -27,6 +27,11 @@ module.exports = {
height: 115,
});
return new XMLSerializer().serializeToString(svgNode);
+ },
+ getTotal(buy) {
+ return (this.showEntryLines) ?
+ `${buy.entryLabelNum} / ${buy.entryLabels}` :
+ `${buy.buyLabelNum} / ${buy.buyLabels}`;
}
},
props: {
@@ -34,6 +39,10 @@ module.exports = {
type: Number,
required: true,
description: 'The entry id'
+ },
+ showEntryLines: {
+ type: Boolean,
+ required: false
}
}
};
diff --git a/print/templates/reports/buy-label-supplier/sql/buy.sql b/print/templates/reports/buy-label-supplier/sql/buy.sql
index 26efeb06e..fe001ff10 100644
--- a/print/templates/reports/buy-label-supplier/sql/buy.sql
+++ b/print/templates/reports/buy-label-supplier/sql/buy.sql
@@ -10,7 +10,7 @@ WITH RECURSIVE numbers AS (
)
),
labels AS (
- SELECT ROW_NUMBER() OVER(ORDER BY b.id, num.n) labelNum,
+ SELECT ROW_NUMBER() OVER(ORDER BY b.id, num.n) entryLabelNum,
i.name,
i.`size`,
i.category,
@@ -33,6 +33,9 @@ labels AS (
WHERE b.entryFk = ?
AND num.n <= b.stickers
)
-SELECT *, (SELECT SUM(stickers) FROM buy WHERE entryFk = ?) maxLabelNum
+SELECT *,
+ ROW_NUMBER() OVER(ORDER BY entryLabelNum) buyLabelNum,
+ (SELECT SUM(stickers) FROM buy WHERE entryFk = ?) entryLabels,
+ (SELECT stickers FROM buy WHERE id = ?) buyLabels
FROM labels
WHERE id = ?
\ No newline at end of file
diff --git a/print/templates/reports/driver-route/driver-route.html b/print/templates/reports/driver-route/driver-route.html
index 109afd2f5..e3a206656 100644
--- a/print/templates/reports/driver-route/driver-route.html
+++ b/print/templates/reports/driver-route/driver-route.html
@@ -16,7 +16,7 @@
{{$t('date')}} |
- {{formatDate(route.created, '%d-%m-%Y')}} |
+ {{formatDate(route.dated, '%d-%m-%Y')}} |
{{$t('vehicle')}} |
{{route.vehicleTradeMark}} {{route.vehicleModel}} |
diff --git a/print/templates/reports/driver-route/sql/routes.sql b/print/templates/reports/driver-route/sql/routes.sql
index 9d2dd5c13..334f2337d 100644
--- a/print/templates/reports/driver-route/sql/routes.sql
+++ b/print/templates/reports/driver-route/sql/routes.sql
@@ -1,6 +1,6 @@
SELECT r.id,
r.m3,
- r.created,
+ r.dated,
r.time,
u.nickName userNickName,
v.tradeMark vehicleTradeMark,
diff --git a/print/templates/reports/entry-order/assets/css/style.css b/print/templates/reports/entry-order/assets/css/style.css
index 767b1185a..858ae704e 100644
--- a/print/templates/reports/entry-order/assets/css/style.css
+++ b/print/templates/reports/entry-order/assets/css/style.css
@@ -17,4 +17,14 @@ h3 {
.tags {
font-size: 10px;
margin: 0;
+}
+
+.column-oriented th,
+.column-oriented td{
+ padding: 5px
+}
+
+[row] {
+ display: flex;
+ column-gap: 5px;
}
\ No newline at end of file
diff --git a/print/templates/reports/entry-order/entry-order.html b/print/templates/reports/entry-order/entry-order.html
index e5d3bfb6d..d3f909d4d 100644
--- a/print/templates/reports/entry-order/entry-order.html
+++ b/print/templates/reports/entry-order/entry-order.html
@@ -41,42 +41,50 @@
+ {{$t('code')}} |
{{$t('boxes')}} |
- |
+ |
{{$t('packing')}} |
- {{$t('concept')}} |
- {{$t('reference')}} |
- {{$t('tags')}} |
- {{$t('quantity')}} |
- |
- {{$t('price')}} |
- |
- {{$t('amount')}} |
+ {{$t('concept')}} |
+ {{$t('reference')}} |
+ {{$t('tags')}} |
+ {{$t('quantity')}} |
+ |
+ {{$t('price')}} |
+ |
+ {{$t('amount')}} |
+ {{buy.itemFk}} |
{{buy.stickers}} |
- x |
- {{buy.packing}} |
- {{buy.name}} |
- {{buy.comment}} |
-
- {{buy.tag5}} → {{buy.value5}}
- {{buy.tag6}} → {{buy.value6}}
- {{buy.tag7}} → {{buy.value7}}
+ | x |
+ {{buy.packing}} |
+ {{buy.name}} |
+ {{buy.comment}} |
+
+
+ {{buy.tag5}}→ {{buy.value5}}
+ {{buy.tag6}}→ {{buy.value6}}
+
+
+ {{buy.tag7}}→ {{buy.value7}}
+ {{buy.tag8}}→ {{buy.value8}}
+
|
- {{buy.quantity | number($i18n.locale)}} |
- x |
- {{buy.buyingValue | currency('EUR', $i18n.locale)}} |
- = |
-
+ | {{buy.quantity | number($i18n.locale)}} |
+ x |
+ {{buy.buyingValue | currency('EUR', $i18n.locale)}} |
+ = |
+
{{buy.buyingValue * buy.quantity | currency('EUR', $i18n.locale)}}
|
+ |
{{getTotalBy('stickers')}} |
|
|
diff --git a/print/templates/reports/entry-order/locale/es.yml b/print/templates/reports/entry-order/locale/es.yml
index 5a6716ba1..9ec357802 100644
--- a/print/templates/reports/entry-order/locale/es.yml
+++ b/print/templates/reports/entry-order/locale/es.yml
@@ -16,4 +16,5 @@ entry: Entrada {0}
supplierData: Datos del proveedor
notes: Notas
reference: Referencia
-tags: Tags
\ No newline at end of file
+tags: Etiquetas
+code: Código
\ No newline at end of file
diff --git a/print/templates/reports/entry-order/sql/buys.sql b/print/templates/reports/entry-order/sql/buys.sql
index 92c055483..545849908 100644
--- a/print/templates/reports/entry-order/sql/buys.sql
+++ b/print/templates/reports/entry-order/sql/buys.sql
@@ -10,7 +10,9 @@ SELECT b.itemFk,
i.tag6,
i.value6,
i.tag7,
- i.value7
+ i.value7,
+ i.tag8,
+ i.value8
FROM buy b
JOIN item i ON i.id = b.itemFk
LEFT JOIN item i2 ON i2.id = b.itemOriginalFk
diff --git a/print/templates/reports/expedition-pallet-label/sql/labelData.sql b/print/templates/reports/expedition-pallet-label/sql/labelData.sql
index 49a4031ae..5ddf8eb6e 100644
--- a/print/templates/reports/expedition-pallet-label/sql/labelData.sql
+++ b/print/templates/reports/expedition-pallet-label/sql/labelData.sql
@@ -4,7 +4,7 @@ SELECT ep.id palletFk,
r.description `zone`,
COUNT(es.id) labels,
t.warehouseFk warehouseFk,
- dayname(r.created) `dayName`,
+ dayname(r.dated) `dayName`,
rs.id <=> rm.roadmapStopFk isMatch
FROM vn.roadmapStop rs
JOIN vn.expeditionPallet ep ON ep.truckFk = rs.id
diff --git a/print/templates/reports/incoterms-authorization/locale/en.yml b/print/templates/reports/incoterms-authorization/locale/en.yml
new file mode 100644
index 000000000..eb6a8a513
--- /dev/null
+++ b/print/templates/reports/incoterms-authorization/locale/en.yml
@@ -0,0 +1,39 @@
+reportName: autorization-incoterms
+description: '{socialName} a duly constituted and responsible company limited
+and registered under corporate law {country} and here represented by {socialName}, with address in {address},
+CIF {fiscalID}. Hereinafter referred to as {name}.'
+issued: 'In {0}, on {1} of {2} of {3}'
+client: 'Customer {0}'
+declaration: '{socialName} hereby declares that:'
+declarations:
+ - 'All purchases made by {socialName} with {companyName} They are delivered according to the conditions defined in the Incoterm.'
+ - '{socialName} recognizes that it is important for {companyName} have
+proof of intra-community delivery of the goods to {destinationCountry} to
+be able to invoice with 0% VAT.'
+ - 'Therefore, by signing this agreement, {socialName} declares that all goods
+purchased from {companyName} will be delivered to {destinationCountry}.'
+ - 'Besides, {socialName} shall, at the first request of {companyName},
+provide proof that all products purchased from {companyName} have
+been delivered in {destinationCountry}.'
+ - 'In addition to the above, {companyName} will provide to {socialName}
+a monthly summary that includes all bills (and corresponding deliveries).
+{socialName} will sign and return the monthly summary to {companyName},
+S.L. within 5 days of receiving the summary.'
+signer:
+ representative: Representative
+ representativeRole: Position of the representative
+ signed: Date of signature
+manager: Manager
+months:
+ - 'January'
+ - 'February'
+ - 'March'
+ - 'April'
+ - 'May'
+ - 'June'
+ - 'July'
+ - 'August'
+ - 'September'
+ - 'October'
+ - 'November'
+ - 'December'