diff --git a/db/routines/sage/procedures/clientSupplier_add.sql b/db/routines/sage/procedures/clientSupplier_add.sql index 2d1a51882..2f859f6e6 100644 --- a/db/routines/sage/procedures/clientSupplier_add.sql +++ b/db/routines/sage/procedures/clientSupplier_add.sql @@ -58,7 +58,7 @@ BEGIN IFNULL(c.street, ''), c.accountingAccount, @fi := IF(cu.code = LEFT(TRIM(c.fi), 2) AND c.isVies, MID(TRIM(c.fi), 3, LENGTH(TRIM(c.fi))-1), TRIM(c.fi)), - IF(c.isVies, CONCAT(IFNULL(cu.viesCode,cu.code), @fi ), TRIM(c.fi)), + IF(c.isVies, CONCAT(cu.code, @fi ), TRIM(c.fi)), IFNULL(c.postcode, ''), IFNULL(c.city, ''), IFNULL(pr.CodigoProvincia, ''), @@ -95,7 +95,7 @@ BEGIN IFNULL(s.street, ''), s.account, @nif := IF(co.code = LEFT(TRIM(s.nif), 2), MID(TRIM(s.nif), 3, LENGTH(TRIM(s.nif))-1), TRIM(s.nif)), - IF(s.isVies, CONCAT(IFNULL(co.viesCode,co.code), @nif), TRIM(s.nif)), + TRIM(CONCAT(IFNULL(s.viesCode,''), @nif)), IFNULL(s.postCode,''), IFNULL(s.city, ''), IFNULL(pr.CodigoProvincia, ''), diff --git a/db/routines/vn/procedures/addressTaxArea.sql b/db/routines/vn/procedures/addressTaxArea.sql index a1bb0dec0..acc56d1ff 100644 --- a/db/routines/vn/procedures/addressTaxArea.sql +++ b/db/routines/vn/procedures/addressTaxArea.sql @@ -17,7 +17,7 @@ BEGIN WHEN (NOT IFNULL(auClient.isUeeMember, cClient.isUeeMember) OR NOT cSupplier.isUeeMember) AND NOT (auSupplier.id <=> auClient.id) THEN 'WORLD' - WHEN cClient.isUeeMember AND cSupplier.isUeeMember AND c.countryFk != s.countryFk AND c.isVies THEN + WHEN cClient.isUeeMember AND cSupplier.isUeeMember AND c.countryFk != s.countryFk AND c.viesCode THEN 'CEE' WHEN a.isEqualizated AND cClient.code = 'ES' THEN 'EQU' diff --git a/db/versions/11303-salmonMoss/00-firstScript.sql b/db/versions/11303-salmonMoss/00-firstScript.sql new file mode 100644 index 000000000..71cdf0304 --- /dev/null +++ b/db/versions/11303-salmonMoss/00-firstScript.sql @@ -0,0 +1,88 @@ +use vn; +ALTER TABLE vn.client + 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' + WHERE c2.name= 'España'; + +UPDATE vn.client c + JOIN country c2 ON c2.id = c.countryFk + SET c.viesCode = 'IT' + WHERE c2.name= 'Italia'; + +UPDATE vn.client c + JOIN country c2 ON c2.id = c.countryFk + SET c.viesCode = 'DE' + WHERE c2.name= 'Alemania'; + +UPDATE vn.client c + JOIN country c2 ON c2.id = c.countryFk + SET c.viesCode = 'RO' + WHERE c2.name= 'Rumania'; + +UPDATE vn.client c + JOIN country c2 ON c2.id = c.countryFk + SET c.viesCode = 'IT' + WHERE c2.name= 'Italia'; + +UPDATE client c + JOIN country c2 ON c2.id = c.countryFk + SET c.viesCode = 'NL' + WHERE c2.name= 'Holanda'; + +UPDATE vn.client c + JOIN country c2 ON c2.id = c.countryFk + SET c.viesCode = 'BE' + WHERE c2.name= 'Bélgica'; + +UPDATE vn.client c + JOIN country c2 ON c2.id = c.countryFk + SET c.viesCode = 'PT' + WHERE c2.name= 'Portugal'; + +UPDATE vn.client c + JOIN country c2 ON c2.id = c.countryFk + SET c.viesCode = 'FR' + WHERE c2.name= 'Francia'; + +UPDATE vn.client c + JOIN country c2 ON c2.id = c.countryFk + SET c.viesCode = 'PL' + WHERE c2.name = 'Polonia'; + +UPDATE client c + JOIN country c2 ON c2.id = c.countryFk + SET c.viesCode = 'AD' + WHERE c2.name = 'Andorra'; + +UPDATE client c + JOIN country c2 ON c2.id = c.countryFk + SET c.viesCode = 'LU' + WHERE c2.name = 'Luxemburgo'; + +UPDATE client c + JOIN country c2 ON c2.id = c.countryFk + SET c.viesCode = 'DK' + WHERE c2.name = 'Dinamarca'; + +UPDATE client c + JOIN country c2 ON c2.id = c.countryFk + SET c.viesCode = 'MN' + WHERE c2.name = 'Mongolia'; + +UPDATE client c + JOIN country c2 ON c2.id = c.countryFk + SET c.viesCode = 'SK' + WHERE c2.name = 'Eslovaquia'; + +UPDATE client c + JOIN country c2 ON c2.id = c.countryFk + SET c.viesCode = 'FR' + WHERE c2.name = 'Mónaco'; + +UPDATE client c + JOIN country c2 ON c2.id = c.countryFk + SET c.viesCode = 'HU' + WHERE c2.name = 'Hungria'; diff --git a/modules/client/back/methods/client/updateFiscalData.js b/modules/client/back/methods/client/updateFiscalData.js index 8ed55b856..c7d577453 100644 --- a/modules/client/back/methods/client/updateFiscalData.js +++ b/modules/client/back/methods/client/updateFiscalData.js @@ -103,6 +103,10 @@ module.exports = Self => { { arg: 'hasDailyInvoice', type: 'boolean' + }, + { + arg: 'viesCode', + type: 'any' } ], returns: { diff --git a/modules/client/back/models/client.json b/modules/client/back/models/client.json index f24f69ae7..85420de22 100644 --- a/modules/client/back/models/client.json +++ b/modules/client/back/models/client.json @@ -147,8 +147,10 @@ }, "hasDailyInvoice": { "type": "boolean" + }, + "viesCode": { + "type": "string" } - }, "relations": { "account": {