salix/db/changes/10141-zoneDoCalc/03-viewSaleFreight__.sql

25 lines
939 B
MySQL
Raw Normal View History

2020-02-17 11:01:11 +00:00
DROP VIEW IF EXISTS `vn`.`saleFreight` ;
USE `vn`;
CREATE
OR REPLACE ALGORITHM = UNDEFINED
DEFINER = `root`@`%`
SQL SECURITY DEFINER
VIEW `saleFreight__` AS
SELECT
`s`.`ticketFk` AS `ticketFk`,
`t`.`clientFk` AS `clientFk`,
`t`.`routeFk` AS `routeFk`,
`s`.`id` AS `saleFk`,
`t`.`zoneFk` AS `zoneFk`,
`t`.`companyFk` AS `companyFk`,
`t`.`shipped` AS `shipped`,
`t`.`zonePrice` AS `price`,
((((`s`.`quantity` * `r`.`cm3`) * `t`.`zonePrice`) * `i`.`compression`) / `cb`.`volume`) AS `freight`
FROM
((((`vn`.`sale` `s`
JOIN `vn`.`item` `i` ON ((`i`.`id` = `s`.`itemFk`)))
JOIN `vn`.`ticket` `t` ON ((`t`.`id` = `s`.`ticketFk`)))
JOIN `vn`.`packaging` `cb` ON ((`cb`.`id` = '94')))
JOIN `bi`.`rotacion` `r` ON (((`r`.`Id_Article` = `s`.`itemFk`)
AND (`r`.`warehouse_id` = `t`.`warehouseFk`))));