diff --git a/CHANGELOG.md b/CHANGELOG.md index bfff5e53b..75e807a7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [2322.01] - 2023-06-08 +## [2324.01] - 2023-06-08 ### Added - @@ -19,6 +19,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 +## [2322.01] - 2023-06-01 + +### Added +- (Tickets -> Crear Factura) Al facturar se envia automáticamente el pdf al cliente +- (Artículos -> Histórico) Filtro para mostrar lo anterior al inventario + + +### Changed +- (Trabajadores -> Nuevo trabajador) Los clientes se crean sin 'TR' pero se añade tipo de negocio 'Trabajador' + +### Fixed +- (Tickets -> Líneas) Se permite hacer split de líneas al mismo ticket + + + ## [2320.01] - 2023-05-25 ### Added @@ -38,10 +53,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - (Usuarios -> Histórico) Nueva sección - (Roles -> Histórico) Nueva sección -- (General -> Traducciones) Correo de bienvenida a clientes al portugués y al francés +- (Trabajadores -> Dar de alta) Permite elegir el método de pago ### Changed - (Artículo -> Precio fijado) Modificado el buscador superior por uno lateral +- (Trabajadores -> Dar de alta) Quitada obligatoriedad del iban ### Fixed - (Ticket -> Boxing) Arreglado selección de horas diff --git a/back/methods/docuware/deliveryNoteEmail.js b/back/methods/docuware/deliveryNoteEmail.js index 1f9d7556f..1557a3a87 100644 --- a/back/methods/docuware/deliveryNoteEmail.js +++ b/back/methods/docuware/deliveryNoteEmail.js @@ -4,25 +4,25 @@ module.exports = Self => { Self.remoteMethodCtx('deliveryNoteEmail', { description: 'Sends the delivery note email with an docuware attached PDF', accessType: 'WRITE', + accessScopes: ['docuwareDeliveryNoteEmail'], accepts: [ { arg: 'id', - type: 'string', + type: 'number', required: true, description: 'The ticket id', - http: {source: 'path'} - }, - { - arg: 'recipient', - type: 'string', - description: 'The recipient email', - required: true, }, { arg: 'recipientId', type: 'number', description: 'The client id', - required: false + required: true + }, + { + arg: 'recipient', + type: 'string', + description: 'The recipient email', + required: false, } ], returns: [ @@ -41,12 +41,13 @@ module.exports = Self => { } ], http: { - path: '/:id/delivery-note-email', + path: '/delivery-note-email', verb: 'POST' } }); - Self.deliveryNoteEmail = async(ctx, id) => { + Self.deliveryNoteEmail = async(ctx, id, recipientId, recipient) => { + const models = Self.app.models; const args = Object.assign({}, ctx.args); const params = { recipient: args.recipient, @@ -57,9 +58,14 @@ module.exports = Self => { for (const param in args) params[param] = args[param]; + if (!recipient) { + client = await models.Client.findById(recipientId, {fields: ['email']}); + params.recipient = client.email; + } + const email = new Email('delivery-note', params); - const docuwareFile = await Self.app.models.Docuware.download(ctx, id, 'deliveryNote'); + const docuwareFile = await models.Docuware.download(ctx, id, 'deliveryNote'); return email.send({ overrideAttachments: true, diff --git a/back/methods/image/download.js b/back/methods/image/download.js index 3a8bcf30e..c4037b809 100644 --- a/back/methods/image/download.js +++ b/back/methods/image/download.js @@ -67,7 +67,7 @@ module.exports = Self => { if (!image) return false; - const hasReadRole = models.ImageCollection.hasReadRole(ctx, collection); + const hasReadRole = await models.ImageCollection.hasReadRole(ctx, collection); if (!hasReadRole) throw new UserError(`You don't have enough privileges`); diff --git a/back/methods/vn-user/acl.js b/back/methods/vn-user/acl.js index 4f4bf0623..b72b19381 100644 --- a/back/methods/vn-user/acl.js +++ b/back/methods/vn-user/acl.js @@ -23,13 +23,7 @@ module.exports = Self => { let models = Self.app.models; let user = await Self.findById(userId, { - fields: ['id', 'name', 'nickname', 'email', 'lang'], - include: { - relation: 'userConfig', - scope: { - fields: ['darkMode'] - } - } + fields: ['id', 'name', 'nickname', 'email', 'lang'] }); let roles = await models.RoleMapping.find({ diff --git a/back/models/dms-type.json b/back/models/dms-type.json index c7a1815fe..de3d564b4 100644 --- a/back/models/dms-type.json +++ b/back/models/dms-type.json @@ -44,4 +44,4 @@ "principalId": "$everyone", "permission": "ALLOW" }] -} \ No newline at end of file +} diff --git a/back/models/image-collection.js b/back/models/image-collection.js index 2c4d274ee..69905beca 100644 --- a/back/models/image-collection.js +++ b/back/models/image-collection.js @@ -9,10 +9,11 @@ module.exports = Self => { * @return {boolean} True for user with read privileges */ Self.hasReadRole = async(ctx, name, options) => { - const collection = await Self.findOne({where: {name}}, { + const collection = await Self.findOne({ include: { relation: 'readRole' - } + }, + where: {name} }, options); return await hasRole(ctx, collection, options); diff --git a/db/changes/230202/00-itemConfig.sql b/db/.archive/230202/00-itemConfig.sql similarity index 100% rename from db/changes/230202/00-itemConfig.sql rename to db/.archive/230202/00-itemConfig.sql diff --git a/db/changes/230401/00-ACL.sql b/db/.archive/230401/00-ACL.sql similarity index 100% rename from db/changes/230401/00-ACL.sql rename to db/.archive/230401/00-ACL.sql diff --git a/db/changes/230401/00-ACL_tag_update.sql b/db/.archive/230401/00-ACL_tag_update.sql similarity index 100% rename from db/changes/230401/00-ACL_tag_update.sql rename to db/.archive/230401/00-ACL_tag_update.sql diff --git a/db/changes/230401/00-createWorker.sql b/db/.archive/230401/00-createWorker.sql similarity index 100% rename from db/changes/230401/00-createWorker.sql rename to db/.archive/230401/00-createWorker.sql diff --git a/db/changes/230401/00-ticket_canAdvance.sql b/db/.archive/230401/00-ticket_canAdvance.sql similarity index 100% rename from db/changes/230401/00-ticket_canAdvance.sql rename to db/.archive/230401/00-ticket_canAdvance.sql diff --git a/db/changes/230401/00-updateIsToBeMailed.sql b/db/.archive/230401/00-updateIsToBeMailed.sql similarity index 100% rename from db/changes/230401/00-updateIsToBeMailed.sql rename to db/.archive/230401/00-updateIsToBeMailed.sql diff --git a/db/changes/230403/00-clienteCompensado.sql b/db/.archive/230403/00-clienteCompensado.sql similarity index 100% rename from db/changes/230403/00-clienteCompensado.sql rename to db/.archive/230403/00-clienteCompensado.sql diff --git a/db/changes/230404/00-ticket_canAdvance.sql b/db/.archive/230404/00-ticket_canAdvance.sql similarity index 100% rename from db/changes/230404/00-ticket_canAdvance.sql rename to db/.archive/230404/00-ticket_canAdvance.sql diff --git a/db/changes/230601/00-acl_claim.sql b/db/.archive/230601/00-acl_claim.sql similarity index 100% rename from db/changes/230601/00-acl_claim.sql rename to db/.archive/230601/00-acl_claim.sql diff --git a/db/changes/230601/00-acl_notifications.sql b/db/.archive/230601/00-acl_notifications.sql similarity index 100% rename from db/changes/230601/00-acl_notifications.sql rename to db/.archive/230601/00-acl_notifications.sql diff --git a/db/changes/230601/00-itemConfig_warehouseFk.sql b/db/.archive/230601/00-itemConfig_warehouseFk.sql similarity index 100% rename from db/changes/230601/00-itemConfig_warehouseFk.sql rename to db/.archive/230601/00-itemConfig_warehouseFk.sql diff --git a/db/changes/230601/00-uniqueKeyNotificationSubscription.sql b/db/.archive/230601/00-uniqueKeyNotificationSubscription.sql similarity index 100% rename from db/changes/230601/00-uniqueKeyNotificationSubscription.sql rename to db/.archive/230601/00-uniqueKeyNotificationSubscription.sql diff --git a/db/changes/230601/01-alter_notSubs.sql b/db/.archive/230601/01-alter_notSubs.sql similarity index 100% rename from db/changes/230601/01-alter_notSubs.sql rename to db/.archive/230601/01-alter_notSubs.sql diff --git a/db/changes/230801/00-acl_itemConfig.sql b/db/.archive/230801/00-acl_itemConfig.sql similarity index 100% rename from db/changes/230801/00-acl_itemConfig.sql rename to db/.archive/230801/00-acl_itemConfig.sql diff --git a/db/changes/230801/00-supplierIsVies.sql b/db/.archive/230801/00-supplierIsVies.sql similarity index 100% rename from db/changes/230801/00-supplierIsVies.sql rename to db/.archive/230801/00-supplierIsVies.sql diff --git a/db/changes/230801/00-workerLocker.sql b/db/.archive/230801/00-workerLocker.sql similarity index 100% rename from db/changes/230801/00-workerLocker.sql rename to db/.archive/230801/00-workerLocker.sql diff --git a/db/changes/230801/01-sage_supplierAdd.sql b/db/.archive/230801/01-sage_supplierAdd.sql similarity index 100% rename from db/changes/230801/01-sage_supplierAdd.sql rename to db/.archive/230801/01-sage_supplierAdd.sql diff --git a/db/changes/231001/00-delivery.sql b/db/.archive/231001/00-delivery.sql similarity index 100% rename from db/changes/231001/00-delivery.sql rename to db/.archive/231001/00-delivery.sql diff --git a/db/changes/231001/00-invoiceOut.sql b/db/.archive/231001/00-invoiceOut.sql similarity index 100% rename from db/changes/231001/00-invoiceOut.sql rename to db/.archive/231001/00-invoiceOut.sql diff --git a/db/changes/231001/00-invoiceOut_getWeight.sql b/db/.archive/231001/00-invoiceOut_getWeight.sql similarity index 100% rename from db/changes/231001/00-invoiceOut_getWeight.sql rename to db/.archive/231001/00-invoiceOut_getWeight.sql diff --git a/db/changes/231001/00-report.sql b/db/.archive/231001/00-report.sql similarity index 100% rename from db/changes/231001/00-report.sql rename to db/.archive/231001/00-report.sql diff --git a/db/changes/231001/01-invoiceOut_getMaxIssued.sql b/db/.archive/231001/01-invoiceOut_getMaxIssued.sql similarity index 100% rename from db/changes/231001/01-invoiceOut_getMaxIssued.sql rename to db/.archive/231001/01-invoiceOut_getMaxIssued.sql diff --git a/db/changes/231001/02-invoiceOut_new.sql b/db/.archive/231001/02-invoiceOut_new.sql similarity index 100% rename from db/changes/231001/02-invoiceOut_new.sql rename to db/.archive/231001/02-invoiceOut_new.sql diff --git a/db/changes/231001/03-ticketPackaging_add.sql b/db/.archive/231001/03-ticketPackaging_add.sql similarity index 100% rename from db/changes/231001/03-ticketPackaging_add.sql rename to db/.archive/231001/03-ticketPackaging_add.sql diff --git a/db/Dockerfile b/db/Dockerfile index cb3aa741c..053fbcee6 100644 --- a/db/Dockerfile +++ b/db/Dockerfile @@ -1,9 +1,10 @@ -FROM mariadb:10.7.3 +FROM mariadb:10.7.5 ENV MYSQL_ROOT_PASSWORD root ENV TZ Europe/Madrid - +ARG MOCKDATE=2001-01-01 11:00:00 ARG DEBIAN_FRONTEND=noninteractive + RUN apt-get update \ && apt-get install -y --no-install-recommends curl ca-certificates \ && curl -sL https://apt.verdnatura.es/conf/verdnatura.gpg | apt-key add - \ @@ -31,14 +32,15 @@ COPY \ import-changes.sh \ config.ini \ dump/mysqlPlugins.sql \ - dump/mockDate.sql \ dump/structure.sql \ + dump/mockDate.sql \ dump/dumpedFixtures.sql \ ./ RUN gosu mysql docker-init.sh \ && docker-dump.sh mysqlPlugins \ - && docker-dump.sh mockDate \ && docker-dump.sh structure \ + && sed -i -e 's/@mockDate/'"$MOCKDATE"'/g' mockDate.sql \ + && docker-dump.sh mockDate \ && docker-dump.sh dumpedFixtures \ && gosu mysql docker-temp-stop.sh diff --git a/db/changes/230601/00-acl_receiptEmail.sql b/db/changes/231801/00-acl_receiptEmail.sql similarity index 100% rename from db/changes/230601/00-acl_receiptEmail.sql rename to db/changes/231801/00-acl_receiptEmail.sql diff --git a/db/changes/231801/00-client_setRatingAcl.sql b/db/changes/231801/00-client_setRatingAcl.sql index b041b131a..6687b11ec 100644 --- a/db/changes/231801/00-client_setRatingAcl.sql +++ b/db/changes/231801/00-client_setRatingAcl.sql @@ -27,7 +27,6 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalTyp ('Client', 'summary', '*', 'ALLOW', 'ROLE', 'employee'), ('Client', 'updateAddress', '*', 'ALLOW', 'ROLE', 'employee'), ('Client', 'updateFiscalData', '*', 'ALLOW', 'ROLE', 'employee'), - ('Client', 'updateUser', '*', 'ALLOW', 'ROLE', 'employee'), ('Client', 'uploadFile', '*', 'ALLOW', 'ROLE', 'employee'), ('Client', 'campaignMetricsPdf', '*', 'ALLOW', 'ROLE', 'employee'), ('Client', 'campaignMetricsEmail', '*', 'ALLOW', 'ROLE', 'employee'), diff --git a/db/changes/231401/00-deviceProduction.sql b/db/changes/231801/00-deviceProduction.sql similarity index 100% rename from db/changes/231401/00-deviceProduction.sql rename to db/changes/231801/00-deviceProduction.sql diff --git a/db/changes/232001/00-createWorker.sql b/db/changes/232001/00-createWorker.sql index 3e5af683f..0ea7ecbe8 100644 --- a/db/changes/232001/00-createWorker.sql +++ b/db/changes/232001/00-createWorker.sql @@ -1,4 +1,4 @@ - INSERT INTO `vn`.`businessType` (`code`, `description`) +INSERT INTO `vn`.`businessType` (`code`, `description`) VALUES ('worker','Trabajador'); ALTER TABLE `vn`.`workerConfig` ADD businessTypeFk varchar(100) NULL diff --git a/db/changes/232001/00-procedurecanAdvance.sql b/db/changes/232001/00-procedurecanAdvance.sql new file mode 100644 index 000000000..9d5c24296 --- /dev/null +++ b/db/changes/232001/00-procedurecanAdvance.sql @@ -0,0 +1,127 @@ +DELIMITER $$ +$$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT) +BEGIN +/** + * Devuelve los tickets y la cantidad de lineas de venta que se pueden adelantar. + * + * @param vDateFuture Fecha de los tickets que se quieren adelantar. + * @param vDateToAdvance Fecha a cuando se quiere adelantar. + * @param vWarehouseFk Almacén + */ + + DECLARE vDateInventory DATE; + + SELECT inventoried INTO vDateInventory FROM config; + + DROP TEMPORARY TABLE IF EXISTS tmp.stock; + CREATE TEMPORARY TABLE tmp.stock + (itemFk INT PRIMARY KEY, + amount INT) + ENGINE = MEMORY; + + INSERT INTO tmp.stock(itemFk, amount) + SELECT itemFk, SUM(quantity) amount FROM + ( + SELECT itemFk, quantity + FROM itemTicketOut + WHERE shipped >= vDateInventory + AND shipped < vDateFuture + AND warehouseFk = vWarehouseFk + UNION ALL + SELECT itemFk, quantity + FROM itemEntryIn + WHERE landed >= vDateInventory + AND landed < vDateFuture + AND isVirtualStock = FALSE + AND warehouseInFk = vWarehouseFk + UNION ALL + SELECT itemFk, quantity + FROM itemEntryOut + WHERE shipped >= vDateInventory + AND shipped < vDateFuture + AND warehouseOutFk = vWarehouseFk + ) t + GROUP BY itemFk HAVING amount != 0; + + DROP TEMPORARY TABLE IF EXISTS tmp.filter; + CREATE TEMPORARY TABLE tmp.filter + (INDEX (id)) +SELECT + origin.ticketFk futureId, + dest.ticketFk id, + dest.state, + origin.futureState, + origin.futureIpt, + dest.ipt, + origin.workerFk, + origin.futureLiters, + origin.futureLines, + dest.shipped, + origin.shipped futureShipped, + dest.totalWithVat, + origin.totalWithVat futureTotalWithVat, + dest.agency, + origin.futureAgency, + dest.lines, + dest.liters, + origin.futureLines - origin.hasStock AS notMovableLines, + (origin.futureLines = origin.hasStock) AS isFullMovable, + origin.classColor, + dest.classColor futureClassColor + FROM ( + SELECT + s.ticketFk, + t.workerFk, + t.shipped, + t.totalWithVat, + st.name futureState, + t.addressFk, + am.name futureAgency, + count(s.id) futureLines, + GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt, + CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters, + SUM((s.quantity <= IFNULL(st.amount,0))) hasStock, + st.classColor + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN saleVolume sv ON sv.saleFk = s.id + JOIN item i ON i.id = s.itemFk + JOIN ticketState ts ON ts.ticketFk = t.id + JOIN state st ON st.id = ts.stateFk + JOIN agencyMode am ON t.agencyModeFk = am.id + LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk + LEFT JOIN tmp.stock st ON st.itemFk = i.id + WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture) + AND t.warehouseFk = vWarehouseFk + GROUP BY t.id + ) origin + JOIN ( + SELECT + t.id ticketFk, + t.addressFk, + st.name state, + GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt, + t.shipped, + t.totalWithVat, + am.name agency, + CAST(SUM(litros) AS DECIMAL(10,0)) liters, + CAST(COUNT(*) AS DECIMAL(10,0)) `lines`, + st.classColor + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN saleVolume sv ON sv.saleFk = s.id + JOIN item i ON i.id = s.itemFk + JOIN ticketState ts ON ts.ticketFk = t.id + JOIN state st ON st.id = ts.stateFk + JOIN agencyMode am ON t.agencyModeFk = am.id + LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk + WHERE t.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance) + AND t.warehouseFk = vWarehouseFk + AND st.order <= 5 + GROUP BY t.id + ) dest ON dest.addressFk = origin.addressFk + WHERE origin.hasStock != 0; + DROP TEMPORARY TABLE tmp.stock; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/changes/232001/00-procedurecanbePostponed.sql b/db/changes/232001/00-procedurecanbePostponed.sql new file mode 100644 index 000000000..39aa35cd5 --- /dev/null +++ b/db/changes/232001/00-procedurecanbePostponed.sql @@ -0,0 +1,72 @@ +DELIMITER $$ +$$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canbePostponed`(vOriginDated DATE, vFutureDated DATE, vWarehouseFk INT) +BEGIN +/** + * Devuelve un listado de tickets susceptibles de fusionarse con otros tickets en el futuro + * + * @param vOriginDated Fecha en cuestión + * @param vFutureDated Fecha en el futuro a sondear + * @param vWarehouseFk Identificador de vn.warehouse + */ + DROP TEMPORARY TABLE IF EXISTS tmp.filter; + CREATE TEMPORARY TABLE tmp.filter + (INDEX (id)) + SELECT sv.ticketFk id, + sub2.id futureId, + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt, + CAST(sum(litros) AS DECIMAL(10,0)) liters, + CAST(count(*) AS DECIMAL(10,0)) `lines`, + st.name state, + sub2.iptd futureIpt, + sub2.state futureState, + t.clientFk, + t.warehouseFk, + ts.alertLevel, + t.shipped, + sub2.shipped futureShipped, + t.workerFk, + st.code stateCode, + sub2.code futureStateCode, + st.classColor + FROM vn.saleVolume sv + JOIN vn.sale s ON s.id = sv.saleFk + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.ticket t ON t.id = sv.ticketFk + JOIN vn.address a ON a.id = t.addressFk + JOIN vn.province p ON p.id = a.provinceFk + JOIN vn.country c ON c.id = p.countryFk + JOIN vn.ticketState ts ON ts.ticketFk = t.id + JOIN vn.state st ON st.id = ts.stateFk + JOIN vn.alertLevel al ON al.id = ts.alertLevel + LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id + LEFT JOIN ( + SELECT * + FROM ( + SELECT + t.addressFk, + t.id, + t.shipped, + st.name state, + st.code code, + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) iptd + FROM vn.ticket t + JOIN vn.ticketState ts ON ts.ticketFk = t.id + JOIN vn.state st ON st.id = ts.stateFk + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + WHERE t.shipped BETWEEN vFutureDated + AND util.dayend(vFutureDated) + AND t.warehouseFk = vWarehouseFk + GROUP BY t.id + ) sub + GROUP BY sub.addressFk + ) sub2 ON sub2.addressFk = t.addressFk AND t.id != sub2.id + WHERE t.shipped BETWEEN vOriginDated AND util.dayend(vOriginDated) + AND t.warehouseFk = vWarehouseFk + AND al.code = 'FREE' + AND tp.ticketFk IS NULL + GROUP BY sv.ticketFk + HAVING futureId; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/changes/232201/00-defaulterView.sql b/db/changes/232201/00-defaulterView.sql new file mode 100644 index 000000000..8b56e5945 --- /dev/null +++ b/db/changes/232201/00-defaulterView.sql @@ -0,0 +1,20 @@ +-- vn.defaulter source + +CREATE OR REPLACE +ALGORITHM = UNDEFINED VIEW `vn`.`defaulter` AS +select + `d`.`clientFk` AS `clientFk`, + `d`.`created` AS `created`, + `d`.`amount` AS `amount`, + `d`.`defaulterSinced` AS `defaulterSinced`, + `d`.`hasChanged` AS `hasChanged`, + `c`.`countryFk` AS `country`, + `c`.`payMethodFk` AS `payMethod` +from + (((`bs`.`defaulter` `d` +join `vn`.`client` `c` on + (`c`.`id` = `d`.`clientFk`)) +join `vn`.`country` `co` on + (`co`.`id` = `c`.`countryFk`)) +join `vn`.`payMethod` `pm` on + (`pm`.`id` = `c`.`payMethodFk`)); \ No newline at end of file diff --git a/db/changes/232201/00-workerConfigPayMethod.sql b/db/changes/232201/00-workerConfigPayMethod.sql new file mode 100644 index 000000000..91f477bec --- /dev/null +++ b/db/changes/232201/00-workerConfigPayMethod.sql @@ -0,0 +1,7 @@ +ALTER TABLE `vn`.`workerConfig` ADD payMethodFk tinyint(3) unsigned NULL; +ALTER TABLE `vn`.`workerConfig` ADD CONSTRAINT workerConfig_FK FOREIGN KEY (roleFk) REFERENCES account.`role`(id) ON DELETE RESTRICT ON UPDATE CASCADE; +ALTER TABLE `vn`.`workerConfig` ADD CONSTRAINT workerConfig_FK_1 FOREIGN KEY (payMethodFk) REFERENCES `vn`.`payMethod`(id) ON DELETE SET NULL ON UPDATE CASCADE; +-- Cuando se apruebe el PR quitar y poner en redmine para hacerse manualmente +UPDATE `vn`.`workerConfig` + SET payMethodFk = 4 + WHERE id=1; diff --git a/db/changes/232401/.gitkeep b/db/changes/232401/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/db/changes/232401/00-useSpecificsAcls.sql b/db/changes/232401/00-useSpecificsAcls.sql new file mode 100644 index 000000000..0d17ca948 --- /dev/null +++ b/db/changes/232401/00-useSpecificsAcls.sql @@ -0,0 +1,121 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('Ticket', 'editDiscount', 'WRITE', 'ALLOW', 'ROLE', 'claimManager'), + ('Ticket', 'editDiscount', 'WRITE', 'ALLOW', 'ROLE', 'salesPerson'), + ('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'salesAssistant'), + ('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'deliveryBoss'), + ('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'buyer'), + ('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'claimManager'), + ('Ticket', 'deleteTicketWithPartPrepared', 'WRITE', 'ALLOW', 'ROLE', 'salesAssistant'), + ('Ticket', 'editZone', 'WRITE', 'ALLOW', 'ROLE', 'deliveryBoss'), + ('State', 'editableStates', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('State', 'seeEditableStates', 'READ', 'ALLOW', 'ROLE', 'administrative'), + ('State', 'seeEditableStates', 'READ', 'ALLOW', 'ROLE', 'production'), + ('State', 'isSomeEditable', 'READ', 'ALLOW', 'ROLE', 'salesPerson'), + ('State', 'isAllEditable', 'READ', 'ALLOW', 'ROLE', 'production'), + ('State', 'isAllEditable', 'READ', 'ALLOW', 'ROLE', 'administrative'), + ('Agency', 'seeExpired', 'READ', 'ALLOW', 'ROLE', 'administrative'), + ('Agency', 'seeExpired', 'READ', 'ALLOW', 'ROLE', 'productionBoss'), + ('Claim', 'createAfterDeadline', 'WRITE', 'ALLOW', 'ROLE', 'claimManager'), + ('Client', 'editAddressLogifloraAllowed', 'WRITE', 'ALLOW', 'ROLE', 'salesAssistant'), + ('Client', 'editFiscalDataWithoutTaxDataCheck', 'WRITE', 'ALLOW', 'ROLE', 'salesAssistant'), + ('Client', 'editVerifiedDataWithoutTaxDataCheck', 'WRITE', 'ALLOW', 'ROLE', 'salesAssistant'), + ('Client', 'editCredit', 'WRITE', 'ALLOW', 'ROLE', 'financialBoss'), + ('Client', 'isNotEditableCredit', 'WRITE', 'ALLOW', 'ROLE', 'financialBoss'), + ('InvoiceOut', 'canCreatePdf', 'WRITE', 'ALLOW', 'ROLE', 'invoicing'), + ('Supplier', 'editPayMethodCheck', 'WRITE', 'ALLOW', 'ROLE', 'financial'), + ('Worker', 'isTeamBoss', 'WRITE', 'ALLOW', 'ROLE', 'teamBoss'), + ('Worker', 'forceIsSubordinate', 'READ', 'ALLOW', 'ROLE', 'hr'), + ('Claim', 'editState', 'WRITE', 'ALLOW', 'ROLE', 'claimManager'); + +DELETE FROM `salix`.`ACL` + WHERE + model = 'Claim' + AND property = '*' + AND accessType = '*'; + +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('Claim', 'find', 'READ', 'ALLOW', 'ROLE', 'salesPerson'), + ('Claim', 'findById', 'READ', 'ALLOW', 'ROLE', 'salesPerson'), + ('Claim', 'findOne', 'READ', 'ALLOW', 'ROLE', 'salesPerson'), + ('Claim', 'getSummary', 'READ', 'ALLOW', 'ROLE', 'salesPerson'), + ('Claim', 'updateClaim', 'WRITE', 'ALLOW', 'ROLE', 'salesPerson'), + ('Claim', 'regularizeClaim', 'WRITE', 'ALLOW', 'ROLE', 'claimManager'), + ('Claim', 'updateClaimDestination', 'WRITE', 'ALLOW', 'ROLE', 'claimManager'), + ('Claim', 'downloadFile', 'READ', 'ALLOW', 'ROLE', 'claimManager'), + ('Claim', 'deleteById', 'WRITE', 'ALLOW', 'ROLE', 'claimManager'), + ('Claim', 'filter', 'READ', 'ALLOW', 'ROLE', 'salesPerson'), + ('Claim', 'logs', 'READ', 'ALLOW', 'ROLE', 'claimManager'); + +DELETE FROM `salix`.`ACL` + WHERE + model = 'Ticket' + AND property = '*' + AND accessType = '*'; + +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('Ticket', 'find', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'findById', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'findOne', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'getVolume', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'getTotalVolume', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'summary', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'priceDifference', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'componentUpdate', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'new', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'isEditable', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'setDeleted', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'restore', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'getSales', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'getSalesPersonMana', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'filter', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'makeInvoice', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'updateEditableTicket', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'updateDiscount', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'transferSales', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'sendSms', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'isLocked', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'freightCost', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'getComponentsSum', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'updateAttributes', 'WRITE', 'ALLOW', 'ROLE', 'delivery'), -- Change Priority in Route tickets + ('Ticket', 'deliveryNoteCsv', 'READ', 'ALLOW', 'ROLE', 'employee'); + +DELETE FROM `salix`.`ACL` + WHERE + model = 'State' + AND property = '*' + AND accessType = 'READ'; + +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('State', 'find', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('State', 'findById', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('State', 'findOne', 'READ', 'ALLOW', 'ROLE', 'employee'); + +DELETE FROM `salix`.`ACL` + WHERE + model = 'Worker' + AND property = '*' + AND accessType = 'READ'; + +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('Worker', 'find', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Worker', 'findById', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Worker', 'findOne', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Worker', 'filter', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Worker', 'getWorkedHours', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Worker', 'active', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Worker', 'activeWithRole', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Worker', 'uploadFile', 'WRITE', 'ALLOW', 'ROLE', 'hr'), + ('Worker', 'contracts', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Worker', 'holidays', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Worker', 'activeContract', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Worker', 'activeWithInheritedRole', 'READ', 'ALLOW', 'ROLE', 'employee'); + +DELETE FROM `salix`.`ACL` + WHERE model = 'Client' + AND property = 'updateUser' + AND accessType = '*'; diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql index 39388e140..abb5516f7 100644 --- a/db/dump/dumpedFixtures.sql +++ b/db/dump/dumpedFixtures.sql @@ -1,8 +1,8 @@ USE `util`; --- MariaDB dump 10.19 Distrib 10.5.18-MariaDB, for debian-linux-gnu (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.15-MariaDB, for debian-linux-gnu (x86_64) -- --- Host: db-proxy.verdnatura.es Database: util +-- Host: db.verdnatura.es Database: util -- ------------------------------------------------------ -- Server version 10.7.7-MariaDB-1:10.7.7+maria~deb11-log @@ -22,7 +22,7 @@ USE `util`; LOCK TABLES `config` WRITE; /*!40000 ALTER TABLE `config` DISABLE KEYS */; -INSERT INTO `config` VALUES (1,'230404',0,'production',NULL); +INSERT INTO `config` VALUES (1,'231801',0,'production',NULL,'2001-01-01 11:00:00',NULL,0); /*!40000 ALTER TABLE `config` ENABLE KEYS */; UNLOCK TABLES; @@ -32,7 +32,7 @@ UNLOCK TABLES; LOCK TABLES `version` WRITE; /*!40000 ALTER TABLE `version` DISABLE KEYS */; -INSERT INTO `version` VALUES ('salix','10230','53f69ae8e526a4a5d827c237a5b076d38507b392','2020-11-09 11:06:43',NULL),('vn-database','10481','0b4092f49d8b8b4f50623246cbbcad53ed0eb057','2023-02-20 08:46:42','10481'); +INSERT INTO `version` VALUES ('salix','10230','53f69ae8e526a4a5d827c237a5b076d38507b392','2020-11-09 11:06:43',NULL),('vn-database','10598','11ac980456205f7851dc94367d04243d33ca3c0b','2023-05-16 08:20:30','10600'); /*!40000 ALTER TABLE `version` ENABLE KEYS */; UNLOCK TABLES; @@ -42,7 +42,7 @@ UNLOCK TABLES; LOCK TABLES `versionLog` WRITE; /*!40000 ALTER TABLE `versionLog` DISABLE KEYS */; -INSERT INTO `versionLog` VALUES ('vn-database','00001','00-test.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL),('vn-database','00003','00-sage.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL),('vn-database','10008','00-alterRoleConfig.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL),('vn-database','10014','00-rolePrefix.sql','jenkins@10.0.2.68','2022-02-11 00:13:25',NULL,NULL),('vn-database','10017','01-firstScript.sql','jenkins@10.0.2.70','2022-03-09 11:36:54',NULL,NULL),('vn-database','10021','00-bankAccount.sql','jenkins@10.0.2.69','2022-03-16 14:11:22',NULL,NULL),('vn-database','10023','00-firstScript.sql','jenkins@10.0.2.69','2022-03-16 15:05:29',NULL,NULL),('vn-database','10026','00-invoiceInIntrastat.sql','jenkins@10.0.2.69','2022-03-21 15:10:53',NULL,NULL),('vn-database','10027','00-Clientes_cedidos.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10028','00-item_last_buy_.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10029','00-bankToViewAccountingToTable.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10030','00-KkejarNiche.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10036','00-updateBuyConfig.sql','jenkins@10.0.2.69','2022-03-29 12:36:54',NULL,NULL),('vn-database','10037','00-firstScript.sql','jenkins@10.0.2.69','2022-03-28 11:14:26',NULL,NULL),('vn-database','10038','00-printServerQueue.sql','jenkins@10.0.2.69','2022-03-29 08:13:24',NULL,NULL),('vn-database','10048','00-firstScript.sql','jenkins@10.0.2.69','2022-03-30 12:29:06',NULL,NULL),('vn-database','10058','00-vehicleAddFields.sql','jenkins@10.0.2.69','2022-04-06 08:48:34',NULL,NULL),('vn-database','10060','00-firstScript.sql','jenkins@10.0.2.69','2022-04-07 08:50:11',NULL,NULL),('vn-database','10062','00-firstScript.sql','jenkins@10.0.2.69','2022-04-06 10:51:45',NULL,NULL),('vn-database','10064','00-firstScript.sql','jenkins@10.0.2.69','2022-04-06 13:57:11',NULL,NULL),('vn-database','10066','00-firstScript.sql','jenkins@10.0.2.69','2022-04-07 08:50:12',NULL,NULL),('vn-database','10067','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 10:18:20',NULL,NULL),('vn-database','10071','00-packingSiteLog.sql','jenkins@10.0.2.69','2022-04-08 09:37:30',NULL,NULL),('vn-database','10072','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 11:01:46',NULL,NULL),('vn-database','10073','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 13:40:56',NULL,NULL),('vn-database','10074','00-firstScript.sql','jenkins@10.0.2.69','2022-04-10 13:15:05',NULL,NULL),('vn-database','10077','00-firstScript.sql','jenkins@10.0.2.69','2022-04-12 08:07:15',NULL,NULL),('vn-database','10078','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 07:44:21',NULL,NULL),('vn-database','10079','00-firstScript.sql','jenkins@10.0.2.69','2022-04-12 12:01:37',NULL,NULL),('vn-database','10086','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 08:58:34',NULL,NULL),('vn-database','10087','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 09:39:49',NULL,NULL),('vn-database','10088','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 15:05:12',NULL,NULL),('vn-database','10089','00-firstScript.sql','jenkins@10.0.2.69','2022-04-18 14:12:52',NULL,NULL),('vn-database','10090','00-firstScript.sql','jenkins@10.0.2.69','2022-04-18 14:34:46',NULL,NULL),('vn-database','10092','00-firstScript.sql','jenkins@10.0.2.69','2022-04-19 14:45:46',NULL,NULL),('vn-database','10093','00-autoradioConfig.sql','jenkins@10.0.2.69','2022-05-03 09:16:47',NULL,NULL),('vn-database','10094','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 10:57:30',NULL,NULL),('vn-database','10097','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:12:59',NULL,NULL),('vn-database','10099','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 14:35:27',NULL,NULL),('vn-database','10100','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 14:35:27',NULL,NULL),('vn-database','10101','00-firstScript.sql','jenkins@10.0.2.69','2022-04-21 14:59:31',NULL,NULL),('vn-database','10103','00-awbVolume.sql','jenkins@10.0.2.69','2022-05-05 10:12:59',NULL,NULL),('vn-database','10104','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:12:59',NULL,NULL),('vn-database','10105','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:13:00',NULL,NULL),('vn-database','10107','00-firstScript.sql','jenkins@10.0.2.69','2022-04-23 10:53:53',NULL,NULL),('vn-database','10112','00-firstScript.sql','jenkins@10.0.2.69','2022-05-09 09:14:53',NULL,NULL),('vn-database','10113','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:13:00',NULL,NULL),('vn-database','10114','00-updateConfig.sql','jenkins@10.0.2.69','2022-04-27 13:37:25',NULL,NULL),('vn-database','10116','00-firstScript.sql','jenkins@10.0.2.69','2022-04-28 11:10:14',NULL,NULL),('vn-database','10118','00-firstScript.sql','jenkins@10.0.2.69','2022-04-29 08:10:15',NULL,NULL),('vn-database','10119','00-AfegirFKPart1.sql','jenkins@10.0.2.69','2022-05-05 10:13:00',NULL,NULL),('vn-database','10119','01-AfegirFkPart2.sql','jenkins@10.0.2.69','2022-05-05 10:22:25',NULL,NULL),('vn-database','10125','00-firstScript.sql','jenkins@10.0.2.68','2022-05-18 18:44:30',NULL,NULL),('vn-database','10127','00-firstScript.sql','jenkins@10.0.2.69','2022-05-02 11:04:46',NULL,NULL),('vn-database','10128','00-firstScript.sql','jenkins@10.0.2.69','2022-05-02 13:04:31',NULL,NULL),('vn-database','10129','00-firstScript.sql','jenkins@10.0.2.69','2022-05-03 08:21:01',NULL,NULL),('vn-database','10132','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:22:25',NULL,NULL),('vn-database','10133','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 14:32:30',NULL,NULL),('vn-database','10134','00-firstScript.sql','jenkins@10.0.2.69','2022-05-06 07:45:25',NULL,NULL),('vn-database','10135','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 08:46:17',NULL,NULL),('vn-database','10136','00-workerTimeControl.sql','jenkins@10.0.2.69','2022-05-09 13:51:12',NULL,NULL),('vn-database','10138','00-firstScript.sql','jenkins@10.0.2.69','2022-05-10 13:58:05',NULL,NULL),('vn-database','10139','00-firstScript.sql','jenkins@10.0.2.68','2022-05-16 14:32:37',NULL,NULL),('vn-database','10139','01-secondScript.sql','jenkins@10.0.2.68','2022-05-17 12:16:13',NULL,NULL),('vn-database','10141','00-firstScript.sql','jenkins@10.0.2.70','2022-05-12 08:27:31',NULL,NULL),('vn-database','10142','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:20:31',NULL,NULL),('vn-database','10143','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:20:31',NULL,NULL),('vn-database','10144','00-AfegirFKPArt1.sql','jenkins@10.0.2.68','2022-05-20 09:22:33',NULL,NULL),('vn-database','10144','00-firstScript.sql','jenkins@10.0.2.68','2022-05-13 09:44:25',NULL,NULL),('vn-database','10147','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:33',NULL,NULL),('vn-database','10149','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:33',NULL,NULL),('vn-database','10150','00-firstScript.sql','jenkins@10.0.2.68','2022-05-17 09:57:16',NULL,NULL),('vn-database','10152','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:34',NULL,NULL),('vn-database','10153','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:34',NULL,NULL),('vn-database','10154','00-compressionKk.sql','jenkins@10.0.2.68','2022-05-20 09:22:34',NULL,NULL),('vn-database','10157','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:35',NULL,NULL),('vn-database','10158','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:21',NULL,NULL),('vn-database','10160','00-firstScript.sql','jenkins@10.0.2.69','2022-06-30 09:30:50',NULL,NULL),('vn-database','10163','00-firstScript.sql','jenkins@10.0.2.68','2022-05-23 08:17:14',NULL,NULL),('vn-database','10164','00-borrarSectorsDesus.sql','jenkins@10.0.2.68','2022-06-02 12:47:21',NULL,NULL),('vn-database','10165','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10166','00-firstScript.sql','jenkins@10.0.2.68','2022-05-24 16:11:21',NULL,NULL),('vn-database','10167','00-renameVnActiveContrat.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10168','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10169','00-createTableBankEntityConfig.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10169','02-addNotNullToBankEntityBic.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10171','00-volumeConfig.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-18 14:11:11',NULL,NULL),('vn-database','10171','01-itemWeight.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-18 16:01:34',NULL,NULL),('vn-database','10171','02-agencymode.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-18 16:01:34',NULL,NULL),('vn-database','10172','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10174','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 08:46:17',NULL,NULL),('vn-database','10175','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:03:41',NULL,NULL),('vn-database','10177','00-crearTablaSpecialLabels.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10178','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:24',NULL,NULL),('vn-database','10179','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:24',NULL,NULL),('vn-database','10183','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:24',NULL,NULL),('vn-database','10184','00-firstScript.sql','jenkins@10.0.2.68','2022-06-03 08:05:34',NULL,NULL),('vn-database','10185','00-firstScript.sql','jenkins@10.0.2.68','2022-06-06 09:07:45',NULL,NULL),('vn-database','10186','00-desactivar_trigger.sql','jenkins@10.0.2.68','2022-06-07 09:31:23',NULL,NULL),('vn-database','10186','01-alter_Table_buy.sql','jenkins@10.0.2.68','2022-06-07 09:34:47',NULL,NULL),('vn-database','10186','02-alter_table_entryConfig.sql','jenkins@10.0.2.68','2022-06-07 09:34:47',NULL,NULL),('vn-database','10186','04-regularizar_Sticker_Inventario.sql','jenkins@10.0.2.68','2022-06-07 09:34:51',NULL,NULL),('vn-database','10186','09-reactivar_trigger.sql','jenkins@10.0.2.68','2022-06-07 09:34:51',NULL,NULL),('vn-database','10187','00-firstScript.sql','jenkins@10.0.2.68','2022-06-06 12:37:31',NULL,NULL),('vn-database','10188','00-firstScript.sql','jenkins@10.0.2.68','2022-06-06 14:03:36',NULL,NULL),('vn-database','10189','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:03:41',NULL,NULL),('vn-database','10191','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:03:41',NULL,NULL),('vn-database','10194','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:03:41',NULL,NULL),('vn-database','10195','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:03:41',NULL,NULL),('vn-database','10200','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:04:00',NULL,NULL),('vn-database','10201','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:04:00',NULL,NULL),('vn-database','10202','00-Remove_FK_to_ediGenus.sql','jenkins@10.0.2.69','2022-06-17 09:04:00',NULL,NULL),('vn-database','10203','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:04:01',NULL,NULL),('vn-database','10204','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:04:01',NULL,NULL),('vn-database','10205','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:04:21',NULL,NULL),('vn-database','10207','00-Alter_table_entry.sql','jenkins@10.0.2.69','2022-06-16 07:22:50',NULL,NULL),('vn-database','10207','01-Update_invoiceAmount.sql','jenkins@10.0.2.69','2022-06-16 07:23:00',NULL,NULL),('vn-database','10208','00-firstScript.sql','jenkins@10.0.2.69','2022-06-30 09:31:26',NULL,NULL),('vn-database','10209','00-firstScript.sql','jenkins@10.0.2.69','2022-06-16 08:47:40',NULL,NULL),('vn-database','10210','00-firstScript.sql','jenkins@10.0.2.69','2022-06-16 17:39:17',1046,'Base de datos no seleccionada'),('vn-database','10211','01-firstScript.sql','jenkins@10.0.2.69','2022-06-17 07:11:27',NULL,NULL),('vn-database','10215','00-renameIsInventory.sql','jenkins@10.0.2.69','2022-06-30 09:31:26',NULL,NULL),('vn-database','10216','00-firstScript.sql','jenkins@10.0.2.69','2022-06-23 11:15:28',NULL,NULL),('vn-database','10216','01-batchIndex.sql','jenkins@10.0.2.70','2022-06-27 18:10:55',NULL,NULL),('vn-database','10219','00-AddCollectionFkOnPackingSite.sql','jenkins@10.0.2.70','2022-06-29 09:23:42',NULL,NULL),('vn-database','10219','01-AddFkToCollectionFk.sql','jenkins@10.0.2.70','2022-06-29 09:23:43',NULL,NULL),('vn-database','10220','00-createPersonalProtectionEquipment.sql','jenkins@10.0.2.69','2022-06-30 09:31:26',NULL,NULL),('vn-database','10222','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:12:40',NULL,NULL),('vn-database','10223','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:13:52',NULL,NULL),('vn-database','10224','00-cosetes.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-21 12:03:45',NULL,NULL),('vn-database','10229','00-firstScript.sql','jenkins@10.0.2.69','2022-07-01 11:59:34',NULL,NULL),('vn-database','10231','01-tablaEktConfig.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:25:39',NULL,NULL),('vn-database','10233','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:13:53',NULL,NULL),('vn-database','10235','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:13:53',NULL,NULL),('vn-database','10236','00-firstScript.sql','jenkins@10.0.2.69','2022-07-05 12:11:40',NULL,NULL),('vn-database','10237','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:13:53',NULL,NULL),('vn-database','10238','00-worker_mobileExtension.sql','jenkins@10.0.2.69','2022-07-14 09:14:09',NULL,NULL),('vn-database','10239','00-firstScript.sql','jenkins@10.0.2.69','2022-07-07 21:51:58',NULL,NULL),('vn-database','10241','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-29 08:14:01',NULL,NULL),('vn-database','10242','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:14:32',NULL,NULL),('vn-database','10243','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:14:32',NULL,NULL),('vn-database','10245','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:34:51',NULL,NULL),('vn-database','10247','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:34:51',NULL,NULL),('vn-database','10248','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-20 17:27:51',NULL,NULL),('vn-database','10250','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:36:40',NULL,NULL),('vn-database','10253','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:36:57',NULL,NULL),('vn-database','10254','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:38:48',NULL,NULL),('vn-database','10256','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:38:48',NULL,NULL),('vn-database','10258','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-12-16 09:14:48',NULL,NULL),('vn-database','10259','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-02 08:54:56',NULL,NULL),('vn-database','10261','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-22 08:42:20',NULL,NULL),('vn-database','10262','00-createTablepackagingWithFreight.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:13',NULL,NULL),('vn-database','10262','01-alterTablePackagingConfig.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:13',NULL,NULL),('vn-database','10262','02-insertsInicials.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:13',NULL,NULL),('vn-database','10262','03-createTablepackingWithoutFreight.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:14',NULL,NULL),('vn-database','10263','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:38:48',NULL,NULL),('vn-database','10265','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:38:48',NULL,NULL),('vn-database','10267','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:34:17',NULL,NULL),('vn-database','10267','01-fixMerge.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:34:17',NULL,NULL),('vn-database','10275','00-improvedGeneralLog.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-01 09:55:56',NULL,NULL),('vn-database','10277','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 10:26:32',NULL,NULL),('vn-database','10278','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-01 17:51:41',NULL,NULL),('vn-database','10279','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:34:17',NULL,NULL),('vn-database','10281','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:34:18',NULL,NULL),('vn-database','10282','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:34:18',NULL,NULL),('vn-database','10283','00-alterTable.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:34:18',NULL,NULL),('vn-database','10284','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-04 16:59:08',NULL,NULL),('vn-database','10285','00-firstScript.sql','jenkins@swarm-worker3.static.verdnatura.es','2022-08-05 09:19:33',NULL,NULL),('vn-database','10287','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:35:24',NULL,NULL),('vn-database','10288','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:35:24',NULL,NULL),('vn-database','10289','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:29:36',NULL,NULL),('vn-database','10291','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-10 14:19:34',NULL,NULL),('vn-database','10293','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 10:26:32',NULL,NULL),('vn-database','10297','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-16 12:43:36',NULL,NULL),('vn-database','10298','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-13 21:04:13',NULL,NULL),('vn-database','10299','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:14',NULL,NULL),('vn-database','10301','00-productionConfig.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:14',NULL,NULL),('vn-database','10301','01-drop.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:14',NULL,NULL),('vn-database','10301','02-collection.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:15',NULL,NULL),('vn-database','10302','00-CreateTableEntryType.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:15',NULL,NULL),('vn-database','10302','01-insertDataEntryType.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:15',NULL,NULL),('vn-database','10302','02-alterTableEntry.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:22',NULL,NULL),('vn-database','10303','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:23',NULL,NULL),('vn-database','10304','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:23:48',NULL,NULL),('vn-database','10304','01-altertableticket.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:23:51',NULL,NULL),('vn-database','10305','00-ektAssign.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:24:52',NULL,NULL),('vn-database','10306','00-deliveryInformation.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:25:25',NULL,NULL),('vn-database','10307','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:25:26',NULL,NULL),('vn-database','10308','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:26:43',NULL,NULL),('vn-database','10309','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-06 11:37:54',NULL,NULL),('vn-database','10310','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 10:26:33',NULL,NULL),('vn-database','10311','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-06 11:37:55',NULL,NULL),('vn-database','10312','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 10:26:33',NULL,NULL),('vn-database','10313','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 10:27:21',NULL,NULL),('vn-database','10314','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-20 12:37:19',NULL,NULL),('vn-database','10315','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 10:31:43',NULL,NULL),('vn-database','10317','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 10:31:43',NULL,NULL),('vn-database','10318','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 10:31:43',NULL,NULL),('vn-database','10319','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-20 12:37:41',NULL,NULL),('vn-database','10320','00-operator.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:29:37',NULL,NULL),('vn-database','10320','01-collection.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:29:37',NULL,NULL),('vn-database','10320','02-productionConfig.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:29:38',NULL,NULL),('vn-database','10321','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 11:11:12',NULL,NULL),('vn-database','10322','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-09 09:19:05',NULL,NULL),('vn-database','10326','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:29:38',NULL,NULL),('vn-database','10328','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:29:38',NULL,NULL),('vn-database','10329','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:29:38',NULL,NULL),('vn-database','10330','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:34:30',NULL,NULL),('vn-database','10332','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:34:30',NULL,NULL),('vn-database','10334','00-collectionHotbed.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:34:30',NULL,NULL),('vn-database','10334','01-saleGroupDetail.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:34:32',NULL,NULL),('vn-database','10335','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-10-06 09:52:38',NULL,NULL),('vn-database','10336','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:34:32',NULL,NULL),('vn-database','10337','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:34:32',NULL,NULL),('vn-database','10339','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-19 09:41:19',NULL,NULL),('vn-database','10340','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-29 11:08:03',NULL,NULL),('vn-database','10341','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:34:32',NULL,NULL),('vn-database','10342','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-29 11:08:03',NULL,NULL),('vn-database','10343','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:35:30',NULL,NULL),('vn-database','10345','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-11-04 08:25:16',NULL,NULL),('vn-database','10347','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-29 11:08:03',NULL,NULL),('vn-database','10347','01-addVirtualField.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-29 11:08:03',NULL,NULL),('vn-database','10349','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-10-06 09:52:38',NULL,NULL),('vn-database','10350','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-30 10:11:56',NULL,NULL),('vn-database','10352','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-11-04 08:25:16',NULL,NULL),('vn-database','10353','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-10-06 09:52:38',NULL,NULL),('vn-database','10354','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-10-06 09:52:38',NULL,NULL),('vn-database','10356','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-10 22:35:00',NULL,NULL),('vn-database','10356','01-orderConfigFk.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-10 22:35:00',NULL,NULL),('vn-database','10356','02-orderConfigDrop.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-10 22:35:00',NULL,NULL),('vn-database','10357','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-10-06 09:52:38',NULL,NULL),('vn-database','10359','00-improvedGeneralLog_collate.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-10-06 09:52:39',NULL,NULL),('vn-database','10360','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-10-06 09:52:39',NULL,NULL),('vn-database','10361','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-10-06 11:16:07',NULL,NULL),('vn-database','10362','00-dropUdfs.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-10-10 11:01:15',NULL,NULL),('vn-database','10363','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-11-04 08:25:17',NULL,NULL),('vn-database','10365','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-10-13 19:30:46',NULL,NULL),('vn-database','10368','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-11-04 08:25:17',NULL,NULL),('vn-database','10369','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-10-14 13:38:06',NULL,NULL),('vn-database','10370','00-deleteForeignKey.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-17 14:32:41',NULL,NULL),('vn-database','10370','01-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-17 14:32:47',NULL,NULL),('vn-database','10370','02-deleteTable.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-17 14:32:49',NULL,NULL),('vn-database','10370','03-accion.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-17 14:32:49',NULL,NULL),('vn-database','10370','04-inter.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-17 14:32:53',NULL,NULL),('vn-database','10371','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-12 10:56:23',NULL,NULL),('vn-database','10372','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-12-16 09:14:48',NULL,NULL),('vn-database','10373','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-10-19 08:31:58',NULL,NULL),('vn-database','10378','00-rename_routeUserPercentage.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-11-04 08:25:17',NULL,NULL),('vn-database','10382','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-12-01 08:47:20',NULL,NULL),('vn-database','10383','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-17 14:32:53',NULL,NULL),('vn-database','10385','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-17 14:32:54',NULL,NULL),('vn-database','10386','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-17 14:32:54',NULL,NULL),('vn-database','10387','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-16 14:05:33',NULL,NULL),('vn-database','10388','00-resizeUtilVerionLogCode.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-12-01 08:47:20',NULL,NULL),('vn-database','10388','01-resizeUtilVersionCode.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-12-01 08:47:20',NULL,NULL),('vn-database','10390','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-12-01 08:50:16',NULL,NULL),('vn-database','10391','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-12 10:56:23',NULL,NULL),('vn-database','10394','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-12-01 08:50:24',NULL,NULL),('vn-database','10395','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-12-01 08:50:29',NULL,NULL),('vn-database','10396','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-17 15:36:38',NULL,NULL),('vn-database','10397','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-12-01 08:50:29',NULL,NULL),('vn-database','10399','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-12-01 08:50:29',NULL,NULL),('vn-database','10400','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-12-01 08:50:29',NULL,NULL),('vn-database','10402','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-21 14:11:31',NULL,NULL),('vn-database','10404','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-12-01 08:50:29',NULL,NULL),('vn-database','10405','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-16 09:58:22',NULL,NULL),('vn-database','10407','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-12-16 09:14:49',NULL,NULL),('vn-database','10408','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-12 10:56:23',NULL,NULL),('vn-database','10409','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-12-16 09:14:49',NULL,NULL),('vn-database','10412','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-30 12:45:44',NULL,NULL),('vn-database','10413','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-12 10:56:24',NULL,NULL),('vn-database','10416','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-12 10:56:24',NULL,NULL),('vn-database','10420','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-12 10:56:25',NULL,NULL),('vn-database','10421','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-12 10:56:26',NULL,NULL),('vn-database','10428','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-26 13:27:05',NULL,NULL),('vn-database','10433','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-26 13:27:05',NULL,NULL),('vn-database','10434','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-26 13:27:05',NULL,NULL),('vn-database','10435','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-13 07:30:10',NULL,NULL),('vn-database','10436','00-createFkWorker.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-16 09:58:59',NULL,NULL),('vn-database','10436','01-addStateToWorkerProductivity.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-16 09:59:00',NULL,NULL),('vn-database','10436','02-DeprecateVnSaleTrackingState.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-16 09:59:00',NULL,NULL),('vn-database','10436','03-DeprecateColumnVnSaleTrackingActionFk.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-16 09:59:01',NULL,NULL),('vn-database','10436','04-DropSchemaVnControl.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-16 09:59:01',NULL,NULL),('vn-database','10436','05-RemoveFkWorkerProductivity.sql','jenkins@db-proxy2.static.verdnatura.es','2023-02-17 14:51:19',NULL,NULL),('vn-database','10444','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-16 09:59:01',NULL,NULL),('vn-database','10445','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-16 09:59:31',NULL,NULL),('vn-database','10448','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-16 09:59:31',NULL,NULL),('vn-database','10450','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-27 08:28:04',NULL,NULL),('vn-database','10451','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-06 08:08:32',NULL,NULL),('vn-database','10452','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-31 12:30:04',NULL,NULL),('vn-database','10453','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-31 14:04:37',NULL,NULL),('vn-database','10454','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-31 12:30:04',NULL,NULL),('vn-database','10455','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-31 12:30:04',NULL,NULL),('vn-database','10456','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-31 12:00:30',NULL,NULL),('vn-database','10457','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-31 12:00:33',NULL,NULL),('vn-database','10460','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-16 09:59:31',NULL,NULL),('vn-database','10461','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-16 09:59:31',NULL,NULL),('vn-database','10463','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-03 12:59:26',NULL,NULL),('vn-database','10468','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-16 09:59:31',NULL,NULL),('vn-database','10469','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-16 09:59:31',NULL,NULL),('vn-database','10480','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-02-17 15:09:26',NULL,NULL),('vn-database','10481','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-02-17 16:37:22',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','00001','00-test.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL),('vn-database','00003','00-sage.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL),('vn-database','10008','00-alterRoleConfig.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL),('vn-database','10014','00-rolePrefix.sql','jenkins@10.0.2.68','2022-02-11 00:13:25',NULL,NULL),('vn-database','10017','01-firstScript.sql','jenkins@10.0.2.70','2022-03-09 11:36:54',NULL,NULL),('vn-database','10021','00-bankAccount.sql','jenkins@10.0.2.69','2022-03-16 14:11:22',NULL,NULL),('vn-database','10023','00-firstScript.sql','jenkins@10.0.2.69','2022-03-16 15:05:29',NULL,NULL),('vn-database','10026','00-invoiceInIntrastat.sql','jenkins@10.0.2.69','2022-03-21 15:10:53',NULL,NULL),('vn-database','10027','00-Clientes_cedidos.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10028','00-item_last_buy_.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10029','00-bankToViewAccountingToTable.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10030','00-KkejarNiche.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10036','00-updateBuyConfig.sql','jenkins@10.0.2.69','2022-03-29 12:36:54',NULL,NULL),('vn-database','10037','00-firstScript.sql','jenkins@10.0.2.69','2022-03-28 11:14:26',NULL,NULL),('vn-database','10038','00-printServerQueue.sql','jenkins@10.0.2.69','2022-03-29 08:13:24',NULL,NULL),('vn-database','10048','00-firstScript.sql','jenkins@10.0.2.69','2022-03-30 12:29:06',NULL,NULL),('vn-database','10058','00-vehicleAddFields.sql','jenkins@10.0.2.69','2022-04-06 08:48:34',NULL,NULL),('vn-database','10060','00-firstScript.sql','jenkins@10.0.2.69','2022-04-07 08:50:11',NULL,NULL),('vn-database','10062','00-firstScript.sql','jenkins@10.0.2.69','2022-04-06 10:51:45',NULL,NULL),('vn-database','10064','00-firstScript.sql','jenkins@10.0.2.69','2022-04-06 13:57:11',NULL,NULL),('vn-database','10066','00-firstScript.sql','jenkins@10.0.2.69','2022-04-07 08:50:12',NULL,NULL),('vn-database','10067','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 10:18:20',NULL,NULL),('vn-database','10071','00-packingSiteLog.sql','jenkins@10.0.2.69','2022-04-08 09:37:30',NULL,NULL),('vn-database','10072','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 11:01:46',NULL,NULL),('vn-database','10073','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 13:40:56',NULL,NULL),('vn-database','10074','00-firstScript.sql','jenkins@10.0.2.69','2022-04-10 13:15:05',NULL,NULL),('vn-database','10077','00-firstScript.sql','jenkins@10.0.2.69','2022-04-12 08:07:15',NULL,NULL),('vn-database','10078','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 07:44:21',NULL,NULL),('vn-database','10079','00-firstScript.sql','jenkins@10.0.2.69','2022-04-12 12:01:37',NULL,NULL),('vn-database','10086','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 08:58:34',NULL,NULL),('vn-database','10087','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 09:39:49',NULL,NULL),('vn-database','10088','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 15:05:12',NULL,NULL),('vn-database','10089','00-firstScript.sql','jenkins@10.0.2.69','2022-04-18 14:12:52',NULL,NULL),('vn-database','10090','00-firstScript.sql','jenkins@10.0.2.69','2022-04-18 14:34:46',NULL,NULL),('vn-database','10092','00-firstScript.sql','jenkins@10.0.2.69','2022-04-19 14:45:46',NULL,NULL),('vn-database','10093','00-autoradioConfig.sql','jenkins@10.0.2.69','2022-05-03 09:16:47',NULL,NULL),('vn-database','10094','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 10:57:30',NULL,NULL),('vn-database','10097','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:12:59',NULL,NULL),('vn-database','10099','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 14:35:27',NULL,NULL),('vn-database','10100','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 14:35:27',NULL,NULL),('vn-database','10101','00-firstScript.sql','jenkins@10.0.2.69','2022-04-21 14:59:31',NULL,NULL),('vn-database','10103','00-awbVolume.sql','jenkins@10.0.2.69','2022-05-05 10:12:59',NULL,NULL),('vn-database','10104','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:12:59',NULL,NULL),('vn-database','10105','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:13:00',NULL,NULL),('vn-database','10107','00-firstScript.sql','jenkins@10.0.2.69','2022-04-23 10:53:53',NULL,NULL),('vn-database','10112','00-firstScript.sql','jenkins@10.0.2.69','2022-05-09 09:14:53',NULL,NULL),('vn-database','10113','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:13:00',NULL,NULL),('vn-database','10114','00-updateConfig.sql','jenkins@10.0.2.69','2022-04-27 13:37:25',NULL,NULL),('vn-database','10116','00-firstScript.sql','jenkins@10.0.2.69','2022-04-28 11:10:14',NULL,NULL),('vn-database','10118','00-firstScript.sql','jenkins@10.0.2.69','2022-04-29 08:10:15',NULL,NULL),('vn-database','10119','00-AfegirFKPart1.sql','jenkins@10.0.2.69','2022-05-05 10:13:00',NULL,NULL),('vn-database','10119','01-AfegirFkPart2.sql','jenkins@10.0.2.69','2022-05-05 10:22:25',NULL,NULL),('vn-database','10125','00-firstScript.sql','jenkins@10.0.2.68','2022-05-18 18:44:30',NULL,NULL),('vn-database','10127','00-firstScript.sql','jenkins@10.0.2.69','2022-05-02 11:04:46',NULL,NULL),('vn-database','10128','00-firstScript.sql','jenkins@10.0.2.69','2022-05-02 13:04:31',NULL,NULL),('vn-database','10129','00-firstScript.sql','jenkins@10.0.2.69','2022-05-03 08:21:01',NULL,NULL),('vn-database','10132','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:22:25',NULL,NULL),('vn-database','10133','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 14:32:30',NULL,NULL),('vn-database','10134','00-firstScript.sql','jenkins@10.0.2.69','2022-05-06 07:45:25',NULL,NULL),('vn-database','10135','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 08:46:17',NULL,NULL),('vn-database','10136','00-workerTimeControl.sql','jenkins@10.0.2.69','2022-05-09 13:51:12',NULL,NULL),('vn-database','10138','00-firstScript.sql','jenkins@10.0.2.69','2022-05-10 13:58:05',NULL,NULL),('vn-database','10139','00-firstScript.sql','jenkins@10.0.2.68','2022-05-16 14:32:37',NULL,NULL),('vn-database','10139','01-secondScript.sql','jenkins@10.0.2.68','2022-05-17 12:16:13',NULL,NULL),('vn-database','10141','00-firstScript.sql','jenkins@10.0.2.70','2022-05-12 08:27:31',NULL,NULL),('vn-database','10142','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:20:31',NULL,NULL),('vn-database','10143','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:20:31',NULL,NULL),('vn-database','10144','00-AfegirFKPArt1.sql','jenkins@10.0.2.68','2022-05-20 09:22:33',NULL,NULL),('vn-database','10144','00-firstScript.sql','jenkins@10.0.2.68','2022-05-13 09:44:25',NULL,NULL),('vn-database','10147','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:33',NULL,NULL),('vn-database','10149','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:33',NULL,NULL),('vn-database','10150','00-firstScript.sql','jenkins@10.0.2.68','2022-05-17 09:57:16',NULL,NULL),('vn-database','10152','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:34',NULL,NULL),('vn-database','10153','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:34',NULL,NULL),('vn-database','10154','00-compressionKk.sql','jenkins@10.0.2.68','2022-05-20 09:22:34',NULL,NULL),('vn-database','10157','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:35',NULL,NULL),('vn-database','10158','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:21',NULL,NULL),('vn-database','10160','00-firstScript.sql','jenkins@10.0.2.69','2022-06-30 09:30:50',NULL,NULL),('vn-database','10163','00-firstScript.sql','jenkins@10.0.2.68','2022-05-23 08:17:14',NULL,NULL),('vn-database','10164','00-borrarSectorsDesus.sql','jenkins@10.0.2.68','2022-06-02 12:47:21',NULL,NULL),('vn-database','10165','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10166','00-firstScript.sql','jenkins@10.0.2.68','2022-05-24 16:11:21',NULL,NULL),('vn-database','10167','00-renameVnActiveContrat.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10168','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10169','00-createTableBankEntityConfig.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10169','02-addNotNullToBankEntityBic.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10171','00-volumeConfig.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-18 14:11:11',NULL,NULL),('vn-database','10171','01-itemWeight.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-18 16:01:34',NULL,NULL),('vn-database','10171','02-agencymode.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-18 16:01:34',NULL,NULL),('vn-database','10172','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10174','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 08:46:17',NULL,NULL),('vn-database','10175','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:03:41',NULL,NULL),('vn-database','10177','00-crearTablaSpecialLabels.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10178','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:24',NULL,NULL),('vn-database','10179','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:24',NULL,NULL),('vn-database','10183','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:24',NULL,NULL),('vn-database','10184','00-firstScript.sql','jenkins@10.0.2.68','2022-06-03 08:05:34',NULL,NULL),('vn-database','10185','00-firstScript.sql','jenkins@10.0.2.68','2022-06-06 09:07:45',NULL,NULL),('vn-database','10186','00-desactivar_trigger.sql','jenkins@10.0.2.68','2022-06-07 09:31:23',NULL,NULL),('vn-database','10186','01-alter_Table_buy.sql','jenkins@10.0.2.68','2022-06-07 09:34:47',NULL,NULL),('vn-database','10186','02-alter_table_entryConfig.sql','jenkins@10.0.2.68','2022-06-07 09:34:47',NULL,NULL),('vn-database','10186','04-regularizar_Sticker_Inventario.sql','jenkins@10.0.2.68','2022-06-07 09:34:51',NULL,NULL),('vn-database','10186','09-reactivar_trigger.sql','jenkins@10.0.2.68','2022-06-07 09:34:51',NULL,NULL),('vn-database','10187','00-firstScript.sql','jenkins@10.0.2.68','2022-06-06 12:37:31',NULL,NULL),('vn-database','10188','00-firstScript.sql','jenkins@10.0.2.68','2022-06-06 14:03:36',NULL,NULL),('vn-database','10189','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:03:41',NULL,NULL),('vn-database','10191','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:03:41',NULL,NULL),('vn-database','10194','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:03:41',NULL,NULL),('vn-database','10195','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:03:41',NULL,NULL),('vn-database','10200','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:04:00',NULL,NULL),('vn-database','10201','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:04:00',NULL,NULL),('vn-database','10202','00-Remove_FK_to_ediGenus.sql','jenkins@10.0.2.69','2022-06-17 09:04:00',NULL,NULL),('vn-database','10203','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:04:01',NULL,NULL),('vn-database','10204','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:04:01',NULL,NULL),('vn-database','10205','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:04:21',NULL,NULL),('vn-database','10207','00-Alter_table_entry.sql','jenkins@10.0.2.69','2022-06-16 07:22:50',NULL,NULL),('vn-database','10207','01-Update_invoiceAmount.sql','jenkins@10.0.2.69','2022-06-16 07:23:00',NULL,NULL),('vn-database','10208','00-firstScript.sql','jenkins@10.0.2.69','2022-06-30 09:31:26',NULL,NULL),('vn-database','10209','00-firstScript.sql','jenkins@10.0.2.69','2022-06-16 08:47:40',NULL,NULL),('vn-database','10210','00-firstScript.sql','jenkins@10.0.2.69','2022-06-16 17:39:17',1046,'Base de datos no seleccionada'),('vn-database','10211','01-firstScript.sql','jenkins@10.0.2.69','2022-06-17 07:11:27',NULL,NULL),('vn-database','10215','00-renameIsInventory.sql','jenkins@10.0.2.69','2022-06-30 09:31:26',NULL,NULL),('vn-database','10216','00-firstScript.sql','jenkins@10.0.2.69','2022-06-23 11:15:28',NULL,NULL),('vn-database','10216','01-batchIndex.sql','jenkins@10.0.2.70','2022-06-27 18:10:55',NULL,NULL),('vn-database','10219','00-AddCollectionFkOnPackingSite.sql','jenkins@10.0.2.70','2022-06-29 09:23:42',NULL,NULL),('vn-database','10219','01-AddFkToCollectionFk.sql','jenkins@10.0.2.70','2022-06-29 09:23:43',NULL,NULL),('vn-database','10220','00-createPersonalProtectionEquipment.sql','jenkins@10.0.2.69','2022-06-30 09:31:26',NULL,NULL),('vn-database','10222','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:12:40',NULL,NULL),('vn-database','10223','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:13:52',NULL,NULL),('vn-database','10224','00-cosetes.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-21 12:03:45',NULL,NULL),('vn-database','10229','00-firstScript.sql','jenkins@10.0.2.69','2022-07-01 11:59:34',NULL,NULL),('vn-database','10231','01-tablaEktConfig.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:25:39',NULL,NULL),('vn-database','10233','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:13:53',NULL,NULL),('vn-database','10235','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:13:53',NULL,NULL),('vn-database','10236','00-firstScript.sql','jenkins@10.0.2.69','2022-07-05 12:11:40',NULL,NULL),('vn-database','10237','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:13:53',NULL,NULL),('vn-database','10238','00-worker_mobileExtension.sql','jenkins@10.0.2.69','2022-07-14 09:14:09',NULL,NULL),('vn-database','10239','00-firstScript.sql','jenkins@10.0.2.69','2022-07-07 21:51:58',NULL,NULL),('vn-database','10241','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-29 08:14:01',NULL,NULL),('vn-database','10242','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:14:32',NULL,NULL),('vn-database','10243','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:14:32',NULL,NULL),('vn-database','10245','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:34:51',NULL,NULL),('vn-database','10247','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:34:51',NULL,NULL),('vn-database','10248','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-20 17:27:51',NULL,NULL),('vn-database','10250','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:36:40',NULL,NULL),('vn-database','10253','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:36:57',NULL,NULL),('vn-database','10254','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:38:48',NULL,NULL),('vn-database','10256','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:38:48',NULL,NULL),('vn-database','10258','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-12-16 09:14:48',NULL,NULL),('vn-database','10259','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-02 08:54:56',NULL,NULL),('vn-database','10261','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-22 08:42:20',NULL,NULL),('vn-database','10262','00-createTablepackagingWithFreight.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:13',NULL,NULL),('vn-database','10262','01-alterTablePackagingConfig.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:13',NULL,NULL),('vn-database','10262','02-insertsInicials.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:13',NULL,NULL),('vn-database','10262','03-createTablepackingWithoutFreight.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:14',NULL,NULL),('vn-database','10263','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:38:48',NULL,NULL),('vn-database','10265','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:38:48',NULL,NULL),('vn-database','10267','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:34:17',NULL,NULL),('vn-database','10267','01-fixMerge.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:34:17',NULL,NULL),('vn-database','10275','00-improvedGeneralLog.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-01 09:55:56',NULL,NULL),('vn-database','10277','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 10:26:32',NULL,NULL),('vn-database','10278','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-01 17:51:41',NULL,NULL),('vn-database','10279','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:34:17',NULL,NULL),('vn-database','10281','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:34:18',NULL,NULL),('vn-database','10282','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:34:18',NULL,NULL),('vn-database','10283','00-alterTable.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:34:18',NULL,NULL),('vn-database','10284','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-04 16:59:08',NULL,NULL),('vn-database','10285','00-firstScript.sql','jenkins@swarm-worker3.static.verdnatura.es','2022-08-05 09:19:33',NULL,NULL),('vn-database','10287','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:35:24',NULL,NULL),('vn-database','10288','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:35:24',NULL,NULL),('vn-database','10289','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:29:36',NULL,NULL),('vn-database','10291','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-10 14:19:34',NULL,NULL),('vn-database','10293','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 10:26:32',NULL,NULL),('vn-database','10297','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-16 12:43:36',NULL,NULL),('vn-database','10298','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-13 21:04:13',NULL,NULL),('vn-database','10299','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:14',NULL,NULL),('vn-database','10301','00-productionConfig.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:14',NULL,NULL),('vn-database','10301','01-drop.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:14',NULL,NULL),('vn-database','10301','02-collection.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:15',NULL,NULL),('vn-database','10302','00-CreateTableEntryType.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:15',NULL,NULL),('vn-database','10302','01-insertDataEntryType.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:15',NULL,NULL),('vn-database','10302','02-alterTableEntry.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:22',NULL,NULL),('vn-database','10303','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:23',NULL,NULL),('vn-database','10304','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:23:48',NULL,NULL),('vn-database','10304','01-altertableticket.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:23:51',NULL,NULL),('vn-database','10305','00-ektAssign.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:24:52',NULL,NULL),('vn-database','10306','00-deliveryInformation.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:25:25',NULL,NULL),('vn-database','10307','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:25:26',NULL,NULL),('vn-database','10308','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:26:43',NULL,NULL),('vn-database','10309','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-06 11:37:54',NULL,NULL),('vn-database','10310','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 10:26:33',NULL,NULL),('vn-database','10311','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-06 11:37:55',NULL,NULL),('vn-database','10312','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 10:26:33',NULL,NULL),('vn-database','10313','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 10:27:21',NULL,NULL),('vn-database','10314','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-20 12:37:19',NULL,NULL),('vn-database','10315','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 10:31:43',NULL,NULL),('vn-database','10317','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 10:31:43',NULL,NULL),('vn-database','10318','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 10:31:43',NULL,NULL),('vn-database','10319','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-20 12:37:41',NULL,NULL),('vn-database','10320','00-operator.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:29:37',NULL,NULL),('vn-database','10320','01-collection.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:29:37',NULL,NULL),('vn-database','10320','02-productionConfig.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:29:38',NULL,NULL),('vn-database','10321','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 11:11:12',NULL,NULL),('vn-database','10322','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-09 09:19:05',NULL,NULL),('vn-database','10326','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:29:38',NULL,NULL),('vn-database','10328','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:29:38',NULL,NULL),('vn-database','10329','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:29:38',NULL,NULL),('vn-database','10330','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:34:30',NULL,NULL),('vn-database','10332','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:34:30',NULL,NULL),('vn-database','10334','00-collectionHotbed.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:34:30',NULL,NULL),('vn-database','10334','01-saleGroupDetail.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:34:32',NULL,NULL),('vn-database','10335','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-10-06 09:52:38',NULL,NULL),('vn-database','10336','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:34:32',NULL,NULL),('vn-database','10337','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:34:32',NULL,NULL),('vn-database','10339','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-19 09:41:19',NULL,NULL),('vn-database','10340','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-29 11:08:03',NULL,NULL),('vn-database','10341','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:34:32',NULL,NULL),('vn-database','10342','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-29 11:08:03',NULL,NULL),('vn-database','10343','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-22 08:35:30',NULL,NULL),('vn-database','10345','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-11-04 08:25:16',NULL,NULL),('vn-database','10347','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-29 11:08:03',NULL,NULL),('vn-database','10347','01-addVirtualField.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-29 11:08:03',NULL,NULL),('vn-database','10349','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-10-06 09:52:38',NULL,NULL),('vn-database','10350','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-30 10:11:56',NULL,NULL),('vn-database','10352','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-11-04 08:25:16',NULL,NULL),('vn-database','10353','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-10-06 09:52:38',NULL,NULL),('vn-database','10354','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-10-06 09:52:38',NULL,NULL),('vn-database','10356','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-10 22:35:00',NULL,NULL),('vn-database','10356','01-orderConfigFk.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-10 22:35:00',NULL,NULL),('vn-database','10356','02-orderConfigDrop.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-10 22:35:00',NULL,NULL),('vn-database','10357','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-10-06 09:52:38',NULL,NULL),('vn-database','10359','00-improvedGeneralLog_collate.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-10-06 09:52:39',NULL,NULL),('vn-database','10360','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-10-06 09:52:39',NULL,NULL),('vn-database','10361','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-10-06 11:16:07',NULL,NULL),('vn-database','10362','00-dropUdfs.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-10-10 11:01:15',NULL,NULL),('vn-database','10363','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-11-04 08:25:17',NULL,NULL),('vn-database','10365','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-10-13 19:30:46',NULL,NULL),('vn-database','10368','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-11-04 08:25:17',NULL,NULL),('vn-database','10369','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-10-14 13:38:06',NULL,NULL),('vn-database','10370','00-deleteForeignKey.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-17 14:32:41',NULL,NULL),('vn-database','10370','01-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-17 14:32:47',NULL,NULL),('vn-database','10370','02-deleteTable.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-17 14:32:49',NULL,NULL),('vn-database','10370','03-accion.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-17 14:32:49',NULL,NULL),('vn-database','10370','04-inter.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-17 14:32:53',NULL,NULL),('vn-database','10371','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-12 10:56:23',NULL,NULL),('vn-database','10372','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-12-16 09:14:48',NULL,NULL),('vn-database','10373','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-10-19 08:31:58',NULL,NULL),('vn-database','10378','00-rename_routeUserPercentage.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-11-04 08:25:17',NULL,NULL),('vn-database','10379','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-03-09 08:40:16',NULL,NULL),('vn-database','10382','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-12-01 08:47:20',NULL,NULL),('vn-database','10383','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-17 14:32:53',NULL,NULL),('vn-database','10384','00-business_workcenterFk.sql','jenkins@db-proxy2.static.verdnatura.es','2023-05-12 09:18:01',NULL,NULL),('vn-database','10385','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-17 14:32:54',NULL,NULL),('vn-database','10386','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-17 14:32:54',NULL,NULL),('vn-database','10387','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-16 14:05:33',NULL,NULL),('vn-database','10388','00-resizeUtilVerionLogCode.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-12-01 08:47:20',NULL,NULL),('vn-database','10388','01-resizeUtilVersionCode.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-12-01 08:47:20',NULL,NULL),('vn-database','10390','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-12-01 08:50:16',NULL,NULL),('vn-database','10391','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-12 10:56:23',NULL,NULL),('vn-database','10394','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-12-01 08:50:24',NULL,NULL),('vn-database','10395','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-12-01 08:50:29',NULL,NULL),('vn-database','10396','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-17 15:36:38',NULL,NULL),('vn-database','10397','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-12-01 08:50:29',NULL,NULL),('vn-database','10399','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-12-01 08:50:29',NULL,NULL),('vn-database','10400','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-12-01 08:50:29',NULL,NULL),('vn-database','10402','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-21 14:11:31',NULL,NULL),('vn-database','10404','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-12-01 08:50:29',NULL,NULL),('vn-database','10405','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-16 09:58:22',NULL,NULL),('vn-database','10407','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-12-16 09:14:49',NULL,NULL),('vn-database','10408','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-12 10:56:23',NULL,NULL),('vn-database','10409','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-12-16 09:14:49',NULL,NULL),('vn-database','10412','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2022-11-30 12:45:44',NULL,NULL),('vn-database','10413','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-12 10:56:24',NULL,NULL),('vn-database','10416','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-12 10:56:24',NULL,NULL),('vn-database','10420','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-12 10:56:25',NULL,NULL),('vn-database','10421','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-12 10:56:26',NULL,NULL),('vn-database','10426','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-04-20 09:07:40',NULL,NULL),('vn-database','10428','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-26 13:27:05',NULL,NULL),('vn-database','10431','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-03-23 09:09:22',NULL,NULL),('vn-database','10433','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-26 13:27:05',NULL,NULL),('vn-database','10434','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-26 13:27:05',NULL,NULL),('vn-database','10435','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-13 07:30:10',NULL,NULL),('vn-database','10436','00-createFkWorker.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-16 09:58:59',NULL,NULL),('vn-database','10436','01-addStateToWorkerProductivity.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-16 09:59:00',NULL,NULL),('vn-database','10436','02-DeprecateVnSaleTrackingState.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-16 09:59:00',NULL,NULL),('vn-database','10436','03-DeprecateColumnVnSaleTrackingActionFk.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-16 09:59:01',NULL,NULL),('vn-database','10436','04-DropSchemaVnControl.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-16 09:59:01',NULL,NULL),('vn-database','10436','05-RemoveFkWorkerProductivity.sql','jenkins@db-proxy2.static.verdnatura.es','2023-02-17 14:51:19',NULL,NULL),('vn-database','10440','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-02-23 10:28:41',NULL,NULL),('vn-database','10444','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-16 09:59:01',NULL,NULL),('vn-database','10445','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-16 09:59:31',NULL,NULL),('vn-database','10448','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-16 09:59:31',NULL,NULL),('vn-database','10450','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-27 08:28:04',NULL,NULL),('vn-database','10451','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-06 08:08:32',NULL,NULL),('vn-database','10452','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-31 12:30:04',NULL,NULL),('vn-database','10453','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-31 14:04:37',NULL,NULL),('vn-database','10454','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-31 12:30:04',NULL,NULL),('vn-database','10455','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-31 12:30:04',NULL,NULL),('vn-database','10456','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-31 12:00:30',NULL,NULL),('vn-database','10457','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-01-31 12:00:33',NULL,NULL),('vn-database','10458','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-03-09 08:40:17',NULL,NULL),('vn-database','10459','00-alterTableUtilConfig.sql','jenkins@db-proxy1.static.verdnatura.es','2023-02-23 10:28:41',NULL,NULL),('vn-database','10459','01-createFunctionCurdate.sql','jenkins@db-proxy1.static.verdnatura.es','2023-02-23 10:28:41',NULL,NULL),('vn-database','10459','02-createFunctionMockTime.sql','jenkins@db-proxy1.static.verdnatura.es','2023-02-23 10:28:41',NULL,NULL),('vn-database','10459','03-createFunctionMockTimeBase.sql','jenkins@db-proxy1.static.verdnatura.es','2023-02-23 10:28:41',NULL,NULL),('vn-database','10459','04-createFunctionNow.sql','jenkins@db-proxy1.static.verdnatura.es','2023-02-23 10:28:41',NULL,NULL),('vn-database','10460','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-16 09:59:31',NULL,NULL),('vn-database','10461','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-16 09:59:31',NULL,NULL),('vn-database','10463','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-03 12:59:26',NULL,NULL),('vn-database','10468','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-16 09:59:31',NULL,NULL),('vn-database','10469','00-firstScript.sql','jenkins@swarm-worker1.static.verdnatura.es','2023-02-16 09:59:31',NULL,NULL),('vn-database','10470','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-02-23 10:28:54',NULL,NULL),('vn-database','10471','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-02-23 10:28:54',NULL,NULL),('vn-database','10472','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-02-23 10:28:54',NULL,NULL),('vn-database','10477','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-03-23 09:09:31',NULL,NULL),('vn-database','10478','00-dropBasket.sql','jenkins@db-proxy1.static.verdnatura.es','2023-02-23 10:28:54',NULL,NULL),('vn-database','10478','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-02-23 10:28:54',NULL,NULL),('vn-database','10478','01-orderConfigured.sql','jenkins@db-proxy1.static.verdnatura.es','2023-02-23 10:29:16',NULL,NULL),('vn-database','10478','02-configuredUpdate.sql','jenkins@db-proxy1.static.verdnatura.es','2023-02-23 10:29:53',NULL,NULL),('vn-database','10478','99-privileges.sql','jenkins@db-proxy1.static.verdnatura.es','2023-02-23 10:29:53',NULL,NULL),('vn-database','10480','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-02-17 15:09:26',NULL,NULL),('vn-database','10481','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-02-17 16:37:22',NULL,NULL),('vn-database','10482','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-02-21 10:00:28',NULL,NULL),('vn-database','10485','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-03-09 08:40:17',NULL,NULL),('vn-database','10488','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-03-09 08:40:17',NULL,NULL),('vn-database','10491','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-03-09 08:40:18',NULL,NULL),('vn-database','10492','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-03-09 08:40:18',NULL,NULL),('vn-database','10493','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-05-12 09:18:01',NULL,NULL),('vn-database','10495','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-03-09 08:40:19',NULL,NULL),('vn-database','10498','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-03-23 09:09:38',NULL,NULL),('vn-database','10500','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-03-03 07:06:03',NULL,NULL),('vn-database','10501','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-03-03 10:52:24',NULL,NULL),('vn-database','10502','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-03-23 09:09:48',NULL,NULL),('vn-database','10506','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-03-23 09:09:48',NULL,NULL),('vn-database','10507','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-04-05 10:35:23',NULL,NULL),('vn-database','10508','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-04-05 10:36:43',NULL,NULL),('vn-database','10510','00-dropBusinessFk.sql','jenkins@db-proxy2.static.verdnatura.es','2023-04-05 10:36:47',NULL,NULL),('vn-database','10510','01-createTableProfessionalCategory.sql','jenkins@db-proxy2.static.verdnatura.es','2023-04-05 10:36:47',NULL,NULL),('vn-database','10510','02-exportToNewTable.sql','jenkins@db-proxy2.static.verdnatura.es','2023-04-05 10:36:47',NULL,NULL),('vn-database','10510','03-RecreateFK.sql','jenkins@db-proxy2.static.verdnatura.es','2023-04-05 10:36:51',NULL,NULL),('vn-database','10510','04-kkPostgresqlTable.sql','jenkins@db-proxy2.static.verdnatura.es','2023-04-05 10:36:51',NULL,NULL),('vn-database','10511','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-04-20 09:07:41',NULL,NULL),('vn-database','10512','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-04-05 10:36:52',NULL,NULL),('vn-database','10513','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-04-05 10:36:56',NULL,NULL),('vn-database','10514','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-04-20 09:07:41',NULL,NULL),('vn-database','10516','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-03-23 09:09:48',NULL,NULL),('vn-database','10521','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-03-21 06:58:13',NULL,NULL),('vn-database','10522','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-04-20 09:07:41',NULL,NULL),('vn-database','10523','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-04-20 09:07:41',NULL,NULL),('vn-database','10525','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-03-21 12:42:50',NULL,NULL),('vn-database','10526','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-04-05 10:36:57',NULL,NULL),('vn-database','10528','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-04-05 10:37:00',NULL,NULL),('vn-database','10530','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-03-23 14:49:30',NULL,NULL),('vn-database','10531','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-03-24 11:47:10',NULL,NULL),('vn-database','10532','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-03-24 11:17:38',NULL,NULL),('vn-database','10533','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-04-05 10:37:04',NULL,NULL),('vn-database','10537','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-03-29 15:18:36',NULL,NULL),('vn-database','10538','00-createChronopostConfig.sql','jenkins@db-proxy1.static.verdnatura.es','2023-04-20 09:07:41',NULL,NULL),('vn-database','10538','01-createChronopostService.sql','jenkins@db-proxy1.static.verdnatura.es','2023-04-20 09:07:41',NULL,NULL),('vn-database','10538','02-createChronopostExpedition.sql','jenkins@db-proxy1.static.verdnatura.es','2023-04-20 09:07:41',NULL,NULL),('vn-database','10538','03-createChronopostSenderAddress.sql','jenkins@db-proxy1.static.verdnatura.es','2023-04-20 09:07:41',NULL,NULL),('vn-database','10538','04-addgrantPrivilegies.sql','jenkins@db-proxy1.static.verdnatura.es','2023-04-20 09:07:41',NULL,NULL),('vn-database','10538','05-updateChronopostConfig.sql','jenkins@db-proxy1.static.verdnatura.es','2023-04-21 11:54:57',NULL,NULL),('vn-database','10539','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-04-05 10:37:07',NULL,NULL),('vn-database','10540','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-05-12 09:18:01',NULL,NULL),('vn-database','10545','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-04-11 08:31:03',NULL,NULL),('vn-database','10546','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-04-20 09:08:10',NULL,NULL),('vn-database','10547','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-05-12 09:21:58',NULL,NULL),('vn-database','10549','00-updateUpdateLog.sql','jenkins@db-proxy1.static.verdnatura.es','2023-04-21 07:29:22',NULL,NULL),('vn-database','10549','01-updateInsertLog.sql','jenkins@db-proxy1.static.verdnatura.es','2023-04-21 07:30:11',NULL,NULL),('vn-database','10549','02-updateDeleteLog.sql','jenkins@db-proxy1.static.verdnatura.es','2023-04-21 07:30:51',NULL,NULL),('vn-database','10549','03-deleteEmptyLog.sql','jenkins@db-proxy1.static.verdnatura.es','2023-04-21 07:31:34',NULL,NULL),('vn-database','10549','04-optimizeLogTables.sql','jenkins@db-proxy1.static.verdnatura.es','2023-04-21 07:33:58',NULL,NULL),('vn-database','10550','00-editorFk.sql','jenkins@db-proxy2.static.verdnatura.es','2023-05-12 09:42:33',NULL,NULL),('vn-database','10550','01-originFk.sql','jenkins@db-proxy2.static.verdnatura.es','2023-05-12 09:45:28',NULL,NULL),('vn-database','10552','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-04-13 08:25:10',NULL,NULL),('vn-database','10554','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-04-20 09:08:10',NULL,NULL),('vn-database','10557','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-04-17 07:45:56',NULL,NULL),('vn-database','10559','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-04-18 10:53:50',NULL,NULL),('vn-database','10560','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-04-17 09:19:31',NULL,NULL),('vn-database','10562','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-05-12 09:45:28',NULL,NULL),('vn-database','10563','00-delivery_ticketFk.sql','jenkins@db-proxy2.static.verdnatura.es','2023-04-20 09:30:53',NULL,NULL),('vn-database','10566','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-04-20 10:08:41',NULL,NULL),('vn-database','10567','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-04-20 10:18:06',NULL,NULL),('vn-database','10568','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-05-12 09:45:28',NULL,NULL),('vn-database','10569','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-04-24 09:14:35',NULL,NULL),('vn-database','10570','00-createSendingConfig.sql','jenkins@db-proxy2.static.verdnatura.es','2023-05-12 09:45:28',NULL,NULL),('vn-database','10570','01-createSendingServiceWeekday.sql','jenkins@db-proxy2.static.verdnatura.es','2023-05-12 09:45:28',NULL,NULL),('vn-database','10570','02-createSendingService.sql','jenkins@db-proxy2.static.verdnatura.es','2023-05-12 09:45:28',NULL,NULL),('vn-database','10570','03-permisos.sql','jenkins@db-proxy2.static.verdnatura.es','2023-05-12 09:45:28',NULL,NULL),('vn-database','10575','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-04-26 11:27:32',NULL,NULL),('vn-database','10577','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-04-27 14:00:12',NULL,NULL),('vn-database','10578','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-05-12 09:45:28',NULL,NULL),('vn-database','10579','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-04-28 11:27:36',NULL,NULL),('vn-database','10580','00-itemTypeDropConstraint.sql','jenkins@db-proxy2.static.verdnatura.es','2023-04-28 18:18:52',NULL,NULL),('vn-database','10580','01-itemTypeAddConstraint.sql','jenkins@db-proxy2.static.verdnatura.es','2023-04-28 18:19:10',NULL,NULL),('vn-database','10581','00-itemTypeAutoIncrement.sql','jenkins@db-proxy2.static.verdnatura.es','2023-04-28 19:06:46',NULL,NULL),('vn-database','10582','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-05-12 09:45:28',NULL,NULL),('vn-database','10583','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-05-12 09:45:28',NULL,NULL),('vn-database','10584','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-05-12 09:45:28',NULL,NULL),('vn-database','10598','00-workerLog.sql','jenkins@db-proxy2.static.verdnatura.es','2023-05-12 09:45:29',NULL,NULL),('vn-database','10598','01-supplierLog.sql','jenkins@db-proxy2.static.verdnatura.es','2023-05-12 09:45:29',NULL,NULL),('vn-database','10598','02-workerTimeControlLog.sql','jenkins@db-proxy2.static.verdnatura.es','2023-05-12 09:45:29',NULL,NULL),('vn-database','10598','03-workerClockLog.sql','jenkins@db-proxy2.static.verdnatura.es','2023-05-12 09:45:29',NULL,NULL); /*!40000 ALTER TABLE `versionLog` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -54,11 +54,11 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2023-02-20 14:45:51 +-- Dump completed on 2023-05-16 8:24:00 USE `account`; --- MariaDB dump 10.19 Distrib 10.5.18-MariaDB, for debian-linux-gnu (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.15-MariaDB, for debian-linux-gnu (x86_64) -- --- Host: db-proxy.verdnatura.es Database: account +-- Host: db.verdnatura.es Database: account -- ------------------------------------------------------ -- Server version 10.7.7-MariaDB-1:10.7.7+maria~deb11-log @@ -78,7 +78,7 @@ USE `account`; LOCK TABLES `role` WRITE; /*!40000 ALTER TABLE `role` DISABLE KEYS */; -INSERT INTO `role` VALUES (1,'employee','Empleado básico',1,'2017-05-19 07:04:58','2017-11-29 10:06:31'),(2,'customer','Privilegios básicos de un cliente',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(3,'agency','Consultar tablas de predicciones de bultos',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(5,'administrative','Tareas relacionadas con la contabilidad',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(6,'guest','Privilegios para usuarios sin cuenta',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(9,'developer','Desarrolladores del sistema',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(11,'account','Privilegios relacionados con el login',0,'2017-05-19 07:04:58','2017-09-20 17:06:35'),(13,'teamBoss','Jefe de equipo/departamento',1,'2017-05-19 07:04:58','2021-06-30 13:29:30'),(15,'logistic','Departamento de compras, responsables de la logistica',1,'2017-05-19 07:04:58','2018-02-12 10:50:10'),(16,'logisticBoss','Jefe del departamento de logística',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(17,'adminBoss','Jefe del departamento de administración',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(18,'salesPerson','Departamento de ventas',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(19,'salesBoss','Jefe del departamento de ventas',1,'2017-05-19 07:04:58','2017-08-16 12:38:27'),(20,'manager','Gerencia',1,'2017-06-01 14:57:02','2022-07-29 07:36:15'),(21,'salesAssistant','Jefe auxiliar de ventas',1,'2017-08-16 12:40:52','2017-08-16 12:40:52'),(22,'teamManager','Jefe de departamento con privilegios de auxiliar de venta.',1,'2017-09-07 09:08:12','2017-09-07 09:08:12'),(30,'financialBoss','Director finaciero',1,'2017-09-21 11:05:36','2017-09-21 11:05:36'),(31,'freelancer','Trabajadores por cuenta ajena',1,'2017-10-10 12:57:26','2017-10-10 12:59:27'),(32,'ett','Trabajadores de empresa temporal',1,'2017-10-10 12:58:58','2017-10-10 12:59:20'),(33,'invoicing','Personal con acceso a facturación',0,'2018-01-29 16:43:34','2018-01-29 16:43:34'),(34,'agencyBoss','Jefe/a del departamento de agencias',1,'2018-01-29 16:44:39','2018-02-23 07:58:53'),(35,'buyer','Departamento de compras',1,'2018-02-12 10:35:42','2018-02-12 10:35:42'),(36,'replenisher','Trabajadores de camara',1,'2018-02-16 14:07:10','2019-04-12 05:38:08'),(37,'hr','Gestor/a de recursos humanos',1,'2018-02-22 17:34:53','2018-02-22 17:34:53'),(38,'hrBoss','Jefe/a de recursos humanos',1,'2018-02-22 17:35:09','2018-02-22 17:35:09'),(39,'adminAssistant','Jefe auxiliar administrativo',1,'2018-02-23 10:37:36','2018-02-23 10:38:41'),(40,'handmade','Departamento de confección',1,'2018-02-23 11:14:53','2018-02-23 11:39:12'),(41,'handmadeBoss','Jefe de departamento de confección',1,'2018-02-23 11:15:09','2018-02-23 11:39:26'),(42,'artificial','Departamento de artificial',1,'2018-02-23 11:39:59','2018-02-23 11:39:59'),(43,'artificialBoss','Jefe del departamento de artificial',1,'2018-02-23 11:40:16','2018-02-23 11:40:16'),(44,'accessory','Departamento de complementos',1,'2018-02-23 11:41:12','2018-02-23 11:41:12'),(45,'accessoryBoss','Jefe del departamento de complementos',1,'2018-02-23 11:41:23','2018-02-23 11:41:23'),(47,'cooler','Empleados de cámara',1,'2018-02-23 13:08:18','2018-02-23 13:08:18'),(48,'coolerBoss','Jefe del departamento de cámara',1,'2018-02-23 13:12:01','2018-02-23 13:12:01'),(49,'production','Empleado de producción',1,'2018-02-26 15:28:23','2021-02-12 09:42:35'),(50,'productionBoss','Jefe de producción',1,'2018-02-26 15:34:12','2018-02-26 15:34:12'),(51,'marketing','Departamento de marketing',1,'2018-03-01 07:28:39','2018-03-01 07:28:39'),(52,'marketingBoss','Jefe del departamento de marketing',1,'2018-03-01 07:28:57','2018-03-01 07:28:57'),(53,'insurance','Gestor de seguros de cambio',0,'2018-03-05 07:44:35','2019-02-01 13:47:57'),(54,'itemPicker','Sacador en cámara',1,'2018-03-05 12:08:17','2018-03-05 12:08:17'),(55,'itemPickerBoss','Jefe de sacadores',1,'2018-03-05 12:08:31','2018-03-05 12:08:31'),(56,'delivery','Personal de reparto',1,'2018-05-30 06:07:02','2018-05-30 06:07:02'),(57,'deliveryBoss','Jefe de personal de reparto',1,'2018-05-30 06:07:19','2018-05-30 06:07:19'),(58,'packager','Departamento encajadores',1,'2019-01-21 12:43:45','2019-01-21 12:43:45'),(59,'packagerBoss','Jefe departamento encajadores',1,'2019-01-21 12:44:10','2019-01-21 12:44:10'),(60,'productionAssi','Tareas relacionadas con producción y administración',1,'2019-01-29 13:29:01','2019-01-29 13:29:01'),(61,'replenisherBos','Jefe de Complementos/Camara',1,'2019-07-01 06:44:07','2019-07-01 06:44:07'),(62,'noLogin','Role without login access to MySQL',0,'2019-07-01 06:50:19','2019-07-02 13:42:05'),(64,'balanceSheet','Consulta de Balance',0,'2019-07-16 12:12:08','2019-07-16 12:12:08'),(65,'officeBoss','Jefe de filial',1,'2019-08-02 06:54:26','2019-08-02 06:54:26'),(66,'sysadmin','Administrador de sistema',1,'2019-08-08 06:58:56','2019-08-08 06:58:56'),(67,'adminOfficer','categoria profesional oficial de administración',1,'2020-01-03 08:09:23','2020-01-03 08:09:23'),(69,'coolerAssist','Empleado cámara con permiso compras',1,'2020-02-05 12:36:09','2020-02-05 12:36:09'),(70,'trainee','Alumno de prácticas',1,'2020-03-04 11:00:25','2020-03-04 11:00:25'),(71,'checker','Rol de revisor con privilegios de itemPicker',1,'2020-10-02 10:50:07','2020-10-02 10:50:07'),(72,'claimManager','Personal de reclamaciones',1,'2020-10-13 10:01:32','2020-10-26 07:29:46'),(73,'financial','Departamento de finanzas',1,'2020-11-16 09:30:27','2020-11-16 09:30:27'),(74,'userPhotos','Privilegios para subir fotos de usuario',1,'2021-02-03 10:24:27','2021-02-03 10:24:27'),(75,'catalogPhotos','Privilegios para subir fotos del catálogo',1,'2021-02-03 10:24:27','2021-02-03 10:24:27'),(76,'chat','Rol para utilizar el rocket chat',1,'2020-11-27 13:06:50','2020-12-17 07:49:41'),(100,'root','Rol con todos los privilegios',0,'2018-04-23 14:33:36','2020-11-12 06:50:07'),(101,'buyerBoss','Jefe del departamento de compras',1,'2021-06-16 09:53:17','2021-06-16 09:53:17'),(102,'preservedBoss','Responsable preservado',1,'2021-09-14 13:45:37','2021-09-14 13:45:37'),(103,'it','Departamento de informática',1,'2021-11-11 09:48:22','2021-11-11 09:48:22'),(104,'itBoss','Jefe de departamento de informática',1,'2021-11-11 09:48:49','2021-11-11 09:48:49'),(105,'grant','Adjudicar roles a usuarios',1,'2021-11-11 12:41:09','2021-11-11 12:41:09'),(106,'ext','Usuarios externos de la Base de datos',1,'2021-11-23 14:51:16','2021-11-23 14:51:16'),(107,'productionPlus','Creado para pepe por orden de Juanvi',1,'2022-02-08 06:47:10','2022-02-08 06:47:10'),(108,'system','System user',1,'2022-05-16 08:09:51','2022-05-16 08:09:51'),(109,'salesTeamBoss','Jefe de equipo de comerciales',1,'2022-06-14 13:45:56','2022-06-14 13:45:56'),(110,'palletizer','Paletizadores',1,'2022-12-02 12:56:22','2022-12-02 12:56:30'),(111,'entryEditor','Entry editor',1,'2023-01-13 11:21:55','2023-01-13 11:21:55'),(112,'maintenance','Personal de mantenimiento',1,'2023-01-19 06:23:35','2023-01-19 06:23:35'),(114,'maintenanceBos','Jefe de mantenimiento',1,'2023-01-19 06:31:16','2023-01-19 06:31:16'); +INSERT INTO `role` VALUES (1,'employee','Empleado básico',1,'2017-05-19 07:04:58','2017-11-29 10:06:31',NULL),(2,'customer','Privilegios básicos de un cliente',1,'2017-05-19 07:04:58','2017-05-19 07:04:58',NULL),(3,'agency','Consultar tablas de predicciones de bultos',1,'2017-05-19 07:04:58','2017-05-19 07:04:58',NULL),(5,'administrative','Tareas relacionadas con la contabilidad',1,'2017-05-19 07:04:58','2017-05-19 07:04:58',NULL),(6,'guest','Privilegios para usuarios sin cuenta',1,'2017-05-19 07:04:58','2017-05-19 07:04:58',NULL),(9,'developer','Desarrolladores del sistema',1,'2017-05-19 07:04:58','2017-05-19 07:04:58',NULL),(11,'account','Privilegios relacionados con el login',0,'2017-05-19 07:04:58','2017-09-20 17:06:35',NULL),(13,'teamBoss','Jefe de equipo/departamento',1,'2017-05-19 07:04:58','2021-06-30 13:29:30',NULL),(15,'logistic','Departamento de compras, responsables de la logistica',1,'2017-05-19 07:04:58','2018-02-12 10:50:10',NULL),(16,'logisticBoss','Jefe del departamento de logística',1,'2017-05-19 07:04:58','2017-05-19 07:04:58',NULL),(17,'adminBoss','Jefe del departamento de administración',1,'2017-05-19 07:04:58','2017-05-19 07:04:58',NULL),(18,'salesPerson','Departamento de ventas',1,'2017-05-19 07:04:58','2017-05-19 07:04:58',NULL),(19,'salesBoss','Jefe del departamento de ventas',1,'2017-05-19 07:04:58','2017-08-16 12:38:27',NULL),(20,'manager','Gerencia',1,'2017-06-01 14:57:02','2022-07-29 07:36:15',NULL),(21,'salesAssistant','Jefe auxiliar de ventas',1,'2017-08-16 12:40:52','2017-08-16 12:40:52',NULL),(22,'teamManager','Jefe de departamento con privilegios de auxiliar de venta.',1,'2017-09-07 09:08:12','2017-09-07 09:08:12',NULL),(30,'financialBoss','Director finaciero',1,'2017-09-21 11:05:36','2017-09-21 11:05:36',NULL),(31,'freelancer','Trabajadores por cuenta ajena',1,'2017-10-10 12:57:26','2017-10-10 12:59:27',NULL),(32,'ett','Trabajadores de empresa temporal',1,'2017-10-10 12:58:58','2017-10-10 12:59:20',NULL),(33,'invoicing','Personal con acceso a facturación',0,'2018-01-29 16:43:34','2018-01-29 16:43:34',NULL),(34,'agencyBoss','Jefe/a del departamento de agencias',1,'2018-01-29 16:44:39','2018-02-23 07:58:53',NULL),(35,'buyer','Departamento de compras',1,'2018-02-12 10:35:42','2018-02-12 10:35:42',NULL),(36,'replenisher','Trabajadores de camara',1,'2018-02-16 14:07:10','2019-04-12 05:38:08',NULL),(37,'hr','Gestor/a de recursos humanos',1,'2018-02-22 17:34:53','2018-02-22 17:34:53',NULL),(38,'hrBoss','Jefe/a de recursos humanos',1,'2018-02-22 17:35:09','2018-02-22 17:35:09',NULL),(39,'adminAssistant','Jefe auxiliar administrativo',1,'2018-02-23 10:37:36','2018-02-23 10:38:41',NULL),(40,'handmade','Departamento de confección',1,'2018-02-23 11:14:53','2018-02-23 11:39:12',NULL),(41,'handmadeBoss','Jefe de departamento de confección',1,'2018-02-23 11:15:09','2018-02-23 11:39:26',NULL),(42,'artificial','Departamento de artificial',1,'2018-02-23 11:39:59','2018-02-23 11:39:59',NULL),(43,'artificialBoss','Jefe del departamento de artificial',1,'2018-02-23 11:40:16','2018-02-23 11:40:16',NULL),(44,'accessory','Departamento de complementos',1,'2018-02-23 11:41:12','2018-02-23 11:41:12',NULL),(45,'accessoryBoss','Jefe del departamento de complementos',1,'2018-02-23 11:41:23','2018-02-23 11:41:23',NULL),(47,'cooler','Empleados de cámara',1,'2018-02-23 13:08:18','2018-02-23 13:08:18',NULL),(48,'coolerBoss','Jefe de cámara',1,'2018-02-23 13:12:01','2023-03-13 08:49:43',NULL),(49,'production','Empleado de producción',1,'2018-02-26 15:28:23','2021-02-12 09:42:35',NULL),(50,'productionBoss','Jefe de producción',1,'2018-02-26 15:34:12','2018-02-26 15:34:12',NULL),(51,'marketing','Departamento de marketing',1,'2018-03-01 07:28:39','2018-03-01 07:28:39',NULL),(52,'marketingBoss','Jefe del departamento de marketing',1,'2018-03-01 07:28:57','2018-03-01 07:28:57',NULL),(53,'insurance','Gestor de seguros de cambio',0,'2018-03-05 07:44:35','2019-02-01 13:47:57',NULL),(54,'itemPicker','Sacador en cámara',1,'2018-03-05 12:08:17','2018-03-05 12:08:17',NULL),(55,'itemPickerBoss','Jefe de sacadores',1,'2018-03-05 12:08:31','2018-03-05 12:08:31',NULL),(56,'delivery','Personal de reparto',1,'2018-05-30 06:07:02','2018-05-30 06:07:02',NULL),(57,'deliveryBoss','Jefe de personal de reparto',1,'2018-05-30 06:07:19','2018-05-30 06:07:19',NULL),(58,'packager','Departamento encajadores',1,'2019-01-21 12:43:45','2019-01-21 12:43:45',NULL),(59,'packagerBoss','Jefe departamento encajadores',1,'2019-01-21 12:44:10','2019-01-21 12:44:10',NULL),(60,'productionAssi','Tareas relacionadas con producción y administración',1,'2019-01-29 13:29:01','2019-01-29 13:29:01',NULL),(61,'replenisherBos','Jefe de Complementos/Camara',1,'2019-07-01 06:44:07','2019-07-01 06:44:07',NULL),(62,'noLogin','Role without login access to MySQL',0,'2019-07-01 06:50:19','2019-07-02 13:42:05',NULL),(64,'balanceSheet','Consulta de Balance',0,'2019-07-16 12:12:08','2019-07-16 12:12:08',NULL),(65,'officeBoss','Jefe de filial',1,'2019-08-02 06:54:26','2019-08-02 06:54:26',NULL),(66,'sysadmin','Administrador de sistema',1,'2019-08-08 06:58:56','2019-08-08 06:58:56',NULL),(67,'adminOfficer','categoria profesional oficial de administración',1,'2020-01-03 08:09:23','2020-01-03 08:09:23',NULL),(69,'coolerAssist','Asistente de cámara con permiso compras',1,'2020-02-05 12:36:09','2023-03-13 08:50:07',NULL),(70,'trainee','Alumno de prácticas',1,'2020-03-04 11:00:25','2020-03-04 11:00:25',NULL),(71,'checker','Rol de revisor con privilegios de itemPicker',1,'2020-10-02 10:50:07','2020-10-02 10:50:07',NULL),(72,'claimManager','Personal de reclamaciones',1,'2020-10-13 10:01:32','2020-10-26 07:29:46',NULL),(73,'financial','Departamento de finanzas',1,'2020-11-16 09:30:27','2020-11-16 09:30:27',NULL),(74,'userPhotos','Privilegios para subir fotos de usuario',1,'2021-02-03 10:24:27','2021-02-03 10:24:27',NULL),(75,'catalogPhotos','Privilegios para subir fotos del catálogo',1,'2021-02-03 10:24:27','2021-02-03 10:24:27',NULL),(76,'chat','Rol para utilizar el rocket chat',1,'2020-11-27 13:06:50','2020-12-17 07:49:41',NULL),(100,'root','Rol con todos los privilegios',0,'2018-04-23 14:33:36','2020-11-12 06:50:07',NULL),(101,'buyerBoss','Jefe del departamento de compras',1,'2021-06-16 09:53:17','2021-06-16 09:53:17',NULL),(102,'preservedBoss','Responsable preservado',1,'2021-09-14 13:45:37','2021-09-14 13:45:37',NULL),(103,'it','Departamento de informática',1,'2021-11-11 09:48:22','2021-11-11 09:48:22',NULL),(104,'itBoss','Jefe de departamento de informática',1,'2021-11-11 09:48:49','2021-11-11 09:48:49',NULL),(105,'grant','Adjudicar roles a usuarios',1,'2021-11-11 12:41:09','2021-11-11 12:41:09',NULL),(106,'ext','Usuarios externos de la Base de datos',1,'2021-11-23 14:51:16','2021-11-23 14:51:16',NULL),(107,'productionPlus','Creado para pepe por orden de Juanvi',1,'2022-02-08 06:47:10','2022-02-08 06:47:10',NULL),(108,'system','System user',1,'2022-05-16 08:09:51','2022-05-16 08:09:51',NULL),(109,'salesTeamBoss','Jefe de equipo de comerciales',1,'2022-06-14 13:45:56','2022-06-14 13:45:56',NULL),(110,'palletizer','Paletizadores',1,'2022-12-02 12:56:22','2022-12-02 12:56:30',NULL),(111,'entryEditor','Entry editor',1,'2023-01-13 11:21:55','2023-01-13 11:21:55',NULL),(112,'maintenance','Personal de mantenimiento',1,'2023-01-19 06:23:35','2023-01-19 06:23:35',NULL),(114,'maintenanceBos','Jefe de mantenimiento',1,'2023-01-19 06:31:16','2023-05-12 08:47:34',19294),(115,'itManagement','TI management',1,'2023-03-29 07:27:55','2023-03-29 07:28:04',NULL); /*!40000 ALTER TABLE `role` ENABLE KEYS */; UNLOCK TABLES; @@ -88,7 +88,7 @@ UNLOCK TABLES; LOCK TABLES `roleInherit` WRITE; /*!40000 ALTER TABLE `roleInherit` DISABLE KEYS */; -INSERT INTO `roleInherit` VALUES (1,1,2),(2,1,3),(3,1,70),(4,2,11),(5,3,11),(6,5,1),(7,5,21),(8,5,33),(124,5,76),(261,5,111),(167,9,103),(10,11,6),(11,13,1),(12,15,35),(143,15,49),(150,15,56),(114,15,76),(14,16,13),(15,16,15),(127,16,76),(16,17,20),(17,17,37),(18,17,39),(19,17,64),(145,17,67),(136,17,76),(20,18,1),(132,18,76),(21,19,21),(242,20,9),(22,20,13),(23,20,16),(24,20,65),(134,20,76),(25,21,13),(26,21,18),(27,21,53),(241,21,72),(131,21,76),(28,22,13),(29,22,21),(30,30,5),(31,30,20),(32,30,22),(33,30,53),(34,30,64),(118,30,76),(35,31,1),(36,32,1),(37,34,1),(38,34,13),(39,34,33),(40,35,1),(142,35,75),(129,35,76),(260,35,111),(41,36,44),(42,36,47),(43,37,1),(139,37,74),(125,37,76),(146,38,13),(44,38,37),(45,38,64),(126,38,76),(46,39,5),(47,39,21),(48,39,57),(115,39,76),(49,40,1),(50,40,49),(51,41,13),(52,41,35),(53,41,40),(135,41,76),(54,42,35),(55,42,49),(128,42,76),(56,43,13),(57,43,42),(258,43,111),(58,44,1),(59,45,13),(60,45,44),(61,47,1),(257,47,111),(62,48,13),(153,48,35),(63,48,47),(253,48,49),(256,48,69),(64,49,36),(65,49,58),(66,50,13),(67,50,21),(68,50,35),(69,50,49),(70,50,57),(71,50,59),(133,50,76),(72,51,1),(251,51,21),(264,51,35),(140,51,74),(141,51,75),(73,52,13),(74,52,19),(76,52,51),(137,52,76),(77,53,1),(78,54,1),(79,55,13),(80,55,54),(81,56,1),(82,57,13),(245,57,33),(83,57,56),(138,57,76),(84,58,1),(85,59,13),(109,59,50),(87,60,5),(89,60,50),(90,60,57),(130,60,76),(91,61,13),(92,61,36),(93,65,19),(94,65,35),(95,65,50),(117,65,76),(168,66,9),(237,66,103),(97,67,5),(98,67,37),(99,69,35),(152,69,47),(101,70,11),(102,71,1),(103,71,58),(105,72,18),(265,72,49),(259,72,111),(106,73,5),(108,73,19),(107,73,64),(148,101,13),(266,101,18),(147,101,35),(154,102,1),(248,102,13),(246,102,35),(173,103,1),(194,103,2),(181,103,3),(179,103,5),(201,103,6),(176,103,11),(231,103,13),(212,103,15),(213,103,16),(178,103,17),(230,103,18),(229,103,19),(238,103,20),(228,103,21),(232,103,22),(199,103,30),(200,103,31),(197,103,32),(207,103,33),(182,103,34),(186,103,35),(225,103,36),(204,103,37),(205,103,38),(177,103,39),(202,103,40),(203,103,41),(183,103,42),(184,103,43),(174,103,44),(175,103,45),(191,103,47),(193,103,48),(222,103,49),(224,103,50),(215,103,51),(216,103,52),(206,103,53),(210,103,54),(211,103,55),(195,103,56),(196,103,57),(219,103,58),(220,103,59),(223,103,60),(226,103,61),(185,103,64),(218,103,65),(180,103,67),(192,103,69),(233,103,70),(189,103,71),(190,103,72),(198,103,73),(234,103,74),(188,103,75),(172,103,76),(187,103,101),(221,103,102),(171,104,9),(170,104,66),(169,104,100),(166,104,103),(239,106,11),(240,107,60),(247,108,1),(250,109,13),(249,109,18),(254,110,1),(255,110,76),(262,112,1),(263,114,112); +INSERT INTO `roleInherit` VALUES (1,1,2,NULL),(2,1,3,NULL),(3,1,70,NULL),(4,2,11,NULL),(5,3,11,NULL),(6,5,1,NULL),(8,5,33,NULL),(10,11,6,NULL),(11,13,1,NULL),(12,15,35,NULL),(15,16,15,NULL),(16,17,20,NULL),(17,17,37,NULL),(18,17,39,NULL),(19,17,64,NULL),(20,18,1,NULL),(21,19,21,NULL),(22,20,13,NULL),(23,20,16,NULL),(24,20,65,NULL),(25,21,13,NULL),(26,21,18,NULL),(27,21,53,NULL),(28,22,13,NULL),(29,22,21,NULL),(30,30,5,NULL),(31,30,20,NULL),(32,30,22,NULL),(33,30,53,NULL),(34,30,64,NULL),(35,31,1,NULL),(36,32,1,NULL),(37,34,1,NULL),(38,34,13,NULL),(39,34,33,NULL),(40,35,1,NULL),(41,36,44,NULL),(42,36,47,NULL),(43,37,1,NULL),(44,38,37,NULL),(45,38,64,NULL),(46,39,5,NULL),(47,39,21,NULL),(48,39,57,NULL),(49,40,1,NULL),(50,40,49,NULL),(51,41,13,NULL),(52,41,35,NULL),(53,41,40,NULL),(54,42,35,NULL),(55,42,49,NULL),(56,43,13,NULL),(57,43,42,NULL),(58,44,1,NULL),(59,45,13,NULL),(60,45,44,NULL),(61,47,1,NULL),(62,48,13,NULL),(63,48,47,NULL),(64,49,36,NULL),(65,49,58,NULL),(66,50,13,NULL),(67,50,21,NULL),(68,50,35,NULL),(69,50,49,NULL),(70,50,57,NULL),(72,51,1,NULL),(73,52,13,NULL),(74,52,19,NULL),(76,52,51,NULL),(77,53,1,NULL),(78,54,1,NULL),(79,55,13,NULL),(80,55,54,NULL),(81,56,1,NULL),(82,57,13,NULL),(83,57,56,NULL),(84,58,1,NULL),(85,59,13,NULL),(87,60,5,NULL),(91,61,13,NULL),(92,61,36,NULL),(94,65,35,NULL),(97,67,5,NULL),(98,67,37,NULL),(99,69,35,NULL),(101,70,11,NULL),(102,71,1,NULL),(103,71,58,NULL),(105,72,18,NULL),(106,73,5,NULL),(107,73,64,NULL),(108,73,19,NULL),(109,59,50,NULL),(115,39,76,NULL),(117,65,76,NULL),(118,30,76,NULL),(124,5,76,NULL),(125,37,76,NULL),(126,38,76,NULL),(128,42,76,NULL),(129,35,76,NULL),(130,60,76,NULL),(131,21,76,NULL),(132,18,76,NULL),(133,50,76,NULL),(134,20,76,NULL),(135,41,76,NULL),(136,17,76,NULL),(137,52,76,NULL),(138,57,76,NULL),(139,37,74,NULL),(140,51,74,NULL),(141,51,75,NULL),(142,35,75,NULL),(143,15,49,NULL),(145,17,67,NULL),(146,38,13,NULL),(147,101,35,NULL),(148,101,13,NULL),(150,15,56,NULL),(152,69,47,NULL),(153,48,35,NULL),(154,102,1,NULL),(167,9,103,NULL),(168,66,9,NULL),(169,104,100,NULL),(172,103,76,NULL),(173,103,1,NULL),(174,103,44,NULL),(175,103,45,NULL),(176,103,11,NULL),(177,103,39,NULL),(178,103,17,NULL),(179,103,5,NULL),(180,103,67,NULL),(181,103,3,NULL),(182,103,34,NULL),(183,103,42,NULL),(184,103,43,NULL),(185,103,64,NULL),(186,103,35,NULL),(187,103,101,NULL),(188,103,75,NULL),(189,103,71,NULL),(190,103,72,NULL),(191,103,47,NULL),(192,103,69,NULL),(193,103,48,NULL),(194,103,2,NULL),(195,103,56,NULL),(196,103,57,NULL),(197,103,32,NULL),(198,103,73,NULL),(199,103,30,NULL),(200,103,31,NULL),(201,103,6,NULL),(202,103,40,NULL),(203,103,41,NULL),(204,103,37,NULL),(205,103,38,NULL),(206,103,53,NULL),(207,103,33,NULL),(210,103,54,NULL),(211,103,55,NULL),(212,103,15,NULL),(213,103,16,NULL),(215,103,51,NULL),(216,103,52,NULL),(218,103,65,NULL),(219,103,58,NULL),(220,103,59,NULL),(221,103,102,NULL),(222,103,49,NULL),(223,103,60,NULL),(224,103,50,NULL),(225,103,36,NULL),(226,103,61,NULL),(228,103,21,NULL),(229,103,19,NULL),(230,103,18,NULL),(231,103,13,NULL),(232,103,22,NULL),(233,103,70,NULL),(234,103,74,NULL),(237,66,103,NULL),(238,103,20,NULL),(239,106,11,NULL),(240,107,60,NULL),(241,21,72,NULL),(242,20,9,NULL),(245,57,33,NULL),(246,102,35,NULL),(247,108,1,NULL),(248,102,13,NULL),(249,109,18,NULL),(250,109,13,NULL),(251,51,21,NULL),(253,48,49,NULL),(254,110,1,NULL),(255,110,76,NULL),(256,48,69,NULL),(257,47,111,NULL),(258,43,111,NULL),(259,72,111,NULL),(260,35,111,NULL),(261,5,111,NULL),(262,112,1,NULL),(263,114,112,NULL),(264,51,35,NULL),(265,72,49,NULL),(266,101,18,NULL),(268,65,57,NULL),(269,65,59,NULL),(270,65,49,NULL),(271,65,18,NULL),(272,65,13,NULL),(273,60,35,NULL),(275,50,59,NULL),(276,60,49,NULL),(280,5,53,NULL),(281,5,18,NULL),(282,50,60,NULL),(283,5,21,NULL),(284,60,57,NULL),(285,58,76,NULL),(287,69,58,NULL),(288,115,66,NULL),(289,115,9,NULL),(290,104,115,NULL),(291,115,103,NULL),(297,21,33,NULL),(298,49,54,NULL),(299,112,49,NULL),(300,114,13,NULL); /*!40000 ALTER TABLE `roleInherit` ENABLE KEYS */; UNLOCK TABLES; @@ -98,7 +98,7 @@ UNLOCK TABLES; LOCK TABLES `roleRole` WRITE; /*!40000 ALTER TABLE `roleRole` DISABLE KEYS */; -INSERT INTO `roleRole` VALUES (135896,1,1),(135897,1,2),(135898,1,3),(135901,1,6),(135900,1,11),(135899,1,70),(135813,2,2),(135815,2,6),(135814,2,11),(135680,3,3),(135682,3,6),(135681,3,11),(135638,5,1),(135647,5,2),(135646,5,3),(135637,5,5),(135654,5,6),(135651,5,11),(135644,5,13),(135643,5,18),(135639,5,21),(135640,5,33),(135653,5,36),(135656,5,44),(135655,5,47),(135650,5,49),(135648,5,53),(135652,5,58),(135645,5,70),(135649,5,72),(135641,5,76),(135642,5,111),(136006,6,6),(135836,9,1),(135837,9,2),(135838,9,3),(135839,9,5),(135840,9,6),(135834,9,9),(135841,9,11),(135842,9,13),(135843,9,15),(135844,9,16),(135845,9,17),(135846,9,18),(135847,9,19),(135848,9,20),(135849,9,21),(135850,9,22),(135851,9,30),(135852,9,31),(135853,9,32),(135854,9,33),(135855,9,34),(135856,9,35),(135857,9,36),(135858,9,37),(135859,9,38),(135860,9,39),(135861,9,40),(135862,9,41),(135863,9,42),(135864,9,43),(135865,9,44),(135866,9,45),(135867,9,47),(135868,9,48),(135869,9,49),(135870,9,50),(135871,9,51),(135872,9,52),(135873,9,53),(135874,9,54),(135875,9,55),(135876,9,56),(135877,9,57),(135878,9,58),(135879,9,59),(135880,9,60),(135881,9,61),(135882,9,64),(135883,9,65),(135884,9,67),(135885,9,69),(135886,9,70),(135887,9,71),(135888,9,72),(135889,9,73),(135890,9,74),(135891,9,75),(135892,9,76),(135893,9,101),(135894,9,102),(135835,9,103),(135895,9,111),(135551,11,6),(135550,11,11),(136772,13,1),(136773,13,2),(136774,13,3),(136777,13,6),(136776,13,11),(136771,13,13),(136775,13,70),(136227,15,1),(136233,15,2),(136232,15,3),(136235,15,6),(136234,15,11),(136219,15,15),(136220,15,35),(136224,15,36),(136230,15,44),(136229,15,47),(136221,15,49),(136222,15,56),(136228,15,58),(136231,15,70),(136226,15,75),(136223,15,76),(136225,15,111),(136242,16,1),(136247,16,2),(136246,16,3),(136254,16,6),(136253,16,11),(136237,16,13),(136238,16,15),(136236,16,16),(136241,16,35),(136249,16,36),(136252,16,44),(136251,16,47),(136240,16,49),(136243,16,56),(136250,16,58),(136245,16,70),(136244,16,75),(136239,16,76),(136248,16,111),(135583,17,1),(135594,17,2),(135593,17,3),(135588,17,5),(135618,17,6),(135587,17,9),(135617,17,11),(135586,17,13),(135598,17,15),(135585,17,16),(135575,17,17),(135601,17,18),(135597,17,19),(135576,17,20),(135589,17,21),(135616,17,22),(135615,17,30),(135614,17,31),(135613,17,32),(135591,17,33),(135612,17,34),(135596,17,35),(135611,17,36),(135577,17,37),(135610,17,38),(135578,17,39),(135609,17,40),(135608,17,41),(135607,17,42),(135606,17,43),(135605,17,44),(135619,17,45),(135620,17,47),(135621,17,48),(135622,17,49),(135595,17,50),(135623,17,51),(135624,17,52),(135602,17,53),(135625,17,54),(135626,17,55),(135604,17,56),(135590,17,57),(135627,17,58),(135628,17,59),(135629,17,60),(135630,17,61),(135579,17,64),(135584,17,65),(135580,17,67),(135631,17,69),(135592,17,70),(135632,17,71),(135603,17,72),(135633,17,73),(135582,17,74),(135634,17,75),(135581,17,76),(135635,17,101),(135636,17,102),(135599,17,103),(135600,17,111),(136684,18,1),(136687,18,2),(136686,18,3),(136690,18,6),(136689,18,11),(136683,18,18),(136688,18,70),(136685,18,76),(136673,19,1),(136678,19,2),(136677,19,3),(136682,19,6),(136681,19,11),(136666,19,13),(136667,19,18),(136664,19,19),(136665,19,21),(136675,19,36),(136680,19,44),(136679,19,47),(136672,19,49),(136668,19,53),(136674,19,58),(136676,19,70),(136669,19,72),(136670,19,76),(136671,19,111),(136279,20,1),(136287,20,2),(136286,20,3),(136285,20,5),(136284,20,6),(136271,20,9),(136283,20,11),(136272,20,13),(136278,20,15),(136273,20,16),(136282,20,17),(136288,20,18),(136277,20,19),(136270,20,20),(136289,20,21),(136290,20,22),(136291,20,30),(136292,20,31),(136293,20,32),(136294,20,33),(136295,20,34),(136276,20,35),(136296,20,36),(136297,20,37),(136298,20,38),(136299,20,39),(136300,20,40),(136301,20,41),(136302,20,42),(136303,20,43),(136304,20,44),(136305,20,45),(136306,20,47),(136307,20,48),(136308,20,49),(136281,20,50),(136309,20,51),(136310,20,52),(136311,20,53),(136312,20,54),(136313,20,55),(136314,20,56),(136315,20,57),(136316,20,58),(136317,20,59),(136318,20,60),(136319,20,61),(136320,20,64),(136274,20,65),(136321,20,67),(136322,20,69),(136323,20,70),(136324,20,71),(136325,20,72),(136326,20,73),(136327,20,74),(136328,20,75),(136275,20,76),(136329,20,101),(136330,20,102),(136280,20,103),(136331,20,111),(136654,21,1),(136659,21,2),(136658,21,3),(136663,21,6),(136662,21,11),(136647,21,13),(136648,21,18),(136646,21,21),(136656,21,36),(136661,21,44),(136660,21,47),(136653,21,49),(136649,21,53),(136655,21,58),(136657,21,70),(136650,21,72),(136651,21,76),(136652,21,111),(136782,22,1),(136790,22,2),(136789,22,3),(136796,22,6),(136793,22,11),(136779,22,13),(136781,22,18),(136780,22,21),(136778,22,22),(136792,22,36),(136795,22,44),(136794,22,47),(136787,22,49),(136783,22,53),(136791,22,58),(136788,22,70),(136784,22,72),(136785,22,76),(136786,22,111),(135948,30,1),(135958,30,2),(135957,30,3),(135937,30,5),(135968,30,6),(135944,30,9),(135970,30,11),(135943,30,13),(135952,30,15),(135949,30,16),(135967,30,17),(135955,30,18),(135951,30,19),(135938,30,20),(135947,30,21),(135939,30,22),(135936,30,30),(135966,30,31),(135965,30,32),(135946,30,33),(135964,30,34),(135959,30,35),(135963,30,36),(135962,30,37),(135961,30,38),(135971,30,39),(135972,30,40),(135973,30,41),(135974,30,42),(135975,30,43),(135976,30,44),(135977,30,45),(135978,30,47),(135979,30,48),(135969,30,49),(135960,30,50),(135980,30,51),(135981,30,52),(135940,30,53),(135982,30,54),(135983,30,55),(135984,30,56),(135985,30,57),(135986,30,58),(135987,30,59),(135988,30,60),(135989,30,61),(135941,30,64),(135950,30,65),(135990,30,67),(135991,30,69),(135956,30,70),(135992,30,71),(135954,30,72),(135993,30,73),(135994,30,74),(135995,30,75),(135942,30,76),(135996,30,101),(135997,30,102),(135953,30,103),(135945,30,111),(135999,31,1),(136000,31,2),(136001,31,3),(136004,31,6),(136003,31,11),(135998,31,31),(136002,31,70),(135904,32,1),(135905,32,2),(135906,32,3),(135909,32,6),(135908,32,11),(135903,32,32),(135907,32,70),(136066,33,33),(135684,34,1),(135689,34,2),(135688,34,3),(135691,34,6),(135690,34,11),(135685,34,13),(135686,34,33),(135683,34,34),(135687,34,70),(135728,35,1),(135734,35,2),(135733,35,3),(135736,35,6),(135735,35,11),(135727,35,35),(135732,35,70),(135729,35,75),(135730,35,76),(135731,35,111),(136554,36,1),(136556,36,2),(136555,36,3),(136559,36,6),(136558,36,11),(136550,36,36),(136551,36,44),(136552,36,47),(136557,36,70),(136553,36,111),(136039,37,1),(136044,37,2),(136043,37,3),(136046,37,6),(136045,37,11),(136038,37,37),(136042,37,70),(136040,37,74),(136041,37,76),(136053,38,1),(136056,38,2),(136055,38,3),(136058,38,6),(136057,38,11),(136048,38,13),(136049,38,37),(136047,38,38),(136050,38,64),(136054,38,70),(136052,38,74),(136051,38,76),(135560,39,1),(135568,39,2),(135567,39,3),(135553,39,5),(135574,39,6),(135571,39,11),(135557,39,13),(135561,39,18),(135554,39,21),(135559,39,33),(135570,39,36),(135552,39,39),(135573,39,44),(135572,39,47),(135565,39,49),(135562,39,53),(135564,39,56),(135555,39,57),(135569,39,58),(135566,39,70),(135563,39,72),(135556,39,76),(135558,39,111),(136008,40,1),(136011,40,2),(136010,40,3),(136019,40,6),(136017,40,11),(136013,40,36),(136007,40,40),(136016,40,44),(136015,40,47),(136009,40,49),(136014,40,58),(136012,40,70),(136018,40,111),(136028,41,1),(136032,41,2),(136031,41,3),(136037,41,6),(136036,41,11),(136021,41,13),(136022,41,35),(136029,41,36),(136023,41,40),(136020,41,41),(136035,41,44),(136034,41,47),(136025,41,49),(136033,41,58),(136030,41,70),(136027,41,75),(136024,41,76),(136026,41,111),(135698,42,1),(135705,42,2),(135704,42,3),(135707,42,6),(135706,42,11),(135693,42,35),(135699,42,36),(135692,42,42),(135702,42,44),(135701,42,47),(135694,42,49),(135700,42,58),(135703,42,70),(135697,42,75),(135695,42,76),(135696,42,111),(135714,43,1),(135719,43,2),(135718,43,3),(135725,43,6),(135724,43,11),(135709,43,13),(135713,43,35),(135720,43,36),(135710,43,42),(135708,43,43),(135723,43,44),(135722,43,47),(135712,43,49),(135721,43,58),(135717,43,70),(135716,43,75),(135715,43,76),(135711,43,111),(135535,44,1),(135536,44,2),(135537,44,3),(135540,44,6),(135539,44,11),(135534,44,44),(135538,44,70),(135544,45,1),(135546,45,2),(135545,45,3),(135549,45,6),(135548,45,11),(135542,45,13),(135543,45,44),(135541,45,45),(135547,45,70),(135776,47,1),(135779,47,2),(135778,47,3),(135782,47,6),(135781,47,11),(135775,47,47),(135780,47,70),(135777,47,111),(135805,48,1),(135810,48,2),(135809,48,3),(135812,48,6),(135811,48,11),(135796,48,13),(135797,48,35),(135801,48,36),(135807,48,44),(135798,48,47),(135795,48,48),(135799,48,49),(135806,48,58),(135800,48,69),(135808,48,70),(135804,48,75),(135803,48,76),(135802,48,111),(136463,49,1),(136465,49,2),(136464,49,3),(136469,49,6),(136468,49,11),(136459,49,36),(136462,49,44),(136461,49,47),(136458,49,49),(136460,49,58),(136467,49,70),(136466,49,111),(136511,50,1),(136519,50,2),(136518,50,3),(136521,50,6),(136520,50,11),(136498,50,13),(136510,50,18),(136499,50,21),(136513,50,33),(136500,50,35),(136505,50,36),(136516,50,44),(136515,50,47),(136501,50,49),(136497,50,50),(136509,50,53),(136514,50,56),(136502,50,57),(136512,50,58),(136503,50,59),(136517,50,70),(136508,50,72),(136507,50,75),(136504,50,76),(136506,50,111),(136333,51,1),(136342,51,2),(136341,51,3),(136351,51,6),(136348,51,11),(136339,51,13),(136338,51,18),(136334,51,21),(136335,51,35),(136350,51,36),(136353,51,44),(136352,51,47),(136347,51,49),(136332,51,51),(136343,51,53),(136349,51,58),(136340,51,70),(136344,51,72),(136336,51,74),(136337,51,75),(136345,51,76),(136346,51,111),(136362,52,1),(136368,52,2),(136367,52,3),(136375,52,6),(136372,52,11),(136355,52,13),(136365,52,18),(136356,52,19),(136361,52,21),(136360,52,35),(136374,52,36),(136377,52,44),(136376,52,47),(136371,52,49),(136357,52,51),(136354,52,52),(136364,52,53),(136373,52,58),(136366,52,70),(136369,52,72),(136359,52,74),(136363,52,75),(136358,52,76),(136370,52,111),(136060,53,1),(136061,53,2),(136062,53,3),(136065,53,6),(136064,53,11),(136059,53,53),(136063,53,70),(136204,54,1),(136205,54,2),(136206,54,3),(136209,54,6),(136208,54,11),(136203,54,54),(136207,54,70),(136213,55,1),(136215,55,2),(136214,55,3),(136218,55,6),(136217,55,11),(136211,55,13),(136212,55,54),(136210,55,55),(136216,55,70),(135817,56,1),(135818,56,2),(135819,56,3),(135822,56,6),(135821,56,11),(135816,56,56),(135820,56,70),(135828,57,1),(135831,57,2),(135830,57,3),(135833,57,6),(135832,57,11),(135824,57,13),(135825,57,33),(135826,57,56),(135823,57,57),(135829,57,70),(135827,57,76),(136407,58,1),(136408,58,2),(136409,58,3),(136412,58,6),(136411,58,11),(136406,58,58),(136410,58,70),(136417,59,1),(136427,59,2),(136426,59,3),(136437,59,6),(136436,59,11),(136414,59,13),(136424,59,18),(136416,59,21),(136432,59,33),(136418,59,35),(136430,59,36),(136435,59,44),(136434,59,47),(136419,59,49),(136415,59,50),(136423,59,53),(136433,59,56),(136420,59,57),(136431,59,58),(136413,59,59),(136425,59,70),(136422,59,72),(136428,59,75),(136421,59,76),(136429,59,111),(136478,60,1),(136492,60,2),(136491,60,3),(136471,60,5),(136496,60,6),(136495,60,11),(136479,60,13),(136489,60,18),(136477,60,21),(136476,60,33),(136480,60,35),(136485,60,36),(136494,60,44),(136493,60,47),(136481,60,49),(136472,60,50),(136488,60,53),(136483,60,56),(136473,60,57),(136484,60,58),(136482,60,59),(136470,60,60),(136490,60,70),(136487,60,72),(136486,60,75),(136474,60,76),(136475,60,111),(136564,61,1),(136568,61,2),(136567,61,3),(136571,61,6),(136570,61,11),(136561,61,13),(136562,61,36),(136563,61,44),(136565,61,47),(136560,61,61),(136566,61,70),(136569,61,111),(136378,62,62),(135726,64,64),(136386,65,1),(136396,65,2),(136395,65,3),(136405,65,6),(136404,65,11),(136388,65,13),(136399,65,18),(136380,65,19),(136387,65,21),(136400,65,33),(136381,65,35),(136393,65,36),(136403,65,44),(136402,65,47),(136389,65,49),(136382,65,50),(136398,65,53),(136401,65,56),(136390,65,57),(136392,65,58),(136391,65,59),(136379,65,65),(136394,65,70),(136397,65,72),(136385,65,75),(136383,65,76),(136384,65,111),(136705,66,1),(136704,66,2),(136706,66,3),(136707,66,5),(136708,66,6),(136702,66,9),(136709,66,11),(136710,66,13),(136711,66,15),(136712,66,16),(136713,66,17),(136714,66,18),(136715,66,19),(136716,66,20),(136717,66,21),(136718,66,22),(136719,66,30),(136720,66,31),(136721,66,32),(136722,66,33),(136723,66,34),(136724,66,35),(136725,66,36),(136726,66,37),(136727,66,38),(136728,66,39),(136729,66,40),(136730,66,41),(136731,66,42),(136732,66,43),(136733,66,44),(136734,66,45),(136735,66,47),(136736,66,48),(136737,66,49),(136738,66,50),(136739,66,51),(136740,66,52),(136741,66,53),(136742,66,54),(136743,66,55),(136744,66,56),(136745,66,57),(136746,66,58),(136747,66,59),(136748,66,60),(136749,66,61),(136750,66,64),(136751,66,65),(136701,66,66),(136752,66,67),(136753,66,69),(136754,66,70),(136755,66,71),(136756,66,72),(136757,66,73),(136758,66,74),(136759,66,75),(136760,66,76),(136761,66,101),(136762,66,102),(136703,66,103),(136763,66,111),(135661,67,1),(135671,67,2),(135670,67,3),(135658,67,5),(135677,67,6),(135674,67,11),(135668,67,13),(135667,67,18),(135660,67,21),(135662,67,33),(135676,67,36),(135659,67,37),(135679,67,44),(135678,67,47),(135673,67,49),(135666,67,53),(135675,67,58),(135657,67,67),(135669,67,70),(135672,67,72),(135665,67,74),(135663,67,76),(135664,67,111),(135787,69,1),(135792,69,2),(135791,69,3),(135794,69,6),(135793,69,11),(135784,69,35),(135785,69,47),(135783,69,69),(135790,69,70),(135786,69,75),(135788,69,76),(135789,69,111),(136799,70,6),(136798,70,11),(136797,70,70),(135753,71,1),(135756,71,2),(135755,71,3),(135759,71,6),(135758,71,11),(135754,71,58),(135757,71,70),(135752,71,71),(135766,72,1),(135771,72,2),(135770,72,3),(135774,72,6),(135773,72,11),(135761,72,18),(135764,72,36),(135768,72,44),(135772,72,47),(135762,72,49),(135767,72,58),(135769,72,70),(135760,72,72),(135765,72,76),(135763,72,111),(135919,73,1),(135926,73,2),(135925,73,3),(135914,73,5),(135933,73,6),(135930,73,11),(135923,73,13),(135922,73,18),(135915,73,19),(135918,73,21),(135917,73,33),(135932,73,36),(135935,73,44),(135934,73,47),(135929,73,49),(135927,73,53),(135931,73,58),(135916,73,64),(135924,73,70),(135928,73,72),(135913,73,73),(135920,73,76),(135921,73,111),(136800,74,74),(135750,75,75),(135751,76,76),(136598,100,1),(136594,100,2),(136580,100,3),(136578,100,5),(136606,100,6),(136597,100,9),(136575,100,11),(136642,100,13),(136617,100,15),(136618,100,16),(136577,100,17),(136638,100,18),(136637,100,19),(136621,100,20),(136636,100,21),(136643,100,22),(136603,100,30),(136604,100,31),(136600,100,32),(136612,100,33),(136581,100,34),(136585,100,35),(136634,100,36),(136609,100,37),(136610,100,38),(136576,100,39),(136607,100,40),(136608,100,41),(136582,100,42),(136583,100,43),(136573,100,44),(136574,100,45),(136591,100,47),(136593,100,48),(136630,100,49),(136632,100,50),(136622,100,51),(136623,100,52),(136611,100,53),(136615,100,54),(136616,100,55),(136595,100,56),(136596,100,57),(136626,100,58),(136627,100,59),(136631,100,60),(136635,100,61),(136624,100,62),(136584,100,64),(136625,100,65),(136640,100,66),(136579,100,67),(136592,100,69),(136644,100,70),(136589,100,71),(136590,100,72),(136602,100,73),(136645,100,74),(136587,100,75),(136588,100,76),(136572,100,100),(136586,100,101),(136629,100,102),(136613,100,103),(136614,100,104),(136605,100,105),(136601,100,106),(136633,100,107),(136641,100,108),(136639,100,109),(136628,100,110),(136599,100,111),(136619,100,112),(136620,100,114),(135743,101,1),(135747,101,2),(135746,101,3),(135749,101,6),(135748,101,11),(135738,101,13),(135739,101,18),(135740,101,35),(135745,101,70),(135741,101,75),(135742,101,76),(135737,101,101),(135744,101,111),(136447,102,1),(136452,102,2),(136451,102,3),(136457,102,6),(136456,102,11),(136448,102,13),(136449,102,35),(136450,102,70),(136453,102,75),(136454,102,76),(136446,102,102),(136455,102,111),(136068,103,1),(136069,103,2),(136070,103,3),(136071,103,5),(136072,103,6),(136127,103,9),(136073,103,11),(136074,103,13),(136075,103,15),(136076,103,16),(136077,103,17),(136078,103,18),(136079,103,19),(136080,103,20),(136081,103,21),(136082,103,22),(136083,103,30),(136084,103,31),(136085,103,32),(136086,103,33),(136087,103,34),(136088,103,35),(136089,103,36),(136090,103,37),(136091,103,38),(136092,103,39),(136093,103,40),(136094,103,41),(136095,103,42),(136096,103,43),(136097,103,44),(136098,103,45),(136099,103,47),(136100,103,48),(136101,103,49),(136102,103,50),(136103,103,51),(136104,103,52),(136105,103,53),(136106,103,54),(136107,103,55),(136108,103,56),(136109,103,57),(136110,103,58),(136111,103,59),(136112,103,60),(136113,103,61),(136114,103,64),(136115,103,65),(136116,103,67),(136117,103,69),(136118,103,70),(136119,103,71),(136120,103,72),(136121,103,73),(136122,103,74),(136123,103,75),(136124,103,76),(136125,103,101),(136126,103,102),(136067,103,103),(136128,103,111),(136137,104,1),(136136,104,2),(136135,104,3),(136134,104,5),(136138,104,6),(136130,104,9),(136139,104,11),(136140,104,13),(136141,104,15),(136142,104,16),(136143,104,17),(136144,104,18),(136145,104,19),(136146,104,20),(136147,104,21),(136148,104,22),(136149,104,30),(136150,104,31),(136151,104,32),(136152,104,33),(136153,104,34),(136154,104,35),(136155,104,36),(136156,104,37),(136157,104,38),(136158,104,39),(136159,104,40),(136160,104,41),(136161,104,42),(136162,104,43),(136163,104,44),(136164,104,45),(136165,104,47),(136166,104,48),(136167,104,49),(136168,104,50),(136169,104,51),(136170,104,52),(136171,104,53),(136172,104,54),(136173,104,55),(136174,104,56),(136175,104,57),(136176,104,58),(136177,104,59),(136178,104,60),(136179,104,61),(136198,104,62),(136180,104,64),(136181,104,65),(136131,104,66),(136182,104,67),(136183,104,69),(136184,104,70),(136185,104,71),(136186,104,72),(136187,104,73),(136188,104,74),(136189,104,75),(136190,104,76),(136132,104,100),(136191,104,101),(136192,104,102),(136133,104,103),(136129,104,104),(136195,104,105),(136194,104,106),(136200,104,107),(136202,104,108),(136201,104,109),(136199,104,110),(136193,104,111),(136196,104,112),(136197,104,114),(136005,105,105),(135912,106,6),(135911,106,11),(135910,106,106),(136531,107,1),(136545,107,2),(136544,107,3),(136524,107,5),(136549,107,6),(136548,107,11),(136532,107,13),(136542,107,18),(136530,107,21),(136529,107,33),(136533,107,35),(136538,107,36),(136547,107,44),(136546,107,47),(136534,107,49),(136525,107,50),(136541,107,53),(136536,107,56),(136526,107,57),(136537,107,58),(136535,107,59),(136523,107,60),(136543,107,70),(136540,107,72),(136539,107,75),(136527,107,76),(136522,107,107),(136528,107,111),(136765,108,1),(136766,108,2),(136767,108,3),(136770,108,6),(136769,108,11),(136768,108,70),(136764,108,108),(136695,109,1),(136697,109,2),(136696,109,3),(136700,109,6),(136699,109,11),(136692,109,13),(136693,109,18),(136698,109,70),(136694,109,76),(136691,109,109),(136439,110,1),(136442,110,2),(136441,110,3),(136445,110,6),(136444,110,11),(136443,110,70),(136440,110,76),(136438,110,110),(135902,111,111),(136256,112,1),(136257,112,2),(136258,112,3),(136261,112,6),(136260,112,11),(136259,112,70),(136255,112,112),(136264,114,1),(136265,114,2),(136266,114,3),(136269,114,6),(136268,114,11),(136267,114,70),(136263,114,112),(136262,114,114); +INSERT INTO `roleRole` VALUES (234609,1,1),(234610,1,2),(234611,1,3),(234614,1,6),(234613,1,11),(234612,1,70),(234496,2,2),(234498,2,6),(234497,2,11),(234357,3,3),(234359,3,6),(234358,3,11),(234313,5,1),(234324,5,2),(234323,5,3),(234312,5,5),(234330,5,6),(234326,5,11),(234321,5,13),(234314,5,18),(234315,5,21),(234316,5,33),(234329,5,36),(234332,5,44),(234331,5,47),(234325,5,49),(234317,5,53),(234328,5,54),(234327,5,58),(234322,5,70),(234320,5,72),(234318,5,76),(234319,5,111),(234720,6,6),(234549,9,1),(234550,9,2),(234551,9,3),(234552,9,5),(234553,9,6),(234547,9,9),(234554,9,11),(234555,9,13),(234556,9,15),(234557,9,16),(234558,9,17),(234559,9,18),(234560,9,19),(234561,9,20),(234562,9,21),(234563,9,22),(234564,9,30),(234565,9,31),(234566,9,32),(234567,9,33),(234568,9,34),(234569,9,35),(234570,9,36),(234571,9,37),(234572,9,38),(234573,9,39),(234574,9,40),(234575,9,41),(234576,9,42),(234577,9,43),(234578,9,44),(234579,9,45),(234580,9,47),(234581,9,48),(234582,9,49),(234583,9,50),(234584,9,51),(234585,9,52),(234586,9,53),(234587,9,54),(234588,9,55),(234589,9,56),(234590,9,57),(234591,9,58),(234592,9,59),(234593,9,60),(234594,9,61),(234595,9,64),(234596,9,65),(234597,9,67),(234598,9,69),(234599,9,70),(234600,9,71),(234601,9,72),(234602,9,73),(234603,9,74),(234604,9,75),(234605,9,76),(234606,9,101),(234607,9,102),(234548,9,103),(234608,9,111),(234225,11,6),(234224,11,11),(235592,13,1),(235593,13,2),(235594,13,3),(235597,13,6),(235596,13,11),(235591,13,13),(235595,13,70),(235008,15,1),(235017,15,2),(235016,15,3),(235019,15,6),(235018,15,11),(235002,15,15),(235003,15,35),(235010,15,36),(235014,15,44),(235013,15,47),(235004,15,49),(235011,15,54),(235005,15,56),(235012,15,58),(235015,15,70),(235007,15,75),(235006,15,76),(235009,15,111),(235027,16,1),(235036,16,2),(235035,16,3),(235038,16,6),(235037,16,11),(235021,16,15),(235020,16,16),(235022,16,35),(235029,16,36),(235033,16,44),(235032,16,47),(235023,16,49),(235030,16,54),(235024,16,56),(235031,16,58),(235034,16,70),(235026,16,75),(235025,16,76),(235028,16,111),(234258,17,1),(234268,17,2),(234267,17,3),(234263,17,5),(234293,17,6),(234262,17,9),(234292,17,11),(234261,17,13),(234273,17,15),(234260,17,16),(234250,17,17),(234272,17,18),(234291,17,19),(234251,17,20),(234264,17,21),(234290,17,22),(234289,17,30),(234288,17,31),(234287,17,32),(234275,17,33),(234286,17,34),(234271,17,35),(234285,17,36),(234252,17,37),(234284,17,38),(234253,17,39),(234283,17,40),(234282,17,41),(234281,17,42),(234280,17,43),(234294,17,44),(234295,17,45),(234296,17,47),(234297,17,48),(234270,17,49),(234298,17,50),(234299,17,51),(234300,17,52),(234276,17,53),(234301,17,54),(234302,17,55),(234279,17,56),(234265,17,57),(234303,17,58),(234269,17,59),(234304,17,60),(234305,17,61),(234254,17,64),(234259,17,65),(234255,17,67),(234306,17,69),(234266,17,70),(234307,17,71),(234278,17,72),(234308,17,73),(234257,17,74),(234309,17,75),(234256,17,76),(234310,17,101),(234311,17,102),(234274,17,103),(234277,17,111),(235504,18,1),(235507,18,2),(235506,18,3),(235510,18,6),(235509,18,11),(235503,18,18),(235508,18,70),(235505,18,76),(235492,19,1),(235498,19,2),(235497,19,3),(235502,19,6),(235501,19,11),(235484,19,13),(235485,19,18),(235482,19,19),(235483,19,21),(235486,19,33),(235495,19,36),(235500,19,44),(235499,19,47),(235491,19,49),(235487,19,53),(235494,19,54),(235493,19,58),(235496,19,70),(235488,19,72),(235489,19,76),(235490,19,111),(235080,20,1),(235092,20,2),(235091,20,3),(235090,20,5),(235089,20,6),(235072,20,9),(235088,20,11),(235073,20,13),(235079,20,15),(235074,20,16),(235087,20,17),(235078,20,18),(235086,20,19),(235071,20,20),(235085,20,21),(235093,20,22),(235094,20,30),(235095,20,31),(235096,20,32),(235097,20,33),(235098,20,34),(235077,20,35),(235099,20,36),(235100,20,37),(235101,20,38),(235102,20,39),(235103,20,40),(235104,20,41),(235105,20,42),(235106,20,43),(235107,20,44),(235108,20,45),(235109,20,47),(235110,20,48),(235082,20,49),(235111,20,50),(235112,20,51),(235113,20,52),(235114,20,53),(235115,20,54),(235116,20,55),(235117,20,56),(235083,20,57),(235118,20,58),(235084,20,59),(235119,20,60),(235120,20,61),(235121,20,64),(235075,20,65),(235122,20,67),(235123,20,69),(235124,20,70),(235125,20,71),(235126,20,72),(235127,20,73),(235128,20,74),(235129,20,75),(235076,20,76),(235130,20,101),(235131,20,102),(235081,20,103),(235132,20,111),(235471,21,1),(235477,21,2),(235476,21,3),(235481,21,6),(235480,21,11),(235463,21,13),(235464,21,18),(235462,21,21),(235465,21,33),(235474,21,36),(235479,21,44),(235478,21,47),(235470,21,49),(235466,21,53),(235473,21,54),(235472,21,58),(235475,21,70),(235467,21,72),(235468,21,76),(235469,21,111),(235602,22,1),(235611,22,2),(235610,22,3),(235618,22,6),(235615,22,11),(235599,22,13),(235601,22,18),(235600,22,21),(235598,22,22),(235603,22,33),(235614,22,36),(235617,22,44),(235616,22,47),(235608,22,49),(235604,22,53),(235613,22,54),(235612,22,58),(235609,22,70),(235605,22,72),(235606,22,76),(235607,22,111),(234662,30,1),(234674,30,2),(234673,30,3),(234651,30,5),(234684,30,6),(234657,30,9),(234685,30,11),(234663,30,13),(234669,30,15),(234664,30,16),(234683,30,17),(234661,30,18),(234682,30,19),(234652,30,20),(234660,30,21),(234653,30,22),(234650,30,30),(234681,30,31),(234680,30,32),(234659,30,33),(234679,30,34),(234668,30,35),(234678,30,36),(234677,30,37),(234676,30,38),(234686,30,39),(234687,30,40),(234688,30,41),(234689,30,42),(234690,30,43),(234691,30,44),(234692,30,45),(234693,30,47),(234694,30,48),(234667,30,49),(234695,30,50),(234696,30,51),(234697,30,52),(234654,30,53),(234698,30,54),(234699,30,55),(234700,30,56),(234666,30,57),(234701,30,58),(234675,30,59),(234702,30,60),(234703,30,61),(234655,30,64),(234665,30,65),(234704,30,67),(234705,30,69),(234672,30,70),(234706,30,71),(234671,30,72),(234707,30,73),(234708,30,74),(234709,30,75),(234656,30,76),(234710,30,101),(234711,30,102),(234670,30,103),(234658,30,111),(234713,31,1),(234714,31,2),(234715,31,3),(234718,31,6),(234717,31,11),(234712,31,31),(234716,31,70),(234617,32,1),(234618,32,2),(234619,32,3),(234622,32,6),(234621,32,11),(234616,32,32),(234620,32,70),(234783,33,33),(234361,34,1),(234366,34,2),(234365,34,3),(234368,34,6),(234367,34,11),(234362,34,13),(234363,34,33),(234360,34,34),(234364,34,70),(234407,35,1),(234413,35,2),(234412,35,3),(234415,35,6),(234414,35,11),(234406,35,35),(234411,35,70),(234408,35,75),(234409,35,76),(234410,35,111),(235368,36,1),(235370,36,2),(235369,36,3),(235373,36,6),(235372,36,11),(235364,36,36),(235365,36,44),(235366,36,47),(235371,36,70),(235367,36,111),(234756,37,1),(234761,37,2),(234760,37,3),(234763,37,6),(234762,37,11),(234755,37,37),(234759,37,70),(234757,37,74),(234758,37,76),(234770,38,1),(234773,38,2),(234772,38,3),(234775,38,6),(234774,38,11),(234765,38,13),(234766,38,37),(234764,38,38),(234767,38,64),(234771,38,70),(234769,38,74),(234768,38,76),(234234,39,1),(234242,39,2),(234241,39,3),(234227,39,5),(234249,39,6),(234246,39,11),(234236,39,13),(234233,39,18),(234228,39,21),(234232,39,33),(234245,39,36),(234226,39,39),(234248,39,44),(234247,39,47),(234239,39,49),(234231,39,53),(234244,39,54),(234238,39,56),(234229,39,57),(234243,39,58),(234240,39,70),(234237,39,72),(234230,39,76),(234235,39,111),(234722,40,1),(234725,40,2),(234724,40,3),(234735,40,6),(234733,40,11),(234727,40,36),(234721,40,40),(234732,40,44),(234731,40,47),(234723,40,49),(234728,40,54),(234729,40,58),(234726,40,70),(234730,40,76),(234734,40,111),(234744,41,1),(234748,41,2),(234747,41,3),(234754,41,6),(234753,41,11),(234737,41,13),(234738,41,35),(234745,41,36),(234739,41,40),(234736,41,41),(234752,41,44),(234751,41,47),(234741,41,49),(234749,41,54),(234750,41,58),(234746,41,70),(234743,41,75),(234740,41,76),(234742,41,111),(234375,42,1),(234383,42,2),(234382,42,3),(234385,42,6),(234384,42,11),(234370,42,35),(234376,42,36),(234369,42,42),(234380,42,44),(234379,42,47),(234371,42,49),(234377,42,54),(234378,42,58),(234381,42,70),(234374,42,75),(234372,42,76),(234373,42,111),(234392,43,1),(234397,43,2),(234396,43,3),(234404,43,6),(234403,43,11),(234387,43,13),(234391,43,35),(234398,43,36),(234388,43,42),(234386,43,43),(234402,43,44),(234401,43,47),(234390,43,49),(234399,43,54),(234400,43,58),(234395,43,70),(234394,43,75),(234393,43,76),(234389,43,111),(234209,44,1),(234210,44,2),(234211,44,3),(234214,44,6),(234213,44,11),(234208,44,44),(234212,44,70),(234218,45,1),(234220,45,2),(234219,45,3),(234223,45,6),(234222,45,11),(234216,45,13),(234217,45,44),(234215,45,45),(234221,45,70),(234457,47,1),(234460,47,2),(234459,47,3),(234463,47,6),(234462,47,11),(234456,47,47),(234461,47,70),(234458,47,111),(234487,48,1),(234493,48,2),(234492,48,3),(234495,48,6),(234494,48,11),(234478,48,13),(234479,48,35),(234483,48,36),(234490,48,44),(234480,48,47),(234477,48,48),(234481,48,49),(234488,48,54),(234489,48,58),(234482,48,69),(234491,48,70),(234486,48,75),(234485,48,76),(234484,48,111),(235273,49,1),(235279,49,2),(235278,49,3),(235282,49,6),(235281,49,11),(235270,49,36),(235275,49,44),(235274,49,47),(235269,49,49),(235271,49,54),(235272,49,58),(235277,49,70),(235276,49,76),(235280,49,111),(235325,50,1),(235334,50,2),(235333,50,3),(235329,50,5),(235336,50,6),(235335,50,11),(235310,50,13),(235324,50,18),(235311,50,21),(235323,50,33),(235312,50,35),(235318,50,36),(235331,50,44),(235330,50,47),(235313,50,49),(235309,50,50),(235322,50,53),(235326,50,54),(235328,50,56),(235314,50,57),(235327,50,58),(235315,50,59),(235316,50,60),(235332,50,70),(235321,50,72),(235320,50,75),(235317,50,76),(235319,50,111),(235134,51,1),(235143,51,2),(235142,51,3),(235154,51,6),(235150,51,11),(235140,51,13),(235139,51,18),(235135,51,21),(235144,51,33),(235136,51,35),(235153,51,36),(235156,51,44),(235155,51,47),(235149,51,49),(235133,51,51),(235145,51,53),(235152,51,54),(235151,51,58),(235141,51,70),(235146,51,72),(235137,51,74),(235138,51,75),(235147,51,76),(235148,51,111),(235165,52,1),(235171,52,2),(235170,52,3),(235180,52,6),(235176,52,11),(235158,52,13),(235168,52,18),(235159,52,19),(235164,52,21),(235167,52,33),(235163,52,35),(235179,52,36),(235182,52,44),(235181,52,47),(235175,52,49),(235160,52,51),(235157,52,52),(235172,52,53),(235178,52,54),(235177,52,58),(235169,52,70),(235173,52,72),(235162,52,74),(235166,52,75),(235161,52,76),(235174,52,111),(234777,53,1),(234778,53,2),(234779,53,3),(234782,53,6),(234781,53,11),(234776,53,53),(234780,53,70),(234923,54,1),(234924,54,2),(234925,54,3),(234928,54,6),(234927,54,11),(234922,54,54),(234926,54,70),(234932,55,1),(234934,55,2),(234933,55,3),(234937,55,6),(234936,55,11),(234930,55,13),(234931,55,54),(234929,55,55),(234935,55,70),(234500,56,1),(234501,56,2),(234502,56,3),(234505,56,6),(234504,56,11),(234499,56,56),(234503,56,70),(234511,57,1),(234514,57,2),(234513,57,3),(234516,57,6),(234515,57,11),(234507,57,13),(234508,57,33),(234509,57,56),(234506,57,57),(234512,57,70),(234510,57,76),(235214,58,1),(235217,58,2),(235216,58,3),(235220,58,6),(235219,58,11),(235213,58,58),(235218,58,70),(235215,58,76),(235225,59,1),(235237,59,2),(235236,59,3),(235244,59,5),(235248,59,6),(235247,59,11),(235222,59,13),(235234,59,18),(235224,59,21),(235233,59,33),(235226,59,35),(235240,59,36),(235246,59,44),(235245,59,47),(235227,59,49),(235223,59,50),(235232,59,53),(235241,59,54),(235243,59,56),(235228,59,57),(235242,59,58),(235221,59,59),(235229,59,60),(235235,59,70),(235231,59,72),(235238,59,75),(235230,59,76),(235239,59,111),(235293,60,1),(235306,60,2),(235305,60,3),(235284,60,5),(235308,60,6),(235307,60,11),(235299,60,13),(235292,60,18),(235291,60,21),(235290,60,33),(235285,60,35),(235296,60,36),(235302,60,44),(235301,60,47),(235286,60,49),(235289,60,53),(235297,60,54),(235300,60,56),(235287,60,57),(235298,60,58),(235283,60,60),(235304,60,70),(235303,60,72),(235295,60,75),(235288,60,76),(235294,60,111),(235378,61,1),(235382,61,2),(235381,61,3),(235385,61,6),(235384,61,11),(235375,61,13),(235376,61,36),(235377,61,44),(235379,61,47),(235374,61,61),(235380,61,70),(235383,61,111),(235183,62,62),(234405,64,64),(235198,65,1),(235207,65,2),(235206,65,3),(235208,65,5),(235212,65,6),(235211,65,11),(235185,65,13),(235186,65,18),(235202,65,21),(235192,65,33),(235187,65,35),(235195,65,36),(235204,65,44),(235203,65,47),(235188,65,49),(235200,65,50),(235210,65,53),(235194,65,54),(235199,65,56),(235189,65,57),(235193,65,58),(235190,65,59),(235201,65,60),(235184,65,65),(235205,65,70),(235209,65,72),(235197,65,75),(235191,65,76),(235196,65,111),(235525,66,1),(235524,66,2),(235526,66,3),(235527,66,5),(235528,66,6),(235522,66,9),(235529,66,11),(235530,66,13),(235531,66,15),(235532,66,16),(235533,66,17),(235534,66,18),(235535,66,19),(235536,66,20),(235537,66,21),(235538,66,22),(235539,66,30),(235540,66,31),(235541,66,32),(235542,66,33),(235543,66,34),(235544,66,35),(235545,66,36),(235546,66,37),(235547,66,38),(235548,66,39),(235549,66,40),(235550,66,41),(235551,66,42),(235552,66,43),(235553,66,44),(235554,66,45),(235555,66,47),(235556,66,48),(235557,66,49),(235558,66,50),(235559,66,51),(235560,66,52),(235561,66,53),(235562,66,54),(235563,66,55),(235564,66,56),(235565,66,57),(235566,66,58),(235567,66,59),(235568,66,60),(235569,66,61),(235570,66,64),(235571,66,65),(235521,66,66),(235572,66,67),(235573,66,69),(235574,66,70),(235575,66,71),(235576,66,72),(235577,66,73),(235578,66,74),(235579,66,75),(235580,66,76),(235581,66,101),(235582,66,102),(235523,66,103),(235583,66,111),(234337,67,1),(234348,67,2),(234347,67,3),(234334,67,5),(234354,67,6),(234350,67,11),(234345,67,13),(234336,67,18),(234338,67,21),(234339,67,33),(234353,67,36),(234335,67,37),(234356,67,44),(234355,67,47),(234349,67,49),(234340,67,53),(234352,67,54),(234351,67,58),(234333,67,67),(234346,67,70),(234344,67,72),(234343,67,74),(234341,67,76),(234342,67,111),(234470,69,1),(234474,69,2),(234473,69,3),(234476,69,6),(234475,69,11),(234465,69,35),(234466,69,47),(234467,69,58),(234464,69,69),(234472,69,70),(234469,69,75),(234468,69,76),(234471,69,111),(235621,70,6),(235620,70,11),(235619,70,70),(234432,71,1),(234435,71,2),(234434,71,3),(234439,71,6),(234438,71,11),(234433,71,58),(234436,71,70),(234431,71,71),(234437,71,76),(234446,72,1),(234453,72,2),(234452,72,3),(234455,72,6),(234454,72,11),(234441,72,18),(234444,72,36),(234450,72,44),(234449,72,47),(234442,72,49),(234447,72,54),(234448,72,58),(234451,72,70),(234440,72,72),(234445,72,76),(234443,72,111),(234632,73,1),(234641,73,2),(234640,73,3),(234627,73,5),(234647,73,6),(234643,73,11),(234638,73,13),(234631,73,18),(234628,73,19),(234630,73,21),(234633,73,33),(234646,73,36),(234649,73,44),(234648,73,47),(234642,73,49),(234634,73,53),(234645,73,54),(234644,73,58),(234629,73,64),(234639,73,70),(234637,73,72),(234626,73,73),(234635,73,76),(234636,73,111),(235622,74,74),(234429,75,75),(234430,76,76),(235413,100,1),(235408,100,2),(235394,100,3),(235392,100,5),(235421,100,6),(235412,100,9),(235389,100,11),(235458,100,13),(235433,100,15),(235434,100,16),(235391,100,17),(235454,100,18),(235453,100,19),(235437,100,20),(235452,100,21),(235459,100,22),(235418,100,30),(235419,100,31),(235415,100,32),(235427,100,33),(235395,100,34),(235399,100,35),(235450,100,36),(235424,100,37),(235425,100,38),(235390,100,39),(235422,100,40),(235423,100,41),(235396,100,42),(235397,100,43),(235387,100,44),(235388,100,45),(235405,100,47),(235407,100,48),(235446,100,49),(235448,100,50),(235438,100,51),(235439,100,52),(235426,100,53),(235430,100,54),(235431,100,55),(235409,100,56),(235410,100,57),(235442,100,58),(235443,100,59),(235447,100,60),(235451,100,61),(235440,100,62),(235398,100,64),(235441,100,65),(235456,100,66),(235393,100,67),(235406,100,69),(235460,100,70),(235403,100,71),(235404,100,72),(235417,100,73),(235461,100,74),(235401,100,75),(235402,100,76),(235386,100,100),(235400,100,101),(235445,100,102),(235428,100,103),(235429,100,104),(235420,100,105),(235416,100,106),(235449,100,107),(235457,100,108),(235455,100,109),(235444,100,110),(235414,100,111),(235435,100,112),(235436,100,114),(235432,100,115),(235411,100,116),(234422,101,1),(234426,101,2),(234425,101,3),(234428,101,6),(234427,101,11),(234417,101,13),(234418,101,18),(234419,101,35),(234424,101,70),(234420,101,75),(234421,101,76),(234416,101,101),(234423,101,111),(235258,102,1),(235263,102,2),(235262,102,3),(235268,102,6),(235267,102,11),(235259,102,13),(235260,102,35),(235261,102,70),(235264,102,75),(235265,102,76),(235257,102,102),(235266,102,111),(234785,103,1),(234786,103,2),(234787,103,3),(234788,103,5),(234789,103,6),(234844,103,9),(234790,103,11),(234791,103,13),(234792,103,15),(234793,103,16),(234794,103,17),(234795,103,18),(234796,103,19),(234797,103,20),(234798,103,21),(234799,103,22),(234800,103,30),(234801,103,31),(234802,103,32),(234803,103,33),(234804,103,34),(234805,103,35),(234806,103,36),(234807,103,37),(234808,103,38),(234809,103,39),(234810,103,40),(234811,103,41),(234812,103,42),(234813,103,43),(234814,103,44),(234815,103,45),(234816,103,47),(234817,103,48),(234818,103,49),(234819,103,50),(234820,103,51),(234821,103,52),(234822,103,53),(234823,103,54),(234824,103,55),(234825,103,56),(234826,103,57),(234827,103,58),(234828,103,59),(234829,103,60),(234830,103,61),(234831,103,64),(234832,103,65),(234833,103,67),(234834,103,69),(234835,103,70),(234836,103,71),(234837,103,72),(234838,103,73),(234839,103,74),(234840,103,75),(234841,103,76),(234842,103,101),(234843,103,102),(234784,103,103),(234845,103,111),(234854,104,1),(234853,104,2),(234852,104,3),(234855,104,5),(234856,104,6),(234850,104,9),(234857,104,11),(234858,104,13),(234859,104,15),(234860,104,16),(234861,104,17),(234862,104,18),(234863,104,19),(234864,104,20),(234865,104,21),(234866,104,22),(234867,104,30),(234868,104,31),(234869,104,32),(234870,104,33),(234871,104,34),(234872,104,35),(234873,104,36),(234874,104,37),(234875,104,38),(234876,104,39),(234877,104,40),(234878,104,41),(234879,104,42),(234880,104,43),(234881,104,44),(234882,104,45),(234883,104,47),(234884,104,48),(234885,104,49),(234886,104,50),(234887,104,51),(234888,104,52),(234889,104,53),(234890,104,54),(234891,104,55),(234892,104,56),(234893,104,57),(234894,104,58),(234895,104,59),(234896,104,60),(234897,104,61),(234917,104,62),(234898,104,64),(234899,104,65),(234849,104,66),(234900,104,67),(234901,104,69),(234902,104,70),(234903,104,71),(234904,104,72),(234905,104,73),(234906,104,74),(234907,104,75),(234908,104,76),(234847,104,100),(234909,104,101),(234910,104,102),(234851,104,103),(234846,104,104),(234914,104,105),(234913,104,106),(234919,104,107),(234921,104,108),(234920,104,109),(234918,104,110),(234911,104,111),(234915,104,112),(234916,104,114),(234848,104,115),(234912,104,116),(234719,105,105),(234625,106,6),(234624,106,11),(234623,106,106),(235348,107,1),(235361,107,2),(235360,107,3),(235339,107,5),(235363,107,6),(235362,107,11),(235354,107,13),(235347,107,18),(235346,107,21),(235345,107,33),(235340,107,35),(235351,107,36),(235357,107,44),(235356,107,47),(235341,107,49),(235344,107,53),(235352,107,54),(235355,107,56),(235342,107,57),(235353,107,58),(235338,107,60),(235359,107,70),(235358,107,72),(235350,107,75),(235343,107,76),(235337,107,107),(235349,107,111),(235585,108,1),(235586,108,2),(235587,108,3),(235590,108,6),(235589,108,11),(235588,108,70),(235584,108,108),(235515,109,1),(235517,109,2),(235516,109,3),(235520,109,6),(235519,109,11),(235512,109,13),(235513,109,18),(235518,109,70),(235514,109,76),(235511,109,109),(235250,110,1),(235253,110,2),(235252,110,3),(235256,110,6),(235255,110,11),(235254,110,70),(235251,110,76),(235249,110,110),(234615,111,111),(235040,112,1),(235043,112,2),(235042,112,3),(235053,112,6),(235051,112,11),(235045,112,36),(235050,112,44),(235049,112,47),(235041,112,49),(235046,112,54),(235047,112,58),(235044,112,70),(235048,112,76),(235052,112,111),(235039,112,112),(235058,114,1),(235060,114,2),(235059,114,3),(235070,114,6),(235068,114,11),(235055,114,13),(235062,114,36),(235067,114,44),(235066,114,47),(235057,114,49),(235063,114,54),(235064,114,58),(235061,114,70),(235065,114,76),(235069,114,111),(235056,114,112),(235054,114,114),(234944,115,1),(234943,115,2),(234942,115,3),(234945,115,5),(234946,115,6),(234939,115,9),(234947,115,11),(234948,115,13),(234949,115,15),(234950,115,16),(234951,115,17),(234952,115,18),(234953,115,19),(234954,115,20),(234955,115,21),(234956,115,22),(234957,115,30),(234958,115,31),(234959,115,32),(234960,115,33),(234961,115,34),(234962,115,35),(234963,115,36),(234964,115,37),(234965,115,38),(234966,115,39),(234967,115,40),(234968,115,41),(234969,115,42),(234970,115,43),(234971,115,44),(234972,115,45),(234973,115,47),(234974,115,48),(234975,115,49),(234976,115,50),(234977,115,51),(234978,115,52),(234979,115,53),(234980,115,54),(234981,115,55),(234982,115,56),(234983,115,57),(234984,115,58),(234985,115,59),(234986,115,60),(234987,115,61),(234988,115,64),(234989,115,65),(234940,115,66),(234990,115,67),(234991,115,69),(234992,115,70),(234993,115,71),(234994,115,72),(234995,115,73),(234996,115,74),(234997,115,75),(234998,115,76),(234999,115,101),(235000,115,102),(234941,115,103),(235001,115,111),(234938,115,115),(234533,116,1),(234544,116,2),(234543,116,3),(234521,116,5),(234546,116,6),(234545,116,11),(234537,116,13),(234532,116,18),(234525,116,19),(234531,116,21),(234530,116,33),(234520,116,35),(234534,116,36),(234540,116,44),(234539,116,47),(234522,116,49),(234529,116,53),(234535,116,54),(234538,116,56),(234523,116,57),(234536,116,58),(234518,116,60),(234526,116,64),(234542,116,70),(234541,116,72),(234519,116,73),(234527,116,75),(234524,116,76),(234528,116,111),(234517,116,116); /*!40000 ALTER TABLE `roleRole` ENABLE KEYS */; UNLOCK TABLES; @@ -140,11 +140,11 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2023-02-20 14:45:52 +-- Dump completed on 2023-05-16 8:24:00 USE `salix`; --- MariaDB dump 10.19 Distrib 10.5.18-MariaDB, for debian-linux-gnu (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.15-MariaDB, for debian-linux-gnu (x86_64) -- --- Host: db-proxy.verdnatura.es Database: salix +-- Host: db.verdnatura.es Database: salix -- ------------------------------------------------------ -- Server version 10.7.7-MariaDB-1:10.7.7+maria~deb11-log @@ -164,7 +164,7 @@ USE `salix`; LOCK TABLES `ACL` WRITE; /*!40000 ALTER TABLE `ACL` DISABLE KEYS */; -INSERT INTO `ACL` VALUES (1,'Account','*','*','ALLOW','ROLE','employee'),(3,'Address','*','*','ALLOW','ROLE','employee'),(5,'AgencyService','*','READ','ALLOW','ROLE','employee'),(7,'Client','*','*','ALLOW','ROLE','employee'),(9,'ClientObservation','*','*','ALLOW','ROLE','employee'),(11,'ContactChannel','*','READ','ALLOW','ROLE','trainee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','trainee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','trainee'),(18,'State','*','READ','ALLOW','ROLE','employee'),(20,'TicketState','*','*','ALLOW','ROLE','employee'),(24,'Delivery','*','READ','ALLOW','ROLE','employee'),(25,'Zone','*','READ','ALLOW','ROLE','employee'),(26,'ClientCredit','*','*','ALLOW','ROLE','employee'),(27,'ClientCreditLimit','*','READ','ALLOW','ROLE','trainee'),(30,'GreugeType','*','READ','ALLOW','ROLE','trainee'),(31,'Mandate','*','READ','ALLOW','ROLE','trainee'),(32,'MandateType','*','READ','ALLOW','ROLE','trainee'),(33,'Company','*','READ','ALLOW','ROLE','trainee'),(34,'Greuge','*','READ','ALLOW','ROLE','trainee'),(35,'AddressObservation','*','*','ALLOW','ROLE','employee'),(36,'ObservationType','*','*','ALLOW','ROLE','employee'),(37,'Greuge','*','WRITE','ALLOW','ROLE','employee'),(38,'AgencyMode','*','READ','ALLOW','ROLE','employee'),(39,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(40,'ItemBotanical','*','WRITE','ALLOW','ROLE','buyer'),(41,'ItemBotanical','*','READ','ALLOW','ROLE','employee'),(42,'ItemPlacement','*','WRITE','ALLOW','ROLE','buyer'),(43,'ItemPlacement','*','WRITE','ALLOW','ROLE','replenisher'),(44,'ItemPlacement','*','READ','ALLOW','ROLE','employee'),(45,'ItemBarcode','*','READ','ALLOW','ROLE','employee'),(46,'ItemBarcode','*','WRITE','ALLOW','ROLE','buyer'),(47,'ItemBarcode','*','WRITE','ALLOW','ROLE','replenisher'),(51,'ItemTag','*','READ','ALLOW','ROLE','employee'),(53,'Item','*','READ','ALLOW','ROLE','employee'),(54,'Item','*','WRITE','ALLOW','ROLE','buyer'),(55,'Recovery','*','READ','ALLOW','ROLE','trainee'),(56,'Recovery','*','WRITE','ALLOW','ROLE','administrative'),(58,'CreditClassification','*','*','ALLOW','ROLE','insurance'),(60,'CreditInsurance','*','*','ALLOW','ROLE','insurance'),(61,'InvoiceOut','*','READ','ALLOW','ROLE','employee'),(62,'Ticket','*','*','ALLOW','ROLE','employee'),(63,'TicketObservation','*','*','ALLOW','ROLE','employee'),(64,'Route','*','READ','ALLOW','ROLE','employee'),(65,'Sale','*','READ','ALLOW','ROLE','employee'),(66,'TicketTracking','*','READ','ALLOW','ROLE','employee'),(68,'TicketPackaging','*','*','ALLOW','ROLE','employee'),(69,'Packaging','*','READ','ALLOW','ROLE','employee'),(70,'Packaging','*','WRITE','ALLOW','ROLE','logistic'),(72,'SaleComponent','*','READ','ALLOW','ROLE','employee'),(73,'Expedition','*','READ','ALLOW','ROLE','employee'),(74,'Expedition','*','WRITE','ALLOW','ROLE','deliveryBoss'),(75,'Expedition','*','WRITE','ALLOW','ROLE','production'),(76,'AnnualAverageInvoiced','*','READ','ALLOW','ROLE','employee'),(77,'WorkerMana','*','READ','ALLOW','ROLE','employee'),(78,'TicketTracking','*','WRITE','ALLOW','ROLE','production'),(79,'TicketTracking','changeState','*','ALLOW','ROLE','employee'),(80,'Sale','deleteSales','*','ALLOW','ROLE','employee'),(81,'Sale','moveToTicket','*','ALLOW','ROLE','employee'),(82,'Sale','updateQuantity','*','ALLOW','ROLE','employee'),(83,'Sale','updatePrice','*','ALLOW','ROLE','employee'),(84,'Sale','updateDiscount','*','ALLOW','ROLE','employee'),(85,'SaleTracking','*','READ','ALLOW','ROLE','employee'),(86,'Order','*','*','ALLOW','ROLE','employee'),(87,'OrderRow','*','*','ALLOW','ROLE','employee'),(88,'ClientContact','*','*','ALLOW','ROLE','employee'),(89,'Sale','moveToNewTicket','*','ALLOW','ROLE','employee'),(90,'Sale','reserve','*','ALLOW','ROLE','employee'),(91,'TicketWeekly','*','READ','ALLOW','ROLE','employee'),(94,'Agency','landsThatDay','*','ALLOW','ROLE','employee'),(96,'ClaimEnd','*','READ','ALLOW','ROLE','employee'),(97,'ClaimEnd','*','WRITE','ALLOW','ROLE','claimManager'),(98,'ClaimBeginning','*','*','ALLOW','ROLE','employee'),(99,'ClaimDevelopment','*','READ','ALLOW','ROLE','employee'),(100,'ClaimDevelopment','*','WRITE','ALLOW','ROLE','claimManager'),(101,'Claim','*','*','ALLOW','ROLE','employee'),(102,'Claim','createFromSales','*','ALLOW','ROLE','employee'),(104,'Item','*','WRITE','ALLOW','ROLE','marketingBoss'),(105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketingBoss'),(106,'ItemBotanical','*','WRITE','ALLOW','ROLE','marketingBoss'),(108,'ItemPlacement','*','WRITE','ALLOW','ROLE','marketingBoss'),(109,'UserConfig','*','*','ALLOW','ROLE','employee'),(110,'Bank','*','READ','ALLOW','ROLE','trainee'),(111,'ClientLog','*','READ','ALLOW','ROLE','trainee'),(112,'Defaulter','*','READ','ALLOW','ROLE','employee'),(113,'ClientRisk','*','READ','ALLOW','ROLE','trainee'),(114,'Receipt','*','READ','ALLOW','ROLE','trainee'),(115,'Receipt','*','WRITE','ALLOW','ROLE','administrative'),(116,'BankEntity','*','*','ALLOW','ROLE','employee'),(117,'ClientSample','*','*','ALLOW','ROLE','employee'),(118,'WorkerTeam','*','*','ALLOW','ROLE','salesPerson'),(119,'Travel','*','READ','ALLOW','ROLE','employee'),(120,'Travel','*','WRITE','ALLOW','ROLE','buyer'),(121,'Item','regularize','*','ALLOW','ROLE','employee'),(122,'TicketRequest','*','*','ALLOW','ROLE','employee'),(123,'Worker','*','READ','ALLOW','ROLE','employee'),(124,'Client','confirmTransaction','WRITE','ALLOW','ROLE','administrative'),(125,'Agency','getAgenciesWithWarehouse','*','ALLOW','ROLE','employee'),(126,'Client','activeWorkersWithRole','*','ALLOW','ROLE','employee'),(127,'TicketLog','*','READ','ALLOW','ROLE','employee'),(129,'TicketService','*','*','ALLOW','ROLE','employee'),(130,'Expedition','*','WRITE','ALLOW','ROLE','packager'),(131,'CreditInsurance','*','READ','ALLOW','ROLE','trainee'),(132,'CreditClassification','*','READ','ALLOW','ROLE','trainee'),(133,'ItemTag','*','WRITE','ALLOW','ROLE','marketingBoss'),(135,'ZoneGeo','*','READ','ALLOW','ROLE','employee'),(136,'ZoneCalendar','*','READ','ALLOW','ROLE','employee'),(137,'ZoneIncluded','*','READ','ALLOW','ROLE','employee'),(138,'LabourHoliday','*','READ','ALLOW','ROLE','employee'),(139,'LabourHolidayLegend','*','READ','ALLOW','ROLE','employee'),(140,'LabourHolidayType','*','READ','ALLOW','ROLE','employee'),(141,'Zone','*','*','ALLOW','ROLE','deliveryBoss'),(142,'ZoneCalendar','*','WRITE','ALLOW','ROLE','deliveryBoss'),(143,'ZoneIncluded','*','*','ALLOW','ROLE','deliveryBoss'),(144,'Stowaway','*','*','ALLOW','ROLE','employee'),(145,'Ticket','getPossibleStowaways','READ','ALLOW','ROLE','employee'),(147,'UserConfigView','*','*','ALLOW','ROLE','employee'),(148,'UserConfigView','*','*','ALLOW','ROLE','employee'),(149,'Sip','*','READ','ALLOW','ROLE','employee'),(150,'Sip','*','WRITE','ALLOW','ROLE','hr'),(151,'Department','*','READ','ALLOW','ROLE','employee'),(152,'Department','*','WRITE','ALLOW','ROLE','hr'),(153,'Route','*','READ','ALLOW','ROLE','employee'),(154,'Route','*','WRITE','ALLOW','ROLE','delivery'),(155,'Calendar','*','READ','ALLOW','ROLE','hr'),(156,'WorkerLabour','*','READ','ALLOW','ROLE','hr'),(157,'Calendar','absences','READ','ALLOW','ROLE','employee'),(158,'ItemTag','*','WRITE','ALLOW','ROLE','accessory'),(160,'TicketServiceType','*','READ','ALLOW','ROLE','employee'),(161,'TicketConfig','*','READ','ALLOW','ROLE','employee'),(162,'InvoiceOut','delete','WRITE','ALLOW','ROLE','invoicing'),(163,'InvoiceOut','book','WRITE','ALLOW','ROLE','invoicing'),(165,'TicketDms','*','*','ALLOW','ROLE','employee'),(167,'Worker','isSubordinate','READ','ALLOW','ROLE','employee'),(168,'Worker','mySubordinates','READ','ALLOW','ROLE','employee'),(169,'WorkerTimeControl','filter','READ','ALLOW','ROLE','employee'),(170,'WorkerTimeControl','addTime','WRITE','ALLOW','ROLE','employee'),(171,'TicketServiceType','*','WRITE','ALLOW','ROLE','administrative'),(172,'Sms','*','READ','ALLOW','ROLE','employee'),(173,'Sms','send','WRITE','ALLOW','ROLE','employee'),(174,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(175,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(176,'Device','*','*','ALLOW','ROLE','employee'),(177,'Device','*','*','ALLOW','ROLE','employee'),(178,'WorkerTimeControl','*','*','ALLOW','ROLE','employee'),(179,'ItemLog','*','READ','ALLOW','ROLE','employee'),(180,'RouteLog','*','READ','ALLOW','ROLE','employee'),(181,'Dms','removeFile','WRITE','ALLOW','ROLE','employee'),(182,'Dms','uploadFile','WRITE','ALLOW','ROLE','employee'),(183,'Dms','downloadFile','READ','ALLOW','ROLE','employee'),(184,'Client','uploadFile','WRITE','ALLOW','ROLE','employee'),(185,'ClientDms','removeFile','WRITE','ALLOW','ROLE','employee'),(186,'ClientDms','*','READ','ALLOW','ROLE','trainee'),(187,'Ticket','uploadFile','WRITE','ALLOW','ROLE','employee'),(190,'Route','updateVolume','WRITE','ALLOW','ROLE','deliveryBoss'),(191,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(192,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(194,'Postcode','*','WRITE','ALLOW','ROLE','deliveryBoss'),(195,'Ticket','addSale','WRITE','ALLOW','ROLE','employee'),(196,'Dms','updateFile','WRITE','ALLOW','ROLE','employee'),(197,'Dms','*','READ','ALLOW','ROLE','trainee'),(198,'ClaimDms','removeFile','WRITE','ALLOW','ROLE','employee'),(199,'ClaimDms','*','READ','ALLOW','ROLE','employee'),(200,'Claim','uploadFile','WRITE','ALLOW','ROLE','employee'),(201,'Sale','updateConcept','WRITE','ALLOW','ROLE','employee'),(202,'Claim','updateClaimAction','WRITE','ALLOW','ROLE','claimManager'),(203,'UserPhone','*','*','ALLOW','ROLE','employee'),(204,'WorkerDms','removeFile','WRITE','ALLOW','ROLE','hr'),(205,'WorkerDms','*','READ','ALLOW','ROLE','hr'),(206,'Chat','*','*','ALLOW','ROLE','employee'),(207,'Chat','sendMessage','*','ALLOW','ROLE','employee'),(208,'Sale','recalculatePrice','WRITE','ALLOW','ROLE','employee'),(209,'Ticket','recalculateComponents','WRITE','ALLOW','ROLE','employee'),(211,'TravelLog','*','READ','ALLOW','ROLE','buyer'),(212,'Thermograph','*','*','ALLOW','ROLE','buyer'),(213,'TravelThermograph','*','WRITE','ALLOW','ROLE','buyer'),(214,'Entry','*','*','ALLOW','ROLE','buyer'),(215,'TicketWeekly','*','WRITE','ALLOW','ROLE','buyer'),(216,'TravelThermograph','*','READ','ALLOW','ROLE','employee'),(218,'Intrastat','*','*','ALLOW','ROLE','buyer'),(219,'Account','acl','READ','ALLOW','ROLE','account'),(220,'Account','getCurrentUserData','READ','ALLOW','ROLE','account'),(221,'UserConfig','getUserConfig','READ','ALLOW','ROLE','account'),(222,'Client','*','READ','ALLOW','ROLE','trainee'),(226,'ClientObservation','*','READ','ALLOW','ROLE','trainee'),(227,'Address','*','READ','ALLOW','ROLE','trainee'),(228,'AddressObservation','*','READ','ALLOW','ROLE','trainee'),(230,'ClientCredit','*','READ','ALLOW','ROLE','trainee'),(231,'ClientContact','*','READ','ALLOW','ROLE','trainee'),(232,'ClientSample','*','READ','ALLOW','ROLE','trainee'),(233,'EntryLog','*','READ','ALLOW','ROLE','buyer'),(234,'WorkerLog','*','READ','ALLOW','ROLE','salesAssistant'),(235,'CustomsAgent','*','*','ALLOW','ROLE','employee'),(236,'Buy','*','*','ALLOW','ROLE','buyer'),(237,'WorkerDms','filter','*','ALLOW','ROLE','employee'),(238,'Town','*','WRITE','ALLOW','ROLE','deliveryBoss'),(239,'Province','*','WRITE','ALLOW','ROLE','deliveryBoss'),(240,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(241,'SupplierContact','*','WRITE','ALLOW','ROLE','administrative'),(242,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(244,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(246,'Account','changePassword','*','ALLOW','ROLE','account'),(247,'UserAccount','exists','*','ALLOW','ROLE','account'),(248,'RoleMapping','*','READ','ALLOW','ROLE','account'),(249,'UserPassword','*','READ','ALLOW','ROLE','account'),(250,'Town','*','WRITE','ALLOW','ROLE','deliveryBoss'),(251,'Province','*','WRITE','ALLOW','ROLE','deliveryBoss'),(252,'Supplier','*','READ','ALLOW','ROLE','employee'),(253,'Supplier','*','WRITE','ALLOW','ROLE','administrative'),(254,'SupplierLog','*','READ','ALLOW','ROLE','employee'),(256,'Image','*','WRITE','ALLOW','ROLE','employee'),(257,'FixedPrice','*','*','ALLOW','ROLE','buyer'),(258,'PayDem','*','READ','ALLOW','ROLE','employee'),(259,'Client','createReceipt','*','ALLOW','ROLE','salesAssistant'),(260,'PrintServerQueue','*','WRITE','ALLOW','ROLE','employee'),(261,'SupplierAccount','*','*','ALLOW','ROLE','administrative'),(262,'Entry','*','*','ALLOW','ROLE','administrative'),(263,'InvoiceIn','*','*','ALLOW','ROLE','administrative'),(264,'StarredModule','*','*','ALLOW','ROLE','employee'),(265,'ItemBotanical','*','WRITE','ALLOW','ROLE','logisticBoss'),(266,'ZoneLog','*','READ','ALLOW','ROLE','employee'),(267,'Genus','*','WRITE','ALLOW','ROLE','logisticBoss'),(268,'Specie','*','WRITE','ALLOW','ROLE','logisticBoss'),(269,'InvoiceOut','createPdf','WRITE','ALLOW','ROLE','employee'),(270,'SupplierAddress','*','*','ALLOW','ROLE','employee'),(271,'SalesMonitor','*','*','ALLOW','ROLE','employee'),(272,'InvoiceInLog','*','*','ALLOW','ROLE','employee'),(273,'InvoiceInTax','*','*','ALLOW','ROLE','administrative'),(274,'InvoiceInLog','*','READ','ALLOW','ROLE','administrative'),(275,'InvoiceOut','createManualInvoice','WRITE','ALLOW','ROLE','invoicing'),(276,'InvoiceOut','globalInvoicing','WRITE','ALLOW','ROLE','invoicing'),(277,'Role','*','*','ALLOW','ROLE','it'),(278,'RoleInherit','*','WRITE','ALLOW','ROLE','grant'),(279,'MailAlias','*','*','ALLOW','ROLE','marketing'),(282,'UserAccount','*','WRITE','ALLOW','ROLE','it'),(283,'EntryObservation','*','*','ALLOW','ROLE','buyer'),(284,'LdapConfig','*','*','ALLOW','ROLE','sysadmin'),(285,'SambaConfig','*','*','ALLOW','ROLE','sysadmin'),(286,'ACL','*','*','ALLOW','ROLE','developer'),(287,'AccessToken','*','*','ALLOW','ROLE','developer'),(288,'MailAliasAccount','*','*','ALLOW','ROLE','marketing'),(289,'MailAliasAccount','*','*','ALLOW','ROLE','hr'),(290,'MailAlias','*','*','ALLOW','ROLE','hr'),(291,'MailForward','*','*','ALLOW','ROLE','marketing'),(292,'MailForward','*','*','ALLOW','ROLE','hr'),(293,'RoleInherit','*','*','ALLOW','ROLE','it'),(294,'RoleRole','*','*','ALLOW','ROLE','it'),(295,'AccountConfig','*','*','ALLOW','ROLE','sysadmin'),(296,'Collection','*','READ','ALLOW','ROLE','employee'),(297,'Sale','refund','WRITE','ALLOW','ROLE','invoicing'),(298,'InvoiceInDueDay','*','*','ALLOW','ROLE','administrative'),(299,'Collection','setSaleQuantity','*','ALLOW','ROLE','employee'),(300,'Docuware','*','*','ALLOW','ROLE','employee'),(301,'Agency','*','READ','ALLOW','ROLE','employee'),(302,'AgencyTerm','*','*','ALLOW','ROLE','administrative'),(303,'ClaimLog','*','READ','ALLOW','ROLE','claimManager'),(304,'Edi','updateData','WRITE','ALLOW','ROLE','employee'),(305,'EducationLevel','*','*','ALLOW','ROLE','employee'),(306,'InvoiceInIntrastat','*','*','ALLOW','ROLE','employee'),(307,'SupplierAgencyTerm','*','*','ALLOW','ROLE','administrative'),(308,'InvoiceInIntrastat','*','*','ALLOW','ROLE','employee'),(309,'Zone','getZoneClosing','*','ALLOW','ROLE','employee'),(310,'ExpeditionState','*','READ','ALLOW','ROLE','employee'),(311,'Expense','*','READ','ALLOW','ROLE','employee'),(312,'Expense','*','WRITE','ALLOW','ROLE','administrative'),(314,'SupplierActivity','*','READ','ALLOW','ROLE','employee'),(315,'SupplierActivity','*','WRITE','ALLOW','ROLE','administrative'),(316,'Dms','deleteTrashFiles','WRITE','ALLOW','ROLE','employee'),(317,'ClientUnpaid','*','*','ALLOW','ROLE','administrative'),(318,'MdbVersion','*','*','ALLOW','ROLE','developer'),(319,'ItemType','*','READ','ALLOW','ROLE','employee'),(320,'ItemType','*','WRITE','ALLOW','ROLE','buyer'),(321,'InvoiceOut','refund','WRITE','ALLOW','ROLE','invoicing'),(322,'InvoiceOut','refund','WRITE','ALLOW','ROLE','salesAssistant'),(323,'InvoiceOut','refund','WRITE','ALLOW','ROLE','claimManager'),(324,'Ticket','refund','WRITE','ALLOW','ROLE','invoicing'),(325,'Ticket','refund','WRITE','ALLOW','ROLE','salesAssistant'),(326,'Ticket','refund','WRITE','ALLOW','ROLE','claimManager'),(327,'Sale','refund','WRITE','ALLOW','ROLE','salesAssistant'),(328,'Sale','refund','WRITE','ALLOW','ROLE','claimManager'),(329,'TicketRefund','*','WRITE','ALLOW','ROLE','invoicing'),(330,'ClaimObservation','*','WRITE','ALLOW','ROLE','salesPerson'),(331,'ClaimObservation','*','READ','ALLOW','ROLE','salesPerson'),(332,'Client','setPassword','WRITE','ALLOW','ROLE','salesPerson'),(333,'Client','updateUser','WRITE','ALLOW','ROLE','salesPerson'),(334,'ShelvingLog','*','READ','ALLOW','ROLE','employee'),(335,'ZoneExclusionGeo','*','READ','ALLOW','ROLE','employee'),(336,'ZoneExclusionGeo','*','WRITE','ALLOW','ROLE','deliveryBoss'),(337,'Parking','*','*','ALLOW','ROLE','employee'),(338,'Shelving','*','*','ALLOW','ROLE','employee'),(339,'OsTicket','*','*','ALLOW','ROLE','employee'),(340,'OsTicketConfig','*','*','ALLOW','ROLE','it'),(341,'ClientConsumptionQueue','*','WRITE','ALLOW','ROLE','employee'),(342,'Ticket','deliveryNotePdf','READ','ALLOW','ROLE','employee'),(343,'Ticket','deliveryNoteEmail','WRITE','ALLOW','ROLE','employee'),(344,'Ticket','deliveryNoteCsvPdf','READ','ALLOW','ROLE','employee'),(345,'Ticket','deliveryNoteCsvEmail','WRITE','ALLOW','ROLE','employee'),(346,'Client','campaignMetricsPdf','READ','ALLOW','ROLE','employee'),(347,'Client','campaignMetricsEmail','WRITE','ALLOW','ROLE','employee'),(348,'Client','clientWelcomeHtml','READ','ALLOW','ROLE','employee'),(349,'Client','clientWelcomeEmail','WRITE','ALLOW','ROLE','employee'),(350,'Client','creditRequestPdf','READ','ALLOW','ROLE','employee'),(351,'Client','creditRequestHtml','READ','ALLOW','ROLE','employee'),(352,'Client','creditRequestEmail','WRITE','ALLOW','ROLE','employee'),(353,'Client','printerSetupHtml','READ','ALLOW','ROLE','employee'),(354,'Client','printerSetupEmail','WRITE','ALLOW','ROLE','employee'),(355,'Client','sepaCoreEmail','WRITE','ALLOW','ROLE','employee'),(356,'Client','letterDebtorPdf','READ','ALLOW','ROLE','employee'),(357,'Client','letterDebtorStHtml','READ','ALLOW','ROLE','employee'),(358,'Client','letterDebtorStEmail','WRITE','ALLOW','ROLE','employee'),(359,'Client','letterDebtorNdHtml','READ','ALLOW','ROLE','employee'),(360,'Client','letterDebtorNdEmail','WRITE','ALLOW','ROLE','employee'),(361,'Client','clientDebtStatementPdf','READ','ALLOW','ROLE','employee'),(362,'Client','clientDebtStatementHtml','READ','ALLOW','ROLE','employee'),(363,'Client','clientDebtStatementEmail','WRITE','ALLOW','ROLE','employee'),(364,'Client','incotermsAuthorizationPdf','READ','ALLOW','ROLE','employee'),(365,'Client','incotermsAuthorizationHtml','READ','ALLOW','ROLE','employee'),(366,'Client','incotermsAuthorizationEmail','WRITE','ALLOW','ROLE','employee'),(367,'Client','consumptionSendQueued','WRITE','ALLOW','ROLE','system'),(368,'InvoiceOut','invoiceEmail','WRITE','ALLOW','ROLE','employee'),(369,'InvoiceOut','exportationPdf','READ','ALLOW','ROLE','employee'),(370,'InvoiceOut','sendQueued','WRITE','ALLOW','ROLE','system'),(371,'Ticket','invoiceCsvPdf','READ','ALLOW','ROLE','employee'),(372,'Ticket','invoiceCsvEmail','WRITE','ALLOW','ROLE','employee'),(373,'Supplier','campaignMetricsPdf','READ','ALLOW','ROLE','employee'),(374,'Supplier','campaignMetricsEmail','WRITE','ALLOW','ROLE','employee'),(375,'Travel','extraCommunityPdf','READ','ALLOW','ROLE','employee'),(376,'Travel','extraCommunityEmail','WRITE','ALLOW','ROLE','employee'),(377,'Entry','entryOrderPdf','READ','ALLOW','ROLE','employee'),(378,'OsTicket','osTicketReportEmail','WRITE','ALLOW','ROLE','system'),(379,'Item','buyerWasteEmail','WRITE','ALLOW','ROLE','system'),(380,'Claim','claimPickupPdf','READ','ALLOW','ROLE','employee'),(381,'Claim','claimPickupEmail','WRITE','ALLOW','ROLE','claimManager'),(382,'Item','labelPdf','READ','ALLOW','ROLE','employee'),(383,'Sector','*','READ','ALLOW','ROLE','employee'),(384,'Sector','*','WRITE','ALLOW','ROLE','employee'),(385,'Route','driverRoutePdf','READ','ALLOW','ROLE','employee'),(386,'Route','driverRouteEmail','WRITE','ALLOW','ROLE','employee'),(387,'Ticket','deliveryNotePdf','READ','ALLOW','ROLE','customer'),(388,'Supplier','newSupplier','WRITE','ALLOW','ROLE','administrative'),(389,'ClaimRma','*','READ','ALLOW','ROLE','claimManager'),(390,'ClaimRma','*','WRITE','ALLOW','ROLE','claimManager'),(391,'Notification','*','WRITE','ALLOW','ROLE','system'),(392,'Boxing','*','*','ALLOW','ROLE','employee'),(393,'Url','*','READ','ALLOW','ROLE','employee'),(394,'Url','*','WRITE','ALLOW','ROLE','it'),(395,'ItemShelving','*','READ','ALLOW','ROLE','employee'),(396,'ItemShelving','*','WRITE','ALLOW','ROLE','production'),(397,'ItemShelvingPlacementSupplyStock','*','READ','ALLOW','ROLE','employee'),(398,'NotificationQueue','*','*','ALLOW','ROLE','employee'),(399,'InvoiceOut','clientsToInvoice','WRITE','ALLOW','ROLE','invoicing'),(400,'InvoiceOut','invoiceClient','WRITE','ALLOW','ROLE','invoicing'),(401,'Sale','editTracked','WRITE','ALLOW','ROLE','production'),(402,'Sale','editFloramondo','WRITE','ALLOW','ROLE','salesAssistant'),(403,'Receipt','balanceCompensationEmail','WRITE','ALLOW','ROLE','employee'),(404,'Receipt','balanceCompensationPdf','READ','ALLOW','ROLE','employee'),(405,'Ticket','getTicketsFuture','READ','ALLOW','ROLE','employee'),(406,'Ticket','merge','WRITE','ALLOW','ROLE','employee'),(407,'Sale','editFloramondo','WRITE','ALLOW','ROLE','logistic'),(408,'ZipConfig','*','*','ALLOW','ROLE','employee'),(409,'Item','*','WRITE','ALLOW','ROLE','administrative'),(410,'Sale','editCloned','WRITE','ALLOW','ROLE','buyer'),(411,'Sale','editCloned','WRITE','ALLOW','ROLE','salesAssistant'),(414,'MdbVersion','*','READ','ALLOW','ROLE','$everyone'),(415,'Dms','saveSign','*','ALLOW','ROLE','employee'),(416,'TicketLog','getChanges','READ','ALLOW','ROLE','employee'),(417,'Ticket','getTicketsAdvance','READ','ALLOW','ROLE','employee'),(418,'EntryLog','*','READ','ALLOW','ROLE','administrative'),(419,'Sale','editTracked','WRITE','ALLOW','ROLE','buyer'),(420,'MdbBranch','*','READ','ALLOW','ROLE','$everyone'),(421,'ItemShelvingSale','*','*','ALLOW','ROLE','employee'),(422,'Docuware','checkFile','READ','ALLOW','ROLE','employee'),(423,'Docuware','download','READ','ALLOW','ROLE','salesPerson'),(424,'Docuware','upload','WRITE','ALLOW','ROLE','productionAssi'),(425,'Docuware','deliveryNoteEmail','WRITE','ALLOW','ROLE','salesPerson'),(426,'TpvTransaction','confirm','WRITE','ALLOW','ROLE','$everyone'),(427,'TpvTransaction','start','WRITE','ALLOW','ROLE','$authenticated'),(428,'TpvTransaction','end','WRITE','ALLOW','ROLE','$authenticated'),(429,'ItemConfig','*','READ','ALLOW','ROLE','employee'),(431,'Tag','onSubmit','WRITE','ALLOW','ROLE','employee'),(432,'Worker','updateAttributes','WRITE','ALLOW','ROLE','hr'),(433,'Worker','createAbsence','*','ALLOW','ROLE','employee'),(434,'Worker','updateAbsence','WRITE','ALLOW','ROLE','employee'),(435,'Worker','deleteAbsence','*','ALLOW','ROLE','employee'),(436,'Worker','new','WRITE','ALLOW','ROLE','hr'),(437,'Role','*','READ','ALLOW','ROLE','hr'),(438,'Client','getClientOrSupplierReference','READ','ALLOW','ROLE','employee'); +INSERT INTO `ACL` VALUES (1,'Account','*','*','ALLOW','ROLE','employee'),(3,'Address','*','*','ALLOW','ROLE','employee'),(5,'AgencyService','*','READ','ALLOW','ROLE','employee'),(9,'ClientObservation','*','*','ALLOW','ROLE','employee'),(11,'ContactChannel','*','READ','ALLOW','ROLE','trainee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','trainee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','trainee'),(18,'State','*','READ','ALLOW','ROLE','employee'),(20,'TicketState','*','*','ALLOW','ROLE','employee'),(24,'Delivery','*','READ','ALLOW','ROLE','employee'),(25,'Zone','*','READ','ALLOW','ROLE','employee'),(26,'ClientCredit','*','*','ALLOW','ROLE','employee'),(27,'ClientCreditLimit','*','READ','ALLOW','ROLE','trainee'),(30,'GreugeType','*','READ','ALLOW','ROLE','trainee'),(31,'Mandate','*','READ','ALLOW','ROLE','trainee'),(32,'MandateType','*','READ','ALLOW','ROLE','trainee'),(33,'Company','*','READ','ALLOW','ROLE','trainee'),(34,'Greuge','*','READ','ALLOW','ROLE','trainee'),(35,'AddressObservation','*','*','ALLOW','ROLE','employee'),(36,'ObservationType','*','*','ALLOW','ROLE','employee'),(37,'Greuge','*','WRITE','ALLOW','ROLE','employee'),(38,'AgencyMode','*','READ','ALLOW','ROLE','employee'),(39,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(40,'ItemBotanical','*','WRITE','ALLOW','ROLE','buyer'),(41,'ItemBotanical','*','READ','ALLOW','ROLE','employee'),(42,'ItemPlacement','*','WRITE','ALLOW','ROLE','buyer'),(43,'ItemPlacement','*','WRITE','ALLOW','ROLE','replenisher'),(44,'ItemPlacement','*','READ','ALLOW','ROLE','employee'),(45,'ItemBarcode','*','READ','ALLOW','ROLE','employee'),(46,'ItemBarcode','*','WRITE','ALLOW','ROLE','buyer'),(47,'ItemBarcode','*','WRITE','ALLOW','ROLE','replenisher'),(51,'ItemTag','*','READ','ALLOW','ROLE','employee'),(53,'Item','*','READ','ALLOW','ROLE','employee'),(54,'Item','*','WRITE','ALLOW','ROLE','buyer'),(55,'Recovery','*','READ','ALLOW','ROLE','trainee'),(56,'Recovery','*','WRITE','ALLOW','ROLE','administrative'),(58,'CreditClassification','*','*','ALLOW','ROLE','insurance'),(60,'CreditInsurance','*','*','ALLOW','ROLE','insurance'),(61,'InvoiceOut','*','READ','ALLOW','ROLE','employee'),(62,'Ticket','*','*','ALLOW','ROLE','employee'),(63,'TicketObservation','*','*','ALLOW','ROLE','employee'),(64,'Route','*','READ','ALLOW','ROLE','employee'),(65,'Sale','*','READ','ALLOW','ROLE','employee'),(66,'TicketTracking','*','READ','ALLOW','ROLE','employee'),(68,'TicketPackaging','*','*','ALLOW','ROLE','employee'),(69,'Packaging','*','READ','ALLOW','ROLE','employee'),(70,'Packaging','*','WRITE','ALLOW','ROLE','logistic'),(72,'SaleComponent','*','READ','ALLOW','ROLE','employee'),(73,'Expedition','*','READ','ALLOW','ROLE','employee'),(74,'Expedition','*','WRITE','ALLOW','ROLE','deliveryBoss'),(75,'Expedition','*','WRITE','ALLOW','ROLE','production'),(76,'AnnualAverageInvoiced','*','READ','ALLOW','ROLE','employee'),(77,'WorkerMana','*','READ','ALLOW','ROLE','employee'),(78,'TicketTracking','*','WRITE','ALLOW','ROLE','production'),(79,'TicketTracking','changeState','*','ALLOW','ROLE','employee'),(80,'Sale','deleteSales','*','ALLOW','ROLE','employee'),(81,'Sale','moveToTicket','*','ALLOW','ROLE','employee'),(82,'Sale','updateQuantity','*','ALLOW','ROLE','employee'),(83,'Sale','updatePrice','*','ALLOW','ROLE','employee'),(84,'Sale','updateDiscount','*','ALLOW','ROLE','employee'),(85,'SaleTracking','*','READ','ALLOW','ROLE','employee'),(86,'Order','*','*','ALLOW','ROLE','employee'),(87,'OrderRow','*','*','ALLOW','ROLE','employee'),(88,'ClientContact','*','*','ALLOW','ROLE','employee'),(89,'Sale','moveToNewTicket','*','ALLOW','ROLE','employee'),(90,'Sale','reserve','*','ALLOW','ROLE','employee'),(91,'TicketWeekly','*','READ','ALLOW','ROLE','employee'),(94,'Agency','landsThatDay','*','ALLOW','ROLE','employee'),(96,'ClaimEnd','*','READ','ALLOW','ROLE','employee'),(97,'ClaimEnd','*','WRITE','ALLOW','ROLE','claimManager'),(98,'ClaimBeginning','*','*','ALLOW','ROLE','employee'),(99,'ClaimDevelopment','*','READ','ALLOW','ROLE','employee'),(100,'ClaimDevelopment','*','WRITE','ALLOW','ROLE','claimManager'),(101,'Claim','*','*','ALLOW','ROLE','employee'),(102,'Claim','createFromSales','*','ALLOW','ROLE','employee'),(104,'Item','*','WRITE','ALLOW','ROLE','marketingBoss'),(105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketingBoss'),(106,'ItemBotanical','*','WRITE','ALLOW','ROLE','marketingBoss'),(108,'ItemPlacement','*','WRITE','ALLOW','ROLE','marketingBoss'),(109,'UserConfig','*','*','ALLOW','ROLE','employee'),(110,'Bank','*','READ','ALLOW','ROLE','trainee'),(111,'ClientLog','*','READ','ALLOW','ROLE','trainee'),(112,'Defaulter','*','READ','ALLOW','ROLE','employee'),(113,'ClientRisk','*','READ','ALLOW','ROLE','trainee'),(114,'Receipt','*','READ','ALLOW','ROLE','trainee'),(115,'Receipt','*','WRITE','ALLOW','ROLE','administrative'),(116,'BankEntity','*','*','ALLOW','ROLE','employee'),(117,'ClientSample','*','*','ALLOW','ROLE','employee'),(118,'WorkerTeam','*','*','ALLOW','ROLE','salesPerson'),(119,'Travel','*','READ','ALLOW','ROLE','employee'),(120,'Travel','*','WRITE','ALLOW','ROLE','buyer'),(121,'Item','regularize','*','ALLOW','ROLE','employee'),(122,'TicketRequest','*','*','ALLOW','ROLE','employee'),(123,'Worker','*','READ','ALLOW','ROLE','employee'),(124,'Client','confirmTransaction','WRITE','ALLOW','ROLE','administrative'),(125,'Agency','getAgenciesWithWarehouse','*','ALLOW','ROLE','employee'),(126,'Client','activeWorkersWithRole','*','ALLOW','ROLE','employee'),(127,'TicketLog','*','READ','ALLOW','ROLE','employee'),(129,'TicketService','*','*','ALLOW','ROLE','employee'),(130,'Expedition','*','WRITE','ALLOW','ROLE','packager'),(131,'CreditInsurance','*','READ','ALLOW','ROLE','trainee'),(132,'CreditClassification','*','READ','ALLOW','ROLE','trainee'),(133,'ItemTag','*','WRITE','ALLOW','ROLE','marketingBoss'),(135,'ZoneGeo','*','READ','ALLOW','ROLE','employee'),(136,'ZoneCalendar','*','READ','ALLOW','ROLE','employee'),(137,'ZoneIncluded','*','READ','ALLOW','ROLE','employee'),(138,'LabourHoliday','*','READ','ALLOW','ROLE','employee'),(139,'LabourHolidayLegend','*','READ','ALLOW','ROLE','employee'),(140,'LabourHolidayType','*','READ','ALLOW','ROLE','employee'),(141,'Zone','*','*','ALLOW','ROLE','logisticBoss'),(142,'ZoneCalendar','*','WRITE','ALLOW','ROLE','deliveryBoss'),(143,'ZoneIncluded','*','*','ALLOW','ROLE','deliveryBoss'),(144,'Stowaway','*','*','ALLOW','ROLE','employee'),(145,'Ticket','getPossibleStowaways','READ','ALLOW','ROLE','employee'),(147,'UserConfigView','*','*','ALLOW','ROLE','employee'),(148,'UserConfigView','*','*','ALLOW','ROLE','employee'),(149,'Sip','*','READ','ALLOW','ROLE','employee'),(150,'Sip','*','WRITE','ALLOW','ROLE','hr'),(151,'Department','*','READ','ALLOW','ROLE','employee'),(152,'Department','*','WRITE','ALLOW','ROLE','hr'),(153,'Route','*','READ','ALLOW','ROLE','employee'),(154,'Route','*','WRITE','ALLOW','ROLE','delivery'),(155,'Calendar','*','READ','ALLOW','ROLE','hr'),(156,'WorkerLabour','*','READ','ALLOW','ROLE','hr'),(157,'Calendar','absences','READ','ALLOW','ROLE','employee'),(158,'ItemTag','*','WRITE','ALLOW','ROLE','accessory'),(160,'TicketServiceType','*','READ','ALLOW','ROLE','employee'),(161,'TicketConfig','*','READ','ALLOW','ROLE','employee'),(162,'InvoiceOut','delete','WRITE','ALLOW','ROLE','invoicing'),(163,'InvoiceOut','book','WRITE','ALLOW','ROLE','invoicing'),(165,'TicketDms','*','*','ALLOW','ROLE','employee'),(167,'Worker','isSubordinate','READ','ALLOW','ROLE','employee'),(168,'Worker','mySubordinates','READ','ALLOW','ROLE','employee'),(169,'WorkerTimeControl','filter','READ','ALLOW','ROLE','employee'),(170,'WorkerTimeControl','addTime','WRITE','ALLOW','ROLE','employee'),(171,'TicketServiceType','*','WRITE','ALLOW','ROLE','administrative'),(172,'Sms','*','READ','ALLOW','ROLE','employee'),(173,'Sms','send','WRITE','ALLOW','ROLE','employee'),(174,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(175,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(176,'Device','*','*','ALLOW','ROLE','employee'),(177,'Device','*','*','ALLOW','ROLE','employee'),(178,'WorkerTimeControl','*','*','ALLOW','ROLE','employee'),(179,'ItemLog','*','READ','ALLOW','ROLE','employee'),(180,'RouteLog','*','READ','ALLOW','ROLE','employee'),(181,'Dms','removeFile','WRITE','ALLOW','ROLE','employee'),(182,'Dms','uploadFile','WRITE','ALLOW','ROLE','employee'),(183,'Dms','downloadFile','READ','ALLOW','ROLE','employee'),(184,'Client','uploadFile','WRITE','ALLOW','ROLE','employee'),(185,'ClientDms','removeFile','WRITE','ALLOW','ROLE','employee'),(186,'ClientDms','*','READ','ALLOW','ROLE','trainee'),(187,'Ticket','uploadFile','WRITE','ALLOW','ROLE','employee'),(190,'Route','updateVolume','WRITE','ALLOW','ROLE','deliveryBoss'),(191,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(192,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(194,'Postcode','*','WRITE','ALLOW','ROLE','deliveryBoss'),(195,'Ticket','addSale','WRITE','ALLOW','ROLE','employee'),(196,'Dms','updateFile','WRITE','ALLOW','ROLE','employee'),(197,'Dms','*','READ','ALLOW','ROLE','trainee'),(198,'ClaimDms','removeFile','WRITE','ALLOW','ROLE','employee'),(199,'ClaimDms','*','READ','ALLOW','ROLE','employee'),(200,'Claim','uploadFile','WRITE','ALLOW','ROLE','employee'),(201,'Sale','updateConcept','WRITE','ALLOW','ROLE','employee'),(202,'Claim','updateClaimAction','WRITE','ALLOW','ROLE','claimManager'),(203,'UserPhone','*','*','ALLOW','ROLE','employee'),(204,'WorkerDms','removeFile','WRITE','ALLOW','ROLE','hr'),(205,'WorkerDms','*','READ','ALLOW','ROLE','hr'),(206,'Chat','*','*','ALLOW','ROLE','employee'),(207,'Chat','sendMessage','*','ALLOW','ROLE','employee'),(208,'Sale','recalculatePrice','WRITE','ALLOW','ROLE','employee'),(209,'Ticket','recalculateComponents','WRITE','ALLOW','ROLE','employee'),(211,'TravelLog','*','READ','ALLOW','ROLE','buyer'),(212,'Thermograph','*','*','ALLOW','ROLE','buyer'),(213,'TravelThermograph','*','WRITE','ALLOW','ROLE','buyer'),(214,'Entry','*','*','ALLOW','ROLE','buyer'),(215,'TicketWeekly','*','WRITE','ALLOW','ROLE','buyer'),(216,'TravelThermograph','*','READ','ALLOW','ROLE','employee'),(218,'Intrastat','*','*','ALLOW','ROLE','buyer'),(221,'UserConfig','getUserConfig','READ','ALLOW','ROLE','account'),(222,'Client','*','READ','ALLOW','ROLE','trainee'),(226,'ClientObservation','*','READ','ALLOW','ROLE','trainee'),(227,'Address','*','READ','ALLOW','ROLE','trainee'),(228,'AddressObservation','*','READ','ALLOW','ROLE','trainee'),(230,'ClientCredit','*','READ','ALLOW','ROLE','trainee'),(231,'ClientContact','*','READ','ALLOW','ROLE','trainee'),(232,'ClientSample','*','READ','ALLOW','ROLE','trainee'),(233,'EntryLog','*','READ','ALLOW','ROLE','buyer'),(234,'WorkerLog','*','READ','ALLOW','ROLE','salesAssistant'),(235,'CustomsAgent','*','*','ALLOW','ROLE','employee'),(236,'Buy','*','*','ALLOW','ROLE','buyer'),(237,'WorkerDms','filter','*','ALLOW','ROLE','employee'),(238,'Town','*','WRITE','ALLOW','ROLE','deliveryBoss'),(239,'Province','*','WRITE','ALLOW','ROLE','deliveryBoss'),(240,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(241,'SupplierContact','*','WRITE','ALLOW','ROLE','administrative'),(242,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(244,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(248,'RoleMapping','*','READ','ALLOW','ROLE','account'),(249,'UserPassword','*','READ','ALLOW','ROLE','account'),(250,'Town','*','WRITE','ALLOW','ROLE','deliveryBoss'),(251,'Province','*','WRITE','ALLOW','ROLE','deliveryBoss'),(252,'Supplier','*','READ','ALLOW','ROLE','employee'),(253,'Supplier','*','WRITE','ALLOW','ROLE','administrative'),(254,'SupplierLog','*','READ','ALLOW','ROLE','employee'),(256,'Image','*','WRITE','ALLOW','ROLE','employee'),(257,'FixedPrice','*','*','ALLOW','ROLE','buyer'),(258,'PayDem','*','READ','ALLOW','ROLE','employee'),(259,'Client','createReceipt','*','ALLOW','ROLE','salesAssistant'),(260,'PrintServerQueue','*','WRITE','ALLOW','ROLE','employee'),(261,'SupplierAccount','*','*','ALLOW','ROLE','administrative'),(262,'Entry','*','*','ALLOW','ROLE','administrative'),(263,'InvoiceIn','*','*','ALLOW','ROLE','administrative'),(264,'StarredModule','*','*','ALLOW','ROLE','employee'),(265,'ItemBotanical','*','WRITE','ALLOW','ROLE','logisticBoss'),(266,'ZoneLog','*','READ','ALLOW','ROLE','employee'),(267,'Genus','*','WRITE','ALLOW','ROLE','logisticBoss'),(268,'Specie','*','WRITE','ALLOW','ROLE','logisticBoss'),(269,'InvoiceOut','createPdf','WRITE','ALLOW','ROLE','employee'),(270,'SupplierAddress','*','*','ALLOW','ROLE','employee'),(271,'SalesMonitor','*','*','ALLOW','ROLE','employee'),(272,'InvoiceInLog','*','READ','ALLOW','ROLE','employee'),(273,'InvoiceInTax','*','*','ALLOW','ROLE','administrative'),(274,'InvoiceInLog','*','READ','ALLOW','ROLE','administrative'),(275,'InvoiceOut','createManualInvoice','WRITE','ALLOW','ROLE','invoicing'),(276,'InvoiceOut','globalInvoicing','WRITE','ALLOW','ROLE','invoicing'),(277,'Role','*','*','ALLOW','ROLE','it'),(278,'RoleInherit','*','WRITE','ALLOW','ROLE','grant'),(279,'MailAlias','*','*','ALLOW','ROLE','marketing'),(283,'EntryObservation','*','*','ALLOW','ROLE','buyer'),(284,'LdapConfig','*','*','ALLOW','ROLE','sysadmin'),(285,'SambaConfig','*','*','ALLOW','ROLE','sysadmin'),(286,'ACL','*','*','ALLOW','ROLE','developer'),(287,'AccessToken','*','*','ALLOW','ROLE','developer'),(288,'MailAliasAccount','*','*','ALLOW','ROLE','marketing'),(289,'MailAliasAccount','*','*','ALLOW','ROLE','hr'),(290,'MailAlias','*','*','ALLOW','ROLE','hr'),(291,'MailForward','*','*','ALLOW','ROLE','marketing'),(292,'MailForward','*','*','ALLOW','ROLE','hr'),(293,'RoleInherit','*','*','ALLOW','ROLE','it'),(294,'RoleRole','*','*','ALLOW','ROLE','it'),(295,'AccountConfig','*','*','ALLOW','ROLE','sysadmin'),(296,'Collection','*','READ','ALLOW','ROLE','employee'),(297,'Sale','refund','WRITE','ALLOW','ROLE','invoicing'),(298,'InvoiceInDueDay','*','*','ALLOW','ROLE','administrative'),(299,'Collection','setSaleQuantity','*','ALLOW','ROLE','employee'),(300,'Docuware','*','*','ALLOW','ROLE','employee'),(301,'Agency','*','READ','ALLOW','ROLE','employee'),(302,'AgencyTerm','*','*','ALLOW','ROLE','administrative'),(303,'ClaimLog','*','READ','ALLOW','ROLE','claimManager'),(304,'Edi','updateData','WRITE','ALLOW','ROLE','employee'),(305,'EducationLevel','*','*','ALLOW','ROLE','employee'),(306,'InvoiceInIntrastat','*','*','ALLOW','ROLE','employee'),(307,'SupplierAgencyTerm','*','*','ALLOW','ROLE','administrative'),(308,'InvoiceInIntrastat','*','*','ALLOW','ROLE','employee'),(309,'Zone','getZoneClosing','*','ALLOW','ROLE','employee'),(310,'ExpeditionState','*','READ','ALLOW','ROLE','employee'),(311,'Expense','*','READ','ALLOW','ROLE','employee'),(312,'Expense','*','WRITE','ALLOW','ROLE','administrative'),(314,'SupplierActivity','*','READ','ALLOW','ROLE','employee'),(315,'SupplierActivity','*','WRITE','ALLOW','ROLE','administrative'),(316,'Dms','deleteTrashFiles','WRITE','ALLOW','ROLE','employee'),(317,'ClientUnpaid','*','*','ALLOW','ROLE','administrative'),(318,'MdbVersion','*','*','ALLOW','ROLE','developer'),(319,'ItemType','*','READ','ALLOW','ROLE','employee'),(320,'ItemType','*','WRITE','ALLOW','ROLE','buyer'),(321,'InvoiceOut','refund','WRITE','ALLOW','ROLE','invoicing'),(322,'InvoiceOut','refund','WRITE','ALLOW','ROLE','salesAssistant'),(323,'InvoiceOut','refund','WRITE','ALLOW','ROLE','claimManager'),(324,'Ticket','refund','WRITE','ALLOW','ROLE','invoicing'),(325,'Ticket','refund','WRITE','ALLOW','ROLE','salesAssistant'),(326,'Ticket','refund','WRITE','ALLOW','ROLE','claimManager'),(327,'Sale','refund','WRITE','ALLOW','ROLE','salesAssistant'),(328,'Sale','refund','WRITE','ALLOW','ROLE','claimManager'),(329,'TicketRefund','*','WRITE','ALLOW','ROLE','invoicing'),(330,'ClaimObservation','*','WRITE','ALLOW','ROLE','salesPerson'),(331,'ClaimObservation','*','READ','ALLOW','ROLE','salesPerson'),(332,'Client','setPassword','WRITE','ALLOW','ROLE','salesPerson'),(333,'Client','updateUser','WRITE','ALLOW','ROLE','salesPerson'),(334,'ShelvingLog','*','READ','ALLOW','ROLE','employee'),(335,'ZoneExclusionGeo','*','READ','ALLOW','ROLE','employee'),(336,'ZoneExclusionGeo','*','WRITE','ALLOW','ROLE','deliveryBoss'),(337,'Parking','*','*','ALLOW','ROLE','employee'),(338,'Shelving','*','*','ALLOW','ROLE','employee'),(339,'OsTicket','*','*','ALLOW','ROLE','employee'),(340,'OsTicketConfig','*','*','ALLOW','ROLE','it'),(341,'ClientConsumptionQueue','*','WRITE','ALLOW','ROLE','employee'),(342,'Ticket','deliveryNotePdf','READ','ALLOW','ROLE','employee'),(343,'Ticket','deliveryNoteEmail','WRITE','ALLOW','ROLE','employee'),(344,'Ticket','deliveryNoteCsvPdf','READ','ALLOW','ROLE','employee'),(345,'Ticket','deliveryNoteCsvEmail','WRITE','ALLOW','ROLE','employee'),(346,'Client','campaignMetricsPdf','READ','ALLOW','ROLE','employee'),(347,'Client','campaignMetricsEmail','WRITE','ALLOW','ROLE','employee'),(348,'Client','clientWelcomeHtml','READ','ALLOW','ROLE','employee'),(349,'Client','clientWelcomeEmail','WRITE','ALLOW','ROLE','employee'),(350,'Client','creditRequestPdf','READ','ALLOW','ROLE','employee'),(351,'Client','creditRequestHtml','READ','ALLOW','ROLE','employee'),(352,'Client','creditRequestEmail','WRITE','ALLOW','ROLE','employee'),(353,'Client','printerSetupHtml','READ','ALLOW','ROLE','employee'),(354,'Client','printerSetupEmail','WRITE','ALLOW','ROLE','employee'),(355,'Client','sepaCoreEmail','WRITE','ALLOW','ROLE','employee'),(356,'Client','letterDebtorPdf','READ','ALLOW','ROLE','employee'),(357,'Client','letterDebtorStHtml','READ','ALLOW','ROLE','employee'),(358,'Client','letterDebtorStEmail','WRITE','ALLOW','ROLE','employee'),(359,'Client','letterDebtorNdHtml','READ','ALLOW','ROLE','employee'),(360,'Client','letterDebtorNdEmail','WRITE','ALLOW','ROLE','employee'),(361,'Client','clientDebtStatementPdf','READ','ALLOW','ROLE','employee'),(362,'Client','clientDebtStatementHtml','READ','ALLOW','ROLE','employee'),(363,'Client','clientDebtStatementEmail','WRITE','ALLOW','ROLE','employee'),(364,'Client','incotermsAuthorizationPdf','READ','ALLOW','ROLE','employee'),(365,'Client','incotermsAuthorizationHtml','READ','ALLOW','ROLE','employee'),(366,'Client','incotermsAuthorizationEmail','WRITE','ALLOW','ROLE','employee'),(367,'Client','consumptionSendQueued','WRITE','ALLOW','ROLE','system'),(368,'InvoiceOut','invoiceEmail','WRITE','ALLOW','ROLE','employee'),(369,'InvoiceOut','exportationPdf','READ','ALLOW','ROLE','employee'),(370,'InvoiceOut','sendQueued','WRITE','ALLOW','ROLE','system'),(371,'Ticket','invoiceCsvPdf','READ','ALLOW','ROLE','employee'),(372,'Ticket','invoiceCsvEmail','WRITE','ALLOW','ROLE','employee'),(373,'Supplier','campaignMetricsPdf','READ','ALLOW','ROLE','employee'),(374,'Supplier','campaignMetricsEmail','WRITE','ALLOW','ROLE','employee'),(375,'Travel','extraCommunityPdf','READ','ALLOW','ROLE','employee'),(376,'Travel','extraCommunityEmail','WRITE','ALLOW','ROLE','employee'),(377,'Entry','entryOrderPdf','READ','ALLOW','ROLE','employee'),(378,'OsTicket','osTicketReportEmail','WRITE','ALLOW','ROLE','system'),(379,'Item','buyerWasteEmail','WRITE','ALLOW','ROLE','system'),(380,'Claim','claimPickupPdf','READ','ALLOW','ROLE','employee'),(381,'Claim','claimPickupEmail','WRITE','ALLOW','ROLE','claimManager'),(382,'Item','labelPdf','READ','ALLOW','ROLE','employee'),(383,'Sector','*','READ','ALLOW','ROLE','employee'),(384,'Sector','*','WRITE','ALLOW','ROLE','employee'),(385,'Route','driverRoutePdf','READ','ALLOW','ROLE','employee'),(386,'Route','driverRouteEmail','WRITE','ALLOW','ROLE','employee'),(387,'Ticket','deliveryNotePdf','READ','ALLOW','ROLE','customer'),(388,'Supplier','newSupplier','WRITE','ALLOW','ROLE','administrative'),(389,'ClaimRma','*','READ','ALLOW','ROLE','claimManager'),(390,'ClaimRma','*','WRITE','ALLOW','ROLE','claimManager'),(391,'Notification','*','WRITE','ALLOW','ROLE','system'),(392,'Boxing','*','*','ALLOW','ROLE','employee'),(393,'Url','*','READ','ALLOW','ROLE','employee'),(394,'Url','*','WRITE','ALLOW','ROLE','it'),(395,'ItemShelving','*','READ','ALLOW','ROLE','employee'),(396,'ItemShelving','*','WRITE','ALLOW','ROLE','production'),(397,'ItemShelvingPlacementSupplyStock','*','READ','ALLOW','ROLE','employee'),(398,'NotificationQueue','*','*','ALLOW','ROLE','employee'),(399,'InvoiceOut','clientsToInvoice','WRITE','ALLOW','ROLE','invoicing'),(400,'InvoiceOut','invoiceClient','WRITE','ALLOW','ROLE','invoicing'),(401,'Sale','editTracked','WRITE','ALLOW','ROLE','production'),(402,'Sale','editFloramondo','WRITE','ALLOW','ROLE','salesAssistant'),(403,'Receipt','balanceCompensationEmail','WRITE','ALLOW','ROLE','employee'),(404,'Receipt','balanceCompensationPdf','READ','ALLOW','ROLE','employee'),(405,'Ticket','getTicketsFuture','READ','ALLOW','ROLE','employee'),(406,'Ticket','merge','WRITE','ALLOW','ROLE','employee'),(407,'Sale','editFloramondo','WRITE','ALLOW','ROLE','logistic'),(408,'ZipConfig','*','*','ALLOW','ROLE','employee'),(409,'Item','*','WRITE','ALLOW','ROLE','administrative'),(410,'Sale','editCloned','WRITE','ALLOW','ROLE','buyer'),(411,'Sale','editCloned','WRITE','ALLOW','ROLE','salesAssistant'),(414,'MdbVersion','*','READ','ALLOW','ROLE','$everyone'),(416,'TicketLog','getChanges','READ','ALLOW','ROLE','employee'),(417,'Ticket','getTicketsAdvance','READ','ALLOW','ROLE','employee'),(418,'EntryLog','*','READ','ALLOW','ROLE','administrative'),(419,'Sale','editTracked','WRITE','ALLOW','ROLE','buyer'),(420,'MdbBranch','*','READ','ALLOW','ROLE','$everyone'),(421,'ItemShelvingSale','*','*','ALLOW','ROLE','employee'),(422,'Docuware','checkFile','READ','ALLOW','ROLE','employee'),(423,'Docuware','download','READ','ALLOW','ROLE','salesPerson'),(424,'Docuware','upload','WRITE','ALLOW','ROLE','productionAssi'),(425,'Docuware','deliveryNoteEmail','WRITE','ALLOW','ROLE','salesPerson'),(426,'TpvTransaction','confirm','WRITE','ALLOW','ROLE','$everyone'),(427,'TpvTransaction','start','WRITE','ALLOW','ROLE','$authenticated'),(428,'TpvTransaction','end','WRITE','ALLOW','ROLE','$authenticated'),(429,'ItemConfig','*','READ','ALLOW','ROLE','employee'),(431,'Tag','onSubmit','WRITE','ALLOW','ROLE','employee'),(432,'Worker','updateAttributes','WRITE','ALLOW','ROLE','hr'),(433,'Worker','createAbsence','*','ALLOW','ROLE','employee'),(434,'Worker','updateAbsence','WRITE','ALLOW','ROLE','employee'),(435,'Worker','deleteAbsence','*','ALLOW','ROLE','employee'),(436,'Worker','new','WRITE','ALLOW','ROLE','hr'),(437,'Role','*','READ','ALLOW','ROLE','hr'),(438,'Client','getClientOrSupplierReference','READ','ALLOW','ROLE','employee'),(439,'NotificationSubscription','*','*','ALLOW','ROLE','employee'),(440,'NotificationAcl','*','READ','ALLOW','ROLE','employee'),(441,'MdbApp','*','READ','ALLOW','ROLE','$everyone'),(442,'MdbApp','*','*','ALLOW','ROLE','developer'),(443,'ItemConfig','*','*','ALLOW','ROLE','employee'),(444,'DeviceProduction','*','*','ALLOW','ROLE','hr'),(445,'DeviceProductionModels','*','*','ALLOW','ROLE','hr'),(446,'DeviceProductionState','*','*','ALLOW','ROLE','hr'),(447,'DeviceProductionUser','*','*','ALLOW','ROLE','hr'),(448,'DeviceProduction','*','*','ALLOW','ROLE','productionAssi'),(449,'DeviceProductionModels','*','*','ALLOW','ROLE','productionAssi'),(450,'DeviceProductionState','*','*','ALLOW','ROLE','productionAssi'),(451,'DeviceProductionUser','*','*','ALLOW','ROLE','productionAssi'),(452,'Worker','deallocatePDA','*','ALLOW','ROLE','hr'),(453,'Worker','allocatePDA','*','ALLOW','ROLE','hr'),(454,'Worker','deallocatePDA','*','ALLOW','ROLE','productionAssi'),(455,'Worker','allocatePDA','*','ALLOW','ROLE','productionAssi'),(456,'Zone','*','*','ALLOW','ROLE','deliveryBoss'),(457,'Account','setPassword','WRITE','ALLOW','ROLE','itManagement'),(458,'Operator','*','READ','ALLOW','ROLE','employee'),(459,'Operator','*','WRITE','ALLOW','ROLE','employee'),(460,'InvoiceIn','getSerial','READ','ALLOW','ROLE','administrative'),(461,'Ticket','saveSign','WRITE','ALLOW','ROLE','employee'),(462,'InvoiceOut','negativeBases','READ','ALLOW','ROLE','administrative'),(463,'InvoiceOut','negativeBasesCsv','READ','ALLOW','ROLE','administrative'),(464,'WorkerObservation','*','*','ALLOW','ROLE','hr'),(465,'ClientInforma','*','READ','ALLOW','ROLE','employee'),(466,'ClientInforma','*','WRITE','ALLOW','ROLE','financial'),(467,'Receipt','receiptEmail','*','ALLOW','ROLE','salesAssistant'),(468,'Client','setRating','WRITE','ALLOW','ROLE','financial'),(469,'Client','*','READ','ALLOW','ROLE','employee'),(470,'Client','addressesPropagateRe','*','ALLOW','ROLE','employee'),(471,'Client','canBeInvoiced','*','ALLOW','ROLE','employee'),(472,'Client','canCreateTicket','*','ALLOW','ROLE','employee'),(473,'Client','consumption','*','ALLOW','ROLE','employee'),(474,'Client','createAddress','*','ALLOW','ROLE','employee'),(475,'Client','createWithUser','*','ALLOW','ROLE','employee'),(476,'Client','extendedListFilter','*','ALLOW','ROLE','employee'),(477,'Client','getAverageInvoiced','*','ALLOW','ROLE','employee'),(478,'Client','getCard','*','ALLOW','ROLE','employee'),(479,'Client','getDebt','*','ALLOW','ROLE','employee'),(480,'Client','getMana','*','ALLOW','ROLE','employee'),(481,'Client','transactions','*','ALLOW','ROLE','employee'),(482,'Client','hasCustomerRole','*','ALLOW','ROLE','employee'),(483,'Client','isValidClient','*','ALLOW','ROLE','employee'),(484,'Client','lastActiveTickets','*','ALLOW','ROLE','employee'),(485,'Client','sendSms','*','ALLOW','ROLE','employee'),(486,'Client','setPassword','*','ALLOW','ROLE','employee'),(487,'Client','summary','*','ALLOW','ROLE','employee'),(488,'Client','updateAddress','*','ALLOW','ROLE','employee'),(489,'Client','updateFiscalData','*','ALLOW','ROLE','employee'),(490,'Client','updateUser','*','ALLOW','ROLE','employee'),(491,'Client','uploadFile','*','ALLOW','ROLE','employee'),(492,'Client','campaignMetricsPdf','*','ALLOW','ROLE','employee'),(493,'Client','campaignMetricsEmail','*','ALLOW','ROLE','employee'),(494,'Client','clientWelcomeHtml','*','ALLOW','ROLE','employee'),(495,'Client','clientWelcomeEmail','*','ALLOW','ROLE','employee'),(496,'Client','printerSetupHtml','*','ALLOW','ROLE','employee'),(497,'Client','printerSetupEmail','*','ALLOW','ROLE','employee'),(498,'Client','sepaCoreEmail','*','ALLOW','ROLE','employee'),(499,'Client','letterDebtorPdf','*','ALLOW','ROLE','employee'),(500,'Client','letterDebtorStHtml','*','ALLOW','ROLE','employee'),(501,'Client','letterDebtorStEmail','*','ALLOW','ROLE','employee'),(502,'Client','letterDebtorNdHtml','*','ALLOW','ROLE','employee'),(503,'Client','letterDebtorNdEmail','*','ALLOW','ROLE','employee'),(504,'Client','clientDebtStatementPdf','*','ALLOW','ROLE','employee'),(505,'Client','clientDebtStatementHtml','*','ALLOW','ROLE','employee'),(506,'Client','clientDebtStatementEmail','*','ALLOW','ROLE','employee'),(507,'Client','creditRequestPdf','*','ALLOW','ROLE','employee'),(508,'Client','creditRequestHtml','*','ALLOW','ROLE','employee'),(509,'Client','creditRequestEmail','*','ALLOW','ROLE','employee'),(510,'Client','incotermsAuthorizationPdf','*','ALLOW','ROLE','employee'),(511,'Client','incotermsAuthorizationHtml','*','ALLOW','ROLE','employee'),(512,'Client','incotermsAuthorizationEmail','*','ALLOW','ROLE','employee'),(513,'Client','consumptionSendQueued','*','ALLOW','ROLE','employee'),(514,'Client','filter','*','ALLOW','ROLE','employee'),(515,'Client','getClientOrSupplierReference','*','ALLOW','ROLE','employee'),(516,'Client','upsert','*','ALLOW','ROLE','employee'),(517,'Client','create','*','ALLOW','ROLE','employee'),(518,'Client','replaceById','*','ALLOW','ROLE','employee'),(519,'Client','updateAttributes','*','ALLOW','ROLE','employee'),(520,'Client','updateAttributes','*','ALLOW','ROLE','employee'),(521,'Client','deleteById','*','ALLOW','ROLE','employee'),(522,'Client','replaceOrCreate','*','ALLOW','ROLE','employee'),(523,'Client','updateAll','*','ALLOW','ROLE','employee'),(524,'Client','upsertWithWhere','*','ALLOW','ROLE','employee'),(525,'Defaulter','observationEmail','WRITE','ALLOW','ROLE','employee'),(526,'VnUser','*','*','ALLOW','ROLE','employee'),(527,'VnUser','acl','READ','ALLOW','ROLE','account'),(528,'VnUser','getCurrentUserData','READ','ALLOW','ROLE','account'),(529,'VnUser','changePassword','WRITE','ALLOW','ROLE','account'),(530,'Account','exists','READ','ALLOW','ROLE','account'),(531,'Account','exists','READ','ALLOW','ROLE','account'),(532,'UserLog','*','READ','ALLOW','ROLE','employee'),(533,'RoleLog','*','READ','ALLOW','ROLE','employee'); /*!40000 ALTER TABLE `ACL` ENABLE KEYS */; UNLOCK TABLES; @@ -206,11 +206,11 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2023-02-20 14:45:53 +-- Dump completed on 2023-05-16 8:24:00 USE `vn`; --- MariaDB dump 10.19 Distrib 10.5.18-MariaDB, for debian-linux-gnu (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.15-MariaDB, for debian-linux-gnu (x86_64) -- --- Host: db-proxy.verdnatura.es Database: vn +-- Host: db.verdnatura.es Database: vn -- ------------------------------------------------------ -- Server version 10.7.7-MariaDB-1:10.7.7+maria~deb11-log @@ -240,7 +240,7 @@ UNLOCK TABLES; LOCK TABLES `alertLevel` WRITE; /*!40000 ALTER TABLE `alertLevel` DISABLE KEYS */; -INSERT INTO `alertLevel` VALUES ('FREE',0),('ON_PREPARATION',1),('PACKED',2),('DELIVERED',3); +INSERT INTO `alertLevel` VALUES ('FREE',0,1),('ON_PREPARATION',1,1),('PACKED',2,0),('DELIVERED',3,0); /*!40000 ALTER TABLE `alertLevel` ENABLE KEYS */; UNLOCK TABLES; @@ -400,7 +400,7 @@ UNLOCK TABLES; LOCK TABLES `department` WRITE; /*!40000 ALTER TABLE `department` DISABLE KEYS */; -INSERT INTO `department` VALUES (1,NULL,'VERDNATURA',1,98,763,0,0,0,0,29,NULL,'/',NULL,0,NULL,0,0,0,0,NULL),(22,NULL,'COMPRAS',2,3,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(23,'CMA','CAMARA',13,14,NULL,72,1,1,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,1,NULL),(31,'IT','INFORMATICA',4,5,NULL,72,0,0,1,0,1,'/1/','informatica-cau',1,NULL,1,0,0,0,NULL),(34,NULL,'CONTABILIDAD',6,7,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(35,NULL,'FINANZAS',8,9,NULL,0,0,0,1,0,1,'/1/',NULL,1,'begonya@verdnatura.es',1,0,0,0,NULL),(36,NULL,'LABORAL',10,11,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(37,'PROD','PRODUCCION',12,27,NULL,72,1,1,1,7,1,'/1/',NULL,0,NULL,0,1,1,1,NULL),(38,NULL,'SACADO',15,16,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(39,NULL,'ENCAJADO',17,18,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(41,NULL,'ADMINISTRACION',28,29,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(43,'VT','VENTAS',30,51,NULL,0,0,0,1,10,1,'/1/',NULL,1,'',1,0,0,0,NULL),(44,NULL,'GERENCIA',52,53,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(45,NULL,'LOGISTICA',54,55,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(46,NULL,'REPARTO',56,57,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL),(48,NULL,'ALMACENAJE',58,59,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(49,NULL,'PROPIEDAD',60,61,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(52,NULL,'CARGA AEREA',62,63,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(53,NULL,'MARKETING Y COMUNICACIÓN',64,65,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(54,NULL,'ORNAMENTALES',66,67,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(55,NULL,'TALLER NATURAL',68,71,14548,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,1,1,0,1118),(56,NULL,'TALLER ARTIFICIAL',69,70,8470,72,0,0,2,0,55,'/1/55/',NULL,0,NULL,0,1,1,0,1927),(58,'CMP','CAMPOS',72,75,NULL,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(59,NULL,'MANTENIMIENTO',76,77,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(60,NULL,'RECLAMACIONES',78,79,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(61,NULL,'VNH',80,81,NULL,73,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(66,NULL,'VERDNAMADRID',82,83,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(68,NULL,'COMPLEMENTOS',19,20,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,0,0,NULL),(69,NULL,'VERDNABARNA',84,85,NULL,74,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(80,NULL,'EQUIPO J VALLES',31,32,4250,72,0,0,2,0,43,'/1/43/','jvp_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL),(86,NULL,'LIMPIEZA',86,87,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(89,NULL,'COORDINACION',88,89,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(90,NULL,'TRAILER',90,91,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(91,NULL,'ARTIFICIAL',21,22,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(92,NULL,'EQUIPO SILVERIO',33,34,1203,0,0,0,2,0,43,'/1/43/','sdc_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL),(93,NULL,'CONFECCION',92,93,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,1,0,NULL),(94,NULL,'EQUIPO J BROCAL',35,36,3797,0,0,0,2,0,43,'/1/43/','jes_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL),(95,NULL,'EQUIPO C ZAMBRANO',37,38,4667,0,0,0,2,0,43,'/1/43/','czg_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL),(96,NULL,'EQUIPO C LOPEZ',39,40,4661,0,0,0,2,0,43,'/1/43/','cla_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL),(115,NULL,'EQUIPO CLAUDI',41,42,3810,0,0,0,2,0,43,'/1/43/','csr_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL),(123,NULL,'EQUIPO ELENA BASCUÑANA',43,44,7102,0,0,0,2,0,43,'/1/43/','ebt_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL),(124,NULL,'CONTROL INTERNO',94,95,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,1,0,0,0,NULL),(125,NULL,'EQUIPO MIRIAM MAR',45,46,1118,0,0,0,2,0,43,'/1/43/','mir_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL),(126,NULL,'PRESERVADO',96,97,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,1,0,NULL),(128,NULL,'PALETIZADO',23,24,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(130,NULL,'REVISION',25,26,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(131,NULL,'INVERNADERO',73,74,NULL,0,0,0,2,0,58,'/1/58/',NULL,0,NULL,0,0,0,0,NULL),(132,NULL,'EQUIPO DC',47,48,1731,0,0,0,2,0,43,'/1/43/','dc_equipo',1,'gestioncomercial@verdnatura.es',0,0,0,0,NULL),(133,NULL,'EQUIPO FRANCIA',49,50,1731,72,0,0,2,0,43,'/1/43/','fra_equipo',1,'gestioncomercial@verdnatura.es',0,0,0,0,NULL); +INSERT INTO `department` VALUES (1,NULL,'VERDNATURA',1,100,763,0,0,0,0,29,NULL,'/',NULL,0,NULL,0,0,0,0,NULL),(22,NULL,'COMPRAS',2,3,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(23,'CMA','CAMARA',13,14,NULL,72,1,1,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,1,NULL),(31,'IT','INFORMATICA',4,5,NULL,72,0,0,1,0,1,'/1/','informatica-cau',1,NULL,1,0,0,0,NULL),(34,NULL,'CONTABILIDAD',6,7,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(35,NULL,'FINANZAS',8,9,NULL,0,0,0,1,0,1,'/1/',NULL,1,'begonya@verdnatura.es',1,0,0,0,NULL),(36,NULL,'LABORAL',10,11,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(37,'PROD','PRODUCCION',12,27,NULL,72,1,1,1,7,1,'/1/',NULL,0,NULL,0,1,1,1,NULL),(38,NULL,'SACADO',15,16,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(39,NULL,'ENCAJADO',17,18,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(41,NULL,'ADMINISTRACION',28,29,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(43,'VT','VENTAS',30,53,NULL,0,0,0,1,11,1,'/1/',NULL,1,'',1,0,0,0,NULL),(44,'management','GERENCIA',54,55,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(45,NULL,'LOGISTICA',56,57,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(46,NULL,'REPARTO',58,59,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL),(48,NULL,'ALMACENAJE',60,61,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(49,NULL,'PROPIEDAD',62,63,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(52,NULL,'CARGA AEREA',64,65,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(53,NULL,'MARKETING Y COMUNICACIÓN',66,67,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(54,NULL,'ORNAMENTALES',68,69,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(55,NULL,'TALLER NATURAL',70,73,14548,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,1,1,0,1118),(56,NULL,'TALLER ARTIFICIAL',71,72,8470,72,0,0,2,0,55,'/1/55/',NULL,0,NULL,0,1,1,0,1927),(58,'CMP','CAMPOS',74,77,NULL,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(59,NULL,'MANTENIMIENTO',78,79,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL),(60,NULL,'RECLAMACIONES',80,81,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,1,0,0,NULL),(61,NULL,'VNH',82,83,NULL,73,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(66,NULL,'VERDNAMADRID',84,85,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(68,NULL,'COMPLEMENTOS',19,20,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,0,0,NULL),(69,NULL,'VERDNABARNA',86,87,NULL,74,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(80,NULL,'EQUIPO J VALLES',31,32,4250,72,0,0,2,0,43,'/1/43/','jvp_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL),(86,NULL,'LIMPIEZA',88,89,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(89,NULL,'COORDINACION',90,91,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(90,NULL,'TRAILER',92,93,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(91,NULL,'ARTIFICIAL',21,22,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(92,NULL,'EQUIPO SILVERIO',33,34,1203,0,0,0,2,0,43,'/1/43/','sdc_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL),(93,NULL,'CONFECCION',94,95,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,1,0,NULL),(94,NULL,'EQUIPO J BROCAL',35,36,3797,0,0,0,2,0,43,'/1/43/','jes_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL),(95,NULL,'EQUIPO C ZAMBRANO',37,38,4667,0,0,0,2,0,43,'/1/43/','czg_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL),(96,NULL,'EQUIPO C LOPEZ',39,40,4661,0,0,0,2,0,43,'/1/43/','cla_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL),(115,NULL,'EQUIPO CLAUDI',41,42,3810,0,0,0,2,0,43,'/1/43/','csr_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL),(123,NULL,'EQUIPO ELENA BASCUÑANA',43,44,7102,0,0,0,2,0,43,'/1/43/','ebt_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL),(124,NULL,'CONTROL INTERNO',96,97,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,1,0,0,0,NULL),(125,NULL,'EQUIPO MIRIAM MAR',45,46,1118,0,0,0,2,0,43,'/1/43/','mir_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL),(126,NULL,'PRESERVADO',98,99,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,1,0,NULL),(128,NULL,'PALETIZADO',23,24,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(130,NULL,'REVISION',25,26,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(131,NULL,'INVERNADERO',75,76,NULL,0,0,0,2,0,58,'/1/58/',NULL,0,NULL,0,1,0,0,NULL),(132,NULL,'EQUIPO DC',47,48,1731,0,0,0,2,0,43,'/1/43/','dc_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL),(133,'franceTeam','EQUIPO FRANCIA',49,50,1731,72,0,0,2,0,43,'/1/43/','fra_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL),(134,NULL,'EQUIPO RODRI',51,52,6264,0,0,0,2,0,43,'/1/43/','rhr_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL); /*!40000 ALTER TABLE `department` ENABLE KEYS */; UNLOCK TABLES; @@ -450,7 +450,7 @@ UNLOCK TABLES; LOCK TABLES `state` WRITE; /*!40000 ALTER TABLE `state` DISABLE KEYS */; -INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0,0,0,0,0,4,1,'alert'),(2,'Libre',2,0,'FREE',NULL,2,0,0,0,0,0,0,4,1,'notice'),(3,'OK',3,0,'OK',3,28,1,0,0,0,1,1,3,0,'success'),(4,'Impreso',4,0,'PRINTED',2,29,1,0,1,0,0,1,2,0,'success'),(5,'Preparación',6,1,'ON_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning'),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3,0,0,1,0,'warning'),(7,'Sin Acabar',1,0,'NOT_READY',NULL,7,0,0,0,0,0,0,4,1,'alert'),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3,0,0,1,0,'warning'),(9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0,0,0,1,0,NULL),(10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0,0,0,0,0,NULL),(11,'Facturado',0,3,'INVOICED',NULL,11,0,1,0,0,0,0,0,0,NULL),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0,0,0,4,1,'alert'),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0,0,0,0,0,NULL),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2,0,0,1,0,'warning'),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0,0,0,0,NULL),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0,0,0,0,0,NULL),(20,'Asignado',4,0,'PICKER_DESIGNED',NULL,20,1,0,0,0,0,0,2,0,'success'),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0,0,0,2,0,'success'),(22,'Pte. Ampliar',2,0,'EXPANDABLE',NULL,22,0,0,0,0,0,0,4,1,'alert'),(23,'URGENTE',5,1,'LAST_CALL',NULL,23,1,0,1,0,0,0,4,1,'success'),(24,'Encadenado',4,0,'CHAINED',4,24,0,0,0,0,0,0,3,1,'success'),(25,'Embarcando',3,0,'BOARDING',5,25,1,0,0,0,0,0,3,0,'alert'),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,28,1,0,0,1,0,0,2,0,'warning'),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0,0,0,2,0,'success'),(28,'Previa OK',3,0,'OK PREVIOUS',3,28,1,0,1,1,1,1,3,0,'warning'),(29,'Previa Impreso',4,0,'PRINTED PREVIOUS',2,29,1,0,1,0,0,1,2,0,'success'),(30,'Embarcado',4,1,'BOARD',5,30,0,0,0,2,0,0,3,0,'success'),(31,'Polizon Impreso',4,1,'PRINTED STOWAWAY',2,29,1,0,1,0,0,1,2,0,'success'),(32,'Polizon OK',3,1,'OK STOWAWAY',3,31,1,0,0,1,1,1,3,0,'warning'),(33,'Auto_Impreso',4,0,'PRINTED_AUTO',2,29,1,0,1,0,0,1,2,0,'success'),(34,'Pte Pago',3,0,'WAITING_FOR_PAYMENT',NULL,34,0,0,0,0,0,0,4,1,'alert'),(35,'Semi-Encajado',9,2,'HALF_PACKED',NULL,10,0,1,0,0,0,0,1,0,NULL),(36,'Previa Revisando',3,0,'PREVIOUS_CONTROL',2,37,1,0,0,4,0,1,2,0,'warning'),(37,'Previa Revisado',3,0,'PREVIOUS_CONTROLLED',2,29,1,0,1,0,0,1,2,0,'warning'),(38,'Prep Cámara',6,1,'COOLER_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning'); +INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0,0,0,0,0,4,1,'alert'),(2,'Libre',2,0,'FREE',NULL,2,0,0,0,0,0,0,4,1,'notice'),(3,'OK',3,0,'OK',3,28,1,0,0,0,1,1,3,0,'success'),(4,'Impreso',4,0,'PRINTED',2,29,1,0,1,0,0,1,2,0,'success'),(5,'Preparación',6,1,'ON_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning'),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3,0,0,1,0,'warning'),(7,'Sin Acabar',1,0,'NOT_READY',NULL,7,0,0,0,0,0,0,4,1,'alert'),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3,0,0,1,0,'warning'),(9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0,0,0,1,0,NULL),(10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0,0,0,0,0,NULL),(11,'Facturado',0,3,'INVOICED',NULL,11,0,1,0,0,0,0,0,0,NULL),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0,0,0,4,1,'alert'),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0,0,0,0,0,NULL),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2,0,0,1,0,'warning'),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0,0,0,0,NULL),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0,0,0,0,0,NULL),(20,'Asignado',4,0,'PICKER_DESIGNED',NULL,20,1,0,0,0,0,0,2,0,'success'),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0,0,0,2,0,'success'),(22,'Pte. Ampliar',2,0,'EXPANDABLE',NULL,22,0,0,0,0,0,0,4,1,'alert'),(23,'URGENTE',5,1,'LAST_CALL',NULL,23,1,0,1,0,0,0,4,1,'success'),(24,'Encadenado',4,0,'CHAINED',4,24,0,0,0,0,0,0,3,1,'success'),(25,'Embarcando',3,0,'BOARDING',5,25,1,0,0,0,0,0,3,0,'alert'),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,28,1,0,0,1,0,0,2,0,'warning'),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0,0,0,2,0,'success'),(28,'Previa OK',3,0,'OK PREVIOUS',3,28,1,0,1,1,1,1,3,0,'warning'),(29,'Previa Impreso',4,0,'PRINTED PREVIOUS',2,29,1,0,1,0,0,1,2,0,'success'),(30,'Embarcado',4,1,'BOARD',5,30,0,0,0,2,0,0,3,0,'success'),(31,'Polizon Impreso',4,1,'PRINTED STOWAWAY',2,29,1,0,1,0,0,1,2,0,'success'),(32,'Polizon OK',3,1,'OK STOWAWAY',3,31,1,0,0,1,1,1,3,0,'warning'),(33,'Auto_Impreso',4,0,'PRINTED_AUTO',2,29,1,0,1,0,0,1,2,0,'success'),(34,'Pte Pago',3,0,'WAITING_FOR_PAYMENT',NULL,34,0,0,0,0,0,0,4,1,'alert'),(35,'Semi-Encajado',9,2,'HALF_PACKED',NULL,10,0,1,0,0,0,0,1,0,NULL),(36,'Previa Revisando',3,0,'PREVIOUS_CONTROL',2,37,1,0,0,4,0,1,2,0,'warning'),(37,'Previa Revisado',3,0,'PREVIOUS_CONTROLLED',2,29,1,0,1,0,0,1,2,0,'warning'),(38,'Prep Cámara',6,1,'COOLER_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning'),(41,'Prep Parcial',6,1,'PARTIAL_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning'); /*!40000 ALTER TABLE `state` ENABLE KEYS */; UNLOCK TABLES; @@ -493,6 +493,16 @@ LOCK TABLES `workCenter` WRITE; INSERT INTO `workCenter` VALUES (1,'Silla',20,859,1,'Av espioca 100',552703,NULL),(2,'Mercaflor',19,NULL,NULL,NULL,NULL,NULL),(3,'Marjales',26,20008,NULL,NULL,NULL,NULL),(4,'VNH',NULL,NULL,NULL,NULL,NULL,NULL),(5,'Madrid',28,2869,5,'Av constitución 3',554145,0.50),(6,'Vilassar',88,88038,NULL,'Cami del Crist, 33',556412,NULL),(7,'Tenerife',NULL,NULL,NULL,NULL,NULL,NULL),(8,'Silla-Agrario',26,NULL,NULL,NULL,NULL,NULL),(9,'Algemesi',20,1354,60,'Fenollars, 2',523549,NULL); /*!40000 ALTER TABLE `workCenter` ENABLE KEYS */; UNLOCK TABLES; + +-- +-- Dumping data for table `companyI18n` +-- + +LOCK TABLES `companyI18n` WRITE; +/*!40000 ALTER TABLE `companyI18n` DISABLE KEYS */; +INSERT INTO `companyI18n` VALUES (442,'en','In compliance with the provisions of Organic Law 15/1999, on the Protection of Personal Data, we inform you that the personal data you provide will be included in automated files of VERDNATURA LEVANTE SL, being able at all times to exercise the rights of access, rectification, cancellation and opposition, communicating it in writing to the registered office of the entity. The purpose of the file is administrative management, accounting, and billing.'),(442,'fr','Conformément aux dispositions de la loi organique 15/1999 sur la protection des données personnelles, nous vous informons que les données personnelles que vous fournissez seront incluses dans des dossiers. VERDNATURA LEVANTE S.L., vous pouvez à tout moment, exercer les droits d``accès, de rectification, d``annulation et d``opposition, en communiquant par écrit au siège social de la société. Le dossier a pour objet la gestion administrative, la comptabilité et la facturation.'),(442,'pt','Em cumprimento do disposto na lei Orgânica 15/1999, de Protecção de Dados de Carácter Pessoal, comunicamos que os dados pessoais que facilite se incluirão nos ficheiros automatizados de VERDNATURA LEVANTE S.L., podendo em todo momento exercer os direitos de acesso, rectificação, cancelação e oposição, comunicando por escrito ao domicílio social da entidade. A finalidade do ficheiro é a gestão administrativa, contabilidade e facturação.'); +/*!40000 ALTER TABLE `companyI18n` ENABLE KEYS */; +UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; @@ -502,11 +512,11 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2023-02-20 14:45:54 +-- Dump completed on 2023-05-16 8:24:00 USE `cache`; --- MariaDB dump 10.19 Distrib 10.5.18-MariaDB, for debian-linux-gnu (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.15-MariaDB, for debian-linux-gnu (x86_64) -- --- Host: db-proxy.verdnatura.es Database: cache +-- Host: db.verdnatura.es Database: cache -- ------------------------------------------------------ -- Server version 10.7.7-MariaDB-1:10.7.7+maria~deb11-log @@ -538,11 +548,11 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2023-02-20 14:45:55 +-- Dump completed on 2023-05-16 8:24:00 USE `hedera`; --- MariaDB dump 10.19 Distrib 10.5.18-MariaDB, for debian-linux-gnu (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.15-MariaDB, for debian-linux-gnu (x86_64) -- --- Host: db-proxy.verdnatura.es Database: hedera +-- Host: db.verdnatura.es Database: hedera -- ------------------------------------------------------ -- Server version 10.7.7-MariaDB-1:10.7.7+maria~deb11-log @@ -572,7 +582,7 @@ UNLOCK TABLES; LOCK TABLES `imageCollection` WRITE; /*!40000 ALTER TABLE `imageCollection` DISABLE KEYS */; -INSERT INTO `imageCollection` VALUES (1,'catalog','Artículo',3840,2160,'Item','image','vn','item','image',1,75),(4,'link','Enlace',200,200,'Link','image','hedera','link','image',1,9),(5,'news','Noticias',800,1200,'New','image','hedera','news','image',1,9),(6,'user','Usuario',800,1200,'Account','image','account','user','image',1,74); +INSERT INTO `imageCollection` VALUES (1,'catalog','Artículo',3840,2160,'Item','image','vn','item','image',1,75),(4,'link','Enlace',200,200,'Link','image','hedera','link','image',1,9),(5,'news','Noticias',800,1200,'New','image','hedera','news','image',1,9),(6,'user','Usuario',800,1200,'VnUser','image','account','user','image',1,74); /*!40000 ALTER TABLE `imageCollection` ENABLE KEYS */; UNLOCK TABLES; @@ -622,7 +632,7 @@ UNLOCK TABLES; LOCK TABLES `menu` WRITE; /*!40000 ALTER TABLE `menu` DISABLE KEYS */; -INSERT INTO `menu` VALUES (1,'Home','cms/home',6,NULL,1),(2,'Orders',NULL,11,NULL,1),(3,'Catalog','ecomerce/catalog',6,NULL,2),(7,'Administration',NULL,1,NULL,2),(8,'Users','admin/users',1,7,2),(9,'Connections','admin/connections',1,7,2),(11,'Agencies','agencies/packages',3,NULL,2),(12,'News','news/news',1,7,3),(15,'Photos','admin/photos',1,7,3),(17,'Configuration',NULL,11,NULL,3),(19,'Control panel','admin/links',1,7,1),(21,'Basket','ecomerce/basket',11,NULL,1),(22,'Last orders','ecomerce/orders',11,2,2),(23,'Invoices','ecomerce/invoices',11,2,2),(24,'Account','account/conf',11,17,1),(25,'Addresses','account/address-list',11,17,2),(26,'Shelves','reports/shelves',1,29,1),(28,'Visits','admin/visits',1,7,2),(29,'Reports',NULL,1,NULL,2),(30,'Items','admin/items',1,7,3); +INSERT INTO `menu` VALUES (1,'Home','cms/home',6,NULL,1),(2,'Orders',NULL,11,NULL,1),(3,'Catalog','ecomerce/catalog',6,NULL,2),(7,'Administration',NULL,1,NULL,2),(8,'Users','admin/users',1,7,2),(9,'Connections','admin/connections',1,7,2),(11,'Agencies','agencies/packages',3,NULL,2),(12,'News','news/news',1,7,3),(15,'Photos','admin/photos',1,7,3),(17,'Configuration',NULL,11,NULL,3),(19,'Control panel','admin/links',1,7,1),(21,'Basket','ecomerce/basket',11,NULL,1),(22,'Last orders','ecomerce/orders',11,2,2),(23,'Invoices','ecomerce/invoices',11,2,2),(24,'Account','account/conf',11,17,1),(25,'Addresses','account/address-list',11,17,2),(26,'Shelves','reports/shelves',1,29,1),(28,'Visits','admin/visits',1,7,2),(29,'Reports',NULL,1,NULL,2),(30,'Items','admin/items',1,7,3),(31,'Pending orders','ecomerce/pending',11,2,1); /*!40000 ALTER TABLE `menu` ENABLE KEYS */; UNLOCK TABLES; @@ -632,7 +642,7 @@ UNLOCK TABLES; LOCK TABLES `message` WRITE; /*!40000 ALTER TABLE `message` DISABLE KEYS */; -INSERT INTO `message` VALUES (1,'ORDER_DATE_HOLIDAY','No es posible realizar pedidos para días festivos'),(2,'ORDER_EMPTY','El pedido esta vacío'),(3,'ORDER_UNAVAILABLE','Algunos artículos ya no están disponibles, verifica las cantidades resaltadas en rojo'),(4,'SURVEY_MAX_ONE_VOTE','Solo es posible realizar un voto por encuesta'),(5,'ORDER_MAX_EXCEEDED','Has excedido el número máximo de pedidos por confirmar, por favor elimina o confirma los pedidos iniciados'),(6,'LOGIN_INCORRECT','Usuario o contraseña incorrectos. Recuerda que se hace distinción entre mayúsculas y minúsculas.'),(7,'ORDER_DATE_PAST','La fecha de su pedido debe ser mayor o igual al día de hoy'),(8,'ORDER_DATE_LAST','No es posible realizar más para hoy, por favor atrasa la fecha de tu pedido a mañana o días posteriores'),(9,'ORDER_DATE_SUNDAY','No es posible confirmar pedidos para Domingo'),(10,'ORDER_DATE_SATURATED','Estamos saturados de pedidos, por favor selecciona otra fecha de envío o recogida '),(11,'USER_DISCONNECTED','Has sido desconectado del servidor, por favor vuelve a iniciar sesión'),(12,'UNAUTH_ACTION','Acción no permitida'),(13,'ORDER_INVALID_AGENCY','La agencia de envío no es válida'),(14,'ORDER_EMPTY_ADDRESS','Selecciona una dirección de envío'),(15,'ORDER_AMOUNT_ROUNDED','Este artículo se vende agrupado y la cantidad ha sido redondeada'),(16,'ORDER_ALREADY_CONFIRMED','Este pedido ya estaba confirmado'); +INSERT INTO `message` VALUES (1,'ORDER_DATE_HOLIDAY','No es posible realizar pedidos para días festivos'),(2,'ORDER_EMPTY','El pedido esta vacío'),(3,'ORDER_UNAVAILABLE','Algunos artículos ya no están disponibles, verifica las cantidades resaltadas en rojo'),(4,'SURVEY_MAX_ONE_VOTE','Solo es posible realizar un voto por encuesta'),(5,'ORDER_MAX_EXCEEDED','Has excedido el número máximo de pedidos por confirmar, por favor elimina o confirma los pedidos iniciados'),(6,'LOGIN_INCORRECT','Usuario o contraseña incorrectos. Recuerda que se hace distinción entre mayúsculas y minúsculas.'),(7,'ORDER_DATE_PAST','La fecha de su pedido debe ser mayor o igual al día de hoy'),(8,'ORDER_DATE_LAST','No es posible realizar más para hoy, por favor atrasa la fecha de tu pedido a mañana o días posteriores'),(9,'ORDER_DATE_SUNDAY','No es posible confirmar pedidos para Domingo'),(10,'ORDER_DATE_SATURATED','Estamos saturados de pedidos, por favor selecciona otra fecha de envío o recogida '),(11,'USER_DISCONNECTED','Has sido desconectado del servidor, por favor vuelve a iniciar sesión'),(12,'UNAUTH_ACTION','Acción no permitida'),(13,'ORDER_INVALID_AGENCY','La agencia de envío no es válida'),(14,'ORDER_EMPTY_ADDRESS','Selecciona una dirección de envío'),(15,'ORDER_AMOUNT_ROUNDED','Este artículo se vende agrupado y la cantidad ha sido redondeada'),(17,'orderOutdated','La configuración del pedido es incorrecta, por favor vuelve a configurarlo para continuar comprando'),(18,'orderNotOwnedByUser','El pedido pertenece a otro usuario'),(19,'orderConfirmed','El pedido ya ha sido confirmado y no puede modificarse'); /*!40000 ALTER TABLE `message` ENABLE KEYS */; UNLOCK TABLES; @@ -704,11 +714,11 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2023-02-20 14:45:56 +-- Dump completed on 2023-05-16 8:24:00 USE `postgresql`; --- MariaDB dump 10.19 Distrib 10.5.18-MariaDB, for debian-linux-gnu (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.15-MariaDB, for debian-linux-gnu (x86_64) -- --- Host: db-proxy.verdnatura.es Database: postgresql +-- Host: db.verdnatura.es Database: postgresql -- ------------------------------------------------------ -- Server version 10.7.7-MariaDB-1:10.7.7+maria~deb11-log @@ -722,16 +732,6 @@ USE `postgresql`; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; --- --- Dumping data for table `calendar_labour_type` --- - -LOCK TABLES `calendar_labour_type` WRITE; -/*!40000 ALTER TABLE `calendar_labour_type` DISABLE KEYS */; -INSERT INTO `calendar_labour_type` VALUES (1,'Horario general','00:20:00',40,0),(2,'Horario 35h/semana','00:20:00',35,1),(3,'Horario 20h/semana','00:00:00',20,1),(4,'Festivo y Fin de semana','00:00:00',0,1),(5,'Horario 30h/semana','00:20:00',30,1),(6,'Horario 25h/semana','00:20:00',25,1),(7,'Vacaciones trabajadas','00:00:00',0,1),(8,'Vacaciones','00:00:00',0,1),(9,'Horario 26h/semana','00:20:00',26,1),(10,'Horario 28h/semana','00:20:00',28,1),(11,'Horario 8h/semana','00:00:00',8,1),(12,'Horario 16h/semana','00:00:00',16,1),(13,'Horario 32h/semana','00:20:00',32,1),(14,'Horario 24h/semana','00:20:00',24,1),(15,'Horario 10h/semana','00:00:00',10,1),(16,'Horario 27,5h/semana','00:20:00',28,1),(17,'Horario 13,5h/semana','00:20:00',14,1),(18,'Horario 31h/semana',NULL,31,1),(19,'Horario 21,5h/semana',NULL,22,1),(20,'Horario 34h/semana',NULL,34,1),(21,'Horario 17h/semana',NULL,17,1),(22,'Horario 18h/semana',NULL,18,1),(23,'Horario 37,5 h/semana',NULL,38,1),(24,'Horario 29 h/semana',NULL,29,1),(25,'Horario 12h/semana',NULL,12,1),(26,'Horario 10h/semana',NULL,10,1),(27,'Horario 15h/semana',NULL,15,1),(28,'Horario 9h/semana',NULL,9,1),(29,'Horario 23h/semana',NULL,23,1),(30,'Horario 21h/semana',NULL,21,1),(31,'Horario 39h/semana',NULL,39,1),(32,'Horario 22/semana',NULL,22,1); -/*!40000 ALTER TABLE `calendar_labour_type` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Dumping data for table `labour_agreement` -- @@ -751,26 +751,6 @@ LOCK TABLES `media_type` WRITE; INSERT INTO `media_type` VALUES (3,'email'),(12,'extension movil'),(6,'facebook'),(2,'fijo'),(11,'material'),(10,'movil empresa'),(1,'movil personal'),(5,'msn'),(9,'seg social'),(4,'skype'),(7,'web'); /*!40000 ALTER TABLE `media_type` ENABLE KEYS */; UNLOCK TABLES; - --- --- Dumping data for table `professional_category` --- - -LOCK TABLES `professional_category` WRITE; -/*!40000 ALTER TABLE `professional_category` DISABLE KEYS */; -INSERT INTO `professional_category` VALUES (1,'Mozos',5,1,27.5,NULL),(2,'Encargados',3,1,27.5,NULL),(4,'Comprador',3,1,27.5,NULL),(5,'Aux Administracion',NULL,1,27.5,NULL),(6,'Of Administracion',3,1,27.5,NULL),(7,'Jefe Administracion',2,1,27.5,NULL),(8,'Informatico',3,1,27.5,NULL),(9,'Directivo',1,0,27.5,NULL),(10,'Aux Ventas',4,1,27.5,NULL),(11,'Vendedor',4,1,27.5,NULL),(12,'Jefe de Ventas',4,0,27.5,NULL),(13,'Repartidor',5,1,27.5,NULL),(14,'Aprendices',NULL,1,27.5,NULL),(15,'Técnicos',2,1,27.5,NULL),(16,'Aux Florista',5,1,27.5,NULL),(17,'Florista',4,1,27.5,NULL),(18,'Jefe Floristas',2,1,27.5,NULL),(19,'Técnico marketing',3,1,27.5,NULL),(20,'Auxiliar marketing',4,1,27.5,NULL),(21,'Aux Informática',4,1,27.5,NULL),(22,'Peón agrícola',5,1,27.5,NULL),(23,'Oficial mantenimiento',4,1,27.5,NULL),(24,'Aux mantenimiento',5,1,27.5,NULL),(25,'Mozo Aeropuerto',5,1,27.5,NULL),(26,'Coordinador',2,1,27.5,NULL),(28,'Aux Logistica',4,1,27.5,NULL),(29,'Oficial Logistica',3,1,27.5,NULL),(30,'Subencargado',4,1,27.5,NULL),(31,'Conductor +3500kg',NULL,1,27.5,32400),(32,'Oficial 1ª',NULL,1,27.5,NULL),(33,'Oficial 2ª',NULL,1,27.5,NULL),(34,'Supervisor',NULL,1,27.5,NULL),(35,'Aux.Comerc./Market.',NULL,1,27.5,NULL),(36,'Oficial Comerc./Market.',NULL,1,27.5,NULL),(37,'Coord. Comerc./Market.',NULL,1,27.5,NULL),(38,'Aux. Florista 1ª',NULL,1,27.5,NULL),(39,'Mozo/campo',NULL,1,27.5,NULL),(40,'Conductor B',NULL,1,27.5,NULL),(41,'Conductor C',NULL,1,27.5,NULL),(42,'Conductor C + E',NULL,1,27.5,NULL),(43,'Enrutador I',NULL,1,27.5,NULL),(44,'Enrutador II',NULL,1,27.5,NULL),(45,'Jefe Logística',NULL,1,27.5,NULL); -/*!40000 ALTER TABLE `professional_category` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Dumping data for table `profile_type` --- - -LOCK TABLES `profile_type` WRITE; -/*!40000 ALTER TABLE `profile_type` DISABLE KEYS */; -INSERT INTO `profile_type` VALUES (1,'Laboral'),(2,'Personal'),(3,'Cliente'),(4,'Proveedor'),(5,'Banco'),(6,'Patronal'); -/*!40000 ALTER TABLE `profile_type` ENABLE KEYS */; -UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; @@ -780,11 +760,11 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2023-02-20 14:45:56 +-- Dump completed on 2023-05-16 8:24:00 USE `sage`; --- MariaDB dump 10.19 Distrib 10.5.18-MariaDB, for debian-linux-gnu (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.15-MariaDB, for debian-linux-gnu (x86_64) -- --- Host: db-proxy.verdnatura.es Database: sage +-- Host: db.verdnatura.es Database: sage -- ------------------------------------------------------ -- Server version 10.7.7-MariaDB-1:10.7.7+maria~deb11-log @@ -836,4 +816,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2023-02-20 14:45:57 +-- Dump completed on 2023-05-16 8:24:00 diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 0a0f2232e..e19a0d56d 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -351,20 +351,20 @@ INSERT INTO `vn`.`contactChannel`(`id`, `name`) (4, 'GCN Channel'), (5, 'The Newspaper'); -INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`,`clientTypeFk`,`mailAddress`,`hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`, `businessTypeFk`) +INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`,`clientTypeFk`, `hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`, `businessTypeFk`) VALUES - (1101, 'Bruce Wayne', '84612325V', 'Batman', 'Alfred', '1007 Mountain Drive, Gotham', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), - (1102, 'Petter Parker', '87945234L', 'Spider man', 'Aunt May', '20 Ingram Street, Queens, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), - (1103, 'Clark Kent', '06815934E', 'Super man', 'lois lane', '344 Clinton Street, Apartament 3-D', 'Gotham', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), - (1104, 'Tony Stark', '06089160W', 'Iron man', 'Pepper Potts', '10880 Malibu Point, 90265', 'Gotham', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), - (1105, 'Max Eisenhardt', '251628698', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Gotham', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1, 'florist'), - (1106, 'DavidCharlesHaller', '53136686Q', 'Legion', 'Charles Xavier', 'City of New York, New York, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 19, 0, 1, 'florist'), - (1107, 'Hank Pym', '09854837G', 'Ant man', 'Hawk', 'Anthill, San Francisco, California', 'Gotham', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, 0, NULL, 0, 0, 19, 0, 1, 'florist'), - (1108, 'Charles Xavier', '22641921P', 'Professor X', 'Beast', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1, 'florist'), - (1109, 'Bruce Banner', '16104829E', 'Hulk', 'Black widow', 'Somewhere in New York', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, 0, NULL, 0, 0, 9, 0, 1, 'florist'), - (1110, 'Jessica Jones', '58282869H', 'Jessica Jones', 'Luke Cage', 'NYCC 2015 Poster', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, 0, NULL, 0, 0, NULL, 0, 1, 'florist'), - (1111, 'Missing', NULL, 'Missing man', 'Anton', 'The space, Universe far away', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 1, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others'), - (1112, 'Trash', NULL, 'Garbage man', 'Unknown name', 'New York city, Underground', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 1, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others'); + (1101, 'Bruce Wayne', '84612325V', 'Batman', 'Alfred', '1007 Mountain Drive, Gotham', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), + (1102, 'Petter Parker', '87945234L', 'Spider man', 'Aunt May', '20 Ingram Street, Queens, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), + (1103, 'Clark Kent', '06815934E', 'Super man', 'lois lane', '344 Clinton Street, Apartament 3-D', 'Gotham', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), + (1104, 'Tony Stark', '06089160W', 'Iron man', 'Pepper Potts', '10880 Malibu Point, 90265', 'Gotham', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), + (1105, 'Max Eisenhardt', '251628698', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Gotham', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1, 'florist'), + (1106, 'DavidCharlesHaller', '53136686Q', 'Legion', 'Charles Xavier', 'City of New York, New York, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 19, 0, 1, 'florist'), + (1107, 'Hank Pym', '09854837G', 'Ant man', 'Hawk', 'Anthill, San Francisco, California', 'Gotham', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, 19, 0, 1, 'florist'), + (1108, 'Charles Xavier', '22641921P', 'Professor X', 'Beast', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1, 'florist'), + (1109, 'Bruce Banner', '16104829E', 'Hulk', 'Black widow', 'Somewhere in New York', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, 9, 0, 1, 'florist'), + (1110, 'Jessica Jones', '58282869H', 'Jessica Jones', 'Luke Cage', 'NYCC 2015 Poster', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, NULL, 0, 1, 'florist'), + (1111, 'Missing', NULL, 'Missing man', 'Anton', 'The space, Universe far away', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others'), + (1112, 'Trash', NULL, 'Garbage man', 'Unknown name', 'New York city, Underground', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others'); INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `gestdocFk`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`) SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), CONCAT(name, 'Social'), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, util.VN_CURDATE(), 1 @@ -709,7 +709,7 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF (15, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1105, 'An incredibly long alias for testing purposes', 125, NULL, 0, 3, 5, 1, util.VN_CURDATE()), (16, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE()), (17, 1, 7, 2, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE()), - (18, 1, 4, 4, 4, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1108, 'Cerebro', 128, NULL, 0, 12, 5, 1, util.VN_CURDATE()), + (18, 1, 4, 4, 4, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1108, 'Cerebro', 128, NULL, 0, 12, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +12 HOUR)), (19, 1, 5, 5, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 1, NULL, 5, 1, util.VN_CURDATE()), (20, 1, 5, 5, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)), (21, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Holland', 102, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)), @@ -1942,6 +1942,16 @@ INSERT INTO `pbx`.`sip`(`user_id`, `extension`) (5, 1102), (9, 1201); +INSERT INTO `vn`.`professionalCategory` (`id`, `name`, `level`, `dayBreak`) + VALUES + (1, 'employee', NULL, NULL), + (2, 'florist', NULL, NULL); + +INSERT INTO `vn`.`calendarType` (`id`, `description`, `hoursWeek`, `isPartial`) + VALUES + (1, 'General schedule', 40, 0); + + DROP TEMPORARY TABLE IF EXISTS tmp.worker; CREATE TEMPORARY TABLE tmp.worker (PRIMARY KEY (id)) @@ -1970,7 +1980,7 @@ UPDATE `vn`.`business` WHERE `id`= 1106; UPDATE `vn`.`business` b - SET b.`workerBusinessProfessionalCategoryFk` = 31 + SET b.`workerBusinessProfessionalCategoryFk` = 2 WHERE b.`workerFk` = 1110; UPDATE `vn`.`business` b @@ -2324,26 +2334,26 @@ INSERT INTO `vn`.`workerTimeControl`(`userFk`, `timed`, `manual`, `direction`, ` INSERT INTO `vn`.`dmsType`(`id`, `name`, `path`, `readRoleFk`, `writeRoleFk`, `code`) VALUES - (1, 'Facturas Recibidas', 'recibidas', NULL, NULL, 'invoiceIn'), - (2, 'Doc oficial', 'oficial', NULL, NULL, 'officialDoc'), - (3, 'Laboral', 'laboral', 37, 37, 'hhrrData'), - (4, 'Albaranes recibidos', 'entradas', NULL, NULL, 'deliveryNote'), - (5, 'Otros', 'otros', 1, 1, 'miscellaneous'), - (6, 'Pruebas', 'pruebas', NULL, NULL, 'tests'), - (7, 'IAE Clientes', 'IAE_Clientes', 1, 1, 'economicActivitiesTax'), - (8, 'Fiscal', 'fiscal', NULL, NULL, 'fiscal'), - (9, 'Vehiculos', 'vehiculos', NULL, NULL, 'vehicles'), - (10, 'Plantillas', 'plantillas', NULL, NULL, 'templates'), - (11, 'Contratos', 'contratos', NULL, NULL, 'contracts'), - (12, 'ley de pagos', 'ley pagos', 1, 1, 'paymentsLaw'), - (13, 'Basura', 'basura', 1, 1, 'trash'), - (14, 'Ticket', 'tickets', 1, 1, 'ticket'), - (15, 'Presupuestos', 'Presupuestos', NULL, NULL, 'budgets'), - (16, 'Logistica', 'logistica', NULL, NULL, 'logistics'), - (17, 'cmr', 'cmr', NULL, NULL, 'cmr'), - (18, 'dua', 'dua', NULL, NULL, 'dua'), - (19, 'inmovilizado', 'inmovilizado', NULL, NULL, 'fixedAssets'), - (20, 'Reclamación', 'reclamacion', 1, 1, 'claim'); + (1, 'Facturas Recibidas', 'recibidas', NULL, NULL, 'invoiceIn'), + (2, 'Doc oficial', 'oficial', NULL, NULL, 'officialDoc'), + (3, 'Laboral', 'laboral', 37, 37, 'hhrrData'), + (4, 'Albaranes recibidos', 'entradas', NULL, NULL, 'deliveryNote'), + (5, 'Otros', 'otros', 1, 1, 'miscellaneous'), + (6, 'Pruebas', 'pruebas', NULL, NULL, 'tests'), + (7, 'IAE Clientes', 'IAE_Clientes', 1, 1, 'economicActivitiesTax'), + (8, 'Fiscal', 'fiscal', NULL, NULL, 'fiscal'), + (9, 'Vehiculos', 'vehiculos', NULL, NULL, 'vehicles'), + (10, 'Plantillas', 'plantillas', NULL, NULL, 'templates'), + (11, 'Contratos', 'contratos', NULL, NULL, 'contracts'), + (12, 'ley de pagos', 'ley pagos', 1, 1, 'paymentsLaw'), + (13, 'Basura', 'basura', 1, 1, 'trash'), + (14, 'Ticket', 'tickets', 1, 1, 'ticket'), + (15, 'Presupuestos', 'Presupuestos', NULL, NULL, 'budgets'), + (16, 'Logistica', 'logistica', NULL, NULL, 'logistics'), + (17, 'cmr', 'cmr', NULL, NULL, 'cmr'), + (18, 'dua', 'dua', NULL, NULL, 'dua'), + (19, 'inmovilizado', 'inmovilizado', NULL, NULL, 'fixedAssets'), + (20, 'Reclamación', 'reclamacion', 1, 1, 'claim'); INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `contentType`, `workerFk`, `warehouseFk`, `companyFk`, `hardCopyNumber`, `hasFile`, `reference`, `description`, `created`) VALUES @@ -2773,10 +2783,23 @@ UPDATE `account`.`user` INSERT INTO `vn`.`ticketLog` (`originFk`, userFk, `action`, changedModel, oldInstance, newInstance, changedModelId, `description`) VALUES - (7, 18, 'update', 'Sale', '{"quantity":1}', '{"quantity":10}', 1, NULL), - (7, 18, 'update', 'Ticket', '{"quantity":1,"concept":"Chest ammo box"}', '{"quantity":10,"concept":"Chest ammo box"}', 1, NULL), - (7, 18, 'update', 'Sale', '{"price":3}', '{"price":5}', 1, NULL), - (7, 18, 'update', NULL, NULL, NULL, NULL, "Cambio cantidad Melee weapon heavy shield 1x0.5m de '5' a '10'"); + (7, 18, 'update', 'Sale', '{"quantity":1}', '{"quantity":10}', 1, NULL), + (7, 18, 'update', 'Ticket', '{"quantity":1,"concept":"Chest ammo box"}', '{"quantity":10,"concept":"Chest ammo box"}', 1, NULL), + (7, 18, 'update', 'Sale', '{"price":3}', '{"price":5}', 1, NULL), + (7, 18, 'update', NULL, NULL, NULL, NULL, "Cambio cantidad Melee weapon heavy shield 1x0.5m de '5' a '10'"); + +INSERT INTO `vn`.`ticketLog` (originFk, userFk, `action`, creationDate, changedModel, changedModelId, changedModelValue, oldInstance, newInstance, description) + VALUES + (1, NULL, 'delete', '2001-06-09 11:00:04', 'Ticket', 45, 'Spider Man' , NULL, NULL, NULL), + (1, 18, 'select', '2001-06-09 11:00:03', 'Ticket', 45, 'Spider Man' , NULL, NULL, NULL), + (1, NULL, 'update', '2001-05-09 10:00:02', 'Sale', 69854, 'Armor' , '{"isPicked": false}','{"isPicked": true}', NULL), + (1, 18, 'update', '2001-01-01 10:05:01', 'Sale', 69854, 'Armor' , NULL, NULL, 'Armor quantity changed from ''15'' to ''10'''), + (1, NULL, 'delete', '2001-01-01 10:00:10', 'Sale', 5689, 'Shield' , '{"quantity":10,"concept":"Shield"}', NULL, NULL), + (1, 18, 'insert', '2000-12-31 15:00:05', 'Sale', 69854, 'Armor' , NULL,'{"quantity":15,"concept":"Armor", "price": 345.99, "itemFk": 2}', NULL), + (1, 18, 'update', '2000-12-28 08:40:45', 'Ticket', 45, 'Spider Man' , '{"warehouseFk":60,"shipped":"2023-05-16T22:00:00.000Z","nickname":"Super Man","isSigned":true,"isLabeled":true,"isPrinted":true,"packages":0,"hour":0,"isBlocked":false,"hasPriority":false,"companyFk":442,"landed":"2023-05-17T22:00:00.000Z","isBoxed":true,"isDeleted":true,"zoneFk":713,"zonePrice":13,"zoneBonus":0}','{"warehouseFk":61,"shipped":"2023-05-17T22:00:00.000Z","nickname":"Spider Man","isSigned":false,"isLabeled":false,"isPrinted":false,"packages":1,"hour":0,"isBlocked":true,"hasPriority":true,"companyFk":443,"landed":"2023-05-18T22:00:00.000Z","isBoxed":false,"isDeleted":false,"zoneFk":713,"zonePrice":13,"zoneBonus":1}', NULL), + (1, 18, 'select', '2000-12-27 03:40:30', 'Ticket', 45, NULL , NULL, NULL, NULL), + (1, 18, 'insert', '2000-04-10 09:40:15', 'Sale', 5689, 'Shield' , NULL, '{"quantity":10,"concept":"Shield", "price": 10.5, "itemFk": 1}', NULL), + (1, 18, 'insert', '1999-05-09 10:00:00', 'Ticket', 45, 'Super Man' , NULL, '{"id":45,"clientFk":8608,"warehouseFk":60,"shipped":"2023-05-16T22:00:00.000Z","nickname":"Super Man","addressFk":48637,"isSigned":true,"isLabeled":true,"isPrinted":true,"packages":0,"hour":0,"created":"2023-05-16T11:42:56.000Z","isBlocked":false,"hasPriority":false,"companyFk":442,"agencyModeFk":639,"landed":"2023-05-17T22:00:00.000Z","isBoxed":true,"isDeleted":true,"zoneFk":713,"zonePrice":13,"zoneBonus":0}', NULL); INSERT INTO `vn`.`osTicketConfig` (`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`, `responseType`, `fromEmailId`, `replyTo`) VALUES @@ -2804,9 +2827,9 @@ INSERT INTO `vn`.`payDemDetail` (`id`, `detail`) VALUES (1, 1); -INSERT INTO `vn`.`workerConfig` (`id`, `businessUpdated`, `roleFk`, `businessTypeFk`) +INSERT INTO `vn`.`workerConfig` (`id`, `businessUpdated`, `roleFk`, `payMethodFk`, `businessTypeFk`) VALUES - (1, NULL, 1, 'worker'); + (1, NULL, 1, 4, 'worker'); INSERT INTO `vn`.`ticketRefund`(`refundTicketFk`, `originalTicketFk`) VALUES diff --git a/db/dump/mockDate.sql b/db/dump/mockDate.sql index 937da071c..2b4c33d74 100644 --- a/db/dump/mockDate.sql +++ b/db/dump/mockDate.sql @@ -1,42 +1,33 @@ -CREATE SCHEMA IF NOT EXISTS `util`; -USE `util`; +DROP FUNCTION IF EXISTS `util`.`mockTime`; -DELIMITER ;; -DROP FUNCTION IF EXISTS `util`.`mockedDate`; -CREATE FUNCTION `util`.`mockedDate`() -RETURNS DATETIME -DETERMINISTIC +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` FUNCTION `util`.`mockTime`() RETURNS datetime + DETERMINISTIC BEGIN - RETURN CONVERT_TZ('2001-01-01 11:00:00', 'utc', 'Europe/Madrid'); -END ;; + RETURN CONVERT_TZ('@mockDate', 'utc', 'Europe/Madrid'); +END$$ DELIMITER ; -DELIMITER ;; -DROP FUNCTION IF EXISTS `util`.`VN_CURDATE`; -CREATE FUNCTION `util`.`VN_CURDATE`() -RETURNS DATE -DETERMINISTIC +DROP FUNCTION IF EXISTS `util`.`mockUtcTime`; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` FUNCTION `util`.`mockUtcTime`() RETURNS datetime + DETERMINISTIC BEGIN - RETURN DATE(mockedDate()); -END ;; + RETURN CONVERT_TZ('@mockDate', 'utc', 'Europe/Madrid'); +END$$ DELIMITER ; -DELIMITER ;; -DROP FUNCTION IF EXISTS `util`.`VN_CURTIME`; -CREATE FUNCTION `util`.`VN_CURTIME`() -RETURNS TIME -DETERMINISTIC +DROP FUNCTION IF EXISTS `util`.`mockTimeBase`; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` FUNCTION `util`.`mockTimeBase`(vIsUtc BOOL) RETURNS datetime + DETERMINISTIC BEGIN - RETURN TIME(mockedDate()); -END ;; + RETURN CONVERT_TZ('@mockDate', 'utc', 'Europe/Madrid'); +END$$ DELIMITER ; -DELIMITER ;; -DROP FUNCTION IF EXISTS `util`.`VN_NOW`; -CREATE FUNCTION `util`.`VN_NOW`() -RETURNS DATETIME -DETERMINISTIC -BEGIN - RETURN mockedDate(); -END ;; -DELIMITER ; diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 3256ecdca..cbb1e39c8 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -32,7 +32,10 @@ DROP TABLE IF EXISTS `account`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `account` ( `id` int(10) unsigned NOT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), + KEY `account_fk_editor` (`editorFk`), + CONSTRAINT `account_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `user` (`id`), CONSTRAINT `account_ibfk_3` FOREIGN KEY (`id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Users allowed to have an account'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -45,6 +48,26 @@ CREATE TABLE `account` ( /*!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 `account`.`account_beforeInsert` + BEFORE INSERT ON `account` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`account_afterInsert` AFTER INSERT ON `account` FOR EACH ROW @@ -53,6 +76,27 @@ BEGIN SELECT `name` FROM `user` WHERE id = NEW.id; END */;; DELIMITER ; + +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!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 `account`.`account_beforeUpdate` + BEFORE UPDATE ON `account` + 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 */ ; @@ -176,10 +220,78 @@ CREATE TABLE `mailAlias` ( `alias` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, `description` varchar(255) DEFAULT NULL, `isPublic` tinyint(4) NOT NULL DEFAULT 1, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `alias` (`alias`) + UNIQUE KEY `alias` (`alias`), + KEY `mailAlias_fk_editor` (`editorFk`), + CONSTRAINT `mailAlias_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `user` (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Mail aliases'; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`mailAlias_beforeInsert` + BEFORE INSERT ON `mailAlias` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; + +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`mailAlias_beforeUpdate` + BEFORE UPDATE ON `mailAlias` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`mailAlias_afterDelete` + AFTER DELETE ON `mailAlias` + FOR EACH ROW +BEGIN + INSERT INTO userLog + SET `action` = 'delete', + `changedModel` = 'MailAlias', + `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 */ ; -- -- Table structure for table `mailAliasAccount` @@ -235,16 +347,61 @@ CREATE TABLE `mailConfig` ( -- Table structure for table `mailForward` -- + DROP TABLE IF EXISTS `mailForward`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `mailForward` ( `account` int(10) unsigned NOT NULL, `forwardTo` varchar(250) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`account`), + KEY `mailForward_fk_editor` (`editorFk`), + CONSTRAINT `mailForward_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `user` (`id`), CONSTRAINT `mailForward_ibfk_1` FOREIGN KEY (`account`) REFERENCES `account` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Mail forwarding'; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`mailForward_beforeInsert` + BEFORE INSERT ON `mailForward` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`mailForward_beforeUpdate` + BEFORE UPDATE ON `mailForward` + 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 */ ; -- -- Table structure for table `mailSenderAccess` @@ -310,8 +467,11 @@ CREATE TABLE `role` ( `hasLogin` tinyint(3) unsigned NOT NULL DEFAULT 1, `created` timestamp NOT NULL DEFAULT current_timestamp(), `modified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `name` (`name`) + UNIQUE KEY `name` (`name`), + KEY `role_fk_editor` (`editorFk`), + CONSTRAINT `role_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `user` (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Roles'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -327,6 +487,7 @@ DELIMITER ;; BEFORE INSERT ON `role` FOR EACH ROW BEGIN + SET NEW.editorFk = account.myUser_getId(); CALL role_checkName(NEW.`name`); END */;; DELIMITER ; @@ -347,6 +508,7 @@ DELIMITER ;; BEFORE UPDATE ON `role` FOR EACH ROW BEGIN + SET NEW.editorFk = account.myUser_getId(); IF !(NEW.`name` <=> OLD.`name`) THEN CALL role_checkName (NEW.`name`); END IF; @@ -356,6 +518,30 @@ DELIMITER ; /*!50003 SET 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 `account`.`role_afterDelete` + AFTER DELETE ON `role` + FOR EACH ROW +BEGIN + INSERT INTO roleLog + SET `action` = 'delete', + `changedModel` = 'Role', + `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 */ ; -- -- Table structure for table `roleConfig` @@ -386,13 +572,107 @@ CREATE TABLE `roleInherit` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `role` int(10) unsigned NOT NULL, `inheritsFrom` int(10) unsigned NOT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `role` (`role`,`inheritsFrom`), KEY `owner_id` (`inheritsFrom`), + KEY `roleInherit_fk_editor` (`editorFk`), + CONSTRAINT `roleInherit_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `user` (`id`), CONSTRAINT `roleInherit_ibfk_1` FOREIGN KEY (`role`) REFERENCES `role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `roleInherit_ibfk_2` FOREIGN KEY (`inheritsFrom`) REFERENCES `role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Role inheritance'; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`roleInherit_beforeInsert` + BEFORE INSERT ON `roleInherit` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`roleInherit_beforeUpdate` + BEFORE UPDATE ON `roleInherit` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`roleInherit_afterDelete` + AFTER DELETE ON `roleInherit` + FOR EACH ROW +BEGIN + INSERT INTO roleLog + SET `action` = 'delete', + `changedModel` = 'RoleInherit', + `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 */ ; + +-- +-- Table structure for table `roleLog` +-- + +DROP TABLE IF EXISTS `roleLog`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `roleLog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `originFk` int(10) unsigned DEFAULT NULL, + `userFk` int(10) unsigned DEFAULT NULL, + `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` varchar(45) DEFAULT NULL, + `oldInstance` text DEFAULT NULL, + `newInstance` text DEFAULT NULL, + `changedModelId` int(11) DEFAULT NULL, + `changedModelValue` varchar(45) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `originFk` (`originFk`), + KEY `userFk` (`userFk`), + CONSTRAINT `roleLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `roleLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `roleRole` @@ -455,6 +735,7 @@ CREATE TABLE `user` ( `recoverPass` tinyint(3) unsigned NOT NULL DEFAULT 1 COMMENT 'Deprecated', `sync` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'Deprecated', `hasGrant` tinyint(1) NOT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`), UNIQUE KEY `mail` (`email`), @@ -462,6 +743,8 @@ CREATE TABLE `user` ( KEY `email` (`email`), KEY `nickname` (`nickname`), KEY `lang` (`lang`), + KEY `user_fk_editor` (`editorFk`), + CONSTRAINT `user_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `user` (`id`), CONSTRAINT `user_ibfk_2` FOREIGN KEY (`role`) REFERENCES `role` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Global users'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -478,6 +761,8 @@ DELIMITER ;; BEFORE INSERT ON `user` FOR EACH ROW BEGIN + SET NEW.editorFk = account.myUser_getId(); + CALL user_checkName(NEW.`name`); IF NEW.nickname = '' THEN @@ -524,6 +809,8 @@ DELIMITER ;; BEFORE UPDATE ON `user` FOR EACH ROW BEGIN + SET NEW.editorFk = account.myUser_getId(); + IF !(NEW.`name` <=> OLD.`name`) THEN CALL user_checkName (NEW.`name`); END IF; @@ -562,41 +849,9 @@ BEGIN INSERT IGNORE INTO userSync SET `name` = OLD.`name`; END IF; - IF !(NEW.`role` <=> OLD.`role`) - THEN - CALL vn.mail_insert('jgallego@verdnatura.es', - 'jgallego@verdnatura.es', - 'Rol modificado', - CONCAT( - myUser_getName(), - ' ha modificado el rol del usuario ', - NEW.`name`, ' de ', OLD.role, ' a ', NEW.role) - ); - END IF; END */;; DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`user_afterDelete` - AFTER DELETE ON `user` - FOR EACH ROW -BEGIN - CALL hedera.image_unref('user', OLD.image); - INSERT IGNORE INTO userSync SET `name` = OLD.`name`; -END */;; -DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; @@ -616,6 +871,33 @@ CREATE TABLE `userConfig` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `userLog` +-- + +DROP TABLE IF EXISTS `userLog`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `userLog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `originFk` int(10) unsigned DEFAULT NULL, + `userFk` int(10) unsigned DEFAULT NULL, + `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` varchar(45) DEFAULT NULL, + `oldInstance` text DEFAULT NULL, + `newInstance` text DEFAULT NULL, + `changedModelId` int(11) DEFAULT NULL, + `changedModelValue` varchar(45) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `originFk` (`originFk`), + KEY `userFk` (`userFk`), + CONSTRAINT `userLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `userLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `userPassword` -- @@ -739,7 +1021,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `myUser_getName`() RETURNS varchar(30) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `myUser_getName`() RETURNS varchar(30) CHARSET utf8mb3 COLLATE utf8mb3_general_ci NO SQL DETERMINISTIC BEGIN @@ -826,7 +1108,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `passwordGenerate`() RETURNS text CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `passwordGenerate`() RETURNS text CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci READS SQL DATA BEGIN /** @@ -916,7 +1198,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `user_getMysqlRole`(vUserName VARCHAR(255)) RETURNS varchar(255) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `user_getMysqlRole`(vUserName VARCHAR(255)) RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN /** @@ -951,7 +1233,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `user_getNameFromId`(vSelf INT) RETURNS varchar(30) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `user_getNameFromId`(vSelf INT) RETURNS varchar(30) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN /** @@ -1972,6 +2254,7 @@ BEGIN FLUSH PRIVILEGES; END ;; DELIMITER ; + /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; @@ -2735,7 +3018,7 @@ CREATE TABLE `sale` ( CONSTRAINT `sale_FK` FOREIGN KEY (`saleFk`) REFERENCES `vn`.`sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `sale_FK_1` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `sale_FK_2` FOREIGN KEY (`companyFk`) REFERENCES `vn`.`company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `sale_FK_3` FOREIGN KEY (`typeFk`) REFERENCES `vn`.`itemType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `sale_FK_3` FOREIGN KEY (`typeFk`) REFERENCES `vn`.`itemType` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -2766,7 +3049,7 @@ CREATE TABLE `salesByItemTypeDay` ( KEY `itemTypeSalesByweek_itemCategoryFk_idx` (`itemCategoryFk`), KEY `itemTypeSalesByweek_period_idx` (`dated`), CONSTRAINT `itemTypeSalesByweek_itemCategoryFk` FOREIGN KEY (`itemCategoryFk`) REFERENCES `vn`.`itemCategory` (`id`) ON UPDATE CASCADE, - CONSTRAINT `itemTypeSalesByweek_itemTypeFk` FOREIGN KEY (`itemTypeFk`) REFERENCES `vn`.`itemType` (`id`) ON UPDATE CASCADE + CONSTRAINT `itemTypeSalesByweek_itemTypeFk` FOREIGN KEY (`itemTypeFk`) REFERENCES `vn`.`itemType` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Ventas diarias agrupadas por reino y familia'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -2955,7 +3238,7 @@ CREATE TABLE `waste` ( PRIMARY KEY (`buyer`,`year`,`week`,`family`,`itemFk`), KEY `waste_itemType_id` (`itemTypeFk`), KEY `waste_item_id` (`itemFk`), - CONSTRAINT `waste_itemType_id` FOREIGN KEY (`itemTypeFk`) REFERENCES `vn`.`itemType` (`id`) ON UPDATE CASCADE, + CONSTRAINT `waste_itemType_id` FOREIGN KEY (`itemTypeFk`) REFERENCES `vn`.`itemType` (`id`), CONSTRAINT `waste_item_id` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -3037,7 +3320,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `nightTask_launchAll` ON SCHEDULE EVERY 1 DAY STARTS '2022-02-08 04:14:00' ON COMPLETION PRESERVE DISABLE ON SLAVE DO CALL bs.nightTask_launchAll */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `nightTask_launchAll` ON SCHEDULE EVERY 1 DAY STARTS '2022-02-08 04:14:00' ON COMPLETION PRESERVE ENABLE DO CALL bs.nightTask_launchAll */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -3053,13 +3336,13 @@ 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 = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `tramo`(vDateTime DATETIME) RETURNS varchar(20) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `tramo`(vDateTime DATETIME) RETURNS varchar(20) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci NO SQL BEGIN @@ -3481,7 +3764,7 @@ BLOCK1: BEGIN JOIN vn.productionConfig pc WHERE t.shipped BETWEEN util.VN_CURDATE() + INTERVAL -(`notBuyingMonths`) MONTH AND util.VN_CURDATE() + INTERVAL -(`pc`.`rookieDays`) DAY) notRookie ON notRookie.clientFk = cnb.clientFk - SET cnd.isRookie = ISNULL(notRookie.clientFk); + SET cnb.isRookie = ISNULL(notRookie.clientFk); END BLOCK1 ;; DELIMITER ; @@ -3715,77 +3998,67 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `compradores_evolution_add`() BEGIN -/* +/** + * Inserta en la tabla compradores_evolution las ventas acumuladas en los ultimos 365 dias + * + */ + DECLARE vDated DATE; + DECLARE vCount INT DEFAULT 1; -Inserta en la tabla compradores_evolution las ventas acumuladas en los ultimos 365 dias + SELECT MAX(fecha) + INTERVAL 1 DAY INTO vDated + FROM compradores_evolution; -*/ + IF vDated IS NULL THEN -DECLARE datFEC DATE; -DECLARE i INT DEFAULT 1; + SELECT MIN(dated) INTO vDated + FROM sale; + INSERT INTO compradores_evolution( + Id_Trabajador, + fecha, + importe) + SELECT it.workerFk, + vDated, + SUM(s.amount) + FROM sale s + JOIN vn.itemType it ON it.id = s.typeFk + WHERE s.dated = vDated + GROUP BY it.workerFk; -SELECT TIMESTAMPADD(DAY,1,MAX(fecha)) INTO datFEC FROM bs.compradores_evolution; + SET vDated = vDated + INTERVAL 1 DAY; + END IF; - IF ISNULL(datFEC) THEN + WHILE vDated < util.VN_CURDATE() DO - SELECT min(fecha) INTO datFEC - FROM bs.ventas; - - INSERT INTO bs.compradores_evolution( Id_Trabajador - , fecha - , importe) - SELECT Id_Trabajador, datFEC, sum(importe) - FROM bs.ventas v - JOIN vn2008.Tipos tp using(tipo_id) - WHERE fecha = datFEC - GROUP BY Id_Trabajador; - - SET datFEC = TIMESTAMPADD(DAY, 1, datFEC); - - END IF; - - WHILE datFEC < util.VN_CURDATE() DO - - IF i mod 150 = 0 THEN - SELECT datFEC; - END IF; - - SET i = i + 1; - - REPLACE bs.compradores_evolution( Id_Trabajador - , fecha - , importe) - - SELECT Id_Trabajador - , datFEC as fecha - , sum(importe) as importe - - FROM - ( - - SELECT Id_Trabajador - , importe - FROM bs.compradores_evolution - WHERE fecha = TIMESTAMPADD(DAY,-1,datFEC) -- las ventas acumuladas del dia anterior - - UNION ALL - - SELECT Id_Trabajador - , importe * IF(v.fecha < datFEC,-1,1) -- se restan las ventas del año anterior y se suman las del actual - FROM bs.ventas v - JOIN vn2008.Tipos tp using(tipo_id) - WHERE fecha IN (datFEC, TIMESTAMPADD(DAY,-365,datFEC)) - AND reino_id != 6 - - )sub - GROUP BY Id_Trabajador; - - SET datFEC = TIMESTAMPADD(DAY,1,datFEC); - - END WHILE; + SET vCount = vCount + 1; + REPLACE compradores_evolution( + Id_Trabajador, + fecha, + importe) + SELECT Id_Trabajador, + vDated, + SUM(importe) + FROM( + SELECT Id_Trabajador, importe + FROM compradores_evolution + JOIN ( + SELECT DISTINCT it.workerFk + FROM vn.itemType it + )sub2 ON sub2.workerFk = Id_Trabajador + WHERE fecha = vDated - INTERVAL 1 DAY + UNION ALL + SELECT it.workerFk, s.amount * IF(s.dated < vDated, -1, 1) + FROM sale s + JOIN vn.itemType it ON it.id = s.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + WHERE s.dated IN (vDated, vDated - INTERVAL 1 YEAR) + AND ic.merchandise + )sub + GROUP BY Id_Trabajador; + SET vDated = vDated + INTERVAL 1 DAY; + END WHILE; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -3957,9 +4230,9 @@ BEGIN -- Número de trabajadores activos UPDATE indicators SET countEmployee = - (SELECT CAST(SUM(cl.hours_week) / 40 AS DECIMAL (10, 2)) + (SELECT CAST(SUM(ct.hoursWeek) / 40 AS DECIMAL (10, 2)) FROM vn.business b - JOIN postgresql.calendar_labour_type cl ON cl.calendar_labour_type_id = b.calendarTypeFk + JOIN vn.calendarType ct ON ct.id = b.calendarTypeFk WHERE vDated BETWEEN b.started AND IFNULL(b.ended, vDated) AND b.companyCodeFk = 'VNL' ) @@ -4092,61 +4365,6 @@ BEGIN END WHILE; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `inspeccionSS_2021_add` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `inspeccionSS_2021_add`() -BEGIN - - TRUNCATE bs.inspeccionSS_2021; - - INSERT INTO bs.inspeccionSS_2021 - SELECT wbd.businessFk , - w.id, - w.firstName, - w.lastName, - d.name , - wtc.timed , - cl.hours_week , - t.`year` , - t.week , - t.dated , - 0 AS orden - FROM vn.workerTimeControl wtc - JOIN vn.worker w ON w.id = wtc.userFk - JOIN vn.workerBusinessDated wbd ON wbd.workerFk = wtc.userFk - AND wbd.dated = date(wtc.timed) - JOIN vn.time t ON t.dated = wbd.dated - JOIN vn.business b ON b.id = wbd.businessFk - JOIN postgresql.calendar_labour_type AS cl ON b.calendarTypeFk = cl.calendar_labour_type_id - JOIN vn.department d ON d.id = b.departmentFk - JOIN vn.department d2 ON d2.id = d.parentFk AND d2.name = 'PRODUCCION' - WHERE wtc.timed BETWEEN '2020-10-01' AND '2021-04-19' - AND d.lft BETWEEN d2.lft AND d2.rgt - AND lastName NOT LIKE 'FERRER%'; - - SET @orden := 1; - SET @id := 0; - SET @day := 0; - - UPDATE bs.inspeccionSS_2021 - SET orden = IF(id = @id AND day(timed) = @day, @orden := @orden + 1, @orden := 1), - id = @id := id + (0 * @day := day(timed)) - ORDER BY id, timed; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -4321,16 +4539,18 @@ BEGIN * para el componente de maná automático. */ UPDATE vn.workerMana wm - JOIN( - SELECT sb.salespersonFk, FLOOR(SUM(sb.amount) / 12) monthlyAmount - FROM salesByclientSalesPerson sb - JOIN vn.time t ON t.dated = sb.dated - WHERE t.year * 100 + t.month >= - (YEAR(util.VN_CURDATE()) - 1) * 100 + MONTH(util.VN_CURDATE()) - GROUP BY salespersonFk - ) lastYearSales ON wm.workerFk = lastYearSales.salespersonFk - SET pricesModifierRate = GREATEST(minRate, - LEAST(maxRate, ROUND( - amount / lastYearSales.monthlyAmount, 3))); + JOIN ( + SELECT c.lastSalesPersonFk, + FLOOR(SUM(s.amount) / 12) amount + FROM salesByclientSalesPerson s + JOIN vn.client c ON c.id = s.clientFk + WHERE s.dated BETWEEN util.VN_CURDATE() - INTERVAL 1 YEAR AND util.VN_CURDATE() + GROUP BY c.lastSalesPersonFk + )avgPortfolioWeight ON avgPortfolioWeight.lastSalesPersonFk = wm.workerFk + JOIN vn.salespersonConfig spc + SET wm.pricesModifierRate = GREATEST( + spc.manaMinRate, + LEAST(spc.manaMaxRate, ROUND( - wm.amount / avgPortfolioWeight.amount))); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -4664,16 +4884,16 @@ DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `salesByItemTypeDay_add`(vDateStart DATE, vDateEnd DATE) BEGIN /** - * Almacena datos relativos a las ventas de artículos agrupados por reino y familia + * Almacena datos relativos a las ventas de artículos agrupados por reino, familia y dia * * @param vDateStart * @param vDateEnd */ - DELETE FROM bs.salesByItemTypeDay + DELETE FROM bs.salesByItemTypeDay WHERE dated BETWEEN vDateStart AND vDateEnd; - INSERT INTO bs.salesByItemTypeDay (itemTypeFk, itemCategoryFk, dated) + INSERT INTO bs.salesByItemTypeDay (itemTypeFk, itemCategoryFk, dated) SELECT id, categoryFk, dated FROM vn.itemType JOIN vn.`time` @@ -4697,7 +4917,6 @@ BEGIN GROUP BY ic.id, it.id, bs.dated) sub ON sub.dated = it.dated AND sub.itemCategoryFk = it.itemCategoryFk AND sub.itemTypeFk = it.itemTypeFk SET it.netSale = sub.netSale; - UPDATE bs.salesByItemTypeDay it JOIN (SELECT ic.id AS itemCategoryFk, it.id AS itemTypeFk, @@ -4709,7 +4928,7 @@ BEGIN JOIN vn.sale s ON s.id = bs.saleFk JOIN vn.ticket t ON t.id = s.ticketFk JOIN vn.item i ON i.id = s.itemFk - JOIN vn.`time` tm ON tm.dated = bs.dated + JOIN vn.`time` tm ON tm.dated = bs.dated WHERE ic.merchandise AND bs.dated BETWEEN vDateStart AND vDateEnd GROUP BY ic.id, it.id, bs.dated) sub ON sub.dated = it.dated AND sub.itemCategoryFk = it.itemCategoryFk AND sub.itemTypeFk = it.itemTypeFk @@ -4778,7 +4997,7 @@ BEGIN JOIN vn.itemCategory ic ON ic.id = it.categoryFk JOIN vn.claimConfig cc WHERE ic.merchandise - AND t.shipped BETWEEN vDateStart AND util.dayEnd(vDateEnd) + AND t.shipped BETWEEN vDateStart AND util.dayEnd(vDateEnd) GROUP BY ic.id, it.id, dated) sub ON sub.dated = it.dated AND sub.itemCategoryFk = it.itemCategoryFk AND sub.itemTypeFk = it.itemTypeFk SET it.accepted = sub.accepted, it.claimed = sub.claimed; @@ -4816,7 +5035,7 @@ BEGIN JOIN vn.item i ON i.id = b.itemFk JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.itemCategory ic ON ic.id = it.categoryFk - WHERE ic.merchandise + WHERE ic.merchandise AND t.landed BETWEEN vDateStart AND vDateEnd GROUP BY ic.id, it.id, t.landed) sub GROUP BY itemCategoryFk, itemTypeFk, dated) sub2 ON sub2.dated = it.dated AND sub2.itemCategoryFk = it.itemCategoryFk AND sub2.itemTypeFk = it.itemTypeFk @@ -4845,34 +5064,13 @@ BEGIN WHERE t.shipped BETWEEN vDateStart AND util.dayEnd(vDateEnd) GROUP BY ic.id, it.id, dated; - UPDATE bs.salesByItemTypeDay it + UPDATE bs.salesByItemTypeDay it JOIN tmp.`component` c ON c.dated = it.dated AND c.itemCategoryFk = it.itemCategoryFk AND c.itemTypeFk = it.itemTypeFk SET it.costComponent = c.costComponent, it.marginComponent = c.marginComponent, - it.saleComponent = c.costComponent + c.marginComponent; + it.saleComponent = c.costComponent + c.marginComponent; - DROP TEMPORARY TABLE tmp.`component`; - -/* UPDATE bs.salesByItemTypeDay it - JOIN(SELECT DATE(t.shipped) dated, - ic.id itemCategoryFk, - it.id itemTypeFk, - SUM(s.quantity * IF(c.code = 'purchaseValue', sc.value,0)) costComponent, - SUM(s.quantity * IF(ct.isMargin, sc.value,0)) marginComponent - FROM vn.ticket t - JOIN vn.sale s ON t.id = s.ticketFk - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.itemCategory ic ON ic.id = it.categoryFk - JOIN vn.saleComponent sc ON sc.saleFk = s.id - STRAIGHT_JOIN vn.component c ON c.id = sc.componentFk - JOIN vn.componentType ct ON ct.id = c.typeFk - JOIN vn.`time` tm ON tm.dated = DATE(t.shipped) - WHERE t.shipped BETWEEN vDateStart AND util.dayEnd(vDateEnd) - GROUP BY ic.id, it.id, dated)sub ON sub.dated = it.dated AND sub.itemCategoryFk = it.itemCategoryFk AND sub.itemTypeFk = it.itemTypeFk - SET it.costComponent = sub.costComponent, - it.marginComponent = sub.marginComponent, - it.saleComponent = sub.costComponent + sub.marginComponent;*/ + DROP TEMPORARY TABLE tmp.`component`; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -5015,8 +5213,8 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `ventas_add`( IN vEnded DATETIME) BEGIN /** -* Añade las ventas que se realizaron de hace -* una semana hasta hoy +* Añade las ventas que se realizaron entre +* vStarted y vEnded * * @param vStarted Fecha de inicio * @param vEnded Fecha de finalizacion @@ -5032,7 +5230,7 @@ BEGIN SET vEnded = util.dayEnd(vEnded); SET vStartingDate = vStarted ; - SET vEndingDate = vn2008.dayend(vStartingDate); + SET vEndingDate = util.dayEnd(vStartingDate); DELETE FROM sale @@ -5103,14 +5301,13 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ventas_add_launcher`() BEGIN +/** + * Añade las ventas a la tabla bs.sale que se realizaron desde hace un mes hasta hoy + * + */ - /** - * Añade las ventas que se realizaron de hace - * una semana hasta hoy - * - **/ - - CALL bs.ventas_add(timestampadd(week,-1,util.VN_CURDATE()),util.VN_CURDATE()); + DECLARE vCurDate DATE DEFAULT util.VN_CURDATE(); + CALL ventas_add(vCurDate - INTERVAL 1 MONTH, vCurDate); END ;; DELIMITER ; @@ -5572,7 +5769,7 @@ DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerProductivity_add`() BEGIN DECLARE vDateFrom DATE; - SELECT DATE_SUB(util.VN_CURDATE(), INTERVAL 30 DAY) INTO vDateFrom; + SELECT DATE_SUB(util.VN_CURDATE(),INTERVAL 30 DAY) INTO vDateFrom; DELETE FROM workerProductivity WHERE dated >= vDateFrom; @@ -5905,7 +6102,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `cacheCalc_clean` ON SCHEDULE EVERY 30 MINUTE STARTS '2022-01-28 09:29:18' ON COMPLETION NOT PRESERVE DISABLE ON SLAVE DO CALL cacheCalc_clean */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `cacheCalc_clean` ON SCHEDULE EVERY 30 MINUTE STARTS '2022-01-28 09:29:18' ON COMPLETION NOT PRESERVE ENABLE DO CALL cacheCalc_clean */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -5923,7 +6120,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `cache_clean` ON SCHEDULE EVERY 5 MINUTE STARTS '2022-01-28 09:29:18' ON COMPLETION NOT PRESERVE DISABLE ON SLAVE DO CALL cache_clean */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `cache_clean` ON SCHEDULE EVERY 5 MINUTE STARTS '2022-01-28 09:29:18' ON COMPLETION NOT PRESERVE ENABLE DO CALL cache_clean */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -6298,7 +6495,7 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `cacheCalc_clean`() BEGIN - DECLARE vCleanTime DATETIME DEFAULT TIMESTAMPADD(MINUTE, -5, util.VN_NOW()); + DECLARE vCleanTime DATETIME DEFAULT TIMESTAMPADD(MINUTE, -5, NOW()); DELETE FROM cache_calc WHERE expires < vCleanTime; END ;; DELIMITER ; @@ -6325,8 +6522,8 @@ BEGIN UPDATE cache_calc cc JOIN cache c ON c.id = cc.cache_id SET - cc.last_refresh = util.VN_NOW(), - cc.expires = LEAST(ADDTIME(util.VN_NOW(), c.lifetime), util.midNight()), + cc.last_refresh = NOW(), + cc.expires = ADDTIME(NOW(), c.lifetime), cc.connection_id = NULL WHERE cc.id = v_calc; @@ -6361,12 +6558,13 @@ proc: BEGIN DECLARE v_cache_id INT; DECLARE v_expires DATETIME; DECLARE v_clean_time DATETIME; + DECLARE vLastRefresh DATETIME; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN IF v_lock_id IS NOT NULL THEN DO RELEASE_LOCK(v_lock_id); - END IF; + END IF; RESIGNAL; END; @@ -6396,8 +6594,8 @@ proc: BEGIN -- Comprueba si el calculo solicitado existe y esta actualizado. - SELECT c.id, ca.id, ca.expires - INTO v_cache_id, v_calc, v_expires + SELECT c.id, ca.id, ca.expires, ca.last_refresh + INTO v_cache_id, v_calc, v_expires, vLastRefresh FROM cache c LEFT JOIN cache_calc ca ON ca.cache_id = c.id AND ca.params = v_params COLLATE 'utf8_general_ci' @@ -6405,7 +6603,7 @@ proc: BEGIN -- Si existe una calculo valido libera el bloqueo y devuelve su identificador. - IF !v_refresh AND util.VN_NOW() < v_expires + IF !v_refresh AND NOW() < v_expires AND vLastRefresh >= CURDATE() THEN DO RELEASE_LOCK(v_lock_id); SET v_refresh = FALSE; @@ -6511,12 +6709,11 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `clean`() BEGIN + DECLARE vDateShort DATETIME; - DECLARE vDateShort DATETIME; + SET vDateShort = TIMESTAMPADD(MONTH, -1, util.VN_CURDATE()); - SET vDateShort = TIMESTAMPADD(MONTH, -1, util.VN_CURDATE()); - - DELETE FROM cache.departure_limit WHERE Fecha < vDateShort; + DELETE FROM cache.departure_limit WHERE Fecha < vDateShort; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -6616,9 +6813,9 @@ DELIMITER ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `last_buy_refresh`(vRefresh BOOL) proc: BEGIN @@ -6738,7 +6935,7 @@ proc: BEGIN **/ DECLARE v_calc INT; DECLARE v_date_inv DATE; - DECLARE v_curdate DATE; + DECLARE vCURDATE DATE; DECLARE v_last_refresh DATETIME; DECLARE EXIT HANDLER FOR SQLEXCEPTION @@ -6755,7 +6952,7 @@ proc: BEGIN END IF; SET v_date_inv = (SELECT inventoried FROM vn.config LIMIT 1); - SET v_curdate = util.VN_CURDATE(); + SET vCURDATE = util.VN_CURDATE(); DELETE FROM stock; @@ -6764,15 +6961,15 @@ proc: BEGIN ( SELECT itemFk AS item_id, warehouseFk AS warehouse_id, quantity AS amount FROM vn.itemTicketOut - WHERE shipped >= v_date_inv AND shipped < v_curdate + WHERE shipped >= v_date_inv AND shipped < vCURDATE UNION ALL SELECT itemFk ASitem_id, warehouseInFk AS warehouse_id, quantity AS amount FROM vn.itemEntryIn - WHERE landed >= v_date_inv AND landed < v_curdate AND isVirtualStock is FALSE + WHERE landed >= v_date_inv AND landed < vCURDATE AND isVirtualStock is FALSE UNION ALL SELECT itemFk AS item_id ,warehouseOutFk AS warehouse_id, quantity AS amount FROM vn.itemEntryOut - WHERE shipped >= v_date_inv AND shipped < v_curdate + WHERE shipped >= v_date_inv AND shipped < vCURDATE ) t GROUP BY item_id, warehouse_id HAVING amount != 0; @@ -7059,7 +7256,7 @@ CREATE TABLE `ekt` ( `vendorOrderNumber` bigint(20) unsigned DEFAULT NULL COMMENT 'RFF+VN', `fec` date DEFAULT NULL COMMENT 'DTM+97', `hor` time DEFAULT NULL COMMENT 'UNB', - `util.VN_NOW` timestamp NULL DEFAULT current_timestamp() COMMENT 'Creation time', + `now` timestamp NULL DEFAULT current_timestamp() COMMENT 'Creation time', `ptj` bigint(20) unsigned DEFAULT NULL COMMENT 'NAD+BY', `ref` int(11) NOT NULL COMMENT 'LIN', `item` varchar(50) DEFAULT NULL COMMENT 'IMD+S99', @@ -7088,7 +7285,7 @@ CREATE TABLE `ekt` ( `s6` varchar(3) DEFAULT NULL, `ok` tinyint(4) NOT NULL DEFAULT 0, `trolleyFk` int(11) DEFAULT NULL, - `putOrderFk` bigint(20) unsigned DEFAULT NULL COMMENT 'RFF+ON', + `putOrderFk` bigint(20) DEFAULT NULL COMMENT 'RFF+ON', `scanned` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Whether it''s been scanned', `cps` varchar(7) DEFAULT NULL COMMENT 'Código alfanumérico de Floriday', `dp` bigint(20) unsigned DEFAULT NULL COMMENT 'NAD+DP', @@ -7103,7 +7300,8 @@ CREATE TABLE `ekt` ( KEY `fec` (`fec`), KEY `putOrderFk` (`putOrderFk`), KEY `ekt_batchNumber` (`batchNumber`) USING BTREE, - KEY `ekt_vendorOrderNumber` (`vendorOrderNumber`) USING BTREE + KEY `ekt_vendorOrderNumber` (`vendorOrderNumber`) USING BTREE, + KEY `ekt_sub_IDX` (`sub`) USING BTREE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -7141,7 +7339,7 @@ SET character_set_client = utf8; `vendorOrderNumber` tinyint NOT NULL, `fec` tinyint NOT NULL, `hor` tinyint NOT NULL, - `util.VN_NOW` tinyint NOT NULL, + `now` tinyint NOT NULL, `ptj` tinyint NOT NULL, `ref` tinyint NOT NULL, `item` tinyint NOT NULL, @@ -7504,7 +7702,7 @@ CREATE TABLE `item_groupToOffer` ( KEY `item_groupToOffer_fk2_idx` (`itemTypeFk`), KEY `item_groupToOffer_fk3_idx` (`intrastatFk`), KEY `item_groupToOffer_fk4_idx` (`originFk`), - CONSTRAINT `item_groupToOffer_fk2` FOREIGN KEY (`itemTypeFk`) REFERENCES `vn`.`itemType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `item_groupToOffer_fk2` FOREIGN KEY (`itemTypeFk`) REFERENCES `vn`.`itemType` (`id`), CONSTRAINT `item_groupToOffer_fk3` FOREIGN KEY (`intrastatFk`) REFERENCES `vn`.`intrastat` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `item_groupToOffer_fk4` FOREIGN KEY (`originFk`) REFERENCES `vn`.`origin` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='se ofreceran para ser comprados'; @@ -7632,6 +7830,20 @@ CREATE TABLE `offerList` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Lista de las ofertas para mostrar en grafana'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `offerRefreshConfig` +-- + +DROP TABLE IF EXISTS `offerRefreshConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `offerRefreshConfig` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `dayRange` int(10) unsigned DEFAULT NULL COMMENT 'range of days to update the photos of an article in seconds', + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `param` -- @@ -8180,7 +8392,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `floramondo` ON SCHEDULE EVERY 6 MINUTE STARTS '2022-01-28 09:52:45' ON COMPLETION NOT PRESERVE DISABLE ON SLAVE DO CALL edi.floramondo_offerRefresh() */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `floramondo` ON SCHEDULE EVERY 6 MINUTE STARTS '2022-01-28 09:52:45' ON COMPLETION NOT PRESERVE ENABLE DO CALL edi.floramondo_offerRefresh() */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -8202,7 +8414,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `imageName`(vPictureReference VARCHAR(255)) RETURNS varchar(255) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `imageName`(vPictureReference VARCHAR(255)) RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN @@ -8506,7 +8718,7 @@ proc:BEGIN AND IF(t.package, l.package = e.package, TRUE) AND IF(t.item, l.item = e.item, TRUE) AND i.isFloramondo = vIsFloramondoDirect - ORDER BY l.util.VN_NOW DESC, b.id ASC + ORDER BY l.now DESC, b.id ASC LIMIT 1; END IF; @@ -8676,20 +8888,18 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ekt_loadNotBuy`() BEGIN - - /** - * Ejecuta ekt_load para aquellos ekt de hoy que no tienen vn.buy - */ - +/** + * Ejecuta ekt_load para aquellos ekt de hoy que no tienen vn.buy + */ DECLARE vEktFk INTEGER; DECLARE done BOOL; - - DECLARE cursor1 CURSOR FOR SELECT e.id - FROM edi.ekt e - LEFT JOIN vn.buy b ON b.ektFk = e.id - WHERE e.fec >= util.VN_CURDATE() - AND ISNULL(b.ektFk); + DECLARE cursor1 CURSOR FOR + SELECT e.id + FROM edi.ekt e + LEFT JOIN vn.buy b ON b.ektFk = e.id + WHERE e.fec >= util.VN_CURDATE() + AND ISNULL(b.ektFk); DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; @@ -8706,7 +8916,6 @@ BEGIN END LOOP bucle; CLOSE cursor1; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -8938,7 +9147,7 @@ DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `floramondo_offerRefresh`() proc: BEGIN DECLARE vLanded DATETIME; - DECLARE done INT DEFAULT FALSE; + DECLARE vDone INT DEFAULT FALSE; DECLARE vFreeId INT; DECLARE vSupplyResponseFk INT; DECLARE vLastInserted DATETIME; @@ -8946,6 +9155,7 @@ proc: BEGIN DECLARE vMaxNewItems INT DEFAULT 10000; DECLARE vStartingTime DATETIME; DECLARE vAalsmeerMarketPlaceID VARCHAR(13) DEFAULT '8713783439043'; + DECLARE vDayRange INT; DECLARE cur1 CURSOR FOR SELECT id @@ -8955,7 +9165,7 @@ proc: BEGIN SELECT srId FROM itemToInsert; - DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DECLARE EXIT HANDLER FOR SQLSTATE '45000' BEGIN ROLLBACK; @@ -8963,9 +9173,10 @@ proc: BEGIN END; DECLARE CONTINUE HANDLER FOR SQLEXCEPTION - BEGIN + BEGIN DO RELEASE_LOCK('edi.floramondo_offerRefresh'); - RESIGNAL; + SET @isTriggerDisabled = FALSE; + RESIGNAL; END; IF 'test' = (SELECT environment FROM util.config) THEN @@ -8976,16 +9187,23 @@ proc: BEGIN LEAVE proc; END IF; + SELECT dayRange INTO vDayRange + FROM offerRefreshConfig; + + IF vDayRange IS NULL THEN + CALL util.throw("Variable vDayRange not declared"); + END IF; + SET vStartingTime = util.VN_NOW(); - TRUNCATE edi.offerList ; + TRUNCATE edi.offerList; INSERT INTO edi.offerList(supplier, total) SELECT v.name, COUNT(DISTINCT sr.ID) total FROM edi.supplyResponse sr - JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID + JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID WHERE sr.NumberOfUnits > 0 - AND sr.EmbalageCode != 999 + AND sr.EmbalageCode != 999 GROUP BY sr.vmpID; UPDATE edi.offerList o @@ -8995,30 +9213,23 @@ proc: BEGIN GROUP BY sr.vmpID) sub ON o.supplier = sub.name SET o.`filter` = sub.total; - -- Refresca las fotos de los items existentes, con prioridad baja (0.7 seg) - INSERT IGNORE INTO vn.itemImageQueue(itemFk, url,priority) - SELECT i.id, sr.PictureReference , 100 - FROM edi.supplyResponse sr - JOIN vn.item i ON i.supplyResponseFk = sr.ID - WHERE i.image != edi.imageName(sr.PictureReference) - AND sr.NumberOfUnits > 0; - -- Elimina de la lista de items libres aquellos que ya existen DELETE itf.* FROM edi.item_free itf JOIN vn.item i ON i.id = itf.id; - DROP TEMPORARY TABLE IF EXISTS tmp; - CREATE TEMPORARY TABLE tmp (INDEX (`Item_ArticleCode`)) ENGINE = MEMORY + CREATE OR REPLACE TEMPORARY TABLE tmp + (INDEX (`Item_ArticleCode`)) + ENGINE = MEMORY SELECT t.* FROM ( - SELECT * - FROM edi.supplyOffer - ORDER BY (MarketPlaceID = vAalsmeerMarketPlaceID) DESC, NumberOfUnits DESC LIMIT 10000000000000000000) t + SELECT * + FROM edi.supplyOffer + ORDER BY (MarketPlaceID = vAalsmeerMarketPlaceID) DESC, + NumberOfUnits DESC LIMIT 10000000000000000000) t GROUP BY t.srId; - DROP TEMPORARY TABLE IF EXISTS edi.offer; - CREATE TEMPORARY TABLE edi.offer (INDEX (`srID`), INDEX (`EmbalageCode`), + CREATE OR REPLACE TEMPORARY TABLE edi.offer (INDEX (`srID`), INDEX (`EmbalageCode`), INDEX (`ef1`), INDEX (`ef2`), INDEX (`ef3`), INDEX (`ef4`),INDEX (`ef5`), INDEX (`ef6`), INDEX (`s1Value`), INDEX (`s2Value`), INDEX (`s3Value`), INDEX (`s4Value`),INDEX (`s5Value`), INDEX (`s6Value`)) ENGINE = MEMORY @@ -9037,23 +9248,35 @@ proc: BEGIN eif6.feature ef6 FROM tmp so LEFT JOIN edi.item_feature eif1 ON eif1.item_id = so.Item_ArticleCode - AND eif1.presentation_order = 1 AND eif1.expiry_date IS NULL + AND eif1.presentation_order = 1 + AND eif1.expiry_date IS NULL LEFT JOIN edi.item_feature eif2 ON eif2.item_id = so.Item_ArticleCode - AND eif2.presentation_order = 2 AND eif2.expiry_date IS NULL + AND eif2.presentation_order = 2 + AND eif2.expiry_date IS NULL LEFT JOIN edi.item_feature eif3 ON eif3.item_id = so.Item_ArticleCode - AND eif3.presentation_order = 3 AND eif3.expiry_date IS NULL + AND eif3.presentation_order = 3 + AND eif3.expiry_date IS NULL LEFT JOIN edi.item_feature eif4 ON eif4.item_id = so.Item_ArticleCode - AND eif4.presentation_order = 4 AND eif4.expiry_date IS NULL + AND eif4.presentation_order = 4 + AND eif4.expiry_date IS NULL LEFT JOIN edi.item_feature eif5 ON eif5.item_id = so.Item_ArticleCode - AND eif5.presentation_order = 5 AND eif5.expiry_date IS NULL + AND eif5.presentation_order = 5 + AND eif5.expiry_date IS NULL LEFT JOIN edi.item_feature eif6 ON eif6.item_id = so.Item_ArticleCode - AND eif6.presentation_order = 6 AND eif6.expiry_date IS NULL - LEFT JOIN edi.`value` ev1 ON ev1.type_id = eif1.feature AND so.s1 = ev1.type_value - LEFT JOIN edi.`value` ev2 ON ev2.type_id = eif2.feature AND so.s2 = ev2.type_value - LEFT JOIN edi.`value` ev3 ON ev3.type_id = eif3.feature AND so.s3 = ev3.type_value - LEFT JOIN edi.`value` ev4 ON ev4.type_id = eif4.feature AND so.s4 = ev4.type_value - LEFT JOIN edi.`value` ev5 ON ev5.type_id = eif5.feature AND so.s5 = ev5.type_value - LEFT JOIN edi.`value` ev6 ON ev6.type_id = eif6.feature AND so.s6 = ev6.type_value + AND eif6.presentation_order = 6 + AND eif6.expiry_date IS NULL + LEFT JOIN edi.`value` ev1 ON ev1.type_id = eif1.feature + AND so.s1 = ev1.type_value + LEFT JOIN edi.`value` ev2 ON ev2.type_id = eif2.feature + AND so.s2 = ev2.type_value + LEFT JOIN edi.`value` ev3 ON ev3.type_id = eif3.feature + AND so.s3 = ev3.type_value + LEFT JOIN edi.`value` ev4 ON ev4.type_id = eif4.feature + AND so.s4 = ev4.type_value + LEFT JOIN edi.`value` ev5 ON ev5.type_id = eif5.feature + AND so.s5 = ev5.type_value + LEFT JOIN edi.`value` ev6 ON ev6.type_id = eif6.feature + AND so.s6 = ev6.type_value ORDER BY Price; DROP TEMPORARY TABLE tmp; @@ -9068,11 +9291,11 @@ proc: BEGIN LEFT JOIN vn.tag t6 ON t6.ediTypeFk = o.ef6 AND t6.overwrite = 'size' JOIN vn.floramondoConfig fc ON TRUE WHERE (t1.id IS NOT NULL AND CONVERT(s1Value, UNSIGNED) > fc.itemMaxSize) - OR(t2.id IS NOT NULL AND CONVERT(s2Value, UNSIGNED) > fc.itemMaxSize) - OR(t3.id IS NOT NULL AND CONVERT(s3Value, UNSIGNED) > fc.itemMaxSize) - OR(t4.id IS NOT NULL AND CONVERT(s4Value, UNSIGNED) > fc.itemMaxSize) - OR(t5.id IS NOT NULL AND CONVERT(s5Value, UNSIGNED) > fc.itemMaxSize) - OR(t6.id IS NOT NULL AND CONVERT(s6Value, UNSIGNED) > fc.itemMaxSize); + OR (t2.id IS NOT NULL AND CONVERT(s2Value, UNSIGNED) > fc.itemMaxSize) + OR (t3.id IS NOT NULL AND CONVERT(s3Value, UNSIGNED) > fc.itemMaxSize) + OR (t4.id IS NOT NULL AND CONVERT(s4Value, UNSIGNED) > fc.itemMaxSize) + OR (t5.id IS NOT NULL AND CONVERT(s5Value, UNSIGNED) > fc.itemMaxSize) + OR (t6.id IS NOT NULL AND CONVERT(s6Value, UNSIGNED) > fc.itemMaxSize); START TRANSACTION; @@ -9092,22 +9315,24 @@ proc: BEGIN AND i.quality <=> o.Quality JOIN vn.itemType it ON it.id = i.typeFk LEFT JOIN vn.sale s ON s.itemFk = i.id - LEFT JOIN vn.ticket t ON t.id = s.ticketFk AND t.shipped > TIMESTAMPADD(WEEK, -1, util.VN_CURDATE()) + LEFT JOIN vn.ticket t ON t.id = s.ticketFk + AND t.shipped > (util.VN_CURDATE() - INTERVAL 1 WEEK) LEFT JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk LEFT JOIN edi.deliveryInformation di ON di.supplyResponseID = sr.ID - LEFT JOIN edi.putOrder po ON po.supplyResponseID = i.supplyResponseFk AND po.OrderTradeLineDateTime > TIMESTAMPADD(WEEK, -1, util.VN_CURDATE()) + LEFT JOIN edi.putOrder po ON po.supplyResponseID = i.supplyResponseFk + AND po.OrderTradeLineDateTime > (util.VN_CURDATE() - INTERVAL 1 WEEK) SET i.supplyResponseFk = o.srID - WHERE ( sr.ID IS NULL - OR sr.NumberOfUnits = 0 - OR di.LatestOrderDateTime < util.VN_NOW() - OR di.ID IS NULL) + WHERE (sr.ID IS NULL + OR sr.NumberOfUnits = 0 + OR di.LatestOrderDateTime < util.VN_NOW() + OR di.ID IS NULL) AND it.isInventory AND t.id IS NULL AND po.id IS NULL; - -- select util.VN_NOW(),'Antes de crear ITO'; - DROP TEMPORARY TABLE IF EXISTS itemToInsert; - CREATE TEMPORARY TABLE itemToInsert ENGINE = MEMORY - SELECT o.*, CAST(NULL AS DECIMAL(6,0)) as itemFk + + CREATE OR REPLACE TEMPORARY TABLE itemToInsert + ENGINE = MEMORY + SELECT o.*, CAST(NULL AS DECIMAL(6,0)) itemFk FROM edi.offer o LEFT JOIN vn.item i ON i.supplyResponseFk = o.srId WHERE i.id IS NULL @@ -9122,7 +9347,7 @@ proc: BEGIN FETCH cur2 INTO vSupplyResponseFk; FETCH cur1 INTO vFreeId; - IF done THEN + IF vDone THEN LEAVE read_loop; END IF; @@ -9145,32 +9370,34 @@ proc: BEGIN intrastatFk, originFk, supplyResponseFk, - numberOfItemsPerCask, - embalageCode, - quality, - isFloramondo) - SELECT iti.itemFk, + numberOfItemsPerCask, + embalageCode, + quality, + isFloramondo) + SELECT iti.itemFk, iti.product_name, iti.product_name, - iti.company_name, + iti.company_name, iti.expenseFk, iti.itemTypeFk, iti.intrastatFk, iti.originFk, iti.`srId`, iti.NumberOfItemsPerCask, - iti.EmbalageCode, - iti.Quality, - TRUE + iti.EmbalageCode, + iti.Quality, + TRUE FROM itemToInsert iti; + -- Inserta la foto de los articulos nuevos (prioridad alta) INSERT IGNORE INTO vn.itemImageQueue(itemFk, url) SELECT i.id, PictureReference FROM itemToInsert ii JOIN vn.item i ON i.supplyResponseFk = ii.srId - WHERE PictureReference IS NOT NULL; + WHERE PictureReference IS NOT NULL + AND i.image IS NULL; - INSERT INTO edi.log(tableName, fieldName,fieldValue) + INSERT INTO edi.`log`(tableName, fieldName,fieldValue) SELECT 'itemImageQueue','NumImagenesPtes', COUNT(*) FROM vn.itemImageQueue WHERE attempts = 0; @@ -9179,73 +9406,72 @@ proc: BEGIN INSERT IGNORE INTO vn.tag (name, ediTypeFk) SELECT description, type_id FROM edi.type; + -- Desabilita el trigger para recalcular los tags al final + SET @isTriggerDisabled = TRUE; + -- Inserta los tags sólo en los articulos nuevos - - -- desabilita el trigger para recalcular los tags al final - SET @isTriggerDisabled = TRUE; - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) SELECT i.id, t.id , ii.product_name, 1 FROM itemToInsert ii JOIN vn.tag t ON t.`name` = 'Producto' JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT ISNULL(ii.product_name); + WHERE NOT ii.product_name IS NULL; INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) SELECT i.id, t.id , ii.Quality, 3 FROM itemToInsert ii JOIN vn.tag t ON t.`name` = 'Calidad' JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT ISNULL(ii.Quality); + WHERE NOT ii.Quality IS NULL; INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) SELECT i.id, t.id , ii.company_name, 4 FROM itemToInsert ii JOIN vn.tag t ON t.`name` = 'Productor' JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT ISNULL(ii.company_name); + WHERE NOT ii.company_name IS NULL; INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) SELECT i.id, t.id , s1Value, 5 FROM itemToInsert ii JOIN vn.tag t ON t.ediTypeFk = ii.ef1 JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT ISNULL(s1Value); + WHERE NOT s1Value IS NULL; INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) SELECT i.id, t.id , s2Value, 6 FROM itemToInsert ii JOIN vn.tag t ON t.ediTypeFk = ii.ef2 JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT ISNULL(s2Value); + WHERE NOT s2Value IS NULL; INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) SELECT i.id, t.id , s3Value, 7 FROM itemToInsert ii JOIN vn.tag t ON t.ediTypeFk = ii.ef3 JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT ISNULL(s3Value); + WHERE NOT s3Value IS NULL; INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) SELECT i.id, t.id , s4Value, 8 FROM itemToInsert ii JOIN vn.tag t ON t.ediTypeFk = ii.ef4 JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT ISNULL(s4Value); + WHERE NOT s4Value IS NULL; INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) SELECT i.id, t.id , s5Value, 9 FROM itemToInsert ii JOIN vn.tag t ON t.ediTypeFk = ii.ef5 JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT ISNULL(s5Value); + WHERE NOT s5Value IS NULL; INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) SELECT i.id, t.id , s6Value, 10 FROM itemToInsert ii JOIN vn.tag t ON t.ediTypeFk = ii.ef6 JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT ISNULL(s6Value); + WHERE NOT s6Value IS NULL; INSERT IGNORE INTO vn.itemTag(itemFk, tagFk, value, priority) SELECT i.id, t.id, IFNULL(ink.name, ik.color), 11 @@ -9253,31 +9479,21 @@ proc: BEGIN JOIN vn.item i ON i.supplyResponseFk = ii.`srId` JOIN vn.tag t ON t.`name` = 'Color' LEFT JOIN edi.feature f ON f.item_id = ii.Item_ArticleCode - LEFT JOIN edi.`type` tp ON tp.type_id = f.feature_type_id AND tp.`description` = 'Hoofdkleur 1' + LEFT JOIN edi.`type` tp ON tp.type_id = f.feature_type_id + AND tp.`description` = 'Hoofdkleur 1' LEFT JOIN vn.ink ON ink.dutchCode = f.feature_value LEFT JOIN vn.itemInk ik ON ik.longName = i.longName WHERE ink.name IS NOT NULL OR ik.color IS NOT NULL; - UPDATE vn.item i - JOIN itemToInsert ii ON i.supplyResponseFk = ii.`srId` - JOIN vn.packaging p ON p.id LIKE ii.EmbalageCode -- AND hasCompressionVariations - JOIN vn.itemTag it ON it.itemFk = i.id - LEFT JOIN vn.tag tSize ON tSize.overwrite = 'size' AND tSize.id = it.tagFk - JOIN vn.volumeConfig vc - SET i.packingOut = IFNULL(vc.standardFlowerBox * 1000 - * ii.NumberOfItemsPerCask - / (p.width * p.depth * IFNULL(p.height, it.value )),ii.NumberOfItemsPerCask); - - DROP TABLE IF EXISTS tmp.item; - CREATE TABLE tmp.item + CREATE OR REPLACE TABLE tmp.item (PRIMARY KEY (id)) SELECT i.id FROM vn.item i JOIN itemToInsert ii ON i.supplyResponseFk = ii.`srId`; CALL vn.item_refreshTags(); - SET @isTriggerDisabled = FALSE; + DROP TABLE tmp.item; SELECT MIN(LatestDeliveryDateTime) INTO vLanded FROM edi.supplyResponse sr @@ -9285,7 +9501,10 @@ proc: BEGIN JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID JOIN vn.floramondoConfig fc WHERE mp.isLatestOrderDateTimeRelevant - AND di.LatestOrderDateTime > IF(fc.MaxLatestOrderHour > HOUR(util.VN_NOW()), util.VN_CURDATE(), TIMESTAMPADD(DAY,1,util.VN_CURDATE())); + AND di.LatestOrderDateTime > IF( + fc.MaxLatestOrderHour > HOUR(util.VN_NOW()), + util.VN_CURDATE(), + util.VN_CURDATE() + INTERVAL 1 DAY); UPDATE vn.floramondoConfig SET nextLanded = vLanded @@ -9300,7 +9519,7 @@ proc: BEGIN LEFT JOIN edi.supplyResponse sr ON i.supplyResponseFk = sr.ID LEFT JOIN edi.deliveryInformation di ON di.ID = b.deliveryFk SET b.quantity = 0 - WHERE (IFNULL(di.LatestOrderDateTime,util.VN_NOW()) <= util.VN_NOW() + WHERE (IFNULL(di.LatestOrderDateTime,util.VN_NOW()) <= util.VN_NOW() OR i.supplyResponseFk IS NULL OR sr.NumberOfUnits = 0) AND am.name = 'LOGIFLORA' @@ -9308,19 +9527,20 @@ proc: BEGIN -- Localiza las entradas de cada almacen UPDATE edi.warehouseFloramondo - SET entryFk = vn.entry_getForLogiflora(TIMESTAMPADD(DAY,travellingDays,vLanded), warehouseFk); + SET entryFk = vn.entry_getForLogiflora(vLanded + INTERVAL travellingDays DAY, warehouseFk); IF vLanded IS NOT NULL THEN - -- actualiza la oferta existente + -- Actualiza la oferta existente UPDATE vn.buy b - JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk - JOIN vn.item i ON i.id = b.itemFk - JOIN edi.offer o ON i.supplyResponseFk = o.`srId` + JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk + JOIN vn.item i ON i.id = b.itemFk + JOIN edi.offer o ON i.supplyResponseFk = o.`srId` SET b.quantity = o.NumberOfUnits * o.NumberOfItemsPerCask, b.buyingValue = o.price - WHERE (b.quantity <> o.NumberOfUnits * o.NumberOfItemsPerCask OR b.buyingValue <> o.price); + WHERE (b.quantity <> o.NumberOfUnits * o.NumberOfItemsPerCask + OR b.buyingValue <> o.price); - -- Se inserta el resto + -- Inserta el resto SET vLastInserted := util.VN_NOW(); -- Inserta la oferta @@ -9334,67 +9554,67 @@ proc: BEGIN groupingMode, packageFk, deliveryFk) - - SELECT wf.entryFk, + SELECT wf.entryFk, i.id, - o.NumberOfUnits * o.NumberOfItemsPerCask as quantity, + o.NumberOfUnits * o.NumberOfItemsPerCask quantity, o.Price, - o.NumberOfUnits as etiquetas, - o.NumberOfItemsPerCask as packing, - GREATEST(1, IFNULL(o.MinimumQuantity,0)) * o.NumberOfItemsPerCask as `grouping`, + o.NumberOfUnits etiquetas, + o.NumberOfItemsPerCask packing, + GREATEST(1, IFNULL(o.MinimumQuantity,0)) * o.NumberOfItemsPerCask `grouping`, 2, -- Obliga al Packing o.embalageCode, o.diId FROM edi.offer o JOIN vn.item i ON i.supplyResponseFk = o.srId JOIN edi.warehouseFloramondo wf - JOIN vn.packaging p ON p.id LIKE o.embalageCode - LEFT JOIN vn.buy b ON b.itemFk = i.id AND b.entryFk = wf.entryFk - WHERE ISNULL(b.id); -- llevar esta linea i mirar de crear els packages a temps real + JOIN vn.packaging p ON p.id + LIKE o.embalageCode + LEFT JOIN vn.buy b ON b.itemFk = i.id + AND b.entryFk = wf.entryFk + WHERE b.id IS NULL; -- Quitar esta linea y mirar de crear los packages a tiempo REAL DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc; - CREATE TEMPORARY TABLE tmp.buyRecalc - SELECT b.id - FROM vn.buy b - JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk - WHERE b.created >= vLastInserted; + CREATE TEMPORARY TABLE tmp.buyRecalc + SELECT b.id + FROM vn.buy b + JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk + WHERE b.created >= vLastInserted; - CALL vn.buy_recalcPrices(); + CALL vn.buy_recalcPrices(); - UPDATE edi.offerList o - JOIN (SELECT v.name, COUNT(DISTINCT b.itemFk) total - FROM vn.buy b - JOIN vn.item i ON i.id = b.itemFk - JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk - JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID - JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk - JOIN vn.warehouse w ON w.id = wf.warehouseFk - WHERE w.name = 'VNH' - AND b.quantity > 0 - GROUP BY sr.vmpID) sub ON o.supplier = sub.name - SET o.vnh = sub.total; - - UPDATE edi.offerList o - JOIN (SELECT v.name, COUNT(DISTINCT b.itemFk) total - FROM vn.buy b - JOIN vn.item i ON i.id = b.itemFk - JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk - JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID - JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk - JOIN vn.warehouse w ON w.id = wf.warehouseFk - WHERE w.name = 'ALGEMESI' - AND b.quantity > 0 - GROUP BY sr.vmpID) sub ON o.supplier = sub.name - SET o.algemesi = sub.total; + UPDATE edi.offerList o + JOIN (SELECT v.name, COUNT(DISTINCT b.itemFk) total + FROM vn.buy b + JOIN vn.item i ON i.id = b.itemFk + JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk + JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID + JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk + JOIN vn.warehouse w ON w.id = wf.warehouseFk + WHERE w.name = 'VNH' + AND b.quantity > 0 + GROUP BY sr.vmpID) sub ON o.supplier = sub.name + SET o.vnh = sub.total; + UPDATE edi.offerList o + JOIN (SELECT v.name, COUNT(DISTINCT b.itemFk) total + FROM vn.buy b + JOIN vn.item i ON i.id = b.itemFk + JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk + JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID + JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk + JOIN vn.warehouse w ON w.id = wf.warehouseFk + WHERE w.name = 'ALGEMESI' + AND b.quantity > 0 + GROUP BY sr.vmpID) sub ON o.supplier = sub.name + SET o.algemesi = sub.total; END IF; DROP TEMPORARY TABLE edi.offer, itemToInsert; - DROP TABLE tmp.item; + SET @isTriggerDisabled = FALSE; COMMIT; @@ -9409,8 +9629,21 @@ proc: BEGIN WHERE i.longName LIKE 'Rosa ec %' AND typeFk = 17; - INSERT INTO edi.log(tableName, fieldName,fieldValue) - VALUES('floramondo_offerRefresh','Tiempo de proceso',TIMEDIFF(util.VN_NOW(),vStartingTime)); + -- Refresca las fotos de los items existentes que mostramos (prioridad baja) + INSERT IGNORE INTO vn.itemImageQueue(itemFk, url, priority) + SELECT i.id, sr.PictureReference, 100 + FROM edi.supplyResponse sr + JOIN vn.item i ON i.supplyResponseFk = sr.ID + JOIN edi.supplyOffer so ON so.srId = sr.ID + JOIN hedera.image i2 ON i2.name = i.image + AND i2.collectionFk = 'catalog' + WHERE i2.updated <= (UNIX_TIMESTAMP(util.VN_NOW()) - vDayRange) + AND sr.NumberOfUnits; + + INSERT INTO edi.`log` + SET tableName = 'floramondo_offerRefresh', + fieldName = 'Tiempo de proceso', + fieldValue = TIMEDIFF(util.VN_NOW(), vStartingTime); DO RELEASE_LOCK('edi.floramondo_offerRefresh'); END ;; @@ -9468,11 +9701,11 @@ 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 = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getNewByEkt`(vEktFk INT, OUT vItemFk INT) BEGIN @@ -9485,11 +9718,11 @@ BEGIN START TRANSACTION; - SELECT MIN(id) id INTO vItemFk - FROM edi.item_free; + SELECT MIN(id) id INTO vItemFk + FROM edi.item_free; - DELETE FROM edi.item_free - WHERE id = vItemFk; + DELETE FROM edi.item_free + WHERE id = vItemFk; COMMIT; @@ -9499,30 +9732,29 @@ BEGIN FROM vn.item i; END IF; - - INSERT INTO vn.item(id, - `name`, - longName, - subName, - expenceFk, - typeFk, - intrastatFk, - originFk, - numberOfItemsPerCask, - embalageCode, - quality, - isFloramondo) + `name`, + longName, + subName, + expenceFk, + typeFk, + intrastatFk, + originFk, + numberOfItemsPerCask, + embalageCode, + quality, + isFloramondo + ) SELECT vItemFk, e.item, e.item, e.item, - igto.expenseFk , - igto.itemTypeFk , - igto.intrastatFk , + igto.expenseFk, + igto.itemTypeFk, + igto.intrastatFk, igto.originFk, e.pac, - least(IF((e.package = 800),((e.package * 10) + e.pac), e.package), ifnull(idt.bucket_id, '999')) packageFk, + least(IF((e.package = 800),((e.package * 10) + e.pac), e.package), IFNULL(idt.bucket_id, '999')) packageFk, e.cat, TRUE FROM edi.ekt e @@ -9650,6 +9882,14 @@ BEGIN SET @isTriggerDisabled = FALSE; + INSERT IGNORE INTO vn.itemImageQueue(itemFk, url) + SELECT vItemFk, sr.PictureReference + FROM edi.ekt e + JOIN edi.supplyResponse sr ON e.ref = sr.Item_ArticleCode + WHERE e.id = vEktFk + AND NOT sr.PictureReference IS NULL + ORDER BY sr.created DESC + LIMIT 1; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -9709,72 +9949,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticket_calcCompByFloramondo` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_calcCompByFloramondo`(vSelf INT) -BEGIN - - /** - * Recalcula "a pelo" los componentes para un ticket de Floramondo - * - * Pendiente de concretar la solución cuando Logiflora conteste. - * - * @param vSelf Identificador de vn.ticket - */ - - CALL cache.last_buy_refresh(TRUE); - - DELETE sc.* - FROM vn.saleComponent sc - JOIN vn.sale s ON s.id = sc.saleFk - WHERE s.ticketFk = vSelf; - - UPDATE vn.sale s - JOIN vn.item i ON i.id = s.itemFk - JOIN edi.floraHollandConfig fhc - LEFT JOIN cache.last_buy lb ON lb.item_id = i.id - LEFT JOIN vn.buy b ON b.id = lb.buy_id - LEFT JOIN vn.warehouse w ON w.id = lb.warehouse_id AND w.name = 'Floramondo' - SET s.price = b.buyingValue * (1 + fhc.floramondoMargin) - WHERE s.ticketFk = vSelf; - - INSERT INTO vn.saleComponent(saleFk, componentFk, value) - SELECT s.id, c.id, MAX(b.buyingValue) - FROM vn.sale s - JOIN vn.item i ON i.id = s.itemFk - LEFT JOIN cache.last_buy lb ON lb.item_id = i.id - LEFT JOIN vn.buy b ON b.id = lb.buy_id - LEFT JOIN vn.warehouse w ON w.id = lb.warehouse_id AND w.name = 'Floramondo' - JOIN vn.component c ON c.code = 'purchaseValue' - WHERE s.ticketFk = vSelf - GROUP BY s.id; - - INSERT INTO vn.saleComponent(saleFk, componentFk, value) - SELECT s.id, c.id, MAX(b.buyingValue) * fhc.floramondoMargin - FROM vn.sale s - JOIN vn.item i ON i.id = s.itemFk - JOIN edi.floraHollandConfig fhc - LEFT JOIN cache.last_buy lb ON lb.item_id = i.id - LEFT JOIN vn.buy b ON b.id = lb.buy_id - LEFT JOIN vn.warehouse w ON w.id = lb.warehouse_id AND w.name = 'Floramondo' - JOIN vn.component c ON c.code = 'margin' - WHERE s.ticketFk = vSelf - GROUP BY s.id; - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -- -- Current Database: `hedera` @@ -9799,24 +9973,6 @@ CREATE TABLE `androidUser` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `basketOrder` --- - -DROP TABLE IF EXISTS `basketOrder`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `basketOrder` ( - `clientFk` int(11) NOT NULL, - `orderFk` int(10) unsigned NOT NULL, - PRIMARY KEY (`orderFk`,`clientFk`), - UNIQUE KEY `customer_id` (`clientFk`), - CONSTRAINT `basketOrder_ibfk_1` FOREIGN KEY (`orderFk`, `clientFk`) REFERENCES `order` (`id`, `customer_id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `basketOrder_ibfk_2` FOREIGN KEY (`orderFk`) REFERENCES `order` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `basketOrder_ibfk_3` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `browser` -- @@ -9882,7 +10038,7 @@ CREATE TABLE `image` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `collectionFk` varchar(50) NOT NULL, `name` varchar(255) NOT NULL, - `updated` int(11) DEFAULT NULL, + `updated` bigint(20) unsigned DEFAULT NULL, `nRefs` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Number of references, don''t modify this column manually', PRIMARY KEY (`id`), UNIQUE KEY `collection` (`collectionFk`,`name`), @@ -10196,27 +10352,6 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `myBasket` --- - -DROP TABLE IF EXISTS `myBasket`; -/*!50001 DROP VIEW IF EXISTS `myBasket`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `myBasket` ( - `id` tinyint NOT NULL, - `made` tinyint NOT NULL, - `sent` tinyint NOT NULL, - `clientFk` tinyint NOT NULL, - `deliveryMethodFk` tinyint NOT NULL, - `agencyModeFk` tinyint NOT NULL, - `addressFk` tinyint NOT NULL, - `companyFk` tinyint NOT NULL, - `notes` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - -- -- Temporary table structure for view `myBasketDefaults` -- @@ -10233,24 +10368,6 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `myBasketItem` --- - -DROP TABLE IF EXISTS `myBasketItem`; -/*!50001 DROP VIEW IF EXISTS `myBasketItem`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `myBasketItem` ( - `id` tinyint NOT NULL, - `orderFk` tinyint NOT NULL, - `warehouseFk` tinyint NOT NULL, - `itemFk` tinyint NOT NULL, - `amount` tinyint NOT NULL, - `price` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - -- -- Temporary table structure for view `myClient` -- @@ -10310,18 +10427,21 @@ SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `myOrder` ( `id` tinyint NOT NULL, - `landed` tinyint NOT NULL, + `sent` tinyint NOT NULL, `clientFk` tinyint NOT NULL, `deliveryMethodFk` tinyint NOT NULL, `agencyModeFk` tinyint NOT NULL, `addressFk` tinyint NOT NULL, `companyFk` tinyint NOT NULL, - `note` tinyint NOT NULL, + `notes` tinyint NOT NULL, `sourceApp` tinyint NOT NULL, `isConfirmed` tinyint NOT NULL, `created` tinyint NOT NULL, `firstRowStamp` tinyint NOT NULL, - `confirmed` tinyint NOT NULL + `confirmed` tinyint NOT NULL, + `taxableBase` tinyint NOT NULL, + `tax` tinyint NOT NULL, + `total` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; @@ -10335,7 +10455,7 @@ SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `myOrderRow` ( `id` tinyint NOT NULL, - `Fk` tinyint NOT NULL, + `orderFk` tinyint NOT NULL, `itemFk` tinyint NOT NULL, `warehouseFk` tinyint NOT NULL, `shipped` tinyint NOT NULL, @@ -10595,6 +10715,7 @@ CREATE TABLE `order` ( `taxableBase` decimal(10,2) NOT NULL, `tax` decimal(10,2) NOT NULL, `total` decimal(10,2) NOT NULL, + `configured` datetime DEFAULT NULL, PRIMARY KEY (`id`), KEY `address` (`address_id`), KEY `delivery_method` (`delivery_method_id`), @@ -10986,7 +11107,7 @@ CREATE TABLE `shelfConfig` ( KEY `shelf_id` (`shelf`), KEY `family_id` (`family`), KEY `warehouse_id` (`warehouse`), - CONSTRAINT `shelfConfig_ibfk_1` FOREIGN KEY (`family`) REFERENCES `vn`.`itemType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `shelfConfig_ibfk_1` FOREIGN KEY (`family`) REFERENCES `vn`.`itemType` (`id`), CONSTRAINT `shelfConfig_ibfk_2` FOREIGN KEY (`shelf`) REFERENCES `shelf` (`id`) ON UPDATE CASCADE, CONSTRAINT `shelfConfig_ibfk_3` FOREIGN KEY (`warehouse`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -11196,7 +11317,7 @@ CREATE TABLE `tpvTransaction` ( CONSTRAINT `receipt_id` FOREIGN KEY (`receiptFk`) REFERENCES `vn`.`receipt` (`Id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `tpvTransaction_ibfk_1` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `tpvTransaction_ibfk_2` FOREIGN KEY (`merchantFk`) REFERENCES `tpvMerchant` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Transactions realized through the virtual TPV'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Transactions realized through the virtual TPV'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11315,7 +11436,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `order_doRecalc` ON SCHEDULE EVERY 10 SECOND STARTS '2019-08-29 14:18:04' ON COMPLETION PRESERVE DISABLE ON SLAVE DO CALL order_doRecalc */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `order_doRecalc` ON SCHEDULE EVERY 10 SECOND STARTS '2019-08-29 14:18:04' ON COMPLETION PRESERVE ENABLE DO CALL order_doRecalc */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -11327,31 +11448,6 @@ DELIMITER ; -- -- Dumping routines for database 'hedera' -- -/*!50003 DROP FUNCTION IF EXISTS `myBasket_getId` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `myBasket_getId`() RETURNS int(11) - DETERMINISTIC -BEGIN - DECLARE vOrder INT; - - SELECT orderFk INTO vOrder FROM basketOrder - WHERE clientFk = account.myUser_getId(); - - RETURN vOrder; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP FUNCTION IF EXISTS `myClient_getDebt` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -11370,7 +11466,7 @@ BEGIN * * @return Saldo del cliente */ - RETURN vn.clientGetDebt(account.myUser_getId(), vDate); + RETURN vn.client_getDebt(account.myUser_getId(), vDate); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -11515,58 +11611,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `catalog_calcFromMyAddress_beta` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_calcFromMyAddress_beta`(vDelivery DATE, vAddress INT) -BEGIN -/** - * Gets the available items list. - * - * @param vDelivery Delivery date - * @param vAddress Address id - * @return tmp.ticketCalculateItem - * @return tmp.ticketComponentPrice - * @return tmp.ticketComponent - * @return tmp.ticketLot - * @return tmp.zoneGetShipped - */ - DECLARE vAgencyMode INT; - - SELECT a.agencyModeFk - INTO vAgencyMode - FROM myClient c - JOIN vn.address a ON a.clientFk = c.id - WHERE a.id = vAddress; - - CALL vn.available_calc(vDelivery, vAddress, vAgencyMode); - - DROP TEMPORARY TABLE IF EXISTS tmp.item; - CREATE TEMPORARY TABLE tmp.item - (INDEX (itemFk)) - ENGINE = MEMORY - SELECT c.item_id itemFk - FROM `cache`.available c - JOIN tmp.availableCalc a ON a.calcFk = c.calc_id - WHERE c.available > 0 - GROUP BY c.item_id; - - CALL vn.catalog_calculate_beta(vDelivery, vAddress, vAgencyMode); - - DROP TEMPORARY TABLE tmp.item; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `image_ref` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -11595,7 +11639,7 @@ proc: BEGIN INSERT INTO `image` SET `collectionFk` = vCollection, `name` = vName, - `updated` = UNIX_TIMESTAMP(), + `updated` = util.VN_UNIX_TIMESTAMP(), `nRefs` = 1 ON DUPLICATE KEY UPDATE `nRefs` = nRefs + 1; @@ -11861,7 +11905,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `myBasket_addItem` */; +/*!50003 DROP PROCEDURE IF EXISTS `myOrder_addItem` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -11871,19 +11915,21 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_addItem`( +CREATE DEFINER=`root`@`localhost` PROCEDURE `myOrder_addItem`( + vSelf INT, vWarehouse INT, - vItem INT, - vAmount INT) + vItem INT, + vAmount INT) BEGIN - CALL order_addItem(myBasket_getId(), vWarehouse, vItem, vAmount); + CALL myOrder_checkMine(vSelf); + CALL order_addItem(vSelf, vWarehouse, vItem, vAmount); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `myBasket_calcCatalogFromItem` */; +/*!50003 DROP PROCEDURE IF EXISTS `myOrder_calcCatalogFromItem` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -11893,11 +11939,11 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_calcCatalogFromItem`(vItem INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `myOrder_calcCatalogFromItem`(vSelf INT, vItem INT) BEGIN /** * Gets the availability and prices for the given item - * using current user basket parameters. + * using current user order parameters. * * @table tmp.item(itemFk) * @return tmp.ticketCalculateItem @@ -11906,14 +11952,15 @@ BEGIN * @return tmp.ticketLot * @return tmp.zoneGetShipped */ - CALL order_calcCatalogFromItem(myBasket_getId(), vItem); + CALL myOrder_checkMine(vSelf); + CALL order_calcCatalogFromItem(vSelf, vItem); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `myBasket_calcCatalogFull` */; +/*!50003 DROP PROCEDURE IF EXISTS `myOrder_calcCatalogFull` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -11923,11 +11970,11 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_calcCatalogFull`() +CREATE DEFINER=`root`@`localhost` PROCEDURE `myOrder_calcCatalogFull`(vSelf INT) BEGIN /** * Gets the availability and prices for the given items - * using current user basket parameters. + * using current user order parameters. * * @table tmp.item(itemFk) * @return tmp.ticketCalculateItem @@ -11936,14 +11983,15 @@ BEGIN * @return tmp.ticketLot * @return tmp.zoneGetShipped */ - CALL order_calcCatalogFull(myBasket_getId()); + CALL myOrder_checkMine(vSelf); + CALL order_calcCatalogFull(vSelf); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `myBasket_check` */; +/*!50003 DROP PROCEDURE IF EXISTS `myOrder_checkConfig` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -11953,8 +12001,8 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_check`() -BEGIN +CREATE DEFINER=`root`@`localhost` PROCEDURE `myOrder_checkConfig`(vSelf INT) +proc: BEGIN /** * Comprueba que la cesta esta creada y que su configuración es * correcta. Si la configuración es correcta pero lleva mucho @@ -11962,36 +12010,15 @@ BEGIN * * @select El id del pedido y el estado de la cesta */ - DECLARE vSelf INT; - DECLARE vCreated DATETIME; - DECLARE vStatus VARCHAR(15) DEFAULT 'OK'; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vStatus = 'NOT_EXISTS'; - DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET vStatus = 'BAD_CONFIG'; - - SELECT id, made - INTO vSelf, vCreated - FROM myBasket; - - IF vStatus = 'OK' - THEN - CALL order_checkConfig(vSelf); - - IF vStatus = 'OK' AND vCreated < TIMESTAMPADD(DAY, -1, util.VN_NOW()) - THEN - CALL order_update(vSelf); - SET vStatus = 'UPDATED'; - END IF; - END IF; - - SELECT vStatus stat; + CALL myOrder_checkMine(vSelf); + CALL order_checkConfig(vSelf); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `myBasket_configure` */; +/*!50003 DROP PROCEDURE IF EXISTS `myOrder_checkMine` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -12001,86 +12028,77 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_configure`( +CREATE DEFINER=`root`@`localhost` PROCEDURE `myOrder_checkMine`(vSelf INT) +proc: BEGIN +/** + * Check that order is owned by current user, otherwise throws an error. + * + * @param vSelf The order id + */ + DECLARE vIsMine BOOL; + + SELECT COUNT(*) > 0 INTO vIsMine + FROM `order` + WHERE id = vSelf + AND customer_id = account.myUser_getId(); + + IF NOT vIsMine THEN + CALL util.throw('orderNotOwnedByUser'); + END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `myOrder_configure` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `myOrder_configure`( + vSelf INT, vDelivery DATE, vDeliveryMethod VARCHAR(45), vAgency INT, vAddress INT) BEGIN /** - * Configura la cesta de la compra utilizando los parámetros pasados. Si los - * parámetros no son válidos devuelve un error. + * Creates an order with passed parameters. If passed parameters are wrong + * it returns an error. * - * @param vDelivery Fecha de recogida - * @param vAgency Id de la agencia - * @param vAddress Id de dirección de envío, @NULL si es recogida + * @param vSelf The order id + * @param vDelivery Delivery date + * @param vDeliveryMethod Delivery method code + * @param vAgency Agency id + * @param vAddress Address id, @NULL for pickup */ - DECLARE vSelf INT; - DECLARE vCompany INT; - DECLARE vDeliveryMethodId INT; + CALL myOrder_checkMine(vSelf); - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vSelf = NULL; - DECLARE EXIT HANDLER FOR SQLSTATE '45000' - BEGIN - ROLLBACK; - RESIGNAL; - END; - - START TRANSACTION; - - SELECT id INTO vDeliveryMethodId - FROM vn.deliveryMethod - WHERE code = vDeliveryMethod; - - IF vDeliveryMethod = 'PICKUP' AND vAddress IS NULL THEN - SELECT defaultAddressFk INTO vAddress - FROM myClient; + IF vAddress IS NOT NULL + AND NOT (SELECT COUNT(*) FROM myAddress WHERE id = vAddress) THEN + CALL util.throw('addressNotOwnedByUser'); END IF; - SET vSelf = myBasket_getId(); - - IF vSelf IS NULL THEN - SELECT defaultCompanyFk INTO vCompany - FROM orderConfig; - - INSERT INTO `order` - SET - customer_id = account.myUser_getId(), - date_send = vDelivery, - delivery_method_id = vDeliveryMethodId, - agency_id = vAgency, - address_id = vAddress, - source_app = 'WEB', - company_id = vCompany; - - SET vSelf = LAST_INSERT_ID(); - - INSERT INTO basketOrder SET - clientFk = account.myUser_getId(), - orderFk = vSelf; - ELSE - UPDATE `order` - SET - date_send = vDelivery, - delivery_method_id = vDeliveryMethodId, - agency_id = vAgency, - address_id = vAddress - WHERE - id = vSelf; - - CALL order_update(vSelf); - END IF; - - CALL order_checkConfig(vSelf); - - COMMIT; + CALL order_configure( + vSelf, + vDelivery, + vDeliveryMethod, + vAgency, + vAddress + ); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `myBasket_configureForGuest` */; +/*!50003 DROP PROCEDURE IF EXISTS `myOrder_configureForGuest` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -12090,7 +12108,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_configureForGuest`() +CREATE DEFINER=`root`@`localhost` PROCEDURE `myOrder_configureForGuest`(OUT vSelf INT) BEGIN DECLARE vMethod VARCHAR(255); DECLARE vAgency INT; @@ -12109,119 +12127,28 @@ BEGIN SET vDate = TIMESTAMPADD(DAY, 7 - WEEKDAY(vDate), vDate); END IF; - CALL myBasket_configure(vDate, vMethod, vAgency, vAddress); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `myBasket_confirm` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_confirm`() -BEGIN - DECLARE vSelf INT DEFAULT myBasket_getId(); - - IF vSelf IS NOT NULL THEN - CALL order_confirm(vSelf); - - DELETE FROM basketOrder - WHERE orderFk = vSelf; - END IF; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `myBasket_getAvailable` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_getAvailable`() -BEGIN -/** - * Gets the available items list. - * - * @table tmp.itemAvailable - */ - CALL order_getAvailable(myBasket_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 DROP PROCEDURE IF EXISTS `myBasket_getTax` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_getTax`() - READS SQL DATA -BEGIN -/** - * Returns the taxes for the current client basket. - * - * @treturn tmp.orderTax - */ - DROP TEMPORARY TABLE IF EXISTS tmp.`order`; - CREATE TEMPORARY TABLE tmp.`order` - ENGINE = MEMORY - SELECT myBasket_getId() orderFk; - - CALL order_getTax(); - - DROP TEMPORARY TABLE IF EXISTS tmp.`order`; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `myOrder_addItem` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `myOrder_addItem`( - vSelf INT, - vWarehouse INT, - vItem INT, - vAmount INT) -BEGIN - DECLARE vIsMine BOOL; - - SELECT COUNT(*) INTO vIsMine + SELECT id INTO vSelf FROM myOrder - WHERE id = vSelf; + WHERE NOT isConfirmed + ORDER BY id DESC + LIMIT 1; - IF vIsMine THEN - CALL order_addItem(vSelf, vWarehouse, vItem, vAmount); + IF vSelf IS NULL THEN + CALL myOrder_create( + vSelf, + vDate, + vMethod, + vAgency, + vAddress + ); + ELSE + CALL myOrder_configure( + vSelf, + vDate, + vMethod, + vAgency, + vAddress + ); END IF; END ;; DELIMITER ; @@ -12241,15 +12168,59 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myOrder_confirm`(vSelf INT) BEGIN - DECLARE vIsMine BOOL; + CALL myOrder_checkMine(vSelf); + CALL order_checkConfig(vSelf); + CALL order_confirm(vSelf); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `myOrder_create` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `myOrder_create`( + OUT vSelf INT, + vDelivery DATE, + vDeliveryMethod VARCHAR(45), + vAgency INT, + vAddress INT) +proc: BEGIN +/** + * Creates a new order for the current user. If passed parameters are wrong + * it returns an error. + * + * @param vDelivery Delivery date + * @param vDeliveryMethod Delivery method code + * @param vAgency Agency id + * @param vAddress Address id, @NULL for pickup + */ + DECLARE vCompany INT; - SELECT COUNT(*) INTO vIsMine - FROM myOrder - WHERE id = vSelf; + SELECT defaultCompanyFk INTO vCompany + FROM orderConfig; - IF vIsMine THEN - CALL order_confirm(vSelf); - END IF; + INSERT INTO `order` + SET customer_id = account.myUser_getId(), + source_app = 'WEB', + company_id = vCompany; + + SET vSelf = LAST_INSERT_ID(); + CALL myOrder_configure( + vSelf, + vDelivery, + vDeliveryMethod, + vAgency, + vAddress + ); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -12274,15 +12245,42 @@ BEGIN * @param vSelf The order id * @table tmp.itemAvailable */ - DECLARE isMine BOOL; + CALL myOrder_checkMine(vSelf); + CALL order_getAvailable(vSelf); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `myOrder_getTax` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `myOrder_getTax`(vSelf INT) + READS SQL DATA +BEGIN +/** + * Returns the taxes for the current client order. + * + * @treturn tmp.orderTax + */ + CALL myOrder_checkMine(vSelf); - SELECT COUNT(*) INTO isMine - FROM myOrder - WHERE id = vSelf; + DROP TEMPORARY TABLE IF EXISTS tmp.`order`; + CREATE TEMPORARY TABLE tmp.`order` + ENGINE = MEMORY + SELECT vSelf orderFk; - IF isMine THEN - CALL order_getAvailable(vSelf); - END IF; + CALL order_getTax(); + + DROP TEMPORARY TABLE IF EXISTS tmp.`order`; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -12770,6 +12768,8 @@ BEGIN CALL order_calcCatalogFromItem(vSelf, vItem); START TRANSACTION; + CALL order_checkEditable(vSelf); + SELECT shipped INTO vShipment FROM tmp.zoneGetShipped WHERE warehouseFk = vWarehouse; @@ -12995,15 +12995,24 @@ BEGIN DECLARE vIsAvailable BOOL; DECLARE vIsActive BOOL; DECLARE vClientFk INT; + DECLARE vConfigured DATETIME; + + CALL order_checkEditable(vSelf); -- Obtiene los datos del pedido - SELECT d.code, o.date_send, o.agency_id, o.address_id - INTO vDeliveryMethod, vLanded, vAgencyMode, vAddress + SELECT d.code, o.date_send, o.agency_id, o.address_id, customer_id, configured + INTO vDeliveryMethod, vLanded, vAgencyMode, vAddress, vClientFk, vConfigured FROM `order` o JOIN vn.deliveryMethod d ON d.id = o.delivery_method_id WHERE o.id = vSelf; + -- Comprueba que no ha caducado la configuración + + IF vConfigured IS NULL OR vConfigured < TIMESTAMPADD(DAY, -1, util.VN_NOW()) THEN + CALL util.throw('orderOutdated'); + END IF; + -- Comprueba que se ha seleccionado una dirección IF vDeliveryMethod IN ('AGENCY', 'DELIVERY') AND vAddress IS NULL THEN @@ -13012,10 +13021,6 @@ BEGIN -- Comprueba que el cliente esté activo - SELECT customer_id INTO vClientFk - FROM hedera.`order` - WHERE id = vSelf; - SELECT isActive INTO vIsActive FROM vn.client WHERE id = vClientFk; @@ -13043,6 +13048,106 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `order_checkEditable` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `order_checkEditable`(vSelf INT) +BEGIN +/** + * Cheks if order is editable. + * + * @param vSelf The order id + */ + DECLARE vIsConfirmed BOOL; + + SELECT confirmed INTO vIsConfirmed + FROM `order` WHERE id = vSelf; + + IF vIsConfirmed THEN + CALL util.throw('orderConfirmed'); + END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `order_configure` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `order_configure`( + vSelf INT, + vDelivery DATE, + vDeliveryMethod VARCHAR(45), + vAgency INT, + vAddress INT) +BEGIN +/** + * Creates an order with passed parameters. If passed parameters are wrong + * it returns an error. + * + * @param vSelf The order id + * @param vDelivery Delivery date + * @param vDeliveryMethod Delivery method code + * @param vAgency Agency id + * @param vAddress Address id, @NULL for pickup + */ + DECLARE vCompany INT; + DECLARE vDeliveryMethodId INT; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vSelf = NULL; + DECLARE EXIT HANDLER FOR SQLSTATE '45000' + BEGIN + ROLLBACK; + RESIGNAL; + END; + + START TRANSACTION; + + CALL order_checkEditable(vSelf); + + SELECT id INTO vDeliveryMethodId + FROM vn.deliveryMethod + WHERE code = vDeliveryMethod; + + IF vDeliveryMethod = 'PICKUP' AND vAddress IS NULL THEN + SELECT defaultAddressFk INTO vAddress + FROM myClient; + END IF; + + UPDATE `order` + SET date_send = vDelivery, + delivery_method_id = vDeliveryMethodId, + agency_id = vAgency, + address_id = vAddress, + configured = util.VN_NOW() + WHERE + id = vSelf; + + CALL order_update(vSelf); + CALL order_checkConfig(vSelf); + + COMMIT; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `order_confirm` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -13079,13 +13184,13 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `order_confirmWithUser`(IN `vOrder` INT, IN `vUserId` INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `order_confirmWithUser`(vSelf INT, vUserId INT) BEGIN /** * Confirms an order, creating each of its tickets on the corresponding * date, store and user. * - * @param vOrder The order identifier + * @param vSelf The order identifier * @param vUser The user identifier */ DECLARE vOk BOOL; @@ -13112,15 +13217,13 @@ BEGIN DECLARE vIsLogifloraItem BOOL; DECLARE vOldQuantity INT; DECLARE vNewQuantity INT; - DECLARE vOldInstance JSON; - DECLARE vNewInstance JSON; DECLARE cDates CURSOR FOR SELECT zgs.shipped, r.warehouse_id FROM `order` o JOIN order_row r ON r.order_id = o.id LEFT JOIN tmp.zoneGetShipped zgs ON zgs.warehouseFk = r.warehouse_id - WHERE o.id = vOrder AND r.amount != 0 + WHERE o.id = vSelf AND r.amount != 0 GROUP BY r.warehouse_id; DECLARE cRows CURSOR FOR @@ -13129,7 +13232,7 @@ BEGIN JOIN vn.item i ON i.id = r.item_id WHERE r.amount != 0 AND r.warehouse_id = vWarehouse - AND r.order_id = vOrder + AND r.order_id = vSelf ORDER BY r.rate DESC; DECLARE CONTINUE HANDLER FOR NOT FOUND @@ -13148,9 +13251,9 @@ BEGIN vClientId, vCompanyId, vAgencyModeId FROM hedera.`order` o JOIN vn.address a ON a.id = o.address_id - WHERE o.id = vOrder; + WHERE o.id = vSelf; - -- Carga las fechas de salida de cada almac?n + -- Carga las fechas de salida de cada almacen CALL vn.zone_getShipped (vDelivery, vAddress, vAgencyModeId, FALSE); -- Trabajador que realiza la accion @@ -13159,25 +13262,20 @@ BEGIN END IF; START TRANSACTION; - -- Comprueba que el pedido no esta confirmado - SELECT o.confirmed INTO vIsConfirmed - FROM hedera.`order` o - WHERE o.id = vOrder - FOR UPDATE; - IF vIsConfirmed THEN - CALL util.throw ('ORDER_ALREADY_CONFIRMED'); - END IF; + CALL order_checkEditable(vSelf); + + -- Check order is not empty - -- Comprueba que el pedido no esta vacio SELECT COUNT(*) > 0 INTO vOk - FROM order_row WHERE order_id = vOrder AND amount > 0; + FROM order_row WHERE order_id = vSelf AND amount > 0; IF NOT vOk THEN CALL util.throw ('ORDER_EMPTY'); END IF; -- Crea los tickets del pedido + OPEN cDates; lDates: @@ -13201,7 +13299,7 @@ BEGIN -- AND o.agency_id = t.agencyModeFk AND o.date_send = t.landed AND vShipment = DATE(t.shipped) - WHERE o.id = vOrder + WHERE o.id = vSelf AND t.refFk IS NULL AND IFNULL(tls.alertLevel,0) = 0 LIMIT 1; @@ -13234,7 +13332,7 @@ BEGIN END IF; INSERT IGNORE INTO vn.orderTicket - SET orderFk = vOrder, + SET orderFk = vSelf, ticketFk = vTicket; -- Añade las notas @@ -13283,15 +13381,6 @@ BEGIN FROM vn.sale s WHERE id = vSale; - SET vOldInstance = JSON_OBJECT( - 'quantity', vOldQuantity - ); - SET vNewInstance = JSON_OBJECT( - 'quantity', vNewQuantity - ); - - CALL `util`.`log_addWithUser`('vn', 'ticket', - 'Sale', vTicket, vSale, 'update', vOldInstance, vNewInstance, vUserId); ELSE INSERT INTO vn.sale SET @@ -13305,18 +13394,6 @@ BEGIN SET vSale = LAST_INSERT_ID(); - SET vNewInstance = JSON_OBJECT( - 'itemFk', vItem, - 'ticketFk', vTicket, - 'concept', vConcept, - 'quantity', vAmount, - 'price', vPrice, - 'priceFixed', FALSE, - 'isPriceFixed', TRUE - ); - CALL `util`.`log_addWithUser`('vn', 'ticket', - 'Sale', vTicket, vSale, 'insert', NULL, vNewInstance, vUserId); - INSERT INTO vn.saleComponent (saleFk, componentFk, `value`) SELECT vSale, cm.component_id, cm.price @@ -13364,7 +13441,7 @@ BEGIN JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk LEFT JOIN edi.clientFHAdminNumber ca ON ca.clientFk = vClientId JOIN edi.floraHollandConfig fhc - JOIN hedera.`order` o ON o.id = vOrder + JOIN hedera.`order` o ON o.id = vSelf WHERE i.id = vItem AND di.LatestOrderDateTime > util.VN_NOW() AND vAmount > @available @@ -13398,10 +13475,8 @@ BEGIN CLOSE cDates; - DELETE FROM basketOrder WHERE orderFk = vOrder; - UPDATE `order` SET confirmed = TRUE, confirm_date = util.VN_NOW() - WHERE id = vOrder; + WHERE id = vSelf; COMMIT; END ;; @@ -14038,6 +14113,72 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `tpvTransaction_confirmFromExport` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `tpvTransaction_confirmFromExport`() +BEGIN +/** + * Confirms multiple transactions comming from Redsys "canales" exported CSV. + * + * @table tmp.transactions(id, isAuthorization, amount) The list of exported transactions + */ + DECLARE vDone BOOL; + DECLARE vTransactionId INT; + DECLARE vAmount INT; + DECLARE vConfirmedAmount INT; + + DECLARE cur CURSOR FOR + SELECT * FROM tPendingTransactions; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + CREATE OR REPLACE TEMPORARY TABLE tPendingTransactions + ENGINE = MEMORY + SELECT t.id, t.amount, tt.amount confirmedAmount + FROM tmp.transactions t + JOIN hedera.tpvTransaction tt ON tt.id = t.id + WHERE t.isAuthorization + AND tt.response IS NULL; + + OPEN cur; + + l: LOOP + SET vDone = FALSE; + FETCH cur INTO vTransactionId, vAmount, vConfirmedAmount; + + IF vDone THEN + LEAVE l; + END IF; + + IF NOT (vAmount <=> vConfirmedAmount) THEN + CALL util.throw(CONCAT( + 'Transaction ', vTransactionId ,', source amount "', vAmount , + '" does not match confirmed amount "', vConfirmedAmount ,'"' + )); + END IF; + + CALL tpvTransaction_confirmById(vTransactionId); + END LOOP; + + CLOSE cur; + + SELECT id, amount FROM tPendingTransactions; + + DROP TEMPORARY TABLE tPendingTransactions; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `tpvTransaction_end` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -15103,7 +15244,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `phone_format`(vPhone VARCHAR(255)) RETURNS varchar(255) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `phone_format`(vPhone VARCHAR(255)) RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_general_ci DETERMINISTIC BEGIN DECLARE vI INT DEFAULT 0; @@ -15307,203 +15448,19 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `postgresql` /*!40100 DEFAULT CHARACTER USE `postgresql`; -- --- Table structure for table `address` +-- Table structure for table `incometype_employee__` -- -DROP TABLE IF EXISTS `address`; +DROP TABLE IF EXISTS `incometype_employee__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `address` ( - `address_id` int(11) NOT NULL AUTO_INCREMENT, - `town_id` int(11) NOT NULL, - `address_type_id` int(11) NOT NULL, - `name` varchar(40) DEFAULT NULL, - `address1` varchar(255) DEFAULT NULL, - `number` int(11) DEFAULT NULL, - `address2` varchar(30) DEFAULT NULL, - PRIMARY KEY (`address_id`), - KEY `address_address_type_id_idx` (`address_type_id`), - KEY `address_town_id_idx` (`town_id`), - CONSTRAINT `address_ibfk_1` FOREIGN KEY (`address_type_id`) REFERENCES `address_type` (`address_type_id`) ON DELETE NO ACTION ON UPDATE CASCADE, - CONSTRAINT `address_ibfk_2` FOREIGN KEY (`town_id`) REFERENCES `townKk` (`town_id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `address_type` --- - -DROP TABLE IF EXISTS `address_type`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `address_type` ( - `address_type_id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(20) NOT NULL, - PRIMARY KEY (`address_type_id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `bank_account_type` --- - -DROP TABLE IF EXISTS `bank_account_type`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `bank_account_type` ( - `bank_account_type_id` int(11) NOT NULL AUTO_INCREMENT, - `name` char(15) DEFAULT NULL, - PRIMARY KEY (`bank_account_type_id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Temporary table structure for view `calendar_employee` --- - -DROP TABLE IF EXISTS `calendar_employee`; -/*!50001 DROP VIEW IF EXISTS `calendar_employee`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `calendar_employee` ( - `id` tinyint NOT NULL, - `businessFk` tinyint NOT NULL, - `calendar_state_id` tinyint NOT NULL, - `date` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - --- --- Table structure for table `calendar_labour_type` --- - -DROP TABLE IF EXISTS `calendar_labour_type`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `calendar_labour_type` ( - `calendar_labour_type_id` int(11) NOT NULL AUTO_INCREMENT, - `descripcion` varchar(50) DEFAULT NULL, - `pausa_remunerada` time DEFAULT NULL, - `hours_week` smallint(6) DEFAULT NULL, - `isPartial` tinyint(1) NOT NULL DEFAULT 0, - PRIMARY KEY (`calendar_labour_type_id`), - UNIQUE KEY `hours_labour_hours_labour_id_key` (`calendar_labour_type_id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `erte_COVID19` --- - -DROP TABLE IF EXISTS `erte_COVID19`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `erte_COVID19` ( - `personFk` int(11) NOT NULL, - `description` varchar(45) DEFAULT NULL, - PRIMARY KEY (`personFk`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `income_employee` --- - -DROP TABLE IF EXISTS `income_employee`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `income_employee` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `debe` decimal(10,2) NOT NULL DEFAULT 0.00, - `haber` decimal(10,2) NOT NULL DEFAULT 0.00, - `id_incomeType` int(11) DEFAULT NULL, - `odbc_date` date DEFAULT NULL, - `workerFk` int(11) unsigned NOT NULL, - `concepto` longtext DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `income_employeeId_incomeType_idx` (`id_incomeType`), - KEY `income_employee_workerFk_idx` (`workerFk`), - CONSTRAINT `income_employeeId_incomeType` FOREIGN KEY (`id_incomeType`) REFERENCES `vn2008`.`payroll_conceptos` (`conceptoid`) ON UPDATE CASCADE, - CONSTRAINT `income_employee_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `postgresql`.`income_employee_afterInsert` - AFTER INSERT ON `income_employee` - FOR EACH ROW -BEGIN - CALL vn.worker_updateBalance(NEW.workerFk,NEW.haber,NEW.debe); -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET 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 `postgresql`.`income_employee_afterUpdate` - AFTER UPDATE ON `income_employee` - FOR EACH ROW -BEGIN - CALL vn.worker_updateBalance(NEW.workerFk,-OLD.haber,-OLD.debe); - - CALL vn.worker_updateBalance(NEW.workerFk,NEW.haber,NEW.debe); -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET 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 `postgresql`.`income_employee_afterDelete` - AFTER DELETE ON `income_employee` - FOR EACH ROW -BEGIN - CALL vn.worker_updateBalance(OLD.workerFk,-OLD.haber,-OLD.debe); -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; - --- --- Table structure for table `incometype_employee` --- - -DROP TABLE IF EXISTS `incometype_employee`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `incometype_employee` ( +CREATE TABLE `incometype_employee__` ( `id_incometype` int(11) NOT NULL, `descripcion` varchar(255) DEFAULT NULL, `nomina` smallint(6) DEFAULT 0, `isExtraSalarial` tinyint(4) NOT NULL DEFAULT 0, PRIMARY KEY (`id_incometype`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='@deprecated 2023-03-15'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -15545,21 +15502,21 @@ CREATE TABLE `labour_agreement` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `media` +-- Table structure for table `media__` -- -DROP TABLE IF EXISTS `media`; +DROP TABLE IF EXISTS `media__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `media` ( +CREATE TABLE `media__` ( `media_id` int(11) NOT NULL AUTO_INCREMENT, `media_type_id` int(11) NOT NULL, `value` varchar(55) NOT NULL, `sort` int(11) DEFAULT NULL, PRIMARY KEY (`media_id`), KEY `media_media_type_id_idx` (`media_type_id`), - CONSTRAINT `media_ibfk_1` FOREIGN KEY (`media_type_id`) REFERENCES `media_type` (`media_type_id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; + CONSTRAINT `media___ibfk_1` FOREIGN KEY (`media_type_id`) REFERENCES `media_type` (`media_type_id`) ON DELETE NO ACTION ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='@deprecated 2023-03-31'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -15578,13 +15535,13 @@ CREATE TABLE `media_type` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `professional_category` +-- Table structure for table `professional_category__` -- -DROP TABLE IF EXISTS `professional_category`; +DROP TABLE IF EXISTS `professional_category__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `professional_category` ( +CREATE TABLE `professional_category__` ( `professional_category_id` int(11) NOT NULL AUTO_INCREMENT, `category_name` varchar(50) NOT NULL, `professional_levels_id` int(11) DEFAULT NULL, @@ -15593,22 +15550,7 @@ CREATE TABLE `professional_category` ( `dayBreak` int(11) DEFAULT NULL, PRIMARY KEY (`professional_category_id`), UNIQUE KEY `professional_category_name_category_key` (`category_name`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `professional_levels` --- - -DROP TABLE IF EXISTS `professional_levels`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `professional_levels` ( - `professional_levels_id` int(11) NOT NULL AUTO_INCREMENT, - `level_name` varchar(5) DEFAULT NULL, - `price_overtime` double DEFAULT NULL, - PRIMARY KEY (`professional_levels_id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='@deprecated 2023-03-24'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -15629,90 +15571,19 @@ CREATE TABLE `profile_address` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `profile_media` +-- Table structure for table `province__` -- -DROP TABLE IF EXISTS `profile_media`; +DROP TABLE IF EXISTS `province__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `profile_media` ( - `profile_media_id` int(11) NOT NULL AUTO_INCREMENT, - `profile_id` int(11) NOT NULL, - `media_id` int(11) NOT NULL, - PRIMARY KEY (`profile_media_id`), - KEY `profile_media_media_id_idx` (`media_id`), - CONSTRAINT `fk_profile_media_media1` FOREIGN KEY (`media_id`) REFERENCES `media` (`media_id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `profile_type` --- - -DROP TABLE IF EXISTS `profile_type`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `profile_type` ( - `profile_type_id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(15) NOT NULL, - PRIMARY KEY (`profile_type_id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `province` --- - -DROP TABLE IF EXISTS `province`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `province` ( +CREATE TABLE `province__` ( `province_id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(15) NOT NULL, `nation_id` int(11) NOT NULL, PRIMARY KEY (`province_id`), UNIQUE KEY `province_name_key` (`name`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `townKk` --- - -DROP TABLE IF EXISTS `townKk`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `townKk` ( - `town_id` int(11) NOT NULL AUTO_INCREMENT, - `province_id` int(11) NOT NULL, - `name` varchar(30) NOT NULL, - `postal_code` varchar(8) NOT NULL, - PRIMARY KEY (`town_id`), - KEY `town_province_id_idx` (`province_id`), - CONSTRAINT `townKk_ibfk_1` FOREIGN KEY (`province_id`) REFERENCES `province` (`province_id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `workers20190711_FichadasAbril` --- - -DROP TABLE IF EXISTS `workers20190711_FichadasAbril`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `workers20190711_FichadasAbril` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `person_id` int(11) NOT NULL DEFAULT 0, - `nif` varchar(15) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `Apellidos` varchar(60) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, - `Nombre` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `Fecha` date DEFAULT NULL, - `Hora` int(2) DEFAULT NULL, - `Minuto` int(2) DEFAULT NULL, - `sumable` double DEFAULT NULL, - `jornada` decimal(5,2) NOT NULL DEFAULT 8.00, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='@deprecated 2023-03-21'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16981,8 +16852,8 @@ BEGIN c.socialName, IFNULL(c.street, ''), c.accountingAccount, - TRIM(IF(cu.code = LEFT(c.fi, 2), MID(c.fi, 3, LENGTH(c.fi)-1), c.fi)), - IF(n.NacionCEE,TRIM(IF(cu.code = LEFT(c.fi, 2), c.fi, CONCAT(cu.code,c.fi))) , ''), + @fi := IF(cu.code = LEFT(TRIM(c.fi), 2) AND c.isVies, MID(TRIM(c.fi), 3, LENGTH(TRIM(c.fi))-1), TRIM(c.fi)), + IF(c.isVies, CONCAT(cu.code, @fi ), TRIM(c.fi)), IFNULL(c.postcode, ''), IFNULL(c.city, ''), IFNULL(pr.CodigoProvincia, ''), @@ -17019,8 +16890,8 @@ BEGIN s.name, IFNULL(s.street, ''), s.account, - TRIM(IF(co.code = LEFT(s.nif, 2), MID(s.nif, 3, LENGTH(s.nif) - 1), s.nif)), - IF(n.NacionCEE, TRIM(CONCAT(co.code, IF(co.code = LEFT(s.nif, 2), MID(s.nif, 3, LENGTH(s.nif) - 1), s.nif))), ''), + @nif := IF(co.code = LEFT(TRIM(s.nif), 2), MID(TRIM(s.nif), 3, LENGTH(TRIM(s.nif))-1), TRIM(s.nif)), + IF(s.isVies, CONCAT(co.code, @nif), TRIM(s.nif)), IFNULL(s.postCode,''), IFNULL(s.city, ''), IFNULL(pr.CodigoProvincia, ''), @@ -17087,6 +16958,7 @@ BEGIN DECLARE vSerialDua VARCHAR(1) DEFAULT 'D'; DECLARE vInvoiceTypeReceived VARCHAR(1); DECLARE vInvoiceTypeInformative VARCHAR(1); + DECLARE vIsInformativeExportation BOOL DEFAULT FALSE; DECLARE vCursor CURSOR FOR SELECT it.taxableBase, @@ -17115,6 +16987,15 @@ BEGIN SELECT codeSage INTO vInvoiceTypeInformative FROM invoiceType WHERE code ='informative'; + SELECT d.ASIEN AND x.ASIEN IS NULL INTO vIsInformativeExportation + FROM vn.dua d + LEFT JOIN vn.XDiario x ON x.ASIEN = d.ASIEN + AND x.SERIE = vSerialDua COLLATE utf8mb3_unicode_ci + WHERE d.ASIEN = ( + SELECT ASIEN + FROM vn.XDiario + WHERE id = vXDiarioFk); + INSERT INTO movContaIVA(id, LibreA1) VALUES (vXDiarioFk, vInvoiceInFk); @@ -17206,10 +17087,12 @@ BEGIN mci.Factura = ii.serialNumber, mci.FechaFactura = ii.issued, mci.ImporteFactura = IFNULL(mci.BaseIva1, 0) + IFNULL(mci.CuotaIva1, 0) + - IFNULL(mci.BaseIva2, 0) + IFNULL(mci.CuotaIva2, 0) + - IFNULL(mci.BaseIva3, 0) + IFNULL(mci.CuotaIva3, 0) + - IFNULL(mci.BaseIva4, 0) + IFNULL(mci.CuotaIva4, 0), - mci.TipoFactura = IF(id.id, IF( ii.serial = vSerialDua COLLATE utf8mb3_unicode_ci, vInvoiceTypeReceived, vInvoiceTypeInformative), vInvoiceTypeReceived), + IFNULL(mci.BaseIva2, 0) + IFNULL(mci.CuotaIva2, 0) + + IFNULL(mci.BaseIva3, 0) + IFNULL(mci.CuotaIva3, 0) + + IFNULL(mci.BaseIva4, 0) + IFNULL(mci.CuotaIva4, 0), + mci.TipoFactura = IF(id.id, + IF( ii.serial = vSerialDua COLLATE utf8mb3_unicode_ci, vInvoiceTypeReceived, vInvoiceTypeInformative), + IF(vIsInformativeExportation,vInvoiceTypeInformative, vInvoiceTypeReceived)), mci.CodigoCuentaFactura = x.SUBCTA, mci.CifDni = IF(LEFT(TRIM(s.nif), 2) = n.SiglaNacion, SUBSTRING(TRIM(s.nif), 3), s.nif), mci.Nombre = s.name, @@ -17233,7 +17116,7 @@ BEGIN JOIN vn.invoiceInTax iit ON iit.invoiceInFk = ii.id JOIN vn.expence e ON e.id = iit.expenceFk JOIN TiposRetencion t ON t.CodigoRetencion = ii.withholdingSageFk - LEFT JOIN tmp.invoiceDua id ON id.id = mci.id + LEFT JOIN tmp.invoiceDua id ON id.id = mci.id JOIN (SELECT SUM(x2.BASEEURO) taxableBase, SUM(x2.EURODEBE) taxBase FROM vn.XDiario x1 JOIN vn.XDiario x2 ON x1.ASIEN = x2.ASIEN @@ -17248,7 +17131,7 @@ BEGIN mci.ImporteRetencion = iit.taxableBase * - 1 WHERE mci.id = vXDiarioFk AND e.name = 'Retenciones' - AND id.id IS NULL; + AND id.id IS NULL; END ;; DELIMITER ; @@ -17910,7 +17793,9 @@ CREATE TABLE `AccessToken` ( `scopes` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, `created` datetime DEFAULT NULL, `userId` int(11) DEFAULT NULL, - PRIMARY KEY (`id`) + `outdated` datetime GENERATED ALWAYS AS (`created` + interval `ttl` second) STORED, + PRIMARY KEY (`id`), + KEY `outdated_Index` (`outdated`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -18079,10 +17964,54 @@ CREATE TABLE `userConfigView` ( -- -- Dumping events for database 'salix' -- +/*!50106 SET @save_time_zone= @@TIME_ZONE */ ; +/*!50106 DROP EVENT IF EXISTS `accessToken_prune` */; +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=`root`@`localhost`*/ /*!50106 EVENT `accessToken_prune` ON SCHEDULE EVERY 1 DAY STARTS '2023-03-14 05:14:00' ON COMPLETION PRESERVE ENABLE DO CALL salix.accessToken_prune */ ;; +/*!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 */ ;; +DELIMITER ; +/*!50106 SET TIME_ZONE= @save_time_zone */ ; -- -- Dumping routines for database 'salix' -- +/*!50003 DROP PROCEDURE IF EXISTS `accessToken_prune` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `accessToken_prune`() +BEGIN +/** + * Borra de la tabla salix.AccessToken todos aquellos tokens que hayan caducado + */ + DELETE FROM salix.AccessToken + WHERE outdated < NOW(); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; -- -- Current Database: `stock` @@ -18334,7 +18263,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `log_clean` ON SCHEDULE EVERY 1 DAY STARTS '2022-01-28 09:29:18' ON COMPLETION PRESERVE DISABLE ON SLAVE DO CALL log_clean */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `log_clean` ON SCHEDULE EVERY 1 DAY STARTS '2022-01-28 09:29:18' ON COMPLETION PRESERVE ENABLE DO CALL log_clean */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -19354,6 +19283,9 @@ CREATE TABLE `config` ( `hasTriggersDisabled` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Defines if triggers are disabled', `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, + `mockTime` datetime DEFAULT NULL, + `mockEnabled` tinyint(3) unsigned NOT NULL DEFAULT 0, PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Global configuration table'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -19491,11 +19423,14 @@ DROP TABLE IF EXISTS `notificationSubscription`; CREATE TABLE `notificationSubscription` ( `notificationFk` int(11) NOT NULL, `userFk` int(10) unsigned NOT NULL, - PRIMARY KEY (`notificationFk`,`userFk`), + `id` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`), + UNIQUE KEY `notificationSubscription_UN` (`notificationFk`,`userFk`), KEY `notificationSubscription_ibfk_2` (`userFk`), + KEY `notificationSubscription_ibfk_1` (`notificationFk`), CONSTRAINT `notificationSubscription_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `notification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `notificationSubscription_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -19550,7 +19485,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `slowLog_prune` ON SCHEDULE EVERY 1 DAY STARTS '2021-10-08 00:00:00' ON COMPLETION PRESERVE DISABLE ON SLAVE DO CALL util.slowLog_prune */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `slowLog_prune` ON SCHEDULE EVERY 1 DAY STARTS '2021-10-08 00:00:00' ON COMPLETION PRESERVE ENABLE DO CALL util.slowLog_prune */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -19572,7 +19507,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `accountShortToStandard`(vAccount VARCHAR(10)) RETURNS varchar(10) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `accountShortToStandard`(vAccount VARCHAR(10)) RETURNS varchar(10) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN RETURN REPLACE(vAccount, '.', REPEAT('0', 11 - LENGTH(vAccount))); @@ -19592,7 +19527,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `capitalizeFirst`(vString VARCHAR(255)) RETURNS varchar(255) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `capitalizeFirst`(vString VARCHAR(255)) RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_general_ci NO SQL DETERMINISTIC BEGIN @@ -19646,7 +19581,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `crypt`(vText VARCHAR(255), vKey VARCHAR(255)) RETURNS varchar(255) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `crypt`(vText VARCHAR(255), vKey VARCHAR(255)) RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_general_ci READS SQL DATA BEGIN @@ -19672,7 +19607,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `cryptOff`(vText VARCHAR(255), vKey VARCHAR(255)) RETURNS varchar(255) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `cryptOff`(vText VARCHAR(255), vKey VARCHAR(255)) RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_general_ci READS SQL DATA BEGIN @@ -19742,102 +19677,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP FUNCTION IF EXISTS `CURDATE` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `util`.`CURDATE`() RETURNS date - DETERMINISTIC -BEGIN - /** - * @return The mock date - **/ - - RETURN DATE(mockTime()); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP FUNCTION IF EXISTS `mockTime` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `util`.`mockTime`() RETURNS datetime - DETERMINISTIC -BEGIN -/** - * Returns the mockTime with predefined timezone or current dateTime - * depending of config.mockEnabled - * - * @return formatted datetime - */ - DECLARE vMockEnabled BOOL; - - SELECT mockEnabled INTO vMockEnabled FROM config LIMIT 1; - - IF vMockEnabled THEN - RETURN mockTimeBase(FALSE); - ELSE - RETURN NOW(); - END IF; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP FUNCTION IF EXISTS `mockTimeBase` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `util`.`mockTimeBase`(vIsUtc BOOL) RETURNS datetime - DETERMINISTIC -BEGIN -/** - * Returns the date formatted to utc if vIsUtc or config.mocTz if not - * - * @param vIsUtc If date must be returned as UTC format - * @return The formatted mock time - */ -DECLARE vMockUtcTime DATETIME; - DECLARE vMockTz VARCHAR(255); - - SELECT mockUtcTime, mockTz - INTO vMockUtcTime, vMockTz - FROM config - LIMIT 1; - - IF vIsUtc OR vMockTz IS NULL THEN - RETURN vMockUtcTime; - ELSE - RETURN CONVERT_TZ(vMockUtcTime, '+00:00', vMockTz); - END IF; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP FUNCTION IF EXISTS `firstDayOfYear` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -19875,7 +19714,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `formatRow`(vType CHAR(3), vValues VARCHAR(512)) RETURNS varchar(512) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `formatRow`(vType CHAR(3), vValues VARCHAR(512)) RETURNS varchar(512) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN DECLARE vRow VARCHAR(512); @@ -19908,7 +19747,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `formatTable`(vFields VARCHAR(512), vOldValues VARCHAR(512), vNewValues VARCHAR(512)) RETURNS text CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `formatTable`(vFields VARCHAR(512), vOldValues VARCHAR(512), vNewValues VARCHAR(512)) RETURNS text CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN DECLARE vTable TEXT; @@ -19965,7 +19804,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `hmacSha2`(`vAlg` SMALLINT, `vMsg` MEDIUMBLOB, `vKey` MEDIUMBLOB) RETURNS varchar(128) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `hmacSha2`(`vAlg` SMALLINT, `vMsg` MEDIUMBLOB, `vKey` MEDIUMBLOB) RETURNS varchar(128) CHARSET utf8mb3 COLLATE utf8mb3_general_ci NO SQL DETERMINISTIC BEGIN @@ -20032,6 +19871,7 @@ DELIMITER ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `json_removeNulls`(vObject JSON) RETURNS longtext CHARSET utf8mb4 COLLATE utf8mb4_bin + DETERMINISTIC BEGIN /** * Elimina las propiedades con valor NULL de un objeto. @@ -20040,18 +19880,19 @@ BEGIN * @return El objeto JSON sin propiedades a NULL */ DECLARE vKeys JSON; - DECLARE vKey VARCHAR(255); + DECLARE vPath VARCHAR(255); DECLARE vValue VARCHAR(255); DECLARE i INT DEFAULT 0; DECLARE vCount INT; SET vKeys = JSON_KEYS(vObject); SET vCount = JSON_LENGTH(vKeys); + WHILE i < vCount DO - SET vKey = JSON_VALUE(vKeys, CONCAT('$[',i,']')); - SET vValue = JSON_VALUE(vObject, CONCAT('$.', vKey)); + SET vPath = CONCAT('$.', JSON_VALUE(vKeys, CONCAT('$[',i,']'))); + SET vValue = JSON_VALUE(vObject, vPath); IF vValue IS NULL THEN - SET vObject = JSON_REMOVE(vObject, CONCAT('$.', vKey)); + SET vObject = JSON_REMOVE(vObject, vPath); END IF; SET i := i + 1; END WHILE; @@ -20073,7 +19914,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `lang`() RETURNS char(2) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `lang`() RETURNS char(2) CHARSET utf8mb3 COLLATE utf8mb3_general_ci NO SQL DETERMINISTIC BEGIN @@ -20116,6 +19957,48 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP FUNCTION IF EXISTS `log_formatDate` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` FUNCTION `log_formatDate`(vInstance JSON) RETURNS longtext CHARSET utf8mb4 COLLATE utf8mb4_bin + DETERMINISTIC +BEGIN + DECLARE vKeys JSON; + DECLARE vPath VARCHAR(255); + DECLARE vValue VARCHAR(255); + DECLARE i INT DEFAULT 0; + DECLARE vCount INT; + + IF vInstance IS NULL THEN + RETURN NULL; + END IF; + + SET vKeys = JSON_KEYS(vInstance); + SET vCount = JSON_LENGTH(vInstance); + + WHILE i < vCount DO + SET vPath = CONCAT('$.', JSON_VALUE(vKeys, CONCAT('$[', i ,']'))); + SET vValue = JSON_VALUE(vInstance, vPath); + IF vValue REGEXP '^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2} [[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}$' THEN + SET vInstance = JSON_SET(vInstance, vPath, DATE_FORMAT(CONVERT_TZ(vValue, '+01:00', '+00:00'), '%Y-%m-%dT%T.%fZ')); + END IF; + SET i := i + 1; + END WHILE; + + RETURN vInstance; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP FUNCTION IF EXISTS `midnight` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -20138,6 +20021,107 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP FUNCTION IF EXISTS `mockTime` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` FUNCTION `mockTime`() RETURNS datetime + DETERMINISTIC +BEGIN +/** + * Returns the mockTime with predefined timezone or current dateTime + * depending of config.mockEnabled + * + * @return formatted datetime + */ +-- FIXME: #5041 Commented because there is slowness when querying a table +/* + DECLARE vMockEnabled BOOL; + + SELECT mockEnabled INTO vMockEnabled FROM config LIMIT 1; + + IF vMockEnabled THEN + RETURN mockTimeBase(FALSE); + ELSE + RETURN NOW(); + END IF; +*/ + RETURN CONVERT_TZ('2001-01-01 11:00:00', 'utc', 'Europe/Madrid'); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP FUNCTION IF EXISTS `mockTimeBase` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` FUNCTION `mockTimeBase`(vIsUtc BOOL) RETURNS datetime + DETERMINISTIC +BEGIN +/** + * Returns the date formatted to utc if vIsUtc or config.mocTz if not + * + * @param vIsUtc If date must be returned as UTC format + * @return The formatted mock time + */ + RETURN CONVERT_TZ('2001-01-01 11:00:00', 'utc', 'Europe/Madrid'); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP FUNCTION IF EXISTS `mockUtcTime` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` FUNCTION `mockUtcTime`() RETURNS datetime + DETERMINISTIC +BEGIN +/** + * Returns the UTC datetime in mockTime format or timeStamp depending on config table + * + * @return The UTC datetime format + */ +-- FIXME: #5041 Commented because there is slowness when querying a table +/* + DECLARE vMockEnabled BOOL; + + SELECT mockEnabled INTO vMockEnabled FROM config LIMIT 1; + + IF vMockEnabled THEN + RETURN mockTimeBase(TRUE); + ELSE + RETURN UTC_TIMESTAMP(); + END IF; +*/ + RETURN CONVERT_TZ('2001-01-01 11:00:00', 'utc', 'Europe/Madrid'); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP FUNCTION IF EXISTS `nextWeek` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -20233,7 +20217,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `quoteIdentifier`(vString TEXT) RETURNS text CHARSET utf8mb3 +CREATE DEFINER=`root`@`localhost` FUNCTION `quoteIdentifier`(vString TEXT) RETURNS text CHARSET utf8mb3 COLLATE utf8mb3_general_ci NO SQL DETERMINISTIC BEGIN @@ -20357,6 +20341,167 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP FUNCTION IF EXISTS `VN_CURDATE` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` FUNCTION `VN_CURDATE`() RETURNS date + DETERMINISTIC +BEGIN +/** + * @return The mock date + */ + RETURN DATE(mockTime()); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP FUNCTION IF EXISTS `VN_CURTIME` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` FUNCTION `VN_CURTIME`() RETURNS time + DETERMINISTIC +BEGIN +/** + * @return The mock curtime + */ + RETURN TIME(mockTime()); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP FUNCTION IF EXISTS `VN_NOW` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` FUNCTION `VN_NOW`() RETURNS datetime + DETERMINISTIC +BEGIN +/** + * @return The mock datetime + */ + RETURN mockTime(); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP FUNCTION IF EXISTS `VN_UNIX_TIMESTAMP` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` FUNCTION `VN_UNIX_TIMESTAMP`() RETURNS int(11) + DETERMINISTIC +BEGIN + /** + * @return The mock time in unix timestamp format + */ + RETURN UNIX_TIMESTAMP(mocktime()); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP FUNCTION IF EXISTS `VN_UTC_DATE` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` FUNCTION `VN_UTC_DATE`() RETURNS date + DETERMINISTIC +BEGIN +/** + * @return The mock Date in UTC format + */ + RETURN DATE(mockUtcTime()); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP FUNCTION IF EXISTS `VN_UTC_TIME` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` FUNCTION `VN_UTC_TIME`() RETURNS time + DETERMINISTIC +BEGIN +/** + * @return The mock time in utc format + */ + RETURN TIME(mockUtcTime()); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP FUNCTION IF EXISTS `VN_UTC_TIMESTAMP` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` FUNCTION `VN_UTC_TIMESTAMP`() RETURNS datetime + DETERMINISTIC +BEGIN +/* + * @return The mock utc datetime + */ + RETURN mockUtcTime(); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP FUNCTION IF EXISTS `yearRelativePosition` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -20367,7 +20512,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `yearRelativePosition`(vYear INT) RETURNS varchar(20) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `yearRelativePosition`(vYear INT) RETURNS varchar(20) CHARSET utf8mb3 COLLATE utf8mb3_general_ci DETERMINISTIC BEGIN /** @@ -20773,36 +20918,11 @@ BEGIN * @param vUserId Id del usuario que realiza la acción */ DECLARE vTableName VARCHAR(255) DEFAULT CONCAT(IFNULL(vEntity, ''), 'Log'); - DECLARE vKeys JSON; - DECLARE vKey VARCHAR(255); - DECLARE vOldValue VARCHAR(255); - DECLARE vNewValue VARCHAR(255); - DECLARE vValue VARCHAR(255); - DECLARE i INT DEFAULT 0; - DECLARE vCount INT; SET vSchema = util.quoteIdentifier(vSchema); SET vTableName = util.quoteIdentifier(vTableName); - CASE vActionCode - WHEN 'insert' THEN - SELECT json_removeNulls(vNewInstance) INTO vNewInstance; - WHEN 'update' THEN - SET vKeys = JSON_KEYS(vOldInstance); - SET vCount = JSON_LENGTH(vOldInstance); - WHILE i < vCount DO - SET vKey = JSON_VALUE(vKeys, CONCAT('$[',i,']')); - SET vOldValue = JSON_VALUE(vOldInstance, CONCAT('$.',vKey)); - SET vNewValue = JSON_VALUE(vNewInstance, CONCAT('$.',vKey)); - IF (vOldValue = vNewValue) THEN - SET vOldInstance = JSON_REMOVE(vOldInstance, CONCAT('$.',vKey)); - SET vNewInstance = JSON_REMOVE(vNewInstance, CONCAT('$.',vKey)); - END IF; - SET i := i + 1; - END WHILE; - WHEN 'delete' THEN - SELECT json_removeNulls(vOldInstance) INTO vOldInstance; - END CASE; + CALL util.log_cleanInstances(vActionCode, vOldInstance, vNewInstance); EXECUTE IMMEDIATE CONCAT( 'INSERT INTO ', vSchema, '.', vTableName, ' SET changedModel = ?, originFk = ?, changedModelId= ?, action = ?, oldInstance = ?, newInstance = ?, userFk = ?' @@ -20813,6 +20933,73 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `log_cleanInstances` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `log_cleanInstances`( + vActionCode VARCHAR(45), + INOUT vOldInstance JSON, + INOUT vNewInstance JSON) +BEGIN +/** + * Cleans both instances removing nulls and keys whose values are the same. + * + * @param vActionCode The action code {insert | delete | update} + * @param vOldInstance JSON containing the old values + * @param vNewInstance JSON containing the new values + */ + DECLARE vKeys JSON; + DECLARE vPath VARCHAR(255); + DECLARE vOldValue JSON; + DECLARE vNewValue JSON; + DECLARE vOld JSON; + DECLARE vNew JSON; + DECLARE i INT DEFAULT 0; + DECLARE vCount INT; + + CASE vActionCode + WHEN 'insert' THEN + SET vNewInstance = json_removeNulls(vNewInstance); + WHEN 'update' THEN + SET vOld = '{}'; + SET vNew = '{}'; + SET vKeys = JSON_KEYS(vNewInstance); + SET vCount = JSON_LENGTH(vKeys); + WHILE i < vCount DO + SET vPath = CONCAT('$.', JSON_VALUE(vKeys, CONCAT('$[',i,']'))); + SET vOldValue = JSON_EXTRACT(vOldInstance, vPath); + SET vNewValue = JSON_EXTRACT(vNewInstance, vPath); + IF NOT (vOldValue <=> vNewValue) THEN + IF vOldValue IS NOT NULL AND vOldValue <> 'null' THEN + SET vOld = JSON_SET(vOld, vPath, JSON_COMPACT(vOldValue)); + END IF; + IF vNewValue IS NOT NULL THEN + SET vNew = JSON_SET(vNew, vPath, JSON_COMPACT(vNewValue)); + END IF; + END IF; + SET i := i + 1; + END WHILE; + SET vOldInstance = vOld; + SET vNewInstance = vNew; + WHEN 'delete' THEN + SET vOldInstance = json_removeNulls(vOldInstance); + END CASE; + + SET vOldInstance = log_formatDate(vOldInstance); + SET vNewInstance = log_formatDate(vNewInstance); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `procNoOverlap` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -20938,11 +21125,11 @@ 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 = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `slowLog_prune`() BEGIN @@ -21086,36 +21273,20 @@ CREATE TABLE `XDiario` ( `BASEEURO` decimal(10,2) DEFAULT NULL, `SERIE` varchar(1) DEFAULT NULL, `FACTURA` varchar(8) DEFAULT '0', - `BASEIMPO` decimal(10,2) DEFAULT NULL, `IVA` decimal(10,2) DEFAULT NULL, `RECEQUIV` decimal(10,2) DEFAULT 0.00, - `DOCUMENTO` varchar(10) DEFAULT NULL, - `DEPARTA` varchar(3) DEFAULT NULL, `CLAVE` int(11) DEFAULT NULL, - `ESTADO` varchar(1) DEFAULT NULL, - `NCASADO` decimal(10,2) DEFAULT NULL, - `TCASADO` decimal(10,2) DEFAULT NULL, - `TRANS` decimal(10,2) DEFAULT NULL, `CAMBIO` decimal(10,2) DEFAULT NULL, `DEBEME` decimal(10,2) DEFAULT NULL, `HABERME` decimal(10,2) DEFAULT NULL, - `PTAHABER` decimal(10,2) DEFAULT NULL, `AUXILIAR` varchar(1) DEFAULT NULL, - `SUCURSAL` varchar(4) DEFAULT NULL, - `PTADEBE` decimal(10,2) DEFAULT NULL, - `CODDIVISA` varchar(5) DEFAULT NULL, - `IMPAUXME` decimal(10,2) DEFAULT NULL, `MONEDAUSO` varchar(1) DEFAULT '2', - `NOCONV` tinyint(1) NOT NULL DEFAULT 0, - `NUMEROINV` varchar(10) DEFAULT NULL, `TIPOOPE` varchar(1) DEFAULT NULL, `NFACTICK` tinyint(1) NOT NULL DEFAULT 1, `TERIDNIF` tinyint(1) NOT NULL DEFAULT 2, `TERNIF` varchar(20) NOT NULL DEFAULT 'I.F.', `TERNOM` varchar(50) NOT NULL DEFAULT 'Nombre Importador', `OPBIENES` tinyint(1) NOT NULL DEFAULT 1, - `TIPOFAC` varchar(1) DEFAULT NULL, - `TIPOIVA` varchar(1) DEFAULT NULL, `L340` tinyint(2) NOT NULL DEFAULT 0, `enlazado` tinyint(1) NOT NULL DEFAULT 0, `FECHA_EX` date DEFAULT NULL COMMENT 'FEcha de expedicion de la factura', @@ -21383,6 +21554,7 @@ CREATE TABLE `address` ( `customsAgentFk` int(11) DEFAULT NULL, `incotermsFk` varchar(3) DEFAULT NULL, `isLogifloraAllowed` tinyint(4) NOT NULL DEFAULT 0, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `Id_Agencia` (`agencyModeFk`), KEY `Id_cliente` (`clientFk`), @@ -21392,8 +21564,10 @@ CREATE TABLE `address` ( KEY `CODPOSTAL` (`postalCode`), KEY `address_customsAgentFk_idx` (`customsAgentFk`), KEY `address_incotermsFk_idx` (`incotermsFk`), + KEY `address_fk_editor` (`editorFk`), 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 @@ -21414,6 +21588,8 @@ DELIMITER ;; BEGIN DECLARE vIsEqualizated BOOL; + SET NEW.editorFk = account.myUser_getId(); + IF (NEW.phone <> '') THEN CALL pbx.phone_isValid(NEW.phone); END IF; @@ -21450,6 +21626,8 @@ DELIMITER ;; FOR EACH ROW BEGIN + SET NEW.editorFk = account.myUser_getId(); + IF !(NEW.phone <=> OLD.phone) AND (NEW.phone <> '') THEN CALL pbx.phone_isValid(NEW.phone); END IF; @@ -21509,6 +21687,30 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`address_afterDelete` + AFTER DELETE ON `address` + FOR EACH ROW +BEGIN + INSERT INTO clientLog + SET `action` = 'delete', + `changedModel` = 'Address', + `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 */ ; -- -- Table structure for table `addressFilter` @@ -21685,10 +21887,10 @@ CREATE TABLE `agencyModeItemType` ( `agencyModeFk` int(11) NOT NULL, `itemTypeFk` smallint(5) unsigned NOT NULL, PRIMARY KEY (`id`), - KEY `agencyModeItemType_FK` (`agencyModeFk`), + UNIQUE KEY `agencyModeFk_ItemType_UNIQUE` (`agencyModeFk`,`itemTypeFk`), KEY `agencyModeItemType_FK_1` (`itemTypeFk`), CONSTRAINT `agencyModeItemType_FK` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `agencyModeItemType_FK_1` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `agencyModeItemType_FK_1` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Combinaciones prohibidas entre agencyMode e itemType al calcular el catálogo de items'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -21737,6 +21939,7 @@ DROP TABLE IF EXISTS `alertLevel`; CREATE TABLE `alertLevel` ( `code` varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, `id` int(11) NOT NULL, + `hasToRecalcPrice` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -21814,10 +22017,12 @@ DROP TABLE IF EXISTS `auctionConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `auctionConfig` ( + `id` int(11) NOT NULL, `conversionCoefficient` double NOT NULL DEFAULT 1 COMMENT 'value used to calculate the used space of an item in a container', - `warehosueFk` smallint(6) unsigned NOT NULL DEFAULT 7 COMMENT 'default warehouse used for the calculation', - KEY `auctionConfig_FK` (`warehosueFk`), - CONSTRAINT `auctionConfig_FK` FOREIGN KEY (`warehosueFk`) REFERENCES `warehouse` (`id`) + `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT 7 COMMENT 'Default warehouse used for the calculation', + PRIMARY KEY (`id`), + KEY `auctionConfig_FK` (`warehouseFk`), + CONSTRAINT `auctionConfig_FK` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -22074,7 +22279,6 @@ CREATE TABLE `bankEntity` ( `name` varchar(45) NOT NULL, `bic` varchar(11) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `bic_UNIQUE` (`bic`), KEY `fg_entity1_idx` (`countryFk`), CONSTRAINT `fg_entity1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Entidades bancarias '; @@ -22411,13 +22615,14 @@ CREATE TABLE `business` ( `workerBusinessProfessionalCategoryFk` int(11) DEFAULT NULL, `calendarTypeFk` int(11) DEFAULT 1, `isHourlyLabor` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Contrato por horas', - `workcenterFk` int(11) NOT NULL, + `workcenterFk` int(11) DEFAULT NULL, `rate` int(11) DEFAULT NULL, `workerBusinessCategoryFk` int(11) DEFAULT NULL, `workerBusinessTypeFk` int(11) DEFAULT NULL, `amount` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT 'Importe pactado', `workerBusinessAgreementFk` int(11) DEFAULT NULL, `basicSalary` decimal(10,2) DEFAULT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `business_occupationCodeFk` (`occupationCodeFk`), KEY `business_companyCodeFk` (`companyCodeFk`), @@ -22428,13 +22633,17 @@ CREATE TABLE `business` ( KEY `business_workerBusinessCategoryFk` (`workerBusinessCategoryFk`), KEY `business_workerBusinessTypeFk_idx` (`workerBusinessTypeFk`), KEY `business_workerBusinessAgreementFk_idx` (`workerBusinessAgreementFk`), - CONSTRAINT `business_calendarTypeFk` FOREIGN KEY (`calendarTypeFk`) REFERENCES `postgresql`.`calendar_labour_type` (`calendar_labour_type_id`) ON UPDATE CASCADE, + KEY `business_workcenterFk_idx` (`workcenterFk`), + KEY `business_fk_editor` (`editorFk`), + CONSTRAINT `business_FK` FOREIGN KEY (`workerBusinessProfessionalCategoryFk`) REFERENCES `professionalCategory` (`id`) ON UPDATE CASCADE, + CONSTRAINT `business_calendarTypeFk` FOREIGN KEY (`calendarTypeFk`) REFERENCES `calendarType` (`id`) ON UPDATE CASCADE, CONSTRAINT `business_companyCodeFk` FOREIGN KEY (`companyCodeFk`) REFERENCES `company` (`code`) ON UPDATE CASCADE, CONSTRAINT `business_departmentFk` FOREIGN KEY (`departmentFk`) REFERENCES `department` (`id`) ON UPDATE CASCADE, + CONSTRAINT `business_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `business_occupationCodeFk` FOREIGN KEY (`occupationCodeFk`) REFERENCES `occupationCode` (`code`) ON UPDATE CASCADE, + CONSTRAINT `business_workcenterFk` FOREIGN KEY (`workcenterFk`) REFERENCES `workCenter` (`id`) ON UPDATE CASCADE, CONSTRAINT `business_workerBusinessAgreementFk` FOREIGN KEY (`workerBusinessAgreementFk`) REFERENCES `postgresql`.`labour_agreement` (`labour_agreement_id`) ON UPDATE CASCADE, - CONSTRAINT `business_workerBusinessCategoryFk` FOREIGN KEY (`workerBusinessCategoryFk`) REFERENCES `vn2008`.`payroll_categorias` (`codcategoria`) ON UPDATE CASCADE, - CONSTRAINT `business_workerBusinessProfessionalCategoryFk` FOREIGN KEY (`workerBusinessProfessionalCategoryFk`) REFERENCES `postgresql`.`professional_category` (`professional_category_id`) ON UPDATE CASCADE, + CONSTRAINT `business_workerBusinessCategoryFk` FOREIGN KEY (`workerBusinessCategoryFk`) REFERENCES `payrollCategories` (`id`) ON UPDATE CASCADE, CONSTRAINT `business_workerBusinessTypeFk` FOREIGN KEY (`workerBusinessTypeFk`) REFERENCES `workerBusinessType` (`id`) ON UPDATE CASCADE, CONSTRAINT `business_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; @@ -22452,6 +22661,8 @@ DELIMITER ;; BEFORE INSERT ON `business` FOR EACH ROW BEGIN + SET NEW.editorFk = account.myUser_getId(); + IF NEW.ended IS NULL THEN SET NEW.payedHolidays = 0; END IF; @@ -22494,7 +22705,9 @@ DELIMITER ;; BEFORE UPDATE ON `business` FOR EACH ROW BEGIN - DECLARE isOverlapping BOOL; + DECLARE isOverlapping BOOL; + + SET NEW.editorFk = account.myUser_getId(); IF NEW.ended IS NULL THEN SET NEW.payedHolidays = 0; @@ -22513,9 +22726,9 @@ BEGIN AND b.id <> OLD.id AND workerFk = OLD.workerFk; - IF isOverlapping THEN - CALL util.throw ('IS_OVERLAPPING'); - END IF; + IF isOverlapping THEN + CALL util.throw ('IS_OVERLAPPING'); + END IF; END IF; @@ -22562,6 +22775,12 @@ DELIMITER ;; AFTER DELETE ON `business` FOR EACH ROW BEGIN + INSERT INTO workerLog + SET `action` = 'delete', + `changedModel` = 'Business', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); + CALL worker_updateBusiness(OLD.workerFk); END */;; DELIMITER ; @@ -22643,7 +22862,7 @@ CREATE TABLE `buy` ( `price2` decimal(10,2) DEFAULT 0.00, `price3` decimal(10,2) DEFAULT 0.00, `minPrice` decimal(10,2) DEFAULT 0.00, - `printedStickers` int(11) DEFAULT 0, + `printedStickers` int(11) NOT NULL DEFAULT 0, `workerFk` int(11) DEFAULT 0, `isChecked` tinyint(1) NOT NULL DEFAULT 0, `isPickedOff` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Esta mercancia no va a la zona de picking.', @@ -22653,6 +22872,7 @@ CREATE TABLE `buy` ( `weight` decimal(10,2) unsigned DEFAULT NULL, `deliveryFk` int(11) DEFAULT NULL, `itemOriginalFk` int(11) DEFAULT NULL COMMENT 'Item original de la entrada', + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `CompresId_Trabajador` (`workerFk`), KEY `Id_Cubo` (`packageFk`), @@ -22662,10 +22882,13 @@ CREATE TABLE `buy` ( KEY `itemFk_entryFk` (`itemFk`,`entryFk`), KEY `buy_fk_4_idx` (`deliveryFk`), KEY `buy_FK` (`itemOriginalFk`), + KEY `buy_itemFk_IDX` (`itemFk`) USING BTREE, + KEY `buy_fk_editor` (`editorFk`), CONSTRAINT `buy_FK` FOREIGN KEY (`itemOriginalFk`) REFERENCES `item` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `buy_FK_1` FOREIGN KEY (`containerFk`) REFERENCES `vn2008`.`container` (`container_id`) ON UPDATE CASCADE, CONSTRAINT `buy_ektFk` FOREIGN KEY (`ektFk`) REFERENCES `edi`.`ekt` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `buy_fk_4` FOREIGN KEY (`deliveryFk`) REFERENCES `edi`.`deliveryInformation` (`ID`) ON DELETE SET NULL ON UPDATE SET NULL, + CONSTRAINT `buy_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `buy_ibfk_1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE, CONSTRAINT `buy_ibfk_2` FOREIGN KEY (`packageFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE, CONSTRAINT `buy_id` FOREIGN KEY (`entryFk`) REFERENCES `entry` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, @@ -22696,6 +22919,8 @@ trig: BEGIN LEAVE trig; END IF; + SET NEW.editorFk = account.myUser_getId(); + CALL buy_checkGrouping(NEW.`grouping`); SELECT t.warehouseInFk, t.landed INTO vWarehouse, vLanding FROM entry e @@ -22755,31 +22980,13 @@ DELIMITER ;; AFTER INSERT ON `buy` FOR EACH ROW trig: BEGIN - DECLARE vValues VARCHAR(255); + IF @isModeInventory OR @isTriggerDisabled THEN + LEAVE trig; + END IF; CALL stock.log_add('buy', NEW.id, NULL); - IF @isModeInventory THEN - LEAVE trig; - END IF; - - IF @isTriggerDisabled THEN - LEAVE trig; - END IF; - CALL buy_afterUpsert(NEW.id); - - /*IF entry_isInventoryOrPrevious(NEW.entryFk) THEN - SET vValues = CONCAT_WS(',', - NEW.entryFk, - NEW.itemFk, - NEW.quantity, - NEW.price1, - NEW.price2, - NEW.price3 - ); - CALL entry_notifyChanged(NEW.entryFk, NEW.id, vValues, NULL); - END IF;*/ END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -22805,6 +23012,9 @@ trig:BEGIN IF @isTriggerDisabled THEN LEAVE trig; END IF; + + SET NEW.editorFk = account.myUser_getId(); + IF !(NEW.`grouping` <=> OLD.`grouping`) THEN CALL buy_checkGrouping(NEW.`grouping`); END IF; @@ -22859,8 +23069,10 @@ trig: BEGIN DECLARE vBuyerFk INT; DECLARE vIsBuyerToBeEmailed BOOL; DECLARE vItemName VARCHAR(50); - DECLARE vNewValues VARCHAR(255); - DECLARE vOldValues VARCHAR(255); + + IF @isModeInventory OR @isTriggerDisabled THEN + LEAVE trig; + END IF; IF !(NEW.id <=> OLD.id) OR !(NEW.entryFk <=> OLD.entryFk) @@ -22870,14 +23082,6 @@ trig: BEGIN CALL stock.log_add('buy', NEW.id, OLD.id); END IF; - IF @isModeInventory THEN - LEAVE trig; - END IF; - - IF @isTriggerDisabled THEN - LEAVE trig; - END IF; - CALL buy_afterUpsert(NEW.id); SELECT w.isBuyerToBeEmailed, t.landed @@ -22911,7 +23115,6 @@ trig: BEGIN ); END IF; END IF; - END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -22955,25 +23158,18 @@ DELIMITER ;; trig: BEGIN DECLARE vValues VARCHAR(255); - IF @isTriggerDisabled THEN + IF @isModeInventory OR @isTriggerDisabled THEN LEAVE trig; END IF; CALL stock.log_add('buy', NULL, OLD.id); - CALL util.debugAdd('buy_deleted', CONCAT(OLD.id,' ', OLD.itemFk,' ', OLD.entryFk, ' ', vn.getWorkerCode())); + INSERT INTO entryLog + SET `action` = 'delete', + `changedModel` = 'Buy', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); - /*IF entry_isInventoryOrPrevious(OLD.entryFk) THEN - SET vValues = CONCAT_WS(',', - OLD.entryFk, - OLD.itemFk, - OLD.quantity, - OLD.price1, - OLD.price2, - OLD.price3 - ); - CALL entry_notifyChanged(OLD.entryFk, OLD.id, NULL, vValues); - END IF;*/ END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -23103,6 +23299,23 @@ CREATE TABLE `calendarHolidaysType` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `calendarType` +-- + +DROP TABLE IF EXISTS `calendarType`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `calendarType` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `description` varchar(50) DEFAULT NULL, + `hoursWeek` smallint(6) unsigned DEFAULT NULL, + `isPartial` tinyint(1) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + UNIQUE KEY `hours_labour_hours_labour_id_key` (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `campaign` -- @@ -23167,9 +23380,10 @@ CREATE TABLE `chat` ( `dated` datetime DEFAULT NULL, `checkUserStatus` tinyint(1) DEFAULT NULL, `message` text DEFAULT NULL, - `status` tinyint(1) DEFAULT NULL, + `status__` tinyint(1) DEFAULT NULL, `attempts` int(1) DEFAULT NULL, `error` text DEFAULT NULL, + `status` enum('pending','sent','error','sending') NOT NULL DEFAULT 'pending', PRIMARY KEY (`id`), KEY `chat_FK` (`senderFk`), CONSTRAINT `chat_FK` FOREIGN KEY (`senderFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE @@ -23193,6 +23407,83 @@ CREATE TABLE `chatConfig` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `chronopostConfig` +-- + +DROP TABLE IF EXISTS `chronopostConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `chronopostConfig` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `accountNumber` int(11) NOT NULL, + `password` varchar(20) NOT NULL, + `idEmit` varchar(20) NOT NULL DEFAULT 'CHRFR' COMMENT 'Valor fijo de chronopost', + `urlShipping` varchar(100) NOT NULL DEFAULT 'https://ws.chronopost.fr/shipping-cxf/ShippingServiceWS/', + `urlTracking` varchar(100) NOT NULL DEFAULT 'https://ws.chronopost.fr/tracking-cxf/TrackingServiceWS/', + `cxfShipping` varchar(100) NOT NULL DEFAULT 'http://cxf.shipping.soap.chronopost.fr/', + `cxfTracking` varchar(100) NOT NULL DEFAULT 'http://cxf.tracking.soap.chronopost.fr/', + `evtCode` varchar(2) NOT NULL DEFAULT 'DC' COMMENT 'Valor fijo de chronopost', + `objectType` varchar(3) NOT NULL DEFAULT 'MAR' COMMENT 'MAR: mercancia, DOC: documentación', + `productCode` varchar(2) NOT NULL DEFAULT '1S', + `weightUnit` varchar(3) NOT NULL DEFAULT 'KGM', + `stickerMode` varchar(6) NOT NULL DEFAULT 'THE' COMMENT 'THE: vertical, THEPSG: horizontal, PDF, ...', + `defaultWeight` int(11) NOT NULL DEFAULT 10, + `defaultSevice` int(11) NOT NULL DEFAULT 0, + `numberOfParcel` int(11) NOT NULL DEFAULT 1, + `civility` varchar(1) NOT NULL DEFAULT 'M', + `modeRetour` varchar(1) NOT NULL DEFAULT '2', + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `chronopostExpedition` +-- + +DROP TABLE IF EXISTS `chronopostExpedition`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `chronopostExpedition` ( + `expeditionFk` int(11) NOT NULL, + `skybillNumber` varchar(20) NOT NULL COMMENT 'Código devuelto por chronopost', + PRIMARY KEY (`expeditionFk`), + CONSTRAINT `chronopostExpedition_FK` FOREIGN KEY (`expeditionFk`) REFERENCES `expedition` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `chronopostSenderAddress` +-- + +DROP TABLE IF EXISTS `chronopostSenderAddress`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `chronopostSenderAddress` ( + `warehouseFk` smallint(6) unsigned NOT NULL, + `addressFk` int(11) NOT NULL, + PRIMARY KEY (`warehouseFk`), + KEY `chronopostSenderAddress_FK_1` (`addressFk`), + CONSTRAINT `chronopostSenderAddress_FK` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, + CONSTRAINT `chronopostSenderAddress_FK_1` FOREIGN KEY (`addressFk`) REFERENCES `address` (`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 `chronopostServiceWeekday` +-- + +DROP TABLE IF EXISTS `chronopostServiceWeekday`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `chronopostServiceWeekday` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `weekdays` set('mon','tue','wed','thu','fri','sat','sun') NOT NULL, + `serviceType` int(11) unsigned NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `claim` -- @@ -23214,16 +23505,84 @@ CREATE TABLE `claim` ( `hasToPickUp` tinyint(1) NOT NULL, `packages` smallint(10) unsigned DEFAULT 0 COMMENT 'packages received by the client', `rma` varchar(100) DEFAULT NULL, + `responsabilityRate` decimal(3,2) GENERATED ALWAYS AS ((5 - `responsibility`) / 4) VIRTUAL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `cl_est_id` (`claimStateFk`), KEY `Id_Cliente` (`clientFk`), KEY `Id_Trabajador` (`workerFk`), KEY `cl_main_ticketFk_idx` (`ticketFk`), + KEY `claim_fk_editor` (`editorFk`), CONSTRAINT `cl_main_ticketFk` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON UPDATE CASCADE, + CONSTRAINT `claim_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `claim_ibfk_3` FOREIGN KEY (`claimStateFk`) REFERENCES `claimState` (`id`) ON UPDATE CASCADE, CONSTRAINT `claim_ibfk_5` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Reclamaciones, tabla principal'; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claim_beforeInsert` + BEFORE INSERT ON `claim` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claim_beforeUpdate` + BEFORE UPDATE ON `claim` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claim_afterDelete` + AFTER DELETE ON `claim` + FOR EACH ROW +BEGIN + INSERT INTO clientLog + SET `action` = 'delete', + `changedModel` = 'Claim', + `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 */ ; -- -- Table structure for table `claimBeginning` @@ -23237,9 +23596,12 @@ CREATE TABLE `claimBeginning` ( `claimFk` int(10) unsigned NOT NULL, `saleFk` int(11) DEFAULT NULL, `quantity` double DEFAULT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `Id_Movimiento` (`saleFk`), KEY `cl_main_id` (`claimFk`), + KEY `claimBeginning_fk_editor` (`editorFk`), + CONSTRAINT `claimBeginning_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `claimBeginning_ibfk_7` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `claimBeginning_ibfk_8` FOREIGN KEY (`claimFk`) REFERENCES `claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Detalle de las reclamaciones'; @@ -23253,19 +23615,55 @@ CREATE TABLE `claimBeginning` ( /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimBeginning_afterInsert` - AFTER INSERT ON `claimBeginning` +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimBeginning_beforeInsert` + BEFORE INSERT ON `claimBeginning` FOR EACH ROW BEGIN - DECLARE vTicket INT; - - SELECT ticketFk INTO vTicket - FROM sale - WHERE id = NEW.saleFk; - - UPDATE claim - SET ticketFk = vTicket - WHERE id = NEW.claimFk; + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimBeginning_beforeUpdate` + BEFORE UPDATE ON `claimBeginning` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimBeginning_afterDelete` + AFTER DELETE ON `claimBeginning` + FOR EACH ROW +BEGIN + INSERT INTO claimLog + SET `action` = 'delete', + `changedModel` = 'ClaimBeginning', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -23320,6 +23718,7 @@ CREATE TABLE `claimDevelopment` ( `claimResultFk` int(10) unsigned NOT NULL DEFAULT 1, `claimRedeliveryFk` tinyint(3) unsigned NOT NULL DEFAULT 1, `claimDestinationFk` tinyint(3) unsigned NOT NULL DEFAULT 2, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `cl_main_id` (`claimFk`), KEY `cl_res_id` (`claimResponsibleFk`), @@ -23328,6 +23727,8 @@ CREATE TABLE `claimDevelopment` ( KEY `cl_con_id` (`claimResultFk`), KEY `cl_dev` (`claimRedeliveryFk`), KEY `cl_sol` (`claimDestinationFk`), + KEY `claimDevelopment_fk_editor` (`editorFk`), + CONSTRAINT `claimDevelopment_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `claimDevelopment_ibfk_10` FOREIGN KEY (`claimFk`) REFERENCES `claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `claimDevelopment_ibfk_11` FOREIGN KEY (`claimRedeliveryFk`) REFERENCES `claimRedelivery` (`id`) ON UPDATE CASCADE, CONSTRAINT `claimDevelopment_ibfk_12` FOREIGN KEY (`claimDestinationFk`) REFERENCES `claimDestination` (`id`) ON UPDATE CASCADE, @@ -23337,6 +23738,70 @@ CREATE TABLE `claimDevelopment` ( CONSTRAINT `claimDevelopment_ibfk_9` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Causas de las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimDevelopment_beforeInsert` + BEFORE INSERT ON `claimDevelopment` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimDevelopment_beforeUpdate` + BEFORE UPDATE ON `claimDevelopment` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimDevelopment_afterDelete` + AFTER DELETE ON `claimDevelopment` + FOR EACH ROW +BEGIN + INSERT INTO claimLog + SET `action` = 'delete', + `changedModel` = 'ClaimDevelopment', + `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 */ ; -- -- Table structure for table `claimDms` @@ -23348,12 +23813,79 @@ DROP TABLE IF EXISTS `claimDms`; CREATE TABLE `claimDms` ( `claimFk` int(10) unsigned NOT NULL, `dmsFk` int(11) NOT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`claimFk`,`dmsFk`), KEY `dmsFk_idx` (`dmsFk`), + KEY `claimDms_fk_editor` (`editorFk`), + CONSTRAINT `claimDms_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `claimFk` FOREIGN KEY (`claimFk`) REFERENCES `claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `dmsFk` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimDms_beforeInsert` + BEFORE INSERT ON `claimDms` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimDms_beforeUpdate` + BEFORE UPDATE ON `claimDms` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimDms_afterDelete` + AFTER DELETE ON `claimDms` + FOR EACH ROW +BEGIN + INSERT INTO claimLog + SET `action` = 'delete', + `changedModel` = 'ClaimDms', + `changedModelId` = OLD.claimFk, + `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 */ ; -- -- Table structure for table `claimEnd` @@ -23369,16 +23901,83 @@ CREATE TABLE `claimEnd` ( `workerFk` int(10) unsigned NOT NULL DEFAULT 20, `claimDestinationFk` tinyint(4) DEFAULT NULL, `isGreuge` tinyint(4) NOT NULL DEFAULT 0, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `cl_main_id` (`claimFk`), KEY `Id_Trabajador` (`workerFk`), KEY `Id_Movimiento` (`saleFk`), KEY `cl_sol_id` (`claimDestinationFk`), + KEY `claimEnd_fk_editor` (`editorFk`), + CONSTRAINT `claimEnd_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `claimEnd_ibfk_1` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `claimEnd_ibfk_3` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `claimEnd_ibfk_4` FOREIGN KEY (`claimFk`) REFERENCES `claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Acciones en respuesta a las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimEnd_beforeInsert` + BEFORE INSERT ON `claimEnd` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimEnd_beforeUpdate` + BEFORE UPDATE ON `claimEnd` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimEnd_afterDelete` + AFTER DELETE ON `claimEnd` + FOR EACH ROW +BEGIN + INSERT INTO claimLog + SET `action` = 'delete', + `changedModel` = 'ClaimEnd', + `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 */ ; -- -- Table structure for table `claimLog` @@ -23389,7 +23988,7 @@ DROP TABLE IF EXISTS `claimLog`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `claimLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `originFk` int(10) unsigned NOT NULL, + `originFk` int(10) unsigned DEFAULT NULL, `userFk` int(10) unsigned DEFAULT NULL, `action` set('insert','update','delete') NOT NULL, `creationDate` timestamp NULL DEFAULT current_timestamp(), @@ -23420,14 +24019,81 @@ CREATE TABLE `claimObservation` ( `workerFk` int(10) unsigned DEFAULT NULL, `text` text NOT NULL, `created` timestamp NOT NULL DEFAULT current_timestamp(), + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `worker_key` (`workerFk`), KEY `claim_key` (`claimFk`), KEY `claimObservation_created_IDX` (`created`) USING BTREE, + KEY `claimObservation_fk_editor` (`editorFk`), + CONSTRAINT `claimObservation_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `claimObservation_ibfk_1` FOREIGN KEY (`claimFk`) REFERENCES `claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `claimObservation_ibfk_2` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Todas las observaciones referentes a una reclamación'; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimObservation_beforeInsert` + BEFORE INSERT ON `claimObservation` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimObservation_beforeUpdate` + BEFORE UPDATE ON `claimObservation` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimObservation_afterDelete` + AFTER DELETE ON `claimObservation` + FOR EACH ROW +BEGIN + INSERT INTO claimLog + SET `action` = 'delete', + `changedModel` = 'ClaimObservation', + `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 */ ; -- -- Table structure for table `claimRatio` @@ -23536,11 +24202,78 @@ CREATE TABLE `claimState` ( `roleFk` int(10) unsigned NOT NULL DEFAULT 1, `priority` int(11) NOT NULL DEFAULT 1, `hasToNotify` tinyint(4) DEFAULT 0, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `roleFgn_idx` (`roleFk`), + KEY `claimState_fk_editor` (`editorFk`), + CONSTRAINT `claimState_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `roleFgn` FOREIGN KEY (`roleFk`) REFERENCES `account`.`role` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Estados posibles de las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimState_beforeInsert` + BEFORE INSERT ON `claimState` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimState_beforeUpdate` + BEFORE UPDATE ON `claimState` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimState_afterDelete` + AFTER DELETE ON `claimState` + FOR EACH ROW +BEGIN + INSERT INTO claimLog + SET `action` = 'delete', + `changedModel` = 'ClaimState', + `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 */ ; -- -- Table structure for table `client` @@ -23586,7 +24319,6 @@ CREATE TABLE `client` ( `hasCoreVnh` tinyint(1) DEFAULT 0, `isRelevant` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Define los clientes cuyas ventas hay que tener en cuenta en los calculos estadisticos.', `clientTypeFk` int(11) NOT NULL DEFAULT 1, - `mailAddress` int(11) DEFAULT NULL, `creditInsurance` int(11) DEFAULT NULL, `eypbc` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Email\\nYesterday\\nPurchases\\nBy\\nConsigna', `hasToInvoiceByAddress` tinyint(1) DEFAULT 0, @@ -23603,6 +24335,9 @@ CREATE TABLE `client` ( `lastSalesPersonFk` int(10) unsigned DEFAULT NULL COMMENT 'ultimo comercial que tuvo, para el calculo del peso en los rankings de equipo', `businessTypeFk` varchar(20) NOT NULL DEFAULT 'florist', `hasIncoterms` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Received incoterms authorization from client', + `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, PRIMARY KEY (`id`), UNIQUE KEY `IF` (`fi`), KEY `Id_Trabajador` (`salesPersonFk`), @@ -23623,11 +24358,13 @@ CREATE TABLE `client` ( KEY `client_lastSalesPersonFk_IDX` (`lastSalesPersonFk`) USING BTREE, KEY `client_FK_3` (`transferorFk`), KEY `codpos` (`postcode`), + KEY `client_fk_editor` (`editorFk`), CONSTRAINT `canal_nuevo_cliente` FOREIGN KEY (`contactChannelFk`) REFERENCES `contactChannel` (`id`) ON UPDATE CASCADE, CONSTRAINT `client_FK` FOREIGN KEY (`businessTypeFk`) REFERENCES `businessType` (`code`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `client_FK_1` FOREIGN KEY (`bankEntityFk`) REFERENCES `bankEntity` (`id`) ON UPDATE CASCADE, CONSTRAINT `client_FK_2` FOREIGN KEY (`lastSalesPersonFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `client_FK_3` FOREIGN KEY (`transferorFk`) REFERENCES `client` (`id`), + CONSTRAINT `client_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `client_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE, CONSTRAINT `client_ibfk_2` FOREIGN KEY (`payMethodFk`) REFERENCES `payMethod` (`id`) ON UPDATE CASCADE, CONSTRAINT `client_ibfk_3` FOREIGN KEY (`salesPersonFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, @@ -23653,6 +24390,8 @@ DELIMITER ;; FOR EACH ROW BEGIN + SET NEW.editorFk = account.myUser_getId(); + IF (NEW.phone <> '') THEN CALL pbx.phone_isValid(NEW.phone); END IF; @@ -23685,6 +24424,9 @@ DELIMITER ;; BEGIN DECLARE vText VARCHAR(255) DEFAULT NULL; DECLARE vPayMethodFk INT; + + SET NEW.editorFk = account.myUser_getId(); + -- Comprueba que el formato de los teléfonos es válido IF !(NEW.phone <=> OLD.phone) AND (NEW.phone <> '') THEN @@ -23740,7 +24482,7 @@ BEGIN SET NEW.lastSalesPersonFk = IFNULL(NEW.salesPersonFk, OLD.salesPersonFk); END IF; - IF !(NEW.businessTypeFk <=> OLD.businessTypeFk) THEN + IF !(NEW.businessTypeFk <=> OLD.businessTypeFk) AND (NEW.businessTypeFk = 'individual' OR OLD.businessTypeFk = 'individual') THEN SET NEW.isTaxDataChecked = 0; END IF; @@ -23789,6 +24531,30 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`client_afterDelete` + AFTER DELETE ON `client` + FOR EACH ROW +BEGIN + INSERT INTO clientLog + SET `action` = 'delete', + `changedModel` = 'Client', + `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 */ ; -- -- Table structure for table `clientChain` @@ -23855,9 +24621,56 @@ CREATE TABLE `clientContact` ( `clientFk` int(11) NOT NULL, `name` varchar(45) DEFAULT NULL, `phone` varchar(15) DEFAULT NULL, - PRIMARY KEY (`id`) + `editorFk` int(10) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `clientContact_fk_editor` (`editorFk`), + CONSTRAINT `clientContact_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientContact_beforeInsert` + BEFORE INSERT ON `clientContact` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientContact_afterDelete` + AFTER DELETE ON `clientContact` + FOR EACH ROW +BEGIN + INSERT INTO clientLog + SET `action` = 'delete', + `changedModel` = 'ClientContact', + `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 */ ; -- -- Table structure for table `clientCredit` @@ -23942,13 +24755,102 @@ DROP TABLE IF EXISTS `clientDms`; CREATE TABLE `clientDms` ( `clientFk` int(11) NOT NULL, `dmsFk` int(11) NOT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`dmsFk`), KEY `gest_doc_id` (`dmsFk`), KEY `fk_clientes_gestdoc_1_idx` (`clientFk`), + KEY `clientDms_fk_editor` (`editorFk`), + CONSTRAINT `clientDms_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `clientDms_ibfk_2` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_clientes_gestdoc_3` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientDms_beforeInsert` + BEFORE INSERT ON `clientDms` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientDms_beforeUpdate` + BEFORE UPDATE ON `clientDms` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientDms_afterDelete` + AFTER DELETE ON `clientDms` + FOR EACH ROW +BEGIN + INSERT INTO clientLog + SET `action` = 'delete', + `changedModel` = 'ClientDms', + `changedModelId` = OLD.dmsFk, + `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 */ ; + +-- +-- Table structure for table `clientInforma` +-- + +DROP TABLE IF EXISTS `clientInforma`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `clientInforma` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `clientFk` int(11) NOT NULL, + `rating` int(10) unsigned DEFAULT NULL, + `recommendedCredit` int(10) unsigned DEFAULT NULL, + `workerFk` int(10) unsigned NOT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `informaWorkers_fk_idx` (`workerFk`), + KEY `informaClientFk` (`clientFk`), + CONSTRAINT `informa_ClienteFk` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `informa_workers_fk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='información proporcionada por Informa, se actualiza desde el hook de client (salix)'; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `clientItemType` @@ -23963,7 +24865,7 @@ CREATE TABLE `clientItemType` ( `clientFk` int(11) NOT NULL, `itemTypeFk` smallint(5) unsigned NOT NULL DEFAULT 1, PRIMARY KEY (`id`), - KEY `clientItemType_FK` (`clientFk`), + UNIQUE KEY `clientFk_itemTypeFk_UNIQUE` (`clientFk`,`itemTypeFk`), KEY `clientItemType_FK_1` (`itemTypeFk`), CONSTRAINT `clientItemType_FK` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `clientItemType_FK_1` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) @@ -23979,7 +24881,7 @@ DROP TABLE IF EXISTS `clientLog`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `clientLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `originFk` int(11) NOT NULL, + `originFk` int(11) DEFAULT NULL, `userFk` int(10) unsigned DEFAULT NULL, `action` set('insert','update','delete') NOT NULL, `creationDate` timestamp NULL DEFAULT current_timestamp(), @@ -24042,14 +24944,81 @@ CREATE TABLE `clientObservation` ( `workerFk` int(10) unsigned DEFAULT NULL, `text` text NOT NULL, `created` timestamp NOT NULL DEFAULT current_timestamp(), + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `Id_Trabajador` (`workerFk`), KEY `Id_Cliente` (`clientFk`), KEY `clientObservation_created_IDX` (`created`) USING BTREE, + KEY `clientObservation_fk_editor` (`editorFk`), + 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 ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientObservation_beforeInsert` + BEFORE INSERT ON `clientObservation` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientObservation_beforeUpdate` + BEFORE UPDATE ON `clientObservation` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientObservation_afterDelete` + AFTER DELETE ON `clientObservation` + FOR EACH ROW +BEGIN + INSERT INTO clientLog + SET `action` = 'delete', + `changedModel` = 'ClientObservation', + `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 */ ; -- -- Table structure for table `clientPackagingGifts` @@ -24134,11 +25103,78 @@ CREATE TABLE `clientSample` ( `balance` float NOT NULL, `companyFk` smallint(5) unsigned DEFAULT NULL, `userFk` int(11) DEFAULT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `empresa_id` (`companyFk`), + KEY `clientSample_fk_editor` (`editorFk`), + CONSTRAINT `clientSample_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `clientSample_ibfk_1` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientSample_beforeInsert` + BEFORE INSERT ON `clientSample` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientSample_beforeUpdate` + BEFORE UPDATE ON `clientSample` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientSample_afterDelete` + AFTER DELETE ON `clientSample` + FOR EACH ROW +BEGIN + INSERT INTO clientLog + SET `action` = 'delete', + `changedModel` = 'ClientSample', + `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 */ ; -- -- Table structure for table `clientType` @@ -24531,6 +25567,46 @@ CREATE TABLE `collectionVolumetry` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `collectionWagon` +-- + +DROP TABLE IF EXISTS `collectionWagon`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `collectionWagon` ( + `collectionFk` int(11) NOT NULL, + `wagonFk` int(11) NOT NULL, + `position` int(11) unsigned NOT NULL, + PRIMARY KEY (`collectionFk`,`position`), + UNIQUE KEY `collectionWagon_unique` (`collectionFk`,`wagonFk`), + KEY `collectionWagon_wagon` (`wagonFk`), + CONSTRAINT `collectionWagon_collection` FOREIGN KEY (`collectionFk`) REFERENCES `collection` (`id`) ON UPDATE CASCADE, + CONSTRAINT `collectionWagon_wagon` FOREIGN KEY (`wagonFk`) REFERENCES `wagon` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `collectionWagonTicket` +-- + +DROP TABLE IF EXISTS `collectionWagonTicket`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `collectionWagonTicket` ( + `ticketFk` int(11) NOT NULL, + `wagonFk` int(11) NOT NULL, + `trayFk` int(11) unsigned NOT NULL, + `side` set('L','R') DEFAULT NULL, + PRIMARY KEY (`ticketFk`), + KEY `collectionWagonTicket_wagon` (`wagonFk`), + KEY `collectionWagonTicket_tray` (`trayFk`), + CONSTRAINT `collectionWagonTicket_ticket` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON UPDATE CASCADE, + CONSTRAINT `collectionWagonTicket_tray` FOREIGN KEY (`trayFk`) REFERENCES `wagonTypeTray` (`id`) ON UPDATE CASCADE, + CONSTRAINT `collectionWagonTicket_wagon` FOREIGN KEY (`wagonFk`) REFERENCES `wagon` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `commissionConfig` -- @@ -24592,6 +25668,7 @@ CREATE TABLE `company` ( `footnotes` longtext DEFAULT NULL COMMENT 'pie de paginas en las facturas', `phytosanitary` longtext DEFAULT NULL, `fhAdminNumber` int(11) DEFAULT NULL COMMENT 'número de cliente en FloraHolland', + `web` varchar(100) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `companyCode_UNIQUE` (`code`), KEY `gerente_id` (`workerManagerFk`), @@ -24620,6 +25697,36 @@ CREATE TABLE `companyGroup` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `companyI18n` +-- + +DROP TABLE IF EXISTS `companyI18n`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `companyI18n` ( + `companyFk` smallint(5) unsigned NOT NULL, + `lang` char(2) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, + `footnotes` longtext DEFAULT NULL, + PRIMARY KEY (`companyFk`,`lang`), + CONSTRAINT `companyI18n_FK` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `companyL10n` +-- + +DROP TABLE IF EXISTS `companyL10n`; +/*!50001 DROP VIEW IF EXISTS `companyL10n`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `companyL10n` ( + `id` tinyint NOT NULL, + `footnotes` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `comparativeFilterType` -- @@ -24728,12 +25835,14 @@ CREATE TABLE `config` ( `meterPrice` decimal(10,1) DEFAULT NULL, `kmPrice` decimal(10,1) DEFAULT NULL, `routeOption` int(11) DEFAULT 1, - `dbproduccion` tinyint(1) NOT NULL DEFAULT 1, + `dbproduccion` tinyint(1) NOT NULL DEFAULT 0, `mdbServer` varchar(255) NOT NULL, `fakeEmail` varchar(255) DEFAULT NULL, `defaultersMaxAmount` int(10) DEFAULT 200 COMMENT 'maxima deuda permitida a partir de la cual se bloquea a un usuario', `ASIEN` bigint(20) DEFAULT NULL, `dayStartingHour` int(11) NOT NULL DEFAULT 3 COMMENT 'Hora a la que empieza una nueva jornada de producción', + `comparativeLastBuyScope` int(11) DEFAULT NULL COMMENT 'Rango en el que se busca la última entrada de un artículo', + `mainWarehouseFk` smallint(6) unsigned NOT NULL DEFAULT 60, PRIMARY KEY (`id`), KEY `fechainv_idx` (`inventoried`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -25400,10 +26509,10 @@ CREATE TABLE `delivery` ( `longitude` decimal(11,7) DEFAULT NULL, `latitude` decimal(11,7) DEFAULT NULL, `dated` datetime DEFAULT NULL, - `addressFk` int(11) NOT NULL, + `ticketFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), - KEY `delivery_FK` (`addressFk`), - CONSTRAINT `delivery_FK` FOREIGN KEY (`addressFk`) REFERENCES `address` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + KEY `delivery_ticketFk_FK` (`ticketFk`), + CONSTRAINT `delivery_ticketFk_FK` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Informa de los datos geográficos y temporales de las entregas de los repartidores'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -25722,48 +26831,6 @@ CREATE TABLE `deviceProduction` ( CONSTRAINT `deviceProduction_FK` FOREIGN KEY (`stateFk`) REFERENCES `deviceProductionState` (`code`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProduction_afterInsert` - AFTER INSERT - ON deviceProduction FOR EACH ROW -BEGIN - INSERT INTO deviceProductionLog (originFk, userFk, newInstance, action, changedModel, changedModelId) - VALUES(NEW.id, account.myUser_getId(), NEW.stateFk, 'INSERT', 'deviceProduction', NEW.id); -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProduction_afterUpdate` - BEFORE UPDATE - ON vn.deviceProduction FOR EACH ROW -BEGIN - INSERT INTO deviceProductionLog (originFk, userFk, newInstance, oldInstance , action, changedModel, changedModelId) - VALUES(OLD.id, account.myUser_getId(), NEW.stateFk, OLD.stateFk , 'update', 'deviceProduction', OLD.id); -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -- -- Table structure for table `deviceProductionConfig` @@ -25872,35 +26939,6 @@ CREATE TABLE `deviceProductionUser` ( CONSTRAINT `deviceProductionUser_PK` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionUser_afterDelete` - AFTER DELETE - ON deviceProductionUser FOR EACH ROW -BEGIN - INSERT INTO deviceProductionLog (originFk, userFk, oldInstance, action, changedModel, changedModelId) - SELECT - OLD.deviceProductionFk, - account.myUser_getId(), - stateFk, - 'DELETE', - 'deviceProductionUser', - OLD.deviceProductionFk - FROM deviceProduction - WHERE id = OLD.deviceProductionFk; -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -- -- Table structure for table `disabilityGrade` @@ -26056,24 +27094,6 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; --- --- Table structure for table `dmsRecover` --- - -DROP TABLE IF EXISTS `dmsRecover`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `dmsRecover` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `ticketFk` int(11) DEFAULT NULL, - `sign` text DEFAULT NULL, - `created` timestamp NULL DEFAULT current_timestamp(), - PRIMARY KEY (`id`), - KEY `ticketFk_idx` (`ticketFk`), - CONSTRAINT `ticketFk` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `dmsType` -- @@ -26495,7 +27515,6 @@ CREATE TABLE `entry` ( `invoiceNumber` varchar(50) DEFAULT NULL, `isBooked` tinyint(1) NOT NULL DEFAULT 0, `isExcludedFromAvailable` tinyint(1) NOT NULL DEFAULT 0, - `notes` longtext DEFAULT NULL, `isConfirmed` tinyint(1) NOT NULL DEFAULT 0, `isOrdered` tinyint(1) NOT NULL DEFAULT 0, `isRaid` tinyint(1) NOT NULL DEFAULT 0, @@ -26517,8 +27536,9 @@ CREATE TABLE `entry` ( `buyerFk` int(10) unsigned DEFAULT NULL, `typeFk` varchar(100) DEFAULT NULL COMMENT 'Tipo de entrada', `reference` varchar(50) DEFAULT NULL COMMENT 'Referencia para eti', - `ref` varchar(50) GENERATED ALWAYS AS (`invoiceNumber`) VIRTUAL COMMENT 'Columna virtual provisional para Salix', - `observationEditorFk` INT(10) unsigned NULL COMMENT 'Último usuario que ha modificado el campo evaNotes', + `observationEditorFk` int(10) unsigned DEFAULT NULL COMMENT 'Último usuario que ha modificado el campo evaNotes', + `clonedFrom` int(11) DEFAULT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `Id_Proveedor` (`supplierFk`), KEY `Fecha` (`dated`), @@ -26528,13 +27548,16 @@ CREATE TABLE `entry` ( KEY `recibida_id` (`invoiceInFk`), KEY `entry_FK` (`buyerFk`), KEY `entry_FK_1` (`typeFk`), + KEY `entry_observationEditorFk` (`observationEditorFk`), + KEY `entry_fk_editor` (`editorFk`), CONSTRAINT `Entradas_fk8` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `entry_FK` FOREIGN KEY (`buyerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `entry_FK_1` FOREIGN KEY (`typeFk`) REFERENCES `entryType` (`code`) ON UPDATE CASCADE, + CONSTRAINT `entry_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `entry_ibfk_1` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE, CONSTRAINT `entry_ibfk_6` FOREIGN KEY (`travelFk`) REFERENCES `travel` (`id`) ON UPDATE CASCADE, CONSTRAINT `entry_ibfk_7` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE, - CONSTRAINT `entry_observationEditorFk` FOREIGN KEY (`observationEditorFk`) REFERENCES `account`.`user`(`id`) ON UPDATE CASCADE + CONSTRAINT `entry_observationEditorFk` FOREIGN KEY (`observationEditorFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='InnoDB free: 88064 kB; (`Id_Proveedor`) REFER `vn2008/Provee'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -26550,9 +27573,11 @@ DELIMITER ;; BEFORE INSERT ON `entry` FOR EACH ROW BEGIN - CALL supplier_checkIsActive(NEW.supplierFk); - SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk); - SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk,NEW.supplierFk); + SET NEW.editorFk = account.myUser_getId(); + CALL supplier_checkIsActive(NEW.supplierFk); + SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk); + SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk,NEW.supplierFk); + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -26592,9 +27617,11 @@ DELIMITER ;; BEFORE UPDATE ON `entry` FOR EACH ROW BEGIN - DECLARE vIsVirtual BOOL; - DECLARE vPrintedCount INT; - DECLARE vHasDistinctWarehouses BOOL; + DECLARE vIsVirtual BOOL; + DECLARE vPrintedCount INT; + DECLARE vHasDistinctWarehouses BOOL; + + SET NEW.editorFk = account.myUser_getId(); IF !(NEW.travelFk <=> OLD.travelFk) THEN SELECT COUNT(*) > 0 INTO vIsVirtual @@ -26612,35 +27639,35 @@ BEGIN SET MESSAGE_TEXT = 'A cloned entry cannot be moved to a travel with different warehouses'; END IF; - IF NEW.travelFk IS NULL THEN + IF NEW.travelFk IS NULL THEN SELECT COUNT(*) INTO vPrintedCount FROM buy - WHERE entryFk = OLD.id + WHERE entryFk = OLD.id AND printedStickers > 0; IF vPrintedCount > 0 THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'An entry that contains lines with printed labels cannot be deleted'; END IF; - END IF; + END IF; END IF; - IF !(NEW.supplierFk <=> OLD.supplierFk) THEN + IF NOT (NEW.supplierFk <=> OLD.supplierFk) THEN CALL supplier_checkIsActive(NEW.supplierFk); SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk); END IF; - IF !(NEW.travelFk <=> OLD.travelFk) - OR !(NEW.currencyFk <=> OLD.currencyFk) THEN + IF NOT (NEW.travelFk <=> OLD.travelFk) + OR NOT (NEW.currencyFk <=> OLD.currencyFk) THEN SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk,NEW.supplierFk); END IF; - IF !(ABS(NEW.isBooked) <=> ABS(OLD.isBooked)) THEN + IF NOT (ABS(NEW.isBooked) <=> ABS(OLD.isBooked)) THEN INSERT INTO entryLog SET action = 'update', - description = 'Cambia a Contabilizada', - userFk = account.myUser_getId(), - originFk = NEW.id; + description = 'Cambia a Contabilizada', + userFk = account.myUser_getId(), + originFk = NEW.id; END IF; END */;; DELIMITER ; @@ -26661,26 +27688,16 @@ DELIMITER ;; AFTER UPDATE ON `entry` FOR EACH ROW BEGIN - IF !(NEW.id <=> OLD.id) - OR !(NEW.travelFk <=> OLD.travelFk) - OR !(NEW.isRaid <=> OLD.isRaid) THEN + IF NOT(NEW.id <=> OLD.id) + OR NOT(NEW.travelFk <=> OLD.travelFk) + OR NOT(NEW.isRaid <=> OLD.isRaid) THEN CALL stock.log_add('entry', NEW.id, OLD.id); END IF; - IF !(NEW.travelFk <=> OLD.travelFk) THEN + IF NOT (NEW.travelFk <=> OLD.travelFk) THEN CALL travel_requestRecalc(OLD.travelFk); CALL travel_requestRecalc(NEW.travelFk); END IF; - - IF NOT (NEW.invoiceAmount <=> OLD.invoiceAmount) THEN - INSERT INTO vn.entryLog SET - `action` = 'update', - userFk = account.myUser_getId(), - originFk = NEW.id, - changedModel = 'Entry', - oldInstance = CONCAT('{"old invoiceAmount":', OLD.invoiceAmount, '}'), - newInstance = CONCAT('{"new invoiceAmount":', NEW.invoiceAmount, '}'); - END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -26720,6 +27737,12 @@ DELIMITER ;; AFTER DELETE ON `entry` FOR EACH ROW BEGIN + INSERT INTO entryLog + SET `action` = 'delete', + `changedModel` = 'Entry', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); + CALL travel_requestRecalc(OLD.travelFk); END */;; DELIMITER ; @@ -26752,8 +27775,8 @@ DROP TABLE IF EXISTS `entryLog`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `entryLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `originFk` int(11) NOT NULL, - `userFk` int(10) unsigned NOT NULL, + `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, @@ -26765,6 +27788,7 @@ CREATE TABLE `entryLog` ( PRIMARY KEY (`id`), KEY `logEntry_ibfk_1` (`originFk`), KEY `entryLog_ibfk_2` (`userFk`), + KEY `entryLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), CONSTRAINT `entryLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `entry` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `entryLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -26782,13 +27806,80 @@ CREATE TABLE `entryObservation` ( `entryFk` int(11) NOT NULL, `observationTypeFk` tinyint(3) unsigned DEFAULT NULL, `description` text DEFAULT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `entryFk_observationTypeFk_UNIQUE` (`entryFk`,`observationTypeFk`), KEY `observationType_id_observationTypeFk` (`observationTypeFk`), + KEY `entryObservation_fk_editor` (`editorFk`), + CONSTRAINT `entryObservation_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `entry_id_entryFk` FOREIGN KEY (`entryFk`) REFERENCES `entry` (`id`), CONSTRAINT `observationType_id_observationTypeFk` FOREIGN KEY (`observationTypeFk`) REFERENCES `observationType` (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entryObservation_beforeInsert` + BEFORE INSERT ON `entryObservation` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entryObservation_beforeUpdate` + BEFORE UPDATE ON `entryObservation` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entryObservation_afterDelete` + AFTER DELETE ON `entryObservation` + FOR EACH ROW +BEGIN + INSERT INTO entryLog + SET `action` = 'delete', + `changedModel` = 'EntryObservation', + `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 */ ; -- -- Table structure for table `entryType` @@ -27039,6 +28130,7 @@ CREATE TABLE `expedition` ( `stateTypeFk` int(11) DEFAULT NULL COMMENT 'Ultimo estado de la expedicion', `hasNewRoute` bit(1) NOT NULL DEFAULT b'0', `isBox` int(11) GENERATED ALWAYS AS (`freightItemFk`) VIRTUAL COMMENT 'Columna virtual provisional para Salix', + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `index1` (`agencyModeFk`), KEY `index2` (`freightItemFk`), @@ -27048,10 +28140,12 @@ CREATE TABLE `expedition` ( KEY `expedition_itemPackingTypeFk` (`itemPackingTypeFk`), KEY `workerFk` (`workerFk`), KEY `expedition_FK` (`stateTypeFk`), + KEY `expedition_fk_editor` (`editorFk`), CONSTRAINT `expedition_FK` FOREIGN KEY (`stateTypeFk`) REFERENCES `expeditionStateType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `expedition_fk1` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE, CONSTRAINT `expedition_fk2` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `expedition_fk3` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE, + CONSTRAINT `expedition_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `expedition_ibfk_1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`), CONSTRAINT `expedition_itemPackingTypeFk` FOREIGN KEY (`itemPackingTypeFk`) REFERENCES `itemPackingType` (`code`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -27072,6 +28166,8 @@ BEGIN DECLARE intcounter INT; DECLARE vShipFk INT; + SET NEW.editorFk = account.myUser_getId(); + IF NEW.freightItemFk IS NOT NULL THEN UPDATE ticket SET packages = nz(packages) + 1 WHERE id = NEW.ticketFk; @@ -27106,6 +28202,8 @@ DELIMITER ;; BEFORE UPDATE ON `expedition` FOR EACH ROW BEGIN + SET NEW.editorFk = account.myUser_getId(); + IF NEW.counter <> OLD.counter THEN IF (SELECT COUNT(*) FROM expedition e INNER JOIN ticket t1 ON e.ticketFk = t1.id @@ -27144,6 +28242,30 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expedition_afterDelete` + AFTER DELETE ON `expedition` + FOR EACH ROW +BEGIN + INSERT INTO ticketLog + SET `action` = 'delete', + `changedModel` = 'Expedition', + `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 */ ; -- -- Table structure for table `expeditionBoxVol` @@ -27684,6 +28806,90 @@ CREATE TABLE `expence` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `farming` +-- + +DROP TABLE IF EXISTS `farming`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `farming` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(100) NOT NULL, + `location` varchar(255) NOT NULL, + `warehouseFk` smallint(6) unsigned NOT NULL, + `description` text DEFAULT NULL, + `photo` blob DEFAULT NULL, + `isActive` tinyint(1) NOT NULL DEFAULT 1, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `companyFk` smallint(5) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `farming_FK` (`warehouseFk`), + KEY `farming_FK_1` (`companyFk`), + CONSTRAINT `farming_FK` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, + CONSTRAINT `farming_FK_1` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `farmingDms` +-- + +DROP TABLE IF EXISTS `farmingDms`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `farmingDms` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `farmingFk` int(10) unsigned NOT NULL, + `dmsFk` int(11) NOT NULL, + PRIMARY KEY (`id`), + KEY `farmingDms_FK` (`farmingFk`), + KEY `farmingDms_FK_1` (`dmsFk`), + CONSTRAINT `farmingDms_FK` FOREIGN KEY (`farmingFk`) REFERENCES `farming` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `farmingDms_FK_1` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `farmingInvoiceIn` +-- + +DROP TABLE IF EXISTS `farmingInvoiceIn`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `farmingInvoiceIn` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `farmingFk` int(10) unsigned NOT NULL, + `invoiceInFk` mediumint(8) unsigned NOT NULL, + `amount` decimal(10,2) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `farmingInvoiceIn_FK` (`invoiceInFk`), + KEY `farmingInvoiceIn_FK_1` (`farmingFk`), + CONSTRAINT `farmingInvoiceIn_FK` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`), + CONSTRAINT `farmingInvoiceIn_FK_1` FOREIGN KEY (`farmingFk`) REFERENCES `farming` (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `farmingNotes` +-- + +DROP TABLE IF EXISTS `farmingNotes`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `farmingNotes` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `farmingFk` int(10) unsigned NOT NULL, + `note` text NOT NULL, + `userFk` int(10) unsigned NOT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `farmingNotes_FK_1` (`farmingFk`), + CONSTRAINT `farmingNotes_FK` FOREIGN KEY (`id`) REFERENCES `account`.`user` (`id`), + CONSTRAINT `farmingNotes_FK_1` FOREIGN KEY (`farmingFk`) REFERENCES `farming` (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Temporary table structure for view `firstTicketShipped` -- @@ -27757,6 +28963,20 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +-- +-- Table structure for table `franceExpressConfig` +-- + +DROP TABLE IF EXISTS `franceExpressConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `franceExpressConfig` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `path` varchar(100) DEFAULT '\\\\server\\agencies\\franceexpress\\expeditions', + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `fuelType` -- @@ -27856,10 +29076,29 @@ CREATE TABLE `glsConfig` ( `package` int(1) DEFAULT NULL, `refund` int(1) DEFAULT NULL, `weight` int(1) DEFAULT NULL, + `density` int(11) NOT NULL DEFAULT 42, PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `glsExpedition` +-- + +DROP TABLE IF EXISTS `glsExpedition`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `glsExpedition` ( + `expeditionFk` int(11) NOT NULL, + `barcode` varchar(20) DEFAULT NULL, + `uid` varchar(45) DEFAULT NULL COMMENT 'Valor retornado por GLS al hacer pertición al webservice', + `codexp` int(11) DEFAULT NULL COMMENT 'Valor retornado por GLS al hacer pertición al webservice', + `created` timestamp NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`expeditionFk`), + CONSTRAINT `glsExpedition_FK` FOREIGN KEY (`expeditionFk`) REFERENCES `expedition` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `greuge` -- @@ -27877,14 +29116,17 @@ CREATE TABLE `greuge` ( `greugeTypeFk` int(11) DEFAULT NULL, `ticketFk` int(11) DEFAULT NULL, `userFk` int(10) unsigned DEFAULT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`Id`), KEY `greuges_type_fk_idx` (`greugeTypeFk`), KEY `Id_Ticket_Greuge_Ticket_idx` (`ticketFk`), KEY `Greuges_cliente_idx` (`clientFk`), KEY `greuge_shipped_IDX` (`shipped`) USING BTREE, KEY `greuge_FK` (`userFk`), + KEY `greuge_fk_editor` (`editorFk`), CONSTRAINT `Id_Ticket_Greuge_Ticket` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `greuge_FK` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `greuge_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `greuges_type_fk` FOREIGN KEY (`greugeTypeFk`) REFERENCES `greugeType` (`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci ROW_FORMAT=COMPACT; /*!40101 SET character_set_client = @saved_cs_client */; @@ -27910,6 +29152,70 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`greuge_beforeInsert` + BEFORE INSERT ON `greuge` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`greuge_beforeUpdate` + BEFORE UPDATE ON `greuge` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`greuge_afterDelete` + AFTER DELETE ON `greuge` + FOR EACH ROW +BEGIN + INSERT INTO clientLog + SET `action` = 'delete', + `changedModel` = 'Greuge', + `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 */ ; -- -- Table structure for table `greugeConfig` @@ -27922,6 +29228,8 @@ CREATE TABLE `greugeConfig` ( `id` int(11) NOT NULL AUTO_INCREMENT, `freightPickUpPrice` decimal(10,2) NOT NULL, `yearsToDelete` int(11) DEFAULT NULL, + `maxPercentToWrong` decimal(10,2) DEFAULT NULL COMMENT 'Porcentaje del precio del ticket que es considerado error', + `lastNotifyCheck` timestamp NULL DEFAULT NULL COMMENT 'Última ejecución del procedimiento que revisa los greuges anormales', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -28250,6 +29558,7 @@ CREATE TABLE `invoiceIn` ( `isVatDeductible` tinyint(1) NOT NULL DEFAULT 1, `withholdingSageFk` smallint(6) DEFAULT NULL COMMENT 'Tipos de retención SAGE', `expenceFkDeductible` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `proveedor_id` (`supplierFk`), KEY `empresa_id` (`companyFk`), @@ -28264,7 +29573,9 @@ CREATE TABLE `invoiceIn` ( KEY `recibida_ibfk_7` (`cplusTrascendency472Fk`), KEY `invoiceIn_withholdingFk_idx` (`withholdingSageFk`), KEY `invoiceIn_expenceFkDeductible_idx` (`expenceFkDeductible`), + KEY `invoiceIn_fk_editor` (`editorFk`), CONSTRAINT `invoiceIn_expenceFkDeductible` FOREIGN KEY (`expenceFkDeductible`) REFERENCES `expence` (`id`) ON UPDATE CASCADE, + CONSTRAINT `invoiceIn_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `invoiceIn_ibfk_1` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoiceIn_ibfk_2` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoiceIn_ibfk_3` FOREIGN KEY (`cplusSubjectOpFk`) REFERENCES `cplusSubjectOp` (`id`) ON UPDATE CASCADE, @@ -28294,6 +29605,8 @@ BEGIN DECLARE vActive TINYINT; DECLARE vWithholdingSageFk INT; + SET NEW.editorFk = account.myUser_getId(); + SELECT withholdingSageFk INTO vWithholdingSageFk FROM vn.supplier WHERE id = NEW.supplierFk; @@ -28361,6 +29674,8 @@ BEGIN DECLARE vWithholdingSageFk INT; + SET NEW.editorFk = account.myUser_getId(); + IF (SELECT COUNT(*) FROM vn.invoiceIn WHERE supplierRef = NEW.supplierRef AND supplierFk = NEW.supplierFk @@ -28423,6 +29738,30 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceIn_afterDelete` + AFTER DELETE ON `invoiceIn` + FOR EACH ROW +BEGIN + INSERT INTO invoiceInLog + SET `action` = 'delete', + `changedModel` = 'InvoiceIn', + `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 */ ; -- -- Table structure for table `invoiceInConfig` @@ -28436,6 +29775,7 @@ CREATE TABLE `invoiceInConfig` ( `retentionRate` int(3) NOT NULL, `retentionName` varchar(25) NOT NULL, `sageWithholdingFk` smallint(6) NOT NULL, + `daysAgo` int(10) unsigned DEFAULT 45 COMMENT 'Días en el pasado para mostrar facturas en invoiceIn series en salix', PRIMARY KEY (`id`), KEY `invoiceInConfig_sageWithholdingFk` (`sageWithholdingFk`), CONSTRAINT `invoiceInConfig_sageWithholdingFk` FOREIGN KEY (`sageWithholdingFk`) REFERENCES `sage`.`TiposRetencion` (`CodigoRetencion`) ON DELETE CASCADE ON UPDATE CASCADE @@ -28579,7 +29919,7 @@ DROP TABLE IF EXISTS `invoiceInLog`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `invoiceInLog` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `originFk` mediumint(8) unsigned NOT NULL, + `originFk` mediumint(8) unsigned DEFAULT NULL, `userFk` int(10) unsigned DEFAULT NULL, `action` set('insert','update','delete') NOT NULL, `creationDate` timestamp NULL DEFAULT current_timestamp(), @@ -28594,7 +29934,7 @@ CREATE TABLE `invoiceInLog` ( KEY `userFk` (`userFk`), CONSTRAINT `invoiceInLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceInLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28667,18 +30007,85 @@ CREATE TABLE `invoiceInTax` ( `taxTypeSageFk` smallint(6) DEFAULT NULL COMMENT 'Tipo de IVA SAGE', `transactionTypeSageFk` tinyint(4) DEFAULT NULL COMMENT 'Tipo de transacción SAGE', `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `recibida_id` (`invoiceInFk`), KEY `recibida_iva_ibfk_2` (`taxCodeFk`), KEY `recibida_iva_taxTypeSageFk` (`taxTypeSageFk`), KEY `invoiceInTax_transactionTypeSageFk_idx` (`transactionTypeSageFk`), KEY `invoiceInTax_idx` (`expenceFk`), + KEY `invoiceInTax_fk_editor` (`editorFk`), CONSTRAINT `invoiceInTax_expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `expence` (`id`) ON UPDATE CASCADE, + CONSTRAINT `invoiceInTax_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `invoiceInTax_ibfk_5` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceInTax_transactionTypeSageFk` FOREIGN KEY (`transactionTypeSageFk`) REFERENCES `sage`.`TiposTransacciones` (`CodigoTransaccion`) ON UPDATE CASCADE, CONSTRAINT `recibida_iva_taxTypeSageFk` FOREIGN KEY (`taxTypeSageFk`) REFERENCES `sage`.`TiposIva` (`CodigoIva`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceInTax_beforeInsert` + BEFORE INSERT ON `invoiceInTax` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceInTax_beforeUpdate` + BEFORE UPDATE ON `invoiceInTax` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceInTax_afterDelete` + AFTER DELETE ON `invoiceInTax` + FOR EACH ROW +BEGIN + INSERT INTO invoiceInLog + SET `action` = 'delete', + `changedModel` = 'InvoiceInTax', + `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 */ ; -- -- Table structure for table `invoiceInTaxBookingAccount` @@ -28798,29 +30205,17 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET character_set_client = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceOut_afterInsert` AFTER INSERT ON `invoiceOut` FOR EACH ROW BEGIN CALL clientRisk_update(NEW.clientFk, NEW.companyFk, NEW.amount); - IF (SELECT COUNT(*) - FROM client - WHERE id = NEW.clientFk - AND businessTypeFk = 'officialOrganism' - ) THEN - CALL mail_insert('administracion@verdnatura.es', - NULL, - CONCAT('Se ha emitido una factura al organismo: ', NEW.clientFk), - CONCAT('Presentar factura en FACE https://salix.verdnatura.es/#!/invoice-out/', - NEW.id, - '/summary')); - END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -28906,6 +30301,7 @@ CREATE TABLE `invoiceOutSerial` ( `cplusInvoiceType477Fk` int(10) unsigned DEFAULT 1, `footNotes` longtext DEFAULT NULL, `isRefEditable` tinyint(4) NOT NULL DEFAULT 0, + `type` enum('global','quick') DEFAULT NULL, PRIMARY KEY (`code`), KEY `taxAreaFk_idx` (`taxAreaFk`), CONSTRAINT `invoiceOutSeriaTaxArea` FOREIGN KEY (`taxAreaFk`) REFERENCES `taxArea` (`code`) ON UPDATE CASCADE @@ -29025,6 +30421,7 @@ CREATE TABLE `item` ( `isLaid` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Indica si el producto se puede tumbar a efectos del transporte desde Holanda', `lastUsed` datetime DEFAULT current_timestamp(), `weightByPiece` int(10) unsigned DEFAULT NULL COMMENT 'peso por defecto para un articulo por tallo/unidad', + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `item_supplyResponseFk_idx` (`supplyResponseFk`), KEY `Color` (`inkFk`), @@ -29043,10 +30440,12 @@ CREATE TABLE `item` ( KEY `item_size_IDX2` (`longName`) USING BTREE, KEY `item_lastUsed_IDX` (`lastUsed`) USING BTREE, KEY `item_expenceFk_idx` (`expenceFk`), + KEY `item_fk_editor` (`editorFk`), CONSTRAINT `item_FK` FOREIGN KEY (`genericFk`) REFERENCES `item` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `item_FK_1` FOREIGN KEY (`typeFk`) REFERENCES `itemType` (`id`), CONSTRAINT `item_expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `expence` (`id`) ON UPDATE CASCADE, CONSTRAINT `item_family` FOREIGN KEY (`family`) REFERENCES `itemFamily` (`code`) ON UPDATE CASCADE, + CONSTRAINT `item_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `item_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `origin` (`id`) ON UPDATE CASCADE, CONSTRAINT `item_ibfk_2` FOREIGN KEY (`intrastatFk`) REFERENCES `intrastat` (`id`) ON UPDATE CASCADE, CONSTRAINT `itemsupplyResponseFk` FOREIGN KEY (`supplyResponseFk`) REFERENCES `edi`.`supplyResponse` (`ID`) ON DELETE SET NULL ON UPDATE CASCADE, @@ -29068,14 +30467,14 @@ DELIMITER ;; BEGIN DECLARE vItemPackingType VARCHAR(1); - IF NEW.itemPackingTypeFk IS NULL THEN + SET NEW.editorFk = account.myUser_getId(); + IF NEW.itemPackingTypeFk IS NULL THEN SELECT itemPackingTypeFk INTO vItemPackingType FROM vn.itemType it WHERE id = NEW.typeFk; SET NEW.itemPackingTypeFk = vItemPackingType; - END IF; END */;; DELIMITER ; @@ -29088,30 +30487,24 @@ DELIMITER ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`item_afterInsert` AFTER INSERT ON `item` FOR EACH ROW BEGIN - CALL hedera.image_ref('catalog', NEW.image); - INSERT INTO vn.itemTaxCountry(itemFk, countryFk) - SELECT NEW.id, 1; - - INSERT INTO vn.itemTaxCountry(itemFk, countryFk) - SELECT NEW.id, 5; - - INSERT INTO vn.itemTaxCountry(itemFk, countryFk) - SELECT NEW.id, 30; + INSERT INTO vn.itemTaxCountry(itemFk, countryFk) VALUES + (NEW.id, 1), + (NEW.id, 5), + (NEW.id, 30); DELETE ifr.* FROM edi.item_free ifr WHERE ifr.id = NEW.id; - END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -29131,25 +30524,21 @@ DELIMITER ;; BEFORE UPDATE ON `item` FOR EACH ROW BEGIN - DECLARE vNewPackingShelve INT; - IF ISNULL(NEW.packingShelve) AND NOT ISNULL(NEW.packingOut) THEN + SET NEW.editorFk = account.myUser_getId(); + IF ISNULL(NEW.packingShelve) AND NOT ISNULL(NEW.packingOut) THEN SELECT NEW.packingOut * vc.shelveVolume / vc.standardFlowerBox INTO vNewPackingShelve FROM vn.volumeConfig vc; SET NEW.packingShelve = vNewPackingShelve; - END IF; IF NEW.itemPackingTypeFk = '' THEN - SET NEW.itemPackingTypeFk = NULL; - END IF; - END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -29159,11 +30548,11 @@ 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 = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`item_afterUpdate` AFTER UPDATE ON `item` @@ -29195,8 +30584,8 @@ BEGIN CALL hedera.image_unref('catalog', OLD.image); IF OLD.isFloramondo THEN - INSERT IGNORE edi.item_free (id) - VALUES (OLD.id); + INSERT IGNORE edi.item_free + SET id = OLD.id; END IF; END */;; DELIMITER ; @@ -29216,13 +30605,80 @@ CREATE TABLE `itemBarcode` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `itemFk` int(11) NOT NULL, `code` varchar(22) NOT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `code` (`code`), UNIQUE KEY `Id_Article_2` (`itemFk`,`code`), KEY `Id_Article` (`itemFk`), + KEY `itemBarcode_fk_editor` (`editorFk`), + CONSTRAINT `itemBarcode_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `itemBarcode_ibfk_1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemBarcode_beforeInsert` + BEFORE INSERT ON `itemBarcode` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemBarcode_beforeUpdate` + BEFORE UPDATE ON `itemBarcode` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemBarcode_afterDelete` + AFTER DELETE ON `itemBarcode` + FOR EACH ROW +BEGIN + INSERT INTO itemLog + SET `action` = 'delete', + `changedModel` = 'ItemBarcode', + `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 */ ; -- -- Table structure for table `itemBotanical` @@ -29235,14 +30691,81 @@ CREATE TABLE `itemBotanical` ( `itemFk` int(11) NOT NULL, `genusFk` int(11) NOT NULL, `specieFk` int(11) DEFAULT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`itemFk`), KEY `genusFgn_idx` (`genusFk`), KEY `specieFgn_idx` (`specieFk`), + KEY `itemBotanical_fk_editor` (`editorFk`), CONSTRAINT `itemBotanicalItemFkFk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemBotanical_FK` FOREIGN KEY (`specieFk`) REFERENCES `specie` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `itemBotanical_FK_1` FOREIGN KEY (`genusFk`) REFERENCES `genus` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `itemBotanical_FK_1` FOREIGN KEY (`genusFk`) REFERENCES `genus` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `itemBotanical_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Sustituye a antiguo NomBotanic de Articles'; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemBotanical_beforeInsert` + BEFORE INSERT ON `itemBotanical` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemBotanical_beforeUpdate` + BEFORE UPDATE ON `itemBotanical` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemBotanical_afterDelete` + AFTER DELETE ON `itemBotanical` + FOR EACH ROW +BEGIN + INSERT INTO itemLog + SET `action` = 'delete', + `changedModel` = 'ItemBotanical', + `changedModelId` = OLD.itemFk, + `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 */ ; -- -- Temporary table structure for view `itemBotanicalWithGenus` @@ -29382,6 +30905,7 @@ CREATE TABLE `itemConfig` ( `defaultTag` int(11) NOT NULL DEFAULT 56, `validPriorities` varchar(50) NOT NULL DEFAULT '[1,2,3]', `defaultPriority` int(11) NOT NULL DEFAULT 2, + `warehouseFk` smallint(6) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `itemConfig_FK` (`defaultTag`), CONSTRAINT `itemConfig_FK` FOREIGN KEY (`defaultTag`) REFERENCES `tag` (`id`) @@ -29407,6 +30931,7 @@ CREATE TABLE `itemCost` ( `wasted` decimal(10,4) NOT NULL DEFAULT 0.0000, `cm3delivery` int(11) NOT NULL DEFAULT 0, `grams` int(11) NOT NULL DEFAULT 0 COMMENT 'peso en gramos de una unidad de venta', + `created` timestamp NULL DEFAULT current_timestamp(), PRIMARY KEY (`itemFk`,`warehouseFk`), KEY `warehouse_id_rotacion_idx` (`warehouseFk`), CONSTRAINT `id_article_rotaci` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, @@ -29539,7 +31064,7 @@ DROP TABLE IF EXISTS `itemImageQueue`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `itemImageQueue` ( `itemFk` int(11) NOT NULL, - `url` varchar(255) DEFAULT NULL, + `url` varchar(255) NOT NULL, `error` text DEFAULT NULL, `attempts` int(11) DEFAULT 0, `created` timestamp NULL DEFAULT current_timestamp(), @@ -29591,7 +31116,7 @@ DROP TABLE IF EXISTS `itemLog`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `itemLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `originFk` int(11) NOT NULL, + `originFk` int(11) DEFAULT NULL, `userFk` int(10) unsigned DEFAULT NULL, `action` set('insert','update','delete') NOT NULL, `creationDate` timestamp NULL DEFAULT current_timestamp(), @@ -29604,6 +31129,8 @@ CREATE TABLE `itemLog` ( PRIMARY KEY (`id`), KEY `itemLogItemFk_idx` (`originFk`), KEY `itemLogUserFk_idx` (`userFk`), + KEY `itemLog_changedModel_idx` (`changedModel`,`changedModelId`) USING BTREE, + KEY `itemLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), CONSTRAINT `itemLogItemFk` FOREIGN KEY (`originFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemLogUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -30205,6 +31732,7 @@ CREATE TABLE `itemTag` ( `value` varchar(50) NOT NULL, `intValue` int(11) DEFAULT NULL, `priority` int(2) NOT NULL DEFAULT 0, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `itemTagItemUq` (`itemFk`,`tagFk`), UNIQUE KEY `itemTagItemPriority` (`itemFk`,`priority`), @@ -30212,8 +31740,10 @@ CREATE TABLE `itemTag` ( KEY `priorityItem` (`priority`,`itemFk`), KEY `value` (`value`), KEY `itemFk_2` (`itemFk`,`tagFk`,`intValue`), + KEY `itemTag_fk_editor` (`editorFk`), CONSTRAINT `itemTagItemFk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `itemTagTagFk` FOREIGN KEY (`tagFk`) REFERENCES `tag` (`id`) ON UPDATE CASCADE + CONSTRAINT `itemTagTagFk` FOREIGN KEY (`tagFk`) REFERENCES `tag` (`id`) ON UPDATE CASCADE, + CONSTRAINT `itemTag_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -30229,6 +31759,7 @@ DELIMITER ;; BEFORE INSERT ON `itemTag` FOR EACH ROW BEGIN + SET NEW.editorFk = account.myUser_getId(); SET NEW.intValue = itemTag_getIntValue(NEW.`value`); END */;; DELIMITER ; @@ -30284,6 +31815,8 @@ DELIMITER ;; BEFORE UPDATE ON `itemTag` FOR EACH ROW BEGIN + SET NEW.editorFk = account.myUser_getId(); + IF !(OLD.`value` <=> NEW.`value`) OR !(OLD.intValue <=> NEW.intValue) THEN SET NEW.intValue = itemTag_getIntValue(NEW.`value`); @@ -30346,6 +31879,12 @@ trig: BEGIN DECLARE vItemFk INT; DECLARE visTriggerDisabled BOOL; + INSERT INTO itemLog + SET `action` = 'delete', + `changedModel` = 'ItemTag', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); + SELECT isItemTagTriggerDisabled INTO visTriggerDisabled FROM vn.itemConfig; @@ -30392,15 +31931,122 @@ CREATE TABLE `itemTaxCountry` ( `countryFk` mediumint(8) unsigned DEFAULT NULL, `taxClassFk` tinyint(3) unsigned NOT NULL DEFAULT 1, `effectived` timestamp NOT NULL DEFAULT current_timestamp(), + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `itemFk_UNIQUE` (`itemFk`,`countryFk`), KEY `taxClassFK_idx` (`taxClassFk`), KEY `countryFK_paises_idx` (`countryFk`), + KEY `itemTaxCountry_fk_editor` (`editorFk`), CONSTRAINT `countryFK_paises` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE, CONSTRAINT `itemFK_Article` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `itemTaxCountry_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `taxClassFK_Iva_Group` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Define la clase de iva por artículo y pais'; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTaxCountry_beforeInsert` + BEFORE INSERT ON `itemTaxCountry` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierAccount_beforeInsert` + BEFORE INSERT ON `itemTaxCountry` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTaxCountry_beforeUpdate` + BEFORE UPDATE ON `itemTaxCountry` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierAccount_beforeUpdate` + BEFORE UPDATE ON `itemTaxCountry` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTaxCountry_afterDelete` + AFTER DELETE ON `itemTaxCountry` + FOR EACH ROW +BEGIN + INSERT INTO itemLog + SET `action` = 'delete', + `changedModel` = 'ItemTaxCountry', + `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 */ ; -- -- Temporary table structure for view `itemTicketOut` @@ -30431,7 +32077,7 @@ DROP TABLE IF EXISTS `itemType`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `itemType` ( - `id` smallint(5) unsigned NOT NULL, + `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, `code` varchar(3) NOT NULL, `name` varchar(30) NOT NULL, `gramsMax` int(11) DEFAULT NULL, @@ -30460,6 +32106,7 @@ CREATE TABLE `itemType` ( `isLaid` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Indica si el producto se puede tumbar a efectos del transporte desde Holanda', `maxRefs` int(10) unsigned DEFAULT NULL COMMENT 'Indica el número máximo de referencias', `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, PRIMARY KEY (`id`), UNIQUE KEY `Tipo_UNIQUE` (`name`,`categoryFk`), UNIQUE KEY `itemType_UN` (`code`), @@ -30473,7 +32120,7 @@ CREATE TABLE `itemType` ( CONSTRAINT `itemType_ibfk_1` FOREIGN KEY (`categoryFk`) REFERENCES `itemCategory` (`id`) ON UPDATE CASCADE, CONSTRAINT `temperatureFk` FOREIGN KEY (`temperatureFk`) REFERENCES `temperature` (`code`), CONSTRAINT `warehouseFk5` FOREIGN KEY (`warehouseFk__`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE -) 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.'; +) ENGINE=InnoDBDEFAULT 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 */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -31283,6 +32930,7 @@ CREATE TABLE `mrwService` ( `agencyModeCodeFk` varchar(45) NOT NULL, `clientType` int(11) unsigned NOT NULL, `serviceType` int(11) unsigned DEFAULT NULL, + `kg` int(11) DEFAULT NULL, PRIMARY KEY (`agencyModeCodeFk`), CONSTRAINT `mrwService_agencyModeCodeFk` FOREIGN KEY (`agencyModeCodeFk`) REFERENCES `agencyMode` (`code`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Configuración de los servicios de MRW'; @@ -31402,17 +33050,63 @@ CREATE TABLE `operator` ( `trainFk` int(11) NOT NULL DEFAULT 1, `itemPackingTypeFk` varchar(1) NOT NULL DEFAULT 'H', `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT 60, + `sectorFk` int(11) DEFAULT NULL, + `labelerFk` tinyint(3) unsigned DEFAULT NULL, PRIMARY KEY (`workerFk`), KEY `operator_FK` (`workerFk`), KEY `operator_FK_1` (`trainFk`), KEY `operator_FK_2` (`itemPackingTypeFk`), KEY `operator_FK_3` (`warehouseFk`), + KEY `operator_FK_5` (`labelerFk`), 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_3` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `operator_FK_5` FOREIGN KEY (`labelerFk`) REFERENCES `printer` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`operator_beforeInsert` + BEFORE INSERT ON `operator` + FOR EACH ROW +BEGIN + CALL vn.printer_checkSector(NEW.labelerFk, NEW.sectorFk); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`operator_beforeUpdate` + BEFORE UPDATE ON `operator` + FOR EACH ROW +BEGIN + IF NOT (NEW.labelerFk <=> OLD.labelerFk AND NEW.sectorFk <=> OLD.sectorFk) THEN + CALL vn.printer_checkSector(NEW.labelerFk, NEW.sectorFk); + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; -- -- Temporary table structure for view `operatorWorkerCode` @@ -31757,7 +33451,7 @@ DROP TABLE IF EXISTS `packingSite`; CREATE TABLE `packingSite` ( `id` int(11) NOT NULL AUTO_INCREMENT, `code` varchar(10) DEFAULT NULL, - `hostFk` int(11) NOT NULL, + `hostFk` int(11) DEFAULT NULL, `printerFk` tinyint(3) unsigned DEFAULT NULL, `collectionFk` int(11) DEFAULT NULL COMMENT 'Last collection packed on this site', `monitorId` varchar(255) DEFAULT NULL, @@ -32173,6 +33867,21 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +-- +-- Table structure for table `payrollCategories` +-- + +DROP TABLE IF EXISTS `payrollCategories`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `payrollCategories` ( + `id` int(11) NOT NULL, + `description` varchar(255) NOT NULL, + `rate` tinyint(4) NOT 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 `pcs` -- @@ -32514,6 +34223,7 @@ CREATE TABLE `ppe` ( `workerFk` int(10) unsigned DEFAULT NULL, `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, `description` varchar(45) DEFAULT NULL, + `isDone` tinyint(1) DEFAULT NULL, PRIMARY KEY (`id`), KEY `ppe_fk1_idx` (`workerFk`), KEY `ppe_fk2_idx` (`planFk`), @@ -32718,7 +34428,7 @@ CREATE TABLE `printQueue` ( `error` text DEFAULT NULL, `errorNumber` int(11) DEFAULT NULL, `created` timestamp NOT NULL DEFAULT current_timestamp(), - `serverId` int(10) unsigned DEFAULT NULL COMMENT 'Indica el id del servidor de impresión', + `serverId` varchar(255) DEFAULT NULL COMMENT 'Indica el identificador de los servidores de impresión', PRIMARY KEY (`id`), KEY `statusCode` (`statusCode`), KEY `printerFk` (`printerFk`), @@ -32728,7 +34438,7 @@ CREATE TABLE `printQueue` ( CONSTRAINT `printQueue_printerFk` FOREIGN KEY (`printerFk`) REFERENCES `printer` (`id`) ON UPDATE CASCADE, CONSTRAINT `printQueue_priorityFk` FOREIGN KEY (`priorityFk`) REFERENCES `queuePriority` (`id`) ON UPDATE CASCADE, CONSTRAINT `printQueue_report` FOREIGN KEY (`reportFk`) REFERENCES `report` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32741,7 +34451,7 @@ DROP TABLE IF EXISTS `printQueueArgs`; CREATE TABLE `printQueueArgs` ( `printQueueFk` int(10) unsigned NOT NULL, `name` varchar(255) NOT NULL, - `value` varchar(255) NOT NULL, + `value` varchar(255) DEFAULT NULL, PRIMARY KEY (`printQueueFk`,`name`), KEY `printQueueArgs_printQueueFk_idx` (`printQueueFk`), CONSTRAINT `printQueueArgs_printQueueFk` FOREIGN KEY (`printQueueFk`) REFERENCES `printQueue` (`id`) ON DELETE CASCADE ON UPDATE CASCADE @@ -32909,11 +34619,11 @@ DROP TABLE IF EXISTS `professionalCategory`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `professionalCategory` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(45) DEFAULT NULL, - `salary` decimal(10,2) DEFAULT NULL, - `salaryorSeniority` decimal(10,2) DEFAULT NULL, - `year` int(2) DEFAULT NULL, - PRIMARY KEY (`id`) + `name` varchar(50) NOT NULL, + `level` int(11) unsigned DEFAULT NULL, + `dayBreak` int(11) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `prefessionalCategory_UN` (`name`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -33053,7 +34763,7 @@ CREATE TABLE `property` ( `tome` int(11) DEFAULT NULL, `url` varchar(250) DEFAULT NULL, `protocol` varchar(100) DEFAULT NULL COMMENT 'numero de protocolo notarial de la escritura de compra venta', - `purchased` date NOT NULL DEFAULT util.VN_CURDATE() COMMENT 'date of purchase of the property', + `purchased` date NOT NULL DEFAULT curdate() COMMENT 'date of purchase of the property', `booked` date DEFAULT NULL COMMENT 'date of completion of property registration', PRIMARY KEY (`id`), KEY `property_FK` (`propertyGroupFk`), @@ -33533,12 +35243,79 @@ CREATE TABLE `recovery` ( `finished` date DEFAULT NULL COMMENT 'Fecha en la que acaba', `amount` double NOT NULL, `period` tinyint(3) unsigned NOT NULL DEFAULT 7 COMMENT 'numero de dias que indica cada cuanto hare el recobro', + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `cliente_idx` (`clientFk`), + KEY `recovery_fk_editor` (`editorFk`), CONSTRAINT `cliente333` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE, - CONSTRAINT `cliente_cliente` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE + CONSTRAINT `cliente_cliente` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE, + CONSTRAINT `recovery_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='En esta tabla apuntaremos los acuerdos de recobro semanal a '; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`recovery_beforeInsert` + BEFORE INSERT ON `recovery` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`recovery_beforeUpdate` + BEFORE UPDATE ON `recovery` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`recovery_afterDelete` + AFTER DELETE ON `recovery` + FOR EACH ROW +BEGIN + INSERT INTO clientLog + SET `action` = 'delete', + `changedModel` = 'Recovery', + `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 */ ; -- -- Table structure for table `referenceCurrent` @@ -33689,6 +35466,7 @@ CREATE TABLE `route` ( `invoiceInFk` mediumint(8) unsigned DEFAULT NULL, `beachFk` int(11) DEFAULT NULL, `commissionWorkCenterFk` int(11) DEFAULT NULL COMMENT 'WorkerCenter que gestiona la ruta', + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `Id_Agencia` (`agencyModeFk`), KEY `Fecha` (`created`), @@ -33698,9 +35476,11 @@ CREATE TABLE `route` ( KEY `asdfasdf_idx` (`invoiceInFk`), KEY `route_idxIsOk` (`isOk`), KEY `route_WorkCenterFk_idx` (`commissionWorkCenterFk`), + KEY `route_fk_editor` (`editorFk`), CONSTRAINT `fk_route_1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `route_WorkCenterFk` FOREIGN KEY (`commissionWorkCenterFk`) REFERENCES `workCenter` (`id`) ON UPDATE CASCADE, CONSTRAINT `route_fk5` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `route_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `route_ibfk_1` FOREIGN KEY (`gestdocFk`) REFERENCES `dms` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `route_ibfk_2` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `route_invoiceInFk` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) ON DELETE SET NULL ON UPDATE CASCADE @@ -33719,6 +35499,8 @@ DELIMITER ;; BEFORE INSERT ON `route` FOR EACH ROW BEGIN + SET NEW.editorFk = account.myUser_getId(); + SET NEW.commissionWorkCenterFk = ( SELECT IFNULL(b.workCenterFK, r.defaultWorkCenterFk) FROM vn.routeConfig r @@ -33765,6 +35547,8 @@ DELIMITER ;; BEGIN DECLARE vKmMax INT; + SET NEW.editorFk = account.myUser_getId(); + IF NEW.isOk <> FALSE AND OLD.isOk = FALSE THEN SET NEW.m3 = ( SELECT SUM(litros)/1000 FROM vn.saleVolume s @@ -33802,7 +35586,6 @@ DELIMITER ;; AFTER UPDATE ON `route` FOR EACH ROW 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 @@ -33831,6 +35614,30 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`route_afterDelete` + AFTER DELETE ON `route` + FOR EACH ROW +BEGIN + INSERT INTO routeLog + SET `action` = 'delete', + `changedModel` = 'Route', + `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 */ ; -- -- Table structure for table `routeAction` @@ -33953,20 +35760,18 @@ CREATE TABLE `routeConfig` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `routeLoadWorker` +-- Table structure for table `routeLoadWorker__` -- -DROP TABLE IF EXISTS `routeLoadWorker`; +DROP TABLE IF EXISTS `routeLoadWorker__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `routeLoadWorker` ( +CREATE TABLE `routeLoadWorker__` ( `routeFk` int(10) unsigned NOT NULL, `workerFk` int(10) unsigned NOT NULL, PRIMARY KEY (`routeFk`,`workerFk`), - KEY `frmWorker_idx` (`workerFk`), - CONSTRAINT `frmRutas` FOREIGN KEY (`routeFk`) REFERENCES `route` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT `frmWorker` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + KEY `frmWorker_idx` (`workerFk`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Table deprecated on 26/04/23'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33978,7 +35783,7 @@ DROP TABLE IF EXISTS `routeLog`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `routeLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `originFk` int(10) unsigned NOT NULL, + `originFk` int(10) unsigned DEFAULT NULL, `userFk` int(10) unsigned DEFAULT NULL, `action` set('insert','update','delete') NOT NULL, `creationDate` timestamp NULL DEFAULT current_timestamp(), @@ -34135,10 +35940,14 @@ CREATE TABLE `sale` ( `isPriceFixed` tinyint(1) NOT NULL DEFAULT 0, `created` timestamp NOT NULL DEFAULT current_timestamp(), `isAdded` tinyint(1) NOT NULL DEFAULT 0, + `total` decimal(10,2) GENERATED ALWAYS AS (`price` * `quantity` * (100 - `discount`) / 100) VIRTUAL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `Id_Ticket` (`ticketFk`), KEY `itemFk_ticketFk` (`itemFk`,`ticketFk`), + KEY `sale_fk_editor` (`editorFk`), CONSTRAINT `movement_ticket_id` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `sale_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `sale_ibfk_1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -34151,6 +35960,26 @@ CREATE TABLE `sale` ( /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`sale_beforeInsert` + BEFORE INSERT ON `sale` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`sale_afterInsert` AFTER INSERT ON `sale` FOR EACH ROW @@ -34211,12 +36040,14 @@ BEGIN CALL util.throw('Cannot insert a service item into a ticket'); END IF; */ + SET NEW.editorFk = account.myUser_getId(); + IF NEW.discount > 100 THEN SET NEW.discount = 0; END IF; IF old.discount > 0 AND NEW.discount = 0 THEN - INSERT INTO ticketLog + INSERT INTO ticketLog SET originFk = NEW.ticketFk, userFk = account.myUser_getId(), `action` = 'insert', description = CONCAT('Cambio de descuento del item :', ' ', new.itemFk, ' de ', old.discount ,' a 0 '); END IF; @@ -34240,8 +36071,6 @@ DELIMITER ;; FOR EACH ROW BEGIN DECLARE vIsToSendMail BOOL; - DECLARE vPickedLines INT; - DECLARE vCollectionFk INT; DECLARE vUserRole VARCHAR(255); IF !(NEW.id <=> OLD.id) @@ -34382,6 +36211,12 @@ BEGIN DECLARE vIsToSendMail BOOL; DECLARE vUserRole VARCHAR(255); + INSERT INTO ticketLog + SET `action` = 'delete', + `changedModel` = 'Sale', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); + CALL stock.log_add('sale', NULL, OLD.id); CALL ticket_requestRecalc(OLD.ticketFk); @@ -34594,10 +36429,9 @@ CREATE TABLE `saleGroupDetail` ( `saleFk` int(11) NOT NULL, `saleGroupFk` int(11) NOT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `saleGroupDetail_UN` (`saleFk`,`saleGroupFk`), KEY `saleGroupDetail_FK_1` (`saleGroupFk`), - CONSTRAINT `saleGroupDetail_FK` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `saleGroupDetail_FK_1` FOREIGN KEY (`saleGroupFk`) REFERENCES `saleGroup` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + KEY `saleFk` (`saleFk`), + CONSTRAINT `saleGroupDetail_ibfk_1` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='relaciona sale y saleGroup'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -34724,6 +36558,7 @@ CREATE TABLE `saleTracking` ( `actionFk__` int(11) DEFAULT NULL, `id` int(11) NOT NULL AUTO_INCREMENT, `stateFk` tinyint(3) unsigned NOT NULL, + `isScanned` tinyint(1) DEFAULT NULL COMMENT 'TRUE: se ha escaneado. FALSE: escrito a mano. NULL:demás casos', PRIMARY KEY (`id`), UNIQUE KEY `saleTracking_UN` (`saleFk`,`workerFk`,`stateFk`), KEY `Id_Movimiento` (`saleFk`), @@ -34918,6 +36753,21 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `salespersonConfig` +-- + +DROP TABLE IF EXISTS `salespersonConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `salespersonConfig` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `manaMaxRate` decimal(3,2) DEFAULT 0.05 COMMENT 'Valor máximo a recficar en una línea por el maná de un comercial', + `manaMinRate` decimal(3,2) DEFAULT -0.05 COMMENT 'Valor mínimo a recficar en una línea por el maná de un comercial', + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `sample` -- @@ -35005,10 +36855,11 @@ CREATE TABLE `sectorCollectionSaleGroup` ( `sectorCollectionFk` int(11) NOT NULL, `saleGroupFk` int(11) NOT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `sectorCollectionSaleGroup_UN` (`sectorCollectionFk`,`saleGroupFk`), - KEY `sectorCollectionSaleGroup_FK_1` (`saleGroupFk`), - CONSTRAINT `sectorCollectionSaleGroup_FK` FOREIGN KEY (`sectorCollectionFk`) REFERENCES `sectorCollection` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `sectorCollectionSaleGroup_FK_1` FOREIGN KEY (`saleGroupFk`) REFERENCES `saleGroup` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + UNIQUE KEY `saleGroupFk` (`saleGroupFk`), + KEY `sectorCollectionFk` (`sectorCollectionFk`), + CONSTRAINT `sectorCollectionSaleGroup_ibfk_1` FOREIGN KEY (`sectorCollectionFk`) REFERENCES `sectorCollection` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `sectorCollectionSaleGroup_ibfk_2` FOREIGN KEY (`saleGroupFk`) REFERENCES `saleGroup` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `sectorCollectionSaleGroup_ibfk_3` FOREIGN KEY (`saleGroupFk`) REFERENCES `saleGroup` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Relaciona las lineas de venta con la coleccion del sector'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -35035,6 +36886,52 @@ CREATE TABLE `sectorProductivity` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `sendingConfig` +-- + +DROP TABLE IF EXISTS `sendingConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `sendingConfig` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `defaultWeight` int(11) NOT NULL DEFAULT 13, + `defaultPackages` int(11) NOT NULL DEFAULT 1, + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `sendingService` +-- + +DROP TABLE IF EXISTS `sendingService`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `sendingService` ( + `agencyModeCodeFk` varchar(45) NOT NULL, + `serviceType` varchar(45) NOT NULL DEFAULT '01', + `accountNumber` varchar(100) NOT NULL, + PRIMARY KEY (`agencyModeCodeFk`), + CONSTRAINT `sendingService_agencyModeCodeFk` FOREIGN KEY (`agencyModeCodeFk`) REFERENCES `agencyMode` (`code`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Configuración de los servicios de Sending'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `sendingServiceWeekday` +-- + +DROP TABLE IF EXISTS `sendingServiceWeekday`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `sendingServiceWeekday` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `weekdays` set('mon','tue','wed','thu','fri','sat','sun') NOT NULL, + `params` varchar(20) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Configuración de parámetros por dia de SENDING'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `sharingCart` -- @@ -35241,12 +37138,15 @@ CREATE TABLE `shelving` ( `userFk` int(10) unsigned DEFAULT NULL, `isSpam` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'señala las matrículas con producto que se puede llevar a la reserva', `isRecyclable` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'las matrículas marcadas como reciclables se liberan cada noche desde vn.shelving_clean para poder volver a utilizarlas', + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `shelving_UN` (`code`), KEY `shelving_fk1_idx` (`parkingFk`), KEY `shelving_fk2_idx` (`userFk`), + KEY `shelving_fk_editor` (`editorFk`), CONSTRAINT `shelving_fk1` FOREIGN KEY (`parkingFk`) REFERENCES `parking` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `shelving_fk2` FOREIGN KEY (`userFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE + CONSTRAINT `shelving_fk2` FOREIGN KEY (`userFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `shelving_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tabla usada para localizar el carro en el parking del altillo'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -35262,11 +37162,10 @@ DELIMITER ;; BEFORE INSERT ON `shelving` FOR EACH ROW BEGIN + SET NEW.editorFk = account.myUser_getId(); IF NEW.code = "" THEN - CALL util.throw('NOT_EMPTY_CODE_ALLOWED'); - END IF; END */;; @@ -35288,11 +37187,10 @@ DELIMITER ;; BEFORE UPDATE ON `shelving` FOR EACH ROW BEGIN + SET NEW.editorFk = account.myUser_getId(); - IF NEW.code = "" THEN - + IF NEW.code = "" THEN CALL util.throw('NOT_EMPTY_CODE_ALLOWED'); - END IF; END */;; @@ -35301,6 +37199,30 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`shelving_afterDelete` + AFTER DELETE ON `shelving` + FOR EACH ROW +BEGIN + INSERT INTO shelvingLog + SET `action` = 'delete', + `changedModel` = 'Shelving', + `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 */ ; -- -- Table structure for table `shelvingLog` @@ -35311,7 +37233,7 @@ DROP TABLE IF EXISTS `shelvingLog`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `shelvingLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `originFk` int(11) NOT NULL, + `originFk` int(11) DEFAULT NULL, `userFk` int(10) unsigned DEFAULT NULL, `action` set('insert','update','delete','select') NOT NULL, `creationDate` timestamp NULL DEFAULT current_timestamp(), @@ -35860,6 +37782,8 @@ CREATE TABLE `supplier` ( `supplierActivityFk` varchar(45) DEFAULT NULL, `healthRegister` varchar(45) DEFAULT NULL, `isPayMethodChecked` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'Se ha validado la forma de pago', + `isVies` tinyint(4) NOT NULL DEFAULT 0, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `cuenta` (`account`), UNIQUE KEY `NIF` (`nif`), @@ -35873,10 +37797,12 @@ CREATE TABLE `supplier` ( KEY `supplier_transactionFk_idx` (`transactionTypeSageFk`), KEY `suppplier_supplierActivityFk` (`supplierActivityFk`), KEY `supplier_workerFk` (`workerFk`), + KEY `supplier_fk_editor` (`editorFk`), 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, CONSTRAINT `province_id` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON UPDATE CASCADE, + CONSTRAINT `supplier_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `supplier_taxTypeFk` FOREIGN KEY (`taxTypeSageFk`) REFERENCES `sage`.`TiposIva` (`CodigoIva`) ON UPDATE CASCADE, 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, @@ -35887,11 +37813,31 @@ CREATE TABLE `supplier` ( /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplier_beforeInsert` + BEFORE INSERT ON `supplier` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplier_beforeUpdate` BEFORE UPDATE ON `supplier` @@ -35904,6 +37850,8 @@ BEGIN DECLARE vOldPayMethodName VARCHAR(20); DECLARE vNewPayMethodName VARCHAR(20); + SET NEW.editorFk = account.myUser_getId(); + SELECT hasVerified INTO vPayMethodHasVerified FROM payMethod WHERE id = NEW.payMethodFk; @@ -35938,6 +37886,30 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplier_afterDelete` + AFTER DELETE ON `supplier` + FOR EACH ROW +BEGIN + INSERT INTO supplierLog + SET `action` = 'delete', + `changedModel` = 'Supplier', + `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 */ ; -- -- Table structure for table `supplierAccount` @@ -35953,16 +37925,19 @@ CREATE TABLE `supplierAccount` ( `office` varchar(4) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, `DC` varchar(2) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, `number` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `description` varchar(45) DEFAULT NULL COMMENT 'obsoleta(comprobar)', + `description__` varchar(45) DEFAULT NULL COMMENT '@deprecated 2023-03-23', `bankEntityFk` int(10) unsigned DEFAULT NULL, - `bankFk` int(11) DEFAULT NULL COMMENT 'obsoleta(comprobar)', + `accountingFk` int(11) DEFAULT NULL, `beneficiary` varchar(50) DEFAULT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `fk_proveedores_proveedores_account_idx` (`supplierFk`), KEY `fk_Proveedores_account_entity1_idx` (`bankEntityFk`), - KEY `fk_banco_prov_account_idx` (`bankFk`), + KEY `fk_banco_prov_account_idx` (`accountingFk`), + KEY `supplierAccount_fk_editor` (`editorFk`), CONSTRAINT `supplierAccount_FK` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE, - CONSTRAINT `supplierAccount_FK_1` FOREIGN KEY (`bankEntityFk`) REFERENCES `bankEntity` (`id`) ON UPDATE CASCADE + CONSTRAINT `supplierAccount_FK_1` FOREIGN KEY (`bankEntityFk`) REFERENCES `bankEntity` (`id`) ON UPDATE CASCADE, + CONSTRAINT `supplierAccount_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -35974,67 +37949,15 @@ CREATE TABLE `supplierAccount` ( /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierAccount_afterInsert` - AFTER INSERT ON `supplierAccount` - FOR EACH ROW -BEGIN - UPDATE vn.supplier - SET isPayMethodChecked = FALSE - WHERE id = NEW.supplierFk; -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET 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_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER supplierAccount_afterUpdate - AFTER UPDATE ON supplierAccount - FOR EACH ROW -BEGIN - DECLARE vPayMethodHasVerified BOOL; - - SELECT pm.hasVerified INTO vPayMethodHasVerified - FROM vn.supplier s - JOIN vn.payMethod pm ON pm.id = s.payMethodFk - WHERE s.id = OLD.supplierFk; - - IF OLD.iban <> NEW.iban OR OLD.bankEntityFk <> NEW.bankEntityFk AND vPayMethodHasVerified THEN - UPDATE vn.supplier - SET isPayMethodChecked = FALSE - WHERE id = OLD.supplierFk; - END IF; - -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierAccount_afterDelete` AFTER DELETE ON `supplierAccount` FOR EACH ROW BEGIN - UPDATE vn.supplier - SET isPayMethodChecked = FALSE - WHERE id = OLD.supplierFk; + INSERT INTO supplierLog + SET `action` = 'delete', + `changedModel` = 'SupplierAccount', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -36073,11 +37996,78 @@ CREATE TABLE `supplierAddress` ( `city` varchar(50) DEFAULT NULL, `phone` varchar(15) DEFAULT NULL, `mobile` varchar(15) DEFAULT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `supplierAddress_province_fk` (`provinceFk`), + KEY `supplierAddress_fk_editor` (`editorFk`), + CONSTRAINT `supplierAddress_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `supplierAddress_province_fk` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierAddress_beforeInsert` + BEFORE INSERT ON `supplierAddress` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierAddress_beforeUpdate` + BEFORE UPDATE ON `supplierAddress` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierAddress_afterDelete` + AFTER DELETE ON `supplierAddress` + FOR EACH ROW +BEGIN + INSERT INTO supplierLog + SET `action` = 'delete', + `changedModel` = 'SupplierAddress', + `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 */ ; -- -- Table structure for table `supplierAgencyTerm` @@ -36118,8 +38108,11 @@ CREATE TABLE `supplierContact` ( `email` varchar(255) DEFAULT NULL, `observation` text DEFAULT NULL, `name` varchar(255) DEFAULT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `supplier_id` (`supplierFk`), + KEY `supplierContact_fk_editor` (`editorFk`), + CONSTRAINT `supplierContact_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `supplier_id` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -36179,8 +38172,8 @@ DROP TABLE IF EXISTS `supplierLog`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `supplierLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `originFk` int(11) NOT NULL, - `userFk` int(10) unsigned NOT NULL, + `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, @@ -36497,7 +38490,7 @@ CREATE TABLE `ticket` ( `packages` smallint(10) unsigned DEFAULT 0, `location` varchar(15) DEFAULT NULL, `hour` int(11) DEFAULT 0, - `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `created` timestamp NOT NULL DEFAULT current_timestamp(), `isBlocked` tinyint(1) NOT NULL DEFAULT 1, `solution` varchar(5) DEFAULT NULL, `routeFk` int(10) unsigned DEFAULT NULL, @@ -36514,6 +38507,8 @@ CREATE TABLE `ticket` ( `totalWithVat` decimal(10,2) DEFAULT NULL COMMENT 'cache calculada del total con iva', `totalWithoutVat` decimal(10,2) DEFAULT NULL COMMENT 'cache calculada del total sin iva', `weight` decimal(10,2) DEFAULT NULL COMMENT 'En caso de informar, se utilizará su valor para calcular el peso de la factura', + `clonedFrom` int(11) DEFAULT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `Id_Cliente` (`clientFk`), KEY `Id_Consigna` (`addressFk`), @@ -36526,8 +38521,10 @@ CREATE TABLE `ticket` ( KEY `warehouse_date` (`warehouseFk`,`shipped`), KEY `Fecha` (`shipped`,`clientFk`), KEY `tickets_zone_fk_idx` (`zoneFk`), + KEY `ticket_fk_editor` (`editorFk`), CONSTRAINT `ticket_FK` FOREIGN KEY (`refFk`) REFERENCES `invoiceOut` (`ref`) ON UPDATE CASCADE, CONSTRAINT `ticket_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE, + CONSTRAINT `ticket_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `ticket_ibfk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticket_ibfk_5` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticket_ibfk_6` FOREIGN KEY (`addressFk`) REFERENCES `address` (`id`) ON UPDATE CASCADE, @@ -36545,6 +38542,26 @@ CREATE TABLE `ticket` ( /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticket_beforeInsert` + BEFORE INSERT ON `ticket` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticket_afterInsert` AFTER INSERT ON `ticket` FOR EACH ROW @@ -36565,10 +38582,7 @@ BEGIN SET vStateCode = 'FREE'; END IF; - INSERT INTO ticketTracking(ticketFk, stateFk, workerFk) - SELECT NEW.id, id, account.myUser_getId() - FROM state - WHERE `code` = vStateCode COLLATE utf8_general_ci; + CALL ticket_setState(NEW.id, vStateCode); IF YEAR(NEW.shipped) > 2000 THEN @@ -36604,6 +38618,8 @@ DELIMITER ;; BEGIN DECLARE vNewTime TIME; + SET NEW.editorFk = account.myUser_getId(); + IF !(NEW.routeFk <=> OLD.routeFk) THEN INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`) SELECT r.id @@ -36612,7 +38628,7 @@ BEGIN AND r.id IN (OLD.routeFk,NEW.routeFk) AND r.created >= util.VN_CURDATE() GROUP BY r.id; - END IF; + END IF; IF !(DATE(NEW.shipped) <=> DATE(OLD.shipped)) THEN IF YEAR(NEW.shipped) < 2000 THEN @@ -36638,10 +38654,10 @@ BEGIN SET NEW.shipped = DATE_FORMAT(NEW.shipped, '2000-%m-%d %T'); SET NEW.landed = DATE_FORMAT(NEW.landed, '2000-%m-%d %T'); SET NEW.routeFk = NULL; - SET NEW.zoneFk = NULL; + SET NEW.zoneFk = NULL; END IF; - IF NEW.routeFk AND NEW.isDeleted THEN + IF NEW.routeFk AND NEW.isDeleted THEN CALL util.throw ('This ticket is deleted'); END IF; @@ -36688,34 +38704,22 @@ DELIMITER ;; FOR EACH ROW BEGIN - IF !(NEW.id <=> OLD.id) - OR !(NEW.warehouseFk <=> OLD.warehouseFk) - OR !(NEW.shipped <=> OLD.shipped) THEN + IF !(NEW.id <=> OLD.id) + OR !(NEW.warehouseFk <=> OLD.warehouseFk) + OR !(NEW.shipped <=> OLD.shipped) THEN CALL stock.log_add('ticket', NEW.id, OLD.id); END IF; - IF !(NEW.clientFk <=> OLD.clientFk) - OR !(NEW.addressFk <=> OLD.addressFk) - OR !(NEW.companyFk <=> OLD.companyFk) THEN - CALL ticket_requestRecalc(NEW.id); + IF !(NEW.clientFk <=> OLD.clientFk) + OR !(NEW.addressFk <=> OLD.addressFk) + OR !(NEW.companyFk <=> OLD.companyFk) THEN + CALL ticket_requestRecalc(NEW.id); END IF; - IF NEW.clientFk = 2067 AND !(NEW.clientFk <=> OLD.clientFk) THEN - -- Fallo que se insertan no se sabe como tickets en este cliente - CALL mail_insert( - 'jgallego@verdnatura.es', - 'jgallego@verdnatura.es', - 'Modificado ticket al cliente 2067', - CONCAT(account.myUser_getName(), ' ha modificado el ticket ',NEW.id) - ); - END IF; - IF NEW.routeFk <> OLD.routeFk THEN - UPDATE expedition SET hasNewRoute = TRUE WHERE ticketFk = NEW.id; - END IF; END */;; @@ -36754,6 +38758,30 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticket_afterDelete` + AFTER DELETE ON `ticket` + FOR EACH ROW +BEGIN + INSERT INTO ticketLog + SET `action` = 'delete', + `changedModel` = 'Ticket', + `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 */ ; -- -- Table structure for table `ticketCollection` @@ -36837,6 +38865,8 @@ CREATE TABLE `ticketConfig` ( `scopeDays` tinyint(3) DEFAULT NULL, `pickingDelay` int(11) NOT NULL DEFAULT 10 COMMENT 'minutos de cortesia desde que se crea un ticket hasta que se puede preparar', `packagingInvoicingDated` date NOT NULL DEFAULT '2017-11-21' COMMENT 'Fecha desde la cual se gestiona el registro de embalajes de tickets (tabla vn.ticketPackaging)', + `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', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -36851,9 +38881,12 @@ DROP TABLE IF EXISTS `ticketDms`; CREATE TABLE `ticketDms` ( `ticketFk` int(11) NOT NULL, `dmsFk` int(11) NOT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`ticketFk`,`dmsFk`), KEY `gestdoc_id` (`dmsFk`), + KEY `ticketDms_fk_editor` (`editorFk`), CONSTRAINT `ticketDms_dmsFk` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `ticketDms_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `ticketDms_ticketFk` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -36866,6 +38899,46 @@ CREATE TABLE `ticketDms` ( /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketDms_beforeInsert` + BEFORE INSERT ON `ticketDms` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketDms_beforeUpdate` + BEFORE UPDATE ON `ticketDms` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketDms_beforeDelete` BEFORE DELETE ON `ticketDms` FOR EACH ROW @@ -36885,6 +38958,30 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketDms_afterDelete` + AFTER DELETE ON `ticketDms` + FOR EACH ROW +BEGIN + INSERT INTO ticketLog + SET `action` = 'delete', + `changedModel` = 'ticketDms', + `changedModelId` = OLD.ticketFk, + `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 */ ; -- -- Table structure for table `ticketDocumentation` @@ -36991,7 +39088,7 @@ DROP TABLE IF EXISTS `ticketLog`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ticketLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `originFk` int(11) NOT NULL, + `originFk` int(11) DEFAULT NULL, `userFk` int(10) unsigned DEFAULT NULL, `action` set('insert','update','delete','select') NOT NULL, `creationDate` timestamp NULL DEFAULT current_timestamp(), @@ -37004,6 +39101,8 @@ CREATE TABLE `ticketLog` ( PRIMARY KEY (`id`), KEY `logTicketoriginFk` (`originFk`), KEY `logTicketuserFk` (`userFk`), + KEY `ticketLog_creationDate_IDX` (`creationDate`) USING BTREE, + KEY `ticketLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), CONSTRAINT `ticketLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketLog_user` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -37067,13 +39166,80 @@ CREATE TABLE `ticketObservation` ( `ticketFk` int(11) NOT NULL, `observationTypeFk` tinyint(3) unsigned NOT NULL, `description` text NOT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `Id_Ticket` (`ticketFk`,`observationTypeFk`), KEY `observation_type_id` (`observationTypeFk`), + KEY `ticketObservation_fk_editor` (`editorFk`), + CONSTRAINT `ticketObservation_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `ticketObservation_ibfk_1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketObservation_ibfk_2` FOREIGN KEY (`observationTypeFk`) REFERENCES `observationType` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketObservation_beforeInsert` + BEFORE INSERT ON `ticketObservation` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketObservation_beforeUpdate` + BEFORE UPDATE ON `ticketObservation` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketObservation_afterDelete` + AFTER DELETE ON `ticketObservation` + FOR EACH ROW +BEGIN + INSERT INTO ticketLog + SET `action` = 'delete', + `changedModel` = 'TicketObservation', + `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 */ ; -- -- Table structure for table `ticketPackage` @@ -37105,13 +39271,16 @@ CREATE TABLE `ticketPackaging` ( `created` timestamp NOT NULL DEFAULT current_timestamp(), `pvp` double DEFAULT NULL, `workerFk` int(10) unsigned DEFAULT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `ticketPackaging_fk1_idx` (`ticketFk`), KEY `ticketPackaging_fk2_idx` (`packagingFk`), KEY `ticketPackaging_fk3_idx` (`workerFk`), + KEY `ticketPackaging_fk_editor` (`editorFk`), CONSTRAINT `ticketPackaging_fk1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketPackaging_fk2` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE, - CONSTRAINT `ticketPackaging_fk3` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `ticketPackaging_fk3` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `ticketPackaging_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -37127,7 +39296,7 @@ DELIMITER ;; BEFORE INSERT ON `ticketPackaging` FOR EACH ROW BEGIN - + SET NEW.editorFk = account.myUser_getId(); SET NEW.workerFk = account.myUser_getId(); END */;; @@ -37136,6 +39305,50 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketPackaging_beforeUpdate` + BEFORE UPDATE ON `ticketPackaging` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketPackaging_afterDelete` + AFTER DELETE ON `ticketPackaging` + FOR EACH ROW +BEGIN + INSERT INTO ticketLog + SET `action` = 'delete', + `changedModel` = 'TicketPackaging', + `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 */ ; -- -- Table structure for table `ticketPackagingStartingStock` @@ -37273,11 +39486,14 @@ CREATE TABLE `ticketRefund` ( `id` int(11) NOT NULL AUTO_INCREMENT, `refundTicketFk` int(11) NOT NULL, `originalTicketFk` int(11) NOT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `ticketRefund_FK_1` (`originalTicketFk`), KEY `ticketRefund_FK` (`refundTicketFk`), + KEY `ticketRefund_fk_editor` (`editorFk`), CONSTRAINT `ticketRefund_FK` FOREIGN KEY (`refundTicketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `ticketRefund_FK_1` FOREIGN KEY (`originalTicketFk`) REFERENCES `ticket` (`id`) ON UPDATE CASCADE + CONSTRAINT `ticketRefund_FK_1` FOREIGN KEY (`originalTicketFk`) REFERENCES `ticket` (`id`) ON UPDATE CASCADE, + CONSTRAINT `ticketRefund_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -37293,7 +39509,8 @@ DELIMITER ;; BEFORE INSERT ON `ticketRefund` FOR EACH ROW BEGIN - CALL ticketRefund_beforeUpsert(NEW.refundTicketFk, NEW.originalTicketFk); + SET NEW.editorFk = account.myUser_getId(); + CALL ticketRefund_beforeUpsert(NEW.refundTicketFk, NEW.originalTicketFk); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -37313,7 +39530,32 @@ DELIMITER ;; BEFORE UPDATE ON `ticketRefund` FOR EACH ROW BEGIN - CALL ticketRefund_beforeUpsert(NEW.refundTicketFk, NEW.originalTicketFk); + SET NEW.editorFk = account.myUser_getId(); + CALL ticketRefund_beforeUpsert(NEW.refundTicketFk, NEW.originalTicketFk); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketRefund_afterDelete` + AFTER DELETE ON `ticketRefund` + FOR EACH ROW +BEGIN + INSERT INTO ticketLog + SET `action` = 'delete', + `changedModel` = 'TicketRefund', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -37348,6 +39590,7 @@ CREATE TABLE `ticketRequest` ( `requesterFk` int(10) unsigned DEFAULT NULL, `attenderFk` int(10) unsigned DEFAULT NULL, `ticketFk` int(11) DEFAULT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `Id_Movimiento_UNIQUE` (`saleFk`), KEY `Id_ARTICLE` (`itemFk`), @@ -37358,10 +39601,12 @@ CREATE TABLE `ticketRequest` ( KEY `fgnRequester_idx` (`requesterFk`), KEY `fgnAtender_idx` (`attenderFk`), KEY `fgnTicket_idx` (`ticketFk`), + KEY `ticketRequest_fk_editor` (`editorFk`), CONSTRAINT `fgbMovimiento` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `fgnAtender` FOREIGN KEY (`attenderFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `fgnRequester` FOREIGN KEY (`requesterFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, - CONSTRAINT `fgnTicket` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `fgnTicket` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `ticketRequest_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -37377,17 +39622,19 @@ DELIMITER ;; BEFORE INSERT ON `ticketRequest` FOR EACH ROW BEGIN - IF NEW.ticketFk IS NULL THEN - SET NEW.ticketFk = (SELECT s.ticketFk FROM sale s WHERE s.id = NEW.saleFk); - END IF; + SET NEW.editorFk = account.myUser_getId(); - IF NEW.requesterFk IS NULL THEN - SET NEW.requesterFk = (SELECT w.id FROM worker w WHERE w.code = NEW.salesPersonCode); - END IF; + IF NEW.ticketFk IS NULL THEN + SET NEW.ticketFk = (SELECT s.ticketFk FROM sale s WHERE s.id = NEW.saleFk); + END IF; - IF NEW.attenderFk IS NULL THEN - SET NEW.attenderFk = (SELECT w.id FROM worker w WHERE w.code = NEW.buyerCode); - END IF; + IF NEW.requesterFk IS NULL THEN + SET NEW.requesterFk = (SELECT w.id FROM worker w WHERE w.code = NEW.salesPersonCode); + END IF; + + IF NEW.attenderFk IS NULL THEN + SET NEW.attenderFk = (SELECT w.id FROM worker w WHERE w.code = NEW.buyerCode); + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -37407,17 +39654,43 @@ DELIMITER ;; BEFORE UPDATE ON `ticketRequest` FOR EACH ROW BEGIN - IF NEW.saleFk <> OLD.saleFk THEN - SET NEW.ticketFk = (SELECT s.ticketFk FROM sale s WHERE s.id = NEW.saleFk); - END IF; + SET NEW.editorFk = account.myUser_getId(); - IF NEW.salesPersonCode <> OLD.salesPersonCode THEN - SET NEW.requesterFk = (SELECT w.id FROM worker w WHERE w.code = NEW.salesPersonCode); - END IF; + IF NEW.saleFk <> OLD.saleFk THEN + SET NEW.ticketFk = (SELECT s.ticketFk FROM sale s WHERE s.id = NEW.saleFk); + END IF; - IF NEW.buyerCode <> OLD.buyerCode THEN - SET NEW.attenderFk = (SELECT w.id FROM worker w WHERE w.code = NEW.buyerCode); - END IF; + IF NEW.salesPersonCode <> OLD.salesPersonCode THEN + SET NEW.requesterFk = (SELECT w.id FROM worker w WHERE w.code = NEW.salesPersonCode); + END IF; + + IF NEW.buyerCode <> OLD.buyerCode THEN + SET NEW.attenderFk = (SELECT w.id FROM worker w WHERE w.code = NEW.buyerCode); + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketRequest_afterDelete` + AFTER DELETE ON `ticketRequest` + FOR EACH ROW +BEGIN + INSERT INTO ticketLog + SET `action` = 'delete', + `changedModel` = 'TicketRequest', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -37440,12 +39713,15 @@ CREATE TABLE `ticketService` ( `taxClassFk` tinyint(3) unsigned NOT NULL DEFAULT 2, `ticketFk` int(11) NOT NULL, `ticketServiceTypeFk` int(11) NOT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `ticketServiceIvaGroup_idx` (`taxClassFk`), KEY `fgn_ticketFk_idx` (`ticketFk`), KEY `ticketService_ticketServiceType_idx` (`ticketServiceTypeFk`), + KEY `ticketService_fk_editor` (`editorFk`), CONSTRAINT `fgn_ticketFk` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketServiceIvaGroup` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE, + CONSTRAINT `ticketService_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `ticketService_ticketServiceType` FOREIGN KEY (`ticketServiceTypeFk`) REFERENCES `ticketServiceType` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Servicios asociadas a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -37458,6 +39734,26 @@ CREATE TABLE `ticketService` ( /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketService_beforeInsert` + BEFORE INSERT ON `ticketService` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketService_ai` AFTER INSERT ON `ticketService` FOR EACH ROW @@ -37480,6 +39776,26 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketService_beforeUpdate` + BEFORE UPDATE ON `ticketService` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketService_au` AFTER UPDATE ON `ticketService` FOR EACH ROW @@ -37509,6 +39825,11 @@ DELIMITER ;; AFTER DELETE ON `ticketService` FOR EACH ROW BEGIN + INSERT INTO ticketLog + SET `action` = 'delete', + `changedModel` = 'TicketService', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); CALL ticket_requestRecalc(OLD.ticketFk); @@ -37549,7 +39870,7 @@ CREATE TABLE `ticketSms` ( PRIMARY KEY (`smsFk`), KEY `ticketSms_FK_1` (`ticketFk`), CONSTRAINT `ticketSms_FK` FOREIGN KEY (`smsFk`) REFERENCES `sms` (`id`) ON UPDATE CASCADE, - CONSTRAINT `ticketSms_FK_1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON UPDATE CASCADE + CONSTRAINT `ticketSms_FK_1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -37613,14 +39934,17 @@ CREATE TABLE `ticketTracking` ( `ticketFk` int(11) DEFAULT NULL, `workerFk` int(11) DEFAULT NULL, `supervisorFk` int(10) unsigned DEFAULT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `currante` (`workerFk`), KEY `responsable` (`supervisorFk`), KEY `ticket` (`ticketFk`), KEY `inter_state` (`stateFk`), KEY `inter_id` (`ticketFk`,`id`) USING BTREE, + KEY `ticketTracking_fk_editor` (`editorFk`), CONSTRAINT `inter_state` FOREIGN KEY (`stateFk`) REFERENCES `state` (`id`) ON UPDATE CASCADE, CONSTRAINT `responsable` FOREIGN KEY (`supervisorFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, + CONSTRAINT `ticketTracking_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `ticketTracking_ibfk_1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -37637,21 +39961,7 @@ DELIMITER ;; BEFORE INSERT ON `ticketTracking` FOR EACH ROW BEGIN - DECLARE vState VARCHAR(15); - DECLARE vZoneFk INT; - DECLARE vBoardingStateFk INT; - - SELECT s.code INTO vState - FROM state s - WHERE s.id = NEW.stateFk; - - SELECT t.zonefk INTO vZoneFk - FROM ticket t - WHERE t.id = NEW.ticketFk; - - IF vState = 'OK' AND vZoneFk IS NULL THEN - CALL util.throw("ASSIGN_ZONE_FIRST"); - END IF; + SET NEW.editorFk = account.myUser_getId(); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -37692,6 +40002,26 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketTracking_beforeUpdate` + BEFORE UPDATE ON `ticketTracking` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketTracking_afterUpdate` AFTER UPDATE ON `ticketTracking` FOR EACH ROW @@ -37750,6 +40080,12 @@ BEGIN WHERE ticketFk = OLD.ticketFk; END; + INSERT INTO ticketLog + SET `action` = 'delete', + `changedModel` = 'TicketTracking', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); + CALL util.debugAdd('deletedState', CONCAT('interFk: ', OLD.id, ' ticketFk: ', OLD.ticketFk, @@ -37829,12 +40165,79 @@ CREATE TABLE `ticketWeekly` ( `ticketFk` int(11) NOT NULL AUTO_INCREMENT, `weekDay` tinyint(1) NOT NULL COMMENT 'funcion de mysql Lunes = 0, Domingo = 6\nShipped, dia de preparacion del pedido', `agencyModeFk` int(11) DEFAULT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`ticketFk`), KEY `agencyModeFk_idx` (`agencyModeFk`), + KEY `ticketWeekly_fk_editor` (`editorFk`), CONSTRAINT `Id_Ticket_fk` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `agencyModeFk` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON DELETE SET NULL ON UPDATE CASCADE + CONSTRAINT `agencyModeFk` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `ticketWeekly_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketWeekly_beforeInsert` + BEFORE INSERT ON `ticketWeekly` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketWeekly_beforeUpdate` + BEFORE UPDATE ON `ticketWeekly` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketWeekly_afterDelete` + AFTER DELETE ON `ticketWeekly` + FOR EACH ROW +BEGIN + INSERT INTO ticketLog + SET `action` = 'delete', + `changedModel` = 'TicketWeekly', + `changedModelId` = OLD.ticketFk, + `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 */ ; -- -- Table structure for table `till` @@ -37978,7 +40381,7 @@ CREATE TABLE `timeControlDevice` ( `key` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name_UNIQUE` (`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -38251,6 +40654,8 @@ CREATE TABLE `travel` ( `totalEntries` tinyint(4) unsigned DEFAULT 0, `appointment` datetime DEFAULT NULL, `agencyModeFk` int(11) DEFAULT NULL, + `clonedFrom` int(11) DEFAULT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `shipment_1` (`shipped`,`landed`,`warehouseInFk`,`warehouseOutFk`,`agencyFk`,`agencyModeFk`,`ref`), KEY `agency_id` (`agencyFk`), @@ -38260,7 +40665,9 @@ CREATE TABLE `travel` ( KEY `warehouse_out_shipment` (`warehouseOutFk`,`shipped`), KEY `travel_ibfk_4_idx` (`cargoSupplierFk`), KEY `travel_FK` (`agencyModeFk`), + KEY `travel_fk_editor` (`editorFk`), CONSTRAINT `travel_FK` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE, + CONSTRAINT `travel_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `travel_ibfk_1` FOREIGN KEY (`warehouseInFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `travel_ibfk_2` FOREIGN KEY (`warehouseOutFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `travel_ibfk_3` FOREIGN KEY (`agencyFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE @@ -38279,6 +40686,8 @@ DELIMITER ;; BEFORE INSERT ON `travel` FOR EACH ROW BEGIN + SET NEW.editorFk = account.myUser_getId(); + CALL travel_checkDates(NEW.shipped, NEW.landed); -- Actualizar agencyFk y agencyModeFk @@ -38308,19 +40717,26 @@ DELIMITER ;; BEFORE UPDATE ON `travel` FOR EACH ROW BEGIN - IF !(NEW.landed <=> OLD.landed) - OR !(NEW.shipped <=> OLD.shipped) THEN + SET NEW.editorFk = account.myUser_getId(); + + IF NOT (NEW.landed <=> OLD.landed) + OR NOT (NEW.shipped <=> OLD.shipped) THEN CALL travel_checkDates(NEW.shipped, NEW.landed); END IF; -- Actualizar agencyFk y agencyModeFk - IF !(NEW.agencyFk <=> OLD.agencyFk)THEN - SET NEW.agencyModeFk = NEW.agencyFk; - END IF; + IF NOT (NEW.agencyFk <=> OLD.agencyFk)THEN + SET NEW.agencyModeFk = NEW.agencyFk; + END IF; + + IF NOT (NEW.agencyModeFk <=> OLD.agencyModeFk) THEN + SET NEW.agencyFk = NEW.agencyModeFk; + END IF; + + IF NOT (NEW.isReceived <=> OLD.isReceived) THEN + CALL travel_checkPackaging(NEW.id); + END IF; - IF !(NEW.agencyModeFk <=> OLD.agencyModeFk) THEN - SET NEW.agencyFk = NEW.agencyModeFk; - END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -38342,21 +40758,35 @@ DELIMITER ;; BEGIN CALL stock.log_add('travel', NEW.id, OLD.id); - IF !(NEW.shipped <=> OLD.shipped) THEN + IF !(NEW.shipped <=> OLD.shipped) THEN UPDATE entry - SET commission = entry_getCommission(travelFk, currencyFk,supplierFk) + SET commission = entry_getCommission(travelFk, currencyFk,supplierFk) WHERE travelFk = NEW.id; - END IF; -/* - IF !(ABS(NEW.isDelivered) <=> ABS(OLD.isDelivered)) - THEN - INSERT INTO vn2008.travel_dits SET - idaccion_dits = 89, - Id_Trabajador = account.myUser_getId(), - Id_Ticket = NEW.id, - value_old = OLD.isDelivered, - value_new = NEW.isDelivered; - 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_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`travel_afterDelete` + AFTER DELETE ON `travel` + FOR EACH ROW +BEGIN + INSERT INTO travelLog + SET `action` = 'delete', + `changedModel` = 'Travel', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -38407,7 +40837,7 @@ DROP TABLE IF EXISTS `travelLog`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `travelLog` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `originFk` int(10) unsigned NOT NULL, + `originFk` int(10) unsigned DEFAULT NULL, `userFk` int(10) unsigned DEFAULT NULL, `action` set('insert','update','delete') NOT NULL, `creationDate` timestamp NULL DEFAULT current_timestamp(), @@ -38471,19 +40901,86 @@ 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.', + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `thermograph_fk_idx` (`thermographFk`), KEY `gestdoc_fk_idx` (`dmsFk`), KEY `travel_id` (`travelFk`), KEY `warehouse_id` (`warehouseFk`), KEY `travelThermographTemperatureFgn` (`temperatureFk`), + KEY `travelThermograph_fk_editor` (`editorFk`), CONSTRAINT `travelThermographDmsFgn` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) 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`), - CONSTRAINT `travelThermographWarehouseFgn` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE + CONSTRAINT `travelThermographWarehouseFgn` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE, + CONSTRAINT `travelThermograph_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Registra cada termografo que se ha introducido en cada travel'; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`travelThermograph_beforeInsert` + BEFORE INSERT ON `travelThermograph` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`travelThermograph_beforeUpdate` + BEFORE UPDATE ON `travelThermograph` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`travelThermograph_afterDelete` + AFTER DELETE ON `travelThermograph` + FOR EACH ROW +BEGIN + INSERT INTO travelLog + SET `action` = 'delete', + `changedModel` = 'TravelThermograph', + `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 */ ; -- -- Table structure for table `trolley` @@ -38763,10 +41260,83 @@ CREATE TABLE `wagon` ( `id` int(11) NOT NULL AUTO_INCREMENT, `volume` int(11) NOT NULL DEFAULT 150 COMMENT 'Volumen en litros', `plate` varchar(10) NOT NULL COMMENT 'Matrícula', + `typeFk` int(11) unsigned NOT NULL, + `label` int(11) unsigned NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `wagonConfig` +-- + +DROP TABLE IF EXISTS `wagonConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `wagonConfig` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `width` int(11) unsigned DEFAULT 1350, + `height` int(11) unsigned DEFAULT 1900, + `maxWagonHeight` int(11) unsigned DEFAULT 200, + `minHeightBetweenTrays` int(11) unsigned DEFAULT 50, + `maxTrays` int(11) unsigned DEFAULT 6, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `wagonType` +-- + +DROP TABLE IF EXISTS `wagonType`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `wagonType` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(30) NOT NULL, + `divisible` tinyint(1) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + UNIQUE KEY `name` (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `wagonTypeColor` +-- + +DROP TABLE IF EXISTS `wagonTypeColor`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `wagonTypeColor` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(30) NOT NULL, + `rgb` varchar(30) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name` (`name`), + UNIQUE KEY `rgb` (`rgb`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `wagonTypeTray` +-- + +DROP TABLE IF EXISTS `wagonTypeTray`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `wagonTypeTray` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `typeFk` int(11) unsigned DEFAULT NULL, + `height` int(11) unsigned NOT NULL, + `colorFk` int(11) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `typeFk` (`typeFk`,`height`), + KEY `wagonTypeTray_color` (`colorFk`), + CONSTRAINT `wagonTypeTray_color` FOREIGN KEY (`colorFk`) REFERENCES `wagonTypeColor` (`id`) ON UPDATE CASCADE, + CONSTRAINT `wagonTypeTray_type` FOREIGN KEY (`typeFk`) REFERENCES `wagonType` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `wagonVolumetry` -- @@ -38975,19 +41545,24 @@ CREATE TABLE `worker` ( `sex` enum('M','F') NOT NULL DEFAULT 'F' COMMENT 'M Masculino F Femenino', `businessFk` int(11) DEFAULT NULL, `balance` decimal(10,2) DEFAULT NULL, + `locker` int(10) unsigned DEFAULT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `CodigoTrabajador_UNIQUE` (`code`), UNIQUE KEY `user_id_UNIQUE` (`userFk`), UNIQUE KEY `worker_business` (`businessFk`), + UNIQUE KEY `locker` (`locker`), KEY `sub` (`sub`), KEY `boss_idx` (`bossFk`), KEY `worker_FK` (`labelerFk`), KEY `worker_FK_2` (`educationLevelFk`), KEY `worker_FK_1` (`originCountryFk`), + KEY `worker_fk_editor` (`editorFk`), CONSTRAINT `worker_FK` FOREIGN KEY (`labelerFk`) REFERENCES `printer` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `worker_FK_1` FOREIGN KEY (`originCountryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE, CONSTRAINT `worker_FK_2` FOREIGN KEY (`educationLevelFk`) REFERENCES `educationLevel` (`id`) ON UPDATE CASCADE, CONSTRAINT `worker_businessFk` FOREIGN KEY (`businessFk`) REFERENCES `business` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `worker_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `worker_ibfk_1` FOREIGN KEY (`id`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -39014,18 +41589,26 @@ 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 character_set_client = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`worker_beforeUpdate` -BEFORE UPDATE -ON worker FOR EACH ROW + BEFORE UPDATE ON `worker` + FOR EACH ROW BEGIN IF NOT (NEW.labelerFk <=> OLD.labelerFk AND NEW.sectorFk <=> OLD.sectorFk) THEN - CALL vn.printer_checkSector(NEW.labelerFk, NEW.sectorFk); + CALL vn.printer_checkSector(NEW.labelerFk, NEW.sectorFk); + + INSERT IGNORE INTO vn.operator (workerFk) + VALUES (NEW.id); + + UPDATE operator + SET labelerFk = NEW.labelerFk, + sectorFk = NEW.sectorFk + WHERE workerFk = NEW.id; END IF; END */;; DELIMITER ; @@ -39101,22 +41684,6 @@ CREATE TABLE `workerBusinessType` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Temporary table structure for view `workerCalendar` --- - -DROP TABLE IF EXISTS `workerCalendar`; -/*!50001 DROP VIEW IF EXISTS `workerCalendar`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `workerCalendar` ( - `businessFk` tinyint NOT NULL, - `workerFk` tinyint NOT NULL, - `absenceTypeFk` tinyint NOT NULL, - `dated` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - -- -- Table structure for table `workerClockLog` -- @@ -39127,7 +41694,7 @@ DROP TABLE IF EXISTS `workerClockLog`; CREATE TABLE `workerClockLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, `originFk` int(11) NOT NULL, - `userFk` int(10) unsigned NOT NULL, + `userFk` int(10) unsigned DEFAULT NULL, `action` set('insert','update','delete','select') NOT NULL, `creationDate` timestamp NULL DEFAULT current_timestamp(), `description` text NOT NULL, @@ -39210,13 +41777,80 @@ CREATE TABLE `workerDocument` ( `worker` int(10) unsigned DEFAULT NULL, `document` int(11) DEFAULT NULL, `isReadableByWorker` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Indica si el empleado tiene permiso para acceder al documento', + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `workerDocument_ibfk_1` (`worker`), KEY `workerDocument_ibfk_2` (`document`), + KEY `workerDocument_fk_editor` (`editorFk`), + CONSTRAINT `workerDocument_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `workerDocument_ibfk_1` FOREIGN KEY (`worker`) REFERENCES `worker` (`userFk`) ON UPDATE CASCADE, CONSTRAINT `workerDocument_ibfk_2` FOREIGN KEY (`document`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerDocument_beforeInsert` + BEFORE INSERT ON `workerDocument` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerDocument_beforeUpdate` + BEFORE UPDATE ON `workerDocument` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerDocument_afterDelete` + AFTER DELETE ON `workerDocument` + FOR EACH ROW +BEGIN + INSERT INTO workerLog + SET `action` = 'delete', + `changedModel` = 'WorkerDocument', + `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 */ ; -- -- Table structure for table `workerEmergencyBoss` @@ -39250,6 +41884,91 @@ CREATE TABLE `workerHourPrice` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Recoge los acuerdos de los distintos convenios'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `workerIncome` +-- + +DROP TABLE IF EXISTS `workerIncome`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `workerIncome` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `debit` decimal(10,2) NOT NULL DEFAULT 0.00, + `credit` decimal(10,2) NOT NULL DEFAULT 0.00, + `incomeTypeFk` int(11) DEFAULT NULL, + `paymentDate` date DEFAULT NULL, + `workerFk` int(11) unsigned NOT NULL, + `concept` longtext DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `income_employeeId_incomeType_idx` (`incomeTypeFk`), + KEY `income_employee_workerFk_idx` (`workerFk`), + CONSTRAINT `income_employeeId_incomeType` FOREIGN KEY (`incomeTypeFk`) REFERENCES `vn2008`.`payroll_conceptos` (`conceptoid`) ON UPDATE CASCADE, + CONSTRAINT `income_employee_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerIncome_afterInsert` + AFTER INSERT ON `workerIncome` + FOR EACH ROW +BEGIN + CALL worker_updateBalance(NEW.workerFk,NEW.credit,NEW.debit); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerIncome_afterUpdate` + AFTER UPDATE ON `workerIncome` + FOR EACH ROW +BEGIN + CALL worker_updateBalance(NEW.workerFk,-OLD.credit,-OLD.debit); + + CALL worker_updateBalance(NEW.workerFk,NEW.credit,NEW.debit); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerIncome_afterDelete` + AFTER DELETE ON `workerIncome` + FOR EACH ROW +BEGIN + CALL worker_updateBalance(OLD.workerFk,-OLD.credit,-OLD.debit); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; + -- -- Table structure for table `workerIrpf` -- @@ -39341,8 +42060,8 @@ DROP TABLE IF EXISTS `workerLog`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workerLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `originFk` int(10) unsigned NOT NULL, - `userFk` int(10) unsigned NOT NULL, + `originFk` int(10) unsigned DEFAULT NULL, + `userFk` int(10) unsigned DEFAULT NULL, `action` set('insert','update','delete') NOT NULL, `creationDate` timestamp NULL DEFAULT current_timestamp(), `description` text NOT NULL, @@ -39372,8 +42091,6 @@ CREATE TABLE `workerMana` ( `amount` int(11) NOT NULL DEFAULT 0, `pricesModifierRate` double NOT NULL DEFAULT 0, `isPricesModifierActivated` tinyint(1) NOT NULL DEFAULT 1, - `minRate` decimal(3,2) NOT NULL DEFAULT -0.05, - `maxRate` decimal(3,2) NOT NULL DEFAULT 0.05, PRIMARY KEY (`workerFk`), KEY `fk_mana_spellers_Trabajadores_idx` (`workerFk`), CONSTRAINT `fk_mana_spellers_Trabajadores` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE @@ -39442,6 +42159,27 @@ CREATE TABLE `workerMistakeType` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `workerObservation` +-- + +DROP TABLE IF EXISTS `workerObservation`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `workerObservation` ( + `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, + `workerFk` int(10) unsigned DEFAULT NULL, + `userFk` int(10) unsigned DEFAULT NULL, + `text` text NOT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `workerFk_workerObservation_FK` (`workerFk`), + KEY `userFk_workerObservation_FK` (`userFk`), + CONSTRAINT `userFk_workerObservation_FK` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE, + CONSTRAINT `workerFk_workerObservation_FK` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Todas las observaciones referentes a un trabajador'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `workerRelatives` -- @@ -39589,11 +42327,11 @@ CREATE TABLE `workerTimeControl` ( /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerTimeControl_AI` AFTER INSERT ON `workerTimeControl` @@ -39641,27 +42379,12 @@ CREATE TABLE `workerTimeControlConfig` ( `longWeekDays` int(11) DEFAULT NULL COMMENT 'Días a tener en cuenta para calcular el descanso largo', `teleworkingStart` int(11) DEFAULT NULL COMMENT 'Hora comienzo jornada de los teletrabajdores expresada en segundos', `teleworkingStartBreakTime` int(11) DEFAULT NULL COMMENT 'Hora comienzo descanso de los teletrabjadores expresada en segundos', + `breakTimeSplitDay` int(11) unsigned DEFAULT 3600 COMMENT 'Tiempo de descanso a partir del cual se determina que la jornada es partida', + `dateSplitDay` date DEFAULT '2023-03-01' COMMENT 'Fecha a partir de la cual se tiene en cuenta el valor de configuración de breakTimeSplitDay', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin COMMENT='All values in seconds'; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `workerTimeControlConfig_` --- - -DROP TABLE IF EXISTS `workerTimeControlConfig_`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `workerTimeControlConfig_` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `warehouseFk` smallint(6) unsigned NOT NULL, - `host` varchar(45) NOT NULL, - PRIMARY KEY (`id`), - KEY `warehouseFk_1_idx` (`warehouseFk`), - CONSTRAINT `warehouseFk_2` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `workerTimeControlLog` -- @@ -39671,7 +42394,7 @@ DROP TABLE IF EXISTS `workerTimeControlLog`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workerTimeControlLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `userFk` int(10) NOT NULL, + `userFk` int(10) DEFAULT NULL, `created` datetime NOT NULL DEFAULT current_timestamp(), `description` varchar(45) NOT NULL, PRIMARY KEY (`id`) @@ -39811,163 +42534,6 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `workers20190711` --- - -DROP TABLE IF EXISTS `workers20190711`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `workers20190711` ( - `person_id` int(11) NOT NULL DEFAULT 0, - `business_id` int(11) NOT NULL DEFAULT 0, - `Apellidos` varchar(60) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, - `Nombre` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `nif` varchar(15) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `Fecha_Inicio` date DEFAULT NULL, - `Fecha_Fin` date DEFAULT NULL, - `departamento` varchar(45) NOT NULL, - `Jornada_Semanal` smallint(6) DEFAULT NULL, - `Codigo_Contrato` int(11) DEFAULT NULL, - `userFk` int(11) NOT NULL, - PRIMARY KEY (`person_id`), - UNIQUE KEY `userFk_UNIQUE` (`userFk`), - UNIQUE KEY `nif_UNIQUE` (`nif`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `workers20190711_FichadasAbril` --- - -DROP TABLE IF EXISTS `workers20190711_FichadasAbril`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `workers20190711_FichadasAbril` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `person_id` int(11) NOT NULL DEFAULT 0, - `nif` varchar(15) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `Apellidos` varchar(60) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, - `Nombre` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `Fecha` date DEFAULT NULL, - `Hora` int(2) DEFAULT NULL, - `Minuto` int(2) DEFAULT NULL, - `sumable` double DEFAULT NULL, - `jornada` decimal(5,2) NOT NULL DEFAULT 8.00, - PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `workers20190711_FichadasJulio11` --- - -DROP TABLE IF EXISTS `workers20190711_FichadasJulio11`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `workers20190711_FichadasJulio11` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `person_id` int(11) NOT NULL DEFAULT 0, - `nif` varchar(15) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `Apellidos` varchar(60) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, - `Nombre` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `Fecha` date DEFAULT NULL, - `Hora` int(2) DEFAULT NULL, - `Minuto` int(2) DEFAULT NULL, - `sumable` double DEFAULT NULL, - `jornada` decimal(5,2) NOT NULL DEFAULT 8.00, - PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `workers20190711_FichadasJunio` --- - -DROP TABLE IF EXISTS `workers20190711_FichadasJunio`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `workers20190711_FichadasJunio` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `person_id` int(11) NOT NULL DEFAULT 0, - `nif` varchar(15) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `Apellidos` varchar(60) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, - `Nombre` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `Fecha` date DEFAULT NULL, - `Hora` int(2) DEFAULT NULL, - `Minuto` int(2) DEFAULT NULL, - `sumable` double DEFAULT NULL, - `jornada` decimal(5,2) NOT NULL DEFAULT 8.00, - PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `workers20190711_FichadasMayo` --- - -DROP TABLE IF EXISTS `workers20190711_FichadasMayo`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `workers20190711_FichadasMayo` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `person_id` int(11) NOT NULL DEFAULT 0, - `nif` varchar(15) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `Apellidos` varchar(60) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, - `Nombre` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `Fecha` date DEFAULT NULL, - `Hora` int(2) DEFAULT NULL, - `Minuto` int(2) DEFAULT NULL, - `sumable` double DEFAULT NULL, - `jornada` decimal(5,2) NOT NULL DEFAULT 8.00, - PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `workers20190711_FichadasOctubre` --- - -DROP TABLE IF EXISTS `workers20190711_FichadasOctubre`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `workers20190711_FichadasOctubre` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `person_id` int(11) NOT NULL DEFAULT 0, - `nif` varchar(15) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `Apellidos` varchar(60) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, - `Nombre` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `Fecha` date DEFAULT NULL, - `Hora` int(2) DEFAULT NULL, - `Minuto` int(2) DEFAULT NULL, - `sumable` double DEFAULT NULL, - `jornada` decimal(5,2) NOT NULL DEFAULT 8.00, - PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `workers20190711_Garrote` --- - -DROP TABLE IF EXISTS `workers20190711_Garrote`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `workers20190711_Garrote` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `person_id` int(11) NOT NULL DEFAULT 0, - `nif` varchar(15) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `Apellidos` varchar(60) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, - `Nombre` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `Fecha` date DEFAULT NULL, - `Hora` int(2) DEFAULT NULL, - `Minuto` int(2) DEFAULT NULL, - `sumable` double DEFAULT NULL, - `jornada` decimal(5,2) NOT NULL DEFAULT 8.00, - PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `workingHours` -- @@ -40042,12 +42608,79 @@ CREATE TABLE `zone` ( `m3Max` decimal(10,2) unsigned DEFAULT NULL, `itemMaxSize` int(11) DEFAULT NULL COMMENT 'tamaño maximo de los articulos que esa ruta puede transportar', `code` varchar(45) DEFAULT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `fk_zone_2_idx` (`agencyModeFk`), KEY `zone_name_idx` (`name`), - CONSTRAINT `fk_zone_2` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION + KEY `zone_fk_editor` (`editorFk`), + CONSTRAINT `fk_zone_2` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT `zone_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zone_beforeInsert` + BEFORE INSERT ON `zone` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zone_beforeUpdate` + BEFORE UPDATE ON `zone` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zone_afterDelete` + AFTER DELETE ON `zone` + FOR EACH ROW +BEGIN + INSERT INTO zoneLog + SET `action` = 'delete', + `changedModel` = 'Zone', + `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 */ ; -- -- Table structure for table `zoneAgencyMode` @@ -40138,11 +42771,78 @@ CREATE TABLE `zoneEvent` ( `price` decimal(10,2) DEFAULT NULL, `bonus` decimal(10,2) DEFAULT NULL, `m3Max` decimal(10,2) unsigned DEFAULT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `zoneFk` (`zoneFk`,`type`,`dated`), + KEY `zoneEvent_fk_editor` (`editorFk`), + CONSTRAINT `zoneEvent_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `zoneEvent_ibfk_1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneEvent_beforeInsert` + BEFORE INSERT ON `zoneEvent` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneEvent_beforeUpdate` + BEFORE UPDATE ON `zoneEvent` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneEvent_afterDelete` + AFTER DELETE ON `zoneEvent` + FOR EACH ROW +BEGIN + INSERT INTO zoneLog + SET `action` = 'delete', + `changedModel` = 'zoneEvent', + `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 */ ; -- -- Table structure for table `zoneExclusion` @@ -40157,9 +42857,12 @@ CREATE TABLE `zoneExclusion` ( `dated` date NOT NULL, `created` timestamp NOT NULL DEFAULT current_timestamp(), `userFk` int(11) DEFAULT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `zoneFk_2` (`zoneFk`,`dated`), KEY `zoneFk` (`zoneFk`), + KEY `zoneExclusion_fk_editor` (`editorFk`), + CONSTRAINT `zoneExclusion_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `zoneExclusion_ibfk_1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -40176,7 +42879,7 @@ DELIMITER ;; BEFORE INSERT ON `zoneExclusion` FOR EACH ROW BEGIN - + SET NEW.editorFk = account.myUser_getId(); SET NEW.userFk = account.myUser_getId(); END */;; @@ -40198,7 +42901,7 @@ DELIMITER ;; BEFORE UPDATE ON `zoneExclusion` FOR EACH ROW BEGIN - + SET NEW.editorFk = account.myUser_getId(); SET NEW.userFk = account.myUser_getId(); END */;; @@ -40207,6 +42910,30 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneExclusion_afterDelete` + AFTER DELETE ON `zoneExclusion` + FOR EACH ROW +BEGIN + INSERT INTO zoneLog + SET `action` = 'delete', + `changedModel` = 'zoneExclusion', + `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 */ ; -- -- Table structure for table `zoneExclusionGeo` @@ -40339,12 +43066,79 @@ CREATE TABLE `zoneIncluded` ( `zoneFk` int(11) NOT NULL, `geoFk` int(11) NOT NULL, `isIncluded` tinyint(1) DEFAULT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`zoneFk`,`geoFk`), KEY `geoFk_idx` (`geoFk`), + KEY `zoneIncluded_fk_editor` (`editorFk`), CONSTRAINT `zoneFk2` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `zoneGeoFk2` FOREIGN KEY (`geoFk`) REFERENCES `zoneGeo` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `zoneGeoFk2` FOREIGN KEY (`geoFk`) REFERENCES `zoneGeo` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `zoneIncluded_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneIncluded_beforeInsert` + BEFORE INSERT ON `zoneIncluded` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneIncluded_beforeUpdate` + BEFORE UPDATE ON `zoneIncluded` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneIncluded_afterDelete` + AFTER DELETE ON `zoneIncluded` + FOR EACH ROW +BEGIN + INSERT INTO zoneLog + SET `action` = 'delete', + `changedModel` = 'zoneIncluded', + `changedModelId` = OLD.zoneFk, + `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 */ ; -- -- Table structure for table `zoneItemType` @@ -40358,10 +43152,10 @@ CREATE TABLE `zoneItemType` ( `zoneFk` int(11) NOT NULL, `itemTypeFk` smallint(5) unsigned NOT NULL, PRIMARY KEY (`id`), - KEY `zoneItemType_FK` (`zoneFk`), + UNIQUE KEY `zoneType_itemTypeFk_UNIQUE` (`zoneFk`,`itemTypeFk`), KEY `zoneItemType_FK_1` (`itemTypeFk`), CONSTRAINT `zoneItemType_FK` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `zoneItemType_FK_1` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `zoneItemType_FK_1` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Combinaciones prohibidas entre zone e itemType al calcular el catálogo de items'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -40374,7 +43168,7 @@ DROP TABLE IF EXISTS `zoneLog`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `zoneLog` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `originFk` int(10) NOT NULL, + `originFk` int(11) DEFAULT NULL, `userFk` int(10) unsigned DEFAULT NULL, `action` set('insert','update','delete') NOT NULL, `creationDate` timestamp NULL DEFAULT current_timestamp(), @@ -40403,13 +43197,80 @@ CREATE TABLE `zoneWarehouse` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `zoneFk` int(11) NOT NULL, `warehouseFk` smallint(6) unsigned NOT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `zoneFk` (`zoneFk`,`warehouseFk`), KEY `warehouseFk` (`warehouseFk`), + KEY `zoneWarehouse_fk_editor` (`editorFk`), + CONSTRAINT `zoneWarehouse_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `zoneWarehouse_fk_warehouse` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `zoneWarehouse_ibfk_1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneWarehouse_beforeInsert` + BEFORE INSERT ON `zoneWarehouse` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneWarehouse_beforeUpdate` + BEFORE UPDATE ON `zoneWarehouse` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneWarehouse_afterDelete` + AFTER DELETE ON `zoneWarehouse` + FOR EACH ROW +BEGIN + INSERT INTO zoneLog + SET `action` = 'delete', + `changedModel` = 'ZoneWarehouse', + `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 */ ; -- -- Dumping events for database 'vn' @@ -40427,7 +43288,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `collection_make` ON SCHEDULE EVERY 5 MINUTE STARTS '2022-09-15 00:00:00' ON COMPLETION PRESERVE DISABLE ON SLAVE DO CALL vn.collection_make */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `collection_make` ON SCHEDULE EVERY 5 MINUTE STARTS '2022-09-15 00:00:00' ON COMPLETION PRESERVE ENABLE DO CALL vn.collection_make */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -40445,7 +43306,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `department_doCalc` ON SCHEDULE EVERY 15 SECOND STARTS '2019-11-15 00:00:00' ON COMPLETION PRESERVE DISABLE ON SLAVE DO CALL vn.department_doCalc */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `department_doCalc` ON SCHEDULE EVERY 15 SECOND STARTS '2019-11-15 00:00:00' ON COMPLETION PRESERVE ENABLE DO CALL vn.department_doCalc */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -40463,7 +43324,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `envialiaThreHoldChecker` ON SCHEDULE EVERY 1 DAY STARTS '2022-01-28 09:52:46' ON COMPLETION NOT PRESERVE DISABLE ON SLAVE DO BEGIN +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `envialiaThreHoldChecker` ON SCHEDULE EVERY 1 DAY STARTS '2022-01-28 09:52:46' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN DECLARE vActualNumber BIGINT; DECLARE vEndRange BIGINT; DECLARE vIsAlreadyNotified BOOLEAN; @@ -40497,6 +43358,24 @@ 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 `greuge_notify` */;; +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=`root`@`localhost`*/ /*!50106 EVENT `greuge_notify` ON SCHEDULE EVERY 1 DAY STARTS '2023-01-01 00:07:00' ON COMPLETION NOT PRESERVE ENABLE COMMENT 'Notifies subscribed users of events in wrong greuges' DO CALL vn.greuge_notifyEvents(util.CURDATE(), util.CURDATE()) */ ;; +/*!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 `mysqlConnectionsSorter_kill` */;; DELIMITER ;; /*!50003 SET @saved_cs_client = @@character_set_client */ ;; @@ -40509,7 +43388,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `mysqlConnectionsSorter_kill` ON SCHEDULE EVERY 1 MINUTE STARTS '2021-10-28 09:56:27' ON COMPLETION NOT PRESERVE DISABLE ON SLAVE DO CALL mysqlConnectionsSorter_kill() */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `mysqlConnectionsSorter_kill` ON SCHEDULE EVERY 1 MINUTE STARTS '2021-10-28 09:56:27' ON COMPLETION NOT PRESERVE ENABLE DO CALL mysqlConnectionsSorter_kill() */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -40527,7 +43406,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `printQueue_check` ON SCHEDULE EVERY 10 MINUTE STARTS '2022-01-28 09:52:46' ON COMPLETION PRESERVE DISABLE ON SLAVE DO BEGIN +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `printQueue_check` ON SCHEDULE EVERY 10 MINUTE STARTS '2022-01-28 09:52:46' ON COMPLETION PRESERVE ENABLE DO BEGIN DECLARE vCurrentCount INT; DECLARE vCheckSum INT; @@ -40636,7 +43515,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `route_doRecalc` ON SCHEDULE EVERY 10 SECOND STARTS '2021-07-08 07:32:23' ON COMPLETION PRESERVE DISABLE ON SLAVE DO CALL route_doRecalc */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `route_doRecalc` ON SCHEDULE EVERY 10 SECOND STARTS '2021-07-08 07:32:23' ON COMPLETION PRESERVE ENABLE DO CALL route_doRecalc */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -40654,7 +43533,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `sale_checkWithoutComponents` ON SCHEDULE EVERY 10 MINUTE STARTS '2020-05-04 11:56:23' ON COMPLETION PRESERVE DISABLE DO call sale_checkNoComponents(DATE_ADD(util.VN_NOW(), INTERVAL -10 MINUTE),DATE_ADD(util.VN_NOW(), INTERVAL -1 MINUTE)) */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `sale_checkWithoutComponents` ON SCHEDULE EVERY 10 MINUTE STARTS '2020-05-04 11:56:23' ON COMPLETION PRESERVE DISABLE ON SLAVE DO call sale_checkNoComponents(DATE_ADD(util.VN_NOW(), INTERVAL -10 MINUTE),DATE_ADD(util.VN_NOW(), INTERVAL -1 MINUTE)) */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -40672,7 +43551,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `ticketClosure` ON SCHEDULE EVERY 1 DAY STARTS '2017-09-18 00:30:00' ON COMPLETION NOT PRESERVE DISABLE COMMENT 'Realiza el cierre de todos los almacenes del dia actual' DO CALL ticketClosureMultiWarehouse(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 DAY)) */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `ticketClosure` ON SCHEDULE EVERY 1 DAY STARTS '2017-09-18 00:30:00' ON COMPLETION NOT PRESERVE DISABLE ON SLAVE COMMENT 'Realiza el cierre de todos los almacenes del dia actual' DO CALL ticketClosureMultiWarehouse(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 DAY)) */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -40690,7 +43569,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `ticket_doRecalc` ON SCHEDULE EVERY 10 SECOND STARTS '2022-01-28 09:29:18' ON COMPLETION PRESERVE DISABLE ON SLAVE DO CALL ticket_doRecalc */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `ticket_doRecalc` ON SCHEDULE EVERY 10 SECOND STARTS '2022-01-28 09:29:18' ON COMPLETION PRESERVE ENABLE DO CALL ticket_doRecalc */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -40708,7 +43587,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `travel_doRecalc` ON SCHEDULE EVERY 15 SECOND STARTS '2019-05-17 10:52:29' ON COMPLETION PRESERVE DISABLE ON SLAVE DO CALL travel_doRecalc */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `travel_doRecalc` ON SCHEDULE EVERY 15 SECOND STARTS '2019-05-17 10:52:29' ON COMPLETION PRESERVE ENABLE DO CALL travel_doRecalc */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -40726,35 +43605,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `vehicle_notify` ON SCHEDULE EVERY 1 DAY STARTS '2022-01-01 00:07:00' ON COMPLETION NOT PRESERVE DISABLE ON SLAVE COMMENT 'Notifies subscribed users of events in vehicles that are about t' DO CALL vn.vehicle_notifyEvents */ ;; -/*!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 `workerTimeControl_sendMail` */;; -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 = utf8mb3 */ ;; -/*!50003 SET character_set_results = utf8mb3 */ ;; -/*!50003 SET collation_connection = utf8mb3_general_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=`root`@`localhost`*/ /*!50106 EVENT `workerTimeControl_sendMail` ON SCHEDULE EVERY 1 WEEK STARTS '2020-11-25 08:00:00' ON COMPLETION NOT PRESERVE DISABLE ON SLAVE DO BEGIN - DECLARE vWeek,vYear INT; - - SELECT week,year INTO vWeek,vYear - FROM vn.time - WHERE dated IN (DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL -4 DAY)) - GROUP BY year,week - LIMIT 1; - - CALL vn.workerTimeControl_sendMail(vWeek, vYear, NULL); -END */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `vehicle_notify` ON SCHEDULE EVERY 1 DAY STARTS '2022-01-01 00:07:00' ON COMPLETION NOT PRESERVE ENABLE COMMENT 'Notifies subscribed users of events in vehicles that are about t' DO CALL vn.vehicle_notifyEvents */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -40772,7 +43623,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `worker_updateChangedBusiness` ON SCHEDULE EVERY 1 DAY STARTS '2000-01-01 00:00:05' ON COMPLETION NOT PRESERVE DISABLE ON SLAVE DO CALL worker_updateChangedBusiness */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `worker_updateChangedBusiness` ON SCHEDULE EVERY 1 DAY STARTS '2000-01-01 00:00:05' ON COMPLETION NOT PRESERVE ENABLE DO CALL worker_updateChangedBusiness */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -40790,7 +43641,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `zoneGeo_doCalc` ON SCHEDULE EVERY 15 SECOND STARTS '2019-09-13 15:30:47' ON COMPLETION PRESERVE DISABLE ON SLAVE DO CALL vn.zoneGeo_doCalc */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `zoneGeo_doCalc` ON SCHEDULE EVERY 15 SECOND STARTS '2019-09-13 15:30:47' ON COMPLETION PRESERVE ENABLE DO CALL vn.zoneGeo_doCalc */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -40812,7 +43663,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `addressTaxArea`(vAddresId INT, vCompanyId INT) RETURNS varchar(25) CHARSET utf8mb3 +CREATE DEFINER=`root`@`localhost` FUNCTION `addressTaxArea`(vAddresId INT, vCompanyId INT) RETURNS varchar(25) CHARSET utf8mb3 COLLATE utf8mb3_general_ci DETERMINISTIC BEGIN /** @@ -41145,35 +43996,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP FUNCTION IF EXISTS `clientGetDebt` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `clientGetDebt`(`vClient` INT, `vDate` DATE) RETURNS decimal(10,2) - READS SQL DATA -BEGIN -/** - * Returns the risk of a customer. - * - * @param vClient client id - * @param vDate date to check the risk - * @return client risk - */ - DECLARE vDebt DECIMAL(10,2); - SELECT vn.client_getDebt(vClient,vDate) INTO vDebt; - RETURN vDebt; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP FUNCTION IF EXISTS `clientGetMana` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -41291,7 +44113,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `clientTaxArea`(vClientId INT, vCompanyId INT) RETURNS varchar(25) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `clientTaxArea`(vClientId INT, vCompanyId INT) RETURNS varchar(25) CHARSET utf8mb3 COLLATE utf8mb3_general_ci READS SQL DATA BEGIN /** @@ -41547,7 +44369,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `client_getSalesPersonCode`(vClientFk INT, vDated DATE) RETURNS varchar(3) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `client_getSalesPersonCode`(vClientFk INT, vDated DATE) RETURNS varchar(3) CHARSET utf8mb3 COLLATE utf8mb3_general_ci DETERMINISTIC BEGIN /** @@ -41585,7 +44407,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `client_getSalesPersonCodeByTicket`(vTicketFk INT) RETURNS varchar(3) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `client_getSalesPersonCodeByTicket`(vTicketFk INT) RETURNS varchar(3) CHARSET utf8mb3 COLLATE utf8mb3_general_ci DETERMINISTIC BEGIN /** @@ -41610,42 +44432,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP FUNCTION IF EXISTS `collectionExpeditionLacks` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `collectionExpeditionLacks`(vCollectionFk INT) RETURNS varchar(100) CHARSET utf8 COLLATE utf8_unicode_ci - DETERMINISTIC -BEGIN -/** - * Return message with tickets and collection if there is tickets of a collection without expeditions. - * - * @param vCollectionFk The collection to check - * @return An array with collection and tickets without expeditions - */ - DECLARE vAnswer VARCHAR(100) DEFAULT ''; - - IF collection_isPacked(vCollectionFk) = FALSE THEN - SELECT CONCAT('Colección: ',tc.collectionFk,' Tickets: ' , GROUP_CONCAT(tc.ticketFk) ) INTO vAnswer - FROM vn.ticketCollection tc - LEFT JOIN vn.expedition e ON e.ticketFk = tc.ticketFk - WHERE tc.collectionFk = vCollectionFk - AND ISNULL(e.id); - END IF; - - RETURN vAnswer; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP FUNCTION IF EXISTS `collection_isPacked` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -41972,8 +44758,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `entry_getCommission`( - vTravelFk INT, +CREATE DEFINER=`root`@`localhost` FUNCTION `entry_getCommission`(vTravelFk INT, vCurrencyFk INT, vSupplierFk INT ) RETURNS int(11) @@ -42042,8 +44827,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `entry_getCurrency`( - vCurrency INT, +CREATE DEFINER=`root`@`localhost` FUNCTION `entry_getCurrency`(vCurrency INT, vSupplierFk INT ) RETURNS int(11) READS SQL DATA @@ -42259,7 +45043,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `getAlert3State`(vTicket INT) RETURNS varchar(45) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `getAlert3State`(vTicket INT) RETURNS varchar(45) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci READS SQL DATA BEGIN DECLARE vDeliveryType INTEGER DEFAULT 0; @@ -42309,7 +45093,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `getAlert3StateTest`(vTicket INT) RETURNS varchar(45) CHARSET latin1 +CREATE DEFINER=`root`@`localhost` FUNCTION `getAlert3StateTest`(vTicket INT) RETURNS varchar(45) CHARSET latin1 COLLATE latin1_swedish_ci READS SQL DATA BEGIN DECLARE vDeliveryType INTEGER DEFAULT 0; @@ -42745,7 +45529,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `getWorkerCode`() RETURNS varchar(3) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `getWorkerCode`() RETURNS varchar(3) CHARSET utf8mb3 COLLATE utf8mb3_general_ci READS SQL DATA BEGIN DECLARE vUserCode VARCHAR(3) CHARSET utf8 COLLATE utf8_unicode_ci; @@ -42918,6 +45702,49 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP FUNCTION IF EXISTS `invoiceOut_getMaxIssued` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` FUNCTION `invoiceOut_getMaxIssued`(vSerial VARCHAR(2), + vCompanyFk INT, + vYear INT +) RETURNS date + READS SQL DATA +BEGIN +/** + * Retorna la fecha a partir de la cual es válido emitir una factura + * + * @param vSerial Serie de facturación + * @param vCompanyFk Empresa factura emitida + * @param vYear Año contable + * @return vInvoiceOutIssued fecha factura válida + */ + DECLARE vInvoiceOutIssued DATE; + DECLARE vFirstDayOfYear DATE; + + SET vFirstDayOfYear := MAKEDATE(vYear, 1); + + SELECT IFNULL(MAX(io.issued), vFirstDayOfYear) INTO vInvoiceOutIssued + FROM invoiceOut io + WHERE io.serial = vSerial + AND io.companyFk = vCompanyFk + AND io.issued BETWEEN vFirstDayOfYear + AND util.lastDayOfYear(vFirstDayOfYear); + + RETURN vInvoiceOutIssued; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP FUNCTION IF EXISTS `invoiceOut_getPath` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -42928,7 +45755,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `invoiceOut_getPath`(vSelf INT) RETURNS varchar(255) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `invoiceOut_getPath`(vSelf INT) RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_general_ci DETERMINISTIC BEGIN DECLARE vIssued DATE; @@ -42961,13 +45788,14 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `invoiceOut_getWeight`(vInvoice VARCHAR(15)) RETURNS decimal(10,2) +CREATE DEFINER=`root`@`localhost` FUNCTION `invoiceOut_getWeight`(vInvoiceRef VARCHAR(15) +) RETURNS decimal(10,2) READS SQL DATA BEGIN /** * Calcula el peso de una factura emitida * - * @param vInvoice Id de la factura + * @param vInvoiceRef referencia de la factura * @return vTotalWeight peso de la factura */ DECLARE vTotalWeight DECIMAL(10,2); @@ -42981,7 +45809,7 @@ BEGIN JOIN item i ON i.id = s.itemFk JOIN itemCost ic ON ic.itemFk = i.id AND ic.warehouseFk = t.warehouseFk - WHERE t.refFk = vInvoice + WHERE t.refFk = vInvoiceRef AND i.intrastatFk; RETURN vTotalWeight; @@ -43001,7 +45829,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `invoiceSerial`(vClientFk INT, vCompanyFk INT, vType CHAR(1)) RETURNS char(1) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `invoiceSerial`(vClientFk INT, vCompanyFk INT, vType CHAR(1)) RETURNS char(1) CHARSET utf8mb3 COLLATE utf8mb3_general_ci DETERMINISTIC BEGIN /** @@ -43350,7 +46178,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `item_getFhImage`(itemFk INT) RETURNS varchar(255) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `item_getFhImage`(itemFk INT) RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN DECLARE vImageUrl VARCHAR(255); @@ -43379,7 +46207,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `item_getPackage`(vItemFk INT) RETURNS varchar(50) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `item_getPackage`(vItemFk INT) RETURNS varchar(50) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN @@ -43774,7 +46602,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `phytoPassport`(vRef VARCHAR(15)) RETURNS text CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `phytoPassport`(vRef VARCHAR(15)) RETURNS text CHARSET utf8mb3 COLLATE utf8mb3_general_ci DETERMINISTIC BEGIN DECLARE vPhyto TEXT CHARSET utf8 COLLATE utf8_unicode_ci; @@ -44073,7 +46901,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `testCIF`(vCIF VARCHAR(9)) RETURNS varchar(10) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `testCIF`(vCIF VARCHAR(9)) RETURNS varchar(10) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN @@ -44266,7 +47094,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `ticketCollection_getNoPacked`(vCollectionFk INT) RETURNS varchar(100) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `ticketCollection_getNoPacked`(vCollectionFk INT) RETURNS varchar(100) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN @@ -44348,7 +47176,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `ticketPositionInPath`(vTicketId INT) RETURNS varchar(10) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `ticketPositionInPath`(vTicketId INT) RETURNS varchar(10) CHARSET utf8mb3 COLLATE utf8mb3_general_ci DETERMINISTIC BEGIN @@ -44439,7 +47267,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `ticketSplitCounter`(vTicketFk INT) RETURNS varchar(15) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `ticketSplitCounter`(vTicketFk INT) RETURNS varchar(15) CHARSET utf8mb3 COLLATE utf8mb3_general_ci READS SQL DATA BEGIN DECLARE vSplitCounter VARCHAR(15); @@ -44733,65 +47561,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP FUNCTION IF EXISTS `ticket_getWithParameters` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `ticket_getWithParameters`(vClientFk INT, vWarehouseFk INT, vShipped DATE, vAddressFk INT, vCompanyFk INT, vAgencyModeFk INT) RETURNS int(11) - DETERMINISTIC -BEGIN -/** - * Devuelve un ticket con los parametros, en caso de no existir lo crea - * - * @param vClientFk Cliente - * @param vWarehouseFk almacen - * @param vShipped Fecha de preparacion - * @param vAddressFk Consignatario - * @param vCompanyFk Empresa - * @param vAgencyModeFk agencia - */ - - DECLARE vTicket INT; - - SELECT t.id INTO vTicket - FROM vn.ticket t - WHERE (t.clientFk <=> vClientFk OR vClientFk IS NULL) - AND (t.warehouseFk <=> vWarehouseFk OR vWarehouseFk IS NULL) - AND (t.shipped <=> vShipped OR vShipped IS NULL) - AND (t.addressFk <=> vAddressFk OR vAddressFk IS NULL) - AND (t.companyFk <=> vCompanyFk OR vCompanyFk IS NULL) - AND (t.agencyModeFk <=> vAgencyModeFk OR vAgencyModeFk IS NULL) - LIMIT 1; - - IF vTicket IS NULL THEN - CALL vn.ticket_add( - vClientFk, - IFNULL(vShipped, util.VN_CURDATE()), - vWarehouseFk, - vCompanyFk, - vAddressFk, - vAgencyModeFk, - NULL, - vShipped, - `account`.`myUser_getId`(), - TRUE, - vTicket - ); - END IF; - - RETURN vTicket; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP FUNCTION IF EXISTS `ticket_HasUbication` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -44843,7 +47612,7 @@ BEGIN */ DECLARE vIsTicketInTime BOOL; - SELECT TIMEDIFF(util.VN_CURTIME(), zc.hour + INTERVAL tc.packingDelay HOUR) > 0 INTO vIsTicketInTime + SELECT TIMEDIFF(CURRENT_TIME(), zc.hour + INTERVAL tc.packingDelay HOUR) > 0 INTO vIsTicketInTime FROM vn.ticket t JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk LEFT JOIN vn.ticketConfig tc ON TRUE @@ -44867,8 +47636,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `till_new`( - vClient INT +CREATE DEFINER=`root`@`localhost` FUNCTION `till_new`(vClient INT ,vBank INT ,vAmount DOUBLE ,vConcept VARCHAR(25) @@ -44959,7 +47727,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `timeWorkerControl_getDirection`(vUserFk INT, vTimed DATETIME) RETURNS varchar(6) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `timeWorkerControl_getDirection`(vUserFk INT, vTimed DATETIME) RETURNS varchar(6) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci READS SQL DATA BEGIN /** @@ -45273,7 +48041,6 @@ BEGIN * @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 @@ -45283,7 +48050,6 @@ BEGIN ELSE RETURN FALSE; END IF; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -45339,7 +48105,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `workerTimeControl_add`( vUserFk INT, vWarehouseFk INT, vTimed DATETIME, vIsManual BOOL) RETURNS int(11) +CREATE DEFINER=`root`@`localhost` FUNCTION `workerTimeControl_add`(vUserFk INT, vWarehouseFk INT, vTimed DATETIME, vIsManual BOOL) RETURNS int(11) DETERMINISTIC BEGIN DECLARE vDirection VARCHAR(6); @@ -45408,7 +48174,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `workerTimeControl_addDirection`( vUserFk INT, vWarehouseFk INT, vTimed DATETIME, vIsManual BOOL) RETURNS int(11) +CREATE DEFINER=`root`@`localhost` FUNCTION `workerTimeControl_addDirection`(vUserFk INT, vWarehouseFk INT, vTimed DATETIME, vIsManual BOOL) RETURNS int(11) DETERMINISTIC BEGIN DECLARE vDirection VARCHAR(6); @@ -45516,8 +48282,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `xdiario_new`( - vAsiento INT, +CREATE DEFINER=`root`@`localhost` FUNCTION `xdiario_new`(vAsiento INT, vDated DATE, vSubaccount VARCHAR(12), vAccount VARCHAR(12), @@ -46071,7 +48836,6 @@ BEGIN FROM tmp.buyUltimateFromInterval WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL) AND landed > vDated; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -46126,9 +48890,8 @@ BEGIN WHERE t.landed BETWEEN vStarted AND vEnded AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) AND b.price2 > 0 - AND NOT b.isIgnored AND b.quantity > 0 - ORDER BY t.landed DESC, b.id DESC + ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC LIMIT 10000000000000000000) sub GROUP BY itemFk, warehouseFk; @@ -46353,9 +49116,12 @@ DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_getSplit`(vSelf INT, vDated DATE) BEGIN /** - * Devuelve las ventas de una compra + * Devuelve tantos registros como etiquetas se necesitan para cada uno de los cubos o cajas de + * las ventas correspondientes a la compra que se pasa como parámetro, en los almacenes que tienen + * habilitada la venta de productos con stock virtual, aunque los productos pueden ser de cualquier tipo. * * @param vSelf Identificador de vn.buy + * @param vDated Fecha de preparación de las ventas que queremos etiquetar */ DECLARE vItemFk INT; DECLARE vPacking INT; @@ -46376,6 +49142,7 @@ BEGIN AND t.shipped >= vDated AND w.isLogiflora AND IFNULL(l.stem, 0) < s.quantity + ORDER BY s.quantity = vRemaining DESC LOCK IN SHARE MODE; DECLARE CONTINUE HANDLER FOR NOT FOUND @@ -46421,8 +49188,18 @@ BEGIN SET vLabels = vAmount DIV vPacking; - INSERT INTO tmp.split - VALUES (vSaleFk, vLabels, 0); + -- Se inserta una linea por cada etiqueta + SET vCounter = 1; + + WHILE vLabels >= vCounter DO + INSERT INTO tmp.split + SET + id = vSaleFk, + labels = vLabels, + counter = vCounter; + + SET vCounter = vCounter + 1; + END WHILE; INSERT INTO vn.saleLabel SET @@ -46432,21 +49209,10 @@ BEGIN ON DUPLICATE KEY UPDATE stem = stem + VALUES(stem), label = label + VALUES(label); - END LOOP; CLOSE cur; - -- Aumentar las lineas de tmp.split para tener una por cada etiqueta - WHILE vLabels > vCounter DO - INSERT INTO tmp.split(id, labels, counter) - VALUES(vSaleFk, vLabels, vCounter); - SET vCounter = vCounter + 1; - END WHILE; - - UPDATE tmp.split - SET counter = counter + 1; - -- Devuelve los splits creados SELECT CONCAT(sp.counter,'/',sp.labels) labels, COALESCE(sfc.nickname, sfa.nickname, a.nickname) destination, @@ -46468,7 +49234,6 @@ BEGIN LEFT JOIN vn.splitFilter sfc ON sfc.clientFk = t.clientFk; -- Limpia y confirma cambios - DROP TEMPORARY TABLE tmp.split; @@ -46814,7 +49579,6 @@ BEGIN * @param vItemFk Id del Artículo * @param vGrouping Cantidad de grouping */ - CALL vn.buyUltimate(vWarehouseFk, util.VN_CURDATE()); UPDATE vn.buy b @@ -47466,170 +50230,6 @@ BEGIN tmp.ticketComponentPrice, tmp.ticketComponent, tmp.ticketLot; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `catalog_test` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_test`() -proc: BEGIN -/** - * Calcula los articulos disponibles y sus precios - * - * @table tmp.item(itemFk) Listado de artículos a calcular - * @param vLanded Fecha de recepcion de mercancia - * @param vAddressFk Id del consignatario - * @param vAgencyModeFk Id de la agencia - * @return tmp.ticketCalculateItem(itemFk, available, producer, - * item, size, stems, category, inkFk, image, origin, price) - * @return tmp.ticketLot(warehouseFk, itemFk, available, buyFk) - * @return tmp.ticketComponent - * @return tmp.ticketComponentPrice - * @return tmp.zoneGetShipped - */ - DECLARE vLanded DATE DEFAULT DATE_ADD(util.VN_CURDATE(),INTERVAL 2 DAY); - DECLARE vAddressFk INT DEFAULT 24526; - DECLARE vAgencyModeFk INT DEFAULT 639; - DECLARE vAvailableCalc INT; - DECLARE vShipped DATE; - DECLARE vWarehouseFk SMALLINT; - DECLARE vZoneFk INT; - DECLARE vDone BOOL; - DECLARE cTravelTree CURSOR FOR - SELECT zoneFk, warehouseFk, shipped FROM tmp.zoneGetShipped; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - DROP TEMPORARY TABLE IF EXISTS tmp.item; - CREATE TEMPORARY TABLE tmp.item - ENGINE = MEMORY - SELECT 10 itemFk; - -- Establece los almacenes y las fechas que van a entrar al disponible -SELECT 1; - CALL vn.zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, FALSE); -SELECT 2; - DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; - CREATE TEMPORARY TABLE tmp.ticketLot( - `warehouseFk` smallint(5) unsigned NOT NULL, - `itemFk` int(11) NOT NULL, - `available` double DEFAULT NULL, - `buyFk` int(11) DEFAULT NULL, - `fix` tinyint(3) unsigned DEFAULT '0', - `zoneFk` int(11) NOT NULL, - KEY `itemFk` (`itemFk`), - KEY `item_warehouse` (`itemFk`,`warehouseFk`) USING HASH - ) ENGINE=MEMORY DEFAULT CHARSET=utf8; - CALL catalog_componentPrepare(); - -SELECT 3; - DROP TEMPORARY TABLE IF EXISTS tmp.ticketCalculateItem; - CREATE TEMPORARY TABLE tmp.ticketCalculateItem( - itemFk INT(11) NOT NULL, - available INT(11), - producer VARCHAR(50), - item VARCHAR(50), - size INT(10) UNSIGNED, - stems INT(11), - category VARCHAR(3), - inkFk VARCHAR(3), - image VARCHAR(50), - origin VARCHAR(3), - price DECIMAL(10,2), - priceKg DECIMAL(10,2), - PRIMARY KEY `itemFk` (`itemFk`) - ) ENGINE = MEMORY DEFAULT CHARSET=utf8; - - OPEN cTravelTree; - - l: LOOP - SET vDone = FALSE; - FETCH cTravelTree INTO vZoneFk, vWarehouseFk, vShipped; - - IF vDone THEN - LEAVE l; - END IF; - - CALL `cache`.available_refresh (vAvailableCalc, FALSE, vWarehouseFk, vShipped); -SELECT '4', vWarehouseFk, vShipped ; - CALL buyUltimate (vWarehouseFk, vShipped); -SELECT 5; - INSERT INTO tmp.ticketLot (warehouseFk, itemFk, available, buyFk, zoneFk) - SELECT vWarehouseFk, - i.item_id, - IFNULL(i.available, 0), - bu.buyFk, - vZoneFk - FROM `cache`.available i - JOIN tmp.item br ON br.itemFk = i.item_id - LEFT JOIN item it ON it.id = i.item_id - LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = i.item_id - WHERE i.calc_id = vAvailableCalc - AND i.available > 0; - - DROP TEMPORARY TABLE tmp.buyUltimate; - - CALL vn.catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk); -SELECT 6; - INSERT INTO tmp.ticketCalculateItem ( - itemFk, - available, - producer, - item, - size, - stems, - category, - inkFk, - image, - origin, - price, - priceKg) - SELECT - tl.itemFk, - SUM(tl.available) available, - p.name producer, - i.name item, - i.size size, - i.stems, - i.category, - i.inkFk, - i.image, - o.code origin, - bl.price, - bl.priceKg - FROM tmp.ticketLot tl - JOIN item i ON tl.itemFk = i.id - LEFT JOIN producer p ON p.id = i.producerFk AND p.isVisible - JOIN origin o ON o.id = i.originFk - JOIN ( - SELECT * - FROM (SELECT price, itemFk, priceKg - FROM tmp.ticketComponentPrice - WHERE warehouseFk = vWarehouseFk - ORDER BY (rate = 2) DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk - ) bl ON bl.itemFk = tl.itemFk - WHERE tl.zoneFk = vZoneFk AND tl.warehouseFk = vWarehouseFk - GROUP BY tl.itemFk - ON DUPLICATE KEY UPDATE available = available + VALUES(available); - - END LOOP; - - CLOSE cTravelTree; - DROP TEMPORARY TABLE tmp.item; -SELECT 7; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -47651,6 +50251,7 @@ BEGIN DECLARE vDateShort DATETIME; DECLARE vOneYearAgo DATE; DECLARE vFourYearsAgo DATE; + DECLARE vFiveYearsAgo DATE; DECLARE v18Month DATE; DECLARE v26Month DATE; DECLARE v3Month DATE; @@ -47660,6 +50261,7 @@ BEGIN SET vDateShort = util.VN_CURDATE() - INTERVAL 2 MONTH; SET vOneYearAgo = util.VN_CURDATE() - INTERVAL 1 YEAR; SET vFourYearsAgo = util.VN_CURDATE() - INTERVAL 4 YEAR; + SET vFiveYearsAgo = util.VN_CURDATE() - INTERVAL 5 YEAR; SET v18Month = util.VN_CURDATE() - INTERVAL 18 MONTH; SET v26Month = util.VN_CURDATE() - INTERVAL 26 MONTH; SET v3Month = util.VN_CURDATE() - INTERVAL 3 MONTH; @@ -47703,7 +50305,7 @@ BEGIN DELETE FROM vn.stockBuyed WHERE creationDate < vDateShort; DELETE FROM vn.itemCleanLog WHERE created < util.VN_NOW() - INTERVAL 1 YEAR; DELETE FROM printQueue WHERE statusCode = 'printed' AND created < vDateShort; - + DELETE FROM ticketLog WHERE creationDate <= vFiveYearsAgo; -- Equipos duplicados DELETE w.* FROM workerTeam w @@ -47792,7 +50394,7 @@ BEGIN CREATE TEMPORARY TABLE tmp.duaToDelete SELECT * FROM vn.dua - WHERE operated < TIMESTAMPADD(YEAR,-2,util.VN_CURDATE()); + WHERE operated < TIMESTAMPADD(YEAR,-2,CURDATE()); UPDATE tmp.duaToDelete tm JOIN vn.dms d ON d.id = tm.gestdocFk @@ -48053,7 +50655,7 @@ BEGIN DECLARE vClientDebt DOUBLE; - SELECT vn.clientGetDebt(vClientFk, util.VN_CURDATE()) INTO vClientDebt; + SELECT vn.client_getDebt(vClientFk, util.VN_CURDATE()) INTO vClientDebt; INSERT INTO vn.greuge(clientFk, description, amount, shipped, greugeTypeFk) VALUES (vClientFk, 'Saldo pendiente', vClientDebt, util.VN_CURDATE(), 5); @@ -48088,12 +50690,11 @@ DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `clientFreeze`() BEGIN /** -* Congela diariamente aquellos clientes que son morosos sin recobro, -* pero que no sean trabajadores, -* y que el riesgo no sea menor que cero -* hasta que no se gire la remesa no se congelan a los clientes de giro -*/ - + * Congela diariamente aquellos clientes que son morosos sin recobro, + * pero que no sean trabajadores, + * y que el riesgo no sea menor que cero + * hasta que no se gire la remesa no se congelan a los clientes de giro + */ DECLARE vIsRemittanced BOOLEAN; SELECT id into vIsRemittanced @@ -48109,7 +50710,7 @@ BEGIN WHERE created = util.VN_CURDATE() AND amount; - CALL clientGetDebt(util.VN_CURDATE()); + CALL client_getDebt(util.VN_CURDATE()); UPDATE client c JOIN bi.defaulters d ON d.client = c.id AND d.date = util.VN_CURDATE() @@ -48132,32 +50733,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `clientGetDebt` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `clientGetDebt`(vDate DATE) -BEGIN -/** - * Call client_getDebt - * - * @table tmp.clientGetDebt(clientFk) - * @param vDate Fecha maxima de los registros - * @return tmp.risk - */ - CALL vn.client_getDebt(vDate); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `clientGetDebtDiary` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -49024,160 +51599,157 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `collectionPlacement_get`(vParamFk INT(11), vIsPicker bool) +CREATE DEFINER=`root`@`localhost` PROCEDURE `collectionPlacement_get`( + vParamFk INT(11), + vIsPicker bool) BEGIN -/** Devuelve el listado de ubicaciones a las que hay que ir para preparar una colección o ticket +/** + * Devuelve el listado de ubicaciones a las que hay que ir + * para preparar una colección o ticket de manera ordenada * - * @param vParamFk Identificador de vn.collection o Identificador de vn.ticket - * @param vIsPicker Booleano para distinguer el sacador del revisador + * @param vParamFk Identificador de collection o Identificador de ticket + * @param vIsPicker Booleano para distinguer el sacador del revisador */ - DECLARE vCalcFk INT; DECLARE vWarehouseFk INT; DECLARE vCurrentYear INT DEFAULT YEAR(util.VN_NOW()); - DROP TEMPORARY TABLE IF EXISTS tmp.sale; - - CREATE TEMPORARY TABLE tmp.sale - ENGINE = MEMORY - SELECT s.ticketFk, s.id saleFk, s.itemFk, s.quantity - FROM vn.ticketCollection tc - JOIN vn.sale s ON s.ticketFk = tc.ticketFk - WHERE tc.collectionFk = vParamFk - UNION ALL - SELECT s.ticketFk, s.id, s.itemFk, s.quantity - FROM vn.sale s - WHERE s.ticketFk = vParamFk; + DROP TEMPORARY TABLE IF EXISTS tSale; + CREATE TEMPORARY TABLE tSale + (INDEX(ticketFk), INDEX(saleFk), INDEX(itemFk)) + ENGINE = MEMORY + SELECT s.ticketFk, s.id saleFk, s.itemFk, s.quantity + FROM ticketCollection tc + JOIN sale s ON s.ticketFk = tc.ticketFk + WHERE tc.collectionFk = vParamFk + UNION ALL + SELECT s.ticketFk, s.id, s.itemFk, s.quantity + FROM sale s + WHERE s.ticketFk = vParamFk; SELECT t.warehouseFk INTO vWarehouseFk - FROM vn.ticket t - JOIN tmp.sale ts ON ts.ticketFk = t.id - JOIN vn.warehouse w ON w.id = t.warehouseFk + FROM ticket t + JOIN tSale ts ON ts.ticketFk = t.id + JOIN warehouse w ON w.id = t.warehouseFk LIMIT 1; - CALL cache.visible_refresh(vCalcFk,FALSE,vWarehouseFk); + CALL cache.visible_refresh(vCalcFk, FALSE, vWarehouseFk); - DROP TEMPORARY TABLE IF EXISTS tmp.sale2; - CREATE TEMPORARY TABLE tmp.sale2 - ENGINE = MEMORY - SELECT * FROM tmp.sale; - - DROP TEMPORARY TABLE IF EXISTS tmp.`grouping`; - CREATE TEMPORARY TABLE tmp.`grouping` + DROP TEMPORARY TABLE IF EXISTS tGrouping; + CREATE TEMPORARY TABLE tGrouping (INDEX(itemFk)) ENGINE = MEMORY SELECT b.itemFk, - CASE b.groupingMode - WHEN 0 THEN 1 - WHEN 2 THEN b.packing - ELSE b.`grouping` - END AS `grouping` - FROM buy b - JOIN cache.last_buy lb ON lb.buy_id = b.id - WHERE lb.warehouse_id = vWarehouseFk - GROUP BY b.itemFk; + CASE b.groupingMode + WHEN 0 THEN 1 + WHEN 2 THEN b.packing + ELSE b.`grouping` + END `grouping` + FROM buy b + JOIN cache.last_buy lb ON lb.buy_id = b.id + WHERE lb.warehouse_id = vWarehouseFk + GROUP BY b.itemFk; - DROP TEMPORARY TABLE IF EXISTS tmp.grouping2; - CREATE TEMPORARY TABLE tmp.grouping2 - ENGINE MEMORY - SELECT * FROM tmp.`grouping`; - - DROP TEMPORARY TABLE IF EXISTS tmp.salePlacementList; - CREATE TEMPORARY TABLE tmp.salePlacementList - ENGINE MEMORY - - SELECT ts.saleFk, - ts.itemFk, - CAST(0 AS DECIMAL(10,0)) as saleOrder, - IF(ish.visible > 0 OR iss.id, 1, 100000) * p.pickingOrder as `order`, - IF(iss.id, TO_SECONDS(TIMESTAMPADD(YEAR,-vCurrentYear,iss.created)), TO_SECONDS(TIMESTAMPADD(YEAR,- year(ish.created),ish.created)) /* + TO_SECONDS(TIMESTAMPADD(YEAR,-vCurrentYear,util.VN_NOW())) */) as priority, - CONCAT( - IF( iss.id, - CONCAT('< ', IFNULL(wk.`code`, '---'),' > '), - ''), - p.`code`) COLLATE utf8_general_ci as placement, - sh.priority shelvingPriority, - sh.code COLLATE utf8_general_ci as shelving, - ish.created, - ish.visible, - IFNULL(IF(sc.isPreviousPreparedByPacking, ish.packing, g.`grouping`),1) as `grouping`, - sc.isPreviousPrepared, - iss.id as itemShelvingSaleFk, - ts.ticketFk - ,iss.id - , st.saleFk as salePreviousPrepared - , iss.userFk - , ts.quantity - FROM tmp.sale ts - LEFT JOIN (SELECT DISTINCT saleFk - FROM vn.saleTracking st - JOIN vn.state s ON s.id = st.stateFk - WHERE st.isChecked - AND s.semaphore = 1) st ON st.saleFk = ts.saleFk - JOIN vn.itemShelving ish ON ish.itemFk = ts.itemFk - JOIN vn.shelving sh ON sh.code = ish.shelvingFk - JOIN vn.parking p ON p.id = sh.parkingFk - JOIN vn.sector sc ON sc.id = p.sectorFk - JOIN vn.warehouse w ON w.id = sc.warehouseFk - LEFT JOIN tmp.`grouping` g ON g.itemFk = ts.itemFk - LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = ts.saleFk AND iss.itemShelvingFk = ish.id - LEFT JOIN vn.worker wk ON wk.id = iss.userFk - WHERE w.id = vWarehouseFk - AND NOT sc.isHideForPickers + DROP TEMPORARY TABLE IF EXISTS tSalePlacementList; + CREATE TEMPORARY TABLE tSalePlacementList + (INDEX(saleFk), INDEX(`order`)) + ENGINE = MEMORY + SELECT ts.saleFk, + ts.itemFk, + CAST(0 AS DECIMAL(10,0)) saleOrder, + IF(ish.visible > 0 OR iss.id, 1, 100000) * + IFNULL(p2.pickingOrder, p.pickingOrder) `order`, + TO_SECONDS(IF(iss.id, + iss.created - INTERVAL vCurrentYear YEAR, + ish.created - INTERVAL YEAR(ish.created) YEAR)) priority, + CONCAT( + IF(iss.id, + CONCAT('< ', IFNULL(wk.`code`, '---'),' > '), + ''), + p.`code`) COLLATE utf8_general_ci placement, + sh.priority shelvingPriority, + sh.code COLLATE utf8_general_ci shelving, + ish.created, + ish.visible, + IFNULL( + IF(sc.isPreviousPreparedByPacking, ish.packing, g.`grouping`), + 1) `grouping`, + sc.isPreviousPrepared, + iss.id itemShelvingSaleFk, + ts.ticketFk, + iss.id, + st.saleFk salePreviousPrepared, + iss.userFk, + ts.quantity + FROM tSale ts + LEFT JOIN (SELECT DISTINCT saleFk + FROM saleTracking st + JOIN state s ON s.id = st.stateFk + WHERE st.isChecked + AND s.semaphore = 1) st ON st.saleFk = ts.saleFk + JOIN itemShelving ish ON ish.itemFk = ts.itemFk + JOIN shelving sh ON sh.code = 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 + LEFT JOIN tGrouping g ON g.itemFk = ts.itemFk + LEFT JOIN itemShelvingSale iss ON iss.saleFk = ts.saleFk + AND iss.itemShelvingFk = ish.id + LEFT JOIN worker wk ON wk.id = iss.userFk + LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = ts.saleFk + LEFT JOIN saleGroup sg ON sg.id = sgd.saleGroupFk + LEFT JOIN parking p2 ON p2.id = sg.parkingFk + WHERE w.id = vWarehouseFk + AND NOT sc.isHideForPickers HAVING (iss.id AND st.saleFk) OR salePreviousPrepared IS NULL; - DROP TEMPORARY TABLE IF EXISTS tmp.salePlacementList_2; - CREATE TEMPORARY TABLE tmp.salePlacementList_2 - ENGINE MEMORY - SELECT saleFk, priority as olderPriority - FROM (SELECT saleFk, priority - FROM tmp.salePlacementList - ORDER BY isPreviousPrepared DESC, - itemShelvingSaleFk IS NULL DESC, - visible >= quantity DESC, - visible > 0 DESC, - IFNULL(shelvingPriority,0) DESC, - priority - LIMIT 10000000000000000000 - ) sub - GROUP BY saleFk; + DROP TEMPORARY TABLE IF EXISTS tSalePlacementList2; + CREATE TEMPORARY TABLE tSalePlacementList2 + (INDEX(saleFk), INDEX(olderPriority)) + ENGINE = MEMORY + SELECT saleFk, priority olderPriority + FROM (SELECT saleFk, priority + FROM tSalePlacementList + ORDER BY isPreviousPrepared DESC, + itemShelvingSaleFk IS NULL DESC, + visible >= quantity DESC, + visible > 0 DESC, + IFNULL(shelvingPriority, 0) DESC, + priority + LIMIT 10000000000000000000 + )sub + GROUP BY saleFk; - DROP TEMPORARY TABLE IF EXISTS tmp.salePlacementList_3; - CREATE TEMPORARY TABLE tmp.salePlacementList_3 - ENGINE MEMORY - SELECT s1.saleFk, `order`as saleOrder - FROM tmp.salePlacementList s1 - JOIN tmp.salePlacementList_2 s2 ON s2.saleFk = s1.saleFk AND s2.olderPriority = s1.priority; - - UPDATE tmp.salePlacementList s1 - JOIN tmp.salePlacementList_3 s3 ON s3.saleFk = s1.saleFk - SET s1.saleOrder = s3.saleOrder; + UPDATE tSalePlacementList tsp + JOIN (SELECT s1.saleFk, `order` saleOrder + FROM tSalePlacementList s1 + JOIN tSalePlacementList2 s2 ON s2.saleFk = s1.saleFk + AND s2.olderPriority = s1.priority + ) sub ON sub.saleFk = tsp.saleFk + SET tsp.saleOrder = sub.saleOrder; -- Anula el orden de antigüedad y ordena por ubicación - UPDATE tmp.salePlacementList + UPDATE tSalePlacementList SET saleOrder = `order`; SELECT spl.* - FROM tmp.salePlacementList spl - JOIN vn.sale s ON s.id = spl.saleFk + FROM tSalePlacementList spl + JOIN sale s ON s.id = spl.saleFk ORDER BY saleOrder, - isPreviousPrepared DESC, - itemShelvingSaleFk DESC, - IF(vIsPicker, visible = 0, TRUE), - s.quantity <= spl.visible DESC, - shelvingPriority DESC, -- PAK 05/11/2021 - priority; + isPreviousPrepared DESC, + itemShelvingSaleFk DESC, + IF(vIsPicker, visible = 0, TRUE), + s.quantity <= spl.visible DESC, + shelvingPriority DESC, + priority; DROP TEMPORARY TABLE - tmp.sale, - tmp.sale2, - tmp.`grouping`, - tmp.salePlacementList, - tmp.grouping2, - tmp.salePlacementList_2, - tmp.salePlacementList_3; + tSale, + tGrouping, + tSalePlacementList, + tSalePlacementList2; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -49194,32 +51766,60 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_addItem`(vItemFk INT, vQuantity INT, vTicketFk INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_addItem`( + vBarccodeFk INT, + vQuantity INT, + vTicketFk INT +) BEGIN +/** + * Add a sales line to the ticket with the indicated amount. + * + * @param vBarcodeFk barcode on the item label + * @param vQuantity quantity to be added to the ticket + * @param vTicketFk ticket to which the sales line is added + */ DECLARE vConcept VARCHAR(50); - DECLARE itemFk INT; - DECLARE vSaleFk INT default 0; - + DECLARE vItemFk INT; + DECLARE vSaleFk INT; DECLARE vDescription VARCHAR(50); - DECLARE vItemName VARCHAR(50); + DECLARE vItemName VARCHAR(50); - SELECT barcodeToItem(vItemFk) INTO itemFk; + SELECT barcodeToItem(vBarccodeFk) INTO vItemFk; - SELECT CONCAT(vn.getUser()," ",DATE_FORMAT(util.VN_NOW( ), "%H:%i" )," ",i.name) INTO vConcept FROM vn.item i WHERE i.id = itemFk; + SELECT CONCAT(getUser(), + ' ', + DATE_FORMAT(util.VN_NOW(), '%H:%i' ), + ' ', + i.name + ) INTO vConcept + FROM item i + WHERE i.id = vItemFk; - SELECT name INTO vItemName FROM vn.item WHERE id = vItemFk; - SELECT CONCAT("Añadido articulo ", vItemName, " cantidad:", vQuantity) INTO vDescription; + SELECT name INTO vItemName FROM item WHERE id = vBarccodeFk; - INSERT INTO vn.ticketLog (originFk, userFk, action , description) - VALUES(vTicketFk, vn.getUser(), 'update', vDescription); + SELECT CONCAT('Añadido articulo ', + vItemName, + ' cantidad:', + vQuantity + ) INTO vDescription; - INSERT INTO vn.sale (itemFk,ticketFk,concept,quantity,isAdded) - VALUES (itemFk,vTicketFk,vConcept,vQuantity,1); + INSERT INTO ticketLog + SET originFk = vTicketFk, + userFk = getUser(), + `action` = 'update', + `description` = vDescription; - SELECT last_insert_id() INTO vSaleFk; + INSERT INTO sale + SET itemFk = vItemFk, + ticketFk = vTicketFk, + concept = vConcept, + quantity = vQuantity, + isAdded = TRUE; - CALL vn.sale_calculateComponent(vSaleFk, null); + SELECT LAST_INSERT_ID() INTO vSaleFk; + CALL sale_calculateComponent(vSaleFk, NULL); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -49323,18 +51923,18 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_get`(vWorkerFk INT) BEGIN - - /* Obtiene colección del sacador si tiene líneas pendientes - * - * @param vWorkerFk id del worker - * - * @table Devuelve tabla temporal con las colecciones pendientes. - */ +/** + * Obtiene colección del sacador si tiene líneas pendientes. + * + * @param vWorkerFk id del worker. + * @table Devuelve tabla temporal con las colecciones pendientes + */ DROP TEMPORARY TABLE IF EXISTS tCollection; CREATE TEMPORARY TABLE tCollection SELECT c.id collectionFk, - date(c.created) created + date(c.created) created, + COUNT(DISTINCT tc.ticketFk) ticketTotalCount FROM collection c JOIN ticketCollection tc ON tc.collectionFk = c.id JOIN sale s ON s.ticketFk = tc.ticketFk @@ -49444,20 +52044,17 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_kill`(vSelf INT) BEGIN - - /* Elimina una coleccion y coloca sus tickets en OK - * - */ - +/** + * Elimina una coleccion y coloca sus tickets en OK + */ INSERT INTO ticketTracking(stateFk, ticketFk) SELECT s.id, ticketFk - FROM vn.ticketCollection tc - JOIN vn.state s ON s.code = 'OK' - WHERE tc.collectionFk = vSelf; + FROM vn.ticketCollection tc + JOIN vn.state s ON s.code = 'OK' + WHERE tc.collectionFk = vSelf; DELETE FROM vn.collection WHERE id = vSelf; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -49857,673 +52454,6 @@ proc:BEGIN DROP TEMPORARY TABLE tTrain, tmp.productionBuffer; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `collection_newSmartTag` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_newSmartTag`(vSectorFk INT) -proc:BEGIN - DECLARE vWorkerFk INT; - DECLARE vWagons INT; - DECLARE vCollectionFk INT; - - SELECT w.id INTO vWorkerFk - FROM vn.worker w - WHERE w.id = vn.getUser(); - - SELECT COUNT(ws.id) INTO vWagons - FROM workerShelving ws - WHERE ws.workerFk = vWorkerFk - AND ws.collectionFk IS NULL; - - CALL collection_newWithWagon(vSectorFk, vWagons); - - SELECT id INTO vCollectionFk - FROM collection - WHERE workerFk = vWorkerFk - ORDER BY created DESC - LIMIT 1; - - UPDATE workerShelving ws - SET ws.collectionFk = vCollectionFk - WHERE ws.workerFk = vWorkerFk - AND ws.collectionFk IS NULL; - - SET @wagon := 0; - - DROP TEMPORARY TABLE IF EXISTS tmp.smartTags; - CREATE TEMPORARY TABLE tmp.smartTags - SELECT s.code, sub.wagon, s.level - FROM ( - SELECT @wagon:=@wagon+1 as wagon, ws.shelvingFk - FROM workerShelving ws - WHERE ws.collectionFk = vCollectionFk) sub - JOIN smartTag s ON s.shelvingFk = sub.shelvingFk - ORDER BY wagon ASC, level ASC; - - UPDATE vn.ticketCollection tc - JOIN tmp.smartTags ts ON tc.wagon = ts.wagon AND tc.level = ts.level - SET tc.smartTagFk = ts.code - WHERE tc.collectionFk = vCollectionFk; - - DROP TEMPORARY TABLE tmp.smartTags; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `collection_newWithWagon` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_newWithWagon`(vSectorFk INT, vWagons INT) -proc:BEGIN - - DECLARE vIsPreviousPrepared BOOLEAN; - DECLARE vCollectionFk INT; - DECLARE vWarehouseFk INT; - DECLARE vMaxTickets INT; - DECLARE vStateFk INT; - DECLARE vFirstTicketFk INT; - DECLARE vHour INT; - DECLARE vMinute INT; - DECLARE vWorkerCode VARCHAR(3); - DECLARE vWagon INT; - DECLARE vWagonCounter INT; - DECLARE vShelve INT; - DECLARE vTicket INT; - DECLARE vTicketToSplit INT; - DECLARE vPrintedTickets INT; - DECLARE vMaxTicketPrinted INT; - DECLARE vItemPackingTypeFk VARCHAR(1); - DECLARE hasAssignedTickets BOOLEAN; - DECLARE vMaxNotReadyCollections INT; - DECLARE vNotReadyCollections INT; - DECLARE vTrainFk INT DEFAULT 1; - DECLARE vUserFk INT; - DECLARE vHourMatters BOOL DEFAULT TRUE; - - SELECT pc.ticketPrintedMax * vWagons, pc.ticketTrolleyMax * vWagons, pc.maxNotReadyCollections - INTO vMaxTicketPrinted, vMaxTickets, vMaxNotReadyCollections - FROM vn.productionConfig pc; - /*IF NOT vn.deviceProductionUser_Exists(vUserFk) THEN - - LEAVE proc; - - END IF;*/ - - SELECT w.code, w.id INTO vWorkerCode, vUserFk - FROM vn.worker w - WHERE w.id =account.myUser_getId(); - - -- Establecemos el almacén y si es un sector de preparación previa, así como el estado para los tickets que se vayan preparando - SELECT isPreviousPrepared, warehouseFk, itemPackingTypeFk - INTO vIsPreviousPrepared, vWarehouseFk, vItemPackingTypeFk - FROM vn.sector - WHERE id = vSectorFk; -- Hola - --- Si está habilitado el modo cazador para las motos, y el usuario no esta registrado, se sale. - - IF (SELECT isTractorHuntingMode FROM vn.deviceProductionConfig dpc) AND vItemPackingTypeFk = 'H' THEN - IF (SELECT COUNT(*) FROM vn.workerWithoutTractor wwt WHERE wwt.workerFk = vUserFk) THEN - CALL util.throw('Usuario no registrado con moto'); - LEAVE proc; - END IF; - END IF; - - --- Si hay colecciones sin terminar, sale del proceso - SELECT count(*) INTO vNotReadyCollections - FROM ( - SELECT count(DISTINCT s.id) totalRow, count(DISTINCT st.id) pickedRow - FROM vn.collection c - JOIN vn.ticketCollection tc ON tc.collectionFk = c.id - JOIN vn.sale s ON s.ticketFk = tc.ticketFk - JOIN vn.state ss ON ss.code = 'PREPARED' - LEFT JOIN vn.saleTracking st ON st.saleFk = s.id AND st.stateFk = ss.id - WHERE c.workerFk = vUserFk - AND c.created >= TIMESTAMPADD(HOUR , -6,util.VN_NOW()) - AND s.quantity != 0 - GROUP BY c.id - HAVING totalRow > pickedRow) sub; - - IF vMaxNotReadyCollections < vNotReadyCollections THEN - - CALL util.throw('Hay colecciones pendientes'); - LEAVE proc; - - END IF; - - IF vIsPreviousPrepared THEN - - CALL util.throw('Es de preparación previa'); - LEAVE proc; -- Hasta que tengamos el altillo, vamos a cancelar esta opcion - - SELECT id INTO vStateFk - FROM vn.state - WHERE `code` = 'PREVIOUS_PREPARATION'; - ELSE - - SELECT id INTO vStateFk - FROM vn.state - WHERE `code` = 'ON_PREPARATION'; - - END IF; - - CALL vn.productionControl(vWarehouseFk, 0); - - -- Esto hay que corregirlo añadiendo un nuevo parámetro al proc. PAK 23/12/21 - IF vSectorFk = 65 THEN -- Pedidos pequeños - - SET vTrainFk = 2; - - SET vHourMatters = FALSE; - - DELETE pb.* - FROM tmp.productionBuffer pb - JOIN vn.volumeConfig vc - WHERE pb.m3 * 1000 > vc.minTicketVolume; - - END IF; - - -- Se obtiene nº de colección y el buffer con los pedidos preparables - INSERT INTO vn.collection - SET workerFk = vUserFk, - itemPackingTypeFk = vItemPackingTypeFk, - trainFk = vTrainFk; - - SELECT LAST_INSERT_ID() INTO vCollectionFk; - - -- 05/08/2021 PAK Jose Frau pide que los tickets de recogida en Algemesí sólo se saquen si están asignados. - DELETE pb.* - FROM tmp.productionBuffer pb - JOIN vn.state s ON s.id = pb.state - WHERE pb.agency = 'REC_ALGEMESI' - AND s.code != 'PICKER_DESIGNED'; - - -- 2/3/2022 PAK Se acuerda con Pepe que los pedidos con riesgo no se sacan aunque se asignen. - DELETE pb.* - FROM tmp.productionBuffer pb - WHERE 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 hasAssignedTickets - FROM tmp.productionBuffer pb - JOIN vn.state s ON s.id = pb.state - WHERE s.code = 'PICKER_DESIGNED' - AND pb.workerCode = vWorkerCode; - - IF hasAssignedTickets THEN - - UPDATE vn.collection - SET itemPackingTypeFk = NULL - WHERE id = vCollectionFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketToSplit; - CREATE TEMPORARY TABLE tmp.ticketToSplit - SELECT pb.ticketFk - FROM tmp.productionBuffer pb - JOIN vn.state s ON s.id = pb.state - WHERE s.code = 'PICKER_DESIGNED' - AND pb.workerCode = vWorkerCode - ORDER BY HH, - mm, - s.`order` DESC, - pb.m3 DESC; - - WHILE (SELECT COUNT(*) FROM tmp.ticketToSplit) DO - - SELECT MIN(ticketFk) INTO vTicketToSplit - FROM tmp.ticketToSplit; - - CALL vn.ticket_splitItemPackingType(vTicketToSplit,IFNULL(vItemPackingTypeFk, 'H')); - - INSERT INTO vn.ticketCollection(ticketFk, collectionFk) - SELECT ticketFk, vCollectionFk - FROM tmp.ticketIPT - WHERE (itemPackingTypeFk = vItemPackingTypeFk) ; - - DELETE FROM tmp.ticketToSplit - WHERE ticketFk = vTicketToSplit; - - DROP TEMPORARY TABLE tmp.ticketIPT; - - END WHILE; - - CALL vn.productionControl(vWarehouseFk, 0); - - ELSE - - SELECT COUNT(*) INTO vPrintedTickets - FROM tmp.productionBuffer pb - JOIN vn.state s ON s.id = pb.state - JOIN vn.agencyMode am ON am.id = pb.agencyModeFk - JOIN vn.agency a ON a.id = am.agencyFk - JOIN vn.productionConfig pc - WHERE pb.shipped = util.VN_CURDATE() - AND (pb.ubicacion IS NOT NULL - OR a.isOwn = FALSE ) - AND s.isPreparable - AND ( - (pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH)) - OR (pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV)) - OR (pb.H = 0 AND pb.V = 0 AND pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV)) - ) - AND (pc.isPreviousPreparationRequired = FALSE - OR pb.previousWithoutParking = FALSE); - - SET vMaxTicketPrinted = vMaxTicketPrinted - vPrintedTickets; - - -- AutoPRINT - - INSERT INTO ticketTracking(stateFk, ticketFk, workerFk) - SELECT s2.id, pb.ticketFk, vUserFk - FROM tmp.productionBuffer pb - JOIN vn.agencyMode am ON am.id = pb.agencyModeFk - JOIN vn.agency a ON a.id = am.agencyFk - JOIN vn.state s ON s.id = pb.state - JOIN vn.state s2 ON s2.code = 'PRINTED_AUTO' - JOIN vn.ticket t ON t.id = pb.ticketFk - JOIN vn.ticketConfig tc - JOIN vn.productionConfig pc - WHERE pb.shipped = util.VN_CURDATE() - AND (LENGTH(pb.problem) = 0 - OR (pb.problem = 'PEQUEÑO' AND vTrainFk = 2)) - AND (pb.ubicacion IS NOT NULL - OR a.isOwn = FALSE ) - AND s.isPrintable - AND s.isOK - AND ( - (pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH)) - OR (pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV)) - OR (pb.H = 0 AND pb.V = 0 AND pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV)) - ) - AND t.created < TIMESTAMPADD(MINUTE, - tc.pickingDelay , util.VN_NOW()) - AND (pc.isPreviousPreparationRequired = FALSE - OR pb.previousWithoutParking = FALSE) - ORDER BY HH, - mm, - s.`order` DESC, - pb.m3 DESC - LIMIT vMaxTicketPrinted; - - -- Se seleccionan los primeros tickets, asignando colección para dejarlos bloqueados a otros sacadores. - -- Se splitan los tickets preparables, para que solo tengan un tipo de empaquetado - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketToSplit; - CREATE TEMPORARY TABLE tmp.ticketToSplit - SELECT pb.ticketFk, (pb.H + pb.V = 0) isNeutral - FROM tmp.productionBuffer pb - JOIN vn.agencyMode am ON am.id = pb.agencyModeFk - JOIN vn.agency a ON a.id = am.agencyFk - JOIN vn.ticketStateToday tst ON tst.ticket = pb.ticketFk - JOIN vn.state s ON s.id = tst.state - JOIN vn.productionConfig pc - WHERE ( - (pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH)) - OR (pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV)) - OR (pb.H = 0 AND pb.V = 0 AND pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV)) - ) - AND (pb.ubicacion IS NOT NULL - OR a.isOwn = FALSE ) - AND LENGTH(pb.problem) = 0 - AND s.isPreparable - AND (pc.isPreviousPreparationRequired = FALSE - OR pb.previousWithoutParking = FALSE) - ORDER BY pb.HH, pb.mm, s.`order` DESC - LIMIT vMaxTickets; - - WHILE (SELECT COUNT(*) FROM tmp.ticketToSplit) DO - - SELECT MIN(ticketFk) INTO vTicketToSplit - FROM tmp.ticketToSplit; - - - IF (SELECT isNeutral - FROM tmp.ticketToSplit - WHERE ticketFk = vTicketToSplit) THEN - - INSERT INTO vn.ticketCollection(ticketFk, collectionFk) - VALUES(vTicketToSplit, vCollectionFk); - - ELSE - - CALL vn.ticket_splitItemPackingType(vTicketToSplit, vItemPackingTypeFk); - - INSERT INTO vn.ticketCollection(ticketFk, collectionFk) - SELECT ticketFk, vCollectionFk - FROM tmp.ticketIPT - WHERE itemPackingTypeFk = vItemPackingTypeFk; - - DROP TEMPORARY TABLE tmp.ticketIPT; - - END IF; - - DELETE FROM tmp.ticketToSplit - WHERE ticketFk = vTicketToSplit; - - END WHILE; - - END IF; - - -- Creamos una tabla temporal con los datos que necesitamos para depurar la colección - DROP TEMPORARY TABLE IF EXISTS tmp.ticket; - CREATE TEMPORARY TABLE tmp.ticket - SELECT pb.ticketFk, - pb.`lines`, - pb.m3 * 1000 liters, - 0 as height, - 0 as shelve, - 0 as wagon, - 0 AS shelveLiters, - pb.productionOrder, - pb.HH, - pb.mm - FROM tmp.productionBuffer pb - JOIN vn.ticketCollection tc ON tc.ticketFk = pb.ticketFk - WHERE tc.collectionFk = vCollectionFk - LIMIT vMaxTickets; - - -- Voumen de las lineas de los pedidos, de acuerdo con el packingShelve establecido por los controladores - DROP TEMPORARY TABLE IF EXISTS tmp.ticketShelveLiters; - CREATE TEMPORARY TABLE tmp.ticketShelveLiters - SELECT t.ticketFk, SUM(s.quantity * vc.shelveVolume / i.packingShelve) shelveLiters - FROM tmp.ticket t - JOIN vn.sale s ON s.ticketFk = t.ticketFk - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.volumeConfig vc - WHERE i.packingShelve - GROUP BY t.ticketFk; - - UPDATE tmp.ticket t - JOIN tmp.ticketShelveLiters tsl ON tsl.ticketFk = t.ticketFk - SET t.shelveLiters = tsl.shelveLiters; - - -- Es importante que el primer ticket se coja en todos los casos - - SET vFirstTicketFk = 0; - - SELECT ticketFk, HH, mm - INTO vFirstTicketFk, vHour, vMinute - FROM tmp.ticket - ORDER BY productionOrder DESC, HH, mm - LIMIT 1; - - -- Hay que excluir aquellos que no tengan la misma hora de preparación - IF vHourMatters THEN - - DELETE - FROM tmp.ticket - WHERE HH != vHour - OR mm != vMinute; - - END IF; - - -- En el caso de pedidos de más volumen de un carro, la colección será monoticket. Pero si el primer pedido - -- no es monoticket, excluimos a los de más de un carro - IF (SELECT (t.shelveLiters > vc.trolleyM3 * 1000) - FROM tmp.ticket t - JOIN vn.volumeConfig vc - WHERE t.ticketFk = vFirstTicketFk) THEN - - DELETE - FROM tmp.ticket - WHERE ticketFk != vFirstTicketFk; - - ELSE - - DELETE t.* - FROM tmp.ticket t - JOIN vn.volumeConfig vc - WHERE t.shelveLiters > vc.trolleyM3 * 1000; - - END IF; - - -- Elimina los tickets bloqueados que no se van a preparar - DELETE tc.* - FROM vn.ticketCollection tc - LEFT JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk - WHERE tc.collectionFk = vCollectionFk - AND t.ticketFk IS NULL; - - -- Construccion del tren - - -- Establece altura máxima por pedido, porque las plantas no se pueden recostar. - UPDATE tmp.ticket t - JOIN - ( SELECT MAX(i.size) maxHeigth, - tc.ticketFk - FROM vn.ticketCollection tc - JOIN vn.sale s ON s.ticketFk = tc.ticketFk - JOIN vn.item i ON i.id = s.itemFk - WHERE i.itemPackingTypeFk = 'V' - AND tc.collectionFk = vCollectionFk - GROUP BY tc.ticketFk) sub ON sub.ticketFk = t.ticketFk - SET t.height = IFNULL(sub.maxHeigth,0); - - -- Vamos a generar una tabla con todas las posibilidades de asignacion de pedido - DROP TEMPORARY TABLE IF EXISTS tmp.wagonsVolumetry; - CREATE TEMPORARY TABLE tmp.wagonsVolumetry - SELECT cv.`level` as shelve, - 1 as wagon, - cv.`lines`, - cv.liters, - cv.height - FROM vn.collectionVolumetry cv - WHERE cv.itemPackingTypeFk = IFNULL(vItemPackingTypeFk, 'H') - AND cv.trainFk = vTrainFk; - - SET vWagonCounter = 1; - - WHILE vWagonCounter < vWagons DO - - SET vWagonCounter = vWagonCounter + 1; - - INSERT INTO tmp.wagonsVolumetry(shelve, wagon, `lines`, liters, height) - SELECT cv.`level` as shelve, - vWagonCounter as wagon, - cv.`lines`, - cv.liters, - cv.height - FROM vn.collectionVolumetry cv - WHERE cv.itemPackingTypeFk = IFNULL(vItemPackingTypeFk, 'H') - AND cv.trainFk = vTrainFk; - - END WHILE; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketShelve; - CREATE TEMPORARY TABLE tmp.ticketShelve - SELECT ticketFk, shelve, wagon, linesDif, LitersDif, heightDif - FROM ( - SELECT t.ticketFk, - wv.shelve, - wv.wagon, - t.productionOrder, - CAST(wv.`lines` AS SIGNED) - t.`lines` as linesDif, - CAST(wv.liters AS SIGNED) - t.shelveLiters as litersDif, - CAST(wv.height AS SIGNED) - t.height as heightDif - FROM tmp.wagonsVolumetry wv - JOIN tmp.ticket t - ) sub - WHERE linesDif >= 0 - AND litersDif >= 0 - AND heightDif >= 0 - ORDER BY productionOrder DESC, linesDif, LitersDif, heightDif ; - - -- Insertamos una opcion virtual para carro completo. Todo ticket tiene que poder entrar en un carro completo.... - INSERT INTO tmp.ticketShelve(ticketFk, shelve, wagon, linesDif, LitersDif, heightDif) - SELECT t.ticketFk, 0, wv.wagon, 999, 999,999 - FROM tmp.ticket t - JOIN tmp.wagonsVolumetry wv - GROUP BY t.ticketFk, wv.wagon; - - SET vWagonCounter = 0; - - WHILE vWagonCounter < vWagons DO - - SET vWagonCounter = vWagonCounter + 1; - - -- Asignamos la primera balda util al primer pedido - IF vWagonCounter = 1 THEN - - SELECT shelve INTO vShelve - FROM tmp.ticketShelve - WHERE ticketFk = vFirstTicketFk - AND wagon = vWagonCounter - ORDER BY heightDif, litersDif, linesDif - LIMIT 1; - - ELSE - - SELECT shelve, ticketFk INTO vShelve, vFirstTicketFk - FROM tmp.ticketShelve - WHERE wagon = vWagonCounter - ORDER BY heightDif, litersDif, linesDif - LIMIT 1; - - END IF; - - IF vShelve > 0 THEN - - UPDATE tmp.ticket - SET shelve = vShelve, - wagon = vWagonCounter - WHERE ticketFk = vFirstTicketFk; - - DELETE FROM tmp.ticketShelve - WHERE ticketFk = vFirstTicketFk - OR (shelve = vShelve AND wagon = vWagonCounter); - - WHILE (SELECT COUNT(*) FROM tmp.ticketShelve WHERE wagon = vWagonCounter) DO - - SELECT ticketFk, shelve - INTO vTicket, vShelve - FROM tmp.ticketShelve - WHERE wagon = vWagonCounter - LIMIT 1; - - UPDATE tmp.ticket - SET shelve = vShelve, - wagon = vWagonCounter - WHERE ticketFk = vTicket; - - DELETE FROM tmp.ticketShelve - WHERE ticketFk = vTicket - OR (shelve = vShelve AND wagon = vWagonCounter); - - END WHILE; - - ELSE - - UPDATE tmp.ticket - SET shelve = 1, wagon = vWagonCounter - WHERE ticketFk = vFirstTicketFk; - - DELETE FROM tmp.ticketShelve - WHERE ticketFk = vFirstTicketFk - AND wagon != vWagonCounter; - - END IF; - - END WHILE; - - -- Eliminamos los que se han quedado sin balda - DELETE FROM tmp.ticket WHERE shelve = 0; - - -- Elimina los tickets bloqueados que no se van a preparar - DELETE tc.* - FROM vn.ticketCollection tc - LEFT JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk - WHERE tc.collectionFk = vCollectionFk - AND t.ticketFk IS NULL; - - -- Elimina los tickets que ya estan en otra coleccion - DELETE tc.* - FROM vn.ticketCollection tc - JOIN vn.ticketCollection tc2 ON tc2.ticketFk = tc.ticketFk - WHERE tc.collectionFk = vCollectionFk - AND tc2.collectionFk != vCollectionFk; - - -- Actualiza el estado de la colección - UPDATE vn.collection c - JOIN vn.state st ON st.code = 'ON_PREPARATION' - SET c.stateFk = st.id - WHERE c.id = vCollectionFk; - - -- Asigna las bandejas - UPDATE vn.ticketCollection tc - JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk - SET tc.level = t.shelve, - tc.wagon = t.wagon, - tc.itemCount = t.`lines`, - tc.liters = t.shelveLiters; - - -- Actualiza el estado de los tickets - INSERT INTO ticketTracking(stateFk, ticketFk, workerFk) - SELECT vStateFk, ticketFk, vUserFk - FROM vn.ticketCollection tc - WHERE tc.collectionFk = vCollectionFk; - - -- Aviso para la preparacion previa - INSERT INTO vn.ticketDown(ticketFk, collectionFk) - SELECT tc.ticketFk, tc.collectionFk - FROM vn.ticketCollection tc - WHERE tc.collectionFk = vCollectionFk; - - IF (SELECT count(*) FROM vn.ticketCollection WHERE collectionFk = vCollectionFk) THEN - - CALL vn.sales_mergeByCollection(vCollectionFk); - - UPDATE vn.collection c - JOIN (SELECT count(*) saleTotalCount , - sum(s.isPicked != 0) salePickedCount - FROM vn.ticketCollection tc - JOIN vn.sale s ON s.ticketFk = tc.ticketFk - WHERE tc.collectionFk = vCollectionFk - AND s.quantity > 0 - ) sub - SET c.saleTotalCount = sub.saleTotalCount, - c.salePickedCount = sub.salePickedCount - WHERE c.id = vCollectionFk; - - SELECT vCollectionFk; - - ELSE - - CALL util.throw('No ha sido posible obtener colección'); - DELETE FROM vn.collection WHERE id = vCollectionFk; - - END IF; - - DROP TEMPORARY TABLE - tmp.ticketToSplit, - tmp.ticketShelveLiters, - tmp.ticket, - tmp.wagonsVolumetry, - tmp.ticketShelve, - tmp.productionBuffer; - - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -50564,12 +52494,12 @@ BEGIN END IF; CALL report_print( - 'LabelCollection', - (SELECT w.labelerFk FROM worker w WHERE w.id = account.myUser_getId()), - account.myUser_getId(), - vPrintArgs, - 'high' - ); + 'LabelCollection', + (SELECT o.labelerFk FROM operator o WHERE o.workerFk = account.myUser_getId()), + account.myUser_getId(), + vPrintArgs, + 'high' + ); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -50598,57 +52528,6 @@ proc: BEGIN SELECT tc.ticketFk, vParkingFk FROM vn.ticketCollection tc WHERE tc.collectionFk = vCollectionFk; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `collection_updateSale` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_updateSale`( - vSaleFk INT, - vOriginalQuantity INT, - vWorkerFk INT, - vStateFk INT, - vTicketFk INT) -BEGIN - - DECLARE vNumPrepared INT; - DECLARE vNumTotal INT; - - REPLACE INTO vn.saleTracking(saleFk, isChecked, originalQuantity, workerFk, stateFk) - VALUES(vSaleFk,1,vOriginalQuantity,vWorkerFk,vStateFk); - - UPDATE vn.sale SET isPicked = 1 - WHERE id = vSaleFk; - - SELECT COUNT(s.id) INTO vNumPrepared - FROM vn.sale s - WHERE s.ticketFk = vTicketFk AND s.isPicked = 1; - - SELECT COUNT(s.id) INTO vNumTotal - FROM vn.sale s - WHERE s.ticketFk = vTicketFk; - - IF vNumPrepared = vNumTotal THEN - - INSERT INTO ticketTracking - SET stateFk = vStateFk, ticketFk = vTicketFk, workerFk = vWorkerFk; - - CALL vn.collection_update(vTicketFk); - - END IF; - - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -50815,7 +52694,7 @@ BEGIN AND r.isBooked AND r.companyFk = vSelf ORDER BY supplierFk, companyFk, companyFk, dueDated, isPayment DESC, id; - -- util.VN_NOW, we calculate the outstanding amount for each receipt in descending order + -- Now, we calculate the outstanding amount for each receipt in descending order SET @risk := 0.0; SET @supplier := 0.0; SET @company := 0.0; @@ -50876,7 +52755,7 @@ BEGIN WHERE vp.isPayment = FALSE; SELECT vp.expirationId, - vp.dated, + vp.dated, vp.supplierFk, vp.companyFk, vp.currencyFk, @@ -50887,11 +52766,12 @@ BEGIN vp.isPayment, vp.isReconciled, vp.endingBalance, - cr.amount clientRiskAmount + cr.amount clientRiskAmount FROM tPendingDuedates vp - LEFT JOIN supplier s ON s.id = vp.supplierFk - LEFT JOIN vn.client c ON c.fi = s.nif - LEFT JOIN vn.clientRisk cr ON cr.clientFk = c.id; + LEFT JOIN supplier s ON s.id = vp.supplierFk + LEFT JOIN client c ON c.fi = s.nif + LEFT JOIN clientRisk cr ON cr.clientFk = c.id + AND cr.companyFk = vp.companyFk; DROP TEMPORARY TABLE tOpeningBalances; DROP TEMPORARY TABLE tPendingDuedates; @@ -52223,7 +54103,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `entryToTicket` */; +/*!50003 DROP PROCEDURE IF EXISTS `entryLog_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -52233,17 +54113,38 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `entryToTicket`(vEntryFk INT, vTicketFk INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `entryLog_add`( + vChangedModel VARCHAR(45), + vOriginFk INT, + vChangedModelId INT, + vActionCode VARCHAR(45), + vChangedModelValue VARCHAR(255), + vOldInstance JSON, + vNewInstance JSON) BEGIN +/** + * Guarda las acciones realizadas por el usuario + * + * @param vChangedModel Nombre que hace referencia a la tabla que se modifica + * @param vOriginFk Id del registro de la tabla origen + * @param vChangedModelId Id del registro de la tabla a la que se realiza la acción + * @param vActionCode Código de la acción {insert | delete | update} + * @param vOldInstance JSON que contiene los valores viejos + * @param vNewInstance JSON que contiene los valores nuevos + */ + CALL util.log_cleanInstances(vActionCode, vOldInstance, vNewInstance); - INSERT INTO vn.sale(ticketFk, itemFk, concept, quantity) - SELECT vTicketFk, b.itemFk, i.longname, b.quantity - FROM vn.buy b - JOIN vn.item i ON i.id = b.itemFk - WHERE b.entryFk = vEntryFk; - - CALL vn.ticket_recalcComponents(vTicketFk); - + IF !(vOldInstance = '{}' AND vNewInstance = '{}') THEN + INSERT INTO entryLog SET + changedModel = vChangedModel, + originFk = vOriginFk, + changedModelId = vChangedModelId, + `action` = vActionCode, + changedModelValue = vChangedModelValue, + oldInstance = vOldInstance, + newInstance = vNewInstance, + userFk = account.myUser_getId(); + END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -52317,6 +54218,39 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `entry_checkPackaging` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_checkPackaging`(vEntryFk INT) +BEGIN +/** + * Comprueba que los campos package y packaging no sean nulos + * + * @param vEntryFk Id de entrada + */ + DECLARE vpackageOrPackingNull INT; + + SELECT count(*) INTO vpackageOrPackingNull + FROM buy b + WHERE b.entryFk = vEntryFk + AND (b.packing IS NULL OR b.packageFk IS NULL); + + IF vpackageOrPackingNull THEN + CALL util.throw("packageOrPackingNull"); + END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `entry_clone` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -52378,27 +54312,26 @@ BEGIN supplierFk, dated, isExcludedFromAvailable, - notes, isRaid, commission, currencyFk, - companyFk + companyFk, + clonedFrom ) SELECT IFNULL(vTravelFk, travelFk), supplierFk, dated, isExcludedFromAvailable, - notes, isRaid, commission, currencyFk, - companyFk + companyFk, + vSelf FROM entry WHERE id = vSelf; SET vNewEntryFk = LAST_INSERT_ID(); - CALL logAdd(vNewEntryFk, 'insert', 'entry', CONCAT('clona entrada ', vSelf)); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -52521,7 +54454,9 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_fixMisfit`(vSelf INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_fixMisfit`( + vSelf INT +) BEGIN /** * Arregla el descuadre de una entrada, agregando registros en vn.buy @@ -52558,7 +54493,7 @@ BEGIN weight) SELECT vSelf, itemFk, - (printedStickers - stickers) * packing quantity, + SUM(printedStickers - stickers) * packing quantity, buyingValue, freightValue, TRUE isIgnored, @@ -52576,9 +54511,11 @@ BEGIN price3, minPrice, weight - FROM vn.buy b + FROM buy b WHERE b.entryFk = vSelf - AND b.printedStickers != b.stickers; + AND b.printedStickers <> b.stickers + GROUP BY itemFk + HAVING quantity; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -53091,8 +55028,8 @@ BEGIN WHERE b.entryFk = vSelf AND i.description = 'MISFIT'; - INSERT INTO vn.entry(supplierFk, dated, notes, travelFk, currencyFk, companyFk) - SELECT supplierFk, dated, CONCAT('E:',vSelf), travelFk, currencyFk, companyFk + INSERT INTO vn.entry(supplierFk, dated, travelFk, currencyFk, companyFk) + SELECT supplierFk, dated, travelFk, currencyFk, companyFk FROM vn.entry e WHERE e.id = vSelf; @@ -53244,7 +55181,6 @@ BEGIN JOIN ticket t on t.id = s.ticketFk WHERE (t.shipped BETWEEN vDatedFrom AND vDatedTo) AND s2.code IN ('OK','PREVIOUS_PREPARATION','PREPARED','CHECKED') - GROUP BY s.ticketFk ) sub1 GROUP BY sub1.workerFk; @@ -53604,11 +55540,11 @@ 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 character_set_client = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionPallet_printLabel`(vSelf INT) BEGIN @@ -53621,9 +55557,9 @@ BEGIN DECLARE vPrinterFk INT; DECLARE vUserFk INT DEFAULT account.myUser_getId(); - SELECT w.labelerFk INTO vPrinterFk - FROM worker w - WHERE w.id = vUserFk; + SELECT o.labelerFk INTO vPrinterFk + FROM operator o + WHERE o.workerFk = vUserFk; CALL vn.report_print( 'LabelPalletExpedition', @@ -53791,11 +55727,11 @@ 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 = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionState_add`(vParam INT, vStateCode VARCHAR(100)) BEGIN @@ -53837,9 +55773,9 @@ DELIMITER ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionState_addByAdress`(vAdressFk INT, vRouteFk INT, vStateCode VARCHAR(100)) BEGIN @@ -53869,11 +55805,11 @@ 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 = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionState_addByExpedition`(vExpeditionFk INT, vStateCode VARCHAR(100)) BEGIN @@ -53944,11 +55880,11 @@ 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 = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionState_addByRoute`(vRouteFk INT, vStateCode VARCHAR(100)) BEGIN @@ -54223,91 +56159,6 @@ BEGIN LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk WHERE e.id = vExpeditionFk; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `faultsReview` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `faultsReview`(vWarehouseFk INT) -BEGIN - - DECLARE vCalcVisibleFk INT; - - CALL cache.visible_refresh(vCalcVisibleFk, TRUE, vWarehouseFk); - - DROP TEMPORARY TABLE IF EXISTS tmp.itemShelvingRadar; - - CREATE TEMPORARY TABLE tmp.itemShelvingRadar - (PRIMARY KEY (itemFk)) - ENGINE = MEMORY - SELECT iss.itemFk, - i.size, - i.subName producer, - SUM(IF(s.sonFk, iss.visible,0)) upstairs, - SUM(IF(s.sonFk, 0, iss.visible)) downstairs, - v.visible - FROM vn.itemShelvingStock iss - JOIN vn.sector s ON s.id = iss.sectorFk - JOIN vn.item i on i.id = iss.itemFk - LEFT JOIN cache.visible v ON v.item_id = iss.itemFk AND v.calc_id = vCalcVisibleFk - WHERE iss.warehouseFk = vWarehouseFk - GROUP BY iss.itemFk; - - SELECT ishr.*, sub.longName, - CAST(visible - upstairs - downstairs AS DECIMAL(10,0)) AS nicho, - CAST(sub.fault AS DECIMAL(10,0)) as faltas - FROM tmp.itemShelvingRadar ishr - JOIN (SELECT s.itemFk, s.quantity as fault, s.concept as longName - FROM vn.sale s - JOIN vn.ticket t ON t.id = s.ticketFk - JOIN vn.client c ON c.id = t.clientFk - WHERE c.typeFk = 'loses' COLLATE utf8_unicode_ci - AND s.isPicked = FALSE - AND date(t.shipped) = util.VN_CURDATE() - AND t.warehouseFk = vWarehouseFk - ) sub ON sub.itemFk = ishr.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 DROP PROCEDURE IF EXISTS `faultsReview_isChecked` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `faultsReview_isChecked`(vItemFk INT, vWarehouseFk INT) -BEGIN - - UPDATE vn.sale s - JOIN vn.ticket t ON t.id = s.ticketFk - JOIN vn.client c ON c.id = t.clientFk - SET s.isPicked = TRUE - WHERE c.typeFk = 'loses' COLLATE utf8_unicode_ci - AND date(t.shipped) = util.VN_CURDATE() - AND t.warehouseFk = vWarehouseFk - AND s.itemFk = vItemFk; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -54647,32 +56498,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `getItemUbication` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `getItemUbication`(vItemFk VARCHAR(22)) -BEGIN - - /* - * @deprecated Utilizar itemShelving_getInfo - * - */ - - CALL itemshelving_getInfo(vItemFk); - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `getPedidosInternos` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54729,6 +56554,91 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `greuge_notifyEvents` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `greuge_notifyEvents`() +BEGIN +/** + * Notify to detect wrong greuges. + */ + DECLARE vTimeStart DATETIME; + DECLARE vTimeEnd DATETIME; + DECLARE vMaxPercentToWrong DECIMAL(10,2); + DECLARE vJSON JSON; + DECLARE vArray JSON; + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vHasData BOOL DEFAULT FALSE; + DECLARE vCounter INT DEFAULT 0; + DECLARE myCur CURSOR FOR + SELECT JSON_OBJECT( + 'ticketId', g.ticketFk, + 'clientId', g.clientFk, + 'description', g.description, + 'amount', g.amount + ) + FROM greuge g + JOIN greugeType gt ON gt.id = g.greugeTypeFk + JOIN ticket t ON t.id = g.ticketFk + WHERE g.created BETWEEN vTimeStart AND util.dayEnd(vTimeEnd) + AND g.amount > (t.totalWithVat * (vMaxPercentToWrong / 100)) + AND gt.code = 'freightDifference' + AND SIGN(t.totalWithVat) + ORDER BY g.clientFk; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + SELECT IFNULL(DATE(lastNotifyCheck), util.VN_CURDATE()) INTO vTimeStart + FROM greugeConfig; + + SET vTimeEnd = util.VN_NOW(); + + SELECT maxPercentToWrong INTO vMaxPercentToWrong + FROM greugeConfig + LIMIT 1; + + IF vMaxPercentToWrong IS NULL THEN + CALL util.throw('Greuge max percent to wrong is not configured'); + END IF; + + SET vArray = JSON_ARRAY(); + + OPEN myCur; + myCur: LOOP + FETCH myCur INTO vJSON; + + IF vDone THEN + LEAVE myCur; + END IF; + + SET vArray = JSON_MERGE(vArray, vJSON); + SET vCounter = vCounter + 1; + SET vHasData = TRUE; + END LOOP; + CLOSE myCur; + + IF vHasData THEN + SELECT util.notification_send( + 'greuge-wrong', + JSON_OBJECT('tickets', JSON_EXTRACT(vArray, '$')), + account.myUser_getId() + ); + END IF; + + UPDATE greugeConfig + SET lastNotifyCheck = vTimeEnd; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `inventoryFailureAdd` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -55272,7 +57182,7 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS `tmp`.`ticketToInvoice`; - CREATE TEMPORARY TABLE `tmp`.`ticketToInvoice` + CREATE TEMPORARY TABLE `tmp.``ticketToInvoice` (PRIMARY KEY (`id`)) ENGINE = MEMORY SELECT Id_Ticket id FROM vn2008.Tickets WHERE (Fecha BETWEEN vMinDateTicket @@ -55671,9 +57581,9 @@ DELIMITER ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInDueDay_calculate`(vInvoiceInFk INT) BEGIN @@ -56497,7 +58407,7 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOut_new`( vSerial VARCHAR(255), - vInvoiceDate DATETIME, + vInvoiceDate DATE, vTaxArea VARCHAR(25), OUT vNewInvoiceId INT) BEGIN @@ -56526,14 +58436,32 @@ BEGIN DECLARE vNewInvoiceInFk INT; DECLARE vIsInterCompany BOOL DEFAULT FALSE; DECLARE vIsCEESerial BOOL DEFAULT FALSE; + DECLARE vIsCorrectInvoiceDate BOOL; + DECLARE vMaxShipped DATE; - SET vInvoiceDate = IFNULL(vInvoiceDate,util.VN_CURDATE()); + SET vInvoiceDate = IFNULL(vInvoiceDate, util.VN_CURDATE()); - SELECT t.clientFk, t.companyFk - INTO vClientFk, vCompanyFk + SELECT t.clientFk, + t.companyFk, + MAX(DATE(t.shipped)), + DATE(vInvoiceDate) >= invoiceOut_getMaxIssued( + vSerial, + t.companyFk, + YEAR(vInvoiceDate)) + INTO vClientFk, + vCompanyFk, + vMaxShipped, + vIsCorrectInvoiceDate FROM tmp.ticketToInvoice tt - JOIN ticket t ON t.id = tt.id - LIMIT 1; + JOIN ticket t ON t.id = tt.id; + + IF(vMaxShipped > vInvoiceDate) THEN + CALL util.throw("Invoice date can't be less than max date"); + END IF; + + IF NOT vIsCorrectInvoiceDate THEN + CALL util.throw('Exists an invoice with a previous date'); + END IF; -- Eliminem de tmp.ticketToInvoice els tickets que no han de ser facturats DELETE ti.* @@ -56544,17 +58472,20 @@ BEGIN JOIN supplier su ON su.id = t.companyFk JOIN client c ON c.id = t.clientFk LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id AND itc.countryFk = su.countryFk - WHERE YEAR(t.shipped) < 2001 + WHERE (YEAR(t.shipped) < 2001 AND t.isDeleted) OR c.isTaxDataChecked = FALSE OR t.isDeleted OR c.hasToInvoice = FALSE OR itc.id IS NULL; - SELECT SUM(s.quantity * s.price * (100 - s.discount)/100), ts.id - INTO vIsAnySaleToInvoice, vIsAnyServiceToInvoice + SELECT SUM(s.quantity * s.price * (100 - s.discount)/100) <> 0 + INTO vIsAnySaleToInvoice FROM tmp.ticketToInvoice t - LEFT JOIN sale s ON s.ticketFk = t.id - LEFT JOIN ticketService ts ON ts.ticketFk = t.id; + JOIN sale s ON s.ticketFk = t.id; + + SELECT COUNT(*) > 0 INTO vIsAnyServiceToInvoice + FROM tmp.ticketToInvoice t + JOIN ticketService ts ON ts.ticketFk = t.id; IF (vIsAnySaleToInvoice OR vIsAnyServiceToInvoice) AND (vCorrectingSerial = vSerial OR NOT hasAnyNegativeBase()) @@ -57062,6 +58993,54 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `itemLog_add` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `itemLog_add`( + vChangedModel VARCHAR(45), + vOriginFk INT, + vChangedModelId INT, + vActionCode VARCHAR(45), + vChangedModelValue VARCHAR(255), + vOldInstance JSON, + vNewInstance JSON) +BEGIN +/** + * Guarda las acciones realizadas por el usuario + * + * @param vChangedModel Nombre que hace referencia a la tabla que se modifica + * @param vOriginFk Id del registro de la tabla origen + * @param vChangedModelId Id del registro de la tabla a la que se realiza la acción + * @param vActionCode Código de la acción {insert | delete | update} + * @param vOldInstance JSON que contiene los valores viejos + * @param vNewInstance JSON que contiene los valores nuevos + */ + CALL util.log_cleanInstances(vActionCode, vOldInstance, vNewInstance); + + IF !(vOldInstance = '{}' AND vNewInstance = '{}') THEN + INSERT INTO itemLog SET + changedModel = vChangedModel, + originFk = vOriginFk, + changedModelId = vChangedModelId, + `action` = vActionCode, + changedModelValue = vChangedModelValue, + oldInstance = vOldInstance, + newInstance = vNewInstance, + userFk = account.myUser_getId(); + END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemPlacementFromTicket` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -58695,11 +60674,6 @@ proc:BEGIN */ DECLARE vCalcVisibleFk INT; - IF vBuyerFk = 103 THEN -- hay que arreglarlo despues de la campaña PAK 23/04/2022 - CALL vn.itemShelvingRadar_Urgent(); - LEAVE proc; - END IF; - CALL cache.visible_refresh(vCalcVisibleFk, TRUE, vWarehouseFk); SELECT * FROM @@ -58710,19 +60684,20 @@ proc:BEGIN sub.upstairs, sub.downstairs, sub.visible, - sub.sectorFk, - CAST(visible - upstairs - downstairs AS DECIMAL(10,0)) nicho + CAST(visible - upstairs - downstairs AS DECIMAL(10,0)) nicho, + sub.name itemColour FROM (SELECT iss.itemFk, - CONCAT(i.longName,' ',i.size,' ',IFNULL(i.subName,'') ) longName, + CONCAT(i.longName, ' ', i.size,' ', IFNULL(i.subName,'') ) longName, '' size, - CONCAT(iss.parkingCode , ' ', iss.shelvingFk) producer, + CONCAT(iss.parkingCode, ' ', iss.shelvingFk) producer, 0 upstairs, SUM(IFNULL(iss.visible,0)) downstairs, - IF(it.isPackaging, null, IFNULL(v.visible,0)) visible, - IFNULL(iss.sectorFk,0) sectorFk + IF(it.isPackaging, null, IFNULL(v.visible, 0)) visible, + ik.name FROM itemShelvingStock iss JOIN sector s ON s.id = iss.sectorFk JOIN item i on i.id = iss.itemFk + LEFT JOIN ink ik ON ik.id = i.inkFk JOIN itemType it ON it.id = i.typeFk LEFT JOIN cache.visible v ON v.item_id = iss.itemFk AND v.calc_id = vCalcVisibleFk WHERE s.warehouseFk = vWarehouseFk @@ -58735,7 +60710,7 @@ proc:BEGIN JOIN client c on c.id = t.clientFk JOIN clientType ct ON ct.id = c.clientTypeFk WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) - AND ISNULL(st.saleFk) + AND st.saleFk IS NULL AND ct.code IN ('normal', 'trust') GROUP BY s.itemFk ) sub2 ON sub2.itemFk = sub.itemFk @@ -58747,25 +60722,26 @@ proc:BEGIN 0, 0, v.visible, - IFNULL(iss.sectorFk,0), - v.visible nicho + v.visible nicho, + ik.name itemColour FROM cache.visible v JOIN item i ON i.id = v.item_id + LEFT JOIN ink ik ON ik.id = i.inkFk JOIN itemType it ON it.id = i.typeFk LEFT JOIN itemShelvingStock iss ON iss.itemFk = v.item_id - LEFT JOIN (SELECT s.itemFk , SUM(s.quantity) pendiente + LEFT JOIN (SELECT s.itemFk, SUM(s.quantity) pendiente FROM sale s LEFT JOIN saleTracking st ON st.saleFk = s.id JOIN ticket t ON t.id = s.ticketFk JOIN client c on c.id = t.clientFk JOIN clientType ct ON ct.id = c.clientTypeFk WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) - AND ISNULL(st.saleFk) + AND st.saleFk IS NULL AND ct.code IN ('normal', 'trust') GROUP BY s.itemFk ) sub5 ON sub5.itemFk = v.item_id WHERE v.calc_id = vCalcVisibleFk - AND ISNULL(iss.itemFk) + AND iss.itemFk IS NULL AND it.workerFk = vBuyerFk ) sub3 WHERE nicho @@ -58799,9 +60775,7 @@ BEGIN CEIL(ish.visible/ish.packing) stickers, ish.packing, ish.grouping, - IF (p.column IS NULL, '', p.column) col, - IF (p.row IS NULL, '', p.row) row, - IF (p.code IS NULL, '', p.code) code, + p.code, ish.id, s.priority, ish.isChecked @@ -58820,11 +60794,11 @@ 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 character_set_client = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_getAlternatives`(vShelvingFk VARCHAR(10)) BEGIN @@ -58839,6 +60813,7 @@ BEGIN JOIN shelving sh ON sh.code = 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 LEFT JOIN worker w ON w.sectorFk = s.id AND w.id = 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 @@ -59048,6 +61023,105 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `itemShelving_selfConsumption` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_selfConsumption`( + vShelvingFk VARCHAR(255) COLLATE utf8_general_ci, + vItemFk INT, + vQuantity INT +) +BEGIN +/** + * Leave the indicated amount on the shelf + * and create a ticket with the difference. + * + * @param vShelvingFk id of the shelf 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 shelf + */ + DECLARE vVisible INT; + DECLARE vClientFk INT; + DECLARE vTicketFk INT; + DECLARE vWarehouseFk INT; + DECLARE vCompanyFk INT; + DECLARE vAgencyModeFk INT; + DECLARE vItemShelvingFk INT; + + SELECT c.id, + c.clientFk, + a.agencyModeFk, + s.warehouseFk + INTO vCompanyFk, + vClientFk, + vAgencyModeFk, + vWarehouseFk + FROM company c + JOIN address a ON a.clientFk = c.clientFk + JOIN warehouse w ON w.addressFk = a.id + JOIN sector s ON s.warehouseFk = w.id + JOIN parking p ON p.sectorFk = s.id + JOIN shelving s2 ON s2.parkingFk = p.id + WHERE s2.code = vShelvingFk; + + IF vClientFk IS NULL THEN + CALL util.throw('The company does not have a customer assigned'); + END IF; + + IF vQuantity IS NULL OR vQuantity < 0 THEN + CALL util.throw('The shelf cannot have NULL or negative quantities'); + END IF; + + IF vShelvingFk IS NULL THEN + CALL util.throw('The shelf is necessary'); + END IF; + + IF vItemFk IS NULL THEN + CALL util.throw('The article is required to create the ticket.'); + END IF; + + SELECT SUM(visible), id INTO vVisible, vItemShelvingFk + FROM itemShelving + WHERE shelvingFk = vShelvingFk + AND itemFk = vItemFk; + + IF vVisible IS NULL THEN + CALL util.throw('The item is not on the shelf.'); + END IF; + + CALL ticket_getWithParameters( + vClientFk, + vWarehouseFk, + CURDATE(), + NULL, + vCompanyFk, + vAgencyModeFk, + vTicketFk + ); + + INSERT INTO sale (itemFk, ticketFk, quantity, concept) + SELECT vItemFk, vTicketFk, (vVisible - vQuantity), longName + FROM item + WHERE id = vItemFk; + + CALL sale_calculateComponent(LAST_INSERT_ID(), NULL); + UPDATE itemShelving + SET visible = IF(id = vItemShelvingFk, vQuantity, 0) + WHERE shelvingFk = vShelvingFk + AND itemFk = vItemFk; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelving_update` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -59438,32 +61512,30 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTrash`( vQuantity INT, vIsTrash BOOLEAN) BEGIN - DECLARE vTicketFk INT; - DECLARE vClientFk INT; - DECLARE vCompanyVnlFk INT DEFAULT 442; + DECLARE vClientFk INT; + DECLARE vCompanyVnlFk INT DEFAULT 442; DECLARE vCalc INT; SELECT barcodeToItem(vItemFk) INTO vItemFk; - SELECT IF(vIsTrash, 200, 400) INTO vClientFk; + SELECT IF(vIsTrash, 200, 400) INTO vClientFk; - SELECT t.id INTO vTicketFk + SELECT t.id INTO vTicketFk FROM ticket t JOIN address a ON a.id=t.addressFk - WHERE t.warehouseFk = vWarehouseFk + WHERE t.warehouseFk = vWarehouseFk AND t.clientFk = vClientFk - AND DATE(t.shipped) = util.VN_CURDATE() - AND a.isDefaultAddress - LIMIT 1; + AND DATE(t.shipped) = util.VN_CURDATE() + AND a.isDefaultAddress + LIMIT 1; - CALL cache.visible_refresh(vCalc, TRUE, vWarehouseFk); + CALL cache.visible_refresh(vCalc, TRUE, vWarehouseFk); - IF vTicketFk IS NULL THEN - - CALL ticket_add( - vClientFk, - util.VN_CURDATE(), + IF vTicketFk IS NULL THEN + CALL ticket_add( + vClientFk, + util.VN_CURDATE(), vWarehouseFk, vCompanyVnlFk, NULL, @@ -59473,21 +61545,20 @@ BEGIN account.myUser_getId(), FALSE, vTicketFk); - END IF; + END IF; - INSERT INTO sale(ticketFk, itemFk, concept, quantity) + INSERT INTO sale(ticketFk, itemFk, concept, quantity) SELECT vTicketFk, vItemFk, CONCAT(longName,' ',getWorkerCode(), ' ', LEFT(CAST(util.VN_NOW() AS TIME),5)), vQuantity FROM item - WHERE id = vItemFk; + WHERE id = vItemFk; UPDATE cache.visible SET visible = visible - vQuantity - WHERE calc_id = vCalc + WHERE calc_id = vCalc AND item_id = vItemFk; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -59548,7 +61619,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `item_clean` */; +/*!50003 DROP PROCEDURE IF EXISTS `item_cleanFloramondo` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -59558,21 +61629,27 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_clean`() +CREATE DEFINER=`root`@`localhost` PROCEDURE `item_cleanFloramondo`() BEGIN /** - * Elimina todos los items repetidos y los - * sustituye por el que tiene menor id - */ +* Elimina todos los items repetidos de floramondo +* y los sustituye por el que tiene menor id +*/ + DECLARE vItemFrom INT; + DECLARE vItemEnd INT; DECLARE vItemOld INT; DECLARE vItemNew INT; + DECLARE vCurrentItem INT; + DECLARE vQuantity INT; DECLARE vCounter INT DEFAULT 0; + DECLARE vIsStop BOOL DEFAULT FALSE; DECLARE vDone BOOL DEFAULT FALSE; DECLARE curItemClean CURSOR FOR - SELECT i.id idOld, - i2.id idNew - FROM vn.item i - JOIN (SELECT i.id, + SELECT GREATEST(i.id, i2.id) idOld, + LEAST(i.id, i2.id) idNew + FROM item i + JOIN ( + SELECT i.id, i.name, i.subname, i.value5, @@ -59584,30 +61661,32 @@ BEGIN i.NumberOfItemsPerCask, i.EmbalageCode, i.quality - FROM vn.item i - LEFT JOIN (SELECT i.id, - sr.NumberOfUnits, - MAX(di.LatestOrderDateTime) lodt - FROM vn.item i - JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk - JOIN edi.deliveryInformation di ON di.supplyResponseID = i.supplyResponseFk - GROUP BY i.id) sub ON sub.id = i.id - WHERE isFloramondo - AND (ISNULL(i.supplyResponseFk) + FROM item i + LEFT JOIN ( + SELECT i.id, + sr.NumberOfUnits, + MAX(di.LatestOrderDateTime) lodt + FROM item i + JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk + JOIN edi.deliveryInformation di ON di.supplyResponseID = i.supplyResponseFk + GROUP BY i.id + )sub ON sub.id = i.id + WHERE i.isFloramondo + AND (i.supplyResponseFk IS NULL OR sub.NumberOfUnits = 0 OR sub.lodt < util.VN_NOW()) GROUP BY i.name, - subname, - value5, - value6, - value7, - value8, - value9, - value10, - NumberOfItemsPerCask, - EmbalageCode, - quality - ORDER BY i.id) i2 ON i2.name <=> i.name + i.subname, + i.value5, + i.value6, + i.value7, + i.value8, + i.value9, + i.value10, + i.NumberOfItemsPerCask, + i.EmbalageCode, + i.quality + ) i2 ON i2.name <=> i.name AND i2.subname <=> i.subname AND i2.value5 <=> i.value5 AND i2.value6 <=> i.value6 @@ -59618,12 +61697,22 @@ BEGIN AND i2.NumberOfItemsPerCask <=> i.NumberOfItemsPerCask AND i2.EmbalageCode <=> i.EmbalageCode AND i2.quality <=> i.quality - WHERE isFloramondo - AND i.id <> i2.id - ORDER BY i.id; + JOIN ( + SELECT DISTINCT b.itemFk + FROM buy b + JOIN item i ON i.id = b.itemFk + WHERE i.isFloramondo + AND NOT b.printedStickers + )sub2 ON sub2.itemFk = GREATEST(i.id, i2.id) + WHERE i.isFloramondo + AND i.id <> i2.id; - DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET vDone = TRUE; - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + DECLARE EXIT HANDLER FOR SQLEXCEPTION SET vDone = TRUE; + BEGIN + SET vDone = TRUE; + ROLLBACK; + RESIGNAL; + END; SET @isModeInventory:= TRUE; @@ -59635,11 +61724,11 @@ BEGIN START TRANSACTION; # Deletes - UPDATE IGNORE vn.itemCost + UPDATE IGNORE itemCost SET itemFk = vItemNew WHERE itemFk = vItemOld; - DELETE FROM vn.itemCost + DELETE FROM itemCost WHERE itemFk = vItemOld; DELETE FROM vn2008.rec_translator @@ -59648,47 +61737,47 @@ BEGIN DELETE FROM bs.waste WHERE itemFk = vItemOld; - DELETE FROM vn.priceFixed + DELETE FROM priceFixed WHERE itemFk = vItemOld; - DELETE FROM vn.itemMatchProperties + DELETE FROM itemMatchProperties WHERE itemFk = vItemOld; - DELETE FROM vn.itemBotanical + DELETE FROM itemBotanical WHERE itemFk = vItemOld; - DELETE FROM vn.itemProposal + DELETE FROM itemProposal WHERE itemFk = vItemOld; SET @isTriggerDisabled := TRUE; - DELETE FROM vn.itemTag + DELETE FROM itemTag WHERE itemFk = vItemOld; SET @isTriggerDisabled := FALSE; - DELETE FROM vn.itemBarcode + DELETE FROM itemBarcode WHERE itemFk = vItemOld; - DELETE FROM vn.itemTaxCountry + DELETE FROM itemTaxCountry WHERE itemFk = vItemOld; # Updates - UPDATE vn.buy + UPDATE buy SET itemFk = vItemNew WHERE itemFk = vItemOld; - UPDATE vn.sale + UPDATE sale SET itemFk = vItemNew WHERE itemFk = vItemOld; - UPDATE vn.specialPrice + UPDATE specialPrice SET itemFk = vItemNew WHERE itemFk = vItemOld; - UPDATE vn.packaging + UPDATE packaging SET itemFk = vItemNew WHERE itemFk = vItemOld; - UPDATE vn.packaging + UPDATE packaging SET freightItemFk = vItemNew WHERE freightItemFk = vItemOld; @@ -59696,48 +61785,41 @@ BEGIN SET itemFk = vItemNew WHERE itemFk = vItemOld; - UPDATE vn.itemLog + UPDATE itemLog SET originFk = vItemNew WHERE originFk = vItemOld; - UPDATE vn.itemShelving + UPDATE itemShelving SET itemFk = vItemNew WHERE itemFk = vItemOld; - UPDATE vn.ticketPackagingStartingStock + UPDATE ticketPackagingStartingStock SET itemFk = vItemNew WHERE itemFk = vItemOld; - UPDATE vn.inventoryFailure + UPDATE inventoryFailure SET itemFk = vItemNew WHERE itemFk = vItemOld; - UPDATE vn.genericAllocation + UPDATE genericAllocation SET itemFk = vItemNew WHERE itemFk = vItemOld; - UPDATE vn.itemPlacementSupply + UPDATE itemPlacementSupply SET itemFk = vItemNew WHERE itemFk = vItemOld; # Eliminamos el item sustituido - DELETE FROM vn.item + DELETE FROM item WHERE id = vItemOld; COMMIT; - IF vDone THEN - LEAVE curItemClean; - END IF; - SET vCounter = vCounter + 1; END LOOP; CLOSE curItemClean; - INSERT INTO itemCleanLog (itemDeleted) - VALUES (vCounter); - SET @isModeInventory:= FALSE; END ;; DELIMITER ; @@ -59861,141 +61943,205 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getBalance`(IN vItemId int, IN vWarehouse int) +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getBalance`(vItemFk int, vWarehouseFk int, vDate DATETIME) BEGIN - DECLARE vDateInventory DATETIME; - DECLARE vCurdate DATE DEFAULT util.VN_CURDATE(); - DECLARE vDayEnd DATETIME DEFAULT util.dayEnd(vCurdate); +/** + * @vItemFk item a buscar + * @vWarehouseFk almacen donde buscar + * @vDate Si la fecha es null, muestra el histórico desde el inventario. Si la fecha no es null, muestra histórico desde la fecha pasada. + */ - SELECT inventoried INTO vDateInventory FROM config; - SET @a = 0; - SET @currentLineFk = 0; - SET @shipped = ''; + DECLARE vDateInventory DATETIME; + DECLARE vInvCalculated INT; - SELECT DATE(@shipped:= shipped) shipped, - alertLevel, - stateName, - origin, - reference, - clientFk, - name, - `in` AS invalue, - `out`, - @a := @a + IFNULL(`in`,0) - IFNULL(`out`,0) as balance, - @currentLineFk := IF (@shipped < util.VN_CURDATE() - OR (@shipped = util.VN_CURDATE() AND (isPicked OR alertLevel >= 2)), - lineFk,@currentLineFk) lastPreparedLineFk, - isTicket, - lineFk, - isPicked, - clientType, - claimFk - FROM - ( SELECT tr.landed AS shipped, - b.quantity AS `in`, - NULL AS `out`, - al.id AS alertLevel, - st.name AS stateName, - s.name AS name, - e.invoiceNumber AS reference, - e.id AS origin, - s.id AS clientFk, - IF(al.id = 3, TRUE, FALSE) isPicked, - FALSE AS isTicket, - b.id lineFk, - NULL `order`, - NULL AS clientType, - NULL AS claimFk - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel tr ON tr.id = e.travelFk - JOIN supplier s ON s.id = e.supplierFk - JOIN alertLevel al ON al.id = - CASE - WHEN tr.landed < util.VN_CURDATE() THEN 3 - WHEN tr.landed = util.VN_CURDATE() AND tr.isReceived = TRUE THEN 3 - ELSE 0 - END - JOIN state st ON st.code = al.code - WHERE tr.landed >= vDateInventory - AND vWarehouse = tr.warehouseInFk - AND b.itemFk = vItemId - AND e.isExcludedFromAvailable = FALSE - AND e.isRaid = FALSE - UNION ALL + IF vDate IS NULL THEN + SELECT inventoried INTO vDateInventory + FROM config; + ELSE + SELECT mockUtcTime INTO vDateInventory + FROM util.config; + END IF; - SELECT tr.shipped, - NULL, - b.quantity, - al.id, - st.name, - s.name, - e.invoiceNumber, - e.id, - s.id, - IF(al.id = 3, TRUE, FALSE), - FALSE, - b.id, - NULL, - NULL, - NULL - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel tr ON tr.id = e.travelFk - JOIN warehouse w ON w.id = tr.warehouseOutFk - JOIN supplier s ON s.id = e.supplierFk - JOIN alertLevel al ON al.id = - CASE - WHEN tr.shipped < util.VN_CURDATE() THEN 3 - WHEN tr.shipped = util.VN_CURDATE() AND tr.isReceived = TRUE THEN 3 - ELSE 0 - END - JOIN state st ON st.code = al.code - WHERE tr.shipped >= vDateInventory - AND vWarehouse =tr.warehouseOutFk - AND s.id <> 4 - AND b.itemFk = vItemId - AND e.isExcludedFromAvailable = FALSE - AND w.isFeedStock = FALSE - AND e.isRaid = FALSE - UNION ALL + CREATE OR REPLACE TEMPORARY TABLE itemDiary( + shipped DATE, + `in` INT(11), + `out` INT(11), + alertLevel INT(11), + stateName VARCHAR(20), + `name` VARCHAR(50), + reference VARCHAR(50), + origin INT(11), + clientFk INT(11), + isPicked INT(11), + isTicket TINYINT(1), + lineFk INT(11), + `order` TINYINT(3) UNSIGNED, + clientType VARCHAR(20), + claimFk INT(10) UNSIGNED + ); - SELECT DATE(t.shipped), - NULL, - s.quantity, - al.id, - st.name, - t.nickname, - t.refFk, - t.id, - t.clientFk, - stk.id, - TRUE, - s.id, - st.`order`, - ct.code, - cb.claimFk - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - LEFT JOIN ticketState ts ON ts.ticket = t.id - LEFT JOIN state st ON st.code = ts.code - JOIN client c ON c.id = t.clientFk - JOIN clientType ct ON ct.id = c.clientTypeFk - JOIN alertLevel al ON al.id = - CASE - WHEN t.shipped < util.VN_CURDATE() THEN 3 - WHEN t.shipped > util.dayEnd(util.VN_CURDATE()) THEN 0 - ELSE IFNULL(ts.alertLevel, 0) - END - LEFT JOIN state stPrep ON stPrep.`code` = 'PREPARED' - LEFT JOIN saleTracking stk ON stk.saleFk = s.id AND stk.stateFk = stPrep.id - LEFT JOIN claimBeginning cb ON s.id = cb.saleFk - WHERE t.shipped >= vDateInventory - AND s.itemFk = vItemId - AND vWarehouse =t.warehouseFk - ORDER BY shipped, alertLevel DESC, isTicket, `order` DESC, isPicked DESC, `in` DESC, `out` DESC - ) AS itemDiary; + INSERT INTO itemDiary + SELECT tr.landed shipped, + b.quantity `in`, + NULL `out`, + al.id alertLevel, + st.name stateName, + s.name `name`, + e.invoiceNumber reference, + e.id origin, + s.id clientFk, + IF(al.code = 'DELIVERED', TRUE, FALSE) isPicked, + FALSE isTicket, + b.id lineFk, + NULL `order`, + NULL clientType, + NULL claimFk + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN supplier s ON s.id = e.supplierFk + JOIN alertLevel al ON al.code = + CASE + WHEN tr.landed < util.VN_CURDATE() THEN 'DELIVERED' + WHEN tr.landed = util.VN_CURDATE() AND tr.isReceived = TRUE THEN 'DELIVERED' + ELSE 'FREE' + END + JOIN state st ON st.code = al.code + WHERE tr.landed >= vDateInventory + AND vWarehouseFk = tr.warehouseInFk + AND b.itemFk = vItemFk + AND e.isExcludedFromAvailable = FALSE + AND e.isRaid = FALSE + UNION ALL + SELECT tr.shipped, + NULL, + b.quantity, + al.id, + st.name, + s.name, + e.invoiceNumber, + e.id, + s.id, + IF(al.code = 'DELIVERED', TRUE, FALSE), + FALSE, + b.id, + NULL, + NULL, + NULL + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN warehouse w ON w.id = tr.warehouseOutFk + JOIN supplier s ON s.id = e.supplierFk + JOIN alertLevel al ON al.code = + CASE + WHEN tr.shipped < util.VN_CURDATE() THEN 'DELIVERED' + WHEN tr.shipped = util.VN_CURDATE() AND tr.isReceived = TRUE THEN 'DELIVERED' + ELSE 'FREE' + END + JOIN state st ON st.code = al.code + JOIN entryConfig ec + WHERE tr.shipped >= vDateInventory + AND vWarehouseFk =tr.warehouseOutFk + AND s.id <> ec.inventorySupplierFk + AND b.itemFk = vItemFk + AND e.isExcludedFromAvailable = FALSE + AND w.isFeedStock = FALSE + AND e.isRaid = FALSE + UNION ALL + SELECT DATE(t.shipped), + NULL, + s.quantity, + al3.id, + st.name, + t.nickname, + t.refFk, + t.id, + t.clientFk, + stk.id, + TRUE, + s.id, + st.`order`, + ct.code, + cb.claimFk + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + LEFT JOIN ticketState ts ON ts.ticket = t.id + LEFT JOIN state st ON st.code = ts.code + JOIN client c ON c.id = t.clientFk + JOIN clientType ct ON ct.id = c.clientTypeFk + JOIN alertLevel al ON al.code = 'DELIVERED' + JOIN alertLevel al2 ON al2.code = 'FREE' + JOIN alertLevel al3 ON al3.id = + CASE + WHEN t.shipped < util.VN_CURDATE() THEN al.code + WHEN t.shipped > util.dayEnd(util.VN_CURDATE()) THEN al2.code + ELSE IFNULL(ts.alertLevel, al2.code) + END + LEFT JOIN state stPrep ON stPrep.`code` = 'PREPARED' + LEFT JOIN saleTracking stk ON stk.saleFk = s.id AND stk.stateFk = stPrep.id + LEFT JOIN claimBeginning cb ON s.id = cb.saleFk + WHERE t.shipped >= vDateInventory + AND s.itemFk = vItemFk + AND vWarehouseFk =t.warehouseFk + ORDER BY shipped, alertLevel DESC, isTicket, `order` DESC, isPicked DESC, `in` DESC, `out` DESC; + IF vDate IS NULL THEN + SET @a = 0; + SET @currentLineFk = 0; + SET @shipped = ''; + + SELECT DATE(@shipped:= shipped) shipped, + alertLevel, + stateName, + origin, + reference, + clientFk, + name, + `in` AS invalue, + `out`, + @a := @a + IFNULL(`in`,0) - IFNULL(`out`,0) as balance, + @currentLineFk := IF (@shipped < util.VN_CURDATE() + OR (@shipped = util.VN_CURDATE() AND (isPicked OR a.code >= 'ON_PREPARATION')), + lineFk, @currentLineFk) lastPreparedLineFk, + isTicket, + lineFk, + isPicked, + clientType, + claimFk + FROM itemDiary + JOIN alertLevel a ON a.id = itemDiary.alertLevel; + ELSE + SELECT sum(`in`) - sum(`out`) INTO vInvCalculated + FROM itemDiary + WHERE shipped < vDate; + + SELECT p1.* + FROM( + SELECT vDate shipped, + 0 alertLevel, + 0 stateName, + 0 origin, + '' reference, + 0 clientFk, + 'Inventario calculado', + vInvCalculated invalue, + NULL `out`, + 0 balance, + 0 lastPreparedLineFk, + 0 isTicket, + 0 lineFk, + 0 isPicked, + 0 clientType, + 0 claimFk + UNION ALL + SELECT shipped, alertlevel, stateName, origin, reference, clientFk, name, `in`, `out`, 0,0, isTicket, lineFk, isPicked, clientType, claimFk + FROM itemDiary + WHERE shipped >= vDate + )as p1; + END IF; + + DROP TEMPORARY TABLE itemDiary; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -60823,11 +62969,11 @@ 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 = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_updatePackingShelve`(vSelf INT, vPacking INT) BEGIN @@ -61495,17 +63641,13 @@ 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; - + 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 */ ; @@ -62519,7 +64661,6 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `prepareTicketList`(vStartingDate DATETIME, vEndingDate DATETIME) BEGIN - DROP TEMPORARY TABLE IF EXISTS tmp.productionTicket; CREATE TEMPORARY TABLE tmp.productionTicket (PRIMARY KEY (ticketFk)) @@ -62659,12 +64800,15 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `productionControl`(vWarehouseFk INT, vScopeDays INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `productionControl`( + vWarehouseFk INT, + vScopeDays INT +) proc: BEGIN /** * Devuelve un listado de tickets con parámetros relativos a la producción de los días en rango. * - * @param vWarehouseFk Identificador de vn.warehouse + * @param vWarehouseFk Identificador de warehouse * @param vScopeDays Número de días desde hoy en adelante que entran en el cálculo. * * @return Table tmp.productionBuffer @@ -62674,89 +64818,102 @@ proc: BEGIN SELECT TIMESTAMPADD(DAY, LEAST(vScopeDays, pc.maxProductionScopeDays), util.dayEnd(util.VN_CURDATE())) INTO vEndingDate - FROM vn.productionConfig pc; + FROM productionConfig pc; SELECT isTodayRelative INTO vIsTodayRelative - FROM vn.worker - WHERE userFk = vn.getUser(); + FROM worker + WHERE userFk = getUser(); - CALL vn.prepareTicketList(TIMESTAMPADD(DAY, -1, util.VN_CURDATE()), vEndingDate); + CALL prepareTicketList( util.VN_CURDATE() - INTERVAL 1 DAY, vEndingDate); CREATE OR REPLACE TEMPORARY TABLE tmp.ticket SELECT * FROM tmp.productionTicket; - CALL vn.prepareClientList(); + CALL prepareClientList(); CREATE OR REPLACE TEMPORARY TABLE tmp.sale_getProblems (INDEX (ticketFk)) ENGINE = MEMORY SELECT tt.ticketFk, tt.clientFk, t.warehouseFk, t.shipped FROM tmp.productionTicket tt - JOIN vn.ticket t ON t.id = tt.ticketFk; + JOIN ticket t ON t.id = tt.ticketFk; - CALL vn.ticket_getProblems(vIsTodayRelative); + CALL ticket_getProblems(vIsTodayRelative); CREATE OR REPLACE TEMPORARY TABLE tmp.productionBuffer - (PRIMARY KEY(ticketFk)) - ENGINE = MEMORY - SELECT tt.ticketFk, - tt.clientFk, - t.warehouseFk, - t.nickname, - t.packages, - IF(HOUR(t.shipped), HOUR(t.shipped),COALESCE(HOUR(zc.hour),HOUR(z.hour))) HH, - COALESCE(HOUR(zc.hour),HOUR(z.hour)) Departure, - COALESCE(MINUTE(t.shipped), MINUTE(zc.hour), MINUTE(z.hour)) mm, - t.routeFk, - IF(am.deliveryMethodFk = 2,z.`id`,0) zona, - t.nickname addressNickname, - a.postalCode, - a.city, - p.name province, - CONCAT(z.`name`,' ',IFNULL(RIGHT(t.routeFk,3),'')) agency, - am.id agencyModeFk, - 0 `lines`, - CAST( 0 AS DECIMAL(5,2)) m3, - CAST( 0 AS DECIMAL(5,2)) preparationRate, - "" problem, - IFNULL(tls.state,2) state, - w.code workerCode, - DATE(t.shipped) shipped, - wk.code salesPersonCode, - p.id provinceFk, - tls.productionOrder, - IFNULL(tls.alertLevel,0) alertLevel, - t.isBoxed palletized, - IF(rm.isPickingAllowed ,rm.bufferFk, NULL) ubicacion, - tlu.lastUpdated, - ifnull(st.graphCategory,0) graphCategory, - pk.code parking, - 0 H, - 0 V, - 0 N, - st.isOk, - ag.isOwn, - rm.bufferFk - FROM tmp.productionTicket tt - JOIN vn.ticket t on tt.ticketFk = t.id - LEFT JOIN vn.ticketStateToday tst ON tst.ticket = t.id - LEFT JOIN vn.state st ON st.id = tst.state - LEFT JOIN vn.client c ON c.id = t.clientFk - LEFT JOIN vn.worker wk ON wk.id = c.salesPersonFk - JOIN vn.address a on a.id = t.addressFk - LEFT JOIN vn.province p on p.id = a.provinceFk - JOIN vn.agencyMode am ON am.id = t.agencyModeFk - JOIN vn.agency ag ON ag.id = am.agencyFk - LEFT JOIN vn.ticketState tls on tls.ticket = tt.ticketFk - LEFT JOIN vn.ticketLastUpdated tlu ON tlu.ticketFk = tt.ticketFk - LEFT JOIN vn.worker w on w.id = tls.worker - LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk - LEFT JOIN vn.`zone` z ON z.id = t.zoneFk - LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk - AND DATE(t.shipped) = zc.dated - LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id - LEFT JOIN vn.parking pk ON pk.id = tp.parkingFk - WHERE t.warehouseFk = vWarehouseFk - AND am.deliveryMethodFk IN (1,2,3); + (PRIMARY KEY(ticketFk), previaParking VARCHAR(255)) + ENGINE = MEMORY + SELECT tt.ticketFk, + tt.clientFk, + t.warehouseFk, + t.nickname, + t.packages, + IF(HOUR(t.shipped), HOUR(t.shipped), COALESCE(HOUR(zc.hour),HOUR(z.hour))) HH, + COALESCE(HOUR(zc.hour), HOUR(z.hour)) Departure, + COALESCE(MINUTE(t.shipped), MINUTE(zc.hour), MINUTE(z.hour)) mm, + t.routeFk, + IF(dm.code = 'DELIVERY', z.`id`, 0) zona, + t.nickname addressNickname, + a.postalCode, + a.city, + p.name province, + CONCAT(z.`name`,' ',IFNULL(RIGHT(t.routeFk,3),'')) agency, + am.id agencyModeFk, + 0 `lines`, + CAST( 0 AS DECIMAL(5,2)) m3, + CAST( 0 AS DECIMAL(5,2)) preparationRate, + "" problem, + IFNULL(tls.state,2) state, + w.code workerCode, + DATE(t.shipped) shipped, + wk.code salesPersonCode, + p.id provinceFk, + tls.productionOrder, + IFNULL(tls.alertLevel, 0) alertLevel, + t.isBoxed palletized, + IF(rm.isPickingAllowed, rm.bufferFk, NULL) ubicacion, + tlu.lastUpdated, + IFNULL(st.graphCategory, 0) graphCategory, + pk.code parking, + 0 H, + 0 V, + 0 N, + st.isOk, + ag.isOwn, + rm.bufferFk + FROM tmp.productionTicket tt + JOIN ticket t ON tt.ticketFk = t.id + LEFT JOIN ticketStateToday tst ON tst.ticket = t.id + LEFT JOIN state st ON st.id = tst.state + LEFT JOIN client c ON c.id = t.clientFk + LEFT JOIN worker wk ON wk.id = c.salesPersonFk + JOIN address a ON a.id = t.addressFk + LEFT JOIN province p ON p.id = a.provinceFk + JOIN agencyMode am ON am.id = t.agencyModeFk + JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk + JOIN agency ag ON ag.id = am.agencyFk + LEFT JOIN ticketState tls ON tls.ticket = tt.ticketFk + LEFT JOIN ticketLastUpdated tlu ON tlu.ticketFk = tt.ticketFk + LEFT JOIN worker w on w.id = tls.worker + LEFT JOIN routesMonitor rm ON rm.routeFk = t.routeFk + LEFT JOIN `zone` z ON z.id = t.zoneFk + LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk + AND DATE(t.shipped) = zc.dated + LEFT JOIN ticketParking tp ON tp.ticketFk = t.id + LEFT JOIN parking pk ON pk.id = tp.parkingFk + WHERE t.warehouseFk = vWarehouseFk + AND dm.code IN ('AGENCY', 'DELIVERY', 'PICKUP'); + + UPDATE tmp.productionBuffer pb + JOIN ( + SELECT pb.ticketFk, GROUP_CONCAT(p.code) previaParking + FROM tmp.productionBuffer pb + JOIN sale s ON s.ticketFk = pb.ticketFk + JOIN saleGroupDetail sgd ON sgd.saleFk = s.id + JOIN saleGroup sg ON sg.id = sgd.saleGroupFk + JOIN parking p ON p.id = sg.parkingFk + GROUP BY pb.ticketFk + ) t ON t.ticketFk = pb.ticketFk + SET pb.previaParking = t.previaParking; -- Problemas por ticket ALTER TABLE tmp.productionBuffer @@ -62767,23 +64924,23 @@ proc: BEGIN UPDATE tmp.productionBuffer pb JOIN tmp.ticket_problems tp ON tp.ticketFk = pb.ticketFk - SET pb.problem = TRIM(CAST(CONCAT( IFNULL(tp.itemShortage,''), - IFNULL(tp.itemDelay,''), - IFNULL(tp.itemLost,''), - IF(tp.isFreezed,' CONGELADO',''), - IF(tp.hasHighRisk,' RIESGO',''), + SET pb.problem = TRIM(CAST(CONCAT( IFNULL(tp.itemShortage, ''), + IFNULL(tp.itemDelay, ''), + IFNULL(tp.itemLost, ''), + IF(tp.isFreezed, ' CONGELADO',''), + IF(tp.hasHighRisk, ' RIESGO',''), IF(tp.hasTicketRequest, ' COD 100',''), IF(tp.isTaxDataChecked, '',' FICHA INCOMPLETA'), - IF(tp.hasComponentLack,' COMPONENTES', ''), - IF(HOUR(util.VN_NOW()) < pb.HH AND tp.isTooLittle,' PEQUEÑO', '') - ) AS char(255))); + IF(tp.hasComponentLack, ' COMPONENTES', ''), + IF(HOUR(util.VN_NOW()) < pb.HH AND tp.isTooLittle, ' PEQUEÑO', '') + ) AS char(255))); -- Clientes Nuevos o Recuperados UPDATE tmp.productionBuffer pb - LEFT JOIN bs.clientNewBorn cnb ON cnb.clientFk = pb.clientFk - JOIN vn.productionConfig pc + LEFT JOIN bs.clientNewBorn cnb ON cnb.clientFk = pb.clientFk + JOIN productionConfig pc SET pb.problem = TRIM(CAST(CONCAT('NUEVO ', pb.problem) AS CHAR(255))) - WHERE (ISNULL(cnb.clientFk) OR cnb.isRookie) + WHERE (cnb.clientFk IS NULL OR cnb.isRookie) AND pc.rookieDays; -- Líneas y volumen por ticket @@ -62792,14 +64949,14 @@ proc: BEGIN SELECT tt.ticketFk, COUNT(*) `lines`, SUM(sv.volume) m3, - IFNULL(SUM(IF(sv.isPicked,sv.volume,0)) / SUM(sv.volume),0) rate + IFNULL(SUM(IF(sv.isPicked, sv.volume, 0)) / SUM(sv.volume), 0) rate FROM tmp.productionTicket tt - JOIN vn.saleVolume sv ON sv.ticketFk = tt.ticketFk + JOIN saleVolume sv ON sv.ticketFk = tt.ticketFk GROUP BY tt.ticketFk ) m on m.ticketFk = pb.ticketFk SET pb.`lines` = m.`lines`, - pb.m3 = m.m3, - pb.preparationRate = m.rate; + pb.m3 = m.m3, + pb.preparationRate = m.rate; DELETE FROM tmp.productionBuffer WHERE `lines`= 0; @@ -62811,13 +64968,13 @@ proc: BEGIN SUM(sub.V) V, SUM(sub.N) N FROM ( - SELECT t.ticketFk, + SELECT t.ticketFk, SUM(i.itemPackingTypeFk = 'H') H, SUM(i.itemPackingTypeFk = 'V') V, - SUM(ISNULL(i.itemPackingTypeFk)) N + SUM(i.itemPackingTypeFk IS NULL) N FROM tmp.productionTicket t - JOIN vn.sale s ON s.ticketFk = t.ticketFk - JOIN vn.item i ON i.id = s.itemFk + JOIN sale s ON s.ticketFk = t.ticketFk + JOIN item i ON i.id = s.itemFk GROUP BY t.ticketFk, i.itemPackingTypeFk) sub GROUP BY ticketFk ) sub2 ON sub2.ticketFk = pb.ticketFk @@ -62827,10 +64984,10 @@ proc: BEGIN -- Colecciones segun tipo de encajado UPDATE tmp.productionBuffer pb - JOIN vn.ticketCollection tc ON pb.ticketFk = tc.ticketFk - SET pb.collectionH = IF(pb.H,tc.collectionFk,NULL), - pb.collectionV = IF(pb.V,tc.collectionFk,NULL), - pb.collectionN = IF(pb.N,tc.collectionFk,NULL); + JOIN ticketCollection tc ON pb.ticketFk = tc.ticketFk + SET pb.collectionH = IF(pb.H, tc.collectionFk, NULL), + pb.collectionV = IF(pb.V, tc.collectionFk, NULL), + pb.collectionN = IF(pb.N, tc.collectionFk, NULL); -- Previa pendiente ALTER TABLE tmp.productionBuffer @@ -62847,30 +65004,30 @@ proc: BEGIN INSERT INTO tmp.ticketWithPrevia(ticketFk, salesCount) SELECT pb.ticketFk, COUNT(DISTINCT s.id) FROM tmp.productionBuffer pb - JOIN vn.sale s ON s.ticketFk = pb.ticketFk - JOIN vn.itemShelvingStock iss ON iss.itemFk = s.itemFk - JOIN vn.sector sc ON sc.id = iss.sectorFk - JOIN vn.item i ON i.id = iss.itemFk + JOIN sale s ON s.ticketFk = pb.ticketFk + JOIN itemShelvingStock iss ON iss.itemFk = s.itemFk + JOIN sector sc ON sc.id = iss.sectorFk + JOIN item i ON i.id = iss.itemFk WHERE iss.isPreviousPrepared - AND (ISNULL(sc.itemPackingTypeFk) - OR (ISNULL(i.itemPackingTypeFk) AND NOT pb.V) - OR sc.itemPackingTypeFk = i.itemPackingTypeFk ) + AND (sc.itemPackingTypeFk IS NULL + OR (i.itemPackingTypeFk IS NULL AND NOT pb.V) + OR sc.itemPackingTypeFk = i.itemPackingTypeFk) GROUP BY pb.ticketFk; -- Se calcula la cantidad de productos que estan ya preparados porque su saleGroup está aparcado UPDATE tmp.ticketWithPrevia twp JOIN ( SELECT pb.ticketFk, COUNT(DISTINCT s.id) salesInParkingCount FROM tmp.productionBuffer pb - JOIN vn.sale s ON s.ticketFk = pb.ticketFk - JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id - JOIN vn.saleGroup sg ON sg.id = sgd.saleGroupFk - WHERE NOT ISNULL(sg.parkingFk) - GROUP BY pb.ticketFk ) sub ON twp.ticketFk = sub.ticketFk + JOIN sale s ON s.ticketFk = pb.ticketFk + JOIN saleGroupDetail sgd ON sgd.saleFk = s.id + JOIN saleGroup sg ON sg.id = sgd.saleGroupFk + WHERE sg.parkingFk IS NOT NULL + GROUP BY pb.ticketFk) sub ON twp.ticketFk = sub.ticketFk SET twp.salesInParkingCount = sub.salesInParkingCount; -- Marcamos como pendientes aquellos que no coinciden las cantidades UPDATE tmp.productionBuffer pb - JOIN tmp.ticketWithPrevia twp ON twp.ticketFk = pb.ticketFk + JOIN tmp.ticketWithPrevia twp ON twp.ticketFk = pb.ticketFk SET pb.previousWithoutParking = TRUE WHERE twp.salesCount > twp.salesInParkingCount; @@ -63317,145 +65474,6 @@ BEGIN ORDER BY (lb.warehouse_id = vWarehouseFk) DESC LIMIT 1; */ -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `refund` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `refund`(IN vOriginTicket INT, OUT vNewTicket INT) -BEGIN - - DECLARE vDone BIT DEFAULT 0; - DECLARE vCustomer MEDIUMINT; - DECLARE vWarehouse TINYINT; - DECLARE vCompany MEDIUMINT; - DECLARE vAddress MEDIUMINT; - DECLARE vRefundAgencyMode INT; - DECLARE vItemFk INT; - DECLARE vQuantity DECIMAL (10,2); - DECLARE vConcept VARCHAR(50); - DECLARE vPrice DECIMAL (10,2); - DECLARE vDiscount TINYINT; - DECLARE vSaleNew INT; - DECLARE vSaleMain INT; - DECLARE vZoneFk INT; - - DECLARE vRsMainTicket CURSOR FOR - SELECT id, itemFk, - quantity, concept, price, discount - FROM vn.sale - WHERE ticketFk = vOriginTicket; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1; - - SELECT id INTO vRefundAgencyMode - FROM agencyMode WHERE `name` = 'ABONO'; - - SELECT clientFk, warehouseFk, companyFk, addressFk - INTO vCustomer, vWarehouse, vCompany, vAddress - FROM ticket - WHERE id = vOriginTicket; - - SELECT id INTO vZoneFk - FROM zone WHERE agencyModeFk = vRefundAgencyMode - LIMIT 1; - - INSERT INTO vn2008.Tickets ( - Id_Cliente, - Fecha, - Id_Consigna, - Id_Agencia, - Alias, - warehouse_id, - empresa_id, - landing, - zoneFk - ) - SELECT - vCustomer, - util.VN_CURDATE(), - vAddress, - vRefundAgencyMode, - a.nickname, - vWarehouse, - vCompany, - util.VN_CURDATE(), - vZoneFk - FROM address a - WHERE a.id = vAddress; - - SET vNewTicket = LAST_INSERT_ID(); - - SET vDone := 0; - OPEN vRsMainTicket ; - FETCH vRsMainTicket INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount; - - WHILE NOT vDone DO - - INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price, discount) - VALUES( vNewTicket, vItemFk, vQuantity, vConcept, vPrice, vDiscount ); - - SET vSaleNew = LAST_INSERT_ID(); - - INSERT INTO vn.saleComponent(saleFk,componentFk,`value`) - SELECT vSaleNew,componentFk,`value` - FROM vn.saleComponent - WHERE saleFk = vSaleMain; - - FETCH vRsMainTicket INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount; - - END WHILE; - CLOSE vRsMainTicket; - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `replaceMovimientosMark` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `replaceMovimientosMark`( - idMovimiento INT, - detalle INT, - originalQuantity INT, - idTrabajador INT, - stateFk INT, - originFk INT, - userFk INT, - actionString VARCHAR(50), - description VARCHAR(100)) -BEGIN - - /* DEPRECATED - * - * usar vn.saleTracking_Replace - * - */ - - REPLACE INTO vn2008.Movimientos_mark(Id_Movimiento, valor, original_quantity, Id_Trabajador, stateFk) - VALUES(idMovimiento,detalle,originalQuantity,idTrabajador,stateFk); - /*INSERT INTO vn.ticketLog (originFk, userFk, action , description) - VALUES(originFk, userFk, actionString, description);*/ - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -63747,6 +65765,54 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `routeLog_add` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `routeLog_add`( + vChangedModel VARCHAR(45), + vOriginFk INT, + vChangedModelId INT, + vActionCode VARCHAR(45), + vChangedModelValue VARCHAR(255), + vOldInstance JSON, + vNewInstance JSON) +BEGIN +/** + * Guarda las acciones realizadas por el usuario + * + * @param vChangedModel Nombre que hace referencia a la tabla que se modifica + * @param vOriginFk Id del registro de la tabla origen + * @param vChangedModelId Id del registro de la tabla a la que se realiza la acción + * @param vActionCode Código de la acción {insert | delete | update} + * @param vOldInstance JSON que contiene los valores viejos + * @param vNewInstance JSON que contiene los valores nuevos + */ + CALL util.log_cleanInstances(vActionCode, vOldInstance, vNewInstance); + + IF !(vOldInstance = '{}' AND vNewInstance = '{}') THEN + INSERT INTO routeLog SET + changedModel = vChangedModel, + originFk = vOriginFk, + changedModelId = vChangedModelId, + `action` = vActionCode, + changedModelValue = vChangedModelValue, + oldInstance = vOldInstance, + newInstance = vNewInstance, + userFk = account.myUser_getId(); + END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `routeMonitor_calculate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -63757,22 +65823,21 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `routeMonitor_calculate`(vDate DATE) +CREATE DEFINER=`root`@`localhost` PROCEDURE `routeMonitor_calculate`( + vDate DATE, + vDaysAgo INT +) BEGIN + DECLARE vDateEnd DATETIME; + SET vDate = vDate - INTERVAL vDaysAgo DAY; + SET vDateEnd = util.dayend(vDate); - DECLARE vDateEND DATETIME; - - SET vDateEND = util.dayend(vDate); - SET vDate = TIMESTAMPADD(DAY,-1,vDate); - - DROP TEMPORARY TABLE IF EXISTS tmp.routesMonitor; - - CREATE TEMPORARY TABLE tmp.routesMonitor + CREATE OR REPLACE TEMPORARY TABLE tmp.routesMonitor (INDEX (routeFk)) ENGINE = MEMORY SELECT DISTINCT(t.routeFk) routeFk FROM vn.ticket t - WHERE t.shipped BETWEEN vDate AND vDateEND + WHERE t.shipped BETWEEN vDate AND vDateEnd AND t.routeFk IS NOT NULL; INSERT IGNORE INTO routesMonitor(routeFk) @@ -63789,64 +65854,79 @@ BEGIN rm.dated = r.created; UPDATE routesMonitor rm - JOIN(SELECT t.routeFk, COUNT(*) AS ticketFree + JOIN ( + SELECT t.routeFk, COUNT(*) AS ticketFree FROM vn.ticket t JOIN tmp.routesMonitor rm ON rm.routeFk = t.routeFk JOIN ticketLastState ts ON t.id = ts.ticketFk JOIN ticketTracking tt ON tt.id = ts.ticketTrackingFk - JOIN state s ON s.id = tt.stateFk AND s.alertLevel = 0 + JOIN state s ON s.id = tt.stateFk + JOIN vn.alertLevel al ON al.id = s.alertLevel + AND al.code = "FREE" GROUP BY t.routeFk - ) sub ON sub.routeFk = rm.routeFk + ) sub ON sub.routeFk = rm.routeFk SET rm.ticketFree = sub.ticketFree; UPDATE routesMonitor rm - JOIN(SELECT t.routeFk, COUNT(*) AS ticketPacked + JOIN( + SELECT t.routeFk, COUNT(*) AS ticketPacked FROM vn.ticket t JOIN tmp.routesMonitor rm ON rm.routeFk = t.routeFk JOIN ticketLastState ts ON t.id = ts.ticketFk JOIN ticketTracking tt ON tt.id = ts.ticketTrackingFk - JOIN state s ON s.id = tt.stateFk AND s.alertLevel = 2 + JOIN state s ON s.id = tt.stateFk + JOIN vn.alertLevel al ON al.id = s.alertLevel + AND al.code = "PACKED" GROUP BY t.routeFk - ) sub ON sub.routeFk = rm.routeFk + ) sub ON sub.routeFk = rm.routeFk SET rm.ticketPacked = sub.ticketPacked; UPDATE routesMonitor rm - JOIN(SELECT t.routeFk, COUNT(*) AS ticketProduction + JOIN( + SELECT t.routeFk, COUNT(*) AS ticketProduction FROM vn.ticket t JOIN tmp.routesMonitor rm ON rm.routeFk = t.routeFk JOIN ticketLastState ts ON t.id = ts.ticketFk JOIN ticketTracking tt ON tt.id = ts.ticketTrackingFk - JOIN state s ON s.id = tt.stateFk AND s.alertLevel = 3 + JOIN state s ON s.id = tt.stateFk + JOIN vn.alertLevel al ON al.id = s.alertLevel + AND al.code = "DELIVERED" GROUP BY t.routeFk - ) sub ON sub.routeFk = rm.routeFk + ) sub ON sub.routeFk = rm.routeFk SET rm.ticketProduction = sub.ticketProduction; UPDATE routesMonitor rm - JOIN( SELECT t.routeFk, COUNT(*) AS packages + JOIN ( + SELECT t.routeFk, COUNT(*) packages FROM vn.ticket t JOIN tmp.routesMonitor rm ON rm.routeFk = t.routeFk JOIN expedition e ON e.ticketFk = t.id GROUP BY t.routeFk - ) sub ON sub.routeFk = rm.routeFk + ) sub ON sub.routeFk = rm.routeFk SET rm.packages = sub.packages; UPDATE routesMonitor rm - JOIN( SELECT t.routeFk, SUM(sv.volume) AS m3 + JOIN( SELECT t.routeFk, SUM(sv.volume) m3 FROM vn.ticket t JOIN tmp.routesMonitor rm ON rm.routeFk = t.routeFk JOIN vn.saleVolume sv ON sv.ticketFk = t.id GROUP BY t.routeFk - ) sub ON sub.routeFk = rm.routeFk + ) sub ON sub.routeFk = rm.routeFk SET rm.m3 = sub.m3; UPDATE routesMonitor rm - JOIN( SELECT t.routeFk , sum(IFNULL(pk.volume, pk.width * pk.height * pk.`depth` )) / 1000000 m3boxes + JOIN ( + SELECT t.routeFk, + SUM(IFNULL(pk.volume, + pk.width * pk.height * pk.`depth` + ) + ) / 1000000 m3boxes FROM vn.ticket t JOIN tmp.routesMonitor rm ON rm.routeFk = t.routeFk JOIN vn.expedition e ON e.ticketFk = t.id JOIN vn.packaging pk ON pk.id = e.packagingFk GROUP BY t.routeFk - ) sub ON sub.routeFk = rm.routeFk + ) sub ON sub.routeFk = rm.routeFk SET rm.m3boxes = sub.m3boxes; UPDATE routesMonitor rm @@ -64077,56 +66157,64 @@ BEGIN * de sus tickets. * * @param vRouteFk - * * @select Información de los tickets */ - - SELECT - t.id Id, - t.clientFk Client, - a.id Address, - a.nickname ClientName, - t.packages Packages, - a.street AddressName, - a.postalCode PostalCode, - a.city City, - sub2.itemPackingTypeFk PackingType, - c.phone ClientPhone, - c.mobile ClientMobile, - a.phone AddressPhone, - a.mobile AddressMobile, - d.longitude Longitude, - d.latitude Latitude, - wm.mediaValue SalePersonPhone, - tob.Note Note, - t.isSigned Signed - FROM ticket t - JOIN client c ON t.clientFk = c.id - JOIN address a ON t.addressFk = a.id - LEFT JOIN delivery d ON d.addressFk = a.id - LEFT JOIN workerMedia wm ON wm.workerFk = c.salesPersonFk - LEFT JOIN - (SELECT tob.description Note, t.id - FROM ticketObservation tob - JOIN ticket t ON tob.ticketFk = t.id - JOIN observationType ot ON ot.id = tob.observationTypeFk - WHERE t.routeFk = vRouteFk - AND ot.code = 'delivery' - )tob ON tob.id = t.id - LEFT JOIN - (SELECT sub.ticketFk, - CONCAT('(', GROUP_CONCAT(DISTINCT sub.itemPackingTypeFk ORDER BY sub.items DESC SEPARATOR ','), ') ') itemPackingTypeFk - FROM (SELECT s.ticketFk , i.itemPackingTypeFk, COUNT(*) items - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - JOIN item i ON i.id = s.itemFk +SELECT * + FROM ( + SELECT t.id Id, + t.clientFk Client, + a.id Address, + a.nickname ClientName, + t.packages Packages, + a.street AddressName, + a.postalCode PostalCode, + a.city City, + sub2.itemPackingTypeFk PackingType, + c.phone ClientPhone, + c.mobile ClientMobile, + a.phone AddressPhone, + a.mobile AddressMobile, + d.longitude Longitude, + d.latitude Latitude, + wm.mediaValue SalePersonPhone, + tob.description Note, + t.isSigned Signed, + t.priority + FROM ticket t + JOIN client c ON t.clientFk = c.id + JOIN address a ON t.addressFk = a.id + LEFT JOIN delivery d ON d.ticketFk = t.id + LEFT JOIN workerMedia wm ON wm.workerFk = c.salesPersonFk + LEFT JOIN( + SELECT tob.description, t.id + FROM ticketObservation tob + JOIN ticket t ON tob.ticketFk = t.id + JOIN observationType ot ON ot.id = tob.observationTypeFk WHERE t.routeFk = vRouteFk - GROUP BY t.id,i.itemPackingTypeFk)sub - GROUP BY sub.ticketFk - ) sub2 ON sub2.ticketFk = t.id - WHERE t.routeFk = vRouteFk - GROUP BY t.id - ORDER BY t.priority; + AND ot.code = 'delivery' + )tob ON tob.id = t.id + LEFT JOIN( + SELECT sub.ticketFk, + CONCAT('(', + GROUP_CONCAT(DISTINCT sub.itemPackingTypeFk + ORDER BY sub.items DESC SEPARATOR ','), + ') ') itemPackingTypeFk + FROM ( + SELECT s.ticketFk, i.itemPackingTypeFk, COUNT(*) items + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN item i ON i.id = s.itemFk + WHERE t.routeFk = vRouteFk + GROUP BY t.id, i.itemPackingTypeFk + )sub + GROUP BY sub.ticketFk + )sub2 ON sub2.ticketFk = t.id + WHERE t.routeFk = vRouteFk + ORDER BY d.id DESC + LIMIT 10000000000000000000 + )sub3 + GROUP BY sub3.id + ORDER BY sub3.priority; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -64453,97 +66541,6 @@ BEGIN INSERT INTO vn.saleMistake(saleFk, userFk, typeFk) VALUES(vSaleFk, vUserFk, vTypeFk); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `saleMove` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `saleMove`(IN vSaleFk BIGINT, IN vQuantity BIGINT) -BEGIN - - DECLARE vShipped DATE; - DECLARE vWarehouseFk INT; - DECLARE vAddressFk INT; - DECLARE vAgencyModeFk INT; - DECLARE vNewTicket BIGINT; - DECLARE vNewSale BIGINT; - DECLARE vLanded DATE; - DECLARE vShippedDayEnd DATETIME; - DECLARE vTicketOriginalFk INT; - DECLARE hasAlreadyItem BOOLEAN; - DECLARE vItemFk INT; - DECLARE vClientTypeFk VARCHAR(20); - - SELECT t.shipped, t.warehouseFk, t.addressFk, agencyModeFk, landed, t.id, s.itemfk, c.typeFk - INTO vShipped, vWarehouseFk, vAddressFk, vAgencyModeFk, vLanded, vTicketOriginalFk, vItemFk, vClientTypeFk - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - JOIN `client` c ON t.clientFk = c.id - WHERE s.id = vSaleFk; - - SET vShippedDayEnd = util.dayEnd(vShipped); - - IF vClientTypeFk <> 'handMaking' THEN - SELECT t.id INTO vNewTicket - FROM ticket t - JOIN ticketState ts ON ts.ticketFk = t.id - WHERE t.addressFk = vAddressFk - AND t.warehouseFk = vWarehouseFk - AND t.agencyModeFk = vAgencyModeFk - AND t.landed <=> vLanded - AND t.shipped BETWEEN vShipped AND vShippedDayEnd - AND t.refFk IS NULL - AND t.id <> vTicketOriginalFk - AND IFNULL(ts.alertLevel,0) = 0 - LIMIT 1; - END IF; - - IF vNewTicket IS NULL THEN - CALL vn.ticket_Clone(vTicketOriginalFk, vNewTicket); - END IF; - - INSERT INTO ticketTracking(ticketFk, workerFk, stateFk) - SELECT vNewTicket, account.myUser_getId(), s.id - FROM state s - WHERE s.code = 'FIXING'; - - SELECT COUNT(id) INTO hasAlreadyItem - FROM sale s - WHERE s.ticketFk = vNewTicket AND s.itemFk = vItemFk; - - IF hasAlreadyItem = FALSE THEN - - INSERT INTO sale(ticketFk, itemFk, concept, quantity, price, discount) - SELECT vNewTicket, itemFk, concept, vQuantity, price, discount - FROM sale s - WHERE s.id = vSaleFk; - - SELECT LAST_INSERT_ID() INTO vNewSale; - - INSERT INTO saleComponent(saleFk, componentFk, `value`) - SELECT vNewSale, componentFk, `value` - FROM saleComponent - WHERE saleFk = vSaleFk; - - ELSE - - UPDATE sale - SET quantity = quantity + vQuantity - WHERE ticketFk = vNewTicket AND itemFk = vItemFk; - - END IF; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -64609,62 +66606,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `saleSplit` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `saleSplit`(vSaleFk INT, vQuantity INT) -BEGIN - - - DECLARE vNewSaleFk INT; - - INSERT INTO vn.sale(itemFk, - concept, - price, - discount, - quantity, - ticketFk, - isPriceFixed) - SELECT s.itemFk, - i.longName, - s.price, - s.discount, - vQuantity, - s.ticketFk, - s.isPriceFixed - FROM vn.sale s - JOIN vn.item i ON i.id = s.itemFk - WHERE s.id = vSaleFk; - - UPDATE vn.sale s - JOIN vn.item i ON i.id = s.itemFk - SET s.quantity = s.quantity - vQuantity, s.concept = i.longName - WHERE s.id = vSaleFk; - - SELECT LAST_INSERT_ID() INTO vNewSaleFk; - - INSERT INTO vn.saleComponent( saleFk, - componentFk, - value) - SELECT vNewSaleFk, - componentFk, - value - FROM vn.saleComponent - WHERE saleFk = vSaleFk; - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `sales_merge` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -64896,56 +66837,41 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_new`( vSaleFK INT, +CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_new`( + vSaleFK INT, vIsChecked BOOLEAN, - vOriginalQuantity INT, - vWorkerFk INT, - vAction VARCHAR(50), - vState VARCHAR(50)) + vOriginalQuantity INT, + vWorkerFk INT, + vAction VARCHAR(50), + vState VARCHAR(50), + vIsScanned BOOLEAN) BEGIN /** * Modifica registro de saleTracking - + * * @param vSaleFK Identificador del registro a modificar * @param vIsChecked Indica si la línea ha sido pulsada * @param vOriginalQuantity Cantidad original * @param vWorkerFk Identificador del trabajador * @param vAction Identificador de la acción realizada * @param vState Identificador del estado a modificar + * @param vIsScanned Identificador si se ha escaneado automáticamente o manual */ + REPLACE vn.saleTracking(saleFk, - isChecked, - originalQuantity, - workerFk, - stateFk) - SELECT vSaleFk, + isChecked, + originalQuantity, + workerFk, + stateFk, + isScanned) + SELECT vSaleFK, vIsChecked, - vOriginalQuantity, - IFNULL(vWorkerFk, vn.getUser()), - s.id + vOriginalQuantity, + IFNULL(vWorkerFk, vn.getUser()), + s.id, + vIsScanned FROM vn.state s WHERE s.code = vState COLLATE utf8_unicode_ci; - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `saleTracking_Replace` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_Replace`(vSaleFk INT, vIsChecked INT, vOriginalQuantity INT, vStateFk INT) -BEGIN - REPLACE vn.saleTracking(saleFk, isChecked, originalQuantity, stateFk) - VALUES(vSaleFk, vIsChecked, vOriginalQuantity, vStateFk); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -64958,11 +66884,11 @@ DELIMITER ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_updateIsChecked`(vSaleFk INT, vIsChecked BOOL) +CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_updateIsChecked`(vSaleFK INT, vIsChecked BOOL, vIsScanned BOOL) BEGIN /** @@ -64975,14 +66901,15 @@ BEGIN UPDATE vn.saleTracking st JOIN vn.state s ON s.id = st.stateFk AND s.code = 'PREVIOUS_PREPARATION' - SET st.isChecked = vIsChecked - WHERE st.saleFk = vSaleFk + SET st.isChecked = vIsChecked, + st.isScanned = vIsScanned + WHERE st.saleFk = vSaleFK AND st.workerFk = account.myUser_getId(); IF vIsChecked = FALSE THEN DELETE FROM vn.itemShelvingSale - WHERE saleFk = vSaleFk; + WHERE saleFk = vSaleFK; END IF; @@ -65002,21 +66929,20 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_calculateComponent`(vSale INT, vOption INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_calculateComponent`(vSelf INT, vOption INT) proc: BEGIN /** * Crea tabla temporal para vn.sale_recalcComponent() para recalcular los componentes * - * @param vSale Id de la venta + * @param vSelf Id de la venta * @param vOption indica en que componente pone el descuadre, NULL en casos habituales */ - DROP TEMPORARY TABLE IF EXISTS tmp.recalculateSales; - CREATE TEMPORARY TABLE tmp.recalculateSales + CREATE OR REPLACE TEMPORARY TABLE tmp.recalculateSales SELECT s.id FROM sale s - WHERE s.id = vSale; + WHERE s.id = vSelf; - CALL vn.sale_recalcComponent(vOption); + CALL sale_recalcComponent(vOption); DROP TEMPORARY TABLE tmp.recalculateSales; END ;; @@ -65257,7 +67183,7 @@ BEGIN DECLARE vDate DATE; DECLARE vAvailableCache INT; DECLARE vVisibleCache INT; - DECLARE vDone INT DEFAULT 0; + DECLARE vDone BOOL; DECLARE vComponentCount INT; DECLARE vCursor CURSOR FOR @@ -65266,7 +67192,7 @@ BEGIN WHERE DATE(tt.shipped) BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY, IF(vIsTodayRelative, 9.9, 1.9), util.VN_CURDATE()); - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DELETE tt.* FROM tmp.sale_getProblems tt @@ -65275,8 +67201,7 @@ BEGIN WHERE ot.code = 'administrative' AND tto.description = 'Miriam'; - DROP TEMPORARY TABLE IF EXISTS tmp.sale_problems; - CREATE TEMPORARY TABLE tmp.sale_problems ( + CREATE OR REPLACE TEMPORARY TABLE tmp.sale_problems ( ticketFk INT(11), saleFk INT(11), isFreezed INTEGER(1) DEFAULT 0, @@ -65292,8 +67217,7 @@ BEGIN PRIMARY KEY (ticketFk, saleFk) ) ENGINE = MEMORY; - DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; - CREATE TEMPORARY TABLE tmp.ticket_list + CREATE OR REPLACE TEMPORARY TABLE tmp.ticket_list (PRIMARY KEY (ticketFk)) ENGINE = MEMORY SELECT tp.ticketFk, tp.clientFk @@ -65348,15 +67272,14 @@ BEGIN WHERE c.isFreezed ON DUPLICATE KEY UPDATE isFreezed = c.isFreezed; - -- Cr�dito excedido - DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt; - CREATE TEMPORARY TABLE tmp.clientGetDebt + -- Credit exceeded + CREATE OR REPLACE TEMPORARY TABLE tmp.clientGetDebt (PRIMARY KEY (clientFk)) ENGINE = MEMORY SELECT DISTINCT clientFk FROM tmp.ticket_list; - CALL clientGetDebt(util.VN_CURDATE()); + CALL client_getDebt(util.VN_CURDATE()); INSERT INTO tmp.sale_problems(ticketFk, risk, hasHighRisk) SELECT DISTINCT tl.ticketFk, r.risk, ((r.risk - cc.riskTolerance) > c.credit + 10) @@ -65382,10 +67305,14 @@ BEGIN -- Disponible, Faltas, Inventario y Retrasos OPEN vCursor; - WHILE NOT vDone DO - + l: LOOP + SET vDone = FALSE; FETCH vCursor INTO vWarehouseFk, vDate; + IF vDone THEN + LEAVE l; + END IF; + -- Disponible: no va a haber suficiente producto para preparar todos los pedidos CALL cache.available_refresh(vAvailableCache, FALSE, vWarehouseFk, vDate); @@ -65473,7 +67400,7 @@ BEGIN AND t.warehouseFk = vWarehouseFk GROUP BY tl.ticketFk) sub ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk; - END WHILE; + END LOOP; CLOSE vCursor; @@ -65538,9 +67465,9 @@ DELIMITER ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_PriceFix`(vTicketFk INT) BEGIN @@ -65580,25 +67507,26 @@ DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_recalcComponent`(vOption INT) proc: BEGIN /** - * Actualiza los componentes + * Este procedimiento recalcula los componentes de un conjunto de sales, + * eliminando los componentes existentes e insertandolos de nuevo * - * @table tmp.recalculateSales + * @param vOption si no se quiere forzar llamar con NULL + * @table tmp.recalculateSales (id) */ DECLARE vShipped DATE; DECLARE vWarehouseFk SMALLINT; DECLARE vAgencyModeFk INT; DECLARE vAddressFk INT; - DECLARE vTicketFk BIGINT; - DECLARE vItemFk BIGINT; + DECLARE vTicketFk INT; DECLARE vLanded DATE; DECLARE vIsEditable BOOLEAN; DECLARE vZoneFk INTEGER; - - DECLARE vSale INTEGER; DECLARE vDone BOOL DEFAULT FALSE; DECLARE vCur CURSOR FOR - SELECT id from tmp.recalculateSales; + SELECT DISTINCT s.ticketFk + FROM tmp.recalculateSales rs + JOIN vn.sale s ON s.id = rs.id; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; @@ -65606,15 +67534,13 @@ proc: BEGIN l: LOOP SET vDone = FALSE; - FETCH vCur INTO vSale; + FETCH vCur INTO vTicketFk; IF vDone THEN LEAVE l; END IF; - SELECT t.refFk IS NULL, - s.ticketFk, - s.itemFk , + SELECT (hasToRecalcPrice OR ts.alertLevel IS NULL) AND t.refFk IS NULL, t.zoneFk, t.warehouseFk, t.shipped, @@ -65622,8 +67548,6 @@ proc: BEGIN t.agencyModeFk, t.landed INTO vIsEditable, - vTicketFk, - vItemFk, vZoneFk, vWarehouseFk, vShipped, @@ -65631,9 +67555,9 @@ proc: BEGIN vAgencyModeFk, vLanded FROM ticket t - JOIN sale s ON s.ticketFk = t.id - LEFT JOIN ticketState ts ON ts.ticketFk = t.id - WHERE s.id = vSale; + LEFT JOIN ticketState ts ON t.id = ts.ticket + LEFT JOIN alertLevel al ON al.id = ts.alertLevel + WHERE t.id = vTicketFk; CALL zone_getLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk, TRUE); @@ -65661,22 +67585,24 @@ proc: BEGIN -- rellena la tabla buyUltimate con la ultima compra CALL buyUltimate (vWarehouseFk, vShipped); - DELETE FROM tmp.buyUltimate WHERE itemFk != vItemFk; + CREATE OR REPLACE TEMPORARY TABLE tmp.sale + (PRIMARY KEY (saleFk)) ENGINE = MEMORY + SELECT s.id saleFk, vWarehouseFk warehouseFk + FROM sale s + JOIN tmp.recalculateSales rs ON s.id = rs.id + WHERE s.ticketFk = vTicketFk; - DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; - CREATE TEMPORARY TABLE tmp.ticketLot - SELECT vWarehouseFk warehouseFk, NULL available, vItemFk itemFk, buyFk, vZoneFk zoneFk - FROM tmp.buyUltimate - WHERE itemFk = vItemFk; + CREATE OR REPLACE TEMPORARY TABLE tmp.ticketLot + SELECT vWarehouseFk warehouseFk, NULL available, s.itemFk, bu.buyFk, vZoneFk zoneFk + FROM sale s + JOIN tmp.recalculateSales rs ON s.id = rs.id + LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk + WHERE s.ticketFk = vTicketFk + GROUP BY s.itemFk; CALL catalog_componentPrepare(); CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk); - DROP TEMPORARY TABLE IF EXISTS tmp.sale; - CREATE TEMPORARY TABLE tmp.sale - (PRIMARY KEY (saleFk)) ENGINE = MEMORY - SELECT vSale saleFk,vWarehouseFk warehouseFk; - IF vOption IS NULL THEN SET vOption = IF(vIsEditable, 1, 6); END IF; @@ -65690,72 +67616,6 @@ proc: BEGIN END LOOP; CLOSE vCur; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `sale_setQuantity` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_setQuantity`(vSaleFk INT, vQuantity INT) -BEGIN -/* - * Actualiza la cantidad de la línea de venta - * - * @vSaleFk id de la línea de venta - * @vQuantity cantidad a modificar - * - */ - - DECLARE vDescription VARCHAR(100); - DECLARE vOrigin INT; - - SELECT CONCAT("Cambio cantidad ",concept," de ", quantity," a ", vQuantity) INTO vDescription - FROM sale - WHERE id = vSaleFk; - - SELECT ticketFk INTO vOrigin FROM sale WHERE id = vSaleFk; - - CALL logAdd(vOrigin, 'update', 'ticket', vDescription); - - UPDATE sale - SET originalQuantity = quantity, - quantity = vQuantity - WHERE id = vSaleFk; - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `sale_updateOriginalQuantity` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_updateOriginalQuantity`(vSale INT, vQuantity INT) -proc: BEGIN - -UPDATE vn.sale SET originalQuantity = vQuantity -WHERE id = vSale; - -SELECT * FROM vn.sale WHERE id = vSale; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -65774,7 +67634,6 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sectorCollectionSaleGroup_add`(vSaleGroupFk INT, vSectorCollectionFk INT) BEGIN - /** * Inserta un nuevo registro en vn.sectorCollectionSaleGroup * Actualiza el usuario en vn.saleGroup y reemplaza los registros de vn.saleTracking @@ -65782,36 +67641,32 @@ BEGIN * @param vSaleGroupFk Identificador de vn.saleGroup * @param vSectorCollectionFk Identificador de vn.sectorCollection */ + REPLACE sectorCollectionSaleGroup + SET sectorCollectionFk = vSectorCollectionFk, + saleGroupFk = vSaleGroupFk; - REPLACE vn.sectorCollectionSaleGroup(sectorCollectionFk, saleGroupFk) - VALUES(vSectorCollectionFk, vSaleGroupFk); - - UPDATE vn.saleGroup sg - JOIN vn.sectorCollectionSaleGroup scsg ON scsg.saleGroupFk = sg.id - JOIN vn.sectorCollection sc ON sc.id = scsg.sectorCollectionFk + UPDATE saleGroup sg + JOIN sectorCollectionSaleGroup scsg ON scsg.saleGroupFk = sg.id + JOIN sectorCollection sc ON sc.id = scsg.sectorCollectionFk SET sg.userFk = sc.userFk WHERE sg.id = vSaleGroupFk; - - INSERT IGNORE vn.saleTracking(saleFk, - isChecked, - workerFk, - stateFk) - SELECT sgd.saleFk , + INSERT IGNORE saleTracking( + saleFk, + isChecked, + workerFk, + stateFk + ) + SELECT sgd.saleFk , FALSE, sc.userFk, s.id - FROM vn.saleGroupDetail sgd - JOIN vn.sectorCollectionSaleGroup scsg ON scsg.saleGroupFk = sgd.saleGroupFk - JOIN vn.sectorCollection sc ON sc.id = scsg.sectorCollectionFk - JOIN vn.state s ON s.code = 'PREVIOUS_PREPARATION' + FROM saleGroupDetail sgd + JOIN sectorCollectionSaleGroup scsg + ON scsg.saleGroupFk = sgd.saleGroupFk + JOIN sectorCollection sc ON sc.id = scsg.sectorCollectionFk + JOIN state s ON s.code = 'PREVIOUS_PREPARATION' WHERE sgd.saleGroupFk = vSaleGroupFk; - - UPDATE vn.saleTracking st - JOIN vn.saleGroupDetail sgd ON sgd.saleFk = st.saleFk - SET st.isChecked = TRUE - WHERE sgd.saleGroupFk = vSaleGroupFk AND st.workerFk = 20; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -65828,15 +67683,12 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `sectorCollection_get`(vSectorFk INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `sectorCollection_get`() BEGIN - - /** - * Devuelve las colecciones del sector que corresponden al usuario conectado, y que estan incompletas - * - * @param vSectorFk Identificador de vn.sector - */ - +/** + * Devuelve las colecciones del sector que corresponden al usuario conectado, y que estan incompletas + * + */ SELECT DISTINCT sc.id collectionFk, sc.created FROM vn.sectorCollection sc JOIN vn.state s ON s.code = 'PREVIOUS_PREPARATION' @@ -65845,11 +67697,11 @@ BEGIN LEFT JOIN vn.saleTracking st ON st.saleFk = sgd.saleFk AND st.stateFk = s.id AND st.workerFk = sc.userFk LEFT JOIN vn.sale sl ON sl.id = st.saleFk WHERE sc.userFk = account.myUser_getId() - AND (ISNULL(scsg.sectorCollectionFk) - OR - (NOT st.isChecked AND sl.quantity > 0)) + AND ( + ISNULL(scsg.sectorCollectionFk) + OR (NOT st.isChecked AND sl.quantity > 0) + ) AND sc.created > util.VN_CURDATE(); - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -65873,7 +67725,7 @@ BEGIN * * @param vSelf Identificador de vn.sectorCollection */ - SELECT s.ticketFk, + SELECT s.ticketFk, s.itemFk, i.longName, itemPackingTypeFk, @@ -65884,16 +67736,17 @@ BEGIN iss.quantity pickedQuantity, c.salesPersonFk FROM vn.sale s - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id - JOIN vn.sectorCollectionSaleGroup scsg ON scsg.saleGroupFk = sgd.saleGroupFk - JOIN vn.saleTracking st ON st.saleFk = s.id - JOIN vn.state stt ON stt.id = st.stateFk AND stt.code = 'PREVIOUS_PREPARATION' - JOIN vn.worker w ON w.id = st.workerFk - JOIN vn.ticket t ON t.id= s.ticketFk - JOIN vn.client c ON c.id=t.clientFk - LEFT JOIN vn.itemShelvingSaleSum iss ON iss.saleFk = s.id - WHERE scsg.sectorCollectionFk = vSelf; + JOIN item i ON i.id = s.itemFk + JOIN saleGroupDetail sgd ON sgd.saleFk = s.id + JOIN sectorCollectionSaleGroup scsg ON scsg.saleGroupFk = sgd.saleGroupFk + JOIN saleTracking st ON st.saleFk = s.id + JOIN `state` stt ON stt.id = st.stateFk AND stt.code = 'PREVIOUS_PREPARATION' + JOIN worker w ON w.id = st.workerFk + JOIN ticket t ON t.id= s.ticketFk + JOIN client c ON c.id=t.clientFk + LEFT JOIN itemShelvingSaleSum iss ON iss.saleFk = s.id + WHERE scsg.sectorCollectionFk = vSelf + AND st.workerFk = account.myUser_getId(); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -66267,11 +68120,11 @@ 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 = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `shelving_clean`() BEGIN @@ -66319,14 +68172,13 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `shelving_getSpam`(vDated DATE, vWarehouseFk INT) BEGIN - - /** - * Devuelve las matrículas con productos que no son necesarios para la venta hasta la fecha señalada - * - * @param vDated Fecha hasta la que se puede pasar sin esos productos. - * @param vWarehouse Identificador único de vn.warehouse - */ - +/** + * Devuelve las matrículas con productos que no son necesarios para la venta + * hasta la fecha señalada. + * + * @param vDated Fecha hasta la que se puede pasar sin esos productos + * @param vWarehouse Identificador único de vn.warehouse + */ DROP TEMPORARY TABLE IF EXISTS tmp.stock; CALL cache.stock_refresh(FALSE); @@ -66342,38 +68194,38 @@ BEGIN JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.itemCategory ic ON ic.id = it.categoryFk 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.parking p ON p.id = sh.parkingFk - JOIN vn.sector s ON s.id = p.sectorFk - WHERE s.code = 'FUENTES_PICASSE' - OR sh.isSpam - GROUP BY ish.itemFk - ) fue ON fue.itemFk = i.id + 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.parking p ON p.id = sh.parkingFk + JOIN vn.sector s ON s.id = p.sectorFk + WHERE s.code = 'FUENTES_PICASSE' + OR sh.isSpam + GROUP BY ish.itemFk + ) fue ON fue.itemFk = i.id LEFT JOIN cache.stock v ON i.id = v.item_id AND v.warehouse_id = vWarehouseFk LEFT JOIN ( - SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as venta - FROM vn2008.item_out - WHERE dat BETWEEN util.VN_CURDATE() AND util.dayend(vDated) - AND warehouse_id = vWarehouseFk - GROUP BY item_id - ) sale ON sale.item_id = i.id + SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as venta + FROM vn2008.item_out + WHERE dat BETWEEN util.VN_CURDATE() AND util.dayend(vDated) + AND warehouse_id = vWarehouseFk + GROUP BY item_id + ) sale ON sale.item_id = i.id LEFT JOIN ( - SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as compra - FROM vn2008.item_entry_in - WHERE dat BETWEEN util.VN_CURDATE() AND util.dayend(vDated) - AND warehouse_id = vWarehouseFk - AND isVirtualStock = FALSE - GROUP BY item_id - ) buy ON buy.item_id = i.id + SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as compra + FROM vn2008.item_entry_in + WHERE dat BETWEEN util.VN_CURDATE() AND util.dayend(vDated) + AND warehouse_id = vWarehouseFk + AND isVirtualStock = FALSE + GROUP BY item_id + ) buy ON buy.item_id = i.id LEFT JOIN ( - SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as traslado - FROM vn2008.item_entry_out - WHERE dat BETWEEN util.VN_CURDATE() AND util.dayend(vDated) - AND warehouse_id = vWarehouseFk - GROUP BY item_id - ) mov ON mov.item_id = i.id + SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as traslado + FROM vn2008.item_entry_out + WHERE dat BETWEEN util.VN_CURDATE() AND util.dayend(vDated) + AND warehouse_id = vWarehouseFk + GROUP BY item_id + ) mov ON mov.item_id = i.id WHERE v.amount; SELECT ish.shelvingFk matricula, @@ -66399,7 +68251,6 @@ BEGIN HAVING lineas = spam OR isSpam; DROP TEMPORARY TABLE tmp.stock; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -66516,7 +68367,9 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `stockBuyedByWorker`(vDate DATE, vWorker INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `stockBuyedByWorker`( + vDate DATE, + vWorker INT) BEGIN /** * Calculates the space reserved by buyers of the same container @@ -66524,20 +68377,24 @@ BEGIN * @param vdate date of container delivery * @param vWorker buyer reserving space in the container */ - DECLARE vVolume DECIMAL(10,2); + DECLARE vVolume DECIMAL(10, 2); DECLARE vWarehouseFk INT; - DECLARE vCompressionRatio DECIMAL(1,1); + DECLARE vCompressionRatio DECIMAL(1, 1); CALL stockTraslation(vDate); - SELECT warehosueFk, conversionCoefficient INTO vWarehouseFk, vCompressionRatio FROM auctionConfig; - SELECT volume INTO vVolume FROM vn.packaging WHERE id = 'cc'; + SELECT warehouseFk, conversionCoefficient INTO vWarehouseFk, vCompressionRatio + FROM auctionConfig; + + SELECT volume INTO vVolume + FROM vn.packaging WHERE id = 'cc'; SELECT b.entryFk Id_Entrada, i.id Id_Article, i.name Article, ti.amount Cantidad, - (vCompressionRatio * (ti.amount / b.packing) * vn.buy_getVolume(b.id))/vVolume buyed, + (vCompressionRatio * (ti.amount / b.packing) * vn.buy_getVolume(b.id)) + / vVolume buyed, b.packageFk id_cubo, b.packing FROM tmp_item ti @@ -66545,7 +68402,8 @@ BEGIN 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 tmp.buyUltimate bu ON bu.itemFk = i.id AND bu.warehouseFk = vWarehouseFk + JOIN tmp.buyUltimate bu ON bu.itemFk = i.id + AND bu.warehouseFk = vWarehouseFk JOIN buy b ON b.id = bu.buyFk WHERE ic.display AND w.id = vWorker; @@ -66634,37 +68492,40 @@ DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `stockTraslation`(vDate DATE) BEGIN /** - * Calcula el stock del vWarehouse desde FechaInventario hasta v_date - * sin tener en cuenta las salidas del mismo dia vDate - * para ver el transporte a reservar + * Calcula el stock del almacén de subasta desde FechaInventario hasta vDate + * sin tener en cuenta las salidas del mismo dia vDate + * para ver el transporte a reservar + * @param vDate Fecha hasta la cual calcula el stock */ + DECLARE vAuctionWarehouseFk INT; - DECLARE vWarehouse INT DEFAULT 7; + DELETE FROM stockBuyed WHERE `date` = vDate; - DELETE FROM stockBuyed WHERE `date` = vDate; + SELECT warehouseFk INTO vAuctionWarehouseFk + FROM auctionConfig; - DROP TEMPORARY TABLE IF EXISTS tmp_item; - CREATE TEMPORARY TABLE tmp_item - (UNIQUE INDEX i USING HASH (item_id)) - ENGINE = MEMORY - SELECT item_id, SUM(amount) amount - FROM vn2008.item_entry_in - WHERE dat = vDate - AND vDate >= util.VN_CURDATE() - AND warehouse_id = vWarehouse - AND isVirtualStock is FALSE - GROUP BY item_id - HAVING amount != 0; + DROP TEMPORARY TABLE IF EXISTS tmp_item; + CREATE TEMPORARY TABLE tmp_item + (UNIQUE INDEX i USING HASH (item_id)) + ENGINE = MEMORY + SELECT item_id, SUM(amount) amount + FROM vn2008.item_entry_in + WHERE dat = vDate + AND vDate >= util.VN_CURDATE() + AND warehouse_id = vAuctionWarehouseFk + AND isVirtualStock is FALSE + GROUP BY item_id + HAVING amount != 0; - CALL `cache`.stock_refresh (FALSE); + CALL `cache`.stock_refresh (FALSE); - INSERT INTO tmp_item (item_id,amount) - SELECT item_id,s.amount - FROM `cache`.stock s - WHERE warehouse_id = vWarehouse - ON DUPLICATE KEY UPDATE amount = tmp_item.amount + VALUES(amount); + INSERT INTO tmp_item (item_id,amount) + SELECT item_id,s.amount + FROM `cache`.stock s + WHERE warehouse_id = vAuctionWarehouseFk + ON DUPLICATE KEY UPDATE amount = tmp_item.amount + VALUES(amount); - CALL buyUltimate(vWarehouse,vDate); + CALL buyUltimate(vAuctionWarehouseFk, vDate); END ;; DELIMITER ; @@ -67112,9 +68973,9 @@ DELIMITER ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `supplier_disablePayMethodChecked`() BEGIN @@ -67268,81 +69129,31 @@ BEGIN * @param vTicketNew nuevo ticket clonado * @param vTicketOld icket original, a partir del qual se clonara el nuevo */ - DECLARE vShipped DATE; - DECLARE vClient INT; - DECLARE vWarehouse SMALLINT; - DECLARE vAgencyMode INT; - DECLARE vAddress INT; - DECLARE vLanded DATE; - DECLARE vAgency INT; - DECLARE vZoneFk INT; REPLACE INTO orderTicket(orderFk,ticketFk) SELECT orderFk, vTicketNew FROM orderTicket WHERE ticketFk = vTicketOld; - SELECT t.clientFk, t.warehouseFk, date(t.shipped), t.addressFk, t.agencyModeFk, t.landed, a.agencyFk, t.zoneFk - INTO vClient, vWarehouse, vShipped, vAddress, vAgencyMode, vLanded, vAgency, vZoneFk - FROM agencyMode a - JOIN ticket t ON t.agencyModeFk = a.id - WHERE t.id = vTicketNew; - - IF vLanded IS NULL THEN - CALL zone_getLanded(vShipped, vAddress, vAgency, vWarehouse, TRUE); - UPDATE ticket t - JOIN tmp.zoneGetLanded zgl ON t.warehouseFk = zgl.warehouseFk - SET t.landed = zgl.landed, - t.zoneFk = zgl.zoneFk - WHERE t.id = vTicketNew; - - SELECT zoneFk INTO vZoneFk FROM tmp.zoneGetLanded LIMIT 1; - DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetLanded; - END IF; - - -- rellena la tabla tmp.buyUltimate con la ultima compra - CALL buyUltimate(vWarehouse, vShipped); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; - CREATE TEMPORARY TABLE tmp.ticketLot - SELECT vWarehouse warehouseFk, NULL available, s.itemFk, bu.buyFk, vZoneFk zoneFk - FROM sale s - LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk - WHERE s.ticketFk = vTicketOld GROUP BY s.itemFk; - - CALL catalog_componentPrepare(); - CALL catalog_componentCalculate(vZoneFk, vAddress, vShipped, vWarehouse); - -- Bionizamos lineas con Preu = 0 - DROP TEMPORARY TABLE IF EXISTS tmp.sale; - CREATE TEMPORARY TABLE tmp.sale - (PRIMARY KEY (saleFk)) ENGINE = MEMORY - SELECT s.id saleFk, vWarehouse warehouseFk - FROM sale s - JOIN ticket t on t.id = s.ticketFk WHERE s.ticketFk = vTicketNew AND s.price = 0; + CREATE OR REPLACE TEMPORARY TABLE tmp.recalculateSales + (PRIMARY KEY (id)) ENGINE = MEMORY + SELECT id + FROM sale + WHERE ticketFk = vTicketNew AND price = 0; - CALL ticketComponentUpdateSale(1); + CALL sale_recalcComponent(1); -- Bionizamos lineas con Preu > 0 - DROP TEMPORARY TABLE IF EXISTS tmp.sale; - CREATE TEMPORARY TABLE tmp.sale - (PRIMARY KEY (saleFk)) ENGINE = MEMORY - SELECT s.id saleFk, vWarehouse warehouseFk - FROM sale s - JOIN ticket t on t.id = s.ticketFk WHERE s.ticketFk = vTicketNew - AND s.price > 0; + CREATE OR REPLACE TEMPORARY TABLE tmp.recalculateSales + (PRIMARY KEY (id)) ENGINE = MEMORY + SELECT id + FROM sale + WHERE ticketFk = vTicketNew AND price > 0; - CALL ticketComponentUpdateSale(6); + CALL sale_recalcComponent(6); - -- Log - CALL `logAdd`(vTicketNew, 'update', ' ticket' , 'Bioniza Ticket'); - - -- Limpieza - CALL catalog_componentPurge(); - DROP TEMPORARY TABLE IF EXISTS - tmp.buyUltimate, - tmp.sale, - tmp.zoneGetLanded; + DROP TEMPORARY TABLE IF EXISTS tmp.recalculateSales; END ;; DELIMITER ; @@ -67836,75 +69647,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticketCreate` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCreate`( - vClientId INT - ,vShipped DATE - ,vWarehouseId INT - ,vCompanyFk INT - ,vAddressFk INT - ,vAgencyType INT - ,vRouteFk INT - ,vlanded DATE - ,OUT vNewTicket INT) -BEGIN - CALL `ticketCreateWithUser`(vClientId, vShipped, vWarehouseId, vCompanyFk, vAddressFk, vAgencyType, vRouteFk, vlanded, account.myUser_getId(), vNewTicket); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticketCreateWithUser` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCreateWithUser`( - vClientId INT - ,vShipped DATE - ,vWarehouseFk INT - ,vCompanyFk INT - ,vAddressFk INT - ,vAgencyModeFk INT - ,vRouteFk INT - ,vlanded DATE - ,vUserId INT - ,OUT vNewTicket INT) -BEGIN - CALL ticket_add( - vClientId, - vShipped, - vWarehouseFk, - vCompanyFk, - vAddressFk, - vAgencyModeFk, - vRouteFk, - vlanded, - vUserId, - TRUE, - vNewTicket - ); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketDown_PrintableSelection` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68148,42 +69890,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticketManaToPromo` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketManaToPromo`(vTicketFk INT) -BEGIN - - DECLARE vManaComponent INT; - - DECLARE vPromoComponent INT; - - SELECT id INTO vManaComponent - FROM vn.component c - WHERE c.code = 'mana'; - - SELECT id INTO vPromoComponent - FROM vn.component c - WHERE c.code = 'floramondoPromo'; - - UPDATE vn.saleComponent sc - JOIN vn.sale s ON s.id = sc.saleFk - SET componentFk = vPromoComponent - WHERE componentFk = vManaComponent - AND s.ticketFk = vTicketFk; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketMissed_List` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68295,9 +70001,9 @@ DELIMITER ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketObservation_addNewBorn`(vTicketFk INT) BEGIN @@ -68326,13 +70032,14 @@ 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 character_set_client = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketPackaging_add`( + vClientFk INT, vDated DATE, vCompanyFk INT, vWithoutPeriodGrace BOOLEAN) @@ -68341,6 +70048,7 @@ BEGIN * Genera nuevos tickets de embalajes para los clientes no han los han retornado * y actualiza los valores para la tabla ticketPackaging * + * @param vClientFk Cliente en caso de NULL todos los clientes * @param vDated Fecha hasta la cual se revisan los embalajes * @param vCompanyFk Empresa de la cual se comprobaran sus clientes * @param vWithoutPeriodGrace si no se aplica el periodo de gracia de un mes @@ -68352,7 +70060,7 @@ BEGIN DECLARE vWarehouseInventory INT; DECLARE vComponentCost INT; DECLARE vDone INT DEFAULT FALSE; - DECLARE vClientFk INT; + DECLARE vClientId INT; DECLARE vCursor CURSOR FOR SELECT DISTINCT clientFk @@ -68410,6 +70118,7 @@ BEGIN JOIN ticket t ON t.id = tp.ticketFk JOIN client c ON c.id = t.clientFk WHERE c.isActive + AND (vClientFk IS NULL OR t.clientFk = vClientFk) AND t.shipped BETWEEN vDateStart AND vDateEnd AND (tp.quantity < 0 OR (tp.quantity > 0 AND t.shipped < vGraceDate)) AND tp.quantity @@ -68418,7 +70127,7 @@ BEGIN OPEN vCursor; l: LOOP - FETCH vCursor INTO vClientFk; + FETCH vCursor INTO vClientId; IF vDone THEN LEAVE l; @@ -68427,7 +70136,7 @@ BEGIN START TRANSACTION; CALL ticket_add( - vClientFk, + vClientId, vDateEnd, vWarehouseInventory, vCompanyFk, @@ -68442,7 +70151,7 @@ BEGIN INSERT INTO ticketPackaging(ticketFk, packagingFk, quantity, pvp) SELECT vNewTicket, packagingFk, - SUM(quantity) totalQuantity, price FROM tmp.packagingToInvoice - WHERE clientFk = vClientFk + WHERE clientFk = vClientId GROUP BY packagingFk HAVING IF(vWithoutPeriodGrace, totalQuantity <> 0, totalQuantity < 0); @@ -68450,7 +70159,7 @@ BEGIN SELECT vNewTicket, pti.itemFk, i.name, SUM(pti.quantity) totalQuantity, pti.price FROM tmp.packagingToInvoice pti JOIN item i ON i.id = pti.itemFk - WHERE pti.clientFk = vClientFk + WHERE pti.clientFk = vClientId GROUP BY pti.itemFk HAVING IF(vWithoutPeriodGrace, totalQuantity <> 0, totalQuantity > 0); @@ -68689,7 +70398,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `tmp`.`ticketToInvoiceByAddress` */; +/*!50003 DROP PROCEDURE IF EXISTS `ticketToInvoiceByAddress` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -68821,32 +70530,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticketTrackingAdd` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketTrackingAdd`(vTicketFk INT, vState VARCHAR(25) CHARSET UTF8, vWorkerFk INT) -BEGIN -/** - * Inserta un registro de cambios en un ticket. - * @param vTicketFk Id del ticket - * @param vState Código del estado - * @param vWorkerFk Id del trabajador - */ - INSERT INTO ticketTracking (stateFk, ticketFk, workerFk) - SELECT s.id, vTicketFk, vWorkerFk FROM state s WHERE s.code = vState; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68875,7 +70558,6 @@ BEGIN DECLARE vBonus DECIMAL(10,2); DECLARE vIsActive BOOL; DECLARE vNickname VARCHAR(100); - DECLARE vNewInstance JSON; IF vClientId IS NULL THEN CALL util.throw ('CLIENT_NOT_ESPECIFIED'); @@ -68947,23 +70629,6 @@ BEGIN SET vNewTicket = LAST_INSERT_ID(); - SET vNewInstance = JSON_OBJECT( - 'clientFk', vClientId, - 'shipped', vShipped, - 'addressFk', vAddressFk, - 'agencyModeFk', vAgencyModeFk, - 'nickname', vNickname, - 'warehouseFk', vWarehouseFk, - 'routeFk', vRouteFk, - 'companyFk', vCompanyFk, - 'landed', vlanded, - 'zoneFk', vZoneFk, - 'zonePrice', vPrice, - 'zoneBonus', vBonus - ); - CALL util.log_addWithUser('vn', 'ticket', - 'Ticket', vNewTicket, vNewTicket, 'insert', NULL, vNewInstance, vUserId); - INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) SELECT vNewTicket, ao.observationTypeFk, ao.description FROM addressObservation ao @@ -69026,11 +70691,11 @@ 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 = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT) BEGIN @@ -69041,7 +70706,6 @@ BEGIN * @param vDateToAdvance Fecha a cuando se quiere adelantar. * @param vWarehouseFk Almacén */ - DECLARE vDateInventory DATE; SELECT inventoried INTO vDateInventory FROM config; @@ -69320,92 +70984,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticket_changeClient` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_changeClient`(vNewClient INT, vUserFk INT) -BEGIN -/** - * Dado un conjunto de tickets - * cambia el cliente al nuevo cliente dado - * - * params @vNewClient nuevo cliente - * params @vUserFk usuario que realiza el cambio - * - * table @tmp.ticket(ticketFk) conjunto de tickets - */ - INSERT INTO ticketLog (originFk, userFk, `action`, changedModel, oldInstance, newInstance) - SELECT t.id, vUserFk, 'update', 'Ticket', CONCAT('{"clientFk":',t.clientFk,'}'), CONCAT('{"clientFk":',vNewClient,'}') - FROM ticket t - JOIN tmp.ticket tt - ON t.id = tt.ticketFk; - - UPDATE ticket t - JOIN tmp.ticket tt - ON t.id = tt.ticketFk - SET t.clientFk = vNewClient; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticket_checkFullyControlled` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_checkFullyControlled`(vWorkerFk INT, vTicketFk INT ) -BEGIN -/** - * Comprueba que no hay ningún ticket pendiente de revisar de alguna colección que haya revisado el trabajador - * @param vWorkerFk id del user - * @param vTicketFk número de ticket escaneada - * - */ - - SELECT t.id - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - JOIN ticketCollection tc ON tc.ticketFk = t.id - JOIN (SELECT tc.collectionFk - FROM ticketState ts - JOIN ticketCollection tc ON tc.ticketFk = ts.ticketFk - LEFT JOIN (SELECT tc.collectionFk - FROM ticketCollection tc - WHERE ticketFk = vTicketFk - AND tc.created >= util.VN_CURDATE() - )sub ON sub.collectionFk = tc.collectionFk - WHERE ts.workerFk = vWorkerFk - AND sub.collectionFk IS NULL - AND tc.created >= util.VN_CURDATE() - GROUP BY tc.collectionFk - )sub ON sub.collectionFk = tc.collectionFk - JOIN ticketState ts ON ts.ticketFk = t.id - JOIN state s2 ON s2.id = ts.stateFk - WHERE s2.code IN ('ON_PREPARATION', 'PREPARED', 'PREVIOUS_PREPARATION', 'OK PREVIOUS') - AND t.shipped >= util.VN_CURDATE() - AND s.quantity <>0 - LIMIT 1; - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_checkNoComponents` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -69421,38 +70999,16 @@ BEGIN /** * Comprueba que los tickets entre un rango de fechas tienen componentes + * y recalcula sus componentes * * @param vShippedFrom rango inicial de fecha * @param vShippedTo rango final de fecha */ - DECLARE v_done BOOL DEFAULT FALSE; - DECLARE vSaleFk INTEGER; - DECLARE vCur CURSOR FOR - SELECT s.id - FROM ticket t - JOIN client clt ON clt.id = t.clientFk - JOIN sale s ON s.ticketFk = t.id - JOIN item i ON i.id = s.itemFk - JOIN itemType tp ON tp.id = i.typeFk - JOIN itemCategory ic ON ic.id = tp.categoryFk - LEFT JOIN tmp.coste c ON c.id = s.id - WHERE t.shipped >= vShippedFrom AND t.shipped <= vShippedTo - AND c.id IS NULL - AND clt.isActive != 0 - AND ic.merchandise != 0 - GROUP BY s.id; - DECLARE CONTINUE HANDLER FOR NOT FOUND - SET v_done = TRUE; - - DROP TEMPORARY TABLE IF EXISTS tmp.coste; - - DROP TEMPORARY TABLE IF EXISTS tmp.coste; - CREATE TEMPORARY TABLE tmp.coste - (primary key (id)) ENGINE = MEMORY + CREATE OR REPLACE TEMPORARY TABLE tmp.coste + (primary key (id)) ENGINE = MEMORY SELECT s.id FROM ticket t - JOIN client clt ON clt.id = t.clientFk JOIN sale s ON s.ticketFk = t.id JOIN item i ON i.id = s.itemFk JOIN itemType tp ON tp.id = i.typeFk @@ -69460,23 +71016,25 @@ BEGIN JOIN saleComponent sc ON sc.saleFk = s.id JOIN component c ON c.id = sc.componentFk JOIN componentType ct ON ct.id = c.typeFk AND ct.id = 1 - WHERE t.shipped >= vShippedFrom - AND ic.merchandise != 0; + WHERE t.shipped BETWEEN vShippedFrom AND vShippedTo + AND ic.merchandise; - OPEN vCur; + CREATE OR REPLACE TEMPORARY TABLE tmp.recalculateSales + (primary key (id)) ENGINE = MEMORY + SELECT DISTINCT s.id + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN item i ON i.id = s.itemFk + JOIN itemType tp ON tp.id = i.typeFk + JOIN itemCategory ic ON ic.id = tp.categoryFk + LEFT JOIN tmp.coste c ON c.id = s.id + WHERE t.shipped >= vShippedFrom AND t.shipped <= vShippedTo + AND c.id IS NULL + AND ic.merchandise; - l: LOOP - SET v_done = FALSE; - FETCH vCur INTO vSaleFk; + CALL vn.sale_recalcComponent(1); - IF v_done THEN - LEAVE l; - END IF; - - CALL sale_calculateComponent(vSaleFk, 1); - END LOOP; - - CLOSE vCur; + DROP TEMPORARY TABLE tmp.recalculateSales; DROP TEMPORARY TABLE tmp.coste; END ;; DELIMITER ; @@ -69518,7 +71076,8 @@ BEGIN zoneBonus, routeFk, priority, - hasPriority + hasPriority, + clonedFrom ) SELECT clientFk, @@ -69530,21 +71089,21 @@ BEGIN companyFk, landed, zoneFk, - zonePrice, - zoneBonus, - routeFk, - priority, - hasPriority + zonePrice, + zoneBonus, + routeFk, + priority, + hasPriority, + vOriginalTicket FROM ticket WHERE id = vOriginalTicket; SET vNewTicket = LAST_INSERT_ID(); INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) - SELECT vNewTicket, ao.observationTypeFk, ao.description - FROM addressObservation ao - JOIN ticket t ON t.addressFk = ao.addressFk - WHERE t.id = vNewTicket; + SELECT vNewTicket, o.observationTypeFk, o.description + FROM ticketObservation o + WHERE o.ticketFk = vOriginalTicket; INSERT INTO ticketLog SET originFk = vNewTicket, userFk = account.myUser_getId(), `action` = 'insert', @@ -69581,16 +71140,16 @@ BEGIN DECLARE vLanding DATE; DECLARE vShipment DATE; DECLARE vWarehouseFk INT; - DECLARE vTicketFk INT; - DECLARE vWeekDay INT; - DECLARE vClientFk INT; - DECLARE vCompanyFk INT; - DECLARE vAddressFk INT; - DECLARE vAgencyModeFk INT; - DECLARE vNewTicket INT; - DECLARE vYear INT; + DECLARE vTicketFk INT; + DECLARE vWeekDay INT; + DECLARE vClientFk INT; + DECLARE vCompanyFk INT; + DECLARE vAddressFk INT; + DECLARE vAgencyModeFk INT; + DECLARE vNewTicket INT; + DECLARE vYear INT; - DECLARE rsTicket CURSOR FOR + DECLARE rsTicket CURSOR FOR SELECT tt.ticketFk, tt.weekDay, t.clientFk, t.warehouseFk, t.companyFk, t.addressFk, tt.agencyModeFk FROM vn.ticketWeekly tt JOIN vn.ticket t ON tt.ticketFk = t.id; @@ -69601,30 +71160,30 @@ BEGIN OPEN rsTicket; myLoop: LOOP - BEGIN - DECLARE vSalesPersonEmail VARCHAR(150); - DECLARE vMailSent BOOL; - DECLARE vSubject VARCHAR(150); - DECLARE vMessage TEXT; + BEGIN + DECLARE vSalesPersonEmail VARCHAR(150); + DECLARE vMailSent BOOL; + DECLARE vSubject VARCHAR(150); + DECLARE vMessage TEXT; SET vIsDone = FALSE; FETCH rsTicket INTO vTicketFk, vWeekDay, vClientFk, vWarehouseFk, vCompanyFk, vAddressFk, vAgencyModeFk; IF vIsDone THEN - LEAVE myLoop; END IF; + SELECT dated INTO vShipment FROM `time` WHERE `year` = vYear AND `week` = vWeek AND WEEKDAY(dated) = vWeekDay; - -- busca si el ticket ya ha sido clonado - IF (SELECT COUNT(*) FROM vn.ticket tOrig + -- busca si el ticket ya ha sido clonado + IF (SELECT COUNT(*) FROM vn.ticket tOrig JOIN vn.sale saleOrig ON tOrig.id = saleOrig.ticketFk - JOIN vn.saleCloned sc ON sc.saleOriginalFk = saleOrig.id - JOIN vn.sale saleClon ON saleClon.id = sc.saleClonedFk - JOIN vn.ticket tClon ON tClon.id = saleClon.ticketFk + JOIN vn.saleCloned sc ON sc.saleOriginalFk = saleOrig.id + JOIN vn.sale saleClon ON saleClon.id = sc.saleClonedFk + JOIN vn.ticket tClon ON tClon.id = saleClon.ticketFk WHERE tOrig.id = vTicketFk AND tClon.isDeleted = FALSE AND DATE(tClon.shipped) = vShipment) > 0 THEN ITERATE myLoop; @@ -69632,11 +71191,11 @@ BEGIN IF vAgencyModeFk IS NULL THEN SELECT agencyModeFk INTO vAgencyModeFk - FROM address - WHERE clientFk = vClientFk AND isDefaultAddress; - END IF; + FROM address + WHERE clientFk = vClientFk AND isDefaultAddress; + END IF; - CALL vn.zone_getLanded(vShipment, vAddressFk, vAgencyModeFk, vWarehouseFk,FALSE); + CALL vn.zone_getLanded(vShipment, vAddressFk, vAgencyModeFk, vWarehouseFk,FALSE); SET vLanding = NULL; SELECT landed INTO vLanding from tmp.zoneGetLanded LIMIT 1; @@ -69653,6 +71212,10 @@ BEGIN FALSE, vNewTicket); + UPDATE ticket + SET clonedFrom = vTicketFk + WHERE id = vNewTicket; + IF (vLanding IS NULL) THEN SELECT e.email INTO vSalesPersonEmail @@ -69695,7 +71258,7 @@ BEGIN SELECT description,ordered,shipped,quantity,price,itemFk,clientFk,response, total,buyed,requesterFk,attenderFk,vNewTicket FROM ticketRequest - WHERE ticketFk =vTicketFk; + WHERE ticketFk =vTicketFk; INSERT INTO ticketObservation(ticketFk,observationTypeFk,description) VALUES(vNewTicket,4,CONCAT('turno desde ticket: ',vTicketFk)) ON DUPLICATE KEY UPDATE description = CONCAT(ticketObservation.description,VALUES(description),' '); @@ -69807,7 +71370,7 @@ BEGIN IF(vHasDailyInvoice) AND vHasToInvoice THEN -- Facturacion rapida - CALL ticketTrackingAdd(vCurTicketFk, 'DELIVERED', NULL); + CALL ticket_setState(vCurTicketFk, 'DELIVERED'); -- Facturar si está contabilizado IF vIsTaxDataChecked THEN CALL invoiceOut_newFromClient( @@ -69820,7 +71383,7 @@ BEGIN vNewInvoiceId); END IF; ELSE - CALL ticketTrackingAdd(vCurTicketFk, (SELECT vn.getAlert3State(vCurTicketFk)), NULL); + CALL ticket_setState(vCurTicketFk, (SELECT vn.getAlert3State(vCurTicketFk))); END IF; END LOOP; @@ -69881,12 +71444,20 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_componentMakeUpdate`(IN vTicketFk INT, IN vClientFk INT, - IN vNickname VARCHAR(50), IN vAgencyModeFk INT, - IN vAddressFk INT, IN vZoneFk INT, IN vWarehouseFk TINYINT, - IN vCompanyFk SMALLINT, IN vShipped DATETIME, - IN vLanded DATE, IN vIsDeleted TINYINT(1), - IN vHasToBeUnrouted TINYINT(1), IN vOption INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_componentMakeUpdate`( + vTicketFk INT, + vClientFk INT, + vNickname VARCHAR(50), + vAgencyModeFk INT, + vAddressFk INT, + vZoneFk INT, + vWarehouseFk INT, + vCompanyFk INT, + vShipped DATETIME, + vLanded DATE, + vIsDeleted BOOLEAN, + vHasToBeUnrouted BOOLEAN, + vOption INT) BEGIN /** @@ -70101,7 +71672,6 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_DelayTruck`(vWarehouserFk INT, vHour INT, vMinute INT) BEGIN - DECLARE done INT DEFAULT FALSE; DECLARE vTicketFk INT; DECLARE cur1 CURSOR FOR SELECT ticketFk FROM tmp.ticket; @@ -70112,29 +71682,25 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket; CREATE TEMPORARY TABLE tmp.ticket - SELECT ticketFk - FROM tmp.productionBuffer - WHERE shipped = util.VN_CURDATE() - AND problem LIKE '%I:%' - AND (HH <= vHour OR HH = vHour AND mm < vMinute) - AND alertLevel = 0; + SELECT ticketFk + FROM tmp.productionBuffer + WHERE shipped = util.VN_CURDATE() + AND problem LIKE '%I:%' + AND (HH <= vHour OR HH = vHour AND mm < vMinute) + AND alertLevel = 0; OPEN cur1; - read_loop: LOOP + read_loop: LOOP + FETCH cur1 INTO vTicketFk; + IF done THEN + LEAVE read_loop; + END IF; - FETCH cur1 INTO vTicketFk; - - IF done THEN - LEAVE read_loop; - END IF; - - CALL vn.ticket_DelayTruckSplit(vTicketFk); - - END LOOP; - - CLOSE cur1; + CALL vn.ticket_DelayTruckSplit(vTicketFk); + END LOOP; + CLOSE cur1; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -70224,7 +71790,6 @@ proc: BEGIN */ DECLARE vDone BOOL; DECLARE vTicketFk INT; - DECLARE vError INT; DECLARE cCur CURSOR FOR SELECT DISTINCT ticketFk FROM tTicket; @@ -70236,8 +71801,6 @@ proc: BEGIN BEGIN DO RELEASE_LOCK('vn.ticket_doRecalc'); ROLLBACK; - GET DIAGNOSTICS CONDITION 2 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT; - SET vError = IFNULL(@errno, 0); RESIGNAL; END; @@ -70276,140 +71839,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticket_doRefund` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_doRefund`(OUT vNewTicket INT) -BEGIN -/** - * Crea un ticket de abono a partir de tmp.sale y/o tmp.ticketService - * - * @return vNewTicket - */ - DECLARE vDone BIT DEFAULT 0; - DECLARE vClientFk MEDIUMINT; - DECLARE vWarehouse TINYINT; - DECLARE vCompany MEDIUMINT; - DECLARE vAddress MEDIUMINT; - DECLARE vRefundAgencyMode INT; - DECLARE vItemFk INT; - DECLARE vQuantity DECIMAL (10,2); - DECLARE vConcept VARCHAR(50); - DECLARE vPrice DECIMAL (10,2); - DECLARE vDiscount TINYINT; - DECLARE vSaleNew INT; - DECLARE vSaleMain INT; - DECLARE vZoneFk INT; - DECLARE vDescription VARCHAR(50); - DECLARE vTaxClassFk INT; - DECLARE vTicketServiceTypeFk INT; - DECLARE vOriginTicket INT; - - DECLARE cSales CURSOR FOR - SELECT s.id, s.itemFk, - s.quantity, s.concept, s.price, s.discount - FROM tmp.sale s; - - DECLARE cTicketServices CURSOR FOR - SELECT ts.description, - ts.quantity, ts.price, ts.taxClassFk, ts.ticketServiceTypeFk - FROM tmp.ticketService ts; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - SELECT sub.ticketFk INTO vOriginTicket - FROM ( - SELECT s.ticketFk - FROM tmp.sale s - UNION ALL - SELECT ts.ticketFk - FROM tmp.ticketService ts - ) sub - LIMIT 1; - - SELECT id INTO vRefundAgencyMode - FROM agencyMode WHERE `name` = 'ABONO'; - - SELECT clientFk, warehouseFk, companyFk, addressFk - INTO vClientFk, vWarehouse, vCompany, vAddress - FROM ticket - WHERE id = vOriginTicket; - - SELECT id INTO vZoneFk - FROM zone WHERE agencyModeFk = vRefundAgencyMode - LIMIT 1; - - INSERT INTO vn.ticket ( - clientFk, - shipped, - addressFk, - agencyModeFk, - nickname, - warehouseFk, - companyFk, - landed, - zoneFk - ) - SELECT - vClientFk, - util.VN_CURDATE(), - vAddress, - vRefundAgencyMode, - a.nickname, - vWarehouse, - vCompany, - util.VN_CURDATE(), - vZoneFk - FROM address a - WHERE a.id = vAddress; - - SET vNewTicket = LAST_INSERT_ID(); - - SET vDone := FALSE; - OPEN cSales; - FETCH cSales INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount; - - WHILE NOT vDone DO - INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price, discount) - VALUES( vNewTicket, vItemFk, vQuantity, vConcept, vPrice, vDiscount ); - - SET vSaleNew = LAST_INSERT_ID(); - - INSERT INTO vn.saleComponent(saleFk,componentFk,`value`) - SELECT vSaleNew,componentFk,`value` - FROM vn.saleComponent - WHERE saleFk = vSaleMain; - - FETCH cSales INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount; - END WHILE; - CLOSE cSales; - - SET vDone := FALSE; - OPEN cTicketServices; - FETCH cTicketServices INTO vDescription, vQuantity, vPrice, vTaxClassFk, vTicketServiceTypeFk; - - WHILE NOT vDone DO - INSERT INTO vn.ticketService(description, quantity, price, taxClassFk, ticketFk, ticketServiceTypeFk) - VALUES(vDescription, vQuantity, vPrice, vTaxClassFk, vNewTicket, vTicketServiceTypeFk); - - FETCH cTicketServices INTO vDescription, vQuantity, vPrice, vTaxClassFk, vTicketServiceTypeFk; - END WHILE; - - CLOSE cTicketServices; - - INSERT INTO vn.ticketRefund(refundTicketFk, originalTicketFk) - VALUES(vNewTicket, vOriginTicket); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_getFromFloramondo` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -70936,6 +72365,123 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_getWarnings` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getWarnings`() +BEGIN +/** + * Calcula las adventencias para un conjunto de tickets. + * Agrupados por ticket + * + * @table tmp.sale_getWarnings(ticketFk) Identificadores de los tickets a calcular + * @return tmp.ticket_warnings + */ + CREATE OR REPLACE TEMPORARY TABLE tSaleWarnings ( + ticketFk INT(11), + saleFk INT(11), + isFragile INTEGER(1) DEFAULT 0, + PRIMARY KEY (ticketFk, saleFk) + ) ENGINE = MEMORY; + + -- Fragile + INSERT INTO tSaleWarnings(ticketFk, saleFk, isFragile) + SELECT tt.ticketFk, s.id, TRUE + FROM tmp.sale_getWarnings tt + LEFT JOIN sale s ON s.ticketFk = tt.ticketFk + LEFT JOIN item i ON i.id = s.itemFk + LEFT JOIN itemType it ON it.id = i.typeFk + LEFT JOIN agencyMode am ON am.id = tt.agencyModeFk + LEFT JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk + WHERE dm.code IN ('AGENCY') + AND it.isFragile; + + CREATE OR REPLACE TEMPORARY TABLE tmp.ticket_warnings + (PRIMARY KEY (ticketFk)) + ENGINE = MEMORY + SELECT + sw.ticketFk, + MAX(sw.isFragile) AS isFragile + FROM tSaleWarnings sw + GROUP BY sw.ticketFk; + + DROP TEMPORARY TABLE + tSaleWarnings; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_getWithParameters` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getWithParameters`( + vClientFk INT, + vWarehouseFk INT, + vShipped DATE, + vAddressFk INT, + vCompanyFk INT, + vAgencyModeFk INT, + OUT vTicketFk INT + ) +BEGIN +/** + * Devuelve un ticket con los parametros, en caso de no existir lo crea + * + * @param vClientFk Cliente + * @param vWarehouseFk almacen + * @param vShipped Fecha de preparacion + * @param vAddressFk Consignatario + * @param vCompanyFk Empresa + * @param vAgencyModeFk agencia + */ + + SELECT t.id INTO vTicketFk + FROM vn.ticket t + WHERE t.clientFk <=> vClientFk + AND t.warehouseFk <=> vWarehouseFk + AND (t.shipped <=> vShipped OR vShipped IS NULL) + AND (t.addressFk <=> vAddressFk OR vAddressFk IS NULL) + AND (t.companyFk <=> vCompanyFk OR vCompanyFk IS NULL) + AND (t.agencyModeFk <=> vAgencyModeFk OR vAgencyModeFk IS NULL) + LIMIT 1; + + IF vTicketFk IS NULL THEN + CALL vn.ticket_add( + vClientFk, + IFNULL(vShipped, util.VN_CURDATE()), + vWarehouseFk, + vCompanyFk, + vAddressFk, + vAgencyModeFk, + NULL, + vShipped, + `account`.`myUser_getId`(), + TRUE, + vTicketFk + ); + END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_insertZone` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -70991,15 +72537,13 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_merge`(vSelf INT, vTicketTargetFk INT) BEGIN - - /** - * Fusiona el primer ticket al segundo - * - * @param vSelf Número de ticket a fusionar - * @param vTicketTargetFk Ticket destino - * - */ - +/** + * Fusiona el primer ticket al segundo. + * + * @param vSelf Número de ticket a fusionar + * @param vTicketTargetFk Ticket destino + * + */ UPDATE vn.sale s SET s.ticketFk = vTicketTargetFk WHERE s.ticketFk = vSelf; @@ -71007,7 +72551,6 @@ BEGIN UPDATE vn.ticket t SET t.shipped = TIMESTAMPADD(YEAR, - YEAR(util.VN_NOW()) MOD 2000, t.shipped ) WHERE t.id = vSelf; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -71071,6 +72614,52 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_printLabelPrevious` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_printLabelPrevious`(vTicketFk INT) +BEGIN +/** + * Calls the report_print procedure and passes it + * the necessary parameters for printing. + * + * @param vTicketFk id ticket to print. + */ + DECLARE vPrinterFk INT; + DECLARE vSaleGroup INT; + DECLARE vUserFk INT DEFAULT account.myUser_getId(); + + SELECT sg.id, w.labelerFk INTO vSaleGroup, vPrinterFk + FROM saleGroup sg + JOIN sector sc ON sc.id = sg.sectorFk + JOIN saleGroupDetail sgd ON sg.id = sgd.saleGroupFk + JOIN sale s ON sgd.saleFk = s.id + JOIN ticket t ON s.ticketFk = t.id + JOIN worker w ON w.id = vUserFk + WHERE sc.id = w.sectorFk + AND t.id = vTicketFk + LIMIT 1; + + CALL report_print( + 'LabelPrevia', + vPrinterFk, + vUserFk, + JSON_OBJECT('id', vSaleGroup, 'userFk', vUserFk), + 'high' + ); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_recalc` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -71120,92 +72709,24 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_recalcComponents`(IN vTicketFk BIGINT, vIsTicketEditable BOOLEAN) +CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_recalcComponents`(vSelf INT, vOption INT) proc: BEGIN /** - * Este procedimiento recalcula los componentes de un ticket, - * eliminando los componentes existentes e insertandolos de nuevo + * Crea tabla temporal para sale_recalcComponent() para recalcular los componentes * - * @param vTicketFk Id del ticket - * @param vIsTicketEditable si no se quiere forzar llamar con NULL + * @param vSelf Id del ticket + * @param vOption si no se quiere forzar llamar con NULL */ - DECLARE vShipped DATE; - DECLARE vWarehouseFk SMALLINT; - DECLARE vAgencyModeFk INT; - DECLARE vAddressFk INT; - DECLARE vLanded DATE; - DECLARE vZoneFk INTEGER; - IF vIsTicketEditable IS NULL THEN - SELECT IFNULL(ts.alertLevel,0) = 0 AND IFNULL(t.refFk,'') = '' - INTO vIsTicketEditable - FROM ticket t LEFT JOIN ticketState ts ON t.id = ts.ticket - WHERE id = vTicketFk; - END IF; - - SELECT t.warehouseFk, - t.shipped, - t.addressFk, - t.agencyModeFk, - t.landed, - t.zoneFk - INTO vWarehouseFk, vShipped, vAddressFk, vAgencyModeFk, vLanded, vZoneFk - FROM ticket t LEFT JOIN ticketState ts ON t.id = ts.ticket - WHERE t.id = vTicketFk; - - CALL zone_getLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk, TRUE); - - IF (SELECT COUNT(*) FROM tmp.zoneGetLanded LIMIT 1) = 0 THEN - CALL util.throw('There is no zone for these parameters'); - END IF; - - IF vLanded IS NULL OR vZoneFk IS NULL THEN - - UPDATE ticket t - SET t.landed = (SELECT landed FROM tmp.zoneGetLanded LIMIT 1) - WHERE t.id = vTicketFk AND t.landed IS NULL; - - IF vZoneFk IS NULL THEN - SELECT zoneFk INTO vZoneFk FROM tmp.zoneGetLanded LIMIT 1; - UPDATE ticket t - SET t.zoneFk = vZoneFk - WHERE t.id = vTicketFk AND t.zoneFk IS NULL; - END IF; - - END IF; - - DROP TEMPORARY TABLE tmp.zoneGetLanded; - - -- rellena la tabla buyUltimate con la ultima compra - CALL buyUltimate (vWarehouseFk, vShipped); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; - CREATE TEMPORARY TABLE tmp.ticketLot - SELECT vWarehouseFk warehouseFk, NULL available, - s.itemFk, bu.buyFk, vZoneFk zoneFk + CREATE OR REPLACE TEMPORARY TABLE tmp.recalculateSales + SELECT s.id FROM sale s - LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk - WHERE s.ticketFk = vTicketFk - GROUP BY s.itemFk; + WHERE s.ticketFk = vSelf; - CALL catalog_componentPrepare(); - CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk); + CALL sale_recalcComponent(vOption); - DROP TEMPORARY TABLE IF EXISTS tmp.sale; - CREATE TEMPORARY TABLE tmp.sale - (PRIMARY KEY (saleFk)) ENGINE = MEMORY - SELECT id saleFk, vWarehouseFk warehouseFk - FROM sale s - WHERE s.ticketFk = vTicketFk; - - -- si el ticket esta facturado, respeta los precios - CALL ticketComponentUpdateSale(IF(vIsTicketEditable, 1, 6)); - - CALL catalog_componentPurge(); - DROP TEMPORARY TABLE - tmp.buyUltimate, - tmp.sale; + DROP TEMPORARY TABLE tmp.recalculateSales; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -71386,7 +72907,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setState`(vSelf INT, vStateCode VARCHAR(255)) +CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setState`(vSelf INT, vStateCode VARCHAR(255) COLLATE utf8_general_ci) BEGIN /** * Modifica el estado de un ticket si se cumplen las condiciones necesarias. @@ -71394,32 +72915,50 @@ BEGIN * @param vSelf el id del ticket * @param vStateCode estado a modificar del ticket */ - DECLARE vAlertLevel INT; - DECLARE vCurrentStateCode VARCHAR(255); + DECLARE vticketAlertLevel INT; + DECLARE vTicketStateCode VARCHAR(255); DECLARE vCanChangeState BOOL; - DECLARE vPackedState INT; + DECLARE vPackedAlertLevel INT; + DECLARE vOnPreparationAlertLevel INT; + DECLARE vNextAlertLevel INT; + DECLARE vZoneFk INT; - SELECT s.alertLevel, s.`code` - INTO vAlertLevel, vCurrentStateCode + SELECT s.alertLevel, s.`code`, s2.alertLevel, t.zoneFk + INTO vticketAlertLevel, vTicketStateCode, vNextAlertLevel , vZoneFk FROM state s - JOIN ticketState ts ON ts.stateFk = s.id - WHERE ts.ticketFk = vSelf; + JOIN ticketTracking tt ON tt.stateFk = s.id + JOIN state s2 ON s2.code = vStateCode + JOIN ticket t ON t.id = tt.ticketFk + WHERE tt.ticketFk = vSelf + ORDER BY tt.created DESC + LIMIT 1; - SELECT id INTO vPackedState - FROM alertLevel - WHERE code = 'PACKED'; + SELECT id INTO vPackedAlertLevel FROM alertLevel WHERE code = 'PACKED'; + SELECT id INTO vOnPreparationAlertLevel FROM alertLevel WHERE code = 'ON_PREPARATION'; - SET vCanChangeState = (vStateCode <> 'ON_CHECKING' OR vAlertLevel < vPackedState) + IF vStateCode = 'OK' AND vZoneFk IS NULL THEN + CALL util.throw('ASSIGN_ZONE_FIRST'); + END IF; + + IF vNextAlertLevel > vticketAlertLevel && vticketAlertLevel < vOnPreparationAlertLevel THEN + UPDATE sale + SET originalQuantity = quantity + WHERE ticketFk = vSelf; + END IF; + + SET vCanChangeState = (vStateCode <> 'ON_CHECKING' OR vticketAlertLevel < vPackedAlertLevel) AND NOT ( - vCurrentStateCode IN ('CHECKED', 'CHECKING') + vTicketStateCode IN ('CHECKED', 'CHECKING') AND vStateCode IN ('PREPARED', 'ON_PREPARATION') ); IF vCanChangeState THEN - INSERT INTO ticketTracking(stateFk, ticketFk, workerFk) + INSERT INTO ticketTracking (stateFk, ticketFk, workerFk) SELECT id, vSelf, account.myUser_getId() FROM state WHERE `code` = vStateCode COLLATE utf8_unicode_ci; + ELSE + CALL util.throw('INCORRECT_TICKET_STATE'); END IF; END ;; DELIMITER ; @@ -71806,17 +73345,17 @@ BEGIN at2.name, at2.permissionRate, at2.discountRate, - cl.hours_week hoursWeek, + ct.hoursWeek hoursWeek, at2.isAllowedToWork FROM time t LEFT JOIN business b ON t.dated BETWEEN b.started AND IFNULL(b.ended, vDatedTo) LEFT JOIN worker w ON w.id = b.workerFk JOIN tmp.`user` u ON u.userFK = w.userFK LEFT JOIN workCenter wc ON wc.id = b.workcenterFK - LEFT JOIN postgresql.calendar_labour_type cl ON cl.calendar_labour_type_id = b.calendarTypeFk + LEFT JOIN calendarType ct ON ct.id = b.calendarTypeFk LEFT JOIN postgresql.journey j ON j.business_id = b.id AND j.day_id = WEEKDAY(t.dated) + 1 - LEFT JOIN postgresql.calendar_employee ce ON ce.businessFk = b.id AND ce.date = t.dated - LEFT JOIN absenceType at2 ON at2.id = ce.calendar_state_id + LEFT JOIN calendar c ON c.businessFk = b.id AND c.dated = t.dated + LEFT JOIN absenceType at2 ON at2.id = c.dayOffTypeFk WHERE t.dated BETWEEN vDatedFrom AND vDatedTo GROUP BY w.userFk, t.dated )sub; @@ -72009,25 +73548,33 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_calculate`(vDatedFrom DATETIME, vDatedTo DATETIME) +CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_calculate`( + vDatedFrom DATETIME, + vDatedTo DATETIME) BEGIN /* * @param vDatedFrom * @param vDatedTo - * Calculo de horas trabajadas por empleado y dia, sin tener encuenta los dias con fichadas incorrectas - * segun la tabla tmp.timeControlError - * @return tmp.timeControlCalculate (workerFk, dated, timeWorkSeconds, timeWorkSexagesimal, timeWorkDecimal, timed) + * Cálculo de horas trabajadas por empleado y día, + * sin tener encuenta los días con fichadas incorrectas según la tabla tmp.timeControlError + * En el caso de haber hecho descanso y hacer jornada intensiva, + * se añade al tiempo de trabajo efectivo un descanso el valor de vBreakTime + * @return tmp.timeControlCalculate + * (workerFk, dated, timeWorkSeconds, timeWorkSexagesimal, timeWorkDecimal, timed) */ DECLARE vHourToSeconds INTEGER; DECLARE vDatedFromYesterday DATETIME; DECLARE vDatedToTomorrow DATETIME; DECLARE vTimeToBreakTime INT; DECLARE vBreakTime INT; + DECLARE vBreakTimeSplitDay INT; + DECLARE vDateSplitDay DATE; SELECT DATE_SUB(vDatedFrom, INTERVAL 1 DAY), DATE_ADD(vDatedTo, INTERVAL 1 DAY) INTO vDatedFromYesterday, vDatedToTomorrow; - SELECT timeToBreakTime, breakTime INTO vTimeToBreakTime, vBreakTime + SELECT timeToBreakTime, breakTime, breakTimeSplitDay, dateSplitDay + INTO vTimeToBreakTime, vBreakTime, vBreakTimeSplitDay, vDateSplitDay FROM workerTimeControlConfig LIMIT 1; CALL timeControl_getError(vDatedFrom, vDatedTo); @@ -72065,11 +73612,15 @@ BEGIN -- Cambio de dia en medio de un descanso INSERT INTO tmp.workerTimeControlAux (id, userFk, timed, direction) - SELECT @vCont:= @vCont + 1 id, userFk, util.dayEnd(dated) timed, 'middle' direction + SELECT @vCont:= @vCont + 1 id, + userFk, + util.dayEnd(dated) timed, + 'middle' direction FROM(SELECT wtc.userFk, DATE(@lastTimed) dated, (@vIsOdd := NOT @vIsOdd) isOdd, - IF(@vIsOdd AND wtc.direction = 'middle' AND DATE(timed) <> DATE(@lastTimed), TRUE, FALSE) hasBreak, + IF(@vIsOdd AND wtc.direction = 'middle' + AND DATE(timed) <> DATE(@lastTimed), TRUE, FALSE) hasBreak, @lastTimed := wtc.timed FROM tmp.workerTimeControl wtc ORDER BY wtc.userFk, wtc.timed @@ -72081,11 +73632,15 @@ BEGIN SET @vIsOdd := FALSE; INSERT INTO tmp.workerTimeControlAux (id, userFk, timed, direction) - SELECT @vCont:= @vCont + 1, userFk, DATE_ADD(sub.dated, INTERVAL 1 DAY), 'middle' + SELECT @vCont:= @vCont + 1, + userFk, + DATE_ADD(sub.dated, INTERVAL 1 DAY), + 'middle' FROM(SELECT wtc.userFk, DATE(@lastTimed) dated, (@vIsOdd := NOT @vIsOdd) isOdd, - IF(@vIsOdd AND wtc.direction = 'middle' AND DATE(timed) <> DATE(@lastTimed), TRUE, FALSE) hasBreak, + IF(@vIsOdd AND wtc.direction = 'middle' + AND DATE(timed) <> DATE(@lastTimed), TRUE, FALSE) hasBreak, @lastTimed := wtc.timed FROM tmp.workerTimeControl wtc ORDER BY wtc.userFk, wtc.timed @@ -72095,7 +73650,10 @@ BEGIN -- Cambio de dia INSERT INTO tmp.workerTimeControlAux (id, userFk, timed, direction) - SELECT @vCont:= @vCont + 1 id, sub.userFk, util.dayEnd(sub.dated) timed, 'out' direction + SELECT @vCont:= @vCont + 1 id, + sub.userFk, + util.dayEnd(sub.dated) timed, + 'out' direction FROM (SELECT MAX(wtc.timed) timed, wtc.userFk, date(wtc.timed) dated FROM workerTimeControl wtc JOIN tmp.`user` w ON w.userFk = wtc.userFk @@ -72104,7 +73662,8 @@ BEGIN AND tce.id IS NULL GROUP BY wtc.userFk, DATE(wtc.timed) ) sub - JOIN tmp.workerTimeControl wtc ON wtc.timed = sub.timed AND wtc.userFk = sub.userFk + JOIN tmp.workerTimeControl wtc ON wtc.timed = sub.timed + AND wtc.userFk = sub.userFk WHERE wtc.direction <> 'out'; INSERT INTO tmp.workerTimeControlAux (id, userFk, timed, direction) @@ -72117,7 +73676,8 @@ BEGIN AND tce.id IS NULL GROUP BY wtc.userFk, DATE(wtc.timed) ) sub - JOIN tmp.workerTimeControl wtc ON wtc.timed = sub.timed AND wtc.userFk = sub.userFk + JOIN tmp.workerTimeControl wtc ON wtc.timed = sub.timed + AND wtc.userFk = sub.userFk WHERE wtc.direction <> 'out'; INSERT INTO tmp.workerTimeControl (id, userFk, timed, direction, isReal) @@ -72127,24 +73687,34 @@ BEGIN SET @vIsOdd := TRUE; SET @vDated := 0; SET @vLastTimed := 0; + SET @vPreviousTimed := 0; DROP TEMPORARY TABLE IF EXISTS tmp.workerBreakDays; CREATE TEMPORARY TABLE tmp.workerBreakDays (INDEX (userFk), INDEX (dated)) ENGINE = MEMORY - SELECT sub.userFk, sub.dated + SELECT sub.userFk, + sub.dated, + SUM(isSplitDay) isSplitDay FROM (SELECT (@vIsOdd := NOT @vIsOdd), IF(wtc.direction = 'in', @vIsOdd := TRUE, NULL), + IF(@vIsOdd AND direction <> 'in' + AND UNIX_TIMESTAMP(wtc.timed) - @previousTimed > vBreakTimeSplitDay, + TRUE, + FALSE + ) isSplitDay, IF(@vIsOdd, @vLastTimed := UNIX_TIMESTAMP(wtc.timed), NULL), IF(@vIsOdd, 0, UNIX_TIMESTAMP(wtc.timed) - @vLastTimed) timeWork, IF(direction='in', @vDated := DATE(wtc.timed), @vDated) dated, + @previousTimed := UNIX_TIMESTAMP(wtc.timed), wtc.userFk FROM tmp.workerTimeControl wtc ORDER BY wtc.userFk, wtc.timed, wtc.id LIMIT 10000000000000000000 )sub GROUP BY sub.userFk, sub.dated - HAVING SUM(sub.timeWork) >= vTimeToBreakTime; + HAVING SUM(sub.timeWork) >= vTimeToBreakTime + AND (NOT isSplitDay OR dated < vDateSplitDay); SET @vIsOdd := TRUE; SET @vDated := 0; @@ -72166,7 +73736,8 @@ BEGIN IF(wb.userFk, vBreakTime, 0) + SUM(sub.timeWork) timeWorkSeconds, SEC_TO_TIME(IF(wb.userFk, vBreakTime, 0) + SUM(sub.timeWork)) timeWorkSexagesimal, (IF(wb.userFk, vBreakTime, 0) + SUM(sub.timeWork)) / vHourToSeconds timeWorkDecimal, - CAST(GROUP_CONCAT(DATE_FORMAT(sub.realTimed, "%H:%i") ORDER BY sub.timed ASC SEPARATOR ' - ') AS CHAR(256)) timed + CAST(GROUP_CONCAT(DATE_FORMAT(sub.realTimed, "%H:%i") + ORDER BY sub.timed ASC SEPARATOR ' - ') AS CHAR(256)) timed FROM (SELECT (@vIsOdd := NOT @vIsOdd), IF(direction='in', @vIsOdd := TRUE, 0), IF(@vIsOdd, @vLastTimed := UNIX_TIMESTAMP(timed), 0), @@ -72475,7 +74046,54 @@ BEGIN AND t.status = 'ok' AND t.created < DATE_ADD(util.VN_NOW(),INTERVAL - 2 DAY) GROUP BY t.clientFk; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `travelLog_add` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `travelLog_add`( + vChangedModel VARCHAR(45), + vOriginFk INT, + vChangedModelId INT, + vActionCode VARCHAR(45), + vChangedModelValue VARCHAR(255), + vOldInstance JSON, + vNewInstance JSON) +BEGIN +/** + * Guarda las acciones realizadas por el usuario + * + * @param vChangedModel Nombre que hace referencia a la tabla que se modifica + * @param vOriginFk Id del registro de la tabla origen + * @param vChangedModelId Id del registro de la tabla a la que se realiza la acción + * @param vActionCode Código de la acción {insert | delete | update} + * @param vOldInstance JSON que contiene los valores viejos + * @param vNewInstance JSON que contiene los valores nuevos + */ + CALL util.log_cleanInstances(vActionCode, vOldInstance, vNewInstance); + IF !(vOldInstance = '{}' AND vNewInstance = '{}') THEN + INSERT INTO travelLog SET + changedModel = vChangedModel, + originFk = vOriginFk, + changedModelId = vChangedModelId, + `action` = vActionCode, + changedModelValue = vChangedModelValue, + oldInstance = vOldInstance, + newInstance = vNewInstance, + userFk = account.myUser_getId(); + END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -72585,6 +74203,49 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `travel_checkPackaging` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_checkPackaging`(vSelf INT) +BEGIN + DECLARE vDone BOOL; + DECLARE vEntryFk INT; + + DECLARE cTravelEntries CURSOR FOR + SELECT id + FROM entry + WHERE entry.travelFk = vSelf; + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + OPEN cTravelEntries; + + l: LOOP + SET vDone = FALSE; + FETCH cTravelEntries INTO vEntryFk; + + IF vDone THEN + LEAVE l; + END IF; + + CALL entry_checkPackaging(vEntryFk); + END LOOP; + + CLOSE cTravelEntries; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `travel_clone` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -72621,7 +74282,8 @@ BEGIN warehouseOutFk, agencyModeFk, `ref`, - cargoSupplierFk) + cargoSupplierFk, + clonedFrom) SELECT shipped, shipmentHour, TIMESTAMPADD(DAY, vDays, landed), @@ -72630,7 +74292,8 @@ BEGIN warehouseOutFk, agencyModeFk, `ref`, - cargoSupplierFk + cargoSupplierFk, + vSelf FROM vn.travel WHERE id = vSelf; @@ -72696,13 +74359,12 @@ BEGIN START TRANSACTION; - INSERT INTO travel (shipped, landed, warehouseInFk, warehouseOutFk, agencyModeFk, `ref`, isDelivered, isReceived, m3, cargoSupplierFk, kg) - SELECT vDateStart, vDateEnd, vWarehouseInFk, vWarehouseOutFk, vAgencyModeFk, vRef, isDelivered, isReceived, m3,cargoSupplierFk, kg + INSERT INTO travel (shipped, landed, warehouseInFk, warehouseOutFk, agencyModeFk, `ref`, isDelivered, isReceived, m3, cargoSupplierFk, kg,clonedFrom) + SELECT vDateStart, vDateEnd, vWarehouseInFk, vWarehouseOutFk, vAgencyModeFk, vRef, isDelivered, isReceived, m3,cargoSupplierFk, kg,vTravelFk FROM travel WHERE id = vTravelFk; SET vNewTravelFk = LAST_INSERT_ID(); - CALL logAdd(vNewTravelFk, 'insert', 'travel', CONCAT('clona travel ',vTravelFk)); SET vDone = FALSE; SET @isModeInventory = TRUE; @@ -72792,6 +74454,37 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `travel_getEntriesMissingPackage` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_getEntriesMissingPackage`(vSelf INT) +BEGIN + DECLARE vpackageOrPackingNull INT; + DECLARE vTravelFk INT; + + SELECT travelfk INTO vTravelFk + FROM entry + WHERE id = vSelf; + + SELECT e.id entryFk + FROM travel t + JOIN entry e ON e.travelFk = t.id + JOIN buy b ON b.entryFk = e.id + WHERE t.id = vTravelFk + AND (b.packing IS NULL OR b.packageFk IS NULL); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `travel_moveRaids` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -72909,6 +74602,48 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `travel_updatePacking` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_updatePacking`(vItemFk INT, vPacking INT) +BEGIN +/** + * Actualiza packing para los movimientos de almacén de la subasta al almacén central + * + * @param vItemFk id del item + * @param vPacking nuevo packing + */ + + DECLARE vAuctionWarehouseFk INT; + DECLARE vMainWarehouseFk INT; + + SELECT warehouseFk INTO vAuctionWarehouseFk + FROM auctionConfig; + + SELECT mainWarehouseFk INTO vMainWarehouseFk + FROM config; + + UPDATE entry e + JOIN travel t ON t.id = e.travelFk + JOIN buy b on b.entryFk = e.id + SET b.packing = vPacking + WHERE t.shipped >= util.dayEnd(CURDATE()) + AND t.warehouseInFk = vMainWarehouseFk + AND t.warehouseOutFk = vAuctionWarehouseFk + AND b.itemFk = vItemFk; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `travel_weeklyClone` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -73349,7 +75084,7 @@ BEGIN SELECT IF(b.started < CONCAT(vYear,"-01-01"), CONCAT(vYear,"-01-01"),b.started), IF(b.ended IS NULL OR YEAR(b.ended)>vYear , CONCAT(vYear,"-12-31"), b.ended), IF(wbt.hasHolidayEntitlement, w.days, 0), - c.hours_week, + c.hoursWeek, IF(YEAR(b.ended) = vYear, b.payedHolidays, 0) payedHolidays INTO vStarted, vEnded, @@ -73359,7 +75094,7 @@ BEGIN FROM business b JOIN workerBusinessType wbt ON wbt.id = b.workerBusinessTypeFk JOIN workCenterHoliday w ON w.workcenterFk = b.workcenterFk - LEFT JOIN postgresql.calendar_labour_type c ON c.calendar_labour_type_id = b.calendarTypeFk + LEFT JOIN calendarType c ON c.id = b.calendarTypeFk WHERE b.id = vBusinessFk AND w.year = vYear; @@ -73368,14 +75103,16 @@ BEGIN IF vStarted < vEnded THEN SET vDifDays = DAYOFYEAR(vEnded) - DAYOFYEAR(vStarted) + 1; - SELECT IFNULL(SUM(holidayEntitlementRate), 0), - SUM(-(discountRate - 1)) + vPayedHolidays + SELECT IFNULL(SUM(a.holidayEntitlementRate), 0), + SUM(-(a.discountRate - 1)) + vPayedHolidays INTO vDaysToSubtract, vDaysHolidayEnjoyed - FROM workerCalendar w - JOIN absenceType a ON a.id = w.absenceTypeFk - WHERE w.businessFk = vBusinessFk - AND YEAR(dated) = vYear; + FROM calendar c + JOIN absenceType a ON a.id = c.dayOffTypeFk + JOIN business b ON b.id = c.businessFk + WHERE b.id = vBusinessFk + AND YEAR(c.dated) = vYear; + END IF; CREATE TEMPORARY TABLE tmp.workerCalendarCalculateBusiness @@ -73514,12 +75251,11 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `workerCreateExternal`( vRole INT(2) ) BEGIN - DECLARE vUserId INT; DECLARE vSurnames VARCHAR(100); - INSERT INTO account.user(name, password, role) - SELECT vUser, MD5(vPassword), vRole; + INSERT INTO account.`user`(name, nickname, password, `role`, hasGrant) + SELECT vUser, vUser, MD5(vPassword), vRole, false; SET vUserId = LAST_INSERT_ID(); @@ -73529,8 +75265,8 @@ BEGIN SET vSurnames = CONCAT(vSurname1, ' ', vSurname2); END IF; - INSERT INTO worker(firstName, lastName, code, userFk, isFreelance) - SELECT vFirstName, vSurnames, vWorkerCode, vUserId, TRUE; + INSERT INTO worker(id, firstName, lastName, code, userFk, isFreelance) + SELECT vUserId, vFirstName, vSurnames, vWorkerCode, vUserId, true; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -73560,10 +75296,10 @@ BEGIN d.id departmentFk, b.started, d.isProduction, - CAST(12 * b.amount / clt.hours_week / 52 AS DECIMAL(10,2)) costeHora, + CAST(12 * b.amount / ct.hoursWeek / 52 AS DECIMAL(10,2)) costeHora, w.fi nif FROM business b - JOIN postgresql.calendar_labour_type clt ON clt.calendar_labour_type_id = b.calendarTypeFk + JOIN calendarType ct ON ct.id = b.calendarTypeFk JOIN department d ON d.id = b.departmentFk JOIN worker w ON w.id = b.workerFk WHERE b.started <= vDate @@ -73578,11 +75314,11 @@ 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 = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerDisable`(vUserId int) mainLabel:BEGIN @@ -73938,12 +75674,11 @@ BEGIN -- Horas téoricas y precio de la hora ordinaria UPDATE workerJourney wj JOIN business b ON b.id = wj.businessFk - JOIN postgresql.calendar_labour_type cl - ON cl.calendar_labour_type_id = b.calendarTypeFk + JOIN calendarType ct ON ct.id = b.calendarTypeFk SET wj.priceOrdinaryHour = (vMonthsByYear * b.amount) / - (vWeeksByYear * cl.hours_week), - wj.contractJourney = cl.hours_week / vDaysByWeek + (vWeeksByYear * ct.hoursWeek), + wj.contractJourney = ct.hoursWeek / vDaysByWeek WHERE wj.dated BETWEEN vDatedFrom AND vDatedTo AND (vWorkerFk IS NULL OR wj.userFk = vWorkerFk) AND NOT wj.isPaid @@ -73968,10 +75703,9 @@ BEGIN -- Elimina el precio de las horas extras para los contratos parciales. UPDATE workerJourney wj JOIN business b ON b.id = wj.businessFk - JOIN postgresql.calendar_labour_type cl - ON cl.calendar_labour_type_id = b.calendarTypeFk + JOIN calendarType ct ON ct.id = b.calendarTypeFk SET wj.priceExtraHour = 0 - WHERE cl.isPartial + WHERE ct.isPartial AND wj.dated BETWEEN vDatedFrom AND vDatedTo AND (vWorkerFk IS NULL OR wj.userFk = vWorkerFk) AND NOT wj.isPaid @@ -74032,6 +75766,52 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `workerLog_add` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `workerLog_add`( + vChangedModel VARCHAR(45), + vOriginFk INT, + vChangedModelId INT, + vActionCode VARCHAR(45), + vOldInstance JSON, + vNewInstance JSON) +BEGIN +/** + * Guarda las acciones realizadas por el usuario + * + * @param vChangedModel Nombre que hace referencia a la tabla que se modifica + * @param vOriginFk Id del registro de la tabla origen + * @param vChangedModelId Id del registro de la tabla a la que se realiza la acción + * @param vActionCode Código de la acción {insert | delete | update} + * @param vOldInstance JSON que contiene los valores viejos + * @param vNewInstance JSON que contiene los valores nuevos + */ + CALL util.log_cleanInstances(vActionCode, vOldInstance, vNewInstance); + + IF !(vOldInstance = '{}' AND vNewInstance = '{}') THEN + INSERT INTO workerLog SET + changedModel = vChangedModel, + originFk = vOriginFk, + changedModelId = vChangedModelId, + `action` = vActionCode, + oldInstance = vOldInstance, + newInstance = vNewInstance, + userFk = account.myUser_getId(); + END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerMistakeType_get` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -74081,88 +75861,6 @@ BEGIN INSERT INTO vn.workerMistake(userFk, workerMistakeTypeFk) VALUES(vWorkerFk, vWorkerMistakeTypeFk); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `workerShelving_Add` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerShelving_Add`(vWorkerFk INT, vBarcode VARCHAR(12)) -BEGIN -/* - * Inserta en workerShelving asociando los carros al trabajador - * @Param vWorkerFk es id del trabajador - * @Param vBarcode se puede pasar tanto el smarttag como el shelving - */ - DECLARE vIsShelvingFk BOOL; - - SELECT COUNT(*) > 0 INTO vIsShelvingFk - FROM vn.shelving s - WHERE s.code = vBarcode COLLATE utf8_general_ci; - - IF NOT vIsShelvingFk THEN - - SELECT st.shelvingFk INTO vBarcode - FROM vn.smartTag st - WHERE st.code = vBarcode COLLATE utf8_general_ci; - - END IF; - - INSERT INTO vn.workerShelving (workerFk, shelvingFk) - VALUES(vWorkerFk, vBarcode); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `workerShelving_delete` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerShelving_delete`(vWorkerFk INT, vBarcode VARCHAR(12)) -BEGIN -/* - * Borra de workerShelving el carro o etiqueta insertado por el trabajador - * @param vWorkerFk es id del trabajador - * @param vBarcode se puede pasar tanto el smarttag como el shelving - */ - DECLARE vIsShelvingFk BOOL; - - - SELECT COUNT(*) > 0 INTO vIsShelvingFk - FROM vn.shelving s - WHERE s.code = vBarcode COLLATE utf8_general_ci; - - - IF NOT vIsShelvingFk THEN - - SELECT st.shelvingFk INTO vBarcode - FROM vn.smartTag st - WHERE st.code = vBarcode COLLATE utf8_general_ci; - - END IF; - - DELETE FROM vn.workerShelving - WHERE shelvingFk = vBarcode COLLATE utf8_general_ci - AND workerFk = vWorkerFk ; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -74245,34 +75943,6 @@ BEGIN manual = manual + (0 * @day := day(timed)) ORDER BY userFk, timed; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControlSetOrder_by_User_and_dateRange` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControlSetOrder_by_User_and_dateRange`(vUserFk INT, vStarted DATE, vFinished DATE) -BEGIN - - SET @order := 0; - SET @day := '2000-01-01'; - - UPDATE vn.workerTimeControl w - SET w.`order` = @order := IF(@day = @day := date(timed), @order, 0) + 1 - WHERE w.userFk = vUserFk - AND w.timed BETWEEN vStarted AND util.dayend(vFinished) - ORDER BY w.timed; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -74740,7 +76410,7 @@ BEGIN /** * Verifica si el empleado puede fichar * @param vWorker Identificador del trabajador - * @param vTimed valor de la fichada, IF vTimed IS NULL vTimed = util.VN_NOW() + * @param vTimed valor de la fichada, IF vTimed IS NULL vTimed = NOW * @param vDirection solo se pueden pasa los valores del campo * workerTimeControl.direction ENUM('in', 'out', 'middle') * @return Si todo es correcto, retorna el número de id la tabla workerTimeControl. @@ -74842,7 +76512,7 @@ BEGIN SET vDated = DATE(vTimed); - SELECT IF(pc.category_name = 'Conductor +3500kg', + SELECT IF(pc.name = 'Conductor +3500kg', wc.dayBreakDriver, wc.dayBreak), wc.shortWeekBreak, @@ -74853,8 +76523,8 @@ BEGIN vLongWeekBreak, vWeekScope FROM business b - JOIN postgresql.professional_category pc - ON pc.professional_category_id = b.workerBusinessProfessionalCategoryFk + JOIN professionalCategory pc + ON pc.id = b.workerBusinessProfessionalCategoryFk JOIN workerTimeControlConfig wc ON TRUE WHERE b.workerFk = vWorker AND vDated BETWEEN b.started AND IFNULL(b.ended, vDated); @@ -75072,9 +76742,9 @@ DELIMITER ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_direction`(vWorkerFk VARCHAR(10), vTimed DATETIME) BEGIN @@ -75384,319 +77054,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_sendMail` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_sendMail`( - vWeek INT, - vYear INT, - vWorkerFk INT -) -BEGIN -/** - * Inserta en la tabla vn.mail para notificar a los empleados que teletrabajan de las jornadas que se han registrado. - * Inserta fichadas en el casos que se determina que el empleado está realizando teletrabajo - * - * @param vWeek - * @param vYear - * @param vWorkerFk -> En el caso de querer generarlo para todos los empleados deberá de informarse como NULL - */ - DECLARE vStarted VARCHAR(25); - DECLARE vEnded VARCHAR(25); - DECLARE vDone BOOL; - DECLARE vReceiver VARCHAR(255); - DECLARE vReceiverOld VARCHAR(255); - DECLARE vDated DATE; - DECLARE vTimeWorkDecimal DECIMAL(5,2); - DECLARE vTimeWorkSexagesimal VARCHAR(5); - DECLARE vTimeWorkedDecimal DECIMAL(5,2); - DECLARE vTimeWorkedSexagesimal VARCHAR(5); - DECLARE vTimeWorkDecimalTotal DECIMAL(5,2); - DECLARE vTimeTable VARCHAR(100); - DECLARE vTimeTableDecimal DECIMAL(5,2); - DECLARE vWorkerFkOld INTEGER; - DECLARE vBusinessFk INTEGER; - DECLARE vHeader TEXT; - DECLARE vBody TEXT; - DECLARE vFooter TEXT; - DECLARE vReturn INTEGER; - DECLARE vAbsenceType VARCHAR(50); - DECLARE vWorkerInfo VARCHAR(90); - DECLARE vPermissionRate DECIMAL(5,2); - DECLARE vIsTeleworking BOOL; - DECLARE vIsTeleworkingOld BOOL; - DECLARE vError BOOL DEFAULT FALSE; - - DECLARE vCursor CURSOR FOR - SELECT CONCAT(u.name, '@verdnatura.es'), - u.id, - tb.dated, - tb.timeWorkDecimal, - LEFT(tb.timeWorkSexagesimal,5) timeWorkSexagesimal, - tb.timeTable, - tc.timeWorkDecimal timeWorkedDecimal, - LEFT(tc.timeWorkSexagesimal,5) timeWorkedSexagesimal, - tb.type, - tb.businessFk, - tb.permissionRate, - d.isTeleworking - FROM tmp.timeBusinessCalculate tb - JOIN account.user u ON u.id = tb.userFk - JOIN department d ON d.id = tb.departmentFk - JOIN business b ON b.id = tb.businessFk - LEFT JOIN tmp.timeControlCalculate tc ON tc.userFk = tb.userFk AND tc.dated = tb.dated - LEFT JOIN worker w ON w.id = u.id - LEFT JOIN account.`user` u2 ON u2.id = w.bossFk - JOIN (SELECT tb.userFk, - SUM(IF(tb.type IS NULL, - IF(tc.timeWorkDecimal > 0, FALSE, IF(tb.timeWorkDecimal > 0, TRUE, FALSE)), - TRUE))isTeleworkingWeek - FROM tmp.timeBusinessCalculate tb - LEFT JOIN tmp.timeControlCalculate tc ON tc.userFk = tb.userFk AND tc.dated = tb.dated - GROUP BY tb.userFk - HAVING isTeleworkingWeek > 0 - )sub ON sub.userFk = u.id - WHERE d.hasToRefill - AND IFNULL(vWorkerFk, u.id) = u.id - AND b.companyCodeFk = 'VNL' - AND w.businessFk - ORDER BY u.id, tb.dated; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - DECLARE CONTINUE HANDLER FOR SQLEXCEPTION - BEGIN - SET vError = TRUE; - - INSERT INTO tmp.error(workerFk) - SELECT vWorkerFk; - END; - - DROP TABLE IF EXISTS tmp.timeControlCalculate; - DROP TABLE IF EXISTS tmp.timeBusinessCalculate; - DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate; - DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate; - DROP TEMPORARY TABLE IF EXISTS tmp.error; - - CREATE TEMPORARY TABLE tmp.error (workerFk INT); - - SELECT MIN(dated), util.dayEnd(MAX(dated)) INTO vStarted, vEnded - FROM time - WHERE period = CONCAT(vYear, LPAD(vWeek, 2, '0')); - - DELETE FROM workerTimeControl - WHERE IFNULL(vWorkerFk, userFk) = userFk AND - timed BETWEEN vStarted AND vEnded AND - isSendMail; - - UPDATE workerTimeControlMail - SET updated = util.VN_NOW(), state = 'SENDED' - WHERE year = vYear AND - week = vWeek AND - IFNULL(vWorkerFk, workerFk) = workerFk ; - - IF vWorkerFk IS NULL THEN - CALL timeControl_calculateAll(vStarted,vEnded); - CALL timeBusiness_calculateAll(vStarted,vEnded); - ELSE - CALL timeControl_calculateByUser(vWorkerFk,vStarted,vEnded); - CALL timeBusiness_calculateByUser(vWorkerFk,vStarted,vEnded); - END IF; - - SET vTimeWorkDecimalTotal = 0; - SET vBody= ''; - OPEN vCursor; - FETCH vCursor INTO vReceiver, vWorkerFk, vDated, vTimeWorkDecimal, vTimeWorkSexagesimal, vTimeTable, vTimeWorkedDecimal, vTimeWorkedSexagesimal, vAbsenceType, vBusinessFk, vPermissionRate, vIsTeleworking ; - SET vWorkerFkOld = vWorkerFk ; - SET vReceiverOld = vReceiver; - SET vIsTeleworkingOld = vIsTeleworking; -proc: LOOP - IF vDone THEN - LEAVE proc; - END IF; - - START TRANSACTION; - SET vError = FALSE; - - IF vTimeWorkDecimal>0 AND vTimeWorkedDecimal IS NULL AND IFNULL(vPermissionRate, TRUE) THEN - IF vTimeTable IS NULL THEN - INSERT INTO workerTimeControl (userFk, timed, manual, direction, isSendMail) - SELECT vWorkerFk, CONCAT(vDated,' 08:00'), TRUE, 'in', TRUE; - IF vTimeWorkDecimal >= 5 THEN - INSERT INTO workerTimeControl (userFk, timed, manual, direction, isSendMail) - SELECT vWorkerFk, CONCAT(vDated,' 09:00'), TRUE, 'middle', TRUE; - INSERT INTO workerTimeControl (userFk, timed, manual, direction, isSendMail) - SELECT vWorkerFk, CONCAT(vDated,' 09:20'), TRUE, 'middle', TRUE; - END IF; - INSERT INTO workerTimeControl (userFk, timed, manual, direction, isSendMail) - SELECT vWorkerFk,CONCAT(vDated,' ', LEFT (SEC_TO_TIME(28800 + (vTimeWorkDecimal * 3600)), 5)), TRUE, 'out', TRUE; - ELSE - SELECT SUM(TIME_TO_SEC(j.end)-TIME_TO_SEC(j.start))/3600 INTO vTimeTableDecimal - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND - j.day_id = WEEKDAY(vDated)+1; - IF vTimeWorkDecimal = vTimeTableDecimal THEN - INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) - SELECT vWorkerFk, CONCAT(vDated, ' ', j.start), TRUE, TRUE - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND - j.day_id = WEEKDAY(vDated)+1; - - INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) - SELECT vWorkerFk, CONCAT(vDated, ' ', j.end), TRUE, TRUE - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND - j.day_id = WEEKDAY(vDated)+1; - ELSE - INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) - SELECT vWorkerFk, CONCAT(vDated, ' ', MIN(j.start)), TRUE, TRUE - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND - j.day_id = WEEKDAY(vDated)+1; - INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) - SELECT vWorkerFk, CONCAT(vDated, ' ', SEC_TO_TIME(TIME_TO_SEC(MIN(j.start)) + (vTimeWorkDecimal * 3600))), TRUE, TRUE - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND - j.day_id = WEEKDAY(vDated)+1; - END IF; - - IF vTimeWorkDecimal >= 5 THEN - INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) - SELECT vWorkerFk, CONCAT(vDated, ' ', SEC_TO_TIME(TIME_TO_SEC(MIN(j.start)) + 3600)), TRUE, TRUE - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND - j.day_id = WEEKDAY(vDated)+1; - INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) - SELECT vWorkerFk, CONCAT(vDated, ' ', SEC_TO_TIME(TIME_TO_SEC(MIN(j.start)) + 4800)), TRUE, TRUE - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND - j.day_id = WEEKDAY(vDated)+1; - END IF; - - UPDATE workerTimeControl wtc - JOIN (SELECT id FROM workerTimeControl - WHERE userFk = vWorkerFk AND - timed BETWEEN vDated AND CONCAT(vDated, ' 23:59:59') - ORDER BY timed ASC - LIMIT 1)sub on sub.id= wtc.id - SET direction = 'in' ; - - UPDATE workerTimeControl wtc - JOIN (SELECT id FROM workerTimeControl - WHERE userFk = vWorkerFk AND - timed BETWEEN vDated AND CONCAT(vDated, ' 23:59:59') - ORDER BY timed DESC - LIMIT 1)sub on sub.id= wtc.id - SET direction = 'out' ; - - END IF; - END IF; - - SELECT CONCAT(IFNULL(vBody,""), " - ", DATE_FORMAT(vDated, "%d/%m/%Y"), " - ", CASE WEEKDAY(vDated)+1 - WHEN 1 THEN 'Lunes' - WHEN 2 THEN 'Martes' - WHEN 3 THEN 'Miércoles' - WHEN 4 THEN 'Jueves' - WHEN 5 THEN 'Viernes' - WHEN 6 THEN 'Sábado' - WHEN 7 THEN 'Domingo' - END , " - ", IFNULL(GROUP_CONCAT(MID(timed, 12, 5) ORDER BY timed ASC SEPARATOR ' - '), " - ")," - ", IFNULL(vAbsenceType, IF (vTimeWorkedDecimal>0, "Presencial", IF(vTimeWorkDecimal>0, "Teletrabajo", " - "))), " - ", IFNULL(vTimeWorkedSexagesimal,IF(IFNULL(vPermissionRate, TRUE), vTimeWorkDecimal, 0)), " - ") INTO vBody - FROM workerTimeControl - WHERE userFk = vWorkerFk AND - timed BETWEEN vDated AND CONCAT(vDated," 23:59:59"); - SET vTimeWorkDecimalTotal = vTimeWorkDecimalTotal + IFNULL(vTimeWorkedDecimal, IF( IFNULL(vPermissionRate, TRUE), vTimeWorkDecimal, 0)); - SET vDone = FALSE; - FETCH vCursor INTO vReceiver, vWorkerFk, vDated, vTimeWorkDecimal, vTimeWorkSexagesimal, vTimeTable, vTimeWorkedDecimal, vTimeWorkedSexagesimal, vAbsenceType, vBusinessFk, vPermissionRate, vIsTeleworking; - - IF vWorkerFk <> vWorkerFkOld OR vDone THEN - SELECT CONCAT_WS(' ', fi, firstName, lastName) INTO vWorkerInfo - FROM worker - WHERE id = vWorkerFkOld; - - SET vHeader = CONCAT("


-
-

", vWorkerInfo , "

- - - - - - - - - - - - "); - - SET vFooter = CONCAT(" - - - - -
- Según la información recogida en el sistema adjuntamos la tabla con los registros de las horas trabajadas en el período indicado. - Si está conforme tiene que contestar indicando únicamente la palabra OK, en caso contrario puede contestar detallando la causa de la disconformidad. - Rogamos nos conteste lo antes posible. -

-
FechaDíaFichadasDescripciónHoras
TOTAL", IFNULL(LEFT (SEC_TO_TIME(vTimeWorkDecimalTotal * 3600), 5), 0), "
-
"); - - IF vIsTeleworkingOld AND NOT vError THEN - CALL mail_insert( - vReceiverOld, - 'timecontrol@verdnatura.es', - CONCAT('Registro de horas semana ', vWeek, ' año ', vYear) , - CONCAT(vHeader, ' ' , vBody, ' ', vFooter) - ); - - INSERT IGNORE INTO workerTimeControlMail (workerFk, year, week) - VALUES(vWorkerFkOld, vYear, vWeek); - ELSE - ROLLBACK; - END IF; - - SET vBody = ''; - SET vTimeWorkDecimalTotal = 0; - SET vWorkerFkOld = vWorkerFk; - SET vIsTeleworkingOld = vIsTeleworking; - SET vReceiverOld = vReceiver; - END IF; - COMMIT; - END LOOP; - CLOSE vCursor; - - INSERT INTO mail (receiver, replyTo, subject, body) - SELECT CONCAT(u.name, '@verdnatura.es'), - CONCAT('Error registro de horas semana ', vWeek, ' año ', vYear) , - CONCAT('No se ha podido enviar el registro de horas al empleado/s: ', GROUP_CONCAT(DISTINCT CONCAT('
', w.id, ' ', w.firstName, ' ', w.lastName))) - FROM tmp.error e - JOIN worker w ON w.id = e.workerFk - JOIN account.user u ON u.id = w.bossFk - GROUP BY w.bossFk; - - DROP TABLE tmp.timeControlCalculate; - DROP TABLE tmp.timeBusinessCalculate; - DROP TABLE tmp.error; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_sendMailByDepartment` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -76081,110 +77438,6 @@ BEGIN SELECT 'El fichador no pertenece a tu departamento.' as Item, '' as Cantidad, IF(isEnabled, 'Correcto','Error') as Análisis; END IF; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `workerWeekTiming` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerWeekTiming`(vUserFk INT, vDated DATE) -BEGIN - -/* -* Muestra una tabla con los 7 dias inmediatamente anteriores a la fecha proporcionada -* y las fichadas de cada dia, en columnas por dia -* -*/ - -CALL vn.workerTimeControlSetOrder_by_User_and_dateRange(vUserFk,TIMESTAMPADD(DAY,-8,vDated),vDated); - -DROP TEMPORARY TABLE IF EXISTS tmp.workerWeekTiming; -CREATE TEMPORARY TABLE tmp.workerWeekTiming -SELECT orden `orden`, - max(hace7dias) 7_dias_antes, - max(hace6dias) 6_dias_antes, - max(hace5dias) 5_dias_antes, - max(hace4dias) 4_dias_antes, - max(hace3dias) 3_dias_antes, - max(antesdeayer) 2_dias_antes, - max(ayer) 1_dia_antes, - max(hoy) mismo_dia - FROM - ( - SELECT IF(dias = 7, fichada, '') as hace7dias, - IF(dias = 6, fichada, '') as hace6dias, - IF(dias = 5, fichada, '') as hace5dias, - IF(dias = 4, fichada, '') as hace4dias, - IF(dias = 3, fichada, '') as hace3dias, - IF(dias = 2, fichada, '') as antesdeayer, - IF(dias = 1, fichada, '') as ayer, - IF(dias = 0, fichada, '') as hoy, - orden - - FROM - ( - SELECT `order` as orden, datediff(vDated, timed) as dias, date(timed) as fecha, TIME_FORMAT(timed,'%H:%i') as fichada - FROM vn.workerTimeControl wtc - WHERE userFk = vUserFk - AND timed >= TIMESTAMPADD(DAY, -7, vDated) - ) sub - )sub2 - GROUP BY orden - ; - -DROP TEMPORARY TABLE IF EXISTS tmp.workerWeekTiming_Aux; -CREATE TEMPORARY TABLE tmp.workerWeekTiming_Aux - SELECT * FROM tmp.workerWeekTiming; - -INSERT INTO tmp.workerWeekTiming( 7_dias_antes,6_dias_antes,5_dias_antes,4_dias_antes,3_dias_antes,2_dias_antes,1_dia_antes,mismo_dia) - VALUES('total','','','','','','',''); - -INSERT INTO tmp.workerWeekTiming( orden, 7_dias_antes,6_dias_antes,5_dias_antes,4_dias_antes,3_dias_antes,2_dias_antes,1_dia_antes, mismo_dia) -SELECT 0, - IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(7_dias_antes), TIME_TO_SEC(7_dias_antes)))),'%H:%i'),''), - IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(6_dias_antes), TIME_TO_SEC(6_dias_antes)))),'%H:%i'),''), - IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(5_dias_antes), TIME_TO_SEC(5_dias_antes)))),'%H:%i'),''), - IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(4_dias_antes), TIME_TO_SEC(4_dias_antes)))),'%H:%i'),''), - IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(3_dias_antes), TIME_TO_SEC(3_dias_antes)))),'%H:%i'),''), - IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(2_dias_antes), TIME_TO_SEC(2_dias_antes)))),'%H:%i'),''), - IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(1_dia_antes), TIME_TO_SEC(1_dia_antes)))),'%H:%i'),''), - '' - FROM tmp.workerWeekTiming_Aux; - -INSERT INTO tmp.workerWeekTiming_Aux( orden, 1_dia_antes) -SELECT 0, ROUND(( - IFNULL(TIME_TO_SEC(7_dias_antes),0) + - IFNULL(TIME_TO_SEC(6_dias_antes),0) + - IFNULL(TIME_TO_SEC(5_dias_antes),0) + - IFNULL(TIME_TO_SEC(4_dias_antes),0) + - IFNULL(TIME_TO_SEC(3_dias_antes),0) + - IFNULL(TIME_TO_SEC(2_dias_antes),0) + - IFNULL(TIME_TO_SEC(1_dia_antes),0) - ) / 3600,1) - FROM tmp.workerWeekTiming - WHERE orden = 0; - - -INSERT INTO tmp.workerWeekTiming( 7_dias_antes,6_dias_antes,5_dias_antes,4_dias_antes,3_dias_antes,2_dias_antes,1_dia_antes,mismo_dia) - SELECT '','','','','','',1_dia_antes,'' - FROM tmp.workerWeekTiming_Aux - WHERE orden = 0; - -SELECT 7_dias_antes,6_dias_antes,5_dias_antes,4_dias_antes,3_dias_antes,2_dias_antes,1_dia_antes,mismo_dia FROM tmp.workerWeekTiming; - -DROP TEMPORARY TABLE tmp.workerWeekTiming; -DROP TEMPORARY TABLE tmp.workerWeekTiming_Aux; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -76382,11 +77635,11 @@ BEGIN DECLARE vWorkerFk INT; DECLARE vDone BOOL; - DECLARE vCursor CURSOR FOR - SELECT DISTINCT b.workerFk - FROM business b - WHERE b.started > vBusinessUpdated AND b.started <= vCurdate - OR b.ended >= vBusinessUpdated AND b.ended < vCurdate; + DECLARE vCursor CURSOR FOR + SELECT DISTINCT b.workerFk + FROM business b + WHERE b.started > vBusinessUpdated AND b.started <= vCurdate + OR b.ended >= vBusinessUpdated AND b.ended < vCurdate; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; @@ -78231,7 +79484,7 @@ USE `bs`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `bajasLaborales` AS select `w`.`firstName` AS `firstname`,`w`.`lastName` AS `name`,`b`.`id` AS `businessFk`,max(`ce`.`date`) AS `lastDate`,max(ifnull(`b`.`ended`,util.VN_CURDATE())) AS `endContract`,`at`.`name` AS `type`,cast(count(0) as decimal(10,0)) AS `dias`,`w`.`id` AS `userFk` from (((`postgresql`.`calendar_employee` `ce` join `vn`.`business` `b` on(`b`.`id` = `ce`.`businessFk`)) join `vn`.`worker` `w` on(`w`.`id` = `b`.`workerFk`)) join `vn`.`absenceType` `at` on(`at`.`id` = `ce`.`calendar_state_id`)) where `ce`.`date` >= util.VN_CURDATE() + interval -1 year and `at`.`name` not in ('Vacaciones','Vacaciones 1/2 día','Compensar','Festivo') group by `w`.`id`,`at`.`id` having `endContract` >= util.VN_CURDATE() */; +/*!50001 VIEW `bajasLaborales` AS select `w`.`firstName` AS `firstname`,`w`.`lastName` AS `name`,`b`.`id` AS `businessFk`,max(`c`.`dated`) AS `lastDate`,max(ifnull(`b`.`ended`,`util`.`VN_CURDATE`())) AS `endContract`,`at`.`name` AS `type`,cast(count(0) as decimal(10,0)) AS `dias`,`w`.`id` AS `userFk` from (((`vn`.`calendar` `c` join `vn`.`business` `b` on(`b`.`id` = `c`.`businessFk`)) join `vn`.`worker` `w` on(`w`.`id` = `b`.`workerFk`)) join `vn`.`absenceType` `at` on(`at`.`id` = `c`.`dayOffTypeFk`)) where `c`.`dated` >= `util`.`VN_CURDATE`() + interval -1 year and `at`.`name` not in ('Vacaciones','Vacaciones 1/2 día','Compensar','Festivo') group by `w`.`id`,`at`.`id` having `endContract` >= `util`.`VN_CURDATE`() */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78269,7 +79522,7 @@ USE `bs`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `packingSpeed` AS select hour(`e`.`created`) AS `hora`,minute(`e`.`created`) AS `minuto`,ifnull(`p`.`volume`,`p`.`width` * `p`.`height` * `p`.`depth`) AS `cm3`,`t`.`warehouseFk` AS `warehouse_id`,`e`.`created` AS `odbc_date` from ((`vn`.`expedition` `e` join `vn`.`packaging` `p` on(`p`.`id` = `e`.`packagingFk`)) join `vn`.`ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) where `e`.`created` between util.VN_CURDATE() and `util`.`dayend`(util.VN_CURDATE()) */; +/*!50001 VIEW `packingSpeed` AS select hour(`e`.`created`) AS `hora`,minute(`e`.`created`) AS `minuto`,ifnull(`p`.`volume`,`p`.`width` * `p`.`height` * `p`.`depth`) AS `cm3`,`t`.`warehouseFk` AS `warehouse_id`,`e`.`created` AS `odbc_date` from ((`vn`.`expedition` `e` join `vn`.`packaging` `p` on(`p`.`id` = `e`.`packagingFk`)) join `vn`.`ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) where `e`.`created` between `util`.`VN_CURDATE`() and `util`.`dayend`(`util`.`VN_CURDATE`()) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78357,7 +79610,7 @@ USE `edi`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `ektRecent` AS select `e`.`id` AS `id`,`e`.`barcode` AS `barcode`,`e`.`entryYear` AS `entryYear`,`e`.`batchNumber` AS `batchNumber`,`e`.`deliveryNumber` AS `deliveryNumber`,`e`.`vendorOrderNumber` AS `vendorOrderNumber`,`e`.`fec` AS `fec`,`e`.`hor` AS `hor`,`e`.`util.VN_NOW` AS `util.VN_NOW`,`e`.`ptj` AS `ptj`,`e`.`ref` AS `ref`,`e`.`item` AS `item`,`e`.`pac` AS `pac`,`e`.`qty` AS `qty`,`e`.`ori` AS `ori`,`e`.`cat` AS `cat`,`e`.`agj` AS `agj`,`e`.`kop` AS `kop`,`e`.`ptd` AS `ptd`,`e`.`sub` AS `sub`,`e`.`pro` AS `pro`,`e`.`pri` AS `pri`,`e`.`package` AS `package`,`e`.`auction` AS `auction`,`e`.`klo` AS `klo`,`e`.`k1` AS `k1`,`e`.`k2` AS `k2`,`e`.`k3` AS `k3`,`e`.`k4` AS `k4`,`e`.`s1` AS `s1`,`e`.`s2` AS `s2`,`e`.`s3` AS `s3`,`e`.`s4` AS `s4`,`e`.`s5` AS `s5`,`e`.`s6` AS `s6`,`e`.`ok` AS `ok`,`e`.`trolleyFk` AS `trolleyFk`,`e`.`putOrderFk` AS `putOrderFk`,`e`.`scanned` AS `scanned`,`e`.`cps` AS `cps`,`e`.`dp` AS `dp`,`e`.`sender` AS `sender`,`ec`.`usefulAuctionLeftSegmentLength` AS `usefulAuctionLeftSegmentLength`,`ec`.`standardBarcodeLength` AS `standardBarcodeLength`,`ec`.`floridayBarcodeLength` AS `floridayBarcodeLength`,`ec`.`floramondoBarcodeLength` AS `floramondoBarcodeLength`,`ec`.`defaultKlo` AS `defaultKlo`,`ec`.`ektRecentScopeDays` AS `ektRecentScopeDays` from (`ekt` `e` join `ektConfig` `ec`) where `e`.`entryYear` = year(util.VN_CURDATE()) and `e`.`fec` >= util.VN_CURDATE() + interval -`ec`.`ektRecentScopeDays` day */; +/*!50001 VIEW `ektRecent` AS select `e`.`id` AS `id`,`e`.`barcode` AS `barcode`,`e`.`entryYear` AS `entryYear`,`e`.`batchNumber` AS `batchNumber`,`e`.`deliveryNumber` AS `deliveryNumber`,`e`.`vendorOrderNumber` AS `vendorOrderNumber`,`e`.`fec` AS `fec`,`e`.`hor` AS `hor`,`e`.`now` AS `now`,`e`.`ptj` AS `ptj`,`e`.`ref` AS `ref`,`e`.`item` AS `item`,`e`.`pac` AS `pac`,`e`.`qty` AS `qty`,`e`.`ori` AS `ori`,`e`.`cat` AS `cat`,`e`.`agj` AS `agj`,`e`.`kop` AS `kop`,`e`.`ptd` AS `ptd`,`e`.`sub` AS `sub`,`e`.`pro` AS `pro`,`e`.`pri` AS `pri`,`e`.`package` AS `package`,`e`.`auction` AS `auction`,`e`.`klo` AS `klo`,`e`.`k1` AS `k1`,`e`.`k2` AS `k2`,`e`.`k3` AS `k3`,`e`.`k4` AS `k4`,`e`.`s1` AS `s1`,`e`.`s2` AS `s2`,`e`.`s3` AS `s3`,`e`.`s4` AS `s4`,`e`.`s5` AS `s5`,`e`.`s6` AS `s6`,`e`.`ok` AS `ok`,`e`.`trolleyFk` AS `trolleyFk`,`e`.`putOrderFk` AS `putOrderFk`,`e`.`scanned` AS `scanned`,`e`.`cps` AS `cps`,`e`.`dp` AS `dp`,`e`.`sender` AS `sender`,`ec`.`usefulAuctionLeftSegmentLength` AS `usefulAuctionLeftSegmentLength`,`ec`.`standardBarcodeLength` AS `standardBarcodeLength`,`ec`.`floridayBarcodeLength` AS `floridayBarcodeLength`,`ec`.`floramondoBarcodeLength` AS `floramondoBarcodeLength`,`ec`.`defaultKlo` AS `defaultKlo`,`ec`.`ektRecentScopeDays` AS `ektRecentScopeDays` from (`ekt` `e` join `ektConfig` `ec`) where `e`.`entryYear` = year(`util`.`VN_CURDATE`()) and `e`.`fec` >= `util`.`VN_CURDATE`() + interval -`ec`.`ektRecentScopeDays` day */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78376,7 +79629,7 @@ USE `edi`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `errorList` AS select `po`.`id` AS `id`,`c`.`name` AS `name`,`i`.`longName` AS `longName`,`po`.`quantity` AS `quantity`,left(`po`.`error`,4) AS `stock`,`po`.`error` AS `error`,`po`.`deliveryInformationID` AS `deliveryInformationID`,`po`.`supplyResponseID` AS `supplyResponseID`,`po`.`OrderTradeLineDateTime` AS `OrderTradeLineDateTime`,`po`.`EndUserPartyGLN` AS `EndUserPartyGLN` from ((`edi`.`putOrder` `po` left join `vn`.`client` `c` on(`c`.`id` = `po`.`EndUserPartyGLN`)) left join `vn`.`item` `i` on(`i`.`supplyResponseFk` = `po`.`supplyResponseID`)) where `po`.`OrderTradeLineDateTime` > util.VN_CURDATE() + interval -12 hour and `po`.`OrderStatus` = 3 and left(`po`.`error`,4) <> '(0) ' */; +/*!50001 VIEW `errorList` AS select `po`.`id` AS `id`,`c`.`name` AS `name`,`i`.`longName` AS `longName`,`po`.`quantity` AS `quantity`,left(`po`.`error`,4) AS `stock`,`po`.`error` AS `error`,`po`.`deliveryInformationID` AS `deliveryInformationID`,`po`.`supplyResponseID` AS `supplyResponseID`,`po`.`OrderTradeLineDateTime` AS `OrderTradeLineDateTime`,`po`.`EndUserPartyGLN` AS `EndUserPartyGLN` from ((`edi`.`putOrder` `po` left join `vn`.`client` `c` on(`c`.`id` = `po`.`EndUserPartyGLN`)) left join `vn`.`item` `i` on(`i`.`supplyResponseFk` = `po`.`supplyResponseID`)) where `po`.`OrderTradeLineDateTime` > `util`.`VN_CURDATE`() + interval -12 hour and `po`.`OrderStatus` = 3 and left(`po`.`error`,4) <> '(0) ' */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78445,26 +79698,6 @@ USE `hedera`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `myBasket` --- - -/*!50001 DROP TABLE IF EXISTS `myBasket`*/; -/*!50001 DROP VIEW IF EXISTS `myBasket`*/; -/*!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 `myBasket` AS select `o`.`id` AS `id`,`o`.`date_make` AS `made`,`o`.`date_send` AS `sent`,`o`.`customer_id` AS `clientFk`,`o`.`delivery_method_id` AS `deliveryMethodFk`,`o`.`agency_id` AS `agencyModeFk`,`o`.`address_id` AS `addressFk`,`o`.`company_id` AS `companyFk`,`o`.`note` AS `notes` from `hedera`.`order` `o` where `o`.`id` = `MYBASKET_GETID`() */ -/*!50002 WITH CASCADED CHECK OPTION */; -/*!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 `myBasketDefaults` -- @@ -78484,26 +79717,6 @@ USE `hedera`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `myBasketItem` --- - -/*!50001 DROP TABLE IF EXISTS `myBasketItem`*/; -/*!50001 DROP VIEW IF EXISTS `myBasketItem`*/; -/*!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 `myBasketItem` AS select `r`.`id` AS `id`,`r`.`orderFk` AS `orderFk`,`r`.`warehouseFk` AS `warehouseFk`,`r`.`itemFk` AS `itemFk`,`r`.`amount` AS `amount`,`r`.`price` AS `price` from `hedera`.`orderRow` `r` where `r`.`orderFk` = `MYBASKET_GETID`() */ -/*!50002 WITH CASCADED CHECK OPTION */; -/*!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 `myClient` -- @@ -78576,7 +79789,8 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `myOrder` AS select `o`.`id` AS `id`,`o`.`date_send` AS `landed`,`o`.`customer_id` AS `clientFk`,`o`.`delivery_method_id` AS `deliveryMethodFk`,`o`.`agency_id` AS `agencyModeFk`,`o`.`address_id` AS `addressFk`,`o`.`company_id` AS `companyFk`,`o`.`note` AS `note`,`o`.`source_app` AS `sourceApp`,`o`.`confirmed` AS `isConfirmed`,`o`.`date_make` AS `created`,`o`.`first_row_stamp` AS `firstRowStamp`,`o`.`confirm_date` AS `confirmed` from `hedera`.`order` `o` where `o`.`customer_id` = `account`.`myUser_getId`() */; +/*!50001 VIEW `myOrder` AS select `o`.`id` AS `id`,`o`.`date_send` AS `sent`,`o`.`customer_id` AS `clientFk`,`o`.`delivery_method_id` AS `deliveryMethodFk`,`o`.`agency_id` AS `agencyModeFk`,`o`.`address_id` AS `addressFk`,`o`.`company_id` AS `companyFk`,`o`.`note` AS `notes`,`o`.`source_app` AS `sourceApp`,`o`.`confirmed` AS `isConfirmed`,`o`.`date_make` AS `created`,`o`.`first_row_stamp` AS `firstRowStamp`,`o`.`confirm_date` AS `confirmed`,`o`.`taxableBase` AS `taxableBase`,`o`.`tax` AS `tax`,`o`.`total` AS `total` from `hedera`.`order` `o` where `o`.`customer_id` = `account`.`myUser_getId`() and `o`.`source_app` = 'WEB' and `o`.`confirmed` = 0 */ +/*!50002 WITH CASCADED CHECK OPTION */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78595,7 +79809,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `myOrderRow` AS select `orw`.`id` AS `id`,`orw`.`order_id` AS `Fk`,`orw`.`item_id` AS `itemFk`,`orw`.`warehouse_id` AS `warehouseFk`,`orw`.`shipment` AS `shipped`,`orw`.`amount` AS `amount`,`orw`.`price` AS `price`,`orw`.`rate` AS `rate`,`orw`.`created` AS `created`,`orw`.`Id_Movimiento` AS `saleFk` from (`hedera`.`order_row` `orw` join `hedera`.`myOrder` `o` on(`o`.`id` = `orw`.`order_id`)) */ +/*!50001 VIEW `myOrderRow` AS select `orw`.`id` AS `id`,`orw`.`order_id` AS `orderFk`,`orw`.`item_id` AS `itemFk`,`orw`.`warehouse_id` AS `warehouseFk`,`orw`.`shipment` AS `shipped`,`orw`.`amount` AS `amount`,`orw`.`price` AS `price`,`orw`.`rate` AS `rate`,`orw`.`created` AS `created`,`orw`.`Id_Movimiento` AS `saleFk` from `hedera`.`order_row` `orw` where `orw`.`order_id` in (select `myOrder`.`id` from `hedera`.`myOrder`) */ /*!50002 WITH CASCADED CHECK OPTION */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -78900,25 +80114,6 @@ USE `pbx`; USE `postgresql`; --- --- Final view structure for view `calendar_employee` --- - -/*!50001 DROP TABLE IF EXISTS `calendar_employee`*/; -/*!50001 DROP VIEW IF EXISTS `calendar_employee`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8mb4 */; -/*!50001 SET character_set_results = utf8mb4 */; -/*!50001 SET collation_connection = utf8mb4_unicode_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `calendar_employee` AS select `ce`.`id` AS `id`,`ce`.`businessFk` AS `businessFk`,`ce`.`dayOffTypeFk` AS `calendar_state_id`,`ce`.`dated` AS `date` from `vn`.`calendar` `ce` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - -- -- Current Database: `sage` -- @@ -78939,7 +80134,7 @@ USE `sage`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `clientLastTwoMonths` AS select `vn`.`invoiceOut`.`clientFk` AS `clientFk`,`vn`.`invoiceOut`.`companyFk` AS `companyFk` from `vn`.`invoiceOut` where `vn`.`invoiceOut`.`issued` > util.VN_CURDATE() - interval 2 month union select `vn`.`receipt`.`clientFk` AS `clientFk`,`vn`.`receipt`.`companyFk` AS `companyFk` from `vn`.`receipt` where `vn`.`receipt`.`payed` > util.VN_CURDATE() - interval 2 month */; +/*!50001 VIEW `clientLastTwoMonths` AS select `vn`.`invoiceOut`.`clientFk` AS `clientFk`,`vn`.`invoiceOut`.`companyFk` AS `companyFk` from `vn`.`invoiceOut` where `vn`.`invoiceOut`.`issued` > `util`.`VN_CURDATE`() - interval 2 month union select `vn`.`receipt`.`clientFk` AS `clientFk`,`vn`.`receipt`.`companyFk` AS `companyFk` from `vn`.`receipt` where `vn`.`receipt`.`payed` > `util`.`VN_CURDATE`() - interval 2 month */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78958,7 +80153,7 @@ USE `sage`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `invoiceInList` AS select `vn`.`invoiceIn`.`id` AS `id`,`vn`.`invoiceIn`.`supplierRef` AS `supplierRef`,`vn`.`invoiceIn`.`serial` AS `serial`,`vn`.`invoiceIn`.`supplierFk` AS `supplierFk`,`vn`.`invoiceIn`.`issued` AS `issued`,if(`vn`.`invoiceIn`.`expenceFkDeductible` > 0,1,0) AS `isVatDeductible`,`vn`.`invoiceIn`.`serialNumber` AS `serialNumber` from `vn`.`invoiceIn` where `vn`.`invoiceIn`.`issued` >= date_format(util.VN_CURDATE(),'%Y-01-01') + interval -1 year union all select `vn`.`dua`.`id` AS `id`,`vn`.`dua`.`code` AS `code`,'D' AS `D`,`c`.`id` AS `supplierFk`,`vn`.`dua`.`issued` AS `issued`,0 AS `FALSE`,`vn`.`dua`.`id` AS `serialNumber` from (`vn`.`dua` join `vn`.`company` `c` on(`c`.`code` = 'VNL')) */; +/*!50001 VIEW `invoiceInList` AS select `vn`.`invoiceIn`.`id` AS `id`,`vn`.`invoiceIn`.`supplierRef` AS `supplierRef`,`vn`.`invoiceIn`.`serial` AS `serial`,`vn`.`invoiceIn`.`supplierFk` AS `supplierFk`,`vn`.`invoiceIn`.`issued` AS `issued`,if(`vn`.`invoiceIn`.`expenceFkDeductible` > 0,1,0) AS `isVatDeductible`,`vn`.`invoiceIn`.`serialNumber` AS `serialNumber` from `vn`.`invoiceIn` where `vn`.`invoiceIn`.`issued` >= date_format(`util`.`VN_CURDATE`(),'%Y-01-01') + interval -1 year union all select `vn`.`dua`.`id` AS `id`,`vn`.`dua`.`code` AS `code`,'D' AS `D`,`c`.`id` AS `supplierFk`,`vn`.`dua`.`issued` AS `issued`,0 AS `FALSE`,`vn`.`dua`.`id` AS `serialNumber` from (`vn`.`dua` join `vn`.`company` `c` on(`c`.`code` = 'VNL')) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78977,7 +80172,7 @@ USE `sage`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `supplierLastThreeMonths` AS select `vn`.`invoiceIn`.`supplierFk` AS `supplierFk`,`vn`.`invoiceIn`.`companyFk` AS `companyFk` from `vn`.`invoiceIn` where `vn`.`invoiceIn`.`issued` > util.VN_CURDATE() - interval 3 month union select `vn`.`payment`.`supplierFk` AS `supplierFk`,`vn`.`payment`.`companyFk` AS `companyFk` from `vn`.`payment` where `vn`.`payment`.`received` > util.VN_CURDATE() + interval -3 month */; +/*!50001 VIEW `supplierLastThreeMonths` AS select `vn`.`invoiceIn`.`supplierFk` AS `supplierFk`,`vn`.`invoiceIn`.`companyFk` AS `companyFk` from `vn`.`invoiceIn` where `vn`.`invoiceIn`.`issued` > `util`.`VN_CURDATE`() - interval 3 month union select `vn`.`payment`.`supplierFk` AS `supplierFk`,`vn`.`payment`.`companyFk` AS `companyFk` from `vn`.`payment` where `vn`.`payment`.`received` > `util`.`VN_CURDATE`() + interval -3 month */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79115,7 +80310,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `NewView` AS select `c`.`id` AS `clientFk`,max(`t`.`shipped`) AS `lastShipped`,`pc`.`notBuyingMonths` AS `notBuyingMonths` from ((`client` `c` join `productionConfig` `pc`) left join `ticket` `t` on(`c`.`id` = `t`.`clientFk` and `t`.`shipped` < util.VN_CURDATE() + interval -`pc`.`rookieDays` day)) group by `c`.`id` having `lastShipped` is null or `lastShipped` < util.VN_CURDATE() + interval -`notBuyingMonths` month */; +/*!50001 VIEW `NewView` AS select `c`.`id` AS `clientFk`,max(`t`.`shipped`) AS `lastShipped`,`pc`.`notBuyingMonths` AS `notBuyingMonths` from ((`client` `c` join `productionConfig` `pc`) left join `ticket` `t` on(`c`.`id` = `t`.`clientFk` and `t`.`shipped` < `util`.`VN_CURDATE`() + interval -`pc`.`rookieDays` day)) group by `c`.`id` having `lastShipped` is null or `lastShipped` < `util`.`VN_CURDATE`() + interval -`notBuyingMonths` month */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79191,7 +80386,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `awbVolume` AS select `d`.`awbFk` AS `awbFk`,`b`.`stickers` * `i`.`density` * if(`p`.`volume` > 0,`p`.`volume`,`p`.`width` * `p`.`depth` * if(`p`.`height` = 0,`i`.`size` + 10,`p`.`height`)) / (`vc`.`aerealVolumetricDensity` * 1000) AS `volume`,`b`.`id` AS `buyFk` from ((((((((`buy` `b` join `item` `i` on(`b`.`itemFk` = `i`.`id`)) join `itemType` `it` on(`i`.`typeFk` = `it`.`id`)) join `packaging` `p` on(`p`.`id` = `b`.`packageFk`)) join `entry` `e` on(`b`.`entryFk` = `e`.`id`)) join `travel` `t` on(`t`.`id` = `e`.`travelFk`)) join `duaEntry` `de` on(`de`.`entryFk` = `e`.`id`)) join `dua` `d` on(`d`.`id` = `de`.`duaFk`)) join `volumeConfig` `vc`) where `t`.`shipped` > makedate(year(util.VN_CURDATE()) - 1,1) */; +/*!50001 VIEW `awbVolume` AS select `d`.`awbFk` AS `awbFk`,`b`.`stickers` * `i`.`density` * if(`p`.`volume` > 0,`p`.`volume`,`p`.`width` * `p`.`depth` * if(`p`.`height` = 0,`i`.`size` + 10,`p`.`height`)) / (`vc`.`aerealVolumetricDensity` * 1000) AS `volume`,`b`.`id` AS `buyFk` from ((((((((`buy` `b` join `item` `i` on(`b`.`itemFk` = `i`.`id`)) join `itemType` `it` on(`i`.`typeFk` = `it`.`id`)) join `packaging` `p` on(`p`.`id` = `b`.`packageFk`)) join `entry` `e` on(`b`.`entryFk` = `e`.`id`)) join `travel` `t` on(`t`.`id` = `e`.`travelFk`)) join `duaEntry` `de` on(`de`.`entryFk` = `e`.`id`)) join `dua` `d` on(`d`.`id` = `de`.`duaFk`)) join `volumeConfig` `vc`) where `t`.`shipped` > makedate(year(`util`.`VN_CURDATE`()) - 1,1) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79248,7 +80443,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `businessCalendar` AS select `ce`.`id` AS `id`,`ce`.`businessFk` AS `businessFk`,`ce`.`calendar_state_id` AS `absenceTypeFk`,`ce`.`date` AS `dated` from `postgresql`.`calendar_employee` `ce` */; +/*!50001 VIEW `businessCalendar` AS select `c`.`id` AS `id`,`c`.`businessFk` AS `businessFk`,`c`.`dayOffTypeFk` AS `absenceTypeFk`,`c`.`dated` AS `dated` from `calendar` `c` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79305,7 +80500,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `clientLost` AS select `c`.`id` AS `clientFk`,max(`t`.`shipped`) AS `lastShipped`,`pc`.`notBuyingMonths` AS `notBuyingMonths` from ((`client` `c` join `productionConfig` `pc`) left join `ticket` `t` on(`c`.`id` = `t`.`clientFk` and `t`.`shipped` < util.VN_CURDATE() + interval -`pc`.`rookieDays` day)) group by `c`.`id` having `lastShipped` is null or `lastShipped` < util.VN_CURDATE() + interval -`notBuyingMonths` month */; +/*!50001 VIEW `clientLost` AS select `c`.`id` AS `clientFk`,max(`t`.`shipped`) AS `lastShipped`,`pc`.`notBuyingMonths` AS `notBuyingMonths` from ((`client` `c` join `productionConfig` `pc`) left join `ticket` `t` on(`c`.`id` = `t`.`clientFk` and `t`.`shipped` < `util`.`VN_CURDATE`() + interval -`pc`.`rookieDays` day)) group by `c`.`id` having `lastShipped` is null or `lastShipped` < `util`.`VN_CURDATE`() + interval -`notBuyingMonths` month */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79348,6 +80543,25 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `companyL10n` +-- + +/*!50001 DROP TABLE IF EXISTS `companyL10n`*/; +/*!50001 DROP VIEW IF EXISTS `companyL10n`*/; +/*!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 = utf8mb3 */; +/*!50001 SET character_set_results = utf8mb3 */; +/*!50001 SET collation_connection = utf8mb3_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `companyL10n` AS select `c`.`id` AS `id`,ifnull(`ci`.`footnotes`,`c`.`footnotes`) AS `footnotes` from (`company` `c` left join `companyI18n` `ci` on(`ci`.`companyFk` = `c`.`id` and `ci`.`lang` = `util`.`LANG`())) */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `defaulter` -- @@ -79457,7 +80671,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `exchangeInsuranceEntry` AS select max(`tr`.`landed`) AS `dated`,cast(sum((`b`.`buyingValue` + `b`.`freightValue`) * `b`.`quantity`) as decimal(10,2)) AS `Dolares`,cast(sum((`b`.`buyingValue` + `b`.`freightValue`) * `b`.`quantity`) / sum((100 + `e`.`commission`) / 100 * (`b`.`buyingValue` + `b`.`freightValue`) * `b`.`quantity`) as decimal(10,4)) AS `rate` from ((`entry` `e` join `buy` `b` on(`e`.`id` = `b`.`entryFk`)) join `travel` `tr` on(`tr`.`id` = `e`.`travelFk`)) where `tr`.`landed` between '2016-01-31' and util.VN_CURDATE() and `e`.`commission` < 0 and `e`.`currencyFk` = 2 group by month(`tr`.`landed`),year(`tr`.`landed`) */; +/*!50001 VIEW `exchangeInsuranceEntry` AS select max(`tr`.`landed`) AS `dated`,cast(sum((`b`.`buyingValue` + `b`.`freightValue`) * `b`.`quantity`) as decimal(10,2)) AS `Dolares`,cast(sum((`b`.`buyingValue` + `b`.`freightValue`) * `b`.`quantity`) / sum((100 + `e`.`commission`) / 100 * (`b`.`buyingValue` + `b`.`freightValue`) * `b`.`quantity`) as decimal(10,4)) AS `rate` from ((`entry` `e` join `buy` `b` on(`e`.`id` = `b`.`entryFk`)) join `travel` `tr` on(`tr`.`id` = `e`.`travelFk`)) where `tr`.`landed` between '2016-01-31' and `util`.`VN_CURDATE`() and `e`.`commission` < 0 and `e`.`currencyFk` = 2 group by month(`tr`.`landed`),year(`tr`.`landed`) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79533,7 +80747,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionCommon` AS select `et`.`id` AS `truckFk`,`et`.`ETD` AS `etd`,ifnull(ucase(`et`.`description`),'SIN ESCANEAR') AS `description`,`es`.`palletFk` AS `palletFk`,`t`.`routeFk` AS `routeFk`,`es`.`id` AS `scanFk`,`e`.`id` AS `expeditionFk`,`r`.`expeditionTruckFk` AS `expeditionTruckFk`,`t`.`warehouseFk` AS `warehouseFk`,`e`.`created` AS `lastPacked`,`t`.`id` AS `ticketFk` from (((((`expeditionTruck` `et` left join `routesMonitor` `r` on(`et`.`id` = `r`.`expeditionTruckFk`)) left join `ticket` `t` on(`r`.`routeFk` = `t`.`routeFk`)) left join `expedition` `e` on(`t`.`id` = `e`.`ticketFk`)) left join `expeditionScan` `es` on(`e`.`id` = `es`.`expeditionFk`)) left join `expeditionPallet` `ep` on(`es`.`palletFk` = `ep`.`id`)) where `et`.`ETD` >= util.VN_CURDATE() */; +/*!50001 VIEW `expeditionCommon` AS select `et`.`id` AS `truckFk`,`et`.`ETD` AS `etd`,ifnull(ucase(`et`.`description`),'SIN ESCANEAR') AS `description`,`es`.`palletFk` AS `palletFk`,`t`.`routeFk` AS `routeFk`,`es`.`id` AS `scanFk`,`e`.`id` AS `expeditionFk`,`r`.`expeditionTruckFk` AS `expeditionTruckFk`,`t`.`warehouseFk` AS `warehouseFk`,`e`.`created` AS `lastPacked`,`t`.`id` AS `ticketFk` from (((((`expeditionTruck` `et` left join `routesMonitor` `r` on(`et`.`id` = `r`.`expeditionTruckFk`)) left join `ticket` `t` on(`r`.`routeFk` = `t`.`routeFk`)) left join `expedition` `e` on(`t`.`id` = `e`.`ticketFk`)) left join `expeditionScan` `es` on(`e`.`id` = `es`.`expeditionFk`)) left join `expeditionPallet` `ep` on(`es`.`palletFk` = `ep`.`id`)) where `et`.`ETD` >= `util`.`VN_CURDATE`() */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79552,7 +80766,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionPallet_Print` AS select `et2`.`description` AS `truck`,`t`.`routeFk` AS `routeFk`,`r`.`description` AS `zone`,count(`es`.`id`) AS `eti`,`ep`.`id` AS `palletFk`,`et`.`id` <=> `rm`.`expeditionTruckFk` AS `isMatch`,`t`.`warehouseFk` AS `warehouseFk`,if(`r`.`created` > util.VN_CURDATE() + interval 1 day,ucase(dayname(`r`.`created`)),NULL) AS `nombreDia` from (((((((`vn`.`expeditionTruck` `et` join `vn`.`expeditionPallet` `ep` on(`ep`.`truckFk` = `et`.`id`)) join `vn`.`expeditionScan` `es` on(`es`.`palletFk` = `ep`.`id`)) join `vn`.`expedition` `e` on(`e`.`id` = `es`.`expeditionFk`)) join `vn`.`ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) join `vn`.`route` `r` on(`r`.`id` = `t`.`routeFk`)) left join `vn2008`.`Rutas_monitor` `rm` on(`rm`.`Id_Ruta` = `r`.`id`)) left join `vn`.`expeditionTruck` `et2` on(`et2`.`id` = `rm`.`expeditionTruckFk`)) group by `ep`.`id`,`t`.`routeFk` */; +/*!50001 VIEW `expeditionPallet_Print` AS select `et2`.`description` AS `truck`,`t`.`routeFk` AS `routeFk`,`r`.`description` AS `zone`,count(`es`.`id`) AS `eti`,`ep`.`id` AS `palletFk`,`et`.`id` <=> `rm`.`expeditionTruckFk` AS `isMatch`,`t`.`warehouseFk` AS `warehouseFk`,if(`r`.`created` > `util`.`VN_CURDATE`() + interval 1 day,ucase(dayname(`r`.`created`)),NULL) AS `nombreDia` from (((((((`vn`.`expeditionTruck` `et` join `vn`.`expeditionPallet` `ep` on(`ep`.`truckFk` = `et`.`id`)) join `vn`.`expeditionScan` `es` on(`es`.`palletFk` = `ep`.`id`)) join `vn`.`expedition` `e` on(`e`.`id` = `es`.`expeditionFk`)) join `vn`.`ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) join `vn`.`route` `r` on(`r`.`id` = `t`.`routeFk`)) left join `vn2008`.`Rutas_monitor` `rm` on(`rm`.`Id_Ruta` = `r`.`id`)) left join `vn`.`expeditionTruck` `et2` on(`et2`.`id` = `rm`.`expeditionTruckFk`)) 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 */; @@ -79647,7 +80861,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionTicket_NoBoxes` AS select `t`.`id` AS `ticketFk`,`t`.`warehouseFk` AS `warehouseFk`,`t`.`routeFk` AS `routeFk`,`et`.`description` AS `description` from (((`ticket` `t` left join `expedition` `e` on(`e`.`ticketFk` = `t`.`id`)) join `routesMonitor` `rm` on(`rm`.`routeFk` = `t`.`routeFk`)) join `expeditionTruck` `et` on(`et`.`id` = `rm`.`expeditionTruckFk`)) where `e`.`id` is null and `et`.`ETD` > util.VN_CURDATE() */; +/*!50001 VIEW `expeditionTicket_NoBoxes` AS select `t`.`id` AS `ticketFk`,`t`.`warehouseFk` AS `warehouseFk`,`t`.`routeFk` AS `routeFk`,`et`.`description` AS `description` from (((`ticket` `t` left join `expedition` `e` on(`e`.`ticketFk` = `t`.`id`)) join `routesMonitor` `rm` on(`rm`.`routeFk` = `t`.`routeFk`)) join `expeditionTruck` `et` on(`et`.`id` = `rm`.`expeditionTruckFk`)) where `e`.`id` is null and `et`.`ETD` > `util`.`VN_CURDATE`() */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79666,7 +80880,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionTimeExpended` AS select `e`.`ticketFk` AS `ticketFk`,min(`e`.`created`) AS `started`,max(`e`.`created`) AS `finished`,max(`e`.`counter`) AS `cajas`,`w`.`code` AS `code`,`t`.`warehouseFk` AS `warehouseFk` from ((`expedition` `e` join `worker` `w` on(`w`.`id` = `e`.`workerFk`)) join `ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) where `e`.`created` > util.VN_CURDATE() group by `e`.`ticketFk` */; +/*!50001 VIEW `expeditionTimeExpended` AS select `e`.`ticketFk` AS `ticketFk`,min(`e`.`created`) AS `started`,max(`e`.`created`) AS `finished`,max(`e`.`counter`) AS `cajas`,`w`.`code` AS `code`,`t`.`warehouseFk` AS `warehouseFk` from ((`expedition` `e` join `worker` `w` on(`w`.`id` = `e`.`workerFk`)) join `ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) where `e`.`created` > `util`.`VN_CURDATE`() group by `e`.`ticketFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79799,7 +81013,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `invoiceCorrectionDataSource` AS select `s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`s`.`price` AS `price`,`s`.`discount` AS `discount`,`t`.`refFk` AS `refFk`,`s`.`id` AS `saleFk`,`t`.`shipped` AS `shipped` from (`sale` `s` join `ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) where `t`.`shipped` > util.VN_CURDATE() + interval -3 year */; +/*!50001 VIEW `invoiceCorrectionDataSource` AS select `s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`s`.`price` AS `price`,`s`.`discount` AS `discount`,`t`.`refFk` AS `refFk`,`s`.`id` AS `saleFk`,`t`.`shipped` AS `shipped` from (`sale` `s` join `ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) where `t`.`shipped` > `util`.`VN_CURDATE`() + interval -3 year */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79932,7 +81146,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemPlacementSupplyList` AS select `ips`.`id` AS `id`,`ips`.`itemFk` AS `itemFk`,`ips`.`quantity` AS `quantity`,`ips`.`priority` AS `priority`,ifnull(`isps`.`created`,`ips`.`created`) AS `created`,`ips`.`userFk` AS `userFk`,`ips`.`repoUserFk` AS `repoUserFk`,`ips`.`quantity` - sum(ifnull(`isps`.`quantity`,0)) AS `saldo`,concat(`i`.`longName`,' ',`i`.`size`) AS `longName`,`i`.`subName` AS `subName`,`i`.`size` AS `size`,`w`.`code` AS `workerCode`,`rw`.`code` AS `repoCode`,`ips`.`sectorFk` AS `sectorFk` from ((((`itemPlacementSupply` `ips` join `item` `i` on(`i`.`id` = `ips`.`itemFk`)) left join `worker` `w` on(`w`.`userFk` = `ips`.`userFk`)) left join `worker` `rw` on(`rw`.`userFk` = `ips`.`repoUserFk`)) left join `itemShelvingPlacementSupply` `isps` on(`isps`.`itemPlacementSupplyFk` = `ips`.`id`)) where `ips`.`created` >= util.VN_CURDATE() group by `ips`.`priority`,`ips`.`id`,`ips`.`sectorFk` */; +/*!50001 VIEW `itemPlacementSupplyList` AS select `ips`.`id` AS `id`,`ips`.`itemFk` AS `itemFk`,`ips`.`quantity` AS `quantity`,`ips`.`priority` AS `priority`,ifnull(`isps`.`created`,`ips`.`created`) AS `created`,`ips`.`userFk` AS `userFk`,`ips`.`repoUserFk` AS `repoUserFk`,`ips`.`quantity` - sum(ifnull(`isps`.`quantity`,0)) AS `saldo`,concat(`i`.`longName`,' ',`i`.`size`) AS `longName`,`i`.`subName` AS `subName`,`i`.`size` AS `size`,`w`.`code` AS `workerCode`,`rw`.`code` AS `repoCode`,`ips`.`sectorFk` AS `sectorFk` from ((((`itemPlacementSupply` `ips` join `item` `i` on(`i`.`id` = `ips`.`itemFk`)) left join `worker` `w` on(`w`.`userFk` = `ips`.`userFk`)) left join `worker` `rw` on(`rw`.`userFk` = `ips`.`repoUserFk`)) left join `itemShelvingPlacementSupply` `isps` on(`isps`.`itemPlacementSupplyFk` = `ips`.`id`)) where `ips`.`created` >= `util`.`VN_CURDATE`() group by `ips`.`priority`,`ips`.`id`,`ips`.`sectorFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79989,7 +81203,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemShelvingAvailable` AS select `s`.`id` AS `saleFk`,`tst`.`updated` AS `Modificado`,`s`.`ticketFk` AS `ticketFk`,0 AS `isPicked`,`s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`i`.`size` AS `size`,`st`.`name` AS `Estado`,`st`.`sectorProdPriority` AS `sectorProdPriority`,`stock`.`visible` AS `available`,`stock`.`sectorFk` AS `sectorFk`,`stock`.`shelvingFk` AS `matricula`,`stock`.`parkingFk` AS `parking`,`stock`.`itemShelvingFk` AS `itemShelving`,`am`.`name` AS `Agency`,`t`.`shipped` AS `shipped`,`stock`.`grouping` AS `grouping`,`stock`.`packing` AS `packing`,`z`.`hour` AS `hour`,`st`.`isPreviousPreparable` AS `isPreviousPreparable`,`sv`.`physicalVolume` AS `physicalVolume`,`t`.`warehouseFk` AS `warehouseFk` from (((((((((`sale` `s` join `ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `agencyMode` `am` on(`am`.`id` = `t`.`agencyModeFk`)) join `ticketStateToday` `tst` on(`tst`.`ticket` = `t`.`id`)) join `state` `st` on(`st`.`id` = `tst`.`state`)) join `item` `i` on(`i`.`id` = `s`.`itemFk`)) join `itemShelvingStock` `stock` on(`stock`.`itemFk` = `i`.`id`)) left join `saleTracking` `stk` on(`stk`.`saleFk` = `s`.`id`)) left join `zone` `z` on(`z`.`id` = `t`.`zoneFk`)) left join `saleVolume` `sv` on(`sv`.`saleFk` = `s`.`id`)) where `t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(util.VN_CURDATE()) and `stk`.`id` is null and `stock`.`visible` > 0 and `stk`.`saleFk` is null and `st`.`isPreviousPreparable` <> 0 */; +/*!50001 VIEW `itemShelvingAvailable` AS select `s`.`id` AS `saleFk`,`tst`.`updated` AS `Modificado`,`s`.`ticketFk` AS `ticketFk`,0 AS `isPicked`,`s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`i`.`size` AS `size`,`st`.`name` AS `Estado`,`st`.`sectorProdPriority` AS `sectorProdPriority`,`stock`.`visible` AS `available`,`stock`.`sectorFk` AS `sectorFk`,`stock`.`shelvingFk` AS `matricula`,`stock`.`parkingFk` AS `parking`,`stock`.`itemShelvingFk` AS `itemShelving`,`am`.`name` AS `Agency`,`t`.`shipped` AS `shipped`,`stock`.`grouping` AS `grouping`,`stock`.`packing` AS `packing`,`z`.`hour` AS `hour`,`st`.`isPreviousPreparable` AS `isPreviousPreparable`,`sv`.`physicalVolume` AS `physicalVolume`,`t`.`warehouseFk` AS `warehouseFk` from (((((((((`sale` `s` join `ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `agencyMode` `am` on(`am`.`id` = `t`.`agencyModeFk`)) join `ticketStateToday` `tst` on(`tst`.`ticket` = `t`.`id`)) join `state` `st` on(`st`.`id` = `tst`.`state`)) join `item` `i` on(`i`.`id` = `s`.`itemFk`)) join `itemShelvingStock` `stock` on(`stock`.`itemFk` = `i`.`id`)) left join `saleTracking` `stk` on(`stk`.`saleFk` = `s`.`id`)) left join `zone` `z` on(`z`.`id` = `t`.`zoneFk`)) left join `saleVolume` `sv` on(`sv`.`saleFk` = `s`.`id`)) where `t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(`util`.`VN_CURDATE`()) and `stk`.`id` is null and `stock`.`visible` > 0 and `stk`.`saleFk` is null and `st`.`isPreviousPreparable` <> 0 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80236,7 +81450,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `lastHourProduction` AS select `t`.`warehouseFk` AS `warehouseFk`,cast(sum(ifnull(`p`.`volume`,`p`.`width` * `p`.`height` * `p`.`depth`) / 1000000) as decimal(5,1)) AS `m3` from (((`warehouse` `w` join `ticket` `t` on(`t`.`warehouseFk` = `w`.`id`)) left join `expedition` `e` on(`t`.`id` = `e`.`ticketFk`)) left join `packaging` `p` on(`p`.`id` = `e`.`packagingFk`)) where `e`.`created` between current_timestamp() - interval 1 hour and current_timestamp() group by `t`.`warehouseFk` */; +/*!50001 VIEW `lastHourProduction` AS select `t`.`warehouseFk` AS `warehouseFk`,cast(sum(ifnull(`p`.`volume`,`p`.`width` * `p`.`height` * `p`.`depth`) / 1000000) as decimal(5,1)) AS `m3` from (((`warehouse` `w` join `ticket` `t` on(`t`.`warehouseFk` = `w`.`id`)) left join `expedition` `e` on(`t`.`id` = `e`.`ticketFk`)) left join `packaging` `p` on(`p`.`id` = `e`.`packagingFk`)) where `e`.`created` between `util`.`VN_NOW`() - interval 1 hour and `util`.`VN_NOW`() group by `t`.`warehouseFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80274,7 +81488,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `lastTopClaims` AS select `s`.`itemFk` AS `itemFk`,`i`.`longName` AS `itemName`,`it`.`name` AS `itemTypeName`,count(0) AS `claimsNumber`,round(sum(`cb`.`quantity` * `s`.`price` * (1 - (`c`.`responsibility` - 1) / 4) * (100 - `s`.`discount`) / 100),2) AS `claimedAmount`,round(sum(`cb`.`quantity` * `s`.`price` * (100 - `s`.`discount`) / 100),2) AS `totalAmount` from ((((`claim` `c` join `claimBeginning` `cb` on(`cb`.`claimFk` = `c`.`id`)) join `sale` `s` on(`s`.`id` = `cb`.`saleFk`)) join `item` `i` on(`i`.`id` = `s`.`itemFk`)) join `itemType` `it` on(`it`.`id` = `i`.`typeFk`)) where `c`.`created` >= util.VN_CURDATE() + interval -1 week group by `s`.`itemFk` having `claimedAmount` > 100 and `claimsNumber` > 2 or `claimsNumber` > 4 order by count(0) desc */; +/*!50001 VIEW `lastTopClaims` AS select `s`.`itemFk` AS `itemFk`,`i`.`longName` AS `itemName`,`it`.`name` AS `itemTypeName`,count(0) AS `claimsNumber`,round(sum(`cb`.`quantity` * `s`.`price` * (1 - (`c`.`responsibility` - 1) / 4) * (100 - `s`.`discount`) / 100),2) AS `claimedAmount`,round(sum(`cb`.`quantity` * `s`.`price` * (100 - `s`.`discount`) / 100),2) AS `totalAmount` from ((((`claim` `c` join `claimBeginning` `cb` on(`cb`.`claimFk` = `c`.`id`)) join `sale` `s` on(`s`.`id` = `cb`.`saleFk`)) join `item` `i` on(`i`.`id` = `s`.`itemFk`)) join `itemType` `it` on(`it`.`id` = `i`.`typeFk`)) where `c`.`created` >= `util`.`VN_CURDATE`() + interval -1 week group by `s`.`itemFk` having `claimedAmount` > 100 and `claimsNumber` > 2 or `claimsNumber` > 4 order by count(0) desc */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80345,12 +81559,12 @@ USE `vn`; /*!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 SET character_set_client = utf8mb3 */; +/*!50001 SET character_set_results = utf8mb3 */; +/*!50001 SET collation_connection = utf8mb3_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `operatorWorkerCode` AS select `o`.`workerFk` AS `workerFk`,concat(`w`.`firstName`,' ',`w`.`lastName`) AS `fullName`,`w`.`code` AS `code`,`o`.`numberOfWagons` AS `numberOfWagons` from ((`worker` `w` join `operator` `o` on(`o`.`workerFk` = `w`.`id`)) join `sector` `s` on(`w`.`sectorFk` = `s`.`id`)) where `w`.`sectorFk` is not null and `s`.`code` in ('H2','H2','PEQUES_H','ALTILLO COMP','ALTILLO ARTI') */; +/*!50001 VIEW `operatorWorkerCode` AS select `o`.`workerFk` AS `workerFk`,concat(`w`.`firstName`,' ',`w`.`lastName`) AS `fullName`,`w`.`code` AS `code`,`o`.`numberOfWagons` AS `numberOfWagons` from ((`worker` `w` join `operator` `o` on(`o`.`workerFk` = `w`.`id`)) join `sector` `s` on(`o`.`sectorFk` = `s`.`id`)) where `o`.`sectorFk` is not null and `s`.`code` in ('H2','H2','PEQUES_H','ALTILLO COMP','ALTILLO ARTI') */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80445,7 +81659,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `productionVolume` AS select hour(`e`.`created`) AS `hora`,minute(`e`.`created`) AS `minuto`,ifnull(`p`.`volume`,ifnull(`p`.`width` * `p`.`height` * `p`.`depth`,94500)) AS `cm3`,`t`.`warehouseFk` AS `warehouseFk`,`e`.`created` AS `created` from (((`expedition` `e` left join `packaging` `p` on(`p`.`id` = `e`.`packagingFk`)) join `ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) join `client` `c` on(`c`.`id` = `t`.`clientFk`)) where `e`.`created` between util.VN_CURDATE() and `util`.`dayend`(util.VN_CURDATE()) and `c`.`isRelevant` <> 0 */; +/*!50001 VIEW `productionVolume` AS select hour(`e`.`created`) AS `hora`,minute(`e`.`created`) AS `minuto`,ifnull(`p`.`volume`,ifnull(`p`.`width` * `p`.`height` * `p`.`depth`,94500)) AS `cm3`,`t`.`warehouseFk` AS `warehouseFk`,`e`.`created` AS `created` from (((`expedition` `e` left join `packaging` `p` on(`p`.`id` = `e`.`packagingFk`)) join `ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) join `client` `c` on(`c`.`id` = `t`.`clientFk`)) where `e`.`created` between `util`.`VN_CURDATE`() and `util`.`dayend`(`util`.`VN_CURDATE`()) and `c`.`isRelevant` <> 0 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80464,7 +81678,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `productionVolume_LastHour` AS select cast(sum(`productionVolume`.`cm3` / 1000000) as decimal(10,0)) AS `m3`,`productionVolume`.`warehouseFk` AS `warehouseFk` from `productionVolume` where `productionVolume`.`created` > current_timestamp() + interval -1 hour and `productionVolume`.`warehouseFk` in (1,44,60) group by `productionVolume`.`warehouseFk` */; +/*!50001 VIEW `productionVolume_LastHour` AS select cast(sum(`productionVolume`.`cm3` / 1000000) as decimal(10,0)) AS `m3`,`productionVolume`.`warehouseFk` AS `warehouseFk` from `productionVolume` where `productionVolume`.`created` > `util`.`VN_NOW`() + interval -1 hour and `productionVolume`.`warehouseFk` in (1,44,60) group by `productionVolume`.`warehouseFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80597,7 +81811,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleSaleTracking` AS select distinct `st`.`saleFk` AS `saleFk` from `saleTracking` `st` where `st`.`created` >= util.VN_CURDATE() + interval -1 day */; +/*!50001 VIEW `saleSaleTracking` AS select distinct `st`.`saleFk` AS `saleFk` from `saleTracking` `st` where `st`.`created` >= `util`.`VN_CURDATE`() + interval -1 day */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80635,7 +81849,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleVolume` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,round(`ic`.`cm3delivery` * `s`.`quantity` / 1000,0) AS `litros`,`t`.`routeFk` AS `routeFk`,`t`.`shipped` AS `shipped`,`t`.`landed` AS `landed`,`s`.`quantity` * `ic`.`cm3delivery` / 1000000 AS `volume`,`s`.`quantity` * `ic`.`grams` / 1000 AS `physicalWeight`,`s`.`quantity` * `ic`.`cm3delivery` * greatest(`ic`.`grams` / `ic`.`cm3delivery`,`vc`.`aerealVolumetricDensity`) / 1000000 AS `weight`,`s`.`quantity` * `ic`.`cm3delivery` / 1000000 AS `physicalVolume`,`s`.`quantity` * `ic`.`cm3delivery` * ifnull(`t`.`zonePrice`,`z`.`price`) / (`vc`.`standardFlowerBox` * 1000) AS `freight`,`t`.`zoneFk` AS `zoneFk`,`t`.`clientFk` AS `clientFk`,`s`.`isPicked` AS `isPicked`,`s`.`quantity` * `s`.`price` * (100 - `s`.`discount`) / 100 AS `eurosValue`,`i`.`itemPackingTypeFk` AS `itemPackingTypeFk` from (((((`sale` `s` join `item` `i` on(`i`.`id` = `s`.`itemFk`)) join `ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `zone` `z` on(`z`.`id` = `t`.`zoneFk`)) join `volumeConfig` `vc`) join `itemCost` `ic` on(`ic`.`itemFk` = `s`.`itemFk` and `ic`.`warehouseFk` = `t`.`warehouseFk`)) where `s`.`quantity` > 0 */; +/*!50001 VIEW `saleVolume` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,round(`ic`.`cm3delivery` * `s`.`quantity` / 1000,0) AS `litros`,`t`.`routeFk` AS `routeFk`,`t`.`shipped` AS `shipped`,`t`.`landed` AS `landed`,`s`.`quantity` * `ic`.`cm3delivery` / 1000000 AS `volume`,`s`.`quantity` * `ic`.`grams` / 1000 AS `physicalWeight`,`s`.`quantity` * `ic`.`cm3delivery` * greatest(`ic`.`grams` / `ic`.`cm3delivery`,`vc`.`aerealVolumetricDensity`) / 1000000 AS `weight`,`s`.`quantity` * `ic`.`cm3delivery` / 1000000 AS `physicalVolume`,`s`.`quantity` * `ic`.`cm3delivery` * ifnull(`t`.`zonePrice` - ifnull(`t`.`zoneBonus`,0),`z`.`price` - `z`.`bonus`) / (`vc`.`standardFlowerBox` * 1000) AS `freight`,`t`.`zoneFk` AS `zoneFk`,`t`.`clientFk` AS `clientFk`,`s`.`isPicked` AS `isPicked`,`s`.`quantity` * `s`.`price` * (100 - `s`.`discount`) / 100 AS `eurosValue`,`i`.`itemPackingTypeFk` AS `itemPackingTypeFk` from (((((`sale` `s` join `item` `i` on(`i`.`id` = `s`.`itemFk`)) join `ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `zone` `z` on(`z`.`id` = `t`.`zoneFk`)) join `volumeConfig` `vc`) join `itemCost` `ic` on(`ic`.`itemFk` = `s`.`itemFk` and `ic`.`warehouseFk` = `t`.`warehouseFk`)) where `s`.`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 */; @@ -80654,7 +81868,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleVolume_Today_VNH` AS select `t`.`nickname` AS `Cliente`,`p`.`name` AS `Provincia`,`c`.`country` AS `Pais`,cast(sum(`sv`.`volume`) as decimal(5,1)) AS `volume` from (((((`saleVolume` `sv` join `ticket` `t` on(`t`.`id` = `sv`.`ticketFk`)) join `address` `a` on(`a`.`id` = `t`.`addressFk`)) join `province` `p` on(`p`.`id` = `a`.`provinceFk`)) join `country` `c` on(`c`.`id` = `p`.`countryFk`)) join `warehouse` `w` on(`w`.`id` = `t`.`warehouseFk`)) where `w`.`name` = 'VNH' and `t`.`shipped` between util.VN_CURDATE() and `util`.`dayend`(util.VN_CURDATE()) group by `t`.`nickname`,`p`.`name` */; +/*!50001 VIEW `saleVolume_Today_VNH` AS select `t`.`nickname` AS `Cliente`,`p`.`name` AS `Provincia`,`c`.`country` AS `Pais`,cast(sum(`sv`.`volume`) as decimal(5,1)) AS `volume` from (((((`saleVolume` `sv` join `ticket` `t` on(`t`.`id` = `sv`.`ticketFk`)) join `address` `a` on(`a`.`id` = `t`.`addressFk`)) join `province` `p` on(`p`.`id` = `a`.`provinceFk`)) join `country` `c` on(`c`.`id` = `p`.`countryFk`)) join `warehouse` `w` on(`w`.`id` = `t`.`warehouseFk`)) where `w`.`name` = 'VNH' and `t`.`shipped` between `util`.`VN_CURDATE`() and `util`.`dayend`(`util`.`VN_CURDATE`()) group by `t`.`nickname`,`p`.`name` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80692,7 +81906,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `salesPersonSince` AS select `b`.`workerFk` AS `workerFk`,min(`b`.`started`) AS `started` from ((`vn`.`business` `b` join `vn`.`worker` `w` on(`w`.`id` = `b`.`workerFk`)) left join `postgresql`.`professional_category` `pc` on(`pc`.`professional_category_id` = `b`.`workerBusinessProfessionalCategoryFk`)) where `pc`.`category_name` = 'Aux ventas' group by `b`.`workerFk` */; +/*!50001 VIEW `salesPersonSince` AS select `b`.`workerFk` AS `workerFk`,min(`b`.`started`) AS `started` from ((`business` `b` join `worker` `w` on(`w`.`id` = `b`.`workerFk`)) left join `professionalCategory` `pc` on(`pc`.`id` = `b`.`workerBusinessProfessionalCategoryFk`)) where `pc`.`name` = 'Aux ventas' group by `b`.`workerFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80711,7 +81925,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `salesPreparedLastHour` AS select `t`.`warehouseFk` AS `warehouseFk`,`st`.`saleFk` AS `saleFk`,`st`.`isChecked` AS `isChecked`,`st`.`originalQuantity` AS `originalQuantity`,`st`.`created` AS `created`,`e`.`code` AS `code`,`w`.`firstName` AS `firstname`,`w`.`lastName` AS `lastName`,`w`.`code` AS `workerCode`,`ic`.`cm3delivery` * `s`.`quantity` / 1000 AS `litros`,`s`.`concept` AS `concept`,`d`.`name` AS `departmentName` from ((((((((`saleTracking` `st` left join `salesPreviousPreparated` `prevPrepSales` on(`prevPrepSales`.`saleFk` = `st`.`saleFk`)) join `sale` `s` on(`s`.`id` = `st`.`saleFk`)) join `ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `itemCost` `ic` on(`ic`.`warehouseFk` = `t`.`warehouseFk` and `ic`.`itemFk` = `s`.`itemFk`)) join `worker` `w` on(`w`.`id` = `st`.`workerFk`)) join `state` `e` on(`e`.`id` = `st`.`stateFk`)) join `workerDepartment` `wd` on(`wd`.`workerFk` = `st`.`workerFk`)) join `department` `d` on(`d`.`id` = `wd`.`departmentFk`)) where `st`.`created` > current_timestamp() + interval -1 hour and `prevPrepSales`.`saleFk` is null and `d`.`name` not like 'EQUIPO%' */; +/*!50001 VIEW `salesPreparedLastHour` AS select `t`.`warehouseFk` AS `warehouseFk`,`st`.`saleFk` AS `saleFk`,`st`.`isChecked` AS `isChecked`,`st`.`originalQuantity` AS `originalQuantity`,`st`.`created` AS `created`,`e`.`code` AS `code`,`w`.`firstName` AS `firstname`,`w`.`lastName` AS `lastName`,`w`.`code` AS `workerCode`,`ic`.`cm3delivery` * `s`.`quantity` / 1000 AS `litros`,`s`.`concept` AS `concept`,`d`.`name` AS `departmentName` from ((((((((`saleTracking` `st` left join `salesPreviousPreparated` `prevPrepSales` on(`prevPrepSales`.`saleFk` = `st`.`saleFk`)) join `sale` `s` on(`s`.`id` = `st`.`saleFk`)) join `ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `itemCost` `ic` on(`ic`.`warehouseFk` = `t`.`warehouseFk` and `ic`.`itemFk` = `s`.`itemFk`)) join `worker` `w` on(`w`.`id` = `st`.`workerFk`)) join `state` `e` on(`e`.`id` = `st`.`stateFk`)) join `workerDepartment` `wd` on(`wd`.`workerFk` = `st`.`workerFk`)) join `department` `d` on(`d`.`id` = `wd`.`departmentFk`)) where `st`.`created` > `util`.`VN_NOW`() + interval -1 hour and `prevPrepSales`.`saleFk` is null and `d`.`name` not like 'EQUIPO%' */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80730,7 +81944,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `salesPreviousPreparated` AS select `st`.`saleFk` AS `saleFk` from (`saleTracking` `st` join `state` `e` on(`e`.`id` = `st`.`stateFk`)) where `st`.`created` > util.VN_CURDATE() and `e`.`code` like 'PREVIOUS_PREPARATION' */; +/*!50001 VIEW `salesPreviousPreparated` AS select `st`.`saleFk` AS `saleFk` from (`saleTracking` `st` join `state` `e` on(`e`.`id` = `st`.`stateFk`)) where `st`.`created` > `util`.`VN_CURDATE`() and `e`.`code` like 'PREVIOUS_PREPARATION' */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80806,7 +82020,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketLastUpdatedList` AS select `s`.`ticketFk` AS `ticketFk`,`st`.`created` AS `created` from (`saleTracking` `st` join `sale` `s` on(`s`.`id` = `st`.`saleFk`)) where `st`.`created` > util.VN_CURDATE() union all select `tt`.`ticketFk` AS `Id_Ticket`,`tt`.`created` AS `odbc_date` from `ticketTracking` `tt` where `tt`.`created` > util.VN_CURDATE() union all select `s`.`ticketFk` AS `ticketFk`,`iss`.`created` AS `created` from (`itemShelvingSale` `iss` join `sale` `s` on(`s`.`id` = `iss`.`saleFk`)) where `iss`.`created` > util.VN_CURDATE() */; +/*!50001 VIEW `ticketLastUpdatedList` AS select `s`.`ticketFk` AS `ticketFk`,`st`.`created` AS `created` from (`saleTracking` `st` join `sale` `s` on(`s`.`id` = `st`.`saleFk`)) where `st`.`created` > `util`.`VN_CURDATE`() union all select `tt`.`ticketFk` AS `Id_Ticket`,`tt`.`created` AS `odbc_date` from `ticketTracking` `tt` where `tt`.`created` > `util`.`VN_CURDATE`() union all select `s`.`ticketFk` AS `ticketFk`,`iss`.`created` AS `created` from (`itemShelvingSale` `iss` join `sale` `s` on(`s`.`id` = `iss`.`saleFk`)) where `iss`.`created` > `util`.`VN_CURDATE`() */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80860,7 +82074,7 @@ USE `vn`; /*!50001 SET @saved_col_connection = @@collation_connection */; /*!50001 SET character_set_client = utf8mb4 */; /*!50001 SET character_set_results = utf8mb4 */; -/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `ticketPackingList` AS select `t`.`nickname` AS `nickname`,`t`.`id` AS `ticketFk`,`am`.`name` AS `agencyMode`,`am`.`flag` AS `flag`,`p`.`name` AS `province`,`s`.`itemFk` AS `itemFk`,`s`.`concept` AS `concept`,`s`.`quantity` AS `quantity`,`sv`.`litros` AS `litros`,`to`.`description` AS `observaciones` from (((((((`ticket` `t` join `address` `a` on(`a`.`id` = `t`.`addressFk`)) join `province` `p` on(`p`.`id` = `a`.`provinceFk`)) join `agencyMode` `am` on(`am`.`id` = `t`.`agencyModeFk`)) left join `sale` `s` on(`s`.`ticketFk` = `t`.`id`)) left join `saleVolume` `sv` on(`sv`.`saleFk` = `s`.`id`)) join `observationType` `ot` on(`ot`.`code` = 'packager')) left join `ticketObservation` `to` on(`to`.`ticketFk` = `t`.`id` and `ot`.`id` = `to`.`observationTypeFk`)) */; @@ -80882,7 +82096,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketPreviousPreparingList` AS select `s`.`ticketFk` AS `ticketFk`,`w`.`code` AS `code`,count(`s`.`id`) AS `saleLines`,sum(`s`.`isPicked` <> 0) AS `alreadyMadeSaleLines`,sum(`s`.`isPicked` <> 0) / count(`s`.`id`) AS `madeRate`,`sg`.`created` AS `created`,`p`.`code` AS `parking`,`iss`.`sectorFk` AS `sectorFk`,`al`.`code` AS `alertCode` from (((((((`saleGroup` `sg` join `saleGroupDetail` `sgd` on(`sgd`.`saleGroupFk` = `sg`.`id`)) join `sale` `s` on(`s`.`id` = `sgd`.`saleFk`)) join `ticketState` `tls` on(`tls`.`ticketFk` = `s`.`ticketFk`)) join `alertLevel` `al` on(`al`.`id` = `tls`.`alertLevel`)) join `worker` `w` on(`w`.`id` = `sg`.`userFk`)) left join `parking` `p` on(`p`.`id` = `sg`.`parkingFk`)) join `itemShelvingStock` `iss` on(`iss`.`itemFk` = `s`.`itemFk`)) where `sg`.`created` >= util.VN_CURDATE() + interval 0.1 day group by `sg`.`id` */; +/*!50001 VIEW `ticketPreviousPreparingList` AS select `s`.`ticketFk` AS `ticketFk`,`w`.`code` AS `code`,count(`s`.`id`) AS `saleLines`,sum(`s`.`isPicked` <> 0) AS `alreadyMadeSaleLines`,sum(`s`.`isPicked` <> 0) / count(`s`.`id`) AS `madeRate`,`sg`.`created` AS `created`,`p`.`code` AS `parking`,`iss`.`sectorFk` AS `sectorFk`,`al`.`code` AS `alertCode` from (((((((`saleGroup` `sg` join `saleGroupDetail` `sgd` on(`sgd`.`saleGroupFk` = `sg`.`id`)) join `sale` `s` on(`s`.`id` = `sgd`.`saleFk`)) join `ticketState` `tls` on(`tls`.`ticketFk` = `s`.`ticketFk`)) join `alertLevel` `al` on(`al`.`id` = `tls`.`alertLevel`)) join `worker` `w` on(`w`.`id` = `sg`.`userFk`)) left join `parking` `p` on(`p`.`id` = `sg`.`parkingFk`)) join `itemShelvingStock` `iss` on(`iss`.`itemFk` = `s`.`itemFk`)) where `sg`.`created` >= `util`.`VN_CURDATE`() + interval 0.1 day group by `sg`.`id` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80920,7 +82134,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketStateToday` AS select `ts`.`ticket` AS `ticket`,`ts`.`state` AS `state`,`ts`.`productionOrder` AS `productionOrder`,`ts`.`alertLevel` AS `alertLevel`,`ts`.`worker` AS `worker`,`ts`.`code` AS `code`,`ts`.`updated` AS `updated`,`ts`.`isPicked` AS `isPicked` from (`ticketState` `ts` join `ticket` `t` on(`t`.`id` = `ts`.`ticket`)) where `t`.`shipped` between util.VN_CURDATE() and `MIDNIGHT`(util.VN_CURDATE()) */; +/*!50001 VIEW `ticketStateToday` AS select `ts`.`ticket` AS `ticket`,`ts`.`state` AS `state`,`ts`.`productionOrder` AS `productionOrder`,`ts`.`alertLevel` AS `alertLevel`,`ts`.`worker` AS `worker`,`ts`.`code` AS `code`,`ts`.`updated` AS `updated`,`ts`.`isPicked` AS `isPicked` from (`ticketState` `ts` join `ticket` `t` on(`t`.`id` = `ts`.`ticket`)) where `t`.`shipped` between `util`.`VN_CURDATE`() and `MIDNIGHT`(`util`.`VN_CURDATE`()) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80996,26 +82210,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerBusinessDated` AS select `t`.`dated` AS `dated`,`b`.`id` AS `businessFk`,`b`.`workerFk` AS `workerFk` from (`time` `t` left join `business` `b` on(`t`.`dated` between `b`.`started` and ifnull(`b`.`ended`,util.VN_CURDATE()))) where `t`.`dated` > util.VN_CURDATE() + interval -2 year */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - --- --- Final view structure for view `workerCalendar` --- - -/*!50001 DROP TABLE IF EXISTS `workerCalendar`*/; -/*!50001 DROP VIEW IF EXISTS `workerCalendar`*/; -/*!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 `workerCalendar` AS select `b`.`id` AS `businessFk`,`b`.`workerFk` AS `workerFk`,`ce`.`calendar_state_id` AS `absenceTypeFk`,`ce`.`date` AS `dated` from (`vn`.`business` `b` join `postgresql`.`calendar_employee` `ce` on(`ce`.`businessFk` = `b`.`id`)) */; +/*!50001 VIEW `workerBusinessDated` AS select `t`.`dated` AS `dated`,`b`.`id` AS `businessFk`,`b`.`workerFk` AS `workerFk` from (`time` `t` left join `business` `b` on(`t`.`dated` between `b`.`started` and ifnull(`b`.`ended`,`util`.`VN_CURDATE`()))) where `t`.`dated` > `util`.`VN_CURDATE`() + interval -2 year */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81091,7 +82286,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerSpeedExpedition` AS select `sv`.`ticketFk` AS `ticketFk`,sum(`sv`.`litros`) AS `litros`,sum(if(`sub`.`started` > current_timestamp() + interval -1 hour,`sv`.`litros`,0)) AS `literLastHour`,cast(60 * sum(`sv`.`litros`) / time_to_sec(timediff(max(`sub`.`finished`),min(`sub`.`started`))) as decimal(10,1)) AS `litersByMinute`,`sub`.`code` AS `workerCode`,`sub`.`cajas` AS `cajas`,`sub`.`warehouseFk` AS `warehouseFk` from (`saleVolume` `sv` join `expeditionTimeExpended` `sub` on(`sub`.`ticketFk` = `sv`.`ticketFk`)) group by `sub`.`code` */; +/*!50001 VIEW `workerSpeedExpedition` AS select `sv`.`ticketFk` AS `ticketFk`,sum(`sv`.`litros`) AS `litros`,sum(if(`sub`.`started` > `util`.`VN_NOW`() + interval -1 hour,`sv`.`litros`,0)) AS `literLastHour`,cast(60 * sum(`sv`.`litros`) / time_to_sec(timediff(max(`sub`.`finished`),min(`sub`.`started`))) as decimal(10,1)) AS `litersByMinute`,`sub`.`code` AS `workerCode`,`sub`.`cajas` AS `cajas`,`sub`.`warehouseFk` AS `warehouseFk` from (`saleVolume` `sv` join `expeditionTimeExpended` `sub` on(`sub`.`ticketFk` = `sv`.`ticketFk`)) group by `sub`.`code` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81110,7 +82305,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerSpeedSaleTracking` AS select `salesPreparedLastHour`.`warehouseFk` AS `warehouseFk`,`salesPreparedLastHour`.`code` AS `state`,`salesPreparedLastHour`.`workerCode` AS `workerCode`,sum(`salesPreparedLastHour`.`litros`) AS `sumaLitros`,min(`salesPreparedLastHour`.`created`) AS `started`,max(`salesPreparedLastHour`.`created`) AS `finished`,sum(if(`salesPreparedLastHour`.`created` >= current_timestamp() + interval -1 hour,`salesPreparedLastHour`.`litros`,0)) AS `sumaLitrosLastHour`,cast(60 * sum(`salesPreparedLastHour`.`litros`) / time_to_sec(timediff(max(`salesPreparedLastHour`.`created`),min(`salesPreparedLastHour`.`created`))) as decimal(10,1)) AS `litersByMinute`,`salesPreparedLastHour`.`departmentName` AS `departmentName` from `salesPreparedLastHour` group by `salesPreparedLastHour`.`warehouseFk`,`salesPreparedLastHour`.`code`,`salesPreparedLastHour`.`workerCode` */; +/*!50001 VIEW `workerSpeedSaleTracking` AS select `salesPreparedLastHour`.`warehouseFk` AS `warehouseFk`,`salesPreparedLastHour`.`code` AS `state`,`salesPreparedLastHour`.`workerCode` AS `workerCode`,sum(`salesPreparedLastHour`.`litros`) AS `sumaLitros`,min(`salesPreparedLastHour`.`created`) AS `started`,max(`salesPreparedLastHour`.`created`) AS `finished`,sum(if(`salesPreparedLastHour`.`created` >= `util`.`VN_NOW`() + interval -1 hour,`salesPreparedLastHour`.`litros`,0)) AS `sumaLitrosLastHour`,cast(60 * sum(`salesPreparedLastHour`.`litros`) / time_to_sec(timediff(max(`salesPreparedLastHour`.`created`),min(`salesPreparedLastHour`.`created`))) as decimal(10,1)) AS `litersByMinute`,`salesPreparedLastHour`.`departmentName` AS `departmentName` from `salesPreparedLastHour` group by `salesPreparedLastHour`.`warehouseFk`,`salesPreparedLastHour`.`code`,`salesPreparedLastHour`.`workerCode` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81186,7 +82381,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerWithoutTractor` AS select `c`.`workerFk` AS `workerFk`,`cl`.`name` AS `Trabajador`,count(distinct `c`.`id`) AS `Colecciones`,max(`c`.`created`) AS `created` from ((`collection` `c` join `client` `cl` on(`cl`.`id` = `c`.`workerFk`)) left join `machineWorker` `mw` on(`mw`.`workerFk` = `c`.`workerFk` and `mw`.`inTimed` > 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`)) 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 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81200,12 +82395,12 @@ USE `vn`; /*!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 SET character_set_client = utf8mb3 */; +/*!50001 SET character_set_results = utf8mb3 */; +/*!50001 SET collation_connection = utf8mb3_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `zoneEstimatedDelivery` AS select `t`.`zoneFk` AS `zoneFk`,cast(util.VN_CURDATE() + interval hour(ifnull(`zc`.`hour`,`z`.`hour`)) * 60 + minute(ifnull(`zc`.`hour`,`z`.`hour`)) minute as time) AS `hourTheoretical`,cast(sum(`sv`.`volume`) as decimal(5,1)) AS `totalVolume`,cast(sum(if(`s`.`alertLevel` < 2,`sv`.`volume`,0)) as decimal(5,1)) AS `remainingVolume`,greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0)) AS `speed`,cast(`zc`.`hour` + interval -sum(if(`s`.`alertLevel` < 2,`sv`.`volume`,0)) * 60 / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0)) minute as time) AS `hourEffective`,floor(-sum(if(`s`.`alertLevel` < 2,`sv`.`volume`,0)) * 60 / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0))) AS `minutesLess`,cast(`zc`.`hour` + interval -sum(if(`s`.`alertLevel` < 2,`sv`.`volume`,0)) * 60 / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0)) minute as time) AS `etc` from (((((((((`vn`.`ticket` `t` join `vn`.`ticketStateToday` `tst` on(`tst`.`ticket` = `t`.`id`)) join `vn`.`state` `s` on(`s`.`id` = `tst`.`state`)) join `vn`.`saleVolume` `sv` on(`sv`.`ticketFk` = `t`.`id`)) left join `vn`.`lastHourProduction` `lhp` on(`lhp`.`warehouseFk` = `t`.`warehouseFk`)) join `vn`.`warehouse` `w` on(`w`.`id` = `t`.`warehouseFk`)) join `vn`.`warehouseAlias` `wa` on(`wa`.`id` = `w`.`aliasFk`)) join `vn`.`zone` `z` on(`z`.`id` = `t`.`zoneFk`)) left join `vn`.`zoneClosure` `zc` on(`zc`.`zoneFk` = `t`.`zoneFk` and `zc`.`dated` = util.VN_CURDATE())) left join `cache`.`departure_limit` `dl` on(`dl`.`warehouse_id` = `t`.`warehouseFk` and `dl`.`fecha` = util.VN_CURDATE())) where `w`.`hasProduction` <> 0 and cast(`t`.`shipped` as date) = util.VN_CURDATE() group by `t`.`zoneFk` */; +/*!50001 VIEW `zoneEstimatedDelivery` AS select `t`.`zoneFk` AS `zoneFk`,cast(`util`.`VN_CURDATE`() + interval hour(ifnull(`zc`.`hour`,`z`.`hour`)) * 60 + minute(ifnull(`zc`.`hour`,`z`.`hour`)) minute as time) AS `hourTheoretical`,cast(sum(`sv`.`volume`) as decimal(5,1)) AS `totalVolume`,cast(sum(if(`s`.`alertLevel` < 2,`sv`.`volume`,0)) as decimal(5,1)) AS `remainingVolume`,greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0)) AS `speed`,cast(`zc`.`hour` + interval -sum(if(`s`.`alertLevel` < 2,`sv`.`volume`,0)) * 60 / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0)) minute as time) AS `hourEffective`,floor(-sum(if(`s`.`alertLevel` < 2,`sv`.`volume`,0)) * 60 / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0))) AS `minutesLess`,cast(`zc`.`hour` + interval -sum(if(`s`.`alertLevel` < 2,`sv`.`volume`,0)) * 60 / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0)) minute as time) AS `etc` from (((((((((`vn`.`ticket` `t` join `vn`.`ticketStateToday` `tst` on(`tst`.`ticket` = `t`.`id`)) join `vn`.`state` `s` on(`s`.`id` = `tst`.`state`)) join `vn`.`saleVolume` `sv` on(`sv`.`ticketFk` = `t`.`id`)) left join `vn`.`lastHourProduction` `lhp` on(`lhp`.`warehouseFk` = `t`.`warehouseFk`)) join `vn`.`warehouse` `w` on(`w`.`id` = `t`.`warehouseFk`)) join `vn`.`warehouseAlias` `wa` on(`wa`.`id` = `w`.`aliasFk`)) straight_join `vn`.`zone` `z` on(`z`.`id` = `t`.`zoneFk`)) left join `vn`.`zoneClosure` `zc` on(`zc`.`zoneFk` = `t`.`zoneFk` and `zc`.`dated` = `util`.`VN_CURDATE`())) left join `cache`.`departure_limit` `dl` on(`dl`.`warehouse_id` = `t`.`warehouseFk` and `dl`.`fecha` = `util`.`VN_CURDATE`())) where `w`.`hasProduction` <> 0 and cast(`t`.`shipped` as date) = `util`.`VN_CURDATE`() group by `t`.`zoneFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81219,5 +82414,4 @@ USE `vn`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2023-02-21 8:14:30 - +-- Dump completed on 2023-05-16 8:23:56 diff --git a/db/export-data.sh b/db/export-data.sh index 11358e64c..2288c1c62 100755 --- a/db/export-data.sh +++ b/db/export-data.sh @@ -100,11 +100,8 @@ dump_tables ${TABLES[@]} TABLES=( postgresql - calendar_labour_type labour_agreement media_type - professional_category - profile_type ) dump_tables ${TABLES[@]} diff --git a/db/export-structure.sh b/db/export-structure.sh index 80a2efc41..a6888f2ac 100755 --- a/db/export-structure.sh +++ b/db/export-structure.sh @@ -93,12 +93,5 @@ mysqldump \ --databases \ ${SCHEMAS[@]} \ ${IGNORETABLES[@]} \ - | sed 's/\bCURDATE\b/util.VN_CURDATE/ig'\ - | sed 's/\bCURTIME\b/util.VN_CURTIME/ig' \ - | sed 's/\bNOW\b/util.VN_NOW/ig' \ - | sed 's/\bCURRENT_DATE\b/util.VN_CURDATE/ig' \ - | sed 's/\bCURRENT_TIME\b/util.VN_CURTIME/ig' \ - | sed 's/\bLOCALTIME\b/util.VN_NOW/ig' \ - | sed 's/\bLOCALTIMESTAMP\b/util.VN_NOW/ig' \ | sed 's/ AUTO_INCREMENT=[0-9]* //g' \ > dump/structure.sql diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index b19db24d7..086909ebf 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -313,7 +313,7 @@ export default { anyClient: 'vn-client-defaulter tbody > tr', firstClientName: 'vn-client-defaulter tbody > tr:nth-child(1) > td:nth-child(2) > span', firstSalesPersonName: 'vn-client-defaulter tbody > tr:nth-child(1) > td:nth-child(3) > span', - firstObservation: 'vn-client-defaulter tbody > tr:nth-child(1) > td:nth-child(6) > vn-textarea[ng-model="defaulter.observation"]', + firstObservation: 'vn-client-defaulter tbody > tr:nth-child(1) > td:nth-child(8) > vn-textarea[ng-model="defaulter.observation"]', allDefaulterCheckbox: 'vn-client-defaulter thead vn-multi-check', addObservationButton: 'vn-client-defaulter vn-button[icon="icon-notes"]', observation: '.vn-dialog.shown vn-textarea[ng-model="$ctrl.defaulter.observation"]', diff --git a/e2e/paths/02-client/07_edit_web_access.spec.js b/e2e/paths/02-client/07_edit_web_access.spec.js index 26b4c4e27..5386d12bd 100644 --- a/e2e/paths/02-client/07_edit_web_access.spec.js +++ b/e2e/paths/02-client/07_edit_web_access.spec.js @@ -5,8 +5,8 @@ const $ = { userName: 'vn-client-web-access vn-textfield[ng-model="$ctrl.account.name"]', email: 'vn-client-web-access vn-textfield[ng-model="$ctrl.account.email"]', saveButton: 'vn-client-web-access button[type=submit]', - nameValue: 'vn-client-log .change:nth-child(1) .basic-json:nth-child(1) vn-json-value', - activeValue: 'vn-client-log .change:nth-child(2) .basic-json:nth-child(2) vn-json-value' + nameValue: 'vn-client-log .change:nth-child(1) .basic-json:nth-child(2) vn-json-value', + activeValue: 'vn-client-log .change:nth-child(2) .basic-json:nth-child(1) vn-json-value' }; describe('Client web access path', () => { diff --git a/e2e/paths/04-item/02_basic_data.spec.js b/e2e/paths/04-item/02_basic_data.spec.js index bb8f3f134..f177a98df 100644 --- a/e2e/paths/04-item/02_basic_data.spec.js +++ b/e2e/paths/04-item/02_basic_data.spec.js @@ -50,6 +50,7 @@ describe('Item Edit basic data path', () => { it(`should create a new intrastat and save it`, async() => { await page.click($.newIntrastatButton); + await page.waitForSelector($.intrastatForm); await page.fillForm($.intrastatForm, { id: '588420239', description: 'Tropical Flowers' diff --git a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js index 2c9646708..2158eec8b 100644 --- a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js +++ b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js @@ -251,6 +251,7 @@ describe('Ticket Edit sale path', () => { await page.waitToClick(selectors.ticketSales.moreMenu); await page.waitToClick(selectors.ticketSales.moreMenuCreateClaim); await page.waitToClick(selectors.globalItems.acceptButton); + await page.waitToClick(selectors.globalItems.acceptButton); await page.waitForState('claim.card.basicData'); }); diff --git a/e2e/paths/06-claim/05_summary.spec.js b/e2e/paths/06-claim/05_summary.spec.js index 758dc2ee3..9656ea656 100644 --- a/e2e/paths/06-claim/05_summary.spec.js +++ b/e2e/paths/06-claim/05_summary.spec.js @@ -17,7 +17,7 @@ describe('Claim summary path', () => { }); it('should navigate to the target claim summary section', async() => { - await page.loginAndModule('employee', 'claim'); + await page.loginAndModule('salesPerson', 'claim'); await page.accessToSearchResult(claimId); await page.waitForState('claim.card.summary'); }); diff --git a/e2e/paths/06-claim/06_descriptor.spec.js b/e2e/paths/06-claim/06_descriptor.spec.js index 0826bad63..059bd68dd 100644 --- a/e2e/paths/06-claim/06_descriptor.spec.js +++ b/e2e/paths/06-claim/06_descriptor.spec.js @@ -16,7 +16,7 @@ describe('Claim descriptor path', () => { }); it('should now navigate to the target claim summary section', async() => { - await page.loginAndModule('employee', 'claim'); + await page.loginAndModule('salesPerson', 'claim'); await page.accessToSearchResult(claimId); await page.waitForState('claim.card.summary'); }); diff --git a/e2e/paths/13-supplier/03_fiscal_data.spec.js b/e2e/paths/13-supplier/03_fiscal_data.spec.js index 80c6c79b2..891b769c9 100644 --- a/e2e/paths/13-supplier/03_fiscal_data.spec.js +++ b/e2e/paths/13-supplier/03_fiscal_data.spec.js @@ -1,5 +1,20 @@ import getBrowser from '../../helpers/puppeteer'; +const $ = { + saveButton: 'vn-supplier-fiscal-data button[type="submit"]', +}; +const $inputs = { + province: 'vn-supplier-fiscal-data [name="province"]', + country: 'vn-supplier-fiscal-data [name="country"]', + postcode: 'vn-supplier-fiscal-data [name="postcode"]', + city: 'vn-supplier-fiscal-data [name="city"]', + socialName: 'vn-supplier-fiscal-data [name="socialName"]', + taxNumber: 'vn-supplier-fiscal-data [name="taxNumber"]', + account: 'vn-supplier-fiscal-data [name="account"]', + sageWithholding: 'vn-supplier-fiscal-data [ng-model="$ctrl.supplier.sageWithholdingFk"]', + sageTaxType: 'vn-supplier-fiscal-data [ng-model="$ctrl.supplier.sageTaxTypeFk"]' +}; + describe('Supplier fiscal data path', () => { let browser; let page; diff --git a/front/core/components/avatar/index.js b/front/core/components/avatar/index.js index e1aede6be..ec3a27d1d 100644 --- a/front/core/components/avatar/index.js +++ b/front/core/components/avatar/index.js @@ -1,5 +1,6 @@ import ngModule from '../../module'; import Component from 'core/lib/component'; +import {hashToColor} from '../../lib/string'; import './style.scss'; /** @@ -16,13 +17,8 @@ export default class Avatar extends Component { this._val = value; const val = value || ''; - let hash = 0; - for (let i = 0; i < val.length; i++) - hash += val.charCodeAt(i); - const color = '#' + colors[hash % colors.length]; - const el = this.element; - el.style.backgroundColor = color; + el.style.backgroundColor = hashToColor(val); el.title = val; } } @@ -35,29 +31,3 @@ ngModule.vnComponent('vnAvatar', { }, transclude: true }); - -const colors = [ - 'e2553d', // Coral - 'FFA07A', // Salmon - 'FFDAB9', // Peach - 'a17077', // Pink - 'bf0e99', // Pink light - '52a500', // Green chartreuse - '00aeae', // Cian - 'b754cf', // Purple middle - '8a69cd', // Blue lavender - '1fa8a1', // Green ocean - 'DC143C', // Red crimson - '5681cf', // Blue steel - 'FF1493', // Ping intense - '02ba02', // Green lime - '1E90FF', // Blue sky - '8B008B', // Purple dark - 'cc7000', // Orange bright - '00b5b8', // Turquoise - '8B0000', // Red dark - '008080', // Green bluish - '2F4F4F', // Gray board - '7e7e7e', // Gray - '5d5d5d', // Gray dark -]; diff --git a/front/core/components/json-value/index.js b/front/core/components/json-value/index.js index 6bf0ae4aa..6b7517417 100644 --- a/front/core/components/json-value/index.js +++ b/front/core/components/json-value/index.js @@ -2,7 +2,7 @@ import ngModule from '../../module'; import Component from 'core/lib/component'; import './style.scss'; -const maxStrLen = 50; +const maxStrLen = 512; /** * Displays pretty JSON value. @@ -28,6 +28,12 @@ export default class Controller extends Component { } else { cssClass = type; switch (type) { + case 'number': + if (Number.isInteger(value)) + text = value; + else + text = Math.round((value + Number.EPSILON) * 1000) / 1000; + break; case 'boolean': text = value ? '✓' : '✗'; cssClass = value ? 'true' : 'false'; diff --git a/front/core/components/json-value/index.spec.js b/front/core/components/json-value/index.spec.js index b79d15a5d..ff7a45977 100644 --- a/front/core/components/json-value/index.spec.js +++ b/front/core/components/json-value/index.spec.js @@ -75,5 +75,19 @@ describe('Component vnJsonValue', () => { expect(el.textContent).toEqual('2050'); expect(el.className).toContain('json-number'); }); + + it('should display number when value is decimal', () => { + controller.value = 10.1; + + expect(el.textContent).toEqual('10.1'); + expect(el.className).toContain('json-number'); + }); + + it('should display rounded number when value is decimal with lot of decimals', () => { + controller.value = 10.124323234; + + expect(el.textContent).toEqual('10.124'); + expect(el.className).toContain('json-number'); + }); }); }); diff --git a/front/core/components/multi-check/locale/es.yml b/front/core/components/multi-check/locale/es.yml index 5365c3392..25cde3df0 100644 --- a/front/core/components/multi-check/locale/es.yml +++ b/front/core/components/multi-check/locale/es.yml @@ -1,3 +1,3 @@ SelectAllRows: Seleccionar las {{rows}} fila(s) -All: Se han seleccionado -row(s) have been selected.: fila(s). \ No newline at end of file +Have been selected: Se han seleccionado +row(s) have been selected.: fila(s). diff --git a/front/core/components/searchbar/searchbar.js b/front/core/components/searchbar/searchbar.js index aefa89b5b..c74146817 100644 --- a/front/core/components/searchbar/searchbar.js +++ b/front/core/components/searchbar/searchbar.js @@ -203,7 +203,7 @@ export default class Searchbar extends Component { doSearch(filter, source) { if (filter === this.filter && !this.isIndex) return; - let promise = this.onSearch({$params: filter}); + let promise = this.onSearch({$params: filter}, source); promise = promise || this.$q.resolve(); promise.then(data => this.onFilter(filter, source, data)); this.toBar(filter); @@ -259,12 +259,6 @@ export default class Searchbar extends Component { this.filter = filter; - if (source == 'removeBar') { - delete params[this.toRemove]; - delete this.model.userParams[this.toRemove]; - this.model.refresh(); - } - if (!filter && this.model) this.model.clear(); if (source != 'state') @@ -279,7 +273,7 @@ export default class Searchbar extends Component { return {id: params.$row.id}; } - onSearch(args) { + onSearch(args, source) { if (!this.model) return; let filter = args.$params; @@ -325,6 +319,12 @@ export default class Searchbar extends Component { for (let param in stateFilter.tableQ) params[param] = stateFilter.tableQ[param]; + if (source == 'removeBar') { + delete params[this.toRemove]; + delete this.model.userParams[this.toRemove]; + delete stateFilter[this.toRemove]; + } + const newParams = Object.assign(stateFilter, params); return this.model.applyParams(newParams) .then(() => this.model.data); diff --git a/front/core/components/searchbar/searchbar.spec.js b/front/core/components/searchbar/searchbar.spec.js index 9998e7a7c..2e00c2905 100644 --- a/front/core/components/searchbar/searchbar.spec.js +++ b/front/core/components/searchbar/searchbar.spec.js @@ -197,7 +197,7 @@ describe('Component vnSearchbar', () => { controller.doSearch(filter, 'any'); $scope.$apply(); - expect(controller.onSearch).toHaveBeenCalledWith({$params: filter}); + expect(controller.onSearch).toHaveBeenCalledWith({$params: filter}, 'any'); expect(controller.onFilter).toHaveBeenCalledWith(filter, 'any', undefined); }); }); diff --git a/front/core/lib/string.js b/front/core/lib/string.js index 50bee9873..9f68ef8bb 100644 --- a/front/core/lib/string.js +++ b/front/core/lib/string.js @@ -30,3 +30,39 @@ export function camelToKebab(str) { export function firstUpper(str) { return str.charAt(0).toUpperCase() + str.substr(1); } + +export function djb2a(string) { + let hash = 5381; + for (let i = 0; i < string.length; i++) + hash = ((hash << 5) + hash) ^ string.charCodeAt(i); + return hash >>> 0; +} + +export function hashToColor(value) { + return '#' + colors[djb2a(value || '') % colors.length]; +} + +const colors = [ + 'b5b941', // Yellow + 'ae9681', // Peach + 'd78767', // Salmon + 'cc7000', // Orange bright + 'e2553d', // Coral + '8B0000', // Red dark + 'de4362', // Red crimson + 'FF1493', // Ping intense + 'be39a2', // Pink light + 'b754cf', // Purple middle + 'a87ba8', // Pink + '8a69cd', // Blue lavender + 'ab20ab', // Purple dark + '00b5b8', // Turquoise + '1fa8a1', // Green ocean + '5681cf', // Blue steel + '3399fe', // Blue sky + '6d9c3e', // Green chartreuse + '51bb51', // Green lime + '518b8b', // Gray board + '7e7e7e', // Gray + '5d5d5d', // Gray dark +]; diff --git a/front/core/styles/text.scss b/front/core/styles/text.scss index 701a84d05..190eff55d 100644 --- a/front/core/styles/text.scss +++ b/front/core/styles/text.scss @@ -1,70 +1,73 @@ -@import "./variables"; - -/* Headings */ - -.text-h1, h1 { - font-size: 2.3rem; -} -.text-h2, h2 { - font-size: 2.25rem; -} -.text-h3, h3 { - font-size: 2rem; -} -.text-h4, h4 { - font-size: 1.6rem; -} -.text-h5, h5 { - font-size: 1.3rem; -} -.text-h6, h6 { - font-size: 1.125rem; -} -.text-subtitle1 { - font-size: 1.06rem; -} -.text-subtitle2 { - font-size: 1rem; -} -.text-body1 { - font-size: .875rem; -} -.text-body2 { - font-size: .875rem; -} -.text-caption { - font-size: .875rem; -} -.text-overline { - font-size: .8rem; -} - -h1, h2, h3, h4, h5, h6 { - padding: 0; - margin-top: 0; - margin-bottom: 4px; -} - -/* Colors */ - -.text-primary { - color: $color-main; -} -.text-secondary { - color: $color-font-light; -} - -/* Helpers */ - -.text-uppercase { - text-transform: uppercase; -} -.text-center { - text-align: center; -} -.text-right { - text-align: right; -} -.text-left { - text-align: left; -} +@import "./variables"; + +/* Headings */ + +.text-h1, h1 { + font-size: 2.3rem; +} +.text-h2, h2 { + font-size: 2.25rem; +} +.text-h3, h3 { + font-size: 2rem; +} +.text-h4, h4 { + font-size: 1.6rem; +} +.text-h5, h5 { + font-size: 1.3rem; +} +.text-h6, h6 { + font-size: 1.125rem; +} +.text-subtitle1 { + font-size: 1.06rem; +} +.text-subtitle2 { + font-size: 1rem; +} +.text-body1 { + font-size: .875rem; +} +.text-body2 { + font-size: .875rem; +} +.text-caption { + font-size: .875rem; +} +.text-overline { + font-size: .8rem; +} +.text-capitalize { + text-transform: capitalize; +} + +h1, h2, h3, h4, h5, h6 { + padding: 0; + margin-top: 0; + margin-bottom: 4px; +} + +/* Colors */ + +.text-primary { + color: $color-main; +} +.text-secondary { + color: $color-font-light; +} + +/* Helpers */ + +.text-uppercase { + text-transform: uppercase; +} +.text-center { + text-align: center; +} +.text-right { + text-align: right; +} +.text-left { + text-align: left; +} diff --git a/front/salix/components/descriptor/style.scss b/front/salix/components/descriptor/style.scss index 27f482f26..b96e900c4 100644 --- a/front/salix/components/descriptor/style.scss +++ b/front/salix/components/descriptor/style.scss @@ -7,22 +7,24 @@ vn-descriptor-content { .photo { position: relative; + width: 100%; + text-align: center; + overflow: hidden; & > img[ng-src] { min-height: 16em; display: block; - max-width: 100%; height: 256px; } vn-float-button { - position: absolute; - margin: 1em; - bottom: 0; + position: absolute; + margin: 1em; + bottom: 0; right: 0 } } - + & > vn-spinner { display: block; height: 40px; @@ -39,7 +41,7 @@ vn-descriptor-content { align-items: stretch; color: $color-font-dark; - & > a, + & > a, & > vn-icon-button { display: flex; min-width: 45px; @@ -89,7 +91,7 @@ vn-descriptor-content { display: flex; align-items: center; justify-content: center; - + & > vn-icon { padding: $spacing-xs $spacing-sm; font-size: 1.5rem; diff --git a/front/salix/components/log/index.html b/front/salix/components/log/index.html index c6b1ade2a..d5675975b 100644 --- a/front/salix/components/log/index.html +++ b/front/salix/components/log/index.html @@ -10,19 +10,18 @@ + class="vn-w-sm vn-px-sm">
- -
+ +
+ + {{::$ctrl.relativeDate(log.creationDate)}}
- - {{::$ctrl.actionsText[log.action]}} - -
-
- - {{::log.changedModelI18n}} - - - #{{::log.changedModelId}} - - - {{::log.changedModelValue}} - -
-
- - - - -
- - - - {{::prop.nameI18n}}: - - , - -
-
- - {{::prop.nameI18n}}: - - - - ← - -
-
-
- - {{::log.description}} - - - No changes +
+ + {{::log.changedModelI18n}}
+
+
+ #{{::log.changedModelId}} + {{::log.changedModelValue}} +
+
+ + + + + + {{::prop.nameI18n}}: + + , + +
+
+ + {{::prop.nameI18n}}: + + + + ← + +
+
+
+ + {{::log.description}} +
@@ -114,10 +100,6 @@
- - -
+ + + + + + + + show-field="changedModelI18n" + data="$ctrl.models" + class="changed-model"> + - + @@ -199,7 +195,7 @@ label="To" ng-model="filter.to"> - + diff --git a/front/salix/components/log/index.js b/front/salix/components/log/index.js index 803eea45e..7452c6636 100644 --- a/front/salix/components/log/index.js +++ b/front/salix/components/log/index.js @@ -1,5 +1,6 @@ import ngModule from '../../module'; import Section from '../section'; +import {hashToColor} from 'core/lib/string'; import './style.scss'; const validDate = /^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(.[0-9]+)?(Z)?$/; @@ -7,11 +8,12 @@ const validDate = /^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[ export default class Controller extends Section { constructor($element, $) { super($element, $); + this.hashToColor = hashToColor; this.actionsText = { insert: 'Creates', - update: 'Updates', + update: 'Edits', delete: 'Deletes', - select: 'Views' + select: 'Accesses' }; this.actionsClass = { insert: 'success', @@ -19,6 +21,12 @@ export default class Controller extends Section { delete: 'alert', select: 'notice' }; + this.actionsIcon = { + insert: 'add', + update: 'edit', + delete: 'remove', + select: 'visibility' + }; this.filter = { include: [{ relation: 'user', @@ -55,14 +63,14 @@ export default class Controller extends Section { set logs(value) { this._logs = value; - if (!this.logs) return; + if (!value) return; const empty = {}; const validations = window.validations; for (const log of value) { const oldValues = log.oldInstance || empty; const newValues = log.newInstance || empty; const locale = validations[log.changedModel]?.locale || empty; - log.changedModelI18n = locale.name || log.changedModel; + log.changedModelI18n = firstUpper(locale.name) || log.changedModel; let props = Object.keys(oldValues).concat(Object.keys(newValues)); props = [...new Set(props)]; @@ -71,11 +79,27 @@ export default class Controller extends Section { for (const prop of props) { log.props.push({ name: prop, - nameI18n: locale.columns?.[prop] || prop, + nameI18n: firstUpper(locale.columns?.[prop]) || prop, old: this.castJsonValue(oldValues[prop]), new: this.castJsonValue(newValues[prop]) }); } + log.props.sort( + (a, b) => a.nameI18n.localeCompare(b.nameI18n)); + } + } + + get models() { + return this._models; + } + + set models(value) { + this._models = value; + if (!value) return; + for (const model of value) { + const name = model.changedModel; + model.changedModelI18n = + firstUpper(window.validations[name]?.locale?.name) || name; } } @@ -93,11 +117,6 @@ export default class Controller extends Section { return action == 'delete' ? prop.old : prop.new; } - toggleAttributes(log, changesEl, force) { - log.expand = force; - changesEl.classList.toggle('expanded', force); - } - relativeDate(dateVal) { if (dateVal == null) return ''; const date = new Date(dateVal); @@ -130,8 +149,17 @@ export default class Controller extends Section { function getParam(prop, value) { if (value == null || value == '') return null; switch (prop) { - case 'changedModelValue': - return {[prop]: {like: `%${value}%`}}; + case 'search': + const or = [{changedModelId: value}]; + if (!/^[0-9]+$/.test(value)) + or.push({changedModelValue: {like: `%${value}%`}}); + return {or}; + case 'changes': + return {or: [ + {oldInstance: {like: `%${value}%`}}, + {newInstance: {like: `%${value}%`}}, + {description: {like: `%${value}%`}} + ]}; case 'who': switch (value) { case 'all': @@ -195,6 +223,10 @@ export default class Controller extends Section { } } +function firstUpper(str) { + return str && str.charAt(0).toUpperCase() + str.substr(1); +} + ngModule.vnComponent('vnLog', { controller: Controller, template: require('./index.html'), diff --git a/front/salix/components/log/locale/es.yml b/front/salix/components/log/locale/es.yml index 385b42147..95d930716 100644 --- a/front/salix/components/log/locale/es.yml +++ b/front/salix/components/log/locale/es.yml @@ -1,5 +1,8 @@ Date: Fecha -Model: Modelo +Concept: Concepto +Search: Buscar +Search by id or concept: Buscar por identificador o concepto +Entity: Entidad Action: Acción Author: Autor Before: Antes @@ -7,12 +10,12 @@ After: Despues History: Historial Name: Nombre Creates: Crea -Updates: Actualiza +Edits: Modifica Deletes: Elimina -Views: Visualiza +Accesses: Accede System: Sistema +Details: Detalles note: nota Changes: Cambios -No changes: No hay cambios today: hoy yesterday: ayer diff --git a/front/salix/components/log/style.scss b/front/salix/components/log/style.scss index 381b99039..7a5e18049 100644 --- a/front/salix/components/log/style.scss +++ b/front/salix/components/log/style.scss @@ -1,4 +1,5 @@ @import "variables"; +@import "effects"; vn-log { .change { @@ -45,31 +46,52 @@ vn-log { overflow: hidden; & > .header { + display: flex; + justify-content: space-between; + align-items: center; overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - & > .chip { - padding: 2px 4px; - border-radius: 4px; - display: inline-block; - color: $color-font-bg; + & > .action-model { + display: inline-flex; + overflow: hidden; - &.notice { - background-color: $color-notice-medium; - } - &.success { - background-color: $color-success-medium; - } - &.warning { - background-color: $color-main-medium; - } - &.alert { - background-color: lighten($color-alert, 5%); + & > .model-name { + display: inline-block; + padding: 2px 5px; + color: $color-font-dark; + border-radius: 8px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } } - .date { - float: right; + & > .action-date { + white-space: nowrap; + + & > .action { + display: inline-flex; + align-items: center; + justify-content: center; + color: $color-font-bg; + vertical-align: middle; + border-radius: 50%; + width: 24px; + height: 24px; + font-size: 1.4em; + + &.notice { + background-color: $color-notice-medium + } + &.success { + background-color: $color-success-medium; + } + &.warning { + background-color: $color-main-medium; + } + &.alert { + background-color: lighten($color-alert, 5%); + } + } } } & > .model { @@ -77,16 +99,12 @@ vn-log { text-overflow: ellipsis; white-space: nowrap; - & > .model-name { - text-transform: capitalize; - } & > .model-value { font-style: italic; - color: #c7bd2b; } & > .model-id { color: $color-font-secondary; - font-size: .9em; + font-size: .9rem; } } } @@ -94,59 +112,35 @@ vn-log { .changes { overflow: hidden; background-color: rgba(255, 255, 255, .05); - border-radius: 4px; - color: $color-font-secondary; - transition: max-height 150ms ease-in-out; - max-height: 28px; + color: $color-font-light; position: relative; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + min-height: 34px; + box-sizing: border-box; - & > .expand-button, - & > .shrink-button { - display: none; + & > vn-icon { + @extend %clickable; + float: right; + position: relative; + transition-property: transform, background-color; + transition-duration: 150ms; + margin: -5px; + margin-left: 4px; + padding: 1px; + border-radius: 50%; } - &.props { - padding-right: 24px; + &.expanded { + text-overflow: initial; + white-space: initial; - & > .expand-button, - & > .shrink-button { - position: absolute; - top: 6px; - right: 8px; - font-size: inherit; - float: right; - cursor: pointer; - } - & > .expand-button { - display: block; - } - &.expanded { - max-height: 500px; - padding-right: 0; - - & > .changes-wrapper { - text-overflow: initial; - white-space: initial; - } - & > .shrink-button { - display: block; - } - & > .expand-button { - display: none; - } + & > vn-icon { + transform: rotate(180deg); } } - & > .changes-wrapper { - padding: 4px 6px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - - & > .no-changes { - font-style: italic; - } - .json-field { - text-transform: capitalize; - } + & > .no-changes { + font-style: italic; } } } diff --git a/front/salix/components/reset-password/index.js b/front/salix/components/reset-password/index.js index 20c6c34fe..a3ca03237 100644 --- a/front/salix/components/reset-password/index.js +++ b/front/salix/components/reset-password/index.js @@ -33,7 +33,7 @@ export default class Controller { const newPassword = this.newPassword; - this.$http.post('users/reset-password', {newPassword}, {headers}) + this.$http.post('VnUsers/reset-password', {newPassword}, {headers}) .then(() => { this.vnApp.showSuccess(this.$translate.instant('Password changed!')); this.$state.go('login'); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index e950b981b..a517a6183 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -171,5 +171,6 @@ "Added observation": "Added observation", "Comment added to client": "Comment added to client", "This ticket is already a refund": "This ticket is already a refund", - "A claim with that sale already exists": "A claim with that sale already exists" + "A claim with that sale already exists": "A claim with that sale already exists", + "ASSIGN_ZONE_FIRST": "Assign zone first" } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 45993bdd5..d88a4ebc9 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -84,6 +84,7 @@ "The current ticket can't be modified": "El ticket actual no puede ser modificado", "The current claim can't be modified": "La reclamación actual no puede ser modificada", "The sales of this ticket can't be modified": "Las lineas de este ticket no pueden ser modificadas", + "The sales do not exists": "La(s) línea(s) seleccionada(s) no existe(n)", "Please select at least one sale": "Por favor selecciona al menos una linea", "All sales must belong to the same ticket": "Todas las lineas deben pertenecer al mismo ticket", "NO_ZONE_FOR_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada", @@ -290,5 +291,7 @@ "isTaxDataChecked": "Datos comprobados", "comercialId": "Id comercial", "comercialName": "Comercial", - "Invalid NIF for VIES": "Invalid NIF for VIES" -} \ No newline at end of file + "Invalid NIF for VIES": "Invalid NIF for VIES", + "Ticket does not exist": "Este ticket no existe", + "Ticket is already signed": "Este ticket ya ha sido firmado" +} diff --git a/modules/account/back/locale/mail-forward/en.yml b/modules/account/back/locale/mail-forward/en.yml new file mode 100644 index 000000000..2e136e664 --- /dev/null +++ b/modules/account/back/locale/mail-forward/en.yml @@ -0,0 +1,4 @@ +name: mail forward +columns: + account: account + forwardTo: forward to diff --git a/modules/account/back/locale/mail-forward/es.yml b/modules/account/back/locale/mail-forward/es.yml new file mode 100644 index 000000000..3e81f833e --- /dev/null +++ b/modules/account/back/locale/mail-forward/es.yml @@ -0,0 +1,4 @@ +name: reenvio de correo +columns: + account: cuenta + forwardTo: reenviar a diff --git a/modules/account/back/locale/mail/es.yml b/modules/account/back/locale/mail/es.yml index a0b02b45f..340f7ec50 100644 --- a/modules/account/back/locale/mail/es.yml +++ b/modules/account/back/locale/mail/es.yml @@ -1,4 +1,4 @@ -name: mail +name: correo electrónico columns: id: id receiver: receptor diff --git a/modules/account/back/locale/role-inherit/en.yml b/modules/account/back/locale/role-inherit/en.yml new file mode 100644 index 000000000..760881325 --- /dev/null +++ b/modules/account/back/locale/role-inherit/en.yml @@ -0,0 +1,4 @@ +name: subrole +columns: + role: rol + inheritsFrom: inherits diff --git a/modules/account/back/locale/role-inherit/es.yml b/modules/account/back/locale/role-inherit/es.yml new file mode 100644 index 000000000..c352c6ff2 --- /dev/null +++ b/modules/account/back/locale/role-inherit/es.yml @@ -0,0 +1,4 @@ +name: subrol +columns: + role: rol + inheritsFrom: hereda diff --git a/modules/account/back/locale/role/en.yml b/modules/account/back/locale/role/en.yml new file mode 100644 index 000000000..69199dfce --- /dev/null +++ b/modules/account/back/locale/role/en.yml @@ -0,0 +1,5 @@ +name: role +columns: + id: id + name: name + description: description diff --git a/modules/account/back/locale/role/es.yml b/modules/account/back/locale/role/es.yml new file mode 100644 index 000000000..ee025be0f --- /dev/null +++ b/modules/account/back/locale/role/es.yml @@ -0,0 +1,5 @@ +name: rol +columns: + id: id + name: nombre + description: descripción diff --git a/back/locale/account/en.yml b/modules/account/back/locale/vn-user/en.yml similarity index 84% rename from back/locale/account/en.yml rename to modules/account/back/locale/vn-user/en.yml index 0d6c5db80..135cf75b4 100644 --- a/back/locale/account/en.yml +++ b/modules/account/back/locale/vn-user/en.yml @@ -1,4 +1,4 @@ -name: account +name: user columns: id: id name: name @@ -6,7 +6,7 @@ columns: nickname: nickname lang: lang password: password - bcryptPassword: bcrypt password + bcryptPassword: BCRYPT password active: active email: email emailVerified: email verified diff --git a/back/locale/account/es.yml b/modules/account/back/locale/vn-user/es.yml similarity index 59% rename from back/locale/account/es.yml rename to modules/account/back/locale/vn-user/es.yml index 79e8a8cc6..53086ae2d 100644 --- a/back/locale/account/es.yml +++ b/modules/account/back/locale/vn-user/es.yml @@ -1,4 +1,4 @@ -name: cuenta +name: usuario columns: id: id name: nombre @@ -6,12 +6,12 @@ columns: nickname: apodo lang: idioma password: contraseña - bcryptPassword: contraseña bcrypt + bcryptPassword: contraseña BCRYPT active: activo - email: email - emailVerified: email verificado + email: correo electrónico + emailVerified: correo verificado created: creado updated: actualizado image: imagen - hasGrant: tiene permiso + hasGrant: puede delegar userFk: usuario diff --git a/modules/claim/back/locale/claim-beginning/en.yml b/modules/claim/back/locale/claim-beginning/en.yml index 47cc29c69..4c1520704 100644 --- a/modules/claim/back/locale/claim-beginning/en.yml +++ b/modules/claim/back/locale/claim-beginning/en.yml @@ -1,4 +1,4 @@ -name: claim beginning +name: beginning columns: id: id quantity: quantity diff --git a/modules/claim/back/locale/claim-beginning/es.yml b/modules/claim/back/locale/claim-beginning/es.yml index 5e898c25e..20110cb52 100644 --- a/modules/claim/back/locale/claim-beginning/es.yml +++ b/modules/claim/back/locale/claim-beginning/es.yml @@ -1,4 +1,4 @@ -name: comienzo reclamación +name: comienzo columns: id: id quantity: cantidad diff --git a/modules/claim/back/locale/claim-development/en.yml b/modules/claim/back/locale/claim-development/en.yml index 054381e67..875cbf121 100644 --- a/modules/claim/back/locale/claim-development/en.yml +++ b/modules/claim/back/locale/claim-development/en.yml @@ -1,4 +1,4 @@ -name: claim development +name: development columns: id: id claimFk: claim diff --git a/modules/claim/back/locale/claim-development/es.yml b/modules/claim/back/locale/claim-development/es.yml index d5223e755..c95a1c0e7 100644 --- a/modules/claim/back/locale/claim-development/es.yml +++ b/modules/claim/back/locale/claim-development/es.yml @@ -1,4 +1,4 @@ -name: desarrollo reclamación +name: desarrollo columns: id: id claimFk: reclamación diff --git a/modules/claim/back/locale/claim-dms/en.yml b/modules/claim/back/locale/claim-dms/en.yml index c76c364e7..4b54ca19b 100644 --- a/modules/claim/back/locale/claim-dms/en.yml +++ b/modules/claim/back/locale/claim-dms/en.yml @@ -1,4 +1,4 @@ -name: claim dms +name: document columns: dmsFk: dms claimFk: claim diff --git a/modules/claim/back/locale/claim-dms/es.yml b/modules/claim/back/locale/claim-dms/es.yml index 949e20a36..d471b1ff6 100644 --- a/modules/claim/back/locale/claim-dms/es.yml +++ b/modules/claim/back/locale/claim-dms/es.yml @@ -1,4 +1,4 @@ -name: documento reclamación +name: documento columns: dmsFk: dms claimFk: reclamación diff --git a/modules/claim/back/locale/claim-end/en.yml b/modules/claim/back/locale/claim-end/en.yml index f9e736d76..4565cd579 100644 --- a/modules/claim/back/locale/claim-end/en.yml +++ b/modules/claim/back/locale/claim-end/en.yml @@ -1,4 +1,4 @@ -name: claim end +name: end columns: id: id claimFk: claim diff --git a/modules/claim/back/locale/claim-end/es.yml b/modules/claim/back/locale/claim-end/es.yml index 9855eca03..e5511c166 100644 --- a/modules/claim/back/locale/claim-end/es.yml +++ b/modules/claim/back/locale/claim-end/es.yml @@ -1,4 +1,4 @@ -name: final reclamación +name: finalización columns: id: id claimFk: reclamación diff --git a/modules/claim/back/locale/claim-observation/en.yml b/modules/claim/back/locale/claim-observation/en.yml index 772ea038c..a0ba2c449 100644 --- a/modules/claim/back/locale/claim-observation/en.yml +++ b/modules/claim/back/locale/claim-observation/en.yml @@ -1,4 +1,4 @@ -name: claim observation +name: observation columns: id: id claimFk: claim diff --git a/modules/claim/back/locale/claim-observation/es.yml b/modules/claim/back/locale/claim-observation/es.yml index fae3a1ae9..9ea5e275c 100644 --- a/modules/claim/back/locale/claim-observation/es.yml +++ b/modules/claim/back/locale/claim-observation/es.yml @@ -1,4 +1,4 @@ -name: observación reclamación +name: observación columns: id: id claimFk: reclamación diff --git a/modules/claim/back/methods/claim/createFromSales.js b/modules/claim/back/methods/claim/createFromSales.js index 10d0b9b28..07bdb30aa 100644 --- a/modules/claim/back/methods/claim/createFromSales.js +++ b/modules/claim/back/methods/claim/createFromSales.js @@ -59,12 +59,14 @@ module.exports = Self => { const landedPlusWeek = new Date(ticket.landed); landedPlusWeek.setDate(landedPlusWeek.getDate() + 7); - const hasClaimManagerRole = await models.VnUser.hasRole(userId, 'claimManager', myOptions); const isClaimable = landedPlusWeek >= Date.vnNew(); + const canCreateClaimAfterDeadline = + await models.ACL.checkAccessAcl(ctx, 'Claim', 'createAfterDeadline', 'WRITE'); + if (ticket.isDeleted) throw new UserError(`You can't create a claim for a removed ticket`); - if (!isClaimable && !hasClaimManagerRole) + if (!isClaimable && !canCreateClaimAfterDeadline) throw new UserError(`You can't create a claim from a ticket delivered more than seven days ago`); const newClaim = await Self.create({ diff --git a/modules/claim/back/methods/claim/updateClaim.js b/modules/claim/back/methods/claim/updateClaim.js index f10c68b21..cc7392e39 100644 --- a/modules/claim/back/methods/claim/updateClaim.js +++ b/modules/claim/back/methods/claim/updateClaim.js @@ -46,7 +46,6 @@ module.exports = Self => { Self.updateClaim = async(ctx, id, options) => { const models = Self.app.models; - const userId = ctx.req.accessToken.userId; const args = ctx.args; let tx; const myOptions = {}; @@ -81,9 +80,9 @@ module.exports = Self => { if (args.claimStateFk) { const canEditOldState = await models.ClaimState.isEditable(ctx, claim.claimStateFk, myOptions); const canEditNewState = await models.ClaimState.isEditable(ctx, args.claimStateFk, myOptions); - const isClaimManager = await models.VnUser.hasRole(userId, 'claimManager', myOptions); + const canEditState = await models.ACL.checkAccessAcl(ctx, 'Claim', 'editState', 'WRITE'); - if (!canEditOldState || !canEditNewState || changedHasToPickUp && !isClaimManager) + if (!canEditOldState || !canEditNewState || changedHasToPickUp && !canEditState) throw new UserError(`You don't have enough privileges to change that field`); } diff --git a/modules/client/back/locale/address/en.yml b/modules/client/back/locale/address/en.yml index 3d090ba89..00f3b15f5 100644 --- a/modules/client/back/locale/address/en.yml +++ b/modules/client/back/locale/address/en.yml @@ -18,3 +18,4 @@ columns: addressFk: address incotermsFk: incoterms customsAgentFk: customs agent + isDefaultAddress: default diff --git a/modules/client/back/locale/address/es.yml b/modules/client/back/locale/address/es.yml index 1379f75a4..f2b954124 100644 --- a/modules/client/back/locale/address/es.yml +++ b/modules/client/back/locale/address/es.yml @@ -18,3 +18,4 @@ columns: addressFk: dirección incotermsFk: incoterms customsAgentFk: agente adunanas + isDefaultAddress: predeterminada diff --git a/modules/client/back/locale/client-contact/en.yml b/modules/client/back/locale/client-contact/en.yml index 5bd6e25db..2b47f5b4b 100644 --- a/modules/client/back/locale/client-contact/en.yml +++ b/modules/client/back/locale/client-contact/en.yml @@ -1,4 +1,4 @@ -name: client contact +name: contact columns: id: id name: name diff --git a/modules/client/back/locale/client-contact/es.yml b/modules/client/back/locale/client-contact/es.yml index 5802c0dde..0116a537a 100644 --- a/modules/client/back/locale/client-contact/es.yml +++ b/modules/client/back/locale/client-contact/es.yml @@ -1,4 +1,4 @@ -name: contacto cliente +name: contacto columns: id: id name: nombre diff --git a/modules/client/back/locale/client-dms/en.yml b/modules/client/back/locale/client-dms/en.yml index c8ad68635..de4d6c434 100644 --- a/modules/client/back/locale/client-dms/en.yml +++ b/modules/client/back/locale/client-dms/en.yml @@ -1,4 +1,4 @@ -name: client dms +name: document columns: dmsFk: dms clientFk: client diff --git a/modules/client/back/locale/client-dms/es.yml b/modules/client/back/locale/client-dms/es.yml index c683f4764..e1744b019 100644 --- a/modules/client/back/locale/client-dms/es.yml +++ b/modules/client/back/locale/client-dms/es.yml @@ -1,4 +1,4 @@ -name: documento cliente +name: documento columns: dmsFk: dms clientFk: client diff --git a/modules/client/back/locale/client-observation/en.yml b/modules/client/back/locale/client-observation/en.yml index 2dd8393ae..0cf5e0dc1 100644 --- a/modules/client/back/locale/client-observation/en.yml +++ b/modules/client/back/locale/client-observation/en.yml @@ -1,4 +1,4 @@ -name: client observation +name: observation columns: id: id clientFk: client diff --git a/modules/client/back/locale/client-observation/es.yml b/modules/client/back/locale/client-observation/es.yml index 0fc6bbf04..b04ae63d9 100644 --- a/modules/client/back/locale/client-observation/es.yml +++ b/modules/client/back/locale/client-observation/es.yml @@ -1,4 +1,4 @@ -name: observación cliente +name: observación columns: id: id clientFk: cliente diff --git a/modules/client/back/locale/client-sample/en.yml b/modules/client/back/locale/client-sample/en.yml index 77639fbb4..4c355ab7f 100644 --- a/modules/client/back/locale/client-sample/en.yml +++ b/modules/client/back/locale/client-sample/en.yml @@ -1,4 +1,4 @@ -name: client sample +name: sample columns: id: id created: created @@ -6,3 +6,5 @@ columns: typeFk: type userFk: user companyFk: company + workerFk: worker + balance: balance diff --git a/modules/client/back/locale/client-sample/es.yml b/modules/client/back/locale/client-sample/es.yml index 6311eb25a..5293adaa8 100644 --- a/modules/client/back/locale/client-sample/es.yml +++ b/modules/client/back/locale/client-sample/es.yml @@ -1,4 +1,4 @@ -name: muestra cliente +name: muestra columns: id: id created: creado @@ -6,3 +6,5 @@ columns: typeFk: tipo userFk: usuario companyFk: compañia + workerFk: trabajador + balance: balance diff --git a/modules/client/back/locale/client/en.yml b/modules/client/back/locale/client/en.yml index 71048f657..74384461c 100644 --- a/modules/client/back/locale/client/en.yml +++ b/modules/client/back/locale/client/en.yml @@ -2,7 +2,7 @@ name: client columns: id: id name: name - fi: fi + fi: tax identifier socialName: socialName contact: contact street: street @@ -14,22 +14,22 @@ columns: isActive: active credit: credit creditInsurance: credit insurance - iban: iban + iban: IBAN dueDay: due day isEqualizated: equalizated isFreezed: freezed hasToInvoiceByAddress: invoice by address hasToInvoice: has to invoice - isToBeMailed: be mailed - hasSepaVnl: sepa nnl - hasLcr: lcr - hasCoreVnl: core vnl - hasCoreVnh: core vnh + isToBeMailed: mailed + hasSepaVnl: sepa VNL + hasLcr: LCR + hasCoreVnl: core VNL + hasCoreVnh: core VNH hasIncoterms: incoterms isTaxDataChecked: tax data checked - eypbc: eypbc + eypbc: EYPBC quality: quality - isVies: vies + isVies: VIES isRelevant: relevant accountingAccount: accounting account created: created @@ -47,4 +47,9 @@ columns: defaultAddressFk: default address bankEntityFk: bank entity transferorFk: transferor + riskCalculated: risk calculated + isCreatedAsServed: created as served + hasInvoiceSimplified: simplified invoice + typeFk: type + lastSalesPersonFk: last salesperson diff --git a/modules/client/back/locale/client/es.yml b/modules/client/back/locale/client/es.yml index 04e391af0..47bf896d9 100644 --- a/modules/client/back/locale/client/es.yml +++ b/modules/client/back/locale/client/es.yml @@ -2,7 +2,7 @@ name: cliente columns: id: id name: nombre - fi: fi + fi: identificador fiscal socialName: nombre social contact: contacto street: calle @@ -14,27 +14,27 @@ columns: isActive: activo credit: crédito creditInsurance: seguro crédito - iban: iban + iban: IBAN dueDay: día vencimiento isEqualizated: igualado isFreezed: congelado hasToInvoiceByAddress: factura por dirección hasToInvoice: tiene que facturar isToBeMailed: envío por email - hasSepaVnl: sepa nnl - hasLcr: lcr - hasCoreVnl: centro vnl - hasCoreVnh: cenrto vnh + hasSepaVnl: sepa VNL + hasLcr: LCR + hasCoreVnl: centro VNL + hasCoreVnh: centro VNH hasIncoterms: incoterms isTaxDataChecked: datos fiscales comprobados - eypbc: eypbc + eypbc: EYPBC quality: calidad - isVies: vies + isVies: VIES isRelevant: importante accountingAccount: cuenta contable created: creado sageTaxTypeFk: tipo impuesto sage - sageTransactionTypeFk: tipo transacción sage + sageTransactionTypeFk: tipo transacción Sage businessTypeFk: tipo negocio salesPersonFk: comercial hasElectronicInvoice: factura electrónica @@ -47,4 +47,9 @@ columns: defaultAddressFk: dirección predeterminada bankEntityFk: entidad bancaria transferorFk: cedente + riskCalculated: riesgo calculado + isCreatedAsServed: creado como servido + hasInvoiceSimplified: factura simple + typeFk: tipo + lastSalesPersonFk: último comercial diff --git a/modules/client/back/locale/tpv-transaction/en.yml b/modules/client/back/locale/tpv-transaction/en.yml index fbe1bbadc..c70914495 100644 --- a/modules/client/back/locale/tpv-transaction/en.yml +++ b/modules/client/back/locale/tpv-transaction/en.yml @@ -1,4 +1,4 @@ -name: tpv transaction +name: TPV transaction columns: id: id merchantFk: merchant diff --git a/modules/client/back/locale/tpv-transaction/es.yml b/modules/client/back/locale/tpv-transaction/es.yml index c751b354d..7d412ba66 100644 --- a/modules/client/back/locale/tpv-transaction/es.yml +++ b/modules/client/back/locale/tpv-transaction/es.yml @@ -1,4 +1,4 @@ -name: transacción tpv +name: transacción TPV columns: id: id merchantFk: comerciante diff --git a/modules/client/back/methods/client/updateAddress.js b/modules/client/back/methods/client/updateAddress.js index e521870fd..7342b28f1 100644 --- a/modules/client/back/methods/client/updateAddress.js +++ b/modules/client/back/methods/client/updateAddress.js @@ -87,15 +87,15 @@ module.exports = function(Self) { Self.updateAddress = async(ctx, clientId, addressId, options) => { const models = Self.app.models; const args = ctx.args; - const userId = ctx.req.accessToken.userId; const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); - const isSalesAssistant = await models.VnUser.hasRole(userId, 'salesAssistant', myOptions); + const canEditAddressLogifloraAllowed = + await models.ACL.checkAccessAcl(ctx, 'Client', 'editAddressLogifloraAllowed'); - if (args.isLogifloraAllowed && !isSalesAssistant) + if (args.isLogifloraAllowed && !canEditAddressLogifloraAllowed) throw new UserError(`You don't have enough privileges`); const address = await models.Address.findOne({ diff --git a/modules/client/back/methods/client/updateFiscalData.js b/modules/client/back/methods/client/updateFiscalData.js index c63dc3991..697c567a3 100644 --- a/modules/client/back/methods/client/updateFiscalData.js +++ b/modules/client/back/methods/client/updateFiscalData.js @@ -131,9 +131,10 @@ module.exports = Self => { myOptions.transaction = tx; } try { - const isSalesAssistant = await models.VnUser.hasRole(userId, 'salesAssistant', myOptions); + const canEditNotTaxDataChecked = + await models.ACL.checkAccessAcl(ctx, 'Client', 'editFiscalDataWithoutTaxDataCheck', 'WRITE'); const client = await models.Client.findById(clientId, null, myOptions); - if (!isSalesAssistant && client.isTaxDataChecked) + if (!canEditNotTaxDataChecked && client.isTaxDataChecked) throw new UserError(`Not enough privileges to edit a client with verified data`); // Sage data validation const taxDataChecked = args.isTaxDataChecked; diff --git a/modules/client/back/methods/client/updateUser.js b/modules/client/back/methods/client/updateUser.js index 479b4da47..55f1accdd 100644 --- a/modules/client/back/methods/client/updateUser.js +++ b/modules/client/back/methods/client/updateUser.js @@ -2,6 +2,7 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethodCtx('updateUser', { description: 'Updates the user information', + accessType: 'WRITE', accepts: [ { arg: 'id', @@ -32,7 +33,6 @@ module.exports = Self => { Self.updateUser = async function(ctx, id, options) { const models = Self.app.models; - const userId = ctx.req.accessToken.userId; let tx; const myOptions = {}; @@ -45,9 +45,8 @@ module.exports = Self => { } try { - const isSalesPerson = await models.VnUser.hasRole(userId, 'salesPerson', myOptions); - - if (!isSalesPerson) + const canEdit = await models.ACL.checkAccessAcl(ctx, 'Client', 'updateUser', 'WRITE'); + if (!canEdit) throw new UserError(`Not enough privileges to edit a client`); const isClient = await models.Client.findById(id, null, myOptions); diff --git a/modules/client/back/methods/defaulter/filter.js b/modules/client/back/methods/defaulter/filter.js index 748581913..736c29f9c 100644 --- a/modules/client/back/methods/defaulter/filter.js +++ b/modules/client/back/methods/defaulter/filter.js @@ -67,9 +67,13 @@ module.exports = Self => { uw.id workerFk, uw.name workerName, c.creditInsurance, - d.defaulterSinced + d.defaulterSinced, + cn.country, + pm.name payMethod FROM vn.defaulter d JOIN vn.client c ON c.id = d.clientFk + JOIN vn.country cn ON cn.id = c.countryFk + JOIN vn.payMethod pm ON pm.id = c.payMethodFk LEFT JOIN vn.clientObservation co ON co.clientFk = c.id LEFT JOIN account.user u ON u.id = c.salesPersonFk LEFT JOIN account.user uw ON uw.id = co.workerFk diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index 56adc8b03..7b577fa98 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -218,9 +218,9 @@ module.exports = Self => { const models = Self.app.models; const loopBackContext = LoopBackContext.getCurrentContext(); - const userId = loopBackContext.active.accessToken.userId; + const accessToken = {req: loopBackContext.active.accessToken}; - const isSalesAssistant = await models.VnUser.hasRole(userId, 'salesAssistant', ctx.options); + const editVerifiedDataWithoutTaxDataChecked = models.ACL.checkAccessAcl(accessToken, 'Client', 'editVerifiedDataWithoutTaxDataCheck', 'WRITE'); const hasChanges = orgData && changes; const isTaxDataChecked = hasChanges && (changes.isTaxDataChecked || orgData.isTaxDataChecked); @@ -232,8 +232,8 @@ module.exports = Self => { const sageTransactionType = hasChanges && (changes.sageTransactionTypeFk || orgData.sageTransactionTypeFk); const sageTransactionTypeChanged = hasChanges && orgData.sageTransactionTypeFk != sageTransactionType; - const cantEditVerifiedData = isTaxDataCheckedChanged && !isSalesAssistant; - const cantChangeSageData = (sageTaxTypeChanged || sageTransactionTypeChanged) && !isSalesAssistant; + const cantEditVerifiedData = isTaxDataCheckedChanged && !editVerifiedDataWithoutTaxDataChecked; + const cantChangeSageData = (sageTaxTypeChanged || sageTransactionTypeChanged) && !editVerifiedDataWithoutTaxDataChecked; if (cantEditVerifiedData || cantChangeSageData) throw new UserError(`You don't have enough privileges`); @@ -401,9 +401,10 @@ module.exports = Self => { Self.changeCredit = async function changeCredit(ctx, finalState, changes) { const models = Self.app.models; const userId = ctx.options.accessToken.userId; + const accessToken = {req: {accessToken: ctx.options.accessToken} }; - const isFinancialBoss = await models.VnUser.hasRole(userId, 'financialBoss', ctx.options); - if (!isFinancialBoss) { + const canEditCredit = await models.ACL.checkAccessAcl(accessToken, 'Client', 'editCredit', 'WRITE'); + if (!canEditCredit) { const lastCredit = await models.ClientCredit.findOne({ where: { clientFk: finalState.id @@ -412,10 +413,9 @@ module.exports = Self => { }, ctx.options); const lastAmount = lastCredit && lastCredit.amount; - const lastWorkerId = lastCredit && lastCredit.workerFk; - const lastWorkerIsFinancialBoss = await models.VnUser.hasRole(lastWorkerId, 'financialBoss', ctx.options); + const lastCreditIsNotEditable = !await models.ACL.checkAccessAcl(accessToken, 'Client', 'isNotEditableCredit', 'WRITE'); - if (lastAmount == 0 && lastWorkerIsFinancialBoss) + if (lastAmount == 0 && lastCreditIsNotEditable) throw new UserError(`You can't change the credit set to zero from a financialBoss`); const creditLimits = await models.ClientCreditLimit.find({ diff --git a/modules/client/back/models/defaulter.json b/modules/client/back/models/defaulter.json index ddff1d214..03d68ea71 100644 --- a/modules/client/back/models/defaulter.json +++ b/modules/client/back/models/defaulter.json @@ -29,6 +29,16 @@ "type": "belongsTo", "model": "Client", "foreignKey": "clientFk" + }, + "country": { + "type": "belongsTo", + "model": "Country", + "foreignKey": "country" + }, + "payMethod": { + "type": "belongsTo", + "model": "PayMethod", + "foreignKey": "payMethod" } } } \ No newline at end of file diff --git a/modules/client/front/defaulter/index.html b/modules/client/front/defaulter/index.html index 8f22629a9..4f662b62b 100644 --- a/modules/client/front/defaulter/index.html +++ b/modules/client/front/defaulter/index.html @@ -57,6 +57,13 @@ Comercial + + Country + + + P.Method + @@ -111,6 +118,12 @@ {{::defaulter.salesPersonName | dashIfEmpty}} + + {{::defaulter.country}} + + + {{::defaulter.payMethod}} + {{::defaulter.amount | currency: 'EUR': 2}} + + diff --git a/modules/entry/back/locale/entry-observation/en.yml b/modules/entry/back/locale/entry-observation/en.yml index efe908c9f..379683303 100644 --- a/modules/entry/back/locale/entry-observation/en.yml +++ b/modules/entry/back/locale/entry-observation/en.yml @@ -1,4 +1,4 @@ -name: entry observation +name: observation columns: id: id description: description diff --git a/modules/entry/back/locale/entry-observation/es.yml b/modules/entry/back/locale/entry-observation/es.yml index 43799ae00..8879f1e1b 100644 --- a/modules/entry/back/locale/entry-observation/es.yml +++ b/modules/entry/back/locale/entry-observation/es.yml @@ -1,4 +1,4 @@ -name: observación entrada +name: observación columns: id: id description: descripción diff --git a/modules/entry/front/basic-data/index.html b/modules/entry/front/basic-data/index.html index 0b3537fac..888205320 100644 --- a/modules/entry/front/basic-data/index.html +++ b/modules/entry/front/basic-data/index.html @@ -5,6 +5,11 @@ form="form" save="patch"> + + @@ -152,14 +157,14 @@ diff --git a/modules/invoiceOut/back/methods/invoiceOut/createPdf.js b/modules/invoiceOut/back/methods/invoiceOut/createPdf.js index a9c151ae4..dfdb3c1a7 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/createPdf.js +++ b/modules/invoiceOut/back/methods/invoiceOut/createPdf.js @@ -25,7 +25,6 @@ module.exports = Self => { Self.createPdf = async function(ctx, id, options) { const models = Self.app.models; - const userId = ctx.req.accessToken.userId; if (process.env.NODE_ENV == 'test') throw new UserError(`Action not allowed on the test environment`); @@ -43,9 +42,9 @@ module.exports = Self => { try { const invoiceOut = await Self.findById(id, null, myOptions); - const hasInvoicing = await models.VnUser.hasRole(userId, 'invoicing', myOptions); + const canCreatePdf = await models.ACL.checkAccessAcl(ctx, 'InvoiceOut', 'canCreatePdf', 'WRITE'); - if (invoiceOut.hasPdf && !hasInvoicing) + if (invoiceOut.hasPdf && !canCreatePdf) throw new UserError(`You don't have enough privileges`); await invoiceOut.updateAttributes({ diff --git a/modules/item/back/locale/item-barcode/en.yml b/modules/item/back/locale/item-barcode/en.yml index c1b20855f..16b18b163 100644 --- a/modules/item/back/locale/item-barcode/en.yml +++ b/modules/item/back/locale/item-barcode/en.yml @@ -1,4 +1,4 @@ -name: item barcode +name: barcode columns: id: id code: code diff --git a/modules/item/back/locale/item-barcode/es.yml b/modules/item/back/locale/item-barcode/es.yml index c1557f6d8..11d9f0c22 100644 --- a/modules/item/back/locale/item-barcode/es.yml +++ b/modules/item/back/locale/item-barcode/es.yml @@ -1,4 +1,4 @@ -name: código barras artículo +name: código barras columns: id: id code: código diff --git a/modules/item/back/locale/item-botanical/en.yml b/modules/item/back/locale/item-botanical/en.yml index f5a9e4c5a..03c66a097 100644 --- a/modules/item/back/locale/item-botanical/en.yml +++ b/modules/item/back/locale/item-botanical/en.yml @@ -1,4 +1,4 @@ -name: item botanical +name: botanical columns: itemFk: item genusFk: genus diff --git a/modules/item/back/locale/item-botanical/es.yml b/modules/item/back/locale/item-botanical/es.yml index 8e0a45491..ca7fd5bf1 100644 --- a/modules/item/back/locale/item-botanical/es.yml +++ b/modules/item/back/locale/item-botanical/es.yml @@ -1,4 +1,4 @@ -name: artículo botánico +name: botánico columns: itemFk: artículo genusFk: género diff --git a/modules/item/back/locale/item-tag/en.yml b/modules/item/back/locale/item-tag/en.yml index fee588b4c..8d8288a96 100644 --- a/modules/item/back/locale/item-tag/en.yml +++ b/modules/item/back/locale/item-tag/en.yml @@ -1,4 +1,4 @@ -name: item tag +name: tag columns: id: id value: value diff --git a/modules/item/back/locale/item-tag/es.yml b/modules/item/back/locale/item-tag/es.yml index 3e1d1a9cf..f9c9aac0b 100644 --- a/modules/item/back/locale/item-tag/es.yml +++ b/modules/item/back/locale/item-tag/es.yml @@ -1,4 +1,4 @@ -name: etiqueta artículo +name: etiqueta columns: id: id value: valor diff --git a/modules/item/back/locale/item-tax-country/en.yml b/modules/item/back/locale/item-tax-country/en.yml index 060ad9910..c85c5af43 100644 --- a/modules/item/back/locale/item-tax-country/en.yml +++ b/modules/item/back/locale/item-tax-country/en.yml @@ -1,4 +1,4 @@ -name: item tax country +name: country tax columns: id: id effectived: effectived diff --git a/modules/item/back/locale/item-tax-country/es.yml b/modules/item/back/locale/item-tax-country/es.yml index 2a0e6b5e2..48baf735b 100644 --- a/modules/item/back/locale/item-tax-country/es.yml +++ b/modules/item/back/locale/item-tax-country/es.yml @@ -1,7 +1,7 @@ -name: impuesto país del artículo +name: impuesto país columns: id: id effectived: efectivo itemFk: artículo countryFk: país - taxClassFk: clase impuestos + taxClassFk: clase impuesto diff --git a/modules/item/back/locale/item/en.yml b/modules/item/back/locale/item/en.yml index d63c95c70..39e465300 100644 --- a/modules/item/back/locale/item/en.yml +++ b/modules/item/back/locale/item/en.yml @@ -44,4 +44,6 @@ columns: intrastatFk: intrastat genericFk: generic itemFk: item + density: density + compression: compression diff --git a/modules/item/back/locale/item/es.yml b/modules/item/back/locale/item/es.yml index d65288954..4b75b4704 100644 --- a/modules/item/back/locale/item/es.yml +++ b/modules/item/back/locale/item/es.yml @@ -27,8 +27,8 @@ columns: value9: valor9 tag10: etiqueta10 value10: valor10 - itemPackingTypeFk: embalaje del artículo - hasKgPrice: tiene precio kg + itemPackingTypeFk: tipo embalaje + hasKgPrice: precio kg family: familia expenseFk: gasto minPrice: precio mínimo @@ -44,4 +44,6 @@ columns: intrastatFk: intrastat genericFk: genérico itemFk: artículo + density: densidad + compression: compresión diff --git a/modules/item/back/methods/item/getBalance.js b/modules/item/back/methods/item/getBalance.js index 50372652d..5751b0a04 100644 --- a/modules/item/back/methods/item/getBalance.js +++ b/modules/item/back/methods/item/getBalance.js @@ -26,8 +26,8 @@ module.exports = Self => { Object.assign(myOptions, options); const where = filter.where; - const query = 'CALL vn.item_getBalance(?, ?)'; - const [diary] = await Self.rawSql(query, [where.itemFk, where.warehouseFk], myOptions); + const query = 'CALL vn.item_getBalance(?, ?, ?)'; + const [diary] = await Self.rawSql(query, [where.itemFk, where.warehouseFk, where.date], myOptions); for (const entry of diary) if (entry.clientType === 'loses') entry.highlighted = true; diff --git a/modules/item/back/methods/item/specs/getBalance.spec.js b/modules/item/back/methods/item/specs/getBalance.spec.js index 779516b19..1ffd3c302 100644 --- a/modules/item/back/methods/item/specs/getBalance.spec.js +++ b/modules/item/back/methods/item/specs/getBalance.spec.js @@ -21,7 +21,8 @@ describe('item getBalance()', () => { const filter = { where: { itemFk: 1, - warehouseFk: 1 + warehouseFk: 1, + date: null } }; const results = await models.Item.getBalance(filter, options); @@ -45,14 +46,16 @@ describe('item getBalance()', () => { const firstFilter = { where: { itemFk: 1, - warehouseFk: 1 + warehouseFk: 1, + date: null } }; const secondFilter = { where: { itemFk: 2, - warehouseFk: 1 + warehouseFk: 1, + date: null } }; diff --git a/modules/item/front/descriptor/index.html b/modules/item/front/descriptor/index.html index 8e85e043f..d98eabe3e 100644 --- a/modules/item/front/descriptor/index.html +++ b/modules/item/front/descriptor/index.html @@ -1,3 +1,8 @@ + + + data="warehouses" + show-field="name" + value="id">> diff --git a/modules/item/front/diary/index.html b/modules/item/front/diary/index.html index 0f00f5854..481cec51a 100644 --- a/modules/item/front/diary/index.html +++ b/modules/item/front/diary/index.html @@ -25,6 +25,16 @@ ng-model="$ctrl.warehouseFk" label="Select warehouse"> + + + + @@ -44,7 +54,7 @@ - {{::sale.shipped | date:'dd/MM/yyyy' }} @@ -99,13 +109,13 @@ - - - diff --git a/modules/item/front/diary/index.js b/modules/item/front/diary/index.js index 03134913f..1d2e34a66 100644 --- a/modules/item/front/diary/index.js +++ b/modules/item/front/diary/index.js @@ -38,12 +38,8 @@ class Controller extends Section { if (value && value != this._warehouseFk) { this._warehouseFk = value; this.card.warehouseFk = value; + this.filter.where.warehouseFk = this.warehouseFk; - this.$state.go(this.$state.current.name, { - warehouseFk: value - }); - - this.filter.where.warehouseFk = value; this.$.model.refresh(); } } @@ -52,6 +48,28 @@ class Controller extends Section { return this._warehouseFk; } + set date(value) { + this._date = value; + this.filter.where.date = value; + this.filter.where.warehouseFk = this.warehouseFk; + + this.$.model.refresh(); + } + + get date() { + return this._date; + } + + set showOld(value) { + this._showOld = value; + if (!this._showOld) this.date = null; + else this.date = new Date(); + } + + get showOld() { + return this._showOld; + } + scrollToLine(lineFk) { this.$.$applyAsync(() => { const hashFk = this.lineFk || lineFk; diff --git a/modules/item/front/diary/locale/es.yml b/modules/item/front/diary/locale/es.yml index e00816d78..a312da774 100644 --- a/modules/item/front/diary/locale/es.yml +++ b/modules/item/front/diary/locale/es.yml @@ -1,4 +1,5 @@ In: Entrada Out: Salida Visible quantity: Cantidad visible -Ticket/Entry: Ticket/Entrada \ No newline at end of file +Ticket/Entry: Ticket/Entrada +Show what's before the inventory: Mostrar lo anterior al inventario diff --git a/modules/item/front/diary/style.scss b/modules/item/front/diary/style.scss index e8d261ec2..0a6cafcb9 100644 --- a/modules/item/front/diary/style.scss +++ b/modules/item/front/diary/style.scss @@ -27,4 +27,7 @@ vn-item-diary { overflow: hidden; text-overflow: ellipsis; } -} \ No newline at end of file + .table-check{ + justify-content: center; + } +} diff --git a/modules/item/front/fixed-price/style.scss b/modules/item/front/fixed-price/style.scss index 97ceaf7cd..f70ec2f50 100644 --- a/modules/item/front/fixed-price/style.scss +++ b/modules/item/front/fixed-price/style.scss @@ -2,8 +2,8 @@ vn-fixed-price{ smart-table table{ [shrink-field]{ - width: 80px; - max-width: 80px; + width: 90px; + max-width: 90px; } [shrink-field-expand]{ width: 150px; @@ -15,8 +15,8 @@ vn-fixed-price{ align-items: center; text-align: center; vn-input-number { - width: 90px; - max-width: 90px; + width: 75px; + max-width: 75px; } } diff --git a/modules/item/front/request-search-panel/index.html b/modules/item/front/request-search-panel/index.html index dfafb02f3..a76684776 100644 --- a/modules/item/front/request-search-panel/index.html +++ b/modules/item/front/request-search-panel/index.html @@ -1,4 +1,9 @@
+ + + data="warehouses" + show-field="name" + value-field="id"> diff --git a/modules/monitor/front/index/search-panel/index.html b/modules/monitor/front/index/search-panel/index.html index 5458202d2..822f84922 100644 --- a/modules/monitor/front/index/search-panel/index.html +++ b/modules/monitor/front/index/search-panel/index.html @@ -1,4 +1,9 @@
+ + + data="Warehouses"> + + + order="created DESC, id DESC"> - \ No newline at end of file + diff --git a/modules/route/front/search-panel/index.html b/modules/route/front/search-panel/index.html index 6e3d30d30..a5635766a 100644 --- a/modules/route/front/search-panel/index.html +++ b/modules/route/front/search-panel/index.html @@ -1,4 +1,9 @@
+ + diff --git a/modules/supplier/back/locale/supplier-account/en.yml b/modules/supplier/back/locale/supplier-account/en.yml index bc2add833..2bce50cfa 100644 --- a/modules/supplier/back/locale/supplier-account/en.yml +++ b/modules/supplier/back/locale/supplier-account/en.yml @@ -1,7 +1,7 @@ -name: supplier account +name: account columns: id: id - iban: iban + iban: IBAN beneficiary: beneficiary supplierFk: supplier bankEntityFk: bank entity diff --git a/modules/supplier/back/locale/supplier-account/es.yml b/modules/supplier/back/locale/supplier-account/es.yml index 0d751b387..120293c8a 100644 --- a/modules/supplier/back/locale/supplier-account/es.yml +++ b/modules/supplier/back/locale/supplier-account/es.yml @@ -1,7 +1,7 @@ -name: cuenta proveedor +name: cuenta columns: id: id - iban: iban + iban: IBAN beneficiary: beneficiario supplierFk: proveedor bankEntityFk: entidad bancaria diff --git a/modules/supplier/back/locale/supplier-contact/en.yml b/modules/supplier/back/locale/supplier-contact/en.yml index 62f923293..f79dfae19 100644 --- a/modules/supplier/back/locale/supplier-contact/en.yml +++ b/modules/supplier/back/locale/supplier-contact/en.yml @@ -1,4 +1,4 @@ -name: supplier contact +name: contact columns: id: id supplierFk: supplier diff --git a/modules/supplier/back/locale/supplier-contact/es.yml b/modules/supplier/back/locale/supplier-contact/es.yml index d35f0bf2e..486c7924d 100644 --- a/modules/supplier/back/locale/supplier-contact/es.yml +++ b/modules/supplier/back/locale/supplier-contact/es.yml @@ -1,4 +1,4 @@ -name: contacto proveedor +name: contacto columns: id: id supplierFk: proveedor diff --git a/modules/supplier/back/locale/supplier/en.yml b/modules/supplier/back/locale/supplier/en.yml index 1be941a70..25bcae1e3 100644 --- a/modules/supplier/back/locale/supplier/en.yml +++ b/modules/supplier/back/locale/supplier/en.yml @@ -4,7 +4,7 @@ columns: name: name account: account countryFk: country - nif: nif + nif: NIF phone: phone retAccount: ret account commission: commission diff --git a/modules/supplier/back/locale/supplier/es.yml b/modules/supplier/back/locale/supplier/es.yml index 6ac8379f5..678c384a9 100644 --- a/modules/supplier/back/locale/supplier/es.yml +++ b/modules/supplier/back/locale/supplier/es.yml @@ -4,7 +4,7 @@ columns: name: nombre account: cuenta countryFk: país - nif: nif + nif: NIF phone: teléfono retAccount: cuenta ret commission: comisión diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js index ae3eb4bcc..e113e5d59 100644 --- a/modules/supplier/back/models/supplier.js +++ b/modules/supplier/back/models/supplier.js @@ -99,18 +99,20 @@ module.exports = Self => { Self.observe('before save', async function(ctx) { if (ctx.isNewInstance) return; - const loopbackContext = LoopBackContext.getCurrentContext(); const changes = ctx.data || ctx.instance; const orgData = ctx.currentInstance; - const userId = loopbackContext.active.accessToken.userId; + const loopBackContext = LoopBackContext.getCurrentContext(); + const accessToken = {req: loopBackContext.active.accessToken}; + + const editPayMethodCheck = + await Self.app.models.ACL.checkAccessAcl(accessToken, 'Supplier', 'editPayMethodCheck', 'WRITE'); - const isNotFinancial = !await Self.app.models.VnUser.hasRole(userId, 'financial'); const isPayMethodChecked = changes.isPayMethodChecked || orgData.isPayMethodChecked; const hasChanges = orgData && changes; const isPayMethodCheckedChanged = hasChanges && orgData.isPayMethodChecked != isPayMethodChecked; - if (isNotFinancial && isPayMethodCheckedChanged) + if (!editPayMethodCheck && isPayMethodCheckedChanged) throw new UserError('You can not modify is pay method checked'); }); diff --git a/modules/ticket/back/locale/expedition/en.yml b/modules/ticket/back/locale/expedition/en.yml index 1834984ea..5ec5d5ecd 100644 --- a/modules/ticket/back/locale/expedition/en.yml +++ b/modules/ticket/back/locale/expedition/en.yml @@ -8,3 +8,7 @@ columns: agencyModeFk: agency workerFk: worker packagingFk: packaging + hasNewRoute: new route + hostFk: PC + isBox: box + itemPackingTypeFk: packing type diff --git a/modules/ticket/back/locale/expedition/es.yml b/modules/ticket/back/locale/expedition/es.yml index 32f72b943..cda577f18 100644 --- a/modules/ticket/back/locale/expedition/es.yml +++ b/modules/ticket/back/locale/expedition/es.yml @@ -8,3 +8,7 @@ columns: agencyModeFk: agencia workerFk: trabajador packagingFk: embalaje + hasNewRoute: nueva ruta + hostFk: PC + isBox: caja + itemPackingTypeFk: tipo empaquetado diff --git a/modules/ticket/back/locale/sale/en.yml b/modules/ticket/back/locale/sale/en.yml index f844bf0c5..09fa6735c 100644 --- a/modules/ticket/back/locale/sale/en.yml +++ b/modules/ticket/back/locale/sale/en.yml @@ -1,5 +1,6 @@ name: sale columns: + id: id concept: concept quantity: quantity price: price @@ -11,3 +12,7 @@ columns: itemFk: item ticketFk: ticket saleFk: sale + priceFixed: price fixed + isPriceFixed: has fixed price + isAdded: added + total: total diff --git a/modules/ticket/back/locale/sale/es.yml b/modules/ticket/back/locale/sale/es.yml index 8196a089c..e6a984a5d 100644 --- a/modules/ticket/back/locale/sale/es.yml +++ b/modules/ticket/back/locale/sale/es.yml @@ -1,13 +1,18 @@ name: línea columns: + id: id concept: concepto quantity: cantidad price: precio discount: descuento reserved: reservado - isPicked: esta seleccionado + isPicked: cogida created: creado originalQuantity: cantidad original itemFk: artículo ticketFk: ticket saleFk: línea + priceFixed: precio fijado + isPriceFixed: tiene precio fijado + isAdded: añadida + total: total diff --git a/modules/ticket/back/locale/ticket-dms/en.yml b/modules/ticket/back/locale/ticket-dms/en.yml index 771e4daf3..ff4c9f14b 100644 --- a/modules/ticket/back/locale/ticket-dms/en.yml +++ b/modules/ticket/back/locale/ticket-dms/en.yml @@ -1,4 +1,4 @@ -name: ticket dms +name: document columns: dmsFk: dms ticketFk: ticket diff --git a/modules/ticket/back/locale/ticket-dms/es.yml b/modules/ticket/back/locale/ticket-dms/es.yml index 360268428..09c380732 100644 --- a/modules/ticket/back/locale/ticket-dms/es.yml +++ b/modules/ticket/back/locale/ticket-dms/es.yml @@ -1,4 +1,4 @@ -name: documento ticket +name: documento columns: dmsFk: dms ticketFk: ticket diff --git a/modules/ticket/back/locale/ticket-observation/en.yml b/modules/ticket/back/locale/ticket-observation/en.yml index 40bd567bf..5a43b5887 100644 --- a/modules/ticket/back/locale/ticket-observation/en.yml +++ b/modules/ticket/back/locale/ticket-observation/en.yml @@ -1,4 +1,4 @@ -name: ticket observation +name: observation columns: id: id description: description diff --git a/modules/ticket/back/locale/ticket-observation/es.yml b/modules/ticket/back/locale/ticket-observation/es.yml index 155eb58e2..7e72cd0c7 100644 --- a/modules/ticket/back/locale/ticket-observation/es.yml +++ b/modules/ticket/back/locale/ticket-observation/es.yml @@ -1,4 +1,4 @@ -name: observación ticket +name: observación columns: id: id description: descripción diff --git a/modules/ticket/back/locale/ticket-packaging/en.yml b/modules/ticket/back/locale/ticket-packaging/en.yml index 4dd018524..51cc01e07 100644 --- a/modules/ticket/back/locale/ticket-packaging/en.yml +++ b/modules/ticket/back/locale/ticket-packaging/en.yml @@ -1,4 +1,4 @@ -name: ticket packaging +name: packaging columns: id: id quantity: quantity diff --git a/modules/ticket/back/locale/ticket-packaging/es.yml b/modules/ticket/back/locale/ticket-packaging/es.yml index a31a8c097..b2c3e22ce 100644 --- a/modules/ticket/back/locale/ticket-packaging/es.yml +++ b/modules/ticket/back/locale/ticket-packaging/es.yml @@ -1,4 +1,4 @@ -name: embalaje ticket +name: embalaje columns: id: id quantity: cantidad diff --git a/modules/ticket/back/locale/ticket-refund/en.yml b/modules/ticket/back/locale/ticket-refund/en.yml index 961b5c8c3..7da82a1a3 100644 --- a/modules/ticket/back/locale/ticket-refund/en.yml +++ b/modules/ticket/back/locale/ticket-refund/en.yml @@ -1,4 +1,4 @@ -name: ticket refund +name: refund columns: id: id refundTicketFk: refund ticket diff --git a/modules/ticket/back/locale/ticket-refund/es.yml b/modules/ticket/back/locale/ticket-refund/es.yml index 8826ef949..d83a60c55 100644 --- a/modules/ticket/back/locale/ticket-refund/es.yml +++ b/modules/ticket/back/locale/ticket-refund/es.yml @@ -1,4 +1,4 @@ -name: ticket abono +name: abono columns: id: id refundTicketFk: ticket abono diff --git a/modules/ticket/back/locale/ticket-request/en.yml b/modules/ticket/back/locale/ticket-request/en.yml index 498a933ac..f381e0c9d 100644 --- a/modules/ticket/back/locale/ticket-request/en.yml +++ b/modules/ticket/back/locale/ticket-request/en.yml @@ -1,4 +1,4 @@ -name: ticket request +name: request columns: id: id description: description diff --git a/modules/ticket/back/locale/ticket-request/es.yml b/modules/ticket/back/locale/ticket-request/es.yml index b2871e737..5504448bf 100644 --- a/modules/ticket/back/locale/ticket-request/es.yml +++ b/modules/ticket/back/locale/ticket-request/es.yml @@ -1,4 +1,4 @@ -name: peticiones ticket +name: peticion columns: id: id description: descripción diff --git a/modules/ticket/back/locale/ticket-service/en.yml b/modules/ticket/back/locale/ticket-service/en.yml index cf4e6f43f..a7c329415 100644 --- a/modules/ticket/back/locale/ticket-service/en.yml +++ b/modules/ticket/back/locale/ticket-service/en.yml @@ -1,4 +1,4 @@ -name: ticket service +name: service columns: id: id ticketFk: ticket diff --git a/modules/ticket/back/locale/ticket-service/es.yml b/modules/ticket/back/locale/ticket-service/es.yml index ee07c13d3..4b11be6d1 100644 --- a/modules/ticket/back/locale/ticket-service/es.yml +++ b/modules/ticket/back/locale/ticket-service/es.yml @@ -1,4 +1,4 @@ -name: servicios ticket +name: servicio columns: id: id ticketFk: ticket diff --git a/modules/ticket/back/locale/ticket-tracking/en.yml b/modules/ticket/back/locale/ticket-tracking/en.yml index 15505a763..213b9bff5 100644 --- a/modules/ticket/back/locale/ticket-tracking/en.yml +++ b/modules/ticket/back/locale/ticket-tracking/en.yml @@ -1,7 +1,8 @@ -name: ticket tracking +name: state columns: id: id created: created ticketFk: ticket stateFk: state workerFk: worker + failFk: fail diff --git a/modules/ticket/back/locale/ticket-tracking/es.yml b/modules/ticket/back/locale/ticket-tracking/es.yml index 3459ab367..d8d7a121f 100644 --- a/modules/ticket/back/locale/ticket-tracking/es.yml +++ b/modules/ticket/back/locale/ticket-tracking/es.yml @@ -1,7 +1,8 @@ -name: seguimiento ticket +name: estado columns: id: id created: creado ticketFk: ticket stateFk: estado workerFk: trabajador + failFk: fallo diff --git a/modules/ticket/back/locale/ticket/en.yml b/modules/ticket/back/locale/ticket/en.yml index 2481c42f8..96f7569ef 100644 --- a/modules/ticket/back/locale/ticket/en.yml +++ b/modules/ticket/back/locale/ticket/en.yml @@ -1,5 +1,6 @@ name: ticket columns: + id: id shipped: shipped landed: landed nickname: nickname @@ -23,3 +24,14 @@ columns: agencyModeFk: agency ticketFk: ticket mergedTicket: merged ticket + withWarningAccept: negative warning + isWithoutNegatives: without negatives + isSigned: signed + isLabeled: labeled + isPrinted: printed + hour: hour + created: created + isBlocked: bloqued + hasPriority: priority + isBoxed: boxed + clonedFrom: cloned from diff --git a/modules/ticket/back/locale/ticket/es.yml b/modules/ticket/back/locale/ticket/es.yml index 558378612..1cb8f478e 100644 --- a/modules/ticket/back/locale/ticket/es.yml +++ b/modules/ticket/back/locale/ticket/es.yml @@ -1,5 +1,6 @@ name: ticket columns: + id: id shipped: salida landed: entrega nickname: alias @@ -25,3 +26,12 @@ columns: mergedTicket: ticket fusionado withWarningAccept: aviso negativos isWithoutNegatives: sin negativos + isSigned: firmado + isLabeled: etiquetado + isPrinted: impreso + hour: hora + created: creado + isBlocked: bloqueado + hasPriority: prioritario + isBoxed: encajado + clonedFrom: Clonado de diff --git a/modules/ticket/back/methods/sale/canEdit.js b/modules/ticket/back/methods/sale/canEdit.js index 3091ebca7..cb3f2420a 100644 --- a/modules/ticket/back/methods/sale/canEdit.js +++ b/modules/ticket/back/methods/sale/canEdit.js @@ -38,6 +38,9 @@ module.exports = Self => { } }, myOptions); + if (!salesData.length) + throw new UserError(`The sales do not exists`); + const ticketId = salesData[0].ticketFk; const isTicketEditable = await models.Ticket.isEditable(ctx, ticketId, myOptions); @@ -62,7 +65,5 @@ module.exports = Self => { throw new UserError('It is not possible to modify cloned sales'); if (!shouldEditFloramondo) throw new UserError('It is not possible to modify sales that their articles are from Floramondo'); - - return true; }; }; diff --git a/modules/ticket/back/methods/sale/specs/canEdit.spec.js b/modules/ticket/back/methods/sale/specs/canEdit.spec.js index 62f98421a..eef9136a8 100644 --- a/modules/ticket/back/methods/sale/specs/canEdit.spec.js +++ b/modules/ticket/back/methods/sale/specs/canEdit.spec.js @@ -17,6 +17,32 @@ describe('sale canEdit()', () => { }); }); + describe('sale not exists', () => { + it('should return error if sale not exists', async() => { + const tx = await models.Sale.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const developerId = 9; + const ctx = {req: {accessToken: {userId: developerId}}}; + + let max = await models.Sale.findOne({fields: ['id'], order: 'id DESC'}, options); + max.id = max.id + 1; + + const sales = [max.id]; + await models.Sale.canEdit(ctx, sales, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e.message; + } + + expect(error).toEqual('The sales do not exists'); + }); + }); + describe('sale editTracked', () => { it('should return true if the role is production regardless of the saleTrackings', async() => { const tx = await models.Sale.beginTransaction({}); @@ -29,9 +55,7 @@ describe('sale canEdit()', () => { const sales = [25]; - const result = await models.Sale.canEdit(ctx, sales, options); - - expect(result).toEqual(true); + await models.Sale.canEdit(ctx, sales, options); await tx.rollback(); } catch (e) { @@ -51,9 +75,7 @@ describe('sale canEdit()', () => { const sales = [10]; - const result = await models.Sale.canEdit(ctx, sales, options); - - expect(result).toEqual(true); + await models.Sale.canEdit(ctx, sales, options); await tx.rollback(); } catch (e) { @@ -87,9 +109,7 @@ describe('sale canEdit()', () => { }); const ctx = {req: {accessToken: {userId: role.id}}}; - const result = await models.Sale.canEdit(ctx, saleCloned, options); - - expect(result).toEqual(true); + await models.Sale.canEdit(ctx, saleCloned, options); await tx.rollback(); } catch (e) { @@ -150,9 +170,7 @@ describe('sale canEdit()', () => { const saleToEdit = await models.Sale.findById(sales[0], null, options); await saleToEdit.updateAttribute('itemFk', 9, options); - const result = await models.Sale.canEdit(ctx, sales, options); - - expect(result).toEqual(true); + await models.Sale.canEdit(ctx, sales, options); await tx.rollback(); } catch (e) { diff --git a/modules/ticket/back/methods/sale/specs/updateQuantity.spec.js b/modules/ticket/back/methods/sale/specs/updateQuantity.spec.js index 4778f6b6d..80adb0bd1 100644 --- a/modules/ticket/back/methods/sale/specs/updateQuantity.spec.js +++ b/modules/ticket/back/methods/sale/specs/updateQuantity.spec.js @@ -64,7 +64,7 @@ describe('sale updateQuantity()', () => { try { const options = {transaction: tx}; - const isRoleAdvanced = await models.Ticket.isRoleAdvanced(ctx, options); + const isRoleAdvanced = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'isRoleAdvanced', '*'); expect(isRoleAdvanced).toEqual(true); diff --git a/modules/ticket/back/methods/sale/updateQuantity.js b/modules/ticket/back/methods/sale/updateQuantity.js index d2927c65c..421c74702 100644 --- a/modules/ticket/back/methods/sale/updateQuantity.js +++ b/modules/ticket/back/methods/sale/updateQuantity.js @@ -64,7 +64,7 @@ module.exports = Self => { const sale = await models.Sale.findById(id, filter, myOptions); - const isRoleAdvanced = await models.Ticket.isRoleAdvanced(ctx, myOptions); + const isRoleAdvanced = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'isRoleAdvanced', '*'); if (newQuantity > sale.quantity && !isRoleAdvanced) throw new UserError('The new quantity should be smaller than the old one'); diff --git a/modules/ticket/back/methods/state/editableStates.js b/modules/ticket/back/methods/state/editableStates.js index 061097a65..1ddfbffa2 100644 --- a/modules/ticket/back/methods/state/editableStates.js +++ b/modules/ticket/back/methods/state/editableStates.js @@ -1,3 +1,4 @@ +const mergeFilters = require('vn-loopback/util/filter').mergeFilters; module.exports = Self => { Self.remoteMethodCtx('editableStates', { description: 'Gets the editable states according the user role ', @@ -18,26 +19,15 @@ module.exports = Self => { Self.editableStates = async(ctx, filter, options) => { const models = Self.app.models; - const userId = ctx.req.accessToken.userId; - const myOptions = {}; + const myOptions = {...(options || {})}; - if (typeof options == 'object') - Object.assign(myOptions, options); + const seeEditableStates = await models.ACL.checkAccessAcl(ctx, 'State', 'seeEditableStates', 'READ'); - let statesList = await models.State.find(filter, myOptions); - const isProduction = await models.VnUser.hasRole(userId, 'production', myOptions); - const isSalesPerson = await models.VnUser.hasRole(userId, 'salesPerson', myOptions); - const isAdministrative = await models.VnUser.hasRole(userId, 'administrative', myOptions); + if (!seeEditableStates) + filter = mergeFilters(filter, {where: {alertLevel: 0}}); - if (isProduction || isAdministrative) - return statesList; + const states = await models.State.find(filter, myOptions); - if (isSalesPerson) { - return statesList = statesList.filter(stateList => - stateList.alertLevel === 0 || stateList.code === 'PICKER_DESIGNED' - ); - } - - return statesList.filter(stateList => stateList.alertLevel === 0); + return states; }; }; diff --git a/modules/ticket/back/methods/state/isEditable.js b/modules/ticket/back/methods/state/isEditable.js index 730e6b9eb..ec246c61f 100644 --- a/modules/ticket/back/methods/state/isEditable.js +++ b/modules/ticket/back/methods/state/isEditable.js @@ -19,22 +19,23 @@ module.exports = Self => { }); Self.isEditable = async(ctx, stateId, options) => { - const accessToken = ctx.req.accessToken; const models = Self.app.models; - const userId = accessToken.userId; const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); - const isProduction = await models.VnUser.hasRole(userId, 'production', myOptions); - const isSalesPerson = await models.VnUser.hasRole(userId, 'salesPerson', myOptions); - const isAdministrative = await models.VnUser.hasRole(userId, 'administrative', myOptions); + const isAllEditable = await models.ACL.checkAccessAcl(ctx, 'State', 'isAllEditable', 'READ'); + const state = await models.State.findById(stateId, null, myOptions); + const isSomeEditable = ( + await models.ACL.checkAccessAcl(ctx, 'State', 'isSomeEditable', 'READ') + && ( + state.code == 'PICKER_DESIGNED' || state.code == 'PRINTED' + ) + ); - const salesPersonAllowed = (isSalesPerson && (state.code == 'PICKER_DESIGNED' || state.code == 'PRINTED')); - - const isAllowed = isProduction || isAdministrative || salesPersonAllowed || state.alertLevel == 0; + const isAllowed = isAllEditable || isSomeEditable || state.alertLevel == 0; return isAllowed; }; }; diff --git a/modules/ticket/back/methods/state/specs/editableState.spec.js b/modules/ticket/back/methods/state/specs/editableState.spec.js index c75242be0..2e1ce0c19 100644 --- a/modules/ticket/back/methods/state/specs/editableState.spec.js +++ b/modules/ticket/back/methods/state/specs/editableState.spec.js @@ -24,31 +24,6 @@ describe('ticket editableStates()', () => { } }); - it(`should return the expected states by a specific role`, async() => { - const tx = await models.State.beginTransaction({}); - - try { - const options = {transaction: tx}; - - const productionRole = 18; - const ctx = {req: {accessToken: {userId: productionRole}}}; - - const editableStates = await models.State.editableStates(ctx, filter, options); - - const deliveredState = editableStates.some(state => state.code == 'DELIVERED'); - - const pickerDesignedState = editableStates.some(state => state.code == 'PICKER_DESIGNED'); - - expect(deliveredState).toBeFalsy(); - expect(pickerDesignedState).toBeTruthy(); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); - it(`should return again the expected state by a specific role`, async() => { const tx = await models.State.beginTransaction({}); @@ -70,4 +45,25 @@ describe('ticket editableStates()', () => { throw e; } }); + + it(`should return the expected state matching with the name`, async() => { + const tx = await models.State.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const employeeRole = 1; + const ctx = {req: {accessToken: {userId: employeeRole}}}; + const filter = {where: {name: {like: '%Previa OK%'}}}; + + const [editableStates] = await models.State.editableStates(ctx, filter, options); + + expect(editableStates.name).toBe('Previa OK'); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); }); diff --git a/modules/ticket/back/methods/ticket/closeAll.js b/modules/ticket/back/methods/ticket/closeAll.js index 3726d85b7..6690126b9 100644 --- a/modules/ticket/back/methods/ticket/closeAll.js +++ b/modules/ticket/back/methods/ticket/closeAll.js @@ -52,7 +52,7 @@ module.exports = Self => { JOIN province p ON p.id = c.provinceFk JOIN country co ON co.id = p.countryFk LEFT JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk - WHERE al.code = 'PACKED' OR (am.code = 'refund' AND al.code != 'delivered') + WHERE (al.code = 'PACKED' OR (am.code = 'refund' AND al.code != 'delivered')) AND DATE(t.shipped) BETWEEN DATE_ADD(?, INTERVAL -2 DAY) AND util.dayEnd(?) AND t.refFk IS NULL diff --git a/modules/ticket/back/methods/ticket/componentUpdate.js b/modules/ticket/back/methods/ticket/componentUpdate.js index b03301204..dac8e4f52 100644 --- a/modules/ticket/back/methods/ticket/componentUpdate.js +++ b/modules/ticket/back/methods/ticket/componentUpdate.js @@ -121,8 +121,8 @@ module.exports = Self => { if (!isEditable) throw new UserError(`The sales of this ticket can't be modified`); - const isDeliveryBoss = await models.VnUser.hasRole(userId, 'deliveryBoss', myOptions); - if (!isDeliveryBoss) { + const editZone = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'editZone', 'WRITE'); + if (!editZone) { const zoneShipped = await models.Agency.getShipped( ctx, args.landed, diff --git a/modules/ticket/back/methods/ticket/isEditable.js b/modules/ticket/back/methods/ticket/isEditable.js index d8fbb86ce..13bd4d57f 100644 --- a/modules/ticket/back/methods/ticket/isEditable.js +++ b/modules/ticket/back/methods/ticket/isEditable.js @@ -30,7 +30,7 @@ module.exports = Self => { where: {ticketFk: id} }, myOptions); - const isRoleAdvanced = await models.Ticket.isRoleAdvanced(ctx, myOptions); + const isRoleAdvanced = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'isRoleAdvanced', '*'); const alertLevel = state ? state.alertLevel : null; const ticket = await models.Ticket.findById(id, { diff --git a/modules/ticket/back/methods/ticket/isRoleAdvanced.js b/modules/ticket/back/methods/ticket/isRoleAdvanced.js deleted file mode 100644 index d6186a0c9..000000000 --- a/modules/ticket/back/methods/ticket/isRoleAdvanced.js +++ /dev/null @@ -1,32 +0,0 @@ -module.exports = Self => { - Self.remoteMethodCtx('isRoleAdvanced', { - description: 'Check if a ticket is editable', - accessType: 'READ', - returns: { - type: 'boolean', - root: true - }, - http: { - path: `/isRoleAdvanced`, - verb: 'GET' - } - }); - - Self.isRoleAdvanced = async(ctx, options) => { - const models = Self.app.models; - const userId = ctx.req.accessToken.userId; - const myOptions = {}; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - const isSalesAssistant = await models.VnUser.hasRole(userId, 'salesAssistant', myOptions); - const isDeliveryBoss = await models.VnUser.hasRole(userId, 'deliveryBoss', myOptions); - const isBuyer = await models.VnUser.hasRole(userId, 'buyer', myOptions); - const isClaimManager = await models.VnUser.hasRole(userId, 'claimManager', myOptions); - - const isRoleAdvanced = isSalesAssistant || isDeliveryBoss || isBuyer || isClaimManager; - - return isRoleAdvanced; - }; -}; diff --git a/modules/ticket/back/methods/ticket/merge.js b/modules/ticket/back/methods/ticket/merge.js index 8aaca1085..9a6f859f7 100644 --- a/modules/ticket/back/methods/ticket/merge.js +++ b/modules/ticket/back/methods/ticket/merge.js @@ -63,10 +63,11 @@ module.exports = Self => { newInstance: {mergedTicket: ticket.originId} }; - await models.TicketLog.create(ticketDestinationLogRecord, myOptions); await models.Sale.updateAll({ticketFk: ticket.originId}, {ticketFk: ticket.destinationId}, myOptions); - await models.Ticket.setDeleted(ctx, ticket.originId, myOptions); - await models.Chat.sendCheckingPresence(ctx, ticket.workerFk, message); + if (await models.Ticket.setDeleted(ctx, ticket.originId, myOptions)) { + await models.TicketLog.create(ticketDestinationLogRecord, myOptions); + await models.Chat.sendCheckingPresence(ctx, ticket.workerFk, message); + } } if (tx) await tx.commit(); diff --git a/modules/ticket/back/methods/ticket/priceDifference.js b/modules/ticket/back/methods/ticket/priceDifference.js index 16812dcb0..27fdb9160 100644 --- a/modules/ticket/back/methods/ticket/priceDifference.js +++ b/modules/ticket/back/methods/ticket/priceDifference.js @@ -60,7 +60,6 @@ module.exports = Self => { Self.priceDifference = async(ctx, options) => { const args = ctx.args; const models = Self.app.models; - const userId = ctx.req.accessToken.userId; const myOptions = {}; let tx; @@ -78,8 +77,8 @@ module.exports = Self => { if (!isEditable) throw new UserError(`The sales of this ticket can't be modified`); - const isDeliveryBoss = await models.VnUser.hasRole(userId, 'deliveryBoss', myOptions); - if (!isDeliveryBoss) { + const editZone = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'editZone', 'WRITE'); + if (!editZone) { const zoneShipped = await models.Agency.getShipped( ctx, args.landed, diff --git a/modules/ticket/back/methods/ticket/saveSign.js b/modules/ticket/back/methods/ticket/saveSign.js index aede7de8e..b8f9d5ced 100644 --- a/modules/ticket/back/methods/ticket/saveSign.js +++ b/modules/ticket/back/methods/ticket/saveSign.js @@ -29,8 +29,7 @@ module.exports = Self => { } }); - Self.saveSign = async(ctx, options) => { - const args = Object.assign({}, ctx.args); + Self.saveSign = async(ctx, tickets, location, signedTime, options) => { const models = Self.app.models; const myOptions = {}; let tx; @@ -48,9 +47,9 @@ module.exports = Self => { async function setLocation(ticketId) { await models.Delivery.create({ ticketFk: ticketId, - longitude: args.location.Longitude, - latitude: args.location.Latitude, - dated: args.signedTime || new Date() + longitude: location.Longitude, + latitude: location.Latitude, + dated: signedTime || new Date() }, myOptions); } @@ -107,9 +106,9 @@ module.exports = Self => { } try { - for (let i = 0; i < args.tickets.length; i++) { + for (const ticketId of tickets) { const ticketState = await models.TicketState.findOne( - {where: {ticketFk: args.tickets[i]}, + {where: {ticketFk: ticketId}, fields: ['alertLevel'] }, myOptions); @@ -117,16 +116,19 @@ module.exports = Self => { fields: ['id'] }, myOptions); + if (!ticketState) + throw new UserError('Ticket does not exist'); if (ticketState.alertLevel < packedAlertLevel.id) throw new UserError('This ticket cannot be signed because it has not been boxed'); - else if (!await gestDocExists(args.tickets[i])) { - if (args.location) setLocation(args.tickets[i]); - if (!gestDocCreated) await createGestDoc(args.tickets[i]); - await models.TicketDms.create({ticketFk: args.tickets[i], dmsFk: dms[0].id}, myOptions); - const ticket = await models.Ticket.findById(args.tickets[i], null, myOptions); - await ticket.updateAttribute('isSigned', true, myOptions); - await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [args.tickets[i], 'DELIVERED'], myOptions); - } + if (await gestDocExists(ticketId)) + throw new UserError('Ticket is already signed'); + + if (location) setLocation(ticketId); + if (!gestDocCreated) await createGestDoc(ticketId); + await models.TicketDms.create({ticketFk: ticketId, dmsFk: dms[0].id}, myOptions); + const ticket = await models.Ticket.findById(ticketId, null, myOptions); + await ticket.updateAttribute('isSigned', true, myOptions); + await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [ticketId, 'DELIVERED'], myOptions); } if (tx) await tx.commit(); diff --git a/modules/ticket/back/methods/ticket/setDeleted.js b/modules/ticket/back/methods/ticket/setDeleted.js index 2889160d1..228e2e765 100644 --- a/modules/ticket/back/methods/ticket/setDeleted.js +++ b/modules/ticket/back/methods/ticket/setDeleted.js @@ -36,7 +36,9 @@ module.exports = Self => { } try { - const userId = ctx.req.accessToken.userId; + const ticketToDelete = await models.Ticket.findById(id, {fields: ['isDeleted']}, myOptions); + if (ticketToDelete.isDeleted) return false; + const isEditable = await Self.isEditable(ctx, id, myOptions); if (!isEditable) @@ -51,7 +53,8 @@ module.exports = Self => { throw new UserError($t('Tickets with associated refunds', {id: ticketRefunds[0].id})); // Check if has sales with shelving - const isSalesAssistant = await models.VnUser.hasRole(userId, 'salesAssistant', myOptions); + const canDeleteTicketWithPartPrepared = + await models.ACL.checkAccessAcl(ctx, 'Ticket', 'deleteTicketWithPartPrepared', 'WRITE'); const sales = await models.Sale.find({ include: {relation: 'itemShelvingSale'}, where: {ticketFk: id} @@ -60,7 +63,7 @@ module.exports = Self => { return sale.itemShelvingSale(); }); - if (hasItemShelvingSales && !isSalesAssistant) + if (hasItemShelvingSales && !canDeleteTicketWithPartPrepared) throw new UserError(`You cannot delete a ticket that part of it is being prepared`); // Check for existing claim diff --git a/modules/ticket/back/methods/ticket/transferSales.js b/modules/ticket/back/methods/ticket/transferSales.js index 48035648c..5737e628f 100644 --- a/modules/ticket/back/methods/ticket/transferSales.js +++ b/modules/ticket/back/methods/ticket/transferSales.js @@ -3,6 +3,7 @@ let UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethodCtx('transferSales', { description: 'Transfer sales to a new or a given ticket', + accessType: 'WRITE', accepts: [{ arg: 'id', type: 'number', @@ -78,7 +79,7 @@ module.exports = Self => { const saleIds = sales.map(sale => sale.id); const hasClaimedSales = await models.ClaimBeginning.findOne({where: {saleFk: {inq: saleIds}}}); - if (hasClaimedSales) + if (ticketId != id && hasClaimedSales) throw new UserError(`Can't transfer claimed sales`); for (const sale of sales) { diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index 8300db886..4b31c0ce4 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -85,17 +85,14 @@ module.exports = Self => { const userId = ctx.req.accessToken.userId; const isLocked = await models.Ticket.isLocked(id, myOptions); - const roles = await models.VnUser.getRoles(userId, myOptions); - const hasAllowedRoles = roles.filter(role => - role == 'salesPerson' || role == 'claimManager' - ); + const canEditDiscount = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'editDiscount'); const state = await Self.app.models.TicketState.findOne({ where: {ticketFk: id} }, myOptions); const alertLevel = state ? state.alertLevel : null; - if (isLocked || (!hasAllowedRoles && alertLevel > 0)) + if (isLocked || (!canEditDiscount && alertLevel > 0)) throw new UserError(`The sales of this ticket can't be modified`); const usesMana = await models.Sale.usesMana(ctx, myOptions); diff --git a/modules/ticket/back/models/ticket-methods.js b/modules/ticket/back/models/ticket-methods.js index 3992e7307..e5a8e8d94 100644 --- a/modules/ticket/back/models/ticket-methods.js +++ b/modules/ticket/back/models/ticket-methods.js @@ -36,7 +36,6 @@ module.exports = function(Self) { require('../methods/ticket/getTicketsFuture')(Self); require('../methods/ticket/merge')(Self); require('../methods/ticket/getTicketsAdvance')(Self); - require('../methods/ticket/isRoleAdvanced')(Self); require('../methods/ticket/collectionLabel')(Self); require('../methods/ticket/expeditionPalletLabel')(Self); require('../methods/ticket/saveSign')(Self); diff --git a/modules/ticket/front/advance-search-panel/index.html b/modules/ticket/front/advance-search-panel/index.html index ee18c26f9..c2f5ecd8f 100644 --- a/modules/ticket/front/advance-search-panel/index.html +++ b/modules/ticket/front/advance-search-panel/index.html @@ -1,4 +1,9 @@
+ + diff --git a/modules/ticket/front/advance/index.html b/modules/ticket/front/advance/index.html index 007f80fe6..c937fe2ac 100644 --- a/modules/ticket/front/advance/index.html +++ b/modules/ticket/front/advance/index.html @@ -122,7 +122,7 @@ {{::ticket.ipt | dashIfEmpty}} + class="chip {{ticket.classColor}}"> {{::ticket.state | dashIfEmpty}} @@ -150,7 +150,7 @@ {{::ticket.futureIpt | dashIfEmpty}} + class="chip {{ticket.classColor}}"> {{::ticket.futureState | dashIfEmpty}} diff --git a/modules/ticket/front/basic-data/step-one/index.html b/modules/ticket/front/basic-data/step-one/index.html index 498630b87..73df8c370 100644 --- a/modules/ticket/front/basic-data/step-one/index.html +++ b/modules/ticket/front/basic-data/step-one/index.html @@ -4,6 +4,11 @@ order="name" auto-load="true"> + + @@ -25,7 +30,7 @@ { const $data = {email: 'brucebanner@gothamcity.com'}; const params = { + id: 16, recipient: $data.email, recipientId: ticket.client.id }; diff --git a/modules/ticket/front/dms/edit/index.html b/modules/ticket/front/dms/edit/index.html index cf9af46d0..221c86e7e 100644 --- a/modules/ticket/front/dms/edit/index.html +++ b/modules/ticket/front/dms/edit/index.html @@ -2,6 +2,11 @@ vn-id="watcher" data="$ctrl.dms"> + + diff --git a/modules/ticket/front/future-search-panel/index.html b/modules/ticket/front/future-search-panel/index.html index 18b574f2a..d873fbc37 100644 --- a/modules/ticket/front/future-search-panel/index.html +++ b/modules/ticket/front/future-search-panel/index.html @@ -1,4 +1,9 @@
+ + diff --git a/modules/ticket/front/future/index.html b/modules/ticket/front/future/index.html index 8628bb34c..2f0290c27 100644 --- a/modules/ticket/front/future/index.html +++ b/modules/ticket/front/future/index.html @@ -137,7 +137,7 @@ {{::ticket.ipt | dashIfEmpty}} + class="chip {{ticket.classColor}}"> {{::ticket.state}} @@ -158,7 +158,7 @@ {{::ticket.futureIpt | dashIfEmpty}} + class="chip {{ticket.classColor}}"> {{::ticket.futureState}} diff --git a/modules/ticket/front/future/index.js b/modules/ticket/front/future/index.js index 1732c562c..66d626993 100644 --- a/modules/ticket/front/future/index.js +++ b/modules/ticket/front/future/index.js @@ -95,13 +95,6 @@ export default class Controller extends Section { return checkedLines; } - stateColor(state) { - if (state === 'OK') - return 'success'; - else if (state === 'Libre') - return 'notice'; - } - dateRange(value) { const minHour = new Date(value); minHour.setHours(0, 0, 0, 0); diff --git a/modules/ticket/front/future/index.spec.js b/modules/ticket/front/future/index.spec.js index 188421298..ca29c6df7 100644 --- a/modules/ticket/front/future/index.spec.js +++ b/modules/ticket/front/future/index.spec.js @@ -60,24 +60,6 @@ describe('Component vnTicketFuture', () => { }); }); - describe('stateColor()', () => { - it('should return success to the OK tickets', () => { - const ok = controller.stateColor(controller.$.model.data[0].state); - const notOk = controller.stateColor(controller.$.model.data[1].state); - - expect(ok).toEqual('success'); - expect(notOk).not.toEqual('success'); - }); - - it('should return success to the FREE tickets', () => { - const notFree = controller.stateColor(controller.$.model.data[0].state); - const free = controller.stateColor(controller.$.model.data[1].state); - - expect(free).toEqual('notice'); - expect(notFree).not.toEqual('notice'); - }); - }); - describe('dateRange()', () => { it('should return two dates with the hours at the start and end of the given date', () => { const dateRange = controller.dateRange(today); diff --git a/modules/ticket/front/main/index.html b/modules/ticket/front/main/index.html index 82b5e58cd..e1e6c4e47 100644 --- a/modules/ticket/front/main/index.html +++ b/modules/ticket/front/main/index.html @@ -16,4 +16,4 @@ - \ No newline at end of file + diff --git a/modules/ticket/front/main/index.js b/modules/ticket/front/main/index.js index 3f9482fc4..c49418cfc 100644 --- a/modules/ticket/front/main/index.js +++ b/modules/ticket/front/main/index.js @@ -1,5 +1,6 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; +const UserError = require('vn-loopback/util/user-error'); export default class Ticket extends ModuleMain { fetchParams($params) { @@ -14,10 +15,19 @@ export default class Ticket extends ModuleMain { 'scopeDays' ]; + const seachPanelParams = Object.entries($params); + const hasFromParam = seachPanelParams.some(subarray => subarray.length > 0 && subarray[0] === 'from'); + const hasToParam = seachPanelParams.some(subarray => subarray.length > 0 && subarray[0] === 'to'); + + if ((hasFromParam && !hasToParam) || (!hasFromParam && hasToParam)) + throw new UserError(`Date range must have 'from' and 'to'`); + const hasExcludedParams = excludedParams.some(param => { return $params && $params[param] != undefined; }); + const hasParams = Object.entries($params).length; + if (!hasParams || !hasExcludedParams) $params.scopeDays = 1; @@ -28,7 +38,6 @@ export default class Ticket extends ModuleMain { const to = new Date(from.getTime()); to.setDate(to.getDate() + $params.scopeDays); to.setHours(23, 59, 59, 999); - Object.assign($params, {from, to}); } diff --git a/modules/ticket/front/main/locale/es.yml b/modules/ticket/front/main/locale/es.yml new file mode 100644 index 000000000..8db264e45 --- /dev/null +++ b/modules/ticket/front/main/locale/es.yml @@ -0,0 +1 @@ +Date range must have 'from' and 'to': El rango de fechas debe tener 'desde' y 'hasta' diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 6c37230ae..b2c0db18d 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -488,6 +488,12 @@ on-accept="$ctrl.onCreateClaimAccepted()"> + + + - Add claim - + Add claim = this.ticketConfig[0].daysForWarningClaim) @@ -241,7 +244,12 @@ class Controller extends Section { const query = `tickets/${this.ticket.id}/transferSales`; this.$http.post(query, params) - .then(res => this.$state.go('ticket.card.sale', {id: res.data.id})); + .then(res => { + if (res.data && res.data.id === this.ticket.id) { + this.$.transfer.hide(); + this.$.model.refresh(); + } else this.$state.go('ticket.card.sale', {id: res.data.id}); + }); } showEditPricePopover(event, sale) { diff --git a/modules/ticket/front/sale/locale/es.yml b/modules/ticket/front/sale/locale/es.yml index bb61db824..6eb558a56 100644 --- a/modules/ticket/front/sale/locale/es.yml +++ b/modules/ticket/front/sale/locale/es.yml @@ -42,3 +42,4 @@ Claim mana: Maná reclamación History: Historial Do you want to continue?: ¿Desea continuar? Claim out of time: Reclamación fuera de plazo +Do you want to create a claim?: ¿Quieres crear una reclamación? \ No newline at end of file diff --git a/modules/ticket/front/search-panel/index.html b/modules/ticket/front/search-panel/index.html index 7002f3dd6..d22b06a46 100644 --- a/modules/ticket/front/search-panel/index.html +++ b/modules/ticket/front/search-panel/index.html @@ -1,4 +1,9 @@
+ + + data="Warehouses"> + + diff --git a/modules/worker/back/locale/business/en.yml b/modules/worker/back/locale/business/en.yml new file mode 100644 index 000000000..f0642fbe4 --- /dev/null +++ b/modules/worker/back/locale/business/en.yml @@ -0,0 +1,12 @@ +name: contrato +columns: + id: id + companyCodeFk: company + started: started + ended: ended + payedHolidays: payed holidays + workerFk: worker + calendarTypeFk: calendar type + isHourlyLabor: hourly labor + workcenterFk: workcenter + amount: amount diff --git a/modules/worker/back/locale/business/es.yml b/modules/worker/back/locale/business/es.yml new file mode 100644 index 000000000..13ecfdb19 --- /dev/null +++ b/modules/worker/back/locale/business/es.yml @@ -0,0 +1,12 @@ +name: contrato +columns: + id: id + companyCodeFk: empresa + started: iniciado + ended: finalizado + payedHolidays: vacaciones pagadas + workerFk: trabajador + calendarTypeFk: tipo calendario + isHourlyLabor: horario laboral + workcenterFk: centro de trabajo + amount: salario diff --git a/modules/worker/back/locale/worker-dms/en.yml b/modules/worker/back/locale/worker-dms/en.yml index f870adaf0..b1b7b6ce4 100644 --- a/modules/worker/back/locale/worker-dms/en.yml +++ b/modules/worker/back/locale/worker-dms/en.yml @@ -1,4 +1,4 @@ -name: worker dms +name: document columns: id: id dmsFk: dms diff --git a/modules/worker/back/locale/worker-dms/es.yml b/modules/worker/back/locale/worker-dms/es.yml index c3bdea5af..878669181 100644 --- a/modules/worker/back/locale/worker-dms/es.yml +++ b/modules/worker/back/locale/worker-dms/es.yml @@ -1,4 +1,4 @@ -name: documento trabajador +name: documento columns: id: id dmsFk: dms diff --git a/modules/worker/back/locale/worker-time-control-mail/en.yml b/modules/worker/back/locale/worker-time-control-mail/en.yml index 821a3a3c9..ec7e59e7f 100644 --- a/modules/worker/back/locale/worker-time-control-mail/en.yml +++ b/modules/worker/back/locale/worker-time-control-mail/en.yml @@ -1,4 +1,4 @@ -name: worker time control mail +name: time control mail columns: id: id workerFk: worker diff --git a/modules/worker/back/locale/worker-time-control-mail/es.yml b/modules/worker/back/locale/worker-time-control-mail/es.yml index 159fcddf5..26733eb9a 100644 --- a/modules/worker/back/locale/worker-time-control-mail/es.yml +++ b/modules/worker/back/locale/worker-time-control-mail/es.yml @@ -1,4 +1,4 @@ -name: correo de control de tiempo del trabajador +name: correo de fichadas columns: id: id workerFk: trabajador diff --git a/modules/worker/back/methods/worker-dms/specs/downloadFile.spec.js b/modules/worker/back/methods/worker-dms/specs/downloadFile.spec.js index ac8e4539f..bdeec215c 100644 --- a/modules/worker/back/methods/worker-dms/specs/downloadFile.spec.js +++ b/modules/worker/back/methods/worker-dms/specs/downloadFile.spec.js @@ -1,4 +1,4 @@ -const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; describe('worker-dms downloadFile()', () => { let dmsId = 4; @@ -6,7 +6,7 @@ describe('worker-dms downloadFile()', () => { it('should return a response for an employee with text content-type', async() => { let workerId = 1106; let ctx = {req: {accessToken: {userId: workerId}}}; - const result = await app.models.WorkerDms.downloadFile(ctx, dmsId); + const result = await models.WorkerDms.downloadFile(ctx, dmsId); expect(result[1]).toEqual('text/plain'); }); @@ -17,7 +17,7 @@ describe('worker-dms downloadFile()', () => { let error; try { - await app.models.WorkerDms.downloadFile(ctx, dmsId); + await models.WorkerDms.downloadFile(ctx, dmsId); } catch (e) { error = e; } diff --git a/modules/worker/back/methods/worker-time-control/addTimeEntry.js b/modules/worker/back/methods/worker-time-control/addTimeEntry.js index 01a5a16ee..bcc96985f 100644 --- a/modules/worker/back/methods/worker-time-control/addTimeEntry.js +++ b/modules/worker/back/methods/worker-time-control/addTimeEntry.js @@ -40,10 +40,10 @@ module.exports = Self => { Object.assign(myOptions, options); const isSubordinate = await models.Worker.isSubordinate(ctx, workerId, myOptions); - const isTeamBoss = await models.VnUser.hasRole(currentUserId, 'teamBoss', myOptions); + const isTeamBoss = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isTeamBoss', 'WRITE'); const isHimself = currentUserId == workerId; - if (isSubordinate === false || (isSubordinate && isHimself && !isTeamBoss)) + if (!isSubordinate || (isSubordinate && isHimself && !isTeamBoss)) throw new UserError(`You don't have enough privileges`); query = `CALL vn.workerTimeControl_clockIn(?,?,?)`; diff --git a/modules/worker/back/methods/worker-time-control/deleteTimeEntry.js b/modules/worker/back/methods/worker-time-control/deleteTimeEntry.js index 1dcd12f5b..80482901f 100644 --- a/modules/worker/back/methods/worker-time-control/deleteTimeEntry.js +++ b/modules/worker/back/methods/worker-time-control/deleteTimeEntry.js @@ -32,7 +32,7 @@ module.exports = Self => { const targetTimeEntry = await Self.findById(id, null, myOptions); const isSubordinate = await models.Worker.isSubordinate(ctx, targetTimeEntry.userFk, myOptions); - const isTeamBoss = await models.VnUser.hasRole(currentUserId, 'teamBoss', myOptions); + const isTeamBoss = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isTeamBoss', 'WRITE'); const isHimself = currentUserId == targetTimeEntry.userFk; if (isSubordinate === false || (isSubordinate && isHimself && !isTeamBoss)) diff --git a/modules/worker/back/methods/worker-time-control/updateTimeEntry.js b/modules/worker/back/methods/worker-time-control/updateTimeEntry.js index 344421311..8231be7bb 100644 --- a/modules/worker/back/methods/worker-time-control/updateTimeEntry.js +++ b/modules/worker/back/methods/worker-time-control/updateTimeEntry.js @@ -38,7 +38,7 @@ module.exports = Self => { const targetTimeEntry = await Self.findById(id, null, myOptions); const isSubordinate = await models.Worker.isSubordinate(ctx, targetTimeEntry.userFk, myOptions); - const isTeamBoss = await models.VnUser.hasRole(currentUserId, 'teamBoss', myOptions); + const isTeamBoss = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isTeamBoss', 'WRITE'); const isHimself = currentUserId == targetTimeEntry.userFk; const notAllowed = isSubordinate === false || (isSubordinate && isHimself && !isTeamBoss); diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index f53164a50..cb2cf8330 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -53,7 +53,7 @@ module.exports = Self => { try { const isSubordinate = await models.Worker.isSubordinate(ctx, id, myOptions); - const isTeamBoss = await models.VnUser.hasRole(userId, 'teamBoss', myOptions); + const isTeamBoss = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isTeamBoss', 'WRITE'); if (!isSubordinate || (isSubordinate && userId == id && !isTeamBoss)) throw new UserError(`You don't have enough privileges`); diff --git a/modules/worker/back/methods/worker/deleteAbsence.js b/modules/worker/back/methods/worker/deleteAbsence.js index 2d0078ba7..c315f5178 100644 --- a/modules/worker/back/methods/worker/deleteAbsence.js +++ b/modules/worker/back/methods/worker/deleteAbsence.js @@ -40,7 +40,7 @@ module.exports = Self => { try { const isSubordinate = await models.Worker.isSubordinate(ctx, id, myOptions); - const isTeamBoss = await models.VnUser.hasRole(userId, 'teamBoss', myOptions); + const isTeamBoss = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isTeamBoss', 'WRITE'); if (!isSubordinate || (isSubordinate && userId == id && !isTeamBoss)) throw new UserError(`You don't have enough privileges`); diff --git a/modules/worker/back/methods/worker/isSubordinate.js b/modules/worker/back/methods/worker/isSubordinate.js index 6c17ad0d0..53adc68b7 100644 --- a/modules/worker/back/methods/worker/isSubordinate.js +++ b/modules/worker/back/methods/worker/isSubordinate.js @@ -25,22 +25,15 @@ module.exports = Self => { Self.isSubordinate = async(ctx, id, options) => { const models = Self.app.models; - const myUserId = ctx.req.accessToken.userId; - const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); const mySubordinates = await Self.mySubordinates(ctx, myOptions); - const isSubordinate = mySubordinates.find(subordinate => { - return subordinate.workerFk == id; - }); + const isSubordinate = mySubordinates.some(subordinate => subordinate.workerFk == id); + const forceIsSubordinate = await models.ACL.checkAccessAcl(ctx, 'Worker', 'forceIsSubordinate', 'READ'); - const isHr = await models.VnUser.hasRole(myUserId, 'hr', myOptions); - if (isHr || isSubordinate) - return true; - - return false; + return forceIsSubordinate || isSubordinate; }; }; diff --git a/modules/worker/back/methods/worker/new.js b/modules/worker/back/methods/worker/new.js index cec7524c6..398411118 100644 --- a/modules/worker/back/methods/worker/new.js +++ b/modules/worker/back/methods/worker/new.js @@ -54,18 +54,6 @@ module.exports = Self => { description: `The worker province`, required: true, }, - { - arg: 'iban', - type: 'string', - description: `The worker iban`, - required: true, - }, - { - arg: 'bankEntityFk', - type: 'number', - description: `The worker bank entity`, - required: true, - }, { arg: 'companyFk', type: 'number', @@ -101,6 +89,22 @@ module.exports = Self => { type: 'date', description: `The worker birth`, required: true, + }, + { + arg: 'payMethodFk', + type: 'number', + description: `The client payMethod`, + required: true, + }, + { + arg: 'iban', + type: 'string', + description: `The client iban`, + }, + { + arg: 'bankEntityFk', + type: 'number', + description: `The client bank entity`, } ], returns: { @@ -162,6 +166,10 @@ module.exports = Self => { myOptions ); + const payMethod = await models.PayMethod.findById(args.payMethodFk, {fields: ['isIbanRequiredForClients']}); + if (payMethod.isIbanRequiredForClients && !args.iban) + throw new UserError(`That payment method requires an IBAN`); + await models.Worker.rawSql( 'CALL vn.clientCreate(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [ @@ -169,7 +177,7 @@ module.exports = Self => { args.lastNames, args.fi, args.street, - args.postalCode, + args.postcode, args.city, args.provinceFk, args.companyFk, @@ -186,7 +194,7 @@ module.exports = Self => { street: args.street, city: args.city, provinceFk: args.provinceFk, - postalCode: args.postalCode, + postalCode: args.postcode, mobile: args.phone, nickname: nickname, isDefaultAddress: true, @@ -202,6 +210,7 @@ module.exports = Self => { await client.updateAttributes( { + payMethod: args.payMethod, iban: args.iban, bankEntityFk: args.bankEntityFk, defaultAddressFk: address.id, diff --git a/modules/worker/back/methods/worker/specs/new.spec.js b/modules/worker/back/methods/worker/specs/new.spec.js index dbcc66683..44f6e9b09 100644 --- a/modules/worker/back/methods/worker/specs/new.spec.js +++ b/modules/worker/back/methods/worker/specs/new.spec.js @@ -27,14 +27,14 @@ describe('Worker new', () => { street: 'S/ defaultWorkerStreet', city: 'defaultWorkerCity', provinceFk: 1, - iban: 'ES8304879798578129532677', - bankEntityFk: 128, companyFk: 442, postcode: '46680', phone: '123456789', code: 'DWW', bossFk: 9, - birth: '2022-12-11T23:00:00.000Z' + birth: '2022-12-11T23:00:00.000Z', + payMethodFk: 1, + roleFk: 1 }; it('should return error if personal mail already exists', async() => { @@ -105,6 +105,33 @@ describe('Worker new', () => { expect(error.message).toEqual('This worker already exists'); }); + it('should return error if payMethod require iban', async() => { + const payMethodIbanRequired = await models.PayMethod.findOne({ + where: { + isIbanRequiredForClients: true + }, + fields: ['id'] + }); + + const tx = await models.Worker.beginTransaction({}); + + let error; + try { + const options = {transaction: tx}; + const ctx = { + args: Object.assign({}, defaultWorker, {payMethodFk: payMethodIbanRequired.id}) + }; + await models.Worker.new(ctx, options); + + await tx.rollback(); + } catch (e) { + error = e; + await tx.rollback(); + } + + expect(error.message).toEqual('That payment method requires an IBAN'); + }); + it('should create a new worker', async() => { const newWorker = await models.Worker.new({args: defaultWorker}); diff --git a/modules/worker/back/methods/worker/updateAbsence.js b/modules/worker/back/methods/worker/updateAbsence.js index d904c2c14..5e13097a0 100644 --- a/modules/worker/back/methods/worker/updateAbsence.js +++ b/modules/worker/back/methods/worker/updateAbsence.js @@ -30,7 +30,7 @@ module.exports = Self => { const models = Self.app.models; const userId = ctx.req.accessToken.userId; const isSubordinate = await models.Worker.isSubordinate(ctx, id); - const isTeamBoss = await models.VnUser.hasRole(userId, 'teamBoss'); + const isTeamBoss = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isTeamBoss', 'WRITE'); if (!isSubordinate || (isSubordinate && userId == id && !isTeamBoss)) throw new UserError(`You don't have enough privileges`); diff --git a/modules/worker/back/models/worker-config.json b/modules/worker/back/models/worker-config.json index bcee74067..f7f257669 100644 --- a/modules/worker/back/models/worker-config.json +++ b/modules/worker/back/models/worker-config.json @@ -15,6 +15,9 @@ "roleFk": { "type": "number" }, + "payMethodFk": { + "type": "number" + }, "businessTypeFk": { "type": "string" } diff --git a/modules/worker/front/create/index.html b/modules/worker/front/create/index.html index 5f5ab9d07..eb45704a7 100644 --- a/modules/worker/front/create/index.html +++ b/modules/worker/front/create/index.html @@ -142,12 +142,19 @@ + + + on-change="$ctrl.autofillBic()" + rule> { + if (res.data) this.worker.payMethodFk = res.data.payMethodFk; + }); } onSubmit() { + if (!this.worker.iban && !this.worker.bankEntityFk) { + delete this.worker.iban; + delete this.worker.bankEntityFk; + } + return this.$.watcher.submit().then(json => { this.$state.go('worker.card.basicData', {id: json.data.id}); }); diff --git a/modules/worker/front/create/locale/es.yml b/modules/worker/front/create/locale/es.yml index 8c79d770c..1a0f03ef6 100644 --- a/modules/worker/front/create/locale/es.yml +++ b/modules/worker/front/create/locale/es.yml @@ -10,3 +10,4 @@ Street: Dirección Postcode: Código postal Web user: Usuario Web Access permission: Permiso de acceso +Pay method: Método de pago diff --git a/modules/worker/front/dms/create/index.html b/modules/worker/front/dms/create/index.html index 3495bf260..96f39ea6b 100644 --- a/modules/worker/front/dms/create/index.html +++ b/modules/worker/front/dms/create/index.html @@ -3,6 +3,11 @@ vn-id="watcher" data="$ctrl.dms"> + + { $element = $compile(``)($rootScope); controller = $element.controller('vnWorkerDmsCreate'); controller._worker = {id: 1101, name: 'Bruce wayne'}; + $httpBackend.whenRoute('GET', `Warehouses?filter=%7B%7D`).respond([{$oldData: {}}]); })); describe('worker() setter', () => { diff --git a/modules/worker/front/dms/edit/index.html b/modules/worker/front/dms/edit/index.html index 2ac96851c..e4939b4ea 100644 --- a/modules/worker/front/dms/edit/index.html +++ b/modules/worker/front/dms/edit/index.html @@ -2,6 +2,11 @@ vn-id="watcher" data="$ctrl.dms"> + + diff --git a/modules/zone/back/methods/agency/getLanded.js b/modules/zone/back/methods/agency/getLanded.js index cdde3b155..ebaa2db62 100644 --- a/modules/zone/back/methods/agency/getLanded.js +++ b/modules/zone/back/methods/agency/getLanded.js @@ -35,19 +35,13 @@ module.exports = Self => { }); Self.getLanded = async(ctx, shipped, addressFk, agencyModeFk, warehouseFk, options) => { + const models = Self.app.models; const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); - const userId = ctx.req.accessToken.userId; - const models = Self.app.models; - const roles = await models.VnUser.getRoles(userId); - const canSeeExpired = roles.filter(role => - role == 'productionBoss' || role == 'administrative' - ); - let showExpired = false; - if (canSeeExpired.length) showExpired = true; + const canSeeExpired = await models.ACL.checkAccessAcl(ctx, 'Agency', 'seeExpired', 'READ'); const stmts = []; stmts.push(new ParameterizedSQL( @@ -56,7 +50,7 @@ module.exports = Self => { addressFk, agencyModeFk, warehouseFk, - showExpired + canSeeExpired ] )); diff --git a/modules/zone/back/methods/zone/includingExpired.js b/modules/zone/back/methods/zone/includingExpired.js index 59e4079c2..f9e7fd038 100644 --- a/modules/zone/back/methods/zone/includingExpired.js +++ b/modules/zone/back/methods/zone/includingExpired.js @@ -24,7 +24,6 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const userId = ctx.req.accessToken.userId; const conn = Self.dataSource.connector; const models = Self.app.models; const where = filter.where; @@ -36,10 +35,7 @@ module.exports = Self => { && where.agencyModeFk && where.warehouseFk; if (filterByAvailability) { - const roles = await models.VnUser.getRoles(userId, myOptions); - const canSeeExpired = roles.filter(role => - role == 'productionBoss' || role == 'administrative' - ); + const canSeeExpired = await models.ACL.checkAccessAcl(ctx, 'Agency', 'seeExpired'); let showExpired = false; if (canSeeExpired.length) showExpired = true; diff --git a/package.json b/package.json index d068d6615..7a0dc5b7c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "23.22.01", + "version": "23.24.01", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", diff --git a/print/templates/reports/invoiceIn/invoiceIn.html b/print/templates/reports/invoiceIn/invoiceIn.html index 22988b654..8f072947f 100644 --- a/print/templates/reports/invoiceIn/invoiceIn.html +++ b/print/templates/reports/invoiceIn/invoiceIn.html @@ -19,7 +19,7 @@ {{$t('date')}} - {{formatDate(invoice.created, '%d-%m-%Y')}} + {{formatDate(invoice.issued, '%d-%m-%Y')}} diff --git a/print/templates/reports/invoiceIn/sql/invoice.sql b/print/templates/reports/invoiceIn/sql/invoice.sql index eea8e81a5..dae979011 100644 --- a/print/templates/reports/invoiceIn/sql/invoice.sql +++ b/print/templates/reports/invoiceIn/sql/invoice.sql @@ -1,7 +1,7 @@ SELECT i.supplierRef, s.id supplierId, - i.created, + i.issued, s.name, s.street AS postalAddress, s.nif,