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

48 lines
1.6 KiB
MySQL
Raw Normal View History

CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`ticketeToPreparePrepared`
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`,
HOUR(`t`.`shipped`) 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`.`CodigoTrabajador` AS `trabajador`,
`is`.`sectorFk` AS `sectorFk`
FROM (
(
(
(
(
(
(
(
`vn2008`.`Movimientos_mark` `mk`
JOIN `vn`.`state` `st` ON(`st`.`id` = `mk`.`stateFk`)
)
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`.`itemShelvingSaleSum` `is` ON(`is`.`saleFk` = `mk`.`Id_Movimiento`)
)
JOIN `vn2008`.`Articles` `art` ON(`art`.`Id_Article` = `m`.`Id_Article`)
)
LEFT JOIN `vn2008`.`Trabajadores` `t` ON(`t`.`Id_Trabajador` = `mk`.`Id_Trabajador`)
)
WHERE `st`.`code` LIKE 'PREVIOUS_PREPARATION'