37 lines
1003 B
MySQL
37 lines
1003 B
MySQL
|
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||
|
SQL SECURITY DEFINER
|
||
|
VIEW `vn`.`awbVolume`
|
||
|
AS SELECT `d`.`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 (
|
||
|
(
|
||
|
(
|
||
|
(
|
||
|
(
|
||
|
(
|
||
|
(
|
||
|
(
|
||
|
`vn`.`buy` `b`
|
||
|
JOIN `vn`.`item` `i` ON(`b`.`itemFk` = `i`.`id`)
|
||
|
)
|
||
|
JOIN `vn`.`itemType` `it` ON(`i`.`typeFk` = `it`.`id`)
|
||
|
)
|
||
|
JOIN `vn`.`packaging` `p` ON(`p`.`id` = `b`.`packagingFk`)
|
||
|
)
|
||
|
JOIN `vn`.`entry` `e` ON(`b`.`entryFk` = `e`.`id`)
|
||
|
)
|
||
|
JOIN `vn`.`travel` `t` ON(`t`.`id` = `e`.`travelFk`)
|
||
|
)
|
||
|
JOIN `vn`.`duaEntry` `de` ON(`de`.`entryFk` = `e`.`id`)
|
||
|
)
|
||
|
JOIN `vn`.`dua` `d` ON(`d`.`id` = `de`.`duaFk`)
|
||
|
)
|
||
|
JOIN `vn`.`volumeConfig` `vc`
|
||
|
)
|
||
|
WHERE `t`.`shipped` > makedate(year(`util`.`VN_CURDATE`()) - 1, 1)
|