2021-06-16 11:04:54 +00:00
|
|
|
SELECT
|
|
|
|
t.id,
|
|
|
|
t.ref,
|
|
|
|
t.shipped,
|
|
|
|
t.landed,
|
|
|
|
t.kg,
|
2022-03-28 11:24:26 +00:00
|
|
|
am.id AS agencyModeFk,
|
2021-06-16 11:04:54 +00:00
|
|
|
SUM(b.stickers) AS stickers,
|
|
|
|
CAST(SUM(i.density * b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000 ) as DECIMAL(10,0)) as loadedKg,
|
|
|
|
CAST(SUM(167.5 * b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000 ) as DECIMAL(10,0)) as volumeKg
|
|
|
|
FROM travel t
|
|
|
|
LEFT JOIN supplier s ON s.id = t.cargoSupplierFk
|
|
|
|
LEFT JOIN entry e ON e.travelFk = t.id
|
|
|
|
LEFT JOIN buy b ON b.entryFk = e.id
|
|
|
|
LEFT JOIN packaging pkg ON pkg.id = b.packageFk
|
|
|
|
LEFT JOIN item i ON i.id = b.itemFk
|
|
|
|
LEFT JOIN itemType it ON it.id = i.typeFk
|
|
|
|
JOIN warehouse w ON w.id = t.warehouseInFk
|
|
|
|
JOIN warehouse wo ON wo.id = t.warehouseOutFk
|
|
|
|
JOIN country c ON c.id = wo.countryFk
|
|
|
|
LEFT JOIN continent cnt ON cnt.id = c.continentFk
|
|
|
|
JOIN agencyMode am ON am.id = t.agencyFk
|