diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index e95bd3b04..23f8788ba 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -388,20 +388,20 @@ INSERT INTO `vn`.`contactChannel`(`id`, `name`) (4, 'GCN Channel'), (5, 'The Newspaper'); -INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`, `hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`businessTypeFk`,`typeFk`) +INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`, `hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`viesCode`,`businessTypeFk`,`typeFk`) VALUES - (1101, 'Bruce Wayne', '84612325V', 'BATMAN', 'Alfred', '1007 MOUNTAIN DRIVE, GOTHAM', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'), - (1102, 'Petter Parker', '87945234L', 'SPIDER MAN', 'Aunt May', '20 INGRAM STREET, QUEENS, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'), - (1103, 'Clark Kent', '06815934E', 'SUPER MAN', 'lois lane', '344 CLINTON STREET, APARTAMENT 3-D', 'Gotham', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'), - (1104, 'Tony Stark', '06089160W', 'IRON MAN', 'Pepper Potts', '10880 MALIBU POINT, 90265', 'Gotham', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'), - (1105, 'Max Eisenhardt', '251628698', 'MAGNETO', 'Rogue', 'UNKNOWN WHEREABOUTS', 'Gotham', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, NULL, 0, 0, 18, 0, 'florist','normal'), - (1106, 'DavidCharlesHaller', '53136686Q', 'LEGION', 'Charles Xavier', 'CITY OF NEW YORK, NEW YORK, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 19, 0, 'florist','normal'), - (1107, 'Hank Pym', '09854837G', 'ANT MAN', 'Hawk', 'ANTHILL, SAN FRANCISCO, CALIFORNIA', 'Gotham', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, 19, 0, 'florist','normal'), - (1108, 'Charles Xavier', '22641921P', 'PROFESSOR X', 'Beast', '3800 VICTORY PKWY, CINCINNATI, OH 45207, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 5, 1, 300, 13, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, NULL, 0, 0, 19, 0, 'florist','normal'), - (1109, 'Bruce Banner', '16104829E', 'HULK', 'Black widow', 'SOMEWHERE IN NEW YORK', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, 9, 0, 'florist','normal'), - (1110, 'Jessica Jones', '58282869H', 'JESSICA JONES', 'Luke Cage', 'NYCC 2015 POSTER', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, NULL, 1, 'florist','normal'), - (1111, 'Missing', NULL, 'MISSING MAN', 'Anton', 'THE SPACE, UNIVERSE FAR AWAY', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses'), - (1112, 'Trash', NULL, 'GARBAGE MAN', 'Unknown name', 'NEW YORK CITY, UNDERGROUND', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses'); + (1101, 'Bruce Wayne', '84612325V', 'BATMAN', 'Alfred', '1007 MOUNTAIN DRIVE, GOTHAM', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, NULL, 'florist','normal'), + (1102, 'Petter Parker', '87945234L', 'SPIDER MAN', 'Aunt May', '20 INGRAM STREET, QUEENS, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, NULL, 'florist','normal'), + (1103, 'Clark Kent', '06815934E', 'SUPER MAN', 'lois lane', '344 CLINTON STREET, APARTAMENT 3-D', 'Gotham', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, NULL, 'florist','normal'), + (1104, 'Tony Stark', '06089160W', 'IRON MAN', 'Pepper Potts', '10880 MALIBU POINT, 90265', 'Gotham', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, NULL, 'florist','normal'), + (1105, 'Max Eisenhardt', '251628698', 'MAGNETO', 'Rogue', 'UNKNOWN WHEREABOUTS', 'Gotham', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, NULL, 0, 0, 18, NULL, 'florist','normal'), + (1106, 'DavidCharlesHaller', '53136686Q', 'LEGION', 'Charles Xavier', 'CITY OF NEW YORK, NEW YORK, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 19, NULL, 'florist','normal'), + (1107, 'Hank Pym', '09854837G', 'ANT MAN', 'Hawk', 'ANTHILL, SAN FRANCISCO, CALIFORNIA', 'Gotham', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, 19, NULL, 'florist','normal'), + (1108, 'Charles Xavier', '22641921P', 'PROFESSOR X', 'Beast', '3800 VICTORY PKWY, CINCINNATI, OH 45207, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 5, 1, 300, 13, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, NULL, 0, 0, 19, NULL, 'florist','normal'), + (1109, 'Bruce Banner', '16104829E', 'HULK', 'Black widow', 'SOMEWHERE IN NEW YORK', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, 9, NULL, 'florist','normal'), + (1110, 'Jessica Jones', '58282869H', 'JESSICA JONES', 'Luke Cage', 'NYCC 2015 POSTER', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, NULL, 'ES', 'florist','normal'), + (1111, 'Missing', NULL, 'MISSING MAN', 'Anton', 'THE SPACE, UNIVERSE FAR AWAY', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, NULL, 'others','loses'), + (1112, 'Trash', NULL, 'GARBAGE MAN', 'Unknown name', 'NEW YORK CITY, UNDERGROUND', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, NULL, 'others','loses'); INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`) SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), UPPER(CONCAT(name, 'Social')), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1 diff --git a/db/routines/sage/procedures/clientSupplier_add.sql b/db/routines/sage/procedures/clientSupplier_add.sql index 2d1a51882..dffd52dc8 100644 --- a/db/routines/sage/procedures/clientSupplier_add.sql +++ b/db/routines/sage/procedures/clientSupplier_add.sql @@ -57,8 +57,8 @@ BEGIN c.socialName, 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)), + @fi := IF(cu.code = LEFT(TRIM(c.fi), 2) AND c.viesCode IS NOT NULL, MID(TRIM(c.fi), 3, LENGTH(TRIM(c.fi))-1), TRIM(c.fi)), + IF(c.viesCode IS NOT NULL, CONCAT(cu.code, @fi ), TRIM(c.fi)), IFNULL(c.postcode, ''), IFNULL(c.city, ''), IFNULL(pr.CodigoProvincia, ''), @@ -68,7 +68,7 @@ BEGIN IF((c.fi REGEXP '^([[:blank:]]|[[:digit:]])'), 'J','F'), IF(cu.code = 'ES', 1, - IF((cu.isUeeMember AND c.isVies), 2, 4)), + IF((cu.isUeeMember AND c.viesCode IS NOT NULL), 2, 4)), IFNULL(c.taxTypeSageFk,0), IF(n.SiglaNacion = vCountryCanariasCode COLLATE utf8mb3_unicode_ci, IF(@isCeutaMelilla, 'CEUTA Y MELILLA', IF (@isCanarias, 'ISLAS CANARIAS', n.Nacion)), @@ -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..4f5f51cd9 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 IS NOT NULL THEN 'CEE' WHEN a.isEqualizated AND cClient.code = 'ES' THEN 'EQU' diff --git a/db/routines/vn/procedures/invoiceIn_booking.sql b/db/routines/vn/procedures/invoiceIn_booking.sql index 36189afcc..855f23b1b 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 IS NOT NULL AND c.nontaxableTransactionTypeFk = tii.transactionTypeSageFk AND tii.taxCode = 'nonTaxable') GROUP BY tii.PorcentajeIva, tii.expenseFk; diff --git a/db/routines/vn/triggers/client_afterUpdate.sql b/db/routines/vn/triggers/client_afterUpdate.sql index eb977faa3..eba9c0ccc 100644 --- a/db/routines/vn/triggers/client_afterUpdate.sql +++ b/db/routines/vn/triggers/client_afterUpdate.sql @@ -16,7 +16,7 @@ BEGIN OR NOT (NEW.socialName <=> OLD.socialName) OR NOT (NEW.street <=> OLD.street) OR NOT (NEW.accountingAccount <=> OLD.accountingAccount) - OR NOT (NEW.isVies <=> OLD.isVies) + OR NOT (NEW.viesCode <=> OLD.viesCode) OR NOT (NEW.fi <=> OLD.fi) OR NOT (NEW.postcode <=> OLD.postcode) OR NOT (NEW.city <=> OLD.city) diff --git a/db/routines/vn/triggers/supplier_afterUpdate.sql b/db/routines/vn/triggers/supplier_afterUpdate.sql index 07f31b5e0..99e09be4c 100644 --- a/db/routines/vn/triggers/supplier_afterUpdate.sql +++ b/db/routines/vn/triggers/supplier_afterUpdate.sql @@ -8,7 +8,7 @@ BEGIN OR NOT (NEW.street <=> OLD.street) OR NOT (NEW.account <=> OLD.account) OR NOT (NEW.nif <=> OLD.nif) - OR NOT (NEW.isVies <=> OLD.isVies) + OR NOT (NEW.viesCode <=> OLD.viesCode) OR NOT (NEW.provinceFk <=> OLD.provinceFk) OR NOT (NEW.countryFk <=> OLD.countryFk) OR NOT (NEW.postCode <=> OLD.postCode) diff --git a/db/routines/vn2008/views/Clientes.sql b/db/routines/vn2008/views/Clientes.sql index 9f8ef712e..c6f89b6bb 100644 --- a/db/routines/vn2008/views/Clientes.sql +++ b/db/routines/vn2008/views/Clientes.sql @@ -40,7 +40,7 @@ AS SELECT `c`.`id` AS `id_cliente`, `c`.`isCreatedAsServed` AS `isCreatedAsServed`, `c`.`hasInvoiceSimplified` AS `hasInvoiceSimplified`, `c`.`salesPersonFk` AS `Id_Trabajador`, - `c`.`isVies` AS `vies`, + `c`.`viesCode` AS `vies`, `c`.`bankEntityFk` AS `bankEntityFk`, `c`.`typeFk` AS `typeFk` FROM `vn`.`client` `c` diff --git a/db/versions/11303-salmonMoss/00-firstScript.sql b/db/versions/11303-salmonMoss/00-firstScript.sql new file mode 100644 index 000000000..6bbfcaa2e --- /dev/null +++ b/db/versions/11303-salmonMoss/00-firstScript.sql @@ -0,0 +1,211 @@ +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' + 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'; + +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/methods/client/updateFiscalData.js b/modules/client/back/methods/client/updateFiscalData.js index 8ed55b856..752adcc52 100644 --- a/modules/client/back/methods/client/updateFiscalData.js +++ b/modules/client/back/methods/client/updateFiscalData.js @@ -73,8 +73,8 @@ module.exports = Self => { type: 'boolean' }, { - arg: 'isVies', - type: 'boolean' + arg: 'viesCode', + type: 'any' }, { arg: 'isToBeMailed', 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/client/back/models/client.json b/modules/client/back/models/client.json index f24f69ae7..828a54396 100644 --- a/modules/client/back/models/client.json +++ b/modules/client/back/models/client.json @@ -103,9 +103,6 @@ "quality": { "type": "number" }, - "isVies": { - "type": "boolean" - }, "isRelevant": { "type": "boolean" }, @@ -147,8 +144,10 @@ }, "hasDailyInvoice": { "type": "boolean" + }, + "viesCode": { + "type": "string" } - }, "relations": { "account": { diff --git a/modules/supplier/back/methods/supplier/updateFiscalData.js b/modules/supplier/back/methods/supplier/updateFiscalData.js index f2cdd63be..3a3f6e8d7 100644 --- a/modules/supplier/back/methods/supplier/updateFiscalData.js +++ b/modules/supplier/back/methods/supplier/updateFiscalData.js @@ -50,12 +50,12 @@ module.exports = Self => { }, { arg: 'healthRegister', type: 'any' - }, { - arg: 'isVies', - type: 'boolean' }, { arg: 'isTrucker', type: 'boolean' + }, { + arg: 'viesCode', + type: 'any' }], returns: { arg: 'res', @@ -68,7 +68,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, isTrucker, viesCode, options) => { const models = Self.app.models; const {args} = ctx; const myOptions = {}; @@ -102,8 +102,8 @@ module.exports = Self => { countryFk, 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..ff9f08738 100644 --- a/modules/supplier/back/models/supplier.json +++ b/modules/supplier/back/models/supplier.json @@ -111,9 +111,9 @@ "healthRegister": { "type": "string" }, - "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..c95027560 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 IS NOT NULL `, [ticket.clientFk], myOptions);