59 lines
1.8 KiB
SQL
59 lines
1.8 KiB
SQL
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
SQL SECURITY DEFINER
|
|
VIEW `vn`.`ticketToPrepare`
|
|
AS SELECT `m`.`Id_Ticket` AS `Id_Ticket`,
|
|
`mk`.`Id_Movimiento` AS `Id_Movimiento`,
|
|
`mk`.`Id_Movimiento_mark` AS `Id_Movimiento_mark`,
|
|
`mk`.`Id_Trabajador` AS `Id_Trabjador`,
|
|
`m`.`Id_Article` AS `Id_Article`,
|
|
`m`.`Concepte` AS `Concepte`,
|
|
`art`.`subName` AS `subName`,
|
|
`mk`.`original_quantity` - IFNULL(`is`.`quantity`, 0) AS `Cantidad`,
|
|
`mk`.`original_quantity` AS `original_quantity`,
|
|
IF(
|
|
HOUR(`t`.`shipped`),
|
|
HOUR(`t`.`shipped`),
|
|
HOUR(`z`.`hour`)
|
|
) AS `Hora`,
|
|
HOUR(`t`.`shipped`) AS `Departure`,
|
|
MINUTE(`t`.`shipped`) AS `Minuto`,
|
|
`am`.`agencyFk` AS `agency_id`,
|
|
`t`.`warehouseFk` AS `warehouse_id`,
|
|
`a`.`provinceFk` AS `province_id`,
|
|
`is`.`quantity` AS `picked`,
|
|
`t`.`zoneFk` AS `zoneFk`,
|
|
`p`.`sectorFk` AS `sectorFk`
|
|
FROM (
|
|
(
|
|
(
|
|
(
|
|
(
|
|
(
|
|
(
|
|
(
|
|
(
|
|
(
|
|
`vn2008`.`Movimientos_mark` `mk`
|
|
JOIN `vn2008`.`Movimientos` `m` ON(`m`.`Id_Movimiento` = `mk`.`Id_Movimiento`)
|
|
)
|
|
JOIN `vn`.`ticket` `t` ON(`m`.`Id_Ticket` = `t`.`id`)
|
|
)
|
|
JOIN `vn`.`agencyMode` `am` ON(`am`.`id` = `t`.`agencyModeFk`)
|
|
)
|
|
JOIN `vn`.`address` `a` ON(`a`.`id` = `t`.`addressFk`)
|
|
)
|
|
LEFT JOIN `vn`.`itemShelvingSale` `is` ON(`is`.`saleFk` = `mk`.`Id_Movimiento`)
|
|
)
|
|
LEFT JOIN `vn`.`itemShelving` `ish` ON(`ish`.`id` = `is`.`itemShelvingFk`)
|
|
)
|
|
LEFT JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`)
|
|
)
|
|
LEFT JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`)
|
|
)
|
|
LEFT JOIN `vn2008`.`Articles` `art` ON(`art`.`Id_Article` = `m`.`Id_Article`)
|
|
)
|
|
LEFT JOIN `vn`.`zone` `z` ON(`z`.`id` = `t`.`zoneFk`)
|
|
)
|
|
WHERE `mk`.`stateFk` = 26
|
|
AND `mk`.`valor` <> 1
|