CREATE OR REPLACE DEFINER=`vn`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn`.`ticketPackingList`
AS SELECT `t`.`nickname` AS `nickname`,
	`t`.`id` AS `ticketFk`,
	`am`.`name` AS `agencyMode`,
	`am`.`flag` AS `flag`,
	`p`.`name` AS `province`,
	`s`.`itemFk` AS `itemFk`,
	`s`.`concept` AS `concept`,
	`s`.`quantity` AS `quantity`,
	`sv`.`litros` AS `litros`,
	`to`.`description` AS `observaciones`
FROM (
		(
			(
				(
					(
						(
							(
								`vn`.`ticket` `t`
								JOIN `vn`.`address` `a` ON(`a`.`id` = `t`.`addressFk`)
							)
							JOIN `vn`.`province` `p` ON(`p`.`id` = `a`.`provinceFk`)
						)
						JOIN `vn`.`agencyMode` `am` ON(`am`.`id` = `t`.`agencyModeFk`)
					)
					LEFT JOIN `vn`.`sale` `s` ON(`s`.`ticketFk` = `t`.`id`)
				)
				LEFT JOIN `vn`.`saleVolume` `sv` ON(`sv`.`saleFk` = `s`.`id`)
			)
			JOIN `vn`.`observationType` `ot` ON(`ot`.`code` = 'packager')
		)
		LEFT JOIN `vn`.`ticketObservation` `to` ON(
			`to`.`ticketFk` = `t`.`id`
			AND `ot`.`id` = `to`.`observationTypeFk`
		)
	)
