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`.`traceabilityBuy`
|
|
|
|
AS SELECT `b`.`id` AS `buyFk`,
|
|
|
|
`b`.`quantity` AS `quantity`,
|
|
|
|
`tr`.`landed` AS `landed`,
|
|
|
|
`w`.`name` AS `warehouseName`,
|
|
|
|
`b`.`entryFk` AS `entryFk`,
|
|
|
|
`s`.`name` AS `supplierName`,
|
|
|
|
IFNULL(`b`.`itemOriginalFk`, `b`.`itemFk`) AS `itemFk`
|
|
|
|
FROM (
|
|
|
|
(
|
|
|
|
(
|
|
|
|
(
|
|
|
|
`vn`.`buy` `b`
|
|
|
|
JOIN `vn`.`entry` `e` ON(`e`.`id` = `b`.`entryFk`)
|
|
|
|
)
|
|
|
|
JOIN `vn`.`travel` `tr` ON(`tr`.`id` = `e`.`travelFk`)
|
|
|
|
)
|
|
|
|
JOIN `vn`.`supplier` `s` ON(`s`.`id` = `e`.`supplierFk`)
|
|
|
|
)
|
|
|
|
JOIN `vn`.`warehouse` `w` ON(`w`.`id` = `tr`.`warehouseInFk`)
|
|
|
|
)
|