2024-07-22 09:52:42 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn-admin`@`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`()
|
|
|
|
AND `e`.`isRaid` = 0
|
|
|
|
AND `b`.`stickers` > 0
|