From 9003f2db9119a7ad47ada29b8d8b8ef63e431b59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 18 Jul 2024 19:37:03 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20refs=20#7748=20solicitud=20de=20domicili?= =?UTF-8?q?aci=C3=B3n=20bancaria?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/reports/sepa-core/sepa-core.js | 11 ---- .../reports/sepa-core/sql/client.sql | 26 ++++----- .../reports/sepa-core/sql/supplier.sql | 54 +++++++++---------- 3 files changed, 39 insertions(+), 52 deletions(-) diff --git a/print/templates/reports/sepa-core/sepa-core.js b/print/templates/reports/sepa-core/sepa-core.js index 6b941556e..2600b596e 100755 --- a/print/templates/reports/sepa-core/sepa-core.js +++ b/print/templates/reports/sepa-core/sepa-core.js @@ -23,16 +23,5 @@ module.exports = { type: Number, required: true } - }, - methods: { - getSupplierCif() { - return db.findOne(` - SELECT DISTINCT ad.value - FROM supplierAccount sa - JOIN accountDetail ad ON ad.supplierAccountFk = sa.id - JOIN accountDetailType adt ON adt.id = ad.accountDetailTypeFk AND adt.id = 3 - WHERE sa.supplierFk = ?`) [this.companyId]; - } } - }; diff --git a/print/templates/reports/sepa-core/sql/client.sql b/print/templates/reports/sepa-core/sql/client.sql index b3ba180b3..6cdd7403f 100644 --- a/print/templates/reports/sepa-core/sql/client.sql +++ b/print/templates/reports/sepa-core/sql/client.sql @@ -1,19 +1,21 @@ -SELECT - c.id, +SELECT c.id, m.code mandateCode, c.socialName, c.street, c.postcode, c.city, c.fi, - p.name AS province, + p.name province, ct.name country, - ct.code AS countryCode, - ct.ibanLength AS ibanLength -FROM client c - JOIN country ct ON ct.id = c.countryFk - LEFT JOIN mandate m ON m.clientFk = c.id - AND m.companyFk = ? AND m.finished IS NULL - LEFT JOIN province p ON p.id = c.provinceFk -WHERE (m.companyFk = ? OR m.companyFk IS NULL) AND c.id = ? -ORDER BY m.created DESC LIMIT 1 \ No newline at end of file + ct.code countryCode, + ct.ibanLength ibanLength + FROM client c + JOIN country ct ON ct.id = c.countryFk + LEFT JOIN province p ON p.id = c.provinceFk + LEFT JOIN mandate m ON m.clientFk = c.id + AND m.companyFk = ? + AND m.finished IS NULL + WHERE (m.companyFk = ? OR m.companyFk IS NULL) + AND c.id = ? + ORDER BY m.created DESC + LIMIT 1 \ No newline at end of file diff --git a/print/templates/reports/sepa-core/sql/supplier.sql b/print/templates/reports/sepa-core/sql/supplier.sql index 1276f2437..749f2c430 100644 --- a/print/templates/reports/sepa-core/sql/supplier.sql +++ b/print/templates/reports/sepa-core/sql/supplier.sql @@ -1,29 +1,25 @@ -SELECT - m.code mandateCode, - s.name, - s.street, - sc.name country, - s.postCode, - s.city, - sp.name province, - s.nif, - sa.supplierFk, - be.name bankName, - ad.value accountDetailValue -FROM - client c - LEFT JOIN mandate m ON m.clientFk = c.id AND m.companyFk = ? AND m.finished IS NULL - LEFT JOIN supplier s ON s.id = m.companyFk - 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 supplierAccount sa ON sa.supplierFk = s.id - LEFT JOIN bankEntity be ON sa.bankEntityFk = be.id - LEFT JOIN accountDetail ad ON ad.supplierAccountFk = sa.id - JOIN accountDetailType adt ON adt.id = ad.accountDetailTypeFk AND adt.id = 3 -WHERE - (m.companyFk = ? OR m.companyFk IS NULL) - AND (c.id = ? OR (c.id IS NULL AND c.countryFk = sa.countryFk)) -GROUP BY ad.value -ORDER BY -m.created DESC; +SELECT m.code mandateCode, + s.name, + s.street, + sc.name country, + s.postCode, + s.city, + sp.name province, + ad.value accountDetailValue + FROM client c + JOIN mandate m ON m.clientFk = c.id + JOIN mandateType mt ON mt.id = m.mandateTypeFk + JOIN supplier s ON s.id = m.companyFk + LEFT JOIN country sc ON sc.id = s.countryFk + LEFT JOIN province sp ON sp.id = s.provinceFk + JOIN supplierAccount sa ON sa.supplierFk = s.id + JOIN accountDetail ad ON ad.supplierAccountFk = sa.id + JOIN accountDetailType adt ON adt.id = ad.accountDetailTypeFk + WHERE m.companyFk = ? + AND m.finished IS NULL + AND c.id = ? + AND mt.name = 'CORE' + AND adt.description = 'Referencia Remesas' + GROUP BY m.id + ORDER BY m.created DESC + LIMIT 1;