diff --git a/back/methods/chat/send.js b/back/methods/chat/send.js index b0a9431c7..53e5da7cc 100644 --- a/back/methods/chat/send.js +++ b/back/methods/chat/send.js @@ -32,6 +32,8 @@ module.exports = Self => { if (sender.name != recipient) return sendMessage(sender, to, message); + + return false; }; async function sendMessage(sender, channel, message) { diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index ac5836af3..b2a3ca725 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -30,24 +30,19 @@ module.exports = Self => { const query = `SELECT worker_isWorking(?) isWorking`; const [result] = await Self.rawSql(query, [workerId]); - let room; - if (result.isWorking) - room = `@${account.name}`; - else { + if (!result.isWorking) { const workerDepartment = await models.WorkerDepartment.findById(workerId, { include: { relation: 'department' } }); - const department = workerDepartment.department(); + const department = workerDepartment && workerDepartment.department(); const channelName = department.chatName; - room = `#${channelName}`; if (channelName) - room = `#${channelName}`; - else room = `@${account.name}`; + return Self.send(ctx, `#${channelName}`, `@${account.name} => ${message}`); } - return Self.send(ctx, room, message); + return Self.send(ctx, `@${account.name}`, message); }; }; diff --git a/back/methods/chat/spec/send.spec.js b/back/methods/chat/spec/send.spec.js index b2585a9a1..56f2a9c27 100644 --- a/back/methods/chat/spec/send.spec.js +++ b/back/methods/chat/spec/send.spec.js @@ -9,10 +9,10 @@ describe('chat send()', () => { expect(response.message).toEqual('Fake notification sent'); }); - it('should not return a response', async() => { + it('should retrun false as response', async() => { let ctx = {req: {accessToken: {userId: 18}}}; let response = await app.models.Chat.send(ctx, '@salesPerson', 'I changed something'); - expect(response).toBeUndefined(); + expect(response).toBeFalsy(); }); }); diff --git a/back/methods/chat/spec/sendCheckingPresence.spec.js b/back/methods/chat/spec/sendCheckingPresence.spec.js index 12a163962..1523cb1d0 100644 --- a/back/methods/chat/spec/sendCheckingPresence.spec.js +++ b/back/methods/chat/spec/sendCheckingPresence.spec.js @@ -38,7 +38,7 @@ describe('chat sendCheckingPresence()', () => { expect(response.statusCode).toEqual(200); expect(response.message).toEqual('Fake notification sent'); - expect(chatModel.send).toHaveBeenCalledWith(ctx, '#cooler', 'I changed something'); + expect(chatModel.send).toHaveBeenCalledWith(ctx, '#cooler', '@HankPym => I changed something'); }); it(`should call to send() method with the worker username when the worker is working`, async() => { diff --git a/db/changes/10121-zoneClosure/00-zoneClosure.sql b/db/changes/10121-zoneClosure/00-zoneClosure.sql deleted file mode 100644 index 07db5b167..000000000 --- a/db/changes/10121-zoneClosure/00-zoneClosure.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE TABLE `vn`.`zoneClosure` ( - `zoneFk` INT NOT NULL, - `dated` DATE NOT NULL, - `hour` TIME NOT NULL, - PRIMARY KEY (`zoneFk`, `dated`)); diff --git a/db/changes/10121-zoneClosure/00-zoneClosure_recalc.sql b/db/changes/10121-zoneClosure/00-zoneClosure_recalc.sql deleted file mode 100644 index cb313cdec..000000000 --- a/db/changes/10121-zoneClosure/00-zoneClosure_recalc.sql +++ /dev/null @@ -1,50 +0,0 @@ - -DROP procedure IF EXISTS vn.`zoneClosure_recalc`; - -DELIMITER $$ -CREATE DEFINER=`root`@`%` PROCEDURE vn.`zoneClosure_recalc`() -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; - - TRUNCATE TABLE zoneClosure; - - REPEAT - CALL zone_getOptionsForShipment(vShipped); - INSERT INTO zoneClosure(zoneFk, dated, `hour`) - SELECT zoneFk, vShipped, `hour` FROM tmp.zoneOption; - - SET vCounter = vCounter + 1; - SET vShipped = TIMESTAMPADD(DAY, 1, vShipped); - UNTIL vCounter > vScope - END REPEAT; - - DROP TEMPORARY TABLE tmp.zone; - DO RELEASE_LOCK('vn.zoneClosure_recalc'); -END$$ - -DELIMITER ; - diff --git a/db/changes/10121-zoneClosure/00-zoneConfig.sql b/db/changes/10121-zoneClosure/00-zoneConfig.sql deleted file mode 100644 index 915fb8894..000000000 --- a/db/changes/10121-zoneClosure/00-zoneConfig.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE `vn`.`zoneConfig` ( - `id` INT UNSIGNED NOT NULL, - `scope` INT UNSIGNED NOT NULL, - PRIMARY KEY (`id`)); - -ALTER TABLE `vn`.`zoneConfig` -CHANGE COLUMN `id` `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT ; - -INSERT INTO `vn`.`zoneConfig` (`scope`) VALUES ('1'); - -INSERT INTO `bs`.`nightTask` (`order`, `schema`, `procedure`) VALUES ('100', 'vn', 'zoneClosure_recalc'); diff --git a/db/changes/10130-christmas/00-catalog_componentCalculate.sql b/db/changes/10130-christmas/00-catalog_componentCalculate.sql deleted file mode 100644 index c778c7b3a..000000000 --- a/db/changes/10130-christmas/00-catalog_componentCalculate.sql +++ /dev/null @@ -1,254 +0,0 @@ -DROP procedure IF EXISTS `vn`.`catalog_componentCalculate`; - -DELIMITER $$ -CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`catalog_componentCalculate`( - vZoneFk INT, - vAddressFk INT, - vShipped DATE) -proc: BEGIN -/** - * Calcula los componentes de los articulos de tmp.ticketLot - * - * @param vZoneFk para calcular el transporte - * @param vAgencyModeFk Id del modo de agencia - * @param tmp.ticketLot (warehouseFk,available,itemFk,buyFk) - * - * @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 vBoxFreightItem INT DEFAULT 71; - 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; - - 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 INDEX `itemWarehouseComponent` (`itemFk` ASC, `warehouseFk` ASC, `componentFk` ASC)); - - 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 - 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; - - 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((z.price - z.bonus) - * 1/*amz.inflation*/ , 50)) / vBoxVolume, 4 - ) cost - FROM tmp.ticketComponentCalculate tcc - JOIN item i ON i.id = tcc.itemFk - 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; - - 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; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentPrice; - CREATE TEMPORARY TABLE tmp.ticketComponentPrice ENGINE = MEMORY - 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 ; \ No newline at end of file diff --git a/db/changes/10130-christmas/00-chatConfig.sql b/db/changes/10130-christmas/00-chatConfig.sql deleted file mode 100644 index beff3bde4..000000000 --- a/db/changes/10130-christmas/00-chatConfig.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE `vn`.`chatConfig` -ADD COLUMN `host` VARCHAR(255) NOT NULL AFTER `id`, -CHANGE COLUMN `uri` `api` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ; - -UPDATE `vn`.`chatConfig` SET `host` = 'https://chat.verdnatura.es' WHERE (`id` = '1'); diff --git a/db/changes/10130-christmas/00-greugeConfig.sql b/db/changes/10130-christmas/00-greugeConfig.sql deleted file mode 100644 index c21751f08..000000000 --- a/db/changes/10130-christmas/00-greugeConfig.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE `vn`.`greugeConfig` ( - `id` INT NOT NULL AUTO_INCREMENT, - `freightPickUpPrice` DECIMAL(10,2) NOT NULL, - PRIMARY KEY (`id`)); - -INSERT IGNORE INTO `vn`.`greugeConfig` (`id`, `freightPickUpPrice`) VALUES ('1', '11'); diff --git a/db/changes/10130-christmas/00-manaSpellersRequery.sql b/db/changes/10130-christmas/00-manaSpellersRequery.sql deleted file mode 100644 index cc185fdba..000000000 --- a/db/changes/10130-christmas/00-manaSpellersRequery.sql +++ /dev/null @@ -1,70 +0,0 @@ - -DROP procedure IF EXISTS `vn`.`manaSpellersRequery`; - -DELIMITER $$ -CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`manaSpellersRequery`(vWorkerFk INTEGER) -BEGIN - - DECLARE vWorkerIsExcluded BOOLEAN; - DECLARE vFromDated DATE; - DECLARE vToDated DATE DEFAULT TIMESTAMPADD(DAY,1,CURDATE()); - DECLARE vMana INT; - DECLARE vAutoMana INT; - DECLARE vManaBank INT; - DECLARE vManaGreugeType INT; - - SELECT id INTO vMana - FROM `component` WHERE code = 'mana'; - - SELECT id INTO vAutoMana - FROM `component` WHERE code = 'autoMana'; - - SELECT id INTO vManaBank - FROM `bank` WHERE code = 'mana'; - - SELECT id INTO vManaGreugeType - FROM `greugeType` WHERE code = 'mana'; - - SELECT COUNT(*) INTO vWorkerIsExcluded - FROM workerManaExcluded - WHERE workerFk = vWorkerFk; - - IF NOT vWorkerIsExcluded THEN - - SELECT max(dated) INTO vFromDated - FROM clientManaCache; - - REPLACE workerMana (workerFk, amount) - SELECT vWorkerFk, sum(mana) FROM - ( - SELECT s.quantity * sc.value as mana - FROM ticket t - JOIN address a ON a.id = t.addressFk - JOIN client c ON c.id = a.clientFk - JOIN sale s ON s.ticketFk = t.id - JOIN saleComponent sc ON sc.saleFk = s.id - WHERE c.salesPersonFk = vWorkerFk AND sc.componentFk IN (vMana, vAutoMana) - AND t.shipped > vFromDated AND t.shipped < vToDated - UNION ALL - SELECT - r.amountPaid - FROM receipt r - JOIN client c ON c.id = r.clientFk - WHERE c.salesPersonFk = vWorkerFk AND bankFk = vManaBank - AND payed > vFromDated - UNION ALL - SELECT g.amount - FROM greuge g - JOIN client c ON c.id = g.clientFk - WHERE c.salesPersonFk = vWorkerFk AND g.greugeTypeFk = vManaGreugeType - AND g.shipped > vFromDated and g.shipped < CURDATE() - UNION ALL - SELECT cc.mana - FROM clientManaCache cc - JOIN client c ON c.id = cc.clientFk - WHERE c.salesPersonFk = vWorkerFk AND cc.dated = vFromDated - ) sub; - END IF; -END$$ - -DELIMITER ; - diff --git a/db/changes/10130-christmas/00-timeControl_calculate.sql b/db/changes/10130-christmas/00-timeControl_calculate.sql deleted file mode 100644 index 0a6470216..000000000 --- a/db/changes/10130-christmas/00-timeControl_calculate.sql +++ /dev/null @@ -1,44 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `timeControl_calculate`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `timeControl_calculate`(vDatedFrom DATETIME, vDatedTo DATETIME) -BEGIN - SET @vIsOdd := TRUE; - SET @vUser := NULL; - SET @vDated := NULL; - - DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate; - - CREATE TEMPORARY TABLE tmp.timeControlCalculate - SELECT userFk, - dated, - IF( timeWork >= 18000, @timeWork:=timeWork + 1200, @timeWork:=timeWork) timeWorkSeconds, - SEC_TO_TIME(@timeWork ) timeWorkSexagesimal, - @timeWork / 3600 timeWorkDecimal - FROM (SELECT SUM(timeWork) timeWork, - userFk, - dated - FROM (SELECT IF(@vUser = wtc.userFk, @vUser :=@vUser, @vUser := wtc.userFk ), - IF(@vIsOdd, @vIsOdd := FALSE, @vIsOdd := TRUE ), - IF(direction='in', @vIsOdd := TRUE, @vIsOdd := @vIsOdd ), - IF(@vIsOdd, @vLastTimed:=UNIX_TIMESTAMP(timed),@vLastTimed:=@vLastTimed), - IF(@vIsOdd, 0, UNIX_TIMESTAMP(timed)-@vLastTimed) timeWork, - IF(direction='in', @vDated := DATE(wtc.timed), @vDated :=@vDated) dated, - wtc.userFk, - wtc.timed timed, - direction - FROM (SELECT * FROM workerTimeControl ORDER BY userFk, timed ASC) wtc - JOIN tmp.`user` w ON w.userFk = wtc.userFk - WHERE wtc.timed BETWEEN vDatedFrom AND vDatedTo - ORDER BY userFk, timed ASC - ) sub - GROUP BY userFk, dated - ORDER BY userFk, dated - )sub2; - -END$$ - -DELIMITER ; - diff --git a/db/changes/10140-kings/00-ACL.sql b/db/changes/10140-kings/00-ACL.sql deleted file mode 100644 index fe1cbeb24..000000000 --- a/db/changes/10140-kings/00-ACL.sql +++ /dev/null @@ -1,3 +0,0 @@ -INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Thermograph', '*', '*', 'ALLOW', 'ROLE', 'buyer'); -INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('TravelThermograph', '*', '*', 'ALLOW', 'ROLE', 'buyer'); -INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Entry', '*', '*', 'ALLOW', 'ROLE', 'buyer'); \ No newline at end of file diff --git a/db/changes/10140-kings/00-buy_afterUpsert.sql b/db/changes/10140-kings/00-buy_afterUpsert.sql deleted file mode 100644 index ab038628c..000000000 --- a/db/changes/10140-kings/00-buy_afterUpsert.sql +++ /dev/null @@ -1,81 +0,0 @@ - -DROP procedure IF EXISTS `vn`.`buy_afterUpsert`; - -DELIMITER $$ -CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`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; - DECLARE vLanded DATE; - DECLARE vBuyerFk INT; - DECLARE vItemName VARCHAR(50); - - SELECT entryFk, itemFk, stickers, packing - INTO vEntryFk, vItemFk, vStickers, vPacking - FROM buy - WHERE id = vSelf; - - SELECT t.warehouseInFk, t.warehouseOutFk, t.landed - INTO vWarehouse, vWarehouseOut, vLanded - FROM entry e - JOIN travel t ON t.id = e.travelFk - WHERE e.id = vEntryFk; - - SELECT k.merchandise, it.workerFk, i.longName - INTO vIsMerchandise, vBuyerFk, vItemName - 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); - 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; - - -- Aviso al comprador de modificacion de entrada en Barajas - IF (SELECT isBuyerToBeEmailed FROM warehouse WHERE id = vWarehouse) - AND vLanded = CURDATE() - AND vBuyerFk != account.myUserGetId() - THEN - - CALL vn.mail_insert(CONCAT(account.userGetNameFromId(vBuyerFk),'@verdnatura.es'), - CONCAT(account.myUserGetName(),'@verdnatura.es'), - CONCAT('E ',vEntryFk,' Se ha modificado item ', vItemFk, ' ',vItemName), - 'Este email se ha generado automáticamente'); - - END IF; - -END$$ - -DELIMITER ; - diff --git a/db/changes/10140-kings/00-clientRisk_update.sql b/db/changes/10140-kings/00-clientRisk_update.sql deleted file mode 100644 index 389236e1d..000000000 --- a/db/changes/10140-kings/00-clientRisk_update.sql +++ /dev/null @@ -1,18 +0,0 @@ - -DELIMITER $$ -CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`clientRisk_update`(vClientId INT, vCompanyId INT, vAmount DECIMAL(10,2)) -BEGIN - IF vAmount IS NOT NULL - THEN - INSERT INTO clientRisk - SET - clientFk = vClientId, - companyFk = vCompanyId, - amount = vAmount - ON DUPLICATE KEY UPDATE - amount = amount + VALUES(amount); - END IF; -END$$ - -DELIMITER ; - diff --git a/db/changes/10140-kings/00-componentType.sql b/db/changes/10140-kings/00-componentType.sql deleted file mode 100644 index e17d35400..000000000 --- a/db/changes/10140-kings/00-componentType.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE `vn`.`componentType` -CHANGE COLUMN `base` `isBase` TINYINT(4) NOT NULL DEFAULT '0' COMMENT 'Marca aquellas series que se utilizan para calcular el precio base de las ventas, a efectos estadisticos' ; - diff --git a/db/changes/10140-kings/00-customer_risk_update.sql b/db/changes/10140-kings/00-customer_risk_update.sql deleted file mode 100644 index c7ecead4f..000000000 --- a/db/changes/10140-kings/00-customer_risk_update.sql +++ /dev/null @@ -1,12 +0,0 @@ - -DROP procedure IF EXISTS `bi`.`customer_risk_update`; - -DELIMITER $$ -USE `bi`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `bi`.`customer_risk_update`(v_customer INT, v_company INT, v_amount DECIMAL(10,2)) -BEGIN - CALL vn.clientRisk_update(v_customer, v_company, v_amount); -END$$ - -DELIMITER ; - diff --git a/db/changes/10140-kings/00-department.sql b/db/changes/10140-kings/00-department.sql deleted file mode 100644 index 29008d753..000000000 --- a/db/changes/10140-kings/00-department.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `vn`.`department` -ADD COLUMN `chatName` VARCHAR(45) NULL AFTER `path`; diff --git a/db/changes/10140-kings/00-ticketComponentUpdateSale.sql b/db/changes/10140-kings/00-ticketComponentUpdateSale.sql deleted file mode 100644 index b40debce6..000000000 --- a/db/changes/10140-kings/00-ticketComponentUpdateSale.sql +++ /dev/null @@ -1,155 +0,0 @@ - - -DROP procedure IF EXISTS `vn`.`ticketComponentUpdateSale`; - -DELIMITER $$ - -CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`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 - SET vComponentFk = 17; - SET vRenewComponents = TRUE; - SET vKeepPrices = TRUE; - WHEN 3 THEN - SET vComponentFk = 37; - SET vRenewComponents = TRUE; - SET vKeepPrices = TRUE; - WHEN 4 THEN - SET vComponentFk = 34; - SET vRenewComponents = TRUE; - SET vKeepPrices = TRUE; - WHEN 5 THEN - SET vComponentFk = 35; - SET vRenewComponents = TRUE; - SET vKeepPrices = TRUE; - WHEN 6 THEN - SET vComponentFk = 36; - 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/10140-kings/00-travelThermograph.sql b/db/changes/10140-kings/00-travelThermograph.sql deleted file mode 100644 index c19151a45..000000000 --- a/db/changes/10140-kings/00-travelThermograph.sql +++ /dev/null @@ -1,7 +0,0 @@ -ALTER TABLE `vn`.`travelThermograph` -ADD COLUMN `id` INT NOT NULL AUTO_INCREMENT FIRST, -DROP PRIMARY KEY, -ADD PRIMARY KEY (`id`); - -ALTER TABLE `vn`.`travelThermograph` -ADD UNIQUE INDEX `thermograph_created` (`thermographFk` ASC, `created` ASC) VISIBLE; \ No newline at end of file diff --git a/db/changes/10140-kings/00-triggerInvoiceOut.sql b/db/changes/10140-kings/00-triggerInvoiceOut.sql deleted file mode 100644 index 7f6ed30b1..000000000 --- a/db/changes/10140-kings/00-triggerInvoiceOut.sql +++ /dev/null @@ -1,27 +0,0 @@ -DROP TRIGGER IF EXISTS `vn`.`invoiceOut_afterInsert`; - -DELIMITER $$ -CREATE DEFINER=`root`@`%` TRIGGER `vn`.`invoiceOut_afterInsert` AFTER INSERT ON `vn`.`invoiceOut` FOR EACH ROW BEGIN - CALL clientRisk_update(NEW.clientFk, NEW.companyFk, NEW.amount); -END$$ -DELIMITER ; - -DROP TRIGGER IF EXISTS `vn`.`invoiceOut_beforeUpdate`; - -DELIMITER $$ -CREATE DEFINER=`root`@`%` TRIGGER `vn`.`invoiceOut_beforeUpdate` BEFORE UPDATE ON `vn`.`invoiceOut` FOR EACH ROW -BEGIN - CALL clientRisk_update (OLD.clientFk, OLD.companyFk, -OLD.amount); - CALL clientRisk_update (NEW.clientFk, NEW.companyFk, NEW.amount); -END$$ - -DELIMITER ; - - -DROP TRIGGER IF EXISTS `vn`.`invoiceOut_beforeDelete`; - -DELIMITER $$ -CREATE DEFINER=`root`@`%` TRIGGER `vn`.`invoiceOut_beforeDelete` BEFORE DELETE ON `invoiceOut` FOR EACH ROW BEGIN - CALL clientRisk_update (OLD.clientFk, OLD.companyFk, -OLD.amount); -END$$ -DELIMITER ; diff --git a/db/changes/10140-kings/00-triggerReceipt.sql b/db/changes/10140-kings/00-triggerReceipt.sql deleted file mode 100644 index c9c368a40..000000000 --- a/db/changes/10140-kings/00-triggerReceipt.sql +++ /dev/null @@ -1,20 +0,0 @@ -DROP TRIGGER IF EXISTS `vn`.`receipt_afterInsert`; - -DELIMITER $$ -CREATE DEFINER=`root`@`%` TRIGGER `vn`.`receipt_afterInsert` AFTER INSERT ON `receipt` FOR EACH ROW - CALL clientRisk_update(NEW.clientFk, NEW.companyFk, -NEW.amountPaid)$$ -DELIMITER ; -DROP TRIGGER IF EXISTS `vn`.`receipt_beforeUpdate`; - -DELIMITER $$ -CREATE DEFINER=`root`@`%` TRIGGER `vn`.`receipt_beforeUpdate` BEFORE UPDATE ON `receipt` FOR EACH ROW BEGIN - CALL clientRisk_update(OLD.clientFk, OLD.companyFk, OLD.amountPaid); - CALL clientRisk_update(NEW.clientFk, NEW.companyFk, -NEW.amountPaid); -END$$ -DELIMITER ; -DROP TRIGGER IF EXISTS `vn`.`receipt_beforeDelete`; - -DELIMITER $$ -CREATE DEFINER=`root`@`%` TRIGGER `vn`.`receipt_beforeDelete` BEFORE DELETE ON `receipt` FOR EACH ROW - CALL clientRisk_update(OLD.clientFk, OLD.companyFk, OLD.amountPaid)$$ -DELIMITER ; diff --git a/db/changes/10140-kings/00-weekWaste_getDetail.sql b/db/changes/10140-kings/00-weekWaste_getDetail.sql deleted file mode 100644 index a7e099f58..000000000 --- a/db/changes/10140-kings/00-weekWaste_getDetail.sql +++ /dev/null @@ -1,29 +0,0 @@ -USE `bs`; -DROP procedure IF EXISTS `weekWaste_getDetail`; - -DELIMITER $$ -USE `bs`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `weekWaste_getDetail`() -BEGIN - DECLARE vLastWeek DATE; - DECLARE vWeek INT; - DECLARE vYear INT; - - SET vLastWeek = TIMESTAMPADD(WEEK,-1,CURDATE()); - SET vYear = YEAR(vLastWeek); - SET vWeek = WEEK(vLastWeek, 1); - - SELECT *, 100 * dwindle / total AS percentage - FROM ( - SELECT buyer, - ws.family, - sum(ws.saleTotal) AS total, - sum(ws.saleWaste) AS dwindle - FROM bs.waste ws - WHERE year = vYear AND week = vWeek - GROUP BY buyer, family - ) sub - ORDER BY percentage DESC; -END$$ - -DELIMITER ; diff --git a/db/changes/10140-kings/00-worker_isWorking.sql b/db/changes/10140-kings/00-worker_isWorking.sql deleted file mode 100644 index b80d287e0..000000000 --- a/db/changes/10140-kings/00-worker_isWorking.sql +++ /dev/null @@ -1,32 +0,0 @@ -USE `vn`; -DROP function IF EXISTS `worker_isWorking`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` FUNCTION `worker_isWorking`(vWorkerFk INT) RETURNS tinyint(1) - READS SQL DATA -BEGIN -/** - * Comprueba si el trabajador está trabajando en el momento de la consulta - * @return Devuelve TRUE en caso de que este trabajando. Si se encuentra en un descanso devolverá FALSE - */ - DECLARE vLastIn DATETIME ; - - SELECT MAX(timed) INTO vLastIn - FROM vn.workerTimeControl - WHERE userFk = vWorkerFk AND - direction = 'in'; - - IF (SELECT MOD(COUNT(*),2) - FROM vn.workerTimeControl - WHERE userFk = vWorkerFk AND - timed >= vLastIn - ) THEN - RETURN TRUE; - ELSE - RETURN FALSE; - END IF; -END$$ - -DELIMITER ; - diff --git a/db/changes/10140-kings/01-order_confirmWithUser.sql b/db/changes/10140-kings/01-order_confirmWithUser.sql deleted file mode 100644 index c398edc4c..000000000 --- a/db/changes/10140-kings/01-order_confirmWithUser.sql +++ /dev/null @@ -1,240 +0,0 @@ - -DROP procedure IF EXISTS `hedera`.`order_confirmWithUser`; - -DELIMITER $$ -CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`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 !vOk THEN - CALL util.throw ('ORDER_EMPTY'); - END IF; - - -- Carga las fechas de salida de cada almacén - - CALL vn.zone_getShippedWarehouse (vDelivery, vAddress, vAgencyModeId); - - -- 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; - - 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; - - 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 ; - diff --git a/db/changes/10140-kings/01-tarifaComponentSerie.sql b/db/changes/10140-kings/01-tarifaComponentSerie.sql deleted file mode 100644 index acdae0b13..000000000 --- a/db/changes/10140-kings/01-tarifaComponentSerie.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE - OR REPLACE ALGORITHM = UNDEFINED - DEFINER = `root`@`%` - SQL SECURITY DEFINER -VIEW `bi`.`tarifa_componentes_series` AS - SELECT - `ct`.`id` AS `tarifa_componentes_series_id`, - `ct`.`type` AS `Serie`, - `ct`.`isBase` AS `base`, - `ct`.`isMargin` AS `margen` - FROM - `vn`.`componentType` `ct`; diff --git a/db/changes/10141-zoneDoCalc/00-ticket.sql b/db/changes/10141-zoneDoCalc/00-ticket.sql new file mode 100644 index 000000000..a756a11af --- /dev/null +++ b/db/changes/10141-zoneDoCalc/00-ticket.sql @@ -0,0 +1,19 @@ +ALTER TABLE `vn`.`ticket` +ADD COLUMN `zonePrice` DECIMAL(10,2) NULL DEFAULT NULL AFTER `collectionFk`, +ADD COLUMN `zoneBonus` DECIMAL(10,2) NULL DEFAULT NULL AFTER `zonePrice`, +ADD COLUMN `zoneClosure` TIME NULL AFTER `zoneBonus`; + +CREATE TABLE `vn`.`zoneCalcTicket` ( + `zoneFk` int(11) NOT NULL PRIMARY KEY, + CONSTRAINT `zoneCalcTicketfk_1` FOREIGN KEY (`zoneFk`) REFERENCES `vn`.`zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + +DROP EVENT IF EXISTS vn.`zone_doCalc`; +CREATE DEFINER=`root`@`%` EVENT vn.`zone_doCalc` + ON SCHEDULE EVERY 15 SECOND STARTS '2020-01-31 11:32:30' + ON COMPLETION PRESERVE ENABLE + DO CALL util.procNoOverlap('vn.zone_doCalc'); + +DROP TABLE `vn`.`zoneConfig`; + +DROP procedure IF EXISTS vn.`zoneClosure_recalc`; \ No newline at end of file diff --git a/db/changes/10141-zoneDoCalc/01-ticket_doCalc.sql b/db/changes/10141-zoneDoCalc/01-ticket_doCalc.sql new file mode 100644 index 000000000..d7538ff84 --- /dev/null +++ b/db/changes/10141-zoneDoCalc/01-ticket_doCalc.sql @@ -0,0 +1,56 @@ +USE `vn`; +DROP procedure IF EXISTS `zone_doCalc`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `zone_doCalc`() +proc: BEGIN +/** + * Updates ticket fields related with zone + */ + DECLARE vDone BOOL; + DECLARE vTicketFk INT; + DECLARE vShipped DATE; + DECLARE vZoneFk INT; + + DECLARE cCur CURSOR FOR + SELECT t.id, t.shipped, t.zoneFk + FROM zoneCalcTicket zct + JOIN ticket t ON t.zoneFk = zct.zoneFk + WHERE shipped >= CURDATE(); + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + OPEN cCur; + + myLoop: LOOP + SET vDone = FALSE; + FETCH cCur INTO vTicketFk, vShipped, vZoneFk; + + IF vDone THEN + LEAVE myLoop; + END IF; + + DROP TEMPORARY TABLE IF EXISTS tmp.zone; + CREATE TEMPORARY TABLE tmp.zone + (INDEX (id)) + ENGINE = MEMORY + SELECT vZoneFk id; + + CALL zone_getOptionsForShipment(vShipped, TRUE); + + UPDATE ticket t + LEFT JOIN tmp.zoneOption zo ON TRUE + SET zonePrice = zo.price, zoneBonus = zo.bonus, zoneClosure = zo.`hour` + WHERE t.id = vTicketFk; + + END LOOP; + + CLOSE cCur; + + DELETE FROM zoneCalcTicket; +END$$ + +DELIMITER ; + diff --git a/db/changes/10141-zoneDoCalc/02-insertPastTickets.sql b/db/changes/10141-zoneDoCalc/02-insertPastTickets.sql new file mode 100644 index 000000000..4314e5d7d --- /dev/null +++ b/db/changes/10141-zoneDoCalc/02-insertPastTickets.sql @@ -0,0 +1,62 @@ +USE `vn`; +DROP procedure IF EXISTS `zone_doCalcInitialize`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `zone_doCalcInitialize`() +proc: BEGIN +/** + * Initialize ticket + */ + DECLARE vDone BOOL; + DECLARE vTicketFk INT; + DECLARE vLanded DATE; + DECLARE vZoneFk INT; + + DECLARE cCur CURSOR FOR + SELECT t.id, t.landed, t.zoneFk + FROM ticket t + WHERE (zonePrice IS NULL OR zoneBonus IS NULL OR zoneClosure IS NULL) + AND landed >= '2019-01-01' AND shipped >= '2019-01-01' + GROUP BY landed, zoneFk; + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + OPEN cCur; + + myLoop: LOOP + SET vDone = FALSE; + FETCH cCur INTO vTicketFk, vLanded, vZoneFk; + + IF vDone THEN + LEAVE myLoop; + END IF; + + DROP TEMPORARY TABLE IF EXISTS tmp.zone; + CREATE TEMPORARY TABLE tmp.zone + (INDEX (id)) + ENGINE = MEMORY + SELECT vZoneFk id; + + CALL zone_getOptionsForLanding(vLanded, TRUE); + + UPDATE ticket t + LEFT JOIN tmp.zoneOption zo ON TRUE + SET zonePrice = zo.price, zoneBonus = zo.bonus, zoneClosure = zo.`hour` + WHERE t.zoneFk = vZoneFk AND landed = vLanded; + + UPDATE ticket t + LEFT JOIN vn.zone z ON z.id = t.zoneFk + SET zonePrice = z.price, zoneBonus = z.bonus, zoneClosure = z.`hour` + WHERE t.zonePrice IS NULL AND z.id = vZoneFk + AND landed >= '2019-01-01' AND shipped >= '2019-01-01'; + + END LOOP; + + CLOSE cCur; + + DELETE FROM zoneCalcTicket; +END$$ + +DELIMITER ; \ No newline at end of file diff --git a/db/changes/10141-zoneDoCalc/02-procNoOverlap.sql b/db/changes/10141-zoneDoCalc/02-procNoOverlap.sql new file mode 100644 index 000000000..253264ce9 --- /dev/null +++ b/db/changes/10141-zoneDoCalc/02-procNoOverlap.sql @@ -0,0 +1,30 @@ +USE `util`; +DROP procedure IF EXISTS `procNoOverlap`; + +DELIMITER $$ +USE `util`$$ +CREATE PROCEDURE `procNoOverlap` (procName VARCHAR(255)) +SQL SECURITY INVOKER +proc: BEGIN +/** + * call procedure without overlap + */ + DECLARE vIsChanged BOOL; + + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION + BEGIN + DO RELEASE_LOCK(procName); + RESIGNAL; + END; + + IF !GET_LOCK(procName, 0) THEN + LEAVE proc; + END IF; + + CALL exec(CONCAT('CALL ', procName)); + + DO RELEASE_LOCK(procName); +END$$ + +DELIMITER ; + diff --git a/db/changes/10141-zoneDoCalc/03-getOptionsForLanding.sql b/db/changes/10141-zoneDoCalc/03-getOptionsForLanding.sql new file mode 100644 index 000000000..e0f5f9a48 --- /dev/null +++ b/db/changes/10141-zoneDoCalc/03-getOptionsForLanding.sql @@ -0,0 +1,66 @@ +USE `vn`; +DROP procedure IF EXISTS `zone_getOptionsForLanding`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `zone_getOptionsForLanding`(vLanded DATE, vShowExpiredZones BOOLEAN) +BEGIN +/** + * Gets computed options for the passed zones and delivery date. + * + * @table tmp.zones(id) The zones ids + * @param vLanded The delivery date + * @return tmp.zoneOption The computed options + */ + DROP TEMPORARY TABLE IF EXISTS tmp.zoneOption; + CREATE TEMPORARY TABLE tmp.zoneOption + ENGINE = MEMORY + SELECT + zoneFk, + `hour`, + travelingDays, + price, + bonus, + TIMESTAMPADD(DAY, -travelingDays, vLanded) shipped + FROM ( + SELECT t.id zoneFk, + TIME(IFNULL(e.`hour`, z.`hour`)) `hour`, + IFNULL(e.travelingDays, z.travelingDays) travelingDays, + IFNULL(e.price, z.price) price, + IFNULL(e.bonus, z.bonus) bonus + FROM tmp.zone t + JOIN zone z ON z.id = t.id + JOIN zoneEvent e ON e.zoneFk = t.id + WHERE ( + e.`type` = 'day' + AND e.dated = vLanded + ) OR ( + e.`type` != 'day' + AND e.weekDays & (1 << WEEKDAY(vLanded)) + AND (e.`started` IS NULL OR vLanded >= e.`started`) + AND (e.`ended` IS NULL OR vLanded <= 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; + + DELETE t FROM tmp.zoneOption t + JOIN zoneExclusion e + ON e.zoneFk = t.zoneFk AND e.`dated` = vLanded; + + IF NOT vShowExpiredZones THEN + DELETE FROM tmp.zoneOption + WHERE shipped < CURDATE() + OR (shipped = CURDATE() AND CURTIME() > `hour`); + END IF; +END$$ + +DELIMITER ; \ No newline at end of file diff --git a/db/changes/10141-zoneDoCalc/03-rutasAnalyze.sql b/db/changes/10141-zoneDoCalc/03-rutasAnalyze.sql new file mode 100644 index 000000000..313f2f797 --- /dev/null +++ b/db/changes/10141-zoneDoCalc/03-rutasAnalyze.sql @@ -0,0 +1,171 @@ +USE `vn`; +DROP procedure IF EXISTS `rutasAnalyze`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `rutasAnalyze`(vYear INT, vMonth INT) +BEGIN + +/* Analiza los costes de las rutas de reparto y lo almacena en la tabla Rutas_Master +* +* PAK 15/4/2019 +*/ + + DELETE FROM bi.rutasBoard + WHERE year = vYear AND month = vMonth; + + -- Rellenamos la tabla con los datos de las rutas VOLUMETRICAS, especialmente con los bultos "virtuales" + INSERT INTO bi.rutasBoard(year, + month, + warehouse_id, + Id_Ruta, + Id_Agencia, + km, + Dia, + Fecha, + Bultos, + Matricula, + Tipo, + Terceros) + SELECT YEAR(r.created), + MONTH(r.created), + GREATEST(1,a.warehouseFk), + r.id, + r.agencyModeFk, + r.kmEnd - r.kmStart, + DAYNAME(r.created), + r.created, + SUM(sv.volume / ebv.m3), + v.numberPlate, + IF(ISNULL(`r`.`cost`), 'P', 'A'), + r.cost + FROM vn.route r + JOIN vn.ticket t ON t.routeFk = r.id + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk + LEFT JOIN vn.agency a ON a.id = am.agencyFk + LEFT JOIN vn.vehicle v ON v.id = r.vehicleFk + JOIN vn.saleVolume sv ON sv.ticketFk = t.id + JOIN vn.expeditionBoxVol ebv ON ebv.boxFk = 71 + WHERE YEAR(r.created) = vYear AND MONTH(r.created) = vMonth + AND z.isVolumetric + GROUP BY r.id; + + -- Rellenamos la tabla con los datos de las rutas NO VOLUMETRICAS, especialmente con los bultos "virtuales" + INSERT INTO bi.rutasBoard(year, + month, + warehouse_id, + Id_Ruta, + Id_Agencia, + km, + Dia, + Fecha, + Bultos, + Matricula, + Tipo, + Terceros) + SELECT YEAR(r.created), + MONTH(r.created), + GREATEST(1,a.warehouseFk), + r.id, + r.agencyModeFk, + r.kmEnd - r.kmStart, + DAYNAME(r.created), + r.created, + SUM(t.packages), + v.numberPlate, + IF(ISNULL(`r`.`cost`), 'P', 'A'), + r.cost + FROM vn.route r + JOIN vn.ticket t ON t.routeFk = r.id + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk + LEFT JOIN vn.agency a ON a.id = am.agencyFk + LEFT JOIN vn.vehicle v ON v.id = r.vehicleFk + WHERE YEAR(r.created) = vYear AND MONTH(r.created) = vMonth + AND z.isVolumetric = FALSE + GROUP BY r.id + ON DUPLICATE KEY UPDATE Bultos = Bultos + VALUES(Bultos); + + -- Coste REAL de cada bulto "virtual", de acuerdo con el valor apuntado a mano en la ruta + UPDATE bi.rutasBoard r + INNER JOIN vn2008.Rutas_Master rm ON rm.año = r.year AND rm.mes = r.month AND rm.warehouse_id = r.warehouse_id + SET r.coste_bulto = IF(r.Tipo ='A', r.Terceros, r.km * rm.coste_km ) / r.Bultos + WHERE r.Bultos > 0 + AND rm.año = vYear + AND rm.mes = vMonth; + + -- Coste PRACTICO de cada bulto, de acuerdo con los componentes de tipo AGENCIA en cada linea de venta + UPDATE bi.rutasBoard r + JOIN ( + SELECT t.routeFk, sum(s.quantity * sc.value) practicoTotal + FROM vn.route r + JOIN vn.time tm ON tm.dated = r.created + JOIN vn.ticket t ON t.routeFk = r.id + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.saleComponent sc ON sc.saleFk = s.id + JOIN vn.`component` c ON c.id = sc.componentFk + JOIN vn.componentType ct ON ct.id = c.typeFk + WHERE ct.type = 'agencia' + AND tm.year = vYear + AND tm.month = vMonth + GROUP BY r.id + ) sub ON sub.routeFk = r.Id_Ruta + SET r.practico = sub.practicoTotal / r.Bultos; + + -- Coste TEORICO de una caja "virtual" para cada ruta, teniendo en cuenta que hay carros, pallets, etc + UPDATE bi.rutasBoard r + JOIN ( + SELECT t.routeFk, + SUM(t.zonePrice/ ebv.ratio)/ count(*) AS BultoTeoricoMedio + FROM vn.ticket t + JOIN vn.route r ON r.id = t.routeFk + JOIN vn.time tm ON tm.dated = r.created + JOIN vn.expedition e ON e.ticketFk = t.id + JOIN vn.expeditionBoxVol ebv ON ebv.boxFk = e.isBox + JOIN vn.address ad ON ad.id = t.addressFk + JOIN vn.client c ON c.id = ad.clientFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk + WHERE tm.year = vYear + AND tm.month = vMonth + AND z.isVolumetric = FALSE + GROUP BY t.routeFk) sub ON r.Id_Ruta = sub.routeFk + SET r.teorico = sub.BultoTeoricoMedio; + + -- Coste VOLUMETRICO TEORICO de una caja "virtual" para cada ruta + UPDATE bi.rutasBoard r + JOIN ( + SELECT t.routeFk, + SUM(freight) AS BultoTeoricoMedio + FROM vn.ticket t + JOIN vn.route r ON r.id = t.routeFk + JOIN vn.time tm ON tm.dated = r.created + JOIN vn.saleVolume sf ON sf.ticketFk = t.id + JOIN vn.client c ON c.id = t.clientFk + JOIN vn.zone z ON z.id = t.zoneFk + WHERE tm.year = vYear + AND tm.month = vMonth + AND z.isVolumetric != FALSE + GROUP BY t.routeFk) sub ON r.Id_Ruta = sub.routeFk + SET r.teorico = sub.BultoTeoricoMedio / r.Bultos; + + -- La diferencia entre el teorico y el practico se deberia de cobrar en greuges, cada noche + UPDATE bi.rutasBoard r + JOIN ( + SELECT t.routeFk, + Sum(g.amount) AS greuge + FROM vn.ticket t + JOIN vn.route r ON r.id = t.routeFk + JOIN vn.time tm ON tm.dated = r.created + JOIN vn.greuge g ON g.ticketFk = t.id + JOIN vn.greugeType gt ON gt.id = g.greugeTypeFk + WHERE tm.year = vYear + AND tm.month = vMonth + AND gt.name = 'Diferencia portes' + GROUP BY t.routeFk) sub ON r.Id_Ruta = sub.routeFk + SET r.greuge = sub.greuge / r.Bultos; + +END$$ + +DELIMITER ; + diff --git a/db/changes/10141-zoneDoCalc/03-saleVolume.sql b/db/changes/10141-zoneDoCalc/03-saleVolume.sql new file mode 100644 index 000000000..2ded49a8d --- /dev/null +++ b/db/changes/10141-zoneDoCalc/03-saleVolume.sql @@ -0,0 +1,26 @@ +USE `vn`; +CREATE + OR REPLACE ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +VIEW `saleVolume` AS + SELECT + `s`.`ticketFk` AS `ticketFk`, + `s`.`id` AS `saleFk`, + IFNULL(ROUND(((((`i`.`compression` * (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`) * `i`.`compression`) / 1000000) AS `volume`, + ((((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) * (GREATEST(`i`.`density`, 167) / 167)) / 1000000) AS `physicalWeight`, + (((`s`.`quantity` * `ic`.`cm3`) * `i`.`density`) / 1000000) AS `weight`, + (((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) / 1000000) AS `physicalVolume`, + ((((`s`.`quantity` * `ic`.`cm3`) * `t`.`zonePrice`) * `i`.`compression`) / `cb`.`volume`) AS `freight` + 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`)))); diff --git a/db/changes/10141-zoneDoCalc/03-viewSaleFreight__.sql b/db/changes/10141-zoneDoCalc/03-viewSaleFreight__.sql new file mode 100644 index 000000000..903c8b48a --- /dev/null +++ b/db/changes/10141-zoneDoCalc/03-viewSaleFreight__.sql @@ -0,0 +1,24 @@ +DROP VIEW IF EXISTS `vn`.`saleFreight` ; +USE `vn`; +CREATE + OR REPLACE ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +VIEW `saleFreight__` AS + SELECT + `s`.`ticketFk` AS `ticketFk`, + `t`.`clientFk` AS `clientFk`, + `t`.`routeFk` AS `routeFk`, + `s`.`id` AS `saleFk`, + `t`.`zoneFk` AS `zoneFk`, + `t`.`companyFk` AS `companyFk`, + `t`.`shipped` AS `shipped`, + `t`.`zonePrice` AS `price`, + ((((`s`.`quantity` * `r`.`cm3`) * `t`.`zonePrice`) * `i`.`compression`) / `cb`.`volume`) AS `freight` + FROM + ((((`vn`.`sale` `s` + JOIN `vn`.`item` `i` ON ((`i`.`id` = `s`.`itemFk`))) + JOIN `vn`.`ticket` `t` ON ((`t`.`id` = `s`.`ticketFk`))) + JOIN `vn`.`packaging` `cb` ON ((`cb`.`id` = '94'))) + JOIN `bi`.`rotacion` `r` ON (((`r`.`Id_Article` = `s`.`itemFk`) + AND (`r`.`warehouse_id` = `t`.`warehouseFk`)))); diff --git a/db/changes/10141-zoneDoCalc/03-zone_geShippedWarehouse.sql b/db/changes/10141-zoneDoCalc/03-zone_geShippedWarehouse.sql new file mode 100644 index 000000000..14d5d8cd9 --- /dev/null +++ b/db/changes/10141-zoneDoCalc/03-zone_geShippedWarehouse.sql @@ -0,0 +1,41 @@ +USE `vn`; +DROP procedure IF EXISTS `zone_getShippedWarehouse`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `zone_getShippedWarehouse`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT) +BEGIN +/** + * Devuelve la mínima fecha de envío para cada warehouse + * + * @param vLanded La fecha de recepcion + * @param vAddressFk Id del consignatario + * @param vAgencyModeFk Id de la agencia + * @return tmp.zoneGetShipped + */ + + CALL zone_getFromGeo(address_getGeo(vAddressFk)); + CALL zone_getOptionsForLanding(vLanded,TRUE); + + DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetShipped; + CREATE TEMPORARY TABLE tmp.zoneGetShipped + ENGINE = MEMORY + SELECT * FROM ( + SELECT zo.zoneFk, + TIMESTAMPADD(DAY,-zo.travelingDays, vLanded) shipped, + zo.`hour`, + zw.warehouseFk, + z.agencyModeFk + FROM tmp.zoneOption zo + JOIN zoneWarehouse zw ON zw.zoneFk = zo.zoneFk + JOIN zone z ON z.id = zo.zoneFk + WHERE z.agencyModeFk = vAgencyModeFk + ORDER BY shipped) t + GROUP BY warehouseFk; + + DROP TEMPORARY TABLE + tmp.zone, + tmp.zoneOption; +END$$ + +DELIMITER ; \ No newline at end of file diff --git a/db/changes/10141-zoneDoCalc/03-zone_getAgency.sql b/db/changes/10141-zoneDoCalc/03-zone_getAgency.sql new file mode 100644 index 000000000..b2837d43c --- /dev/null +++ b/db/changes/10141-zoneDoCalc/03-zone_getAgency.sql @@ -0,0 +1,42 @@ +USE `vn`; +DROP procedure IF EXISTS `zone_getAgency`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `zone_getAgency`(vAddress INT, vLanded DATE) +BEGIN +/** + * Devuelve el listado de agencias disponibles para la fecha + * y dirección pasadas. + * + * @param vAddress Id de dirección de envío, %NULL si es recogida + * @param vLanded Fecha de recogida + * @select Listado de agencias disponibles + */ + + CALL zone_getFromGeo(address_getGeo(vAddress)); + CALL zone_getOptionsForLanding(vLanded, FALSE); + + DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetAgency; + CREATE TEMPORARY TABLE tmp.zoneGetAgency + (INDEX (agencyModeFk)) ENGINE = MEMORY + SELECT am.name agencyMode, + am.description, + z.agencyModeFk, + am.deliveryMethodFk, + TIMESTAMPADD(DAY,-zo.travelingDays, vLanded) shipped, + TRUE isIncluded, + zo.zoneFk + FROM tmp.zoneOption zo + JOIN zone z ON z.id = zo.zoneFk + JOIN agencyMode am ON am.id = z.agencyModeFk + GROUP BY agencyModeFk; + + DROP TEMPORARY TABLE + tmp.zone, + tmp.zoneOption; + +END$$ + +DELIMITER ; + diff --git a/db/changes/10141-zoneDoCalc/03-zone_getAvailable.sql b/db/changes/10141-zoneDoCalc/03-zone_getAvailable.sql new file mode 100644 index 000000000..2ef1a1ae9 --- /dev/null +++ b/db/changes/10141-zoneDoCalc/03-zone_getAvailable.sql @@ -0,0 +1,18 @@ +USE `vn`; +DROP procedure IF EXISTS `zone_getAvailable`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `zone_getAvailable`(vAddress INT, vLanded DATE) +BEGIN + CALL zone_getFromGeo(address_getGeo(vAddress)); + CALL zone_getOptionsForLanding(vLanded, FALSE); + + SELECT * FROM tmp.zoneOption; + + DROP TEMPORARY TABLE + tmp.zone, + tmp.zoneOption; +END$$ + +DELIMITER ; \ No newline at end of file diff --git a/db/changes/10141-zoneDoCalc/03-zone_getWarehouse.sql b/db/changes/10141-zoneDoCalc/03-zone_getWarehouse.sql new file mode 100644 index 000000000..c1cea8b13 --- /dev/null +++ b/db/changes/10141-zoneDoCalc/03-zone_getWarehouse.sql @@ -0,0 +1,41 @@ +USE `vn`; +DROP procedure IF EXISTS `zone_getWarehouse`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `zone_getWarehouse`(vAddress INT, vLanded DATE, vWarehouse INT) +BEGIN +/** + * Devuelve el listado de agencias disponibles para la fecha, + * dirección y almacén pasados. + * + * @param vAddress + * @param vWarehouse warehouse + * @param vLanded Fecha de recogida + * @select Listado de agencias disponibles + */ + + CALL zone_getFromGeo(address_getGeo(vAddress)); + CALL zone_getOptionsForLanding(vLanded, FALSE); + + SELECT am.id agencyModeFk, + am.name agencyMode, + am.description, + am.deliveryMethodFk, + TIMESTAMPADD(DAY, -zo.travelingDays, vLanded) shipped, + zw.warehouseFk, + z.id zoneFk + FROM tmp.zoneOption zo + JOIN zone z ON z.id = zo.zoneFk + JOIN agencyMode am ON am.id = z.agencyModeFk + JOIN zoneWarehouse zw ON zw.zoneFk = zo.zoneFk + WHERE zw.warehouseFk + GROUP BY z.agencyModeFk + ORDER BY agencyMode; + + DROP TEMPORARY TABLE + tmp.zone, + tmp.zoneOption; +END$$ + +DELIMITER ; \ No newline at end of file diff --git a/db/changes/10141-kings/00-ACL.sql b/db/changes/10142-kings/00-ACL.sql similarity index 100% rename from db/changes/10141-kings/00-ACL.sql rename to db/changes/10142-kings/00-ACL.sql diff --git a/db/changes/10141-kings/01-customsAgent.sql b/db/changes/10142-kings/01-customsAgent.sql similarity index 100% rename from db/changes/10141-kings/01-customsAgent.sql rename to db/changes/10142-kings/01-customsAgent.sql diff --git a/db/changes/10141-kings/02-incoterms.sql b/db/changes/10142-kings/02-incoterms.sql similarity index 100% rename from db/changes/10141-kings/02-incoterms.sql rename to db/changes/10142-kings/02-incoterms.sql diff --git a/db/changes/10141-kings/03-address.sql b/db/changes/10142-kings/03-address.sql similarity index 100% rename from db/changes/10141-kings/03-address.sql rename to db/changes/10142-kings/03-address.sql diff --git a/db/changes/10160-postValentineDay/00-ACL.sql b/db/changes/10160-postValentineDay/00-ACL.sql new file mode 100644 index 000000000..5b6301e3d --- /dev/null +++ b/db/changes/10160-postValentineDay/00-ACL.sql @@ -0,0 +1,2 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES ('Intrastat', '*', '*', 'ALLOW', 'ROLE', 'buyer'); diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql index 7e766195d..74290b451 100644 --- a/db/dump/dumpedFixtures.sql +++ b/db/dump/dumpedFixtures.sql @@ -23,7 +23,7 @@ USE `util`; LOCK TABLES `config` WRITE; /*!40000 ALTER TABLE `config` DISABLE KEYS */; -INSERT INTO `config` VALUES (1,'10121',0,'production',NULL); +INSERT INTO `config` VALUES (1,'10140',0,'production',NULL); /*!40000 ALTER TABLE `config` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -36,7 +36,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-01-23 14:05:01 +-- Dump completed on 2020-02-13 9:07:05 USE `account`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -61,7 +61,7 @@ USE `account`; LOCK TABLES `role` WRITE; /*!40000 ALTER TABLE `role` DISABLE KEYS */; -INSERT INTO `role` VALUES (0,'root','Rol con todos los privilegios',0,'2018-04-23 14:33:36','2018-04-23 14:33:59'),(1,'employee','Empleado básico',1,'2017-05-19 07:04:58','2017-11-29 10:06:31'),(2,'customer','Privilegios básicos de un cliente',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(3,'agency','Consultar tablas de predicciones de bultos',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(5,'administrative','Tareas relacionadas con la contabilidad',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(6,'guest','Privilegios para usuarios sin cuenta',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(9,'developer','Desarrolladores del sistema',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(11,'account','Privilegios relacionados con el login',0,'2017-05-19 07:04:58','2017-09-20 17:06:35'),(13,'teamBoss','Jefe de departamento',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(15,'logistic','Departamento de compras, responsables de la logistica',1,'2017-05-19 07:04:58','2018-02-12 10:50:10'),(16,'logisticBoss','Jefe del departamento de logística',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(17,'adminBoss','Jefe del departamento de administración',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(18,'salesPerson','Departamento de ventas',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(19,'salesBoss','Jefe del departamento de ventas',1,'2017-05-19 07:04:58','2017-08-16 12:38:27'),(20,'manager','Departamento de gerencia',1,'2017-06-01 14:57:02','2017-06-01 14:57:51'),(21,'salesAssistant','Jefe auxiliar de ventas',1,'2017-08-16 12:40:52','2017-08-16 12:40:52'),(22,'teamManager','Jefe de departamento con privilegios de auxiliar de venta.',1,'2017-09-07 09:08:12','2017-09-07 09:08:12'),(30,'financialBoss','Director finaciero',1,'2017-09-21 11:05:36','2017-09-21 11:05:36'),(31,'freelancer','Trabajadores por cuenta ajena',1,'2017-10-10 12:57:26','2017-10-10 12:59:27'),(32,'ett','Trabajadores de empresa temporal',1,'2017-10-10 12:58:58','2017-10-10 12:59:20'),(33,'invoicing','Personal con acceso a facturación',0,'2018-01-29 16:43:34','2018-01-29 16:43:34'),(34,'agencyBoss','Jefe/a del departamento de agencias',1,'2018-01-29 16:44:39','2018-02-23 07:58:53'),(35,'buyer','Departamento de compras',1,'2018-02-12 10:35:42','2018-02-12 10:35:42'),(36,'replenisher','Trabajadores de camara',1,'2018-02-16 14:07:10','2019-04-12 05:38:08'),(37,'hr','Gestor/a de recursos humanos',1,'2018-02-22 17:34:53','2018-02-22 17:34:53'),(38,'hrBoss','Jefe/a de recursos humanos',1,'2018-02-22 17:35:09','2018-02-22 17:35:09'),(39,'adminAssistant','Jefe auxiliar administrativo',1,'2018-02-23 10:37:36','2018-02-23 10:38:41'),(40,'handmade','Departamento de confección',1,'2018-02-23 11:14:53','2018-02-23 11:39:12'),(41,'handmadeBoss','Jefe de departamento de confección',1,'2018-02-23 11:15:09','2018-02-23 11:39:26'),(42,'artificial','Departamento de artificial',1,'2018-02-23 11:39:59','2018-02-23 11:39:59'),(43,'artificialBoss','Jefe del departamento de artificial',1,'2018-02-23 11:40:16','2018-02-23 11:40:16'),(44,'accessory','Departamento de complementos',1,'2018-02-23 11:41:12','2018-02-23 11:41:12'),(45,'accessoryBoss','Jefe del departamento de complementos',1,'2018-02-23 11:41:23','2018-02-23 11:41:23'),(47,'cooler','Empleados de cámara',1,'2018-02-23 13:08:18','2018-02-23 13:08:18'),(48,'coolerBoss','Jefe del departamento de cámara',1,'2018-02-23 13:12:01','2018-02-23 13:12:01'),(49,'production','Empleado de producción',0,'2018-02-26 15:28:23','2019-01-21 12:57:21'),(50,'productionBoss','Jefe de producción',1,'2018-02-26 15:34:12','2018-02-26 15:34:12'),(51,'marketing','Departamento de marketing',1,'2018-03-01 07:28:39','2018-03-01 07:28:39'),(52,'marketingBoss','Jefe del departamento de marketing',1,'2018-03-01 07:28:57','2018-03-01 07:28:57'),(53,'insurance','Gestor de seguros de cambio',0,'2018-03-05 07:44:35','2019-02-01 13:47:57'),(54,'itemPicker','Sacador en cámara',1,'2018-03-05 12:08:17','2018-03-05 12:08:17'),(55,'itemPickerBoss','Jefe de sacadores',1,'2018-03-05 12:08:31','2018-03-05 12:08:31'),(56,'delivery','Personal de reparto',1,'2018-05-30 06:07:02','2018-05-30 06:07:02'),(57,'deliveryBoss','Jefe de personal de reparto',1,'2018-05-30 06:07:19','2018-05-30 06:07:19'),(58,'packager','Departamento encajadores',1,'2019-01-21 12:43:45','2019-01-21 12:43:45'),(59,'packagerBoss','Jefe departamento encajadores',1,'2019-01-21 12:44:10','2019-01-21 12:44:10'),(60,'productionAssi','Tareas relacionadas con producción y administración',1,'2019-01-29 13:29:01','2019-01-29 13:29:01'),(61,'replenisherBos','Jefe de Complementos/Camara',1,'2019-07-01 06:44:07','2019-07-01 06:44:07'),(62,'noLogin','Role without login access to MySQL',0,'2019-07-01 06:50:19','2019-07-02 13:42:05'),(64,'balanceSheet','Consulta de Balance',0,'2019-07-16 12:12:08','2019-07-16 12:12:08'),(65,'officeBoss','Jefe de filial',1,'2019-08-02 06:54:26','2019-08-02 06:54:26'),(66,'sysadmin','Administrador de sistema',1,'2019-08-08 06:58:56','2019-08-08 06:58:56'),(67,'adminOfficer','categoria profesional oficial de administración',1,'2020-01-03 08:09:23','2020-01-03 08:09:23'); +INSERT INTO `role` VALUES (0,'root','Rol con todos los privilegios',0,'2018-04-23 14:33:36','2018-04-23 14:33:59'),(1,'employee','Empleado básico',1,'2017-05-19 07:04:58','2017-11-29 10:06:31'),(2,'customer','Privilegios básicos de un cliente',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(3,'agency','Consultar tablas de predicciones de bultos',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(5,'administrative','Tareas relacionadas con la contabilidad',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(6,'guest','Privilegios para usuarios sin cuenta',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(9,'developer','Desarrolladores del sistema',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(11,'account','Privilegios relacionados con el login',0,'2017-05-19 07:04:58','2017-09-20 17:06:35'),(13,'teamBoss','Jefe de departamento',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(15,'logistic','Departamento de compras, responsables de la logistica',1,'2017-05-19 07:04:58','2018-02-12 10:50:10'),(16,'logisticBoss','Jefe del departamento de logística',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(17,'adminBoss','Jefe del departamento de administración',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(18,'salesPerson','Departamento de ventas',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(19,'salesBoss','Jefe del departamento de ventas',1,'2017-05-19 07:04:58','2017-08-16 12:38:27'),(20,'manager','Departamento de gerencia',1,'2017-06-01 14:57:02','2017-06-01 14:57:51'),(21,'salesAssistant','Jefe auxiliar de ventas',1,'2017-08-16 12:40:52','2017-08-16 12:40:52'),(22,'teamManager','Jefe de departamento con privilegios de auxiliar de venta.',1,'2017-09-07 09:08:12','2017-09-07 09:08:12'),(30,'financialBoss','Director finaciero',1,'2017-09-21 11:05:36','2017-09-21 11:05:36'),(31,'freelancer','Trabajadores por cuenta ajena',1,'2017-10-10 12:57:26','2017-10-10 12:59:27'),(32,'ett','Trabajadores de empresa temporal',1,'2017-10-10 12:58:58','2017-10-10 12:59:20'),(33,'invoicing','Personal con acceso a facturación',0,'2018-01-29 16:43:34','2018-01-29 16:43:34'),(34,'agencyBoss','Jefe/a del departamento de agencias',1,'2018-01-29 16:44:39','2018-02-23 07:58:53'),(35,'buyer','Departamento de compras',1,'2018-02-12 10:35:42','2018-02-12 10:35:42'),(36,'replenisher','Trabajadores de camara',1,'2018-02-16 14:07:10','2019-04-12 05:38:08'),(37,'hr','Gestor/a de recursos humanos',1,'2018-02-22 17:34:53','2018-02-22 17:34:53'),(38,'hrBoss','Jefe/a de recursos humanos',1,'2018-02-22 17:35:09','2018-02-22 17:35:09'),(39,'adminAssistant','Jefe auxiliar administrativo',1,'2018-02-23 10:37:36','2018-02-23 10:38:41'),(40,'handmade','Departamento de confección',1,'2018-02-23 11:14:53','2018-02-23 11:39:12'),(41,'handmadeBoss','Jefe de departamento de confección',1,'2018-02-23 11:15:09','2018-02-23 11:39:26'),(42,'artificial','Departamento de artificial',1,'2018-02-23 11:39:59','2018-02-23 11:39:59'),(43,'artificialBoss','Jefe del departamento de artificial',1,'2018-02-23 11:40:16','2018-02-23 11:40:16'),(44,'accessory','Departamento de complementos',1,'2018-02-23 11:41:12','2018-02-23 11:41:12'),(45,'accessoryBoss','Jefe del departamento de complementos',1,'2018-02-23 11:41:23','2018-02-23 11:41:23'),(47,'cooler','Empleados de cámara',1,'2018-02-23 13:08:18','2018-02-23 13:08:18'),(48,'coolerBoss','Jefe del departamento de cámara',1,'2018-02-23 13:12:01','2018-02-23 13:12:01'),(49,'production','Empleado de producción',0,'2018-02-26 15:28:23','2019-01-21 12:57:21'),(50,'productionBoss','Jefe de producción',1,'2018-02-26 15:34:12','2018-02-26 15:34:12'),(51,'marketing','Departamento de marketing',1,'2018-03-01 07:28:39','2018-03-01 07:28:39'),(52,'marketingBoss','Jefe del departamento de marketing',1,'2018-03-01 07:28:57','2018-03-01 07:28:57'),(53,'insurance','Gestor de seguros de cambio',0,'2018-03-05 07:44:35','2019-02-01 13:47:57'),(54,'itemPicker','Sacador en cámara',1,'2018-03-05 12:08:17','2018-03-05 12:08:17'),(55,'itemPickerBoss','Jefe de sacadores',1,'2018-03-05 12:08:31','2018-03-05 12:08:31'),(56,'delivery','Personal de reparto',1,'2018-05-30 06:07:02','2018-05-30 06:07:02'),(57,'deliveryBoss','Jefe de personal de reparto',1,'2018-05-30 06:07:19','2018-05-30 06:07:19'),(58,'packager','Departamento encajadores',1,'2019-01-21 12:43:45','2019-01-21 12:43:45'),(59,'packagerBoss','Jefe departamento encajadores',1,'2019-01-21 12:44:10','2019-01-21 12:44:10'),(60,'productionAssi','Tareas relacionadas con producción y administración',1,'2019-01-29 13:29:01','2019-01-29 13:29:01'),(61,'replenisherBos','Jefe de Complementos/Camara',1,'2019-07-01 06:44:07','2019-07-01 06:44:07'),(62,'noLogin','Role without login access to MySQL',0,'2019-07-01 06:50:19','2019-07-02 13:42:05'),(64,'balanceSheet','Consulta de Balance',0,'2019-07-16 12:12:08','2019-07-16 12:12:08'),(65,'officeBoss','Jefe de filial',1,'2019-08-02 06:54:26','2019-08-02 06:54:26'),(66,'sysadmin','Administrador de sistema',1,'2019-08-08 06:58:56','2019-08-08 06:58:56'),(67,'adminOfficer','categoria profesional oficial de administración',1,'2020-01-03 08:09:23','2020-01-03 08:09:23'),(69,'coolerAssist','Empleado cámara con permiso compras',1,'2020-02-05 12:36:09','2020-02-05 12:36:09'); /*!40000 ALTER TABLE `role` ENABLE KEYS */; UNLOCK TABLES; @@ -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),(1,11),(2,11),(3,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),(30,22),(5,33),(34,33),(15,35),(41,35),(52,35),(65,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),(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); +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),(1,11),(2,11),(3,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),(30,22),(5,33),(34,33),(15,35),(41,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); /*!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),(1,1),(1,2),(1,3),(1,6),(1,11),(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),(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),(11,6),(11,11),(13,1),(13,2),(13,3),(13,6),(13,11),(13,13),(15,1),(15,2),(15,3),(15,6),(15,11),(15,13),(15,15),(15,35),(15,56),(15,57),(16,1),(16,2),(16,3),(16,6),(16,11),(16,13),(16,15),(16,16),(16,35),(16,56),(16,57),(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),(18,1),(18,2),(18,3),(18,6),(18,11),(18,18),(19,1),(19,2),(19,3),(19,6),(19,11),(19,13),(19,18),(19,19),(19,21),(19,53),(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),(21,1),(21,2),(21,3),(21,6),(21,11),(21,13),(21,18),(21,21),(21,53),(22,1),(22,2),(22,3),(22,6),(22,11),(22,13),(22,18),(22,21),(22,22),(22,53),(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),(31,1),(31,2),(31,3),(31,6),(31,11),(31,31),(32,1),(32,2),(32,3),(32,6),(32,11),(32,32),(33,33),(34,1),(34,2),(34,3),(34,6),(34,11),(34,13),(34,33),(34,34),(35,1),(35,2),(35,3),(35,6),(35,11),(35,35),(36,1),(36,2),(36,3),(36,6),(36,11),(36,36),(36,44),(36,47),(37,1),(37,2),(37,3),(37,6),(37,11),(37,37),(38,1),(38,2),(38,3),(38,6),(38,11),(38,37),(38,38),(38,64),(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),(40,1),(40,2),(40,3),(40,6),(40,11),(40,40),(41,1),(41,2),(41,3),(41,6),(41,11),(41,13),(41,35),(41,40),(41,41),(42,1),(42,2),(42,3),(42,6),(42,11),(42,42),(43,1),(43,2),(43,3),(43,6),(43,11),(43,13),(43,42),(43,43),(44,1),(44,2),(44,3),(44,6),(44,11),(44,44),(45,1),(45,2),(45,3),(45,6),(45,11),(45,13),(45,44),(45,45),(47,1),(47,2),(47,3),(47,6),(47,11),(47,47),(48,1),(48,2),(48,3),(48,6),(48,11),(48,13),(48,47),(48,48),(49,1),(49,2),(49,3),(49,6),(49,11),(49,36),(49,44),(49,47),(49,49),(49,58),(50,1),(50,2),(50,3),(50,6),(50,11),(50,13),(50,36),(50,44),(50,47),(50,49),(50,50),(50,56),(50,57),(50,58),(50,59),(51,1),(51,2),(51,3),(51,6),(51,11),(51,51),(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),(53,1),(53,2),(53,3),(53,6),(53,11),(53,53),(54,1),(54,2),(54,3),(54,6),(54,11),(54,54),(55,1),(55,2),(55,3),(55,6),(55,11),(55,13),(55,54),(55,55),(56,1),(56,2),(56,3),(56,6),(56,11),(56,56),(57,1),(57,2),(57,3),(57,6),(57,11),(57,13),(57,56),(57,57),(58,1),(58,2),(58,3),(58,6),(58,11),(58,58),(59,1),(59,2),(59,3),(59,6),(59,11),(59,13),(59,58),(59,59),(60,1),(60,2),(60,3),(60,5),(60,6),(60,11),(60,13),(60,18),(60,21),(60,33),(60,36),(60,37),(60,44),(60,47),(60,49),(60,50),(60,53),(60,56),(60,57),(60,58),(60,59),(60,60),(61,1),(61,2),(61,3),(61,6),(61,11),(61,13),(61,36),(61,44),(61,47),(61,61),(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),(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),(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); +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),(1,1),(1,2),(1,3),(1,6),(1,11),(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),(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),(11,6),(11,11),(13,1),(13,2),(13,3),(13,6),(13,11),(13,13),(15,1),(15,2),(15,3),(15,6),(15,11),(15,13),(15,15),(15,35),(15,56),(15,57),(16,1),(16,2),(16,3),(16,6),(16,11),(16,13),(16,15),(16,16),(16,35),(16,56),(16,57),(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),(18,1),(18,2),(18,3),(18,6),(18,11),(18,18),(19,1),(19,2),(19,3),(19,6),(19,11),(19,13),(19,18),(19,19),(19,21),(19,53),(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),(21,1),(21,2),(21,3),(21,6),(21,11),(21,13),(21,18),(21,21),(21,53),(22,1),(22,2),(22,3),(22,6),(22,11),(22,13),(22,18),(22,21),(22,22),(22,53),(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),(31,1),(31,2),(31,3),(31,6),(31,11),(31,31),(32,1),(32,2),(32,3),(32,6),(32,11),(32,32),(33,33),(34,1),(34,2),(34,3),(34,6),(34,11),(34,13),(34,33),(34,34),(35,1),(35,2),(35,3),(35,6),(35,11),(35,35),(36,1),(36,2),(36,3),(36,6),(36,11),(36,36),(36,44),(36,47),(37,1),(37,2),(37,3),(37,6),(37,11),(37,37),(38,1),(38,2),(38,3),(38,6),(38,11),(38,37),(38,38),(38,64),(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),(40,1),(40,2),(40,3),(40,6),(40,11),(40,40),(41,1),(41,2),(41,3),(41,6),(41,11),(41,13),(41,35),(41,40),(41,41),(42,1),(42,2),(42,3),(42,6),(42,11),(42,42),(43,1),(43,2),(43,3),(43,6),(43,11),(43,13),(43,42),(43,43),(44,1),(44,2),(44,3),(44,6),(44,11),(44,44),(45,1),(45,2),(45,3),(45,6),(45,11),(45,13),(45,44),(45,45),(47,1),(47,2),(47,3),(47,6),(47,11),(47,47),(48,1),(48,2),(48,3),(48,6),(48,11),(48,13),(48,47),(48,48),(49,1),(49,2),(49,3),(49,6),(49,11),(49,36),(49,44),(49,47),(49,49),(49,58),(50,1),(50,2),(50,3),(50,6),(50,11),(50,13),(50,36),(50,44),(50,47),(50,49),(50,50),(50,56),(50,57),(50,58),(50,59),(51,1),(51,2),(51,3),(51,6),(51,11),(51,51),(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),(53,1),(53,2),(53,3),(53,6),(53,11),(53,53),(54,1),(54,2),(54,3),(54,6),(54,11),(54,54),(55,1),(55,2),(55,3),(55,6),(55,11),(55,13),(55,54),(55,55),(56,1),(56,2),(56,3),(56,6),(56,11),(56,56),(57,1),(57,2),(57,3),(57,6),(57,11),(57,13),(57,56),(57,57),(58,1),(58,2),(58,3),(58,6),(58,11),(58,58),(59,1),(59,2),(59,3),(59,6),(59,11),(59,13),(59,58),(59,59),(60,1),(60,2),(60,3),(60,5),(60,6),(60,11),(60,13),(60,18),(60,21),(60,33),(60,36),(60,37),(60,44),(60,47),(60,49),(60,50),(60,53),(60,56),(60,57),(60,58),(60,59),(60,60),(61,1),(61,2),(61,3),(61,6),(61,11),(61,13),(61,36),(61,44),(61,47),(61,61),(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),(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),(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),(69,1),(69,2),(69,3),(69,6),(69,11),(69,35),(69,47),(69,69); /*!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-01-23 14:05:01 +-- Dump completed on 2020-02-13 9:07:05 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','employee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','employee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','employee'),(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','employee'),(30,'GreugeType','*','READ','ALLOW','ROLE','employee'),(31,'Mandate','*','READ','ALLOW','ROLE','employee'),(32,'MandateType','*','READ','ALLOW','ROLE','employee'),(33,'Company','*','READ','ALLOW','ROLE','employee'),(34,'Greuge','*','READ','ALLOW','ROLE','employee'),(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','employee'),(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','*','*','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','employee'),(111,'ClientLog','*','READ','ALLOW','ROLE','employee'),(112,'Defaulter','*','READ','ALLOW','ROLE','employee'),(113,'ClientRisk','*','READ','ALLOW','ROLE','employee'),(114,'Receipt','*','READ','ALLOW','ROLE','employee'),(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','employee'),(132,'CreditClassification','*','READ','ALLOW','ROLE','employee'),(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','employee'),(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','employee'),(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'); +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','employee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','employee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','employee'),(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','employee'),(30,'GreugeType','*','READ','ALLOW','ROLE','employee'),(31,'Mandate','*','READ','ALLOW','ROLE','employee'),(32,'MandateType','*','READ','ALLOW','ROLE','employee'),(33,'Company','*','READ','ALLOW','ROLE','employee'),(34,'Greuge','*','READ','ALLOW','ROLE','employee'),(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','employee'),(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','employee'),(111,'ClientLog','*','READ','ALLOW','ROLE','employee'),(112,'Defaulter','*','READ','ALLOW','ROLE','employee'),(113,'ClientRisk','*','READ','ALLOW','ROLE','employee'),(114,'Receipt','*','READ','ALLOW','ROLE','employee'),(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','employee'),(132,'CreditClassification','*','READ','ALLOW','ROLE','employee'),(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','employee'),(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','employee'),(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','*','*','ALLOW','ROLE','buyer'),(214,'Entry','*','*','ALLOW','ROLE','buyer'),(215,'TicketWeekly','*','WRITE','ALLOW','ROLE','buyer'),(216,'TravelThermograph','*','READ','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-01-23 14:05:01 +-- Dump completed on 2020-02-13 9:07:05 USE `vn`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -217,7 +217,7 @@ UNLOCK TABLES; LOCK TABLES `pgc` WRITE; /*!40000 ALTER TABLE `pgc` DISABLE KEYS */; -INSERT INTO `pgc` VALUES ('4722000000',0.00,'Importación Exento ',1,0,0,1),('4722000010',10.00,'Importación Reducido ',1,0,0,1),('4722000021',21.00,'Importación General ',1,0,0,1),('4770000001',8.00,'Reducido',1,1,1,1),('4770000002',0.00,'Extra-Community supply',3,1,0,2),('4770000004',4.00,'Super reducido',1,1,1,1),('4770000010',10.00,'Reducido',1,1,1,1),('4770000020',0.00,'Exento',7,1,1,1),('4770000021',21.00,'General',1,1,1,1),('4770000101',10.00,'Reducido ',1,1,1,1),('4770000108',8.00,'Reducido',1,1,1,1),('4770000110',1.40,'Rec. Eq. Reducido',1,0,0,1),('4770000215',21.00,'General',1,1,1,1),('4770000405',0.50,'Rec. Eq. Super Reducido',1,0,0,1),('4770000504',4.00,'Super reducido',1,1,1,1),('4770000521',5.20,'Rec. Eq. General',1,0,0,1),('4770000701',1.00,'Rec. Eq. Reducido',1,0,0,1),('4771000000',0.00,'Intra-Community supply',6,1,1,1),('4771000001',0.00,'Intra-Community services',7,1,1,1),('HolandaGEN',21.00,'General',1,0,0,1),('HolandaRED',9.00,'Reducido',1,0,0,1),('IGIC cero',0.00,'Cero',1,0,0,1),('IGIC gener',6.50,'General',1,0,0,1),('IGIC reduc',3.00,'Reducido',1,0,0,1); +INSERT INTO `pgc` VALUES ('4722000000',0.00,'Importación Exento ',1,0,0,1,0),('4722000010',10.00,'Importación Reducido ',1,0,0,1,0),('4722000021',21.00,'Importación General ',1,0,0,1,0),('4770000001',8.00,'Reducido',1,1,1,1,0),('4770000002',0.00,'Extra-Community supply',3,1,0,2,0),('4770000004',4.00,'Super reducido',1,1,1,1,0),('4770000010',10.00,'Reducido',1,1,1,1,0),('4770000020',0.00,'Exento',7,1,1,1,0),('4770000021',21.00,'General',1,1,1,1,0),('4770000101',10.00,'Reducido ',1,1,1,1,0),('4770000108',8.00,'Reducido',1,1,1,1,0),('4770000110',1.40,'Rec. Eq. Reducido',1,0,0,1,1),('4770000215',21.00,'General',1,1,1,1,0),('4770000405',0.50,'Rec. Eq. Super Reducido',1,0,0,1,1),('4770000504',4.00,'Super reducido',1,1,1,1,0),('4770000521',5.20,'Rec. Eq. General',1,0,0,1,1),('4770000701',1.00,'Rec. Eq. Reducido',1,0,0,1,1),('4771000000',0.00,'Intra-Community supply',6,1,1,1,0),('4771000001',0.00,'Intra-Community services',7,1,1,1,0),('HolandaGEN',21.00,'General',1,0,0,1,0),('HolandaRED',9.00,'Reducido',1,0,0,1,0),('IGIC cero',0.00,'Cero',1,0,0,1,0),('IGIC gener',6.50,'General',1,0,0,1,0),('IGIC reduc',3.00,'Reducido',1,0,0,1,0); /*!40000 ALTER TABLE `pgc` 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,'/'),(22,'COMPRAS',3,4,NULL,72,596,2,5,0,0,0,0,NULL,'/'),(23,'CAMARA',5,6,NULL,72,604,2,6,1,0,0,0,NULL,'/'),(31,'INFORMATICA',7,8,NULL,72,127,3,9,0,0,0,0,NULL,'/'),(34,'CONTABILIDAD',9,10,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/'),(35,'FINANZAS',11,12,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/'),(36,'LABORAL',13,14,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/'),(37,'PRODUCCION',15,24,NULL,72,230,3,11,0,0,0,4,NULL,'/'),(38,'SACADO',16,17,NULL,72,230,4,14,1,0,1,0,37,'/37/'),(39,'ENCAJADO',18,19,NULL,72,230,4,12,1,0,1,0,37,'/37/'),(41,'ADMINISTRACION',25,26,NULL,72,599,3,8,0,0,0,0,NULL,'/'),(43,'VENTAS',27,48,NULL,0,NULL,NULL,NULL,0,0,0,10,NULL,'/'),(44,'GERENCIA',49,50,NULL,72,300,2,7,0,0,0,0,NULL,'/'),(45,'LOGISTICA',51,52,NULL,72,596,3,19,0,0,0,0,NULL,'/'),(46,'REPARTO',20,21,NULL,72,659,3,10,0,0,1,0,37,'/37/'),(48,'ALMACENAJE',53,54,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/'),(49,'PROPIEDAD',55,56,NULL,72,1008,1,1,0,0,0,0,NULL,'/'),(52,'CARGA AEREA',57,58,NULL,72,163,4,28,0,0,0,0,NULL,'/'),(53,'MARKETING Y COMUNICACIÓN',59,60,NULL,72,1238,0,0,0,0,0,0,NULL,'/'),(54,'ORNAMENTALES',61,62,NULL,72,433,3,21,0,0,0,0,NULL,'/'),(55,'TALLER NATURAL',63,64,NULL,72,695,2,23,0,0,0,0,NULL,'/'),(56,'TALLER ARTIFICIAL',65,66,NULL,72,1780,2,24,0,0,0,0,NULL,'/'),(58,'CAMPOS',67,68,NULL,72,225,2,2,0,0,0,0,NULL,'/'),(59,'MANTENIMIENTO',69,70,NULL,72,1907,4,16,0,0,0,0,NULL,'/'),(60,'RECLAMACIONES',71,72,NULL,72,563,3,20,0,0,0,0,NULL,'/'),(61,'VNH',73,74,NULL,73,1297,3,17,0,0,0,0,NULL,'/'),(63,'VENTAS FRANCIA',28,29,NULL,72,277,2,27,0,0,1,0,43,'/43/'),(66,'VERDNAMADRID',75,76,NULL,72,163,3,18,0,0,0,0,NULL,'/'),(68,'COMPLEMENTOS',77,78,NULL,72,617,3,26,1,0,0,0,NULL,'/'),(69,'VERDNABARNA',79,80,NULL,74,432,3,22,0,0,0,0,NULL,'/'),(77,'PALETIZADO',22,23,NULL,72,230,4,15,1,0,1,0,37,'/37/'),(80,'EQUIPO J VALLES',30,31,NULL,72,693,3,4,0,0,1,0,43,'/43/'),(86,'LIMPIEZA',81,82,NULL,72,599,0,0,0,0,0,0,NULL,'/'),(89,'COORDINACION',83,84,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/'),(90,'TRAILER',85,86,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/'),(91,'ARTIFICIAL',87,88,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/'),(92,'EQUIPO SILVERIO',32,33,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/'),(93,'CONFECCION',89,90,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/'),(94,'EQUIPO J BROCAL',34,35,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/'),(95,'EQUIPO C ZAMBRANO',36,37,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/'),(96,'EQUIPO C LOPEZ',38,39,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/'),(97,'EQUIPO D SARRION',40,41,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/'),(98,'EQUIPO RODRIGO',42,43,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/'),(99,'EQUIPO MANOLI',44,45,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/'),(101,'EQUIPO J IBAÑEZ',46,47,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/'); +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',5,6,NULL,72,604,2,6,1,0,0,0,NULL,'/',NULL),(31,'INFORMATICA',7,8,NULL,72,127,3,9,0,0,0,0,NULL,'/','informatica'),(34,'CONTABILIDAD',9,10,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(35,'FINANZAS',11,12,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(36,'LABORAL',13,14,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(37,'PRODUCCION',15,24,NULL,72,230,3,11,0,0,0,4,NULL,'/',NULL),(38,'SACADO',16,17,NULL,72,230,4,14,1,0,1,0,37,'/37/',NULL),(39,'ENCAJADO',18,19,NULL,72,230,4,12,1,0,1,0,37,'/37/',NULL),(41,'ADMINISTRACION',25,26,NULL,72,599,3,8,0,0,0,0,NULL,'/',NULL),(43,'VENTAS',27,48,NULL,0,NULL,NULL,NULL,0,0,0,10,NULL,'/',NULL),(44,'GERENCIA',49,50,NULL,72,300,2,7,0,0,0,0,NULL,'/',NULL),(45,'LOGISTICA',51,52,NULL,72,596,3,19,0,0,0,0,NULL,'/',NULL),(46,'REPARTO',20,21,NULL,72,659,3,10,0,0,1,0,37,'/37/',NULL),(48,'ALMACENAJE',53,54,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(49,'PROPIEDAD',55,56,NULL,72,1008,1,1,0,0,0,0,NULL,'/',NULL),(52,'CARGA AEREA',57,58,NULL,72,163,4,28,0,0,0,0,NULL,'/',NULL),(53,'MARKETING Y COMUNICACIÓN',59,60,NULL,72,1238,0,0,0,0,0,0,NULL,'/',NULL),(54,'ORNAMENTALES',61,62,NULL,72,433,3,21,0,0,0,0,NULL,'/',NULL),(55,'TALLER NATURAL',63,64,NULL,72,695,2,23,0,0,0,0,NULL,'/',NULL),(56,'TALLER ARTIFICIAL',65,66,NULL,72,1780,2,24,0,0,0,0,NULL,'/',NULL),(58,'CAMPOS',67,68,NULL,72,225,2,2,0,0,0,0,NULL,'/',NULL),(59,'MANTENIMIENTO',69,70,NULL,72,1907,4,16,0,0,0,0,NULL,'/',NULL),(60,'RECLAMACIONES',71,72,NULL,72,563,3,20,0,0,0,0,NULL,'/',NULL),(61,'VNH',73,74,NULL,73,1297,3,17,0,0,0,0,NULL,'/',NULL),(63,'VENTAS FRANCIA',28,29,NULL,72,277,2,27,0,0,1,0,43,'/43/',NULL),(66,'VERDNAMADRID',75,76,NULL,72,163,3,18,0,0,0,0,NULL,'/',NULL),(68,'COMPLEMENTOS',77,78,NULL,72,617,3,26,1,0,0,0,NULL,'/',NULL),(69,'VERDNABARNA',79,80,NULL,74,432,3,22,0,0,0,0,NULL,'/',NULL),(77,'PALETIZADO',22,23,NULL,72,230,4,15,1,0,1,0,37,'/37/',NULL),(80,'EQUIPO J VALLES',30,31,NULL,72,693,3,4,0,0,1,0,43,'/43/','jvp_equipo'),(86,'LIMPIEZA',81,82,NULL,72,599,0,0,0,0,0,0,NULL,'/',NULL),(89,'COORDINACION',83,84,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL),(90,'TRAILER',85,86,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(91,'ARTIFICIAL',87,88,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL),(92,'EQUIPO SILVERIO',32,33,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','sdc_equipo'),(93,'CONFECCION',89,90,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(94,'EQUIPO J BROCAL',34,35,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jes_equipo'),(95,'EQUIPO C ZAMBRANO',36,37,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','czg_equipo'),(96,'EQUIPO C LOPEZ',38,39,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','cla_equipo'),(97,'EQUIPO D SARRION',40,41,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','dsr_equipo'),(98,'EQUIPO RODRIGO',42,43,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','rhr_equipo'),(99,'EQUIPO MANOLI',44,45,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','man_equipo'),(101,'EQUIPO J IBAÑEZ',46,47,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jmi_equipo'); /*!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-01-23 14:05:01 +-- Dump completed on 2020-02-13 9:07:05 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-01-23 14:05:01 +-- Dump completed on 2020-02-13 9:07:05 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-01-23 14:05:01 +-- Dump completed on 2020-02-13 9:07:06 USE `postgresql`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -491,7 +491,7 @@ UNLOCK TABLES; LOCK TABLES `professional_category` WRITE; /*!40000 ALTER TABLE `professional_category` DISABLE KEYS */; -INSERT INTO `professional_category` VALUES (1,'Mozos',5,1,27.5),(2,'Encargados',3,1,27.5),(4,'Comprador',3,1,27.5),(5,'Aux Administracion',NULL,1,27.5),(6,'Of Administracion',3,1,27.5),(7,'Jefe Administracion',2,1,27.5),(8,'Informatico',3,1,27.5),(9,'Directivo',1,0,27.5),(10,'Aux Ventas',4,1,27.5),(11,'Vendedor',4,1,27.5),(12,'Jefe de Ventas',4,0,27.5),(13,'Repartidor',5,1,27.5),(14,'Aprendices',NULL,1,27.5),(15,'Técnicos',2,1,27.5),(16,'Aux Florista',5,1,27.5),(17,'Florista',4,1,27.5),(18,'Jefe Floristas',2,1,27.5),(19,'Técnico marketing',3,1,27.5),(20,'Auxiliar marketing',4,1,27.5),(21,'Aux Informática',4,1,27.5),(22,'Peón agrícola',5,1,27.5),(23,'Oficial mantenimiento',4,1,27.5),(24,'Aux mantenimiento',5,1,27.5),(25,'Mozo Aeropuerto',5,1,27.5),(26,'Coordinador',2,1,27.5),(28,'Aux Logistica',4,1,27.5),(29,'Oficial Logistica',3,1,27.5),(30,'Subencargado',4,1,27.5); +INSERT INTO `professional_category` VALUES (1,'Mozos',5,1,27.5),(2,'Encargados',3,1,27.5),(4,'Comprador',3,1,27.5),(5,'Aux Administracion',NULL,1,27.5),(6,'Of Administracion',3,1,27.5),(7,'Jefe Administracion',2,1,27.5),(8,'Informatico',3,1,27.5),(9,'Directivo',1,0,27.5),(10,'Aux Ventas',4,1,27.5),(11,'Vendedor',4,1,27.5),(12,'Jefe de Ventas',4,0,27.5),(13,'Repartidor',5,1,27.5),(14,'Aprendices',NULL,1,27.5),(15,'Técnicos',2,1,27.5),(16,'Aux Florista',5,1,27.5),(17,'Florista',4,1,27.5),(18,'Jefe Floristas',2,1,27.5),(19,'Técnico marketing',3,1,27.5),(20,'Auxiliar marketing',4,1,27.5),(21,'Aux Informática',4,1,27.5),(22,'Peón agrícola',5,1,27.5),(23,'Oficial mantenimiento',4,1,27.5),(24,'Aux mantenimiento',5,1,27.5),(25,'Mozo Aeropuerto',5,1,27.5),(26,'Coordinador',2,1,27.5),(28,'Aux Logistica',4,1,27.5),(29,'Oficial Logistica',3,1,27.5),(30,'Subencargado',4,1,27.5),(31,'Conductor +3500kg',NULL,1,NULL); /*!40000 ALTER TABLE `professional_category` ENABLE KEYS */; UNLOCK TABLES; @@ -511,7 +511,7 @@ UNLOCK TABLES; LOCK TABLES `workcenter` WRITE; /*!40000 ALTER TABLE `workcenter` DISABLE KEYS */; -INSERT INTO `workcenter` VALUES (1,'Silla',20,1027,1),(2,'Mercaflor',19,NULL,NULL),(3,'Marjales',26,20008,NULL),(4,'VNH',NULL,NULL,3),(5,'Madrid',28,2852,5),(6,'Vilassar',88,88031,2),(7,'Tenerife',NULL,NULL,10); +INSERT INTO `workcenter` VALUES (1,'Silla',20,1030,1),(2,'Mercaflor',19,NULL,NULL),(3,'Marjales',26,20008,NULL),(4,'VNH',NULL,NULL,3),(5,'Madrid',28,2852,5),(6,'Vilassar',88,88031,2),(7,'Tenerife',NULL,NULL,10); /*!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-01-23 14:05:01 +-- Dump completed on 2020-02-13 9:07:06 diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 7b7651a9d..f7d5d94f1 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -35,7 +35,7 @@ INSERT INTO `vn`.`packagingConfig`(`upperGap`) UPDATE `account`.`role` SET id = 100 WHERE id = 0; INSERT INTO `account`.`user`(`id`,`name`, `nickname`, `password`,`role`,`active`,`email`, `lang`) - SELECT id, name, CONCAT(name, 'Nick'),MD5('nightmare'), id, 1, CONCAT(name, '@mydomain.com'), 'es' + SELECT id, name, CONCAT(name, 'Nick'),MD5('nightmare'), id, 1, CONCAT(name, '@mydomain.com'), 'EN' FROM `account`.`role` WHERE id <> 20 ORDER BY id; @@ -55,18 +55,18 @@ INSERT INTO `hedera`.`tpvConfig`(`id`, `currency`, `terminal`, `transactionType` INSERT INTO `account`.`user`(`id`,`name`,`nickname`, `password`,`role`,`active`,`email`,`lang`) VALUES - (101, 'BruceWayne', 'Bruce Wayne', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'BruceWayne@mydomain.com', 'es'), - (102, 'PetterParker', 'Petter Parker', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'PetterParker@mydomain.com', 'en'), - (103, 'ClarkKent', 'Clark Kent', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'ClarkKent@mydomain.com', 'fr'), - (104, 'TonyStark', 'Tony Stark', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'TonyStark@mydomain.com', 'es'), - (105, 'MaxEisenhardt', 'Max Eisenhardt', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'MaxEisenhardt@mydomain.com', 'pt'), - (106, 'DavidCharlesHaller', 'David Charles Haller', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'DavidCharlesHaller@mydomain.com', 'es'), - (107, 'HankPym', 'Hank Pym', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'HankPym@mydomain.com', 'es'), - (108, 'CharlesXavier', 'Charles Xavier', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'CharlesXavier@mydomain.com', 'es'), - (109, 'BruceBanner', 'Bruce Banner', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'BruceBanner@mydomain.com', 'es'), - (110, 'JessicaJones', 'Jessica Jones', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'JessicaJones@mydomain.com', 'es'), - (111, 'Missing', 'Missing', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'es'), - (112, 'Trash', 'Trash', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'es'); + (101, 'BruceWayne', 'Bruce Wayne', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'BruceWayne@mydomain.com', 'ES'), + (102, 'PetterParker', 'Petter Parker', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'PetterParker@mydomain.com', 'EN'), + (103, 'ClarkKent', 'Clark Kent', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'ClarkKent@mydomain.com', 'FR'), + (104, 'TonyStark', 'Tony Stark', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'TonyStark@mydomain.com', 'ES'), + (105, 'MaxEisenhardt', 'Max Eisenhardt', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'MaxEisenhardt@mydomain.com', 'PT'), + (106, 'DavidCharlesHaller', 'David Charles Haller', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'DavidCharlesHaller@mydomain.com', 'EN'), + (107, 'HankPym', 'Hank Pym', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'HankPym@mydomain.com', 'EN'), + (108, 'CharlesXavier', 'Charles Xavier', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'CharlesXavier@mydomain.com', 'EN'), + (109, 'BruceBanner', 'Bruce Banner', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'BruceBanner@mydomain.com', 'EN'), + (110, 'JessicaJones', 'Jessica Jones', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'JessicaJones@mydomain.com', 'EN'), + (111, 'Missing', 'Missing', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'EN'), + (112, 'Trash', 'Trash', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'EN'); INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`) VALUES @@ -684,8 +684,14 @@ INSERT INTO `vn`.`taxCode`(`id`, `dated`, `code`, `taxTypeFk`, `rate`, `equaliza INSERT INTO `vn`.`taxClass`(`id`, `description`, `code`) VALUES - (1, 'Reduced VAT','R'), + (1, 'Reduced VAT', 'R'), (2, 'General VAT', 'G'); + +INSERT INTO `vn`.`taxClassCode`(`taxClassFk`, `effectived`, `taxCodeFk`) + VALUES + (1, CURDATE(), 1), + (1, CURDATE(), 21), + (2, CURDATE(), 2); INSERT INTO `vn`.`intrastat`(`id`, `description`, `taxClassFk`, `taxCodeFk`) VALUES @@ -753,7 +759,7 @@ INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `pric (7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.44, 0, 0, 0, CURDATE()), (8, 4, 11, 'Melee weapon heavy shield 1x0.5m', 10, 1.79, 0, 0, 0, CURDATE()), (9, 1, 16, 'Ranged weapon longbow 2m', 1, 103.49, 0, 0, 0, CURDATE()), - (10, 2, 16, 'Melee weapon combat fist 15cm', 10, 7.08, 0, 0, 0, CURDATE()), + (10, 2, 16, 'Melee weapon combat fist 15cm', 10, 7.09, 0, 0, 0, CURDATE()), (11, 1, 16, 'Ranged weapon longbow 2m', 1, 103.49, 0, 0, 0, CURDATE()), (12, 4, 16, 'Melee weapon heavy shield 1x0.5m', 20, 1.71, 0, 0, 0, CURDATE()), (13, 2, 8, 'Melee weapon combat fist 15cm', 10, 7.08, 0, 0, 0, CURDATE()), @@ -814,25 +820,25 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) (8, 28, 1.25), (8, 29, 0.42), (8, 39, 0.017), + (9, 15, 3.0949), (9, 21, 0.001), - (9, 28, 50), - (9, 29, 49.4), + (9, 28, 53), + (9, 29, 46.4), (9, 39, 0.994), - (10, 15, 0.0111), - (10, 21, -0.001), - (10, 28, 5), - (10, 29, 2), + (10, 15, 0.0199), + (10, 28, 7), + (10, 29, 0), (10, 39, 0.07), (11, 15, 3.0949), (11, 21, 0.001), - (11, 28, 50), - (11, 29, 49.4), + (11, 28, 53), + (11, 29, 46.4), (11, 39, 0.994), (12, 15, 0.0199), (12, 21, 0.003), - (12, 28, 1.25), - (12, 29, 0.42), + (12, 28, 2.25), + (12, 29, -0.58), (12, 39, 0.017), (13, 15, 0.114), (13, 28, 5), @@ -1123,17 +1129,19 @@ 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); + (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); -INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `companyFk`, `ref`, `notes`, `evaNotes`) +INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `companyFk`, `ref`,`isInventory`, `isRaid`, `notes`, `evaNotes`) VALUES - (1, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 442, 'Movement 1', 'this is the note one', 'observation one'), - (2, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 442, 'Movement 2', 'this is the note two', 'observation two'), - (3, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 3, 442, 'Movement 3', 'this is the note three', 'observation three'), - (4, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 69, 'Movement 4', 'this is the note four', 'observation four'), - (5, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 442, 'Movement 5', 'this is the note five', 'observation five'), - (6, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 6, 442, 'Movement 6', 'this is the note six', 'observation six'), - (7, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 7, 442, 'Movement 7', 'this is the note seven', 'observation seven'); + (1, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 442, 'Movement 1', 0, 0, '', ''), + (2, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 442, 'Movement 2', 0, 0, 'this is the note two', 'observation two'), + (3, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 3, 442, 'Movement 3', 0, 0, 'this is the note three', 'observation three'), + (4, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 69, 'Movement 4', 0, 0, 'this is the note four', 'observation four'), + (5, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 442, 'Movement 5', 0, 0, 'this is the note five', 'observation five'), + (6, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 6, 442, 'Movement 6', 0, 0, 'this is the note six', 'observation six'), + (7, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 7, 442, 'Movement 7', 0, 0, 'this is the note seven', 'observation seven'), + (8, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 7, 442, 'Movement 8', 1, 1, '', ''); INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRate`, `priceIncreasing`, `packingRate`) VALUES diff --git a/db/dump/structure.sql b/db/dump/structure.sql index c78730381..35cb82fd4 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -3217,7 +3217,7 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `comercialesCompleto__`(IN vWorker INT, vDate DATE) BEGIN -CALL vn.subordinateGetList(vWorker); +CALL vn.worker_GetHierarchy(vWorker); SELECT c.Id_Cliente id_cliente, @@ -3323,9 +3323,9 @@ FROM WHERE (c.Id_Trabajador = vWorker OR tr.boss = vWorker) GROUP BY Id_Cliente) dead ON dead.Id_Cliente = c.Id_Cliente - JOIN tmp.subordinate s ON s.workerFk = c.Id_Trabajador; + JOIN tmp.workerHierarchyList s ON s.workerFk = c.Id_Trabajador; -DROP TEMPORARY TABLE tmp.subordinate; +DROP TEMPORARY TABLE tmp.workerHierarchyList; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -3583,6 +3583,36 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; ALTER DATABASE `bs` CHARACTER SET utf8 COLLATE utf8_unicode_ci ; +/*!50003 DROP PROCEDURE IF EXISTS `fruitsEvolution` */; +/*!50003 SET @saved_cs_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=`z-developer`@`%` PROCEDURE `fruitsEvolution`() +BEGIN +select Id_Cliente, + Cliente, count(semana) as semanas, (w.code IS NOT NULL) isWorker +from ( +select distinct v.Id_Cliente, c.name as Cliente, week(fecha, 3) as semana +from bs.ventas v +join vn.itemType it ON it.id = v.tipo_id +join vn.client c ON c.id = v.Id_Cliente +where it.categoryFk = 12 +and v.fecha > '2020-01-01') sub +left join vn.worker w ON w.id = sub.Id_Cliente +group by Id_Cliente; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_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 `indicatorsUpdate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4725,13 +4755,194 @@ 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 @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 + , 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); + + 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_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 = 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 `vendedores_add`(intYEAR INT, vQuarter INT) +CREATE DEFINER=`root`@`%` PROCEDURE `vendedores_add_launcher`() +BEGIN + + call bs.vendedores_add(YEAR(CURDATE()),QUARTER(CURDATE())); + + call bs.vendedores_evolution_add; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_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; @@ -4879,40 +5090,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 `vendedores_add_launcher` */; +/*!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 = 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 `vendedores_add_launcher`() -BEGIN - - call bs.vendedores_add(YEAR(CURDATE()),QUARTER(CURDATE())); - - call bs.vendedores_evolution_add; - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_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 = 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 `vendedores_add__`(intYEAR INT, vQuarter INT) +CREATE DEFINER=`root`@`%` PROCEDURE `vendedores_add___`(intYEAR INT, vQuarter INT) BEGIN DECLARE comisionRate DOUBLE DEFAULT 0.029; @@ -5573,9 +5761,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 ;; @@ -11666,20 +11854,20 @@ BEGIN -- Comprueba que se ha seleccionado una dirección IF vDeliveryMethod IN ('AGENCY', 'DELIVERY') - && vAddress IS NULL + AND vAddress IS NULL THEN CALL util.throw ('ORDER_EMPTY_ADDRESS'); END IF; -- Comprueba que la agencia es correcta - CALL vn.zoneGetAgency(vAddress, vLanded); + CALL vn.zone_getAgency(vAddress, vLanded); SELECT COUNT(*) > 0 INTO vIsAvailable FROM tmp.zoneGetAgency WHERE agencyModeFk = vAgencyMode; - IF !vIsAvailable THEN + IF NOT vIsAvailable THEN CALL util.throw ('ORDER_INVALID_AGENCY'); END IF; @@ -11719,9 +11907,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 ;; @@ -11918,8 +12106,7 @@ BEGIN (saleFk, componentFk, `value`) SELECT vSale, cm.component_id, cm.price FROM order_component cm - JOIN bi.tarifa_componentes tc - ON tc.Id_Componente = cm.component_id + JOIN vn.component c ON c.id = cm.component_id WHERE cm.order_row_id = vRowId GROUP BY vSale, cm.component_id; @@ -11938,12 +12125,9 @@ BEGIN ENGINE = MEMORY SELECT SUM(sc.`value`) valueSum, sc.saleFk FROM vn.saleComponent sc - JOIN bi.tarifa_componentes tc ON tc.Id_Componente = sc.componentFk - JOIN bi.tarifa_componentes_series tcs - ON tcs.tarifa_componentes_series_id = tc.tarifa_componentes_series_id - AND tcs.base - JOIN vn.sale s - ON s.id = sc.saleFk + 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; @@ -16604,6 +16788,37 @@ CREATE TABLE `debug` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Log de depuración'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `version` +-- + +DROP TABLE IF EXISTS `version`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `version` ( + `code` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `number` char(11) COLLATE utf8_unicode_ci NOT NULL, + `updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `versionUser` +-- + +DROP TABLE IF EXISTS `versionUser`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `versionUser` ( + `code` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `user` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `number` char(11) COLLATE utf8_unicode_ci NOT NULL, + `updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`code`,`user`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Dumping events for database 'util' -- @@ -17270,7 +17485,6 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `findObject` */; -ALTER DATABASE `util` CHARACTER SET utf8 COLLATE utf8_general_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -17292,6 +17506,77 @@ BEGIN */ SET vChain = CONCAT('%', vChain, '%'); + SELECT * FROM + ( + SELECT + `routine_schema` `schema`, + `routine_name` `name`, + `routine_type` `type`, + `routine_definition` `definition`, + `created`, + `last_altered` + FROM `information_schema`.`routines` + WHERE `routine_definition` LIKE vChain COLLATE utf8_general_ci + UNION ALL + SELECT + `event_schema`, + `event_name`, + 'EVENT', + `event_definition`, + `created`, + `last_altered` + FROM `information_schema`.`events` + WHERE `event_definition` LIKE vChain COLLATE utf8_general_ci + UNION ALL + SELECT + `EVENT_OBJECT_SCHEMA`, + `TRIGGER_NAME`, + 'TRIGGER', + `ACTION_STATEMENT`, + NULL, + NULL + FROM `information_schema`.`TRIGGERS` + WHERE `ACTION_STATEMENT` LIKE vChain COLLATE utf8_general_ci + UNION ALL + SELECT + `TABLE_SCHEMA`, + `TABLE_NAME`, + 'VIEW', + `VIEW_DEFINITION`, + NULL, + NULL + FROM `information_schema`.`VIEWS` + WHERE `VIEW_DEFINITION` LIKE vChain COLLATE utf8_general_ci + ) t + ORDER BY `schema`, `name`; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `findObject__` */; +/*!50003 SET @saved_cs_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 `findObject__`(vChain VARCHAR(45)) + READS SQL DATA +BEGIN +/** + * Devuelve un listado de todos los procedimientos, funciones + * eventos, disparadores y vistas que inluyen una cadena dada. + * + * @param vChain Cadena a buscar + * @select Listado de objetos + */ + SET vChain = CONCAT('%', vChain, '%'); + SELECT * FROM ( SELECT @@ -17341,7 +17626,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 */ ; -ALTER DATABASE `util` CHARACTER SET utf8 COLLATE utf8_unicode_ci ; /*!50003 DROP PROCEDURE IF EXISTS `proc_changedPrivs` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -17895,7 +18179,7 @@ CREATE TABLE `agencyMode` ( `cod71` tinyint(3) unsigned DEFAULT '0', `web` smallint(1) unsigned zerofill NOT NULL DEFAULT '0', `agencyFk` smallint(5) unsigned NOT NULL, - `agencyServiceFk` tinyint(4) NOT NULL DEFAULT '1', + `agencyServiceFk__` tinyint(4) NOT NULL DEFAULT '1', `inflation` decimal(5,2) NOT NULL DEFAULT '0.00' COMMENT 'Este valor se utiliza para aumentar el valor del componente porte.', `isVolumetric` tinyint(1) NOT NULL DEFAULT '0', `reportMail` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, @@ -18042,7 +18326,7 @@ CREATE TABLE `bank` ( `bank` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `account` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, `cash` smallint(6) NOT NULL DEFAULT '0', - `warehouseFk` smallint(5) unsigned NOT NULL DEFAULT '1', + `warehouseFk__` smallint(5) unsigned NOT NULL DEFAULT '1', `entityFk` int(10) unsigned NOT NULL, `isActive` tinyint(4) NOT NULL DEFAULT '1', `currencyFk` tinyint(3) unsigned DEFAULT '1', @@ -18516,7 +18800,8 @@ DROP TABLE IF EXISTS `chatConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `chatConfig` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `uri` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `host` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `api` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `user` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `password` varchar(50) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) @@ -18851,7 +19136,7 @@ CREATE TABLE `client` ( `fi` varchar(14) COLLATE utf8_unicode_ci DEFAULT NULL, `phone` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, `fax` varchar(11) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'obsoleta (comprobar)', - `email` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, + `email` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `cc` varchar(23) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'obsoleta (comprobar)', `dueDay` smallint(6) NOT NULL DEFAULT '5', `receipt` int(11) DEFAULT '1' COMMENT 'obsoleta', @@ -19497,7 +19782,7 @@ CREATE TABLE `collectionVolumetry` ( `level` int(10) unsigned NOT NULL DEFAULT '0', `lines` int(10) unsigned NOT NULL DEFAULT '1', `liters` int(10) unsigned NOT NULL DEFAULT '0', - `height` int(10) NOT NULL DEFAULT '20', + `height` int(10) unsigned NOT NULL DEFAULT '20', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -19607,7 +19892,7 @@ DROP TABLE IF EXISTS `componentType`; CREATE TABLE `componentType` ( `id` int(11) NOT NULL AUTO_INCREMENT, `type` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `base` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Marca aquellas series que se utilizan para calcular el precio base de las ventas, a efectos estadisticos', + `isBase` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Marca aquellas series que se utilizan para calcular el precio base de las ventas, a efectos estadisticos', `isMargin` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `Serie_UNIQUE` (`type`) @@ -19763,6 +20048,101 @@ CREATE TABLE `contactChannel` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Canal por el que nos ha conocido un cliente y se ha dado de'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `conveyor` +-- + +DROP TABLE IF EXISTS `conveyor`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `conveyor` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `typeFk` int(11) NOT NULL, + `stratum` int(11) NOT NULL DEFAULT '0', + `length` int(11) DEFAULT NULL, + `width` int(11) DEFAULT NULL, + `height` int(11) DEFAULT NULL, + `x` int(11) DEFAULT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `conveyor_fk1_idx` (`typeFk`), + CONSTRAINT `conveyor_fk1` FOREIGN KEY (`typeFk`) REFERENCES `conveyorType` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `conveyorBuildingClass` +-- + +DROP TABLE IF EXISTS `conveyorBuildingClass`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `conveyorBuildingClass` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `priority` int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tipo de caja para el montaje de pallets'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `conveyorConfig` +-- + +DROP TABLE IF EXISTS `conveyorConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `conveyorConfig` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `itemName` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `length` int(11) DEFAULT NULL, + `width` int(11) DEFAULT NULL, + `height` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `itemName_UNIQUE` (`itemName`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `conveyorExpedition` +-- + +DROP TABLE IF EXISTS `conveyorExpedition`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `conveyorExpedition` ( + `expeditionFk` int(11) NOT NULL, + `conveyorFk` int(11) DEFAULT NULL, + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `conveyorBuildingClassFk` int(11) NOT NULL, + `length` int(11) NOT NULL DEFAULT '1', + `width` int(11) NOT NULL DEFAULT '1', + `height` int(11) NOT NULL DEFAULT '1', + `x` int(11) NOT NULL DEFAULT '1', + `y` int(11) NOT NULL DEFAULT '1', + `routeFk` int(11) NOT NULL, + PRIMARY KEY (`expeditionFk`), + KEY `conveyorExpedition_fk1_idx` (`conveyorFk`), + KEY `conveyorExpedition_fk2_idx` (`conveyorBuildingClassFk`), + CONSTRAINT `conveyorExpedition_fk1` FOREIGN KEY (`conveyorFk`) REFERENCES `conveyor` (`id`) ON UPDATE CASCADE, + CONSTRAINT `conveyorExpedition_fk2` FOREIGN KEY (`conveyorBuildingClassFk`) REFERENCES `conveyorBuildingClass` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `conveyorType` +-- + +DROP TABLE IF EXISTS `conveyorType`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `conveyorType` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `country` -- @@ -20208,6 +20588,7 @@ CREATE TABLE `department` ( `sons` decimal(10,0) NOT NULL DEFAULT '0', `parentFk` int(10) unsigned DEFAULT NULL, `path` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `chatName` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name_UNIQUE` (`name`), KEY `fk_department_Trabajadores1_idx` (`workerFk`), @@ -21042,6 +21423,22 @@ CREATE TABLE `envialiaConfig` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `errorLogApp` +-- + +DROP TABLE IF EXISTS `errorLogApp`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `errorLogApp` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `error` varchar(55) COLLATE utf8_unicode_ci DEFAULT NULL, + `date` datetime DEFAULT NULL, + `workerFk` int(11) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Guarda un registro de errores e la app de almacén'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Temporary table structure for view `exchangeInsuranceEntry` -- @@ -21381,6 +21778,20 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +-- +-- Table structure for table `greugeConfig` +-- + +DROP TABLE IF EXISTS `greugeConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `greugeConfig` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `freightPickUpPrice` decimal(10,2) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `greugeType` -- @@ -21772,16 +22183,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_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 ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`invoiceOut_afterInsert` - AFTER INSERT ON `invoiceOut` FOR EACH ROW -BEGIN - CALL bi.customer_risk_update (NEW.clientFk, NEW.companyFk, NEW.amount); +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`invoiceOut_afterInsert` AFTER INSERT ON `vn`.`invoiceOut` FOR EACH ROW BEGIN + CALL clientRisk_update(NEW.clientFk, NEW.companyFk, NEW.amount); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -21791,17 +22200,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 = 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 ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`invoiceOut_beforeUpdate` - BEFORE UPDATE ON `invoiceOut` FOR EACH ROW +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`invoiceOut_beforeUpdate` BEFORE UPDATE ON `vn`.`invoiceOut` FOR EACH ROW BEGIN - CALL bi.customer_risk_update (OLD.clientFk, OLD.companyFk, -OLD.amount); - CALL bi.customer_risk_update (NEW.clientFk, NEW.companyFk, NEW.amount); + CALL clientRisk_update (OLD.clientFk, OLD.companyFk, -OLD.amount); + CALL clientRisk_update (NEW.clientFk, NEW.companyFk, NEW.amount); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -21811,16 +22219,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_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 ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`invoiceOut_beforeDelete` - BEFORE DELETE ON `invoiceOut` FOR EACH ROW -BEGIN - CALL bi.customer_risk_update (OLD.clientFk, OLD.companyFk, -OLD.amount); +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`invoiceOut_beforeDelete` BEFORE DELETE ON `invoiceOut` FOR EACH ROW BEGIN + CALL clientRisk_update (OLD.clientFk, OLD.companyFk, -OLD.amount); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -22366,6 +22772,23 @@ CREATE TABLE `itemFreeNumber` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `itemLabel` +-- + +DROP TABLE IF EXISTS `itemLabel`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemLabel` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `itemFk` int(11) DEFAULT NULL, + `itemName` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, + `price` decimal(10,2) DEFAULT NULL, + `labels` int(11) DEFAULT NULL COMMENT 'Tabla hecha para Ruben Espinosa, para sacar etiquetas en Holanda para un cliente.', + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `itemLog` -- @@ -22457,7 +22880,7 @@ CREATE TABLE `itemPlacementSupply` ( `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `userFk` int(10) unsigned NOT NULL COMMENT 'Persona que crea la orden', `repoUserFk` int(10) unsigned DEFAULT NULL COMMENT 'Reponedor que la tiene asignada', - `sectorFk` int(11) NOT NULL DEFAULT '2', + `sectorFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `itemPlacementSupply_fk1_idx` (`itemFk`), KEY `itemPlacementSupply_fk2_idx` (`userFk`), @@ -22492,33 +22915,6 @@ SET character_set_client = utf8; 1 AS `size`, 1 AS `workerCode`, 1 AS `repoCode`, - 1 AS `parking`, - 1 AS `sectorFk`*/; -SET character_set_client = @saved_cs_client; - --- --- Temporary table structure for view `itemPlacementSupplyList__` --- - -DROP TABLE IF EXISTS `itemPlacementSupplyList__`; -/*!50001 DROP VIEW IF EXISTS `itemPlacementSupplyList__`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `itemPlacementSupplyList__` AS SELECT - 1 AS `id`, - 1 AS `itemFk`, - 1 AS `quantity`, - 1 AS `priority`, - 1 AS `created`, - 1 AS `userFk`, - 1 AS `repoUserFk`, - 1 AS `saldo`, - 1 AS `longName`, - 1 AS `subName`, - 1 AS `size`, - 1 AS `workerCode`, - 1 AS `repoCode`, - 1 AS `parking`, 1 AS `sectorFk`*/; SET character_set_client = @saved_cs_client; @@ -22654,7 +23050,8 @@ SET character_set_client = utf8; 1 AS `packing`, 1 AS `hour`, 1 AS `isPreviousPreparable`, - 1 AS `physicalVolume`*/; + 1 AS `physicalVolume`, + 1 AS `warehouseFk`*/; SET character_set_client = @saved_cs_client; -- @@ -23211,6 +23608,18 @@ CREATE TABLE `itemVerdecora` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona nuestros articulos con los de Verdecora'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `kk` +-- + +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 +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `labourTree` -- @@ -23869,6 +24278,7 @@ CREATE TABLE `pgc` ( `mod340` tinyint(1) NOT NULL DEFAULT '0', `mod347` tinyint(1) NOT NULL DEFAULT '0', `cplusTrascendency477Fk` int(10) unsigned DEFAULT '1', + `isEqualizated` tinyint(1) DEFAULT '0', PRIMARY KEY (`code`), KEY `pgc_fk1_idx` (`cplusTaxBreakFk`), KEY `pgc_fk2_idx` (`cplusTrascendency477Fk`), @@ -24237,7 +24647,7 @@ CREATE TABLE `printServerQueue2` ( KEY `Id_Informe` (`reportFk`), KEY `Id_Prioridad` (`priorityFk`), KEY `Id_Trabajador` (`workerFk`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24512,14 +24922,14 @@ CREATE TABLE `receipt` ( /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!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 ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`receipt_afterInsert` AFTER INSERT ON `receipt` FOR EACH ROW - CALL bi.customer_risk_update (NEW.clientFk, NEW.companyFk, -NEW.amountPaid) */;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`receipt_afterInsert` AFTER INSERT ON `receipt` FOR EACH ROW + CALL clientRisk_update(NEW.clientFk, NEW.companyFk, -NEW.amountPaid) */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; @@ -24528,16 +24938,15 @@ 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 ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`receipt_beforeUpdate` BEFORE UPDATE ON `receipt` FOR EACH ROW -BEGIN - CALL bi.customer_risk_update (OLD.clientFk, OLD.companyFk, OLD.amountPaid); - CALL bi.customer_risk_update (NEW.clientFk, NEW.companyFk, -NEW.amountPaid); +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`receipt_beforeUpdate` BEFORE UPDATE ON `receipt` FOR EACH ROW BEGIN + CALL clientRisk_update(OLD.clientFk, OLD.companyFk, OLD.amountPaid); + CALL clientRisk_update(NEW.clientFk, NEW.companyFk, -NEW.amountPaid); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -24547,14 +24956,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_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 ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`receipt_beforeDelete` BEFORE DELETE ON `receipt` FOR EACH ROW - CALL bi.customer_risk_update (OLD.clientFk, OLD.companyFk, OLD.amountPaid) */;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`receipt_beforeDelete` BEFORE DELETE ON `receipt` FOR EACH ROW + CALL clientRisk_update(OLD.clientFk, OLD.companyFk, OLD.amountPaid) */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; @@ -24979,6 +25388,11 @@ BEGIN SET NEW.discount = 0; END IF; + IF old.discount > 0 AND NEW.discount = 0 THEN + INSERT INTO ticketLog + SET originFk = NEW.ticketFk, userFk = account.myUserGetId(), `action` = 'insert', + description = CONCAT('Cambio de descuento del item :', ' ', new.itemFk, ' de ', old.discount ,' a 0 '); + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -25422,9 +25836,12 @@ CREATE TABLE `shelving` ( `isPrinted` tinyint(4) NOT NULL DEFAULT '0', `priority` int(11) DEFAULT NULL, `parked` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `userFk` int(11) DEFAULT NULL, PRIMARY KEY (`code`), KEY `shelving_fk1_idx` (`parkingFk`), - CONSTRAINT `shelving_fk1` FOREIGN KEY (`parkingFk`) REFERENCES `parking` (`id`) ON DELETE SET NULL ON UPDATE CASCADE + KEY `shelving_fk2_idx` (`userFk`), + CONSTRAINT `shelving_fk1` FOREIGN KEY (`parkingFk`) REFERENCES `parking` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `shelving_fk2` FOREIGN KEY (`userFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tabla usada para localizar el carro en el parking del altillo'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -26144,6 +26561,10 @@ BEGIN SET NEW.landed = DATE_FORMAT(NEW.landed, '2000-%m-%d %T'); SET NEW.routeFk = NULL; END IF; + + IF NEW.routeFk AND NEW.isDeleted THEN + CALL util.throw ('This ticket is deleted'); + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -26212,8 +26633,8 @@ CREATE TABLE `ticketCollection` ( `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `level` int(11) DEFAULT NULL, PRIMARY KEY (`id`), + UNIQUE KEY `ticketCollection_fk2_idx` (`ticketFk`), KEY `ticketCollection_fk1_idx` (`collectionFk`), - KEY `ticketCollection_fk2_idx` (`ticketFk`), CONSTRAINT `ticketCollection_fk1` FOREIGN KEY (`collectionFk`) REFERENCES `collection` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketCollection_fk2` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -26261,8 +26682,14 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`ticketDms_beforeDelete` BEFORE DELETE ON `ticketDms` FOR EACH ROW BEGIN UPDATE dms - SET dmsTypeFk = (SELECT id FROM dmsType WHERE `code` = 'trash') - WHERE id = OLD.dmsFk; + SET dmsTypeFk = (SELECT id + FROM dmsType + WHERE `code` = 'trash' + ) + WHERE id = OLD.dmsFk AND ( SELECT IF(COUNT(*) > 0, FALSE, TRUE) + FROM ticketDms + WHERE dmsFk = OLD.dmsFk + ) ; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -27204,6 +27631,7 @@ DROP TABLE IF EXISTS `travelThermograph`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `travelThermograph` ( + `id` int(11) NOT NULL AUTO_INCREMENT, `thermographFk` varchar(45) COLLATE utf8_unicode_ci NOT NULL, `created` date NOT NULL, `warehouseFk` smallint(6) unsigned NOT NULL, @@ -27211,7 +27639,7 @@ CREATE TABLE `travelThermograph` ( `temperature` enum('COOL','WARM') COLLATE utf8_unicode_ci NOT NULL, `result` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `dmsFk` int(11) DEFAULT NULL, - PRIMARY KEY (`thermographFk`,`created`), + PRIMARY KEY (`id`), KEY `thermograph_fk_idx` (`thermographFk`), KEY `gestdoc_fk_idx` (`dmsFk`), KEY `travel_id` (`travelFk`), @@ -27220,7 +27648,7 @@ CREATE TABLE `travelThermograph` ( CONSTRAINT `travelThermographThermographFgn` FOREIGN KEY (`thermographFk`) REFERENCES `thermograph` (`id`) ON UPDATE CASCADE, CONSTRAINT `travelThermographTravelFgn` FOREIGN KEY (`travelFk`) REFERENCES `travel` (`id`), CONSTRAINT `travelThermographWarehouseFgn` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Registra cada termografo que se ha introducido en cada travel'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Registra cada termografo que se ha introducido en cada travel'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27505,7 +27933,6 @@ CREATE TABLE `worker` ( `birthed` date NOT NULL, `maritalStatus` enum('soltero/a','casado/a') COLLATE utf8_unicode_ci NOT NULL, `phone` varchar(9) COLLATE utf8_unicode_ci NOT NULL, - `companyFk` smallint(5) unsigned NOT NULL, `clientFk` int(11) DEFAULT NULL, `userFk` int(10) unsigned DEFAULT NULL, `bossFk` int(11) NOT NULL DEFAULT '2', @@ -27518,7 +27945,6 @@ CREATE TABLE `worker` ( UNIQUE KEY `Id_Cliente_Interno` (`clientFk`), KEY `sub` (`sub`), KEY `boss_idx` (`bossFk`), - KEY `empresa_id` (`companyFk`), CONSTRAINT `Clientes` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE, CONSTRAINT `worker_ibfk_1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -28016,14 +28442,14 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `workerTimeControl_Journey` +-- Temporary table structure for view `workerTimeControl_Journey__` -- -DROP TABLE IF EXISTS `workerTimeControl_Journey`; -/*!50001 DROP VIEW IF EXISTS `workerTimeControl_Journey`*/; +DROP TABLE IF EXISTS `workerTimeControl_Journey__`; +/*!50001 DROP VIEW IF EXISTS `workerTimeControl_Journey__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `workerTimeControl_Journey` AS SELECT +/*!50001 CREATE VIEW `workerTimeControl_Journey__` AS SELECT 1 AS `userFk`, 1 AS `dated`, 1 AS `Journey`, @@ -29226,14 +29652,15 @@ BEGIN LIMIT 1; -- Margen - INSERT INTO tmp.catalog_component (warehouseFk, itemFk, componentFk, cost) + -- No se aplica margen, cau 12589 +/* INSERT INTO tmp.catalog_component (warehouseFk, itemFk, componentFk, cost) SELECT vWarehouse, vItem, vComponentMargin, (vCost / ((100 - rate2) / 100)) - vCost FROM vn.rate WHERE dated <= CURDATE() AND warehouseFk = vWarehouse ORDER BY dated DESC LIMIT 1; - + */ -- Recobro INSERT INTO tmp.catalog_component (warehouseFk, itemFk, componentFk, cost) SELECT vWarehouse, vItem, vComponentRecovery, ROUND(LEAST(recobro,0.25), 3) @@ -32100,9 +32527,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 ;; @@ -32731,11 +33158,11 @@ BEGIN JOIN itemType it ON it.categoryFk = k.id JOIN item i ON i.typeFk = it.id WHERE i.id = vItemFk; - + IF vIsMerchandise THEN - REPLACE bi.rotacion SET - Id_Article = vItemFk, - warehouse_id = vWarehouse, + REPLACE itemCost SET + itemFk = vItemFk, + warehouseFk = vWarehouse, cm3 = buy_getUnitVolume(vSelf); END IF; @@ -32750,7 +33177,7 @@ BEGIN JOIN edi.supplier es ON es.supplier_id = be.pro WHERE b.id = vSelf; - IF vn2008.has_notify_passport(vItemFk, vSelf) THEN + IF buy_hasNotifyPassport(vSelf, vItemFk) THEN CALL vn.buy_notifyPassport(vSelf, vItemFk, vStickers, vPacking); END IF; END IF; @@ -33356,9 +33783,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 ;; @@ -33378,7 +33805,6 @@ proc: BEGIN * 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; @@ -33471,17 +33897,17 @@ proc: BEGIN GROUP BY tc.itemFk, warehouseFk; INSERT INTO tmp.ticketComponent - SELECT tcb.warehouseFk, tcb.itemFk, vRecoveryComponent, ROUND(tcb.base * LEAST(cr.recobro, 0.25), 3) + SELECT tcb.warehouseFk, tcb.itemFk, vRecoveryComponent, ROUND(tcb.base * LEAST(cr.priceIncreasing, 0.25), 3) FROM tmp.ticketComponentBase tcb - JOIN bi.claims_ratio cr ON cr.Id_Cliente = vClientFk - WHERE cr.recobro > 0.009; + 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 + prices_modifier_rate), 3) as manaAuto + 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 bs.mana_spellers ms ON c.salesPersonFk = ms.Id_Trabajador - WHERE ms.prices_modifier_activated + JOIN workerMana wm ON c.salesPersonFk = wm.workerFk + WHERE wm.isPricesModifierActivated HAVING manaAuto <> 0; INSERT INTO tmp.ticketComponent @@ -33490,7 +33916,7 @@ proc: BEGIN c.id, GREATEST(IFNULL(ROUND(tcb.base * c.tax, 4), 0), tcc.minPrice - tcc.rate3) FROM tmp.ticketComponentBase tcb - JOIN `component` c + 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; @@ -33509,7 +33935,7 @@ proc: BEGIN vGeneralInflationCoefficient * ROUND(( i.compression - * r.cm3 + * ic.cm3 * IF(am.deliveryMethodFk = 1, (GREATEST(i.density, vMinimumDensityWeight) / vMinimumDensityWeight), 1) * IFNULL((z.price - z.bonus) * 1/*amz.inflation*/ , 50)) / vBoxVolume, 4 @@ -33518,8 +33944,8 @@ proc: BEGIN JOIN item i ON i.id = tcc.itemFk JOIN zone z ON z.id = vZoneFk JOIN agencyMode am ON am.id = z.agencyModeFk - LEFT JOIN bi.rotacion r ON r.warehouse_id = tcc.warehouseFk - AND r.Id_Article = tcc.itemFk + LEFT JOIN itemCost ic ON ic.warehouseFk = tcc.warehouseFk + AND ic.itemFk = tcc.itemFk HAVING cost <> 0; IF (SELECT COUNT(*) FROM vn.addressForPackaging WHERE addressFk = vAddressFk) THEN @@ -33540,7 +33966,7 @@ proc: BEGIN vSpecialPriceComponent, sp.value - SUM(tcc.cost) sumCost FROM tmp.ticketComponentCopy tcc - JOIN `component` c ON c.id = tcc.componentFk + 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 @@ -33552,7 +33978,7 @@ proc: BEGIN ENGINE = MEMORY SELECT SUM(cost) sumCost, tc.itemFk, tc.warehouseFk, c.classRate FROM tmp.ticketComponent tc - JOIN `component` c ON c.id = tc.componentFk + JOIN component c ON c.id = tc.componentFk GROUP BY tc.itemFk, tc.warehouseFk, c.classRate; DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentRate; @@ -34569,6 +34995,34 @@ 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 `clientRisk_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 @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `clientRisk_update`(vClientId INT, vCompanyId INT, vAmount DECIMAL(10,2)) +BEGIN + IF vAmount IS NOT NULL + THEN + INSERT INTO clientRisk + SET + clientFk = vClientId, + companyFk = vCompanyId, + amount = vAmount + ON DUPLICATE KEY UPDATE + amount = amount + VALUES(amount); + 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 `clonTravelComplete` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -34786,18 +35240,20 @@ BEGIN sh.code COLLATE utf8_general_ci as shelving, ish.created, ish.visible, - IFNULL(p.pickingOrder,0) as `order`, + IFNULL(cpd.id,0) as `order`, IF(sc.isPreviousPreparedByPacking, ish.packing, g.`grouping`) as `grouping` FROM vn.ticketCollection tc JOIN vn.sale s ON s.ticketFk = tc.ticketFk JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk JOIN vn.shelving sh ON sh.code = ish.shelvingFk JOIN vn.parking p ON p.id = sh.parkingFk + LEFT JOIN vn.coolerPathDetail cpd ON CAST(cpd.hallway AS DECIMAL(3,0)) = p.column JOIN vn.sector sc ON sc.id = p.sectorFk JOIN vn.warehouse w ON w.id = sc.warehouseFk JOIN tmp.`grouping` g ON g.itemFk = s.itemFk WHERE tc.collectionFk = vCollectionFk AND w.aliasFk = vWarehouseAliasFk + AND ish.visible > 0 UNION ALL SELECT s.id as saleFk, s.itemFk, ip.code COLLATE utf8_general_ci as placement, @@ -34814,8 +35270,241 @@ BEGIN JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vCalcFk LEFT JOIN tmp.grouping2 g ON g.itemFk = s.itemFk WHERE tc.collectionFk = vCollectionFk - -- HAVING visible > 0 - ; + AND v.visible - p.quantity > 0 + AND IFNULL(cpd.id,0); + + DROP TEMPORARY TABLE + tmp.parked, + tmp.`grouping`, + tmp.grouping2; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_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 `collectionPlacement_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 `collectionPlacement_get_beta`(vCollectionFk INT) +BEGIN + + DECLARE vCalcFk INT; + DECLARE vWarehouseFk INT; + DECLARE vWarehouseAliasFk INT; + + SELECT t.warehouseFk, w.aliasFk + INTO vWarehouseFk, vWarehouseAliasFk + FROM vn.ticket t + JOIN vn.ticketCollection tc ON tc.ticketFk = t.id + JOIN vn.warehouse w ON w.id = t.warehouseFk + WHERE tc.collectionFk = vCollectionFk + LIMIT 1; + + CALL cache.visible_refresh(vCalcFk,FALSE,vWarehouseFk); + + DROP TEMPORARY TABLE IF EXISTS tmp.parked; + CREATE TEMPORARY TABLE tmp.parked + ENGINE MEMORY + SELECT s.itemFk, 0 as quantity + FROM vn.ticketCollection tc + JOIN vn.sale s ON s.ticketFk = tc.ticketFk + WHERE tc.collectionFk = vCollectionFk; + + UPDATE tmp.parked pk + JOIN ( SELECT itemFk, sum(visible) as visible + FROM vn.itemShelvingStock iss + JOIN vn.warehouse w ON w.id = iss.warehouseFk + WHERE w.aliasFk = vWarehouseAliasFk + GROUP BY iss.itemFk ) iss ON iss.itemFk = pk.itemFk + SET pk.quantity = iss.visible; + + DROP TEMPORARY TABLE IF EXISTS tmp.`grouping`; + CREATE TEMPORARY TABLE tmp.`grouping` + ENGINE MEMORY + SELECT itemFk, `grouping` + FROM ( + SELECT itemFk, + CASE groupingMode + WHEN 0 THEN 1 + WHEN 2 THEN packing + ELSE `grouping` + END AS `grouping` + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + WHERE tr.warehouseInFk = vWarehouseFk + AND landed BETWEEN (SELECT FechaInventario FROM vn2008.tblContadores LIMIT 1) AND CURDATE() + AND b.isIgnored = FALSE + ORDER BY tr.landed DESC + ) sub + GROUP BY sub.itemFk ; + + DROP TEMPORARY TABLE IF EXISTS tmp.grouping2; + CREATE TEMPORARY TABLE tmp.grouping2 + ENGINE MEMORY + SELECT * FROM tmp.`grouping`; + + SELECT s.id as saleFk, s.itemFk, + p.code COLLATE utf8_general_ci as placement , + sh.code COLLATE utf8_general_ci as shelving, + ish.created, + ish.visible, + IFNULL(cpd.id,0) as `order`, + IF(sc.isPreviousPreparedByPacking, ish.packing, g.`grouping`) as `grouping` + FROM vn.ticketCollection tc + JOIN vn.sale s ON s.ticketFk = tc.ticketFk + JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk + JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.parking p ON p.id = sh.parkingFk + LEFT JOIN vn.coolerPathDetail cpd ON CAST(cpd.hallway AS DECIMAL(3,0)) = p.column + JOIN vn.sector sc ON sc.id = p.sectorFk + JOIN vn.warehouse w ON w.id = sc.warehouseFk + JOIN tmp.`grouping` g ON g.itemFk = s.itemFk + WHERE tc.collectionFk = vCollectionFk + AND w.aliasFk = vWarehouseAliasFk + AND ish.visible > 0 + UNION ALL + SELECT s.id as saleFk, s.itemFk, + ip.code COLLATE utf8_general_ci as placement, + '' COLLATE utf8_general_ci as shelving, + modificationDate as created, + v.visible - p.quantity as visible, + IFNULL(cpd.id,0) as `order`, + g.`grouping` + FROM vn.ticketCollection tc + JOIN vn.sale s ON s.ticketFk = tc.ticketFk + JOIN vn.itemPlacement ip ON ip.itemFk = s.itemFk AND ip.warehouseFk = vWarehouseFk + LEFT JOIN vn.coolerPathDetail cpd ON cpd.hallway = LEFT(ip.`code`,3) + JOIN tmp.parked p ON p.itemFk = s.itemFk + JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vCalcFk + LEFT JOIN tmp.grouping2 g ON g.itemFk = s.itemFk + WHERE tc.collectionFk = vCollectionFk + AND v.visible - p.quantity > 0 + AND IFNULL(cpd.id,0); + + DROP TEMPORARY TABLE + tmp.parked, + tmp.`grouping`, + tmp.grouping2; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_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 `collectionPlacement_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 `collectionPlacement_get__`(vCollectionFk INT) +BEGIN + + DECLARE vCalcFk INT; + DECLARE vWarehouseFk INT; + DECLARE vWarehouseAliasFk INT; + + SELECT t.warehouseFk, w.aliasFk + INTO vWarehouseFk, vWarehouseAliasFk + FROM vn.ticket t + JOIN vn.ticketCollection tc ON tc.ticketFk = t.id + JOIN vn.warehouse w ON w.id = t.warehouseFk + WHERE tc.collectionFk = vCollectionFk + LIMIT 1; + + CALL cache.visible_refresh(vCalcFk,FALSE,vWarehouseFk); + + DROP TEMPORARY TABLE IF EXISTS tmp.parked; + CREATE TEMPORARY TABLE tmp.parked + ENGINE MEMORY + SELECT s.itemFk, 0 as quantity + FROM vn.ticketCollection tc + JOIN vn.sale s ON s.ticketFk = tc.ticketFk + WHERE tc.collectionFk = vCollectionFk; + + UPDATE tmp.parked pk + JOIN ( SELECT itemFk, sum(visible) as visible + FROM vn.itemShelvingStock iss + JOIN vn.warehouse w ON w.id = iss.warehouseFk + WHERE w.aliasFk = vWarehouseAliasFk + GROUP BY iss.itemFk ) iss ON iss.itemFk = pk.itemFk + SET pk.quantity = iss.visible; + + DROP TEMPORARY TABLE IF EXISTS tmp.`grouping`; + CREATE TEMPORARY TABLE tmp.`grouping` + ENGINE MEMORY + SELECT itemFk, `grouping` + FROM ( + SELECT itemFk, + CASE groupingMode + WHEN 0 THEN 1 + WHEN 2 THEN packing + ELSE `grouping` + END AS `grouping` + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + WHERE tr.warehouseInFk = vWarehouseFk + AND landed BETWEEN (SELECT FechaInventario FROM vn2008.tblContadores LIMIT 1) AND CURDATE() + AND b.isIgnored = FALSE + ORDER BY tr.landed DESC + ) sub + GROUP BY sub.itemFk ; + + DROP TEMPORARY TABLE IF EXISTS tmp.grouping2; + CREATE TEMPORARY TABLE tmp.grouping2 + ENGINE MEMORY + SELECT * FROM tmp.`grouping`; + + SELECT s.id as saleFk, s.itemFk, + p.code COLLATE utf8_general_ci as placement , + sh.code COLLATE utf8_general_ci as shelving, + ish.created, + ish.visible, + IFNULL(p.pickingOrder,0) as `order`, + IF(sc.isPreviousPreparedByPacking, ish.packing, g.`grouping`) as `grouping` + FROM vn.ticketCollection tc + JOIN vn.sale s ON s.ticketFk = tc.ticketFk + JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk + JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.parking p ON p.id = sh.parkingFk + JOIN vn.sector sc ON sc.id = p.sectorFk + JOIN vn.warehouse w ON w.id = sc.warehouseFk + JOIN tmp.`grouping` g ON g.itemFk = s.itemFk + WHERE tc.collectionFk = vCollectionFk + AND w.aliasFk = vWarehouseAliasFk + AND ish.visible > 0 + UNION ALL + SELECT s.id as saleFk, s.itemFk, + ip.code COLLATE utf8_general_ci as placement, + '' COLLATE utf8_general_ci as shelving, + modificationDate as created, + v.visible - p.quantity as visible, + IFNULL(cpd.hallway * 100,0) as `order`, + g.`grouping` + FROM vn.ticketCollection tc + JOIN vn.sale s ON s.ticketFk = tc.ticketFk + JOIN vn.itemPlacement ip ON ip.itemFk = s.itemFk AND ip.warehouseFk = vWarehouseFk + LEFT JOIN vn.coolerPathDetail cpd ON cpd.hallway = LEFT(ip.`code`,3) + JOIN tmp.parked p ON p.itemFk = s.itemFk + JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vCalcFk + LEFT JOIN tmp.grouping2 g ON g.itemFk = s.itemFk + WHERE tc.collectionFk = vCollectionFk + AND v.visible - p.quantity > 0 + AND IFNULL(cpd.id,0); DROP TEMPORARY TABLE tmp.parked, @@ -35035,6 +35724,238 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `collection_new`(vSectorFk INT) +proc:BEGIN + + DECLARE vIsPreviousPrepared BOOLEAN; + DECLARE vCollectionFk INT; + DECLARE vWarehouseFk INT; + DECLARE vMaxTickets INT DEFAULT 4; + DECLARE vStateFk INT; + DECLARE vFirstTicketFk INT; + DECLARE vWorkerCode VARCHAR(3); + DECLARE vShelve INT; + DECLARE vTicket INT; + + -- Establecemos el almacén y si es un sector de preparación previa, así como el estado para los tickets que se vayan preparando + SELECT isPreviousPrepared, warehouseFk + INTO vIsPreviousPrepared, vWarehouseFk + FROM vn.sector + WHERE id = vSectorFk; + + IF vIsPreviousPrepared THEN + + SELECT id INTO vStateFk + FROM vn.state + WHERE `code` = 'PREVIOUS_PREPARATION'; + ELSE + + SELECT id INTO vStateFk + FROM vn.state + WHERE `code` = 'ON_PREPARATION'; + + END IF; + + -- Obtenemos el código del usuario + SELECT w.code + INTO vWorkerCode + FROM vn.worker w + WHERE w.id = account.myUserGetId(); + + -- Se obtiene nº de colección y el buffer con los pedidos preparables + INSERT INTO vn.collection + SET workerFk = account.myUserGetId(); + + SELECT LAST_INSERT_ID() INTO vCollectionFk; + + CALL vn2008.production_control_source(vWarehouseFk, 0); + + -- Se seleccionan los primeros tickets, asignando colección para dejarlos bloqueados a otros sacadores. + INSERT IGNORE INTO vn.ticketCollection(ticketFk, collectionFk) + SELECT pb.Id_Ticket, + vCollectionFk + FROM tmp.production_buffer pb + JOIN vn.state s ON s.id = pb.state + WHERE pb.collectionFk IS NULL + AND (s.isPreparable OR (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode)) + ORDER BY (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) DESC, pb.Hora, pb.Minuto + LIMIT vMaxTickets; + + -- Creamos una tabla temporal con los datos que necesitamos para depurar la colección + DROP TEMPORARY TABLE IF EXISTS tmp.ticket; + CREATE TEMPORARY TABLE tmp.ticket + SELECT pb.Id_Ticket ticketFk, + pb.lines, + pb.m3 * 1000 liters, + 0 as height, + 0 as shelve + FROM tmp.production_buffer pb + JOIN vn.ticketCollection tc ON tc.ticketFk = pb.Id_Ticket + WHERE tc.collectionFk = vCollectionFk; + + /* El criterio para formar la colección es el siguiente: + * + * 1º.- Los tickets asignados son prioritarios, y por ello ya vienen ordenados en las primeras posiciones. + * 2º.- Las recogidas en Silla tienen que ir en carros independientes. + * + * Por tanto, si el primer pedido es recogida, nos olvidamos del resto. + * Si el primer pedido no es recogida, eliminamos las recogidas posteriores. + */ + + SELECT ticketFk + INTO vFirstTicketFk + FROM tmp.ticket + LIMIT 1; + + IF (SELECT pb.Agencia FROM tmp.production_buffer pb WHERE Id_Ticket = vFirstTicketFk) = 'REC_SILLA' THEN + + DELETE FROM tmp.ticket WHERE ticketFk != vFirstTicketFk; + + UPDATE tmp.ticket SET shelve = 1; + -- Como sólo hay un ticket, se le asigna el nivel 1 y acabamos + + ELSE + + -- Eliminamos los de recogida, puesto que el primero sabemos que no es de rec_silla + DELETE t.* + FROM tmp.ticket t + JOIN tmp.production_buffer pb ON pb.Id_Ticket = t.ticketFk + WHERE pb.Agencia = 'REC_SILLA'; + + -- Establece altura máxima por pedido, porque las plantas no se pueden recostar. + UPDATE tmp.ticket t + JOIN + ( SELECT MAX(i.size) maxHeigth, + tc.ticketFk + FROM vn.ticketCollection tc + JOIN vn.sale s ON s.ticketFk = tc.ticketFk + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + WHERE ic.isReclining = FALSE + AND tc.collectionFk = vCollectionFk + GROUP BY tc.ticketFk) sub ON sub.ticketFk = t.ticketFk + SET t.height = sub.maxHeigth; + + -- Vamos a generar una tabla con todas las posibilidades de asignacion de pedido + DROP TEMPORARY TABLE IF EXISTS tmp.ticketShelve; + CREATE TEMPORARY TABLE tmp.ticketShelve + SELECT ticketFk, shelve + FROM ( + SELECT t.ticketFk, + cv.`level` shelve, + CAST(cv.lines AS SIGNED) - t.lines as linesDif, + CAST(cv.liters AS SIGNED) - t.liters as litersDif, + CAST(cv.height AS SIGNED) - t.height as heightDif + FROM vn.collectionVolumetry cv + JOIN tmp.ticket t + ORDER BY (t.ticketFk = vFirstTicketFk) DESC, linesDif + ) sub + WHERE linesDif >= 0 + AND litersDif >= 0 + AND heightDif >= 0 + ORDER BY linesDif; + + -- Asignamos la primera balda util al primer pedido + SELECT IFNULL(shelve,0) INTO vShelve + FROM tmp.ticketShelve + WHERE ticketFk = vFirstTicketFk + LIMIT 1; + + IF vShelve THEN + + UPDATE tmp.ticket + SET shelve = vShelve + WHERE ticketFk = vFirstTicketFk; + + DELETE FROM tmp.ticketShelve + WHERE ticketFk = vFirstTicketFk + OR shelve = vShelve; + + WHILE (SELECT COUNT(*) FROM tmp.ticketShelve) DO + + SELECT ticketFk, shelve + INTO vTicket, vShelve + FROM tmp.ticketShelve + LIMIT 1; + + UPDATE tmp.ticket + SET shelve = vShelve + WHERE ticketFk = vTicket; + + DELETE FROM tmp.ticketShelve + WHERE ticketFk = vTicket + OR shelve = vShelve; + + END WHILE; + + ELSE + + UPDATE tmp.ticket + SET shelve = 1 + WHERE ticketFk = vFirstTicketFk; + + END IF; + + END IF; + + -- Eliminamos los que se han quedado sin balda + DELETE FROM tmp.ticket WHERE shelve = 0 ; + + -- Elimina los tickets bloqueados que no se van a preparar + DELETE tc.* + FROM vn.ticketCollection tc + LEFT JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk + WHERE tc.collectionFk = vCollectionFk + AND t.ticketFk IS NULL; + + -- Actualiza el estado de la colección + UPDATE vn.collection c + JOIN vn.state st ON st.code = 'ON_PREPARATION' + SET c.stateFk = st.id + WHERE c.id = vCollectionFk; + + -- Asigna las bandejas + UPDATE vn.ticketCollection tc + JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk + SET tc.level = t.shelve; + + -- Actualiza el estado de los tickets + INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) + SELECT vStateFk, ticketFk, account.myUserGetId() + FROM vn.ticketCollection tc + WHERE tc.collectionFk = vCollectionFk; + + -- Avisa los preparados previos que hay que bajar del altillo imprimiendo etiqueta + INSERT IGNORE INTO vn.ticketDown(ticketFk) + SELECT DISTINCT tc.ticketFk + FROM vn.ticketCollection tc + JOIN vncontrol.inter vi ON vi.Id_Ticket = tc.ticketFk + JOIN vn.state st ON st.id = vi.state_id + JOIN vn.ticket t ON t.id = tc.ticketFk + JOIN vn.warehouse w ON w.id = t.warehouseFk + WHERE tc.collectionFk = vCollectionFk + AND w.name = 'Silla FV' + AND st.code = 'PREVIOUS_PREPARATION'; + + SELECT vCollectionFk; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `collection_new__` */; +/*!50003 SET @saved_cs_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 `collection_new__`(vSectorFk INT) proc:BEGIN DECLARE vIsPreviousPrepared BOOLEAN; @@ -35078,6 +35999,14 @@ proc:BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + -- Reenvio a la version beta si el sector es el de pruebas + IF vSectorFk IN (17,18) THEN + + CALL vn.collection_new_beta(vSectorFk); + LEAVE proc; + + END IF; + SELECT isPreviousPrepared, warehouseFk INTO vIsPreviousPrepared, vWarehouseFk FROM vn.sector @@ -35130,6 +36059,7 @@ proc:BEGIN JOIN vn.state s ON s.id = pb.state LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = pb.Id_Ticket WHERE pb.problems = 0 + AND pb.Agencia = 'REC_SILLA' AND tc.ticketFk IS NULL AND (s.isPreparable OR (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode)) ORDER BY (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) DESC, pb.Hora, pb.Minuto, m3 DESC, pb.lines DESC @@ -35316,510 +36246,39 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `collection_new_beta` */; +/*!50003 DROP PROCEDURE IF EXISTS `collection_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 `collection_new_beta`(vSectorFk INT) -proc:BEGIN +CREATE DEFINER=`root`@`%` PROCEDURE `collection_update`(vTicketFk INT) +BEGIN + + DECLARE vNumChecked INT; + DECLARE vCollectionFk INT; - DECLARE vIsPreviousPrepared BOOLEAN; - DECLARE vCollectionFk INT; - DECLARE vWarehouseFk INT; - - DECLARE vTicketLiters INT; - DECLARE vTicketLines INT; - DECLARE vTicketFk INT; - DECLARE vTicketHeight INT; - DECLARE vTicketHeightTop INT; - DECLARE vTicketHeightFloor INT; - DECLARE vIsTicketCollected BOOLEAN; - DECLARE vMaxTickets INT; - DECLARE vStateFk INT; - DECLARE vTopTicketFk INT; - DECLARE vFloorTicketFk INT; - - DECLARE vVolumetryLiters INT; - DECLARE vVolumetryLines INT; - DECLARE vVolumetryFk INT; - DECLARE vVolumetryLevel INT; - DECLARE vVolumetryHeight INT; - DECLARE vVolumetryLitersMax INT; - DECLARE vVolumetryLinesMax INT; - DECLARE vVolumetryHeightTop INT; - DECLARE vVolumetryHeightFloor INT; - - DECLARE vDone BOOLEAN DEFAULT FALSE; - DECLARE vWorkerCode VARCHAR(3); - - DECLARE cVolumetry CURSOR FOR - SELECT level, liters, `lines`, height - FROM vn.collectionVolumetry - ORDER BY `level`; - - DECLARE cTicket CURSOR FOR - SELECT * - FROM tmp.ticket - ORDER BY height DESC; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - SELECT isPreviousPrepared, warehouseFk - INTO vIsPreviousPrepared, vWarehouseFk - FROM vn.sector - WHERE id = vSectorFk; - - SELECT w.code - INTO vWorkerCode - FROM vn.worker w - WHERE w.id = account.myUserGetId(); - - IF vIsPreviousPrepared THEN - - SELECT id INTO vStateFk - FROM vn.state - WHERE `code` = 'PREVIOUS_PREPARATION'; - ELSE - - SELECT id INTO vStateFk - FROM vn.state - WHERE `code` = 'ON_PREPARATION'; - - END IF; - - SELECT COUNT(*), sum(liters), sum(`lines`) - INTO vMaxTickets, vVolumetryLitersMax, vVolumetryLinesMax - FROM vn.collectionVolumetry; - - CALL vn2008.production_control_source(vWarehouseFk, 0); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket; - - -- Recogida Silla requiere carros individuales - - IF (SELECT pb.Agencia - FROM tmp.production_buffer pb - JOIN vn.state s ON s.id = pb.state - LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = pb.Id_Ticket - WHERE pb.problems = 0 - AND tc.ticketFk IS NULL - AND (s.isPreparable OR (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode)) - ORDER BY (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) DESC, pb.Hora, pb.Minuto, m3 DESC, pb.lines DESC - LIMIT 1) = 'REC_SILLA' THEN - - CREATE TEMPORARY TABLE tmp.ticket - SELECT pb.Id_Ticket ticketFk, - pb.lines, - pb.m3 * 1000 liters, - 0 as height - FROM tmp.production_buffer pb - JOIN vn.state s ON s.id = pb.state - LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = pb.Id_Ticket - WHERE pb.problems = 0 - AND tc.ticketFk IS NULL - AND (s.isPreparable OR (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode)) - ORDER BY (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) DESC, pb.Hora, pb.Minuto, m3 DESC, pb.lines DESC - LIMIT 1; - - ELSE - - CREATE TEMPORARY TABLE tmp.ticket - SELECT pb.Id_Ticket ticketFk, - pb.lines, - pb.m3 * 1000 liters, - 0 as height - FROM tmp.production_buffer pb - JOIN vn.state s ON s.id = pb.state - LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = pb.Id_Ticket - WHERE pb.problems = 0 - AND pb.Agencia != 'REC_SILLA' - AND tc.ticketFk IS NULL - AND (s.isPreparable OR (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode)) - ORDER BY (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) DESC, pb.Hora, pb.Minuto, m3 DESC, pb.lines DESC - LIMIT vMaxTickets; - - -- Establece altura máxima por pedido, porque las plantas no se pueden recostar. - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket2; - CREATE TEMPORARY TABLE tmp.ticket2 - SELECT MAX(i.size) maxHeigth, t.ticketFk - FROM tmp.ticket t - JOIN vn.sale s ON s.ticketFk = t.ticketFk - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.itemCategory ic ON ic.id = it.categoryFk - WHERE ic.isReclining = FALSE - GROUP BY t.ticketFk; - - UPDATE tmp.ticket t - JOIN tmp.ticket2 t2 ON t2.ticketFk = t.ticketFk - SET t.height = t2.maxHeigth; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket2; - -- Si hay un ticket con una planta que supera la máxima altura para la bandeja superior, el pedido ha de ser único. Por tanto, eliminamos el resto. - -- Si hay dos tickets con plantas que superen la medida inferior, el carro llevará una bandeja. Hay que eliminar los otros dos. - - SELECT height, ticketFk - INTO vTicketHeightTop, vTopTicketFk - FROM tmp.ticket - ORDER BY height DESC - LIMIT 1; - - SELECT max(height) - INTO vVolumetryHeightTop - FROM vn.collectionVolumetry; - - SELECT height, ticketFk - INTO vTicketHeightFloor, vFloorTicketFk - FROM tmp.ticket - WHERE ticketFk != vTopTicketFk - ORDER BY height DESC - LIMIT 1; - - SELECT height - INTO vVolumetryHeightFloor - FROM vn.collectionVolumetry - WHERE level = 1; - - IF vTicketHeightTop > vVolumetryHeightTop - OR vTicketHeightFloor > vVolumetryHeightFloor THEN - - DELETE FROM tmp.ticket WHERE ticketFk != vTopTicketFk; - - ELSEIF vTicketHeightFloor <= vVolumetryHeightFloor THEN - - DELETE FROM tmp.ticket WHERE ticketFk NOT IN (vTopTicketFk, vFloorTicketFk); - - END IF; - - - + /*SI TODAS LOS TICKETS DE UNA COLECCIÓN ESTAN REVISADOS CAMBIADOS ESTADO COLECCIÓN*/ + SELECT collectionFk + INTO vCollectionFk + FROM vn.ticketCollection + WHERE ticketFk = vTicketFk; + + IF (SELECT COUNT(*) + FROM vn.ticketCollection tc + JOIN vn.ticketLastState tls ON tls.ticketFk = tc.ticketFk + WHERE tc.collectionFk = vCollectionFk + AND (name = 'Preparación' OR name = 'En Revisión' OR name = 'Impreso' OR name = 'Preparado') ) = 0 THEN + + UPDATE vn.collection + SET stateFk = (SELECT id FROM vn.state WHERE code = 'PREPARED') + WHERE id = vCollectionFk; END IF; - - - -- Empieza el bucle - OPEN cVolumetry; - OPEN cTicket; - - FETCH cTicket INTO vTicketFk, vTicketLines, vTicketLiters, vTicketHeight; - FETCH cVolumetry INTO vVolumetryLevel, vVolumetryLiters, vVolumetryLines, vVolumetryHeight; - - IF NOT vDone THEN - - INSERT INTO vn.collection - SET workerFk = account.myUserGetId(); - - SELECT LAST_INSERT_ID() INTO vCollectionFk; - - END IF; - - bucle:WHILE NOT vDone DO - - IF (vVolumetryLitersMax < vTicketLiters OR vVolumetryLinesMax < vTicketLines) AND vVolumetryLevel > 1 THEN - - LEAVE bucle; - - END IF; - - SELECT COUNT(*) INTO vIsTicketCollected - FROM vn.ticketCollection - WHERE ticketFk = vTicketFk - AND collectionFk = vCollectionFk; - - IF vIsTicketCollected THEN - - UPDATE vn.ticketCollection - SET level = CONCAT(level, vVolumetryLevel) - WHERE ticketFk = vTicketFk - AND collectionFk = vCollectionFk; - - ELSE - - INSERT INTO vn.ticketCollection - SET collectionFk = vCollectionFk, - ticketFk = vTicketFk, - level = vVolumetryLevel; - - INSERT INTO vncontrol.inter - SET state_id = vStateFk, - Id_Ticket = vTicketFk, - Id_Trabajador = account.myUserGetId(); - - END IF; - - SET vVolumetryLitersMax = GREATEST(0,vVolumetryLitersMax - vVolumetryLiters); - SET vVolumetryLinesMax = GREATEST(0,vVolumetryLinesMax - vVolumetryLines); - SET vTicketLiters = GREATEST(0,vTicketLiters - vVolumetryLiters); - SET vTicketLines = GREATEST(0,vTicketLines - vVolumetryLines); - - IF vVolumetryLitersMax = 0 OR vVolumetryLinesMax = 0 THEN - - LEAVE bucle; - - END IF; - - IF vTicketLiters > 0 OR vTicketLines > 0 THEN - - FETCH cVolumetry INTO vVolumetryLevel, vVolumetryLiters, vVolumetryLines, vVolumetryHeight; - - ELSE - - FETCH cTicket INTO vTicketFk, vTicketLines, vTicketLiters, vTicketHeight; - FETCH cVolumetry INTO vVolumetryLevel, vVolumetryLiters, vVolumetryLines, vVolumetryHeight; - - END IF; - - END WHILE; - - - UPDATE vn.collection c - JOIN vn.state st ON st.code = 'ON_PREPARATION' - SET c.stateFk = st.id - WHERE c.id = vCollectionFk; - - INSERT IGNORE INTO vn.ticketDown(ticketFk) - SELECT DISTINCT tc.ticketFk - FROM vn.ticketCollection tc - JOIN vncontrol.inter vi ON vi.Id_Ticket = tc.ticketFk - JOIN vn.state st ON st.id = vi.state_id - JOIN vn.ticket t ON t.id = tc.ticketFk - JOIN vn.warehouse w ON w.id = t.warehouseFk - WHERE tc.collectionFk = vCollectionFk - AND w.name = 'Silla FV' - AND st.code = 'PREVIOUS_PREPARATION'; - - - SELECT vCollectionFk; - - CLOSE cVolumetry; - CLOSE cTicket; - -- DROP TEMPORARY TABLE IF EXISTS tmp.ticket; - -- DROP TEMPORARY TABLE IF EXISTS 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 `collection_new__` */; -/*!50003 SET @saved_cs_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 `collection_new__`(vSectorFk INT) -proc:BEGIN - - DECLARE vIsPreviousPrepared BOOLEAN; - DECLARE vCollectionFk INT; - DECLARE vWarehouseFk INT; - DECLARE vTicketLiters INT; - DECLARE vTicketLines INT; - DECLARE vTicketFk INT; - DECLARE vIsTicketCollected BOOLEAN; - DECLARE vMaxTickets INT; - DECLARE vStateFk INT; - DECLARE vVolumetryLiters INT; - DECLARE vVolumetryLines INT; - DECLARE vVolumetryFk INT; - DECLARE vVolumetryLevel INT; - DECLARE vVolumetryLitersMax INT; - DECLARE vVolumetryLinesMax INT; - DECLARE vDone BOOLEAN DEFAULT FALSE; - DECLARE vWorkerCode VARCHAR(3); - - DECLARE cVolumetry CURSOR FOR - SELECT level, liters, `lines` - FROM vn.collectionVolumetry - ORDER BY `level`; - - DECLARE cTicket CURSOR FOR - SELECT * - FROM tmp.ticket; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - SELECT isPreviousPrepared, warehouseFk - INTO vIsPreviousPrepared, vWarehouseFk - FROM vn.sector - WHERE id = vSectorFk; - - SELECT w.code - INTO vWorkerCode - FROM vn.worker w - WHERE w.id = account.myUserGetId(); - - IF vIsPreviousPrepared THEN - - SELECT id INTO vStateFk - FROM vn.state - WHERE `code` = 'PREVIOUS_PREPARATION'; - ELSE - - SELECT id INTO vStateFk - FROM vn.state - WHERE `code` = 'ON_PREPARATION'; - - END IF; - - SELECT COUNT(*), sum(liters), sum(`lines`) - INTO vMaxTickets, vVolumetryLitersMax, vVolumetryLinesMax - FROM vn.collectionVolumetry; - - CALL vn2008.production_control_source(vWarehouseFk, 0); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket; - - IF (SELECT pb.Agencia - FROM tmp.production_buffer pb - JOIN vn.state s ON s.id = pb.state - LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = pb.Id_Ticket - WHERE pb.problems = 0 - AND tc.ticketFk IS NULL - AND (s.isPreparable OR (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode)) - ORDER BY (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) DESC, pb.Hora, pb.Minuto, m3 DESC, pb.lines DESC - LIMIT 1) = 'REC_SILLA' THEN - - CREATE TEMPORARY TABLE tmp.ticket - SELECT pb.Id_Ticket ticketFk, - pb.lines, - pb.m3 * 1000 liters - FROM tmp.production_buffer pb - JOIN vn.state s ON s.id = pb.state - LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = pb.Id_Ticket - WHERE pb.problems = 0 - AND tc.ticketFk IS NULL - AND (s.isPreparable OR (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode)) - ORDER BY (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) DESC, pb.Hora, pb.Minuto, m3 DESC, pb.lines DESC - LIMIT 1; - - ELSE - - CREATE TEMPORARY TABLE tmp.ticket - SELECT pb.Id_Ticket ticketFk, - pb.lines, - pb.m3 * 1000 liters - FROM tmp.production_buffer pb - JOIN vn.state s ON s.id = pb.state - LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = pb.Id_Ticket - WHERE pb.problems = 0 - AND pb.Agencia != 'REC_SILLA' - AND tc.ticketFk IS NULL - AND (s.isPreparable OR (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode)) - ORDER BY (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) DESC, pb.Hora, pb.Minuto, m3 DESC, pb.lines DESC - LIMIT vMaxTickets; - - END IF; - - -- Empieza el bucle - OPEN cVolumetry; - OPEN cTicket; - - FETCH cTicket INTO vTicketFk, vTicketLines, vTicketLiters; - FETCH cVolumetry INTO vVolumetryLevel, vVolumetryLiters, vVolumetryLines; - - IF NOT vDone THEN - - INSERT INTO vn.collection - SET workerFk = account.myUserGetId(); - - SELECT LAST_INSERT_ID() INTO vCollectionFk; - - END IF; - - bucle:WHILE NOT vDone DO - - IF (vVolumetryLitersMax < vTicketLiters OR vVolumetryLinesMax < vTicketLines) AND vVolumetryLevel > 1 THEN - - LEAVE bucle; - - END IF; - - SELECT COUNT(*) INTO vIsTicketCollected - FROM vn.ticketCollection - WHERE ticketFk = vTicketFk - AND collectionFk = vCollectionFk; - - IF vIsTicketCollected THEN - - UPDATE vn.ticketCollection - SET level = CONCAT(level, vVolumetryLevel) - WHERE ticketFk = vTicketFk - AND collectionFk = vCollectionFk; - - ELSE - - INSERT INTO vn.ticketCollection - SET collectionFk = vCollectionFk, - ticketFk = vTicketFk, - level = vVolumetryLevel; - - INSERT INTO vncontrol.inter - SET state_id = vStateFk, - Id_Ticket = vTicketFk, - Id_Trabajador = account.myUserGetId(); - - END IF; - - SET vVolumetryLitersMax = GREATEST(0,vVolumetryLitersMax - vVolumetryLiters); - SET vVolumetryLinesMax = GREATEST(0,vVolumetryLinesMax - vVolumetryLines); - SET vTicketLiters = GREATEST(0,vTicketLiters - vVolumetryLiters); - SET vTicketLines = GREATEST(0,vTicketLines - vVolumetryLines); - - IF vVolumetryLitersMax = 0 OR vVolumetryLinesMax = 0 THEN - - LEAVE bucle; - - END IF; - - IF vTicketLiters > 0 OR vTicketLines > 0 THEN - - FETCH cVolumetry INTO vVolumetryLevel, vVolumetryLiters, vVolumetryLines; - - ELSE - - FETCH cTicket INTO vTicketFk, vTicketLines, vTicketLiters; - FETCH cVolumetry INTO vVolumetryLevel, vVolumetryLiters, vVolumetryLines; - - END IF; - - END WHILE; - - - UPDATE vn.collection c - JOIN vn.state st ON st.code = 'ON_PREPARATION' - SET c.stateFk = st.id - WHERE c.id = vCollectionFk; - - INSERT IGNORE INTO vn.ticketDown(ticketFk) - SELECT DISTINCT tc.ticketFk - FROM vn.ticketCollection tc - JOIN vncontrol.inter vi ON vi.Id_Ticket = tc.ticketFk - JOIN vn.state st ON st.id = vi.state_id - JOIN vn.ticket t ON t.id = tc.ticketFk - JOIN vn.warehouse w ON w.id = t.warehouseFk - WHERE tc.collectionFk = vCollectionFk - AND w.name = 'Silla FV' - AND st.code = 'PREVIOUS_PREPARATION'; - - - SELECT vCollectionFk; - - CLOSE cVolumetry; - CLOSE cTicket; - DROP TEMPORARY TABLE IF EXISTS tmp.ticket; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -37815,7 +38274,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `getItemUbication`(vItemFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `getItemUbication`(vItemFk VARCHAR(22)) BEGIN SELECT vn.barcodeToItem(vItemFk) INTO vItemFk; @@ -41882,28 +42341,22 @@ 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 `itemShelvingMake`(IN `vShelvingFk` VARCHAR(8), IN `vBarcode` VARCHAR(22), IN `vShelve` VARCHAR(2), IN `vDeep` INT, IN `vQuantity` INT, IN `vPackagingFk` VARCHAR(10), IN `vGrouping` INT, IN `vPacking` INT, IN `vWarehouseFk` INT, IN `vLevel` INT) BEGIN - - DECLARE vItemFk INT; - - - + SELECT vn.barcodeToItem(vBarcode) INTO vItemFk; - - SELECT itemFk INTO vItemFk + /*SELECT itemFk INTO vItemFk FROM vn.buy b - WHERE b.id = vItemFk; - + WHERE b.id = vItemFk;*/ IF (SELECT COUNT(*) FROM vn.shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN @@ -41915,8 +42368,6 @@ BEGIN END IF; - - IF (SELECT COUNT(*) FROM vn.itemShelving WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk @@ -42474,9 +42925,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 ;; @@ -42497,12 +42948,12 @@ BEGIN LIMIT 1; UPDATE vn.itemShelving - SET quantity = quantity - ( vPacking * vQuantity ), - visible = visible - ( vPacking * vQuantity ), - available = available - ( vPacking * vQuantity ) - WHERE shelvingFk = shelvingFkO COLLATE utf8_unicode_ci AND itemFk = vItemFk; + SET shelvingFk = shelvingFkD + WHERE shelvingFk = shelvingFkO COLLATE utf8_unicode_ci + AND itemFk = vItemFk + AND visible = ( vPacking * vQuantity ); - CALL vn.itemShelvingMakeFromDate(shelvingFkD,vItemFk,'A',0,( vPacking * vQuantity ),'',0,vPacking,1,1,vDate); + /*CALL vn.itemShelvingMakeFromDate(shelvingFkD,vItemFk,'A',0,( vPacking * vQuantity ),'',0,vPacking,1,1,vDate); */ SELECT true; @@ -43547,9 +43998,25 @@ BEGIN DECLARE vWorkerIsExcluded BOOLEAN; DECLARE vFromDated DATE; DECLARE vToDated DATE DEFAULT TIMESTAMPADD(DAY,1,CURDATE()); - - SELECT COUNT(*) INTO vWorkerIsExcluded - FROM bs.manaSpellersExcluded + DECLARE vMana INT; + DECLARE vAutoMana INT; + DECLARE vManaBank INT; + DECLARE vManaGreugeType INT; + + SELECT id INTO vMana + FROM `component` WHERE code = 'mana'; + + SELECT id INTO vAutoMana + FROM `component` WHERE code = 'autoMana'; + + SELECT id INTO vManaBank + FROM `bank` WHERE code = 'mana'; + + SELECT id INTO vManaGreugeType + FROM `greugeType` WHERE code = 'mana'; + + SELECT COUNT(*) INTO vWorkerIsExcluded + FROM workerManaExcluded WHERE workerFk = vWorkerFk; IF NOT vWorkerIsExcluded THEN @@ -43557,7 +44024,7 @@ BEGIN SELECT max(dated) INTO vFromDated FROM clientManaCache; - REPLACE bs.workerMana (workerFk, amount) + REPLACE workerMana (workerFk, amount) SELECT vWorkerFk, sum(mana) FROM ( SELECT s.quantity * sc.value as mana @@ -43566,28 +44033,22 @@ BEGIN JOIN client c ON c.id = a.clientFk JOIN sale s ON s.ticketFk = t.id JOIN saleComponent sc ON sc.saleFk = s.id - WHERE c.salesPersonFk = vWorkerFk AND componentFk IN (39, 37) -- maná auto y maná + WHERE c.salesPersonFk = vWorkerFk AND sc.componentFk IN (vMana, vAutoMana) AND t.shipped > vFromDated AND t.shipped < vToDated - UNION ALL - SELECT - r.amountPaid FROM receipt r JOIN client c ON c.id = r.clientFk - WHERE c.salesPersonFk = vWorkerFk AND bankFk = 66 + WHERE c.salesPersonFk = vWorkerFk AND bankFk = vManaBank AND payed > vFromDated - UNION ALL - SELECT g.amount FROM greuge g JOIN client c ON c.id = g.clientFk - WHERE c.salesPersonFk = vWorkerFk AND g.greugeTypeFk = 3 -- Maná - AND g.shipped > vFromDated and g.shipped < CURDATE() - - UNION ALL - - SELECT mana + WHERE c.salesPersonFk = vWorkerFk AND g.greugeTypeFk = vManaGreugeType + AND g.shipped > vFromDated and g.shipped < CURDATE() + UNION ALL + SELECT cc.mana FROM clientManaCache cc JOIN client c ON c.id = cc.clientFk WHERE c.salesPersonFk = vWorkerFk AND cc.dated = vFromDated @@ -44462,7 +44923,7 @@ BEGIN WHILE vRow <= vToRow DO INSERT IGNORE INTO vn.parking(`column`, `row`, sectorFk, `code`, pickingOrder) - VALUES (vColumn, vRow, vSectorFk, vCode, vColumn ) + VALUES (vColumn, vRow, vSectorFk, vCode, vColumn * 100 + vRow ) ON DUPLICATE KEY UPDATE `code` = vCode; SET vRow = vRow + 1; @@ -44623,7 +45084,6 @@ BEGIN 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.*, @@ -44641,7 +45101,7 @@ BEGIN 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 + JOIN vn.sector s ON s.id = isa.sectorFk AND s.warehouseFk = isa.warehouseFk WHERE IF(s.isPreviousPreparedByPacking, (MOD(TRUNCATE(isa.quantity,0), isa.packing)= 0 ), TRUE) AND isa.isPreviousPreparable = TRUE AND isa.sectorFk = vSectorFk @@ -46151,7 +46611,7 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `shelvingPark`(IN `vShelvingFk` VARCHAR(8), IN `vParkingCode` VARCHAR(8)) -BEGIN +proc: BEGIN DECLARE vParkingFk INT DEFAULT 0; DECLARE idParking INT; @@ -46162,22 +46622,23 @@ BEGIN /*ELIMINAR ESPACIOS*/ SET vParkingCode = replace(vParkingCode,' ','') ; - /*SINO EXISTE EL PARKING LO CREAMOS*/ + /*SINO EXISTE EL PARKING ABORTAMOS*/ SELECT id INTO idParking FROM vn.parking WHERE code = vParkingCode COLLATE utf8_unicode_ci; - + IF idParking IS NULL THEN - IF LOCATE('-',vParkingCode) = 4 THEN + + LEAVE proc; + /*IF LOCATE('-',vParkingCode) = 4 THEN SELECT SUBSTRING_INDEX(vParkingCode,'-',1) INTO vColumn; SELECT SUBSTRING_INDEX(vParkingCode,'-',-1) INTO vRow; INSERT INTO vn.parking(`column`,`row`,code,sectorFk) VALUES(vColumn,vRow,vParkingCode,1); END IF; + */ END IF; - /*FIN INSERTAR PARKING*/ - - + SELECT id INTO vParkingFk FROM vn.parking WHERE `code` = vParkingCode COLLATE utf8_unicode_ci; @@ -46321,77 +46782,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 `sinComponentes` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!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 `sinComponentes`() -BEGIN - DECLARE v_done BOOL DEFAULT FALSE; - DECLARE vSaleFk INTEGER; - DECLARE vCur CURSOR FOR -SELECT s.id - FROM vn.ticket t - JOIN vn.client clt ON clt.id = t.clientFk - JOIN vn.sale s ON s.ticketFk = t.id - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType tp ON tp.id = i.typeFk - JOIN vn.itemCategory ic ON ic.id = tp.categoryFk - LEFT JOIN tmp.coste c ON c.id = s.id - WHERE t.shipped >= '2019-10-01' AND t.shipped <= '2019-10-30' - 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 vn.ticket t - JOIN vn.client clt ON clt.id = t.clientFk - JOIN vn.sale s ON s.ticketFk = t.id - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType tp ON tp.id = i.typeFk - JOIN vn.itemCategory ic ON ic.id = tp.categoryFk - JOIN vn.saleComponent sc ON sc.saleFk = s.id - JOIN vn.component c ON c.id = sc.componentFk - JOIN vn.componentType ct ON ct.id = c.typeFk AND ct.id = 1 - WHERE t.shipped >= '2019-10-01' - 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 vn.ticketCalculateSaleForcePrice2(vSaleFk); - END LOOP; - - CLOSE vCur; - END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `solunionRiskRequest` */; ALTER DATABASE `vn` CHARACTER SET utf8 COLLATE utf8_general_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -47455,9 +47845,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 ;; @@ -47478,6 +47868,7 @@ BEGIN DECLARE vNewInvoiceId INT; DECLARE vHasDailyInvoice BOOL; DECLARE vWithPackage BOOL; + DECLARE vHasToInvoice BOOL; DECLARE cur CURSOR FOR SELECT ticketFk FROM tmp.ticketClosure; @@ -47511,13 +47902,15 @@ BEGIN t.companyFk, t.shipped, co.hasDailyInvoice, - w.isManaged + w.isManaged, + c.hasToInvoice INTO vClientFk, vIsTaxDataChecked, vCompanyFk, vShipped, vHasDailyInvoice, - vWithPackage + vWithPackage, + vHasToInvoice FROM ticket t JOIN `client` c ON c.id = t.clientFk JOIN province p ON p.id = c.provinceFk @@ -47543,7 +47936,7 @@ BEGIN AND getSpecialPrice(e.itemFk, vClientFk) > 0 GROUP BY e.itemFk); - IF(vHasDailyInvoice) THEN + IF(vHasDailyInvoice) AND vHasToInvoice THEN -- Facturacion rapida CALL ticketTrackingAdd(vTicketFk, 'DELIVERED', NULL); @@ -47827,6 +48220,30 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticketCollection_get` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticketCollection_get`(vTicketFk INT) +BEGIN + + SELECT collectionFk + FROM vn.collectionReportSource + WHERE ticketFk = vTicketFk + GROUP BY collectionFk; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_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 `ticketComponentCalculate__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -48526,7 +48943,7 @@ BEGIN 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.base + 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; @@ -50433,7 +50850,7 @@ BEGIN DECLARE vWarehouseFk INT; DECLARE vCursor CURSOR FOR SELECT id, landed, addressFk, agencyModeFk, warehouseFk - FROM vn.ticket WHERE shipped >= '2019-07-01'; + FROM vn.ticket WHERE shipped BETWEEN '2019-01-01' and '2019-02-01' AND zoneFk is null; DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET vDone = 1; OPEN vCursor; @@ -50442,7 +50859,7 @@ BEGIN CALL zoneGetShippedWarehouse(vLanded, vAddressFk, vAgencyModeFk); UPDATE vn.ticket t JOIN tmp.zoneGetShipped zgs ON zgs.warehouseFk = vWarehouseFk - SET zoneFk = zgs.id + SET t.zoneFk = zgs.zoneFk WHERE t.id = vFechedTicket; UNTIL vDone END REPEAT; @@ -50683,6 +51100,76 @@ 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_withoutComponents` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!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_withoutComponents`(vDatedFrom DATETIME, vDatedTo DATETIME) +BEGIN + DECLARE v_done BOOL DEFAULT FALSE; + DECLARE vSaleFk INTEGER; + DECLARE vCur CURSOR FOR + SELECT s.id + FROM vn.ticket t + JOIN vn.client clt ON clt.id = t.clientFk + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType tp ON tp.id = i.typeFk + JOIN vn.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 vn.ticket t + JOIN vn.client clt ON clt.id = t.clientFk + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType tp ON tp.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = tp.categoryFk + JOIN vn.saleComponent sc ON sc.saleFk = s.id + JOIN vn.component c ON c.id = sc.componentFk + JOIN vn.componentType ct ON ct.id = c.typeFk 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 vn.ticketCalculateSaleForcePrice2(vSaleFk); + END LOOP; + + CLOSE vCur; + END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `timeBusiness_calculate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -50944,9 +51431,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 ;; @@ -50976,10 +51463,14 @@ BEGIN wtc.userFk, wtc.timed timed, direction - FROM workerTimeControl wtc - JOIN tmp.`user` w ON w.userFk = wtc.userFk + FROM (SELECT wtc.* + FROM workerTimeControl wtc + JOIN tmp.`user` w ON w.userFk = wtc.userFk + WHERE wtc.timed BETWEEN vDatedFrom AND vDatedTo + ORDER BY userFk, timed ASC + ) wtc WHERE wtc.timed BETWEEN vDatedFrom AND vDatedTo - ORDER BY userFk, timed + ORDER BY userFk, timed ASC ) sub GROUP BY userFk, dated ORDER BY userFk, dated @@ -51138,6 +51629,57 @@ BEGIN DROP TEMPORARY TABLE tmp.`user`; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_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 `timeControl_calculate__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!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 `timeControl_calculate__`(vDatedFrom DATETIME, vDatedTo DATETIME) +BEGIN + SET @vIsOdd := TRUE; + SET @vUser := NULL; + SET @vDated := NULL; + + DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate; + + CREATE TEMPORARY TABLE tmp.timeControlCalculate + SELECT userFk, + dated, + IF( timeWork >= 18000, @timeWork:=timeWork + 1200, @timeWork:=timeWork) timeWorkSeconds, + SEC_TO_TIME(@timeWork ) timeWorkSexagesimal, + @timeWork / 3600 timeWorkDecimal + FROM (SELECT SUM(timeWork) timeWork, + userFk, + dated + FROM (SELECT IF(@vUser = wtc.userFk, @vUser :=@vUser, @vUser := wtc.userFk ), + IF(@vIsOdd, @vIsOdd := FALSE, @vIsOdd := TRUE ), + IF(direction='in', @vIsOdd := TRUE, @vIsOdd := @vIsOdd ), + IF(@vIsOdd, @vLastTimed:=UNIX_TIMESTAMP(timed),@vLastTimed:=@vLastTimed), + IF(@vIsOdd, 0, UNIX_TIMESTAMP(timed)-@vLastTimed) timeWork, + IF(direction='in', @vDated := DATE(wtc.timed), @vDated :=@vDated) dated, + wtc.userFk, + wtc.timed timed, + direction + FROM (SELECT * FROM workerTimeControl ORDER BY userFk, timed ASC) wtc + JOIN tmp.`user` w ON w.userFk = wtc.userFk + WHERE wtc.timed BETWEEN vDatedFrom AND vDatedTo + ORDER BY userFk, timed ASC + ) sub + GROUP BY userFk, dated + ORDER BY userFk, dated + )sub2; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -54073,6 +54615,9 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `zone_getAvailable`(vAddress INT, vLanded DATE) BEGIN + +/* JGF esta trabajando en este archivo, si se modifica avisadme 2020-02-12*/ + CALL zone_getFromGeo(address_getGeo(vAddress)); CALL zone_getOptionsForLanding(vLanded); @@ -54364,14 +54909,86 @@ 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 `zone_getOptionsForLanding`(vLanded DATE) BEGIN +/** + * Gets computed options for the passed zones and delivery date. + * + * @table tmp.zones(id) The zones ids + * @param vLanded The delivery date + * @return tmp.zoneOption The computed options + */ + DROP TEMPORARY TABLE IF EXISTS tmp.zoneOption; + CREATE TEMPORARY TABLE tmp.zoneOption + ENGINE = MEMORY + SELECT + zoneFk, + `hour`, + travelingDays, + price, + bonus, + TIMESTAMPADD(DAY, -travelingDays, vLanded) shipped + FROM ( + SELECT t.id zoneFk, + TIME(IFNULL(e.`hour`, z.`hour`)) `hour`, + IFNULL(e.travelingDays, z.travelingDays) travelingDays, + IFNULL(e.price, z.price) price, + IFNULL(e.bonus, z.bonus) bonus + FROM tmp.zone t + JOIN zone z ON z.id = t.id + JOIN zoneEvent e ON e.zoneFk = t.id + WHERE ( + e.`type` = 'day' + AND e.dated = vLanded + ) OR ( + e.`type` != 'day' + AND e.weekDays & (1 << WEEKDAY(vLanded)) + AND (e.`started` IS NULL OR vLanded >= e.`started`) + AND (e.`ended` IS NULL OR vLanded <= 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; + + DELETE t FROM tmp.zoneOption t + JOIN zoneExclusion e + ON e.zoneFk = t.zoneFk AND e.`dated` = vLanded; + + DELETE FROM tmp.zoneOption + WHERE shipped < CURDATE() + OR (shipped = CURDATE() AND CURTIME() > `hour`); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_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_getOptionsForLanding__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!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 `zone_getOptionsForLanding__`(vLanded DATE) +BEGIN /** * Gets computed options for the passed zones and delivery date. * @@ -54438,14 +55055,99 @@ 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 `zone_getOptionsForShipment`(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; + + 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; + + DROP TEMPORARY TABLE tLandings; + + DELETE t FROM tmp.zoneOption t + JOIN zoneExclusion e + ON e.zoneFk = t.zoneFk AND e.`dated` = t.landed; + + 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 */ ; +/*!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__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!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 `zone_getOptionsForShipment__`(vShipped DATE, vShowExpiredZones BOOLEAN) +BEGIN /** * Gets computed options for the passed zones and shipping date. * @@ -54585,6 +55287,9 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `zone_getWarehouse`(vAddress INT, vLanded DATE, vWarehouse INT) BEGIN + +/* JGF esta trabajando en este archivo, si se modifica avisadme 2020-02-12*/ + /** * Devuelve el listado de agencias disponibles para la fecha, * dirección y almacén pasados. @@ -54735,10 +55440,14 @@ DELIMITER ;; AFTER INSERT ON `inter` 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 */ ; @@ -56284,25 +56993,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemPlacementSupplyList` AS select `ips`.`id` AS `id`,`ips`.`itemFk` AS `itemFk`,`ips`.`quantity` AS `quantity`,`ips`.`priority` AS `priority`,ifnull(`isps`.`created`,`ips`.`created`) AS `created`,`ips`.`userFk` AS `userFk`,`ips`.`repoUserFk` AS `repoUserFk`,(`ips`.`quantity` - sum(ifnull(`isps`.`quantity`,0))) AS `saldo`,concat(`i`.`longName`,' ',`i`.`size`) AS `longName`,`i`.`subName` AS `subName`,`i`.`size` AS `size`,`w`.`code` AS `workerCode`,`rw`.`code` AS `repoCode`,max(`p`.`code`) AS `parking`,`ips`.`sectorFk` AS `sectorFk` from (((((((`itemPlacementSupply` `ips` join `item` `i` on((`i`.`id` = `ips`.`itemFk`))) left join `worker` `w` on((`w`.`userFk` = `ips`.`userFk`))) left join `worker` `rw` on((`rw`.`userFk` = `ips`.`repoUserFk`))) left join `itemShelvingPlacementSupply` `isps` on((`isps`.`itemPlacementSupplyFk` = `ips`.`id`))) left join `itemShelving` `ish` on((`ish`.`id` = `isps`.`itemShelvingFk`))) left join `shelving` `s` on((`ish`.`shelvingFk` = `s`.`code`))) left join `parking` `p` on((`s`.`parkingFk` = `p`.`id`))) where (`ips`.`created` >= curdate()) group by `ips`.`priority`,`ips`.`id`,`p`.`sectorFk` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - --- --- Final view structure for view `itemPlacementSupplyList__` --- - -/*!50001 DROP VIEW IF EXISTS `itemPlacementSupplyList__`*/; -/*!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 `itemPlacementSupplyList__` AS select `ips`.`id` AS `id`,`ips`.`itemFk` AS `itemFk`,`ips`.`quantity` AS `quantity`,`ips`.`priority` AS `priority`,`ips`.`created` AS `created`,`ips`.`userFk` AS `userFk`,`ips`.`repoUserFk` AS `repoUserFk`,(`ips`.`quantity` - sum(ifnull(`isps`.`quantity`,0))) AS `saldo`,concat(`i`.`longName`,' ',`i`.`size`) AS `longName`,`i`.`subName` AS `subName`,`i`.`size` AS `size`,`w`.`code` AS `workerCode`,`rw`.`code` AS `repoCode`,max(`p`.`code`) AS `parking`,max(`p`.`sectorFk`) AS `sectorFk` from (((((((`itemPlacementSupply` `ips` join `itemShelving` `ish` on((`ish`.`itemFk` = `ips`.`itemFk`))) join `item` `i` on((`i`.`id` = `ish`.`itemFk`))) left join `worker` `w` on((`w`.`userFk` = `ips`.`userFk`))) left join `worker` `rw` on((`rw`.`userFk` = `ips`.`repoUserFk`))) left join `itemShelvingPlacementSupply` `isps` on((`isps`.`itemPlacementSupplyFk` = `ips`.`id`))) left join `shelving` `s` on((`ish`.`shelvingFk` = `s`.`code`))) left join `parking` `p` on((`s`.`parkingFk` = `p`.`id`))) where (`ips`.`created` >= curdate()) group by `ips`.`priority`,`ips`.`id`,`p`.`sectorFk` */; +/*!50001 VIEW `itemPlacementSupplyList` AS select `ips`.`id` AS `id`,`ips`.`itemFk` AS `itemFk`,`ips`.`quantity` AS `quantity`,`ips`.`priority` AS `priority`,ifnull(`isps`.`created`,`ips`.`created`) AS `created`,`ips`.`userFk` AS `userFk`,`ips`.`repoUserFk` AS `repoUserFk`,(`ips`.`quantity` - sum(ifnull(`isps`.`quantity`,0))) AS `saldo`,concat(`i`.`longName`,' ',`i`.`size`) AS `longName`,`i`.`subName` AS `subName`,`i`.`size` AS `size`,`w`.`code` AS `workerCode`,`rw`.`code` AS `repoCode`,`ips`.`sectorFk` AS `sectorFk` from ((((`itemPlacementSupply` `ips` join `item` `i` on((`i`.`id` = `ips`.`itemFk`))) left join `worker` `w` on((`w`.`userFk` = `ips`.`userFk`))) left join `worker` `rw` on((`rw`.`userFk` = `ips`.`repoUserFk`))) left join `itemShelvingPlacementSupply` `isps` on((`isps`.`itemPlacementSupplyFk` = `ips`.`id`))) where (`ips`.`created` >= curdate()) group by `ips`.`priority`,`ips`.`id`,`ips`.`sectorFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -56338,7 +57029,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemShelvingAvailable` AS select `s`.`id` AS `saleFk`,`tst`.`updated` AS `Modificado`,`s`.`ticketFk` AS `ticketFk`,0 AS `isPicked`,`s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`i`.`size` AS `size`,`st`.`name` AS `Estado`,`st`.`sectorProdPriority` AS `sectorProdPriority`,`stock`.`visible` AS `available`,`stock`.`sectorFk` AS `sectorFk`,`stock`.`shelvingFk` AS `matricula`,`stock`.`parkingFk` AS `parking`,`stock`.`itemShelvingFk` AS `itemShelving`,`am`.`name` AS `Agency`,`t`.`shipped` AS `shipped`,`stock`.`grouping` AS `grouping`,`stock`.`packing` AS `packing`,`z`.`hour` AS `hour`,`st`.`isPreviousPreparable` AS `isPreviousPreparable`,`sv`.`physicalVolume` AS `physicalVolume` from (((((((((`vn`.`sale` `s` join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) join `vn`.`ticketStateToday` `tst` on((`tst`.`ticket` = `t`.`id`))) join `vn`.`state` `st` on((`st`.`id` = `tst`.`state`))) join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`itemShelvingStock` `stock` on((`stock`.`itemFk` = `i`.`id`))) left join `vn`.`saleTracking` `stk` on((`stk`.`saleFk` = `s`.`id`))) left join `vn`.`zone` `z` on((`z`.`id` = `t`.`zoneFk`))) left join `vn`.`saleVolume` `sv` on((`sv`.`saleFk` = `s`.`id`))) where ((`t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(curdate())) and isnull(`stk`.`id`) and (`stock`.`visible` > 0) and isnull(`stk`.`saleFk`) and `st`.`sectorProdPriority`) */; +/*!50001 VIEW `itemShelvingAvailable` AS select `s`.`id` AS `saleFk`,`tst`.`updated` AS `Modificado`,`s`.`ticketFk` AS `ticketFk`,0 AS `isPicked`,`s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`i`.`size` AS `size`,`st`.`name` AS `Estado`,`st`.`sectorProdPriority` AS `sectorProdPriority`,`stock`.`visible` AS `available`,`stock`.`sectorFk` AS `sectorFk`,`stock`.`shelvingFk` AS `matricula`,`stock`.`parkingFk` AS `parking`,`stock`.`itemShelvingFk` AS `itemShelving`,`am`.`name` AS `Agency`,`t`.`shipped` AS `shipped`,`stock`.`grouping` AS `grouping`,`stock`.`packing` AS `packing`,`z`.`hour` AS `hour`,`st`.`isPreviousPreparable` AS `isPreviousPreparable`,`sv`.`physicalVolume` AS `physicalVolume`,`t`.`warehouseFk` AS `warehouseFk` from (((((((((`vn`.`sale` `s` join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) join `vn`.`ticketStateToday` `tst` on((`tst`.`ticket` = `t`.`id`))) join `vn`.`state` `st` on((`st`.`id` = `tst`.`state`))) join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`itemShelvingStock` `stock` on((`stock`.`itemFk` = `i`.`id`))) left join `vn`.`saleTracking` `stk` on((`stk`.`saleFk` = `s`.`id`))) left join `vn`.`zone` `z` on((`z`.`id` = `t`.`zoneFk`))) left join `vn`.`saleVolume` `sv` on((`sv`.`saleFk` = `s`.`id`))) where ((`t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(curdate())) and isnull(`stk`.`id`) and (`stock`.`visible` > 0) and isnull(`stk`.`saleFk`) and `st`.`sectorProdPriority`) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -56531,12 +57222,12 @@ USE `vn`; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; +/*!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 `lastTopClaims` AS select `s`.`itemFk` AS `itemFk`,`i`.`longName` AS `itemName`,`it`.`name` AS `itemTypeName`,count(0) AS `claimsNumber`,round(sum(((((`cb`.`quantity` * `s`.`price`) * (1 - ((`c`.`responsibility` - 1) / 4))) * (100 - `s`.`discount`)) / 100)),2) AS `claimedAmount`,round(sum((((`cb`.`quantity` * `s`.`price`) * (100 - `s`.`discount`)) / 100)),2) AS `totalAmount` from ((((`claim` `c` join `claimBeginning` `cb` on((`cb`.`claimFk` = `c`.`id`))) join `sale` `s` on((`s`.`id` = `cb`.`saleFk`))) join `item` `i` on((`i`.`id` = `s`.`itemFk`))) join `itemType` `it` on((`it`.`id` = `i`.`typeFk`))) where (`c`.`created` >= (curdate() + interval -(1) week)) group by `s`.`itemFk` having (((`claimedAmount` > 100) and (`claimsNumber` > 2)) or (`claimsNumber` > 4)) order by `claimedAmount` desc */; +/*!50001 VIEW `lastTopClaims` AS select `s`.`itemFk` AS `itemFk`,`i`.`longName` AS `itemName`,`it`.`name` AS `itemTypeName`,count(0) AS `claimsNumber`,round(sum(((((`cb`.`quantity` * `s`.`price`) * (1 - ((`c`.`responsibility` - 1) / 4))) * (100 - `s`.`discount`)) / 100)),2) AS `claimedAmount`,round(sum((((`cb`.`quantity` * `s`.`price`) * (100 - `s`.`discount`)) / 100)),2) AS `totalAmount` from ((((`claim` `c` join `claimBeginning` `cb` on((`cb`.`claimFk` = `c`.`id`))) join `sale` `s` on((`s`.`id` = `cb`.`saleFk`))) join `item` `i` on((`i`.`id` = `s`.`itemFk`))) join `itemType` `it` on((`it`.`id` = `i`.`typeFk`))) where (`c`.`created` >= (curdate() + interval -(1) week)) group by `s`.`itemFk` having (((`claimedAmount` > 100) and (`claimsNumber` > 2)) or (`claimsNumber` > 4)) order by `claimsNumber` desc */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -56974,19 +57665,19 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `workerTimeControl_Journey` +-- Final view structure for view `workerTimeControl_Journey__` -- -/*!50001 DROP VIEW IF EXISTS `workerTimeControl_Journey`*/; +/*!50001 DROP VIEW IF EXISTS `workerTimeControl_Journey__`*/; /*!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 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 `workerTimeControl_Journey` AS select `wtc`.`userFk` AS `userFk`,cast(`wtc`.`timed` as date) AS `dated`,cast(sum((if((`wtc`.`order` % 2),-(1),1) * (hour(`wtc`.`timed`) + (minute(`wtc`.`timed`) / 60)))) as decimal(10,2)) AS `Journey`,dayname(`wtc`.`timed`) AS `dayName`,`w`.`lastName` AS `name`,`w`.`firstName` AS `firstname` from (`workerTimeControl` `wtc` join `worker` `w` on((`w`.`userFk` = `wtc`.`userFk`))) group by cast(`wtc`.`timed` as date),`wtc`.`userFk` */; +/*!50001 VIEW `workerTimeControl_Journey__` AS select `wtc`.`userFk` AS `userFk`,cast(`wtc`.`timed` as date) AS `dated`,cast(sum((if((`wtc`.`order` % 2),-(1),1) * (hour(`wtc`.`timed`) + (minute(`wtc`.`timed`) / 60)))) as decimal(10,2)) AS `Journey`,dayname(`wtc`.`timed`) AS `dayName`,`w`.`lastName` AS `name`,`w`.`firstName` AS `firstname` from (`workerTimeControl` `wtc` join `worker` `w` on((`w`.`userFk` = `wtc`.`userFk`))) group by cast(`wtc`.`timed` as date),`wtc`.`userFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -57024,4 +57715,4 @@ USE `vncontrol`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-01-24 12:08:27 +-- Dump completed on 2020-02-13 9:07:01 diff --git a/db/tests/vn/ticket_recalcComponents.spec.js b/db/tests/vn/ticket_recalcComponents.spec.js new file mode 100644 index 000000000..e140db34c --- /dev/null +++ b/db/tests/vn/ticket_recalcComponents.spec.js @@ -0,0 +1,62 @@ +const app = require('vn-loopback/server/server'); +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; + +describe('ticket_recalcComponents()', () => { + it('should recalculate the components in a ticket and check it', async() => { + let stmts = []; + let stmt; + const ticketId = 11; + + stmts.push('START TRANSACTION'); + + let sales = await app.models.Sale.find({where: {ticketFk: ticketId}}); + + stmt = new ParameterizedSQL('UPDATE vn.sale SET price=100 WHERE id IN(?,?)', [ + sales[0].id, + sales[1].id + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('SELECT * FROM vn.sale WHERE ticketFk = ?', [ + ticketId + ]); + stmts.push(stmt); + + let modifiedSales = stmts.push(stmt) - 1; + + stmt = new ParameterizedSQL('CALL vn.ticket_recalcComponents(?)', [ + ticketId, + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('SELECT * FROM vn.sale WHERE ticketFk = ?', [ + ticketId + ]); + stmts.push(stmt); + + let expectedSales = stmts.push(stmt) - 1; + + stmts.push('ROLLBACK'); + + let sql = ParameterizedSQL.join(stmts, ';'); + let result = await app.models.Ticket.rawStmt(sql); + + // original data + const firstPrice = sales[0].price; + const secondPrice = sales[1].price; + + // alteratons for test purposes + const modifiedFirstPrice = result[modifiedSales][0].price; + const modifiedSecondPrice = result[modifiedSales][1].price; + + // expected data after recalc + const expectedSalesFirstPrice = result[expectedSales][0].price; + const expectedSalesSecondPrice = result[expectedSales][1].price; + + expect(firstPrice).not.toEqual(modifiedFirstPrice); + expect(secondPrice).not.toEqual(modifiedSecondPrice); + + expect(firstPrice).toEqual(expectedSalesFirstPrice); + expect(secondPrice).toEqual(expectedSalesSecondPrice); + }); +}); diff --git a/e2e/dms/ecc/3.jpeg b/e2e/dms/ecc/3.jpeg new file mode 100644 index 000000000..fb2483f69 Binary files /dev/null and b/e2e/dms/ecc/3.jpeg differ diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index 452dd3a4d..816eea064 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -1,4 +1,3 @@ -/* eslint no-invalid-this: "off" */ import {url as defaultURL} from './config'; let actions = { @@ -21,6 +20,7 @@ let actions = { } catch (error) { throw new Error(`failed to reach URL containing: ${expectedHash}`); } + await this.waitForContentLoaded(); return true; }, @@ -30,20 +30,6 @@ let actions = { }, selector); }, - changeLanguageToEnglish: async function() { - let langSelector = '.user-popover vn-autocomplete[ng-model="$ctrl.lang"]'; - - await this.waitToClick('#user'); - await this.waitForSelector(`${langSelector} input`, {}); - - let lang = await this.waitToGetProperty(langSelector, 'value'); - if (lang !== 'English') - await this.autocompleteSearch(langSelector, 'English'); - - await this.keyboard.press('Escape'); - await this.waitForSelector(langSelector, {hidden: true}); - }, - doLogin: async function(userName, password = 'nightmare') { await this.waitForSelector(`vn-login vn-textfield[ng-model="$ctrl.user"]`, {visible: true}); await this.clearInput(`vn-login vn-textfield[ng-model="$ctrl.user"]`); @@ -69,7 +55,6 @@ let actions = { await this.waitForFunction(() => { return document.location.hash === '#!/'; }, {}); - await this.changeLanguageToEnglish(); }, selectModule: async function(moduleName) { @@ -167,7 +152,7 @@ let actions = { waitToGetProperty: async function(selector, property) { let builtSelector = selector; - if (property != 'innerText') + if (selector.includes('vn-input-file') || property != 'innerText') builtSelector = await this.selectorFormater(selector); try { @@ -311,6 +296,9 @@ let actions = { if (selector.includes('vn-textfield')) return builtSelector = `${selector} input`; + if (selector.includes('vn-input-file')) + return builtSelector = `${selector} section`; + return builtSelector; }, @@ -365,14 +353,15 @@ let actions = { await this.write('vn-searchbar', searchValue); await this.waitToClick('vn-searchbar vn-icon[icon="search"]'); await this.waitForNumberOfElements('.search-result', 1); - await this.waitFor(1000); + await this.waitForContentLoaded(); await this.evaluate(() => { return document.querySelector('.search-result').click(); }); + await this.waitForContentLoaded(); }, accessToSection: async function(sectionRoute) { - await this.waitForSelector(`vn-left-menu`, {visible: true}); + await this.waitForSelector('vn-left-menu'); let nested = await this.evaluate(sectionRoute => { return document.querySelector(`vn-left-menu li li > a[ui-sref="${sectionRoute}"]`) != null; }, sectionRoute); @@ -394,6 +383,7 @@ let actions = { autocompleteSearch: async function(selector, searchValue) { let builtSelector = await this.selectorFormater(selector); + await this.waitForContentLoaded(); await this.waitToClick(selector); await this.waitForSelector(selector => { document @@ -424,10 +414,11 @@ let actions = { }, {}, builtSelector, searchValue); await this.waitForMutation(`.vn-drop-down`, 'childList'); + await this.waitForContentLoaded(); }, reloadSection: async function(sectionRoute) { - await this.waitFor(1000); + await this.waitForContentLoaded(); await Promise.all([ this.waitForNavigation({waitUntil: 'networkidle0'}), this.click('vn-icon[icon="desktop_windows"]', {}), @@ -437,6 +428,7 @@ let actions = { this.waitForNavigation({waitUntil: 'networkidle0'}), this.click(`vn-left-menu li > a[ui-sref="${sectionRoute}"]`, {}), ]); + await this.waitForContentLoaded(); }, forceReloadSection: async function(sectionRoute) { @@ -526,6 +518,13 @@ let actions = { }, selector); }, + closePopup: async function(selector) { + await Promise.all([ + this.keyboard.press('Escape'), + this.waitForSelector('.vn-popup', {hidden: true}), + ]); + }, + waitForContentLoaded: async function() { await this.waitFor(1000); // to be implemented in base of a directive loaded once al modules are done loading, further investigation required. diff --git a/e2e/helpers/puppeteer.js b/e2e/helpers/puppeteer.js index 351a26669..ed05909d0 100644 --- a/e2e/helpers/puppeteer.js +++ b/e2e/helpers/puppeteer.js @@ -15,6 +15,18 @@ export async function getBrowser() { slowMo: 0, // slow down by ms }); let page = (await browser.pages())[0]; + await page.evaluateOnNewDocument(() => { + Object.defineProperty(navigator, 'language', { + get: function() { + return 'en'; + } + }); + Object.defineProperty(navigator, 'languages', { + get: function() { + return ['en']; + } + }); + }); page = extendPage(page); page.setDefaultTimeout(5000); await page.goto(defaultURL, {waitUntil: 'networkidle0'}); diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 63e5ddf2f..bbf3d0452 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -27,6 +27,17 @@ export default { createClientButton: `vn-float-button`, othersButton: 'vn-left-menu li[name="Others"] > a' }, + clientSummary: { + header: 'vn-client-summary > vn-card > h5', + email: 'vn-client-summary vn-label-value[label="Email"]', + street: 'vn-client-summary vn-label-value[label="Street"]', + verifiedData: 'vn-client-summary > vn-card > vn-horizontal vn-check[ng-model="$ctrl.summary.isTaxDataChecked"]', + payMethod: 'vn-client-summary vn-label-value[label="Pay method"]', + defaultAdressName: 'vn-client-summary vn-label-value[label="Name"]', + userName: 'vn-client-summary vn-label-value[label="User"]', + rate: 'vn-client-summary vn-label-value[label="Rate"]', + credit: 'vn-client-summary vn-label-value[label="Credit"]', + }, createClientView: { name: 'vn-client-create vn-textfield[ng-model="$ctrl.client.name"]', taxNumber: 'vn-client-create vn-textfield[ng-model="$ctrl.client.fi"]', @@ -93,7 +104,7 @@ export default { newBankEntityBIC: '.vn-dialog.shown vn-textfield[ng-model="$ctrl.newBankEntity.bic"]', newBankEntityCode: '.vn-dialog.shown vn-textfield[ng-model="$ctrl.newBankEntity.id"]', acceptBankEntityButton: '.vn-dialog.shown button[response="accept"]', - saveButton: `button[type=submit]`, + saveButton: 'vn-client-billing-data button[type=submit]', watcher: 'vn-client-billing-data vn-watcher' }, clientAddresses: { @@ -185,6 +196,13 @@ export default { firstDocWorkerDescriptor: '.vn-popover.shown vn-worker-descriptor', acceptDeleteButton: '.vn-confirm.shown button[response="accept"]' }, + clientContacts: { + addContactButton: 'vn-client-contact vn-icon[icon="add_circle"]', + name: 'vn-client-contact vn-textfield[ng-model="contact.name"]', + phone: 'vn-client-contact vn-textfield[ng-model="contact.phone"]', + deleteFirstPhone: 'vn-client-contact vn-icon[icon="delete"]', + saveButton: 'button[type=submit]' + }, itemsIndex: { searchIcon: 'vn-searchbar vn-icon[icon="search"]', createItemButton: `vn-float-button`, @@ -244,6 +262,10 @@ export default { longName: 'vn-textfield[ng-model="$ctrl.item.longName"]', isActiveCheckbox: 'vn-check[label="Active"]', priceInKgCheckbox: 'vn-check[label="Price in kg"]', + newIntrastatButton: 'vn-item-basic-data vn-icon-button[vn-tooltip="New intrastat"] > button', + newIntrastatId: '.vn-dialog.shown vn-input-number[ng-model="$ctrl.newIntrastat.intrastatId"]', + newIntrastatDescription: '.vn-dialog.shown vn-textfield[ng-model="$ctrl.newIntrastat.description"]', + acceptIntrastatButton: '.vn-dialog.shown button[response="accept"]', submitBasicDataButton: `button[type=submit]` }, itemTags: { @@ -598,9 +620,9 @@ export default { orderCatalog: { plantRealmButton: 'vn-order-catalog > vn-side-menu vn-icon[icon="icon-plant"]', type: 'vn-autocomplete[data="$ctrl.itemTypes"]', - itemId: 'vn-order-catalog > vn-side-menu vn-textfield[ng-model="$ctrl.itemId"]', - itemTagValue: 'vn-order-catalog > vn-side-menu vn-textfield[ng-model="$ctrl.value"]', - openTagSearch: 'vn-order-catalog > vn-side-menu > div > vn-vertical > vn-textfield[ng-model="$ctrl.value"] .append i', + itemId: 'vn-order-catalog > vn-side-menu vn-textfield[vn-id="itemId"]', + itemTagValue: 'vn-order-catalog > vn-side-menu vn-datalist[vn-id="search"]', + openTagSearch: 'vn-order-catalog > vn-side-menu > div > vn-vertical > vn-datalist[vn-id="search"] .append i', tag: 'vn-order-catalog-search-panel vn-autocomplete[ng-model="filter.tagFk"]', tagValue: 'vn-order-catalog-search-panel vn-textfield[ng-model="filter.value"]', searchTagButton: 'vn-order-catalog-search-panel button[type=submit]', @@ -636,7 +658,13 @@ export default { volume: 'vn-route-descriptor vn-label-value[label="Volume"] > section > span' }, routeSummary: { - routeId: 'vn-route-summary > vn-card > vn-horizontal > vn-one:nth-child(1) > vn-label-value:nth-child(1) > section > span' + header: 'vn-route-summary > vn-card > h5', + routeId: 'vn-route-summary > vn-card > vn-horizontal > vn-one:nth-child(1) > vn-label-value:nth-child(1) > section > span', + cost: 'vn-route-summary vn-label-value[label="Cost"]', + firstTicketID: 'vn-route-summary vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(2) > span', + firstTicketDescriptor: '.vn-popover.shown vn-ticket-descriptor', + firstAlias: 'vn-route-summary vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(3) > span', + firstClientDescriptor: '.vn-popover.shown vn-client-descriptor', }, routeBasicData: { worker: 'vn-route-basic-data vn-autocomplete[ng-model="$ctrl.route.workerFk"]', @@ -735,6 +763,30 @@ export default { acceptBookingButton: '.vn-confirm.shown button[response="accept"]' }, invoiceOutSummary: { - bookedLabel: 'vn-invoice-out-summary > vn-card > vn-horizontal > vn-one > vn-label-value:nth-child(4) > section > span' + bookedLabel: 'vn-invoice-out-summary > vn-card > vn-horizontal > vn-one > vn-label-value:nth-child(4) > section > span', + company: 'vn-invoice-out-summary vn-label-value[label="Company"]', + taxOne: 'vn-invoice-out-summary > vn-card > vn-horizontal > vn-two > vn-table > div > vn-tbody > vn-tr:nth-child(1)', + taxTwo: 'vn-invoice-out-summary > vn-card > vn-horizontal > vn-two > vn-table > div > vn-tbody > vn-tr:nth-child(2)', + ticketOne: 'vn-invoice-out-summary > vn-card > vn-horizontal > vn-auto > vn-table > div > vn-tbody > vn-tr:nth-child(1)', + ticketTwo: 'vn-invoice-out-summary > vn-card > vn-horizontal > vn-auto > vn-table > div > vn-tbody > vn-tr:nth-child(2)' + }, + travelThermograph: { + add: 'vn-travel-thermograph-index vn-float-button[icon="add"]', + thermographID: 'vn-travel-thermograph-create vn-autocomplete[ng-model="$ctrl.dms.thermographId"]', + uploadIcon: 'vn-travel-thermograph-create vn-icon[icon="cloud_upload"]', + createdThermograph: 'vn-travel-thermograph-index vn-tbody > vn-tr', + upload: 'vn-travel-thermograph-create button[type=submit]' + }, + agencyBasicData: { + name: 'vn-zone-basic-data vn-textfield[ng-model="$ctrl.zone.name"]', + agency: 'vn-zone-basic-data vn-autocomplete[ng-model="$ctrl.zone.agencyModeFk"]', + maxVolume: 'vn-zone-basic-data vn-input-number[ng-model="$ctrl.zone.m3Max"]', + travelingDays: 'vn-zone-basic-data vn-input-number[ng-model="$ctrl.zone.travelingDays"]', + closing: 'vn-zone-basic-data vn-input-time[ng-model="$ctrl.zone.hour"]', + price: 'vn-zone-basic-data vn-input-number[ng-model="$ctrl.zone.price"]', + bonus: 'vn-zone-basic-data vn-input-number[ng-model="$ctrl.zone.bonus"]', + inflation: 'vn-zone-basic-data vn-input-number[ng-model="$ctrl.zone.inflation"]', + volumetric: 'vn-zone-basic-data vn-check[ng-model="$ctrl.zone.isVolumetric"]', + saveButton: 'vn-zone-basic-data vn-submit > button', } }; diff --git a/e2e/paths/02-client-module/01_create_client.spec.js b/e2e/paths/02-client/01_create_client.spec.js similarity index 98% rename from e2e/paths/02-client-module/01_create_client.spec.js rename to e2e/paths/02-client/01_create_client.spec.js index 29525df49..8f1a116ee 100644 --- a/e2e/paths/02-client-module/01_create_client.spec.js +++ b/e2e/paths/02-client/01_create_client.spec.js @@ -53,7 +53,6 @@ describe('Client create path', async() => { await page.write(selectors.createClientView.name, 'Carol Danvers'); await page.write(selectors.createClientView.socialName, 'AVG tax'); await page.write(selectors.createClientView.street, 'Many places'); - await page.waitForContentLoaded(); await page.autocompleteSearch(selectors.createClientView.country, 'España'); await page.autocompleteSearch(selectors.createClientView.province, 'Province one'); await page.write(selectors.createClientView.city, 'Valencia'); @@ -113,7 +112,6 @@ describe('Client create path', async() => { }); it(`should search for the user Carol Danvers to confirm it exists`, async() => { - await page.waitForContentLoaded(); await page.accessToSearchResult('Carol Danvers'); let url = await page.expectURL('#!/client/114/summary'); diff --git a/e2e/paths/02-client-module/02_edit_basic_data.spec.js b/e2e/paths/02-client/02_edit_basic_data.spec.js similarity index 97% rename from e2e/paths/02-client-module/02_edit_basic_data.spec.js rename to e2e/paths/02-client/02_edit_basic_data.spec.js index 8b665bd96..6ae512542 100644 --- a/e2e/paths/02-client-module/02_edit_basic_data.spec.js +++ b/e2e/paths/02-client/02_edit_basic_data.spec.js @@ -70,14 +70,14 @@ describe('Client Edit basicData path', () => { }); describe('as salesAssistant', () => { - beforeAll(async() => { + it('should navigate to a client basic data', async() => { await page.loginAndModule('salesASsistant', 'client'); await page.accessToSearchResult('Ptonomy Wallace'); await page.accessToSection('client.card.basicData'); }); it('should be able to change the salesPerson', async() => { - await page.wait(selectors.clientBasicData.name); + await page.waitForSelector(selectors.clientBasicData.name); const result = await page.evaluate(selector => { return document.querySelector(selector).disabled; }, `${selectors.clientBasicData.salesPerson} input`); diff --git a/e2e/paths/02-client-module/03_edit_fiscal_data.spec.js b/e2e/paths/02-client/03_edit_fiscal_data.spec.js similarity index 99% rename from e2e/paths/02-client-module/03_edit_fiscal_data.spec.js rename to e2e/paths/02-client/03_edit_fiscal_data.spec.js index d39f196cb..ac08b100d 100644 --- a/e2e/paths/02-client-module/03_edit_fiscal_data.spec.js +++ b/e2e/paths/02-client/03_edit_fiscal_data.spec.js @@ -83,7 +83,7 @@ describe('Client Edit fiscalData path', () => { const result = await page.waitForLastSnackbar(); expect(result).toEqual('Invalid Tax number'); - }, 15000); + }); it(`should edit the fiscal this time with a valid fiscal id`, async() => { await page.clearInput(selectors.clientFiscalData.fiscalId); diff --git a/e2e/paths/02-client-module/04_edit_billing_data.spec.js b/e2e/paths/02-client/04_edit_billing_data.spec.js similarity index 99% rename from e2e/paths/02-client-module/04_edit_billing_data.spec.js rename to e2e/paths/02-client/04_edit_billing_data.spec.js index 7e8df8aa8..b757940be 100644 --- a/e2e/paths/02-client-module/04_edit_billing_data.spec.js +++ b/e2e/paths/02-client/04_edit_billing_data.spec.js @@ -60,7 +60,7 @@ describe('Client Edit billing data path', () => { }); it(`should save the form with all its new data`, async() => { - await page.waitFor(2000); + await page.waitFor(3000); await page.waitForWatcherData(selectors.clientBillingData.watcher); await page.waitToClick(selectors.clientBillingData.saveButton); let snackbarMessage = await page.waitForLastSnackbar(); diff --git a/e2e/paths/02-client-module/05_add_address.spec.js b/e2e/paths/02-client/05_add_address.spec.js similarity index 100% rename from e2e/paths/02-client-module/05_add_address.spec.js rename to e2e/paths/02-client/05_add_address.spec.js diff --git a/e2e/paths/02-client-module/06_add_address_notes.spec.js b/e2e/paths/02-client/06_add_address_notes.spec.js similarity index 100% rename from e2e/paths/02-client-module/06_add_address_notes.spec.js rename to e2e/paths/02-client/06_add_address_notes.spec.js diff --git a/e2e/paths/02-client-module/07_edit_web_access.spec.js b/e2e/paths/02-client/07_edit_web_access.spec.js similarity index 100% rename from e2e/paths/02-client-module/07_edit_web_access.spec.js rename to e2e/paths/02-client/07_edit_web_access.spec.js diff --git a/e2e/paths/02-client-module/08_add_notes.spec.js b/e2e/paths/02-client/08_add_notes.spec.js similarity index 100% rename from e2e/paths/02-client-module/08_add_notes.spec.js rename to e2e/paths/02-client/08_add_notes.spec.js diff --git a/e2e/paths/02-client-module/09_add_credit.spec.js b/e2e/paths/02-client/09_add_credit.spec.js similarity index 94% rename from e2e/paths/02-client-module/09_add_credit.spec.js rename to e2e/paths/02-client/09_add_credit.spec.js index 1cb06fb36..05c50e809 100644 --- a/e2e/paths/02-client-module/09_add_credit.spec.js +++ b/e2e/paths/02-client/09_add_credit.spec.js @@ -24,7 +24,6 @@ describe('Client Add credit path', () => { }); it(`should edit the credit`, async() => { - await page.waitForContentLoaded(); await page.clearInput(selectors.clientCredit.credit); await page.write(selectors.clientCredit.credit, '999'); await page.waitToClick(selectors.clientCredit.saveButton); @@ -34,7 +33,6 @@ describe('Client Add credit path', () => { }); it('should confirm the credit was updated', async() => { - await page.waitForContentLoaded(); const result = await page.waitToGetProperty(selectors.clientCredit.firstCreditText, 'innerText'); expect(result).toContain(999); diff --git a/e2e/paths/02-client-module/10_add_greuge.spec.js b/e2e/paths/02-client/10_add_greuge.spec.js similarity index 100% rename from e2e/paths/02-client-module/10_add_greuge.spec.js rename to e2e/paths/02-client/10_add_greuge.spec.js diff --git a/e2e/paths/02-client-module/11_mandate.spec.js b/e2e/paths/02-client/11_mandate.spec.js similarity index 100% rename from e2e/paths/02-client-module/11_mandate.spec.js rename to e2e/paths/02-client/11_mandate.spec.js diff --git a/e2e/paths/02-client-module/12_lock_of_verified_data.spec.js b/e2e/paths/02-client/12_lock_of_verified_data.spec.js similarity index 100% rename from e2e/paths/02-client-module/12_lock_of_verified_data.spec.js rename to e2e/paths/02-client/12_lock_of_verified_data.spec.js diff --git a/e2e/paths/02-client-module/13_log.spec.js b/e2e/paths/02-client/13_log.spec.js similarity index 100% rename from e2e/paths/02-client-module/13_log.spec.js rename to e2e/paths/02-client/13_log.spec.js diff --git a/e2e/paths/02-client-module/14_balance.spec.js b/e2e/paths/02-client/14_balance.spec.js similarity index 97% rename from e2e/paths/02-client-module/14_balance.spec.js rename to e2e/paths/02-client/14_balance.spec.js index 2e29dc04e..f45937deb 100644 --- a/e2e/paths/02-client-module/14_balance.spec.js +++ b/e2e/paths/02-client/14_balance.spec.js @@ -17,7 +17,6 @@ describe('Client balance path', () => { it('should now edit the local user config data', async() => { await page.waitToClick(selectors.globalItems.userMenuButton); - await page.waitForContentLoaded(); await page.autocompleteSearch(selectors.globalItems.userLocalCompany, 'CCs'); let result = await page.waitForLastSnackbar(); @@ -40,7 +39,7 @@ describe('Client balance path', () => { }); it('should click the new payment button', async() => { - await page.keyboard.press('Escape'); + await page.closePopup(); await page.reloadSection('client.card.balance.index'); let url = await page.expectURL('/balance'); @@ -118,7 +117,6 @@ describe('Client balance path', () => { }); it('should now search for the user Petter Parker', async() => { - await page.waitForContentLoaded(); await page.write(selectors.clientsIndex.topbarSearch, 'Petter Parker'); await page.waitToClick(selectors.clientsIndex.searchButton); await page.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1); diff --git a/e2e/paths/02-client-module/15_user_config.spec.js b/e2e/paths/02-client/15_user_config.spec.js similarity index 99% rename from e2e/paths/02-client-module/15_user_config.spec.js rename to e2e/paths/02-client/15_user_config.spec.js index 6f76c73ca..193305177 100644 --- a/e2e/paths/02-client-module/15_user_config.spec.js +++ b/e2e/paths/02-client/15_user_config.spec.js @@ -21,7 +21,7 @@ describe('User config', () => { it('should now open the user config form to check the settings', async() => { await page.waitToClick(selectors.globalItems.userMenuButton); - await page.waitFor(1000); + await page.waitForContentLoaded(); let expectedLocalWarehouse = await page .expectPropertyValue(selectors.globalItems.userLocalWarehouse, 'value', ''); diff --git a/e2e/paths/02-client-module/16_web_payment.spec.js b/e2e/paths/02-client/16_web_payment.spec.js similarity index 100% rename from e2e/paths/02-client-module/16_web_payment.spec.js rename to e2e/paths/02-client/16_web_payment.spec.js diff --git a/e2e/paths/02-client-module/17_dms.spec.js b/e2e/paths/02-client/17_dms.spec.js similarity index 93% rename from e2e/paths/02-client-module/17_dms.spec.js rename to e2e/paths/02-client/17_dms.spec.js index 01a197c84..9891fd3f4 100644 --- a/e2e/paths/02-client-module/17_dms.spec.js +++ b/e2e/paths/02-client/17_dms.spec.js @@ -27,7 +27,7 @@ describe('Client DMS', () => { it(`should click on the first document line worker name making the descriptor visible`, async() => { await page.waitToClick(selectors.dms.firstDocWorker); - await page.wait(selectors.dms.firstDocWorkerDescriptor); + await page.waitForSelector(selectors.dms.firstDocWorkerDescriptor); const visible = await page.isVisible(selectors.dms.firstDocWorkerDescriptor); expect(visible).toBeTruthy(); diff --git a/e2e/paths/02-client/18_contacts.spec.js b/e2e/paths/02-client/18_contacts.spec.js new file mode 100644 index 000000000..252c5d667 --- /dev/null +++ b/e2e/paths/02-client/18_contacts.spec.js @@ -0,0 +1,37 @@ +import selectors from '../../helpers/selectors'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Client contacts', () => { + let browser; + let page; + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('employee', 'client'); + await page.accessToSearchResult('Clark Kent'); + await page.accessToSection('client.card.contact'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should add a contact', async() => { + await page.waitToClick(selectors.clientContacts.addContactButton); + await page.clearInput(selectors.clientContacts.name); + await page.write(selectors.clientContacts.name, 'Ansible'); + await page.write(selectors.clientContacts.phone, 'FTL comms'); + await page.waitToClick(selectors.clientContacts.saveButton); + let result = await page.waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); + + it('should delete de contact', async() => { + await page.waitToClick(selectors.clientContacts.deleteFirstPhone); + await page.waitToClick(selectors.clientContacts.saveButton); + let result = await page.waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); +}); diff --git a/e2e/paths/02-client/19_summary.spec.js b/e2e/paths/02-client/19_summary.spec.js new file mode 100644 index 000000000..11b5a298e --- /dev/null +++ b/e2e/paths/02-client/19_summary.spec.js @@ -0,0 +1,80 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Client summary path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('employee', 'client'); + await page.accessToSearchResult('Petter Parker'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should reach the first route summary section', async() => { + let url = await page.expectURL('#!/client/102/summary'); + + expect(url).toBe(true); + }); + + it('should display details from the client on the header', async() => { + await page.waitForTextInElement(selectors.clientSummary.header, 'Petter Parker'); + const result = await page.waitToGetProperty(selectors.clientSummary.header, 'innerText'); + + expect(result).toContain('Petter Parker'); + }); + + it('should display some basic data', async() => { + const result = await page.waitToGetProperty(selectors.clientSummary.email, 'innerText'); + + expect(result).toContain('PetterParker@mydomain.com'); + }); + + it('should display fiscal address details', async() => { + const result = await page.waitToGetProperty(selectors.clientSummary.street, 'innerText'); + + expect(result).toContain('20 Ingram Street'); + }); + + it('should display some fiscal data', async() => { + await page.waitForClassPresent(selectors.clientSummary.verifiedData, 'checked'); + const result = await page.waitToGetProperty(selectors.clientSummary.verifiedData, 'innerText'); + + expect(result).toContain('Verified data'); + }); + + it('should display pay method details', async() => { + const result = await page.waitToGetProperty(selectors.clientSummary.payMethod, 'innerText'); + + expect(result).toContain('PayMethod five'); + }); + + it('should display default address details', async() => { + const result = await page.waitToGetProperty(selectors.clientSummary.defaultAdressName, 'innerText'); + + expect(result).toContain('Petter Parker'); + }); + + it('should display web access details', async() => { + const result = await page.waitToGetProperty(selectors.clientSummary.userName, 'innerText'); + + expect(result).toContain('PetterParker'); + }); + + it('should display business data', async() => { + const result = await page.waitToGetProperty(selectors.clientSummary.rate, 'innerText'); + + expect(result).toContain('%'); + }); + + it('should display financial information', async() => { + const result = await page.waitToGetProperty(selectors.clientSummary.credit, 'innerText'); + + expect(result).toContain('€300.00'); + }); +}); diff --git a/e2e/paths/03-worker-module/01_basicData.spec.js b/e2e/paths/03-worker/01_basicData.spec.js similarity index 100% rename from e2e/paths/03-worker-module/01_basicData.spec.js rename to e2e/paths/03-worker/01_basicData.spec.js diff --git a/e2e/paths/03-worker-module/02_time_control.spec.js b/e2e/paths/03-worker/02_time_control.spec.js similarity index 100% rename from e2e/paths/03-worker-module/02_time_control.spec.js rename to e2e/paths/03-worker/02_time_control.spec.js diff --git a/e2e/paths/03-worker-module/03_pbx.spec.js b/e2e/paths/03-worker/03_pbx.spec.js similarity index 100% rename from e2e/paths/03-worker-module/03_pbx.spec.js rename to e2e/paths/03-worker/03_pbx.spec.js diff --git a/e2e/paths/04-item-module/01_summary.spec.js b/e2e/paths/04-item/01_summary.spec.js similarity index 96% rename from e2e/paths/04-item-module/01_summary.spec.js rename to e2e/paths/04-item/01_summary.spec.js index 0196e0930..97fef9ca9 100644 --- a/e2e/paths/04-item-module/01_summary.spec.js +++ b/e2e/paths/04-item/01_summary.spec.js @@ -68,9 +68,8 @@ describe('Item summary path', () => { }); it(`should close the summary popup`, async() => { - await page.keyboard.press('Escape'); - await page.waitUntilNotPresent(selectors.itemSummary.basicData); - await page.waitFor(selectors.itemSummary.basicData, {hidden: true}); + await page.closePopup(); + await page.waitForSelector(selectors.itemSummary.basicData, {hidden: true}); }); it('should search for other item', async() => { @@ -125,7 +124,7 @@ describe('Item summary path', () => { }); it(`should now close the summary popup`, async() => { - await page.keyboard.press('Escape'); + await page.closePopup(); await page.waitForSelector(selectors.itemSummary.basicData, {hidden: true}); }); diff --git a/e2e/paths/04-item-module/02_basic_data.spec.js b/e2e/paths/04-item/02_basic_data.spec.js similarity index 77% rename from e2e/paths/04-item-module/02_basic_data.spec.js rename to e2e/paths/04-item/02_basic_data.spec.js index 2b3ff9d51..64827ed9b 100644 --- a/e2e/paths/04-item-module/02_basic_data.spec.js +++ b/e2e/paths/04-item/02_basic_data.spec.js @@ -39,9 +39,28 @@ describe('Item Edit basic data path', () => { expect(result).toEqual('Data saved!'); }, 20000); + it(`should create a new intrastat`, async() => { + await page.waitToClick(selectors.itemBasicData.newIntrastatButton); + await page.write(selectors.itemBasicData.newIntrastatId, '588420239'); + await page.write(selectors.itemBasicData.newIntrastatDescription, 'Tropical Flowers'); + await page.waitToClick(selectors.itemBasicData.acceptIntrastatButton); + await page.waitForTextInField(selectors.itemBasicData.intrastat, 'Tropical Flowers'); + let newcode = await page.waitToGetProperty(selectors.itemBasicData.intrastat, 'value'); + + expect(newcode).toEqual('588420239 Tropical Flowers'); + }); + + it(`should save with the new intrastat`, async() => { + await page.waitFor(250); + await page.waitForTextInField(selectors.itemBasicData.intrastat, 'Tropical Flowers'); + await page.waitToClick(selectors.itemBasicData.submitBasicDataButton); + const result = await page.waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); + it(`should confirm the item name was edited`, async() => { await page.reloadSection('item.card.basicData'); - await page.waitForContentLoaded(); const result = await page.waitToGetProperty(selectors.itemBasicData.name, 'value'); expect(result).toEqual('Rose of Purity'); @@ -54,11 +73,11 @@ describe('Item Edit basic data path', () => { expect(result).toEqual('Anthurium'); }); - it(`should confirm the item intrastad was edited`, async() => { + it(`should confirm the item intrastat was edited`, async() => { const result = await page .waitToGetProperty(selectors.itemBasicData.intrastat, 'value'); - expect(result).toEqual('5080000 Coral y materiales similares'); + expect(result).toEqual('588420239 Tropical Flowers'); }); it(`should confirm the item relevancy was edited`, async() => { diff --git a/e2e/paths/04-item-module/03_tax.spec.js b/e2e/paths/04-item/03_tax.spec.js similarity index 100% rename from e2e/paths/04-item-module/03_tax.spec.js rename to e2e/paths/04-item/03_tax.spec.js diff --git a/e2e/paths/04-item-module/04_tags.spec.js b/e2e/paths/04-item/04_tags.spec.js similarity index 100% rename from e2e/paths/04-item-module/04_tags.spec.js rename to e2e/paths/04-item/04_tags.spec.js diff --git a/e2e/paths/04-item-module/05_niche.spec.js b/e2e/paths/04-item/05_niche.spec.js similarity index 100% rename from e2e/paths/04-item-module/05_niche.spec.js rename to e2e/paths/04-item/05_niche.spec.js diff --git a/e2e/paths/04-item-module/06_botanical.spec.js b/e2e/paths/04-item/06_botanical.spec.js similarity index 100% rename from e2e/paths/04-item-module/06_botanical.spec.js rename to e2e/paths/04-item/06_botanical.spec.js diff --git a/e2e/paths/04-item-module/07_barcode.spec.js b/e2e/paths/04-item/07_barcode.spec.js similarity index 100% rename from e2e/paths/04-item-module/07_barcode.spec.js rename to e2e/paths/04-item/07_barcode.spec.js diff --git a/e2e/paths/04-item-module/08_create_and_clone.spec.js b/e2e/paths/04-item/08_create_and_clone.spec.js similarity index 99% rename from e2e/paths/04-item-module/08_create_and_clone.spec.js rename to e2e/paths/04-item/08_create_and_clone.spec.js index 7d6a8e54d..32d0ff23b 100644 --- a/e2e/paths/04-item-module/08_create_and_clone.spec.js +++ b/e2e/paths/04-item/08_create_and_clone.spec.js @@ -40,7 +40,6 @@ describe('Item Create/Clone path', () => { }); it('should now access to the create item view by clicking the create floating button', async() => { - await page.waitForContentLoaded(); await page.waitToClick(selectors.itemsIndex.createItemButton); let url = await page.expectURL('#!/item/create'); diff --git a/e2e/paths/04-item-module/09_regularize.spec.js b/e2e/paths/04-item/09_regularize.spec.js similarity index 97% rename from e2e/paths/04-item-module/09_regularize.spec.js rename to e2e/paths/04-item/09_regularize.spec.js index 76e92f8a6..7f63694b9 100644 --- a/e2e/paths/04-item-module/09_regularize.spec.js +++ b/e2e/paths/04-item/09_regularize.spec.js @@ -27,8 +27,7 @@ describe('Item regularize path', () => { const userLocalWarehouse = await page .waitToGetProperty(selectors.globalItems.userLocalWarehouse, 'value'); - await page.keyboard.press('Escape'); - await page.waitForSelector('.user-popover.vn-popover', {hidden: true}); + await page.closePopup(); expect(userLocalWarehouse).toContain('Warehouse Four'); }); @@ -81,7 +80,6 @@ describe('Item regularize path', () => { }); it('should clear the user local settings now', async() => { - await page.waitForTransitionEnd('vn-searchbar'); await page.waitToClick(selectors.globalItems.userMenuButton); await page.clearInput(selectors.globalItems.userConfigFirstAutocomplete); const result = await page.waitForLastSnackbar(); diff --git a/e2e/paths/04-item-module/10_item_index.spec.js b/e2e/paths/04-item/10_item_index.spec.js similarity index 100% rename from e2e/paths/04-item-module/10_item_index.spec.js rename to e2e/paths/04-item/10_item_index.spec.js diff --git a/e2e/paths/04-item-module/11_item_log.spec.js b/e2e/paths/04-item/11_item_log.spec.js similarity index 100% rename from e2e/paths/04-item-module/11_item_log.spec.js rename to e2e/paths/04-item/11_item_log.spec.js diff --git a/e2e/paths/04-item-module/12_descriptor.spec.js b/e2e/paths/04-item/12_descriptor.spec.js similarity index 100% rename from e2e/paths/04-item-module/12_descriptor.spec.js rename to e2e/paths/04-item/12_descriptor.spec.js diff --git a/e2e/paths/05-ticket-module/01-sale/01_list_sales.spec.js b/e2e/paths/05-ticket/01-sale/01_list_sales.spec.js similarity index 100% rename from e2e/paths/05-ticket-module/01-sale/01_list_sales.spec.js rename to e2e/paths/05-ticket/01-sale/01_list_sales.spec.js diff --git a/e2e/paths/05-ticket-module/01-sale/02_edit_sale.spec.js b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js similarity index 100% rename from e2e/paths/05-ticket-module/01-sale/02_edit_sale.spec.js rename to e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js diff --git a/e2e/paths/05-ticket-module/01_observations.spec.js b/e2e/paths/05-ticket/01_observations.spec.js similarity index 99% rename from e2e/paths/05-ticket-module/01_observations.spec.js rename to e2e/paths/05-ticket/01_observations.spec.js index b343bcfeb..cccfa8b67 100644 --- a/e2e/paths/05-ticket-module/01_observations.spec.js +++ b/e2e/paths/05-ticket/01_observations.spec.js @@ -25,7 +25,7 @@ describe('Ticket Create notes path', () => { const result = await page.waitForLastSnackbar(); expect(result).toEqual('Data saved!'); - }, 15000); + }); it('should confirm the note is the expected one', async() => { await page.reloadSection('ticket.card.observation'); diff --git a/e2e/paths/05-ticket-module/02_expeditions_and_log.spec.js b/e2e/paths/05-ticket/02_expeditions_and_log.spec.js similarity index 100% rename from e2e/paths/05-ticket-module/02_expeditions_and_log.spec.js rename to e2e/paths/05-ticket/02_expeditions_and_log.spec.js diff --git a/e2e/paths/05-ticket-module/04_packages.spec.js b/e2e/paths/05-ticket/04_packages.spec.js similarity index 100% rename from e2e/paths/05-ticket-module/04_packages.spec.js rename to e2e/paths/05-ticket/04_packages.spec.js diff --git a/e2e/paths/05-ticket-module/05_tracking_state.spec.js b/e2e/paths/05-ticket/05_tracking_state.spec.js similarity index 100% rename from e2e/paths/05-ticket-module/05_tracking_state.spec.js rename to e2e/paths/05-ticket/05_tracking_state.spec.js diff --git a/e2e/paths/05-ticket-module/06_basic_data_steps.spec.js b/e2e/paths/05-ticket/06_basic_data_steps.spec.js similarity index 100% rename from e2e/paths/05-ticket-module/06_basic_data_steps.spec.js rename to e2e/paths/05-ticket/06_basic_data_steps.spec.js diff --git a/e2e/paths/05-ticket-module/08_components.spec.js b/e2e/paths/05-ticket/08_components.spec.js similarity index 100% rename from e2e/paths/05-ticket-module/08_components.spec.js rename to e2e/paths/05-ticket/08_components.spec.js diff --git a/e2e/paths/05-ticket-module/09_weekly.spec.js b/e2e/paths/05-ticket/09_weekly.spec.js similarity index 96% rename from e2e/paths/05-ticket-module/09_weekly.spec.js rename to e2e/paths/05-ticket/09_weekly.spec.js index e88018ad5..3e791dc18 100644 --- a/e2e/paths/05-ticket-module/09_weekly.spec.js +++ b/e2e/paths/05-ticket/09_weekly.spec.js @@ -8,7 +8,7 @@ describe('Ticket descriptor path', () => { beforeAll(async() => { browser = await getBrowser(); page = browser.page; - await page.loginAndModule('employee', 'ticket'); + await page.loginAndModule('buyer', 'ticket'); await page.accessToSection('ticket.weekly.index'); }); @@ -26,7 +26,6 @@ describe('Ticket descriptor path', () => { it('should go back to the ticket index then search and access a ticket summary', async() => { await page.accessToSection('ticket.index'); await page.accessToSearchResult('11'); - await page.waitForContentLoaded(); }); it('should add the ticket to thursday turn using the descriptor more menu', async() => { @@ -64,7 +63,6 @@ describe('Ticket descriptor path', () => { }); it('should now search for the ticket 11', async() => { - await page.waitForContentLoaded(); await page.write(selectors.ticketsIndex.topbarSearch, '11'); await page.waitToClick(selectors.ticketsIndex.searchButton); await page.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1); @@ -81,7 +79,6 @@ describe('Ticket descriptor path', () => { }); it('should add the ticket to saturday turn using the descriptor more menu', async() => { - await page.waitForContentLoaded(); await page.waitToClick(selectors.ticketDescriptor.moreMenu); await page.waitToClick(selectors.ticketDescriptor.moreMenuAddToTurn); await page.waitToClick(selectors.ticketDescriptor.saturdayButton); diff --git a/e2e/paths/05-ticket-module/10_request.spec.js b/e2e/paths/05-ticket/10_request.spec.js similarity index 100% rename from e2e/paths/05-ticket-module/10_request.spec.js rename to e2e/paths/05-ticket/10_request.spec.js diff --git a/e2e/paths/05-ticket-module/11_diary.spec.js b/e2e/paths/05-ticket/11_diary.spec.js similarity index 100% rename from e2e/paths/05-ticket-module/11_diary.spec.js rename to e2e/paths/05-ticket/11_diary.spec.js diff --git a/e2e/paths/05-ticket-module/12_descriptor.spec.js b/e2e/paths/05-ticket/12_descriptor.spec.js similarity index 98% rename from e2e/paths/05-ticket-module/12_descriptor.spec.js rename to e2e/paths/05-ticket/12_descriptor.spec.js index 6e3864b48..1aa0516de 100644 --- a/e2e/paths/05-ticket-module/12_descriptor.spec.js +++ b/e2e/paths/05-ticket/12_descriptor.spec.js @@ -34,7 +34,6 @@ describe('Ticket descriptor path', () => { }); it(`should update the shipped hour using the descriptor menu`, async() => { - await page.waitForContentLoaded(); await page.waitToClick(selectors.ticketDescriptor.moreMenu); await page.waitToClick(selectors.ticketDescriptor.moreMenuChangeShippedHour); await page.pickTime(selectors.ticketDescriptor.changeShippedHour, '08:15'); @@ -130,7 +129,6 @@ describe('Ticket descriptor path', () => { }); it('should delete the stowaway', async() => { - await page.waitForContentLoaded(); await page.waitToClick(selectors.ticketDescriptor.moreMenu); await page.waitToClick(selectors.ticketDescriptor.moreMenuDeleteStowawayButton); await page.waitToClick(selectors.ticketDescriptor.acceptDeleteStowawayButton); diff --git a/e2e/paths/05-ticket-module/13_services.spec.js b/e2e/paths/05-ticket/13_services.spec.js similarity index 98% rename from e2e/paths/05-ticket-module/13_services.spec.js rename to e2e/paths/05-ticket/13_services.spec.js index cafc5f27c..0a09c7aa3 100644 --- a/e2e/paths/05-ticket-module/13_services.spec.js +++ b/e2e/paths/05-ticket/13_services.spec.js @@ -26,7 +26,7 @@ describe('Ticket services path', () => { const result = await page.isDisabled(selectors.ticketService.firstAddServiceTypeButton); expect(result).toBeTruthy(); - }, 15000); + }); it('should receive an error if you attempt to save a service without access rights', async() => { await page.clearInput(selectors.ticketService.firstPrice); @@ -50,7 +50,6 @@ describe('Ticket services path', () => { }); it('should click on the add button to prepare the form to create a new service', async() => { - await page.waitForContentLoaded(); await page.waitToClick(selectors.ticketService.addServiceButton); const result = await page .isVisible(selectors.ticketService.firstServiceType); diff --git a/e2e/paths/05-ticket-module/14_create_ticket.spec.js b/e2e/paths/05-ticket/14_create_ticket.spec.js similarity index 100% rename from e2e/paths/05-ticket-module/14_create_ticket.spec.js rename to e2e/paths/05-ticket/14_create_ticket.spec.js diff --git a/e2e/paths/05-ticket-module/15_create_ticket_from_client.spec.js b/e2e/paths/05-ticket/15_create_ticket_from_client.spec.js similarity index 96% rename from e2e/paths/05-ticket-module/15_create_ticket_from_client.spec.js rename to e2e/paths/05-ticket/15_create_ticket_from_client.spec.js index 80bb217fb..28c11de3a 100644 --- a/e2e/paths/05-ticket-module/15_create_ticket_from_client.spec.js +++ b/e2e/paths/05-ticket/15_create_ticket_from_client.spec.js @@ -17,7 +17,6 @@ describe('Ticket create from client path', () => { }); it('should click the create simple ticket on the descriptor menu', async() => { - await page.waitForContentLoaded(); await page.waitToClick(selectors.clientDescriptor.moreMenu); await page.waitToClick(selectors.clientDescriptor.simpleTicketButton); let url = await page.expectURL('clientFk=102'); diff --git a/e2e/paths/05-ticket-module/16_summary.spec.js b/e2e/paths/05-ticket/16_summary.spec.js similarity index 100% rename from e2e/paths/05-ticket-module/16_summary.spec.js rename to e2e/paths/05-ticket/16_summary.spec.js diff --git a/e2e/paths/06-claim-module/01_basic_data.spec.js b/e2e/paths/06-claim/01_basic_data.spec.js similarity index 100% rename from e2e/paths/06-claim-module/01_basic_data.spec.js rename to e2e/paths/06-claim/01_basic_data.spec.js diff --git a/e2e/paths/06-claim-module/02_development.spec.js b/e2e/paths/06-claim/02_development.spec.js similarity index 99% rename from e2e/paths/06-claim-module/02_development.spec.js rename to e2e/paths/06-claim/02_development.spec.js index 351dee50f..346f88581 100644 --- a/e2e/paths/06-claim-module/02_development.spec.js +++ b/e2e/paths/06-claim/02_development.spec.js @@ -29,7 +29,7 @@ describe('Claim development', () => { const result = await page.waitForLastSnackbar(); expect(result).toEqual('Data saved!'); - }, 15000); + }); it(`should redirect to the next section of claims as the role is salesAssistant`, async() => { let url = await page.expectURL('/action'); diff --git a/e2e/paths/06-claim-module/03_detail.spec.js b/e2e/paths/06-claim/03_detail.spec.js similarity index 100% rename from e2e/paths/06-claim-module/03_detail.spec.js rename to e2e/paths/06-claim/03_detail.spec.js diff --git a/e2e/paths/06-claim-module/04_claim_action.spec.js b/e2e/paths/06-claim/04_claim_action.spec.js similarity index 100% rename from e2e/paths/06-claim-module/04_claim_action.spec.js rename to e2e/paths/06-claim/04_claim_action.spec.js diff --git a/e2e/paths/06-claim-module/05_summary.spec.js b/e2e/paths/06-claim/05_summary.spec.js similarity index 95% rename from e2e/paths/06-claim-module/05_summary.spec.js rename to e2e/paths/06-claim/05_summary.spec.js index a9d97533c..9dab65954 100644 --- a/e2e/paths/06-claim-module/05_summary.spec.js +++ b/e2e/paths/06-claim/05_summary.spec.js @@ -60,8 +60,7 @@ describe('claim Summary path', () => { it(`should check the url for the item diary link of the descriptor is for the right item id`, async() => { await page.waitForSelector(selectors.claimSummary.itemDescriptorPopoverItemDiaryButton, {visible: true}); - await page.keyboard.press('Escape'); - await page.waitFor(1000); + await page.closePopup(); }); it('should display the claim development details', async() => { @@ -81,8 +80,7 @@ describe('claim Summary path', () => { it(`should check the url for the go to clientlink of the descriptor is for the right client id`, async() => { await page.waitForSelector(selectors.claimSummary.firstDevelopmentWorkerGoToClientButton, {visible: true}); - await page.keyboard.press('Escape'); - await page.waitFor(1000); + await page.closePopup(); }); it(`should click on the first action ticket ID making the ticket descriptor visible`, async() => { diff --git a/e2e/paths/06-claim-module/06_descriptor.spec.js b/e2e/paths/06-claim/06_descriptor.spec.js similarity index 98% rename from e2e/paths/06-claim-module/06_descriptor.spec.js rename to e2e/paths/06-claim/06_descriptor.spec.js index 8e6b3fd05..104f63945 100644 --- a/e2e/paths/06-claim-module/06_descriptor.spec.js +++ b/e2e/paths/06-claim/06_descriptor.spec.js @@ -24,7 +24,6 @@ describe('claim Descriptor path', () => { }); it(`should not be able to see the delete claim button of the descriptor more menu`, async() => { - await page.waitForContentLoaded(); await page.waitToClick(selectors.claimDescriptor.moreMenu); await page.waitForSelector(selectors.claimDescriptor.moreMenuDeleteClaim, {hidden: true}); }); diff --git a/e2e/paths/07-order-module/01_edit_basic_data.spec.js b/e2e/paths/07-order/01_edit_basic_data.spec.js similarity index 97% rename from e2e/paths/07-order-module/01_edit_basic_data.spec.js rename to e2e/paths/07-order/01_edit_basic_data.spec.js index 2cbee95f7..768985628 100644 --- a/e2e/paths/07-order-module/01_edit_basic_data.spec.js +++ b/e2e/paths/07-order/01_edit_basic_data.spec.js @@ -27,7 +27,7 @@ describe('Order edit basic data path', () => { const result = await page.waitForLastSnackbar(); expect(result).toEqual(`You can't make changes on the basic data of an confirmed order or with rows`); - }, 15000); + }); }); describe('when order with rows', () => { @@ -39,7 +39,6 @@ describe('Order edit basic data path', () => { await page.waitForContentLoaded(); await page.accessToSearchResult(orderId); await page.accessToSection('order.card.basicData'); - await page.waitForContentLoaded(); await page.waitForSelector(selectors.orderBasicData.observation, {visible: true}); let url = await page.expectURL(`#!/order/${orderId}/basic-data`); @@ -47,7 +46,6 @@ describe('Order edit basic data path', () => { }); it('should not be able to change anything', async() => { - await page.waitForContentLoaded(); await page.write(selectors.orderBasicData.observation, 'observation'); await page.waitToClick(selectors.orderBasicData.saveButton); const result = await page.waitForLastSnackbar(); diff --git a/e2e/paths/07-order-module/02_catalog.spec.js b/e2e/paths/07-order/02_catalog.spec.js similarity index 97% rename from e2e/paths/07-order-module/02_catalog.spec.js rename to e2e/paths/07-order/02_catalog.spec.js index d67dd3c92..ca6489779 100644 --- a/e2e/paths/07-order-module/02_catalog.spec.js +++ b/e2e/paths/07-order/02_catalog.spec.js @@ -35,9 +35,7 @@ describe('Order catalog', () => { }); it('should add the realm and type filters and obtain results', async() => { - await page.waitForContentLoaded(); await page.waitToClick(selectors.orderCatalog.plantRealmButton); - await page.waitForContentLoaded(); await page.autocompleteSearch(selectors.orderCatalog.type, 'Anthurium'); await page.waitForNumberOfElements('section.product', 4); const result = await page.countElement('section.product'); diff --git a/e2e/paths/07-order-module/03_lines.spec.js b/e2e/paths/07-order/03_lines.spec.js similarity index 100% rename from e2e/paths/07-order-module/03_lines.spec.js rename to e2e/paths/07-order/03_lines.spec.js diff --git a/e2e/paths/08-route/01_summary.spec.js b/e2e/paths/08-route/01_summary.spec.js new file mode 100644 index 000000000..c062b9b08 --- /dev/null +++ b/e2e/paths/08-route/01_summary.spec.js @@ -0,0 +1,61 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Route summary path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('employee', 'route'); + await page.waitToClick('vn-route-index vn-tbody > a:nth-child(1)'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should reach the first route summary section', async() => { + let url = await page.expectURL('#!/route/1/summary'); + + expect(url).toBe(true); + }); + + it(`should display details from the route on the header`, async() => { + await page.waitForTextInElement(selectors.routeSummary.header, 'first route'); + const result = await page.waitToGetProperty(selectors.routeSummary.header, 'innerText'); + + expect(result).toContain('first route'); + }); + + it('should display some route details like the cost', async() => { + const result = await page.waitToGetProperty(selectors.routeSummary.cost, 'innerText'); + + expect(result).toContain('€10.00'); + }); + + it('should click on the first ticket ID making the descriptor popover visible', async() => { + await page.waitToClick(selectors.routeSummary.firstTicketID); + await page.waitForSelector(selectors.routeSummary.firstTicketDescriptor); + const visible = await page.isVisible(selectors.routeSummary.firstTicketDescriptor); + + expect(visible).toBe(true); + }); + + it('should close the ticket descriptor', async() => { + await page.closePopup(); + }); + + it('should click on the first alias making the client descriptor popover visible', async() => { + await page.waitToClick(selectors.routeSummary.firstAlias); + await page.waitForSelector(selectors.routeSummary.firstClientDescriptor); + const visible = await page.isVisible(selectors.routeSummary.firstClientDescriptor); + + expect(visible).toBe(true); + }); + + it('should close the client descriptor', async() => { + await page.closePopup(); + }); +}); diff --git a/e2e/paths/08-route-module/02_basic_data.spec.js b/e2e/paths/08-route/02_basic_data.spec.js similarity index 99% rename from e2e/paths/08-route-module/02_basic_data.spec.js rename to e2e/paths/08-route/02_basic_data.spec.js index 7828b3827..91688b3ff 100644 --- a/e2e/paths/08-route-module/02_basic_data.spec.js +++ b/e2e/paths/08-route/02_basic_data.spec.js @@ -31,7 +31,7 @@ describe('Route basic Data path', () => { const result = await page.waitForLastSnackbar(); expect(result).toEqual('Data saved!'); - }, 15000); + }); it('should confirm the worker was edited', async() => { await page.reloadSection('route.card.basicData'); diff --git a/e2e/paths/08-route-module/01_create.spec.js b/e2e/paths/08-route/03_create.spec.js similarity index 98% rename from e2e/paths/08-route-module/01_create.spec.js rename to e2e/paths/08-route/03_create.spec.js index 14d5273b3..11ffd500b 100644 --- a/e2e/paths/08-route-module/01_create.spec.js +++ b/e2e/paths/08-route/03_create.spec.js @@ -37,7 +37,6 @@ describe('Route create path', () => { beforeAll(async() => { await page.login('delivery'); await page.selectModule('route'); - await page.changeLanguageToEnglish(); }); it('should again click on the add new route button and open the creation form', async() => { diff --git a/e2e/paths/08-route-module/03_tickets.spec.js b/e2e/paths/08-route/04_tickets.spec.js similarity index 100% rename from e2e/paths/08-route-module/03_tickets.spec.js rename to e2e/paths/08-route/04_tickets.spec.js diff --git a/e2e/paths/09-invoice-out/01_summary.spec.js b/e2e/paths/09-invoice-out/01_summary.spec.js new file mode 100644 index 000000000..126c745d3 --- /dev/null +++ b/e2e/paths/09-invoice-out/01_summary.spec.js @@ -0,0 +1,48 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('InvoiceOut summary path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('employee', 'invoiceOut'); + await page.accessToSearchResult('T1111111'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should reach the summary section', async() => { + const result = await page.expectURL('/summary'); + + expect(result).toBe(true); + }); + + it('should contain the company from which the invoice is emited', async() => { + const result = await page.waitToGetProperty(selectors.invoiceOutSummary.company, 'innerText'); + + expect(result).toEqual('Company VNL'); + }); + + it('should contain the tax breakdown', async() => { + const firstTax = await page.waitToGetProperty(selectors.invoiceOutSummary.taxOne, 'innerText'); + + const secondTax = await page.waitToGetProperty(selectors.invoiceOutSummary.taxTwo, 'innerText'); + + expect(firstTax).toContain('10%'); + expect(secondTax).toContain('21%'); + }); + + it('should contain the tickets info', async() => { + const firstTicket = await page.waitToGetProperty(selectors.invoiceOutSummary.ticketOne, 'innerText'); + + const secondTicket = await page.waitToGetProperty(selectors.invoiceOutSummary.ticketTwo, 'innerText'); + + expect(firstTicket).toContain('Bat cave'); + expect(secondTicket).toContain('Stark tower'); + }); +}); diff --git a/e2e/paths/09-invoice-out-module/01_descriptor.spec.js b/e2e/paths/09-invoice-out/02_descriptor.spec.js similarity index 98% rename from e2e/paths/09-invoice-out-module/01_descriptor.spec.js rename to e2e/paths/09-invoice-out/02_descriptor.spec.js index a51ae9d8f..e70c39ded 100644 --- a/e2e/paths/09-invoice-out-module/01_descriptor.spec.js +++ b/e2e/paths/09-invoice-out/02_descriptor.spec.js @@ -37,7 +37,6 @@ describe('InvoiceOut descriptor path', () => { }); it('should search for the target invoiceOut', async() => { - await page.waitForContentLoaded(); await page.write(selectors.invoiceOutIndex.topbarSearch, 'T2222222'); await page.waitToClick(selectors.invoiceOutIndex.searchButton); await page.waitForNumberOfElements(selectors.invoiceOutIndex.searchResult, 1); @@ -108,7 +107,6 @@ describe('InvoiceOut descriptor path', () => { }); it(`should search and access to the invoiceOut summary`, async() => { - await page.waitForContentLoaded(); await page.accessToSearchResult('T1111111'); let url = await page.expectURL('/summary'); diff --git a/e2e/paths/10-travel/01_thermograph.spec.js b/e2e/paths/10-travel/01_thermograph.spec.js new file mode 100644 index 000000000..efa2295a6 --- /dev/null +++ b/e2e/paths/10-travel/01_thermograph.spec.js @@ -0,0 +1,52 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Travel thermograph path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('buyer', 'travel'); + await page.accessToSearchResult('3'); + await page.accessToSection('travel.card.thermograph.index'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should reach the thermograph section', async() => { + const result = await page.expectURL('/thermograph/index'); + + expect(result).toBe(true); + }); + + it('should click the add thermograph floating button', async() => { + await page.waitToClick(selectors.travelThermograph.add); + const result = await page.expectURL('/thermograph/create'); + + expect(result).toBe(true); + }); + + it('should select the thermograph and then the file to upload', async() => { + let currentDir = process.cwd(); + let filePath = `${currentDir}/e2e/dms/ecc/3.jpeg`; + await page.autocompleteSearch(selectors.travelThermograph.thermographID, '138350-0'); + + const [fileChooser] = await Promise.all([ + page.waitForFileChooser(), + page.waitToClick(selectors.travelThermograph.uploadIcon) + ]); + await fileChooser.accept([filePath]); + + await page.waitToClick(selectors.travelThermograph.upload); + }); + + it('should reload the section and check everything was saved', async() => { + let createdThermograph = await page.waitToGetProperty(selectors.travelThermograph.createdThermograph, 'innerText'); + + expect(createdThermograph).toContain('138350-0'); + }); +}); diff --git a/e2e/paths/11-agency/01_basic-data.spec.js b/e2e/paths/11-agency/01_basic-data.spec.js new file mode 100644 index 000000000..43369aeab --- /dev/null +++ b/e2e/paths/11-agency/01_basic-data.spec.js @@ -0,0 +1,103 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Agency basic data path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('deliveryBoss', 'zone'); // turns up the agency module name and route aint the same lol + await page.accessToSearchResult('10'); + await page.accessToSection('zone.card.basicData'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should reach the basic data section', async() => { + let url = await page.expectURL('#!/zone/10/basic-data'); + + expect(url).toBe(true); + }); + + it('should edit de form and then save', async() => { + await page.clearInput(selectors.agencyBasicData.name); + await page.write(selectors.agencyBasicData.name, 'Brimstone teleportation'); + await page.autocompleteSearch(selectors.agencyBasicData.agency, 'Quantum break device'); + await page.write(selectors.agencyBasicData.maxVolume, '10'); + await page.clearInput(selectors.agencyBasicData.travelingDays); + await page.write(selectors.agencyBasicData.travelingDays, '1'); + await page.clearInput(selectors.agencyBasicData.closing); + await page.type(selectors.agencyBasicData.closing, '2100'); + await page.clearInput(selectors.agencyBasicData.price); + await page.write(selectors.agencyBasicData.price, '999'); + await page.clearInput(selectors.agencyBasicData.bonus); + await page.write(selectors.agencyBasicData.bonus, '100'); + await page.clearInput(selectors.agencyBasicData.inflation); + await page.write(selectors.agencyBasicData.inflation, '200'); + await page.waitToClick(selectors.agencyBasicData.volumetric); + await page.waitToClick(selectors.agencyBasicData.saveButton); + }); + + it('should reload the section', async() => { + await page.reloadSection('zone.card.basicData'); + let url = await page.expectURL('#!/zone/10/basic-data'); + + expect(url).toBe(true); + }); + + it('should confirm the name was updated', async() => { + const result = await page.waitToGetProperty(selectors.agencyBasicData.name, 'value'); + + expect(result).toEqual('Brimstone teleportation'); + }); + + it('should confirm the agency was updated', async() => { + const result = await page.waitToGetProperty(selectors.agencyBasicData.agency, 'value'); + + expect(result).toEqual('Quantum break device'); + }); + + it('should confirm the max volume was updated', async() => { + const result = await page.waitToGetProperty(selectors.agencyBasicData.maxVolume, 'value'); + + expect(result).toEqual('10'); + }); + + it('should confirm the traveling days were updated', async() => { + const result = await page.waitToGetProperty(selectors.agencyBasicData.travelingDays, 'value'); + + expect(result).toEqual('1'); + }); + + it('should confirm the closing hour was updated', async() => { + const result = await page.waitToGetProperty(selectors.agencyBasicData.closing, 'value'); + + expect(result).toEqual('21:00'); + }); + + it('should confirm the price was updated', async() => { + const result = await page.waitToGetProperty(selectors.agencyBasicData.price, 'value'); + + expect(result).toEqual('999'); + }); + + it('should confirm the bonus was updated', async() => { + const result = await page.waitToGetProperty(selectors.agencyBasicData.bonus, 'value'); + + expect(result).toEqual('100'); + }); + + it('should confirm the inflation was updated', async() => { + const result = await page.waitToGetProperty(selectors.agencyBasicData.inflation, 'value'); + + expect(result).toEqual('200'); + }); + + it('should confirm the volumetric checkbox was checked', async() => { + await page.waitForClassPresent(selectors.agencyBasicData.volumetric, 'checked'); + }); +}); diff --git a/front/core/components/button/index.js b/front/core/components/button/index.js index 96d68c23b..e8c998801 100644 --- a/front/core/components/button/index.js +++ b/front/core/components/button/index.js @@ -29,8 +29,10 @@ export default class Button extends FormInput { } onClick(event) { - if (this.disabled) + if (this.disabled) { + event.preventDefault(); event.stopImmediatePropagation(); + } } } Button.$inject = ['$element', '$scope']; diff --git a/front/core/components/datalist/index.html b/front/core/components/datalist/index.html new file mode 100644 index 000000000..15c0f0e8a --- /dev/null +++ b/front/core/components/datalist/index.html @@ -0,0 +1,36 @@ +
+
+
+
+
+
+
+ +
+
+ + + + +
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/front/core/components/datalist/index.js b/front/core/components/datalist/index.js new file mode 100644 index 000000000..bf3cab9a1 --- /dev/null +++ b/front/core/components/datalist/index.js @@ -0,0 +1,293 @@ +import ngModule from '../../module'; +import ArrayModel from '../array-model/array-model'; +import CrudModel from '../crud-model/crud-model'; +import {mergeWhere} from 'vn-loopback/util/filter'; +import Textfield from '../textfield/textfield'; +import './style.scss'; + +export default class Datalist extends Textfield { + constructor($element, $scope, $compile, $transclude) { + super($element, $scope, $compile); + this.$transclude = $transclude; + this.searchDelay = 300; + this._selection = null; + + this.buildInput('text'); + this.input.setAttribute('autocomplete', 'off'); + } + + get field() { + return super.field; + } + + set field(value) { + let oldValue = super.field; + super.field = value; + + value = value == '' || value == null ? null : value; + oldValue = oldValue == '' || oldValue == null ? null : oldValue; + + this.refreshSelection(); + + if (!value || value === oldValue && this.modelData != null) return; + + if (this.validSelection(value)) return; + + if (!oldValue) + return this.fetchSelection(); + + this.$timeout.cancel(this.searchTimeout); + + if (this.model) { + this.model.clear(); + if (!this.data) { + this.searchTimeout = this.$timeout(() => { + this.refreshModel(); + this.searchTimeout = null; + }, this.field != null ? this.searchDelay : 0); + } else + this.refreshModel(); + } + } + + validSelection(selection) { + return this.modelData && this.modelData.find(item => { + return item[this.valueField] == selection; + }); + } + + refreshSelection() { + const selectedItem = this.validSelection(this.field); + + if (this.field == null) { + this.selection = null; + return; + } + + if (selectedItem) + this.selection = selectedItem; + } + + get name() { + return super.name; + } + + set name(value) { + super.name = value; + + this.input.setAttribute('list', `datalist-${value}`); + } + + get modelData() { + return this.model ? this.model.data : null; + } + + get url() { + return this._url; + } + + set url(value) { + this._url = value; + if (value) { + this.model = new CrudModel(this.$q, this.$http); + this.model.autoLoad = false; + this.model.url = value; + this.model.$onInit(); + } + } + + get data() { + return this._data; + } + + set data(value) { + this._data = value; + if (value) { + this.model = new ArrayModel(this.$q, this.$filter); + this.model.autoLoad = false; + this.model.orgData = value; + this.model.$onInit(); + } + } + + /** + * @type {Object} The selected data object, you can use this property + * to prevent requests to display the initial value. + */ + get selection() { + return this._selection; + } + + set selection(value) { + this._selection = value; + } + + refreshModel() { + let model = this.model; + + let order; + if (this.order) + order = this.order; + else if (this.showField) + order = `${this.showField} ASC`; + + let filter = { + order, + limit: this.limit || 30 + }; + + if (model instanceof CrudModel) { + let searchExpr = this._field == null + ? null + : this.searchFunction({$search: this._field}); + + Object.assign(filter, { + fields: this.getFields(), + include: this.include, + where: mergeWhere(this.where, searchExpr) + }); + } else if (model instanceof ArrayModel) { + if (this._field != null) + filter.where = this.searchFunction({$search: this._field}); + } + + return this.model.applyFilter(filter).then(() => { + if (this.validSelection(this.field)) { + this.refreshSelection(); + this.destroyList(); + } else + this.buildList(); + }); + } + + searchFunction(scope) { + if (this.model instanceof CrudModel) + return {[this.showField]: {like: `%${scope.$search}%`}}; + if (this.model instanceof ArrayModel) + return {[this.showField]: scope.$search}; + } + + fetchSelection() { + const data = this.modelData; + + if (data) { + let selection = data.find(i => this.validSelection(i[this.valueField])); + if (selection) return selection; + } + + if (this.url) { + let where = {}; + + if (this.multiple) + where[this.valueField] = {inq: this.field}; + else + where[this.valueField] = this.field; + + where = mergeWhere(where, this.fetchFunction); + + let filter = { + fields: this.getFields(), + where: where + }; + + let json = encodeURIComponent(JSON.stringify(filter)); + this.$http.get(`${this.url}?filter=${json}`).then( + json => this.onSelectionRequest(json.data), + () => this.onSelectionRequest() + ); + } + + return null; + } + + onSelectionRequest(data) { + if (data && data.length > 0) { + if (this.multiple) + this.selection = data; + else + this.selection = data[0]; + } else + this.selection = null; + } + + getFields() { + const fields = []; + fields.push(this.valueField); + fields.push(this.showField); + + if (this.fields) { + for (let field of this.fields) + fields.push(field); + } + + return fields; + } + + buildList() { + const list = this.$.datalist; + const data = this.modelData; + + this.destroyList(); + + const hasTemplate = this.$transclude && this.$transclude.isSlotFilled('tplItem'); + const fragment = this.document.createDocumentFragment(); + + if (data) { + for (let item of data) { + const option = document.createElement('option'); + option.setAttribute('value', item[this.valueField]); + + if (hasTemplate) { + this.$transclude((clone, scope) => { + Object.assign(scope, item); + option.appendChild(clone[0]); + this.scopes.push(scope); + }, null, 'tplItem'); + } else { + const text = document.createTextNode(item[this.showField]); + option.appendChild(text); + } + + fragment.appendChild(option); + } + + list.appendChild(fragment); + } + } + + destroyList() { + const list = this.$.datalist; + if (list) + list.innerHTML = ''; + + if (this.scopes) { + for (let scope of this.scopes) + scope.$destroy(); + } + + this.scopes = []; + } +} + +Datalist.$inject = ['$element', '$scope', '$compile', '$transclude']; + +ngModule.vnComponent('vnDatalist', { + controller: Datalist, + template: require('./index.html'), + bindings: { + showField: '@?', + valueField: '@?', + selection: '=?', + multiple: ' { - element.$ctrl.disabled = true; + const controller = element.$ctrl; + controller.$oldDisabled = controller.disabled; + controller.disabled = true; cb($scope).finally(() => { - element.$ctrl.disabled = false; + if (!controller.$oldDisabled) + controller.disabled = false; }); }); } diff --git a/front/core/directives/http-submit.js b/front/core/directives/http-submit.js index 0cf17866e..3d93f0220 100644 --- a/front/core/directives/http-submit.js +++ b/front/core/directives/http-submit.js @@ -19,12 +19,16 @@ export function directive($parse) { const fields = angular.element(elements); angular.forEach(fields, field => { - field.$ctrl.disabled = true; + const controller = field.$ctrl; + controller.$oldDisabled = controller.disabled; + controller.disabled = true; }); cb($scope).finally(() => { angular.forEach(fields, field => { - field.$ctrl.disabled = false; + const controller = field.$ctrl; + if (!controller.$oldDisabled) + controller.disabled = false; }); }); }); diff --git a/front/core/module.js b/front/core/module.js index 0c52fd565..82a954892 100644 --- a/front/core/module.js +++ b/front/core/module.js @@ -80,7 +80,7 @@ export function config($translateProvider, $translatePartialLoaderProvider, $ani let langs = ['en', 'es']; let langAliases = { en_US: 'en', - en_UK: 'en', + en_GB: 'en', es_ES: 'es', es_AR: 'es' }; diff --git a/gulpfile.js b/gulpfile.js index 853fcf2d4..eb421ba9b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -174,12 +174,13 @@ function e2eSingleRun() { `${__dirname}/e2e/paths/07*/*[sS]pec.js`, `${__dirname}/e2e/paths/08*/*[sS]pec.js`, `${__dirname}/e2e/paths/09*/*[sS]pec.js`, + `${__dirname}/e2e/paths/10*/*[sS]pec.js`, `${__dirname}/e2e/paths/**/*[sS]pec.js` ]; return gulp.src(specFiles).pipe(jasmine({ errorOnFail: false, - timeout: 10000, + timeout: 30000, reporter: [ new SpecReporter({ spec: { diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 23717ba8f..49cd0f171 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -61,7 +61,7 @@ "MESSAGE_BOUGHT_UNITS": "Bought {{quantity}} units of {{concept}} (#{{itemId}}) for the ticket id [#{{ticketId}}]({{{url}}})", "MESSAGE_INSURANCE_CHANGE": "I have changed the insurence credit of client [{{clientName}} (#{{clientId}})]({{{url}}}) to *{{credit}} €*", "MESSAGE_CHANGED_PAYMETHOD": "I have changed the pay method for client [{{clientName}} (#{{clientId}})]({{{url}}})", - "MESSAGE_CLAIM_ITEM_REGULARIZE": "I sent *{{quantity}}* units of [{{concept}} (#{{itemId}})]({{{itemUrl}}}) to {{nickname}} coming from ticket id [#{{ticketId}}]({{{ticketUrl}}})", + "Sent units from ticket": "I sent *{{quantity}}* units of [{{concept}} (#{{itemId}})]({{{itemUrl}}}) to *\"{{nickname}}\"* coming from ticket id [#{{ticketId}}]({{{ticketUrl}}})", "Customs agent is required for a non UEE member": "Customs agent is required for a non UEE member", "Incoterms is required for a non UEE member": "Incoterms is required for a non UEE member", "Client checked as validated despite of duplication": "Client checked as validated despite of duplication from client id {{clientId}}" diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 90d4f8793..7577c5349 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -124,7 +124,8 @@ "MESSAGE_BOUGHT_UNITS": "Se ha comprado {{quantity}} unidades de {{concept}} (#{{itemId}}) para el ticket id [#{{ticketId}}]({{{url}}})", "MESSAGE_INSURANCE_CHANGE": "He cambiado el crédito asegurado del cliente [{{clientName}} (#{{clientId}})]({{{url}}}) a *{{credit}} €*", "MESSAGE_CHANGED_PAYMETHOD": "He cambiado la forma de pago del cliente [{{clientName}} (#{{clientId}})]({{{url}}})", - "MESSAGE_CLAIM_ITEM_REGULARIZE": "Envio *{{quantity}}* unidades de [{{concept}} (#{{itemId}})]({{{itemUrl}}}) a {{nickname}} provenientes del ticket id [#{{ticketId}}]({{{ticketUrl}}})", + "Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} (#{{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [#{{ticketId}}]({{{ticketUrl}}})", "Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}", - "ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto" + "ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto", + "Distance must be lesser than 1000": "La distancia debe ser inferior a 1000" } \ No newline at end of file diff --git a/modules/agency/back/model-config.json b/modules/agency/back/model-config.json index 7638e3f6c..c9a49ffe9 100644 --- a/modules/agency/back/model-config.json +++ b/modules/agency/back/model-config.json @@ -11,7 +11,7 @@ "Zone": { "dataSource": "vn" }, - "ZoneClosure": { + "ZoneCalcTicket": { "dataSource": "vn" }, "ZoneEvent": { diff --git a/modules/agency/back/models/zone-calc-ticket.js b/modules/agency/back/models/zone-calc-ticket.js new file mode 100644 index 000000000..c3633e8f4 --- /dev/null +++ b/modules/agency/back/models/zone-calc-ticket.js @@ -0,0 +1,24 @@ +const app = require('vn-loopback/server/server'); + + +module.exports = Self => { + app.on('started', function() { + let models = ['Zone', 'ZoneEvent', 'ZoneExclusion']; + + for (let modelName of models) { + let Model = app.models[modelName]; + + Model.observe('after save', doCalc); + Model.observe('after delete', doCalc); + } + + async function doCalc(ctx) { + try { + await Self.create({zoneFk: ctx.instance.zoneFk || ctx.instance.id}); + } catch (err) { + if (err.code != 'ER_DUP_ENTRY') + throw err; + } + } + }); +}; diff --git a/modules/agency/back/models/zone-closure.json b/modules/agency/back/models/zone-calc-ticket.json similarity index 62% rename from modules/agency/back/models/zone-closure.json rename to modules/agency/back/models/zone-calc-ticket.json index 895374838..5083d08ed 100644 --- a/modules/agency/back/models/zone-closure.json +++ b/modules/agency/back/models/zone-calc-ticket.json @@ -1,23 +1,15 @@ { - "name": "ZoneClosure", + "name": "ZoneCalcTicket", "base": "VnModel", "options": { "mysql": { - "table": "zoneClosure" + "table": "zoneCalcTicket" } }, "properties": { "zoneFk": { "id": true, "type": "Number" - }, - "dated": { - "type": "Date", - "required": true - }, - "hour": { - "type": "date", - "required": true } }, "relations": { diff --git a/modules/agency/back/models/zone-closure.js b/modules/agency/back/models/zone-closure.js deleted file mode 100644 index 8b66e31ae..000000000 --- a/modules/agency/back/models/zone-closure.js +++ /dev/null @@ -1,13 +0,0 @@ -module.exports = Self => { - Self.doRecalc = async function() { - try { - await Self.rawSql(` - CREATE EVENT zoneClosure_doRecalc - ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 15 SECOND - DO CALL zoneClosure_recalc; - `); - } catch (err) { - if (err.code != 'ER_EVENT_ALREADY_EXISTS') throw err; - } - }; -}; diff --git a/modules/agency/back/models/zone-event.js b/modules/agency/back/models/zone-event.js index 46b2df202..d4fad8e96 100644 --- a/modules/agency/back/models/zone-event.js +++ b/modules/agency/back/models/zone-event.js @@ -34,12 +34,4 @@ module.exports = Self => { }, { message: `You should mark at least one week day` }); - - Self.observe('after save', async function() { - await app.models.ZoneClosure.doRecalc(); - }); - - Self.observe('after delete', async function() { - await app.models.ZoneClosure.doRecalc(); - }); }; diff --git a/modules/agency/back/models/zone-exclusion.js b/modules/agency/back/models/zone-exclusion.js deleted file mode 100644 index 51998aab8..000000000 --- a/modules/agency/back/models/zone-exclusion.js +++ /dev/null @@ -1,11 +0,0 @@ -const app = require('vn-loopback/server/server'); - -module.exports = Self => { - Self.observe('after save', async function() { - await app.models.ZoneClosure.doRecalc(); - }); - - Self.observe('after delete', async function() { - await app.models.ZoneClosure.doRecalc(); - }); -}; diff --git a/modules/agency/back/models/zone.js b/modules/agency/back/models/zone.js index 9d715a8d8..0c3ac24f6 100644 --- a/modules/agency/back/models/zone.js +++ b/modules/agency/back/models/zone.js @@ -1,5 +1,3 @@ -const app = require('vn-loopback/server/server'); - module.exports = Self => { require('../methods/zone/clone')(Self); require('../methods/zone/getLeaves')(Self); @@ -9,12 +7,4 @@ module.exports = Self => { Self.validatesPresenceOf('agencyModeFk', { message: `Agency cannot be blank` }); - - Self.observe('after save', async function() { - await app.models.ZoneClosure.doRecalc(); - }); - - Self.observe('after delete', async function() { - await app.models.ZoneClosure.doRecalc(); - }); }; diff --git a/modules/claim/back/methods/claim/regularizeClaim.js b/modules/claim/back/methods/claim/regularizeClaim.js index 8a4f6dc95..adf1623c6 100644 --- a/modules/claim/back/methods/claim/regularizeClaim.js +++ b/modules/claim/back/methods/claim/regularizeClaim.js @@ -37,27 +37,43 @@ module.exports = Self => { for (let i = 0; i < claimEnds.length; i++) { const claimEnd = claimEnds[i]; const destination = claimEnd.claimDestination(); - const addressFk = destination && destination.addressFk; + const sale = await getSale(claimEnd.saleFk, options); + const addressId = destination && destination.addressFk; - if (!addressFk) continue; + let address; + if (addressId) + address = await models.Address.findById(addressId, null, options); + + const salesPerson = sale.ticket().client().salesPerson(); + if (salesPerson) { + const nickname = address && address.nickname || destination.description; + const origin = ctx.req.headers.origin; + const message = $t('Sent units from ticket', { + quantity: sale.quantity, + concept: sale.concept, + itemId: sale.itemFk, + ticketId: sale.ticketFk, + nickname: nickname, + ticketUrl: `${origin}/#!/ticket/${sale.ticketFk}/summary`, + itemUrl: `${origin}/#!/item/${sale.itemFk}/summary` + }); + await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message); + } + + if (!address) continue; - let sale = await getSale(claimEnd.saleFk, options); let ticketFk = await getTicketId({ - addressFk: addressFk, + addressFk: addressId, companyFk: sale.ticket().companyFk, warehouseFk: sale.ticket().warehouseFk }, options); - let address = await models.Address.findOne({ - where: {id: addressFk} - }, options); - if (!ticketFk) { ticketFk = await createTicket(ctx, { clientId: address.clientFk, warehouseId: sale.ticket().warehouseFk, companyId: sale.ticket().companyFk, - addressId: addressFk + addressId: addressId }, options); } @@ -69,21 +85,6 @@ module.exports = Self => { price: sale.price, discount: 100 }, options); - - const salesPerson = sale.ticket().client().salesPerson(); - if (salesPerson) { - const origin = ctx.req.headers.origin; - const message = $t('MESSAGE_CLAIM_ITEM_REGULARIZE', { - quantity: sale.quantity, - concept: sale.concept, - itemId: sale.itemFk, - ticketId: sale.ticketFk, - nickname: address.nickname, - ticketUrl: `${origin}/#!/ticket/${sale.ticketFk}/summary`, - itemUrl: `${origin}/#!/item/${sale.itemFk}/summary` - }); - await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message); - } } let claim = await Self.findById(params.claimFk, null, options); diff --git a/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js b/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js index fd3fb3c3d..c7aa1cf0a 100644 --- a/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js +++ b/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js @@ -5,6 +5,7 @@ describe('regularizeClaim()', () => { const pendentState = 1; const resolvedState = 3; const trashDestination = 2; + const okDestination = 1; const trashAddress = 12; let claimEnds = []; let trashTicket; @@ -21,15 +22,20 @@ describe('regularizeClaim()', () => { done(); }); - it('should change claim state to resolved', async() => { - const ctx = {req: { - accessToken: {userId: 18}, - headers: {origin: 'http://localhost'}} + it('should send a chat message with value "Trash" and then change claim state to resolved', async() => { + const ctx = { + req: { + accessToken: {userId: 18}, + headers: {origin: 'http://localhost'} + } }; - ctx.req.__ = value => { - return value; + ctx.req.__ = (value, params) => { + return params.nickname; }; + let params = {claimFk: claimFk}; + const chatModel = app.models.Chat; + spyOn(chatModel, 'sendCheckingPresence').and.callThrough(); claimEnds = await app.models.ClaimEnd.importTicketSales(ctx, { claimFk: claimFk, @@ -49,5 +55,32 @@ describe('regularizeClaim()', () => { expect(trashTicket.addressFk).toEqual(trashAddress); expect(claimBefore.claimStateFk).toEqual(pendentState); expect(claimAfter.claimStateFk).toEqual(resolvedState); + expect(chatModel.sendCheckingPresence).toHaveBeenCalledWith(ctx, 18, 'Trash'); + expect(chatModel.sendCheckingPresence).toHaveBeenCalledTimes(4); + }); + + it('should send a chat message with value "Bueno" and then change claim state to resolved', async() => { + const ctx = { + req: { + accessToken: {userId: 18}, + headers: {origin: 'http://localhost'} + } + }; + ctx.req.__ = (value, params) => { + return params.nickname; + }; + + let params = {claimFk: claimFk}; + const chatModel = app.models.Chat; + spyOn(chatModel, 'sendCheckingPresence').and.callThrough(); + + claimEnds.forEach(async claimEnd => { + claimEnd.updateAttributes({claimDestinationFk: okDestination}); + }); + + await app.models.Claim.regularizeClaim(ctx, params); + + expect(chatModel.sendCheckingPresence).toHaveBeenCalledWith(ctx, 18, 'Bueno'); + expect(chatModel.sendCheckingPresence).toHaveBeenCalledTimes(4); }); }); diff --git a/modules/client/back/methods/client/specs/activeWorkersWithRole.spec.js b/modules/client/back/methods/client/specs/activeWorkersWithRole.spec.js index b9b28fe09..0004b2156 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(10); + expect(result.length).toEqual(11); expect(isBuyer).toBeTruthy(); }); }); diff --git a/modules/client/back/methods/client/specs/listWorkers.spec.js b/modules/client/back/methods/client/specs/listWorkers.spec.js index 728268457..97f4b591d 100644 --- a/modules/client/back/methods/client/specs/listWorkers.spec.js +++ b/modules/client/back/methods/client/specs/listWorkers.spec.js @@ -6,7 +6,7 @@ describe('Client listWorkers', () => { .then(result => { let amountOfEmployees = Object.keys(result).length; - expect(amountOfEmployees).toEqual(49); + expect(amountOfEmployees).toEqual(50); done(); }) .catch(done.fail); diff --git a/modules/client/front/balance/index/index.html b/modules/client/front/balance/index/index.html index f42998bbd..8cdb5c971 100644 --- a/modules/client/front/balance/index/index.html +++ b/modules/client/front/balance/index/index.html @@ -85,9 +85,9 @@ {{::balance.bankFk}} - {{::balance.debit | currency: 'EUR':2}} - {{::balance.credit | currency: 'EUR':2}} - {{balance.balance | currency: 'EUR':2}} + {{::balance.debit | currency: 'EUR':2}} + {{::balance.credit | currency: 'EUR':2}} + {{balance.balance | currency: 'EUR':2}} { expect(expectedBalances[2].balance).toEqual(213.24); }); }); + + describe('balances() setter', () => { + it('should set the balances data and not call the getBalances() method', () => { + spyOn(controller, 'getBalances'); + controller.$.riskModel.data = null; + controller.balances = [{ + id: 1, + debit: 1000, + credit: null + }, { + id: 2, + debit: null, + credit: 500 + }, { + id: 3, + debit: null, + credit: 300 + }]; + + expect(controller.balances).toBeDefined(); + expect(controller.getBalances).not.toHaveBeenCalledWith(); + }); + + it('should set the balances data and then call the getBalances() method', () => { + spyOn(controller, 'getBalances'); + controller.balances = [{ + id: 1, + debit: 1000, + credit: null + }, { + id: 2, + debit: null, + credit: 500 + }, { + id: 3, + debit: null, + credit: 300 + }]; + + expect(controller.balances).toBeDefined(); + expect(controller.getBalances).toHaveBeenCalledWith(); + }); + }); }); }); diff --git a/modules/client/front/descriptor/index.html b/modules/client/front/descriptor/index.html index 722802c66..30777bcda 100644 --- a/modules/client/front/descriptor/index.html +++ b/modules/client/front/descriptor/index.html @@ -70,4 +70,35 @@ - \ No newline at end of file + + + +
+
+ From date +
+ + +
+ To date +
+ + +
+
+ + + + +
\ No newline at end of file diff --git a/modules/client/front/descriptor/index.js b/modules/client/front/descriptor/index.js index 332d87deb..3ef1e7616 100644 --- a/modules/client/front/descriptor/index.js +++ b/modules/client/front/descriptor/index.js @@ -2,12 +2,13 @@ import ngModule from '../module'; import Component from 'core/lib/component'; class Controller extends Component { - constructor($element, $) { + constructor($element, $, $httpParamSerializer) { super($element, $); - + this.$httpParamSerializer = $httpParamSerializer; this.moreOptions = [ {name: 'Simple ticket', callback: this.newTicket}, {name: 'Send SMS', callback: this.showSMSDialog}, + {name: 'Send consumer report', callback: this.showConsumerReportDialog} ]; } @@ -63,9 +64,22 @@ class Controller extends Component { }; this.$.sms.open(); } + + showConsumerReportDialog() { + this.$.consumerReportDialog.show(); + } + + sendConsumerReport(response) { + if (response === 'accept') { + const data = {from: this.from, to: this.to, clientId: this.client.id}; + const serializedParams = this.$httpParamSerializer(data); + const url = `api/report/campaign-metrics?${serializedParams}`; + window.open(url); + } + } } -Controller.$inject = ['$element', '$scope']; +Controller.$inject = ['$element', '$scope', '$httpParamSerializer']; ngModule.component('vnClientDescriptor', { template: require('./index.html'), diff --git a/modules/client/front/descriptor/locale/es.yml b/modules/client/front/descriptor/locale/es.yml index 5ae6935d0..293191ec5 100644 --- a/modules/client/front/descriptor/locale/es.yml +++ b/modules/client/front/descriptor/locale/es.yml @@ -1 +1,2 @@ -Simple ticket: Ticket simple \ No newline at end of file +Simple ticket: Ticket simple +Send consumer report: Enviar informe de consumo \ No newline at end of file diff --git a/modules/client/front/sample/create/index.html b/modules/client/front/sample/create/index.html index 6a87d55b6..cd3412868 100644 --- a/modules/client/front/sample/create/index.html +++ b/modules/client/front/sample/create/index.html @@ -15,7 +15,8 @@ + ng-model="$ctrl.clientSample.recipient" + info="Its only used when sample is sent"> @@ -30,7 +31,7 @@ { - this.$.showPreview.show(); - let dialog = document.body.querySelector('div.vn-dialog'); - let body = dialog.querySelector('tpl-body'); - let scroll = dialog.querySelector('div:first-child'); - - body.innerHTML = res.data; - scroll.scrollTop = 0; - }); + this.clientSample.companyId = value; } onSubmit() { @@ -73,28 +42,49 @@ class Controller extends Component { ); } + showPreview() { + this.send(true, res => { + this.$.showPreview.show(); + const dialog = document.body.querySelector('div.vn-dialog'); + const body = dialog.querySelector('tpl-body'); + const scroll = dialog.querySelector('div:first-child'); + + body.innerHTML = res.data; + scroll.scrollTop = 0; + }); + } + sendSample() { - let sampleType = this.$.sampleType.selection; - let params = { + this.send(false, () => { + this.vnApp.showSuccess(this.$translate.instant('Notification sent!')); + this.$state.go('client.card.sample.index'); + }); + } + + send(isPreview, cb) { + const sampleType = this.$.sampleType.selection; + const params = { clientId: this.$params.id, recipient: this.clientSample.recipient }; + if (!params.recipient) + return this.vnApp.showError(this.$translate.instant('Email cannot be blank')); + if (!sampleType) return this.vnApp.showError(this.$translate.instant('Choose a sample')); - if (sampleType.hasCompany && !this.clientSample.companyFk) + if (sampleType.hasCompany && !this.clientSample.companyId) return this.vnApp.showError(this.$translate.instant('Choose a company')); if (sampleType.hasCompany) - params.companyId = this.clientSample.companyFk; + params.companyId = this.clientSample.companyId; + + if (isPreview) params.isPreview = true; const serializedParams = this.$httpParamSerializer(params); const query = `email/${sampleType.code}?${serializedParams}`; - this.$http.get(query).then(res => { - this.vnApp.showSuccess(this.$translate.instant('Notification sent!')); - this.$state.go('client.card.sample.index'); - }); + this.$http.get(query).then(cb); } } Controller.$inject = ['$element', '$scope', 'vnApp', '$httpParamSerializer', 'vnConfig']; diff --git a/modules/client/front/sample/create/index.spec.js b/modules/client/front/sample/create/index.spec.js index efcda5401..da9a557f1 100644 --- a/modules/client/front/sample/create/index.spec.js +++ b/modules/client/front/sample/create/index.spec.js @@ -40,84 +40,16 @@ describe('Client', () => { $httpParamSerializer = _$httpParamSerializer_; $element = angular.element(''); controller = $componentController('vnClientSampleCreate', {$element, $scope}); + const element = document.createElement('div'); + document.body.querySelector = () => { + return { + querySelector: () => { + return element; + } + }; + }; })); - describe('showPreview()', () => { - it(`should perform a query (GET) and open a sample preview`, () => { - spyOn(controller.$.showPreview, 'show'); - const element = document.createElement('div'); - document.body.querySelector = () => { - return { - querySelector: () => { - return element; - } - }; - }; - - controller.$.sampleType.selection = { - hasCompany: false, - code: 'MyReport' - }; - - controller.clientSample = { - clientFk: 101 - }; - - let event = {preventDefault: () => {}}; - - const params = { - clientId: 101, - isPreview: true - }; - const serializedParams = $httpParamSerializer(params); - - $httpBackend.when('GET', `email/MyReport?${serializedParams}`).respond(true); - $httpBackend.expect('GET', `email/MyReport?${serializedParams}`); - controller.showPreview(event); - $httpBackend.flush(); - - expect(controller.$.showPreview.show).toHaveBeenCalledWith(); - }); - - it(`should perform a query (GET) with companyFk param and open a sample preview`, () => { - spyOn(controller.$.showPreview, 'show'); - const element = document.createElement('div'); - document.body.querySelector = () => { - return { - querySelector: () => { - return element; - } - }; - }; - - controller.$.sampleType.selection = { - hasCompany: true, - code: 'MyReport' - }; - - controller.clientSample = { - clientFk: 101, - companyFk: 442 - }; - - let event = {preventDefault: () => {}}; - - const params = { - clientId: 101, - companyId: 442, - isPreview: true - }; - const serializedParams = $httpParamSerializer(params); - - $httpBackend.when('GET', `email/MyReport?${serializedParams}`).respond(true); - $httpBackend.expect('GET', `email/MyReport?${serializedParams}`); - controller.showPreview(event); - $httpBackend.flush(); - - expect(controller.$.showPreview.show).toHaveBeenCalledWith(); - }); - }); - describe('onSubmit()', () => { it(`should call sendSample() method`, () => { spyOn(controller, 'sendSample'); @@ -127,55 +59,113 @@ describe('Client', () => { }); }); - describe('sendSample()', () => { - it(`should perform a query (GET) and call go() method`, () => { - spyOn(controller.$state, 'go'); + describe('send()', () => { + it(`should not perform an HTTP query if no recipient is specified`, () => { + spyOn(controller.$http, 'get'); controller.$.sampleType.selection = { hasCompany: false, code: 'MyReport' }; - controller.clientSample = { - clientFk: 101 - }; - - const params = { clientId: 101 }; - const serializedParams = $httpParamSerializer(params); - $httpBackend.when('GET', `email/MyReport?${serializedParams}`).respond(true); - $httpBackend.expect('GET', `email/MyReport?${serializedParams}`); - controller.sendSample(); - $httpBackend.flush(); + controller.send(false, () => {}); - expect(controller.$state.go).toHaveBeenCalledWith('client.card.sample.index'); + expect(controller.$http.get).not.toHaveBeenCalled(); }); - it(`should perform a query (GET) with companyFk param and call go() method`, () => { - spyOn(controller.$state, 'go'); + it(`should not perform an HTTP query if no sample is specified`, () => { + spyOn(controller.$http, 'get'); + + controller.$.sampleType.selection = null; + controller.clientSample = { + clientId: 101, + recipient: 'client@email.com' + }; + + controller.send(false, () => {}); + + expect(controller.$http.get).not.toHaveBeenCalled(); + }); + + it(`should not perform an HTTP query if company is required and not specified`, () => { + spyOn(controller.$http, 'get'); controller.$.sampleType.selection = { hasCompany: true, code: 'MyReport' }; - controller.clientSample = { - clientFk: 101, - companyFk: 442 + clientId: 101, + recipient: 'client@email.com' }; - const params = { + controller.send(false, () => {}); + + expect(controller.$http.get).not.toHaveBeenCalled(); + }); + + it(`should perform an HTTP query without passing companyId param`, () => { + controller.$.sampleType.selection = { + hasCompany: false, + code: 'MyReport' + }; + controller.clientSample = { clientId: 101, + recipient: 'client@email.com' + }; + + const serializedParams = $httpParamSerializer(controller.clientSample); + $httpBackend.expect('GET', `email/MyReport?${serializedParams}`).respond(true); + controller.send(false, () => {}); + $httpBackend.flush(); + }); + + it(`should perform an HTTP query passing companyId param`, () => { + controller.$.sampleType.selection = { + hasCompany: true, + code: 'MyReport' + }; + controller.clientSample = { + clientId: 101, + recipient: 'client@email.com', companyId: 442 }; - const serializedParams = $httpParamSerializer(params); - $httpBackend.when('GET', `email/MyReport?${serializedParams}`).respond(true); - $httpBackend.expect('GET', `email/MyReport?${serializedParams}`); - controller.sendSample(); + const serializedParams = $httpParamSerializer(controller.clientSample); + $httpBackend.expect('GET', `email/MyReport?${serializedParams}`).respond(true); + controller.send(false, () => {}); $httpBackend.flush(); + }); + }); + + describe('showPreview()', () => { + it(`should open a sample preview`, () => { + spyOn(controller.$.showPreview, 'show'); + + controller.send = (isPreview, cb) => { + cb({ + data: '
' + }); + }; + controller.showPreview(); + + expect(controller.$.showPreview.show).toHaveBeenCalledWith(); + }); + }); + + describe('sendSample()', () => { + it(`should perform a query (GET) and call go() method`, () => { + spyOn(controller.$state, 'go'); + + controller.send = (isPreview, cb) => { + cb({ + data: true + }); + }; + controller.sendSample(); expect(controller.$state.go).toHaveBeenCalledWith('client.card.sample.index'); }); diff --git a/modules/client/front/sample/create/locale/es.yml b/modules/client/front/sample/create/locale/es.yml index d1ef82c0e..6828e3e48 100644 --- a/modules/client/front/sample/create/locale/es.yml +++ b/modules/client/front/sample/create/locale/es.yml @@ -1,3 +1,5 @@ Choose a sample: Selecciona una plantilla Choose a company: Selecciona una empresa -Recipient: Destinatario \ No newline at end of file +Email cannot be blank: Debes introducir un email +Recipient: Destinatario +Its only used when sample is sent: Se utiliza únicamente cuando se envía la plantilla \ No newline at end of file diff --git a/modules/client/front/sms/index.html b/modules/client/front/sms/index.html index ac7a20651..fb2f1dfff 100644 --- a/modules/client/front/sms/index.html +++ b/modules/client/front/sms/index.html @@ -8,22 +8,32 @@ + ng-model="$ctrl.sms.destination" + required="true" + rule>
- + - {{'Characters remaining' | translate}}: {{$ctrl.charactersRemaining()}} + {{'Characters remaining' | translate}}: + + {{$ctrl.charactersRemaining()}} + diff --git a/modules/client/front/sms/index.js b/modules/client/front/sms/index.js index 1bf2fb99c..c7d89e717 100644 --- a/modules/client/front/sms/index.js +++ b/modules/client/front/sms/index.js @@ -17,23 +17,35 @@ class Controller extends Component { } charactersRemaining() { - let elementMaxLength; - let textAreaLength; const element = this.$scope.message; + const value = element.input.value; - textAreaLength = element.input.textLength; - elementMaxLength = element.maxlength; - return elementMaxLength - textAreaLength; + const maxLength = 160; + const textAreaLength = new Blob([value]).size; + return maxLength - textAreaLength; } onResponse(response) { if (response === 'accept') { - this.$http.post(`Clients/${this.$params.id}/sendSms`, this.sms).then(res => { - this.vnApp.showMessage(this.$translate.instant('SMS sent!')); + 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`); - if (res.data) this.emit('send', {response: res.data}); - }); + this.$http.post(`Clients/${this.$params.id}/sendSms`, this.sms).then(res => { + this.vnApp.showMessage(this.$translate.instant('SMS sent!')); + + if (res.data) this.emit('send', {response: res.data}); + }); + } catch (e) { + this.vnApp.showError(this.$translate.instant(e.message)); + return false; + } } + return true; } } diff --git a/modules/client/front/sms/index.spec.js b/modules/client/front/sms/index.spec.js index c2a7eb935..03d9cbf1d 100644 --- a/modules/client/front/sms/index.spec.js +++ b/modules/client/front/sms/index.spec.js @@ -15,6 +15,11 @@ describe('Client', () => { controller = $componentController('vnClientSms', {$element, $scope}); controller.client = {id: 101}; controller.$params = {id: 101}; + controller.$scope.message = { + input: { + value: 'My SMS' + } + }; })); describe('onResponse()', () => { @@ -30,20 +35,39 @@ describe('Client', () => { expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent!'); }); + + it('should call onResponse without the destination and show an error snackbar', () => { + controller.sms = {destinationFk: 101, message: 'My SMS'}; + + spyOn(controller.vnApp, 'showError'); + + controller.onResponse('accept'); + + expect(controller.vnApp.showError).toHaveBeenCalledWith(`The destination can't be empty`); + }); + + it('should call onResponse without the message and show an error snackbar', () => { + controller.sms = {destinationFk: 101, destination: 222222222}; + + spyOn(controller.vnApp, 'showError'); + + controller.onResponse('accept'); + + expect(controller.vnApp.showError).toHaveBeenCalledWith(`The message can't be empty`); + }); }); describe('charactersRemaining()', () => { it('should return the characters remaining in a element', () => { controller.$scope.message = { input: { - textLength: 50 - }, - maxlength: 150 + value: 'My message 0€' + } }; let result = controller.charactersRemaining(); - expect(result).toEqual(100); + expect(result).toEqual(145); }); }); }); diff --git a/modules/client/front/sms/locale/es.yml b/modules/client/front/sms/locale/es.yml index f26c8ba24..64c3fcca6 100644 --- a/modules/client/front/sms/locale/es.yml +++ b/modules/client/front/sms/locale/es.yml @@ -2,4 +2,8 @@ Send SMS: Enviar SMS Destination: Destinatario Message: Mensaje SMS sent!: ¡SMS enviado! -Characters remaining: Carácteres restantes \ No newline at end of file +Characters remaining: Carácteres restantes +The destination can't be empty: El destinatario no puede estar vacio +The message can't be empty: El mensaje no puede estar vacio +The message it's too long: El mensaje es demasiado largo +Special characters like accents counts as a multiple: Carácteres especiales como los acentos cuentan como varios \ No newline at end of file diff --git a/modules/entry/back/methods/entry/filter.js b/modules/entry/back/methods/entry/filter.js index 8cbe5e15e..93e9558a9 100644 --- a/modules/entry/back/methods/entry/filter.js +++ b/modules/entry/back/methods/entry/filter.js @@ -127,6 +127,7 @@ module.exports = Self => { e.companyFk, e.gestDocFk, e.invoiceInFk, + t.landed, s.name AS supplierName, co.code AS companyCode, cu.code AS currencyCode diff --git a/modules/entry/back/methods/entry/specs/filter.spec.js b/modules/entry/back/methods/entry/specs/filter.spec.js index 9b935d831..25d2da0b4 100644 --- a/modules/entry/back/methods/entry/specs/filter.spec.js +++ b/modules/entry/back/methods/entry/specs/filter.spec.js @@ -23,7 +23,7 @@ describe('Entry filter()', () => { let result = await app.models.Entry.filter(ctx); - expect(result.length).toEqual(7); + expect(result.length).toEqual(8); }); it('should return the entry matching the supplier', async() => { @@ -35,7 +35,7 @@ describe('Entry filter()', () => { let result = await app.models.Entry.filter(ctx); - expect(result.length).toEqual(5); + expect(result.length).toEqual(6); }); it('should return the entry matching the company', async() => { @@ -47,7 +47,7 @@ describe('Entry filter()', () => { let result = await app.models.Entry.filter(ctx); - expect(result.length).toEqual(6); + expect(result.length).toEqual(7); }); it('should return the entries matching isBooked', async() => { diff --git a/modules/entry/front/index/index.html b/modules/entry/front/index/index.html index 8ddd4d3a3..f0f540489 100644 --- a/modules/entry/front/index/index.html +++ b/modules/entry/front/index/index.html @@ -16,45 +16,68 @@ + Id - Created - Travel - Notes + Landed Reference - Booked - Is inventory - Confirmed - Ordered - Is raid - Commission Supplier Currency Company + Booked + Confirmed + Ordered + Notes + + + + + + {{::entry.id}} - {{::entry.created | date:'dd/MM/yyyy'}} - {{::entry.travelFk}} - {{::entry.notes}} + + + {{::entry.landed | date:'dd/MM/yyyy'}} + + {{::entry.ref}} - - - - - - {{::entry.commission}} {{::entry.supplierName}} {{::entry.currencyCode}} {{::entry.companyCode}} + + + + + + + + + diff --git a/modules/entry/front/index/index.js b/modules/entry/front/index/index.js index ec78c06df..53d2f45e0 100644 --- a/modules/entry/front/index/index.js +++ b/modules/entry/front/index/index.js @@ -1,5 +1,5 @@ import ngModule from '../module'; - +import './style.scss'; export default class Controller { constructor($scope) { this.$ = $scope; @@ -11,6 +11,16 @@ export default class Controller { else this.$.model.clear(); } + + showTravelDescriptor(event, travelFk) { + if (event.defaultPrevented) return; + event.preventDefault(); + event.stopPropagation(); + + this.selectedTravel = travelFk; + this.$.travelDescriptor.parent = event.target; + this.$.travelDescriptor.show(); + } } Controller.$inject = ['$scope']; diff --git a/modules/entry/front/index/locale/es.yml b/modules/entry/front/index/locale/es.yml new file mode 100644 index 000000000..8ef9b2c7a --- /dev/null +++ b/modules/entry/front/index/locale/es.yml @@ -0,0 +1,15 @@ +Inventory entry: Es inventario +Virtual entry: Es una redada +Supplier: Proveedor +Currency: Moneda +Company: Empresa +Confirmed: Confirmada +Ordered: Pedida +Is raid: Redada +Commission: Comisión +Landed: F. entrega +Reference: Referencia +Created: Creado +Booked: Facturado +Is inventory: Inventario +Notes: Notas \ No newline at end of file diff --git a/modules/entry/front/index/style.scss b/modules/entry/front/index/style.scss new file mode 100644 index 000000000..ab759d2cc --- /dev/null +++ b/modules/entry/front/index/style.scss @@ -0,0 +1,5 @@ +@import "variables"; + + vn-icon[icon=insert_drive_file]{ + color: $color-font-secondary; + } diff --git a/modules/entry/front/locale/es.yml b/modules/entry/front/locale/es.yml index 214be93d4..3de6c59a8 100644 --- a/modules/entry/front/locale/es.yml +++ b/modules/entry/front/locale/es.yml @@ -1,15 +1,3 @@ #Ordenar alfabeticamente -Reference: Referencia -Created: Creado -Booked: Facturado -Is inventory: Inventario -Notes: Notas -Travel: Envío -Supplier: Proveedor -Currency: Moneda -Company: Empresa -Confirmed: Confirmada -Ordered: Pedida -Is raid: Redada -Commission: Comisión + # Sections diff --git a/modules/entry/front/routes.json b/modules/entry/front/routes.json index f23ff02bf..bd1ace3f2 100644 --- a/modules/entry/front/routes.json +++ b/modules/entry/front/routes.json @@ -2,6 +2,7 @@ "module": "entry", "name": "Entries", "icon": "icon-entry", + "dependencies": ["travel"], "validations": true, "menus": { "main": [ diff --git a/modules/invoiceOut/front/summary/index.html b/modules/invoiceOut/front/summary/index.html index 990957079..19ceeb3ab 100644 --- a/modules/invoiceOut/front/summary/index.html +++ b/modules/invoiceOut/front/summary/index.html @@ -19,7 +19,7 @@ -

Desglose impositivo

+

Tax breakdown

diff --git a/modules/invoiceOut/front/summary/locale/es.yml b/modules/invoiceOut/front/summary/locale/es.yml index d1b4a2406..f79a23093 100644 --- a/modules/invoiceOut/front/summary/locale/es.yml +++ b/modules/invoiceOut/front/summary/locale/es.yml @@ -8,4 +8,5 @@ Shipped: F. envío Type: Tipo Rate: Tasa Fee: Cuota -Taxable base: Base imp. \ No newline at end of file +Taxable base: Base imp. +Tax breakdown: Desglose impositivo \ No newline at end of file diff --git a/modules/item/back/methods/item/createIntrastat.js b/modules/item/back/methods/item/createIntrastat.js new file mode 100644 index 000000000..1a88d16e2 --- /dev/null +++ b/modules/item/back/methods/item/createIntrastat.js @@ -0,0 +1,61 @@ +let UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethod('createIntrastat', { + description: 'Creates a new item intrastat', + accessType: 'WRITE', + accepts: [{ + arg: 'id', + type: 'number', + required: true, + description: 'The item id', + http: {source: 'path'} + }, + { + arg: 'intrastatId', + type: 'number', + required: true + }, + { + arg: 'description', + type: 'string', + required: true + }], + returns: { + type: 'boolean', + root: true + }, + http: { + path: `/:id/createIntrastat`, + verb: 'PATCH' + } + }); + + Self.createIntrastat = async(id, intrastatId, description) => { + const models = Self.app.models; + const country = await models.Country.findOne({ + where: {code: 'ES'} + }); + + const itemTaxCountry = await models.ItemTaxCountry.findOne({ + where: { + itemFk: id, + countryFk: country.id + }, + order: 'effectived DESC' + }); + const taxClassCode = await models.TaxClassCode.findOne({ + where: { + taxClassFk: itemTaxCountry.taxClassFk + }, + order: 'effectived DESC' + }); + + return models.Intrastat.create({ + id: intrastatId, + description: description, + taxClassFk: itemTaxCountry.taxClassFk, + taxCodeFk: taxClassCode.taxCodeFk + }); + }; +}; diff --git a/modules/item/back/methods/item/getLastEntries.js b/modules/item/back/methods/item/getLastEntries.js index bab808cef..a438afcb6 100644 --- a/modules/item/back/methods/item/getLastEntries.js +++ b/modules/item/back/methods/item/getLastEntries.js @@ -22,6 +22,7 @@ module.exports = Self => { let where = filter.where; let query = `CALL vn.itemLastEntries(?, ?)`; let [lastEntries] = await Self.rawSql(query, [where.itemFk, where.date]); + return lastEntries; }; }; diff --git a/modules/item/back/methods/item/specs/createIntrastat.spec.js b/modules/item/back/methods/item/specs/createIntrastat.spec.js new file mode 100644 index 000000000..fb10de858 --- /dev/null +++ b/modules/item/back/methods/item/specs/createIntrastat.spec.js @@ -0,0 +1,22 @@ +const app = require('vn-loopback/server/server'); + +describe('createIntrastat()', () => { + let newIntrastat; + + afterAll(async done => { + await app.models.Intrastat.destroyById(newIntrastat.id); + + done(); + }); + + it('should create a new intrastat', async() => { + const intrastatId = 588420239; + const description = 'Tropical Flowers'; + const itemId = 9; + newIntrastat = await app.models.Item.createIntrastat(itemId, intrastatId, description); + + expect(newIntrastat.description).toEqual(description); + expect(newIntrastat.taxClassFk).toEqual(1); + expect(newIntrastat.taxCodeFk).toEqual(21); + }); +}); diff --git a/modules/item/back/model-config.json b/modules/item/back/model-config.json index db8eed9d5..d8ec5914a 100644 --- a/modules/item/back/model-config.json +++ b/modules/item/back/model-config.json @@ -62,6 +62,9 @@ "TaxClass": { "dataSource": "vn" }, + "TaxClassCode": { + "dataSource": "vn" + }, "TaxCode": { "dataSource": "vn" }, diff --git a/modules/item/back/models/item.js b/modules/item/back/models/item.js index 6c221e94d..01061ce99 100644 --- a/modules/item/back/models/item.js +++ b/modules/item/back/models/item.js @@ -12,6 +12,7 @@ module.exports = Self => { require('../methods/item/getVisibleAvailable')(Self); require('../methods/item/new')(Self); require('../methods/item/getWasteDetail')(Self); + require('../methods/item/createIntrastat')(Self); Self.validatesPresenceOf('originFk', {message: 'Cannot be blank'}); diff --git a/modules/item/back/models/item.json b/modules/item/back/models/item.json index d8d1cb64d..dbaa3a409 100644 --- a/modules/item/back/models/item.json +++ b/modules/item/back/models/item.json @@ -1,13 +1,13 @@ { "name": "Item", - "base": "Loggable", - "log": { - "model":"ItemLog", + "base": "Loggable", + "log": { + "model": "ItemLog", "showField": "id" - }, + }, "options": { "mysql": { - "table": "item" + "table": "item" } }, "properties": { @@ -125,55 +125,55 @@ } }, "relations": { - "itemType": { - "type": "belongsTo", - "model": "ItemType", - "foreignKey": "typeFk" - }, - "ink": { - "type": "belongsTo", - "model": "Ink", - "foreignKey": "inkFk" - }, - "origin": { - "type": "belongsTo", - "model": "Origin", - "foreignKey": "originFk" - }, - "producer": { - "type": "belongsTo", - "model": "Producer", - "foreignKey": "producerFk" - }, - "intrastat": { - "type": "belongsTo", - "model": "Intrastat", - "foreignKey": "intrastatFk" - }, - "expense": { - "type": "belongsTo", - "model": "Expense", - "foreignKey": "expenseFk" - }, - "tags": { - "type": "hasMany", - "model": "ItemTag", - "foreignKey": "itemFk" - }, - "itemBarcode": { - "type": "hasMany", - "model": "ItemBarcode", - "foreignKey": "itemFk" - }, - "taxes": { - "type": "hasMany", - "model": "ItemTaxCountry", - "foreignKey": "itemFk" - }, - "itemNiche": { - "type": "hasMany", - "model": "ItemNiche", - "foreignKey": "itemFk" - } + "itemType": { + "type": "belongsTo", + "model": "ItemType", + "foreignKey": "typeFk" + }, + "ink": { + "type": "belongsTo", + "model": "Ink", + "foreignKey": "inkFk" + }, + "origin": { + "type": "belongsTo", + "model": "Origin", + "foreignKey": "originFk" + }, + "producer": { + "type": "belongsTo", + "model": "Producer", + "foreignKey": "producerFk" + }, + "intrastat": { + "type": "belongsTo", + "model": "Intrastat", + "foreignKey": "intrastatFk" + }, + "expense": { + "type": "belongsTo", + "model": "Expense", + "foreignKey": "expenseFk" + }, + "tags": { + "type": "hasMany", + "model": "ItemTag", + "foreignKey": "itemFk" + }, + "itemBarcode": { + "type": "hasMany", + "model": "ItemBarcode", + "foreignKey": "itemFk" + }, + "taxes": { + "type": "hasMany", + "model": "ItemTaxCountry", + "foreignKey": "itemFk" + }, + "itemNiche": { + "type": "hasMany", + "model": "ItemNiche", + "foreignKey": "itemFk" + } } - } \ No newline at end of file +} \ No newline at end of file diff --git a/modules/item/back/models/tax-class-code.json b/modules/item/back/models/tax-class-code.json new file mode 100644 index 000000000..ef8c529d9 --- /dev/null +++ b/modules/item/back/models/tax-class-code.json @@ -0,0 +1,46 @@ +{ + "name": "TaxClassCode", + "base": "VnModel", + "options": { + "mysql": { + "table": "taxClassCode" + } + }, + "properties": { + "taxClassFk": { + "type": "number", + "required": true, + "id": 1 + }, + "taxCodeFk": { + "type": "number", + "required": true, + "id": 2 + }, + "effectived": { + "type": "date", + "required": true, + "id": 3 + } + }, + "relations": { + "taxClass": { + "type": "belongsTo", + "model": "TaxClass", + "foreignKey": "taxClassFk" + }, + "taxCode": { + "type": "belongsTo", + "model": "TaxCode", + "foreignKey": "taxCodeFk" + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/modules/item/front/basic-data/__snapshots__/index.spec.js.snap b/modules/item/front/basic-data/__snapshots__/index.spec.js.snap deleted file mode 100644 index 92219bb33..000000000 --- a/modules/item/front/basic-data/__snapshots__/index.spec.js.snap +++ /dev/null @@ -1,3 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`vnItemBasicData Component vnItemBasicData $onChanges() should pass the data to the watcher 1`] = `"the current value of an item"`; diff --git a/modules/item/front/basic-data/index.html b/modules/item/front/basic-data/index.html index bd0cec86d..3cd879945 100644 --- a/modules/item/front/basic-data/index.html +++ b/modules/item/front/basic-data/index.html @@ -55,6 +55,13 @@
{{::id}}
{{::description}}
+ + + + - +
@@ -134,3 +141,30 @@ + + + + +
New intrastat
+ + + + + + + + +
+ + + + +
\ No newline at end of file diff --git a/modules/item/front/basic-data/index.js b/modules/item/front/basic-data/index.js index 123aa59cd..33a60b32d 100644 --- a/modules/item/front/basic-data/index.js +++ b/modules/item/front/basic-data/index.js @@ -1,20 +1,23 @@ import ngModule from '../module'; +import Component from 'core/lib/component'; +class Controller extends Component { + showIntrastat(event) { + if (event.defaultPrevented) return; + event.preventDefault(); -class Controller { - constructor($scope, $timeout) { - this.$scope = $scope; - this.$timeout = $timeout; + this.newIntrastat = { + taxClassFk: this.item.taxClassFk + }; + this.$.intrastat.show(); } - $onChanges(data) { - this.$timeout(() => { - this.$scope.watcher.data = data.item.currentValue; - }); + onIntrastatAccept() { + const query = `Items/${this.$params.id}/createIntrastat`; + return this.$http.patch(query, this.newIntrastat) + .then(res => this.item.intrastatFk = res.data.id); } } -Controller.$inject = ['$scope', '$timeout']; - ngModule.component('vnItemBasicData', { template: require('./index.html'), bindings: { diff --git a/modules/item/front/basic-data/index.spec.js b/modules/item/front/basic-data/index.spec.js index e7578b54c..178fac278 100644 --- a/modules/item/front/basic-data/index.spec.js +++ b/modules/item/front/basic-data/index.spec.js @@ -2,26 +2,31 @@ import './index.js'; describe('vnItemBasicData', () => { describe('Component vnItemBasicData', () => { + let $httpBackend; let $scope; let controller; - let $timeout; + let $element; beforeEach(ngModule('item')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$timeout_) => { - $timeout = _$timeout_; + beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { + $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); - controller = $componentController('vnItemBasicData', {$scope, $timeout}); - controller.$scope.watcher = {}; + $element = angular.element(''); + controller = $componentController('vnItemBasicData', {$element, $scope}); + controller.$.watcher = {}; + controller.$params.id = 1; + controller.item = {id: 1, name: 'Rainbow Coral'}; })); - describe('$onChanges()', () => { + describe('onIntrastatAccept()', () => { it('should pass the data to the watcher', () => { - const data = {item: {currentValue: 'the current value of an item'}}; - controller.$onChanges(data); - $timeout.flush(); + const newIntrastatId = 20; + $httpBackend.expect('PATCH', 'Items/1/createIntrastat').respond({id: 20}); + controller.onIntrastatAccept(); + $httpBackend.flush(); - expect(controller.$scope.watcher.data).toMatchSnapshot(); + expect(controller.item.intrastatFk).toEqual(newIntrastatId); }); }); }); diff --git a/modules/item/front/basic-data/locale/es.yml b/modules/item/front/basic-data/locale/es.yml index 67780557a..07e681770 100644 --- a/modules/item/front/basic-data/locale/es.yml +++ b/modules/item/front/basic-data/locale/es.yml @@ -5,4 +5,6 @@ Full name calculates based on tags 1-3. Is not recommended to change it manually No se recomienda cambiarlo manualmente Is active: Activo Expense: Gasto -Price in kg: Precio en kg \ No newline at end of file +Price in kg: Precio en kg +New intrastat: Nuevo intrastat +Identifier: Identificador \ No newline at end of file diff --git a/modules/order/back/methods/order/catalogFilter.js b/modules/order/back/methods/order/catalogFilter.js index 3814aa12d..114cd2786 100644 --- a/modules/order/back/methods/order/catalogFilter.js +++ b/modules/order/back/methods/order/catalogFilter.js @@ -162,6 +162,7 @@ module.exports = Self => { `SELECT it.tagFk, it.itemFk, + it.value, t.name FROM tmp.ticketCalculateItem tci JOIN vn.itemTag it ON it.itemFk = tci.itemFk diff --git a/modules/order/front/catalog-search-panel/index.html b/modules/order/front/catalog-search-panel/index.html index 3bd0ba3e2..d32ecaafa 100644 --- a/modules/order/front/catalog-search-panel/index.html +++ b/modules/order/front/catalog-search-panel/index.html @@ -1,13 +1,15 @@
-
+ + value-field="id" + required="true"> {{name}} @@ -15,7 +17,8 @@ + ng-model="filter.value" + required="true"> diff --git a/modules/order/front/catalog/index.html b/modules/order/front/catalog/index.html index 5cc72e3c8..7131d6a6e 100644 --- a/modules/order/front/catalog/index.html +++ b/modules/order/front/catalog/index.html @@ -77,20 +77,21 @@
- + label="Item id"> - + show-field="value" + value-field="value" + label="Search tag"> @@ -101,7 +102,7 @@ style="cursor: pointer;"> - +
+ + Id: {{$ctrl.itemId}} + - {{::tag.value}} +
+ + + {{::tag.tagSelection.name}} + + : + + + "{{::tag.value}}" + +
\ No newline at end of file diff --git a/modules/order/front/catalog/index.js b/modules/order/front/catalog/index.js index a7d2c18b2..e0ed61175 100644 --- a/modules/order/front/catalog/index.js +++ b/modules/order/front/catalog/index.js @@ -10,7 +10,7 @@ class Controller { this.$compile = $compile; this.$transitions = $transitions; this.itemTypes = []; - this.tags = []; + this._tags = []; // Static autocomplete data this.orderWays = [ @@ -19,7 +19,7 @@ class Controller { ]; this.defaultOrderFields = [ {field: 'relevancy DESC, name', name: 'Relevancy'}, - {field: 'showOrder, price', name: 'Color'}, + {field: 'showOrder, price', name: 'Color and price'}, {field: 'name', name: 'Name'}, {field: 'price', name: 'Price'} ]; @@ -52,11 +52,17 @@ class Controller { if (!value) return; this.$.$applyAsync(() => { + if (this.$stateParams.itemId) + this.itemId = parseInt(this.$stateParams.itemId); + if (this.$stateParams.categoryId) - this.categoryId = this.$stateParams.categoryId; + this.categoryId = parseInt(this.$stateParams.categoryId); if (this.$stateParams.typeId) - this.typeId = this.$stateParams.typeId; + this.typeId = parseInt(this.$stateParams.typeId); + + if (this.$stateParams.tags) + this.tags = JSON.parse(this.$stateParams.tags); }); } @@ -69,37 +75,8 @@ class Controller { if (!value) return; - const newFilterList = []; - value.forEach(item => { - // Add new tag filters - item.tags.forEach(itemTag => { - const alreadyAdded = newFilterList.findIndex(filter => { - return filter.field == itemTag.tagFk; - }); - - if (alreadyAdded == -1) { - newFilterList.push({ - name: itemTag.name, - field: itemTag.tagFk, - isTag: true - }); - } - }); - }); - - // Add default filters - Replaces tags with same name - this.defaultOrderFields.forEach(orderField => { - const index = newFilterList.findIndex(newfield => { - return newfield.name == orderField.name; - }); - - if (index > -1) - newFilterList[index] = orderField; - else - newFilterList.push(orderField); - }); - - this.orderFields = newFilterList; + this.buildTagsFilter(value); + this.buildOrderFilter(value); } get categoryId() { @@ -138,6 +115,30 @@ class Controller { this.applyFilters(); } + get itemId() { + return this._itemId; + } + + set itemId(value) { + this._itemId = value; + + this.updateStateParams(); + this.applyFilters(); + } + + get tags() { + return this._tags; + } + + set tags(value) { + this._tags = value; + + this.updateStateParams(); + + if (value.length) + this.applyFilters(); + } + /** * Get order way ASC/DESC */ @@ -198,23 +199,36 @@ class Controller { this.itemTypes = res.data); } + /** + * Search by item id filter + * @param {object} event + */ onSearchById(event) { - const hasValue = this.tags.length > 0 || this.itemId || this.typeId; - if (event.key === 'Enter' && hasValue) - this.applyFilters(); + const value = this.$.itemId.value; + if (event.key === 'Enter' && value) { + this.itemId = value; + this.$.itemId.value = null; + } } + /** + * Search by tag value + * @param {object} event + */ onSearchByTag(event) { - if (event.key !== 'Enter' || !this.value) return; + const value = this.$.search.value; + if (event.key !== 'Enter' || !value) return; this.tags.push({ - value: this.value, + value: value, }); this.$.search.value = null; + this.updateStateParams(); this.applyFilters(); } remove(index) { this.tags.splice(index, 1); + this.updateStateParams(); if (this.tags.length >= 0 || this.itemId || this.typeId) this.applyFilters(); @@ -254,6 +268,7 @@ class Controller { onPanelSubmit(filter) { this.$.popover.hide(); this.tags.push(filter); + this.updateStateParams(); this.applyFilters(); } @@ -263,16 +278,76 @@ class Controller { updateStateParams() { const params = {}; + params.categoryId = undefined; if (this.categoryId) params.categoryId = this.categoryId; - else params.categoryId = undefined; + params.typeId = undefined; if (this.typeId) params.typeId = this.typeId; - else params.typeId = undefined; + + params.itemId = undefined; + if (this.itemId) + params.itemId = this.itemId; + + params.tags = undefined; + if (this.tags.length) { + const tags = []; + for (let tag of this.tags) { + const tagParam = {value: tag.value}; + + if (tag.tagSelection) { + tagParam.tagFk = tag.tagFk; + tagParam.tagSelection = { + name: tag.tagSelection.name + }; + } + + tags.push(tagParam); + } + + params.tags = JSON.stringify(tags); + } this.$state.go(this.$state.current.name, params); } + + buildTagsFilter(items) { + const tagValues = []; + items.forEach(item => { + item.tags.forEach(itemTag => { + const alreadyAdded = tagValues.findIndex(tag => { + return tag.value == itemTag.value; + }); + + if (alreadyAdded == -1) + tagValues.push(itemTag); + }); + }); + this.tagValues = tagValues; + } + + buildOrderFilter(items) { + const tags = []; + items.forEach(item => { + item.tags.forEach(itemTag => { + const alreadyAdded = tags.findIndex(tag => { + return tag.field == itemTag.tagFk; + }); + + if (alreadyAdded == -1) { + tags.push({ + name: itemTag.name, + field: itemTag.tagFk, + isTag: true + }); + } + }); + }); + let newFilterList = [].concat(this.defaultOrderFields); + newFilterList = newFilterList.concat(tags); + this.orderFields = newFilterList; + } } Controller.$inject = ['$http', '$scope', '$state', '$compile', '$transitions']; diff --git a/modules/order/front/catalog/index.spec.js b/modules/order/front/catalog/index.spec.js index dd9e13257..e2d2d0aff 100644 --- a/modules/order/front/catalog/index.spec.js +++ b/modules/order/front/catalog/index.spec.js @@ -15,6 +15,7 @@ describe('Order', () => { $scope = $rootScope.$new(); $scope.model = crudModel; $scope.search = {}; + $scope.itemId = {}; $state = _$state_; $state.params.categoryId = 1; $state.params.typeId = 2; @@ -37,29 +38,35 @@ describe('Order', () => { describe('items() setter', () => { it(`should return an object with order params`, () => { - let expectedResult = [{field: 'showOrder, price', name: 'Color'}]; - let unexpectedResult = [{tagFk: 5, name: 'Color'}]; - controller.items = [{id: 1, name: 'My Item', tags: [ + jest.spyOn(controller, 'buildTagsFilter'); + jest.spyOn(controller, 'buildOrderFilter'); + + const expectedResult = [{field: 'showOrder, price', name: 'Color and price'}]; + const items = [{id: 1, name: 'My Item', tags: [ {tagFk: 4, name: 'Length'}, {tagFk: 5, name: 'Color'} ]}]; + controller.items = items; - expect(controller.orderFields.length).toEqual(5); + expect(controller.orderFields.length).toEqual(6); expect(controller.orderFields).toEqual(jasmine.arrayContaining(expectedResult)); - expect(controller.orderFields).not.toEqual(jasmine.arrayContaining(unexpectedResult)); + expect(controller.buildTagsFilter).toHaveBeenCalledWith(items); + expect(controller.buildOrderFilter).toHaveBeenCalledWith(items); }); }); describe('categoryId() setter', () => { it(`should set category property to null, call updateStateParams() method and not call applyFilters()`, () => { - spyOn(controller, 'updateStateParams'); + jest.spyOn(controller, 'updateStateParams'); + controller.categoryId = null; expect(controller.updateStateParams).toHaveBeenCalledWith(); }); it(`should set category property and then call updateStateParams() and applyFilters() methods`, () => { - spyOn(controller, 'updateStateParams'); + jest.spyOn(controller, 'updateStateParams'); + controller.categoryId = 2; expect(controller.updateStateParams).toHaveBeenCalledWith(); @@ -84,8 +91,9 @@ describe('Order', () => { describe('typeId() setter', () => { it(`should set type property to null, call updateStateParams() method and not call applyFilters()`, () => { - spyOn(controller, 'updateStateParams'); - spyOn(controller, 'applyFilters'); + jest.spyOn(controller, 'updateStateParams'); + jest.spyOn(controller, 'applyFilters'); + controller.typeId = null; expect(controller.updateStateParams).toHaveBeenCalledWith(); @@ -93,8 +101,9 @@ describe('Order', () => { }); it(`should set category property and then call updateStateParams() and applyFilters() methods`, () => { - spyOn(controller, 'updateStateParams'); - spyOn(controller, 'applyFilters'); + jest.spyOn(controller, 'updateStateParams'); + jest.spyOn(controller, 'applyFilters'); + controller.typeId = 2; expect(controller.updateStateParams).toHaveBeenCalledWith(); @@ -102,21 +111,46 @@ describe('Order', () => { }); }); + describe('itemId() setter', () => { + it(`should set itemId property and then call updateStateParams() and applyFilters() methods`, () => { + jest.spyOn(controller, 'updateStateParams'); + jest.spyOn(controller, 'applyFilters'); + + controller.itemId = 1; + + expect(controller.updateStateParams).toHaveBeenCalledWith(); + expect(controller.applyFilters).toHaveBeenCalledWith(); + }); + }); + + describe('tags() setter', () => { + it(`should set tags property and then call updateStateParams() and applyFilters() methods`, () => { + jest.spyOn(controller, 'updateStateParams'); + jest.spyOn(controller, 'applyFilters'); + + controller.tags = [{tagFk: 11, value: 'Brown'}]; + + expect(controller.updateStateParams).toHaveBeenCalledWith(); + expect(controller.applyFilters).toHaveBeenCalledWith(); + }); + }); + describe('onSearchByTag()', () => { it(`should not add a new tag if the event key code doesn't equals to 'Enter'`, () => { - spyOn(controller, 'applyFilters'); + jest.spyOn(controller, 'applyFilters'); + controller.order = {id: 4}; - controller.value = 'Color'; + controller.$.search.value = 'Brown'; controller.onSearchByTag({key: 'Tab'}); expect(controller.applyFilters).not.toHaveBeenCalledWith(); }); it(`should add a new tag if the event key code equals to 'Enter' an then call applyFilters()`, () => { - spyOn(controller, 'applyFilters'); - controller.order = {id: 4}; - controller.value = 'Color'; + jest.spyOn(controller, 'applyFilters'); + controller.order = {id: 4}; + controller.$.search.value = 'Brown'; controller.onSearchByTag({key: 'Enter'}); expect(controller.applyFilters).toHaveBeenCalledWith(); @@ -125,17 +159,18 @@ describe('Order', () => { describe('onSearchById()', () => { it(`should not filter by id if the event key code doesn't equals to 'Enter'`, () => { - spyOn(controller, 'applyFilters'); - controller.itemId = 1; + jest.spyOn(controller, 'applyFilters'); + + controller.$.itemId.value = 1; controller.onSearchById({key: 'Tab'}); expect(controller.applyFilters).not.toHaveBeenCalledWith(); }); it(`should filter by id if the event key code equals to 'Enter' an then call applyFilters()`, () => { - spyOn(controller, 'applyFilters'); - controller.itemId = 1; + jest.spyOn(controller, 'applyFilters'); + controller.$.itemId.value = 1; controller.onSearchById({key: 'Enter'}); expect(controller.applyFilters).toHaveBeenCalledWith(); @@ -144,14 +179,14 @@ describe('Order', () => { describe('applyFilters()', () => { it(`should call model applyFilter() method with a new filter`, () => { - let model = controller.$.model; - spyOn(model, 'applyFilter'); + jest.spyOn(controller.$.model, 'applyFilter'); + controller._categoryId = 2; controller._typeId = 4; controller.applyFilters(); - expect(model.applyFilter).toHaveBeenCalledWith( + expect(controller.$.model.applyFilter).toHaveBeenCalledWith( {where: {categoryFk: 2, typeFk: 4}}, {orderFk: 4, orderBy: controller.getOrderBy(), tags: []}); }); @@ -159,7 +194,8 @@ describe('Order', () => { describe('remove()', () => { it(`should remove a tag from tags property`, () => { - spyOn(controller, 'applyFilters'); + jest.spyOn(controller, 'applyFilters'); + controller.tags = [{tagFk: 1, value: 'Blue'}, {tagFk: 2, value: '70'}]; controller.remove(0); @@ -169,7 +205,8 @@ describe('Order', () => { }); it(`should remove a tag from tags property and call applyFilters() if there's no more tags`, () => { - spyOn(controller, 'applyFilters'); + jest.spyOn(controller, 'applyFilters'); + controller._categoryId = 1; controller._typeId = 1; controller.tags = [{tagFk: 1, value: 'Blue'}]; @@ -182,10 +219,19 @@ describe('Order', () => { describe('updateStateParams()', () => { it(`should call state go() method passing category and type state params`, () => { - spyOn(controller.$state, 'go'); + jest.spyOn(controller.$state, 'go'); + controller._categoryId = 2; controller._typeId = 4; - let result = {categoryId: 2, typeId: 4}; + controller._itemId = 1; + controller._tags = [ + {tagFk: 11, value: 'Precission', tagSelection: {name: 'Category'}} + ]; + const tags = JSON.stringify([{ + value: 'Precission', + tagFk: 11, tagSelection: {name: 'Category'}} + ]); + let result = {categoryId: 2, typeId: 4, itemId: 1, tags: tags}; controller.updateStateParams(); expect(controller.$state.go).toHaveBeenCalledWith('my.current.state', result); @@ -209,19 +255,63 @@ describe('Order', () => { describe('applyOrder()', () => { it(`should apply order param to model calling getOrderBy()`, () => { + jest.spyOn(controller, 'getOrderBy'); + jest.spyOn(controller.$.model, 'addFilter'); + controller.field = 'relevancy DESC, name'; controller.way = 'ASC'; controller._categoryId = 1; controller._typeId = 1; let expectedOrder = {orderBy: controller.getOrderBy()}; - spyOn(controller, 'getOrderBy').and.callThrough(); - spyOn(controller.$.model, 'addFilter'); + controller.applyOrder(); expect(controller.getOrderBy).toHaveBeenCalledWith(); expect(controller.$.model.addFilter).toHaveBeenCalledWith(null, expectedOrder); }); }); + + describe('buildTagsFilter()', () => { + it(`should create an array of non repeated tag values and then set the tagValues property`, () => { + const items = [ + { + id: 1, name: 'My Item 1', tags: [ + {tagFk: 4, name: 'Length', value: 1}, + {tagFk: 5, name: 'Color', value: 'red'} + ] + }, + { + id: 2, name: 'My Item 2', tags: [ + {tagFk: 4, name: 'Length', value: 1}, + {tagFk: 5, name: 'Color', value: 'blue'} + ] + }]; + controller.buildTagsFilter(items); + + expect(controller.tagValues.length).toEqual(3); + }); + }); + + describe('buildOrderFilter()', () => { + it(`should create an array of non repeated tags plus default filters and then set the orderFields property`, () => { + const items = [ + { + id: 1, name: 'My Item 1', tags: [ + {tagFk: 4, name: 'Length'}, + {tagFk: 5, name: 'Color'} + ] + }, + { + id: 2, name: 'My Item 2', tags: [ + {tagFk: 5, name: 'Color'}, + {tagFk: 6, name: 'Relevancy'} + ] + }]; + controller.buildOrderFilter(items); + + expect(controller.orderFields.length).toEqual(7); + }); + }); }); }); diff --git a/modules/order/front/locale/es.yml b/modules/order/front/locale/es.yml index 0ada37bfd..565d4f251 100644 --- a/modules/order/front/locale/es.yml +++ b/modules/order/front/locale/es.yml @@ -16,6 +16,7 @@ Item id: Id de artículo Order by: Ordenar por Order: Orden Price: Precio +Color and price: Color y precio Ascendant: Ascendente Descendant: Descendente Created from: Creado desde diff --git a/modules/order/front/prices-popover/index.js b/modules/order/front/prices-popover/index.js index 2df8bea15..b732f2090 100644 --- a/modules/order/front/prices-popover/index.js +++ b/modules/order/front/prices-popover/index.js @@ -73,30 +73,6 @@ class Controller extends Component { addQuantity(price) { if (this.total + price.grouping <= this.max) price.quantity += price.grouping; - - this.validate(); - } - - validate() { - /* - this.$timeout(() => { - this.calculateTotal(); - let inputs = this.$element[0].querySelectorAll('vn-input-number[name="quantity"] div.infix:not(.validated)'); - - inputs.forEach(input => { - if (this.total > this.item.available) - input.classList.add('invalid'); - else - input.classList.remove('invalid'); - }); - let wrongInputs = this.$element[0].querySelectorAll('vn-input-number[name="quantity"] div.infix.invalid'); - - if (wrongInputs.length > 0) - this.$element[0].querySelector('vn-vertical.prices').classList.add('invalid'); - else - this.$element[0].querySelector('vn-vertical.prices').classList.remove('invalid'); - }); - */ } getFilledLines() { diff --git a/modules/order/front/routes.json b/modules/order/front/routes.json index 789870fd1..b607aef9d 100644 --- a/modules/order/front/routes.json +++ b/modules/order/front/routes.json @@ -41,7 +41,7 @@ "order": "$ctrl.order" } }, { - "url": "/catalog?categoryId&typeId", + "url": "/catalog?categoryId&typeId&itemId&tags", "state": "order.card.catalog", "component": "vn-order-catalog", "description": "Catalog", diff --git a/modules/route/back/models/route.js b/modules/route/back/models/route.js index 4dd9f3dc0..6d93cfe40 100644 --- a/modules/route/back/models/route.js +++ b/modules/route/back/models/route.js @@ -5,4 +5,21 @@ module.exports = Self => { require('../methods/route/guessPriority')(Self); require('../methods/route/updateVolume')(Self); require('../methods/route/getDeliveryPoint')(Self); + + Self.validate('kmStart', validateDistance, { + message: 'Distance must be lesser than 1000' + }); + + Self.validate('kmEnd', validateDistance, { + message: 'Distance must be lesser than 1000' + }); + + function validateDistance(err) { + const routeTotalKm = this.kmEnd - this.kmStart; + const routeMaxKm = 1000; + if ( routeTotalKm > routeMaxKm || this.kmStart > this.kmEnd) + err(); + } }; + + diff --git a/modules/route/front/basic-data/index.js b/modules/route/front/basic-data/index.js index 810fd7511..d4a481dc5 100644 --- a/modules/route/front/basic-data/index.js +++ b/modules/route/front/basic-data/index.js @@ -1,8 +1,10 @@ import ngModule from '../module'; class Controller { - constructor($scope) { + constructor($scope, vnApp, $translate) { this.$ = $scope; + this.vnApp = vnApp; + this.$translate = $translate; } onSubmit() { @@ -11,7 +13,7 @@ class Controller { }); } } -Controller.$inject = ['$scope']; +Controller.$inject = ['$scope', 'vnApp', '$translate']; ngModule.component('vnRouteBasicData', { template: require('./index.html'), diff --git a/modules/route/front/basic-data/locale/es.yml b/modules/route/front/basic-data/locale/es.yml index 442a4fa82..f0414b5b1 100644 --- a/modules/route/front/basic-data/locale/es.yml +++ b/modules/route/front/basic-data/locale/es.yml @@ -2,4 +2,4 @@ Date finished: Fecha fin Date started: Fecha inicio Km start: Km de inicio Km end: Km de fin -Description: Descripción \ No newline at end of file +Description: Descripción diff --git a/modules/route/front/summary/index.html b/modules/route/front/summary/index.html index 0ec6c47fe..527f7fe96 100644 --- a/modules/route/front/summary/index.html +++ b/modules/route/front/summary/index.html @@ -84,8 +84,8 @@ {{ticket.packages}} {{ticket.volume}} {{ticket.warehouse.name}} - {{ticket.client.postcode}} - {{ticket.client.street}} + {{ticket.address.postalCode}} + {{ticket.address.street}} { let result = await app.models.Ticket.priceDifference(httpCtx, ticketId, landed, addressId, agencyModeId, zoneId, warehouseId); - expect(result.totalUnitPrice).toEqual(215.77); - expect(result.totalNewPrice).toEqual(215.77); + expect(result.totalUnitPrice).toEqual(215.78); + expect(result.totalNewPrice).toEqual(215.78); expect(result.totalDifference).toEqual(0); }); diff --git a/modules/ticket/back/methods/ticket/transferSales.js b/modules/ticket/back/methods/ticket/transferSales.js index 9d39453be..c2257bf09 100644 --- a/modules/ticket/back/methods/ticket/transferSales.js +++ b/modules/ticket/back/methods/ticket/transferSales.js @@ -62,11 +62,14 @@ module.exports = Self => { for (const sale of originalSales) map.set(sale.id, sale); - for (const sale of sales) { const originalSale = map.get(sale.id); - - let originalSaleQuantity = originalSale.quantity; + const originalSaleData = { // <-- Loopback modifies original instance on save + itemFk: originalSale.itemFk, + quantity: originalSale.quantity, + concept: originalSale.concept, + ticketFk: originalSale.ticketFk + }; if (sale.quantity == originalSale.quantity) { await models.Sale.updateAll({ @@ -77,39 +80,47 @@ module.exports = Self => { ticketId, originalSale, sale, options); } - let logTicketOrigin = { + // Log to original ticket + await models.TicketLog.create({ originFk: id, userFk: userId, action: 'update', changedModel: 'Ticket', - changedModelId: ticketId, - oldInstance: {item: sale.itemFk, - quantity: 0, - concept: sale.concept, - ticket: ticketId}, - newInstance: {item: sale.itemFk, + changedModelId: id, + oldInstance: { + item: originalSaleData.itemFk, + quantity: originalSaleData.quantity, + concept: originalSaleData.concept, + ticket: originalSaleData.ticketFk + }, + newInstance: { + item: sale.itemFk, quantity: sale.quantity, concept: sale.concept, - ticket: ticketId} - }; - await models.TicketLog.create(logTicketOrigin, options); + ticket: ticketId + } + }, options); - let logTicketDestination = { + // Log to destination ticket + await models.TicketLog.create({ originFk: ticketId, userFk: userId, action: 'update', changedModel: 'Ticket', changedModelId: ticketId, - oldInstance: {item: sale.itemFk, - quantity: originalSaleQuantity, + oldInstance: { + item: originalSaleData.itemFk, + quantity: originalSaleData.quantity, + concept: originalSaleData.concept, + ticket: originalSaleData.ticketFk + }, + newInstance: { + item: sale.itemFk, + quantity: sale.quantity, concept: sale.concept, - ticket: id}, - newInstance: {item: sale.itemFk, - quantity: originalSaleQuantity - sale.quantity, - concept: sale.concept, - ticket: id} - }; - await models.TicketLog.create(logTicketDestination, options); + ticket: ticketId + } + }, options); } const isTicketEmpty = await models.Ticket.isEmpty(id, options); @@ -146,9 +157,9 @@ module.exports = Self => { // Update original sale const rest = originalSale.quantity - sale.quantity; - const updatedSale = await models.Sale.updateAll({ - id: sale.id - }, {quantity: rest}, options); + const originalInstance = await models.Sale.findById(sale.id, options); + await originalInstance.updateAttribute('quantity', rest, options); + // Clone sale with new quantity const newSale = originalSale; newSale.id = undefined; @@ -169,6 +180,6 @@ module.exports = Self => { await models.SaleComponent.create(newComponents, options); - return updatedSale; + return originalInstance; } }; diff --git a/modules/ticket/front/create/card.js b/modules/ticket/front/create/card.js index 2e775c18b..54cc56c68 100644 --- a/modules/ticket/front/create/card.js +++ b/modules/ticket/front/create/card.js @@ -14,7 +14,7 @@ class Controller { $onInit() { if (this.$stateParams && this.$stateParams.clientFk) - this.clientId = this.$stateParams.clientFk; + this.clientId = parseInt(this.$stateParams.clientFk); this.warehouseId = this.vnConfig.warehouseFk; } diff --git a/modules/ticket/front/descriptor/index.js b/modules/ticket/front/descriptor/index.js index ef64bf84e..10da4cca9 100644 --- a/modules/ticket/front/descriptor/index.js +++ b/modules/ticket/front/descriptor/index.js @@ -7,7 +7,11 @@ class Controller extends Component { this.aclService = aclService; this.$httpParamSerializer = $httpParamSerializer; this.moreOptions = [ - {name: 'Add turn', callback: this.showAddTurnDialog}, + { + name: 'Add turn', + acl: 'buyer', + callback: this.showAddTurnDialog + }, {name: 'Show Delivery Note', callback: this.showDeliveryNote}, {name: 'Send Delivery Note', callback: this.confirmDeliveryNote}, {name: 'Delete ticket', callback: this.showDeleteTicketDialog}, diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 998f481ea..224392deb 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -323,19 +323,19 @@ - - - - - - + + + + + + + + - - + + ng-model="$ctrl.sms.destination" + required="true" + rule>
@@ -16,14 +18,22 @@ vn-id="message" label="Message" ng-model="$ctrl.sms.message" + info="Special characters like accents counts as a multiple" rows="5" - maxlength="160" + required="true" rule> - {{'Characters remaining' | translate}}: {{$ctrl.charactersRemaining()}} + {{'Characters remaining' | translate}}: + + {{$ctrl.charactersRemaining()}} + diff --git a/modules/ticket/front/sms/index.js b/modules/ticket/front/sms/index.js index 1f2c7f9c0..ac1131513 100644 --- a/modules/ticket/front/sms/index.js +++ b/modules/ticket/front/sms/index.js @@ -17,23 +17,35 @@ class Controller extends Component { } charactersRemaining() { - let elementMaxLength; - let textAreaLength; const element = this.$scope.message; + const value = element.input.value; - textAreaLength = element.input.textLength; - elementMaxLength = element.maxlength; - return elementMaxLength - textAreaLength; + const maxLength = 160; + const textAreaLength = new Blob([value]).size; + return maxLength - textAreaLength; } onResponse(response) { if (response === 'accept') { - this.$http.post(`Tickets/${this.$params.id}/sendSms`, this.sms).then(res => { - this.vnApp.showMessage(this.$translate.instant('SMS sent!')); + 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`); - if (res.data) this.emit('send', {response: res.data}); - }); + this.$http.post(`Tickets/${this.$params.id}/sendSms`, this.sms).then(res => { + this.vnApp.showMessage(this.$translate.instant('SMS sent!')); + + if (res.data) this.emit('send', {response: res.data}); + }); + } catch (e) { + this.vnApp.showError(this.$translate.instant(e.message)); + return false; + } } + return true; } } diff --git a/modules/ticket/front/sms/index.spec.js b/modules/ticket/front/sms/index.spec.js index 5565c3623..96c10edd1 100644 --- a/modules/ticket/front/sms/index.spec.js +++ b/modules/ticket/front/sms/index.spec.js @@ -14,6 +14,11 @@ describe('Ticket', () => { $element = angular.element(''); controller = $componentController('vnTicketSms', {$element, $scope}); controller.$params = {id: 11}; + controller.$scope.message = { + input: { + value: 'My SMS' + } + }; })); describe('onResponse()', () => { @@ -29,20 +34,39 @@ describe('Ticket', () => { expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent!'); }); + + it('should call onResponse without the destination and show an error snackbar', () => { + controller.sms = {destinationFk: 101, message: 'My SMS'}; + + spyOn(controller.vnApp, 'showError'); + + controller.onResponse('accept'); + + expect(controller.vnApp.showError).toHaveBeenCalledWith(`The destination can't be empty`); + }); + + it('should call onResponse without the message and show an error snackbar', () => { + controller.sms = {destinationFk: 101, destination: 222222222}; + + spyOn(controller.vnApp, 'showError'); + + controller.onResponse('accept'); + + expect(controller.vnApp.showError).toHaveBeenCalledWith(`The message can't be empty`); + }); }); describe('charactersRemaining()', () => { it('should return the characters remaining in a element', () => { controller.$scope.message = { input: { - textLength: 50 - }, - maxlength: 150 + value: 'My message 0€' + } }; let result = controller.charactersRemaining(); - expect(result).toEqual(100); + expect(result).toEqual(145); }); }); }); diff --git a/modules/ticket/front/sms/locale/es.yml b/modules/ticket/front/sms/locale/es.yml index f26c8ba24..64c3fcca6 100644 --- a/modules/ticket/front/sms/locale/es.yml +++ b/modules/ticket/front/sms/locale/es.yml @@ -2,4 +2,8 @@ Send SMS: Enviar SMS Destination: Destinatario Message: Mensaje SMS sent!: ¡SMS enviado! -Characters remaining: Carácteres restantes \ No newline at end of file +Characters remaining: Carácteres restantes +The destination can't be empty: El destinatario no puede estar vacio +The message can't be empty: El mensaje no puede estar vacio +The message it's too long: El mensaje es demasiado largo +Special characters like accents counts as a multiple: Carácteres especiales como los acentos cuentan como varios \ No newline at end of file diff --git a/modules/travel/back/methods/travel/specs/filter.spec.js b/modules/travel/back/methods/travel/specs/filter.spec.js index f2fe44989..03849f2b0 100644 --- a/modules/travel/back/methods/travel/specs/filter.spec.js +++ b/modules/travel/back/methods/travel/specs/filter.spec.js @@ -23,7 +23,7 @@ describe('Travel filter()', () => { let result = await app.models.Travel.filter(ctx); - expect(result.length).toEqual(7); + expect(result.length).toEqual(8); }); it('should return the travel matching "total entries"', async() => { diff --git a/modules/travel/front/descriptor-popover/index.html b/modules/travel/front/descriptor-popover/index.html new file mode 100644 index 000000000..fc0fb0301 --- /dev/null +++ b/modules/travel/front/descriptor-popover/index.html @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/modules/travel/front/descriptor-popover/index.js b/modules/travel/front/descriptor-popover/index.js new file mode 100644 index 000000000..cb13d7f06 --- /dev/null +++ b/modules/travel/front/descriptor-popover/index.js @@ -0,0 +1,88 @@ +import ngModule from '../module'; +import Component from 'core/lib/component'; + +class Controller extends Component { + constructor($element, $scope, $http, $timeout, $q) { + super($element, $scope); + this.$timeout = $timeout; + this.$http = $http; + this.$q = $q; + this.travel = null; + this._quicklinks = {}; + } + + set travelId(travelId) { + if (travelId == this._travelId) return; + + this._travelId = travelId; + this.travel = null; + this.loadData(); + } + + get travelId() { + return this._travelId; + } + + get quicklinks() { + return this._quicklinks; + } + + set quicklinks(value = {}) { + Object.keys(value).forEach(key => { + this._quicklinks[key] = value[key]; + }); + } + + show() { + this.$.popover.parent = this.parent; + this.$.popover.show(); + } + + loadData() { + let query = `Travels/findOne`; + let filter = { + fields: [ + 'id', + 'ref', + 'shipped', + 'landed', + 'totalEntries', + 'warehouseInFk', + 'warehouseOutFk' + ], + where: { + id: this._travelId + }, + include: [ + { + relation: 'warehouseIn', + scope: { + fields: ['name'] + } + }, { + relation: 'warehouseOut', + scope: { + fields: ['name'] + } + } + ] + }; + + this.$http.get(query, {params: {filter}}).then(res => { + this.travel = res.data; + this.$.$applyAsync(() => { + this.$.popover.relocate(); + }); + }); + } +} +Controller.$inject = ['$element', '$scope', '$http', '$timeout', '$q']; + +ngModule.component('vnTravelDescriptorPopover', { + template: require('./index.html'), + controller: Controller, + bindings: { + travelId: '<', + quicklinks: '<' + } +}); diff --git a/modules/travel/front/descriptor-popover/index.spec.js b/modules/travel/front/descriptor-popover/index.spec.js new file mode 100644 index 000000000..12ad364bf --- /dev/null +++ b/modules/travel/front/descriptor-popover/index.spec.js @@ -0,0 +1,100 @@ +import './index.js'; + +describe('travel Component vnTravelDescriptorPopover', () => { + let $httpBackend; + let $httpParamSerializer; + let $scope; + let controller; + let $element; + + beforeEach(ngModule('travel')); + + beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { + $httpBackend = _$httpBackend_; + $httpParamSerializer = _$httpParamSerializer_; + $element = angular.element(`
`); + $scope = $rootScope.$new(); + $scope.popover = {relocate: () => {}, show: () => {}}; + controller = $componentController('vnTravelDescriptorPopover', {$scope, $element}); + })); + + describe('travelId()', () => { + it(`should not apply any changes if the received id is the same stored in _travelId`, () => { + controller.travel = 'I exist!'; + controller._travelId = 1; + spyOn(controller, 'loadData'); + controller.travelId = 1; + + expect(controller.travel).toEqual('I exist!'); + expect(controller._travelId).toEqual(1); + expect(controller.loadData).not.toHaveBeenCalled(); + }); + + it(`should set the received id into _travelId, set the travel to null and then call loadData()`, () => { + controller.travel = `Please don't`; + controller._travelId = 1; + spyOn(controller, 'loadData'); + controller.travelId = 999; + + expect(controller.travel).toBeNull(); + expect(controller._travelId).toEqual(999); + expect(controller.loadData).toHaveBeenCalledWith(); + }); + }); + + describe('show()', () => { + it(`should call the show()`, () => { + spyOn(controller.$.popover, 'show'); + controller.show(); + + expect(controller.$.popover.show).toHaveBeenCalledWith(); + }); + }); + + describe('loadData()', () => { + it(`should perform a get query to store the worker data into the controller`, () => { + controller.travelId = 1; + controller.canceler = null; + let response = {}; + + let config = { + filter: { + fields: [ + 'id', + 'ref', + 'shipped', + 'landed', + 'totalEntries', + 'warehouseInFk', + 'warehouseOutFk' + ], + where: { + id: controller.travelId + }, + include: [ + { + relation: 'warehouseIn', + scope: { + fields: ['name'] + } + }, { + relation: 'warehouseOut', + scope: { + fields: ['name'] + } + } + ] + } + }; + + let json = $httpParamSerializer(config); + + $httpBackend.whenGET(`Travels/findOne?${json}`).respond(response); + $httpBackend.expectGET(`Travels/findOne?${json}`); + controller.loadData(); + $httpBackend.flush(); + + expect(controller.travel).toEqual(response); + }); + }); +}); diff --git a/modules/travel/front/index.js b/modules/travel/front/index.js index 1f5346e98..b72f9fd51 100644 --- a/modules/travel/front/index.js +++ b/modules/travel/front/index.js @@ -11,4 +11,4 @@ import './log'; import './create'; import './thermograph/index/'; import './thermograph/create/'; - +import './descriptor-popover'; diff --git a/modules/worker/front/descriptor-popover/index.js b/modules/worker/front/descriptor-popover/index.js index b648e8bd2..55843a67d 100644 --- a/modules/worker/front/descriptor-popover/index.js +++ b/modules/worker/front/descriptor-popover/index.js @@ -1,6 +1,5 @@ import ngModule from '../module'; import Component from 'core/lib/component'; -import './style.scss'; class Controller extends Component { constructor($element, $scope, $http, $timeout, $q) { diff --git a/modules/worker/front/descriptor-popover/style.scss b/modules/worker/front/descriptor-popover/style.scss deleted file mode 100644 index 58e65d320..000000000 --- a/modules/worker/front/descriptor-popover/style.scss +++ /dev/null @@ -1,11 +0,0 @@ -vn-ticket-descriptor-popover { - vn-ticket-descriptor { - display: block; - width: 16em; - max-height: 28em; - - & > vn-card { - margin: 0!important; - } - } -} \ No newline at end of file diff --git a/modules/worker/front/log/index.html b/modules/worker/front/log/index.html index 9624d4aed..8aa693924 100644 --- a/modules/worker/front/log/index.html +++ b/modules/worker/front/log/index.html @@ -14,18 +14,18 @@ - Date + Date Author Model Action - Name + Name Before After - + {{::log.creationDate | date:'dd/MM/yyyy HH:mm'}}
@@ -63,7 +63,7 @@ {{::$ctrl.actionsText[log.action]}} - + {{::log.changedModelValue}} diff --git a/modules/worker/front/log/style.scss b/modules/worker/front/log/style.scss index 0943cbc77..0d2d93914 100644 --- a/modules/worker/front/log/style.scss +++ b/modules/worker/front/log/style.scss @@ -14,14 +14,6 @@ vn-log { color: $color-font; } - .after, .before { - max-width: 250px; - } - - vn-table .firstColumn { - min-width: 150px - } - @media screen and (max-width: 1570px) { vn-table .expendable { display: none; diff --git a/print/templates/reports/campaign-metrics/campaign-metrics.html b/print/templates/reports/campaign-metrics/campaign-metrics.html index 5e4bc7d08..7a0f30948 100644 --- a/print/templates/reports/campaign-metrics/campaign-metrics.html +++ b/print/templates/reports/campaign-metrics/campaign-metrics.html @@ -57,27 +57,39 @@ - + - - - - - - + +
{{$t('Code')}}{{$t('Code')}} {{$t('Quantity')}} {{$t('Concept')}}
{{sale.itemFk}}{{Math.trunc(sale.subtotal)}} - {{sale.concept}} {{sale.subName | uppercase}} -
- {{sale.tag5}} - {{sale.value5}} - {{sale.tag6}} - {{sale.value6}} - {{sale.tag7}} - {{sale.value7}} -
-
diff --git a/print/templates/reports/driver-route/driver-route.html b/print/templates/reports/driver-route/driver-route.html index bfeba3b8a..6d3b840df 100644 --- a/print/templates/reports/driver-route/driver-route.html +++ b/print/templates/reports/driver-route/driver-route.html @@ -14,7 +14,7 @@
-

{{$t('title')}}

+

{{route.id}}

{{$t('information')}}