7199-devToTest_2316 #2287

Merged
alexm merged 169 commits from 7199-devToTest_2316 into test 2024-04-11 06:25:23 +00:00
10 changed files with 288 additions and 427 deletions
Showing only changes of commit 4dca49360e - Show all commits

View File

@ -23,7 +23,7 @@ BEGIN
ENGINE = MEMORY ENGINE = MEMORY
SELECT Id_Ticket SELECT Id_Ticket
FROM vn2008.Tickets t FROM vn2008.Tickets t
JOIN vn.invoiceOut io ON io.id = t.Factura JOIN vn.invoiceOut io ON io.`ref` = t.Factura
WHERE year(io.issued) = vYear WHERE year(io.issued) = vYear
AND month(io.issued) = vMonth; AND month(io.issued) = vMonth;

View File

@ -0,0 +1,102 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`absoluteInventoryHistory`(
vItemFk INT,
vWarehouseFk INT,
vDate DATETIME
)
BEGIN
/**
* Calcula y proporciona un historial de inventario absoluto
* para un artículo específico en un almacén dado
* hasta una fecha determinada.
*
* @param vItemFk Id de artículo
* @param vWarehouseFk Id de almacén
* @param vDate Fecha
*/
DECLARE vCalculatedInventory INT;
DECLARE vToday DATETIME DEFAULT util.VN_CURDATE();
DECLARE vStartDate DATE DEFAULT '2001-01-01';
CREATE OR REPLACE TEMPORARY TABLE tHistoricalPast
ENGINE = MEMORY
SELECT *
FROM (
SELECT tr.landed `date`,
b.quantity input,
NULL `output`,
tr.isReceived ok,
s.name alias,
e.invoiceNumber reference,
e.id id,
tr.isDelivered f5
FROM buy b
JOIN `entry` e ON e.id = b.entryFk
JOIN travel tr ON tr.id = e.travelFk
JOIN supplier s ON s.id = e.supplierFk
WHERE tr.landed >= vStartDate
AND s.id <> (SELECT supplierFk FROM inventoryConfig)
AND vWarehouseFk IN (tr.warehouseInFk, 0)
AND b.itemFk = vItemFk
AND NOT e.isExcludedFromAvailable
AND NOT e.isRaid
UNION ALL
SELECT tr.shipped,
NULL,
b.quantity,
tr.isDelivered,
s.name,
e.invoiceNumber,
e.id,
tr.isDelivered
FROM buy b
JOIN `entry` e ON e.id = b.entryFk
JOIN travel tr ON tr.id = e.travelFk
JOIN supplier s ON s.id = e.supplierFk
WHERE tr.shipped >= vStartDate
AND vWarehouseFk = tr.warehouseOutFk
AND s.id <> (SELECT supplierFk FROM inventoryConfig)
AND b.itemFk = vItemFk
AND NOT e.isExcludedFromAvailable
AND NOT e.isRaid
UNION ALL
SELECT t.shipped,
NULL,
m.quantity,
(m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL),
t.nickname,
t.refFk,
t.id,
t.isPrinted
FROM sale m
JOIN ticket t ON t.id = m.ticketFk
JOIN client c ON c.id = t.clientFk
WHERE t.shipped >= vStartDate
AND m.itemFk = vItemFk
AND vWarehouseFk IN (t.warehouseFk, 0)
) t1
ORDER BY `date`, input DESC, ok DESC;
SELECT SUM(input) - SUM(`output`) INTO vCalculatedInventory
FROM tHistoricalPast
WHERE `date` < vDate;
SELECT p1.*, NULL v_virtual
FROM (
SELECT vDate `date`,
vCalculatedInventory input,
NULL `output`,
1 ok,
'Inventario calculado' alias,
'' reference,
0 id,
1 f5
UNION ALL
SELECT *
FROM tHistoricalPast
WHERE `date` >= vDate
) p1;
DROP TEMPORARY TABLE tHistoricalPast;
END$$
DELIMITER ;

View File

