2024-01-15 11:31:03 +00:00
|
|
|
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`,
|
2024-01-15 11:31:03 +00:00
|
|
|
`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-02-06 07:21:34 +00:00
|
|
|
JOIN `vn`.`ticketStateToday` `tst` ON(`tst`.`ticketFk` = `t`.`id`)
|
2024-01-15 11:31:03 +00:00
|
|
|
)
|
|
|
|
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
|