salix/db/routines/vn/views/awbVolume.sql

32 lines
864 B
MySQL
Raw Normal View History

CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`awbVolume`
2024-01-25 16:33:54 +00:00
AS SELECT `t`.`awbFk` AS `awbFk`,
`b`.`stickers` * `i`.`density` * IF(
`p`.`volume` > 0,
`p`.`volume`,
`p`.`width` * `p`.`depth` * IF(`p`.`height` = 0, `i`.`size` + 10, `p`.`height`)
) / (`vc`.`aerealVolumetricDensity` * 1000) AS `volume`,
`b`.`id` AS `buyFk`
FROM (
(
(
(
(
(
2024-01-25 16:33:54 +00:00
`vn`.`buy` `b`
JOIN `vn`.`item` `i` ON(`b`.`itemFk` = `i`.`id`)
)
2024-01-25 16:33:54 +00:00
JOIN `vn`.`itemType` `it` ON(`i`.`typeFk` = `it`.`id`)
)
2024-01-25 16:33:54 +00:00
JOIN `vn`.`packaging` `p` ON(`p`.`id` = `b`.`packagingFk`)
)
2024-01-25 16:33:54 +00:00
JOIN `vn`.`entry` `e` ON(`b`.`entryFk` = `e`.`id`)
)
2024-01-25 16:33:54 +00:00
JOIN `vn`.`travel` `t` ON(`t`.`id` = `e`.`travelFk`)
)
JOIN `vn`.`volumeConfig` `vc`
)
WHERE `t`.`shipped` > makedate(year(`util`.`VN_CURDATE`()) - 1, 1)
2024-02-15 09:04:15 +00:00
AND `t`.`awbFk` <> 0