2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost`
|
2024-01-15 11:31:03 +00:00
|
|
|
SQL SECURITY DEFINER
|
|
|
|
VIEW `vn`.`awbVolume`
|
2024-01-25 16:33:54 +00:00
|
|
|
AS SELECT `t`.`awbFk` AS `awbFk`,
|
2024-01-15 11:31:03 +00:00
|
|
|
`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-15 11:31:03 +00:00
|
|
|
)
|
2024-01-25 16:33:54 +00:00
|
|
|
JOIN `vn`.`itemType` `it` ON(`i`.`typeFk` = `it`.`id`)
|
2024-01-15 11:31:03 +00:00
|
|
|
)
|
2024-01-25 16:33:54 +00:00
|
|
|
JOIN `vn`.`packaging` `p` ON(`p`.`id` = `b`.`packagingFk`)
|
2024-01-15 11:31:03 +00:00
|
|
|
)
|
2024-01-25 16:33:54 +00:00
|
|
|
JOIN `vn`.`entry` `e` ON(`b`.`entryFk` = `e`.`id`)
|
2024-01-15 11:31:03 +00:00
|
|
|
)
|
2024-01-25 16:33:54 +00:00
|
|
|
JOIN `vn`.`travel` `t` ON(`t`.`id` = `e`.`travelFk`)
|
2024-01-15 11:31:03 +00:00
|
|
|
)
|
|
|
|
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
|