This commit is contained in:
parent
13ed86d26d
commit
4d1031e031
|
@ -28,7 +28,10 @@ BEGIN
|
||||||
'MERMA: RECLAMACION FALTAS'
|
'MERMA: RECLAMACION FALTAS'
|
||||||
),
|
),
|
||||||
(b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
|
(b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
|
||||||
0
|
IF(c.code = 'manaClaim',
|
||||||
|
sc.value * s.quantity,
|
||||||
|
0
|
||||||
|
)
|
||||||
)
|
)
|
||||||
) externalWaste
|
) externalWaste
|
||||||
FROM vn.sale s
|
FROM vn.sale s
|
||||||
|
@ -40,9 +43,11 @@ BEGIN
|
||||||
JOIN cache.last_buy lb ON lb.item_id = i.id
|
JOIN cache.last_buy lb ON lb.item_id = i.id
|
||||||
AND lb.warehouse_id = w.id
|
AND lb.warehouse_id = w.id
|
||||||
JOIN vn.buy b ON b.id = lb.buy_id
|
JOIN vn.buy b ON b.id = lb.buy_id
|
||||||
|
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
|
||||||
|
LEFT JOIN component c ON c.id = sc.componentFk
|
||||||
WHERE w.isManaged
|
WHERE w.isManaged
|
||||||
AND YEAR(t.shipped) = YEAR(util.VN_CURDATE())
|
AND YEAR(t.shipped) = YEAR(util.VN_CURDATE())
|
||||||
AND WEEK(t.shipped, 4) = WEEK(util.VN_CURDATE(), 4)
|
AND WEEK(t.shipped, 4) = WEEK(util.VN_CURDATE(), 4)
|
||||||
GROUP BY it.id, s.itemFk;
|
GROUP BY it.id, i.id;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
Loading…
Reference in New Issue