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

30 lines
869 B
MySQL
Raw Normal View History

2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`saleMistakeList`
AS SELECT `st`.`saleFk` AS `saleFk`,
`st`.`workerFk` AS `workerFk`,
concat(`w2`.`firstName`, ' ', `w2`.`lastName`) AS `sacador`,
`st`.`created` AS `created`,
concat(`w`.`firstName`, ' ', `w`.`lastName`) AS `revisador`,
`mt`.`description` AS `description`,
`sm`.`created` AS `controlled`
FROM (
(
(
(
(
`vn`.`saleTracking` `st`
JOIN `vn`.`worker` `w2` ON(`w2`.`id` = `st`.`workerFk`)
)
JOIN `vn`.`state` `s` ON(
`s`.`id` = `st`.`stateFk`
AND `s`.`code` IN ('PREVIOUS_PREPARATION', 'PREPARED', 'OK')
)
)
LEFT JOIN `vn`.`saleMistake` `sm` ON(`st`.`saleFk` = `sm`.`saleFk`)
)
LEFT JOIN `vn`.`mistakeType` `mt` ON(`mt`.`id` = `sm`.`typeFk`)
)
LEFT JOIN `vn`.`worker` `w` ON(`w`.`id` = `sm`.`userFk`)
)