refs #5525 fixear sql, fixtures, js

This commit is contained in:
Carlos Satorres 2024-07-04 16:50:54 +02:00
parent fcec3bc0ae
commit cf621071d0
4 changed files with 33 additions and 14 deletions

View File

@ -3884,3 +3884,18 @@ INSERT INTO `vn`.`calendarHolidays` (calendarHolidaysTypeFk, dated, calendarHoli
(1, '2001-05-17', 1, 5), (1, '2001-05-17', 1, 5),
(1, '2001-05-18', 1, 5); (1, '2001-05-18', 1, 5);
INSERT INTO vn.accountDetail
(id, value, accountDetailTypeFk, supplierAccountFk)
VALUES
(21, 'ES12345B12345678', 3, 241),
(35, 'ES12346B12345679', 3, 241);
INSERT INTO vn.accountDetailType
(id, description)
VALUES
(1, 'IBAN'),
(2, 'SWIFT'),
(3, 'Referencia Remesas'),
(4, 'Referencia Transferencias'),
(5, 'Referencia Nominas'),
(6, 'ABA');

View File

@ -27,8 +27,7 @@
<tr> <tr>
<td>{{$t('supplier.identifier')}}</td> <td>{{$t('supplier.identifier')}}</td>
<th> <th>
<div>{{supplier.iban}}</div> <div>{{supplier.accountDetailValue.join(', ')}}</div>
<div>{{supplier.nif}}</div>
</th> </th>
</tr> </tr>
<tr> <tr>

View File

@ -7,7 +7,11 @@ module.exports = {
async serverPrefetch() { async serverPrefetch() {
this.client = await this.findOneFromDef('client', [this.companyId, this.companyId, this.id]); this.client = await this.findOneFromDef('client', [this.companyId, this.companyId, this.id]);
this.checkMainEntity(this.client); this.checkMainEntity(this.client);
this.supplier = await this.findOneFromDef('supplier', [this.companyId, this.companyId, this.id]); const suppliers = await this.rawSqlFromDef('supplier', [this.companyId, this.companyId, this.id]);
this.supplier = {
...suppliers[0],
accountDetailValue: suppliers.map(val => val?.accountDetailValue)
};
}, },
props: { props: {
id: { id: {
@ -23,12 +27,11 @@ module.exports = {
methods: { methods: {
getSupplierCif() { getSupplierCif() {
return db.findOne(` return db.findOne(`
SELECT sa.iban, s.nif SELECT DISTINCT ad.value
FROM supplierAccount sa FROM supplierAccount sa
JOIN company co ON co.supplierAccountFk = sa.id JOIN accountDetail ad ON ad.supplierAccountFk = sa.id
JOIN supplier s ON sa.supplierFk = s.id JOIN accountDetailType adt ON adt.id = ad.accountDetailTypeFk AND adt.id = 3
WHERE co.id = ? WHERE sa.supplierFk = ?`) [this.companyId];
AND ad.accountDetailTypeFk = 3`) [this.companyId];
} }
} }

View File

@ -1,15 +1,16 @@
SELECT SELECT
m.code mandateCode, m.code AS mandateCode,
s.name, s.name,
s.street, s.street,
sc.name country, sc.name AS country,
s.postCode, s.postCode,
s.city, s.city,
sp.name province, sp.name AS province,
s.nif, s.nif,
sa.iban, sa.iban,
sa.supplierFk, sa.supplierFk,
be.name bankName be.name AS bankName,
ad.value AS accountDetailValue
FROM FROM
client c client c
LEFT JOIN mandate m ON m.clientFk = c.id AND m.companyFk = ? AND m.finished IS NULL LEFT JOIN mandate m ON m.clientFk = c.id AND m.companyFk = ? AND m.finished IS NULL
@ -19,9 +20,10 @@ FROM
LEFT JOIN province p ON p.id = c.provinceFk LEFT JOIN province p ON p.id = c.provinceFk
LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id
LEFT JOIN bankEntity be ON sa.bankEntityFk = be.id LEFT JOIN bankEntity be ON sa.bankEntityFk = be.id
LEFT JOIN accountDetail ad ON ad.supplierAccountFk = sa.id
LEFT JOIN accountDetailType adt ON adt.id = ad.accountDetailTypeFk AND adt.id = 3
WHERE WHERE
(m.companyFk = ? OR m.companyFk IS NULL) (m.companyFk = ? OR m.companyFk IS NULL)
AND (c.id = ? OR (c.id IS NULL AND c.countryFk = sa.countryFk)) AND (c.id = ? OR (c.id IS NULL AND c.countryFk = sa.countryFk))
ORDER BY ORDER BY
m.created DESC m.created DESC;
LIMIT 1;