refs #6498 procRefactor6 #2134
|
@ -16,6 +16,7 @@ BEGIN
|
|||
*/
|
||||
DECLARE vCalculatedInventory INT;
|
||||
guillermo marked this conversation as resolved
|
||||
DECLARE vToday DATETIME DEFAULT util.VN_CURDATE();
|
||||
DECLARE vStartDate DATE DEFAULT '2001-01-01';
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tHistoricalPast
|
||||
ENGINE = MEMORY
|
||||
|
@ -33,44 +34,44 @@ BEGIN
|
|||
JOIN `entry` e ON e.id = b.entryFk
|
||||
JOIN travel tr ON tr.id = e.travelFk
|
||||
JOIN supplier s ON s.id = e.supplierFk
|
||||
guillermo
commented
No poner números a pelo en el código, para ello:
No poner números a pelo en el código, para ello:
```
AND s.id <> (SELECT supplierFk FROM inventoryConfig)
```
|
||||
WHERE tr.landed >= '2001-01-01'
|
||||
AND s.id <> 4
|
||||
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 `date`,
|
||||
NULL input,
|
||||
b.quantity `output`,
|
||||
tr.isDelivered ok,
|
||||
s.name alias,
|
||||
e.invoiceNumber reference,
|
||||
e.id id,
|
||||
tr.isDelivered f5
|
||||
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 >= '2001-01-01'
|
||||
WHERE tr.shipped >= vStartDate
|
||||
AND vWarehouseFk = tr.warehouseOutFk
|
||||
AND s.id <> 4
|
||||
AND s.id <> (SELECT supplierFk FROM inventoryConfig)
|
||||
AND b.itemFk = vItemFk
|
||||
AND NOT e.isExcludedFromAvailable
|
||||
AND NOT e.isRaid
|
||||
UNION ALL
|
||||
SELECT t.shipped `date`,
|
||||
NULL input,
|
||||
m.quantity `output`,
|
||||
(m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL) ok,
|
||||
t.nickname alias,
|
||||
t.refFk reference,
|
||||
SELECT t.shipped,
|
||||
NULL,
|
||||
guillermo
commented
```
(m.isPicked OR t.isLabeled OR t.refFk IS NOT 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
|
||||
guillermo
commented
'2001-01-01' repetido en el código, crear variable con DEFAULT '2001-01-01' '2001-01-01' repetido en el código, crear variable con DEFAULT '2001-01-01'
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
WHERE t.shipped >= '2001-01-01'
|
||||
WHERE t.shipped >= vStartDate
|
||||
AND m.itemFk = vItemFk
|
||||
AND vWarehouseFk IN (t.warehouseFk, 0)
|
||||
) t1
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`multipleInventoryHistory`(
|
||||
vItemFk INT)
|
||||
vItemFk INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Calcula y proporciona un historial de inventario detallado
|
||||
|
@ -28,7 +29,7 @@ BEGIN
|
|||
SELECT tr.landed `date`,
|
||||
c.quantity input,
|
||||
NULL `output`,
|
||||
guillermo marked this conversation as resolved
guillermo
commented
warehouseInFk warehouse warehouseInFk warehouse
|
||||
IF(warehouseInFk = 44, 1, warehouseInFk) warehouse,
|
||||
tr.warehouseInFk warehouse,
|
||||
guillermo
commented
`tr.isReceived`
|
||||
tr.isReceived ok,
|
||||
e.invoiceNumber reference,
|
||||
guillermo
commented
e.id e.id
|
||||
e.id
|
||||
|
@ -40,12 +41,12 @@ BEGIN
|
|||
AND NOT e.isRaid
|
||||
guillermo
commented
`AND c.quantity`
|
||||
AND c.quantity
|
||||
UNION ALL
|
||||
SELECT tr.shipped `date`,
|
||||
NULL input,
|
||||
c.quantity `output`,
|
||||
tr.warehouseOutFk warehouse,
|
||||
tr.isDelivered ok,
|
||||
e.invoiceNumber reference,
|
||||
SELECT tr.shipped,
|
||||
NULL,
|
||||
c.quantity,
|
||||
tr.warehouseOutFk,
|
||||
tr.isDelivered,
|
||||
e.invoiceNumber,
|
||||
guillermo
commented
Quitar alias siempre a partir del segundo select cuando se haga un UNION Quitar alias siempre a partir del segundo select cuando se haga un UNION
|
||||
e.id
|
||||
FROM buy c
|
||||
JOIN `entry` e ON e.id = c.entryFk
|
||||
|
@ -55,13 +56,13 @@ BEGIN
|
|||
AND NOT e.isRaid
|
||||
guillermo
commented
`c.quantity`
|
||||
AND c.quantity
|
||||
UNION ALL
|
||||
SELECT t.shipped `date`,
|
||||
NULL input,
|
||||
m.quantity `output`,
|
||||
tr.warehouseInFk warehouse,
|
||||
(m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL) ok,
|
||||
t.refFk reference,
|
||||
t.id id
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue
Quitar linea