Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 2087-snackbar_show_counter

This commit is contained in:
Carlos Jimenez Ruiz 2020-02-20 11:01:41 +01:00
commit d9783c80d1
208 changed files with 4520 additions and 2665 deletions

View File

@ -32,6 +32,8 @@ module.exports = Self => {
if (sender.name != recipient)
return sendMessage(sender, to, message);
return false;
};
async function sendMessage(sender, channel, message) {

View File

@ -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);
};
};

View File

@ -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();
});
});

View File

@ -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() => {

View File

@ -1,5 +0,0 @@
CREATE TABLE `vn`.`zoneClosure` (
`zoneFk` INT NOT NULL,
`dated` DATE NOT NULL,
`hour` TIME NOT NULL,
PRIMARY KEY (`zoneFk`, `dated`));

View File

@ -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 ;

View File

@ -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');

View File

@ -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 ;

View File

@ -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');

View File

@ -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');

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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');

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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' ;

View File

@ -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 ;

View File

@ -1,2 +0,0 @@
ALTER TABLE `vn`.`department`
ADD COLUMN `chatName` VARCHAR(45) NULL AFTER `path`;

View File

@ -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 ;

View File

@ -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;

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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`;

View File

@ -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`;

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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`))));

View File

@ -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`))));

View File

@ -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 ­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 ;

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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 ;

View File

@ -0,0 +1,2 @@
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
VALUES ('Intrastat', '*', '*', 'ALLOW', 'ROLE', 'buyer');

File diff suppressed because one or more lines are too long

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

@ -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);
});
});

BIN
e2e/dms/ecc/3.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -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.

View File

@ -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'});

View File

@ -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',
}
};

View File

@ -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');

View File

@ -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`);

View File

@ -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);

View File

@ -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();

View File

@ -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);

View File

@ -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);

View File

@ -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', '');

View File

@ -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();

View File

@ -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!');
});
});

View File

@ -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');
});
});

View File

@ -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});
});

View File

@ -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() => {

View File

@ -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');

View File

@ -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();

View File

@ -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');

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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');

Some files were not shown because too many files have changed in this diff Show More