From 540c76005e3f9573f6ab9647b8e958b4aa70bb1a Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 23 Jan 2024 12:30:04 +0100 Subject: [PATCH] fix: #6742 calcula hasIncoterm a partir de la serie --- .../reports/invoice-incoterms/sql/incoterms.sql | 2 +- .../templates/reports/invoice/sql/hasIncoterms.sql | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/print/templates/reports/invoice-incoterms/sql/incoterms.sql b/print/templates/reports/invoice-incoterms/sql/incoterms.sql index b36f50084..81c0ec189 100644 --- a/print/templates/reports/invoice-incoterms/sql/incoterms.sql +++ b/print/templates/reports/invoice-incoterms/sql/incoterms.sql @@ -15,7 +15,7 @@ SELECT pack.packages, LEFT JOIN vn.province p ON p.id = c.provinceFk JOIN vn.ticket t ON t.refFk = io.ref JOIN vn.address a ON a.id = t.addressFk - LEFT JOIN vn.incoterms ic ON ic.code = a.incotermsFk + JOIN vn.incoterms ic ON ic.code = a.incotermsFk LEFT JOIN vn.customsAgent ca ON ca.id = a.customsAgentFk JOIN vn.sale s ON s.ticketFk = t.id JOIN ( diff --git a/print/templates/reports/invoice/sql/hasIncoterms.sql b/print/templates/reports/invoice/sql/hasIncoterms.sql index 40a6db384..176fb30a6 100644 --- a/print/templates/reports/invoice/sql/hasIncoterms.sql +++ b/print/templates/reports/invoice/sql/hasIncoterms.sql @@ -1,8 +1,5 @@ -SELECT IF(incotermsFk IS NULL, FALSE, TRUE) AS hasIncoterms - FROM ticket t - JOIN invoiceOut io ON io.ref = t.refFk - JOIN client c ON c.id = t.clientFk - JOIN address a ON a.id = t.addressFk - WHERE t.refFk = ? - AND IF(c.hasToinvoiceByAddress = FALSE, c.defaultAddressFk, TRUE) - LIMIT 1 \ No newline at end of file +SELECT COUNT(*) AS hasIncoterms + FROM invoiceOut io + JOIN vn.invoiceOutSerial ios ON ios.code = io.serial + AND ios.taxAreaFk = 'WORLD' + WHERE io.ref = ?