2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost`
|
2024-01-15 11:31:03 +00:00
|
|
|
SQL SECURITY DEFINER
|
|
|
|
VIEW `vn`.`lastPurchases`
|
|
|
|
AS SELECT `tr`.`landed` AS `landed`,
|
|
|
|
`w`.`id` AS `warehouseFk`,
|
|
|
|
`w`.`name` AS `warehouse`,
|
|
|
|
`i`.`longName` AS `longName`,
|
|
|
|
`i`.`subName` AS `subName`,
|
|
|
|
`e`.`id` AS `entryFk`,
|
|
|
|
`b`.`stickers` AS `stickers`,
|
|
|
|
`b`.`packing` AS `packing`,
|
|
|
|
`e`.`invoiceNumber` AS `ref`,
|
|
|
|
`b`.`itemFk` AS `itemFk`,
|
|
|
|
`ek`.`pro` AS `pro`,
|
|
|
|
`ek`.`ref` AS `ektRef`,
|
|
|
|
`ek`.`agj` AS `agj`
|
|
|
|
FROM (
|
|
|
|
(
|
|
|
|
(
|
|
|
|
(
|
|
|
|
(
|
|
|
|
`vn`.`buy` `b`
|
|
|
|
JOIN `vn`.`entry` `e` ON(`e`.`id` = `b`.`entryFk`)
|
|
|
|
)
|
|
|
|
JOIN `vn`.`item` `i` ON(`i`.`id` = `b`.`itemFk`)
|
|
|
|
)
|
|
|
|
JOIN `vn`.`travel` `tr` ON(`tr`.`id` = `e`.`travelFk`)
|
|
|
|
)
|
|
|
|
JOIN `vn`.`warehouse` `w` ON(`w`.`id` = `tr`.`warehouseInFk`)
|
|
|
|
)
|
|
|
|
LEFT JOIN `edi`.`ekt` `ek` ON(`ek`.`id` = `b`.`ektFk`)
|
|
|
|
)
|
|
|
|
WHERE `tr`.`landed` BETWEEN `util`.`yesterday`() AND `util`.`tomorrow`()
|
2024-10-24 10:33:47 +00:00
|
|
|
AND NOT `tr`.`daysInForward`
|
2024-01-15 11:31:03 +00:00
|
|
|
AND `b`.`stickers` > 0
|