@ -10,20 +10,15 @@ BEGIN
* @param vInvoiceInFk Id de factura recibida * @param vInvoiceInFk Id de factura recibida
*/ */
DECLARE vRate DOUBLE DEFAULT 1; DECLARE vRate DOUBLE DEFAULT 1;
DECLARE vDated DATE; DECLARE vExpenseFk VARCHAR(10);
DECLARE vExpenseFk INT;
SELECT MAX(rr.dated) INTO vDated SELECT `value` INTO vRate
FROM referenceRate rr FROM referenceRate rr
JOIN invoiceIn ii ON ii.id = vInvoiceInFk JOIN invoiceIn ii ON ii.id = vInvoiceInFk
WHERE rr.dated <= ii.issued WHERE rr.dated <= ii.issued
AND rr.currencyFk = ii.currencyFk; AND rr.currencyFk = ii.currencyFk
ORDER BY dated DESC
IF vDated THEN LIMIT 1;
SELECT `value` INTO vRate
FROM referenceRate
WHERE dated = vDated;
END IF;
DELETE FROM invoiceInTax WHERE invoiceInFk = vInvoiceInFk; DELETE FROM invoiceInTax WHERE invoiceInFk = vInvoiceInFk;

View File

@ -0,0 +1,158 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`multipleInventoryHistory`(
vItemFk INT
)
BEGIN
/**
* Calcula y proporciona un historial de inventario detallado
* para un artículo dividiendo la información
* por almacén.
*
* @param vItemFk Artículo
*/
DECLARE vDateInventory DATETIME;
SELECT inventoried INTO vDateInventory FROM config;
DROP TEMPORARY TABLE IF EXISTS tMultipleHistory1;
CREATE TEMPORARY TABLE tMultipleHistory1
SELECT DATE(`date`) `date`,
input,
`output`,
ok,
reference,
history.id,
warehouse,
`name` warehouseName
FROM (
SELECT tr.landed `date`,
c.quantity input,
NULL `output`,
tr.warehouseInFk warehouse,
tr.isReceived ok,
e.invoiceNumber reference,
e.id
FROM buy c
JOIN `entry` e ON e.id = c.entryFk
JOIN travel tr ON tr.id = e.travelFk
WHERE tr.landed >= vDateInventory
AND c.itemFk = vItemFk
AND NOT e.isRaid
AND c.quantity
UNION ALL
SELECT tr.shipped,
NULL,
c.quantity,
tr.warehouseOutFk,
tr.isDelivered,
e.invoiceNumber,
e.id
FROM buy c
JOIN `entry` e ON e.id = c.entryFk
JOIN travel tr ON tr.id = e.travelFk
WHERE tr.shipped >= vDateInventory
AND c.itemFk = vItemFk
AND NOT e.isRaid
AND c.quantity
UNION ALL
SELECT t.shipped,
NULL,
m.quantity,
t.warehouseFk,
(m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL),
t.refFk,
t.id
FROM sale m
JOIN ticket t ON t.id = m.ticketFk
WHERE t.shipped >= vDateInventory
AND m.itemFk = vItemFk
) history
JOIN warehouse ON warehouse.id = history.warehouse
ORDER BY `date`, input DESC, ok DESC;
DROP TEMPORARY TABLE IF EXISTS tMultipleHistory2, tMultipleHistory3,
tMultipleHistory4, tMultipleHistory5, tMultipleHistory6, tMultipleHistory7, tMultipleHistory8;
CREATE TEMPORARY TABLE tMultipleHistory2 SELECT * FROM tMultipleHistory1 WHERE warehouse = 19;
CREATE TEMPORARY TABLE tMultipleHistory3 SELECT * FROM tMultipleHistory1 WHERE warehouse = 7;
CREATE TEMPORARY TABLE tMultipleHistory4 SELECT * FROM tMultipleHistory1 WHERE warehouse = 60;
CREATE TEMPORARY TABLE tMultipleHistory5 SELECT * FROM tMultipleHistory1 WHERE warehouse = 5;
CREATE TEMPORARY TABLE tMultipleHistory6 SELECT * FROM tMultipleHistory1 WHERE warehouse = 17;
CREATE TEMPORARY TABLE tMultipleHistory7 SELECT * FROM tMultipleHistory1 WHERE warehouse = 37;
CREATE TEMPORARY TABLE tMultipleHistory8 SELECT * FROM tMultipleHistory1 WHERE warehouse = 55;
SELECT *
FROM (
SELECT `date`, input BOGinput, `output` BOGoutput, ok BOGok, reference BOGreference, id BOGid,
NULL VNHinput, NULL VNHoutput, NULL VNHok, NULL VNHreference, NULL VNHid,
NULL ALGinput, NULL ALGoutput, NULL ALGok, NULL ALGreference, NULL ALGid,
NULL MADinput, NULL MADoutput, NULL MADok, NULL MADreference, NULL MADid,
NULL MCFinput, NULL MCFoutput, NULL MCFok, NULL MCFreference, NULL MCFid,
NULL VILinput, NULL VILoutput, NULL VILok, NULL VILreference, NULL VILid,
NULL BARinput, NULL BARoutput, NULL BARok, NULL BARreference, NULL BARid
FROM tMultipleHistory2
UNION ALL
SELECT `date`,
NULL, NULL, NULL, NULL, NULL,
input, `output`, ok, reference, id,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL
FROM tMultipleHistory3
UNION ALL
SELECT `date`,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
input, `output`, ok, reference, id,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL
FROM tMultipleHistory4
UNION ALL
SELECT `date`,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
input, `output`, ok, reference, id,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL
FROM tMultipleHistory5
UNION ALL
SELECT `date`,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
input, `output`, ok, reference, id,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL
FROM tMultipleHistory6
UNION ALL
SELECT `date`,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
input, `output`, ok, reference, id,
NULL, NULL, NULL, NULL, NULL
FROM tMultipleHistory7
UNION ALL
SELECT `date`,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
input, `output`, ok, reference, id
FROM tMultipleHistory8
) sub
ORDER BY `date`, BOGinput IS NULL, VNHinput IS NULL, ALGinput IS NULL,
MADinput IS NULL, MCFinput IS NULL, VILinput IS NULL, BARinput IS NULL;
END$$
DELIMITER ;

