7806_devToTest_2332 #2801
|
@ -11,22 +11,14 @@ BEGIN
|
||||||
SUM((b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity) value,
|
SUM((b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity) value,
|
||||||
SUM (
|
SUM (
|
||||||
IF(
|
IF(
|
||||||
a.nickname IN (
|
aw.type = 'internal',
|
||||||
'MERMA: FALTAS',
|
|
||||||
'MERMA: CONTENEDOR',
|
|
||||||
'MERMA: TRANSPORTE/OTROS'
|
|
||||||
),
|
|
||||||
(b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
|
(b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
) internalWaste,
|
) internalWaste,
|
||||||
SUM (
|
SUM (
|
||||||
IF(
|
IF(
|
||||||
a.nickname IN (
|
aw.type = 'external',
|
||||||
'MERMA: RECLAMACION BASURA',
|
|
||||||
'MERMA: RECLAMACION TALLER',
|
|
||||||
'MERMA: RECLAMACION FALTAS'
|
|
||||||
),
|
|
||||||
(b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
|
(b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
|
||||||
IF(c.code = 'manaClaim',
|
IF(c.code = 'manaClaim',
|
||||||
sc.value * s.quantity,
|
sc.value * s.quantity,
|
||||||
|
@ -39,6 +31,7 @@ BEGIN
|
||||||
JOIN vn.itemType it ON it.id = i.typeFk
|
JOIN vn.itemType it ON it.id = i.typeFk
|
||||||
JOIN vn.ticket t ON t.id = s.ticketFk
|
JOIN vn.ticket t ON t.id = s.ticketFk
|
||||||
STRAIGHT_JOIN vn.address a ON a.id = t.addressFk
|
STRAIGHT_JOIN vn.address a ON a.id = t.addressFk
|
||||||
|
LEFT JOIN vn.addressWaste aw ON aw.addressFk = a.id
|
||||||
JOIN vn.warehouse w ON w.id = t.warehouseFk
|
JOIN vn.warehouse w ON w.id = t.warehouseFk
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue