Because the sql shown at the end and other similar ones give an error when generating the PDF. And yet they work both in SQL tests in phpMyAdmin and also in development tests and also in Production.
SELECT a.codeler, a.description, SUM(l.quantity)/1000 as tons, (l.price * 1000) as price, SUM(l.amount) as amount FROM invoice l INNER JOIN master_articles a ON l.code = a.articlecode WHERE l.companycode = {f.companycode} AND l.exercisecode = {f.exerciciocode} AND l.factocode = {f.factocode} GROUP BY l.code, l.price ORDER BY a.description