refs #6498 procRefactor6 #2134

Merged
ivanm merged 8 commits from 6499-procRefactor6 into dev 2024-03-21 11:03:33 +00:00
2 changed files with 37 additions and 35 deletions
Showing only changes of commit 6b2533cfb1 - Show all commits

View File

@ -16,6 +16,7 @@ BEGIN
*/
DECLARE vCalculatedInventory INT;
guillermo marked this conversation as resolved
Review

Quitar linea

Quitar linea
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

No poner números a pelo en el código, para ello:

AND s.id <> (SELECT supplierFk FROM inventoryConfig)
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,
(m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL)
``` (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
Review

'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

View File

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

warehouseInFk warehouse

warehouseInFk warehouse
IF(warehouseInFk = 44, 1, warehouseInFk) warehouse,
tr.warehouseInFk warehouse,

tr.isReceived

`tr.isReceived`
tr.isReceived ok,
e.invoiceNumber reference,

e.id

e.id
e.id
@ -40,12 +41,12 @@ BEGIN
AND NOT e.isRaid

AND c.quantity

`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,

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

c.quantity

`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