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-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>
<td>{{$t('supplier.identifier')}}</td>
<th>
<div>{{supplier.iban}}</div>
<div>{{supplier.nif}}</div>
<div>{{supplier.accountDetailValue.join(', ')}}</div>
</th>
</tr>
<tr>

View File

@ -7,7 +7,11 @@ module.exports = {
async serverPrefetch() {
this.client = await this.findOneFromDef('client', [this.companyId, this.companyId, this.id]);
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: {
id: {
@ -23,12 +27,11 @@ module.exports = {
methods: {
getSupplierCif() {
return db.findOne(`
SELECT sa.iban, s.nif
SELECT DISTINCT ad.value
FROM supplierAccount sa
JOIN company co ON co.supplierAccountFk = sa.id
JOIN supplier s ON sa.supplierFk = s.id
WHERE co.id = ?
AND ad.accountDetailTypeFk = 3`) [this.companyId];
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,15 +1,16 @@
SELECT
m.code mandateCode,
m.code AS mandateCode,
s.name,
s.street,
sc.name country,
sc.name AS country,
s.postCode,
s.city,
sp.name province,
sp.name AS province,
s.nif,
sa.iban,
sa.supplierFk,
be.name bankName
be.name AS bankName,
ad.value AS accountDetailValue
FROM
client c
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 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
LEFT 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))
ORDER BY
m.created DESC
LIMIT 1;
m.created DESC;