CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn`.`expeditionCommon`
AS SELECT `et`.`id` AS `truckFk`,
	`et`.`eta` AS `eta`,
	IFNULL(ucase(`et`.`description`), 'SIN ESCANEAR') AS `description`,
	`es`.`palletFk` AS `palletFk`,
	`t`.`routeFk` AS `routeFk`,
	`es`.`id` AS `scanFk`,
	`e`.`id` AS `expeditionFk`,
	`r`.`expeditionTruckFk` AS `expeditionTruckFk`,
	`t`.`warehouseFk` AS `warehouseFk`,
	`e`.`created` AS `lastPacked`,
	`t`.`id` AS `ticketFk`
FROM (
		(
			(
				(
					(
						`vn`.`expeditionTruck` `et`
						LEFT JOIN `vn`.`routesMonitor` `r` ON(`et`.`id` = `r`.`expeditionTruckFk`)
					)
					LEFT JOIN `vn`.`ticket` `t` ON(`r`.`routeFk` = `t`.`routeFk`)
				)
				LEFT JOIN `vn`.`expedition` `e` ON(`t`.`id` = `e`.`ticketFk`)
			)
			LEFT JOIN `vn`.`expeditionScan` `es` ON(`e`.`id` = `es`.`expeditionFk`)
		)
		LEFT JOIN `vn`.`expeditionPallet` `ep` ON(`es`.`palletFk` = `ep`.`id`)
	)
WHERE `et`.`eta` >= `util`.`VN_CURDATE`()