View File

@ -1,61 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`add_awb_component`(IN vAwbFk SMALLINT)
BEGIN
DECLARE vShipped DATE;
DECLARE vHasStems BOOLEAN;
SELECT t.shipped, IF(a.stems, TRUE, FALSE)
INTO vShipped, vHasStems
FROM vn.travel t
JOIN vn.awb a ON a.id = t.awbFk
WHERE awbFk = vAwbFk
LIMIT 1;
INSERT IGNORE INTO awb_component (awb_id,Id_Proveedor,awb_component_type_id,awb_role_id,awb_unit_id,value,Id_Moneda)
SELECT id, Id_Proveedor, awb_component_type_id, awb_role_id,awb_unit_id, LEAST(GREATEST(value1, IFNULL(min_value, value1)), IFNULL(max_value, value1)), Id_Moneda
FROM (
SELECT a.id,
IFNULL(act.carguera_id,
CASE awb_role_id
WHEN 1 THEN a.carguera_id
WHEN 2 THEN a.transitario_id
WHEN 3 THEN f.airline_id
END
) Id_Proveedor,
act.awb_component_type_id,
act.awb_role_id,
act.awb_unit_id,
value *
CASE awb_unit_id
WHEN '1000Tj-20' THEN ((CAST(stems AS SIGNED) - 20000)/1000) + (min_value / value)
WHEN '1000Tj-10' THEN ((CAST(stems AS SIGNED) - 10000)/1000) + (min_value / value)
WHEN '100GW' THEN peso/100
WHEN 'AWB' THEN 1 -- No action
WHEN 'FB' THEN hb/2
WHEN 'GW' THEN peso
WHEN 'TW' THEN GREATEST(peso,volume_weight)
WHEN 'PN' THEN LEAST(90, value + a.propertyNumber * 10)
END value1,
value,
act.Id_Moneda,
act.min_value,
act.max_value
FROM awb a
JOIN flight f ON f.flight_id = a.flight_id
LEFT JOIN awb_component_template act ON
((IFNULL(act.carguera_id, a.carguera_id) = a.carguera_id AND awb_role_id = 1)
OR (IFNULL(act.carguera_id, a.transitario_id) = a.transitario_id AND awb_role_id = 2)
OR (IFNULL(act.airline_id, f.airline_id) = f.airline_id AND awb_role_id = 3)
OR (awb_role_id = 4))
AND IFNULL(act.airport_out, f.airport_out) = f.airport_out
AND IFNULL(act.airport_in, f.airport_in) = f.airport_in
AND IFNULL(act.airline_id, f.airline_id) = f.airline_id
AND INSTR(IFNULL(act.days, WEEKDAY(vShipped) + 1),WEEKDAY(vShipped) + 1)
JOIN awb_component_type acty ON acty.awb_component_type_id = act.awb_component_type_id
WHERE a.id = vAwbFk AND Fecha <= vShipped
AND (vHasStems = TRUE OR acty.hasStems)
ORDER BY Fecha DESC, act.days DESC LIMIT 10000000000000000000
) t;
END$$
DELIMITER ;

