fix: refs #7748 solicitud de domiciliación bancaria
gitea/salix/pipeline/pr-master This commit looks good Details

This commit is contained in:
Carlos Andrés 2024-07-18 19:37:03 +02:00
parent 29e7d97878
commit 9003f2db91
3 changed files with 39 additions and 52 deletions

View File

@ -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];
}
}
};

View File

@ -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
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

View File

@ -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;