From bbf1bb50e978318cb9ea2b8f9692615c49cb5055 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 28 Dec 2023 13:27:38 +0100 Subject: [PATCH] refs #5525 fix sql supplier for sepacore --- print/templates/reports/sepa-core/sql/supplier.sql | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/print/templates/reports/sepa-core/sql/supplier.sql b/print/templates/reports/sepa-core/sql/supplier.sql index 72f950213..ade4b048e 100644 --- a/print/templates/reports/sepa-core/sql/supplier.sql +++ b/print/templates/reports/sepa-core/sql/supplier.sql @@ -17,9 +17,11 @@ FROM LEFT JOIN country sc ON sc.id = s.countryFk LEFT JOIN province sp ON sp.id = s.provinceFk LEFT JOIN province p ON p.id = c.provinceFk - LEFT JOIN bankEntity be ON sa.supplierFk = s.id - LEFT JOIN supplierAccount sa ON sa.bankEntityFk = be.id - WHERE (m.companyFk = ? OR m.companyFk IS NULL) AND c.id = ? OR (c.id IS NULL AND c.countryFk = sa.countryFk) - ORDER BY - m.created DESC - LIMIT 1; + LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id + LEFT JOIN bankEntity be ON sa.bankEntityFk = be.id +WHERE + (m.companyFk = ? OR m.companyFk IS NULL) + AND (c.id = ? OR (c.id IS NULL AND c.countryFk = sa.countryFk)) +ORDER BY + m.created DESC +LIMIT 1;