CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`supplierPackaging` AS SELECT `e`.`supplierFk` AS `supplierFk`, `b`.`itemFk` AS `itemFk`, `i`.`longName` AS `longName`, `s`.`name` AS `supplier`, `b`.`entryFk` AS `entryFk`, `tr`.`landed` AS `landed`, - least(`b`.`quantity`, 0) AS `out`, greatest(`b`.`quantity`, 0) AS `in`, `w`.`name` AS `warehouse`, `b`.`buyingValue` AS `buyingValue` FROM ( ( ( ( ( ( `vn`.`buy` `b` JOIN `vn`.`item` `i` ON(`i`.`id` = `b`.`itemFk`) ) JOIN `vn`.`packaging` `p` ON(`p`.`itemFk` = `i`.`id`) ) JOIN `vn`.`entry` `e` ON(`e`.`id` = `b`.`entryFk`) ) JOIN `vn`.`supplier` `s` ON(`s`.`id` = `e`.`supplierFk`) ) JOIN `vn`.`travel` `tr` ON(`tr`.`id` = `e`.`travelFk`) ) JOIN `vn`.`warehouse` `w` ON(`w`.`id` = `tr`.`warehouseInFk`) ) WHERE `p`.`isPackageReturnable` <> 0