salix/db/routines/sage/views/supplierLastThreeMonths.sql

13 lines
502 B
SQL

CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `sage`.`supplierLastThreeMonths`
AS SELECT `vn`.`invoiceIn`.`supplierFk` AS `supplierFk`,
`vn`.`invoiceIn`.`companyFk` AS `companyFk`
FROM `vn`.`invoiceIn`
WHERE `vn`.`invoiceIn`.`issued` > `util`.`VN_CURDATE`() - INTERVAL 3 MONTH
UNION
SELECT `vn`.`payment`.`supplierFk` AS `supplierFk`,
`vn`.`payment`.`companyFk` AS `companyFk`
FROM `vn`.`payment`
WHERE `vn`.`payment`.`received` > `util`.`VN_CURDATE`() + INTERVAL -3 MONTH