From 1044a24bc71d47107d9d06597f72541941bece84 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 23 Apr 2024 12:00:23 +0200 Subject: [PATCH 01/31] refactor: #6997 Deleted vn.client.eypbc --- db/dump/fixtures.before.sql | 26 ++++++++++++------------ db/routines/vn2008/views/Clientes.sql | 1 - modules/client/back/locale/client/en.yml | 1 - modules/client/back/locale/client/es.yml | 1 - modules/client/back/models/client.json | 3 --- modules/worker/back/models/worker.json | 1 - 6 files changed, 13 insertions(+), 20 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index ff58af2e2..c71e01a0c 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -371,20 +371,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`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`, `hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`, `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`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`, `hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`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, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 1, '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, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 1, '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, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 1, '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, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 1, '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, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, NULL, 0, 0, 18, 0, 1, '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, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 19, 0, 1, '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, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, 19, 0, 1, '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, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, NULL, 0, 0, 19, 0, 1, '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, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, 9, 0, 1, '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, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, NULL, 0, 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, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 1, '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, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 1, '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, NULL, 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, NULL, 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, NULL, 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, NULL, 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, NULL, 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, NULL, 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, NULL, 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, NULL, 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, NULL, 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, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, NULL, 0, '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, NULL, 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, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, '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`, `gestdocFk`, `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,NULL, 10, 5, util.VN_CURDATE(), 1 diff --git a/db/routines/vn2008/views/Clientes.sql b/db/routines/vn2008/views/Clientes.sql index a696cb6e0..153d875bc 100644 --- a/db/routines/vn2008/views/Clientes.sql +++ b/db/routines/vn2008/views/Clientes.sql @@ -42,7 +42,6 @@ AS SELECT `c`.`id` AS `id_cliente`, `c`.`hasInvoiceSimplified` AS `hasInvoiceSimplified`, `c`.`salesPersonFk` AS `Id_Trabajador`, `c`.`isVies` AS `vies`, - `c`.`eypbc` AS `EYPBC`, `c`.`bankEntityFk` AS `bankEntityFk`, `c`.`typeFk` AS `typeFk` FROM `vn`.`client` `c` diff --git a/modules/client/back/locale/client/en.yml b/modules/client/back/locale/client/en.yml index ad21a6ce6..75ff0f7ac 100644 --- a/modules/client/back/locale/client/en.yml +++ b/modules/client/back/locale/client/en.yml @@ -27,7 +27,6 @@ columns: hasCoreVnh: core VNH hasIncoterms: incoterms isTaxDataChecked: tax data checked - eypbc: EYPBC quality: quality isVies: VIES isRelevant: relevant diff --git a/modules/client/back/locale/client/es.yml b/modules/client/back/locale/client/es.yml index b17f53b1c..7ff6a5c30 100644 --- a/modules/client/back/locale/client/es.yml +++ b/modules/client/back/locale/client/es.yml @@ -27,7 +27,6 @@ columns: hasCoreVnh: centro VNH hasIncoterms: incoterms isTaxDataChecked: datos fiscales comprobados - eypbc: EYPBC quality: calidad isVies: VIES isRelevant: importante diff --git a/modules/client/back/models/client.json b/modules/client/back/models/client.json index 550ac380e..510857595 100644 --- a/modules/client/back/models/client.json +++ b/modules/client/back/models/client.json @@ -103,9 +103,6 @@ "isTaxDataChecked":{ "type": "boolean" }, - "eypbc": { - "type": "boolean" - }, "quality": { "type": "number" }, diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index c203f6e09..4c28cf217 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -154,7 +154,6 @@ "hasCoreVnh", "hasIncoterms", "isTaxDataChecked", - "eypbc", "quality", "isVies", "isRelevant", From f7ebd071bf14c2334739913af92d8cca82e1fe7e Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 24 Apr 2024 09:53:31 +0200 Subject: [PATCH 02/31] refactor: #7258 Deleted all dependences of vn2008 schema --- db/dump/fixtures.after.sql | 2 +- db/dump/fixtures.before.sql | 1 - .../bi/procedures/Greuge_Evolution_Add.sql | 12 +- .../analisis_ventas_evolution_add.sql | 10 +- .../bi/procedures/analisis_ventas_update.sql | 50 +++---- .../bi/procedures/claim_ratio_routine.sql | 128 +++++++++--------- db/routines/bi/procedures/clean_launcher.sql | 9 -- db/routines/bi/procedures/comparativa_add.sql | 32 ----- .../bi/procedures/comparativa_add_manual.sql | 40 ------ .../bi/procedures/defaultersFromDate.sql | 6 +- db/routines/bi/procedures/defaulting.sql | 9 +- db/routines/bi/views/last_Id_Cubo.sql | 19 --- db/routines/bi/views/v_ventas_contables.sql | 23 ---- .../bs/procedures/bancos_evolution_add.sql | 112 --------------- .../bs/procedures/comercialesCompleto.sql | 111 --------------- .../bs/procedures/indicatorsUpdate.sql | 6 +- .../bs/procedures/manaCustomerUpdate.sql | 20 +-- .../bs/procedures/ventas_contables_add.sql | 44 +++--- .../ventas_contables_por_cliente.sql | 47 ------- db/routines/bs/procedures/vivosMuertos.sql | 63 --------- db/routines/bs/views/VentasPorCliente.sql | 14 -- db/routines/bs/views/bajasLaborales.sql | 31 ----- db/routines/bs/views/horasSilla.sql | 27 ---- db/routines/bs/views/s1_ticketDetail.sql | 19 --- db/routines/bs/views/s21_saleDetail.sql | 42 ------ .../cache/procedures/prod_graphic_refresh.sql | 36 ----- db/routines/edi/procedures/ekt_load.sql | 8 +- .../vn/functions/getAlert3StateTest.sql | 40 ------ .../vn/functions/ticketPositionInPath.sql | 6 +- .../vn/functions/ticketSplitCounter.sql | 6 +- .../vn/procedures/itemShelvingProblem.sql | 18 +-- .../vn/procedures/item_cleanFloramondo.sql | 3 - .../vn/procedures/packingListPrinted.sql | 13 -- .../vn/procedures/packingListSwitch.sql | 8 +- .../vn/triggers/solunionCAP_afterInsert.sql | 4 +- .../vn/triggers/solunionCAP_afterUpdate.sql | 8 +- .../vn/triggers/solunionCAP_beforeDelete.sql | 4 +- db/routines/vn/views/especialPrice.sql | 10 +- db/routines/vn/views/exchangeInsurance.sql | 16 --- .../vn/views/paymentExchangeInsurance.sql | 26 ++-- db/routines/vn/views/promissoryNote.sql | 7 - db/routines/vn/views/saleLabel.sql | 8 -- db/routines/vn/views/ticketMRW.sql | 47 ------- db/routines/vn/views/ticketToPrepare.sql | 58 -------- .../vn/views/ticketeToPreparePrepared.sql | 47 ------- .../11012-silverRuscus/00-firstScript.sql | 1 + myt.config.yml | 8 +- 47 files changed, 196 insertions(+), 1063 deletions(-) delete mode 100644 db/routines/bi/procedures/clean_launcher.sql delete mode 100644 db/routines/bi/procedures/comparativa_add.sql delete mode 100644 db/routines/bi/procedures/comparativa_add_manual.sql delete mode 100644 db/routines/bi/views/last_Id_Cubo.sql delete mode 100644 db/routines/bi/views/v_ventas_contables.sql delete mode 100644 db/routines/bs/procedures/bancos_evolution_add.sql delete mode 100644 db/routines/bs/procedures/comercialesCompleto.sql delete mode 100644 db/routines/bs/procedures/ventas_contables_por_cliente.sql delete mode 100644 db/routines/bs/procedures/vivosMuertos.sql delete mode 100644 db/routines/bs/views/VentasPorCliente.sql delete mode 100644 db/routines/bs/views/bajasLaborales.sql delete mode 100644 db/routines/bs/views/horasSilla.sql delete mode 100644 db/routines/bs/views/s1_ticketDetail.sql delete mode 100644 db/routines/bs/views/s21_saleDetail.sql delete mode 100644 db/routines/cache/procedures/prod_graphic_refresh.sql delete mode 100644 db/routines/vn/functions/getAlert3StateTest.sql delete mode 100644 db/routines/vn/procedures/packingListPrinted.sql delete mode 100644 db/routines/vn/views/exchangeInsurance.sql delete mode 100644 db/routines/vn/views/promissoryNote.sql delete mode 100644 db/routines/vn/views/saleLabel.sql delete mode 100644 db/routines/vn/views/ticketMRW.sql delete mode 100644 db/routines/vn/views/ticketToPrepare.sql delete mode 100644 db/routines/vn/views/ticketeToPreparePrepared.sql create mode 100644 db/versions/11012-silverRuscus/00-firstScript.sql diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index 523f41bfb..fd940d8a6 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -146,7 +146,7 @@ INSERT INTO `vn`.`businessReasonEnd` (`id`, `reason`) ('2', 'No supera PP empresa'), ('3', 'Despido'); -INSERT INTO `vn2008`.`payroll_categorias` (`codcategoria`, `descripcion`, `Tarifa`) +INSERT INTO `vn`.`payrollCategories` (`id`, `description`, `rate`) VALUES ('11', 'INFORMATICA', '2'), ('12', 'AUX INFORMATICA', '7'); diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index ff58af2e2..5520e0989 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -11,7 +11,6 @@ CREATE ROLE 'salix'; GRANT 'salix' TO 'root'@'%'; SET DEFAULT ROLE 'salix' FOR 'root'@'%'; -CREATE SCHEMA IF NOT EXISTS `vn2008`; CREATE SCHEMA IF NOT EXISTS `tmp`; UPDATE `util`.`config` diff --git a/db/routines/bi/procedures/Greuge_Evolution_Add.sql b/db/routines/bi/procedures/Greuge_Evolution_Add.sql index c5b077f29..6480155cb 100644 --- a/db/routines/bi/procedures/Greuge_Evolution_Add.sql +++ b/db/routines/bi/procedures/Greuge_Evolution_Add.sql @@ -91,15 +91,15 @@ BEGIN -- Recobro UPDATE bi.Greuge_Evolution ge JOIN ( - SELECT cs.Id_Cliente, sum(Valor * Cantidad) as Importe + SELECT a.clientFk Id_Cliente, sum(sc.value * s.quantity) as Importe FROM vn.ticket t - JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.addressFk - JOIN vn2008.Movimientos m on m.Id_Ticket = t.id - JOIN vn2008.Movimientos_componentes mc on mc.Id_Movimiento = m.Id_Movimiento + JOIN vn.address a on a.id = t.addressFk + JOIN vn.sale s on s.ticketFk = t.id + JOIN vn.saleComponent sc on sc.saleFk = s.id WHERE t.shipped >= datFEC AND t.shipped < datFEC_TOMORROW - AND mc.Id_Componente = 17 -- Recobro - GROUP BY cs.Id_Cliente + AND sc.componentFk = 17 -- Recobro + GROUP BY a.clientFk ) sub using(Id_Cliente) SET Recobro = Importe WHERE ge.Fecha = datFEC; diff --git a/db/routines/bi/procedures/analisis_ventas_evolution_add.sql b/db/routines/bi/procedures/analisis_ventas_evolution_add.sql index fca749681..7c2cc5678 100644 --- a/db/routines/bi/procedures/analisis_ventas_evolution_add.sql +++ b/db/routines/bi/procedures/analisis_ventas_evolution_add.sql @@ -24,7 +24,7 @@ BEGIN WHERE Periodo < vMaxPeriod; SELECT MIN(period) INTO vCurrentPeriod - FROM vn2008.time + FROM vn.time WHERE period > vPreviousPeriod; SET vYear = FLOOR(vCurrentPeriod / 100); @@ -66,7 +66,7 @@ BEGIN WHERE periodo < vMaxPeriod; SELECT MIN(period) INTO vCurrentPeriod - FROM vn2008.time + FROM vn.time WHERE period > vPreviousPeriod; SET vYear = FLOOR(vCurrentPeriod / 100); @@ -108,7 +108,7 @@ BEGIN WHERE periodo < vMaxPeriod; SELECT MIN(period) INTO vCurrentPeriod - FROM vn2008.time + FROM vn.time WHERE period > vPreviousPeriod; SET vYear = FLOOR(vCurrentPeriod / 100); @@ -156,7 +156,7 @@ BEGIN WHERE periodo < vMaxPeriod; SELECT MIN(period) INTO vCurrentPeriod - FROM vn2008.time + FROM vn.time WHERE period > vPreviousPeriod; SET vYear = FLOOR(vCurrentPeriod / 100); @@ -198,7 +198,7 @@ BEGIN WHERE periodo < vMaxPeriod; SELECT MIN(period) INTO vCurrentPeriod - FROM vn2008.time + FROM vn.time WHERE period > vPreviousPeriod; SET vYear = FLOOR(vCurrentPeriod / 100); diff --git a/db/routines/bi/procedures/analisis_ventas_update.sql b/db/routines/bi/procedures/analisis_ventas_update.sql index 228660d07..ef3e165a0 100644 --- a/db/routines/bi/procedures/analisis_ventas_update.sql +++ b/db/routines/bi/procedures/analisis_ventas_update.sql @@ -23,31 +23,31 @@ BEGIN Importe ) SELECT - tp.Tipo AS Familia, - r.reino AS Reino, - tr.CodigoTrabajador AS Comercial, - tr2.CodigoTrabajador AS Comprador, - p.name AS Provincia, - w.name AS almacen, - tm.year AS Año, - tm.month AS Mes, - tm.week AS Semana, - dm.description AS Vista, - bt.importe AS Importe + it.name, + ic.name, + w.code, + w2.code, + p.name, + wa.name, + tm.year, + tm.month, + tm.week, + dm.description, + bt.importe FROM bs.ventas bt - LEFT JOIN vn2008.Tipos tp ON tp.tipo_id = bt.tipo_id - LEFT JOIN vn2008.reinos r ON r.id = tp.reino_id - LEFT JOIN vn2008.Clientes c on c.Id_Cliente = bt.Id_Cliente - LEFT JOIN vn2008.Trabajadores tr ON tr.Id_Trabajador = c.Id_Trabajador - LEFT JOIN vn2008.Trabajadores tr2 ON tr2.Id_Trabajador = tp.Id_Trabajador - JOIN vn2008.time tm ON tm.date = bt.fecha - JOIN vn2008.Movimientos m ON m.Id_Movimiento = bt.Id_Movimiento - LEFT JOIN vn.ticket t ON t.id = m.Id_Ticket - JOIN vn2008.Agencias a ON a.Id_Agencia = t.agencyModeFk - LEFT JOIN vn.deliveryMethod dm ON dm.id = a.Vista - LEFT JOIN vn2008.Consignatarios cs ON cs.Id_Consigna = t.addressFk - LEFT JOIN vn2008.province p ON p.province_id = cs.province_id - LEFT JOIN vn.warehouse w ON w.id = t.warehouseFk - WHERE bt.fecha >= vLastMonth AND r.mercancia; + LEFT JOIN vn.itemType it ON it.id = bt.tipo_id + LEFT JOIN vn.itemCategory ic ON ic.id = it.categoryFk + LEFT JOIN vn.client c on c.id = bt.Id_Cliente + LEFT JOIN vn.worker w ON w.id = c.salesPersonFk + LEFT JOIN vn.worker w2 ON w2.id = it.workerFk + JOIN vn.time tm ON tm.dated = bt.fecha + JOIN vn.sale s ON s.id = bt.Id_Movimiento + LEFT JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.agencyMode am ON am.id = t.agencyModeFk + LEFT JOIN vn.deliveryMethod dm ON dm.id = am.deliveryMethodFk + LEFT JOIN vn.address a ON a.id = t.addressFk + LEFT JOIN vn.province p ON p.id = a.provinceFk + LEFT JOIN vn.warehouse wa ON wa.id = t.warehouseFk + WHERE bt.fecha >= vLastMonth AND ic.merchandise; END$$ DELIMITER ; diff --git a/db/routines/bi/procedures/claim_ratio_routine.sql b/db/routines/bi/procedures/claim_ratio_routine.sql index 83d70c867..ae87e15a2 100644 --- a/db/routines/bi/procedures/claim_ratio_routine.sql +++ b/db/routines/bi/procedures/claim_ratio_routine.sql @@ -13,46 +13,45 @@ BEGIN INSERT INTO vn.greuge(shipped, clientFk, description, amount, greugeTypeFk, ticketFk) - SELECT cm.Fecha - , cm.Id_Cliente - , concat('Claim ',cm.id,' : ', m.Concepte) - ,round( -1 * ((sensib -1)/4) * Cantidad * - Preu * (100 - Descuento) / 100, 2) AS Reclamaciones + SELECT c.ticketCreated + , c.clientFk + , concat('Claim ', c.id,' : ', s.concept) + ,round( -1 * ((c.responsibility -1)/4) * s.quantity * + s.price * (100 - s.discount) / 100, 2) , 4 - , m.Id_Ticket - FROM vn2008.Movimientos m - JOIN vn2008.cl_act ca USING(Id_Movimiento) - JOIN vn2008.cl_main cm ON cm.id = ca.cl_main_id - WHERE ca.cl_sol_id NOT IN (1,5) - AND ca.greuge = 0 - AND cm.cl_est_id = 3; + , s.ticketFk + FROM vn.sale s + JOIN vn.claimEnd ce ON ce.saleFk = s.id + JOIN vn.claim c ON c.id = ce.claimFk + WHERE ce.claimDestinationFk NOT IN (1,5) + AND NOT ce.isGreuge + AND c.claimStateFk = 3; -- Reclamaciones que pasan a Maná INSERT INTO vn.greuge(shipped, clientFk, description, amount, greugeTypeFk, ticketFk) - SELECT cm.Fecha - , cm.Id_Cliente - , concat('Claim_mana ',cm.id,' : ', m.Concepte) - ,round( ((sensib -1)/4) * Cantidad * Preu * (100 - Descuento) / 100, 2) - AS Reclamaciones + SELECT c.ticketCreated + , c.clientFk + , concat('Claim_mana ',c.id,' : ', s.concept) + ,round( ((c.responsibility -1)/4) * s.quantity * s.price * (100 - s.discount) / 100, 2) ,3 - ,m.Id_Ticket - FROM vn2008.Movimientos m - JOIN vn2008.cl_act ca USING(Id_Movimiento) - JOIN vn2008.cl_main cm ON cm.id = ca.cl_main_id - WHERE ca.cl_sol_id NOT IN (1,5) - AND ca.greuge = 0 - AND cm.cl_est_id = 3 - AND cm.mana; + ,s.ticketFk + FROM vn.sale s + JOIN vn.claimEnd ce ON ce.saleFk = s.id + JOIN vn.claim c ON c.id = ce.claimFk + WHERE ce.claimDestinationFk NOT IN (1,5) + AND NOT ce.isGreuge + AND c.claimStateFk = 3 + AND c.isChargedToMana; -- Marcamos para no repetir - UPDATE vn2008.cl_act ca - JOIN vn2008.cl_main cm ON cm.id = ca.cl_main_id - SET greuge = 1 - WHERE ca.cl_sol_id NOT IN (1,5) - AND ca.greuge = 0 - AND cm.cl_est_id = 3; + UPDATE vn.claimEnd ce + JOIN vn.claim c ON c.id = ce.claimFk + SET c.isChargedToMana = TRUE + WHERE ce.claimDestinationFk NOT IN (1,5) + AND NOT ce.isGreuge + AND c.claimStateFk = 3; -- Recobros @@ -60,17 +59,17 @@ BEGIN CREATE TEMPORARY TABLE tmp.ticket_list (PRIMARY KEY (Id_Ticket)) SELECT DISTINCT t.id Id_Ticket - FROM vn2008.Movimientos_componentes mc - JOIN vn2008.Movimientos m ON mc.Id_Movimiento = m.Id_Movimiento - JOIN vn.ticket t ON t.id = m.Id_Ticket + FROM vn.saleComponent sc + JOIN vn.sale s ON sc.saleFk = s.id + JOIN vn.ticket t ON t.id = s.ticketFk JOIN vn.ticketLastState ts ON ts.ticketFk = t.id JOIN vn.ticketTracking tt ON tt.id = ts.ticketTrackingFk - JOIN vn.state s ON s.id = tt.stateFk - WHERE mc.Id_Componente = 17 - AND mc.greuge = 0 + JOIN vn.state st ON st.id = tt.stateFk + WHERE sc.componentFk = 17 + AND sc.isGreuge = 0 AND t.shipped >= '2016-10-01' AND t.shipped < util.VN_CURDATE() - AND s.alertLevel >= 3; + AND st.alertLevel >= 3; DELETE g.* FROM vn.greuge g @@ -80,24 +79,24 @@ BEGIN INSERT INTO vn.greuge(clientFk, description, amount,shipped, greugeTypeFk, ticketFk) SELECT t.clientFk - ,concat('recobro ', m.Id_Ticket), - round(SUM(mc.Valor*Cantidad),2) - AS dif - ,date(t.shipped) + ,concat('recobro ', s.ticketFk), - round(SUM(sc.value*s.quantity),2) + AS dif, + date(t.shipped) , 2 ,tt.Id_Ticket - FROM vn2008.Movimientos m - JOIN vn.ticket t ON t.id = m.Id_Ticket + FROM vn.sale s + JOIN vn.ticket t ON t.id = s.ticketFk JOIN tmp.ticket_list tt ON tt.Id_Ticket = t.id - JOIN vn2008.Movimientos_componentes mc - ON mc.Id_Movimiento = m.Id_Movimiento AND mc.Id_Componente = 17 + JOIN vn.saleComponent sc + ON sc.saleFk = s.id AND sc.componentFk = 17 GROUP BY t.id HAVING ABS(dif) > 1; - UPDATE vn2008.Movimientos_componentes mc - JOIN vn2008.Movimientos m ON m.Id_Movimiento = mc.Id_Movimiento - JOIN tmp.ticket_list tt ON tt.Id_Ticket = m.Id_Ticket - SET greuge = 1 - WHERE Id_Componente = 17; + UPDATE vn.saleComponent sc + JOIN vn.sale s ON s.id = sc.saleFk + JOIN tmp.ticket_list tt ON tt.Id_Ticket = s.ticketFk + SET sc.isGreuge = 1 + WHERE sc.componentFk = 17; /* * Recalculamos la ratio de las reclamaciones, que luego @@ -105,26 +104,25 @@ BEGIN */ REPLACE bi.claims_ratio(Id_Cliente, Consumo, Reclamaciones, Ratio, recobro) - SELECT Id_Cliente, 0,0,0,0 - FROM vn2008.Clientes; + SELECT id, 0,0,0,0 + FROM vn.client; REPLACE bi.claims_ratio(Id_Cliente, Consumo, Reclamaciones, Ratio, recobro) SELECT fm.Id_Cliente, 12 * fm.Consumo, Reclamaciones, - round(Reclamaciones / (12*fm.Consumo),4) AS Ratio, 0 + round(Reclamaciones / (12*fm.Consumo),4), 0 FROM bi.facturacion_media_anual fm LEFT JOIN( - SELECT cm.Id_Cliente, round(sum(-1 * ((sensib -1)/4) * - Cantidad * Preu * (100 - Descuento) / 100)) + SELECT c.clientFk, round(sum(-1 * ((c.responsibility -1)/4) * + s.quantity * s.price * (100 - s.discount) / 100)) AS Reclamaciones - FROM vn2008.Movimientos m - JOIN vn2008.cl_act ca - ON ca.Id_Movimiento = m.Id_Movimiento - JOIN vn2008.cl_main cm ON cm.id = ca.cl_main_id - WHERE ca.cl_sol_id NOT IN (1,5) - AND cm.cl_est_id = 3 - AND cm.Fecha >= TIMESTAMPADD(YEAR, -1, util.VN_CURDATE()) - GROUP BY cm.Id_Cliente - ) claims ON claims.Id_Cliente = fm.Id_Cliente; + FROM vn.sale s + JOIN vn.claimEnd ce ON ce.saleFk = s.id + JOIN vn.claim c ON c.id = ce.claimFk + WHERE ce.claimDestinationFk NOT IN (1,5) + AND c.claimStateFk = 3 + AND c.ticketCreated >= TIMESTAMPADD(YEAR, -1, util.VN_CURDATE()) + GROUP BY c.clientFk + ) claims ON claims.clientFk = fm.Id_Cliente; -- Calculamos el porcentaje del recobro para añadirlo al precio de venta @@ -153,7 +151,7 @@ BEGIN -- CLIENTE 5523, VERDECORA UPDATE bi.claims_ratio SET recobro = GREATEST(0.12, recobro) WHERE Id_Cliente = 5523; - -- CLIENTE 15979, SERVEIS VETERINARIS + -- CLIENTE 15979, SERVEIS VETERINARIS UPDATE bi.claims_ratio SET recobro = GREATEST(0.05, recobro) WHERE Id_Cliente = 15979; -- CLIENTE 5189 i 8942, son de CSR i son el mateix client diff --git a/db/routines/bi/procedures/clean_launcher.sql b/db/routines/bi/procedures/clean_launcher.sql deleted file mode 100644 index 9eea34584..000000000 --- a/db/routines/bi/procedures/clean_launcher.sql +++ /dev/null @@ -1,9 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`clean_launcher`() -BEGIN -/** - * Borra registros de las principales tablas (excepto de "ticket"). - */ - CALL vn2008.clean(0); -END$$ -DELIMITER ; diff --git a/db/routines/bi/procedures/comparativa_add.sql b/db/routines/bi/procedures/comparativa_add.sql deleted file mode 100644 index ac06798db..000000000 --- a/db/routines/bi/procedures/comparativa_add.sql +++ /dev/null @@ -1,32 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`comparativa_add`() -BEGIN - DECLARE lastCOMP INT; # Se trata de una variable para almacenar el ultimo valor del Periodo - DECLARE vMaxPeriod INT; - DECLARE vMaxWeek INT; - - SELECT t.period, t.`week` INTO vMaxPeriod, vMaxWeek - FROM vn.`time` t - WHERE t.dated = util.VN_CURDATE(); - - SELECT MAX(Periodo) INTO lastCOMP FROM vn2008.Comparativa; - -- Fijaremos las ventas con más de un mes de antiguedad en la tabla Comparativa - - IF lastCOMP < vMaxPeriod - 3 AND vMaxWeek > 3 THEN - - REPLACE vn2008.Comparativa(Periodo, Id_Article, warehouse_id, Cantidad,price) - SELECT tm.period as Periodo, m.Id_Article, t.warehouseFk, sum(m.Cantidad), sum(v.importe) - FROM bs.ventas v - JOIN vn2008.time tm ON tm.date = v.fecha - JOIN vn2008.Movimientos m ON m.Id_Movimiento = v.Id_Movimiento - JOIN vn2008.Tipos tp ON tp.tipo_id = v.tipo_id - JOIN vn2008.reinos r ON r.id = tp.reino_id - JOIN vn.ticket t ON t.id = m.Id_Ticket - WHERE tm.period BETWEEN lastCOMP AND vMaxPeriod - 3 - AND t.clientFk NOT IN(400,200) - AND t.warehouseFk NOT IN (0,13) - GROUP BY m.Id_Article, Periodo, t.warehouseFk; - - END IF; -END$$ -DELIMITER ; diff --git a/db/routines/bi/procedures/comparativa_add_manual.sql b/db/routines/bi/procedures/comparativa_add_manual.sql deleted file mode 100644 index 2b05b1277..000000000 --- a/db/routines/bi/procedures/comparativa_add_manual.sql +++ /dev/null @@ -1,40 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`comparativa_add_manual`(IN vStarted DATE, IN vEnded DATE) -BEGIN -/** - * Recalcula la tabla Comparativa para dos valores dados - * - * @param vStarted fecha desde - * @param vEnded fecha hasta - */ - - DECLARE periodStart INT; - DECLARE periodEnd INT; - - -- Seleccionamos la fecha minima/maxima del periodo que vamos a consultar - - SELECT t.period INTO periodStart - FROM vn.`time` t - WHERE t.dated = vStarted; - - SELECT t.period INTO periodEnd - FROM vn.`time` t - WHERE t.dated = vEnded; - - DELETE FROM vn2008.Comparativa - WHERE Periodo BETWEEN periodStart AND periodEnd; - - INSERT INTO vn2008.Comparativa(Periodo, Id_Article, warehouse_id, Cantidad,price) - SELECT tm.period as Periodo, m.Id_Article, t.warehouseFk, sum(m.Cantidad), sum(v.importe) - FROM bs.ventas v - JOIN vn2008.time tm ON tm.date = v.fecha - JOIN vn2008.Movimientos m ON m.Id_Movimiento = v.Id_Movimiento - JOIN vn2008.Tipos tp ON tp.tipo_id = v.tipo_id - JOIN vn2008.reinos r ON r.id = tp.reino_id - JOIN vn.ticket t ON t.id = m.Id_Ticket - WHERE tm.period BETWEEN periodStart AND periodEnd - AND t.clientFk NOT IN(400,200) - AND t.warehouseFk NOT IN (0,13) - GROUP BY m.Id_Article, Periodo, t.warehouseFk; -END$$ -DELIMITER ; diff --git a/db/routines/bi/procedures/defaultersFromDate.sql b/db/routines/bi/procedures/defaultersFromDate.sql index 267c90dab..bfe133750 100644 --- a/db/routines/bi/procedures/defaultersFromDate.sql +++ b/db/routines/bi/procedures/defaultersFromDate.sql @@ -2,7 +2,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`defaultersFromDate`(IN vDate DATE) BEGIN - SELECT t1.*, c.Cliente, w.code AS workerCode, c.pay_met_id,c.Vencimiento + SELECT t1.*, c.name Cliente, w.code workerCode, c.payMethodFk pay_met_id, c.dueDay Vencimiento FROM ( -- Filtramos aquellos clientes cuyo saldo se ha incrementado de ayer a hoy select * from( @@ -18,7 +18,7 @@ BEGIN having today.amount > 0 and difference <> 0 ) newDefaulters - )t1 left join vn2008.Clientes c ON t1.client = c.Id_Cliente - left join vn.worker w ON w.id = c.Id_Trabajador; + )t1 left join vn.client c ON c.id = t1.client + left join vn.worker w ON w.id = c.salesPersonFk; END$$ DELIMITER ; diff --git a/db/routines/bi/procedures/defaulting.sql b/db/routines/bi/procedures/defaulting.sql index e8ba5e682..3ff9bc4a1 100644 --- a/db/routines/bi/procedures/defaulting.sql +++ b/db/routines/bi/procedures/defaulting.sql @@ -8,10 +8,11 @@ BEGIN DECLARE vAmountInvoice DECIMAL(10,2); DECLARE vGraceDays INT; DECLARE defaulters CURSOR FOR - SELECT client, amount, graceDays FROM bi.defaulters d - JOIN vn2008.Clientes c ON c.Id_Cliente = d.client - JOIN vn2008.pay_met pm ON pm.id = c.pay_met_id - WHERE hasChanged AND date = vDate; + SELECT d.client, d.amount, pm.graceDays + FROM bi.defaulters d + JOIN vn.client c ON c.id = d.client + JOIN vn.payMethod pm ON pm.id = c.pay_met_id + WHERE hasChanged AND date = vDate; DECLARE invoices CURSOR FOR SELECT dued Vencimiento, amount importe FROM vn.invoiceOut diff --git a/db/routines/bi/views/last_Id_Cubo.sql b/db/routines/bi/views/last_Id_Cubo.sql deleted file mode 100644 index 758b524fd..000000000 --- a/db/routines/bi/views/last_Id_Cubo.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `bi`.`last_Id_Cubo` -AS SELECT `C`.`Id_Compra` AS `Id_Compra`, - `C`.`Id_Article` AS `Id_Article`, - `tr`.`warehouse_id` AS `warehouse_id`, - `C`.`Id_Cubo` AS `Id_Cubo`, - `C`.`Packing` AS `Packing` -FROM ( - ( - `vn2008`.`Compres` `C` - JOIN `vn2008`.`Entradas` `E` ON(`C`.`Id_Entrada` = `E`.`Id_Entrada`) - ) - JOIN `vn2008`.`travel` `tr` ON(`E`.`travel_id` = `tr`.`id`) - ) -WHERE `C`.`Id_Cubo` IS NOT NULL - AND `C`.`Id_Cubo` <> '--' - AND `tr`.`landing` > `util`.`VN_CURDATE`() - INTERVAL 18 MONTH -ORDER BY `C`.`Id_Compra` DESC diff --git a/db/routines/bi/views/v_ventas_contables.sql b/db/routines/bi/views/v_ventas_contables.sql deleted file mode 100644 index 82bbeeaac..000000000 --- a/db/routines/bi/views/v_ventas_contables.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `bi`.`v_ventas_contables` -AS SELECT `time`.`year` AS `year`, - `time`.`month` AS `month`, - cast( - sum( - `m`.`Cantidad` * `m`.`Preu` * (100 - `m`.`Descuento`) / 100 - ) AS decimal(10, 0) - ) AS `importe` -FROM ( - ( - ( - `vn`.`ticket` `t` - JOIN `bi`.`f_tvc` ON(`t`.`id` = `bi`.`f_tvc`.`Id_Ticket`) - ) - JOIN `vn2008`.`Movimientos` `m` ON(`t`.`id` = `m`.`Id_Ticket`) - ) - JOIN `vn2008`.`time` ON(`time`.`date` = cast(`t`.`shipped` AS date)) - ) -WHERE `t`.`shipped` >= '2014-01-01' -GROUP BY `time`.`year`, - `time`.`month` diff --git a/db/routines/bs/procedures/bancos_evolution_add.sql b/db/routines/bs/procedures/bancos_evolution_add.sql deleted file mode 100644 index f0a3b3709..000000000 --- a/db/routines/bs/procedures/bancos_evolution_add.sql +++ /dev/null @@ -1,112 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`bancos_evolution_add`(vStartingDate DATE) -BEGIN -/** - * Inserta en la tabla bancos_evolution los saldos acumulados de cada banco - * - * @param vStartingDate Fecha desde la cual se recalculan la tabla bs.bancos_evolution - */ - DECLARE vCurrentDate DATE; - DECLARE vMaxDate DATE DEFAULT TIMESTAMPADD(MONTH, 7, util.VN_CURDATE()); - IF IFNULL(vStartingDate,0) < TIMESTAMPADD(YEAR, -5, util.VN_CURDATE()) THEN - CALL util.throw('invalid date'); - END IF; - DELETE FROM bs.bancos_evolution WHERE Fecha >= vStartingDate; - - SET vCurrentDate = vStartingDate; - - INSERT INTO bs.bancos_evolution(Fecha, Id_Banco, saldo) - SELECT vCurrentDate, Id_Banco, deuda - FROM bs.bancos_evolution - WHERE Fecha = TIMESTAMPADD(DAY,-1,vCurrentDate); - - WHILE vCurrentDate < vMaxDate DO --- insertar solo el dia de ayer - INSERT INTO bs.bancos_evolution(Fecha ,Id_Banco, saldo) - SELECT vCurrentDate, Id_Banco, SUM(saldo) - FROM ( - SELECT Id_Banco ,saldo - FROM bs.bancos_evolution - WHERE Fecha = TIMESTAMPADD(DAY,-1,vCurrentDate) -- los saldos acumulados del dia anterior - UNION ALL - - SELECT c.Id_Banco, IFNULL(SUM(Entrada),0) - IFNULL(SUM(Salida),0) as saldo - FROM vn2008.Cajas c - JOIN vn2008.Bancos b using(Id_Banco) -- saldos de las cajas - JOIN vn.accountingType at2 ON at2.id = b.cash - WHERE at2.code IN ('wireTransfer','fundingLine') - AND Cajafecha = vCurrentDate - AND (Serie = 'MB' OR at2.code = 'fundingLine') - GROUP BY Id_Banco - )sub - GROUP BY Id_Banco - ON DUPLICATE KEY UPDATE saldo = saldo + VALUES(saldo); - - SET vCurrentDate = TIMESTAMPADD(DAY,1,vCurrentDate); - - END WHILE; - - -- Ahora actualizamos la quilla - UPDATE bs.bancos_evolution be - JOIN - ( - SELECT bp.Id_Banco, - sum(bp.importe) as quilla, t.dated - FROM vn.time t - JOIN vn2008.Bancos_poliza bp ON t.dated between apertura AND IFNULL(cierre, t.dated) - WHERE t.dated BETWEEN vStartingDate AND vMaxDate - GROUP BY Id_Banco, t.dated - ) sub ON be.Id_Banco = sub.Id_Banco AND sub.dated = be.Fecha - SET be.quilla = sub.quilla; - - -- pagos futuros no concilidados - INSERT INTO bs.bancos_evolution(Fecha, Id_Banco, saldo) - SELECT t.dated, p.id_banco, - importe - FROM vn.time t - join vn2008.pago p ON p.fecha <= t.dated - WHERE t.dated BETWEEN util.VN_CURDATE() AND vMaxDate - AND p.fecha BETWEEN util.VN_CURDATE() AND vMaxDate - AND NOT conciliado - ON DUPLICATE KEY UPDATE saldo = saldo + VALUES(saldo); - - -- cobros futuros - INSERT INTO bs.bancos_evolution(Fecha, Id_Banco, saldo) - SELECT t.dated, r.Id_Banco, SUM(Entregado) - FROM vn.time t - JOIN vn2008.Recibos r ON r.Fechacobro <= t.dated - WHERE r.Fechacobro > util.VN_CURDATE() AND r.Fechacobro <= vMaxDate - AND t.dated BETWEEN util.VN_CURDATE() AND vMaxDate - GROUP BY t.dated, r.Id_Banco - ON DUPLICATE KEY UPDATE saldo = saldo + VALUES(saldo); - - -- saldos de la tabla prevision - INSERT INTO bs.bancos_evolution(Fecha, Id_Banco, saldo) - SELECT t.dated, sp.Id_Banco, SUM(Importe) - FROM vn.time t - JOIN vn2008.Saldos_Prevision sp ON sp.Fecha <= t.dated - JOIN vn2008.Bancos b ON sp.Id_Banco = b.Id_Banco - JOIN vn.accountingType at2 ON at2.id = b.cash - WHERE at2.code IN ('wireTransfer','fundingLine') - AND t.dated BETWEEN vStartingDate AND vMaxDate - GROUP BY t.dated, sp.Id_Banco - ON DUPLICATE KEY UPDATE saldo = saldo + VALUES(saldo); - - -- Utilizamos el saldo_auxiliar para calcular lo dispuesto en las polizas - UPDATE bs.bancos_evolution be - SET saldo_aux = saldo - WHERE Fecha >= vStartingDate; - - -- Deuda - UPDATE bs.bancos_evolution be - JOIN vn2008.Bancos b using(Id_Banco) - JOIN vn.accountingType at2 ON at2.id = b.cash - SET be.deuda = IF(at2.code = 'fundingLine', be.saldo_aux, 0) - , be.saldo = IF(at2.code = 'fundingLine', 0, be.saldo_aux) - WHERE Fecha >= vStartingDate; - - -- Liquidez - update bs.bancos_evolution set liquidez = saldo - quilla + deuda WHERE Fecha >= vStartingDate; - -- Disponibilidad - update bs.bancos_evolution set `disponibilidad ajena` = - quilla + deuda WHERE Fecha >= vStartingDate; - -END$$ -DELIMITER ; diff --git a/db/routines/bs/procedures/comercialesCompleto.sql b/db/routines/bs/procedures/comercialesCompleto.sql deleted file mode 100644 index 96cab5b4f..000000000 --- a/db/routines/bs/procedures/comercialesCompleto.sql +++ /dev/null @@ -1,111 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`comercialesCompleto`(IN vWorker INT, vDate DATE) -BEGIN - DECLARE vAYearAgoStarted DATE DEFAULT DATE_FORMAT(TIMESTAMPADD(YEAR, - 1, vDate), '%Y-%m-01'); - DECLARE vAYearAgoEnded DATE DEFAULT TIMESTAMPADD(YEAR, - 1, LAST_DAY(vDate)); - - CALL vn.worker_GetHierarchy(vWorker); - - INSERT IGNORE INTO tmp.workerHierarchyList (workerFk) - SELECT wd2.workerFk - FROM vn.workerDepartment wd2 - WHERE wd2.workerFk = vWorker; - - -- Falta que en algunos casos solo tenga en cuenta los tipos afectados. - SELECT - c.Id_Cliente id_cliente, - c.Cliente cliente, - cr.recobro * 100 tarifa, - c.Telefono telefono, - c.movil, - c.POBLACION poblacion, - p.`name` provincia, - ROUND(f.futur, 2) futur, - c.Credito credito, - pm.`name` forma_pago, - ROUND(c365 / 12, 2) consumo_medio365, - ROUND(c365, 2) consumo365, - ROUND(CmLy.peso, 2) peso_mes_año_pasado, - ROUND(CmLy.peso * 1.19, 2) objetivo, - tr.CodigoTrabajador, - ROUND(mes_actual.consumo, 2) consumoMes, - ROUND(IFNULL(mes_actual.consumo, 0) - IFNULL(CmLy.peso * 1.19, 0), 2) como_lo_llevo, - DATE(LastTicket) ultimo_ticket, - dead.muerto, - g.Greuge, - cr.recobro - FROM - vn2008.Clientes c - LEFT JOIN - (SELECT g.clientFk Id_Cliente, CAST( SUM(g.amount) as DECIMAL(12,2)) AS Greuge - FROM vn.greuge g - JOIN vn.`client` c ON c.id = g.clientFk - LEFT JOIN vn.worker w ON c.salesPersonFk = w.id - WHERE (c.salesPersonFk = vWorker OR w.bossFk = vWorker) - GROUP BY Id_Cliente - ) g ON g.Id_Cliente = c.Id_Cliente - LEFT JOIN - vn2008.province p ON p.province_id = c.province_id - JOIN - vn2008.pay_met pm ON pm.id = c.pay_met_id - LEFT JOIN - vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador - LEFT JOIN - bi.claims_ratio cr on cr.Id_Cliente = c.Id_Cliente - LEFT JOIN - (SELECT v.Id_Cliente, SUM(importe) c365 -- optimizat de 6s /5.3s/ 4.7s a 0.3/0.4/0.3 - FROM bs.ventas v - JOIN vn2008.Clientes c ON c.Id_Cliente = v.Id_Cliente - WHERE v.fecha BETWEEN TIMESTAMPADD(YEAR, - 1, vDate) AND vDate - GROUP BY v.Id_Cliente) c365 ON c365.Id_Cliente = c.Id_Cliente - LEFT JOIN - (SELECT - Id_Cliente, SUM(importe) consumo - FROM - bs.ventas v - INNER JOIN vn2008.Clientes c USING (Id_Cliente) - LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador - WHERE - (c.Id_Trabajador = vWorker OR tr.boss = vWorker) - AND (v.fecha BETWEEN TIMESTAMPADD(DAY, - DAY(vDate) + 1, vDate) AND TIMESTAMPADD(DAY, - 1, vDate)) - GROUP BY Id_Cliente) mes_actual ON mes_actual.Id_Cliente = c.Id_Cliente - LEFT JOIN - (SELECT t.clientFk Id_Cliente, SUM(m.preu * m.Cantidad * (1 - m.Descuento / 100)) futur - FROM vn.ticket t - JOIN vn2008.Clientes c ON c.Id_Cliente = t.clientFk - JOIN vn2008.Movimientos m ON m.Id_Ticket = t.id - LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador - WHERE - (c.Id_Trabajador = vWorker OR tr.boss = vWorker) - AND t.shipped BETWEEN vDate AND util.dayEnd(LAST_DAY(vDate)) - GROUP BY Id_Cliente) f ON c.Id_Cliente = f.Id_Cliente - LEFT JOIN - (SELECT MAX(t.shipped) LastTicket, c.Id_Cliente - FROM vn.ticket t - JOIN vn2008.Clientes c ON c.Id_cliente = t.clientFk - LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador - WHERE - (c.Id_Trabajador = vWorker OR tr.boss = vWorker) - GROUP BY t.clientFk) LastTicket ON LastTicket.Id_Cliente = c.Id_Cliente - LEFT JOIN - ( - SELECT SUM(importe) peso, c.Id_Cliente - FROM bs.ventas v - JOIN vn2008.Clientes c ON c.Id_Cliente = v.Id_Cliente - LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador - WHERE fecha BETWEEN vAYearAgoStarted and vAYearAgoEnded - AND (c.Id_Trabajador = vWorker OR tr.boss = vWorker) - GROUP BY c.Id_Cliente) CmLy ON CmLy.Id_Cliente = c.Id_Cliente - LEFT JOIN - (SELECT c.Id_Cliente, - IF(MAX(io.issued) < DATE_FORMAT(TIMESTAMPADD(MONTH, - 1, vDate), '%Y- %m-01'), TRUE, FALSE) muerto - FROM vn.invoiceOut io - JOIN vn2008.Clientes c ON c.Id_cliente = io.clientFk - LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador - WHERE (c.Id_Trabajador = vWorker OR tr.boss = vWorker) - GROUP BY Id_Cliente) dead ON dead.Id_Cliente = c.Id_Cliente - JOIN tmp.workerHierarchyList s ON s.workerFk = c.Id_Trabajador; - - DROP TEMPORARY TABLE tmp.workerHierarchyList; -END$$ -DELIMITER ; diff --git a/db/routines/bs/procedures/indicatorsUpdate.sql b/db/routines/bs/procedures/indicatorsUpdate.sql index b2a3ee8b3..d66e52a61 100644 --- a/db/routines/bs/procedures/indicatorsUpdate.sql +++ b/db/routines/bs/procedures/indicatorsUpdate.sql @@ -15,10 +15,10 @@ BEGIN SET lastYearSales = (SELECT SUM(importe + recargo) FROM ventas v - JOIN vn2008.empresa e ON e.id = v.empresa_id - JOIN vn2008.empresa_grupo eg ON eg.empresa_grupo_id = e.empresa_grupo + JOIN vn.company c ON c.id = v.empresa_id + JOIN vn.companyGroup cg ON cg.id = c.companyGroupFk WHERE fecha BETWEEN oneYearBefore AND vDated - AND eg.grupo = 'Verdnatura' + AND cg.code = 'Verdnatura' ) WHERE updated = vDated; diff --git a/db/routines/bs/procedures/manaCustomerUpdate.sql b/db/routines/bs/procedures/manaCustomerUpdate.sql index f53d293b3..b77ddc1fd 100644 --- a/db/routines/bs/procedures/manaCustomerUpdate.sql +++ b/db/routines/bs/procedures/manaCustomerUpdate.sql @@ -67,20 +67,20 @@ BEGIN vToDated FROM ( - SELECT cs.Id_Cliente, Cantidad * Valor as mana + SELECT a.clientFk Id_Cliente, s.quantity * sc.value as mana FROM vn.ticket t - JOIN vn2008.Consignatarios cs using(Id_Consigna) - JOIN vn2008.Movimientos m on m.Id_Ticket = t.id - JOIN vn2008.Movimientos_componentes mc on mc.Id_Movimiento = m.Id_Movimiento - WHERE Id_Componente IN (vManaAutoId, vManaId, vClaimManaId) + JOIN vn.address a ON a.id = t.addressFk + JOIN vn.sale s on s.ticketFk = t.id + JOIN vn.saleComponent sc on sc.saleFk = s.id + WHERE sc.componentFk IN (vManaAutoId, vManaId, vClaimManaId) AND t.shipped > vFromDated AND date(t.shipped) <= vToDated UNION ALL - SELECT r.Id_Cliente, - Entregado - FROM vn2008.Recibos r - WHERE Id_Banco = vManaBankId - AND Fechacobro > vFromDated - AND Fechacobro <= vToDated + SELECT clientFk, - amountPaid + FROM vn.receipt + WHERE bankFk = vManaBankId + AND payed > vFromDated + AND payed <= vToDated UNION ALL SELECT clientFk, amount FROM vn.greuge diff --git a/db/routines/bs/procedures/ventas_contables_add.sql b/db/routines/bs/procedures/ventas_contables_add.sql index ad4e80a06..5ebd550b4 100644 --- a/db/routines/bs/procedures/ventas_contables_add.sql +++ b/db/routines/bs/procedures/ventas_contables_add.sql @@ -38,35 +38,35 @@ BEGIN SELECT vYear , vMonth - , round(sum(Cantidad * Preu * (100 - m.Descuento)/100)) + , round(sum(s.quantity * s.price * (100 - s.discount)/100)) , IF( - e.empresa_grupo = e2.empresa_grupo + co.companyGroupFk = co2.companyGroupFk ,1 - ,IF(e2.empresa_grupo,2,0) + ,IF(co2.companyGroupFk,2,0) ) as grupo - , tp.reino_id - , a.tipo_id + , it.categoryFk + , i.typeFk , t.companyFk - , a.expenseFk - + IF(e.empresa_grupo = e2.empresa_grupo + , i.expenseFk + + IF(co.companyGroupFk = co2.companyGroupFk ,1 - ,IF(e2.empresa_grupo,2,0) + ,IF(co2.companyGroupFk,2,0) ) * 100000 - + tp.reino_id * 1000 as Gasto - FROM vn2008.Movimientos m - JOIN vn.ticket t ON t.id = m.Id_Ticket - JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.addressFk - JOIN vn2008.Clientes c on c.Id_Cliente = cs.Id_Cliente + + it.categoryFk * 1000 as Gasto + FROM vn.sale s + JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.address a on a.id = t.addressFk + JOIN vn.client c on c.id = a.clientFk JOIN tmp.ticket_list tt on tt.id = t.id - JOIN vn2008.Articles a on m.Id_Article = a.Id_Article - JOIN vn2008.empresa e on e.id = t.companyFk - LEFT JOIN vn2008.empresa e2 on e2.Id_Cliente = c.Id_Cliente - JOIN vn2008.Tipos tp on tp.tipo_id = a.tipo_id - WHERE Cantidad <> 0 - AND Preu <> 0 - AND m.Descuento <> 100 - AND a.tipo_id != TIPO_PATRIMONIAL - GROUP BY grupo, reino_id, tipo_id, companyFk, Gasto; + JOIN vn.item i on s.itemFk = i.Id_Ticket + JOIN vn.company co on co.id = t.companyFk + LEFT JOIN vn.company co2 on co2.clientFk = c.id + JOIN vn.itemType it on it.id = i.typeFk + WHERE s.quantity <> 0 + AND s.price <> 0 + AND s.discount <> 100 + AND i.typeFk <> TIPO_PATRIMONIAL + GROUP BY grupo, it.categoryFk, i.typeFk, t.companyFk, Gasto; INSERT INTO bs.ventas_contables(year , month diff --git a/db/routines/bs/procedures/ventas_contables_por_cliente.sql b/db/routines/bs/procedures/ventas_contables_por_cliente.sql deleted file mode 100644 index ed3773cf7..000000000 --- a/db/routines/bs/procedures/ventas_contables_por_cliente.sql +++ /dev/null @@ -1,47 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`ventas_contables_por_cliente`(IN vYear INT, IN vMonth INT) -BEGIN - - /** - * Muestra las ventas (€) de cada cliente - * dependiendo del año - */ - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; - - CREATE TEMPORARY TABLE tmp.ticket_list - (PRIMARY KEY (id)) - SELECT t.id - FROM vn.ticket t - JOIN vn.invoiceOut io ON io.id = t.refFk - WHERE year(io.issued) = vYear - AND month(io.issued) = vMonth; - - SELECT vYear Año, - vMonth Mes, - t.clientFk Id_Cliente, - round(sum(Cantidad * Preu * (100 - m.Descuento)/100)) Venta, - IF(e.empresa_grupo = e2.empresa_grupo, - 1, - IF(e2.empresa_grupo,2,0)) - AS grupo, - t.companyFk empresa - FROM vn2008.Movimientos m - JOIN vn.ticket t ON t.id = m.Id_Ticket - JOIN vn2008.Consignatarios cs ON cs.Id_Consigna = t.addressFk - JOIN vn2008.Clientes c ON c.Id_Cliente = cs.Id_Cliente - JOIN tmp.ticket_list tt ON tt.id = t.id - JOIN vn2008.Articles a ON m.Id_Article = a.Id_Article - JOIN vn2008.empresa e ON e.id = t.companyFk - LEFT JOIN vn2008.empresa e2 ON e2.Id_Cliente = c.Id_Cliente - JOIN vn2008.Tipos tp ON tp.tipo_id = a.tipo_id - WHERE Cantidad <> 0 - AND Preu <> 0 - AND m.Descuento <> 100 - AND a.tipo_id != 188 - GROUP BY t.clientFk, grupo,t.companyFk; - - DROP TEMPORARY TABLE tmp.ticket_list; - -END$$ -DELIMITER ; diff --git a/db/routines/bs/procedures/vivosMuertos.sql b/db/routines/bs/procedures/vivosMuertos.sql deleted file mode 100644 index c07570603..000000000 --- a/db/routines/bs/procedures/vivosMuertos.sql +++ /dev/null @@ -1,63 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`vivosMuertos`() -BEGIN - - /** - * Devuelve el número de clientes nuevos y muertos, - * dependiendo de la fecha actual. - * - * @param @datSTART Fecha de inicio a buscar - * @param @datEND Fecha de finalización a buscar - */ - - SET @datSTART = TIMESTAMPADD(YEAR,-2,util.VN_CURDATE()); - SET @datEND = TIMESTAMPADD(DAY,-DAY(util.VN_CURDATE()),util.VN_CURDATE()); - - DROP TEMPORARY TABLE IF EXISTS tmp.VivosMuertos; - - CREATE TEMPORARY TABLE tmp.VivosMuertos - SELECT c.Id_Cliente, tm.yearMonth, f.Compra, 0 as Nuevo, 0 as Muerto - FROM vn2008.Clientes c - JOIN - (SELECT DISTINCT yearMonth - FROM vn2008.time - WHERE date BETWEEN @datSTART - AND @datEND ) tm - LEFT JOIN - (SELECT DISTINCT tm.yearMonth, io.clientFk Id_Cliente , 1 as Compra - FROM vn.invoiceOut io - JOIN vn2008.time tm ON tm.date = io.issued - WHERE io.issued BETWEEN @datSTART - AND @datEND) f ON f.yearMonth = tm.yearMonth - AND f.Id_Cliente = c.Id_Cliente; - - UPDATE tmp.VivosMuertos vm - JOIN - (SELECT MIN(tm.yearMonth) firstMonth, io.clientFk Id_Cliente - FROM vn.invoiceOut io - JOIN vn2008.time tm ON tm.date = io.issued - WHERE io.issued BETWEEN @datSTART AND @datEND - GROUP BY io.clientFk) fm ON fm.firstMonth = vm.yearMonth - AND fm.Id_Cliente = vm.Id_Cliente - - SET Nuevo = 1; - - SELECT max(yearMonth) INTO @lastYearMonth FROM tmp.VivosMuertos; - - UPDATE tmp.VivosMuertos vm - JOIN ( - SELECT MAX(tm.yearMonth) firstMonth, io.clientFk Id_Cliente - FROM vn.invoiceOut io - JOIN vn2008.time tm ON tm.date = io.issued - WHERE io.issued BETWEEN @datSTART AND @datEND - GROUP BY io.clientFk) fm ON fm.firstMonth = vm.yearMonth - AND fm.Id_Cliente = vm.Id_Cliente - - SET Muerto = 1 - - WHERE yearMonth < @lastYearMonth; - - SELECT * FROM tmp.VivosMuertos; - -END$$ -DELIMITER ; diff --git a/db/routines/bs/views/VentasPorCliente.sql b/db/routines/bs/views/VentasPorCliente.sql deleted file mode 100644 index 579d3b955..000000000 --- a/db/routines/bs/views/VentasPorCliente.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `bs`.`VentasPorCliente` -AS SELECT `v`.`Id_Cliente` AS `Id_Cliente`, - round(sum(`v`.`importe`), 0) AS `VentaBasica`, - `t`.`year` AS `year`, - `t`.`month` AS `month` -FROM ( - `vn2008`.`time` `t` - JOIN `bs`.`ventas` `v` ON(`v`.`fecha` = `t`.`date`) - ) -GROUP BY `v`.`Id_Cliente`, - `t`.`year`, - `t`.`month` diff --git a/db/routines/bs/views/bajasLaborales.sql b/db/routines/bs/views/bajasLaborales.sql deleted file mode 100644 index 31f870d06..000000000 --- a/db/routines/bs/views/bajasLaborales.sql +++ /dev/null @@ -1,31 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `bs`.`bajasLaborales` -AS SELECT `w`.`firstName` AS `firstname`, - `w`.`lastName` AS `name`, - `b`.`id` AS `businessFk`, - max(`c`.`dated`) AS `lastDate`, - max(IFNULL(`b`.`ended`, `util`.`VN_CURDATE`())) AS `endContract`, - `at`.`name` AS `type`, - cast(COUNT(0) AS decimal(10, 0)) AS `dias`, - `w`.`id` AS `userFk` -FROM ( - ( - ( - `vn`.`calendar` `c` - JOIN `vn`.`business` `b` ON(`b`.`id` = `c`.`businessFk`) - ) - JOIN `vn`.`worker` `w` ON(`w`.`id` = `b`.`workerFk`) - ) - JOIN `vn`.`absenceType` `at` ON(`at`.`id` = `c`.`dayOffTypeFk`) - ) -WHERE `c`.`dated` >= `util`.`VN_CURDATE`() + INTERVAL -1 year - AND `at`.`name` NOT IN ( - 'Vacaciones', - 'Vacaciones 1/2 día', - 'Compensar', - 'Festivo' - ) -GROUP BY `w`.`id`, - `at`.`id` -HAVING `endContract` >= `util`.`VN_CURDATE`() diff --git a/db/routines/bs/views/horasSilla.sql b/db/routines/bs/views/horasSilla.sql deleted file mode 100644 index 973108e8a..000000000 --- a/db/routines/bs/views/horasSilla.sql +++ /dev/null @@ -1,27 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `bs`.`horasSilla` -AS SELECT `wj`.`dated` AS `Fecha`, - `d`.`name` AS `Departamento`, - cast(sum(`wj`.`total`) AS decimal(10, 2)) AS `Horas`, - cast( - sum( - (`wj`.`total` + `wj`.`lunch`) * `wj`.`priceOrdinaryHour` - ) AS decimal(10, 2) - ) AS `Salarios` -FROM ( - ( - `vn`.`workerJourney` `wj` - JOIN `vn`.`business` `b` ON(`b`.`id` = `wj`.`businessFk`) - ) - JOIN `vn`.`department` `d` ON(`d`.`id` = `b`.`departmentFk`) - ) -WHERE `d`.`name` IN ( - 'CAMARA', - 'ENCAJADO', - 'PALETIZADORES', - 'PRODUCCION', - 'SACADORES' - ) -GROUP BY `wj`.`dated`, - `d`.`name` diff --git a/db/routines/bs/views/s1_ticketDetail.sql b/db/routines/bs/views/s1_ticketDetail.sql deleted file mode 100644 index 77fbcdcd9..000000000 --- a/db/routines/bs/views/s1_ticketDetail.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `bs`.`s1_ticketDetail` -AS SELECT `s`.`ticketFk` AS `ticketFk`, - cast( - sum(`s`.`price` * `s`.`quantity`) AS decimal(10, 2) - ) AS `ticketAmount`, - COUNT(`s`.`id`) AS `ticketLines`, - cast(sum(`sv`.`volume`) AS decimal(10, 2)) AS `ticketM3`, - cast(`t`.`shipped` AS date) AS `shipped` -FROM ( - ( - `vn`.`ticket` `t` - JOIN `vn`.`sale` `s` ON(`s`.`ticketFk` = `t`.`id`) - ) - JOIN `vn`.`saleVolume` `sv` ON(`sv`.`saleFk` = `s`.`id`) - ) -WHERE `t`.`shipped` BETWEEN '2021-09-01' AND '2021-10-31 23:59' -GROUP BY `s`.`ticketFk` diff --git a/db/routines/bs/views/s21_saleDetail.sql b/db/routines/bs/views/s21_saleDetail.sql deleted file mode 100644 index 778994bfb..000000000 --- a/db/routines/bs/views/s21_saleDetail.sql +++ /dev/null @@ -1,42 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `bs`.`s21_saleDetail` -AS SELECT dayofmonth(`t`.`shipped`) AS `dia`, - year(`t`.`shipped`) AS `año`, - MONTH(`t`.`shipped`) AS `mes`, - `s`.`concept` AS `concepto`, - `s`.`quantity` AS `unidades`, - `s`.`price` AS `precio`, - `s`.`quantity` * `s`.`price` AS `venta`, - `it`.`name` AS `familia`, - `w`.`code` AS `comprador`, - `s`.`itemFk` AS `itemFk`, - `s`.`ticketFk` AS `ticketFk`, - `sv`.`volume` AS `volume` -FROM ( - ( - ( - ( - ( - ( - `vn`.`sale` `s` - JOIN `vn`.`item` `i` ON(`i`.`id` = `s`.`itemFk`) - ) - JOIN `vn`.`itemType` `it` ON(`it`.`id` = `i`.`typeFk`) - ) - JOIN `vn`.`worker` `w` ON(`w`.`id` = `it`.`workerFk`) - ) - JOIN `vn`.`ticket` `t` ON(`t`.`id` = `s`.`ticketFk`) - ) - JOIN `vn`.`client` `c` ON(`c`.`id` = `t`.`clientFk`) - ) - JOIN `vn`.`saleVolume` `sv` ON(`sv`.`saleFk` = `s`.`id`) - ) -WHERE ( - `t`.`shipped` BETWEEN '2020-10-21' AND '2020-10-28' - OR `t`.`shipped` BETWEEN '2019-10-21' AND '2019-10-28' - OR `t`.`shipped` BETWEEN '2021-09-1' AND '2021-10-28' - ) - AND `t`.`warehouseFk` IN (1, 60) - AND `c`.`isRelevant` <> 0 - AND `s`.`quantity` > 0 diff --git a/db/routines/cache/procedures/prod_graphic_refresh.sql b/db/routines/cache/procedures/prod_graphic_refresh.sql deleted file mode 100644 index edeeba436..000000000 --- a/db/routines/cache/procedures/prod_graphic_refresh.sql +++ /dev/null @@ -1,36 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`prod_graphic_refresh`(v_refresh BOOL, wh_id INT) -proc: BEGIN - DECLARE datEQ DATETIME; - DECLARE timDIF TIME; - DECLARE v_calc INT; - - CALL cache_calc_start (v_calc, v_refresh, 'prod_graphic', wh_id); - - IF !v_refresh - THEN - LEAVE proc; - END IF; - - CALL vn2008.production_control_source(wh_id, 0); - - DELETE FROM prod_graphic_source; - - INSERT INTO prod_graphic_source (warehouse_id, graphCategory, m3, hora, `order`, Agencia) - SELECT - wh_id, - st.graphCategory, - CAST(SUM(m3) AS DECIMAL(10,0)) as m3, - pb.Hora, - pb.state_order, - pb.Agencia - FROM tmp.production_buffer pb - JOIN vn.state st ON st.id = pb.state - WHERE Fecha = util.VN_CURDATE() - GROUP BY wh_id, graphCategory - ; - - - CALL cache_calc_end (v_calc); -END$$ -DELIMITER ; diff --git a/db/routines/edi/procedures/ekt_load.sql b/db/routines/edi/procedures/ekt_load.sql index 9ec0c81d4..190b09a86 100644 --- a/db/routines/edi/procedures/ekt_load.sql +++ b/db/routines/edi/procedures/ekt_load.sql @@ -70,16 +70,16 @@ proc:BEGIN ELSE - INSERT IGNORE INTO vn2008.Cubos (Id_Cubo, X, Y, Z) + INSERT IGNORE INTO vn.packaging (id, width, depth, height) SELECT bucket_id, ROUND(x_size/10), ROUND(y_size/10), ROUND(z_size/10) FROM bucket WHERE bucket_id = vPackage; IF ROW_COUNT() > 0 THEN - INSERT INTO vn2008.mail SET + INSERT INTO vn.mail SET `subject` = 'Cubo añadido', - `text` = CONCAT('Se ha añadido el cubo: ', vPackage), - `to` = 'ekt@verdnatura.es'; + `body` = CONCAT('Se ha añadido el cubo: ', vPackage), + `receiver` = 'ekt@verdnatura.es'; END IF; END IF; diff --git a/db/routines/vn/functions/getAlert3StateTest.sql b/db/routines/vn/functions/getAlert3StateTest.sql deleted file mode 100644 index f1a8ac4cc..000000000 --- a/db/routines/vn/functions/getAlert3StateTest.sql +++ /dev/null @@ -1,40 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`getAlert3StateTest`(vTicket INT) - RETURNS varchar(45) CHARSET latin1 COLLATE latin1_swedish_ci - NOT DETERMINISTIC - READS SQL DATA -BEGIN - DECLARE vDeliveryType INTEGER DEFAULT 0; - DECLARE isWaitingForPickUp BOOLEAN DEFAULT FALSE; - DECLARE vCode VARCHAR(45); - - SELECT - a.Vista - INTO vDeliveryType - FROM ticket t - JOIN vn2008.Agencias a ON a.Id_Agencia = t.agencyModeFk - WHERE t.id = vTicket; - - CASE vDeliveryType - WHEN 1 THEN -- AGENCIAS - SET vCode = 'DELIVERED'; - - WHEN 2 THEN -- REPARTO - SET vCode = 'ON_DELIVERY'; - - ELSE -- MERCADO, OTROS - SELECT t.warehouseFk <> w.warehouse_id INTO isWaitingForPickUp - FROM ticket t - LEFT JOIN vn2008.warehouse_pickup w - ON w.agency_id = t.agencyModeFk AND w.warehouse_id = t.warehouseFk - WHERE t.id = vTicket; - - IF isWaitingForPickUp THEN - SET vCode = 'WAITING_FOR_PICKUP'; - ELSE - SET vCode = 'DELIVERED'; - END IF; - END CASE; - RETURN vCode; -END$$ -DELIMITER ; diff --git a/db/routines/vn/functions/ticketPositionInPath.sql b/db/routines/vn/functions/ticketPositionInPath.sql index 9a3bb4a0e..5e75d868d 100644 --- a/db/routines/vn/functions/ticketPositionInPath.sql +++ b/db/routines/vn/functions/ticketPositionInPath.sql @@ -26,11 +26,11 @@ SELECT t.routeFk, t.warehouseFk, IFNULL(ts.productionOrder,0) LEFT JOIN ticketState ts on ts.ticketFk = t.id WHERE t.id = vTicketId; -SELECT (ag.`name` = 'VN_VALENCIA') +SELECT (a.`name` = 'VN_VALENCIA') INTO vIsValenciaPath FROM `route` r - JOIN vn2008.Agencias a on a.Id_Agencia = r.agencyModeFk - JOIN vn2008.agency ag on ag.agency_id = a.agency_id + JOIN agencyMode am on am.id = r.agencyModeFk + JOIN agency a on a.id = am.agencyFk WHERE r.id = vMyPath; IF vIsValenciaPath THEN -- Rutas Valencia diff --git a/db/routines/vn/functions/ticketSplitCounter.sql b/db/routines/vn/functions/ticketSplitCounter.sql index a04c4f8a9..e82c079ae 100644 --- a/db/routines/vn/functions/ticketSplitCounter.sql +++ b/db/routines/vn/functions/ticketSplitCounter.sql @@ -9,9 +9,9 @@ BEGIN SELECT CONCAT(printedStickers,'/',Total, IF(printedStickers = Total ,' LS','')) INTO vSplitCounter FROM ( - SELECT count(l.Id_Movimiento) as printedStickers, COUNT(*) as Total - FROM vn.sale s - LEFT JOIN vn2008.movement_label l ON l.Id_Movimiento = s.id + SELECT count(sl.saleFk) as printedStickers, COUNT(*) as Total + FROM sale s + LEFT JOIN saleLabel sl ON sl.saleFk = s.id WHERE ticketFk = vTicketFk ) sub; diff --git a/db/routines/vn/procedures/itemShelvingProblem.sql b/db/routines/vn/procedures/itemShelvingProblem.sql index 01d9d6b5a..aed7572ee 100644 --- a/db/routines/vn/procedures/itemShelvingProblem.sql +++ b/db/routines/vn/procedures/itemShelvingProblem.sql @@ -20,17 +20,17 @@ BEGIN GREATEST(0,iss.visible - IFNULL(sub3.transit,0)) as Altillo, s.id as saleFk, IFNULL(sub3.transit,0) transit, - v.visible, s.isPicked, s.reserved, t.shipped, tst.productionOrder, mm.Id_Movimiento - FROM vn.ticket t - JOIN vn.ticketState tst ON tst.ticketFk = t.id - JOIN vn.sale s ON s.ticketFk = t.id - JOIN vn.item i ON i.id = s.itemFk + v.visible, s.isPicked, s.reserved, t.shipped, tst.productionOrder, st.saleFk + FROM ticket t + JOIN ticketState tst ON tst.ticketFk = t.id + JOIN sale s ON s.ticketFk = t.id + JOIN item i ON i.id = s.itemFk JOIN cache.visible v ON s.itemFk = v.item_id AND v.calc_id = vVisibleCache - LEFT JOIN vn2008.Movimientos_mark mm ON mm.Id_Movimiento = s.id AND mm.stateFk = 26 - JOIN vn.itemShelvingStock iss ON iss.itemFk = v.item_id + LEFT JOIN saleTracking st ON st.saleFk = s.id AND st.stateFk = 26 + JOIN itemShelvingStock iss ON iss.itemFk = v.item_id LEFT JOIN (SELECT itemFk, sum(saldo) as transit - FROM vn.itemPlacementSupplyList + FROM itemPlacementSupplyList WHERE saldo > 0 AND sectorFk = vSectorFk GROUP BY itemFk) sub3 ON sub3.itemFk = i.id @@ -42,7 +42,7 @@ BEGIN AND tst.isPreviousPreparable = TRUE AND t.warehouseFk = vWarehouseFk AND iss.sectorFk = vSectorFk - AND mm.Id_Movimiento IS NULL + AND st.saleFk IS NULL ORDER BY itemFk; END$$ diff --git a/db/routines/vn/procedures/item_cleanFloramondo.sql b/db/routines/vn/procedures/item_cleanFloramondo.sql index cae06ee54..080c61b5b 100644 --- a/db/routines/vn/procedures/item_cleanFloramondo.sql +++ b/db/routines/vn/procedures/item_cleanFloramondo.sql @@ -101,9 +101,6 @@ BEGIN DELETE FROM itemCost WHERE itemFk = vItemOld; - DELETE FROM vn2008.rec_translator - WHERE Id_Article = vItemOld; - DELETE FROM bs.waste WHERE itemFk = vItemOld; diff --git a/db/routines/vn/procedures/packingListPrinted.sql b/db/routines/vn/procedures/packingListPrinted.sql deleted file mode 100644 index 473ead5be..000000000 --- a/db/routines/vn/procedures/packingListPrinted.sql +++ /dev/null @@ -1,13 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`packingListPrinted`(ticketFk INT) -BEGIN - - UPDATE vn2008.Movimientos_mark mm - JOIN vn2008.Movimientos m ON m.Id_Movimiento = mm.Id_Movimiento - SET mm.valor = 2 -- Impreso - WHERE mm.valor = 1 -- Listo para imprimir - AND mm.stateFk = 9 -- Encajando - AND m.Id_Ticket = ticketFk; - -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/packingListSwitch.sql b/db/routines/vn/procedures/packingListSwitch.sql index 65384827c..0883a7b6d 100644 --- a/db/routines/vn/procedures/packingListSwitch.sql +++ b/db/routines/vn/procedures/packingListSwitch.sql @@ -5,14 +5,14 @@ BEGIN DECLARE valueFk INT; DECLARE encajando INT DEFAULT 9; - SELECT valor INTO valueFk - FROM vn2008.Movimientos_mark - WHERE Id_Movimiento = saleFk + SELECT isChecked INTO valueFk + FROM saleTracking + WHERE saleFk = saleFk AND stateFk = encajando; SET valueFk = (IFNULL(valueFk,0) + 1) MOD 3; - REPLACE vn2008.Movimientos_mark(Id_Movimiento, valor, Id_Trabajador, stateFk) + REPLACE saleTracking(saleFk, isChecked, workerFk, stateFk) VALUES(saleFk,valueFk,account.myUser_getId(),encajando); diff --git a/db/routines/vn/triggers/solunionCAP_afterInsert.sql b/db/routines/vn/triggers/solunionCAP_afterInsert.sql index 8524689a7..9907bcbab 100644 --- a/db/routines/vn/triggers/solunionCAP_afterInsert.sql +++ b/db/routines/vn/triggers/solunionCAP_afterInsert.sql @@ -3,8 +3,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`solunionCAP_afterInse AFTER INSERT ON `solunionCAP` FOR EACH ROW BEGIN - UPDATE vn2008.Clientes c - JOIN creditClassification cc ON c.Id_Cliente = cc.client + UPDATE client c + JOIN creditClassification cc ON cc.client = c.clientFk JOIN creditInsurance ci ON ci.creditClassification = cc.id SET creditInsurance = ci.credit * 2 WHERE ci.id = NEW.creditInsurance; END$$ diff --git a/db/routines/vn/triggers/solunionCAP_afterUpdate.sql b/db/routines/vn/triggers/solunionCAP_afterUpdate.sql index 688241515..62d4e0e6b 100644 --- a/db/routines/vn/triggers/solunionCAP_afterUpdate.sql +++ b/db/routines/vn/triggers/solunionCAP_afterUpdate.sql @@ -4,13 +4,13 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`solunionCAP_afterUpda FOR EACH ROW BEGIN IF NEW.dateLeaving IS NOT NULL THEN - UPDATE vn2008.Clientes c - JOIN creditClassification cc ON c.Id_Cliente = cc.client + UPDATE client c + JOIN creditClassification cc ON cc.client = c.clientFk JOIN creditInsurance ci ON ci.creditClassification = cc.id SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance; ELSE - UPDATE vn2008.Clientes c - JOIN creditClassification cc ON c.Id_Cliente = cc.client + UPDATE client c + JOIN creditClassification cc ON cc.client = c.clientFk JOIN creditInsurance ci ON ci.creditClassification = cc.id SET creditInsurance = ci.credit * 2 WHERE ci.id = OLD.creditInsurance; END IF; diff --git a/db/routines/vn/triggers/solunionCAP_beforeDelete.sql b/db/routines/vn/triggers/solunionCAP_beforeDelete.sql index 85d65a949..924310c3f 100644 --- a/db/routines/vn/triggers/solunionCAP_beforeDelete.sql +++ b/db/routines/vn/triggers/solunionCAP_beforeDelete.sql @@ -3,8 +3,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`solunionCAP_beforeDel BEFORE DELETE ON `solunionCAP` FOR EACH ROW BEGIN - UPDATE vn2008.Clientes c - JOIN creditClassification cc ON c.Id_Cliente = cc.client + UPDATE client c + JOIN creditClassification cc ON cc.client = c.clientFk JOIN creditInsurance ci ON ci.creditClassification = cc.id SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance; END$$ diff --git a/db/routines/vn/views/especialPrice.sql b/db/routines/vn/views/especialPrice.sql index 08b9b434a..79d3e1384 100644 --- a/db/routines/vn/views/especialPrice.sql +++ b/db/routines/vn/views/especialPrice.sql @@ -1,8 +1,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`especialPrice` -AS SELECT `p`.`Id_PrecioEspecial` AS `id`, - `p`.`Id_Cliente` AS `clientFk`, - `p`.`Id_Article` AS `itemFk`, - `p`.`PrecioEspecial` AS `value` -FROM `vn2008`.`PreciosEspeciales` `p` +AS SELECT `sp`.`id` AS `id`, + `sp`.`clientFk` AS `clientFk`, + `sp`.`itemFk` AS `itemFk`, + `sp`.`value` AS `value` +FROM `vn`.`specialPrice` `sp` diff --git a/db/routines/vn/views/exchangeInsurance.sql b/db/routines/vn/views/exchangeInsurance.sql deleted file mode 100644 index 5df3c2f1d..000000000 --- a/db/routines/vn/views/exchangeInsurance.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn`.`exchangeInsurance` -AS SELECT `vn2008`.`pago_sdc`.`pago_sdc_id` AS `id`, - `vn2008`.`pago_sdc`.`importe` AS `amount`, - `vn2008`.`pago_sdc`.`fecha` AS `dated`, - `vn2008`.`pago_sdc`.`vencimiento` AS `finished`, - `vn2008`.`pago_sdc`.`entity_id` AS `entityFk`, - `vn2008`.`pago_sdc`.`ref` AS `ref`, - `vn2008`.`pago_sdc`.`rate` AS `rate`, - `vn2008`.`pago_sdc`.`empresa_id` AS `companyFk`, - `vn2008`.`pago_sdc`.`financialProductTypefk` AS `financialProductTypefk`, - `vn2008`.`pago_sdc`.`upperBarrier` AS `upperBarrier`, - `vn2008`.`pago_sdc`.`lowerBarrier` AS `lowerBarrier`, - `vn2008`.`pago_sdc`.`strike` AS `strike` -FROM `vn2008`.`pago_sdc` diff --git a/db/routines/vn/views/paymentExchangeInsurance.sql b/db/routines/vn/views/paymentExchangeInsurance.sql index 7128144ea..f3e07eaaf 100644 --- a/db/routines/vn/views/paymentExchangeInsurance.sql +++ b/db/routines/vn/views/paymentExchangeInsurance.sql @@ -1,16 +1,16 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`paymentExchangeInsurance` -AS SELECT `p`.`pago_sdc_id` AS `id`, - `p`.`importe` AS `amount`, - `p`.`fecha` AS `created`, - `p`.`vencimiento` AS `dueDay`, - `p`.`entity_id` AS `entityFk`, - `p`.`ref` AS `ref`, - `p`.`rate` AS `rate`, - `p`.`empresa_id` AS `companyFk`, - `p`.`financialProductTypefk` AS `financialProductTypefk`, - `p`.`upperBarrier` AS `upperBarrier`, - `p`.`lowerBarrier` AS `lowerBarrier`, - `p`.`strike` AS `strike` -FROM `vn2008`.`pago_sdc` `p` +AS SELECT `ei`.`id` AS `pago_sdc_id`, + `ei`.`amount` AS `importe`, + `ei`.`dated` AS `fecha`, + `ei`.`dueDated` AS `vencimiento`, + `ei`.`entityFk` AS `entity_id`, + `ei`.`ref` AS `ref`, + `ei`.`rate` AS `rate`, + `ei`.`companyFk` AS `empresa_id`, + `ei`.`financialProductTypefk` AS `financialProductTypefk`, + `ei`.`upperBarrier` AS `upperBarrier`, + `ei`.`lowerBarrier` AS `lowerBarrier`, + `ei`.`strike` AS `strike` +FROM `vn`.`exchangeInsurance` `ei` diff --git a/db/routines/vn/views/promissoryNote.sql b/db/routines/vn/views/promissoryNote.sql deleted file mode 100644 index a9f047285..000000000 --- a/db/routines/vn/views/promissoryNote.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn`.`promissoryNote` -AS SELECT `p`.`Id_Pagare` AS `id`, - `p`.`Concepto` AS `Concept`, - `p`.`pago_id` AS `paymentFk` -FROM `vn2008`.`Pagares` `p` diff --git a/db/routines/vn/views/saleLabel.sql b/db/routines/vn/views/saleLabel.sql deleted file mode 100644 index 4feae9294..000000000 --- a/db/routines/vn/views/saleLabel.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn`.`saleLabel` -AS SELECT `ml`.`Id_movimiento` AS `saleFk`, - `ml`.`label` AS `label`, - `ml`.`stem` AS `stem`, - `ml`.`created` AS `created` -FROM `vn2008`.`movement_label` `ml` diff --git a/db/routines/vn/views/ticketMRW.sql b/db/routines/vn/views/ticketMRW.sql deleted file mode 100644 index 26b928ac4..000000000 --- a/db/routines/vn/views/ticketMRW.sql +++ /dev/null @@ -1,47 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn`.`ticketMRW` -AS SELECT `ticket`.`agencyModeFk` AS `id_Agencia`, - `ticket`.`companyFk` AS `empresa_id`, - `Consignatarios`.`consignatario` AS `Consignatario`, - `Consignatarios`.`domicilio` AS `DOMICILIO`, - `Consignatarios`.`poblacion` AS `POBLACION`, - `Consignatarios`.`codPostal` AS `CODPOSTAL`, - `Consignatarios`.`telefono` AS `telefono`, - IFNULL( - IFNULL( - IFNULL( - IFNULL(`Consignatarios`.`movil`, `Clientes`.`movil`), - `Consignatarios`.`telefono` - ), - `Clientes`.`telefono` - ), - 0 - ) AS `movil`, - `Clientes`.`if` AS `IF`, - `ticket`.`id` AS `Id_Ticket`, - `ticket`.`warehouseFk` AS `warehouse_id`, - `Consignatarios`.`id_consigna` AS `Id_Consigna`, - `Paises`.`Codigo` AS `CodigoPais`, - `ticket`.`shipped` AS `Fecha`, - `province`.`province_id` AS `province_id`, - `ticket`.`landed` AS `landing` -FROM ( - ( - ( - ( - `vn2008`.`Clientes` - JOIN `vn2008`.`Consignatarios` ON( - `Clientes`.`id_cliente` = `Consignatarios`.`Id_cliente` - ) - ) - JOIN `vn`.`ticket` ON( - `Consignatarios`.`id_consigna` = `ticket`.`addressFk` - ) - ) - JOIN `vn2008`.`province` ON( - `Consignatarios`.`province_id` = `province`.`province_id` - ) - ) - JOIN `vn2008`.`Paises` ON(`province`.`Paises_Id` = `Paises`.`Id`) - ); diff --git a/db/routines/vn/views/ticketToPrepare.sql b/db/routines/vn/views/ticketToPrepare.sql deleted file mode 100644 index 98302b60d..000000000 --- a/db/routines/vn/views/ticketToPrepare.sql +++ /dev/null @@ -1,58 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn`.`ticketToPrepare` -AS SELECT `m`.`Id_Ticket` AS `Id_Ticket`, - `mk`.`Id_Movimiento` AS `Id_Movimiento`, - `mk`.`Id_Movimiento_mark` AS `Id_Movimiento_mark`, - `mk`.`Id_Trabajador` AS `Id_Trabjador`, - `m`.`Id_Article` AS `Id_Article`, - `m`.`Concepte` AS `Concepte`, - `art`.`subName` AS `subName`, - `mk`.`original_quantity` - IFNULL(`is`.`quantity`, 0) AS `Cantidad`, - `mk`.`original_quantity` AS `original_quantity`, - IF( - HOUR(`t`.`shipped`), - HOUR(`t`.`shipped`), - HOUR(`z`.`hour`) - ) AS `Hora`, - HOUR(`t`.`shipped`) AS `Departure`, - MINUTE(`t`.`shipped`) AS `Minuto`, - `am`.`agencyFk` AS `agency_id`, - `t`.`warehouseFk` AS `warehouse_id`, - `a`.`provinceFk` AS `province_id`, - `is`.`quantity` AS `picked`, - `t`.`zoneFk` AS `zoneFk`, - `p`.`sectorFk` AS `sectorFk` -FROM ( - ( - ( - ( - ( - ( - ( - ( - ( - ( - `vn2008`.`Movimientos_mark` `mk` - JOIN `vn2008`.`Movimientos` `m` ON(`m`.`Id_Movimiento` = `mk`.`Id_Movimiento`) - ) - JOIN `vn`.`ticket` `t` ON(`m`.`Id_Ticket` = `t`.`id`) - ) - JOIN `vn`.`agencyMode` `am` ON(`am`.`id` = `t`.`agencyModeFk`) - ) - JOIN `vn`.`address` `a` ON(`a`.`id` = `t`.`addressFk`) - ) - LEFT JOIN `vn`.`itemShelvingSale` `is` ON(`is`.`saleFk` = `mk`.`Id_Movimiento`) - ) - LEFT JOIN `vn`.`itemShelving` `ish` ON(`ish`.`id` = `is`.`itemShelvingFk`) - ) - LEFT JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`) - ) - LEFT JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`) - ) - LEFT JOIN `vn2008`.`Articles` `art` ON(`art`.`Id_Article` = `m`.`Id_Article`) - ) - LEFT JOIN `vn`.`zone` `z` ON(`z`.`id` = `t`.`zoneFk`) - ) -WHERE `mk`.`stateFk` = 26 - AND `mk`.`valor` <> 1 diff --git a/db/routines/vn/views/ticketeToPreparePrepared.sql b/db/routines/vn/views/ticketeToPreparePrepared.sql deleted file mode 100644 index 76e840816..000000000 --- a/db/routines/vn/views/ticketeToPreparePrepared.sql +++ /dev/null @@ -1,47 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn`.`ticketeToPreparePrepared` -AS SELECT `m`.`Id_Ticket` AS `Id_Ticket`, - `mk`.`Id_Movimiento` AS `Id_Movimiento`, - `mk`.`Id_Movimiento_mark` AS `Id_Movimiento_mark`, - `mk`.`Id_Trabajador` AS `Id_Trabjador`, - `m`.`Id_Article` AS `Id_Article`, - `m`.`Concepte` AS `Concepte`, - `art`.`subName` AS `subName`, - `mk`.`original_quantity` - IFNULL(`is`.`quantity`, 0) AS `Cantidad`, - `mk`.`original_quantity` AS `original_quantity`, - HOUR(`t`.`shipped`) AS `Hora`, - HOUR(`t`.`shipped`) AS `Departure`, - MINUTE(`t`.`shipped`) AS `Minuto`, - `am`.`agencyFk` AS `agency_id`, - `t`.`warehouseFk` AS `warehouse_id`, - `a`.`provinceFk` AS `province_id`, - `is`.`quantity` AS `picked`, - `t`.`CodigoTrabajador` AS `trabajador`, - `is`.`sectorFk` AS `sectorFk` -FROM ( - ( - ( - ( - ( - ( - ( - ( - `vn2008`.`Movimientos_mark` `mk` - JOIN `vn`.`state` `st` ON(`st`.`id` = `mk`.`stateFk`) - ) - JOIN `vn2008`.`Movimientos` `m` ON(`m`.`Id_Movimiento` = `mk`.`Id_Movimiento`) - ) - JOIN `vn`.`ticket` `t` ON(`m`.`Id_Ticket` = `t`.`id`) - ) - JOIN `vn`.`agencyMode` `am` ON(`am`.`id` = `t`.`agencyModeFk`) - ) - JOIN `vn`.`address` `a` ON(`a`.`id` = `t`.`addressFk`) - ) - LEFT JOIN `vn`.`itemShelvingSaleSum` `is` ON(`is`.`saleFk` = `mk`.`Id_Movimiento`) - ) - JOIN `vn2008`.`Articles` `art` ON(`art`.`Id_Article` = `m`.`Id_Article`) - ) - LEFT JOIN `vn2008`.`Trabajadores` `t` ON(`t`.`Id_Trabajador` = `mk`.`Id_Trabajador`) - ) -WHERE `st`.`code` LIKE 'PREVIOUS_PREPARATION' diff --git a/db/versions/11012-silverRuscus/00-firstScript.sql b/db/versions/11012-silverRuscus/00-firstScript.sql new file mode 100644 index 000000000..3a43b6c46 --- /dev/null +++ b/db/versions/11012-silverRuscus/00-firstScript.sql @@ -0,0 +1 @@ +DROP TABLE cache.prod_graphic_source; diff --git a/myt.config.yml b/myt.config.yml index d94913b05..17300aa37 100755 --- a/myt.config.yml +++ b/myt.config.yml @@ -288,6 +288,7 @@ localFixtures: - payDemDetail - payMethod - payrollCategories + - payrollWorker - postCode - priceFixed - printer @@ -322,6 +323,7 @@ localFixtures: - shelving - smsConfig - specie + - split - supplier - supplierAccount - supplierActivity @@ -392,8 +394,4 @@ localFixtures: - zoneExclusionGeo - zoneGeo - zoneIncluded - - zoneWarehouse - vn2008: - - payroll_employee - - Splits - - zones + - zoneWarehouse \ No newline at end of file From 67069747845d6daea1237971f73a82ac0740bced Mon Sep 17 00:00:00 2001 From: Jon Date: Wed, 24 Apr 2024 10:31:26 +0200 Subject: [PATCH 03/31] fix: refs #6731 fix ticketRequest --- .../vn/procedures/ticketRequest_Add.sql | 19 ------------ .../triggers/ticketRequest_beforeInsert.sql | 2 +- .../triggers/ticketRequest_beforeUpdate.sql | 4 --- .../11002-limeCarnation/00-firstScript.sql | 7 +++++ loopback/locale/en.json | 4 +-- .../ticket-request/specs/confirm.spec.js | 5 +--- modules/ticket/back/models/ticket-config.json | 10 +++++++ modules/ticket/back/models/ticket-request.js | 30 +++++++++++++------ 8 files changed, 42 insertions(+), 39 deletions(-) delete mode 100644 db/routines/vn/procedures/ticketRequest_Add.sql create mode 100644 db/versions/11002-limeCarnation/00-firstScript.sql diff --git a/db/routines/vn/procedures/ticketRequest_Add.sql b/db/routines/vn/procedures/ticketRequest_Add.sql deleted file mode 100644 index 5ba347fef..000000000 --- a/db/routines/vn/procedures/ticketRequest_Add.sql +++ /dev/null @@ -1,19 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketRequest_Add`(vDescription VARCHAR(255), vQuantity INT, vPrice DOUBLE, vTicketFk INT, vBuyerCode VARCHAR(3)) -BEGIN - - INSERT INTO vn.ticketRequest(description, - quantity, - price, - ticketFk, - buyerCode, - requesterFk) - VALUES(vDescription, - vQuantity, - vPrice, - vTicketFk, - vBuyerCode, - vn.getUser()); - -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/ticketRequest_beforeInsert.sql b/db/routines/vn/triggers/ticketRequest_beforeInsert.sql index d17459912..00e659abc 100644 --- a/db/routines/vn/triggers/ticketRequest_beforeInsert.sql +++ b/db/routines/vn/triggers/ticketRequest_beforeInsert.sql @@ -14,7 +14,7 @@ BEGIN END IF; IF NEW.attenderFk IS NULL THEN - SET NEW.attenderFk = (SELECT w.id FROM worker w WHERE w.code = NEW.buyerCode); + SET NEW.attenderFk = (SELECT defaultAttenderFk FROM ticketConfig LIMIT 1); END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/ticketRequest_beforeUpdate.sql b/db/routines/vn/triggers/ticketRequest_beforeUpdate.sql index e5e9c307e..954df8ed3 100644 --- a/db/routines/vn/triggers/ticketRequest_beforeUpdate.sql +++ b/db/routines/vn/triggers/ticketRequest_beforeUpdate.sql @@ -12,9 +12,5 @@ BEGIN IF NEW.salesPersonCode <> OLD.salesPersonCode THEN SET NEW.requesterFk = (SELECT w.id FROM worker w WHERE w.code = NEW.salesPersonCode); END IF; - - IF NEW.buyerCode <> OLD.buyerCode THEN - SET NEW.attenderFk = (SELECT w.id FROM worker w WHERE w.code = NEW.buyerCode); - END IF; END$$ DELIMITER ; diff --git a/db/versions/11002-limeCarnation/00-firstScript.sql b/db/versions/11002-limeCarnation/00-firstScript.sql new file mode 100644 index 000000000..b1a49a309 --- /dev/null +++ b/db/versions/11002-limeCarnation/00-firstScript.sql @@ -0,0 +1,7 @@ +-- Place your SQL code here +ALTER TABLE `vn`.`ticketRequest` + CHANGE IF EXISTS `buyerCode` `buyerCode__` varchar(3) NOT NULL COMMENT '@deprecated 2024-04-23 refs #6731 field not used'; + +ALTER TABLE `vn`.`ticketConfig` ADD COLUMN IF NOT EXISTS `defaultAttenderFk` int unsigned; + +ALTER TABLE vn.ticketConfig ADD CONSTRAINT ticketConfig_worker_FK FOREIGN KEY (defaultAttenderFk) REFERENCES vn.worker(id); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 9a3a1f52a..93a54393d 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -223,7 +223,7 @@ "printerNotExists": "The printer does not exist", "There are not picking tickets": "There are not picking tickets", "ticketCommercial": "The ticket {{ ticket }} for the salesperson {{ salesMan }} is in preparation. (automatically generated message)", - "This password can only be changed by the user themselves": "This password can only be changed by the user themselves", - "They're not your subordinate": "They're not your subordinate", + "This password can only be changed by the user themselves": "This password can only be changed by the user themselves", + "They're not your subordinate": "They're not your subordinate", "InvoiceIn is already booked": "InvoiceIn is already booked" } \ No newline at end of file diff --git a/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js b/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js index de2817d87..668a991f4 100644 --- a/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js +++ b/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js @@ -92,9 +92,7 @@ describe('ticket-request confirm()', () => { const request = await models.TicketRequest.findById(requestId, null, options); expect(request.saleFk).toBeNull(); - - await request.updateAttributes({saleFk: 2}, options); - + await request.updateAttributes({saleFk: 2}); ctx.args = { itemFk: itemId, id: requestId, @@ -102,7 +100,6 @@ describe('ticket-request confirm()', () => { }; await models.TicketRequest.confirm(ctx, options); - await tx.rollback(); } catch (e) { await tx.rollback(); diff --git a/modules/ticket/back/models/ticket-config.json b/modules/ticket/back/models/ticket-config.json index d757fbd1a..6dd2808ea 100644 --- a/modules/ticket/back/models/ticket-config.json +++ b/modules/ticket/back/models/ticket-config.json @@ -23,6 +23,16 @@ }, "daysForWarningClaim": { "type": "number" + }, + "defaultAttenderFk": { + "type": "number" + } + }, + "relations": { + "attender": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "defaultAttenderFk" } } } diff --git a/modules/ticket/back/models/ticket-request.js b/modules/ticket/back/models/ticket-request.js index d133f85d5..622cd7696 100644 --- a/modules/ticket/back/models/ticket-request.js +++ b/modules/ticket/back/models/ticket-request.js @@ -8,21 +8,21 @@ module.exports = function(Self) { require('../methods/ticket-request/getItemTypeWorker')(Self); Self.observe('before save', async function(ctx) { - if (ctx.isNewInstance) { - const loopBackContext = LoopBackContext.getCurrentContext(); - const filter = {where: {id: loopBackContext.active.accessToken.userId}}; - const models = Self.app.models; - const worker = await models.Worker.findOne(filter); + const loopBackContext = LoopBackContext.getCurrentContext(); + const filter = {where: {id: loopBackContext.active.accessToken.userId}}; + const models = Self.app.models; + const worker = await models.Worker.findOne(filter); + const instance = ctx.instance; + const attenderFk = instance?.attenderFk; - const instance = ctx.instance; + if (ctx.isNewInstance) { instance.requesterFk = worker.id; const httpCtx = {req: loopBackContext.active}; const httpRequest = httpCtx.req.http .req; const $t = httpRequest.__; - const attenderId = instance.attenderFk; - if (attenderId) { + if (attenderFk) { const ticket = await models.Ticket.findById(instance.ticketFk); let messageText = 'New ticket request has been created'; if (instance.price) @@ -35,8 +35,20 @@ module.exports = function(Self) { quantity: instance.quantity, price: instance.price }); - await models.Chat.sendCheckingPresence(httpCtx, attenderId, message); + await models.Chat.sendCheckingPresence(httpCtx, attenderFk, message); + } else { + const {defaultAttenderFk} = await models.TicketConfig.findOne(); + Object.assign(instance, {attenderFk: defaultAttenderFk}); } } }); + + Self.observe('after save', async function(ctx) { + const models = Self.app.models; + const instance = ctx.instance; + if (instance?.attenderFk === null && !ctx.isNewInstance) { + const {defaultAttenderFk} = await models.TicketConfig.findOne(); + await models.TicketRequest.updateAll({id: instance.id}, {attenderFk: defaultAttenderFk}); + } + }); }; From 71e1e53ccd3e012e1b5ab832aeff732f46f09953 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 24 Apr 2024 10:57:35 +0200 Subject: [PATCH 04/31] refactor: #7258 Fixes --- db/routines/bi/procedures/defaulting.sql | 48 +++++++++---------- .../bs/procedures/ventas_contables_add.sql | 2 +- .../vn/triggers/solunionCAP_afterInsert.sql | 2 +- .../vn/triggers/solunionCAP_afterUpdate.sql | 4 +- .../vn/triggers/solunionCAP_beforeDelete.sql | 2 +- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/db/routines/bi/procedures/defaulting.sql b/db/routines/bi/procedures/defaulting.sql index 3ff9bc4a1..d20232b8b 100644 --- a/db/routines/bi/procedures/defaulting.sql +++ b/db/routines/bi/procedures/defaulting.sql @@ -2,22 +2,22 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`defaulting`(IN `vDate` DATE) BEGIN DECLARE vDone BOOLEAN; - DECLARE vClient INT; - DECLARE vAmount INT; - DECLARE vDued DATE; - DECLARE vAmountInvoice DECIMAL(10,2); - DECLARE vGraceDays INT; + DECLARE vClient INT; + DECLARE vAmount INT; + DECLARE vDued DATE; + DECLARE vAmountInvoice DECIMAL(10,2); + DECLARE vGraceDays INT; DECLARE defaulters CURSOR FOR SELECT d.client, d.amount, pm.graceDays FROM bi.defaulters d JOIN vn.client c ON c.id = d.client - JOIN vn.payMethod pm ON pm.id = c.pay_met_id - WHERE hasChanged AND date = vDate; - + JOIN vn.payMethod pm ON pm.id = c.payMethodFk + WHERE hasChanged AND date = vDate; + DECLARE invoices CURSOR FOR SELECT dued Vencimiento, amount importe FROM vn.invoiceOut WHERE issued >= '2016-01-01' AND clientFk = vClient ORDER BY issued DESC; - + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DELETE FROM bi.defaulters WHERE date = vDate; @@ -27,7 +27,7 @@ BEGIN FROM vn.`client` c LEFT JOIN bi.customerRiskOverdue cro ON c.id = cro.customer_id GROUP BY c.id; - + -- marcamos si ha cambiado y heredamos la fecha defaulterSince UPDATE bi.defaulters d LEFT JOIN ( @@ -36,16 +36,16 @@ BEGIN WHERE date <= TIMESTAMPADD(DAY,-1, vDate) ORDER BY date DESC LIMIT 10000000000000000000) t GROUP BY client - ) yesterday using(client) + ) yesterday using(client) SET d.hasChanged = (IFNULL(d.amount,0) <> IFNULL(yesterday.amount,0)), d.defaulterSince = yesterday.defaulterSince, - d.frozened = yesterday.frozened + d.frozened = yesterday.frozened WHERE d.date = vDate ; - - OPEN defaulters; + + OPEN defaulters; defaulters: LOOP SET vDone = FALSE; - SET vAmount = 0; + SET vAmount = 0; FETCH defaulters INTO vClient,vAmount, vGraceDays; IF vDone THEN LEAVE defaulters; @@ -61,7 +61,7 @@ BEGIN IF TIMESTAMPADD(DAY, vGraceDays, vDued) <= vDate THEN SET vAmount = vAmount - vAmountInvoice; IF vAmount <= 0 THEN - + UPDATE defaulters SET defaulterSince = vDued WHERE client = vClient and date = vDate; @@ -74,20 +74,20 @@ BEGIN END LOOP; CLOSE defaulters; - DELETE FROM defaulters + DELETE FROM defaulters WHERE amount = 0 AND hasChanged = FALSE - AND `date` = vDate; - - UPDATE defaulters d + AND `date` = vDate; + + UPDATE defaulters d JOIN vn.config ON TRUE SET d.frozened = NULL WHERE `date` = vDate AND d.amount <= config.defaultersMaxAmount; - - CALL vn.clientFreeze(); - - -- actualizamos defaulting + + CALL vn.clientFreeze(); + + -- actualizamos defaulting DELETE FROM bi.defaulting WHERE date = vDate; INSERT INTO bi.defaulting(date, amount) diff --git a/db/routines/bs/procedures/ventas_contables_add.sql b/db/routines/bs/procedures/ventas_contables_add.sql index 5ebd550b4..72b0c0fee 100644 --- a/db/routines/bs/procedures/ventas_contables_add.sql +++ b/db/routines/bs/procedures/ventas_contables_add.sql @@ -58,7 +58,7 @@ BEGIN JOIN vn.address a on a.id = t.addressFk JOIN vn.client c on c.id = a.clientFk JOIN tmp.ticket_list tt on tt.id = t.id - JOIN vn.item i on s.itemFk = i.Id_Ticket + JOIN vn.item i on s.itemFk = i.id JOIN vn.company co on co.id = t.companyFk LEFT JOIN vn.company co2 on co2.clientFk = c.id JOIN vn.itemType it on it.id = i.typeFk diff --git a/db/routines/vn/triggers/solunionCAP_afterInsert.sql b/db/routines/vn/triggers/solunionCAP_afterInsert.sql index 9907bcbab..0d6e510ad 100644 --- a/db/routines/vn/triggers/solunionCAP_afterInsert.sql +++ b/db/routines/vn/triggers/solunionCAP_afterInsert.sql @@ -4,7 +4,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`solunionCAP_afterInse FOR EACH ROW BEGIN UPDATE client c - JOIN creditClassification cc ON cc.client = c.clientFk + JOIN creditClassification cc ON cc.client = c.id JOIN creditInsurance ci ON ci.creditClassification = cc.id SET creditInsurance = ci.credit * 2 WHERE ci.id = NEW.creditInsurance; END$$ diff --git a/db/routines/vn/triggers/solunionCAP_afterUpdate.sql b/db/routines/vn/triggers/solunionCAP_afterUpdate.sql index 62d4e0e6b..40ff57f35 100644 --- a/db/routines/vn/triggers/solunionCAP_afterUpdate.sql +++ b/db/routines/vn/triggers/solunionCAP_afterUpdate.sql @@ -5,12 +5,12 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`solunionCAP_afterUpda BEGIN IF NEW.dateLeaving IS NOT NULL THEN UPDATE client c - JOIN creditClassification cc ON cc.client = c.clientFk + JOIN creditClassification cc ON cc.client = c.id JOIN creditInsurance ci ON ci.creditClassification = cc.id SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance; ELSE UPDATE client c - JOIN creditClassification cc ON cc.client = c.clientFk + JOIN creditClassification cc ON cc.client = c.id JOIN creditInsurance ci ON ci.creditClassification = cc.id SET creditInsurance = ci.credit * 2 WHERE ci.id = OLD.creditInsurance; END IF; diff --git a/db/routines/vn/triggers/solunionCAP_beforeDelete.sql b/db/routines/vn/triggers/solunionCAP_beforeDelete.sql index 924310c3f..29c4298fd 100644 --- a/db/routines/vn/triggers/solunionCAP_beforeDelete.sql +++ b/db/routines/vn/triggers/solunionCAP_beforeDelete.sql @@ -4,7 +4,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`solunionCAP_beforeDel FOR EACH ROW BEGIN UPDATE client c - JOIN creditClassification cc ON cc.client = c.clientFk + JOIN creditClassification cc ON cc.client = c.id JOIN creditInsurance ci ON ci.creditClassification = cc.id SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance; END$$ From 6fb87531c4fddf83cd2952989d8a5dd3b82ffb57 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 24 Apr 2024 11:27:16 +0200 Subject: [PATCH 05/31] refactor: #7258 Deprecated last tables vn2008 --- db/versions/11012-silverRuscus/00-firstScript.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/db/versions/11012-silverRuscus/00-firstScript.sql b/db/versions/11012-silverRuscus/00-firstScript.sql index 3a43b6c46..161960f6b 100644 --- a/db/versions/11012-silverRuscus/00-firstScript.sql +++ b/db/versions/11012-silverRuscus/00-firstScript.sql @@ -1 +1,5 @@ DROP TABLE cache.prod_graphic_source; +RENAME TABLE vn2008.unary TO vn2008.unary__; +ALTER TABLE vn2008.unary__ COMMENT='refs #7258 @deprecated 2023-12-13'; +RENAME TABLE vn2008.jerarquia TO vn2008.jerarquia__; +ALTER TABLE vn2008.jerarquia__ COMMENT='refs #7258 @deprecated 2023-12-13'; From 46f2d790db3aeb03178f2b20eabbd584ffd400ba Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 25 Apr 2024 08:01:32 +0200 Subject: [PATCH 06/31] refs #6312 hotFix fix:replaceItem --- db/routines/vn/procedures/sale_replaceItem.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/sale_replaceItem.sql b/db/routines/vn/procedures/sale_replaceItem.sql index 1d9f6ff71..fb68b3f3a 100644 --- a/db/routines/vn/procedures/sale_replaceItem.sql +++ b/db/routines/vn/procedures/sale_replaceItem.sql @@ -92,8 +92,8 @@ BEGIN START TRANSACTION; UPDATE sale - SET quantity = quantity - vQuantity - WHERE id = vSaleFk; + SET originalQuantity = quantity - vQuantity, + quantity = quantity - vQuantity INSERT INTO vn.sale(ticketFk, itemFk, From d4d31c6d9e1c7a7826b08ba411831e7f226c78fd Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 25 Apr 2024 08:35:59 +0200 Subject: [PATCH 07/31] refs #6312 hotFix fix:replaceItem --- db/routines/vn/procedures/sale_replaceItem.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/db/routines/vn/procedures/sale_replaceItem.sql b/db/routines/vn/procedures/sale_replaceItem.sql index fb68b3f3a..9a431020b 100644 --- a/db/routines/vn/procedures/sale_replaceItem.sql +++ b/db/routines/vn/procedures/sale_replaceItem.sql @@ -94,6 +94,7 @@ BEGIN UPDATE sale SET originalQuantity = quantity - vQuantity, quantity = quantity - vQuantity + WHERE id = vSaleFk; INSERT INTO vn.sale(ticketFk, itemFk, From c819b921412792baee8b53a165bad10bb81c0f62 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 26 Apr 2024 09:09:22 +0200 Subject: [PATCH 08/31] fix: refs #177968 restore restriction --- db/routines/vn/procedures/sale_replaceItem.sql | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/sale_replaceItem.sql b/db/routines/vn/procedures/sale_replaceItem.sql index 9a431020b..e50f83b7f 100644 --- a/db/routines/vn/procedures/sale_replaceItem.sql +++ b/db/routines/vn/procedures/sale_replaceItem.sql @@ -81,6 +81,10 @@ BEGIN ORDER BY (vQuantity % `grouping`) ASC LIMIT 1; + IF vNewPrice IS NULL THEN + CALL util.throw('price retrieval failed'); + END IF; + IF vNewPrice > vOldPrice THEN SET vFinalPrice = vOldPrice; SET vOption = 'substitution'; @@ -103,7 +107,8 @@ BEGIN price) SELECT vTicketFk, vNewItemFk, - CEIL(vQuantity / vRoundQuantity) * vRoundQuantity, CONCAT('+ ', i.name), + CEIL(vQuantity / vRoundQuantity) * vRoundQuantity, + CONCAT('+ ', i.name), vFinalPrice FROM vn.item i WHERE id = vNewItemFk; From 9e87b055b74ff8f35eb4c81c0b54695449f0bbdb Mon Sep 17 00:00:00 2001 From: Pako Date: Sat, 27 Apr 2024 12:36:21 +0200 Subject: [PATCH 09/31] hotFix --- db/routines/vn/procedures/collection_assign.sql | 8 +++++--- db/routines/vn/procedures/collection_new.sql | 8 +++++--- db/versions/11016-pinkAralia/00-firstScript.sql | 5 +++++ 3 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 db/versions/11016-pinkAralia/00-firstScript.sql diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql index f6000e87d..1d656a0ed 100644 --- a/db/routines/vn/procedures/collection_assign.sql +++ b/db/routines/vn/procedures/collection_assign.sql @@ -30,8 +30,10 @@ BEGIN -- Si hay colecciones sin terminar, sale del proceso CALL collection_get(vUserFk); - SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0 - INTO vHasTooMuchCollections + SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, + pc.collection_assign_lockname + INTO vHasTooMuchCollections, + vLockName FROM tCollection JOIN productionConfig pc; @@ -47,7 +49,7 @@ BEGIN WHERE workerFk = vUserFk; SET vLockName = CONCAT_WS('/', - 'collection_assign', + vLockName, vWarehouseFk, vItemPackingTypeFk ); diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index f3767ddf3..8a1eff4a1 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -63,7 +63,8 @@ BEGIN o.numberOfWagons, o.trainFk, o.linesLimit, - o.volumeLimit + o.volumeLimit, + pc.collection_new_lockname INTO vMaxTickets, vHasUniqueCollectionTime, vWorkerCode, @@ -73,14 +74,15 @@ BEGIN vWagons, vTrainFk, vLinesLimit, - vVolumeLimit + vVolumeLimit, + vLockName FROM productionConfig pc JOIN worker w ON w.id = vUserFk JOIN state st ON st.`code` = 'ON_PREPARATION' JOIN operator o ON o.workerFk = vUserFk; SET vLockName = CONCAT_WS('/', - 'collection_new', + vLockName, vWarehouseFk, vItemPackingTypeFk ); diff --git a/db/versions/11016-pinkAralia/00-firstScript.sql b/db/versions/11016-pinkAralia/00-firstScript.sql new file mode 100644 index 000000000..675507254 --- /dev/null +++ b/db/versions/11016-pinkAralia/00-firstScript.sql @@ -0,0 +1,5 @@ +-- Place your SQL code here +ALTER TABLE vn.productionConfig ADD collection_new_lockname varchar(100) + DEFAULT 'collection_new' NOT NULL COMMENT 'Lockname value for proc vn.collection_new'; +ALTER TABLE vn.productionConfig ADD collection_assign_lockname varchar(100) + DEFAULT 'collection_assign' NULL COMMENT 'Lockname value for proc vn.collection_new'; From 3440bb1725a0ec8e8b67ed5762d815d20f66c75b Mon Sep 17 00:00:00 2001 From: Pako Date: Sat, 27 Apr 2024 12:43:15 +0200 Subject: [PATCH 10/31] hotFix --- db/routines/vn/procedures/collection_assign.sql | 8 +++++--- db/routines/vn/procedures/collection_new.sql | 8 +++++--- db/versions/11018-crimsonBamboo/00-firstScript.sql | 3 +++ 3 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 db/versions/11018-crimsonBamboo/00-firstScript.sql diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql index f6000e87d..1d656a0ed 100644 --- a/db/routines/vn/procedures/collection_assign.sql +++ b/db/routines/vn/procedures/collection_assign.sql @@ -30,8 +30,10 @@ BEGIN -- Si hay colecciones sin terminar, sale del proceso CALL collection_get(vUserFk); - SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0 - INTO vHasTooMuchCollections + SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, + pc.collection_assign_lockname + INTO vHasTooMuchCollections, + vLockName FROM tCollection JOIN productionConfig pc; @@ -47,7 +49,7 @@ BEGIN WHERE workerFk = vUserFk; SET vLockName = CONCAT_WS('/', - 'collection_assign', + vLockName, vWarehouseFk, vItemPackingTypeFk ); diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index f3767ddf3..8a1eff4a1 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -63,7 +63,8 @@ BEGIN o.numberOfWagons, o.trainFk, o.linesLimit, - o.volumeLimit + o.volumeLimit, + pc.collection_new_lockname INTO vMaxTickets, vHasUniqueCollectionTime, vWorkerCode, @@ -73,14 +74,15 @@ BEGIN vWagons, vTrainFk, vLinesLimit, - vVolumeLimit + vVolumeLimit, + vLockName FROM productionConfig pc JOIN worker w ON w.id = vUserFk JOIN state st ON st.`code` = 'ON_PREPARATION' JOIN operator o ON o.workerFk = vUserFk; SET vLockName = CONCAT_WS('/', - 'collection_new', + vLockName, vWarehouseFk, vItemPackingTypeFk ); diff --git a/db/versions/11018-crimsonBamboo/00-firstScript.sql b/db/versions/11018-crimsonBamboo/00-firstScript.sql new file mode 100644 index 000000000..1d0c8f0bd --- /dev/null +++ b/db/versions/11018-crimsonBamboo/00-firstScript.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here +ALTER TABLE vn.productionConfig ADD collection_new_lockname varchar(100) DEFAULT 'collection_new' NOT NULL COMMENT 'Lockname value for proc vn.collection_new'; +ALTER TABLE vn.productionConfig ADD collection_assign_lockname varchar(100) DEFAULT 'collection_assign' NULL COMMENT 'Lockname value for proc vn.collection_new'; From 9aa6e3f80a0455711bbef787b5bbcfd4eba37cea Mon Sep 17 00:00:00 2001 From: Pako Date: Sat, 27 Apr 2024 13:09:15 +0200 Subject: [PATCH 11/31] hotfix --- db/routines/vn/procedures/collection_assign.sql | 2 +- db/routines/vn/procedures/collection_new.sql | 2 +- db/versions/11016-pinkAralia/00-firstScript.sql | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql index 1d656a0ed..47efa7cd3 100644 --- a/db/routines/vn/procedures/collection_assign.sql +++ b/db/routines/vn/procedures/collection_assign.sql @@ -31,7 +31,7 @@ BEGIN CALL collection_get(vUserFk); SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, - pc.collection_assign_lockname + pc.collectionAssignLockname INTO vHasTooMuchCollections, vLockName FROM tCollection diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index 8a1eff4a1..f207eb2b0 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -64,7 +64,7 @@ BEGIN o.trainFk, o.linesLimit, o.volumeLimit, - pc.collection_new_lockname + pc.collectionNewLockname INTO vMaxTickets, vHasUniqueCollectionTime, vWorkerCode, diff --git a/db/versions/11016-pinkAralia/00-firstScript.sql b/db/versions/11016-pinkAralia/00-firstScript.sql index 675507254..de090013d 100644 --- a/db/versions/11016-pinkAralia/00-firstScript.sql +++ b/db/versions/11016-pinkAralia/00-firstScript.sql @@ -1,5 +1,5 @@ -- Place your SQL code here -ALTER TABLE vn.productionConfig ADD collection_new_lockname varchar(100) +ALTER TABLE vn.productionConfig ADD collectionNewLockname varchar(100) DEFAULT 'collection_new' NOT NULL COMMENT 'Lockname value for proc vn.collection_new'; -ALTER TABLE vn.productionConfig ADD collection_assign_lockname varchar(100) +ALTER TABLE vn.productionConfig ADD collectionAssignLockname varchar(100) DEFAULT 'collection_assign' NULL COMMENT 'Lockname value for proc vn.collection_new'; From f2225b49a71415bb977dc39e6d3bb9c523b8510d Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 29 Apr 2024 08:19:18 +0200 Subject: [PATCH 12/31] refs #6275 hotFix fix:getExpeditionSummary --- modules/route/back/methods/route/getExpeditionSummary.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/route/back/methods/route/getExpeditionSummary.js b/modules/route/back/methods/route/getExpeditionSummary.js index ee89401a8..4f95ded2a 100644 --- a/modules/route/back/methods/route/getExpeditionSummary.js +++ b/modules/route/back/methods/route/getExpeditionSummary.js @@ -49,7 +49,7 @@ module.exports = Self => { JOIN vn.agencyMode am ON am.id = r.agencyModeFk JOIN vn.agency ag ON ag.id = am.agencyFk LEFT JOIN vn.userConfig uc ON uc.userFk = account.myUser_getId() - WHERE (r.created = util.VN_CURDATE() OR r.created = util.yesterday()) + WHERE (r.created BETWEEN util.yesterday() AND util.VN_CURDATE() + INTERVAL 1 DAY) AND t.routeFk = ? GROUP BY t.addressFk, e.itemPackingTypeFk ) sub From f4767728bcdede8ed81fd56b9e27b7271572bcfb Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 29 Apr 2024 08:20:57 +0200 Subject: [PATCH 13/31] refs #6275 hotFix fix:getExpeditionSummary --- modules/route/back/methods/route/getExpeditionSummary.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/route/back/methods/route/getExpeditionSummary.js b/modules/route/back/methods/route/getExpeditionSummary.js index 4f95ded2a..34f55feb2 100644 --- a/modules/route/back/methods/route/getExpeditionSummary.js +++ b/modules/route/back/methods/route/getExpeditionSummary.js @@ -49,7 +49,7 @@ module.exports = Self => { JOIN vn.agencyMode am ON am.id = r.agencyModeFk JOIN vn.agency ag ON ag.id = am.agencyFk LEFT JOIN vn.userConfig uc ON uc.userFk = account.myUser_getId() - WHERE (r.created BETWEEN util.yesterday() AND util.VN_CURDATE() + INTERVAL 1 DAY) + WHERE (r.created BETWEEN util.yesterday() AND util.VN_CURDATE() + INTERVAL 1 DAY) AND t.routeFk = ? GROUP BY t.addressFk, e.itemPackingTypeFk ) sub From a180f54390ebe454de3c9ed0b39d686c6170c58a Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 29 Apr 2024 08:59:12 +0200 Subject: [PATCH 14/31] refs #6275 hotFix fix:getExpeditionSummary --- modules/route/back/methods/route/getExpeditionSummary.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/route/back/methods/route/getExpeditionSummary.js b/modules/route/back/methods/route/getExpeditionSummary.js index 34f55feb2..2bd2ca43a 100644 --- a/modules/route/back/methods/route/getExpeditionSummary.js +++ b/modules/route/back/methods/route/getExpeditionSummary.js @@ -49,8 +49,7 @@ module.exports = Self => { JOIN vn.agencyMode am ON am.id = r.agencyModeFk JOIN vn.agency ag ON ag.id = am.agencyFk LEFT JOIN vn.userConfig uc ON uc.userFk = account.myUser_getId() - WHERE (r.created BETWEEN util.yesterday() AND util.VN_CURDATE() + INTERVAL 1 DAY) - AND t.routeFk = ? + WHERE t.routeFk = ? GROUP BY t.addressFk, e.itemPackingTypeFk ) sub GROUP BY addressFk From f3c7b1e89ca87b56b9e83374a11ba6ab3134f4a4 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 29 Apr 2024 11:59:51 +0200 Subject: [PATCH 15/31] refs #6870 add observationEmail --- loopback/locale/es.json | 4 ++-- modules/client/back/methods/defaulter/observationEmail.js | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index d7f9564fe..afb6aae3d 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -277,7 +277,7 @@ "Collection does not exist": "La colección no existe", "Cannot obtain exclusive lock": "No se puede obtener un bloqueo exclusivo", "Insert a date range": "Inserte un rango de fechas", - "Added observation": "{{user}} añadió esta observacion: {{text}}", + "Added observation": "{{user}} añadió esta observacion: {{text}} {defaulterUrl}", "Comment added to client": "Observación añadida al cliente {{clientFk}}", "Invalid auth code": "Código de verificación incorrecto", "Invalid or expired verification code": "Código de verificación incorrecto o expirado", @@ -354,4 +354,4 @@ "They're not your subordinate": "No es tu subordinado/a.", "No results found": "No se han encontrado resultados", "InvoiceIn is already booked": "La factura recibida está contabilizada" -} \ No newline at end of file +} diff --git a/modules/client/back/methods/defaulter/observationEmail.js b/modules/client/back/methods/defaulter/observationEmail.js index 5ac00b4ee..5b13e8282 100644 --- a/modules/client/back/methods/defaulter/observationEmail.js +++ b/modules/client/back/methods/defaulter/observationEmail.js @@ -29,6 +29,7 @@ module.exports = Self => { const $t = ctx.req.__; // $translate const myOptions = {}; const userId = ctx.req.accessToken.userId; + const url = await Self.app.models.Url.getUrl(); if (typeof options == 'object') Object.assign(myOptions, options); @@ -38,7 +39,8 @@ module.exports = Self => { const body = $t('Added observation', { user: user.name, - text: observation + text: observation, + defaulterUrl: `${url}client/${defaulter.clientFk}/summary` }); await models.Mail.create({ From dcb6f90ab3241ef405a34733ce6572fc50eede99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 29 Apr 2024 14:42:16 +0200 Subject: [PATCH 16/31] hotfix collection_assign elimino vLockTime --- db/routines/vn/procedures/collection_assign.sql | 5 ----- 1 file changed, 5 deletions(-) diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql index 47efa7cd3..8f23ebe4a 100644 --- a/db/routines/vn/procedures/collection_assign.sql +++ b/db/routines/vn/procedures/collection_assign.sql @@ -16,7 +16,6 @@ BEGIN DECLARE vItemPackingTypeFk VARCHAR(1); DECLARE vWarehouseFk INT; DECLARE vLockName VARCHAR(215); - DECLARE vLockTime INT DEFAULT 30; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN @@ -54,10 +53,6 @@ BEGIN vItemPackingTypeFk ); - IF NOT GET_LOCK(vLockName, vLockTime) THEN - CALL util.throw(CONCAT('Cannot get lock: ', vLockName)); - END IF; - -- Se eliminan las colecciones sin asignar que estan obsoletas INSERT INTO ticketTracking(stateFk, ticketFk) SELECT s.id, tc.ticketFk From 51c8736da2b707ee313cede6941c466386e2a4a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 29 Apr 2024 14:54:15 +0200 Subject: [PATCH 17/31] hotFix collection_assign --- db/routines/vn/procedures/collection_assign.sql | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql index 8f23ebe4a..13bf7f836 100644 --- a/db/routines/vn/procedures/collection_assign.sql +++ b/db/routines/vn/procedures/collection_assign.sql @@ -16,6 +16,7 @@ BEGIN DECLARE vItemPackingTypeFk VARCHAR(1); DECLARE vWarehouseFk INT; DECLARE vLockName VARCHAR(215); + DECLARE vLockTime INT DEFAULT 30; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN @@ -33,8 +34,8 @@ BEGIN pc.collectionAssignLockname INTO vHasTooMuchCollections, vLockName - FROM tCollection - JOIN productionConfig pc; + FROM productionConfig pc + LEFT JOIN tCollection; DROP TEMPORARY TABLE tCollection; @@ -53,6 +54,10 @@ BEGIN vItemPackingTypeFk ); + IF NOT GET_LOCK(vLockName, vLockTime) THEN + CALL util.throw(CONCAT('Cannot get lock: ', vLockName)); + END IF; + -- Se eliminan las colecciones sin asignar que estan obsoletas INSERT INTO ticketTracking(stateFk, ticketFk) SELECT s.id, tc.ticketFk From 7b7afb05c56d1a7f9131df0d60e311cbc398abcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 29 Apr 2024 15:01:20 +0200 Subject: [PATCH 18/31] hotfix collection_assign --- db/routines/vn/procedures/collection_assign.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql index 13bf7f836..1c3ef06ab 100644 --- a/db/routines/vn/procedures/collection_assign.sql +++ b/db/routines/vn/procedures/collection_assign.sql @@ -35,7 +35,7 @@ BEGIN INTO vHasTooMuchCollections, vLockName FROM productionConfig pc - LEFT JOIN tCollection; + LEFT JOIN tCollection ON TRUE; DROP TEMPORARY TABLE tCollection; From 21a1e1eed307b29066877cd1345b7083d9a58e02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 29 Apr 2024 16:59:56 +0200 Subject: [PATCH 19/31] Hotfix feat: new function to kill connections --- db/routines/util/procedures/connection_kill.sql | 11 +++++++++++ db/routines/vn/procedures/collection_assign.sql | 7 ++----- db/routines/vn/procedures/collection_new.sql | 8 +++----- db/versions/11021-bronzeErica/00-firstScript.sql | 4 ++++ 4 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 db/routines/util/procedures/connection_kill.sql create mode 100644 db/versions/11021-bronzeErica/00-firstScript.sql diff --git a/db/routines/util/procedures/connection_kill.sql b/db/routines/util/procedures/connection_kill.sql new file mode 100644 index 000000000..c321a5117 --- /dev/null +++ b/db/routines/util/procedures/connection_kill.sql @@ -0,0 +1,11 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`connection_kill`(vConnectionId BIGINT) +BEGIN +/** + * Kill a connection + * + * @param vConnectionId + */ + KILL vConnectionId; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql index 1c3ef06ab..e976367cd 100644 --- a/db/routines/vn/procedures/collection_assign.sql +++ b/db/routines/vn/procedures/collection_assign.sql @@ -30,10 +30,7 @@ BEGIN -- Si hay colecciones sin terminar, sale del proceso CALL collection_get(vUserFk); - SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, - pc.collectionAssignLockname - INTO vHasTooMuchCollections, - vLockName + SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0 INTO vHasTooMuchCollections FROM productionConfig pc LEFT JOIN tCollection ON TRUE; @@ -49,7 +46,7 @@ BEGIN WHERE workerFk = vUserFk; SET vLockName = CONCAT_WS('/', - vLockName, + 'collection_assign', vWarehouseFk, vItemPackingTypeFk ); diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index f207eb2b0..f3767ddf3 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -63,8 +63,7 @@ BEGIN o.numberOfWagons, o.trainFk, o.linesLimit, - o.volumeLimit, - pc.collectionNewLockname + o.volumeLimit INTO vMaxTickets, vHasUniqueCollectionTime, vWorkerCode, @@ -74,15 +73,14 @@ BEGIN vWagons, vTrainFk, vLinesLimit, - vVolumeLimit, - vLockName + vVolumeLimit FROM productionConfig pc JOIN worker w ON w.id = vUserFk JOIN state st ON st.`code` = 'ON_PREPARATION' JOIN operator o ON o.workerFk = vUserFk; SET vLockName = CONCAT_WS('/', - vLockName, + 'collection_new', vWarehouseFk, vItemPackingTypeFk ); diff --git a/db/versions/11021-bronzeErica/00-firstScript.sql b/db/versions/11021-bronzeErica/00-firstScript.sql new file mode 100644 index 000000000..f08667f8e --- /dev/null +++ b/db/versions/11021-bronzeErica/00-firstScript.sql @@ -0,0 +1,4 @@ + + ALTER TABLE vn.productionConfig + DROP COLUMN IF EXISTS collectionNewLockname, + DROP COLUMN IF EXISTS collectionAssignLockname; \ No newline at end of file From e55658e6b3301674ecd23bdc9561604f4380e714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 29 Apr 2024 17:02:47 +0200 Subject: [PATCH 20/31] Hotfix feat: new function to kill connections --- db/routines/util/procedures/connection_kill.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/db/routines/util/procedures/connection_kill.sql b/db/routines/util/procedures/connection_kill.sql index c321a5117..b38509d1b 100644 --- a/db/routines/util/procedures/connection_kill.sql +++ b/db/routines/util/procedures/connection_kill.sql @@ -1,5 +1,7 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`connection_kill`(vConnectionId BIGINT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`connection_kill`( + vConnectionId BIGINT +) BEGIN /** * Kill a connection From e934b47e9831c88b35eb07339bc179cc8947526e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 29 Apr 2024 17:09:51 +0200 Subject: [PATCH 21/31] Hotfix feat: new function to kill connections --- db/versions/11021-bronzeErica/00-firstScript.sql | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/db/versions/11021-bronzeErica/00-firstScript.sql b/db/versions/11021-bronzeErica/00-firstScript.sql index f08667f8e..6f6b68d49 100644 --- a/db/versions/11021-bronzeErica/00-firstScript.sql +++ b/db/versions/11021-bronzeErica/00-firstScript.sql @@ -1,4 +1,13 @@ ALTER TABLE vn.productionConfig DROP COLUMN IF EXISTS collectionNewLockname, - DROP COLUMN IF EXISTS collectionAssignLockname; \ No newline at end of file + DROP COLUMN IF EXISTS collectionAssignLockname; + + DELIMITER $$ + CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`connection_kill`() + BEGIN + + END$$ + DELIMITER ; + + GRANT EXECUTE ON PROCEDURE util.connection_kill TO 'developer'; \ No newline at end of file From d44b8f7c9a1a167b0bc5eca4241ac3367f5470cf Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 30 Apr 2024 11:44:16 +0200 Subject: [PATCH 22/31] hotfix: ticket #179514 ticket_close packaging fix --- db/routines/vn/procedures/ticket_close.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/ticket_close.sql b/db/routines/vn/procedures/ticket_close.sql index 91e0979cd..47d748ddf 100644 --- a/db/routines/vn/procedures/ticket_close.sql +++ b/db/routines/vn/procedures/ticket_close.sql @@ -63,7 +63,7 @@ BEGIN INSERT INTO ticketPackaging (ticketFk, packagingFk, quantity) (SELECT vCurTicketFk, p.id, COUNT(*) FROM expedition e - JOIN packaging p ON p.itemFk = e.freightItemFk + JOIN packaging p ON p.id = e.packagingFk WHERE e.ticketFk = vCurTicketFk AND p.isPackageReturnable AND vWithPackage GROUP BY p.itemFk); From d18f08e676ab4099d352117bd03b3769f5356c4e Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 30 Apr 2024 12:15:27 +0200 Subject: [PATCH 23/31] hotFix(addSaleByCode) add userId --- modules/ticket/back/methods/ticket/addSaleByCode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/addSaleByCode.js b/modules/ticket/back/methods/ticket/addSaleByCode.js index a73628c86..ca3d2cb07 100644 --- a/modules/ticket/back/methods/ticket/addSaleByCode.js +++ b/modules/ticket/back/methods/ticket/addSaleByCode.js @@ -30,7 +30,7 @@ module.exports = Self => { }); Self.addSaleByCode = async(ctx, barcode, quantity, ticketFk, warehouseFk, options) => { - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') From e546a13e5d3a30a236ca9bd62d843a67f269b936 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 30 Apr 2024 12:41:29 +0200 Subject: [PATCH 24/31] refs #6895 redirect lilium --- modules/shelving/front/main/index.html | 19 ------------------- modules/shelving/front/main/index.js | 18 +++--------------- 2 files changed, 3 insertions(+), 34 deletions(-) diff --git a/modules/shelving/front/main/index.html b/modules/shelving/front/main/index.html index 3f3cc718b..e69de29bb 100644 --- a/modules/shelving/front/main/index.html +++ b/modules/shelving/front/main/index.html @@ -1,19 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/modules/shelving/front/main/index.js b/modules/shelving/front/main/index.js index 96689fbd9..a4a6031a4 100644 --- a/modules/shelving/front/main/index.js +++ b/modules/shelving/front/main/index.js @@ -4,22 +4,10 @@ import ModuleMain from 'salix/components/module-main'; export default class Shelving extends ModuleMain { constructor($element, $) { super($element, $); - this.filter = { - include: [ - {relation: 'parking'} - ], - }; } - - exprBuilder(param, value) { - switch (param) { - case 'search': - return {code: {like: `%${value}%`}}; - case 'parkingFk': - case 'userFk': - case 'isRecyclable': - return {[param]: value}; - } + async $onInit() { + const url = await this.vnApp.getUrl(`shelving/`); + window.location.href = url; } } From b0b8f12ca94c9056b07fc058779425ed61732798 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 30 Apr 2024 13:17:19 +0200 Subject: [PATCH 25/31] refs #6895 remove code --- modules/shelving/front/basic-data/index.html | 52 ------------------- modules/shelving/front/basic-data/index.js | 10 ---- modules/shelving/front/card/index.html | 8 --- modules/shelving/front/card/index.js | 29 ----------- modules/shelving/front/card/index.spec.js | 26 ---------- modules/shelving/front/create/index.html | 51 ------------------ modules/shelving/front/create/index.js | 15 ------ modules/shelving/front/create/index.spec.js | 38 -------------- modules/shelving/front/descriptor/index.html | 45 ---------------- modules/shelving/front/descriptor/index.js | 26 ---------- .../shelving/front/descriptor/index.spec.js | 29 ----------- .../shelving/front/descriptor/locale/es.yml | 3 -- modules/shelving/front/index.js | 8 --- modules/shelving/front/index/index.html | 47 ----------------- modules/shelving/front/index/index.js | 14 ----- modules/shelving/front/index/index.spec.js | 39 -------------- modules/shelving/front/index/locale/es.yml | 2 - modules/shelving/front/log/index.html | 1 - modules/shelving/front/log/index.js | 7 --- modules/shelving/front/log/locale/es.yml | 1 - modules/shelving/front/routes.json | 36 ------------- .../shelving/front/search-panel/index.html | 43 --------------- modules/shelving/front/search-panel/index.js | 7 --- .../shelving/front/search-panel/locale/es.yml | 1 - modules/shelving/front/summary/index.html | 51 ------------------ modules/shelving/front/summary/index.js | 41 --------------- modules/shelving/front/summary/locale/es.yml | 5 -- modules/shelving/front/summary/style.scss | 7 --- 28 files changed, 642 deletions(-) delete mode 100644 modules/shelving/front/basic-data/index.html delete mode 100644 modules/shelving/front/basic-data/index.js delete mode 100644 modules/shelving/front/card/index.html delete mode 100644 modules/shelving/front/card/index.js delete mode 100644 modules/shelving/front/card/index.spec.js delete mode 100644 modules/shelving/front/create/index.html delete mode 100644 modules/shelving/front/create/index.js delete mode 100644 modules/shelving/front/create/index.spec.js delete mode 100644 modules/shelving/front/descriptor/index.html delete mode 100644 modules/shelving/front/descriptor/index.js delete mode 100644 modules/shelving/front/descriptor/index.spec.js delete mode 100644 modules/shelving/front/descriptor/locale/es.yml delete mode 100644 modules/shelving/front/index/index.html delete mode 100644 modules/shelving/front/index/index.js delete mode 100644 modules/shelving/front/index/index.spec.js delete mode 100644 modules/shelving/front/index/locale/es.yml delete mode 100644 modules/shelving/front/log/index.html delete mode 100644 modules/shelving/front/log/index.js delete mode 100644 modules/shelving/front/log/locale/es.yml delete mode 100644 modules/shelving/front/search-panel/index.html delete mode 100644 modules/shelving/front/search-panel/index.js delete mode 100644 modules/shelving/front/search-panel/locale/es.yml delete mode 100644 modules/shelving/front/summary/index.html delete mode 100644 modules/shelving/front/summary/index.js delete mode 100644 modules/shelving/front/summary/locale/es.yml delete mode 100644 modules/shelving/front/summary/style.scss diff --git a/modules/shelving/front/basic-data/index.html b/modules/shelving/front/basic-data/index.html deleted file mode 100644 index 68d61e169..000000000 --- a/modules/shelving/front/basic-data/index.html +++ /dev/null @@ -1,52 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - -
\ No newline at end of file diff --git a/modules/shelving/front/basic-data/index.js b/modules/shelving/front/basic-data/index.js deleted file mode 100644 index e17c9feee..000000000 --- a/modules/shelving/front/basic-data/index.js +++ /dev/null @@ -1,10 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -ngModule.vnComponent('vnShelvingBasicData', { - template: require('./index.html'), - controller: Section, - bindings: { - shelving: '<' - } -}); diff --git a/modules/shelving/front/card/index.html b/modules/shelving/front/card/index.html deleted file mode 100644 index c83afc288..000000000 --- a/modules/shelving/front/card/index.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - diff --git a/modules/shelving/front/card/index.js b/modules/shelving/front/card/index.js deleted file mode 100644 index 4f571d876..000000000 --- a/modules/shelving/front/card/index.js +++ /dev/null @@ -1,29 +0,0 @@ -import ngModule from '../module'; -import ModuleCard from 'salix/components/module-card'; - -class Controller extends ModuleCard { - reload() { - const filter = { - include: [ - {relation: 'worker', - scope: { - fields: ['id'], - include: { - relation: 'user', - scope: { - fields: ['nickname'] - } - } - }}, - {relation: 'parking'} - ] - }; - this.$http.get(`Shelvings/${this.$params.id}`, {filter}) - .then(res => this.shelving = res.data); - } -} - -ngModule.vnComponent('vnShelvingCard', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/shelving/front/card/index.spec.js b/modules/shelving/front/card/index.spec.js deleted file mode 100644 index 85b1bd269..000000000 --- a/modules/shelving/front/card/index.spec.js +++ /dev/null @@ -1,26 +0,0 @@ -import './index'; - -describe('component vnShelvingCard', () => { - let controller; - let $httpBackend; - const data = {id: 1, code: 'AAA'}; - - beforeEach(ngModule('shelving')); - - beforeEach(inject(($componentController, _$httpBackend_, $stateParams) => { - $httpBackend = _$httpBackend_; - - let $element = angular.element('
'); - controller = $componentController('vnShelvingCard', {$element}); - - $stateParams.id = data.id; - $httpBackend.whenRoute('GET', 'Shelvings/:id').respond(data); - })); - - it('should reload the controller data', () => { - controller.reload(); - $httpBackend.flush(); - - expect(controller.shelving).toEqual(data); - }); -}); diff --git a/modules/shelving/front/create/index.html b/modules/shelving/front/create/index.html deleted file mode 100644 index edb3a7d3b..000000000 --- a/modules/shelving/front/create/index.html +++ /dev/null @@ -1,51 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - -
\ No newline at end of file diff --git a/modules/shelving/front/create/index.js b/modules/shelving/front/create/index.js deleted file mode 100644 index bb0e441eb..000000000 --- a/modules/shelving/front/create/index.js +++ /dev/null @@ -1,15 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - onSubmit() { - return this.$.watcher.submit().then(res => - this.$state.go('shelving.card.basicData', {id: res.data.id}) - ); - } -} - -ngModule.vnComponent('vnShelvingCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/shelving/front/create/index.spec.js b/modules/shelving/front/create/index.spec.js deleted file mode 100644 index 0bdde9145..000000000 --- a/modules/shelving/front/create/index.spec.js +++ /dev/null @@ -1,38 +0,0 @@ -import './index'; - -describe('Shelving', () => { - describe('Component vnShelvingCreate', () => { - let $scope; - let $state; - let controller; - - beforeEach(ngModule('shelving')); - - beforeEach(inject(($componentController, $rootScope, _$state_) => { - $scope = $rootScope.$new(); - $state = _$state_; - $scope.watcher = { - submit: () => { - return { - then: callback => { - callback({data: {id: 1}}); - } - }; - } - }; - const $element = angular.element(''); - controller = $componentController('vnShelvingCreate', {$element, $scope}); - controller.$params = {}; - })); - - describe('onSubmit()', () => { - it(`should redirect to basic data by calling the $state.go function`, () => { - jest.spyOn(controller.$state, 'go'); - - controller.onSubmit(); - - expect(controller.$state.go).toHaveBeenCalledWith('shelving.card.basicData', {id: 1}); - }); - }); - }); -}); diff --git a/modules/shelving/front/descriptor/index.html b/modules/shelving/front/descriptor/index.html deleted file mode 100644 index 53dd37258..000000000 --- a/modules/shelving/front/descriptor/index.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - Delete shelving - - - -
- - - - - - - {{::$ctrl.shelving.worker.user.nickname}} - - -
-
-
- - - - - - - diff --git a/modules/shelving/front/descriptor/index.js b/modules/shelving/front/descriptor/index.js deleted file mode 100644 index 931dbb6dc..000000000 --- a/modules/shelving/front/descriptor/index.js +++ /dev/null @@ -1,26 +0,0 @@ -import ngModule from '../module'; -import Descriptor from 'salix/components/descriptor'; - -class Controller extends Descriptor { - get shelving() { - return this.entity; - } - - set shelving(value) { - this.entity = value; - } - - onDelete() { - return this.$http.delete(`Shelvings/${this.shelving.id}`) - .then(() => this.$state.go('shelving.index')) - .then(() => this.vnApp.showSuccess(this.$t('Shelving removed'))); - } -} - -ngModule.vnComponent('vnShelvingDescriptor', { - template: require('./index.html'), - controller: Controller, - bindings: { - shelving: '<' - } -}); diff --git a/modules/shelving/front/descriptor/index.spec.js b/modules/shelving/front/descriptor/index.spec.js deleted file mode 100644 index 3ee33580b..000000000 --- a/modules/shelving/front/descriptor/index.spec.js +++ /dev/null @@ -1,29 +0,0 @@ -import './index.js'; - -describe('component vnShelvingDescriptor', () => { - let $httpBackend; - let controller; - - const shelving = {id: 1, code: 'AA6'}; - - beforeEach(ngModule('shelving')); - - beforeEach(inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnShelvingDescriptor', {$element: null}, {shelving}); - jest.spyOn(controller.vnApp, 'showSuccess'); - })); - - describe('onDelete()', () => { - it('should delete entity and go to index', () => { - controller.$state.go = jest.fn(); - - $httpBackend.expectDELETE('Shelvings/1').respond(); - controller.onDelete(); - $httpBackend.flush(); - - expect(controller.$state.go).toHaveBeenCalledWith('shelving.index'); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); -}); diff --git a/modules/shelving/front/descriptor/locale/es.yml b/modules/shelving/front/descriptor/locale/es.yml deleted file mode 100644 index e7fafc320..000000000 --- a/modules/shelving/front/descriptor/locale/es.yml +++ /dev/null @@ -1,3 +0,0 @@ -Delete shelving: Eliminar carro -Shelving will be removed: El carro será eliminado -Shelving removed: Carro eliminado diff --git a/modules/shelving/front/index.js b/modules/shelving/front/index.js index 2ad9bc1b9..a7209a0bd 100644 --- a/modules/shelving/front/index.js +++ b/modules/shelving/front/index.js @@ -1,11 +1,3 @@ export * from './module'; -import './basic-data'; -import './card'; -import './create'; -import './descriptor'; -import './index/'; import './main'; -import './search-panel'; -import './summary'; -import './log'; diff --git a/modules/shelving/front/index/index.html b/modules/shelving/front/index/index.html deleted file mode 100644 index 1532abd42..000000000 --- a/modules/shelving/front/index/index.html +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/shelving/front/index/index.js b/modules/shelving/front/index/index.js deleted file mode 100644 index 04d8ea9cd..000000000 --- a/modules/shelving/front/index/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - preview(shelving) { - this.selectedShelving = shelving; - this.$.summary.show(); - } -} - -ngModule.vnComponent('vnShelvingIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/shelving/front/index/index.spec.js b/modules/shelving/front/index/index.spec.js deleted file mode 100644 index aad79fb0e..000000000 --- a/modules/shelving/front/index/index.spec.js +++ /dev/null @@ -1,39 +0,0 @@ -import './index.js'; -describe('Component vnShelvingIndex', () => { - let controller; - let $window; - let shelvings = [{ - id: 1, - code: 'AAA' - }, { - id: 2, - code: 'AA1' - }, { - id: 3, - code: 'AA2' - }]; - - beforeEach(ngModule('shelving')); - - beforeEach(inject(($componentController, _$window_) => { - $window = _$window_; - const $element = angular.element(''); - controller = $componentController('vnShelvingIndex', {$element}); - })); - - describe('preview()', () => { - it('should show the dialog summary', () => { - controller.$.summary = {show: () => {}}; - jest.spyOn(controller.$.summary, 'show'); - - let event = new MouseEvent('click', { - view: $window, - bubbles: true, - cancelable: true - }); - controller.preview(event, shelvings[0]); - - expect(controller.$.summary.show).toHaveBeenCalledWith(); - }); - }); -}); diff --git a/modules/shelving/front/index/locale/es.yml b/modules/shelving/front/index/locale/es.yml deleted file mode 100644 index 4d30f4cee..000000000 --- a/modules/shelving/front/index/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -Parking: Parking -Priority: Prioridad \ No newline at end of file diff --git a/modules/shelving/front/log/index.html b/modules/shelving/front/log/index.html deleted file mode 100644 index 8f0e6851c..000000000 --- a/modules/shelving/front/log/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/modules/shelving/front/log/index.js b/modules/shelving/front/log/index.js deleted file mode 100644 index 588e0995a..000000000 --- a/modules/shelving/front/log/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -ngModule.vnComponent('vnShelvingLog', { - template: require('./index.html'), - controller: Section, -}); diff --git a/modules/shelving/front/log/locale/es.yml b/modules/shelving/front/log/locale/es.yml deleted file mode 100644 index c572b78d1..000000000 --- a/modules/shelving/front/log/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -Changed by: Cambiado por \ No newline at end of file diff --git a/modules/shelving/front/routes.json b/modules/shelving/front/routes.json index 4059e5095..7f6408cad 100644 --- a/modules/shelving/front/routes.json +++ b/modules/shelving/front/routes.json @@ -26,42 +26,6 @@ "state": "shelving.index", "component": "vn-shelving-index", "description": "Shelvings" - }, - { - "url": "/create", - "state": "shelving.create", - "component": "vn-shelving-create", - "description": "New shelving" - }, - { - "url": "/:id", - "state": "shelving.card", - "abstract": true, - "component": "vn-shelving-card" - }, - { - "url": "/summary", - "state": "shelving.card.summary", - "component": "vn-shelving-summary", - "description": "Summary", - "params": { - "shelving": "$ctrl.shelving" - } - }, - { - "url": "/basic-data", - "state": "shelving.card.basicData", - "component": "vn-shelving-basic-data", - "description": "Basic data", - "params": { - "shelving": "$ctrl.shelving" - } - }, - { - "url" : "/log", - "state": "shelving.card.log", - "component": "vn-shelving-log", - "description": "Log" } ] } diff --git a/modules/shelving/front/search-panel/index.html b/modules/shelving/front/search-panel/index.html deleted file mode 100644 index b7ca068a5..000000000 --- a/modules/shelving/front/search-panel/index.html +++ /dev/null @@ -1,43 +0,0 @@ -
-
- - - - - - - - - - - - - - - - - -
-
\ No newline at end of file diff --git a/modules/shelving/front/search-panel/index.js b/modules/shelving/front/search-panel/index.js deleted file mode 100644 index 51b81538b..000000000 --- a/modules/shelving/front/search-panel/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -ngModule.vnComponent('vnShelvingSearchPanel', { - template: require('./index.html'), - controller: SearchPanel -}); diff --git a/modules/shelving/front/search-panel/locale/es.yml b/modules/shelving/front/search-panel/locale/es.yml deleted file mode 100644 index bd19b1b33..000000000 --- a/modules/shelving/front/search-panel/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -Search shelvings by code: Busca carros por código \ No newline at end of file diff --git a/modules/shelving/front/summary/index.html b/modules/shelving/front/summary/index.html deleted file mode 100644 index 61e44d278..000000000 --- a/modules/shelving/front/summary/index.html +++ /dev/null @@ -1,51 +0,0 @@ - -
- - - - {{::$ctrl.summary.code}} -
- - -

- - Basic data - -

- - - - - - - - - - {{$ctrl.summary.worker.user.nickname}} - - - - - -
-
-
- - \ No newline at end of file diff --git a/modules/shelving/front/summary/index.js b/modules/shelving/front/summary/index.js deleted file mode 100644 index 91f8e2aa7..000000000 --- a/modules/shelving/front/summary/index.js +++ /dev/null @@ -1,41 +0,0 @@ -import ngModule from '../module'; -import Summary from 'salix/components/summary'; -import './style.scss'; - -class Controller extends Summary { - set shelving(value) { - this._shelving = value; - this.summary = null; - if (!value) return; - - const filter = { - include: [ - {relation: 'worker', - scope: { - fields: ['id'], - include: { - relation: 'user', - scope: { - fields: ['nickname'] - } - } - }}, - {relation: 'parking'} - ] - }; - this.$http.get(`Shelvings/${value.id}`, {filter}) - .then(res => this.summary = res.data); - } - - get shelving() { - return this._shelving; - } -} - -ngModule.vnComponent('vnShelvingSummary', { - template: require('./index.html'), - controller: Controller, - bindings: { - shelving: '<' - } -}); diff --git a/modules/shelving/front/summary/locale/es.yml b/modules/shelving/front/summary/locale/es.yml deleted file mode 100644 index d5d14d52a..000000000 --- a/modules/shelving/front/summary/locale/es.yml +++ /dev/null @@ -1,5 +0,0 @@ -Code: Código -Parking: Parking -Priority: Prioridad -Worker: Trabajador -Recyclable: Reciclable \ No newline at end of file diff --git a/modules/shelving/front/summary/style.scss b/modules/shelving/front/summary/style.scss deleted file mode 100644 index 1eb6b2323..000000000 --- a/modules/shelving/front/summary/style.scss +++ /dev/null @@ -1,7 +0,0 @@ -@import "variables"; - -vn-client-summary { - .alert span { - color: $color-alert - } -} \ No newline at end of file From b66111a03254d3f12618aa2b3a12930c4209599f Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 30 Apr 2024 13:33:46 +0200 Subject: [PATCH 26/31] refs #6895 remove tfront --- modules/shelving/front/main/index.spec.js | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 modules/shelving/front/main/index.spec.js diff --git a/modules/shelving/front/main/index.spec.js b/modules/shelving/front/main/index.spec.js deleted file mode 100644 index dcfa912bc..000000000 --- a/modules/shelving/front/main/index.spec.js +++ /dev/null @@ -1,19 +0,0 @@ -import './index'; - -describe('component vnShelving', () => { - let controller; - - beforeEach(ngModule('shelving')); - - beforeEach(inject($componentController => { - controller = $componentController('vnShelving', {$element: null}); - })); - - describe('exprBuilder()', () => { - it('should search by code', () => { - let expr = controller.exprBuilder('search', 'UXN'); - - expect(expr).toEqual({code: {like: '%UXN%'}},); - }); - }); -}); From b9267250216b6c84f26f28cacd8581a8d01f7d60 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 2 May 2024 08:04:44 +0200 Subject: [PATCH 27/31] hotfix: ticket#179915 Fix no worker exists --- db/routines/vn/triggers/ticketPackaging_beforeInsert.sql | 2 -- 1 file changed, 2 deletions(-) diff --git a/db/routines/vn/triggers/ticketPackaging_beforeInsert.sql b/db/routines/vn/triggers/ticketPackaging_beforeInsert.sql index a58955e0d..f47a7ae35 100644 --- a/db/routines/vn/triggers/ticketPackaging_beforeInsert.sql +++ b/db/routines/vn/triggers/ticketPackaging_beforeInsert.sql @@ -4,7 +4,5 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketPackaging_befor FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); - SET NEW.workerFk = account.myUser_getId(); - END$$ DELIMITER ; From ae15f4b5d1836e69db02193b495c0881ed2f01f8 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 2 May 2024 12:14:39 +0200 Subject: [PATCH 28/31] refs #6870 markdown --- loopback/locale/es.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index bc469523d..35b373795 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -277,7 +277,7 @@ "Collection does not exist": "La colección no existe", "Cannot obtain exclusive lock": "No se puede obtener un bloqueo exclusivo", "Insert a date range": "Inserte un rango de fechas", - "Added observation": "{{user}} añadió esta observacion: {{text}} {defaulterUrl}", + "Added observation": "{{user}} añadió esta observacion: {{text}} [{{clientFk}}]({{{defaulterUrl}}})", "Comment added to client": "Observación añadida al cliente {{clientFk}}", "Invalid auth code": "Código de verificación incorrecto", "Invalid or expired verification code": "Código de verificación incorrecto o expirado", From def15211310f8dff5f5c9223eb22796352877cc0 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 2 May 2024 12:42:17 +0200 Subject: [PATCH 29/31] refs #6870 defaulter id --- loopback/locale/es.json | 2 +- modules/client/back/methods/defaulter/observationEmail.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 35b373795..f1c57455e 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -277,7 +277,7 @@ "Collection does not exist": "La colección no existe", "Cannot obtain exclusive lock": "No se puede obtener un bloqueo exclusivo", "Insert a date range": "Inserte un rango de fechas", - "Added observation": "{{user}} añadió esta observacion: {{text}} [{{clientFk}}]({{{defaulterUrl}}})", + "Added observation": "{{user}} añadió esta observacion: {{text}} {{defaulterId}} ({{{defaulterUrl}}})", "Comment added to client": "Observación añadida al cliente {{clientFk}}", "Invalid auth code": "Código de verificación incorrecto", "Invalid or expired verification code": "Código de verificación incorrecto o expirado", diff --git a/modules/client/back/methods/defaulter/observationEmail.js b/modules/client/back/methods/defaulter/observationEmail.js index 5b13e8282..c06d1d3d0 100644 --- a/modules/client/back/methods/defaulter/observationEmail.js +++ b/modules/client/back/methods/defaulter/observationEmail.js @@ -40,6 +40,7 @@ module.exports = Self => { const body = $t('Added observation', { user: user.name, text: observation, + defaulterId: defaulter.clientFk, defaulterUrl: `${url}client/${defaulter.clientFk}/summary` }); From 9e2332ca4a26ba7c69876c71c3bd58eeff2088d3 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 2 May 2024 12:48:11 +0200 Subject: [PATCH 30/31] refs #6895 state home --- modules/shelving/front/main/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/shelving/front/main/index.js b/modules/shelving/front/main/index.js index a4a6031a4..4e45a7dd3 100644 --- a/modules/shelving/front/main/index.js +++ b/modules/shelving/front/main/index.js @@ -6,8 +6,8 @@ export default class Shelving extends ModuleMain { super($element, $); } async $onInit() { - const url = await this.vnApp.getUrl(`shelving/`); - window.location.href = url; + this.$state.go('home'); + window.location.href = await this.vnApp.getUrl(`shelving/`); } } From b6e413018447b4d7ef61d9c712d245e09da4000f Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 3 May 2024 07:51:04 +0200 Subject: [PATCH 31/31] feat: refs #7325 item_getBalance --- db/routines/vn/procedures/item_getBalance.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/item_getBalance.sql b/db/routines/vn/procedures/item_getBalance.sql index 11af7e570..88583cf00 100644 --- a/db/routines/vn/procedures/item_getBalance.sql +++ b/db/routines/vn/procedures/item_getBalance.sql @@ -179,7 +179,7 @@ BEGIN LEFT JOIN alertLevel a ON a.id = t.alertLevel; ELSE - SELECT SUM(`in`) - SUM(`out`) INTO @a + SELECT IFNULL(SUM(IFNULL(`in`, 0)) - SUM(IFNULL(`out`, 0)), 0) INTO @a FROM tItemDiary WHERE shipped < vDate;