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`.`ticketNotInvoiced`
|
|
|
|
AS SELECT `t`.`companyFk` AS `companyFk`,
|
|
|
|
`cm`.`code` AS `companyCode`,
|
|
|
|
`t`.`clientFk` AS `clientFk`,
|
|
|
|
`c`.`name` AS `clientName`,
|
|
|
|
`t`.`shipped` AS `shipped`,
|
|
|
|
cast(
|
|
|
|
sum(
|
|
|
|
`s`.`quantity` * `s`.`price` * (100 - `s`.`discount`) / 100
|
|
|
|
) AS decimal(10, 2)
|
|
|
|
) AS `value`
|
|
|
|
FROM (
|
|
|
|
(
|
|
|
|
(
|
|
|
|
`vn`.`ticket` `t`
|
|
|
|
JOIN `vn`.`sale` `s` ON(`s`.`ticketFk` = `t`.`id`)
|
|
|
|
)
|
|
|
|
JOIN `vn`.`client` `c` ON(`c`.`id` = `t`.`clientFk`)
|
|
|
|
)
|
|
|
|
JOIN `vn`.`company` `cm` ON(`cm`.`id` = `t`.`companyFk`)
|
|
|
|
)
|
|
|
|
WHERE `t`.`refFk` IS NULL
|
|
|
|
AND `t`.`shipped` > '2017-01-01'
|
|
|
|
GROUP BY `t`.`id`
|