View File

@ -1,50 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`agencyModeImbalance`(vStarted DATE, vEnded DATE)
BEGIN
/**
* Devuelve el valor de los precios teorico, practico de las agencias
* y si ademas es de mrw lo compara con su fichero previamente procesado
*
* @param vEktFk Identificador de edi.ekt
*/
DECLARE vEndedDayEnd DATETIME;
SET vEndedDayEnd = util.dayEnd(vEnded);
SELECT t.id ticketFk,t.addressFk,
CAST(v.amount AS DECIMAL (10,2)) AS VN,
CAST(v.amount - e.shipping_charge AS DECIMAL (10,2)) AS Difer,
CAST(mrwPrice AS DECIMAL (10,2)) mrwPrice,
CAST(e.shipping_charge - mrwPrice AS DECIMAL (10,2)) mrwDifference,
CAST(e.shipping_charge AS DECIMAL (10,2)) AS teorico,
CAST(e.extraCharge AS DECIMAL (10,2)) AS extraCharge,
t.packages, t.clientFk,
t.zoneFk, a.provinceFk, mrwCount
FROM vn.ticket t
LEFT JOIN
(SELECT ticketFk, SUM(amount) amount, fc.shipped
FROM vn.sale_freightComponent fc
JOIN vn.ticket t ON t.id = fc.ticketFk
JOIN tmp.agencyMode am ON am.agencyModeFk = t.agencyModeFk
WHERE fc.shipped BETWEEN vStarted AND vEndedDayEnd
GROUP BY ticketFk) v ON t.id = v.ticketFk
LEFT JOIN (SELECT t.id,
SUM(t.zonePrice) shipping_charge,
SUM(IFNULL(aex.price,0)) extraCharge
FROM vn.ticket t
LEFT JOIN vn.expedition e ON e.ticketFk = t.id
LEFT JOIN vn.packaging p ON p.id = e.packagingFk
JOIN tmp.agencyMode amc ON amc.agencyModeFk = t.agencyModeFk
JOIN vn.agencyMode am ON am.id = amc.agencyModeFk
LEFT JOIN vn.agencyExtraCharge aex ON p.width+p.depth+p.height BETWEEN aex.sizeMin AND aex.sizeMax AND aex.agencyFk = am.agencyFk
WHERE t.shipped BETWEEN vStarted AND vEndedDayEnd
GROUP BY t.id
) e ON t.id = e.id
LEFT JOIN (SELECT ticketFk, SUM(price) mrwPrice, COUNT(*) mrwCount
FROM vn.mrw
GROUP BY ticketFk) mrw ON mrw.ticketFk = t.id
JOIN vn.address a ON a.id = t.addressFk
JOIN tmp.agencyMode am ON am.agencyModeFk = t.agencyModeFk
WHERE t.shipped BETWEEN vStarted AND vEndedDayEnd;
END$$
DELIMITER ;

View File

