6745-2404_testToMaster #1950

Merged
alexm merged 191 commits from 6745-2404_testToMaster into master 2024-01-25 07:39:13 +00:00
3 changed files with 36 additions and 22 deletions
Showing only changes of commit 556b403a5b - Show all commits

View File

@ -1,10 +1,9 @@
ALTER TABLE `vn`.`company` MODIFY COLUMN `supplierAccountFk` mediumint(8) unsigned DEFAULT NULL NULL COMMENT 'Cuenta por defecto para ingresos desde este pais'; ALTER TABLE `vn`.`company` MODIFY COLUMN `supplierAccountFk` mediumint(8) unsigned DEFAULT NULL NULL COMMENT 'Cuenta por defecto para ingresos desde este pais';
CREATE TABLE `vn`.`supplierAccountI18n` ( ALTER TABLE `vn`.`supplierAccount`
supplierAccountFk mediumint(8) unsigned NOT NULL, ADD COLUMN `countryFk` mediumint(8) unsigned DEFAULT NULL,
countryFk mediumint(8) unsigned NOT NULL, ADD CONSTRAINT `fk_supplierAccount_country`
FOREIGN KEY (supplierAccountFk) REFERENCES supplierAccount(id), FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE;
FOREIGN KEY (countryFk) REFERENCES country(id)
);

View File

@ -7,12 +7,28 @@ module.exports = {
name: 'letter-debtor-st', name: 'letter-debtor-st',
async serverPrefetch() { async serverPrefetch() {
this.debtor = await db.findOne(` this.debtor = await db.findOne(`
SELECT sa.iban, be.name bankName SELECT sa.iban,
FROM supplierAccount sa be.name bankName,
JOIN bankEntity be ON sa.bankEntityFk = be.id sa.countryFk,
JOIN client c ON c.countryFk = sa.countryFk c.countryFk
WHERE c.id = ? OR (c.id IS NULL AND c.countryFk = sa.countryFk);`, FROM supplierAccount sa
[this.id]); JOIN bankEntity be ON sa.bankEntityFk = be.id
LEFT JOIN company co ON co.supplierAccountFk = sa.id
LEFT JOIN client c ON c.countryFk = sa.countryFk
WHERE c.id = ?
ORDER BY co.id DESC
LIMIT 1;
`, [this.id]);
if (!this.debtor.length) {
this.debtor = await db.findOne(`
SELECT sa.iban,
be.name bankName
FROM supplierAccount sa
JOIN bankEntity be ON sa.bankEntityFk = be.id
JOIN company co ON co.supplierAccountFk = sa.id
WHERE co.code = ?;
`, [this.companyCode]);
}
}, },
data() { data() {
return { return {

View File

@ -1,10 +1,9 @@
SELECT SELECT c.dueDay,
c.dueDay, sa.iban,
c.iban, be.name bankName
sa.iban, FROM client c
be.name AS bankName JOIN supplierAccount sa ON sa.id = cny.supplierAccountFk
FROM client c JOIN bankEntity be ON be.id = sa.bankEntityFk
JOIN company AS cny JOIN company cny
JOIN supplierAccount AS sa ON sa.id = cny.supplierAccountFk WHERE c.id = ?
JOIN bankEntity be ON be.id = sa.bankEntityFk AND cny.id = ?
WHERE c.id = ? AND cny.id = ?