From 7b1362a9d5ad1c3613906d9283969ac628ed5d66 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 21 Oct 2024 14:50:53 +0200 Subject: [PATCH] feat: refs #7731 modificar columna --- .../vn/procedures/invoiceIn_booking.sql | 4 +- .../11303-salmonMoss/00-firstScript.sql | 123 ++++++++++++++++++ .../back/methods/client/extendedListFilter.js | 2 +- modules/client/back/models/client.js | 2 +- .../back/methods/supplier/updateFiscalData.js | 8 +- modules/supplier/back/models/supplier.js | 2 +- modules/supplier/back/models/supplier.json | 5 +- modules/ticket/back/methods/ticket/closure.js | 2 +- 8 files changed, 139 insertions(+), 9 deletions(-) diff --git a/db/routines/vn/procedures/invoiceIn_booking.sql b/db/routines/vn/procedures/invoiceIn_booking.sql index 36189afcc..a7f576c02 100644 --- a/db/routines/vn/procedures/invoiceIn_booking.sql +++ b/db/routines/vn/procedures/invoiceIn_booking.sql @@ -50,7 +50,7 @@ BEGIN s.account supplierAccount, s.name supplierName, s.nif, - s.IsVies, + s.viesCode, iit.taxTypeSageFk, tt.code taxCode, ti.Iva, @@ -281,7 +281,7 @@ BEGIN JOIN sage.config c WHERE tii.taxCode = 'ISP21' OR MID(tii.supplierAccount, 4, 1) = '1' AND tii.taxTypeSageFk IS NOT NULL - AND NOT(tii.isVies + AND NOT(tii.viesCode AND c.nontaxableTransactionTypeFk = tii.transactionTypeSageFk AND tii.taxCode = 'nonTaxable') GROUP BY tii.PorcentajeIva, tii.expenseFk; diff --git a/db/versions/11303-salmonMoss/00-firstScript.sql b/db/versions/11303-salmonMoss/00-firstScript.sql index 71cdf0304..6bbfcaa2e 100644 --- a/db/versions/11303-salmonMoss/00-firstScript.sql +++ b/db/versions/11303-salmonMoss/00-firstScript.sql @@ -2,6 +2,9 @@ use vn; ALTER TABLE vn.client ADD COLUMN IF NOT EXISTS viesCode varchar(2) DEFAULT NULL; +ALTER TABLE vn.supplier + ADD COLUMN IF NOT EXISTS viesCode varchar(2) DEFAULT NULL; + UPDATE vn.client c JOIN country c2 ON c2.id = c.countryFk SET c.viesCode = 'ES' @@ -86,3 +89,123 @@ UPDATE client c JOIN country c2 ON c2.id = c.countryFk SET c.viesCode = 'HU' WHERE c2.name = 'Hungria'; + +UPDATE supplier s + JOIN country c ON c.id = s.countryFk +SET c.viesCode = 'DE' +WHERE c.name = 'Alemania'; + +UPDATE supplier s + JOIN country c ON c.id = s.countryFk +SET c.viesCode = 'AT' +WHERE c.name = 'Austria'; + +UPDATE supplier s + JOIN country c ON c.id = s.countryFk +SET c.viesCode = 'BE' +WHERE c.name = 'Belgica'; + +UPDATE supplier s + JOIN country c ON c.id = s.countryFk +SET c.viesCode = 'BG' +WHERE c.name = 'Bulgaria'; + +UPDATE supplier s + JOIN country c ON c.id = s.countryFk +SET c.viesCode = 'CZ' +WHERE c.name = 'Chequia'; + +UPDATE supplier s + JOIN country c ON c.id = s.countryFk +SET c.viesCode = 'CY' +WHERE c.name = 'Chipre'; + +UPDATE supplier s + JOIN country c ON c.id = s.countryFk +SET c.viesCode = 'DK' +WHERE c.name = 'Dinamarca'; + +UPDATE supplier s + JOIN country c ON c.id = s.countryFk +SET c.viesCode = 'SK' +WHERE c.name = 'Eslovaquia'; + +UPDATE supplier s + JOIN country c ON c.id = s.countryFk +SET c.viesCode = 'SI' +WHERE c.name = 'Eslovenia'; + +UPDATE supplier s + JOIN country c ON c.id = s.countryFk +SET c.viesCode = 'ES' +WHERE c.name = 'España'; + +UPDATE supplier s + JOIN country c ON c.id = s.countryFk +SET c.viesCode = 'FI' +WHERE c.name = 'Finlandia'; + +UPDATE supplier s + JOIN country c ON c.id = s.countryFk +SET c.viesCode = 'FR' +WHERE c.name = 'Francia'; + +UPDATE supplier s + JOIN country c ON c.id = s.countryFk +SET c.viesCode = 'GB' +WHERE c.name = 'Gran Bretaña'; + +UPDATE supplier s + JOIN country c ON c.id = s.countryFk +SET c.viesCode = 'NL' +WHERE c.name = 'Holanda'; + +UPDATE supplier s + JOIN country c ON c.id = s.countryFk +SET c.viesCode = 'IE' +WHERE c.name = 'Irlanda'; + +UPDATE supplier s + JOIN country c ON c.id = s.countryFk +SET c.viesCode = 'IT' +WHERE c.name = 'Italia'; + +UPDATE supplier s + JOIN country c ON c.id = s.countryFk +SET c.viesCode = 'LV' +WHERE c.name = 'Letonia'; + +UPDATE supplier s + JOIN country c ON c.id = s.countryFk +SET c.viesCode = 'LT' +WHERE c.name = 'Lituania'; + +UPDATE supplier s + JOIN country c ON c.id = s.countryFk +SET c.viesCode = 'LU' +WHERE c.name = 'Luxemburgo'; + +UPDATE supplier s + JOIN country c ON c.id = s.countryFk +SET c.viesCode = 'NO' +WHERE c.name = 'Noruega'; + +UPDATE supplier s + JOIN country c ON c.id = s.countryFk +SET c.viesCode = 'PL' +WHERE c.name = 'Polonia'; + +UPDATE supplier s + JOIN country c ON c.id = s.countryFk +SET c.viesCode = 'PT' +WHERE c.name = 'Portugal'; + +UPDATE supplier s + JOIN country c ON c.id = s.countryFk +SET c.viesCode = 'SE' +WHERE c.name = 'Suecia'; + +UPDATE supplier s + JOIN country c ON c.id = s.countryFk +SET c.viesCode = 'CH' +WHERE c.name = 'Suiza'; \ No newline at end of file diff --git a/modules/client/back/methods/client/extendedListFilter.js b/modules/client/back/methods/client/extendedListFilter.js index 174970a2f..97946048a 100644 --- a/modules/client/back/methods/client/extendedListFilter.js +++ b/modules/client/back/methods/client/extendedListFilter.js @@ -112,7 +112,7 @@ module.exports = Self => { c.email, c.created, c.isActive, - c.isVies, + c.viesCode, c.isTaxDataChecked, c.isEqualizated, c.isFreezed, diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index dc19c5d81..03c7a80c3 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -121,7 +121,7 @@ module.exports = Self => { const code = country ? country.code.toLowerCase() : null; const countryCode = this.fi?.toLowerCase().substring(0, 2); - if (!this.fi || !validateTin(this.fi, code) || (this.isVies && countryCode == code)) + if (!this.fi || !validateTin(this.fi, code) || (this.viesCode && countryCode == code)) err(); done(); } diff --git a/modules/supplier/back/methods/supplier/updateFiscalData.js b/modules/supplier/back/methods/supplier/updateFiscalData.js index f2cdd63be..56e5e8376 100644 --- a/modules/supplier/back/methods/supplier/updateFiscalData.js +++ b/modules/supplier/back/methods/supplier/updateFiscalData.js @@ -56,6 +56,9 @@ module.exports = Self => { }, { arg: 'isTrucker', type: 'boolean' + }, { + arg: 'viesCode', + type: 'any' }], returns: { arg: 'res', @@ -68,7 +71,7 @@ module.exports = Self => { } }); - Self.updateFiscalData = async(ctx, supplierId, name, nif, account, phone, sageTaxTypeFk, sageWithholdingFk, sageTransactionTypeFk, postCode, street, city, provinceFk, countryFk, supplierActivityFk, healthRegister, isVies, isTrucker, options) => { + Self.updateFiscalData = async(ctx, supplierId, name, nif, account, phone, sageTaxTypeFk, sageWithholdingFk, sageTransactionTypeFk, postCode, street, city, provinceFk, countryFk, supplierActivityFk, healthRegister, isVies, isTrucker, viesCode, options) => { const models = Self.app.models; const {args} = ctx; const myOptions = {}; @@ -103,7 +106,8 @@ module.exports = Self => { supplierActivityFk, healthRegister, isVies, - isTrucker + isTrucker, + viesCode }, myOptions); }; }; diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js index 7e6908d57..16bc45a80 100644 --- a/modules/supplier/back/models/supplier.js +++ b/modules/supplier/back/models/supplier.js @@ -73,7 +73,7 @@ module.exports = Self => { const code = country ? country.code.toLowerCase() : null; const countryCode = this.nif?.toLowerCase().substring(0, 2); - if (!validateTin(this.nif, code) || (this.isVies && countryCode == code)) + if (!validateTin(this.nif, code) || (this.viesCode && countryCode == code)) err(); done(); } diff --git a/modules/supplier/back/models/supplier.json b/modules/supplier/back/models/supplier.json index 90b266ba9..0fb202400 100644 --- a/modules/supplier/back/models/supplier.json +++ b/modules/supplier/back/models/supplier.json @@ -113,7 +113,10 @@ }, "isVies": { "type": "boolean" - } + }, + "viesCode": { + "type": "string" + } }, "relations": { "payMethod": { diff --git a/modules/ticket/back/methods/ticket/closure.js b/modules/ticket/back/methods/ticket/closure.js index e4cb49007..b633aa95c 100644 --- a/modules/ticket/back/methods/ticket/closure.js +++ b/modules/ticket/back/methods/ticket/closure.js @@ -120,7 +120,7 @@ module.exports = async function(ctx, Self, tickets, options) { JOIN client c ON c.id = t.clientFk WHERE t.clientFk = ? AND NOT t.isDeleted - AND c.isVies + AND c.viesCode `, [ticket.clientFk], myOptions);