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

18 lines
509 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`.`exchangeInsuranceOut`
AS SELECT `p`.`received` AS `received`,
sum(`p`.`divisa`) AS `divisa`,
sum(`p`.`divisa`) / sum(`p`.`amount`) AS `rate`
FROM (
(
`vn`.`payment` `p`
2024-03-14 07:36:19 +00:00
JOIN `vn`.`accounting` `a` ON(`a`.`id` = `p`.`bankFk`)
)
2024-03-14 07:36:19 +00:00
JOIN `vn`.`accountingType` `at2` ON(`at2`.`id` = `a`.`accountingTypeFk`)
)
WHERE `p`.`currencyFk` = 2
AND `at2`.`code` = 'wireTransfer'
AND `p`.`supplierFk` <> 2213
GROUP BY `p`.`received`