@ -1,91 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`historico_absoluto`(IN idART INT, IN wh INT, IN datfecha DATETIME)
BEGIN
DECLARE inv_calculado INT;
DECLARE inv INT;
DECLARE today DATETIME;
DECLARE fecha_inv DATETIME;
SET today = util.VN_CURDATE();
CREATE OR REPLACE TEMPORARY TABLE historico_pasado
SELECT *
FROM (
SELECT TR.landing Fecha,
C.Cantidad Entrada,
NULL Salida,
(TR.received != FALSE) OK,
P.Proveedor Alias,
E.Referencia Referencia,
E.Id_Entrada id,
TR.delivered F5
FROM Compres C -- mirar perque no entra en received
INNER JOIN Entradas E USING (Id_Entrada)
INNER JOIN travel TR ON TR.id = E.travel_id
INNER JOIN Proveedores P USING (Id_Proveedor)
WHERE TR.landing >= '2001-01-01'
AND Id_proveedor <> 4
AND wh IN (TR.warehouse_id , 0)
AND C.Id_Article = idART
AND E.Inventario = 0
AND E.Redada = 0
UNION ALL
SELECT TR.shipment Fecha,
NULL Entrada,
C.Cantidad Salida,
TR.delivered OK,
P.Proveedor Alias,
E.Referencia Referencia,
E.Id_Entrada id,
TR.delivered F5
FROM Compres C
INNER JOIN Entradas E USING (Id_Entrada)
INNER JOIN travel TR ON TR.id = E.travel_id
INNER JOIN Proveedores P USING (Id_Proveedor)
WHERE TR.shipment >= '2001-01-01'
AND wh = TR.warehouse_id_out
AND Id_Proveedor <> 4
AND C.Id_Article = idART
AND E.Inventario = 0
AND E.Redada = 0
UNION ALL
SELECT T.Fecha Fecha,
NULL Entrada,
M.Cantidad Salida,
(M.OK <> 0 OR T.Etiquetasemitidas <> 0 OR T.Factura IS NOT NULL) OK,
T.Alias Alias,
T.Factura Referencia,
T.Id_Ticket,
T.PedidoImpreso
FROM Movimientos M
INNER JOIN Tickets T USING (Id_Ticket)
JOIN Clientes C ON C.Id_Cliente = T.Id_Cliente
WHERE T.Fecha >= '2001-01-01'
AND M.Id_Article = idART
AND wh IN (T.warehouse_id , 0)
) t1
ORDER BY Fecha, Entrada DESC, OK DESC;
SELECT sum(Entrada) - sum(Salida) INTO inv_calculado
FROM historico_pasado
WHERE Fecha < datfecha;
SELECT p1.*, NULL v_virtual
FROM(
SELECT datfecha Fecha,
inv_calculado Entrada,
NULL Salida,
1 OK,
'Inventario calculado' Alias,
'' Referencia, 0 id,
1 F5
UNION ALL
SELECT *
FROM historico_pasado
WHERE Fecha >= datfecha
) p1;
DROP TEMPORARY TABLE historico_pasado;
END$$
DELIMITER ;

View File

