CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`salesPreviousPreparated` AS SELECT `st`.`saleFk` AS `saleFk` FROM ( `vn`.`saleTracking` `st` JOIN `vn`.`state` `e` ON(`e`.`id` = `st`.`stateFk`) ) WHERE `st`.`created` > `util`.`VN_CURDATE`() AND `e`.`code` LIKE 'PREVIOUS_PREPARATION'