This commit is contained in:
parent
adadf70f1e
commit
f30f907d8e
|
@ -10,7 +10,7 @@ BEGIN
|
||||||
JOIN (
|
JOIN (
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM (
|
FROM (
|
||||||
SELECT id, landed, tt.warehouseInFk, tt.warehouseOutFk
|
SELECT t.id, t.landed, tt.warehouseInFk, tt.warehouseOutFk
|
||||||
FROM travel t
|
FROM travel t
|
||||||
JOIN (
|
JOIN (
|
||||||
SELECT t.warehouseInFk, t.warehouseOutFk
|
SELECT t.warehouseInFk, t.warehouseOutFk
|
||||||
|
@ -19,11 +19,11 @@ BEGIN
|
||||||
JOIN travel t ON t.id = e.travelFk
|
JOIN travel t ON t.id = e.travelFk
|
||||||
GROUP BY t.warehouseInFk, t.warehouseOutFk
|
GROUP BY t.warehouseInFk, t.warehouseOutFk
|
||||||
) tt ON t.warehouseInFk = tt.warehouseInFk AND t.warehouseOutFk = tt.warehouseOutFk
|
) tt ON t.warehouseInFk = tt.warehouseInFk AND t.warehouseOutFk = tt.warehouseOutFk
|
||||||
WHERE shipped > util.VN_CURDATE() AND isDelivered = FALSE
|
WHERE shipped > util.VN_CURDATE() AND NOT isDelivered
|
||||||
ORDER BY t.landed
|
ORDER BY t.landed
|
||||||
LIMIT 10000000000000000000
|
LIMIT 10000000000000000000
|
||||||
) t
|
) t
|
||||||
GROUP BY warehouseInFk, warehouseOutFk
|
GROUP BY t.warehouseInFk, t.warehouseOutFk
|
||||||
) tt ON t.warehouseInFk = tt.warehouseInFk AND t.warehouseOutFk = tt.warehouseOutFk
|
) tt ON t.warehouseInFk = tt.warehouseInFk AND t.warehouseOutFk = tt.warehouseOutFk
|
||||||
SET e.travelFk = t.id;
|
SET e.travelFk = t.id;
|
||||||
|
|
||||||
|
|
|
@ -18,14 +18,14 @@ BEGIN
|
||||||
( SELECT
|
( SELECT
|
||||||
t.year,
|
t.year,
|
||||||
t.month,
|
t.month,
|
||||||
CAST(SUM(divisa) AS DECIMAL(10,2)) dollars,
|
CAST(SUM(p.divisa) AS DECIMAL(10,2)) dollars,
|
||||||
CAST(SUM(divisa) / SUM(amount) AS DECIMAL(5,4)) changePractical,
|
CAST(SUM(p.divisa) / SUM(p.amount) AS DECIMAL(5,4)) changePractical,
|
||||||
CAST(rr.value * 0.998 AS DECIMAL(5,4)) changeOfficial
|
CAST(rr.value * 0.998 AS DECIMAL(5,4)) changeOfficial
|
||||||
FROM payment p
|
FROM payment p
|
||||||
JOIN time t ON t.dated = p.received
|
JOIN time t ON t.dated = p.received
|
||||||
JOIN referenceRate rr ON rr.dated = p.received
|
JOIN referenceRate rr ON rr.dated = p.received
|
||||||
JOIN currency c ON c.id = rr.currencyFk
|
JOIN currency c ON c.id = rr.currencyFk
|
||||||
WHERE divisa
|
WHERE p.divisa
|
||||||
AND c.code = 'USD'
|
AND c.code = 'USD'
|
||||||
GROUP BY t.year, t.month
|
GROUP BY t.year, t.month
|
||||||
) pagos ON t.year = pagos.year AND t.month = pagos.MONTH
|
) pagos ON t.year = pagos.year AND t.month = pagos.MONTH
|
||||||
|
|
Loading…
Reference in New Issue