@ -1,206 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`historico_multiple`(IN vItemFk INT)
BEGIN
DECLARE vDateInventory DATETIME;
SELECT Fechainventario INTO vDateInventory FROM tblContadores;
SET @a = 0;
DROP TEMPORARY TABLE IF EXISTS hm1;
CREATE TEMPORARY TABLE hm1
SELECT DATE(Fecha) as Fecha,
Entrada,
Salida,
OK,
Referencia,
Historia.id,
wh,
`name` as wh_name
FROM
( SELECT TR.landing as Fecha,
C.Cantidad as Entrada,
NULL as Salida,
IF(warehouse_id = 44, 1, warehouse_id) as wh,
(TR.received != FALSE) as OK,
E.Referencia as Referencia,
E.Id_Entrada as id
FROM Compres C
INNER JOIN Entradas E USING (Id_Entrada)
INNER JOIN travel TR ON TR.id = E.travel_id
WHERE TR.landing >= vDateInventory
AND C.Id_Article = vItemFk
AND E.Redada = 0
AND C.Cantidad <> 0
UNION ALL
SELECT TR.shipment as Fecha,
NULL as Entrada,
C.Cantidad as Salida,
warehouse_id_out as wh,
TR.delivered as OK,
E.Referencia as Referencia,
E.Id_Entrada as id
FROM Compres C
INNER JOIN Entradas E USING (Id_Entrada)
INNER JOIN travel TR ON TR.id = E.travel_id
WHERE TR.shipment >= vDateInventory
AND C.Id_Article = vItemFk
AND E.Redada = 0
AND C.Cantidad <> 0
UNION ALL
SELECT T.Fecha as Fecha,
NULL as Entrada,
M.Cantidad as Salida,
warehouse_id as wh,
(M.OK <> 0 OR T.Etiquetasemitidas <> 0 OR T.Factura IS NOT NULL) as OK,
T.Factura as Referencia,
T.Id_Ticket as id
FROM Movimientos M
INNER JOIN Tickets T USING (Id_Ticket)
WHERE T.Fecha >= vDateInventory
AND M.Id_Article = vItemFk
) AS Historia
INNER JOIN warehouse ON warehouse.id = Historia.wh
ORDER BY Fecha, Entrada DESC, OK DESC;
DROP TEMPORARY TABLE IF EXISTS hm2;
DROP TEMPORARY TABLE IF EXISTS hm3;
DROP TEMPORARY TABLE IF EXISTS hm4;
DROP TEMPORARY TABLE IF EXISTS hm5;
DROP TEMPORARY TABLE IF EXISTS hm6;
DROP TEMPORARY TABLE IF EXISTS hm7;
DROP TEMPORARY TABLE IF EXISTS hm8;
CREATE TEMPORARY TABLE hm2 SELECT * FROM hm1 WHERE wh = 19;
CREATE TEMPORARY TABLE hm3 SELECT * FROM hm1 WHERE wh = 7;
CREATE TEMPORARY TABLE hm4 SELECT * FROM hm1 WHERE wh = 60;
CREATE TEMPORARY TABLE hm5 SELECT * FROM hm1 WHERE wh = 5;
CREATE TEMPORARY TABLE hm6 SELECT * FROM hm1 WHERE wh = 17;
CREATE TEMPORARY TABLE hm7 SELECT * FROM hm1 WHERE wh = 37;
CREATE TEMPORARY TABLE hm8 SELECT * FROM hm1 WHERE wh = 55;
SELECT * FROM
(
SELECT Fecha, Entrada as BOGEntrada, Salida as BOGSalida, OK as BOGOK, Referencia as BOGReferencia, id as BOGid,
NULL AS VNHEntrada, NULL AS VNHSalida, NULL AS VNHOK, NULL AS VNHReferencia, NULL AS VNHid,
NULL AS ALGEntrada, NULL AS ALGSalida, NULL AS ALGOK, NULL AS ALGReferencia, NULL AS ALGid,
NULL AS MADEntrada, NULL AS MADSalida, NULL AS MADOK, NULL AS MADReferencia, NULL AS MADid,
NULL AS MCFEntrada, NULL AS MCFSalida, NULL AS MCFOK, NULL AS MCFReferencia, NULL AS MCFid,
NULL AS VILEntrada, NULL AS VILSalida, NULL AS VILOK, NULL AS VILReferencia, NULL AS VILid,
NULL AS BAREntrada, NULL AS BARSalida, NULL AS BAROK, NULL AS BARReferencia, NULL AS BARid
FROM hm2
UNION ALL
SELECT Fecha
, NULL, NULL, NULL, NULL, NULL
,Entrada, Salida, OK, Referencia, id
, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL, NULL
FROM hm3
UNION ALL
SELECT Fecha
, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL, NULL
, Entrada, Salida, OK, Referencia, id
, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL, NULL
FROM hm4
UNION ALL
SELECT Fecha
, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL, NULL
, Entrada, Salida, OK, Referencia, id
, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL, NULL
FROM hm5
UNION ALL
SELECT Fecha
, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL, NULL
, Entrada, Salida, OK, Referencia, id
, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL, NULL
FROM hm6
UNION ALL
SELECT Fecha
, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL, NULL
, Entrada, Salida, OK, Referencia, id
, NULL, NULL, NULL, NULL, NULL
FROM hm7
UNION ALL
SELECT Fecha
, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL, NULL
, Entrada, Salida, OK, Referencia, id
FROM hm8
) sub
ORDER BY Fecha, BOGEntrada IS NULL, VNHEntrada IS NULL, ALGEntrada IS NULL, MADEntrada IS NULL, MCFEntrada IS NULL, VILEntrada IS NULL, BAREntrada IS NULL;
END$$
DELIMITER ;

View File

@ -0,0 +1,22 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`multipleInventoryHistory`(
vItemFk INT)
BEGIN
DECLARE vDateInventory DATETIME;
SELECT inventoried INTO vDateInventory FROM config;
END$$
DELIMITER ;
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`absoluteInventoryHistory`(
vItemFk INT, vWarehouse INT, vDate DATETIME)
BEGIN
DECLARE vCalculatedInventory INT;
SET vCalculatedInventory = 0;
END$$
DELIMITER ;
GRANT EXECUTE ON PROCEDURE vn.absoluteInventoryHistory TO buyer;
GRANT EXECUTE ON PROCEDURE vn.multipleInventoryHistory TO buyer;

View File

@ -22,12 +22,4 @@ describe('Account Connections path', () => {
expect(firstResult).toContain(account); expect(firstResult).toContain(account);
}); });
it('should kill this connection and then get redirected to the login page', async() => {
await page.waitToClick(selectors.accountConnections.deleteFirstConnection);
await page.waitToClick(selectors.globalItems.acceptButton);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Your session has expired, please login again');
});
}); });