diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index f0821349b..000000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.gitignore b/.gitignore index f4b1ab270..35172e5d2 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ npm-debug.log datasources.*.json print.*.json db.json -junit.xml \ No newline at end of file +junit.xml +.DS_Store \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index a574e61fd..b42249099 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,11 @@ RUN apt-get update \ ca-certificates \ gnupg2 \ libfontconfig \ + && apt-get -y install xvfb gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 \ + libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 \ + libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 \ + libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 \ + libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget \ && curl -sL https://deb.nodesource.com/setup_12.x | bash - \ && apt-get install -y --no-install-recommends \ nodejs \ diff --git a/Jenkinsfile b/Jenkinsfile index 2848ea59b..c810dc474 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -69,13 +69,13 @@ pipeline { } } } - stage('Backend') { + /* stage('Backend') { steps { nodejs('node-lts') { sh 'gulp backTestOnce --ci' } } - } + } */ } } stage('Build') { diff --git a/back/.DS_Store b/back/.DS_Store deleted file mode 100644 index a15d86adb..000000000 Binary files a/back/.DS_Store and /dev/null differ diff --git a/back/methods/.DS_Store b/back/methods/.DS_Store deleted file mode 100644 index 810045cc9..000000000 Binary files a/back/methods/.DS_Store and /dev/null differ diff --git a/back/model-config.json b/back/model-config.json index 872f2239e..323e5f233 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -26,6 +26,15 @@ "Delivery": { "dataSource": "vn" }, + "Image": { + "dataSource": "vn" + }, + "ImageCollection": { + "dataSource": "vn" + }, + "ImageCollectionSize": { + "dataSource": "vn" + }, "Province": { "dataSource": "vn" }, diff --git a/back/models/image-collection-size.json b/back/models/image-collection-size.json new file mode 100644 index 000000000..adb92d16b --- /dev/null +++ b/back/models/image-collection-size.json @@ -0,0 +1,44 @@ +{ + "name": "ImageCollectionSize", + "base": "VnModel", + "options": { + "mysql": { + "table": "hedera.imageCollectionSize" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "width": { + "type": "Number", + "required": true + }, + "height": { + "type": "Number", + "required": true + }, + "crop": { + "type": "Boolean", + "required": true + } + }, + "relations": { + "collection": { + "type": "belongsTo", + "model": "ImageCollection", + "foreignKey": "collectionFk" + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "employee", + "permission": "ALLOW" + } + ] +} + \ No newline at end of file diff --git a/back/models/image-collection.json b/back/models/image-collection.json new file mode 100644 index 000000000..2234766c9 --- /dev/null +++ b/back/models/image-collection.json @@ -0,0 +1,57 @@ +{ + "name": "ImageCollection", + "base": "VnModel", + "options": { + "mysql": { + "table": "hedera.imageCollection" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "name": { + "type": "String", + "required": true + }, + "desc": { + "type": "String", + "required": true + }, + "maxWidth": { + "type": "Number", + "required": true + }, + "maxHeight": { + "type": "Number", + "required": true + }, + "model": { + "type": "String", + "required": true + }, + "property": { + "type": "String", + "required": true + } + }, + "relations": { + "sizes": { + "type": "hasMany", + "model": "ImageCollectionSize", + "foreignKey": "collectionFk", + "property": "id" + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "employee", + "permission": "ALLOW" + } + ] +} + \ No newline at end of file diff --git a/back/models/image.js b/back/models/image.js new file mode 100644 index 000000000..079acd293 --- /dev/null +++ b/back/models/image.js @@ -0,0 +1,99 @@ +const fs = require('fs-extra'); +const sharp = require('sharp'); +const path = require('path'); + +module.exports = Self => { + Self.getPath = function() { + return '/var/lib/salix/image'; + }; + + Self.registerImage = async(collectionName, file, srcFilePath) => { + const models = Self.app.models; + const tx = await Self.beginTransaction({}); + const myOptions = {transaction: tx}; + + try { + const collection = await models.ImageCollection.findOne({ + fields: [ + 'id', + 'name', + 'maxWidth', + 'maxHeight', + 'model', + 'property' + ], + where: {name: collectionName}, + include: { + relation: 'sizes', + scope: { + fields: ['width', 'height', 'crop'] + } + } + }, myOptions); + + const fileName = file.split('.')[0]; + const rootPath = Self.getPath(); + const data = { + name: fileName, + collectionFk: collectionName + }; + + const newImage = await Self.upsertWithWhere(data, { + name: fileName, + collectionFk: collectionName, + updated: (new Date).getTime() + }, myOptions); + + // Resizes and saves the image + const collectionDir = path.join(rootPath, collectionName); + const dstDir = path.join(collectionDir, 'full'); + const dstFile = path.join(dstDir, file); + + const resizeOpts = { + withoutEnlargement: true, + fit: 'inside' + }; + + await fs.mkdir(dstDir, {recursive: true}); + await sharp(srcFilePath) + .resize(collection.maxWidth, collection.maxHeight, resizeOpts) + .toFile(dstFile); + + const sizes = collection.sizes(); + for (let size of sizes) { + const dstDir = path.join(collectionDir, `${size.width}x${size.height}`); + const dstFile = path.join(dstDir, file); + const resizeOpts = { + withoutEnlargement: true, + fit: size.crop ? 'cover' : 'inside' + }; + + await fs.mkdir(dstDir, {recursive: true}); + await sharp(srcFilePath) + .resize(size.width, size.height, resizeOpts) + .toFile(dstFile); + } + + const model = models[collection.model]; + + if (!model) + throw new Error('Matching model not found'); + + const item = await model.findById(fileName, null, myOptions); + if (item) { + await item.updateAttribute( + collection.property, + fileName, + myOptions + ); + } + + await fs.unlink(srcFilePath); + await tx.commit(); + return newImage; + } catch (e) { + await tx.rollback(); + throw e; + } + }; +}; diff --git a/back/models/image.json b/back/models/image.json new file mode 100644 index 000000000..5b8c76cf1 --- /dev/null +++ b/back/models/image.json @@ -0,0 +1,41 @@ +{ + "name": "Image", + "base": "VnModel", + "options": { + "mysql": { + "table": "hedera.image" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "The id" + }, + "name": { + "type": "String", + "required": true + }, + "collectionFk": { + "type": "String", + "required": true + }, + "updated": { + "type": "Number" + }, + "nRefs": { + "type": "Number", + "required": true, + "default": 0 + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "employee", + "permission": "ALLOW" + } + ] +} + \ No newline at end of file diff --git a/db/changes/10180-holyWeek/00-ACL.sql b/db/changes/10180-holyWeek/00-ACL.sql deleted file mode 100644 index b0ab68a97..000000000 --- a/db/changes/10180-holyWeek/00-ACL.sql +++ /dev/null @@ -1 +0,0 @@ -INSERT IGNORE INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('WorkerLog', '*', 'READ', 'ALLOW', 'ROLE', 'hr'); \ No newline at end of file diff --git a/db/changes/10180-holyWeek/00-claim.sql b/db/changes/10180-holyWeek/00-claim.sql deleted file mode 100644 index e3b979efe..000000000 --- a/db/changes/10180-holyWeek/00-claim.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `vn`.`claim` -ADD COLUMN `hasToPickUp` TINYINT(1) NOT NULL AFTER `ticketFk`; diff --git a/db/changes/10180-holyWeek/00-claimState.sql b/db/changes/10180-holyWeek/00-claimState.sql deleted file mode 100644 index c39ba751d..000000000 --- a/db/changes/10180-holyWeek/00-claimState.sql +++ /dev/null @@ -1,28 +0,0 @@ -ALTER TABLE `vn`.`claimState` -DROP FOREIGN KEY `roleFgn`; -ALTER TABLE `vn`.`claimState` -ADD COLUMN `code` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' NULL AFTER `id`, -CHANGE COLUMN `roleFk` `roleFk` INT(10) UNSIGNED NOT NULL DEFAULT '1' ; -ALTER TABLE `vn`.`claimState` -ADD CONSTRAINT `roleFgn` - FOREIGN KEY (`roleFk`) - REFERENCES `account`.`role` (`id`) - ON UPDATE CASCADE; - -UPDATE `vn`.`claimState` SET `code` = 'pending' WHERE (`id` = '1'); -UPDATE `vn`.`claimState` SET `code` = 'canceled' WHERE (`id` = '4'); -UPDATE `vn`.`claimState` SET `code` = 'resolved' WHERE (`id` = '3'); -UPDATE `vn`.`claimState` SET `code` = 'disputed' WHERE (`id` = '5'); -UPDATE `vn`.`claimState` SET `code` = 'mana' WHERE (`id` = '6'); -UPDATE `vn`.`claimState` SET `code` = 'managed' WHERE (`id` = '2'); - -ALTER TABLE `vn`.`claimState` -ADD COLUMN `priority` INT NOT NULL DEFAULT 1 AFTER `roleFk`; - -UPDATE `vn`.`claimState` SET `priority` = '1' WHERE (`id` = '1'); -UPDATE `vn`.`claimState` SET `priority` = '5' WHERE (`id` = '2'); -UPDATE `vn`.`claimState` SET `priority` = '7' WHERE (`id` = '3'); -UPDATE `vn`.`claimState` SET `priority` = '6' WHERE (`id` = '4'); -UPDATE `vn`.`claimState` SET `priority` = '3' WHERE (`id` = '5'); -UPDATE `vn`.`claimState` SET `priority` = '4' WHERE (`id` = '6'); -UPDATE `vn`.`claimState` SET `priority` = '2' WHERE (`id` = '7'); \ No newline at end of file diff --git a/db/changes/10180-holyWeek/00-ticketWeekly.sql b/db/changes/10180-holyWeek/00-ticketWeekly.sql deleted file mode 100644 index 05d65e124..000000000 --- a/db/changes/10180-holyWeek/00-ticketWeekly.sql +++ /dev/null @@ -1,13 +0,0 @@ -ALTER TABLE `vn`.`ticketWeekly` -ADD COLUMN `agencyModeFk` INT(11) NULL DEFAULT NULL AFTER `weekDay`, -ADD INDEX `agencyModeFk_idx` (`agencyModeFk` ASC); - -ALTER TABLE `vn`.`ticketWeekly` -ADD CONSTRAINT `agencyModeFk` - FOREIGN KEY (`agencyModeFk`) - REFERENCES `vn`.`agencyMode` (`id`) - ON DELETE SET NULL - ON UPDATE CASCADE; - -ALTER TABLE `vn`.`ticketWeekly` -CHANGE COLUMN `weekDay` `weekDay` TINYINT(1) NOT NULL COMMENT 'funcion de mysql Lunes = 0, Domingo = 6' ; diff --git a/db/changes/10180-holyWeek/00-ticket_cloneWeekly.sql b/db/changes/10180-holyWeek/00-ticket_cloneWeekly.sql deleted file mode 100644 index 544296feb..000000000 --- a/db/changes/10180-holyWeek/00-ticket_cloneWeekly.sql +++ /dev/null @@ -1,130 +0,0 @@ -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `ticket_cloneWeekly`(IN vWeek INT) -BEGIN - DECLARE vIsDone BOOL; - DECLARE vLanding DATE; - DECLARE vShipment DATE; - DECLARE vWarehouse INT; - DECLARE vTicket INT; - DECLARE vWeekDay INT; - DECLARE vClient INT; - DECLARE vEmpresa INT; - DECLARE vAddressFk INT; - DECLARE vAgencyModeFk INT; - DECLARE vNewTicket INT; - DECLARE vYear INT; - - DECLARE rsTicket CURSOR FOR - SELECT tw.ticketFk, weekDay, t.clientFk, t.warehouseFk, t.companyFk, t.addressFk, tw.agencyModeFk - FROM ticketWeekly tw - JOIN ticket t ON tt.ticketFk = t.id; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE; - - SET vYear = YEAR(CURDATE()) + IF(vWeek < WEEK(CURDATE()),1, 0); - - OPEN rsTicket; - - myLoop: LOOP - BEGIN - DECLARE vError TEXT; - DECLARE vSalesPersonEmail VARCHAR(150); - DECLARE vMailSent BOOL; - DECLARE vSubject VARCHAR(150); - DECLARE vMessage TEXT; - DECLARE CONTINUE HANDLER FOR SQLEXCEPTION - BEGIN - GET DIAGNOSTICS CONDITION 1 - vError = MESSAGE_TEXT; - - END; - - SET vIsDone = FALSE; - FETCH rsTicket INTO vTicket, vWeekDay, vClient, vWarehouse, vEmpresa, vAddressFk, vAgencyModeFk; - - IF vIsDone THEN - - LEAVE myLoop; - END IF; - SELECT date INTO vShipment - FROM `time` - WHERE `year` = vYear AND `week` = vWeek - AND WEEKDAY(date) = vWeekDay; - - -- 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 - WHERE tOrig.id = vTicket AND DATE(tClon.shipped) = vShipment) > 0 - THEN - ITERATE myLoop; - END IF; - CALL vn.zone_getLanded(vShipment, vAddressFk, vAgencyModeFk, vWarehouse); - - SELECT landed INTO vLanding from tmp.zoneGetLanded LIMIT 1; - - CALL vn.ticketCreateWithoutZone(vClient, vShipment, vWarehouse, vEmpresa, vAddressFk, vAgencyModeFk, NULL, vLanding, account.userGetId(), vNewTicket); - - IF (vLanding IS NULL) THEN - - SELECT e.email INTO vSalesPersonEmail - FROM vn.client c - JOIN vn.worker sp ON sp.id = c.salesPersonFk - JOIN account.emailUser e ON e.userFk = sp.userFk - WHERE c.id = vClient; - - SET vSubject = CONCAT('Turnos - No se ha podido clonar correctamente el ticket ', vTicket, - ' para el dia: ', vShipment); - SET vMessage = CONCAT('No se ha podido clonar el ticket ', vTicket, - ' para el dia: ', vShipment, - ' porque no hay una zona de envío disponible. Se ha creado el ticket: ', vNewTicket, - ' pero ha que revisar las fechas y la agencia'); - - SELECT COUNT(*) INTO vMailSent - FROM vn.mail - WHERE sender = vSalesPersonEmail - AND subject = vSubject; - - IF NOT vMailSent THEN - INSERT INTO vn.mail (sender,`subject`,body) - VALUES (vSalesPersonEmail, vSubject, vMessage); - END IF; - CALL vn.ticketStateUpdate (vNewTicket, 'FIXING'); - END IF; - - INSERT INTO vn.sale (ticketFk, itemFk, concept, quantity, price, discount, priceFixed, isPriceFixed) - SELECT vNewTicket, saleOrig.itemFk , saleOrig.concept , saleOrig.quantity, saleOrig.price , saleOrig.discount, saleOrig.priceFixed, saleOrig.isPriceFixed - FROM vn.ticket tOrig - JOIN vn.sale saleOrig ON tOrig.id = saleOrig.ticketFk - LEFT JOIN vn.saleCloned sc ON sc.saleOriginalFk = saleOrig.id - LEFT JOIN vn.sale saleClon ON saleClon.id = sc.saleClonedFk - LEFT JOIN vn.ticket tClon ON tClon.id = saleClon.ticketFk AND DATE(tClon.shipped) = vShipment - WHERE tOrig.id = vTicket AND saleClon.id IS NULL; - - INSERT IGNORE INTO vn.saleCloned(saleOriginalFk, saleClonedFk) - SELECT saleOriginal.id, saleClon.id - FROM vn.sale saleOriginal - JOIN vn.sale saleClon ON saleOriginal.itemFk = saleClon.itemFk AND saleOriginal.quantity = saleClon.quantity - WHERE saleOriginal.ticketFk = vTicket AND saleClon.ticketFk = vNewTicket; - - INSERT INTO ticketRequest (description, ordered, shipped, salesPersonCode, buyerCode, quantity, price, - itemFk ,clientFk, response, total, buyed, saleFk) - SELECT tr.description, tr.ordered, tr.shipped, tr.salesPersonCode, tr.buyerCode, tr.quantity, tr.price, - tr.itemFk, tr.clientFk, tr.response, tr.total, tr.buyed, tr.saleFk - FROM sale s JOIN ticketRequest tr ON tr.saleFk = s.id - JOIN sale s2 ON s.concept = s2.concept AND s.quantity = s2.quantity AND m.Id_Article = m2.Id_Article - WHERE s.ticketFk = vTicket AND s2.ticketFk = vNewTicket; - - CALL vn.ticketCalculateClon(vNewTicket, vTicket); - END; - END LOOP; - - CLOSE rsTicket; - -END$$ - -DELIMITER ; - diff --git a/db/changes/10180-holyWeek/00-time_createTable.sql b/db/changes/10180-holyWeek/00-time_createTable.sql deleted file mode 100644 index 62b60c4bf..000000000 --- a/db/changes/10180-holyWeek/00-time_createTable.sql +++ /dev/null @@ -1,20 +0,0 @@ -USE `util`; -DROP procedure IF EXISTS `time_createTable`; - -DELIMITER $$ -USE `util`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `time_createTable`(vStarted DATE, vEnded DATE) -BEGIN - DECLARE vCurrentDate DATE; - - DROP TEMPORARY TABLE IF EXISTS tmp.time; - CREATE TEMPORARY TABLE tmp.time (dated DATE PRIMARY KEY) ENGINE = MEMORY; - SET vCurrentDate = vStarted; - WHILE vCurrentDate <= vEnded DO - INSERT INTO tmp.time (dated) VALUES (vCurrentDate); - SET vCurrentDate = DATE_ADD(vCurrentDate, INTERVAL 1 DAY); - END WHILE; - -END$$ - -DELIMITER ; \ No newline at end of file diff --git a/db/changes/10180-holyWeek/00-workerLog.sql b/db/changes/10180-holyWeek/00-workerLog.sql deleted file mode 100644 index f3f76f274..000000000 --- a/db/changes/10180-holyWeek/00-workerLog.sql +++ /dev/null @@ -1,6 +0,0 @@ -ALTER TABLE `vn`.`workerLog` -ADD COLUMN `changedModel` VARCHAR(45) NULL DEFAULT NULL AFTER `description`, -ADD COLUMN `oldInstance` TEXT NULL DEFAULT NULL AFTER `changedModel`, -ADD COLUMN `newInstance` TEXT NULL DEFAULT NULL AFTER `oldInstance`, -ADD COLUMN `changedModelId` INT(11) NULL DEFAULT NULL AFTER `newInstance`, -ADD COLUMN `changedModelValue` VARCHAR(45) NULL DEFAULT NULL AFTER `changedModelId`; diff --git a/db/changes/10180-holyWeek/01-componentRenameMismatchXImbalance.sql b/db/changes/10180-holyWeek/01-componentRenameMismatchXImbalance.sql deleted file mode 100644 index 34dd3be3c..000000000 --- a/db/changes/10180-holyWeek/01-componentRenameMismatchXImbalance.sql +++ /dev/null @@ -1 +0,0 @@ -UPDATE `vn`.`component` SET `code` = 'imbalance' WHERE (`id` = '36'); diff --git a/db/changes/10180-holyWeek/01-migrateFromTicketToTicketWeekly.sql b/db/changes/10180-holyWeek/01-migrateFromTicketToTicketWeekly.sql deleted file mode 100644 index 939a8e73c..000000000 --- a/db/changes/10180-holyWeek/01-migrateFromTicketToTicketWeekly.sql +++ /dev/null @@ -1,6 +0,0 @@ -UPDATE vn.ticketWeekly tw - JOIN vn.ticket t ON t.id = tw.ticketFk - JOIN vn.agencyMode am ON am.id = t.agencyModeFk -SET tw.agencyModeFk = t.agencyModeFk -WHERE am.name NOT LIKE '%turno%'; - diff --git a/db/changes/10180-holyWeek/01-zoneConfigAlterTable.sql b/db/changes/10180-holyWeek/01-zoneConfigAlterTable.sql deleted file mode 100644 index 5f4e7114b..000000000 --- a/db/changes/10180-holyWeek/01-zoneConfigAlterTable.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `vn`.`zoneConfig` -ADD COLUMN `forwardDays` INT(10) NOT NULL DEFAULT 7 COMMENT 'days forward to show zone_upcomingDeliveries' AFTER `scope`; diff --git a/db/changes/10180-holyWeek/02-catalog_calculate.sql b/db/changes/10180-holyWeek/02-catalog_calculate.sql deleted file mode 100644 index eeadb7241..000000000 --- a/db/changes/10180-holyWeek/02-catalog_calculate.sql +++ /dev/null @@ -1,148 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `catalog_calculate`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `catalog_calculate`( - vLanded DATE, - vAddressFk INT, - vAgencyModeFk INT) -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 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; - - -- Establece los almacenes y las fechas que van a entrar al disponible - - CALL vn.zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, FALSE); - - 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(); - - 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), - 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); - CALL buyUltimate (vWarehouseFk, vShipped); - - 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); - - 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 MIN(price) price, itemFk, priceKg - FROM tmp.ticketComponentPrice - WHERE warehouseFk = vWarehouseFk - GROUP BY itemFk - ) bl ON bl.itemFk = tl.itemFk - WHERE tl.zoneFk = vZoneFk AND tl.warehouseFk = vWarehouseFk - GROUP BY tl.itemFk; - -- on duplicatekey update - - END LOOP; - - CLOSE cTravelTree; - -END$$ - -DELIMITER ; - diff --git a/db/changes/10180-holyWeek/02-catalog_componentCalculate.sql b/db/changes/10180-holyWeek/02-catalog_componentCalculate.sql deleted file mode 100644 index 04ec1330a..000000000 --- a/db/changes/10180-holyWeek/02-catalog_componentCalculate.sql +++ /dev/null @@ -1,262 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `catalog_componentCalculate`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `catalog_componentCalculate`( - vZoneFk INT, - vAddressFk INT, - vShipped DATE, - vWarehouseFk INT) -proc: BEGIN -/** - * Calcula los componentes de los articulos de tmp.ticketLot - * - * @param vZoneFk para calcular el transporte - * @param vAddressFk Consignatario - * @param vShipped dia de salida del pedido - * @param tmp.ticketLot (warehouseFk, available, itemFk, buyFk, zoneFk) - * - * @return tmp.ticketComponent(itemFk, warehouseFk, available, rate2, rate3, minPrice, - * packing, grouping, groupingMode, buyFk, typeFk) - * @return tmp.ticketComponentPrice (warehouseFk, itemFk, rate, grouping, price) - */ - DECLARE vClientFk INT; - DECLARE vGeneralInflationCoefficient INT DEFAULT 1; - DECLARE vMinimumDensityWeight INT DEFAULT 167; - DECLARE vBoxVolume BIGINT; -- DEFAULT 138000; - DECLARE vSpecialPriceComponent INT DEFAULT 10; - DECLARE vDeliveryComponent INT DEFAULT 15; - DECLARE vRecoveryComponent INT DEFAULT 17; - DECLARE vSellByPacketComponent INT DEFAULT 22; - DECLARE vBuyValueComponent INT DEFAULT 28; - DECLARE vMarginComponent INT DEFAULT 29; - DECLARE vDiscountLastItemComponent INT DEFAULT 32; - DECLARE vExtraBaggedComponent INT DEFAULT 38; - DECLARE vManaAutoComponent INT DEFAULT 39; - - SELECT volume INTO vBoxVolume - FROM vn.packaging - WHERE id = '94'; - - SELECT clientFk INTO vClientFK - FROM address - WHERE id = vAddressFk; - - SET @rate2 := 0; - SET @rate3 := 0; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCalculate; - CREATE TEMPORARY TABLE tmp.ticketComponentCalculate - (PRIMARY KEY (itemFk, warehouseFk)) - ENGINE = MEMORY - SELECT - tl.itemFk, tl.warehouseFk, tl.available, - IF((@rate2 := IFNULL(pf.rate2, b.price2)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate2) * 1.0 rate2, - IF((@rate3 := IFNULL(pf.rate3, b.price3)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate3) * 1.0 rate3, - IFNULL(pf.rate3, 0) AS minPrice, - IFNULL(pf.packing, b.packing) packing, - IFNULL(pf.`grouping`, b.`grouping`) `grouping`, - ABS(IFNULL(pf.box, b.groupingMode)) groupingMode, - tl.buyFk, - i.typeFk, - IF(i.hasKgPrice, b.weight / b.packing, NULL) weightGrouping - FROM tmp.ticketLot tl - JOIN buy b ON b.id = tl.buyFk - JOIN item i ON i.id = tl.itemFk - JOIN itemType it ON it.id = i.typeFk - LEFT JOIN itemCategory ic ON ic.id = it.categoryFk - LEFT JOIN specialPrice sp ON sp.itemFk = i.id AND sp.clientFk = vClientFk - LEFT JOIN ( - SELECT * FROM ( - SELECT pf.itemFk, pf.`grouping`, pf.packing, pf.box, pf.rate2, pf.rate3, zw.warehouseFk - FROM priceFixed pf - JOIN zoneWarehouse zw ON zw.zoneFk = vZoneFk AND (zw.warehouseFk = pf.warehouseFk OR pf.warehouseFk = 0) - WHERE vShipped BETWEEN pf.started AND pf.ended ORDER BY pf.itemFk, pf.warehouseFk DESC - ) tpf - GROUP BY tpf.itemFk, tpf.warehouseFk - ) pf ON pf.itemFk = tl.itemFk AND pf.warehouseFk = tl.warehouseFk - WHERE b.buyingValue + b.freightValue + b.packageValue + b.comissionValue > 0.01 AND ic.display <> 0 - AND tl.zoneFk = vZoneFk AND tl.warehouseFk = vWarehouseFk; - - INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT - tcc.warehouseFk, - tcc.itemFk, - vBuyValueComponent, - b.buyingValue + b.freightValue + b.packageValue + b.comissionValue - FROM tmp.ticketComponentCalculate tcc - JOIN buy b ON b.id = tcc.buyFk; - - INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT - tcc.warehouseFk, - tcc.itemFk, - vMarginComponent, - tcc.rate3 - b.buyingValue - b.freightValue - b.packageValue - b.comissionValue - FROM tmp.ticketComponentCalculate tcc - JOIN buy b ON b.id = tcc.buyFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentBase; - CREATE TEMPORARY TABLE tmp.ticketComponentBase ENGINE = MEMORY - SELECT tc.itemFk, ROUND(SUM(tc.cost), 4) AS base, tc.warehouseFk - FROM tmp.ticketComponent tc - JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tc.itemFk AND tcc.warehouseFk = tc.warehouseFk - GROUP BY tc.itemFk, warehouseFk; - - INSERT INTO tmp.ticketComponent - SELECT tcb.warehouseFk, tcb.itemFk, vRecoveryComponent, ROUND(tcb.base * LEAST(cr.priceIncreasing, 0.25), 3) - FROM tmp.ticketComponentBase tcb - JOIN claimRatio cr ON cr.clientFk = vClientFk - WHERE cr.priceIncreasing > 0.009; - - INSERT INTO tmp.ticketComponent - SELECT tcb.warehouseFk, tcb.itemFk, vManaAutoComponent, ROUND(base * (0.01 + wm.pricesModifierRate), 3) as manaAuto - FROM tmp.ticketComponentBase tcb - JOIN `client` c on c.id = vClientFk - JOIN workerMana wm ON c.salesPersonFk = wm.workerFk - WHERE wm.isPricesModifierActivated - HAVING manaAuto <> 0; - - INSERT INTO tmp.ticketComponent - SELECT tcb.warehouseFk, - tcb.itemFk, - c.id, - GREATEST(IFNULL(ROUND(tcb.base * c.tax, 4), 0), tcc.minPrice - tcc.rate3) - FROM tmp.ticketComponentBase tcb - JOIN component c - JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tcb.itemFk AND tcc.warehouseFk = tcb.warehouseFk - LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk - WHERE c.id = vDiscountLastItemComponent AND c.tax <> 0 AND tcc.minPrice < tcc.rate3 AND sp.value IS NULL; - - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, tcc.itemFk, vSellByPacketComponent, tcc.rate2 - tcc.rate3 - FROM tmp.ticketComponentCalculate tcc - JOIN buy b ON b.id = tcc.buyFk - LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk - WHERE sp.value IS NULL; - - DROP TEMPORARY TABLE IF EXISTS tmp.zone; - CREATE TEMPORARY TABLE IF NOT EXISTS tmp.zone (INDEX (id)) - ENGINE = MEMORY - SELECT vZoneFk id; - - CALL zone_getOptionsForShipment(vShipped, TRUE); - - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFK, - tcc.itemFk, - vDeliveryComponent, - vGeneralInflationCoefficient - * ROUND(( - i.compression - * ic.cm3 - * IF(am.deliveryMethodFk = 1, (GREATEST(i.density, vMinimumDensityWeight) / vMinimumDensityWeight), 1) - * IFNULL((zo.price - zo.bonus) - * 1/*amz.inflation*/ , 50)) / vBoxVolume, 4 - ) cost - FROM tmp.ticketComponentCalculate tcc - JOIN item i ON i.id = tcc.itemFk - JOIN tmp.zoneOption zo ON zo.zoneFk = vZoneFk - JOIN zone z ON z.id = vZoneFk - JOIN agencyMode am ON am.id = z.agencyModeFk - LEFT JOIN itemCost ic ON ic.warehouseFk = tcc.warehouseFk - AND ic.itemFk = tcc.itemFk - HAVING cost <> 0; - - DROP TEMPORARY TABLE tmp.zoneOption; - - IF (SELECT COUNT(*) FROM vn.addressForPackaging WHERE addressFk = vAddressFk) THEN - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, b.itemFk, vExtraBaggedComponent, ap.packagingValue cost - FROM tmp.ticketComponentCalculate tcc - JOIN vn.addressForPackaging ap - WHERE ap.addressFk = vAddressFk; - END IF; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCopy; - CREATE TEMPORARY TABLE tmp.ticketComponentCopy ENGINE = MEMORY - SELECT * FROM tmp.ticketComponent; - - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, - tcc.itemFk, - vSpecialPriceComponent, - sp.value - SUM(tcc.cost) sumCost - FROM tmp.ticketComponentCopy tcc - JOIN component c ON c.id = tcc.componentFk - JOIN specialPrice sp ON sp.clientFk = vClientFK AND sp.itemFk = tcc.itemFk - WHERE c.classRate IS NULL - GROUP BY tcc.itemFk, tcc.warehouseFk - HAVING ABS(sumCost) > 0.001; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentSum; - CREATE TEMPORARY TABLE tmp.ticketComponentSum - (INDEX (itemFk, warehouseFk)) - ENGINE = MEMORY - SELECT SUM(cost) sumCost, tc.itemFk, tc.warehouseFk, c.classRate - FROM tmp.ticketComponent tc - JOIN component c ON c.id = tc.componentFk - GROUP BY tc.itemFk, tc.warehouseFk, c.classRate; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentRate; - CREATE TEMPORARY TABLE tmp.ticketComponentRate ENGINE = MEMORY - SELECT tcc.warehouseFk, - tcc.itemFk, - 1 rate, - IF(tcc.groupingMode = 1, tcc.`grouping`, 1) `grouping`, - CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) price, - CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) / weightGrouping priceKg - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE IFNULL(tcs.classRate, 1) = 1 - AND tcc.groupingMode < 2 AND (tcc.packing > tcc.`grouping` or tcc.groupingMode = 0) - GROUP BY tcs.warehouseFk, tcs.itemFk; - - INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg) - SELECT - tcc.warehouseFk, - tcc.itemFk, - 2 rate, - tcc.packing `grouping`, - SUM(tcs.sumCost) price, - SUM(tcs.sumCost) / weightGrouping priceKg - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE tcc.available IS NULL OR (IFNULL(tcs.classRate, 2) = 2 - AND tcc.packing > 0 AND tcc.available >= tcc.packing) - GROUP BY tcs.warehouseFk, tcs.itemFk; - - INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg) - SELECT - tcc.warehouseFk, - tcc.itemFk, - 3 rate, - tcc.available `grouping`, - SUM(tcs.sumCost) price, - SUM(tcs.sumCost) / weightGrouping priceKg - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE IFNULL(tcs.classRate, 3) = 3 - GROUP BY tcs.warehouseFk, tcs.itemFk; - - INSERT INTO tmp.ticketComponentPrice (warehouseFk, itemFk, rate, `grouping`, price, priceKg) - SELECT * FROM ( - SELECT * FROM tmp.ticketComponentRate ORDER BY price - ) t - GROUP BY itemFk, warehouseFk, `grouping`; - - DROP TEMPORARY TABLE - tmp.ticketComponentCalculate, - tmp.ticketComponentSum, - tmp.ticketComponentBase, - tmp.ticketComponentRate, - tmp.ticketComponentCopy; - -END$$ - -DELIMITER ; - diff --git a/db/changes/10180-holyWeek/02-catalog_componentPrepare.sql b/db/changes/10180-holyWeek/02-catalog_componentPrepare.sql deleted file mode 100644 index 98b93a97e..000000000 --- a/db/changes/10180-holyWeek/02-catalog_componentPrepare.sql +++ /dev/null @@ -1,33 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `catalog_componentPrepare`; - -DELIMITER $$ -USE `vn`$$ -CREATE PROCEDURE `catalog_componentPrepare` () -BEGIN - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent; - CREATE TEMPORARY TABLE tmp.ticketComponent ( - `warehouseFk` INT UNSIGNED NOT NULL, - `itemFk` INT NOT NULL, - `componentFk` INT UNSIGNED NOT NULL, - `cost` DECIMAL(10,4) NOT NULL, - INDEX `itemWarehouse` USING BTREE (`itemFk` ASC, `warehouseFk` ASC), - UNIQUE `fkItemWarehouseComponent` (`itemFk` ASC, `warehouseFk` ASC, `componentFk` ASC) - )ENGINE=MEMORY DEFAULT CHARSET=utf8; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentPrice; - CREATE TEMPORARY TABLE tmp.ticketComponentPrice ( - `warehouseFk` INT UNSIGNED NOT NULL, - `itemFk` INT NOT NULL, - `rate` INT NOT NULL, - `grouping` INT UNSIGNED NOT NULL, - `price` DECIMAL(10,4) NOT NULL, - `priceKg` DECIMAL(10,4), - INDEX `itemWarehouse` USING BTREE (`itemFk` ASC, `warehouseFk` ASC), - UNIQUE `fkItemWarehouseRate` (`itemFk` ASC, `warehouseFk` ASC, `rate` ASC) - )ENGINE=MEMORY DEFAULT CHARSET=utf8; -END$$ - -DELIMITER ; - diff --git a/db/changes/10180-holyWeek/02-catalog_componentPurge.sql b/db/changes/10180-holyWeek/02-catalog_componentPurge.sql deleted file mode 100644 index 2b744b5f0..000000000 --- a/db/changes/10180-holyWeek/02-catalog_componentPurge.sql +++ /dev/null @@ -1,16 +0,0 @@ - -USE `vn`; -DROP procedure IF EXISTS `vn`.`catalog_componentPurge`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `catalog_componentPurge`() -BEGIN - DROP TEMPORARY TABLE - tmp.ticketComponentPrice, - tmp.ticketComponent, - tmp.ticketLot; -END$$ - -DELIMITER ; -; diff --git a/db/changes/10180-holyWeek/02-order_confirmWithUser.sql b/db/changes/10180-holyWeek/02-order_confirmWithUser.sql deleted file mode 100644 index c9acdc038..000000000 --- a/db/changes/10180-holyWeek/02-order_confirmWithUser.sql +++ /dev/null @@ -1,250 +0,0 @@ -USE `hedera`; -DROP procedure IF EXISTS `order_confirmWithUser`; - -DELIMITER $$ -USE `hedera`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `order_confirmWithUser`(IN `vOrder` INT, IN `vUserId` INT) -BEGIN -/** - * Confirms an order, creating each of its tickets on the corresponding - * date, store and user. - * - * @param vOrder The order identifier - * @param vUser The user identifier - */ - DECLARE vOk BOOL; - DECLARE vDone BOOL DEFAULT FALSE; - DECLARE vWarehouse INT; - DECLARE vShipment DATETIME; - DECLARE vTicket INT; - DECLARE vNotes VARCHAR(255); - DECLARE vItem INT; - DECLARE vConcept VARCHAR(30); - DECLARE vAmount INT; - DECLARE vPrice DECIMAL(10,2); - DECLARE vSale INT; - DECLARE vRate INT; - DECLARE vRowId INT; - DECLARE vDelivery DATE; - DECLARE vAddress INT; - DECLARE vIsConfirmed BOOL; - DECLARE vClientId INT; - DECLARE vCompanyId INT; - DECLARE vAgencyModeId INT; - DECLARE TICKET_FREE INT DEFAULT 2; - - 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 - GROUP BY r.warehouse_id; - - DECLARE cRows CURSOR FOR - SELECT r.id, r.item_id, i.name, r.amount, r.price, r.rate - FROM order_row r - JOIN vn.item i ON i.id = r.item_id - WHERE r.amount != 0 - AND r.warehouse_id = vWarehouse - AND r.order_id = vOrder - ORDER BY r.rate DESC; - - DECLARE CONTINUE HANDLER FOR NOT FOUND - SET vDone = TRUE; - - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - - -- Carga los datos del pedido - - SELECT o.date_send, o.address_id, o.note, - o.confirmed, a.clientFk, o.company_id, o.agency_id - INTO vDelivery, vAddress, vNotes, - vIsConfirmed, vClientId, vCompanyId, vAgencyModeId - FROM hedera.`order` o - JOIN vn.address a ON a.id = o.address_id - WHERE o.id = vOrder; - - -- Comprueba que el pedido no está confirmado - - IF vIsConfirmed THEN - CALL util.throw ('ORDER_ALREADY_CONFIRMED'); - END IF; - - -- Comprueba que el pedido no está vacío - - SELECT COUNT(*) > 0 INTO vOk - FROM order_row WHERE order_id = vOrder AND amount > 0; - - IF NOT vOk THEN - CALL util.throw ('ORDER_EMPTY'); - END IF; - - -- Carga las fechas de salida de cada almacén - - CALL vn.zone_getShipped (vDelivery, vAddress, vAgencyModeId, FALSE); - - -- Trabajador que realiza la acción - - IF vUserId IS NULL THEN - SELECT employeeFk INTO vUserId FROM orderConfig; - END IF; - - -- Crea los tickets del pedido - - START TRANSACTION; - - OPEN cDates; - - lDates: - LOOP - SET vTicket = NULL; - SET vDone = FALSE; - FETCH cDates INTO vShipment, vWarehouse; - - IF vDone THEN - LEAVE lDates; - END IF; - - -- Busca un ticket existente que coincida con los parametros - - SELECT t.id INTO vTicket - FROM vn.ticket t - LEFT JOIN vn.ticketState tls on tls.ticket = t.id - JOIN `order` o - ON o.address_id = t.addressFk - AND vWarehouse = t.warehouseFk - AND o.agency_id = t.agencyModeFk - AND o.date_send = t.landed - AND vShipment = DATE(t.shipped) - WHERE o.id = vOrder - AND t.invoiceOutFk IS NULL - AND IFNULL(tls.alertLevel,0) = 0 - AND t.clientFk <> 1118 - LIMIT 1; - - -- Crea el ticket en el caso de no existir uno adecuado - - IF vTicket IS NULL - THEN - CALL vn.ticketCreateWithUser( - vClientId, - IFNULL(vShipment, CURDATE()), - vWarehouse, - vCompanyId, - vAddress, - vAgencyModeId, - NULL, - vDelivery, - vUserId, - vTicket - ); - ELSE - INSERT INTO vncontrol.inter - SET Id_Ticket = vTicket, - Id_Trabajador = vUserId, - state_id = TICKET_FREE; - END IF; - - INSERT IGNORE INTO vn.orderTicket - SET orderFk = vOrder, - ticketFk = vTicket; - - -- Añade las notas - - IF vNotes IS NOT NULL AND vNotes != '' - THEN - INSERT INTO vn.ticketObservation SET - ticketFk = vTicket, - observationTypeFk = 4 /* salesperson */ , - `description` = vNotes - ON DUPLICATE KEY UPDATE - `description` = CONCAT(VALUES(`description`),'. ', `description`); - END IF; - - -- Añade los movimientos y sus componentes - - OPEN cRows; - - lRows: - LOOP - SET vDone = FALSE; - FETCH cRows INTO vRowId, vItem, vConcept, vAmount, vPrice, vRate; - - IF vDone THEN - LEAVE lRows; - END IF; - SET vSale = NULL; - SELECT s.id INTO vSale - FROM vn.sale s - WHERE ticketFk = vTicket - AND price = vPrice - AND itemFk = vItem - LIMIT 1; - IF vSale THEN - UPDATE vn.sale - SET quantity = quantity + vAmount - WHERE id = vSale; - ELSE - INSERT INTO vn.sale - SET - itemFk = vItem, - ticketFk = vTicket, - concept = vConcept, - quantity = vAmount, - price = vPrice, - priceFixed = 0, - isPriceFixed = TRUE; - - SET vSale = LAST_INSERT_ID(); - - INSERT INTO vn.saleComponent - (saleFk, componentFk, `value`) - SELECT vSale, cm.component_id, cm.price - FROM order_component cm - JOIN vn.component c ON c.id = cm.component_id - WHERE cm.order_row_id = vRowId - GROUP BY vSale, cm.component_id; - END IF; - UPDATE order_row SET Id_Movimiento = vSale - WHERE id = vRowId; - - END LOOP; - - CLOSE cRows; - - -- Fija el coste - - DROP TEMPORARY TABLE IF EXISTS tComponents; - CREATE TEMPORARY TABLE tComponents - (INDEX (saleFk)) - ENGINE = MEMORY - SELECT SUM(sc.`value`) valueSum, sc.saleFk - FROM vn.saleComponent sc - JOIN vn.component c ON c.id = sc.componentFk - JOIN vn.componentType ct ON ct.id = c.typeFk AND ct.isBase - JOIN vn.sale s ON s.id = sc.saleFk - WHERE s.ticketFk = vTicket - GROUP BY sc.saleFk; - - UPDATE vn.sale s - JOIN tComponents mc ON mc.saleFk = s.id - SET s.priceFixed = valueSum; - - DROP TEMPORARY TABLE tComponents; - END LOOP; - - CLOSE cDates; - - DELETE FROM basketOrder WHERE orderFk = vOrder; - UPDATE `order` SET confirmed = TRUE, confirm_date = NOW() - WHERE id = vOrder; - - COMMIT; -END$$ - -DELIMITER ; \ No newline at end of file diff --git a/db/changes/10180-holyWeek/02-sale_calculateComponent.sql b/db/changes/10180-holyWeek/02-sale_calculateComponent.sql deleted file mode 100644 index 979608a35..000000000 --- a/db/changes/10180-holyWeek/02-sale_calculateComponent.sql +++ /dev/null @@ -1,103 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `sale_calculateComponent`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `sale_calculateComponent`(vSale INT, vOption INT) -proc: BEGIN -/** - * Actualiza los componentes - * - * @param vSale Delivery date - * @param vOption indica en que componente pone el descuadre, NULL en casos habituales - */ - DECLARE vShipped DATE; - DECLARE vWarehouseFk SMALLINT; - DECLARE vAgencyModeFk INT; - DECLARE vAddressFk INT; - DECLARE vTicketFk BIGINT; - DECLARE vItemFk BIGINT; - DECLARE vLanded DATE; - DECLARE vIsEditable BOOLEAN; - DECLARE vZoneFk INTEGER; - - SELECT t.refFk IS NULL AND (IFNULL(ts.alertLevel, 0) = 0 OR s.price = 0), - s.ticketFk, - s.itemFk , - t.zoneFk, - t.warehouseFk, - t.shipped, - t.addressFk, - t.agencyModeFk, - t.landed - INTO vIsEditable, - vTicketFk, - vItemFk, - vZoneFk, - vWarehouseFk, - vShipped, - vAddressFk, - 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; - - IF vLanded IS NULL OR vZoneFk IS NULL THEN - - CALL zone_getLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk); - - IF (SELECT COUNT(*) FROM tmp.zoneGetLanded LIMIT 1) = 0 THEN - CALL util.throw('There is no zone for these parameters'); - END IF; - - 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; - DROP TEMPORARY TABLE tmp.zoneGetLanded; - - END IF; - - -- rellena la tabla buyUltimate con la ultima compra - CALL buyUltimate (vWarehouseFk, vShipped); - - DELETE FROM tmp.buyUltimate WHERE itemFk != vItemFk; - - 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; - - 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; - - CALL ticketComponentUpdateSale(vOption); - - INSERT INTO ticketLog (originFk, userFk, `action`, description) - VALUES (vTicketFk, account.userGetId(), 'update', CONCAT('Bionizo linea id ', vSale)); - - CALL catalog_componentPurge(); - DROP TEMPORARY TABLE tmp.buyUltimate; - DROP TEMPORARY TABLE tmp.sale; -END$$ - -DELIMITER ; - diff --git a/db/changes/10180-holyWeek/02-ticketCalculateClon.sql b/db/changes/10180-holyWeek/02-ticketCalculateClon.sql deleted file mode 100644 index 6c9518b3b..000000000 --- a/db/changes/10180-holyWeek/02-ticketCalculateClon.sql +++ /dev/null @@ -1,93 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `ticketCalculateClon`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `ticketCalculateClon`(IN vTicketNew INT, vTicketOld INT) -BEGIN -/* - * Recalcula los componentes un ticket clonado, - * las lineas a precio cero fuerza para que tengan precio, el resto lo respeta - * @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); - UPDATE ticket t - JOIN tmp.zoneGetLanded zgl ON t.warehouseFk = zgl.warehouseFk - SET t.landed = zgl.landed, - t.zone = 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, vAgencyMode, 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; - - CALL ticketComponentUpdateSale(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; - - CALL ticketComponentUpdateSale(6); - - -- Log - CALL `logAdd`(vTicketNew, 'update', ' ticket' , 'Bioniza Ticket'); - - -- Limpieza - CALL catalog_componentPurge(); - DROP TEMPORARY TABLE IF EXISTS - tmp.buyUltimate, - tmp.sale, - tmp.zoneGetLanded; - -END$$ - -DELIMITER ; - diff --git a/db/changes/10180-holyWeek/02-ticketCalculateSaleForcePrice.sql b/db/changes/10180-holyWeek/02-ticketCalculateSaleForcePrice.sql deleted file mode 100644 index 99ecf739e..000000000 --- a/db/changes/10180-holyWeek/02-ticketCalculateSaleForcePrice.sql +++ /dev/null @@ -1,61 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `ticketCalculateSaleForcePrice`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `ticketCalculateSaleForcePrice`(IN vSale BIGINT) -proc: BEGIN - - DECLARE vShipped DATE; - DECLARE vWarehouseFk SMALLINT; - DECLARE vAddressFk INT; - DECLARE vTicket BIGINT; - DECLARE vItem BIGINT; - DECLARE vZoneFk INT; - - SELECT ticketFk, itemFk - INTO vTicket, vItem - FROM sale - WHERE id = vSale; - - SELECT t.warehouseFk, DATE(t.shipped), t.addressFk, t.zoneFk - INTO vWarehouseFk, vShipped, vAddressFk, vZoneFk - FROM agencyMode a - JOIN ticket t ON t.agencyModeFk = a.id - WHERE t.id = vTicket; - - IF vZoneFk IS NULL THEN - CALL util.throw('ticket without zone'); - END IF; - - CALL buyUltimate (vWarehouseFk, vShipped); - - DELETE FROM tmp.buyUltimate WHERE itemFk != vItem; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; - CREATE TEMPORARY TABLE tmp.ticketLot - SELECT vWarehouseFk warehouseFk, NULL available, vItem itemFk, buyFk, vZoneFk zoneFk - FROM tmp.buyUltimate - WHERE itemFk = vItem; - - 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; - - CALL ticketComponentUpdateSale(1); - - INSERT INTO vn.ticketLog (originFk, userFk, `action`, description) - VALUES (vTicket, account.userGetId(), 'update', CONCAT('Bionizo linea id ', vSale)); - - CALL catalog_componentPurge(); - DROP TEMPORARY TABLE tmp.buyUltimate; - DROP TEMPORARY TABLE tmp.sale; - -END$$ - -DELIMITER ; - diff --git a/db/changes/10180-holyWeek/02-ticketComponentUpdateSale.sql b/db/changes/10180-holyWeek/02-ticketComponentUpdateSale.sql deleted file mode 100644 index b58189ae6..000000000 --- a/db/changes/10180-holyWeek/02-ticketComponentUpdateSale.sql +++ /dev/null @@ -1,154 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `ticketComponentUpdateSale`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `ticketComponentUpdateSale`(vOption INT) -BEGIN -/** - * A partir de la tabla tmp.sale, crea los Movimientos_componentes - * y modifica el campo Preu de la tabla Movimientos - * - * @param i_option integer tipo de actualizacion - * @param table tmp.sale tabla memory con el campo saleFk, warehouseFk - **/ - DECLARE vComponentFk INT; - DECLARE vRenewComponents BOOLEAN; - DECLARE vKeepPrices BOOLEAN; - - CASE vOption - WHEN 1 THEN - SET vRenewComponents = TRUE; - SET vKeepPrices = FALSE; - WHEN 2 THEN - SELECT id INTO vComponentFk FROM component WHERE `code` = 'debtCollection'; - SET vRenewComponents = TRUE; - SET vKeepPrices = TRUE; - WHEN 3 THEN - SELECT id INTO vComponentFk FROM component WHERE `code` = 'mana'; - SET vRenewComponents = TRUE; - SET vKeepPrices = TRUE; - WHEN 4 THEN - SELECT id INTO vComponentFk FROM component WHERE `code` = 'buyerDiscount'; - SET vRenewComponents = TRUE; - SET vKeepPrices = TRUE; - /* WHEN 5 THEN - SET vComponentFk = 35; - SET vRenewComponents = TRUE; - SET vKeepPrices = TRUE;*/ - WHEN 6 THEN - SELECT id INTO vComponentFk FROM component WHERE `code` = 'imbalance'; - SET vRenewComponents = TRUE; - SET vKeepPrices = TRUE; - WHEN 7 THEN - REPLACE INTO saleComponent(saleFk, componentFk, value) - SELECT s.id, 28, ROUND(((s.price * (100 - s.discount) / 100) - SUM(IFNULL(sc.value, 0))) * 0.8, 3) - FROM sale s - JOIN tmp.sale tmps ON tmps.saleFk = s.id - LEFT JOIN saleComponent sc ON sc.saleFk = s.id - AND sc.componentFk NOT IN (28, 29) - GROUP BY s.id; - - REPLACE INTO saleComponent(saleFk, componentFk, value) - SELECT s.id, 29, ROUND(((s.price * (100 - s.discount) / 100) - SUM(IFNULL(sc.value, 0))) * 0.2, 3) - FROM sale s - JOIN tmp.sale tmps ON tmps.saleFk = s.id - LEFT JOIN saleComponent sc ON sc.saleFk = s.id - AND sc.componentFk NOT IN (28, 29) - GROUP BY s.id; - - SET vRenewComponents = FALSE; - SET vKeepPrices = FALSE; - WHEN 8 THEN - DELETE sc.* - FROM tmp.sale tmps JOIN saleComponent sc ON sc.saleFk = tmps.saleFk; - - REPLACE INTO saleComponent(saleFk, componentFk, value) - SELECT s.id, 28, ROUND(((s.price * (100 - s.discount) / 100)), 3) - FROM sale s - JOIN tmp.sale tmps ON tmps.saleFk = s.id; - - SET vRenewComponents = FALSE; - SET vKeepPrices = FALSE; - WHEN 9 THEN - SET vRenewComponents = TRUE; - SET vKeepPrices = TRUE; - END CASE; - - IF vRenewComponents THEN - DELETE sc.* - FROM tmp.sale tmps - JOIN saleComponent sc ON sc.saleFk = tmps.saleFk - JOIN `component` c ON c.id = sc.componentFk - WHERE c.isRenewable; - - REPLACE INTO saleComponent(saleFk, componentFk, value) - SELECT s.id, tc.componentFk, tc.cost - FROM sale s - JOIN tmp.sale tmps ON tmps.saleFk = s.id - JOIN tmp.ticketComponent tc ON tc.itemFk = s.itemFk AND tc.warehouseFk = tmps.warehouseFk - LEFT JOIN saleComponent sc ON sc.saleFk = s.id - AND sc.componentFk = tc.componentFk - LEFT JOIN `component` c ON c.id = tc.componentFk - WHERE IF(sc.componentFk IS NULL AND NOT c.isRenewable, FALSE, TRUE); - END IF; - - IF vKeepPrices THEN - REPLACE INTO saleComponent(saleFk, componentFk, value) - SELECT s.id, vComponentFk, ROUND((s.price * (100 - s.discount) / 100) - SUM(sc.value), 3) dif - FROM sale s - JOIN tmp.sale tmps ON tmps.saleFk = s.id - LEFT JOIN saleComponent sc ON sc.saleFk = s.id - WHERE sc.saleFk <> vComponentFk - GROUP BY s.id - HAVING dif <> 0; - ELSE - UPDATE sale s - JOIN item i on i.id = s.itemFk - JOIN itemType it on it.id = i.typeFk - JOIN (SELECT SUM(sc.value) sumValue, sc.saleFk - FROM saleComponent sc - JOIN tmp.sale tmps ON tmps.saleFk = sc.saleFk - GROUP BY sc.saleFk) sc ON sc.saleFk = s.id - SET s.price = sumValue - WHERE it.code != 'PRT' ; - - REPLACE INTO saleComponent(saleFk, componentFk, value) - SELECT s.id, 21, ROUND((s.price * (100 - s.discount) / 100) - SUM(value), 3) saleValue - FROM sale s - JOIN tmp.sale tmps ON tmps.saleFk = s.id - LEFT JOIN saleComponent sc ON sc.saleFk = s.id - WHERE sc.componentFk != 21 - GROUP BY s.id - HAVING ROUND(saleValue, 4) <> 0; - END IF; - - UPDATE sale s - JOIN ( - SELECT SUM(sc.value) sumValue, sc.saleFk - FROM saleComponent sc - JOIN tmp.sale tmps ON tmps.saleFk = sc.saleFk - JOIN `component` c ON c.id = sc.componentFk - JOIN componentType ct on ct.id = c.typeFk AND ct.isBase - GROUP BY sc.saleFk) sc ON sc.saleFk = s.id - SET s.priceFixed = sumValue, s.isPriceFixed = 1; - - DELETE sc.* - FROM saleComponent sc - JOIN tmp.sale tmps ON tmps.saleFk = sc.saleFk - JOIN sale s on s.id = sc.saleFk - JOIN item i ON i.id = s.itemFk - JOIN itemType it ON it.id = i.typeFk - WHERE it.code = 'PRT'; - - INSERT INTO saleComponent(saleFk, componentFk, value) - SELECT s.id, 15, s.price - FROM sale s - JOIN tmp.sale tmps ON tmps.saleFk = s.id - JOIN item i ON i.id = s.itemFK - JOIN itemType it ON it.id = i.typeFk - WHERE it.code = 'PRT' AND s.price > 0; -END$$ - -DELIMITER ; - diff --git a/db/changes/10180-holyWeek/02-ticket_componentMakeUpdate.sql b/db/changes/10180-holyWeek/02-ticket_componentMakeUpdate.sql deleted file mode 100644 index 7fdf3f193..000000000 --- a/db/changes/10180-holyWeek/02-ticket_componentMakeUpdate.sql +++ /dev/null @@ -1,107 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `ticket_componentMakeUpdate`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `ticket_componentMakeUpdate`( - vTicketFk INT, - vClientFk INT, - vAgencyModeFk INT, - vAddressFk INT, - vZoneFk INT, - vWarehouseFk TINYINT, - vCompanyFk SMALLINT, - vShipped DATETIME, - vLanded DATE, - vIsDeleted BOOLEAN, - vHasToBeUnrouted BOOLEAN, - vOption INT) -BEGIN -/** - * Modifica en el ticket los campos que se le pasan por parámetro - * y cambia sus componentes - * - * @param vTicketFk Id del ticket a modificar - * @param vClientFk nuevo cliente - * @param vAgencyModeFk nueva agencia - * @param vAddressFk nuevo consignatario - * @param vZoneFk nueva zona - * @param vWarehouseFk nuevo almacen - * @param vCompanyFk nueva empresa - * @param vShipped nueva fecha del envio de mercancia - * @param vLanded nueva fecha de recepcion de mercancia - * @param vIsDeleted si se borra el ticket - * @param vHasToBeUnrouted si se le elimina la ruta al ticket - * @param vOption opcion para el case del proc ticketComponentUpdateSale - */ - DECLARE vPrice DECIMAL(10,2); - DECLARE vBonus DECIMAL(10,2); - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - - CALL ticket_componentPreview (vTicketFk, vLanded, vAddressFk, vZoneFk, vWarehouseFk); - - START TRANSACTION; - - IF (SELECT addressFk FROM ticket WHERE id = vTicketFk) <> vAddressFk THEN - - UPDATE ticket t - JOIN address a ON a.id = vAddressFk - SET t.nickname = a.nickname - WHERE t.id = vTicketFk; - - END IF; - - CALL zone_getShippedWarehouse(vlanded, vAddressFk, vAgencyModeFk); - - SELECT zoneFk, price, bonus INTO vZoneFk, vPrice, vBonus - FROM tmp.zoneGetShipped - WHERE shipped = vShipped AND warehouseFk = vWarehouseFk LIMIT 1; - - UPDATE ticket t - SET - t.clientFk = vClientFk, - t.agencyModeFk = vAgencyModeFk, - t.addressFk = vAddressFk, - t.zoneFk = vZoneFk, - t.zonePrice = vPrice, - t.zoneBonus = vBonus, - t.warehouseFk = vWarehouseFk, - t.companyFk = vCompanyFk, - t.landed = vLanded, - t.shipped = vShipped, - t.isDeleted = vIsDeleted - WHERE - t.id = vTicketFk; - - IF vHasToBeUnrouted THEN - UPDATE ticket t SET t.routeFk = NULL - WHERE t.id = vTicketFk; - END IF; - - IF vOption <> 8 THEN - DROP TEMPORARY TABLE IF EXISTS tmp.sale; - CREATE TEMPORARY TABLE tmp.sale - (PRIMARY KEY (saleFk)) - ENGINE = MEMORY - SELECT id AS saleFk, vWarehouseFk warehouseFk - FROM sale s WHERE s.ticketFk = vTicketFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent; - CREATE TEMPORARY TABLE tmp.ticketComponent - SELECT * FROM tmp.ticketComponentPreview; - - CALL ticketComponentUpdateSale (vOption); - - DROP TEMPORARY TABLE tmp.sale; - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent; - END IF; - COMMIT; - - DROP TEMPORARY TABLE tmp.zoneGetShipped, tmp.ticketComponentPreview; -END$$ - -DELIMITER ; \ No newline at end of file diff --git a/db/changes/10180-holyWeek/02-ticket_componentPreview.sql b/db/changes/10180-holyWeek/02-ticket_componentPreview.sql deleted file mode 100644 index d69435bb7..000000000 --- a/db/changes/10180-holyWeek/02-ticket_componentPreview.sql +++ /dev/null @@ -1,111 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `ticket_componentPreview`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `ticket_componentPreview`( - vTicketFk INT, - vLanded DATE, - vAddressFk INT, - vZoneFk INT, - vWarehouseFk SMALLINT) -BEGIN -/** - * Calcula los componentes de los articulos de un ticket - * - * @param vTicketFk id del ticket - * @param vLanded nueva fecha de entrega - * @param vAddressFk nuevo consignatario - * @param vZoneFk nueva zona - * @param vWarehouseFk nuevo warehouse - * - * @return tmp.ticketComponentPreview (warehouseFk, itemFk, componentFk, cost) - */ - DECLARE vHasDataChanged BOOL DEFAULT FALSE; - DECLARE vHasAddressChanged BOOL; - DECLARE vHasZoneChanged BOOL DEFAULT FALSE; - DECLARE vHasWarehouseChanged BOOL DEFAULT FALSE; - - DECLARE vShipped DATE; - DECLARE vAddressTypeRateFk INT DEFAULT NULL; - DECLARE vAgencyModeTypeRateFk INT DEFAULT NULL; - - DECLARE vHasChangeAll BOOL DEFAULT FALSE; - - SELECT DATE(landed) <> vLanded, - addressFk <> vAddressFk, - zoneFk <> vZoneFk, - warehouseFk <> vWarehouseFk - INTO - vHasDataChanged, - vHasAddressChanged, - vHasZoneChanged, - vHasWarehouseChanged - FROM vn.ticket t - WHERE t.id = vTicketFk; - - IF vHasDataChanged OR vHasWarehouseChanged THEN - SET vHasChangeAll = TRUE; - END IF; - - IF vHasAddressChanged THEN - SET vAddressTypeRateFk = 5; - END IF; - - IF vHasZoneChanged THEN - SET vAgencyModeTypeRateFk = 6; - END IF; - - SELECT TIMESTAMPADD(DAY, -travelingDays, vLanded) INTO vShipped - FROM zone - WHERE id = vZoneFk; - - CALL buyUltimate(vWarehouseFk, vShipped); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; - CREATE TEMPORARY TABLE tmp.ticketLot ENGINE = MEMORY ( - SELECT - vWarehouseFk AS warehouseFk, - NULL AS available, - s.itemFk, - bu.buyFk, - vZoneFk zoneFk - FROM sale s - LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk - WHERE s.ticketFk = vTicketFk - GROUP BY bu.warehouseFk, bu.itemFk); - - CALL catalog_componentPrepare(); - CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk); - - REPLACE INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT t.warehouseFk, s.itemFk, sc.componentFk, sc.value - FROM saleComponent sc - JOIN sale s ON s.id = sc.saleFk - JOIN ticket t ON t.id = s.ticketFk - JOIN `component` c ON c.id = sc.componentFk - WHERE s.ticketFk = vTicketFk - AND (c.isRenewable = FALSE - OR - (NOT vHasChangeAll - AND (NOT (c.typeFk <=> vAddressTypeRateFk - OR c.typeFk <=> vAgencyModeTypeRateFk)))); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentPreview; - CREATE TEMPORARY TABLE tmp.ticketComponentPreview - SELECT * FROM tmp.ticketComponent; - - CALL catalog_componentPurge(); - DROP TEMPORARY TABLE tmp.buyUltimate; - - IF vShipped IS NULL THEN - CALL util.throw('NO_ZONE_AVAILABLE'); - END IF; - - IF vShipped < CURDATE() THEN - CALL util.throw('ERROR_PAST_SHIPMENT'); - END IF; -END$$ - -DELIMITER ; - diff --git a/db/changes/10180-holyWeek/02-ticket_priceDifference.sql b/db/changes/10180-holyWeek/02-ticket_priceDifference.sql deleted file mode 100644 index b80ea7f88..000000000 --- a/db/changes/10180-holyWeek/02-ticket_priceDifference.sql +++ /dev/null @@ -1,50 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `ticket_priceDifference`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `ticket_priceDifference`( - vTicketFk INT, - vLanded DATE, - vAddressFk INT, - vZoneFk INT, - vWarehouseFk INT) -BEGIN -/** - * Devuelve las diferencias de precio de los movimientos de un ticket. - * - * @param vTicketFk Id del ticket - * @param vLanded Fecha de recepcion - * @param vAddressFk Id del consignatario - * @param vZoneFk Id de la zona - * @param vWarehouseFk Id del almacén - */ - CALL vn.ticket_componentPreview(vTicketFk, vLanded, vAddressFk, vZoneFk, vWarehouseFk); - - SELECT s.itemFk, - i.name, - i.size, - i.category, - IFNULL(s.quantity, 0) AS quantity, - IFNULL(s.price, 0) AS price, - ROUND(SUM(tc.cost), 2) AS newPrice, - s.quantity * (s.price - ROUND(SUM(tc.cost), 2)) difference, - s.id AS saleFk - FROM sale s - JOIN item i ON i.id = s.itemFk - JOIN ticket t ON t.id = s.ticketFk - LEFT JOIN tmp.ticketComponentPreview tc ON tc.itemFk = s.itemFk - AND tc.warehouseFk = t.warehouseFk - LEFT JOIN saleComponent sc ON sc.saleFk = s.id - AND sc.componentFk = tc.componentFk - LEFT JOIN `component` c ON c.id = tc.componentFk - WHERE t.id = vTicketFk - AND IF(sc.componentFk IS NULL - AND c.classRate IS NOT NULL, FALSE, TRUE) - GROUP BY s.id ORDER BY s.id; - - DROP TEMPORARY TABLE tmp.ticketComponentPreview; -END$$ - -DELIMITER ; - diff --git a/db/changes/10180-holyWeek/02-ticket_recalcComponents.sql b/db/changes/10180-holyWeek/02-ticket_recalcComponents.sql deleted file mode 100644 index 9ac4942f9..000000000 --- a/db/changes/10180-holyWeek/02-ticket_recalcComponents.sql +++ /dev/null @@ -1,94 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `ticket_recalcComponents`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `ticket_recalcComponents`(IN vTicketFk BIGINT, vIsTicketEditable BOOLEAN) -proc: BEGIN - -/** - * Este procedimiento recalcula los componentes de un ticket, - * eliminando los componentes existentes e insertandolos de nuevo - * - * @param vTicketFk Id del ticket - * @param vIsTicketEditable 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; - - IF vLanded IS NULL OR vZoneFk IS NULL THEN - - CALL zone_getLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk); - - IF (SELECT COUNT(*) FROM tmp.zoneGetLanded LIMIT 1) = 0 THEN - CALL util.throw('There is no zone for these parameters'); - END IF; - - 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; - DROP TEMPORARY TABLE tmp.zoneGetLanded; - - END IF; - - -- 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 - FROM sale s - 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 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; -END$$ - -DELIMITER ; - diff --git a/db/changes/10180-holyWeek/02-ticket_recalcComponentsForcePrice__.sql b/db/changes/10180-holyWeek/02-ticket_recalcComponentsForcePrice__.sql deleted file mode 100644 index 995bfbfcd..000000000 --- a/db/changes/10180-holyWeek/02-ticket_recalcComponentsForcePrice__.sql +++ /dev/null @@ -1,2 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `ticket_recalcComponentsForcePrice`; diff --git a/db/changes/10180-holyWeek/02-ticket_withoutComponents.sql b/db/changes/10180-holyWeek/02-ticket_withoutComponents.sql deleted file mode 100644 index de789b956..000000000 --- a/db/changes/10180-holyWeek/02-ticket_withoutComponents.sql +++ /dev/null @@ -1,72 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `ticket_withoutComponents`; -DROP procedure IF EXISTS `ticket_checkNoComponents`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `ticket_checkNoComponents`(vShippedFrom DATETIME, vShippedTo DATETIME) -BEGIN - -/** - * Comprueba que los tickets entre un rango de fechas tienen componentes - * - * @param vDatedFrom Id del ticket - * @param vIsTicketEditable si no se quiere forzar llamar con NULL - */ - 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 >= vDatedFrom AND t.shipped <= vDatedTo - 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 - 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 - 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 >= vDatedFrom - AND ic.merchandise != 0; - - OPEN vCur; - - l: LOOP - SET v_done = FALSE; - FETCH vCur INTO vSaleFk; - - IF v_done THEN - LEAVE l; - END IF; - - CALL sale_calculateComponent(vSaleFk, 1); - END LOOP; - - CLOSE vCur; - DROP TEMPORARY TABLE tmp.coste; - END$$ - -DELIMITER ; - diff --git a/db/changes/10180-holyWeek/03-ekt_load.sql b/db/changes/10180-holyWeek/03-ekt_load.sql deleted file mode 100644 index 6766cdfaf..000000000 --- a/db/changes/10180-holyWeek/03-ekt_load.sql +++ /dev/null @@ -1,162 +0,0 @@ - -USE `edi`; -DROP procedure IF EXISTS `ekt_load`; - -DELIMITER $$ -USE `edi`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `ekt_load`(IN `vSelf` INT) -BEGIN - DECLARE vRef INT; - DECLARE vBuy INT; - DECLARE vItem INT; - DECLARE vQty INT; - DECLARE vPackage INT; - DECLARE vIsLot BOOLEAN; - DECLARE vForceToPacking INT DEFAULT 2; - - -- Carga los datos necesarios del EKT - - SELECT ref, qty, package INTO vRef, vQty, vPackage - FROM ekt e - LEFT JOIN item i ON e.ref = i.id - WHERE e.id = vSelf; - - -- Inserta el cubo si no existe - - IF vPackage = 800 - THEN - SET vPackage = 800 + vQty; - - INSERT IGNORE INTO vn2008.Cubos SET - Id_Cubo = vPackage, - x = 7200 / vQty, - y = 1; - ELSE - INSERT IGNORE INTO vn2008.Cubos (Id_Cubo, X, Y, Z) - SELECT bucket_id, ROUND(x_size/10), ROUND(y_size/10), ROUND(z_size/10) - FROM bucket WHERE bucket_id = vPackage; - - IF ROW_COUNT() > 0 - THEN - INSERT INTO vn2008.mail SET - `subject` = 'Cubo añadido', - `text` = CONCAT('Se ha añadido el cubo: ', vPackage), - `to` = 'ekt@verdnatura.es'; - END IF; - END IF; - - -- Intenta obtener el artículo en base a los atributos holandeses - - INSERT IGNORE INTO item_track SET - item_id = vRef; - - SELECT c.Id_Compra, c.Id_Article INTO vBuy, vItem - FROM vn2008.buy_edi e - JOIN item_track t ON t.item_id = e.ref - LEFT JOIN vn2008.buy_edi l ON l.ref = e.ref - LEFT JOIN vn2008.Compres c ON c.buy_edi_id = l.id - JOIN vn2008.config cfg - WHERE e.id = vSelf - AND l.id != vSelf - AND c.Id_Article != cfg.generic_item - AND IF(t.s1, l.s1 = e.s1, TRUE) - AND IF(t.s2, l.s2 = e.s2, TRUE) - AND IF(t.s3, l.s3 = e.s3, TRUE) - AND IF(t.s4, l.s4 = e.s4, TRUE) - AND IF(t.s5, l.s5 = e.s5, TRUE) - AND IF(t.s6, l.s6 = e.s6, TRUE) - AND IF(t.kop, l.kop = e.kop, TRUE) - AND IF(t.pac, l.pac = e.pac, TRUE) - AND IF(t.cat, l.cat = e.cat, TRUE) - AND IF(t.ori, l.ori = e.ori, TRUE) - AND IF(t.pro, l.pro = e.pro, TRUE) - AND IF(t.sub, l.sub = e.sub, TRUE) - AND IF(t.package, l.package = e.package, TRUE) - AND c.Id_Article < 170000 - ORDER BY l.now DESC, c.Id_Compra ASC LIMIT 1; - - -- Determina si el articulo se vende por lotes - - IF vItem - THEN - SELECT COUNT(*) > 0 INTO vIsLot - FROM vn2008.Articles a - LEFT JOIN vn2008.Tipos t ON t.tipo_id = a.tipo_id - WHERE a.Id_Article = vItem - AND t.`transaction`; - - -- Si el articulo se vende por lotes se inserta un nuevo artículo - - IF vIsLot - THEN - INSERT INTO vn2008.Articles ( - Article - ,Medida - ,Categoria - ,Id_Origen - ,iva_group_id - ,Foto - ,Color - ,Codintrastat - ,tipo_id - ,Tallos - ) - SELECT - i.`name` - ,IFNULL(e.s1, e.pac) - ,e.cat - ,IFNULL(o.id, 17) - ,IFNULL(a.iva_group_id, 1) - ,a.Foto - ,a.Color - ,a.Codintrastat - ,IFNULL(a.tipo_id, 10) - ,IF(a.tipo_id = 15, 0, 1) - FROM vn2008.buy_edi e - LEFT JOIN item i ON i.id = e.ref - LEFT JOIN vn2008.Origen o ON o.Abreviatura = e.ori - LEFT JOIN vn2008.Articles a ON a.Id_Article = vItem - WHERE e.id = vSelf; - - SET vItem = LAST_INSERT_ID(); - END IF; - END IF; - - -- Inserta la compra asociada al EKT - - INSERT INTO vn2008.Compres - ( - Id_Entrada - ,buy_edi_id - ,Costefijo - ,Id_Article - ,`grouping` - ,caja - ,Packing - ,Cantidad - ,Productor - ,Etiquetas - ,Id_Cubo - ,`weight` - ) - SELECT - cfg.edi_entry - ,vSelf - ,(@t := IF(a.Tallos, a.Tallos, 1)) * e.pri - ,IFNULL(vItem, cfg.generic_item) - ,IFNULL(c.`grouping`, e.pac) - ,vForceToPacking - ,@pac := e.pac / @t - ,@pac * e.qty - ,s.company_name - ,e.qty - ,IFNULL(c.Id_Cubo, e.package) - ,a.density * (vn.item_getVolume(a.Id_Article, IFNULL(c.Id_Cubo, e.package)) / 1000000) - FROM vn2008.buy_edi e - LEFT JOIN vn2008.Compres c ON c.Id_Compra = vBuy - LEFT JOIN vn2008.Articles a ON a.Id_Article = c.Id_Article - LEFT JOIN supplier s ON e.pro = s.supplier_id - JOIN vn2008.config cfg - WHERE e.id = vSelf - LIMIT 1; -END \ No newline at end of file diff --git a/db/changes/10180-holyWeek/03-itemDiary.sql b/db/changes/10180-holyWeek/03-itemDiary.sql deleted file mode 100644 index d30597e14..000000000 --- a/db/changes/10180-holyWeek/03-itemDiary.sql +++ /dev/null @@ -1,130 +0,0 @@ -DROP procedure IF EXISTS `vn`.`item_getBalance`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `item_getBalance`(IN vItemId INT, IN vWarehouse INT) -BEGIN - DECLARE vDateInventory DATETIME; - DECLARE vCurdate DATE DEFAULT CURDATE(); - DECLARE vDayEnd DATETIME DEFAULT util.dayEnd(vCurdate); - - SELECT inventoried INTO vDateInventory FROM config; - SET @a = 0; - SET @currentLineFk = 0; - SET @shipped = ''; - - SELECT DATE(@shipped:= shipped) shipped, - alertLevel, - stateName, - origin, - reference, - clientFk, - name, - `in`, - `out`, - @a := @a + IFNULL(`in`,0) - IFNULL(`out`,0) as balance, - @currentLineFk := IF (@shipped < CURDATE() - OR (@shipped = CURDATE() AND (isPicked OR alertLevel >= 2)), - lineFk,@currentLineFk) lastPreparedLineFk, - isTicket, - lineFk,isPicked - FROM - ( SELECT tr.landed as shipped, - b.quantity as `in`, - NULL as `out`, - al.alertLevel as alertLevel, - st.name AS stateName, - s.name as name, - e.ref as reference, - e.id as origin, - s.id as clientFk, - IF(al.alertLevel = 3, TRUE, FALSE) isPicked, - FALSE AS isTicket, - b.id lineFk, - NULL `order` - 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.alertLevel = - CASE - WHEN tr.shipped < CURDATE() THEN 3 - WHEN tr.shipped = 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.isInventory = FALSE - AND e.isRaid = FALSE - UNION ALL - - SELECT tr.shipped, - NULL as `in`, - b.quantity as `out`, - al.alertLevel as alertLevel, - st.name AS stateName, - s.name as name, - e.ref as reference, - e.id as origin, - s.id as clientFk, - IF(al.alertLevel = 3, TRUE, FALSE) isPicked, - FALSE AS isTicket, - b.id, - NULL `order` - 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.alertLevel = - CASE - WHEN tr.shipped < CURDATE() THEN 3 - WHEN tr.shipped = 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.isInventory = FALSE - AND w.isFeedStock = FALSE - AND e.isRaid = FALSE - UNION ALL - - SELECT DATE(t.shipped), - NULL as `in`, - s.quantity as `out`, - al.alertLevel as alertLevel, - st.name AS stateName, - t.nickname as name, - t.refFk as reference, - t.id as origin, - t.clientFk, - stk.id as isPicked, - TRUE as isTicket, - s.id, - st.`order` - 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 alertLevel al ON al.alertLevel = - CASE - WHEN t.shipped < curdate() THEN 3 - WHEN t.shipped > util.dayEnd(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 - 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; - -END$$ -delimiter ; \ No newline at end of file diff --git a/db/changes/10180-holyWeek/03-ticketCalculateSaleForcePrice2__.sql b/db/changes/10180-holyWeek/03-ticketCalculateSaleForcePrice2__.sql deleted file mode 100644 index a880135ba..000000000 --- a/db/changes/10180-holyWeek/03-ticketCalculateSaleForcePrice2__.sql +++ /dev/null @@ -1,2 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `ticketCalculateSaleForcePrice2`; \ No newline at end of file diff --git a/db/changes/10180-holyWeek/03-ticketCalculateSaleForcePrice__.sql b/db/changes/10180-holyWeek/03-ticketCalculateSaleForcePrice__.sql deleted file mode 100644 index d7eb5d32b..000000000 --- a/db/changes/10180-holyWeek/03-ticketCalculateSaleForcePrice__.sql +++ /dev/null @@ -1,2 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `ticketCalculateSaleForcePrice`; \ No newline at end of file diff --git a/db/changes/10180-holyWeek/03-ticketCalculateSale__.sql b/db/changes/10180-holyWeek/03-ticketCalculateSale__.sql deleted file mode 100644 index acefc29d5..000000000 --- a/db/changes/10180-holyWeek/03-ticketCalculateSale__.sql +++ /dev/null @@ -1,68 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `ticketCalculateSale`; -DROP procedure IF EXISTS `ticketCalculateSale__`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `ticketCalculateSale__`(IN vSale BIGINT) -proc: BEGIN --- OBSOLETO USAR: sale_calculateComponent(vSale, NULL) - DECLARE vShipped DATE; - DECLARE vWarehouseFk SMALLINT; - DECLARE vAgencyModeFk INT; - DECLARE vAddressFk INT; - DECLARE vTicket BIGINT; - DECLARE vItem BIGINT; - DECLARE vLanded DATE; - DECLARE vTicketFree BOOLEAN DEFAULT TRUE; - DECLARE vZoneFk INTEGER; - - SELECT NOT (t.refFk IS NOT NULL OR ts.alertLevel > 0) OR s.price = 0, s.ticketFk, s.itemFk , t.zoneFk - INTO vTicketFree, vTicket, vItem, vZoneFk - FROM vn.ticket t - JOIN vn.sale s ON s.ticketFk = t.id - LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id - WHERE s.id = vSale - LIMIT 1; - - SELECT t.warehouseFk, DATE(t.shipped), t.addressFk, t.agencyModeFk, t.landed - INTO vWarehouseFk, vShipped, vAddressFk, vAgencyModeFk, vLanded - FROM agencyMode a - JOIN ticket t ON t.agencyModeFk = a.id - WHERE t.id = vTicket; - - IF IFNULL(vZoneFk,0) = 0 THEN - CALL util.throw('ticket dont have zone'); - END IF; - - CALL buyUltimate (vWarehouseFk, vShipped); - - DELETE FROM tmp.buyUltimate WHERE itemFk != vItem; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; - CREATE TEMPORARY TABLE tmp.ticketLot - SELECT vWarehouseFk warehouseFk, NULL available, vItem itemFk, buyFk, vZoneFk zoneFk - FROM tmp.buyUltimate - WHERE itemFk = vItem; - - CALL vn.catalog_componentCalculate; - 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; - - CALL ticketComponentUpdateSale(IF(vTicketFree,1,6)); - - INSERT INTO vn.ticketLog (originFk, userFk, `action`, description) - VALUES (vTicket, account.userGetId(), 'update', CONCAT('Bionizo linea id ', vSale)); - - CALL catalog_componentPurge(); - DROP TEMPORARY TABLE tmp.buyUltimate; - DROP TEMPORARY TABLE IF EXISTS tmp.sale; - -END$$ - -DELIMITER ; - diff --git a/db/changes/10180-holyWeek/03-ticket_componentUpdate__.sql b/db/changes/10180-holyWeek/03-ticket_componentUpdate__.sql deleted file mode 100644 index f75f157e8..000000000 --- a/db/changes/10180-holyWeek/03-ticket_componentUpdate__.sql +++ /dev/null @@ -1,83 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `vn`.`ticket_componentUpdate`; -DROP procedure IF EXISTS `vn`.`ticket_componentUpdate__`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `ticket_componentUpdate__`( - vTicketFk INT, - vClientFk INT, - vAgencyModeFk INT, - vAddressFk INT, - vZoneFk INT, - vWarehouseFk TINYINT, - vCompanyFk SMALLINT, - vShipped DATETIME, - vLanded DATE, - vIsDeleted BOOLEAN, - vHasToBeUnrouted BOOLEAN, - vOption INT) -BEGIN - DECLARE vPrice DECIMAL(10,2); - DECLARE vBonus DECIMAL(10,2); - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - - START TRANSACTION; - - IF (SELECT addressFk FROM ticket WHERE id = vTicketFk) <> vAddressFk THEN - - UPDATE ticket t - JOIN address a ON a.id = vAddressFk - SET t.nickname = a.nickname - WHERE t.id = vTicketFk; - - END IF; - - CALL vn.zone_getShippedWarehouse(vlanded, vAddressFk, vAgencyModeFk); - - SELECT zoneFk, price, bonus INTO vZoneFk, vPrice, vBonus - FROM tmp.zoneGetShipped - WHERE shipped = vShipped AND warehouseFk = vWarehouseFk LIMIT 1; - - UPDATE ticket t - SET - t.clientFk = vClientFk, - t.agencyModeFk = vAgencyModeFk, - t.addressFk = vAddressFk, - t.zoneFk = vZoneFk, - t.zonePrice = vPrice, - t.zoneBonus = vBonus, - t.warehouseFk = vWarehouseFk, - t.companyFk = vCompanyFk, - t.landed = vLanded, - t.shipped = vShipped, - t.isDeleted = vIsDeleted - WHERE - t.id = vTicketFk; - - IF vHasToBeUnrouted THEN - UPDATE ticket t SET t.routeFk = NULL - WHERE t.id = vTicketFk; - END IF; - - IF vOption <> 8 THEN - DROP TEMPORARY TABLE IF EXISTS tmp.sale; - CREATE TEMPORARY TABLE tmp.sale - (PRIMARY KEY (saleFk)) - ENGINE = MEMORY - SELECT id AS saleFk, vWarehouseFk warehouseFk - FROM sale s WHERE s.ticketFk = vTicketFk; - - CALL ticketComponentUpdateSale (vOption); - - DROP TEMPORARY TABLE tmp.sale; - END IF; - COMMIT; -END$$ - -DELIMITER ; -; diff --git a/db/changes/10180-holyWeek/03-zone_UpcomingDeliveries.sql b/db/changes/10180-holyWeek/03-zone_UpcomingDeliveries.sql deleted file mode 100644 index c8f85527e..000000000 --- a/db/changes/10180-holyWeek/03-zone_UpcomingDeliveries.sql +++ /dev/null @@ -1,80 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `zone_upcomingDeliveries`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_upcomingDeliveries`() -BEGIN - DECLARE vForwardDays INT; - - SELECT forwardDays INTO vForwardDays FROM zoneConfig; - CALL util.time_createTable(CURDATE(), DATE_ADD(CURDATE(), INTERVAL vForwardDays DAY)); - - DROP TEMPORARY TABLE IF EXISTS tLandings; - CREATE TEMPORARY TABLE tLandings - (INDEX (eventFk)) - ENGINE = MEMORY - SELECT e.id eventFk, - @travelingDays := IFNULL(e.travelingDays, z.travelingDays) travelingDays, - TIMESTAMPADD(DAY, @travelingDays, ti.dated) landed, - ti.dated shipped - FROM zone z - JOIN zoneEvent e ON e.zoneFk = z.id - JOIN tmp.time ti ON ti.dated BETWEEN curdate() AND TIMESTAMPADD(DAY, vForwardDays, curdate()); - - DROP TEMPORARY TABLE IF EXISTS tmp.zoneOption; - CREATE TEMPORARY TABLE tmp.zoneOption - ENGINE = MEMORY - SELECT * - FROM ( - SELECT z.id zoneFk, - TIME(IFNULL(e.`hour`, z.`hour`)) `hour`, - l.travelingDays, - IFNULL(e.price, z.price) price, - IFNULL(e.bonus, z.bonus) bonus, - l.landed, - l.shipped - FROM zone z - JOIN zoneEvent e ON e.zoneFk = z.id - JOIN tLandings l ON l.eventFk = e.id - WHERE ( - e.`type` = 'day' - AND e.`dated` = l.landed - ) OR ( - e.`type` != 'day' - AND e.weekDays & (1 << WEEKDAY(l.landed)) - AND (e.`started` IS NULL OR l.landed >= e.`started`) - AND (e.`ended` IS NULL OR l.landed <= e.`ended`) - ) - ORDER BY - zoneFk, - CASE - WHEN e.`type` = 'day' - THEN 1 - WHEN e.`type` = 'range' - THEN 2 - ELSE 3 - END - ) t - GROUP BY zoneFk, landed; - - DELETE t FROM tmp.zoneOption t - JOIN zoneExclusion e - ON e.zoneFk = t.zoneFk AND e.`dated` = t.landed; - - SELECT MAX(zo.`hour`) `hour`, zg.`name`, zo.shipped - FROM tmp.zoneOption zo - JOIN `zone` z ON z.id = zo.zoneFk - JOIN agencyMode am ON am.id = z.agencyModeFk - JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk - JOIN zoneIncluded zi ON zi.zoneFk = z.id - JOIN zoneGeo zg ON zg.id = zi.geoFk AND zg.type = 'province' - WHERE dm.code = 'DELIVERY' - GROUP BY shipped, zg.`name` - ORDER BY shipped, zg.`name`; - - DROP TEMPORARY TABLE tmp.time, tLandings; -END$$ - -DELIMITER ; - diff --git a/db/changes/10190-PostErte/00-ACL.sql b/db/changes/10190-PostErte/00-ACL.sql deleted file mode 100644 index 8ef44224a..000000000 --- a/db/changes/10190-PostErte/00-ACL.sql +++ /dev/null @@ -1,5 +0,0 @@ -UPDATE `salix`.`ACL` SET `accessType`='WRITE' WHERE `id`='213'; -UPDATE `salix`.`ACL` SET `property` = 'deleteSales' WHERE (`id` = '80'); - -INSERT IGNORE INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('CustomsAgent', '*', '*', 'ALLOW', 'ROLE', 'employee'); - diff --git a/db/changes/10190-PostErte/00-itemLastEntry.sql b/db/changes/10190-PostErte/00-itemLastEntry.sql deleted file mode 100644 index b293c234e..000000000 --- a/db/changes/10190-PostErte/00-itemLastEntry.sql +++ /dev/null @@ -1,42 +0,0 @@ - -DROP procedure IF EXISTS `vn`.`itemLastEntries`; - -DELIMITER $$ -CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`itemLastEntries`(IN `vItem` INT, IN `vDays` DATE) -BEGIN - SELECT - w.id AS warehouseFk, - w.name AS warehouse, - tr.landed, - b.entryFk, - b.isIgnored, - b.price2, - b.price3, - b.stickers, - b.packing, - b.`grouping`, - b.groupingMode, - b.weight, - i.stems, - b.quantity, - b.buyingValue, - b.packageFk , - s.id AS supplierFk, - s.name AS supplier - FROM itemType it - RIGHT JOIN (entry e - LEFT JOIN supplier s ON s.id = e.supplierFk - RIGHT JOIN buy b ON b.entryFk = e.id - LEFT JOIN item i ON i.id = b.itemFk - LEFT JOIN ink ON ink.id = i.inkFk - LEFT JOIN travel tr ON tr.id = e.travelFk - LEFT JOIN warehouse w ON w.id = tr.warehouseInFk - LEFT JOIN origin o ON o.id = i.originFk - ) ON it.id = i.typeFk - LEFT JOIN edi.ekt ek ON b.ektFk = ek.id - WHERE b.itemFk = vItem And tr.shipped BETWEEN vDays AND DATE_ADD(CURDATE(), INTERVAl + 10 DAY) - ORDER BY tr.landed DESC , b.id DESC; -END$$ - -DELIMITER ; - diff --git a/db/changes/10190-PostErte/00-route.sql b/db/changes/10190-PostErte/00-route.sql deleted file mode 100644 index 5ffab3a46..000000000 --- a/db/changes/10190-PostErte/00-route.sql +++ /dev/null @@ -1,8 +0,0 @@ -ALTER TABLE `vn`.`route` -DROP FOREIGN KEY `fk_route_1`; -ALTER TABLE `vn`.`route` -ADD CONSTRAINT `fk_route_1` - FOREIGN KEY (`zoneFk`) - REFERENCES `vn`.`zone` (`id`) - ON DELETE SET NULL - ON UPDATE CASCADE; diff --git a/db/changes/10190-PostErte/00-saleCalculateComponent.sql b/db/changes/10190-PostErte/00-saleCalculateComponent.sql deleted file mode 100644 index 8ab498f57..000000000 --- a/db/changes/10190-PostErte/00-saleCalculateComponent.sql +++ /dev/null @@ -1,99 +0,0 @@ - -DROP procedure IF EXISTS `vn`.`sale_calculateComponent`; - -DELIMITER $$ -CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`sale_calculateComponent`(vSale INT, vOption INT) -proc: BEGIN -/** - * Actualiza los componentes - * - * @param vSale Delivery date - * @param vOption indica en que componente pone el descuadre, NULL en casos habituales - */ - DECLARE vShipped DATE; - DECLARE vWarehouseFk SMALLINT; - DECLARE vAgencyModeFk INT; - DECLARE vAddressFk INT; - DECLARE vTicketFk BIGINT; - DECLARE vItemFk BIGINT; - DECLARE vLanded DATE; - DECLARE vIsEditable BOOLEAN; - DECLARE vZoneFk INTEGER; - - SELECT t.refFk IS NULL AND (IFNULL(ts.alertLevel, 0) = 0 OR s.price = 0), - s.ticketFk, - s.itemFk , - t.zoneFk, - t.warehouseFk, - t.shipped, - t.addressFk, - t.agencyModeFk, - t.landed - INTO vIsEditable, - vTicketFk, - vItemFk, - vZoneFk, - vWarehouseFk, - vShipped, - vAddressFk, - 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; - - IF vLanded IS NULL OR vZoneFk IS NULL THEN - - 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; - - 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; - DROP TEMPORARY TABLE tmp.zoneGetLanded; - - END IF; - - -- rellena la tabla buyUltimate con la ultima compra - CALL buyUltimate (vWarehouseFk, vShipped); - - DELETE FROM tmp.buyUltimate WHERE itemFk != vItemFk; - - 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; - - 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; - - CALL ticketComponentUpdateSale(vOption); - CALL catalog_componentPurge(); - - DROP TEMPORARY TABLE tmp.buyUltimate; - DROP TEMPORARY TABLE tmp.sale; -END$$ - -DELIMITER ; - diff --git a/db/changes/10190-PostErte/01-ticketCalculateClon.sql b/db/changes/10190-PostErte/01-ticketCalculateClon.sql deleted file mode 100644 index 6e2906f6a..000000000 --- a/db/changes/10190-PostErte/01-ticketCalculateClon.sql +++ /dev/null @@ -1,93 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `ticketCalculateClon`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `ticketCalculateClon`(IN vTicketNew INT, vTicketOld INT) -BEGIN -/* - * Recalcula los componentes un ticket clonado, - * las lineas a precio cero fuerza para que tengan precio, el resto lo respeta - * @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.zone = 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, vAgencyMode, 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; - - CALL ticketComponentUpdateSale(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; - - CALL ticketComponentUpdateSale(6); - - -- Log - CALL `logAdd`(vTicketNew, 'update', ' ticket' , 'Bioniza Ticket'); - - -- Limpieza - CALL catalog_componentPurge(); - DROP TEMPORARY TABLE IF EXISTS - tmp.buyUltimate, - tmp.sale, - tmp.zoneGetLanded; - -END$$ - -DELIMITER ; - diff --git a/db/changes/10190-PostErte/01-ticket_cloneWeekly.sql b/db/changes/10190-PostErte/01-ticket_cloneWeekly.sql deleted file mode 100644 index 137386ac9..000000000 --- a/db/changes/10190-PostErte/01-ticket_cloneWeekly.sql +++ /dev/null @@ -1,132 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `ticket_cloneWeekly`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `ticket_cloneWeekly`(IN vWeek INT) -BEGIN - DECLARE vIsDone BOOL; - DECLARE vLanding DATE; - DECLARE vShipment DATE; - DECLARE vWarehouse INT; - DECLARE vTicket INT; - DECLARE vWeekDay INT; - DECLARE vClient INT; - DECLARE vEmpresa INT; - DECLARE vAddressFk INT; - DECLARE vAgencyModeFk INT; - DECLARE vNewTicket INT; - DECLARE vYear INT; - - DECLARE rsTicket CURSOR FOR - SELECT tw.ticketFk, weekDay, t.clientFk, t.warehouseFk, t.companyFk, t.addressFk, tw.agencyModeFk - FROM ticketWeekly tw - JOIN ticket t ON tt.ticketFk = t.id; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE; - - SET vYear = YEAR(CURDATE()) + IF(vWeek < WEEK(CURDATE()),1, 0); - - OPEN rsTicket; - - myLoop: LOOP - BEGIN - DECLARE vError TEXT; - DECLARE vSalesPersonEmail VARCHAR(150); - DECLARE vMailSent BOOL; - DECLARE vSubject VARCHAR(150); - DECLARE vMessage TEXT; - DECLARE CONTINUE HANDLER FOR SQLEXCEPTION - BEGIN - GET DIAGNOSTICS CONDITION 1 - vError = MESSAGE_TEXT; - END; - - SET vIsDone = FALSE; - FETCH rsTicket INTO vTicket, vWeekDay, vClient, vWarehouse, vEmpresa, vAddressFk, vAgencyModeFk; - - IF vIsDone THEN - - LEAVE myLoop; - END IF; - SELECT date INTO vShipment - FROM `time` - WHERE `year` = vYear AND `week` = vWeek - AND WEEKDAY(date) = vWeekDay; - - -- 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 - WHERE tOrig.id = vTicket AND DATE(tClon.shipped) = vShipment) > 0 - THEN - ITERATE myLoop; - END IF; - CALL vn.zone_getLanded(vShipment, vAddressFk, vAgencyModeFk, vWarehouse, TRUE); - - SELECT landed INTO vLanding from tmp.zoneGetLanded LIMIT 1; - - CALL vn.ticketCreateWithoutZone(vClient, vShipment, vWarehouse, vEmpresa, vAddressFk, vAgencyModeFk, NULL, vLanding, account.userGetId(), vNewTicket); - - IF (vLanding IS NULL) THEN - - SELECT e.email INTO vSalesPersonEmail - FROM vn.client c - JOIN vn.worker sp ON sp.id = c.salesPersonFk - JOIN account.emailUser e ON e.userFk = sp.userFk - WHERE c.id = vClient; - - SET vSubject = CONCAT('Turnos - No se ha podido clonar correctamente el ticket ', vTicket, - ' para el dia: ', vShipment); - SET vMessage = CONCAT('No se ha podido clonar el ticket ', vTicket, - ' para el dia: ', vShipment, - ' porque no hay una zona de envío disponible. Se ha creado el ticket: ', vNewTicket, - ' pero ha que revisar las fechas y la agencia'); - - SELECT COUNT(*) INTO vMailSent - FROM vn.mail - WHERE sender = vSalesPersonEmail - AND subject = vSubject; - - IF NOT vMailSent THEN - INSERT INTO vn.mail (sender,`subject`,body) - VALUES (vSalesPersonEmail, vSubject, vMessage); - END IF; - CALL vn.ticketStateUpdate (vNewTicket, 'FIXING'); - END IF; - - INSERT INTO vn.sale (ticketFk, itemFk, concept, quantity, price, discount, priceFixed, isPriceFixed) - SELECT vNewTicket, saleOrig.itemFk , saleOrig.concept , saleOrig.quantity, saleOrig.price , saleOrig.discount, saleOrig.priceFixed, saleOrig.isPriceFixed - FROM vn.ticket tOrig - JOIN vn.sale saleOrig ON tOrig.id = saleOrig.ticketFk - LEFT JOIN vn.saleCloned sc ON sc.saleOriginalFk = saleOrig.id - LEFT JOIN vn.sale saleClon ON saleClon.id = sc.saleClonedFk - LEFT JOIN vn.ticket tClon ON tClon.id = saleClon.ticketFk AND DATE(tClon.shipped) = vShipment - WHERE tOrig.id = vTicket AND saleClon.id IS NULL; - - INSERT IGNORE INTO vn.saleCloned(saleOriginalFk, saleClonedFk) - SELECT saleOriginal.id, saleClon.id - FROM vn.sale saleOriginal - JOIN vn.sale saleClon ON saleOriginal.itemFk = saleClon.itemFk AND saleOriginal.quantity = saleClon.quantity - WHERE saleOriginal.ticketFk = vTicket AND saleClon.ticketFk = vNewTicket; - - INSERT INTO ticketRequest (description, ordered, shipped, salesPersonCode, buyerCode, quantity, price, - itemFk ,clientFk, response, total, buyed, saleFk) - SELECT tr.description, tr.ordered, tr.shipped, tr.salesPersonCode, tr.buyerCode, tr.quantity, tr.price, - tr.itemFk, tr.clientFk, tr.response, tr.total, tr.buyed, tr.saleFk - FROM sale s JOIN ticketRequest tr ON tr.saleFk = s.id - JOIN sale s2 ON s.concept = s2.concept AND s.quantity = s2.quantity AND m.Id_Article = m2.Id_Article - WHERE s.ticketFk = vTicket AND s2.ticketFk = vNewTicket; - - CALL vn.ticketCalculateClon(vNewTicket, vTicket); - END; - END LOOP; - - CLOSE rsTicket; - -END$$ - -DELIMITER ; - diff --git a/db/changes/10190-PostErte/01-ticket_recalcComponents.sql b/db/changes/10190-PostErte/01-ticket_recalcComponents.sql deleted file mode 100644 index 8a8f71ea4..000000000 --- a/db/changes/10190-PostErte/01-ticket_recalcComponents.sql +++ /dev/null @@ -1,93 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `ticket_recalcComponents`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `ticket_recalcComponents`(IN vTicketFk BIGINT, vIsTicketEditable BOOLEAN) -proc: BEGIN - -/** - * Este procedimiento recalcula los componentes de un ticket, - * eliminando los componentes existentes e insertandolos de nuevo - * - * @param vTicketFk Id del ticket - * @param vIsTicketEditable 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; - - IF vLanded IS NULL OR vZoneFk IS NULL THEN - - 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; - - 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; - DROP TEMPORARY TABLE tmp.zoneGetLanded; - - END IF; - - -- 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 - FROM sale s - 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 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; -END$$ - -DELIMITER ; \ No newline at end of file diff --git a/db/changes/10190-PostErte/01-zone_getLanded.sql b/db/changes/10190-PostErte/01-zone_getLanded.sql deleted file mode 100644 index 4ddac0112..000000000 --- a/db/changes/10190-PostErte/01-zone_getLanded.sql +++ /dev/null @@ -1,40 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `zone_getLanded`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `zone_getLanded`(vShipped DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT, vShowExpiredZones BOOLEAN) -BEGIN -/** -* Devuelve una tabla temporal con el dia de recepcion para vShipped. -* -* @param vShipped Fecha de preparacion de mercancia -* @param vAddressFk Id de consignatario, %NULL para recogida -* @param vAgencyModeFk Id agencia -* @param vWarehouseFk vWarehouseFk -* @table tmp.zoneGetLanded Datos de recepción -*/ - - CALL zone_getFromGeo(address_getGeo(vAddressFk)); - CALL zone_getOptionsForShipment(vShipped, vShowExpiredZones); - - DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetLanded; - CREATE TEMPORARY TABLE tmp.zoneGetLanded - ENGINE = MEMORY - SELECT vWarehouseFk warehouseFk, - TIMESTAMPADD(DAY,zo.travelingDays, vShipped) landed, - zo.zoneFk - FROM tmp.zoneOption zo - JOIN zone z ON z.id = zo.zoneFk - JOIN zoneWarehouse zw ON zw.zoneFk = z.id - WHERE agencyModeFk = vAgencyModeFk - AND zw.warehouseFk = vWarehouseFk; - - DROP TEMPORARY TABLE - tmp.zone, - tmp.zoneOption; - -END$$ - -DELIMITER ; - diff --git a/db/changes/10200-normality/00-ACL.sql b/db/changes/10200-normality/00-ACL.sql new file mode 100644 index 000000000..ad9bc79d6 --- /dev/null +++ b/db/changes/10200-normality/00-ACL.sql @@ -0,0 +1,2 @@ +UPDATE `salix`.`ACL` SET `model` = 'Calendar' WHERE (`id` = '155'); +UPDATE `salix`.`ACL` SET `model` = 'Calendar' WHERE (`id` = '157'); diff --git a/db/changes/10200-normality/00-zoneEstimatedDelivery.sql b/db/changes/10200-normality/00-zoneEstimatedDelivery.sql new file mode 100644 index 000000000..8cf30796e --- /dev/null +++ b/db/changes/10200-normality/00-zoneEstimatedDelivery.sql @@ -0,0 +1,47 @@ +USE `vn`; +CREATE + OR REPLACE ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +VIEW `vn`.`zoneEstimatedDelivery` AS + SELECT + `t`.`zoneFk` AS `zoneFk`, + CAST((CURDATE() + INTERVAL ((HOUR(`zc`.`hour`) * 60) + MINUTE(`zc`.`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 + ((((((((`ticket` `t` + JOIN `ticketStateToday` `tst` ON ((`tst`.`ticket` = `t`.`id`))) + JOIN `state` `s` ON ((`s`.`id` = `tst`.`state`))) + JOIN `saleVolume` `sv` ON ((`sv`.`ticketFk` = `t`.`id`))) + LEFT JOIN `lastHourProduction` `lhp` ON ((`lhp`.`warehouseFk` = `t`.`warehouseFk`))) + JOIN `warehouse` `w` ON ((`w`.`id` = `t`.`warehouseFk`))) + JOIN `warehouseAlias` `wa` ON ((`wa`.`id` = `w`.`aliasFk`))) + LEFT JOIN `zoneClosure` `zc` ON (((`zc`.`zoneFk` = `t`.`zoneFk`) + AND (`zc`.`dated` = CURDATE())))) + LEFT JOIN `cache`.`departure_limit` `dl` ON (((`dl`.`warehouse_id` = `t`.`warehouseFk`) + AND (`dl`.`fecha` = CURDATE())))) + WHERE + ((`wa`.`name` = 'Silla') + AND (CAST(`t`.`shipped` AS DATE) = CURDATE())) + GROUP BY `t`.`zoneFk`; \ No newline at end of file diff --git a/db/changes/10200-normality/01-zoneETD.sql b/db/changes/10200-normality/01-zoneETD.sql new file mode 100644 index 000000000..e4cf48548 --- /dev/null +++ b/db/changes/10200-normality/01-zoneETD.sql @@ -0,0 +1,16 @@ +CREATE + OR REPLACE ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +VIEW `vn`.`zone_ETD` AS + SELECT + `zed`.`zoneFk` AS `zoneFk`, + `zed`.`hourTheoretical` AS `HoraTeórica`, + `zed`.`totalVolume` AS `volumenTotal`, + `zed`.`remainingVolume` AS `volumenPendiente`, + `zed`.`speed` AS `velocidad`, + `zed`.`hourEffective` AS `HoraPráctica`, + `zed`.`minutesLess` AS `minutesLess`, + `zed`.`etc` AS `etc` + FROM + `vn`.`zoneEstimatedDelivery` `zed` \ No newline at end of file diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql index 94c62e984..ae20b019c 100644 --- a/db/dump/dumpedFixtures.sql +++ b/db/dump/dumpedFixtures.sql @@ -36,7 +36,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-23 8:07:57 +-- Dump completed on 2020-08-11 11:50:54 USE `account`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -71,7 +71,7 @@ UNLOCK TABLES; LOCK TABLES `roleInherit` WRITE; /*!40000 ALTER TABLE `roleInherit` DISABLE KEYS */; -INSERT INTO `roleInherit` VALUES (9,0),(66,0),(5,1),(13,1),(18,1),(31,1),(32,1),(34,1),(35,1),(37,1),(40,1),(42,1),(44,1),(47,1),(51,1),(53,1),(54,1),(56,1),(58,1),(1,2),(1,3),(30,5),(39,5),(60,5),(67,5),(11,6),(2,11),(3,11),(70,11),(16,13),(20,13),(21,13),(22,13),(34,13),(41,13),(43,13),(45,13),(48,13),(50,13),(52,13),(55,13),(57,13),(59,13),(61,13),(16,15),(20,16),(21,18),(52,19),(65,19),(17,20),(30,20),(5,21),(19,21),(22,21),(39,21),(50,21),(30,22),(5,33),(34,33),(15,35),(41,35),(50,35),(52,35),(65,35),(69,35),(49,36),(61,36),(17,37),(38,37),(60,37),(67,37),(17,39),(41,40),(43,42),(36,44),(45,44),(36,47),(48,47),(69,47),(50,49),(60,50),(65,50),(52,51),(21,53),(30,53),(55,54),(57,56),(15,57),(39,57),(50,57),(60,57),(49,58),(59,58),(50,59),(17,64),(30,64),(38,64),(20,65),(1,70); +INSERT INTO `roleInherit` VALUES (9,0),(66,0),(5,1),(13,1),(18,1),(31,1),(32,1),(34,1),(35,1),(37,1),(40,1),(44,1),(47,1),(51,1),(53,1),(54,1),(56,1),(58,1),(1,2),(1,3),(30,5),(39,5),(60,5),(67,5),(11,6),(2,11),(3,11),(70,11),(16,13),(20,13),(21,13),(22,13),(34,13),(41,13),(43,13),(45,13),(48,13),(50,13),(52,13),(55,13),(57,13),(59,13),(61,13),(16,15),(20,16),(21,18),(52,19),(65,19),(17,20),(30,20),(5,21),(19,21),(22,21),(39,21),(50,21),(30,22),(5,33),(34,33),(15,35),(41,35),(42,35),(50,35),(52,35),(65,35),(69,35),(49,36),(61,36),(17,37),(38,37),(60,37),(67,37),(17,39),(41,40),(43,42),(36,44),(45,44),(36,47),(48,47),(69,47),(40,49),(42,49),(50,49),(59,49),(60,50),(65,50),(52,51),(21,53),(30,53),(55,54),(57,56),(15,57),(39,57),(50,57),(60,57),(49,58),(50,59),(17,64),(30,64),(38,64),(20,65),(1,70); /*!40000 ALTER TABLE `roleInherit` ENABLE KEYS */; UNLOCK TABLES; @@ -81,7 +81,7 @@ UNLOCK TABLES; LOCK TABLES `roleRole` WRITE; /*!40000 ALTER TABLE `roleRole` DISABLE KEYS */; -INSERT INTO `roleRole` VALUES (0,0),(0,1),(0,2),(0,3),(0,5),(0,6),(0,9),(0,11),(0,13),(0,15),(0,16),(0,17),(0,18),(0,19),(0,20),(0,21),(0,22),(0,30),(0,31),(0,32),(0,33),(0,34),(0,35),(0,36),(0,37),(0,38),(0,39),(0,40),(0,41),(0,42),(0,43),(0,44),(0,45),(0,47),(0,48),(0,49),(0,50),(0,51),(0,52),(0,53),(0,54),(0,55),(0,56),(0,57),(0,58),(0,59),(0,60),(0,61),(0,62),(0,64),(0,65),(0,66),(0,67),(0,69),(0,70),(1,1),(1,2),(1,3),(1,6),(1,11),(1,70),(2,2),(2,6),(2,11),(3,3),(3,6),(3,11),(5,1),(5,2),(5,3),(5,5),(5,6),(5,11),(5,13),(5,18),(5,21),(5,33),(5,53),(5,70),(6,6),(9,0),(9,1),(9,2),(9,3),(9,5),(9,6),(9,9),(9,11),(9,13),(9,15),(9,16),(9,17),(9,18),(9,19),(9,20),(9,21),(9,22),(9,30),(9,31),(9,32),(9,33),(9,34),(9,35),(9,36),(9,37),(9,38),(9,39),(9,40),(9,41),(9,42),(9,43),(9,44),(9,45),(9,47),(9,48),(9,49),(9,50),(9,51),(9,52),(9,53),(9,54),(9,55),(9,56),(9,57),(9,58),(9,59),(9,60),(9,61),(9,62),(9,64),(9,65),(9,66),(9,67),(9,69),(9,70),(11,6),(11,11),(13,1),(13,2),(13,3),(13,6),(13,11),(13,13),(13,70),(15,1),(15,2),(15,3),(15,6),(15,11),(15,13),(15,15),(15,35),(15,56),(15,57),(15,70),(16,1),(16,2),(16,3),(16,6),(16,11),(16,13),(16,15),(16,16),(16,35),(16,56),(16,57),(16,70),(17,1),(17,2),(17,3),(17,5),(17,6),(17,11),(17,13),(17,15),(17,16),(17,17),(17,18),(17,19),(17,20),(17,21),(17,33),(17,35),(17,36),(17,37),(17,39),(17,44),(17,47),(17,49),(17,50),(17,53),(17,56),(17,57),(17,58),(17,59),(17,64),(17,65),(17,70),(18,1),(18,2),(18,3),(18,6),(18,11),(18,18),(18,70),(19,1),(19,2),(19,3),(19,6),(19,11),(19,13),(19,18),(19,19),(19,21),(19,53),(19,70),(20,1),(20,2),(20,3),(20,6),(20,11),(20,13),(20,15),(20,16),(20,18),(20,19),(20,20),(20,21),(20,35),(20,36),(20,44),(20,47),(20,49),(20,50),(20,53),(20,56),(20,57),(20,58),(20,59),(20,65),(20,70),(21,1),(21,2),(21,3),(21,6),(21,11),(21,13),(21,18),(21,21),(21,53),(21,70),(22,1),(22,2),(22,3),(22,6),(22,11),(22,13),(22,18),(22,21),(22,22),(22,53),(22,70),(30,1),(30,2),(30,3),(30,5),(30,6),(30,11),(30,13),(30,15),(30,16),(30,18),(30,19),(30,20),(30,21),(30,22),(30,30),(30,33),(30,35),(30,36),(30,44),(30,47),(30,49),(30,50),(30,53),(30,56),(30,57),(30,58),(30,59),(30,64),(30,65),(30,70),(31,1),(31,2),(31,3),(31,6),(31,11),(31,31),(31,70),(32,1),(32,2),(32,3),(32,6),(32,11),(32,32),(32,70),(33,33),(34,1),(34,2),(34,3),(34,6),(34,11),(34,13),(34,33),(34,34),(34,70),(35,1),(35,2),(35,3),(35,6),(35,11),(35,35),(35,70),(36,1),(36,2),(36,3),(36,6),(36,11),(36,36),(36,44),(36,47),(36,70),(37,1),(37,2),(37,3),(37,6),(37,11),(37,37),(37,70),(38,1),(38,2),(38,3),(38,6),(38,11),(38,37),(38,38),(38,64),(38,70),(39,1),(39,2),(39,3),(39,5),(39,6),(39,11),(39,13),(39,18),(39,21),(39,33),(39,39),(39,53),(39,56),(39,57),(39,70),(40,1),(40,2),(40,3),(40,6),(40,11),(40,40),(40,70),(41,1),(41,2),(41,3),(41,6),(41,11),(41,13),(41,35),(41,40),(41,41),(41,70),(42,1),(42,2),(42,3),(42,6),(42,11),(42,42),(42,70),(43,1),(43,2),(43,3),(43,6),(43,11),(43,13),(43,42),(43,43),(43,70),(44,1),(44,2),(44,3),(44,6),(44,11),(44,44),(44,70),(45,1),(45,2),(45,3),(45,6),(45,11),(45,13),(45,44),(45,45),(45,70),(47,1),(47,2),(47,3),(47,6),(47,11),(47,47),(47,70),(48,1),(48,2),(48,3),(48,6),(48,11),(48,13),(48,47),(48,48),(48,70),(49,1),(49,2),(49,3),(49,6),(49,11),(49,36),(49,44),(49,47),(49,49),(49,58),(49,70),(50,1),(50,2),(50,3),(50,6),(50,11),(50,13),(50,18),(50,21),(50,35),(50,36),(50,44),(50,47),(50,49),(50,50),(50,53),(50,56),(50,57),(50,58),(50,59),(50,70),(51,1),(51,2),(51,3),(51,6),(51,11),(51,51),(51,70),(52,1),(52,2),(52,3),(52,6),(52,11),(52,13),(52,18),(52,19),(52,21),(52,35),(52,51),(52,52),(52,53),(52,70),(53,1),(53,2),(53,3),(53,6),(53,11),(53,53),(53,70),(54,1),(54,2),(54,3),(54,6),(54,11),(54,54),(54,70),(55,1),(55,2),(55,3),(55,6),(55,11),(55,13),(55,54),(55,55),(55,70),(56,1),(56,2),(56,3),(56,6),(56,11),(56,56),(56,70),(57,1),(57,2),(57,3),(57,6),(57,11),(57,13),(57,56),(57,57),(57,70),(58,1),(58,2),(58,3),(58,6),(58,11),(58,58),(58,70),(59,1),(59,2),(59,3),(59,6),(59,11),(59,13),(59,58),(59,59),(59,70),(60,1),(60,2),(60,3),(60,5),(60,6),(60,11),(60,13),(60,18),(60,21),(60,33),(60,35),(60,36),(60,37),(60,44),(60,47),(60,49),(60,50),(60,53),(60,56),(60,57),(60,58),(60,59),(60,60),(60,70),(61,1),(61,2),(61,3),(61,6),(61,11),(61,13),(61,36),(61,44),(61,47),(61,61),(61,70),(62,62),(64,64),(65,1),(65,2),(65,3),(65,6),(65,11),(65,13),(65,18),(65,19),(65,21),(65,35),(65,36),(65,44),(65,47),(65,49),(65,50),(65,53),(65,56),(65,57),(65,58),(65,59),(65,65),(65,70),(66,0),(66,1),(66,2),(66,3),(66,5),(66,6),(66,9),(66,11),(66,13),(66,15),(66,16),(66,17),(66,18),(66,19),(66,20),(66,21),(66,22),(66,30),(66,31),(66,32),(66,33),(66,34),(66,35),(66,36),(66,37),(66,38),(66,39),(66,40),(66,41),(66,42),(66,43),(66,44),(66,45),(66,47),(66,48),(66,49),(66,50),(66,51),(66,52),(66,53),(66,54),(66,55),(66,56),(66,57),(66,58),(66,59),(66,60),(66,61),(66,62),(66,64),(66,65),(66,66),(66,67),(66,69),(66,70),(67,1),(67,2),(67,3),(67,5),(67,6),(67,11),(67,13),(67,18),(67,21),(67,33),(67,37),(67,53),(67,67),(67,70),(69,1),(69,2),(69,3),(69,6),(69,11),(69,35),(69,47),(69,69),(69,70),(70,6),(70,11),(70,70); +INSERT INTO `roleRole` VALUES (0,0),(0,1),(0,2),(0,3),(0,5),(0,6),(0,9),(0,11),(0,13),(0,15),(0,16),(0,17),(0,18),(0,19),(0,20),(0,21),(0,22),(0,30),(0,31),(0,32),(0,33),(0,34),(0,35),(0,36),(0,37),(0,38),(0,39),(0,40),(0,41),(0,42),(0,43),(0,44),(0,45),(0,47),(0,48),(0,49),(0,50),(0,51),(0,52),(0,53),(0,54),(0,55),(0,56),(0,57),(0,58),(0,59),(0,60),(0,61),(0,62),(0,64),(0,65),(0,66),(0,67),(0,69),(0,70),(1,1),(1,2),(1,3),(1,6),(1,11),(1,70),(2,2),(2,6),(2,11),(3,3),(3,6),(3,11),(5,1),(5,2),(5,3),(5,5),(5,6),(5,11),(5,13),(5,18),(5,21),(5,33),(5,53),(5,70),(6,6),(9,0),(9,1),(9,2),(9,3),(9,5),(9,6),(9,9),(9,11),(9,13),(9,15),(9,16),(9,17),(9,18),(9,19),(9,20),(9,21),(9,22),(9,30),(9,31),(9,32),(9,33),(9,34),(9,35),(9,36),(9,37),(9,38),(9,39),(9,40),(9,41),(9,42),(9,43),(9,44),(9,45),(9,47),(9,48),(9,49),(9,50),(9,51),(9,52),(9,53),(9,54),(9,55),(9,56),(9,57),(9,58),(9,59),(9,60),(9,61),(9,62),(9,64),(9,65),(9,66),(9,67),(9,69),(9,70),(11,6),(11,11),(13,1),(13,2),(13,3),(13,6),(13,11),(13,13),(13,70),(15,1),(15,2),(15,3),(15,6),(15,11),(15,13),(15,15),(15,35),(15,56),(15,57),(15,70),(16,1),(16,2),(16,3),(16,6),(16,11),(16,13),(16,15),(16,16),(16,35),(16,56),(16,57),(16,70),(17,1),(17,2),(17,3),(17,5),(17,6),(17,11),(17,13),(17,15),(17,16),(17,17),(17,18),(17,19),(17,20),(17,21),(17,33),(17,35),(17,36),(17,37),(17,39),(17,44),(17,47),(17,49),(17,50),(17,53),(17,56),(17,57),(17,58),(17,59),(17,64),(17,65),(17,70),(18,1),(18,2),(18,3),(18,6),(18,11),(18,18),(18,70),(19,1),(19,2),(19,3),(19,6),(19,11),(19,13),(19,18),(19,19),(19,21),(19,53),(19,70),(20,1),(20,2),(20,3),(20,6),(20,11),(20,13),(20,15),(20,16),(20,18),(20,19),(20,20),(20,21),(20,35),(20,36),(20,44),(20,47),(20,49),(20,50),(20,53),(20,56),(20,57),(20,58),(20,59),(20,65),(20,70),(21,1),(21,2),(21,3),(21,6),(21,11),(21,13),(21,18),(21,21),(21,53),(21,70),(22,1),(22,2),(22,3),(22,6),(22,11),(22,13),(22,18),(22,21),(22,22),(22,53),(22,70),(30,1),(30,2),(30,3),(30,5),(30,6),(30,11),(30,13),(30,15),(30,16),(30,18),(30,19),(30,20),(30,21),(30,22),(30,30),(30,33),(30,35),(30,36),(30,44),(30,47),(30,49),(30,50),(30,53),(30,56),(30,57),(30,58),(30,59),(30,64),(30,65),(30,70),(31,1),(31,2),(31,3),(31,6),(31,11),(31,31),(31,70),(32,1),(32,2),(32,3),(32,6),(32,11),(32,32),(32,70),(33,33),(34,1),(34,2),(34,3),(34,6),(34,11),(34,13),(34,33),(34,34),(34,70),(35,1),(35,2),(35,3),(35,6),(35,11),(35,35),(35,70),(36,1),(36,2),(36,3),(36,6),(36,11),(36,36),(36,44),(36,47),(36,70),(37,1),(37,2),(37,3),(37,6),(37,11),(37,37),(37,70),(38,1),(38,2),(38,3),(38,6),(38,11),(38,37),(38,38),(38,64),(38,70),(39,1),(39,2),(39,3),(39,5),(39,6),(39,11),(39,13),(39,18),(39,21),(39,33),(39,39),(39,53),(39,56),(39,57),(39,70),(40,1),(40,2),(40,3),(40,6),(40,11),(40,36),(40,40),(40,44),(40,47),(40,49),(40,58),(40,70),(41,1),(41,2),(41,3),(41,6),(41,11),(41,13),(41,35),(41,36),(41,40),(41,41),(41,44),(41,47),(41,49),(41,58),(41,70),(42,1),(42,2),(42,3),(42,6),(42,11),(42,35),(42,36),(42,42),(42,44),(42,47),(42,49),(42,58),(42,70),(43,1),(43,2),(43,3),(43,6),(43,11),(43,13),(43,35),(43,36),(43,42),(43,43),(43,44),(43,47),(43,49),(43,58),(43,70),(44,1),(44,2),(44,3),(44,6),(44,11),(44,44),(44,70),(45,1),(45,2),(45,3),(45,6),(45,11),(45,13),(45,44),(45,45),(45,70),(47,1),(47,2),(47,3),(47,6),(47,11),(47,47),(47,70),(48,1),(48,2),(48,3),(48,6),(48,11),(48,13),(48,47),(48,48),(48,70),(49,1),(49,2),(49,3),(49,6),(49,11),(49,36),(49,44),(49,47),(49,49),(49,58),(49,70),(50,1),(50,2),(50,3),(50,6),(50,11),(50,13),(50,18),(50,21),(50,35),(50,36),(50,44),(50,47),(50,49),(50,50),(50,53),(50,56),(50,57),(50,58),(50,59),(50,70),(51,1),(51,2),(51,3),(51,6),(51,11),(51,51),(51,70),(52,1),(52,2),(52,3),(52,6),(52,11),(52,13),(52,18),(52,19),(52,21),(52,35),(52,51),(52,52),(52,53),(52,70),(53,1),(53,2),(53,3),(53,6),(53,11),(53,53),(53,70),(54,1),(54,2),(54,3),(54,6),(54,11),(54,54),(54,70),(55,1),(55,2),(55,3),(55,6),(55,11),(55,13),(55,54),(55,55),(55,70),(56,1),(56,2),(56,3),(56,6),(56,11),(56,56),(56,70),(57,1),(57,2),(57,3),(57,6),(57,11),(57,13),(57,56),(57,57),(57,70),(58,1),(58,2),(58,3),(58,6),(58,11),(58,58),(58,70),(59,1),(59,2),(59,3),(59,6),(59,11),(59,13),(59,36),(59,44),(59,47),(59,49),(59,58),(59,59),(59,70),(60,1),(60,2),(60,3),(60,5),(60,6),(60,11),(60,13),(60,18),(60,21),(60,33),(60,35),(60,36),(60,37),(60,44),(60,47),(60,49),(60,50),(60,53),(60,56),(60,57),(60,58),(60,59),(60,60),(60,70),(61,1),(61,2),(61,3),(61,6),(61,11),(61,13),(61,36),(61,44),(61,47),(61,61),(61,70),(62,62),(64,64),(65,1),(65,2),(65,3),(65,6),(65,11),(65,13),(65,18),(65,19),(65,21),(65,35),(65,36),(65,44),(65,47),(65,49),(65,50),(65,53),(65,56),(65,57),(65,58),(65,59),(65,65),(65,70),(66,0),(66,1),(66,2),(66,3),(66,5),(66,6),(66,9),(66,11),(66,13),(66,15),(66,16),(66,17),(66,18),(66,19),(66,20),(66,21),(66,22),(66,30),(66,31),(66,32),(66,33),(66,34),(66,35),(66,36),(66,37),(66,38),(66,39),(66,40),(66,41),(66,42),(66,43),(66,44),(66,45),(66,47),(66,48),(66,49),(66,50),(66,51),(66,52),(66,53),(66,54),(66,55),(66,56),(66,57),(66,58),(66,59),(66,60),(66,61),(66,62),(66,64),(66,65),(66,66),(66,67),(66,69),(66,70),(67,1),(67,2),(67,3),(67,5),(67,6),(67,11),(67,13),(67,18),(67,21),(67,33),(67,37),(67,53),(67,67),(67,70),(69,1),(69,2),(69,3),(69,6),(69,11),(69,35),(69,47),(69,69),(69,70),(70,6),(70,11),(70,70); /*!40000 ALTER TABLE `roleRole` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -94,7 +94,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-23 8:07:57 +-- Dump completed on 2020-08-11 11:50:55 USE `salix`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -119,7 +119,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'),(48,'ItemNiche','*','READ','ALLOW','ROLE','employee'),(49,'ItemNiche','*','WRITE','ALLOW','ROLE','buyer'),(50,'ItemNiche','*','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'),(71,'SaleChecked','*','READ','ALLOW','ROLE','employee'),(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','removes','*','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','salesAssistant'),(98,'ClaimBeginning','*','*','ALLOW','ROLE','employee'),(99,'ClaimDevelopment','*','READ','ALLOW','ROLE','employee'),(100,'ClaimDevelopment','*','WRITE','ALLOW','ROLE','salesAssistant'),(101,'Claim','*','*','ALLOW','ROLE','employee'),(102,'Claim','createFromSales','*','ALLOW','ROLE','employee'),(103,'ClaimEnd','importTicketSales','WRITE','ALLOW','ROLE','salesAssistant'),(104,'Item','*','WRITE','ALLOW','ROLE','marketingBoss'),(105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketingBoss'),(106,'ItemBotanical','*','WRITE','ALLOW','ROLE','marketingBoss'),(107,'ItemNiche','*','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','*','*','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,'WorkerCalendar','*','READ','ALLOW','ROLE','hr'),(156,'WorkerLabour','*','READ','ALLOW','ROLE','hr'),(157,'WorkerCalendar','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'),(164,'InvoiceOut','regenerate','WRITE','ALLOW','ROLE','invoicing'),(165,'TicketDms','*','READ','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'),(188,'TicketDms','removeFile','WRITE','ALLOW','ROLE','employee'),(189,'TicketDms','*','READ','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','employee'),(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','salesAssistant'),(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'),(229,'CustomsAgent','*','*','ALLOW','ROLE','employee'),(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','hr'),(235,'CustomsAgent','*','*','ALLOW','ROLE','employee'); +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'),(48,'ItemNiche','*','READ','ALLOW','ROLE','employee'),(49,'ItemNiche','*','WRITE','ALLOW','ROLE','buyer'),(50,'ItemNiche','*','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'),(71,'SaleChecked','*','READ','ALLOW','ROLE','employee'),(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','salesAssistant'),(98,'ClaimBeginning','*','*','ALLOW','ROLE','employee'),(99,'ClaimDevelopment','*','READ','ALLOW','ROLE','employee'),(100,'ClaimDevelopment','*','WRITE','ALLOW','ROLE','salesAssistant'),(101,'Claim','*','*','ALLOW','ROLE','employee'),(102,'Claim','createFromSales','*','ALLOW','ROLE','employee'),(103,'ClaimEnd','importTicketSales','WRITE','ALLOW','ROLE','salesAssistant'),(104,'Item','*','WRITE','ALLOW','ROLE','marketingBoss'),(105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketingBoss'),(106,'ItemBotanical','*','WRITE','ALLOW','ROLE','marketingBoss'),(107,'ItemNiche','*','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','*','*','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,'WorkerCalendar','*','READ','ALLOW','ROLE','hr'),(156,'WorkerLabour','*','READ','ALLOW','ROLE','hr'),(157,'WorkerCalendar','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'),(164,'InvoiceOut','regenerate','WRITE','ALLOW','ROLE','invoicing'),(165,'TicketDms','*','READ','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'),(188,'TicketDms','removeFile','WRITE','ALLOW','ROLE','employee'),(189,'TicketDms','*','READ','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','employee'),(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','salesAssistant'),(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','hr'),(235,'CustomsAgent','*','*','ALLOW','ROLE','employee'); /*!40000 ALTER TABLE `ACL` ENABLE KEYS */; UNLOCK TABLES; @@ -142,7 +142,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-23 8:07:58 +-- Dump completed on 2020-08-11 11:50:56 USE `vn`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -227,7 +227,7 @@ UNLOCK TABLES; LOCK TABLES `tag` WRITE; /*!40000 ALTER TABLE `tag` DISABLE KEYS */; -INSERT INTO `tag` VALUES (1,'color','Color',0,0,'ink',NULL,NULL),(2,NULL,'Forma',1,0,NULL,NULL,NULL),(3,NULL,'Material',1,0,NULL,NULL,NULL),(4,NULL,'Longitud',1,1,NULL,'mm',NULL),(5,NULL,'Diámetro',1,1,NULL,'mm',NULL),(6,NULL,'Perímetro',1,1,NULL,'mm',NULL),(7,NULL,'Ancho de la base',1,1,NULL,'mm',NULL),(8,NULL,'Altura',1,1,NULL,'mm',NULL),(9,NULL,'Volumen',1,1,NULL,'ml',NULL),(10,NULL,'Densidad',1,1,NULL,NULL,NULL),(11,NULL,'Calidad',1,0,NULL,NULL,NULL),(12,NULL,'Textura',1,0,NULL,NULL,NULL),(13,NULL,'Material del mango',1,0,NULL,NULL,NULL),(14,NULL,'Compra mínima',1,0,NULL,NULL,NULL),(15,NULL,'Nº pétalos',1,1,NULL,NULL,NULL),(16,NULL,'Ancho',1,1,NULL,'mm',NULL),(18,NULL,'Profundidad',1,1,NULL,'mm',NULL),(19,NULL,'Largo',1,1,NULL,'mm',NULL),(20,NULL,'Ancho superior',1,1,NULL,'mm',NULL),(21,NULL,'Ancho inferior',1,1,NULL,'mm',NULL),(22,NULL,'Gramaje',1,1,NULL,'g',NULL),(23,'stems','Tallos',1,1,NULL,NULL,NULL),(24,NULL,'Estado',1,0,NULL,NULL,NULL),(25,NULL,'Color principal',0,0,'ink',NULL,NULL),(26,NULL,'Color secundario',0,0,'ink',NULL,NULL),(27,NULL,'Longitud(cm)',1,1,NULL,'cm',NULL),(28,NULL,'Diámetro base',1,1,'','mm',NULL),(29,NULL,'Colección',1,0,NULL,NULL,NULL),(30,NULL,'Uds / caja',1,1,NULL,NULL,NULL),(31,NULL,'Contenido',1,0,NULL,NULL,NULL),(32,NULL,'Peso',1,1,NULL,'g',NULL),(33,NULL,'Grosor',1,1,NULL,'mm',NULL),(34,NULL,'Marca',1,0,NULL,NULL,NULL),(35,'origin','Origen',0,0,'origin',NULL,NULL),(36,NULL,'Proveedor',1,0,NULL,NULL,NULL),(37,'producer','Productor',0,0,'producer',NULL,NULL),(38,NULL,'Duración',1,1,NULL,'s',NULL),(39,NULL,'Flor',1,0,NULL,NULL,NULL),(40,NULL,'Soporte',1,0,NULL,NULL,NULL),(41,NULL,'Tamaño flor',1,0,NULL,NULL,NULL),(42,NULL,'Apertura',1,0,NULL,NULL,NULL),(43,NULL,'Tallo',1,0,NULL,NULL,NULL),(44,NULL,'Nº hojas',1,1,NULL,NULL,NULL),(45,NULL,'Dimensiones',1,0,NULL,NULL,NULL),(46,NULL,'Diámetro boca',1,1,NULL,'mm',NULL),(47,NULL,'Nº flores',1,1,NULL,NULL,NULL),(48,NULL,'Uds / paquete',1,1,NULL,NULL,NULL),(49,NULL,'Maceta',1,1,NULL,'cm',NULL),(50,NULL,'Textura flor',1,0,NULL,NULL,NULL),(51,NULL,'Textura hoja',1,0,NULL,NULL,NULL),(52,NULL,'Tipo de IVA',1,0,NULL,NULL,NULL),(53,NULL,'Tronco',1,0,NULL,NULL,NULL),(54,NULL,'Hoja',1,0,NULL,NULL,NULL),(55,NULL,'Formato',1,0,NULL,NULL,NULL),(56,NULL,'Genero',1,0,NULL,NULL,NULL),(57,NULL,'Especie',1,0,NULL,NULL,NULL),(58,NULL,'Variedad',1,0,NULL,NULL,NULL),(59,NULL,'Medida grande',1,0,NULL,NULL,NULL),(60,NULL,'Medida mediano',1,0,NULL,NULL,NULL),(61,NULL,'Medida pequeño',1,0,NULL,NULL,NULL),(63,NULL,'Recipiente interior',1,0,NULL,NULL,NULL),(64,NULL,'Material secundario',1,0,NULL,NULL,NULL),(65,NULL,'Colores',1,0,NULL,NULL,NULL),(66,NULL,'Referencia',1,0,NULL,NULL,NULL),(67,NULL,'Categoria',1,0,NULL,NULL,NULL),(68,NULL,'Amb',1,0,NULL,NULL,NULL),(69,NULL,'Anchura',1,1,NULL,'cm',NULL),(70,NULL,'Hueco interior',1,0,NULL,NULL,NULL),(71,NULL,'Tamaño',1,0,NULL,NULL,NULL),(72,NULL,'Color botón',1,0,NULL,NULL,NULL),(73,NULL,'Tamaño minimo del botón',1,0,NULL,NULL,NULL),(74,NULL,'Obtentor',1,0,NULL,NULL,NULL),(75,NULL,'Longitud del brote',1,0,NULL,NULL,NULL),(76,NULL,'Tallos / u.v.',1,0,NULL,NULL,NULL),(77,NULL,'Madera de',1,0,NULL,NULL,NULL),(78,NULL,'Unidad de venta',1,0,NULL,NULL,NULL),(79,NULL,'Temporal',1,0,NULL,NULL,NULL),(80,NULL,'Gramaje/tallo',1,1,NULL,'g',NULL),(81,NULL,'Peso/paquete',1,1,NULL,'g',NULL),(82,NULL,'Flexibilidad del tallo',1,0,NULL,NULL,NULL),(83,NULL,'Nº planchas',1,1,NULL,NULL,NULL),(84,NULL,'Nº páginas',1,1,NULL,NULL,NULL),(85,NULL,'Editorial',1,0,NULL,NULL,NULL),(86,NULL,'Idioma',1,0,NULL,NULL,NULL),(87,NULL,'Fecha publicación',1,0,NULL,NULL,NULL),(88,NULL,'Cubierta',1,0,NULL,NULL,NULL),(89,NULL,'Encuadernación',1,0,NULL,NULL,NULL),(90,NULL,'Autor',1,0,NULL,NULL,NULL),(91,NULL,'Envoltorio',1,0,NULL,NULL,NULL),(92,NULL,'Nombre temporal',1,0,NULL,NULL,NULL),(93,NULL,'Modelo',1,0,NULL,NULL,NULL),(94,NULL,'Producto',1,0,NULL,NULL,NULL),(95,NULL,'Título',1,0,NULL,NULL,NULL),(96,NULL,'Tomo',1,0,NULL,NULL,NULL),(97,NULL,'Articulo',1,0,NULL,NULL,NULL),(98,NULL,'Metodo de cultivo',1,0,NULL,NULL,NULL),(99,NULL,'Edad',1,0,NULL,NULL,NULL),(100,NULL,'Agotado',1,0,NULL,NULL,NULL),(101,NULL,'Altura con asa',1,1,NULL,'cm',NULL),(102,NULL,'Nº tallos',1,1,NULL,NULL,NULL),(103,NULL,'Cultivo',1,0,NULL,NULL,NULL),(104,NULL,'Sabor',1,0,NULL,NULL,NULL),(105,NULL,'Talla',1,0,NULL,NULL,NULL),(106,NULL,'Calibre',1,1,NULL,NULL,NULL),(107,NULL,'Dulzura',1,1,NULL,'bx',NULL),(108,NULL,'Piezas',1,0,NULL,NULL,NULL),(109,NULL,'Altura con patas',1,0,NULL,NULL,NULL),(110,NULL,'Envase',1,0,NULL,NULL,NULL),(111,NULL,'Nº piezas',1,0,NULL,NULL,NULL),(112,NULL,'Uso',1,0,NULL,'cm',NULL),(113,NULL,'Color luz',1,0,NULL,NULL,NULL),(114,NULL,'Capacidad',1,0,NULL,NULL,NULL); +INSERT INTO `tag` VALUES (1,'color','Color',0,0,'ink',NULL,NULL,'inkFk'),(2,NULL,'Forma',1,0,NULL,NULL,NULL,NULL),(3,NULL,'Material',1,0,NULL,NULL,NULL,NULL),(4,NULL,'Longitud',1,1,NULL,'mm',NULL,'size'),(5,NULL,'Diámetro',1,1,NULL,'mm',NULL,NULL),(6,NULL,'Perímetro',1,1,NULL,'mm',NULL,NULL),(7,NULL,'Ancho de la base',1,1,NULL,'mm',NULL,NULL),(8,NULL,'Altura',1,1,NULL,'mm',NULL,'size'),(9,NULL,'Volumen',1,1,NULL,'ml',NULL,NULL),(10,NULL,'Densidad',1,1,NULL,NULL,NULL,NULL),(11,NULL,'Calidad',1,0,NULL,NULL,NULL,NULL),(12,NULL,'Textura',1,0,NULL,NULL,NULL,NULL),(13,NULL,'Material del mango',1,0,NULL,NULL,NULL,NULL),(14,NULL,'Compra mínima',1,0,NULL,NULL,NULL,NULL),(15,NULL,'Nº pétalos',1,1,NULL,NULL,NULL,NULL),(16,NULL,'Ancho',1,1,NULL,'mm',NULL,NULL),(18,NULL,'Profundidad',1,1,NULL,'mm',NULL,NULL),(19,NULL,'Largo',1,1,NULL,'mm',NULL,'size'),(20,NULL,'Ancho superior',1,1,NULL,'mm',NULL,NULL),(21,NULL,'Ancho inferior',1,1,NULL,'mm',NULL,NULL),(22,NULL,'Gramaje',1,1,NULL,'g',NULL,NULL),(23,'stems','Tallos',1,1,NULL,NULL,NULL,'stems'),(24,NULL,'Estado',1,0,NULL,NULL,NULL,NULL),(25,NULL,'Color principal',0,0,'ink',NULL,NULL,NULL),(26,NULL,'Color secundario',0,0,'ink',NULL,NULL,NULL),(27,NULL,'Longitud(cm)',1,1,NULL,'cm',NULL,NULL),(28,NULL,'Diámetro base',1,1,'','mm',NULL,NULL),(29,NULL,'Colección',1,0,NULL,NULL,NULL,NULL),(30,NULL,'Uds / caja',1,1,NULL,NULL,NULL,NULL),(31,NULL,'Contenido',1,0,NULL,NULL,NULL,NULL),(32,NULL,'Peso',1,1,NULL,'g',NULL,NULL),(33,NULL,'Grosor',1,1,NULL,'mm',NULL,NULL),(34,NULL,'Marca',1,0,NULL,NULL,NULL,NULL),(35,'origin','Origen',0,0,'origin',NULL,NULL,'originFk'),(36,NULL,'Proveedor',1,0,NULL,NULL,NULL,NULL),(37,'producer','Productor',0,0,'producer',NULL,NULL,'producerFk'),(38,NULL,'Duración',1,1,NULL,'s',NULL,NULL),(39,NULL,'Flor',1,0,NULL,NULL,NULL,NULL),(40,NULL,'Soporte',1,0,NULL,NULL,NULL,NULL),(41,NULL,'Tamaño flor',1,0,NULL,NULL,NULL,NULL),(42,NULL,'Apertura',1,0,NULL,NULL,NULL,NULL),(43,NULL,'Tallo',1,0,NULL,NULL,NULL,NULL),(44,NULL,'Nº hojas',1,1,NULL,NULL,NULL,NULL),(45,NULL,'Dimensiones',1,0,NULL,NULL,NULL,NULL),(46,NULL,'Diámetro boca',1,1,NULL,'mm',NULL,NULL),(47,NULL,'Nº flores',1,1,NULL,NULL,NULL,NULL),(48,NULL,'Uds / paquete',1,1,NULL,NULL,NULL,NULL),(49,NULL,'Maceta',1,1,NULL,'cm',NULL,NULL),(50,NULL,'Textura flor',1,0,NULL,NULL,NULL,NULL),(51,NULL,'Textura hoja',1,0,NULL,NULL,NULL,NULL),(52,NULL,'Tipo de IVA',1,0,NULL,NULL,NULL,NULL),(53,NULL,'Tronco',1,0,NULL,NULL,NULL,NULL),(54,NULL,'Hoja',1,0,NULL,NULL,NULL,NULL),(55,NULL,'Formato',1,0,NULL,NULL,NULL,NULL),(56,NULL,'Genero',1,0,NULL,NULL,NULL,NULL),(57,NULL,'Especie',1,0,NULL,NULL,NULL,NULL),(58,NULL,'Variedad',1,0,NULL,NULL,NULL,NULL),(59,NULL,'Medida grande',1,0,NULL,NULL,NULL,NULL),(60,NULL,'Medida mediano',1,0,NULL,NULL,NULL,NULL),(61,NULL,'Medida pequeño',1,0,NULL,NULL,NULL,NULL),(63,NULL,'Recipiente interior',1,0,NULL,NULL,NULL,NULL),(64,NULL,'Material secundario',1,0,NULL,NULL,NULL,NULL),(65,NULL,'Colores',1,0,NULL,NULL,NULL,NULL),(66,NULL,'Referencia',1,0,NULL,NULL,NULL,NULL),(67,'category','Categoria',1,0,NULL,NULL,NULL,NULL),(68,NULL,'Amb',1,0,NULL,NULL,NULL,NULL),(69,NULL,'Anchura',1,1,NULL,'cm',NULL,NULL),(70,NULL,'Hueco interior',1,0,NULL,NULL,NULL,NULL),(71,NULL,'Tamaño',1,0,NULL,NULL,NULL,NULL),(72,NULL,'Color botón',1,0,NULL,NULL,NULL,NULL),(73,NULL,'Tamaño minimo del botón',1,0,NULL,NULL,NULL,NULL),(74,NULL,'Obtentor',1,0,NULL,NULL,NULL,NULL),(75,NULL,'Longitud del brote',1,0,NULL,NULL,NULL,NULL),(76,NULL,'Tallos / u.v.',1,0,NULL,NULL,NULL,NULL),(77,NULL,'Madera de',1,0,NULL,NULL,NULL,NULL),(78,NULL,'Unidad de venta',1,0,NULL,NULL,NULL,NULL),(79,NULL,'Temporal',1,0,NULL,NULL,NULL,NULL),(80,NULL,'Gramaje/tallo',1,1,NULL,'g',NULL,NULL),(81,NULL,'Peso/paquete',1,1,NULL,'g',NULL,NULL),(82,NULL,'Flexibilidad del tallo',1,0,NULL,NULL,NULL,NULL),(83,NULL,'Nº planchas',1,1,NULL,NULL,NULL,NULL),(84,NULL,'Nº páginas',1,1,NULL,NULL,NULL,NULL),(85,NULL,'Editorial',1,0,NULL,NULL,NULL,NULL),(86,NULL,'Idioma',1,0,NULL,NULL,NULL,NULL),(87,NULL,'Fecha publicación',1,0,NULL,NULL,NULL,NULL),(88,NULL,'Cubierta',1,0,NULL,NULL,NULL,NULL),(89,NULL,'Encuadernación',1,0,NULL,NULL,NULL,NULL),(90,NULL,'Autor',1,0,NULL,NULL,NULL,NULL),(91,NULL,'Envoltorio',1,0,NULL,NULL,NULL,NULL),(92,NULL,'Nombre temporal',1,0,NULL,NULL,NULL,NULL),(93,NULL,'Modelo',1,0,NULL,NULL,NULL,NULL),(94,NULL,'Producto',1,0,NULL,NULL,NULL,NULL),(95,NULL,'Título',1,0,NULL,NULL,NULL,NULL),(96,NULL,'Tomo',1,0,NULL,NULL,NULL,NULL),(97,NULL,'Articulo',1,0,NULL,NULL,NULL,NULL),(98,NULL,'Metodo de cultivo',1,0,NULL,NULL,NULL,NULL),(99,NULL,'Edad',1,0,NULL,NULL,NULL,NULL),(100,NULL,'Agotado',1,0,NULL,NULL,NULL,NULL),(101,NULL,'Altura con asa',1,1,NULL,'cm',NULL,NULL),(102,NULL,'Nº tallos',1,1,NULL,NULL,NULL,NULL),(103,NULL,'Cultivo',1,0,NULL,NULL,NULL,NULL),(104,NULL,'Sabor',1,0,NULL,NULL,NULL,NULL),(105,NULL,'Talla',1,0,NULL,NULL,NULL,NULL),(106,NULL,'Calibre',1,1,NULL,NULL,NULL,NULL),(107,NULL,'Dulzura',1,1,NULL,'bx',NULL,NULL),(108,NULL,'Piezas',1,0,NULL,NULL,NULL,NULL),(109,NULL,'Altura con patas',1,0,NULL,NULL,NULL,NULL),(110,NULL,'Envase',1,0,NULL,NULL,NULL,NULL),(111,NULL,'Nº piezas',1,0,NULL,NULL,NULL,NULL),(112,NULL,'Uso',1,0,NULL,'cm',NULL,NULL),(113,NULL,'Color luz',1,0,NULL,NULL,NULL,NULL),(114,NULL,'Capacidad',1,0,NULL,NULL,NULL,NULL),(184,NULL,'Tallos por paquete',1,0,NULL,NULL,NULL,NULL),(205,NULL,'Apertura',1,0,NULL,NULL,'S05',NULL),(219,NULL,'Altura',1,0,NULL,NULL,'S20','size'),(552,NULL,'fout kenmerk',1,0,NULL,NULL,'081',NULL),(553,NULL,'Potinhoud',1,0,NULL,NULL,'A01',NULL),(554,NULL,'Marketingconcept',1,0,NULL,NULL,'A02',NULL),(555,NULL,'Leeftijd',1,0,NULL,NULL,'A03',NULL),(556,NULL,'Uitgangsmateriaal',1,0,NULL,NULL,'A04',NULL),(557,NULL,'Kleurbehandeld',1,0,NULL,NULL,'A05','inkFk'),(558,NULL,'Verzorging: Standplaats',1,0,NULL,NULL,'A06',NULL),(559,NULL,'Verzorging: Water',1,0,NULL,NULL,'A07',NULL),(560,NULL,'Verzorging: Voeding',1,0,NULL,NULL,'A08',NULL),(561,NULL,'Verzorging: Temperatuur',1,0,NULL,NULL,'A09',NULL),(562,NULL,'Verzorging: Specifieke in',1,0,NULL,NULL,'A10',NULL),(563,NULL,'Verzorging: Consumptie',1,0,NULL,NULL,'A11',NULL),(564,NULL,'Nabehandeling',1,0,NULL,NULL,'A13',NULL),(565,NULL,'Artikel beeld',1,0,NULL,NULL,'A23',NULL),(566,NULL,'Hoofdkleur 1',1,0,NULL,NULL,'B01',NULL),(567,NULL,'Hoofdkleur 2',1,0,NULL,NULL,'B02',NULL),(568,NULL,'RHS hoofdkleur 1',1,0,NULL,NULL,'B03',NULL),(569,NULL,'RHS hoofdkleur 2',1,0,NULL,NULL,'B04',NULL),(570,NULL,'Hoofdkleur 1 blad',1,0,NULL,NULL,'B05',NULL),(571,NULL,'Hoofdkleur 2 blad',1,0,NULL,NULL,'B06',NULL),(572,NULL,'RHS hoofdkleur 1 blad',1,0,NULL,NULL,'B07',NULL),(573,NULL,'RHS hoofdkleur 2 blad',1,0,NULL,NULL,'B08',NULL),(574,NULL,'Botanisch beeld',1,0,NULL,NULL,'B09',NULL),(575,NULL,'Hoofdkleur bes/vrucht',1,0,NULL,NULL,'B10',NULL),(576,NULL,'RHS hoofdkleur bes/vrucht',1,0,NULL,NULL,'B11',NULL),(577,NULL,'UPOV hoofdkleur 1 bloem',1,0,NULL,NULL,'B12',NULL),(578,NULL,'UPOV hoofdkleur 2 bloem',1,0,NULL,NULL,'B13',NULL),(579,NULL,'UPOV hoofdkleur 1 blad',1,0,NULL,NULL,'B14',NULL),(580,NULL,'UPOV hoofdkleur 2 blad',1,0,NULL,NULL,'B15',NULL),(581,NULL,'UPOV hoofdkleur bes/vruch',1,0,NULL,NULL,'B16',NULL),(582,NULL,'Negatieve keurcode 1',1,0,NULL,NULL,'K01',NULL),(583,NULL,'Negatieve keurcode 2',1,0,NULL,NULL,'K02',NULL),(584,NULL,'Bedrijfskenmerk fytosanit',1,0,NULL,NULL,'K03',NULL),(585,NULL,'Certificaten aardwarmte',1,0,NULL,NULL,'K04',NULL),(586,NULL,'Certificaten MPS-TraceCer',1,0,NULL,NULL,'K05',NULL),(587,NULL,'Overige leveranciersinfor',1,0,NULL,NULL,'K07',NULL),(588,NULL,'Certificaten MPS-GAP',1,0,NULL,NULL,'K08',NULL),(589,NULL,'Betrouwbaarheidsindex kla',1,0,NULL,NULL,'K11',NULL),(590,NULL,'Betrouwbaarheidsindex waa',1,0,NULL,NULL,'K12',NULL),(591,NULL,'Productkwaliteitslabel',1,0,NULL,NULL,'K13',NULL),(592,NULL,'Label Fair Flowers Fair P',1,0,NULL,NULL,'K14',NULL),(593,NULL,'Certificaten Socialy Qual',1,0,NULL,NULL,'K15',NULL),(594,NULL,'Certificaten GlobalGAP',1,0,NULL,NULL,'K16',NULL),(595,NULL,'Certificaten MPS Quality',1,0,NULL,NULL,'K17',NULL),(596,NULL,'Certificaten biologisch',1,0,NULL,NULL,'K18',NULL),(597,NULL,'Certificaten eetbare prod',1,0,NULL,NULL,'K19',NULL),(598,NULL,'Certificaten Florimark',1,0,NULL,NULL,'K20',NULL),(599,NULL,'Certificaten Milieukeur',1,0,NULL,NULL,'K21',NULL),(600,NULL,'Certificaten Kenya Flower',1,0,NULL,NULL,'K22',NULL),(601,NULL,'Certificaten Fairtrade',1,0,NULL,NULL,'K23',NULL),(602,NULL,'Keurmerk MPS-ProductProof',1,0,NULL,NULL,'K24',NULL),(603,NULL,'Certificaten ISO',1,0,NULL,NULL,'K25',NULL),(604,NULL,'Certificaten aardwarmte',1,0,NULL,NULL,'K26',NULL),(605,NULL,'Certificaten Florverde',1,0,NULL,NULL,'K27',NULL),(606,NULL,'Certificaten Ethical Trad',1,0,NULL,NULL,'K28',NULL),(607,NULL,'Certificaten Ethiopian EH',1,0,NULL,NULL,'K29',NULL),(608,NULL,'Certificaten gewasbescher',1,0,NULL,NULL,'K30',NULL),(609,NULL,'Certificaten SAN',1,0,NULL,NULL,'K31',NULL),(610,NULL,'Certificaten GRASP',1,0,NULL,NULL,'K32',NULL),(611,NULL,'Label Fair Flora',1,0,NULL,NULL,'K33',NULL),(612,NULL,'GLobalG.A.P. Chain of Cus',1,0,NULL,NULL,'K34',NULL),(613,NULL,'Fust',1,0,NULL,NULL,'L01',NULL),(614,NULL,'Stapelwagen',1,0,NULL,NULL,'L02',NULL),(615,NULL,'Aantal legborden veilings',1,0,NULL,NULL,'L03',NULL),(616,NULL,'Aantal legborden Deense s',1,0,NULL,NULL,'L04',NULL),(617,NULL,'Aantal onderstellen Deens',1,0,NULL,NULL,'L05',NULL),(618,NULL,'Fustsoort',1,0,NULL,NULL,'L06',NULL),(619,NULL,'Fustmateriaal',1,0,NULL,NULL,'L07',NULL),(620,NULL,'Aantal legborden Eurostap',1,0,NULL,NULL,'L08',NULL),(621,NULL,'Aantal onderstellen Euros',1,0,NULL,NULL,'L09',NULL),(622,NULL,'Tallos/bolsa',1,0,NULL,NULL,'L11',''),(623,NULL,'Aantal bossen per bundel',1,0,NULL,NULL,'L12',NULL),(624,NULL,'Aantal stuks per fust',1,0,NULL,NULL,'L13',NULL),(625,NULL,'Aantal bossen per fust',1,0,NULL,NULL,'L14',NULL),(626,NULL,'Aantal bundels per fust',1,0,NULL,NULL,'L15',NULL),(627,NULL,'Aantal bossen per hoes',1,0,NULL,NULL,'L16',NULL),(628,NULL,'Aantal bundels per hoes',1,0,NULL,NULL,'L17',NULL),(629,NULL,'Fustlabel',1,0,NULL,NULL,'L18',NULL),(630,NULL,'Karlabel',1,0,NULL,NULL,'L19',NULL),(631,NULL,'Service productlabel',1,0,NULL,NULL,'L20',NULL),(632,NULL,'Service fustlabel',1,0,NULL,NULL,'L21',NULL),(633,NULL,'Service karlabel',1,0,NULL,NULL,'L22',NULL),(634,NULL,'Aantal fusten per laag',1,0,NULL,NULL,'L23',NULL),(635,NULL,'Presentatie per schapm2',1,0,NULL,NULL,'L24',NULL),(636,NULL,'Positieve keurcode fytosa',1,0,NULL,NULL,'P01',NULL),(637,NULL,'Positieve keurcode kwalit',1,0,NULL,NULL,'P02',NULL),(638,NULL,'Positieve keurcode veilin',1,0,NULL,NULL,'P03',NULL),(639,NULL,'Maceta',1,1,NULL,'cm','S01',NULL),(640,NULL,'Altura',1,0,NULL,NULL,'S02','size'),(641,NULL,'nº plantas',1,0,NULL,NULL,'S03',NULL),(642,NULL,'Diámetro',1,0,NULL,NULL,'S04',NULL),(644,NULL,'Combinatiehoogte',1,0,NULL,NULL,'S06',NULL),(645,NULL,'Plantas/Maceta',1,0,NULL,NULL,'S07',NULL),(646,NULL,'Dikte',1,0,NULL,NULL,'S08',NULL),(647,NULL,'nº flores',1,0,NULL,NULL,'S09',NULL),(648,NULL,'Min aantal bloemtrossen p',1,0,NULL,NULL,'S10',NULL),(649,NULL,'nº ramales',1,0,NULL,NULL,'S11',NULL),(650,NULL,'Minimum aantal bollen per',1,0,NULL,NULL,'S12',NULL),(651,NULL,'Minimum aantal bladeren p',1,0,NULL,NULL,'S13',NULL),(652,NULL,'Minimum stamhoogte',1,0,NULL,NULL,'S14',NULL),(653,NULL,'Altura caja',1,0,NULL,NULL,'S15',NULL),(654,NULL,'Lengte scheuten',1,0,NULL,NULL,'S16',NULL),(655,NULL,'Min aant vertakkingen pr ',1,0,NULL,NULL,'S17',NULL),(656,NULL,'Altura del capullo',1,0,NULL,NULL,'S19',NULL),(658,NULL,'Peso tallo',1,0,NULL,NULL,'S21',NULL),(659,NULL,'nº flores',1,0,NULL,NULL,'S22',NULL),(660,NULL,'Diámetro de la flor',1,0,NULL,NULL,'S23',NULL),(661,NULL,'Minimum bloemschedelengte',1,0,NULL,NULL,'S24',NULL),(662,NULL,'Aantal bloemkoppen per tr',1,0,NULL,NULL,'S25',NULL),(663,NULL,'Aant.kleuren/cultiv/vorme',1,0,NULL,NULL,'S26',NULL),(664,NULL,'Aant.kleuren/cultiv/vorme',1,0,NULL,NULL,'S27',NULL),(665,NULL,'Aant.kleuren/cultiv/vorme',1,0,NULL,NULL,'S28',NULL),(666,NULL,'Longitud inflorescencia',1,0,NULL,NULL,'S29',NULL),(667,NULL,'Verpakkingswijze snijbloe',1,0,NULL,NULL,'S30',NULL),(668,NULL,'Minimum aant bloemen per ',1,0,NULL,NULL,'S31',NULL),(669,NULL,'Longitud',1,0,NULL,NULL,'S32',NULL),(670,NULL,'Jaartal sortering hout',1,0,NULL,NULL,'S33',NULL),(671,NULL,'Diámetro de la hoja',1,0,NULL,NULL,'S34',NULL),(672,NULL,'Peso paquete',1,0,NULL,NULL,'S35',NULL),(673,NULL,'Maximum planthoogte',1,0,NULL,NULL,'S36',NULL),(674,NULL,'Maximum plantdiameter',1,0,NULL,NULL,'S37',NULL),(675,NULL,'Max aantal bloemen/bloeiw',1,0,NULL,NULL,'S38',NULL),(676,NULL,'Maximum aantal takken per',1,0,NULL,NULL,'S39',NULL),(677,NULL,'Maximum aantal bollen per',1,0,NULL,NULL,'S40',NULL),(678,NULL,'Maximum stamhoogte',1,0,NULL,NULL,'S41',NULL),(679,NULL,'Longitud mínima',1,0,NULL,NULL,'S42','size'),(680,NULL,'Maximum aantal knoppen sn',1,0,NULL,NULL,'S43',NULL),(681,NULL,'Maximum bloemdiameter',1,0,NULL,NULL,'S44',NULL),(682,NULL,'Maximum bloeiwijzelengte',1,0,NULL,NULL,'S45',NULL),(683,NULL,'Aantal vruchten / trossen',1,0,NULL,NULL,'S46',NULL),(684,NULL,'Verpakkingswijze',1,0,NULL,NULL,'S47',NULL),(685,NULL,'Minimum vruchtdiameter',1,0,NULL,NULL,'S48',NULL),(686,NULL,'Bolomvang',1,0,NULL,NULL,'S49',NULL),(687,NULL,'Bloem/bes/vruchtkleur 1',1,0,NULL,NULL,'S50',NULL),(688,NULL,'Potvorm',1,0,NULL,NULL,'S51',NULL),(689,NULL,'Potkleur',1,0,NULL,NULL,'S52',NULL),(690,NULL,'Material maceta',1,0,NULL,NULL,'S53',NULL),(691,NULL,'Plantvorm',1,0,NULL,NULL,'S54',NULL),(692,NULL,'Aantal kleuren/cultiv per',1,0,NULL,NULL,'S55',NULL),(693,NULL,'Teeltwijze',1,0,NULL,NULL,'S56',NULL),(694,NULL,'Teeltmedium',1,0,NULL,NULL,'S57',NULL),(695,NULL,'Hoesmateriaal',1,0,NULL,NULL,'S58',NULL),(696,NULL,'Hoesvorm',1,0,NULL,NULL,'S59',NULL),(697,NULL,'Hoesbedrukking algemeen',1,0,NULL,NULL,'S60',NULL),(698,NULL,'Extra toevoegingen',1,0,NULL,NULL,'S61',NULL),(699,NULL,'Land van herkomst (bedrij',1,0,NULL,NULL,'S62',NULL),(700,NULL,'Verpakte orchidee',1,0,NULL,NULL,'S63',NULL),(701,NULL,'Hoesbedrukking extra',1,0,NULL,NULL,'S64',NULL),(702,NULL,'Voorbehandeling',1,0,NULL,NULL,'S65',NULL),(703,NULL,'Overige niet in pot',1,0,NULL,NULL,'S66',NULL),(704,NULL,'Vorm snijbloemen',1,0,NULL,NULL,'S67',NULL),(705,NULL,'Buigzaamheid bloemsteel',1,0,NULL,NULL,'S68',NULL),(706,NULL,'Hoeskleur',1,0,NULL,NULL,'S69',NULL),(707,NULL,'Extra deco materiaal',1,0,NULL,NULL,'S70',NULL),(708,NULL,'Productkleur',1,0,NULL,NULL,'S71','inkFk'),(709,NULL,'Productmateriaal',1,0,NULL,NULL,'S72',NULL),(710,NULL,'Materiaalhoogte',1,0,NULL,NULL,'S73',NULL),(711,NULL,'Materiaaldiameter',1,0,NULL,NULL,'S74',NULL),(712,NULL,'Barcode',1,0,NULL,NULL,'S75',NULL),(713,NULL,'Productlabel',1,0,NULL,NULL,'S76',NULL),(714,NULL,'Eetbaar/ niet eetbaar',1,0,NULL,NULL,'S77',NULL),(715,NULL,'Plantmaat zonder pot',1,0,NULL,NULL,'S78',NULL),(716,NULL,'Aantal kleuren/cultiv per',1,0,NULL,NULL,'S79',NULL),(717,NULL,'Maximum percentage oud ho',1,0,NULL,NULL,'S80',NULL),(718,NULL,'Maximum lengte verschil',1,0,NULL,NULL,'S81',NULL),(719,NULL,'Bladkleur',1,0,NULL,NULL,'S82',NULL),(720,NULL,'Plantgewicht',1,0,NULL,NULL,'S83',NULL),(721,NULL,'Diámetro',1,0,NULL,NULL,'S84',NULL),(722,NULL,'Bloem/bes/vruchtkleur 2',1,0,NULL,NULL,'S85',NULL),(723,NULL,'Winterhardheid (USDA zone',1,0,NULL,NULL,'S86',NULL),(724,NULL,'Kleurbehandeld',1,0,NULL,NULL,'S87','inkFk'),(725,NULL,'Bloem-/bladkleurverdeling',1,0,NULL,NULL,'S88',NULL),(726,NULL,'Diámetro del capullo',1,0,NULL,NULL,'S89',NULL),(727,NULL,'Volume inhoud',1,0,NULL,NULL,'S90',NULL),(728,NULL,'Vruchtbenaming',1,0,NULL,NULL,'S91',NULL),(729,NULL,'Vaaslevenindex',1,0,NULL,NULL,'S92',NULL),(730,NULL,'Overige informatie plante',1,0,NULL,NULL,'S93',NULL),(731,NULL,'Overige informatie snijbl',1,0,NULL,NULL,'S94',NULL),(732,NULL,'Toepassingsmogelijkheid',1,0,NULL,NULL,'S95',NULL),(733,NULL,'Productbeeld aanvoerder',1,0,NULL,NULL,'S96',NULL),(734,NULL,'MPS certificering',1,0,NULL,NULL,'S97',NULL),(735,NULL,'Kwaliteitsgroep',1,0,NULL,NULL,'S98',NULL),(736,NULL,'Artikelomschrijving',1,0,NULL,NULL,'S99',NULL),(737,NULL,'BTW-tarief',1,0,NULL,NULL,'T01',NULL),(738,NULL,'Prijseenheid',1,0,NULL,NULL,'T02',NULL),(739,NULL,'Transactievorm',1,0,NULL,NULL,'T03',NULL),(740,NULL,'Handelsverpakking voorwaa',1,0,NULL,NULL,'T10',NULL),(741,NULL,'Consumentenverpakking voo',1,0,NULL,NULL,'T11',NULL),(742,NULL,'Leveringsvoorwaarden',1,0,NULL,NULL,'T12',NULL),(743,NULL,'PT heffing voorwaarden',1,0,NULL,NULL,'T13',NULL),(744,NULL,'Serviceheffing voorwaarde',1,0,NULL,NULL,'T14',NULL),(745,NULL,'Algemene voorwaarden',1,0,NULL,NULL,'T15',NULL),(746,NULL,'Marktvorm',1,0,NULL,NULL,'T16',NULL),(747,NULL,'Themadagen',1,0,NULL,NULL,'T17',NULL),(748,NULL,'Handelscategorie',1,0,NULL,NULL,'T18',NULL),(749,NULL,'Producentengroepen',1,0,NULL,NULL,'T19',NULL),(750,NULL,'Favorieten Id',1,0,NULL,NULL,'T20',NULL),(751,NULL,'Verkoopeenheid',1,0,NULL,NULL,'T21',NULL),(752,NULL,'Veilgroep voorkeur',1,0,NULL,NULL,'V01',NULL),(753,NULL,'Gereserveerd FloraHolland',1,0,NULL,NULL,'V02',NULL),(754,NULL,'Keurmeesternummer FloraHo',1,0,NULL,NULL,'V03',NULL),(755,NULL,'Rijnummer Rijnsburg',1,0,NULL,NULL,'V04',NULL),(756,NULL,'Verwerkingslocatie FloraH',1,0,NULL,NULL,'V05',NULL),(757,NULL,'FloraHolland Financial',1,0,NULL,NULL,'V06',NULL),(758,NULL,'Gereserveerd FloraHolland',1,0,NULL,NULL,'V07',NULL),(759,NULL,'Benefiet veiling',1,0,NULL,NULL,'V08',NULL),(760,NULL,'Kloksoort',1,0,NULL,NULL,'V09',NULL),(761,NULL,'Minimumprijs aanvoerder',1,0,NULL,NULL,'V10',NULL),(762,NULL,'Rest aantallen',1,0,NULL,NULL,'V11',NULL),(763,NULL,'Veilsoort',1,0,NULL,NULL,'V12',NULL),(764,NULL,'Gereserveerd FloraHolland',1,0,NULL,NULL,'V13',NULL),(765,NULL,'Gereserveerd FloraHolland',1,0,NULL,NULL,'V14',NULL),(766,NULL,'Gereserveerd FloraHolland',1,0,NULL,NULL,'V15',NULL),(767,NULL,'Gereserveerd FloraHolland',1,0,NULL,NULL,'V16',NULL),(768,NULL,'Gereserveerd FloraHolland',1,0,NULL,NULL,'V17',NULL),(769,NULL,'Gereserveerd FloraHolland',1,0,NULL,NULL,'V18',NULL),(770,NULL,'Gereserveerd FloraHolland',1,0,NULL,NULL,'V19',NULL),(771,NULL,'Gereserveerd',1,0,NULL,NULL,'V20',NULL),(772,NULL,'Veilgroep Aalsmeer',1,0,NULL,NULL,'V21',NULL),(773,NULL,'Promotie kenmerk FloraHol',1,0,NULL,NULL,'V22',NULL),(774,NULL,'Verrekening snijbloemenvo',1,0,NULL,NULL,'V23',NULL),(775,NULL,'Gereserveerd Aalsmeer',1,0,NULL,NULL,'V24',NULL),(776,NULL,'Gereserveerd Aalsmeer',1,0,NULL,NULL,'V25',NULL),(777,NULL,'Gereserveerd Aalsmeer',1,0,NULL,NULL,'V26',NULL),(778,NULL,'Gereserveerd Aalsmeer',1,0,NULL,NULL,'V27',NULL),(779,NULL,'Gereserveerd Aalsmeer',1,0,NULL,NULL,'V28',NULL),(780,NULL,'Gereserveerd Aalsmeer',1,0,NULL,NULL,'V29',NULL),(781,NULL,'Gereserveerd Aalsmeer',1,0,NULL,NULL,'V30',NULL),(782,NULL,'Gereserveerd Aalsmeer',1,0,NULL,NULL,'V31',NULL),(783,NULL,'Gereserveerd Aalsmeer',1,0,NULL,NULL,'V32',NULL),(784,NULL,'Gereserveerd Aalsmeer',1,0,NULL,NULL,'V33',NULL),(785,NULL,'Gereserveerd Aalsmeer',1,0,NULL,NULL,'V34',NULL),(786,NULL,'Gereserveerd Aalsmeer',1,0,NULL,NULL,'V35',NULL),(787,NULL,'Gereserveerd Aalsmeer',1,0,NULL,NULL,'V36',NULL),(788,NULL,'Gereserveerd Aalsmeer',1,0,NULL,NULL,'V37',NULL),(789,NULL,'Gereserveerd Aalsmeer',1,0,NULL,NULL,'V38',NULL),(790,NULL,'Gereserveerd Aalsmeer',1,0,NULL,NULL,'V39',NULL),(791,NULL,'Gereserveerd',1,0,NULL,NULL,'V40',NULL),(792,NULL,'Tussenopslag klok Plantio',1,0,NULL,NULL,'V41',NULL),(793,NULL,'Soort ladingsdrager Plant',1,0,NULL,NULL,'V42',NULL),(794,NULL,'Logistiek middel Plantion',1,0,NULL,NULL,'V43',NULL),(795,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V44',NULL),(796,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V45',NULL),(797,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V46',NULL),(798,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V47',NULL),(799,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V48',NULL),(800,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V49',NULL),(801,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V50',NULL),(802,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V51',NULL),(803,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V52',NULL),(804,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V53',NULL),(805,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V54',NULL),(806,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V55',NULL),(807,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V56',NULL),(808,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V57',NULL),(809,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V58',NULL),(810,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V59',NULL),(811,NULL,'Gereserveerd',1,0,NULL,NULL,'V60',NULL),(812,NULL,'Veilgroep Plantion Ede',1,0,NULL,NULL,'V61',NULL),(813,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V62',NULL),(814,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V63',NULL),(815,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V64',NULL),(816,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V65',NULL),(817,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V66',NULL),(818,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V67',NULL),(819,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V68',NULL),(820,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V69',NULL),(821,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V70',NULL),(822,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V71',NULL),(823,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V72',NULL),(824,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V73',NULL),(825,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V74',NULL),(826,NULL,'Gereserveerd Plantion Ede',1,0,NULL,NULL,'V75',NULL),(827,NULL,'Gereserveerd Holambra',1,0,NULL,NULL,'V76',NULL),(828,NULL,'Gereserveerd Holambra',1,0,NULL,NULL,'V77',NULL),(829,NULL,'Gereserveerd Holambra',1,0,NULL,NULL,'V78',NULL),(830,NULL,'Gereserveerd Holambra',1,0,NULL,NULL,'V79',NULL),(831,NULL,'Toegevoegde waardes VRM',1,0,NULL,NULL,'V80',NULL),(832,NULL,'Gereserveerd VRM',1,0,NULL,NULL,'V81',NULL),(833,NULL,'Gereserveerd VRM',1,0,NULL,NULL,'V82',NULL),(834,NULL,'Gereserveerd VRM',1,0,NULL,NULL,'V83',NULL),(835,NULL,'Gereserveerd VRM',1,0,NULL,NULL,'V84',NULL),(836,NULL,'Gereserveerd VRM',1,0,NULL,NULL,'V85',NULL),(837,NULL,'Gereserveerd VRM',1,0,NULL,NULL,'V86',NULL),(838,NULL,'Gereserveerd VRM',1,0,NULL,NULL,'V87',NULL),(839,NULL,'Gereserveerd VRM',1,0,NULL,NULL,'V88',NULL),(840,NULL,'Gereserveerd VRM',1,0,NULL,NULL,'V89',NULL),(841,NULL,'Veiling',1,0,NULL,NULL,'V99',NULL),(842,NULL,'kopersaantallen',1,0,NULL,NULL,'Z01',NULL); /*!40000 ALTER TABLE `tag` ENABLE KEYS */; UNLOCK TABLES; @@ -287,7 +287,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),(2,'Libre',2,0,'FREE',NULL,2,1,0,0,0,1,0,4),(3,'OK',3,0,'OK',3,28,1,0,0,0,1,1,3),(4,'Impreso',4,1,'PRINTED',2,29,1,0,1,0,0,0,2),(5,'Preparación',5,1,'ON_PREPARATION',7,5,0,0,0,2,0,0,2),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3,0,0,1),(7,'Sin Acabar',1,0,'NOT_READY',NULL,7,0,0,0,0,1,0,4),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3,0,0,1),(9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0,0,0,0),(10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0,0,0,0),(11,'Facturado',0,0,'INVOICED',NULL,11,0,1,0,0,0,0,0),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0,0,0,4),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0,0,0,0),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2,0,0,1),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0,0,0),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0,0,0,0),(17,'Eliminado',14,3,'ERASED',NULL,17,0,0,0,0,0,0,0),(20,'Asignado',4,1,'PICKER_DESIGNED',NULL,20,1,0,0,0,0,0,2),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0,0,0,2),(22,'¿Fecha?',2,0,'WRONG_DATE',NULL,22,0,0,0,0,0,0,4),(23,'URGENTE',2,0,'LAST_CALL',NULL,23,1,0,0,0,0,0,4),(24,'Encadenado',4,0,'CHAINED',4,24,0,0,0,0,0,0,3),(25,'Embarcando',3,0,'BOARDING',5,25,1,0,0,0,1,0,3),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,26,0,0,0,1,0,0,2),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0,0,0,2),(28,'Previa OK',3,1,'OK PREVIOUS',3,28,1,0,0,1,1,1,3),(29,'Previa Impreso',4,1,'PRINTED PREVIOUS',2,29,1,0,1,1,0,0,3),(30,'Embarcado',4,0,'BOARD',5,30,0,0,0,2,0,0,3),(31,'Polizon Impreso',4,1,'PRINTED STOWAWAY',2,29,1,0,1,0,0,0,3),(32,'Polizon OK',3,1,'OK STOWAWAY',3,31,1,0,0,1,1,1,3),(33,'Auto_Impreso',4,1,'PRINTED_AUTO',2,29,1,0,1,0,0,0,2); +INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0,0,0,0,0,4),(2,'Libre',2,0,'FREE',NULL,2,1,0,0,0,1,0,4),(3,'OK',3,0,'OK',3,28,1,0,0,0,1,1,3),(4,'Impreso',4,1,'PRINTED',2,29,1,0,1,0,0,0,2),(5,'Preparación',5,1,'ON_PREPARATION',7,5,0,0,0,2,0,0,2),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3,0,0,1),(7,'Sin Acabar',1,0,'NOT_READY',NULL,7,0,0,0,0,1,0,4),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3,0,0,1),(9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0,0,0,0),(10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0,0,0,0),(11,'Facturado',0,0,'INVOICED',NULL,11,0,1,0,0,0,0,0),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0,0,0,4),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0,0,0,0),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2,0,0,1),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0,0,0),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0,0,0,0),(20,'Asignado',4,1,'PICKER_DESIGNED',NULL,20,1,0,0,0,0,0,2),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0,0,0,2),(22,'¿Fecha?',2,0,'WRONG_DATE',NULL,22,0,0,0,0,0,0,4),(23,'URGENTE',2,0,'LAST_CALL',NULL,23,1,0,0,0,0,0,4),(24,'Encadenado',4,0,'CHAINED',4,24,0,0,0,0,0,0,3),(25,'Embarcando',3,0,'BOARDING',5,25,1,0,0,0,1,0,3),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,26,0,0,0,1,0,0,2),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0,0,0,2),(28,'Previa OK',3,1,'OK PREVIOUS',3,28,1,0,0,1,1,1,3),(29,'Previa Impreso',4,1,'PRINTED PREVIOUS',2,29,1,0,1,1,0,0,3),(30,'Embarcado',4,0,'BOARD',5,30,0,0,0,2,0,0,3),(31,'Polizon Impreso',4,1,'PRINTED STOWAWAY',2,29,1,0,1,0,0,0,3),(32,'Polizon OK',3,1,'OK STOWAWAY',3,31,1,0,0,1,1,1,3),(33,'Auto_Impreso',4,1,'PRINTED_AUTO',2,29,1,0,1,0,0,0,2); /*!40000 ALTER TABLE `state` ENABLE KEYS */; UNLOCK TABLES; @@ -307,7 +307,7 @@ UNLOCK TABLES; LOCK TABLES `department` WRITE; /*!40000 ALTER TABLE `department` DISABLE KEYS */; -INSERT INTO `department` VALUES (1,'VERDNATURA',1,2,763,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(22,'COMPRAS',3,4,NULL,72,596,2,5,0,0,0,0,NULL,'/',NULL),(23,'CAMARA',14,19,NULL,72,604,2,6,1,0,1,2,37,'/37/',NULL),(31,'INFORMATICA',5,6,NULL,72,127,3,9,0,0,0,0,NULL,'/','informatica'),(34,'CONTABILIDAD',7,8,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(35,'FINANZAS',9,10,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(36,'LABORAL',11,12,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(37,'PRODUCCION',13,52,NULL,72,230,3,11,1,0,0,17,NULL,'/',NULL),(38,'SACADO',20,21,NULL,72,230,4,14,1,0,1,0,37,'/37/',NULL),(39,'ENCAJADO',22,23,NULL,72,230,4,12,1,0,1,0,37,'/37/',NULL),(41,'ADMINISTRACION',53,54,NULL,72,599,3,8,0,0,0,0,NULL,'/',NULL),(43,'VENTAS',55,78,NULL,0,NULL,NULL,NULL,0,0,0,11,NULL,'/',NULL),(44,'GERENCIA',79,80,NULL,72,300,2,7,0,0,0,0,NULL,'/',NULL),(45,'LOGISTICA',81,82,NULL,72,596,3,19,0,0,0,0,NULL,'/',NULL),(46,'REPARTO',83,86,NULL,72,659,3,10,0,0,0,1,NULL,'/',NULL),(48,'ALMACENAJE',87,88,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL),(49,'PROPIEDAD',89,90,NULL,72,1008,1,1,0,0,0,0,NULL,'/',NULL),(52,'CARGA AEREA',91,92,NULL,72,163,4,28,0,0,0,0,NULL,'/',NULL),(53,'MARKETING Y COMUNICACIÓN',93,94,NULL,72,1238,0,0,0,0,0,0,NULL,'/',NULL),(54,'ORNAMENTALES',95,96,NULL,72,433,3,21,0,0,0,0,NULL,'/',NULL),(55,'TALLER NATURAL',97,98,NULL,72,695,2,23,0,0,0,0,NULL,'/',NULL),(56,'TALLER ARTIFICIAL',99,100,NULL,72,1780,2,24,0,0,0,0,NULL,'/',NULL),(58,'CAMPOS',101,102,NULL,72,225,2,2,0,0,0,0,NULL,'/',NULL),(59,'MANTENIMIENTO',103,104,NULL,72,1907,4,16,0,0,0,0,NULL,'/',NULL),(60,'RECLAMACIONES',105,106,NULL,72,563,3,20,0,0,0,0,NULL,'/',NULL),(61,'VNH',107,108,NULL,73,1297,3,17,0,0,0,0,NULL,'/',NULL),(63,'VENTAS FRANCIA',56,57,NULL,72,277,2,27,0,0,1,0,43,'/43/',NULL),(66,'VERDNAMADRID',109,110,NULL,72,163,3,18,0,0,0,0,NULL,'/',NULL),(68,'COMPLEMENTOS',24,25,NULL,72,617,3,26,1,0,1,0,37,'/37/',NULL),(69,'VERDNABARNA',111,112,NULL,74,432,3,22,0,0,0,0,NULL,'/',NULL),(77,'PALETIZADO',84,85,NULL,72,230,4,15,1,0,1,0,46,'/46/',NULL),(80,'EQUIPO J VALLES',58,59,NULL,72,693,3,4,0,0,1,0,43,'/43/','jvp_equipo'),(86,'LIMPIEZA',113,114,NULL,72,599,0,0,0,0,0,0,NULL,'/',NULL),(89,'COORDINACION',115,116,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL),(90,'TRAILER',117,118,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(91,'ARTIFICIAL',26,27,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(92,'EQUIPO SILVERIO',60,61,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','sdc_equipo'),(93,'CONFECCION',119,120,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(94,'EQUIPO J BROCAL',62,63,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jes_equipo'),(95,'EQUIPO C ZAMBRANO',64,65,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','czg_equipo'),(96,'EQUIPO C LOPEZ',66,67,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','cla_equipo'),(97,'EQUIPO D SARRION',68,69,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','dsr_equipo'),(98,'EQUIPO RODRIGO',70,71,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','rhr_equipo'),(99,'EQUIPO MANOLI',72,73,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','man_equipo'),(101,'EQUIPO J IBAÑEZ',74,75,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jmi_equipo'),(102,'EQ ROJO FV RUBEN C',28,29,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(103,'EQ AZUL FV A FOLQUES',30,31,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(104,'EQ AMARILLO FV NORMAN G',32,33,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(105,'EQ MORADO FV MATOU',34,35,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(106,'EQ VERDE PCA KEVIN GIMENEZ',36,37,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(107,'EQ NARANJA PCA RUBEN ZANON',38,39,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(110,'EQ ROSA PCA J BONDIA',40,41,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(111,'EQ REPONEDOR CAJAS',42,43,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(112,'CAMARA EQ EDGAR LLEO',15,16,NULL,0,NULL,NULL,NULL,1,0,2,0,23,'/37/23/',NULL),(113,'CAMARA EQ MARC ROCA',17,18,NULL,0,NULL,NULL,NULL,1,0,2,0,23,'/37/23/',NULL),(114,'EQ MARRON PCA JL NUEVO',44,45,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(115,'EQUIPO CLAUDI',76,77,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','csr_equipo'),(120,'PCA PRODUCCION',46,47,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(121,'FV PRODUCCION',48,49,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(122,'PCA ALMACEN',50,51,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL); +INSERT INTO `department` VALUES (1,'VERDNATURA',1,2,763,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0),(22,'COMPRAS',3,4,NULL,72,596,2,5,0,0,0,0,NULL,'/',NULL,1),(23,'CAMARA',14,19,NULL,72,604,2,6,1,0,1,2,37,'/37/',NULL,0),(31,'INFORMATICA',5,6,NULL,72,127,3,9,0,0,0,0,NULL,'/','informatica',1),(34,'CONTABILIDAD',7,8,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1),(35,'FINANZAS',9,10,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1),(36,'LABORAL',11,12,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1),(37,'PRODUCCION',13,52,NULL,72,230,3,11,1,0,0,17,NULL,'/',NULL,0),(38,'SACADO',20,21,NULL,72,230,4,14,1,0,1,0,37,'/37/',NULL,0),(39,'ENCAJADO',22,23,NULL,72,230,4,12,1,0,1,0,37,'/37/',NULL,0),(41,'ADMINISTRACION',53,54,NULL,72,599,3,8,0,0,0,0,NULL,'/',NULL,1),(43,'VENTAS',55,80,NULL,0,NULL,NULL,NULL,0,0,0,12,NULL,'/',NULL,1),(44,'GERENCIA',81,82,NULL,72,300,2,7,0,0,0,0,NULL,'/',NULL,0),(45,'LOGISTICA',83,84,NULL,72,596,3,19,0,0,0,0,NULL,'/',NULL,1),(46,'REPARTO',85,88,NULL,72,659,3,10,0,0,0,1,NULL,'/',NULL,0),(48,'ALMACENAJE',89,90,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL,0),(49,'PROPIEDAD',91,92,NULL,72,1008,1,1,0,0,0,0,NULL,'/',NULL,0),(52,'CARGA AEREA',93,94,NULL,72,163,4,28,0,0,0,0,NULL,'/',NULL,0),(53,'MARKETING Y COMUNICACIÓN',95,96,NULL,72,1238,0,0,0,0,0,0,NULL,'/',NULL,1),(54,'ORNAMENTALES',97,98,NULL,72,433,3,21,0,0,0,0,NULL,'/',NULL,0),(55,'TALLER NATURAL',99,100,NULL,72,695,2,23,0,0,0,0,NULL,'/',NULL,0),(56,'TALLER ARTIFICIAL',101,102,NULL,72,1780,2,24,0,0,0,0,NULL,'/',NULL,0),(58,'CAMPOS',103,104,NULL,72,225,2,2,0,0,0,0,NULL,'/',NULL,0),(59,'MANTENIMIENTO',105,106,NULL,72,1907,4,16,0,0,0,0,NULL,'/',NULL,0),(60,'RECLAMACIONES',107,108,NULL,72,563,3,20,0,0,0,0,NULL,'/',NULL,1),(61,'VNH',109,110,NULL,73,1297,3,17,0,0,0,0,NULL,'/',NULL,0),(63,'VENTAS FRANCIA',56,57,NULL,72,277,2,27,0,0,1,0,43,'/43/',NULL,0),(66,'VERDNAMADRID',111,112,NULL,72,163,3,18,0,0,0,0,NULL,'/',NULL,0),(68,'COMPLEMENTOS',24,25,NULL,72,617,3,26,1,0,1,0,37,'/37/',NULL,0),(69,'VERDNABARNA',113,114,NULL,74,432,3,22,0,0,0,0,NULL,'/',NULL,0),(77,'PALETIZADO',86,87,NULL,72,230,4,15,1,0,1,0,46,'/46/',NULL,0),(80,'EQUIPO J VALLES',58,59,NULL,72,693,3,4,0,0,1,0,43,'/43/','jvp_equipo',1),(86,'LIMPIEZA',115,116,NULL,72,599,0,0,0,0,0,0,NULL,'/',NULL,0),(89,'COORDINACION',117,118,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL,0),(90,'TRAILER',119,120,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0),(91,'ARTIFICIAL',26,27,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0),(92,'EQUIPO SILVERIO',60,61,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','sdc_equipo',1),(93,'CONFECCION',121,122,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0),(94,'EQUIPO J BROCAL',62,63,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jes_equipo',1),(95,'EQUIPO C ZAMBRANO',64,65,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','czg_equipo',1),(96,'EQUIPO C LOPEZ',66,67,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','cla_equipo',1),(97,'EQUIPO D SARRION',68,69,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/',NULL,1),(98,'EQUIPO RODRIGO',70,71,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','rhr_equipo',1),(99,'EQUIPO MANOLI',72,73,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/',NULL,1),(101,'EQUIPO J IBAÑEZ',74,75,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jmi_equipo',1),(102,'EQ ROJO FV RUBEN C',28,29,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0),(103,'EQ AZUL FV A FOLQUES',30,31,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0),(104,'EQ AMARILLO FV NORMAN G',32,33,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0),(105,'EQ MORADO FV MATOU',34,35,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0),(106,'EQ VERDE PCA KEVIN GIMENEZ',36,37,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0),(107,'EQ NARANJA PCA RUBEN ZANON',38,39,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0),(110,'EQ ROSA PCA J BONDIA',40,41,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0),(111,'EQ REPONEDOR CAJAS',42,43,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0),(112,'CAMARA EQ EDGAR LLEO',15,16,NULL,0,NULL,NULL,NULL,1,0,2,0,23,'/37/23/',NULL,0),(113,'CAMARA EQ MARC ROCA',17,18,NULL,0,NULL,NULL,NULL,1,0,2,0,23,'/37/23/',NULL,0),(114,'EQ MARRON PCA JL NUEVO',44,45,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0),(115,'EQUIPO CLAUDI',76,77,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','csr_equipo',1),(120,'PCA PRODUCCION',46,47,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0),(121,'FV PRODUCCION',48,49,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0),(122,'PCA ALMACEN',50,51,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0),(123,'EQUIPO ELENA BASCUÑANA',78,79,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','ebt_equipo',0); /*!40000 ALTER TABLE `department` ENABLE KEYS */; UNLOCK TABLES; @@ -340,7 +340,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-23 8:08:02 +-- Dump completed on 2020-08-11 11:51:01 USE `cache`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -378,7 +378,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-23 8:08:02 +-- Dump completed on 2020-08-11 11:51:01 USE `hedera`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -436,7 +436,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-23 8:08:03 +-- Dump completed on 2020-08-11 11:51:03 USE `postgresql`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -511,7 +511,7 @@ UNLOCK TABLES; LOCK TABLES `workcenter` WRITE; /*!40000 ALTER TABLE `workcenter` DISABLE KEYS */; -INSERT INTO `workcenter` VALUES (1,'Silla',20,1037,1,'Av espioca 100',552703),(2,'Mercaflor',19,NULL,NULL,NULL,NULL),(3,'Marjales',26,20008,NULL,NULL,NULL),(4,'VNH',NULL,NULL,3,NULL,NULL),(5,'Madrid',28,2852,5,'Av constitución 3',554145),(6,'Vilassar',88,88031,2,'Cami del Crist, 33',556412),(7,'Tenerife',NULL,NULL,10,NULL,NULL); +INSERT INTO `workcenter` VALUES (1,'Silla',20,1040,1,'Av espioca 100',552703),(2,'Mercaflor',19,NULL,NULL,NULL,NULL),(3,'Marjales',26,20008,NULL,NULL,NULL),(4,'VNH',NULL,NULL,3,NULL,NULL),(5,'Madrid',28,2852,5,'Av constitución 3',554145),(6,'Vilassar',88,88031,2,'Cami del Crist, 33',556412),(7,'Tenerife',NULL,NULL,10,NULL,NULL); /*!40000 ALTER TABLE `workcenter` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -524,4 +524,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-23 8:08:05 +-- Dump completed on 2020-08-11 11:51:04 diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 8cf0a6fb0..e46a7ecee 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -88,13 +88,18 @@ INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, (19,'Francia', 1, 'FR', 1, 27), (30,'Canarias', 1, 'IC', 1, 24); -INSERT INTO `vn`.`warehouse`(`id`, `name`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasStowaway`, `hasDms`, `hasComission`) +INSERT INTO `vn`.`warehouseAlias`(`id`, `name`) VALUES - (1, 'Warehouse One', 1, 1, 1, 1, 1, 1, 1), - (2, 'Warehouse Two', 1, 1, 1, 1, 0, 0, 1), - (3, 'Warehouse Three', 1, 1, 1, 1, 0, 0, 0), - (4, 'Warehouse Four', 1, 1, 1, 1, 0, 0, 0), - (5, 'Warehouse Five', 1, 1, 1, 1, 0, 0, 0); + (1, 'Main Warehouse'), + (2, 'Silla'); + +INSERT INTO `vn`.`warehouse`(`id`, `name`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasStowaway`, `hasDms`, `hasComission`, `aliasFk`) + VALUES + (1, 'Warehouse One', 1, 1, 1, 1, 1, 1, 1, 2), + (2, 'Warehouse Two', 1, 1, 1, 1, 0, 0, 1, 2), + (3, 'Warehouse Three', 1, 1, 1, 1, 0, 0, 0, 2), + (4, 'Warehouse Four', 1, 1, 1, 1, 0, 0, 0, 2), + (5, 'Warehouse Five', 1, 1, 1, 1, 0, 0, 0, 2); INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`, `pickingPlacement`, `path`) VALUES @@ -111,10 +116,6 @@ INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `park ('GVC', '1', '0', '1', '0', '106'), ('HEJ', '2', '0', '1', '0', '106'); -INSERT INTO `vn`.`warehouseAlias`(`id`, `name`) - VALUES - (1, 'Main Warehouse'); - INSERT INTO `vn`.`accountingType`(`id`, `description`) VALUES (1, 'Digital money'), @@ -510,7 +511,23 @@ INSERT INTO `vn`.`zoneWarehouse` (`id`, `zoneFk`, `warehouseFk`) (11, 11, 5), (12, 12, 4), (13, 13, 5); - + +INSERT INTO `vn`.`zoneClosure` (`zoneFk`, `dated`, `hour`) + VALUES + (1, CURDATE(), '23:59'), + (2, CURDATE(), '23:59'), + (3, CURDATE(), '23:59'), + (4, CURDATE(), '23:59'), + (5, CURDATE(), '23:59'), + (6, CURDATE(), '23:59'), + (7, CURDATE(), '23:59'), + (8, CURDATE(), '23:59'), + (9, CURDATE(), '23:59'), + (10, CURDATE(), '23:59'), + (11, CURDATE(), '23:59'), + (12, CURDATE(), '23:59'), + (13, CURDATE(), '23:59'); + INSERT INTO `vn`.`zoneConfig` (`scope`) VALUES ('1'); INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agencyModeFk`, `description`, `m3`, `cost`, `started`, `finished`, `zoneFk`) @@ -549,6 +566,32 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF (22, NULL, 5, 5, 5, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 'Somewhere in Japan', 103, NULL, 0, 13, 5, 1, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), (23, NULL, 8, 1, 7, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 101, 'address 21', 121, NULL, 0, 5, 5, 1, CURDATE()), (24 ,NULL, 8, 1, 7, CURDATE(), CURDATE(), 101, 'Bruce Wayne', 1, NULL, 0, 5, 5, 1, CURDATE()); +INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `created`) + VALUES + (1 , 3, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 101, 'Bat cave', 121, 'T1111111', 0, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), + (2 , 1, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 104, 'Stark tower', 124, 'T1111111', 0, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), + (3 , 1, 7, 1, 6, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 104, 'Stark tower', 124, 'T2222222', 0, 3, DATE_ADD(CURDATE(), INTERVAL -2 MONTH)), + (4 , 3, 2, 1, 2, DATE_ADD(CURDATE(), INTERVAL -3 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 104, 'Stark tower', 124, 'T3333333', 0, 9, DATE_ADD(CURDATE(), INTERVAL -3 MONTH)), + (5 , 3, 3, 3, 3, DATE_ADD(CURDATE(), INTERVAL -4 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 104, 'Stark tower', 124, 'T4444444', 0, 10, DATE_ADD(CURDATE(), INTERVAL -4 MONTH)), + (6 , 1, 3, 3, 3, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 101, 'Mountain Drive Gotham', 1, 'A1111111', 0, 10, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), + (7 , NULL, 7, 1, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 101, 'Mountain Drive Gotham', 1, NULL, 0, 3, CURDATE()), + (8 , NULL, 7, 1, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 101, 'Bat cave', 121, NULL, 0, 3, CURDATE()), + (9 , NULL, 7, 1, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 104, 'Stark tower', 124, NULL, 0, 3, CURDATE()), + (10, 1, 1, 5, 1, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 102, 'Ingram Street', 2, NULL, 0, 1, CURDATE()), + (11, 1, 7, 1, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 102, 'NY roofs', 122, NULL, 0, 3, CURDATE()), + (12, 1, 1, 1, 1, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 103, 'Phone Box', 123, NULL, 0, 1, CURDATE()), + (13, 1, 7, 1, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 103, 'Phone Box', 123, NULL, 0, 3, CURDATE()), + (14, 1, 2, 1, NULL, CURDATE(), CURDATE(), 104, 'Malibu Point', 4, NULL, 0, 9, CURDATE()), + (15, 1, 7, 1, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 105, 'An incredibly long alias for testing purposes', 125, NULL, 0, 3, CURDATE()), + (16, 1, 7, 1, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 106, 'Many Places', 126, NULL, 0, 3, CURDATE()), + (17, 1, 7, 2, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 106, 'Many Places', 126, NULL, 0, 3, CURDATE()), + (18, 1, 4, 4, 4, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 108, 'Cerebro', 128, NULL, 0, 12, CURDATE()), + (19, 1, 5, 5, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 109, 'Somewhere in Thailand', 129, NULL, 1, 13, CURDATE()), + (20, 1, 5, 5, 3, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 'Somewhere in Thailand', 129, NULL, 0, 13, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), + (21, NULL, 5, 5, 5, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 'Somewhere in Holland', 102, NULL, 0, 13, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), + (22, NULL, 5, 5, 5, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 'Somewhere in Japan', 103, NULL, 0, 13, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), + (23, NULL, 8, 1, 7, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 101, 'address 21', 121, NULL, 0, 5, CURDATE()), + (24 ,NULL, 8, 1, 7, CURDATE(), CURDATE(), 101, 'Bruce Wayne', 1, NULL, 0, 5, CURDATE()); INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`) VALUES @@ -588,7 +631,7 @@ INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `workerFk`, `created`) (16, 3, 19, NOW()), (17, 3, 19, NOW()), (18, 3, 19, NOW()), - (19, 17, 19, NOW()), + (19, 3, 19, NOW()), (20, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)), (21, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)), (22, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)), @@ -1186,8 +1229,8 @@ INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseO (4, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 50.00, 500, 'fourth travel', 0), (5, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 3, 2, 1, 50.00, 500, 'fifth travel', 1), (6, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 4, 2, 1, 50.00, 500, 'sixth travel', 1), - (7, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 2, 1, 50.00, 500, 'seventh travel', 1), - (8, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 2, 1, 50.00, 500, 'eight travel', 1); + (7, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 2, 1, 50.00, 500, 'seventh travel', 2), + (8, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 2, 1, 50.00, 500, 'eight travel', 1); INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `ref`,`isInventory`, `isRaid`, `notes`, `evaNotes`) VALUES @@ -1238,30 +1281,30 @@ INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`package (14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 7.30, 7.00, 0.00, NULL, 0, 1, 0, 4, CURDATE()), (15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, 4, CURDATE()); -INSERT INTO `hedera`.`order`(`id`, `date_send`, `customer_id`, `delivery_method_id`, `agency_id`, `address_id`, `company_id`, `note`, `source_app`, `confirmed`, `date_make`, `first_row_stamp`, `confirm_date`) +INSERT INTO `hedera`.`order`(`id`, `date_send`, `customer_id`, `delivery_method_id`, `agency_id`, `address_id`, `company_id`, `note`, `source_app`, `confirmed`,`total`, `date_make`, `first_row_stamp`, `confirm_date`) VALUES - (1, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 101, 3, 1, 121, 442, NULL, 'TPV', 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (2, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 104, 3, 1, 124, 442, NULL, 'WEB', 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (3, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 104, 1, 2, 124, 442, NULL, 'ANDROID', 1, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), DATE_ADD(CURDATE(), INTERVAL -2 MONTH), DATE_ADD(CURDATE(), INTERVAL -2 MONTH)), - (4, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 104, 1, 2, 124, 442, NULL, 'SALIX', 1, DATE_ADD(CURDATE(), INTERVAL -3 MONTH), DATE_ADD(CURDATE(), INTERVAL -3 MONTH), DATE_ADD(CURDATE(), INTERVAL -3 MONTH)), - (5, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 104, 1, 3, 124, 442, NULL, 'SALIX', 1, DATE_ADD(CURDATE(), INTERVAL -4 MONTH), DATE_ADD(CURDATE(), INTERVAL -4 MONTH), DATE_ADD(CURDATE(), INTERVAL -4 MONTH)), - (6, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 101, 1, 3, 1, 442, NULL, 'SALIX', 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (7, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 101, 2, 7, 1, 442, NULL, 'SALIX', 0, CURDATE(), CURDATE(), CURDATE()), - (8, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 101, 2, 7, 121, 442, NULL, 'SALIX', 0, CURDATE(), CURDATE(), CURDATE()), - (9, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 104, 2, 7, 124, 442, NULL, 'SALIX', 0, CURDATE(), CURDATE(), CURDATE()), - (10, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 102, 3, 1, 2, 442, NULL, 'SALIX', 0, CURDATE(), CURDATE(), CURDATE()), - (11, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 102, 2, 7, 122, 442, NULL, 'SALIX', 0, CURDATE(), CURDATE(), CURDATE()), - (12, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 103, 3, 1, 3, 442, NULL, 'SALIX', 0, CURDATE(), CURDATE(), CURDATE()), - (13, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 103, 1, 2, 123, 442, NULL, 'SALIX', 0, CURDATE(), CURDATE(), CURDATE()), - (14, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 104, 1, 2, 4, 442, NULL, 'SALIX', 0, CURDATE(), CURDATE(), CURDATE()), - (15, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 105, 1, 3, 125, 442, NULL, 'SALIX', 0, CURDATE(), CURDATE(), CURDATE()), - (16, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 106, 2, 7, 126, 442, NULL, 'SALIX', 0, CURDATE(), CURDATE(), CURDATE()), - (17, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 107, 1, 4, 127, 442, NULL, 'SALIX', 0, CURDATE(), CURDATE(), CURDATE()), - (18, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 108, 1, 4, 128, 442, NULL, 'SALIX', 0, CURDATE(), CURDATE(), CURDATE()), - (19, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 109, 1, 5, 129, 442, NULL, 'SALIX', 0, CURDATE(), CURDATE(), CURDATE()), - (20, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 1, 5, 101, 442, NULL, 'SALIX', 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), - (21, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 1, 5, 102, 442, NULL, 'SALIX', 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), - (22, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 1, 5, 103, 442, NULL, 'SALIX', 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH)); + (1, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 101, 3, 1, 121, 442, NULL, 'TPV', 1,'155.89', DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), + (2, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 104, 3, 1, 124, 442, NULL, 'WEB', 1,'100.10', DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), + (3, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 104, 1, 2, 124, 442, NULL, 'ANDROID', 1,'107.25', DATE_ADD(CURDATE(), INTERVAL -2 MONTH), DATE_ADD(CURDATE(), INTERVAL -2 MONTH), DATE_ADD(CURDATE(), INTERVAL -2 MONTH)), + (4, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 104, 1, 2, 124, 442, NULL, 'SALIX', 1,'10.01', DATE_ADD(CURDATE(), INTERVAL -3 MONTH), DATE_ADD(CURDATE(), INTERVAL -3 MONTH), DATE_ADD(CURDATE(), INTERVAL -3 MONTH)), + (5, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 104, 1, 3, 124, 442, NULL, 'SALIX', 1,'10.01', DATE_ADD(CURDATE(), INTERVAL -4 MONTH), DATE_ADD(CURDATE(), INTERVAL -4 MONTH), DATE_ADD(CURDATE(), INTERVAL -4 MONTH)), + (6, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 101, 1, 3, 1, 442, NULL, 'SALIX', 1,'10.01', DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), + (7, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 101, 2, 7, 1, 442, NULL, 'SALIX', 0,'10.01', CURDATE(), CURDATE(), CURDATE()), + (8, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 101, 2, 7, 121, 442, NULL, 'SALIX', 0,'123.53', CURDATE(), CURDATE(), CURDATE()), + (9, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 104, 2, 7, 124, 442, NULL, 'SALIX', 0,'10.01', CURDATE(), CURDATE(), CURDATE()), + (10, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 102, 3, 1, 2, 442, NULL, 'SALIX', 0,'10.01', CURDATE(), CURDATE(), CURDATE()), + (11, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 102, 2, 7, 122, 442, NULL, 'SALIX', 0,'60.90', CURDATE(), CURDATE(), CURDATE()), + (12, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 103, 3, 1, 3, 442, NULL, 'SALIX', 0,'72.60', CURDATE(), CURDATE(), CURDATE()), + (13, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 103, 1, 2, 123, 442, NULL, 'SALIX', 0,'72.60', CURDATE(), CURDATE(), CURDATE()), + (14, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 104, 1, 2, 4, 442, NULL, 'SALIX', 0,'72.60', CURDATE(), CURDATE(), CURDATE()), + (15, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 105, 1, 3, 125, 442, NULL, 'SALIX', 0,'72.60', CURDATE(), CURDATE(), CURDATE()), + (16, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 106, 2, 7, 126, 442, NULL, 'SALIX', 0,'155.89', CURDATE(), CURDATE(), CURDATE()), + (17, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 107, 1, 4, 127, 442, NULL, 'SALIX', 0,'72.60', CURDATE(), CURDATE(), CURDATE()), + (18, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 108, 1, 4, 128, 442, NULL, 'SALIX', 0,'72.60', CURDATE(), CURDATE(), CURDATE()), + (19, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 109, 1, 5, 129, 442, NULL, 'SALIX', 0,'16.50', CURDATE(), CURDATE(), CURDATE()), + (20, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 1, 5, 101, 442, NULL, 'SALIX', 0,'21.45', DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), + (21, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 1, 5, 102, 442, NULL, 'SALIX', 0,'0.00', DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), + (22, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 1, 5, 103, 442, NULL, 'SALIX', 0,'148.50', DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH)); INSERT INTO `hedera`.`orderRow`(`id`, `orderFk`, `itemFk`, `warehouseFk`, `shipment`, `amount`, `price`, `rate`, `created`, `saleFk`) VALUES diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 95b056f3c..ce0c634ac 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -1908,11 +1908,47 @@ DROP TABLE IF EXISTS `clientNewBorn`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `clientNewBorn` ( `clientFk` int(11) NOT NULL, - `shipped` date NOT NULL, + `firstShipped` date NOT NULL COMMENT 'Primer pedido o de la relacion comercial, o después de un año de inactividad', + `lastShipped` date NOT NULL COMMENT 'último pedido del cliente', PRIMARY KEY (`clientFk`), CONSTRAINT `clientNewBorn_fk1` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Listado de clientes que se consideran nuevos a efectos de cobrar la comision adicional del comercial'; /*!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_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `bs`.`clientNewBorn_BEFORE_UPDATE` BEFORE UPDATE ON `clientNewBorn` FOR EACH ROW +BEGIN + -- Si ha pasado un año o mas + IF TIMESTAMPDIFF(YEAR,NEW.lastShipped, OLD.lastShipped) THEN + SET NEW.firstShipped = NEW.lastShipped; + 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 */ ; + +-- +-- Table structure for table `clientNewBorn__` +-- + +DROP TABLE IF EXISTS `clientNewBorn__`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `clientNewBorn__` ( + `clientFk` int(11) NOT NULL, + `shipped` date NOT NULL, + PRIMARY KEY (`clientFk`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Listado de clientes que se consideran nuevos a efectos de cobrar la comision adicional del comercial'; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `compradores` @@ -2619,14 +2655,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 = utf8 */ ;; +/*!50003 SET character_set_results = utf8 */ ;; +/*!50003 SET collation_connection = utf8_general_ci */ ;; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `nightTask_launchAll` ON SCHEDULE EVERY 1 DAY STARTS '2017-08-27 02:00:00' ON COMPLETION NOT PRESERVE ENABLE DO CALL bs.nightTask_launchAll */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `nightTask_launchAll` ON SCHEDULE EVERY 1 DAY STARTS '2020-08-05 02:45:17' ON COMPLETION NOT 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 */ ;; @@ -3051,18 +3087,23 @@ ALTER DATABASE `bs` CHARACTER SET utf8 COLLATE utf8_unicode_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!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 ;; CREATE DEFINER=`root`@`%` PROCEDURE `clean`() BEGIN DECLARE vFourYearsAgo DATETIME; + DECLARE vOneYearAgo DATETIME; SET vFourYearsAgo = TIMESTAMPADD(YEAR, -4,CURDATE()); + SET vOneYearAgo = TIMESTAMPADD(YEAR, -1,CURDATE()); + DELETE FROM bs.clientNewBorn + WHERE lastShipped < vOneYearAgo; + DELETE FROM ventas WHERE fecha < vFourYearsAgo; END ;; @@ -3120,17 +3161,17 @@ 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 `clientNewBorn_Update` */; +/*!50003 DROP PROCEDURE IF EXISTS `clientNewBorn_Update__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!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 ;; -CREATE DEFINER=`root`@`%` PROCEDURE `clientNewBorn_Update`() +CREATE DEFINER=`root`@`%` PROCEDURE `clientNewBorn_Update__`() BEGIN DECLARE fromDated DATE DEFAULT '2019-04-01'; @@ -3157,9 +3198,9 @@ 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 = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!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 ;; @@ -3253,7 +3294,7 @@ BEGIN LEFT JOIN tmp.itemTypeExcluded ite ON ite.itemTypeFk = v.tipo_id WHERE (c.Id_Trabajador = vWorker OR tr.boss = vWorker) AND ite.itemTypeFk IS NULL - AND (v.fecha BETWEEN TIMESTAMPADD(DAY, - DAY(vDate) + 1, vDate) AND TIMESTAMPADD(DAY, - 1, vDate)) + AND (v.fecha BETWEEN TIMESTAMPADD(DAY, - DAY(vDate) + 1, vDate) AND vDate) GROUP BY Id_Cliente) mes_actual ON mes_actual.Id_Cliente = c.Id_Cliente LEFT JOIN (SELECT @@ -3940,9 +3981,9 @@ 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_general_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -3961,7 +4002,7 @@ BEGIN WHERE fecha >= datSTART; INSERT INTO bs.m3 (fecha, provinceFk, warehouseFk, m3, year, month, week, day, dayName, euros) - SELECT v.fecha, a.provinceFk, t.warehouseFk, sum(i.compression * s.quantity * r.cm3) / 1000000 AS m3, + SELECT v.fecha, a.provinceFk, t.warehouseFk, sum(s.quantity * ic.cm3delivery) / 1000000 AS m3, tm.year, tm.month, tm.week, tm.day, dayname(v.fecha), sum(importe) FROM vn.ticket t JOIN vn.sale s ON s.ticketFk = t.id @@ -3969,7 +4010,7 @@ BEGIN JOIN vn.itemType it ON it.id = i.typeFk JOIN bs.ventas v ON v.Id_Movimiento = s.id -- Filtra solo por ventas "buenas" JOIN vn.time tm ON tm.dated = v.fecha - JOIN bi.rotacion r ON r.Id_Article = s.itemFk AND r.warehouse_id = t.warehouseFk + JOIN vn.itemCost ic ON ic.itemFk = s.itemFk AND ic.warehouseFk = t.warehouseFk JOIN vn.address a ON a.id = t.addressFk WHERE v.fecha BETWEEN datSTART AND datEND AND s.quantity > 0 -- evita abonos @@ -4100,16 +4141,16 @@ BEGIN * La tabla mana_spellers es una caché * */ - - UPDATE mana_spellers me - JOIN - (SELECT Id_Trabajador, FLOOR(SUM(importe)/12) as pesoCarteraMensual - FROM bs.vendedores - WHERE año * 100 + mes >= (YEAR(CURDATE()) -1) * 100 + MONTH(CURDATE()) - GROUP BY Id_Trabajador - ) lastYearSales USING(Id_Trabajador) - SET me.prices_modifier_rate = GREATEST(me.minRate,LEAST(me.maxRate,ROUND(- me.used/lastYearSales.pesoCarteraMensual,3))) ; - + + UPDATE mana_spellers me + JOIN + (SELECT Id_Trabajador, FLOOR(SUM(importe)/12) as pesoCarteraMensual + FROM bs.vendedores + WHERE año * 100 + mes >= (YEAR(CURDATE()) -1) * 100 + MONTH(CURDATE()) + GROUP BY Id_Trabajador + ) lastYearSales USING(Id_Trabajador) + SET me.prices_modifier_rate = GREATEST(me.minRate,LEAST(me.maxRate,ROUND(- me.used/lastYearSales.pesoCarteraMensual,3))) ; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -4787,6 +4828,96 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `vendedores_add`(intYEAR INT, vQuarter INT) +BEGIN + + DECLARE vCommissionRate DOUBLE DEFAULT 0.008; + + -- vaciar tabla + DELETE v.* FROM vendedores v + JOIN vn.`time` t ON t.`year` = v.año AND t.`month` = v.mes + WHERE t.`year` = intYEAR AND QUARTER(t.dated) = vQuarter; + + REPLACE vendedores(Id_Trabajador, año, mes, importe, comision) + SELECT c.Id_Trabajador + , intYEAR + , MONTH(v.fecha) intMONTH + , sum(v.importe) + , sum(v.importe) * vCommissionRate + FROM ventas v + JOIN vn2008.Clientes c on v.Id_Cliente = c.Id_Cliente + JOIN vn.`time` t on t.dated = v.fecha + WHERE c.Id_Trabajador is not null + AND t.`year` = intYEAR AND QUARTER(t.dated) = vQuarter + GROUP BY c.Id_Trabajador, t.`month`; + + -- Sustitucion cedidas - lended + INSERT INTO vendedores (Id_Trabajador, mes, año, comision) + SELECT c.salesPersonFk + , t.`month` + , t.`year` + , sum(importe) * vCommissionRate as lended + FROM ventas v + JOIN vn.client c ON c.id = v.Id_Cliente + JOIN vn.sharingCartDaily scd on scd.ownerFk = c.salesPersonFk AND scd.dated = v.fecha + JOIN vn.`time` t ON t.dated = v.fecha + WHERE t.`year` = intYEAR AND QUARTER(t.dated) = vQuarter + GROUP BY c.salesPersonFk, t.`month` + ON DUPLICATE KEY UPDATE comision = comision - VALUES(comision); + + -- Sustitucion arrendadas - borrowed + INSERT INTO vendedores (Id_Trabajador, mes, año, sustitucionArrendada) + SELECT scd.substituteFk + , t.`month` + , t.`year` + , sum(importe) * vCommissionRate as borrowed + FROM ventas v + JOIN vn.`client` c ON c.id = v.Id_Cliente + JOIN vn.sharingCartDaily scd on scd.ownerFk = c.salesPersonFk AND scd.dated = v.fecha + JOIN vn.`time` t ON t.dated = v.fecha + WHERE t.`year` = intYEAR AND QUARTER(t.dated) = vQuarter + GROUP BY scd.substituteFk, t.`month` + ON DUPLICATE KEY UPDATE sustitucionArrendada = VALUES(sustitucionArrendada); + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_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 `vendedores_add_launcher` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!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 ;; +CREATE DEFINER=`root`@`%` PROCEDURE `vendedores_add_launcher`() +BEGIN + + CALL bs.vendedores_add(YEAR(CURDATE()),QUARTER(CURDATE())); + CALL bs.vendedores_evolution_add; + CALL bs.salesPersonClient_add(YEAR(CURDATE()), QUARTER(CURDATE())); + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_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 `vendedores_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_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `vendedores_add__`(intYEAR INT, vQuarter INT) BEGIN DECLARE vCommissionRate DOUBLE DEFAULT 0.029; @@ -4823,6 +4954,7 @@ BEGIN JOIN vn2008.`time` t on t.`date` = v.fecha WHERE c.Id_Trabajador is not null AND t.`year` = intYEAR AND QUARTER(v.fecha) = vQuarter + AND cnb.firstShipped > DATE_ADD(v.fecha, INTERVAL -1 YEAR) GROUP BY c.Id_Trabajador, t.`month` ) sub ON sub.Id_Trabajador = v.Id_Trabajador AND sub.`month` = v.mes AND sub.`year` = v.año SET v.comisionNuevos = sub.comisionNueva, v.comision = v.comision - sub.comisionNueva; @@ -4928,282 +5060,6 @@ BEGIN DROP TEMPORARY TABLE tmp.workerItemType; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_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 `vendedores_add_launcher` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!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 ;; -CREATE DEFINER=`root`@`%` PROCEDURE `vendedores_add_launcher`() -BEGIN - - CALL bs.vendedores_add(YEAR(CURDATE()),QUARTER(CURDATE())); - CALL bs.vendedores_evolution_add; - CALL bs.salesPersonClient_add(YEAR(CURDATE()), QUARTER(CURDATE())); - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_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 `vendedores_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_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `vendedores_add__`(intYEAR INT, vQuarter INT) -BEGIN - - DECLARE vCommissionRate DOUBLE DEFAULT 0.029; - - -- vaciar tabla - DELETE v.* FROM vendedores v - JOIN vn.`time` t ON t.`year` = v.año AND t.`month` = v.mes - WHERE t.`year` = intYEAR AND QUARTER(t.dated) = vQuarter; - - REPLACE vendedores(Id_Trabajador, año, mes, importe, comision) - SELECT c.Id_Trabajador - , intYEAR - , MONTH(v.fecha) intMONTH - , sum(v.importe) - , sum(v.importe) * vCommissionRate - FROM ventas v - JOIN vn2008.Clientes c on v.Id_Cliente = c.Id_Cliente - JOIN vn.`time` t on t.dated = v.fecha - WHERE c.Id_Trabajador is not null - AND t.`year` = intYEAR AND QUARTER(t.dated) = vQuarter - GROUP BY c.Id_Trabajador, t.`month`; - - -- Ventas nuevas - UPDATE vendedores v - JOIN - ( - SELECT c.Id_Trabajador - , sum(importe) * vCommissionRate as comisionNueva - , t.`month` - , t.`year` - FROM ventas v - JOIN bs.clientNewBorn cnb on v.Id_Cliente = cnb.clientFk - JOIN vn2008.Clientes c ON c.Id_Cliente = v.Id_Cliente - JOIN vn2008.`time` t on t.`date` = v.fecha - WHERE c.Id_Trabajador is not null - AND t.`year` = intYEAR AND QUARTER(v.fecha) = vQuarter - GROUP BY c.Id_Trabajador, t.`month` - ) sub ON sub.Id_Trabajador = v.Id_Trabajador AND sub.`month` = v.mes AND sub.`year` = v.año - SET v.comisionNuevos = sub.comisionNueva, v.comision = v.comision - sub.comisionNueva; - - -- Ventas cedidas - UPDATE vendedores v - JOIN ( - SELECT cc.Id_Trabajador_old as Id_Trabajador - , sum(importe) * vCommissionRate * comision_old as cedido - , sum(importe) * vCommissionRate * comision_new as arrendada - , t.`month` - , t.`year` - FROM ventas v - JOIN vn2008.Clientes c on v.Id_Cliente = c.Id_Cliente - JOIN vn2008.Clientes_cedidos cc on cc.Id_Cliente = c.Id_Cliente AND v.fecha between datSTART and datEND - JOIN vn2008.`time` t on t.`date` = v.fecha - WHERE c.Id_Trabajador is not null - AND t.`year` = intYEAR AND QUARTER(v.fecha) = vQuarter - GROUP BY cc.Id_Trabajador_old, t.`month` - ) sub ON sub.Id_Trabajador = v.Id_Trabajador AND sub.`month` = v.mes AND sub.`year` = v.año - SET v.comisionCedida = sub.cedido, v.comision = v.comision - sub.cedido - sub.arrendada; - - -- Ventas arrendadas - UPDATE vendedores v - JOIN ( - SELECT cc.Id_Trabajador_new as Id_Trabajador - , sum(importe) * vCommissionRate * comision_new as arrendada - , t.`month` - , t.`year` - FROM ventas v - JOIN vn2008.Clientes c on v.Id_Cliente = c.Id_Cliente - JOIN vn2008.Clientes_cedidos cc on cc.Id_Cliente = c.Id_Cliente AND v.fecha between datSTART and datEND - JOIN vn2008.`time` t on t.`date` = v.fecha - WHERE c.Id_Trabajador is not null - AND t.`year` = intYEAR AND QUARTER(v.fecha) = vQuarter - GROUP BY cc.Id_Trabajador_new, t.`month` - ) sub ON sub.Id_Trabajador = v.Id_Trabajador AND sub.`month` = v.mes AND sub.`year` = v.año - SET v.comisionArrendada = sub.arrendada; - - -- Sustitucion cedidas - lended - INSERT INTO vendedores (Id_Trabajador, mes, año, comision) - SELECT c.salesPersonFk - , sum(importe) * vCommissionRate as lended - , t.`month` - , t.`year` - FROM ventas v - JOIN vn.client c ON c.id = v.Id_Cliente - JOIN vn.sharingCartDaily scd on scd.ownerFk = c.salesPersonFk AND scd.dated = v.fecha - JOIN vn.`time` t ON t.dated = v.fecha - WHERE t.`year` = intYEAR AND QUARTER(t.dated) = vQuarter - GROUP BY c.salesPersonFk, t.`month` - ON DUPLICATE KEY UPDATE comision = comision - VALUES(comision); - - -- Sustitucion arrendadas - borrowed - INSERT INTO vendedores (Id_Trabajador, mes, año, sustitucionArrendada) - SELECT scd.substituteFk - , sum(importe) * vCommissionRate as borrowed - , t.`month` - , t.`year` - FROM ventas v - JOIN vn.client c ON c.id = v.Id_Cliente - JOIN vn.sharingCartDaily scd on scd.ownerFk = c.salesPersonFk AND scd.dated = v.fecha - JOIN vn.`time` t ON t.dated = v.fecha - WHERE t.`year` = intYEAR AND QUARTER(t.dated) = vQuarter - GROUP BY scd.substituteFk, t.`month` - ON DUPLICATE KEY UPDATE sustitucionArrendada = sustitucionArrendada + VALUES(sustitucionArrendada); - - DROP TEMPORARY TABLE IF EXISTS tmp.workerItemType; - CREATE TEMPORARY TABLE tmp.workerItemType - (INDEX(ownerWorkerFk, itemTypeFk)) - SELECT wd.workerFk ownerWorkerFk, itemTypeFk, dit.workerFk substituteFk - FROM vn.departmentItemType dit - JOIN vn.workerDepartment wd ON wd.departmentFk = dit.departmentFk; - - -- itemType Lended, prestado - UPDATE vendedores v - JOIN ( - SELECT c.Id_Trabajador - , sum(importe) * vCommissionRate as amount - , t.`month` - , t.`year` - FROM ventas v - JOIN vn2008.Clientes c on v.Id_Cliente = c.Id_Cliente - JOIN tmp.workerItemType wit ON wit.ownerWorkerFk = c.Id_Trabajador AND wit.itemTypeFk = v.tipo_id - JOIN vn2008.`time` t on t.`date` = v.fecha - WHERE t.`year` = intYEAR AND QUARTER(v.fecha) = vQuarter - GROUP BY c.Id_Trabajador, t.`month` - ) sub ON sub.Id_Trabajador = v.Id_Trabajador AND sub.`month` = v.mes AND sub.`year` = v.año - SET v.comision = v.comision - sub.amount; - - -- itemType borrowed, tomado prestado - INSERT INTO vendedores (Id_Trabajador, año, mes, itemTypeBorrowed) - SELECT wit.substituteFk - , t.`year` - , t.`month` - , importe * vCommissionRate - FROM ventas v - JOIN vn2008.Clientes c on v.Id_Cliente = c.Id_Cliente - JOIN tmp.workerItemType wit ON wit.ownerWorkerFk = c.Id_Trabajador AND wit.itemTypeFk = v.tipo_id - JOIN vn2008.`time` t on t.`date` = v.fecha - WHERE t.`year` = intYEAR AND QUARTER(v.fecha) = vQuarter - ON DUPLICATE KEY UPDATE itemTypeBorrowed = itemTypeBorrowed + values(itemTypeBorrowed); - - DROP TEMPORARY TABLE tmp.workerItemType; - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_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 `vendedores_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_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `vendedores_add___`(intYEAR INT, vQuarter INT) -BEGIN - - DECLARE comisionRate DOUBLE DEFAULT 0.029; - - REPLACE vendedores - SELECT c.Id_Trabajador - , intYEAR - , MONTH(v.fecha) intMONTH - , sum(importe) as importe - , sum(importe) * 0.029 as comision - , 0 as comisionArrendada - , 0 as comisionCedida - , 0 as comisionNuevos - , 0 as sustitucionArrendada - , 0 as sustitucionCedida - , 0 as itemTypeLended - , 0 as itemTypeBorrowed - - FROM ventas v - JOIN vn2008.Clientes c on v.Id_Cliente = c.Id_Cliente - JOIN vn2008.`time` t on t.`date` = v.fecha - WHERE c.Id_Trabajador is not null - AND t.`year` = intYEAR AND QUARTER(v.fecha) = vQuarter - GROUP BY c.Id_Trabajador, t.`month`; - - -- Ventas nuevas - UPDATE vendedores v - JOIN - ( - SELECT c.Id_Trabajador - , sum(importe) * 0.029 as comisionNueva - , t.`month` - , t.`year` - FROM ventas v - JOIN bs.clientNewBorn cnb on v.Id_Cliente = cnb.clientFk - JOIN vn2008.Clientes c ON c.Id_Cliente = v.Id_Cliente - JOIN vn2008.`time` t on t.`date` = v.fecha - WHERE c.Id_Trabajador is not null - AND t.`year` = intYEAR AND QUARTER(v.fecha) = vQuarter - GROUP BY c.Id_Trabajador, t.`month` - ) sub ON sub.Id_Trabajador = v.Id_Trabajador AND sub.`month` = v.mes AND sub.`year` = v.año - SET v.comisionNuevos = sub.comisionNueva, v.comision = v.comision - sub.comisionNueva; - - -- Ventas cedidas - UPDATE vendedores v - JOIN ( - SELECT cc.Id_Trabajador_old as Id_Trabajador - , sum(importe) * 0.029 * comision_old as cedido - , sum(importe) * 0.029 * comision_new as arrendada - , t.`month` - , t.`year` - FROM ventas v - JOIN vn2008.Clientes c on v.Id_Cliente = c.Id_Cliente - JOIN vn2008.Clientes_cedidos cc on cc.Id_Cliente = c.Id_Cliente AND v.fecha between datSTART and datEND - JOIN vn2008.`time` t on t.`date` = v.fecha - WHERE c.Id_Trabajador is not null - AND t.`year` = intYEAR AND QUARTER(v.fecha) = vQuarter - GROUP BY cc.Id_Trabajador_old, t.`month` - ) sub ON sub.Id_Trabajador = v.Id_Trabajador AND sub.`month` = v.mes AND sub.`year` = v.año - SET v.comisionCedida = sub.cedido, v.comision = v.comision - sub.cedido - sub.arrendada; - - -- Ventas arrendadas - UPDATE vendedores v - JOIN ( - SELECT cc.Id_Trabajador_new as Id_Trabajador - , sum(importe) * 0.029 * comision_new as arrendada - , t.`month` - , t.`year` - FROM ventas v - JOIN vn2008.Clientes c on v.Id_Cliente = c.Id_Cliente - JOIN vn2008.Clientes_cedidos cc on cc.Id_Cliente = c.Id_Cliente AND v.fecha between datSTART and datEND - JOIN vn2008.`time` t on t.`date` = v.fecha - WHERE c.Id_Trabajador is not null - AND t.`year` = intYEAR AND QUARTER(v.fecha) = vQuarter - GROUP BY cc.Id_Trabajador_new, t.`month` - ) sub ON sub.Id_Trabajador = v.Id_Trabajador AND sub.`month` = v.mes AND sub.`year` = v.año - SET v.comisionArrendada = sub.arrendada; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -6222,9 +6078,9 @@ 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 = utf8 */ ;; +/*!50003 SET character_set_results = utf8 */ ;; +/*!50003 SET collation_connection = utf8_general_ci */ ;; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; @@ -6240,9 +6096,9 @@ 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 = utf8 */ ;; +/*!50003 SET character_set_results = utf8 */ ;; +/*!50003 SET collation_connection = utf8_general_ci */ ;; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; @@ -6456,9 +6312,9 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `cacheCalc_clean`() -BEGIN - DECLARE vCleanTime DATETIME DEFAULT TIMESTAMPADD(MINUTE, -5, NOW()); - DELETE FROM cache_calc WHERE expires < vCleanTime; +BEGIN + DECLARE vCleanTime DATETIME DEFAULT TIMESTAMPADD(MINUTE, -5, NOW()); + DELETE FROM cache_calc WHERE expires < vCleanTime; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -6476,27 +6332,27 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `cache_calc_end`(IN `v_calc` INT) -BEGIN - DECLARE v_cache_name VARCHAR(255); - DECLARE v_params VARCHAR(255); - - -- Libera el bloqueo y actualiza la fecha de ultimo refresco. - - UPDATE cache_calc cc JOIN cache c ON c.id = cc.cache_id - SET - cc.last_refresh = NOW(), - cc.expires = ADDTIME(NOW(), c.lifetime), - cc.connection_id = NULL - WHERE cc.id = v_calc; - - SELECT c.name, ca.params INTO v_cache_name, v_params - FROM cache c - JOIN cache_calc ca ON c.id = ca.cache_id - WHERE ca.id = v_calc; - - IF v_cache_name IS NOT NULL THEN - DO RELEASE_LOCK(CONCAT_WS('/', v_cache_name, IFNULL(v_params, ''))); - END IF; +BEGIN + DECLARE v_cache_name VARCHAR(255); + DECLARE v_params VARCHAR(255); + + -- Libera el bloqueo y actualiza la fecha de ultimo refresco. + + UPDATE cache_calc cc JOIN cache c ON c.id = cc.cache_id + SET + cc.last_refresh = NOW(), + cc.expires = ADDTIME(NOW(), c.lifetime), + cc.connection_id = NULL + WHERE cc.id = v_calc; + + SELECT c.name, ca.params INTO v_cache_name, v_params + FROM cache c + JOIN cache_calc ca ON c.id = ca.cache_id + WHERE ca.id = v_calc; + + IF v_cache_name IS NOT NULL THEN + DO RELEASE_LOCK(CONCAT_WS('/', v_cache_name, IFNULL(v_params, ''))); + END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -6514,88 +6370,88 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `cache_calc_start`(OUT `v_calc` INT, INOUT `v_refresh` INT, IN `v_cache_name` VARCHAR(50), IN `v_params` VARCHAR(100)) -proc: BEGIN - DECLARE v_valid BOOL; - DECLARE v_lock_id VARCHAR(100); - DECLARE v_cache_id INT; - DECLARE v_expires DATETIME; - DECLARE v_clean_time DATETIME; - - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - IF v_lock_id IS NOT NULL THEN - DO RELEASE_LOCK(v_lock_id); - END IF; - - RESIGNAL; - END; - - SET v_params = IFNULL(v_params, ''); - - -- Si el servidor se ha reiniciado invalida todos los calculos. - - SELECT COUNT(*) > 0 INTO v_valid FROM cache_valid; - - IF !v_valid - THEN - DELETE FROM cache_calc; - INSERT INTO cache_valid (valid) VALUES (TRUE); - END IF; - - -- Obtiene un bloqueo exclusivo para que no haya problemas de concurrencia. - - SET v_lock_id = CONCAT_WS('/', v_cache_name, v_params); - - IF !GET_LOCK(v_lock_id, 30) - THEN - SET v_calc = NULL; - SET v_refresh = FALSE; - LEAVE proc; - END IF; - - -- Comprueba si el calculo solicitado existe y esta actualizado. - - SELECT c.id, ca.id, ca.expires - INTO v_cache_id, v_calc, v_expires - FROM cache c - LEFT JOIN cache_calc ca - ON ca.cache_id = c.id AND ca.params = v_params COLLATE 'utf8_general_ci' - WHERE c.name = v_cache_name COLLATE 'utf8_general_ci'; - - -- Si existe una calculo valido libera el bloqueo y devuelve su identificador. - - IF !v_refresh AND NOW() < v_expires - THEN - DO RELEASE_LOCK(v_lock_id); - SET v_refresh = FALSE; - LEAVE proc; - END IF; - - -- Si el calculo no existe le crea una entrada en la tabla de calculos. - - IF v_calc IS NULL - THEN - INSERT INTO cache_calc SET - cache_id = v_cache_id, - cacheName = v_cache_name, - params = v_params, - last_refresh = NULL, - expires = NULL, - connection_id = CONNECTION_ID(); - - SET v_calc = LAST_INSERT_ID(); - ELSE - UPDATE cache_calc - SET - last_refresh = NULL, - expires = NULL, - connection_id = CONNECTION_ID() - WHERE id = v_calc; - END IF; - - -- Si se debe recalcular mantiene el bloqueo y devuelve su identificador. - - SET v_refresh = TRUE; +proc: BEGIN + DECLARE v_valid BOOL; + DECLARE v_lock_id VARCHAR(100); + DECLARE v_cache_id INT; + DECLARE v_expires DATETIME; + DECLARE v_clean_time DATETIME; + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + IF v_lock_id IS NOT NULL THEN + DO RELEASE_LOCK(v_lock_id); + END IF; + + RESIGNAL; + END; + + SET v_params = IFNULL(v_params, ''); + + -- Si el servidor se ha reiniciado invalida todos los calculos. + + SELECT COUNT(*) > 0 INTO v_valid FROM cache_valid; + + IF !v_valid + THEN + DELETE FROM cache_calc; + INSERT INTO cache_valid (valid) VALUES (TRUE); + END IF; + + -- Obtiene un bloqueo exclusivo para que no haya problemas de concurrencia. + + SET v_lock_id = CONCAT_WS('/', v_cache_name, v_params); + + IF !GET_LOCK(v_lock_id, 30) + THEN + SET v_calc = NULL; + SET v_refresh = FALSE; + LEAVE proc; + END IF; + + -- Comprueba si el calculo solicitado existe y esta actualizado. + + SELECT c.id, ca.id, ca.expires + INTO v_cache_id, v_calc, v_expires + FROM cache c + LEFT JOIN cache_calc ca + ON ca.cache_id = c.id AND ca.params = v_params COLLATE 'utf8_general_ci' + WHERE c.name = v_cache_name COLLATE 'utf8_general_ci'; + + -- Si existe una calculo valido libera el bloqueo y devuelve su identificador. + + IF !v_refresh AND NOW() < v_expires + THEN + DO RELEASE_LOCK(v_lock_id); + SET v_refresh = FALSE; + LEAVE proc; + END IF; + + -- Si el calculo no existe le crea una entrada en la tabla de calculos. + + IF v_calc IS NULL + THEN + INSERT INTO cache_calc SET + cache_id = v_cache_id, + cacheName = v_cache_name, + params = v_params, + last_refresh = NULL, + expires = NULL, + connection_id = CONNECTION_ID(); + + SET v_calc = LAST_INSERT_ID(); + ELSE + UPDATE cache_calc + SET + last_refresh = NULL, + expires = NULL, + connection_id = CONNECTION_ID() + WHERE id = v_calc; + END IF; + + -- Si se debe recalcular mantiene el bloqueo y devuelve su identificador. + + SET v_refresh = TRUE; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -6613,24 +6469,24 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `cache_calc_unlock`(IN `v_calc` INT) -proc: BEGIN - DECLARE v_cache_name VARCHAR(50); - DECLARE v_params VARCHAR(100); - - IF v_calc IS NULL THEN - LEAVE proc; - END IF; - - SELECT c.name, ca.params INTO v_cache_name, v_params - FROM cache c - JOIN cache_calc ca ON c.id = ca.cache_id - WHERE ca.id = v_calc; - - DELETE FROM cache_calc WHERE id = v_calc; - - IF v_cache_name IS NOT NULL THEN - DO RELEASE_LOCK(CONCAT_WS('/', v_cache_name, IFNULL(v_params, ''))); - END IF; +proc: BEGIN + DECLARE v_cache_name VARCHAR(50); + DECLARE v_params VARCHAR(100); + + IF v_calc IS NULL THEN + LEAVE proc; + END IF; + + SELECT c.name, ca.params INTO v_cache_name, v_params + FROM cache c + JOIN cache_calc ca ON c.id = ca.cache_id + WHERE ca.id = v_calc; + + DELETE FROM cache_calc WHERE id = v_calc; + + IF v_cache_name IS NOT NULL THEN + DO RELEASE_LOCK(CONCAT_WS('/', v_cache_name, IFNULL(v_params, ''))); + END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -6649,9 +6505,9 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `cache_clean`() NO SQL -BEGIN - CALL available_clean; - CALL visible_clean; +BEGIN + CALL available_clean; + CALL visible_clean; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -6669,13 +6525,13 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `clean`() -BEGIN - - DECLARE vDateShort DATETIME; - - SET vDateShort = TIMESTAMPADD(MONTH, -1, CURDATE()); - - DELETE FROM cache.departure_limit WHERE Fecha < vDateShort; +BEGIN + + DECLARE vDateShort DATETIME; + + SET vDateShort = TIMESTAMPADD(MONTH, -1, CURDATE()); + + DELETE FROM cache.departure_limit WHERE Fecha < vDateShort; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -7714,8 +7570,15 @@ CREATE TABLE `item_groupToOffer` ( `itemTypeFk` smallint(5) unsigned NOT NULL, `intrastatFk` int(8) unsigned zerofill NOT NULL, `originFk` tinyint(2) unsigned NOT NULL DEFAULT '17', - `expenseFk` varchar(10) COLLATE utf8_unicode_ci DEFAULT '6001000001', - PRIMARY KEY (`group_code`) + `expenseFk` varchar(10) COLLATE utf8_unicode_ci DEFAULT '7001000000', + PRIMARY KEY (`group_code`), + KEY `item_groupToOffer_fk2_idx` (`itemTypeFk`), + KEY `item_groupToOffer_fk3_idx` (`intrastatFk`), + KEY `item_groupToOffer_fk4_idx` (`originFk`), + CONSTRAINT `item_groupToOffer_fk1` FOREIGN KEY (`group_code`) REFERENCES `item_group` (`group_code`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `item_groupToOffer_fk2` FOREIGN KEY (`itemTypeFk`) REFERENCES `vn`.`itemType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + 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=utf8 COLLATE=utf8_unicode_ci COMMENT='se ofreceran para ser comprados'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -7794,7 +7657,7 @@ CREATE TABLE `marketPlace` ( `id` varchar(13) COLLATE utf8_unicode_ci NOT NULL, `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, `supplierFk` int(11) NOT NULL DEFAULT '1433', - `IsOffered` tinyint(2) NOT NULL DEFAULT '0', + `isOffered` tinyint(2) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -7977,6 +7840,7 @@ CREATE TABLE `supplyResponse` ( `PackingPriceQuantityType` tinyint(1) DEFAULT NULL COMMENT 'Unit: 1 = piece, 2 = bunch, 3 = box, 4 = layer, 5 = load carrier/trolley', `MarketPlaceID` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `MarketFormCode` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '"002" Standard Sales\n"005" Catalogue (optional)\n"001" Committed (optional)\n"003" Buffer (optional, Clock Pre Sales) ', + `FlowerColor` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`ID`), UNIQUE KEY `ID_UNIQUE` (`ID`), KEY `IX_TransNumber` (`TransactionNumber`) COMMENT 'Agregado por Ernesto 11.6.2019\nSe ejecutaba 1 consulta por segundo desde MAIL y consumia un 20% de CPU de todo el servidor !!!!!\nCPU usada es mas estable que Indice en SendererID, cpu vs espacio que ocupa?\n', @@ -8023,96 +7887,118 @@ CREATE TABLE `value` ( -- -- Dumping events for database 'edi' -- +/*!50106 SET @save_time_zone= @@TIME_ZONE */ ; +/*!50106 DROP EVENT IF EXISTS `floramondo` */; +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 = utf8 */ ;; +/*!50003 SET character_set_results = utf8 */ ;; +/*!50003 SET collation_connection = utf8_general_ci */ ;; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ;; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;; +/*!50003 SET @saved_time_zone = @@time_zone */ ;; +/*!50003 SET time_zone = 'SYSTEM' */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `floramondo` ON SCHEDULE EVERY 5 MINUTE STARTS '2020-07-29 01:58:29' 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 */ ;; +/*!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 'edi' -- -/*!50003 DROP FUNCTION IF EXISTS `floramondoTodayEntryGet` */; +/*!50003 DROP FUNCTION IF EXISTS `floramondoTodayEntryGet__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!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 ;; -CREATE DEFINER=`root`@`%` FUNCTION `floramondoTodayEntryGet`() RETURNS int(11) +CREATE DEFINER=`root`@`%` FUNCTION `floramondoTodayEntryGet__`() RETURNS int(11) READS SQL DATA BEGIN - DECLARE myTravel INT; - DECLARE myEntry INT; + DECLARE vTravelFk INT; + DECLARE vEntryFk INT; - SET myTravel = FloramondoTodayTravelGet(); + SET vTravelFk = FloramondoTodayTravelGet(); - SELECT IFNULL(MAX(id),0) INTO myEntry + SELECT IFNULL(MAX(id),0) INTO vEntryFk FROM vn.entry - WHERE travelFk = myTravel; + WHERE travelFk = vTravelFk; - IF NOT myEntry THEN + IF NOT vEntryFk THEN - INSERT INTO vn.entry(travelFk, supplierFk, commission, companyFk, currencyFk) - SELECT myTravel, s.id, 4, c.id, cu.id + INSERT INTO vn.entry(travelFk, supplierFk, commission, companyFk, currencyFk, isRaid) + SELECT vTravelFk, s.id, 4, c.id, cu.id, TRUE FROM vn.supplier s JOIN vn.company c ON c.code = 'VNL' JOIN vn.currency cu ON cu.code = 'EUR' WHERE s.name = 'KONINKLIJE COOPERATIEVE BLOEMENVEILING FLORAHOLLAN'; - SELECT IFNULL(MAX(id),0) INTO myEntry + SELECT IFNULL(MAX(id),0) INTO vEntryFk FROM vn.entry - WHERE travelFk = myTravel; + WHERE travelFk = vTravelFk; END IF; - RETURN myEntry; + RETURN vEntryFk; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_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 `floramondoTodayTravelGet` */; +/*!50003 DROP FUNCTION IF EXISTS `floramondoTodayTravelGet__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!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 ;; -CREATE DEFINER=`root`@`%` FUNCTION `floramondoTodayTravelGet`() RETURNS int(11) +CREATE DEFINER=`root`@`%` FUNCTION `floramondoTodayTravelGet__`() RETURNS int(11) READS SQL DATA BEGIN DECLARE myTravel INT; - + DECLARE vWarehouseOutName VARCHAR(50) DEFAULT 'Holanda'; + DECLARE vWarehouseInName VARCHAR(50) DEFAULT 'VNH'; +-- recuperar hora del delivery SELECT IFNULL(MAX(tr.id),0) INTO myTravel FROM vn.travel tr JOIN vn.warehouse wIn ON wIn.id = tr.warehouseInFk JOIN vn.warehouse wOut ON wOut.id = tr.warehouseOutFk - WHERE wIn.name = 'VNH' - AND wOut.name = 'Floramondo' - AND landed = CURDATE(); + WHERE wIn.name = vWarehouseInName + AND wOut.name = vWarehouseOutName + AND landed = util.tomorrow(); IF NOT myTravel THEN INSERT INTO vn.travel(landed, shipped, warehouseInFk, warehouseOutFk, agencyFk) - SELECT CURDATE(), util.yesterday(), wIn.id, wOut.id, am.id + SELECT util.tomorrow(), curdate(), wIn.id, wOut.id, am.id FROM vn.warehouse wIn - JOIN vn.warehouse wOut ON wOut.name = 'Floramondo' + JOIN vn.warehouse wOut ON wOut.name = vWarehouseOutName JOIN vn.agencyMode am ON am.name = 'HOLANDA DIRECTO' - WHERE wIn.name = 'VNH'; + WHERE wIn.name = vWarehouseInName; SELECT MAX(tr.id) INTO myTravel FROM vn.travel tr JOIN vn.warehouse wIn ON wIn.id = tr.warehouseInFk JOIN vn.warehouse wOut ON wOut.id = tr.warehouseOutFk - WHERE wIn.name = 'VNH' - AND wOut.name = 'Floramondo' - AND landed = CURDATE(); - + WHERE wIn.name = vWarehouseInName + AND wOut.name = vWarehouseOutName + AND landed = util.tomorrow(); END IF; RETURN myTravel; @@ -8127,21 +8013,24 @@ 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 = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!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 ;; CREATE DEFINER=`root`@`%` PROCEDURE `clean`() BEGIN - DELETE di.* - FROM edi.deliveryInformation di - -- LEFT JOIN vn.buy b ON b.deliveryFk = di.ID - WHERE LatestOrderDateTime < CURDATE() - -- AND b.id IS NULL - ; + DECLARE vFourYearsAgo DATE DEFAULT TIMESTAMPADD(YEAR,-4,CURDATE()); + DECLARE vOneWeekAgo DATE DEFAULT TIMESTAMPADD(WEEK,-1,CURDATE()); + + DELETE FROM ekt WHERE fec < vFourYearsAgo; + + DELETE IGNORE sr.* + FROM supplyResponse sr + LEFT JOIN edi.deliveryInformation di ON sr.ID = di.supplyResponseID + WHERE di.LatestOrderDateTime < vOneWeekAgo OR di.ID IS NULL; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -8152,13 +8041,195 @@ 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 = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!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 ;; CREATE DEFINER=`root`@`%` PROCEDURE `ekt_load`(IN `vSelf` INT) +BEGIN + DECLARE vRef INT; + DECLARE vBuy INT; + DECLARE vItem INT; + DECLARE vQty INT; + DECLARE vPackage INT; + DECLARE vPutOrderFk INT; + DECLARE vIsLot BOOLEAN; + DECLARE vForceToPacking INT DEFAULT 2; + + -- Carga los datos necesarios del EKT + + SELECT ref, qty, package, putOrderFk INTO vRef, vQty, vPackage, vPutOrderFk + FROM ekt e + LEFT JOIN item i ON e.ref = i.id + WHERE e.id = vSelf; + + -- Inserta el cubo si no existe + + IF vPackage = 800 + THEN + SET vPackage = 800 + vQty; + + INSERT IGNORE INTO vn2008.Cubos SET + Id_Cubo = vPackage, + x = 7200 / vQty, + y = 1; + ELSE + INSERT IGNORE INTO vn2008.Cubos (Id_Cubo, X, Y, Z) + SELECT bucket_id, ROUND(x_size/10), ROUND(y_size/10), ROUND(z_size/10) + FROM bucket WHERE bucket_id = vPackage; + + IF ROW_COUNT() > 0 + THEN + INSERT INTO vn2008.mail SET + `subject` = 'Cubo añadido', + `text` = CONCAT('Se ha añadido el cubo: ', vPackage), + `to` = 'ekt@verdnatura.es'; + END IF; + END IF; + + -- Si es una compra de Floramondo obtiene el articulo + IF vPutOrderFk THEN + SELECT b.itemFk, b.id INTO vItem, vBuy + FROM edi.putOrder po + JOIN vn.buy b ON b.deliveryFk = po.deliveryInformationID + WHERE po.id = vPutOrderFk + LIMIT 1; + END IF; + + IF IFNULL(vItem,0) = 0 THEN + -- Intenta obtener el artículo en base a los atributos holandeses + + INSERT IGNORE INTO item_track SET + item_id = vRef; + + SELECT c.Id_Compra, c.Id_Article INTO vBuy, vItem + FROM vn2008.buy_edi e + JOIN item_track t ON t.item_id = e.ref + LEFT JOIN vn2008.buy_edi l ON l.ref = e.ref + LEFT JOIN vn2008.Compres c ON c.buy_edi_id = l.id + JOIN vn2008.config cfg + WHERE e.id = vSelf + AND l.id != vSelf + AND c.Id_Article != cfg.generic_item + AND IF(t.s1, l.s1 = e.s1, TRUE) + AND IF(t.s2, l.s2 = e.s2, TRUE) + AND IF(t.s3, l.s3 = e.s3, TRUE) + AND IF(t.s4, l.s4 = e.s4, TRUE) + AND IF(t.s5, l.s5 = e.s5, TRUE) + AND IF(t.s6, l.s6 = e.s6, TRUE) + AND IF(t.kop, l.kop = e.kop, TRUE) + AND IF(t.pac, l.pac = e.pac, TRUE) + AND IF(t.cat, l.cat = e.cat, TRUE) + AND IF(t.ori, l.ori = e.ori, TRUE) + AND IF(t.pro, l.pro = e.pro, TRUE) + AND IF(t.sub, l.sub = e.sub, TRUE) + AND IF(t.package, l.package = e.package, TRUE) + AND c.Id_Article < 170000 + ORDER BY l.now DESC, c.Id_Compra ASC LIMIT 1; + END IF; + + -- Determina si el articulo se vende por lotes + IF vItem + THEN + SELECT COUNT(*) > 0 INTO vIsLot + FROM vn2008.Articles a + LEFT JOIN vn2008.Tipos t ON t.tipo_id = a.tipo_id + WHERE a.Id_Article = vItem + AND t.`transaction`; + + -- Si el articulo se vende por lotes se inserta un nuevo artículo + + IF vIsLot + THEN + INSERT INTO vn2008.Articles ( + Article + ,Medida + ,Categoria + ,Id_Origen + ,iva_group_id + ,Foto + ,Color + ,Codintrastat + ,tipo_id + ,Tallos + ) + SELECT + i.`name` + ,IFNULL(e.s1, e.pac) + ,e.cat + ,IFNULL(o.id, 17) + ,IFNULL(a.iva_group_id, 1) + ,a.Foto + ,a.Color + ,a.Codintrastat + ,IFNULL(a.tipo_id, 10) + ,IF(a.tipo_id = 15, 0, 1) + FROM vn2008.buy_edi e + LEFT JOIN item i ON i.id = e.ref + LEFT JOIN vn2008.Origen o ON o.Abreviatura = e.ori + LEFT JOIN vn2008.Articles a ON a.Id_Article = vItem + WHERE e.id = vSelf; + + SET vItem = LAST_INSERT_ID(); + END IF; + END IF; + + -- Inserta la compra asociada al EKT + + INSERT INTO vn2008.Compres + ( + Id_Entrada + ,buy_edi_id + ,Costefijo + ,Id_Article + ,`grouping` + ,caja + ,Packing + ,Cantidad + ,Productor + ,Etiquetas + ,Id_Cubo + ,`weight` + ) + SELECT + cfg.edi_entry + ,vSelf + ,(@t := IF(a.Tallos, a.Tallos, 1)) * e.pri + ,IFNULL(vItem, cfg.generic_item) + ,IFNULL(c.`grouping`, e.pac) + ,vForceToPacking + ,@pac := e.pac / @t + ,@pac * e.qty + ,s.company_name + ,e.qty + ,IFNULL(c.Id_Cubo, e.package) + ,a.density * (vn.item_getVolume(a.Id_Article, IFNULL(c.Id_Cubo, e.package)) / 1000000) + FROM vn2008.buy_edi e + LEFT JOIN vn2008.Compres c ON c.Id_Compra = vBuy + LEFT JOIN vn2008.Articles a ON a.Id_Article = c.Id_Article + LEFT JOIN supplier s ON e.pro = s.supplier_id + JOIN vn2008.config cfg + WHERE e.id = vSelf + 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 `ekt_load__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!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 ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ekt_load__`(IN `vSelf` INT) BEGIN DECLARE vRef INT; DECLARE vBuy INT; @@ -8319,175 +8390,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 `ekt_load__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ekt_load__`(IN `vSelf` INT) -BEGIN - DECLARE vRef INT; - DECLARE vBuy INT; - DECLARE vItem INT; - DECLARE vQty INT; - DECLARE vPackage INT; - DECLARE vIsLot BOOLEAN; - DECLARE vForceToPacking INT DEFAULT 2; - - -- Carga los datos necesarios del EKT - - SELECT ref, qty, package INTO vRef, vQty, vPackage - FROM ekt e - LEFT JOIN item i ON e.ref = i.id - WHERE e.id = vSelf; - - -- Inserta el cubo si no existe - - IF vPackage = 800 - THEN - SET vPackage = 800 + vQty; - - INSERT IGNORE INTO vn2008.Cubos SET - Id_Cubo = vPackage, - x = 7200 / vQty, - y = 1; - ELSE - INSERT IGNORE INTO vn2008.Cubos (Id_Cubo, X, Y, Z) - SELECT bucket_id, ROUND(x_size/10), ROUND(y_size/10), ROUND(z_size/10) - FROM bucket WHERE bucket_id = vPackage; - - IF ROW_COUNT() > 0 - THEN - INSERT INTO vn2008.mail SET - `subject` = 'Cubo añadido', - `text` = CONCAT('Se ha añadido el cubo: ', vPackage), - `to` = 'ekt@verdnatura.es'; - END IF; - END IF; - - -- Intenta obtener el artículo en base a los atributos holandeses - - INSERT IGNORE INTO item_track SET - item_id = vRef; - - SELECT c.Id_Compra, c.Id_Article INTO vBuy, vItem - FROM vn2008.buy_edi e - JOIN item_track t ON t.item_id = e.ref - LEFT JOIN vn2008.buy_edi l ON l.ref = e.ref - LEFT JOIN vn2008.Compres c ON c.buy_edi_id = l.id - JOIN vn2008.config cfg - WHERE e.id = vSelf - AND l.id != vSelf - AND c.Id_Article != cfg.generic_item - AND IF(t.s1, l.s1 = e.s1, TRUE) - AND IF(t.s2, l.s2 = e.s2, TRUE) - AND IF(t.s3, l.s3 = e.s3, TRUE) - AND IF(t.s4, l.s4 = e.s4, TRUE) - AND IF(t.s5, l.s5 = e.s5, TRUE) - AND IF(t.s6, l.s6 = e.s6, TRUE) - AND IF(t.kop, l.kop = e.kop, TRUE) - AND IF(t.pac, l.pac = e.pac, TRUE) - AND IF(t.cat, l.cat = e.cat, TRUE) - AND IF(t.ori, l.ori = e.ori, TRUE) - AND IF(t.pro, l.pro = e.pro, TRUE) - AND IF(t.sub, l.sub = e.sub, TRUE) - AND IF(t.package, l.package = e.package, TRUE) - AND c.Id_Article < 170000 - ORDER BY l.now DESC, c.Id_Compra ASC LIMIT 1; - - -- Determina si el articulo se vende por lotes - - IF vItem - THEN - SELECT COUNT(*) > 0 INTO vIsLot - FROM vn2008.Articles a - LEFT JOIN vn2008.Tipos t ON t.tipo_id = a.tipo_id - WHERE a.Id_Article = vItem - AND t.`transaction`; - - -- Si el articulo se vende por lotes se inserta un nuevo artículo - - IF vIsLot - THEN - INSERT INTO vn2008.Articles ( - Article - ,Medida - ,Categoria - ,Id_Origen - ,iva_group_id - ,Foto - ,Color - ,Codintrastat - ,tipo_id - ,Tallos - ) - SELECT - i.`name` - ,IFNULL(e.s1, e.pac) - ,e.cat - ,IFNULL(o.id, 17) - ,IFNULL(a.iva_group_id, 1) - ,a.Foto - ,a.Color - ,a.Codintrastat - ,IFNULL(a.tipo_id, 10) - ,IF(a.tipo_id = 15, 0, 1) - FROM vn2008.buy_edi e - LEFT JOIN item i ON i.id = e.ref - LEFT JOIN vn2008.Origen o ON o.Abreviatura = e.ori - LEFT JOIN vn2008.Articles a ON a.Id_Article = vItem - WHERE e.id = vSelf; - - SET vItem = LAST_INSERT_ID(); - END IF; - END IF; - - -- Inserta la compra asociada al EKT - - INSERT INTO vn2008.Compres - ( - Id_Entrada - ,buy_edi_id - ,Costefijo - ,Id_Article - ,`grouping` - ,caja - ,Packing - ,Cantidad - ,Productor - ,Etiquetas - ,Id_Cubo - ) - SELECT - cfg.edi_entry - ,vSelf - ,(@t := IF(a.Tallos, a.Tallos, 1)) * e.pri - ,IFNULL(vItem, cfg.generic_item) - ,IFNULL(c.`grouping`, e.pac) - ,vForceToPacking - ,@pac := e.pac / @t - ,@pac * e.qty - ,s.company_name - ,e.qty - ,IFNULL(c.Id_Cubo, e.package) - FROM vn2008.buy_edi e - LEFT JOIN vn2008.Compres c ON c.Id_Compra = vBuy - LEFT JOIN vn2008.Articles a ON a.Id_Article = c.Id_Article - LEFT JOIN supplier s ON e.pro = s.supplier_id - JOIN vn2008.config cfg - WHERE e.id = vSelf - 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 `exchange_new` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -8531,154 +8433,377 @@ CREATE DEFINER=`root`@`%` PROCEDURE `exchange_new`( IN `vAuction` SMALLINT, IN `vPackage` INT, IN `vPutOrderFk` INT) -BEGIN +BEGIN /** * Adds a new exchange, generates it's barcode and * inserts/updates the transaction. When the referenced * transaction exists as provisional, updates it with - * the new values. - */ - DECLARE vEkt INT; - DECLARE vRewriteKop INT DEFAULT NULL; - DECLARE vBarcode CHAR(15) DEFAULT NULL; - DECLARE vIsDuplicated BOOL; + * the new values. + */ + DECLARE vEkt INT; + DECLARE vRewriteKop INT DEFAULT NULL; + DECLARE vBarcode CHAR(15) DEFAULT NULL; + DECLARE vIsDuplicated BOOL; DECLARE vUpdateExistent BOOL DEFAULT FALSE; - DECLARE duplicateKey CONDITION FOR 1062; - - DECLARE CONTINUE HANDLER FOR duplicateKey - SET vIsDuplicated = TRUE; - - -- Generates the barcode - - IF vAgj != 0 AND vAgj IS NOT NULL - THEN - SET vBarcode = CONCAT( - LPAD(vAuction, 2, 0), - LPAD(IFNULL(vClock, 99), 2, 0), - LPAD(DAYOFYEAR(vDate), 3, 0), - IF(vClock IS NULL OR vClock = 99, - LPAD(vAgj, 7, 0), - CONCAT(LPAD(vAgj, 5, 0), '01') - ), - '0' - ); - END IF; - - -- Rewrites the kop parameter - - IF vKop IS NULL THEN - SELECT defaultKop INTO vKop FROM exchangeConfig; - END IF; - - SELECT e.kop INTO vRewriteKop - FROM mailSender e - JOIN mail m ON m.senderFk = e.id - WHERE m.id = vMailFk; - - SET vKop = IFNULL(vRewriteKop, vKop); - - -- Inserts the new transaction + DECLARE duplicateKey CONDITION FOR 1062; + + DECLARE CONTINUE HANDLER FOR duplicateKey + SET vIsDuplicated = TRUE; + + -- Generates the barcode + + IF vAgj != 0 AND vAgj IS NOT NULL + THEN + SET vBarcode = CONCAT( + LPAD(vAuction, 2, 0), + LPAD(IFNULL(vClock, 99), 2, 0), + LPAD(DAYOFYEAR(vDate), 3, 0), + IF(vClock IS NULL OR vClock = 99, + LPAD(vAgj, 7, 0), + CONCAT(LPAD(vAgj, 5, 0), '01') + ), + '0' + ); + END IF; + + -- Rewrites the kop parameter + + IF vKop IS NULL THEN + SELECT defaultKop INTO vKop FROM exchangeConfig; + END IF; + + SELECT e.kop INTO vRewriteKop + FROM mailSender e + JOIN mail m ON m.senderFk = e.id + WHERE m.id = vMailFk; + + SET vKop = IFNULL(vRewriteKop, vKop); + + -- Inserts the new transaction + + SET vIsDuplicated = FALSE; + INSERT INTO ekt SET + barcode = IFNULL(vBarcode, barcode) + ,deliveryNumber = vDeliveryNumber + ,entryYear = YEAR(vDate) + ,fec = vDate + ,hor = vHour + ,ref = vRef + ,item = vItem + ,agj = vAgj + ,cat = vCat + ,pac = vPac + ,sub = vSub + ,kop = vKop + ,ptd = vPtd + ,pro = vPro + ,ori = vOrigin + ,ptj = vPtj + ,qty = vQuantiy + ,pri = vPrice + ,klo = vClock + ,s1 = vS1 + ,s2 = vS2 + ,s3 = vS3 + ,s4 = vS4 + ,s5 = vS5 + ,s6 = vS6 + ,k1 = vK1 + ,k2 = vK2 + ,k3 = vP1 + ,k4 = vP2 + ,auction = vAuction + ,package = vPackage + ,putOrderFk = vPutOrderFk; + + -- If it exists duplicado updates it + + IF NOT vIsDuplicated + THEN + SET vEkt = LAST_INSERT_ID(); + CALL ekt_load (vEkt); + + ELSEIF vDeliveryNumber != 0 + AND vDeliveryNumber IS NOT NULL + THEN + SELECT id INTO vEkt + FROM ekt + WHERE deliveryNumber = vDeliveryNumber; + + SELECT COUNT(*) = 0 INTO vUpdateExistent + FROM ekt t + JOIN `exchange` b ON b.ektFk = t.id + JOIN exchangeConfig c + WHERE t.deliveryNumber = vDeliveryNumber + AND t.entryYear = YEAR(vDate) + AND b.typeFk != c.presaleFk; + END IF; + + IF vUpdateExistent + THEN + UPDATE ekt SET + barcode = IFNULL(vBarcode, barcode) + ,fec = vDate + ,hor = vHour + ,ref = vRef + ,item = vItem + ,agj = vAgj + ,cat = vCat + ,pac = vPac + ,sub = vSub + ,kop = vKop + ,ptd = vPtd + ,pro = vPro + ,ori = vOrigin + ,ptj = vPtj + ,qty = vQuantiy + ,pri = vPrice + ,klo = vClock + ,s1 = vS1 + ,s2 = vS2 + ,s3 = vS3 + ,s4 = vS4 + ,s5 = vS5 + ,s6 = vS6 + ,k1 = vK1 + ,k2 = vK2 + ,k3 = vP1 + ,k4 = vP2 + ,auction = vAuction + ,package = vPackage + ,putOrderFk = vPutOrderFk + WHERE id = vEkt; + END IF; + + -- Registers the exchange + + INSERT INTO `exchange` SET + mailFk = vMailFk + ,typeFk = vType + ,ektFk = vEkt; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_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 `floramondo_offerRefresh` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `floramondo_offerRefresh`() +BEGIN + DECLARE vLanded DATE; + + DROP TEMPORARY TABLE IF EXISTS tmp; + CREATE TEMPORARY TABLE tmp ENGINE = MEMORY + SELECT * FROM ( + SELECT * + FROM edi.supplyOffer + JOIN edi.marketPlace mp ON mp.id = MarketPlaceID + WHERE mp.isOffered = TRUE + -- OR diId IN(35413041, 35408673, 35335122, 35400930) + ORDER BY NumberOfUnits DESC) t + JOIN edi.item_groupToOffer igo ON igo.group_code = t.group_id + GROUP BY Item_ArticleCode, s1, s2, s3, s4, s5, s6, company_name, Price, Quality, NumberOfItemsPerCask, EmbalageCode; + + DROP TEMPORARY TABLE IF EXISTS edi.offer; + CREATE TEMPORARY TABLE edi.offer ENGINE = MEMORY + SELECT so.*, ev1.type_description s1Value, ev2.type_description s2Value, ev3.type_description s3Value, + ev4.type_description s4Value, ev5.type_description s5Value, ev6.type_description s6Value, + eif1.feature ef1, eif2.feature ef2, eif3.feature ef3, eif4.feature ef4, eif5.feature ef5, 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 + LEFT JOIN edi.item_feature eif2 ON eif2.item_id = so.Item_ArticleCode + 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 + LEFT JOIN edi.item_feature eif4 ON eif4.item_id = so.Item_ArticleCode + 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 + 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; + + DROP TEMPORARY TABLE tmp; + + -- Actualizamos el campo supplyResponseFk para aquellos articulos que ya estan creados y reutilizamos + UPDATE IGNORE edi.offer o + LEFT JOIN vn.item iExist ON iExist.supplyResponseFk = o.srID + JOIN vn.item i ON i.name = o.product_name + AND i.subname <=> o.company_name + AND i.value5 <=> o.s1Value + AND i.value6 <=> o.s2Value + AND i.value7 <=> o.s3Value + AND i.value8 <=> o.s4Value + AND i.value9 <=> o.s5Value + AND i.value10 <=> o.s6Value + SET i.supplyResponseFk = o.srID + WHERE iExist.id IS NULL; + + DROP TEMPORARY TABLE IF EXISTS itemToInsert; + CREATE TEMPORARY TABLE itemToInsert ENGINE = MEMORY + SELECT o.* + FROM edi.offer o + LEFT JOIN vn.item i ON i.supplyResponseFk = o.srId + WHERE i.id IS NULL; + + -- Insertamos todos los items en Articles de la oferta + INSERT IGNORE INTO vn.item(`name`, + longName, + subName, + expenceFk, + typeFk, + intrastatFk, + originFk, + supplyResponseFk) + SELECT product_name, + product_name, + company_name, + expenseFk, + itemTypeFk, + intrastatFk, + originFk, + srId + FROM itemToInsert; + + INSERT IGNORE INTO vn.itemImageQueue(itemFk, url) + SELECT i.id, PictureReference + FROM itemToInsert ii + JOIN vn.item i ON i.supplyResponseFk = ii.srId; + + -- Inserta si se añadiesen tags nuevos + INSERT IGNORE INTO vn.tag (name, ediTypeFk) + SELECT description, type_id FROM edi.type; + + -- 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 , CONCAT(ii.product_name,IF(ii.Quality != 'A1', CONCAT(' ',ii.Quality),'')), 1 + FROM itemToInsert ii + JOIN vn.tag t ON t.`name` = 'Producto' + JOIN vn.item i ON i.supplyResponseFk = ii.srId; + + 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` = 'Marca' + JOIN vn.item i ON i.supplyResponseFk = ii.srId; + + 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 s1Value; + + INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) + SELECT i.id, t.id , REPLACE(s2Value," en 'op'","+") , 6 + FROM itemToInsert ii + JOIN vn.tag t ON t.ediTypeFk = ii.ef2 + JOIN vn.item i ON i.supplyResponseFk = ii.srId + WHERE s2Value; + + 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 s3Value; + + INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) + SELECT i.id, t.id , ii.Quality, 8 + FROM itemToInsert ii + JOIN vn.tag t ON t.`name` = 'Calidad' + JOIN vn.item i ON i.supplyResponseFk = ii.srId; + + 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 s5Value; + + DROP TABLE IF EXISTS tmp.item; + CREATE 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; + + SELECT LatestOrderDateTime INTO vLanded + FROM edi.offer + ORDER BY LatestOrderDateTime ASC + LIMIT 1; + SET @myEntry := vn.floramondo_getEntry(vLanded); + IF @myEntry THEN + -- Inserta la oferta obsoleta + DELETE b FROM vn.buy b + JOIN vn.item i ON i.id = b.itemFk + LEFT JOIN edi.offer o ON i.supplyResponseFk = o.srId + WHERE b.entryFk = @myEntry AND o.id IS NULL; + -- actualiza la oferta existente + UPDATE vn.buy b + 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.entryFk = @myEntry; + + -- Inserta la oferta + INSERT INTO vn.buy(entryFk, + itemFk, + quantity, + buyingValue, + stickers, + packing, + `grouping`, + groupingMode, + packageFk, + deliveryFk) + + SELECT @myEntry, + i.id, + o.NumberOfUnits * o.NumberOfItemsPerCask as quantity, + o.Price, + o.NumberOfUnits as etiquetas, + o.NumberOfItemsPerCask as packing, + o.MinimumQuantity * o.NumberOfItemsPerCask as `grouping`, + 1, -- Obliga al Packing + o.embalageCode, + o.diId + FROM edi.offer o + JOIN vn.item i ON i.supplyResponseFk = o.srId + LEFT JOIN vn.buy b ON i.id = b.itemFk + WHERE b.id IS NULL AND NOT b.entryFk <=> @myEntry; + + CALL vn2008.buy_tarifas_entry(@myEntry); + END IF; + DROP TEMPORARY TABLE + edi.offer, + itemToInsert; + + DROP TABLE tmp.item; - SET vIsDuplicated = FALSE; - INSERT INTO ekt SET - barcode = IFNULL(vBarcode, barcode) - ,deliveryNumber = vDeliveryNumber - ,entryYear = YEAR(vDate) - ,fec = vDate - ,hor = vHour - ,ref = vRef - ,item = vItem - ,agj = vAgj - ,cat = vCat - ,pac = vPac - ,sub = vSub - ,kop = vKop - ,ptd = vPtd - ,pro = vPro - ,ori = vOrigin - ,ptj = vPtj - ,qty = vQuantiy - ,pri = vPrice - ,klo = vClock - ,s1 = vS1 - ,s2 = vS2 - ,s3 = vS3 - ,s4 = vS4 - ,s5 = vS5 - ,s6 = vS6 - ,k1 = vK1 - ,k2 = vK2 - ,k3 = vP1 - ,k4 = vP2 - ,auction = vAuction - ,package = vPackage - ,putOrderFk = vPutOrderFk; - - -- If it exists duplicado updates it - - IF NOT vIsDuplicated - THEN - SET vEkt = LAST_INSERT_ID(); - CALL ekt_load (vEkt); - - ELSEIF vDeliveryNumber != 0 - AND vDeliveryNumber IS NOT NULL - THEN - SELECT id INTO vEkt - FROM ekt - WHERE deliveryNumber = vDeliveryNumber; - - SELECT COUNT(*) = 0 INTO vUpdateExistent - FROM ekt t - JOIN `exchange` b ON b.ektFk = t.id - JOIN exchangeConfig c - WHERE t.deliveryNumber = vDeliveryNumber - AND t.entryYear = YEAR(vDate) - AND b.typeFk != c.presaleFk; - END IF; - - IF vUpdateExistent - THEN - UPDATE ekt SET - barcode = IFNULL(vBarcode, barcode) - ,fec = vDate - ,hor = vHour - ,ref = vRef - ,item = vItem - ,agj = vAgj - ,cat = vCat - ,pac = vPac - ,sub = vSub - ,kop = vKop - ,ptd = vPtd - ,pro = vPro - ,ori = vOrigin - ,ptj = vPtj - ,qty = vQuantiy - ,pri = vPrice - ,klo = vClock - ,s1 = vS1 - ,s2 = vS2 - ,s3 = vS3 - ,s4 = vS4 - ,s5 = vS5 - ,s6 = vS6 - ,k1 = vK1 - ,k2 = vK2 - ,k3 = vP1 - ,k4 = vP2 - ,auction = vAuction - ,package = vPackage - ,putOrderFk = vPutOrderFk - WHERE id = vEkt; - END IF; - - -- Registers the exchange - - INSERT INTO `exchange` SET - mailFk = vMailFk - ,typeFk = vType - ,ektFk = vEkt; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -8815,7 +8940,8 @@ CREATE TABLE `config` ( `productionDomain` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'The address for production website', `pdfsDir` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Directory where PDFs are allocated', `dmsDir` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Directory where documents are allocated', - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + KEY `jwtkey_IX` (`jwtKey`) COMMENT 'Prueba de Ernesto 3.8.2020. MySQL se queja de no tener indices. Si, se que solo tiene un registro pero molesta para depurar otros.' ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Global configuration parameters'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -10185,9 +10311,9 @@ 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 = utf8 */ ;; +/*!50003 SET character_set_results = utf8 */ ;; +/*!50003 SET collation_connection = utf8_general_ci */ ;; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; @@ -10754,30 +10880,30 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `item_listAllocation`(IN `vWh` TINYINT, IN `vDate` DATE, IN `vType` INT, IN `vPrefix` VARCHAR(255), IN `vUseIds` BOOLEAN) -BEGIN -/** - * Lists visible items and it's box sizes of the specified - * type at specified date. - * - * @param vWh The warehouse id - * @param vDate The visible date - * @param vType The type id - * @param vPrefix The article prefix to filter or %NULL for all - * @param vUseIds Whether to order the result by item id - * @select List of visible items with it's box sizes - */ - CALL item_getVisible(vWh, vDate, vType, vPrefix); - - IF vUseIds - THEN - SELECT * FROM tmp.itemVisible - ORDER BY Id_Article; - ELSE - SELECT * FROM tmp.itemVisible - ORDER BY Article, packing; - END IF; - - DROP TEMPORARY TABLE tmp.itemVisible; +BEGIN +/** + * Lists visible items and it's box sizes of the specified + * type at specified date. + * + * @param vWh The warehouse id + * @param vDate The visible date + * @param vType The type id + * @param vPrefix The article prefix to filter or %NULL for all + * @param vUseIds Whether to order the result by item id + * @select List of visible items with it's box sizes + */ + CALL item_getVisible(vWh, vDate, vType, vPrefix); + + IF vUseIds + THEN + SELECT * FROM tmp.itemVisible + ORDER BY Id_Article; + ELSE + SELECT * FROM tmp.itemVisible + ORDER BY Article, packing; + END IF; + + DROP TEMPORARY TABLE tmp.itemVisible; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -12031,9 +12157,9 @@ 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 = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!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 ;; @@ -12134,6 +12260,275 @@ BEGIN OPEN cDates; + lDates: + LOOP + SET vTicket = NULL; + SET vDone = FALSE; + FETCH cDates INTO vShipment, vWarehouse; + + IF vDone THEN + LEAVE lDates; + END IF; + + -- Busca un ticket existente que coincida con los parametros + + SELECT t.id INTO vTicket + FROM vn.ticket t + LEFT JOIN vn.ticketState tls on tls.ticket = t.id + JOIN `order` o + ON o.address_id = t.addressFk + AND vWarehouse = t.warehouseFk + AND o.agency_id = t.agencyModeFk + AND o.date_send = t.landed + AND vShipment = DATE(t.shipped) + WHERE o.id = vOrder + AND t.invoiceOutFk IS NULL + AND IFNULL(tls.alertLevel,0) = 0 + AND t.clientFk <> 1118 + LIMIT 1; + + -- Crea el ticket en el caso de no existir uno adecuado + + IF vTicket IS NULL + THEN + CALL vn.ticketCreateWithUser( + vClientId, + IFNULL(vShipment, CURDATE()), + vWarehouse, + vCompanyId, + vAddress, + vAgencyModeId, + NULL, + vDelivery, + vUserId, + vTicket + ); + ELSE + INSERT INTO vncontrol.inter + SET Id_Ticket = vTicket, + Id_Trabajador = vUserId, + state_id = TICKET_FREE; + END IF; + + INSERT IGNORE INTO vn.orderTicket + SET orderFk = vOrder, + ticketFk = vTicket; + + -- Añade las notas + + IF vNotes IS NOT NULL AND vNotes != '' + THEN + INSERT INTO vn.ticketObservation SET + ticketFk = vTicket, + observationTypeFk = 4 /* salesperson */ , + `description` = vNotes + ON DUPLICATE KEY UPDATE + `description` = CONCAT(VALUES(`description`),'. ', `description`); + END IF; + + -- Añade los movimientos y sus componentes + + OPEN cRows; + + lRows: + LOOP + SET vDone = FALSE; + FETCH cRows INTO vRowId, vItem, vConcept, vAmount, vPrice, vRate; + + IF vDone THEN + LEAVE lRows; + END IF; + SET vSale = NULL; + SELECT s.id INTO vSale + FROM vn.sale s + WHERE ticketFk = vTicket + AND price = vPrice + AND itemFk = vItem + LIMIT 1; + IF vSale THEN + UPDATE vn.sale + SET quantity = quantity + vAmount + WHERE id = vSale; + ELSE + INSERT INTO vn.sale + SET + itemFk = vItem, + ticketFk = vTicket, + concept = vConcept, + quantity = vAmount, + price = vPrice, + priceFixed = FALSE, + isPriceFixed = TRUE; + + SET vSale = LAST_INSERT_ID(); + + INSERT INTO vn.saleComponent + (saleFk, componentFk, `value`) + SELECT vSale, cm.component_id, cm.price + FROM order_component cm + JOIN vn.component c ON c.id = cm.component_id + WHERE cm.order_row_id = vRowId + GROUP BY vSale, cm.component_id; + END IF; + UPDATE order_row SET Id_Movimiento = vSale + WHERE id = vRowId; + + INSERT INTO edi.putOrder (deliveryInformationID, + supplyResponseId, + quantity, + EndUserPartyId, + EndUserPartyGLN) + SELECT di.ID, i.supplyResponseFk, vAmount / NumberOfItemsPerCask, FALSE, vClientId + FROM edi.deliveryInformation di + JOIN vn.item i ON i.supplyResponseFk = di.supplyResponseID + JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk + WHERE i.id = vItem + LIMIT 1; + END LOOP; + + CLOSE cRows; + + -- Fija el coste + + DROP TEMPORARY TABLE IF EXISTS tComponents; + CREATE TEMPORARY TABLE tComponents + (INDEX (saleFk)) + ENGINE = MEMORY + SELECT SUM(sc.`value`) valueSum, sc.saleFk + FROM vn.saleComponent sc + JOIN vn.component c ON c.id = sc.componentFk + JOIN vn.componentType ct ON ct.id = c.typeFk AND ct.isBase + JOIN vn.sale s ON s.id = sc.saleFk + WHERE s.ticketFk = vTicket + GROUP BY sc.saleFk; + + UPDATE vn.sale s + JOIN tComponents mc ON mc.saleFk = s.id + SET s.priceFixed = valueSum; + + DROP TEMPORARY TABLE tComponents; + END LOOP; + + CLOSE cDates; + + DELETE FROM basketOrder WHERE orderFk = vOrder; + UPDATE `order` SET confirmed = TRUE, confirm_date = NOW() + WHERE id = vOrder; + + 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_confirmWithUser__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!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 ;; +CREATE DEFINER=`root`@`%` PROCEDURE `order_confirmWithUser__`(IN `vOrder` INT, IN `vUserId` INT) +BEGIN +/** + * Confirms an order, creating each of its tickets on the corresponding + * date, store and user. + * + * @param vOrder The order identifier + * @param vUser The user identifier + */ + DECLARE vOk BOOL; + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vWarehouse INT; + DECLARE vShipment DATETIME; + DECLARE vTicket INT; + DECLARE vNotes VARCHAR(255); + DECLARE vItem INT; + DECLARE vConcept VARCHAR(30); + DECLARE vAmount INT; + DECLARE vPrice DECIMAL(10,2); + DECLARE vSale INT; + DECLARE vRate INT; + DECLARE vRowId INT; + DECLARE vDelivery DATE; + DECLARE vAddress INT; + DECLARE vIsConfirmed BOOL; + DECLARE vClientId INT; + DECLARE vCompanyId INT; + DECLARE vAgencyModeId INT; + DECLARE TICKET_FREE INT DEFAULT 2; + + 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 + GROUP BY r.warehouse_id; + + DECLARE cRows CURSOR FOR + SELECT r.id, r.item_id, i.name, r.amount, r.price, r.rate + FROM order_row r + JOIN vn.item i ON i.id = r.item_id + WHERE r.amount != 0 + AND r.warehouse_id = vWarehouse + AND r.order_id = vOrder + ORDER BY r.rate DESC; + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + -- Carga los datos del pedido + + SELECT o.date_send, o.address_id, o.note, + o.confirmed, a.clientFk, o.company_id, o.agency_id + INTO vDelivery, vAddress, vNotes, + vIsConfirmed, vClientId, vCompanyId, vAgencyModeId + FROM hedera.`order` o + JOIN vn.address a ON a.id = o.address_id + WHERE o.id = vOrder; + + -- Comprueba que el pedido no está confirmado + + IF vIsConfirmed THEN + CALL util.throw ('ORDER_ALREADY_CONFIRMED'); + END IF; + + -- Comprueba que el pedido no está vacío + + SELECT COUNT(*) > 0 INTO vOk + FROM order_row WHERE order_id = vOrder AND amount > 0; + + IF NOT vOk THEN + CALL util.throw ('ORDER_EMPTY'); + END IF; + + -- Carga las fechas de salida de cada almacén + + CALL vn.zone_getShipped (vDelivery, vAddress, vAgencyModeId, FALSE); + + -- Trabajador que realiza la acción + + IF vUserId IS NULL THEN + SELECT employeeFk INTO vUserId FROM orderConfig; + END IF; + + -- Crea los tickets del pedido + + START TRANSACTION; + + OPEN cDates; + lDates: LOOP SET vTicket = NULL; @@ -12285,271 +12680,13 @@ 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_confirmWithUser__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!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 ;; -CREATE DEFINER=`root`@`%` PROCEDURE `order_confirmWithUser__`(IN `vOrder` INT, IN `vUserId` INT) -BEGIN -/** - * Confirms an order, creating each of its tickets on the corresponding - * date, store and user. - * - * @param vOrder The order identifier - * @param vUser The user identifier - */ - DECLARE vOk BOOL; - DECLARE vDone BOOL DEFAULT FALSE; - DECLARE vWarehouse INT; - DECLARE vShipment DATETIME; - DECLARE vTicket INT; - DECLARE vNotes VARCHAR(255); - DECLARE vItem INT; - DECLARE vConcept VARCHAR(30); - DECLARE vAmount INT; - DECLARE vPrice DECIMAL(10,2); - DECLARE vSale INT; - DECLARE vRate INT; - DECLARE vRowId INT; - DECLARE vDelivery DATE; - DECLARE vAddress INT; - DECLARE vIsConfirmed BOOL; - DECLARE vClientId INT; - DECLARE vCompanyId INT; - DECLARE vAgencyModeId INT; - DECLARE TICKET_FREE INT DEFAULT 2; - - 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 - GROUP BY r.warehouse_id; - - DECLARE cRows CURSOR FOR - SELECT r.id, r.item_id, i.name, r.amount, r.price, r.rate - FROM order_row r - JOIN vn.item i ON i.id = r.item_id - WHERE r.amount != 0 - AND r.warehouse_id = vWarehouse - AND r.order_id = vOrder - ORDER BY r.rate DESC; - - DECLARE CONTINUE HANDLER FOR NOT FOUND - SET vDone = TRUE; - - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - - -- Carga los datos del pedido - - SELECT o.date_send, o.address_id, o.note, - o.confirmed, a.clientFk, o.company_id, o.agency_id - INTO vDelivery, vAddress, vNotes, - vIsConfirmed, vClientId, vCompanyId, vAgencyModeId - FROM hedera.`order` o - JOIN vn.address a ON a.id = o.address_id - WHERE o.id = vOrder; - - -- Comprueba que el pedido no está confirmado - - IF vIsConfirmed THEN - CALL util.throw ('ORDER_ALREADY_CONFIRMED'); - END IF; - - -- Comprueba que el pedido no está vacío - - SELECT COUNT(*) > 0 INTO vOk - FROM order_row WHERE order_id = vOrder AND amount > 0; - - IF NOT vOk THEN - CALL util.throw ('ORDER_EMPTY'); - END IF; - - -- Carga las fechas de salida de cada almacén - - CALL vn.zone_getShipped (vDelivery, vAddress, vAgencyModeId, FALSE); - - -- Trabajador que realiza la acción - - IF vUserId IS NULL THEN - SELECT employeeFk INTO vUserId FROM orderConfig; - END IF; - - -- Crea los tickets del pedido - - START TRANSACTION; - - OPEN cDates; - - lDates: - LOOP - SET vTicket = NULL; - SET vDone = FALSE; - FETCH cDates INTO vShipment, vWarehouse; - - IF vDone THEN - LEAVE lDates; - END IF; - - -- Busca un ticket existente que coincida con los parametros - - SELECT t.id INTO vTicket - FROM vn.ticket t - LEFT JOIN vn.ticketState tls on tls.ticket = t.id - JOIN `order` o - ON o.address_id = t.addressFk - AND vWarehouse = t.warehouseFk - AND o.agency_id = t.agencyModeFk - AND o.date_send = t.landed - AND vShipment = DATE(t.shipped) - WHERE o.id = vOrder - AND t.invoiceOutFk IS NULL - AND IFNULL(tls.alertLevel,0) = 0 - AND t.clientFk <> 1118 - LIMIT 1; - - -- Crea el ticket en el caso de no existir uno adecuado - - IF vTicket IS NULL - THEN - CALL vn.ticketCreateWithUser( - vClientId, - IFNULL(vShipment, CURDATE()), - vWarehouse, - vCompanyId, - vAddress, - vAgencyModeId, - NULL, - vDelivery, - vUserId, - vTicket - ); - ELSE - INSERT INTO vncontrol.inter - SET Id_Ticket = vTicket, - Id_Trabajador = vUserId, - state_id = TICKET_FREE; - END IF; - - INSERT IGNORE INTO vn.orderTicket - SET orderFk = vOrder, - ticketFk = vTicket; - - -- Añade las notas - - IF vNotes IS NOT NULL AND vNotes != '' - THEN - INSERT INTO vn.ticketObservation SET - ticketFk = vTicket, - observationTypeFk = 4 /* salesperson */ , - `description` = vNotes - ON DUPLICATE KEY UPDATE - `description` = CONCAT(VALUES(`description`),'. ', `description`); - END IF; - - -- Añade los movimientos y sus componentes - - OPEN cRows; - - lRows: - LOOP - SET vDone = FALSE; - FETCH cRows INTO vRowId, vItem, vConcept, vAmount, vPrice, vRate; - - IF vDone THEN - LEAVE lRows; - END IF; - SET vSale = NULL; - SELECT s.id INTO vSale - FROM vn.sale s - WHERE ticketFk = vTicket - AND price = vPrice - AND itemFk = vItem - LIMIT 1; - IF vSale THEN - UPDATE vn.sale - SET quantity = quantity + vAmount - WHERE id = vSale; - ELSE - INSERT INTO vn.sale - SET - itemFk = vItem, - ticketFk = vTicket, - concept = vConcept, - quantity = vAmount, - price = vPrice, - priceFixed = 0, - isPriceFixed = TRUE; - - SET vSale = LAST_INSERT_ID(); - - INSERT INTO vn.saleComponent - (saleFk, componentFk, `value`) - SELECT vSale, cm.component_id, cm.price - FROM order_component cm - JOIN vn.component c ON c.id = cm.component_id - WHERE cm.order_row_id = vRowId - GROUP BY vSale, cm.component_id; - END IF; - UPDATE order_row SET Id_Movimiento = vSale - WHERE id = vRowId; - - END LOOP; - - CLOSE cRows; - - -- Fija el coste - - DROP TEMPORARY TABLE IF EXISTS tComponents; - CREATE TEMPORARY TABLE tComponents - (INDEX (saleFk)) - ENGINE = MEMORY - SELECT SUM(sc.`value`) valueSum, sc.saleFk - FROM vn.saleComponent sc - JOIN vn.component c ON c.id = sc.componentFk - JOIN vn.componentType ct ON ct.id = c.typeFk AND ct.isBase - JOIN vn.sale s ON s.id = sc.saleFk - WHERE s.ticketFk = vTicket - GROUP BY sc.saleFk; - - UPDATE vn.sale s - JOIN tComponents mc ON mc.saleFk = s.id - SET s.priceFixed = valueSum; - - DROP TEMPORARY TABLE tComponents; - END LOOP; - - CLOSE cDates; - - DELETE FROM basketOrder WHERE orderFk = vOrder; - UPDATE `order` SET confirmed = TRUE, confirm_date = NOW() - WHERE id = vOrder; - - 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_doRecalc` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!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 character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -12570,6 +12707,8 @@ proc: BEGIN DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN DO RELEASE_LOCK('hedera.order_doRecalc'); + # Agregado por Ernesto 9.Agosto.2020, quiero comprobar cuantos rollbacks suceden. + CALL util.debugAdd('Event Hedera order_doRecalc() (ernesto)', 'Rollback! '); # max 255 chars en variable y 255 en value, ya hay campo de fecha ROLLBACK; RESIGNAL; END; @@ -14411,6 +14550,7 @@ SET character_set_client = utf8; 1 AS `careinvite`, 1 AS `insecure`, 1 AS `transport`, + 1 AS `nat`, 1 AS `ipaddr`, 1 AS `regseconds`, 1 AS `port`, @@ -14448,6 +14588,7 @@ CREATE TABLE `sipConfig` ( `dtlscertfile` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `dtlsprivatekey` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `dtlssetup` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `nat` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Default values for SIP accounts'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -14753,7 +14894,7 @@ CREATE TABLE `bank_account` ( KEY `bank_account_bank_account_type_id_fkey` (`bank_account_type_id`), KEY `bank_account_nation_id_fkey` (`nation_id`), CONSTRAINT `bank_account_bank_account_type_id_fkey` FOREIGN KEY (`bank_account_type_id`) REFERENCES `bank_account_type` (`bank_account_type_id`) ON UPDATE CASCADE, - CONSTRAINT `bank_account_nation_id_fkey` FOREIGN KEY (`nation_id`) REFERENCES `nation` (`nation_id`) ON UPDATE CASCADE, + CONSTRAINT `bank_account_nation_id_fkey` FOREIGN KEY (`nation_id`) REFERENCES `nation__` (`nation_id`) ON UPDATE CASCADE, CONSTRAINT `bank_profile` FOREIGN KEY (`client_id`) REFERENCES `profile` (`profile_id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -14773,13 +14914,13 @@ CREATE TABLE `bank_account_type` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `bank_bic` +-- Table structure for table `bank_bic__` -- -DROP TABLE IF EXISTS `bank_bic`; +DROP TABLE IF EXISTS `bank_bic__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `bank_bic` ( +CREATE TABLE `bank_bic__` ( `nrbe` int(11) NOT NULL, `denominacion` varchar(255) DEFAULT NULL, `bic` char(11) DEFAULT NULL, @@ -14866,31 +15007,28 @@ CREATE TABLE `business_labour_payroll` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `calendar_employee` +-- Temporary table structure for view `calendar_employee` -- DROP TABLE IF EXISTS `calendar_employee`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `calendar_employee` ( - `business_id` int(11) NOT NULL, - `calendar_state_id` int(11) NOT NULL, - `date` date NOT NULL, - PRIMARY KEY (`business_id`,`date`), - KEY `calendar_employee_business_labour_id_idx` (`business_id`), - KEY `calendar_employee_calendar_state_calendar_state_id_idx` (`calendar_state_id`), - CONSTRAINT `calendar_employee_state_id` FOREIGN KEY (`calendar_state_id`) REFERENCES `calendar_state` (`calendar_state_id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `calendar_employee`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `calendar_employee` AS SELECT + 1 AS `id`, + 1 AS `business_id`, + 1 AS `calendar_state_id`, + 1 AS `date`*/; +SET character_set_client = @saved_cs_client; -- --- Table structure for table `calendar_free` +-- Table structure for table `calendar_free__` -- -DROP TABLE IF EXISTS `calendar_free`; +DROP TABLE IF EXISTS `calendar_free__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `calendar_free` ( +CREATE TABLE `calendar_free__` ( `calendar_free_id` int(11) NOT NULL AUTO_INCREMENT, `type` varchar(20) NOT NULL, `rgb` varchar(7) DEFAULT NULL, @@ -14918,7 +15056,7 @@ CREATE TABLE `calendar_labour__` ( KEY `fki_calendar_labour_legend_id` (`calendar_labour_legend_id`), KEY `fki_calendar_labour_person_day` (`person_id`,`day`), KEY `fki_workcenter_calendar` (`workcenter_id`), - CONSTRAINT `fk_calendar_labour_calendar_free1` FOREIGN KEY (`calendar_free_id`) REFERENCES `calendar_free` (`calendar_free_id`) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT `fk_calendar_labour_calendar_free1` FOREIGN KEY (`calendar_free_id`) REFERENCES `calendar_free__` (`calendar_free_id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_calendar_labour_legend_id` FOREIGN KEY (`calendar_labour_legend_id`) REFERENCES `calendar_labour_legend__` (`calendar_labour_legend_id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `workcenter_calendar` FOREIGN KEY (`workcenter_id`) REFERENCES `workcenter` (`workcenter_id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8; @@ -14980,13 +15118,13 @@ CREATE TABLE `calendar_state` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `currency` +-- Table structure for table `currency__` -- -DROP TABLE IF EXISTS `currency`; +DROP TABLE IF EXISTS `currency__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `currency` ( +CREATE TABLE `currency__` ( `currency_id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(15) NOT NULL, PRIMARY KEY (`currency_id`) @@ -15042,6 +15180,7 @@ 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=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -15117,13 +15256,13 @@ CREATE TABLE `media_type` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `nation` +-- Table structure for table `nation__` -- -DROP TABLE IF EXISTS `nation`; +DROP TABLE IF EXISTS `nation__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `nation` ( +CREATE TABLE `nation__` ( `nation_id` int(11) NOT NULL AUTO_INCREMENT, `currency_id` int(11) NOT NULL DEFAULT '1', `name` varchar(20) NOT NULL, @@ -15132,7 +15271,7 @@ CREATE TABLE `nation` ( PRIMARY KEY (`nation_id`), UNIQUE KEY `nation_name_key` (`name`), KEY `nation_currency_id_idx` (`currency_id`), - CONSTRAINT `nation_ibfk_1` FOREIGN KEY (`currency_id`) REFERENCES `currency` (`currency_id`) ON DELETE NO ACTION ON UPDATE NO ACTION + CONSTRAINT `nation___ibfk_1` FOREIGN KEY (`currency_id`) REFERENCES `currency__` (`currency_id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDBDEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -15298,7 +15437,7 @@ CREATE TABLE `province` ( PRIMARY KEY (`province_id`), UNIQUE KEY `province_name_key` (`name`), KEY `province_nation_id_idx` (`nation_id`), - CONSTRAINT `fk_province_nation1` FOREIGN KEY (`nation_id`) REFERENCES `nation` (`nation_id`) ON DELETE NO ACTION ON UPDATE NO ACTION + CONSTRAINT `fk_province_nation1` FOREIGN KEY (`nation_id`) REFERENCES `nation__` (`nation_id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDBDEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -15410,7 +15549,10 @@ CREATE TABLE `ACL` ( `permission` set('DENY','ALLOW') COLLATE utf8_unicode_ci DEFAULT 'ALLOW', `principalType` set('ROLE','USER') COLLATE utf8_unicode_ci DEFAULT 'ROLE', `principalId` varchar(512) CHARACTER SET utf8 DEFAULT NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + KEY `model_ix` (`model`(255)) COMMENT 'ernesto 3.8.2020. Mysql pide indices', + KEY `property_ix` (`property`(255)), + KEY `accessType_ix` (`accessType`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -15702,9 +15844,10 @@ DROP TABLE IF EXISTS `inboundPick`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `inboundPick` ( - `inboundFk` int(10) unsigned DEFAULT NULL, - `outboundFk` int(10) unsigned DEFAULT NULL, + `inboundFk` int(10) unsigned NOT NULL, + `outboundFk` int(10) unsigned NOT NULL, `quantity` int(11) NOT NULL, + PRIMARY KEY (`inboundFk`,`outboundFk`,`quantity`), UNIQUE KEY `buyFk` (`inboundFk`,`outboundFk`), KEY `saleFk` (`outboundFk`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -15843,9 +15986,9 @@ 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 = utf8 */ ;; +/*!50003 SET character_set_results = utf8 */ ;; +/*!50003 SET collation_connection = utf8_general_ci */ ;; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; @@ -16158,8 +16301,8 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `log_add_beta`(IN `vTableName` VARCHAR(255), IN `vNewId` VARCHAR(255), IN `vOldId` VARCHAR(255)) -proc: BEGIN - -- XXX: Disabled while testing +proc: BEGIN + -- XXX: Disabled while testing DECLARE vLanded DATE; DECLARE vWarehouseFk INT; DECLARE vBuyerFk INT; @@ -16167,20 +16310,20 @@ proc: BEGIN DECLARE vItemFk INT; DECLARE vItemName VARCHAR(50); - -- LEAVE proc; + -- LEAVE proc; - IF vOldId IS NOT NULL AND !(vOldId <=> vNewId) THEN - INSERT IGNORE INTO `log` SET - tableName = vTableName, - tableId = vOldId, - operation = 'delete'; - END IF; - - IF vNewId IS NOT NULL THEN - INSERT IGNORE INTO `log` SET - tableName = vTableName, - tableId = vNewId, - operation = 'insert'; + IF vOldId IS NOT NULL AND !(vOldId <=> vNewId) THEN + INSERT IGNORE INTO `log` SET + tableName = vTableName, + tableId = vOldId, + operation = 'delete'; + END IF; + + IF vNewId IS NOT NULL THEN + INSERT IGNORE INTO `log` SET + tableName = vTableName, + tableId = vNewId, + operation = 'insert'; END IF; IF vTableName = 'buy' THEN @@ -16210,7 +16353,7 @@ proc: BEGIN END IF; END IF; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -16478,29 +16621,29 @@ CREATE DEFINER=`root`@`%` PROCEDURE `log_refreshSale`( BEGIN DROP TEMPORARY TABLE IF EXISTS tValues; CREATE TEMPORARY TABLE tValues - ENGINE = MEMORY - SELECT - m.id saleFk, - m.ticketFk, - m.itemFk, - t.warehouseFk, - t.shipped, + ENGINE = MEMORY + SELECT + m.id saleFk, + m.ticketFk, + m.itemFk, + t.warehouseFk, + t.shipped, ABS(m.quantity) quantity, m.created, TIMESTAMPADD(DAY, tp.life, t.shipped) expired, m.quantity < 0 isIn, - m.isPicked OR s.alertLevel > 1 isPicked - FROM vn.sale m - JOIN vn.ticket t ON t.id = m.ticketFk + m.isPicked OR s.alertLevel > 1 isPicked + FROM vn.sale m + JOIN vn.ticket t ON t.id = m.ticketFk JOIN vn.ticketState s ON s.ticketFk = t.id JOIN vn.item i ON i.id = m.itemFk - JOIN vn.itemType tp ON tp.id = i.typeFk + JOIN vn.itemType tp ON tp.id = i.typeFk WHERE ( - vTableId IS NULL - OR (vTableName = 'ticket' AND t.id = vTableId) - OR (vTableName = 'sale' AND m.id = vTableId) - ) - AND t.shipped >= vn.getInventoryDate() + vTableId IS NULL + OR (vTableName = 'ticket' AND t.id = vTableId) + OR (vTableName = 'sale' AND m.id = vTableId) + ) + AND t.shipped >= vn.getInventoryDate() AND m.quantity != 0; REPLACE INTO inbound ( @@ -16533,7 +16676,7 @@ BEGIN FROM tValues WHERE !isIn; - DROP TEMPORARY TABLE tValues; + DROP TEMPORARY TABLE tValues; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -16947,7 +17090,7 @@ CREATE TABLE `debug` ( `variable` varchar(255) CHARACTER SET utf8 DEFAULT NULL, `value` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Log de depuración'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Log de depuración'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -18029,8 +18172,8 @@ CREATE TABLE `XDiario` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ASIEN` double DEFAULT NULL, `FECHA` datetime DEFAULT NULL, - `SUBCTA` varchar(12) COLLATE utf8_unicode_ci DEFAULT NULL, - `CONTRA` varchar(12) COLLATE utf8_unicode_ci DEFAULT NULL, + `SUBCTA` varchar(12) CHARACTER SET utf8 DEFAULT NULL, + `CONTRA` varchar(12) CHARACTER SET utf8 DEFAULT NULL, `CONCEPTO` varchar(50) CHARACTER SET utf8 DEFAULT NULL, `EURODEBE` decimal(10,2) DEFAULT NULL, `EUROHABER` decimal(10,2) DEFAULT NULL, @@ -18519,11 +18662,11 @@ DROP TABLE IF EXISTS `agencyTerm`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `agencyTerm` ( `agencyFk` smallint(5) unsigned NOT NULL, - `minimumPackages` int(11) DEFAULT NULL COMMENT 'numero minimo de bultos', - `kmPrice` decimal(10,2) DEFAULT NULL COMMENT 'precio extra por km', - `packagePrice` decimal(10,2) DEFAULT NULL COMMENT 'precio extra por bulto', + `minimumPackages` int(11) NOT NULL DEFAULT '0' COMMENT 'numero minimo de bultos', + `kmPrice` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT 'precio extra por km', + `packagePrice` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT 'precio extra por bulto', `routePrice` decimal(10,2) DEFAULT NULL COMMENT 'precio fijo por ruta', - `minimumKm` int(11) DEFAULT NULL, + `minimumKm` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`agencyFk`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -18775,6 +18918,21 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +-- +-- Temporary table structure for view `businessCalendar` +-- + +DROP TABLE IF EXISTS `businessCalendar`; +/*!50001 DROP VIEW IF EXISTS `businessCalendar`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `businessCalendar` AS SELECT + 1 AS `id`, + 1 AS `businessFk`, + 1 AS `absenceTypeFk`, + 1 AS `dated`*/; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `businessReasonEnd` -- @@ -18827,6 +18985,7 @@ CREATE TABLE `buy` ( `__cm2` int(10) unsigned NOT NULL DEFAULT '0', `ektFk` int(11) DEFAULT NULL, `weight` decimal(10,2) unsigned DEFAULT NULL, + `deliveryFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `CompresId_Trabajador` (`workerFk`), KEY `Id_Cubo` (`packageFk`), @@ -18834,6 +18993,9 @@ CREATE TABLE `buy` ( KEY `container_id` (`containerFk`), KEY `buy_edi_id` (`ektFk`), KEY `itemFk_entryFk` (`itemFk`,`entryFk`), + KEY `buy_fk_4_idx` (`deliveryFk`), + 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_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, @@ -19071,6 +19233,27 @@ CREATE TABLE `buyMark` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `calendar` +-- + +DROP TABLE IF EXISTS `calendar`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `calendar` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `businessFk` int(11) NOT NULL, + `dayOffTypeFk` int(11) NOT NULL, + `dated` date NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `business_id_date` (`businessFk`,`dated`), + KEY `calendar_employee_business_labour_id_idx` (`businessFk`), + KEY `calendar_employee_calendar_state_calendar_state_id_idx` (`dayOffTypeFk`), + KEY `id_index` (`id`), + CONSTRAINT `calendar_employee_state_id` FOREIGN KEY (`dayOffTypeFk`) REFERENCES `postgresql`.`calendar_state` (`calendar_state_id`) ON DELETE NO ACTION ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `calendarHolidays` -- @@ -19122,6 +19305,21 @@ CREATE TABLE `calendarHolidaysType` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `calendar__` +-- + +DROP TABLE IF EXISTS `calendar__`; +/*!50001 DROP VIEW IF EXISTS `calendar__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `calendar__` AS SELECT + 1 AS `id`, + 1 AS `businessFk`, + 1 AS `dayOffTypeFk`, + 1 AS `dated`*/; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `category` -- @@ -20972,24 +21170,26 @@ DROP TABLE IF EXISTS `delivery_zip`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `delivery_zip` ( - `postal_code` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, - `country_code` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, - `place_name` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, - `admin_name1` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, + `postal_code` varchar(2) COLLATE utf8_unicode_ci NOT NULL, + `country_code` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL, + `place_name` varchar(150) COLLATE utf8_unicode_ci NOT NULL, + `admin_name1` varchar(150) COLLATE utf8_unicode_ci NOT NULL, `code_name1` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, `admin_name2` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, - `code_name2` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, - `admin_name3` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, - `code_name3` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, - `latitude` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, - `longitude` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, - `accuracy` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, + `code_name2` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL, + `admin_name3` varchar(150) COLLATE utf8_unicode_ci NOT NULL, + `code_name3` varchar(5) COLLATE utf8_unicode_ci NOT NULL, + `latitude` varchar(10) COLLATE utf8_unicode_ci NOT NULL, + `longitude` varchar(10) COLLATE utf8_unicode_ci NOT NULL, + `accuracy` varchar(1) COLLATE utf8_unicode_ci NOT NULL, + `delivery_zipPK` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`delivery_zipPK`), KEY `country_code_idx` (`country_code`), KEY `place_name_idx` (`place_name`), KEY `postal_code_idx` (`postal_code`), KEY `admin_name3_idx` (`admin_name3`), KEY `admin_name2_idx` (`admin_name2`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -21016,6 +21216,7 @@ CREATE TABLE `department` ( `parentFk` int(10) unsigned DEFAULT NULL, `path` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `chatName` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `isTeleworking` tinyint(1) DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `name_UNIQUE` (`name`), KEY `fk_department_Trabajadores1_idx` (`workerFk`), @@ -22222,7 +22423,7 @@ CREATE TABLE `expeditionScan` ( UNIQUE KEY `expeditionFk_UNIQUE` (`expeditionFk`), KEY `expeditionScan_fk1_idx` (`expeditionFk`), KEY `expeditionScan_fk2_idx` (`palletFk`), - CONSTRAINT `expeditionScan_fk1` FOREIGN KEY (`expeditionFk`) REFERENCES `expedition` (`id`) ON UPDATE CASCADE, + CONSTRAINT `expeditionScan_fk1` FOREIGN KEY (`expeditionFk`) REFERENCES `expedition` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `expeditionScan_fk2` FOREIGN KEY (`palletFk`) REFERENCES `expeditionPallet` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -22427,6 +22628,20 @@ SET character_set_client = utf8; 1 AS `companyFk`*/; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `floramondoConfig` +-- + +DROP TABLE IF EXISTS `floramondoConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `floramondoConfig` ( + `id` int(11) NOT NULL, + `entryFk` int(11) DEFAULT NULL COMMENT 'ultima entrada de floramondo', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `fuelType` -- @@ -23113,10 +23328,12 @@ CREATE TABLE `item` ( `compression` decimal(5,2) NOT NULL DEFAULT '1.00' COMMENT 'Relacion de compresividad entre el volumen de las entradas en Silla y el empaquetado en los envios a clientes.\n\nMenor que 1 significa que se puede comprimir más que el volumen original.', `minimum` decimal(10,0) unsigned NOT NULL DEFAULT '3' COMMENT 'Cantidad máxima de cajas / cubos que cabe en un nicho', `upToDown` decimal(10,0) unsigned NOT NULL DEFAULT '0' COMMENT 'Se muestra el precio por kilo ', + `supplyResponseFk` int(11) DEFAULT NULL, `hasKgPrice` tinyint(1) NOT NULL DEFAULT '0', `sectorFk` int(11) DEFAULT '2', `isFloramondo` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), + UNIQUE KEY `item_supplyResponseFk_idx` (`supplyResponseFk`), KEY `Article` (`name`), KEY `Color` (`inkFk`), KEY `id_origen` (`originFk`), @@ -23133,15 +23350,16 @@ CREATE TABLE `item` ( CONSTRAINT `item_ibfk_4` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE, CONSTRAINT `item_ibfk_5` FOREIGN KEY (`typeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE, CONSTRAINT `item_ibfk_6` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `itemsupplyResponseFk` FOREIGN KEY (`supplyResponseFk`) REFERENCES `edi`.`supplyResponse` (`ID`) ON UPDATE CASCADE, CONSTRAINT `producer_id` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_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 = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!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 ;; @@ -23149,6 +23367,7 @@ DELIMITER ;; BEFORE INSERT ON `item` FOR EACH ROW BEGIN DECLARE vDensity DOUBLE; + DECLARE vCompression DOUBLE; IF NEW.density IS NULL THEN SELECT density INTO vDensity @@ -23156,7 +23375,13 @@ BEGIN SET NEW.density = vDensity; END IF; - + + IF NEW.compression IS NULL OR NEW.compression = 1 THEN + SELECT compression INTO vCompression + FROM itemType WHERE id = NEW.typeFk; + + SET NEW.compression = vCompression; + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -23532,6 +23757,21 @@ CREATE TABLE `itemFreeNumber` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `itemImageQueue` +-- + +DROP TABLE IF EXISTS `itemImageQueue`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemImageQueue` ( + `itemFk` int(11) NOT NULL, + `url` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + PRIMARY KEY (`itemFk`), + CONSTRAINT `itemImageQueueItemIdx` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Cola para añadir las imagenes al campo vn.item.image a partir de una url'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `itemLabel` -- @@ -24313,6 +24553,7 @@ CREATE TABLE `itemType` ( `hasComponents` tinyint(1) NOT NULL DEFAULT '1', `roleCodeFk__` varchar(14) COLLATE utf8_unicode_ci DEFAULT NULL, `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '1', + `compression` decimal(5,2) DEFAULT '1.00', PRIMARY KEY (`code`), UNIQUE KEY `tipo_id_UNIQUE` (`id`), UNIQUE KEY `Tipo_UNIQUE` (`name`,`categoryFk`), @@ -24432,10 +24673,36 @@ DROP TABLE IF EXISTS `kk`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `kk` ( - `pasillo` varchar(3) COLLATE utf8_unicode_ci NOT NULL + `pasillo` varchar(3) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`pasillo`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `labelInfo` +-- + +DROP TABLE IF EXISTS `labelInfo`; +/*!50001 DROP VIEW IF EXISTS `labelInfo`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `labelInfo` AS SELECT + 1 AS `itemId`, + 1 AS `itemName`, + 1 AS `colorCode`, + 1 AS `stems`, + 1 AS `category`, + 1 AS `productor`, + 1 AS `packing`, + 1 AS `warehouse_id`, + 1 AS `size`, + 1 AS `isPickedOff`, + 1 AS `notes`, + 1 AS `wh_in`, + 1 AS `entryId`, + 1 AS `buyId`*/; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `labourTree` -- @@ -24505,9 +24772,10 @@ DROP TABLE IF EXISTS `lungSize`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `lungSize` ( - `hora` time DEFAULT NULL, - `size` decimal(5,0) DEFAULT NULL, - `dia` date NOT NULL + `hora` time NOT NULL, + `size` decimal(5,0) NOT NULL, + `dia` date NOT NULL, + PRIMARY KEY (`hora`,`size`,`dia`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -25719,6 +25987,35 @@ CREATE TABLE `producer` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `productionVolume` +-- + +DROP TABLE IF EXISTS `productionVolume`; +/*!50001 DROP VIEW IF EXISTS `productionVolume`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `productionVolume` AS SELECT + 1 AS `hora`, + 1 AS `minuto`, + 1 AS `cm3`, + 1 AS `warehouseFk`, + 1 AS `created`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `productionVolume_LastHour` +-- + +DROP TABLE IF EXISTS `productionVolume_LastHour`; +/*!50001 DROP VIEW IF EXISTS `productionVolume_LastHour`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `productionVolume_LastHour` AS SELECT + 1 AS `m3`, + 1 AS `warehouseFk`*/; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `professionalCategory` -- @@ -25731,7 +26028,8 @@ CREATE TABLE `professionalCategory` ( `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `salary` decimal(10,2) DEFAULT NULL, `salaryorSeniority` decimal(10,2) DEFAULT NULL, - `year` int(2) DEFAULT NULL + `year` int(2) DEFAULT NULL, + PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -27527,12 +27825,13 @@ DROP TABLE IF EXISTS `tag`; CREATE TABLE `tag` ( `id` int(11) NOT NULL AUTO_INCREMENT, `code` varchar(45) CHARACTER SET utf8 DEFAULT NULL, - `name` varchar(35) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(25) COLLATE utf8_unicode_ci NOT NULL, `isFree` tinyint(1) NOT NULL DEFAULT '1', `isQuantitatif` tinyint(4) NOT NULL DEFAULT '0', `sourceTable` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `unit` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `ediTypeFk` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, + `overwrite` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'nombre del campo de item a sobreescribir con el valor del tag, hay que añadir el código correspondiente en item_refreshTags', PRIMARY KEY (`id`), UNIQUE KEY `tagNameIdx` (`name`,`ediTypeFk`), UNIQUE KEY `tagEdiTypeFkIdx` (`ediTypeFk`), @@ -27640,7 +27939,7 @@ DROP TABLE IF EXISTS `taxCode`; CREATE TABLE `taxCode` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `dated` date NOT NULL, - `code` varchar(10) COLLATE utf8_unicode_ci NOT NULL, + `code` varchar(10) CHARACTER SET utf8 NOT NULL, `taxTypeFk` tinyint(2) NOT NULL, `rate` decimal(4,1) NOT NULL DEFAULT '0.0', `equalizationTax` decimal(4,1) NOT NULL DEFAULT '0.0', @@ -27793,14 +28092,11 @@ BEGIN FROM state WHERE `code` = vStateCode COLLATE utf8_general_ci; - -- Borrar al acabar el proceso de cambio de nichos a carros - /* IF NEW.warehouseFk IN (1,44) THEN - - INSERT INTO vn.ticketObservation(ticketFk, description, observationTypeFk) - VALUES(NEW.id,'NO OLVIDES ESCANEAR LAS MATRICULAS',1) - ON DUPLICATE KEY UPDATE description = CONCAT(description,'. Y NO OLVIDES ESCANEAR LAS MATRICULAS'); - - END IF; */ + IF YEAR(NEW.shipped) > 2000 THEN + INSERT INTO bs.clientNewBorn(clientFk, firstShipped, lastShipped) + VALUES(NEW.clientFk, NEW.shipped, NEW.shipped) + ON DUPLICATE KEY UPDATE lastShipped = NEW.shipped; + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -27810,9 +28106,9 @@ 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 = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!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 ;; @@ -28567,6 +28863,49 @@ CREATE TABLE `tillConfig` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `time` +-- + +DROP TABLE IF EXISTS `time`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `time` ( + `dated` date NOT NULL, + `period` int(6) NOT NULL, + `month` int(2) NOT NULL, + `year` int(4) NOT NULL, + `day` int(2) NOT NULL, + `week` int(2) NOT NULL, + `yearMonth` int(6) NOT NULL, + PRIMARY KEY (`dated`), + KEY `day_index` (`day`) USING HASH, + KEY `week_index` (`week`) USING HASH, + KEY `year_index` (`year`) USING HASH, + KEY `month_index` (`month`) USING HASH, + KEY `periodo` (`period`) USING HASH, + KEY `yearMonth` (`yearMonth`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tabla de referencia para las semanas, años y meses'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `time__` +-- + +DROP TABLE IF EXISTS `time__`; +/*!50001 DROP VIEW IF EXISTS `time__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `time__` AS SELECT + 1 AS `dated`, + 1 AS `period`, + 1 AS `month`, + 1 AS `year`, + 1 AS `day`, + 1 AS `week`, + 1 AS `yearMonth`*/; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `town` -- @@ -29250,6 +29589,7 @@ CREATE TABLE `worker` ( `bossFk` int(11) NOT NULL DEFAULT '103', `fiDueDate` datetime DEFAULT NULL, `hasMachineryAutorized` tinyint(2) DEFAULT '0', + `seniority` date DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `CodigoTrabajador_UNIQUE` (`code`), UNIQUE KEY `user` (`user__`), @@ -29640,6 +29980,7 @@ CREATE TABLE `workerTimeControl` ( `order` int(11) DEFAULT NULL, `warehouseFk` smallint(6) unsigned DEFAULT NULL, `direction` enum('in','out','middle') COLLATE utf8_unicode_ci DEFAULT 'middle', + `isSendMail` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Fichadas generadas autómaticamente con el procedimiento vn.workerTimeControl_sendMail', PRIMARY KEY (`id`), UNIQUE KEY `userFk_Timed_uniq` (`userFk`,`timed`), KEY `warehouseFkfk1_idx` (`warehouseFk`), @@ -29681,6 +30022,27 @@ CREATE TABLE `workerTimeControlLog` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Log de fichadas, se rellena cuando el fichador(tablet) no autoriza el fichaje (PROC:vn.workerTimeControl_check)'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `workerTimeControlMail` +-- + +DROP TABLE IF EXISTS `workerTimeControlMail`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `workerTimeControlMail` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `workerFk` int(10) NOT NULL, + `year` int(4) NOT NULL, + `week` int(2) NOT NULL, + `state` enum('SENDED','CONFIRMED','ANSWERED') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'SENDED', + `updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Fecha/hora último cambio de estado', + PRIMARY KEY (`id`), + UNIQUE KEY `workerFk_UNIQUE` (`workerFk`,`year`,`week`), + KEY `workerFk_idx` (`workerFk`), + CONSTRAINT `workerTimeControlMail_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Guarda las respuestas de mail de los correos generados automáticamente por la procedimiento workerTimeControl_sendMail'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `workerTimeControlParams` -- @@ -30081,7 +30443,7 @@ CREATE TABLE `zoneEvent` ( `bonus` decimal(10,2) DEFAULT NULL, `m3Max` decimal(10,2) unsigned DEFAULT NULL, PRIMARY KEY (`id`), - KEY `zoneFk` (`zoneFk`), + UNIQUE KEY `zoneFk` (`zoneFk`,`type`,`dated`), CONSTRAINT `zoneEvent_ibfk_1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -30328,97 +30690,97 @@ 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 = utf8 */ ;; +/*!50003 SET character_set_results = utf8 */ ;; +/*!50003 SET collation_connection = utf8_general_ci */ ;; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `printQueue_check` ON SCHEDULE EVERY 10 MINUTE STARTS '2019-11-08 00:00:00' ON COMPLETION PRESERVE ENABLE COMMENT 'Notifica en caso de que el servidor de impresión este parado' DO BEGIN - - DECLARE vCurrentCount INT; - DECLARE vCheckSum INT; - DECLARE vIsAlreadyNotified BOOLEAN; - DECLARE vTableQueue TEXT; - DECLARE vLineQueue TEXT; - DECLARE vDone BOOL DEFAULT FALSE; - DECLARE vCur CURSOR FOR - SELECT CONCAT(' - ', IFNULL(pq.id, ''), ' - ', IFNULL(p.path, ''),' - ', IFNULL(i.Informe, ''),' - ', IFNULL(e.Estado, ''),' - ', IFNULL(w.firstname, ''), " ", IFNULL(w.lastName, ''),' - ', IFNULL(pq.`error`, ''),' - ') - FROM vn.printingQueue pq - LEFT JOIN vn.worker w ON w.id = pq.worker - LEFT JOIN vn.printer p ON p.id = pq.printer - LEFT JOIN vn2008.Informes i ON i.Id_Informe = pq.report - JOIN vn2008.Estados e ON e.Id_Estado = pq.state - LIMIT 30; - - DECLARE CONTINUE HANDLER FOR NOT FOUND - SET vDone = TRUE; - - SELECT COUNT(*), IFNULL(SUM(id),0) INTO vCurrentCount, vCheckSum - FROM vn.printingQueue WHERE state = 1; - - SELECT isAlreadyNotified INTO vIsAlreadyNotified - FROM printingQueueCheck; - - IF (SELECT lastCount FROM printingQueueCheck) = vCurrentCount AND - (SELECT lastCheckSum FROM printingQueueCheck) = vCheckSum AND - vIsAlreadyNotified = FALSE AND vCurrentCount > 0 - THEN - - SELECT ' - - - - - - - - ' INTO vTableQueue; - - OPEN vCur; - - l: LOOP - - SET vDone = FALSE; - - FETCH vCur INTO vLineQueue; - - IF vDone THEN - LEAVE l; - END IF; - - SELECT CONCAT(vTableQueue, vLineQueue) INTO vTableQueue; - - END LOOP; - - CLOSE vCur; - - INSERT INTO vn2008.mail (`to`, subject, text) - VALUES ('cau@verdnatura.es, sysadmin@verdnatura.es', - 'servidor de impresion parado', - CONCAT('Hay ', vCurrentCount, ' lineas bloqueadas', vTableQueue, '
Id ColaRuta ImpresoraInformeEstadoTrabajadorError
')); - - UPDATE printingQueueCheck SET isAlreadyNotified = TRUE; - END IF; - - IF (SELECT lastCount FROM printingQueueCheck) > vCurrentCount AND - vIsAlreadyNotified = TRUE - THEN - UPDATE printingQueueCheck SET isAlreadyNotified = FALSE; - END IF; - - UPDATE printingQueueCheck - SET lastCount = vCurrentCount, - lastCheckSum = vCheckSum; - +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `printQueue_check` ON SCHEDULE EVERY 10 MINUTE STARTS '2019-11-08 00:00:00' ON COMPLETION PRESERVE ENABLE COMMENT 'Notifica en caso de que el servidor de impresión este parado' DO BEGIN + + DECLARE vCurrentCount INT; + DECLARE vCheckSum INT; + DECLARE vIsAlreadyNotified BOOLEAN; + DECLARE vTableQueue TEXT; + DECLARE vLineQueue TEXT; + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vCur CURSOR FOR + SELECT CONCAT(' + ', IFNULL(pq.id, ''), ' + ', IFNULL(p.path, ''),' + ', IFNULL(i.Informe, ''),' + ', IFNULL(e.Estado, ''),' + ', IFNULL(w.firstname, ''), " ", IFNULL(w.lastName, ''),' + ', IFNULL(pq.`error`, ''),' + ') + FROM vn.printingQueue pq + LEFT JOIN vn.worker w ON w.id = pq.worker + LEFT JOIN vn.printer p ON p.id = pq.printer + LEFT JOIN vn2008.Informes i ON i.Id_Informe = pq.report + JOIN vn2008.Estados e ON e.Id_Estado = pq.state + LIMIT 30; + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + SELECT COUNT(*), IFNULL(SUM(id),0) INTO vCurrentCount, vCheckSum + FROM vn.printingQueue WHERE state = 1; + + SELECT isAlreadyNotified INTO vIsAlreadyNotified + FROM printingQueueCheck; + + IF (SELECT lastCount FROM printingQueueCheck) = vCurrentCount AND + (SELECT lastCheckSum FROM printingQueueCheck) = vCheckSum AND + vIsAlreadyNotified = FALSE AND vCurrentCount > 0 + THEN + + SELECT ' + + + + + + + + ' INTO vTableQueue; + + OPEN vCur; + + l: LOOP + + SET vDone = FALSE; + + FETCH vCur INTO vLineQueue; + + IF vDone THEN + LEAVE l; + END IF; + + SELECT CONCAT(vTableQueue, vLineQueue) INTO vTableQueue; + + END LOOP; + + CLOSE vCur; + + INSERT INTO vn2008.mail (`to`, subject, text) + VALUES ('cau@verdnatura.es, sysadmin@verdnatura.es', + 'servidor de impresion parado', + CONCAT('Hay ', vCurrentCount, ' lineas bloqueadas', vTableQueue, '
Id ColaRuta ImpresoraInformeEstadoTrabajadorError
')); + + UPDATE printingQueueCheck SET isAlreadyNotified = TRUE; + END IF; + + IF (SELECT lastCount FROM printingQueueCheck) > vCurrentCount AND + vIsAlreadyNotified = TRUE + THEN + UPDATE printingQueueCheck SET isAlreadyNotified = FALSE; + END IF; + + UPDATE printingQueueCheck + SET lastCount = vCurrentCount, + lastCheckSum = vCheckSum; + END */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; @@ -30466,9 +30828,9 @@ 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 = utf8 */ ;; +/*!50003 SET character_set_results = utf8 */ ;; +/*!50003 SET collation_connection = utf8_general_ci */ ;; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; @@ -30484,9 +30846,9 @@ 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 = utf8 */ ;; +/*!50003 SET character_set_results = utf8 */ ;; +/*!50003 SET collation_connection = utf8_general_ci */ ;; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; @@ -31045,11 +31407,94 @@ BEGIN CALL vn.ticketGetTotal; SELECT IFNULL(SUM(t.amount), 0) INTO vDebt - FROM ( - SELECT SUM(total) amount + FROM ( + SELECT SUM(IFNULL(total,0)) amount FROM tmp.ticketTotal + UNION ALL + SELECT SUM(amountPaid) amount + FROM receipt + WHERE clientFk = vClient + AND payed > vDateEnd UNION ALL - SELECT SUM(amountPaid) + SELECT SUM(amount) + FROM clientRisk + WHERE clientFk = vClient + UNION ALL + SELECT CAST(-SUM(amount) / 100 AS DECIMAL(10,2)) + FROM hedera.tpvTransaction + WHERE clientFk = vClient + AND receiptFk IS NULL + AND `status` = 'ok' + ) t; + + DROP TEMPORARY TABLE IF EXISTS + tmp.ticket, + tmp.ticketTotal; + + 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 `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 = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` FUNCTION `clientGetDebt__`(vClient INT, vDate DATE) RETURNS decimal(10,2) + READS SQL DATA +BEGIN +/** + * Devuelve el saldo de un cliente. + * + * @param vClient Identificador del cliente + * @param vDate Fecha hasta la que tener en cuenta + * @return Saldo del cliente + */ + DECLARE vDateEnd DATETIME; + DECLARE vDateIni DATETIME; + DECLARE vDebt DECIMAL(10,2); + DECLARE vHasDebt BOOLEAN; + + SELECT COUNT(*) INTO vHasDebt + FROM `client` c + WHERE c.id = vClient AND c.typeFk = 'normal'; + + IF NOT vHasDebt THEN + RETURN 0; + END IF; + + SET vDate = IFNULL(vDate, CURDATE()); + + SET vDateIni = TIMESTAMPADD(MONTH, -2, CURDATE()); + SET vDateEnd = TIMESTAMP(vDate, '23:59:59'); + + DROP TEMPORARY TABLE IF EXISTS tmp.ticket; + CREATE TEMPORARY TABLE tmp.ticket + (INDEX (ticketFk)) + ENGINE = MEMORY + SELECT id ticketFk + FROM ticket + WHERE clientFk = vClient + AND refFk IS NULL + AND shipped BETWEEN vDateIni AND vDateEnd; + + CALL vn.ticketGetTotal; + + SELECT IFNULL(SUM(t.amount), 0) INTO vDebt + FROM ( + + SELECT SUM(IFNULL(total,0)) amount + FROM tmp.ticketTotal + UNION ALL + SELECT SUM(amountPaid) amount FROM receipt WHERE clientFk = vClient AND payed > vDateEnd @@ -31701,17 +32146,18 @@ 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 `floramondoNewItemFk` */; +/*!50003 DROP FUNCTION IF EXISTS `floramondoNewItemFk__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!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 ;; -CREATE DEFINER=`root`@`%` FUNCTION `floramondoNewItemFk`() RETURNS int(11) +CREATE DEFINER=`root`@`%` FUNCTION `floramondoNewItemFk__`() RETURNS int(11) + DETERMINISTIC BEGIN DECLARE vItemFk INT; @@ -31722,6 +32168,112 @@ BEGIN RETURN 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 FUNCTION IF EXISTS `floramondo_getEntry` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!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 ;; +CREATE DEFINER=`root`@`%` FUNCTION `floramondo_getEntry`(vLanded DATE) RETURNS int(11) + READS SQL DATA +BEGIN + + DECLARE vTravelFk INT; + DECLARE vEntryFk INT; + DECLARE previousEntryFk INT; + + SET vTravelFk = floramondo_getTravel(vLanded); + + IF vLanded THEN + SELECT IFNULL(MAX(id),0) INTO vEntryFk + FROM vn.entry + WHERE travelFk = vTravelFk AND isRaid; + + IF NOT vEntryFk THEN + + INSERT INTO vn.entry(travelFk, supplierFk, commission, companyFk, currencyFk, isRaid) + SELECT vTravelFk, s.id, 4, c.id, cu.id, TRUE + FROM vn.supplier s + JOIN vn.company c ON c.code = 'VNL' + JOIN vn.currency cu ON cu.code = 'EUR' + WHERE s.name = 'KONINKLIJE COOPERATIEVE BLOEMENVEILING FLORAHOLLAN'; + + SELECT MAX(id) INTO vEntryFk + FROM vn.entry + WHERE travelFk = vTravelFk; + + END IF; + END IF; + SELECT entryFk INTO previousEntryFk FROM floramondoConfig; + IF NOT (previousEntryFk <=> vEntryFk) THEN + DELETE FROM buy WHERE entryFk = previousEntryFk; + REPLACE INTO floramondoConfig SET entryFk = vEntryFk; + END IF; + + RETURN vEntryFk; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_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 `floramondo_getTravel` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!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 ;; +CREATE DEFINER=`root`@`%` FUNCTION `floramondo_getTravel`(vLanded DATE) RETURNS int(11) + READS SQL DATA +BEGIN + + DECLARE vTravelFk INT; + DECLARE vWarehouseOutName VARCHAR(50) DEFAULT 'Holanda'; + DECLARE vWarehouseInName VARCHAR(50) DEFAULT 'VNH'; + + IF vLanded THEN + SELECT IFNULL(MAX(tr.id),0) INTO vTravelFk + FROM vn.travel tr + JOIN vn.warehouse wIn ON wIn.id = tr.warehouseInFk + JOIN vn.warehouse wOut ON wOut.id = tr.warehouseOutFk + WHERE wIn.name = vWarehouseInName + AND wOut.name = vWarehouseOutName + AND landed = vLanded; + + IF NOT vTravelFk THEN + + INSERT INTO vn.travel(landed, shipped, warehouseInFk, warehouseOutFk, agencyFk) + SELECT vLanded, curdate(), wIn.id, wOut.id, am.id + FROM vn.warehouse wIn + JOIN vn.warehouse wOut ON wOut.name = vWarehouseOutName + JOIN vn.agencyMode am ON am.name = 'HOLANDA DIRECTO' + WHERE wIn.name = vWarehouseInName; + + SELECT MAX(tr.id) INTO vTravelFk + FROM vn.travel tr + JOIN vn.warehouse wIn ON wIn.id = tr.warehouseInFk + JOIN vn.warehouse wOut ON wOut.id = tr.warehouseOutFk + WHERE wIn.name = vWarehouseInName + AND wOut.name = vWarehouseOutName + AND landed = vLanded; + END IF; + END IF; + RETURN vTravelFk; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -32928,7 +33480,7 @@ BEGIN SELECT SUM(IF(p.volume > 0, p.volume, - p.width * p.depth * IF(p.height, p.height, i.size + 10) + p.width * p.depth * IF(p.height, p.height, IFNULL(i.size,60) + 10) )) INTO vVolume FROM packaging p JOIN item i ON i.id = vSelf @@ -33128,7 +33680,7 @@ BEGIN DECLARE vWarehouseId INTEGER; DECLARE vVolume DECIMAL(10,3); - SELECT IFNULL(SUM(o.amount * i.compression * ic.cm3)/1000000,0) INTO vVolume + SELECT IFNULL(SUM(o.amount * ic.cm3delivery)/1000000,0) INTO vVolume FROM hedera.orderRow o JOIN item i ON i.id = o.itemFk JOIN itemCost ic on ic.itemFk = o.itemFk AND ic.warehouseFk = o.warehouseFk @@ -34687,10 +35239,24 @@ BEGIN WHERE i.id = vItemFk; IF vIsMerchandise THEN - REPLACE itemCost SET + + REPLACE itemCost SET itemFk = vItemFk, warehouseFk = vWarehouse, cm3 = buy_getUnitVolume(vSelf); + + UPDATE vn.itemCost ic + JOIN vn.item i ON i.id = ic.itemFk + SET ic.cm3delivery = i.compression * ic.cm3 + WHERE ic.itemFk = vItemFk AND + ic.warehouseFk = vWarehouse; + + UPDATE vn.itemCost ic + JOIN cache.last_buy lb ON lb.item_id = ic.itemFk AND lb.warehouse_id = ic.warehouseFk + JOIN vn.buy b ON b.id = lb.buy_id + SET ic.grams = b.weight * 1000 / b.packing + WHERE ic.itemFk = vItemFk AND + ic.warehouseFk = vWarehouse; END IF; SELECT isFeedStock INTO vIsFeedStock @@ -34798,6 +35364,88 @@ BEGIN 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 `buy_afterUpsert___` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!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 ;; +CREATE DEFINER=`root`@`%` PROCEDURE `buy_afterUpsert___`(vSelf INT) +BEGIN +/** + * Triggered actions when a buy is updated or inserted. + * + * @param vSelf The buy reference + */ + DECLARE vEntryFk INT; + DECLARE vItemFk INT; + DECLARE vStickers INT; + DECLARE vPacking INT; + DECLARE vWarehouse INT; + DECLARE vWarehouseOut INT; + DECLARE vIsMerchandise BOOL; + DECLARE vIsFeedStock BOOL; + + + SELECT entryFk, itemFk, stickers, packing + INTO vEntryFk, vItemFk, vStickers, vPacking + FROM buy + WHERE id = vSelf; + + SELECT t.warehouseInFk, t.warehouseOutFk + INTO vWarehouse, vWarehouseOut + FROM entry e + JOIN travel t ON t.id = e.travelFk + WHERE e.id = vEntryFk; + + SELECT k.merchandise + INTO vIsMerchandise + FROM itemCategory k + JOIN itemType it ON it.categoryFk = k.id + JOIN item i ON i.typeFk = it.id + WHERE i.id = vItemFk; + + IF vIsMerchandise THEN + + REPLACE itemCost SET + itemFk = vItemFk, + warehouseFk = vWarehouse, + cm3 = buy_getUnitVolume(vSelf); + + UPDATE vn.itemCost ic + JOIN vn.item i ON i.id = ic.itemFk + SET ic.cm3delivery = i.compression * ic.cm3 + WHERE ic.itemFk = vItemFk + AND ic.warehouseFk = vWarehouse; + + END IF; + + SELECT isFeedStock INTO vIsFeedStock + FROM warehouse WHERE id = vWarehouseOut AND id <> 13; + + IF vIsFeedStock THEN + INSERT IGNORE INTO producer(`name`) + SELECT es.company_name + FROM buy b + JOIN edi.ekt be ON be.id = b.ektFk + JOIN edi.supplier es ON es.supplier_id = be.pro + WHERE b.id = vSelf; + + IF buy_hasNotifyPassport(vSelf, vItemFk) THEN + CALL vn.buy_notifyPassport(vSelf, vItemFk, vStickers, vPacking); + END IF; + END IF; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -35686,10 +36334,10 @@ proc: BEGIN tcc.itemFk, vDeliveryComponent, vGeneralInflationCoefficient - * ROUND(ic.cm3 * IFNULL((zo.price - zo.bonus),50) / vBoxVolume, 4) cost + * ROUND(ic.cm3delivery * IFNULL((zo.price - zo.bonus),50) / vBoxVolume, 4) cost /* * ROUND(( - i.compression -- PAK 2020/06/19 ic.cm3 ya incorpora el volumen de entrada multiplicado por la compresion + i.compression -- PAK 2020/06/19 * ic.cm3 * IF(am.deliveryMethodFk = 1, (GREATEST(i.density, vMinimumDensityWeight) / vMinimumDensityWeight), 1) -- el packingOut soluciona este problema * IFNULL((zo.price - zo.bonus) @@ -36137,9 +36785,9 @@ 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_general_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -36190,6 +36838,7 @@ BEGIN JOIN travel t ON t.id = e.travelFk WHERE t.landed <= vDateShort; DELETE FROM stowaway WHERE created < v3Month; + DELETE FROM vn.buy WHERE created < vDateShort AND entryFk = 9200; -- Equipos duplicados DELETE w.* @@ -37067,54 +37716,54 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `clientRemoveWorker__`() -BEGIN - DECLARE done BOOL DEFAULT FALSE; - DECLARE vClientFk INT; - - DECLARE rs CURSOR FOR - SELECT c.clientFk - FROM tmp.clientGetDebt c - LEFT JOIN tmp.risk r ON r.clientFk = c.clientFk - WHERE IFNULL(r.risk,0) = 0; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; - - DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt; - CREATE TEMPORARY TABLE tmp.clientGetDebt - SELECT cd.id as clientFk - FROM bs.clientDied cd - LEFT JOIN vn.clientProtected cp ON cp.clientFk = cd.id - JOIN vn.client c ON c.id = cd.id - JOIN vn.province p ON p.id = c.provinceFk - JOIN vn.country co ON co.id = p.countryFk - WHERE cd.Aviso = 'TERCER AVISO' - AND cp.clientFk IS NULL - AND co.country NOT IN ('Portugal','Francia','España exento') - AND c.salesPersonFk IS NOT NULL; - - CALL vn.clientGetDebt(curdate()); - - DROP TEMPORARY TABLE IF EXISTS tmp.contador; - CREATE TEMPORARY TABLE tmp.contador (id INT) - ENGINE = MEMORY; - - OPEN rs; - FETCH rs INTO vClientFk; - - WHILE NOT done DO - INSERT INTO tmp.contador SET id = vClientFk; - CALL vn.clientGreugeSpray(vClientFk, TRUE, '',TRUE); +BEGIN + DECLARE done BOOL DEFAULT FALSE; + DECLARE vClientFk INT; + + DECLARE rs CURSOR FOR + SELECT c.clientFk + FROM tmp.clientGetDebt c + LEFT JOIN tmp.risk r ON r.clientFk = c.clientFk + WHERE IFNULL(r.risk,0) = 0; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; + + DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt; + CREATE TEMPORARY TABLE tmp.clientGetDebt + SELECT cd.id as clientFk + FROM bs.clientDied cd + LEFT JOIN vn.clientProtected cp ON cp.clientFk = cd.id + JOIN vn.client c ON c.id = cd.id + JOIN vn.province p ON p.id = c.provinceFk + JOIN vn.country co ON co.id = p.countryFk + WHERE cd.Aviso = 'TERCER AVISO' + AND cp.clientFk IS NULL + AND co.country NOT IN ('Portugal','Francia','España exento') + AND c.salesPersonFk IS NOT NULL; + + CALL vn.clientGetDebt(curdate()); + + DROP TEMPORARY TABLE IF EXISTS tmp.contador; + CREATE TEMPORARY TABLE tmp.contador (id INT) + ENGINE = MEMORY; + + OPEN rs; + FETCH rs INTO vClientFk; + + WHILE NOT done DO + INSERT INTO tmp.contador SET id = vClientFk; + CALL vn.clientGreugeSpray(vClientFk, TRUE, '',TRUE); UPDATE vn.client SET salesPersonFk = NULL WHERE id = vClientFk; INSERT INTO vn.clientLog (originFk, userFk, `action`, description) VALUES (vClientFk, account.userGetId(), 'update', CONCAT('Se ha desasignado el cliente por que no ha comprado en 3 meses')); - + REPLACE bs.clientNewBorn(clientFk, shipped) - VALUES(vClientFk, CURDATE()); - FETCH rs INTO vClientFk; - END WHILE; - - CLOSE rs; + VALUES(vClientFk, CURDATE()); + FETCH rs INTO vClientFk; + END WHILE; + + CLOSE rs; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -37480,6 +38129,198 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `collectionSale_get`(vCollectionFk INT) +BEGIN + + DROP TEMPORARY TABLE IF EXISTS tmp.ticket; + CREATE TEMPORARY TABLE tmp.ticket + SELECT t.id, clientFk, id as showTicketFk + FROM vn.ticket t + WHERE id = vCollectionFk + AND shipped > '2020-01-01' + UNION ALL + SELECT tc.ticketFk id, clientFk, tc.ticketFk as showTicketFk + FROM vn.ticketCollection tc + JOIN vn.ticket t ON t.id = tc.ticketFk + WHERE tc.collectionFk = vCollectionFk; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticket2; + CREATE TEMPORARY TABLE tmp.ticket2 + SELECT sw.id, t.clientFk, sw.shipFk showTicketFk + FROM vn.stowaway sw + JOIN tmp.ticket t ON t.id = sw.shipFk; + + INSERT INTO tmp.ticket + SELECT * FROM tmp.ticket2; + + SELECT showTicketFk ticketFk, + s.id as saleFk, + s.itemFk, + s.quantity, + i.longName, + i.size, + s.reserved, + MAX(IF(st.semaphore <=> 1, TRUE, FALSE)) as isPreviousPrepared, + MAX(IF(st.semaphore <=> 2, TRUE, FALSE)) as isPrepared, + MAX(IF(st.semaphore <=> 3, TRUE, FALSE)) as isControlled, + ic.color, + ip.productor, + s.discount, + s.price, + i.stems, + i.category, + o.code AS origin, + t.clientFk, + s.originalQuantity, + TRIM(CONCAT(LPAD(i.longName,30,' '), ' ',RPAD(IFNULL(i.size,''),5,' '))) as line1, + TRIM(CONCAT(LPAD(IFNULL(ip.productor,''),30,' '), ' ',LPAD(IFNULL(o.code,''),4,' '))) as line2, + TRIM(CONCAT(ic.color, IF(MAX(IF(st.semaphore <=> 1, TRUE, FALSE)) AND t.id != t.showTicketFk, CONCAT(' [ TICKET ',t.id,' ] '),''), IFNULL(LPAD(st.parkingCode,40,' '),''))) as line3, + s.isAdded, + str.originalQuantity as startQuantity, -- eliminar cuando tengamos la nueva apk + c.workerFk, + IFNULL(SUM(iss.quantity),0) as pickedQuantity + FROM vn.sale s + JOIN tmp.ticket t ON t.id = s.ticketFk + JOIN vn.item i ON i.id = s.itemFk + LEFT JOIN vn.saleTracking str ON str.saleFk = s.id AND str.isChecked = 1 + LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id + LEFT JOIN vn.state st ON st.id = str.stateFk + LEFT JOIN vn.itemColor ic ON ic.itemFk = s.itemFk + LEFT JOIN vn.itemProductor ip ON ip.itemFk = s.itemFk + LEFT JOIN vn.origin o ON o.id = i.originFk + LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = t.id + LEFT JOIN vn.collection c ON c.id = tc.collectionFk + LEFT JOIN (SELECT st.saleFk, p.`code` as parkingCode + FROM vn.saleTracking st + JOIN vn.state s ON s.id = st.stateFk + JOIN vn.sale sa ON sa.id = st.saleFk + JOIN vn.ticketParking tp ON tp.ticketFk = sa.ticketFk + JOIN vn.parking p ON p.id = tp.parkingFk + WHERE st.isChecked + AND s.semaphore = 1 + GROUP BY st.saleFk) st ON st.saleFk = s.id + GROUP BY s.id + HAVING quantity > 0 OR workerFk != vn.getUser() + ; + + + + DROP TEMPORARY TABLE tmp.ticket; + DROP TEMPORARY TABLE tmp.ticket2; + + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_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 `collectionSale_get_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 = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `collectionSale_get_beta`(vCollectionFk INT) +BEGIN + + DROP TEMPORARY TABLE IF EXISTS tmp.ticket; + CREATE TEMPORARY TABLE tmp.ticket + SELECT t.id, clientFk, id as showTicketFk + FROM vn.ticket t + WHERE id = vCollectionFk + AND shipped > '2020-01-01' + UNION ALL + SELECT tc.ticketFk id, clientFk, tc.ticketFk as showTicketFk + FROM vn.ticketCollection tc + JOIN vn.ticket t ON t.id = tc.ticketFk + WHERE tc.collectionFk = vCollectionFk; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticket2; + CREATE TEMPORARY TABLE tmp.ticket2 + SELECT sw.id, t.clientFk, sw.shipFk showTicketFk + FROM vn.stowaway sw + JOIN tmp.ticket t ON t.id = sw.shipFk; + + INSERT INTO tmp.ticket + SELECT * FROM tmp.ticket2; + + SELECT showTicketFk ticketFk, + s.id as saleFk, + s.itemFk, + s.quantity, + i.longName, + i.size, + s.reserved, + MAX(IF(st.semaphore <=> 1, TRUE, FALSE)) as isPreviousPrepared, + MAX(IF(st.semaphore <=> 2, TRUE, FALSE)) as isPrepared, + MAX(IF(st.semaphore <=> 3, TRUE, FALSE)) as isControlled, + ic.color, + ip.productor, + s.discount, + s.price, + i.stems, + i.category, + o.code AS origin, + t.clientFk, + s.originalQuantity, + TRIM(CONCAT(LPAD(i.longName,30,' '), ' ',RPAD(IFNULL(i.size,''),5,' '))) as line1, + TRIM(CONCAT(LPAD(IFNULL(ip.productor,''),30,' '), ' ',LPAD(IFNULL(o.code,''),4,' '))) as line2, + TRIM(CONCAT(ic.color, IF(MAX(IF(st.semaphore <=> 1, TRUE, FALSE)) AND t.id != t.showTicketFk, CONCAT(' [ TICKET ',t.id,' ] '),''), IFNULL(LPAD(st.parkingCode,40,' '),''))) as line3, + s.isAdded, + str.originalQuantity as startQuantity, + c.workerFk, + IFNULL(SUM(iss.quantity),0) as pickedQuantity + FROM vn.sale s + JOIN tmp.ticket t ON t.id = s.ticketFk + JOIN vn.item i ON i.id = s.itemFk + LEFT JOIN vn.saleTracking str ON str.saleFk = s.id AND str.isChecked = 1 + LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id + LEFT JOIN vn.state st ON st.id = str.stateFk + LEFT JOIN vn.itemColor ic ON ic.itemFk = s.itemFk + LEFT JOIN vn.itemProductor ip ON ip.itemFk = s.itemFk + LEFT JOIN vn.origin o ON o.id = i.originFk + LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = t.id + LEFT JOIN vn.collection c ON c.id = tc.collectionFk + LEFT JOIN (SELECT st.saleFk, p.`code` as parkingCode + FROM vn.saleTracking st + JOIN vn.state s ON s.id = st.stateFk + JOIN vn.sale sa ON sa.id = st.saleFk + JOIN vn.ticketParking tp ON tp.ticketFk = sa.ticketFk + JOIN vn.parking p ON p.id = tp.parkingFk + WHERE st.isChecked + AND s.semaphore = 1 + GROUP BY st.saleFk) st ON st.saleFk = s.id + GROUP BY s.id + HAVING quantity > 0 OR workerFk != vn.getUser() + ; + + + + DROP TEMPORARY TABLE tmp.ticket; + DROP TEMPORARY TABLE tmp.ticket2; + + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_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 `collectionSale_get__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `collectionSale_get__`(vCollectionFk INT) BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket; @@ -37613,9 +38454,9 @@ 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 = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!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 ;; @@ -37624,12 +38465,12 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket; CREATE TEMPORARY TABLE tmp.ticket - SELECT t.id, t.clientFk, t.warehouseFk, t.zoneFk + SELECT t.id, t.clientFk, t.warehouseFk, t.zoneFk,t.observations FROM vn.ticket t WHERE id = vCollectionFk AND t.shipped > '2020-01-01' UNION ALL - SELECT t.id, t.clientFk, t.warehouseFk, t.zoneFk + SELECT t.id, t.clientFk, t.warehouseFk, t.zoneFk,t.observations FROM vn.ticketCollection tc JOIN vn.ticket t ON t.id = tc.ticketFk WHERE tc.collectionFk = vCollectionFk; @@ -37638,13 +38479,15 @@ BEGIN IFNULL(tc.wagon * 100 + tc.level,0) `level`, am.name as agencyName, t.warehouseFk , - w.id as salesPersonFk + w.id as salesPersonFk, + IFNULL(tob.description,'')as observaciones FROM tmp.ticket t LEFT JOIN vn.ticketCollection tc ON t.id = tc.ticketFk LEFT JOIN vn.zone z ON z.id = t.zoneFk LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk LEFT JOIN vn.client c ON c.id = t.clientFk - LEFT JOIN vn.worker w ON w.id = c.salesPersonFk; + LEFT JOIN vn.worker w ON w.id = c.salesPersonFk + LEFT JOIN vn.ticketObservation tob ON tob.ticketFk = t.id AND tob.observationTypeFk = 1; END ;; DELIMITER ; @@ -38017,19 +38860,19 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `collection_addItem`(vItemFk INT, vQuantity INT, vTicketFk INT) BEGIN DECLARE vConcept VARCHAR(50); - DECLARE vPrice DOUBLE default 0.0; DECLARE itemFk INT; + DECLARE vSaleFk INT default 0; SELECT barcodeToItem(vItemFk) INTO itemFk; SELECT CONCAT(vn.getUser()," ",DATE_FORMAT(NOW( ), "%H:%i" )," ",i.name) INTO vConcept FROM vn.item i WHERE i.id = itemFk; - SELECT i.minPrice INTO vPrice FROM vn.item i WHERE i.id = itemFk; + INSERT INTO vn.sale (itemFk,ticketFk,concept,quantity,isAdded) + VALUES (itemFk,vTicketFk,vConcept,vQuantity,1); - INSERT INTO vn.sale (itemFk,ticketFk,concept,quantity,price) - VALUES (itemFk,vTicketFk,vConcept,vQuantity,vPrice); + SELECT last_insert_id() INTO vSaleFk; - CALL vn.ticket_recalcComponents(vTicketFk,null); + CALL vn.sale_calculateComponent(vSaleFk, null); END ;; DELIMITER ; @@ -38103,6 +38946,82 @@ BEGIN JOIN vn.state s ON c.stateFk = s.id WHERE c.workerFk = vWorkerFk AND s.code = 'ON_PREPARATION'; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_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_increaseQuantity` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!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 ;; +CREATE DEFINER=`root`@`%` PROCEDURE `collection_increaseQuantity`( + vSaleFk INT, + vQuantity INT) +BEGIN + DECLARE vOriginalQuantity INT; + + SELECT quantity INTO vOriginalQuantity FROM vn.sale WHERE id = vSaleFk; + UPDATE `vn`.`sale` SET `quantity` = vQuantity,`originalQuantity` = vOriginalQuantity 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 `collection_missingTrash` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!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 ;; +CREATE DEFINER=`root`@`%` PROCEDURE `collection_missingTrash`(vSaleFk BIGINT, vQuantity INT, vIsTrash BOOLEAN, vWarehouseFk INT, vNewQuantity INT) +BEGIN + DECLARE vTicketFk INT; + DECLARE vClientFk INT DEFAULT 400; + DECLARE vClientName VARCHAR(50); + DECLARE vConsignatario INT; + DECLARE vOriginalQuantity INT; + + IF vIsTrash THEN + SELECT 200 INTO vClientFk; + END IF; + + SELECT t.id INTO vTicketFk FROM vn.ticket t WHERE t.created > DATE_SUB(NOW(), INTERVAL 1 DAY) AND t.clientFk = vClientFk AND t.warehouseFk = vWarehouseFk LIMIT 1; + + IF vTicketFk IS NULL THEN + SELECT c.name , co.id INTO vClientName,vConsignatario + FROM vn.client c + INNER JOIN vn.address co ON c.id = co.clientFk + WHERE c.id = vClientFk + LIMIT 1; + + INSERT INTO vn.ticket (clientFk,warehouseFk,shipped,nickname,addressFk,workerFk,agencyModeFk) + VALUES (vClientFk,vWarehouseFk,NOW(),vClientName,vConsignatario,vn.getUser(),2); + + SELECT t.id INTO vTicketFk FROM vn.ticket t WHERE t.created > DATE_SUB(NOW(), INTERVAL 1 DAY) AND t.clientFk = vClientFk AND t.warehouseFk = vWarehouseFk LIMIT 1; + + END IF; + + INSERT INTO vn.sale (itemFk, ticketFk, concept, quantity, originalQuantity, price, discount, priceFixed, reserved, isPicked, isPriceFixed, created, isAdded) + SELECT itemFk, vTicketFk, concept, vQuantity, originalQuantity, price, discount, priceFixed, reserved, isPicked, isPriceFixed, created, isAdded + FROM vn.sale s WHERE s.id = vSaleFk; + + SELECT quantity INTO vOriginalQuantity FROM vn.sale WHERE id = vSaleFk; + UPDATE vn.sale SET originalQuantity = vOriginalQuantity ,quantity = vNewQuantity WHERE id = vSaleFk; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -38436,6 +39355,29 @@ proc:BEGIN 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 `collection_reject` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!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 ;; +CREATE DEFINER=`root`@`%` PROCEDURE `collection_reject`(vSale INT, vQuantity INT) +proc: BEGIN + +UPDATE vn.sale SET quantity = vQuantity +WHERE id = vSale; + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -38526,6 +39468,54 @@ BEGIN 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 `collection_updateState` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!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 ;; +CREATE DEFINER=`root`@`%` PROCEDURE `collection_updateState`(vTicketFk INT, vState VARCHAR(50)) +BEGIN + +DECLARE vCollectionFk INT; +DECLARE vStateFk INT; +DECLARE vLastState VARCHAR(50); + +SELECT name INTO vLastState FROM vn.ticketLastState WHERE ticketFk = vTicketFk; + +IF vLastState <> 'Encajado' THEN + + SELECT collectionFk INTO vCollectionFk FROM vn.ticketCollection WHERE ticketFk = vTicketFk; + + SELECT id INTO vStateFk + FROM vn.state + WHERE `code` = vState COLLATE utf8_unicode_ci; + + -- Actualiza el estado del ticket + INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) + SELECT vStateFk, ticketFk, account.myUserGetId() + FROM vn.ticketCollection tc + WHERE tc.ticketFk = vTicketFk + UNION ALL + SELECT vStateFk, sw.id, account.myUserGetId() + FROM vn.stowaway sw + JOIN vn.ticketCollection tc ON tc.ticketFk = sw.shipFk + WHERE tc.ticketFk = vTicketFk; + + -- Actualiza la colección + CALL vn.collection_update(vTicketFk); + +END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -39950,216 +40940,216 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `entryConverter`(IN `vEntry` INT) -BEGIN - - DECLARE vWarehouseIn INT; - DECLARE vWarehouseOut INT; - DECLARE vTravel INT; - - DECLARE done BOOL DEFAULT FALSE; - - DECLARE vId_Entrada INT; - DECLARE vId_Article INT; - DECLARE vEtiquetas INT; - DECLARE vId_Cubo VARCHAR(10); - DECLARE vPacking INT; - DECLARE vGrouping INT; - DECLARE vCantidad INT; - DECLARE vCostefijo DECIMAL(10,3); - DECLARE vPortefijo DECIMAL(10,3); - DECLARE vEmbalajefijo DECIMAL(10); - DECLARE vComisionfija DECIMAL(10,3); - DECLARE vCaja INT; - DECLARE vNicho VARCHAR(5); - DECLARE vTarifa1 DECIMAL(10,2); - DECLARE vTarifa2 DECIMAL(10,2); - DECLARE vTarifa3 DECIMAL(10,2); - DECLARE vPVP DECIMAL(10,2); - DECLARE vCompra INT; - - DECLARE rs CURSOR FOR - SELECT - b.Id_Entrada, - b.Id_Article, - b.Etiquetas, - b.Id_Cubo, - b.Packing, - b.`grouping`, - b.Cantidad, - b.Costefijo, - b.Portefijo, - b.Embalajefijo, - b.Comisionfija, - b.caja, - b.Nicho, - b.Tarifa1, - b.Tarifa2, - b.Tarifa3, - b.PVP - FROM vn2008.Compres b - JOIN vn.itemConversor ic ON ic.espItemFk = b.Id_Article - WHERE Id_Entrada = vEntry; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; - - SELECT warehouseInFk, warehouseOutFk, tr.id - INTO vWarehouseIn, vWarehouseOut, vTravel - FROM travel tr - JOIN entry e ON e.travelFk = tr.id - WHERE e.id = vEntry; - - UPDATE travel - SET warehouseInFk = vWarehouseOut, - warehouseOutFk = vWarehouseIn - WHERE id = vTravel; - - UPDATE vn2008.Compres c - LEFT JOIN vn.itemConversor ic ON ic.espItemFk = c.Id_Article - SET Etiquetas = 0, Cantidad = 0 - WHERE c.Id_Entrada = vEntry - AND ic.espItemFk IS NULL; - - OPEN rs; - - DELETE FROM vn2008.Compres WHERE Id_Entrada = vEntry; - - FETCH rs INTO - vId_Entrada, - vId_Article, - vEtiquetas, - vId_Cubo, - vPacking, - vGrouping, - vCantidad, - vCostefijo, - vPortefijo, - vEmbalajefijo, - vComisionfija, - vCaja, - vNicho, - vTarifa1, - vTarifa2, - vTarifa3, - vPVP; - - WHILE NOT done DO - - -- Primero la linea original con las cantidades invertidas - INSERT INTO vn2008.Compres - ( - Id_Entrada, - Id_Article, - Etiquetas, - Id_Cubo, - Packing, - `grouping`, - Cantidad, - Costefijo, - Portefijo, - Embalajefijo, - Comisionfija, - caja, - Nicho, - Tarifa1, - Tarifa2, - Tarifa3, - PVP - ) - VALUES - ( - vId_Entrada, - vId_Article, - - vEtiquetas, - vId_Cubo, - vPacking, - vGrouping, - - vCantidad, - vCostefijo, - vPortefijo, - vEmbalajefijo, - vComisionfija, - vCaja, - vNicho, - vTarifa1, - vTarifa2, - vTarifa3, - vPVP); - - -- Ahora la linea nueva, con el item genérico - INSERT INTO vn2008.Compres - ( - Id_Entrada, - Id_Article, - Etiquetas, - Id_Cubo, - Packing, - `grouping`, - Cantidad, - Costefijo, - Portefijo, - Embalajefijo, - Comisionfija, - caja, - Nicho, - Tarifa1, - Tarifa2, - Tarifa3, - PVP - ) - SELECT - vId_Entrada, - genItemFk as Id_Article, - vEtiquetas, - vId_Cubo, - vPacking, - vGrouping, - vCantidad, - vCostefijo, - vPortefijo, - vEmbalajefijo, - vComisionfija, - vCaja, - vNicho, - vTarifa1, - vTarifa2, - vTarifa3, - vPVP - FROM itemConversor - WHERE espItemFk = vId_Article; - - SELECT LAST_INSERT_ID() - INTO vCompra; - - REPLACE vn2008.Compres_mark(Id_Compra,`comment`) - SELECT vCompra, vId_Article; - - - FETCH rs INTO - vId_Entrada, - vId_Article, - vEtiquetas, - vId_Cubo, - vPacking, - vGrouping, - vCantidad, - vCostefijo, - vPortefijo, - vEmbalajefijo, - vComisionfija, - vCaja, - vNicho, - vTarifa1, - vTarifa2, - vTarifa3, - vPVP; - - END WHILE; - - - CLOSE rs; - - - +BEGIN + + DECLARE vWarehouseIn INT; + DECLARE vWarehouseOut INT; + DECLARE vTravel INT; + + DECLARE done BOOL DEFAULT FALSE; + + DECLARE vId_Entrada INT; + DECLARE vId_Article INT; + DECLARE vEtiquetas INT; + DECLARE vId_Cubo VARCHAR(10); + DECLARE vPacking INT; + DECLARE vGrouping INT; + DECLARE vCantidad INT; + DECLARE vCostefijo DECIMAL(10,3); + DECLARE vPortefijo DECIMAL(10,3); + DECLARE vEmbalajefijo DECIMAL(10); + DECLARE vComisionfija DECIMAL(10,3); + DECLARE vCaja INT; + DECLARE vNicho VARCHAR(5); + DECLARE vTarifa1 DECIMAL(10,2); + DECLARE vTarifa2 DECIMAL(10,2); + DECLARE vTarifa3 DECIMAL(10,2); + DECLARE vPVP DECIMAL(10,2); + DECLARE vCompra INT; + + DECLARE rs CURSOR FOR + SELECT + b.Id_Entrada, + b.Id_Article, + b.Etiquetas, + b.Id_Cubo, + b.Packing, + b.`grouping`, + b.Cantidad, + b.Costefijo, + b.Portefijo, + b.Embalajefijo, + b.Comisionfija, + b.caja, + b.Nicho, + b.Tarifa1, + b.Tarifa2, + b.Tarifa3, + b.PVP + FROM vn2008.Compres b + JOIN vn.itemConversor ic ON ic.espItemFk = b.Id_Article + WHERE Id_Entrada = vEntry; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; + + SELECT warehouseInFk, warehouseOutFk, tr.id + INTO vWarehouseIn, vWarehouseOut, vTravel + FROM travel tr + JOIN entry e ON e.travelFk = tr.id + WHERE e.id = vEntry; + + UPDATE travel + SET warehouseInFk = vWarehouseOut, + warehouseOutFk = vWarehouseIn + WHERE id = vTravel; + + UPDATE vn2008.Compres c + LEFT JOIN vn.itemConversor ic ON ic.espItemFk = c.Id_Article + SET Etiquetas = 0, Cantidad = 0 + WHERE c.Id_Entrada = vEntry + AND ic.espItemFk IS NULL; + + OPEN rs; + + DELETE FROM vn2008.Compres WHERE Id_Entrada = vEntry; + + FETCH rs INTO + vId_Entrada, + vId_Article, + vEtiquetas, + vId_Cubo, + vPacking, + vGrouping, + vCantidad, + vCostefijo, + vPortefijo, + vEmbalajefijo, + vComisionfija, + vCaja, + vNicho, + vTarifa1, + vTarifa2, + vTarifa3, + vPVP; + + WHILE NOT done DO + + -- Primero la linea original con las cantidades invertidas + INSERT INTO vn2008.Compres + ( + Id_Entrada, + Id_Article, + Etiquetas, + Id_Cubo, + Packing, + `grouping`, + Cantidad, + Costefijo, + Portefijo, + Embalajefijo, + Comisionfija, + caja, + Nicho, + Tarifa1, + Tarifa2, + Tarifa3, + PVP + ) + VALUES + ( + vId_Entrada, + vId_Article, + - vEtiquetas, + vId_Cubo, + vPacking, + vGrouping, + - vCantidad, + vCostefijo, + vPortefijo, + vEmbalajefijo, + vComisionfija, + vCaja, + vNicho, + vTarifa1, + vTarifa2, + vTarifa3, + vPVP); + + -- Ahora la linea nueva, con el item genérico + INSERT INTO vn2008.Compres + ( + Id_Entrada, + Id_Article, + Etiquetas, + Id_Cubo, + Packing, + `grouping`, + Cantidad, + Costefijo, + Portefijo, + Embalajefijo, + Comisionfija, + caja, + Nicho, + Tarifa1, + Tarifa2, + Tarifa3, + PVP + ) + SELECT + vId_Entrada, + genItemFk as Id_Article, + vEtiquetas, + vId_Cubo, + vPacking, + vGrouping, + vCantidad, + vCostefijo, + vPortefijo, + vEmbalajefijo, + vComisionfija, + vCaja, + vNicho, + vTarifa1, + vTarifa2, + vTarifa3, + vPVP + FROM itemConversor + WHERE espItemFk = vId_Article; + + SELECT LAST_INSERT_ID() + INTO vCompra; + + REPLACE vn2008.Compres_mark(Id_Compra,`comment`) + SELECT vCompra, vId_Article; + + + FETCH rs INTO + vId_Entrada, + vId_Article, + vEtiquetas, + vId_Cubo, + vPacking, + vGrouping, + vCantidad, + vCostefijo, + vPortefijo, + vEmbalajefijo, + vComisionfija, + vCaja, + vNicho, + vTarifa1, + vTarifa2, + vTarifa3, + vPVP; + + END WHILE; + + + CLOSE rs; + + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -40221,62 +41211,62 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `entryPrepare`(IN `idE` BIGINT) -BEGIN - SELECT - b.quantity / b.packing AS Paquetes, - b.packing AS `Grouping`, - barcode, - 'ASEGURADO' AS asegurado, - ic.name, - ic.order, - s.name AS Consignatario, - e.supplierFk AS Id_Cliente, - e.isOrdered, - e.isConfirmed, - 10 AS Calidad, - LPAD(IFNULL(cpd.id, ip.code), - 5, - '0') AS path, - b.entryFk AS Id_Ticket, - t.landed AS Fecha, - b.itemFk, - b.quantity, - i.name AS Concepte, - i.size, - i.inkFk, - i.category, - o.code AS Origen, - 0 AS Bultos, - wIn.`name` AS Tipo, - 0 AS OK, - 0 AS Reservado, - i.stems, - b.id AS Id_Movimiento, - ip.code, - 'PEDIDO ASEGURADO' AS MSG, - 0 AS Seguro, - i.image, - pr.name AS producer - FROM vn.buy b - JOIN vn.entry e ON b.entryFk = e.id - JOIN vn.travel t ON t.id = e.travelFk - JOIN vn.warehouse wIn ON wIn.id = t.warehouseInFk - JOIN vn.warehouse wOut ON wOut.id = t.warehouseOutFk - 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 - JOIN vn.packaging pkg ON pkg.id = b.packageFk - LEFT JOIN vn.itemPlacement ip ON i.id = ip.itemFk AND ip.warehouseFk = wIn.id AND ip.warehouseFk = t.warehouseOutFk - LEFT JOIN (SELECT itemFk, code AS barcode FROM vn.itemBarcode GROUP BY itemFk) ib ON ib.itemFk = b.itemFk - LEFT JOIN vn.origin o ON o.id = i.originFk - LEFT JOIN vn.supplier s ON s.id = e.supplierFk - LEFT JOIN vn.producer pr on pr.id = i.producerFk - LEFT JOIN vn.coolerPathDetail cpd ON LEFT(ip.code, 3) = cpd.hallway - WHERE - NOT wIn.isFeedStock AND NOT e.isInventory AND NOT e.isRaid - AND e.id = 158772 - AND i.typeFk IS NOT NULL - AND ic.merchandise IS NOT FALSE; +BEGIN + SELECT + b.quantity / b.packing AS Paquetes, + b.packing AS `Grouping`, + barcode, + 'ASEGURADO' AS asegurado, + ic.name, + ic.order, + s.name AS Consignatario, + e.supplierFk AS Id_Cliente, + e.isOrdered, + e.isConfirmed, + 10 AS Calidad, + LPAD(IFNULL(cpd.id, ip.code), + 5, + '0') AS path, + b.entryFk AS Id_Ticket, + t.landed AS Fecha, + b.itemFk, + b.quantity, + i.name AS Concepte, + i.size, + i.inkFk, + i.category, + o.code AS Origen, + 0 AS Bultos, + wIn.`name` AS Tipo, + 0 AS OK, + 0 AS Reservado, + i.stems, + b.id AS Id_Movimiento, + ip.code, + 'PEDIDO ASEGURADO' AS MSG, + 0 AS Seguro, + i.image, + pr.name AS producer + FROM vn.buy b + JOIN vn.entry e ON b.entryFk = e.id + JOIN vn.travel t ON t.id = e.travelFk + JOIN vn.warehouse wIn ON wIn.id = t.warehouseInFk + JOIN vn.warehouse wOut ON wOut.id = t.warehouseOutFk + 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 + JOIN vn.packaging pkg ON pkg.id = b.packageFk + LEFT JOIN vn.itemPlacement ip ON i.id = ip.itemFk AND ip.warehouseFk = wIn.id AND ip.warehouseFk = t.warehouseOutFk + LEFT JOIN (SELECT itemFk, code AS barcode FROM vn.itemBarcode GROUP BY itemFk) ib ON ib.itemFk = b.itemFk + LEFT JOIN vn.origin o ON o.id = i.originFk + LEFT JOIN vn.supplier s ON s.id = e.supplierFk + LEFT JOIN vn.producer pr on pr.id = i.producerFk + LEFT JOIN vn.coolerPathDetail cpd ON LEFT(ip.code, 3) = cpd.hallway + WHERE + NOT wIn.isFeedStock AND NOT e.isInventory AND NOT e.isRaid + AND e.id = 158772 + AND i.typeFk IS NOT NULL + AND ic.merchandise IS NOT FALSE; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -41060,7 +42050,7 @@ BEGIN FROM vn.itemShelving ish JOIN vn.shelving sh ON sh.`code` = ish.shelvingFk JOIN vn.parking pk ON pk.id = sh.parkingFk - WHERE ish.itemFk = vItemFk; + WHERE ish.itemFk = vItemFk ORDER BY created ASC; END ;; DELIMITER ; @@ -42010,7 +43000,7 @@ BEGIN INTO vSerial FROM newInvoiceIn; - SELECT SUM(iit.taxableBase * IF(vSerial = 'R', 1 +(tc.rate/100),1)), + SELECT SUM(iit.taxableBase * IF(vSerial = 'R' AND tc.`type` <> 'I', 1 +(tc.rate/100),1)), SUM(iit.foreignValue * IF(vSerial = 'R', 1 +(tc.rate/100),1)), iit.taxableBase/iit.foreignValue INTO vTotalAmount, vTotalAmountDivisa, vRate @@ -44390,9 +45380,9 @@ 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 = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!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 ;; @@ -45146,137 +46136,20 @@ 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 = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!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 ;; CREATE DEFINER=`root`@`%` PROCEDURE `itemRefreshTags`(IN vItem INT) BEGIN -/** - * Actualiza la tabla item, los campos "cache" de tags - * - * @param vItem El id del articulo. Si es NULL, equivale a todos. - **/ - DECLARE vInkId VARCHAR(3) DEFAULT NULL; - DECLARE vSize INT DEFAULT NULL; - DECLARE vOriginId INT DEFAULT NULL; - DECLARE vProducerId INT DEFAULT NULL; - DECLARE vStems INT DEFAULT NULL; - - UPDATE item i - LEFT JOIN itemTag it1 ON it1.priority = 1 AND it1.itemFk = i.id - LEFT JOIN itemTag it2 ON it2.priority = 2 AND it2.itemFk = i.id - LEFT JOIN itemTag it3 ON it3.priority = 3 AND it3.itemFk = i.id - SET i.longName = CONCAT_WS(' ', it1.`value`, it2.`value`, it3.`value`) - WHERE (vItem IS NULL OR vItem = i.id); - - UPDATE item i - LEFT JOIN itemTag it1 ON it1.priority = 1 AND it1.itemFk = i.id - LEFT JOIN tagAbbreviation ta1 ON ta1.`value` = it1.`value` - LEFT JOIN itemTag it2 ON it2.priority = 2 AND it2.itemFk = i.id - LEFT JOIN tagAbbreviation ta2 ON ta2.`value` = it2.`value` - LEFT JOIN itemTag it3 ON it3.priority = 3 AND it3.itemFk = i.id - LEFT JOIN tagAbbreviation ta3 ON ta3.`value` = it3.`value` - SET i.`name` = CONCAT_WS(' ', - IFNULL(ta1.abbreviation,it1.`value`), - IFNULL(ta2.abbreviation,it2.`value`), - IFNULL(ta3.abbreviation,it3.`value`)) - WHERE (vItem IS NULL OR vItem = i.id); - - UPDATE item i - LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 4 - SET i.subName = it.`value` - WHERE (vItem IS NULL OR vItem = i.id); - - UPDATE item i - LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 5 - LEFT JOIN tag t ON t.id = it.tagFk - SET tag5 = t.name, value5 = it.`value` - WHERE (vItem IS NULL OR vItem = i.id); - - UPDATE item i - LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 6 - LEFT JOIN tag t ON t.id = it.tagFk - SET tag6 = t.name, value6 = it.`value` - WHERE (vItem IS NULL OR vItem = i.id); - - UPDATE item i - LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 7 - LEFT JOIN tag t ON t.id = it.tagFk - SET i.tag7 = t.name, i.value7 = it.`value` - WHERE (vItem IS NULL OR vItem = i.id); - - UPDATE item i - LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 8 - LEFT JOIN tag t ON t.id = it.tagFk - SET tag8 = t.name, value8 = it.`value` - WHERE (vItem IS NULL OR vItem = i.id); - - UPDATE item i - LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 9 - LEFT JOIN tag t ON t.id = it.tagFk - SET tag9 = t.name, value9 = it.`value` - WHERE (vItem IS NULL OR vItem = i.id); - - UPDATE item i - LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 10 - LEFT JOIN tag t ON t.id = it.tagFk - SET tag10 = t.name, value10 = it.`value` - WHERE (vItem IS NULL OR vItem = i.id); - - IF vItem IS NOT NULL THEN - -- Al insertar el tag color se modifica también el antiguo campo color - SELECT i.id INTO vInkId FROM ink i - JOIN itemTag it ON it.tagFk = 1 AND i.`name` = it.`value` - WHERE vItem = it.itemFk - LIMIT 1; - - IF vInkId > '' THEN - UPDATE item SET inkFk = vInkId WHERE id = vItem; - END IF; - - -- Al insertar el tag origen se modifica también en la tabla item - SELECT o.id INTO vOriginId FROM origin o - JOIN itemTag it ON it.tagFk = 35 AND o.`name` = it.`value` - WHERE vItem = it.itemFk - LIMIT 1; - - IF vOriginId > '' THEN - UPDATE item SET originFk = vOriginId WHERE id = vItem; - END IF; - - -- Al insertar el tag medida se modifica también en la tabla item - SELECT it.`value` INTO vSize - FROM itemTag it - WHERE vItem = it.itemFk AND it.tagFk IN (4, 8) - LIMIT 1; - - IF vSize > '' THEN - UPDATE item SET size = vSize WHERE id = vItem; - END IF; - - -- Al insertar el tag productor se modifica también en la tabla item - SELECT p.id INTO vProducerId FROM producer p - JOIN itemTag it ON it.tagFk = 37 AND p.`name` = it.`value` - WHERE vItem = it.itemFk - LIMIT 1; - - IF vProducerId > '' THEN - UPDATE item SET producerFk = vProducerId WHERE id = vItem; - END IF; - - -- Al insertar el tag tallos se modifica también en la tabla item - SELECT CAST(it.`value` as signed) INTO vStems - FROM itemTag it - WHERE vItem = it.itemFk AND it.tagFk = 23 - LIMIT 1; - - IF vStems > 0 THEN - UPDATE item SET stems = vStems WHERE id = vItem; - END IF; - END IF; + /* DEPRECATED USAR item_refreshTags JGF 16/17/2020*/ + DROP TEMPORARY TABLE IF EXISTS tmp.item; + CREATE TEMPORARY TABLE tmp.item + SELECT vItem id; + CALL item_refreshTags(); + DROP TEMPORARY TABLE tmp.item; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -45377,9 +46250,9 @@ 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 = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!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 ;; @@ -45392,9 +46265,9 @@ BEGIN ish.visible as visible, ceil(ish.visible/ish.packing) as stickers, ish.packing as packing, - p.`column` as col, - p.`row` as `row`, - p.`code` as `code`, + IF (p.`column` IS NULL,"",p.`column`) as col, + IF (p.`row` IS NULL,"",p.`row`) as `row`, + IF (p.`code` IS NULL,"",p.`code`) as `code`, ish.id, s.priority FROM vn.itemShelving ish @@ -46902,9 +47775,9 @@ 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_general_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -46912,6 +47785,139 @@ CREATE DEFINER=`root`@`%` PROCEDURE `item_refreshTags`() BEGIN /** * Actualiza la tabla item, los campos "cache" de tags + * Para actualizar mas de un registro, la tabla NO tiene que ser en memoria + * Error Code: 1137. No puedo reabrir tabla: 'tmpI + * + * @param temporary table vItem(id) del articulo + **/ + DROP TEMPORARY TABLE IF EXISTS tmp.itemToRefresh; + CREATE TEMPORARY TABLE tmp.itemToRefresh + SELECT id from tmp.item; + + + UPDATE item i + JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id + LEFT JOIN itemTag it1 ON it1.priority = 1 AND it1.itemFk = i.id + LEFT JOIN itemTag it2 ON it2.priority = 2 AND it2.itemFk = i.id + LEFT JOIN itemTag it3 ON it3.priority = 3 AND it3.itemFk = i.id + SET i.longName = CONCAT_WS(' ', it1.`value`, it2.`value`, it3.`value`); + + UPDATE item i + JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id + LEFT JOIN itemTag it1 ON it1.priority = 1 AND it1.itemFk = i.id + LEFT JOIN tagAbbreviation ta1 ON ta1.`value` = it1.`value` + LEFT JOIN itemTag it2 ON it2.priority = 2 AND it2.itemFk = i.id + LEFT JOIN tagAbbreviation ta2 ON ta2.`value` = it2.`value` + LEFT JOIN itemTag it3 ON it3.priority = 3 AND it3.itemFk = i.id + LEFT JOIN tagAbbreviation ta3 ON ta3.`value` = it3.`value` + SET i.`name` = CONCAT_WS(' ', + IFNULL(ta1.abbreviation,it1.`value`), + IFNULL(ta2.abbreviation,it2.`value`), + IFNULL(ta3.abbreviation,it3.`value`)); + + UPDATE item i + JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id + LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 4 + SET i.subName = it.`value` + WHERE i.subName IS NULL; + + UPDATE item i + JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id + LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 5 + LEFT JOIN tag t ON t.id = it.tagFk + SET tag5 = t.name, value5 = it.`value`; + + UPDATE item i + JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id + LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 6 + LEFT JOIN tag t ON t.id = it.tagFk + SET tag6 = t.name, value6 = it.`value`; + + UPDATE item i + JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id + LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 7 + LEFT JOIN tag t ON t.id = it.tagFk + SET i.tag7 = t.name, i.value7 = it.`value`; + + UPDATE item i + JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id + LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 8 + LEFT JOIN tag t ON t.id = it.tagFk + SET tag8 = t.name, value8 = it.`value`; + + UPDATE item i + JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id + LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 9 + LEFT JOIN tag t ON t.id = it.tagFk + SET tag9 = t.name, value9 = it.`value`; + + UPDATE item i + JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id + LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 10 + LEFT JOIN tag t ON t.id = it.tagFk + SET tag10 = t.name, value10 = it.`value`; + + -- Al insertar el tag color se modifica también el antiguo campo color + UPDATE item i + JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id + JOIN tag t ON t.overwrite = 'inkFk' + JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = t.id + JOIN ink ON ink.`name` = it.`value` + SET i.inkFk = ink.id; + + -- Al insertar el tag origen se modifica también en la tabla item + UPDATE item i + JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id + JOIN tag t ON t.overwrite = 'originFk' + JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = t.id + JOIN origin o ON o.`name` = it.`value` + SET i.originFk = o.id; + + -- Al insertar el tag medida se modifica también en la tabla item + UPDATE item i + JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id + JOIN tag t ON t.overwrite = 'size' + JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = t.id + SET i.size = it.`value`; + + -- Al insertar el tag productor se modifica también en la tabla item + UPDATE item i + JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id + JOIN tag t ON t.overwrite = 'producerFk' + JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = t.id + JOIN producer p ON p.`name` = it.`value` + SET i.producerFk = p.id; + + -- Al insertar el tag tallos se modifica también en la tabla item + UPDATE item i + JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id + JOIN tag t ON t.overwrite = 'stems' + JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = t.id + SET i.stems = it.`value`; + + DROP TEMPORARY TABLE IF EXISTS tmp.itemToRefresh; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_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 `item_refreshTags__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `item_refreshTags__`() +BEGIN +/** + * Actualiza la tabla item, los campos "cache" de tags + * Para actualizar mas de un registro, la tabla NO tiene que ser en memoria + * Error Code: 1137. No puedo reabrir tabla: 'tmpI * * @param temporary table vItem(id) del articulo **/ @@ -46980,34 +47986,39 @@ BEGIN -- Al insertar el tag color se modifica también el antiguo campo color UPDATE item i JOIN tmp.item tmpI ON tmpI.id = i.id - JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = 1 + JOIN tag t ON t.overwrite = 'inkFk' + JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = t.id JOIN ink ON ink.`name` = it.`value` SET i.inkFk = ink.id; -- Al insertar el tag origen se modifica también en la tabla item UPDATE item i JOIN tmp.item tmpI ON tmpI.id = i.id - JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = 35 + JOIN tag t ON t.overwrite = 'originFk' + JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = t.id JOIN origin o ON o.`name` = it.`value` SET i.originFk = o.id; -- Al insertar el tag medida se modifica también en la tabla item UPDATE item i JOIN tmp.item tmpI ON tmpI.id = i.id - JOIN itemTag it ON it.itemFk = i.id AND it.tagFk IN (4, 8) + JOIN tag t ON t.overwrite = 'size' + JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = t.id SET i.size = it.`value`; -- Al insertar el tag productor se modifica también en la tabla item UPDATE item i JOIN tmp.item tmpI ON tmpI.id = i.id - JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = 37 + JOIN tag t ON t.overwrite = 'producerFk' + JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = t.id JOIN producer p ON p.`name` = it.`value` SET i.producerFk = p.id; -- Al insertar el tag tallos se modifica también en la tabla item UPDATE item i JOIN tmp.item tmpI ON tmpI.id = i.id - JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = 23 + JOIN tag t ON t.overwrite = 'stems' + JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = t.id SET i.stems = it.`value`; END ;; @@ -47416,7 +48427,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`z-sysadmin`@`%` PROCEDURE `kk`(IN vItemId INT, IN vWarehouse INT) +CREATE DEFINER=`root`@`%` PROCEDURE `kk`(IN vItemId INT, IN vWarehouse INT) BEGIN DECLARE vDateInventory DATETIME; DECLARE vCurdate DATE DEFAULT CURDATE(); @@ -48468,7 +49479,7 @@ BEGIN o.itemFk, i.description, o.amount, - round(ic.cm3 * i.compression * o.amount / 1000000,3) as volume + round(ic.cm3delivery * o.amount / 1000000,3) as volume FROM hedera.orderRow o JOIN item i ON i.id = o.itemFk JOIN itemCost ic ON ic.itemFk = o.itemFk AND ic.warehouseFk = o.warehouseFk @@ -49020,6 +50031,68 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `productionSectorList`(vSectorFk INT) +BEGIN + + DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt; + CREATE TEMPORARY TABLE tmp.clientGetDebt + SELECT DISTINCT t.clientFk + FROM vn.ticket t + JOIN vn.itemShelvingAvailable isa ON isa.ticketFk = t.id; + + CALL vn.clientGetDebt(CURDATE()); + + SELECT 0,999999,0 INTO @sameTicket, @ticket, @litrosTicket; + + SELECT @litrosTicket := IF(sub.ticketFk = @ticket, @litrosTicket + Litros, Litros) as LitrosTicket, + @sameTicket := IF(sub.ticketFk = @ticket, @sameTicket, IF(@sameTicket, 0 , 1)) as sameTicket, + sub.*, + @ticket := ticketFk + FROM + ( + SELECT * FROM + ( + SELECT isa.*, + cast(max(isa.quantity mod isa.packing) as DECIMAL(10,0)) as picos, + sum(isa.available) as totalAvailable, + IF (HOUR(isa.shipped),HOUR(isa.shipped), HOUR(isa.`hour`)) Hora, + IF (MINUTE(isa.shipped),MINUTE(isa.shipped), MINUTE(isa.`hour`)) Minuto, + i.subName, + CAST(isa.physicalVolume * 1000 AS DECIMAL(10,0)) as Litros + FROM vn.itemShelvingAvailable isa + JOIN vn.item i ON i.id = isa.itemFk + JOIN vn.sector s ON s.id = isa.sectorFk AND s.warehouseFk = isa.warehouseFk + JOIN vn.ticket t ON t.id = isa.ticketFk + JOIN vn.client c ON c.id = t.clientFk + JOIN tmp.risk r ON r.clientFk = c.id + WHERE IF(s.isPreviousPreparedByPacking, (MOD(TRUNCATE(isa.quantity,0), isa.packing)= 0 ), TRUE) + -- AND isa.isPreviousPreparable = TRUE + AND isa.sectorFk = vSectorFk + AND isa.quantity > 0 + AND r.risk < c.credit + 10 + GROUP BY saleFk + HAVING isa.quantity <= totalAvailable + ) sub2 + ORDER BY Hora, Minuto, ticketFk + ) sub + ; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_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 `productionSectorList__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `productionSectorList__`(vSectorFk INT) BEGIN SELECT 0,999999,0 INTO @sameTicket, @ticket, @litrosTicket; @@ -49590,9 +50663,9 @@ 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 = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!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 ;; @@ -49602,6 +50675,7 @@ BEGIN DECLARE vPackages INT; DECLARE vM3 INT; DECLARE vKg INT; + DECLARE vMatricula varchar(50); SELECT sum(packages) as bultos INTO vPackages @@ -49613,10 +50687,17 @@ BEGIN FROM vn.saleVolume sv WHERE sv.routeFk = vRouteFk; + SELECT v.numberPlate as matricula + INTO vMatricula + FROM vn.route r + JOIN vn.vehicle v ON r.vehicleFk = v.id + WHERE r.id = vRouteFk; + SELECT vRouteFk as Ruta, vPackages as Bultos, vM3 as m3, - vKg as Kg; + vKg as Kg, + vMatricula as Matricula; END ;; DELIMITER ; @@ -49926,77 +51007,77 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `saleItemShelvingMake`(IN `vTicketFk` INT, IN `vSectorFk` INT) -BEGIN - - SET @rest:= CAST(0 AS DECIMAL(10,0)); - SET @saleFk := CAST(0 AS DECIMAL(10,0)); - SET @reserved := CAST(0 AS DECIMAL(10,0)); - - UPDATE vn.itemShelving ish - JOIN vn.saleItemShelving sis ON sis.itemShelvingFk = ish.id - JOIN sale s ON s.id = sis.saleFk - SET ish.visible = sis.quantity + ish.visible, - ish.available = sis.quantity + ish.visible - WHERE s.ticketFk = vTicketFk; - - DELETE sis.* - FROM saleItemShelving sis - JOIN sale s ON s.id = sis.saleFk - WHERE s.ticketFk = vTicketFk; - - INSERT INTO saleItemShelving( saleFk, - itemShelvingFk, - quantity, - ubication) - SELECT saleFk, - itemShelvingFk, - CAST(Reserved as DECIMAL(10,0)) as Reserved, - ubication - FROM - (SELECT saleFk, - itemShelvingFk, - ubication, - @rest := IF(@saleFk = saleFk, @rest, quantity) as Falta, - @reserved := IF(available < @rest, available, IF(@rest < packing,0,@rest)) as Reserved, - @rest := @rest - @reserved, - @saleFk := saleFk - FROM - ( SELECT s.id as saleFk, - ish.created, - ish.id as itemShelvingFk, - ish.available, - s.quantity, - ish.packing, - CONCAT(p.`column`, '-',p.`row`,': ', sh.code ) as ubication - FROM vn.sale s - JOIN vn.ticket t ON t.id = s.ticketFk - JOIN vn.sector sc ON sc.warehouseFk = t.warehouseFk - JOIN vn.parking p ON p.sectorFk = sc.id - JOIN vn.shelving sh ON sh.parkingFk = p.id - JOIN vn.itemShelving ish ON ish.shelvingFk = sh.code AND ish.itemFk = s.itemFk - WHERE t.id = vTicketFk - AND sc.id = vSectorFk - AND s.quantity MOD ish.packing = 0 - AND s.quantity >= ish.packing - ORDER BY s.id, - sh.priority DESC, - ish.packing DESC, - ish.created - ) sub - ) sub2 - WHERE Reserved > 0; - - UPDATE vn.itemShelving ish - JOIN vn.saleItemShelving sis ON sis.itemShelvingFk = ish.id - JOIN vn.sale s ON s.id = sis.saleFk - SET ish.available = ish.visible - sis.quantity, - ish.visible = ish.visible - sis.quantity - WHERE s.ticketFk = vTicketFk - AND s.isPicked = FALSE; - - CALL vn.saleItemShelvingIsPicked(vTicketFk, TRUE); - - +BEGIN + + SET @rest:= CAST(0 AS DECIMAL(10,0)); + SET @saleFk := CAST(0 AS DECIMAL(10,0)); + SET @reserved := CAST(0 AS DECIMAL(10,0)); + + UPDATE vn.itemShelving ish + JOIN vn.saleItemShelving sis ON sis.itemShelvingFk = ish.id + JOIN sale s ON s.id = sis.saleFk + SET ish.visible = sis.quantity + ish.visible, + ish.available = sis.quantity + ish.visible + WHERE s.ticketFk = vTicketFk; + + DELETE sis.* + FROM saleItemShelving sis + JOIN sale s ON s.id = sis.saleFk + WHERE s.ticketFk = vTicketFk; + + INSERT INTO saleItemShelving( saleFk, + itemShelvingFk, + quantity, + ubication) + SELECT saleFk, + itemShelvingFk, + CAST(Reserved as DECIMAL(10,0)) as Reserved, + ubication + FROM + (SELECT saleFk, + itemShelvingFk, + ubication, + @rest := IF(@saleFk = saleFk, @rest, quantity) as Falta, + @reserved := IF(available < @rest, available, IF(@rest < packing,0,@rest)) as Reserved, + @rest := @rest - @reserved, + @saleFk := saleFk + FROM + ( SELECT s.id as saleFk, + ish.created, + ish.id as itemShelvingFk, + ish.available, + s.quantity, + ish.packing, + CONCAT(p.`column`, '-',p.`row`,': ', sh.code ) as ubication + FROM vn.sale s + JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.sector sc ON sc.warehouseFk = t.warehouseFk + JOIN vn.parking p ON p.sectorFk = sc.id + JOIN vn.shelving sh ON sh.parkingFk = p.id + JOIN vn.itemShelving ish ON ish.shelvingFk = sh.code AND ish.itemFk = s.itemFk + WHERE t.id = vTicketFk + AND sc.id = vSectorFk + AND s.quantity MOD ish.packing = 0 + AND s.quantity >= ish.packing + ORDER BY s.id, + sh.priority DESC, + ish.packing DESC, + ish.created + ) sub + ) sub2 + WHERE Reserved > 0; + + UPDATE vn.itemShelving ish + JOIN vn.saleItemShelving sis ON sis.itemShelvingFk = ish.id + JOIN vn.sale s ON s.id = sis.saleFk + SET ish.available = ish.visible - sis.quantity, + ish.visible = ish.visible - sis.quantity + WHERE s.ticketFk = vTicketFk + AND s.isPicked = FALSE; + + CALL vn.saleItemShelvingIsPicked(vTicketFk, TRUE); + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -50354,9 +51435,9 @@ 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 = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!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 ;; @@ -50377,7 +51458,7 @@ BEGIN SELECT vSaleFk, vIsChecked, vOriginalQuantity, - vWorkerFk, + IFNULL(vWorkerFk, vn.getUser()), a.accion_id, s.id FROM vncontrol.accion a @@ -50395,18 +51476,16 @@ 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 = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!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 ;; CREATE DEFINER=`root`@`%` PROCEDURE `saleTracking_Replace`(vSaleFk INT, vIsChecked INT, vOriginalQuantity INT, vStateFk INT) BEGIN - - REPLACE vn.saleTracking(saleFk, isChecked, originalQuantity, workerFk, stateFk) - VALUES(vSaleFk, vIsChecked, vOriginalQuantity, vn.getUser(), vStateFk); - + REPLACE vn.saleTracking(saleFk, isChecked, originalQuantity, stateFk) + VALUES(vSaleFk, vIsChecked, vOriginalQuantity, vStateFk); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -50719,50 +51798,6 @@ BEGIN REPLACE INTO vn.routeLoadWorker(routeFk, workerFk) VALUES(routeFk,workerFk); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_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 `scanTreeCreate` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `scanTreeCreate`() -BEGIN - CALL nestTree( - 'vn2008', - 'scan', - 'vn2008', - 'scanTree' - ); - - UPDATE vn2008.scanTree st - JOIN ( - SELECT sl.scan_id, - MAX(sl.odbc_date) lastScanned, - COUNT(DISTINCT t.routeFk) routeCount, - MIN(t.routeFk) mod 1000 as minRoute, - MAX(t.routeFk) mod 1000 as maxRoute, - COUNT(sl.scan_line_id) as scanned - FROM vn2008.scan_line sl - JOIN expedition e ON e.id = sl.`code` - JOIN ticket t ON t.id = e.ticketFk - WHERE t.routeFk - GROUP BY sl.scan_id - ) rs ON rs.scan_id = st.id - SET st.lastScanned = rs.lastScanned, - st.routeCount = rs.routeCount, - st.minRoute = rs.minRoute, - st.maxRoute = IF(rs.minRoute != rs.maxRoute, rs.maxRoute,NULL), - st.scanned = rs.scanned; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -50773,40 +51808,40 @@ 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 = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!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 ;; CREATE DEFINER=`root`@`%` PROCEDURE `scanTreeCreate__`() -BEGIN - CALL nestTree( - 'vn2008', - 'scan', - 'vn2008', - 'scanTree' - ); - - UPDATE vn2008.scanTree st - JOIN ( - SELECT sl.scan_id, - MAX(sl.odbc_date) lastScanned, - COUNT(DISTINCT t.routeFk) routeCount, - MIN(t.routeFk) mod 1000 as minRoute, - MAX(t.routeFk) mod 1000 as maxRoute, - COUNT(sl.scan_line_id) as scanned - FROM vn2008.scan_line sl - JOIN expedition e ON e.id = sl.`code` - JOIN ticket t ON t.id = e.ticketFk - WHERE t.routeFk - GROUP BY sl.scan_id - ) rs ON rs.scan_id = st.id - SET st.lastScanned = rs.lastScanned, - st.routeCount = rs.routeCount, - st.minRoute = rs.minRoute, - st.maxRoute = IF(rs.minRoute != rs.maxRoute, rs.maxRoute,NULL), - st.scanned = rs.scanned; +BEGIN + CALL nestTree( + 'vn2008', + 'scan', + 'vn2008', + 'scanTree' + ); + + UPDATE vn2008.scanTree st + JOIN ( + SELECT sl.scan_id, + MAX(sl.odbc_date) lastScanned, + COUNT(DISTINCT t.routeFk) routeCount, + MIN(t.routeFk) mod 1000 as minRoute, + MAX(t.routeFk) mod 1000 as maxRoute, + COUNT(sl.scan_line_id) as scanned + FROM vn2008.scan_line sl + JOIN expedition e ON e.id = sl.`code` + JOIN ticket t ON t.id = e.ticketFk + WHERE t.routeFk + GROUP BY sl.scan_id + ) rs ON rs.scan_id = st.id + SET st.lastScanned = rs.lastScanned, + st.routeCount = rs.routeCount, + st.minRoute = rs.minRoute, + st.maxRoute = IF(rs.minRoute != rs.maxRoute, rs.maxRoute,NULL), + st.scanned = rs.scanned; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -51163,7 +52198,7 @@ proc: BEGIN UPDATE vn.shelving - SET parkingFk = vParkingFk, parked = NOW() + SET parkingFk = vParkingFk, parked = NOW(), isPrinted = 1 WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci; SELECT (COUNT(*) > 0) AS IsUpdated @@ -51211,6 +52246,27 @@ SELECT s.itemFk, HAVING sinServir > aparcado; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_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 `shelvingPriority_update` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `shelvingPriority_update`(priority INT,vShelvingFk VARCHAR(10)) +BEGIN + + UPDATE vn.shelving SET priority = priority WHERE code=vShelvingFk COLLATE utf8_unicode_ci; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -51240,9 +52296,9 @@ BEGIN UPDATE vn.shelving sh LEFT JOIN vn.itemShelving its ON its.shelvingFk = sh.`code` - SET isPrinted = 0 - WHERE isPrinted = 1 - AND its.id IS NULL + SET isPrinted = 0, + parkingFk = NULL + WHERE its.id IS NULL AND ( sh.parked IS NULL OR sh.parked < TIMESTAMPADD(MONTH,-1,CURDATE()) @@ -51254,6 +52310,28 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `sleep_X_min` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `sleep_X_min`() +BEGIN + # Ernesto. 4.8.2020 + # Para su uso en las tareas ejecutadas a las 2AM (visibles con: SELECT * FROM bs.nightTask order by started asc;) + # Simplemente esperar unos minutos para que en las graficas de rendimiento de Percona PMM y escritura a disco de vCenter se puedan ver los efectos de cada tarea. + do SLEEP(300); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_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 `solunionRiskRequest` */; ALTER DATABASE `vn` CHARACTER SET utf8 COLLATE utf8_general_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -52409,6 +53487,109 @@ 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 `ticketClon` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticketClon`(vTicketFk INT, vNewShipped DATE) +BEGIN + + DECLARE done INT DEFAULT FALSE; + DECLARE vNewTicketFk INT; + DECLARE vOldSaleFk INT; + DECLARE vNewSaleFk INT; + + DECLARE cur1 CURSOR FOR + SELECT id + FROM vn.sale + WHERE ticketFk = vTicketFk; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; + + SET vNewShipped = IFNULL(vNewShipped, CURDATE()); + + CALL vn.ticket_Clone(vTicketFk, vNewTicketFk); + + UPDATE vn.ticket + SET landed = TIMESTAMPADD(DAY, DATEDIFF(vNewShipped, shipped), landed), + shipped = vNewShipped + WHERE id = vNewTicketFk; + + OPEN cur1; + + read_loop: LOOP + + FETCH cur1 INTO vOldSaleFk; + + IF done THEN + LEAVE read_loop; + END IF; + + INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed) + SELECT vNewTicketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed + FROM vn.sale + WHERE id = vOldSaleFk; + + SELECT max(id) INTO vNewSaleFk + FROM vn.sale + WHERE ticketFk = vNewTicketFk; + + INSERT INTO vn.saleComponent(saleFk, componentFk, value, isGreuge) + SELECT vNewSaleFk, componentFk, value, isGreuge + FROM vn.saleComponent + WHERE saleFk = vOldSaleFk; + + END LOOP; + + CLOSE cur1; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_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 `ticketClon_OneYear` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticketClon_OneYear`(vTicketFk INT) +BEGIN + + DECLARE vShipped DATE; + DECLARE vMaxDated DATE; + + SELECT shipped, TIMESTAMPADD(YEAR,1,shipped) + INTO vShipped, vMaxDated + FROM vn.ticket + WHERE id = vTicketFk; + + WHILE vShipped <= vMaxDated DO + + SET vShipped = TIMESTAMPADD(WEEK, 1, vShipped); + + CALL vn.ticketClon(vTicketFk, vShipped); + + 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 `ticketClosure` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -53629,9 +54810,9 @@ 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 = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!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 ;; @@ -53702,7 +54883,7 @@ BEGIN SELECT DISTINCT tl.ticketFk, 1 FROM tmp.ticketList tl JOIN vn.ticketRequest tr ON tr.ticketFk = tl.ticketFk - WHERE tr.isOK IS NULL + WHERE tr.isOK IS NULL AND tr.saleFk IS NOT NULL ON DUPLICATE KEY UPDATE hasTicketRequest = 1; @@ -53777,9 +54958,9 @@ 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_general_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -54003,7 +55184,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 `ticketGetTotal` */; +/*!50003 DROP PROCEDURE IF EXISTS `ticketGetTax__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -54013,6 +55194,113 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticketGetTax__`() + READS SQL DATA +BEGIN +/** + * Calcula la base imponible, el IVA y el recargo de equivalencia para + * un conjunto de tickets. + * + * @table tmp.ticket(ticketFk) Identificadores de los tickets a calcular + * @return tmp.ticketAmount + * @return tmp.ticketTax Impuesto desglosado para cada ticket. + + */ + DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany; + CREATE TEMPORARY TABLE tmp.addressCompany + (INDEX (addressFk, companyFk)) + ENGINE = MEMORY + SELECT DISTINCT t.addressFk, t.companyFk + FROM tmp.ticket tmpTicket + JOIN ticket t ON t.id = tmpTicket.ticketFk; + + CALL addressTaxArea (); + + + /** Solo se calcula la base imponible (taxableBase) y el impuesto se calculará posteriormente + * No se debería cambiar el sistema por problemas con los decimales + */ + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketTax; + CREATE TEMPORARY TABLE tmp.ticketTax + (INDEX (ticketFk)) + ENGINE = MEMORY + SELECT tmpTicket.ticketFk, + bp.pgcFk, + SUM(s.quantity * s.price * (100 - s.discount)/100 ) AS taxableBase, + pgc.rate, + tc.code + FROM tmp.ticket tmpTicket + JOIN sale s ON s.ticketFk = tmpTicket.ticketFk + JOIN item i ON i.id = s.itemFk + JOIN ticket t ON t.id = tmpTicket.ticketFk + JOIN supplier su ON su.id = t.companyFk + JOIN tmp.addressTaxArea ata + ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk + JOIN itemTaxCountry itc + ON itc.itemFk = i.id AND itc.countryFk = su.countryFk + JOIN bookingPlanner bp + ON bp.countryFk = su.countryFk + AND bp.taxAreaFk = ata.areaFk + AND bp.taxClassFk = itc.taxClassFk + JOIN pgc ON pgc.code = bp.pgcFk + JOIN taxClass tc ON tc.id = bp.taxClassFk + GROUP BY tmpTicket.ticketFk, pgc.code,pgc.rate + HAVING taxableBase != 0; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketServiceTax; + CREATE TEMPORARY TABLE tmp.ticketServiceTax + (INDEX (ticketFk)) + ENGINE = MEMORY + SELECT tt.ticketFk, + SUM(ts.quantity * ts.price) AS taxableBase, + pgc.rate, + tc.code + FROM tmp.ticketTax tt + JOIN ticketService ts ON ts.ticketFk = tt.ticketFk + JOIN ticket t ON t.id = tt.ticketFk + JOIN supplier su ON su.id = t.companyFk + JOIN tmp.addressTaxArea ata + ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk + JOIN bookingPlanner bp + ON bp.countryFk = su.countryFk + AND bp.taxAreaFk = ata.areaFk + AND bp.taxClassFk = ts.taxClassFk + JOIN pgc ON pgc.code = bp.pgcFk AND pgc.rate = tt.rate + JOIN taxClass tc ON tc.id = bp.taxClassFk + GROUP BY tt.ticketFk, tt.code,tt.rate + HAVING taxableBase != 0; + + UPDATE tmp.ticketTax tt + JOIN tmp.ticketServiceTax ts ON tt.ticketFk = ts.ticketFk AND tt.code = ts.code AND tt.rate = ts.rate + SET tt.taxableBase = tt.taxableBase + ts.taxableBase; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketAmount; + CREATE TEMPORARY TABLE tmp.ticketAmount + (INDEX (ticketFk)) + ENGINE = MEMORY + SELECT ticketFk, taxableBase, SUM(CAST(taxableBase * rate / 100 AS DECIMAL(10, 2))) tax,code + FROM tmp.ticketTax + GROUP BY ticketFk, code; + + DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany; + DROP TEMPORARY TABLE IF EXISTS tmp.addressTaxArea; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_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 `ticketGetTotal` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `ticketGetTotal`() READS SQL DATA BEGIN @@ -54137,13 +55425,12 @@ BEGIN SELECT warehouseFk, shipped INTO vWarehouseId,vShippedDate FROM ticket WHERE id = vTicketId; SELECT s.quantity, - round(ic.cm3 * i.compression * s.quantity / 1000000,3) as m3, + round(ic.cm3delivery * s.quantity / 1000000,3) as m3, s.itemFk, s.id AS saleFk, s.concept, t.agencyModeFk FROM sale s - JOIN item i ON i.id = s.itemFk JOIN ticket t on t.id = s.ticketFk JOIN itemCost ic ON ic.itemFk = s.itemFk AND ic.warehouseFk = t.warehouseFk WHERE s.ticketFk = vTicketId; @@ -54705,9 +55992,9 @@ 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_general_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -54722,14 +56009,14 @@ BEGIN CREATE TEMPORARY TABLE tmp.ticketVolumeByDate ENGINE = MEMORY SELECT s.ticketFk, - CAST(SUM(r.cm3 * s.quantity) / 1000000 AS DECIMAL(10,2)) as m3 + CAST(SUM(ic.cm3delivery * s.quantity) / 1000000 AS DECIMAL(10,2)) as m3 FROM sale s 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.itemCategory c ON c.id = it.categoryFk JOIN vn.ticket t on t.id = s.ticketFk - JOIN bi.rotacion r ON r.Id_Article = s.itemFk AND r.warehouse_id = t.warehouseFk - WHERE ic.merchandise + JOIN vn.itemCost ic ON ic.itemFk = s.itemFk AND ic.warehouseFk = t.warehouseFk + WHERE c.merchandise AND t.shipped BETWEEN vDateStart AND vDateEnd GROUP BY s.ticketFk; END ;; @@ -55808,9 +57095,9 @@ 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 = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!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 ;; @@ -55916,6 +57203,118 @@ 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_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_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticket_getTax__`(vTaxArea VARCHAR(25)) + READS SQL DATA +BEGIN +/** + * Calcula la base imponible, el IVA y el recargo de equivalencia para + * un conjunto de tickets. + * + * @table tmp.ticket(ticketFk) Identificadores de los tickets a calcular + * @return tmp.ticketAmount + * @return tmp.ticketTax Impuesto desglosado para cada ticket. + */ + DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany; + CREATE TEMPORARY TABLE tmp.addressCompany + (INDEX (addressFk, companyFk)) + ENGINE = MEMORY + SELECT DISTINCT t.addressFk, t.companyFk + FROM tmp.ticket tmpTicket + JOIN ticket t ON t.id = tmpTicket.ticketFk; + + CALL addressTaxArea (); + + IF vTaxArea > '' THEN + UPDATE tmp.addressTaxArea + SET areaFk = vTaxArea; + END IF; + /** Solo se calcula la base imponible (taxableBase) y el impuesto se calculará posteriormente + * No se debería cambiar el sistema por problemas con los decimales + */ + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketTax; + CREATE TEMPORARY TABLE tmp.ticketTax + (INDEX (ticketFk)) + ENGINE = MEMORY + SELECT * FROM ( + SELECT tmpTicket.ticketFk, + bp.pgcFk, + SUM(s.quantity * s.price * (100 - s.discount)/100 ) AS taxableBase, + pgc.rate, + tc.code, + bp.priority + FROM tmp.ticket tmpTicket + JOIN sale s ON s.ticketFk = tmpTicket.ticketFk + JOIN item i ON i.id = s.itemFk + JOIN ticket t ON t.id = tmpTicket.ticketFk + JOIN supplier su ON su.id = t.companyFk + JOIN tmp.addressTaxArea ata + ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk + JOIN itemTaxCountry itc + ON itc.itemFk = i.id AND itc.countryFk = su.countryFk + JOIN bookingPlanner bp + ON bp.countryFk = su.countryFk + AND bp.taxAreaFk = ata.areaFk + AND bp.taxClassFk = itc.taxClassFk + JOIN pgc ON pgc.code = bp.pgcFk + JOIN taxClass tc ON tc.id = bp.taxClassFk + GROUP BY tmpTicket.ticketFk, pgc.code,pgc.rate + HAVING taxableBase != 0) t + ORDER BY priority; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketServiceTax; + CREATE TEMPORARY TABLE tmp.ticketServiceTax + (INDEX (ticketFk)) + ENGINE = MEMORY + SELECT tt.ticketFk, + SUM(ts.quantity * ts.price) AS taxableBase, + pgc.rate, + tc.code + FROM tmp.ticketTax tt + JOIN ticketService ts ON ts.ticketFk = tt.ticketFk + JOIN ticket t ON t.id = tt.ticketFk + JOIN supplier su ON su.id = t.companyFk + JOIN tmp.addressTaxArea ata + ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk + JOIN bookingPlanner bp + ON bp.countryFk = su.countryFk + AND bp.taxAreaFk = ata.areaFk + AND bp.taxClassFk = ts.taxClassFk + JOIN pgc ON pgc.code = bp.pgcFk AND pgc.rate = tt.rate + JOIN taxClass tc ON tc.id = bp.taxClassFk + GROUP BY tt.ticketFk, tt.code,tt.rate + HAVING taxableBase != 0; + + UPDATE tmp.ticketTax tt + JOIN tmp.ticketServiceTax ts ON tt.ticketFk = ts.ticketFk AND tt.code = ts.code AND tt.rate = ts.rate + SET tt.taxableBase = tt.taxableBase + ts.taxableBase; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketAmount; + CREATE TEMPORARY TABLE tmp.ticketAmount + (INDEX (ticketFk)) + ENGINE = MEMORY + SELECT ticketFk, taxableBase, SUM(CAST(taxableBase * rate / 100 AS DECIMAL(10, 2))) tax,code + FROM tmp.ticketTax + GROUP BY ticketFk, code; + + DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany; + DROP TEMPORARY TABLE IF EXISTS tmp.addressTaxArea; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_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 */ ; @@ -56279,6 +57678,69 @@ proc: BEGIN DROP TEMPORARY TABLE tmp.ticketComponentPrice; DROP TEMPORARY TABLE tmp.ticketComponent; DROP TEMPORARY TABLE tmp.sale; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_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_WeightDeclaration` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticket_WeightDeclaration`(vClientFk INT, vDated DATE) +BEGIN + + DECLARE vTheorycalWeight DECIMAL(10,2); + DECLARE vRealWeight DECIMAL(10,2); + DECLARE vRatio DOUBLE; + + SELECT IFNULL(sum(tob.description),0) INTO vRealWeight + FROM vn.ticketObservation tob + JOIN vn.observationType ot ON ot.id = tob.observationTypeFk + JOIN vn.ticket t ON t.id = tob.ticketFk + WHERE ot.description = 'Peso Aduana' + AND t.clientFk = vClientFk + AND t.shipped BETWEEN vDated AND util.dayend(vDated); + + SELECT sum(IF(sv.physicalWeight = 0, sv.weight, sv.physicalWeight)) INTO vTheorycalWeight + FROM vn.ticket t + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.saleVolume sv ON sv.saleFk = s.id + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemCost ic ON ic.itemFk = i.id AND ic.warehouseFk = t.warehouseFk + WHERE t.clientFk = vClientFk + AND t.shipped BETWEEN vDated AND util.dayend(vDated); + + SET vRatio = vRealWeight / vTheorycalWeight; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketWeight; + + CREATE TEMPORARY TABLE tmp.ticketWeight + ENGINE = MEMORY + SELECT i.intrastatFk, + ib.ediBotanic, + FLOOR(sum(s.quantity)) as quantity, + CAST(vRatio * SUM(IF(sv.physicalWeight = 0, sv.weight, sv.physicalWeight) ) AS DECIMAL(10,2)) physicalWeight, + o.code as countryCode, + vDated as Dated + FROM vn.ticket t + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.saleVolume sv ON sv.saleFk = s.id + JOIN vn.item i ON i.id = s.itemFk + LEFT JOIN vn.itemBotanicalWithGenus ib ON ib.itemFk = i.id + LEFT JOIN vn.origin o ON o.id = i.originFk + WHERE t.clientFk = vClientFk + AND t.shipped BETWEEN vDated AND util.dayend(vDated) + GROUP BY ib.ediBotanic, o.code; + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -56289,9 +57751,9 @@ 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_general_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -56306,18 +57768,19 @@ BEGIN * @return tmp.timeBusinessCalculate */ - DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate; + DROP TABLE IF EXISTS tmp.timeBusinessCalculate; DROP TEMPORARY TABLE IF EXISTS tmp.businessFullTime; CALL rangeDateInfo(vDatedFrom, vDatedTo); - CREATE TEMPORARY TABLE tmp.timeBusinessCalculate + CREATE TABLE tmp.timeBusinessCalculate SELECT dated, businessFk, userFk, departmentFk, hourStart, hourEnd, + timeTable, timeWorkSeconds, SEC_TO_TIME(timeWorkSeconds) timeWorkSexagesimal, timeWorkSeconds / 3600 timeWorkDecimal, @@ -56332,8 +57795,9 @@ BEGIN b.business_id businessFk, w.userFk, bl.department_id departmentFk, - IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.start,2) ORDER BY j.start ASC SEPARATOR '-')) hourStart , - IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.end,2) ORDER BY j.end ASC SEPARATOR '-')) hourEnd, + IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.start,5) ORDER BY j.start ASC SEPARATOR ' - ')) hourStart , + IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.end,5) ORDER BY j.end ASC SEPARATOR ' - ')) hourEnd, + IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.start,5), " - ", LEFT(j.end,5) ORDER BY j.end ASC SEPARATOR ' - ')) timeTable, IF(j.start = NULL, 0, IFNULL(SUM(TIME_TO_SEC(j.end)) - SUM(TIME_TO_SEC(j.start)),0)) timeWorkSeconds, cs.type, cs.permissionRate, @@ -56370,7 +57834,7 @@ BEGIN UPDATE tmp.timeBusinessCalculate t SET t.timeWorkSeconds = t.timeWorkSeconds - (t.timeWorkSeconds * permissionRate) , - t.timeWorkSexagesimal = SEC_TO_TIME(t.timeWorkSeconds - (t.timeWorkSeconds * permissionRate)), + t.timeWorkSexagesimal = SEC_TO_TIME ((t.timeWorkDecimal - (t.timeWorkDecimal * permissionRate)) * 3600), t.timeWorkDecimal = t.timeWorkDecimal - (t.timeWorkDecimal * permissionRate) WHERE permissionRate <> 0; @@ -56567,10 +58031,12 @@ BEGIN dated, IF( timeWork >= 18000, @timeWork:=timeWork + 1200, @timeWork:=timeWork) timeWorkSeconds, SEC_TO_TIME(@timeWork ) timeWorkSexagesimal, - @timeWork / 3600 timeWorkDecimal + @timeWork / 3600 timeWorkDecimal, + timed FROM (SELECT SUM(timeWork) timeWork, userFk, - dated + dated, + GROUP_CONCAT(DATE_FORMAT(sub.timed,"%H:%i") ORDER BY sub.timed ASC SEPARATOR ' - ') timed FROM (SELECT IF(@vUser = wtc.userFk, @vUser :=@vUser, @vUser := wtc.userFk ), IF(@vIsOdd, @vIsOdd := FALSE, @vIsOdd := TRUE ), IF(direction='in', @vIsOdd := TRUE, @vIsOdd := @vIsOdd ), @@ -56583,7 +58049,8 @@ BEGIN FROM (SELECT wtc.* FROM workerTimeControl wtc JOIN tmp.`user` w ON w.userFk = wtc.userFk - WHERE wtc.timed BETWEEN vDatedFrom AND vDatedTo + WHERE wtc.timed BETWEEN vDatedFrom AND vDatedTo AND + isSendMail = FALSE ORDER BY userFk, timed ASC ) wtc WHERE wtc.timed BETWEEN vDatedFrom AND vDatedTo @@ -57593,9 +59060,9 @@ 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_general_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -57627,7 +59094,7 @@ BEGIN JOIN vn.time tm ON tm.dated BETWEEN b.date_start AND IFNULL(b.date_end,CURDATE()) WHERE b.date_start <= vToDate AND IFNULL(b.date_end, CURDATE()) >= vFromDate - AND bl.porhoras + -- AND bl.porhoras AND vUserFk IN (0,w.userFk); @@ -58806,6 +60273,240 @@ 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_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` 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 vSender VARCHAR(255); + DECLARE vSenderOld 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 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 + FROM tmp.timeBusinessCalculate tb + JOIN user u ON u.id = tb.userFk + JOIN department d ON d.id = tb.departmentFk + LEFT JOIN tmp.timeControlCalculate tc ON tc.userFk = tb.userFk AND tc.dated = tb.dated + WHERE d.isTeleworking AND + IFNULL(vWorkerFk,u.id) = u.id + ORDER BY u.id, tb.dated; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + SELECT CONCAT( IFNULL(nif, ""), " - ", firstName, " ", name ) INTO vWorkerInfo + FROM postgresql.person + WHERE id_trabajador = vWorkerFk; + SET vHeader = CONCAT("


+
+

", vWorkerInfo , "

+ + + + + + + + + + + + "); + + DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate; + DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate; + + SELECT CONCAT (MIN(dated), " 00:00:00"), CONCAT (MAX(dated), " 23:59:59") INTO vStarted, vEnded + FROM time + WHERE year = vYear AND + week = vWeek; + + DELETE FROM workerTimeControl + WHERE IFNULL(vWorkerFk, userFk) = userFk AND + timed BETWEEN vStarted AND vEnded AND isSendMail; + + UPDATE workerTimeControlMail + SET updated = 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 vSender, vWorkerFk, vDated, vTimeWorkDecimal, vTimeWorkSexagesimal, vTimeTable, vTimeWorkedDecimal, vTimeWorkedSexagesimal, vAbsenceType, vBusinessFk ; + proc: LOOP + IF vDone THEN + LEAVE proc; + END IF; + + IF vTimeTable IS NULL AND vTimeWorkDecimal>0 AND vTimeWorkedDecimal 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; + ELSEIF vTimeWorkDecimal>0 AND vTimeWorkedDecimal IS NULL THEN + 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; + + SELECT CONCAT(IFNULL(vBody,""), " + + + + + + ") INTO vBody + FROM workerTimeControl + WHERE userFk = vWorkerFk AND + timed BETWEEN vDated AND CONCAT(vDated," 23:59:59"); + SET vTimeWorkDecimalTotal = vTimeWorkDecimalTotal + IFNULL(vTimeWorkedDecimal, vTimeWorkDecimal); + SET vDone = FALSE; + FETCH vCursor INTO vSender, vWorkerFk, vDated, vTimeWorkDecimal, vTimeWorkSexagesimal, vTimeTable, vTimeWorkedDecimal, vTimeWorkedSexagesimal, vAbsenceType, vBusinessFk ; + + IF vWorkerFk <> vWorkerFkOld OR vDone THEN + 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
", 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, vTimeWorkSexagesimal) , "
TOTAL", IFNULL(LEFT (SEC_TO_TIME(vTimeWorkDecimalTotal * 3600), 5), 0), "
+
"); + INSERT INTO mail(sender, replyto, subject, body) + VALUES (vSenderOld, "timecontrol@verdnatura.es", CONCAT("Registro de horas semana ", vWeek, " año ", vYear) , CONCAT(vHeader," " , vBody," ", vFooter)); + + INSERT IGNORE INTO workerTimeControlMail (workerFk, year,week) + VALUES(vWorkerFk, vYear, vWeek); + + SET vBody = ""; + SET vTimeWorkDecimalTotal = 0; + + END IF; + + SET vWorkerFkOld = vWorkerFk ; + SET vSenderOld = vSender; + + END LOOP; + CLOSE vCursor; + + DROP TEMPORARY TABLE tmp.timeBusinessCalculate; + DROP TEMPORARY TABLE tmp.timeControlCalculate; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_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 `workerWeekControl` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -59446,15 +61147,84 @@ proc: BEGIN TRUNCATE TABLE zoneClosure; WHILE vCounter <= vScope DO + CALL zone_getOptionsForShipment(vShipped, TRUE); - INSERT INTO zoneClosure(zoneFk, dated, `hour`) - SELECT zoneFk, vShipped, `hour` FROM tmp.zoneOption; + + REPLACE zoneClosure(zoneFk, dated, `hour`) + SELECT zoneFk, vShipped, `hour` + FROM tmp.zoneOption; SET vCounter = vCounter + 1; SET vShipped = TIMESTAMPADD(DAY, 1, vShipped); END WHILE; - DROP TEMPORARY TABLE tmp.zone; + -- DROP TEMPORARY TABLE tmp.zone; + DO RELEASE_LOCK('vn.zoneClosure_recalc'); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_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 `zoneClosure_recalc_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 = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `zoneClosure_recalc_beta`() +proc: BEGIN +/** + * Recalculates the delivery time (hour) for every zone in days + scope in future + */ + DECLARE vScope INT; + DECLARE vCounter INT DEFAULT 0; + DECLARE vShipped DATE DEFAULT CURDATE(); + + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION + BEGIN + DO RELEASE_LOCK('vn.zoneClosure_recalc'); + RESIGNAL; + END; + + IF NOT GET_LOCK('vn.zoneClosure_recalc', 0) THEN + LEAVE proc; + END IF; + + SELECT scope INTO vScope + FROM zoneConfig; + + DROP TEMPORARY TABLE IF EXISTS tmp.zone; + CREATE TEMPORARY TABLE tmp.zone + (INDEX (id)) + ENGINE = MEMORY + SELECT id FROM zone; + + WHILE vCounter <= vScope DO + + DELETE FROM zoneClosure + WHERE dated = vShipped; + + SELECT vShipped; + + CALL zone_getOptionsForShipment_beta(vShipped, TRUE); + + REPLACE zoneClosure(zoneFk, dated, `hour`) + SELECT zoneFk, vShipped, `hour` + FROM tmp.zoneOption; + + SET vCounter = vCounter + 1; + SET vShipped = TIMESTAMPADD(DAY, 1, vShipped); + END WHILE; + + SELECT * + FROM tmp.zoneOption; + + -- DROP TEMPORARY TABLE tmp.zone; DO RELEASE_LOCK('vn.zoneClosure_recalc'); END ;; DELIMITER ; @@ -60668,6 +62438,123 @@ BEGIN WHERE vShipped < CURDATE() OR (vShipped = CURDATE() AND CURTIME() > `hour`); 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 `zone_getOptionsForShipment_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 = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `zone_getOptionsForShipment_beta`(vShipped DATE, vShowExpiredZones BOOLEAN) +BEGIN +/** + * Gets computed options for the passed zones and shipping date. + * + * @table tmp.zones(id) The zones ids + * @param vShipped The shipping date + * @return tmp.zoneOption(zoneFk, hour, travelingDays, price, bonus, specificity) The computed options + */ + DECLARE vHour TIME DEFAULT TIME(NOW()); + + DROP TEMPORARY TABLE IF EXISTS tLandings; + CREATE TEMPORARY TABLE tLandings + (INDEX (eventFk)) + ENGINE = MEMORY + SELECT e.id eventFk, + @travelingDays := IFNULL(e.travelingDays, z.travelingDays) travelingDays, + TIMESTAMPADD(DAY, @travelingDays, vShipped) landed + FROM tmp.zone t + JOIN zone z ON z.id = t.id + JOIN zoneEvent e ON e.zoneFk = t.id; + + SELECT * FROM tLandings + JOIN vn.zoneEvent ze ON ze.id = eventFk + WHERE ze.zoneFk = 25; + + DROP TEMPORARY TABLE IF EXISTS tmp.zoneOption; + CREATE TEMPORARY TABLE tmp.zoneOption + ENGINE = MEMORY + SELECT * + FROM ( + SELECT t.id zoneFk, + TIME(IFNULL(e.`hour`, z.`hour`)) `hour`, + l.travelingDays, + IFNULL(e.price, z.price) price, + IFNULL(e.bonus, z.bonus) bonus, + l.landed + FROM tmp.zone t + JOIN zone z ON z.id = t.id + JOIN zoneEvent e ON e.zoneFk = t.id + JOIN tLandings l ON l.eventFk = e.id + WHERE ( + e.`type` = 'day' + AND e.`dated` = l.landed + ) OR ( + e.`type` != 'day' + AND e.weekDays & (1 << WEEKDAY(l.landed)) + AND (e.`started` IS NULL OR l.landed >= e.`started`) + AND (e.`ended` IS NULL OR l.landed <= e.`ended`) + ) + ORDER BY + zoneFk, + CASE + WHEN e.`type` = 'day' + THEN -1 + WHEN e.`type` = 'range' + THEN 2 + ELSE 3 + END + ) t + GROUP BY zoneFk; + + SELECT e.id, e.type, (e.`dated` = l.landed), e.`dated` , l.landed, t.id zoneFk, + TIME(IFNULL(e.`hour`, z.`hour`)) `hour`, + l.travelingDays, + IFNULL(e.price, z.price) price, + IFNULL(e.bonus, z.bonus) bonus, + l.landed + FROM tmp.zone t + JOIN zone z ON z.id = t.id + JOIN zoneEvent e ON e.zoneFk = t.id + JOIN tLandings l ON l.eventFk = e.id + WHERE zoneFk = 25 + ORDER BY + zoneFk, + CASE + WHEN e.`type` = 'day' + THEN 1 + WHEN e.`type` = 'range' + THEN 2 + ELSE 3 + END; + + SELECT * FROm tmp.zoneOption WHERE zoneFk = 25; + + DROP TEMPORARY TABLE tLandings; + + DELETE t FROM tmp.zoneOption t + JOIN zoneExclusion e + ON e.zoneFk = t.zoneFk AND e.`dated` = t.landed; + + SELECT * FROm tmp.zoneOption WHERE zoneFk = 25; + + IF NOT vShowExpiredZones THEN + DELETE FROM tmp.zoneOption + WHERE vShipped < CURDATE() + OR (vShipped = CURDATE() AND CURTIME() > `hour`); + END IF; + + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -61217,13 +63104,11 @@ DELIMITER ;; FOR EACH ROW BEGIN - REPLACE vn.ticketLastState(ticketFk, ticketTrackingFk, name) SELECT NEW.Id_Ticket, NEW.inter_id, `name` FROM vn.state WHERE id = NEW.state_id; - END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -61297,18 +63182,18 @@ BEGIN WHERE ticketFk = OLD.Id_Ticket; END; - SELECT i.Id_Ticket, i.inter_id, s.`name` - INTO vTicketFk, vTicketTrackingFk, vStateName - FROM vncontrol.inter i - JOIN vn.state s ON i.state_id = s.id - WHERE Id_Ticket = OLD.Id_Ticket - ORDER BY odbc_date DESC - LIMIT 1; + SELECT i.Id_Ticket, i.inter_id, s.`name` + INTO vTicketFk, vTicketTrackingFk, vStateName + FROM vncontrol.inter i + JOIN vn.state s ON i.state_id = s.id + WHERE Id_Ticket = OLD.Id_Ticket + ORDER BY odbc_date DESC + LIMIT 1; - IF vTicketFk > 0 THEN - REPLACE INTO vn.ticketLastState(ticketFk, ticketTrackingFk,name) - VALUES(vTicketFk, vTicketTrackingFk, vStateName); - END IF; + IF vTicketFk > 0 THEN + REPLACE INTO vn.ticketLastState(ticketFk, ticketTrackingFk,name) + VALUES(vTicketFk, vTicketTrackingFk, vStateName); + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -62073,7 +63958,7 @@ USE `pbx`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `sipConf` AS select `s`.`user_id` AS `id`,`s`.`extension` AS `name`,NULL AS `callbackextension`,`s`.`md5Secret` AS `md5secret`,`u`.`nickname` AS `callerid`,`c`.`host` AS `host`,`c`.`deny` AS `deny`,`c`.`permit` AS `permit`,`c`.`type` AS `type`,`c`.`context` AS `context`,`c`.`incomingLimit` AS `incominglimit`,`c`.`pickupGroup` AS `pickupgroup`,`c`.`careInvite` AS `careinvite`,`c`.`insecure` AS `insecure`,`c`.`transport` AS `transport`,`r`.`ipAddr` AS `ipaddr`,`r`.`regSeconds` AS `regseconds`,`r`.`port` AS `port`,`r`.`defaultUser` AS `defaultuser`,`r`.`userAgent` AS `useragent`,`r`.`lastMs` AS `lastms`,`r`.`fullContact` AS `fullcontact`,`r`.`regServer` AS `regserver` from (((`pbx`.`sip` `s` join `account`.`user` `u` on((`u`.`id` = `s`.`user_id`))) left join `pbx`.`sipReg` `r` on((`s`.`user_id` = `r`.`userId`))) join `pbx`.`sipConfig` `c`) */; +/*!50001 VIEW `sipConf` AS select `s`.`user_id` AS `id`,`s`.`extension` AS `name`,NULL AS `callbackextension`,`s`.`md5Secret` AS `md5secret`,`u`.`nickname` AS `callerid`,`c`.`host` AS `host`,`c`.`deny` AS `deny`,`c`.`permit` AS `permit`,`c`.`type` AS `type`,`c`.`context` AS `context`,`c`.`incomingLimit` AS `incominglimit`,`c`.`pickupGroup` AS `pickupgroup`,`c`.`careInvite` AS `careinvite`,`c`.`insecure` AS `insecure`,`c`.`transport` AS `transport`,`c`.`nat` AS `nat`,`r`.`ipAddr` AS `ipaddr`,`r`.`regSeconds` AS `regseconds`,`r`.`port` AS `port`,`r`.`defaultUser` AS `defaultuser`,`r`.`userAgent` AS `useragent`,`r`.`lastMs` AS `lastms`,`r`.`fullContact` AS `fullcontact`,`r`.`regServer` AS `regserver` from (((`pbx`.`sip` `s` join `account`.`user` `u` on((`u`.`id` = `s`.`user_id`))) left join `pbx`.`sipReg` `r` on((`s`.`user_id` = `r`.`userId`))) join `pbx`.`sipConfig` `c`) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -62084,6 +63969,24 @@ USE `pbx`; USE `postgresql`; +-- +-- Final view structure for view `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_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `calendar_employee` AS select `ce`.`id` AS `id`,`ce`.`businessFk` AS `business_id`,`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: `salix` -- @@ -62234,6 +64137,42 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `businessCalendar` +-- + +/*!50001 DROP VIEW IF EXISTS `businessCalendar`*/; +/*!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_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `businessCalendar` AS select `ce`.`id` AS `id`,`ce`.`business_id` AS `businessFk`,`ce`.`calendar_state_id` AS `absenceTypeFk`,`ce`.`date` AS `dated` from `postgresql`.`calendar_employee` `ce` */; +/*!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 `calendar__` +-- + +/*!50001 DROP VIEW IF EXISTS `calendar__`*/; +/*!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_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `calendar__` AS select `ce`.`id` AS `id`,`ce`.`business_id` AS `businessFk`,`ce`.`calendar_state_id` AS `dayOffTypeFk`,`ce`.`date` AS `dated` from `postgresql`.`calendar_employee` `ce` */; +/*!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 `claimRatio__` -- @@ -62751,7 +64690,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `holidayType__` AS select `cf`.`calendar_free_id` AS `id`,`cf`.`type` AS `name`,`cf`.`rgb` AS `rgb` from `postgresql`.`calendar_free` `cf` */; +/*!50001 VIEW `holidayType__` AS select `cf`.`calendar_free_id` AS `id`,`cf`.`type` AS `name`,`cf`.`rgb` AS `rgb` from `postgresql`.`calendar_free__` `cf` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -63152,6 +65091,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `labelInfo` +-- + +/*!50001 DROP VIEW IF EXISTS `labelInfo`*/; +/*!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_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `labelInfo` AS select `i`.`id` AS `itemId`,`i`.`name` AS `itemName`,`i`.`inkFk` AS `colorCode`,`i`.`stems` AS `stems`,`i`.`category` AS `category`,`i`.`subName` AS `productor`,`b`.`packing` AS `packing`,`clb`.`warehouse_id` AS `warehouse_id`,`i`.`size` AS `size`,`b`.`isPickedOff` AS `isPickedOff`,`e`.`evaNotes` AS `notes`,`w`.`name` AS `wh_in`,`e`.`id` AS `entryId`,`b`.`id` AS `buyId` from (((((`vn`.`buy` `b` join `vn`.`item` `i` on((`i`.`id` = `b`.`itemFk`))) join `cache`.`last_buy` `clb` on((`clb`.`item_id` = `i`.`id`))) join `vn`.`entry` `e` on((`e`.`id` = `b`.`entryFk`))) left join `vn`.`travel` `tr` on((`tr`.`id` = `e`.`travelFk`))) join `vn`.`warehouse` `w` on((`w`.`id` = `tr`.`warehouseInFk`))) */; +/*!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 `lastHourProduction` -- @@ -63242,6 +65199,42 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `productionVolume` +-- + +/*!50001 DROP VIEW IF EXISTS `productionVolume`*/; +/*!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 = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` 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`.`itemFk` = `e`.`itemFk`))) join `ticket` `t` on((`t`.`id` = `e`.`ticketFk`))) join `client` `c` on((`c`.`id` = `t`.`clientFk`))) where ((`e`.`created` between curdate() and `util`.`dayend`(curdate())) and `c`.`isRelevant`) */; +/*!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 `productionVolume_LastHour` +-- + +/*!50001 DROP VIEW IF EXISTS `productionVolume_LastHour`*/; +/*!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 = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` 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` > (now() + interval -(1) hour)) and (`productionVolume`.`warehouseFk` in (1,44))) 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 */; + -- -- Final view structure for view `role` -- @@ -63309,7 +65302,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleVolume` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,ifnull(round(((((greatest(`i`.`density`,167) / 167) * `ic`.`cm3`) * `s`.`quantity`) / 1000),2),0) AS `litros`,`t`.`routeFk` AS `routeFk`,`t`.`shipped` AS `shipped`,((`s`.`quantity` * `ic`.`cm3`) / 1000000) AS `volume`,((`s`.`quantity` * `ic`.`grams`) / 1000) AS `physicalWeight`,((((`s`.`quantity` * `ic`.`cm3`) * greatest(`i`.`density`,167)) / 167) / 1000000) AS `weight`,((`s`.`quantity` * `ic`.`cm3`) / 1000000) AS `physicalVolume`,(((`s`.`quantity` * `ic`.`cm3`) * `t`.`zonePrice`) / `cb`.`volume`) AS `freight`,`t`.`zoneFk` AS `zoneFk`,`t`.`clientFk` AS `clientFk`,`s`.`isPicked` AS `isPicked` from ((((`sale` `s` join `item` `i` on((`i`.`id` = `s`.`itemFk`))) join `ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `packaging` `cb` on((`cb`.`id` = '94'))) join `itemCost` `ic` on(((`ic`.`itemFk` = `s`.`itemFk`) and (`ic`.`warehouseFk` = `t`.`warehouseFk`)))) */; +/*!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`,((`s`.`quantity` * `ic`.`cm3delivery`) / 1000000) AS `volume`,((`s`.`quantity` * `ic`.`grams`) / 1000) AS `physicalWeight`,(((`s`.`quantity` * `ic`.`cm3delivery`) * greatest(`i`.`density`,167)) / 1000000) AS `weight`,((`s`.`quantity` * `ic`.`cm3delivery`) / 1000000) AS `physicalVolume`,(((`s`.`quantity` * `ic`.`cm3delivery`) * ifnull(`t`.`zonePrice`,`z`.`price`)) / `cb`.`volume`) AS `freight`,`t`.`zoneFk` AS `zoneFk`,`t`.`clientFk` AS `clientFk`,`s`.`isPicked` AS `isPicked` 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 `packaging` `cb` on((`cb`.`id` = '94'))) join `itemCost` `ic` on(((`ic`.`itemFk` = `s`.`itemFk`) and (`ic`.`warehouseFk` = `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 */; @@ -63345,7 +65338,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `salesPreparedLastHour` AS select `t`.`warehouseFk` AS `warehouseFk`,`st`.`saleFk` AS `saleFk`,`st`.`isChecked` AS `isChecked`,`st`.`originalQuantity` AS `originalQuantity`,`a`.`accion` AS `accion`,`st`.`created` AS `created`,`e`.`code` AS `code`,`w`.`firstName` AS `firstname`,`w`.`lastName` AS `lastName`,`w`.`code` AS `workerCode`,((`r`.`cm3` * `s`.`quantity`) / 1000) AS `litros`,`s`.`concept` AS `concept`,`d`.`name` AS `departmentName` from (((((((((`vn`.`saleTracking` `st` left join `vn`.`salesPreviousPreparated` `prevPrepSales` on((`prevPrepSales`.`saleFk` = `st`.`saleFk`))) join `vn`.`sale` `s` on((`s`.`id` = `st`.`saleFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `bi`.`rotacion` `r` on(((`r`.`warehouse_id` = `t`.`warehouseFk`) and (`r`.`Id_Article` = `s`.`itemFk`)))) join `vn`.`worker` `w` on((`w`.`id` = `st`.`workerFk`))) join `vn`.`state` `e` on((`e`.`id` = `st`.`stateFk`))) join `vncontrol`.`accion` `a` on((`a`.`accion_id` = `st`.`actionFk`))) join `vn`.`workerDepartment` `wd` on((`wd`.`workerFk` = `st`.`workerFk`))) join `vn`.`department` `d` on((`d`.`id` = `wd`.`departmentFk`))) where ((`st`.`created` > (now() + interval -(1) hour)) and isnull(`prevPrepSales`.`saleFk`) and (not((`d`.`name` like 'EQUIPO%')))) */; +/*!50001 VIEW `salesPreparedLastHour` AS select `t`.`warehouseFk` AS `warehouseFk`,`st`.`saleFk` AS `saleFk`,`st`.`isChecked` AS `isChecked`,`st`.`originalQuantity` AS `originalQuantity`,`a`.`accion` AS `accion`,`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 (((((((((`vn`.`saleTracking` `st` left join `vn`.`salesPreviousPreparated` `prevPrepSales` on((`prevPrepSales`.`saleFk` = `st`.`saleFk`))) join `vn`.`sale` `s` on((`s`.`id` = `st`.`saleFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`itemCost` `ic` on(((`ic`.`warehouseFk` = `t`.`warehouseFk`) and (`ic`.`itemFk` = `s`.`itemFk`)))) join `vn`.`worker` `w` on((`w`.`id` = `st`.`workerFk`))) join `vn`.`state` `e` on((`e`.`id` = `st`.`stateFk`))) join `vncontrol`.`accion` `a` on((`a`.`accion_id` = `st`.`actionFk`))) join `vn`.`workerDepartment` `wd` on((`wd`.`workerFk` = `st`.`workerFk`))) join `vn`.`department` `d` on((`d`.`id` = `wd`.`departmentFk`))) where ((`st`.`created` > (now() + interval -(1) hour)) and isnull(`prevPrepSales`.`saleFk`) and (not((`d`.`name` 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 */; @@ -63512,6 +65505,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `time__` +-- + +/*!50001 DROP VIEW IF EXISTS `time__`*/; +/*!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_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `time__` AS select `t`.`date` AS `dated`,`t`.`period` AS `period`,`t`.`month` AS `month`,`t`.`year` AS `year`,`t`.`day` AS `day`,`t`.`week` AS `week`,`t`.`yearMonth` AS `yearMonth` from `vn2008`.`time` `t` */; +/*!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 `tr2` -- @@ -63797,4 +65808,4 @@ USE `vncontrol`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-23 12:58:41 +-- Dump completed on 2020-08-11 11:57:36 diff --git a/db/export-structure.sh b/db/export-structure.sh index ec9578aad..891812824 100755 --- a/db/export-structure.sh +++ b/db/export-structure.sh @@ -80,7 +80,6 @@ IGNORETABLES=( --ignore-table=vn.ticketRequest__ --ignore-table=vn.ticketToPrepare --ignore-table=vn.till__ - --ignore-table=vn.time --ignore-table=vn.travelThermograph__ --ignore-table=vn.travel_cloneWeekly --ignore-table=vn.unary diff --git a/docker-compose.yml b/docker-compose.yml index fabd968a1..c04f7e388 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -28,6 +28,7 @@ services: volumes: - /mnt/storage/pdfs:/var/lib/salix/pdfs - /mnt/storage/dms:/var/lib/salix/dms + - /mnt/storage/image:/var/lib/salix/image deploy: replicas: 6 configs: diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index f9a84ac65..e1b6b1c65 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -631,7 +631,7 @@ export default { }, ordersIndex: { searchResult: 'vn-order-index vn-card > vn-table > div > vn-tbody > a.vn-tr', - firstSearchResultTotal: 'vn-order-index vn-card > vn-table > div > vn-tbody vn-tr vn-td:nth-child(7)', + secondSearchResultTotal: 'vn-order-index vn-card > vn-table > div > vn-tbody vn-tr:nth-child(2) vn-td:nth-child(9)', searchResultDate: 'vn-order-index vn-table vn-tbody > a:nth-child(1) > vn-td:nth-child(4)', searchResultAddress: 'vn-order-index vn-table vn-tbody > a:nth-child(1) > vn-td:nth-child(6)', searchButton: 'vn-searchbar vn-icon[icon="search"]', @@ -870,7 +870,7 @@ export default { confirmed: 'vn-entry-summary vn-check[label="Confirmed"]', }, entryDescriptor: { - agency: 'vn-entry-descriptor div.body vn-label-value:nth-child(2) span', + agency: 'vn-entry-descriptor div.body vn-label-value:nth-child(1) span', travelsQuicklink: 'vn-entry-descriptor vn-quick-link[icon="local_airport"] > a', entriesQuicklink: 'vn-entry-descriptor vn-quick-link[icon="icon-entry"] > a' } 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 a7b24e4a3..08ff97b96 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 @@ -211,12 +211,16 @@ describe('Ticket Edit sale path', () => { it('should search for a ticket then access to the sales section', async() => { await page.accessToSearchResult('16'); await page.accessToSection('ticket.card.sale'); + await page.wait(2000); }); it('should select the third sale and delete it', async() => { await page.waitToClick(selectors.ticketSales.thirdSaleCheckbox); + await page.wait(2000); await page.waitToClick(selectors.ticketSales.deleteSaleButton); + await page.wait(2000); await page.waitToClick(selectors.ticketSales.acceptDeleteLineButton); + await page.wait(2000); await page.waitForSpinnerLoad(); const message = await page.waitForSnackbar(); diff --git a/e2e/paths/07-order/01_summary.spec.js b/e2e/paths/07-order/01_summary.spec.js index f4bc44827..d170f290e 100644 --- a/e2e/paths/07-order/01_summary.spec.js +++ b/e2e/paths/07-order/01_summary.spec.js @@ -8,6 +8,7 @@ describe('Order summary path', () => { browser = await getBrowser(); page = browser.page; await page.loginAndModule('employee', 'order'); + await page.waitFor(2000); await page.accessToSearchResult('16'); }); diff --git a/e2e/paths/07-order/05_index.spec.js b/e2e/paths/07-order/05_index.spec.js index ef55051aa..c07a9c6f7 100644 --- a/e2e/paths/07-order/05_index.spec.js +++ b/e2e/paths/07-order/05_index.spec.js @@ -15,9 +15,9 @@ describe('Order Index', () => { await browser.close(); }); - it(`should check the first search result doesn't contain a total of 0€`, async() => { + it(`should check the second search result doesn't contain a total of 0€`, async() => { await page.waitToClick(selectors.ordersIndex.searchButton); - const result = await page.waitToGetProperty(selectors.ordersIndex.firstSearchResultTotal, 'innerText'); + const result = await page.waitToGetProperty(selectors.ordersIndex.secondSearchResultTotal, 'innerText'); expect(result).not.toContain('0.00'); }); @@ -26,8 +26,8 @@ describe('Order Index', () => { await page.waitToClick(selectors.ordersIndex.openAdvancedSearch); await page.waitToClick(selectors.ordersIndex.advancedSearchShowEmptyCheckbox); await page.waitToClick(selectors.ordersIndex.advancedSearchButton); - await page.waitForTextInElement(selectors.ordersIndex.firstSearchResultTotal, '0.00'); - const result = await page.waitToGetProperty(selectors.ordersIndex.firstSearchResultTotal, 'innerText'); + await page.waitForTextInElement(selectors.ordersIndex.secondSearchResultTotal, '0.00'); + const result = await page.waitToGetProperty(selectors.ordersIndex.secondSearchResultTotal, 'innerText'); expect(result).toContain('0.00'); }); diff --git a/front/core/components/array-model/array-model.js b/front/core/components/array-model/array-model.js index 5b0b94cdc..7ebb95755 100644 --- a/front/core/components/array-model/array-model.js +++ b/front/core/components/array-model/array-model.js @@ -214,7 +214,7 @@ export default class ArrayModel extends ModelProxy { } ArrayModel.$inject = ['$q', '$filter', '$element', '$scope']; -ngModule.component('vnArrayModel', { +ngModule.vnComponent('vnArrayModel', { controller: ArrayModel, bindings: { orgData: ' -1) - this.input.value = this.$translate.instant(display); + this.input.value = this.$t(display); } } diff --git a/front/core/components/calendar/index.js b/front/core/components/calendar/index.js index 96bc435db..17bf52941 100644 --- a/front/core/components/calendar/index.js +++ b/front/core/components/calendar/index.js @@ -135,7 +135,10 @@ export default class Calendar extends FormInput { $days: [day], $type: 'day' }); - this.repaint(); + + // Repaint only if 'selection' event is not listening + if (!this.$events || this.$events && !this.$events['selection']) + this.repaint(); } /* diff --git a/front/core/components/chip/index.spec.js b/front/core/components/chip/index.spec.js index 60129fd69..fc93527d6 100644 --- a/front/core/components/chip/index.spec.js +++ b/front/core/components/chip/index.spec.js @@ -8,7 +8,7 @@ describe('Component vnChip', () => { beforeEach(ngModule('vnCore')); - beforeEach(angular.mock.inject(($componentController, $rootScope) => { + beforeEach(inject(($componentController, $rootScope) => { $scope = $rootScope.$new(); $element = angular.element(`
${template}
`); controller = $componentController('vnChip', {$element, $scope, $transclude: () => {}}); diff --git a/front/core/components/crud-model/crud-model.js b/front/core/components/crud-model/crud-model.js index 52052cc7f..9cfa3b410 100644 --- a/front/core/components/crud-model/crud-model.js +++ b/front/core/components/crud-model/crud-model.js @@ -272,7 +272,7 @@ export default class CrudModel extends ModelProxy { } CrudModel.$inject = ['$q', '$http', '$element', '$scope']; -ngModule.component('vnCrudModel', { +ngModule.vnComponent('vnCrudModel', { controller: CrudModel, bindings: { orgData: ' { beforeEach(ngModule('vnCore')); - beforeEach(angular.mock.inject(($compile, $rootScope, _$filter_) => { + beforeEach(inject(($compile, $rootScope, _$filter_) => { $filter = _$filter_; $element = $compile(``)($rootScope); diff --git a/front/core/components/dialog/index.spec.js b/front/core/components/dialog/index.spec.js index e8c8f6320..03720bf31 100644 --- a/front/core/components/dialog/index.spec.js +++ b/front/core/components/dialog/index.spec.js @@ -5,7 +5,7 @@ describe('Component vnDialog', () => { beforeEach(ngModule('vnCore')); - beforeEach(angular.mock.inject(($rootScope, $compile) => { + beforeEach(inject(($rootScope, $compile) => { $scope = $rootScope.$new(); $element = $compile('Body')($scope); controller = $element.controller('vnDialog'); diff --git a/front/core/components/drop-down/index.js b/front/core/components/drop-down/index.js index dfdfbe18d..fd5792da6 100644 --- a/front/core/components/drop-down/index.js +++ b/front/core/components/drop-down/index.js @@ -276,7 +276,7 @@ export default class DropDown extends Popover { if (this.translateFields) { option = Object.assign({}, option); for (let field of this.translateFields) - option[field] = this.$translate.instant(option[field]); + option[field] = this.$t(option[field]); } let li = this.document.createElement('li'); diff --git a/front/core/components/icon/icon.js b/front/core/components/icon/icon.js index 1b78f4693..38aea0056 100644 --- a/front/core/components/icon/icon.js +++ b/front/core/components/icon/icon.js @@ -25,7 +25,7 @@ class Icon { } Icon.$inject = ['$attrs']; -ngModule.component('vnIcon', { +ngModule.vnComponent('vnIcon', { template: '{{::$ctrl.iconContent}}', controller: Icon, bindings: { diff --git a/front/core/components/input-file/index.spec.js b/front/core/components/input-file/index.spec.js index 3b37a8d6c..25df9a47e 100644 --- a/front/core/components/input-file/index.spec.js +++ b/front/core/components/input-file/index.spec.js @@ -7,7 +7,7 @@ describe('Component vnInputFile', () => { beforeEach(ngModule('vnCore')); - beforeEach(angular.mock.inject(($compile, $rootScope) => { + beforeEach(inject(($compile, $rootScope) => { $scope = $rootScope.$new(); $element = $compile('')($scope); controller = $element.controller('vnInputFile'); diff --git a/front/core/components/input-number/index.spec.js b/front/core/components/input-number/index.spec.js index 0e0f8c4a5..5e80659f1 100644 --- a/front/core/components/input-number/index.spec.js +++ b/front/core/components/input-number/index.spec.js @@ -6,7 +6,7 @@ describe('Component vnInputNumber', () => { beforeEach(ngModule('vnCore')); - beforeEach(angular.mock.inject(($compile, $rootScope) => { + beforeEach(inject(($compile, $rootScope) => { $element = $compile(``)($rootScope); $ctrl = $element.controller('vnInputNumber'); })); diff --git a/front/core/components/input-time/index.spec.js b/front/core/components/input-time/index.spec.js index 39993b5cc..abb684df8 100644 --- a/front/core/components/input-time/index.spec.js +++ b/front/core/components/input-time/index.spec.js @@ -7,7 +7,7 @@ describe('Component vnInputTime', () => { beforeEach(ngModule('vnCore')); - beforeEach(angular.mock.inject(($compile, $rootScope, _$filter_) => { + beforeEach(inject(($compile, $rootScope, _$filter_) => { $filter = _$filter_; $element = $compile(``)($rootScope); diff --git a/front/core/components/label-value/index.js b/front/core/components/label-value/index.js index 71863f867..ec1e6c1a3 100644 --- a/front/core/components/label-value/index.js +++ b/front/core/components/label-value/index.js @@ -42,7 +42,7 @@ export default class Controller extends Component { } } -ngModule.component('vnLabelValue', { +ngModule.vnComponent('vnLabelValue', { controller: Controller, template: require('./index.html'), transclude: true, diff --git a/front/core/components/model-proxy/model-proxy.js b/front/core/components/model-proxy/model-proxy.js index 1eaf749d5..592b25710 100644 --- a/front/core/components/model-proxy/model-proxy.js +++ b/front/core/components/model-proxy/model-proxy.js @@ -30,7 +30,7 @@ export class DataModel extends Component { clear() {} } -ngModule.component('vnDataModel', { +ngModule.vnComponent('vnDataModel', { controller: DataModel, bindings: { data: '=?', @@ -269,7 +269,7 @@ export default class ModelProxy extends DataModel { } } -ngModule.component('vnModelProxy', { +ngModule.vnComponent('vnModelProxy', { controller: ModelProxy, bindings: { orgData: ' { beforeEach(ngModule('vnCore')); - beforeEach(angular.mock.inject($componentController => { + beforeEach(inject($componentController => { $element = angular.element(`
`); controller = $componentController('vnMultiCheck', {$element: $element}); controller._model = crudModel; diff --git a/front/core/components/pagination/pagination.js b/front/core/components/pagination/pagination.js index f1393aee8..9979be368 100644 --- a/front/core/components/pagination/pagination.js +++ b/front/core/components/pagination/pagination.js @@ -90,7 +90,7 @@ class Pagination extends Component { } } -ngModule.component('vnPagination', { +ngModule.vnComponent('vnPagination', { template: require('./pagination.html'), bindings: { model: '<', diff --git a/front/core/components/scroll-up/scroll-up.js b/front/core/components/scroll-up/scroll-up.js index 2ada05394..f18513bca 100644 --- a/front/core/components/scroll-up/scroll-up.js +++ b/front/core/components/scroll-up/scroll-up.js @@ -22,7 +22,7 @@ export default class Controller extends Component { Controller.$inject = ['$element', '$scope', '$window']; -ngModule.component('vnScrollUp', { +ngModule.vnComponent('vnScrollUp', { template: require('./scroll-up.html'), controller: Controller, bindings: { diff --git a/front/core/components/searchbar/searchbar.js b/front/core/components/searchbar/searchbar.js index 073b77f6e..0b7bd8cd2 100644 --- a/front/core/components/searchbar/searchbar.js +++ b/front/core/components/searchbar/searchbar.js @@ -36,7 +36,7 @@ export default class Searchbar extends Component { } this.searchState = `${this.baseState}.index`; - this.placeholder = this.$translate.instant('Search by', { + this.placeholder = this.$t('Search by', { module: this.baseState }); } @@ -189,7 +189,7 @@ export default class Searchbar extends Component { } doSearch(filter, source) { - if (filter === this.filter) return; + if (filter === this.filter && source != 'state') return; let promise = this.onSearch({$params: filter}); promise = promise || this.$q.resolve(); promise.then(data => this.onFilter(filter, source, data)); diff --git a/front/core/components/slot/portal.js b/front/core/components/slot/portal.js index f4dbecb09..40631c52e 100644 --- a/front/core/components/slot/portal.js +++ b/front/core/components/slot/portal.js @@ -19,7 +19,7 @@ export default class Portal { } Portal.$inject = ['$transclude', 'vnSlotService']; -ngModule.component('vnPortal', { +ngModule.vnComponent('vnPortal', { controller: Portal, transclude: true, bindings: { diff --git a/front/core/components/snackbar/snackbar.js b/front/core/components/snackbar/snackbar.js index 9439198f0..14d920211 100644 --- a/front/core/components/snackbar/snackbar.js +++ b/front/core/components/snackbar/snackbar.js @@ -144,7 +144,7 @@ export default class Controller extends Component { } } -ngModule.component('vnSnackbar', { +ngModule.vnComponent('vnSnackbar', { template: require('./snackbar.html'), controller: Controller }); diff --git a/front/core/components/spinner/spinner.js b/front/core/components/spinner/spinner.js index aee973aa6..ad535b6a4 100644 --- a/front/core/components/spinner/spinner.js +++ b/front/core/components/spinner/spinner.js @@ -54,4 +54,4 @@ export const component = { }, controller: Spinner }; -ngModule.component('vnSpinner', component); +ngModule.vnComponent('vnSpinner', component); diff --git a/front/core/components/spinner/spinner.spec.js b/front/core/components/spinner/spinner.spec.js index ef3c99623..fc1f8d207 100644 --- a/front/core/components/spinner/spinner.spec.js +++ b/front/core/components/spinner/spinner.spec.js @@ -6,7 +6,7 @@ describe('Component vnSpinner', () => { beforeEach(ngModule('vnCore')); - beforeEach(angular.mock.inject(($compile, $rootScope) => { + beforeEach(inject(($compile, $rootScope) => { $element = $compile(``)($rootScope); controller = $element.controller('vnSpinner'); })); diff --git a/front/core/components/step-control/step-control.js b/front/core/components/step-control/step-control.js index 0ca1f0c46..b5b3466ca 100644 --- a/front/core/components/step-control/step-control.js +++ b/front/core/components/step-control/step-control.js @@ -74,7 +74,7 @@ export default class StepControl { StepControl.$inject = ['$state']; -ngModule.component('vnStepControl', { +ngModule.vnComponent('vnStepControl', { template: require('./step-control.html'), controller: StepControl, bindings: { diff --git a/front/core/components/step-control/step-control.spec.js b/front/core/components/step-control/step-control.spec.js index 11a157470..d4fbbb1eb 100644 --- a/front/core/components/step-control/step-control.spec.js +++ b/front/core/components/step-control/step-control.spec.js @@ -6,7 +6,7 @@ describe('Component vnStepControl', () => { beforeEach(ngModule('vnCore')); - beforeEach(angular.mock.inject(($componentController, _$state_) => { + beforeEach(inject(($componentController, _$state_) => { $state = _$state_; jest.spyOn($state, 'go'); controller = $componentController('vnStepControl', {$state: $state}); diff --git a/front/core/components/table/index.js b/front/core/components/table/index.js index 0b9236c84..a61b97485 100644 --- a/front/core/components/table/index.js +++ b/front/core/components/table/index.js @@ -45,7 +45,7 @@ export default class Table { Table.$inject = ['$scope', '$element', '$transclude']; -ngModule.component('vnTable', { +ngModule.vnComponent('vnTable', { template: require('./index.html'), transclude: true, controller: Table, diff --git a/front/core/components/table/index.spec.js b/front/core/components/table/index.spec.js index 40e1ef74e..631111b72 100644 --- a/front/core/components/table/index.spec.js +++ b/front/core/components/table/index.spec.js @@ -7,7 +7,7 @@ describe('Component vnTable', () => { beforeEach(ngModule('vnCore')); - beforeEach(angular.mock.inject(($componentController, $rootScope) => { + beforeEach(inject(($componentController, $rootScope) => { $scope = $rootScope.$new(); $element = angular.element(` diff --git a/front/core/components/td-editable/index.js b/front/core/components/td-editable/index.js index 844e7501e..b3ef1e436 100644 --- a/front/core/components/td-editable/index.js +++ b/front/core/components/td-editable/index.js @@ -94,7 +94,7 @@ export default class Controller extends Component { } Controller.$inject = ['$element', '$scope', '$transclude', '$timeout']; -ngModule.component('vnTdEditable', { +ngModule.vnComponent('vnTdEditable', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/front/core/components/textarea/index.spec.js b/front/core/components/textarea/index.spec.js index fc153be93..ea105db13 100644 --- a/front/core/components/textarea/index.spec.js +++ b/front/core/components/textarea/index.spec.js @@ -6,7 +6,7 @@ describe('Component vnTextarea', () => { beforeEach(ngModule('vnCore')); - beforeEach(angular.mock.inject(($compile, $rootScope) => { + beforeEach(inject(($compile, $rootScope) => { $element = $compile(``)($rootScope); $ctrl = $element.controller('vnTextarea'); })); diff --git a/front/core/components/th/index.js b/front/core/components/th/index.js index 682fb4eb1..b8260bd74 100644 --- a/front/core/components/th/index.js +++ b/front/core/components/th/index.js @@ -75,7 +75,7 @@ export default class Th { Th.$inject = ['$element']; -ngModule.component('vnTh', { +ngModule.vnComponent('vnTh', { template: require('./index.html'), transclude: true, controller: Th, diff --git a/front/core/components/th/index.spec.js b/front/core/components/th/index.spec.js index ce6dbeec5..a00f73cc9 100644 --- a/front/core/components/th/index.spec.js +++ b/front/core/components/th/index.spec.js @@ -7,7 +7,7 @@ describe('Component vnTh', () => { beforeEach(ngModule('vnCore')); - beforeEach(angular.mock.inject($componentController => { + beforeEach(inject($componentController => { $element = angular.element(`
${template}
`); controller = $componentController('vnTh', {$element: $element}); controller.table = { diff --git a/front/core/components/tooltip/tooltip.js b/front/core/components/tooltip/tooltip.js index 72d69f83d..e2dba2d03 100644 --- a/front/core/components/tooltip/tooltip.js +++ b/front/core/components/tooltip/tooltip.js @@ -197,7 +197,7 @@ export default class Tooltip extends Component { } Tooltip.$inject = ['$element', '$scope', '$timeout']; -ngModule.component('vnTooltip', { +ngModule.vnComponent('vnTooltip', { template: require('./tooltip.html'), controller: Tooltip, transclude: true, diff --git a/front/core/components/treeview/child.js b/front/core/components/treeview/child.js index 9e4edef35..36db07601 100644 --- a/front/core/components/treeview/child.js +++ b/front/core/components/treeview/child.js @@ -49,7 +49,7 @@ class Controller { } Controller.$inject = ['$element', '$scope', '$compile']; -ngModule.component('vnTreeviewChild', { +ngModule.vnComponent('vnTreeviewChild', { template: require('./child.html'), controller: Controller, bindings: { diff --git a/front/core/components/treeview/childs.js b/front/core/components/treeview/childs.js index 03ae30233..dfb241ed2 100644 --- a/front/core/components/treeview/childs.js +++ b/front/core/components/treeview/childs.js @@ -2,7 +2,7 @@ import ngModule from '../../module'; class Controller {} -ngModule.component('vnTreeviewChilds', { +ngModule.vnComponent('vnTreeviewChilds', { template: require('./childs.html'), controller: Controller, bindings: { diff --git a/front/core/components/treeview/index.js b/front/core/components/treeview/index.js index b39ff7b46..848440cdc 100644 --- a/front/core/components/treeview/index.js +++ b/front/core/components/treeview/index.js @@ -247,7 +247,7 @@ export default class Treeview extends Component { Treeview.$inject = ['$element', '$scope', '$transclude', '$window']; -ngModule.component('vnTreeview', { +ngModule.vnComponent('vnTreeview', { template: require('./index.html'), controller: Treeview, bindings: { diff --git a/front/core/components/watcher/watcher.js b/front/core/components/watcher/watcher.js index 1a1abffa5..9de9d8c1b 100644 --- a/front/core/components/watcher/watcher.js +++ b/front/core/components/watcher/watcher.js @@ -267,7 +267,7 @@ export default class Watcher extends Component { } Watcher.$inject = ['$element', '$scope', '$state', '$stateParams', '$transitions', '$http', 'vnApp', '$translate', '$attrs', '$q']; -ngModule.component('vnWatcher', { +ngModule.vnComponent('vnWatcher', { template: require('./watcher.html'), bindings: { url: '@?', diff --git a/front/core/components/watcher/watcher.spec.js b/front/core/components/watcher/watcher.spec.js index 6c2567f7e..e19592387 100644 --- a/front/core/components/watcher/watcher.spec.js +++ b/front/core/components/watcher/watcher.spec.js @@ -12,7 +12,7 @@ describe('Component vnWatcher', () => { beforeEach(ngModule('vnCore')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$state_, _$q_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$state_, _$q_) => { $scope = $rootScope.$new(); $element = angular.element('
'); $state = _$state_; diff --git a/front/core/directives/specs/zoom-image.spec.js b/front/core/directives/specs/zoom-image.spec.js index f9d9c1801..541bc65f2 100644 --- a/front/core/directives/specs/zoom-image.spec.js +++ b/front/core/directives/specs/zoom-image.spec.js @@ -7,7 +7,7 @@ describe('Directive zoomImage', () => { beforeEach(ngModule('vnCore')); - beforeEach(angular.mock.inject(($compile, $rootScope) => { + beforeEach(inject(($compile, $rootScope) => { compile = $compile; scope = $rootScope.$new(); })); diff --git a/front/core/lib/specs/module-loader.spec.js b/front/core/lib/specs/module-loader.spec.js index dbed5e9a0..811922169 100644 --- a/front/core/lib/specs/module-loader.spec.js +++ b/front/core/lib/specs/module-loader.spec.js @@ -5,7 +5,7 @@ describe('factory vnModuleLoader', () => { beforeEach(ngModule('vnCore')); - beforeEach(angular.mock.inject((_vnModuleLoader_, _$rootScope_, $httpBackend, _$window_, $q) => { + beforeEach(inject((_vnModuleLoader_, _$rootScope_, $httpBackend, _$window_, $q) => { vnModuleLoader = _vnModuleLoader_; $rootScope = _$rootScope_; $window = _$window_; diff --git a/front/salix/components/descriptor/index.js b/front/salix/components/descriptor/index.js index 3d6dd1b3f..333360d2b 100644 --- a/front/salix/components/descriptor/index.js +++ b/front/salix/components/descriptor/index.js @@ -107,7 +107,7 @@ export class DescriptorContent { } DescriptorContent.$inject = ['$transclude', 'vnModules']; -ngModule.component('vnDescriptorContent', { +ngModule.vnComponent('vnDescriptorContent', { template: require('./index.html'), controller: DescriptorContent, bindings: { diff --git a/front/salix/components/descriptor/quick-link.js b/front/salix/components/descriptor/quick-link.js index 545f235a0..cd85f5250 100644 --- a/front/salix/components/descriptor/quick-link.js +++ b/front/salix/components/descriptor/quick-link.js @@ -2,7 +2,7 @@ import ngModule from '../../module'; export default class QuickLink {} -ngModule.component('vnQuickLink', { +ngModule.vnComponent('vnQuickLink', { template: require('./quick-link.html'), controller: QuickLink, bindings: { diff --git a/front/salix/components/home/home.js b/front/salix/components/home/home.js index 367880b31..3da49a265 100644 --- a/front/salix/components/home/home.js +++ b/front/salix/components/home/home.js @@ -28,7 +28,7 @@ export default class Controller extends Component { } Controller.$inject = ['$element', '$scope', 'vnModules', '$sce']; -ngModule.component('vnHome', { +ngModule.vnComponent('vnHome', { template: require('./home.html'), controller: Controller }); diff --git a/front/salix/components/layout/index..js b/front/salix/components/layout/index..js deleted file mode 100644 index 9fdcfc034..000000000 --- a/front/salix/components/layout/index..js +++ /dev/null @@ -1,24 +0,0 @@ -import './index.js'; - -describe('Component vnMainMenu', () => { - let $httpBackend; - let controller; - - beforeEach(ngModule('salix')); - - beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => { - let vnModules = {get: () => {}}; - $httpBackend = _$httpBackend_; - controller = $componentController('vnMainMenu', {vnModules}); - })); - - describe('getCurrentUserName()', () => { - it(`should set the user name property in the controller`, () => { - $httpBackend.expect('GET', `Accounts/getUserData`).respond({name: 'batman'}); - controller.getCurrentUserName(); - $httpBackend.flush(); - - expect(controller.$.$root.user.name).toEqual('batman'); - }); - }); -}); diff --git a/front/salix/components/layout/index.js b/front/salix/components/layout/index.js index 883b010ba..b8ca74b99 100644 --- a/front/salix/components/layout/index.js +++ b/front/salix/components/layout/index.js @@ -21,7 +21,7 @@ export class Layout extends Component { } Layout.$inject = ['$element', '$scope', 'vnModules']; -ngModule.component('vnLayout', { +ngModule.vnComponent('vnLayout', { template: require('./index.html'), controller: Layout, require: { diff --git a/front/salix/components/layout/index.spec.js b/front/salix/components/layout/index.spec.js index 7163acb65..18aca1f01 100644 --- a/front/salix/components/layout/index.spec.js +++ b/front/salix/components/layout/index.spec.js @@ -6,7 +6,7 @@ describe('Component vnLayout', () => { beforeEach(ngModule('salix')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => { + beforeEach(inject(($componentController, _$httpBackend_) => { let vnModules = {get: () => {}}; $httpBackend = _$httpBackend_; let $element = angular.element('
'); diff --git a/front/salix/components/left-menu/left-menu.js b/front/salix/components/left-menu/left-menu.js index c4bba64dd..5f047060a 100644 --- a/front/salix/components/left-menu/left-menu.js +++ b/front/salix/components/left-menu/left-menu.js @@ -117,7 +117,7 @@ export default class LeftMenu { } LeftMenu.$inject = ['$state', '$transitions', 'aclService', '$timeout', '$element']; -ngModule.component('vnLeftMenu', { +ngModule.vnComponent('vnLeftMenu', { template: require('./left-menu.html'), controller: LeftMenu, bindings: { diff --git a/front/salix/components/left-menu/left-menu.spec.js b/front/salix/components/left-menu/left-menu.spec.js index 84c1b60d4..56d7ea10d 100644 --- a/front/salix/components/left-menu/left-menu.spec.js +++ b/front/salix/components/left-menu/left-menu.spec.js @@ -6,7 +6,7 @@ describe('Component vnLeftMenu', () => { beforeEach(ngModule('salix')); - beforeEach(angular.mock.inject(($componentController, $state, $window) => { + beforeEach(inject(($componentController, $state, $window) => { $element = angular.element('
'); $state.current.name = 'client.card.summary'; $state.current.data = {moduleIndex: 0}; diff --git a/front/salix/components/login/login.js b/front/salix/components/login/login.js index efb5e02bb..b5f8c1e7d 100644 --- a/front/salix/components/login/login.js +++ b/front/salix/components/login/login.js @@ -37,7 +37,7 @@ export default class Controller { } Controller.$inject = ['$scope', '$element', 'vnAuth']; -ngModule.component('vnLogin', { +ngModule.vnComponent('vnLogin', { template: require('./login.html'), controller: Controller }); diff --git a/front/salix/components/side-menu/side-menu.js b/front/salix/components/side-menu/side-menu.js index c2b5b421e..0e683b4bb 100644 --- a/front/salix/components/side-menu/side-menu.js +++ b/front/salix/components/side-menu/side-menu.js @@ -68,7 +68,7 @@ export default class SideMenu extends Component { } } -ngModule.component('vnSideMenu', { +ngModule.vnComponent('vnSideMenu', { template: require('./side-menu.html'), controller: SideMenu, transclude: true, diff --git a/front/salix/components/user-popover/index.js b/front/salix/components/user-popover/index.js index 88efb26d1..c2fb6a130 100644 --- a/front/salix/components/user-popover/index.js +++ b/front/salix/components/user-popover/index.js @@ -80,7 +80,7 @@ class Controller { } Controller.$inject = ['$scope', '$translate', 'vnConfig', 'vnAuth']; -ngModule.component('vnUserPopover', { +ngModule.vnComponent('vnUserPopover', { template: require('./index.html'), controller: Controller }); diff --git a/front/salix/components/user-popover/index.spec.js b/front/salix/components/user-popover/index.spec.js index 217471ca5..a0f1a953c 100644 --- a/front/salix/components/user-popover/index.spec.js +++ b/front/salix/components/user-popover/index.spec.js @@ -7,7 +7,7 @@ describe('Salix', () => { beforeEach(ngModule('salix')); - beforeEach(angular.mock.inject(($componentController, $rootScope, $httpBackend) => { + beforeEach(inject(($componentController, $rootScope, $httpBackend) => { $httpBackend.expectGET('UserConfigs/getUserConfig'); $scope = $rootScope.$new(); diff --git a/loopback/.DS_Store b/loopback/.DS_Store deleted file mode 100644 index 5eff1eaf0..000000000 Binary files a/loopback/.DS_Store and /dev/null differ diff --git a/loopback/common/models/loggable.js b/loopback/common/models/loggable.js index 99a1ad39b..eaa44f9ba 100644 --- a/loopback/common/models/loggable.js +++ b/loopback/common/models/loggable.js @@ -249,7 +249,6 @@ module.exports = function(Self) { let newInstance = {}; if (ctx.hookState.newInstance) Object.assign(newInstance, ctx.hookState.newInstance); - let userFk; if (loopBackContext) userFk = loopBackContext.active.accessToken.userId; diff --git a/loopback/locale/es.json b/loopback/locale/es.json index e58d55da0..9951df4a5 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -133,5 +133,6 @@ "Distance must be lesser than 1000": "La distancia debe ser inferior a 1000", "This ticket is deleted": "Este ticket está eliminado", "A travel with this data already exists": "Ya existe un travel con estos datos", - "This thermograph id already exists": "La id del termógrafo ya existe" + "This thermograph id already exists": "La id del termógrafo ya existe", + "ORDER_ALREADY_CONFIRMED": "ORDER_ALREADY_CONFIRMED" } \ No newline at end of file diff --git a/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js b/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js index ecaccd4e4..1d3bff26d 100644 --- a/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js +++ b/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js @@ -1,7 +1,6 @@ const app = require('vn-loopback/server/server'); -// #2304 -xdescribe('regularizeClaim()', () => { +describe('regularizeClaim()', () => { const claimFk = 1; const pendentState = 1; const resolvedState = 3; diff --git a/modules/claim/back/models/claim-beginning.js b/modules/claim/back/models/claim-beginning.js index 19e5eb4eb..681aaebc7 100644 --- a/modules/claim/back/models/claim-beginning.js +++ b/modules/claim/back/models/claim-beginning.js @@ -22,7 +22,8 @@ module.exports = Self => { async function claimIsEditable(ctx) { const loopBackContext = LoopBackContext.getCurrentContext(); const httpCtx = {req: loopBackContext.active}; - const isEditable = await Self.app.models.Claim.isEditable(httpCtx, ctx.where.id); + const claimBeginning = await Self.findById(ctx.where.id); + const isEditable = await Self.app.models.Claim.isEditable(httpCtx, claimBeginning.claimFk); if (!isEditable) throw new UserError(`The current claim can't be modified`); diff --git a/modules/claim/front/action/index.js b/modules/claim/front/action/index.js index 2ba010ef2..2010d75c8 100644 --- a/modules/claim/front/action/index.js +++ b/modules/claim/front/action/index.js @@ -154,7 +154,7 @@ export default class Controller extends Section { } } -ngModule.component('vnClaimAction', { +ngModule.vnComponent('vnClaimAction', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/claim/front/action/index.spec.js b/modules/claim/front/action/index.spec.js index c477984d9..34899537b 100644 --- a/modules/claim/front/action/index.spec.js +++ b/modules/claim/front/action/index.spec.js @@ -9,7 +9,7 @@ describe('claim', () => { beforeEach(ngModule('claim')); - beforeEach(angular.mock.inject(($componentController, _$state_, _$httpBackend_) => { + beforeEach(inject(($componentController, _$state_, _$httpBackend_) => { $httpBackend = _$httpBackend_; $state = _$state_; $state.params.id = 1; @@ -91,7 +91,7 @@ describe('claim', () => { $httpBackend.flush(); expect(controller.$.model.refresh).toHaveBeenCalledWith(); - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); + expect(controller.vnApp.showSuccess).toHaveBeenCalled(); expect(controller.$.lastTicketsPopover.hide).toHaveBeenCalledWith(); }); }); @@ -106,7 +106,7 @@ describe('claim', () => { $httpBackend.flush(); expect(controller.card.reload).toHaveBeenCalledWith(); - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); + expect(controller.vnApp.showSuccess).toHaveBeenCalled(); }); }); diff --git a/modules/claim/front/basic-data/index.js b/modules/claim/front/basic-data/index.js index c3eac92ff..9fa3bdf4d 100644 --- a/modules/claim/front/basic-data/index.js +++ b/modules/claim/front/basic-data/index.js @@ -11,7 +11,7 @@ class Controller extends Section { } } -ngModule.component('vnClaimBasicData', { +ngModule.vnComponent('vnClaimBasicData', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/claim/front/basic-data/index.spec.js b/modules/claim/front/basic-data/index.spec.js index 65e934cb8..638f88418 100644 --- a/modules/claim/front/basic-data/index.spec.js +++ b/modules/claim/front/basic-data/index.spec.js @@ -8,7 +8,7 @@ describe('Claim', () => { beforeEach(ngModule('claim')); - beforeEach(angular.mock.inject(($componentController, $rootScope) => { + beforeEach(inject(($componentController, $rootScope) => { $scope = $rootScope.$new(); $scope.watcher = watcher; const $element = angular.element(''); diff --git a/modules/claim/front/card/index.spec.js b/modules/claim/front/card/index.spec.js index 1b2344925..aa796c1e3 100644 --- a/modules/claim/front/card/index.spec.js +++ b/modules/claim/front/card/index.spec.js @@ -8,7 +8,7 @@ describe('Claim', () => { beforeEach(ngModule('claim')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $stateParams) => { + beforeEach(inject(($componentController, _$httpBackend_, $stateParams) => { $httpBackend = _$httpBackend_; let $element = angular.element('
'); diff --git a/modules/claim/front/detail/index.js b/modules/claim/front/detail/index.js index 7719a9fc9..b1c6c81e0 100644 --- a/modules/claim/front/detail/index.js +++ b/modules/claim/front/detail/index.js @@ -22,16 +22,25 @@ class Controller extends Section { }; } - set salesClaimed(value) { - this._salesClaimed = value; + get claim() { + return this._claim; + } + + set claim(value) { + this._claim = value; if (value) { - this.calculateTotals(); this.isClaimEditable(); this.isTicketEditable(); } } + set salesClaimed(value) { + this._salesClaimed = value; + + if (value) this.calculateTotals(); + } + get salesClaimed() { return this._salesClaimed; } @@ -66,7 +75,7 @@ class Controller extends Section { this.$http.post(query, saleToAdd).then(() => { this.$.addSales.hide(); this.$.model.refresh(); - this.vnApp.showSuccess(this.$translate.instant('Data saved!')); + this.vnApp.showSuccess(this.$t('Data saved!')); if (this.aclService.hasAny(['salesAssistant'])) this.$state.go('claim.card.development'); @@ -81,7 +90,7 @@ class Controller extends Section { deleteClaimedSale() { let query = `ClaimBeginnings/${this.sale.id}`; this.$http.delete(query).then(() => { - this.vnApp.showSuccess(this.$translate.instant('Data saved!')); + this.vnApp.showSuccess(this.$t('Data saved!')); this.$.model.remove(this.sale); this.calculateTotals(); }); @@ -91,7 +100,7 @@ class Controller extends Section { let params = {id: id, quantity: claimedQuantity}; let query = `ClaimBeginnings/`; this.$http.patch(query, params).then(() => { - this.vnApp.showSuccess(this.$translate.instant('Data saved!')); + this.vnApp.showSuccess(this.$t('Data saved!')); this.calculateTotals(); }); } @@ -125,7 +134,7 @@ class Controller extends Section { showEditPopover(event, saleClaimed) { if (this.isEditable) { if (!this.aclService.hasAny(['salesAssistant'])) - return this.vnApp.showError(this.$translate.instant('Insuficient permisos')); + return this.vnApp.showError(this.$t('Insuficient permisos')); this.saleClaimed = saleClaimed; this.$.editPopover.parent = event.target; @@ -166,7 +175,7 @@ class Controller extends Section { this.calculateTotals(); this.clearDiscount(); - this.vnApp.showSuccess(this.$translate.instant('Data saved!')); + this.vnApp.showSuccess(this.$t('Data saved!')); }).catch(err => { this.vnApp.showError(err.message); }); @@ -187,7 +196,7 @@ class Controller extends Section { Controller.$inject = ['$element', '$scope']; -ngModule.component('vnClaimDetail', { +ngModule.vnComponent('vnClaimDetail', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/claim/front/detail/index.spec.js b/modules/claim/front/detail/index.spec.js index 5061eaff7..972d487e5 100644 --- a/modules/claim/front/detail/index.spec.js +++ b/modules/claim/front/detail/index.spec.js @@ -9,7 +9,7 @@ describe('claim', () => { beforeEach(ngModule('claim')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope) => { + beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { $scope = $rootScope.$new(); $scope.descriptor = { show: () => {} @@ -80,7 +80,7 @@ describe('claim', () => { controller.deleteClaimedSale(); $httpBackend.flush(); - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); + expect(controller.vnApp.showSuccess).toHaveBeenCalled(); }); }); @@ -91,7 +91,7 @@ describe('claim', () => { controller.setClaimedQuantity(1, 1); $httpBackend.flush(); - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); + expect(controller.vnApp.showSuccess).toHaveBeenCalled(); }); }); @@ -126,7 +126,7 @@ describe('claim', () => { expect(controller.calculateTotals).toHaveBeenCalledWith(); expect(controller.clearDiscount).toHaveBeenCalledWith(); - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); + expect(controller.vnApp.showSuccess).toHaveBeenCalled(); expect(controller.$.editPopover.hide).toHaveBeenCalledWith(); }); }); diff --git a/modules/claim/front/development/index.js b/modules/claim/front/development/index.js index cc86d5452..a19654c56 100644 --- a/modules/claim/front/development/index.js +++ b/modules/claim/front/development/index.js @@ -15,7 +15,7 @@ class Controller extends Section { } } -ngModule.component('vnClaimDevelopment', { +ngModule.vnComponent('vnClaimDevelopment', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/claim/front/development/index.spec.js b/modules/claim/front/development/index.spec.js index 5708f82f2..e2574ccb9 100644 --- a/modules/claim/front/development/index.spec.js +++ b/modules/claim/front/development/index.spec.js @@ -9,7 +9,7 @@ describe('Claim', () => { beforeEach(ngModule('claim')); - beforeEach(angular.mock.inject(($componentController, $rootScope) => { + beforeEach(inject(($componentController, $rootScope) => { $scope = $rootScope.$new(); $scope.watcher = watcher; $scope.model = crudModel; diff --git a/modules/claim/front/index/index.js b/modules/claim/front/index/index.js index 773c6a999..fe4b6def7 100644 --- a/modules/claim/front/index/index.js +++ b/modules/claim/front/index/index.js @@ -19,7 +19,7 @@ export default class Controller extends Section { } } -ngModule.component('vnClaimIndex', { +ngModule.vnComponent('vnClaimIndex', { template: require('./index.html'), controller: Controller }); diff --git a/modules/claim/front/photos/index.js b/modules/claim/front/photos/index.js index 38cb89ad1..2b77c6abc 100644 --- a/modules/claim/front/photos/index.js +++ b/modules/claim/front/photos/index.js @@ -93,7 +93,7 @@ class Controller extends Section { Controller.$inject = ['$element', '$scope', 'vnFile']; -ngModule.component('vnClaimPhotos', { +ngModule.vnComponent('vnClaimPhotos', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/claim/front/photos/index.spec.js b/modules/claim/front/photos/index.spec.js index 9cb893bae..38e77d13f 100644 --- a/modules/claim/front/photos/index.spec.js +++ b/modules/claim/front/photos/index.spec.js @@ -9,7 +9,7 @@ describe('Claim', () => { beforeEach(ngModule('claim')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); controller = $componentController('vnClaimPhotos', {$element: null, $scope}); diff --git a/modules/claim/front/search-panel/index.js b/modules/claim/front/search-panel/index.js index b6bd2b974..a7e8fb046 100644 --- a/modules/claim/front/search-panel/index.js +++ b/modules/claim/front/search-panel/index.js @@ -1,7 +1,7 @@ import ngModule from '../module'; import SearchPanel from 'core/components/searchbar/search-panel'; -ngModule.component('vnClaimSearchPanel', { +ngModule.vnComponent('vnClaimSearchPanel', { template: require('./index.html'), controller: SearchPanel }); diff --git a/modules/claim/front/summary/index.js b/modules/claim/front/summary/index.js index 6e62252d5..6991e0975 100644 --- a/modules/claim/front/summary/index.js +++ b/modules/claim/front/summary/index.js @@ -45,7 +45,7 @@ class Controller extends Section { Controller.$inject = ['$element', '$scope', 'vnFile']; -ngModule.component('vnClaimSummary', { +ngModule.vnComponent('vnClaimSummary', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/claim/front/summary/index.spec.js b/modules/claim/front/summary/index.spec.js index b6e03d929..d6300b30a 100644 --- a/modules/claim/front/summary/index.spec.js +++ b/modules/claim/front/summary/index.spec.js @@ -9,7 +9,7 @@ describe('Claim', () => { beforeEach(ngModule('claim')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope) => { + beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { $scope = $rootScope.$new(); $httpBackend = _$httpBackend_; const $element = angular.element(''); @@ -20,8 +20,7 @@ describe('Claim', () => { describe('getSummary()', () => { it('should perform a query to set summary', () => { - $httpBackend.when('GET', `Claims/1/getSummary`).respond(200, 24); - $httpBackend.expect('GET', `Claims/1/getSummary`); + $httpBackend.expect('GET', `Claims/1/getSummary`).respond(200, 24); controller.getSummary(); $httpBackend.flush(); diff --git a/modules/client/back/methods/client/consumption.js b/modules/client/back/methods/client/consumption.js index cb5b39c29..8430c4661 100644 --- a/modules/client/back/methods/client/consumption.js +++ b/modules/client/back/methods/client/consumption.js @@ -17,20 +17,20 @@ module.exports = Self => { type: 'String', description: `If it's and integer searchs by id, otherwise it searchs by name` }, { - arg: 'itemFk', - type: 'Integer', + arg: 'itemId', + type: 'Number', description: 'Item id' }, { - arg: 'categoryFk', - type: 'Integer', + arg: 'categoryId', + type: 'Number', description: 'Category id' }, { - arg: 'typeFk', - type: 'Integer', + arg: 'typeId', + type: 'Number', description: 'Item type id', }, { - arg: 'buyerFk', - type: 'Integer', + arg: 'buyerId', + type: 'Number', description: 'Buyer id' }, { arg: 'from', @@ -75,6 +75,10 @@ module.exports = Self => { return {'it.id': value}; case 'buyerId': return {'it.workerFk': value}; + case 'from': + return {'t.shipped': {gte: value}}; + case 'to': + return {'t.shipped': {lte: value}}; } }); filter = mergeFilters(filter, {where}); diff --git a/modules/client/back/methods/client/getCard.js b/modules/client/back/methods/client/getCard.js index 6c69d32a8..121534b02 100644 --- a/modules/client/back/methods/client/getCard.js +++ b/modules/client/back/methods/client/getCard.js @@ -27,11 +27,11 @@ module.exports = function(Self) { { relation: 'salesPerson', scope: { - fields: ['userFk'], + fields: ['userFk', 'firstName'], include: { relation: 'user', scope: { - fields: ['nickname'] + fields: ['name', 'nickname'] } } } @@ -45,6 +45,12 @@ module.exports = function(Self) { scope: { fields: ['id', 'name'] } + }, { + }, { + relation: 'salesPersonUser', + scope: { + fields: ['id', 'name'] + } }, { relation: 'country', scope: { diff --git a/modules/client/back/methods/client/specs/activeWorkersWithRole.spec.js b/modules/client/back/methods/client/specs/activeWorkersWithRole.spec.js index 8e9af247a..7eb8e7ed9 100644 --- a/modules/client/back/methods/client/specs/activeWorkersWithRole.spec.js +++ b/modules/client/back/methods/client/specs/activeWorkersWithRole.spec.js @@ -17,7 +17,7 @@ describe('Client activeWorkersWithRole', () => { let isBuyer = await app.models.Account.hasRole(result[0].id, 'buyer'); - expect(result.length).toEqual(13); + expect(result.length).toEqual(15); expect(isBuyer).toBeTruthy(); }); }); diff --git a/modules/client/back/methods/client/specs/consumption.spec.js b/modules/client/back/methods/client/specs/consumption.spec.js index e7a42a8da..30a0572b3 100644 --- a/modules/client/back/methods/client/specs/consumption.spec.js +++ b/modules/client/back/methods/client/specs/consumption.spec.js @@ -37,4 +37,24 @@ describe('client consumption() filter', () => { expect(secondRow.quantity).toEqual(15); expect(thirdRow.quantity).toEqual(20); }); + + it('should return a list of tickets from the item id 4', async() => { + const ctx = {req: {accessToken: {userId: 9}}, + args: { + itemId: 4 + } + }; + const filter = { + where: { + clientFk: 101 + }, + order: 'itemTypeFk, itemName, itemSize' + }; + const result = await app.models.Client.consumption(ctx, filter); + + const expectedItemId = 4; + const firstRow = result[0]; + + expect(firstRow.itemFk).toEqual(expectedItemId); + }); }); diff --git a/modules/client/back/methods/client/specs/getCard.spec.js b/modules/client/back/methods/client/specs/getCard.spec.js index 18519d440..1483af48b 100644 --- a/modules/client/back/methods/client/specs/getCard.spec.js +++ b/modules/client/back/methods/client/specs/getCard.spec.js @@ -7,6 +7,6 @@ describe('Client get', () => { expect(result.id).toEqual(101); expect(result.name).toEqual('Bruce Wayne'); - expect(result.debt).toEqual(889.38); + expect(result.debt).toEqual(879.38); }); }); diff --git a/modules/client/back/methods/client/specs/getDebt.spec.js b/modules/client/back/methods/client/specs/getDebt.spec.js index 9e539c219..60696e344 100644 --- a/modules/client/back/methods/client/specs/getDebt.spec.js +++ b/modules/client/back/methods/client/specs/getDebt.spec.js @@ -4,7 +4,7 @@ describe('client getDebt()', () => { it('should return the client debt', async() => { let result = await app.models.Client.getDebt(101); - expect(result.debt).toEqual(889.38); + expect(result.debt).toEqual(879.38); }); }); diff --git a/modules/client/back/methods/client/specs/summary.spec.js b/modules/client/back/methods/client/specs/summary.spec.js index e4ebd9c67..3c79060a8 100644 --- a/modules/client/back/methods/client/specs/summary.spec.js +++ b/modules/client/back/methods/client/specs/summary.spec.js @@ -17,7 +17,7 @@ describe('client summary()', () => { it('should return a summary object containing debt', async() => { let result = await app.models.Client.summary(101); - expect(result.debt.debt).toEqual(889.38); + expect(result.debt.debt).toEqual(879.38); }); it('should return a summary object containing averageInvoiced', async() => { diff --git a/modules/client/back/models/client.json b/modules/client/back/models/client.json index c62ae3832..6f108d640 100644 --- a/modules/client/back/models/client.json +++ b/modules/client/back/models/client.json @@ -136,6 +136,11 @@ "model": "Worker", "foreignKey": "salesPersonFk" }, + "salesPersonUser": { + "type": "belongsTo", + "model": "Account", + "foreignKey": "salesPersonFk" + }, "province": { "type": "belongsTo", "model": "Province", diff --git a/modules/client/front/address/create/index.js b/modules/client/front/address/create/index.js index 79774cf93..02c98ab3b 100644 --- a/modules/client/front/address/create/index.js +++ b/modules/client/front/address/create/index.js @@ -79,7 +79,7 @@ export default class Controller extends Section { Controller.$inject = ['$element', '$scope']; -ngModule.component('vnClientAddressCreate', { +ngModule.vnComponent('vnClientAddressCreate', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/client/front/address/create/index.spec.js b/modules/client/front/address/create/index.spec.js index 4f332e75e..1a4340115 100644 --- a/modules/client/front/address/create/index.spec.js +++ b/modules/client/front/address/create/index.spec.js @@ -11,7 +11,7 @@ describe('Client', () => { beforeEach(ngModule('client')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$state_, _$httpBackend_) => { + beforeEach(inject(($componentController, $rootScope, _$state_, _$httpBackend_) => { $scope = $rootScope.$new(); $httpBackend = _$httpBackend_; $state = _$state_; diff --git a/modules/client/front/address/edit/index.js b/modules/client/front/address/edit/index.js index 58bca6322..363621327 100644 --- a/modules/client/front/address/edit/index.js +++ b/modules/client/front/address/edit/index.js @@ -81,7 +81,7 @@ export default class Controller extends Section { } } -ngModule.component('vnClientAddressEdit', { +ngModule.vnComponent('vnClientAddressEdit', { template: require('./index.html'), controller: Controller, require: { diff --git a/modules/client/front/address/edit/index.spec.js b/modules/client/front/address/edit/index.spec.js index c4c1a78b5..f763495ac 100644 --- a/modules/client/front/address/edit/index.spec.js +++ b/modules/client/front/address/edit/index.spec.js @@ -10,7 +10,7 @@ describe('Client', () => { beforeEach(ngModule('client')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$state_, _$httpBackend_) => { + beforeEach(inject(($componentController, $rootScope, _$state_, _$httpBackend_) => { $scope = $rootScope.$new(); $httpBackend = _$httpBackend_; $state = _$state_; diff --git a/modules/client/front/address/index/index.js b/modules/client/front/address/index/index.js index 6a9d7507b..ea6a9f6b9 100644 --- a/modules/client/front/address/index/index.js +++ b/modules/client/front/address/index/index.js @@ -50,7 +50,7 @@ class Controller extends Section { if (res.data) { this.client.defaultAddressFk = res.data.defaultAddressFk; this.sortAddresses(); - this.vnApp.showSuccess(this.$translate.instant('Data saved!')); + this.vnApp.showSuccess(this.$t('Data saved!')); } }); } @@ -80,7 +80,7 @@ class Controller extends Section { } Controller.$inject = ['$element', '$scope']; -ngModule.component('vnClientAddressIndex', { +ngModule.vnComponent('vnClientAddressIndex', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/client/front/address/index/index.spec.js b/modules/client/front/address/index/index.spec.js index 4240e8629..c7b4985c8 100644 --- a/modules/client/front/address/index/index.spec.js +++ b/modules/client/front/address/index/index.spec.js @@ -10,7 +10,7 @@ describe('Client', () => { beforeEach(ngModule('client')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$stateParams_, _$httpBackend_) => { + beforeEach(inject(($componentController, $rootScope, _$stateParams_, _$httpBackend_) => { $stateParams = _$stateParams_; $stateParams.id = 1; $httpBackend = _$httpBackend_; @@ -28,8 +28,7 @@ describe('Client', () => { let data = {defaultAddressFk: address.id}; let expectedResult = {defaultAddressFk: address.id}; - $httpBackend.when('PATCH', `Clients/1`, data).respond(200, expectedResult); - $httpBackend.expect('PATCH', `Clients/1`, data); + $httpBackend.expect('PATCH', `Clients/1`, data).respond(200, expectedResult); controller.setDefault(address); $httpBackend.flush(); diff --git a/modules/client/front/balance/index/index.js b/modules/client/front/balance/index/index.js index 582456d85..8f5261176 100644 --- a/modules/client/front/balance/index/index.js +++ b/modules/client/front/balance/index/index.js @@ -83,7 +83,7 @@ class Controller extends Section { Controller.$inject = ['$element', '$scope']; -ngModule.component('vnClientBalanceIndex', { +ngModule.vnComponent('vnClientBalanceIndex', { template: require('./index.html'), controller: Controller, }); diff --git a/modules/client/front/balance/index/index.spec.js b/modules/client/front/balance/index/index.spec.js index 6a7a6e321..496407847 100644 --- a/modules/client/front/balance/index/index.spec.js +++ b/modules/client/front/balance/index/index.spec.js @@ -6,7 +6,7 @@ describe('Client', () => { beforeEach(ngModule('client')); - beforeEach(angular.mock.inject(($componentController, $rootScope) => { + beforeEach(inject(($componentController, $rootScope) => { let $scope = $rootScope.$new(); const $element = angular.element(''); controller = $componentController('vnClientBalanceIndex', {$element, $scope}); diff --git a/modules/client/front/basic-data/index.js b/modules/client/front/basic-data/index.js index 5d491ec75..3dc7dbc2d 100644 --- a/modules/client/front/basic-data/index.js +++ b/modules/client/front/basic-data/index.js @@ -1,7 +1,7 @@ import ngModule from '../module'; import Section from 'salix/components/section'; -ngModule.component('vnClientBasicData', { +ngModule.vnComponent('vnClientBasicData', { template: require('./index.html'), controller: Section, bindings: { diff --git a/modules/client/front/billing-data/index.js b/modules/client/front/billing-data/index.js index 589c4f528..2dda347b9 100644 --- a/modules/client/front/billing-data/index.js +++ b/modules/client/front/billing-data/index.js @@ -77,7 +77,7 @@ export default class Controller extends Section { } } -ngModule.component('vnClientBillingData', { +ngModule.vnComponent('vnClientBillingData', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/client/front/billing-data/index.spec.js b/modules/client/front/billing-data/index.spec.js index 1b295abeb..dd44bd0fa 100644 --- a/modules/client/front/billing-data/index.spec.js +++ b/modules/client/front/billing-data/index.spec.js @@ -9,7 +9,7 @@ describe('Client', () => { beforeEach(ngModule('client')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _vnApp_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _vnApp_) => { let $element = angular.element(''); $httpBackend = _$httpBackend_; vnApp = _vnApp_; diff --git a/modules/client/front/card/index.js b/modules/client/front/card/index.js index 5aacc83ea..76a4711d1 100644 --- a/modules/client/front/card/index.js +++ b/modules/client/front/card/index.js @@ -8,7 +8,7 @@ export default class Controller extends ModuleCard { } } -ngModule.component('vnClientCard', { +ngModule.vnComponent('vnClientCard', { template: require('./index.html'), controller: Controller }); diff --git a/modules/client/front/card/index.spec.js b/modules/client/front/card/index.spec.js index 72272fe89..979497253 100644 --- a/modules/client/front/card/index.spec.js +++ b/modules/client/front/card/index.spec.js @@ -8,7 +8,7 @@ describe('Client', () => { beforeEach(ngModule('client')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $stateParams) => { + beforeEach(inject(($componentController, _$httpBackend_, $stateParams) => { $httpBackend = _$httpBackend_; let $element = angular.element('
'); diff --git a/modules/client/front/consumption-search-panel/index.js b/modules/client/front/consumption-search-panel/index.js index 9b9354a93..685c0c1f5 100644 --- a/modules/client/front/consumption-search-panel/index.js +++ b/modules/client/front/consumption-search-panel/index.js @@ -1,7 +1,7 @@ import ngModule from '../module'; import SearchPanel from 'core/components/searchbar/search-panel'; -ngModule.component('vnConsumptionSearchPanel', { +ngModule.vnComponent('vnConsumptionSearchPanel', { template: require('./index.html'), controller: SearchPanel }); diff --git a/modules/client/front/consumption/index.html b/modules/client/front/consumption/index.html index 8ea65ecae..4bc4c34c3 100644 --- a/modules/client/front/consumption/index.html +++ b/modules/client/front/consumption/index.html @@ -2,6 +2,7 @@ url="Clients/consumption" link="{clientFk: $ctrl.$params.id}" filter="::$ctrl.filter" + limit="20" user-params="::$ctrl.filterParams" data="sales" order="itemTypeFk, itemName, itemSize"> diff --git a/modules/client/front/consumption/index.js b/modules/client/front/consumption/index.js index 4b075abb9..e36e94682 100644 --- a/modules/client/front/consumption/index.js +++ b/modules/client/front/consumption/index.js @@ -57,7 +57,7 @@ class Controller extends Section { Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail']; -ngModule.component('vnClientConsumption', { +ngModule.vnComponent('vnClientConsumption', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/client/front/consumption/index.spec.js b/modules/client/front/consumption/index.spec.js index d76bc1e76..9fe92fee1 100644 --- a/modules/client/front/consumption/index.spec.js +++ b/modules/client/front/consumption/index.spec.js @@ -10,7 +10,7 @@ describe('Client', () => { beforeEach(ngModule('client')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpParamSerializer_, _$httpBackend_) => { + beforeEach(inject(($componentController, $rootScope, _$httpParamSerializer_, _$httpBackend_) => { $scope = $rootScope.$new(); $httpParamSerializer = _$httpParamSerializer_; $httpBackend = _$httpBackend_; diff --git a/modules/client/front/contact/index.js b/modules/client/front/contact/index.js index 4f29ddb8c..d79c7645a 100644 --- a/modules/client/front/contact/index.js +++ b/modules/client/front/contact/index.js @@ -5,7 +5,7 @@ class Controller extends Section { add() { this.$.model.insert({ clientFk: this.client.id, - name: this.$translate.instant('Phone'), + name: this.$t('Phone'), phone: null }); } @@ -19,7 +19,7 @@ class Controller extends Section { } } -ngModule.component('vnClientContact', { +ngModule.vnComponent('vnClientContact', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/client/front/create/index.js b/modules/client/front/create/index.js index 4f7ce4104..d8ded6560 100644 --- a/modules/client/front/create/index.js +++ b/modules/client/front/create/index.js @@ -86,7 +86,7 @@ export default class Controller extends Section { Controller.$inject = ['$element', '$scope']; -ngModule.component('vnClientCreate', { +ngModule.vnComponent('vnClientCreate', { template: require('./index.html'), controller: Controller }); diff --git a/modules/client/front/create/index.spec.js b/modules/client/front/create/index.spec.js index c6c31c084..24fc80d21 100644 --- a/modules/client/front/create/index.spec.js +++ b/modules/client/front/create/index.spec.js @@ -8,7 +8,7 @@ describe('Client', () => { beforeEach(ngModule('client')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$state_) => { + beforeEach(inject(($componentController, $rootScope, _$state_) => { $scope = $rootScope.$new(); $state = _$state_; $scope.watcher = { diff --git a/modules/client/front/credit-insurance/create/index.js b/modules/client/front/credit-insurance/create/index.js index 5ea2a8039..83dc18806 100644 --- a/modules/client/front/credit-insurance/create/index.js +++ b/modules/client/front/credit-insurance/create/index.js @@ -11,7 +11,7 @@ class Controller extends Section { onSubmit() { if (this.$.form.$invalid) - return this.vnApp.showError(this.$translate.instant('Some fields are invalid')); + return this.vnApp.showError(this.$t('Some fields are invalid')); let query = `creditClassifications/createWithInsurance`; let data = this.creditClassification; @@ -28,7 +28,7 @@ class Controller extends Section { Controller.$inject = ['$element', '$scope']; -ngModule.component('vnClientCreditInsuranceCreate', { +ngModule.vnComponent('vnClientCreditInsuranceCreate', { template: require('./index.html'), controller: Controller, require: { diff --git a/modules/client/front/credit-insurance/create/index.spec.js b/modules/client/front/credit-insurance/create/index.spec.js index 29bd2c11e..83cec62f8 100644 --- a/modules/client/front/credit-insurance/create/index.spec.js +++ b/modules/client/front/credit-insurance/create/index.spec.js @@ -8,7 +8,7 @@ describe('Client', () => { beforeEach(ngModule('client')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); $scope.form = { diff --git a/modules/client/front/credit-insurance/index/index.html b/modules/client/front/credit-insurance/index/index.html index d2bf1fef6..b3ebb070d 100644 --- a/modules/client/front/credit-insurance/index/index.html +++ b/modules/client/front/credit-insurance/index/index.html @@ -60,7 +60,7 @@ \ No newline at end of file diff --git a/modules/client/front/credit-insurance/index/index.js b/modules/client/front/credit-insurance/index/index.js index e386444f4..5f59c918a 100644 --- a/modules/client/front/credit-insurance/index/index.js +++ b/modules/client/front/credit-insurance/index/index.js @@ -51,17 +51,15 @@ class Controller extends Section { this.$.closeContract.show(); } - returnDialog(response) { - if (response === 'accept') { - let params = {finished: Date.now()}; - this.$http.patch(`CreditClassifications/${this.classificationId}`, params).then(() => { - this._getClassifications(this.client.id); - }); - } + returnDialog() { + let params = {finished: Date.now()}; + this.$http.patch(`CreditClassifications/${this.classificationId}`, params).then(() => { + this._getClassifications(this.client.id); + }); } } -ngModule.component('vnClientCreditInsuranceIndex', { +ngModule.vnComponent('vnClientCreditInsuranceIndex', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/client/front/credit-insurance/index/index.spec.js b/modules/client/front/credit-insurance/index/index.spec.js index bed58a7d6..678301f28 100644 --- a/modules/client/front/credit-insurance/index/index.spec.js +++ b/modules/client/front/credit-insurance/index/index.spec.js @@ -8,7 +8,7 @@ describe('Client', () => { beforeEach(ngModule('client')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope) => { + beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); const $element = angular.element(''); @@ -77,9 +77,8 @@ describe('Client', () => { it('should call the returnDialog method and perform a PATCH query, then call _getClassifications method', () => { jest.spyOn(controller, '_getClassifications').mockReturnThis(); controller.classificationId = 1; - $httpBackend.when('PATCH', `CreditClassifications/1`).respond(200); - $httpBackend.expect('PATCH', `CreditClassifications/1`); - controller.returnDialog('accept'); + $httpBackend.expect('PATCH', `CreditClassifications/1`).respond(200); + controller.returnDialog(); $httpBackend.flush(); expect(controller._getClassifications).toHaveBeenCalledWith(101); diff --git a/modules/client/front/credit-insurance/insurance/create/index.js b/modules/client/front/credit-insurance/insurance/create/index.js index 2363cac76..94de53352 100644 --- a/modules/client/front/credit-insurance/insurance/create/index.js +++ b/modules/client/front/credit-insurance/insurance/create/index.js @@ -21,7 +21,7 @@ class Controller extends Section { Controller.$inject = ['$element', '$scope']; -ngModule.component('vnClientCreditInsuranceInsuranceCreate', { +ngModule.vnComponent('vnClientCreditInsuranceInsuranceCreate', { template: require('./index.html'), controller: Controller, require: { diff --git a/modules/client/front/credit-insurance/insurance/index/index.js b/modules/client/front/credit-insurance/insurance/index/index.js index f78d06785..193a0b088 100644 --- a/modules/client/front/credit-insurance/insurance/index/index.js +++ b/modules/client/front/credit-insurance/insurance/index/index.js @@ -29,7 +29,7 @@ class Controller extends Section { Controller.$inject = ['$element', '$scope']; -ngModule.component('vnClientCreditInsuranceInsuranceIndex', { +ngModule.vnComponent('vnClientCreditInsuranceInsuranceIndex', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/client/front/credit-insurance/insurance/index/index.spec.js b/modules/client/front/credit-insurance/insurance/index/index.spec.js index 490d6a924..34e557fa4 100644 --- a/modules/client/front/credit-insurance/insurance/index/index.spec.js +++ b/modules/client/front/credit-insurance/insurance/index/index.spec.js @@ -8,7 +8,7 @@ describe('Client', () => { beforeEach(ngModule('client')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope) => { + beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { $scope = $rootScope.$new(); $httpBackend = _$httpBackend_; const $element = angular.element(''); diff --git a/modules/client/front/credit/create/index.html b/modules/client/front/credit/create/index.html index c77c1556c..e3160a2ae 100644 --- a/modules/client/front/credit/create/index.html +++ b/modules/client/front/credit/create/index.html @@ -25,7 +25,7 @@ diff --git a/modules/client/front/credit/create/index.js b/modules/client/front/credit/create/index.js index 049c206b3..3c1d376ed 100644 --- a/modules/client/front/credit/create/index.js +++ b/modules/client/front/credit/create/index.js @@ -16,9 +16,8 @@ class Controller extends Section { this.goToIndex(); } - returnDialog(response) { - if (response === 'accept') - this.addCredit(); + returnDialog() { + this.addCredit(); } goToIndex() { @@ -34,7 +33,7 @@ class Controller extends Section { } } -ngModule.component('vnClientCreditCreate', { +ngModule.vnComponent('vnClientCreditCreate', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/client/front/credit/create/index.spec.js b/modules/client/front/credit/create/index.spec.js index a69fb64a9..2fda0af65 100644 --- a/modules/client/front/credit/create/index.spec.js +++ b/modules/client/front/credit/create/index.spec.js @@ -10,7 +10,7 @@ describe('Client', () => { beforeEach(ngModule('client')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope, _$state_) => { + beforeEach(inject(($componentController, _$httpBackend_, $rootScope, _$state_) => { $scope = $rootScope.$new(); $scope.confirmation = {show: () => { return { @@ -75,7 +75,7 @@ describe('Client', () => { describe('returnDialog()', () => { it('should call addCredit() when is called with accept', () => { jest.spyOn(controller, 'addCredit'); - controller.returnDialog('accept'); + controller.returnDialog(); expect(controller.addCredit).toHaveBeenCalledWith(); }); diff --git a/modules/client/front/credit/index/index.js b/modules/client/front/credit/index/index.js index bea30b2d1..151aa35d6 100644 --- a/modules/client/front/credit/index/index.js +++ b/modules/client/front/credit/index/index.js @@ -25,7 +25,7 @@ class Controller extends Section { Controller.$inject = ['$element', '$scope']; -ngModule.component('vnClientCreditIndex', { +ngModule.vnComponent('vnClientCreditIndex', { template: require('./index.html'), controller: Controller }); diff --git a/modules/client/front/dms/create/index.js b/modules/client/front/dms/create/index.js index 0422ab6a6..3c3f20100 100644 --- a/modules/client/front/dms/create/index.js +++ b/modules/client/front/dms/create/index.js @@ -33,7 +33,7 @@ class Controller extends Section { } get contentTypesInfo() { - return this.$translate.instant('ContentTypesInfo', { + return this.$t('ContentTypesInfo', { allowedContentTypes: this.allowedContentTypes }); } @@ -51,7 +51,7 @@ class Controller extends Section { warehouseId: warehouseId, companyId: companyId, dmsTypeId: dmsType.id, - description: this.$translate.instant('ClientFileDescription', { + description: this.$t('ClientFileDescription', { dmsTypeName: dmsType.name, clientId: this.client.id, clientName: this.client.name @@ -83,7 +83,7 @@ class Controller extends Section { }; this.$http(options).then(res => { if (res) { - this.vnApp.showSuccess(this.$translate.instant('Data saved!')); + this.vnApp.showSuccess(this.$t('Data saved!')); this.$.watcher.updateOriginalData(); this.$state.go('client.card.dms.index'); } @@ -104,7 +104,7 @@ class Controller extends Section { Controller.$inject = ['$element', '$scope']; -ngModule.component('vnClientDmsCreate', { +ngModule.vnComponent('vnClientDmsCreate', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/client/front/dms/create/index.spec.js b/modules/client/front/dms/create/index.spec.js index 0f0e2cb09..0ed3f6671 100644 --- a/modules/client/front/dms/create/index.spec.js +++ b/modules/client/front/dms/create/index.spec.js @@ -9,7 +9,7 @@ describe('Client', () => { beforeEach(ngModule('client')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { $scope = $rootScope.$new(); $httpBackend = _$httpBackend_; $httpParamSerializer = _$httpParamSerializer_; @@ -39,8 +39,7 @@ describe('Client', () => { where: {code: 'paymentsLaw'} }}; let serializedParams = $httpParamSerializer(params); - $httpBackend.when('GET', `DmsTypes/findOne?${serializedParams}`).respond({id: 12, code: 'paymentsLaw'}); - $httpBackend.expect('GET', `DmsTypes/findOne?${serializedParams}`); + $httpBackend.expect('GET', `DmsTypes/findOne?${serializedParams}`).respond({id: 12, code: 'paymentsLaw'}); controller.setDefaultParams(); $httpBackend.flush(); @@ -63,8 +62,7 @@ describe('Client', () => { describe('getAllowedContentTypes()', () => { it('should make an HTTP GET request to get the allowed content types', () => { const expectedResponse = ['image/png', 'image/jpg']; - $httpBackend.when('GET', `clientDms/allowedContentTypes`).respond(expectedResponse); - $httpBackend.expect('GET', `clientDms/allowedContentTypes`); + $httpBackend.expect('GET', `clientDms/allowedContentTypes`).respond(expectedResponse); controller.getAllowedContentTypes(); $httpBackend.flush(); diff --git a/modules/client/front/dms/edit/index.js b/modules/client/front/dms/edit/index.js index dedd67e3f..2b8a7046d 100644 --- a/modules/client/front/dms/edit/index.js +++ b/modules/client/front/dms/edit/index.js @@ -24,7 +24,7 @@ class Controller extends Section { } get contentTypesInfo() { - return this.$translate.instant('ContentTypesInfo', { + return this.$t('ContentTypesInfo', { allowedContentTypes: this.allowedContentTypes }); } @@ -67,7 +67,7 @@ class Controller extends Section { }; this.$http(options).then(res => { if (res) { - this.vnApp.showSuccess(this.$translate.instant('Data saved!')); + this.vnApp.showSuccess(this.$t('Data saved!')); this.$.watcher.updateOriginalData(); this.$state.go('client.card.dms.index'); } @@ -85,7 +85,7 @@ class Controller extends Section { } } -ngModule.component('vnClientDmsEdit', { +ngModule.vnComponent('vnClientDmsEdit', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/client/front/dms/edit/index.spec.js b/modules/client/front/dms/edit/index.spec.js index f4aaf52f8..e52ab7f7b 100644 --- a/modules/client/front/dms/edit/index.spec.js +++ b/modules/client/front/dms/edit/index.spec.js @@ -8,7 +8,7 @@ describe('Client', () => { beforeEach(ngModule('client')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { $scope = $rootScope.$new(); $httpBackend = _$httpBackend_; const $element = angular.element(''); @@ -45,7 +45,6 @@ describe('Client', () => { hasFileAttached: false }; - $httpBackend.when('GET', `Dms/${dmsId}`).respond(expectedResponse); $httpBackend.expect('GET', `Dms/${dmsId}`).respond(expectedResponse); controller.setDefaultParams(); $httpBackend.flush(); @@ -70,8 +69,7 @@ describe('Client', () => { describe('getAllowedContentTypes()', () => { it('should make an HTTP GET request to get the allowed content types', () => { const expectedResponse = ['image/png', 'image/jpg']; - $httpBackend.when('GET', `clientDms/allowedContentTypes`).respond(expectedResponse); - $httpBackend.expect('GET', `clientDms/allowedContentTypes`); + $httpBackend.expect('GET', `clientDms/allowedContentTypes`).respond(expectedResponse); controller.getAllowedContentTypes(); $httpBackend.flush(); diff --git a/modules/client/front/dms/index/index.js b/modules/client/front/dms/index/index.js index c80b65c9f..c65de39e4 100644 --- a/modules/client/front/dms/index/index.js +++ b/modules/client/front/dms/index/index.js @@ -58,7 +58,7 @@ class Controller extends Section { Controller.$inject = ['$element', '$scope', 'vnFile']; -ngModule.component('vnClientDmsIndex', { +ngModule.vnComponent('vnClientDmsIndex', { template: require('./index.html'), controller: Controller, }); diff --git a/modules/client/front/dms/index/index.spec.js b/modules/client/front/dms/index/index.spec.js index e94cca806..71c8d74a9 100644 --- a/modules/client/front/dms/index/index.spec.js +++ b/modules/client/front/dms/index/index.spec.js @@ -9,7 +9,7 @@ describe('Client', () => { beforeEach(ngModule('client')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); controller = $componentController('vnClientDmsIndex', {$element: null, $scope}); diff --git a/modules/client/front/fiscal-data/index.js b/modules/client/front/fiscal-data/index.js index 92e27e54f..30c7d7656 100644 --- a/modules/client/front/fiscal-data/index.js +++ b/modules/client/front/fiscal-data/index.js @@ -65,7 +65,7 @@ export default class Controller extends Section { onAcceptEt() { const query = `Clients/${this.client.id}/addressesPropagateRe`; return this.$http.patch(query, {isEqualizated: this.client.isEqualizated}).then( - () => this.vnApp.showMessage(this.$translate.instant('Equivalent tax spreaded')) + () => this.vnApp.showMessage(this.$t('Equivalent tax spreaded')) ); } @@ -162,7 +162,7 @@ export default class Controller extends Section { } } -ngModule.component('vnClientFiscalData', { +ngModule.vnComponent('vnClientFiscalData', { template: require('./index.html'), controller: Controller, require: {card: '^vnClientCard'}, diff --git a/modules/client/front/fiscal-data/index.spec.js b/modules/client/front/fiscal-data/index.spec.js index 29608303c..e028d01f3 100644 --- a/modules/client/front/fiscal-data/index.spec.js +++ b/modules/client/front/fiscal-data/index.spec.js @@ -10,7 +10,7 @@ describe('Client', () => { beforeEach(ngModule('client')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); $scope.watcher = watcher; @@ -126,8 +126,7 @@ describe('Client', () => { describe('onAcceptEt()', () => { it('should request to patch the propagation of tax status', () => { controller.client = {id: 123, isEqualizated: false}; - $httpBackend.when('PATCH', `Clients/${controller.client.id}/addressesPropagateRe`, {isEqualizated: controller.client.isEqualizated}).respond('done'); - $httpBackend.expectPATCH(`Clients/${controller.client.id}/addressesPropagateRe`, {isEqualizated: controller.client.isEqualizated}); + $httpBackend.expectPATCH(`Clients/${controller.client.id}/addressesPropagateRe`, {isEqualizated: controller.client.isEqualizated}).respond('done'); controller.onAcceptEt(); $httpBackend.flush(); }); diff --git a/modules/client/front/greuge/create/index.js b/modules/client/front/greuge/create/index.js index 3154d15f0..baf9f6a49 100644 --- a/modules/client/front/greuge/create/index.js +++ b/modules/client/front/greuge/create/index.js @@ -28,7 +28,7 @@ class Controller extends Section { } Controller.$inject = ['$element', '$scope']; -ngModule.component('vnClientGreugeCreate', { +ngModule.vnComponent('vnClientGreugeCreate', { template: require('./index.html'), controller: Controller }); diff --git a/modules/client/front/greuge/create/index.spec.js b/modules/client/front/greuge/create/index.spec.js index cb52ae2a7..2d900d258 100644 --- a/modules/client/front/greuge/create/index.spec.js +++ b/modules/client/front/greuge/create/index.spec.js @@ -8,7 +8,7 @@ describe('Client', () => { beforeEach(ngModule('client')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$state_) => { + beforeEach(inject(($componentController, $rootScope, _$state_) => { $scope = $rootScope.$new(); $state = _$state_; $scope.watcher = { diff --git a/modules/client/front/greuge/index/index.js b/modules/client/front/greuge/index/index.js index bacb93544..2451167a4 100644 --- a/modules/client/front/greuge/index/index.js +++ b/modules/client/front/greuge/index/index.js @@ -20,7 +20,7 @@ class Controller extends Section { Controller.$inject = ['$element', '$scope']; -ngModule.component('vnClientGreugeIndex', { +ngModule.vnComponent('vnClientGreugeIndex', { template: require('./index.html'), controller: Controller }); diff --git a/modules/client/front/index/index.html b/modules/client/front/index/index.html index 6a64954aa..7493ecace 100644 --- a/modules/client/front/index/index.html +++ b/modules/client/front/index/index.html @@ -65,5 +65,4 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/modules/client/front/index/index.js b/modules/client/front/index/index.js index f5400e05a..07d4a8803 100644 --- a/modules/client/front/index/index.js +++ b/modules/client/front/index/index.js @@ -21,7 +21,7 @@ export default class Controller extends Section { } } -ngModule.component('vnClientIndex', { +ngModule.vnComponent('vnClientIndex', { template: require('./index.html'), controller: Controller }); diff --git a/modules/client/front/index/index.spec.js b/modules/client/front/index/index.spec.js index 110db5e6a..4fc2c4f8c 100644 --- a/modules/client/front/index/index.spec.js +++ b/modules/client/front/index/index.spec.js @@ -7,7 +7,7 @@ describe('Client index', () => { beforeEach(ngModule('client')); - beforeEach(angular.mock.inject(($componentController, _$state_, $rootScope) => { + beforeEach(inject(($componentController, _$state_, $rootScope) => { $state = _$state_; $scope = $rootScope.$new(); const $element = angular.element(''); diff --git a/modules/client/front/log/index.js b/modules/client/front/log/index.js index e4cac6e58..f4aa99bfd 100644 --- a/modules/client/front/log/index.js +++ b/modules/client/front/log/index.js @@ -1,7 +1,7 @@ import ngModule from '../module'; import Section from 'salix/components/section'; -ngModule.component('vnClientLog', { +ngModule.vnComponent('vnClientLog', { template: require('./index.html'), controller: Section, }); diff --git a/modules/client/front/mandate/index.js b/modules/client/front/mandate/index.js index 640678e42..114e2b570 100644 --- a/modules/client/front/mandate/index.js +++ b/modules/client/front/mandate/index.js @@ -24,7 +24,7 @@ class Controller extends Section { Controller.$inject = ['$element', '$scope']; -ngModule.component('vnClientMandate', { +ngModule.vnComponent('vnClientMandate', { template: require('./index.html'), controller: Controller }); diff --git a/modules/client/front/note/create/index.js b/modules/client/front/note/create/index.js index 108aba407..c540c3a0b 100644 --- a/modules/client/front/note/create/index.js +++ b/modules/client/front/note/create/index.js @@ -15,7 +15,7 @@ export default class Controller extends Section { } } -ngModule.component('vnNoteCreate', { +ngModule.vnComponent('vnNoteCreate', { template: require('./index.html'), controller: Controller }); diff --git a/modules/client/front/note/create/index.spec.js b/modules/client/front/note/create/index.spec.js index 0dc515b1e..117aa0720 100644 --- a/modules/client/front/note/create/index.spec.js +++ b/modules/client/front/note/create/index.spec.js @@ -7,7 +7,7 @@ describe('Client', () => { beforeEach(ngModule('client')); - beforeEach(angular.mock.inject(($componentController, _$state_) => { + beforeEach(inject(($componentController, _$state_) => { $state = _$state_; $state.params.id = '1234'; const $element = angular.element(''); diff --git a/modules/client/front/note/index/index.js b/modules/client/front/note/index/index.js index 654c460e4..ed15db671 100644 --- a/modules/client/front/note/index/index.js +++ b/modules/client/front/note/index/index.js @@ -13,7 +13,7 @@ export default class Controller extends Section { Controller.$inject = ['$element', '$scope']; -ngModule.component('vnClientNote', { +ngModule.vnComponent('vnClientNote', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/client/front/postcode/index.js b/modules/client/front/postcode/index.js index c05ea0518..aca7a44d3 100644 --- a/modules/client/front/postcode/index.js +++ b/modules/client/front/postcode/index.js @@ -35,18 +35,18 @@ class Controller extends Component { throw new Error(`The town can't be empty`); this.$http.patch(`postcodes`, this.data).then(res => { - this.vnApp.showMessage(this.$translate.instant('The postcode has been saved')); + this.vnApp.showMessage(this.$t('The postcode has been saved')); this.emit('response', {$response: res.data}); }); } catch (e) { - this.vnApp.showError(this.$translate.instant(e.message)); + this.vnApp.showError(this.$t(e.message)); return false; } return true; } } -ngModule.component('vnClientPostcode', { +ngModule.vnComponent('vnClientPostcode', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/client/front/postcode/index.spec.js b/modules/client/front/postcode/index.spec.js index 2cefb6985..8778fd9b0 100644 --- a/modules/client/front/postcode/index.spec.js +++ b/modules/client/front/postcode/index.spec.js @@ -8,7 +8,7 @@ describe('Client', () => { beforeEach(ngModule('client')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope) => { + beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); const $element = angular.element(''); @@ -22,8 +22,7 @@ describe('Client', () => { controller.data = {townFk: 1, provinceFk: 1, countryFk: 1, code: '46460'}; jest.spyOn(controller.vnApp, 'showMessage'); - $httpBackend.when('PATCH', `postcodes`, params).respond(200, params); - $httpBackend.expect('PATCH', `postcodes`, params).respond(params); + $httpBackend.expect('PATCH', `postcodes`, params).respond(200, params); controller.onAccept(); $httpBackend.flush(); diff --git a/modules/client/front/recovery/create/index.js b/modules/client/front/recovery/create/index.js index aa378203b..4fd05eaa0 100644 --- a/modules/client/front/recovery/create/index.js +++ b/modules/client/front/recovery/create/index.js @@ -28,7 +28,7 @@ class Controller extends Section { } Controller.$inject = ['$element', '$scope']; -ngModule.component('vnClientRecoveryCreate', { +ngModule.vnComponent('vnClientRecoveryCreate', { template: require('./index.html'), controller: Controller }); diff --git a/modules/client/front/recovery/create/index.spec.js b/modules/client/front/recovery/create/index.spec.js index d2635ee8d..ec9054140 100644 --- a/modules/client/front/recovery/create/index.spec.js +++ b/modules/client/front/recovery/create/index.spec.js @@ -8,7 +8,7 @@ describe('Client', () => { beforeEach(ngModule('client')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$state_) => { + beforeEach(inject(($componentController, $rootScope, _$state_) => { $scope = $rootScope.$new(); $state = _$state_; $scope.watcher = { diff --git a/modules/client/front/recovery/index/index.js b/modules/client/front/recovery/index/index.js index f82430982..d53ded805 100644 --- a/modules/client/front/recovery/index/index.js +++ b/modules/client/front/recovery/index/index.js @@ -12,7 +12,7 @@ class Controller extends Section { } } -ngModule.component('vnClientRecoveryIndex', { +ngModule.vnComponent('vnClientRecoveryIndex', { template: require('./index.html'), controller: Controller }); diff --git a/modules/client/front/sample/create/index.js b/modules/client/front/sample/create/index.js index d1dfd3ff5..bc2cee39d 100644 --- a/modules/client/front/sample/create/index.js +++ b/modules/client/front/sample/create/index.js @@ -53,7 +53,7 @@ class Controller extends Section { sendSample() { this.send(false, () => { - this.vnApp.showSuccess(this.$translate.instant('Notification sent!')); + this.vnApp.showSuccess(this.$t('Notification sent!')); this.$state.go('client.card.sample.index'); }); } @@ -66,13 +66,13 @@ class Controller extends Section { }; if (!params.recipient) - return this.vnApp.showError(this.$translate.instant('Email cannot be blank')); + return this.vnApp.showError(this.$t('Email cannot be blank')); if (!sampleType) - return this.vnApp.showError(this.$translate.instant('Choose a sample')); + return this.vnApp.showError(this.$t('Choose a sample')); if (sampleType.hasCompany && !this.clientSample.companyFk) - return this.vnApp.showError(this.$translate.instant('Choose a company')); + return this.vnApp.showError(this.$t('Choose a company')); if (sampleType.hasCompany) params.companyId = this.clientSample.companyFk; @@ -85,7 +85,7 @@ class Controller extends Section { } Controller.$inject = ['$element', '$scope']; -ngModule.component('vnClientSampleCreate', { +ngModule.vnComponent('vnClientSampleCreate', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/client/front/sample/create/index.spec.js b/modules/client/front/sample/create/index.spec.js index af7f2f3ff..40fa237b6 100644 --- a/modules/client/front/sample/create/index.spec.js +++ b/modules/client/front/sample/create/index.spec.js @@ -11,7 +11,7 @@ describe('Client', () => { beforeEach(ngModule('client')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope, _$state_, _$httpParamSerializer_) => { + beforeEach(inject(($componentController, _$httpBackend_, $rootScope, _$state_, _$httpParamSerializer_) => { $scope = $rootScope.$new(); $scope.sampleType = {}; $scope.watcher = { diff --git a/modules/client/front/sample/index/index.js b/modules/client/front/sample/index/index.js index c5e8a72cd..e93c2d2dc 100644 --- a/modules/client/front/sample/index/index.js +++ b/modules/client/front/sample/index/index.js @@ -33,7 +33,7 @@ class Controller extends Section { } } -ngModule.component('vnClientSampleIndex', { +ngModule.vnComponent('vnClientSampleIndex', { template: require('./index.html'), controller: Controller }); diff --git a/modules/client/front/search-panel/index.js b/modules/client/front/search-panel/index.js index 8c30982f5..bdbbcdaef 100644 --- a/modules/client/front/search-panel/index.js +++ b/modules/client/front/search-panel/index.js @@ -1,7 +1,7 @@ import ngModule from '../module'; import SearchPanel from 'core/components/searchbar/search-panel'; -ngModule.component('vnClientSearchPanel', { +ngModule.vnComponent('vnClientSearchPanel', { template: require('./index.html'), controller: SearchPanel }); diff --git a/modules/client/front/sms/index.html b/modules/client/front/sms/index.html index fb2f1dfff..6915942c2 100644 --- a/modules/client/front/sms/index.html +++ b/modules/client/front/sms/index.html @@ -1,6 +1,6 @@ + on-accept="$ctrl.onResponse()">
Send SMS
diff --git a/modules/client/front/sms/index.js b/modules/client/front/sms/index.js index 3dfdda8a3..701ee39af 100644 --- a/modules/client/front/sms/index.js +++ b/modules/client/front/sms/index.js @@ -16,25 +16,23 @@ class Controller extends Section { return maxLength - textAreaLength; } - onResponse(response) { - if (response === 'accept') { - try { - if (!this.sms.destination) - throw new Error(`The destination can't be empty`); - if (!this.sms.message) - throw new Error(`The message can't be empty`); - if (this.charactersRemaining() < 0) - throw new Error(`The message it's too long`); + onResponse() { + try { + if (!this.sms.destination) + throw new Error(`The destination can't be empty`); + if (!this.sms.message) + throw new Error(`The message can't be empty`); + if (this.charactersRemaining() < 0) + throw new Error(`The message it's too long`); - this.$http.post(`Clients/${this.$params.id}/sendSms`, this.sms).then(res => { - this.vnApp.showMessage(this.$translate.instant('SMS sent!')); + this.$http.post(`Clients/${this.$params.id}/sendSms`, this.sms).then(res => { + this.vnApp.showMessage(this.$t('SMS sent!')); - if (res.data) this.emit('send', {response: res.data}); - }); - } catch (e) { - this.vnApp.showError(this.$translate.instant(e.message)); - return false; - } + if (res.data) this.emit('send', {response: res.data}); + }); + } catch (e) { + this.vnApp.showError(this.$t(e.message)); + return false; } return true; } @@ -42,7 +40,7 @@ class Controller extends Section { Controller.$inject = ['$element', '$scope', '$http', '$translate', 'vnApp']; -ngModule.component('vnClientSms', { +ngModule.vnComponent('vnClientSms', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/client/front/sms/index.spec.js b/modules/client/front/sms/index.spec.js index a7b4cd3df..3462bf681 100644 --- a/modules/client/front/sms/index.spec.js +++ b/modules/client/front/sms/index.spec.js @@ -8,7 +8,7 @@ describe('Client', () => { beforeEach(ngModule('client')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { $httpBackend = _$httpBackend_; let $scope = $rootScope.$new(); $element = angular.element(''); @@ -30,7 +30,7 @@ describe('Client', () => { jest.spyOn(controller.vnApp, 'showMessage'); $httpBackend.expect('POST', `Clients/101/sendSms`, params).respond(200, params); - controller.onResponse('accept'); + controller.onResponse(); $httpBackend.flush(); expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent!'); diff --git a/modules/client/front/summary/index.js b/modules/client/front/summary/index.js index 4dd299903..5737e2df4 100644 --- a/modules/client/front/summary/index.js +++ b/modules/client/front/summary/index.js @@ -38,7 +38,7 @@ class Controller extends Section { } } -ngModule.component('vnClientSummary', { +ngModule.vnComponent('vnClientSummary', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/client/front/summary/index.spec.js b/modules/client/front/summary/index.spec.js index 1c747d25a..05491267c 100644 --- a/modules/client/front/summary/index.spec.js +++ b/modules/client/front/summary/index.spec.js @@ -8,7 +8,7 @@ describe('Client', () => { beforeEach(ngModule('client')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope) => { + beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); const $element = angular.element(''); @@ -21,8 +21,7 @@ describe('Client', () => { let res = {name: 'Superman', classifications: []}; jest.spyOn(controller, 'sumRisk').mockReturnThis(); - $httpBackend.when('GET', `Clients/101/summary`).respond(200, res); - $httpBackend.expect('GET', `Clients/101/summary`); + $httpBackend.expect('GET', `Clients/101/summary`).respond(200, res); controller.$onChanges(); $httpBackend.flush(); diff --git a/modules/client/front/web-access/index.html b/modules/client/front/web-access/index.html index 590e823d3..f7488dbdf 100644 --- a/modules/client/front/web-access/index.html +++ b/modules/client/front/web-access/index.html @@ -34,7 +34,7 @@ + on-accept="$ctrl.onPassChange()"> { - this.vnApp.showSuccess(this.$translate.instant('Data saved!')); - }); - } catch (e) { - this.vnApp.showError(this.$translate.instant(e.message)); + this.$http.patch(`Accounts/${this.client.id}`, account).then(res => { + this.vnApp.showSuccess(this.$t('Data saved!')); + }); + } catch (e) { + this.vnApp.showError(this.$t(e.message)); - return false; - } + return false; } return true; @@ -64,7 +62,7 @@ export default class Controller extends Section { } Controller.$inject = ['$element', '$scope']; -ngModule.component('vnClientWebAccess', { +ngModule.vnComponent('vnClientWebAccess', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/client/front/web-access/index.spec.js b/modules/client/front/web-access/index.spec.js index 0ed3345d1..73c4f1043 100644 --- a/modules/client/front/web-access/index.spec.js +++ b/modules/client/front/web-access/index.spec.js @@ -8,7 +8,7 @@ describe('Component VnClientWebAccess', () => { beforeEach(ngModule('client')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _vnApp_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _vnApp_) => { $scope = $rootScope.$new(); $httpBackend = _$httpBackend_; vnApp = _vnApp_; @@ -57,8 +57,7 @@ describe('Component VnClientWebAccess', () => { expect(controller.canEnableCheckBox).toBeTruthy(); - $httpBackend.when('GET', `Clients/${controller.client.id}/isValidClient`).respond(false); - $httpBackend.expectGET(`Clients/${controller.client.id}/isValidClient`); + $httpBackend.expectGET(`Clients/${controller.client.id}/isValidClient`).respond(false); controller.checkConditions(); $httpBackend.flush(); @@ -83,9 +82,8 @@ describe('Component VnClientWebAccess', () => { controller.newPassword = 'm24x8'; controller.repeatPassword = 'm24x8'; controller.canChangePassword = true; - $httpBackend.when('PATCH', 'Accounts/1234').respond('done'); - $httpBackend.expectPATCH('Accounts/1234', {password: 'm24x8'}); - controller.onPassChange('accept'); + $httpBackend.expectPATCH('Accounts/1234', {password: 'm24x8'}).respond('done'); + controller.onPassChange(); $httpBackend.flush(); }); @@ -94,7 +92,7 @@ describe('Component VnClientWebAccess', () => { controller.client = {id: '1234'}; controller.newPassword = ''; controller.canChangePassword = true; - controller.onPassChange('accept'); + controller.onPassChange(); expect(vnApp.showError).toHaveBeenCalledWith(`You must enter a new password`); }); @@ -106,7 +104,7 @@ describe('Component VnClientWebAccess', () => { controller.newPassword = 'm24x8'; controller.canChangePassword = true; controller.repeatPassword = 'notMatchingPassword'; - controller.onPassChange('accept'); + controller.onPassChange(); expect(vnApp.showError).toHaveBeenCalledWith(`Passwords don't match`); }); diff --git a/modules/client/front/web-payment/index.js b/modules/client/front/web-payment/index.js index c68abf49e..00d0adc4d 100644 --- a/modules/client/front/web-payment/index.js +++ b/modules/client/front/web-payment/index.js @@ -21,7 +21,7 @@ class Controller extends Section { } } -ngModule.component('vnClientWebPayment', { +ngModule.vnComponent('vnClientWebPayment', { template: require('./index.html'), controller: Controller }); diff --git a/modules/client/front/web-payment/index.spec.js b/modules/client/front/web-payment/index.spec.js index ee07f2fff..ee7d6c717 100644 --- a/modules/client/front/web-payment/index.spec.js +++ b/modules/client/front/web-payment/index.spec.js @@ -9,7 +9,7 @@ describe('Component vnClientWebPayment', () => { beforeEach(ngModule('client')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _vnApp_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _vnApp_) => { $scope = $rootScope.$new(); $scope.model = crudModel; $httpBackend = _$httpBackend_; @@ -25,8 +25,7 @@ describe('Component vnClientWebPayment', () => { let query = 'Clients/confirmTransaction'; controller.confirm(transaction); - $httpBackend.when('POST', query, transaction).respond('ok'); - $httpBackend.expect('POST', query, transaction); + $httpBackend.expect('POST', query, transaction).respond('ok'); $httpBackend.flush(); }); }); diff --git a/modules/entry/front/buy/index.js b/modules/entry/front/buy/index.js index 674243eb1..00a8421fb 100644 --- a/modules/entry/front/buy/index.js +++ b/modules/entry/front/buy/index.js @@ -1,7 +1,7 @@ import ngModule from '../module'; import Section from 'salix/components/section'; -ngModule.component('vnEntryBuy', { +ngModule.vnComponent('vnEntryBuy', { template: require('./index.html'), controller: Section, bindings: { diff --git a/modules/entry/front/card/index.js b/modules/entry/front/card/index.js index 83f47c83d..f9ab6187c 100644 --- a/modules/entry/front/card/index.js +++ b/modules/entry/front/card/index.js @@ -50,7 +50,7 @@ class Controller extends ModuleCard { } } -ngModule.component('vnEntryCard', { +ngModule.vnComponent('vnEntryCard', { template: require('./index.html'), controller: Controller }); diff --git a/modules/entry/front/descriptor/index.html b/modules/entry/front/descriptor/index.html index f0d4491ac..1470eccf4 100644 --- a/modules/entry/front/descriptor/index.html +++ b/modules/entry/front/descriptor/index.html @@ -10,9 +10,6 @@
- - diff --git a/modules/entry/front/index/index.js b/modules/entry/front/index/index.js index 60d70afcb..759ce2724 100644 --- a/modules/entry/front/index/index.js +++ b/modules/entry/front/index/index.js @@ -3,7 +3,7 @@ import Section from 'salix/components/section'; export default class Controller extends Section {} -ngModule.component('vnEntryIndex', { +ngModule.vnComponent('vnEntryIndex', { template: require('./index.html'), controller: Controller }); diff --git a/modules/entry/front/log/index.js b/modules/entry/front/log/index.js index d045f2035..73218f4de 100644 --- a/modules/entry/front/log/index.js +++ b/modules/entry/front/log/index.js @@ -1,7 +1,7 @@ import ngModule from '../module'; import Section from 'salix/components/section'; -ngModule.component('vnEntryLog', { +ngModule.vnComponent('vnEntryLog', { template: require('./index.html'), controller: Section, }); diff --git a/modules/entry/front/search-panel/index.js b/modules/entry/front/search-panel/index.js index d728fe5e8..e87f31056 100644 --- a/modules/entry/front/search-panel/index.js +++ b/modules/entry/front/search-panel/index.js @@ -1,7 +1,7 @@ import ngModule from '../module'; import SearchPanel from 'core/components/searchbar/search-panel'; -ngModule.component('vnEntrySearchPanel', { +ngModule.vnComponent('vnEntrySearchPanel', { template: require('./index.html'), controller: SearchPanel }); diff --git a/modules/entry/front/summary/index.js b/modules/entry/front/summary/index.js index 94eaf1791..f0b4c62b3 100644 --- a/modules/entry/front/summary/index.js +++ b/modules/entry/front/summary/index.js @@ -21,7 +21,7 @@ class Controller extends Section { } } -ngModule.component('vnEntrySummary', { +ngModule.vnComponent('vnEntrySummary', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/entry/front/summary/index.spec.js b/modules/entry/front/summary/index.spec.js index a59bb8009..a2d25d0d6 100644 --- a/modules/entry/front/summary/index.spec.js +++ b/modules/entry/front/summary/index.spec.js @@ -9,7 +9,7 @@ describe('component vnEntrySummary', () => { $translateProvider.translations('en', {}); })); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); const $element = angular.element(``); diff --git a/modules/invoiceOut/front/card/index.js b/modules/invoiceOut/front/card/index.js index 0ad91f4c2..f718f22ae 100644 --- a/modules/invoiceOut/front/card/index.js +++ b/modules/invoiceOut/front/card/index.js @@ -32,7 +32,7 @@ class Controller extends ModuleCard { } } -ngModule.component('vnInvoiceOutCard', { +ngModule.vnComponent('vnInvoiceOutCard', { template: require('./index.html'), controller: Controller }); diff --git a/modules/invoiceOut/front/index/index.js b/modules/invoiceOut/front/index/index.js index 17eb44fec..c884fb90b 100644 --- a/modules/invoiceOut/front/index/index.js +++ b/modules/invoiceOut/front/index/index.js @@ -13,7 +13,7 @@ export default class Controller extends Section { } } -ngModule.component('vnInvoiceOutIndex', { +ngModule.vnComponent('vnInvoiceOutIndex', { template: require('./index.html'), controller: Controller }); diff --git a/modules/invoiceOut/front/search-panel/index.js b/modules/invoiceOut/front/search-panel/index.js index 1ca545ec7..a77d479ca 100644 --- a/modules/invoiceOut/front/search-panel/index.js +++ b/modules/invoiceOut/front/search-panel/index.js @@ -1,7 +1,7 @@ import ngModule from '../module'; import SearchPanel from 'core/components/searchbar/search-panel'; -ngModule.component('vnInvoiceSearchPanel', { +ngModule.vnComponent('vnInvoiceSearchPanel', { template: require('./index.html'), controller: SearchPanel }); diff --git a/modules/invoiceOut/front/summary/index.js b/modules/invoiceOut/front/summary/index.js index ef76768de..dd4237850 100644 --- a/modules/invoiceOut/front/summary/index.js +++ b/modules/invoiceOut/front/summary/index.js @@ -19,7 +19,7 @@ class Controller extends Section { } } -ngModule.component('vnInvoiceOutSummary', { +ngModule.vnComponent('vnInvoiceOutSummary', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/invoiceOut/front/summary/index.spec.js b/modules/invoiceOut/front/summary/index.spec.js index ac6c40bcf..fadf0ad89 100644 --- a/modules/invoiceOut/front/summary/index.spec.js +++ b/modules/invoiceOut/front/summary/index.spec.js @@ -8,7 +8,7 @@ describe('InvoiceOut', () => { beforeEach(ngModule('invoiceOut')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope) => { + beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); const $element = angular.element(''); @@ -19,7 +19,6 @@ describe('InvoiceOut', () => { describe('getSummary()', () => { it('should perform a query to set summary', () => { $httpBackend.when('GET', `InvoiceOuts/1/summary`).respond(200, 'the data you are looking for'); - $httpBackend.expect('GET', `InvoiceOuts/1/summary`); controller.getSummary(); $httpBackend.flush(); diff --git a/modules/item/back/methods/item-image-queue/downloadImages.js b/modules/item/back/methods/item-image-queue/downloadImages.js new file mode 100644 index 000000000..372648dd6 --- /dev/null +++ b/modules/item/back/methods/item-image-queue/downloadImages.js @@ -0,0 +1,56 @@ +const https = require('https'); +const fs = require('fs-extra'); +const path = require('path'); + +module.exports = Self => { + Self.remoteMethod('downloadImages', { + description: 'Returns last entries', + accessType: 'WRITE', + returns: { + type: ['Object'], + root: true + }, + http: { + path: `/downloadImages`, + verb: 'POST' + } + }); + + Self.downloadImages = async() => { + const models = Self.app.models; + + try { + const imageQueue = await Self.find({limit: 25}); + const rootPath = models.Image.getPath(); + const tempPath = path.join(rootPath, 'temp'); + + // Create temporary path + await fs.mkdir(tempPath, {recursive: true}); + + for (let image of imageQueue) { + const fileName = `${image.itemFk}.png`; + const filePath = path.join(tempPath, fileName); + const file = fs.createWriteStream(filePath); + + https.get(image.url, async response => { + response.pipe(file); + }); + + file.on('finish', async function() { + await models.Image.registerImage('catalog', fileName, filePath); + await image.destroy(); + }); + + file.on('error', err => { + fs.unlink(filePath); + + throw err; + }); + } + + return imageQueue; + } catch (e) { + throw e; + } + }; +}; diff --git a/modules/item/back/model-config.json b/modules/item/back/model-config.json index c085e075a..c5623dcca 100644 --- a/modules/item/back/model-config.json +++ b/modules/item/back/model-config.json @@ -50,6 +50,9 @@ "ItemShelvingSale": { "dataSource": "vn" }, + "ItemImageQueue": { + "dataSource": "vn" + }, "Origin": { "dataSource": "vn" }, diff --git a/modules/item/back/models/item-image-queue.js b/modules/item/back/models/item-image-queue.js new file mode 100644 index 000000000..e2059ddac --- /dev/null +++ b/modules/item/back/models/item-image-queue.js @@ -0,0 +1,3 @@ +module.exports = Self => { + require('../methods/item-image-queue/downloadImages')(Self); +}; diff --git a/modules/item/back/models/item-image-queue.json b/modules/item/back/models/item-image-queue.json new file mode 100644 index 000000000..61cb7b018 --- /dev/null +++ b/modules/item/back/models/item-image-queue.json @@ -0,0 +1,36 @@ +{ + "name": "ItemImageQueue", + "description": "Image download queue", + "base": "VnModel", + "options": { + "mysql": { + "table": "itemImageQueue" + } + }, + "properties": { + "itemFk": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "url": { + "type": "String", + "required": true + } + }, + "relations": { + "item": { + "type": "belongsTo", + "model": "Item", + "foreignKey": "itemFk" + } + }, + "acls": [ + { + "accessType": "*", + "principalType": "ROLE", + "principalId": "employee", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/modules/item/front/barcode/index.js b/modules/item/front/barcode/index.js index d9e17a42a..4ceb87b9d 100644 --- a/modules/item/front/barcode/index.js +++ b/modules/item/front/barcode/index.js @@ -11,7 +11,7 @@ export default class Controller extends Section { } } -ngModule.component('vnItemBarcode', { +ngModule.vnComponent('vnItemBarcode', { template: require('./index.html'), controller: Controller }); diff --git a/modules/item/front/basic-data/index.js b/modules/item/front/basic-data/index.js index fb80c5178..1a256c65b 100644 --- a/modules/item/front/basic-data/index.js +++ b/modules/item/front/basic-data/index.js @@ -19,7 +19,7 @@ class Controller extends Section { } } -ngModule.component('vnItemBasicData', { +ngModule.vnComponent('vnItemBasicData', { template: require('./index.html'), bindings: { item: '<' diff --git a/modules/item/front/basic-data/index.spec.js b/modules/item/front/basic-data/index.spec.js index fd7be5d93..274453d30 100644 --- a/modules/item/front/basic-data/index.spec.js +++ b/modules/item/front/basic-data/index.spec.js @@ -8,7 +8,7 @@ describe('vnItemBasicData', () => { beforeEach(ngModule('item')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); const $element = angular.element(''); diff --git a/modules/item/front/botanical/index.js b/modules/item/front/botanical/index.js index 03c62a0e3..61eed3ce8 100644 --- a/modules/item/front/botanical/index.js +++ b/modules/item/front/botanical/index.js @@ -26,7 +26,7 @@ class Controller extends Section { } } -ngModule.component('vnItemBotanical', { +ngModule.vnComponent('vnItemBotanical', { template: require('./index.html'), controller: Controller }); diff --git a/modules/item/front/botanical/index.spec.js b/modules/item/front/botanical/index.spec.js index 1cf79bbb3..24e48e4ae 100644 --- a/modules/item/front/botanical/index.spec.js +++ b/modules/item/front/botanical/index.spec.js @@ -8,7 +8,7 @@ describe('ItemBotanical', () => { beforeEach(ngModule('item')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope) => { + beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); const $element = angular.element(''); diff --git a/modules/item/front/card/index.js b/modules/item/front/card/index.js index 12167500f..8b32e030b 100644 --- a/modules/item/front/card/index.js +++ b/modules/item/front/card/index.js @@ -8,7 +8,7 @@ class Controller extends ModuleCard { } } -ngModule.component('vnItemCard', { +ngModule.vnComponent('vnItemCard', { template: require('./index.html'), controller: Controller }); diff --git a/modules/item/front/card/index.spec.js b/modules/item/front/card/index.spec.js index c0ea80e69..2c97f5935 100644 --- a/modules/item/front/card/index.spec.js +++ b/modules/item/front/card/index.spec.js @@ -8,7 +8,7 @@ describe('Item', () => { beforeEach(ngModule('item')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $stateParams) => { + beforeEach(inject(($componentController, _$httpBackend_, $stateParams) => { $httpBackend = _$httpBackend_; let $element = angular.element('
'); diff --git a/modules/item/front/create/index.js b/modules/item/front/create/index.js index ab51b0734..d207e6f5b 100644 --- a/modules/item/front/create/index.js +++ b/modules/item/front/create/index.js @@ -18,7 +18,7 @@ class Controller extends Section { Controller.$inject = ['$element', '$scope']; -ngModule.component('vnItemCreate', { +ngModule.vnComponent('vnItemCreate', { template: require('./index.html'), controller: Controller }); diff --git a/modules/item/front/create/index.spec.js b/modules/item/front/create/index.spec.js index 518d5f78b..9e54988d7 100644 --- a/modules/item/front/create/index.spec.js +++ b/modules/item/front/create/index.spec.js @@ -8,7 +8,7 @@ describe('Item', () => { beforeEach(ngModule('item')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$state_) => { + beforeEach(inject(($componentController, $rootScope, _$state_) => { $scope = $rootScope.$new(); $state = _$state_; $scope.watcher = { diff --git a/modules/item/front/diary/index.js b/modules/item/front/diary/index.js index e1a15096a..953d203e8 100644 --- a/modules/item/front/diary/index.js +++ b/modules/item/front/diary/index.js @@ -67,7 +67,7 @@ class Controller extends Section { Controller.$inject = ['$element', '$scope', '$anchorScroll', '$location']; -ngModule.component('vnItemDiary', { +ngModule.vnComponent('vnItemDiary', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/item/front/diary/index.spec.js b/modules/item/front/diary/index.spec.js index b6e50e5c5..52608cde3 100644 --- a/modules/item/front/diary/index.spec.js +++ b/modules/item/front/diary/index.spec.js @@ -8,7 +8,7 @@ describe('Item', () => { beforeEach(ngModule('item')); - beforeEach(angular.mock.inject(($componentController, $rootScope) => { + beforeEach(inject(($componentController, $rootScope) => { $scope = $rootScope.$new(); const $element = angular.element(''); controller = $componentController('vnItemDiary', {$element, $scope}); diff --git a/modules/item/front/fetched-tags/index.js b/modules/item/front/fetched-tags/index.js index 9140abcf4..da18b7a7c 100644 --- a/modules/item/front/fetched-tags/index.js +++ b/modules/item/front/fetched-tags/index.js @@ -2,7 +2,7 @@ import ngModule from '../module'; import Component from 'core/lib/component'; import './style.scss'; -ngModule.component('vnFetchedTags', { +ngModule.vnComponent('vnFetchedTags', { template: require('./index.html'), controller: Component, bindings: { diff --git a/modules/item/front/index/index.js b/modules/item/front/index/index.js index e852d7985..cafa3e475 100644 --- a/modules/item/front/index/index.js +++ b/modules/item/front/index/index.js @@ -24,7 +24,7 @@ class Controller extends Section { } } -ngModule.component('vnItemIndex', { +ngModule.vnComponent('vnItemIndex', { template: require('./index.html'), controller: Controller }); diff --git a/modules/item/front/index/index.spec.js b/modules/item/front/index/index.spec.js index f8cf07fe3..18abde581 100644 --- a/modules/item/front/index/index.spec.js +++ b/modules/item/front/index/index.spec.js @@ -8,7 +8,7 @@ describe('Item', () => { beforeEach(ngModule('item')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope) => { + beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); const $element = angular.element(''); diff --git a/modules/item/front/last-entries/index.js b/modules/item/front/last-entries/index.js index 752f1b035..3f9d7be36 100644 --- a/modules/item/front/last-entries/index.js +++ b/modules/item/front/last-entries/index.js @@ -35,7 +35,7 @@ class Controller extends Section { Controller.$inject = ['$element', '$scope']; -ngModule.component('vnItemLastEntries', { +ngModule.vnComponent('vnItemLastEntries', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/item/front/log/index.js b/modules/item/front/log/index.js index 4433b2460..953d48df3 100644 --- a/modules/item/front/log/index.js +++ b/modules/item/front/log/index.js @@ -1,7 +1,7 @@ import ngModule from '../module'; import Section from 'salix/components/section'; -ngModule.component('vnItemLog', { +ngModule.vnComponent('vnItemLog', { template: require('./index.html'), controller: Section, }); diff --git a/modules/item/front/niche/index.js b/modules/item/front/niche/index.js index f4e7cd0be..51621b714 100644 --- a/modules/item/front/niche/index.js +++ b/modules/item/front/niche/index.js @@ -11,7 +11,7 @@ export default class Controller extends Section { } } -ngModule.component('vnItemNiche', { +ngModule.vnComponent('vnItemNiche', { template: require('./index.html'), controller: Controller }); diff --git a/modules/item/front/request-search-panel/index.js b/modules/item/front/request-search-panel/index.js index 07fcefd6b..82639b6e2 100644 --- a/modules/item/front/request-search-panel/index.js +++ b/modules/item/front/request-search-panel/index.js @@ -1,7 +1,7 @@ import ngModule from '../module'; import SearchPanel from 'core/components/searchbar/search-panel'; -ngModule.component('vnRequestSearchPanel', { +ngModule.vnComponent('vnRequestSearchPanel', { template: require('./index.html'), controller: SearchPanel }); diff --git a/modules/item/front/request/index.js b/modules/item/front/request/index.js index a5f030e78..3801c926f 100644 --- a/modules/item/front/request/index.js +++ b/modules/item/front/request/index.js @@ -94,7 +94,7 @@ export default class Controller extends Section { } } -ngModule.component('vnItemRequest', { +ngModule.vnComponent('vnItemRequest', { template: require('./index.html'), controller: Controller }); diff --git a/modules/item/front/request/index.spec.js b/modules/item/front/request/index.spec.js index 8e384b04e..a33a21ec2 100644 --- a/modules/item/front/request/index.spec.js +++ b/modules/item/front/request/index.spec.js @@ -8,7 +8,7 @@ describe('Item', () => { beforeEach(ngModule('item')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); controller = $componentController('vnItemRequest', {$element: null, $scope}); diff --git a/modules/item/front/search-panel/index.js b/modules/item/front/search-panel/index.js index 6b3e7786d..f1a3367c4 100644 --- a/modules/item/front/search-panel/index.js +++ b/modules/item/front/search-panel/index.js @@ -73,7 +73,7 @@ class Controller extends SearchPanel { } } -ngModule.component('vnItemSearchPanel', { +ngModule.vnComponent('vnItemSearchPanel', { template: require('./index.html'), controller: Controller }); diff --git a/modules/item/front/search-panel/index.spec.js b/modules/item/front/search-panel/index.spec.js index cc0cf0375..0e2b7f848 100644 --- a/modules/item/front/search-panel/index.spec.js +++ b/modules/item/front/search-panel/index.spec.js @@ -7,7 +7,7 @@ describe('Item', () => { beforeEach(ngModule('item')); - beforeEach(angular.mock.inject($componentController => { + beforeEach(inject($componentController => { $element = angular.element(`
`); controller = $componentController('vnItemSearchPanel', {$element}); })); diff --git a/modules/item/front/summary/index.js b/modules/item/front/summary/index.js index d38f1f29a..5e441ecf1 100644 --- a/modules/item/front/summary/index.js +++ b/modules/item/front/summary/index.js @@ -15,7 +15,7 @@ class Controller extends Section { } } -ngModule.component('vnItemSummary', { +ngModule.vnComponent('vnItemSummary', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/item/front/summary/index.spec.js b/modules/item/front/summary/index.spec.js index 069c24512..0b349194c 100644 --- a/modules/item/front/summary/index.spec.js +++ b/modules/item/front/summary/index.spec.js @@ -8,7 +8,7 @@ describe('Item', () => { beforeEach(ngModule('item')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope) => { + beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); const $element = angular.element(''); @@ -19,8 +19,7 @@ describe('Item', () => { describe('getSummary()', () => { it('should perform a query to set summary', () => { let data = {id: 1, name: 'Gem of mind'}; - $httpBackend.when('GET', `Items/1/getSummary`).respond(200, data); - $httpBackend.expect('GET', `Items/1/getSummary`); + $httpBackend.expect('GET', `Items/1/getSummary`).respond(200, data); controller.getSummary(); $httpBackend.flush(); diff --git a/modules/item/front/tags/index.html b/modules/item/front/tags/index.html index 888efd8d0..d35345451 100644 --- a/modules/item/front/tags/index.html +++ b/modules/item/front/tags/index.html @@ -22,7 +22,7 @@
- - diff --git a/modules/item/front/tags/index.js b/modules/item/front/tags/index.js index 8737aeed4..0a3ff0f2d 100644 --- a/modules/item/front/tags/index.js +++ b/modules/item/front/tags/index.js @@ -72,7 +72,7 @@ class Controller extends Section { } } -ngModule.component('vnItemTags', { +ngModule.vnComponent('vnItemTags', { template: require('./index.html'), controller: Controller, require: { diff --git a/modules/item/front/tags/index.spec.js b/modules/item/front/tags/index.spec.js index 10128e4f0..fabdc162b 100644 --- a/modules/item/front/tags/index.spec.js +++ b/modules/item/front/tags/index.spec.js @@ -8,7 +8,7 @@ describe('Item', () => { beforeEach(ngModule('item')); - beforeEach(angular.mock.inject(($componentController, $rootScope) => { + beforeEach(inject(($componentController, $rootScope) => { $scope = $rootScope.$new(); $scope.model = crudModel; $scope.model.data = [{priority: 1}, {priority: 2}, {priority: 1}]; diff --git a/modules/item/front/tax/index.js b/modules/item/front/tax/index.js index 251e0802d..b72fbefa3 100644 --- a/modules/item/front/tax/index.js +++ b/modules/item/front/tax/index.js @@ -35,7 +35,7 @@ export default class Controller extends Section { } } -ngModule.component('vnItemTax', { +ngModule.vnComponent('vnItemTax', { template: require('./index.html'), controller: Controller }); diff --git a/modules/item/front/tax/index.spec.js b/modules/item/front/tax/index.spec.js index 95e46cfbf..0aec866b2 100644 --- a/modules/item/front/tax/index.spec.js +++ b/modules/item/front/tax/index.spec.js @@ -9,7 +9,7 @@ describe('Item', () => { beforeEach(ngModule('item')); - beforeEach(angular.mock.inject((_$httpBackend_, $rootScope, _$stateParams_, $compile) => { + beforeEach(inject((_$httpBackend_, $rootScope, _$stateParams_, $compile) => { $stateParams = _$stateParams_; $stateParams.id = 1; $httpBackend = _$httpBackend_; diff --git a/modules/item/front/waste/index.js b/modules/item/front/waste/index.js index d1a10fbf4..3c5d1a6be 100644 --- a/modules/item/front/waste/index.js +++ b/modules/item/front/waste/index.js @@ -2,7 +2,7 @@ import ngModule from '../module'; import Section from 'salix/components/section'; import './style.scss'; -ngModule.component('vnItemWaste', { +ngModule.vnComponent('vnItemWaste', { template: require('./index.html'), controller: Section }); diff --git a/modules/order/back/methods/order/filter.js b/modules/order/back/methods/order/filter.js index cdd54859f..bfa64c4dd 100644 --- a/modules/order/back/methods/order/filter.js +++ b/modules/order/back/methods/order/filter.js @@ -133,7 +133,6 @@ module.exports = Self => { }); filter = mergeFilters(filter, {where}); - let stmts = []; let stmt; @@ -157,14 +156,20 @@ module.exports = Self => { c.salesPersonFk, u.nickname workerNickname, u.name name, - co.code companyCode + co.code companyCode, + zed.zoneFk, + zed.hourTheoretical, + zed.hourEffective FROM hedera.order o LEFT JOIN address a ON a.id = o.address_id LEFT JOIN agencyMode am ON am.id = o.agency_id LEFT JOIN client c ON c.id = o.customer_id LEFT JOIN worker wk ON wk.id = c.salesPersonFk LEFT JOIN account.user u ON u.id = wk.userFk - LEFT JOIN company co ON co.id = o.company_id`); + LEFT JOIN company co ON co.id = o.company_id + LEFT JOIN orderTicket ot ON ot.orderFk = o.id + LEFT JOIN ticket t ON t.id = ot.ticketFk + LEFT JOIN zoneEstimatedDelivery zed ON zed.zoneFk = t.zoneFk`); if (args && args.ticketFk) { stmt.merge({ @@ -172,7 +177,11 @@ module.exports = Self => { }); } - stmt.merge(conn.makeSuffix(filter)); + stmt.merge(conn.makeWhere(filter.where)); + stmt.merge({ + sql: `GROUP BY o.id` + }); + stmt.merge(conn.makePagination(filter)); stmts.push(stmt); stmts.push(` diff --git a/modules/order/front/basic-data/index.js b/modules/order/front/basic-data/index.js index d1f1fc225..3719eb42f 100644 --- a/modules/order/front/basic-data/index.js +++ b/modules/order/front/basic-data/index.js @@ -22,7 +22,7 @@ class Controller extends Section { } } -ngModule.component('vnOrderBasicData', { +ngModule.vnComponent('vnOrderBasicData', { controller: Controller, template: require('./index.html'), bindings: { diff --git a/modules/order/front/basic-data/index.spec.js b/modules/order/front/basic-data/index.spec.js index 0150bd3b3..4442fadcc 100644 --- a/modules/order/front/basic-data/index.spec.js +++ b/modules/order/front/basic-data/index.spec.js @@ -8,7 +8,7 @@ describe('Order', () => { beforeEach(ngModule('order')); - beforeEach(angular.mock.inject(($compile, _$httpBackend_, $rootScope) => { + beforeEach(inject(($compile, _$httpBackend_, $rootScope) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); diff --git a/modules/order/front/card/index.js b/modules/order/front/card/index.js index 80fa99d1d..d154b0b52 100644 --- a/modules/order/front/card/index.js +++ b/modules/order/front/card/index.js @@ -58,7 +58,7 @@ class Controller extends ModuleCard { } } -ngModule.component('vnOrderCard', { +ngModule.vnComponent('vnOrderCard', { template: require('./index.html'), controller: Controller }); diff --git a/modules/order/front/card/index.spec.js b/modules/order/front/card/index.spec.js index 19d070920..f0de26b72 100644 --- a/modules/order/front/card/index.spec.js +++ b/modules/order/front/card/index.spec.js @@ -9,7 +9,7 @@ describe('Order', () => { beforeEach(ngModule('order')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $stateParams) => { + beforeEach(inject(($componentController, _$httpBackend_, $stateParams) => { $httpBackend = _$httpBackend_; let $element = angular.element('
'); diff --git a/modules/order/front/catalog-search-panel/index.js b/modules/order/front/catalog-search-panel/index.js index 7d5f1bfd1..99f3e1c12 100644 --- a/modules/order/front/catalog-search-panel/index.js +++ b/modules/order/front/catalog-search-panel/index.js @@ -1,7 +1,7 @@ import ngModule from '../module'; import SearchPanel from 'core/components/searchbar/search-panel'; -ngModule.component('vnOrderCatalogSearchPanel', { +ngModule.vnComponent('vnOrderCatalogSearchPanel', { template: require('./index.html'), controller: SearchPanel, bindings: { diff --git a/modules/order/front/catalog-view/index.js b/modules/order/front/catalog-view/index.js index 37a2b70a2..1e99ab82b 100644 --- a/modules/order/front/catalog-view/index.js +++ b/modules/order/front/catalog-view/index.js @@ -4,7 +4,7 @@ import './style.scss'; class Controller extends Component {} -ngModule.component('vnOrderCatalogView', { +ngModule.vnComponent('vnOrderCatalogView', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/order/front/catalog/index.js b/modules/order/front/catalog/index.js index 7d73a4dea..ddfe69cc9 100644 --- a/modules/order/front/catalog/index.js +++ b/modules/order/front/catalog/index.js @@ -344,7 +344,7 @@ class Controller extends Section { } } -ngModule.component('vnOrderCatalog', { +ngModule.vnComponent('vnOrderCatalog', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/order/front/catalog/index.spec.js b/modules/order/front/catalog/index.spec.js index f7635665a..eceb3eb66 100644 --- a/modules/order/front/catalog/index.spec.js +++ b/modules/order/front/catalog/index.spec.js @@ -10,7 +10,7 @@ describe('Order', () => { beforeEach(ngModule('order')); - beforeEach(angular.mock.inject(($componentController, _$state_, _$httpBackend_, $rootScope) => { + beforeEach(inject(($componentController, _$state_, _$httpBackend_, $rootScope) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); $scope.model = crudModel; diff --git a/modules/order/front/create/card.js b/modules/order/front/create/card.js index 158ad9a10..315cc8255 100644 --- a/modules/order/front/create/card.js +++ b/modules/order/front/create/card.js @@ -99,13 +99,13 @@ class Controller extends Component { agencyModeId: this.order.agencyModeFk }; this.$http.post(`Orders/new`, params).then(res => { - this.vnApp.showSuccess(this.$translate.instant('Data saved!')); + this.vnApp.showSuccess(this.$t('Data saved!')); this.$state.go('order.card.catalog', {id: res.data}); }); } } -ngModule.component('vnOrderCreateCard', { +ngModule.vnComponent('vnOrderCreateCard', { template: require('./card.html'), controller: Controller, bindings: { diff --git a/modules/order/front/create/card.spec.js b/modules/order/front/create/card.spec.js index f8f0653a7..99e8c1f8a 100644 --- a/modules/order/front/create/card.spec.js +++ b/modules/order/front/create/card.spec.js @@ -8,7 +8,7 @@ describe('Order', () => { beforeEach(ngModule('order')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, _vnApp_, $rootScope) => { + beforeEach(inject(($componentController, _$httpBackend_, _vnApp_, $rootScope) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); const $element = angular.element(''); @@ -91,12 +91,11 @@ describe('Order', () => { jest.spyOn(controller.vnApp, 'showSuccess'); jest.spyOn(controller.$state, 'go'); - $httpBackend.when('POST', 'Orders/new', {landed: 101, addressId: 101, agencyModeId: 101}).respond(200, 1); - $httpBackend.expect('POST', 'Orders/new', {landed: 101, addressId: 101, agencyModeId: 101}); + $httpBackend.expect('POST', 'Orders/new', {landed: 101, addressId: 101, agencyModeId: 101}).respond(200, 1); controller.createOrder(); $httpBackend.flush(); - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); + expect(controller.vnApp.showSuccess).toHaveBeenCalled(); expect(controller.$state.go).toHaveBeenCalledWith('order.card.catalog', {id: 1}); }); }); diff --git a/modules/order/front/create/index.js b/modules/order/front/create/index.js index 5c02e8225..317c4e27e 100644 --- a/modules/order/front/create/index.js +++ b/modules/order/front/create/index.js @@ -8,7 +8,7 @@ class Controller extends Section { } } -ngModule.component('vnOrderCreate', { +ngModule.vnComponent('vnOrderCreate', { template: require('./index.html'), controller: Controller }); diff --git a/modules/order/front/create/index.spec.js b/modules/order/front/create/index.spec.js index 82834a987..af8c8f974 100644 --- a/modules/order/front/create/index.spec.js +++ b/modules/order/front/create/index.spec.js @@ -7,7 +7,7 @@ describe('Order', () => { beforeEach(ngModule('order')); - beforeEach(angular.mock.inject(($componentController, $rootScope) => { + beforeEach(inject(($componentController, $rootScope) => { $scope = $rootScope.$new(); $scope.card = {createOrder: () => {}}; const $element = angular.element(''); diff --git a/modules/order/front/index/index.html b/modules/order/front/index/index.html index a28979646..8e64b4b0c 100644 --- a/modules/order/front/index/index.html +++ b/modules/order/front/index/index.html @@ -10,11 +10,13 @@ Id - Client Sales person + Client Confirmed Created Landed + T. Hour + Real hour Total @@ -24,13 +26,6 @@ class="clickable search-result" ui-sref="order.card.summary({id: {{::order.id}}})"> {{::order.id}} - - - {{::order.clientName}} - - - + + + {{::order.clientName}} + + + {{::order.created | date: 'dd/MM/yyyy HH:mm'}} - {{::order.landed | date:'dd/MM/yyyy'}} + + + {{::order.landed | date:'dd/MM/yyyy'}} + + + {{::order.hourTheoretical | date: 'HH:mm'}} + {{::ticket.hourEffective | date: 'HH:mm'}} {{::order.total | currency: 'EUR': 2 | dashIfEmpty}} { + let controller; + let $window; + let orders = [{ + id: 1, + clientFk: 1, + isConfirmed: false + }, { + id: 2, + clientFk: 1, + isConfirmed: false + }, { + id: 3, + clientFk: 1, + isConfirmed: true + }]; + + beforeEach(ngModule('order')); + + beforeEach(inject(($componentController, _$window_,) => { + $window = _$window_; + const $element = angular.element(''); + controller = $componentController('vnOrderIndex', {$element}); + })); + + describe('compareDate()', () => { + it('should return warning when the date is the present', () => { + let curDate = new Date(); + let result = controller.compareDate(curDate); + + expect(result).toEqual('warning'); + }); + + it('should return sucess when the date is in the future', () => { + let futureDate = new Date(); + futureDate = futureDate.setDate(futureDate.getDate() + 10); + let result = controller.compareDate(futureDate); + + expect(result).toEqual('success'); + }); + + it('should return undefined when the date is in the past', () => { + let pastDate = new Date(); + pastDate = pastDate.setDate(pastDate.getDate() - 10); + let result = controller.compareDate(pastDate); + + expect(result).toEqual(undefined); + }); + }); + + describe('preview()', () => { + it('should show the dialog summary', () => { + controller.$.summary = {show: () => {}}; + jest.spyOn(controller.$.summary, 'show'); + + let event = new MouseEvent('click', { + view: $window, + bubbles: true, + cancelable: true + }); + controller.preview(event, orders[0]); + + expect(controller.$.summary.show).toHaveBeenCalledWith(); + }); + }); +}); diff --git a/modules/order/front/line/index.js b/modules/order/front/line/index.js index bd41acedc..94d1fbfbf 100644 --- a/modules/order/front/line/index.js +++ b/modules/order/front/line/index.js @@ -58,7 +58,7 @@ class Controller extends Section { } } -ngModule.component('vnOrderLine', { +ngModule.vnComponent('vnOrderLine', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/order/front/line/index.spec.js b/modules/order/front/line/index.spec.js index 458bbbdd8..ad0e1edbc 100644 --- a/modules/order/front/line/index.spec.js +++ b/modules/order/front/line/index.spec.js @@ -19,7 +19,7 @@ describe('Order', () => { beforeEach(ngModule('order')); - beforeEach(angular.mock.inject(($componentController, _$state_, _$httpBackend_) => { + beforeEach(inject(($componentController, _$state_, _$httpBackend_) => { $state = _$state_; $httpBackend = _$httpBackend_; diff --git a/modules/order/front/locale/es.yml b/modules/order/front/locale/es.yml index 154f92098..fbc384f21 100644 --- a/modules/order/front/locale/es.yml +++ b/modules/order/front/locale/es.yml @@ -21,4 +21,6 @@ Ascendant: Ascendente Descendant: Descendente Created from: Creado desde Search order by id: Buscar el pedido por identificador -order: pedido \ No newline at end of file +order: pedido +Confirm lines: Confirmar las lineas +Confirm: Confirmar \ No newline at end of file diff --git a/modules/order/front/search-panel/index.js b/modules/order/front/search-panel/index.js index 1ab4c15cf..07be9ca24 100644 --- a/modules/order/front/search-panel/index.js +++ b/modules/order/front/search-panel/index.js @@ -1,7 +1,7 @@ import ngModule from '../module'; import SearchPanel from 'core/components/searchbar/search-panel'; -ngModule.component('vnOrderSearchPanel', { +ngModule.vnComponent('vnOrderSearchPanel', { template: require('./index.html'), controller: SearchPanel }); diff --git a/modules/order/front/summary/index.html b/modules/order/front/summary/index.html index 2f7399dec..f27e2e510 100644 --- a/modules/order/front/summary/index.html +++ b/modules/order/front/summary/index.html @@ -1,5 +1,14 @@ -
{{$ctrl.summary.id}} - {{$ctrl.summary.client.name}} - {{$ctrl.summary.client.salesPerson.id}}
+
{{$ctrl.summary.id}} - {{$ctrl.summary.client.name}} - {{$ctrl.summary.client.salesPerson.id}} + + +
{ + this.vnApp.showSuccess(this.$t('Order confirmed')); + this.$state.go(`ticket.index`, { + q: JSON.stringify({clientFk: this.order.clientFk}) + }); + }); + } } -ngModule.component('vnOrderSummary', { +ngModule.vnComponent('vnOrderSummary', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/order/front/summary/index.spec.js b/modules/order/front/summary/index.spec.js index f0e831aab..0c04593e1 100644 --- a/modules/order/front/summary/index.spec.js +++ b/modules/order/front/summary/index.spec.js @@ -7,7 +7,7 @@ describe('Order', () => { beforeEach(ngModule('order')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => { + beforeEach(inject(($componentController, _$httpBackend_) => { $httpBackend = _$httpBackend_; const $element = angular.element(''); controller = $componentController('vnOrderSummary', {$element}); diff --git a/modules/order/front/summary/style.scss b/modules/order/front/summary/style.scss index a0ed56d42..d0f7a3d03 100644 --- a/modules/order/front/summary/style.scss +++ b/modules/order/front/summary/style.scss @@ -3,6 +3,21 @@ vn-order-summary .summary{ max-width: $width-lg; + h5 { + display: flex; + justify-content: space-between; + align-items: center; + align-content: center; + + + span { + flex: 1; + } + + vn-button { + flex: none + } + } & > div > vn-horizontal > vn-one { min-width: 160px !important; diff --git a/modules/order/front/volume/index.js b/modules/order/front/volume/index.js index 5941611ee..aaadf2af6 100644 --- a/modules/order/front/volume/index.js +++ b/modules/order/front/volume/index.js @@ -27,7 +27,7 @@ class Controller extends Section { } } -ngModule.component('vnOrderVolume', { +ngModule.vnComponent('vnOrderVolume', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/order/front/volume/index.spec.js b/modules/order/front/volume/index.spec.js index 241277d78..6d7b18865 100644 --- a/modules/order/front/volume/index.spec.js +++ b/modules/order/front/volume/index.spec.js @@ -8,7 +8,7 @@ describe('Order', () => { beforeEach(ngModule('order')); - beforeEach(angular.mock.inject(($componentController, $state, _$httpBackend_, $rootScope) => { + beforeEach(inject(($componentController, $state, _$httpBackend_, $rootScope) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); $scope.model = { diff --git a/modules/route/front/basic-data/index.js b/modules/route/front/basic-data/index.js index cced46f55..b8602ed12 100644 --- a/modules/route/front/basic-data/index.js +++ b/modules/route/front/basic-data/index.js @@ -9,7 +9,7 @@ class Controller extends Section { } } -ngModule.component('vnRouteBasicData', { +ngModule.vnComponent('vnRouteBasicData', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/route/front/card/index.js b/modules/route/front/card/index.js index 0760259d3..5813c9e89 100644 --- a/modules/route/front/card/index.js +++ b/modules/route/front/card/index.js @@ -63,7 +63,7 @@ class Controller extends ModuleCard { } } -ngModule.component('vnRouteCard', { +ngModule.vnComponent('vnRouteCard', { template: require('./index.html'), controller: Controller }); diff --git a/modules/route/front/create/index.js b/modules/route/front/create/index.js index 703ecb49a..56c8cc25a 100644 --- a/modules/route/front/create/index.js +++ b/modules/route/front/create/index.js @@ -9,7 +9,7 @@ export default class Controller extends Section { } } -ngModule.component('vnRouteCreate', { +ngModule.vnComponent('vnRouteCreate', { template: require('./index.html'), controller: Controller }); diff --git a/modules/route/front/index/index.js b/modules/route/front/index/index.js index 7014bc609..400684a0d 100644 --- a/modules/route/front/index/index.js +++ b/modules/route/front/index/index.js @@ -8,7 +8,7 @@ export default class Controller extends Section { } } -ngModule.component('vnRouteIndex', { +ngModule.vnComponent('vnRouteIndex', { template: require('./index.html'), controller: Controller }); diff --git a/modules/route/front/log/index.js b/modules/route/front/log/index.js index b7d456b23..c1a7052a9 100644 --- a/modules/route/front/log/index.js +++ b/modules/route/front/log/index.js @@ -1,7 +1,7 @@ import ngModule from '../module'; import Section from 'salix/components/section'; -ngModule.component('vnRouteLog', { +ngModule.vnComponent('vnRouteLog', { template: require('./index.html'), controller: Section, }); diff --git a/modules/route/front/search-panel/index.js b/modules/route/front/search-panel/index.js index 6226236f2..d2de05709 100644 --- a/modules/route/front/search-panel/index.js +++ b/modules/route/front/search-panel/index.js @@ -1,7 +1,7 @@ import ngModule from '../module'; import SearchPanel from 'core/components/searchbar/search-panel'; -ngModule.component('vnRouteSearchPanel', { +ngModule.vnComponent('vnRouteSearchPanel', { template: require('./index.html'), controller: SearchPanel }); diff --git a/modules/route/front/summary/index.js b/modules/route/front/summary/index.js index 95e208b84..66ad17a8d 100644 --- a/modules/route/front/summary/index.js +++ b/modules/route/front/summary/index.js @@ -29,7 +29,7 @@ class Controller extends Section { } } -ngModule.component('vnRouteSummary', { +ngModule.vnComponent('vnRouteSummary', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/route/front/summary/index.spec.js b/modules/route/front/summary/index.spec.js index 99c029394..ad300817a 100644 --- a/modules/route/front/summary/index.spec.js +++ b/modules/route/front/summary/index.spec.js @@ -7,7 +7,7 @@ describe('Route', () => { beforeEach(ngModule('route')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => { + beforeEach(inject(($componentController, _$httpBackend_) => { $httpBackend = _$httpBackend_; const $element = angular.element(''); controller = $componentController('vnRouteSummary', {$element}); @@ -17,7 +17,6 @@ describe('Route', () => { describe('getSummary()', () => { it('should perform a query to set summary', () => { $httpBackend.when('GET', `Routes/1/summary`).respond(200, 24); - $httpBackend.expect('GET', `Routes/1/summary`); controller.getSummary(); $httpBackend.flush(); diff --git a/modules/route/front/tickets/index.html b/modules/route/front/tickets/index.html index fee60dcca..9e48d50ed 100644 --- a/modules/route/front/tickets/index.html +++ b/modules/route/front/tickets/index.html @@ -108,7 +108,7 @@ + on-accept="$ctrl.removeTicketFromRoute()"> diff --git a/modules/route/front/tickets/index.js b/modules/route/front/tickets/index.js index e7c6cb7b1..a811d6d88 100644 --- a/modules/route/front/tickets/index.js +++ b/modules/route/front/tickets/index.js @@ -59,7 +59,7 @@ class Controller extends Section { let params = {priority: priority}; let query = `Tickets/${id}/`; this.$http.patch(query, params).then(() => { - this.vnApp.showSuccess(this.$translate.instant('Data saved!')); + this.vnApp.showSuccess(this.$t('Data saved!')); this.$.model.refresh(); }); } @@ -101,15 +101,13 @@ class Controller extends Section { this.$.confirm.show(); } - removeTicketFromRoute(response) { - if (response === 'accept') { - let params = {routeFk: null}; - let query = `Tickets/${this.selectedTicket}/`; - this.$http.patch(query, params).then(() => { - this.vnApp.showSuccess(this.$translate.instant('Ticket removed from route')); - this.updateVolume(); - }); - } + removeTicketFromRoute() { + let params = {routeFk: null}; + let query = `Tickets/${this.selectedTicket}/`; + this.$http.patch(query, params).then(() => { + this.vnApp.showSuccess(this.$t('Ticket removed from route')); + this.updateVolume(); + }); } updateVolume() { @@ -123,7 +121,7 @@ class Controller extends Section { guessPriority() { let query = `Routes/${this.$params.id}/guessPriority/`; this.$http.get(query).then(() => { - this.vnApp.showSuccess(this.$translate.instant('Order changed')); + this.vnApp.showSuccess(this.$t('Order changed')); this.$.model.refresh(); }); } @@ -133,20 +131,17 @@ class Controller extends Section { this.$.possibleTicketsDialog.show(); } - setTicketsRoute(response) { - if (response === 'accept') { - let tickets = this.getSelectedItems(this.possibleTickets); - - for (let i = 0; i < tickets.length; i++) { - delete tickets[i].checked; - tickets[i].routeFk = this.route.id; - } - - return this.$.possibleTicketsModel.save().then(() => { - this.$.model.data = this.$.model.data.concat(tickets); - }); + setTicketsRoute() { + let tickets = this.getSelectedItems(this.possibleTickets); + if (tickets.length === 0) return; + for (let i = 0; i < tickets.length; i++) { + delete tickets[i].checked; + tickets[i].routeFk = this.route.id; } - return Promise.resolve(); + + return this.$.possibleTicketsModel.save().then(() => { + this.$.model.data = this.$.model.data.concat(tickets); + }); } onDrop($event) { @@ -159,7 +154,7 @@ class Controller extends Section { if (matches && matches.length) this.insert(matches[1]); else - this.vnApp.showError(this.$translate.instant('Ticket not found')); + this.vnApp.showError(this.$t('Ticket not found')); } if (!isNaN(ticketId)) @@ -169,18 +164,18 @@ class Controller extends Section { insert(id) { const params = {routeFk: this.route.id}; this.$http.patch(`Tickets/${id}`, params).then(() => { - this.vnApp.showSuccess(this.$translate.instant('Data saved!')); + this.vnApp.showSuccess(this.$t('Data saved!')); this.$.model.refresh(); this.card.reload(); }).catch(error => { if (error.status == 404) - return this.vnApp.showError(this.$translate.instant('Ticket not found')); + return this.vnApp.showError(this.$t('Ticket not found')); throw error; }); } } -ngModule.component('vnRouteTickets', { +ngModule.vnComponent('vnRouteTickets', { template: require('./index.html'), controller: Controller, require: { diff --git a/modules/route/front/tickets/index.spec.js b/modules/route/front/tickets/index.spec.js index c2671c3d7..a32b368ba 100644 --- a/modules/route/front/tickets/index.spec.js +++ b/modules/route/front/tickets/index.spec.js @@ -7,7 +7,7 @@ describe('Route', () => { beforeEach(ngModule('route')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); const $element = angular.element(''); @@ -101,7 +101,7 @@ describe('Route', () => { controller.setPriority(ticketId, priority); $httpBackend.flush(); - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); + expect(controller.vnApp.showSuccess).toHaveBeenCalled(); expect(controller.$.model.refresh).toHaveBeenCalledWith(); }); }); @@ -170,7 +170,7 @@ describe('Route', () => { controller.selectedTicket = ticketId; $httpBackend.expectPATCH(`Tickets/${ticketId}/`).respond('ok'); - controller.removeTicketFromRoute('accept'); + controller.removeTicketFromRoute(); $httpBackend.flush(); expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Ticket removed from route'); @@ -250,15 +250,11 @@ describe('Route', () => { {id: 5, routeFk: 111} ]; - controller.setTicketsRoute('accept').then(() => { + controller.setTicketsRoute().then(() => { expect(controller.$.model.data).toEqual(expectedResult); done(); }).catch(done.fail); }); - - it('should just return a promise', () => { - expect(controller.setTicketsRoute('cancel')).toEqual(jasmine.any(Promise)); - }); }); describe('onDrop()', () => { @@ -318,7 +314,7 @@ describe('Route', () => { controller.insert(ticketId); $httpBackend.flush(); - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); + expect(controller.vnApp.showSuccess).toHaveBeenCalled(); expect(controller.$.model.refresh).toHaveBeenCalledWith(); }); }); diff --git a/modules/ticket/back/methods/ticket-weekly/filter.js b/modules/ticket/back/methods/ticket-weekly/filter.js index 77f8ecc57..ef00aff9b 100644 --- a/modules/ticket/back/methods/ticket-weekly/filter.js +++ b/modules/ticket/back/methods/ticket-weekly/filter.js @@ -51,7 +51,7 @@ module.exports = Self => { stmt = new ParameterizedSQL( `SELECT t.id AS ticketFk, c.id AS clientFk, c.name AS clientName, tw.weekDay, - wh.name AS warehouseName, u.id AS workerFk, u.nickName, tw.agencyModeFk + wh.name AS warehouseName, u.id AS workerFk, u.name AS userName, u.nickName, tw.agencyModeFk FROM ticketWeekly tw JOIN ticket t ON t.id = tw.ticketFk JOIN client c ON c.id = t.clientFk diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index 28de7b8ee..801563b93 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -203,14 +203,16 @@ module.exports = Self => { am.id AS agencyModeFk, st.name AS state, wk.lastName AS salesPerson, - ts.stateFk as stateFk, - ts.alertLevel as alertLevel, - ts.code as alertLevelCode, - u.nickname userNickname, + ts.stateFk AS stateFk, + ts.alertLevel AS alertLevel, + ts.code AS alertLevelCode, + u.name AS userName, c.salesPersonFk, - z.hour zoneLanding, - HOUR(z.hour) zoneHour, - MINUTE(z.hour) zoneMinute, + z.hour AS zoneLanding, + HOUR(z.hour) AS zoneHour, + MINUTE(z.hour) AS zoneMinute, + z.name AS zoneName, + z.id AS zoneFk, CAST(z.hour AS CHAR) AS hour FROM ticket t LEFT JOIN zone z ON z.id = t.zoneFk diff --git a/modules/ticket/back/methods/ticket/specs/filter.spec.js b/modules/ticket/back/methods/ticket/specs/filter.spec.js index 56d351f2e..4aa1b3a77 100644 --- a/modules/ticket/back/methods/ticket/specs/filter.spec.js +++ b/modules/ticket/back/methods/ticket/specs/filter.spec.js @@ -66,7 +66,7 @@ describe('ticket filter()', () => { const secondRow = result[1]; const thirdRow = result[2]; - expect(result.length).toEqual(13); + expect(result.length).toEqual(12); expect(firstRow.state).toEqual('Entregado'); expect(secondRow.state).toEqual('Entregado'); expect(thirdRow.state).toEqual('Entregado'); diff --git a/modules/ticket/front/basic-data/index.js b/modules/ticket/front/basic-data/index.js index 4deebff17..5d4ad2b73 100644 --- a/modules/ticket/front/basic-data/index.js +++ b/modules/ticket/front/basic-data/index.js @@ -21,7 +21,7 @@ class Controller extends Section { } } -ngModule.component('vnTicketBasicData', { +ngModule.vnComponent('vnTicketBasicData', { template: require('./index.html'), bindings: { ticket: '<' diff --git a/modules/ticket/front/basic-data/step-one/index.js b/modules/ticket/front/basic-data/step-one/index.js index 6cfa51a1f..68f5ac54d 100644 --- a/modules/ticket/front/basic-data/step-one/index.js +++ b/modules/ticket/front/basic-data/step-one/index.js @@ -173,7 +173,7 @@ class Controller extends Component { async onStepChange() { if (this.isFormInvalid()) { return this.vnApp.showError( - this.$translate.instant('Some fields are invalid') + this.$t('Some fields are invalid') ); } @@ -193,7 +193,7 @@ class Controller extends Component { return true; }, err => { this.vnApp.showError( - this.$translate.instant(err.data.error.message) + this.$t(err.data.error.message) ); }); } @@ -211,7 +211,7 @@ class Controller extends Component { this.ticket.shipped = params.shipped; } else { return this.vnApp.showError( - this.$translate.instant(`No delivery zone available for this landing date`) + this.$t(`No delivery zone available for this landing date`) ); } }); @@ -230,7 +230,7 @@ class Controller extends Component { this.ticket.shipped = res.data.shipped; } else { return this.vnApp.showError( - this.$translate.instant(`No delivery zone available for this landing date`) + this.$t(`No delivery zone available for this landing date`) ); } }); @@ -243,7 +243,7 @@ class Controller extends Component { } } -ngModule.component('vnTicketBasicDataStepOne', { +ngModule.vnComponent('vnTicketBasicDataStepOne', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/ticket/front/basic-data/step-one/index.spec.js b/modules/ticket/front/basic-data/step-one/index.spec.js index 43842f5a1..d9c72b660 100644 --- a/modules/ticket/front/basic-data/step-one/index.spec.js +++ b/modules/ticket/front/basic-data/step-one/index.spec.js @@ -8,7 +8,7 @@ describe('Ticket', () => { beforeEach(ngModule('ticket')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => { + beforeEach(inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => { $httpBackend = _$httpBackend_; $httpParamSerializer = _$httpParamSerializer_; const $element = angular.element(''); @@ -251,8 +251,7 @@ describe('Ticket', () => { }; filter = encodeURIComponent(JSON.stringify(filter)); - $httpBackend.when('GET', `Clients/${clientId}/addresses?filter=${filter}`).respond(200); - $httpBackend.expect('GET', `Clients/${clientId}/addresses?filter=${filter}`); + $httpBackend.expect('GET', `Clients/${clientId}/addresses?filter=${filter}`).respond(200); controller.clientAddressesList(clientId); $httpBackend.flush(); }); @@ -262,8 +261,7 @@ describe('Ticket', () => { it('should return the default address from choosed client', async() => { const clientId = 102; - $httpBackend.when('GET', `Clients/${clientId}`).respond(200); - $httpBackend.expect('GET', `Clients/${clientId}`); + $httpBackend.expect('GET', `Clients/${clientId}`).respond(200); controller.getClientDefaultAddress(clientId); $httpBackend.flush(); }); @@ -273,8 +271,7 @@ describe('Ticket', () => { it('should return an available zone', async() => { const zoneId = 5; const agencyModeFk = 8; - $httpBackend.when('GET', `Zones/${zoneId}`).respond(200, {agencyModeFk}); - $httpBackend.expect('GET', `Zones/${zoneId}`); + $httpBackend.expect('GET', `Zones/${zoneId}`).respond(200, {agencyModeFk}); controller.onChangeZone(zoneId); $httpBackend.flush(); @@ -337,8 +334,7 @@ describe('Ticket', () => { }; const serializedParams = $httpParamSerializer(params); - $httpBackend.when('GET', `Agencies/getLanded?${serializedParams}`).respond(200, expectedResult); - $httpBackend.expect('GET', `Agencies/getLanded?${serializedParams}`); + $httpBackend.expect('GET', `Agencies/getLanded?${serializedParams}`).respond(200, expectedResult); controller.getLanded(params); $httpBackend.flush(); @@ -359,8 +355,7 @@ describe('Ticket', () => { }; const serializedParams = $httpParamSerializer(params); - $httpBackend.when('GET', `Agencies/getShipped?${serializedParams}`).respond(200, expectedResult); - $httpBackend.expect('GET', `Agencies/getShipped?${serializedParams}`); + $httpBackend.expect('GET', `Agencies/getShipped?${serializedParams}`).respond(200, expectedResult); controller.getShipped(params); $httpBackend.flush(); diff --git a/modules/ticket/front/basic-data/step-two/index.js b/modules/ticket/front/basic-data/step-two/index.js index 00556350b..ff09bf9ff 100644 --- a/modules/ticket/front/basic-data/step-two/index.js +++ b/modules/ticket/front/basic-data/step-two/index.js @@ -63,7 +63,7 @@ class Controller extends Component { onSubmit() { if (!this.ticket.option) { return this.vnApp.showError( - this.$translate.instant('Choose an option') + this.$t('Choose an option') ); } @@ -83,7 +83,7 @@ class Controller extends Component { this.$http.post(query, params).then(res => { this.vnApp.showMessage( - this.$translate.instant(`The ticket has been unrouted`) + this.$t(`The ticket has been unrouted`) ); this.card.reload(); this.$state.go('ticket.card.summary', {id: this.$params.id}); @@ -91,7 +91,7 @@ class Controller extends Component { } } -ngModule.component('vnTicketBasicDataStepTwo', { +ngModule.vnComponent('vnTicketBasicDataStepTwo', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/ticket/front/basic-data/step-two/index.spec.js b/modules/ticket/front/basic-data/step-two/index.spec.js index e67389f9d..ea8268716 100644 --- a/modules/ticket/front/basic-data/step-two/index.spec.js +++ b/modules/ticket/front/basic-data/step-two/index.spec.js @@ -6,7 +6,7 @@ describe('Ticket', () => { beforeEach(ngModule('ticket')); - beforeEach(angular.mock.inject($componentController => { + beforeEach(inject($componentController => { const $element = angular.element(''); controller = $componentController('vnTicketBasicDataStepTwo', {$element}); })); diff --git a/modules/ticket/front/card/index.js b/modules/ticket/front/card/index.js index 80174b5e2..5b3c3c405 100644 --- a/modules/ticket/front/card/index.js +++ b/modules/ticket/front/card/index.js @@ -5,19 +5,25 @@ class Controller extends ModuleCard { reload() { let filter = { include: [ - {relation: 'address'}, - {relation: 'ship'}, - {relation: 'stowaway'}, + { + relation: 'address'}, + { + relation: 'ship'}, + { + relation: 'stowaway'}, { relation: 'warehouse', scope: {fields: ['name']} - }, { + }, + { relation: 'invoiceOut', scope: {fields: ['id']} - }, { + }, + { relation: 'agencyMode', scope: {fields: ['name']} - }, { + }, + { relation: 'client', scope: { fields: [ @@ -68,7 +74,7 @@ class Controller extends ModuleCard { } } -ngModule.component('vnTicketCard', { +ngModule.vnComponent('vnTicketCard', { template: require('./index.html'), controller: Controller }); diff --git a/modules/ticket/front/card/index.spec.js b/modules/ticket/front/card/index.spec.js index 33757860c..6a66e355e 100644 --- a/modules/ticket/front/card/index.spec.js +++ b/modules/ticket/front/card/index.spec.js @@ -12,7 +12,7 @@ describe('Ticket', () => { beforeEach(ngModule('ticket')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $stateParams) => { + beforeEach(inject(($componentController, _$httpBackend_, $stateParams) => { $httpBackend = _$httpBackend_; let $element = angular.element('
'); diff --git a/modules/ticket/front/component/index.js b/modules/ticket/front/component/index.js index 718e9188f..fd1ea4220 100644 --- a/modules/ticket/front/component/index.js +++ b/modules/ticket/front/component/index.js @@ -77,7 +77,7 @@ class Controller extends Section { } } -ngModule.component('vnTicketComponents', { +ngModule.vnComponent('vnTicketComponents', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/ticket/front/component/index.spec.js b/modules/ticket/front/component/index.spec.js index 3547a4905..1cffcdb52 100644 --- a/modules/ticket/front/component/index.spec.js +++ b/modules/ticket/front/component/index.spec.js @@ -7,7 +7,7 @@ describe('ticket', () => { beforeEach(ngModule('ticket')); - beforeEach(angular.mock.inject(($componentController, $rootScope, $state) => { + beforeEach(inject(($componentController, $rootScope, $state) => { $state.params.id = '1'; let $scope = $rootScope.$new(); $scope.model = crudModel; diff --git a/modules/ticket/front/create/card.js b/modules/ticket/front/create/card.js index 01c5da4c9..213a0b082 100644 --- a/modules/ticket/front/create/card.js +++ b/modules/ticket/front/create/card.js @@ -120,13 +120,13 @@ class Controller extends Component { warehouseId: this.ticket.warehouseFk, }; this.$http.post(`Tickets/new`, params).then(res => { - this.vnApp.showSuccess(this.$translate.instant('Data saved!')); + this.vnApp.showSuccess(this.$t('Data saved!')); this.$state.go('ticket.card.summary', {id: res.data.id}); }); } } -ngModule.component('vnTicketCreateCard', { +ngModule.vnComponent('vnTicketCreateCard', { template: require('./card.html'), controller: Controller, bindings: { diff --git a/modules/ticket/front/create/index.js b/modules/ticket/front/create/index.js index c93051d7a..0166b9e91 100644 --- a/modules/ticket/front/create/index.js +++ b/modules/ticket/front/create/index.js @@ -8,7 +8,7 @@ class Controller extends Section { } } -ngModule.component('vnTicketCreate', { +ngModule.vnComponent('vnTicketCreate', { template: require('./index.html'), controller: Controller }); diff --git a/modules/ticket/front/descriptor/addStowaway.js b/modules/ticket/front/descriptor/addStowaway.js index 4497fef82..c88bda0af 100644 --- a/modules/ticket/front/descriptor/addStowaway.js +++ b/modules/ticket/front/descriptor/addStowaway.js @@ -8,7 +8,7 @@ class Controller extends Component { this.$http.post(`Stowaways/`, params) .then(() => this.cardReload()) .then(() => { - this.vnApp.showSuccess(this.$translate.instant('Data saved!')); + this.vnApp.showSuccess(this.$t('Data saved!')); this.$.dialog.hide(); }); } @@ -22,7 +22,7 @@ class Controller extends Component { } } -ngModule.component('vnAddStowaway', { +ngModule.vnComponent('vnAddStowaway', { template: require('./addStowaway.html'), controller: Controller, bindings: { diff --git a/modules/ticket/front/descriptor/index.spec.js b/modules/ticket/front/descriptor/index.spec.js index ef032d775..4904f2ff1 100644 --- a/modules/ticket/front/descriptor/index.spec.js +++ b/modules/ticket/front/descriptor/index.spec.js @@ -25,7 +25,7 @@ describe('Ticket Component vnTicketDescriptor', () => { beforeEach(ngModule('ticket')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, _$state_) => { + beforeEach(inject(($componentController, _$httpBackend_, _$state_) => { $httpBackend = _$httpBackend_; $httpBackend.whenGET(`Tickets/${ticket.id}/canHaveStowaway`).respond(true); $httpBackend.whenGET(`Tickets/1/isEditable`).respond(true); diff --git a/modules/ticket/front/dms/create/index.js b/modules/ticket/front/dms/create/index.js index e745d98b8..142158e46 100644 --- a/modules/ticket/front/dms/create/index.js +++ b/modules/ticket/front/dms/create/index.js @@ -32,7 +32,7 @@ class Controller extends Section { } get contentTypesInfo() { - return this.$translate.instant('ContentTypesInfo', { + return this.$t('ContentTypesInfo', { allowedContentTypes: this.allowedContentTypes }); } @@ -49,7 +49,7 @@ class Controller extends Section { warehouseId: warehouseId, companyId: this.ticket.companyFk, dmsTypeId: dmsTypeId, - description: this.$translate.instant('FileDescription', { + description: this.$t('FileDescription', { ticketId: this.ticket.id, clientId: this.ticket.client.id, clientName: this.ticket.client.name @@ -81,7 +81,7 @@ class Controller extends Section { }; this.$http(options).then(res => { if (res) { - this.vnApp.showSuccess(this.$translate.instant('Data saved!')); + this.vnApp.showSuccess(this.$t('Data saved!')); this.$.watcher.updateOriginalData(); this.$state.go('ticket.card.dms.index'); } @@ -99,7 +99,7 @@ class Controller extends Section { } } -ngModule.component('vnTicketDmsCreate', { +ngModule.vnComponent('vnTicketDmsCreate', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/ticket/front/dms/create/index.spec.js b/modules/ticket/front/dms/create/index.spec.js index c6cb1da5a..e3c195799 100644 --- a/modules/ticket/front/dms/create/index.spec.js +++ b/modules/ticket/front/dms/create/index.spec.js @@ -9,7 +9,7 @@ describe('Ticket', () => { beforeEach(ngModule('ticket')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { $scope = $rootScope.$new(); $httpBackend = _$httpBackend_; $httpParamSerializer = _$httpParamSerializer_; @@ -44,8 +44,7 @@ describe('Ticket', () => { where: {code: 'ticket'} }}; let serializedParams = $httpParamSerializer(params); - $httpBackend.when('GET', `DmsTypes/findOne?${serializedParams}`).respond({id: 14, code: 'ticket'}); - $httpBackend.expect('GET', `DmsTypes/findOne?${serializedParams}`); + $httpBackend.expect('GET', `DmsTypes/findOne?${serializedParams}`).respond({id: 14, code: 'ticket'}); controller.setDefaultParams(); $httpBackend.flush(); @@ -68,8 +67,7 @@ describe('Ticket', () => { describe('getAllowedContentTypes()', () => { it('should make an HTTP GET request to get the allowed content types', () => { const expectedResponse = ['image/png', 'image/jpg']; - $httpBackend.when('GET', `ticketDms/allowedContentTypes`).respond(expectedResponse); - $httpBackend.expect('GET', `ticketDms/allowedContentTypes`); + $httpBackend.expect('GET', `ticketDms/allowedContentTypes`).respond(expectedResponse); controller.getAllowedContentTypes(); $httpBackend.flush(); diff --git a/modules/ticket/front/dms/edit/index.js b/modules/ticket/front/dms/edit/index.js index 44e3890f8..e50092f77 100644 --- a/modules/ticket/front/dms/edit/index.js +++ b/modules/ticket/front/dms/edit/index.js @@ -23,7 +23,7 @@ class Controller extends Section { } get contentTypesInfo() { - return this.$translate.instant('ContentTypesInfo', { + return this.$t('ContentTypesInfo', { allowedContentTypes: this.allowedContentTypes }); } @@ -66,7 +66,7 @@ class Controller extends Section { }; this.$http(options).then(res => { if (res) { - this.vnApp.showSuccess(this.$translate.instant('Data saved!')); + this.vnApp.showSuccess(this.$t('Data saved!')); this.$.watcher.updateOriginalData(); this.$state.go('ticket.card.dms.index'); } @@ -84,7 +84,7 @@ class Controller extends Section { } } -ngModule.component('vnTicketDmsEdit', { +ngModule.vnComponent('vnTicketDmsEdit', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/ticket/front/dms/edit/index.spec.js b/modules/ticket/front/dms/edit/index.spec.js index 20224a4b9..052b08a1b 100644 --- a/modules/ticket/front/dms/edit/index.spec.js +++ b/modules/ticket/front/dms/edit/index.spec.js @@ -8,7 +8,7 @@ describe('Ticket', () => { beforeEach(ngModule('ticket')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { $scope = $rootScope.$new(); $httpBackend = _$httpBackend_; const $element = angular.element(''); @@ -45,7 +45,6 @@ describe('Ticket', () => { hasFileAttached: false }; - $httpBackend.when('GET', `Dms/${dmsId}`).respond(expectedResponse); $httpBackend.expect('GET', `Dms/${dmsId}`).respond(expectedResponse); controller.setDefaultParams(); $httpBackend.flush(); @@ -70,8 +69,7 @@ describe('Ticket', () => { describe('getAllowedContentTypes()', () => { it('should make an HTTP GET request to get the allowed content types', () => { const expectedResponse = ['image/png', 'image/jpg']; - $httpBackend.when('GET', `ticketDms/allowedContentTypes`).respond(expectedResponse); - $httpBackend.expect('GET', `ticketDms/allowedContentTypes`); + $httpBackend.expect('GET', `ticketDms/allowedContentTypes`).respond(expectedResponse); controller.getAllowedContentTypes(); $httpBackend.flush(); diff --git a/modules/ticket/front/dms/index/index.js b/modules/ticket/front/dms/index/index.js index c3d468e60..2a67d6890 100644 --- a/modules/ticket/front/dms/index/index.js +++ b/modules/ticket/front/dms/index/index.js @@ -59,7 +59,7 @@ class Controller extends Section { Controller.$inject = ['$element', '$scope', 'vnFile']; -ngModule.component('vnTicketDmsIndex', { +ngModule.vnComponent('vnTicketDmsIndex', { template: require('./index.html'), controller: Controller, }); diff --git a/modules/ticket/front/dms/index/index.spec.js b/modules/ticket/front/dms/index/index.spec.js index 2cd63462a..8221abcd8 100644 --- a/modules/ticket/front/dms/index/index.spec.js +++ b/modules/ticket/front/dms/index/index.spec.js @@ -8,7 +8,7 @@ describe('Ticket', () => { beforeEach(ngModule('ticket')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => { + beforeEach(inject(($componentController, _$httpBackend_) => { $httpBackend = _$httpBackend_; controller = $componentController('vnTicketDmsIndex', {$element: null}); controller.$.model = crudModel; diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js index 673c18e33..0c395e6ce 100644 --- a/modules/ticket/front/expedition/index.js +++ b/modules/ticket/front/expedition/index.js @@ -8,7 +8,7 @@ class Controller extends Section { } } -ngModule.component('vnTicketExpedition', { +ngModule.vnComponent('vnTicketExpedition', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/ticket/front/expedition/index.spec.js b/modules/ticket/front/expedition/index.spec.js index 761dc1fb6..425539aef 100644 --- a/modules/ticket/front/expedition/index.spec.js +++ b/modules/ticket/front/expedition/index.spec.js @@ -8,7 +8,7 @@ describe('Ticket', () => { beforeEach(ngModule('ticket')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); $scope.model = { diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index abd772229..b0aff5b91 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -21,7 +21,7 @@ Alias Province State - Agency + Zone Warehouse Invoice Closure @@ -61,26 +61,28 @@
{{::ticket.id}} - + - {{::ticket.userNickname | dashIfEmpty}} + {{::ticket.userName | dashIfEmpty}} - + {{::ticket.shipped | date: 'dd/MM/yyyy'}} {{::ticket.shipped | date: 'HH:mm'}} - + {{::ticket.nickname}} @@ -92,7 +94,14 @@ {{ticket.state}} - {{::ticket.agencyMode}} + + + {{::ticket.zoneName | dashIfEmpty}} + + {{::ticket.warehouse}} {{::ticket.refFk | dashIfEmpty}} {{::ticket.zoneLanding | date: 'HH:mm'}} @@ -155,6 +164,9 @@ + + diff --git a/modules/ticket/front/index/index.js b/modules/ticket/front/index/index.js index 2c8b9b83c..32c2f0baa 100644 --- a/modules/ticket/front/index/index.js +++ b/modules/ticket/front/index/index.js @@ -158,7 +158,7 @@ export default class Controller extends Section { } Controller.$inject = ['$element', '$scope', 'vnReport']; -ngModule.component('vnTicketIndex', { +ngModule.vnComponent('vnTicketIndex', { template: require('./index.html'), controller: Controller }); diff --git a/modules/ticket/front/log/index.js b/modules/ticket/front/log/index.js index df2584481..dc186c6ee 100644 --- a/modules/ticket/front/log/index.js +++ b/modules/ticket/front/log/index.js @@ -1,7 +1,7 @@ import ngModule from '../module'; import Section from 'salix/components/section'; -ngModule.component('vnTicketLog', { +ngModule.vnComponent('vnTicketLog', { template: require('./index.html'), controller: Section, }); diff --git a/modules/ticket/front/note/index.js b/modules/ticket/front/note/index.js index 3eda4561b..419c079e9 100644 --- a/modules/ticket/front/note/index.js +++ b/modules/ticket/front/note/index.js @@ -11,7 +11,7 @@ class Controller extends Section { } } -ngModule.component('vnTicketObservation', { +ngModule.vnComponent('vnTicketObservation', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/ticket/front/package/index.js b/modules/ticket/front/package/index.js index df0b9a503..ed13f12d8 100644 --- a/modules/ticket/front/package/index.js +++ b/modules/ticket/front/package/index.js @@ -20,7 +20,7 @@ class Controller extends Section { } } -ngModule.component('vnTicketPackage', { +ngModule.vnComponent('vnTicketPackage', { template: require('./index.html'), controller: Controller }); diff --git a/modules/ticket/front/picture/index.js b/modules/ticket/front/picture/index.js index 50d7cc777..89cf9e078 100644 --- a/modules/ticket/front/picture/index.js +++ b/modules/ticket/front/picture/index.js @@ -15,7 +15,7 @@ class Controller extends Section { } } -ngModule.component('vnTicketPicture', { +ngModule.vnComponent('vnTicketPicture', { template: require('./index.html'), controller: Controller }); diff --git a/modules/ticket/front/request/create/index.js b/modules/ticket/front/request/create/index.js index 2d432e637..f2781a810 100644 --- a/modules/ticket/front/request/create/index.js +++ b/modules/ticket/front/request/create/index.js @@ -17,7 +17,7 @@ class Controller extends Section { } } -ngModule.component('vnTicketRequestCreate', { +ngModule.vnComponent('vnTicketRequestCreate', { template: require('./index.html'), controller: Controller }); diff --git a/modules/ticket/front/request/index/index.js b/modules/ticket/front/request/index/index.js index 7ee1399e6..b4b11292e 100644 --- a/modules/ticket/front/request/index/index.js +++ b/modules/ticket/front/request/index/index.js @@ -68,7 +68,7 @@ class Controller extends Section { } } -ngModule.component('vnTicketRequestIndex', { +ngModule.vnComponent('vnTicketRequestIndex', { template: require('./index.html'), controller: Controller }); diff --git a/modules/ticket/front/routes.json b/modules/ticket/front/routes.json index cfb2d07c9..cb1701008 100644 --- a/modules/ticket/front/routes.json +++ b/modules/ticket/front/routes.json @@ -3,7 +3,7 @@ "name": "Tickets", "icon": "icon-ticket", "validations": true, - "dependencies": ["worker", "item", "client", "route", "invoiceOut"], + "dependencies": ["worker", "item", "client", "route", "invoiceOut", "zone"], "menus": { "main": [ {"state": "ticket.index", "icon": "icon-ticket"}, @@ -189,28 +189,26 @@ "state": "ticket.weekly.index", "component": "vn-ticket-weekly-index", "description": "Weekly tickets" - }, { - "url": "/request", - "state": "ticket.card.request", - "abstract": true, - "component": "ui-view" }, { "url": "/service", "state": "ticket.card.service", "component": "vn-ticket-service", "description": "Service" + }, { + "url": "/request", + "state": "ticket.card.request", + "abstract": true, + "component": "ui-view" }, { "url" : "/index", "state": "ticket.card.request.index", "component": "vn-ticket-request-index", - "description": "Purchase request", - "acl": ["salesPerson"] + "description": "Purchase request" }, { "url" : "/create", "state": "ticket.card.request.create", "component": "vn-ticket-request-create", - "description": "New purchase request", - "acl": ["salesPerson"] + "description": "New purchase request" }, { "url": "/create?clientFk", "state": "ticket.create", diff --git a/modules/ticket/front/sale-checked/index.js b/modules/ticket/front/sale-checked/index.js index 37d63a485..cfc3985ba 100644 --- a/modules/ticket/front/sale-checked/index.js +++ b/modules/ticket/front/sale-checked/index.js @@ -33,7 +33,7 @@ class Controller extends Section { } } -ngModule.component('vnTicketSaleChecked', { +ngModule.vnComponent('vnTicketSaleChecked', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/ticket/front/sale-tracking/index.js b/modules/ticket/front/sale-tracking/index.js index ebb6f9ada..394ef4f1e 100644 --- a/modules/ticket/front/sale-tracking/index.js +++ b/modules/ticket/front/sale-tracking/index.js @@ -3,7 +3,7 @@ import Section from 'salix/components/section'; class Controller extends Section {} -ngModule.component('vnTicketSaleTracking', { +ngModule.vnComponent('vnTicketSaleTracking', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 4b96b6326..8caa2f89e 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -284,7 +284,7 @@ -
+

Sales to transfer

@@ -384,14 +384,14 @@ vn-id="delete-lines" question="You are going to delete lines of the ticket" message="Continue anyway?" - on-response="$ctrl.removeSales()"> + on-accept="$ctrl.removeSales()"> + on-accept="$ctrl.transferSales($ctrl.transfer.ticketId)"> diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index bd3fa4813..48f33454c 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -281,7 +281,7 @@ class Controller extends Section { const params = {salesIds: saleIds, newDiscount: this.edit.discount}; const query = `Tickets/${this.$params.id}/updateDiscount`; this.$http.post(query, params).then(() => { - this.vnApp.showSuccess(this.$translate.instant('Data saved!')); + this.vnApp.showSuccess(this.$t('Data saved!')); for (let sale of sales) sale.discount = this.edit.discount; @@ -476,7 +476,7 @@ class Controller extends Section { } } -ngModule.component('vnTicketSale', { +ngModule.vnComponent('vnTicketSale', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/ticket/front/sale/index.spec.js b/modules/ticket/front/sale/index.spec.js index ba08d9733..28b3ce3dd 100644 --- a/modules/ticket/front/sale/index.spec.js +++ b/modules/ticket/front/sale/index.spec.js @@ -11,7 +11,7 @@ describe('Ticket', () => { beforeEach(ngModule('ticket')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$state_, _$httpBackend_) => { + beforeEach(inject(($componentController, $rootScope, _$state_, _$httpBackend_) => { const ticket = { id: 1, clientFk: 101, @@ -248,7 +248,7 @@ describe('Ticket', () => { $httpBackend.flush(); expect(controller.card.reload).toHaveBeenCalledWith(); - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); + expect(controller.vnApp.showSuccess).toHaveBeenCalled(); expect(controller.resetChanges).toHaveBeenCalledWith(); }); }); @@ -267,7 +267,7 @@ describe('Ticket', () => { $httpBackend.flush(); expect(controller.removeSelectedSales).toHaveBeenCalledWith(); - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); + expect(controller.vnApp.showSuccess).toHaveBeenCalled(); expect(controller.resetChanges).toHaveBeenCalledWith(); }); }); @@ -371,7 +371,7 @@ describe('Ticket', () => { expect(selectedSale.price).toEqual(2); expect(controller.refreshTotal).toHaveBeenCalledWith(); - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); + expect(controller.vnApp.showSuccess).toHaveBeenCalled(); expect(controller.$.editPricePopover.hide).toHaveBeenCalledWith(); expect(controller.resetChanges).toHaveBeenCalledWith(); }); @@ -472,7 +472,7 @@ describe('Ticket', () => { expect(firstSelectedSale.discount).toEqual(expectedDiscount); expect(secondSelectedSale.discount).toEqual(expectedDiscount); expect(controller.refreshTotal).toHaveBeenCalledWith(); - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); + expect(controller.vnApp.showSuccess).toHaveBeenCalled(); expect(controller.resetChanges).toHaveBeenCalledWith(); }); }); @@ -678,7 +678,7 @@ describe('Ticket', () => { controller.addSale(newSale); $httpBackend.flush(); - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); + expect(controller.vnApp.showSuccess).toHaveBeenCalled(); expect(controller.refreshTotal).toHaveBeenCalledWith(); expect(controller.resetChanges).toHaveBeenCalledWith(); }); @@ -719,7 +719,7 @@ describe('Ticket', () => { controller.calculateSalePrice(); $httpBackend.flush(); - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); + expect(controller.vnApp.showSuccess).toHaveBeenCalled(); expect(controller.$.model.refresh).toHaveBeenCalledWith(); expect(controller.refreshTotal).toHaveBeenCalledWith(); }); diff --git a/modules/ticket/front/search-panel/index.js b/modules/ticket/front/search-panel/index.js index 5c3c44107..22093784a 100644 --- a/modules/ticket/front/search-panel/index.js +++ b/modules/ticket/front/search-panel/index.js @@ -1,7 +1,7 @@ import ngModule from '../module'; import SearchPanel from 'core/components/searchbar/search-panel'; -ngModule.component('vnTicketSearchPanel', { +ngModule.vnComponent('vnTicketSearchPanel', { template: require('./index.html'), controller: SearchPanel }); diff --git a/modules/ticket/front/services/index.js b/modules/ticket/front/services/index.js index efb62fe2e..01678c7bb 100644 --- a/modules/ticket/front/services/index.js +++ b/modules/ticket/front/services/index.js @@ -47,7 +47,7 @@ class Controller extends Section { } } -ngModule.component('vnTicketService', { +ngModule.vnComponent('vnTicketService', { template: require('./index.html'), controller: Controller }); diff --git a/modules/ticket/front/services/index.spec.js b/modules/ticket/front/services/index.spec.js index 10e3ad47e..5d8d58505 100644 --- a/modules/ticket/front/services/index.spec.js +++ b/modules/ticket/front/services/index.spec.js @@ -8,7 +8,7 @@ describe('Ticket component vnTicketService', () => { beforeEach(ngModule('ticket')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope) => { + beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); diff --git a/modules/ticket/front/sms/index.html b/modules/ticket/front/sms/index.html index eeb98cbcb..97bdfef14 100644 --- a/modules/ticket/front/sms/index.html +++ b/modules/ticket/front/sms/index.html @@ -1,6 +1,6 @@
diff --git a/modules/ticket/front/sms/index.js b/modules/ticket/front/sms/index.js index 56959e3ee..33369acae 100644 --- a/modules/ticket/front/sms/index.js +++ b/modules/ticket/front/sms/index.js @@ -16,31 +16,29 @@ class Controller extends Component { return maxLength - textAreaLength; } - onResponse(response) { - if (response === 'accept') { - try { - if (!this.sms.destination) - throw new Error(`The destination can't be empty`); - if (!this.sms.message) - throw new Error(`The message can't be empty`); - if (this.charactersRemaining() < 0) - throw new Error(`The message it's too long`); + onResponse() { + try { + if (!this.sms.destination) + throw new Error(`The destination can't be empty`); + if (!this.sms.message) + throw new Error(`The message can't be empty`); + if (this.charactersRemaining() < 0) + throw new Error(`The message it's too long`); - this.$http.post(`Tickets/${this.$params.id}/sendSms`, this.sms).then(res => { - this.vnApp.showMessage(this.$translate.instant('SMS sent!')); + this.$http.post(`Tickets/${this.$params.id}/sendSms`, this.sms).then(res => { + this.vnApp.showMessage(this.$t('SMS sent!')); - if (res.data) this.emit('send', {response: res.data}); - }); - } catch (e) { - this.vnApp.showError(this.$translate.instant(e.message)); - return false; - } + if (res.data) this.emit('send', {response: res.data}); + }); + } catch (e) { + this.vnApp.showError(this.$t(e.message)); + return false; } return true; } } -ngModule.component('vnTicketSms', { +ngModule.vnComponent('vnTicketSms', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/ticket/front/sms/index.spec.js b/modules/ticket/front/sms/index.spec.js index 45e7765d1..e918ffb54 100644 --- a/modules/ticket/front/sms/index.spec.js +++ b/modules/ticket/front/sms/index.spec.js @@ -7,7 +7,7 @@ describe('Ticket', () => { beforeEach(ngModule('ticket')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { $httpBackend = _$httpBackend_; let $scope = $rootScope.$new(); const $element = angular.element(''); @@ -28,7 +28,7 @@ describe('Ticket', () => { jest.spyOn(controller.vnApp, 'showMessage'); $httpBackend.expect('POST', `Tickets/11/sendSms`, params).respond(200, params); - controller.onResponse('accept'); + controller.onResponse(); $httpBackend.flush(); expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent!'); @@ -39,7 +39,7 @@ describe('Ticket', () => { jest.spyOn(controller.vnApp, 'showError'); - controller.onResponse('accept'); + controller.onResponse(); expect(controller.vnApp.showError).toHaveBeenCalledWith(`The destination can't be empty`); }); @@ -49,7 +49,7 @@ describe('Ticket', () => { jest.spyOn(controller.vnApp, 'showError'); - controller.onResponse('accept'); + controller.onResponse(); expect(controller.vnApp.showError).toHaveBeenCalledWith(`The message can't be empty`); }); diff --git a/modules/ticket/front/summary/index.html b/modules/ticket/front/summary/index.html index 8b73c9c48..7b0e9d06d 100644 --- a/modules/ticket/front/summary/index.html +++ b/modules/ticket/front/summary/index.html @@ -108,7 +108,7 @@ + vn-tooltip="{{::$ctrl.$t('Claim')}}: {{::sale.claimBeginning.claimFk}}"> { - this.vnApp.showSuccess(this.$translate.instant('Data saved!')); + this.vnApp.showSuccess(this.$t('Data saved!')); if (this.card) this.card.reload(); else @@ -74,7 +74,7 @@ class Controller extends Section { } } -ngModule.component('vnTicketSummary', { +ngModule.vnComponent('vnTicketSummary', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/ticket/front/summary/index.spec.js b/modules/ticket/front/summary/index.spec.js index e1f0e8836..e94f316de 100644 --- a/modules/ticket/front/summary/index.spec.js +++ b/modules/ticket/front/summary/index.spec.js @@ -7,7 +7,7 @@ describe('Ticket', () => { beforeEach(ngModule('ticket')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => { + beforeEach(inject(($componentController, _$httpBackend_) => { $httpBackend = _$httpBackend_; const $element = angular.element(''); controller = $componentController('vnTicketSummary', {$element}); @@ -18,7 +18,6 @@ describe('Ticket', () => { it('should perform a GET query and define the summary property', () => { let res = {id: 1, nickname: 'Batman'}; $httpBackend.when('GET', `Tickets/1/summary`).respond(200, res); - $httpBackend.expect('GET', `Tickets/1/summary`); controller.ticket = {id: 1}; $httpBackend.flush(); diff --git a/modules/ticket/front/tracking/edit/index.js b/modules/ticket/front/tracking/edit/index.js index f2de08389..055a8ad67 100644 --- a/modules/ticket/front/tracking/edit/index.js +++ b/modules/ticket/front/tracking/edit/index.js @@ -56,13 +56,13 @@ class Controller extends Section { this.$http.post(`TicketTrackings/changeState`, this.params).then(() => { this.$.watcher.updateOriginalData(); this.card.reload(); - this.vnApp.showSuccess(this.$translate.instant('Data saved!')); + this.vnApp.showSuccess(this.$t('Data saved!')); this.$state.go('ticket.card.tracking.index'); }); } } -ngModule.component('vnTicketTrackingEdit', { +ngModule.vnComponent('vnTicketTrackingEdit', { template: require('./index.html'), controller: Controller, require: { diff --git a/modules/ticket/front/tracking/edit/index.spec.js b/modules/ticket/front/tracking/edit/index.spec.js index cf8036814..8fc21309b 100644 --- a/modules/ticket/front/tracking/edit/index.spec.js +++ b/modules/ticket/front/tracking/edit/index.spec.js @@ -7,7 +7,7 @@ describe('Ticket', () => { beforeEach(ngModule('ticket')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $translate, vnApp) => { + beforeEach(inject(($componentController, _$httpBackend_, $translate, vnApp) => { $httpBackend = _$httpBackend_; const $element = angular.element(''); controller = $componentController('vnTicketTrackingEdit', {$element}); @@ -67,7 +67,7 @@ describe('Ticket', () => { expect(controller.card.reload).toHaveBeenCalledWith(); expect(controller.$.watcher.updateOriginalData).toHaveBeenCalledWith(); - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith(controller.$translate.instant('Data saved!')); + expect(controller.vnApp.showSuccess).toHaveBeenCalledWith(controller.$t('Data saved!')); expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.tracking.index'); }); }); diff --git a/modules/ticket/front/tracking/index/index.js b/modules/ticket/front/tracking/index/index.js index 2826cbf26..5528fc1ad 100644 --- a/modules/ticket/front/tracking/index/index.js +++ b/modules/ticket/front/tracking/index/index.js @@ -28,7 +28,7 @@ class Controller extends Section { } } -ngModule.component('vnTicketTrackingIndex', { +ngModule.vnComponent('vnTicketTrackingIndex', { template: require('./index.html'), controller: Controller }); diff --git a/modules/ticket/front/volume/index.js b/modules/ticket/front/volume/index.js index 74ff61c85..ead46024b 100644 --- a/modules/ticket/front/volume/index.js +++ b/modules/ticket/front/volume/index.js @@ -45,7 +45,7 @@ class Controller extends Section { } } -ngModule.component('vnTicketVolume', { +ngModule.vnComponent('vnTicketVolume', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/ticket/front/volume/index.spec.js b/modules/ticket/front/volume/index.spec.js index f7cb5a58d..8ffb1dfc1 100644 --- a/modules/ticket/front/volume/index.spec.js +++ b/modules/ticket/front/volume/index.spec.js @@ -9,7 +9,7 @@ describe('ticket', () => { beforeEach(ngModule('ticket')); - beforeEach(angular.mock.inject(($componentController, _$state_, _$httpBackend_, $rootScope) => { + beforeEach(inject(($componentController, _$state_, _$httpBackend_, $rootScope) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); $scope.model = {data: [{id: 1}, {id: 2}], accept: () => { diff --git a/modules/ticket/front/weekly/index.html b/modules/ticket/front/weekly/index.html index 92ee64478..b51a7a887 100644 --- a/modules/ticket/front/weekly/index.html +++ b/modules/ticket/front/weekly/index.html @@ -18,13 +18,13 @@ + class="vn-w-xl"> Ticket ID - Client + Client Weekday Agency Warehouse @@ -53,7 +53,7 @@ - - {{::weekly.nickName}} + {{::weekly.userName}} diff --git a/modules/ticket/front/weekly/index.js b/modules/ticket/front/weekly/index.js index 0c373eae3..71365c4b3 100644 --- a/modules/ticket/front/weekly/index.js +++ b/modules/ticket/front/weekly/index.js @@ -32,7 +32,7 @@ export default class Controller extends Section { } } -ngModule.component('vnTicketWeeklyIndex', { +ngModule.vnComponent('vnTicketWeeklyIndex', { template: require('./index.html'), controller: Controller }); diff --git a/modules/ticket/front/weekly/index.spec.js b/modules/ticket/front/weekly/index.spec.js index a66e5c637..2af01db16 100644 --- a/modules/ticket/front/weekly/index.spec.js +++ b/modules/ticket/front/weekly/index.spec.js @@ -8,7 +8,7 @@ describe('ticket weekly', () => { beforeEach(ngModule('ticket')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope) => { + beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { $httpBackend = _$httpBackend_; const $scope = $rootScope.$new(); const $element = angular.element(''); @@ -23,7 +23,7 @@ describe('ticket weekly', () => { controller.onUpdate('ticketFk', 'field', 'value'); $httpBackend.flush(); - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); + expect(controller.vnApp.showSuccess).toHaveBeenCalled(); }); }); @@ -38,7 +38,7 @@ describe('ticket weekly', () => { controller.onDeleteWeeklyAccept('ticketFk'); $httpBackend.flush(); - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); + expect(controller.vnApp.showSuccess).toHaveBeenCalled(); expect(controller.$.model.remove).toHaveBeenCalledWith(0); }); }); diff --git a/modules/ticket/front/weekly/locale/es.yml b/modules/ticket/front/weekly/locale/es.yml index 7c7c6a139..804467dae 100644 --- a/modules/ticket/front/weekly/locale/es.yml +++ b/modules/ticket/front/weekly/locale/es.yml @@ -3,4 +3,5 @@ Weekly tickets: Tickets programados You are going to delete this weekly ticket: Vas a eliminar este ticket programado This ticket will be removed from weekly tickets! Continue anyway?: Este ticket se eliminará de tickets programados! ¿Continuar de todas formas? Search weekly ticket by id or client id: Busca tickets programados por el identificador o el identificador del cliente -Search by weekly ticket: Buscar por tickets programados \ No newline at end of file +Search by weekly ticket: Buscar por tickets programados +weekDay: Dia \ No newline at end of file diff --git a/modules/travel/back/methods/travel/filter.js b/modules/travel/back/methods/travel/filter.js index 4d1be2d0e..0cfafd7ba 100644 --- a/modules/travel/back/methods/travel/filter.js +++ b/modules/travel/back/methods/travel/filter.js @@ -135,7 +135,6 @@ module.exports = Self => { JOIN vn.warehouse wout ON wout.id = t.warehouseOutFk` ); - stmt.merge(conn.makeSuffix(filter)); let itemsIndex = stmts.push(stmt) - 1; diff --git a/modules/travel/front/basic-data/index.js b/modules/travel/front/basic-data/index.js index 139ef46e8..581fd71e5 100644 --- a/modules/travel/front/basic-data/index.js +++ b/modules/travel/front/basic-data/index.js @@ -9,7 +9,7 @@ class Controller extends Section { } } -ngModule.component('vnTravelBasicData', { +ngModule.vnComponent('vnTravelBasicData', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/travel/front/basic-data/index.spec.js b/modules/travel/front/basic-data/index.spec.js index aaad487ef..11894d6e0 100644 --- a/modules/travel/front/basic-data/index.spec.js +++ b/modules/travel/front/basic-data/index.spec.js @@ -7,7 +7,7 @@ describe('Travel Component vnTravelBasicData', () => { $translateProvider.translations('en', {}); })); - beforeEach(angular.mock.inject($componentController => { + beforeEach(inject($componentController => { const $element = angular.element(''); controller = $componentController('vnTravelBasicData', {$element}); controller.card = {reload: () => {}}; diff --git a/modules/travel/front/card/index.js b/modules/travel/front/card/index.js index c3ad41702..d46244cb5 100644 --- a/modules/travel/front/card/index.js +++ b/modules/travel/front/card/index.js @@ -24,7 +24,7 @@ class Controller extends ModuleCard { } } -ngModule.component('vnTravelCard', { +ngModule.vnComponent('vnTravelCard', { template: require('./index.html'), controller: Controller }); diff --git a/modules/travel/front/create/index.js b/modules/travel/front/create/index.js index 286d508de..7d0020034 100644 --- a/modules/travel/front/create/index.js +++ b/modules/travel/front/create/index.js @@ -14,7 +14,7 @@ class Controller extends Section { } } -ngModule.component('vnTravelCreate', { +ngModule.vnComponent('vnTravelCreate', { template: require('./index.html'), controller: Controller }); diff --git a/modules/travel/front/create/index.spec.js b/modules/travel/front/create/index.spec.js index e47f30bd3..4bde7747e 100644 --- a/modules/travel/front/create/index.spec.js +++ b/modules/travel/front/create/index.spec.js @@ -8,7 +8,7 @@ describe('Travel Component vnTravelCreate', () => { beforeEach(ngModule('travel')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$state_) => { + beforeEach(inject(($componentController, $rootScope, _$state_) => { $scope = $rootScope.$new(); $state = _$state_; $scope.watcher = watcher; diff --git a/modules/travel/front/index/index.js b/modules/travel/front/index/index.js index 1115af2c3..d1fd4f381 100644 --- a/modules/travel/front/index/index.js +++ b/modules/travel/front/index/index.js @@ -20,7 +20,7 @@ export default class Controller extends Section { } } -ngModule.component('vnTravelIndex', { +ngModule.vnComponent('vnTravelIndex', { template: require('./index.html'), controller: Controller }); diff --git a/modules/travel/front/index/index.spec.js b/modules/travel/front/index/index.spec.js index 4b018dea6..f88705cc7 100644 --- a/modules/travel/front/index/index.spec.js +++ b/modules/travel/front/index/index.spec.js @@ -11,7 +11,7 @@ describe('Travel Component vnTravelIndex', () => { beforeEach(ngModule('travel')); - beforeEach(angular.mock.inject($componentController => { + beforeEach(inject($componentController => { const $element = angular.element(''); controller = $componentController('vnTravelIndex', {$element}); controller.$.summary = {show: jasmine.createSpy('show')}; diff --git a/modules/travel/front/log/index.js b/modules/travel/front/log/index.js index 742488058..7af601b5c 100644 --- a/modules/travel/front/log/index.js +++ b/modules/travel/front/log/index.js @@ -1,7 +1,7 @@ import ngModule from '../module'; import Section from 'salix/components/section'; -ngModule.component('vnTravelLog', { +ngModule.vnComponent('vnTravelLog', { template: require('./index.html'), controller: Section, }); diff --git a/modules/travel/front/main/index.spec.js b/modules/travel/front/main/index.spec.js index 27dfa0392..96d819a6f 100644 --- a/modules/travel/front/main/index.spec.js +++ b/modules/travel/front/main/index.spec.js @@ -5,7 +5,7 @@ describe('Travel Component vnTravel', () => { beforeEach(ngModule('travel')); - beforeEach(angular.mock.inject($componentController => { + beforeEach(inject($componentController => { let $element = angular.element(`
`); controller = $componentController('vnTravel', {$element}); })); diff --git a/modules/travel/front/search-panel/index.js b/modules/travel/front/search-panel/index.js index d7b2a6eff..8aa25e594 100644 --- a/modules/travel/front/search-panel/index.js +++ b/modules/travel/front/search-panel/index.js @@ -1,7 +1,7 @@ import ngModule from '../module'; import SearchPanel from 'core/components/searchbar/search-panel'; -ngModule.component('vnTravelSearchPanel', { +ngModule.vnComponent('vnTravelSearchPanel', { template: require('./index.html'), controller: SearchPanel }); diff --git a/modules/travel/front/summary/index.js b/modules/travel/front/summary/index.js index 1f2d14e58..9107ea29f 100644 --- a/modules/travel/front/summary/index.js +++ b/modules/travel/front/summary/index.js @@ -58,7 +58,7 @@ class Controller extends Section { } } -ngModule.component('vnTravelSummary', { +ngModule.vnComponent('vnTravelSummary', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/travel/front/summary/index.spec.js b/modules/travel/front/summary/index.spec.js index 95f98bb85..b1b750689 100644 --- a/modules/travel/front/summary/index.spec.js +++ b/modules/travel/front/summary/index.spec.js @@ -10,7 +10,7 @@ describe('component vnTravelSummary', () => { $translateProvider.translations('en', {}); })); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { $httpBackend = _$httpBackend_; $httpParamSerializer = _$httpParamSerializer_; $scope = $rootScope.$new(); diff --git a/modules/travel/front/thermograph/create/index.js b/modules/travel/front/thermograph/create/index.js index d398febf1..4b4cebb9f 100644 --- a/modules/travel/front/thermograph/create/index.js +++ b/modules/travel/front/thermograph/create/index.js @@ -28,7 +28,7 @@ class Controller extends Section { } get contentTypesInfo() { - return this.$translate.instant('ContentTypesInfo', { + return this.$t('ContentTypesInfo', { allowedContentTypes: this.allowedContentTypes }); } @@ -46,7 +46,7 @@ class Controller extends Section { warehouseId: warehouseId, companyId: companyId, dmsTypeId: dmsTypeId, - description: this.$translate.instant('FileDescription', { + description: this.$t('FileDescription', { travelId: this.travel.id }).toUpperCase() }; @@ -97,14 +97,14 @@ class Controller extends Section { data: this.dms.files }; this.$http(options).then(res => { - this.vnApp.showSuccess(this.$translate.instant('Data saved!')); + this.vnApp.showSuccess(this.$t('Data saved!')); this.$.watcher.updateOriginalData(); this.$state.go('travel.card.thermograph.index'); }); } } -ngModule.component('vnTravelThermographCreate', { +ngModule.vnComponent('vnTravelThermographCreate', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/travel/front/thermograph/create/index.spec.js b/modules/travel/front/thermograph/create/index.spec.js index 23976fc96..36f17a409 100644 --- a/modules/travel/front/thermograph/create/index.spec.js +++ b/modules/travel/front/thermograph/create/index.spec.js @@ -10,7 +10,7 @@ describe('Ticket', () => { beforeEach(ngModule('travel')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => { + beforeEach(inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => { $httpBackend = _$httpBackend_; $httpParamSerializer = _$httpParamSerializer_; const $element = angular.element(''); @@ -40,8 +40,7 @@ describe('Ticket', () => { where: {code: 'miscellaneous'} }}; let serializedParams = $httpParamSerializer(params); - $httpBackend.when('GET', `DmsTypes/findOne?${serializedParams}`).respond({id: dmsTypeId, code: 'miscellaneous'}); - $httpBackend.expect('GET', `DmsTypes/findOne?${serializedParams}`); + $httpBackend.expect('GET', `DmsTypes/findOne?${serializedParams}`).respond({id: dmsTypeId, code: 'miscellaneous'}); controller.setDefaultParams(); $httpBackend.flush(); @@ -54,8 +53,7 @@ describe('Ticket', () => { describe('getAllowedContentTypes()', () => { it('should make an HTTP GET request to get the allowed content types', () => { const expectedResponse = ['application/pdf', 'image/png', 'image/jpg']; - $httpBackend.when('GET', `TravelThermographs/allowedContentTypes`).respond(expectedResponse); - $httpBackend.expect('GET', `TravelThermographs/allowedContentTypes`); + $httpBackend.expect('GET', `TravelThermographs/allowedContentTypes`).respond(expectedResponse); controller.getAllowedContentTypes(); $httpBackend.flush(); diff --git a/modules/travel/front/thermograph/edit/index.js b/modules/travel/front/thermograph/edit/index.js index 90e0cc7b1..daa0f696b 100644 --- a/modules/travel/front/thermograph/edit/index.js +++ b/modules/travel/front/thermograph/edit/index.js @@ -24,7 +24,7 @@ class Controller extends Section { } get contentTypesInfo() { - return this.$translate.instant('ContentTypesInfo', { + return this.$t('ContentTypesInfo', { allowedContentTypes: this.allowedContentTypes }); } @@ -71,7 +71,7 @@ class Controller extends Section { }; this.$http(options).then(res => { if (res) { - this.vnApp.showSuccess(this.$translate.instant('Data saved!')); + this.vnApp.showSuccess(this.$t('Data saved!')); this.$.watcher.updateOriginalData(); this.$state.go('travel.card.thermograph.index'); } @@ -89,7 +89,7 @@ class Controller extends Section { } } -ngModule.component('vnTravelThermographEdit', { +ngModule.vnComponent('vnTravelThermographEdit', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/travel/front/thermograph/edit/index.spec.js b/modules/travel/front/thermograph/edit/index.spec.js index 180827134..68ce763c2 100644 --- a/modules/travel/front/thermograph/edit/index.spec.js +++ b/modules/travel/front/thermograph/edit/index.spec.js @@ -10,7 +10,7 @@ describe('Worker', () => { beforeEach(ngModule('travel')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { $scope = $rootScope.$new(); $httpBackend = _$httpBackend_; $httpParamSerializer = _$httpParamSerializer_; @@ -79,8 +79,7 @@ describe('Worker', () => { describe('getAllowedContentTypes()', () => { it('should make an HTTP GET request to get the allowed content types', () => { const expectedResponse = ['image/png', 'image/jpg']; - $httpBackend.when('GET', `TravelThermographs/allowedContentTypes`).respond(expectedResponse); - $httpBackend.expect('GET', `TravelThermographs/allowedContentTypes`); + $httpBackend.expect('GET', `TravelThermographs/allowedContentTypes`).respond(expectedResponse); controller.getAllowedContentTypes(); $httpBackend.flush(); diff --git a/modules/travel/front/thermograph/index/index.js b/modules/travel/front/thermograph/index/index.js index 55c1720c3..f8b239cfe 100644 --- a/modules/travel/front/thermograph/index/index.js +++ b/modules/travel/front/thermograph/index/index.js @@ -26,7 +26,7 @@ class Controller extends Section { const thermographId = data[this.thermographIndex].id; const query = `Travels/deleteThermograph?id=${thermographId}`; this.$http.delete(query).then(() => { - this.vnApp.showSuccess(this.$translate.instant('Thermograph deleted')); + this.vnApp.showSuccess(this.$t('Thermograph deleted')); this.$.model.remove(this.thermographIndex); this.thermographIndex = null; }); @@ -39,7 +39,7 @@ class Controller extends Section { Controller.$inject = ['$element', '$scope', 'vnFile']; -ngModule.component('vnTravelThermographIndex', { +ngModule.vnComponent('vnTravelThermographIndex', { template: require('./index.html'), controller: Controller, require: { diff --git a/modules/worker/back/methods/worker-calendar/absences.js b/modules/worker/back/methods/calendar/absences.js similarity index 96% rename from modules/worker/back/methods/worker-calendar/absences.js rename to modules/worker/back/methods/calendar/absences.js index 7ea80509b..36d71ea81 100644 --- a/modules/worker/back/methods/worker-calendar/absences.js +++ b/modules/worker/back/methods/calendar/absences.js @@ -45,34 +45,6 @@ module.exports = Self => { const calendar = {totalHolidays: 0, holidaysEnjoyed: 0}; const holidays = []; - // Get absences of year - let absences = await Self.find({ - include: { - relation: 'absenceType' - }, - where: { - workerFk: workerFk, - dated: {between: [yearStarted, yearEnded]} - } - }); - - let entitlementRate = 0; - absences.forEach(absence => { - const absenceType = absence.absenceType(); - const isHoliday = absenceType.code === 'holiday'; - const isHalfHoliday = absenceType.code === 'halfHoliday'; - - if (isHoliday) - calendar.holidaysEnjoyed += 1; - if (isHalfHoliday) - calendar.holidaysEnjoyed += 0.5; - - entitlementRate += absenceType.holidayEntitlementRate; - - absence.dated = new Date(absence.dated); - absence.dated.setHours(0, 0, 0, 0); - }); - // Get active contracts on current year const year = yearStarted.getFullYear(); const contracts = await models.WorkerLabour.find({ @@ -112,6 +84,39 @@ module.exports = Self => { } }); + // Contracts ids + const contractsId = contracts.map(contract => { + return contract.businessFk; + }); + + // Get absences of year + let absences = await Self.find({ + include: { + relation: 'absenceType' + }, + where: { + businessFk: {inq: contractsId}, + dated: {between: [yearStarted, yearEnded]} + } + }); + + let entitlementRate = 0; + absences.forEach(absence => { + const absenceType = absence.absenceType(); + const isHoliday = absenceType.code === 'holiday'; + const isHalfHoliday = absenceType.code === 'halfHoliday'; + + if (isHoliday) + calendar.holidaysEnjoyed += 1; + if (isHalfHoliday) + calendar.holidaysEnjoyed += 0.5; + + entitlementRate += absenceType.holidayEntitlementRate; + + absence.dated = new Date(absence.dated); + absence.dated.setHours(0, 0, 0, 0); + }); + // Get number of worked days let workedDays = 0; contracts.forEach(contract => { diff --git a/modules/worker/back/methods/worker-calendar/specs/absences.spec.js b/modules/worker/back/methods/calendar/specs/absences.spec.js similarity index 95% rename from modules/worker/back/methods/worker-calendar/specs/absences.spec.js rename to modules/worker/back/methods/calendar/specs/absences.spec.js index eb5865a17..5cd27127b 100644 --- a/modules/worker/back/methods/worker-calendar/specs/absences.spec.js +++ b/modules/worker/back/methods/calendar/specs/absences.spec.js @@ -17,7 +17,7 @@ xdescribe('Worker absences()', () => { ended.setMonth(monthIndex + 1); ended.setDate(0); - let result = await app.models.WorkerCalendar.absences(ctx, workerFk, started, ended); + let result = await app.models.Calendar.absences(ctx, workerFk, started, ended); let calendar = result[0]; let absences = result[1]; @@ -54,7 +54,7 @@ xdescribe('Worker absences()', () => { ended.setMonth(monthIndex + 1); ended.setDate(0); - let result = await app.models.WorkerCalendar.absences(ctx, workerFk, started, ended); + let result = await app.models.Calendar.absences(ctx, workerFk, started, ended); let calendar = result[0]; let absences = result[1]; @@ -128,7 +128,7 @@ xdescribe('Worker absences()', () => { let ctx = {req: {accessToken: {userId: 106}}}; let workerFk = 106; - let result = await app.models.WorkerCalendar.absences(ctx, workerFk, yearStart, yearEnd); + let result = await app.models.Calendar.absences(ctx, workerFk, yearStart, yearEnd); let calendar = result[0]; let absences = result[1]; diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js new file mode 100644 index 000000000..3163e697d --- /dev/null +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -0,0 +1,58 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethodCtx('createAbsence', { + description: 'Creates a new worker absence', + accepts: [{ + arg: 'id', + type: 'Number', + description: 'The worker id', + http: {source: 'path'} + }, + { + arg: 'absenceTypeId', + type: 'Number', + required: true + }, + { + arg: 'dated', + type: 'Date', + required: false + }], + returns: { + type: 'Object', + root: true + }, + http: { + path: `/:id/createAbsence`, + verb: 'POST' + } + }); + + Self.createAbsence = async(ctx, id, absenceTypeId, dated) => { + const models = Self.app.models; + const userId = ctx.req.accessToken.userId; + const isSubordinate = await models.Worker.isSubordinate(ctx, id); + const isTeamBoss = await models.Account.hasRole(userId, 'teamBoss'); + + if (!isSubordinate || (isSubordinate && userId == id && !isTeamBoss)) + throw new UserError(`You don't have enough privileges`); + + const labour = await models.WorkerLabour.findOne({ + where: { + and: [ + {workerFk: id}, + {or: [{ + ended: {gte: [dated]} + }, {ended: null}]} + ] + } + }); + + return models.Calendar.create({ + businessFk: labour.businessFk, + dayOffTypeFk: absenceTypeId, + dated: dated + }); + }; +}; diff --git a/modules/worker/back/methods/worker/deleteAbsence.js b/modules/worker/back/methods/worker/deleteAbsence.js new file mode 100644 index 000000000..0fe8f7dc8 --- /dev/null +++ b/modules/worker/back/methods/worker/deleteAbsence.js @@ -0,0 +1,37 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethodCtx('deleteAbsence', { + description: 'Deletes a worker absence', + accepts: [{ + arg: 'id', + type: 'Number', + description: 'The worker id', + http: {source: 'path'} + }, + { + arg: 'absenceId', + type: 'Number', + required: true + }], + returns: 'Object', + http: { + path: `/:id/deleteAbsence`, + verb: 'DELETE' + } + }); + + Self.deleteAbsence = async(ctx, id, absenceId) => { + const models = Self.app.models; + const userId = ctx.req.accessToken.userId; + const isSubordinate = await models.Worker.isSubordinate(ctx, id); + const isTeamBoss = await models.Account.hasRole(userId, 'teamBoss'); + + if (!isSubordinate || (isSubordinate && userId == id && !isTeamBoss)) + throw new UserError(`You don't have enough privileges`); + + const absence = await models.Calendar.findById(absenceId); + + return absence.destroy(); + }; +}; diff --git a/modules/worker/back/methods/worker/specs/createAbsence.spec.js b/modules/worker/back/methods/worker/specs/createAbsence.spec.js new file mode 100644 index 000000000..df48cf80b --- /dev/null +++ b/modules/worker/back/methods/worker/specs/createAbsence.spec.js @@ -0,0 +1,39 @@ +const app = require('vn-loopback/server/server'); + +describe('Worker createAbsence()', () => { + const workerId = 106; + let createdAbsence; + + afterAll(async() => { + const absence = await app.models.Calendar.findById(createdAbsence.id); + await absence.destroy(); + }); + + it('should return an error for a user without enough privileges', async() => { + const ctx = {req: {accessToken: {userId: 106}}}; + const absenceTypeId = 1; + const dated = new Date(); + + let error; + await app.models.Worker.createAbsence(ctx, workerId, absenceTypeId, dated).catch(e => { + error = e; + }).finally(() => { + expect(error.message).toEqual(`You don't have enough privileges`); + }); + + expect(error).toBeDefined(); + }); + + it('should create a new absence', async() => { + const ctx = {req: {accessToken: {userId: 37}}}; + const absenceTypeId = 1; + const dated = new Date(); + createdAbsence = await app.models.Worker.createAbsence(ctx, workerId, absenceTypeId, dated); + + const expectedBusinessId = 106; + const expectedAbsenceTypeId = 1; + + expect(createdAbsence.businessFk).toEqual(expectedBusinessId); + expect(createdAbsence.dayOffTypeFk).toEqual(expectedAbsenceTypeId); + }); +}); diff --git a/modules/worker/back/methods/worker/specs/deleteAbsence.spec.js b/modules/worker/back/methods/worker/specs/deleteAbsence.spec.js new file mode 100644 index 000000000..140edada8 --- /dev/null +++ b/modules/worker/back/methods/worker/specs/deleteAbsence.spec.js @@ -0,0 +1,38 @@ +const app = require('vn-loopback/server/server'); + +describe('Worker deleteAbsence()', () => { + const workerId = 106; + let createdAbsence; + + it('should return an error for a user without enough privileges', async() => { + const ctx = {req: {accessToken: {userId: 106}}}; + const businessId = 106; + createdAbsence = await app.models.Calendar.create({ + businessFk: businessId, + dayOffTypeFk: 1, + dated: new Date() + }); + + let error; + await app.models.Worker.deleteAbsence(ctx, workerId, createdAbsence.id).catch(e => { + error = e; + }).finally(() => { + expect(error.message).toEqual(`You don't have enough privileges`); + }); + + expect(error).toBeDefined(); + }); + + it('should create a new absence', async() => { + const ctx = {req: {accessToken: {userId: 37}}}; + const businessId = 106; + + expect(createdAbsence.businessFk).toEqual(businessId); + + await app.models.Worker.deleteAbsence(ctx, workerId, createdAbsence.id); + + const deletedAbsence = await app.models.Calendar.findById(createdAbsence.id); + + expect(deletedAbsence).toBeNull(); + }); +}); diff --git a/modules/worker/back/methods/worker/specs/updateAbsence.spec.js b/modules/worker/back/methods/worker/specs/updateAbsence.spec.js new file mode 100644 index 000000000..1b34cf2e0 --- /dev/null +++ b/modules/worker/back/methods/worker/specs/updateAbsence.spec.js @@ -0,0 +1,38 @@ +const app = require('vn-loopback/server/server'); + +describe('Worker updateAbsence()', () => { + const workerId = 106; + let createdAbsence; + + afterAll(async() => { + const absence = await app.models.Calendar.findById(createdAbsence.id); + await absence.destroy(); + }); + + it('should return an error for a user without enough privileges', async() => { + const ctx = {req: {accessToken: {userId: 106}}}; + const expectedAbsenceTypeId = 2; + createdAbsence = await app.models.Calendar.create({ + businessFk: 106, + dayOffTypeFk: 1, + dated: new Date() + }); + + let error; + await app.models.Worker.updateAbsence(ctx, workerId, createdAbsence.id, expectedAbsenceTypeId).catch(e => { + error = e; + }).finally(() => { + expect(error.message).toEqual(`You don't have enough privileges`); + }); + + expect(error).toBeDefined(); + }); + + it('should create a new absence', async() => { + const ctx = {req: {accessToken: {userId: 37}}}; + const expectedAbsenceTypeId = 2; + const updatedAbsence = await app.models.Worker.updateAbsence(ctx, workerId, createdAbsence.id, expectedAbsenceTypeId); + + expect(updatedAbsence.dayOffTypeFk).toEqual(expectedAbsenceTypeId); + }); +}); diff --git a/modules/worker/back/methods/worker/updateAbsence.js b/modules/worker/back/methods/worker/updateAbsence.js new file mode 100644 index 000000000..7ed8992d3 --- /dev/null +++ b/modules/worker/back/methods/worker/updateAbsence.js @@ -0,0 +1,42 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethodCtx('updateAbsence', { + description: 'Updates a worker absence', + accepts: [{ + arg: 'id', + type: 'Number', + description: 'The worker id', + http: {source: 'path'} + }, + { + arg: 'absenceId', + type: 'Number', + required: true + }, + { + arg: 'absenceTypeId', + type: 'Number', + required: true + }], + returns: 'Object', + http: { + path: `/:id/updateAbsence`, + verb: 'PATCH' + } + }); + + Self.updateAbsence = async(ctx, id, absenceId, absenceTypeId) => { + const models = Self.app.models; + const userId = ctx.req.accessToken.userId; + const isSubordinate = await models.Worker.isSubordinate(ctx, id); + const isTeamBoss = await models.Account.hasRole(userId, 'teamBoss'); + + if (!isSubordinate || (isSubordinate && userId == id && !isTeamBoss)) + throw new UserError(`You don't have enough privileges`); + + const absence = await models.Calendar.findById(absenceId); + + return absence.updateAttribute('dayOffTypeFk', absenceTypeId); + }; +}; diff --git a/modules/worker/back/model-config.json b/modules/worker/back/model-config.json index e91e8b0fc..7a498fce7 100644 --- a/modules/worker/back/model-config.json +++ b/modules/worker/back/model-config.json @@ -2,9 +2,9 @@ "AbsenceType": { "dataSource": "vn" }, - "Department": { + "Calendar": { "dataSource": "vn" - }, + }, "CalendarHoliday": { "dataSource": "vn" }, @@ -14,6 +14,9 @@ "CalendarHolidaysType": { "dataSource": "vn" }, + "Department": { + "dataSource": "vn" + }, "WorkCenter": { "dataSource": "vn" }, @@ -44,9 +47,6 @@ "WorkerDepartment": { "dataSource": "vn" }, - "WorkerCalendar": { - "dataSource": "vn" - }, "WorkerTimeControl": { "dataSource": "vn" }, diff --git a/modules/worker/back/models/calendar.js b/modules/worker/back/models/calendar.js new file mode 100644 index 000000000..7b2f593e4 --- /dev/null +++ b/modules/worker/back/models/calendar.js @@ -0,0 +1,3 @@ +module.exports = Self => { + require('../methods/calendar/absences')(Self); +}; diff --git a/modules/worker/back/models/worker-calendar.json b/modules/worker/back/models/calendar.json similarity index 54% rename from modules/worker/back/models/worker-calendar.json rename to modules/worker/back/models/calendar.json index 569d4d1ba..417442571 100644 --- a/modules/worker/back/models/worker-calendar.json +++ b/modules/worker/back/models/calendar.json @@ -1,35 +1,28 @@ { - "name": "WorkerCalendar", + "name": "Calendar", "base": "VnModel", "options": { "mysql": { - "table": "workerCalendar" + "table": "calendar" } }, "properties": { - "businessFk": { - "id": 1, + "id": { + "id": true, "type": "Number" }, - "workerFk": { - "id": 2, + "businessFk": { "type": "Number" }, "dated": { - "id": 3, "type": "Date" } }, "relations": { - "worker": { - "type": "belongsTo", - "model": "Worker", - "foreignKey": "workerFk" - }, "absenceType": { "type": "belongsTo", "model": "AbsenceType", - "foreignKey": "absenceTypeFk" + "foreignKey": "dayOffTypeFk" } } } diff --git a/modules/worker/back/models/worker-calendar.js b/modules/worker/back/models/worker-calendar.js deleted file mode 100644 index ea603af41..000000000 --- a/modules/worker/back/models/worker-calendar.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = Self => { - require('../methods/worker-calendar/absences')(Self); -}; diff --git a/modules/worker/back/models/worker.js b/modules/worker/back/models/worker.js index 692c8c735..0d94c788e 100644 --- a/modules/worker/back/models/worker.js +++ b/modules/worker/back/models/worker.js @@ -4,4 +4,7 @@ module.exports = Self => { require('../methods/worker/isSubordinate')(Self); require('../methods/worker/getWorkedHours')(Self); require('../methods/worker/uploadFile')(Self); + require('../methods/worker/createAbsence')(Self); + require('../methods/worker/deleteAbsence')(Self); + require('../methods/worker/updateAbsence')(Self); }; diff --git a/modules/worker/front/basic-data/index.js b/modules/worker/front/basic-data/index.js index ebeb4716b..d2c7f5b70 100644 --- a/modules/worker/front/basic-data/index.js +++ b/modules/worker/front/basic-data/index.js @@ -8,7 +8,7 @@ class Controller extends Section { } } -ngModule.component('vnWorkerBasicData', { +ngModule.vnComponent('vnWorkerBasicData', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/worker/front/calendar/index.html b/modules/worker/front/calendar/index.html index 08b3f469c..197fb0797 100644 --- a/modules/worker/front/calendar/index.html +++ b/modules/worker/front/calendar/index.html @@ -5,15 +5,19 @@
- - + + + +
@@ -26,12 +30,19 @@
- + + {{absenceType.name}}
- \ No newline at end of file + + + diff --git a/modules/worker/front/calendar/index.js b/modules/worker/front/calendar/index.js index 6b849d19f..54cc94404 100644 --- a/modules/worker/front/calendar/index.js +++ b/modules/worker/front/calendar/index.js @@ -43,15 +43,17 @@ class Controller extends Section { set worker(value) { this._worker = value; - if (!value) return; - let params = { - workerFk: this.worker.id, - started: this.started, - ended: this.ended - }; - this.$http.get(`WorkerCalendars/absences`, {params}) - .then(res => this.onData(res.data)); + if (value) { + this.refresh().then(() => this.repaint()); + this.getIsSubordinate(); + } + } + + getIsSubordinate() { + this.$http.get(`Workers/${this.worker.id}/isSubordinate`).then(res => + this.isSubordinate = res.data + ); } onData(data) { @@ -79,12 +81,12 @@ class Controller extends Section { let type = absence.absenceType; addEvent(absence.dated, { name: type.name, - color: type.rgb + color: type.rgb, + type: type.code, + absenceId: absence.id }); }); } - - this.repaint(); } repaint() { @@ -102,9 +104,108 @@ class Controller extends Section { dayNumber.style.backgroundColor = event.color; dayNumber.style.color = 'rgba(0, 0, 0, 0.7)'; } + + pick(absenceType) { + if (!this.isSubordinate) return; + if (absenceType == this.absenceType) + absenceType = null; + + this.absenceType = absenceType; + } + + onSelection($event, $days) { + if (!this.absenceType) + return this.vnApp.showMessage(this.$t('Choose an absence type from the right menu')); + + const day = $days[0]; + const stamp = day.getTime(); + const event = this.events[stamp]; + const calendar = $event.target.closest('vn-calendar').$ctrl; + + if (event) { + if (event.type == this.absenceType.code) + this.delete(calendar, day, event); + else + this.edit(calendar, event); + } else + this.create(calendar, day); + } + + create(calendar, dated) { + const absenceType = this.absenceType; + const params = { + dated: dated, + absenceTypeId: absenceType.id + }; + + const path = `Workers/${this.$params.id}/createAbsence`; + this.$http.post(path, params).then(res => { + const newEvent = res.data; + this.events[dated.getTime()] = { + name: absenceType.name, + color: absenceType.rgb, + type: absenceType.code, + absenceId: newEvent.id + }; + + this.repaintCanceller(() => + this.refresh().then(calendar.repaint()) + ); + }); + } + + edit(calendar, event) { + const absenceType = this.absenceType; + const params = { + absenceId: event.absenceId, + absenceTypeId: absenceType.id + }; + const path = `Workers/${this.$params.id}/updateAbsence`; + this.$http.patch(path, params).then(() => { + event.color = absenceType.rgb; + event.name = absenceType.name; + event.type = absenceType.code; + + this.repaintCanceller(() => + this.refresh().then(calendar.repaint()) + ); + }); + } + + delete(calendar, day, event) { + const params = {absenceId: event.absenceId}; + const path = `Workers/${this.$params.id}/deleteAbsence`; + this.$http.delete(path, {params}).then(() => { + delete this.events[day.getTime()]; + + this.repaintCanceller(() => + this.refresh().then(calendar.repaint()) + ); + }); + } + + repaintCanceller(cb) { + if (this.canceller) { + clearTimeout(this.canceller); + this.canceller = null; + } + + this.canceller = setTimeout( + () => cb(), 500); + } + + refresh() { + const params = { + workerFk: this.worker.id, + started: this.started, + ended: this.ended + }; + return this.$http.get(`Calendars/absences`, {params}) + .then(res => this.onData(res.data)); + } } -ngModule.component('vnWorkerCalendar', { +ngModule.vnComponent('vnWorkerCalendar', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/worker/front/calendar/index.spec.js b/modules/worker/front/calendar/index.spec.js index da49b8f0f..97ea89787 100644 --- a/modules/worker/front/calendar/index.spec.js +++ b/modules/worker/front/calendar/index.spec.js @@ -3,17 +3,23 @@ import './index'; describe('Worker', () => { describe('Component vnWorkerCalendar', () => { let $httpBackend; + let $httpParamSerializer; let $scope; let controller; let year = new Date().getFullYear(); beforeEach(ngModule('worker')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { + beforeEach(inject(($componentController, $rootScope, _$httpParamSerializer_, _$httpBackend_) => { $scope = $rootScope.$new(); $httpBackend = _$httpBackend_; - const $element = angular.element(''); + $httpParamSerializer = _$httpParamSerializer_; + const $element = angular.element(''); controller = $componentController('vnWorkerCalendar', {$element, $scope}); + controller.isSubordinate = true; + controller.absenceType = {id: 1, name: 'Holiday', code: 'holiday', rgb: 'red'}; + controller.$params.id = 106; + controller._worker = {id: 106}; })); describe('started property', () => { @@ -44,15 +50,16 @@ describe('Worker', () => { describe('worker() setter', () => { it(`should perform a get query and set the reponse data on the model`, () => { - let today = new Date(); + jest.spyOn(controller, 'getIsSubordinate').mockReturnValue(true); + let today = new Date(); let tomorrow = new Date(today.getTime()); tomorrow.setDate(tomorrow.getDate() + 1); let yesterday = new Date(today.getTime()); yesterday.setDate(yesterday.getDate() - 1); - $httpBackend.whenRoute('GET', 'WorkerCalendars/absences') + $httpBackend.whenRoute('GET', 'Calendars/absences') .respond({ holidays: [ {dated: today, detail: {description: 'New year'}}, @@ -64,7 +71,7 @@ describe('Worker', () => { ] }); - controller.worker = {id: 1}; + controller.worker = {id: 107}; $httpBackend.flush(); let events = controller.events; @@ -73,14 +80,17 @@ describe('Worker', () => { expect(events[tomorrow.getTime()].name).toEqual('Easter'); expect(events[yesterday.getTime()].name).toEqual('Leave'); expect(events[yesterday.getTime()].color).toEqual('#bbb'); + expect(controller.getIsSubordinate).toHaveBeenCalledWith(); }); }); describe('formatDay()', () => { it(`should set the day element style`, () => { + jest.spyOn(controller, 'getIsSubordinate').mockReturnThis(); + let today = new Date(); - $httpBackend.whenRoute('GET', 'WorkerCalendars/absences') + $httpBackend.whenRoute('GET', 'Calendars/absences') .respond({ absences: [ {dated: today, absenceType: {name: 'Holiday', rgb: '#000'}} @@ -99,5 +109,219 @@ describe('Worker', () => { expect(dayNumber.style.backgroundColor).toEqual('rgb(0, 0, 0)'); }); }); + + describe('pick()', () => { + it(`should set the absenceType property to null if they match with the current one`, () => { + const absenceType = {id: 1, name: 'Holiday'}; + controller.absenceType = absenceType; + controller.pick(absenceType); + + expect(controller.absenceType).toBeNull(); + }); + + it(`should set the absenceType property`, () => { + const absenceType = {id: 1, name: 'Holiday'}; + const expectedAbsence = {id: 2, name: 'Leave of absence'}; + controller.absenceType = absenceType; + controller.pick(expectedAbsence); + + expect(controller.absenceType).toEqual(expectedAbsence); + }); + }); + + describe('onSelection()', () => { + it(`should show an snackbar message if no absence type is selected`, () => { + jest.spyOn(controller.vnApp, 'showMessage').mockReturnThis(); + + const $event = {}; + const $days = []; + controller.absenceType = null; + controller.onSelection($event, $days); + + expect(controller.vnApp.showMessage).toHaveBeenCalledWith('Choose an absence type from the right menu'); + }); + + it(`should call to the create() method`, () => { + jest.spyOn(controller, 'create').mockReturnThis(); + + const selectedDay = new Date(); + const $event = { + target: { + closest: () => { + return {$ctrl: {}}; + } + } + }; + const $days = [selectedDay]; + controller.absenceType = {id: 1}; + controller.onSelection($event, $days); + + expect(controller.create).toHaveBeenCalledWith(jasmine.any(Object), selectedDay); + }); + + it(`should call to the delete() method`, () => { + jest.spyOn(controller, 'delete').mockReturnThis(); + + const selectedDay = new Date(); + const expectedEvent = { + dated: selectedDay, + type: 'holiday' + }; + const $event = { + target: { + closest: () => { + return {$ctrl: {}}; + } + } + }; + const $days = [selectedDay]; + controller.events[selectedDay.getTime()] = expectedEvent; + controller.absenceType = {id: 1, code: 'holiday'}; + controller.onSelection($event, $days); + + expect(controller.delete).toHaveBeenCalledWith(jasmine.any(Object), selectedDay, expectedEvent); + }); + + it(`should call to the edit() method`, () => { + jest.spyOn(controller, 'edit').mockReturnThis(); + + const selectedDay = new Date(); + const expectedEvent = { + dated: selectedDay, + type: 'leaveOfAbsence' + }; + const $event = { + target: { + closest: () => { + return {$ctrl: {}}; + } + } + }; + const $days = [selectedDay]; + controller.events[selectedDay.getTime()] = expectedEvent; + controller.absenceType = {id: 1, code: 'holiday'}; + controller.onSelection($event, $days); + + expect(controller.edit).toHaveBeenCalledWith(jasmine.any(Object), expectedEvent); + }); + }); + + describe('create()', () => { + it(`should make a HTTP POST query and then call to the repaintCanceller() method`, () => { + jest.spyOn(controller, 'repaintCanceller').mockReturnThis(); + + const dated = new Date(); + const calendarElement = {}; + const expectedResponse = {id: 10}; + + $httpBackend.expect('POST', `Workers/106/createAbsence`).respond(200, expectedResponse); + controller.create(calendarElement, dated); + $httpBackend.flush(); + + const createdEvent = controller.events[dated.getTime()]; + const absenceType = controller.absenceType; + + expect(createdEvent.absenceId).toEqual(expectedResponse.id); + expect(createdEvent.color).toEqual(absenceType.rgb); + expect(controller.repaintCanceller).toHaveBeenCalled(); + }); + }); + + describe('edit()', () => { + it(`should make a HTTP PATCH query and then call to the repaintCanceller() method`, () => { + jest.spyOn(controller, 'repaintCanceller').mockReturnThis(); + + const event = {absenceId: 10}; + const calendarElement = {}; + const newAbsenceType = { + id: 2, + name: 'Leave of absence', + code: 'leaveOfAbsence', + rgb: 'purple' + }; + controller.absenceType = newAbsenceType; + + const expectedParams = {absenceId: 10, absenceTypeId: 2}; + $httpBackend.expect('PATCH', `Workers/106/updateAbsence`, expectedParams).respond(200); + controller.edit(calendarElement, event); + $httpBackend.flush(); + + expect(event.name).toEqual(newAbsenceType.name); + expect(event.color).toEqual(newAbsenceType.rgb); + expect(event.type).toEqual(newAbsenceType.code); + expect(controller.repaintCanceller).toHaveBeenCalled(); + }); + }); + + describe('delete()', () => { + it(`should make a HTTP DELETE query and then call to the repaintCanceller() method`, () => { + jest.spyOn(controller, 'repaintCanceller').mockReturnThis(); + + const expectedParams = {absenceId: 10}; + const calendarElement = {}; + const selectedDay = new Date(); + const expectedEvent = { + dated: selectedDay, + type: 'leaveOfAbsence', + absenceId: 10 + }; + + controller.events[selectedDay.getTime()] = expectedEvent; + + const serializedParams = $httpParamSerializer(expectedParams); + $httpBackend.expect('DELETE', `Workers/106/deleteAbsence?${serializedParams}`).respond(200); + controller.delete(calendarElement, selectedDay, expectedEvent); + $httpBackend.flush(); + + const event = controller.events[selectedDay.getTime()]; + + expect(event).toBeUndefined(); + expect(controller.repaintCanceller).toHaveBeenCalled(); + }); + }); + + describe('repaintCanceller()', () => { + it(`should cancell the callback execution timer`, () => { + jest.spyOn(window, 'clearTimeout'); + jest.spyOn(window, 'setTimeout'); + + const timeoutId = 90; + controller.canceller = timeoutId; + + controller.repaintCanceller(() => { + return 'My callback'; + }); + + expect(window.clearTimeout).toHaveBeenCalledWith(timeoutId); + expect(window.setTimeout).toHaveBeenCalledWith(jasmine.any(Function), 500); + }); + }); + + describe('refresh()', () => { + it(`should make a HTTP GET query and then call to the onData() method`, () => { + jest.spyOn(controller, 'onData').mockReturnThis(); + + const dated = controller.date; + const started = new Date(dated.getTime()); + started.setMonth(0); + started.setDate(1); + + const ended = new Date(dated.getTime()); + ended.setMonth(12); + ended.setDate(0); + + controller.started = started; + controller.ended = ended; + + const expecteResponse = [{id: 1}]; + const expectedParams = {workerFk: 106, started: started, ended: ended}; + const serializedParams = $httpParamSerializer(expectedParams); + $httpBackend.expect('GET', `Calendars/absences?${serializedParams}`).respond(200, expecteResponse); + controller.refresh(); + $httpBackend.flush(); + + expect(controller.onData).toHaveBeenCalledWith(expecteResponse); + }); + }); }); }); diff --git a/modules/worker/front/calendar/locale/es.yml b/modules/worker/front/calendar/locale/es.yml index 82939ce91..6681f730f 100644 --- a/modules/worker/front/calendar/locale/es.yml +++ b/modules/worker/front/calendar/locale/es.yml @@ -2,4 +2,6 @@ Calendar: Calendario Holidays: Vacaciones Used: Utilizados of: de -days: días \ No newline at end of file +days: días +Choose an absence type from the right menu: Elige un tipo de ausencia desde el menú de la derecha +To start adding absences, click an absence type from the right menu and then on the day you want to add an absence: Para empezar a añadir ausencias, haz clic en un tipo de ausencia desde el menu de la derecha y después en el día que quieres añadir la ausencia \ No newline at end of file diff --git a/modules/worker/front/calendar/style.scss b/modules/worker/front/calendar/style.scss index 9b3fc749b..1934a6ca0 100644 --- a/modules/worker/front/calendar/style.scss +++ b/modules/worker/front/calendar/style.scss @@ -2,6 +2,7 @@ vn-worker-calendar { .calendars { + position: relative; display: flex; flex-wrap: wrap; justify-content: center; @@ -16,4 +17,23 @@ vn-worker-calendar { max-width: 288px; } } + + vn-chip.selectable { + cursor: pointer + } + + vn-chip.selectable:hover { + opacity: 0.8 + } + + vn-chip vn-avatar { + text-align: center; + color: white + } + + vn-icon[icon="info"] { + position: absolute; + top: 16px; + right: 16px + } } diff --git a/modules/worker/front/card/index.js b/modules/worker/front/card/index.js index 14723947e..415b60787 100644 --- a/modules/worker/front/card/index.js +++ b/modules/worker/front/card/index.js @@ -37,7 +37,7 @@ class Controller extends ModuleCard { } } -ngModule.component('vnWorkerCard', { +ngModule.vnComponent('vnWorkerCard', { template: require('./index.html'), controller: Controller }); diff --git a/modules/worker/front/department/index.html b/modules/worker/front/department/index.html index 92102c7d3..df8630104 100644 --- a/modules/worker/front/department/index.html +++ b/modules/worker/front/department/index.html @@ -19,7 +19,7 @@ @@ -27,7 +27,7 @@ { - const item = res.data; - item.parent = parent; + const query = `departments/createChild`; + this.$http.post(query, params).then(res => { + const item = res.data; + item.parent = parent; - this.$.treeview.create(item); - }); - } catch (e) { - this.vnApp.showError(this.$translate.instant(e.message)); - return false; - } + this.$.treeview.create(item); + }); + } catch (e) { + this.vnApp.showError(this.$t(e.message)); + return false; } return true; } @@ -70,18 +68,16 @@ class Controller extends Section { this.$.deleteNode.show(); } - onRemoveResponse(response) { - if (response === 'accept') { - const childId = this.removedChild.id; - const path = `departments/${childId}/removeChild`; - this.$http.post(path).then(() => { - this.$.treeview.remove(this.removedChild); - }); - } + onRemoveResponse() { + const childId = this.removedChild.id; + const path = `departments/${childId}/removeChild`; + this.$http.post(path).then(() => { + this.$.treeview.remove(this.removedChild); + }); } } -ngModule.component('vnWorkerDepartment', { +ngModule.vnComponent('vnWorkerDepartment', { template: require('./index.html'), controller: Controller }); diff --git a/modules/worker/front/department/locale/es.yml b/modules/worker/front/department/locale/es.yml index c481bf4a9..74dec0c45 100644 --- a/modules/worker/front/department/locale/es.yml +++ b/modules/worker/front/department/locale/es.yml @@ -1,3 +1,4 @@ New department: Nuevo departamento Delete department: Eliminar departamento -Are you sure you want to delete it?: ¿Seguro que quieres eliminarlo? \ No newline at end of file +Are you sure you want to delete it?: ¿Seguro que quieres eliminarlo? +Name can't be empty: El nombre esta vacio \ No newline at end of file diff --git a/modules/worker/front/dms/create/index.js b/modules/worker/front/dms/create/index.js index 79d7c5fdd..f712edaf3 100644 --- a/modules/worker/front/dms/create/index.js +++ b/modules/worker/front/dms/create/index.js @@ -33,7 +33,7 @@ class Controller extends Section { } get contentTypesInfo() { - return this.$translate.instant('ContentTypesInfo', { + return this.$t('ContentTypesInfo', { allowedContentTypes: this.allowedContentTypes }); } @@ -51,7 +51,7 @@ class Controller extends Section { warehouseId: warehouseId, companyId: companyId, dmsTypeId: dmsType.id, - description: this.$translate.instant('WorkerFileDescription', { + description: this.$t('WorkerFileDescription', { dmsTypeName: dmsType.name, workerId: this.worker.id, workerName: this.worker.name @@ -83,7 +83,7 @@ class Controller extends Section { }; this.$http(options).then(res => { if (res) { - this.vnApp.showSuccess(this.$translate.instant('Data saved!')); + this.vnApp.showSuccess(this.$t('Data saved!')); this.$.watcher.updateOriginalData(); this.$state.go('worker.card.dms.index'); } @@ -104,7 +104,7 @@ class Controller extends Section { Controller.$inject = ['$element', '$scope']; -ngModule.component('vnWorkerDmsCreate', { +ngModule.vnComponent('vnWorkerDmsCreate', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/worker/front/dms/create/index.spec.js b/modules/worker/front/dms/create/index.spec.js index 6202032af..f0d088715 100644 --- a/modules/worker/front/dms/create/index.spec.js +++ b/modules/worker/front/dms/create/index.spec.js @@ -10,7 +10,7 @@ describe('Client', () => { beforeEach(ngModule('worker')); - beforeEach(angular.mock.inject(($compile, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { + beforeEach(inject(($compile, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { $scope = $rootScope.$new(); $httpBackend = _$httpBackend_; $httpParamSerializer = _$httpParamSerializer_; @@ -64,8 +64,7 @@ describe('Client', () => { describe('getAllowedContentTypes()', () => { it('should make an HTTP GET request to get the allowed content types', () => { const expectedResponse = ['image/png', 'image/jpg']; - $httpBackend.when('GET', `workerDms/allowedContentTypes`).respond(expectedResponse); - $httpBackend.expect('GET', `workerDms/allowedContentTypes`); + $httpBackend.expect('GET', `workerDms/allowedContentTypes`).respond(expectedResponse); controller.getAllowedContentTypes(); $httpBackend.flush(); diff --git a/modules/worker/front/dms/edit/index.js b/modules/worker/front/dms/edit/index.js index ac0104fa1..68c851ff3 100644 --- a/modules/worker/front/dms/edit/index.js +++ b/modules/worker/front/dms/edit/index.js @@ -24,7 +24,7 @@ class Controller extends Section { } get contentTypesInfo() { - return this.$translate.instant('ContentTypesInfo', { + return this.$t('ContentTypesInfo', { allowedContentTypes: this.allowedContentTypes }); } @@ -67,7 +67,7 @@ class Controller extends Section { }; this.$http(options).then(res => { if (res) { - this.vnApp.showSuccess(this.$translate.instant('Data saved!')); + this.vnApp.showSuccess(this.$t('Data saved!')); this.$.watcher.updateOriginalData(); this.$state.go('worker.card.dms.index'); } @@ -85,7 +85,7 @@ class Controller extends Section { } } -ngModule.component('vnWorkerDmsEdit', { +ngModule.vnComponent('vnWorkerDmsEdit', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/worker/front/dms/edit/index.spec.js b/modules/worker/front/dms/edit/index.spec.js index 7dfad9643..3724a6c7c 100644 --- a/modules/worker/front/dms/edit/index.spec.js +++ b/modules/worker/front/dms/edit/index.spec.js @@ -9,7 +9,7 @@ describe('Worker', () => { beforeEach(ngModule('worker')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { $scope = $rootScope.$new(); $httpBackend = _$httpBackend_; $element = angular.element(` { hasFileAttached: false }; - $httpBackend.when('GET', `Dms/${dmsId}`).respond(expectedResponse); $httpBackend.expect('GET', `Dms/${dmsId}`).respond(expectedResponse); controller.setDefaultParams(); $httpBackend.flush(); @@ -71,8 +70,7 @@ describe('Worker', () => { describe('getAllowedContentTypes()', () => { it('should make an HTTP GET request to get the allowed content types', () => { const expectedResponse = ['image/png', 'image/jpg']; - $httpBackend.when('GET', `WorkerDms/allowedContentTypes`).respond(expectedResponse); - $httpBackend.expect('GET', `WorkerDms/allowedContentTypes`); + $httpBackend.expect('GET', `WorkerDms/allowedContentTypes`).respond(expectedResponse); controller.getAllowedContentTypes(); $httpBackend.flush(); diff --git a/modules/worker/front/dms/index/index.js b/modules/worker/front/dms/index/index.js index d4514fdc1..e67240a73 100644 --- a/modules/worker/front/dms/index/index.js +++ b/modules/worker/front/dms/index/index.js @@ -60,7 +60,7 @@ class Controller extends Component { Controller.$inject = ['$element', '$scope', 'vnFile']; -ngModule.component('vnWorkerDmsIndex', { +ngModule.vnComponent('vnWorkerDmsIndex', { template: require('./index.html'), controller: Controller, }); diff --git a/modules/worker/front/index/index.html b/modules/worker/front/index/index.html index dfab7f16a..3d383ae04 100644 --- a/modules/worker/front/index/index.html +++ b/modules/worker/front/index/index.html @@ -46,5 +46,4 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/modules/worker/front/index/index.js b/modules/worker/front/index/index.js index 02632e095..77dd872e1 100644 --- a/modules/worker/front/index/index.js +++ b/modules/worker/front/index/index.js @@ -25,7 +25,7 @@ export default class Controller extends Section { } } -ngModule.component('vnWorkerIndex', { +ngModule.vnComponent('vnWorkerIndex', { template: require('./index.html'), controller: Controller }); diff --git a/modules/worker/front/log/index.js b/modules/worker/front/log/index.js index 325200aa9..ca64bed17 100644 --- a/modules/worker/front/log/index.js +++ b/modules/worker/front/log/index.js @@ -64,7 +64,7 @@ export default class Controller extends Section { } } -ngModule.component('vnLog', { +ngModule.vnComponent('vnLog', { controller: Controller, template: require('./index.html'), bindings: { diff --git a/modules/worker/front/pbx/index.js b/modules/worker/front/pbx/index.js index a62280d9b..d37f6f7d8 100644 --- a/modules/worker/front/pbx/index.js +++ b/modules/worker/front/pbx/index.js @@ -16,7 +16,7 @@ class Controller extends Section { } } -ngModule.component('vnWorkerPbx', { +ngModule.vnComponent('vnWorkerPbx', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/worker/front/search-panel/index.js b/modules/worker/front/search-panel/index.js index ef85c998b..ac7405e78 100644 --- a/modules/worker/front/search-panel/index.js +++ b/modules/worker/front/search-panel/index.js @@ -1,7 +1,7 @@ import ngModule from '../module'; import SearchPanel from 'core/components/searchbar/search-panel'; -ngModule.component('vnWorkerSearchPanel', { +ngModule.vnComponent('vnWorkerSearchPanel', { template: require('./index.html'), controller: SearchPanel }); diff --git a/modules/worker/front/summary/index.js b/modules/worker/front/summary/index.js index f6ee85a5b..adc248ee2 100644 --- a/modules/worker/front/summary/index.js +++ b/modules/worker/front/summary/index.js @@ -54,7 +54,7 @@ class Controller extends Section { } } -ngModule.component('vnWorkerSummary', { +ngModule.vnComponent('vnWorkerSummary', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/worker/front/time-control/index.html b/modules/worker/front/time-control/index.html index d2c91bf94..a333b8585 100644 --- a/modules/worker/front/time-control/index.html +++ b/modules/worker/front/time-control/index.html @@ -92,7 +92,7 @@ this.onData(res.data)); } @@ -233,8 +233,7 @@ class Controller extends Section { this.$.addTimeDialog.show(); } - addTime(response) { - if (response !== 'accept') return; + addTime() { let data = { workerFk: this.$params.id, timed: this.newTime @@ -260,7 +259,7 @@ class Controller extends Section { Controller.$inject = ['$element', '$scope', 'vnWeekDays']; -ngModule.component('vnWorkerTimeControl', { +ngModule.vnComponent('vnWorkerTimeControl', { template: require('./index.html'), controller: Controller }); diff --git a/modules/worker/front/time-control/index.spec.js b/modules/worker/front/time-control/index.spec.js index 519446864..4e9730d9c 100644 --- a/modules/worker/front/time-control/index.spec.js +++ b/modules/worker/front/time-control/index.spec.js @@ -8,7 +8,7 @@ describe('Component vnWorkerTimeControl', () => { beforeEach(ngModule('worker')); - beforeEach(angular.mock.inject(($componentController, $rootScope, $stateParams, _$httpBackend_) => { + beforeEach(inject(($componentController, $rootScope, $stateParams, _$httpBackend_) => { $stateParams.id = 1; $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); diff --git a/modules/worker/front/worker-log/index.js b/modules/worker/front/worker-log/index.js index 1f1a4f2f8..e30ce7e22 100644 --- a/modules/worker/front/worker-log/index.js +++ b/modules/worker/front/worker-log/index.js @@ -1,7 +1,7 @@ import ngModule from '../module'; import Section from 'salix/components/section'; -ngModule.component('vnWorkerLog', { +ngModule.vnComponent('vnWorkerLog', { template: require('./index.html'), controller: Section, }); diff --git a/modules/zone/back/model-config.json b/modules/zone/back/model-config.json index 7638e3f6c..f353be088 100644 --- a/modules/zone/back/model-config.json +++ b/modules/zone/back/model-config.json @@ -28,5 +28,8 @@ }, "ZoneWarehouse": { "dataSource": "vn" + }, + "ZoneEstimatedDelivery": { + "dataSource": "vn" } } diff --git a/modules/zone/back/models/zone-estimated-delivery.json b/modules/zone/back/models/zone-estimated-delivery.json new file mode 100644 index 000000000..d65cee3b5 --- /dev/null +++ b/modules/zone/back/models/zone-estimated-delivery.json @@ -0,0 +1,44 @@ +{ + "name": "ZoneEstimatedDelivery", + "base": "VnModel", + "options": { + "mysql": { + "table": "zoneEstimatedDelivery" + } + }, + "properties": { + "zoneFk": { + "id": true, + "type": "Number" + }, + "hourTheoretical": { + "type": "date" + }, + "totalVolume": { + "type": "Number" + }, + "remainingVolume": { + "type": "Number" + }, + "speed": { + "type": "Number" + }, + "hourEffective": { + "type": "Date" + }, + "minutesLess": { + "type": "Date" + }, + "etc": { + "type": "Date" + } + + }, + "relations": { + "zone": { + "type": "belongsTo", + "model": "Zone", + "foreignKey": "zoneFk" + } + } +} \ No newline at end of file diff --git a/modules/zone/back/models/zone-warehouse.json b/modules/zone/back/models/zone-warehouse.json index afb3bc2b4..14c4e84a4 100644 --- a/modules/zone/back/models/zone-warehouse.json +++ b/modules/zone/back/models/zone-warehouse.json @@ -10,6 +10,10 @@ "id": { "id": true, "type": "Number" + }, + "warehouseFk": { + "type": "Number", + "required": true } }, "relations": { diff --git a/modules/zone/front/basic-data/index.js b/modules/zone/front/basic-data/index.js index 40e5b49dc..402b471fc 100644 --- a/modules/zone/front/basic-data/index.js +++ b/modules/zone/front/basic-data/index.js @@ -9,7 +9,7 @@ class Controller extends Section { } } -ngModule.component('vnZoneBasicData', { +ngModule.vnComponent('vnZoneBasicData', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/zone/front/calendar/index.js b/modules/zone/front/calendar/index.js index e9265621e..00b6176c7 100644 --- a/modules/zone/front/calendar/index.js +++ b/modules/zone/front/calendar/index.js @@ -163,7 +163,7 @@ class Controller extends Component { } Controller.$inject = ['$element', '$scope', 'vnWeekDays']; -ngModule.component('vnZoneCalendar', { +ngModule.vnComponent('vnZoneCalendar', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/zone/front/calendar/index.spec.js b/modules/zone/front/calendar/index.spec.js index 00645b317..82d7a4471 100644 --- a/modules/zone/front/calendar/index.spec.js +++ b/modules/zone/front/calendar/index.spec.js @@ -8,7 +8,7 @@ describe('component vnZoneCalendar', () => { beforeEach(ngModule('zone')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); const $element = angular.element(``); diff --git a/modules/zone/front/card/index.spec.js b/modules/zone/front/card/index.spec.js index 9d0911de2..64127990f 100644 --- a/modules/zone/front/card/index.spec.js +++ b/modules/zone/front/card/index.spec.js @@ -7,7 +7,7 @@ describe('Zone Component vnZoneCard', () => { beforeEach(ngModule('zone')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $stateParams) => { + beforeEach(inject(($componentController, _$httpBackend_, $stateParams) => { $httpBackend = _$httpBackend_; let $element = angular.element('
'); diff --git a/modules/zone/front/create/index.js b/modules/zone/front/create/index.js index c0bce4f08..859204d8d 100644 --- a/modules/zone/front/create/index.js +++ b/modules/zone/front/create/index.js @@ -18,7 +18,7 @@ export default class Controller extends Section { } } -ngModule.component('vnZoneCreate', { +ngModule.vnComponent('vnZoneCreate', { template: require('./index.html'), controller: Controller }); diff --git a/modules/zone/front/create/index.spec.js b/modules/zone/front/create/index.spec.js index 79fe00ed8..fe0088225 100644 --- a/modules/zone/front/create/index.spec.js +++ b/modules/zone/front/create/index.spec.js @@ -8,7 +8,7 @@ describe('Zone Component vnZoneCreate', () => { beforeEach(ngModule('zone')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$state_) => { + beforeEach(inject(($componentController, $rootScope, _$state_) => { $scope = $rootScope.$new(); $state = _$state_; $scope.watcher = watcher; diff --git a/modules/zone/front/delivery-days/index.js b/modules/zone/front/delivery-days/index.js index eb6d7795d..408c77be2 100644 --- a/modules/zone/front/delivery-days/index.js +++ b/modules/zone/front/delivery-days/index.js @@ -67,7 +67,7 @@ class Controller extends Section { } } -ngModule.component('vnZoneDeliveryDays', { +ngModule.vnComponent('vnZoneDeliveryDays', { template: require('./index.html'), controller: Controller }); diff --git a/modules/zone/front/delivery-days/index.spec.js b/modules/zone/front/delivery-days/index.spec.js index db99add2c..c39b34296 100644 --- a/modules/zone/front/delivery-days/index.spec.js +++ b/modules/zone/front/delivery-days/index.spec.js @@ -9,7 +9,7 @@ describe('Zone Component vnZoneDeliveryDays', () => { beforeEach(ngModule('zone')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => { + beforeEach(inject(($componentController, _$httpBackend_) => { $httpBackend = _$httpBackend_; $element = angular.element(' + + + \ No newline at end of file diff --git a/modules/zone/front/descriptor-popover/index.js b/modules/zone/front/descriptor-popover/index.js new file mode 100644 index 000000000..a21232e41 --- /dev/null +++ b/modules/zone/front/descriptor-popover/index.js @@ -0,0 +1,9 @@ +import ngModule from '../module'; +import DescriptorPopover from 'salix/components/descriptor-popover'; + +class Controller extends DescriptorPopover {} + +ngModule.vnComponent('vnZoneDescriptorPopover', { + slotTemplate: require('./index.html'), + controller: Controller +}); diff --git a/modules/zone/front/descriptor/index.html b/modules/zone/front/descriptor/index.html index d4d3eca7b..355028c98 100644 --- a/modules/zone/front/descriptor/index.html +++ b/modules/zone/front/descriptor/index.html @@ -16,10 +16,6 @@
- - diff --git a/modules/zone/front/descriptor/index.js b/modules/zone/front/descriptor/index.js index 5e365e0ac..08ada0606 100644 --- a/modules/zone/front/descriptor/index.js +++ b/modules/zone/front/descriptor/index.js @@ -10,6 +10,22 @@ class Controller extends Descriptor { this.entity = value; } + loadData() { + const filter = { + include: [ + { + relation: 'agencyMode', + scope: { + fields: ['name'], + } + } + ] + }; + + return this.getData(`Zones/${this.id}`, {filter}) + .then(res => this.entity = res.data); + } + onDelete() { const $t = this.$translate.instant; const today = new Date(); diff --git a/modules/zone/front/descriptor/index.spec.js b/modules/zone/front/descriptor/index.spec.js index 23c6e3a3a..435a1d00f 100644 --- a/modules/zone/front/descriptor/index.spec.js +++ b/modules/zone/front/descriptor/index.spec.js @@ -7,7 +7,7 @@ describe('Zone descriptor', () => { beforeEach(ngModule('zone')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => { + beforeEach(inject(($componentController, _$httpBackend_) => { $httpBackend = _$httpBackend_; $element = angular.element(' { beforeEach(ngModule('zone')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); const $element = angular.element(``); diff --git a/modules/zone/front/index.js b/modules/zone/front/index.js index 76a6fdd9b..26c491709 100644 --- a/modules/zone/front/index.js +++ b/modules/zone/front/index.js @@ -6,6 +6,7 @@ import './delivery-days'; import './summary'; import './card'; import './descriptor'; +import './descriptor-popover'; import './search-panel'; import './create'; import './basic-data'; diff --git a/modules/zone/front/index/index.js b/modules/zone/front/index/index.js index b39c6139a..ad54f7df4 100644 --- a/modules/zone/front/index/index.js +++ b/modules/zone/front/index/index.js @@ -15,7 +15,7 @@ export default class Controller extends Section { } } -ngModule.component('vnZoneIndex', { +ngModule.vnComponent('vnZoneIndex', { template: require('./index.html'), controller: Controller }); diff --git a/modules/zone/front/location/index.js b/modules/zone/front/location/index.js index c30ded3ad..e1490c528 100644 --- a/modules/zone/front/location/index.js +++ b/modules/zone/front/location/index.js @@ -48,7 +48,7 @@ class Controller extends Section { } } -ngModule.component('vnZoneLocation', { +ngModule.vnComponent('vnZoneLocation', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/zone/front/location/index.spec.js b/modules/zone/front/location/index.spec.js index 6f2b139c0..30968209c 100644 --- a/modules/zone/front/location/index.spec.js +++ b/modules/zone/front/location/index.spec.js @@ -8,7 +8,7 @@ describe('component vnZoneLocation', () => { beforeEach(ngModule('zone')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); const $element = angular.element(``); diff --git a/modules/zone/front/main/index.spec.js b/modules/zone/front/main/index.spec.js index 24b63a959..1e50cee80 100644 --- a/modules/zone/front/main/index.spec.js +++ b/modules/zone/front/main/index.spec.js @@ -5,7 +5,7 @@ describe('Zone Component vnZone', () => { beforeEach(ngModule('zone')); - beforeEach(angular.mock.inject($componentController => { + beforeEach(inject($componentController => { const $element = angular.element(''); controller = $componentController('vnZone', {$element}); })); diff --git a/modules/zone/front/search-panel/index.js b/modules/zone/front/search-panel/index.js index c01ac35e5..598af02b2 100644 --- a/modules/zone/front/search-panel/index.js +++ b/modules/zone/front/search-panel/index.js @@ -1,7 +1,7 @@ import ngModule from '../module'; import SearchPanel from 'core/components/searchbar/search-panel'; -ngModule.component('vnZoneSearchPanel', { +ngModule.vnComponent('vnZoneSearchPanel', { template: require('./index.html'), controller: SearchPanel }); diff --git a/modules/zone/front/summary/index.js b/modules/zone/front/summary/index.js index 47a6ba32a..6edb47a39 100644 --- a/modules/zone/front/summary/index.js +++ b/modules/zone/front/summary/index.js @@ -47,7 +47,7 @@ class Controller extends Section { } } -ngModule.component('vnZoneSummary', { +ngModule.vnComponent('vnZoneSummary', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/zone/front/summary/index.spec.js b/modules/zone/front/summary/index.spec.js index 49d6614ff..7541ee795 100644 --- a/modules/zone/front/summary/index.spec.js +++ b/modules/zone/front/summary/index.spec.js @@ -8,7 +8,7 @@ describe('component vnZoneSummary', () => { beforeEach(ngModule('zone')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { $httpBackend = _$httpBackend_; $httpParamSerializer = _$httpParamSerializer_; $scope = $rootScope.$new(); diff --git a/modules/zone/front/upcoming-deliveries/index.js b/modules/zone/front/upcoming-deliveries/index.js index e8e6909ae..371321711 100644 --- a/modules/zone/front/upcoming-deliveries/index.js +++ b/modules/zone/front/upcoming-deliveries/index.js @@ -17,7 +17,7 @@ class Controller extends Section { Controller.$inject = ['$element', '$scope', 'vnWeekDays']; -ngModule.component('vnUpcomingDeliveries', { +ngModule.vnComponent('vnUpcomingDeliveries', { template: require('./index.html'), controller: Controller }); diff --git a/modules/zone/front/upcoming-deliveries/index.spec.js b/modules/zone/front/upcoming-deliveries/index.spec.js index a92056102..95eb999f9 100644 --- a/modules/zone/front/upcoming-deliveries/index.spec.js +++ b/modules/zone/front/upcoming-deliveries/index.spec.js @@ -6,7 +6,7 @@ describe('component vnUpcomingDeliveries', () => { beforeEach(ngModule('zone')); - beforeEach(angular.mock.inject(($componentController, $rootScope) => { + beforeEach(inject(($componentController, $rootScope) => { $scope = $rootScope.$new(); const $element = angular.element(``); controller = $componentController('vnUpcomingDeliveries', {$element, $scope}); diff --git a/modules/zone/front/warehouses/index.html b/modules/zone/front/warehouses/index.html index 835880c75..c22890958 100644 --- a/modules/zone/front/warehouses/index.html +++ b/modules/zone/front/warehouses/index.html @@ -28,7 +28,7 @@ + on-accept="$ctrl.onSave()"> { this.selected = null; @@ -52,7 +50,7 @@ class Controller extends Section { } } -ngModule.component('vnZoneWarehouses', { +ngModule.vnComponent('vnZoneWarehouses', { template: require('./index.html'), controller: Controller }); diff --git a/modules/zone/front/warehouses/index.spec.js b/modules/zone/front/warehouses/index.spec.js index aa9cef2e1..0e71d541c 100644 --- a/modules/zone/front/warehouses/index.spec.js +++ b/modules/zone/front/warehouses/index.spec.js @@ -8,7 +8,7 @@ describe('Zone warehouses', () => { beforeEach(ngModule('zone')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => { + beforeEach(inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => { $httpBackend = _$httpBackend_; $httpParamSerializer = _$httpParamSerializer_; $element = angular.element(' { jest.spyOn(controller, 'refresh').mockReturnThis(); $httpBackend.expect('POST', `Zones/1/warehouses`).respond(200); - controller.onSave('accept'); + controller.onSave(); $httpBackend.flush(); expect(controller.selected).toBeNull(); diff --git a/package-lock.json b/package-lock.json index 5e4ac6c46..92030199a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4690,8 +4690,7 @@ "ansi-regex": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=" }, "ansi-styles": { "version": "3.2.1", @@ -4741,8 +4740,7 @@ "aproba": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", - "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", - "dev": true + "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==" }, "archy": { "version": "1.0.0", @@ -4754,7 +4752,6 @@ "version": "1.1.5", "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==", - "dev": true, "requires": { "delegates": "^1.0.0", "readable-stream": "^2.0.6" @@ -6610,8 +6607,7 @@ "chownr": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.3.tgz", - "integrity": "sha512-i70fVHhmV3DtTl6nqvZOnIjbY0Pe4kAUjwHj8z0zAdgBtYrJyYwLKCCuRBQ5ppkyL0AkN7HKRnETdmdp1zqNXw==", - "dev": true + "integrity": "sha512-i70fVHhmV3DtTl6nqvZOnIjbY0Pe4kAUjwHj8z0zAdgBtYrJyYwLKCCuRBQ5ppkyL0AkN7HKRnETdmdp1zqNXw==" }, "chrome-trace-event": { "version": "1.0.2", @@ -6820,8 +6816,7 @@ "code-point-at": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" }, "collect-v8-coverage": { "version": "1.0.1", @@ -6850,11 +6845,19 @@ "object-visit": "^1.0.0" } }, + "color": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/color/-/color-3.1.2.tgz", + "integrity": "sha512-vXTJhHebByxZn3lDvDJYw4lR5+uB3vuoHsuYA5AKuxRVn5wzzIfQKGLBmgdVRHKTJYeK5rvJcHnrd0Li49CFpg==", + "requires": { + "color-convert": "^1.9.1", + "color-string": "^1.5.2" + } + }, "color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, "requires": { "color-name": "1.1.3" } @@ -6862,8 +6865,16 @@ "color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "color-string": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.5.3.tgz", + "integrity": "sha512-dC2C5qeWoYkxki5UAXapdjqO672AM4vZuPGRQfO8b5HKuKGBbKWpITyDYN7TOFKvRW7kOgAn3746clDBMDJyQw==", + "requires": { + "color-name": "^1.0.0", + "simple-swizzle": "^0.2.2" + } }, "color-support": { "version": "1.1.3", @@ -7011,8 +7022,7 @@ "console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", - "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" }, "consolidate": { "version": "0.15.1", @@ -7563,8 +7573,7 @@ "delegates": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", - "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", - "dev": true + "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" }, "denque": { "version": "1.4.1", @@ -7604,6 +7613,11 @@ "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=", "dev": true }, + "detect-libc": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", + "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=" + }, "detect-newline": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", @@ -8369,6 +8383,11 @@ } } }, + "expand-template": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", + "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==" + }, "expand-tilde": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", @@ -9150,6 +9169,11 @@ "readable-stream": "^2.0.0" } }, + "fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, "fs-extra": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-5.0.0.tgz", @@ -9160,6 +9184,14 @@ "universalify": "^0.1.0" } }, + "fs-minipass": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", + "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", + "requires": { + "minipass": "^3.0.0" + } + }, "fs-mkdirp-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-mkdirp-stream/-/fs-mkdirp-stream-1.0.0.tgz", @@ -9798,7 +9830,6 @@ "version": "2.7.4", "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", - "dev": true, "requires": { "aproba": "^1.0.3", "console-control-strings": "^1.0.0", @@ -9813,14 +9844,12 @@ "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" }, "is-fullwidth-code-point": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "dev": true, "requires": { "number-is-nan": "^1.0.0" } @@ -9829,7 +9858,6 @@ "version": "1.0.2", "resolved": "http://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "dev": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -9840,7 +9868,6 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, "requires": { "ansi-regex": "^2.0.0" } @@ -9948,6 +9975,11 @@ "assert-plus": "^1.0.0" } }, + "github-from-package": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", + "integrity": "sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4=" + }, "glob": { "version": "7.1.6", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", @@ -11293,8 +11325,7 @@ "has-unicode": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", - "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", - "dev": true + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" }, "has-value": { "version": "1.0.0", @@ -11897,8 +11928,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", - "dev": true + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" }, "inquirer": { "version": "6.4.1", @@ -12137,8 +12167,7 @@ "is-fullwidth-code-point": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" }, "is-generator-fn": { "version": "2.1.0", @@ -18662,6 +18691,37 @@ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" }, + "minipass": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.3.tgz", + "integrity": "sha512-Mgd2GdMVzY+x3IJ+oHnVM+KG3lA5c8tnabyJKmHSaG2kAGpudxuOf8ToDkhumF7UzME7DecbQE9uOZhNm7PuJg==", + "requires": { + "yallist": "^4.0.0" + }, + "dependencies": { + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + } + } + }, + "minizlib": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.0.tgz", + "integrity": "sha512-EzTZN/fjSvifSX0SlqUERCN39o6T40AMarPbv0MrarSFtIITCBh7bi+dU8nxGFHuqs9jdIAeoYoKuQAAASsPPA==", + "requires": { + "minipass": "^3.0.0", + "yallist": "^4.0.0" + }, + "dependencies": { + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + } + } + }, "mississippi": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/mississippi/-/mississippi-3.0.0.tgz", @@ -18739,6 +18799,11 @@ "minimist": "^1.2.5" } }, + "mkdirp-classic": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" + }, "mktmpdir": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/mktmpdir/-/mktmpdir-0.1.1.tgz", @@ -19079,6 +19144,11 @@ "to-regex": "^3.0.1" } }, + "napi-build-utils": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", + "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==" + }, "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -19121,6 +19191,19 @@ "resolved": "https://registry.npmjs.org/nocache/-/nocache-2.1.0.tgz", "integrity": "sha512-0L9FvHG3nfnnmaEQPjT9xhfN4ISk0A8/2j4M37Np4mcDesJjHgEUfgPhdCyZuFI954tjokaIj/A3NdpFNdEh4Q==" }, + "node-abi": { + "version": "2.18.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.18.0.tgz", + "integrity": "sha512-yi05ZoiuNNEbyT/xXfSySZE+yVnQW6fxPZuFbLyS1s6b5Kw3HzV2PHOM4XR+nsjzkHxByK+2Wg+yCQbe35l8dw==", + "requires": { + "semver": "^5.4.1" + } + }, + "node-addon-api": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.0.0.tgz", + "integrity": "sha512-sSHCgWfJ+Lui/u+0msF3oyCgvdkhxDbkCS6Q8uiJquzOimkJBvX6hl5aSSA7DR1XbMpdM8r7phjcF63sF4rkKg==" + }, "node-fetch": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", @@ -19507,6 +19590,11 @@ } } }, + "noop-logger": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/noop-logger/-/noop-logger-0.1.1.tgz", + "integrity": "sha1-lKKxYzxPExdVMAfYlm/Q6EG2pMI=" + }, "nopt": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", @@ -19561,7 +19649,6 @@ "version": "4.1.2", "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", - "dev": true, "requires": { "are-we-there-yet": "~1.1.2", "console-control-strings": "~1.1.0", @@ -19581,8 +19668,7 @@ "number-is-nan": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" }, "nwsapi": { "version": "2.2.0", @@ -19598,8 +19684,7 @@ "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" }, "object-copy": { "version": "0.1.0", @@ -20381,6 +20466,53 @@ "integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==", "dev": true }, + "prebuild-install": { + "version": "5.3.5", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-5.3.5.tgz", + "integrity": "sha512-YmMO7dph9CYKi5IR/BzjOJlRzpxGGVo1EsLSUZ0mt/Mq0HWZIHOKHHcHdT69yG54C9m6i45GpItwRHpk0Py7Uw==", + "requires": { + "detect-libc": "^1.0.3", + "expand-template": "^2.0.3", + "github-from-package": "0.0.0", + "minimist": "^1.2.3", + "mkdirp": "^0.5.1", + "napi-build-utils": "^1.0.1", + "node-abi": "^2.7.0", + "noop-logger": "^0.1.1", + "npmlog": "^4.0.1", + "pump": "^3.0.0", + "rc": "^1.2.7", + "simple-get": "^3.0.3", + "tar-fs": "^2.0.0", + "tunnel-agent": "^0.6.0", + "which-pm-runs": "^1.0.0" + }, + "dependencies": { + "decompress-response": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-4.2.1.tgz", + "integrity": "sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw==", + "requires": { + "mimic-response": "^2.0.0" + } + }, + "mimic-response": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.1.0.tgz", + "integrity": "sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA==" + }, + "simple-get": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.0.tgz", + "integrity": "sha512-bCR6cP+aTdScaQCnQKbPKtJOKDp/hj9EDLJo3Nw4y1QksqaovlW/bnptB6/c1e+qmNIDHRK+oXFDdEqBT8WzUA==", + "requires": { + "decompress-response": "^4.2.0", + "once": "^1.3.1", + "simple-concat": "^1.0.0" + } + } + } + }, "prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", @@ -20729,7 +20861,6 @@ "version": "1.2.8", "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", - "dev": true, "requires": { "deep-extend": "^0.6.0", "ini": "~1.3.0", @@ -20740,8 +20871,7 @@ "deep-extend": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", - "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", - "dev": true + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==" } } }, @@ -21723,8 +21853,7 @@ "set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", - "dev": true + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" }, "set-value": { "version": "2.0.1", @@ -21779,6 +21908,57 @@ "kind-of": "^6.0.2" } }, + "sharp": { + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.25.4.tgz", + "integrity": "sha512-umSzJJ1oBwIOfwFFt/fJ7JgCva9FvrEU2cbbm7u/3hSDZhXvkME8WE5qpaJqLIe2Har5msF5UG4CzYlEg5o3BQ==", + "requires": { + "color": "^3.1.2", + "detect-libc": "^1.0.3", + "node-addon-api": "^3.0.0", + "npmlog": "^4.1.2", + "prebuild-install": "^5.3.4", + "semver": "^7.3.2", + "simple-get": "^4.0.0", + "tar": "^6.0.2", + "tunnel-agent": "^0.6.0" + }, + "dependencies": { + "chownr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", + "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==" + }, + "mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==" + }, + "semver": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", + "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==" + }, + "tar": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.0.2.tgz", + "integrity": "sha512-Glo3jkRtPcvpDlAs/0+hozav78yoXKFr+c4wgw62NNMO3oo4AaJdCo21Uu7lcwr55h39W2XD1LMERc64wtbItg==", + "requires": { + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "minipass": "^3.0.0", + "minizlib": "^2.1.0", + "mkdirp": "^1.0.3", + "yallist": "^4.0.0" + } + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + } + } + }, "shebang-command": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", @@ -21822,6 +22002,51 @@ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" }, + "simple-concat": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz", + "integrity": "sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY=" + }, + "simple-get": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.0.tgz", + "integrity": "sha512-ZalZGexYr3TA0SwySsr5HlgOOinS4Jsa8YB2GJ6lUNAazyAu4KG/VmzMTwAt2YVXzzVj8QmefmAonZIK2BSGcQ==", + "requires": { + "decompress-response": "^6.0.0", + "once": "^1.3.1", + "simple-concat": "^1.0.0" + }, + "dependencies": { + "decompress-response": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "requires": { + "mimic-response": "^3.1.0" + } + }, + "mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==" + } + } + }, + "simple-swizzle": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", + "integrity": "sha1-pNprY1/8zMoz9w0Xy5JZLeleVXo=", + "requires": { + "is-arrayish": "^0.3.1" + }, + "dependencies": { + "is-arrayish": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", + "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==" + } + } + }, "sisteransi": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", @@ -22442,7 +22667,6 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, "requires": { "is-fullwidth-code-point": "^2.0.0", "strip-ansi": "^4.0.0" @@ -22460,7 +22684,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, "requires": { "ansi-regex": "^3.0.0" } @@ -22496,8 +22719,7 @@ "strip-json-comments": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", - "dev": true + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" }, "strong-error-handler": { "version": "2.3.2", @@ -23080,6 +23302,60 @@ "inherits": "2" } }, + "tar-fs": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.0.tgz", + "integrity": "sha512-9uW5iDvrIMCVpvasdFHW0wJPez0K4JnMZtsuIeDI7HyMGJNxmDZDOCQROr7lXyS+iL/QMpj07qcjGYTSdRFXUg==", + "requires": { + "chownr": "^1.1.1", + "mkdirp-classic": "^0.5.2", + "pump": "^3.0.0", + "tar-stream": "^2.0.0" + } + }, + "tar-stream": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.1.3.tgz", + "integrity": "sha512-Z9yri56Dih8IaK8gncVPx4Wqt86NDmQTSh49XLZgjWpGZL9GK9HKParS2scqHCC4w6X9Gh2jwaU45V47XTKwVA==", + "requires": { + "bl": "^4.0.1", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + }, + "dependencies": { + "bl": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.0.2.tgz", + "integrity": "sha512-j4OH8f6Qg2bGuWfRiltT2HYGx0e1QcBTrK9KAHNMwMZdQnDZFk0ZSYIpADjYCB3U12nicC5tVJwSIhwOWjb4RQ==", + "requires": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "buffer": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.6.0.tgz", + "integrity": "sha512-/gDYp/UtU0eA1ys8bOs9J6a+E/KWIY+DZ+Q2WESNUA0jFRsJOc0SNUO6xJ5SGA1xueg3NL65W6s+NY5l9cunuw==", + "requires": { + "base64-js": "^1.0.2", + "ieee754": "^1.1.4" + } + }, + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } + } + }, "teeny-request": { "version": "3.11.3", "resolved": "https://registry.npmjs.org/teeny-request/-/teeny-request-3.11.3.tgz", @@ -25048,11 +25324,15 @@ "integrity": "sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8=", "dev": true }, + "which-pm-runs": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/which-pm-runs/-/which-pm-runs-1.0.0.tgz", + "integrity": "sha1-Zws6+8VS4LVd9rd4DKdGFfI60cs=" + }, "wide-align": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", - "dev": true, "requires": { "string-width": "^1.0.2 || 2" } diff --git a/package.json b/package.json index 61dff1678..b7cca0364 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "request": "^2.88.0", "request-promise-native": "^1.0.8", "require-yaml": "0.0.1", + "sharp": "^0.25.4", "soap": "^0.26.0", "strong-error-handler": "^2.3.2", "uuid": "^3.3.3", diff --git a/print/common/css/layout.css b/print/common/css/layout.css index b85589a81..3b2643dc9 100644 --- a/print/common/css/layout.css +++ b/print/common/css/layout.css @@ -157,22 +157,6 @@ table { border-spacing: 0; } -/** - * Prevent page break fix - */ -tbody { - page-break-inside: avoid; - break-inside: avoid; - display: block; - width: 100% -} - -thead, tbody tr { - table-layout: fixed; - display: table; - width: 100%; -} - .row-oriented, .column-oriented { text-align: left; width: 100% @@ -188,6 +172,7 @@ thead, tbody tr { } .column-oriented thead { + display: table-header-group; background-color: #e5e5e5 } @@ -197,18 +182,24 @@ thead, tbody tr { background-color: #e5e5e5 } +.column-oriented tfoot { + display: table-row-group; + page-break-inside: avoid; + break-inside: avoid; +} + .column-oriented tbody { border-bottom: 1px solid #DDD; } -.column-oriented tfoot { - border-top: 2px solid #808080; -} - .column-oriented tfoot tr:first-child td { padding-top: 20px !important; } +.column-oriented tfoot tr:first-child { + border-top: 2px solid #808080; +} + .column-oriented .description { font-size: 0.8em } diff --git a/print/common/css/report.css b/print/common/css/report.css index 5b8a1539b..796b99c4f 100644 --- a/print/common/css/report.css +++ b/print/common/css/report.css @@ -3,12 +3,12 @@ * */ body { - zoom: 0.53 + zoom: 0.70; } .title { margin-bottom: 20px; font-weight: 100; - margin-top: 0; - font-size: 2em + font-size: 2em; + margin-top: 0 } \ No newline at end of file diff --git a/print/config/print.json b/print/config/print.json index e1a93e152..5f4c0f7b8 100755 --- a/print/config/print.json +++ b/print/config/print.json @@ -13,10 +13,14 @@ }, "pdf": { "format": "A4", - "border": "1.5cm", - "footer": { - "height": "55px" - } + "margin": { + "top": "1.5cm", + "right": "1.5cm", + "bottom": "3cm", + "left": "1.5cm" + }, + "displayHeaderFooter": true, + "printBackground": true }, "mysql": { "host": "localhost", diff --git a/print/core/components/report-footer/assets/css/style.css b/print/core/components/report-footer/assets/css/style.css index e7ee162a8..e06e8c0ad 100644 --- a/print/core/components/report-footer/assets/css/style.css +++ b/print/core/components/report-footer/assets/css/style.css @@ -1,11 +1,13 @@ -footer { +.footer { font-family: "Roboto", "Helvetica", "Arial", sans-serif; - font-size: 0.55em; + margin-left: 2cm; + margin-right: 2cm; + font-size: 10px; color: #555; zoom: 0.65 } -footer, footer p { +.footer p { text-align: center } @@ -13,12 +15,20 @@ p.privacy { font-size: 0.8em } -footer .page { +.footer .page { border-bottom: 2px solid #CCC; padding-bottom: 2px } -footer .page > section { +.page .centerText { + text-align: center +} + +.page .pageCount { + text-align: right +} + +.footer .page > div { display: inline-block; width: 33% } \ No newline at end of file diff --git a/print/core/components/report-footer/locale/en.yml b/print/core/components/report-footer/locale/en.yml index 404c7e7a4..3899f8b98 100644 --- a/print/core/components/report-footer/locale/en.yml +++ b/print/core/components/report-footer/locale/en.yml @@ -1,4 +1,4 @@ -numPages: Page {{page}} of {{pages}} +numPages: Page of law: privacy: '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 diff --git a/print/core/components/report-footer/locale/es.yml b/print/core/components/report-footer/locale/es.yml index 39dae8b58..985c1e17a 100644 --- a/print/core/components/report-footer/locale/es.yml +++ b/print/core/components/report-footer/locale/es.yml @@ -1,4 +1,4 @@ -numPages: Página {{page}} de {{pages}} +numPages: Página de law: privacy: En cumplimiento de lo dispuesto en la Ley Orgánica 15/1999, de Protección de Datos de Carácter Personal, le comunicamos que los datos personales que facilite diff --git a/print/core/components/report-footer/locale/fr.yml b/print/core/components/report-footer/locale/fr.yml index 8f2543640..861ee5684 100644 --- a/print/core/components/report-footer/locale/fr.yml +++ b/print/core/components/report-footer/locale/fr.yml @@ -1,4 +1,4 @@ -numPages: Page {{page}} de {{pages}} +numPages: Page de law: privacy: 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 diff --git a/print/core/components/report-footer/locale/pt.yml b/print/core/components/report-footer/locale/pt.yml index 8b4987bb7..1c343bb4c 100644 --- a/print/core/components/report-footer/locale/pt.yml +++ b/print/core/components/report-footer/locale/pt.yml @@ -1,4 +1,4 @@ -numPages: Página {{page}} de {{pages}} +numPages: Página de law: privacy: 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 diff --git a/print/core/components/report-footer/report-footer.html b/print/core/components/report-footer/report-footer.html index 4e0b7e327..85395559b 100644 --- a/print/core/components/report-footer/report-footer.html +++ b/print/core/components/report-footer/report-footer.html @@ -1,9 +1,11 @@ -
-
-
{{leftText}}
-
{{centerText}}
-
{{$t('numPages')}}
-
-

{{phytosanitary}}

-

-
+
+ +
diff --git a/print/core/components/report-header/assets/css/style.css b/print/core/components/report-header/assets/css/style.css index cb8cd55c0..3ce75e792 100644 --- a/print/core/components/report-header/assets/css/style.css +++ b/print/core/components/report-header/assets/css/style.css @@ -4,7 +4,7 @@ header { padding-bottom: 10px; margin-bottom: 20px; text-align: center; - font-size: 0.55em; + font-size: 12px; color: #555 } diff --git a/print/core/report.js b/print/core/report.js index db4c9f427..e773c6c91 100644 --- a/print/core/report.js +++ b/print/core/report.js @@ -1,5 +1,5 @@ const fs = require('fs'); -const pdf = require('html-pdf'); +const puppeteer = require('puppeteer'); const path = require('path'); const config = require('./config'); const Component = require('./component'); @@ -20,18 +20,39 @@ class Report extends Component { async toPdfStream() { const template = await this.render(); - let options = config.pdf; + const defaultOptions = Object.assign({}, config.pdf); const optionsPath = `${this.path}/options.json`; const fullPath = path.resolve(__dirname, optionsPath); + let options = defaultOptions; if (fs.existsSync(fullPath)) - options = Object.assign(options, require(optionsPath)); + options = require(optionsPath); - return new Promise(resolve => { - pdf.create(template, options).toStream((err, stream) => { - resolve(stream); - }); + const browser = await puppeteer.launch({ + headless: true, + args: ['--no-sandbox', '--disable-setuid-sandbox'] }); + const page = await browser.newPage(); + await page.setContent(template); + + const element = await page.$('#pageFooter'); + + let footer = '\n'; + if (element) { + footer = await page.evaluate(el => { + const html = el.innerHTML; + el.remove(); + return html; + }, element); + } + + options.headerTemplate = '\n'; + options.footerTemplate = footer; + + const buffer = await page.pdf(options); + await browser.close(); + + return buffer; } } diff --git a/print/methods/report.js b/print/methods/report.js index 348c05ff3..eea249a42 100644 --- a/print/methods/report.js +++ b/print/methods/report.js @@ -10,8 +10,7 @@ module.exports = app => { res.setHeader('Content-type', 'application/pdf'); res.setHeader('Content-Disposition', `inline; filename="${fileName}"`); - - stream.pipe(res); + res.end(stream); } catch (error) { next(error); } diff --git a/print/package-lock.json b/print/package-lock.json index 0704fec0f..1020b8750 100644 --- a/print/package-lock.json +++ b/print/package-lock.json @@ -4,6 +4,26 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@types/node": { + "version": "14.0.27", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.27.tgz", + "integrity": "sha512-kVrqXhbclHNHGu9ztnAwSncIgJv/FaxmzXJvGXNdcCpV1b8u1/Mi6z6m0vwy0LzKeXFTPLH0NzwmoJ3fNCIq0g==", + "optional": true + }, + "@types/yauzl": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.9.1.tgz", + "integrity": "sha512-A1b8SU4D10uoPjwb0lnHmmu8wZhR9d+9o2PKBQT2jU5YPTKsxac6M2qGAdY7VcL+dHHhARVUDmeg0rOrcd9EjA==", + "optional": true, + "requires": { + "@types/node": "*" + } + }, + "agent-base": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-5.1.1.tgz", + "integrity": "sha512-TMeqbNl2fMW0nMjTEPOwe3J/PRFP4vqeoNuQMG0HlMrtm5QxKqdvAkZ1pRBQ/ulIyDD5Yq0nJ7YbdD8ey0TO3g==" + }, "ajv": { "version": "6.7.0", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.7.0.tgz", @@ -69,6 +89,16 @@ "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "base64-js": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", + "integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==" + }, "bcrypt-pbkdf": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", @@ -77,11 +107,51 @@ "tweetnacl": "^0.14.3" } }, + "bl": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.0.2.tgz", + "integrity": "sha512-j4OH8f6Qg2bGuWfRiltT2HYGx0e1QcBTrK9KAHNMwMZdQnDZFk0ZSYIpADjYCB3U12nicC5tVJwSIhwOWjb4RQ==", + "requires": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + }, + "dependencies": { + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + } + } + }, "boolbase": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=" }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "buffer": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.6.0.tgz", + "integrity": "sha512-/gDYp/UtU0eA1ys8bOs9J6a+E/KWIY+DZ+Q2WESNUA0jFRsJOc0SNUO6xJ5SGA1xueg3NL65W6s+NY5l9cunuw==", + "requires": { + "base64-js": "^1.0.2", + "ieee754": "^1.1.4" + } + }, + "buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=" + }, "buffer-from": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", @@ -131,6 +201,11 @@ "lodash.some": "^4.4.0" } }, + "chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" + }, "cliui": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", @@ -182,6 +257,11 @@ "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, "concat-stream": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", @@ -299,6 +379,11 @@ "resolved": "https://registry.npmjs.org/denque/-/denque-1.4.1.tgz", "integrity": "sha512-OfzPuSZKGcgr96rf1oODnfjqBFmr1DVoc/TrItj3Ohe0Ah1C5WX5Baquw/9U9KovnQ88EqmJbD66rKYUQYN1tQ==" }, + "devtools-protocol": { + "version": "0.0.781568", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.781568.tgz", + "integrity": "sha512-9Uqnzy6m6zEStluH9iyJ3iHyaQziFnMnLeC8vK0eN6smiJmIx7+yB64d67C2lH/LZra+5cGscJAJsNXO+MdPMg==" + }, "dijkstrajs": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.1.tgz", @@ -349,6 +434,14 @@ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==" }, + "end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "requires": { + "once": "^1.4.0" + } + }, "entities": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", @@ -434,6 +527,11 @@ "mime-types": "^2.1.12" } }, + "fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, "fs-extra": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", @@ -444,6 +542,11 @@ "universalify": "^0.1.0" } }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, "generate-function": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.3.1.tgz", @@ -457,6 +560,14 @@ "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==" }, + "get-stream": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", + "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", + "requires": { + "pump": "^3.0.0" + } + }, "getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", @@ -465,6 +576,19 @@ "assert-plus": "^1.0.0" } }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, "graceful-fs": { "version": "4.1.15", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", @@ -548,6 +672,30 @@ "sshpk": "^1.7.0" } }, + "https-proxy-agent": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-4.0.0.tgz", + "integrity": "sha512-zoDhWrkR3of1l9QAL8/scJZyLu8j/gBkcwcaQOZh7Gyh/+uJQzGVETdgT30akuwkpL8HTRfssqI3BZuV18teDg==", + "requires": { + "agent-base": "5", + "debug": "4" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, "iconv-lite": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.5.0.tgz", @@ -556,11 +704,25 @@ "safer-buffer": ">= 2.1.2 < 3" } }, + "ieee754": { + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", + "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" + }, "image-size": { "version": "0.7.5", "resolved": "https://registry.npmjs.org/image-size/-/image-size-0.7.5.tgz", "integrity": "sha512-Hiyv+mXHfFEP7LzUL/llg9RwFxxY+o9N3JVLIeG5E7iFIFAalxvRU9UZthBdYDEVnzHMgjnKJPPpay5BWf1g9g==" }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", @@ -804,6 +966,11 @@ "resolved": "https://registry.npmjs.org/mensch/-/mensch-0.3.3.tgz", "integrity": "sha1-4gD/TdgjcX+OBWOzLj9UgfyiYrI=" }, + "mime": { + "version": "2.4.6", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.6.tgz", + "integrity": "sha512-RZKhC3EmpBchfTGBVb8fb+RL2cWyw/32lshnsETttkBAyAUXSGHxbEJWWRXc751DrIxG1q04b8QwMbAwkRPpUA==" + }, "mime-db": { "version": "1.37.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz", @@ -822,6 +989,14 @@ "resolved": "https://registry.npmjs.org/mimer/-/mimer-1.0.0.tgz", "integrity": "sha512-4ZJvCzfcwsBgPbkKXUzGoVZMWjv8IDIygkGzVc7uUYhgnK0t2LmGxxjdgH1i+pn0/KQfB5F/VKUJlfyTSOFQjg==" }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, "minimist": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", @@ -837,6 +1012,11 @@ "minimist": "0.0.8" } }, + "mkdirp-classic": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -905,6 +1085,14 @@ "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, "p-limit": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.1.tgz", @@ -931,6 +1119,11 @@ "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=" }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, "path-key": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", @@ -944,8 +1137,7 @@ "pend": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", - "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=", - "optional": true + "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=" }, "performance-now": { "version": "2.1.0", @@ -1006,6 +1198,46 @@ "pinkie": "^2.0.0" } }, + "pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "requires": { + "find-up": "^4.0.0" + }, + "dependencies": { + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "requires": { + "p-locate": "^4.1.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "requires": { + "p-limit": "^2.2.0" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==" + } + } + }, "pngjs": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-3.4.0.tgz", @@ -1023,6 +1255,11 @@ "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", "optional": true }, + "proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "pseudomap": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", @@ -1033,11 +1270,87 @@ "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.31.tgz", "integrity": "sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw==" }, + "pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, "punycode": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" }, + "puppeteer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-5.2.1.tgz", + "integrity": "sha512-PZoZG7u+T6N1GFWBQmGVG162Ak5MAy8nYSVpeeQrwJK2oYUlDWpHEJPcd/zopyuEMTv7DiztS1blgny1txR2qw==", + "requires": { + "debug": "^4.1.0", + "devtools-protocol": "0.0.781568", + "extract-zip": "^2.0.0", + "https-proxy-agent": "^4.0.0", + "mime": "^2.0.3", + "pkg-dir": "^4.2.0", + "progress": "^2.0.1", + "proxy-from-env": "^1.0.0", + "rimraf": "^3.0.2", + "tar-fs": "^2.0.0", + "unbzip2-stream": "^1.3.3", + "ws": "^7.2.3" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "requires": { + "ms": "^2.1.1" + } + }, + "extract-zip": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz", + "integrity": "sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==", + "requires": { + "@types/yauzl": "^2.9.1", + "debug": "^4.1.1", + "get-stream": "^5.1.0", + "yauzl": "^2.10.0" + } + }, + "fd-slicer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", + "integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=", + "requires": { + "pend": "~1.2.0" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==" + }, + "yauzl": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=", + "requires": { + "buffer-crc32": "~0.2.3", + "fd-slicer": "~1.1.0" + } + } + } + }, "qrcode": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.4.2.tgz", @@ -1125,6 +1438,14 @@ "path-parse": "^1.0.6" } }, + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "requires": { + "glob": "^7.1.3" + } + }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -1265,12 +1586,40 @@ "has-flag": "^3.0.0" } }, + "tar-fs": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.0.tgz", + "integrity": "sha512-9uW5iDvrIMCVpvasdFHW0wJPez0K4JnMZtsuIeDI7HyMGJNxmDZDOCQROr7lXyS+iL/QMpj07qcjGYTSdRFXUg==", + "requires": { + "chownr": "^1.1.1", + "mkdirp-classic": "^0.5.2", + "pump": "^3.0.0", + "tar-stream": "^2.0.0" + } + }, + "tar-stream": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.1.3.tgz", + "integrity": "sha512-Z9yri56Dih8IaK8gncVPx4Wqt86NDmQTSh49XLZgjWpGZL9GK9HKParS2scqHCC4w6X9Gh2jwaU45V47XTKwVA==", + "requires": { + "bl": "^4.0.1", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + } + }, "throttleit": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/throttleit/-/throttleit-1.0.0.tgz", "integrity": "sha1-nnhYNtr0Z0MUWlmEtiaNgoUorGw=", "optional": true }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" + }, "tough-cookie": { "version": "2.4.3", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", @@ -1306,6 +1655,15 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "optional": true }, + "unbzip2-stream": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.4.3.tgz", + "integrity": "sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==", + "requires": { + "buffer": "^5.2.1", + "through": "^2.3.8" + } + }, "universalify": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", @@ -1455,6 +1813,16 @@ } } }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "ws": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.1.tgz", + "integrity": "sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA==" + }, "xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", diff --git a/print/package.json b/print/package.json index 971e74c74..281edb494 100755 --- a/print/package.json +++ b/print/package.json @@ -20,6 +20,7 @@ "juice": "^5.2.0", "mysql2": "^1.7.0", "nodemailer": "^4.7.0", + "puppeteer": "^2.0.0", "qrcode": "^1.4.2", "strftime": "^0.10.0", "vue": "^2.6.10", diff --git a/print/templates/reports/campaign-metrics/campaign-metrics.html b/print/templates/reports/campaign-metrics/campaign-metrics.html index d125ab7e2..536c7c5d2 100644 --- a/print/templates/reports/campaign-metrics/campaign-metrics.html +++ b/print/templates/reports/campaign-metrics/campaign-metrics.html @@ -6,11 +6,7 @@ -
-
- -
-
+
@@ -93,15 +89,11 @@
-
-
- - -
-
+ + diff --git a/print/templates/reports/claim-pickup-order/claim-pickup-order.html b/print/templates/reports/claim-pickup-order/claim-pickup-order.html index 59647cf9a..2fdea5291 100644 --- a/print/templates/reports/claim-pickup-order/claim-pickup-order.html +++ b/print/templates/reports/claim-pickup-order/claim-pickup-order.html @@ -6,11 +6,7 @@ -
-
- -
-
+
@@ -85,15 +81,11 @@
-
-
- - -
-
+ + diff --git a/print/templates/reports/delivery-note/delivery-note.html b/print/templates/reports/delivery-note/delivery-note.html index 913946196..5c8dac8eb 100644 --- a/print/templates/reports/delivery-note/delivery-note.html +++ b/print/templates/reports/delivery-note/delivery-note.html @@ -6,13 +6,9 @@ -
-
- - -
-
+ +
@@ -241,17 +237,13 @@
-
-
- - -
-
+ + diff --git a/print/templates/reports/driver-route/driver-route.html b/print/templates/reports/driver-route/driver-route.html index 919ed0679..549aac060 100644 --- a/print/templates/reports/driver-route/driver-route.html +++ b/print/templates/reports/driver-route/driver-route.html @@ -6,11 +6,7 @@ -
-
- -
-
+
@@ -154,14 +150,10 @@
-
-
- - -
-
+ + diff --git a/print/templates/reports/entry-order/entry-order.html b/print/templates/reports/entry-order/entry-order.html index 3c1cdbd33..cb69ecee9 100644 --- a/print/templates/reports/entry-order/entry-order.html +++ b/print/templates/reports/entry-order/entry-order.html @@ -6,13 +6,9 @@ -
-
- - -
-
+ +
@@ -126,16 +122,12 @@
-
-
- - -
-
+ + diff --git a/print/templates/reports/item-label/options.json b/print/templates/reports/item-label/options.json index 6b00b0443..98c5788b1 100644 --- a/print/templates/reports/item-label/options.json +++ b/print/templates/reports/item-label/options.json @@ -1,10 +1,11 @@ { - "format": "A4", - "orientation": "landscape", "width": "10.4cm", "height": "4.8cm", - "border": "0cm", - "footer": { - "height": "0" - } + "margin": { + "top": "0cm", + "right": "0cm", + "bottom": "0cm", + "left": "0cm" + }, + "printBackground": true } \ No newline at end of file diff --git a/print/templates/reports/letter-debtor/letter-debtor.html b/print/templates/reports/letter-debtor/letter-debtor.html index 81a001765..88bf15bdb 100644 --- a/print/templates/reports/letter-debtor/letter-debtor.html +++ b/print/templates/reports/letter-debtor/letter-debtor.html @@ -6,11 +6,7 @@ -
-
- -
-
+
@@ -74,24 +70,23 @@ - Total {{getTotalDebtOut()}} - {{getTotalDebtIn()}} - {{totalBalance}} + + Total + {{getTotalDebtOut() | currency('EUR', $i18n.locale)}} + + {{getTotalDebtIn() | currency('EUR', $i18n.locale)}} + {{totalBalance | currency('EUR', $i18n.locale)}}
-
-
- - -
-
+ + diff --git a/print/templates/reports/receipt/receipt.html b/print/templates/reports/receipt/receipt.html index 9a4e1964c..3371e6871 100644 --- a/print/templates/reports/receipt/receipt.html +++ b/print/templates/reports/receipt/receipt.html @@ -6,11 +6,7 @@ -
-
- -
-
+
@@ -36,15 +32,11 @@
-
-
- - -
-
+ + diff --git a/print/templates/reports/sepa-core/sepa-core.html b/print/templates/reports/sepa-core/sepa-core.html index d14a3ce6e..300cf976f 100644 --- a/print/templates/reports/sepa-core/sepa-core.html +++ b/print/templates/reports/sepa-core/sepa-core.html @@ -6,11 +6,7 @@ -
-
- -
-
+
@@ -166,15 +162,11 @@
-
-
- - -
-
+ +