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

60 lines
1.8 KiB
MySQL
Raw Normal View History

CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`itemShelvingAvailable`
2024-02-06 07:15:25 +00:00
AS SELECT `s`.`id` `saleFk`,
`tst`.`updated` AS `Modificado`,
`s`.`ticketFk` AS `ticketFk`,
0 AS `isPicked`,
`s`.`itemFk` AS `itemFk`,
`s`.`quantity` AS `quantity`,
`s`.`concept` AS `concept`,
`i`.`size` AS `size`,
`st`.`name` AS `Estado`,
`st`.`sectorProdPriority` AS `sectorProdPriority`,
`stock`.`visible` AS `available`,
`stock`.`sectorFk` AS `sectorFk`,
`stock`.`shelvingFk` AS `matricula`,
`stock`.`parkingFk` AS `parking`,
`stock`.`itemShelvingFk` AS `itemShelving`,
`am`.`name` AS `Agency`,
`t`.`shipped` AS `shipped`,
`stock`.`grouping` AS `grouping`,
`stock`.`packing` AS `packing`,
`z`.`hour` AS `hour`,
`st`.`isPreviousPreparable` AS `isPreviousPreparable`,
`sv`.`physicalVolume` AS `physicalVolume`,
`t`.`warehouseFk` AS `warehouseFk`
FROM (
(
(
(
(
(
(
(
(
`vn`.`sale` `s`
JOIN `vn`.`ticket` `t` ON(`t`.`id` = `s`.`ticketFk`)
)
JOIN `vn`.`agencyMode` `am` ON(`am`.`id` = `t`.`agencyModeFk`)
)
2024-01-25 16:33:54 +00:00
JOIN `vn`.`ticketStateToday` `tst` ON(`tst`.`ticketFk` = `t`.`id`)
)
JOIN `vn`.`state` `st` ON(`st`.`id` = `tst`.`state`)
)
JOIN `vn`.`item` `i` ON(`i`.`id` = `s`.`itemFk`)
)
JOIN `vn`.`itemShelvingStock` `stock` ON(`stock`.`itemFk` = `i`.`id`)
)
LEFT JOIN `vn`.`saleTracking` `stk` ON(`stk`.`saleFk` = `s`.`id`)
)
LEFT JOIN `vn`.`zone` `z` ON(`z`.`id` = `t`.`zoneFk`)
)
LEFT JOIN `vn`.`saleVolume` `sv` ON(`sv`.`saleFk` = `s`.`id`)
)
WHERE `t`.`shipped` BETWEEN `util`.`yesterday`() AND `util`.`dayend`(`util`.`VN_CURDATE`())
AND `stk`.`id` IS NULL
AND `stock`.`visible` > 0
AND `stk`.`saleFk` IS NULL
AND `st`.`isPreviousPreparable` <> 0