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';
CREATE TABLE `vn`.`supplierAccountI18n` (
supplierAccountFk mediumint(8) unsigned NOT NULL,
countryFk mediumint(8) unsigned NOT NULL,
FOREIGN KEY (supplierAccountFk) REFERENCES supplierAccount(id),
FOREIGN KEY (countryFk) REFERENCES country(id)
);
ALTER TABLE `vn`.`supplierAccount`
ADD COLUMN `countryFk` mediumint(8) unsigned DEFAULT NULL,
ADD CONSTRAINT `fk_supplierAccount_country`
FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE;

View File

@ -7,12 +7,28 @@ module.exports = {
name: 'letter-debtor-st',
async serverPrefetch() {
this.debtor = await db.findOne(`
SELECT sa.iban, be.name bankName
SELECT sa.iban,
be.name bankName,
sa.countryFk,
c.countryFk
FROM supplierAccount sa
JOIN bankEntity be ON sa.bankEntityFk = be.id
JOIN client c ON c.countryFk = sa.countryFk
WHERE c.id = ? OR (c.id IS NULL AND c.countryFk = sa.countryFk);`,
[this.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() {
return {

View File

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